@sema-agent/core 7.66.0 → 7.67.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 +3498 -0
- package/LICENSE +2 -1
- package/dist/agents/agent-definition.js +2 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/agent-transcript-tool.js +4 -3
- package/dist/agents/builtin-agents.d.ts +10 -7
- package/dist/agents/builtin-agents.js +1 -0
- package/dist/agents/cascade.d.ts +24 -11
- package/dist/agents/cascade.js +21 -9
- package/dist/agents/child-failure.d.ts +30 -0
- package/dist/agents/child-failure.js +25 -1
- package/dist/agents/composition-placement.d.ts +6 -2
- package/dist/agents/composition-placement.js +7 -3
- package/dist/agents/cross-session-envelope.d.ts +10 -1
- package/dist/agents/cross-session-envelope.js +6 -2
- package/dist/agents/cross-session-judge.d.ts +7 -1
- package/dist/agents/cross-session-judge.js +1 -0
- package/dist/agents/cumulative-stats.d.ts +36 -2
- package/dist/agents/cumulative-stats.js +44 -9
- package/dist/agents/delegation-registry-seat.js +2 -3
- package/dist/agents/inherited-tool-pool.d.ts +9 -4
- package/dist/agents/inherited-tool-pool.js +7 -1
- package/dist/agents/leg-label.d.ts +28 -0
- package/dist/agents/leg-label.js +9 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/list-agents-tool.js +4 -4
- package/dist/agents/org-delivery-gate.d.ts +129 -23
- package/dist/agents/org-delivery-gate.js +41 -20
- package/dist/agents/peer-held-queue.d.ts +15 -10
- package/dist/agents/peer-held-queue.js +47 -19
- package/dist/agents/peer-notice-route.js +2 -2
- package/dist/agents/peer-notices.d.ts +13 -2
- package/dist/agents/peer-notices.js +12 -2
- package/dist/agents/peer-session-drain.d.ts +65 -15
- package/dist/agents/peer-session-drain.js +198 -41
- package/dist/agents/read-inbox-tool.d.ts +3 -2
- package/dist/agents/read-inbox-tool.js +7 -5
- package/dist/agents/repair-loop.js +20 -16
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/retain-ledger.js +2 -4
- package/dist/agents/root-session-lane.d.ts +27 -0
- package/dist/agents/root-session-lane.js +57 -0
- package/dist/agents/roster-store.js +1 -2
- package/dist/agents/send-message-tool.js +6 -4
- package/dist/agents/subagent.d.ts +20 -4
- package/dist/agents/subagent.js +218 -183
- package/dist/agents/tool-filter.d.ts +3 -10
- package/dist/agents/tool-filter.js +0 -13
- package/dist/agents/verifier-independence.d.ts +31 -0
- package/dist/agents/verifier-independence.js +23 -0
- package/dist/agents/verify.d.ts +23 -11
- package/dist/agents/verify.js +28 -12
- package/dist/agents/yield-adoption.d.ts +24 -0
- package/dist/agents/yield-adoption.js +84 -0
- package/dist/bench/metrics.d.ts +2 -2
- package/dist/brain/anthropic.d.ts +4 -2
- package/dist/brain/anthropic.js +49 -35
- package/dist/brain/brain-faces.d.ts +11 -0
- package/dist/brain/brain-faces.js +6 -0
- package/dist/brain/cache-retention.d.ts +2 -0
- package/dist/brain/cache-retention.js +9 -0
- package/dist/brain/circuit-breaker.js +51 -26
- package/dist/brain/errors.d.ts +15 -1
- package/dist/brain/errors.js +8 -0
- package/dist/brain/failover.d.ts +6 -0
- package/dist/brain/failover.js +52 -37
- package/dist/brain/media-degrade.d.ts +5 -0
- package/dist/brain/media-degrade.js +4 -0
- package/dist/brain/model-capability.d.ts +2 -1
- package/dist/brain/model-lane.d.ts +145 -0
- package/dist/brain/model-lane.js +444 -0
- package/dist/brain/open-responses.js +19 -22
- package/dist/brain/openai.js +23 -22
- package/dist/brain/provider-message.d.ts +9 -0
- package/dist/brain/provider-message.js +18 -0
- package/dist/brain/reasoning-request.d.ts +9 -7
- package/dist/brain/reasoning-request.js +9 -10
- package/dist/brain/reasoning.d.ts +47 -13
- package/dist/brain/reasoning.js +20 -10
- package/dist/brain/route-adjudicator.d.ts +8 -2
- package/dist/brain/route-adjudicator.js +35 -1
- package/dist/brain/route-conformance.js +17 -0
- package/dist/brain/routing.d.ts +2 -0
- package/dist/brain/routing.js +19 -8
- package/dist/brain/status-sink.d.ts +5 -4
- package/dist/brain/status-sink.js +2 -2
- package/dist/brain/stream-engine.js +8 -2
- package/dist/brain/stream-shared.d.ts +12 -0
- package/dist/brain/stream-shared.js +18 -0
- package/dist/brain/timeout.d.ts +28 -0
- package/dist/brain/timeout.js +13 -4
- package/dist/brain/tool-schema-projection.d.ts +2 -0
- package/dist/brain/tool-schema-projection.js +108 -0
- package/dist/brain/usage-reading.d.ts +49 -0
- package/dist/brain/usage-reading.js +44 -0
- package/dist/brain/usage-reasoning.d.ts +38 -0
- package/dist/brain/usage-reasoning.js +9 -0
- package/dist/config/catalog.d.ts +3 -0
- package/dist/config/catalog.js +18 -9
- package/dist/core/a2a.d.ts +22 -4
- package/dist/core/a2a.js +191 -50
- package/dist/core/agent-definition.d.ts +3 -1
- package/dist/core/agent-state.d.ts +29 -16
- package/dist/core/agent-state.js +36 -9
- package/dist/core/allow-entry.d.ts +12 -3
- package/dist/core/allow-entry.js +10 -3
- package/dist/core/approval-display.d.ts +18 -0
- package/dist/core/approval-display.js +26 -0
- package/dist/core/approval-object.js +2 -2
- package/dist/core/approval-route.d.ts +16 -0
- package/dist/core/approval-route.js +5 -0
- package/dist/core/approval-words.d.ts +43 -0
- package/dist/core/approval-words.js +37 -0
- package/dist/core/ask-origin.d.ts +37 -10
- package/dist/core/ask-origin.js +19 -7
- package/dist/core/ask-question.d.ts +36 -8
- package/dist/core/ask-question.js +24 -9
- package/dist/core/ask-unresolvable-notice.d.ts +3 -2
- package/dist/core/ask-unresolvable-notice.js +3 -2
- package/dist/core/attachment-source.d.ts +50 -0
- package/dist/core/attachment-source.js +46 -0
- package/dist/core/auto-compaction.d.ts +151 -40
- package/dist/core/auto-compaction.js +115 -50
- package/dist/core/auto-mode.d.ts +5 -0
- package/dist/core/auto-mode.js +11 -4
- package/dist/core/background-agent-store.d.ts +151 -23
- package/dist/core/background-agent-store.js +201 -61
- package/dist/core/background-shell.d.ts +4 -1
- package/dist/core/background-shell.js +1 -0
- package/dist/core/cache-break-detector.d.ts +49 -25
- package/dist/core/cache-break-detector.js +99 -44
- package/dist/core/caller-text.d.ts +28 -0
- package/dist/core/caller-text.js +12 -0
- package/dist/core/canonical-json.d.ts +5 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +80 -9
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-generation.d.ts +8 -1
- package/dist/core/checkpoint-generation.js +3 -0
- package/dist/core/checkpoint-queries.d.ts +47 -14
- package/dist/core/checkpoint-queries.js +63 -30
- package/dist/core/checkpoint-requirements.d.ts +36 -3
- package/dist/core/checkpoint-requirements.js +11 -1
- package/dist/core/checkpoint-row-verdict.d.ts +0 -2
- package/dist/core/checkpoint-row-verdict.js +5 -8
- package/dist/core/checkpoint-store.d.ts +166 -41
- package/dist/core/checkpoint-store.js +96 -15
- package/dist/core/child-clamp-seats.d.ts +10 -2
- package/dist/core/child-clamp-seats.js +2 -2
- package/dist/core/classifier-unavailable-arm.d.ts +11 -9
- package/dist/core/classifier-unavailable-arm.js +4 -2
- package/dist/core/command-sandbox-dispatch.d.ts +13 -0
- package/dist/core/command-sandbox-dispatch.js +8 -0
- package/dist/core/command-sandbox.d.ts +231 -0
- package/dist/core/command-sandbox.js +344 -0
- package/dist/core/completion-id.d.ts +21 -0
- package/dist/core/completion-id.js +14 -0
- package/dist/core/config-refusal-codes.d.ts +22 -0
- package/dist/core/config-refusal-codes.js +196 -0
- package/dist/core/context-edit.d.ts +26 -0
- package/dist/core/context-edit.js +4 -2
- package/dist/core/context-guard.d.ts +80 -7
- package/dist/core/context-guard.js +126 -25
- package/dist/core/context-settings.d.ts +32 -0
- package/dist/core/context-settings.js +41 -3
- package/dist/core/contract-faces.d.ts +22 -0
- package/dist/core/contract-faces.js +1 -0
- package/dist/core/credential-echo.d.ts +2 -2
- package/dist/core/credential-echo.js +2 -2
- package/dist/core/cross-boundary-taint.d.ts +10 -8
- package/dist/core/decision-receipt.d.ts +3 -2
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/definition-entry-grammar.d.ts +42 -0
- package/dist/core/definition-entry-grammar.js +15 -0
- package/dist/core/engine-attestation.d.ts +19 -4
- package/dist/core/engine-attestation.js +4 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-contracts/open-face-contract.d.ts +39 -0
- package/dist/core/engine-contracts/open-face-contract.js +57 -0
- package/dist/core/engine-notice.d.ts +161 -33
- package/dist/core/exclusive-temp.d.ts +25 -0
- package/dist/core/exclusive-temp.js +19 -0
- package/dist/core/existing-target.d.ts +112 -0
- package/dist/core/existing-target.js +88 -0
- package/dist/core/file-history-store.d.ts +14 -6
- package/dist/core/gate-lanes.js +8 -3
- package/dist/core/gate-outcome.d.ts +2 -1
- package/dist/core/git-worktree-env.d.ts +92 -1
- package/dist/core/git-worktree-env.js +87 -6
- package/dist/core/governance-codes.d.ts +49 -8
- package/dist/core/governance-codes.js +59 -8
- package/dist/core/hands-band.d.ts +10 -6
- package/dist/core/hooks.d.ts +60 -6
- package/dist/core/hooks.js +10 -2
- package/dist/core/host-floor.d.ts +24 -8
- package/dist/core/host-floor.js +45 -16
- package/dist/core/human-input-projection.d.ts +7 -0
- package/dist/core/human-input-projection.js +11 -3
- package/dist/core/image-admission.d.ts +16 -4
- package/dist/core/image-admission.js +29 -17
- package/dist/core/input-author.d.ts +43 -1
- package/dist/core/input-author.js +19 -0
- package/dist/core/isolation-scope.d.ts +41 -0
- package/dist/core/isolation-scope.js +10 -0
- package/dist/core/json-schema-seats.d.ts +11 -0
- package/dist/core/json-schema-seats.js +5 -0
- package/dist/core/leg-identity.d.ts +53 -5
- package/dist/core/leg-identity.js +32 -1
- package/dist/core/locked-config.d.ts +33 -38
- package/dist/core/locked-config.js +21 -3
- package/dist/core/lsp.js +2 -1
- package/dist/core/mailbox-store.d.ts +111 -18
- package/dist/core/mailbox-store.js +101 -13
- package/dist/core/mcp-call-meta.js +1 -1
- package/dist/core/mcp-connection-pool.d.ts +8 -2
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +6 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-host-read.d.ts +293 -0
- package/dist/core/mcp-host-read.js +428 -0
- package/dist/core/mcp-server-link.d.ts +28 -6
- package/dist/core/mcp-server-link.js +35 -7
- package/dist/core/mcp-server-spec.d.ts +22 -29
- package/dist/core/mcp-server-spec.js +7 -14
- package/dist/core/mcp-server-unavailable-notice.d.ts +32 -0
- package/dist/core/mcp-server-unavailable-notice.js +15 -0
- package/dist/core/mcp-session-end.d.ts +5 -2
- package/dist/core/mcp-session-end.js +7 -2
- package/dist/core/mcp-tool-meta.d.ts +6 -0
- package/dist/core/mcp-tool-meta.js +1 -0
- package/dist/core/mcp.d.ts +54 -19
- package/dist/core/mcp.js +194 -241
- package/dist/core/memory-engine/committed-shadow-read.d.ts +16 -0
- package/dist/core/memory-engine/committed-shadow-read.js +21 -0
- package/dist/core/memory-engine/consolidation-driver.js +2 -1
- package/dist/core/memory-engine/consolidation.d.ts +3 -3
- package/dist/core/memory-engine/control-objects.d.ts +4 -3
- package/dist/core/memory-engine/control-objects.js +6 -4
- package/dist/core/memory-engine/delegation-settlement.d.ts +127 -25
- package/dist/core/memory-engine/delegation-settlement.js +145 -18
- package/dist/core/memory-engine/distiller.d.ts +2 -1
- package/dist/core/memory-engine/distiller.js +10 -5
- package/dist/core/memory-engine/dual-root.js +2 -2
- package/dist/core/memory-engine/engine.d.ts +127 -33
- package/dist/core/memory-engine/engine.js +774 -323
- package/dist/core/memory-engine/entry-scan.d.ts +3 -0
- package/dist/core/memory-engine/entry-scan.js +8 -0
- package/dist/core/memory-engine/export-bundle.d.ts +4 -0
- package/dist/core/memory-engine/export-bundle.js +2 -0
- package/dist/core/memory-engine/file-backend.d.ts +62 -17
- package/dist/core/memory-engine/file-backend.js +155 -99
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layer-observations.d.ts +7 -1
- package/dist/core/memory-engine/layer-observations.js +6 -0
- package/dist/core/memory-engine/layout.d.ts +88 -26
- package/dist/core/memory-engine/layout.js +105 -29
- package/dist/core/memory-engine/memory-deployment.js +4 -4
- package/dist/core/memory-engine/mount-failed-notice.d.ts +24 -0
- package/dist/core/memory-engine/mount-failed-notice.js +22 -0
- package/dist/core/memory-engine/origin-clearance.d.ts +15 -1
- package/dist/core/memory-engine/origin-clearance.js +30 -10
- package/dist/core/memory-engine/scan.js +1 -1
- package/dist/core/memory-engine/scope-contract.js +4 -3
- package/dist/core/memory-engine/session-write-home.js +13 -1
- package/dist/core/memory-engine/sync-client.d.ts +1 -1
- package/dist/core/memory-engine/sync-client.js +3 -1
- package/dist/core/memory-engine/tools.d.ts +5 -4
- package/dist/core/memory-engine/tools.js +1 -1
- package/dist/core/memory-engine/types.d.ts +18 -1
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/memory.js +2 -6
- package/dist/core/mode-policy.d.ts +8 -1
- package/dist/core/mode-policy.js +6 -2
- package/dist/core/model-fallbacks.d.ts +103 -0
- package/dist/core/model-fallbacks.js +79 -0
- package/dist/core/model-receipt.d.ts +15 -3
- package/dist/core/model-receipt.js +22 -1
- package/dist/core/model-seat.d.ts +1 -1
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/dollar.d.ts +47 -2
- package/dist/core/mods/dollar.js +28 -5
- package/dist/core/mods/kernel/budget.d.ts +6 -0
- package/dist/core/mods/kernel/budget.js +6 -0
- package/dist/core/mods/kernel/dispatch.d.ts +23 -2
- package/dist/core/mods/kernel/dispatch.js +104 -15
- package/dist/core/mods/kernel/events.d.ts +18 -1
- package/dist/core/mods/kernel/events.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +2 -2
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/receive.d.ts +2 -1
- package/dist/core/mods/lifecycle-stations.d.ts +13 -4
- package/dist/core/mods/lifecycle-stations.js +8 -3
- package/dist/core/mods/message-display.d.ts +81 -0
- package/dist/core/mods/message-display.js +369 -0
- package/dist/core/mods/prompt-submit.d.ts +1 -1
- package/dist/core/mods/prompt-submit.js +5 -2
- package/dist/core/mods/session-append.d.ts +2 -2
- package/dist/core/mods/session-append.js +2 -1
- package/dist/core/mods/session-compact.js +2 -2
- package/dist/core/mods/stations.d.ts +48 -18
- package/dist/core/mods/stations.js +100 -19
- package/dist/core/mods/stop-answers.d.ts +23 -0
- package/dist/core/mods/stop-answers.js +20 -0
- package/dist/core/mounted-mcp.d.ts +48 -8
- package/dist/core/mounted-mcp.js +82 -16
- package/dist/core/namespaced-rule-name.js +2 -1
- package/dist/core/own-property-receipt.js +3 -5
- package/dist/core/parent-spec-seat.d.ts +20 -1
- package/dist/core/parent-spec-seat.js +13 -3
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/path-identity.js +2 -1
- package/dist/core/peer-seat.d.ts +21 -7
- package/dist/core/peer-seat.js +25 -16
- package/dist/core/permission-rule-consent.js +15 -5
- package/dist/core/permission-rule-model.d.ts +4 -2
- package/dist/core/permission-rule-model.js +43 -23
- package/dist/core/permission-rule-store.d.ts +31 -16
- package/dist/core/permission-rule-store.js +27 -18
- package/dist/core/present-plan-tool.d.ts +6 -1
- package/dist/core/present-plan-tool.js +11 -3
- package/dist/core/pricing.d.ts +8 -6
- package/dist/core/pricing.js +1 -1
- package/dist/core/principal-name.d.ts +13 -0
- package/dist/core/principal-name.js +9 -2
- package/dist/core/process-identity.d.ts +140 -0
- package/dist/core/process-identity.js +215 -0
- package/dist/core/protocol-http-auth.d.ts +28 -6
- package/dist/core/protocol-http-auth.js +22 -5
- package/dist/core/protocol-naming.d.ts +7 -0
- package/dist/core/protocol-naming.js +12 -2
- package/dist/core/protocol-revocation.d.ts +72 -0
- package/dist/core/protocol-revocation.js +98 -0
- package/dist/core/protocol-table.d.ts +4 -4
- package/dist/core/protocol-table.js +3 -2
- package/dist/core/push-queue.d.ts +35 -2
- package/dist/core/push-queue.js +60 -4
- package/dist/core/read-only-shell.d.ts +19 -0
- package/dist/core/read-only-shell.js +38 -11
- package/dist/core/real-approval.d.ts +26 -0
- package/dist/core/real-approval.js +15 -0
- package/dist/core/redaction-marks.d.ts +6 -2
- package/dist/core/redaction-marks.js +3 -0
- package/dist/core/reminder-mint.d.ts +6 -0
- package/dist/core/reminder-mint.js +9 -8
- package/dist/core/remote-env.d.ts +31 -15
- package/dist/core/remote-env.js +29 -0
- package/dist/core/request-copy-projection.d.ts +51 -0
- package/dist/core/request-copy-projection.js +410 -0
- package/dist/core/resume-config-judge.d.ts +69 -0
- package/dist/core/resume-config-judge.js +78 -0
- package/dist/core/resume-startup-cause.d.ts +14 -4
- package/dist/core/resume-startup-cause.js +12 -2
- package/dist/core/retention-policy.js +2 -1
- package/dist/core/retention.d.ts +119 -24
- package/dist/core/retention.js +60 -16
- package/dist/core/retired-keys.d.ts +0 -10
- package/dist/core/retired-keys.js +2 -3
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +65 -4
- package/dist/core/row-shape.d.ts +149 -0
- package/dist/core/row-shape.js +184 -0
- package/dist/core/runner/advertised-writable-dirs.js +10 -9
- package/dist/core/runner/advisor-instructions.d.ts +11 -27
- package/dist/core/runner/advisor-instructions.js +18 -20
- package/dist/core/runner/advisor-tool.js +1 -0
- package/dist/core/runner/announce-once-ledger.js +4 -1
- package/dist/core/runner/approval-feedback.d.ts +17 -8
- package/dist/core/runner/approval-feedback.js +18 -13
- package/dist/core/runner/approver-defect-announcer.d.ts +17 -0
- package/dist/core/runner/approver-defect-announcer.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +29 -14
- package/dist/core/runner/assemble-result.js +16 -25
- package/dist/core/runner/cache-hit-account.d.ts +77 -0
- package/dist/core/runner/cache-hit-account.js +46 -0
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/call-hook-stations.js +5 -4
- package/dist/core/runner/changed-files-scan.d.ts +43 -0
- package/dist/core/runner/changed-files-scan.js +34 -0
- package/dist/core/runner/checkpoint-scope.d.ts +33 -9
- package/dist/core/runner/checkpoint-scope.js +27 -1
- package/dist/core/runner/classifier-ladder.d.ts +2 -2
- package/dist/core/runner/classifier-ladder.js +18 -9
- package/dist/core/runner/clock-and-limits.d.ts +15 -4
- package/dist/core/runner/clock-and-limits.js +19 -1
- package/dist/core/runner/compact-session.js +84 -14
- package/dist/core/runner/compaction-call-options.d.ts +2 -29
- package/dist/core/runner/compaction-call-options.js +2 -9
- package/dist/core/runner/compaction-restate.d.ts +18 -2
- package/dist/core/runner/compaction-restate.js +36 -2
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/context-room.d.ts +55 -0
- package/dist/core/runner/context-room.js +71 -0
- package/dist/core/runner/contracts.d.ts +313 -205
- package/dist/core/runner/conversation-segment.d.ts +49 -14
- package/dist/core/runner/conversation-segment.js +92 -19
- package/dist/core/runner/cross-boundary-lane.d.ts +4 -0
- package/dist/core/runner/cross-boundary-lane.js +9 -6
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/deferred-ask.d.ts +62 -0
- package/dist/core/runner/deferred-ask.js +44 -0
- package/dist/core/runner/delegation-owner.d.ts +19 -0
- package/dist/core/runner/delegation-owner.js +27 -1
- package/dist/core/runner/denial-limit-arms.d.ts +10 -6
- package/dist/core/runner/denial-limit-arms.js +13 -7
- package/dist/core/runner/env-capability-census.d.ts +1 -1
- package/dist/core/runner/file-history-request.js +2 -1
- package/dist/core/runner/file-history-restore.d.ts +16 -2
- package/dist/core/runner/file-history-restore.js +9 -1
- package/dist/core/runner/gate-exit.d.ts +18 -5
- package/dist/core/runner/gate-exit.js +26 -15
- package/dist/core/runner/git-status-frame.d.ts +26 -8
- package/dist/core/runner/git-status-frame.js +14 -9
- package/dist/core/runner/halt-attribution.d.ts +29 -12
- package/dist/core/runner/halt-attribution.js +38 -11
- package/dist/core/runner/image.js +3 -2
- package/dist/core/runner/initial-run-state.d.ts +1 -1
- package/dist/core/runner/initial-run-state.js +4 -4
- package/dist/core/runner/language-frame.d.ts +66 -0
- package/dist/core/runner/language-frame.js +76 -0
- package/dist/core/runner/leg-frame.d.ts +81 -0
- package/dist/core/runner/leg-frame.js +68 -0
- package/dist/core/runner/main-call-account.d.ts +34 -0
- package/dist/core/runner/main-call-account.js +50 -0
- package/dist/core/runner/mcp-redial.d.ts +9 -7
- package/dist/core/runner/mcp-redial.js +20 -21
- package/dist/core/runner/memory-consolidation-driver.d.ts +2 -0
- package/dist/core/runner/memory-consolidation-driver.js +5 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -0
- package/dist/core/runner/messages-omitted-seat.js +21 -0
- package/dist/core/runner/model-fallback-seat.d.ts +20 -0
- package/dist/core/runner/model-fallback-seat.js +43 -0
- package/dist/core/runner/model-lane-seat.d.ts +12 -0
- package/dist/core/runner/model-lane-seat.js +35 -0
- package/dist/core/runner/nested-memory-content.d.ts +33 -0
- package/dist/core/runner/nested-memory-content.js +171 -0
- package/dist/core/runner/nested-memory-lane.d.ts +181 -0
- package/dist/core/runner/nested-memory-lane.js +673 -0
- package/dist/core/runner/park-commit.d.ts +7 -0
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-advisor.d.ts +7 -9
- package/dist/core/runner/prepare-advisor.js +11 -5
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +8 -3
- package/dist/core/runner/prepare-ask-lane.d.ts +21 -3
- package/dist/core/runner/prepare-ask-lane.js +32 -28
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +21 -17
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +10 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +24 -18
- package/dist/core/runner/prepare-config-doors.d.ts +51 -5
- package/dist/core/runner/prepare-config-doors.js +73 -73
- package/dist/core/runner/prepare-context-lane.d.ts +68 -3
- package/dist/core/runner/prepare-context-lane.js +137 -27
- package/dist/core/runner/prepare-defer-classify.d.ts +0 -4
- package/dist/core/runner/prepare-defer-classify.js +9 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -8
- package/dist/core/runner/prepare-delegation-surface.js +72 -64
- package/dist/core/runner/prepare-execution-env.js +1 -9
- package/dist/core/runner/prepare-file-history.d.ts +3 -2
- package/dist/core/runner/prepare-file-history.js +11 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +21 -11
- package/dist/core/runner/prepare-gate-stations.js +13 -13
- package/dist/core/runner/prepare-hands-readface.d.ts +23 -6
- package/dist/core/runner/prepare-hands-readface.js +18 -12
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -10
- package/dist/core/runner/prepare-lsp.js +2 -1
- package/dist/core/runner/prepare-memory-engine-session.js +30 -10
- package/dist/core/runner/prepare-memory.d.ts +4 -0
- package/dist/core/runner/prepare-memory.js +38 -16
- package/dist/core/runner/prepare-offload-wrappers.d.ts +3 -16
- package/dist/core/runner/prepare-offload-wrappers.js +6 -5
- package/dist/core/runner/prepare-park-ask.d.ts +13 -3
- package/dist/core/runner/prepare-park-ask.js +25 -19
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -3
- package/dist/core/runner/prepare-policy-chain.js +144 -120
- package/dist/core/runner/prepare-project-context.d.ts +15 -53
- package/dist/core/runner/prepare-project-context.js +20 -83
- package/dist/core/runner/prepare-prompt-assembly.d.ts +7 -1
- package/dist/core/runner/prepare-prompt-assembly.js +9 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +9 -3
- package/dist/core/runner/prepare-prompt-inputs.js +5 -3
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
- package/dist/core/runner/prepare-protocol-tools.js +46 -27
- package/dist/core/runner/prepare-question-face.d.ts +7 -6
- package/dist/core/runner/prepare-question-face.js +7 -6
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -0
- package/dist/core/runner/prepare-suspend-saga.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +3 -3
- package/dist/core/runner/prepare-task.js +113 -61
- package/dist/core/runner/prepare-tool-disclosure-mount.js +6 -5
- package/dist/core/runner/prepare-turn-wiring.d.ts +33 -7
- package/dist/core/runner/prepare-turn-wiring.js +53 -17
- package/dist/core/runner/prepare-wiring-manifest.d.ts +42 -5
- package/dist/core/runner/prepare-wiring-manifest.js +81 -42
- package/dist/core/runner/prepare-workspace-restore.js +3 -2
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +31 -18
- package/dist/core/runner/reply-pricing.js +10 -15
- package/dist/core/runner/resume-admission.js +10 -15
- package/dist/core/runner/resume-apply.js +20 -9
- package/dist/core/runner/resume-checkpoint-screen.js +2 -4
- package/dist/core/runner/resume-internals-and-config.d.ts +12 -9
- package/dist/core/runner/resume-internals-and-config.js +37 -9
- package/dist/core/runner/resume-preflight.js +3 -3
- package/dist/core/runner/retired-runner-deps.js +3 -0
- package/dist/core/runner/rewind-files.js +6 -6
- package/dist/core/runner/run-attachment-seats.d.ts +1 -3
- package/dist/core/runner/run-attachment-seats.js +1 -6
- package/dist/core/runner/run-brain-sinks.d.ts +4 -7
- package/dist/core/runner/run-brain-sinks.js +7 -10
- package/dist/core/runner/run-clock-and-content.d.ts +8 -5
- package/dist/core/runner/run-clock-and-content.js +18 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +8 -4
- package/dist/core/runner/run-compaction-machinery.js +4 -19
- package/dist/core/runner/run-git-lane.d.ts +8 -3
- package/dist/core/runner/run-git-lane.js +5 -3
- package/dist/core/runner/run-harness-handlers.d.ts +4 -1
- package/dist/core/runner/run-harness-handlers.js +70 -45
- package/dist/core/runner/run-identity-wiring.d.ts +6 -0
- package/dist/core/runner/run-identity-wiring.js +17 -8
- package/dist/core/runner/run-leg.d.ts +5 -2
- package/dist/core/runner/run-leg.js +156 -71
- package/dist/core/runner/run-notification-lane.d.ts +1 -1
- package/dist/core/runner/run-notification-lane.js +22 -10
- package/dist/core/runner/run-recovery-lanes.js +8 -6
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -0
- package/dist/core/runner/run-settle-and-teardown.js +77 -26
- package/dist/core/runner/run-stop-and-final-verify.js +46 -12
- package/dist/core/runner/run-telemetry-and-budget-seats.js +13 -28
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -2
- package/dist/core/runner/run-terminal-adoption.js +14 -9
- package/dist/core/runner/run-tool-mount-facts.js +5 -9
- package/dist/core/runner/run-turn-boundary.d.ts +3 -2
- package/dist/core/runner/run-turn-boundary.js +112 -106
- package/dist/core/runner/runtask.d.ts +28 -8
- package/dist/core/runner/runtask.js +132 -41
- package/dist/core/runner/session-file-state-replay.d.ts +5 -3
- package/dist/core/runner/session-file-state-replay.js +10 -3
- package/dist/core/runner/session-rule-policy.d.ts +3 -3
- package/dist/core/runner/session-verb-doors.d.ts +18 -3
- package/dist/core/runner/session-verb-doors.js +38 -6
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +4 -4
- package/dist/core/runner/side-call-account.d.ts +12 -8
- package/dist/core/runner/side-call-account.js +24 -15
- package/dist/core/runner/stream-halt-verbs.js +1 -0
- package/dist/core/runner/stream-mode-verb.js +2 -1
- package/dist/core/runner/stream-settle-backstop.js +4 -1
- package/dist/core/runner/stream-steer-verb.js +35 -19
- package/dist/core/runner/sub-agent-deny-lists.d.ts +47 -11
- package/dist/core/runner/sub-agent-deny-lists.js +140 -39
- package/dist/core/runner/teardown-bounded.d.ts +6 -0
- package/dist/core/runner/teardown-bounded.js +12 -7
- package/dist/core/runner/terminal-account.d.ts +2 -0
- package/dist/core/runner/terminal-account.js +6 -1
- package/dist/core/runner/tool-disclosure.js +2 -1
- package/dist/core/runner/tool-end-body.js +3 -1
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +1 -1
- package/dist/core/runner/tool-occurrence.d.ts +34 -9
- package/dist/core/runner/tool-occurrence.js +32 -21
- package/dist/core/runner/tool-progress-lane.d.ts +20 -5
- package/dist/core/runner/tool-progress-lane.js +27 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +15 -4
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/tool-table-view.js +1 -1
- package/dist/core/runner/turn-attachments.d.ts +44 -71
- package/dist/core/runner/turn-attachments.js +52 -104
- package/dist/core/runner/usage-accounting.d.ts +3 -2
- package/dist/core/runner/usage-accounting.js +3 -2
- package/dist/core/runner/void-verifier-pause.js +1 -1
- package/dist/core/runner-deps.d.ts +42 -158
- package/dist/core/runtime-caps.d.ts +16 -4
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +46 -23
- package/dist/core/sensitive-path-policy.d.ts +8 -0
- package/dist/core/sensitive-path-policy.js +10 -2
- package/dist/core/session-checkout.d.ts +32 -27
- package/dist/core/session-checkout.js +109 -61
- package/dist/core/session-log-transfer.js +2 -1
- package/dist/core/session-policy-store.d.ts +24 -11
- package/dist/core/session-policy-store.js +11 -2
- package/dist/core/session-store.d.ts +16 -2
- package/dist/core/session-store.js +43 -17
- package/dist/core/session.d.ts +31 -3
- package/dist/core/session.js +33 -2
- package/dist/core/shell-run-candidates.d.ts +20 -8
- package/dist/core/shell-run-candidates.js +44 -21
- package/dist/core/side-query.d.ts +17 -5
- package/dist/core/side-query.js +17 -14
- package/dist/core/skill-grant.js +2 -3
- package/dist/core/skills-directory.js +3 -66
- package/dist/core/snapshot-frame-seat.d.ts +8 -0
- package/dist/core/snapshot-frame-seat.js +24 -0
- package/dist/core/steer-replay.d.ts +19 -3
- package/dist/core/steer-replay.js +8 -1
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +17 -2
- package/dist/core/store-contracts/background-agent-store-contract.js +131 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +63 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +213 -3
- package/dist/core/store-contracts/permission-rule-write-contract.js +24 -0
- package/dist/core/store-contracts/session-deletion-cascade-contract.d.ts +15 -0
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +288 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +57 -36
- package/dist/core/store-contracts/session-repo-contract.js +130 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/session-store-contract.js +17 -0
- package/dist/core/store-contracts/task-list-store-contract.d.ts +32 -0
- package/dist/core/store-contracts/task-list-store-contract.js +240 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +41 -0
- package/dist/core/stub-env.d.ts +2 -2
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.d.ts +38 -28
- package/dist/core/synthetic-read-verdict.js +19 -28
- package/dist/core/task-event.d.ts +171 -19
- package/dist/core/task-intake.d.ts +26 -0
- package/dist/core/task-intake.js +31 -0
- package/dist/core/task-limits.d.ts +8 -6
- package/dist/core/task-notification.d.ts +88 -8
- package/dist/core/task-notification.js +45 -5
- package/dist/core/task-registry-agent.d.ts +24 -7
- package/dist/core/task-registry-agent.js +51 -28
- package/dist/core/task-registry-monitor.js +16 -14
- package/dist/core/task-registry-shared.d.ts +177 -35
- package/dist/core/task-registry-shared.js +44 -17
- package/dist/core/task-registry-workflow.js +8 -5
- package/dist/core/task-registry-yield.d.ts +32 -0
- package/dist/core/task-registry-yield.js +85 -0
- package/dist/core/task-registry.d.ts +88 -10
- package/dist/core/task-registry.js +124 -33
- package/dist/core/task-result.d.ts +115 -31
- package/dist/core/task-spec-members.d.ts +140 -1
- package/dist/core/task-spec-members.js +23 -8
- package/dist/core/task-spec.d.ts +181 -51
- package/dist/core/task-spec.js +1 -1
- package/dist/core/task-stream.d.ts +12 -2
- package/dist/core/terminal-cause.d.ts +12 -4
- package/dist/core/thrown-value.d.ts +49 -7
- package/dist/core/thrown-value.js +38 -2
- package/dist/core/tool-catalog-entries.js +13 -3
- package/dist/core/tool-data-door.d.ts +7 -0
- package/dist/core/tool-data-door.js +13 -0
- package/dist/core/tool-face-lists.d.ts +25 -0
- package/dist/core/tool-face-lists.js +38 -0
- package/dist/core/tool-face-reader.d.ts +0 -10
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-list-grammar.d.ts +103 -0
- package/dist/core/tool-list-grammar.js +130 -0
- package/dist/core/tool-mount-facts.d.ts +47 -0
- package/dist/core/tool-mount-facts.js +50 -0
- package/dist/core/tool-mount-plan.d.ts +196 -0
- package/dist/core/tool-mount-plan.js +404 -0
- package/dist/core/tool-mount-static.d.ts +12 -0
- package/dist/core/tool-mount-static.js +174 -0
- package/dist/core/tool-name-aliases.d.ts +60 -2
- package/dist/core/tool-name-aliases.js +22 -2
- package/dist/core/tool-name-list.d.ts +3 -0
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +246 -51
- package/dist/core/tool-policy.js +165 -71
- package/dist/core/tool-registry.d.ts +4 -11
- package/dist/core/tool-registry.js +0 -3
- package/dist/core/tool-result-bytes.d.ts +94 -0
- package/dist/core/tool-result-bytes.js +34 -0
- package/dist/core/tool-result-store.d.ts +97 -13
- package/dist/core/tool-result-store.js +52 -4
- package/dist/core/tool-roster.d.ts +71 -10
- package/dist/core/tool-roster.js +71 -21
- package/dist/core/tool-search-setting.d.ts +7 -9
- package/dist/core/tool-search-setting.js +23 -7
- package/dist/core/tool-spec.d.ts +32 -2
- package/dist/core/tools.js +6 -20
- package/dist/core/trace.d.ts +63 -11
- package/dist/core/trace.js +19 -0
- package/dist/core/types.d.ts +8 -6
- package/dist/core/types.js +3 -1
- package/dist/core/unmatched-tool-names.d.ts +37 -0
- package/dist/core/unmatched-tool-names.js +18 -0
- package/dist/core/untrusted-egress.d.ts +16 -5
- package/dist/core/untrusted-egress.js +202 -32
- package/dist/core/untrusted-text.d.ts +29 -8
- package/dist/core/untrusted-text.js +6 -3
- package/dist/core/user-attachment.d.ts +129 -35
- package/dist/core/user-attachment.js +124 -57
- package/dist/core/user-row-origin.d.ts +63 -0
- package/dist/core/user-row-origin.js +61 -0
- package/dist/core/wiring-manifest.d.ts +161 -39
- package/dist/core/wiring-manifest.js +42 -6
- package/dist/core/workflow-run-store-contract.d.ts +11 -1
- package/dist/core/workflow-run-store-contract.js +60 -7
- package/dist/core/workflow-run-store.d.ts +61 -12
- package/dist/core/workflow-run-store.js +100 -15
- package/dist/core/workspace-snapshot.d.ts +10 -14
- package/dist/core/workspace-snapshot.js +3 -22
- package/dist/core/write-protect.d.ts +3 -5
- package/dist/core/write-protect.js +2 -4
- package/dist/engine/compaction/compaction.d.ts +3 -0
- package/dist/engine/compaction/compaction.js +4 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +15 -4
- package/dist/engine/execution-env/node-execution-env.js +80 -27
- package/dist/engine/harness/agent-harness.d.ts +143 -27
- package/dist/engine/harness/agent-harness.js +162 -74
- package/dist/engine/harness/types.d.ts +84 -13
- package/dist/engine/harness/types.js +21 -1
- package/dist/engine/llm/tool-turns.d.ts +4 -0
- package/dist/engine/llm/tool-turns.js +7 -2
- package/dist/engine/llm/types.d.ts +111 -24
- package/dist/engine/llm/types.js +69 -5
- package/dist/engine/llm/validation.js +2 -1
- package/dist/engine/loop/agent-loop.d.ts +39 -6
- package/dist/engine/loop/agent-loop.js +172 -82
- package/dist/engine/loop/types.d.ts +43 -4
- package/dist/engine/lsp/node-lsp-manager.d.ts +5 -3
- package/dist/engine/lsp/node-lsp-manager.js +14 -10
- package/dist/engine/session/import-validate.js +9 -0
- package/dist/engine/session/memory-repo.d.ts +8 -1
- package/dist/engine/session/memory-repo.js +20 -12
- package/dist/engine/session/repo-utils.d.ts +10 -0
- package/dist/engine/session/repo-utils.js +11 -5
- package/dist/engine/session/row-cells.d.ts +32 -0
- package/dist/engine/session/row-cells.js +25 -0
- package/dist/index.d.ts +63 -34
- package/dist/index.js +44 -21
- package/dist/internal/harness.d.ts +8 -6
- package/dist/internal/harness.js +6 -4
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/governance-baseline-validity.d.ts +7 -0
- package/dist/orchestration/governance-baseline-validity.js +33 -9
- package/dist/orchestration/run-workflow-tool.d.ts +2 -0
- package/dist/orchestration/run-workflow-tool.js +25 -12
- package/dist/orchestration/workflow-governance.d.ts +19 -4
- package/dist/orchestration/workflow-governance.js +30 -9
- package/dist/orchestration/workflow-primitives.d.ts +4 -1
- package/dist/orchestration/workflow-primitives.js +2 -2
- package/dist/orchestration/workflow-script-runner.d.ts +1 -1
- package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
- package/dist/orchestration/workflow-types.d.ts +21 -12
- package/dist/orchestration/workflow-types.js +15 -4
- package/dist/orchestration/workflow.d.ts +37 -7
- package/dist/orchestration/workflow.js +81 -35
- package/dist/prompt-assembly/artifact-store.js +6 -9
- package/dist/prompt-assembly/assemble.d.ts +4 -10
- package/dist/prompt-assembly/assemble.js +1 -3
- package/dist/prompt-assembly/catalog/constitution.d.ts +0 -20
- package/dist/prompt-assembly/catalog/constitution.js +2 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +5 -3
- package/dist/prompt-assembly/catalog/engine.d.ts +108 -0
- package/dist/prompt-assembly/catalog/engine.js +19 -0
- package/dist/prompt-assembly/catalog/environment.d.ts +276 -0
- package/dist/prompt-assembly/catalog/environment.js +61 -0
- package/dist/prompt-assembly/catalog/index.d.ts +9 -2
- package/dist/prompt-assembly/catalog/index.js +73 -2
- package/dist/prompt-assembly/catalog/locales/index.d.ts +16 -0
- package/dist/prompt-assembly/catalog/locales/index.js +22 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +124 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.d.ts +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +120 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.js +442 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +15 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +50 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +163 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +148 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/team.d.ts +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/team.js +246 -0
- package/dist/prompt-assembly/catalog/role.js +3 -6
- package/dist/prompt-assembly/catalog/schema.d.ts +23 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/composer.d.ts +6 -11
- package/dist/prompt-assembly/composer.js +7 -7
- package/dist/prompt-assembly/engine-text.d.ts +9 -0
- package/dist/prompt-assembly/engine-text.js +33 -0
- package/dist/prompt-assembly/event-registry.js +3 -3
- package/dist/prompt-assembly/explain.d.ts +1 -0
- package/dist/prompt-assembly/explain.js +1 -1
- package/dist/prompt-assembly/locale-review.d.ts +13 -0
- package/dist/prompt-assembly/locale-review.js +19 -0
- package/dist/prompt-assembly/overlay.d.ts +7 -3
- package/dist/prompt-assembly/overlay.js +27 -5
- package/dist/prompt-assembly/renderers.d.ts +4 -4
- package/dist/prompt-assembly/renderers.js +26 -17
- package/dist/prompt-assembly/role-base.d.ts +1 -1
- package/dist/prompt-assembly/select.d.ts +26 -5
- package/dist/prompt-assembly/select.js +25 -2
- package/dist/prompt-assembly/slots.d.ts +19 -0
- package/dist/prompt-assembly/slots.js +16 -0
- package/dist/prompt-assembly/sugar.d.ts +4 -7
- package/dist/prompt-assembly/sugar.js +1 -2
- package/dist/prompt-assembly/tool-catalog.d.ts +5 -1
- package/dist/prompt-assembly/tool-catalog.js +5 -1
- package/dist/prompt-assembly/turn-snapshot.d.ts +38 -10
- package/dist/prompt-assembly/turn-snapshot.js +43 -13
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/cowork.d.ts +6 -25
- package/dist/prompts/cowork.js +10 -12
- package/dist/prompts/default.d.ts +10 -32
- package/dist/prompts/default.js +37 -63
- package/dist/shell/lex.d.ts +39 -13
- package/dist/shell/lex.js +70 -30
- package/dist/stores/file/background-agent-store.d.ts +5 -0
- package/dist/stores/file/background-agent-store.js +35 -61
- package/dist/stores/file/checkpoint-store.d.ts +5 -3
- package/dist/stores/file/checkpoint-store.js +8 -10
- package/dist/stores/file/fs-atomic.d.ts +27 -70
- package/dist/stores/file/fs-atomic.js +52 -148
- package/dist/stores/file/index.d.ts +12 -0
- package/dist/stores/file/index.js +27 -2
- package/dist/stores/file/mailbox-store.d.ts +10 -1
- package/dist/stores/file/mailbox-store.js +40 -12
- package/dist/stores/file/permission-rule-adopt.js +5 -2
- package/dist/stores/file/permission-rule-store.d.ts +81 -20
- package/dist/stores/file/permission-rule-store.js +126 -33
- package/dist/stores/file/session-policy-store.d.ts +2 -2
- package/dist/stores/file/session-store.d.ts +21 -2
- package/dist/stores/file/session-store.js +27 -14
- package/dist/stores/file/task-list-store.js +23 -25
- package/dist/stores/file/tool-result-store.d.ts +45 -7
- package/dist/stores/file/tool-result-store.js +99 -36
- package/dist/stores/file/workflow-run-store.d.ts +1 -0
- package/dist/stores/file/workflow-run-store.js +14 -11
- package/dist/tools/artifact/artifact-tool.js +2 -0
- package/dist/tools/artifact/local-stub.js +6 -6
- package/dist/tools/fs/bash-program-position.d.ts +1 -2
- package/dist/tools/fs/bash-readonly-classifier.d.ts +35 -0
- package/dist/tools/fs/bash-readonly-classifier.js +50 -12
- package/dist/tools/fs/env-error-detail.d.ts +1 -0
- package/dist/tools/fs/env-error-detail.js +7 -0
- package/dist/tools/fs/fs-bash.d.ts +24 -6
- package/dist/tools/fs/fs-bash.js +73 -25
- package/dist/tools/fs/fs-pdf.js +6 -4
- package/dist/tools/fs/fs-read.d.ts +76 -31
- package/dist/tools/fs/fs-read.js +159 -79
- package/dist/tools/fs/fs-search-tools.d.ts +1 -1
- package/dist/tools/fs/fs-search-tools.js +3 -1
- package/dist/tools/fs/fs-shared.d.ts +59 -63
- package/dist/tools/fs/fs-shared.js +31 -18
- package/dist/tools/fs/fs-write.d.ts +13 -0
- package/dist/tools/fs/fs-write.js +69 -13
- package/dist/tools/fs/index.d.ts +19 -1
- package/dist/tools/fs/index.js +10 -2
- package/dist/tools/fs/pdf.js +10 -9
- package/dist/tools/fs/read-deny.js +4 -10
- package/dist/tools/fs/read-floor.d.ts +5 -4
- package/dist/tools/fs/removal-targets.d.ts +11 -5
- package/dist/tools/fs/removal-targets.js +62 -32
- package/dist/tools/fs/safety.d.ts +26 -19
- package/dist/tools/fs/safety.js +13 -8
- package/dist/tools/fs/search.d.ts +1 -1
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-bindings.d.ts +128 -26
- package/dist/tools/fs/shell-read-bindings.js +667 -139
- package/dist/tools/fs/shell-read-check.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +4 -1
- package/dist/tools/fs/shell-read-judge.js +5 -1
- package/dist/tools/fs/shell-read-plan.d.ts +4 -0
- package/dist/tools/fs/shell-read-plan.js +21 -19
- package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
- package/dist/tools/fs/shell-read-sourced.js +18 -1
- package/dist/tools/fs/shell-read-start.d.ts +6 -6
- package/dist/tools/fs/shell-read-start.js +1 -6
- package/dist/tools/fs/shell-read-word.d.ts +4 -2
- package/dist/tools/fs/shell-read-word.js +7 -6
- package/dist/tools/fs/shell-read-workdir.d.ts +1 -1
- package/dist/tools/fs/shell-reentry-text.d.ts +24 -9
- package/dist/tools/fs/shell-reentry-text.js +50 -20
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +14 -4
- package/dist/tools/scheduler-tools.d.ts +5 -2
- package/dist/tools/scheduler-tools.js +8 -6
- package/dist/tools/task-list.d.ts +49 -20
- package/dist/tools/task-list.js +115 -35
- package/dist/tools/web.d.ts +13 -3
- package/dist/tools/web.js +17 -6
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +24 -25
- package/package.json +10 -3
- package/test/export-surface.snapshot.json +330 -32
- package/wire-changes/core-stores-sql@7.66.1.json +30 -0
- package/wire-changes/core-stores-sql@7.67.0.json +39 -0
- package/wire-changes/core@7.66.1.json +46 -0
- package/wire-changes/core@7.67.0.json +12578 -0
- package/wire-changes/mods-kernel@7.66.1.json +30 -0
- package/wire-changes/mods-kernel@7.67.0.json +167 -0
- package/wire-changes/primitives@7.66.1.json +30 -0
- package/wire-changes/primitives@7.67.0.json +325 -0
- package/wire-changes/wiki-gate@7.67.0.json +1636 -0
- package/dist/brain/degrading.d.ts +0 -93
- package/dist/brain/degrading.js +0 -189
- package/dist/core/tool-conformance.d.ts +0 -20
- package/dist/core/tool-conformance.js +0 -37
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { MAX_TIMER_DELAY_MS } from "../brain/timeout.js";
|
|
2
|
+
import { receiveMembers } from "./own-property-receipt.js";
|
|
3
|
+
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
4
|
+
export const DEGRADE_REASONS = Object.freeze(["breaker_open", "rate_limit", "budget", "server_error", "last_resort", "network", "auth", "stream_torn"]);
|
|
5
|
+
const DEGRADE_REASON_SET = new Set(DEGRADE_REASONS);
|
|
6
|
+
export function isDegradeReason(value) {
|
|
7
|
+
return typeof value === "string" && DEGRADE_REASON_SET.has(value);
|
|
8
|
+
}
|
|
9
|
+
export const DEFAULT_FALLBACK_GATE = Object.freeze(["rate_limit", "breaker_open", "server_error", "last_resort"]);
|
|
10
|
+
export const ANY_HOP_FAILURE = "any";
|
|
11
|
+
export const GATEWAY_HOP_GATE = Object.freeze({ on: ANY_HOP_FAILURE });
|
|
12
|
+
export function hopGateAdmits(gate, reason) {
|
|
13
|
+
return gate.on === ANY_HOP_FAILURE || gate.on.includes(reason);
|
|
14
|
+
}
|
|
15
|
+
export const MAX_MODEL_FALLBACKS = 3;
|
|
16
|
+
export const MODEL_FALLBACK_INVALID = "config.model_fallback_invalid";
|
|
17
|
+
export function modelFallbackRefusal(field, message) {
|
|
18
|
+
const e = new Error(message);
|
|
19
|
+
e.code = MODEL_FALLBACK_INVALID;
|
|
20
|
+
e.detail = { field };
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
const CHAINS = new WeakMap();
|
|
24
|
+
const NO_CHAIN = Object.freeze([]);
|
|
25
|
+
export function modelFallbackChainOf(model) {
|
|
26
|
+
return CHAINS.get(model) ?? NO_CHAIN;
|
|
27
|
+
}
|
|
28
|
+
export function recordedFallbackChainOf(model) {
|
|
29
|
+
return CHAINS.get(model);
|
|
30
|
+
}
|
|
31
|
+
export function recordFallbackChain(model, hops) {
|
|
32
|
+
CHAINS.set(model, Object.freeze([...hops]));
|
|
33
|
+
}
|
|
34
|
+
const RECEIVED_POLICIES = new WeakSet();
|
|
35
|
+
export const DEFAULT_MODEL_FALLBACK_POLICY = Object.freeze({ on: DEFAULT_FALLBACK_GATE });
|
|
36
|
+
RECEIVED_POLICIES.add(DEFAULT_MODEL_FALLBACK_POLICY);
|
|
37
|
+
const POLICY_KEYS = ["on", "firstTokenMs"];
|
|
38
|
+
const GATE_WORDS = DEGRADE_REASONS.filter((r) => r !== "budget");
|
|
39
|
+
export function receiveModelFallbackPolicy(value, field) {
|
|
40
|
+
if (value === undefined)
|
|
41
|
+
return DEFAULT_MODEL_FALLBACK_POLICY;
|
|
42
|
+
if (typeof value === "object" && value !== null && RECEIVED_POLICIES.has(value))
|
|
43
|
+
return value;
|
|
44
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
45
|
+
throw modelFallbackRefusal(field, `${field} is ${describeRejectedValue(value)} — it is a record of \`on\` (the reasons a hop failure moves to the next hop) and \`firstTokenMs\`, or absent for the default gate.`);
|
|
46
|
+
}
|
|
47
|
+
const words = { subject: field, unit: "member", moment: "when the fallback policy is received" };
|
|
48
|
+
const held = receiveMembers(value, words, POLICY_KEYS, (message) => modelFallbackRefusal(field, message));
|
|
49
|
+
let on = DEFAULT_MODEL_FALLBACK_POLICY.on;
|
|
50
|
+
if (held.on !== undefined) {
|
|
51
|
+
if (!Array.isArray(held.on))
|
|
52
|
+
throw modelFallbackRefusal(`${field}.on`, `${field}.on is ${describeRejectedValue(held.on)} — it lists reason words (${GATE_WORDS.join(", ")}).`);
|
|
53
|
+
const listed = held.on;
|
|
54
|
+
const seen = [];
|
|
55
|
+
for (const word of listed) {
|
|
56
|
+
if (!isDegradeReason(word) || word === "budget") {
|
|
57
|
+
throw modelFallbackRefusal(`${field}.on`, `${field}.on holds ${describeRejectedValue(word)}, which is not a fallback reason — the words are ${GATE_WORDS.join(", ")} (\`budget\` is the run's near-budget switch, never a gate word).`);
|
|
58
|
+
}
|
|
59
|
+
if (seen.includes(word))
|
|
60
|
+
throw modelFallbackRefusal(`${field}.on`, `${field}.on names ${JSON.stringify(word)} twice.`);
|
|
61
|
+
seen.push(word);
|
|
62
|
+
}
|
|
63
|
+
on = Object.freeze(seen);
|
|
64
|
+
}
|
|
65
|
+
let firstTokenMs;
|
|
66
|
+
if (held.firstTokenMs !== undefined) {
|
|
67
|
+
const ms = held.firstTokenMs;
|
|
68
|
+
if (typeof ms !== "number" || !Number.isInteger(ms) || ms < 1 || ms > MAX_TIMER_DELAY_MS) {
|
|
69
|
+
throw modelFallbackRefusal(`${field}.firstTokenMs`, `${field}.firstTokenMs must be a whole number of milliseconds from 1 to ${MAX_TIMER_DELAY_MS} (got ${typeof ms === "number" ? describeRejectedValue(ms) : `a ${ms === null ? "null" : typeof ms}`}) — omit it for no per-hop deadline.`);
|
|
70
|
+
}
|
|
71
|
+
if (!on.includes("network")) {
|
|
72
|
+
throw modelFallbackRefusal(`${field}.firstTokenMs`, `${field}.firstTokenMs is set but ${field}.on does not admit "network" — the deadline abandons a hop as a network failure, so without "network" in the gate it would end the request on the hop it is meant to leave.`);
|
|
73
|
+
}
|
|
74
|
+
firstTokenMs = ms;
|
|
75
|
+
}
|
|
76
|
+
const policy = Object.freeze({ on, ...(firstTokenMs !== undefined ? { firstTokenMs } : {}) });
|
|
77
|
+
RECEIVED_POLICIES.add(policy);
|
|
78
|
+
return policy;
|
|
79
|
+
}
|
|
@@ -14,7 +14,7 @@ export type ModelBindingReason = Extract<CheckpointErrorReason, "unknown_model_r
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function modelBindingRefusal(field: string, reason: ModelBindingReason, message: string): Error;
|
|
16
16
|
/** Whether a value is a list — total: a revoked Proxy traps even `Array.isArray`, and a refusal's own reading must not throw in its place. */
|
|
17
|
-
export declare function isList(value: unknown):
|
|
17
|
+
export declare function isList(value: unknown): value is unknown[];
|
|
18
18
|
/** A word in a refusal sentence, bounded and quoted; any other kind of value by its kind (rendering it could itself throw). */
|
|
19
19
|
export declare function bindingShown(value: unknown): string;
|
|
20
20
|
/** The model door's mode of the one receipt: the declaration mode, with `headers` read per use. */
|
|
@@ -27,6 +27,12 @@ export declare function isModelSnapshot(value: unknown): value is Model;
|
|
|
27
27
|
* its own origin.
|
|
28
28
|
*/
|
|
29
29
|
export declare function modelOriginOf(model: Model): Model;
|
|
30
|
+
/**
|
|
31
|
+
* A second snapshot of `snapshot`: the same members (a `headers` read port carried as the same port, never read here), the same
|
|
32
|
+
* origin, minted by the door so it is received as itself — and an identity of its own. The catalog door takes one for an entry
|
|
33
|
+
* whose words, in a later catalog generation, resolve to a chain other than the one its snapshot already carries.
|
|
34
|
+
*/
|
|
35
|
+
export declare function forkModelSnapshot(snapshot: Model): Model;
|
|
30
36
|
/**
|
|
31
37
|
* Receive a Model at `seat` (the place the caller wrote it, as every refusal names it; `what` is how the sentence names the value — a
|
|
32
38
|
* Model object written there, or the catalog entry a word resolved to): its frozen snapshot, or the coded refusal. A snapshot comes
|
|
@@ -35,6 +41,12 @@ export declare function modelOriginOf(model: Model): Model;
|
|
|
35
41
|
* `not_a_model_ref`; a retired member — `config.deps_retired_key` (its own sentence); a member outside the contract — `not_a_model_ref`
|
|
36
42
|
* (a provider's own parameters belong in `Model.params`); an `id` that is not a non-empty string or an `api` that is not a string —
|
|
37
43
|
* `not_a_model_ref`, naming the member; a `defaultThinking` that is present but not one of the seven tiers — `not_a_model_ref`, naming
|
|
38
|
-
* the member.
|
|
44
|
+
* the member; a `fallbacks` that is present but not a list of non-empty strings — `not_a_model_ref`, naming the member.
|
|
45
|
+
*
|
|
46
|
+
* `fallbacks` is a CATALOG member: its words are resolved by the catalog door over the catalog it receives
|
|
47
|
+
* (`model-fallbacks.ts`), so only the catalog door's own receipt (`catalogEntry`: a catalog entry, a tier's model object) takes a
|
|
48
|
+
* Model carrying it. Received anywhere else (a task's model object, a role's model object, an entry of a catalog the door did not
|
|
49
|
+
* receive) it is refused, `config.model_fallback_invalid`: a chain nothing resolved would be a declaration nothing walks. A snapshot
|
|
50
|
+
* comes back as itself either way — one carrying `fallbacks` was minted by the catalog door.
|
|
39
51
|
*/
|
|
40
|
-
export declare function receiveModel(value: unknown, seat: string, what?: string, note?: string): Model;
|
|
52
|
+
export declare function receiveModel(value: unknown, seat: string, what?: string, note?: string, catalogEntry?: boolean): Model;
|
|
@@ -3,6 +3,7 @@ import { isThinkingLevel, THINKING_LEVELS } from "../brain/reasoning.js";
|
|
|
3
3
|
import { describeFault, receive } from "./mods/kernel/receive.js";
|
|
4
4
|
import { DECLARATION_RECEIPT_MODE } from "./own-property-receipt.js";
|
|
5
5
|
import { assertNoRetiredKeys, RETIRED_MODEL_KEYS } from "./retired-keys.js";
|
|
6
|
+
import { modelFallbackRefusal } from "./model-fallbacks.js";
|
|
6
7
|
export function modelBindingRefusal(field, reason, message) {
|
|
7
8
|
const e = new Error(message);
|
|
8
9
|
e.code = "config.unknown_role";
|
|
@@ -30,6 +31,7 @@ const MODEL_MEMBER_TABLE = {
|
|
|
30
31
|
baseUrl: true,
|
|
31
32
|
reasoning: true,
|
|
32
33
|
defaultThinking: true,
|
|
34
|
+
fallbacks: true,
|
|
33
35
|
thinkingLevelMap: true,
|
|
34
36
|
input: true,
|
|
35
37
|
cost: true,
|
|
@@ -55,6 +57,14 @@ export function isModelSnapshot(value) {
|
|
|
55
57
|
export function modelOriginOf(model) {
|
|
56
58
|
return ORIGIN.get(model)?.origin ?? model;
|
|
57
59
|
}
|
|
60
|
+
export function forkModelSnapshot(snapshot) {
|
|
61
|
+
const fork = Object.freeze(Object.create(Object.getPrototypeOf(snapshot), Object.getOwnPropertyDescriptors(snapshot)));
|
|
62
|
+
MINTED.add(fork);
|
|
63
|
+
const origin = ORIGIN.get(snapshot);
|
|
64
|
+
if (origin !== undefined)
|
|
65
|
+
ORIGIN.set(fork, origin);
|
|
66
|
+
return fork;
|
|
67
|
+
}
|
|
58
68
|
function unreadableModelRefusal(seat, what, note, fault) {
|
|
59
69
|
const how = fault.path.length > 0
|
|
60
70
|
? describeFault(fault)
|
|
@@ -63,9 +73,16 @@ function unreadableModelRefusal(seat, what, note, fault) {
|
|
|
63
73
|
: "an object of another prototype (a class instance, an `Object.create(…)` value): a Model is a plain record, its members its own";
|
|
64
74
|
return modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} that could not be read as plain data — ${how}.${note}`);
|
|
65
75
|
}
|
|
66
|
-
export function receiveModel(value, seat, what = "a Model object", note = "") {
|
|
76
|
+
export function receiveModel(value, seat, what = "a Model object", note = "", catalogEntry = false) {
|
|
67
77
|
if (isModelSnapshot(value))
|
|
68
78
|
return value;
|
|
79
|
+
const model = receivedModel(value, seat, what, note);
|
|
80
|
+
if (!catalogEntry && model.fallbacks !== undefined) {
|
|
81
|
+
throw modelFallbackRefusal(seat, `${seat} is ${what} carrying \`fallbacks\`, which only a catalog entry declares — the catalog door (RunnerDeps.models / swapDeps) resolves the words over the catalog it receives. Declare the chain on the catalog entry and name it by its word.${note}`);
|
|
82
|
+
}
|
|
83
|
+
return model;
|
|
84
|
+
}
|
|
85
|
+
function receivedModel(value, seat, what, note) {
|
|
69
86
|
if (typeof value !== "object" || value === null || isList(value)) {
|
|
70
87
|
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} that is ${bindingShown(value)}, not a Model — a Model is a plain record carrying a non-empty string \`id\` and a string \`api\`.${note}`);
|
|
71
88
|
}
|
|
@@ -104,6 +121,10 @@ function judgeModelCopy(copy, seat, what, note) {
|
|
|
104
121
|
if (defaultThinking !== undefined && !isThinkingLevel(defaultThinking)) {
|
|
105
122
|
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`defaultThinking\` is ${bindingShown(defaultThinking)} — a model's default thinking level is one of ${THINKING_LEVELS.join(", ")} ("off" spells thinking off), or absent for no default.${note}`);
|
|
106
123
|
}
|
|
124
|
+
const fallbacks = copy["fallbacks"];
|
|
125
|
+
if (fallbacks !== undefined && (!isList(fallbacks) || !fallbacks.every((w) => typeof w === "string" && w !== ""))) {
|
|
126
|
+
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`fallbacks\` is ${bindingShown(fallbacks)} — a model's fallbacks are a list of catalog words (non-empty strings), or absent for none.${note}`);
|
|
127
|
+
}
|
|
107
128
|
}
|
|
108
129
|
function sameData(a, b, top = false, compared = new Map()) {
|
|
109
130
|
if (Object.is(a, b))
|
|
@@ -94,7 +94,7 @@ export interface Brain {
|
|
|
94
94
|
* it would target — WITHOUT sending anything. `perModelAuth` is the caller's already-resolved
|
|
95
95
|
* per-model auth (the `getApiKeyAndHeaders` result), so a resolution seat can pre-flight the exact
|
|
96
96
|
* request it is about to make. First-party brains implement it against their own config; the
|
|
97
|
-
* decorators (routing/failover/
|
|
97
|
+
* decorators (routing/failover/circuit-breaker) and the engine's model lane re-dispatch it the way their `stream`
|
|
98
98
|
* would. `undefined` = this brain cannot judge (a custom brain without the face) — callers must
|
|
99
99
|
* treat that as "no judgment", never as OK or as broken. A refusal is an `ok: false` verdict, never a
|
|
100
100
|
* throw (the first-party faces include the per-call key handed beside its lane's own key header,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* registration form types a handler by it. Its keys are the event table's `classic.*` rows that carry a station — the key
|
|
5
5
|
* set is held to that table.
|
|
6
6
|
*/
|
|
7
|
-
import type { PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, SessionEndEvent, SessionStartEvent, StopEvent, StopFailureEvent, StopHookResult, SubagentStartEvent, SubagentStartResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
|
|
7
|
+
import type { MessageDisplayEvent, MessageDisplayResult, PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, SessionEndEvent, SessionStartEvent, StopEvent, StopFailureEvent, StopHookResult, SubagentStartEvent, SubagentStartResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
|
|
8
8
|
import type { MappedOn, ModRegistration } from "./kernel/index.js";
|
|
9
9
|
import type { EngineDollar } from "./dollar.js";
|
|
10
10
|
/** The answer of an event whose station reads none (an observation event): a chain handler passes `next(e)`'s on. */
|
|
@@ -67,6 +67,10 @@ export type ClassicEventMap = {
|
|
|
67
67
|
readonly e: PermissionDeniedPayload;
|
|
68
68
|
readonly answer: ObservedAnswer;
|
|
69
69
|
};
|
|
70
|
+
readonly "classic.MessageDisplay": {
|
|
71
|
+
readonly e: MessageDisplayEvent;
|
|
72
|
+
readonly answer: MessageDisplayResult;
|
|
73
|
+
};
|
|
70
74
|
};
|
|
71
75
|
/** A `classic.*` event a station raises. */
|
|
72
76
|
export type ClassicEventName = keyof ClassicEventMap;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { AgentMessage, ExecutionEnv } from "../../internal/harness-types.js";
|
|
7
7
|
import type { Context, Message, Usage } from "../../internal/llm.js";
|
|
8
8
|
import type { CompactOutcome } from "../task-event.js";
|
|
9
|
-
import type
|
|
9
|
+
import { type ModDollarBase, type ModMethodBottoms, type ModTimer } from "./kernel/index.js";
|
|
10
10
|
import type { ContextOccupancy } from "./lifecycle-stations.js";
|
|
11
11
|
/** `$.process.run`'s default command timeout (CC). */
|
|
12
12
|
export declare const PROCESS_RUN_DEFAULT_TIMEOUT_MS = 30000;
|
|
@@ -66,6 +66,11 @@ export interface ModSeatView {
|
|
|
66
66
|
usage(): SessionUsage;
|
|
67
67
|
version(): SessionVersion;
|
|
68
68
|
};
|
|
69
|
+
readonly turn: {
|
|
70
|
+
/** End the leg's running model turn `turn` for registration `by`, judged and cut in one synchronous step
|
|
71
|
+
* ({@link TurnAbortVerdict}). */
|
|
72
|
+
abort(turn: number, by: string): TurnAbortVerdict;
|
|
73
|
+
};
|
|
69
74
|
/** The deployment clock (`RunnerDeps.now`). */
|
|
70
75
|
now(): number;
|
|
71
76
|
tools(): readonly string[];
|
|
@@ -80,6 +85,23 @@ export interface SessionUsage {
|
|
|
80
85
|
export interface SessionVersion {
|
|
81
86
|
readonly version: string;
|
|
82
87
|
}
|
|
88
|
+
/** What the leg found for a `$.turn.abort`: it cut the running turn; no model request is running; the request running
|
|
89
|
+
* is another turn's (`running`, its number); or that turn is already ending. */
|
|
90
|
+
export type TurnAbortVerdict = {
|
|
91
|
+
readonly kind: "cut";
|
|
92
|
+
} | {
|
|
93
|
+
readonly kind: "none";
|
|
94
|
+
} | {
|
|
95
|
+
readonly kind: "not_running";
|
|
96
|
+
readonly running: number;
|
|
97
|
+
} | {
|
|
98
|
+
readonly kind: "ending";
|
|
99
|
+
};
|
|
100
|
+
/** The leg's `$.turn.abort` seat, minted with the leg's facade and filled by the run once its turn count exists (unfilled
|
|
101
|
+
* ⇒ no model request is running). */
|
|
102
|
+
export interface TurnAbortRef {
|
|
103
|
+
seat?: (turn: number, by: string) => TurnAbortVerdict;
|
|
104
|
+
}
|
|
83
105
|
export interface ProcessRunResult {
|
|
84
106
|
readonly stdout: string;
|
|
85
107
|
readonly stderr: string;
|
|
@@ -153,11 +175,30 @@ export interface EngineDollar extends ModDollarBase {
|
|
|
153
175
|
readonly text: string;
|
|
154
176
|
}): Promise<PromptSubmitAnswer>;
|
|
155
177
|
};
|
|
178
|
+
readonly turn: {
|
|
179
|
+
/** `$.turn.abort({ turn })`: end this leg's running model turn — `turn` is the number `turn.start` carried. The turn
|
|
180
|
+
* settles and the run goes on at its ordinary boundary (queued input, else the stop gate); a call that finds no
|
|
181
|
+
* request running, another turn running, or the turn already ending rejects, saying which. */
|
|
182
|
+
abort(args: {
|
|
183
|
+
readonly turn: number;
|
|
184
|
+
}): Promise<void>;
|
|
185
|
+
};
|
|
156
186
|
readonly clock: {
|
|
157
187
|
now(): Promise<number>;
|
|
158
188
|
sleep(args: {
|
|
159
189
|
ms: number;
|
|
160
190
|
}): Promise<void>;
|
|
191
|
+
/** `$.clock.after({ ms }, fn)`: run `fn` once, `ms` from now — the handle at once, the wait one dispatch of `clock.after`.
|
|
192
|
+
* It lives within the leg: cancelled when the leg stops, or by `cancel()`. */
|
|
193
|
+
after(args: {
|
|
194
|
+
ms: number;
|
|
195
|
+
}, fn: () => unknown): ModTimer;
|
|
196
|
+
/** `$.clock.every({ ms }, fn)`: run `fn` every `ms` (at least 1) — each wait one dispatch of `clock.every`, a refused one
|
|
197
|
+
* stopping it; a throw of `fn` is reported and the timer runs on. It lives within the leg: cancelled when the leg stops,
|
|
198
|
+
* or by `cancel()`. */
|
|
199
|
+
every(args: {
|
|
200
|
+
ms: number;
|
|
201
|
+
}, fn: () => unknown): ModTimer;
|
|
161
202
|
};
|
|
162
203
|
readonly tool: {
|
|
163
204
|
list(): Promise<readonly string[]>;
|
|
@@ -213,9 +254,13 @@ export type SessionSendAnswer = {
|
|
|
213
254
|
readonly isDelivered: false;
|
|
214
255
|
readonly reason: string;
|
|
215
256
|
};
|
|
216
|
-
/** What `$.prompt.submit` answers when the input is taken: the text that entered,
|
|
257
|
+
/** What `$.prompt.submit` answers when the input is taken: the text that entered, the answer another registration's prompt
|
|
258
|
+
* screen gave it (`reply`: it entered, and the turn it opens is that answer — no model is asked), or why it did not
|
|
259
|
+
* (returned, not thrown). */
|
|
217
260
|
export type PromptSubmitAnswer = {
|
|
218
261
|
readonly text: string;
|
|
262
|
+
} | {
|
|
263
|
+
readonly reply: string;
|
|
219
264
|
} | {
|
|
220
265
|
readonly drop: string;
|
|
221
266
|
};
|
package/dist/core/mods/dollar.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shellQuote } from "../../tools/fs/search.js";
|
|
2
|
+
import { clockMsRefusal } from "./kernel/index.js";
|
|
2
3
|
export const PROCESS_RUN_DEFAULT_TIMEOUT_MS = 30_000;
|
|
3
4
|
export const PROCESS_RUN_MAX_TIMEOUT_MS = 600_000;
|
|
4
5
|
export const MODEL_COMPLETE_DEFAULT_MAX_TOKENS = 1_024;
|
|
@@ -105,11 +106,12 @@ async function modelComplete(view, args, ctx) {
|
|
|
105
106
|
view.book({ model: reply.model, ...(reply.usage !== undefined ? { usage: reply.usage } : {}) });
|
|
106
107
|
return reply;
|
|
107
108
|
}
|
|
108
|
-
function sleep(args, ctx) {
|
|
109
|
-
only(args,
|
|
109
|
+
function sleep(args, ctx, event) {
|
|
110
|
+
only(args, event, ["ms"]);
|
|
110
111
|
const ms = args["ms"];
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
const why = clockMsRefusal(ms);
|
|
113
|
+
if (why !== undefined || typeof ms !== "number")
|
|
114
|
+
throw refuse(event, why ?? "takes { ms }");
|
|
113
115
|
return new Promise((resolve, reject) => {
|
|
114
116
|
if (ctx.signal.aborted)
|
|
115
117
|
return reject(ctx.signal.reason);
|
|
@@ -141,6 +143,24 @@ function sessionMessages(view, args) {
|
|
|
141
143
|
throw refuse("session.messages", `takes agentId, a non-empty string (got ${typeof agentId === "string" ? "an empty string" : typeof agentId})`);
|
|
142
144
|
return view.session.agentMessages(agentId).then((rows) => Object.freeze(rows.slice(-SESSION_MESSAGES_MAX).map(detachedMessage)));
|
|
143
145
|
}
|
|
146
|
+
function turnAbort(view, args, ctx) {
|
|
147
|
+
only(args, "turn.abort", ["turn"]);
|
|
148
|
+
const turn = args["turn"];
|
|
149
|
+
if (typeof turn !== "number" || !Number.isSafeInteger(turn) || turn < 1)
|
|
150
|
+
throw refuse("turn.abort", "takes { turn } (the number turn.start carried)");
|
|
151
|
+
const said = (why) => new Error(`${ctx.origin.plugin}: $.turn.abort: ${why}`);
|
|
152
|
+
const v = view.turn.abort(turn, ctx.origin.plugin);
|
|
153
|
+
switch (v.kind) {
|
|
154
|
+
case "cut":
|
|
155
|
+
return undefined;
|
|
156
|
+
case "none":
|
|
157
|
+
throw said(`no model request is running (asked for ${turn})`);
|
|
158
|
+
case "not_running":
|
|
159
|
+
throw said(`${turn} is not the running turn (${v.running}); a hook ends the turn turn.start told it about`);
|
|
160
|
+
case "ending":
|
|
161
|
+
throw said(`${turn} is already ending`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
144
164
|
const read = (event, f) => (args) => {
|
|
145
165
|
only(args, event, []);
|
|
146
166
|
return f();
|
|
@@ -159,7 +179,10 @@ export function engineMethodBottoms(view) {
|
|
|
159
179
|
"session.usage": run(read("session.usage", () => view.session.usage())),
|
|
160
180
|
"session.version": run(read("session.version", () => view.session.version())),
|
|
161
181
|
"clock.now": run(read("clock.now", () => view.now())),
|
|
162
|
-
"clock.sleep": run((args, ctx) => sleep(args, ctx)),
|
|
182
|
+
"clock.sleep": run((args, ctx) => sleep(args, ctx, "clock.sleep")),
|
|
183
|
+
"clock.after": run((args, ctx) => sleep(args, ctx, "clock.after")),
|
|
184
|
+
"clock.every": run((args, ctx) => sleep(args, ctx, "clock.every")),
|
|
185
|
+
"turn.abort": run((args, ctx) => turnAbort(view, args, ctx)),
|
|
163
186
|
"tool.list": run(read("tool.list", () => Object.freeze([...view.tools()]))),
|
|
164
187
|
"agent.list": run(read("agent.list", () => Object.freeze([...view.agents()]))),
|
|
165
188
|
});
|
|
@@ -12,6 +12,12 @@ export declare const RUNAWAY_AFTER_MS = 5000;
|
|
|
12
12
|
export declare const POST_ABORT_GRACE_MS = 1000;
|
|
13
13
|
/** `setTimeout`'s ceiling; above it the platform clamps to about 1 ms. */
|
|
14
14
|
export declare const MAX_TIMER_MS = 2147483647;
|
|
15
|
+
/**
|
|
16
|
+
* The one judge of a clock method's `ms` (`$.clock.sleep`, `$.clock.after`, `$.clock.every`): undefined when it is a
|
|
17
|
+
* finite number of milliseconds from 0 to {@link MAX_TIMER_MS}, else why not. Above the ceiling the platform would fire
|
|
18
|
+
* after about 1 ms — refused, never clamped.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clockMsRefusal(ms: unknown): string | undefined;
|
|
15
21
|
/** What `next.budget` reads: the handler's budget and what is left of it. */
|
|
16
22
|
export interface ModBudgetReading {
|
|
17
23
|
readonly ms: number;
|
|
@@ -3,6 +3,12 @@ export const CATCH_BUDGET_MS = 1_000;
|
|
|
3
3
|
export const RUNAWAY_AFTER_MS = 5_000;
|
|
4
4
|
export const POST_ABORT_GRACE_MS = 1_000;
|
|
5
5
|
export const MAX_TIMER_MS = 2_147_483_647;
|
|
6
|
+
export function clockMsRefusal(ms) {
|
|
7
|
+
if (typeof ms === "number" && Number.isFinite(ms) && ms >= 0 && ms <= MAX_TIMER_MS)
|
|
8
|
+
return undefined;
|
|
9
|
+
const got = typeof ms === "number" ? String(ms) : typeof ms;
|
|
10
|
+
return `takes { ms }, a non-negative number of milliseconds no greater than ${MAX_TIMER_MS} (got ${got})`;
|
|
11
|
+
}
|
|
6
12
|
export function resolveModBudgetMs(supplied, report, name) {
|
|
7
13
|
if (supplied === undefined)
|
|
8
14
|
return DEFAULT_MOD_BUDGET_MS;
|
|
@@ -53,10 +53,20 @@ export type ModDispatchOutcome = {
|
|
|
53
53
|
readonly skipped: readonly ModSkip[];
|
|
54
54
|
readonly bottomStarted?: true;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
56
|
+
/** A cancelled dispatch, with what it had reached: `skipped` — the handlers skipped before the cancel (the same record an
|
|
57
|
+
* answered or a failed dispatch carries); `lastAnswer` — the answer the highest handler whose `next` had answered was handed
|
|
58
|
+
* (absent when no handler's `next` had answered), with the extension it came from, as `answeredBy` names it on an answered
|
|
59
|
+
* dispatch. A station that shows what stands of a cancelled chain reads the cancel as a skip of every handler that had not
|
|
60
|
+
* answered — a handler skipped after its `next` answered keeps that answer — and a station that takes nothing from a cancel
|
|
61
|
+
* reads its kind alone. `bottomStarted`: the chain's bottom had started when the dispatch was cancelled — on an effect event,
|
|
62
|
+
* what it did is not known from here. */
|
|
58
63
|
| {
|
|
59
64
|
readonly kind: "aborted";
|
|
65
|
+
readonly skipped: readonly ModSkip[];
|
|
66
|
+
readonly lastAnswer?: {
|
|
67
|
+
readonly answer: unknown;
|
|
68
|
+
readonly answeredBy?: string;
|
|
69
|
+
};
|
|
60
70
|
readonly bottomStarted?: true;
|
|
61
71
|
};
|
|
62
72
|
/** What a participant filter sees of one mounted handler: its registration, that registration's seat, and whether it only observes. */
|
|
@@ -117,7 +127,18 @@ export interface ModBusInput<D extends ModDollarBase = ModDollarBase> {
|
|
|
117
127
|
/** The host's Proxy probe: a Proxy a handler answers or hands on is refused before any of its traps runs (a violation
|
|
118
128
|
* of the site). Absent ⇒ a Proxy is read like any object, its traps run by the copy. */
|
|
119
129
|
readonly isProxy?: ProxyProbe;
|
|
130
|
+
/** Cancels the admission (`plugin.register`'s dispatches) — nothing after it. */
|
|
120
131
|
readonly signal?: AbortSignal;
|
|
132
|
+
/**
|
|
133
|
+
* The bus's lifetime (absent ⇒ it lives as long as its host keeps it). What a registration starts that outlives its
|
|
134
|
+
* handler's own run lives only within it: a timer (`$.clock.after`, `$.clock.every`) is cancelled when it aborts, and a
|
|
135
|
+
* `$` call made after the handler settled is made under it — and refused once it has aborted.
|
|
136
|
+
*/
|
|
137
|
+
readonly lifetime?: AbortSignal;
|
|
138
|
+
}
|
|
139
|
+
/** What `$.clock.after` and `$.clock.every` hand back: `cancel()` stops the timer (no tick or callback after it; a second call does nothing). */
|
|
140
|
+
export interface ModTimer {
|
|
141
|
+
cancel(): void;
|
|
121
142
|
}
|
|
122
143
|
/**
|
|
123
144
|
* Screen both seats, then admit registrations one by one in run order: each is put to the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CATCH_BUDGET_MS, createSelfBudget, POST_ABORT_GRACE_MS, RUNAWAY_AFTER_MS, unrefTimer, watchRunaway } from "./budget.js";
|
|
1
|
+
import { CATCH_BUDGET_MS, clockMsRefusal, createSelfBudget, POST_ABORT_GRACE_MS, RUNAWAY_AFTER_MS, unrefTimer, watchRunaway } from "./budget.js";
|
|
2
2
|
import { expandOnSide, failureRefuses, isModEventName, MOD_SEATS, nextToRefusal, stationOn } from "./events.js";
|
|
3
3
|
import { ENGINE_ORIGIN, modsInvalid, screenModSeats, } from "./registration.js";
|
|
4
4
|
import { answerUpward, answerViolation, detachedCopy, engineObjectsOnce, handedOn, handOnViolation, matcherMatches, matcherViolation, methodAnswerViolation, NEXT_IN_FLIGHT, receiveAnswer, receiveEvent, receivePayload, sealedObjects, } from "./site-rules.js";
|
|
@@ -13,7 +13,7 @@ export async function admitMods(input) {
|
|
|
13
13
|
const mounted = [];
|
|
14
14
|
const records = [];
|
|
15
15
|
const describe = safeDescribe(input.describeThrown);
|
|
16
|
-
const bus = createBus(input.side, mounted, input.bottoms, input.entries ?? {}, report, records, describe, input.isProxy);
|
|
16
|
+
const bus = createBus(input.side, mounted, input.bottoms, input.entries ?? {}, report, records, describe, input.isProxy, input.lifetime);
|
|
17
17
|
const admitted = Object.freeze({ admitted: true });
|
|
18
18
|
for (const cand of screened) {
|
|
19
19
|
if (input.signal?.aborted === true)
|
|
@@ -177,7 +177,14 @@ function handlerOptions(opts) {
|
|
|
177
177
|
}
|
|
178
178
|
const HA = "skipped; what is below it ran in its place";
|
|
179
179
|
const MA = "skipped; its last next() run's result stands";
|
|
180
|
-
function createBus(side, mounted, bottoms, entries, report, records, describe, isProxy) {
|
|
180
|
+
function createBus(side, mounted, bottoms, entries, report, records, describe, isProxy, lifetime) {
|
|
181
|
+
const life = lifetime ?? new AbortController().signal;
|
|
182
|
+
const timers = new Set();
|
|
183
|
+
life.addEventListener("abort", () => {
|
|
184
|
+
for (const t of timers)
|
|
185
|
+
t.abort(life.reason);
|
|
186
|
+
timers.clear();
|
|
187
|
+
}, { once: true });
|
|
181
188
|
const reaches = new Map();
|
|
182
189
|
for (const name of Object.keys(bottoms)) {
|
|
183
190
|
if (!isModEventName(name))
|
|
@@ -265,30 +272,45 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
265
272
|
throw new Error(`${caller.origin.plugin}: $.${event}: ${deny}`);
|
|
266
273
|
return typeof answer === "object" && answer !== null ? Reflect.get(answer, "value") : undefined;
|
|
267
274
|
}
|
|
268
|
-
function dollarFor(reg, frames, budget, signal, engines) {
|
|
275
|
+
function dollarFor(reg, frames, budget, signal, engines, running) {
|
|
269
276
|
const origin = Object.freeze({ plugin: reg.name, tier: reg.tier });
|
|
270
|
-
const
|
|
277
|
+
const ownFrame = Object.freeze({ kind: "dollar", plugin: reg.name });
|
|
278
|
+
const held = Object.freeze({ frames: Object.freeze([...frames, ownFrame]), origin, signal });
|
|
279
|
+
const later = Object.freeze({ frames: Object.freeze([ownFrame]), origin, signal: life });
|
|
271
280
|
const namespaces = new Map();
|
|
272
281
|
for (const event of new Set([...reaches.keys(), ...reg.callsBound])) {
|
|
273
282
|
const dot = event.indexOf(".");
|
|
274
283
|
const ns = namespaces.get(event.slice(0, dot)) ?? {};
|
|
275
284
|
namespaces.set(event.slice(0, dot), ns);
|
|
276
|
-
|
|
285
|
+
const reachOf = () => {
|
|
277
286
|
if (!reg.callsBound.has(event))
|
|
278
287
|
throw new Error(`${reg.name}: $.${event}: not declared in uses.calls`);
|
|
279
288
|
const reach = reaches.get(event);
|
|
280
289
|
if (reach === undefined)
|
|
281
290
|
throw new Error(`${reg.name}: $.${event}: not callable on the ${side} bus in this version`);
|
|
291
|
+
return reach;
|
|
292
|
+
};
|
|
293
|
+
if (stationOn(event, side)?.method?.timer !== undefined) {
|
|
294
|
+
ns[event.slice(dot + 1)] = (args, fn) => startTimer(reg, event, reachOf(), args, fn, origin, later.frames, engines);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
ns[event.slice(dot + 1)] = async (args) => {
|
|
298
|
+
const reach = reachOf();
|
|
282
299
|
const received = receivePayload(args === undefined ? {} : args, isProxy, engines());
|
|
283
300
|
if ("refusal" in received)
|
|
284
301
|
throw new TypeError(`${reg.name}: $.${event}: takes one object — ${received.refusal}`);
|
|
285
|
-
|
|
302
|
+
const now = running.now;
|
|
303
|
+
if (!now && life.aborted)
|
|
304
|
+
throw lifeEnded(reg, event);
|
|
305
|
+
const caller = now ? held : later;
|
|
306
|
+
const pauses = now && reach.pauses;
|
|
307
|
+
if (pauses)
|
|
286
308
|
budget.pause();
|
|
287
309
|
try {
|
|
288
310
|
return reach.kind === "method" ? await callMethod(event, reach, received.payload, caller) : await reach.entry(received.payload, caller);
|
|
289
311
|
}
|
|
290
312
|
finally {
|
|
291
|
-
if (
|
|
313
|
+
if (pauses)
|
|
292
314
|
budget.resume();
|
|
293
315
|
}
|
|
294
316
|
};
|
|
@@ -298,6 +320,68 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
298
320
|
out[ns] = Object.freeze(fns);
|
|
299
321
|
return Object.freeze({ ...out, plugin: Object.freeze({ ...(namespaces.get("plugin") ?? {}), name: reg.name }) });
|
|
300
322
|
}
|
|
323
|
+
function lifeEnded(reg, event) {
|
|
324
|
+
const err = new Error(`${reg.name}: $.${event}: the leg this registration runs in has stopped (or its bus was admitted outside any leg) — ` +
|
|
325
|
+
`a timer, and a $ call made after its handler settled, run only while its leg runs`);
|
|
326
|
+
report(err);
|
|
327
|
+
return err;
|
|
328
|
+
}
|
|
329
|
+
function startTimer(reg, event, reach, args, fn, origin, frames, engines) {
|
|
330
|
+
const repeats = reach.kind === "method" ? reach.st.method?.timer?.repeats : undefined;
|
|
331
|
+
if (reach.kind !== "method" || repeats === undefined)
|
|
332
|
+
throw new Error(`${reg.name}: $.${event}: not a timer on the ${side} bus in this version`);
|
|
333
|
+
const received = receivePayload(args === undefined ? {} : args, isProxy, engines());
|
|
334
|
+
if ("refusal" in received)
|
|
335
|
+
throw new TypeError(`${reg.name}: $.${event}: takes { ms } and a callback — ${received.refusal}`);
|
|
336
|
+
const ms = received.payload["ms"];
|
|
337
|
+
const why = clockMsRefusal(ms);
|
|
338
|
+
if (why !== undefined || typeof ms !== "number")
|
|
339
|
+
throw new TypeError(`${reg.name}: $.${event}: ${why ?? "takes { ms }"}`);
|
|
340
|
+
if (typeof fn !== "function")
|
|
341
|
+
throw new TypeError(`${reg.name}: $.${event}: takes a callback function after { ms }`);
|
|
342
|
+
if (life.aborted)
|
|
343
|
+
throw lifeEnded(reg, event);
|
|
344
|
+
const payload = repeats ? Object.freeze({ ...received.payload, ms: Math.max(1, ms) }) : received.payload;
|
|
345
|
+
const ac = new AbortController();
|
|
346
|
+
timers.add(ac);
|
|
347
|
+
const ctx = Object.freeze({ frames, origin, signal: ac.signal });
|
|
348
|
+
const end = (reason) => {
|
|
349
|
+
timers.delete(ac);
|
|
350
|
+
if (!ac.signal.aborted)
|
|
351
|
+
ac.abort(reason);
|
|
352
|
+
};
|
|
353
|
+
const tick = () => {
|
|
354
|
+
if (ac.signal.aborted)
|
|
355
|
+
return;
|
|
356
|
+
callMethod(event, reach, payload, ctx).then(() => {
|
|
357
|
+
if (ac.signal.aborted)
|
|
358
|
+
return;
|
|
359
|
+
if (!repeats)
|
|
360
|
+
end(new Error(`${reg.name}: $.${event}: fired`));
|
|
361
|
+
invokeNow(() => Reflect.apply(fn, undefined, [])).catch((err) => {
|
|
362
|
+
report(new Error(`${reg.name}: $.${event}: its callback threw ${describe(err)}${repeats ? " — the timer runs on" : ""}`));
|
|
363
|
+
});
|
|
364
|
+
if (repeats)
|
|
365
|
+
setTimeout(tick, 0);
|
|
366
|
+
}, (err) => {
|
|
367
|
+
if (ac.signal.aborted)
|
|
368
|
+
return;
|
|
369
|
+
end(err);
|
|
370
|
+
report(new Error(`${reg.name}: $.${event}: a tick was refused (${describe(err)}) — the timer stopped`));
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
setTimeout(tick, 0);
|
|
374
|
+
return Object.freeze({ cancel: () => end(new Error(`${reg.name}: $.${event}: cancelled`)) });
|
|
375
|
+
}
|
|
376
|
+
function runWithDollar(reg, frames, budget, signal, engines, run) {
|
|
377
|
+
const running = { now: true };
|
|
378
|
+
const p = invokeNow(() => run(dollarFor(reg, frames, budget, signal, engines, running)));
|
|
379
|
+
const settle = () => {
|
|
380
|
+
running.now = false;
|
|
381
|
+
};
|
|
382
|
+
p.then(settle, settle);
|
|
383
|
+
return p;
|
|
384
|
+
}
|
|
301
385
|
function runDispatch(event, st, e0, options) {
|
|
302
386
|
const frames = options.frames ?? [];
|
|
303
387
|
const origin = options.origin ?? ENGINE_ORIGIN;
|
|
@@ -334,7 +418,11 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
334
418
|
rejectOut = rej;
|
|
335
419
|
});
|
|
336
420
|
const signal = options.signal;
|
|
337
|
-
|
|
421
|
+
let reached;
|
|
422
|
+
const aborted = () => {
|
|
423
|
+
const last = reached === undefined ? undefined : Object.freeze({ answer: reached.answer, ...(producers.has(reached.answer) ? { answeredBy: producers.get(reached.answer) } : {}) });
|
|
424
|
+
return { kind: "aborted", skipped: Object.freeze([...skipped]), ...(last !== undefined ? { lastAnswer: last } : {}), ...(bottomStarted ? { bottomStarted: true } : {}) };
|
|
425
|
+
};
|
|
338
426
|
const onAbort = () => {
|
|
339
427
|
if (settled)
|
|
340
428
|
return;
|
|
@@ -451,6 +539,8 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
451
539
|
run.then((v) => {
|
|
452
540
|
state.lastValue = { v };
|
|
453
541
|
state.answers.push(v);
|
|
542
|
+
if (reached === undefined || i < reached.at)
|
|
543
|
+
reached = { at: i, answer: v };
|
|
454
544
|
state.sealed = new Set([...(state.sealed ?? []), ...sealedObjects([v])]);
|
|
455
545
|
stopCounting();
|
|
456
546
|
}, (err) => {
|
|
@@ -541,8 +631,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
541
631
|
}
|
|
542
632
|
else {
|
|
543
633
|
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => descend(x, floors), to);
|
|
544
|
-
|
|
545
|
-
handlerP = invokeNow(() => h.fn($, e, next));
|
|
634
|
+
handlerP = runWithDollar(h.reg, myFrames, budget, ac.signal, engines, ($) => h.fn($, e, next));
|
|
546
635
|
try {
|
|
547
636
|
const raced = await Promise.race([handlerP, budget.expired]);
|
|
548
637
|
if (raced === "expired" && budget.isExpired())
|
|
@@ -651,7 +740,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
651
740
|
return why !== undefined ? Promise.reject(new Error(`${h.reg.name}: ${why}`)) : replay(x, [...floors, { from: h.reg.tier, to: tier }]);
|
|
652
741
|
}, { error, called: state.called });
|
|
653
742
|
try {
|
|
654
|
-
const raced = await Promise.race([
|
|
743
|
+
const raced = await Promise.race([runWithDollar(h.reg, myFrames, budget, ac.signal, engines, ($) => onCatch($, e, next)), budget.expired]);
|
|
655
744
|
if (raced === "expired" && budget.isExpired())
|
|
656
745
|
return { problem: `its .catch ran past its ${catchMs}ms budget` };
|
|
657
746
|
if (violated !== undefined)
|
|
@@ -684,7 +773,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
684
773
|
report(new Error(`${name}: ${event}: an observe handler returned a verdict — not adopted; an observe handler answers undefined`), "observational-hook-verdict-ignored");
|
|
685
774
|
};
|
|
686
775
|
try {
|
|
687
|
-
const raced = await Promise.race([
|
|
776
|
+
const raced = await Promise.race([runWithDollar(h.reg, myFrames, budget, ac.signal, engines, ($) => h.fn($, detachedCopy(e0), next)), budget.expired]);
|
|
688
777
|
if (raced === "expired" && budget.isExpired())
|
|
689
778
|
throw new Error(`ran past its ${budgetMs}ms budget`);
|
|
690
779
|
verdict(raced);
|
|
@@ -706,7 +795,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
706
795
|
called: false,
|
|
707
796
|
});
|
|
708
797
|
try {
|
|
709
|
-
const caught = await Promise.race([
|
|
798
|
+
const caught = await Promise.race([runWithDollar(h.reg, myFrames, catchBudget, cac.signal, engines, ($) => onCatch($, detachedCopy(e0), cnext)), catchBudget.expired]);
|
|
710
799
|
if (!(caught === "expired" && catchBudget.isExpired()))
|
|
711
800
|
verdict(caught);
|
|
712
801
|
}
|
|
@@ -726,7 +815,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
726
815
|
}
|
|
727
816
|
}
|
|
728
817
|
if (signal?.aborted === true && st.abort !== "grace") {
|
|
729
|
-
finish(
|
|
818
|
+
finish(aborted());
|
|
730
819
|
return out;
|
|
731
820
|
}
|
|
732
821
|
const root = [];
|