@sema-agent/core 7.59.0 → 7.61.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 +1169 -0
- package/README.md +2 -2
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +4 -3
- package/dist/agents/agent-transcript-tool.js +4 -2
- package/dist/agents/cascade.d.ts +61 -10
- package/dist/agents/cascade.js +60 -20
- package/dist/agents/child-model-seat.js +6 -3
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -1
- package/dist/agents/inherited-tool-pool.d.ts +28 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +36 -7
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +16 -3
- package/dist/agents/roster-store.d.ts +2 -2
- package/dist/agents/roster-store.js +8 -3
- package/dist/agents/send-message-tool.d.ts +14 -27
- package/dist/agents/send-message-tool.js +47 -54
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +52 -28
- package/dist/agents/subagent.js +276 -246
- package/dist/agents/suspend-guard.d.ts +9 -0
- package/dist/agents/suspend-guard.js +4 -0
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +37 -27
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/route-adjudicator.js +3 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/brain/timeout.d.ts +3 -1
- package/dist/brain/timeout.js +18 -5
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +61 -23
- package/dist/core/allow-entry.js +134 -39
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +66 -17
- package/dist/core/background-agent-store.d.ts +17 -6
- package/dist/core/background-agent-store.js +15 -13
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +24 -3
- package/dist/core/checkpoint-requirements.js +9 -1
- package/dist/core/checkpoint-store.d.ts +86 -32
- package/dist/core/checkpoint-store.js +10 -5
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/compliance.d.ts +1 -1
- package/dist/core/context-settings.js +3 -5
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +5 -6
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +106 -32
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +15 -0
- package/dist/core/frame-settlement.js +10 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +9 -6
- package/dist/core/gate-lanes.js +46 -12
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +19 -3
- package/dist/core/governance-codes.js +27 -3
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +51 -60
- package/dist/core/hooks.js +131 -78
- package/dist/core/host-floor.js +3 -5
- package/dist/core/image-admission.d.ts +145 -52
- package/dist/core/image-admission.js +202 -47
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +55 -3
- package/dist/core/locked-config.js +84 -51
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +83 -16
- package/dist/core/mcp-failure.js +67 -30
- package/dist/core/mcp-host-seat.d.ts +131 -0
- package/dist/core/mcp-host-seat.js +305 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +9 -4
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +39 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +23 -55
- package/dist/core/mcp.js +172 -156
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/index.d.ts +2 -1
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +68 -13
- package/dist/core/memory-engine/sync-client.js +147 -18
- package/dist/core/memory-engine/sync-report.d.ts +106 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +13 -3
- package/dist/core/mode-policy.d.ts +15 -7
- package/dist/core/mode-policy.js +18 -6
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +100 -0
- package/dist/core/mods/agent-stations.js +154 -0
- package/dist/core/mods/dollar.d.ts +62 -0
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +9 -4
- package/dist/core/mods/kernel/dispatch.js +8 -8
- package/dist/core/mods/kernel/events.d.ts +13 -4
- package/dist/core/mods/kernel/events.js +14 -10
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/session-append.d.ts +115 -0
- package/dist/core/mods/session-append.js +311 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +141 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +89 -75
- package/dist/core/mods/stations.js +57 -53
- package/dist/core/mods/tool-call.d.ts +12 -4
- package/dist/core/mods/tool-call.js +32 -16
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +62 -0
- package/dist/core/own-property-receipt.js +43 -0
- package/dist/core/park-selfcheck.js +12 -10
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +66 -11
- package/dist/core/peer-seat.js +199 -42
- package/dist/core/permission-rule-consent.d.ts +21 -26
- package/dist/core/permission-rule-consent.js +22 -3
- package/dist/core/permission-rule-model.d.ts +38 -13
- package/dist/core/permission-rule-model.js +54 -16
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +218 -122
- package/dist/core/remote-env.js +133 -14
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +8 -3
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +12 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +37 -3
- package/dist/core/roles.js +126 -78
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -8
- package/dist/core/runner/assemble-result.js +12 -8
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +21 -10
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/compact-session.js +14 -2
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +7 -2
- package/dist/core/runner/contracts.d.ts +158 -65
- package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +75 -7
- package/dist/core/runner/gate-exit.js +20 -1
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +4 -4
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
- package/dist/core/runner/permission-rule-lanes.js +29 -10
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
- package/dist/core/runner/prepare-boundary-parks.js +4 -4
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +30 -26
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
- package/dist/core/runner/prepare-delegation-surface.js +7 -8
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +23 -17
- package/dist/core/runner/prepare-gate-stations.js +10 -7
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
- package/dist/core/runner/prepare-hands-readface.js +19 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +12 -5
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +8 -7
- package/dist/core/runner/prepare-park-ask.js +6 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
- package/dist/core/runner/prepare-policy-chain.js +131 -128
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +8 -5
- package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
- package/dist/core/runner/prepare-prompt-inputs.js +4 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +9 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
- package/dist/core/runner/prepare-suspend-saga.js +21 -13
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +84 -42
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +7 -3
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +12 -8
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +5 -3
- package/dist/core/runner/resume-admission.js +17 -3
- package/dist/core/runner/resume-apply.js +3 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +6 -1
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +3 -2
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +5 -3
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +15 -6
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +65 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +36 -12
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +14 -8
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +12 -4
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +37 -19
- package/dist/core/runner/runtask.d.ts +25 -7
- package/dist/core/runner/runtask.js +46 -22
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +8 -7
- package/dist/core/runner/sub-agent-deny-lists.js +10 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -4
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +6 -7
- package/dist/core/runner/turn-attachments.js +4 -17
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +55 -43
- package/dist/core/secret-env.d.ts +14 -13
- package/dist/core/secret-env.js +8 -9
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +10 -3
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +5 -2
- package/dist/core/session-store.js +53 -16
- package/dist/core/session.d.ts +2 -1
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.d.ts +9 -0
- package/dist/core/skill-grant.js +18 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +67 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/task-event.d.ts +35 -10
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +172 -12
- package/dist/core/task-notification.js +209 -12
- package/dist/core/task-registry-agent.d.ts +23 -55
- package/dist/core/task-registry-agent.js +41 -56
- package/dist/core/task-registry-monitor.d.ts +8 -1
- package/dist/core/task-registry-monitor.js +43 -61
- package/dist/core/task-registry-shared.d.ts +52 -114
- package/dist/core/task-registry-shared.js +24 -48
- package/dist/core/task-registry-workflow.js +5 -22
- package/dist/core/task-registry.d.ts +64 -90
- package/dist/core/task-registry.js +73 -119
- package/dist/core/task-result.d.ts +27 -19
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +13 -16
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +30 -0
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +3 -6
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +6 -4
- package/dist/core/tool-face.d.ts +2 -3
- package/dist/core/tool-name-aliases.d.ts +23 -28
- package/dist/core/tool-name-aliases.js +63 -7
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +113 -22
- package/dist/core/tool-policy.js +85 -15
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +111 -5
- package/dist/core/tool-result-store.js +52 -12
- package/dist/core/tool-spec.d.ts +39 -10
- package/dist/core/trace.d.ts +18 -2
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +40 -27
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
- package/dist/engine/execution-env/node-execution-env.js +224 -21
- package/dist/engine/harness/agent-harness.d.ts +66 -19
- package/dist/engine/harness/agent-harness.js +98 -27
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +151 -34
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +18 -13
- package/dist/engine/loop/agent-loop.js +173 -32
- package/dist/engine/loop/types.d.ts +21 -5
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +41 -23
- package/dist/index.js +29 -16
- package/dist/internal/harness-types.d.ts +3 -1
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +20 -20
- package/dist/orchestration/run-workflow-tool.js +63 -56
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +8 -0
- package/dist/orchestration/workflow.js +33 -9
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +19 -14
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +24 -16
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +4 -1
- package/dist/stores/file/index.d.ts +9 -6
- package/dist/stores/file/index.js +33 -9
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +43 -21
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +4 -1
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +4 -1
- package/dist/stores/file/session-store.d.ts +17 -4
- package/dist/stores/file/session-store.js +22 -19
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +31 -2
- package/dist/stores/file/tool-result-store.js +129 -7
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +4 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -13
- package/dist/stores/file/workflow-journal-store.js +4 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +13 -0
- package/dist/tools/fs/fs-bash-background-text.js +7 -0
- package/dist/tools/fs/fs-bash.d.ts +11 -22
- package/dist/tools/fs/fs-bash.js +58 -154
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +34 -27
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +39 -16
- package/dist/tools/fs/fs-shared.js +25 -6
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +15 -9
- package/dist/tools/fs/index.js +12 -18
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +57 -6
- package/dist/tools/fs/read-floor.js +241 -2
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +6 -5
- package/dist/tools/fs/search.js +10 -10
- package/dist/tools/fs/shell-read-establish.js +3 -1
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/monitor.d.ts +12 -10
- package/dist/tools/monitor.js +22 -13
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +8 -3
- package/test/export-surface.snapshot.json +166 -30
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
|
@@ -8,14 +8,24 @@ import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export interface MemorySyncCursor {
|
|
10
10
|
scope: string;
|
|
11
|
-
/** The
|
|
11
|
+
/** The identity of the PEER the baseline was taken against (`MemorySyncTransport.peer`); a round over
|
|
12
|
+
* another peer refuses the cursor. One cursor per peer. */
|
|
12
13
|
peer: string;
|
|
14
|
+
/** WHICH STATE of that peer the baseline was taken against: the opaque incarnation the peer answered the last
|
|
15
|
+
* completed sync with (`MemorySyncResponseBody.cursor.incarnation`). Every later sync carries it back as its
|
|
16
|
+
* claim (`MemorySyncRequestBody.peerIncarnation`), and the peer — the side holding that state — compares the claim
|
|
17
|
+
* with its own before it writes anything, refusing when they differ or when the baseline is not empty and no
|
|
18
|
+
* claim is made (a cursor written before cursors carried this member). The same address can answer from another
|
|
19
|
+
* state (a rebuilt or restored center): the address says where the sync goes, this says which state answers it.
|
|
20
|
+
* Persist it verbatim; the engine never mints, derives or compares it. */
|
|
21
|
+
peerIncarnation: string;
|
|
13
22
|
/** The LOCAL store the baseline was taken against (minted by `memorySyncStoreOf`, sync-client.ts).
|
|
14
23
|
* A sync over any other store refuses the cursor: the baseline describes another store's
|
|
15
24
|
* entries, and an id it holds that this store lacks would be pushed as a delete. Persist it
|
|
16
|
-
* verbatim with the rest of the cursor
|
|
25
|
+
* verbatim with the rest of the cursor; the host rebinds it (this member set to the new store's
|
|
26
|
+
* identity) only when the new store holds the entries the baseline was taken over. */
|
|
17
27
|
store: string;
|
|
18
|
-
/** id → rev at the last completed sync
|
|
28
|
+
/** id → rev at the last completed sync with this peer (in the state {@link peerIncarnation} names). */
|
|
19
29
|
baseRevs: Record<string, string>;
|
|
20
30
|
/** Caller-injected clock (never Date.now inside the engine — clock-injection precedent). */
|
|
21
31
|
updatedAtMs: number;
|
|
@@ -134,6 +134,13 @@ export declare function mountedToolRequiresUserInteraction(tools: readonly Agent
|
|
|
134
134
|
* A name the roster does not carry dispatches nowhere and is not judged here.
|
|
135
135
|
*/
|
|
136
136
|
export declare function planRefusesWrite(req: ToolCallRequest, roster: ToolRoster | undefined, readOnlyDeclared?: (toolName: string) => boolean): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Does a question of the MODE reach a call of this tool — its unstated question (the tool declares the `passthrough` seat
|
|
139
|
+
* and the mode asks one, {@link asksUnstated}) or its write gate (a covered path write; under `plan`, every write
|
|
140
|
+
* {@link planRefusesWrite} names)? Read on the tool's face as the roster mints it — its declarations, never a call's
|
|
141
|
+
* arguments — by the load-time ungated-write warning, which names a caller's write-capable tool no question of the mode reaches.
|
|
142
|
+
*/
|
|
143
|
+
export declare function modeQuestionReaches(mode: PermissionMode, roster: ToolRoster, toolName: string, seat: "passthrough" | undefined): boolean;
|
|
137
144
|
/**
|
|
138
145
|
* The mode's WRITE GATE as one live policy layer: every call reads the mode ref and dispatches to the gate the
|
|
139
146
|
* table names for it, so a steer changes the next call's gate without re-composing the chain. The three gates are
|
|
@@ -159,14 +166,15 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
|
|
|
159
166
|
readonly decision?: string;
|
|
160
167
|
} | undefined): PermissionMode | undefined;
|
|
161
168
|
/**
|
|
162
|
-
* The permission MODE's door —
|
|
163
|
-
* absence (a mode a caller believes it declared must not silently run as another): a
|
|
164
|
-
* (`config.spec_retired_key` — `autoModeRequested` / `approverPosture` are one key now); a `permissionMode` outside
|
|
169
|
+
* The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
|
|
170
|
+
* absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
|
|
165
171
|
* the closed set (`config.permission_mode_invalid`); a `shellGate` value other than the floor word `"always"`
|
|
166
|
-
* (`config.shell_gate_value_retired` — `"off"` / `"classify"` were a doctrine the mode arbitration replaced).
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
172
|
+
* (`config.shell_gate_value_retired` — `"off"` / `"classify"` were a doctrine the mode arbitration replaced). A RETIRED
|
|
173
|
+
* mode key (`autoModeRequested` / `approverPosture` — one key now) is refused by the spec's one read (`readCallerSpec`,
|
|
174
|
+
* `config.spec_retired_key`), before this door. The value it screened is the value it RETURNS — the mode seat reads this
|
|
175
|
+
* snapshot, never the spec again. The ONE function both entrances call: prepare (the run's read of its spec, before the
|
|
176
|
+
* config doors rebind it, in its pre-first-await stretch) and the resume ladder's admission rung (the re-supplied
|
|
177
|
+
* config's read, before the claim) — a resume prepare would refuse is refused before it consumes the row.
|
|
170
178
|
*/
|
|
171
179
|
export declare function refusePermissionModeDoors(spec: Pick<TaskSpec, "permissionMode" | "shellGate">): PermissionMode | undefined;
|
|
172
180
|
/** The resume's ONE refusal channel for a door prepare would refuse at: runs `screen` (prepare's own function, which throws prepare's sentence and code) and
|
package/dist/core/mode-policy.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createFsWriteGatePolicy } from "./fs-write-gate-policy.js";
|
|
2
2
|
import { isProtectedWrite } from "./tool-registry.js";
|
|
3
3
|
import { answeredFor } from "./tool-policy.js";
|
|
4
|
-
import {
|
|
4
|
+
import { attest } from "./engine-attestation.js";
|
|
5
|
+
import { rosterEntryNamed, toolCallFaceOf } from "./tool-roster.js";
|
|
5
6
|
import { wireOf } from "./tool-name-readings.js";
|
|
6
7
|
import { clampPermissionMode, isPermissionMode, PERMISSION_MODES } from "./ask-origin.js";
|
|
7
8
|
import { argvOf, lexShellText } from "../shell/lex.js";
|
|
8
9
|
import { COMMAND_RULE_TOOL } from "./permission-rule-model.js";
|
|
9
10
|
import { createSafeNotifier } from "./safe-notify.js";
|
|
10
|
-
import { assertNoRetiredKeys, RETIRED_TASK_SPEC_KEYS } from "./retired-keys.js";
|
|
11
11
|
import { CheckpointError, isCheckpointConfigRefusalCode } from "./checkpoint-store.js";
|
|
12
12
|
export const PERMISSION_MODE_FOLD_REASONS = Object.freeze(["operator_deny", "face_absent", "inherited_ceiling"]);
|
|
13
13
|
export const ACCEPT_EDITS_FILE_COMMANDS = Object.freeze(["mkdir", "touch", "rm", "rmdir", "mv", "cp", "sed"]);
|
|
@@ -64,13 +64,26 @@ export function planRefusesWrite(req, roster, readOnlyDeclared) {
|
|
|
64
64
|
const row = roster === undefined ? undefined : rosterEntryNamed(roster, wireOf("mode.planRosterRow", req));
|
|
65
65
|
return row !== undefined && !ENGINE_ROSTER_SOURCES.has(row.source) && row.effect !== "read" && !(row.effectProvenance === "default" && readOnlyDeclared?.(row.name) === true);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
export function modeQuestionReaches(mode, roster, toolName, seat) {
|
|
68
|
+
const policy = modePolicyOf(mode);
|
|
69
|
+
if (policy.unstated === "ask" && seat === "passthrough")
|
|
70
|
+
return true;
|
|
71
|
+
if (policy.writeGate === "none")
|
|
72
|
+
return false;
|
|
73
|
+
const face = toolCallFaceOf(roster, toolName);
|
|
74
|
+
const call = { toolName, args: {}, toolCallId: "", ...(face !== undefined ? { face } : {}) };
|
|
75
|
+
return policy.writeGate === "plan" ? planRefusesWrite(call, roster) : isProtectedWrite(call);
|
|
76
|
+
}
|
|
77
|
+
const planAsk = (message, call, generic) => {
|
|
78
|
+
const asked = { action: "ask", message, decisionReason: "mode" };
|
|
79
|
+
return generic ? attest(asked, call, { genericQuestion: message }) : asked;
|
|
80
|
+
};
|
|
68
81
|
export function createModeGatePolicy(modeRef, seats) {
|
|
69
82
|
const askGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, defaultWrite: "ask" });
|
|
70
83
|
const acceptSeat = seats.acceptDirs;
|
|
71
84
|
const acceptDirs = typeof acceptSeat === "function" ? acceptSeat : acceptSeat !== undefined && acceptSeat.length > 0 ? [...acceptSeat] : [seats.rootPath];
|
|
72
85
|
const acceptRootGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, acceptDirs, defaultWrite: "ask" });
|
|
73
|
-
const planGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, defaultWrite: "ask", defaultAsk: (path, note) => planAsk(`Cannot write to ${path} while in plan mode.${note ?? ""}
|
|
86
|
+
const planGate = createFsWriteGatePolicy({ env: seats.env, rootPath: seats.rootPath, defaultWrite: "ask", defaultAsk: (path, note, call) => planAsk(`Cannot write to ${path} while in plan mode.${note ?? ""}`, call, note === undefined) });
|
|
74
87
|
return {
|
|
75
88
|
async check(req, signal) {
|
|
76
89
|
const gate = modePolicyOf(modeRef.current).writeGate;
|
|
@@ -80,7 +93,7 @@ export function createModeGatePolicy(modeRef, seats) {
|
|
|
80
93
|
if (!planRefusesWrite(req, seats.roster?.current, seats.readOnlyDeclared))
|
|
81
94
|
return { action: "allow" };
|
|
82
95
|
if (!isProtectedWrite(req))
|
|
83
|
-
return planAsk(`Cannot call ${req.toolName} while in plan mode
|
|
96
|
+
return planAsk(`Cannot call ${req.toolName} while in plan mode.`, req, true);
|
|
84
97
|
return planGate.check(req, signal);
|
|
85
98
|
}
|
|
86
99
|
return (gate === "ask" ? askGate : acceptRootGate).check(req, signal);
|
|
@@ -94,7 +107,6 @@ export function modeRequestAfterResume(seat, recorded, outcome) {
|
|
|
94
107
|
return seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
|
|
95
108
|
}
|
|
96
109
|
export function refusePermissionModeDoors(spec) {
|
|
97
|
-
assertNoRetiredKeys(spec, RETIRED_TASK_SPEC_KEYS, "TaskSpec");
|
|
98
110
|
const mode = spec.permissionMode;
|
|
99
111
|
if (mode !== undefined && !isPermissionMode(mode)) {
|
|
100
112
|
const e = new Error(`permissionMode must be one of ${PERMISSION_MODES.map((w) => JSON.stringify(w)).join(", ")} when present (got ${JSON.stringify(mode)}) — omit it for the default mode; an unrecognized word is refused rather than read as any mode.`);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Model } from "../internal/llm.js";
|
|
2
|
+
import type { CheckpointErrorReason } from "./checkpoint-store.js";
|
|
3
|
+
import { type ReceiptMode } from "./mods/kernel/receive.js";
|
|
4
|
+
/** The arms of the roles family's refusal (`detail.reason` of `config.unknown_role`): a word the catalog does not hold, a value that is no model
|
|
5
|
+
* reference at all, a role word outside the vocabulary, a role whose whole fallback chain supplies no model. Each is a member of the checkpoint
|
|
6
|
+
* refusal reasons (the resume screen carries it on). */
|
|
7
|
+
export type ModelBindingReason = Extract<CheckpointErrorReason, "unknown_model_ref" | "not_a_model_ref" | "unknown_role_word" | "no_model_for_role">;
|
|
8
|
+
/**
|
|
9
|
+
* The coded refusal of a model binding the engine cannot read — a role's seat, a tier's binding, the model a task names, a catalog entry, a
|
|
10
|
+
* role word outside the vocabulary (`field` names the seat as the sentence does, `reason` the arm). The ONE place the code and its `detail`
|
|
11
|
+
* are built: a value that is no model reference at all, a word the catalog does not hold and a role word nothing holds are the caller's own
|
|
12
|
+
* configuration faults, refused by the roles family's code with the seat and the arm beside it — never as the raw read the lookup would have
|
|
13
|
+
* been (a `TypeError` from a value that is not an object, an uncoded lookup error). The terminal states the same `{ field, reason }`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function modelBindingRefusal(field: string, reason: ModelBindingReason, message: string): Error;
|
|
16
|
+
/** Whether a value is a list — total: a revoked Proxy traps even `Array.isArray`, and a refusal's own reading must not throw in its place. */
|
|
17
|
+
export declare function isList(value: unknown): boolean;
|
|
18
|
+
/** A word in a refusal sentence, bounded and quoted; any other kind of value by its kind (rendering it could itself throw). */
|
|
19
|
+
export declare function bindingShown(value: unknown): string;
|
|
20
|
+
/** The model door's mode of the one receipt: the declaration mode, with `headers` read per use. */
|
|
21
|
+
export declare const MODEL_RECEIPT_MODE: ReceiptMode;
|
|
22
|
+
/** Whether `value` is a Model the door minted. */
|
|
23
|
+
export declare function isModelSnapshot(value: unknown): value is Model;
|
|
24
|
+
/**
|
|
25
|
+
* The object a Model snapshot was received from — the read a host keys its own tables by when it compares an engine answer with
|
|
26
|
+
* the Model objects it built (the engine hands back its snapshots, never the caller's objects). A value the door did not mint is
|
|
27
|
+
* its own origin.
|
|
28
|
+
*/
|
|
29
|
+
export declare function modelOriginOf(model: Model): Model;
|
|
30
|
+
/**
|
|
31
|
+
* Receive a Model at `seat` (the place the caller wrote it, as every refusal names it; `what` is how the sentence names the value — a
|
|
32
|
+
* Model object written there, or the catalog entry a word resolved to): its frozen snapshot, or the coded refusal. A snapshot comes
|
|
33
|
+
* back as itself. The refusals: a value that is not a plain record (a Proxy, a class instance, `Object.create(x)`, a list, a primitive) or
|
|
34
|
+
* holds a member the receipt cannot copy (a getter that threw, a function, another prototype) — `config.unknown_role` /
|
|
35
|
+
* `not_a_model_ref`; a retired member — `config.deps_retired_key` (its own sentence); a member outside the contract — `not_a_model_ref`
|
|
36
|
+
* (a provider's own parameters belong in `Model.params`); an `id` that is not a non-empty string or an `api` that is not a string —
|
|
37
|
+
* `not_a_model_ref`, naming the member.
|
|
38
|
+
*/
|
|
39
|
+
export declare function receiveModel(value: unknown, seat: string, what?: string, note?: string): Model;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { describeFault, receive } from "./mods/kernel/receive.js";
|
|
3
|
+
import { DECLARATION_RECEIPT_MODE } from "./own-property-receipt.js";
|
|
4
|
+
import { assertNoRetiredKeys, RETIRED_MODEL_KEYS } from "./retired-keys.js";
|
|
5
|
+
export function modelBindingRefusal(field, reason, message) {
|
|
6
|
+
const e = new Error(message);
|
|
7
|
+
e.code = "config.unknown_role";
|
|
8
|
+
e.detail = { field, reason };
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
export function isList(value) {
|
|
12
|
+
try {
|
|
13
|
+
return Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function bindingShown(value) {
|
|
20
|
+
if (typeof value === "string")
|
|
21
|
+
return JSON.stringify(value.length > 80 ? `${value.slice(0, 80)}…` : value);
|
|
22
|
+
return value === null ? "null" : isList(value) ? "a list" : `a ${typeof value}`;
|
|
23
|
+
}
|
|
24
|
+
const MODEL_MEMBER_TABLE = {
|
|
25
|
+
id: true,
|
|
26
|
+
name: true,
|
|
27
|
+
api: true,
|
|
28
|
+
provider: true,
|
|
29
|
+
baseUrl: true,
|
|
30
|
+
reasoning: true,
|
|
31
|
+
defaultThinking: true,
|
|
32
|
+
thinkingLevelMap: true,
|
|
33
|
+
input: true,
|
|
34
|
+
cost: true,
|
|
35
|
+
contextWindow: true,
|
|
36
|
+
contextTokens: true,
|
|
37
|
+
autoCompactTokens: true,
|
|
38
|
+
charsPerToken: true,
|
|
39
|
+
maxTokens: true,
|
|
40
|
+
params: true,
|
|
41
|
+
extraBody: true,
|
|
42
|
+
headers: true,
|
|
43
|
+
promptTraits: true,
|
|
44
|
+
compat: true,
|
|
45
|
+
};
|
|
46
|
+
const MODEL_MEMBERS = new Set(Object.keys(MODEL_MEMBER_TABLE));
|
|
47
|
+
export const MODEL_RECEIPT_MODE = Object.freeze({ ...DECLARATION_RECEIPT_MODE, live: Object.freeze(["headers"]) });
|
|
48
|
+
const MINTED = new WeakSet();
|
|
49
|
+
const LAST = new WeakMap();
|
|
50
|
+
const ORIGIN = new WeakMap();
|
|
51
|
+
export function isModelSnapshot(value) {
|
|
52
|
+
return typeof value === "object" && value !== null && MINTED.has(value);
|
|
53
|
+
}
|
|
54
|
+
export function modelOriginOf(model) {
|
|
55
|
+
return ORIGIN.get(model)?.origin ?? model;
|
|
56
|
+
}
|
|
57
|
+
function unreadableModelRefusal(seat, what, note, fault) {
|
|
58
|
+
const how = fault.path.length > 0
|
|
59
|
+
? describeFault(fault)
|
|
60
|
+
: fault.kind === "proxy"
|
|
61
|
+
? "a Proxy"
|
|
62
|
+
: "an object of another prototype (a class instance, an `Object.create(…)` value): a Model is a plain record, its members its own";
|
|
63
|
+
return modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} that could not be read as plain data — ${how}.${note}`);
|
|
64
|
+
}
|
|
65
|
+
export function receiveModel(value, seat, what = "a Model object", note = "") {
|
|
66
|
+
if (isModelSnapshot(value))
|
|
67
|
+
return value;
|
|
68
|
+
if (typeof value !== "object" || value === null || isList(value)) {
|
|
69
|
+
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} that is ${bindingShown(value)}, not a Model — a Model is a plain record carrying a non-empty string \`id\` and a string \`api\`.${note}`);
|
|
70
|
+
}
|
|
71
|
+
if (types.isProxy(value))
|
|
72
|
+
throw unreadableModelRefusal(seat, what, note, { kind: "proxy", path: [] });
|
|
73
|
+
const headersAt = Object.getOwnPropertyDescriptor(value, "headers");
|
|
74
|
+
const headers = headersAt !== undefined && !Object.hasOwn(headersAt, "value") ? headersAt.get : undefined;
|
|
75
|
+
const received = receive(value, MODEL_RECEIPT_MODE, MINTED);
|
|
76
|
+
if (!received.ok)
|
|
77
|
+
throw unreadableModelRefusal(seat, what, note, received.fault);
|
|
78
|
+
const copy = received.value;
|
|
79
|
+
judgeModelCopy(copy, seat, what, note);
|
|
80
|
+
const prior = LAST.get(value);
|
|
81
|
+
if (prior !== undefined && ORIGIN.get(prior)?.headers === headers && sameData(prior, copy, true))
|
|
82
|
+
return prior;
|
|
83
|
+
MINTED.add(copy);
|
|
84
|
+
LAST.set(value, copy);
|
|
85
|
+
ORIGIN.set(copy, { origin: value, headers });
|
|
86
|
+
return copy;
|
|
87
|
+
}
|
|
88
|
+
function judgeModelCopy(copy, seat, what, note) {
|
|
89
|
+
assertNoRetiredKeys(copy, RETIRED_MODEL_KEYS, "Model");
|
|
90
|
+
const id = copy["id"];
|
|
91
|
+
const api = copy["api"];
|
|
92
|
+
const [member, got] = typeof id !== "string" || id === "" ? ["id", id] : typeof api !== "string" ? ["api", api] : [undefined, undefined];
|
|
93
|
+
if (member !== undefined) {
|
|
94
|
+
const shown = got === undefined ? "absent" : bindingShown(got);
|
|
95
|
+
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`${member}\` is ${shown} — a Model carries a non-empty string \`id\` and a string \`api\`.${note}`);
|
|
96
|
+
}
|
|
97
|
+
for (const key of Object.keys(copy)) {
|
|
98
|
+
if (!MODEL_MEMBERS.has(key)) {
|
|
99
|
+
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} carrying ${bindingShown(key)}, which is not a member of Model — a provider's own parameters belong in \`Model.params\`.${note}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function sameData(a, b, top = false, compared = new Map()) {
|
|
104
|
+
if (Object.is(a, b))
|
|
105
|
+
return true;
|
|
106
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
107
|
+
return false;
|
|
108
|
+
const partners = compared.get(a);
|
|
109
|
+
if (partners?.has(b) === true)
|
|
110
|
+
return true;
|
|
111
|
+
if (partners === undefined)
|
|
112
|
+
compared.set(a, new Set([b]));
|
|
113
|
+
else
|
|
114
|
+
partners.add(b);
|
|
115
|
+
if (Array.isArray(a) !== Array.isArray(b) || (Array.isArray(a) && Array.isArray(b) && a.length !== b.length))
|
|
116
|
+
return false;
|
|
117
|
+
const ka = Object.keys(a);
|
|
118
|
+
const kb = Object.keys(b);
|
|
119
|
+
if (ka.length !== kb.length)
|
|
120
|
+
return false;
|
|
121
|
+
for (let i = 0; i < ka.length; i++) {
|
|
122
|
+
const k = ka[i];
|
|
123
|
+
if (k !== kb[i])
|
|
124
|
+
return false;
|
|
125
|
+
const da = Object.getOwnPropertyDescriptor(a, k);
|
|
126
|
+
const db = Object.getOwnPropertyDescriptor(b, k);
|
|
127
|
+
const aData = Object.hasOwn(da, "value");
|
|
128
|
+
if (aData !== Object.hasOwn(db, "value"))
|
|
129
|
+
return false;
|
|
130
|
+
if (!aData) {
|
|
131
|
+
if (!top)
|
|
132
|
+
return false;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (!sameData(da.value, db.value, false, compared))
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type ModCallEntry } from "./kernel/index.js";
|
|
2
|
+
import type { HookInvocationIdentity } from "../hooks.js";
|
|
3
|
+
import type { PermissionMode } from "../ask-origin.js";
|
|
4
|
+
import { type LegModBus } from "./stations.js";
|
|
5
|
+
import { type ToolCallEntryInput } from "./tool-call.js";
|
|
6
|
+
/** One agent type as the model is offered it. */
|
|
7
|
+
export interface OfferedAgent {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The offered set — the ONE reading of "which agent types is the model offered": each type the chain does not answer
|
|
13
|
+
* `{ isOffered: false }`, in the order given. A seat nothing hears ({@link seatHears}), no dispatch: the types as given.
|
|
14
|
+
* A dispatch the engine itself could not raise offers the type (an observation of the offer is never what hides it).
|
|
15
|
+
*/
|
|
16
|
+
export declare function offeredAgents<A extends OfferedAgent>(seat: {
|
|
17
|
+
readonly bus: LegModBus;
|
|
18
|
+
} | undefined, agents: readonly A[], signal: AbortSignal | undefined): Promise<readonly A[]>;
|
|
19
|
+
/** A rendered agent listing read through the offered set: the same listing when every type is offered, else a copy with the
|
|
20
|
+
* types the chain hid left out — what a listing frame renders, commits and mirrors. */
|
|
21
|
+
export declare function offeredAgentListing<L extends {
|
|
22
|
+
readonly entries: readonly OfferedAgent[];
|
|
23
|
+
}>(seat: {
|
|
24
|
+
readonly bus: LegModBus;
|
|
25
|
+
} | undefined, listing: L | undefined, signal: AbortSignal | undefined): Promise<L | undefined>;
|
|
26
|
+
/** What the delegation decided about the subagent it is about to start, as `agent.spawn` names it. */
|
|
27
|
+
export interface AgentSpawnFacts {
|
|
28
|
+
/** The delegation call this spawn belongs to. */
|
|
29
|
+
readonly toolCallId: string;
|
|
30
|
+
readonly prompt: string;
|
|
31
|
+
readonly description: string;
|
|
32
|
+
/** The resolved type (a definition's name, `general-purpose`, `fork`). */
|
|
33
|
+
readonly subagentType: string;
|
|
34
|
+
/** The model the subagent starts on, as the delegation settled it; absent when its own prepare decides (a stated tier). */
|
|
35
|
+
readonly model?: string;
|
|
36
|
+
/** The parent's own model. */
|
|
37
|
+
readonly parentModel?: string;
|
|
38
|
+
readonly background: boolean;
|
|
39
|
+
readonly fork: boolean;
|
|
40
|
+
/** The name it is addressed by (a teammate), when the call gave one. */
|
|
41
|
+
readonly name?: string;
|
|
42
|
+
readonly cwd?: string;
|
|
43
|
+
/** A workflow script's agent rather than a model's delegation. */
|
|
44
|
+
readonly workflow?: true;
|
|
45
|
+
}
|
|
46
|
+
/** What `agent.spawn` came to: the subagent may start, or the chain refused it (`by` = the registration). */
|
|
47
|
+
export type AgentSpawnVerdict = {
|
|
48
|
+
readonly go: true;
|
|
49
|
+
} | {
|
|
50
|
+
readonly go: false;
|
|
51
|
+
readonly by: string;
|
|
52
|
+
readonly reason: string;
|
|
53
|
+
};
|
|
54
|
+
/** The model a started subagent is named by: the one the delegation settled, `inherit` when the child's own prepare decides —
|
|
55
|
+
* what `agent.spawn`'s bottom comes up as and what `$.agent.spawn` answers. */
|
|
56
|
+
export declare function spawnedModel(model: string | undefined): string;
|
|
57
|
+
/** The extension's own spawn a delegation call is ({@link AgentStations.extensionSpawn}): who asked, and the one write of "started". */
|
|
58
|
+
export interface ExtensionSpawn {
|
|
59
|
+
/** The registration that called `$.agent.spawn`. */
|
|
60
|
+
readonly by: string;
|
|
61
|
+
/** The subagent was let run under `agentId` — its registry task id, which is its leg's task id and so its events' `agentId`;
|
|
62
|
+
* `model` is the one the delegation settled (`undefined` ⇒ the child's prepare decides). Written once. */
|
|
63
|
+
launched(agentId: string, model: string | undefined): void;
|
|
64
|
+
}
|
|
65
|
+
/** The delegating leg's two agent stations, as its delegation tools read them (a Runner-filled seat, never a model argument). */
|
|
66
|
+
export interface AgentStations {
|
|
67
|
+
/** Whether a handler hangs on the event — a caller with nothing to raise reads none (no await on its path). */
|
|
68
|
+
listens(event: "agent.offer" | "agent.spawn"): boolean;
|
|
69
|
+
/** {@link offeredAgents} over the leg's bus. */
|
|
70
|
+
offered<A extends OfferedAgent>(agents: readonly A[], signal: AbortSignal | undefined): Promise<readonly A[]>;
|
|
71
|
+
/** Raise `agent.spawn` (no handler ⇒ nothing raised: the subagent may start). */
|
|
72
|
+
spawn(facts: AgentSpawnFacts, signal: AbortSignal | undefined): Promise<AgentSpawnVerdict>;
|
|
73
|
+
/** The extension's own call (`$.agent.spawn`) the delegation call `toolCallId` is, on this leg — undefined for any other call
|
|
74
|
+
* (the model's, or a tool's an extension called with `$.tool.call` that runs the delegation in its body). The one reading of
|
|
75
|
+
* "an extension asked for this spawn": read once per call. */
|
|
76
|
+
extensionSpawn(toolCallId: string | undefined): ExtensionSpawn | undefined;
|
|
77
|
+
}
|
|
78
|
+
export interface AgentStationsInput {
|
|
79
|
+
readonly bus: LegModBus;
|
|
80
|
+
/** The delegating leg's identity (its `agentId` is the spawn's `parentAgentId`). */
|
|
81
|
+
readonly identity: HookInvocationIdentity | undefined;
|
|
82
|
+
/** The delegating leg's mode as observed at the spawn. */
|
|
83
|
+
readonly permissionMode: () => PermissionMode | undefined;
|
|
84
|
+
}
|
|
85
|
+
/** The leg's agent stations over its bus. */
|
|
86
|
+
export declare function createAgentStations(input: AgentStationsInput): AgentStations;
|
|
87
|
+
/** What `$.agent.spawn`'s host entry runs a spawn on: the leg's harness (the loop's pipeline under the running prompt), the
|
|
88
|
+
* names its live roster mounts, and the tools as the caller handed them (a delegation tool is known by its `execute`). */
|
|
89
|
+
export interface AgentSpawnEntryInput extends Pick<ToolCallEntryInput, "bus" | "harness" | "specOf"> {
|
|
90
|
+
/** The names the leg's live roster mounts. */
|
|
91
|
+
readonly mounted: () => readonly string[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* `$.agent.spawn`'s host entry (see the module header): the leg's one delegation tool, run through the loop's per-call pipeline as
|
|
95
|
+
* the caller's call. It answers off the call's record: started ⇒ `{ model, agentId }` (whatever the post-execution stations did to
|
|
96
|
+
* the result); not started and refused or failed ⇒ `{ deny: <the result's text> }`; not started with no error (an extension answered
|
|
97
|
+
* the call in place of its body) ⇒ `{ model }`, no `agentId`. It throws on an empty prompt, and when the leg mounts no delegation
|
|
98
|
+
* tool or more than one (it names them; it never picks).
|
|
99
|
+
*/
|
|
100
|
+
export declare function createAgentSpawnEntry(input: AgentSpawnEntryInput): ModCallEntry;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { ENGINE_ORIGIN } from "./kernel/index.js";
|
|
3
|
+
import { isPlainRecord } from "./kernel/receive.js";
|
|
4
|
+
import { NEXT_IN_FLIGHT } from "./kernel/site-rules.js";
|
|
5
|
+
import { describeThrown } from "../tool-policy.js";
|
|
6
|
+
import { extensionWords } from "../untrusted-egress.js";
|
|
7
|
+
import { declaredDelegationNameOf } from "../delegation-name.js";
|
|
8
|
+
import { failedHandlerClause, seatHears } from "./stations.js";
|
|
9
|
+
import { agentIdOf } from "../leg-identity.js";
|
|
10
|
+
import { extensionCallOf, noteExtensionCallLaunched, runExtensionCall } from "./extension-call.js";
|
|
11
|
+
import { resultText } from "./tool-call.js";
|
|
12
|
+
const ENGINE_PROVIDER = Object.freeze({ plugin: ENGINE_ORIGIN.plugin, tier: ENGINE_ORIGIN.tier });
|
|
13
|
+
const OFFERED = Object.freeze({ isOffered: true });
|
|
14
|
+
function offerAnswer(answer) {
|
|
15
|
+
if (!isPlainRecord(answer) || typeof answer["isOffered"] !== "boolean" || Object.keys(answer).some((k) => k !== "isOffered"))
|
|
16
|
+
return "agent.offer takes next(e) or { isOffered: <boolean> }";
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export async function offeredAgents(seat, agents, signal) {
|
|
20
|
+
if (agents.length === 0 || !seatHears(seat, "agent.offer"))
|
|
21
|
+
return agents;
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const a of agents) {
|
|
24
|
+
let outcome;
|
|
25
|
+
try {
|
|
26
|
+
outcome = await seat.bus.dispatch("agent.offer", { agent: a.name, description: a.description, provider: ENGINE_PROVIDER }, { bottom: () => OFFERED, checkAnswer: offerAnswer, ...(signal !== undefined ? { signal } : {}) });
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
out.push(a);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (outcome.kind === "answered" && isPlainRecord(outcome.answer) && outcome.answer["isOffered"] === false)
|
|
33
|
+
continue;
|
|
34
|
+
out.push(a);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
export async function offeredAgentListing(seat, listing, signal) {
|
|
39
|
+
if (listing === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
const entries = await offeredAgents(seat, listing.entries, signal);
|
|
42
|
+
return entries === listing.entries || entries.length === listing.entries.length ? listing : { ...listing, entries };
|
|
43
|
+
}
|
|
44
|
+
export function spawnedModel(model) {
|
|
45
|
+
return model ?? "inherit";
|
|
46
|
+
}
|
|
47
|
+
const GO = Object.freeze({ go: true });
|
|
48
|
+
const FORM = "agent.spawn takes next(e) or { deny: <reason> } (every member is pinned: a spawn is refused, never rewritten)";
|
|
49
|
+
const denyOf = (a) => isPlainRecord(a) && Object.keys(a).length === 1 && typeof a["deny"] === "string" && a["deny"] !== "" ? a["deny"] : undefined;
|
|
50
|
+
const RANKS = Object.freeze({ of: (a) => (denyOf(a) !== undefined ? 1 : 0), top: 1 });
|
|
51
|
+
export function createAgentStations(input) {
|
|
52
|
+
return {
|
|
53
|
+
listens: (event) => seatHears(input, event),
|
|
54
|
+
offered: (agents, signal) => offeredAgents(input, agents, signal),
|
|
55
|
+
extensionSpawn: (toolCallId) => {
|
|
56
|
+
const call = toolCallId !== undefined ? extensionCallOf(input.bus, toolCallId) : undefined;
|
|
57
|
+
if (call === undefined || call.door !== "agent.spawn" || toolCallId === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
return { by: call.caller.origin.plugin, launched: (agentId, model) => noteExtensionCallLaunched(input.bus, toolCallId, { agentId, model: spawnedModel(model) }) };
|
|
60
|
+
},
|
|
61
|
+
spawn: async (facts, signal) => {
|
|
62
|
+
if (!seatHears(input, "agent.spawn"))
|
|
63
|
+
return GO;
|
|
64
|
+
const parentAgentId = agentIdOf(input.identity);
|
|
65
|
+
const permissionMode = input.permissionMode();
|
|
66
|
+
const e = {
|
|
67
|
+
...(input.identity !== undefined ? { identity: input.identity } : {}),
|
|
68
|
+
tool_use_id: facts.toolCallId,
|
|
69
|
+
prompt: facts.prompt,
|
|
70
|
+
description: facts.description,
|
|
71
|
+
subagentType: facts.subagentType,
|
|
72
|
+
provider: ENGINE_PROVIDER,
|
|
73
|
+
...(facts.model !== undefined ? { model: facts.model } : {}),
|
|
74
|
+
...(facts.parentModel !== undefined ? { parentModel: facts.parentModel } : {}),
|
|
75
|
+
...(parentAgentId !== undefined ? { parentAgentId } : {}),
|
|
76
|
+
...(permissionMode !== undefined ? { permissionMode } : {}),
|
|
77
|
+
background: facts.background,
|
|
78
|
+
fork: facts.fork,
|
|
79
|
+
isTeammate: facts.name !== undefined,
|
|
80
|
+
...(facts.name !== undefined ? { name: facts.name } : {}),
|
|
81
|
+
...(facts.cwd !== undefined ? { cwd: facts.cwd } : {}),
|
|
82
|
+
...(facts.workflow === true ? { workflow: true } : {}),
|
|
83
|
+
};
|
|
84
|
+
const started = Object.freeze({ model: spawnedModel(facts.model) });
|
|
85
|
+
const checkAnswer = (a, _e, _by, below, ran) => {
|
|
86
|
+
if (a === started)
|
|
87
|
+
return undefined;
|
|
88
|
+
const reason = denyOf(a);
|
|
89
|
+
if (reason === undefined)
|
|
90
|
+
return FORM;
|
|
91
|
+
if (ran.bottomStarted)
|
|
92
|
+
return "a deny after the subagent was let start (once it starts, only its own run stands)";
|
|
93
|
+
if (below.includes(NEXT_IN_FLIGHT) || below.some((b) => denyOf(b) === undefined))
|
|
94
|
+
return "a deny while its next(e) still runs or after it was answered (deny in place of next)";
|
|
95
|
+
return undefined;
|
|
96
|
+
};
|
|
97
|
+
let outcome;
|
|
98
|
+
try {
|
|
99
|
+
outcome = await input.bus.dispatch("agent.spawn", e, { bottom: () => started, checkAnswer, ranks: RANKS, ...(signal !== undefined ? { signal } : {}) });
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
return { go: false, by: ENGINE_ORIGIN.plugin, reason: `the agent.spawn station could not be raised (${describeThrown(err)}); no subagent was started (fail-closed)` };
|
|
103
|
+
}
|
|
104
|
+
if (outcome.kind === "aborted")
|
|
105
|
+
return outcome.bottomStarted === true ? GO : { go: false, by: ENGINE_ORIGIN.plugin, reason: "the delegation was cancelled before its subagent started" };
|
|
106
|
+
if (outcome.kind === "failed")
|
|
107
|
+
return { go: false, by: outcome.registration, reason: `an agent.spawn extension ${failedHandlerClause(outcome)} before the subagent started; no subagent was started (fail-closed)` };
|
|
108
|
+
if (outcome.answer === started)
|
|
109
|
+
return GO;
|
|
110
|
+
const by = outcome.answeredBy ?? ENGINE_ORIGIN.plugin;
|
|
111
|
+
const reason = denyOf(outcome.answer);
|
|
112
|
+
return {
|
|
113
|
+
go: false,
|
|
114
|
+
by,
|
|
115
|
+
reason: reason !== undefined ? `extension "${extensionWords(by, 80)}" refused this delegation before its subagent started: ${extensionWords(reason, 300)}` : `extension "${extensionWords(by, 80)}" answered this delegation in a form agent.spawn does not take; no subagent was started (fail-closed)`,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const DESCRIPTION_WORDS = 5;
|
|
121
|
+
function delegationInput(args, prompt) {
|
|
122
|
+
return {
|
|
123
|
+
prompt,
|
|
124
|
+
description: args["description"] ?? prompt.split(/\s+/).slice(0, DESCRIPTION_WORDS).join(" "),
|
|
125
|
+
run_in_background: true,
|
|
126
|
+
...(args["model"] !== undefined ? { model: args["model"] } : {}),
|
|
127
|
+
...(args["subagentType"] !== undefined ? { subagent_type: args["subagentType"] } : {}),
|
|
128
|
+
...(args["name"] !== undefined ? { name: args["name"] } : {}),
|
|
129
|
+
...(args["cwd"] !== undefined ? { cwd: args["cwd"] } : {}),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export function createAgentSpawnEntry(input) {
|
|
133
|
+
return async (args, ctx) => {
|
|
134
|
+
const by = ctx.origin.plugin;
|
|
135
|
+
const prompt = args["prompt"];
|
|
136
|
+
if (typeof prompt !== "string" || prompt.trim() === "")
|
|
137
|
+
throw new TypeError(`${by}: $.agent.spawn takes { prompt, ... } (a non-empty prompt)`);
|
|
138
|
+
const tools = input.mounted().filter((name) => declaredDelegationNameOf(input.specOf(name)) !== undefined);
|
|
139
|
+
const tool = tools[0];
|
|
140
|
+
if (tool === undefined)
|
|
141
|
+
throw new TypeError(`${by}: $.agent.spawn: this run mounts no delegation tool`);
|
|
142
|
+
if (tools.length > 1)
|
|
143
|
+
throw new TypeError(`${by}: $.agent.spawn: this run mounts ${tools.length} delegation tools (${tools.map((n) => `"${extensionWords(n, 80)}"`).join(", ")}) and a spawn names none of them`);
|
|
144
|
+
const toolCallId = `ext-${randomUUID()}`;
|
|
145
|
+
return runExtensionCall(input.bus, toolCallId, "agent.spawn", ctx, async (call) => {
|
|
146
|
+
const finalized = await input.harness.callTool({ type: "toolCall", id: toolCallId, name: tool, arguments: delegationInput(args, prompt) }, ctx.signal, () => undefined);
|
|
147
|
+
if (call.launched !== undefined)
|
|
148
|
+
return Object.freeze({ model: call.launched.model, agentId: call.launched.agentId });
|
|
149
|
+
if (call.denied || finalized.isError)
|
|
150
|
+
return Object.freeze({ deny: resultText(finalized.result.content) || "no subagent was started" });
|
|
151
|
+
return Object.freeze({ model: spawnedModel(typeof args["model"] === "string" ? args["model"] : undefined) });
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
}
|