castle-web-cli 0.4.179 → 0.4.181

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/agent.js +19 -11
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -432,11 +432,11 @@ function handleModelCaps(req, res) {
432
432
  }
433
433
  // Build the headless CLI invocation for a spawning backend/role (smith never
434
434
  // comes through here -- it has no CLI process; see runAgentSmith). Cursor's
435
- // router runs in read-only ask mode; claude runs permission-mode auto for
436
- // both roles (NOT plan mode -- that makes it emit plan tool calls) at medium
437
- // effort. claudeModel "openrouter" keeps the SAME claude binary/flags and
438
- // swaps only the model slug and env (see envForOpenrouterSpawn) -- plus one
439
- // extra permission grant, see OPENROUTER_ALLOWED_TOOLS below.
435
+ // router runs in read-only ask mode; hosted claude runs bypassPermissions for
436
+ // both roles because the container is already the permission boundary. Local
437
+ // claude stays on auto (NOT plan mode -- that makes it emit plan tool calls)
438
+ // at medium effort. claudeModel "openrouter" keeps the SAME claude binary and
439
+ // swaps only the model slug and env (see envForOpenrouterSpawn).
440
440
  // claude CLI 2.1.198 SILENTLY resolves `--permission-mode auto` to "default"
441
441
  // whenever --model is not in its built-in catalog -- which is every free-form
442
442
  // OpenRouter slug (verified live: `--model sonnet` inits with
@@ -445,8 +445,8 @@ function handleModelCaps(req, res) {
445
445
  // Headless (-p) default mode then denies every prompt-requiring tool with
446
446
  // "you haven't granted it yet", so OR-routed tasks could never edit files
447
447
  // (incident: task UmI8O3VR looped ~60 denials, then exited 0 having done
448
- // nothing). This explicit tool allowlist restores auto's effective headless
449
- // capability -- edits plus unrestricted Bash, network commands included
448
+ // nothing). On local runs, this explicit tool allowlist restores auto's
449
+ // effective headless capability -- edits plus unrestricted Bash, network commands included
450
450
  // (acceptEdits was rejected: it survives the downgrade but still denies
451
451
  // network Bash like curl, which plain auto allows). Deliberately NOT passed
452
452
  // to plain-claude spawns, where auto still resolves correctly.
@@ -507,11 +507,15 @@ function claudeSettingsArg(auth) {
507
507
  // new process, so that text (the kit guide: ~23k tokens on a kit deck) is sent
508
508
  // uncached on every call of every turn. The router already carries the deck's
509
509
  // quick reference and file tree in its cached system part, and can read a
510
- // guide on demand; tasks keep the CLI's own loading. Measured on a 30k-token
511
- // router prompt: a second turn goes from 40k tokens written to 4.6k.
510
+ // guide on demand; tasks keep the CLI's own loading. Auto memory is off for the
511
+ // same reason: the first process in a deck creates the memory store, the next
512
+ // one's system prompt gains a memory block, and the cached prefix only matches
513
+ // from the third turn on. Measured on a 30k-token router prompt: a second turn
514
+ // goes from 50k tokens written to 6k.
512
515
  const ROUTER_CLAUDE_ENV = {
513
516
  CLAUDE_CODE_DISABLE_CLAUDE_MDS: '1',
514
517
  CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS: '1',
518
+ CLAUDE_CODE_DISABLE_AUTO_MEMORY: '1',
515
519
  };
516
520
  function buildAgentInvocation(backend, role, prompt, claudeModel,
517
521
  // Already resolved for this role by the caller (router turns pass
@@ -533,6 +537,7 @@ systemPrompt) {
533
537
  .filter((text) => Boolean(text))
534
538
  .join('\n\n');
535
539
  if (backend === 'claude') {
540
+ const hosted = Boolean(process.env.CASTLE_SANDBOX_ID);
536
541
  const viaOpenrouter = claudeModel === 'openrouter';
537
542
  const orAuth = viaOpenrouter ? resolveOpenrouterAuth() : null;
538
543
  const anAuth = viaOpenrouter ? null : resolveAnthropicAuth();
@@ -549,8 +554,8 @@ systemPrompt) {
549
554
  'stream-json',
550
555
  '--include-partial-messages',
551
556
  '--permission-mode',
552
- 'auto',
553
- ...(viaOpenrouter ? [openrouterAllowedToolsArg(role)] : []),
557
+ hosted ? 'bypassPermissions' : 'auto',
558
+ ...(!hosted && viaOpenrouter ? [openrouterAllowedToolsArg(role)] : []),
554
559
  '--model',
555
560
  viaOpenrouter ? openrouterModel : claudeModel,
556
561
  '--effort',
@@ -577,6 +582,9 @@ systemPrompt) {
577
582
  direct,
578
583
  })),
579
584
  ...(role === 'router' ? ROUTER_CLAUDE_ENV : {}),
585
+ // Claude Code 2.1.258 refuses bypassPermissions as root unless the
586
+ // child explicitly identifies itself as running in a sandbox.
587
+ ...(hosted ? { IS_SANDBOX: '1' } : {}),
580
588
  },
581
589
  };
582
590
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.179",
3
+ "version": "0.4.181",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/castle-xyz/castle-experimental-web.git"