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
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
155 changes: 155 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
38 changes: 33 additions & 5 deletions apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CanUseTool>[2]): boolean {
return (
"decisionReasonType" in options &&
options.decisionReasonType === "safetyCheck" &&
!("requiresUserInteraction" in options && options.requiresUserInteraction === true)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
);
}

export function permissionResultFromDecision(input: {
readonly toolName: string;
readonly decision: ProviderApprovalDecision;
Expand Down Expand Up @@ -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<ClaudeApprovalResponse, never>();
yield* Ref.update(pendingRuntimeRequests, (current) => {
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/provider/ProviderInstanceRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const makeClaudeConfig = (overrides: Partial<ClaudeSettings>): ClaudeSettings =>
launchArgs: "",
autoCompactWindow: "",
idleCompaction: "default",
approveSafetyChecksInFullAccess: false,
...overrides,
});

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/settings/settingsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
},
{
Expand Down
6 changes: 5 additions & 1 deletion docs/user/permission-modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 17 additions & 1 deletion packages/contracts/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading