@sema-agent/core 7.54.1 → 7.56.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 +950 -0
- package/dist/agents/agent-transcript-tool.js +2 -1
- package/dist/agents/builtin-agents.d.ts +12 -14
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/cc-peer-directory.d.ts +36 -0
- package/dist/agents/cc-peer-directory.js +139 -0
- package/dist/agents/cc-peer-wire.d.ts +105 -0
- package/dist/agents/cc-peer-wire.js +98 -0
- package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
- package/dist/agents/cc-uds-peer-channel.js +457 -0
- package/dist/agents/child-model-seat.d.ts +0 -11
- package/dist/agents/child-model-seat.js +0 -3
- package/dist/agents/cross-session-envelope.d.ts +4 -1
- package/dist/agents/cross-session-envelope.js +8 -1
- package/dist/agents/cross-session-judge.d.ts +2 -2
- package/dist/agents/list-agents-tool.d.ts +3 -1
- package/dist/agents/list-agents-tool.js +9 -8
- package/dist/agents/observer.d.ts +4 -5
- package/dist/agents/observer.js +2 -1
- package/dist/agents/peer-admission.d.ts +6 -0
- package/dist/agents/peer-admission.js +4 -1
- package/dist/agents/peer-directory.d.ts +65 -13
- package/dist/agents/peer-directory.js +90 -25
- package/dist/agents/peer-notices.d.ts +1 -1
- package/dist/agents/peer-session-drain.d.ts +3 -1
- package/dist/agents/peer-session-drain.js +3 -2
- package/dist/agents/read-inbox-tool.js +2 -1
- package/dist/agents/repair-loop.js +2 -2
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/send-message-tool.d.ts +10 -0
- package/dist/agents/send-message-tool.js +37 -8
- package/dist/agents/subagent.d.ts +39 -82
- package/dist/agents/subagent.js +109 -106
- package/dist/agents/tool-filter.d.ts +31 -46
- package/dist/agents/tool-filter.js +13 -33
- package/dist/agents/verify.d.ts +6 -5
- package/dist/agents/verify.js +3 -3
- package/dist/brain/anthropic.js +43 -81
- package/dist/brain/errors.d.ts +15 -0
- package/dist/brain/errors.js +10 -0
- package/dist/brain/media-degrade.d.ts +18 -7
- package/dist/brain/media-degrade.js +13 -2
- package/dist/brain/model-capability.d.ts +37 -0
- package/dist/brain/model-capability.js +34 -0
- package/dist/brain/model-presets.d.ts +6 -12
- package/dist/brain/model-presets.js +1 -6
- package/dist/brain/open-responses.js +27 -35
- package/dist/brain/openai.js +30 -98
- package/dist/brain/provider-dialect.d.ts +39 -3
- package/dist/brain/provider-dialect.js +28 -0
- package/dist/brain/reasoning-request.d.ts +96 -0
- package/dist/brain/reasoning-request.js +174 -0
- package/dist/brain/reasoning.d.ts +12 -12
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/request-params.d.ts +62 -9
- package/dist/brain/request-params.js +42 -7
- package/dist/brain/retry.d.ts +1 -1
- package/dist/brain/route-adjudicator.d.ts +15 -0
- package/dist/brain/route-adjudicator.js +15 -0
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/stream-engine.js +6 -5
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +19 -13
- package/dist/core/advisor-verdict.d.ts +120 -0
- package/dist/core/advisor-verdict.js +92 -0
- package/dist/core/agent-definition.d.ts +17 -8
- package/dist/core/allow-entry.d.ts +69 -36
- package/dist/core/allow-entry.js +81 -52
- package/dist/core/allow-rule-shadow.d.ts +10 -3
- package/dist/core/approval-object.d.ts +2 -1
- package/dist/core/approval-object.js +6 -6
- package/dist/core/ask-origin.d.ts +127 -29
- package/dist/core/ask-origin.js +87 -25
- package/dist/core/ask-question.d.ts +51 -8
- package/dist/core/ask-question.js +12 -7
- package/dist/core/ask-unresolvable-notice.d.ts +8 -3
- package/dist/core/ask-unresolvable-notice.js +16 -2
- package/dist/core/auto-compaction.d.ts +11 -8
- package/dist/core/auto-compaction.js +4 -2
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/auto-mode-defaults.d.ts +8 -8
- package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
- package/dist/core/auto-mode-prompt.d.ts +1 -1
- package/dist/core/auto-mode.d.ts +17 -9
- package/dist/core/auto-mode.js +9 -6
- package/dist/core/background-agent-store.d.ts +3 -3
- package/dist/core/canonical-json.d.ts +1 -1
- package/dist/core/canonical-json.js +2 -2
- package/dist/core/checkpoint-generation.d.ts +53 -0
- package/dist/core/checkpoint-generation.js +35 -0
- package/dist/core/checkpoint-queries.d.ts +180 -0
- package/dist/core/checkpoint-queries.js +272 -0
- package/dist/core/checkpoint-requirements.d.ts +19 -4
- package/dist/core/checkpoint-requirements.js +8 -14
- package/dist/core/checkpoint-store.d.ts +165 -72
- package/dist/core/checkpoint-store.js +79 -82
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +3 -16
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/context-edit.d.ts +6 -7
- package/dist/core/cross-boundary-taint.d.ts +11 -4
- package/dist/core/cross-boundary-taint.js +3 -3
- package/dist/core/decision-receipt.d.ts +37 -3
- package/dist/core/decision-receipt.js +19 -19
- package/dist/core/delegation-not-started.d.ts +6 -0
- package/dist/core/delegation-not-started.js +17 -0
- package/dist/core/effective-path-target.d.ts +1 -1
- package/dist/core/engine-attestation.d.ts +93 -0
- package/dist/core/engine-attestation.js +70 -0
- package/dist/core/engine-capabilities.d.ts +4 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +45 -12
- package/dist/core/exec-output-tail.d.ts +1 -1
- package/dist/core/file-history-retention.d.ts +1 -1
- package/dist/core/file-history-store.d.ts +147 -21
- package/dist/core/file-history-store.js +58 -32
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -11
- package/dist/core/gate-lanes.js +81 -68
- package/dist/core/gate-outcome.d.ts +40 -6
- package/dist/core/gate-outcome.js +56 -0
- package/dist/core/governance-codes.d.ts +17 -3
- package/dist/core/governance-codes.js +16 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +21 -20
- package/dist/core/hooks.js +3 -1
- package/dist/core/host-floor.d.ts +128 -0
- package/dist/core/host-floor.js +206 -0
- package/dist/core/host-target.d.ts +84 -0
- package/dist/core/host-target.js +92 -0
- package/dist/core/image-downsample.d.ts +1 -1
- package/dist/core/lsp-diagnostics.d.ts +4 -4
- package/dist/core/lsp.d.ts +3 -3
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mcp-connection-pool.d.ts +18 -2
- package/dist/core/mcp-connection-pool.js +53 -6
- package/dist/core/mcp-failure.d.ts +23 -4
- package/dist/core/mcp-failure.js +26 -11
- package/dist/core/mcp-listing-drift.d.ts +10 -0
- package/dist/core/mcp-listing-drift.js +6 -0
- package/dist/core/mcp-server-link.d.ts +173 -0
- package/dist/core/mcp-server-link.js +127 -0
- package/dist/core/mcp-server-spec.d.ts +4 -2
- package/dist/core/mcp-session-end.d.ts +26 -0
- package/dist/core/mcp-session-end.js +29 -0
- package/dist/core/mcp-startup-request.d.ts +17 -0
- package/dist/core/mcp-startup-request.js +17 -0
- package/dist/core/mcp.d.ts +17 -13
- package/dist/core/mcp.js +240 -189
- package/dist/core/media-byte-cap.d.ts +1 -1
- package/dist/core/memory-engine/delegation-settlement.js +15 -24
- package/dist/core/memory-engine/engine.d.ts +9 -9
- package/dist/core/memory-engine/engine.js +4 -4
- package/dist/core/memory-engine/layout.d.ts +60 -8
- package/dist/core/memory-engine/layout.js +65 -6
- package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
- package/dist/core/memory-engine/tools.js +4 -1
- package/dist/core/mode-policy.d.ts +1 -1
- package/dist/core/model-seat.d.ts +10 -3
- package/dist/core/mods/classic-events.d.ts +67 -0
- package/dist/core/mods/classic-events.js +1 -0
- package/dist/core/mods/dollar.d.ts +13 -0
- package/dist/core/mods/extension-call.d.ts +31 -0
- package/dist/core/mods/extension-call.js +43 -0
- package/dist/core/mods/kernel/dispatch.d.ts +20 -3
- package/dist/core/mods/kernel/dispatch.js +140 -69
- package/dist/core/mods/kernel/events.d.ts +47 -11
- package/dist/core/mods/kernel/events.js +66 -42
- package/dist/core/mods/kernel/index.d.ts +4 -4
- package/dist/core/mods/kernel/index.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -5
- package/dist/core/mods/kernel/receive.js +290 -17
- package/dist/core/mods/kernel/registration.d.ts +33 -2
- package/dist/core/mods/kernel/registration.js +6 -7
- package/dist/core/mods/kernel/site-rules.d.ts +44 -16
- package/dist/core/mods/kernel/site-rules.js +24 -42
- package/dist/core/mods/spec-seats.d.ts +69 -0
- package/dist/core/mods/spec-seats.js +114 -0
- package/dist/core/mods/stations.d.ts +28 -8
- package/dist/core/mods/stations.js +29 -13
- package/dist/core/mods/tool-call.d.ts +79 -0
- package/dist/core/mods/tool-call.js +152 -0
- package/dist/core/namespaced-rule-name.d.ts +44 -24
- package/dist/core/namespaced-rule-name.js +50 -43
- package/dist/core/output-style.d.ts +1 -1
- package/dist/core/param-rule-reach.d.ts +15 -0
- package/dist/core/param-rule-reach.js +30 -0
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/pause-registry.d.ts +16 -5
- package/dist/core/pause-registry.js +6 -2
- package/dist/core/peer-channel.d.ts +70 -0
- package/dist/core/peer-channel.js +1 -0
- package/dist/core/permission-rule-consent.d.ts +30 -5
- package/dist/core/permission-rule-consent.js +147 -50
- package/dist/core/permission-rule-model.d.ts +245 -65
- package/dist/core/permission-rule-model.js +421 -107
- package/dist/core/permission-rule-org.d.ts +6 -2
- package/dist/core/permission-rule-org.js +7 -3
- package/dist/core/permission-rule-provider.d.ts +6 -2
- package/dist/core/permission-rule-provider.js +41 -11
- package/dist/core/permission-rule-store.d.ts +22 -26
- package/dist/core/permission-rule-store.js +12 -6
- package/dist/core/permission-rule-sync.d.ts +11 -2
- package/dist/core/permission-rule-sync.js +11 -3
- package/dist/core/permission-rule-syntax.d.ts +5 -4
- package/dist/core/permission-rule-syntax.js +2 -2
- package/dist/core/permission-rules.d.ts +53 -15
- package/dist/core/permission-rules.js +125 -100
- package/dist/core/persisted-rule-arms.d.ts +6 -4
- package/dist/core/persisted-rule-arms.js +10 -12
- package/dist/core/present-plan-tool.js +3 -1
- package/dist/core/principal-name.d.ts +20 -0
- package/dist/core/principal-name.js +22 -0
- package/dist/core/prompt-section-seat.js +4 -6
- package/dist/core/protocol-http-auth.d.ts +26 -5
- package/dist/core/protocol-http-auth.js +137 -4
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/read-only-shell-table.d.ts +1 -1
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +16 -0
- package/dist/core/retired-keys.js +16 -4
- package/dist/core/rewrite-rejudge.d.ts +60 -0
- package/dist/core/rewrite-rejudge.js +36 -0
- package/dist/core/roles.d.ts +34 -3
- package/dist/core/roles.js +66 -53
- package/dist/core/rule-lane-reads.d.ts +20 -15
- package/dist/core/rule-lane-reads.js +45 -17
- package/dist/core/rule-offer-read.d.ts +53 -0
- package/dist/core/rule-offer-read.js +146 -0
- package/dist/core/rule-owner.d.ts +46 -0
- package/dist/core/rule-owner.js +29 -0
- package/dist/core/runner/advisor-instructions.d.ts +70 -0
- package/dist/core/runner/advisor-instructions.js +61 -0
- package/dist/core/runner/advisor-tool.d.ts +33 -0
- package/dist/core/runner/advisor-tool.js +112 -0
- package/dist/core/runner/announce-once-ledger.d.ts +18 -26
- package/dist/core/runner/announce-once-ledger.js +19 -46
- package/dist/core/runner/approval-feedback.js +6 -3
- package/dist/core/runner/assemble-result.d.ts +2 -1
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/caller-roster.d.ts +21 -2
- package/dist/core/runner/caller-roster.js +38 -0
- package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
- package/dist/core/runner/capability-withheld-seat.js +24 -0
- package/dist/core/runner/classifier-ladder.d.ts +33 -13
- package/dist/core/runner/classifier-ladder.js +15 -14
- package/dist/core/runner/compaction-restate.d.ts +10 -6
- package/dist/core/runner/compaction-restate.js +9 -3
- package/dist/core/runner/construction-doors.js +3 -0
- package/dist/core/runner/contracts.d.ts +40 -33
- package/dist/core/runner/conversation-segment.d.ts +28 -0
- package/dist/core/runner/conversation-segment.js +42 -0
- package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
- package/dist/core/runner/cross-boundary-lane.js +58 -34
- package/dist/core/runner/decide-continuation.d.ts +7 -4
- package/dist/core/runner/decide-continuation.js +2 -2
- package/dist/core/runner/denial-limit-arms.d.ts +4 -4
- package/dist/core/runner/denial-limit-arms.js +1 -1
- package/dist/core/runner/derived-route-fallback.d.ts +24 -24
- package/dist/core/runner/derived-route-fallback.js +9 -7
- package/dist/core/runner/file-history-request.d.ts +18 -0
- package/dist/core/runner/file-history-request.js +21 -13
- package/dist/core/runner/file-history-restore.d.ts +45 -0
- package/dist/core/runner/file-history-restore.js +46 -0
- package/dist/core/runner/gate-exit.d.ts +9 -3
- package/dist/core/runner/gate-exit.js +11 -5
- package/dist/core/runner/image.d.ts +7 -17
- package/dist/core/runner/image.js +9 -60
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.js +38 -15
- package/dist/core/runner/person-path-rows.d.ts +12 -9
- package/dist/core/runner/person-path-rows.js +19 -8
- package/dist/core/runner/prepare-advisor.d.ts +63 -0
- package/dist/core/runner/prepare-advisor.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
- package/dist/core/runner/prepare-ask-lane.js +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +31 -38
- package/dist/core/runner/prepare-config-doors.js +57 -34
- package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
- package/dist/core/runner/prepare-defer-classify.js +7 -8
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +48 -8
- package/dist/core/runner/prepare-file-history.js +41 -73
- package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
- package/dist/core/runner/prepare-gate-stations.js +12 -8
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
- package/dist/core/runner/prepare-hands-readface.js +15 -14
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
- package/dist/core/runner/prepare-inherited-gate.js +8 -6
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +12 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
- package/dist/core/runner/prepare-policy-chain.js +68 -81
- package/dist/core/runner/prepare-project-context.d.ts +5 -2
- package/dist/core/runner/prepare-project-context.js +6 -3
- package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
- package/dist/core/runner/prepare-prompt-assembly.js +10 -8
- package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
- package/dist/core/runner/prepare-prompt-inputs.js +4 -6
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +5 -4
- package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
- package/dist/core/runner/prepare-safety-scan.js +8 -23
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +5 -6
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +41 -35
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
- package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
- package/dist/core/runner/prepare-turn-wiring.js +2 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
- package/dist/core/runner/prepare-wiring-manifest.js +3 -3
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -12
- package/dist/core/runner/resume-checkpoint-screen.js +3 -0
- package/dist/core/runner/resume-claim.d.ts +4 -2
- package/dist/core/runner/resume-claim.js +15 -8
- package/dist/core/runner/resume-policy-outcome.js +1 -1
- package/dist/core/runner/retired-runner-deps.js +2 -1
- package/dist/core/runner/rewind-files.d.ts +15 -0
- package/dist/core/runner/rewind-files.js +132 -0
- package/dist/core/runner/run-attachment-seats.js +2 -2
- package/dist/core/runner/run-brain-sinks.d.ts +4 -1
- package/dist/core/runner/run-brain-sinks.js +4 -2
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
- package/dist/core/runner/run-compaction-machinery.js +2 -12
- package/dist/core/runner/run-git-lane.d.ts +1 -0
- package/dist/core/runner/run-harness-handlers.js +14 -7
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +43 -18
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/run-turn-boundary.d.ts +1 -0
- package/dist/core/runner/run-turn-boundary.js +15 -22
- package/dist/core/runner/runtask.d.ts +3 -0
- package/dist/core/runner/runtask.js +8 -9
- package/dist/core/runner/session-read-file-states.d.ts +15 -0
- package/dist/core/runner/session-read-file-states.js +28 -0
- package/dist/core/runner/session-rule-policy.d.ts +22 -21
- package/dist/core/runner/session-rule-policy.js +17 -31
- package/dist/core/runner/shell-env-withheld.d.ts +33 -0
- package/dist/core/runner/shell-env-withheld.js +51 -0
- package/dist/core/runner/side-call-account.d.ts +32 -8
- package/dist/core/runner/side-call-account.js +23 -1
- package/dist/core/runner/skills-seat.js +6 -2
- package/dist/core/runner/stream-settle-backstop.js +1 -1
- package/dist/core/runner/strict-output-schema.d.ts +1 -1
- package/dist/core/runner/sub-agent-deny-lists.js +4 -6
- package/dist/core/runner/synthetic-tools.d.ts +16 -13
- package/dist/core/runner/synthetic-tools.js +8 -3
- package/dist/core/runner/tool-disclosure.d.ts +10 -12
- package/dist/core/runner/tool-disclosure.js +3 -4
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-end-body.js +10 -9
- package/dist/core/runner/tool-face-overlay.d.ts +2 -1
- package/dist/core/runner/tool-face-overlay.js +17 -1
- package/dist/core/runner/tool-not-executed.d.ts +5 -0
- package/dist/core/runner/tool-not-executed.js +11 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -0
- package/dist/core/runner/tool-occurrence.js +7 -0
- package/dist/core/runner/tool-progress-lane.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
- package/dist/core/runner/turn-attachments.d.ts +91 -80
- package/dist/core/runner/turn-attachments.js +62 -37
- package/dist/core/runner-deps.d.ts +42 -42
- package/dist/core/runtime-caps.d.ts +4 -4
- package/dist/core/safety-axis-vocab.d.ts +6 -4
- package/dist/core/safety-axis-vocab.js +6 -5
- package/dist/core/safety-merge-corpus.js +26 -2
- package/dist/core/same-plain-value.d.ts +40 -0
- package/dist/core/same-plain-value.js +49 -0
- package/dist/core/scheduler.d.ts +1 -1
- package/dist/core/secret-env.d.ts +26 -3
- package/dist/core/secret-env.js +44 -8
- package/dist/core/select-model.js +3 -3
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +1 -1
- package/dist/core/session-policy-store.d.ts +102 -35
- package/dist/core/session-policy-store.js +210 -48
- package/dist/core/session-reconcile.d.ts +2 -2
- package/dist/core/session-store.d.ts +106 -37
- package/dist/core/session-store.js +165 -91
- package/dist/core/session.d.ts +101 -57
- package/dist/core/session.js +53 -0
- package/dist/core/shared-memory/tools.js +3 -1
- package/dist/core/shared-memory/types.d.ts +1 -1
- package/dist/core/shell-read-silence.d.ts +11 -12
- package/dist/core/shell-read-silence.js +9 -5
- package/dist/core/shell-run-candidates.js +3 -1
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/shell-wrapper-table.d.ts +14 -7
- package/dist/core/shell-wrapper-table.js +5 -4
- package/dist/core/side-query.d.ts +10 -0
- package/dist/core/side-query.js +15 -1
- package/dist/core/skill-grant.d.ts +7 -2
- package/dist/core/skill-grant.js +5 -0
- package/dist/core/skills-directory.js +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
- package/dist/core/store-contracts/file-history-store-contract.js +74 -4
- package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
- package/dist/core/store-contracts/peer-directory-contract.js +14 -2
- package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
- package/dist/core/store-contracts/session-repo-contract.js +176 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
- package/dist/core/store-contracts/session-store-contract.js +361 -51
- package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/surrogate-safe-slice.d.ts +3 -3
- package/dist/core/synthetic-read-verdict.js +3 -3
- package/dist/core/task-event.d.ts +42 -8
- package/dist/core/task-notification.d.ts +19 -15
- package/dist/core/task-registry-agent.d.ts +4 -4
- package/dist/core/task-registry-shared.d.ts +4 -4
- package/dist/core/task-registry-shared.js +1 -0
- package/dist/core/task-registry.d.ts +13 -4
- package/dist/core/task-registry.js +14 -2
- package/dist/core/task-result.d.ts +21 -3
- package/dist/core/task-spec.d.ts +69 -64
- package/dist/core/task-stream.d.ts +6 -6
- package/dist/core/task-tool-shape.d.ts +4 -4
- package/dist/core/tighten-task-spec.d.ts +1 -1
- package/dist/core/tighten-task-spec.js +2 -1
- package/dist/core/tool-catalog-entries.d.ts +36 -2
- package/dist/core/tool-catalog-entries.js +69 -43
- package/dist/core/tool-check-reading.d.ts +11 -0
- package/dist/core/tool-check-reading.js +11 -6
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-errors.d.ts +2 -2
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-face.d.ts +21 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +29 -8
- package/dist/core/tool-name-aliases.js +22 -4
- package/dist/core/tool-name-readings.d.ts +10 -43
- package/dist/core/tool-name-readings.js +2 -11
- package/dist/core/tool-policy.d.ts +85 -196
- package/dist/core/tool-policy.js +150 -175
- package/dist/core/tool-registry.d.ts +14 -7
- package/dist/core/tool-registry.js +17 -7
- package/dist/core/tool-result-store.js +5 -1
- package/dist/core/tool-roster.d.ts +57 -33
- package/dist/core/tool-roster.js +56 -68
- package/dist/core/tool-spec-members.js +8 -3
- package/dist/core/tool-spec.d.ts +53 -31
- package/dist/core/tools.js +51 -10
- package/dist/core/trace.d.ts +6 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/user-attachment.d.ts +8 -1
- package/dist/core/user-attachment.js +64 -4
- package/dist/core/warm-resume.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +58 -0
- package/dist/core/wiring-manifest.js +14 -5
- package/dist/core/workflow-journal-store.d.ts +62 -0
- package/dist/core/workflow-journal-store.js +78 -2
- package/dist/core/workflow-run-store.d.ts +6 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +9 -9
- package/dist/engine/compaction/compaction.js +3 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
- package/dist/engine/execution-env/node-execution-env.js +54 -24
- package/dist/engine/harness/agent-harness.d.ts +39 -9
- package/dist/engine/harness/agent-harness.js +87 -33
- package/dist/engine/harness/types.d.ts +58 -9
- package/dist/engine/harness/types.js +12 -1
- package/dist/engine/llm/types.d.ts +36 -19
- package/dist/engine/llm/validation.d.ts +4 -1
- package/dist/engine/llm/validation.js +13 -1
- package/dist/engine/loop/agent-loop.d.ts +23 -1
- package/dist/engine/loop/agent-loop.js +26 -34
- package/dist/engine/loop/types.d.ts +31 -19
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/memory-repo.d.ts +18 -12
- package/dist/engine/session/memory-repo.js +24 -9
- package/dist/engine/session/parent-chain-guard.d.ts +3 -2
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +32 -3
- package/dist/engine/session/repo-utils.js +50 -5
- package/dist/index.d.ts +47 -23
- package/dist/index.js +35 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +3 -3
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +2 -2
- package/dist/orchestration/run-workflow-tool.d.ts +8 -6
- package/dist/orchestration/run-workflow-tool.js +10 -6
- package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
- package/dist/orchestration/workflow-types.d.ts +18 -0
- package/dist/orchestration/workflow-types.js +6 -0
- package/dist/orchestration/workflow.d.ts +5 -13
- package/dist/orchestration/workflow.js +57 -49
- package/dist/prompt-assembly/artifact.d.ts +2 -2
- package/dist/prompt-assembly/artifact.js +5 -3
- package/dist/prompt-assembly/assemble.d.ts +3 -2
- package/dist/prompt-assembly/assemble.js +1 -1
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
- package/dist/prompt-assembly/catalog/schema.js +34 -2
- package/dist/prompt-assembly/catalog/sections.js +0 -1
- package/dist/prompt-assembly/composer.d.ts +3 -1
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/overlay.js +3 -3
- package/dist/prompt-assembly/renderers.d.ts +1 -1
- package/dist/prompt-assembly/renderers.js +0 -3
- package/dist/prompt-assembly/role-base.d.ts +15 -0
- package/dist/prompt-assembly/role-base.js +9 -0
- package/dist/prompt-assembly/select.d.ts +39 -14
- package/dist/prompt-assembly/select.js +47 -16
- package/dist/prompt-assembly/sugar.d.ts +17 -11
- package/dist/prompt-assembly/sugar.js +8 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
- package/dist/prompt-assembly/tool-catalog.js +117 -4
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
- package/dist/prompt-assembly/turn-snapshot.js +0 -3
- package/dist/prompt-assembly/types.d.ts +0 -7
- package/dist/prompts/default.d.ts +14 -14
- package/dist/scenarios/full-body.d.ts +15 -15
- package/dist/scenarios/full-body.js +4 -3
- package/dist/shell/lex.js +10 -1
- package/dist/stores/file/adoption/adopt.d.ts +4 -3
- package/dist/stores/file/adoption/adopt.js +27 -33
- package/dist/stores/file/adoption/marker.d.ts +6 -13
- package/dist/stores/file/adoption/marker.js +9 -17
- package/dist/stores/file/checkpoint-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.js +45 -7
- package/dist/stores/file/file-history-store.d.ts +20 -19
- package/dist/stores/file/file-history-store.js +157 -141
- package/dist/stores/file/fs-atomic.d.ts +15 -0
- package/dist/stores/file/fs-atomic.js +89 -14
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +2 -1
- package/dist/stores/file/mailbox-store.d.ts +3 -0
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
- package/dist/stores/file/permission-rule-adopt.js +18 -18
- package/dist/stores/file/permission-rule-store.d.ts +18 -2
- package/dist/stores/file/permission-rule-store.js +31 -18
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/stores/file/session-store.d.ts +54 -16
- package/dist/stores/file/session-store.js +114 -85
- package/dist/stores/file/workflow-journal-store.d.ts +10 -4
- package/dist/stores/file/workflow-journal-store.js +28 -13
- package/dist/tools/artifact/artifact-text.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +5 -3
- package/dist/tools/fs/bash-program-position.d.ts +19 -2
- package/dist/tools/fs/bash-program-position.js +56 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
- package/dist/tools/fs/fs-bash.d.ts +2 -2
- package/dist/tools/fs/fs-bash.js +8 -6
- package/dist/tools/fs/fs-glob.d.ts +86 -0
- package/dist/tools/fs/fs-glob.js +226 -0
- package/dist/tools/fs/fs-read.js +14 -14
- package/dist/tools/fs/fs-search-tools.js +7 -7
- package/dist/tools/fs/fs-shared.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
- package/dist/tools/fs/notebook.d.ts +2 -2
- package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
- package/dist/tools/fs/pattern-kill-guard.js +397 -0
- package/dist/tools/fs/pdf.d.ts +9 -6
- package/dist/tools/fs/pdf.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +57 -7
- package/dist/tools/fs/program-read-model.js +11 -1
- package/dist/tools/fs/program-read-model.rows.js +78 -21
- package/dist/tools/fs/read-deny-home.js +3 -2
- package/dist/tools/fs/read-deny.d.ts +29 -7
- package/dist/tools/fs/read-deny.js +63 -22
- package/dist/tools/fs/removal-targets.d.ts +18 -8
- package/dist/tools/fs/removal-targets.js +47 -20
- package/dist/tools/fs/safety.d.ts +9 -9
- package/dist/tools/fs/search.d.ts +16 -6
- package/dist/tools/fs/search.js +20 -26
- package/dist/tools/fs/shell-read-argv.js +89 -12
- package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
- package/dist/tools/fs/shell-read-bindings.js +41 -0
- package/dist/tools/fs/shell-read-check.js +12 -20
- package/dist/tools/fs/shell-read-environment.d.ts +5 -1
- package/dist/tools/fs/shell-read-environment.js +3 -2
- package/dist/tools/fs/shell-read-establish.d.ts +15 -0
- package/dist/tools/fs/shell-read-establish.js +19 -20
- package/dist/tools/fs/shell-read-judge.d.ts +4 -0
- package/dist/tools/fs/shell-read-judge.js +5 -2
- package/dist/tools/fs/shell-read-plan.js +24 -16
- package/dist/tools/fs/shell-read-start.d.ts +6 -1
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
- package/dist/tools/fs/shell-read-write-targets.js +2 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
- package/dist/tools/fs/shell-reentry-text.js +40 -2
- package/dist/tools/loop-tick.d.ts +2 -2
- package/dist/tools/scheduler-tools.js +5 -1
- package/dist/tools/task-list.d.ts +7 -7
- package/dist/tools/task-list.js +5 -1
- package/dist/tools/todo.js +65 -64
- package/dist/tools/web.d.ts +20 -15
- package/dist/tools/web.js +55 -69
- package/dist/tools/worktree.d.ts +3 -3
- package/dist/tools/worktree.js +3 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +5894 -5638
- package/wire-changes/core@7.55.0.json +3318 -0
- package/wire-changes/core@7.56.0.json +3891 -0
- package/wire-changes/mods-kernel@7.56.0.json +303 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
- package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { ENGINE_ORIGIN } from "./kernel/index.js";
|
|
3
|
+
const store = new AsyncLocalStorage();
|
|
4
|
+
export function extensionCallOf(bus, toolCallId) {
|
|
5
|
+
const c = store.getStore();
|
|
6
|
+
return c !== undefined && c.live && c.bus === bus && (toolCallId === undefined || c.toolCallId === toolCallId) ? c : undefined;
|
|
7
|
+
}
|
|
8
|
+
export function requesterOf(bus, toolCallId) {
|
|
9
|
+
const c = extensionCallOf(bus, toolCallId);
|
|
10
|
+
return c !== undefined ? { requestedBy: Object.freeze({ kind: "extension", name: c.caller.origin.plugin }) } : {};
|
|
11
|
+
}
|
|
12
|
+
export function noteExtensionCallDenied(bus, toolCallId) {
|
|
13
|
+
const c = store.getStore();
|
|
14
|
+
if (c !== undefined && c.live && c.bus === bus && c.toolCallId === toolCallId)
|
|
15
|
+
c.denied = true;
|
|
16
|
+
}
|
|
17
|
+
export async function runExtensionCall(bus, toolCallId, caller, pipeline) {
|
|
18
|
+
const call = { bus, toolCallId, caller, live: true, denied: false };
|
|
19
|
+
try {
|
|
20
|
+
return await store.run(call, () => pipeline(call));
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
call.live = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function legBusOf(bus, report) {
|
|
27
|
+
const leg = {
|
|
28
|
+
records: bus.records,
|
|
29
|
+
mounted: () => bus.mounted(),
|
|
30
|
+
hasHandlers: (event, participant) => bus.hasHandlers(event, participant),
|
|
31
|
+
dispatch: (event, e, options) => {
|
|
32
|
+
const c = store.getStore();
|
|
33
|
+
if (c === undefined || c.bus !== leg || options.frames !== undefined)
|
|
34
|
+
return bus.dispatch(event, e, options);
|
|
35
|
+
if (c.live)
|
|
36
|
+
return bus.dispatch(event, e, { ...options, frames: c.caller.frames, origin: c.caller.origin });
|
|
37
|
+
const reason = `${event}: raised under extension "${c.caller.origin.plugin}"'s call ${c.toolCallId}, which has ended — an event is not raised under a call that is over`;
|
|
38
|
+
report(new Error(`engine: ${reason} — the dispatch was not run`));
|
|
39
|
+
return Promise.resolve(Object.freeze({ kind: "failed", registration: ENGINE_ORIGIN.plugin, cause: "violation", reason, skipped: Object.freeze([]) }));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return leg;
|
|
43
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ModBusSide, type ModEventName, type ModSeat } from "./events.js";
|
|
2
2
|
import { type ModAdmissionRecord, type ModDollarBase, type ModOrigin, type ModSeats } from "./registration.js";
|
|
3
|
-
import { type ModAnswerCheck, type ModEventPayload, type ModFailureCause, type ModMatcher, type ModSkip, type ProxyProbe } from "./site-rules.js";
|
|
3
|
+
import { type ModAnswerCheck, type ModAnswerRanks, type ModEventPayload, type ModFailureCause, type ModMatcher, type ModSkip, type ProxyProbe } from "./site-rules.js";
|
|
4
4
|
/** A frame on the dispatch stack: a registration's own `$` call, or one of its handlers running. */
|
|
5
5
|
export type ModFrame = {
|
|
6
6
|
readonly kind: "dollar";
|
|
@@ -28,6 +28,13 @@ export interface ModMethodSeat {
|
|
|
28
28
|
readonly enter?: (args: ModEventPayload) => ModEventPayload;
|
|
29
29
|
}
|
|
30
30
|
export type ModMethodBottoms = Partial<Record<ModEventName, ModMethodSeat>>;
|
|
31
|
+
/**
|
|
32
|
+
* A callable event's host entry: what a `$` call of the event reaches. It runs whatever stands before the event and
|
|
33
|
+
* raises the event once at its own station, under `ctx.frames` and `ctx.origin` (so the caller's own handlers stay out
|
|
34
|
+
* of that raise); its answer is the call's answer (a `{ deny }` is returned, not thrown) and its throw the caller's.
|
|
35
|
+
*/
|
|
36
|
+
export type ModCallEntry = (args: ModEventPayload, ctx: ModBottomContext) => unknown;
|
|
37
|
+
export type ModCallEntries = Partial<Record<ModEventName, ModCallEntry>>;
|
|
31
38
|
export type ModDispatchOutcome = {
|
|
32
39
|
readonly kind: "answered";
|
|
33
40
|
readonly answer: unknown;
|
|
@@ -39,8 +46,12 @@ export type ModDispatchOutcome = {
|
|
|
39
46
|
readonly cause: ModFailureCause;
|
|
40
47
|
readonly reason: string;
|
|
41
48
|
readonly skipped: readonly ModSkip[];
|
|
42
|
-
}
|
|
49
|
+
}
|
|
50
|
+
/** `bottomStarted`: the chain's bottom had started when the dispatch was cancelled — on an effect event, what it did is
|
|
51
|
+
* not known from here. */
|
|
52
|
+
| {
|
|
43
53
|
readonly kind: "aborted";
|
|
54
|
+
readonly bottomStarted?: true;
|
|
44
55
|
};
|
|
45
56
|
/** What a participant filter sees of one mounted handler: its registration, that registration's seat, and whether it only observes. */
|
|
46
57
|
export interface ModParticipant {
|
|
@@ -57,6 +68,9 @@ export interface ModDispatchOptions {
|
|
|
57
68
|
readonly origin?: ModOrigin;
|
|
58
69
|
/** The raiser's reading of an answer; an answer it refuses is a violation of the site. */
|
|
59
70
|
readonly checkAnswer?: ModAnswerCheck;
|
|
71
|
+
/** The station's ranking of its answers — named by every dispatch of an event whose failure column refuses (one that
|
|
72
|
+
* names none is not run), and read by the seat-trust law. */
|
|
73
|
+
readonly ranks?: ModAnswerRanks;
|
|
60
74
|
/** Which mounted handlers take part (absent ⇒ every handler on the event). A handler it leaves out neither runs nor observes. */
|
|
61
75
|
readonly participant?: (p: ModParticipant) => boolean;
|
|
62
76
|
}
|
|
@@ -76,12 +90,15 @@ export interface ModBus {
|
|
|
76
90
|
mounted(): readonly ModMountedHandler[];
|
|
77
91
|
/** Whether any mounted handler hangs on `event` (among those `participant` admits) — no handler, no dispatch (the station skips the call). */
|
|
78
92
|
hasHandlers(event: ModEventName, participant?: (p: ModParticipant) => boolean): boolean;
|
|
79
|
-
|
|
93
|
+
/** Raise `event` with the raiser's `e` (an object the bus receives whole, an event map's `e` as it is). */
|
|
94
|
+
dispatch(event: ModEventName, e: object, options: ModDispatchOptions): Promise<ModDispatchOutcome>;
|
|
80
95
|
}
|
|
81
96
|
export interface ModBusInput<D extends ModDollarBase = ModDollarBase> {
|
|
82
97
|
readonly side: ModBusSide;
|
|
83
98
|
readonly seats: ModSeats<D>;
|
|
84
99
|
readonly bottoms: ModMethodBottoms;
|
|
100
|
+
/** The host's entries of the callable events its bus raises (absent ⇒ none: a `$` call of such an event throws). */
|
|
101
|
+
readonly entries?: ModCallEntries;
|
|
85
102
|
/** Where handler failures go (the host's error channel). Never throws back into the bus. */
|
|
86
103
|
readonly report: (err: Error, classification?: "observational-hook-verdict-ignored") => void;
|
|
87
104
|
/** The host's one rule for turning a THROWN value into text (a handler, a `.catch` or a `register` may throw
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CATCH_BUDGET_MS, createSelfBudget, POST_ABORT_GRACE_MS, RUNAWAY_AFTER_MS, unrefTimer, watchRunaway } from "./budget.js";
|
|
2
|
-
import {
|
|
2
|
+
import { expandOnSide, failureRefuses, isModEventName, MOD_SEATS, nextToRefusal, stationOn } from "./events.js";
|
|
3
3
|
import { ENGINE_ORIGIN, modsInvalid, screenModSeats, } from "./registration.js";
|
|
4
|
-
import { answerUpward, answerViolation, detachedCopy, engineObjectsOnce, handedOn, matcherMatches, matcherViolation, methodAnswerViolation, NEXT_IN_FLIGHT, receiveAnswer, receiveEvent, receivePayload, } from "./site-rules.js";
|
|
4
|
+
import { answerUpward, answerViolation, detachedCopy, engineObjectsOnce, handedOn, matcherMatches, matcherViolation, methodAnswerViolation, NEXT_IN_FLIGHT, receiveAnswer, receiveEvent, receivePayload, sealedObjects, } from "./site-rules.js";
|
|
5
5
|
const TIER_RANK = { prepend: 0, user: 1, append: 2, builtin: 3, core: 4 };
|
|
6
6
|
const bypassed = (floors, tier) => floors.some((f) => TIER_RANK[f.from] < TIER_RANK[tier] && TIER_RANK[tier] < TIER_RANK[f.to]);
|
|
7
7
|
export async function admitMods(input) {
|
|
@@ -10,7 +10,7 @@ export async function admitMods(input) {
|
|
|
10
10
|
const mounted = [];
|
|
11
11
|
const records = [];
|
|
12
12
|
const describe = safeDescribe(input.describeThrown);
|
|
13
|
-
const bus = createBus(input.side, mounted, input.bottoms, report, records, describe, input.isProxy);
|
|
13
|
+
const bus = createBus(input.side, mounted, input.bottoms, input.entries ?? {}, report, records, describe, input.isProxy);
|
|
14
14
|
const admitted = Object.freeze({ admitted: true });
|
|
15
15
|
for (const cand of screened) {
|
|
16
16
|
if (input.signal?.aborted === true)
|
|
@@ -24,14 +24,10 @@ export async function admitMods(input) {
|
|
|
24
24
|
});
|
|
25
25
|
const outcome = await bus.dispatch("plugin.register", e, {
|
|
26
26
|
bottom: () => admitted,
|
|
27
|
+
ranks: ADMISSION_RANKS,
|
|
27
28
|
...(input.signal !== undefined ? { signal: input.signal } : {}),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: refusalOf(a) === undefined
|
|
31
|
-
? "takes next(e) or { refuse: <reason> }"
|
|
32
|
-
: MOD_SEATS.indexOf(by.seat) > MOD_SEATS.findIndex((s) => s === judged["seat"])
|
|
33
|
-
? `a ${by.seat} registration may not refuse a ${String(judged["seat"])} registration`
|
|
34
|
-
: undefined,
|
|
29
|
+
participant: (p) => MOD_SEATS.indexOf(p.seat) <= MOD_SEATS.indexOf(cand.seat),
|
|
30
|
+
checkAnswer: (a) => (a === admitted || refusalOf(a) !== undefined ? undefined : "takes next(e) or { refuse: <reason> }"),
|
|
35
31
|
});
|
|
36
32
|
if (outcome.kind === "aborted")
|
|
37
33
|
throw input.signal?.reason ?? new Error("admission aborted");
|
|
@@ -59,6 +55,7 @@ export async function admitMods(input) {
|
|
|
59
55
|
}
|
|
60
56
|
return bus;
|
|
61
57
|
}
|
|
58
|
+
const ADMISSION_RANKS = Object.freeze({ of: (a) => (refusalOf(a) !== undefined ? 1 : 0), top: 1 });
|
|
62
59
|
function refusalOf(a) {
|
|
63
60
|
if (typeof a !== "object" || a === null || !Object.prototype.hasOwnProperty.call(a, "refuse"))
|
|
64
61
|
return undefined;
|
|
@@ -113,7 +110,7 @@ function mountOne(cand, side, describe) {
|
|
|
113
110
|
const parsed = handlerOptions(opts);
|
|
114
111
|
if (typeof parsed === "string")
|
|
115
112
|
fail(`on("${String(pattern)}"): ${parsed}`);
|
|
116
|
-
const expanded =
|
|
113
|
+
const expanded = expandOnSide(pattern, side);
|
|
117
114
|
if ("refusal" in expanded)
|
|
118
115
|
return void fail(`on(): ${expanded.refusal}`);
|
|
119
116
|
const outside = expanded.names.filter((n) => !cand.eventsBound.has(n));
|
|
@@ -178,16 +175,23 @@ function handlerOptions(opts) {
|
|
|
178
175
|
}
|
|
179
176
|
const HA = "skipped; what is below it ran in its place";
|
|
180
177
|
const MA = "skipped; its last next() run's result stands";
|
|
181
|
-
function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
182
|
-
const
|
|
178
|
+
function createBus(side, mounted, bottoms, entries, report, records, describe, isProxy) {
|
|
179
|
+
const reaches = new Map();
|
|
183
180
|
for (const name of Object.keys(bottoms)) {
|
|
184
|
-
if (!isModEventName(name)
|
|
181
|
+
if (!isModEventName(name))
|
|
185
182
|
continue;
|
|
183
|
+
const seat = bottoms[name];
|
|
186
184
|
const st = stationOn(name, side);
|
|
187
|
-
if (st?.method
|
|
185
|
+
if (seat !== undefined && st?.method !== undefined)
|
|
186
|
+
reaches.set(name, { kind: "method", st, seat, pauses: st.method.pausesCallerBudget });
|
|
187
|
+
}
|
|
188
|
+
for (const name of Object.keys(entries)) {
|
|
189
|
+
if (!isModEventName(name))
|
|
188
190
|
continue;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
+
const entry = entries[name];
|
|
192
|
+
const st = stationOn(name, side);
|
|
193
|
+
if (entry !== undefined && st?.call !== undefined)
|
|
194
|
+
reaches.set(name, { kind: "call", entry, pauses: st.call.pausesCallerBudget });
|
|
191
195
|
}
|
|
192
196
|
const bus = {
|
|
193
197
|
records,
|
|
@@ -215,26 +219,26 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
215
219
|
const inFrames = (fs, h) => fs.some((f) => f.plugin === h.reg.name && (f.kind === "dollar" || f.handler === h.index));
|
|
216
220
|
const caller = frames.slice(-1);
|
|
217
221
|
const above = frames.slice(0, -1);
|
|
218
|
-
const
|
|
222
|
+
const all = [];
|
|
223
|
+
const guards = [];
|
|
219
224
|
for (const h of mounted) {
|
|
220
225
|
if (!h.events.has(event) || !admits(participant, h) || !matcherMatches(h.matcher, e))
|
|
221
226
|
continue;
|
|
222
227
|
if (inFrames(caller, h))
|
|
223
228
|
continue;
|
|
224
229
|
if (!inFrames(above, h))
|
|
225
|
-
|
|
226
|
-
else if (h.
|
|
227
|
-
|
|
230
|
+
all.push({ h, reentry: false });
|
|
231
|
+
else if (h.observe)
|
|
232
|
+
continue;
|
|
233
|
+
else if (h.onCatch !== undefined)
|
|
234
|
+
all.push({ h, reentry: true });
|
|
235
|
+
else
|
|
236
|
+
guards.push(h);
|
|
228
237
|
}
|
|
229
|
-
return
|
|
238
|
+
return { all, guards };
|
|
230
239
|
}
|
|
231
|
-
async function callMethod(event, args, caller) {
|
|
232
|
-
const seat =
|
|
233
|
-
if (seat === undefined)
|
|
234
|
-
throw new Error(`${caller.origin.plugin}: $.${event}: no implementation on the ${side} bus`);
|
|
235
|
-
const st = stationOn(event, side);
|
|
236
|
-
if (st === undefined)
|
|
237
|
-
throw new Error(`${caller.origin.plugin}: $.${event}: not raised on the ${side} bus`);
|
|
240
|
+
async function callMethod(event, reach, args, caller) {
|
|
241
|
+
const { seat, st } = reach;
|
|
238
242
|
let e0 = args;
|
|
239
243
|
if (seat.enter !== undefined) {
|
|
240
244
|
const shaped = receivePayload(seat.enter(args), isProxy, engineObjectsOnce(args)());
|
|
@@ -249,10 +253,6 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
249
253
|
signal: caller.signal,
|
|
250
254
|
checkAnswer: methodAnswerViolation,
|
|
251
255
|
});
|
|
252
|
-
if (outcome.kind !== "aborted")
|
|
253
|
-
for (const s of outcome.skipped)
|
|
254
|
-
if (s.cause === "violation")
|
|
255
|
-
report(new Error(`${s.registration}: $.${event}: ${s.reason} — skipped`));
|
|
256
256
|
if (outcome.kind === "aborted")
|
|
257
257
|
throw new Error(`${caller.origin.plugin}: $.${event}: aborted`);
|
|
258
258
|
if (outcome.kind === "failed")
|
|
@@ -265,24 +265,28 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
265
265
|
}
|
|
266
266
|
function dollarFor(reg, frames, budget, signal, engines) {
|
|
267
267
|
const origin = Object.freeze({ plugin: reg.name, tier: reg.tier });
|
|
268
|
-
const
|
|
268
|
+
const caller = Object.freeze({ frames: Object.freeze([...frames, Object.freeze({ kind: "dollar", plugin: reg.name })]), origin, signal });
|
|
269
269
|
const namespaces = new Map();
|
|
270
|
-
for (const
|
|
271
|
-
const
|
|
272
|
-
namespaces.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
270
|
+
for (const event of new Set([...reaches.keys(), ...reg.callsBound])) {
|
|
271
|
+
const dot = event.indexOf(".");
|
|
272
|
+
const ns = namespaces.get(event.slice(0, dot)) ?? {};
|
|
273
|
+
namespaces.set(event.slice(0, dot), ns);
|
|
274
|
+
ns[event.slice(dot + 1)] = async (args) => {
|
|
275
|
+
if (!reg.callsBound.has(event))
|
|
276
|
+
throw new Error(`${reg.name}: $.${event}: not declared in uses.calls`);
|
|
277
|
+
const reach = reaches.get(event);
|
|
278
|
+
if (reach === undefined)
|
|
279
|
+
throw new Error(`${reg.name}: $.${event}: not callable on the ${side} bus in this version`);
|
|
276
280
|
const received = receivePayload(args === undefined ? {} : args, isProxy, engines());
|
|
277
281
|
if ("refusal" in received)
|
|
278
|
-
throw new TypeError(`${reg.name}: $.${
|
|
279
|
-
if (
|
|
282
|
+
throw new TypeError(`${reg.name}: $.${event}: takes one object — ${received.refusal}`);
|
|
283
|
+
if (reach.pauses)
|
|
280
284
|
budget.pause();
|
|
281
285
|
try {
|
|
282
|
-
return await callMethod(
|
|
286
|
+
return reach.kind === "method" ? await callMethod(event, reach, received.payload, caller) : await reach.entry(received.payload, caller);
|
|
283
287
|
}
|
|
284
288
|
finally {
|
|
285
|
-
if (
|
|
289
|
+
if (reach.pauses)
|
|
286
290
|
budget.resume();
|
|
287
291
|
}
|
|
288
292
|
};
|
|
@@ -290,12 +294,25 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
290
294
|
const out = {};
|
|
291
295
|
for (const [ns, fns] of namespaces)
|
|
292
296
|
out[ns] = Object.freeze(fns);
|
|
293
|
-
return Object.freeze({ ...out, plugin: Object.freeze({ name: reg.name }) });
|
|
297
|
+
return Object.freeze({ ...out, plugin: Object.freeze({ ...(namespaces.get("plugin") ?? {}), name: reg.name }) });
|
|
294
298
|
}
|
|
295
299
|
function runDispatch(event, st, e0, options) {
|
|
296
300
|
const frames = options.frames ?? [];
|
|
297
301
|
const origin = options.origin ?? ENGINE_ORIGIN;
|
|
298
|
-
const
|
|
302
|
+
const refusing = failureRefuses(st.failure);
|
|
303
|
+
const engineFault = (reason) => {
|
|
304
|
+
report(new Error(`engine: ${event}: ${reason} — the dispatch was not run`));
|
|
305
|
+
return Promise.resolve(Object.freeze({ kind: "failed", registration: ENGINE_ORIGIN.plugin, cause: "violation", reason: `${event}: ${reason}`, skipped: Object.freeze([]) }));
|
|
306
|
+
};
|
|
307
|
+
if (refusing && options.ranks === undefined)
|
|
308
|
+
return engineFault("a dispatch of an event whose failure column refuses names no answer ranks (the seat-trust law reads them)");
|
|
309
|
+
const { all, guards } = participants(event, e0, frames, options.participant);
|
|
310
|
+
const guard = refusing ? guards[0] : undefined;
|
|
311
|
+
if (guard !== undefined) {
|
|
312
|
+
const reason = "not run: the dispatch re-entered a frame it is part of, and it has no .catch to answer for it — a guard that cannot answer refuses";
|
|
313
|
+
report(new Error(`${guard.reg.name}: ${event}: ${reason} — failed closed: the dispatch ends here`));
|
|
314
|
+
return Promise.resolve(Object.freeze({ kind: "failed", registration: guard.reg.name, cause: "reentry", reason, skipped: Object.freeze([]) }));
|
|
315
|
+
}
|
|
299
316
|
const observers = all.filter((p) => !p.reentry && p.h.observe).map((p) => p.h);
|
|
300
317
|
const chain = all.filter((p) => !p.h.observe).map((p) => p.h);
|
|
301
318
|
const reentered = new Set(all.filter((p) => p.reentry).map((p) => p.h));
|
|
@@ -305,6 +322,8 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
305
322
|
const dispatchAc = new AbortController();
|
|
306
323
|
const terminal = { kind: "terminal" };
|
|
307
324
|
let settled = false;
|
|
325
|
+
let bottomStarted = false;
|
|
326
|
+
const ownMs = (ms) => (st.budgetMs === undefined ? ms : Math.min(ms, st.budgetMs));
|
|
308
327
|
let graceTimer;
|
|
309
328
|
let resolveOut = () => { };
|
|
310
329
|
let rejectOut = () => { };
|
|
@@ -313,15 +332,16 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
313
332
|
rejectOut = rej;
|
|
314
333
|
});
|
|
315
334
|
const signal = options.signal;
|
|
335
|
+
const aborted = () => (bottomStarted ? { kind: "aborted", bottomStarted: true } : { kind: "aborted" });
|
|
316
336
|
const onAbort = () => {
|
|
317
337
|
if (settled)
|
|
318
338
|
return;
|
|
319
339
|
if (st.abort === "grace") {
|
|
320
|
-
graceTimer ??= setTimeout(() => finish(
|
|
340
|
+
graceTimer ??= setTimeout(() => finish(aborted()), POST_ABORT_GRACE_MS);
|
|
321
341
|
unrefTimer(graceTimer);
|
|
322
342
|
}
|
|
323
343
|
else
|
|
324
|
-
finish(
|
|
344
|
+
finish(aborted());
|
|
325
345
|
};
|
|
326
346
|
function finish(o) {
|
|
327
347
|
if (settled)
|
|
@@ -348,23 +368,66 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
348
368
|
run.then(drop, drop);
|
|
349
369
|
};
|
|
350
370
|
const engines = engineObjectsOnce(e0);
|
|
371
|
+
const eventSealed = (() => {
|
|
372
|
+
let found;
|
|
373
|
+
return () => (found ??= sealedObjects([e0]));
|
|
374
|
+
})();
|
|
351
375
|
const handOn = (passed) => {
|
|
352
376
|
if (passed === e0)
|
|
353
377
|
return { snap: e0 };
|
|
354
378
|
const handed = handedOn(st.pinned, e0, passed, engines(), isProxy);
|
|
355
379
|
return "violation" in handed ? handed : { snap: handed.payload };
|
|
356
380
|
};
|
|
357
|
-
const
|
|
381
|
+
const trustFloors = new Map();
|
|
382
|
+
const NO_FLOOR = Object.freeze(MOD_SEATS.map(() => 0));
|
|
383
|
+
const seatRank = (seat) => MOD_SEATS.indexOf(seat);
|
|
384
|
+
const seatTrust = (taken, s, h, i, tiers) => {
|
|
385
|
+
const ranks = options.ranks;
|
|
386
|
+
if (ranks === undefined)
|
|
387
|
+
return undefined;
|
|
388
|
+
const mine = seatRank(h.reg.seat);
|
|
389
|
+
let rank;
|
|
390
|
+
try {
|
|
391
|
+
rank = ranks.of(taken);
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return "returned an answer the station cannot rank";
|
|
395
|
+
}
|
|
396
|
+
const answered = s.pending === 0 && s.answers.length > 0;
|
|
397
|
+
let floor;
|
|
398
|
+
if (answered) {
|
|
399
|
+
const inherited = trustFloors.get(s.answers[s.answers.length - 1]) ?? NO_FLOOR;
|
|
400
|
+
if (rank < (inherited[mine] ?? 0))
|
|
401
|
+
return `answered less strictly than a more trusted seat's handler below it did — a ${h.reg.seat} answer never stands over a stricter one of a more trusted seat`;
|
|
402
|
+
floor = inherited;
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
const unrun = chain.slice(i + 1).filter((m) => !bypassed(tiers, m.reg.tier)).map((m) => seatRank(m.reg.seat));
|
|
406
|
+
const trusted = unrun.length > 0 ? Math.min(...unrun) : MOD_SEATS.length;
|
|
407
|
+
if (trusted < mine && rank < ranks.top) {
|
|
408
|
+
return `answered ${s.called ? "while its next(e) still ran" : "without calling next(e)"}, with a ${MOD_SEATS[trusted]} handler below it that did not judge — a ${h.reg.seat} answer stands in place of theirs only when it refuses outright`;
|
|
409
|
+
}
|
|
410
|
+
floor = NO_FLOOR.map((_, k) => (k > trusted ? ranks.top : 0));
|
|
411
|
+
}
|
|
412
|
+
trustFloors.set(taken, floor.map((f, k) => (mine < k ? rank : f)));
|
|
413
|
+
return undefined;
|
|
414
|
+
};
|
|
415
|
+
const takeAnswer = (answer, s, e, h, i, tiers) => {
|
|
416
|
+
const handedUp = s.answers.some((a) => Object.is(a, answer));
|
|
358
417
|
let taken = answer;
|
|
359
|
-
if (!
|
|
360
|
-
const
|
|
418
|
+
if (!handedUp) {
|
|
419
|
+
const held = { has: (v) => eventSealed().has(v) || s.sealed?.has(v) === true };
|
|
420
|
+
const received = receiveAnswer(answer, held, isProxy);
|
|
361
421
|
if ("refusal" in received)
|
|
362
422
|
return { violation: received.refusal };
|
|
363
423
|
taken = received.answer;
|
|
364
424
|
}
|
|
365
425
|
const below = s.pending > 0 ? [...s.answers, NEXT_IN_FLIGHT] : s.answers;
|
|
366
|
-
const why = answerViolation(taken, options.checkAnswer, e, answererOf(h), below);
|
|
367
|
-
|
|
426
|
+
const why = answerViolation(taken, options.checkAnswer, e, answererOf(h), below, Object.freeze({ bottomStarted }));
|
|
427
|
+
if (why !== undefined)
|
|
428
|
+
return { violation: why };
|
|
429
|
+
const trust = handedUp ? undefined : seatTrust(taken, s, h, i, tiers);
|
|
430
|
+
return trust !== undefined ? { violation: trust } : { answer: taken };
|
|
368
431
|
};
|
|
369
432
|
const traceOf = (sink, index, plugin, tier, outcome, ms) => {
|
|
370
433
|
sink.push(Object.freeze({ index, plugin, tier, outcome, ms }));
|
|
@@ -383,6 +446,7 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
383
446
|
run.then((v) => {
|
|
384
447
|
state.lastValue = { v };
|
|
385
448
|
state.answers.push(v);
|
|
449
|
+
state.sealed = new Set([...(state.sealed ?? []), ...sealedObjects([v])]);
|
|
386
450
|
stopCounting();
|
|
387
451
|
}, (err) => {
|
|
388
452
|
state.belowError = err;
|
|
@@ -397,8 +461,9 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
397
461
|
const h = chain[i];
|
|
398
462
|
if (h === undefined) {
|
|
399
463
|
const t0 = Date.now();
|
|
464
|
+
bottomStarted = true;
|
|
400
465
|
try {
|
|
401
|
-
const v = answerUpward(await options.bottom(e, Object.freeze({ frames: fr, signal: dispatchAc.signal, origin })));
|
|
466
|
+
const v = answerUpward(await options.bottom(e, Object.freeze({ frames: fr, signal: dispatchAc.signal, origin })), isProxy);
|
|
402
467
|
traceOf(sink, i, "core", "core", "returned", Date.now() - t0);
|
|
403
468
|
return v;
|
|
404
469
|
}
|
|
@@ -432,7 +497,8 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
432
497
|
const name = h.reg.name;
|
|
433
498
|
const ac = new AbortController();
|
|
434
499
|
live.add(ac);
|
|
435
|
-
const
|
|
500
|
+
const budgetMs = ownMs(h.reg.budgetMs);
|
|
501
|
+
const budget = createSelfBudget(budgetMs, () => ac.abort(new Error(`${name} ran past its ${budgetMs}ms budget`)));
|
|
436
502
|
const myFrames = Object.freeze([...fr, Object.freeze({ kind: "handler", plugin: name, handler: h.index })]);
|
|
437
503
|
const state = {
|
|
438
504
|
pending: 0,
|
|
@@ -475,9 +541,9 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
475
541
|
try {
|
|
476
542
|
const raced = await Promise.race([handlerP, budget.expired]);
|
|
477
543
|
if (raced === "expired" && budget.isExpired())
|
|
478
|
-
failure = { cause: "timeout", reason: `ran past its ${
|
|
544
|
+
failure = { cause: "timeout", reason: `ran past its ${budgetMs}ms budget` };
|
|
479
545
|
else {
|
|
480
|
-
const taken = takeAnswer(raced, state, e, h);
|
|
546
|
+
const taken = takeAnswer(raced, state, e, h, i, floors);
|
|
481
547
|
if ("violation" in taken)
|
|
482
548
|
failure = { cause: "violation", reason: state.violated ?? taken.violation };
|
|
483
549
|
else if (state.violated !== undefined)
|
|
@@ -521,11 +587,14 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
521
587
|
return caught.answer;
|
|
522
588
|
}
|
|
523
589
|
if (failure.cause === "threw" && state.belowError !== undefined && failure.error === state.belowError) {
|
|
590
|
+
if (caught !== undefined)
|
|
591
|
+
report(new Error(`${name}: ${event}: ${caught.problem} — what the run below threw stands`));
|
|
524
592
|
traceOf(sink, i, name, h.reg.tier, "rejected", ms);
|
|
525
593
|
throw failure.error;
|
|
526
594
|
}
|
|
527
595
|
const reason = caught !== undefined ? `${failure.reason}; ${caught.problem}` : failure.reason;
|
|
528
|
-
|
|
596
|
+
const effectStands = st.failure === "refuse_until_run" && bottomStarted && state.last !== undefined;
|
|
597
|
+
if (refusing && !effectStands) {
|
|
529
598
|
if (failure.cause !== "violation")
|
|
530
599
|
report(new Error(`${name}: ${event}: ${reason} — failed closed: the dispatch ends here`));
|
|
531
600
|
traceOf(sink, i, name, h.reg.tier, "rejected", ms);
|
|
@@ -534,8 +603,7 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
534
603
|
}
|
|
535
604
|
skipped.push(Object.freeze({ registration: name, cause: failure.cause, reason }));
|
|
536
605
|
const effect = state.last !== undefined ? MA : HA;
|
|
537
|
-
|
|
538
|
-
report(new Error(`${name}: ${event}: ${reason} — ${effect}`));
|
|
606
|
+
report(new Error(`${name}: ${event}: ${reason} — ${effect}`));
|
|
539
607
|
if (state.last !== undefined) {
|
|
540
608
|
traceOf(sink, i, name, h.reg.tier, failure.cause === "timeout" ? "expired" : "kept", ms);
|
|
541
609
|
return state.last;
|
|
@@ -549,7 +617,8 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
549
617
|
return { problem: "no .catch" };
|
|
550
618
|
const ac = new AbortController();
|
|
551
619
|
live.add(ac);
|
|
552
|
-
const
|
|
620
|
+
const catchMs = ownMs(CATCH_BUDGET_MS);
|
|
621
|
+
const budget = createSelfBudget(catchMs, () => ac.abort(new Error(`${h.reg.name}: its .catch ran past its ${catchMs}ms budget`)));
|
|
553
622
|
let done = false;
|
|
554
623
|
let violated;
|
|
555
624
|
const replay = (passed, nextFloors) => {
|
|
@@ -570,7 +639,7 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
570
639
|
return startBelow(state, budget, i, handed.snap, nextFloors, myFrames);
|
|
571
640
|
};
|
|
572
641
|
const message = failure.cause === "threw" ? describe(failure.error) : failure.cause === "violation" ? failure.reason : undefined;
|
|
573
|
-
const error = Object.freeze({ kind: failure.cause, ...(message !== undefined ? { message } : {}), budget:
|
|
642
|
+
const error = Object.freeze({ kind: failure.cause, ...(message !== undefined ? { message } : {}), budget: catchMs });
|
|
574
643
|
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => replay(x, floors), (x, tier) => {
|
|
575
644
|
const why = nextToRefusal(h.reg.tier, tier);
|
|
576
645
|
return why !== undefined ? Promise.reject(new Error(`${h.reg.name}: ${why}`)) : replay(x, [...floors, { from: h.reg.tier, to: tier }]);
|
|
@@ -578,10 +647,10 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
578
647
|
try {
|
|
579
648
|
const raced = await Promise.race([invokeNow(() => onCatch(dollarFor(h.reg, myFrames, budget, ac.signal, engines), e, next)), budget.expired]);
|
|
580
649
|
if (raced === "expired" && budget.isExpired())
|
|
581
|
-
return { problem: `its .catch ran past its ${
|
|
650
|
+
return { problem: `its .catch ran past its ${catchMs}ms budget` };
|
|
582
651
|
if (violated !== undefined)
|
|
583
652
|
return { problem: `its .catch ${violated}` };
|
|
584
|
-
const taken = takeAnswer(raced, state, e, h);
|
|
653
|
+
const taken = takeAnswer(raced, state, e, h, i, floors);
|
|
585
654
|
return "violation" in taken ? { problem: `its .catch ${taken.violation}` } : { answer: taken.answer };
|
|
586
655
|
}
|
|
587
656
|
catch (err) {
|
|
@@ -598,7 +667,8 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
598
667
|
const name = h.reg.name;
|
|
599
668
|
const ac = new AbortController();
|
|
600
669
|
live.add(ac);
|
|
601
|
-
const
|
|
670
|
+
const budgetMs = ownMs(h.reg.budgetMs);
|
|
671
|
+
const budget = createSelfBudget(budgetMs, () => ac.abort(new Error(`${name} ran past its ${budgetMs}ms budget`)));
|
|
602
672
|
const myFrames = Object.freeze([...fr, Object.freeze({ kind: "handler", plugin: name, handler: h.index })]);
|
|
603
673
|
const refuse = () => Promise.reject(new Error(`${name}: an observe handler is not in the chain; next() is unavailable`));
|
|
604
674
|
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]) }, refuse, refuse);
|
|
@@ -610,7 +680,7 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
610
680
|
try {
|
|
611
681
|
const raced = await Promise.race([invokeNow(() => h.fn(dollarFor(h.reg, myFrames, budget, ac.signal, engines), detachedCopy(e0), next)), budget.expired]);
|
|
612
682
|
if (raced === "expired" && budget.isExpired())
|
|
613
|
-
throw new Error(`ran past its ${
|
|
683
|
+
throw new Error(`ran past its ${budgetMs}ms budget`);
|
|
614
684
|
verdict(raced);
|
|
615
685
|
}
|
|
616
686
|
catch (err) {
|
|
@@ -623,9 +693,10 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
623
693
|
budget.clear();
|
|
624
694
|
const cac = new AbortController();
|
|
625
695
|
live.add(cac);
|
|
626
|
-
const
|
|
696
|
+
const catchMs = ownMs(CATCH_BUDGET_MS);
|
|
697
|
+
const catchBudget = createSelfBudget(catchMs, () => cac.abort(new Error(`${name}: its .catch ran past its ${catchMs}ms budget`)));
|
|
627
698
|
const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]) }, refuse, refuse, {
|
|
628
|
-
error: Object.freeze({ kind: cause, ...(cause === "threw" ? { message: describe(err) } : {}), budget:
|
|
699
|
+
error: Object.freeze({ kind: cause, ...(cause === "threw" ? { message: describe(err) } : {}), budget: catchMs }),
|
|
629
700
|
called: false,
|
|
630
701
|
});
|
|
631
702
|
try {
|
|
@@ -662,7 +733,7 @@ function createBus(side, mounted, bottoms, report, records, describe, isProxy) {
|
|
|
662
733
|
if (settled)
|
|
663
734
|
return;
|
|
664
735
|
const answer = await invoke(0, e0, [], frames, root);
|
|
665
|
-
while (
|
|
736
|
+
while (refusing && pendingRuns.size > 0 && !settled)
|
|
666
737
|
await Promise.allSettled([...pendingRuns]);
|
|
667
738
|
finish({ kind: "answered", answer, ...(producers.has(answer) ? { answeredBy: producers.get(answer) } : {}), skipped: Object.freeze([...skipped]) });
|
|
668
739
|
})().catch((err) => {
|
|
@@ -10,12 +10,19 @@
|
|
|
10
10
|
* The kernel CONTRACT number — a monotonic integer, independent of the package version (the package is
|
|
11
11
|
* cut with core every release; this number is not). It is exported for a host that loads a kernel copy
|
|
12
12
|
* beside another one to compare for EQUALITY; nothing in this folder or in the engine reads it, so two
|
|
13
|
-
* copies that differ are not detected here. It is raised when, and only when, one of four things changes
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
13
|
+
* copies that differ are not detected here. It is raised when, and only when, one of four things changes —
|
|
14
|
+
* once per release, however many of them change in it:
|
|
15
|
+
* the chain semantics (`next`, `next.to`, origin, trace, re-entry frames, what a `$` call reaches — a method's
|
|
16
|
+
* chain or a callable event's host entry — what a dispatch records of its run, how answers are received and which
|
|
17
|
+
* seat's answer may stand over which), the registration form (`ModRegistration`, `on`, `uses` and which names a side
|
|
18
|
+
* takes in it), the event closed set (names and their `side`), or the failure columns (failure, abort, pinned keys,
|
|
19
|
+
* an event's own budget ceiling, whether `$` may call it — which keys, and how a pinned key is judged: by value since 2).
|
|
20
|
+
* 3: the shell's events have stations, the event-level budget and `call` columns, a `$` call of a callable event
|
|
21
|
+
* reaches the host's entry, the dispatch records whether its bottom started, a re-entered guard with no `.catch`
|
|
22
|
+
* refuses, the one side lock over `uses` and `on`, answers received as data, the seat-trust law, `prompt.mention`
|
|
23
|
+
* on the engine's side, and `tool.call` with the `refuse_until_run` failure answer, callable.
|
|
17
24
|
*/
|
|
18
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
25
|
+
export declare const KERNEL_CONTRACT_VERSION = 3;
|
|
19
26
|
/** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
|
|
20
27
|
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
21
28
|
export type ModTier = (typeof MOD_TIERS)[number];
|
|
@@ -29,9 +36,15 @@ export declare const MOD_EVENT_SIDES: readonly ["engine", "surface", "both"];
|
|
|
29
36
|
export type ModEventSide = (typeof MOD_EVENT_SIDES)[number];
|
|
30
37
|
/** A bus is one side. */
|
|
31
38
|
export type ModBusSide = Exclude<ModEventSide, "both">;
|
|
32
|
-
/**
|
|
33
|
-
|
|
39
|
+
/**
|
|
40
|
+
* What a handler's failure means for the dispatch: the station's refusal (final); skip the handler; or — on an event
|
|
41
|
+
* whose chain bottom is an effect (a tool runs) — the refusal while the bottom has not started and, once it has, what
|
|
42
|
+
* the bottom did stands (the failure is reported beside the real result, which it never replaces).
|
|
43
|
+
*/
|
|
44
|
+
export declare const MOD_FAILURE_ANSWERS: readonly ["refuse", "skip", "refuse_until_run"];
|
|
34
45
|
export type ModFailureAnswer = (typeof MOD_FAILURE_ANSWERS)[number];
|
|
46
|
+
/** Whether a failure column refuses: the events a station judges on (or runs an effect behind) fail closed. */
|
|
47
|
+
export declare function failureRefuses(failure: ModFailureAnswer): boolean;
|
|
35
48
|
/** What a cancel does to a dispatch: end it now, give it one second, or follow the calling handler. */
|
|
36
49
|
export declare const MOD_ABORT_POSTURES: readonly ["immediate", "grace", "caller"];
|
|
37
50
|
export type ModAbortPosture = (typeof MOD_ABORT_POSTURES)[number];
|
|
@@ -56,7 +69,12 @@ export declare const SEAT_TIER_TABLE: Readonly<{
|
|
|
56
69
|
tiers: readonly ["user"];
|
|
57
70
|
}>;
|
|
58
71
|
}>;
|
|
59
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* The station columns of an event a bus raises. `method` marks a `$` method (the event a `$` call raises; its chain
|
|
74
|
+
* bottom is the host's seat). `call` marks an event `$` may call: the call goes to the host's entry for the event,
|
|
75
|
+
* which runs whatever stands before it and raises it once at its own station. A row is a method, a callable event, or
|
|
76
|
+
* neither — never both.
|
|
77
|
+
*/
|
|
60
78
|
export interface ModStation {
|
|
61
79
|
readonly failure: ModFailureAnswer;
|
|
62
80
|
readonly abort: ModAbortPosture;
|
|
@@ -66,6 +84,12 @@ export interface ModStation {
|
|
|
66
84
|
readonly method?: {
|
|
67
85
|
readonly pausesCallerBudget: boolean;
|
|
68
86
|
};
|
|
87
|
+
readonly call?: {
|
|
88
|
+
readonly pausesCallerBudget: boolean;
|
|
89
|
+
};
|
|
90
|
+
/** The event's own ceiling on a handler's time: every clock a handler runs under on this event (its body, its
|
|
91
|
+
* `.catch`, an observer) is the smaller of its own and this — a registration's budget never widens it. */
|
|
92
|
+
readonly budgetMs?: number;
|
|
69
93
|
}
|
|
70
94
|
/** One event: its side, and its station when a bus raises it in this version (absent ⇒ named, not raised). */
|
|
71
95
|
export interface ModEventRow {
|
|
@@ -75,9 +99,10 @@ export interface ModEventRow {
|
|
|
75
99
|
/**
|
|
76
100
|
* Every event the kernel knows: the reference's closed set of 142 names (CC 2.1.296 `J3e` (cli296.js:238573) — its 33 `classic.*` names,
|
|
77
101
|
* its 46 engine events and its 63 `$` methods, in its own order). The shell's names (`ui.*`, `command.*`,
|
|
78
|
-
* `config.*`, `audio.*`, the prompt-box events and `prompt.read`) carry `side: "surface"
|
|
79
|
-
* buses and the shell
|
|
80
|
-
* none is named, not raised, and a registration that
|
|
102
|
+
* `config.*`, `audio.*`, the prompt-box events and `prompt.read`) carry `side: "surface"`: one table serves both
|
|
103
|
+
* buses, and the shell's stations are its rows here, raised by the shell where their chain bottoms are. A row with a
|
|
104
|
+
* station is raised on its side in this version; a name with none is named, not raised, and a registration that
|
|
105
|
+
* selects only such names is refused.
|
|
81
106
|
*/
|
|
82
107
|
export declare const MOD_EVENT_TABLE: Readonly<{
|
|
83
108
|
"classic.PreToolUse": ModEventRow;
|
|
@@ -241,5 +266,16 @@ export declare function expandModPattern(pattern: unknown): {
|
|
|
241
266
|
} | {
|
|
242
267
|
readonly refusal: string;
|
|
243
268
|
};
|
|
269
|
+
/**
|
|
270
|
+
* The names a pattern selects on a bus of `side` — the ONE side lock, read alike by `uses.events`, `uses.calls` and
|
|
271
|
+
* `on()`: an exact name the other side's bus reads (neither this side nor `both`) is refused (it is that bus's name, never
|
|
272
|
+
* usable here); a `<prefix>.*` pattern selects the names under the prefix this side reads and must select one. A name
|
|
273
|
+
* of this side that no station raises in this version is selected all the same (a forward declaration).
|
|
274
|
+
*/
|
|
275
|
+
export declare function expandOnSide(pattern: unknown, side: ModBusSide): {
|
|
276
|
+
readonly names: readonly ModEventName[];
|
|
277
|
+
} | {
|
|
278
|
+
readonly refusal: string;
|
|
279
|
+
};
|
|
244
280
|
/** A safe one-word description of a host value for a sentence (never calls the value's own toString). */
|
|
245
281
|
export declare function describe(value: unknown): string;
|