fix(runner): withhold Claude's self-scheduling tools from Paperclip ACPX sessions (#21276)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip owns scheduling. An agent uses Paperclip tools such as
task monitors and routines to continue work later.
> - Paperclip Runner runs Claude Code through the ACPX sidecar.
> - Claude Code offers its own scheduling tools to the model:
`CronCreate`, `CronDelete`, `CronList` and `ScheduleWakeup`. With these
tools the provider can wake itself. Paperclip does not see or govern
that work.
> - Today the Runner stops the Claude process when a turn ends, so these
tools have little effect. A later change keeps the Claude process alive
between turns.
> - This pull request removes the four tools from Claude sessions that
Paperclip starts through ACPX.
> - The benefit is that a Claude agent schedules work only through
Paperclip.

## Linked Issues or Issue Description

No public issue exists. The issue is described here.

Refs #19912 (the design for turn-scoped ACPX MCP authority).

**What existing behavior does this improve?**

The set of tools that Claude Code offers the model in a Paperclip ACPX
session.

**Subsystem affected**

Paperclip Runner, ACPX provider (Claude).

**Current behavior**

A Paperclip ACPX Claude session offers the model 26 built-in tools. Four
of them are `CronCreate`, `CronDelete`, `CronList` and `ScheduleWakeup`.

**Proposed behavior**

- The Claude settings that Paperclip writes into the session home deny
the four tools. Claude Code then does not offer them.
- Each Claude launch sets `CLAUDE_CODE_DISABLE_CRON=1`. This stops the
cron scheduler of Claude Code and removes the three cron tools.
- All other tools stay. `SendMessage`, `ListAgents`, `Workflow`, `Agent`
and `TaskStop` do not change.

**Reason and benefit**

The provider cannot schedule its own wake-ups. Paperclip tools stay the
only way to schedule work.

## What Changed

- `packages/paperclip-runner/src/drivers/acpx/permission-policy.ts`: new
constant `CLAUDE_SELF_SCHEDULING_TOOLS` with the four tool names.
- `packages/paperclip-runner/src/drivers/acpx/runtime-sandbox.ts`: the
Claude `settings.json` now always has `permissions.deny` with the four
tools, in each permission mode. The `allow` rules do not change.
- `packages/paperclip-runner/src/drivers/acpx/environment.ts`:
`createSanitizedAcpxSpawnInput` sets `CLAUDE_CODE_DISABLE_CRON=1` for
each Claude launch. The host cannot override it.
- New test `claude-scheduling-tools.claude-acp.test.ts`. It prepares the
session home with the production `prepareAcpxRuntimeSandbox`. It then
runs the pinned `claude-agent-acp` and the pinned Claude Code client
against a local fake Anthropic API. It reads the tools that the client
offers the model.
- Unit tests in `environment.test.ts` and `runtime-sandbox.test.ts`. One
assertion in `runtime-host.test.ts` now expects the `deny` list.
- No change to the `claude-agent-acp` patch, the lockfile or a pinned
digest. No change to Codex.

## State saved by the previous release

- A session that the previous release saved continues with no change.
The new restriction is not part of a saved identity or digest.
- Each time Paperclip starts Claude for a session, it writes its own
`settings.json` again with the deny list and sets
`CLAUDE_CODE_DISABLE_CRON`. This includes a resumed session and a start
after an upgrade.
- A resumed session keeps its identity, its home and its transcript. It
loses the four tools from its next start.
- A Claude process that the previous release started keeps its tools
until it stops. Paperclip does not refuse it and does not classify it
differently. Its next start gets the restriction.
- No refusal code is necessary, because no saved state becomes
incompatible.

## Verification

- `cd packages/paperclip-runner && npx vitest run
src/drivers/acpx/claude-scheduling-tools.claude-acp.test.ts`
- Without the product change: `2 failed` (`expected [ Array(26) ] to not
include 'CronCreate'`).
  - With the product change: `2 passed`.
