castle-web-cli 0.4.180 → 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 +13 -13
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -432,15 +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
436
- // bypassPermissions for both roles (NOT plan mode -- that makes it emit plan
437
- // tool calls) at medium effort. Not `auto`: auto mode runs a sonnet
438
- // classifier call beside every turn, on Anthropic's own key, whatever --model
439
- // says -- a second model's cost and a second billing line per turn. bypass
440
- // asks no classifier. A cli fix is expected upstream; until then bypass is
441
- // the mode. claudeModel "openrouter" keeps the SAME claude binary/flags and
442
- // swaps only the model slug and env (see envForOpenrouterSpawn) -- plus one
443
- // 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).
444
440
  // claude CLI 2.1.198 SILENTLY resolves `--permission-mode auto` to "default"
445
441
  // whenever --model is not in its built-in catalog -- which is every free-form
446
442
  // OpenRouter slug (verified live: `--model sonnet` inits with
@@ -449,8 +445,8 @@ function handleModelCaps(req, res) {
449
445
  // Headless (-p) default mode then denies every prompt-requiring tool with
450
446
  // "you haven't granted it yet", so OR-routed tasks could never edit files
451
447
  // (incident: task UmI8O3VR looped ~60 denials, then exited 0 having done
452
- // nothing). This explicit tool allowlist restores auto's effective headless
453
- // 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
454
450
  // (acceptEdits was rejected: it survives the downgrade but still denies
455
451
  // network Bash like curl, which plain auto allows). Deliberately NOT passed
456
452
  // to plain-claude spawns, where auto still resolves correctly.
@@ -541,6 +537,7 @@ systemPrompt) {
541
537
  .filter((text) => Boolean(text))
542
538
  .join('\n\n');
543
539
  if (backend === 'claude') {
540
+ const hosted = Boolean(process.env.CASTLE_SANDBOX_ID);
544
541
  const viaOpenrouter = claudeModel === 'openrouter';
545
542
  const orAuth = viaOpenrouter ? resolveOpenrouterAuth() : null;
546
543
  const anAuth = viaOpenrouter ? null : resolveAnthropicAuth();
@@ -557,8 +554,8 @@ systemPrompt) {
557
554
  'stream-json',
558
555
  '--include-partial-messages',
559
556
  '--permission-mode',
560
- 'bypassPermissions',
561
- ...(viaOpenrouter ? [openrouterAllowedToolsArg(role)] : []),
557
+ hosted ? 'bypassPermissions' : 'auto',
558
+ ...(!hosted && viaOpenrouter ? [openrouterAllowedToolsArg(role)] : []),
562
559
  '--model',
563
560
  viaOpenrouter ? openrouterModel : claudeModel,
564
561
  '--effort',
@@ -585,6 +582,9 @@ systemPrompt) {
585
582
  direct,
586
583
  })),
587
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' } : {}),
588
588
  },
589
589
  };
590
590
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.180",
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"