chainlesschain 0.166.165 → 0.166.166
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.
- package/README.md +12 -4
- package/package.json +1 -1
- package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
- package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
- package/src/command-help-index.json +1 -1
- package/src/commands/agent.js +30 -0
- package/src/data/changelog.json +13 -0
- package/src/lib/app-server/server.js +8 -0
- package/src/lib/chat-core.js +11 -8
- package/src/lib/goal-store.js +4 -1
- package/src/lib/goal-workspace-evidence.js +8 -3
- package/src/lib/provider-stream.js +7 -2
- package/src/lib/read-file-page.js +35 -0
- package/src/lib/stream-retry.js +57 -5
- package/src/lib/workspace-delivery-receipt.js +99 -0
- package/src/runtime/agent-core.js +17 -1
- package/src/runtime/headless-runner.js +63 -14
- package/src/runtime/headless-stream.js +39 -6
- package/src/runtime/provider-stream-state.js +5 -1
package/README.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
# chainlesschain CLI
|
|
2
2
|
|
|
3
|
-
## CLI 0.166.
|
|
3
|
+
## CLI 0.166.166 candidate
|
|
4
4
|
|
|
5
|
-
The candidate
|
|
5
|
+
The candidate adds workspace delivery readback, provider stream error classification, and bounded file reads. The planned pairing is Open VSX **0.37.201** and JetBrains **0.4.216**.
|
|
6
|
+
|
|
7
|
+
## Public CLI 0.166.165
|
|
8
|
+
|
|
9
|
+
CLI **0.166.165** is public from exact source `206e4e72257ec9178ddb66dcc28107e0ce3c43aa`. CLI CI and Strict Sandbox passed on Linux, Windows, and macOS. GitHub Actions published through OIDC and verified the public archive and signed provenance. Install with `npm i -g chainlesschain@0.166.165 --registry https://registry.npmjs.org`, then use `cc --version` and `cc doctor`. [npm publication](https://github.com/longfa/chainlesschain/actions/runs/45885605925)
|
|
10
|
+
|
|
11
|
+
The fullscreen terminal supports follow-up input while a turn is running and uses `/model` to select the next turn’s model. Press Esc to close the picker or interrupt a turn. New interactive sessions automatically approve routine tool calls. Open VSX **0.37.200** is public and recommends CLI **0.166.165**. JetBrains **0.4.215** is publicly downloadable and recommends CLI **0.166.165**. [Upgrade guide](https://docs.chainlesschain.com/chainlesschain/cli-ide-update-2026-11-26-164.html) · [Open VSX](https://open-vsx.org/extension/chainlesschain/chainlesschain-ide/0.37.200) · [JetBrains](https://plugins.jetbrains.com/plugin/download?rel=true&updateId=1229060)
|
|
12
|
+
|
|
13
|
+
Release limits are `NOT_PAID_READY`, `NOT_ADMITTED`, and `HOLD` for paid readiness, native admission, and automatic promotion.
|
|
6
14
|
|
|
7
15
|
## Public CLI 0.166.164
|
|
8
16
|
|
|
9
17
|
CLI **0.166.164** is publicly available from source `80de4089bbc05773a37ff62737b85e39ab8927d3`. GitHub Actions verified CLI CI and Strict Sandbox on Linux, Windows, and macOS and published the npm archive through OIDC. Install `npm i -g chainlesschain@0.166.164 --registry https://registry.npmjs.org`, then run `cc --version` and `cc doctor`. [npm publication](https://github.com/longfa/chainlesschain/actions/runs/45781019483)
|
|
10
18
|
|
|
11
|
-
The fullscreen Agent adds a fixed input area, live slash commands, queued follow-ups, and a searchable `/model` picker. New interactive sessions automatically approve routine tool use subject to managed policy and explicit rules.
|
|
19
|
+
The fullscreen Agent adds a fixed input area, live slash commands, queued follow-ups, and a searchable `/model` picker. New interactive sessions automatically approve routine tool use subject to managed policy and explicit rules. Open VSX **0.37.199** is public and recommends this CLI. JetBrains **0.4.214** is listed and publicly downloadable. It recommends CLI **0.166.164**. Use `/permissions strict` for per-tool prompts and `/interrupt` if the terminal misses Esc. [User guide](https://docs.chainlesschain.com/chainlesschain/cli-ide-update-2026-11-26-164.html) [Open VSX publication](https://github.com/longfa/chainlesschain/actions/runs/45783391508) · [JetBrains publication](https://github.com/longfa/chainlesschain/actions/runs/45783392448)
|
|
12
20
|
|
|
13
21
|
Release limits are `NOT_PAID_READY`, `NOT_ADMITTED`, and `HOLD` for paid readiness, native admission, and automatic promotion.
|
|
14
22
|
|
|
@@ -18,7 +26,7 @@ CLI **0.166.163** is available on npm from source `b06b3bfe0f1bf91d40617f3a0c83d
|
|
|
18
26
|
|
|
19
27
|
This release improves file-search diagnostics, retries a timed-out Windows credential read once, and asks coding agents to verify workspace changes before reporting delivery. File reads recover when the requested page reaches the model. Canonical compaction can shorten a local handoff while retaining file read positions. Chat Completions stream errors fail the turn, and interrupting a turn closes its pending approvals.
|
|
20
28
|
|
|
21
|
-
Open VSX **0.37.198** is public and recommends CLI `0.166.163`. JetBrains **0.4.213** pairs with the same CLI
|
|
29
|
+
Open VSX **0.37.198** is public and recommends CLI `0.166.163`. JetBrains **0.4.213** is publicly downloadable and pairs with the same CLI. [Open VSX](https://open-vsx.org/extension/chainlesschain/chainlesschain-ide) · [JetBrains workflow](https://github.com/longfa/chainlesschain/actions/runs/45537935036)
|
|
22
30
|
|
|
23
31
|
The release limits are `NOT_PAID_READY` for paid readiness, `NOT_ADMITTED` for native admission, and `HOLD` for automatic promotion.
|
|
24
32
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"a2a": "Usage: chainlesschain a2a [options] [command]\n\nA2A Protocol — agent-to-agent communication\n\nOptions:\n -h, --help display help for command\n\nCommands:\n register [options] <name> Register an agent card\n discover [options] Discover agents by capability or skill\n submit [options] <agent-id> <input> Submit a task to an agent\n status [options] <task-id> Get task status\n complete <task-id> <output> Mark a task as completed\n fail <task-id> <error> Mark a task as failed\n peers [options] List all registered agents\n cards [options] List all agent cards with details\n negotiate [options] <agent-id> <capabilities> Check if an agent supports required capabilities\n task-statuses [options] List V2 task statuses (Phase 81)\n card-statuses [options] List V2 card statuses (Phase 81)\n subscription-types [options] List V2 subscription types (Phase 81)\n negotiation-results [options] List V2 negotiation outcomes (Phase 81)\n validate-card [options] <name> Validate an agent card against the A2A schema\n set-card-status [options] <cardId> <status> Transition a card between active/inactive/expired\n card-status [options] <cardId> Show a card's V2 status\n send-task-v2 [options] <agentId> <input> Submit a V2 task (in-memory, with optional timeout)\n start-working [options] <taskId> Transition a V2 task to working\n request-input [options] <taskId> <prompt> Request user input while a V2 task is working\n provide-input [options] <taskId> <input> Provide input for an input-required V2 task\n complete-task-v2 [options] <taskId> [output] Complete a V2 task (from working only)\n fail-task-v2 [options] <taskId> [error] Fail a V2 task with an error message\n cancel-task [options] <taskId> [reason] Cancel a non-terminal V2 task\n check-timeout [options] <taskId> Check V2 task timeout (auto-fails if past deadline)\n task-v2 [options] <taskId> Show a V2 task snapshot\n tasks-v2 [options] List V2 tasks\n negotiate-v2 [options] <cardJson> Phase 81 capability negotiation against an agent card\n stats-v2 [options] Aggregate V2 stats (tasks + cards + subscriptions)\n enums-v2 Show V2 governance enums\n register-agent-v2 [options] Register an a2a agent profile (pending)\n activate-agent-v2 <id> Activate agent\n suspend-agent-v2 <id> Suspend agent\n retire-agent-v2 <id> Retire agent (terminal)\n touch-agent-v2 <id> Refresh lastTouchedAt\n get-agent-v2 <id> Get agent\n list-agents-v2 List agents\n create-message-v2 [options] Create an a2a message (queued)\n start-message-v2 <id> Transition message to sending\n deliver-message-v2 <id> Transition message to delivered\n fail-message-v2 [options] <id> Fail message\n cancel-message-v2 [options] <id> Cancel message\n get-message-v2 <id> Get message\n list-messages-v2 List messages\n set-max-active-agents-v2 <n> Set per-owner active cap\n set-max-pending-messages-v2 <n> Set per-agent pending cap\n set-agent-idle-ms-v2 <n> Set idle threshold\n set-message-stuck-ms-v2 <n> Set stuck threshold\n auto-suspend-idle-agents-v2 Auto-suspend idle agents\n auto-fail-stuck-messages-v2 Auto-fail stuck sending messages\n gov-stats-v2 V2 governance aggregate stats\n help [command] display help for command\n",
|
|
6
6
|
"activitypub": "Usage: chainlesschain activitypub|ap [options] [command]\n\nActivityPub C2S bridge — actors, outbox/inbox, Follow/Create/Like/Announce\n\nOptions:\n -h, --help display help for command\n\nCommands:\n actor Manage local and remote ActivityPub actors\n publish [options] <content> Publish a Create(Note) activity to the actor's outbox\n follow [options] <target> Publish a Follow activity (target: username or actor URL)\n accept [options] <follow-activity-id> Accept a pending Follow request\n unfollow [options] <target> Publish an Undo(Follow) activity\n like [options] <object-id> Publish a Like activity for an object URL\n announce [options] <object-id> Publish an Announce (boost) activity for an object URL\n outbox [options] <username> List an actor's outbox activities\n inbox [options] <username> List an actor's inbox activities\n deliver [options] <username> <activity-json> Simulate inbox delivery — push a JSON activity into a local actor's inbox\n followers [options] <username> List followers of an actor\n search [options] <query> Search actors and/or notes in the local Fediverse index\n following [options] <username> List who this actor is following\n enums-v2 Show V2 enums\n register-actor-v2 [options] Register an AP actor profile (pending)\n activate-actor-v2 <id> Activate actor\n suspend-actor-v2 <id> Suspend actor\n deactivate-actor-v2 <id> Deactivate actor (terminal)\n touch-actor-v2 <id> Refresh lastTouchedAt\n get-actor-v2 <id> Get actor\n list-actors-v2 List actors\n create-activity-v2 [options] Create an AP activity (queued)\n start-activity-v2 <id> Transition activity to delivering\n deliver-activity-v2 <id> Transition activity to delivered\n fail-activity-v2 [options] <id> Fail activity\n cancel-activity-v2 [options] <id> Cancel activity\n get-activity-v2 <id> Get activity\n list-activities-v2 List activities\n set-max-active-actors-v2 <n> Set per-owner active cap\n set-max-pending-activities-v2 <n> Set per-actor pending cap\n set-actor-idle-ms-v2 <n> Set idle threshold\n set-activity-stuck-ms-v2 <n> Set stuck threshold\n auto-suspend-idle-actors-v2 Auto-suspend idle actors\n auto-fail-stuck-activities-v2 Auto-fail stuck delivering activities\n gov-stats-v2 V2 governance aggregate stats\n help [command] display help for command\n",
|
|
7
7
|
"agenda": "Usage: chainlesschain agenda [options] [command]\n\nFire agent-scheduled wakeups / crons / monitors (persisted by the `schedule`\ntool)\n\nOptions:\n -h, --help display help for command\n\nCommands:\n list [options] List all scheduled entries\n run [options] Fire every entry that is due now\n cancel [options] <id> Remove a scheduled entry by id\n prune [options] Remove finished entries (fired / matched / exhausted /\n expired)\n help [command] display help for command\n",
|
|
8
|
-
"agent": "Usage: chainlesschain agent|a [options] [command] [task...]\n\nStart an agentic AI session (reads/writes files, runs commands)\n\nArguments:\n task Headless task 鈥?when given (or with -p /\n piped stdin), runs non-interactively\n\nOptions:\n --model <model> Model name\n --context-window <tokens> Operator-declared planning window\n (1024-16777216 tokens); not runtime\n verified\n --max-output-tokens <tokens> Maximum provider output tokens per\n agent-loop request (positive safe\n integer)\n --provider <provider> LLM provider (ollama, openai,\n volcengine, deepseek, ...)\n --base-url <url> API base URL\n --service-tier <tier> Reviewed provider service tier\n (standard, fast, flex, ultrafast)\n --api-key <key> API key\n --think [level] Enable Anthropic extended thinking\n (level: think | hard | ultra; Anthropic\n models only)\n --ultrathink Maximum Anthropic extended thinking (=\n --think ultra)\n --thinking-budget <n> Thinking token budget for legacy Claude\n models (Sonnet 4.5 / Opus 4.0-4.5 /\n older); clamped below max_tokens.\n Adaptive-thinking models ignore it (they\n use --think's effort). Requires\n --think/--ultrathink.\n --image <path> Attach an image (png/jpg/jpeg/gif/webp)\n to the prompt for a vision-capable model\n (headless; repeatable)\n --vision-model <id> Explicit image model override\n (otherwise: multimodal main model, then\n config llm.visionModel or\n doubao-seed-2-0-lite-260215)\n --session <id> Resume a previous agent session\n -c, --continue Resume the most recent session (no id\n needed 鈥?claude --continue parity)\n --resume [id] Resume a session by id (no id 鈫?most\n recent 鈥?claude --resume parity)\n --fork-session When resuming, branch into a NEW session\n id and leave the original untouched\n (claude --fork-session parity)\n --fork-request-id <key> Stable idempotency key for\n --fork-session retries (omit for a new\n fork each invocation)\n --add-dir <dir> Extra working directory the agent may\n read/search/edit (repeatable)\n --checkpoint Auto-snapshot the work tree before each\n mutating tool (DEFAULT inside a git\n repo; cc checkpoint restore to roll\n back)\n --no-checkpoint Disable auto-checkpointing (it is on by\n default inside git repos)\n --managed-checkpoint Checkpoint bounded mutating tools with\n Process Broker; unavailable writer\n lifetimes are reported as coverage none\n --managed-checkpoint-state <dir> Durable managed-checkpoint state\n directory (must be outside the\n workspace)\n --managed-checkpoint-exclude <path> Explicit workspace path excluded from\n managed checkpoints; repeatable and\n reported as partial coverage\n --safe-mode Run bare: disable project memory,\n settings hooks, memory recall, IDE\n context, status line and update notice\n (permission rules STAY active)\n --bare Everything --safe-mode disables PLUS\n skills, plugins and MCP/IDE auto-connect\n — minimal fast surface for scripted\n calls (explicit --mcp-config still\n loads; permission rules STAY active)\n --no-plugins Disable plugin customizations for this\n run\n --ephemeral No session persistence: nothing is\n written to the session store (headless;\n a --resume id still replays history\n read-only)\n --decision-mode <mode> Typed Skill-routing experiment for\n durable headless sessions: off | shadow\n | suggest (default: \"off\")\n --decision-provider <provider> Decision provider: typesafe | laya\n (local) | system-one (compatible API)\n (default: \"typesafe\")\n --decision-model <model> Decision model (defaults:\n typesafe=jev-latest, laya=laya; required\n for system-one)\n --decision-base-url <url> System One API base URL (laya: loopback\n only; other providers: HTTPS or\n loopback)\n --decision-timeout-ms <ms> Decision timeout in milliseconds\n (50-30000; default: 800)\n --capabilities Print a machine-readable capability\n manifest (JSON: protocol version, tools,\n permission modes, exit codes) and exit\n --disable-slash-commands Interactive REPL: don't dispatch '/'\n input as slash commands — it reaches the\n model verbatim (/exit and /quit stay\n live)\n --ax-screen-reader Screen-reader friendly output: no ANSI\n colors, no in-place status line repaints\n (also CC_SCREEN_READER=1)\n --worktree Run this session in a fresh git worktree\n (isolated branch; auto-removed when the\n session changes nothing)\n --no-worktree Background Git task: explicitly share\n the current work tree (intended for\n read-only tasks; writable runs are not\n isolated)\n --unattended Enable fail-closed shell action policy\n for scheduled/event-driven runs\n --unattended-allow <classes> Comma-separated action classes\n explicitly allowed for unattended shell\n runs\n --sandbox [image] Run shell commands in an ephemeral\n Docker sandbox (network disabled by\n default)\n --sandbox-mode <mode> Sandbox posture: off | workspace-write |\n strict (explicit isolation modes fail\n closed)\n --sandbox-network Allow network access inside --sandbox\n --otlp <file> Write the agent run's OpenTelemetry\n spans (model/tool/retry) as OTLP/JSON to\n <file>\n --otlp-content Include prompt/response CONTENT in\n --otlp spans (off by default; content is\n redacted unless this is set)\n --auto-rewake When an async `asyncRewake` hook (e.g. a\n background test) fails at turn end,\n re-engage the agent to fix it (bounded\n by --max-rewakes)\n --auto-pin Force-pin the original task (first user\n turn) through compaction (ON by default;\n disable with CC_AUTO_PIN=0 or config\n context.autoPin=false)\n --max-rewakes <n> Max auto-rewake re-drives per run\n (default 1); implies --auto-rewake\n --bg, --background Start as a detached background agent and\n return its id immediately\n --agent-id <id> Agent id for scoped memory recall\n --recall-limit <n> Top-K memories to inject into system\n prompt\n --recall-query <q> Query string for startup memory recall\n --no-recall-memory Disable automatic Memory recall in the\n interactive session\n --vim Start the interactive REPL in vim-mode\n line editing (toggle later with /vim; or\n CC_VIM=1)\n --no-stream Disable streamed response rendering\n --no-park-on-exit Close the session-core handle on exit\n instead of parking it\n --bundle <path> Agent bundle directory (may execute\n local MCP commands from mcp.json)\n -p, --print [prompt] Headless: run one non-interactive turn\n and exit\n --output-format <fmt> Headless output: text | json |\n stream-json (default: \"text\")\n --max-turns <n> Cap agent loop iterations (0 =\n unlimited; interactive streams default\n to unlimited, unattended runs to 50)\n --review-changes Headless: review write/edit tool changes\n once within remaining budgets; final\n text only (no partial deltas)\n --json-schema <file> Headless structured output: final reply\n must be JSON validating against this\n schema (invalid replies retried)\n --allowed-tools <list> Comma/space-separated tool allow-list\n (headless)\n --disallowed-tools <list> Comma/space-separated tool deny-list\n (headless)\n --permission-mode <mode> manual | auto | dontAsk | default | plan\n | acceptEdits | bypassPermissions (plan\n headless-only)\n --no-file-refs Disable @path file-reference expansion\n in the prompt (headless)\n --no-slash-macros Disable /name custom-command\n (.claude/commands) expansion in the\n prompt (headless)\n --system-prompt <text> Replace the built-in system prompt\n (literal text or @file)\n --append-system-prompt <text> Append extra guidance to the system\n prompt (literal text or @file)\n --no-project-memory Skip auto-loaded project memory (cc.md /\n CLAUDE.md / AGENTS.md hierarchy,\n .chainlesschain/rules.md,\n .claude/rules/*.md) — a lean system\n prompt for token-tight surfaces (e.g.\n IDE chat). The agent can still read\n those files with tools when it needs\n them.\n --output-style <name> Apply a named output-style persona\n (.claude/output-styles/<name>.md or a\n built-in: concise | explanatory |\n learning)\n --input-format <fmt> Headless input: text | stream-json\n (NDJSON user events on stdin,\n multi-turn) (default: \"text\")\n --trace-id <id> Correlation id stamped as `trace_id` on\n every stream-json output line (also read\n from CC_TRACE_ID). Lets an IDE/bridge\n trace one run across its own logs, the\n CLI, transcripts and diagnostics.\n Auto-generated per run when omitted.\n --fallback-model <model> Backup model(s) to try in order when the\n primary fails (transient error or\n model-not-found). Repeatable or\n comma-separated; up to 3. A\n `provider:model` entry (e.g.\n openai:gpt-4o) falls back\n cross-provider, using that provider's\n API key from its env var (skipped if\n unset — never reuses the primary key).\n Defaults to config llm.fallbackModels.\n --include-partial-messages Emit live assistant-text deltas as\n stream_event lines (requires\n --output-format stream-json)\n --include-hook-events Emit redacted hook and subagent\n lifecycle events (requires\n --output-format stream-json)\n --goal [id] Bind a cc goal into the run (id, or omit\n the value to auto-resolve the active\n goal)\n --goal-assess After the run, ask the model to assess\n goal progress and persist it (opt-in;\n costs one extra completion; requires\n --goal)\n --goal-condition <spec> Session completion condition; prefer\n verify:<manifest.json> for independent\n engineering acceptance, or\n exit-zero:/file-exists:/contains:/regex:;\n model:<desc> uses model judgment\n --goal-recovery-reviewed Resume an interrupted goal after\n reviewing prior effects and usage\n (requires --resume/--continue and\n --goal-condition)\n --max-outer-turns <n> Max outer re-drive turns for\n --goal-condition (default 10, hard cap\n 100)\n --goal-max-tokens <n> Token budget across --goal-condition\n outer turns\n --goal-max-cost <usd> Cost budget (USD) across\n --goal-condition outer turns\n --goal-max-time <ms> Wall-clock budget (ms) across\n --goal-condition outer turns\n --mcp-config <file> Load ad-hoc MCP servers from a JSON file\n for this run (headless); their tools\n become callable (mcp__<server>__<tool>)\n --no-mcp Don't auto-connect MCP servers\n registered with `cc mcp add\n --auto-connect` (--mcp-config still\n loads)\n --no-mcp-auto-connect Disable implicit MCP and editor\n discovery (explicit --mcp-config or\n bridge flags still apply)\n --ide Force-enable IDE bridge auto-connect:\n discover a running editor's MCP server\n via ~/.chainlesschain/ide/*.json\n (default: auto inside an IDE integrated\n terminal)\n --no-ide Disable IDE bridge auto-connect\n --pdh Force-enable PDH bridge auto-connect:\n discover the Android app's\n device-capability MCP server via\n ~/.chainlesschain/pdh-bridge/*.json\n (default: auto when\n CHAINLESSCHAIN_PDH_PORT is set)\n --no-pdh Disable PDH bridge auto-connect\n --jetbrains Force-enable IntelliJ IDEA built-in MCP\n (IDEA >= 2025.2) as server `idea`\n (default: auto when the ChainlessChain\n JetBrains plugin injects\n CHAINLESSCHAIN_JETBRAINS_MCP_URL)\n --no-jetbrains Disable IDEA built-in MCP auto-connect\n --interactive-approvals Stream mode: confirm-tier approvals\n become approval_request/approval\n stdin-stdout events instead of failing\n closed (chat-panel UX)\n --permission-prompt-tool <tool> Defer tool approvals to an MCP tool\n (mcp__<server>__<tool>; requires\n --mcp-config) instead of headless\n fail-closed\n --remote-control Route confirm-tier approvals to paired\n mobile/web devices — requires a relay or\n explicit LAN opt-in; headless waits\n fail-closed, interactive races the\n terminal prompt (also /remote-control)\n --remote-control-allow-lan Permit --remote-control to expose its\n authenticated WS endpoint on a trusted\n LAN\n --channels <list> Inbound channels for the interactive\n session (webhook[:port],telegram) —\n external events enter as user turns;\n webhook needs its bearer token, telegram\n needs channels.telegram.allowFrom\n --settings <file> Merge an extra\n .claude/settings.json-shaped file for\n this run: permission rules\n (allow/ask/deny) + native config\n overrides (model, env)\n --max-budget-usd <amount> Hard USD spend cap: stop the run before\n the next paid LLM call once the\n estimated cost reaches this (headless;\n uses the cc cost price table)\n --session-budget Enable the durable session-wide budget\n authority (headless; requires\n --session/--resume/--continue)\n --session-max-concurrent <n> Durable session cap for concurrent child\n work\n --session-max-spawns <n> Durable session cap for total child-work\n admissions\n --session-max-depth <n> Durable session cap for child-agent\n nesting depth\n --session-max-turns <n> Durable session cap for model turns\n across resumes\n --session-max-tokens <n> Durable session cap for\n provider-reported tokens across resumes\n --session-max-cost-usd <amount> Durable session cost cap across resumes\n (requires priced provider usage)\n --session-max-wall-ms <n> Durable session cap for cumulative\n active wall time\n --session-max-tool-ms <n> Durable session cap for aggregate tool\n execution time\n --observability-workspace <id> Persist a workspace scope on new session\n authority for causal reports\n --observability-team <id> Persist a team scope on new session\n authority for causal reports\n --observability-policy <id> Persist a policy scope on new session\n authority for causal reports\n --strict-mcp-config Use ONLY --mcp-config servers; ignore\n registered (cc mcp add) and IDE-bridge\n MCP for a reproducible tool surface\n --project-mcp Opt in to loading a project-scoped\n .mcp.json (default off; a checked-in\n .mcp.json can spawn commands)\n --replay-user-messages Stream-input mode: echo each accepted\n stdin user message back as a `user`\n event (transcript/correlation)\n --allow-dangerous-bypass Bypass all permission prompts in\n headless mode (DANGEROUS: auto-approves\n all tool calls) (default: false)\n -y, --yolo Alias for --allow-dangerous-bypass\n (default: false)\n --dangerously-skip-permissions Alias for --allow-dangerous-bypass\n (default: false)\n -h, --help display help for command\n\nCommands:\n controlled-host [options] Run against a pre-provisioned Linux\n permission authority (one-shot, dontAsk)\n process-ownership Inspect Linux process quarantine or\n explicitly stop one recoverable\n execution\n",
|
|
8
|
+
"agent": "Usage: chainlesschain agent|a [options] [command] [task...]\n\nStart an agentic AI session (reads/writes files, runs commands)\n\nArguments:\n task Headless task 鈥?when given (or with -p /\n piped stdin), runs non-interactively\n\nOptions:\n --model <model> Model name\n --context-window <tokens> Operator-declared planning window\n (1024-16777216 tokens); not runtime\n verified\n --max-output-tokens <tokens> Maximum provider output tokens per\n agent-loop request (positive safe\n integer)\n --provider <provider> LLM provider (ollama, openai,\n volcengine, deepseek, ...)\n --base-url <url> API base URL\n --service-tier <tier> Reviewed provider service tier\n (standard, fast, flex, ultrafast)\n --api-key <key> API key\n --think [level] Enable Anthropic extended thinking\n (level: think | hard | ultra; Anthropic\n models only)\n --ultrathink Maximum Anthropic extended thinking (=\n --think ultra)\n --thinking-budget <n> Thinking token budget for legacy Claude\n models (Sonnet 4.5 / Opus 4.0-4.5 /\n older); clamped below max_tokens.\n Adaptive-thinking models ignore it (they\n use --think's effort). Requires\n --think/--ultrathink.\n --image <path> Attach an image (png/jpg/jpeg/gif/webp)\n to the prompt for a vision-capable model\n (headless; repeatable)\n --vision-model <id> Explicit image model override\n (otherwise: multimodal main model, then\n config llm.visionModel or\n doubao-seed-2-0-lite-260215)\n --session <id> Resume a previous agent session\n -c, --continue Resume the most recent session (no id\n needed 鈥?claude --continue parity)\n --resume [id] Resume a session by id (no id 鈫?most\n recent 鈥?claude --resume parity)\n --fork-session When resuming, branch into a NEW session\n id and leave the original untouched\n (claude --fork-session parity)\n --fork-request-id <key> Stable idempotency key for\n --fork-session retries (omit for a new\n fork each invocation)\n --add-dir <dir> Extra working directory the agent may\n read/search/edit (repeatable)\n --expect-deliverable <path> Verify a workspace-relative file changed\n in the first headless turn (repeatable)\n --checkpoint Auto-snapshot the work tree before each\n mutating tool (DEFAULT inside a git\n repo; cc checkpoint restore to roll\n back)\n --no-checkpoint Disable auto-checkpointing (it is on by\n default inside git repos)\n --managed-checkpoint Checkpoint bounded mutating tools with\n Process Broker; unavailable writer\n lifetimes are reported as coverage none\n --managed-checkpoint-state <dir> Durable managed-checkpoint state\n directory (must be outside the\n workspace)\n --managed-checkpoint-exclude <path> Explicit workspace path excluded from\n managed checkpoints; repeatable and\n reported as partial coverage\n --safe-mode Run bare: disable project memory,\n settings hooks, memory recall, IDE\n context, status line and update notice\n (permission rules STAY active)\n --bare Everything --safe-mode disables PLUS\n skills, plugins and MCP/IDE auto-connect\n — minimal fast surface for scripted\n calls (explicit --mcp-config still\n loads; permission rules STAY active)\n --no-plugins Disable plugin customizations for this\n run\n --ephemeral No session persistence: nothing is\n written to the session store (headless;\n a --resume id still replays history\n read-only)\n --decision-mode <mode> Typed Skill-routing experiment for\n durable headless sessions: off | shadow\n | suggest (default: \"off\")\n --decision-provider <provider> Decision provider: typesafe | laya\n (local) | system-one (compatible API)\n (default: \"typesafe\")\n --decision-model <model> Decision model (defaults:\n typesafe=jev-latest, laya=laya; required\n for system-one)\n --decision-base-url <url> System One API base URL (laya: loopback\n only; other providers: HTTPS or\n loopback)\n --decision-timeout-ms <ms> Decision timeout in milliseconds\n (50-30000; default: 800)\n --capabilities Print a machine-readable capability\n manifest (JSON: protocol version, tools,\n permission modes, exit codes) and exit\n --disable-slash-commands Interactive REPL: don't dispatch '/'\n input as slash commands — it reaches the\n model verbatim (/exit and /quit stay\n live)\n --ax-screen-reader Screen-reader friendly output: no ANSI\n colors, no in-place status line repaints\n (also CC_SCREEN_READER=1)\n --worktree Run this session in a fresh git worktree\n (isolated branch; auto-removed when the\n session changes nothing)\n --no-worktree Background Git task: explicitly share\n the current work tree (intended for\n read-only tasks; writable runs are not\n isolated)\n --unattended Enable fail-closed shell action policy\n for scheduled/event-driven runs\n --unattended-allow <classes> Comma-separated action classes\n explicitly allowed for unattended shell\n runs\n --sandbox [image] Run shell commands in an ephemeral\n Docker sandbox (network disabled by\n default)\n --sandbox-mode <mode> Sandbox posture: off | workspace-write |\n strict (explicit isolation modes fail\n closed)\n --sandbox-network Allow network access inside --sandbox\n --otlp <file> Write the agent run's OpenTelemetry\n spans (model/tool/retry) as OTLP/JSON to\n <file>\n --otlp-content Include prompt/response CONTENT in\n --otlp spans (off by default; content is\n redacted unless this is set)\n --auto-rewake When an async `asyncRewake` hook (e.g. a\n background test) fails at turn end,\n re-engage the agent to fix it (bounded\n by --max-rewakes)\n --auto-pin Force-pin the original task (first user\n turn) through compaction (ON by default;\n disable with CC_AUTO_PIN=0 or config\n context.autoPin=false)\n --max-rewakes <n> Max auto-rewake re-drives per run\n (default 1); implies --auto-rewake\n --bg, --background Start as a detached background agent and\n return its id immediately\n --agent-id <id> Agent id for scoped memory recall\n --recall-limit <n> Top-K memories to inject into system\n prompt\n --recall-query <q> Query string for startup memory recall\n --no-recall-memory Disable automatic Memory recall in the\n interactive session\n --vim Start the interactive REPL in vim-mode\n line editing (toggle later with /vim; or\n CC_VIM=1)\n --no-stream Disable streamed response rendering\n --no-park-on-exit Close the session-core handle on exit\n instead of parking it\n --bundle <path> Agent bundle directory (may execute\n local MCP commands from mcp.json)\n -p, --print [prompt] Headless: run one non-interactive turn\n and exit\n --output-format <fmt> Headless output: text | json |\n stream-json (default: \"text\")\n --max-turns <n> Cap agent loop iterations (0 =\n unlimited; interactive streams default\n to unlimited, unattended runs to 50)\n --review-changes Headless: review write/edit tool changes\n once within remaining budgets; final\n text only (no partial deltas)\n --json-schema <file> Headless structured output: final reply\n must be JSON validating against this\n schema (invalid replies retried)\n --allowed-tools <list> Comma/space-separated tool allow-list\n (headless)\n --disallowed-tools <list> Comma/space-separated tool deny-list\n (headless)\n --permission-mode <mode> manual | auto | dontAsk | default | plan\n | acceptEdits | bypassPermissions (plan\n headless-only)\n --no-file-refs Disable @path file-reference expansion\n in the prompt (headless)\n --no-slash-macros Disable /name custom-command\n (.claude/commands) expansion in the\n prompt (headless)\n --system-prompt <text> Replace the built-in system prompt\n (literal text or @file)\n --append-system-prompt <text> Append extra guidance to the system\n prompt (literal text or @file)\n --no-project-memory Skip auto-loaded project memory (cc.md /\n CLAUDE.md / AGENTS.md hierarchy,\n .chainlesschain/rules.md,\n .claude/rules/*.md) — a lean system\n prompt for token-tight surfaces (e.g.\n IDE chat). The agent can still read\n those files with tools when it needs\n them.\n --output-style <name> Apply a named output-style persona\n (.claude/output-styles/<name>.md or a\n built-in: concise | explanatory |\n learning)\n --input-format <fmt> Headless input: text | stream-json\n (NDJSON user events on stdin,\n multi-turn) (default: \"text\")\n --trace-id <id> Correlation id stamped as `trace_id` on\n every stream-json output line (also read\n from CC_TRACE_ID). Lets an IDE/bridge\n trace one run across its own logs, the\n CLI, transcripts and diagnostics.\n Auto-generated per run when omitted.\n --fallback-model <model> Backup model(s) to try in order when the\n primary fails (transient error or\n model-not-found). Repeatable or\n comma-separated; up to 3. A\n `provider:model` entry (e.g.\n openai:gpt-4o) falls back\n cross-provider, using that provider's\n API key from its env var (skipped if\n unset — never reuses the primary key).\n Defaults to config llm.fallbackModels.\n --include-partial-messages Emit live assistant-text deltas as\n stream_event lines (requires\n --output-format stream-json)\n --include-hook-events Emit redacted hook and subagent\n lifecycle events (requires\n --output-format stream-json)\n --goal [id] Bind a cc goal into the run (id, or omit\n the value to auto-resolve the active\n goal)\n --goal-assess After the run, ask the model to assess\n goal progress and persist it (opt-in;\n costs one extra completion; requires\n --goal)\n --goal-condition <spec> Session completion condition; prefer\n verify:<manifest.json> for independent\n engineering acceptance, or\n exit-zero:/file-exists:/contains:/regex:;\n model:<desc> uses model judgment\n --goal-recovery-reviewed Resume an interrupted goal after\n reviewing prior effects and usage\n (requires --resume/--continue and\n --goal-condition)\n --max-outer-turns <n> Max outer re-drive turns for\n --goal-condition (default 10, hard cap\n 100)\n --goal-max-tokens <n> Token budget across --goal-condition\n outer turns\n --goal-max-cost <usd> Cost budget (USD) across\n --goal-condition outer turns\n --goal-max-time <ms> Wall-clock budget (ms) across\n --goal-condition outer turns\n --mcp-config <file> Load ad-hoc MCP servers from a JSON file\n for this run (headless); their tools\n become callable (mcp__<server>__<tool>)\n --no-mcp Don't auto-connect MCP servers\n registered with `cc mcp add\n --auto-connect` (--mcp-config still\n loads)\n --no-mcp-auto-connect Disable implicit MCP and editor\n discovery (explicit --mcp-config or\n bridge flags still apply)\n --ide Force-enable IDE bridge auto-connect:\n discover a running editor's MCP server\n via ~/.chainlesschain/ide/*.json\n (default: auto inside an IDE integrated\n terminal)\n --no-ide Disable IDE bridge auto-connect\n --pdh Force-enable PDH bridge auto-connect:\n discover the Android app's\n device-capability MCP server via\n ~/.chainlesschain/pdh-bridge/*.json\n (default: auto when\n CHAINLESSCHAIN_PDH_PORT is set)\n --no-pdh Disable PDH bridge auto-connect\n --jetbrains Force-enable IntelliJ IDEA built-in MCP\n (IDEA >= 2025.2) as server `idea`\n (default: auto when the ChainlessChain\n JetBrains plugin injects\n CHAINLESSCHAIN_JETBRAINS_MCP_URL)\n --no-jetbrains Disable IDEA built-in MCP auto-connect\n --interactive-approvals Stream mode: confirm-tier approvals\n become approval_request/approval\n stdin-stdout events instead of failing\n closed (chat-panel UX)\n --permission-prompt-tool <tool> Defer tool approvals to an MCP tool\n (mcp__<server>__<tool>; requires\n --mcp-config) instead of headless\n fail-closed\n --remote-control Route confirm-tier approvals to paired\n mobile/web devices — requires a relay or\n explicit LAN opt-in; headless waits\n fail-closed, interactive races the\n terminal prompt (also /remote-control)\n --remote-control-allow-lan Permit --remote-control to expose its\n authenticated WS endpoint on a trusted\n LAN\n --channels <list> Inbound channels for the interactive\n session (webhook[:port],telegram) —\n external events enter as user turns;\n webhook needs its bearer token, telegram\n needs channels.telegram.allowFrom\n --settings <file> Merge an extra\n .claude/settings.json-shaped file for\n this run: permission rules\n (allow/ask/deny) + native config\n overrides (model, env)\n --max-budget-usd <amount> Hard USD spend cap: stop the run before\n the next paid LLM call once the\n estimated cost reaches this (headless;\n uses the cc cost price table)\n --session-budget Enable the durable session-wide budget\n authority (headless; requires\n --session/--resume/--continue)\n --session-max-concurrent <n> Durable session cap for concurrent child\n work\n --session-max-spawns <n> Durable session cap for total child-work\n admissions\n --session-max-depth <n> Durable session cap for child-agent\n nesting depth\n --session-max-turns <n> Durable session cap for model turns\n across resumes\n --session-max-tokens <n> Durable session cap for\n provider-reported tokens across resumes\n --session-max-cost-usd <amount> Durable session cost cap across resumes\n (requires priced provider usage)\n --session-max-wall-ms <n> Durable session cap for cumulative\n active wall time\n --session-max-tool-ms <n> Durable session cap for aggregate tool\n execution time\n --observability-workspace <id> Persist a workspace scope on new session\n authority for causal reports\n --observability-team <id> Persist a team scope on new session\n authority for causal reports\n --observability-policy <id> Persist a policy scope on new session\n authority for causal reports\n --strict-mcp-config Use ONLY --mcp-config servers; ignore\n registered (cc mcp add) and IDE-bridge\n MCP for a reproducible tool surface\n --project-mcp Opt in to loading a project-scoped\n .mcp.json (default off; a checked-in\n .mcp.json can spawn commands)\n --replay-user-messages Stream-input mode: echo each accepted\n stdin user message back as a `user`\n event (transcript/correlation)\n --allow-dangerous-bypass Bypass all permission prompts in\n headless mode (DANGEROUS: auto-approves\n all tool calls) (default: false)\n -y, --yolo Alias for --allow-dangerous-bypass\n (default: false)\n --dangerously-skip-permissions Alias for --allow-dangerous-bypass\n (default: false)\n -h, --help display help for command\n\nCommands:\n controlled-host [options] Run against a pre-provisioned Linux\n permission authority (one-shot, dontAsk)\n process-ownership Inspect Linux process quarantine or\n explicitly stop one recoverable\n execution\n",
|
|
9
9
|
"agent-network": "Usage: chainlesschain agent-network|anet [options] [command]\n\nDecentralized Agent Network (Phase 24) — DID / registry / credentials / task\nrouting\n\nOptions:\n -h, --help display help for command\n\nCommands:\n config [options] Show network constants & reputation weights\n dimensions [options] List reputation dimensions\n task-statuses [options] List task lifecycle statuses\n did-create [options] Create an Agent DID (Ed25519 + DID document)\n did-resolve [options] <did> Resolve DID → DID document\n dids [options] List Agent DIDs\n did-deactivate [options] <did> Deactivate a DID (also forces registry offline)\n sign [options] <did> <data> Sign data with agent's Ed25519 key\n verify [options] <did> <data> <signature> Verify a signature from an agent\n register [options] <did> <orgId> Register an Agent in the federated registry\n unregister [options] <did> Remove an Agent from the registry\n heartbeat [options] <did> Bump last_heartbeat (forces online)\n discover [options] Discover agents (capability / org / status)\n sweep [options] Mark stale online agents offline\n peer-add [options] <peerId> Add/update a Kademlia peer (k-bucket auto-computed)\n peer-remove [options] <peerId> Remove a peer\n peers [options] List peers (optionally by k-bucket)\n auth-start [options] <did> Issue an auth challenge for a DID\n auth-complete [options] <sessionId> <signature> Complete auth with signature over challenge\n auth-validate [options] <token> Validate a session token (returns agentDid or exits 1)\n auth-sessions [options] List auth sessions\n credential-issue [options] <issuerDid> <subjectDid> Issue a VC with HMAC/Ed25519 proof\n credential-verify [options] <id> Verify a VC (signature + expiry + revocation)\n credential-revoke [options] <id> Revoke a credential\n credential-show [options] <id> Show a credential\n credentials [options] List credentials (filter by subject/issuer/status/type)\n task-route [options] <sourceOrg> <taskType> Route task → pick best-rep agent matching capability\n task-show [options] <taskId> Show a task\n task-status [options] <taskId> <status> Update task status (terminal states set completedAt)\n task-cancel [options] <taskId> Cancel a task (sets CANCELLED + reason)\n tasks [options] List tasks\n rep-update [options] <did> <dimension> <score> Record a reputation observation\n rep-show [options] <did> Show reputation summary (weighted total + per-dim avg)\n rep-history [options] <did> Show reputation history (newest first)\n rep-top [options] Top agents by dimension (or total)\n stats [options] Network-level statistics\n agent-maturities-v2 List V2 agent maturity states\n task-lifecycles-v2 List V2 task lifecycle states\n stats-v2 V2 agent-network stats\n get-max-active-agents-v2 Get max active agents per network (V2)\n set-max-active-agents-v2 <n> Set max active agents per network (V2)\n get-max-pending-tasks-v2 Get max pending tasks per agent (V2)\n set-max-pending-tasks-v2 <n> Set max pending tasks per agent (V2)\n get-agent-idle-ms-v2 Get agent idle threshold (V2)\n set-agent-idle-ms-v2 <ms> Set agent idle threshold (V2)\n get-task-stuck-ms-v2 Get task stuck threshold (V2)\n set-task-stuck-ms-v2 <ms> Set task stuck threshold (V2)\n active-agent-count-v2 <networkId> Active agent count for network (V2)\n pending-task-count-v2 <agentId> Pending task count for agent (V2)\n register-agent-v2 [options] <id> Register a V2 agent\n get-agent-v2 <id> Get a V2 agent\n list-agents-v2 [options] List V2 agents\n set-agent-status-v2 <id> <next> Set V2 agent status\n activate-agent-v2 <id> Activate a V2 agent\n suspend-agent-v2 <id> Suspend a V2 agent\n revoke-agent-v2 <id> Revoke a V2 agent\n touch-agent-v2 <id> Touch a V2 agent\n create-task-v2 [options] <id> Create a V2 task\n get-task-v2 <id> Get a V2 task\n list-tasks-v2 [options] List V2 tasks\n set-task-status-v2 <id> <next> Set V2 task status\n start-task-v2 <id> Start a V2 task\n complete-task-v2 <id> Complete a V2 task\n fail-task-v2 <id> Fail a V2 task\n cancel-task-v2 <id> Cancel a V2 task\n auto-suspend-idle-agents-v2 Auto-suspend idle V2 agents\n auto-fail-stuck-tasks-v2 Auto-fail stuck V2 tasks\n help [command] display help for command\n",
|
|
10
10
|
"agents": "Usage: chainlesschain agents [options] [command]\n\nUser-defined subagents (.claude/agents/*.md)\n\nOptions:\n -h, --help display help for command\n\nCommands:\n background|bg [options] List background agent sessions\n logs [options] <id> Print recent output from a background agent\n view [options] <id> Show a detailed background agent view\n stop [options] <id> Stop a running background agent\n rename [options] <id> <title...> Rename a background agent session\n list|ls [options] List discovered subagents (project +\n personal)\n show [options] <name> Show an agent's metadata + system prompt\n run [options] <name> [task...] Run a task headlessly as the named subagent\n new [options] <name> Scaffold a new agent file (project-native\n .chainlesschain/agents/)\n help [command] display help for command\n",
|
|
11
11
|
"android": "Usage: chainlesschain android [options] [command]\n\nAndroid-native bridge: ContentResolver / SAF / Accessibility / Shizuku / root\n(Plan A A7)\n\nOptions:\n -h, --help display help for command\n\nCommands:\n caps [options] Probe what bridge capabilities are available on this\n device\n contacts ContentResolver: contacts\n sms ContentResolver: SMS\n calls ContentResolver: call log\n app PackageManager: app inventory + Intent\n fs SAF / sandbox filesystem\n a11y Accessibility Service\n shizuku Shizuku ADB-like privileges\n root Magisk root su\n perms [options] <name> Check (and request) a runtime permission\n help [command] display help for command\n",
|
package/src/commands/agent.js
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
isFormalQualityHermeticRuntime,
|
|
53
53
|
} from "../lib/formal-quality-eval-runtime.js";
|
|
54
54
|
import { withQuietStdout } from "../runtime/quiet-stdout.js";
|
|
55
|
+
import { deliveryPaths } from "../lib/workspace-delivery-receipt.js";
|
|
55
56
|
import {
|
|
56
57
|
createSessionPersistenceFailure,
|
|
57
58
|
projectSessionPersistenceFailure,
|
|
@@ -399,6 +400,11 @@ export function registerAgentCommand(program, dependencies = {}) {
|
|
|
399
400
|
"Extra working directory the agent may read/search/edit (repeatable)",
|
|
400
401
|
(val, prev) => (prev || []).concat([val]),
|
|
401
402
|
)
|
|
403
|
+
.option(
|
|
404
|
+
"--expect-deliverable <path>",
|
|
405
|
+
"Verify a workspace-relative file changed in the first headless turn (repeatable)",
|
|
406
|
+
(val, prev) => (prev || []).concat([val]),
|
|
407
|
+
)
|
|
402
408
|
.option(
|
|
403
409
|
"--checkpoint",
|
|
404
410
|
"Auto-snapshot the work tree before each mutating tool (DEFAULT inside a git repo; cc checkpoint restore to roll back)",
|
|
@@ -781,6 +787,20 @@ export function registerAgentCommand(program, dependencies = {}) {
|
|
|
781
787
|
)
|
|
782
788
|
.action(async (task, options, command) => {
|
|
783
789
|
const formalQualityHermetic = isFormalQualityHermeticRuntime(process.env);
|
|
790
|
+
let expectedDeliverables;
|
|
791
|
+
try {
|
|
792
|
+
expectedDeliverables = deliveryPaths(
|
|
793
|
+
options.expectDeliverable ??
|
|
794
|
+
(formalQualityHermetic &&
|
|
795
|
+
process.env.CC_VERIFY01_DELIVERY_RECEIPTS === "1"
|
|
796
|
+
? formalQualityAllowedFiles(process.env)
|
|
797
|
+
: null),
|
|
798
|
+
);
|
|
799
|
+
} catch (error) {
|
|
800
|
+
process.stderr.write(`Error: ${error.message}\n`);
|
|
801
|
+
process.exitCode = 1;
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
784
804
|
if (formalQualityHermetic) {
|
|
785
805
|
const provider = formalQualityProvider(process.env);
|
|
786
806
|
if (!provider) {
|
|
@@ -1739,6 +1759,7 @@ export function registerAgentCommand(program, dependencies = {}) {
|
|
|
1739
1759
|
},
|
|
1740
1760
|
);
|
|
1741
1761
|
outcome = await runAgentHeadlessStream({
|
|
1762
|
+
deliveryPaths: expectedDeliverables,
|
|
1742
1763
|
unattendedActionPolicy,
|
|
1743
1764
|
toolAdmission,
|
|
1744
1765
|
model: options.model,
|
|
@@ -1861,6 +1882,14 @@ export function registerAgentCommand(program, dependencies = {}) {
|
|
|
1861
1882
|
const piped = (await readStdin()).trim();
|
|
1862
1883
|
if (piped) prompt = piped;
|
|
1863
1884
|
}
|
|
1885
|
+
if (options.expectDeliverable && (!prompt || backgroundRequested)) {
|
|
1886
|
+
process.stderr.write(
|
|
1887
|
+
"--expect-deliverable requires a foreground headless task.\n",
|
|
1888
|
+
);
|
|
1889
|
+
await _finishWorktree();
|
|
1890
|
+
process.exitCode = 1;
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1864
1893
|
|
|
1865
1894
|
// Commander canonicalizes the dual long-option declaration
|
|
1866
1895
|
// `--bg, --background` to `options.background`; retain `options.bg` for
|
|
@@ -2068,6 +2097,7 @@ export function registerAgentCommand(program, dependencies = {}) {
|
|
|
2068
2097
|
// history when the id already exists and creates it otherwise.
|
|
2069
2098
|
resume: options.session,
|
|
2070
2099
|
outputFormat: options.outputFormat,
|
|
2100
|
+
deliveryPaths: expectedDeliverables,
|
|
2071
2101
|
permissionMode: options.permissionMode,
|
|
2072
2102
|
allowedTools: parseToolList(options.allowedTools),
|
|
2073
2103
|
disallowedTools: parseToolList(options.disallowedTools),
|
package/src/data/changelog.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": "CHANGELOG.md",
|
|
3
3
|
"releases": [
|
|
4
|
+
{
|
|
5
|
+
"productVersion": null,
|
|
6
|
+
"cliVersion": "0.166.166",
|
|
7
|
+
"cliVersions": ["0.166.166"],
|
|
8
|
+
"date": "2026-11-27",
|
|
9
|
+
"title": "",
|
|
10
|
+
"sections": [
|
|
11
|
+
{
|
|
12
|
+
"heading": "Fixed - cc CLI 0.166.166 and IDE pairing (candidate, 2026-11-27)",
|
|
13
|
+
"body": "- Verify declared workspace deliverables and show unverified delivery in CLI and IDE results.\n- Classify explicit provider streaming failures and keep automatic replays disabled.\n- Read regular files through a bounded descriptor and reject files above 8 MiB with a typed error.\n- Keep goal transitions atomic when a Windows reader briefly prevents replacing the goal file.\n- Pair CLI 0.166.166 with Open VSX 0.37.201 and JetBrains 0.4.216."
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
4
17
|
{
|
|
5
18
|
"productVersion": null,
|
|
6
19
|
"cliVersion": "0.166.165",
|
|
@@ -1584,6 +1584,10 @@ export class CcAppServer {
|
|
|
1584
1584
|
result: result?.result ?? null,
|
|
1585
1585
|
error: result?.error ?? null,
|
|
1586
1586
|
code: result?.code ?? null,
|
|
1587
|
+
...(result?.error_details
|
|
1588
|
+
? { error_details: result.error_details }
|
|
1589
|
+
: {}),
|
|
1590
|
+
...(result?.delivery ? { delivery: result.delivery } : {}),
|
|
1587
1591
|
},
|
|
1588
1592
|
});
|
|
1589
1593
|
turn.terminalEvidence = {
|
|
@@ -1603,6 +1607,7 @@ export class CcAppServer {
|
|
|
1603
1607
|
await this.send(
|
|
1604
1608
|
rpcNotification("turn/completed", {
|
|
1605
1609
|
turn: turnProjection(turn),
|
|
1610
|
+
...(result?.delivery ? { delivery: result.delivery } : {}),
|
|
1606
1611
|
error:
|
|
1607
1612
|
status === "failed"
|
|
1608
1613
|
? {
|
|
@@ -1611,6 +1616,9 @@ export class CcAppServer {
|
|
|
1611
1616
|
0,
|
|
1612
1617
|
4096,
|
|
1613
1618
|
),
|
|
1619
|
+
...(result?.error_details
|
|
1620
|
+
? { details: result.error_details }
|
|
1621
|
+
: {}),
|
|
1614
1622
|
}
|
|
1615
1623
|
: null,
|
|
1616
1624
|
}),
|
package/src/lib/chat-core.js
CHANGED
|
@@ -319,23 +319,25 @@ export async function streamOpenAI(
|
|
|
319
319
|
try {
|
|
320
320
|
while (true) {
|
|
321
321
|
const { done, value } = await reader.read();
|
|
322
|
-
if (done)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
buf += decoder.decode(value, { stream: true });
|
|
322
|
+
if (!done) guard.bump();
|
|
323
|
+
buf += done ? decoder.decode() : decoder.decode(value, { stream: true });
|
|
326
324
|
const lines = buf.split("\n");
|
|
327
|
-
buf = lines.pop() || "";
|
|
325
|
+
if (!done) buf = lines.pop() || "";
|
|
328
326
|
|
|
329
327
|
for (const line of lines) {
|
|
330
|
-
if (line.startsWith("data:
|
|
331
|
-
const data = line.slice(
|
|
328
|
+
if (line.startsWith("data:")) {
|
|
329
|
+
const data = line.slice(5).trim();
|
|
332
330
|
if (data === "[DONE]") {
|
|
333
331
|
completed = true;
|
|
334
332
|
continue;
|
|
335
333
|
}
|
|
336
334
|
try {
|
|
337
335
|
const json = JSON.parse(data);
|
|
338
|
-
if (json?.error)
|
|
336
|
+
if (json?.error)
|
|
337
|
+
throw createChatCompletionsStreamError(
|
|
338
|
+
json.error,
|
|
339
|
+
Boolean(fullResponse),
|
|
340
|
+
);
|
|
339
341
|
const content = json.choices?.[0]?.delta?.content;
|
|
340
342
|
if (content) {
|
|
341
343
|
fullResponse += content;
|
|
@@ -363,6 +365,7 @@ export async function streamOpenAI(
|
|
|
363
365
|
}
|
|
364
366
|
}
|
|
365
367
|
}
|
|
368
|
+
if (done) break;
|
|
366
369
|
}
|
|
367
370
|
} catch (e) {
|
|
368
371
|
if (e?.code === CHAT_COMPLETIONS_STREAM_FAILED)
|
package/src/lib/goal-store.js
CHANGED
|
@@ -20,6 +20,7 @@ import fs from "node:fs";
|
|
|
20
20
|
import path from "node:path";
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
22
|
import { getHomeDir } from "./paths.js";
|
|
23
|
+
import { renameWithRetry } from "./config-manager.js";
|
|
23
24
|
import { withFileLock } from "./with-file-lock.js";
|
|
24
25
|
import {
|
|
25
26
|
createGoalRecord,
|
|
@@ -90,7 +91,9 @@ function atomicWriteFileSync(filePath, data) {
|
|
|
90
91
|
const tmp = `${filePath}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
|
|
91
92
|
try {
|
|
92
93
|
fs.writeFileSync(tmp, data, "utf-8");
|
|
93
|
-
|
|
94
|
+
// A concurrent goal watcher can briefly hold the destination open on
|
|
95
|
+
// Windows. Retry the same replacement while the mutation lock is held.
|
|
96
|
+
renameWithRetry(tmp, filePath, { _rename: fs.renameSync });
|
|
94
97
|
} catch (err) {
|
|
95
98
|
try {
|
|
96
99
|
if (fs.existsSync(tmp)) fs.unlinkSync(tmp);
|
|
@@ -116,7 +116,7 @@ async function directoryFiles(root, check, maxFiles) {
|
|
|
116
116
|
export async function captureGoalWorkspace(
|
|
117
117
|
cwd,
|
|
118
118
|
call,
|
|
119
|
-
{ signal, limits = {} } = {},
|
|
119
|
+
{ signal, limits = {}, allowMissingArtifact = false } = {},
|
|
120
120
|
) {
|
|
121
121
|
const bounds = { ...LIMITS, ...limits };
|
|
122
122
|
const started = Date.now();
|
|
@@ -176,8 +176,13 @@ export async function captureGoalWorkspace(
|
|
|
176
176
|
try {
|
|
177
177
|
before = await fsp.lstat(target, { bigint: true });
|
|
178
178
|
} catch (error) {
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
if (artifact && allowMissingArtifact && error.code === "ENOENT") {
|
|
180
|
+
// Keep the same absence checks as deleted tracked files. The result
|
|
181
|
+
// supports a before/after comparison, never positive completion.
|
|
182
|
+
identities.push([target, null]);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
// Deleted tracked files are part of the current source version.
|
|
181
186
|
if (scope !== "git-visible-files-under-cwd" || error.code !== "ENOENT")
|
|
182
187
|
throw error;
|
|
183
188
|
content.update(
|
|
@@ -131,6 +131,7 @@ export async function* openAIStream({
|
|
|
131
131
|
throw new Error(`${res.status} ${res.statusText}`);
|
|
132
132
|
}
|
|
133
133
|
let completed = false;
|
|
134
|
+
let outputReceived = false;
|
|
134
135
|
for await (const raw of responseLines(res.body)) {
|
|
135
136
|
const line = raw.trim();
|
|
136
137
|
if (!line || !line.startsWith("data:")) continue;
|
|
@@ -143,9 +144,13 @@ export async function* openAIStream({
|
|
|
143
144
|
}
|
|
144
145
|
try {
|
|
145
146
|
const obj = JSON.parse(payload);
|
|
146
|
-
if (obj?.error)
|
|
147
|
+
if (obj?.error)
|
|
148
|
+
throw createChatCompletionsStreamError(obj.error, outputReceived);
|
|
147
149
|
const delta = obj?.choices?.[0]?.delta?.content;
|
|
148
|
-
if (delta)
|
|
150
|
+
if (delta) {
|
|
151
|
+
outputReceived = true;
|
|
152
|
+
yield delta;
|
|
153
|
+
}
|
|
149
154
|
} catch (error) {
|
|
150
155
|
if (requireCompletion || error?.code === CHAT_COMPLETIONS_STREAM_FAILED)
|
|
151
156
|
throw error;
|
|
@@ -1,5 +1,40 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { readBoundedDescriptor } from "./evolution/bounded-descriptor-read.js";
|
|
1
3
|
import { recoverCompleteSourceRead } from "./source-read-recovery.js";
|
|
2
4
|
|
|
5
|
+
export const MAX_READ_FILE_BYTES = 8 * 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
export function readRegularFileForPages(path, before, signal) {
|
|
8
|
+
signal?.throwIfAborted();
|
|
9
|
+
const descriptor = fs.openSync(
|
|
10
|
+
path,
|
|
11
|
+
fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK || 0),
|
|
12
|
+
);
|
|
13
|
+
const matches = (stat) =>
|
|
14
|
+
stat.isFile() &&
|
|
15
|
+
stat.ino === before.ino &&
|
|
16
|
+
(process.platform === "win32" || stat.dev === before.dev) &&
|
|
17
|
+
stat.size === before.size &&
|
|
18
|
+
stat.mtimeMs === before.mtimeMs &&
|
|
19
|
+
stat.ctimeMs === before.ctimeMs;
|
|
20
|
+
try {
|
|
21
|
+
if (!matches(fs.fstatSync(descriptor)))
|
|
22
|
+
throw new Error("file changed before read");
|
|
23
|
+
const bytes = readBoundedDescriptor(
|
|
24
|
+
fs,
|
|
25
|
+
descriptor,
|
|
26
|
+
before.size,
|
|
27
|
+
MAX_READ_FILE_BYTES,
|
|
28
|
+
);
|
|
29
|
+
if (!matches(fs.fstatSync(descriptor)) || !matches(fs.statSync(path)))
|
|
30
|
+
throw new Error("file changed during read");
|
|
31
|
+
signal?.throwIfAborted();
|
|
32
|
+
return bytes.toString("utf8");
|
|
33
|
+
} finally {
|
|
34
|
+
fs.closeSync(descriptor);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
3
38
|
/** Build a bounded read result with a cursor describing what was actually read. */
|
|
4
39
|
export function buildReadFilePage(
|
|
5
40
|
rendered,
|
package/src/lib/stream-retry.js
CHANGED
|
@@ -27,14 +27,66 @@ export const STREAM_RETRY_MAX_DELAY_MS = 60_000;
|
|
|
27
27
|
export const CHAT_COMPLETIONS_STREAM_FAILED =
|
|
28
28
|
"CC_CHAT_COMPLETIONS_STREAM_FAILED";
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const providerStreamErrors = new WeakMap();
|
|
31
|
+
|
|
32
|
+
export function createChatCompletionsStreamError(
|
|
33
|
+
payload,
|
|
34
|
+
outputReceived = false,
|
|
35
|
+
) {
|
|
36
|
+
const identifiers = [payload?.code, payload?.type];
|
|
37
|
+
let category = "unknown";
|
|
38
|
+
let message = "OpenAI-compatible stream returned a provider error";
|
|
39
|
+
// Only recognized protocol identifiers become diagnostics. Gateway text and
|
|
40
|
+
// unrecognized identifiers may include secrets or request content.
|
|
41
|
+
if (
|
|
42
|
+
identifiers.includes("insufficient_quota") ||
|
|
43
|
+
identifiers.includes("billing_hard_limit_reached")
|
|
44
|
+
) {
|
|
45
|
+
category = "quota_exhausted";
|
|
46
|
+
message =
|
|
47
|
+
"Model provider quota exhausted. Check the provider account balance and spending limits.";
|
|
48
|
+
} else if (
|
|
49
|
+
identifiers.includes("rate_limit_exceeded") ||
|
|
50
|
+
identifiers.includes("rate_limit_error")
|
|
51
|
+
) {
|
|
52
|
+
category = "rate_limited";
|
|
53
|
+
message =
|
|
54
|
+
"Model provider rate limit reached. Wait before retrying explicitly.";
|
|
55
|
+
} else if (
|
|
56
|
+
identifiers.includes("server_error") ||
|
|
57
|
+
identifiers.includes("internal_server_error") ||
|
|
58
|
+
identifiers.includes("upstream_error") ||
|
|
59
|
+
identifiers.includes("overloaded_error") ||
|
|
60
|
+
(payload?.type === "new_api_error" &&
|
|
61
|
+
typeof payload.message === "string" &&
|
|
62
|
+
/\bupstream stream ended before the response\b/i.test(
|
|
63
|
+
payload.message.slice(0, 256),
|
|
64
|
+
))
|
|
65
|
+
) {
|
|
66
|
+
category = "upstream_failure";
|
|
67
|
+
message =
|
|
68
|
+
"Model provider reported an upstream failure. Check provider status before retrying explicitly.";
|
|
69
|
+
}
|
|
70
|
+
const error = Object.assign(new Error(message), {
|
|
71
|
+
code: CHAT_COMPLETIONS_STREAM_FAILED,
|
|
72
|
+
noReplay: true,
|
|
73
|
+
});
|
|
74
|
+
providerStreamErrors.set(
|
|
75
|
+
error,
|
|
76
|
+
Object.freeze({
|
|
77
|
+
kind: "provider_stream",
|
|
34
78
|
code: CHAT_COMPLETIONS_STREAM_FAILED,
|
|
79
|
+
category,
|
|
80
|
+
outputReceived: outputReceived === true,
|
|
81
|
+
usageSettlement: "unconfirmed",
|
|
35
82
|
noReplay: true,
|
|
36
|
-
},
|
|
83
|
+
}),
|
|
37
84
|
);
|
|
85
|
+
return error;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function providerStreamErrorDetails(error) {
|
|
89
|
+
return providerStreamErrors.get(error);
|
|
38
90
|
}
|
|
39
91
|
|
|
40
92
|
export function cancelProviderStreamReader(reader) {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
export const DELIVERY_UNVERIFIED = "CC_DELIVERABLE_UNVERIFIED";
|
|
4
|
+
export const DELIVERY_UNVERIFIED_MESSAGE =
|
|
5
|
+
"Delivery unverified. At least one expected file has no verified content change.";
|
|
6
|
+
|
|
7
|
+
export function deliveryPaths(values) {
|
|
8
|
+
if (values == null) return [];
|
|
9
|
+
if (!Array.isArray(values) || values.length > 16) {
|
|
10
|
+
throw new TypeError("Specify at most 16 workspace deliverable paths.");
|
|
11
|
+
}
|
|
12
|
+
return [
|
|
13
|
+
...new Set(
|
|
14
|
+
values.map((value) => {
|
|
15
|
+
if (
|
|
16
|
+
typeof value !== "string" ||
|
|
17
|
+
value.length > 1024 ||
|
|
18
|
+
/[:\\]/.test(value) ||
|
|
19
|
+
Array.from(value).some((character) => character.charCodeAt(0) < 32)
|
|
20
|
+
) {
|
|
21
|
+
throw new TypeError(
|
|
22
|
+
"Expected deliverables must use workspace-relative paths with forward slashes.",
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const file = path.posix.normalize(value);
|
|
26
|
+
if (
|
|
27
|
+
!value ||
|
|
28
|
+
file === "." ||
|
|
29
|
+
file === ".." ||
|
|
30
|
+
file.startsWith("../") ||
|
|
31
|
+
file.startsWith("/") ||
|
|
32
|
+
file.endsWith("/")
|
|
33
|
+
) {
|
|
34
|
+
throw new TypeError(
|
|
35
|
+
"Expected deliverables must name files within the workspace.",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return file;
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function snapshotDelivery(cwd, paths, signal) {
|
|
45
|
+
const files = deliveryPaths(paths);
|
|
46
|
+
if (!files.length) return null;
|
|
47
|
+
const { captureGoalWorkspace } = await import("./goal-workspace-evidence.js");
|
|
48
|
+
const snapshots = await Promise.all(
|
|
49
|
+
files.map((file) =>
|
|
50
|
+
captureGoalWorkspace(
|
|
51
|
+
cwd,
|
|
52
|
+
{ tool: "read_file", args: { path: file } },
|
|
53
|
+
{
|
|
54
|
+
signal,
|
|
55
|
+
allowMissingArtifact: true,
|
|
56
|
+
limits: { maxFileBytes: 4 * 1024 * 1024, maxMs: 2000 },
|
|
57
|
+
},
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
);
|
|
61
|
+
return files.map((path, index) => ({ path, ...snapshots[index] }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function verifyDelivery(
|
|
65
|
+
cwd,
|
|
66
|
+
before,
|
|
67
|
+
{ sessionId, turnId, signal },
|
|
68
|
+
) {
|
|
69
|
+
if (!before) return null;
|
|
70
|
+
const after = await snapshotDelivery(
|
|
71
|
+
cwd,
|
|
72
|
+
before.map(({ path }) => path),
|
|
73
|
+
signal,
|
|
74
|
+
);
|
|
75
|
+
const files = after.map((current, index) => {
|
|
76
|
+
const previous = before[index];
|
|
77
|
+
const digest = current.artifacts?.[0]?.digest;
|
|
78
|
+
const status =
|
|
79
|
+
!previous.verified ||
|
|
80
|
+
!current.verified ||
|
|
81
|
+
previous.workspaceId !== current.workspaceId
|
|
82
|
+
? "unavailable"
|
|
83
|
+
: !digest
|
|
84
|
+
? "missing"
|
|
85
|
+
: previous.artifacts[0]?.digest === digest
|
|
86
|
+
? "unchanged"
|
|
87
|
+
: "changed";
|
|
88
|
+
return { path: current.path, status, ...(digest ? { digest } : {}) };
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
session_id: sessionId,
|
|
92
|
+
turn_id: turnId,
|
|
93
|
+
status: files.every(({ status }) => status === "changed")
|
|
94
|
+
? "verified"
|
|
95
|
+
: "unverified",
|
|
96
|
+
files,
|
|
97
|
+
checks: "not_verified",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -74,6 +74,8 @@ export {
|
|
|
74
74
|
import path from "path";
|
|
75
75
|
import {
|
|
76
76
|
buildReadFilePage,
|
|
77
|
+
MAX_READ_FILE_BYTES,
|
|
78
|
+
readRegularFileForPages,
|
|
77
79
|
buildReadFileOutline,
|
|
78
80
|
} from "../lib/read-file-page.js";
|
|
79
81
|
import { ReadFileLoopGuard } from "../lib/read-file-loop-guard.js";
|
|
@@ -5851,6 +5853,20 @@ async function executeToolInner(
|
|
|
5851
5853
|
error: `Path is a directory, not a file: ${filePath}. Use list_dir to see its contents.`,
|
|
5852
5854
|
});
|
|
5853
5855
|
}
|
|
5856
|
+
if (!fileStat.isFile()) {
|
|
5857
|
+
return attachDescriptor({
|
|
5858
|
+
code: "CC_READ_FILE_NOT_REGULAR",
|
|
5859
|
+
error:
|
|
5860
|
+
"Read requires a regular file. Pipes and device files are unsupported.",
|
|
5861
|
+
});
|
|
5862
|
+
}
|
|
5863
|
+
if (fileStat.size > MAX_READ_FILE_BYTES) {
|
|
5864
|
+
return attachDescriptor({
|
|
5865
|
+
code: "CC_READ_FILE_SIZE_LIMIT",
|
|
5866
|
+
error: `File exceeds the ${MAX_READ_FILE_BYTES}-byte read limit. Search for the needed section or use a smaller source file.`,
|
|
5867
|
+
});
|
|
5868
|
+
}
|
|
5869
|
+
signal?.throwIfAborted();
|
|
5854
5870
|
const fileVersion = `${fileStat.size}:${fileStat.mtimeMs}:${fileStat.ctimeMs}`;
|
|
5855
5871
|
_recordFileObservation(filePath);
|
|
5856
5872
|
let rendered;
|
|
@@ -5858,7 +5874,7 @@ async function executeToolInner(
|
|
|
5858
5874
|
let outline;
|
|
5859
5875
|
const render = () => {
|
|
5860
5876
|
if (rendered !== undefined) return rendered;
|
|
5861
|
-
const content =
|
|
5877
|
+
const content = readRegularFileForPages(filePath, fileStat, signal);
|
|
5862
5878
|
nbView =
|
|
5863
5879
|
args.raw !== true && /\.ipynb$/i.test(filePath)
|
|
5864
5880
|
? renderNotebook(content)
|
|
@@ -26,6 +26,13 @@ import { createPersistedModelInputObserver } from "../lib/session-model-input-di
|
|
|
26
26
|
import { randomUUID } from "node:crypto";
|
|
27
27
|
import { isProxy } from "node:util/types";
|
|
28
28
|
import { transportErrorDetails } from "../lib/transport-error-details.js";
|
|
29
|
+
import { providerStreamErrorDetails } from "../lib/stream-retry.js";
|
|
30
|
+
import {
|
|
31
|
+
DELIVERY_UNVERIFIED,
|
|
32
|
+
DELIVERY_UNVERIFIED_MESSAGE,
|
|
33
|
+
snapshotDelivery,
|
|
34
|
+
verifyDelivery,
|
|
35
|
+
} from "../lib/workspace-delivery-receipt.js";
|
|
29
36
|
import { captureAgentExecutionPolicy } from "../lib/agent-execution-policy.js";
|
|
30
37
|
import { resolveLlmConnection } from "../lib/llm-connection-resolution.js";
|
|
31
38
|
import { HERMETIC_CODING_SYSTEM_PROMPT } from "../lib/coding-task-guidance.js";
|
|
@@ -1241,6 +1248,11 @@ async function runAgentHeadlessInWorkspace(
|
|
|
1241
1248
|
let model = connection.model;
|
|
1242
1249
|
const { provider, baseUrl, apiKey } = connection;
|
|
1243
1250
|
const cwd = options.cwd || process.cwd();
|
|
1251
|
+
const deliveryBefore = await snapshotDelivery(
|
|
1252
|
+
cwd,
|
|
1253
|
+
options.deliveryPaths,
|
|
1254
|
+
options.signal,
|
|
1255
|
+
);
|
|
1244
1256
|
const formalQualityHermetic = isFormalQualityHermeticRuntime(process.env);
|
|
1245
1257
|
const hermeticExecution =
|
|
1246
1258
|
options.hermeticExecution === true || formalQualityHermetic;
|
|
@@ -4481,19 +4493,23 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4481
4493
|
: err?.goalModelFailure || err?.goalVerificationFailure
|
|
4482
4494
|
? err.subtype
|
|
4483
4495
|
: "error";
|
|
4496
|
+
const providerDetails =
|
|
4497
|
+
errorSubtype === "error" ? providerStreamErrorDetails(err) : undefined;
|
|
4484
4498
|
const transportDetails =
|
|
4485
4499
|
errorSubtype === "error" ? transportErrorDetails(err) : undefined;
|
|
4486
|
-
const diagnosticFields =
|
|
4487
|
-
? { error_details:
|
|
4488
|
-
:
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4500
|
+
const diagnosticFields = providerDetails
|
|
4501
|
+
? { code: providerDetails.code, error_details: providerDetails }
|
|
4502
|
+
: transportDetails
|
|
4503
|
+
? { error_details: transportDetails }
|
|
4504
|
+
: {
|
|
4505
|
+
...((persistenceFailed || err?.goalVerificationFailure) && err.code
|
|
4506
|
+
? { code: err.code }
|
|
4507
|
+
: {}),
|
|
4508
|
+
...(err?.goalVerificationFailure && err.verification
|
|
4509
|
+
? { verification: err.verification }
|
|
4510
|
+
: {}),
|
|
4511
|
+
...(persistence ? { persistence } : {}),
|
|
4512
|
+
};
|
|
4497
4513
|
if (isStream) {
|
|
4498
4514
|
emitStream({
|
|
4499
4515
|
type: "result",
|
|
@@ -4537,9 +4553,11 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4537
4553
|
exitCode:
|
|
4538
4554
|
persistenceFailed || sessionBudgetFailed
|
|
4539
4555
|
? 1
|
|
4540
|
-
:
|
|
4541
|
-
?
|
|
4542
|
-
:
|
|
4556
|
+
: providerDetails
|
|
4557
|
+
? HEADLESS_EXIT_CODES.MODEL_ERROR
|
|
4558
|
+
: err?.goalModelFailure || err?.goalVerificationFailure
|
|
4559
|
+
? exitCodeForEndReason(err.endReason, true)
|
|
4560
|
+
: classifyLoopError(err),
|
|
4543
4561
|
result: message,
|
|
4544
4562
|
isError: true,
|
|
4545
4563
|
...(persistence ? { persistence } : {}),
|
|
@@ -4550,6 +4568,9 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4550
4568
|
}
|
|
4551
4569
|
: {}),
|
|
4552
4570
|
...(persistenceFailed && err.code ? { code: err.code } : {}),
|
|
4571
|
+
...(providerDetails
|
|
4572
|
+
? { code: providerDetails.code, error_details: providerDetails }
|
|
4573
|
+
: {}),
|
|
4553
4574
|
};
|
|
4554
4575
|
} finally {
|
|
4555
4576
|
// Capture body-cache hits/misses caused by list_skills/run_skill during the
|
|
@@ -4739,6 +4760,22 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4739
4760
|
: isError
|
|
4740
4761
|
? "error"
|
|
4741
4762
|
: "success";
|
|
4763
|
+
const delivery =
|
|
4764
|
+
!isError && deliveryBefore
|
|
4765
|
+
? await verifyDelivery(cwd, deliveryBefore, {
|
|
4766
|
+
sessionId,
|
|
4767
|
+
turnId: options.turnId || randomUUID(),
|
|
4768
|
+
signal: options.signal,
|
|
4769
|
+
})
|
|
4770
|
+
: null;
|
|
4771
|
+
const deliveryUnverified = delivery?.status === "unverified";
|
|
4772
|
+
if (deliveryUnverified) {
|
|
4773
|
+
isError = true;
|
|
4774
|
+
subtype = "error_deliverable_unverified";
|
|
4775
|
+
if (isText) writeErr(DELIVERY_UNVERIFIED_MESSAGE + "\n");
|
|
4776
|
+
} else if (isText && delivery) {
|
|
4777
|
+
writeErr("Delivery files verified. Checks are unverified.\n");
|
|
4778
|
+
}
|
|
4742
4779
|
const durationMs = (deps.now ? deps.now() : Date.now()) - startedAt;
|
|
4743
4780
|
let persistenceFailure = null;
|
|
4744
4781
|
let sessionPersistenceCode = null;
|
|
@@ -4903,7 +4940,16 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4903
4940
|
|
|
4904
4941
|
const resultCode =
|
|
4905
4942
|
sessionPersistenceCode ||
|
|
4943
|
+
(subtype === "error_deliverable_unverified" ? DELIVERY_UNVERIFIED : null) ||
|
|
4906
4944
|
(deniedDestructiveRequest ? DESTRUCTIVE_SHELL_DENIAL_CODE : null);
|
|
4945
|
+
const deliveryFields = delivery
|
|
4946
|
+
? {
|
|
4947
|
+
delivery,
|
|
4948
|
+
...(resultCode === DELIVERY_UNVERIFIED
|
|
4949
|
+
? { error: DELIVERY_UNVERIFIED_MESSAGE }
|
|
4950
|
+
: {}),
|
|
4951
|
+
}
|
|
4952
|
+
: {};
|
|
4907
4953
|
if (isStream) {
|
|
4908
4954
|
emitStream({
|
|
4909
4955
|
type: "result",
|
|
@@ -4920,6 +4966,7 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4920
4966
|
: {}),
|
|
4921
4967
|
...(persistenceFailure ? { persistence: persistenceFailure } : {}),
|
|
4922
4968
|
...(resultCode ? { code: resultCode } : {}),
|
|
4969
|
+
...deliveryFields,
|
|
4923
4970
|
});
|
|
4924
4971
|
} else if (isJson) {
|
|
4925
4972
|
writeOut(
|
|
@@ -4939,6 +4986,7 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4939
4986
|
persistence: persistenceFailure,
|
|
4940
4987
|
}),
|
|
4941
4988
|
...(resultCode ? { code: resultCode } : {}),
|
|
4989
|
+
...deliveryFields,
|
|
4942
4990
|
}) + "\n",
|
|
4943
4991
|
);
|
|
4944
4992
|
} else {
|
|
@@ -4987,6 +5035,7 @@ async function runAgentHeadlessInWorkspace(
|
|
|
4987
5035
|
isError,
|
|
4988
5036
|
...(persistenceFailure ? { persistence: persistenceFailure } : {}),
|
|
4989
5037
|
...(resultCode ? { code: resultCode } : {}),
|
|
5038
|
+
...deliveryFields,
|
|
4990
5039
|
};
|
|
4991
5040
|
}
|
|
4992
5041
|
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
import { createPersistedModelInputObserver } from "../lib/session-model-input-diagnostics.js";
|
|
20
20
|
import { randomUUID } from "node:crypto";
|
|
21
21
|
import { transportErrorDetails } from "../lib/transport-error-details.js";
|
|
22
|
+
import { providerStreamErrorDetails } from "../lib/stream-retry.js";
|
|
23
|
+
import {
|
|
24
|
+
DELIVERY_UNVERIFIED,
|
|
25
|
+
DELIVERY_UNVERIFIED_MESSAGE,
|
|
26
|
+
snapshotDelivery,
|
|
27
|
+
verifyDelivery,
|
|
28
|
+
} from "../lib/workspace-delivery-receipt.js";
|
|
22
29
|
import { storageFailureCauseSuffix } from "../lib/storage-failure-cause-codes.js";
|
|
23
30
|
import { captureAgentExecutionPolicy } from "../lib/agent-execution-policy.js";
|
|
24
31
|
import { resolveLlmConnection } from "../lib/llm-connection-resolution.js";
|
|
@@ -5872,7 +5879,15 @@ async function runAgentHeadlessStreamInWorkspace(
|
|
|
5872
5879
|
}
|
|
5873
5880
|
|
|
5874
5881
|
let outcome;
|
|
5882
|
+
let deliveryBefore = null;
|
|
5875
5883
|
try {
|
|
5884
|
+
if (turns === 1) {
|
|
5885
|
+
deliveryBefore = await snapshotDelivery(
|
|
5886
|
+
cwd,
|
|
5887
|
+
options.deliveryPaths,
|
|
5888
|
+
turnSignal,
|
|
5889
|
+
);
|
|
5890
|
+
}
|
|
5876
5891
|
outcome = await runTurn(
|
|
5877
5892
|
messages,
|
|
5878
5893
|
{
|
|
@@ -6088,13 +6103,15 @@ async function runAgentHeadlessStreamInWorkspace(
|
|
|
6088
6103
|
break;
|
|
6089
6104
|
}
|
|
6090
6105
|
if (!settleToolRoundsForHost("after-model")) break;
|
|
6091
|
-
const
|
|
6106
|
+
const providerDetails = providerStreamErrorDetails(err);
|
|
6107
|
+
const errorDetails = providerDetails || transportErrorDetails(err);
|
|
6092
6108
|
emit({
|
|
6093
6109
|
type: "result",
|
|
6094
6110
|
subtype: "error",
|
|
6095
6111
|
is_error: true,
|
|
6096
6112
|
error: err?.message || String(err),
|
|
6097
|
-
...(
|
|
6113
|
+
...(providerDetails ? { code: providerDetails.code } : {}),
|
|
6114
|
+
...(errorDetails ? { error_details: errorDetails } : {}),
|
|
6098
6115
|
turn: turns,
|
|
6099
6116
|
});
|
|
6100
6117
|
sawError = true;
|
|
@@ -6237,13 +6254,23 @@ async function runAgentHeadlessStreamInWorkspace(
|
|
|
6237
6254
|
const costStopped = outcome.endReason === "cost-budget-exhausted";
|
|
6238
6255
|
const deniedDestructiveRequest =
|
|
6239
6256
|
outcome.endReason === "complete" && outcome.destructiveDenials.length > 0;
|
|
6240
|
-
const
|
|
6257
|
+
const runtimeError =
|
|
6241
6258
|
exhausted ||
|
|
6242
6259
|
costStopped ||
|
|
6243
6260
|
deniedDestructiveRequest ||
|
|
6244
6261
|
outcome.endReason === "no-response" ||
|
|
6245
6262
|
outcome.endReason === "deferred-mutation-unresolved" ||
|
|
6246
6263
|
Boolean(persistenceFailure);
|
|
6264
|
+
const delivery =
|
|
6265
|
+
!runtimeError && deliveryBefore
|
|
6266
|
+
? await verifyDelivery(cwd, deliveryBefore, {
|
|
6267
|
+
sessionId,
|
|
6268
|
+
turnId: parsed.clientMessageId || `${traceId}:${turns}`,
|
|
6269
|
+
signal: turnSignal,
|
|
6270
|
+
})
|
|
6271
|
+
: null;
|
|
6272
|
+
const deliveryUnverified = delivery?.status === "unverified";
|
|
6273
|
+
const isError = runtimeError || deliveryUnverified;
|
|
6247
6274
|
if (isError) sawError = true;
|
|
6248
6275
|
const transcriptRefs = !persistenceFailure
|
|
6249
6276
|
? transcriptResultReferences({
|
|
@@ -6272,9 +6299,11 @@ async function runAgentHeadlessStreamInWorkspace(
|
|
|
6272
6299
|
? "error_max_budget"
|
|
6273
6300
|
: persistenceFailure
|
|
6274
6301
|
? "error_persistence"
|
|
6275
|
-
:
|
|
6276
|
-
? "
|
|
6277
|
-
:
|
|
6302
|
+
: deliveryUnverified
|
|
6303
|
+
? "error_deliverable_unverified"
|
|
6304
|
+
: isError
|
|
6305
|
+
? "error"
|
|
6306
|
+
: "success",
|
|
6278
6307
|
is_error: isError,
|
|
6279
6308
|
result: outcome.finalText,
|
|
6280
6309
|
session_id: sessionId,
|
|
@@ -6282,6 +6311,10 @@ async function runAgentHeadlessStreamInWorkspace(
|
|
|
6282
6311
|
usage: outcome.usage,
|
|
6283
6312
|
...(transcriptRefs ? { transcript_refs: transcriptRefs } : {}),
|
|
6284
6313
|
...(persistenceFailure ? { persistence: persistenceFailure } : {}),
|
|
6314
|
+
...(delivery ? { delivery } : {}),
|
|
6315
|
+
...(deliveryUnverified
|
|
6316
|
+
? { code: DELIVERY_UNVERIFIED, error: DELIVERY_UNVERIFIED_MESSAGE }
|
|
6317
|
+
: {}),
|
|
6285
6318
|
...(deniedDestructiveRequest && !persistenceFailure
|
|
6286
6319
|
? { code: DESTRUCTIVE_SHELL_DENIAL_CODE }
|
|
6287
6320
|
: {}),
|
|
@@ -322,7 +322,11 @@ export function _openaiReduceLine(state, raw, onToken) {
|
|
|
322
322
|
state.terminationInvalid = true;
|
|
323
323
|
return state;
|
|
324
324
|
}
|
|
325
|
-
if (obj?.error)
|
|
325
|
+
if (obj?.error)
|
|
326
|
+
throw createChatCompletionsStreamError(
|
|
327
|
+
obj.error,
|
|
328
|
+
Boolean(state.text || state.tools.length),
|
|
329
|
+
);
|
|
326
330
|
if (state.streamDone) state.terminationInvalid = true;
|
|
327
331
|
if (!Array.isArray(obj.choices) || obj.choices.length > 1) {
|
|
328
332
|
state.terminationInvalid = true;
|