@sema-agent/core 7.59.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 +564 -0
- 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/child-model-seat.js +6 -3
- 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/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 +11 -38
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +117 -78
- 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/degrading.js +3 -1
- package/dist/brain/route-adjudicator.js +3 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/timeout.d.ts +3 -1
- package/dist/brain/timeout.js +18 -5
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +2 -0
- package/dist/core/allow-entry.js +3 -1
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -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 +10 -1
- 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-store.d.ts +8 -13
- package/dist/core/checkpoint-store.js +4 -3
- package/dist/core/compliance.d.ts +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/engine-notice.d.ts +58 -15
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +7 -5
- package/dist/core/gate-lanes.js +39 -8
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +12 -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 +39 -56
- package/dist/core/hooks.js +123 -77
- package/dist/core/image-admission.d.ts +104 -51
- package/dist/core/image-admission.js +170 -46
- 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 +54 -3
- package/dist/core/locked-config.js +81 -50
- 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 +9 -3
- package/dist/core/mcp-failure.js +10 -0
- 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-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +17 -6
- package/dist/core/mcp.js +67 -55
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- 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/index.d.ts +2 -1
- package/dist/core/memory-engine/index.js +2 -1
- 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 +45 -11
- package/dist/core/memory-engine/sync-client.js +82 -11
- 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 +4 -2
- 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/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +10 -4
- package/dist/core/mods/kernel/events.js +10 -6
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -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 +51 -59
- package/dist/core/mods/stations.js +32 -42
- 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/park-selfcheck.js +8 -8
- package/dist/core/peer-seat.d.ts +63 -8
- package/dist/core/peer-seat.js +179 -34
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +1 -2
- package/dist/core/permission-rule-model.d.ts +4 -2
- package/dist/core/permission-rule-model.js +7 -6
- 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/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 +12 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +37 -3
- package/dist/core/roles.js +126 -78
- package/dist/core/rule-owner.d.ts +3 -0
- 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 +21 -10
- 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 +62 -41
- 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/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 +75 -7
- package/dist/core/runner/gate-exit.js +20 -1
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- 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 +4 -4
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +14 -9
- package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
- package/dist/core/runner/prepare-delegation-surface.js +4 -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 +3 -1
- package/dist/core/runner/prepare-hands-readface.js +15 -7
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
- package/dist/core/runner/prepare-inherited-gate.js +9 -5
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +3 -5
- package/dist/core/runner/prepare-park-ask.js +3 -8
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
- package/dist/core/runner/prepare-policy-chain.js +120 -108
- package/dist/core/runner/prepare-project-context.js +8 -5
- package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +9 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +41 -27
- 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 +4 -3
- package/dist/core/runner/prepare-wiring-manifest.js +32 -18
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +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.js +1 -1
- package/dist/core/runner/run-leg.js +26 -28
- 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 +12 -4
- package/dist/core/runner/run-turn-boundary.js +12 -7
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +19 -11
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.js +10 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -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-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 +3 -5
- package/dist/core/runner/turn-attachments.js +3 -16
- package/dist/core/runner-deps.d.ts +31 -18
- package/dist/core/secret-env.d.ts +3 -2
- package/dist/core/session-policy-store.d.ts +9 -2
- package/dist/core/session-policy-store.js +16 -1
- package/dist/core/session-store.d.ts +3 -2
- package/dist/core/session-store.js +50 -11
- package/dist/core/skill-grant.d.ts +9 -0
- package/dist/core/skill-grant.js +18 -0
- 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/task-event.d.ts +18 -2
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +130 -7
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +18 -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 +38 -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 +3 -6
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +1 -1
- 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 +5 -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-spec.d.ts +20 -4
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +14 -6
- package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
- package/dist/engine/execution-env/node-execution-env.js +12 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +8 -4
- package/dist/engine/harness/types.d.ts +112 -29
- package/dist/engine/loop/agent-loop.d.ts +12 -12
- package/dist/engine/loop/agent-loop.js +153 -21
- package/dist/engine/loop/types.d.ts +9 -2
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/index.d.ts +22 -14
- package/dist/index.js +15 -10
- package/dist/internal/harness-types.d.ts +1 -1
- 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.d.ts +4 -0
- package/dist/orchestration/workflow.js +25 -4
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +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 +3 -1
- 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 +8 -4
- package/dist/tools/fs/fs-bash.js +26 -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 +8 -4
- package/dist/tools/fs/read-floor.d.ts +44 -1
- package/dist/tools/fs/read-floor.js +35 -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/monitor.d.ts +5 -4
- package/dist/tools/monitor.js +15 -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 +4 -2
- package/test/export-surface.snapshot.json +75 -21
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
|
@@ -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 };
|
|
@@ -798,9 +798,9 @@ export type ConstraintChainEntry = ConstraintChainEntryMeta & ({
|
|
|
798
798
|
components: readonly ToolPolicyProjectionComponent[];
|
|
799
799
|
requiresLiveRemainder: boolean;
|
|
800
800
|
});
|
|
801
|
-
/** Project one policy into its chain entry (opaque placeholder when it exports no projection
|
|
802
|
-
* carrying the layer's decision-chain metadata posture for the digest (round 12). */
|
|
803
|
-
export declare function constraintChainEntryOf(policy: ToolPolicy, meta?: ConstraintChainEntryMeta): ConstraintChainEntry;
|
|
801
|
+
/** Project one chain entry's policy into its chain entry (opaque placeholder when it exports no projection, and for a
|
|
802
|
+
* screening installation, which has no policy), carrying the layer's decision-chain metadata posture for the digest (round 12). */
|
|
803
|
+
export declare function constraintChainEntryOf(policy: ToolPolicy | undefined, meta?: ConstraintChainEntryMeta): ConstraintChainEntry;
|
|
804
804
|
/**
|
|
805
805
|
* One inherited-chain LAYER as both chain-entry mint sites see it — structurally an
|
|
806
806
|
* `InheritedGate.parentConstraints[]` element, typed here structurally so this module (which owns the
|
|
@@ -808,7 +808,8 @@ export declare function constraintChainEntryOf(policy: ToolPolicy, meta?: Constr
|
|
|
808
808
|
* state between rounds, so nothing about its health enters a chain entry.
|
|
809
809
|
*/
|
|
810
810
|
export interface ConstraintChainLayerView {
|
|
811
|
-
|
|
811
|
+
/** Absent on a screening installation (projected opaque, as its judgments live on its own bus). */
|
|
812
|
+
policy?: ToolPolicy | undefined;
|
|
812
813
|
autoMode?: {
|
|
813
814
|
arming?: unknown;
|
|
814
815
|
};
|
package/dist/core/tool-policy.js
CHANGED
|
@@ -187,7 +187,7 @@ export function constraintChainEntryOf(policy, meta) {
|
|
|
187
187
|
...(meta?.durableMandate ? { durableMandate: true } : {}),
|
|
188
188
|
...(meta?.contentMandate ? { contentMandate: true } : {}),
|
|
189
189
|
};
|
|
190
|
-
const p = policy
|
|
190
|
+
const p = policy?.projection;
|
|
191
191
|
if (p === undefined)
|
|
192
192
|
return { opaque: true, ...m };
|
|
193
193
|
return { components: p.components, requiresLiveRemainder: p.requiresLiveRemainder, ...m };
|
|
@@ -43,14 +43,14 @@ export interface PersistenceFacts {
|
|
|
43
43
|
readonly exclude?: readonly string[];
|
|
44
44
|
/** The leg's by-name effect map: the fallback for a tool that declares no `effect` of its own (silent ⇒ `"write"`). */
|
|
45
45
|
readonly effects?: ReadonlyMap<string, import("./tool-spec.js").ToolEffect>;
|
|
46
|
-
/** The hand band is mounted on
|
|
47
|
-
* root, so their presence proves nothing about persistence there. */
|
|
48
|
-
readonly
|
|
46
|
+
/** The hand band is mounted on an env whose paths are not the host's (`pathsAreHostLocal` is false): its file tools
|
|
47
|
+
* write that filesystem, not the host-side memory root, so their presence proves nothing about persistence there. */
|
|
48
|
+
readonly handsOffHost: boolean;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* The names, among a run's MOUNTED tools (instances, whose face members sit on the object itself), the persistence
|
|
52
52
|
* judgment passes. The judgment's inputs beyond the tools (the exclude snapshot, the by-name effect map, whether the
|
|
53
|
-
* hand band is
|
|
53
|
+
* hand band is off the host's disk) are leg facts only the run holds; {@link rosterCanPersistMemory} is the verdict built on it.
|
|
54
54
|
*/
|
|
55
55
|
export declare function persistenceCapableToolNames(tools: ReadonlyArray<PersistenceProbeTool>, facts: PersistenceFacts): string[];
|
|
56
56
|
/**
|
|
@@ -61,7 +61,7 @@ export declare function persistenceCapableToolNames(tools: ReadonlyArray<Persist
|
|
|
61
61
|
export declare function rosterCanPersistMemory(tools: ReadonlyArray<PersistenceProbeTool>, facts: PersistenceFacts, declared?: boolean): boolean;
|
|
62
62
|
/**
|
|
63
63
|
* The CANDIDATE set, from the static catalog alone: the names whose definition passes the same judgment on no leg
|
|
64
|
-
* facts at all (nothing excluded, no by-name effect map, hands
|
|
64
|
+
* facts at all (nothing excluded, no by-name effect map, hands on the host's disk) — the tools that COULD persist on a leg
|
|
65
65
|
* that mounts them. A prediction, not a verdict: whether a given run's roster persists is
|
|
66
66
|
* {@link rosterCanPersistMemory}, which the runner calls with the facts the run holds.
|
|
67
67
|
*/
|
|
@@ -36,7 +36,7 @@ function toolCanPersist(t, facts) {
|
|
|
36
36
|
const family = t.family ?? catalogEntriesNamed(t.name)[0]?.face.family;
|
|
37
37
|
if (!((pathTarget !== undefined && pathTarget.access !== "read") || family === "shell"))
|
|
38
38
|
return false;
|
|
39
|
-
return !facts.
|
|
39
|
+
return !facts.handsOffHost;
|
|
40
40
|
}
|
|
41
41
|
export function persistenceCapableToolNames(tools, facts) {
|
|
42
42
|
const out = new Set();
|
|
@@ -50,7 +50,7 @@ export function rosterCanPersistMemory(tools, facts, declared) {
|
|
|
50
50
|
}
|
|
51
51
|
export function persistenceCandidateToolNames() {
|
|
52
52
|
const rows = TOOL_CATALOG_ENTRIES.map((e) => ({ name: e.name, effect: e.face.effect, pathTarget: e.face.pathTarget, family: e.face.family }));
|
|
53
|
-
return persistenceCapableToolNames(rows, {
|
|
53
|
+
return persistenceCapableToolNames(rows, { handsOffHost: false });
|
|
54
54
|
}
|
|
55
55
|
export function pathTargetingToolNames() {
|
|
56
56
|
return names((e) => e.face.pathTarget !== undefined);
|
|
@@ -118,6 +118,52 @@ export interface ToolResultStore {
|
|
|
118
118
|
* audit receipts, scheduled execution), of which this is one caller-driven erase.
|
|
119
119
|
*/
|
|
120
120
|
deleteBySession?(sessionId: string): Promise<ToolResultDeletionReport> | ToolResultDeletionReport;
|
|
121
|
+
/**
|
|
122
|
+
* The READ half of the same ownership coordinate {@link deleteBySession} erases by: every entry this store recorded as belonging to
|
|
123
|
+
* `sessionId`, as the ref and the owner recorded at its winning write. Without it the offloaded results a session's transcript
|
|
124
|
+
* points at have no way out of a store, so a session moved to another store reads references it cannot dereference.
|
|
125
|
+
*
|
|
126
|
+
* The listing is the whole of the export: the bytes are read with {@link get} (bounded slices; `totalChars` says how much) and
|
|
127
|
+
* land in the other store with `put(ref, content, entry.provenance)` — that store's write-once election makes a repeated move an
|
|
128
|
+
* idempotent no-op and a ref that already belongs to a different owner a typed refusal ({@link ToolResultRefConflictError}).
|
|
129
|
+
* There is no second path for content.
|
|
130
|
+
*
|
|
131
|
+
* Rules every implementation follows, the same selection as {@link deleteBySession}:
|
|
132
|
+
* - **selection is by RECORDED PROVENANCE, never by parsing the ref**; `taskId` is ignored in the match (the entry's
|
|
133
|
+
* `provenance` still carries the one that was recorded — it is the very owner the importing `put` states);
|
|
134
|
+
* - **an UNOWNED entry is never listed**: it belongs to no session this call can name. It is counted in
|
|
135
|
+
* {@link ToolResultSessionListing.unattributable} (store-wide, the same figure a sweep reports), so a caller learns the
|
|
136
|
+
* listing cannot speak for such rows rather than being told a clean "that is all";
|
|
137
|
+
* - an entry the session owns but whose ref the store cannot name — only an entry written before the store recorded the ref beside
|
|
138
|
+
* it — is counted in {@link ToolResultSessionListing.unaddressable}, never listed under a guessed ref;
|
|
139
|
+
* - the listing is a snapshot with no order promised; an entry that disappears before the caller reads it is honest absence
|
|
140
|
+
* (`get` answers `undefined`), and a listing of a session with no entries is empty, not an error.
|
|
141
|
+
*
|
|
142
|
+
* Typed OPTIONAL, and an OPTIONAL leg of the published contract kit (`toolResultStoreContract`): a store that cannot enumerate
|
|
143
|
+
* by owner is still a usable offload store, so absence is a checkable fact reported through `onOptionalMember`, never a
|
|
144
|
+
* contract breach. Implementing it does NOT make a store `retention: "managed"`.
|
|
145
|
+
*/
|
|
146
|
+
listBySession?(sessionId: string): Promise<ToolResultSessionListing> | ToolResultSessionListing;
|
|
147
|
+
}
|
|
148
|
+
/** One entry a {@link ToolResultStore.listBySession} listing names: the ref and the owner recorded at its winning write — the two
|
|
149
|
+
* arguments an importing store's `put` takes beside the content `get` returns. */
|
|
150
|
+
export interface ToolResultListedEntry {
|
|
151
|
+
readonly ref: string;
|
|
152
|
+
readonly provenance: ToolResultProvenance;
|
|
153
|
+
}
|
|
154
|
+
/** What a {@link ToolResultStore.listBySession} call answers. */
|
|
155
|
+
export interface ToolResultSessionListing {
|
|
156
|
+
/** The session's entries, in no particular order. */
|
|
157
|
+
readonly entries: readonly ToolResultListedEntry[];
|
|
158
|
+
/** Entries the store could not attribute to ANY session (stored without provenance, or with an unreadable owner record) and so did
|
|
159
|
+
* not list: store-wide, the same figure {@link ToolResultDeletionReport.unattributable} reports. */
|
|
160
|
+
readonly unattributable: number;
|
|
161
|
+
/** Entries the session owns whose ref this store cannot name, so they are not listed. It counts ONE thing only — entries written
|
|
162
|
+
* before the store recorded the ref beside the entry (a file backend's folded file name is a digest of the ref, and the owner record
|
|
163
|
+
* it writes now carries the ref; records written by earlier versions do not). It is not a second kind of entry: a store whose
|
|
164
|
+
* entries were all written by a version that records the ref reports `0`, always. Such an entry is still removed by
|
|
165
|
+
* {@link ToolResultStore.deleteBySession}, so `entries.length + unaddressable` is the number a sweep of the session then deletes. */
|
|
166
|
+
readonly unaddressable: number;
|
|
121
167
|
}
|
|
122
168
|
/**
|
|
123
169
|
* What a {@link ToolResultStore.deleteBySession} sweep actually did. A count, not a `void`, because the
|
|
@@ -275,6 +321,11 @@ export declare function assertSafeToolResultRef(ref: string): void;
|
|
|
275
321
|
* matches.
|
|
276
322
|
*/
|
|
277
323
|
export declare function buildToolResultRef(sessionId: string, toolCallId: string, ...extraSegments: string[]): string;
|
|
324
|
+
/** The task whose result `ref` holds, read off the segment {@link buildTaskArtifactRef} put it in — `undefined` for every other
|
|
325
|
+
* ref, which by construction is not a task's result (only that mint carries {@link TASK_ARTIFACT_SEGMENT}). An origin, never an
|
|
326
|
+
* owner: who may read the bytes is still {@link ToolResultStore.ownerOf}'s answer. A task id the mint had to fold comes back as
|
|
327
|
+
* its folded segment, which names no task — the reading of a task that is gone. */
|
|
328
|
+
export declare function taskArtifactOriginOf(ref: string): string | undefined;
|
|
278
329
|
/**
|
|
279
330
|
* Backlog #119 — the ceiling on a ref this module can mint, so a durable backend can size its key
|
|
280
331
|
* column from a stated invariant instead of a guess (TiDB's was `VARCHAR(191)`, which a long
|
|
@@ -320,7 +371,6 @@ export interface ToolResultSlice {
|
|
|
320
371
|
* on the existing honest "may have expired" text). Durability across restarts still requires a real
|
|
321
372
|
* store (e.g. FileToolResultStore) via `RunnerDeps.toolResultStore`. */
|
|
322
373
|
export declare class InMemoryToolResultStore implements ToolResultStore {
|
|
323
|
-
private readonly opts?;
|
|
324
374
|
/** Managed-retention declaration (retention.ts): whether this store's rows are deleted on schedule by the deployment — given by
|
|
325
375
|
* the party that runs the sweep (the `retention` option), `"none"` when none is given; the store itself is put/get only. */
|
|
326
376
|
readonly retention: RetentionDeclaration;
|
|
@@ -330,10 +380,12 @@ export declare class InMemoryToolResultStore implements ToolResultStore {
|
|
|
330
380
|
private totalChars;
|
|
331
381
|
/** @param opts.retention the store's managed-retention declaration, default `"none"`; a word other than the two is refused
|
|
332
382
|
* (`config.retention_capability`). */
|
|
333
|
-
|
|
383
|
+
/** The bound, read once at construction by the integer reading (`undefined` = unbounded): the one value the eviction enforces. */
|
|
384
|
+
private readonly maxTotalChars;
|
|
385
|
+
constructor(options?: {
|
|
334
386
|
maxTotalChars?: number;
|
|
335
387
|
retention?: RetentionDeclaration;
|
|
336
|
-
}
|
|
388
|
+
});
|
|
337
389
|
put(ref: string, content: string, provenance?: ToolResultProvenance): void;
|
|
338
390
|
/** The owner recorded at the winning write; `undefined` for unknown AND for unowned entries,
|
|
339
391
|
* which a read face treats identically (fail-closed). */
|
|
@@ -344,6 +396,9 @@ export declare class InMemoryToolResultStore implements ToolResultStore {
|
|
|
344
396
|
* same provenance match applies with none of the file backend's two-object bookkeeping. Deleting
|
|
345
397
|
* from a Map while iterating it is defined (a removed key is simply not revisited). */
|
|
346
398
|
deleteBySession(sessionId: string): ToolResultDeletionReport;
|
|
399
|
+
/** This session's entries, selected on the owner recorded at the winning write — the very match {@link deleteBySession} runs (the
|
|
400
|
+
* interface states the rules). The ref is the map key, so every owned entry is nameable. */
|
|
401
|
+
listBySession(sessionId: string): ToolResultSessionListing;
|
|
347
402
|
/** design/80 D-2: true when NOTHING has been offloaded — a durable suspend can then proceed safely even on
|
|
348
403
|
* this in-memory store, because a cross-replica resume has no offloaded result to deref to null. */
|
|
349
404
|
isEmpty(): boolean;
|
|
@@ -431,6 +486,30 @@ onNotice?: (notice: import("./types.js").EngineNotice) => void): (toolCallId: st
|
|
|
431
486
|
* already has in hand. `taskId` is omitted (not `undefined`-valued) when the run declares none, so the
|
|
432
487
|
* stored shape compares equal across a durable round-trip. */
|
|
433
488
|
export declare function toolResultProvenanceOf(sessionId: string, taskId?: string): ToolResultProvenance;
|
|
489
|
+
/** Where a background task's result is written when its completion notification carries less than the whole of it: the
|
|
490
|
+
* offload store the receiving run's {@link OFFLOAD_TOOL_NAME} reads, and the session that run's refs are minted under. */
|
|
491
|
+
export interface TaskArtifactSeat {
|
|
492
|
+
readonly store: ToolResultStore;
|
|
493
|
+
readonly sessionId: string;
|
|
494
|
+
}
|
|
495
|
+
/** What {@link persistTaskArtifact} answers: the ref the text is stored under, a write that failed or went unconfirmed
|
|
496
|
+
* (no ref — a ref nobody can read back is a false promise), or no store to write to. */
|
|
497
|
+
export type TaskArtifact = {
|
|
498
|
+
readonly kind: "stored";
|
|
499
|
+
readonly ref: string;
|
|
500
|
+
} | {
|
|
501
|
+
readonly kind: "unconfirmed";
|
|
502
|
+
} | {
|
|
503
|
+
readonly kind: "no_store";
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* THE one write of a background task's result artifact. The ref is CONTENT-ADDRESSED (task id + a digest of the text):
|
|
507
|
+
* two cycles of one task with different answers get different refs, and the same answer written twice lands on the same
|
|
508
|
+
* write-once row — no cycle number is read, so a row reseeded after a restart (whose cycle counter restarts) cannot
|
|
509
|
+
* land a new answer on an old ref. The put is awaited before the answer is returned, so a caller that announces the ref
|
|
510
|
+
* announces a write that already landed.
|
|
511
|
+
*/
|
|
512
|
+
export declare function persistTaskArtifact(seat: TaskArtifactSeat | undefined, taskId: string, text: string): Promise<TaskArtifact>;
|
|
434
513
|
/**
|
|
435
514
|
* RB-374① — the ONE source of the "page the offloaded text back" suggestion sentence, shared by
|
|
436
515
|
* {@link buildPreview} (offload preview tail) and context-edit's cleared-marker refNote. The two
|
|
@@ -495,5 +574,9 @@ export declare const OFFLOADED_DETAIL_NOTICE_PREFIX = "\u2026[offloaded \u2014 "
|
|
|
495
574
|
/** True when `s` carries an offloaded-detail replacement notice (the newline-anchored prefix form the
|
|
496
575
|
* walk emits). A semantic consumer treats such a string as NOT the member's real bytes. */
|
|
497
576
|
export declare function isOffloadedDetailReplacement(s: string): boolean;
|
|
498
|
-
/** The injected `read_tool_result` tool: pages through an offloaded result. `effect:"read"` (verifier/reconcile-safe).
|
|
499
|
-
|
|
577
|
+
/** The injected `read_tool_result` tool: pages through an offloaded result. `effect:"read"` (verifier/reconcile-safe).
|
|
578
|
+
* `legsOfRef` = the legs a page-back of one ref travels: a ref holding a background task's result (`persistTaskArtifact`, its
|
|
579
|
+
* origin in the ref — {@link taskArtifactOriginOf}) travels the legs a poll of that task travels — content from another tree is
|
|
580
|
+
* an off-target read however it is read back — and the registry's reading answers it; absent, or for any other ref (offloaded
|
|
581
|
+
* tool output), none. */
|
|
582
|
+
export declare function createReadToolResultTool(store: ToolResultStore, legsOfRef?: (ref: string, tree: import("./cross-boundary-taint.js").CrossBoundaryTreeToken) => import("./cross-boundary-taint.js").BoundaryLegsGiven): AgentTool;
|
|
@@ -8,6 +8,8 @@ import { mountRuleFace, toolFace } from "./tool-catalog-entries.js";
|
|
|
8
8
|
import { thrownText } from "./thrown-value.js";
|
|
9
9
|
import { readRetentionDeclaration } from "./retention.js";
|
|
10
10
|
import { carryNotStartedReceipt } from "./delegation-not-started.js";
|
|
11
|
+
import { receiveOptions } from "./own-property-receipt.js";
|
|
12
|
+
import { NON_NEGATIVE_SAFE_INTEGER, readIntegerOption } from "./integer-option.js";
|
|
11
13
|
export const TOOL_RESULT_REF_CONFLICT_CODE = "tool_result.ref_conflict";
|
|
12
14
|
export class ToolResultRefConflictError extends Error {
|
|
13
15
|
ref;
|
|
@@ -51,7 +53,18 @@ const MAX_REF_SEGMENT_CHARS = 128;
|
|
|
51
53
|
const REF_SEGMENT_SEPARATOR = "~";
|
|
52
54
|
const FOLDED_SEGMENT_PREFIX = "fold.";
|
|
53
55
|
export function buildToolResultRef(sessionId, toolCallId, ...extraSegments) {
|
|
54
|
-
return
|
|
56
|
+
return composeToolResultRef(sessionId, [toolCallId, ...extraSegments].map(refSegment));
|
|
57
|
+
}
|
|
58
|
+
function composeToolResultRef(sessionId, segments) {
|
|
59
|
+
return [`tr_${refSegment(sessionId)}`, ...segments].join(REF_SEGMENT_SEPARATOR);
|
|
60
|
+
}
|
|
61
|
+
const TASK_ARTIFACT_SEGMENT = `${FOLDED_SEGMENT_PREFIX}task`;
|
|
62
|
+
function buildTaskArtifactRef(sessionId, taskId, text) {
|
|
63
|
+
return composeToolResultRef(sessionId, [TASK_ARTIFACT_SEGMENT, ...[taskId, toolResultContentSegment(text)].map(refSegment)]);
|
|
64
|
+
}
|
|
65
|
+
export function taskArtifactOriginOf(ref) {
|
|
66
|
+
const segments = ref.split(REF_SEGMENT_SEPARATOR);
|
|
67
|
+
return segments[1] === TASK_ARTIFACT_SEGMENT ? segments[2] : undefined;
|
|
55
68
|
}
|
|
56
69
|
function refSegment(raw) {
|
|
57
70
|
if (raw.length <= MAX_REF_SEGMENT_CHARS && NATIVE_REF_CHARSET.test(raw) && !raw.startsWith(FOLDED_SEGMENT_PREFIX))
|
|
@@ -67,17 +80,14 @@ function digestOfString(s) {
|
|
|
67
80
|
return createHash("sha256").update(Buffer.from(s, "utf16le")).digest("hex");
|
|
68
81
|
}
|
|
69
82
|
export class InMemoryToolResultStore {
|
|
70
|
-
opts;
|
|
71
83
|
retention;
|
|
72
84
|
map = new Map();
|
|
73
85
|
totalChars = 0;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
throw new Error("InMemoryToolResultStore: maxTotalChars must be a number (got NaN) — omit it for an unbounded store");
|
|
80
|
-
}
|
|
86
|
+
maxTotalChars;
|
|
87
|
+
constructor(options) {
|
|
88
|
+
const opts = receiveOptions(options, "InMemoryToolResultStore");
|
|
89
|
+
this.retention = readRetentionDeclaration("InMemoryToolResultStore.retention", opts.retention);
|
|
90
|
+
this.maxTotalChars = readIntegerOption("InMemoryToolResultStore.maxTotalChars", opts.maxTotalChars, NON_NEGATIVE_SAFE_INTEGER, "characters", "an unbounded store");
|
|
81
91
|
}
|
|
82
92
|
put(ref, content, provenance) {
|
|
83
93
|
assertSafeToolResultRef(ref);
|
|
@@ -88,8 +98,8 @@ export class InMemoryToolResultStore {
|
|
|
88
98
|
}
|
|
89
99
|
this.map.set(ref, provenance === undefined ? { content } : { content, provenance: normalizeToolResultProvenance(provenance) });
|
|
90
100
|
this.totalChars += content.length;
|
|
91
|
-
const cap = this.
|
|
92
|
-
if (cap !== undefined
|
|
101
|
+
const cap = this.maxTotalChars;
|
|
102
|
+
if (cap !== undefined) {
|
|
93
103
|
for (const [oldRef, oldEntry] of this.map) {
|
|
94
104
|
if (this.totalChars <= cap || oldRef === ref)
|
|
95
105
|
break;
|
|
@@ -117,6 +127,19 @@ export class InMemoryToolResultStore {
|
|
|
117
127
|
}
|
|
118
128
|
return { deleted, unattributable };
|
|
119
129
|
}
|
|
130
|
+
listBySession(sessionId) {
|
|
131
|
+
const entries = [];
|
|
132
|
+
let unattributable = 0;
|
|
133
|
+
for (const [ref, entry] of this.map) {
|
|
134
|
+
if (entry.provenance === undefined) {
|
|
135
|
+
unattributable++;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (entry.provenance.sessionId === sessionId)
|
|
139
|
+
entries.push({ ref, provenance: { ...entry.provenance } });
|
|
140
|
+
}
|
|
141
|
+
return { entries, unattributable, unaddressable: 0 };
|
|
142
|
+
}
|
|
120
143
|
isEmpty() {
|
|
121
144
|
return this.map.size === 0;
|
|
122
145
|
}
|
|
@@ -198,6 +221,18 @@ export function createOffloadPersist(store, sessionId, onNotice) {
|
|
|
198
221
|
export function toolResultProvenanceOf(sessionId, taskId) {
|
|
199
222
|
return taskId === undefined ? { sessionId } : { sessionId, taskId };
|
|
200
223
|
}
|
|
224
|
+
export async function persistTaskArtifact(seat, taskId, text) {
|
|
225
|
+
if (seat === undefined)
|
|
226
|
+
return { kind: "no_store" };
|
|
227
|
+
const ref = buildTaskArtifactRef(seat.sessionId, taskId, text);
|
|
228
|
+
try {
|
|
229
|
+
await seat.store.put(ref, text, toolResultProvenanceOf(seat.sessionId));
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return { kind: "unconfirmed" };
|
|
233
|
+
}
|
|
234
|
+
return { kind: "stored", ref };
|
|
235
|
+
}
|
|
201
236
|
export function offloadPagebackHint(ref, form, reachableTools) {
|
|
202
237
|
const activate = reachableTools !== undefined && !reachableTools.has(OFFLOAD_TOOL_NAME)
|
|
203
238
|
? `${OFFLOAD_TOOL_NAME} is not active yet — call ${TOOL_SEARCH_NAME} with {"query":"select:${OFFLOAD_TOOL_NAME}"} to activate it, then `
|
|
@@ -386,11 +421,15 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
|
|
|
386
421
|
};
|
|
387
422
|
return { value: finalize(value) };
|
|
388
423
|
}
|
|
389
|
-
export function createReadToolResultTool(store) {
|
|
424
|
+
export function createReadToolResultTool(store, legsOfRef) {
|
|
390
425
|
return defineTool({
|
|
391
426
|
name: OFFLOAD_TOOL_NAME,
|
|
392
427
|
...toolFace("read-tool-result"),
|
|
393
428
|
ruleFace: mountRuleFace("read-tool-result"),
|
|
429
|
+
boundaryLegsFor: (rawArgs, at) => {
|
|
430
|
+
const ref = rawArgs?.ref;
|
|
431
|
+
return typeof ref === "string" && legsOfRef !== undefined ? legsOfRef(ref, at.tree) : { legs: [] };
|
|
432
|
+
},
|
|
394
433
|
description: `Read the full content of a tool result that was too large and persisted (you saw it as ` +
|
|
395
434
|
`<persisted-output ref="..."> with a preview). Pass the ref; use offset/limit to page through it.`,
|
|
396
435
|
parameters: Type.Object({
|
package/dist/core/tool-spec.d.ts
CHANGED
|
@@ -192,7 +192,9 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
|
|
|
192
192
|
* runtime tracking of what the child actually did is involved (that is the v2 ticket). `authored`
|
|
193
193
|
* marks the entries minted from a definition a caller wrote on a tool a deployment mounted (not the
|
|
194
194
|
* engine's built-ins, the general-purpose alias, fork, or the engine's nested copy of the tool for a
|
|
195
|
-
* delegated child); prepare's deny-name check judges only those.
|
|
195
|
+
* delegated child); prepare's deny-name check judges only those. `servers` are the MCP servers the definition declares itself
|
|
196
|
+
* (`AgentDefinition.mcp`): part of the child's universe for both readers, and its `allowTools` is the list the child's own layer is
|
|
197
|
+
* minted from (the written one, admitting every tool of those servers).
|
|
196
198
|
*/
|
|
197
199
|
agentToolFaces?: ReadonlyArray<{
|
|
198
200
|
name: string;
|
|
@@ -200,6 +202,10 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
|
|
|
200
202
|
denyTools?: readonly string[];
|
|
201
203
|
canRedelegate?: boolean;
|
|
202
204
|
authored?: true;
|
|
205
|
+
servers?: ReadonlyArray<{
|
|
206
|
+
name: string;
|
|
207
|
+
contentOrigin?: import("./types.js").ToolContentOrigin;
|
|
208
|
+
}>;
|
|
203
209
|
}>;
|
|
204
210
|
/**
|
|
205
211
|
* The tool-level `denyTools` list of the delegation tool (`SubagentToolOptions.denyTools`, applied when no agent definition is
|
|
@@ -740,9 +746,9 @@ export interface ToolExecuteContext {
|
|
|
740
746
|
* is rejected — this seat never widens, it only reopens the documented re-supply channel to
|
|
741
747
|
* the parked-decide lane). Absent ⇒ exactly the previous behavior.
|
|
742
748
|
*
|
|
743
|
-
* One entry kind is NOT a policy the deployment authored: a
|
|
744
|
-
*
|
|
745
|
-
*
|
|
749
|
+
* One entry kind is NOT a policy the deployment authored: a mods-wired parent contributes a
|
|
750
|
+
* SCREENING entry (issue #33), its installation. Rebuild it as `{ installation: await
|
|
751
|
+
* admitModChain(…), hookEnv, …regime }` over the same registrations and the same installed env,
|
|
746
752
|
* or the chain handed back here will be short and rejected on the count check. A face that only
|
|
747
753
|
* observes should be declared `{ observe: true }` instead, and then never enters the chain
|
|
748
754
|
* at all; a park under a screening entry announces the requirement on `onError`
|
|
@@ -1318,6 +1324,10 @@ export interface ToolExecuteContext {
|
|
|
1318
1324
|
onTaskNotification?: (n: import("./task-notification.js").TaskNotificationPayload, opts?: {
|
|
1319
1325
|
priority?: import("./task-notification.js").SystemInjectionPriority;
|
|
1320
1326
|
}) => unknown;
|
|
1327
|
+
/** Where a background task's result is stored when its completion notification ({@link onTaskNotification}) carries
|
|
1328
|
+
* less than the whole of it — the run's offload store, read back with `ReadToolResult`. Present exactly when the run
|
|
1329
|
+
* has one; absent ⇒ a cut notification says the full text is not readable from this session. TRUSTED, run-scoped. */
|
|
1330
|
+
taskArtifacts?: import("./tool-result-store.js").TaskArtifactSeat;
|
|
1321
1331
|
/**
|
|
1322
1332
|
* design/99 (nested-subagent live observability): the host run's OPT-IN display sink — a deployment sets it (via
|
|
1323
1333
|
* `RunInternals.onForwardEvent`) to receive a SUBAGENT's live `task_progress` ticks that otherwise stay in the
|
|
@@ -1384,6 +1394,12 @@ export interface ToolExecuteContext {
|
|
|
1384
1394
|
forkAccess?: {
|
|
1385
1395
|
denied: "task" | "principal";
|
|
1386
1396
|
};
|
|
1397
|
+
/**
|
|
1398
|
+
* The delegating leg's two agent stations over its mods bus — `agent.offer` (the offered set the delegation reads at
|
|
1399
|
+
* dispatch) and `agent.spawn` (raised before a subagent is let start). Runner-filled; never a model argument. Absent
|
|
1400
|
+
* outside a Runner: no station is raised and every type is offered.
|
|
1401
|
+
*/
|
|
1402
|
+
agentStations?: import("./mods/agent-stations.js").AgentStations;
|
|
1387
1403
|
/**
|
|
1388
1404
|
* design/80 D-B — the general "a tool yields to a HUMAN review gate" primitive. A tool calls this to request
|
|
1389
1405
|
* that, at the next SAFE turn boundary, the engine pause with a durable `plan_review` checkpoint
|
package/dist/core/trace.d.ts
CHANGED
|
@@ -64,7 +64,6 @@ export interface PromptManifestSection {
|
|
|
64
64
|
* metadata-only rule). Field meanings: see the `stats.mechanisms` JSDoc in core/types.ts.
|
|
65
65
|
*/
|
|
66
66
|
export interface TraceMechanismsSummary {
|
|
67
|
-
finalVerifyInjected?: true;
|
|
68
67
|
finalVerifyInjections?: number;
|
|
69
68
|
attachmentsInjected?: number;
|
|
70
69
|
/** design/164: how many LIMIT-APPROACH frames were injected this run (0..2). */
|
package/dist/core/types.d.ts
CHANGED
|
@@ -18,12 +18,12 @@ export type { PermissionMode } from "./ask-origin.js";
|
|
|
18
18
|
export type { ToolEffect, ToolContentOrigin, ReversibilityVerdict, ReadRootGrantCandidate, ToolSpec, ToolReturn, NestedUsage, NestedUsageAccum, ToolExecuteContext } from "./tool-spec.js";
|
|
19
19
|
export type { BeforeWriteRequest, BeforeWriteResult, BeforeWriteHook, TrackEditRequest, TrackEditResult, TrackFileEditHook, FileEditedNotice, FileEditedHook, HandsBandOptions } from "./hands-band.js";
|
|
20
20
|
export type { AgentDefinition, SkillSpec } from "./agent-definition.js";
|
|
21
|
-
export type { McpServerSpec, A2aServerSpec, McpElicitRequest, McpElicitResponse, OnElicit, McpRevocationLedger, McpMountIdentity, DeclarationFault, DeclarationPathRule, DeclarationRead, ToolAxesRead, ToolAxesSurface } from "./mcp-server-spec.js";
|
|
22
|
-
export { DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, dataKind, declarationFaultOf, declarerWord, perToolEmptyName, perToolEntryRefusal,
|
|
21
|
+
export type { McpServerSpec, A2aServerSpec, McpElicitRequest, McpElicitResponse, OnElicit, McpRevocationLedger, McpMountIdentity, McpTransportKind, DeclarationFault, DeclarationPathRule, DeclarationRead, ToolAxesRead, ToolAxesSurface } from "./mcp-server-spec.js";
|
|
22
|
+
export { DECLARATION_ENTRY_WORDS, DECLARATION_PATH_RULES, MCP_TRANSPORT_KINDS, NO_DECLARATION_PATH_RULES, TOOL_AXIS_WORDS, callerText, dataKind, declarationFaultOf, declarationPath, declarerWord, perToolEmptyName, perToolEntryRefusal, readMcpToolAxes, readToolAxes, receiveDeclaration, receivePerToolDeclaration, toolAxesRefusal, transportKindOf } from "./mcp-server-spec.js";
|
|
23
23
|
export type { TaskLimits } from "./task-limits.js";
|
|
24
24
|
export type { TaskStatus, RemoteEnvFailureNote, EffectiveMemoryScopes, TaskResult, HumanReviewGateRow } from "./task-result.js";
|
|
25
25
|
export type { TerminalCause, PausedCause } from "./terminal-cause.js";
|
|
26
|
-
export type { TaskEventIdentity, BrainStatusPhase, BrainRetryErrClass, BrainStatus, ToolActivity, HumanInputSource, HumanInputDelivery, DelegationTaskType, TaskEvent, HumanInputEvent, HumanInputAttachment, CompactOutcome, ExtensionRequester, RewriteAuthor, ToolInputRewrite } from "./task-event.js";
|
|
26
|
+
export type { TaskEventIdentity, BrainStatusPhase, BrainStatusSeat, BrainRetryErrClass, BrainStatus, ToolActivity, HumanInputSource, HumanInputDelivery, DelegationTaskType, TaskEvent, HumanInputEvent, HumanInputAttachment, CompactOutcome, ExtensionRequester, RewriteAuthor, ToolInputRewrite } from "./task-event.js";
|
|
27
27
|
export type { TaskStream } from "./task-stream.js";
|
|
28
28
|
export type { WorkflowGovernanceBaseline, RuntimeCaps, AutoModeDenySource } from "./runtime-caps.js";
|
|
29
29
|
export { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js";
|
package/dist/core/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MODEL_ROLES } from "./model-seat.js";
|
|
2
|
-
export { DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, dataKind, declarationFaultOf, declarerWord, perToolEmptyName, perToolEntryRefusal,
|
|
2
|
+
export { DECLARATION_ENTRY_WORDS, DECLARATION_PATH_RULES, MCP_TRANSPORT_KINDS, NO_DECLARATION_PATH_RULES, TOOL_AXIS_WORDS, callerText, dataKind, declarationFaultOf, declarationPath, declarerWord, perToolEmptyName, perToolEntryRefusal, readMcpToolAxes, readToolAxes, receiveDeclaration, receivePerToolDeclaration, toolAxesRefusal, transportKindOf } from "./mcp-server-spec.js";
|
|
3
3
|
export { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js";
|
|
4
4
|
export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
|
|
5
5
|
export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
|
|
@@ -229,7 +229,7 @@ export const ENGINE_ENVELOPES = Object.freeze([
|
|
|
229
229
|
{
|
|
230
230
|
tag: "example",
|
|
231
231
|
kind: "not-an-envelope",
|
|
232
|
-
mint: "engine/compaction SUMMARIZATION_PROMPT (
|
|
232
|
+
mint: "engine/compaction SUMMARIZATION_PROMPT (the output skeleton shown to the summarizer, captured from an early reference build)",
|
|
233
233
|
guard: "no untrusted bytes reach it: the block is a CONSTANT that frames placeholder text (`[Concept 1]`), it wraps nothing, and it is never emitted back — the summarizer's own answer is read through the `<summary>` envelope, not this one",
|
|
234
234
|
fenced: false,
|
|
235
235
|
disclosed: false,
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import type { ImageContent, TextContent, UserAttachmentSupply, UserMessageAttachment } from "../internal/llm.js";
|
|
26
26
|
import type { HumanInputAttachment } from "./task-event.js";
|
|
27
27
|
import { type ModelFileReader } from "../tools/fs/fs-read.js";
|
|
28
|
+
import { type ImageDownsampler } from "./image-downsample.js";
|
|
28
29
|
import type { SyntheticReadJudge } from "./synthetic-read-verdict.js";
|
|
29
30
|
import { type ReminderDisclosureCounts } from "./reminder-disclosure.js";
|
|
30
31
|
import { type AgentMessage } from "../internal/harness.js";
|
|
@@ -115,10 +116,11 @@ export interface UserAttachmentDeclaration {
|
|
|
115
116
|
/** The UserPromptSubmit hook's view of the declarations. */
|
|
116
117
|
export declare function userAttachmentDeclarations(screened: readonly ScreenedUserAttachment[]): readonly UserAttachmentDeclaration[];
|
|
117
118
|
/**
|
|
118
|
-
* The host images' byte admission — the one function an image the Read tool serves passes
|
|
119
|
-
* run on the captured values before any attachment is read or delivered. Throws
|
|
119
|
+
* The host images' byte admission — the one function an image the Read tool serves passes, with the run's processor.
|
|
120
|
+
* Asynchronous (it decodes), run on the captured values before any attachment is read or delivered. Throws
|
|
121
|
+
* `config.user_attachment_invalid`.
|
|
120
122
|
*/
|
|
121
|
-
export declare function admitUserAttachmentImages(screened: readonly ScreenedUserAttachment[]): Promise<ReadonlyMap<number, ImageContent>>;
|
|
123
|
+
export declare function admitUserAttachmentImages(screened: readonly ScreenedUserAttachment[], processor: ImageDownsampler | "none"): Promise<ReadonlyMap<number, ImageContent>>;
|
|
122
124
|
/** The transmission an attachment frame is (the read-state entry its delivery records carries it): when the frame leaves
|
|
123
125
|
* the request — a trim drops it — the entry retires with it. One spelling for the mint and every remover. */
|
|
124
126
|
export declare function attachmentTransmissionId(a: Pick<UserMessageAttachment, "inputId" | "ordinal">): string;
|
|
@@ -171,8 +173,11 @@ export interface AttachmentWindowInput {
|
|
|
171
173
|
}
|
|
172
174
|
/** The objective lane's read: once the UserPromptSubmit hook let the objective through (a blocked objective reads
|
|
173
175
|
* nothing), and before the pre-call gate, which prices the frames (`chars`). Refuses the whole objective when the frames
|
|
174
|
-
* and the objective cannot ride one request ({@link refuseFramesOverWindow}). Commits nothing.
|
|
175
|
-
|
|
176
|
+
* and the objective cannot ride one request ({@link refuseFramesOverWindow}). Commits nothing. `imageSeat` is the run's
|
|
177
|
+
* image processor seat (`RunnerDeps.imageProcessor`): the host images are admitted with it (a path's image is read by the
|
|
178
|
+
* reader, with the same seat), and the first image of the frames sent unprocessed over the soft target is told to
|
|
179
|
+
* `prepared.imageUnprocessed`. */
|
|
180
|
+
export declare function readObjectiveAttachments(prepared: Pick<import("./runner/contracts.js").Prepared, "userAttachments" | "modelFileReader" | "syntheticReadVerdict" | "cwdRef" | "reminderMark" | "reminderDisclosureCounts" | "abortController" | "harness" | "modBus" | "hookIdentity" | "imageUnprocessed">, inputId: string, blocked: boolean, window: AttachmentWindowInput, imageSeat: ImageDownsampler | false | undefined): Promise<{
|
|
176
181
|
frames: MintedAttachmentFrame[];
|
|
177
182
|
chars: number;
|
|
178
183
|
}>;
|