@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
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
7
7
|
import type { Context, Message, Usage } from "../../internal/llm.js";
|
|
8
|
+
import type { CompactOutcome } from "../task-event.js";
|
|
8
9
|
import type { ModDollarBase, ModMethodBottoms } from "./kernel/index.js";
|
|
9
10
|
/** `$.process.run`'s default command timeout (CC). */
|
|
10
11
|
export declare const PROCESS_RUN_DEFAULT_TIMEOUT_MS = 30000;
|
|
@@ -91,6 +92,29 @@ export interface EngineDollar extends ModDollarBase {
|
|
|
91
92
|
root(): Promise<string>;
|
|
92
93
|
model(): Promise<string>;
|
|
93
94
|
messages(): Promise<readonly Message[]>;
|
|
95
|
+
/** `$.session.append({ message: { role: "user", content }, agentId? })`: an extension's own note, admitted at the
|
|
96
|
+
* `session.append` station (`session-append.ts`). */
|
|
97
|
+
append(args: {
|
|
98
|
+
readonly message: {
|
|
99
|
+
readonly role: "user";
|
|
100
|
+
readonly content: string | readonly {
|
|
101
|
+
readonly type: "text";
|
|
102
|
+
readonly text: string;
|
|
103
|
+
}[];
|
|
104
|
+
};
|
|
105
|
+
readonly agentId?: string;
|
|
106
|
+
}): Promise<SessionAppendAnswer>;
|
|
107
|
+
/** `$.session.send({ to, text })`: the leg's SendMessage, run as the caller's own call and raised once at the
|
|
108
|
+
* `session.send` station (`session-send.ts`). */
|
|
109
|
+
send(args: {
|
|
110
|
+
readonly to: string;
|
|
111
|
+
readonly text: string;
|
|
112
|
+
}): Promise<SessionSendAnswer>;
|
|
113
|
+
/** `$.session.compact({ instructions? })`: a manual compaction pass at the turn boundary, in place — from a handler of
|
|
114
|
+
* `turn.complete` only (`session-compact.ts`). */
|
|
115
|
+
compact(args?: {
|
|
116
|
+
readonly instructions?: string;
|
|
117
|
+
}): Promise<SessionCompactAnswer>;
|
|
94
118
|
};
|
|
95
119
|
readonly clock: {
|
|
96
120
|
now(): Promise<number>;
|
|
@@ -107,8 +131,26 @@ export interface EngineDollar extends ModDollarBase {
|
|
|
107
131
|
};
|
|
108
132
|
readonly agent: {
|
|
109
133
|
list(): Promise<readonly string[]>;
|
|
134
|
+
/** `$.agent.spawn({ prompt, ... })`: the delegation tool's own pipeline as the caller's call, the subagent in the background
|
|
135
|
+
* (`createAgentSpawnEntry`, `agent-stations.ts`). */
|
|
136
|
+
spawn(args: {
|
|
137
|
+
readonly prompt: string;
|
|
138
|
+
readonly description?: string;
|
|
139
|
+
readonly subagentType?: string;
|
|
140
|
+
readonly model?: string;
|
|
141
|
+
readonly name?: string;
|
|
142
|
+
readonly cwd?: string;
|
|
143
|
+
}): Promise<AgentSpawnAnswer>;
|
|
110
144
|
};
|
|
111
145
|
}
|
|
146
|
+
/** What `$.agent.spawn` answers: the subagent started (`agentId`, the id its events carry; `model`, as `agent.spawn`'s bottom
|
|
147
|
+
* names it), none started because an extension answered the call in place of its body (`model` alone), or the refusal. */
|
|
148
|
+
export type AgentSpawnAnswer = {
|
|
149
|
+
readonly model: string;
|
|
150
|
+
readonly agentId?: string;
|
|
151
|
+
} | {
|
|
152
|
+
readonly deny: string;
|
|
153
|
+
};
|
|
112
154
|
/** What `$.tool.call` answers — `tool.call`'s own forms: the frozen view of the call's result, or the refusal (returned, not thrown). */
|
|
113
155
|
export type ToolCallAnswer = {
|
|
114
156
|
readonly result: {
|
|
@@ -118,5 +160,25 @@ export type ToolCallAnswer = {
|
|
|
118
160
|
} | {
|
|
119
161
|
readonly deny: string;
|
|
120
162
|
};
|
|
163
|
+
/** What `$.session.append` answers — `session.append`'s own forms: the note as kept (a frozen view), or the refusal (returned, not thrown). */
|
|
164
|
+
export type SessionAppendAnswer = {
|
|
165
|
+
readonly message: {
|
|
166
|
+
readonly role: "user";
|
|
167
|
+
readonly content: string | readonly object[];
|
|
168
|
+
};
|
|
169
|
+
} | {
|
|
170
|
+
readonly deny: string;
|
|
171
|
+
};
|
|
172
|
+
/** What `$.session.send` answers — `session.send`'s own forms: delivered, or not and why (returned, not thrown). */
|
|
173
|
+
export type SessionSendAnswer = {
|
|
174
|
+
readonly isDelivered: true;
|
|
175
|
+
} | {
|
|
176
|
+
readonly isDelivered: false;
|
|
177
|
+
readonly reason: string;
|
|
178
|
+
};
|
|
179
|
+
/** What `$.session.compact` answers: the in-place pass's outcome (a call it refuses throws, its reason on the report sink too). */
|
|
180
|
+
export interface SessionCompactAnswer {
|
|
181
|
+
readonly outcome: CompactOutcome;
|
|
182
|
+
}
|
|
121
183
|
/** The chain bottoms of the wave-one method events over a runner's seat view. */
|
|
122
184
|
export declare function engineMethodBottoms(view: ModSeatView): ModMethodBottoms;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { type ModBottomContext, type ModBus } from "./kernel/index.js";
|
|
2
2
|
import type { ExtensionRequester } from "../task-event.js";
|
|
3
|
+
/** Which `$` call made the record: the door the extension came through. */
|
|
4
|
+
export type ExtensionDoor = "tool.call" | "agent.spawn";
|
|
3
5
|
/** One extension's call while it runs. */
|
|
4
6
|
export interface ExtensionCall {
|
|
5
7
|
/** The leg bus the call was made on (the one {@link legBusOf} returned). */
|
|
6
8
|
readonly bus: ModBus;
|
|
7
9
|
readonly toolCallId: string;
|
|
10
|
+
/** The door: an extension's spawn is a record made by `$.agent.spawn` — a tool an extension calls through `$.tool.call` that
|
|
11
|
+
* runs the delegation inside its own body hands the delegation a tool call's record, and the delegation runs as it would
|
|
12
|
+
* for the model. */
|
|
13
|
+
readonly door: ExtensionDoor;
|
|
8
14
|
/** The `$` call's context: the frames its pipeline's events are raised under, and its origin. */
|
|
9
15
|
readonly caller: ModBottomContext;
|
|
10
16
|
/** Cleared when the call's pipeline settles — the one reading of "this call is still running". */
|
|
11
17
|
readonly live: boolean;
|
|
12
18
|
/** The call's end projection refused it (its latest gate record is a refusal) — written once, by the leg's tool_end station. */
|
|
13
19
|
readonly denied: boolean;
|
|
20
|
+
/** The subagent the call started (`$.agent.spawn`): its id and the model it was let start on — written once, by the delegation
|
|
21
|
+
* tool where it lets the subagent run; absent ⇒ none started (the call's result is never read for it). */
|
|
22
|
+
readonly launched?: {
|
|
23
|
+
readonly agentId: string;
|
|
24
|
+
readonly model: string;
|
|
25
|
+
};
|
|
14
26
|
}
|
|
15
27
|
/** The running extension call this chain carries for `bus`, when it is the call `toolCallId` names (or any, unnamed). */
|
|
16
28
|
export declare function extensionCallOf(bus: object, toolCallId?: string): ExtensionCall | undefined;
|
|
@@ -21,8 +33,10 @@ export declare function requesterOf(bus: object, toolCallId: string): {
|
|
|
21
33
|
};
|
|
22
34
|
/** The leg's tool_end station says the call it is closing was refused (a no-op for any call that is not the running extension call). */
|
|
23
35
|
export declare function noteExtensionCallDenied(bus: object, toolCallId: string): void;
|
|
36
|
+
/** The delegation tool says the extension's spawn it is running started its subagent (a no-op for any other call). */
|
|
37
|
+
export declare function noteExtensionCallLaunched(bus: object, toolCallId: string, launched: NonNullable<ExtensionCall["launched"]>): void;
|
|
24
38
|
/** Run an extension's call: `pipeline` runs with the call's record in scope; the record stops being live when it settles. */
|
|
25
|
-
export declare function runExtensionCall<T>(bus: ModBus, toolCallId: string, caller: ModBottomContext, pipeline: (call: ExtensionCall) => Promise<T>): Promise<T>;
|
|
39
|
+
export declare function runExtensionCall<T>(bus: ModBus, toolCallId: string, door: ExtensionDoor, caller: ModBottomContext, pipeline: (call: ExtensionCall) => Promise<T>): Promise<T>;
|
|
26
40
|
/**
|
|
27
41
|
* The leg bus every station raises on: a dispatch inside a running extension call made on it is raised under that call's
|
|
28
42
|
* frames and origin (a raiser that names its own frames keeps them — they extend the call's); one raised under a call
|
|
@@ -14,8 +14,13 @@ export function noteExtensionCallDenied(bus, toolCallId) {
|
|
|
14
14
|
if (c !== undefined && c.live && c.bus === bus && c.toolCallId === toolCallId)
|
|
15
15
|
c.denied = true;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
18
|
-
const
|
|
17
|
+
export function noteExtensionCallLaunched(bus, toolCallId, launched) {
|
|
18
|
+
const c = store.getStore();
|
|
19
|
+
if (c !== undefined && c.live && c.bus === bus && c.toolCallId === toolCallId && c.launched === undefined)
|
|
20
|
+
c.launched = Object.freeze({ agentId: launched.agentId, model: launched.model });
|
|
21
|
+
}
|
|
22
|
+
export async function runExtensionCall(bus, toolCallId, door, caller, pipeline) {
|
|
23
|
+
const call = { bus, toolCallId, door, caller, live: true, denied: false };
|
|
19
24
|
try {
|
|
20
25
|
return await store.run(call, () => pipeline(call));
|
|
21
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ModBusSide, type ModEventName, type ModSeat } from "./events.js";
|
|
2
2
|
import { type ModAdmissionRecord, type ModDollarBase, type ModOrigin, type ModSeats } from "./registration.js";
|
|
3
|
-
import { type ModAnswerCheck, type ModAnswerRanks, type ModEventPayload, type ModFailureCause, type ModMatcher, type ModSkip, type ProxyProbe } from "./site-rules.js";
|
|
3
|
+
import { type ModAnswerCheck, type ModAnswerer, type ModAnswerRanks, type ModEventPayload, type ModFailureCause, type ModMatcher, type ModSkip, type ProxyProbe } from "./site-rules.js";
|
|
4
4
|
/** A frame on the dispatch stack: a registration's own `$` call, or one of its handlers running. */
|
|
5
5
|
export type ModFrame = {
|
|
6
6
|
readonly kind: "dollar";
|
|
@@ -40,12 +40,16 @@ export type ModDispatchOutcome = {
|
|
|
40
40
|
readonly answer: unknown;
|
|
41
41
|
readonly answeredBy?: string;
|
|
42
42
|
readonly skipped: readonly ModSkip[];
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
|
+
/** `bottomStarted`: the chain's bottom had started when the handler failed — on an effect event, what it did happened, and
|
|
45
|
+
* its outcome is the station's to withhold. */
|
|
46
|
+
| {
|
|
44
47
|
readonly kind: "failed";
|
|
45
48
|
readonly registration: string;
|
|
46
49
|
readonly cause: ModFailureCause;
|
|
47
50
|
readonly reason: string;
|
|
48
51
|
readonly skipped: readonly ModSkip[];
|
|
52
|
+
readonly bottomStarted?: true;
|
|
49
53
|
}
|
|
50
54
|
/** `bottomStarted`: the chain's bottom had started when the dispatch was cancelled — on an effect event, what it did is
|
|
51
55
|
* not known from here. */
|
|
@@ -69,8 +73,9 @@ export interface ModDispatchOptions {
|
|
|
69
73
|
/** The raiser's reading of an answer; an answer it refuses is a violation of the site. */
|
|
70
74
|
readonly checkAnswer?: ModAnswerCheck;
|
|
71
75
|
/** The raiser's reading of what a handler hands on (a payload other than the dispatch's own `e`, received, its pinned keys
|
|
72
|
-
* judged); a payload it refuses is a violation of the site — the other direction of
|
|
73
|
-
|
|
76
|
+
* judged), with the handler that hands it on; a payload it refuses is a violation of the site — the other direction of
|
|
77
|
+
* {@link checkAnswer}. */
|
|
78
|
+
readonly checkHandOn?: (payload: ModEventPayload, by: ModAnswerer) => string | undefined;
|
|
74
79
|
/** The station's ranking of its answers — named by every dispatch of an event whose failure column refuses (one that
|
|
75
80
|
* names none is not run), and read by the seat-trust law. */
|
|
76
81
|
readonly ranks?: ModAnswerRanks;
|
|
@@ -371,13 +371,13 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
371
371
|
let found;
|
|
372
372
|
return () => (found ??= sealedObjects([e0]));
|
|
373
373
|
})();
|
|
374
|
-
const handOn = (passed) => {
|
|
374
|
+
const handOn = (passed, h) => {
|
|
375
375
|
if (passed === e0)
|
|
376
376
|
return { snap: e0 };
|
|
377
377
|
const handed = handedOn(st.pinned, e0, passed, engines(), isProxy);
|
|
378
378
|
if ("violation" in handed)
|
|
379
379
|
return handed;
|
|
380
|
-
const why = handOnViolation(handed.payload, options.checkHandOn);
|
|
380
|
+
const why = handOnViolation(handed.payload, options.checkHandOn, answererOf(h));
|
|
381
381
|
return why !== undefined ? { violation: why } : { snap: handed.payload };
|
|
382
382
|
};
|
|
383
383
|
const trustFloors = new Map();
|
|
@@ -516,7 +516,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
516
516
|
state.violated ??= "next() already called (a handler calls next once; its first run's answer stands)";
|
|
517
517
|
return Promise.reject(new Error(`${name}: next() already called`));
|
|
518
518
|
}
|
|
519
|
-
const handed = handOn(passed);
|
|
519
|
+
const handed = handOn(passed, h);
|
|
520
520
|
if ("violation" in handed) {
|
|
521
521
|
state.violated ??= handed.violation;
|
|
522
522
|
return Promise.reject(new Error(`${name}: ${state.violated}`));
|
|
@@ -596,12 +596,12 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
596
596
|
throw failure.error;
|
|
597
597
|
}
|
|
598
598
|
const reason = caught !== undefined ? `${failure.reason}; ${caught.problem}` : failure.reason;
|
|
599
|
-
const
|
|
600
|
-
if (refusing && !
|
|
601
|
-
if (failure.cause !== "violation")
|
|
599
|
+
const goAheadStands = st.failure === "refuse_until_run" && bottomStarted && state.last !== undefined;
|
|
600
|
+
if (refusing && !goAheadStands) {
|
|
601
|
+
if (failure.cause !== "violation" || bottomStarted)
|
|
602
602
|
report(new Error(`${name}: ${event}: ${reason} — failed closed: the dispatch ends here`));
|
|
603
603
|
traceOf(sink, i, name, h.reg.tier, "rejected", ms);
|
|
604
|
-
finish({ kind: "failed", registration: name, cause: failure.cause, reason, skipped: Object.freeze([...skipped]) });
|
|
604
|
+
finish({ kind: "failed", registration: name, cause: failure.cause, reason, skipped: Object.freeze([...skipped]), ...(bottomStarted ? { bottomStarted: true } : {}) });
|
|
605
605
|
throw terminal;
|
|
606
606
|
}
|
|
607
607
|
skipped.push(Object.freeze({ registration: name, cause: failure.cause, reason }));
|
|
@@ -634,7 +634,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
634
634
|
running.then(resume, resume);
|
|
635
635
|
return running;
|
|
636
636
|
}
|
|
637
|
-
const handed = handOn(passed);
|
|
637
|
+
const handed = handOn(passed, h);
|
|
638
638
|
if ("violation" in handed) {
|
|
639
639
|
violated ??= handed.violation;
|
|
640
640
|
return Promise.reject(new Error(`${h.reg.name}: ${violated}`));
|
|
@@ -26,8 +26,15 @@
|
|
|
26
26
|
* and an admission record carries the registration's `provenance` as the host gave it and lists in `observe` only the patterns
|
|
27
27
|
* on which every handler it hung watches.
|
|
28
28
|
* 5: `classic.SubagentStart` has a station (a delegated leg's opening event).
|
|
29
|
+
* 6: `agent.offer` (a listed or named agent type, before the model is offered it), `agent.spawn` (a delegation the gate let
|
|
30
|
+
* go, before its subagent starts — every argument pinned, a refusal its only answer), `turn.complete` (a model turn ended)
|
|
31
|
+
* and `session.end` (a leg ended) have stations; `tool.call`'s failure column is `refuse` — a failure once the body has
|
|
32
|
+
* started withholds the result (under `refuse_until_run`, its column until 5, the result stood).
|
|
33
|
+
* 7: `session.receive` (a frame arriving for the model), `session.append` (a row entering the conversation), `session.send` (a
|
|
34
|
+
* message the leg sends) and `session.compact` (a compaction about to run) have stations; `agent.spawn` has a `call` column,
|
|
35
|
+
* and so do `session.append`, `session.send` and `session.compact` — a `$` call of each reaches the host's entry.
|
|
29
36
|
*/
|
|
30
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
37
|
+
export declare const KERNEL_CONTRACT_VERSION = 7;
|
|
31
38
|
/** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
|
|
32
39
|
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
33
40
|
export type ModTier = (typeof MOD_TIERS)[number];
|
|
@@ -42,9 +49,11 @@ export type ModEventSide = (typeof MOD_EVENT_SIDES)[number];
|
|
|
42
49
|
/** A bus is one side. */
|
|
43
50
|
export type ModBusSide = Exclude<ModEventSide, "both">;
|
|
44
51
|
/**
|
|
45
|
-
* What a handler's failure means for the dispatch: the station's refusal (final); skip the handler; or — on an event
|
|
46
|
-
*
|
|
47
|
-
* the bottom
|
|
52
|
+
* What a handler's failure means for the dispatch: the station's refusal (final); skip the handler; or — on an event whose
|
|
53
|
+
* bottom is a go-ahead the station acts on after the dispatch (`agent.spawn`: the subagent is let start) — the refusal
|
|
54
|
+
* while the bottom has not started and, once it has, the go-ahead stands (the failure is reported beside it). A `refuse`
|
|
55
|
+
* station refuses whether or not its bottom has started: on one whose bottom is an effect (`tool.call`: a tool runs), the
|
|
56
|
+
* dispatch's `failed` outcome says the bottom had started, and the station withholds what it produced.
|
|
48
57
|
*/
|
|
49
58
|
export declare const MOD_FAILURE_ANSWERS: readonly ["refuse", "skip", "refuse_until_run"];
|
|
50
59
|
export type ModFailureAnswer = (typeof MOD_FAILURE_ANSWERS)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 7;
|
|
2
2
|
export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
|
|
3
3
|
export const MOD_SEATS = Object.freeze(["deployment", "task"]);
|
|
4
4
|
export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
|
|
@@ -43,6 +43,10 @@ const surface = (s) => Object.freeze(s === undefined ? { side: "surface" } : { s
|
|
|
43
43
|
const RENDER_PINNED = ["surface", "component", "requestId", "viewport"];
|
|
44
44
|
const ELEMENT_PINNED = ["plugin", "element", "component", "requestId", "surface"];
|
|
45
45
|
const PROMPT_EDIT_BUDGET_MS = 50;
|
|
46
|
+
const AGENT_SPAWN_PINNED = [
|
|
47
|
+
"tool_use_id", "name", "fork", "isTeammate", "workflow", "parentModel", "permissionMode", "parentAgentId", "provider",
|
|
48
|
+
"prompt", "description", "subagentType", "model", "background", "cwd", "identity",
|
|
49
|
+
];
|
|
46
50
|
export const MOD_EVENT_TABLE = Object.freeze({
|
|
47
51
|
"classic.PreToolUse": engine(station("refuse", "immediate", ["tool", "tool_use_id", "agentId", "input"])),
|
|
48
52
|
"classic.PostToolUse": engine(station("skip", "grace")),
|
|
@@ -77,7 +81,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
77
81
|
"classic.FileChanged": engine(),
|
|
78
82
|
"classic.DirectoryAdded": engine(),
|
|
79
83
|
"classic.MessageDisplay": engine(),
|
|
80
|
-
"tool.call": engine(station("
|
|
84
|
+
"tool.call": engine(station("refuse", "immediate", ["tool", "tool_use_id", "agentId", "input"], { call: true })),
|
|
81
85
|
"tool.check": engine(station("refuse", "immediate", ["tool", "input", "tool_use_id", "agentId", "ceiling"])),
|
|
82
86
|
"ui.render": surface(station("skip", "grace", RENDER_PINNED)),
|
|
83
87
|
"ui.resolve": surface(station("skip", "grace", ["surface", "component"])),
|
|
@@ -88,8 +92,8 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
88
92
|
"ui.fault": surface(),
|
|
89
93
|
"ui.scroll": surface(station("skip", "grace", ["component", "requestId", "by", "bodyRows", "contentRows", "origin", "pointer"], { call: true })),
|
|
90
94
|
"ui.focus": surface(station("skip", "grace", ["component", "requestId", "plugin", "origin", "element"], { call: true })),
|
|
91
|
-
"agent.offer": engine(),
|
|
92
|
-
"agent.spawn": engine(),
|
|
95
|
+
"agent.offer": engine(station("skip", "grace", ["agent", "provider"])),
|
|
96
|
+
"agent.spawn": engine(station("refuse_until_run", "immediate", AGENT_SPAWN_PINNED, { call: true })),
|
|
93
97
|
"prompt.submit": engine(),
|
|
94
98
|
"prompt.fill": surface(station("skip", "grace", ["origin", "mode"], { call: true })),
|
|
95
99
|
"prompt.suggest": surface(station("skip", "grace", ["origin"], { call: true })),
|
|
@@ -110,18 +114,18 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
110
114
|
"skill.prompt": engine(),
|
|
111
115
|
"attribution.text": engine(),
|
|
112
116
|
"session.start": engine(),
|
|
113
|
-
"session.receive": engine(),
|
|
114
|
-
"session.append": engine(),
|
|
115
|
-
"session.send": engine(),
|
|
116
|
-
"session.compact": engine(),
|
|
117
|
+
"session.receive": engine(station("refuse", "immediate", ["origin", "event", "agentId"])),
|
|
118
|
+
"session.append": engine(station("skip", "grace", ["door", "origin", "agentId"], { call: true })),
|
|
119
|
+
"session.send": engine(station("refuse_until_run", "immediate", ["origin", "agentId", "to", "text"], { call: true })),
|
|
120
|
+
"session.compact": engine(station("refuse_until_run", "immediate", ["trigger", "agentId", "instructions"], { call: true })),
|
|
117
121
|
"session.attach": engine(),
|
|
118
122
|
"session.detach": engine(),
|
|
119
123
|
"session.measure": engine(),
|
|
120
|
-
"session.end": engine(),
|
|
124
|
+
"session.end": engine(station("skip", "grace", ["reason", "sessionId", "agentId"])),
|
|
121
125
|
"plugin.register": Object.freeze({ side: "both", station: station("refuse", "immediate", ["name", "seat", "tier", "uses"]) }),
|
|
122
126
|
"turn.start": engine(),
|
|
123
127
|
"turn.step": engine(),
|
|
124
|
-
"turn.complete": engine(),
|
|
128
|
+
"turn.complete": engine(station("skip", "grace", ["answer", "agentId", "turn"])),
|
|
125
129
|
"engine.create": engine(),
|
|
126
130
|
"model.complete": engine(method(true)),
|
|
127
131
|
"model.classify": engine(),
|
|
@@ -72,6 +72,11 @@ export interface ReceiptMode {
|
|
|
72
72
|
readonly leaves?: "cloned";
|
|
73
73
|
/** The host's Proxy probe. */
|
|
74
74
|
readonly isProxy?: (value: object) => boolean;
|
|
75
|
+
/** Members of the received value itself (its top level only, never `wire`) that are read PER USE rather than at the receipt:
|
|
76
|
+
* one of them that is an own accessor is never called by the receipt — the copy carries it as an accessor whose every read
|
|
77
|
+
* calls the caller's getter on the caller's object, once per read (a getter that throws, throws at that read). One that is a
|
|
78
|
+
* data property is received like any other member. */
|
|
79
|
+
readonly live?: readonly string[];
|
|
75
80
|
}
|
|
76
81
|
/** Why a receipt was refused. `uncopyable` has two causes, and depth is neither (the walk keeps its own stack): reading
|
|
77
82
|
* the value threw where none of its getters runs — a Proxy's trap, on a receipt given no Proxy probe; what it threw is
|
|
@@ -336,6 +336,16 @@ export function receive(value, mode, held) {
|
|
|
336
336
|
if (f.list && key === "length")
|
|
337
337
|
continue;
|
|
338
338
|
captured = f.captured[key];
|
|
339
|
+
if (f.level === 0 && !f.list && mode.live?.includes(key) === true && !Object.hasOwn(captured, "value")) {
|
|
340
|
+
const get = Object.hasOwn(captured, "get") ? captured.get : undefined;
|
|
341
|
+
const holder = f.v;
|
|
342
|
+
const d = Object.create(null);
|
|
343
|
+
d.get = get === undefined ? () => undefined : () => Reflect.apply(get, holder, []);
|
|
344
|
+
d.enumerable = true;
|
|
345
|
+
d.configurable = true;
|
|
346
|
+
DEFINE(f.out, key, d);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
339
349
|
}
|
|
340
350
|
if (key !== undefined) {
|
|
341
351
|
path[path.length] = key;
|
|
@@ -23,6 +23,9 @@ export interface ModOrigin {
|
|
|
23
23
|
}
|
|
24
24
|
/** The engine's own origin; its `plugin` word is reserved (no registration may take it). */
|
|
25
25
|
export declare const ENGINE_ORIGIN: ModOrigin;
|
|
26
|
+
/** The form of a registration name: 1–64 of letters, digits, `.`, `_`, `:` and `-` (`:` is the separator of the `skill:<name>` spelling a skill's registrations use). The one rule — a name reaches sentences a person or
|
|
27
|
+
* a model reads (`extension "<name>"`), so a name that could quote, bracket or fold a sentence is refused where it enters. */
|
|
28
|
+
export declare const MOD_REGISTRATION_NAME: RegExp;
|
|
26
29
|
/** The extension a refusal names: the registration's own name — never the engine's origin word (a raise the engine could not run
|
|
27
30
|
* names no extension), never an absent one. The one reading of "who refused" for every station that refuses a call at the hook
|
|
28
31
|
* layer (`GateDisposition.extension`). Module-level: not part of the kernel's entry. */
|
|
@@ -3,6 +3,7 @@ import { resolveModBudgetMs } from "./budget.js";
|
|
|
3
3
|
export const MODS_INVALID_CODE = "config.mods_invalid";
|
|
4
4
|
export const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
|
|
5
5
|
export const ENGINE_ORIGIN = Object.freeze({ plugin: "engine", tier: "core" });
|
|
6
|
+
export const MOD_REGISTRATION_NAME = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
6
7
|
export function namedRegistration(registration) {
|
|
7
8
|
return registration === undefined || registration === ENGINE_ORIGIN.plugin ? undefined : registration;
|
|
8
9
|
}
|
|
@@ -37,8 +38,12 @@ function screenOne(item, seat, side, report) {
|
|
|
37
38
|
if (!isRegistration(item))
|
|
38
39
|
throw modsInvalid(`a ${seat} mods entry is ${describe(item)}; a registration has a name and a register function`);
|
|
39
40
|
const name = item.name;
|
|
41
|
+
if (typeof name !== "string")
|
|
42
|
+
throw modsInvalid(`a ${seat} registration's name is ${describe(name)}; a registration name is a string`);
|
|
40
43
|
if (name === "")
|
|
41
44
|
throw modsInvalid(`a ${seat} registration has an empty name`);
|
|
45
|
+
if (!MOD_REGISTRATION_NAME.test(name))
|
|
46
|
+
throw modsInvalid(`a ${seat} registration's name (${name.length} characters) is outside the form of a registration name — 1 to 64 of letters, digits, ".", "_", ":" and "-"`);
|
|
42
47
|
if (name === ENGINE_ORIGIN.plugin)
|
|
43
48
|
throw modsInvalid(`a ${seat} registration is named "${name}", the engine's own origin word — choose another name`);
|
|
44
49
|
const tier = tierOf(item.tier, seat, name);
|
|
@@ -74,6 +74,9 @@ export interface PinnedKeyBreak {
|
|
|
74
74
|
* ({@link sameModValue}): the engine's own fact handed on as is, or a copy of it, is not a change.
|
|
75
75
|
*/
|
|
76
76
|
export declare function pinnedKeyChanged(pinned: readonly string[], received: ModEventPayload, passed: ModEventPayload): PinnedKeyBreak | undefined;
|
|
77
|
+
/** Whether `b` is the same data as `a`, by the one comparison a pinned key is judged by ({@link sameModValue}): a copy is the
|
|
78
|
+
* value it copies. A pair the walk cannot finish (past the depth bound, or a read that throws) is not proven the same. */
|
|
79
|
+
export declare function sameModData(a: unknown, b: unknown): boolean;
|
|
77
80
|
/** {@link engineObjects} of a dispatch's own event, found the first time it is asked and the same set every time after:
|
|
78
81
|
* the event is frozen, so one finding serves every receipt of the dispatch. */
|
|
79
82
|
export declare function engineObjectsOnce(held: ModEventPayload): () => ReadonlySet<object>;
|
|
@@ -109,9 +112,9 @@ export declare function pinnedHandOn(pinned: readonly string[], held: ModEventPa
|
|
|
109
112
|
};
|
|
110
113
|
/** Why a handler's answer breaks the site, or undefined. No answer at all is never an answer. */
|
|
111
114
|
export declare function answerViolation(answer: unknown, check: ModAnswerCheck | undefined, e: ModEventPayload, by: ModAnswerer, below: readonly unknown[], run: ModDispatchRun): string | undefined;
|
|
112
|
-
/** A station's reading of what a handler hands on: its sentence, or undefined (no check, or the
|
|
113
|
-
* throws is a sentence too — the station could not read the payload, so it is not handed on. */
|
|
114
|
-
export declare function handOnViolation(payload: ModEventPayload, check: ((payload: ModEventPayload) => string | undefined) | undefined): string | undefined;
|
|
115
|
+
/** A station's reading of what a handler hands on (and of who hands it on): its sentence, or undefined (no check, or the
|
|
116
|
+
* payload passes). A check that throws is a sentence too — the station could not read the payload, so it is not handed on. */
|
|
117
|
+
export declare function handOnViolation(payload: ModEventPayload, check: ((payload: ModEventPayload, by: ModAnswerer) => string | undefined) | undefined, by: ModAnswerer): string | undefined;
|
|
115
118
|
/**
|
|
116
119
|
* A `$` method's answer form: `{ value }` (the call's result) or `{ deny }` (the call throws). A `{ deny }` given after
|
|
117
120
|
* the handler's `next` was answered with something that is not a deny — or while that `next` is still running — breaks
|
|
@@ -81,6 +81,14 @@ export function pinnedKeyChanged(pinned, received, passed) {
|
|
|
81
81
|
const compared = comparePinned(pinned, received, passed);
|
|
82
82
|
return "broke" in compared ? compared.broke : undefined;
|
|
83
83
|
}
|
|
84
|
+
export function sameModData(a, b) {
|
|
85
|
+
try {
|
|
86
|
+
return sameModValue(a, b, new Map(), 1, new Map()) !== false;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
84
92
|
function comparePinned(pinned, received, passed) {
|
|
85
93
|
const paired = new Map();
|
|
86
94
|
const homes = new Map();
|
|
@@ -203,11 +211,11 @@ export function answerViolation(answer, check, e, by, below, run) {
|
|
|
203
211
|
return "returned an answer the station cannot read";
|
|
204
212
|
}
|
|
205
213
|
}
|
|
206
|
-
export function handOnViolation(payload, check) {
|
|
214
|
+
export function handOnViolation(payload, check, by) {
|
|
207
215
|
if (check === undefined)
|
|
208
216
|
return undefined;
|
|
209
217
|
try {
|
|
210
|
-
return check(payload);
|
|
218
|
+
return check(payload, by);
|
|
211
219
|
}
|
|
212
220
|
catch {
|
|
213
221
|
return "handed on an event the station cannot read";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A leg's two lifecycle stations over its bus, both observations (an answer changes nothing, a failure skips the handler).
|
|
3
|
+
* `turn.complete`: the turn's end records it ({@link noteCompletedTurn}); the next await point raises it once
|
|
4
|
+
* ({@link raiseCompletedTurn}) — the turn boundary after it, or the leg's settle for a turn whose boundary never ran.
|
|
5
|
+
* `e = { answer, reason, turn, isAborted, agentId?, usage? }`; the bottom comes up as `{ text: answer, usage? }`.
|
|
6
|
+
* `session.end`: a leg's terminal settled; `e = { reason, sessionId, agentId? }`, `reason` the terminal status word.
|
|
7
|
+
*/
|
|
8
|
+
import type { AssistantMessage } from "../../internal/llm.js";
|
|
9
|
+
import type { HookInvocationIdentity } from "../hooks.js";
|
|
10
|
+
import { type LegModBus } from "./stations.js";
|
|
11
|
+
/** Why a model turn ended. */
|
|
12
|
+
export type CompletedTurnReason = "answer" | "aborted" | "error";
|
|
13
|
+
/** A model turn that ended, as `turn.complete` names it (raised once, then gone). */
|
|
14
|
+
export interface CompletedTurn {
|
|
15
|
+
readonly answer: string;
|
|
16
|
+
readonly reason: CompletedTurnReason;
|
|
17
|
+
/** The leg's turn count at the turn's end (1 = its first turn). */
|
|
18
|
+
readonly turn: number;
|
|
19
|
+
readonly usage?: {
|
|
20
|
+
readonly inputTokens: number;
|
|
21
|
+
readonly outputTokens: number;
|
|
22
|
+
readonly cacheReadTokens: number;
|
|
23
|
+
readonly cacheWriteTokens: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Where the leg keeps the turns it has not raised yet, in order (a turn can end with no boundary after it — a recovery
|
|
27
|
+
* re-prompt, a failure's own `turn_end` — so the next await point may find more than one). */
|
|
28
|
+
export interface CompletedTurnSeat {
|
|
29
|
+
completed?: readonly CompletedTurn[];
|
|
30
|
+
}
|
|
31
|
+
/** Record the turn that just ended for `turn.complete` (nothing when no handler hangs on it); `aborted` = the leg's cancel was
|
|
32
|
+
* already in force when the turn ended, `usage` absent when none was reported. */
|
|
33
|
+
export declare function noteCompletedTurn(bus: LegModBus, seat: CompletedTurnSeat, message: AssistantMessage | undefined, turn: number, aborted: boolean, usage: CompletedTurn["usage"] | undefined): void;
|
|
34
|
+
/** Raise `turn.complete` for each turn the seat holds, in order, each once (the seat is emptied first). An engine-side
|
|
35
|
+
* rejection is swallowed: an observation never changes what it observes. */
|
|
36
|
+
export declare function raiseCompletedTurn(bus: LegModBus, seat: CompletedTurnSeat, identity: HookInvocationIdentity | undefined, signal: AbortSignal | undefined): Promise<void>;
|
|
37
|
+
/** Raise `session.end` as the leg's terminal settles (nothing when no handler hangs on it). */
|
|
38
|
+
export declare function raiseSessionEnd(bus: LegModBus, identity: HookInvocationIdentity | undefined, end: {
|
|
39
|
+
readonly reason: string;
|
|
40
|
+
readonly sessionId: string;
|
|
41
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { classicEventBase } from "./stations.js";
|
|
2
|
+
const answerOf = (message) => (message?.content ?? []).flatMap((c) => (c.type === "text" ? [c.text] : [])).join("");
|
|
3
|
+
export function noteCompletedTurn(bus, seat, message, turn, aborted, usage) {
|
|
4
|
+
if (!bus.hasHandlers("turn.complete"))
|
|
5
|
+
return;
|
|
6
|
+
const reason = aborted || message?.stopReason === "aborted" ? "aborted" : message?.stopReason === "error" ? "error" : "answer";
|
|
7
|
+
const ended = Object.freeze({ answer: answerOf(message), reason, turn, ...(usage !== undefined ? { usage: Object.freeze({ inputTokens: usage.inputTokens, outputTokens: usage.outputTokens, cacheReadTokens: usage.cacheReadTokens, cacheWriteTokens: usage.cacheWriteTokens }) } : {}) });
|
|
8
|
+
seat.completed = Object.freeze([...(seat.completed ?? []), ended]);
|
|
9
|
+
}
|
|
10
|
+
export async function raiseCompletedTurn(bus, seat, identity, signal) {
|
|
11
|
+
const turns = seat.completed ?? [];
|
|
12
|
+
seat.completed = undefined;
|
|
13
|
+
if (!bus.hasHandlers("turn.complete"))
|
|
14
|
+
return;
|
|
15
|
+
for (const turn of turns) {
|
|
16
|
+
const e = { ...classicEventBase(identity), answer: turn.answer, reason: turn.reason, turn: turn.turn, isAborted: turn.reason === "aborted", ...(turn.usage !== undefined ? { usage: turn.usage } : {}) };
|
|
17
|
+
const core = Object.freeze({ text: turn.answer, ...(turn.usage !== undefined ? { usage: turn.usage } : {}) });
|
|
18
|
+
try {
|
|
19
|
+
await bus.dispatch("turn.complete", e, { bottom: () => core, ...(signal !== undefined ? { signal } : {}) });
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function raiseSessionEnd(bus, identity, end) {
|
|
26
|
+
if (!bus.hasHandlers("session.end"))
|
|
27
|
+
return;
|
|
28
|
+
const e = { ...classicEventBase(identity), reason: end.reason, sessionId: end.sessionId };
|
|
29
|
+
const core = Object.freeze({ sessionId: end.sessionId });
|
|
30
|
+
try {
|
|
31
|
+
await bus.dispatch("session.end", e, { bottom: () => core });
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
}
|
|
35
|
+
}
|