@sema-agent/core 7.51.2 → 7.52.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 +504 -2
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/read-inbox-tool.d.ts +1 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.js +6 -4
- package/dist/agents/tool-filter.d.ts +40 -13
- package/dist/agents/tool-filter.js +28 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.js +16 -12
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +4 -4
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +117 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/core/allow-entry.d.ts +40 -8
- package/dist/core/allow-entry.js +23 -16
- package/dist/core/auto-compaction.d.ts +23 -20
- package/dist/core/auto-compaction.js +37 -16
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +36 -12
- package/dist/core/checkpoint-store.js +1 -1
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +36 -19
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +5 -23
- package/dist/core/gate-lanes.js +356 -270
- package/dist/core/governance-codes.d.ts +9 -4
- package/dist/core/governance-codes.js +9 -3
- package/dist/core/hooks.d.ts +276 -734
- package/dist/core/hooks.js +97 -192
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-spec.d.ts +16 -0
- package/dist/core/mcp.d.ts +11 -7
- package/dist/core/mcp.js +11 -5
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +8 -11
- package/dist/core/memory-engine/engine.js +9 -5
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +4 -0
- package/dist/core/mode-policy.js +7 -5
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +701 -0
- package/dist/core/mods/kernel/events.d.ts +242 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +65 -0
- package/dist/core/mods/kernel/receive.js +123 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +84 -0
- package/dist/core/mods/kernel/site-rules.js +104 -0
- package/dist/core/mods/stations.d.ts +350 -0
- package/dist/core/mods/stations.js +444 -0
- package/dist/core/own-property-receipt.js +11 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +7 -1
- package/dist/core/permission-rules.js +26 -15
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retired-keys.d.ts +4 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +85 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +8 -2
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/person-path-rows.js +1 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +5 -0
- package/dist/core/runner/prepare-config-doors.js +9 -0
- package/dist/core/runner/prepare-defer-classify.js +3 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +8 -21
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
- package/dist/core/runner/prepare-policy-chain.js +95 -100
- package/dist/core/runner/prepare-project-context.js +7 -10
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +134 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +18 -19
- package/dist/core/runner/prepare-prompt-inputs.js +5 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +6 -4
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +33 -15
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -6
- package/dist/core/runner/prepare-wiring-manifest.js +7 -7
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.js +3 -1
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +62 -84
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +11 -10
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +33 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +23 -34
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +14 -72
- package/dist/core/runner/session-rule-policy.d.ts +5 -5
- package/dist/core/runner/session-rule-policy.js +13 -8
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +121 -22
- package/dist/core/runner/sub-agent-deny-lists.js +228 -71
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +20 -28
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +88 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +52 -16
- package/dist/core/session-policy-store.js +118 -28
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/task-event.d.ts +13 -3
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +59 -18
- package/dist/core/tool-policy.js +77 -12
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/user-attachment.d.ts +12 -2
- package/dist/core/user-attachment.js +17 -2
- package/dist/core/wiring-manifest.d.ts +14 -13
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +3 -3
- package/dist/engine/harness/types.d.ts +17 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.js +1 -1
- package/dist/engine/loop/types.d.ts +1 -1
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +20 -16
- package/dist/index.js +13 -11
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +37 -56
- package/dist/prompt-assembly/artifact-store.js +31 -49
- package/dist/prompt-assembly/artifact.d.ts +89 -76
- package/dist/prompt-assembly/artifact.js +167 -146
- package/dist/prompt-assembly/assemble.d.ts +34 -29
- package/dist/prompt-assembly/assemble.js +33 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +59 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +124 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +24 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +127 -0
- package/dist/prompt-assembly/overlay.js +301 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +56 -0
- package/dist/prompt-assembly/select.js +69 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -500
- package/dist/prompts/default.js +20 -285
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +242 -99
- package/wire-changes/core@7.52.0.json +5859 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mods kernel's closed vocabulary: tiers, seats, sides, the `next.to` allow table, the seat × tier
|
|
3
|
+
* table, and the ONE event table every other rule reads (which events exist, which side's bus raises
|
|
4
|
+
* them, and — for the ones a station raises — the failure, abort and pinned-key columns).
|
|
5
|
+
*
|
|
6
|
+
* Zero-dependency on purpose: this folder is compiled on its own into `@sema-agent/mods-kernel`, so the
|
|
7
|
+
* engine and the shell run the same rules. It imports nothing outside the folder.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The kernel CONTRACT number — a monotonic integer, independent of the package version (the package is
|
|
11
|
+
* cut with core every release; this number is not). Every party that loads a kernel copy compares it for
|
|
12
|
+
* EQUALITY. It is raised when, and only when, one of four things changes: the chain semantics (`next`,
|
|
13
|
+
* `next.to`, origin, trace, re-entry frames), the registration form (`ModRegistration`, `on`, `uses`),
|
|
14
|
+
* the event closed set (names and their `side`), or the failure columns (failure, abort, pinned keys).
|
|
15
|
+
*/
|
|
16
|
+
export declare const KERNEL_CONTRACT_VERSION = 1;
|
|
17
|
+
/** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
|
|
18
|
+
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
19
|
+
export type ModTier = (typeof MOD_TIERS)[number];
|
|
20
|
+
/** The tiers a registration may stand in. */
|
|
21
|
+
export type ModRegistrationTier = Exclude<ModTier, "builtin" | "core">;
|
|
22
|
+
/** Where a registration came from: the deployment's deps or the task's spec — listed most trusted first. */
|
|
23
|
+
export declare const MOD_SEATS: readonly ["deployment", "task"];
|
|
24
|
+
export type ModSeat = (typeof MOD_SEATS)[number];
|
|
25
|
+
/** Which bus raises an event: the engine's, the shell's, or each its own. */
|
|
26
|
+
export declare const MOD_EVENT_SIDES: readonly ["engine", "surface", "both"];
|
|
27
|
+
export type ModEventSide = (typeof MOD_EVENT_SIDES)[number];
|
|
28
|
+
/** A bus is one side. */
|
|
29
|
+
export type ModBusSide = Exclude<ModEventSide, "both">;
|
|
30
|
+
/** What a handler's failure means for the dispatch: the station's refusal (final), or skip the handler. */
|
|
31
|
+
export declare const MOD_FAILURE_ANSWERS: readonly ["refuse", "skip"];
|
|
32
|
+
export type ModFailureAnswer = (typeof MOD_FAILURE_ANSWERS)[number];
|
|
33
|
+
/** What a cancel does to a dispatch: end it now, give it one second, or follow the calling handler. */
|
|
34
|
+
export declare const MOD_ABORT_POSTURES: readonly ["immediate", "grace", "caller"];
|
|
35
|
+
export type ModAbortPosture = (typeof MOD_ABORT_POSTURES)[number];
|
|
36
|
+
/** `next.to(e, to)` from a handler in tier `from` is allowed iff `to` is in `NEXT_TO_TABLE[from]` (CC `pvt`). */
|
|
37
|
+
export declare const NEXT_TO_TABLE: Readonly<{
|
|
38
|
+
prepend: readonly ["append", "builtin", "core"];
|
|
39
|
+
user: readonly [];
|
|
40
|
+
append: readonly ["core"];
|
|
41
|
+
builtin: readonly [];
|
|
42
|
+
core: readonly [];
|
|
43
|
+
}>;
|
|
44
|
+
/** Why `next.to(e, to)` from `from` is refused, or undefined when the table allows it. */
|
|
45
|
+
export declare function nextToRefusal(from: ModTier, to: unknown): string | undefined;
|
|
46
|
+
/** Which tiers each seat may declare, and whether it must declare one (absent ⇒ the first listed). */
|
|
47
|
+
export declare const SEAT_TIER_TABLE: Readonly<{
|
|
48
|
+
deployment: Readonly<{
|
|
49
|
+
declared: "required";
|
|
50
|
+
tiers: readonly ["prepend", "user", "append"];
|
|
51
|
+
}>;
|
|
52
|
+
task: Readonly<{
|
|
53
|
+
declared: "optional";
|
|
54
|
+
tiers: readonly ["user"];
|
|
55
|
+
}>;
|
|
56
|
+
}>;
|
|
57
|
+
/** The station columns of an event a bus raises. `method` marks a `$` method (the event a `$` call raises). */
|
|
58
|
+
export interface ModStation {
|
|
59
|
+
readonly failure: ModFailureAnswer;
|
|
60
|
+
readonly abort: ModAbortPosture;
|
|
61
|
+
/** Keys a handler may not change when it passes `e` on through `next`. */
|
|
62
|
+
readonly pinned: readonly string[];
|
|
63
|
+
readonly method?: {
|
|
64
|
+
readonly pausesCallerBudget: boolean;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** One event: its side, and its station when a bus raises it in this version (absent ⇒ named, not raised). */
|
|
68
|
+
export interface ModEventRow {
|
|
69
|
+
readonly side: ModEventSide;
|
|
70
|
+
readonly station?: ModStation;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 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,
|
|
74
|
+
* its 46 engine events and its 63 `$` methods, in its own order). The shell's names (`ui.*`, `command.*`,
|
|
75
|
+
* `config.*`, `audio.*`, the prompt-box events and `prompt.read`) carry `side: "surface"`, so one table serves both
|
|
76
|
+
* buses and the shell fills their stations. A row with a station is raised on its side in this version; a name with
|
|
77
|
+
* none is named, not raised, and a registration that selects only such names is refused.
|
|
78
|
+
*/
|
|
79
|
+
export declare const MOD_EVENT_TABLE: Readonly<{
|
|
80
|
+
"classic.PreToolUse": ModEventRow;
|
|
81
|
+
"classic.PostToolUse": ModEventRow;
|
|
82
|
+
"classic.PostToolUseFailure": ModEventRow;
|
|
83
|
+
"classic.PostToolBatch": ModEventRow;
|
|
84
|
+
"classic.Notification": ModEventRow;
|
|
85
|
+
"classic.UserPromptSubmit": ModEventRow;
|
|
86
|
+
"classic.UserPromptExpansion": ModEventRow;
|
|
87
|
+
"classic.SessionStart": ModEventRow;
|
|
88
|
+
"classic.SessionEnd": ModEventRow;
|
|
89
|
+
"classic.Stop": ModEventRow;
|
|
90
|
+
"classic.StopFailure": ModEventRow;
|
|
91
|
+
"classic.SubagentStart": ModEventRow;
|
|
92
|
+
"classic.SubagentStop": ModEventRow;
|
|
93
|
+
"classic.PreCompact": ModEventRow;
|
|
94
|
+
"classic.PostCompact": ModEventRow;
|
|
95
|
+
"classic.PreModelSwitch": ModEventRow;
|
|
96
|
+
"classic.PostModelSwitch": ModEventRow;
|
|
97
|
+
"classic.PermissionRequest": ModEventRow;
|
|
98
|
+
"classic.PermissionDenied": ModEventRow;
|
|
99
|
+
"classic.Setup": ModEventRow;
|
|
100
|
+
"classic.TeammateIdle": ModEventRow;
|
|
101
|
+
"classic.TaskCreated": ModEventRow;
|
|
102
|
+
"classic.TaskCompleted": ModEventRow;
|
|
103
|
+
"classic.Elicitation": ModEventRow;
|
|
104
|
+
"classic.ElicitationResult": ModEventRow;
|
|
105
|
+
"classic.ConfigChange": ModEventRow;
|
|
106
|
+
"classic.WorktreeCreate": ModEventRow;
|
|
107
|
+
"classic.WorktreeRemove": ModEventRow;
|
|
108
|
+
"classic.InstructionsLoaded": ModEventRow;
|
|
109
|
+
"classic.CwdChanged": ModEventRow;
|
|
110
|
+
"classic.FileChanged": ModEventRow;
|
|
111
|
+
"classic.DirectoryAdded": ModEventRow;
|
|
112
|
+
"classic.MessageDisplay": ModEventRow;
|
|
113
|
+
"tool.call": ModEventRow;
|
|
114
|
+
"tool.check": ModEventRow;
|
|
115
|
+
"ui.render": ModEventRow;
|
|
116
|
+
"ui.resolve": ModEventRow;
|
|
117
|
+
"ui.press": ModEventRow;
|
|
118
|
+
"ui.input": ModEventRow;
|
|
119
|
+
"ui.select": ModEventRow;
|
|
120
|
+
"ui.message": ModEventRow;
|
|
121
|
+
"ui.fault": ModEventRow;
|
|
122
|
+
"ui.scroll": ModEventRow;
|
|
123
|
+
"ui.focus": ModEventRow;
|
|
124
|
+
"agent.offer": ModEventRow;
|
|
125
|
+
"agent.spawn": ModEventRow;
|
|
126
|
+
"prompt.submit": ModEventRow;
|
|
127
|
+
"prompt.fill": ModEventRow;
|
|
128
|
+
"prompt.suggest": ModEventRow;
|
|
129
|
+
"prompt.edit": ModEventRow;
|
|
130
|
+
"prompt.autocomplete": ModEventRow;
|
|
131
|
+
"prompt.section": ModEventRow;
|
|
132
|
+
"prompt.context": ModEventRow;
|
|
133
|
+
"prompt.attachment": ModEventRow;
|
|
134
|
+
"prompt.mention": ModEventRow;
|
|
135
|
+
"prompt.compose": ModEventRow;
|
|
136
|
+
"tool.describe": ModEventRow;
|
|
137
|
+
"command.run": ModEventRow;
|
|
138
|
+
"command.describe": ModEventRow;
|
|
139
|
+
"config.set": ModEventRow;
|
|
140
|
+
"config.describe": ModEventRow;
|
|
141
|
+
"telemetry.log": ModEventRow;
|
|
142
|
+
"telemetry.mark": ModEventRow;
|
|
143
|
+
"skill.prompt": ModEventRow;
|
|
144
|
+
"attribution.text": ModEventRow;
|
|
145
|
+
"session.start": ModEventRow;
|
|
146
|
+
"session.receive": ModEventRow;
|
|
147
|
+
"session.append": ModEventRow;
|
|
148
|
+
"session.send": ModEventRow;
|
|
149
|
+
"session.compact": ModEventRow;
|
|
150
|
+
"session.attach": ModEventRow;
|
|
151
|
+
"session.detach": ModEventRow;
|
|
152
|
+
"session.measure": ModEventRow;
|
|
153
|
+
"session.end": ModEventRow;
|
|
154
|
+
"plugin.register": Readonly<{
|
|
155
|
+
side: "both";
|
|
156
|
+
station: ModStation;
|
|
157
|
+
}>;
|
|
158
|
+
"turn.start": ModEventRow;
|
|
159
|
+
"turn.step": ModEventRow;
|
|
160
|
+
"turn.complete": ModEventRow;
|
|
161
|
+
"engine.create": ModEventRow;
|
|
162
|
+
"model.complete": ModEventRow;
|
|
163
|
+
"model.classify": ModEventRow;
|
|
164
|
+
"model.fork": ModEventRow;
|
|
165
|
+
"audio.play": ModEventRow;
|
|
166
|
+
"audio.speak": ModEventRow;
|
|
167
|
+
"mcp.call": ModEventRow;
|
|
168
|
+
"mcp.connect": ModEventRow;
|
|
169
|
+
"session.cwd": ModEventRow;
|
|
170
|
+
"session.root": ModEventRow;
|
|
171
|
+
"session.model": ModEventRow;
|
|
172
|
+
"session.turns": ModEventRow;
|
|
173
|
+
"session.id": ModEventRow;
|
|
174
|
+
"session.messages": ModEventRow;
|
|
175
|
+
"session.repo": ModEventRow;
|
|
176
|
+
"session.surface": ModEventRow;
|
|
177
|
+
"session.surfaces": ModEventRow;
|
|
178
|
+
"session.authorize": ModEventRow;
|
|
179
|
+
"session.usage": ModEventRow;
|
|
180
|
+
"session.version": ModEventRow;
|
|
181
|
+
"turn.abort": ModEventRow;
|
|
182
|
+
"prompt.read": ModEventRow;
|
|
183
|
+
"flag.value": ModEventRow;
|
|
184
|
+
"tool.list": ModEventRow;
|
|
185
|
+
"tool.register": ModEventRow;
|
|
186
|
+
"command.list": ModEventRow;
|
|
187
|
+
"command.register": ModEventRow;
|
|
188
|
+
"config.list": ModEventRow;
|
|
189
|
+
"agent.list": ModEventRow;
|
|
190
|
+
"agent.register": ModEventRow;
|
|
191
|
+
"ui.toast": ModEventRow;
|
|
192
|
+
"ui.status": ModEventRow;
|
|
193
|
+
"ui.log": ModEventRow;
|
|
194
|
+
"ui.notice": ModEventRow;
|
|
195
|
+
"ui.invalidate": ModEventRow;
|
|
196
|
+
"ui.open": ModEventRow;
|
|
197
|
+
"ui.close": ModEventRow;
|
|
198
|
+
"ui.panes": ModEventRow;
|
|
199
|
+
"ui.selection": ModEventRow;
|
|
200
|
+
"ui.copy": ModEventRow;
|
|
201
|
+
"ui.notify": ModEventRow;
|
|
202
|
+
"ui.blit": ModEventRow;
|
|
203
|
+
"fs.read": ModEventRow;
|
|
204
|
+
"fs.write": ModEventRow;
|
|
205
|
+
"fs.list": ModEventRow;
|
|
206
|
+
"fs.exists": ModEventRow;
|
|
207
|
+
"fs.stat": ModEventRow;
|
|
208
|
+
"fs.ancestors": ModEventRow;
|
|
209
|
+
"store.get": ModEventRow;
|
|
210
|
+
"store.set": ModEventRow;
|
|
211
|
+
"store.delete": ModEventRow;
|
|
212
|
+
"store.keys": ModEventRow;
|
|
213
|
+
"state.get": ModEventRow;
|
|
214
|
+
"state.set": ModEventRow;
|
|
215
|
+
"clock.now": ModEventRow;
|
|
216
|
+
"clock.sleep": ModEventRow;
|
|
217
|
+
"clock.after": ModEventRow;
|
|
218
|
+
"clock.every": ModEventRow;
|
|
219
|
+
"http.fetch": ModEventRow;
|
|
220
|
+
"process.run": ModEventRow;
|
|
221
|
+
"process.spawn": ModEventRow;
|
|
222
|
+
"settings.read": ModEventRow;
|
|
223
|
+
"env.get": ModEventRow;
|
|
224
|
+
"env.set": ModEventRow;
|
|
225
|
+
}>;
|
|
226
|
+
export type ModEventName = keyof typeof MOD_EVENT_TABLE;
|
|
227
|
+
export declare function isModEventName(name: unknown): name is ModEventName;
|
|
228
|
+
/** The row's station when a bus of `side` raises it; undefined otherwise. */
|
|
229
|
+
export declare function stationOn(name: ModEventName, side: ModBusSide): ModStation | undefined;
|
|
230
|
+
/** Whether a bus of `side` reads `name` at all (its own side or both). */
|
|
231
|
+
export declare function readOnSide(name: ModEventName, side: ModBusSide): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* The known names a pattern selects: an exact name, or `<prefix>.*` for every name under the prefix.
|
|
234
|
+
* A pattern that selects no known name is refused (a typo is not an empty declaration).
|
|
235
|
+
*/
|
|
236
|
+
export declare function expandModPattern(pattern: unknown): {
|
|
237
|
+
readonly names: readonly ModEventName[];
|
|
238
|
+
} | {
|
|
239
|
+
readonly refusal: string;
|
|
240
|
+
};
|
|
241
|
+
/** A safe one-word description of a host value for a sentence (never calls the value's own toString). */
|
|
242
|
+
export declare function describe(value: unknown): string;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 1;
|
|
2
|
+
export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
|
|
3
|
+
export const MOD_SEATS = Object.freeze(["deployment", "task"]);
|
|
4
|
+
export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
|
|
5
|
+
export const MOD_FAILURE_ANSWERS = Object.freeze(["refuse", "skip"]);
|
|
6
|
+
export const MOD_ABORT_POSTURES = Object.freeze(["immediate", "grace", "caller"]);
|
|
7
|
+
export const NEXT_TO_TABLE = Object.freeze({
|
|
8
|
+
prepend: Object.freeze(["append", "builtin", "core"]),
|
|
9
|
+
user: Object.freeze([]),
|
|
10
|
+
append: Object.freeze(["core"]),
|
|
11
|
+
builtin: Object.freeze([]),
|
|
12
|
+
core: Object.freeze([]),
|
|
13
|
+
});
|
|
14
|
+
const CONTINUABLE = NEXT_TO_TABLE.prepend;
|
|
15
|
+
export function nextToRefusal(from, to) {
|
|
16
|
+
const allowed = NEXT_TO_TABLE[from];
|
|
17
|
+
const named = CONTINUABLE.find((t) => t === to);
|
|
18
|
+
if (named === undefined)
|
|
19
|
+
return `next.to names ${describe(to)}, which is not a tier a dispatch continues at (${CONTINUABLE.join(", ")})`;
|
|
20
|
+
if (allowed.length === 0)
|
|
21
|
+
return `next.to is available to prepend and append handlers only, not to a ${from} handler`;
|
|
22
|
+
if (!allowed.includes(named))
|
|
23
|
+
return `next.to("${named}") skips nothing from ${from}; a ${from} handler may continue at ${allowed.join(", ")}`;
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
export const SEAT_TIER_TABLE = Object.freeze({
|
|
27
|
+
deployment: Object.freeze({ declared: "required", tiers: Object.freeze(["prepend", "user", "append"]) }),
|
|
28
|
+
task: Object.freeze({ declared: "optional", tiers: Object.freeze(["user"]) }),
|
|
29
|
+
});
|
|
30
|
+
const station = (failure, abort, pinned = []) => Object.freeze({ failure, abort, pinned: Object.freeze([...pinned]) });
|
|
31
|
+
const method = (pausesCallerBudget) => Object.freeze({ failure: "skip", abort: "caller", pinned: Object.freeze([]), method: Object.freeze({ pausesCallerBudget }) });
|
|
32
|
+
const engine = (s) => Object.freeze(s === undefined ? { side: "engine" } : { side: "engine", station: s });
|
|
33
|
+
const surface = Object.freeze({ side: "surface" });
|
|
34
|
+
export const MOD_EVENT_TABLE = Object.freeze({
|
|
35
|
+
"classic.PreToolUse": engine(station("refuse", "immediate", ["tool", "tool_use_id", "agentId", "input"])),
|
|
36
|
+
"classic.PostToolUse": engine(station("skip", "grace")),
|
|
37
|
+
"classic.PostToolUseFailure": engine(station("skip", "grace")),
|
|
38
|
+
"classic.PostToolBatch": engine(station("skip", "grace")),
|
|
39
|
+
"classic.Notification": engine(),
|
|
40
|
+
"classic.UserPromptSubmit": engine(station("refuse", "immediate", ["source", "inputId", "actor", "prompt"])),
|
|
41
|
+
"classic.UserPromptExpansion": engine(),
|
|
42
|
+
"classic.SessionStart": engine(),
|
|
43
|
+
"classic.SessionEnd": engine(),
|
|
44
|
+
"classic.Stop": engine(station("skip", "immediate")),
|
|
45
|
+
"classic.StopFailure": engine(station("skip", "grace")),
|
|
46
|
+
"classic.SubagentStart": engine(),
|
|
47
|
+
"classic.SubagentStop": engine(station("skip", "immediate")),
|
|
48
|
+
"classic.PreCompact": engine(station("skip", "grace")),
|
|
49
|
+
"classic.PostCompact": engine(station("skip", "grace")),
|
|
50
|
+
"classic.PreModelSwitch": engine(),
|
|
51
|
+
"classic.PostModelSwitch": engine(),
|
|
52
|
+
"classic.PermissionRequest": engine(),
|
|
53
|
+
"classic.PermissionDenied": engine(station("skip", "grace")),
|
|
54
|
+
"classic.Setup": engine(),
|
|
55
|
+
"classic.TeammateIdle": engine(),
|
|
56
|
+
"classic.TaskCreated": engine(),
|
|
57
|
+
"classic.TaskCompleted": engine(),
|
|
58
|
+
"classic.Elicitation": engine(),
|
|
59
|
+
"classic.ElicitationResult": engine(),
|
|
60
|
+
"classic.ConfigChange": engine(),
|
|
61
|
+
"classic.WorktreeCreate": engine(),
|
|
62
|
+
"classic.WorktreeRemove": engine(),
|
|
63
|
+
"classic.InstructionsLoaded": engine(),
|
|
64
|
+
"classic.CwdChanged": engine(),
|
|
65
|
+
"classic.FileChanged": engine(),
|
|
66
|
+
"classic.DirectoryAdded": engine(),
|
|
67
|
+
"classic.MessageDisplay": engine(),
|
|
68
|
+
"tool.call": engine(),
|
|
69
|
+
"tool.check": engine(station("refuse", "immediate", ["tool", "input", "tool_use_id", "agentId", "ceiling"])),
|
|
70
|
+
"ui.render": surface,
|
|
71
|
+
"ui.resolve": surface,
|
|
72
|
+
"ui.press": surface,
|
|
73
|
+
"ui.input": surface,
|
|
74
|
+
"ui.select": surface,
|
|
75
|
+
"ui.message": surface,
|
|
76
|
+
"ui.fault": surface,
|
|
77
|
+
"ui.scroll": surface,
|
|
78
|
+
"ui.focus": surface,
|
|
79
|
+
"agent.offer": engine(),
|
|
80
|
+
"agent.spawn": engine(),
|
|
81
|
+
"prompt.submit": engine(),
|
|
82
|
+
"prompt.fill": surface,
|
|
83
|
+
"prompt.suggest": surface,
|
|
84
|
+
"prompt.edit": surface,
|
|
85
|
+
"prompt.autocomplete": surface,
|
|
86
|
+
"prompt.section": engine(station("skip", "grace", ["name", "key", "mountedTools"])),
|
|
87
|
+
"prompt.context": engine(),
|
|
88
|
+
"prompt.attachment": engine(),
|
|
89
|
+
"prompt.mention": surface,
|
|
90
|
+
"prompt.compose": engine(station("skip", "grace", ["model"])),
|
|
91
|
+
"tool.describe": engine(),
|
|
92
|
+
"command.run": surface,
|
|
93
|
+
"command.describe": surface,
|
|
94
|
+
"config.set": surface,
|
|
95
|
+
"config.describe": surface,
|
|
96
|
+
"telemetry.log": engine(),
|
|
97
|
+
"telemetry.mark": engine(),
|
|
98
|
+
"skill.prompt": engine(),
|
|
99
|
+
"attribution.text": engine(),
|
|
100
|
+
"session.start": engine(),
|
|
101
|
+
"session.receive": engine(),
|
|
102
|
+
"session.append": engine(),
|
|
103
|
+
"session.send": engine(),
|
|
104
|
+
"session.compact": engine(),
|
|
105
|
+
"session.attach": engine(),
|
|
106
|
+
"session.detach": engine(),
|
|
107
|
+
"session.measure": engine(),
|
|
108
|
+
"session.end": engine(),
|
|
109
|
+
"plugin.register": Object.freeze({ side: "both", station: station("skip", "immediate", ["name", "seat", "tier", "uses"]) }),
|
|
110
|
+
"turn.start": engine(),
|
|
111
|
+
"turn.step": engine(),
|
|
112
|
+
"turn.complete": engine(),
|
|
113
|
+
"engine.create": engine(),
|
|
114
|
+
"model.complete": engine(method(true)),
|
|
115
|
+
"model.classify": engine(),
|
|
116
|
+
"model.fork": engine(),
|
|
117
|
+
"audio.play": surface,
|
|
118
|
+
"audio.speak": surface,
|
|
119
|
+
"mcp.call": engine(),
|
|
120
|
+
"mcp.connect": engine(),
|
|
121
|
+
"session.cwd": engine(method(true)),
|
|
122
|
+
"session.root": engine(method(true)),
|
|
123
|
+
"session.model": engine(method(true)),
|
|
124
|
+
"session.turns": engine(),
|
|
125
|
+
"session.id": engine(method(true)),
|
|
126
|
+
"session.messages": engine(method(true)),
|
|
127
|
+
"session.repo": engine(),
|
|
128
|
+
"session.surface": engine(),
|
|
129
|
+
"session.surfaces": engine(),
|
|
130
|
+
"session.authorize": engine(),
|
|
131
|
+
"session.usage": engine(),
|
|
132
|
+
"session.version": engine(),
|
|
133
|
+
"turn.abort": engine(),
|
|
134
|
+
"prompt.read": surface,
|
|
135
|
+
"flag.value": engine(),
|
|
136
|
+
"tool.list": engine(method(true)),
|
|
137
|
+
"tool.register": engine(),
|
|
138
|
+
"command.list": surface,
|
|
139
|
+
"command.register": surface,
|
|
140
|
+
"config.list": surface,
|
|
141
|
+
"agent.list": engine(method(true)),
|
|
142
|
+
"agent.register": engine(),
|
|
143
|
+
"ui.toast": surface,
|
|
144
|
+
"ui.status": surface,
|
|
145
|
+
"ui.log": surface,
|
|
146
|
+
"ui.notice": surface,
|
|
147
|
+
"ui.invalidate": surface,
|
|
148
|
+
"ui.open": surface,
|
|
149
|
+
"ui.close": surface,
|
|
150
|
+
"ui.panes": surface,
|
|
151
|
+
"ui.selection": surface,
|
|
152
|
+
"ui.copy": surface,
|
|
153
|
+
"ui.notify": surface,
|
|
154
|
+
"ui.blit": surface,
|
|
155
|
+
"fs.read": engine(),
|
|
156
|
+
"fs.write": engine(),
|
|
157
|
+
"fs.list": engine(),
|
|
158
|
+
"fs.exists": engine(),
|
|
159
|
+
"fs.stat": engine(),
|
|
160
|
+
"fs.ancestors": engine(),
|
|
161
|
+
"store.get": engine(),
|
|
162
|
+
"store.set": engine(),
|
|
163
|
+
"store.delete": engine(),
|
|
164
|
+
"store.keys": engine(),
|
|
165
|
+
"state.get": engine(),
|
|
166
|
+
"state.set": engine(),
|
|
167
|
+
"clock.now": engine(method(false)),
|
|
168
|
+
"clock.sleep": engine(method(false)),
|
|
169
|
+
"clock.after": engine(),
|
|
170
|
+
"clock.every": engine(),
|
|
171
|
+
"http.fetch": engine(),
|
|
172
|
+
"process.run": engine(method(true)),
|
|
173
|
+
"process.spawn": engine(),
|
|
174
|
+
"settings.read": engine(),
|
|
175
|
+
"env.get": engine(),
|
|
176
|
+
"env.set": engine(),
|
|
177
|
+
});
|
|
178
|
+
const EVENT_NAMES = Object.freeze(Object.keys(MOD_EVENT_TABLE).filter(isModEventName));
|
|
179
|
+
export function isModEventName(name) {
|
|
180
|
+
return typeof name === "string" && Object.prototype.hasOwnProperty.call(MOD_EVENT_TABLE, name);
|
|
181
|
+
}
|
|
182
|
+
export function stationOn(name, side) {
|
|
183
|
+
const row = MOD_EVENT_TABLE[name];
|
|
184
|
+
return row.side === side || row.side === "both" ? row.station : undefined;
|
|
185
|
+
}
|
|
186
|
+
export function readOnSide(name, side) {
|
|
187
|
+
const row = MOD_EVENT_TABLE[name];
|
|
188
|
+
return row.side === side || row.side === "both";
|
|
189
|
+
}
|
|
190
|
+
export function expandModPattern(pattern) {
|
|
191
|
+
if (typeof pattern !== "string" || pattern === "")
|
|
192
|
+
return { refusal: `${describe(pattern)} is not an event name or a "<prefix>.*" pattern` };
|
|
193
|
+
if (pattern.endsWith(".*")) {
|
|
194
|
+
const prefix = pattern.slice(0, -2);
|
|
195
|
+
if (prefix === "" || prefix.includes("*"))
|
|
196
|
+
return { refusal: `"${pattern}" is not an event name or a "<prefix>.*" pattern` };
|
|
197
|
+
const names = EVENT_NAMES.filter((n) => n.startsWith(`${prefix}.`));
|
|
198
|
+
return names.length > 0 ? { names } : { refusal: `"${pattern}" selects no event` };
|
|
199
|
+
}
|
|
200
|
+
return isModEventName(pattern) ? { names: [pattern] } : { refusal: `"${pattern}" is not an event` };
|
|
201
|
+
}
|
|
202
|
+
export function describe(value) {
|
|
203
|
+
if (typeof value === "string")
|
|
204
|
+
return `"${value}"`;
|
|
205
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
206
|
+
return String(value);
|
|
207
|
+
if (value === null)
|
|
208
|
+
return "null";
|
|
209
|
+
return typeof value === "object" ? (Array.isArray(value) ? "an array" : "an object") : typeof value;
|
|
210
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The package entry of `@sema-agent/mods-kernel`; core reads the same modules directly. */
|
|
2
|
+
export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAILURE_ANSWERS, MOD_ABORT_POSTURES, NEXT_TO_TABLE, SEAT_TIER_TABLE, MOD_EVENT_TABLE, nextToRefusal, expandModPattern, isModEventName, stationOn, readOnSide, type ModTier, type ModRegistrationTier, type ModSeat, type ModEventSide, type ModBusSide, type ModFailureAnswer, type ModAbortPosture, type ModStation, type ModEventRow, type ModEventName, } from "./events.js";
|
|
3
|
+
export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, resolveModBudgetMs, type ModBudgetReading, } from "./budget.js";
|
|
4
|
+
export { MOD_FAILURE_CAUSES, type ModFailureCause, type ModEventPayload, type ModAnswerCheck, type ModAnswerer, type ModMatcher, type ModSkip } from "./site-rules.js";
|
|
5
|
+
export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, type ModTraceOutcome, type ModUses, type ModOrigin, type ModPluginFacts, type ModDollarBase, type ModTraceEntry, type ModCaughtError, type ModNext, type ModHandler, type ModHandlerOptions, type On, type ModRegistration, type ModAdmissionRecord, type ModSeats, } from "./registration.js";
|
|
6
|
+
export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModDispatchOutcome, type ModDispatchOptions, type ModBus, type ModMountedHandler, type ModBusInput, } from "./dispatch.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAILURE_ANSWERS, MOD_ABORT_POSTURES, NEXT_TO_TABLE, SEAT_TIER_TABLE, MOD_EVENT_TABLE, nextToRefusal, expandModPattern, isModEventName, stationOn, readOnSide, } from "./events.js";
|
|
2
|
+
export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, resolveModBudgetMs, } from "./budget.js";
|
|
3
|
+
export { MOD_FAILURE_CAUSES } from "./site-rules.js";
|
|
4
|
+
export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, } from "./registration.js";
|
|
5
|
+
export { admitMods, } from "./dispatch.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE receipt of a caller's object: how a value someone else's code built becomes a value the receiver owns.
|
|
3
|
+
* Every reader of a caller's object reads it here — a constructor's configuration (`new Runner`'s deps, a brain's
|
|
4
|
+
* config), a station's answer record, a mods handler's payload and answer — each with its own mode, never its own
|
|
5
|
+
* copy of the walk.
|
|
6
|
+
*
|
|
7
|
+
* The walk: a primitive is itself. A CONTAINER — an ordinary record (prototype `Object.prototype` or none) or an
|
|
8
|
+
* ordinary array — within `depth` levels is copied member by member off its own property descriptors, captured in
|
|
9
|
+
* one call before any of the caller's code can run; each member lands as an enumerable data property of the copy (a
|
|
10
|
+
* defined property, never an assignment, so an own `__proto__` key stays a plain key). Anything else — a function, an
|
|
11
|
+
* object of another prototype, a container past `depth` — is handed as it is or refused, by `others`, which also
|
|
12
|
+
* says whether cycles and shared references keep their shape or are refused / walked again.
|
|
13
|
+
*
|
|
14
|
+
* Zero-dependency on purpose (this folder compiles on its own): a Proxy cannot be recognised from here, so the
|
|
15
|
+
* host passes its probe (`isProxy`); with a probe, a Proxy is refused before anything is asked of it.
|
|
16
|
+
*/
|
|
17
|
+
/** How a receipt reads. */
|
|
18
|
+
export interface ReceiptMode {
|
|
19
|
+
/**
|
|
20
|
+
* `call-once`: every own string-keyed member is read — a data property's value, or an accessor's getter called exactly
|
|
21
|
+
* once on the object (a getter that throws refuses the receipt; one that moves the object's prototype refuses it).
|
|
22
|
+
* `refuse`: only own enumerable string-keyed DATA properties are members; an accessor, a non-enumerable property or
|
|
23
|
+
* a symbol-keyed one refuses the receipt (no getter ever runs).
|
|
24
|
+
*/
|
|
25
|
+
readonly accessors: "call-once" | "refuse";
|
|
26
|
+
/** How many levels of containers are copied (`Infinity` = every level). */
|
|
27
|
+
readonly depth: number;
|
|
28
|
+
/** What a value that is not copied is (a function, another prototype, a container past `depth`, a symbol or a
|
|
29
|
+
* bigint): handed as it is, or a refusal of the receipt. Shared references keep their shape in the copy (one copy
|
|
30
|
+
* each); under `as-is` a cycle does too, under `refuse` a cycle is refused and a shared reference must fit `depth`
|
|
31
|
+
* where it sits each time it is met. */
|
|
32
|
+
readonly others: "as-is" | "refuse";
|
|
33
|
+
/** Every container the copy makes is frozen (a received value cannot be changed after it was received). */
|
|
34
|
+
readonly freeze?: boolean;
|
|
35
|
+
/** The host's Proxy probe. */
|
|
36
|
+
readonly isProxy?: (value: object) => boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Why a receipt was refused. */
|
|
39
|
+
export declare const RECEIPT_FAULTS: readonly ["proxy", "accessor", "hidden", "getter-threw", "prototype-moved", "not-data", "cycle", "too-deep", "uncopyable"];
|
|
40
|
+
export type ReceiptFaultKind = (typeof RECEIPT_FAULTS)[number];
|
|
41
|
+
/** A refusal and where in the value it was met (member names from the top). */
|
|
42
|
+
export interface ReceiptFault {
|
|
43
|
+
readonly kind: ReceiptFaultKind;
|
|
44
|
+
readonly path: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
export type Receipt = {
|
|
47
|
+
readonly ok: true;
|
|
48
|
+
readonly value: unknown;
|
|
49
|
+
} | {
|
|
50
|
+
readonly ok: false;
|
|
51
|
+
readonly fault: ReceiptFault;
|
|
52
|
+
};
|
|
53
|
+
/** Whether `v` is an ordinary record: an object whose prototype is `Object.prototype` or none (an array is not one). */
|
|
54
|
+
export declare function isPlainRecord(v: unknown): v is Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Receive `value` by `mode`. `held` names objects the reader already owns: met in the walk, each is kept as itself
|
|
57
|
+
* (not received again) — so a member handed back unchanged keeps its identity.
|
|
58
|
+
*/
|
|
59
|
+
export declare function receive(value: unknown, mode: ReceiptMode, held?: Iterable<unknown>): Receipt;
|
|
60
|
+
/** The mods bus's mode: a payload and an answer received whole — no accessor runs, no depth limit, cycles and shared
|
|
61
|
+
* references kept, a function or a class instance handed as it is, every copied container frozen (so a member the
|
|
62
|
+
* bus holds cannot be changed under it by a handler that holds it too). */
|
|
63
|
+
export declare const MODS_PAYLOAD_MODE: ReceiptMode;
|
|
64
|
+
/** One clause naming a fault for a sentence ("an accessor at input.deep.x"). */
|
|
65
|
+
export declare function describeFault(fault: ReceiptFault): string;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export const RECEIPT_FAULTS = Object.freeze(["proxy", "accessor", "hidden", "getter-threw", "prototype-moved", "not-data", "cycle", "too-deep", "uncopyable"]);
|
|
2
|
+
export function isPlainRecord(v) {
|
|
3
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
4
|
+
return false;
|
|
5
|
+
const proto = Object.getPrototypeOf(v);
|
|
6
|
+
return proto === Object.prototype || proto === null;
|
|
7
|
+
}
|
|
8
|
+
function isOrdinaryArray(v) {
|
|
9
|
+
return Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype;
|
|
10
|
+
}
|
|
11
|
+
export function receive(value, mode, held) {
|
|
12
|
+
const seen = new Map();
|
|
13
|
+
if (held !== undefined)
|
|
14
|
+
for (const h of held)
|
|
15
|
+
if (typeof h === "object" && h !== null)
|
|
16
|
+
seen.set(h, h);
|
|
17
|
+
const path = [];
|
|
18
|
+
const open = new Set();
|
|
19
|
+
const heights = new Map();
|
|
20
|
+
const refuse = (kind) => {
|
|
21
|
+
throw { refused: Object.freeze({ kind, path: Object.freeze([...path]) }) };
|
|
22
|
+
};
|
|
23
|
+
const other = (v, kind) => (mode.others === "as-is" ? v : refuse(kind));
|
|
24
|
+
const walk = (v, level) => {
|
|
25
|
+
if (v === null || v === undefined || typeof v === "string" || typeof v === "number" || typeof v === "boolean")
|
|
26
|
+
return v;
|
|
27
|
+
if (typeof v !== "object")
|
|
28
|
+
return other(v, "not-data");
|
|
29
|
+
if (seen.has(v)) {
|
|
30
|
+
if (open.has(v))
|
|
31
|
+
return mode.others === "refuse" ? refuse("cycle") : seen.get(v);
|
|
32
|
+
if (mode.others === "refuse" && level + (heights.get(v) ?? 1) > mode.depth)
|
|
33
|
+
return refuse("too-deep");
|
|
34
|
+
return seen.get(v);
|
|
35
|
+
}
|
|
36
|
+
if (level >= mode.depth)
|
|
37
|
+
return other(v, "too-deep");
|
|
38
|
+
if (mode.isProxy?.(v) === true)
|
|
39
|
+
return refuse("proxy");
|
|
40
|
+
const list = isOrdinaryArray(v);
|
|
41
|
+
if (!list && !isPlainRecord(v))
|
|
42
|
+
return other(v, "not-data");
|
|
43
|
+
const proto = Object.getPrototypeOf(v);
|
|
44
|
+
const captured = Object.getOwnPropertyDescriptors(v);
|
|
45
|
+
const out = list ? [] : {};
|
|
46
|
+
seen.set(v, out);
|
|
47
|
+
open.add(v);
|
|
48
|
+
let height = 1;
|
|
49
|
+
if (mode.accessors === "refuse" && Object.getOwnPropertySymbols(captured).length > 0)
|
|
50
|
+
refuse("hidden");
|
|
51
|
+
for (const key of Object.getOwnPropertyNames(captured)) {
|
|
52
|
+
if (list && key === "length")
|
|
53
|
+
continue;
|
|
54
|
+
const d = captured[key];
|
|
55
|
+
path.push(key);
|
|
56
|
+
let member;
|
|
57
|
+
if (Object.hasOwn(d, "value")) {
|
|
58
|
+
if (mode.accessors === "refuse" && d.enumerable !== true)
|
|
59
|
+
refuse("hidden");
|
|
60
|
+
member = d.value;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
if (mode.accessors === "refuse")
|
|
64
|
+
refuse("accessor");
|
|
65
|
+
const get = Object.hasOwn(d, "get") ? d.get : undefined;
|
|
66
|
+
try {
|
|
67
|
+
member = get === undefined ? undefined : get.call(v);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return refuse("getter-threw");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
Object.defineProperty(out, key, { value: walk(member, level + 1), enumerable: true, writable: true, configurable: true });
|
|
74
|
+
if (typeof member === "object" && member !== null)
|
|
75
|
+
height = Math.max(height, (heights.get(member) ?? 0) + 1);
|
|
76
|
+
path.pop();
|
|
77
|
+
}
|
|
78
|
+
heights.set(v, height);
|
|
79
|
+
if (mode.accessors === "call-once" && Object.getPrototypeOf(v) !== proto)
|
|
80
|
+
refuse("prototype-moved");
|
|
81
|
+
if (Array.isArray(out)) {
|
|
82
|
+
const length = captured["length"]?.value;
|
|
83
|
+
if (typeof length === "number")
|
|
84
|
+
out.length = length;
|
|
85
|
+
}
|
|
86
|
+
if (mode.freeze === true)
|
|
87
|
+
Object.freeze(out);
|
|
88
|
+
open.delete(v);
|
|
89
|
+
return out;
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
return { ok: true, value: walk(value, 0) };
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (typeof err === "object" && err !== null && "refused" in err)
|
|
96
|
+
return { ok: false, fault: err.refused };
|
|
97
|
+
return { ok: false, fault: Object.freeze({ kind: "uncopyable", path: Object.freeze([...path]) }) };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export const MODS_PAYLOAD_MODE = Object.freeze({ accessors: "refuse", depth: Infinity, others: "as-is", freeze: true });
|
|
101
|
+
export function describeFault(fault) {
|
|
102
|
+
const at = fault.path.length > 0 ? ` at ${fault.path.join(".")}` : "";
|
|
103
|
+
switch (fault.kind) {
|
|
104
|
+
case "proxy":
|
|
105
|
+
return `a Proxy${at}`;
|
|
106
|
+
case "accessor":
|
|
107
|
+
return `an accessor${at} (a getter is never run)`;
|
|
108
|
+
case "hidden":
|
|
109
|
+
return `a member that is not an enumerable data property${at}`;
|
|
110
|
+
case "getter-threw":
|
|
111
|
+
return `a getter that threw${at}`;
|
|
112
|
+
case "prototype-moved":
|
|
113
|
+
return `a prototype that moved while it was read${at}`;
|
|
114
|
+
case "not-data":
|
|
115
|
+
return `a value that is not data${at}`;
|
|
116
|
+
case "cycle":
|
|
117
|
+
return `a cycle${at}`;
|
|
118
|
+
case "too-deep":
|
|
119
|
+
return `a value nested too deep${at}`;
|
|
120
|
+
case "uncopyable":
|
|
121
|
+
return `a value that could not be copied whole${at}`;
|
|
122
|
+
}
|
|
123
|
+
}
|