@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
|
@@ -6,12 +6,13 @@ import { canAccessAgentRecord, } from "./background-agent-store.js";
|
|
|
6
6
|
import { delimitUntrusted } from "./untrusted-text.js";
|
|
7
7
|
import { createSafeNotifier } from "./safe-notify.js";
|
|
8
8
|
import { stripCwdSentinel } from "../tools/fs/fs-shared.js";
|
|
9
|
+
import { persistTaskArtifact, taskArtifactOriginOf } from "./tool-result-store.js";
|
|
9
10
|
import { registerMonitorLane, pollMonitorLane, stopMonitorLane } from "./task-registry-monitor.js";
|
|
10
11
|
import { registerWorkflowLane, pollWorkflowLane, stopWorkflowLane } from "./task-registry-workflow.js";
|
|
11
|
-
import { mintCompletionId, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, DURABLE_AGENT_HANDLE_RE, } from "./task-registry-shared.js";
|
|
12
|
+
import { mintCompletionId, taskReadHandleText, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, DURABLE_AGENT_HANDLE_RE, } from "./task-registry-shared.js";
|
|
12
13
|
export { normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName } from "./task-registry-shared.js";
|
|
13
14
|
import { TASK_OUTPUT_TOOL_NAME, TASK_STOP_TOOL_NAME, TASK_OUTPUT_MISSING_ID_MESSAGE, TASK_STOP_MISSING_ID_MESSAGE, TASK_STOP_PARAMS, resolveTaskIdArg, REGISTRY_TASK_TOOL_CAPS, composeTaskOutputDescription, composeTaskOutputParams, composeTaskStopDescription, } from "./task-tool-shape.js";
|
|
14
|
-
import { durableAgentArmedLane, durableAgentRowProbeLane, beginDurableClaimLane, endDurableClaimLane, reapDurableAgentsLane, noteBackgroundAgentActivityLane, reapStaleSessionBackgroundAgentsLane, releaseDurableTranscriptAnchorLane, bindBackgroundAgentSessionLane, registerBackgroundAgentLane, recordBackgroundAgentOrgAdmissionLane, parkBackgroundAgentLane, reconcileParkedAgentsLane, claimParkedAgentLane, rollbackParkedClaimLane, consumeParkedFlipLane, finalizeParkedResumeLane, settleBackgroundAgentLane, abortBackgroundAgentsForOwnerLane, serveDurableAgentRowLane, resolveBackgroundAgentByNameLane, backgroundAgentCycleSeqLane, activeDelegationHandlesLane, markRetainedContinuationLane, reviveBackgroundAgentLane, settleRevivedAgentLane, unmarkRetainedContinuationLane, attachAgentNotifyLane, deliverToRunningAgentLane, runningBackgroundAgentLabelsLane, runningAgentFooterLane, notFoundRunningAgentsTail, pollBackgroundAgentLane, stopBackgroundAgentLane, } from "./task-registry-agent.js";
|
|
15
|
+
import { durableAgentArmedLane, durableAgentRowProbeLane, beginDurableClaimLane, endDurableClaimLane, reapDurableAgentsLane, noteBackgroundAgentActivityLane, reapStaleSessionBackgroundAgentsLane, releaseDurableTranscriptAnchorLane, bindBackgroundAgentSessionLane, childSessionAnchorOf, registerBackgroundAgentLane, recordBackgroundAgentOrgAdmissionLane, parkBackgroundAgentLane, reconcileParkedAgentsLane, claimParkedAgentLane, rollbackParkedClaimLane, consumeParkedFlipLane, finalizeParkedResumeLane, settleBackgroundAgentLane, abortBackgroundAgentsForOwnerLane, serveDurableAgentRowLane, resolveBackgroundAgentByNameLane, backgroundAgentCycleSeqLane, activeDelegationHandlesLane, markRetainedContinuationLane, reviveBackgroundAgentLane, settleRevivedAgentLane, unmarkRetainedContinuationLane, attachAgentNotifyLane, deliverToRunningAgentLane, runningBackgroundAgentLabelsLane, runningAgentFooterLane, notFoundRunningAgentsTail, pollBackgroundAgentLane, stopBackgroundAgentLane, } from "./task-registry-agent.js";
|
|
15
16
|
import { mountRuleFace, toolFace } from "./tool-catalog-entries.js";
|
|
16
17
|
import { thrownText } from "./thrown-value.js";
|
|
17
18
|
import { agentStateSourceOfHandle, agentStateSourceOfRecord, agentStateSummary, readAgentState } from "./agent-state.js";
|
|
@@ -81,10 +82,29 @@ async function drainBashTailBestEffort(handle) {
|
|
|
81
82
|
catch {
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
function commandRecordSink(rowOf, record, guarded, sink) {
|
|
86
|
+
return (n) => {
|
|
87
|
+
const row = rowOf(n.task_id);
|
|
88
|
+
if ((row?.type !== "background_bash" && row?.type !== "monitor") || n.status === "event")
|
|
89
|
+
return sink(n);
|
|
90
|
+
const gap = row.outputFile === undefined ? "missing" : row.spool?.mirrorFailed === true ? "incomplete" : undefined;
|
|
91
|
+
if (gap === undefined)
|
|
92
|
+
return sink(n);
|
|
93
|
+
const retained = row.spool !== undefined && row.spool.stdout.length + row.spool.stderr.length > 0 ? row.spool : undefined;
|
|
94
|
+
if (row.taskArtifacts === undefined || retained === undefined)
|
|
95
|
+
return sink(gap === "incomplete" ? { ...n, summary: n.summary + commandRecordGapNote(row, gap, undefined) } : n);
|
|
96
|
+
const body = renderSpoolBody(retained, { running: false, handleStatus: row.status, shape: (text) => text, rolledExtraClause: "", drainNote: "" });
|
|
97
|
+
void persistTaskArtifact(row.taskArtifacts, row.id, body).then((artifact) => {
|
|
98
|
+
const ref = artifact.kind === "stored" ? artifact.ref : undefined;
|
|
99
|
+
if (ref !== undefined)
|
|
100
|
+
record(row.id, ref);
|
|
101
|
+
guarded(() => sink(ref === undefined && gap === "missing" ? n : { ...n, summary: n.summary + commandRecordGapNote(row, gap, ref) }));
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function commandRecordGapNote(row, gap, ref) {
|
|
106
|
+
const head = gap === "incomplete" ? ` [!] Its output file ${row.outputFile} is incomplete (an append failed) — do not read it as the whole output` : " [!] No output file holds its output (the file could not be created)";
|
|
107
|
+
return ref === undefined ? `${head}.` : `${head}; what the engine retained (its head and tail, any gap stated) is stored: read it with ReadToolResult (ref "${ref}").`;
|
|
88
108
|
}
|
|
89
109
|
function explicitStopBashTerminalNote(handle, alreadyGone) {
|
|
90
110
|
const resultText = handle.spool !== undefined ? bashTerminalResult(handle.spool) : "";
|
|
@@ -98,7 +118,7 @@ function explicitStopBashTerminalNote(handle, alreadyGone) {
|
|
|
98
118
|
...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
|
|
99
119
|
status: "killed",
|
|
100
120
|
...(handle.stoppedBy !== undefined ? { stoppedBy: handle.stoppedBy } : {}),
|
|
101
|
-
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — ${detail}${
|
|
121
|
+
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — ${detail}${handle.spool !== undefined ? droppedGapNote(handle.spool) : ""}`,
|
|
102
122
|
...(resultText.length > 0 ? { result: resultText, partial: true } : {}),
|
|
103
123
|
...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
|
|
104
124
|
});
|
|
@@ -146,8 +166,8 @@ export class TaskRegistry {
|
|
|
146
166
|
async reapDurableAgents(scope, deps, policy) {
|
|
147
167
|
return reapDurableAgentsLane(this.core, scope, deps, policy);
|
|
148
168
|
}
|
|
149
|
-
releaseDurableTranscriptAnchor(id) {
|
|
150
|
-
return releaseDurableTranscriptAnchorLane(this.core, id);
|
|
169
|
+
releaseDurableTranscriptAnchor(id, sessionId) {
|
|
170
|
+
return releaseDurableTranscriptAnchorLane(this.core, id, sessionId);
|
|
151
171
|
}
|
|
152
172
|
bindBackgroundAgentSession(id, sessionId) {
|
|
153
173
|
return bindBackgroundAgentSessionLane(this.core, id, sessionId);
|
|
@@ -247,8 +267,8 @@ export class TaskRegistry {
|
|
|
247
267
|
runningBackgroundAgentLabels(access) {
|
|
248
268
|
return runningBackgroundAgentLabelsLane(this.core, access);
|
|
249
269
|
}
|
|
250
|
-
async pollBackgroundAgent(handle, deadline, signal,
|
|
251
|
-
return pollBackgroundAgentLane(handle, deadline, signal,
|
|
270
|
+
async pollBackgroundAgent(handle, deadline, signal, toolResultStore, sessionId, checkpointSeat) {
|
|
271
|
+
return pollBackgroundAgentLane(handle, deadline, signal, toolResultStore, sessionId, checkpointSeat);
|
|
252
272
|
}
|
|
253
273
|
async stopBackgroundAgent(handle) {
|
|
254
274
|
return stopBackgroundAgentLane(this.core, handle);
|
|
@@ -273,6 +293,7 @@ export class TaskRegistry {
|
|
|
273
293
|
if (this.handles.has(id))
|
|
274
294
|
throw new Error(`TaskRegistry: task id already registered: ${id}`);
|
|
275
295
|
const now = input.now ?? Date.now();
|
|
296
|
+
const onTerminal = input.onTerminal !== undefined ? this.commandRecordSink(input.onTerminal) : undefined;
|
|
276
297
|
this.handles.set(id, {
|
|
277
298
|
id,
|
|
278
299
|
type: "background_bash",
|
|
@@ -286,18 +307,22 @@ export class TaskRegistry {
|
|
|
286
307
|
updatedAt: now,
|
|
287
308
|
env: input.env,
|
|
288
309
|
shellId: input.shellId,
|
|
289
|
-
...(
|
|
310
|
+
...(onTerminal !== undefined ? { onTerminal } : {}),
|
|
290
311
|
...(input.outputFile !== undefined ? { outputFile: input.outputFile } : {}),
|
|
312
|
+
...(input.taskArtifacts !== undefined ? { taskArtifacts: input.taskArtifacts } : {}),
|
|
291
313
|
...(retainsBackgroundProcesses({ env: envDeclaresRetain(input.env), task: input.retainBackgroundProcesses === true }) ? { retained: true } : {}),
|
|
292
314
|
...(input.retainBackgroundProcesses !== undefined ? { retainStatedAtLaunch: true } : {}),
|
|
293
315
|
});
|
|
294
|
-
if (
|
|
295
|
-
this.startBashWatcher(id,
|
|
316
|
+
if (onTerminal)
|
|
317
|
+
this.startBashWatcher(id, onTerminal);
|
|
296
318
|
return id;
|
|
297
319
|
}
|
|
320
|
+
commandRecordSink(sink) {
|
|
321
|
+
return commandRecordSink((id) => this.handles.get(id), (id, ref) => this.recordArtifactRef(id, ref, 0), (send) => this.notifier.notify(send, "taskRegistry.commandRecordSink"), sink);
|
|
322
|
+
}
|
|
298
323
|
isBackgroundOutputFile(canonicalPath, access, env) {
|
|
299
324
|
for (const handle of this.handles.values()) {
|
|
300
|
-
if (handle.type !== "background_bash" || handle.outputFile === undefined)
|
|
325
|
+
if ((handle.type !== "background_bash" && handle.type !== "monitor") || handle.outputFile === undefined)
|
|
301
326
|
continue;
|
|
302
327
|
if (handle.env !== env)
|
|
303
328
|
continue;
|
|
@@ -399,6 +424,22 @@ export class TaskRegistry {
|
|
|
399
424
|
getCompletionId(id) {
|
|
400
425
|
return this.handles.get(id)?.completionId;
|
|
401
426
|
}
|
|
427
|
+
recordArtifactRef(id, ref, cycle) {
|
|
428
|
+
const h = this.handles.get(id);
|
|
429
|
+
if (h === undefined)
|
|
430
|
+
return;
|
|
431
|
+
if ((h.type === "background_agent" ? (h.reviveCycle ?? 0) : 0) !== cycle)
|
|
432
|
+
return;
|
|
433
|
+
h.artifactRef = ref;
|
|
434
|
+
}
|
|
435
|
+
artifactBoundaryLegs(ref, access, tree) {
|
|
436
|
+
const id = taskArtifactOriginOf(ref);
|
|
437
|
+
return id === undefined ? { legs: [] } : this.boundaryLegsOf(id, access, "output", tree);
|
|
438
|
+
}
|
|
439
|
+
readHandleOf(id, access) {
|
|
440
|
+
const h = this.handles.get(id);
|
|
441
|
+
return h !== undefined && canAccess(h, access) ? taskReadHandleText(h) : undefined;
|
|
442
|
+
}
|
|
402
443
|
markStopSourceForOwner(access, source, opts) {
|
|
403
444
|
let marked = 0;
|
|
404
445
|
for (const handle of this.handles.values()) {
|
|
@@ -470,7 +511,7 @@ export class TaskRegistry {
|
|
|
470
511
|
...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
|
|
471
512
|
status: "killed",
|
|
472
513
|
stoppedBy: handle.stoppedBy,
|
|
473
|
-
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — killed before completion (${clause(handle.stoppedBy)})${killFailed ? ` — kill attempt reported ${kill.ok ? "" : kill.error.code}: the process may still be terminating; the environment teardown retries` : ""}
|
|
514
|
+
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — killed before completion (${clause(handle.stoppedBy)})${killFailed ? ` — kill attempt reported ${kill.ok ? "" : kill.error.code}: the process may still be terminating; the environment teardown retries` : ""}`,
|
|
474
515
|
...(resultText.length > 0 ? { result: resultText, partial: true } : {}),
|
|
475
516
|
...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
|
|
476
517
|
}));
|
|
@@ -765,7 +806,7 @@ export class TaskRegistry {
|
|
|
765
806
|
...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
|
|
766
807
|
...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
|
|
767
808
|
status: "failed",
|
|
768
|
-
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (${r.error.message}); no further output will arrive
|
|
809
|
+
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (${r.error.message}); no further output will arrive.`,
|
|
769
810
|
...(lostResult.length > 0 ? { result: lostResult } : {}),
|
|
770
811
|
...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
|
|
771
812
|
}));
|
|
@@ -813,7 +854,6 @@ export class TaskRegistry {
|
|
|
813
854
|
? `${terminalTaskSummary("bash", desc, "killed")} — timed out after ${r.value.timeoutSec}s (its own background time budget); the process was killed`
|
|
814
855
|
: `${terminalTaskSummary("bash", desc, "killed")} — timed out (its own background time budget); the process was killed`
|
|
815
856
|
: `${terminalTaskSummary("bash", desc, handle.status === "completed" ? "completed" : handle.status === "killed" ? "killed" : "failed")} — ${r.value.status}`) +
|
|
816
|
-
bashMirrorGapNote(handle) +
|
|
817
857
|
droppedGapNote(spool),
|
|
818
858
|
...(resultText.length > 0 ? { result: resultText } : {}),
|
|
819
859
|
...(handle.status === "killed" && resultText.length > 0 ? { partial: true } : {}),
|
|
@@ -837,7 +877,7 @@ export class TaskRegistry {
|
|
|
837
877
|
...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
|
|
838
878
|
...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
|
|
839
879
|
status: "failed",
|
|
840
|
-
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (poll failed: ${thrownText(e)}); no further output will arrive
|
|
880
|
+
summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (poll failed: ${thrownText(e)}); no further output will arrive.`,
|
|
841
881
|
...(crashedResult.length > 0 ? { result: crashedResult } : {}),
|
|
842
882
|
...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
|
|
843
883
|
}));
|
|
@@ -859,7 +899,7 @@ export class TaskRegistry {
|
|
|
859
899
|
return out;
|
|
860
900
|
}
|
|
861
901
|
registerMonitor(input) {
|
|
862
|
-
return registerMonitorLane(this.core, input);
|
|
902
|
+
return registerMonitorLane(this.core, input.onEvent !== undefined ? { ...input, onEvent: this.commandRecordSink(input.onEvent) } : input);
|
|
863
903
|
}
|
|
864
904
|
registerWorkflow(input) {
|
|
865
905
|
return registerWorkflowLane(this.core, input);
|
|
@@ -883,7 +923,7 @@ export class TaskRegistry {
|
|
|
883
923
|
if (handle.type === "background_bash")
|
|
884
924
|
return this.pollBackgroundBash(handle, taskId, access, opts.filter, deadline, opts.signal);
|
|
885
925
|
if (handle.type === "background_agent")
|
|
886
|
-
return this.pollBackgroundAgent(handle, deadline, opts.signal, opts.
|
|
926
|
+
return this.pollBackgroundAgent(handle, deadline, opts.signal, opts.toolResultStore, access.sessionId, opts.checkpointSeat);
|
|
887
927
|
if (handle.type === "monitor")
|
|
888
928
|
return this.pollMonitor(handle, opts.filter, deadline, opts.signal);
|
|
889
929
|
return this.pollWorkflow(handle, access, deadline, opts.signal);
|
|
@@ -1031,6 +1071,7 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
|
|
|
1031
1071
|
for (const h of this.handles.values()) {
|
|
1032
1072
|
if (!canAccess(h, access))
|
|
1033
1073
|
continue;
|
|
1074
|
+
const childSession = childSessionAnchorOf(h);
|
|
1034
1075
|
out.push({
|
|
1035
1076
|
task_id: h.id,
|
|
1036
1077
|
type: h.type,
|
|
@@ -1039,6 +1080,7 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
|
|
|
1039
1080
|
...((h.type === "background_bash" || h.type === "monitor") && shellRowRetained(h) ? { retained: true } : {}),
|
|
1040
1081
|
...(h.description !== undefined ? { description: h.description } : {}),
|
|
1041
1082
|
...(h.toolUseId !== undefined ? { toolUseId: h.toolUseId } : {}),
|
|
1083
|
+
...(childSession !== undefined ? { sessionId: childSession } : {}),
|
|
1042
1084
|
createdAt: h.createdAt,
|
|
1043
1085
|
updatedAt: h.updatedAt,
|
|
1044
1086
|
});
|
|
@@ -1277,7 +1319,7 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
|
|
|
1277
1319
|
const retrieval_status = r.error.code === "timeout" ? "timeout" : "not_ready";
|
|
1278
1320
|
return {
|
|
1279
1321
|
content: `Error (TaskStop): ${r.error.message} — the kill did not land; the process may still be running.` +
|
|
1280
|
-
(restored ? " Its watcher keeps running:
|
|
1322
|
+
(restored ? " Its watcher keeps running: its output file keeps filling and the completion notification will still fire." : " It has no watcher, so no completion notification will follow."),
|
|
1281
1323
|
details: { task_id: handle.id, type: "background_bash", status: handle.status, retrieval_status, error: r.error.code },
|
|
1282
1324
|
isError: true,
|
|
1283
1325
|
};
|
|
@@ -1354,7 +1396,6 @@ export function createTaskOutputTool(opts) {
|
|
|
1354
1396
|
block: args.block !== false,
|
|
1355
1397
|
timeoutMs: effectiveTimeoutMs,
|
|
1356
1398
|
signal: ctx.signal,
|
|
1357
|
-
oneShot: opts.oneShot,
|
|
1358
1399
|
toolResultStore: opts.toolResultStore,
|
|
1359
1400
|
checkpointSeat: opts.checkpointSeat,
|
|
1360
1401
|
});
|
|
@@ -419,7 +419,7 @@ export interface TaskResult {
|
|
|
419
419
|
* of silence. Present only when at least one applies (absent = nothing to disclose), so a consumer that
|
|
420
420
|
* ignores the field is unchanged. A rewind that could NOT be delivered as asked is NOT a note — it is a
|
|
421
421
|
* terminal failure (`rewind_snapshot.unresolvable` / `rewind.store_unconfigured` /
|
|
422
|
-
* `rewind.restore_failed` / `rewind.invalid_spec` /
|
|
422
|
+
* `rewind.restore_failed` / `rewind.invalid_spec` /
|
|
423
423
|
* `rewind.conflicting_targets` / `rewind.child_scope_unsupported` / `rewind.capture_disabled`).
|
|
424
424
|
*
|
|
425
425
|
* - `conversation_only` — {@link TaskSpec.resumeAt} branched the transcript WITHOUT
|
|
@@ -776,11 +776,8 @@ export interface TaskResult {
|
|
|
776
776
|
* mechanism engaged this leg; absent = none did (byte-compatible).
|
|
777
777
|
*/
|
|
778
778
|
mechanisms?: {
|
|
779
|
-
/** design/132:
|
|
780
|
-
|
|
781
|
-
/** oracle-grounding gate (opus LOW 复审, additive): HOW MANY final-verification injections
|
|
782
|
-
* fired this run — 1 = the R9 one-shot only, 2 = R9 + the grounding re-entry (hard cap).
|
|
783
|
-
* Present iff `finalVerifyInjected` is (the boolean stays for compatibility, RL-1336-finalverify-bool). */
|
|
779
|
+
/** design/132: HOW MANY natural-end final-verification injections fired this run — 1 = the R9 one-shot
|
|
780
|
+
* only, 2 = R9 + the oracle-grounding re-entry (hard cap). Present iff at least one fired. */
|
|
784
781
|
finalVerifyInjections?: number;
|
|
785
782
|
/** design/133: number of attachment blocks injected this run — turn-boundary bundles
|
|
786
783
|
* (todo/task reminders, changed-files notes, plan-mode re-reminders, listing drift frames;
|
|
@@ -874,8 +871,6 @@ export interface TaskResult {
|
|
|
874
871
|
* subagent cost (it lands in `nested`, see assemble-result.ts), so `nestedSubagentMicroUsd` sits
|
|
875
872
|
* OUTSIDE the costMicroUsd identity, not inside it (measured correction: the previous wording
|
|
876
873
|
* `llmRoot + nested + compaction === costMicroUsd` only held when nested was 0).
|
|
877
|
-
* (`memoryConsolidationMicroUsd` is a separate, budget-excluded line, permanently 0 since the
|
|
878
|
-
* runner-integrated consolidation pass was retired — design/157 B19 — and NOT part of any identity).
|
|
879
874
|
* Present whenever stats are assembled, EXCEPT when `costMicroUsd` is absent for unpriced spend
|
|
880
875
|
* (RB-368) — the taxonomy would partition a fabricated total, so it is omitted together with it.
|
|
881
876
|
*/
|
|
@@ -889,10 +884,6 @@ export interface TaskResult {
|
|
|
889
884
|
llmRootMicroUsd: number;
|
|
890
885
|
/** Delegated sub-agent (nested) LLM cost (micro-USD) = `nested?.costMicroUsd ?? 0`. */
|
|
891
886
|
nestedSubagentMicroUsd: number;
|
|
892
|
-
/** Post-task memory-consolidation LLM cost (micro-USD). Permanently 0 since design/157 B19 retired
|
|
893
|
-
* the runner-integrated consolidation pass (kept: public stats contract; an engine-plane re-mount —
|
|
894
|
-
* design/138 §7 — would fill it). A separate, budget-excluded line. */
|
|
895
|
-
memoryConsolidationMicroUsd: number;
|
|
896
887
|
/** design/100 §E12 — prompt-suggestion pass LLM cost (micro-USD) = `suggestions?.costMicroUsd ?? 0`; filled
|
|
897
888
|
* asynchronously after the (post-completion) pass (0 until then). A separate, budget-excluded line. */
|
|
898
889
|
suggestionsMicroUsd?: number;
|
package/dist/core/task-spec.d.ts
CHANGED
|
@@ -441,11 +441,8 @@ export interface TaskSpec {
|
|
|
441
441
|
*
|
|
442
442
|
* There is NO capture request anymore: first-touch tracking is ON whenever a `RunnerDeps.fileHistoryStore`
|
|
443
443
|
* is wired, `RunnerDeps.fileHistoryCapture` is not `"off"`, and no {@link fileHistory} off switch is set (per-edited-file backups are near-zero cost — no tree walk,
|
|
444
|
-
* no size gate)
|
|
445
|
-
*
|
|
446
|
-
* tolerated no-op with a deprecation disclosure (the intent is structurally satisfied); its restore
|
|
447
|
-
* sense (true, with `resumeAt`) is a typed retirement rejection naming THIS field — the restore
|
|
448
|
-
* semantics genuinely changed (whole-tree ⇒ tracked set), so that migration must be explicit.
|
|
444
|
+
* no size gate). The retired `rewindFiles` key is refused by name at prepare (`config.spec_retired_key`) in
|
|
445
|
+
* both of its old senses; the restore sense is THIS field.
|
|
449
446
|
*/
|
|
450
447
|
restoreFiles?: boolean;
|
|
451
448
|
/**
|
|
@@ -820,7 +817,7 @@ export interface TaskSpec {
|
|
|
820
817
|
* their own fake self-check; prompt discipline alone (1.242) had a low landing rate. Opt-in
|
|
821
818
|
* because the evidence is from UNATTENDED long-task legs; consumers default it OFF and expose an
|
|
822
819
|
* explicit opt-in (ruled 2026-08-04). Interactive deployments choose per scenario. Read-only /
|
|
823
|
-
* Q&A runs never trigger it. Telemetry: `stats.mechanisms.
|
|
820
|
+
* Q&A runs never trigger it. Telemetry: `stats.mechanisms.finalVerifyInjections`.
|
|
824
821
|
*/
|
|
825
822
|
finalVerification?: boolean;
|
|
826
823
|
/**
|
|
@@ -1076,6 +1073,17 @@ export interface TaskSpec {
|
|
|
1076
1073
|
* Persists on the checkpoint's data half (`CheckpointState.inheritedGate.permissionMode`), re-judged on every leg.
|
|
1077
1074
|
*/
|
|
1078
1075
|
permissionMode?: PermissionMode;
|
|
1076
|
+
/**
|
|
1077
|
+
* In `auto` mode, let no shell allow entry clear a call — the classifier judges it (the reference's
|
|
1078
|
+
* `autoMode.classifyAllShell`). `true` ⇒ while the mode is `auto` (read per call), the whole shell tool, a name that reaches
|
|
1079
|
+
* it and every `Bash(…)` rule whatever it names stand down — in stored rules, a skill's `allowed-tools`, {@link allowedTools}
|
|
1080
|
+
* and the deployment's list alike. Absent / `false` ⇒ only the entries that hand over arbitrary code stand down. Narrows only;
|
|
1081
|
+
* outside `auto`, and for deny / ask rules, a hook's allow, non-shell entries and a read-only command, nothing changes. Which settings planes may set it is the host's
|
|
1082
|
+
* reading (the reference: user, flag and managed settings, never a repository's own); the host sends its allow lists
|
|
1083
|
+
* unchanged beside it. Tighten-only: `tightenTaskSpec` keeps a baseline's `true`, an engine-built child inherits it. A
|
|
1084
|
+
* present non-boolean refuses the run (`config.invalid_argument`).
|
|
1085
|
+
*/
|
|
1086
|
+
classifyAllShell?: boolean;
|
|
1079
1087
|
/** Task-scoped MCP servers, materialized into tools then disposed. */
|
|
1080
1088
|
mcp?: McpServerSpec[];
|
|
1081
1089
|
/** Task-scoped A2A peers (remote agents), whose advertised skills mount as `a2a__<peer>__<skill>`
|
|
@@ -1115,7 +1123,7 @@ export interface TaskSpec {
|
|
|
1115
1123
|
* deployment's {@link import("./runner-deps.js").RunnerDeps.allowedTools}, under the same predicate: deny and ask rules
|
|
1116
1124
|
* still win, and a question no allow rule clears (a mandated, governance, hook or plan question) is still put to a person,
|
|
1117
1125
|
* with the entry disclosed on the card. In `auto` mode an entry that hands over arbitrary code (the whole shell, an
|
|
1118
|
-
* interpreter or launcher prefix) is left to the classifier.
|
|
1126
|
+
* interpreter or launcher prefix) is left to the classifier — every shell entry, under {@link classifyAllShell}.
|
|
1119
1127
|
*
|
|
1120
1128
|
* Lives for this run — the steers it takes in included; a delegated child holds the entries until it ends; a resumed leg
|
|
1121
1129
|
* holds them only when its spec supplies them again (they are not written into a checkpoint). An entry this grammar
|
|
@@ -270,7 +270,7 @@ export interface TaskStream extends AsyncIterable<TaskEvent> {
|
|
|
270
270
|
* `memory.capture_optout_unavailable` (this run mounted no memory session — nothing to opt out
|
|
271
271
|
* of), `memory.capture_optout_sweep_failed` (the record STANDS but the §2.3 boundary sweep could
|
|
272
272
|
* not contain named residue paths — a repeat call is the retry lane),
|
|
273
|
-
* `config.memory_capture_unsupported` (
|
|
273
|
+
* `config.memory_capture_unsupported` (an execution env whose paths are not the host's, with no
|
|
274
274
|
* {@link RunnerDeps.memoryCaptureRecordStore} — the record would not survive to a resume
|
|
275
275
|
* replica), `steering.invalid_content` (a non-string `options.reason`), plus the steer-family
|
|
276
276
|
* `steering.not_running` once the task has finished. Resolves `{ outcome }`: `"created"` = this
|
|
@@ -141,6 +141,16 @@ export type TerminalCause = {
|
|
|
141
141
|
* Absent on pre-identity checkpoints.
|
|
142
142
|
*/
|
|
143
143
|
checkpointId?: string;
|
|
144
|
+
/**
|
|
145
|
+
* The id of the tool call that asked for this plan_review pause — the call that PRESENTED the plan (the
|
|
146
|
+
* `ExitPlanMode` call for the first-party plan tool), so a card can join the pause to that call by id instead of
|
|
147
|
+
* by adjacency. PRESENT only on a `plan_review` pause whose requester carried a call id; ABSENT on every other
|
|
148
|
+
* pause and on a plan_review pause whose requester had none (a row a deployment minted itself, a revive context). It
|
|
149
|
+
* is provenance, not a binding: the pause gates no call, so no `tool_approval` field rides beside it, and the
|
|
150
|
+
* resume never reads it. Echo of the committed row's {@link import("./checkpoint-store.js").PendingAction}
|
|
151
|
+
* `plan_review.requestedByCallId` — one write, at the park mint.
|
|
152
|
+
*/
|
|
153
|
+
requestedByCallId?: string;
|
|
144
154
|
/**
|
|
145
155
|
* HOW the paused task's remote workspace will come back, present whenever the pause captured a
|
|
146
156
|
* remote workspace. The two modes bill and behave very differently:
|
|
@@ -134,7 +134,7 @@ export const TOOL_CATALOG_ENTRIES = [
|
|
|
134
134
|
{ id: "report-findings", name: "ReportFindings", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["always"], cards: ["report-findings"], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.report_findings@1"), ruleFace: { params: ["level"] } } },
|
|
135
135
|
{ id: "structured-output", name: OUTPUT_TOOL_NAME, protocol: ["structured"], source: "synthetic", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.structured_output@1") } },
|
|
136
136
|
{ id: "skill", name: "Skill", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.skill@1"), renderHints: { approvalCard: "skill" }, ruleFace: { params: ["skill", "args"] } } },
|
|
137
|
-
{ id: "read-tool-result", name: "ReadToolResult", source: "builtin", definedIn: "src/core/tool-result-store.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs:
|
|
137
|
+
{ id: "read-tool-result", name: "ReadToolResult", source: "builtin", definedIn: "src/core/tool-result-store.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: "per_call", effect: "read", contract: c("core.read_tool_result@1"), budgetExempt: true, ruleFace: { params: ["ref", "offset", "limit"] } } },
|
|
138
138
|
{ id: "tool-search", name: "ToolSearch", source: "builtin", definedIn: "src/core/runner/tool-disclosure.ts", mountedBy: ["optional"], cards: ["tool-search"], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.tool_search@1"), ruleFace: { params: ["query", "max_results"] } } },
|
|
139
139
|
{ id: "advisor", name: "advisor", source: "builtin", definedIn: "src/core/runner/advisor-tool.ts", mountedBy: ["optional"], cards: ["advisor"], face: { family: "scaffold", boundaryLegs: [], effect: "read", contentOrigin: "local", contract: c("core.advisor@1"), offload: false, budgetExempt: true, ruleFace: { params: [] } } },
|
|
140
140
|
{ id: "ask-user-question", name: "AskUserQuestion", source: "builtin", definedIn: "src/core/ask-question.ts", mountedBy: ["optional"], cards: ["ask-question"], face: { family: "other", boundaryLegs: [], effect: "read", contract: c("core.ask_user_question@1"), renderHints: { approvalCard: "question" }, ruleFace: { params: [] } } },
|
|
@@ -5,17 +5,17 @@ import { failedHandlerClause } from "./mods/stations.js";
|
|
|
5
5
|
const STANDS = Object.freeze({ kind: "stands" });
|
|
6
6
|
function readToolCheck(heard, standing, call, mayClear) {
|
|
7
7
|
const { toolName } = call;
|
|
8
|
-
const refused = (message) => ({ kind: "denied", deny: refusalOf({ action: "deny", message, decisionReason: "hook" }, call.judged) });
|
|
8
|
+
const refused = (message, by) => ({ kind: "denied", deny: refusalOf({ action: "deny", message, decisionReason: "hook" }, call.judged), ...(by !== undefined ? { by } : {}) });
|
|
9
9
|
if (heard.kind === "aborted")
|
|
10
10
|
return refused(`the task was cancelled while a tool.check handler was still checking this call to "${toolName}"; the call was NOT executed (fail-closed)`);
|
|
11
11
|
if (heard.kind === "failed")
|
|
12
|
-
return refused(`a tool.check handler ${failedHandlerClause(heard)} while checking this call to "${toolName}"; the call was NOT executed (fail-closed)
|
|
12
|
+
return refused(`a tool.check handler ${failedHandlerClause(heard)} while checking this call to "${toolName}"; the call was NOT executed (fail-closed)`, heard.registration);
|
|
13
13
|
if (heard.by === undefined && heard.decision === standing.action)
|
|
14
14
|
return STANDS;
|
|
15
15
|
const { who, why } = speakerOf(heard);
|
|
16
16
|
const rewritten = call.rewrite !== undefined ? { updatedInput: call.rewrite } : {};
|
|
17
17
|
if (heard.decision === "deny")
|
|
18
|
-
return refused(`tool "${toolName}" denied by ${who}${why}
|
|
18
|
+
return refused(`tool "${toolName}" denied by ${who}${why}`, heard.by);
|
|
19
19
|
if (heard.decision === "ask") {
|
|
20
20
|
return standing.action === "ask"
|
|
21
21
|
? { kind: "asked", ask: { ...standing, decisionReason: "hook", ...(heard.reason !== undefined ? { message: heard.reason } : {}) }, minted: false }
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
* the prepare path, and the public surface is tiered by where a symbol is declared (`readToolAxes` is `advanced` for the same reason).
|
|
10
10
|
*/
|
|
11
11
|
import { type McpServerSpec } from "./mcp-server-spec.js";
|
|
12
|
+
/** Every member name a face declaration has, at any depth — the words a `toolFaces` refusal's member path spells (derived from the tables above). */
|
|
13
|
+
export declare const TOOL_FACE_WORDS: ReadonlySet<string>;
|
|
12
14
|
/**
|
|
13
15
|
* {@link readToolFaces}'s answer. `ok: true` hands back a copy of the faces that the reader itself built, plain data and none of the caller's own
|
|
14
16
|
* objects; `faces` is absent when nothing is declared (no key at all, or an empty record). `ok: false` carries one sentence (its detail cut at
|
|
15
|
-
* 240 characters)
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* operator needs echoed to find the fault.
|
|
17
|
+
* 240 characters) pointing at the tool and the member that did not fit. It says the face's own member names, the closed words a member takes,
|
|
18
|
+
* kinds, counts and bounds; it never says the declaration's content — a tool name, an unknown member's name, a word a closed table refuses, a
|
|
19
|
+
* parameter name, a list entry, display text: each is shown in the one caller's-text shape (`callerText`: the redaction mark and its length).
|
|
20
|
+
* These are the mount's judge's own sentences, the ones it announces at the listing, so the reader and the mount tell one operator one thing;
|
|
21
|
+
* `readToolAxes` refuses in the same sentence shape.
|
|
21
22
|
*/
|
|
22
23
|
export type ToolFacesRead = {
|
|
23
24
|
ok: true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dataKind, perToolEmptyName, perToolEntryRefusal,
|
|
1
|
+
import { callerText, dataKind, perToolEmptyName, perToolEntryRefusal, receivePerToolDeclaration } from "./mcp-server-spec.js";
|
|
2
2
|
import { isPlainRecord } from "./mods/kernel/receive.js";
|
|
3
3
|
import { faceProblem } from "./runner/tool-face-overlay.js";
|
|
4
4
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
@@ -9,6 +9,7 @@ const HOST_TARGET_KINDS = { param: "string" };
|
|
|
9
9
|
const HOST_TARGET_REQUIRED = ["param"];
|
|
10
10
|
const RENDER_HINT_KINDS = { userFacingName: "string", activity: "string", summaryParams: "list", resultCards: "list", approvalCard: "string" };
|
|
11
11
|
const RULE_FACE_KINDS = { primaryParams: "list", params: "list", nameValues: "list" };
|
|
12
|
+
export const TOOL_FACE_WORDS = new Set([TOOL_FACE_MEMBERS, PATH_TARGET_KINDS, HOST_TARGET_KINDS, RENDER_HINT_KINDS, RULE_FACE_KINDS].flatMap((table) => Object.keys(table)));
|
|
12
13
|
function kindProblem(label, value, kind) {
|
|
13
14
|
if (value === undefined)
|
|
14
15
|
return undefined;
|
|
@@ -20,7 +21,7 @@ function membersOf(raw, label, names) {
|
|
|
20
21
|
if (!isPlainRecord(raw))
|
|
21
22
|
return `${label} is ${dataKind(raw)}, not an object`;
|
|
22
23
|
const unknown = Object.keys(raw).find((member) => !names.includes(member));
|
|
23
|
-
return unknown === undefined ? raw : `${label} has
|
|
24
|
+
return unknown === undefined ? raw : `${label} has an unknown member ${callerText(unknown)} (the members are ${names.join(", ")})`;
|
|
24
25
|
}
|
|
25
26
|
function ownMember(record, name) {
|
|
26
27
|
return Object.hasOwn(record, name) ? record[name] : undefined;
|
|
@@ -74,7 +75,7 @@ function readOneToolFace(raw) {
|
|
|
74
75
|
export function readToolFaces(declared) {
|
|
75
76
|
if (declared === undefined)
|
|
76
77
|
return { ok: true };
|
|
77
|
-
const received = receivePerToolDeclaration(declared, "toolFaces", "tool");
|
|
78
|
+
const received = receivePerToolDeclaration(declared, "toolFaces", "tool", TOOL_FACE_WORDS);
|
|
78
79
|
if (!received.ok)
|
|
79
80
|
return { ok: false, problem: received.problem };
|
|
80
81
|
const entries = [];
|
|
@@ -65,6 +65,7 @@ export type RuleToolNameVerdict = {
|
|
|
65
65
|
readonly kind: "unmintable_segment";
|
|
66
66
|
readonly guidance: string;
|
|
67
67
|
readonly currentName?: string;
|
|
68
|
+
readonly ambiguous?: true;
|
|
68
69
|
};
|
|
69
70
|
/**
|
|
70
71
|
* A name in ANY protocol namespace split into its owning namespace, its peer segment and its optional tool segment —
|
|
@@ -80,6 +81,23 @@ export declare function splitNamespacedName(name: string): {
|
|
|
80
81
|
readonly peer: string;
|
|
81
82
|
readonly tool?: string;
|
|
82
83
|
} | undefined;
|
|
84
|
+
/** One way a rule name can be read as a protocol name: the peer's MINTED segment and, when the reading names a tool, its segment. */
|
|
85
|
+
export interface PeerReading {
|
|
86
|
+
readonly ns: ProtocolNamespace;
|
|
87
|
+
readonly peer: string;
|
|
88
|
+
readonly tool?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Every way an MCP rule name can denote a peer, when it can be read more than one way — the readings the reference's lookup takes
|
|
92
|
+
* of a name whose server segment may itself carry the separator: a cut at EACH `__` of the body (server = what precedes the cut,
|
|
93
|
+
* tool = what follows) and the whole body as a server (`mcp__a__b` is tool `b` of server `a`, and server `a__b`). The reference
|
|
94
|
+
* spells a server `a__b` as is; the mint folds a run of `_` and drops a trailing one ({@link mintNamespacePrefix}), so a server
|
|
95
|
+
* segment is read through the mint — the peer a reading names is the one the mint would spell it as. `[]` for a name with no
|
|
96
|
+
* second reading: no separator in the body (the one reading is {@link splitNamespacedName}'s), a glob, an empty segment on either
|
|
97
|
+
* side of a cut, or a namespace the reference has no spelling for (only MCP's server names reach a rule from another product).
|
|
98
|
+
* The first reading is the first separator's — the one `splitNamespacedName` gives.
|
|
99
|
+
*/
|
|
100
|
+
export declare function peerReadingsOf(name: string): readonly PeerReading[];
|
|
83
101
|
/**
|
|
84
102
|
* Does a list of this behavior read a `*` in a tool name as a glob over the WHOLE name — anywhere in it, the lone `*` (every tool)
|
|
85
103
|
* included? A list that RESTRICTS (`deny`, `ask`) does: it reaches every tool any of whose names the glob matches (the reference's
|
|
@@ -117,6 +135,7 @@ export type ToolNameFault = {
|
|
|
117
135
|
readonly verdict: Exclude<RuleToolNameVerdict["kind"], "current">;
|
|
118
136
|
readonly guidance?: string;
|
|
119
137
|
readonly currentName?: string;
|
|
138
|
+
readonly ambiguous?: true;
|
|
120
139
|
} | {
|
|
121
140
|
readonly reason: "near_miss";
|
|
122
141
|
readonly currentName: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { carriesNamespaceSeparator, protocolOf } from "./protocol-table.js";
|
|
1
|
+
import { carriesNamespaceSeparator, MCP_NAMESPACE, protocolOf } from "./protocol-table.js";
|
|
2
2
|
import { mintNamespacePrefix } from "./protocol-naming.js";
|
|
3
3
|
import { catalogToolNames } from "./tool-registry.js";
|
|
4
4
|
export const RETIRED_TOOL_NAMES = new Map([
|
|
@@ -54,6 +54,28 @@ export function splitNamespacedName(name) {
|
|
|
54
54
|
const [peer = "", ...rest] = name.slice(ns.prefix.length).split(NAMESPACE_SEPARATOR);
|
|
55
55
|
return rest.length > 0 ? { ns, peer, tool: rest.join(NAMESPACE_SEPARATOR) } : { ns, peer };
|
|
56
56
|
}
|
|
57
|
+
export function peerReadingsOf(name) {
|
|
58
|
+
if (name.includes("*"))
|
|
59
|
+
return [];
|
|
60
|
+
const ns = protocolOf(name);
|
|
61
|
+
if (ns === undefined || ns.id !== MCP_NAMESPACE.id)
|
|
62
|
+
return [];
|
|
63
|
+
const body = name.slice(ns.prefix.length);
|
|
64
|
+
if (body === "" || body.startsWith(NAMESPACE_SEPARATOR))
|
|
65
|
+
return [];
|
|
66
|
+
const mintedPeer = (server) => mintNamespacePrefix(ns, server).slice(ns.prefix.length, -NAMESPACE_SEPARATOR.length);
|
|
67
|
+
const readings = [];
|
|
68
|
+
for (let at = body.indexOf(NAMESPACE_SEPARATOR); at !== -1; at = body.indexOf(NAMESPACE_SEPARATOR, at + 1)) {
|
|
69
|
+
const tool = body.slice(at + NAMESPACE_SEPARATOR.length);
|
|
70
|
+
if (tool !== "")
|
|
71
|
+
readings.push({ ns, peer: mintedPeer(body.slice(0, at)), tool });
|
|
72
|
+
}
|
|
73
|
+
if (readings.length === 0)
|
|
74
|
+
return [];
|
|
75
|
+
if (!body.endsWith(NAMESPACE_SEPARATOR))
|
|
76
|
+
readings.push({ ns, peer: mintedPeer(body) });
|
|
77
|
+
return readings.filter((r, i) => readings.findIndex((o) => o.peer === r.peer && o.tool === r.tool) === i);
|
|
78
|
+
}
|
|
57
79
|
export function readsNameGlob(behavior) {
|
|
58
80
|
return behavior === "deny" || behavior === "ask";
|
|
59
81
|
}
|
|
@@ -86,6 +108,25 @@ function unmintableSegmentOf(split, behavior) {
|
|
|
86
108
|
currentName: `${ns.prefix}${minted}${tool !== undefined ? `${NAMESPACE_SEPARATOR}${tool}` : ""}`,
|
|
87
109
|
};
|
|
88
110
|
}
|
|
111
|
+
function ambiguousServerSpellingOf(name, roster) {
|
|
112
|
+
const readings = peerReadingsOf(name);
|
|
113
|
+
if (readings.length === 0)
|
|
114
|
+
return undefined;
|
|
115
|
+
for (const carried of roster) {
|
|
116
|
+
const split = splitNamespacedName(carried);
|
|
117
|
+
if (split === undefined || split.tool === undefined)
|
|
118
|
+
continue;
|
|
119
|
+
if (!readings.some((r) => r.ns.id === split.ns.id && r.peer === split.peer && (r.tool === undefined || r.tool === split.tool)))
|
|
120
|
+
continue;
|
|
121
|
+
return {
|
|
122
|
+
kind: "unmintable_segment",
|
|
123
|
+
ambiguous: true,
|
|
124
|
+
guidance: "the name reads as more than one MCP server's. To allow it, use the tool's full name.",
|
|
125
|
+
currentName: carried,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
89
130
|
export function judgeRuleToolName(name, roster, behavior) {
|
|
90
131
|
if (roster.has(name))
|
|
91
132
|
return CURRENT;
|
|
@@ -94,6 +135,11 @@ export function judgeRuleToolName(name, roster, behavior) {
|
|
|
94
135
|
const currentName = /^renamed "([^"]+)"/.exec(guidance)?.[1];
|
|
95
136
|
return currentName !== undefined ? { kind: "retired", guidance, currentName } : { kind: "retired", guidance };
|
|
96
137
|
}
|
|
138
|
+
if (behavior === "allow") {
|
|
139
|
+
const ambiguous = ambiguousServerSpellingOf(name, roster);
|
|
140
|
+
if (ambiguous !== undefined)
|
|
141
|
+
return ambiguous;
|
|
142
|
+
}
|
|
97
143
|
const split = splitNamespacedName(name);
|
|
98
144
|
if (split === undefined)
|
|
99
145
|
return carriesNamespaceSeparator(name) && !(readsNameGlob(behavior) && name.includes("*")) ? UNPREFIXED : CURRENT;
|
|
@@ -116,7 +162,13 @@ export function toolNameFaultOf(name, roster, behavior) {
|
|
|
116
162
|
if (verdict.kind === "unprefixed_namespace")
|
|
117
163
|
return { reason: "tool_name", verdict: verdict.kind };
|
|
118
164
|
if (verdict.kind !== "current") {
|
|
119
|
-
return {
|
|
165
|
+
return {
|
|
166
|
+
reason: "tool_name",
|
|
167
|
+
verdict: verdict.kind,
|
|
168
|
+
guidance: verdict.guidance,
|
|
169
|
+
...(verdict.currentName !== undefined ? { currentName: verdict.currentName } : {}),
|
|
170
|
+
...(verdict.kind === "unmintable_segment" && verdict.ambiguous === true ? { ambiguous: true } : {}),
|
|
171
|
+
};
|
|
120
172
|
}
|
|
121
173
|
const mounted = nearMissSpellingOf(name, roster);
|
|
122
174
|
return mounted === undefined ? undefined : { reason: "near_miss", currentName: mounted };
|