@sema-agent/core 7.51.1 → 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 +550 -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.d.ts +5 -0
- package/dist/agents/subagent.js +7 -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 +42 -8
- package/dist/core/allow-entry.js +24 -17
- 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/locked-config.d.ts +26 -5
- package/dist/core/locked-config.js +31 -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 +53 -7
- package/dist/core/mcp-server-spec.js +84 -1
- package/dist/core/mcp.d.ts +11 -7
- package/dist/core/mcp.js +27 -9
- 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 +18 -16
- package/dist/core/runner/prepare-policy-chain.js +98 -101
- 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 +6 -4
- package/dist/core/runner/session-rule-policy.js +17 -10
- 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 +93 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +93 -17
- package/dist/core/session-policy-store.js +178 -25
- 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/types.d.ts +2 -1
- package/dist/core/types.js +1 -0
- 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 +24 -17
- package/dist/index.js +15 -12
- 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/stores/file/session-policy-store.d.ts +3 -3
- 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 +256 -99
- package/wire-changes/core@7.51.1.json +5 -5
- package/wire-changes/core@7.51.2.json +293 -0
- 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
|
@@ -1,101 +1,137 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
|
|
3
3
|
import { assemblePrompt } from "../../prompt-assembly/assemble.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { adoptCenter, centerOverlaysOf } from "../../prompt-assembly/artifact.js";
|
|
5
|
+
import { catalogDigestOf, digestOf, prepareEpochRecord } from "../../prompt-assembly/epoch.js";
|
|
6
|
+
import { rendererVector } from "../../prompt-assembly/renderers.js";
|
|
7
|
+
import { SEMA_DEFAULT_CATALOG } from "../../prompt-assembly/catalog/index.js";
|
|
8
|
+
import { describeCatalog } from "../../prompt-assembly/explain.js";
|
|
9
|
+
import { selectorsOf } from "../../prompt-assembly/select.js";
|
|
7
10
|
import { auditToolCollisions, projectToolManifest } from "../../prompt-assembly/tool-catalog.js";
|
|
8
|
-
import { buildEnvironmentContext
|
|
11
|
+
import { buildEnvironmentContext } from "../../prompts/default.js";
|
|
12
|
+
import { raisePromptCompose } from "../mods/stations.js";
|
|
9
13
|
import { protocolOf } from "../protocol-table.js";
|
|
10
|
-
import { reminderMarkDeclaration } from "../reminder-mint.js";
|
|
11
14
|
import { hasConversationContent } from "../session.js";
|
|
12
15
|
import { PROMPT_HASH_SALT } from "./prompt-hash-salt.js";
|
|
16
|
+
const CATALOG_DIGEST = catalogDigestOf(SEMA_DEFAULT_CATALOG);
|
|
17
|
+
function taskLayerOf(task) {
|
|
18
|
+
return task.map(({ overlay: o, origin }) => ({
|
|
19
|
+
by: origin.by,
|
|
20
|
+
id: o.id,
|
|
21
|
+
op: o.op,
|
|
22
|
+
target: o.target,
|
|
23
|
+
...(o.text !== undefined ? { chars: o.text.length } : {}),
|
|
24
|
+
...(o.message !== undefined ? { message: o.message } : {}),
|
|
25
|
+
...(o.when !== undefined ? { when: o.when } : {}),
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
13
28
|
export async function preparePromptAssembly(input) {
|
|
14
|
-
const { session, deps, internals, resume,
|
|
29
|
+
const { session, deps, internals, resume, sugar, host, binding, modBus, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptProfile, fableMitigations, tools, model, sessionId, onceLedger } = input;
|
|
30
|
+
const topLevel = internals?.parentTaskId === undefined && internals?.parentSessionId === undefined && internals?.parentCenterArtifactDigest === undefined;
|
|
31
|
+
const stored = await session.getPromptEpoch();
|
|
15
32
|
let centerAdoption;
|
|
16
|
-
let centerAdoptionFresh = false;
|
|
17
33
|
{
|
|
18
|
-
const failUnavailable = (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
const failUnavailable = (what) => {
|
|
35
|
+
throw Object.assign(new Error(`prompt snapshot unavailable: ${what} (artifact source miss / not verifiable here${deps.promptSource === undefined ? "; RunnerDeps.promptSource is not configured" : ""}) — refusing to recompose a hybrid prompt`), { code: "prompt.snapshot_unavailable" });
|
|
36
|
+
};
|
|
37
|
+
const resolvePinned = async (digest, sourceRevision, via) => {
|
|
38
|
+
const art = await deps.promptSource?.get(digest);
|
|
39
|
+
const adopted = art !== undefined ? adoptCenter(art, sourceRevision) : undefined;
|
|
40
|
+
return adopted ?? failUnavailable(`${via} center prompt artifact ${digest.slice(0, 23)}… has no verified resolvable copy`);
|
|
22
41
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
failUnavailable(pinnedEarly.centerArtifactDigest, "this session is pinned to");
|
|
28
|
-
centerAdoption = { artifact: art, ...(pinnedEarly.sourceRevision !== undefined ? { sourceRevision: pinnedEarly.sourceRevision } : {}) };
|
|
42
|
+
const pinned = stored?.kind === "pin" ? stored.descriptor : undefined;
|
|
43
|
+
const retiredCenterPin = stored?.kind === "legacy" && stored.centerPinned;
|
|
44
|
+
if (pinned?.layers.center !== undefined) {
|
|
45
|
+
centerAdoption = await resolvePinned(pinned.layers.center, pinned.sourceRevision, "this session is pinned to");
|
|
29
46
|
}
|
|
30
|
-
else if (
|
|
47
|
+
else if (retiredCenterPin && topLevel) {
|
|
48
|
+
const state = deps.promptSource?.sourceState() ?? "unavailable";
|
|
49
|
+
if (state === "unavailable")
|
|
50
|
+
failUnavailable("this session's center pin is of a retired shape and the center source has no verified state; the pin is kept");
|
|
51
|
+
if (state === "active") {
|
|
52
|
+
const cand = deps.promptSource.current();
|
|
53
|
+
centerAdoption = (cand !== undefined ? adoptCenter(cand, cand.sourceRevision) : undefined) ?? failUnavailable("this session's center pin is of a retired shape and the current candidate");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (stored === undefined || retiredCenterPin) {
|
|
31
57
|
if (internals?.parentCenterArtifactDigest !== undefined) {
|
|
32
|
-
|
|
33
|
-
if (art === undefined)
|
|
34
|
-
failUnavailable(internals.parentCenterArtifactDigest, "the spawning parent adopted");
|
|
35
|
-
centerAdoption = {
|
|
36
|
-
artifact: art,
|
|
37
|
-
...(internals.parentCenterSourceRevision !== undefined ? { sourceRevision: internals.parentCenterSourceRevision } : {}),
|
|
38
|
-
};
|
|
58
|
+
centerAdoption = await resolvePinned(internals.parentCenterArtifactDigest, internals.parentCenterSourceRevision, "the spawning parent adopted");
|
|
39
59
|
}
|
|
40
|
-
else if (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
centerAdoption =
|
|
44
|
-
|
|
60
|
+
else if (stored === undefined && topLevel && resume === undefined) {
|
|
61
|
+
const cand = deps.promptSource?.current();
|
|
62
|
+
if (cand !== undefined && !hasConversationContent(await session.getBranch())) {
|
|
63
|
+
centerAdoption = adoptCenter(cand, cand.sourceRevision);
|
|
64
|
+
if (centerAdoption === undefined)
|
|
65
|
+
deps.onError?.(new Error(`center prompt candidate ${cand.artifactDigest.slice(0, 23)}… does not verify on this engine; the session starts with no center layer`), { phase: "prompt-constitution", sessionId });
|
|
45
66
|
}
|
|
46
67
|
}
|
|
47
68
|
}
|
|
48
69
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
70
|
+
const facts = {
|
|
71
|
+
supervisorEnabled: false,
|
|
72
|
+
teammateEnabled: internals?.explicitAgentName !== undefined && tools.some((t) => t.name === SEND_MESSAGE_TOOL_NAME),
|
|
73
|
+
...featureFlags,
|
|
74
|
+
orchestrationEnabled: featureFlags.orchestrationEnabled && tools.some((t) => t.name === "Workflow"),
|
|
75
|
+
orchestrationDeferred: featureFlags.orchestrationDeferred && tools.some((t) => t.name === "Workflow"),
|
|
76
|
+
promptProfile,
|
|
77
|
+
fableMitigations,
|
|
78
|
+
};
|
|
79
|
+
const selectors = selectorsOf(facts, host);
|
|
80
|
+
const selectorRecord = {
|
|
81
|
+
...(binding !== undefined ? { binding } : {}),
|
|
82
|
+
traits: [...selectors.traits].sort(),
|
|
83
|
+
host: { role: selectors.host.role, form: selectors.host.form },
|
|
84
|
+
facts: { ...selectors.facts },
|
|
85
|
+
};
|
|
86
|
+
const centerOverlays = centerOverlaysOf(centerAdoption, binding);
|
|
87
|
+
const lowerAdds = new Map();
|
|
88
|
+
for (const { overlay } of [...sugar, ...centerOverlays])
|
|
89
|
+
if (overlay.op === "add")
|
|
90
|
+
lowerAdds.set(overlay.id, overlay.target);
|
|
91
|
+
const composed = await raisePromptCompose(modBus, {
|
|
92
|
+
model: model.id,
|
|
93
|
+
catalog: describeCatalog().sections,
|
|
94
|
+
selectors: { traits: [...selectors.traits], host: selectors.host, facts: selectors.facts },
|
|
95
|
+
}, { lowerAdds, ...(input.signal !== undefined ? { signal: input.signal } : {}) });
|
|
96
|
+
for (const w of composed.warnings)
|
|
97
|
+
deps.onError?.(new Error(w), { phase: "prompt-constitution", sessionId });
|
|
98
|
+
const taskOverlays = [...sugar, ...composed.task];
|
|
99
|
+
const buildAssembleInputs = (center) => ({
|
|
100
|
+
taskOverlays,
|
|
101
|
+
centerOverlays: centerOverlaysOf(center, binding),
|
|
102
|
+
deployOverlays: composed.deploy,
|
|
103
|
+
host,
|
|
104
|
+
tools,
|
|
105
|
+
facts,
|
|
106
|
+
...(envFacts.cwd !== undefined ? { workspaceFolder: envFacts.cwd } : {}),
|
|
64
107
|
mcpInstructionsBlock,
|
|
65
108
|
memoryBlock,
|
|
66
109
|
buildEnvBlock: (date) => buildEnvironmentContext({ ...envFacts, date }) || undefined,
|
|
67
110
|
date: envFacts.date,
|
|
68
|
-
envFacts,
|
|
69
111
|
...(model.promptGuidance && model.promptGuidance.length > 0 ? { modelGuidance: model.promptGuidance.join("\n\n") } : {}),
|
|
70
112
|
onWarn: (message, phase) => deps.onError?.(new Error(message), { phase, sessionId }),
|
|
71
|
-
...(centerDecls !== undefined ? { centerDeclarations: centerDecls } : {}),
|
|
72
113
|
});
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
114
|
+
const deployLayer = composed.deploy.length > 0 ? digestOf(composed.deploy.map(({ overlay, origin }) => ({ by: origin.by, overlay }))) : undefined;
|
|
115
|
+
const taskLayer = taskOverlays.length > 0 ? digestOf(taskLayerOf(taskOverlays)) : undefined;
|
|
116
|
+
const bindingLayer = digestOf(selectorRecord);
|
|
117
|
+
const renderers = rendererVector();
|
|
118
|
+
const identityFor = (center) => ({
|
|
119
|
+
layers: {
|
|
120
|
+
catalog: CATALOG_DIGEST,
|
|
121
|
+
renderers,
|
|
122
|
+
...(center !== undefined ? { center: center.artifact.artifactDigest } : {}),
|
|
123
|
+
...(deployLayer !== undefined ? { deploy: deployLayer } : {}),
|
|
124
|
+
...(taskLayer !== undefined ? { task: taskLayer } : {}),
|
|
125
|
+
binding: bindingLayer,
|
|
126
|
+
},
|
|
127
|
+
...(center?.sourceRevision !== undefined ? { sourceRevision: center.sourceRevision } : {}),
|
|
128
|
+
});
|
|
129
|
+
const assembled = assemblePrompt(buildAssembleInputs(centerAdoption));
|
|
88
130
|
let systemPrompt = assembled.systemPrompt;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
? (date) => {
|
|
94
|
-
systemPrompt = assembled.renderWithDate(date);
|
|
95
|
-
return systemPrompt;
|
|
96
|
-
}
|
|
97
|
-
: undefined;
|
|
98
|
-
const promptConstitution = assembled.constitution;
|
|
131
|
+
const renderWithDate = (date) => {
|
|
132
|
+
systemPrompt = assembled.renderWithDate(date);
|
|
133
|
+
return systemPrompt;
|
|
134
|
+
};
|
|
99
135
|
const promptBlocks = assembled.blocks;
|
|
100
136
|
const collisionAudit = auditToolCollisions(tools);
|
|
101
137
|
for (const y of collisionAudit.yields) {
|
|
@@ -104,38 +140,34 @@ export async function preparePromptAssembly(input) {
|
|
|
104
140
|
for (const c of collisionAudit.aliasCollisions) {
|
|
105
141
|
onceLedger.onError(new Error(`tool mount: alias "${c.alias}" is claimed by both "${c.owners[0]}" and "${c.owners[1]}" (design/141 warn face — name resolution serves the later mount)`), { phase: "config", sessionId });
|
|
106
142
|
}
|
|
143
|
+
const promptIdentity = identityFor(centerAdoption);
|
|
144
|
+
const priorConversation = stored === undefined ? hasConversationContent(await session.getBranch()) : true;
|
|
145
|
+
const record = prepareEpochRecord(stored, promptIdentity.layers, { priorConversation, ...(promptIdentity.sourceRevision !== undefined ? { sourceRevision: promptIdentity.sourceRevision } : {}) });
|
|
146
|
+
if (record !== undefined)
|
|
147
|
+
await session.appendPromptEpoch(record);
|
|
148
|
+
const current = record ?? (stored?.kind === "pin" ? stored.descriptor : undefined);
|
|
107
149
|
const saltedHash = (text) => createHash("sha256").update(PROMPT_HASH_SALT).update(text).digest("hex").slice(0, 12);
|
|
150
|
+
const contentHashOf = (s) => s.renderer !== undefined || s.chain.some((l) => l.source === "task")
|
|
151
|
+
? `salted:${createHash("sha256").update(PROMPT_HASH_SALT).update(s.text).digest("hex")}`
|
|
152
|
+
: `sha256:${createHash("sha256").update(s.text).digest("hex")}`;
|
|
108
153
|
const promptManifest = {
|
|
109
|
-
|
|
154
|
+
identity: { artifact: current.identity, layers: current.layers, epoch: current.epoch, activatedBy: current.activatedBy },
|
|
155
|
+
selectors: selectorRecord,
|
|
110
156
|
blocks: promptBlocks.map((b) => ({ id: b.id, chars: b.text.length, hash: saltedHash(b.text) })),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
:
|
|
157
|
+
sections: assembled.sections.map((s) => ({
|
|
158
|
+
id: s.id,
|
|
159
|
+
band: s.band,
|
|
160
|
+
rank: s.rank,
|
|
161
|
+
...(s.variant !== undefined ? { variant: s.variant } : {}),
|
|
162
|
+
...(s.renderer !== undefined ? { renderer: { ...s.renderer } } : {}),
|
|
163
|
+
chars: s.text.length,
|
|
164
|
+
locale: s.chain.some((l) => l.source !== "bundled" && l.superseded !== true) ? "overlay" : "canonical",
|
|
165
|
+
contentHash: contentHashOf(s),
|
|
166
|
+
chain: s.chain.map((l) => ({ ...l })),
|
|
167
|
+
})),
|
|
168
|
+
...(assembled.superseded.length > 0 ? { superseded: assembled.superseded.map((s) => ({ ...s })) } : {}),
|
|
114
169
|
tools: projectToolManifest(tools, (t) => protocolOf(t.name)?.id ?? "caller"),
|
|
115
170
|
};
|
|
116
|
-
const epochDeclaredSections = (assembled.sections ?? [])
|
|
117
|
-
.filter((s) => s.origin === "provider")
|
|
118
|
-
.map((s) => ({ id: s.id, slot: s.slot, chars: s.text.length, ...(s.declaredContentHash !== undefined ? { contentHash: s.declaredContentHash } : {}) }));
|
|
119
|
-
let epochArtifactDigestForSnapshot = "";
|
|
120
|
-
{
|
|
121
|
-
const pinned = await session.getPromptEpoch();
|
|
122
|
-
const resolved = resolveEpochAgainstBundled(pinned, SEMA_DEFAULT_PACK, epochDeclaredSections);
|
|
123
|
-
epochArtifactDigestForSnapshot = resolved.descriptor.artifactDigest;
|
|
124
|
-
if (resolved.migrated) {
|
|
125
|
-
const priorConversation = pinned === undefined ? hasConversationContent(await session.getBranch()) : true;
|
|
126
|
-
const activatedBy = pinned === undefined && !priorConversation ? "session_start" : "legacy_migration";
|
|
127
|
-
await session.appendPromptEpoch({
|
|
128
|
-
...resolved.descriptor,
|
|
129
|
-
activatedBy,
|
|
130
|
-
...(centerAdoption !== undefined
|
|
131
|
-
? {
|
|
132
|
-
centerArtifactDigest: centerAdoption.artifact.artifactDigest,
|
|
133
|
-
...(centerAdoption.sourceRevision !== undefined ? { sourceRevision: centerAdoption.sourceRevision } : {}),
|
|
134
|
-
}
|
|
135
|
-
: {}),
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
171
|
return {
|
|
140
172
|
systemPromptSeat: {
|
|
141
173
|
get current() {
|
|
@@ -148,9 +180,10 @@ export async function preparePromptAssembly(input) {
|
|
|
148
180
|
renderWithDate,
|
|
149
181
|
systemBlocks: assembled.systemBlocks,
|
|
150
182
|
promptManifest,
|
|
151
|
-
|
|
152
|
-
epochArtifactDigestForSnapshot,
|
|
183
|
+
promptIdentity,
|
|
153
184
|
buildAssembleInputs,
|
|
185
|
+
identityFor,
|
|
186
|
+
adoptsCandidates: topLevel,
|
|
154
187
|
centerAdoptionRef: {
|
|
155
188
|
get current() {
|
|
156
189
|
return centerAdoption;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PrepareTask's PROMPT-INPUTS phase: the
|
|
3
|
-
*
|
|
4
|
-
* the
|
|
2
|
+
* PrepareTask's PROMPT-INPUTS phase: the runtime feature flags the harness-context block gates on (so it never
|
|
3
|
+
* claims a mechanism the task lacks), the request-body sugar's overlays (the task's role text and appended block),
|
|
4
|
+
* the fenced MCP server-instructions
|
|
5
5
|
* block, the environment facts (client zone + date basis, knowledge cutoff, the deployment's sandbox
|
|
6
6
|
* axes, resume-continuity facts on a durable-resume leg only, the hands facts + the one batched env
|
|
7
7
|
* probe with its cwd/pwd alignment guard) and the git-status lane probe. The body is moved verbatim
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
* Nothing here throws on its own: the env probe and the alignment guard are best-effort (a stub/odd env
|
|
20
20
|
* just omits the shell-derived facts), and the git lane degrades through `onDegrade` → `deps.onError`.
|
|
21
21
|
*/
|
|
22
|
+
import type { LegModBus } from "../mods/stations.js";
|
|
22
23
|
import type { ExecutionEnv, ThinkingLevel } from "../../internal/harness.js";
|
|
23
24
|
import type { Model } from "../../internal/llm.js";
|
|
24
|
-
import { type EnvironmentFacts
|
|
25
|
+
import { type EnvironmentFacts } from "../../prompts/default.js";
|
|
26
|
+
import type { SourcedOverlay } from "../../prompt-assembly/overlay.js";
|
|
25
27
|
import type { ContainmentFace } from "../../tools/fs/index.js";
|
|
26
28
|
import type { LockedPreflight } from "../locked-config.js";
|
|
27
29
|
import type { MaterializedMcp } from "../mcp.js";
|
|
@@ -33,14 +35,15 @@ import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
|
33
35
|
import { type GitStatusLaneRef } from "./git-status-frame.js";
|
|
34
36
|
import { type ContextWindowOverlay } from "../context-settings.js";
|
|
35
37
|
export interface PreparePromptInputsInput {
|
|
36
|
-
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
spec: Pick<TaskSpec, "
|
|
40
|
-
/** borrowed-readonly — deployment deps: `
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `systemPrompt` / `appendSystemPrompt` (handed whole to the
|
|
39
|
+
* request-body sugar), `clientContext` (zone, email), `envFacts` (the deployment's sandbox + resume facts),
|
|
40
|
+
* `compaction` (the within-task flag). Never mutated. */
|
|
41
|
+
spec: Pick<TaskSpec, "systemPrompt" | "appendSystemPrompt" | "clientContext" | "envFacts" | "compaction">;
|
|
42
|
+
/** borrowed-readonly — deployment deps: `onError` (the operator lane: fail-closed advisory, cwd misalignment,
|
|
43
|
+
* git-lane degrade), `modelKnowledgeCutoffs`. Receiver preserved (`deps.onError?.(…)`). */
|
|
44
|
+
deps: Pick<RunnerDeps, "onError" | "modelKnowledgeCutoffs">;
|
|
45
|
+
/** borrowed-readonly — the leg's mods bus (the harness-context block's "hooks may intercept" claim reads it). */
|
|
46
|
+
modBus: LegModBus;
|
|
44
47
|
/** borrowed-readonly — the self-orchestration fail-closed advisory (null = nothing to announce),
|
|
45
48
|
* evaluated by the DRIVER against the whole spec/deps (see the module header). */
|
|
46
49
|
failClosedReason: string | null;
|
|
@@ -65,7 +68,7 @@ export interface PreparePromptInputsInput {
|
|
|
65
68
|
/** borrowed-readonly — the fable-mitigations profile axis (rides the flags with the profile). */
|
|
66
69
|
fableMitigations: boolean;
|
|
67
70
|
/** borrowed-readonly — trusted internals: `goalMode` (goal flag), `isolation` (worktree flag),
|
|
68
|
-
* `defaultSystemPrompt` (the third
|
|
71
|
+
* `defaultSystemPrompt` (the sugar's third source). `undefined` on a standalone prepare. */
|
|
69
72
|
internals: Pick<RunInternals, "goalMode" | "isolation" | "defaultSystemPrompt"> | undefined;
|
|
70
73
|
/** borrowed-readonly — the resolved, role-folded reasoning tier (the awareness flag's input). */
|
|
71
74
|
thinking: ThinkingLevel | undefined;
|
|
@@ -111,14 +114,10 @@ export interface PreparePromptInputsInput {
|
|
|
111
114
|
contextOverlay?: ContextWindowOverlay;
|
|
112
115
|
}
|
|
113
116
|
export interface PreparePromptInputsResult {
|
|
114
|
-
/** owned — the prompt provider in force (`spec` ?? `deps` ?? the default). */
|
|
115
|
-
provider: PromptProvider;
|
|
116
117
|
/** owned — the runtime feature flags (see {@link PromptFeatureFlags}). */
|
|
117
118
|
featureFlags: PromptFeatureFlags;
|
|
118
|
-
/** owned — the
|
|
119
|
-
|
|
120
|
-
/** owned — the caller's append block (`spec.appendSystemPrompt`). */
|
|
121
|
-
userAppendSystemPrompt: string | undefined;
|
|
119
|
+
/** owned — the request-body sugar's overlays (the task class's first contributions), in application order. */
|
|
120
|
+
sugar: readonly SourcedOverlay[];
|
|
122
121
|
/** owned — the fenced MCP server-instructions block, or undefined when no server declared any. */
|
|
123
122
|
mcpInstructionsBlock: string | undefined;
|
|
124
123
|
/** owned — the environment facts the env tail renders from. Filled here; no later phase writes it
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { formatLocalDate, isValidTimeZone
|
|
1
|
+
import { formatLocalDate, isValidTimeZone } from "../../prompts/default.js";
|
|
2
|
+
import { sugarOverlays } from "../../prompt-assembly/sugar.js";
|
|
2
3
|
import { isIsolated } from "../remote-env.js";
|
|
3
4
|
import { readDateAnchor } from "./announce-once-ledger.js";
|
|
4
5
|
import { probeGitStatusLane } from "./git-status-frame.js";
|
|
@@ -7,10 +8,8 @@ const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
|
|
|
7
8
|
import { compactionEnabled } from "../context-settings.js";
|
|
8
9
|
export async function preparePromptInputs(input) {
|
|
9
10
|
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, promptProfile, fableMitigations, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, session, advertisedWritableDirs } = input;
|
|
10
|
-
const provider = promptProviderInForce(spec.promptProvider, deps.promptProvider);
|
|
11
11
|
const promptPolicyEnabled = Boolean(lockedPreflight.toolPolicy);
|
|
12
|
-
const
|
|
13
|
-
const promptHooksEnabled = Boolean(promptHooks?.preToolUse || promptHooks?.postToolUse);
|
|
12
|
+
const promptHooksEnabled = input.modBus.hasHandlers("classic.PreToolUse") || input.modBus.hasHandlers("classic.PostToolUse");
|
|
14
13
|
if (failClosedReason) {
|
|
15
14
|
deps.onError?.(new Error(failClosedReason), { phase: "config", sessionId });
|
|
16
15
|
}
|
|
@@ -31,8 +30,7 @@ export async function preparePromptInputs(input) {
|
|
|
31
30
|
withinTaskCompactionEnabled: compactionEnabled(spec.compaction?.enabled, input.contextOverlay) && (spec.compaction?.withinTask ?? true),
|
|
32
31
|
isSubagent: delegation.isNonForkChild,
|
|
33
32
|
};
|
|
34
|
-
const
|
|
35
|
-
const userAppendSystemPrompt = spec.appendSystemPrompt;
|
|
33
|
+
const sugar = sugarOverlays({ spec, resolvedRole, ...(internals !== undefined ? { internals } : {}) });
|
|
36
34
|
const mcpInstructionsBlock = mcp.serverInstructions.length
|
|
37
35
|
? `# MCP Server Instructions\n${mcp.serverInstructions.map(renderMcpInstructionsEntry).join("\n\n")}`
|
|
38
36
|
: undefined;
|
|
@@ -143,5 +141,5 @@ export async function preparePromptInputs(input) {
|
|
|
143
141
|
taskRoot: taskRootFinal,
|
|
144
142
|
onDegrade: (reason) => deps.onError?.(new Error(`env git snapshot degraded — ${reason}`), { phase: "degraded", sessionId, classification: "env-git-snapshot" }),
|
|
145
143
|
});
|
|
146
|
-
return {
|
|
144
|
+
return { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz, dateAnchor, gitStatusRef };
|
|
147
145
|
}
|
|
@@ -30,18 +30,20 @@ import type { LockedPreflight } from "../locked-config.js";
|
|
|
30
30
|
import type { RunnerDeps, TaskSpec, ToolEffect } from "../types.js";
|
|
31
31
|
import type { AnnounceOnceSink, IrreversibilityTier, Prepared, RollbackStack, ToolFaceSnapshot } from "./contracts.js";
|
|
32
32
|
import { RosterBuilder, type ToolRosterDeltaSeat } from "../tool-roster.js";
|
|
33
|
+
import type { LegModBus } from "../mods/stations.js";
|
|
33
34
|
export interface PrepareProtocolToolsInput {
|
|
34
35
|
/** borrowed-readonly — the frozen preflight; only `mcp` (the declared server entries) is read: the
|
|
35
36
|
* materialize input, the RefreshMcpTools mount predicate, and whether a real client was acquired. */
|
|
36
37
|
lockedPreflight: Pick<LockedPreflight, "mcp">;
|
|
37
38
|
/** borrowed-readonly — the REBOUND spec. Read: `principal` (the MCP header / the A2A identity), `tools`
|
|
38
|
-
* (the caller names both reserved-name guards check against), `a2a` (the peer entries)
|
|
39
|
-
|
|
40
|
-
spec: Pick<TaskSpec, "principal" | "tools" | "a2a" | "promptProvider">;
|
|
39
|
+
* (the caller names both reserved-name guards check against), `a2a` (the peer entries). */
|
|
40
|
+
spec: Pick<TaskSpec, "principal" | "tools" | "a2a">;
|
|
41
41
|
/** borrowed-readonly — the deployment seats the materializers and their operator faces read: `onElicit`
|
|
42
42
|
* and `mcpImageResizer` ride into the MCP intake; `onError` takes the A2A warnings (no ledger — a peer is
|
|
43
43
|
* re-read every prepare); `mcpRevocations` + `onNotice` make the revocation wiring. */
|
|
44
|
-
deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice"
|
|
44
|
+
deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice">;
|
|
45
|
+
/** borrowed-readonly — the leg's mods bus: its `prompt.section` station disposes of each server's instructions at the dial. */
|
|
46
|
+
modBus: LegModBus;
|
|
45
47
|
/** borrowed-readonly — the run tree's MCP connection pool (the leg leases its connections from it) and whether THIS leg created it
|
|
46
48
|
* (then this leg's dispose also closes it). Absent for a leg that declares no server. */
|
|
47
49
|
mcpPool?: {
|
|
@@ -9,7 +9,7 @@ import { REFRESH_MCP_TOOLS_TOOL_NAME, toolFace } from "../tool-catalog-entries.j
|
|
|
9
9
|
import { MCP_NAMESPACE, A2A_NAMESPACE } from "../protocol-table.js";
|
|
10
10
|
import { mintNamespacePrefix } from "../protocol-naming.js";
|
|
11
11
|
import { applyMcpToolFaces } from "./tool-face-overlay.js";
|
|
12
|
-
import {
|
|
12
|
+
import { sectionDisposerOf } from "../prompt-section-seat.js";
|
|
13
13
|
import { thrownText } from "../thrown-value.js";
|
|
14
14
|
export async function prepareProtocolTools(input) {
|
|
15
15
|
const { lockedPreflight, spec, deps, mcpPool, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback } = input;
|
|
@@ -25,7 +25,7 @@ export async function prepareProtocolTools(input) {
|
|
|
25
25
|
throw Object.assign(new Error(`MCP server name ${JSON.stringify(overPeer.name.slice(0, 40) + "…")} is ${overPeer.name.length} characters; a peer rides every roster row of its tools and the roster's bound on a name is ${TOOL_WIRE_NAME_MAX_CHARS}.`), { code: "config.tool_name_too_long" });
|
|
26
26
|
}
|
|
27
27
|
const mcp = lockedPreflight.mcp?.length
|
|
28
|
-
? await materializeMcpTools(lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned },
|
|
28
|
+
? await materializeMcpTools(lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned }, sectionDisposerOf(input.modBus, abortController.signal))
|
|
29
29
|
:
|
|
30
30
|
{ tools: [], toolAxes: [], warnings: [], serverInstructions: [], instructionsDelta: { pendingAdds: [], pendingRemovals: [] }, droppedTools: [], statuses: [], refresh: async () => [], reconnect: async (server) => ({ server, prefix: mintNamespacePrefix(MCP_NAMESPACE, server), outcome: "not_declared", reason: "this task declared no MCP servers", toolCount: 0, added: [], removed: [] }), dispose: async () => { } };
|
|
31
31
|
if (lockedPreflight.mcp?.length)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { callerToolNameProblem } from "../caller-tool-name.js";
|
|
2
2
|
import { engineCardTypes, handBandEffects } from "../tool-registry.js";
|
|
3
3
|
import { callerCardIdOf, offendingResultCard, rosterMemberBoundProblem, schemaKeyBoundProblem, survivorsByName } from "../tool-roster.js";
|
|
4
4
|
import { toolFaceProblem } from "./tool-face-overlay.js";
|
|
@@ -65,18 +65,14 @@ export function prepareSafetyScan(input) {
|
|
|
65
65
|
throw e;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
68
|
+
for (const [what, n] of [["name", t.name], ...(t.aliases ?? []).map((a) => ["alias", a])]) {
|
|
69
|
+
const problem = callerToolNameProblem(n);
|
|
70
|
+
if (problem === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
const e = new Error(`Tool ${what} ${JSON.stringify(n)}${what === "alias" ? ` (of ${JSON.stringify(t.name)})` : ""} is invalid: ${problem}.`);
|
|
70
73
|
e.code = "config.tool_name_invalid";
|
|
71
74
|
throw e;
|
|
72
75
|
}
|
|
73
|
-
for (const alias of t.aliases ?? []) {
|
|
74
|
-
if (carriesNamespaceSeparator(alias)) {
|
|
75
|
-
const e = new Error(`Tool alias "${alias}" (of "${t.name}") is invalid: "__" is reserved for the engine's protocol tool namespaces (${NAMESPACED_NAME_SHAPES}) and must not appear in a caller tool alias.`);
|
|
76
|
-
e.code = "config.tool_name_invalid";
|
|
77
|
-
throw e;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
76
|
if (t.effect && survivors.get(t.name) === t) {
|
|
81
77
|
toolEffects.set(t.name, t.effect);
|
|
82
78
|
}
|
|
@@ -171,6 +171,12 @@ export interface PrepareSuspendSagaInput {
|
|
|
171
171
|
toolCeiling: readonly import("../tool-face.js").ToolSelectorLayer[] | undefined;
|
|
172
172
|
/** borrowed-readonly — the spawning run's judgment of this leg's own lists, while it is bound to them (`boundToolListsJudgment`), the row's `toolListsJudged` stamp. */
|
|
173
173
|
toolListsJudged: string | undefined;
|
|
174
|
+
/** borrowed-readonly — whose lists this leg's own are (the live seat, else the resumed row's), the row's `ownToolLists` stamp. */
|
|
175
|
+
ownToolLists: {
|
|
176
|
+
readonly toolName: string;
|
|
177
|
+
readonly definition?: string;
|
|
178
|
+
readonly lists: string;
|
|
179
|
+
} | undefined;
|
|
174
180
|
/** borrowed-readonly — the external-content-target fold (the row's monotonic bit). */
|
|
175
181
|
externalContentTargetActive: boolean;
|
|
176
182
|
/** borrowed-mutable — the run-scoped remote-lifecycle failure log (`Prepared.remoteEnvFailures`). Writer here: the
|
|
@@ -3,6 +3,7 @@ import { isRemoteExecutionEnv, isSuspendable, RemoteExecutionError } from "../re
|
|
|
3
3
|
import { resolveDeclaredFidelity } from "../checkpoint-store.js";
|
|
4
4
|
import { judgeAsStored, stampCheckpointRequirements } from "../checkpoint-requirements.js";
|
|
5
5
|
import { constraintChainDigest, constraintChainEntryOfLayer } from "../tool-policy.js";
|
|
6
|
+
import { persistedToolNameList } from "../../agents/tool-filter.js";
|
|
6
7
|
import { raceSettlementAgainstSignal } from "./abort-race.js";
|
|
7
8
|
import { placementValueOrAbsent } from "./checkpoint-scope.js";
|
|
8
9
|
import { serializeAnnouncedListings } from "./announce-once-ledger.js";
|
|
@@ -81,7 +82,7 @@ function stampPlacementRootSessionId(placementRootResolved) {
|
|
|
81
82
|
return placementValueOrAbsent(placementRootResolved);
|
|
82
83
|
}
|
|
83
84
|
export function prepareSuspendSaga(input) {
|
|
84
|
-
const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, toolCeiling, toolListsJudged, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
|
|
85
|
+
const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
|
|
85
86
|
if (!gateMachineryActive)
|
|
86
87
|
return { saga: undefined };
|
|
87
88
|
const inFlightSpendMicroUsd = () => {
|
|
@@ -178,8 +179,9 @@ export function prepareSuspendSaga(input) {
|
|
|
178
179
|
placementRootSessionId: stampPlacementRootSessionId(placementRootResolved),
|
|
179
180
|
externalContentTarget: externalContentTargetActive ? true : undefined,
|
|
180
181
|
legScope: checkpointScope,
|
|
181
|
-
toolCeiling: toolCeiling !== undefined ? toolCeiling.map((l) => ({ ...(l.allow !== undefined ? { allow:
|
|
182
|
+
toolCeiling: toolCeiling !== undefined ? toolCeiling.map((l) => ({ ...(l.allow !== undefined ? { allow: persistedToolNameList(l.allow, "allowed") } : {}), deny: persistedToolNameList(l.deny, "denied") })) : undefined,
|
|
182
183
|
toolListsJudged,
|
|
184
|
+
ownToolLists: ownToolLists !== undefined ? { toolName: ownToolLists.toolName, ...(ownToolLists.definition !== undefined ? { definition: ownToolLists.definition } : {}), lists: ownToolLists.lists } : undefined,
|
|
183
185
|
});
|
|
184
186
|
const compensatePausedVM = (remoteEnv, snapshotId) => compensateUnparkedPause(remoteEnv, snapshotId, {
|
|
185
187
|
boundMs: PARK_COMPENSATION_TIMEOUT_MS,
|
|
@@ -212,15 +214,15 @@ export function prepareSuspendSaga(input) {
|
|
|
212
214
|
const committedCount = cp.state.inheritedGate?.parentConstraintCount;
|
|
213
215
|
if (cp.state.inheritedGate?.requiresParentConstraint === true &&
|
|
214
216
|
!screeningParkDisclosedRef.done &&
|
|
215
|
-
(inheritedParentConstraints ?? []).some((pc) => pc.
|
|
217
|
+
(inheritedParentConstraints ?? []).some((pc) => pc.mods !== undefined)) {
|
|
216
218
|
screeningParkDisclosedRef.done = true;
|
|
217
219
|
try {
|
|
218
220
|
deps.onError?.(new Error(`durable park under an inherited PreToolUse SCREENING constraint: this checkpoint records ` +
|
|
219
221
|
`requiresParentConstraint with parentConstraintCount=${committedCount ?? "(unrecorded)"}, and the live ` +
|
|
220
222
|
`closures cannot be persisted. A resume on THIS Runner re-supplies them automatically; a resume on a fresh ` +
|
|
221
223
|
`Runner (restart / another replica) must hand back the whole chain via resumeStream(..., internals), ` +
|
|
222
|
-
`rebuilding the screening entry with createPreToolUseConstraintPolicy(
|
|
223
|
-
`pending.
|
|
224
|
+
`rebuilding the screening entry with createPreToolUseConstraintPolicy(chain, env) over the same registrations — ` +
|
|
225
|
+
`otherwise the row stays pending. A handler declared { observe: true } never enters the chain.`), { phase: "degraded", sessionId, classification: "screening-constraint-in-durable-chain" });
|
|
224
226
|
}
|
|
225
227
|
catch {
|
|
226
228
|
}
|