@sema-agent/core 7.71.1 → 7.73.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 +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { strayMembersOf } from "./own-property-receipt.js";
|
|
1
2
|
export function agentIdOf(identity) {
|
|
2
3
|
return identity?.isDelegatedChild === true ? identity.taskId : undefined;
|
|
3
4
|
}
|
|
@@ -9,6 +10,47 @@ export function rootAnchorOf(internals, sessionId, ownOccupant) {
|
|
|
9
10
|
const occupant = root !== undefined ? internals?.rootSessionIncarnation : ownOccupant;
|
|
10
11
|
return { sessionId: root ?? sessionId, ...(occupant !== undefined ? { occupant } : {}) };
|
|
11
12
|
}
|
|
13
|
+
export function hookRootSessionIdOf(internals, sessionId, isDelegatedChild) {
|
|
14
|
+
if (internals?.rootSessionId !== undefined)
|
|
15
|
+
return internals.rootSessionId;
|
|
16
|
+
if (isDelegatedChild || internals?.observerLeg === true)
|
|
17
|
+
return undefined;
|
|
18
|
+
return sessionId;
|
|
19
|
+
}
|
|
20
|
+
const LEG_IDENTITY_MEMBERS = ["declaredTaskId", "parentTaskId", "rootSessionId", "rootSessionIncarnation", "rootSessionScope", "spawnName"];
|
|
21
|
+
const LEG_IDENTITY_WORDS = { subject: "a parked row's leg identity", unit: "member", moment: "when the row is read" };
|
|
22
|
+
const isFilledString = (v) => typeof v === "string" && v !== "";
|
|
23
|
+
export function legIdentityRecordOf(declaredTaskId, internals) {
|
|
24
|
+
const root = internals?.rootSessionId;
|
|
25
|
+
const scope = internals?.rootSessionScope;
|
|
26
|
+
const record = {};
|
|
27
|
+
if (declaredTaskId !== undefined && declaredTaskId !== "")
|
|
28
|
+
record.declaredTaskId = declaredTaskId;
|
|
29
|
+
if (internals?.parentTaskId !== undefined && internals.parentTaskId !== "")
|
|
30
|
+
record.parentTaskId = internals.parentTaskId;
|
|
31
|
+
if (root !== undefined && root !== "" && scope !== undefined && scope !== "") {
|
|
32
|
+
record.rootSessionId = root;
|
|
33
|
+
record.rootSessionScope = scope;
|
|
34
|
+
if (internals?.rootSessionIncarnation !== undefined && internals.rootSessionIncarnation !== "")
|
|
35
|
+
record.rootSessionIncarnation = internals.rootSessionIncarnation;
|
|
36
|
+
}
|
|
37
|
+
if (internals?.explicitAgentName !== undefined && internals.explicitAgentName !== "")
|
|
38
|
+
record.spawnName = internals.explicitAgentName;
|
|
39
|
+
return Object.keys(record).length > 0 ? record : undefined;
|
|
40
|
+
}
|
|
41
|
+
export function readLegIdentityRecord(raw) {
|
|
42
|
+
if (raw === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
45
|
+
return "damaged";
|
|
46
|
+
const keys = Object.keys(raw);
|
|
47
|
+
if (keys.length === 0 || strayMembersOf(raw, LEG_IDENTITY_WORDS, LEG_IDENTITY_MEMBERS) !== undefined)
|
|
48
|
+
return "damaged";
|
|
49
|
+
if (!keys.every((key) => isFilledString(raw[key])))
|
|
50
|
+
return "damaged";
|
|
51
|
+
const record = raw;
|
|
52
|
+
return (record.rootSessionIncarnation !== undefined || record.rootSessionScope !== undefined) && record.rootSessionId === undefined ? "damaged" : record;
|
|
53
|
+
}
|
|
12
54
|
export const SYNC_CHILD_BLOCK_MEMBERS = Object.freeze(["parentSessionId", "parentTaskId", "rootSessionId", "rootSessionIncarnation"]);
|
|
13
55
|
export function mintAskSourceIdentity(leg) {
|
|
14
56
|
const agentId = agentIdOf({ taskId: leg.taskId, isDelegatedChild: leg.isDelegatedChild });
|
|
@@ -44,9 +86,10 @@ export function noticeAddressOf(askSource, root) {
|
|
|
44
86
|
return { address: { sessionId: own } };
|
|
45
87
|
const rootId = root?.rootSessionId;
|
|
46
88
|
const address = { sessionId: rootId ?? own, sourceSessionId: own, ...(askSource.agentId !== undefined ? { agentId: askSource.agentId } : {}) };
|
|
47
|
-
|
|
89
|
+
const scope = root?.rootSessionScope;
|
|
90
|
+
return rootId !== undefined && rootId !== own ? { address, destination: { sessionId: rootId, occupant: root?.rootSessionIncarnation, ...(scope !== undefined ? { scope } : {}) } } : { address };
|
|
48
91
|
}
|
|
49
|
-
function legNoticeAdmission(route, judge) {
|
|
92
|
+
export function legNoticeAdmission(route, judge) {
|
|
50
93
|
const { address, destination } = route;
|
|
51
94
|
if (destination === undefined || judge === undefined)
|
|
52
95
|
return undefined;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE LAUNCH CHECK of a run that directs workers and reports to a person (a run that declares a member ledger,
|
|
3
|
+
* `TaskSpec.runLedger`): before it spends anything, read whether the leg has what such a run needs, item by item, and say so —
|
|
4
|
+
* refuse when it cannot do the job at all, narrow (and say how) when it can do part of it, never start a manager that can only
|
|
5
|
+
* repeat its workers' words without saying that it can.
|
|
6
|
+
*
|
|
7
|
+
* A pure function over facts the leg's prepare reads; each item `ok`, `missing`, or `unknown` (the fact could not be read here —
|
|
8
|
+
* never shown as missing, and never a reason to narrow or refuse).
|
|
9
|
+
*/
|
|
10
|
+
/** The items, in the order they are read. */
|
|
11
|
+
export declare const MANAGER_LAUNCH_ITEMS: readonly ["background_delegation", "report_tool", "read_hands", "worker_transcript", "isolated_checks", "worker_write_approval", "task_list"];
|
|
12
|
+
export type ManagerLaunchItem = (typeof MANAGER_LAUNCH_ITEMS)[number];
|
|
13
|
+
export type ManagerLaunchState = "ok" | "missing" | "unknown";
|
|
14
|
+
/** `task.manager_launch_narrowed`: the run starts without some of what its job needs (the check's sentence). */
|
|
15
|
+
export declare function managerLaunchNarrowedNotice(c: ManagerLaunchCheck, ids: Record<string, string | undefined>): {
|
|
16
|
+
code: "task.manager_launch_narrowed";
|
|
17
|
+
message: string;
|
|
18
|
+
detail: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
export interface ManagerLaunchCheck {
|
|
21
|
+
/** `ready`: nothing missing; `narrowed`: something missing that the run can do without (said in `items`); `refused`. */
|
|
22
|
+
readonly verdict: "ready" | "narrowed" | "refused";
|
|
23
|
+
readonly items: ReadonlyArray<{
|
|
24
|
+
readonly item: ManagerLaunchItem;
|
|
25
|
+
readonly state: ManagerLaunchState;
|
|
26
|
+
readonly means?: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/** The facts the check reads — each `undefined` when the leg cannot read it. */
|
|
30
|
+
export type ManagerLaunchFacts = Readonly<Record<ManagerLaunchItem, boolean | undefined>>;
|
|
31
|
+
/** The check over its facts — see the module head. */
|
|
32
|
+
export declare function managerLaunchCheck(facts: ManagerLaunchFacts): ManagerLaunchCheck;
|
|
33
|
+
/** What a prepared leg reads for the check: the names on its roster, whether its delegation lane launches in the background and
|
|
34
|
+
* its results come back on a lane, whether a person or a park can take its workers' asks, and whether it is one-shot. */
|
|
35
|
+
export interface ManagerLaunchLegReading {
|
|
36
|
+
readonly names: ReadonlySet<string>;
|
|
37
|
+
readonly backgroundAgents: boolean | undefined;
|
|
38
|
+
readonly completionLane: boolean;
|
|
39
|
+
readonly approver: boolean;
|
|
40
|
+
readonly parkStore: boolean;
|
|
41
|
+
readonly oneShot: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** The check's facts off a prepared leg's reading. A worker's writes have an approval route when the leg has an approver to hand
|
|
44
|
+
* down; they have none when there is no approver, no park store and the run is one-shot (nobody can be asked — the measured
|
|
45
|
+
* `delegation.ask_unresolvable`); every other case is not read here (`unknown`). */
|
|
46
|
+
export declare function managerLaunchFactsOf(r: ManagerLaunchLegReading): ManagerLaunchFacts;
|
|
47
|
+
/** The check as one sentence (the notice's message, the refusal's): what is missing and what that means. */
|
|
48
|
+
export declare function managerLaunchCheckSentence(c: ManagerLaunchCheck): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const MANAGER_LAUNCH_ITEMS = Object.freeze([
|
|
2
|
+
"background_delegation",
|
|
3
|
+
"report_tool",
|
|
4
|
+
"read_hands",
|
|
5
|
+
"worker_transcript",
|
|
6
|
+
"isolated_checks",
|
|
7
|
+
"worker_write_approval",
|
|
8
|
+
"task_list",
|
|
9
|
+
]);
|
|
10
|
+
const REFUSING = new Set(["background_delegation", "report_tool"]);
|
|
11
|
+
const NARROWED = {
|
|
12
|
+
background_delegation: "it cannot dispatch workers that report back, so it cannot direct anyone",
|
|
13
|
+
report_tool: "it has no report tool, so nothing it concludes reaches the person with the engine's ledger beside it",
|
|
14
|
+
read_hands: "it cannot read the work itself; it can only send workers to look",
|
|
15
|
+
worker_transcript: "it cannot read a worker's record; it sees only what each worker says",
|
|
16
|
+
isolated_checks: "checks that need running something go to a verification worker (no isolated environment for the manager's own checks)",
|
|
17
|
+
worker_write_approval: "a worker's writes will be refused: nobody on this run can approve them",
|
|
18
|
+
task_list: "the plan cannot be kept as a shared task list",
|
|
19
|
+
};
|
|
20
|
+
const ITEM_WORDS = {
|
|
21
|
+
background_delegation: "dispatching workers that report back",
|
|
22
|
+
report_tool: "the report tool",
|
|
23
|
+
read_hands: "reading the work",
|
|
24
|
+
worker_transcript: "reading a worker's record",
|
|
25
|
+
isolated_checks: "running checks in isolation",
|
|
26
|
+
worker_write_approval: "an approval route for the workers' writes",
|
|
27
|
+
task_list: "a shared task list",
|
|
28
|
+
};
|
|
29
|
+
export function managerLaunchNarrowedNotice(c, ids) {
|
|
30
|
+
return { code: "task.manager_launch_narrowed", message: managerLaunchCheckSentence(c), detail: { ...ids, launch: c } };
|
|
31
|
+
}
|
|
32
|
+
export function managerLaunchCheck(facts) {
|
|
33
|
+
const items = MANAGER_LAUNCH_ITEMS.map((item) => {
|
|
34
|
+
const v = facts[item];
|
|
35
|
+
const state = v === true ? "ok" : v === false ? "missing" : "unknown";
|
|
36
|
+
return Object.freeze({ item, state, ...(state === "missing" ? { means: NARROWED[item] } : {}) });
|
|
37
|
+
});
|
|
38
|
+
const missing = items.filter((i) => i.state === "missing");
|
|
39
|
+
const verdict = missing.some((i) => REFUSING.has(i.item)) ? "refused" : missing.length > 0 ? "narrowed" : "ready";
|
|
40
|
+
return Object.freeze({ verdict, items: Object.freeze(items) });
|
|
41
|
+
}
|
|
42
|
+
export function managerLaunchFactsOf(r) {
|
|
43
|
+
const has = (...names) => names.every((n) => r.names.has(n));
|
|
44
|
+
return {
|
|
45
|
+
background_delegation: r.backgroundAgents === undefined ? undefined : r.backgroundAgents && r.completionLane,
|
|
46
|
+
report_tool: has("SendUserMessage"),
|
|
47
|
+
read_hands: has("Read", "Grep", "Glob"),
|
|
48
|
+
worker_transcript: has("AgentTranscript"),
|
|
49
|
+
isolated_checks: false,
|
|
50
|
+
worker_write_approval: r.approver ? true : !r.parkStore && r.oneShot ? false : undefined,
|
|
51
|
+
task_list: has("TaskCreate", "TaskList"),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function managerLaunchCheckSentence(c) {
|
|
55
|
+
const missing = c.items.filter((i) => i.state === "missing");
|
|
56
|
+
const unknown = c.items.filter((i) => i.state === "unknown").map((i) => ITEM_WORDS[i.item]);
|
|
57
|
+
const said = missing.map((i) => i.means).join("; ");
|
|
58
|
+
const unread = unknown.length > 0 ? ` Not read here: ${unknown.join(", ")}.` : "";
|
|
59
|
+
if (c.verdict === "ready")
|
|
60
|
+
return `The launch check found everything this run needs.${unread}`;
|
|
61
|
+
if (c.verdict === "refused")
|
|
62
|
+
return `This run declares a member ledger but cannot do that job — ${said}.${unread}`;
|
|
63
|
+
return `This run starts narrowed — ${said}.${unread}`;
|
|
64
|
+
}
|
|
@@ -45,14 +45,14 @@ export declare const MCP_CALLER_META_KEY = "sema/caller";
|
|
|
45
45
|
* Who is calling: the identity facts of the leg a request is sent for, every one a value the engine already mints for the leg's own
|
|
46
46
|
* frames (none is minted for this record). Frozen, no prototype.
|
|
47
47
|
* - `taskId` — the leg's task id, minted once at prepare (`legTaskIdOf`): the value `TaskResult.taskId` and `task_progress.taskId` carry,
|
|
48
|
-
* whatever that reading answers on this run (the leg's registry row id,
|
|
48
|
+
* whatever that reading answers on this run (the leg's registry row id; on a ledger run, the host's task id if it gave one other than the session id, the id the parked row recorded on a resume, otherwise the minted `rl-…` id; else the host's task id or the leg's session id).
|
|
49
49
|
* - `runId` — this invocation of the engine (`Prepared.runId`): new on every run, a resume included.
|
|
50
50
|
* - `rootSessionId` — the delegation tree's root session (`rootAnchorOf`): the leg's own session on a top-level leg.
|
|
51
51
|
* - `parentTaskId` — the spawning leg's task id (`RunInternals.parentTaskId`, the value `task_progress.parentTaskId` carries); absent on a
|
|
52
52
|
* leg nobody spawned under a known task.
|
|
53
53
|
* Built once per leg and run, at prepare: every call and fetch of that run carries the same record. No principal, path, model or display
|
|
54
54
|
* name rides it. Session ids do: `taskId` is the leg's own session id wherever that is its task id (a foreground child, a workflow member
|
|
55
|
-
* or a top-level leg handed no task id), and `rootSessionId` is the tree root's session — independent of `sessionMetaKey`.
|
|
55
|
+
* or a non-ledger top-level leg handed no task id; on a ledger run the task id is the host's if it gave one other than the session id, the id the parked row recorded on a resume, otherwise the minted `rl-…` one), and `rootSessionId` is the tree root's session — independent of `sessionMetaKey`.
|
|
56
56
|
*/
|
|
57
57
|
export type McpCaller = Readonly<{
|
|
58
58
|
taskId: string;
|
|
@@ -98,6 +98,11 @@ export declare function hostSeatLine(what: string, serverLabel: string, seat: Ho
|
|
|
98
98
|
export declare function hostSeatMissing(server: string): Error & {
|
|
99
99
|
code: string;
|
|
100
100
|
};
|
|
101
|
+
/** The same refusal as the waker reads it: the woken leg's host-transport servers (`servers`, inherited at its spawn) that this wake hands
|
|
102
|
+
* no seat, so each fails its dial there with {@link hostSeatMissing}. It states only what the wake knows — the server is a host pipe on
|
|
103
|
+
* the woken side and this leg handed no seat for it — never why this leg holds none (it may not declare the server, declare it with
|
|
104
|
+
* another transport, declare it without holding a seat, or run outside a Runner). */
|
|
105
|
+
export declare function hostSeatNotHandedLine(servers: readonly string[]): string;
|
|
101
106
|
/**
|
|
102
107
|
* One host row's mount under ONE deadline (the module note): `signal` aborts when `ms` (the row's startup bound; absent, the SDK's own
|
|
103
108
|
* request default) has passed since the mount began — a `RequestTimeout`, which the dial reads as `timeout` — or when `run` (the run's
|
|
@@ -35,7 +35,13 @@ export function hostSeatLine(what, serverLabel, seat, writeTail) {
|
|
|
35
35
|
: `${what} on MCP server "${serverLabel}" ended without an outcome the host could report: ${seat.condition}. The request may or may not have executed on the server — the outcome is unknown.${writeTail}`;
|
|
36
36
|
}
|
|
37
37
|
export function hostSeatMissing(server) {
|
|
38
|
-
return Object.assign(new Error(`MCP server "${inlineUntrusted(server, 120)}" is declared with a host-supplied transport, and this leg holds no host seat of that name (RunInternals.mcpHostSeats) — not dialed`), { code:
|
|
38
|
+
return Object.assign(new Error(`MCP server "${inlineUntrusted(server, 120)}" is declared with a host-supplied transport, and this leg holds no host seat of that name (RunInternals.mcpHostSeats) — not dialed`), { code: MCP_HOST_SEAT_MISSING });
|
|
39
|
+
}
|
|
40
|
+
const MCP_HOST_SEAT_MISSING = "config.mcp_host_seat_missing";
|
|
41
|
+
export function hostSeatNotHandedLine(servers) {
|
|
42
|
+
const names = servers.map((s) => `"${inlineUntrusted(s, 120)}"`).join(", ");
|
|
43
|
+
const many = servers.length > 1;
|
|
44
|
+
return `Its MCP server${many ? "s" : ""} ${names} ${many ? "are" : "is"} declared with a host-supplied transport, and this leg hands no host seat for ${many ? "them" : "it"} (a leg hands a seat only for a server it declares with a host-supplied transport and holds a seat for) — not dialed on this wake (${MCP_HOST_SEAT_MISSING}).`;
|
|
39
45
|
}
|
|
40
46
|
export function hostMount(ms, run) {
|
|
41
47
|
const bound = ms ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
@@ -41,9 +41,12 @@ import type { EngineNotice } from "./engine-notice.js";
|
|
|
41
41
|
* · `credentials_not_carried` — a request does not carry an MCP server's credentials, so the
|
|
42
42
|
* deployment has to mount this server itself: the recovery is the
|
|
43
43
|
* administrator's configuration or the entry without its credentials;
|
|
44
|
-
* `field` names the credentials key when the host knows it
|
|
44
|
+
* `field` names the credentials key when the host knows it;
|
|
45
|
+
* · `name_already_mounted` — an agent definition declared an MCP server whose normalized
|
|
46
|
+
* namespace is already mounted on the run (the run's server stays
|
|
47
|
+
* in use; the agent's duplicate entry was not mounted).
|
|
45
48
|
*/
|
|
46
|
-
export declare const MCP_INJECTION_DROP_REASONS: readonly ["malformed_entry", "name_reserved_by_deployment", "gate_closed", "over_cap", "key_retired", "credentials_not_carried"];
|
|
49
|
+
export declare const MCP_INJECTION_DROP_REASONS: readonly ["malformed_entry", "name_reserved_by_deployment", "gate_closed", "over_cap", "key_retired", "credentials_not_carried", "name_already_mounted"];
|
|
47
50
|
export type McpInjectionDropReason = (typeof MCP_INJECTION_DROP_REASONS)[number];
|
|
48
51
|
/**
|
|
49
52
|
* The user-facing sentence per reason — the disposition table over {@link MCP_INJECTION_DROP_REASONS}
|
|
@@ -57,9 +60,10 @@ export declare const MCP_INJECTION_DROP_TEXT: {
|
|
|
57
60
|
readonly over_cap: "the request named more MCP servers than this deployment mounts per leg — trim the list";
|
|
58
61
|
readonly key_retired: "its declaration carries a configuration key this service no longer accepts — update the application that sent this entry, or remove that key from the entry, then start a new session";
|
|
59
62
|
readonly credentials_not_carried: "requests do not carry credentials for MCP servers, so the deployment has to mount this one — ask an administrator to configure it in the deployment, or remove the credentials from this entry";
|
|
63
|
+
readonly name_already_mounted: "another server of that name is already mounted on this run and stays in use — rename the server in this agent's configuration, or remove the duplicate";
|
|
60
64
|
};
|
|
61
65
|
export type DropTextCoversEveryReason = AssertAllKeysHandled<Exclude<McpInjectionDropReason, keyof typeof MCP_INJECTION_DROP_TEXT>>;
|
|
62
|
-
/** What a host knows at the drop site — facts only, no words of the engine's vocabulary composed. */
|
|
66
|
+
/** What a host (or spawn merge) knows at the drop site — facts only, no words of the engine's vocabulary composed. */
|
|
63
67
|
export interface McpInjectionDropFacts {
|
|
64
68
|
/** The session whose injection carried the entry — the notice's routing key, required (see module note). */
|
|
65
69
|
readonly sessionId: string;
|
|
@@ -72,20 +76,26 @@ export interface McpInjectionDropFacts {
|
|
|
72
76
|
* carried in `detail` only.
|
|
73
77
|
*/
|
|
74
78
|
readonly field?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Optional: the agent definition that declared this server entry (for drops in host intake of
|
|
81
|
+
* agent-level MCP declarations and spawn-time collisions with a server already mounted on the run).
|
|
82
|
+
* Carried in `detail.entries[0].agent` and named in the message when non-empty.
|
|
83
|
+
*/
|
|
84
|
+
readonly agent?: string;
|
|
75
85
|
}
|
|
76
86
|
/**
|
|
77
|
-
* Compose the notice for one
|
|
87
|
+
* Compose the notice for one MCP server declaration that was not mounted, from drop facts: `config.entries_not_applied`,
|
|
78
88
|
* kind `mcp_injection_dropped` (until 7.70.0 its own code, `mcp.injection_dropped`).
|
|
79
89
|
*
|
|
80
|
-
* @contract mcp.injection_dropped.single_mint — the notice for a dropped
|
|
81
|
-
* from
|
|
82
|
-
*
|
|
90
|
+
* @contract mcp.injection_dropped.single_mint — the notice for a dropped MCP server declaration is composed by CORE
|
|
91
|
+
* from drop FACTS (session, server name, one of the closed reasons, optionally the bad field and declaring agent); a
|
|
92
|
+
* caller never spells the code, the audience or the sentence, and a fact outside the vocabulary (an
|
|
83
93
|
* unlisted reason word, an empty session or server name) is refused at the mint with a `TypeError`
|
|
84
94
|
* rather than shaped into a notice that would route nowhere or read as an unknown word downstream.
|
|
85
95
|
*
|
|
86
|
-
* `detail: { kind: "mcp_injection_dropped", entries: [{ entry, reason, field? }], count: 1, identity, sessionId }` — `entry` is the
|
|
87
|
-
* server's name as
|
|
88
|
-
*
|
|
96
|
+
* `detail: { kind: "mcp_injection_dropped", entries: [{ entry, reason, field?, agent? }], count: 1, identity, sessionId }` — `entry` is the
|
|
97
|
+
* server's name as spelled, `reason` one of {@link MCP_INJECTION_DROP_REASONS}, `field` and `agent` present only when supplied as
|
|
98
|
+
* non-empty strings; `sessionId` is lifted onto the typed key by {@link import("./engine-notice.js").deliverEngineNotice},
|
|
89
99
|
* the one throat, so the two spellings cannot disagree.
|
|
90
100
|
*/
|
|
91
101
|
export declare function mcpInjectionDroppedNotice(facts: McpInjectionDropFacts): EngineNotice;
|
|
@@ -6,6 +6,7 @@ export const MCP_INJECTION_DROP_REASONS = Object.freeze([
|
|
|
6
6
|
"over_cap",
|
|
7
7
|
"key_retired",
|
|
8
8
|
"credentials_not_carried",
|
|
9
|
+
"name_already_mounted",
|
|
9
10
|
]);
|
|
10
11
|
export const MCP_INJECTION_DROP_TEXT = {
|
|
11
12
|
malformed_entry: "its declaration could not be read — fix the entry and start a new session",
|
|
@@ -14,6 +15,7 @@ export const MCP_INJECTION_DROP_TEXT = {
|
|
|
14
15
|
over_cap: "the request named more MCP servers than this deployment mounts per leg — trim the list",
|
|
15
16
|
key_retired: "its declaration carries a configuration key this service no longer accepts — update the application that sent this entry, or remove that key from the entry, then start a new session",
|
|
16
17
|
credentials_not_carried: "requests do not carry credentials for MCP servers, so the deployment has to mount this one — ask an administrator to configure it in the deployment, or remove the credentials from this entry",
|
|
18
|
+
name_already_mounted: "another server of that name is already mounted on this run and stays in use — rename the server in this agent's configuration, or remove the duplicate",
|
|
17
19
|
};
|
|
18
20
|
const SENTENCE_NAMES_FIELD = {
|
|
19
21
|
malformed_entry: true,
|
|
@@ -22,10 +24,11 @@ const SENTENCE_NAMES_FIELD = {
|
|
|
22
24
|
over_cap: false,
|
|
23
25
|
key_retired: true,
|
|
24
26
|
credentials_not_carried: true,
|
|
27
|
+
name_already_mounted: false,
|
|
25
28
|
};
|
|
26
29
|
const isReason = (x) => typeof x === "string" && MCP_INJECTION_DROP_REASONS.includes(x);
|
|
27
30
|
export function mcpInjectionDroppedNotice(facts) {
|
|
28
|
-
const { sessionId, server, reason, field } = facts;
|
|
31
|
+
const { sessionId, server, reason, field, agent } = facts;
|
|
29
32
|
if (typeof sessionId !== "string" || sessionId.length === 0) {
|
|
30
33
|
throw new TypeError("mcpInjectionDroppedNotice: sessionId is required — a user-audience notice with no session routes nowhere");
|
|
31
34
|
}
|
|
@@ -36,10 +39,13 @@ export function mcpInjectionDroppedNotice(facts) {
|
|
|
36
39
|
throw new TypeError(`mcpInjectionDroppedNotice: reason ${JSON.stringify(reason)} is not one of ${MCP_INJECTION_DROP_REASONS.join("/")}`);
|
|
37
40
|
}
|
|
38
41
|
const fieldSeat = typeof field === "string" && field.length > 0 ? { field } : {};
|
|
42
|
+
const agentName = typeof agent === "string" && agent.length > 0 ? agent : undefined;
|
|
43
|
+
const agentSeat = agentName !== undefined ? { agent: agentName } : {};
|
|
39
44
|
const where = SENTENCE_NAMES_FIELD[reason] && typeof field === "string" && field.length > 0 ? ` (field \`${field}\`)` : "";
|
|
45
|
+
const source = agentName !== undefined ? `declared by agent "${agentName}"` : "from this request";
|
|
40
46
|
return {
|
|
41
47
|
code: "config.entries_not_applied",
|
|
42
|
-
message: `MCP server "${server}"
|
|
43
|
-
detail: { ...entriesNotAppliedDetail("mcp_injection_dropped", [{ entry: server, reason, ...fieldSeat }]), sessionId },
|
|
48
|
+
message: `MCP server "${server}" ${source} was not mounted: ${MCP_INJECTION_DROP_TEXT[reason]}${where}.`,
|
|
49
|
+
detail: { ...entriesNotAppliedDetail("mcp_injection_dropped", [{ entry: server, reason, ...fieldSeat, ...agentSeat }]), sessionId },
|
|
44
50
|
};
|
|
45
51
|
}
|
|
@@ -216,7 +216,8 @@ export interface McpServerSpec {
|
|
|
216
216
|
* spawned under a known task, the spawner's task id (`task_progress.parentTaskId`). One record per leg and run, built at its prepare, so
|
|
217
217
|
* every call and fetch of the run — every attempt of one call included — carries the same; two legs on one pooled connection each send
|
|
218
218
|
* their own. No principal, path or model rides it. Session ids do, with or without {@link sessionMetaKey}: `taskId` is the leg's own
|
|
219
|
-
* session id wherever that is its task id (a foreground child, a workflow member or a top-level leg handed no `taskId`
|
|
219
|
+
* session id wherever that is its task id (a foreground child, a workflow member or a top-level leg handed no `taskId` that keeps no
|
|
220
|
+
* member ledger — one that keeps one runs as the task id the engine minted for it, `rl-…`), and
|
|
220
221
|
* `rootSessionId` is the tree root's session (a top-level leg's own) — a deployment that must not let a server learn any session id does
|
|
221
222
|
* not declare this for it. Absent or `false` ⇒ nothing is sent.
|
|
222
223
|
*
|
package/dist/core/mcp.js
CHANGED
|
@@ -20,6 +20,7 @@ import { LIST_MCP_RESOURCES, MCP_FACE_WORD_DROP_REASON, MCP_RESOURCE_LIST_ALLOW,
|
|
|
20
20
|
import { MCP_CHARS_PER_TOKEN, fetchMcpAnswer, mcpHostReadPorts, mcpMaxOutputTokens, notServed, readMcpListing } from "./mcp-host-read.js";
|
|
21
21
|
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
22
22
|
import { authorizationClause, authorizationOwed, describeHttpTransportFailure, failureFields, livenessOf, lostInFlight, namingLostSession, owesAuthorization, readMcpFailure, sessionGone, unauthorizedLine } from "./mcp-failure.js";
|
|
23
|
+
import { mcpPeerRegistration, peerRegistrationDigestOf } from "./peer-registration.js";
|
|
23
24
|
import { DEFAULT_REQUEST_TIMEOUT_MSEC } from "@modelcontextprotocol/client";
|
|
24
25
|
import { mediaBlockTypeOf } from "./image-admission.js";
|
|
25
26
|
import { keepBytesWith, mediaTypePhrase, noteKeptPiece, withKeptPieces } from "./tool-result-bytes.js";
|
|
@@ -1825,6 +1826,7 @@ async function connectServer(spec, principal, onElicit, binarySeat, reminderDisc
|
|
|
1825
1826
|
}
|
|
1826
1827
|
function intakeListedTools(listed, spec, link, declared, validator, binarySeat, reminderDisclosure, through = OPEN_DOOR, transportKind, seat, echo = NO_CREDENTIAL_ECHO, onSubtreeActivity) {
|
|
1827
1828
|
const declaredContentOrigin = spec.contentOrigin;
|
|
1829
|
+
const registration = peerRegistrationDigestOf("mcp", mcpPeerRegistration(spec, transportKind));
|
|
1828
1830
|
const serverTools = [];
|
|
1829
1831
|
const serverAxes = [];
|
|
1830
1832
|
const gates = new Map();
|
|
@@ -1913,7 +1915,7 @@ function intakeListedTools(listed, spec, link, declared, validator, binarySeat,
|
|
|
1913
1915
|
...(mcpMaxResultSizeChars !== undefined ? { mcpMaxResultSizeChars } : {}),
|
|
1914
1916
|
...(mcpAlwaysLoad ? { mcpAlwaysLoad: true } : {}),
|
|
1915
1917
|
...gateFace,
|
|
1916
|
-
mcpRemoteName: remoteName, ...boundaryFlowFace(spec.toolAxes?.[remoteName]), permissionSeat: "passthrough",
|
|
1918
|
+
mcpRemoteName: remoteName, ...boundaryFlowFace(spec.toolAxes?.[remoteName]), permissionSeat: "passthrough", peerRegistration: registration,
|
|
1917
1919
|
execute: async (toolCallId, params, signal) => {
|
|
1918
1920
|
const what = `The call to tool ${foreignLine(remoteName)}`;
|
|
1919
1921
|
if (taskRequired) {
|
|
@@ -44,7 +44,7 @@ export type MemberOutcomeWord = (typeof MEMBER_OUTCOMES)[number];
|
|
|
44
44
|
/** Membership test for {@link MemberOutcomeWord} — the word crosses process boundaries on the completion frames and the stored rows. */
|
|
45
45
|
export declare function isMemberOutcomeWord(v: unknown): v is MemberOutcomeWord;
|
|
46
46
|
/** What kind of member a row is. Grows by a word when a new holder mints rows (a peer task, a nested workflow). */
|
|
47
|
-
export declare const MEMBER_KINDS: readonly ["workflow_member", "subagent", "background_agent"];
|
|
47
|
+
export declare const MEMBER_KINDS: readonly ["workflow_member", "subagent", "background_agent", "workflow", "peer_task"];
|
|
48
48
|
export type MemberKind = (typeof MEMBER_KINDS)[number];
|
|
49
49
|
/**
|
|
50
50
|
* What ended the run whose end stopped a member (the closed set of {@link MemberOutcome.runEnd}`.cause`). The five stop words are the
|
|
@@ -215,7 +215,8 @@ export type MemberFacts = {
|
|
|
215
215
|
readonly runEnd?: MemberOutcome["runEnd"];
|
|
216
216
|
readonly refused?: MemberRefusals;
|
|
217
217
|
};
|
|
218
|
-
/** The ONE mint of a member's outcome. `kind` / `provenance` are the holder's
|
|
218
|
+
/** The ONE mint of a member's outcome. `kind` / `provenance` are the holder's; `kind` is carried as {@link isMemberOutcome} reads it
|
|
219
|
+
* (a string — a later release's word passes through). The outcome comes back sealed ({@link sealMemberOutcome}). */
|
|
219
220
|
export declare function memberOutcomeOf(kind: MemberKind, provenance: "live" | "replayed", facts: MemberFacts): MemberOutcome;
|
|
220
221
|
/**
|
|
221
222
|
* A background agent row's outcome, as the task registry mints it at the settle that wins the row (first writer wins): the winning
|
|
@@ -6,7 +6,7 @@ const MEMBER_OUTCOME_SET = new Set(MEMBER_OUTCOMES);
|
|
|
6
6
|
export function isMemberOutcomeWord(v) {
|
|
7
7
|
return MEMBER_OUTCOME_SET.has(v);
|
|
8
8
|
}
|
|
9
|
-
export const MEMBER_KINDS = Object.freeze(["workflow_member", "subagent", "background_agent"]);
|
|
9
|
+
export const MEMBER_KINDS = Object.freeze(["workflow_member", "subagent", "background_agent", "workflow", "peer_task"]);
|
|
10
10
|
export const RUN_END_CAUSES = Object.freeze(["turn_end", "one_shot_ceiling", "interrupt", "walltime", "turns", "budget", "signal"]);
|
|
11
11
|
const RUN_END_CAUSE_SET = new Set(RUN_END_CAUSES);
|
|
12
12
|
export function isRunEndCause(v) {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { EntryCustodyReport } from "./file-backend.js";
|
|
2
|
+
import type { MemoryBackend } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A store's answer for one id it does not hold:
|
|
5
|
+
* - `never` — its record is whole and names no deletion of the id in this scope: the id is new to it;
|
|
6
|
+
* - `deleted` — its record names a deletion of the id in this scope; `rev` is the version deleted last, when carried;
|
|
7
|
+
* - `undecidable` — its record cannot say (the chain is damaged, an event id is contradicted, a deletion omits scope,
|
|
8
|
+
* the store keeps no custody face, or the read failed); `why` says which. `why` is the engine's sentence: every word in it
|
|
9
|
+
* the store wrote (an event id, a damage reason, a read's thrown text) went through `foreignLine` where it was put in.
|
|
10
|
+
*/
|
|
11
|
+
export type DeletionRecord = {
|
|
12
|
+
readonly kind: "never";
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "deleted";
|
|
15
|
+
readonly rev?: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "undecidable";
|
|
18
|
+
readonly why: string;
|
|
19
|
+
};
|
|
20
|
+
/** The precedence every reader of deletion evidence shares: a deletion the record names stands even when the rest of the
|
|
21
|
+
* record is impeached (a sound prefix proves it); otherwise an impeached record answers nothing; otherwise the id was
|
|
22
|
+
* never deleted. `deletedRev`: `undefined` = no deletion named, `null` = one named without its version. */
|
|
23
|
+
export declare function deletionRecordFrom(evidence: {
|
|
24
|
+
readonly deletedRev: string | null | undefined;
|
|
25
|
+
readonly sound: boolean;
|
|
26
|
+
readonly unsoundWhy?: string;
|
|
27
|
+
}): DeletionRecord;
|
|
28
|
+
/** The record one custody report (`custodyOf(id)`, the File store's or any backend's) gives for `id` in `scope`;
|
|
29
|
+
* `undefined` = the store has no custody face. A deletion event is a fact of its own scope (`scope` or legacy
|
|
30
|
+
* `from.scope`) and invisible from any other scope; one carrying no scope, or a contradicted `ev`, fails closed. */
|
|
31
|
+
export declare function deletionRecordOf(id: string, custody: EntryCustodyReport | undefined, scope: string): DeletionRecord;
|
|
32
|
+
/** The store's answer for an id a memory file carries in `scope` that no baseline of the mount names, given where the
|
|
33
|
+
* store holds it (`placement`): `held` when it holds it somewhere (the copy / rename lanes answer), otherwise its
|
|
34
|
+
* deletion record for `scope` — a placement that cannot be read answers `undecidable`, never `never`. */
|
|
35
|
+
export declare function unheldIdRecord(backend: MemoryBackend, id: string, scope: string, placement: {
|
|
36
|
+
readonly state: "absent" | "held" | "unknown";
|
|
37
|
+
}): Promise<DeletionRecord | {
|
|
38
|
+
readonly kind: "held";
|
|
39
|
+
}>;
|
|
40
|
+
/** The harvest's reason for not committing such a file: deleted ⇒ refused (the caller contains it); undecidable ⇒ deferred. */
|
|
41
|
+
export declare function unheldIdRefusal(record: Extract<DeletionRecord, {
|
|
42
|
+
kind: "deleted" | "undecidable";
|
|
43
|
+
}>): string;
|
|
44
|
+
/** Read the store's deletion record in `scope` for each id (its `custodyOf` face, one read per id). A store without the
|
|
45
|
+
* face, a throwing getter, or a read that throws answers `undecidable` for that id — never `never`. */
|
|
46
|
+
export declare function memoryDeletionRecords(backend: MemoryBackend, ids: Iterable<string>, scope: string): Promise<Map<string, DeletionRecord>>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { foreignLine } from "../protocol-http-auth.js";
|
|
2
|
+
import { thrownText } from "../thrown-value.js";
|
|
3
|
+
import { inlineUntrusted } from "../untrusted-text.js";
|
|
4
|
+
function deleteEventScope(ev) {
|
|
5
|
+
if (typeof ev["scope"] === "string" && ev["scope"].length > 0)
|
|
6
|
+
return ev["scope"];
|
|
7
|
+
const from = ev["from"];
|
|
8
|
+
if (from !== null && typeof from === "object") {
|
|
9
|
+
const fromScope = from.scope;
|
|
10
|
+
if (typeof fromScope === "string" && fromScope.length > 0)
|
|
11
|
+
return fromScope;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
export function deletionRecordFrom(evidence) {
|
|
16
|
+
if (evidence.deletedRev !== undefined)
|
|
17
|
+
return evidence.deletedRev === null ? { kind: "deleted" } : { kind: "deleted", rev: evidence.deletedRev };
|
|
18
|
+
if (!evidence.sound)
|
|
19
|
+
return { kind: "undecidable", why: evidence.unsoundWhy ?? "the store's deletion record is damaged" };
|
|
20
|
+
return { kind: "never" };
|
|
21
|
+
}
|
|
22
|
+
export function deletionRecordOf(id, custody, scope) {
|
|
23
|
+
if (typeof scope !== "string" || scope.length === 0)
|
|
24
|
+
throw new TypeError("deletionRecordOf: scope must be a non-empty string");
|
|
25
|
+
if (custody === undefined)
|
|
26
|
+
return { kind: "undecidable", why: "the store keeps no deletion record (it has no custodyOf face)" };
|
|
27
|
+
const seenEvs = new Set();
|
|
28
|
+
let deletedRev;
|
|
29
|
+
let scopelessDelete = false;
|
|
30
|
+
for (const ev of custody.events) {
|
|
31
|
+
if (typeof ev.ev === "string" && ev.ev.length > 0) {
|
|
32
|
+
if (seenEvs.has(ev.ev)) {
|
|
33
|
+
return { kind: "undecidable", why: `the store's deletion record carries event id "${foreignLine(ev.ev, 80)}" twice with conflicting payloads` };
|
|
34
|
+
}
|
|
35
|
+
seenEvs.add(ev.ev);
|
|
36
|
+
}
|
|
37
|
+
if (ev.channel !== "delete" || ev["id"] !== id)
|
|
38
|
+
continue;
|
|
39
|
+
const evScope = deleteEventScope(ev);
|
|
40
|
+
if (evScope === undefined) {
|
|
41
|
+
scopelessDelete = true;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (evScope !== scope)
|
|
45
|
+
continue;
|
|
46
|
+
deletedRev = typeof ev["rev"] === "string" && ev["rev"].length > 0 ? ev["rev"] : null;
|
|
47
|
+
}
|
|
48
|
+
if (scopelessDelete)
|
|
49
|
+
return { kind: "undecidable", why: "a deletion event for this id carries no scope — whether it deleted this scope's entry cannot be read" };
|
|
50
|
+
return deletionRecordFrom({ deletedRev, sound: custody.state === "complete", unsoundWhy: `the store's deletion record for this id is damaged${custody.reason !== undefined ? ` (${foreignLine(custody.reason, 200)})` : ""}` });
|
|
51
|
+
}
|
|
52
|
+
export async function unheldIdRecord(backend, id, scope, placement) {
|
|
53
|
+
if (placement.state === "held")
|
|
54
|
+
return { kind: "held" };
|
|
55
|
+
if (placement.state === "unknown")
|
|
56
|
+
return { kind: "undecidable", why: "where the store holds this id could not be read" };
|
|
57
|
+
return (await memoryDeletionRecords(backend, [id], scope)).get(id);
|
|
58
|
+
}
|
|
59
|
+
export function unheldIdRefusal(record) {
|
|
60
|
+
return record.kind === "deleted"
|
|
61
|
+
? "the memory store deleted the entry this file's id names — a deleted entry's bytes are never taken back; to keep the text, write it as a new note without the id line"
|
|
62
|
+
: `memory write deferred: this file carries an id the memory store does not hold, and whether the store deleted that entry cannot be read (${inlineUntrusted(record.why, 200)}) — not committed, so a deleted entry is never taken back; remove the id line to commit it as a new note`;
|
|
63
|
+
}
|
|
64
|
+
export async function memoryDeletionRecords(backend, ids, scope) {
|
|
65
|
+
if (typeof scope !== "string" || scope.length === 0)
|
|
66
|
+
throw new TypeError("memoryDeletionRecords: scope must be a non-empty string");
|
|
67
|
+
let face;
|
|
68
|
+
let faceErr;
|
|
69
|
+
try {
|
|
70
|
+
const raw = backend.custodyOf;
|
|
71
|
+
face = typeof raw === "function" ? raw : undefined;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
faceErr = foreignLine(thrownText(err), 200);
|
|
75
|
+
}
|
|
76
|
+
const out = new Map();
|
|
77
|
+
for (const id of ids) {
|
|
78
|
+
if (out.has(id))
|
|
79
|
+
continue;
|
|
80
|
+
if (faceErr !== undefined) {
|
|
81
|
+
out.set(id, { kind: "undecidable", why: `the store's deletion record could not be read (${faceErr})` });
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (face === undefined) {
|
|
85
|
+
out.set(id, deletionRecordOf(id, undefined, scope));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
out.set(id, deletionRecordOf(id, await face.call(backend, id), scope));
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
out.set(id, { kind: "undecidable", why: `the store's deletion record could not be read (${foreignLine(thrownText(err), 200)})` });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|