Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Propagate runtime approval and sandbox settings to turn startup

Julius Marminge57dd091e0590
diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
index 3c59e54cb..c41ce614a 100644
--- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
+++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
@@ -171,6 +171,8 @@ describe("ProviderCommandReactor", () => {
text: "hello reactor",
attachments: [],
},
+ approvalPolicy: "on-request",
+ sandboxMode: "workspace-write",
createdAt: now,
}),
);
@@ -181,6 +183,8 @@ describe("ProviderCommandReactor", () => {
expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({
cwd: "/tmp/provider-project",
model: "gpt-5-codex",
+ approvalPolicy: "on-request",
+ sandboxMode: "workspace-write",
});
const readModel = await Effect.runPromise(harness.engine.getReadModel());
diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
index dc08566ae..ecba45185 100644
--- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
+++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
@@ -3,7 +3,9 @@ import {
CommandId,
EventId,
type OrchestrationEvent,
+ type ProviderApprovalPolicy,
type ProviderKind,
+ type ProviderSandboxMode,
type OrchestrationSession,
type ThreadId,
type TurnId,
@@ -128,6 +130,10 @@ const make = Effect.gen(function* () {
const ensureSessionForThread = Effect.fnUntraced(function* (
threadId: ThreadId,
createdAt: string,
+ options?: {
+ readonly approvalPolicy?: ProviderApprovalPolicy;
+ readonly sandboxMode?: ProviderSandboxMode;
+ },
) {
const readModel = yield* orchestrationEngine.getReadModel();
const thread = readModel.threads.find((entry) => entry.id === threadId);
@@ -153,6 +159,8 @@ const make = Effect.gen(function* () {
...(preferredProvider ? { provider: preferredProvider } : {}),
...(effectiveCwd ? { cwd: effectiveCwd } : {}),
...(thread.model ? { model: thread.model } : {}),
+ ...(options?.approvalPolicy !== undefined ? { approvalPolicy: options.approvalPolicy } : {}),
+ ...(options?.sandboxMode !== undefined ? { sandboxMode: options.sandboxMode } : {}),
});
yield* setThreadSession({
@@ -180,13 +188,18 @@ const make = Effect.gen(function* () {
readonly attachments?: ReadonlyArray<ChatAttachment>;
readonly model?: string;
readonly effort?: string;
+ readonly approvalPolicy?: ProviderApprovalPolicy;
+ readonly sandboxMode?: ProviderSandboxMode;
readonly createdAt: string;
}) {
const thread = yield* resolveThread(input.threadId);
if (!thread) {
return;
}
- const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt);
+ const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt, {
+ ...(input.approvalPolicy !== undefined ? { approvalPolicy: input.approvalPolicy } : {}),
+ ...(input.sandboxMode !== undefined ? { sandboxMode: input.sandboxMode } : {}),
+ });
const normalizedInput = toNonEmptyProviderInput(input.messageText);
const normalizedAttachments = input.attachments ?? [];
@@ -232,6 +245,8 @@ const make = Effect.gen(function* () {
...(event.payload.model !== undefined ? { model: event.payload.model } : {}),
...(event.payload.effort !== undefined ? { effort: event.payload.effort } : {}),
createdAt: event.payload.createdAt,
+ approvalPolicy: event.payload.approvalPolicy,
+ sandboxMode: event.payload.sandboxMode,
});
});
diff --git a/apps/server/src/orchestration/decider.projectScripts.test.ts b/apps/server/src/orchestration/decider.projectScripts.test.ts
index 9973219f6..6d528614d 100644
--- a/apps/server/src/orchestration/decider.projectScripts.test.ts
+++ b/apps/server/src/orchestration/decider.projectScripts.test.ts
@@ -152,6 +152,8 @@ describe("decider project scripts", () => {
},
model: "gpt-5",
effort: "high",
+ approvalPolicy: "on-request",
+ sandboxMode: "workspace-write",
createdAt: now,
},
readModel,
@@ -169,5 +171,13 @@ describe("decider project scripts", () => {
return;
}
expect(turnStartEvent.payload.assistantDeliveryMode).toBe("buffered");
+ expect(turnStartEvent.payload).toMatchObject({
+ threadId: ThreadId.makeUnsafe("thread-1"),
+ messageId: asMessageId("message-user-1"),
+ model: "gpt-5",
+ effort: "high",
+ approvalPolicy: "on-request",
+ sandboxMode: "workspace-write",
+ });
});
});
diff --git a/apps/server/src/orchestration/decider.ts b/apps/server/src/orchestration/decider.ts
index 91e7d756e..9599b4c05 100644
--- a/apps/server/src/orchestration/decider.ts
+++ b/apps/server/src/orchestration/decider.ts
@@ -254,6 +254,10 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
...(command.model !== undefined ? { model: command.model } : {}),
...(command.effort !== undefined ? { effort: command.effort } : {}),
assistantDeliveryMode: command.assistantDeliveryMode ?? DEFAULT_ASSISTANT_DELIVERY_MODE,
+ ...(command.approvalPolicy !== undefined
+ ? { approvalPolicy: command.approvalPolicy }
+ : {}),
+ ...(command.sandboxMode !== undefined ? { sandboxMode: command.sandboxMode } : {}),
createdAt: command.createdAt,
},
};
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 64ac9e1bd..7ae68e537 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -1522,6 +1522,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
),
);
attemptedTurnStart = true;
+ const approvalPolicy = state.runtimeMode === "full-access" ? "never" : "on-request";
+ const sandboxMode =
+ state.runtimeMode === "full-access" ? "danger-full-access" : "workspace-write";
await api.orchestration.dispatchCommand({
type: "thread.turn.start",
commandId: newCommandId(),
@@ -1535,6 +1538,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
model: selectedModel || undefined,
effort: selectedEffort || undefined,
assistantDeliveryMode: settings.enableAssistantStreaming ? "streaming" : "buffered",
+ approvalPolicy,
+ sandboxMode,
createdAt: messageCreatedAt,
});
} catch (err) {
diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts
index c2f25d4e0..cf69a8db8 100644
--- a/packages/contracts/src/orchestration.ts
+++ b/packages/contracts/src/orchestration.ts
@@ -282,6 +282,8 @@ export const ThreadTurnStartCommand = Schema.Struct({
model: Schema.optional(TrimmedNonEmptyString),
effort: Schema.optional(TrimmedNonEmptyString),
assistantDeliveryMode: Schema.optional(AssistantDeliveryMode),
+ approvalPolicy: Schema.optional(ProviderApprovalPolicy),
+ sandboxMode: Schema.optional(ProviderSandboxMode),
createdAt: IsoDateTime,
});
@@ -496,6 +498,8 @@ export const ThreadTurnStartRequestedPayload = Schema.Struct({
model: Schema.optional(TrimmedNonEmptyString),
effort: Schema.optional(TrimmedNonEmptyString),
assistantDeliveryMode: Schema.optional(AssistantDeliveryMode),
+ approvalPolicy: Schema.optional(ProviderApprovalPolicy),
+ sandboxMode: Schema.optional(ProviderSandboxMode),
createdAt: IsoDateTime,
});