@sema-agent/core 7.55.0 → 7.57.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 +1054 -0
- package/LICENSE +1 -1
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/cc-peer-directory.js +1 -0
- package/dist/agents/child-model-seat.d.ts +0 -11
- package/dist/agents/child-model-seat.js +0 -3
- package/dist/agents/list-agents-tool.d.ts +3 -1
- package/dist/agents/list-agents-tool.js +7 -7
- package/dist/agents/org-delivery-gate.js +3 -4
- package/dist/agents/peer-directory.d.ts +22 -4
- package/dist/agents/peer-directory.js +24 -2
- package/dist/agents/peer-held-queue.d.ts +69 -49
- package/dist/agents/peer-held-queue.js +255 -106
- package/dist/agents/peer-session-drain.js +65 -45
- package/dist/agents/repair-loop.js +2 -2
- package/dist/agents/send-message-tool.js +7 -6
- package/dist/agents/subagent.d.ts +6 -4
- package/dist/agents/subagent.js +72 -68
- package/dist/agents/tool-filter.d.ts +7 -5
- package/dist/agents/tool-filter.js +12 -9
- package/dist/agents/verify.d.ts +3 -2
- package/dist/agents/verify.js +3 -3
- package/dist/brain/anthropic.js +45 -80
- package/dist/brain/media-degrade.d.ts +18 -7
- package/dist/brain/media-degrade.js +13 -2
- package/dist/brain/model-capability.d.ts +37 -0
- package/dist/brain/model-capability.js +34 -0
- package/dist/brain/model-presets.d.ts +2 -8
- package/dist/brain/model-presets.js +1 -6
- package/dist/brain/open-responses.js +23 -34
- package/dist/brain/openai.js +25 -96
- package/dist/brain/provider-dialect.d.ts +3 -2
- package/dist/brain/provider-dialect.js +2 -2
- package/dist/brain/reasoning-request.d.ts +96 -0
- package/dist/brain/reasoning-request.js +174 -0
- package/dist/brain/reasoning.d.ts +11 -11
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/request-params.d.ts +13 -4
- package/dist/brain/request-params.js +21 -5
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/stream-engine.d.ts +9 -0
- package/dist/brain/stream-engine.js +24 -10
- package/dist/brain/stream-shared.d.ts +5 -4
- package/dist/brain/stream-shared.js +4 -4
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +19 -13
- package/dist/core/agent-definition.d.ts +10 -0
- package/dist/core/allow-entry.d.ts +23 -23
- package/dist/core/allow-entry.js +42 -46
- package/dist/core/allow-rule-shadow.d.ts +3 -3
- package/dist/core/approval-object.d.ts +21 -5
- package/dist/core/approval-object.js +44 -17
- package/dist/core/ask-origin.d.ts +66 -20
- package/dist/core/ask-origin.js +63 -23
- package/dist/core/ask-question.d.ts +51 -8
- package/dist/core/ask-question.js +3 -4
- package/dist/core/ask-unresolvable-notice.d.ts +8 -3
- package/dist/core/ask-unresolvable-notice.js +16 -2
- package/dist/core/auto-compaction.d.ts +71 -6
- package/dist/core/auto-compaction.js +42 -26
- package/dist/core/background-agent-store.d.ts +6 -2
- package/dist/core/background-agent-store.js +1 -1
- package/dist/core/checkpoint-generation.d.ts +53 -0
- package/dist/core/checkpoint-generation.js +35 -0
- package/dist/core/checkpoint-queries.d.ts +180 -0
- package/dist/core/checkpoint-queries.js +272 -0
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +6 -0
- package/dist/core/checkpoint-store.d.ts +105 -53
- package/dist/core/checkpoint-store.js +43 -20
- package/dist/core/cross-boundary-taint.d.ts +6 -5
- package/dist/core/cross-boundary-taint.js +5 -5
- package/dist/core/decision-receipt.d.ts +37 -3
- package/dist/core/decision-receipt.js +17 -17
- package/dist/core/delegation-not-started.d.ts +6 -0
- package/dist/core/delegation-not-started.js +17 -0
- package/dist/core/engine-attestation.d.ts +93 -0
- package/dist/core/engine-attestation.js +70 -0
- package/dist/core/engine-capabilities.d.ts +4 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +32 -12
- package/dist/core/engine-notice.js +6 -0
- package/dist/core/file-history-store.d.ts +104 -22
- package/dist/core/file-history-store.js +37 -19
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +22 -10
- package/dist/core/gate-lanes.js +73 -65
- package/dist/core/gate-outcome.d.ts +26 -5
- package/dist/core/gate-outcome.js +26 -0
- package/dist/core/governance-codes.d.ts +5 -1
- package/dist/core/governance-codes.js +6 -0
- package/dist/core/hooks.d.ts +19 -18
- package/dist/core/hooks.js +3 -1
- package/dist/core/host-floor.d.ts +128 -0
- package/dist/core/host-floor.js +206 -0
- package/dist/core/host-target.d.ts +38 -3
- package/dist/core/host-target.js +38 -5
- package/dist/core/mailbox-store.d.ts +62 -1
- package/dist/core/mailbox-store.js +59 -0
- package/dist/core/mcp-name-judge.d.ts +46 -0
- package/dist/core/mcp-name-judge.js +61 -0
- package/dist/core/mcp-probe.d.ts +1 -1
- package/dist/core/mcp-probe.js +2 -5
- package/dist/core/mcp.d.ts +5 -1
- package/dist/core/mcp.js +70 -64
- package/dist/core/memory-engine/consolidation-driver.js +4 -3
- package/dist/core/memory-engine/delegation-settlement.js +15 -24
- package/dist/core/memory-engine/distiller.js +26 -17
- package/dist/core/memory-engine/engine.js +4 -4
- package/dist/core/memory-engine/layout.d.ts +60 -8
- package/dist/core/memory-engine/layout.js +70 -8
- package/dist/core/model-seat.d.ts +10 -3
- package/dist/core/mods/classic-events.d.ts +67 -0
- package/dist/core/mods/classic-events.js +1 -0
- package/dist/core/mods/dollar.d.ts +13 -0
- package/dist/core/mods/extension-call.d.ts +31 -0
- package/dist/core/mods/extension-call.js +43 -0
- package/dist/core/mods/kernel/dispatch.d.ts +20 -3
- package/dist/core/mods/kernel/dispatch.js +140 -69
- package/dist/core/mods/kernel/events.d.ts +47 -11
- package/dist/core/mods/kernel/events.js +66 -42
- package/dist/core/mods/kernel/index.d.ts +4 -4
- package/dist/core/mods/kernel/index.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -5
- package/dist/core/mods/kernel/receive.js +290 -17
- package/dist/core/mods/kernel/registration.d.ts +33 -2
- package/dist/core/mods/kernel/registration.js +6 -7
- package/dist/core/mods/kernel/site-rules.d.ts +44 -16
- package/dist/core/mods/kernel/site-rules.js +24 -42
- package/dist/core/mods/spec-seats.d.ts +69 -0
- package/dist/core/mods/spec-seats.js +114 -0
- package/dist/core/mods/stations.d.ts +28 -8
- package/dist/core/mods/stations.js +29 -13
- package/dist/core/mods/tool-call.d.ts +79 -0
- package/dist/core/mods/tool-call.js +152 -0
- package/dist/core/namespaced-rule-name.d.ts +32 -38
- package/dist/core/namespaced-rule-name.js +29 -36
- package/dist/core/parent-spec-seat.d.ts +6 -1
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +3 -0
- package/dist/core/permission-rule-consent.d.ts +24 -3
- package/dist/core/permission-rule-consent.js +136 -41
- package/dist/core/permission-rule-model.d.ts +57 -5
- package/dist/core/permission-rule-model.js +90 -31
- package/dist/core/permission-rule-org.d.ts +6 -2
- package/dist/core/permission-rule-org.js +8 -4
- package/dist/core/permission-rule-provider.d.ts +5 -2
- package/dist/core/permission-rule-provider.js +41 -11
- package/dist/core/permission-rule-store.d.ts +3 -2
- package/dist/core/permission-rule-store.js +11 -2
- package/dist/core/permission-rule-sync.js +3 -2
- package/dist/core/permission-rule-syntax.d.ts +5 -4
- package/dist/core/permission-rule-syntax.js +2 -2
- package/dist/core/permission-rules.d.ts +4 -4
- package/dist/core/permission-rules.js +11 -20
- package/dist/core/persisted-rule-arms.d.ts +2 -2
- package/dist/core/persisted-rule-arms.js +10 -12
- package/dist/core/principal-name.d.ts +20 -0
- package/dist/core/principal-name.js +22 -0
- package/dist/core/prompt-section-seat.js +4 -6
- package/dist/core/protocol-http-auth.d.ts +40 -5
- package/dist/core/protocol-http-auth.js +168 -4
- package/dist/core/protocol-naming.d.ts +20 -0
- package/dist/core/protocol-naming.js +20 -3
- package/dist/core/read-only-shell.d.ts +20 -5
- package/dist/core/read-only-shell.js +29 -14
- package/dist/core/remote-env.d.ts +37 -1
- package/dist/core/remote-env.js +11 -0
- package/dist/core/resume-startup-cause.d.ts +24 -2
- package/dist/core/resume-startup-cause.js +20 -1
- package/dist/core/retired-keys.d.ts +16 -0
- package/dist/core/retired-keys.js +16 -4
- package/dist/core/rewrite-rejudge.d.ts +60 -0
- package/dist/core/rewrite-rejudge.js +36 -0
- package/dist/core/roles.d.ts +28 -1
- package/dist/core/roles.js +81 -26
- package/dist/core/rule-lane-reads.d.ts +20 -15
- package/dist/core/rule-lane-reads.js +45 -17
- package/dist/core/rule-owner.d.ts +3 -3
- package/dist/core/rule-owner.js +3 -2
- package/dist/core/runner/announce-once-ledger.d.ts +14 -0
- package/dist/core/runner/announce-once-ledger.js +5 -0
- package/dist/core/runner/assemble-result.d.ts +1 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/caller-roster.d.ts +16 -4
- package/dist/core/runner/caller-roster.js +33 -6
- package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
- package/dist/core/runner/capability-withheld-seat.js +24 -0
- package/dist/core/runner/classifier-ladder.d.ts +7 -9
- package/dist/core/runner/classifier-ladder.js +3 -3
- package/dist/core/runner/compact-session.d.ts +10 -0
- package/dist/core/runner/compact-session.js +202 -0
- package/dist/core/runner/compaction-call-options.d.ts +2 -2
- package/dist/core/runner/compaction-seams.d.ts +21 -1
- package/dist/core/runner/compaction-seams.js +11 -8
- package/dist/core/runner/construction-doors.js +3 -0
- package/dist/core/runner/contracts.d.ts +50 -40
- package/dist/core/runner/cross-boundary-lane.d.ts +17 -13
- package/dist/core/runner/cross-boundary-lane.js +40 -27
- package/dist/core/runner/denial-limit-arms.d.ts +2 -2
- package/dist/core/runner/denial-limit-arms.js +1 -1
- package/dist/core/runner/derived-route-fallback.d.ts +13 -0
- package/dist/core/runner/derived-route-fallback.js +6 -0
- package/dist/core/runner/env-capability-census.d.ts +3 -2
- package/dist/core/runner/env-capability-census.js +9 -3
- package/dist/core/runner/file-history-request.d.ts +18 -0
- package/dist/core/runner/file-history-request.js +21 -13
- package/dist/core/runner/file-history-restore.d.ts +45 -0
- package/dist/core/runner/file-history-restore.js +46 -0
- package/dist/core/runner/gate-exit.d.ts +3 -3
- package/dist/core/runner/gate-exit.js +4 -3
- package/dist/core/runner/image.d.ts +7 -17
- package/dist/core/runner/image.js +9 -60
- package/dist/core/runner/permission-rule-lanes.d.ts +11 -11
- package/dist/core/runner/permission-rule-lanes.js +39 -17
- package/dist/core/runner/person-path-rows.d.ts +12 -9
- package/dist/core/runner/person-path-rows.js +18 -7
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +2 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
- package/dist/core/runner/prepare-ask-lane.js +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +35 -38
- package/dist/core/runner/prepare-config-doors.js +46 -28
- package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
- package/dist/core/runner/prepare-defer-classify.js +7 -8
- package/dist/core/runner/prepare-file-history.d.ts +48 -8
- package/dist/core/runner/prepare-file-history.js +7 -39
- package/dist/core/runner/prepare-gate-stations.d.ts +1 -1
- package/dist/core/runner/prepare-gate-stations.js +10 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -9
- package/dist/core/runner/prepare-hands-readface.js +17 -14
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +5 -3
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +2 -0
- package/dist/core/runner/prepare-park-ask.js +7 -7
- package/dist/core/runner/prepare-policy-chain.d.ts +6 -3
- package/dist/core/runner/prepare-policy-chain.js +67 -76
- package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
- package/dist/core/runner/prepare-prompt-assembly.js +10 -8
- package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
- package/dist/core/runner/prepare-prompt-inputs.js +3 -5
- package/dist/core/runner/prepare-protocol-tools.d.ts +2 -0
- package/dist/core/runner/prepare-protocol-tools.js +3 -3
- package/dist/core/runner/prepare-safety-scan.d.ts +1 -1
- package/dist/core/runner/prepare-safety-scan.js +0 -17
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +5 -6
- package/dist/core/runner/prepare-task.d.ts +5 -2
- package/dist/core/runner/prepare-task.js +48 -43
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +20 -4
- package/dist/core/runner/prepare-tool-disclosure-mount.js +33 -23
- package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
- package/dist/core/runner/prepare-turn-wiring.js +2 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -2
- package/dist/core/runner/prepare-wiring-manifest.js +3 -3
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -12
- package/dist/core/runner/resume-checkpoint-screen.js +3 -0
- package/dist/core/runner/resume-claim.d.ts +4 -2
- package/dist/core/runner/resume-claim.js +15 -8
- package/dist/core/runner/retired-runner-deps.js +1 -0
- package/dist/core/runner/rewind-files.d.ts +12 -0
- package/dist/core/runner/rewind-files.js +90 -0
- package/dist/core/runner/run-attachment-seats.js +2 -1
- package/dist/core/runner/run-brain-sinks.d.ts +4 -1
- package/dist/core/runner/run-brain-sinks.js +4 -2
- package/dist/core/runner/run-harness-handlers.js +12 -4
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +40 -39
- package/dist/core/runner/run-notification-lane.d.ts +2 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -4
- package/dist/core/runner/run-settle-and-teardown.js +7 -12
- package/dist/core/runner/run-terminal-adoption.js +3 -4
- package/dist/core/runner/run-turn-boundary.js +4 -15
- package/dist/core/runner/runtask.d.ts +10 -0
- package/dist/core/runner/runtask.js +35 -42
- package/dist/core/runner/send-message-continuation.js +1 -1
- package/dist/core/runner/session-read-file-states.d.ts +15 -0
- package/dist/core/runner/session-read-file-states.js +28 -0
- package/dist/core/runner/session-rule-policy.js +4 -3
- package/dist/core/runner/session-verb-doors.d.ts +28 -0
- package/dist/core/runner/session-verb-doors.js +48 -0
- package/dist/core/runner/session-write-ledger.d.ts +30 -0
- package/dist/core/runner/session-write-ledger.js +101 -0
- package/dist/core/runner/shell-env-withheld.d.ts +33 -0
- package/dist/core/runner/shell-env-withheld.js +51 -0
- package/dist/core/runner/skills-seat.js +6 -2
- package/dist/core/runner/stream-settle-backstop.js +12 -15
- package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
- package/dist/core/runner/sub-agent-deny-lists.js +25 -17
- package/dist/core/runner/synthetic-tools.d.ts +6 -0
- package/dist/core/runner/synthetic-tools.js +4 -1
- package/dist/core/runner/teardown-bounded.d.ts +1 -0
- package/dist/core/runner/teardown-bounded.js +1 -0
- package/dist/core/runner/tool-disclosure.d.ts +10 -12
- package/dist/core/runner/tool-disclosure.js +1 -3
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-end-body.js +10 -9
- package/dist/core/runner/tool-not-executed.d.ts +5 -0
- package/dist/core/runner/tool-not-executed.js +11 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -0
- package/dist/core/runner/tool-occurrence.js +7 -0
- package/dist/core/runner/turn-attachments.d.ts +33 -15
- package/dist/core/runner/turn-attachments.js +62 -37
- package/dist/core/runner-deps.d.ts +7 -7
- package/dist/core/safety-axis-vocab.d.ts +6 -4
- package/dist/core/safety-axis-vocab.js +6 -5
- package/dist/core/safety-merge-corpus.js +11 -3
- package/dist/core/secret-env.d.ts +30 -3
- package/dist/core/secret-env.js +47 -8
- package/dist/core/select-model.js +3 -3
- package/dist/core/session-policy-store.d.ts +32 -15
- package/dist/core/session-policy-store.js +156 -36
- package/dist/core/session-store.d.ts +29 -10
- package/dist/core/session-store.js +51 -19
- package/dist/core/session.d.ts +82 -16
- package/dist/core/session.js +53 -0
- package/dist/core/shell-read-silence.d.ts +11 -12
- package/dist/core/shell-read-silence.js +9 -5
- package/dist/core/shell-run-candidates.js +3 -1
- package/dist/core/shell-wrapper-projection.d.ts +1 -1
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/shell-wrapper-table.d.ts +14 -7
- package/dist/core/shell-wrapper-table.js +5 -4
- package/dist/core/side-query.js +10 -1
- package/dist/core/skill-grant.d.ts +7 -2
- package/dist/core/skill-grant.js +5 -0
- package/dist/core/skills-directory.js +6 -2
- package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +141 -2
- package/dist/core/store-contracts/file-history-store-contract.js +40 -1
- package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
- package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
- package/dist/core/store-contracts/peer-directory-contract.js +14 -2
- package/dist/core/store-contracts/session-repo-contract.js +51 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/session-store-contract.js +150 -14
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.js +3 -3
- package/dist/core/task-event.d.ts +32 -4
- package/dist/core/task-notification.d.ts +16 -12
- package/dist/core/task-registry-agent.d.ts +8 -4
- package/dist/core/task-registry-agent.js +14 -8
- package/dist/core/task-registry-shared.d.ts +35 -6
- package/dist/core/task-registry-shared.js +11 -0
- package/dist/core/task-registry.d.ts +10 -1
- package/dist/core/task-registry.js +12 -2
- package/dist/core/task-result.d.ts +18 -0
- package/dist/core/task-spec.d.ts +18 -13
- package/dist/core/tighten-task-spec.js +2 -1
- package/dist/core/tool-catalog-entries.d.ts +23 -0
- package/dist/core/tool-catalog-entries.js +14 -2
- package/dist/core/tool-check-reading.d.ts +11 -0
- package/dist/core/tool-check-reading.js +11 -6
- package/dist/core/tool-model-gate.d.ts +2 -2
- package/dist/core/tool-name-aliases.d.ts +48 -18
- package/dist/core/tool-name-aliases.js +36 -19
- package/dist/core/tool-name-readings.d.ts +6 -32
- package/dist/core/tool-name-readings.js +2 -9
- package/dist/core/tool-policy.d.ts +78 -204
- package/dist/core/tool-policy.js +152 -204
- package/dist/core/tool-result-store.js +3 -0
- package/dist/core/tool-roster.d.ts +14 -19
- package/dist/core/tool-roster.js +11 -44
- package/dist/core/tool-spec-members.js +7 -2
- package/dist/core/tool-spec.d.ts +19 -11
- package/dist/core/tools.js +49 -9
- package/dist/core/trace.d.ts +6 -3
- package/dist/core/trace.js +2 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +20 -0
- package/dist/core/untrusted-egress.js +77 -3
- package/dist/core/user-attachment.d.ts +8 -1
- package/dist/core/user-attachment.js +64 -4
- package/dist/core/wiring-manifest.d.ts +9 -0
- package/dist/core/wiring-manifest.js +1 -0
- package/dist/core/workflow-journal-store.js +1 -1
- package/dist/engine/compaction/compaction.js +3 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +7 -3
- package/dist/engine/execution-env/node-execution-env.js +11 -2
- package/dist/engine/harness/agent-harness.d.ts +32 -6
- package/dist/engine/harness/agent-harness.js +65 -9
- package/dist/engine/harness/types.d.ts +29 -2
- package/dist/engine/llm/types.d.ts +28 -11
- package/dist/engine/loop/agent-loop.d.ts +23 -4
- package/dist/engine/loop/agent-loop.js +42 -30
- package/dist/engine/loop/types.d.ts +16 -6
- package/dist/engine/session/memory-repo.d.ts +9 -2
- package/dist/engine/session/memory-repo.js +11 -1
- package/dist/engine/session/repo-utils.d.ts +6 -5
- package/dist/engine/session/repo-utils.js +14 -6
- package/dist/index.d.ts +34 -17
- package/dist/index.js +22 -11
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +2 -1
- package/dist/internal/harness.js +1 -0
- package/dist/internal/llm.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +6 -4
- package/dist/orchestration/run-workflow-tool.js +5 -3
- package/dist/orchestration/workflow.d.ts +3 -0
- package/dist/orchestration/workflow.js +36 -18
- package/dist/primitives/credential-ref.d.ts +89 -0
- package/dist/primitives/credential-ref.js +125 -0
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.js +1 -0
- package/dist/prompt-assembly/artifact.d.ts +2 -2
- package/dist/prompt-assembly/artifact.js +5 -3
- package/dist/prompt-assembly/assemble.d.ts +3 -2
- package/dist/prompt-assembly/assemble.js +1 -1
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
- package/dist/prompt-assembly/catalog/schema.js +34 -2
- package/dist/prompt-assembly/catalog/sections.js +0 -1
- package/dist/prompt-assembly/composer.d.ts +3 -1
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/event-registry.js +1 -0
- package/dist/prompt-assembly/overlay.js +3 -3
- package/dist/prompt-assembly/renderers.d.ts +1 -1
- package/dist/prompt-assembly/renderers.js +0 -3
- package/dist/prompt-assembly/role-base.d.ts +15 -0
- package/dist/prompt-assembly/role-base.js +9 -0
- package/dist/prompt-assembly/select.d.ts +39 -14
- package/dist/prompt-assembly/select.js +47 -16
- package/dist/prompt-assembly/sugar.d.ts +17 -11
- package/dist/prompt-assembly/sugar.js +8 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +37 -3
- package/dist/prompt-assembly/tool-catalog.js +114 -4
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
- package/dist/prompt-assembly/turn-snapshot.js +0 -3
- package/dist/prompt-assembly/types.d.ts +0 -7
- package/dist/scenarios/full-body.d.ts +11 -11
- package/dist/scenarios/full-body.js +4 -3
- package/dist/shell/lex.js +10 -1
- package/dist/stores/file/adoption/adopt.js +4 -3
- package/dist/stores/file/adoption/marker.js +3 -2
- package/dist/stores/file/checkpoint-store.d.ts +21 -4
- package/dist/stores/file/checkpoint-store.js +38 -7
- package/dist/stores/file/file-history-store.js +18 -11
- package/dist/stores/file/index.js +2 -1
- package/dist/stores/file/mailbox-store.d.ts +2 -1
- package/dist/stores/file/mailbox-store.js +26 -1
- package/dist/stores/file/permission-rule-adopt.js +4 -3
- package/dist/stores/file/permission-rule-store.js +11 -5
- package/dist/stores/file/session-store.d.ts +29 -6
- package/dist/stores/file/session-store.js +42 -50
- package/dist/tools/artifact/artifact-tool.js +3 -2
- package/dist/tools/fs/bash-program-position.d.ts +19 -2
- package/dist/tools/fs/bash-program-position.js +56 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
- package/dist/tools/fs/bash-readonly-classifier.js +5 -10
- package/dist/tools/fs/fs-bash.js +15 -8
- package/dist/tools/fs/fs-glob.d.ts +86 -0
- package/dist/tools/fs/fs-glob.js +226 -0
- package/dist/tools/fs/fs-read.js +14 -14
- package/dist/tools/fs/fs-search-tools.js +7 -7
- package/dist/tools/fs/pattern-kill-guard.d.ts +23 -0
- package/dist/tools/fs/pattern-kill-guard.js +429 -0
- package/dist/tools/fs/pdf.d.ts +9 -6
- package/dist/tools/fs/pdf.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +57 -7
- package/dist/tools/fs/program-read-model.js +11 -1
- package/dist/tools/fs/program-read-model.rows.js +78 -21
- package/dist/tools/fs/read-deny-home.js +3 -2
- package/dist/tools/fs/removal-targets.d.ts +17 -7
- package/dist/tools/fs/removal-targets.js +47 -20
- package/dist/tools/fs/search.d.ts +10 -0
- package/dist/tools/fs/search.js +20 -26
- package/dist/tools/fs/shell-read-argv.js +89 -12
- package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
- package/dist/tools/fs/shell-read-bindings.js +41 -0
- package/dist/tools/fs/shell-read-check.d.ts +10 -0
- package/dist/tools/fs/shell-read-check.js +13 -20
- package/dist/tools/fs/shell-read-environment.d.ts +5 -1
- package/dist/tools/fs/shell-read-environment.js +3 -2
- package/dist/tools/fs/shell-read-establish.d.ts +15 -0
- package/dist/tools/fs/shell-read-establish.js +19 -20
- package/dist/tools/fs/shell-read-identity.d.ts +12 -9
- package/dist/tools/fs/shell-read-identity.js +9 -4
- package/dist/tools/fs/shell-read-plan.js +24 -16
- package/dist/tools/fs/shell-read-start.d.ts +6 -1
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
- package/dist/tools/fs/shell-read-write-targets.js +2 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
- package/dist/tools/fs/shell-reentry-text.js +40 -2
- package/dist/tools/todo.js +63 -63
- package/dist/tools/web.d.ts +19 -14
- package/dist/tools/web.js +46 -61
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +221 -7
- package/wire-changes/core-stores-sql@7.57.0.json +29 -0
- package/wire-changes/core@7.56.0.json +3891 -0
- package/wire-changes/core@7.57.0.json +1487 -0
- package/wire-changes/mods-kernel@7.56.0.json +303 -0
- package/wire-changes/mods-kernel@7.57.0.json +29 -0
- package/wire-changes/primitives@7.57.0.json +245 -0
|
@@ -5,6 +5,7 @@ import type { ProviderCondition, ProviderConditionSource } from "../../brain/pro
|
|
|
5
5
|
import type { RequestRoute, RouteCarrierBag, RouteCredentialSource } from "../../brain/request-route.js";
|
|
6
6
|
export type { RouteCredentialSource } from "../../brain/request-route.js";
|
|
7
7
|
import type { ModelOutputInvalidCause } from "./tool-turns.js";
|
|
8
|
+
import type { PromptTraitName, TraitCondition } from "../../prompt-assembly/catalog/schema.js";
|
|
8
9
|
export type KnownApi = "openai-completions" | "mistral-conversations" | "openai-responses" | "azure-openai-responses" | "openai-chatgpt-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-vertex";
|
|
9
10
|
export type Api = KnownApi | (string & {});
|
|
10
11
|
export type KnownImagesApi = "openrouter-images";
|
|
@@ -697,11 +698,24 @@ export interface Tool<TParameters extends TSchema = TSchema> {
|
|
|
697
698
|
/** VENDORED EDIT (design/115 P0): canonical tool renames keep old model/SDK wire names as aliases. */
|
|
698
699
|
aliases?: string[];
|
|
699
700
|
description: string;
|
|
700
|
-
/**
|
|
701
|
-
*
|
|
702
|
-
|
|
701
|
+
/** The description's conditional variants (see ToolSpec.descriptionVariants): at mount, the first whose traits
|
|
702
|
+
* condition holds over the run's traits replaces `description`; none holds ⇒ `description`. */
|
|
703
|
+
descriptionVariants?: readonly ToolDescriptionVariant[];
|
|
703
704
|
parameters: TParameters;
|
|
704
705
|
}
|
|
706
|
+
/**
|
|
707
|
+
* One conditional variant of a tool's description — the tool card's variant table is these, first match wins, with
|
|
708
|
+
* `description` as the unconditional last entry. Chosen by the run's prompt traits through the same trait reading the
|
|
709
|
+
* prompt catalog's variants use; the variant chosen is reported in the tool's `cardId` (`<card>#<id>`).
|
|
710
|
+
*/
|
|
711
|
+
export interface ToolDescriptionVariant {
|
|
712
|
+
/** The variant's name in the tool's card id: non-empty, at most 64 characters of `[A-Za-z0-9._-]`, unique per tool. */
|
|
713
|
+
readonly id: string;
|
|
714
|
+
/** The trait condition (`allOf` / `noneOf`, trait names) under which this text replaces `description`. */
|
|
715
|
+
readonly traits: TraitCondition;
|
|
716
|
+
/** The description text (non-blank). */
|
|
717
|
+
readonly text: string;
|
|
718
|
+
}
|
|
705
719
|
export interface Context {
|
|
706
720
|
systemPrompt?: string;
|
|
707
721
|
/**
|
|
@@ -924,7 +938,9 @@ export interface Model<TApi extends Api = Api> {
|
|
|
924
938
|
api: TApi;
|
|
925
939
|
provider: Provider;
|
|
926
940
|
baseUrl: string;
|
|
927
|
-
reasoning:
|
|
941
|
+
/** Declares reasoning (thinking keys): `true` / `false`, absent = not declared. Read only through `capabilityOf`
|
|
942
|
+
* (`brain/model-capability.ts`), which also says what an undeclared capability means. */
|
|
943
|
+
reasoning?: boolean;
|
|
928
944
|
/**
|
|
929
945
|
* design/111 — this model's DEFAULT thinking level (per-model preset). The thinking-resolution chain is
|
|
930
946
|
* `spec.thinking ?? role.thinking ?? model.defaultThinking` (prepare-task) — a caller/role still overrides, but
|
|
@@ -940,7 +956,8 @@ export interface Model<TApi extends Api = Api> {
|
|
|
940
956
|
* Missing keys use provider defaults. null marks a level as unsupported.
|
|
941
957
|
*/
|
|
942
958
|
thinkingLevelMap?: ThinkingLevelMap;
|
|
943
|
-
input:
|
|
959
|
+
/** Declares image input: a list with `"image"` = on, without = off, absent = not declared (same reader as `reasoning`). */
|
|
960
|
+
input?: ("text" | "image")[];
|
|
944
961
|
cost?: {
|
|
945
962
|
input: number;
|
|
946
963
|
output: number;
|
|
@@ -996,13 +1013,13 @@ export interface Model<TApi extends Api = Api> {
|
|
|
996
1013
|
/** Extra request HEADERS merged into the provider call. Cannot override auth / content-type / version. */
|
|
997
1014
|
headers?: Record<string, string>;
|
|
998
1015
|
/**
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1016
|
+
* The prompt traits this model has: the reference's capability names that gate prompt text (`PROMPT_TRAITS`), its
|
|
1017
|
+
* bundle names (`PROMPT_TRAIT_BUNDLES`, expanded to their members), or a deployment's own `x-<namespace>-<name>`.
|
|
1018
|
+
* The prompt catalog and every overlay's `when.traits` select on them; the engine never derives them from `id`. An
|
|
1019
|
+
* EXACT set — nothing is added to what it lists (declare `lean_prompt` for the lean shape). Absent ⇒
|
|
1020
|
+
* `["lean_prompt"]`. A name that is none of these refuses the task (`config.prompt_trait_unknown`).
|
|
1004
1021
|
*/
|
|
1005
|
-
|
|
1022
|
+
promptTraits?: readonly PromptTraitName[];
|
|
1006
1023
|
/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */
|
|
1007
1024
|
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : never;
|
|
1008
1025
|
}
|
|
@@ -129,12 +129,9 @@ export interface TrailingToolBatchSettlement {
|
|
|
129
129
|
aborted: boolean;
|
|
130
130
|
}) => void;
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
133
|
-
* settlement, and the moment the prompts enter the loop transcript, before their frames are emitted
|
|
134
|
-
* — delivery accounts precede the carrying messages' commits. */
|
|
132
|
+
/** A prompt run's seam beyond its prompts (the trailing-batch settlement); a prompt is delivered at its `message_end`. */
|
|
135
133
|
export interface RunAgentLoopSeams {
|
|
136
134
|
settle?: TrailingToolBatchSettlement;
|
|
137
|
-
onPromptsDelivered?: () => void;
|
|
138
135
|
}
|
|
139
136
|
/** The last assistant message of `messages` when at least one of its tool calls has no tool result after it. */
|
|
140
137
|
export declare function findUnansweredToolBatch(messages: readonly AgentMessage[]): AssistantMessage | undefined;
|
|
@@ -154,11 +151,33 @@ type ExecutedToolCallBatch = {
|
|
|
154
151
|
messages: ToolResultMessage[];
|
|
155
152
|
terminate: boolean;
|
|
156
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* ONE call through the loop's per-call pipeline — announced, prepared (the gate included), executed through the execution
|
|
156
|
+
* seat, finalized, closed. The sequential lane runs each call through it and adds the call's tool-result message; a host's
|
|
157
|
+
* own call (`AgentHarness.callTool`) runs it with no model message and adds nothing. The partitioned and streaming lanes run
|
|
158
|
+
* the same steps in two phases.
|
|
159
|
+
*/
|
|
160
|
+
export declare function runToolCall(currentContext: AgentContext, assistantMessage: AssistantMessage | undefined, toolCall: AgentToolCall, config: AgentLoopConfig, signal: AbortSignal | undefined, emit: AgentEventSink): Promise<{
|
|
161
|
+
finalized: FinalizedToolCallOutcome;
|
|
162
|
+
halt?: HaltRemainingDirective;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Partition rule: a call is batch-safe ONLY if its arguments
|
|
166
|
+
* VALIDATE against the tool's schema (CC `safeParse` — a malformed call never rides a parallel batch;
|
|
167
|
+
* it stays a singleton and surfaces its validation error at execution) AND the tool/hook opts in.
|
|
168
|
+
* The hook sees the validated+coerced args — same as CC handing `parsed.data` to `isConcurrencySafe`.
|
|
169
|
+
*/
|
|
170
|
+
export declare function isBatchSafeToolCall(tool: AgentTool | undefined, toolCall: AgentToolCall): boolean;
|
|
157
171
|
/** An executed call's raw outcome, before (and, from {@link finalizeToolOutcome}, after) the post-execution half. */
|
|
158
172
|
export type ExecutedToolCallOutcome = {
|
|
159
173
|
result: AgentToolResult<unknown>;
|
|
160
174
|
isError: boolean;
|
|
161
175
|
};
|
|
176
|
+
type FinalizedToolCallOutcome = {
|
|
177
|
+
toolCall: AgentToolCall;
|
|
178
|
+
result: AgentToolResult<unknown>;
|
|
179
|
+
isError: boolean;
|
|
180
|
+
};
|
|
162
181
|
/**
|
|
163
182
|
* THE reading a value gets on its way to becoming a call's arguments: the tool's own preparation (`prepareArguments` —
|
|
164
183
|
* a default filled in, an alias folded), then the schema's coercions ({@link validateToolArguments}). The loop reads the
|
|
@@ -3,8 +3,10 @@ import { truncateError } from "../../core/tool-errors.js";
|
|
|
3
3
|
import { judgeToolNameMiss, mountedToolNames } from "../../core/tool-name-aliases.js";
|
|
4
4
|
import { INTERRUPTED_BY_USER_FOR_TOOL_USE_MARKER, INTERRUPTED_BY_USER_MARKER, } from "../../core/session-reconcile.js";
|
|
5
5
|
import { resolveAgentCoreStreamFn } from "./runtime-deps.js";
|
|
6
|
-
import { isErrorLike, readMember, thrownMarksOf } from "../../core/thrown-value.js";
|
|
6
|
+
import { isErrorLike, readMember, readOwnMembers, thrownMarksOf } from "../../core/thrown-value.js";
|
|
7
7
|
import { egressThrownText, egressValue } from "../../core/untrusted-egress.js";
|
|
8
|
+
import { remoteWords } from "../../core/protocol-http-auth.js";
|
|
9
|
+
import { types } from "node:util";
|
|
8
10
|
import { admitToolResultMedia } from "../../core/image-admission.js";
|
|
9
11
|
function appendTextDeltaToAssistantMessage(message, contentIndex, delta) {
|
|
10
12
|
const content = [...message.content];
|
|
@@ -75,7 +77,6 @@ export async function runAgentLoop(prompts, context, config, emit, signal, strea
|
|
|
75
77
|
state.hasMoreToolCalls = true;
|
|
76
78
|
state.context.messages.push(...delivered);
|
|
77
79
|
state.newMessages.push(...delivered);
|
|
78
|
-
seams?.onPromptsDelivered?.();
|
|
79
80
|
for (const prompt of delivered) {
|
|
80
81
|
await emit({ type: "message_start", message: prompt });
|
|
81
82
|
await emit({ type: "message_end", message: prompt });
|
|
@@ -756,7 +757,7 @@ async function streamAssistantResponse(context, config, signal, emit, streamFn,
|
|
|
756
757
|
break;
|
|
757
758
|
case "done":
|
|
758
759
|
case "error": {
|
|
759
|
-
const finalMessage = await response.result();
|
|
760
|
+
const finalMessage = receivedFinal(await response.result());
|
|
760
761
|
const cutAtSettle = signal?.aborted === true;
|
|
761
762
|
if (executor && (finalMessage.stopReason === "error" || finalMessage.stopReason === "aborted")) {
|
|
762
763
|
mergeBackAdmittedCalls(finalMessage, executor);
|
|
@@ -775,7 +776,7 @@ async function streamAssistantResponse(context, config, signal, emit, streamFn,
|
|
|
775
776
|
}
|
|
776
777
|
}
|
|
777
778
|
}
|
|
778
|
-
const finalMessage = await response.result();
|
|
779
|
+
const finalMessage = receivedFinal(await response.result());
|
|
779
780
|
const cutAtSettle = signal?.aborted === true;
|
|
780
781
|
if (executor && (finalMessage.stopReason === "error" || finalMessage.stopReason === "aborted")) {
|
|
781
782
|
mergeBackAdmittedCalls(finalMessage, executor);
|
|
@@ -802,27 +803,7 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
|
|
|
802
803
|
const messages = [];
|
|
803
804
|
for (let i = 0; i < toolCalls.length; i++) {
|
|
804
805
|
const toolCall = toolCalls[i];
|
|
805
|
-
await emit
|
|
806
|
-
type: "tool_execution_start",
|
|
807
|
-
toolCallId: toolCall.id,
|
|
808
|
-
toolName: toolCall.name,
|
|
809
|
-
args: toolCall.arguments,
|
|
810
|
-
});
|
|
811
|
-
const preparation = await prepareToolCall(currentContext, assistantMessage, toolCall, config, signal);
|
|
812
|
-
let finalized;
|
|
813
|
-
let halt;
|
|
814
|
-
if (preparation.kind === "immediate") {
|
|
815
|
-
finalized = {
|
|
816
|
-
toolCall,
|
|
817
|
-
result: preparation.result,
|
|
818
|
-
isError: preparation.isError,
|
|
819
|
-
};
|
|
820
|
-
halt = preparation.halt;
|
|
821
|
-
}
|
|
822
|
-
else {
|
|
823
|
-
finalized = await executePreparedWithDisclosure(currentContext, assistantMessage, preparation, config, signal, emit);
|
|
824
|
-
}
|
|
825
|
-
await emitToolExecutionEnd(finalized, emit);
|
|
806
|
+
const { finalized, halt } = await runToolCall(currentContext, assistantMessage, toolCall, config, signal, emit);
|
|
826
807
|
const toolResultMessage = createToolResultMessage(finalized);
|
|
827
808
|
await emitToolResultMessage(toolResultMessage, emit);
|
|
828
809
|
finalizedCalls.push(finalized);
|
|
@@ -846,6 +827,15 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
|
|
|
846
827
|
terminate: shouldTerminateToolBatch(finalizedCalls),
|
|
847
828
|
};
|
|
848
829
|
}
|
|
830
|
+
export async function runToolCall(currentContext, assistantMessage, toolCall, config, signal, emit) {
|
|
831
|
+
await emit({ type: "tool_execution_start", toolCallId: toolCall.id, toolName: toolCall.name, args: toolCall.arguments });
|
|
832
|
+
const preparation = await prepareToolCall(currentContext, assistantMessage, toolCall, config, signal);
|
|
833
|
+
const finalized = preparation.kind === "immediate"
|
|
834
|
+
? { toolCall, result: preparation.result, isError: preparation.isError }
|
|
835
|
+
: await executePreparedWithDisclosure(currentContext, assistantMessage, preparation, config, signal, emit);
|
|
836
|
+
await emitToolExecutionEnd(finalized, emit);
|
|
837
|
+
return { finalized, ...(preparation.kind === "immediate" && preparation.halt !== undefined ? { halt: preparation.halt } : {}) };
|
|
838
|
+
}
|
|
849
839
|
async function settleHaltedToolCall(toolCall, halt, emit) {
|
|
850
840
|
await emit({
|
|
851
841
|
type: "tool_execution_start",
|
|
@@ -887,7 +877,7 @@ function isCallConcurrencySafe(tool, args) {
|
|
|
887
877
|
return false;
|
|
888
878
|
}
|
|
889
879
|
}
|
|
890
|
-
function isBatchSafeToolCall(tool, toolCall) {
|
|
880
|
+
export function isBatchSafeToolCall(tool, toolCall) {
|
|
891
881
|
if (!tool)
|
|
892
882
|
return false;
|
|
893
883
|
let args;
|
|
@@ -1108,7 +1098,7 @@ class StreamToolExecutor {
|
|
|
1108
1098
|
return;
|
|
1109
1099
|
}
|
|
1110
1100
|
entry.prepared = preparation;
|
|
1111
|
-
entry.executed = await executePreparedToolCall(preparation, this.signal, this.emit, this.config.abortResultDetails, (error) => this.retainCancellation(error));
|
|
1101
|
+
entry.executed = await executePreparedToolCall(preparation, this.signal, this.emit, this.config.executeTool, this.config.abortResultDetails, (error) => this.retainCancellation(error));
|
|
1112
1102
|
}
|
|
1113
1103
|
catch (error) {
|
|
1114
1104
|
if (isAbortSemanticsError(error))
|
|
@@ -1190,6 +1180,27 @@ async function harvestExecutorOnErrorFinal(executor, state, finalMessage, signal
|
|
|
1190
1180
|
}
|
|
1191
1181
|
return results;
|
|
1192
1182
|
}
|
|
1183
|
+
function receivedFinal(message) {
|
|
1184
|
+
const words = readMember(message, "errorMessage");
|
|
1185
|
+
const minted = typeof words === "string" ? remoteWords(words, []) : undefined;
|
|
1186
|
+
if (minted === words && readsTheSame(message, "errorMessage", words))
|
|
1187
|
+
return message;
|
|
1188
|
+
const copy = {};
|
|
1189
|
+
for (const [key, value] of Object.entries(readOwnMembers(message) ?? {}))
|
|
1190
|
+
if (key !== "errorMessage")
|
|
1191
|
+
Object.defineProperty(copy, key, { value, enumerable: true, writable: true, configurable: true });
|
|
1192
|
+
if (minted !== undefined)
|
|
1193
|
+
copy.errorMessage = minted;
|
|
1194
|
+
return copy;
|
|
1195
|
+
}
|
|
1196
|
+
function readsTheSame(o, key, value) {
|
|
1197
|
+
if (types.isProxy(o))
|
|
1198
|
+
return false;
|
|
1199
|
+
const d = Reflect.getOwnPropertyDescriptor(o, key);
|
|
1200
|
+
if (d === undefined)
|
|
1201
|
+
return value === undefined && !(key in o);
|
|
1202
|
+
return "value" in d && d.value === value;
|
|
1203
|
+
}
|
|
1193
1204
|
function mergeBackAdmittedCalls(finalMessage, executor) {
|
|
1194
1205
|
const admitted = executor.admittedToolCalls();
|
|
1195
1206
|
if (admitted.length === 0)
|
|
@@ -1395,7 +1406,7 @@ async function prepareToolCall(currentContext, assistantMessage, toolCall, confi
|
|
|
1395
1406
|
};
|
|
1396
1407
|
}
|
|
1397
1408
|
}
|
|
1398
|
-
async function executePreparedToolCall(prepared, signal, emit, abortResultDetails, onLateCancellation) {
|
|
1409
|
+
async function executePreparedToolCall(prepared, signal, emit, executeTool, abortResultDetails, onLateCancellation) {
|
|
1399
1410
|
const updateEvents = [];
|
|
1400
1411
|
let acceptingUpdates = true;
|
|
1401
1412
|
if (signal?.aborted) {
|
|
@@ -1404,7 +1415,7 @@ async function executePreparedToolCall(prepared, signal, emit, abortResultDetail
|
|
|
1404
1415
|
const work = (async () => {
|
|
1405
1416
|
let outcome;
|
|
1406
1417
|
try {
|
|
1407
|
-
const
|
|
1418
|
+
const body = () => prepared.tool.execute(prepared.toolCall.id, prepared.args, signal, (partialResult) => {
|
|
1408
1419
|
if (!acceptingUpdates) {
|
|
1409
1420
|
return;
|
|
1410
1421
|
}
|
|
@@ -1427,6 +1438,7 @@ async function executePreparedToolCall(prepared, signal, emit, abortResultDetail
|
|
|
1427
1438
|
});
|
|
1428
1439
|
updateEvents.push(delivery);
|
|
1429
1440
|
});
|
|
1441
|
+
const result = executeTool !== undefined ? await executeTool({ toolCall: prepared.toolCall, tool: prepared.tool, args: prepared.args }, body, signal) : await body();
|
|
1430
1442
|
outcome = { result, isError: result.isError === true };
|
|
1431
1443
|
}
|
|
1432
1444
|
catch (error) {
|
|
@@ -1507,7 +1519,7 @@ function raiseFatalCancellation(executor) {
|
|
|
1507
1519
|
async function executePreparedWithDisclosure(currentContext, assistantMessage, prepared, config, signal, emit) {
|
|
1508
1520
|
let executed;
|
|
1509
1521
|
try {
|
|
1510
|
-
executed = await executePreparedToolCall(prepared, signal, emit, config.abortResultDetails);
|
|
1522
|
+
executed = await executePreparedToolCall(prepared, signal, emit, config.executeTool, config.abortResultDetails);
|
|
1511
1523
|
}
|
|
1512
1524
|
catch (error) {
|
|
1513
1525
|
if (isAbortSemanticsError(error))
|
|
@@ -127,9 +127,9 @@ export interface AfterToolCallResult {
|
|
|
127
127
|
}
|
|
128
128
|
/** Context passed to `beforeToolCall`. */
|
|
129
129
|
export interface BeforeToolCallContext {
|
|
130
|
-
/** The assistant message that requested the tool call. */
|
|
131
|
-
assistantMessage
|
|
132
|
-
/** The raw tool call block from `assistantMessage.content
|
|
130
|
+
/** The assistant message that requested the tool call — absent for a host's own call (an extension's `$.tool.call`), which no model message carried. */
|
|
131
|
+
assistantMessage?: AssistantMessage;
|
|
132
|
+
/** The raw tool call block (from `assistantMessage.content` when a model message carried it). */
|
|
133
133
|
toolCall: AgentToolCall;
|
|
134
134
|
/** Validated tool arguments for the target tool schema. */
|
|
135
135
|
args: unknown;
|
|
@@ -142,9 +142,9 @@ export interface BeforeToolCallContext {
|
|
|
142
142
|
}
|
|
143
143
|
/** Context passed to `afterToolCall`. */
|
|
144
144
|
export interface AfterToolCallContext {
|
|
145
|
-
/** The assistant message that requested the tool call. */
|
|
146
|
-
assistantMessage
|
|
147
|
-
/** The raw tool call block from `assistantMessage.content
|
|
145
|
+
/** The assistant message that requested the tool call — absent for a host's own call (an extension's `$.tool.call`), which no model message carried. */
|
|
146
|
+
assistantMessage?: AssistantMessage;
|
|
147
|
+
/** The raw tool call block (from `assistantMessage.content` when a model message carried it). */
|
|
148
148
|
toolCall: AgentToolCall;
|
|
149
149
|
/** Validated tool arguments for the target tool schema. */
|
|
150
150
|
args: unknown;
|
|
@@ -564,6 +564,16 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
|
|
|
564
564
|
* signal re-check, which has always minted its abort result with no details.
|
|
565
565
|
*/
|
|
566
566
|
abortResultDetails?: () => Record<string, unknown> | undefined;
|
|
567
|
+
/**
|
|
568
|
+
* The host's station around every tool execution, between the gate's allow and the body: `run` runs the body as the loop
|
|
569
|
+
* would (at most once), and what the station returns is the result the loop finalizes — it may answer without running it,
|
|
570
|
+
* and honors `signal`. Absent ⇒ the loop runs the body itself.
|
|
571
|
+
*/
|
|
572
|
+
executeTool?: (call: {
|
|
573
|
+
readonly toolCall: AgentToolCall;
|
|
574
|
+
readonly tool: AgentTool;
|
|
575
|
+
readonly args: unknown;
|
|
576
|
+
}, run: () => Promise<AgentToolResult<unknown>>, signal: AbortSignal | undefined) => Promise<AgentToolResult<unknown>>;
|
|
567
577
|
/**
|
|
568
578
|
* Fault seat for a THROWING {@link AgentTool.validateInput}: the loop reads the throw as "no
|
|
569
579
|
* verdict" (the call proceeds to the gate as if the tool had no validator) and reports the fault
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { type Session, type SessionCreateOptions, type SessionForkOptions, type SessionHead, type SessionMetadata, type SessionRepo, type SessionTreeEntry } from "../harness/types.js";
|
|
1
|
+
import { type Session, type SessionCreateOptions, type SessionForkOptions, type SessionHead, type SessionMetadata, type SessionRepo, type SessionRow, type SessionTreeEntry } from "../harness/types.js";
|
|
2
2
|
export declare class InMemorySessionRepo implements SessionRepo<SessionMetadata, SessionCreateOptions> {
|
|
3
3
|
private sessions;
|
|
4
|
+
/** Each row's last touch (epoch ms). */
|
|
5
|
+
private touched;
|
|
4
6
|
create(options?: SessionCreateOptions): Promise<Session>;
|
|
5
7
|
open(metadata: SessionMetadata): Promise<Session>;
|
|
6
8
|
/** The row's head off the one session object that IS the row: every cell comes from that object, so a delete and re-create of the
|
|
7
9
|
* id while this reads cannot mix two generations. */
|
|
8
10
|
headOf(sessionId: string): Promise<SessionHead | undefined>;
|
|
9
|
-
|
|
11
|
+
/** Every row, with its last {@link touch} as its activity time where it has one. This repo hands its sessions' storages out and never
|
|
12
|
+
* sees their writes (an entry's own `timestamp` is the writer's data, not the time of the write), so a row never touched carries none
|
|
13
|
+
* and a reader takes its `createdAt`. */
|
|
14
|
+
list(): Promise<SessionRow[]>;
|
|
15
|
+
/** Record activity on the row now (a missing row: nothing to record). The time lives and dies with the row: `delete` drops it. */
|
|
16
|
+
touch(sessionId: string): Promise<void>;
|
|
10
17
|
delete(metadata: SessionMetadata): Promise<void>;
|
|
11
18
|
fork(sourceMetadata: SessionMetadata, options: SessionForkOptions & SessionCreateOptions): Promise<Session>;
|
|
12
19
|
/** 2c session-sync: the FULL log for export. InMemory holds everything (no F3 floor), so
|
|
@@ -4,6 +4,7 @@ import { InMemorySessionStorage } from "./memory-storage.js";
|
|
|
4
4
|
import { assertForkTarget, createSessionId, createTimestamp, forkRowCells, frozenRow, getEntriesToFork, headOfSession, importRowCells, incarnationCell, ownerCell, toSession } from "./repo-utils.js";
|
|
5
5
|
export class InMemorySessionRepo {
|
|
6
6
|
sessions = new Map();
|
|
7
|
+
touched = new Map();
|
|
7
8
|
async create(options = {}) {
|
|
8
9
|
if (options.id !== undefined) {
|
|
9
10
|
const existing = this.sessions.get(options.id);
|
|
@@ -33,10 +34,19 @@ export class InMemorySessionRepo {
|
|
|
33
34
|
return row === undefined ? undefined : headOfSession(row);
|
|
34
35
|
}
|
|
35
36
|
async list() {
|
|
36
|
-
return Promise.all([...this.sessions.
|
|
37
|
+
return Promise.all([...this.sessions.entries()].map(async ([id, session]) => {
|
|
38
|
+
const meta = await session.getMetadata();
|
|
39
|
+
const touched = this.touched.get(id);
|
|
40
|
+
return touched !== undefined ? { ...meta, lastActiveAt: touched } : meta;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
async touch(sessionId) {
|
|
44
|
+
if (this.sessions.has(sessionId))
|
|
45
|
+
this.touched.set(sessionId, Date.now());
|
|
37
46
|
}
|
|
38
47
|
async delete(metadata) {
|
|
39
48
|
this.sessions.delete(metadata.id);
|
|
49
|
+
this.touched.delete(metadata.id);
|
|
40
50
|
}
|
|
41
51
|
async fork(sourceMetadata, options) {
|
|
42
52
|
assertForkTarget(sourceMetadata.id, options.id);
|
|
@@ -22,16 +22,17 @@ export declare function compareOccupants(before: {
|
|
|
22
22
|
} | undefined): "same" | "different" | "unknown";
|
|
23
23
|
/** The {@link SessionHead} a session object shows: its metadata's owner and occupant and its storage's leaf, off that one object. */
|
|
24
24
|
export declare function headOfSession(session: Session): Promise<SessionHead>;
|
|
25
|
-
/** The {@link SessionMetadata.owner} cell the write creating a row records: `owner` (a
|
|
26
|
-
* `null`). An `owner` that is neither is refused before the write, so no row ever holds an owner cell that reads as neither
|
|
25
|
+
/** The {@link SessionMetadata.owner} cell the write creating a row records: `owner` (a principal name, or `null`; `undefined` = none
|
|
26
|
+
* named = `null`). An `owner` that is neither is refused before the write, so no row ever holds an owner cell that reads as neither
|
|
27
|
+
* — a blank string included: it names nobody, so it is no owner and not anonymous either. */
|
|
27
28
|
export declare function ownerCell(owner: unknown): Pick<SessionMetadata, "owner">;
|
|
28
29
|
/** The metadata an import lays down. An import replaces the log, never the row: an existing row keeps its metadata whole (its creation
|
|
29
30
|
* time, lineage, placement, occupant and owner were recorded by the write that created it); an absent id is a new row recording `owner`
|
|
30
31
|
* and a fresh occupant. `owner` is judged either way. */
|
|
31
32
|
export declare function importRowCells(sessionId: string, owner: unknown, existing: SessionMetadata | undefined, createdAt: string): SessionMetadata;
|
|
32
|
-
/** The one decoding of a stored owner cell: a
|
|
33
|
-
* but is neither cannot be read as anyone's, and reading it as anonymous would admit every
|
|
34
|
-
* `corrupt_session` instead (a read fault, never an answer). */
|
|
33
|
+
/** The one decoding of a stored owner cell: a principal name is the owner; absence (`undefined`, `null`) is anonymous. A cell that is
|
|
34
|
+
* there but is neither (a blank string included) cannot be read as anyone's, and reading it as anonymous would admit every
|
|
35
|
+
* principal — the row is refused as `corrupt_session` instead (a read fault, never an answer). */
|
|
35
36
|
export declare function readOwnerCell(raw: unknown, sessionId: string): string | null;
|
|
36
37
|
/** A fork lands on a row OTHER than its source: onto its own id it would mint a new occupant over the source's transcript and erase the lineage that carries the source's records. */
|
|
37
38
|
export declare function assertForkTarget(sourceId: string, targetId: string | undefined): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SessionError, } from "../harness/types.js";
|
|
2
2
|
import { StoredSession } from "./session.js";
|
|
3
3
|
import { uuidv7 } from "./uuid.js";
|
|
4
|
+
import { principalNameFault, principalNameOf } from "../../core/principal-name.js";
|
|
4
5
|
import { randomUUID } from "node:crypto";
|
|
5
6
|
export function createSessionId() {
|
|
6
7
|
return uuidv7();
|
|
@@ -35,21 +36,28 @@ export async function headOfSession(session) {
|
|
|
35
36
|
const meta = await session.getMetadata();
|
|
36
37
|
return { owner: meta.owner ?? null, incarnation: meta.incarnation, leafId: await session.getStorage().getLeafId() };
|
|
37
38
|
}
|
|
39
|
+
function notAnOwnerShape(raw) {
|
|
40
|
+
return typeof raw === "string" ? principalNameFault(raw) : nonStringShape(raw);
|
|
41
|
+
}
|
|
38
42
|
export function ownerCell(owner) {
|
|
39
|
-
if (owner
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
if (owner === undefined || owner === null)
|
|
44
|
+
return { owner: null };
|
|
45
|
+
const name = principalNameOf(owner);
|
|
46
|
+
if (name === undefined)
|
|
47
|
+
throw new TypeError(`session owner must be a principal name (a string with a visible character, no control or separator character, and no format character but a joiner) or null (anonymous), got ${notAnOwnerShape(owner)}`);
|
|
48
|
+
return { owner: name };
|
|
42
49
|
}
|
|
43
50
|
export function importRowCells(sessionId, owner, existing, createdAt) {
|
|
44
51
|
const named = ownerCell(owner);
|
|
45
52
|
return existing ?? { id: sessionId, createdAt, ...incarnationCell(undefined), ...named };
|
|
46
53
|
}
|
|
47
54
|
export function readOwnerCell(raw, sessionId) {
|
|
48
|
-
if (typeof raw === "string")
|
|
49
|
-
return raw;
|
|
50
55
|
if (raw === undefined || raw === null)
|
|
51
56
|
return null;
|
|
52
|
-
|
|
57
|
+
const name = principalNameOf(raw);
|
|
58
|
+
if (name !== undefined)
|
|
59
|
+
return name;
|
|
60
|
+
throw new SessionError("corrupt_session", `session ${sessionId}'s owner cell holds ${notAnOwnerShape(raw)} — neither an owner nor anonymous; refusing to read the row`);
|
|
53
61
|
}
|
|
54
62
|
export function assertForkTarget(sourceId, targetId) {
|
|
55
63
|
if (targetId === sourceId)
|