diff --git a/apps/server/package.json b/apps/server/package.json index 789d612e6fe3b..e68aac46911ef 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -33,7 +33,7 @@ "generate:expo-schema": "node scripts/fetch-expo-schema.ts" }, "dependencies": { - "@anthropic-ai/claude-agent-sdk": "^0.3.276", + "@anthropic-ai/claude-agent-sdk": "^0.3.288", "@cursor/sdk": "1.0.38", "@effect/platform-node": "catalog:", "@effect/platform-node-shared": "catalog:", diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 40f33b3a1a309..72d0096232afd 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -4007,6 +4007,161 @@ describe("ClaudeAdapterV2 background wake turns", () => { ); }); + describe("Full access safety checks", () => { + // Before 0.3.288 the SDK dropped decisionReasonType; rule, hook and plugin asks look the same. + const legacyShape = { + decisionReason: "Dangerous rm operation not ruled out", + suppressAlwaysAllowRule: true, + }; + const safetyCheck = { ...legacyShape, decisionReasonType: "safetyCheck" }; + const bypass = "bypassPermissions"; + + it.effect.each([ + { + name: "approves a safety check", + approve: true, + check: safetyCheck, + cliMode: bypass, + asks: false, + }, + { + name: "asks for a safety check", + approve: false, + check: safetyCheck, + cliMode: bypass, + asks: true, + }, + { + name: "asks for a safety check an ask rule matched", + approve: true, + check: { + ...safetyCheck, + matchedAskRule: { source: "userSettings", toolName: "Bash", ruleContent: "rm:*" }, + }, + cliMode: bypass, + asks: true, + }, + { + name: "asks without a decision type", + approve: true, + check: legacyShape, + cliMode: bypass, + asks: true, + }, + { + name: "asks for a rule ask", + approve: true, + check: { ...legacyShape, decisionReasonType: "rule" }, + cliMode: bypass, + asks: true, + }, + { + name: "asks for a hook ask", + approve: true, + check: { ...legacyShape, decisionReasonType: "hook" }, + cliMode: bypass, + asks: true, + }, + { + name: "asks for an ask of another type", + approve: true, + check: { ...legacyShape, decisionReasonType: "other" }, + cliMode: bypass, + asks: true, + }, + { + name: "asks for a safety check only a person may answer", + approve: true, + check: { ...safetyCheck, requiresUserInteraction: true }, + cliMode: bypass, + asks: true, + }, + { + name: "asks after the CLI leaves bypass", + approve: true, + check: safetyCheck, + cliMode: "default", + asks: true, + }, + { + name: "asks before the CLI reports its mode", + approve: true, + check: safetyCheck, + cliMode: null, + asks: true, + }, + { + name: "asks for a subagent safety check", + approve: true, + check: { ...safetyCheck, agentID: "child-worker" }, + cliMode: bypass, + asks: true, + }, + ] as const)("$name when the setting is $approve", ({ approve, check, cliMode, asks }) => + Effect.gen(function* () { + const harness = yield* makeWakeHarnessWithOptions({ + settings: { ...DEFAULT_CLAUDE_SETTINGS, approveSafetyChecksInFullAccess: approve }, + }); + yield* harness.runtime.startTurn( + makeClaudeTestTurnInput({ + threadId: harness.threadId, + providerThread: harness.providerThread, + now: yield* DateTime.now, + attemptId: RunAttemptId.make("attempt-claude-safety-check"), + text: "Clean the build output.", + attachments: [], + }), + ); + assert.equal(harness.getOpenedOptions()?.permissionMode, "bypassPermissions"); + if (cliMode !== null) { + yield* harness.offerAndWait( + claudeSdkFrame({ + type: "system", + subtype: "init", + permissionMode: cliMode, + uuid: "safety-check-cli-init", + session_id: WAKE_NATIVE_SESSION, + }), + ); + } + const toolInput = { command: 'rm -rf "$OUT"/build' }; + const decision = yield* Effect.promise(() => + harness.getOpenedOptions()!.canUseTool!("Bash", toolInput, { + signal: new AbortController().signal, + toolUseID: "safety-check", + requestId: "request-safety-check", + ...check, + }), + ).pipe(Effect.forkScoped); + const first = yield* Effect.raceFirst( + Queue.take(harness.runtimeRequestReceipts).pipe( + Effect.map((event) => ({ type: "request", event }) as const), + ), + Fiber.join(decision).pipe( + Effect.map((result) => ({ type: "decision", result }) as const), + ), + ); + if (asks) { + assert.equal(first.type, "request", "the request was approved without asking"); + return; + } + assert.equal(first.type, "decision", "the safety check still asked"); + if (first.type === "decision") { + assert.deepEqual(first.result, { + behavior: "allow", + updatedInput: toolInput, + toolUseID: "safety-check", + }); + } + }).pipe( + Effect.scoped, + Effect.provide( + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer), + ), + ), + ); + }); + describe("Plan-mode tool approval", () => { const openPlanTurn = Effect.fn("openPlanTurn")(function* ( runtimeMode: "auto" | "full-access", diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts index 428e44e19020c..ebabe1c03db60 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts @@ -3371,6 +3371,16 @@ export function claudeApprovalPresentation(input: { }; } +// The SDK forwards the CLI's decision_reason_type and requires_user_interaction (since 0.3.288) +// without declaring them. The CLI sends requires_user_interaction only as true, never false. +function isClaudeSafetyCheckAsk(options: Parameters[2]): boolean { + return ( + "decisionReasonType" in options && + options.decisionReasonType === "safetyCheck" && + !("requiresUserInteraction" in options && options.requiresUserInteraction === true) + ); +} + export function permissionResultFromDecision(input: { readonly toolName: string; readonly decision: ProviderApprovalDecision; @@ -9644,17 +9654,35 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( callbackOptions.description ?? callbackOptions.decisionReason ?? summarizeClaudeToolRequest(toolName, nativeToolInput); + const presentation = claudeApprovalPresentation({ + permissionMode: context.queryPolicy.permissionMode, + prompt, + callbackOptions, + }); + const liveQuery = yield* Ref.get(queryContext); + if ( + adapterOptions.settings.approveSafetyChecksInFullAccess && + presentation.fullAccessOverride === "provider_check" && + isClaudeSafetyCheckAsk(callbackOptions) && + // A subagent can run in its own permission mode, which the parent cannot see. + callbackOptions.agentID === undefined && + // The CLI's mode frames can trail its asks, so require the bypass it confirmed. + liveQuery?.receivedInit === true && + liveQuery.permissionMode === "bypassPermissions" + ) { + return { + behavior: "allow", + updatedInput: toolInput, + toolUseID: callbackOptions.toolUseID, + } satisfies PermissionResult; + } const artifacts = yield* buildApprovalRequestArtifacts({ context, nativeItemId: nativeRequestId, nativeRequestId, requestKind, prompt, - presentation: claudeApprovalPresentation({ - permissionMode: context.queryPolicy.permissionMode, - prompt, - callbackOptions, - }), + presentation, }); const decision = yield* Deferred.make(); yield* Ref.update(pendingRuntimeRequests, (current) => { diff --git a/apps/server/src/provider/ProviderInstanceRegistry.test.ts b/apps/server/src/provider/ProviderInstanceRegistry.test.ts index dc9c94e854f68..ce242981bd47b 100644 --- a/apps/server/src/provider/ProviderInstanceRegistry.test.ts +++ b/apps/server/src/provider/ProviderInstanceRegistry.test.ts @@ -104,6 +104,7 @@ const makeClaudeConfig = (overrides: Partial): ClaudeSettings => launchArgs: "", autoCompactWindow: "", idleCompaction: "default", + approveSafetyChecksInFullAccess: false, ...overrides, }); diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts index aabfd0300eda5..3df2fd29d6f84 100644 --- a/apps/web/src/components/settings/settingsSearch.ts +++ b/apps/web/src/components/settings/settingsSearch.ts @@ -796,7 +796,7 @@ export const SETTINGS_SEARCH_ITEMS = [ title: "Providers", to: "/settings/providers", searchTerms: [ - "agents cli codex claude cursor grok fx opencode antigravity google sign in sign out install subscription instances authentication api key models configuration binary path config directory endpoint arguments environment variables display name accent color custom favorite hidden auto compact", + "agents cli codex claude cursor grok fx opencode antigravity google sign in sign out install subscription instances authentication api key models configuration binary path config directory endpoint arguments environment variables display name accent color custom favorite hidden auto compact full access safety checks", ], }, { diff --git a/docs/user/permission-modes.md b/docs/user/permission-modes.md index d7391de5b2249..3d1c07981b3ed 100644 --- a/docs/user/permission-modes.md +++ b/docs/user/permission-modes.md @@ -41,7 +41,11 @@ ACP Registry agents run their own tools in their own mode; T3 Code answers their by the permission mode. See [ACP Registry permissions](./providers-acp.md#permissions-and-terminals). Claude can still ask in **Full access** when its settings disable bypass permissions or require -approval for an action. +approval for an action, or when Claude Code's own safety checks flag a command. Turn on +**Approve safety checks in Full access** in the Claude provider settings to approve the main +agent's safety checks without asking. Claude still asks for a subagent's safety checks, checks it +says you must answer yourself, commands that match your ask rules, and any check before Claude +confirms Full access for the session. While a Claude approval is pending, type a text reply to decline that request and give feedback directly to the agent that asked, including a subagent. Other pending requests stay unanswered. diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 643d27296f34b..3a5d4b76931bb 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -767,9 +767,25 @@ export const ClaudeSettings = makeProviderSettingsSchema( }, }), ), + approveSafetyChecksInFullAccess: Schema.Boolean.pipe( + Schema.withDecodingDefault(Effect.succeed(false)), + Schema.annotateKey({ + title: "Approve safety checks in Full access", + description: + "Also approve commands that Claude Code's own safety checks flag. Your ask rules still prompt.", + providerSettingsForm: { control: "switch" }, + }), + ), }, { - order: ["binaryPath", "homePath", "autoCompactWindow", "idleCompaction", "launchArgs"], + order: [ + "binaryPath", + "homePath", + "autoCompactWindow", + "idleCompaction", + "approveSafetyChecksInFullAccess", + "launchArgs", + ], }, ); export type ClaudeSettings = typeof ClaudeSettings.Type; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 39c062c66dbdf..1351b5b4c6002 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -830,8 +830,8 @@ importers: apps/server: dependencies: '@anthropic-ai/claude-agent-sdk': - specifier: ^0.3.276 - version: 0.3.276(@anthropic-ai/sdk@0.93.0(zod@4.6.5))(@modelcontextprotocol/sdk@1.29.0(supports-color@8.1.1)(zod@4.6.5))(zod@4.6.5) + specifier: ^0.3.288 + version: 0.3.288(@anthropic-ai/sdk@0.93.0(zod@4.6.5))(@modelcontextprotocol/sdk@1.29.0(supports-color@8.1.1)(zod@4.6.5))(zod@4.6.5) '@cursor/sdk': specifier: 1.0.38 version: 1.0.38(zod@4.6.5) @@ -2602,8 +2602,8 @@ packages: pg: optional: true - '@anthropic-ai/claude-agent-sdk@0.3.276': - resolution: {integrity: sha512-Dic43v4uuGLhibPAArWy3RSfq3zHdn+4Oh2AI2/18a5tlbNKkvChEpazyp8c+grUJvzxkzt0jETCa1wrADbkyw==} + '@anthropic-ai/claude-agent-sdk@0.3.288': + resolution: {integrity: sha512-W0axvKSBKC8E1rMvriV8NVMFfNv8uwN3HnJxUiFLJOQcJLp1MDp0SoAugkAKTn3WLx3JnqCxxME6bGvfNJzJoA==} engines: {node: '>=18.0.0'} peerDependencies: '@anthropic-ai/sdk': '>=0.93.0' @@ -12553,7 +12553,7 @@ snapshots: '@effect/sql-pg': 4.0.5(effect@4.0.5) pg: 8.23.0 - '@anthropic-ai/claude-agent-sdk@0.3.276(@anthropic-ai/sdk@0.93.0(zod@4.6.5))(@modelcontextprotocol/sdk@1.29.0(supports-color@8.1.1)(zod@4.6.5))(zod@4.6.5)': + '@anthropic-ai/claude-agent-sdk@0.3.288(@anthropic-ai/sdk@0.93.0(zod@4.6.5))(@modelcontextprotocol/sdk@1.29.0(supports-color@8.1.1)(zod@4.6.5))(zod@4.6.5)': dependencies: '@anthropic-ai/sdk': 0.93.0(zod@4.6.5) '@modelcontextprotocol/sdk': 1.29.0(supports-color@8.1.1)(zod@4.6.5) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index be4d3c29ea763..bd3feacba6b78 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -171,7 +171,6 @@ minimumReleaseAgeExclude: - expo-sqlite@58.0.13 - expo-symbols@58.0.4 - electron@44.10.0 - - "@anthropic-ai/claude-agent-sdk@0.3.276" - "@shadcn/lint@0.1.5" - cn@0.3.2 - uniwind@1.13.0