@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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `session.append` station, and the one seat every conversation row passes on its way in ({@link RowSeat}).
|
|
3
|
+
*
|
|
4
|
+
* THE RULE. A row enters the conversation at one point: its first commit point, before the live context reads it again and
|
|
5
|
+
* before the store keeps it. Every writer calls the seat there, once — the harness for the rows it commits (a row the loop
|
|
6
|
+
* ends, the record of an API failure, a row handed to its port), every direct writer of the leg through
|
|
7
|
+
* `appendAdmittedRow` (`row-admission.ts`). With a handler on `session.append` the seat raises the event once per row; with none, or before
|
|
8
|
+
* the leg's bus is bound, the row passes as made and nothing is raised.
|
|
9
|
+
*
|
|
10
|
+
* `e = { door, origin, agentId?, message }` plus the identity envelope; `door`, `origin` and `agentId` are pinned. `door` and
|
|
11
|
+
* `origin` are read off the row's own typed facts ({@link doorOf}, {@link originOf}) — no writer names them; an extension's
|
|
12
|
+
* own note (raised through `$.session.append`) is door `note`, origin `{ kind: "plugin", name }`. `message` is a frozen data
|
|
13
|
+
* view of the row: its role, the members that name it, and its content.
|
|
14
|
+
*
|
|
15
|
+
* A handler answers:
|
|
16
|
+
* - `next(e)` — the row is kept as made; what comes up is `{ message }`, the row as kept;
|
|
17
|
+
* - `next({ ...e, message })` — the row is kept with its content rewritten: only text changes (a text block's text, or a
|
|
18
|
+
* string content); every other block stays, the same blocks in the same order, and every member beside `content` is
|
|
19
|
+
* pinned. The rewrite is made on the row itself, in place — the same object, so every account kept by identity (the
|
|
20
|
+
* live context, a frame's settlement, the prompt's receipt) settles on it — and the row records who rewrote it
|
|
21
|
+
* (`rewrittenBy`). A rewrite that changes a pinned part, or of a row whose content another reader holds by its exact text
|
|
22
|
+
* (a row the engine composed its frames into, an attachment's row), is not kept: the row is kept as made, and the leg's
|
|
23
|
+
* report sink says so (the reference's form: `appendCoreOf` (cli309.js:296238));
|
|
24
|
+
* - `{ deny: <reason> }` — only before `next`, only of an extension's own note: the note is not kept.
|
|
25
|
+
* The answer is the row as kept: what `next` answered, or a copy of it. Anything else is a violation (the reference's
|
|
26
|
+
* sentences: `Nu` (cli309.js:255554)). A handler may not change `message.role`, nor the members that name the row.
|
|
27
|
+
*
|
|
28
|
+
* A failure skips the handler (the table's column): before `next`, what is below it runs in its place, so the row is kept as
|
|
29
|
+
* made; after it, the row as kept stands. No row is dropped and none is kept twice: an engine row cannot be refused, an
|
|
30
|
+
* extension's own note only by a deny before `next` (a note whose handler failed is kept — the reference refuses it:
|
|
31
|
+
* `ee` (cli309.js:256939)). An engine fault of the dispatch keeps the row as made and is said on the report sink.
|
|
32
|
+
*
|
|
33
|
+
* `$.session.append({ message: { role: "user", content }, agentId? })` is the event called ({@link createSessionAppendEntry}):
|
|
34
|
+
* the leg's harness takes the note through its own port, the seat raises it here under the caller's frames and origin, and
|
|
35
|
+
* the call answers `{ message }` (the note as admitted) or `{ deny: <reason> }` (returned, not thrown): the note is in the
|
|
36
|
+
* conversation the leg goes on with — stored by the port (`AgentHarness.appendMessage`), or carried by a durable park's row
|
|
37
|
+
* (`heldRows`); once the park is taken, or may have been, the call throws `$.session.append: refused: …`.
|
|
38
|
+
*/
|
|
39
|
+
import type { AgentMessage, RowAdmission, RowRaising } from "../../internal/harness-types.js";
|
|
40
|
+
import type { AgentHarness } from "../../internal/harness.js";
|
|
41
|
+
import { type FrameSettlement } from "../frame-settlement.js";
|
|
42
|
+
import type { HookInvocationIdentity } from "../hooks.js";
|
|
43
|
+
import type { ModBottomContext, ModCallEntry } from "./kernel/index.js";
|
|
44
|
+
import { type LegModBus } from "./stations.js";
|
|
45
|
+
/** Where a row comes in: read off the row ({@link doorOf}); an extension's own note is `note`. The doors the leg's commit
|
|
46
|
+
* points produce — a compaction's summary is kept as its own entry, not a conversation row, and the engine writes no
|
|
47
|
+
* command row. */
|
|
48
|
+
export declare const SESSION_APPEND_DOORS: readonly ["prompt", "note", "delivery", "attachment", "response", "tool-result"];
|
|
49
|
+
export type SessionAppendDoor = (typeof SESSION_APPEND_DOORS)[number];
|
|
50
|
+
/** Who made a row: read off the row ({@link originOf}); an extension's own note is `plugin`. */
|
|
51
|
+
export declare const SESSION_APPEND_ORIGIN_KINDS: readonly ["host", "engine", "model", "tool", "plugin"];
|
|
52
|
+
export type SessionAppendOrigin = {
|
|
53
|
+
readonly kind: "host";
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "engine";
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: "model";
|
|
58
|
+
readonly model: string;
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: "tool";
|
|
61
|
+
readonly tool: string;
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "plugin";
|
|
64
|
+
readonly name: string;
|
|
65
|
+
};
|
|
66
|
+
/** A row's door, from its typed facts: a person's (or the host's) input is a `prompt`; what the engine adds for the model to
|
|
67
|
+
* read is a `note` (a user-lane note, or a row of its own kind), a `delivery` (a frame with its delivery key) or an
|
|
68
|
+
* `attachment`; the model's turn is a `response`, a tool's answer a `tool-result`. */
|
|
69
|
+
export declare function doorOf(row: AgentMessage): SessionAppendDoor;
|
|
70
|
+
/** A row's maker, from its typed facts: the model, the tool that answered, the host (a prompt, an attachment the host
|
|
71
|
+
* declared), else the engine. */
|
|
72
|
+
export declare function originOf(row: AgentMessage): SessionAppendOrigin;
|
|
73
|
+
/** What the leg binds the seat to once its bus is admitted. */
|
|
74
|
+
export interface RowSeatBinding {
|
|
75
|
+
readonly bus: LegModBus;
|
|
76
|
+
readonly identity: HookInvocationIdentity | undefined;
|
|
77
|
+
/** The leg's report sink (handler failures and the seat's own disclosures). */
|
|
78
|
+
readonly report: (err: Error) => void;
|
|
79
|
+
/** The leg's settlement seam: a tool result an extension rewrote is a host-side decision of what the model reads
|
|
80
|
+
* (`noteHostRewrite`), so a frame the rewrite took out is withheld by the host side, never owed again. */
|
|
81
|
+
readonly frameSettlement?: FrameSettlement;
|
|
82
|
+
}
|
|
83
|
+
/** What became of an extension's own note: kept (the answer its call returns), refused by a deny, or cancelled with its call. */
|
|
84
|
+
export type RaisedRowOutcome = {
|
|
85
|
+
readonly kind: "kept";
|
|
86
|
+
readonly answer: object;
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: "denied";
|
|
89
|
+
readonly reason: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: "cancelled";
|
|
92
|
+
};
|
|
93
|
+
/** The leg's one admission seat. */
|
|
94
|
+
export interface RowSeat {
|
|
95
|
+
/** What every writer calls at a row's first commit point (`AgentHarnessOptions.admitRows`). */
|
|
96
|
+
readonly admitRows: RowAdmission;
|
|
97
|
+
/** Bind the leg's bus. Until then every row passes as made. */
|
|
98
|
+
bind(binding: RowSeatBinding): void;
|
|
99
|
+
/** The token an extension's own note is handed to the harness with: its dispatch runs under `ctx` (the `$` call's frames,
|
|
100
|
+
* origin and signal). Known by identity; a token this seat did not mint is no raising. */
|
|
101
|
+
raise(ctx: ModBottomContext): RowRaising;
|
|
102
|
+
/** What became of the note a token was handed with — once the seat has admitted it. */
|
|
103
|
+
outcomeOf(raising: RowRaising): RaisedRowOutcome | undefined;
|
|
104
|
+
}
|
|
105
|
+
/** A leg's admission seat (see the module header). */
|
|
106
|
+
export declare function createRowSeat(): RowSeat;
|
|
107
|
+
/** What the host entry reaches: the leg's seat, its harness's port, the leg's `agentId` (a delegated leg's), its clock. */
|
|
108
|
+
export interface SessionAppendEntryInput {
|
|
109
|
+
readonly seat: RowSeat;
|
|
110
|
+
readonly harness: Pick<AgentHarness, "appendMessage">;
|
|
111
|
+
readonly agentId: string | undefined;
|
|
112
|
+
readonly now: () => number;
|
|
113
|
+
}
|
|
114
|
+
/** `$.session.append`'s host entry: an extension's own note, through the harness's port and this station (the module header). */
|
|
115
|
+
export declare function createSessionAppendEntry(input: SessionAppendEntryInput): ModCallEntry;
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { noteHostRewrite } from "../frame-settlement.js";
|
|
2
|
+
import { describeThrown } from "../tool-policy.js";
|
|
3
|
+
import { extensionWords } from "../untrusted-egress.js";
|
|
4
|
+
import { isPlainRecord } from "./kernel/receive.js";
|
|
5
|
+
import { NEXT_IN_FLIGHT, receiveEvent, sameModData } from "./kernel/site-rules.js";
|
|
6
|
+
import { classicEventBase, seatHears } from "./stations.js";
|
|
7
|
+
export const SESSION_APPEND_DOORS = Object.freeze(["prompt", "note", "delivery", "attachment", "response", "tool-result"]);
|
|
8
|
+
export const SESSION_APPEND_ORIGIN_KINDS = Object.freeze(["host", "engine", "model", "tool", "plugin"]);
|
|
9
|
+
export function doorOf(row) {
|
|
10
|
+
switch (row.role) {
|
|
11
|
+
case "assistant":
|
|
12
|
+
return "response";
|
|
13
|
+
case "toolResult":
|
|
14
|
+
return "tool-result";
|
|
15
|
+
case "user":
|
|
16
|
+
if (row.attachment !== undefined)
|
|
17
|
+
return "attachment";
|
|
18
|
+
if (row.engineNoteKey !== undefined)
|
|
19
|
+
return "delivery";
|
|
20
|
+
return row.provenance === "engine-note" || row.engineMinted === true ? "note" : "prompt";
|
|
21
|
+
default:
|
|
22
|
+
return "note";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const HOST = Object.freeze({ kind: "host" });
|
|
26
|
+
const ENGINE = Object.freeze({ kind: "engine" });
|
|
27
|
+
export function originOf(row) {
|
|
28
|
+
switch (row.role) {
|
|
29
|
+
case "assistant":
|
|
30
|
+
return Object.freeze({ kind: "model", model: row.model });
|
|
31
|
+
case "toolResult":
|
|
32
|
+
return Object.freeze({ kind: "tool", tool: row.toolName });
|
|
33
|
+
case "user":
|
|
34
|
+
return doorOf(row) === "prompt" || (row.attachment !== undefined && row.attachment.origin === undefined) ? HOST : ENGINE;
|
|
35
|
+
default:
|
|
36
|
+
return ENGINE;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function viewOf(row) {
|
|
40
|
+
switch (row.role) {
|
|
41
|
+
case "user":
|
|
42
|
+
case "assistant":
|
|
43
|
+
return { role: row.role, content: row.content };
|
|
44
|
+
case "toolResult":
|
|
45
|
+
return { role: row.role, toolCallId: row.toolCallId, toolName: row.toolName, content: row.content, isError: row.isError };
|
|
46
|
+
case "custom":
|
|
47
|
+
return { role: row.role, customType: row.customType, content: row.content };
|
|
48
|
+
default:
|
|
49
|
+
return { role: row.role };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const NAMING_MEMBERS = ["role", "toolCallId", "toolName", "customType"];
|
|
53
|
+
function contentHeldWhy(row) {
|
|
54
|
+
if (row.role === "user") {
|
|
55
|
+
if (row.attachment !== undefined)
|
|
56
|
+
return "its attachment record indexes its content";
|
|
57
|
+
if (row.enginePrefixChars !== undefined || row.engineSegments !== undefined || row.engineMinted === true)
|
|
58
|
+
return "the engine's frames in it are read by their exact text";
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const PINNED_BLOCKS = "its blocks other than text are pinned (the same blocks, in the same order)";
|
|
63
|
+
function rewrittenContent(original, handed) {
|
|
64
|
+
if (typeof original === "string") {
|
|
65
|
+
if (typeof handed !== "string")
|
|
66
|
+
return { why: "its content is a string, and a rewrite keeps the content's form" };
|
|
67
|
+
return handed.trim() === "" ? { why: "its text is blank" } : { content: handed };
|
|
68
|
+
}
|
|
69
|
+
if (!Array.isArray(handed) || handed.length === 0)
|
|
70
|
+
return { why: "its content is a list of blocks, and a rewrite keeps the content's form" };
|
|
71
|
+
const blocks = Array.isArray(original) ? original : [];
|
|
72
|
+
const others = blocks.filter((b) => b.type !== "text");
|
|
73
|
+
const texts = blocks.filter((b) => b.type === "text");
|
|
74
|
+
const out = [];
|
|
75
|
+
let other = 0;
|
|
76
|
+
let text = 0;
|
|
77
|
+
const items = handed;
|
|
78
|
+
for (const b of items) {
|
|
79
|
+
if (!isPlainRecord(b))
|
|
80
|
+
return { why: "its content is a list of blocks, and a rewrite keeps the content's form" };
|
|
81
|
+
if (b["type"] === "text") {
|
|
82
|
+
const was = texts[text++];
|
|
83
|
+
const t = b["text"];
|
|
84
|
+
if (was !== undefined && was["text"] === t)
|
|
85
|
+
out.push(was);
|
|
86
|
+
else if (typeof t === "string" && t.trim() !== "")
|
|
87
|
+
out.push({ type: "text", text: t });
|
|
88
|
+
else
|
|
89
|
+
return { why: "a text block's text is blank" };
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const was = others[other++];
|
|
93
|
+
if (was === undefined || !sameModData(was, b))
|
|
94
|
+
return { why: PINNED_BLOCKS };
|
|
95
|
+
out.push(was);
|
|
96
|
+
}
|
|
97
|
+
return other === others.length ? { content: out } : { why: PINNED_BLOCKS };
|
|
98
|
+
}
|
|
99
|
+
function rewrite(row, view, handed, by) {
|
|
100
|
+
const held = contentHeldWhy(row);
|
|
101
|
+
if (held !== undefined)
|
|
102
|
+
return held;
|
|
103
|
+
for (const k of new Set([...Object.keys(view), ...Object.keys(handed)])) {
|
|
104
|
+
if (k !== "content" && !sameModData(view[k], handed[k]))
|
|
105
|
+
return Object.hasOwn(view, k) ? `its ${k} is pinned` : `a row has no ${k} to set`;
|
|
106
|
+
}
|
|
107
|
+
if (!Object.hasOwn(view, "content"))
|
|
108
|
+
return "it has no content to rewrite";
|
|
109
|
+
const next = rewrittenContent(view["content"], handed["content"]);
|
|
110
|
+
if ("why" in next)
|
|
111
|
+
return next.why;
|
|
112
|
+
const target = row;
|
|
113
|
+
target.content = next.content;
|
|
114
|
+
target.rewrittenBy = Object.freeze([...by]);
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
function keptAnswer(row) {
|
|
118
|
+
const received = receiveEvent({ message: viewOf(row) });
|
|
119
|
+
if ("refusal" in received)
|
|
120
|
+
throw new TypeError(`session.append: the kept row cannot be handed up: ${received.refusal}`);
|
|
121
|
+
return received.payload;
|
|
122
|
+
}
|
|
123
|
+
const isDeny = (a) => isPlainRecord(a) && Object.hasOwn(a, "deny");
|
|
124
|
+
function keepAsMade(row, raised) {
|
|
125
|
+
if (raised !== undefined)
|
|
126
|
+
raised.outcome = { kind: "kept", answer: keptAnswer(row) };
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
export function createRowSeat() {
|
|
130
|
+
let bound;
|
|
131
|
+
const raisings = new WeakMap();
|
|
132
|
+
const admitOne = async (row, raised) => {
|
|
133
|
+
const keep = () => keepAsMade(row, raised);
|
|
134
|
+
const binding = bound;
|
|
135
|
+
if (!seatHears(binding, "session.append"))
|
|
136
|
+
return keep();
|
|
137
|
+
const door = raised !== undefined ? "note" : doorOf(row);
|
|
138
|
+
try {
|
|
139
|
+
const view = viewOf(row);
|
|
140
|
+
const origin = raised !== undefined ? Object.freeze({ kind: "plugin", name: raised.ctx.origin.plugin }) : originOf(row);
|
|
141
|
+
const e = { ...classicEventBase(binding.identity), door, origin, message: view };
|
|
142
|
+
const handOns = [];
|
|
143
|
+
let kept;
|
|
144
|
+
const checkHandOn = (payload, by) => {
|
|
145
|
+
const message = payload["message"];
|
|
146
|
+
if (!isPlainRecord(message))
|
|
147
|
+
return "next() handed on a message that is not a row";
|
|
148
|
+
const changed = NAMING_MEMBERS.find((k) => !sameModData(view[k], message[k]));
|
|
149
|
+
if (changed !== undefined)
|
|
150
|
+
return `a changed message.${changed}`;
|
|
151
|
+
const content = message["content"];
|
|
152
|
+
if (Object.hasOwn(view, "content") && typeof content !== "string" && !(Array.isArray(content) && content.every((b) => isPlainRecord(b) && typeof b["type"] === "string"))) {
|
|
153
|
+
return "next() handed on a content that is neither a string nor a list of blocks";
|
|
154
|
+
}
|
|
155
|
+
handOns.push({ by: by.plugin, message });
|
|
156
|
+
return undefined;
|
|
157
|
+
};
|
|
158
|
+
const bottom = (handed) => {
|
|
159
|
+
if (kept !== undefined)
|
|
160
|
+
return kept;
|
|
161
|
+
const message = handed["message"];
|
|
162
|
+
if (isPlainRecord(message) && !sameModData(view, message)) {
|
|
163
|
+
const by = [];
|
|
164
|
+
let before = view;
|
|
165
|
+
for (const h of handOns) {
|
|
166
|
+
if (!sameModData(before, h.message) && !by.includes(h.by))
|
|
167
|
+
by.push(h.by);
|
|
168
|
+
before = h.message;
|
|
169
|
+
}
|
|
170
|
+
const why = rewrite(row, view, message, by);
|
|
171
|
+
if (why === undefined && row.role === "toolResult" && binding.frameSettlement !== undefined)
|
|
172
|
+
noteHostRewrite(binding.frameSettlement, row.toolCallId);
|
|
173
|
+
if (why !== undefined) {
|
|
174
|
+
binding.report(new Error(`session.append: a rewrite of a ${door} row is not kept (${why}); the row is kept as made — rewritten by ${by.map((b) => `"${extensionWords(b, 80)}"`).join(", ") || "an extension"}`));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
kept = keptAnswer(row);
|
|
178
|
+
return kept;
|
|
179
|
+
};
|
|
180
|
+
const checkAnswer = (a, _e, _by, below) => {
|
|
181
|
+
if (kept !== undefined && a === kept)
|
|
182
|
+
return undefined;
|
|
183
|
+
if (isDeny(a)) {
|
|
184
|
+
const reason = a["deny"];
|
|
185
|
+
if (Object.keys(a).length !== 1)
|
|
186
|
+
return "session.append takes next(e), the row next answered, or { deny: <reason> }";
|
|
187
|
+
if (below.some((b) => !isDeny(b)))
|
|
188
|
+
return "a deny after next kept the row (refuse in place of next)";
|
|
189
|
+
if (below.some((b) => isDeny(b) && b["deny"] === reason))
|
|
190
|
+
return undefined;
|
|
191
|
+
if (raised === undefined)
|
|
192
|
+
return "a deny of a row the engine adds (only an extension's own note is refused)";
|
|
193
|
+
return typeof reason === "string" && reason.trim() !== "" ? undefined : "a deny with no reason (a non-empty string)";
|
|
194
|
+
}
|
|
195
|
+
if (below.length === 0)
|
|
196
|
+
return "an answer without next (the row is kept; next(e) keeps it)";
|
|
197
|
+
let last;
|
|
198
|
+
for (let i = below.length - 1; i >= 0 && last === undefined; i--)
|
|
199
|
+
if (!isDeny(below[i]))
|
|
200
|
+
last = below[i];
|
|
201
|
+
if (last === undefined)
|
|
202
|
+
return "a row after next refused it (nothing was kept)";
|
|
203
|
+
if (last === NEXT_IN_FLIGHT)
|
|
204
|
+
return "a row while its next(e) still runs (the answer is the row as kept)";
|
|
205
|
+
return sameModData(a, last) ? undefined : "a row other than what next answered (the answer is the row as kept)";
|
|
206
|
+
};
|
|
207
|
+
let outcome;
|
|
208
|
+
try {
|
|
209
|
+
outcome = await binding.bus.dispatch("session.append", e, {
|
|
210
|
+
bottom,
|
|
211
|
+
checkAnswer,
|
|
212
|
+
checkHandOn,
|
|
213
|
+
...(raised !== undefined ? { frames: raised.ctx.frames, origin: raised.ctx.origin, signal: raised.ctx.signal } : {}),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
binding.report(new Error(`session.append: the ${door} row is kept as made — the dispatch could not be raised (${describeThrown(err)})`));
|
|
218
|
+
return keep();
|
|
219
|
+
}
|
|
220
|
+
if (kept !== undefined) {
|
|
221
|
+
if (raised !== undefined)
|
|
222
|
+
raised.outcome = { kind: "kept", answer: kept };
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
if (raised !== undefined && outcome.kind === "answered" && isDeny(outcome.answer)) {
|
|
226
|
+
raised.outcome = { kind: "denied", reason: String(outcome.answer["deny"]) };
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if (raised !== undefined && outcome.kind === "aborted") {
|
|
230
|
+
raised.outcome = { kind: "cancelled" };
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
if (outcome.kind === "failed")
|
|
234
|
+
binding.report(new Error(`session.append: the ${door} row is kept as made — ${outcome.reason}`));
|
|
235
|
+
return keep();
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
binding.report(new Error(`session.append: the ${door} row is kept as made — ${describeThrown(err)}`));
|
|
239
|
+
return keep();
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const admitAll = async (rows, raised) => {
|
|
243
|
+
const out = [];
|
|
244
|
+
for (const row of rows)
|
|
245
|
+
if (await admitOne(row, raised))
|
|
246
|
+
out.push(row);
|
|
247
|
+
return out;
|
|
248
|
+
};
|
|
249
|
+
return {
|
|
250
|
+
admitRows: (rows, raising) => {
|
|
251
|
+
const raised = raising !== undefined ? raisings.get(raising) : undefined;
|
|
252
|
+
if (seatHears(bound, "session.append"))
|
|
253
|
+
return admitAll(rows, raised);
|
|
254
|
+
return new Promise((resolve) => resolve(rows.filter((row) => keepAsMade(row, raised))));
|
|
255
|
+
},
|
|
256
|
+
bind: (binding) => {
|
|
257
|
+
bound = binding;
|
|
258
|
+
},
|
|
259
|
+
raise: (ctx) => {
|
|
260
|
+
const token = Object.freeze({ door: "note" });
|
|
261
|
+
raisings.set(token, { ctx });
|
|
262
|
+
return token;
|
|
263
|
+
},
|
|
264
|
+
outcomeOf: (raising) => raisings.get(raising)?.outcome,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function noteContentOf(args, agentId, by) {
|
|
268
|
+
const refuse = (why) => new TypeError(`${by}: $.session.append: refused: ${why}`);
|
|
269
|
+
const extra = Object.keys(args).find((k) => k !== "message" && k !== "agentId");
|
|
270
|
+
if (extra !== undefined)
|
|
271
|
+
throw refuse(`takes { message, agentId? }; "${extensionWords(extra, 40)}" is not one`);
|
|
272
|
+
if (Object.hasOwn(args, "agentId") && (agentId === undefined || args["agentId"] !== agentId))
|
|
273
|
+
throw refuse("agentId names a leg other than this one");
|
|
274
|
+
const message = args["message"];
|
|
275
|
+
if (!isPlainRecord(message))
|
|
276
|
+
throw refuse("takes message, { role: \"user\", content }");
|
|
277
|
+
if (message["role"] === "system")
|
|
278
|
+
throw refuse("a system row (the engine keeps no row outside the conversation the model reads)");
|
|
279
|
+
if (message["role"] !== "user" || Object.keys(message).some((k) => k !== "role" && k !== "content"))
|
|
280
|
+
throw refuse("takes message, { role: \"user\", content }");
|
|
281
|
+
const content = message["content"];
|
|
282
|
+
if (typeof content === "string") {
|
|
283
|
+
if (content.trim() === "")
|
|
284
|
+
throw refuse("the note's text is blank");
|
|
285
|
+
return content;
|
|
286
|
+
}
|
|
287
|
+
if (!Array.isArray(content) || content.length === 0)
|
|
288
|
+
throw refuse("content is a string or a non-empty list of text blocks");
|
|
289
|
+
return content.map((b) => {
|
|
290
|
+
if (!isPlainRecord(b) || b["type"] !== "text" || typeof b["text"] !== "string" || Object.keys(b).some((k) => k !== "type" && k !== "text"))
|
|
291
|
+
throw refuse("each block is { type: \"text\", text }");
|
|
292
|
+
if (b["text"].trim() === "")
|
|
293
|
+
throw refuse("a block's text is blank");
|
|
294
|
+
return { type: "text", text: b["text"] };
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
export function createSessionAppendEntry(input) {
|
|
298
|
+
return async (args, ctx) => {
|
|
299
|
+
const by = ctx.origin.plugin;
|
|
300
|
+
const content = noteContentOf(args, input.agentId, by);
|
|
301
|
+
const row = { role: "user", content, timestamp: input.now(), provenance: "engine-note" };
|
|
302
|
+
const raising = input.seat.raise(ctx);
|
|
303
|
+
await input.harness.appendMessage(row, raising);
|
|
304
|
+
const outcome = input.seat.outcomeOf(raising);
|
|
305
|
+
if (outcome === undefined)
|
|
306
|
+
throw new Error(`${by}: $.session.append: the note was not admitted`);
|
|
307
|
+
if (outcome.kind === "cancelled")
|
|
308
|
+
throw new Error(`${by}: $.session.append: aborted`);
|
|
309
|
+
return outcome.kind === "denied" ? Object.freeze({ deny: outcome.reason }) : outcome.answer;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type MaybeCompactOptions, type maybeCompact } from "../auto-compaction.js";
|
|
2
|
+
import type { HookInvocationIdentity } from "../hooks.js";
|
|
3
|
+
import type { CompactOutcome, ExtensionRequester } from "../task-event.js";
|
|
4
|
+
import { type ModBottomContext, type ModCallEntry } from "./kernel/index.js";
|
|
5
|
+
import { type LegModBus } from "./stations.js";
|
|
6
|
+
type CompactResult = Awaited<ReturnType<typeof maybeCompact>>;
|
|
7
|
+
/** What a pass hands the station: the instructions its manual request named, and — for `$.session.compact` — the call's
|
|
8
|
+
* context (the pass is raised under the caller's frames and origin, so the caller's own handlers stay out of it). */
|
|
9
|
+
export interface CompactPass {
|
|
10
|
+
readonly instructions?: string;
|
|
11
|
+
readonly call?: ModBottomContext;
|
|
12
|
+
}
|
|
13
|
+
/** The boundary's in-place pass, as `$.session.compact` reaches it: run one manual pass now, asked for by `requestedBy`. */
|
|
14
|
+
export type CompactWindowPass = (request: {
|
|
15
|
+
readonly instructions?: string;
|
|
16
|
+
readonly requestedBy: ExtensionRequester;
|
|
17
|
+
readonly call: ModBottomContext;
|
|
18
|
+
}) => Promise<CompactOutcome>;
|
|
19
|
+
/** What the leg binds the station to once its bus is admitted. */
|
|
20
|
+
export interface CompactStationBinding {
|
|
21
|
+
readonly bus: LegModBus;
|
|
22
|
+
readonly identity: HookInvocationIdentity | undefined;
|
|
23
|
+
readonly report: (err: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
/** The leg's `session.compact` station (see the module header). */
|
|
26
|
+
export interface CompactStation {
|
|
27
|
+
bind(binding: CompactStationBinding): void;
|
|
28
|
+
/** One compaction pass through the station: `run` is the lane's `maybeCompact`, handed the options with the station's
|
|
29
|
+
* seats in place (no handler ⇒ the options as they came). */
|
|
30
|
+
compact(opts: MaybeCompactOptions, run: (opts: MaybeCompactOptions) => Promise<CompactResult>, pass?: CompactPass): Promise<CompactResult>;
|
|
31
|
+
/** Run `raise` (the boundary's `turn.complete`) with `$.session.compact` open: a direct call from one of its handlers runs
|
|
32
|
+
* `pass` in place, and `window` answers once that pass has ended too. */
|
|
33
|
+
window<T>(pass: CompactWindowPass, raise: () => Promise<T>): Promise<T>;
|
|
34
|
+
/** `$.session.compact`'s seat: the in-place pass, or the refusal. */
|
|
35
|
+
call(instructions: string | undefined, ctx: ModBottomContext): Promise<CompactOutcome>;
|
|
36
|
+
}
|
|
37
|
+
/** The leg's `session.compact` station. */
|
|
38
|
+
export declare function createCompactStation(): CompactStation;
|
|
39
|
+
/** The extension the last `$.session.compact` request among `waiters` came from (requests coalesce onto one pass), as the
|
|
40
|
+
* member the pass's ending frame spreads; empty when no extension asked. */
|
|
41
|
+
export declare function requesterOf(waiters: ReadonlyArray<{
|
|
42
|
+
readonly requestedBy?: ExtensionRequester;
|
|
43
|
+
}>): {
|
|
44
|
+
readonly requestedBy?: ExtensionRequester;
|
|
45
|
+
};
|
|
46
|
+
/** `$.session.compact`'s host entry: `{ instructions? }`, a manual pass at the turn boundary in place (the module header). */
|
|
47
|
+
export declare function createSessionCompactEntry(station: Pick<CompactStation, "call">): ModCallEntry;
|
|
48
|
+
export {};
|