@sema-agent/core 7.58.0 → 7.60.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 +1340 -0
- package/README.md +6 -4
- 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 +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +9 -4
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +32 -50
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +150 -112
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +90 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +65 -6
- package/dist/brain/timeout.js +111 -11
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +20 -6
- package/dist/core/allow-entry.js +17 -7
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-compaction.js +1 -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 +63 -12
- package/dist/core/background-agent-store.d.ts +26 -4
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +66 -25
- package/dist/core/checkpoint-store.js +22 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +3 -3
- package/dist/core/compliance.js +1 -1
- 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 +4 -5
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +156 -23
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +8 -6
- package/dist/core/gate-lanes.js +47 -12
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +17 -1
- package/dist/core/governance-codes.js +25 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +70 -59
- package/dist/core/hooks.js +125 -80
- package/dist/core/image-admission.d.ts +106 -52
- package/dist/core/image-admission.js +184 -56
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +59 -5
- package/dist/core/locked-config.js +82 -50
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +122 -20
- package/dist/core/mcp-failure.js +73 -5
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +27 -12
- package/dist/core/mcp.js +105 -76
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- 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/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- 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 +51 -9
- package/dist/core/memory-engine/sync-client.js +107 -13
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +8 -1
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- 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 +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +6 -5
- package/dist/core/mods/kernel/events.d.ts +11 -4
- package/dist/core/mods/kernel/events.js +11 -7
- 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 +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +73 -60
- package/dist/core/mods/stations.js +64 -40
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- 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/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +14 -8
- package/dist/core/peer-seat.d.ts +133 -16
- package/dist/core/peer-seat.js +319 -42
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +11 -6
- package/dist/core/permission-rule-model.d.ts +20 -2
- package/dist/core/permission-rule-model.js +8 -7
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- 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 +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +13 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +69 -3
- package/dist/core/roles.js +167 -80
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +23 -12
- 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/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +82 -57
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- 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/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 +87 -11
- package/dist/core/runner/gate-exit.js +30 -8
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- 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/memory-consolidation-driver.js +5 -5
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +16 -9
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
- package/dist/core/runner/prepare-delegation-surface.js +5 -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 +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
- package/dist/core/runner/prepare-hands-readface.js +19 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
- package/dist/core/runner/prepare-inherited-gate.js +22 -31
- 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 +12 -19
- package/dist/core/runner/prepare-park-ask.d.ts +4 -6
- package/dist/core/runner/prepare-park-ask.js +5 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
- package/dist/core/runner/prepare-policy-chain.js +136 -121
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +10 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
- package/dist/core/runner/prepare-prompt-inputs.js +10 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +17 -2
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +44 -28
- 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 +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +3 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -5
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +63 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +14 -6
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +89 -77
- package/dist/core/runner/runtask.d.ts +8 -5
- package/dist/core/runner/runtask.js +21 -13
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +20 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-end-body.js +2 -2
- 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-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- 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/turn-attachments.d.ts +29 -27
- package/dist/core/runner/turn-attachments.js +27 -42
- package/dist/core/runner-deps.d.ts +32 -19
- package/dist/core/secret-env.d.ts +35 -4
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +12 -3
- package/dist/core/session-policy-store.js +29 -10
- package/dist/core/session-store.d.ts +5 -7
- package/dist/core/session-store.js +50 -11
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +17 -5
- package/dist/core/skill-grant.js +24 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -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/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +50 -10
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +146 -17
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +19 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +43 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +15 -7
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +21 -4
- package/dist/core/tool-policy.js +1 -1
- 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 +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +23 -5
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +15 -7
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
- package/dist/engine/execution-env/node-execution-env.js +21 -13
- package/dist/engine/harness/agent-harness.d.ts +26 -3
- package/dist/engine/harness/agent-harness.js +49 -16
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +119 -28
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +20 -12
- package/dist/engine/loop/agent-loop.js +205 -36
- package/dist/engine/loop/types.d.ts +12 -3
- 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/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +26 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +762 -491
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +9 -11
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- 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 +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- 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 +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +14 -4
- package/dist/tools/fs/fs-bash.js +29 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- 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 +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +13 -5
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +62 -0
- package/dist/tools/fs/read-floor.js +58 -0
- 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 +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +9 -4
- package/dist/tools/monitor.js +17 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +161 -21
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
-
import { DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, declarationFaultOf, declarerWord, readToolAxes, receiveDeclaration, toolAxesRefusal } from "./mcp-server-spec.js";
|
|
2
|
+
import { DECLARATION_ENTRY_WORDS, DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, TOOL_AXIS_WORDS, callerText, declarationFaultOf, declarationPath, declarerWord, readToolAxes, receiveDeclaration, toolAxesRefusal, } from "./mcp-server-spec.js";
|
|
3
3
|
import { isPlainRecord, receive } from "./mods/kernel/receive.js";
|
|
4
|
-
import { readToolFaces } from "./tool-face-reader.js";
|
|
4
|
+
import { TOOL_FACE_WORDS, readToolFaces } from "./tool-face-reader.js";
|
|
5
5
|
import { judgeSessionMetaKey } from "./mcp-call-meta.js";
|
|
6
6
|
import { CONFIG_RECEIPT_MODE } from "./own-property-receipt.js";
|
|
7
7
|
import { isToolContentOrigin, TOOL_CONTENT_ORIGINS } from "./memory-engine/content-origin.js";
|
|
8
8
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
9
9
|
import { assertNoRetiredToolPolicyKeys } from "./retired-keys.js";
|
|
10
|
-
import { CREDENTIALS_MEMBER, declaredCredentials, peerSeatMissing, retiredValueMember } from "./peer-seat.js";
|
|
10
|
+
import { CREDENTIALS_MEMBER, RETIRED_VALUE_MEMBERS, declaredCredentials, peerSeatMissing, retiredValueMember } from "./peer-seat.js";
|
|
11
11
|
export const LOCKED_KEY_REGISTRY = {
|
|
12
12
|
mcp: { specFields: ["mcp"] },
|
|
13
|
+
a2a: { specFields: ["a2a"] },
|
|
13
14
|
toolPolicy: { specFields: ["toolPolicy", "basePolicyForResumeEdit"] },
|
|
14
15
|
compliancePosture: { specFields: [] },
|
|
15
16
|
retentionPolicy: { specFields: [] },
|
|
@@ -28,7 +29,7 @@ export function resolveLockedKeys(config) {
|
|
|
28
29
|
for (let index = 0; index < listed.length; index++) {
|
|
29
30
|
const key = listed[index];
|
|
30
31
|
if (!Object.hasOwn(LOCKED_KEY_REGISTRY, key)) {
|
|
31
|
-
throw lockDeclarationRefusal(`RunnerDeps.lockedConfig.keys[${index}]`, `is ${
|
|
32
|
+
throw lockDeclarationRefusal(`RunnerDeps.lockedConfig.keys[${index}]`, `is ${callerText(key)}, which is not a member of the locked-key registry (${Object.keys(LOCKED_KEY_REGISTRY).join(", ")})`);
|
|
32
33
|
}
|
|
33
34
|
keys.add(key);
|
|
34
35
|
}
|
|
@@ -37,13 +38,13 @@ export function resolveLockedKeys(config) {
|
|
|
37
38
|
function declaredLockKeys(config) {
|
|
38
39
|
const received = receiveDeclaration(config, NO_DECLARATION_PATH_RULES);
|
|
39
40
|
if (!received.ok)
|
|
40
|
-
throw lockDeclarationRefusal(
|
|
41
|
+
throw lockDeclarationRefusal(declarationPath(received.fault.path, LOCK_DECLARATION_WORDS, "RunnerDeps.lockedConfig"), `cannot be read: ${received.fault.problem}`);
|
|
41
42
|
const copy = received.value;
|
|
42
43
|
if (!isPlainRecord(copy))
|
|
43
|
-
throw lockDeclarationRefusal("RunnerDeps.lockedConfig", `is ${
|
|
44
|
+
throw lockDeclarationRefusal("RunnerDeps.lockedConfig", `is ${callerText(copy)}, not an object with a \`keys\` list`);
|
|
44
45
|
const keys = Object.hasOwn(copy, "keys") ? copy["keys"] : undefined;
|
|
45
46
|
if (!Array.isArray(keys))
|
|
46
|
-
throw lockDeclarationRefusal("RunnerDeps.lockedConfig.keys", `is ${
|
|
47
|
+
throw lockDeclarationRefusal("RunnerDeps.lockedConfig.keys", `is ${callerText(keys)}, not a list of locked keys`);
|
|
47
48
|
return keys;
|
|
48
49
|
}
|
|
49
50
|
function lockDeclarationRefusal(member, problem) {
|
|
@@ -52,16 +53,8 @@ function lockDeclarationRefusal(member, problem) {
|
|
|
52
53
|
export function snapshotMcpEntries(entries) {
|
|
53
54
|
return entries.map((entry) => snapshotDeclaredEntry(entry, "mcp"));
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
for (const key of path) {
|
|
58
|
-
const name = typeof key === "string" && /^\d+$/.test(key) ? JSON.stringify(key) : String(key);
|
|
59
|
-
rendered += typeof key === "number" ? `[${key}]` : rendered === "" ? name : `.${name}`;
|
|
60
|
-
if (rendered.length > 120 + base.length)
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
return rendered;
|
|
64
|
-
}
|
|
56
|
+
const LOCK_DECLARATION_WORDS = new Set(["keys"]);
|
|
57
|
+
const ENTRY_PATH_WORDS = new Set([...DECLARATION_ENTRY_WORDS, ...TOOL_AXIS_WORDS, ...TOOL_FACE_WORDS, ...Object.values(RETIRED_VALUE_MEMBERS).flat(2)]);
|
|
65
58
|
function unreadableDeclaration(at, declarer, member, problem) {
|
|
66
59
|
const refusal = codedError("config.invalid_argument", `${declarerWord(at)}${declarer === undefined ? "" : ` ${declarerNameOf(declarer)}`} declares ${inlineUntrusted(member, 80)} the engine cannot read: ${problem}. A declaration the engine cannot read is refused ` +
|
|
67
60
|
`rather than partly applied — what the caller wrote and what the engine runs on would otherwise differ without anyone being told.`);
|
|
@@ -81,7 +74,7 @@ function capturedName(entry) {
|
|
|
81
74
|
return typeof entry === "object" && entry !== null && !types.isProxy(entry) ? ownDataString(entry, "name") : undefined;
|
|
82
75
|
}
|
|
83
76
|
function entryFaultRefusal(at, declarer, path, problem) {
|
|
84
|
-
return unreadableDeclaration(at, declarer, path.length === 0 ? "an entry" :
|
|
77
|
+
return unreadableDeclaration(at, declarer, path.length === 0 ? "an entry" : declarationPath(path, ENTRY_PATH_WORDS), problem);
|
|
85
78
|
}
|
|
86
79
|
export function snapshotDeclaredEntry(entry, at) {
|
|
87
80
|
const declared = entry;
|
|
@@ -90,7 +83,7 @@ export function snapshotDeclaredEntry(entry, at) {
|
|
|
90
83
|
if (!received.ok)
|
|
91
84
|
throw entryFaultRefusal(at, declarer, received.fault.path, received.fault.problem);
|
|
92
85
|
if (!isPlainRecord(received.value))
|
|
93
|
-
throw unreadableDeclaration(at, declarer, "an entry", `it is ${
|
|
86
|
+
throw unreadableDeclaration(at, declarer, "an entry", `it is ${callerText(received.value)}, not an object`);
|
|
94
87
|
const retired = retiredValueMember(received.value, at);
|
|
95
88
|
if (retired !== undefined) {
|
|
96
89
|
throw declarationRefusal("config.credential_in_declaration", at, declarer, `declares ${retired.join(".")}, a member that carried values and is retired: a declaration names the peer and at most one opaque reference (${CREDENTIALS_MEMBER[at].join(".")}); the pieces a request carries are answered per send by the deployment's peer seat (RunnerDeps.peerSeat). The value is not repeated here.`);
|
|
@@ -115,20 +108,7 @@ function assertPeerSeatFor(entries, at, seat) {
|
|
|
115
108
|
throw missing;
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
return JSON.stringify(value) ?? String(value);
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
try {
|
|
124
|
-
return String(value);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
return `[unrepresentable ${typeof value}]`;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
const declarerNameOf = (name) => inlineUntrusted(typeof name === "string" ? JSON.stringify(name) : describeDeclared(name), 80);
|
|
111
|
+
const declarerNameOf = (name) => (typeof name === "string" ? inlineUntrusted(JSON.stringify(name), 80) : callerText(name));
|
|
132
112
|
export function judgeEntryToolAxes(copy, at) {
|
|
133
113
|
const { toolAxes: declaredAxes, ...rest } = copy;
|
|
134
114
|
const axes = readToolAxes(declaredAxes, at);
|
|
@@ -149,8 +129,9 @@ function deepFrozen(value) {
|
|
|
149
129
|
}
|
|
150
130
|
return value;
|
|
151
131
|
}
|
|
132
|
+
const FACES_PROBLEM_MAX = 400;
|
|
152
133
|
function toolFacesRefusal(name, problem) {
|
|
153
|
-
return codedError("config.tool_face_invalid", `${declarerWord("mcp")} ${name} declares toolFaces the engine cannot read: ${inlineUntrusted(problem,
|
|
134
|
+
return codedError("config.tool_face_invalid", `${declarerWord("mcp")} ${name} declares toolFaces the engine cannot read: ${inlineUntrusted(problem, FACES_PROBLEM_MAX)}. A per-tool face declaration is the deployment's own ` +
|
|
154
135
|
`narrowing (which argument names a tool's path, how a write is confined, which approval card and rule vocabulary the tool wears), so it is refused ` +
|
|
155
136
|
`rather than partly applied — a member dropped or a word defaulted would mount the tool without the protection its operator declared.`);
|
|
156
137
|
}
|
|
@@ -169,12 +150,25 @@ export function judgeEntrySessionMetaKey(copy) {
|
|
|
169
150
|
return { ok: true, entry: copy };
|
|
170
151
|
return { ok: false, error: codedError("config.invalid_argument", `${declarerWord("mcp")} ${declarerNameOf(copy.name)} declares ${inlineUntrusted(read.problem, 200)}. The key decides where the leg's session id rides on this server's requests, so it is refused rather than dropped or defaulted — a connector keyed on a session it never receives would share one state across every session.`) };
|
|
171
152
|
}
|
|
153
|
+
export function judgeEntryHostTransport(copy) {
|
|
154
|
+
const transport = copy.transport;
|
|
155
|
+
if (!isPlainRecord(transport) || transport["kind"] !== "host")
|
|
156
|
+
return { ok: true, entry: copy };
|
|
157
|
+
const extra = Object.keys(transport).find((member) => member !== "kind" && transport[member] !== undefined);
|
|
158
|
+
const problem = extra !== undefined
|
|
159
|
+
? `a host-supplied transport with the member ${inlineUntrusted(JSON.stringify(extra), 80)}: a host transport carries its kind alone — the host seat carries what each request needs, so a member here would read as in force while nothing carries it`
|
|
160
|
+
: copy.elicitation === true
|
|
161
|
+
? `elicitation on a host-supplied transport: the host seat answers the engine's requests only, so a server's question would have no way back`
|
|
162
|
+
: undefined;
|
|
163
|
+
return problem === undefined ? { ok: true, entry: copy } : { ok: false, error: codedError("config.invalid_argument", `${declarerWord("mcp")} ${declarerNameOf(copy.name)} declares ${problem}.`) };
|
|
164
|
+
}
|
|
172
165
|
export function judgeMcpEntryDeclarations(copy) {
|
|
173
166
|
const axes = judgeEntryToolAxes(copy, "mcp");
|
|
174
167
|
const faces = axes.ok ? judgeEntryToolFaces(axes.entry) : axes;
|
|
175
|
-
|
|
168
|
+
const metaKey = faces.ok ? judgeEntrySessionMetaKey(faces.entry) : faces;
|
|
169
|
+
return metaKey.ok ? judgeEntryHostTransport(metaKey.entry) : metaKey;
|
|
176
170
|
}
|
|
177
|
-
function declaredEntriesOf(declared, at) {
|
|
171
|
+
function declaredEntriesOf(declared, at, where) {
|
|
178
172
|
const field = at;
|
|
179
173
|
const received = receive(declared, CONFIG_RECEIPT_MODE);
|
|
180
174
|
let problem;
|
|
@@ -182,7 +176,7 @@ function declaredEntriesOf(declared, at) {
|
|
|
182
176
|
const list = received.value;
|
|
183
177
|
if (Array.isArray(list) && list !== declared)
|
|
184
178
|
return Array.from({ length: list.length }, (_, index) => list[index]);
|
|
185
|
-
problem = typeof list === "object" && list !== null ? "it is not an array" : `it is ${
|
|
179
|
+
problem = typeof list === "object" && list !== null ? "it is not an array" : `it is ${callerText(list)}`;
|
|
186
180
|
}
|
|
187
181
|
else {
|
|
188
182
|
const fault = declarationFaultOf(received.fault);
|
|
@@ -190,26 +184,65 @@ function declaredEntriesOf(declared, at) {
|
|
|
190
184
|
throw unreadableDeclaration(at, undefined, "an entry", fault.problem);
|
|
191
185
|
problem = fault.problem;
|
|
192
186
|
}
|
|
193
|
-
throw codedError("config.invalid_argument", `TaskSpec.${field} must be a readable array of ${declarerWord(at)} declarations; ${problem}. A list the engine cannot read ` +
|
|
187
|
+
throw codedError("config.invalid_argument", `${where ?? `TaskSpec.${field}`} must be a readable array of ${declarerWord(at)} declarations; ${problem}. A list the engine cannot read ` +
|
|
194
188
|
`is refused rather than read as "no entries" — the declared ${declarerWord(at)}s would otherwise be dropped without anyone being told.`);
|
|
195
189
|
}
|
|
196
|
-
function
|
|
197
|
-
const entries = declaredEntriesOf(declared, "a2a");
|
|
190
|
+
function validatedA2aEntries(entries) {
|
|
198
191
|
if (entries.length === 0)
|
|
199
192
|
return undefined;
|
|
200
193
|
return entries.map((entry) => {
|
|
201
|
-
const judged = judgeEntryToolAxes(
|
|
194
|
+
const judged = judgeEntryToolAxes(received(entry), "a2a");
|
|
202
195
|
if (!judged.ok)
|
|
203
196
|
throw judged.error;
|
|
204
197
|
return judged.entry;
|
|
205
198
|
});
|
|
206
199
|
}
|
|
207
|
-
|
|
208
|
-
|
|
200
|
+
const receiving = (read) => {
|
|
201
|
+
try {
|
|
202
|
+
return { read: read() };
|
|
203
|
+
}
|
|
204
|
+
catch (refused) {
|
|
205
|
+
return { refused };
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const received = (r) => {
|
|
209
|
+
if ("refused" in r)
|
|
210
|
+
throw r.refused;
|
|
211
|
+
return r.read;
|
|
212
|
+
};
|
|
213
|
+
export function receivePeerDeclarations(spec, deps) {
|
|
214
|
+
const locks = receiving(() => resolveLockedKeys(deps.lockedConfig));
|
|
215
|
+
if ("refused" in locks)
|
|
216
|
+
return { locks };
|
|
217
|
+
const list = (at) => {
|
|
218
|
+
if (locks.read.has(at))
|
|
219
|
+
return undefined;
|
|
220
|
+
const declared = receiving(() => spec[at]);
|
|
221
|
+
if ("refused" in declared)
|
|
222
|
+
return declared;
|
|
223
|
+
if (declared.read === undefined)
|
|
224
|
+
return undefined;
|
|
225
|
+
return receiving(() => declaredEntriesOf(declared.read, at).map((entry) => receiving(() => snapshotDeclaredEntry(entry, at))));
|
|
226
|
+
};
|
|
227
|
+
const mcp = list("mcp");
|
|
228
|
+
const a2a = list("a2a");
|
|
229
|
+
return { locks, ...(mcp !== undefined ? { mcp } : {}), ...(a2a !== undefined ? { a2a } : {}) };
|
|
230
|
+
}
|
|
231
|
+
export function receivedDeclarations(receipt) {
|
|
232
|
+
const copies = (r) => r === undefined || "refused" in r ? undefined : r.read.flatMap((entry) => ("read" in entry ? [entry.read] : []));
|
|
233
|
+
const mcp = copies(receipt.mcp);
|
|
234
|
+
const a2a = copies(receipt.a2a);
|
|
235
|
+
return { ...(mcp !== undefined ? { mcp } : {}), ...(a2a !== undefined ? { a2a } : {}) };
|
|
236
|
+
}
|
|
237
|
+
export function snapshotAndValidateMcpEntries(declared, where) {
|
|
238
|
+
return validatedMcpEntries(snapshotMcpEntries(declaredEntriesOf(declared, "mcp", where)));
|
|
239
|
+
}
|
|
240
|
+
function validatedMcpEntries(copies) {
|
|
241
|
+
return copies.map((copy) => {
|
|
209
242
|
const declared = copy.contentOrigin;
|
|
210
243
|
if (declared !== undefined && !isToolContentOrigin(declared)) {
|
|
211
244
|
throw codedError("config.mcp_content_class", `MCP server ${declarerNameOf(copy.name)} declares contentOrigin ` +
|
|
212
|
-
`${
|
|
245
|
+
`${callerText(declared)}, which is not one of ` +
|
|
213
246
|
`${TOOL_CONTENT_ORIGINS.map((v) => `"${v}"`).join(" | ")}. The declaration decides whether this server's tools ` +
|
|
214
247
|
`mark the session's memory externally exposed — a value this engine cannot read is refused at the door rather ` +
|
|
215
248
|
`than folded to a class, because folding it would let a deployment believe a declaration is in force while every ` +
|
|
@@ -221,8 +254,9 @@ function snapshotAndValidateMcpEntries(declared) {
|
|
|
221
254
|
return judged.entry;
|
|
222
255
|
});
|
|
223
256
|
}
|
|
224
|
-
export function preflightLockedConfig(spec, deps, enter = ENTER_AS_IS) {
|
|
225
|
-
const
|
|
257
|
+
export function preflightLockedConfig(spec, deps, enter = ENTER_AS_IS, receipt) {
|
|
258
|
+
const peers = receipt ?? receivePeerDeclarations(spec, { lockedConfig: deps.lockedConfig });
|
|
259
|
+
const lockedKeys = enter("deps", () => received(peers.locks));
|
|
226
260
|
enter("taskConfig", () => {
|
|
227
261
|
for (const key of lockedKeys) {
|
|
228
262
|
for (const field of LOCKED_KEY_REGISTRY[key].specFields) {
|
|
@@ -239,10 +273,8 @@ export function preflightLockedConfig(spec, deps, enter = ENTER_AS_IS) {
|
|
|
239
273
|
const policies = callerPolicySeats(task, deps, toolPolicyLocked);
|
|
240
274
|
enter(!toolPolicyLocked && task.toolPolicy != null ? "taskConfig" : "deps", () => assertNoRetiredToolPolicyKeys(policies.toolPolicy));
|
|
241
275
|
enter(!toolPolicyLocked && task.basePolicyForResumeEdit != null ? "taskConfig" : "deps", () => assertNoRetiredToolPolicyKeys(policies.basePolicyForResumeEdit));
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const declaredPeers = spec.a2a;
|
|
245
|
-
const a2a = declaredPeers === undefined ? undefined : enter("taskConfig", () => snapshotAndValidateA2aEntries(declaredPeers));
|
|
276
|
+
const mcp = lockedKeys.has("mcp") || peers.mcp === undefined ? undefined : enter("taskConfig", () => validatedMcpEntries(received(peers.mcp).map(received)));
|
|
277
|
+
const a2a = lockedKeys.has("a2a") || peers.a2a === undefined ? undefined : enter("taskConfig", () => validatedA2aEntries(received(peers.a2a)));
|
|
246
278
|
enter("taskConfig", () => {
|
|
247
279
|
assertPeerSeatFor(mcp, "mcp", deps.peerSeat);
|
|
248
280
|
assertPeerSeatFor(a2a, "a2a", deps.peerSeat);
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* lease/expiry cycles (a re-leased message keeps its number — dedup/ordering key). */
|
|
3
3
|
export interface MailboxMessage {
|
|
4
4
|
seq: number;
|
|
5
|
+
/** The identity the PRODUCER gave this record ({@link MailboxAppendMessage.id}); absent = it stated none. */
|
|
6
|
+
id?: string;
|
|
5
7
|
/** Sender display name, when the sender had one (SendMessage `senderName` — display only). */
|
|
6
8
|
from?: string;
|
|
7
9
|
content: string;
|
|
@@ -181,7 +183,7 @@ export declare const MAILBOX_TOMBSTONED_RECIPIENT_CODE = "mailbox.recipient_tomb
|
|
|
181
183
|
* A backend may raise the same code with a plain `Error` carrying `.code`; consumers branch on the
|
|
182
184
|
* string, not on this class (a cross-process/out-of-repo store cannot hand back an instance).
|
|
183
185
|
*/
|
|
184
|
-
export type MailboxStoreErrorCode = typeof MAILBOX_TOMBSTONED_RECIPIENT_CODE | typeof MAILBOX_INVALID_PEER_META_CODE | typeof MAILBOX_CROSS_PROCESS_UNSAFE_CODE | typeof MAILBOX_INVALID_DECISION_MOVE_CODE;
|
|
186
|
+
export type MailboxStoreErrorCode = typeof MAILBOX_TOMBSTONED_RECIPIENT_CODE | typeof MAILBOX_INVALID_PEER_META_CODE | typeof MAILBOX_CROSS_PROCESS_UNSAFE_CODE | typeof MAILBOX_INVALID_DECISION_MOVE_CODE | typeof MAILBOX_INVALID_RECORD_ID_CODE | typeof MAILBOX_DUPLICATE_RECORD_ID_CODE;
|
|
185
187
|
export declare class MailboxStoreError extends Error {
|
|
186
188
|
readonly code: MailboxStoreErrorCode;
|
|
187
189
|
constructor(code: MailboxStoreErrorCode, message: string);
|
|
@@ -195,6 +197,14 @@ export interface MailboxLease {
|
|
|
195
197
|
/** REF-D18: one appended mailbox message — the SINGLE shape the interface method and both the
|
|
196
198
|
* In-Memory and File implementations reference. */
|
|
197
199
|
export interface MailboxAppendMessage {
|
|
200
|
+
/**
|
|
201
|
+
* The record's identity, minted by its producer — a re-park of the same message carries the same
|
|
202
|
+
* one. While the box HOLDS a record under this id, an append under it is that record: identical on
|
|
203
|
+
* every {@link MAILBOX_REPLAY_FACETS} facet ⇒ the held `seq`, nothing written; any facet different ⇒
|
|
204
|
+
* refused with {@link MAILBOX_DUPLICATE_RECORD_ID_CODE}. Absent = the producer states no identity and
|
|
205
|
+
* every append is a new record (its `seq` is all it is known by). Validated by {@link readMailboxRecordId}.
|
|
206
|
+
*/
|
|
207
|
+
id?: string;
|
|
198
208
|
from?: string;
|
|
199
209
|
content: string;
|
|
200
210
|
sentAt: number;
|
|
@@ -203,6 +213,33 @@ export interface MailboxAppendMessage {
|
|
|
203
213
|
/** design/385 — see {@link MailboxMessage.peerMeta}; validated by {@link readMailboxPeerMeta}. */
|
|
204
214
|
peerMeta?: MailboxPeerMeta;
|
|
205
215
|
}
|
|
216
|
+
/** An `id` that is not a non-empty string of at most {@link MAILBOX_RECORD_ID_MAX_CHARS} characters. */
|
|
217
|
+
export declare const MAILBOX_INVALID_RECORD_ID_CODE = "mailbox.invalid_record_id";
|
|
218
|
+
/** An append under an `id` the box holds, whose record differs from the held one. */
|
|
219
|
+
export declare const MAILBOX_DUPLICATE_RECORD_ID_CODE = "mailbox.duplicate_record_id";
|
|
220
|
+
export declare const MAILBOX_RECORD_ID_MAX_CHARS = 1024;
|
|
221
|
+
/**
|
|
222
|
+
* What a record SAYS — the facets a repeat under one id is compared on. `sentAt` is not one of them: it
|
|
223
|
+
* is when a write happened, and a re-park of the same message happens later. Closed, in refusal order.
|
|
224
|
+
*/
|
|
225
|
+
export declare const MAILBOX_REPLAY_FACETS: readonly ["from", "content", "hopChain", "peerMeta"];
|
|
226
|
+
export type MailboxReplayFacet = (typeof MAILBOX_REPLAY_FACETS)[number];
|
|
227
|
+
/** Validate a record id at `append`, before any side effect. `undefined` = no identity stated. */
|
|
228
|
+
export declare function readMailboxRecordId(raw: unknown): string | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* ONE read of a caller's append: every member read once, validated (`peerMeta`, then `id`) and detached.
|
|
231
|
+
* A backend judges and persists THIS snapshot — never the caller's object again — so an accessor, or a
|
|
232
|
+
* mutation while the append waits for its lock, cannot make the record judged differ from the record stored.
|
|
233
|
+
*/
|
|
234
|
+
export declare function readMailboxAppend(msg: MailboxAppendMessage): MailboxAppendMessage;
|
|
235
|
+
/**
|
|
236
|
+
* THE append-by-identity judgment, the one every backend runs inside its write critical section
|
|
237
|
+
* (with `msg` already validated: `id` by {@link readMailboxRecordId}, `peerMeta` by {@link readMailboxPeerMeta}).
|
|
238
|
+
* Returns the held record's `seq` when `msg` replays it (the caller writes nothing), `undefined` when the
|
|
239
|
+
* box holds no record under `msg.id` (the caller appends), and throws {@link MAILBOX_DUPLICATE_RECORD_ID_CODE}
|
|
240
|
+
* naming the facets when a different record claims the id. A third-party backend calls this function too.
|
|
241
|
+
*/
|
|
242
|
+
export declare function judgeMailboxAppendById(held: readonly MailboxMessage[], msg: MailboxAppendMessage): number | undefined;
|
|
206
243
|
/**
|
|
207
244
|
* The pluggable mailbox seam (design/151 §7.1). Contract notes for implementations (file/pg):
|
|
208
245
|
* - `append` is durable-first (a returned seq means the message survives a crash); seq is monotonic
|
|
@@ -250,6 +287,13 @@ export interface MailboxAppendMessage {
|
|
|
250
287
|
* and a malformed value is REFUSED with `"mailbox.invalid_peer_meta"` before any side effect
|
|
251
288
|
* (`readMailboxPeerMeta` is the one validator; bundled backends call it first). T1 cases in
|
|
252
289
|
* `mailboxStoreContract` cover the pass trip, the refusal and the aliasing.
|
|
290
|
+
* - RECORD IDENTITY (every backend): `append` takes an optional producer-minted `id`, persists
|
|
291
|
+
* it and hands it back on `claimLease`. While the box holds a record under that id, an append under
|
|
292
|
+
* it is answered by {@link judgeMailboxAppendById} — the held `seq` for an identical record (nothing
|
|
293
|
+
* written), `"mailbox.duplicate_record_id"` for a different one — atomically with the seq allocation;
|
|
294
|
+
* a malformed id is refused with `"mailbox.invalid_record_id"` before any side effect. This is what
|
|
295
|
+
* makes re-asking a store whose reply was lost safe: a rejected append is not proof that nothing was
|
|
296
|
+
* written. The box answers for what it HOLDS — once a record is acked its id is free again.
|
|
253
297
|
* - CROSS-PROCESS SAFETY (design/385, optional capability declared on the store): the session-box
|
|
254
298
|
* drain shares ONE box between several OS processes. A backend that is correct under that sharing —
|
|
255
299
|
* seq minted once across processes, lease/ack never crossing, one process's housekeeping never
|
|
@@ -150,6 +150,54 @@ export class MailboxStoreError extends Error {
|
|
|
150
150
|
this.name = "MailboxStoreError";
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
export const MAILBOX_INVALID_RECORD_ID_CODE = "mailbox.invalid_record_id";
|
|
154
|
+
export const MAILBOX_DUPLICATE_RECORD_ID_CODE = "mailbox.duplicate_record_id";
|
|
155
|
+
export const MAILBOX_RECORD_ID_MAX_CHARS = 1024;
|
|
156
|
+
export const MAILBOX_REPLAY_FACETS = Object.freeze(["from", "content", "hopChain", "peerMeta"]);
|
|
157
|
+
export function readMailboxRecordId(raw) {
|
|
158
|
+
if (raw === undefined)
|
|
159
|
+
return undefined;
|
|
160
|
+
if (typeof raw !== "string" || raw === "" || raw.length > MAILBOX_RECORD_ID_MAX_CHARS) {
|
|
161
|
+
throw new MailboxStoreError(MAILBOX_INVALID_RECORD_ID_CODE, `MailboxStore.append: id must be a non-empty string of at most ${MAILBOX_RECORD_ID_MAX_CHARS} characters`);
|
|
162
|
+
}
|
|
163
|
+
return raw;
|
|
164
|
+
}
|
|
165
|
+
export function readMailboxAppend(msg) {
|
|
166
|
+
const peerMeta = readMailboxPeerMeta(msg.peerMeta);
|
|
167
|
+
const id = readMailboxRecordId(msg.id);
|
|
168
|
+
const from = msg.from;
|
|
169
|
+
const content = msg.content;
|
|
170
|
+
const sentAt = msg.sentAt;
|
|
171
|
+
const hopChain = msg.hopChain;
|
|
172
|
+
return {
|
|
173
|
+
...(id !== undefined ? { id } : {}),
|
|
174
|
+
...(from !== undefined ? { from } : {}),
|
|
175
|
+
content,
|
|
176
|
+
sentAt,
|
|
177
|
+
...(hopChain !== undefined ? { hopChain: [...hopChain] } : {}),
|
|
178
|
+
...(peerMeta !== undefined ? { peerMeta } : {}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function facetSpelling(v) {
|
|
182
|
+
if (v === undefined || v === null)
|
|
183
|
+
return "-";
|
|
184
|
+
if (typeof v !== "object")
|
|
185
|
+
return JSON.stringify(v);
|
|
186
|
+
if (Array.isArray(v))
|
|
187
|
+
return `[${Array.from(v, facetSpelling).join(",")}]`;
|
|
188
|
+
return `{${Object.keys(v).filter((k) => v[k] !== undefined).sort().map((k) => `${JSON.stringify(k)}:${facetSpelling(v[k])}`).join(",")}}`;
|
|
189
|
+
}
|
|
190
|
+
export function judgeMailboxAppendById(held, msg) {
|
|
191
|
+
if (msg.id === undefined)
|
|
192
|
+
return undefined;
|
|
193
|
+
const prior = held.find((m) => m.id === msg.id);
|
|
194
|
+
if (prior === undefined)
|
|
195
|
+
return undefined;
|
|
196
|
+
const differs = MAILBOX_REPLAY_FACETS.filter((f) => facetSpelling(prior[f]) !== facetSpelling(msg[f]));
|
|
197
|
+
if (differs.length === 0)
|
|
198
|
+
return prior.seq;
|
|
199
|
+
throw new MailboxStoreError(MAILBOX_DUPLICATE_RECORD_ID_CODE, `MailboxStore.append: the box already holds a different record under this id (it differs in: ${differs.join(", ")}) — a new message takes a new id; an identical repeat would have been a replay`);
|
|
200
|
+
}
|
|
153
201
|
export function mailboxCrossProcessMountVerdict(store) {
|
|
154
202
|
const declared = store.crossProcessSafe;
|
|
155
203
|
if (declared === true)
|
|
@@ -199,17 +247,13 @@ export class InMemoryMailboxStore {
|
|
|
199
247
|
async append(scope, handle, msg) {
|
|
200
248
|
if (scope === undefined || scope === "")
|
|
201
249
|
throw new Error("MailboxStore.append: refusing a message without a scope");
|
|
202
|
-
const
|
|
250
|
+
const record = readMailboxAppend(msg);
|
|
203
251
|
const b = this.box(scope, handle);
|
|
252
|
+
const held = judgeMailboxAppendById(b.messages, record);
|
|
253
|
+
if (held !== undefined)
|
|
254
|
+
return held;
|
|
204
255
|
const seq = b.nextSeq++;
|
|
205
|
-
b.messages.push({
|
|
206
|
-
seq,
|
|
207
|
-
...(msg.from !== undefined ? { from: msg.from } : {}),
|
|
208
|
-
content: msg.content,
|
|
209
|
-
sentAt: msg.sentAt,
|
|
210
|
-
...(msg.hopChain !== undefined ? { hopChain: [...msg.hopChain] } : {}),
|
|
211
|
-
...(peerMeta !== undefined ? { peerMeta } : {}),
|
|
212
|
-
});
|
|
256
|
+
b.messages.push({ seq, ...record });
|
|
213
257
|
return seq;
|
|
214
258
|
}
|
|
215
259
|
async claimLease(scope, handle, owner, ttlMs, now = Date.now()) {
|
|
@@ -35,8 +35,8 @@ export type SessionMetaKeyReading = {
|
|
|
35
35
|
* prefix of dot-separated labels and a slash, then a name — the format is what a conforming server accepts, and it keeps out names such
|
|
36
36
|
* as `__proto__` that the SDK's own request parse drops) that names no `_meta` member of anyone else's: not the SDK's `progressToken`,
|
|
37
37
|
* not a key under the engine's `sema/` namespace, not under a prefix MCP reserves (the prefix is the text before the first `/`; its
|
|
38
|
-
* labels are DNS labels, so the second one is compared with case folded).
|
|
39
|
-
* text,
|
|
38
|
+
* labels are DNS labels, so the second one is compared with case folded). A refusal says which rule the key breaks and never the key: the
|
|
39
|
+
* key is the declaration's own text, shown in the one caller's-text shape (`callerText`: the redaction mark and its length).
|
|
40
40
|
*/
|
|
41
41
|
export declare function judgeSessionMetaKey(value: unknown): SessionMetaKeyReading;
|
|
42
42
|
/**
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { types } from "node:util";
|
|
3
3
|
import { isPlainRecord } from "./mods/kernel/receive.js";
|
|
4
|
-
import { dataKind } from "./mcp-server-spec.js";
|
|
4
|
+
import { callerText, dataKind } from "./mcp-server-spec.js";
|
|
5
5
|
export const MCP_TOOL_USE_ID_META_KEY = "sema/toolUseId";
|
|
6
6
|
export const MCP_REQUEST_META_KEY = "sema/requestMeta";
|
|
7
7
|
export const MCP_REQUEST_META_MAX_BYTES = 262_144;
|
|
8
8
|
const kindOf = (v) => v === null ? "null" : Array.isArray(v) ? "a list" : typeof v === "object" ? (types.isProxy(v) ? "a Proxy" : "an object that is not a plain record") : `a ${typeof v}`;
|
|
9
|
-
const named = (key) => JSON.stringify(key.length > 60 ? `${key.slice(0, 60)}…` : key);
|
|
10
9
|
export function judgeRequestMeta(value) {
|
|
11
10
|
if (value === undefined)
|
|
12
11
|
return { meta: undefined };
|
|
@@ -23,10 +22,10 @@ export function judgeRequestMeta(value) {
|
|
|
23
22
|
for (const key of Object.getOwnPropertyNames(descriptors)) {
|
|
24
23
|
const d = descriptors[key];
|
|
25
24
|
if (!Object.hasOwn(d, "value") || d.enumerable !== true)
|
|
26
|
-
return { problem: `requestMeta's member ${
|
|
25
|
+
return { problem: `requestMeta's member ${callerText(key)} is not an enumerable data property (a getter is never run)` };
|
|
27
26
|
const v = d.value;
|
|
28
27
|
if (typeof v !== "string")
|
|
29
|
-
return { problem: `requestMeta's member ${
|
|
28
|
+
return { problem: `requestMeta's member ${callerText(key)} is ${kindOf(v)}, not a string` };
|
|
30
29
|
bytes += Buffer.byteLength(key, "utf8") + Buffer.byteLength(v, "utf8");
|
|
31
30
|
Object.defineProperty(copy, key, { value: v, enumerable: true, writable: false, configurable: false });
|
|
32
31
|
members += 1;
|
|
@@ -57,20 +56,20 @@ export function judgeSessionMetaKey(value) {
|
|
|
57
56
|
if (value === "")
|
|
58
57
|
return { problem: "sessionMetaKey is the empty string; it takes a non-empty string" };
|
|
59
58
|
if (value.length > MCP_SESSION_META_KEY_MAX_CHARS)
|
|
60
|
-
return { problem: `sessionMetaKey
|
|
59
|
+
return { problem: `sessionMetaKey is ${value.length} characters; the most is ${MCP_SESSION_META_KEY_MAX_CHARS}` };
|
|
61
60
|
const slash = value.indexOf("/");
|
|
62
61
|
const labels = slash === -1 ? [] : value.slice(0, slash).split(".");
|
|
63
62
|
if (!labels.every((label) => META_LABEL.test(label)))
|
|
64
|
-
return { problem: `sessionMetaKey ${
|
|
63
|
+
return { problem: `sessionMetaKey ${callerText(value)} has a prefix that is not dot-separated labels (a label starts with a letter, ends with a letter or digit, and holds letters, digits and hyphens) followed by a slash` };
|
|
65
64
|
if (!META_NAME.test(value.slice(slash + 1)))
|
|
66
|
-
return { problem: `sessionMetaKey ${
|
|
65
|
+
return { problem: `sessionMetaKey ${callerText(value)} has a name that does not begin and end with a letter or digit, or holds a character other than letters, digits, hyphen, underscore and dot` };
|
|
67
66
|
if (value === SDK_PROGRESS_TOKEN_KEY)
|
|
68
|
-
return { problem: `sessionMetaKey ${
|
|
67
|
+
return { problem: `sessionMetaKey ${callerText(value)} is the key the MCP SDK writes for its own progress token` };
|
|
69
68
|
if (value.startsWith(ENGINE_META_NAMESPACE))
|
|
70
|
-
return { problem: `sessionMetaKey ${
|
|
69
|
+
return { problem: `sessionMetaKey ${callerText(value)} is under the engine's own "${ENGINE_META_NAMESPACE}" namespace` };
|
|
71
70
|
const second = labels[1]?.toLowerCase();
|
|
72
71
|
if (second !== undefined && MCP_RESERVED_LABELS.includes(second))
|
|
73
|
-
return { problem: `sessionMetaKey ${
|
|
72
|
+
return { problem: `sessionMetaKey ${callerText(value)} is under a prefix MCP reserves (second label "${second}")` };
|
|
74
73
|
return { key: value };
|
|
75
74
|
}
|
|
76
75
|
export function mcpCallMeta(toolUseId, requestMeta, sessionMetaKey, sessionId) {
|