Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ function ThreadSettingsSessionProvider(
const compatibleRuntimeMode = compatibleRuntimeModeForChoices(
props.runtimeMode,
runtimeModeChoices,
config?.managedPolicy,
);

const hasLegacyModels = props.providerGroups.some((group) =>
Expand Down
19 changes: 14 additions & 5 deletions apps/mobile/src/features/threads/thread-settings-options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { managedRuntimeModeDenial } from "@t3tools/client-runtime/contract-labels";
import type { ManagedPolicySummary, RuntimeMode } from "@t3tools/contracts";
import {
type ManagedPolicySummary,
providerRuntimeMode,
type RuntimeMode,
} from "@t3tools/contracts";
import { msg } from "gt-react-native";

import { m, type MessageResolver } from "../../i18n/messages";
Expand All @@ -22,7 +26,9 @@ export const RUNTIME_MODE_CHOICES: ReadonlyArray<{
{
mode: "auto",
label: msg("Auto"),
description: msg("Supported providers approve routine actions; others still ask."),
description: msg(
"Supported providers approve routine actions; providers without Auto get Full access.",
),
},
{
mode: "full-access",
Expand Down Expand Up @@ -78,10 +84,13 @@ export function resolveNewThreadRuntimeMode(
export function compatibleRuntimeModeForChoices(
runtimeMode: RuntimeMode,
choices: ReadonlyArray<{ readonly mode: RuntimeMode }>,
managedPolicy: ManagedPolicySummary | undefined,
): RuntimeMode {
return choices.some((choice) => choice.mode === runtimeMode)
? runtimeMode
: (choices[0]?.mode ?? runtimeMode);
return providerRuntimeMode(
runtimeMode,
choices.map((choice) => choice.mode),
managedPolicy?.limits?.maxRuntimeMode,
);
}

export { selectableProviderOptionChoices as selectableChoices } from "@t3tools/client-runtime/model-traits";
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -4917,7 +4917,7 @@
"cceea5cef0684b31": "Änderungen automatisch annehmen",
"3fe210c30bf00152": "Änderungen automatisch genehmigen, vor anderen Aktionen nachfragen.",
"fd064d8807f0aaa2": "Auto",
"451204c240ead696": "Unterstützte Anbieter genehmigen Routineaktionen; andere fragen weiterhin nach.",
"d9efd017a6b1f019": "Unterstützte Anbieter genehmigen Routineaktionen; Anbieter ohne Auto erhalten Vollzugriff.",
"1eed3d794eed6b65": "Vollzugriff",
"7f284f51644bb125": "Befehle und Änderungen ohne Nachfrage erlauben.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4919,7 +4919,7 @@
"cceea5cef0684b31": "Auto-accept edits",
"3fe210c30bf00152": "Auto-approve edits, ask before other actions.",
"fd064d8807f0aaa2": "Auto",
"451204c240ead696": "Supported providers approve routine actions; others still ask.",
"d9efd017a6b1f019": "Supported providers approve routine actions; providers without Auto get Full access.",
"1eed3d794eed6b65": "Full access",
"7f284f51644bb125": "Allow commands and edits without prompts.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4910,7 +4910,7 @@
"cceea5cef0684b31": "Aceptar ediciones automáticamente",
"3fe210c30bf00152": "Aprueba las ediciones automáticamente y pregunta antes de otras acciones.",
"fd064d8807f0aaa2": "Automático",
"451204c240ead696": "Los proveedores compatibles aprueban las acciones rutinarias; los demás siguen preguntando.",
"d9efd017a6b1f019": "Los proveedores compatibles aprueban las acciones rutinarias; los que no tienen Automático obtienen Acceso completo.",
"1eed3d794eed6b65": "Acceso completo",
"7f284f51644bb125": "Permite comandos y ediciones sin preguntar.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,7 @@
"cceea5cef0684b31": "Accepter les modifications automatiquement",
"3fe210c30bf00152": "Approuver automatiquement les modifications, demander avant les autres actions.",
"fd064d8807f0aaa2": "Auto",
"451204c240ead696": "Les fournisseurs compatibles approuvent les actions courantes ; les autres demandent toujours.",
"d9efd017a6b1f019": "Les fournisseurs compatibles approuvent les actions courantes ; ceux sans Auto obtiennent un Accès complet.",
"1eed3d794eed6b65": "Accès complet",
"7f284f51644bb125": "Autoriser les commandes et les modifications sans demander.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -4891,7 +4891,7 @@
"cceea5cef0684b31": "編集を自動承認",
"3fe210c30bf00152": "編集は自動承認し、その他の操作の前に確認します。",
"fd064d8807f0aaa2": "自動",
"451204c240ead696": "対応しているプロバイダーは日常的な操作を承認し、それ以外は確認します。",
"d9efd017a6b1f019": "対応しているプロバイダーは日常的な操作を承認し、自動に対応していないプロバイダーはフルアクセスになります。",
"1eed3d794eed6b65": "フルアクセス",
"7f284f51644bb125": "確認なしでコマンドと編集を許可します。",
"3bb848279618550f": "{label}、{summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -4896,7 +4896,7 @@
"cceea5cef0684b31": "편집 자동 수락",
"3fe210c30bf00152": "편집은 자동 승인하고 다른 작업 전에는 확인합니다.",
"fd064d8807f0aaa2": "자동",
"451204c240ead696": "지원되는 제공자는 일상적인 작업을 승인하고, 나머지는 계속 확인합니다.",
"d9efd017a6b1f019": "지원되는 제공자는 일상적인 작업을 승인하고, 자동을 지원하지 않는 제공자는 전체 액세스로 실행됩니다.",
"1eed3d794eed6b65": "전체 액세스",
"7f284f51644bb125": "확인 없이 명령과 편집을 허용합니다.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,7 @@
"cceea5cef0684b31": "Aceitar edições automaticamente",
"3fe210c30bf00152": "Aprova edições automaticamente e pergunta antes de outras ações.",
"fd064d8807f0aaa2": "Automático",
"451204c240ead696": "Os provedores compatíveis aprovam ações rotineiras; os outros continuam perguntando.",
"d9efd017a6b1f019": "Os provedores compatíveis aprovam ações rotineiras; os que não têm Auto recebem Acesso total.",
"1eed3d794eed6b65": "Acesso total",
"7f284f51644bb125": "Permite comandos e edições sem perguntar.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -4989,7 +4989,7 @@
"cceea5cef0684b31": "Автопринятие правок",
"3fe210c30bf00152": "Автоматически подтверждать правки, спрашивать перед другими действиями.",
"fd064d8807f0aaa2": "Авто",
"451204c240ead696": "Поддерживаемые провайдеры подтверждают рутинные действия; остальные всё равно спрашивают.",
"d9efd017a6b1f019": "Поддерживаемые провайдеры подтверждают рутинные действия; провайдеры без режима «Авто» получают полный доступ.",
"1eed3d794eed6b65": "Полный доступ",
"7f284f51644bb125": "Разрешать команды и правки без запросов.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -4917,7 +4917,7 @@
"cceea5cef0684b31": "Godkänn ändringar automatiskt",
"3fe210c30bf00152": "Godkänn ändringar automatiskt, fråga före andra åtgärder.",
"fd064d8807f0aaa2": "Auto",
"451204c240ead696": "Leverantörer som stöder det godkänner rutinåtgärder; andra frågar fortfarande.",
"d9efd017a6b1f019": "Leverantörer som stöder det godkänner rutinåtgärder; leverantörer utan Auto får full åtkomst.",
"1eed3d794eed6b65": "Full åtkomst",
"7f284f51644bb125": "Tillåt kommandon och ändringar utan att fråga.",
"3bb848279618550f": "{label}, {summary}",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -4900,7 +4900,7 @@
"cceea5cef0684b31": "自动接受编辑",
"3fe210c30bf00152": "自动批准编辑,其他操作前询问。",
"fd064d8807f0aaa2": "自动",
"451204c240ead696": "支持此模式的提供方会自动批准常规操作,其他提供方仍会询问。",
"d9efd017a6b1f019": "支持此模式的提供方会自动批准常规操作,不支持自动模式的提供方将获得完全访问。",
"1eed3d794eed6b65": "完全访问",
"7f284f51644bb125": "允许执行命令和编辑,无需确认。",
"3bb848279618550f": "{label},{summary}",
Expand Down
5 changes: 4 additions & 1 deletion apps/server/src/mcp/OrchestratorMcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5020,7 +5020,10 @@ describe("OrchestratorMcpService provider resolution", () => {
it.effect("steps an inherited mode down to the broadest one the provider offers", () =>
Effect.gen(function* () {
assert.equal(yield* resolveRuntimeMode("full-access", "inherit", muse), "full-access");
assert.equal(yield* resolveRuntimeMode("auto", undefined, muse), "approval-required");
assert.equal(
yield* resolveRuntimeMode("auto-accept-edits", undefined, muse),
"approval-required",
);
}),
);
});
Expand Down
12 changes: 9 additions & 3 deletions apps/server/src/mcp/delegatedTaskModes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export function interactionModeRank(mode: ProviderInteractionMode): number {

/**
* The mode a child runs at: the one asked for, never broader than its parent's.
* An inherited mode the target provider does not offer steps down to the
* broadest one it does; an explicitly requested one is refused instead.
* Auto is kept where the target lacks it: RuntimePolicy runs it as that
* provider's broadest mode. Any other inherited mode the target does not offer
* steps down to the broadest one it does; an explicit one is refused instead.
*/
export function resolveRuntimeMode(
parentMode: RuntimeMode,
Expand All @@ -52,7 +53,12 @@ export function resolveRuntimeMode(
);
}
const supported = target?.supportedRuntimeModes;
if (supported === undefined || supported.length === 0 || supported.includes(resolved)) {
if (
supported === undefined ||
supported.length === 0 ||
supported.includes(resolved) ||
resolved === "auto"
) {
return Effect.succeed(resolved);
}
if (!inherited) {
Expand Down
9 changes: 4 additions & 5 deletions apps/server/src/mcp/toolkits/project/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ it.effect(
}),
);

it.effect("a launch steps an inherited mode down to the provider's, and refuses one it lacks", () =>
it.effect("a launch keeps auto on a provider without it", () =>
Effect.gen(function* () {
// Pi offers no Auto; a mode a provider lacks would run as Supervised.
// Pi offers no Auto; RuntimePolicy runs an Auto thread there in Full access.
const pi = ProviderInstanceId.make("pi");
const launchPi = Effect.fn("test.launchPi")(function* (runtimeMode?: RuntimeMode) {
const launched: Array<ThreadLaunch.ThreadLaunchInput> = [];
Expand Down Expand Up @@ -369,11 +369,10 @@ it.effect("a launch steps an inherited mode down to the provider's, and refuses
});

const inherited = yield* launchPi();
expect(inherited.launched[0]?.runtimeMode).toBe("auto-accept-edits");
expect(inherited.launched[0]?.runtimeMode).toBe("auto");

const requested = yield* launchPi("auto");
expect(requested.result).toMatchObject({ code: "invalid_request" });
expect(requested.launched).toHaveLength(0);
expect(requested.launched[0]?.runtimeMode).toBe("auto");

const offered = yield* launchPi("approval-required");
expect(offered.launched[0]?.runtimeMode).toBe("approval-required");
Expand Down
15 changes: 12 additions & 3 deletions apps/server/src/orchestration-v2/RuntimePolicy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type OrchestrationV2AppThread,
ProjectId,
ProviderInstanceId,
providerRuntimeMode,
type RuntimeMode,
type ServerProvider,
ThreadId,
Expand Down Expand Up @@ -166,7 +167,7 @@ const layerTaskFolderPolicy = layerWithPolicy(
).pipe(Layer.provideMerge(layerTaskFolderStore));

it.layer(layerTest)("RuntimePolicyV2", (it) => {
it.effect("asks for Antigravity command approval when a stored Auto thread falls back", () =>
it.effect("runs a stored Auto thread on Antigravity without Auto in Full access", () =>
Effect.gen(function* () {
const policy = yield* RuntimePolicy.RuntimePolicyV2;
const now = yield* DateTime.now;
Expand All @@ -181,8 +182,16 @@ it.layer(layerTest)("RuntimePolicyV2", (it) => {
options: [{ optionId: "allow", name: "Allow", kind: "allow_once" as const }],
};
const auto = yield* resolve("auto");
assert.equal(auto.runtimeMode, "approval-required");
assert.equal(acpPermissionDisposition(auto, request), "ask");
assert.equal(auto.runtimeMode, "full-access");
assert.equal(acpPermissionDisposition(auto, request), "allow");
assert.equal(
providerRuntimeMode(
"auto",
supportedRuntimeModesByInstance.get(antigravityInstanceId),
"auto",
),
"auto-accept-edits",
);
assert.equal(acpPermissionDisposition(yield* resolve("auto-accept-edits"), request), "ask");
assert.equal(acpPermissionDisposition(yield* resolve("full-access"), request), "allow");
}),
Expand Down
18 changes: 6 additions & 12 deletions apps/server/src/orchestration-v2/RuntimePolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
OrchestrationV2AppThread,
ProjectId,
ProviderInstanceId,
providerRuntimeMode,
RuntimeMode,
ThreadId,
} from "@t3tools/contracts";
Expand Down Expand Up @@ -89,17 +90,6 @@ export const layer: Layer.Layer<RuntimePolicyV2> = Layer.succeed(RuntimePolicyV2
}),
});

export function providerRuntimeMode(
runtimeMode: RuntimeMode,
supportedRuntimeModes: ReadonlyArray<RuntimeMode> | undefined,
): RuntimeMode {
return supportedRuntimeModes === undefined ||
supportedRuntimeModes.length === 0 ||
supportedRuntimeModes.includes(runtimeMode)
? runtimeMode
: "approval-required";
}

const refuseAboveCeiling = (
managedPolicy: ServerSettings.ServerSettingsService["Service"]["managedPolicy"],
thread: OrchestrationV2AppThread,
Expand Down Expand Up @@ -201,7 +191,11 @@ export const layerFromProjectStore: Layer.Layer<
),
);
return ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: providerRuntimeMode(input.thread.runtimeMode, supportedRuntimeModes),
runtimeMode: providerRuntimeMode(
input.thread.runtimeMode,
supportedRuntimeModes,
maxRuntimeMode,
),
interactionMode: input.thread.interactionMode,
cwd,
...(maxRuntimeMode === undefined ? {} : { maxRuntimeMode }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe } from "@effect/vitest";
import { providerRuntimeMode } from "@t3tools/contracts";
import { FX_SUPPORTED_RUNTIME_MODES } from "@t3tools/provider-fx/testing";

import { FxOrchestratorReplayHarness } from "../Adapters/FxAdapterV2.testkit.ts";
import { providerRuntimeMode } from "../RuntimePolicy.ts";
import { itRunsReplayFixtures, runReplayFixture } from "./ProviderReplayFixtures.ts";

describe("fx replay fixtures", () => {
Expand Down
27 changes: 12 additions & 15 deletions apps/server/src/provider/AntigravityProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,20 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => {
}),
);

it.effect("offers Auto only while the signed-in session advertises agy's own Auto", () =>
it.effect("offers Auto until a signed-in session reports it lacks agy's own Auto", () =>
Effect.gen(function* () {
const harness = yield* makeHarness();
yield* harness.initialize;
const supportedModes = harness.provider.snapshot.getSnapshot.pipe(
Effect.map((snapshot) => snapshot.supportedRuntimeModes),
);
const withoutAuto = ["approval-required", "auto-accept-edits", "full-access"];
const withAuto: ReadonlyArray<RuntimeMode> = [
"approval-required",
"auto-accept-edits",
"auto",
"full-access",
];
const startedWithAuto = {
...started,
sessionSetupResult: {
Expand All @@ -376,30 +382,21 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => {
},
},
};
expect(yield* supportedModes).toEqual(withAuto);
yield* harness.provider.onSessionStarted(started);
expect(yield* supportedModes).toEqual(withoutAuto);
yield* harness.provider.onSessionStarted(startedWithAuto);
expect(yield* supportedModes).toEqual([
"approval-required",
"auto-accept-edits",
"auto",
"full-access",
]);
expect(yield* supportedModes).toEqual(withAuto);
yield* harness.provider.onSessionStarted(started);
expect(yield* supportedModes).toEqual(withoutAuto);
yield* harness.provider.onSessionStarted(startedWithAuto);
yield* harness.provider.onSignedOut;
expect(yield* supportedModes).toEqual(withoutAuto);
const withAuto: ReadonlyArray<RuntimeMode> = [
"approval-required",
"auto-accept-edits",
"auto",
"full-access",
];
expect(yield* supportedModes).toEqual(withAuto);
expect(yield* Ref.get(harness.savedRuntimeModes)).toEqual([
withAuto,
withoutAuto,
withAuto,
withoutAuto,
withAuto,
]);

// A restart offers what the last session advertised before any session starts.
Expand Down
16 changes: 12 additions & 4 deletions apps/server/src/provider/AntigravityProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,16 @@ const RUNTIME_MODES_WITHOUT_AUTO = [
"auto-accept-edits",
"full-access",
] as const;
// Before a session reports agy's Auto, Auto is offered: Full access could exceed a native Auto, and a
// session without it asks about each request under an Auto policy.
const RUNTIME_MODES_UNKNOWN = [
"approval-required",
"auto-accept-edits",
"auto",
"full-access",
] as const;

/** Auto is offered only where the session advertises agy's own Auto; elsewhere it runs Supervised. */
/** Auto is offered only where the session advertises agy's own Auto; elsewhere it runs Full access. */
function antigravityRuntimeModes(
sessionSetupResult: AcpSessionRuntime.AcpSessionRuntimeStartResult["sessionSetupResult"],
): ReadonlyArray<RuntimeMode> {
Expand Down Expand Up @@ -212,7 +220,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
presentation: {
displayName: "Antigravity",
showInteractionModeToggle: false,
supportedRuntimeModes: options.rememberedRuntimeModes ?? RUNTIME_MODES_WITHOUT_AUTO,
supportedRuntimeModes: options.rememberedRuntimeModes ?? RUNTIME_MODES_UNKNOWN,
},
enabled: settings.enabled,
checkedAt,
Expand Down Expand Up @@ -526,13 +534,13 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
slashCommands: [],
skills: [],
workspaceSnapshots: [],
supportedRuntimeModes: RUNTIME_MODES_WITHOUT_AUTO,
supportedRuntimeModes: RUNTIME_MODES_UNKNOWN,
supportsTextGeneration: false,
usageLimits: undefined,
},
} satisfies AntigravityProviderState,
]);
yield* rememberRuntimeModes(previousModes, RUNTIME_MODES_WITHOUT_AUTO);
yield* rememberRuntimeModes(previousModes, RUNTIME_MODES_UNKNOWN);
discoveredSkills.clear();
thinkingLevels.clear();
});
Expand Down
Loading
Loading