@sema-agent/core 7.51.2 → 7.53.0
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/CHANGELOG.md +698 -2
- package/README.md +3 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cross-session-envelope.d.ts +8 -0
- package/dist/agents/cross-session-envelope.js +6 -0
- package/dist/agents/cross-session-judge.d.ts +21 -1
- package/dist/agents/cross-session-judge.js +8 -0
- package/dist/agents/cross-session-ref.d.ts +5 -0
- package/dist/agents/cross-session-ref.js +1 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/org-delivery-gate.d.ts +122 -0
- package/dist/agents/org-delivery-gate.js +69 -0
- package/dist/agents/peer-held-queue.d.ts +9 -4
- package/dist/agents/peer-held-queue.js +6 -5
- package/dist/agents/peer-session-drain.d.ts +35 -5
- package/dist/agents/peer-session-drain.js +271 -180
- package/dist/agents/read-inbox-tool.d.ts +8 -1
- package/dist/agents/read-inbox-tool.js +5 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +105 -76
- package/dist/agents/tool-filter.d.ts +58 -13
- package/dist/agents/tool-filter.js +34 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.d.ts +6 -1
- package/dist/brain/anthropic.js +17 -13
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +6 -5
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +123 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/routing.d.ts +24 -1
- package/dist/brain/routing.js +54 -19
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/timeout.js +5 -4
- package/dist/core/a2a.d.ts +5 -2
- package/dist/core/a2a.js +30 -13
- package/dist/core/allow-entry.d.ts +42 -9
- package/dist/core/allow-entry.js +25 -18
- package/dist/core/auto-compaction.d.ts +80 -20
- package/dist/core/auto-compaction.js +65 -18
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +57 -24
- package/dist/core/checkpoint-store.js +3 -3
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/compliance.js +3 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/effective-path-target.d.ts +25 -6
- package/dist/core/effective-path-target.js +24 -2
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +49 -21
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +8 -25
- package/dist/core/gate-lanes.js +358 -274
- package/dist/core/gate-outcome.d.ts +11 -6
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +12 -3
- package/dist/core/hands-band-screen.d.ts +7 -0
- package/dist/core/hands-band-screen.js +32 -0
- package/dist/core/hooks.d.ts +283 -739
- package/dist/core/hooks.js +100 -193
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/locked-config.d.ts +84 -32
- package/dist/core/locked-config.js +128 -42
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +3 -3
- package/dist/core/mcp-server-spec.d.ts +104 -10
- package/dist/core/mcp-server-spec.js +183 -33
- package/dist/core/mcp.d.ts +31 -20
- package/dist/core/mcp.js +66 -56
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +22 -30
- package/dist/core/memory-engine/engine.js +16 -10
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +5 -16
- package/dist/core/mode-policy.js +7 -19
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +699 -0
- package/dist/core/mods/kernel/events.d.ts +245 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +94 -0
- package/dist/core/mods/kernel/receive.js +188 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +149 -0
- package/dist/core/mods/kernel/site-rules.js +296 -0
- package/dist/core/mods/stations.d.ts +344 -0
- package/dist/core/mods/stations.js +437 -0
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +71 -2
- package/dist/core/own-property-receipt.d.ts +13 -0
- package/dist/core/own-property-receipt.js +13 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-model.d.ts +58 -9
- package/dist/core/permission-rule-model.js +81 -7
- package/dist/core/permission-rule-org.d.ts +163 -33
- package/dist/core/permission-rule-org.js +205 -71
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +14 -2
- package/dist/core/permission-rules.js +63 -23
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retention.js +7 -2
- package/dist/core/retired-keys.d.ts +12 -2
- package/dist/core/retired-keys.js +15 -1
- package/dist/core/roles.js +60 -10
- package/dist/core/rule-lane-reads.js +1 -1
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +86 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +12 -5
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +52 -10
- package/dist/core/runner/mcp-redial.js +38 -9
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
- package/dist/core/runner/permission-rule-lanes.js +22 -10
- package/dist/core/runner/person-path-rows.d.ts +3 -1
- package/dist/core/runner/person-path-rows.js +3 -2
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +52 -1
- package/dist/core/runner/prepare-config-doors.js +168 -143
- package/dist/core/runner/prepare-defer-classify.js +7 -11
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +7 -5
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
- package/dist/core/runner/prepare-hands-readface.js +2 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +10 -23
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
- package/dist/core/runner/prepare-memory-engine-session.js +20 -7
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +6 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
- package/dist/core/runner/prepare-offload-wrappers.js +2 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
- package/dist/core/runner/prepare-policy-chain.js +104 -109
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +11 -12
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +138 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
- package/dist/core/runner/prepare-prompt-inputs.js +11 -10
- package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
- package/dist/core/runner/prepare-protocol-tools.js +20 -13
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-question-face.js +4 -3
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +41 -23
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +13 -9
- package/dist/core/runner/prepare-wiring-manifest.js +14 -11
- package/dist/core/runner/resume-admission.d.ts +4 -1
- package/dist/core/runner/resume-admission.js +7 -5
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
- package/dist/core/runner/resume-internals-and-config.js +3 -8
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.d.ts +5 -6
- package/dist/core/runner/retired-runner-deps.js +4 -5
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +103 -95
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +14 -11
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +34 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +32 -37
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +15 -73
- package/dist/core/runner/session-rule-policy.d.ts +5 -5
- package/dist/core/runner/session-rule-policy.js +13 -8
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/skills-seat.d.ts +15 -0
- package/dist/core/runner/skills-seat.js +57 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +124 -23
- package/dist/core/runner/sub-agent-deny-lists.js +230 -71
- package/dist/core/runner/synthetic-tools.d.ts +5 -2
- package/dist/core/runner/synthetic-tools.js +2 -12
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +43 -36
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +88 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +71 -16
- package/dist/core/session-policy-store.js +138 -28
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +49 -3
- package/dist/core/task-notification.js +2 -2
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +62 -18
- package/dist/core/tool-policy.js +86 -15
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/untrusted-text.d.ts +16 -0
- package/dist/core/untrusted-text.js +7 -2
- package/dist/core/user-attachment.d.ts +25 -4
- package/dist/core/user-attachment.js +63 -42
- package/dist/core/wiring-manifest.d.ts +18 -15
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +5 -4
- package/dist/engine/harness/types.d.ts +20 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.d.ts +12 -1
- package/dist/engine/loop/agent-loop.js +18 -6
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +33 -23
- package/dist/index.js +23 -15
- package/dist/internal/harness.d.ts +2 -1
- package/dist/internal/harness.js +2 -1
- package/dist/orchestration/goal.d.ts +24 -1
- package/dist/orchestration/goal.js +3 -2
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +72 -56
- package/dist/prompt-assembly/artifact-store.js +60 -52
- package/dist/prompt-assembly/artifact.d.ts +90 -76
- package/dist/prompt-assembly/artifact.js +197 -145
- package/dist/prompt-assembly/assemble.d.ts +36 -29
- package/dist/prompt-assembly/assemble.js +34 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +60 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
- package/dist/prompt-assembly/catalog/memory.js +6 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +138 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +26 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +137 -0
- package/dist/prompt-assembly/overlay.js +339 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +71 -0
- package/dist/prompt-assembly/select.js +106 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -511
- package/dist/prompts/default.js +20 -288
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/permission-rule-store.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.js +2 -1
- package/dist/tools/artifact/artifact-tool.js +4 -3
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +306 -103
- package/wire-changes/core@7.52.0.json +5859 -0
- package/wire-changes/core@7.53.0.json +1946 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
package/dist/agents/subagent.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
3
|
import { backgroundChildTerminal } from "../core/delegation-frames.js";
|
|
4
|
+
import { bindDelegationName } from "../core/delegation-name.js";
|
|
4
5
|
import { resumeStartupCauseOf } from "../core/resume-startup-cause.js";
|
|
5
6
|
import { errorCodeOf } from "../core/runner/terminal-account.js";
|
|
6
7
|
import { applyParentSpecSeat, memoryTurnedOff, parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
|
|
@@ -264,6 +265,11 @@ export function forkGovernanceDenial(enableFork, allowFork) {
|
|
|
264
265
|
return "principal";
|
|
265
266
|
return undefined;
|
|
266
267
|
}
|
|
268
|
+
const UNDECLARED_EXTRA_TOOL_REFUSAL = {
|
|
269
|
+
undeclared_name: "the extraTools factory of this delegation tool injected a tool its declared extra tools do not name — the declaration is the upper bound of what the factory may inject.",
|
|
270
|
+
undeclared_origin: "the extraTools factory of this delegation tool injected a tool of a content class beyond the one its declared extra tools state — the declaration is the upper bound of what the factory may inject.",
|
|
271
|
+
};
|
|
272
|
+
const WORKTREE_NOT_A_REPOSITORY = "isolation.not_a_repository";
|
|
267
273
|
const worktreeUnavailableSentence = (reason) => `Sub-agent not started: isolation "worktree" is unavailable on this run (${reason}). Retry without the isolation parameter.`;
|
|
268
274
|
const WORKTREE_UNAVAILABLE = {
|
|
269
275
|
readOnly: worktreeUnavailableSentence("no worktree capability — a read-only run mints no worktree"),
|
|
@@ -272,7 +278,20 @@ const WORKTREE_UNAVAILABLE = {
|
|
|
272
278
|
seatSilent: worktreeUnavailableSentence("the runner this tool runs children on does not declare whether it can place a child in a tree other than the caller's (its seat has no canRerootChild), and an undeclared answer is read as no; use a Runner, or add that method to the seat"),
|
|
273
279
|
};
|
|
274
280
|
const placementRefused = (terminal) => terminal?.kind === "failed" && terminal.code === "isolation.unavailable";
|
|
275
|
-
const
|
|
281
|
+
const NOT_STARTED_RESULTS = new WeakSet();
|
|
282
|
+
function notStartedResult(result) {
|
|
283
|
+
const details = result.details;
|
|
284
|
+
if (typeof details === "object" && details !== null)
|
|
285
|
+
NOT_STARTED_RESULTS.add(details);
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
export function isNotStartedDelegationResult(result) {
|
|
289
|
+
if (typeof result !== "object" || result === null)
|
|
290
|
+
return false;
|
|
291
|
+
const details = result.details;
|
|
292
|
+
return typeof details === "object" && details !== null && NOT_STARTED_RESULTS.has(details);
|
|
293
|
+
}
|
|
294
|
+
const isolationUnavailable = (content) => notStartedResult({
|
|
276
295
|
isError: true,
|
|
277
296
|
content,
|
|
278
297
|
details: { error: "isolation.unavailable" },
|
|
@@ -284,7 +303,7 @@ export function createSubagentWorktreeHelper(baseEnv, repoRoot) {
|
|
|
284
303
|
const probe = await baseEnv.exec("git rev-parse --is-inside-work-tree", { cwd: repoRoot });
|
|
285
304
|
if (!probe.ok || probe.value.exitCode !== 0) {
|
|
286
305
|
const detail = probe.ok ? (probe.value.stderr || probe.value.stdout).trim().split("\n")[0] : thrownText(probe.error);
|
|
287
|
-
throw new Error(`the working directory ${repoRoot} is not a git repository${detail ? ` (${detail})` : ""}`);
|
|
306
|
+
throw Object.assign(new Error(`the working directory ${repoRoot} is not a git repository${detail ? ` (${detail})` : ""}`), { code: WORKTREE_NOT_A_REPOSITORY });
|
|
288
307
|
}
|
|
289
308
|
const { env, worktreeDir } = await addWorktree(baseEnv, {
|
|
290
309
|
repoRoot,
|
|
@@ -1062,10 +1081,10 @@ function chargeLocalDelegationInFlight(anchor, key) {
|
|
|
1062
1081
|
live.delete(key);
|
|
1063
1082
|
};
|
|
1064
1083
|
}
|
|
1065
|
-
const spawnAbortedResult = (wt) => ({
|
|
1084
|
+
const spawnAbortedResult = (wt, fault) => notStartedResult({
|
|
1066
1085
|
isError: true,
|
|
1067
1086
|
content: `Sub-agent not started: the delegating call was aborted.${wt ? `\n${wt}` : ""}`,
|
|
1068
|
-
details: { error: "aborted" },
|
|
1087
|
+
details: { error: "aborted", ...fault },
|
|
1069
1088
|
});
|
|
1070
1089
|
const noopRelease = () => undefined;
|
|
1071
1090
|
const DELEGATION_POOL_DEFAULT_SCOPE = "default";
|
|
@@ -1358,7 +1377,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1358
1377
|
...(forkOffered ? [{ name: FORK_SUBAGENT_TYPE, ...(depthPermitsNesting ? { canRedelegate: true } : {}) }] : []),
|
|
1359
1378
|
];
|
|
1360
1379
|
const agentToolPool = delegationPoolFace(opts.tools ?? opts.inheritedTools ?? [], opts.extraTools !== undefined, opts.extraToolNames);
|
|
1361
|
-
return {
|
|
1380
|
+
return bindDelegationName(delegationToolName, {
|
|
1362
1381
|
name: opts.name ?? DEFAULT_SUBAGENT_TOOL_NAME,
|
|
1363
1382
|
...toolFace("agent"),
|
|
1364
1383
|
agentListing,
|
|
@@ -1459,22 +1478,22 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1459
1478
|
const parentSpecSeat = parentSpecSeatOfCtx(ctx);
|
|
1460
1479
|
const reviveClaim = ctx.reviveClaim;
|
|
1461
1480
|
if (reviveClaim !== undefined && opts.background === undefined) {
|
|
1462
|
-
return {
|
|
1481
|
+
return notStartedResult({
|
|
1463
1482
|
isError: true,
|
|
1464
1483
|
content: "Sub-agent not revived: this delegation tool has no background surface (run_in_background is not available here), and a revival is a background run by definition.",
|
|
1465
1484
|
details: { error: "revive.no_background" },
|
|
1466
|
-
};
|
|
1485
|
+
});
|
|
1467
1486
|
}
|
|
1468
1487
|
const prompt = String(a.prompt ?? "").trim();
|
|
1469
1488
|
if (!prompt) {
|
|
1470
|
-
return { isError: true, content: "Sub-agent not started: 'prompt' was empty.", details: { error: "empty prompt" } };
|
|
1489
|
+
return notStartedResult({ isError: true, content: "Sub-agent not started: 'prompt' was empty.", details: { error: "empty prompt" } });
|
|
1471
1490
|
}
|
|
1472
1491
|
if (a.subagent_type !== undefined && typeof a.subagent_type !== "string") {
|
|
1473
|
-
return {
|
|
1492
|
+
return notStartedResult({
|
|
1474
1493
|
isError: true,
|
|
1475
1494
|
content: `Sub-agent not started: subagent_type must be a string. Available subagent_type values: ${acceptedSubagentTypes().join(", ")}.`,
|
|
1476
1495
|
details: { error: "unknown subagent_type" },
|
|
1477
|
-
};
|
|
1496
|
+
});
|
|
1478
1497
|
}
|
|
1479
1498
|
const requestedType = a.subagent_type ?? "";
|
|
1480
1499
|
let rawType = requestedType;
|
|
@@ -1484,11 +1503,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1484
1503
|
const wanted = normalizeSubagentType(requestedType);
|
|
1485
1504
|
const hits = wanted === "" ? [] : accepted.filter((n) => normalizeSubagentType(n) === wanted);
|
|
1486
1505
|
if (hits.length > 1) {
|
|
1487
|
-
return {
|
|
1506
|
+
return notStartedResult({
|
|
1488
1507
|
isError: true,
|
|
1489
1508
|
content: `Sub-agent not started: subagent_type "${requestedType}" is ambiguous — it matches ${hits.join(", ")}. Use the exact name.`,
|
|
1490
1509
|
details: { error: "ambiguous subagent_type" },
|
|
1491
|
-
};
|
|
1510
|
+
});
|
|
1492
1511
|
}
|
|
1493
1512
|
if (hits.length === 1)
|
|
1494
1513
|
rawType = hits[0];
|
|
@@ -1496,62 +1515,62 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1496
1515
|
}
|
|
1497
1516
|
const wantsFork = forkOffered && rawType === FORK_SUBAGENT_TYPE;
|
|
1498
1517
|
if (reviveClaim !== undefined && wantsFork) {
|
|
1499
|
-
return { isError: true, content: `Sub-agent not revived: a "${FORK_SUBAGENT_TYPE}" agent cannot be revived — launch a new agent with the needed context instead.`, details: { error: "revive.fork_unsupported" } };
|
|
1518
|
+
return notStartedResult({ isError: true, content: `Sub-agent not revived: a "${FORK_SUBAGENT_TYPE}" agent cannot be revived — launch a new agent with the needed context instead.`, details: { error: "revive.fork_unsupported" } });
|
|
1500
1519
|
}
|
|
1501
1520
|
const omitted = rawType === "" || (!generalPurposeShadowed && rawType === GENERAL_PURPOSE_SUBAGENT_TYPE);
|
|
1502
1521
|
const def = hasAgents && !wantsFork && !omitted ? agentMap.get(rawType) : undefined;
|
|
1503
1522
|
const wantsBackground = opts.background !== undefined && (a.run_in_background !== false || def?.background === true);
|
|
1504
1523
|
const spawnAgentType = wantsFork ? FORK_SUBAGENT_TYPE : omitted ? GENERAL_PURPOSE_SUBAGENT_TYPE : rawType;
|
|
1505
1524
|
if (!def && !wantsFork && !omitted) {
|
|
1506
|
-
return {
|
|
1525
|
+
return notStartedResult({
|
|
1507
1526
|
isError: true,
|
|
1508
1527
|
content: `Sub-agent not started: unknown subagent_type "${rawType}". Available subagent_type values: ${acceptedSubagentTypes().join(", ")}.`,
|
|
1509
1528
|
details: { error: "unknown subagent_type" },
|
|
1510
|
-
};
|
|
1529
|
+
});
|
|
1511
1530
|
}
|
|
1512
1531
|
const allowFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "allowed", def !== undefined ? def.allowTools : opts.allowTools);
|
|
1513
1532
|
if (allowFlaw !== undefined)
|
|
1514
|
-
return { isError: true, content: `Sub-agent not started: ${inlineUntrusted(allowFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } };
|
|
1533
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(allowFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } });
|
|
1515
1534
|
const denyFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "denied", def !== undefined ? def.denyTools : opts.denyTools);
|
|
1516
1535
|
if (denyFlaw !== undefined)
|
|
1517
|
-
return { isError: true, content: `Sub-agent not started: ${inlineUntrusted(denyFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } };
|
|
1536
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(denyFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } });
|
|
1518
1537
|
if (a.name !== undefined && typeof a.name !== "string") {
|
|
1519
|
-
return { isError: true, content: "Sub-agent not started: name must be a string.", details: { error: "name.invalid" } };
|
|
1538
|
+
return notStartedResult({ isError: true, content: "Sub-agent not started: name must be a string.", details: { error: "name.invalid" } });
|
|
1520
1539
|
}
|
|
1521
1540
|
const agentName = a.name;
|
|
1522
1541
|
if (agentName !== undefined) {
|
|
1523
1542
|
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(agentName)) {
|
|
1524
|
-
return {
|
|
1543
|
+
return notStartedResult({
|
|
1525
1544
|
isError: true,
|
|
1526
1545
|
content: "Sub-agent not started: name must start with a letter or digit and contain only letters, digits, underscores, or hyphens (max 64 chars).",
|
|
1527
1546
|
details: { error: "name.invalid" },
|
|
1528
|
-
};
|
|
1547
|
+
});
|
|
1529
1548
|
}
|
|
1530
1549
|
if (reservedPeerNameReason(agentName) !== undefined) {
|
|
1531
|
-
return { isError: true, content: normalizePeerName(agentName) === "main" ? 'Sub-agent not started: "main" is reserved — SendMessage routes it to the main conversation.' : 'Sub-agent not started: name must not be a reserved name ("main", "team-lead", "user" or "system", in any spelling) or have the shape of an agent id — those already address an agent directly.', details: { error: "name.reserved" } };
|
|
1550
|
+
return notStartedResult({ isError: true, content: normalizePeerName(agentName) === "main" ? 'Sub-agent not started: "main" is reserved — SendMessage routes it to the main conversation.' : 'Sub-agent not started: name must not be a reserved name ("main", "team-lead", "user" or "system", in any spelling) or have the shape of an agent id — those already address an agent directly.', details: { error: "name.reserved" } });
|
|
1532
1551
|
}
|
|
1533
1552
|
if (ctx.spawnedAgentName !== undefined && reviveClaim === undefined) {
|
|
1534
|
-
return {
|
|
1553
|
+
return notStartedResult({
|
|
1535
1554
|
isError: true,
|
|
1536
1555
|
content: "Sub-agent not started: teammates cannot spawn other teammates — the team roster is flat. To spawn a subagent instead, omit the `name` parameter.",
|
|
1537
1556
|
details: { error: "name.nested_teammate" },
|
|
1538
|
-
};
|
|
1557
|
+
});
|
|
1539
1558
|
}
|
|
1540
1559
|
}
|
|
1541
1560
|
if (a.cwd !== undefined && typeof a.cwd !== "string") {
|
|
1542
|
-
return { isError: true, content: "Sub-agent not started: cwd must be an absolute path string.", details: { error: "cwd.relative" } };
|
|
1561
|
+
return notStartedResult({ isError: true, content: "Sub-agent not started: cwd must be an absolute path string.", details: { error: "cwd.relative" } });
|
|
1543
1562
|
}
|
|
1544
1563
|
const childCwd = a.cwd;
|
|
1545
1564
|
if (childCwd !== undefined) {
|
|
1546
1565
|
if (!isAbsolute(childCwd)) {
|
|
1547
|
-
return { isError: true, content: "Sub-agent not started: cwd must be an absolute path.", details: { error: "cwd.relative" } };
|
|
1566
|
+
return notStartedResult({ isError: true, content: "Sub-agent not started: cwd must be an absolute path.", details: { error: "cwd.relative" } });
|
|
1548
1567
|
}
|
|
1549
1568
|
if ((a.isolation ?? def?.isolation) === "worktree") {
|
|
1550
|
-
return {
|
|
1569
|
+
return notStartedResult({
|
|
1551
1570
|
isError: true,
|
|
1552
1571
|
content: 'Sub-agent not started: cwd and isolation "worktree" are mutually exclusive — the worktree defines its own working directory.',
|
|
1553
1572
|
details: { error: "cwd.isolation_conflict" },
|
|
1554
|
-
};
|
|
1573
|
+
});
|
|
1555
1574
|
}
|
|
1556
1575
|
}
|
|
1557
1576
|
if (wantsFork) {
|
|
@@ -1559,21 +1578,21 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1559
1578
|
const who = ctx.forkAccess.denied === "task"
|
|
1560
1579
|
? "this task (enableFork: false)"
|
|
1561
1580
|
: `this principal (runtimeCaps.allowFork: false)`;
|
|
1562
|
-
return {
|
|
1581
|
+
return notStartedResult({
|
|
1563
1582
|
isError: true,
|
|
1564
1583
|
content: `Sub-agent not started: subagent_type "${FORK_SUBAGENT_TYPE}" is disabled for ${who}. Delegate without subagent_type instead.`,
|
|
1565
1584
|
details: { error: "fork.disabled" },
|
|
1566
|
-
};
|
|
1585
|
+
});
|
|
1567
1586
|
}
|
|
1568
1587
|
if (ctx.insideFork === true) {
|
|
1569
|
-
return { isError: true, content: `Sub-agent not started: subagent_type "${FORK_SUBAGENT_TYPE}" is not available inside a forked agent.`, details: { error: "fork.nested" } };
|
|
1588
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: subagent_type "${FORK_SUBAGENT_TYPE}" is not available inside a forked agent.`, details: { error: "fork.nested" } });
|
|
1570
1589
|
}
|
|
1571
1590
|
if (ctx.sessionId === undefined || (ctx.hostSessionFork === undefined && !hasSessionFork(opts.runner.sessions))) {
|
|
1572
|
-
return {
|
|
1591
|
+
return notStartedResult({
|
|
1573
1592
|
isError: true,
|
|
1574
1593
|
content: `Sub-agent not started: subagent_type "${FORK_SUBAGENT_TYPE}" is unavailable here (this run has no fork-capable durable session). Delegate without subagent_type instead.`,
|
|
1575
1594
|
details: { error: "fork.unavailable" },
|
|
1576
|
-
};
|
|
1595
|
+
});
|
|
1577
1596
|
}
|
|
1578
1597
|
}
|
|
1579
1598
|
const modelObjectForm = typeof a.model === "object" &&
|
|
@@ -1583,18 +1602,18 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1583
1602
|
typeof a.model.api === "string";
|
|
1584
1603
|
if (a.model !== undefined && typeof a.model !== "string" && !modelObjectForm) {
|
|
1585
1604
|
const typeDesc = Array.isArray(a.model) ? "an array" : a.model === null ? "null" : typeof a.model === "object" ? "an object" : `a ${typeof a.model}`;
|
|
1586
|
-
return {
|
|
1605
|
+
return notStartedResult({
|
|
1587
1606
|
isError: true,
|
|
1588
1607
|
content: `Sub-agent not started: \`model\` must be a model name (string) from this deployment's catalog — got ${typeDesc}. Omit the parameter to run the agent type's own model.`,
|
|
1589
1608
|
details: { error: "model.invalid" },
|
|
1590
|
-
};
|
|
1609
|
+
});
|
|
1591
1610
|
}
|
|
1592
1611
|
if (typeof a.model === "string" && a.model.trim() === "" && !wantsFork && reviveClaim === undefined) {
|
|
1593
|
-
return {
|
|
1612
|
+
return notStartedResult({
|
|
1594
1613
|
isError: true,
|
|
1595
1614
|
content: "Sub-agent not started: `model` was empty. Name a model from this deployment's catalog, or omit the parameter to run the agent type's own model.",
|
|
1596
1615
|
details: { error: "model.empty" },
|
|
1597
|
-
};
|
|
1616
|
+
});
|
|
1598
1617
|
}
|
|
1599
1618
|
const requestedModel = typeof a.model === "string" && a.model.trim() !== "" ? a.model.trim() : undefined;
|
|
1600
1619
|
let perCallModel;
|
|
@@ -1639,11 +1658,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1639
1658
|
budget -= k.length + 2;
|
|
1640
1659
|
}
|
|
1641
1660
|
const rosterEcho = shown.length === rosterKeys.length ? shown.join(", ") : `${shown.join(", ")}, … (${rosterKeys.length - shown.length} more)`;
|
|
1642
|
-
return {
|
|
1661
|
+
return notStartedResult({
|
|
1643
1662
|
isError: true,
|
|
1644
1663
|
content: `Sub-agent not started: unknown model "${inlineUntrusted(requestedModel, 80)}". Available model values: ${inlineUntrusted(rosterEcho, ROSTER_ECHO_MAX + 32)}. Omit \`model\` to run the agent type's own model, or inherit the caller's.`,
|
|
1645
1664
|
details: { error: "model.unknown" },
|
|
1646
|
-
};
|
|
1665
|
+
});
|
|
1647
1666
|
}
|
|
1648
1667
|
}
|
|
1649
1668
|
}
|
|
@@ -1692,11 +1711,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1692
1711
|
const inheritedSkillGrants = readSkillGrantCapture(ctx.activeSkillGrants?.());
|
|
1693
1712
|
const inheritedAllowedTools = ctx.activeRequestAllowedTools?.();
|
|
1694
1713
|
if (inheritedSkillGrants === undefined) {
|
|
1695
|
-
return {
|
|
1714
|
+
return notStartedResult({
|
|
1696
1715
|
isError: true,
|
|
1697
1716
|
content: "Sub-agent not started: the parent's skill grants could not be read for the child (an unrecognizable capture); a child started without them would lose the parent's disallowed-tools refusals.",
|
|
1698
1717
|
details: { error: "skill_grants.unreadable" },
|
|
1699
|
-
};
|
|
1718
|
+
});
|
|
1700
1719
|
}
|
|
1701
1720
|
let worktreeDir;
|
|
1702
1721
|
if (reviveClaim === undefined && (a.isolation ?? def?.isolation) === "worktree") {
|
|
@@ -1710,15 +1729,18 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1710
1729
|
worktreeDir = (await iso.mint(ctx.toolCallId)).worktreeDir;
|
|
1711
1730
|
}
|
|
1712
1731
|
catch (e) {
|
|
1713
|
-
return {
|
|
1732
|
+
return notStartedResult({
|
|
1714
1733
|
isError: true,
|
|
1715
|
-
content:
|
|
1716
|
-
|
|
1717
|
-
|
|
1734
|
+
content: errorCodeOf(e) === WORKTREE_NOT_A_REPOSITORY
|
|
1735
|
+
? "Sub-agent not started: worktree isolation failed — the working directory is not a git repository. Retry without the isolation parameter."
|
|
1736
|
+
: "Sub-agent not started: worktree isolation failed. Retry without the isolation parameter, or fix the repository state.",
|
|
1737
|
+
details: { error: "isolation.failed", cause: thrownText(e) },
|
|
1738
|
+
});
|
|
1718
1739
|
}
|
|
1719
1740
|
}
|
|
1720
1741
|
let worktreeKeptPath;
|
|
1721
1742
|
let childPlacement;
|
|
1743
|
+
let worktreeFault;
|
|
1722
1744
|
const finishWorktree = async (terminal) => {
|
|
1723
1745
|
if (worktreeDir === undefined)
|
|
1724
1746
|
return undefined;
|
|
@@ -1736,9 +1758,15 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1736
1758
|
}
|
|
1737
1759
|
catch (e) {
|
|
1738
1760
|
worktreeKeptPath = worktreeDir;
|
|
1739
|
-
|
|
1761
|
+
worktreeFault = thrownText(e);
|
|
1762
|
+
return `worktree: ${worktreeDir} (cleanup check failed — the directory is kept on disk)`;
|
|
1740
1763
|
}
|
|
1741
1764
|
};
|
|
1765
|
+
const reportedWorktreeLine = (line) => (line !== undefined && worktreeFault !== undefined ? `${line}: ${worktreeFault}` : line);
|
|
1766
|
+
const faultDetails = (cause) => ({
|
|
1767
|
+
...(cause !== undefined ? { cause: thrownText(cause) } : {}),
|
|
1768
|
+
...(worktreeFault !== undefined ? { worktreeCause: worktreeFault } : {}),
|
|
1769
|
+
});
|
|
1742
1770
|
let injectedTools = [];
|
|
1743
1771
|
let extraToolsNote;
|
|
1744
1772
|
const treeBudget = extraToolsBudget ?? { used: 0 };
|
|
@@ -1778,13 +1806,13 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1778
1806
|
}
|
|
1779
1807
|
const notStarted = async (why, details) => {
|
|
1780
1808
|
const wt = await finishWorktree();
|
|
1781
|
-
return { isError: true, content: `Sub-agent not started: ${why.slice(0, 1600)}${wt ? `\n${wt}` : ""}`, details };
|
|
1809
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: ${why.slice(0, 1600)}${wt ? `\n${wt}` : ""}`, details: { ...details, ...faultDetails() } });
|
|
1782
1810
|
};
|
|
1783
1811
|
if (ctx.signal?.aborted)
|
|
1784
1812
|
return notStarted("the parent task was aborted while extraTools was being evaluated.", { error: "aborted" });
|
|
1785
1813
|
const undeclared = opts.extraToolNames !== undefined ? firstUndeclaredExtraTool(opts.extraToolNames, injectedTools, toolName) : undefined;
|
|
1786
1814
|
if (undeclared !== undefined)
|
|
1787
|
-
return (reportExtraToolsError(extraToolNamesError(undeclared.sentence, undeclared.reason)), notStarted(undeclared.
|
|
1815
|
+
return (reportExtraToolsError(extraToolNamesError(undeclared.sentence, undeclared.reason)), notStarted(UNDECLARED_EXTRA_TOOL_REFUSAL[undeclared.reason], { error: EXTRA_TOOL_NAMES_CODE, reason: undeclared.reason, cause: undeclared.sentence }));
|
|
1788
1816
|
}
|
|
1789
1817
|
const inherited = opts.tools === undefined && extraToolsNote === undefined ? inheritedChildPool(opts.inheritedTools ?? [], ctx.mountsCallerTool, wantsBackground && agentName === undefined && !wantsFork) : [];
|
|
1790
1818
|
if (extraToolsNote !== undefined && opts.tools === undefined && (opts.inheritedTools?.length ?? 0) > 0)
|
|
@@ -1813,7 +1841,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1813
1841
|
}
|
|
1814
1842
|
const governingLists = def !== undefined ? { allow: def.allowTools, deny: def.denyTools } : { allow: opts.allowTools, deny: opts.denyTools };
|
|
1815
1843
|
const childOwnLayer = Object.freeze({ ...(governingLists.allow != null ? { allow: Object.freeze([...governingLists.allow]) } : {}), deny: Object.freeze([...(governingLists.deny ?? [])]) });
|
|
1816
|
-
const
|
|
1844
|
+
const childListsDigest = toolListsDigest(childOwnLayer.allow, childOwnLayer.deny);
|
|
1845
|
+
const childListsJudged = agentToolPool !== undefined ? childListsDigest : undefined;
|
|
1817
1846
|
const childCeiling = ctx.toolSelector?.layers ?? [];
|
|
1818
1847
|
const parentMcp = opts.tools === undefined && extraToolsNote === undefined ? ctx.mountedMcp?.() : undefined;
|
|
1819
1848
|
const childMcp = parentMcp !== undefined ? inheritedMcpDeclarations(parentMcp, compileToolSelector([...childCeiling, childOwnLayer])) : undefined;
|
|
@@ -2079,7 +2108,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2079
2108
|
: undefined;
|
|
2080
2109
|
const childInternals = {
|
|
2081
2110
|
...(ctx.toolSelector !== undefined ? { toolCeiling: childCeiling, ...(childListsJudged !== undefined ? { toolListsJudged: childListsJudged } : {}) } : {}),
|
|
2082
|
-
|
|
2111
|
+
...(childListsDigest !== undefined ? { ownToolLists: { toolName, ...(def !== undefined ? { definition: def.name } : {}), lists: childListsDigest } } : {}),
|
|
2083
2112
|
...(parentMcp?.pool !== undefined && childMcp !== undefined && childMcp.length > 0 ? { mcpPool: parentMcp.pool } : {}),
|
|
2084
2113
|
...(childPick.modelRef !== undefined ? { inheritedModelRef: childPick.modelRef } : {}),
|
|
2085
2114
|
...(inheritedSkillGrants.length > 0 ? { inheritedSkillGrants } : {}),
|
|
@@ -2358,16 +2387,16 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2358
2387
|
if (ctx.signal?.aborted) {
|
|
2359
2388
|
await cancelObserver();
|
|
2360
2389
|
const wt = await finishWorktree();
|
|
2361
|
-
return spawnAbortedResult(wt);
|
|
2390
|
+
return spawnAbortedResult(wt, faultDetails());
|
|
2362
2391
|
}
|
|
2363
2392
|
if (spawnVerdict.kind === "block") {
|
|
2364
2393
|
await cancelObserver();
|
|
2365
2394
|
const wt = await finishWorktree();
|
|
2366
|
-
return {
|
|
2395
|
+
return notStartedResult({
|
|
2367
2396
|
isError: true,
|
|
2368
2397
|
content: `Sub-agent not started: blocked by the auto-mode classifier${spawnVerdict.reason ? `: ${inlineUntrusted(spawnVerdict.reason)}` : ""}.${wt ? `\n${wt}` : ""}`,
|
|
2369
|
-
details: { error: "autoMode.spawn_blocked" },
|
|
2370
|
-
};
|
|
2398
|
+
details: { error: "autoMode.spawn_blocked", ...faultDetails() },
|
|
2399
|
+
});
|
|
2371
2400
|
}
|
|
2372
2401
|
}
|
|
2373
2402
|
if (wantsFork) {
|
|
@@ -2385,11 +2414,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2385
2414
|
}
|
|
2386
2415
|
catch (e) {
|
|
2387
2416
|
const wt = await finishWorktree();
|
|
2388
|
-
return { isError: true, content: `Sub-agent not started: session fork failed
|
|
2417
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: session fork failed.${wt ? `\n${wt}` : ""}`, details: { error: "fork failed", ...faultDetails(e) } });
|
|
2389
2418
|
}
|
|
2390
2419
|
if (!forkedId) {
|
|
2391
2420
|
const wt = await finishWorktree();
|
|
2392
|
-
return { isError: true, content: `Sub-agent not started: source session not found or fork unavailable.${wt ? `\n${wt}` : ""}`, details: { error: "source not found", forkLane: ctx.hostSessionFork ? "host" : "child-runner", ...(ctx.sessionId !== undefined ? { sourceSessionId: ctx.sessionId } : {}) } };
|
|
2421
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: source session not found or fork unavailable.${wt ? `\n${wt}` : ""}`, details: { error: "source not found", forkLane: ctx.hostSessionFork ? "host" : "child-runner", ...(ctx.sessionId !== undefined ? { sourceSessionId: ctx.sessionId } : {}), ...faultDetails() } });
|
|
2393
2422
|
}
|
|
2394
2423
|
const forkInternals = { ...childInternals, insideFork: true, ...(ctx.reminderMark !== undefined ? { reminderMark: ctx.reminderMark } : {}) };
|
|
2395
2424
|
stepRecorder.lockTo(forkedId);
|
|
@@ -2423,7 +2452,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2423
2452
|
}
|
|
2424
2453
|
await cancelObserver();
|
|
2425
2454
|
const wt = await finishWorktree();
|
|
2426
|
-
return errorResult(`Sub-agent not started in background: ${admission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: admission.refusal.code, code: admission.refusal.code });
|
|
2455
|
+
return notStartedResult(errorResult(`Sub-agent not started in background: ${admission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: admission.refusal.code, code: admission.refusal.code, ...faultDetails() }));
|
|
2427
2456
|
}
|
|
2428
2457
|
}
|
|
2429
2458
|
const forkSettlementSeat = ctx.delegationSettlement?.();
|
|
@@ -2435,11 +2464,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2435
2464
|
catch (e) {
|
|
2436
2465
|
dropHostAbortListener();
|
|
2437
2466
|
const wt = await finishWorktree();
|
|
2438
|
-
return {
|
|
2467
|
+
return notStartedResult({
|
|
2439
2468
|
isError: true,
|
|
2440
|
-
content: `Sub-agent not started in background: the delegation settlement account could not record the launch
|
|
2441
|
-
details: { error: "settlement_write_ahead_failed" },
|
|
2442
|
-
};
|
|
2469
|
+
content: `Sub-agent not started in background: the delegation settlement account could not record the launch — fail-closed; repair the memory control plane or retry.${wt ? `\n${wt}` : ""}`,
|
|
2470
|
+
details: { error: "settlement_write_ahead_failed", ...faultDetails(e) },
|
|
2471
|
+
});
|
|
2443
2472
|
}
|
|
2444
2473
|
}
|
|
2445
2474
|
const settleForkRow = (terminal) => {
|
|
@@ -2513,7 +2542,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2513
2542
|
catch {
|
|
2514
2543
|
}
|
|
2515
2544
|
}
|
|
2516
|
-
return { isError: true, content: `Sub-agent not started in background:
|
|
2545
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started in background: the background task could not be registered.${wt ? `\n${wt}` : ""}`, details: { error: "register_failed", ...faultDetails(e) } });
|
|
2517
2546
|
}
|
|
2518
2547
|
if (forkEntryGate.key !== undefined)
|
|
2519
2548
|
chargeDelegationEntryHandle(bg.registry, forkEntryGate.key, bg.agentStore, taskId);
|
|
@@ -2807,7 +2836,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2807
2836
|
}
|
|
2808
2837
|
await cancelObserver();
|
|
2809
2838
|
const wt = await finishWorktree();
|
|
2810
|
-
return spawnAbortedResult(wt);
|
|
2839
|
+
return spawnAbortedResult(wt, faultDetails());
|
|
2811
2840
|
}
|
|
2812
2841
|
const syncForkAdmission = syncForkEntryGate.admit("local");
|
|
2813
2842
|
if (!syncForkAdmission.admitted) {
|
|
@@ -2818,7 +2847,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2818
2847
|
}
|
|
2819
2848
|
await cancelObserver();
|
|
2820
2849
|
const wt = await finishWorktree();
|
|
2821
|
-
return errorResult(`Sub-agent not started: ${syncForkAdmission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: syncForkAdmission.refusal.code, code: syncForkAdmission.refusal.code });
|
|
2850
|
+
return notStartedResult(errorResult(`Sub-agent not started: ${syncForkAdmission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: syncForkAdmission.refusal.code, code: syncForkAdmission.refusal.code, ...faultDetails() }));
|
|
2822
2851
|
}
|
|
2823
2852
|
let forkChild;
|
|
2824
2853
|
try {
|
|
@@ -2860,7 +2889,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2860
2889
|
if (isDurablePause(forkChild.terminal)) {
|
|
2861
2890
|
return durablePauseDelegationReport(` · ${FORK_SUBAGENT_TYPE}`, forkChild.terminal);
|
|
2862
2891
|
}
|
|
2863
|
-
const wtLine = await finishWorktree();
|
|
2892
|
+
const wtLine = reportedWorktreeLine(await finishWorktree());
|
|
2864
2893
|
const forkFace = childTerminalFace(forkChild.terminal);
|
|
2865
2894
|
const forkErr = classifySubagentError(forkChild.terminal);
|
|
2866
2895
|
const forkLines = [
|
|
@@ -2929,7 +2958,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2929
2958
|
dropHostAbortListener();
|
|
2930
2959
|
await cancelObserver();
|
|
2931
2960
|
const wt = await finishWorktree();
|
|
2932
|
-
return errorResult(`Sub-agent not started in background: ${admission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: admission.refusal.code, code: admission.refusal.code });
|
|
2961
|
+
return notStartedResult(errorResult(`Sub-agent not started in background: ${admission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: admission.refusal.code, code: admission.refusal.code, ...faultDetails() }));
|
|
2933
2962
|
}
|
|
2934
2963
|
}
|
|
2935
2964
|
const settlementSeat = ctx.delegationSettlement?.();
|
|
@@ -2942,11 +2971,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2942
2971
|
dropHostAbortListener();
|
|
2943
2972
|
await cancelObserver();
|
|
2944
2973
|
const wt = await finishWorktree();
|
|
2945
|
-
return {
|
|
2974
|
+
return notStartedResult({
|
|
2946
2975
|
isError: true,
|
|
2947
|
-
content: `Sub-agent not started in background: the delegation settlement account could not record the launch
|
|
2948
|
-
details: { error: "settlement_write_ahead_failed" },
|
|
2949
|
-
};
|
|
2976
|
+
content: `Sub-agent not started in background: the delegation settlement account could not record the launch — fail-closed; repair the memory control plane or retry.${wt ? `\n${wt}` : ""}`,
|
|
2977
|
+
details: { error: "settlement_write_ahead_failed", ...faultDetails(e) },
|
|
2978
|
+
});
|
|
2950
2979
|
}
|
|
2951
2980
|
}
|
|
2952
2981
|
const settleDelegationRow = (terminal) => {
|
|
@@ -3051,7 +3080,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3051
3080
|
catch {
|
|
3052
3081
|
}
|
|
3053
3082
|
}
|
|
3054
|
-
return { isError: true, content: `Sub-agent not started in background:
|
|
3083
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started in background: the background task could not be registered.${wt ? `\n${wt}` : ""}`, details: { error: "register_failed", ...faultDetails(e) } });
|
|
3055
3084
|
}
|
|
3056
3085
|
if (capLedgerKey !== undefined)
|
|
3057
3086
|
chargeDelegationEntryHandle(bg.registry, capLedgerKey, bg.agentStore, reviveRow === undefined ? taskId : undefined);
|
|
@@ -3645,11 +3674,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3645
3674
|
details: { error: "parked_resume.startup_failed", task_id: taskId, ...(failure.cause !== undefined ? { cause: failure.cause } : {}) },
|
|
3646
3675
|
};
|
|
3647
3676
|
}
|
|
3648
|
-
return {
|
|
3677
|
+
return notStartedResult({
|
|
3649
3678
|
isError: true,
|
|
3650
3679
|
content: `Sub-agent not revived: the revival failed during startup (its transcript session may be gone or the run could not prepare). This cycle settled failed; the message was NOT delivered — it remains queued and will be delivered if a later revival succeeds, so do not blindly resend the same content.`,
|
|
3651
3680
|
details: { error: "revive.startup_failed", task_id: taskId },
|
|
3652
|
-
};
|
|
3681
|
+
});
|
|
3653
3682
|
}
|
|
3654
3683
|
}
|
|
3655
3684
|
return {
|
|
@@ -3677,13 +3706,13 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3677
3706
|
if (ctx.signal?.aborted) {
|
|
3678
3707
|
await cancelObserver();
|
|
3679
3708
|
const wt = await finishWorktree();
|
|
3680
|
-
return spawnAbortedResult(wt);
|
|
3709
|
+
return spawnAbortedResult(wt, faultDetails());
|
|
3681
3710
|
}
|
|
3682
3711
|
const syncAdmission = syncEntryGate.admit("local");
|
|
3683
3712
|
if (!syncAdmission.admitted) {
|
|
3684
3713
|
await cancelObserver();
|
|
3685
3714
|
const wt = await finishWorktree();
|
|
3686
|
-
return errorResult(`Sub-agent not started: ${syncAdmission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: syncAdmission.refusal.code, code: syncAdmission.refusal.code });
|
|
3715
|
+
return notStartedResult(errorResult(`Sub-agent not started: ${syncAdmission.refusal.text}${wt ? `\n${wt}` : ""}`, { error: syncAdmission.refusal.code, code: syncAdmission.refusal.code, ...faultDetails() }));
|
|
3687
3716
|
}
|
|
3688
3717
|
const syncStartedAt = Date.now();
|
|
3689
3718
|
let retainEntry;
|
|
@@ -3778,7 +3807,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3778
3807
|
}
|
|
3779
3808
|
}
|
|
3780
3809
|
}
|
|
3781
|
-
const worktreeLine = await finishWorktree(child.terminal);
|
|
3810
|
+
const worktreeLine = reportedWorktreeLine(await finishWorktree(child.terminal));
|
|
3782
3811
|
if (worktreeDir !== undefined && placementRefused(child.terminal))
|
|
3783
3812
|
return isolationUnavailable(WORKTREE_UNAVAILABLE.notHonored);
|
|
3784
3813
|
const errClass = classifySubagentError(child.terminal);
|
|
@@ -3853,5 +3882,5 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3853
3882
|
}),
|
|
3854
3883
|
};
|
|
3855
3884
|
},
|
|
3856
|
-
};
|
|
3885
|
+
});
|
|
3857
3886
|
}
|