@sema-agent/core 7.72.0 → 7.74.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 +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- 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/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- 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 +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- 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 +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- 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/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -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/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-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/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/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 +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- 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 +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- 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 +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- 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/permission-rules.js +4 -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/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- 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/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -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 +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- 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-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- 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 +42 -30
- 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 +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- 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/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -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 +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- 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/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- 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.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -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 +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- 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 +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- 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.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- 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 +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- 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-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.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/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- 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 +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- 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 +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -459,9 +459,123 @@ export const OFFLOAD_TOOL_NAME = "ReadToolResult";
|
|
|
459
459
|
export function offloadRefOf(sessionId, toolCallId, fullText) {
|
|
460
460
|
return buildToolResultRef(sessionId, toolCallId, toolResultContentSegment(fullText));
|
|
461
461
|
}
|
|
462
|
+
export const OFFLOAD_PUT_WAIT_BOUND_MS = 10_000;
|
|
463
|
+
function createOffloadWaitWindow() {
|
|
464
|
+
let expired = false;
|
|
465
|
+
let started = false;
|
|
466
|
+
let timer;
|
|
467
|
+
const listeners = new Set();
|
|
468
|
+
return {
|
|
469
|
+
get expired() {
|
|
470
|
+
return expired;
|
|
471
|
+
},
|
|
472
|
+
start() {
|
|
473
|
+
if (started || expired)
|
|
474
|
+
return;
|
|
475
|
+
started = true;
|
|
476
|
+
timer = setTimeout(() => {
|
|
477
|
+
timer = undefined;
|
|
478
|
+
expired = true;
|
|
479
|
+
for (const fn of [...listeners])
|
|
480
|
+
fn();
|
|
481
|
+
listeners.clear();
|
|
482
|
+
}, OFFLOAD_PUT_WAIT_BOUND_MS);
|
|
483
|
+
},
|
|
484
|
+
onExpire(fn) {
|
|
485
|
+
if (expired) {
|
|
486
|
+
fn();
|
|
487
|
+
return () => { };
|
|
488
|
+
}
|
|
489
|
+
listeners.add(fn);
|
|
490
|
+
return () => {
|
|
491
|
+
listeners.delete(fn);
|
|
492
|
+
};
|
|
493
|
+
},
|
|
494
|
+
dispose() {
|
|
495
|
+
if (timer !== undefined) {
|
|
496
|
+
clearTimeout(timer);
|
|
497
|
+
timer = undefined;
|
|
498
|
+
}
|
|
499
|
+
listeners.clear();
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
export function waitForOffloadPuts(puts, opts) {
|
|
504
|
+
const outcomes = puts.map(() => ({ status: "pending" }));
|
|
505
|
+
if (puts.length === 0) {
|
|
506
|
+
return Promise.resolve({ outcomes, timedOut: false, aborted: opts?.signal?.aborted === true });
|
|
507
|
+
}
|
|
508
|
+
const signal = opts?.signal;
|
|
509
|
+
let remaining = puts.length;
|
|
510
|
+
let finished = false;
|
|
511
|
+
let finish;
|
|
512
|
+
for (let i = 0; i < puts.length; i++) {
|
|
513
|
+
const idx = i;
|
|
514
|
+
puts[idx].then((value) => {
|
|
515
|
+
if (finished)
|
|
516
|
+
return;
|
|
517
|
+
outcomes[idx] = { status: "settled", value };
|
|
518
|
+
remaining -= 1;
|
|
519
|
+
if (remaining === 0)
|
|
520
|
+
finish?.(false, false);
|
|
521
|
+
}, (reason) => {
|
|
522
|
+
if (finished)
|
|
523
|
+
return;
|
|
524
|
+
outcomes[idx] = { status: "rejected", reason };
|
|
525
|
+
remaining -= 1;
|
|
526
|
+
if (remaining === 0)
|
|
527
|
+
finish?.(false, false);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
if (signal?.aborted === true) {
|
|
531
|
+
finished = true;
|
|
532
|
+
return Promise.resolve({ outcomes, timedOut: false, aborted: true });
|
|
533
|
+
}
|
|
534
|
+
if (opts?.window?.expired === true) {
|
|
535
|
+
finished = true;
|
|
536
|
+
return Promise.resolve({ outcomes, timedOut: true, aborted: false });
|
|
537
|
+
}
|
|
538
|
+
return new Promise((resolve) => {
|
|
539
|
+
const ownWindow = opts?.window === undefined ? createOffloadWaitWindow() : undefined;
|
|
540
|
+
const win = opts?.window ?? ownWindow;
|
|
541
|
+
let unsubExpire;
|
|
542
|
+
const onAbort = () => {
|
|
543
|
+
finish?.(false, true);
|
|
544
|
+
};
|
|
545
|
+
finish = (timedOut, aborted) => {
|
|
546
|
+
if (finished)
|
|
547
|
+
return;
|
|
548
|
+
finished = true;
|
|
549
|
+
unsubExpire?.();
|
|
550
|
+
ownWindow?.dispose();
|
|
551
|
+
signal?.removeEventListener("abort", onAbort);
|
|
552
|
+
resolve({ outcomes, timedOut, aborted });
|
|
553
|
+
};
|
|
554
|
+
if (remaining === 0) {
|
|
555
|
+
finish(false, false);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
559
|
+
unsubExpire = win.onExpire(() => finish?.(true, false));
|
|
560
|
+
win.start();
|
|
561
|
+
});
|
|
562
|
+
}
|
|
462
563
|
export function createOffloadPersist(store, sessionId, onNotice, tellOnce) {
|
|
463
564
|
const provenance = toolResultProvenanceOf(sessionId);
|
|
464
|
-
|
|
565
|
+
const pending = new Map();
|
|
566
|
+
const givenUp = new Set();
|
|
567
|
+
const owed = () => [...pending.keys()].filter((p) => !givenUp.has(p));
|
|
568
|
+
const tellUnsettled = (late) => {
|
|
569
|
+
const refs = [...new Set(late.map((p) => pending.get(p)))];
|
|
570
|
+
deliverEngineNotice(onNotice, {
|
|
571
|
+
code: "tool_result.offload_put_unsettled",
|
|
572
|
+
message: `tool-result offload: ${refs.length} cleared result write(s) had not settled after ${OFFLOAD_PUT_WAIT_BOUND_MS} ms — the request goes ` +
|
|
573
|
+
`out without waiting for them longer, and no later request of this run waits for them again. Each write runs on: one that ` +
|
|
574
|
+
`lands reads back from then on, one that fails is told as tool_result.offload_put_failed; until then a read of its ref finds nothing.`,
|
|
575
|
+
detail: { refs, sessionId, boundMs: OFFLOAD_PUT_WAIT_BOUND_MS, occurrenceId: uuidv7() },
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
const persist = (toolCallId, fullText) => {
|
|
465
579
|
const ref = offloadRefOf(sessionId, toolCallId, fullText);
|
|
466
580
|
const tellUnreadable = (err) => {
|
|
467
581
|
const deliver = () => deliverEngineNotice(onNotice, {
|
|
@@ -492,7 +606,13 @@ export function createOffloadPersist(store, sessionId, onNotice, tellOnce) {
|
|
|
492
606
|
return true;
|
|
493
607
|
};
|
|
494
608
|
try {
|
|
495
|
-
|
|
609
|
+
const put = Promise.resolve(store.put(ref, fullText, provenance))
|
|
610
|
+
.catch((err) => void settle(err))
|
|
611
|
+
.finally(() => {
|
|
612
|
+
pending.delete(put);
|
|
613
|
+
givenUp.delete(put);
|
|
614
|
+
});
|
|
615
|
+
pending.set(put, ref);
|
|
496
616
|
}
|
|
497
617
|
catch (err) {
|
|
498
618
|
if (settle(err))
|
|
@@ -500,6 +620,35 @@ export function createOffloadPersist(store, sessionId, onNotice, tellOnce) {
|
|
|
500
620
|
}
|
|
501
621
|
return ref;
|
|
502
622
|
};
|
|
623
|
+
return Object.assign(persist, {
|
|
624
|
+
flush: (signal) => new Promise((resolve) => {
|
|
625
|
+
if (signal?.aborted === true || owed().length === 0)
|
|
626
|
+
return resolve();
|
|
627
|
+
let ended = false;
|
|
628
|
+
const end = () => {
|
|
629
|
+
if (ended)
|
|
630
|
+
return;
|
|
631
|
+
ended = true;
|
|
632
|
+
clearTimeout(timer);
|
|
633
|
+
signal?.removeEventListener("abort", end);
|
|
634
|
+
resolve();
|
|
635
|
+
};
|
|
636
|
+
const timer = setTimeout(() => {
|
|
637
|
+
const late = owed();
|
|
638
|
+
for (const p of late)
|
|
639
|
+
givenUp.add(p);
|
|
640
|
+
if (late.length > 0)
|
|
641
|
+
tellUnsettled(late);
|
|
642
|
+
end();
|
|
643
|
+
}, OFFLOAD_PUT_WAIT_BOUND_MS);
|
|
644
|
+
signal?.addEventListener("abort", end, { once: true });
|
|
645
|
+
void (async () => {
|
|
646
|
+
for (let w = owed(); w.length > 0 && !ended; w = owed())
|
|
647
|
+
await Promise.all(w);
|
|
648
|
+
end();
|
|
649
|
+
})();
|
|
650
|
+
}),
|
|
651
|
+
});
|
|
503
652
|
}
|
|
504
653
|
export async function keepToolResultBytes(seat, toolCallId, bytes, mimeType, held) {
|
|
505
654
|
const facts = keptBytesFacts(bytes, mimeType);
|
|
@@ -599,38 +748,76 @@ export function buildPreview(full, ref, sizes, reachableTools) {
|
|
|
599
748
|
`${tail}\n` +
|
|
600
749
|
`</persisted-output>`);
|
|
601
750
|
}
|
|
602
|
-
export function withToolResultOffload(tool, store, thresholdChars, sessionId, reachableTools) {
|
|
751
|
+
export function withToolResultOffload(tool, store, thresholdChars, sessionId, reachableTools, onNotice) {
|
|
603
752
|
if (!(Number.isFinite(thresholdChars) && thresholdChars > 0))
|
|
604
753
|
return tool;
|
|
605
754
|
const provenance = toolResultProvenanceOf(sessionId);
|
|
606
755
|
const wrappedExecute = async (toolCallId, params, signal, onUpdate) => {
|
|
607
756
|
const res = await tool.execute(toolCallId, params, signal, onUpdate);
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
const withDetails = (r) => offloadedDetails === undefined || offloadedDetails.value === res.details ? r : { ...r, details: offloadedDetails.value };
|
|
612
|
-
if (totalTextChars(res.content) <= thresholdChars)
|
|
613
|
-
return withDetails(res);
|
|
614
|
-
const full = res.content
|
|
615
|
-
.filter((b) => b.type === "text")
|
|
616
|
-
.map((b) => b.text)
|
|
617
|
-
.join("\n");
|
|
618
|
-
if (full.length <= PREVIEW_HEAD_CHARS + PREVIEW_TAIL_CHARS)
|
|
619
|
-
return withDetails(res);
|
|
620
|
-
const ref = buildToolResultRef(sessionId, toolCallId, toolResultContentSegment(full));
|
|
757
|
+
const waitWindow = createOffloadWaitWindow();
|
|
758
|
+
const unsettledRefs = [];
|
|
759
|
+
let abortedDuringWait = false;
|
|
621
760
|
try {
|
|
622
|
-
await
|
|
761
|
+
const offloadedDetails = res.details === undefined ? undefined : await offloadOversizedDetailStrings(res.details, store, thresholdChars, sessionId, toolCallId, provenance, signal, waitWindow);
|
|
762
|
+
if (offloadedDetails !== undefined) {
|
|
763
|
+
if (offloadedDetails.aborted)
|
|
764
|
+
abortedDuringWait = true;
|
|
765
|
+
for (const r of offloadedDetails.unsettledRefs)
|
|
766
|
+
unsettledRefs.push(r);
|
|
767
|
+
carryNotStartedReceipt(res.details, offloadedDetails.value);
|
|
768
|
+
}
|
|
769
|
+
const withDetails = (r) => offloadedDetails === undefined || offloadedDetails.value === res.details ? r : { ...r, details: offloadedDetails.value };
|
|
770
|
+
if (abortedDuringWait)
|
|
771
|
+
return withDetails(res);
|
|
772
|
+
if (totalTextChars(res.content) <= thresholdChars)
|
|
773
|
+
return withDetails(res);
|
|
774
|
+
const full = res.content
|
|
775
|
+
.filter((b) => b.type === "text")
|
|
776
|
+
.map((b) => b.text)
|
|
777
|
+
.join("\n");
|
|
778
|
+
if (full.length <= PREVIEW_HEAD_CHARS + PREVIEW_TAIL_CHARS)
|
|
779
|
+
return withDetails(res);
|
|
780
|
+
if (waitWindow.expired)
|
|
781
|
+
return withDetails(res);
|
|
782
|
+
const ref = buildToolResultRef(sessionId, toolCallId, toolResultContentSegment(full));
|
|
783
|
+
let put;
|
|
784
|
+
try {
|
|
785
|
+
put = Promise.resolve(store.put(ref, full, provenance));
|
|
786
|
+
}
|
|
787
|
+
catch {
|
|
788
|
+
return withDetails(res);
|
|
789
|
+
}
|
|
790
|
+
const waited = await waitForOffloadPuts([put], { signal, window: waitWindow });
|
|
791
|
+
if (waited.aborted) {
|
|
792
|
+
abortedDuringWait = true;
|
|
793
|
+
return withDetails(res);
|
|
794
|
+
}
|
|
795
|
+
const outcome = waited.outcomes[0];
|
|
796
|
+
if (outcome.status !== "settled") {
|
|
797
|
+
if (outcome.status === "pending")
|
|
798
|
+
unsettledRefs.push(ref);
|
|
799
|
+
return withDetails(res);
|
|
800
|
+
}
|
|
801
|
+
const images = res.content.filter((b) => b.type !== "text");
|
|
802
|
+
return withDetails({ ...res, content: [{ type: "text", text: buildPreview(full, ref, undefined, reachableTools?.()) }, ...images] });
|
|
623
803
|
}
|
|
624
|
-
|
|
625
|
-
|
|
804
|
+
finally {
|
|
805
|
+
waitWindow.dispose();
|
|
806
|
+
if (unsettledRefs.length > 0 && !abortedDuringWait) {
|
|
807
|
+
const refs = [...new Set(unsettledRefs)];
|
|
808
|
+
deliverEngineNotice(onNotice, {
|
|
809
|
+
code: "tool_result.offload_put_unsettled",
|
|
810
|
+
message: `tool-result offload: ${refs.length} tool-call offload write(s) had not settled after ${OFFLOAD_PUT_WAIT_BOUND_MS} ms — ` +
|
|
811
|
+
`the call finished as unconfirmed (content returned as is; unsettled details members carry no ref). Each write runs on in the background.`,
|
|
812
|
+
detail: { refs, sessionId, boundMs: OFFLOAD_PUT_WAIT_BOUND_MS, occurrenceId: uuidv7() },
|
|
813
|
+
});
|
|
814
|
+
}
|
|
626
815
|
}
|
|
627
|
-
const images = res.content.filter((b) => b.type !== "text");
|
|
628
|
-
return withDetails({ ...res, content: [{ type: "text", text: buildPreview(full, ref, undefined, reachableTools?.()) }, ...images] });
|
|
629
816
|
};
|
|
630
817
|
return { ...tool, execute: wrappedExecute };
|
|
631
818
|
}
|
|
632
819
|
const OFFLOADED_DETAIL_NOTICE_ALLOWANCE_CHARS = MAX_MINTED_TOOL_RESULT_REF_CHARS + 200;
|
|
633
|
-
async function offloadOversizedDetailStrings(details, store, thresholdChars, sessionId, toolCallId, provenance) {
|
|
820
|
+
async function offloadOversizedDetailStrings(details, store, thresholdChars, sessionId, toolCallId, provenance, signal, waitWindow) {
|
|
634
821
|
const isPlainObject = (v) => {
|
|
635
822
|
if (typeof v !== "object" || v === null)
|
|
636
823
|
return false;
|
|
@@ -641,6 +828,8 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
|
|
|
641
828
|
const pending = [];
|
|
642
829
|
const rebuilt = new Set();
|
|
643
830
|
const replace = (full, path) => {
|
|
831
|
+
if (waitWindow.expired)
|
|
832
|
+
return mintOffloadedDetailNotice(full, undefined);
|
|
644
833
|
const detailRef = buildToolResultRef(sessionId, toolCallId, path, toolResultContentSegment(full));
|
|
645
834
|
let done;
|
|
646
835
|
try {
|
|
@@ -652,6 +841,7 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
|
|
|
652
841
|
const marker = {};
|
|
653
842
|
pending.push({
|
|
654
843
|
marker,
|
|
844
|
+
ref: detailRef,
|
|
655
845
|
done,
|
|
656
846
|
render: (stored) => mintOffloadedDetailNotice(full, stored ? detailRef : undefined),
|
|
657
847
|
});
|
|
@@ -712,10 +902,14 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
|
|
|
712
902
|
return v;
|
|
713
903
|
};
|
|
714
904
|
const value = walk(details, []);
|
|
715
|
-
const
|
|
905
|
+
const waited = await waitForOffloadPuts(pending.map((p) => p.done), { signal, window: waitWindow });
|
|
906
|
+
const unsettledRefs = [];
|
|
716
907
|
const notices = new Map();
|
|
717
908
|
pending.forEach((p, i) => {
|
|
718
|
-
|
|
909
|
+
const outcome = waited.outcomes[i];
|
|
910
|
+
if (outcome.status === "pending" && !waited.aborted)
|
|
911
|
+
unsettledRefs.push(p.ref);
|
|
912
|
+
notices.set(p.marker, p.render(outcome.status === "settled"));
|
|
719
913
|
});
|
|
720
914
|
const seen = new Set();
|
|
721
915
|
const finalize = (node) => {
|
|
@@ -740,7 +934,7 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
|
|
|
740
934
|
Object.defineProperty(obj, k, { value: finalize(obj[k]), enumerable: true, writable: true, configurable: true });
|
|
741
935
|
return node;
|
|
742
936
|
};
|
|
743
|
-
return { value: finalize(value) };
|
|
937
|
+
return { value: finalize(value), unsettledRefs, aborted: waited.aborted };
|
|
744
938
|
}
|
|
745
939
|
export function createReadToolResultTool(store, legsOfRef, bytesSeat) {
|
|
746
940
|
return defineTool({
|
package/dist/core/tool-spec.d.ts
CHANGED
|
@@ -781,7 +781,7 @@ export interface ToolExecuteContext {
|
|
|
781
781
|
/**
|
|
782
782
|
* The ROOT task's facts the drive re-states, beside the root's seat the ctx carries (`parentSpecSeat`, minted with
|
|
783
783
|
* `parentSpecSeatOf` from the root's resume input): its CURRENT permission mode and its shell floor — the two members this
|
|
784
|
-
* seat reads. Every other member is refused by name (`config.deps_retired_key`, `detail.field` `"inheritedGate"`):
|
|
784
|
+
* seat reads; every drive (a deny too) hands both, or is refused before the consume. Every other member is refused by name (`config.deps_retired_key`, `detail.field` `"inheritedGate"`):
|
|
785
785
|
* `parentConstraints` above all — the host no longer builds the chain; a revived leg's chain is the live one this runner
|
|
786
786
|
* holds for the row, else REBUILT by the engine from the row's record and this runner's own inputs (`rootPolicy` below
|
|
787
787
|
* for a `taskPolicy` layer, `RunnerDeps.toolPolicy` / `RunnerDeps.mods` for the rest). The data half (ancestor rules,
|
|
@@ -1065,6 +1065,13 @@ export interface ToolExecuteContext {
|
|
|
1065
1065
|
* read-only boundary ended at one level. Strictly a capability REMOVAL — it can never widen a child.
|
|
1066
1066
|
*/
|
|
1067
1067
|
handsReadOnly?: true;
|
|
1068
|
+
/**
|
|
1069
|
+
* The running task's MEMBER LEDGER seat ({@link TaskSpec.runLedger}), Runner-filled on the trusted seat: present ONLY on a run
|
|
1070
|
+
* that declares a ledger, so an ordinary run's ctx gains no key. A delegation tool reports the members it settles in-call (a
|
|
1071
|
+
* synchronous child, a fork) here, and marks its background children's completion frames with the actions digest; the
|
|
1072
|
+
* ledger reads the rest off the run's own lane. Never handed to a child (each leg's ctx is its own run's).
|
|
1073
|
+
*/
|
|
1074
|
+
runLedgerBook?: import("./run-ledger.js").RunLedgerSink;
|
|
1068
1075
|
/**
|
|
1069
1076
|
* The running task's READ-BLOCK clamp ({@link TaskSpec.blockReadsOutsideRoots} — the leg refuses reads outside its declared
|
|
1070
1077
|
* directories, as the leg resolved it: the declaration or a resumed row's record of it), Runner-filled read-only on the
|
|
@@ -1453,7 +1460,7 @@ export interface ToolExecuteContext {
|
|
|
1453
1460
|
* is a DISPLAY channel ONLY — the child stream is NEVER merged into the parent's MODEL context, and nothing
|
|
1454
1461
|
* security-relevant consumes a forwarded event. Present ONLY when the deployment opted in. The tool-ctx wrapper
|
|
1455
1462
|
* passes `task_progress` unconditionally and — when the deployment sets `forwardSubagentEvents: true` — the
|
|
1456
|
-
* transcript classes too (text_delta/text_end/reasoning_delta/tool_start/tool_end); other event types never cross it.
|
|
1463
|
+
* transcript classes too (text_delta/text_end/reasoning_delta/reasoning_end/tool_start/tool_end); other event types never cross it.
|
|
1457
1464
|
* The delegation lane's OWN tap is trusted and forwards the child's FULL event stream (bg frames tagged
|
|
1458
1465
|
* with bgAgentId). ⚠️ Forwarded ticks are UNTRUSTED display hints — any
|
|
1459
1466
|
* tool holding this ctx could self-declare one, so a consumer validates `parentTaskId` against its known runs.
|
package/dist/core/trace.d.ts
CHANGED
|
@@ -537,9 +537,9 @@ export type TraceEvent = {
|
|
|
537
537
|
} | {
|
|
538
538
|
/**
|
|
539
539
|
* design/179 — the person's persisted rule store could not be read (at prepare, or for one call), so
|
|
540
|
-
* that read's rows took no part
|
|
541
|
-
*
|
|
542
|
-
*
|
|
540
|
+
* that read's allow rows took no part (retained deny/ask rows still apply; under asking modes calls ask, under
|
|
541
|
+
* `auto` the classifier judges, under `bypassPermissions` the class is released). The operator's per-read record;
|
|
542
|
+
* the person hears it via `permission.rule_store_unavailable` (once per session when met at prepare, once per run at a call).
|
|
543
543
|
*/
|
|
544
544
|
kind: "permission.rule_store_unreadable";
|
|
545
545
|
version: 1;
|
|
@@ -168,6 +168,9 @@ export declare function frameFileToolsOf(roster: ToolRoster | undefined): FrameF
|
|
|
168
168
|
/** The posture the task root's instruction frame asks of the model: the project's standing context is background it
|
|
169
169
|
* already knows (a small model shown the content alone stays project-aware but passive on an open-ended turn). */
|
|
170
170
|
export declare const PROJECT_CONTEXT_POSTURE = "Treat it as background you ALREADY know: when the user greets you or asks something open-ended, orient your reply to THIS project \u2014 name it and engage with its specifics rather than asking what project this is.";
|
|
171
|
+
/** The owner an instruction frame's opening reminder names (its `It is <owner word> …` sentence, as {@link instructionFramingClause}
|
|
172
|
+
* minted it); none where the opening names no owner word. */
|
|
173
|
+
export declare function instructionFrameOwnerOf(opening: string): InstructionOwner | undefined;
|
|
171
174
|
/** The transmission an attachment frame is (the read-state entry its delivery records carries it): when the frame leaves
|
|
172
175
|
* the request — a trim drops it — the entry retires with it. One spelling for the mint and every remover; an instruction
|
|
173
176
|
* file's frame spells its origin's word in place of {@link FRAME_TRANSMISSION_PREFIX}, so a witness says on itself that the
|
|
@@ -353,10 +356,11 @@ export type InstructionOwner = (typeof INSTRUCTION_OWNERS)[number];
|
|
|
353
356
|
* layer, or a rule for an accessed path), as the instruction-file lane read and cut it: the text the model is shown, the cut's
|
|
354
357
|
* own note, and — for a file — the read-state entry its delivery records (`record`, handed the frame's transmission when the
|
|
355
358
|
* frame is in the transcript). `withdraws`: the frame withdraws the file or text delivered earlier (no data; a file's record
|
|
356
|
-
* deletes its entry). */
|
|
359
|
+
* deletes its entry). `included`: the file was loaded through an `@` include — its owner is its includer's, its frame DATA. */
|
|
357
360
|
export interface NestedMemoryRead {
|
|
358
361
|
readonly supply: "path" | "content_text";
|
|
359
362
|
readonly owner: InstructionOwner;
|
|
363
|
+
readonly included?: true;
|
|
360
364
|
readonly layer: InstructionLayer;
|
|
361
365
|
readonly label: string;
|
|
362
366
|
readonly text: string;
|
|
@@ -288,24 +288,30 @@ function disclosureSentence(v) {
|
|
|
288
288
|
}
|
|
289
289
|
export const PROJECT_CONTEXT_POSTURE = "Treat it as background you ALREADY know: when the user greets you or asks something open-ended, orient your reply to THIS project — name it and engage with its specifics rather than asking what project this is.";
|
|
290
290
|
const OWNER_WORDS = { repository: "repository-controlled", deployment: "deployment-supplied", local: "user-private (not checked in)" };
|
|
291
|
-
|
|
291
|
+
const DEPLOYMENT_INSTRUCTIONS_CLAUSE = "Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.";
|
|
292
|
+
const instructionFramingClause = (owner, included) => owner === "deployment" && !included ? `It is ${OWNER_WORDS[owner]} INSTRUCTIONS. ${DEPLOYMENT_INSTRUCTIONS_CLAUSE}` : `It is ${OWNER_WORDS[owner]} DATA, ${DATA_NOT_INSTRUCTIONS_CLAUSE}`;
|
|
293
|
+
export function instructionFrameOwnerOf(opening) {
|
|
294
|
+
return INSTRUCTION_OWNERS.find((owner) => opening.includes(`It is ${OWNER_WORDS[owner]} `));
|
|
295
|
+
}
|
|
296
|
+
const ROOT_LAYER_FILE = "an instruction file for this task (a root's own, or one that another instruction file or text includes)";
|
|
297
|
+
function openingSentence(shape, n, count, origin, tools, owner, withdraws, included) {
|
|
292
298
|
const host = shape === "client_text";
|
|
293
299
|
if (withdraws === true) {
|
|
294
300
|
if (host)
|
|
295
301
|
return `The engine loaded an instruction text the deployment supplied earlier in this conversation (attachment ${n} of ${count}); the deployment no longer supplies it, or it holds nothing now, so what it said no longer applies. Its name follows.`;
|
|
296
|
-
const what = origin === "project_instructions" ?
|
|
302
|
+
const what = origin === "project_instructions" ? ROOT_LAYER_FILE : "an instruction file of a directory you accessed";
|
|
297
303
|
return `The engine loaded ${what} earlier in this conversation (attachment ${n} of ${count}); the file has since been removed, or holds nothing now, so what it said no longer applies. Its path follows.`;
|
|
298
304
|
}
|
|
299
|
-
const
|
|
305
|
+
const framing = instructionFramingClause(owner ?? "repository", included === true);
|
|
300
306
|
if (origin === "project_instructions") {
|
|
301
|
-
const what = host ? "an instruction text the deployment supplied for this task" :
|
|
307
|
+
const what = host ? "an instruction text the deployment supplied for this task" : ROOT_LAYER_FILE;
|
|
302
308
|
const data = host ? "the name the deployment gave it, then its contents" : "the file's path, then its contents";
|
|
303
|
-
return `The engine loaded ${what} — the standing context of the project you are working in (attachment ${n} of ${count}). Everything after this reminder, up to the reminder that ends attachment ${n}, is data: ${data}. ${PROJECT_CONTEXT_POSTURE}
|
|
309
|
+
return `The engine loaded ${what} — the standing context of the project you are working in (attachment ${n} of ${count}). Everything after this reminder, up to the reminder that ends attachment ${n}, is data: ${data}. ${PROJECT_CONTEXT_POSTURE} ${framing}`;
|
|
304
310
|
}
|
|
305
311
|
if (origin === "nested_memory") {
|
|
306
312
|
const what = host ? "a rule the deployment supplied for paths you accessed" : "an instruction file of a directory you accessed";
|
|
307
313
|
const data = host ? "the name the deployment gave it, then its contents" : "the file's path, then its contents";
|
|
308
|
-
return `The engine loaded ${what} (attachment ${n} of ${count}). Everything after this reminder, up to the reminder that ends attachment ${n}, is data: ${data}.
|
|
314
|
+
return `The engine loaded ${what} (attachment ${n} of ${count}). Everything after this reminder, up to the reminder that ends attachment ${n}, is data: ${data}. ${framing}`;
|
|
309
315
|
}
|
|
310
316
|
const noun = { file: "a file", directory: "a directory", pdf: "a PDF", client_text: "text that the user's client provided (it was not read from the workspace)", client_image: "an image that the user's client provided" }[shape];
|
|
311
317
|
const data = {
|
|
@@ -533,7 +539,7 @@ function mintFrame(r, at, seat) {
|
|
|
533
539
|
const scan = seat.plan(r.unscanned, `user-attachment:${at.inputId}:${at.ordinal}`);
|
|
534
540
|
const notes = scan.note !== undefined ? [...r.notes, scan.note] : r.notes;
|
|
535
541
|
const content = [
|
|
536
|
-
{ type: "text", text: `${mintSystemReminder(openingSentence(r.shape, at.ordinal, at.count, at.origin, at.tools, r.owner, r.withdraws !== undefined), at.mark)}\n` },
|
|
542
|
+
{ type: "text", text: `${mintSystemReminder(openingSentence(r.shape, at.ordinal, at.count, at.origin, at.tools, r.owner, r.withdraws !== undefined, r.included === true), at.mark)}\n` },
|
|
537
543
|
{ type: "text", text: `${r.supply === "path" ? "Path" : "Name"}: ${quoteDataLabel(r.label)}\n` },
|
|
538
544
|
];
|
|
539
545
|
const dataStart = content.length;
|
|
@@ -748,6 +754,7 @@ export function mintInstructionFrames(reads, seat) {
|
|
|
748
754
|
...(r.observation !== undefined ? { observation: r.observation } : {}),
|
|
749
755
|
record: r.record,
|
|
750
756
|
owner: r.owner,
|
|
757
|
+
...(r.included === true ? { included: true } : {}),
|
|
751
758
|
truncated: r.cut !== undefined,
|
|
752
759
|
};
|
|
753
760
|
return mintFrame(read, { inputId, ordinal: i + 1, count: reads.length, mark: seat.mark, origin, tools }, disclosure);
|
|
@@ -38,6 +38,9 @@ import { type StaticToolPlanDeps, type StaticToolPlanSpec, type StaticWiringStat
|
|
|
38
38
|
import { type ToolMountPlan } from "./tool-mount-plan.js";
|
|
39
39
|
import type { WorkspaceSnapshot } from "./workspace-snapshot.js";
|
|
40
40
|
import { type ProjectMarkerUnreadableReason } from "./memory-engine/scope-contract.js";
|
|
41
|
+
import { type HostInstanceDeclaration, type WiringLegInstance } from "./host-instance.js";
|
|
42
|
+
import type { WiringInstructions } from "./instruction-preview.js";
|
|
43
|
+
export type { HostInstanceDeclaration, WiringLegInstance };
|
|
41
44
|
export type { StoreDurability };
|
|
42
45
|
/** The manifest-face projection of {@link StoreDurability}: `"declared_durable"` (the name says it —
|
|
43
46
|
* a DECLARATION relayed, not a verification) vs `"process_local"` (declared so, or fail-closed
|
|
@@ -275,14 +278,21 @@ export declare function deriveLspSeam(mounted: boolean, diagnosticsLive: boolean
|
|
|
275
278
|
*/
|
|
276
279
|
export interface WiringManifest {
|
|
277
280
|
schemaVersion: 1;
|
|
278
|
-
/** Present on EFFECTIVE (per-leg) manifests only;
|
|
281
|
+
/** Present on EFFECTIVE (per-leg) manifests only; never on a static manifest. `instance`: the leg's per-run identity
|
|
282
|
+
* (`{ runId, startedAt }` in epoch ms, minted once together at prepare entry) — present on every engine-minted effective
|
|
283
|
+
* manifest and never on a static one (optional on the type for pre-field producers and unit callers). `runOrigin`: the word of the input that
|
|
279
284
|
* opened this leg, when its host said so (the objective's `TaskSpec.runOrigin`, or the newest input a wake hands over; read
|
|
280
285
|
* once at the config doors), and on a leg a decision resumed, the checkpoint row's — absent when the host said nothing, and
|
|
281
286
|
* on a delegated child (a child is its parent's model's work). */
|
|
282
287
|
leg?: {
|
|
283
288
|
kind: WiringLegKind;
|
|
289
|
+
instance?: WiringLegInstance;
|
|
284
290
|
runOrigin?: RunOrigin;
|
|
285
291
|
};
|
|
292
|
+
/** Both halves — present iff the deployment declared `RunnerDeps.host` (`{ instanceId, startedAt }`, epoch ms); omitted
|
|
293
|
+
* when the deployment declared nothing. Single writer = the deployment; frozen copy detached from the caller's object;
|
|
294
|
+
* excluded from {@link configFingerprint}. */
|
|
295
|
+
host?: HostInstanceDeclaration;
|
|
286
296
|
/** Effective half only — the leg's team role ({@link import("../agents/team-role.js").teamRoleOf}):
|
|
287
297
|
* `lead` for a top-level leg, `teammate` for a named delegation, `none` for an unnamed one. Leg-local
|
|
288
298
|
* (excluded from the fingerprint). */
|
|
@@ -708,22 +718,13 @@ export interface WiringManifest {
|
|
|
708
718
|
projectMemory?: "on" | "disabled" | "absent";
|
|
709
719
|
/**
|
|
710
720
|
* EFFECTIVE half only — the roots' instruction files this leg holds as it starts. Present ⇔ the instruction-file lane is seated (a
|
|
711
|
-
* family declared and left on, hands mounted). `selected` = the task root's family members the
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* declaration order, `directory` the request's own spelling (`TaskSpec.additionalDirectories`), `selected` what that root's
|
|
717
|
-
* level holds, relative to it, as above; a declared entry the hands could not resolve, or one that is the task root or an
|
|
718
|
-
* earlier entry, is not listed. Out of {@link configFingerprint}: a per-leg read.
|
|
721
|
+
* family declared and left on, hands mounted, or host-text withholds recorded). `selected` = the task root's family members the
|
|
722
|
+
* conversation holds or the leg's first load has on its way, relative to the task root; `additionalDirectories` = same per opted-in
|
|
723
|
+
* additional root; `included` = `@`-included files loaded on first load (present iff non-empty); `withheld` = lane-discovered and
|
|
724
|
+
* host-text files withheld on first load (present iff non-empty, with `blockedAfterApproval` on `outside_its_root` when Read admission
|
|
725
|
+
* would still refuse after approval). Produced by the same reading as `Runner.previewInstructions`. Out of {@link configFingerprint}.
|
|
719
726
|
*/
|
|
720
|
-
instructions?:
|
|
721
|
-
readonly selected: readonly string[];
|
|
722
|
-
readonly additionalDirectories?: ReadonlyArray<{
|
|
723
|
-
readonly directory: string;
|
|
724
|
-
readonly selected: readonly string[];
|
|
725
|
-
}>;
|
|
726
|
-
};
|
|
727
|
+
instructions?: WiringInstructions;
|
|
727
728
|
/**
|
|
728
729
|
* EFFECTIVE half only, ALWAYS present on an engine-minted effective manifest: are the legs THIS leg delegates (sync,
|
|
729
730
|
* background, forked, workflow, retained, resumed and observer-sidecar legs, at any depth) bound by a rule written to this
|
|
@@ -771,7 +772,7 @@ export interface WiringManifest {
|
|
|
771
772
|
* detail (zero second read; no file content and no error text). `markerPath` passes through the same
|
|
772
773
|
* {@link codedDetailStringOf} screen as P-e `terminal.detail` (redacted when credential-shaped, omitted when over
|
|
773
774
|
* the coded-detail string bound or when `reason === "repo_root_unreadable"`). Mutually exclusive with
|
|
774
|
-
* {@link WiringManifest.project} (never both present on one manifest; a leg declaring `TaskSpec.
|
|
775
|
+
* {@link WiringManifest.project} (never both present on one manifest; a leg declaring `TaskSpec.project` beside an
|
|
775
776
|
* unreadable marker is refused and emits no manifest). A host (e.g. the service layer) leaves its stored project row
|
|
776
777
|
* untouched on it. Out of {@link configFingerprint}: a per-leg fact.
|
|
777
778
|
*/
|
|
@@ -796,8 +797,12 @@ export interface WiringFacts {
|
|
|
796
797
|
half: "static" | "effective";
|
|
797
798
|
/** Required on the effective half; must be absent on the static half. */
|
|
798
799
|
leg?: WiringLegKind;
|
|
800
|
+
/** Effective half only, reported inside `leg.instance` — minted once at prepare entry; refused on the static half. */
|
|
801
|
+
legInstance?: WiringLegInstance;
|
|
799
802
|
/** Effective half only, reported inside `leg` — see {@link WiringManifest.leg}. */
|
|
800
803
|
runOrigin?: RunOrigin;
|
|
804
|
+
/** Both halves — present iff declared on `RunnerDeps.host`; see {@link WiringManifest.host}. */
|
|
805
|
+
host?: HostInstanceDeclaration;
|
|
801
806
|
/** Effective half only — see {@link WiringManifest.teamRole}. */
|
|
802
807
|
teamRole?: import("../agents/team-role.js").TeamRole;
|
|
803
808
|
/** Effective half only — see {@link WiringManifest.peerPresence}; copied, never aliased. */
|
|
@@ -955,7 +960,7 @@ export interface WiringAdvisorFact {
|
|
|
955
960
|
}
|
|
956
961
|
/** Named view of the deps seats the static half reads (a `Pick` of the real {@link RunnerDeps} —
|
|
957
962
|
* single-source shapes, no parallel hand-copied interface). */
|
|
958
|
-
export type StaticWiringDeps = Pick<RunnerDeps, "onAsk" | "onQuestion" | "interactionPosture" | "onElicit" | "checkpointStore" | "sessionStore" | "backgroundAgentStore" | "onBackgroundChildEvent" | "lockedConfig" | "compliancePostureResolver" | "memoryScopeAdmission" | "retentionPolicy" | "permissionRuleStore" | "permissionRuleSyncWired"> & StaticToolPlanDeps;
|
|
963
|
+
export type StaticWiringDeps = Pick<RunnerDeps, "host" | "onAsk" | "onQuestion" | "interactionPosture" | "onElicit" | "checkpointStore" | "sessionStore" | "backgroundAgentStore" | "onBackgroundChildEvent" | "lockedConfig" | "compliancePostureResolver" | "memoryScopeAdmission" | "retentionPolicy" | "permissionRuleStore" | "permissionRuleSyncWired"> & StaticToolPlanDeps;
|
|
959
964
|
/** Named view of the spec seats the static half reads (a `Pick` of the real {@link TaskSpec}). */
|
|
960
965
|
export type StaticWiringSpec = Pick<TaskSpec, "onAsk" | "approvalReach" | "onQuestion" | "checkpointStore" | "durableApproval" | "mcp" | "interactiveTools" | "interactionPosture"> & StaticToolPlanSpec;
|
|
961
966
|
/**
|
|
@@ -1159,8 +1164,9 @@ export declare function screenInteractionPostureWord(posture: unknown): "interac
|
|
|
1159
1164
|
* mounts decides it — a tool's own or the task's explicit deferral (`defer`, `TaskSpec.deferTools`), the pins against it
|
|
1160
1165
|
* (`alwaysLoad`, `TaskSpec.alwaysLoadTools`), the size threshold (`RunnerDeps.toolSearch`, `RunnerDeps.deferMode`), the tools a
|
|
1161
1166
|
* declared peer lists, the valve admitting `ToolSearch` — and this table does not run that classification;
|
|
1162
|
-
* ·
|
|
1163
|
-
* (`loadedSkills`; a skill over the load limit does not load)
|
|
1167
|
+
* · two rows state what the leg reads from the spec, by the leg's own function: the `Skill` row holds exactly when a skill loads
|
|
1168
|
+
* (`loadedSkills`; a skill over the load limit does not load), and a spec that declares `ownHandsReadOnly` is read as read-only
|
|
1169
|
+
* hands (`withOwnLegHands`: Write / Edit absent, `Bash` the read-only one). The spec is read once by member name
|
|
1164
1170
|
* (`readCallerSpec`), as the Runner reads it, and its refusal (a member that cannot be read, a retired key, a key the engine does
|
|
1165
1171
|
* not read) is thrown here as the leg's config door throws it; `executionEnv` is read over the facts the leg holds when it decides
|
|
1166
1172
|
* whether to start an environment (`listing.skills` is stated after).
|
|
@@ -20,6 +20,7 @@ import { enterConfigDoor } from "./config-refusal-input.js";
|
|
|
20
20
|
import { readCallerSpec } from "./task-spec-members.js";
|
|
21
21
|
import { PROJECT_MARKER_UNREADABLE_REASONS } from "./memory-engine/scope-contract.js";
|
|
22
22
|
import { codedDetailStringOf } from "./runner/terminal-account.js";
|
|
23
|
+
import { readLegInstanceFact, receiveHostInstance } from "./host-instance.js";
|
|
23
24
|
export function wiringLegKindOf(resumed, internals) {
|
|
24
25
|
return resumed ? "resume" : engineLaneLegOf(internals) ? "child" : "root";
|
|
25
26
|
}
|
|
@@ -266,8 +267,8 @@ function readProjectMarkerUnreadableFact(fact) {
|
|
|
266
267
|
return shown !== undefined ? { reason: reason, markerPath: shown } : { reason: reason };
|
|
267
268
|
}
|
|
268
269
|
export function deriveWiringManifest(facts) {
|
|
269
|
-
if (facts.half === "static" && (facts.leg !== undefined || facts.runOrigin !== undefined)) {
|
|
270
|
-
throw new Error("a static wiring manifest has no leg — leg identity (its kind and its run origin) is an effective-half fact");
|
|
270
|
+
if (facts.half === "static" && (facts.leg !== undefined || facts.legInstance !== undefined || facts.runOrigin !== undefined)) {
|
|
271
|
+
throw new Error("a static wiring manifest has no leg — leg identity (its kind, its instance and its run origin) is an effective-half fact");
|
|
271
272
|
}
|
|
272
273
|
if (facts.half === "effective" && facts.leg === undefined) {
|
|
273
274
|
throw new Error("an effective wiring manifest requires its leg kind");
|
|
@@ -290,7 +291,8 @@ export function deriveWiringManifest(facts) {
|
|
|
290
291
|
: "absent";
|
|
291
292
|
const manifest = {
|
|
292
293
|
schemaVersion: 1,
|
|
293
|
-
...(facts.leg !== undefined ? { leg: { kind: facts.leg, ...(facts.runOrigin !== undefined ? { runOrigin: readWordFact(facts.runOrigin, RUN_ORIGINS, "run origin") } : {}) } } : {}),
|
|
294
|
+
...(facts.leg !== undefined ? { leg: { kind: facts.leg, ...(facts.legInstance !== undefined ? { instance: readLegInstanceFact(facts.legInstance) } : {}), ...(facts.runOrigin !== undefined ? { runOrigin: readWordFact(facts.runOrigin, RUN_ORIGINS, "run origin") } : {}) } } : {}),
|
|
295
|
+
...(facts.host !== undefined ? { host: receiveHostInstance(facts.host, "WiringFacts.host") } : {}),
|
|
294
296
|
ask: {
|
|
295
297
|
form: facts.askForm,
|
|
296
298
|
...(facts.askProvenance !== undefined ? { provenance: facts.askProvenance } : {}),
|
|
@@ -459,12 +461,14 @@ export function describeStaticWiring(deps, handed = {}, statement = {}) {
|
|
|
459
461
|
if (read.refusal !== undefined)
|
|
460
462
|
throw read.refusal;
|
|
461
463
|
const spec = read.spec;
|
|
464
|
+
const host = receiveHostInstance(deps.host, "RunnerDeps.host");
|
|
462
465
|
const ask = resolveAskSeamForm(spec, deps);
|
|
463
466
|
const question = resolveQuestionSeam(spec, deps);
|
|
464
467
|
const checkpointStore = resolveCheckpointStore(spec, deps);
|
|
465
468
|
const capable = checkpointStore !== undefined;
|
|
466
469
|
return deriveWiringManifest({
|
|
467
470
|
half: "static",
|
|
471
|
+
...(host !== undefined ? { host } : {}),
|
|
468
472
|
askForm: ask.form,
|
|
469
473
|
...(ask.provenance !== undefined ? { askProvenance: ask.provenance } : {}),
|
|
470
474
|
...(ask.answeredClasses !== undefined ? { askAnsweredClasses: ask.answeredClasses } : {}),
|