- `npx vitest run
src/drivers/acpx/claude-scheduling-tools.claude-acp.test.ts
src/drivers/acpx/environment.test.ts
src/drivers/acpx/runtime-sandbox.test.ts
src/drivers/acpx/runtime-host.test.ts`: `4 passed (4)` files, `147
passed` tests.
- `npx tsc --noEmit -p tsconfig.json` in `packages/paperclip-runner`: no
errors.
- Tools offered after the change, isolated home: the same 26 tools
without `CronCreate`, `CronDelete`, `CronList` and `ScheduleWakeup`.
- `npx vitest run src/drivers/acpx/runtime-host.test.ts -t "previous
release"`: the new test "resumes a Claude session saved by the previous
release and withholds self-scheduling tools on relaunch" fails without
the product change and passes with it. The test saves a session, puts
its home into the shape of the previous release, and resumes it through
`AcpxRuntimeHost.open`.
- `npx tsc --noEmit -p tsconfig.test.json` in
`packages/paperclip-runner`: no errors.
- The fixture in `claude-scheduling-tools.claude-acp.test.ts` now stops
the process group of the provider and waits for it before it removes the
fixture directory.
- Not run: a live run with a real Claude account, and a remote Runner.
Not run: `pnpm verify` and the full suite. CI supplies that coverage.

## Risks

- **A preconfigured home still offers `ScheduleWakeup`.** In that mode
Paperclip does not write the Claude settings of the user, so the deny
list does not apply. The environment variable removes only the three
cron tools. To remove `ScheduleWakeup` there, the Runner must pass
`disallowedTools` to the session. ACPX 0.22 does not forward that
option. This is a follow-up.
- **The new test runs the real pinned Claude Code client.** It needs the
platform binary, as `runner-tool-bridge.claude-schema.test.ts` does
today. It uses no credentials and no network.
- **A prompt or skill that tells Claude to use these tools no longer
works.** No Paperclip instruction refers to them.
- The prepared harness home and remote Runners use the same code path.
They are not tested separately.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Fable 5.2 (`claude-fable-5-2`) in Claude Code planned the
change, reviewed the diff and ran the verification again.
- Claude Opus 5.5 (`claude-opus-5-5`), as a Claude Code subagent with
tool use (shell, file edits, local test runs), investigated the options
and wrote the change and the tests.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Nicky LeachandClaude Fable 5.2 authored and GitHub committed 2026-11-12 22:17:24 -08:00
1 parent bcadbde449
commit ff91bfe2dc
7 files changed
+231 -7

No files matched your search

@@ -0,0 +1,146 @@
import { spawn } from "node:child_process";
import { createServer } from "node:http";
import { mkdir, mkdtemp, rm } from "node:fs/promises";
import { createRequire } from "node:module";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createInterface } from "node:readline";
import { afterEach, expect, it } from "vitest";
import { resolveQualifiedAcpxProfile } from "./qualified-profiles.js";
import { createAcpxRecoveryBinding } from "./recovery-identity.js";
import { prepareAcpxRuntimeSandbox } from "./runtime-sandbox.js";
const SELF_SCHEDULING = ["CronCreate", "CronDelete", "CronList", "ScheduleWakeup"];
const RETAINED = ["Agent", "Bash", "ListAgents", "SendMessage", "TaskStop", "Workflow"];
const agentEntry = createRequire(import.meta.url).resolve("@agentclientprotocol/claude-agent-acp/dist/index.js");
const cleanup: Array<() => Promise<void>> = [];
afterEach(async () => { for (const step of cleanup.splice(0).reverse()) await step(); });
async function fakeAnthropicApi(): Promise<{ url: string; offered: string[][] }> {
const offered: string[][] = [];
const api = createServer(async (request, response) => {
let raw = "";
for await (const chunk of request) raw += chunk;
if (request.method !== "POST" || request.url?.includes("count_tokens")) {
response.writeHead(200, { "content-type": "application/json" });
response.end(request.url?.includes("count_tokens") ? JSON.stringify({ input_tokens: 1 }) : JSON.stringify({ data: [], has_more: false }));
return;
}
const body = JSON.parse(raw || "{}");
if (Array.isArray(body.tools)) offered.push(body.tools.map((tool: { name: string }) => tool.name));
response.writeHead(200, { "content-type": "text/event-stream" });
for (const frame of [
{ type: "message_start", message: { id: "msg_fixture", type: "message", role: "assistant", model: body.model ?? "claude-sonnet-5", content: [], stop_reason: null, stop_sequence: null, usage: { input_tokens: 1, output_tokens: 0 } } },
{ type: "content_block_start", index: 0, content_block: { type: "text", text: "" } },
{ type: "content_block_delta", index: 0, delta: { type: "text_delta", text: "Local fixture complete." } },
{ type: "content_block_stop", index: 0 },
{ type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null }, usage: { output_tokens: 1 } },
{ type: "message_stop" },
]) response.write(`event: ${frame.type}\ndata: ${JSON.stringify(frame)}\n\n`);
response.end();
});
await new Promise<void>(resolve => api.listen(0, "127.0.0.1", resolve));
cleanup.push(async () => { api.closeAllConnections(); await new Promise<void>(resolve => api.close(() => resolve())); });
return { url: `http://127.0.0.1:${(api.address() as { port: number }).port}`, offered };
}
async function promptOnce(env: NodeJS.ProcessEnv, cwd: string): Promise<void> {
const agent = spawn(process.execPath, [agentEntry], { cwd, env, detached: true, stdio: ["pipe", "pipe", "ignore"] });
const closed = new Promise<void>(resolve => agent.once("close", () => resolve()));
let stopping: Promise<void> | undefined;
const stop = () => stopping ??= stopProcessGroup(agent.pid!, closed);
cleanup.push(stop);
let nextId = 1;
const pending = new Map<number, { resolve: (value: Record<string, unknown>) => void; reject: (error: unknown) => void }>();
const send = (message: Record<string, unknown>) => agent.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}\n`);
const request = (method: string, params: Record<string, unknown>) => new Promise<Record<string, unknown>>((resolve, reject) => {
const id = nextId++;
pending.set(id, { resolve, reject });
send({ id, method, params });
});
createInterface({ input: agent.stdout }).on("line", line => {
let message: { id?: number; method?: string; result?: Record<string, unknown>; error?: unknown };
try { message = JSON.parse(line); } catch { return; }
if (message.id !== undefined && message.method === undefined) {
const waiter = pending.get(message.id);
pending.delete(message.id);
if (message.error) waiter?.reject(message.error); else waiter?.resolve(message.result ?? {});
} else if (message.id !== undefined) {
send({ id: message.id, error: { code: -32601, message: "Not supported by this fixture" } });
}
});
agent.once("exit", code => { for (const waiter of pending.values()) waiter.reject(new Error(`claude-agent-acp exited with ${code}`)); });
await request("initialize", { protocolVersion: 1, clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false } });
const session = await request("session/new", { cwd, mcpServers: [] });
await request("session/prompt", { sessionId: session.sessionId, prompt: [{ type: "text", text: "Report this local fixture's result. Do not call tools." }] });
await stop();
}
function signalGroup(pid: number, signal: NodeJS.Signals | 0): boolean {
try { process.kill(-pid, signal); return true; } catch (error) {
if ((error as NodeJS.ErrnoException).code === "ESRCH") return false;
throw error;
}
}
async function stopProcessGroup(pid: number, closed: Promise<void>): Promise<void> {
signalGroup(pid, "SIGTERM");
const deadline = (ms: number) => new Promise<"timeout">(resolve => setTimeout(() => resolve("timeout"), ms).unref());
if (await Promise.race([closed, deadline(5_000)]) === "timeout") signalGroup(pid, "SIGKILL");
await closed;
for (let attempt = 0; signalGroup(pid, 0); attempt += 1) {
if (attempt === 50) signalGroup(pid, "SIGKILL");
if (attempt > 100) throw new Error(`claude-agent-acp process group ${pid} did not exit`);
await deadline(50);
}
}
function fixtureEnvironment(apiUrl: string): NodeJS.ProcessEnv {
return {
PATH: process.env.PATH, ANTHROPIC_API_KEY: "local-fixture-only", ANTHROPIC_BASE_URL: apiUrl,
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
};
}
const launchOnlyEnvironment = { DISABLE_TELEMETRY: "1", DISABLE_ERROR_REPORTING: "1", DISABLE_AUTOUPDATER: "1", ENABLE_TOOL_SEARCH: "false" };
it("withholds Claude's self-scheduling tools from a Paperclip-launched ACPX session", async () => {
const root = await mkdtemp(join(tmpdir(), "claude-scheduling-tools-"));
cleanup.push(() => rm(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 }));
const workspace = join(root, "workspace"), runtimeDirectory = join(root, "runtime");
await Promise.all([mkdir(workspace), mkdir(runtimeDirectory)]);
const binding = await createAcpxRecoveryBinding({
runtimeDirectory, normalizedSessionId: "claude-scheduling-tools", workingDirectory: workspace,
profile: resolveQualifiedAcpxProfile("claude", "claude-sonnet-5"), requestedModel: "claude-sonnet-5",
permissionMode: "approve-reads",
});
const api = await fakeAnthropicApi();
const sandbox = await prepareAcpxRuntimeSandbox({ binding, agent: "claude", environment: fixtureEnvironment(api.url) });
await sandbox.initializeOwnedConfiguration?.();
await promptOnce({ ...sandbox.launchEnvironment, ...launchOnlyEnvironment, TMPDIR: root }, workspace);
expect(api.offered.length).toBeGreaterThan(0);
const offered = api.offered.reduce((longest, tools) => tools.length > longest.length ? tools : longest);
for (const tool of SELF_SCHEDULING) expect(offered).not.toContain(tool);
for (const tool of RETAINED) expect(offered).toContain(tool);
}, 60_000);
it("withholds Claude's cron tools when the run uses a preconfigured home", async () => {
const root = await mkdtemp(join(tmpdir(), "claude-scheduling-tools-home-"));
cleanup.push(() => rm(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 }));
const workspace = join(root, "workspace"), runtimeDirectory = join(root, "runtime"), home = join(root, "home");
await Promise.all([mkdir(workspace), mkdir(runtimeDirectory), mkdir(home)]);
const binding = await createAcpxRecoveryBinding({
runtimeDirectory, normalizedSessionId: "claude-scheduling-tools-home", workingDirectory: workspace,
profile: resolveQualifiedAcpxProfile("claude", "claude-sonnet-5"), requestedModel: "claude-sonnet-5",
permissionMode: "approve-reads",
});
const api = await fakeAnthropicApi();
const sandbox = await prepareAcpxRuntimeSandbox({ binding, agent: "claude", environment: {
...fixtureEnvironment(api.url), HOME: home, PAPERCLIP_RUNNER_HOME_MODE: "preconfigured",
} });
await promptOnce({ ...sandbox.launchEnvironment, ...launchOnlyEnvironment, TMPDIR: root }, workspace);
expect(api.offered.length).toBeGreaterThan(0);
const offered = api.offered.reduce((longest, tools) => tools.length > longest.length ? tools : longest);
for (const tool of ["CronCreate", "CronDelete", "CronList"]) expect(offered).not.toContain(tool);
for (const tool of RETAINED) expect(offered).toContain(tool);
}, 60_000);
@@ -3,9 +3,9 @@ import { afterEach, describe, expect, it, vi } from "vitest";
afterEach(() => vi.unstubAllEnvs());
import { ACPX_CREDENTIAL_BINDING_ENV, CLAUDE_TODO_TOOLS_ENV, createAcpxCredentialBinding, createAcpxSidecarHostEnvironment, createSanitizedAcpxSpawnInput } from "./environment.js";
import { ACPX_CREDENTIAL_BINDING_ENV, CLAUDE_CRON_DISABLE_ENV, CLAUDE_TODO_TOOLS_ENV, createAcpxCredentialBinding, createAcpxSidecarHostEnvironment, createSanitizedAcpxSpawnInput } from "./environment.js";
const claudeLauncherEnv = { [CLAUDE_TODO_TOOLS_ENV]: "1" };
const claudeLauncherEnv = { [CLAUDE_TODO_TOOLS_ENV]: "1", [CLAUDE_CRON_DISABLE_ENV]: "1" };
describe("ACPX launch environment", () => {
it("enables Claude's task-list tools for the native plan and only for Claude", () => {
@@ -15,6 +15,13 @@ describe("ACPX launch environment", () => {
expect(createSanitizedAcpxSpawnInput(host, "codex").env[CLAUDE_TODO_TOOLS_ENV]).toBeUndefined();
});
it("disables Claude's own cron scheduler for every Claude launch and only for Claude", () => {
const host = { PATH: "/bin", [CLAUDE_CRON_DISABLE_ENV]: "0" };
expect(createSanitizedAcpxSpawnInput(host, "claude").env[CLAUDE_CRON_DISABLE_ENV]).toBe("1");
expect(createSanitizedAcpxSpawnInput({ PATH: "/bin", PAPERCLIP_RUNNER_HOME_MODE: "preconfigured" }, "claude").env[CLAUDE_CRON_DISABLE_ENV]).toBe("1");
expect(createSanitizedAcpxSpawnInput(host, "codex").env[CLAUDE_CRON_DISABLE_ENV]).toBeUndefined();
});
it("rejects task shell selectors without a controller-owned helper projection", () => {
const selectors = { BASH_ENV: "/workspace/hook.sh", ZDOTDIR: "/workspace", GH_CONFIG_DIR: "/workspace/gh" };
expect(createSanitizedAcpxSpawnInput(selectors, "claude").env).toEqual(claudeLauncherEnv);
@@ -19,6 +19,7 @@ export const ACPX_CREDENTIAL_NAMES: Readonly<Record<QualifiedAcpxAgent, readonly
};
/** Enables Claude Code's TaskCreate/TaskUpdate tools, which feed the native plan. */
export const CLAUDE_TODO_TOOLS_ENV = "CLAUDE_CODE_ENABLE_TODO_TOOLS";
export const CLAUDE_CRON_DISABLE_ENV = "CLAUDE_CODE_DISABLE_CRON";
export const CLAUDE_ROUTING_ENV_KEYS =["ANTHROPIC_BASE_URL", "ANTHROPIC_CUSTOM_HEADERS", "CLAUDE_CODE_USE_BEDROCK", "AWS_REGION", "AWS_DEFAULT_REGION", "AWS_EC2_METADATA_DISABLED", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC", "ANTHROPIC_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", "CLAUDE_CODE_SUBAGENT_MODEL"] as const;
/** Keep the task projection consistent when excluding general IAM from Pi. */
@@ -188,6 +189,7 @@ export function createSanitizedAcpxSpawnInput(
// Paperclip renders that list as the turn plan (ACP `plan` -> `plan.updated`),
// so the launcher owns this value; a host setting cannot switch it off.
if (agent === "claude") result[CLAUDE_TODO_TOOLS_ENV] = "1";
if (agent === "claude") result[CLAUDE_CRON_DISABLE_ENV] = "1";
if (agent === "claude" && isOpenRouterUrl(result.ANTHROPIC_BASE_URL)) {
result.ANTHROPIC_CUSTOM_HEADERS = openRouterClaudeHeaders(result.ANTHROPIC_CUSTOM_HEADERS);
}
@@ -26,6 +26,8 @@ const AUTOMATIC_PAPERCLIP_WORKFLOW_ACTIONS = new Set([
"create_project", "select_workspace", "request_approval",
]);
export const CLAUDE_SELF_SCHEDULING_TOOLS: readonly string[] = Object.freeze(["CronCreate", "CronDelete", "CronList", "ScheduleWakeup"]);
/** Exact SDK rules for the run's runner-owned Paperclip MCP connection. */
export function claudePaperclipPermissionRules(
tools: readonly Readonly<Record<string, unknown>>[],
@@ -28,6 +28,8 @@ import type {
VerifiedAcpxInstallation,
} from "./installation-integrity.js";
import { resolveQualifiedAcpxProfile } from "./qualified-profiles.js";
import type { AcpxExpectedSessionIdentity } from "./sidecar-protocol.js";
import { acpxProviderSessionIdentity } from "./recovery-identity.js";
import {
prepareAcpxRuntimeSandbox,
type AcpxRuntimeSandbox,
@@ -543,7 +545,7 @@ describe("ACPX runtime host", () => {
join(options.launchEnvironment.CLAUDE_CONFIG_DIR!, "settings.json"),
"utf8",
));
expect(settings.permissions).toEqual(allow ? { allow } : undefined);
expect(settings.permissions).toEqual({ ...(allow ? { allow } : {}), deny: ["CronCreate", "CronDelete", "CronList", "ScheduleWakeup"] });
expect(options.mcpServers).toMatchObject([
{ name: "paperclip", runnerOwned: true },
]);
@@ -570,6 +572,57 @@ describe("ACPX runtime host", () => {
await host.close({ reason: "read permission verified" });
});
it("resumes a Claude session saved by the previous release and withholds self-scheduling tools on relaunch", async () => {
const fixture = await hostFixture();
const tools = {
tools: [{ name: "get_task_context", inputSchema: { type: "object" } }],
handler: async () => ({}),
};
const launches: Array<{ env: Readonly<NodeJS.ProcessEnv>; settings: Record<string, unknown>; restoring: boolean }> = [];
const dependencies = fixture.dependencies({
openRuntime: async (options) => {
launches.push({
env: options.launchEnvironment,
settings: JSON.parse(await readFile(join(options.launchEnvironment.CLAUDE_CONFIG_DIR!, "settings.json"), "utf8")),
restoring: options.restoringSession === true,
});
return runtimePort({ getStatus: async () => ({ models: { currentModelId: "claude-sonnet-5" } }) });
},
});
const open = (expectedIdentity?: AcpxExpectedSessionIdentity) => AcpxRuntimeHost.open({
...fixture.options, agent: "claude", model: "claude-sonnet-5", permissionMode: "approve-reads",
semanticTools: tools, ...(expectedIdentity ? { expectedIdentity } : {}),
}, dependencies);
const first = await open();
const savedIdentity = acpxProviderSessionIdentity(first.identity(), first.binding());
await first.close({ reason: "previous release parked the session" });
const claudeHome = launches[0]!.env.CLAUDE_CONFIG_DIR!;
const previousReleaseSettings = {
model: "claude-sonnet-5", availableModels: ["claude-sonnet-5"],
permissions: { allow: ["mcp__paperclip__get_task_context"] },
};
await writeFile(join(claudeHome, "settings.json"), `${JSON.stringify(previousReleaseSettings)}\n`, { mode: 0o600 });
const transcript = join(claudeHome, "projects", "workspace", "agent-1.jsonl");
await mkdir(join(claudeHome, "projects", "workspace"), { recursive: true });
await writeFile(transcript, "{\"type\":\"user\",\"message\":\"saved by the previous release\"}\n");
const resumed = await open(savedIdentity);
try {
expect(resumed.identity()).toEqual(first.identity());
expect(launches[1]!.restoring).toBe(true);
expect(launches[1]!.env.CLAUDE_CONFIG_DIR).toBe(claudeHome);
expect(launches[1]!.env.CLAUDE_CODE_DISABLE_CRON).toBe("1");
expect(launches[1]!.settings).toEqual({
...previousReleaseSettings,
permissions: { ...previousReleaseSettings.permissions, deny: ["CronCreate", "CronDelete", "CronList", "ScheduleWakeup"] },
});
expect(await readFile(transcript, "utf8")).toContain("saved by the previous release");
} finally {
await resumed.close({ reason: "previous-release session resumed" });
}
});
it("loads assigned Claude skills before launch and refreshes them when reopening", async () => {
const fixture = await hostFixture();
const skillRoot = join(fixture.root, "assigned-source");
@@ -212,6 +212,17 @@ describe("ACPX runtime sandbox", () => {
}
});
it.each(["approve-reads", "approve-paperclip", "deny-all", "approve-all"] as const)(
"denies Claude's self-scheduling tools in isolated settings under %s",
async (permissionMode) => {
const fixture = await sandboxFixture("claude");
const sandbox = await prepareAcpxRuntimeSandbox({ binding: { ...fixture.binding, permissionMode }, agent: "claude" });
await sandbox.initializeOwnedConfiguration?.();
const settings = JSON.parse(await readFile(join(sandbox.agentHomeDirectory, "settings.json"), "utf8"));
expect(settings.permissions.deny).toEqual(["CronCreate", "CronDelete", "CronList", "ScheduleWakeup"]);
},
);
it("restores bound Claude effort in private settings across cold connections", async () => {
const fixture = await sandboxFixture("claude");
for (const claudeEffort of ["high", "xhigh", "max"] as const) {
@@ -36,7 +36,7 @@ import {
import { createSanitizedAcpxSpawnInput } from "./environment.js";
import { cursorInstructionBinding } from "./cursor-instructions.js";
import { claudePaperclipPermissionRules } from "./permission-policy.js";
import { CLAUDE_SELF_SCHEDULING_TOOLS, claudePaperclipPermissionRules } from "./permission-policy.js";
import type { QualifiedAcpxAgent } from "./qualified-profiles.js";
import {
resolveAcpxRuntimeRoot,
@@ -440,9 +440,12 @@ export async function prepareAcpxRuntimeSandbox(input: {
model: input.binding.requestedModel,
availableModels: [input.binding.requestedModel],
...(input.binding.claudeEffort ? { effortLevel: input.binding.claudeEffort } : {}),
...((input.binding.permissionMode === "approve-reads" || input.binding.permissionMode === "approve-paperclip")
? { permissions: { allow: claudePaperclipPermissionRules(input.tools ?? [], input.binding.permissionMode) } }
: {}),
permissions: {
...((input.binding.permissionMode === "approve-reads" || input.binding.permissionMode === "approve-paperclip")
? { allow: claudePaperclipPermissionRules(input.tools ?? [], input.binding.permissionMode) }
: {}),
deny: [...CLAUDE_SELF_SCHEDULING_TOOLS],
},
})}\n`,
);
} : input.agent === "antigravity" ? async () => {