@sema-agent/core 7.51.2 → 7.53.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 +698 -2
- package/README.md +3 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cross-session-envelope.d.ts +8 -0
- package/dist/agents/cross-session-envelope.js +6 -0
- package/dist/agents/cross-session-judge.d.ts +21 -1
- package/dist/agents/cross-session-judge.js +8 -0
- package/dist/agents/cross-session-ref.d.ts +5 -0
- package/dist/agents/cross-session-ref.js +1 -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/org-delivery-gate.d.ts +122 -0
- package/dist/agents/org-delivery-gate.js +69 -0
- package/dist/agents/peer-held-queue.d.ts +9 -4
- package/dist/agents/peer-held-queue.js +6 -5
- package/dist/agents/peer-session-drain.d.ts +35 -5
- package/dist/agents/peer-session-drain.js +271 -180
- package/dist/agents/read-inbox-tool.d.ts +8 -1
- package/dist/agents/read-inbox-tool.js +5 -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 +3 -0
- package/dist/agents/subagent.js +105 -76
- package/dist/agents/tool-filter.d.ts +58 -13
- package/dist/agents/tool-filter.js +34 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.d.ts +6 -1
- package/dist/brain/anthropic.js +17 -13
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +6 -5
- 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 +123 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/routing.d.ts +24 -1
- package/dist/brain/routing.js +54 -19
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/timeout.js +5 -4
- package/dist/core/a2a.d.ts +5 -2
- package/dist/core/a2a.js +30 -13
- package/dist/core/allow-entry.d.ts +42 -9
- package/dist/core/allow-entry.js +25 -18
- package/dist/core/auto-compaction.d.ts +80 -20
- package/dist/core/auto-compaction.js +65 -18
- 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 +57 -24
- package/dist/core/checkpoint-store.js +3 -3
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/compliance.js +3 -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/effective-path-target.d.ts +25 -6
- package/dist/core/effective-path-target.js +24 -2
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +49 -21
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +8 -25
- package/dist/core/gate-lanes.js +358 -274
- package/dist/core/gate-outcome.d.ts +11 -6
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +12 -3
- package/dist/core/hands-band-screen.d.ts +7 -0
- package/dist/core/hands-band-screen.js +32 -0
- package/dist/core/hooks.d.ts +283 -739
- package/dist/core/hooks.js +100 -193
- 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 +84 -32
- package/dist/core/locked-config.js +128 -42
- 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 +3 -3
- package/dist/core/mcp-server-spec.d.ts +104 -10
- package/dist/core/mcp-server-spec.js +183 -33
- package/dist/core/mcp.d.ts +31 -20
- package/dist/core/mcp.js +66 -56
- 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 +22 -30
- package/dist/core/memory-engine/engine.js +16 -10
- 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 +5 -16
- package/dist/core/mode-policy.js +7 -19
- 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 +699 -0
- package/dist/core/mods/kernel/events.d.ts +245 -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 +94 -0
- package/dist/core/mods/kernel/receive.js +188 -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 +149 -0
- package/dist/core/mods/kernel/site-rules.js +296 -0
- package/dist/core/mods/stations.d.ts +344 -0
- package/dist/core/mods/stations.js +437 -0
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +71 -2
- package/dist/core/own-property-receipt.d.ts +13 -0
- package/dist/core/own-property-receipt.js +13 -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-model.d.ts +58 -9
- package/dist/core/permission-rule-model.js +81 -7
- package/dist/core/permission-rule-org.d.ts +163 -33
- package/dist/core/permission-rule-org.js +205 -71
- 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 +14 -2
- package/dist/core/permission-rules.js +63 -23
- 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/retention.js +7 -2
- package/dist/core/retired-keys.d.ts +12 -2
- package/dist/core/retired-keys.js +15 -1
- package/dist/core/roles.js +60 -10
- package/dist/core/rule-lane-reads.js +1 -1
- 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 +86 -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 +12 -5
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +52 -10
- package/dist/core/runner/mcp-redial.js +38 -9
- 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/permission-rule-lanes.d.ts +5 -2
- package/dist/core/runner/permission-rule-lanes.js +22 -10
- package/dist/core/runner/person-path-rows.d.ts +3 -1
- package/dist/core/runner/person-path-rows.js +3 -2
- 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 +52 -1
- package/dist/core/runner/prepare-config-doors.js +168 -143
- package/dist/core/runner/prepare-defer-classify.js +7 -11
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +7 -5
- 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-hands-readface.d.ts +1 -1
- package/dist/core/runner/prepare-hands-readface.js +2 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +10 -23
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
- package/dist/core/runner/prepare-memory-engine-session.js +20 -7
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +6 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
- package/dist/core/runner/prepare-offload-wrappers.js +2 -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 +104 -109
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +11 -12
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +138 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
- package/dist/core/runner/prepare-prompt-inputs.js +11 -10
- package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
- package/dist/core/runner/prepare-protocol-tools.js +20 -13
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-question-face.js +4 -3
- 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 +41 -23
- 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 +13 -9
- package/dist/core/runner/prepare-wiring-manifest.js +14 -11
- package/dist/core/runner/resume-admission.d.ts +4 -1
- package/dist/core/runner/resume-admission.js +7 -5
- 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-internals-and-config.d.ts +3 -3
- package/dist/core/runner/resume-internals-and-config.js +3 -8
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.d.ts +5 -6
- package/dist/core/runner/retired-runner-deps.js +4 -5
- 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 +103 -95
- 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 +14 -11
- 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 +34 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +32 -37
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +15 -73
- 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/skills-seat.d.ts +15 -0
- package/dist/core/runner/skills-seat.js +57 -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 +124 -23
- package/dist/core/runner/sub-agent-deny-lists.js +230 -71
- package/dist/core/runner/synthetic-tools.d.ts +5 -2
- package/dist/core/runner/synthetic-tools.js +2 -12
- 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 +43 -36
- 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 +71 -16
- package/dist/core/session-policy-store.js +138 -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/store-contracts/mailbox-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +49 -3
- package/dist/core/task-notification.js +2 -2
- 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 +62 -18
- package/dist/core/tool-policy.js +86 -15
- 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 -2
- package/dist/core/types.js +1 -1
- 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/untrusted-text.d.ts +16 -0
- package/dist/core/untrusted-text.js +7 -2
- package/dist/core/user-attachment.d.ts +25 -4
- package/dist/core/user-attachment.js +63 -42
- package/dist/core/wiring-manifest.d.ts +18 -15
- 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 +5 -4
- package/dist/engine/harness/types.d.ts +20 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.d.ts +12 -1
- package/dist/engine/loop/agent-loop.js +18 -6
- package/dist/engine/loop/types.d.ts +8 -2
- 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 +33 -23
- package/dist/index.js +23 -15
- package/dist/internal/harness.d.ts +2 -1
- package/dist/internal/harness.js +2 -1
- package/dist/orchestration/goal.d.ts +24 -1
- package/dist/orchestration/goal.js +3 -2
- 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 +72 -56
- package/dist/prompt-assembly/artifact-store.js +60 -52
- package/dist/prompt-assembly/artifact.d.ts +90 -76
- package/dist/prompt-assembly/artifact.js +197 -145
- package/dist/prompt-assembly/assemble.d.ts +36 -29
- package/dist/prompt-assembly/assemble.js +34 -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 +60 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
- package/dist/prompt-assembly/catalog/memory.js +6 -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 +138 -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 +26 -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 +137 -0
- package/dist/prompt-assembly/overlay.js +339 -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 +71 -0
- package/dist/prompt-assembly/select.js +106 -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 -511
- package/dist/prompts/default.js +20 -288
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/permission-rule-store.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.js +2 -1
- package/dist/tools/artifact/artifact-tool.js +4 -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 +306 -103
- package/wire-changes/core@7.52.0.json +5859 -0
- package/wire-changes/core@7.53.0.json +1946 -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,37 +1,42 @@
|
|
|
1
1
|
import type { AgentTool } from "../../internal/harness.js";
|
|
2
2
|
import type { Model } from "../../internal/llm.js";
|
|
3
3
|
import { assemblePrompt, type AssembledPrompt } from "../../prompt-assembly/assemble.js";
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
6
|
-
import
|
|
4
|
+
import { type CenterAdoption } from "../../prompt-assembly/artifact.js";
|
|
5
|
+
import { type RunPromptIdentity } from "../../prompt-assembly/epoch.js";
|
|
6
|
+
import type { HostForm, HostRole } from "../../prompt-assembly/catalog/schema.js";
|
|
7
|
+
import type { SourcedOverlay } from "../../prompt-assembly/overlay.js";
|
|
8
|
+
import { type EnvironmentFacts } from "../../prompts/default.js";
|
|
9
|
+
import { type LegModBus } from "../mods/stations.js";
|
|
7
10
|
import { type StoredSession } from "../session.js";
|
|
8
11
|
import type { RunnerDeps } from "../types.js";
|
|
9
12
|
import type { AnnounceOnceSink, Prepared, PrepareResume, PromptFeatureFlags, RunInternals } from "./contracts.js";
|
|
10
|
-
/** The center adoption a run composes under: the artifact and, when the source stamped one, its revision. */
|
|
11
|
-
export type CenterAdoption = {
|
|
12
|
-
artifact: PromptEpochArtifact;
|
|
13
|
-
sourceRevision?: string;
|
|
14
|
-
};
|
|
15
13
|
export interface PreparePromptAssemblyInput {
|
|
16
|
-
/** borrowed-mutable — the acquired session. Read: `getPromptEpoch` (the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
/** borrowed-mutable — the acquired session. Read: `getPromptEpoch` (the stored record), `getBranch` (the freshness
|
|
15
|
+
* discriminator on the record-less arms). Writer here: `appendPromptEpoch`, the ONE record write of this leg (only
|
|
16
|
+
* when the run's identity differs from the stored record's). The acquire phase and the run loop write it elsewhere. */
|
|
19
17
|
session: Pick<StoredSession, "getPromptEpoch" | "getBranch" | "appendPromptEpoch">;
|
|
20
|
-
/** borrowed-readonly — the deployment seats: `promptSource` (the center artifact
|
|
21
|
-
* (the assembly's warn channel
|
|
18
|
+
/** borrowed-readonly — the deployment seats: `promptSource` (the center artifact source, its candidate and its
|
|
19
|
+
* tri-state), `onError` (the assembly's warn channel). Receiver preserved. */
|
|
22
20
|
deps: Pick<RunnerDeps, "promptSource" | "onError">;
|
|
23
|
-
/** borrowed-readonly — the trusted spawn-side channel: the parent's center
|
|
21
|
+
/** borrowed-readonly — the trusted spawn-side channel: the parent's center layer (`parentCenterArtifactDigest`,
|
|
24
22
|
* `parentCenterSourceRevision`), the top-level freshness facts (`parentTaskId`, `parentSessionId`) and the named-child
|
|
25
23
|
* fact the teammate flag reads (`explicitAgentName`). */
|
|
26
24
|
internals: Pick<RunInternals, "parentCenterArtifactDigest" | "parentCenterSourceRevision" | "parentTaskId" | "parentSessionId" | "explicitAgentName"> | undefined;
|
|
27
25
|
/** borrowed-readonly — the resume leg, or undefined; PRESENCE only (a resumed leg is never truly fresh). */
|
|
28
26
|
resume: Pick<PrepareResume, "seed"> | undefined;
|
|
29
|
-
/** borrowed-readonly — the
|
|
30
|
-
|
|
31
|
-
/** borrowed-readonly — the
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
/** borrowed-readonly — the request-body sugar's overlays (the task class's first contributions). */
|
|
28
|
+
sugar: readonly SourcedOverlay[];
|
|
29
|
+
/** borrowed-readonly — the host selector values (`promptRole` / `promptForm`). */
|
|
30
|
+
host: {
|
|
31
|
+
readonly role?: HostRole;
|
|
32
|
+
readonly form?: HostForm;
|
|
33
|
+
};
|
|
34
|
+
/** borrowed-readonly — the run's binding (`TaskSpec.promptBinding`, validated), or undefined: a selector value. */
|
|
35
|
+
binding: string | undefined;
|
|
36
|
+
/** borrowed-readonly — the leg's mods bus: `prompt.compose` collects the deploy and task seats' overlays. */
|
|
37
|
+
modBus: LegModBus;
|
|
38
|
+
/** borrowed-readonly — the run's abort signal (the compose raise ends with it). */
|
|
39
|
+
signal?: AbortSignal;
|
|
35
40
|
/** borrowed-readonly — the harness-context flags; the two orchestration flags are re-derived against the post-exclusion
|
|
36
41
|
* roster at assembly. */
|
|
37
42
|
featureFlags: PromptFeatureFlags;
|
|
@@ -49,47 +54,47 @@ export interface PreparePromptAssemblyInput {
|
|
|
49
54
|
/** borrowed-readonly — the run's ONE tool roster, read only: the assembly receives DETACHED copies, the audit and the
|
|
50
55
|
* manifest read it in place. Never mutated here. */
|
|
51
56
|
tools: readonly AgentTool[];
|
|
52
|
-
/** borrowed-readonly — the task model
|
|
53
|
-
model: Pick<Model, "promptGuidance">;
|
|
57
|
+
/** borrowed-readonly — the task model: `promptGuidance` (the model-guidance section) and `id` (the compose event's `model`). */
|
|
58
|
+
model: Pick<Model, "id" | "promptGuidance">;
|
|
54
59
|
/** borrowed-readonly — the acquired session id (every operator line's attribution). */
|
|
55
60
|
sessionId: string;
|
|
56
|
-
/** borrowed-readonly — the session's reminder provenance mark (the declaration the assembled prompt must render). */
|
|
57
|
-
reminderMark: string;
|
|
58
61
|
/** borrowed-readonly — the once-per-session ledger's operator sink (the collision audit's two lines). */
|
|
59
62
|
onceLedger: Pick<AnnounceOnceSink, "onError">;
|
|
60
63
|
}
|
|
61
64
|
export interface PreparePromptAssemblyResult {
|
|
62
65
|
/** borrowed-mutable — the LIVE system prompt (an accessor cell over this phase's closure variable). Writers: this
|
|
63
66
|
* phase's `renderWithDate` (the date re-render, called by the listings phase's date_change seam); the turn-wiring
|
|
64
|
-
* phase's center candidate `apply` (the compaction-boundary
|
|
67
|
+
* phase's center candidate `apply` (the compaction-boundary change). Readers: the harness construction, the cache
|
|
65
68
|
* fingerprint, the turn snapshot's stable text, the prompt-overhead term. */
|
|
66
69
|
systemPromptSeat: {
|
|
67
70
|
current: string;
|
|
68
71
|
};
|
|
69
|
-
/** owned — the date re-render
|
|
70
|
-
* writes it into `systemPromptSeat`. */
|
|
72
|
+
/** owned — the date re-render. Returns the new prompt and writes it into `systemPromptSeat`. */
|
|
71
73
|
renderWithDate: ((date: string) => string) | undefined;
|
|
72
|
-
/** owned — the physical block face of the assembled prompt
|
|
73
|
-
*
|
|
74
|
+
/** owned — the physical block face of the assembled prompt (the harness's systemBlocks and the turn snapshot's
|
|
75
|
+
* layout groups). */
|
|
74
76
|
systemBlocks: AssembledPrompt["systemBlocks"];
|
|
75
77
|
/** borrowed-mutable — the composition manifest (`Prepared.promptManifest`). Writers after this phase: the tool-disclosure
|
|
76
78
|
* phase writes `toolDisclosure` (when deferred tools exist); the turn-wiring phase backfills `snapshot` and `lowering`
|
|
77
79
|
* once the final wire tool list exists. */
|
|
78
80
|
promptManifest: Prepared["promptManifest"];
|
|
79
|
-
/** owned — the
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
/** owned — the run's identity inputs and the pinned center layer's provenance (`Prepared.promptIdentity`; the
|
|
82
|
+
* compaction-boundary candidate replaces it after a committed center change). */
|
|
83
|
+
promptIdentity: RunPromptIdentity;
|
|
84
|
+
/** owned — the re-invokable assemble-inputs BUILDER: the compaction-boundary candidate re-assembles with a new center
|
|
85
|
+
* layer through it (facts, tails and the run-frozen mods overlays identical; only the center class differs). */
|
|
86
|
+
buildAssembleInputs: (center: CenterAdoption | undefined) => Parameters<typeof assemblePrompt>[0];
|
|
87
|
+
/** owned — the identity inputs under another center layer (the compaction-boundary candidate's record). */
|
|
88
|
+
identityFor: (center: CenterAdoption | undefined) => RunPromptIdentity;
|
|
89
|
+
/** owned — whether this run adopts center candidates at its boundaries: a top-level run does; a child composes its
|
|
90
|
+
* parent's layer and never adopts one of its own. */
|
|
91
|
+
adoptsCandidates: boolean;
|
|
86
92
|
/** borrowed-mutable — the LIVE center adoption (an accessor cell over this phase's closure variable), or undefined.
|
|
87
|
-
* Writers: this phase (the
|
|
88
|
-
*
|
|
89
|
-
* (inherited-gate, caps-and-workflow), the pin write, the candidate's same-artifact test. */
|
|
93
|
+
* Writers: this phase (the resolution arms); the turn-wiring phase's center candidate `apply` (the boundary change).
|
|
94
|
+
* Readers: the two late-bound ctx getters (inherited-gate, caps-and-workflow), the candidate's same-artifact test. */
|
|
90
95
|
centerAdoptionRef: {
|
|
91
96
|
current: CenterAdoption | undefined;
|
|
92
97
|
};
|
|
93
98
|
}
|
|
94
|
-
/** The M13 phase body — prepareTask's prompt-assembly stretch
|
|
99
|
+
/** The M13 phase body — prepareTask's prompt-assembly stretch (see the module header). */
|
|
95
100
|
export declare function preparePromptAssembly(input: PreparePromptAssemblyInput): Promise<PreparePromptAssemblyResult>;
|
|
@@ -1,101 +1,141 @@
|
|
|
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, verifyPromptArtifactBody } from "../../prompt-assembly/artifact.js";
|
|
5
|
+
import { refusalClause, storedArtifactLine } from "../../prompt-assembly/artifact-store.js";
|
|
6
|
+
import { catalogDigestOf, digestOf, prepareEpochRecord } from "../../prompt-assembly/epoch.js";
|
|
7
|
+
import { rendererVector } from "../../prompt-assembly/renderers.js";
|
|
8
|
+
import { SEMA_DEFAULT_CATALOG } from "../../prompt-assembly/catalog/index.js";
|
|
9
|
+
import { describeCatalog } from "../../prompt-assembly/explain.js";
|
|
10
|
+
import { selectorRecordOf, selectorsOf } from "../../prompt-assembly/select.js";
|
|
7
11
|
import { auditToolCollisions, projectToolManifest } from "../../prompt-assembly/tool-catalog.js";
|
|
8
|
-
import { buildEnvironmentContext
|
|
12
|
+
import { buildEnvironmentContext } from "../../prompts/default.js";
|
|
13
|
+
import { raisePromptCompose } from "../mods/stations.js";
|
|
9
14
|
import { protocolOf } from "../protocol-table.js";
|
|
10
|
-
import { reminderMarkDeclaration } from "../reminder-mint.js";
|
|
11
15
|
import { hasConversationContent } from "../session.js";
|
|
12
16
|
import { PROMPT_HASH_SALT } from "./prompt-hash-salt.js";
|
|
17
|
+
const CATALOG_DIGEST = catalogDigestOf(SEMA_DEFAULT_CATALOG);
|
|
18
|
+
function taskLayerOf(task) {
|
|
19
|
+
return task.map(({ overlay: o, origin }) => ({
|
|
20
|
+
by: origin.by,
|
|
21
|
+
id: o.id,
|
|
22
|
+
op: o.op,
|
|
23
|
+
target: o.target,
|
|
24
|
+
...(o.text !== undefined ? { chars: o.text.length } : {}),
|
|
25
|
+
...(o.message !== undefined ? { message: o.message } : {}),
|
|
26
|
+
...(o.when !== undefined ? { when: o.when } : {}),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
13
29
|
export async function preparePromptAssembly(input) {
|
|
14
|
-
const { session, deps, internals, resume,
|
|
30
|
+
const { session, deps, internals, resume, sugar, host, binding, modBus, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptProfile, fableMitigations, tools, model, sessionId, onceLedger } = input;
|
|
31
|
+
const topLevel = internals?.parentTaskId === undefined && internals?.parentSessionId === undefined && internals?.parentCenterArtifactDigest === undefined;
|
|
32
|
+
const stored = await session.getPromptEpoch();
|
|
15
33
|
let centerAdoption;
|
|
16
|
-
let centerAdoptionFresh = false;
|
|
17
34
|
{
|
|
18
|
-
const failUnavailable = (
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
const failUnavailable = (what, refusal) => {
|
|
36
|
+
const why = refusal !== undefined ? `the source's copy is ${refusalClause(refusal)}` : `artifact source miss / not verifiable here${deps.promptSource === undefined ? "; RunnerDeps.promptSource is not configured" : ""}`;
|
|
37
|
+
throw Object.assign(new Error(`prompt snapshot unavailable: ${what} (${why}) — refusing to recompose a hybrid prompt`), { code: "prompt.snapshot_unavailable" });
|
|
38
|
+
};
|
|
39
|
+
const resolvePinned = async (digest, sourceRevision, via) => {
|
|
40
|
+
const told = {};
|
|
41
|
+
const art = await deps.promptSource?.get(digest, (r) => void (told.current = r));
|
|
42
|
+
const adopted = art !== undefined ? adoptCenter(art, sourceRevision) : undefined;
|
|
43
|
+
if (adopted !== undefined)
|
|
44
|
+
return adopted;
|
|
45
|
+
const checked = art !== undefined ? verifyPromptArtifactBody(art) : undefined;
|
|
46
|
+
const refusal = told.current ?? (checked !== undefined && !checked.ok ? { code: checked.code, reason: checked.reason } : undefined);
|
|
47
|
+
if (refusal !== undefined)
|
|
48
|
+
deps.onError?.(new Error(storedArtifactLine(digest, refusal, `the session fails prompt.snapshot_unavailable (a hybrid prompt is never recomposed)`)), { phase: "prompt-constitution", sessionId });
|
|
49
|
+
return failUnavailable(`${via} center prompt artifact ${digest.slice(0, 23)}… has no verified resolvable copy`, refusal);
|
|
22
50
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
const pinned = stored?.kind === "pin" ? stored.descriptor : undefined;
|
|
52
|
+
const retiredCenterPin = stored?.kind === "legacy" && stored.centerPinned;
|
|
53
|
+
if (pinned?.layers.center !== undefined) {
|
|
54
|
+
centerAdoption = await resolvePinned(pinned.layers.center, pinned.sourceRevision, "this session is pinned to");
|
|
55
|
+
}
|
|
56
|
+
else if (retiredCenterPin && topLevel) {
|
|
57
|
+
const state = deps.promptSource?.sourceState() ?? "unavailable";
|
|
58
|
+
if (state === "unavailable")
|
|
59
|
+
failUnavailable("this session's center pin is of a retired shape and the center source has no verified state; the pin is kept");
|
|
60
|
+
if (state === "active") {
|
|
61
|
+
const cand = deps.promptSource.current();
|
|
62
|
+
centerAdoption = (cand !== undefined ? adoptCenter(cand, cand.sourceRevision) : undefined) ?? failUnavailable("this session's center pin is of a retired shape and the current candidate");
|
|
63
|
+
}
|
|
29
64
|
}
|
|
30
|
-
else if (
|
|
65
|
+
else if (stored === undefined || retiredCenterPin) {
|
|
31
66
|
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
|
-
};
|
|
67
|
+
centerAdoption = await resolvePinned(internals.parentCenterArtifactDigest, internals.parentCenterSourceRevision, "the spawning parent adopted");
|
|
39
68
|
}
|
|
40
|
-
else if (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
centerAdoption =
|
|
44
|
-
|
|
69
|
+
else if (stored === undefined && topLevel && resume === undefined) {
|
|
70
|
+
const cand = deps.promptSource?.current();
|
|
71
|
+
if (cand !== undefined && !hasConversationContent(await session.getBranch())) {
|
|
72
|
+
centerAdoption = adoptCenter(cand, cand.sourceRevision);
|
|
73
|
+
if (centerAdoption === undefined)
|
|
74
|
+
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
75
|
}
|
|
46
76
|
}
|
|
47
77
|
}
|
|
48
78
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
const facts = {
|
|
80
|
+
supervisorEnabled: false,
|
|
81
|
+
teammateEnabled: internals?.explicitAgentName !== undefined && tools.some((t) => t.name === SEND_MESSAGE_TOOL_NAME),
|
|
82
|
+
...featureFlags,
|
|
83
|
+
orchestrationEnabled: featureFlags.orchestrationEnabled && tools.some((t) => t.name === "Workflow"),
|
|
84
|
+
orchestrationDeferred: featureFlags.orchestrationDeferred && tools.some((t) => t.name === "Workflow"),
|
|
85
|
+
promptProfile,
|
|
86
|
+
fableMitigations,
|
|
87
|
+
};
|
|
88
|
+
const selectorRecord = selectorRecordOf(selectorsOf(facts, host, binding));
|
|
89
|
+
const centerOverlays = centerOverlaysOf(centerAdoption);
|
|
90
|
+
const lowerAdds = new Map();
|
|
91
|
+
for (const { overlay } of [...sugar, ...centerOverlays])
|
|
92
|
+
if (overlay.op === "add")
|
|
93
|
+
lowerAdds.set(overlay.id, overlay.target);
|
|
94
|
+
const composed = await raisePromptCompose(modBus, {
|
|
95
|
+
model: model.id,
|
|
96
|
+
catalog: describeCatalog().sections,
|
|
97
|
+
selectors: selectorRecord,
|
|
98
|
+
}, { lowerAdds, ...(input.signal !== undefined ? { signal: input.signal } : {}) });
|
|
99
|
+
for (const w of composed.warnings)
|
|
100
|
+
deps.onError?.(new Error(w), { phase: "prompt-constitution", sessionId });
|
|
101
|
+
const taskOverlays = [...sugar, ...composed.task];
|
|
102
|
+
const buildAssembleInputs = (center) => ({
|
|
103
|
+
taskOverlays,
|
|
104
|
+
centerOverlays: centerOverlaysOf(center),
|
|
105
|
+
deployOverlays: composed.deploy,
|
|
106
|
+
host,
|
|
107
|
+
...(binding !== undefined ? { binding } : {}),
|
|
108
|
+
tools,
|
|
109
|
+
facts,
|
|
110
|
+
...(envFacts.cwd !== undefined ? { workspaceFolder: envFacts.cwd } : {}),
|
|
64
111
|
mcpInstructionsBlock,
|
|
65
112
|
memoryBlock,
|
|
66
113
|
buildEnvBlock: (date) => buildEnvironmentContext({ ...envFacts, date }) || undefined,
|
|
67
114
|
date: envFacts.date,
|
|
68
|
-
envFacts,
|
|
69
115
|
...(model.promptGuidance && model.promptGuidance.length > 0 ? { modelGuidance: model.promptGuidance.join("\n\n") } : {}),
|
|
70
116
|
onWarn: (message, phase) => deps.onError?.(new Error(message), { phase, sessionId }),
|
|
71
|
-
...(centerDecls !== undefined ? { centerDeclarations: centerDecls } : {}),
|
|
72
117
|
});
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
118
|
+
const deployLayer = composed.deploy.length > 0 ? digestOf(composed.deploy.map(({ overlay, origin }) => ({ by: origin.by, overlay }))) : undefined;
|
|
119
|
+
const taskLayer = taskOverlays.length > 0 ? digestOf(taskLayerOf(taskOverlays)) : undefined;
|
|
120
|
+
const bindingLayer = digestOf(selectorRecord);
|
|
121
|
+
const renderers = rendererVector();
|
|
122
|
+
const identityFor = (center) => ({
|
|
123
|
+
layers: {
|
|
124
|
+
catalog: CATALOG_DIGEST,
|
|
125
|
+
renderers,
|
|
126
|
+
...(center !== undefined ? { center: center.artifact.artifactDigest } : {}),
|
|
127
|
+
...(deployLayer !== undefined ? { deploy: deployLayer } : {}),
|
|
128
|
+
...(taskLayer !== undefined ? { task: taskLayer } : {}),
|
|
129
|
+
binding: bindingLayer,
|
|
130
|
+
},
|
|
131
|
+
...(center?.sourceRevision !== undefined ? { sourceRevision: center.sourceRevision } : {}),
|
|
132
|
+
});
|
|
133
|
+
const assembled = assemblePrompt(buildAssembleInputs(centerAdoption));
|
|
88
134
|
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;
|
|
135
|
+
const renderWithDate = (date) => {
|
|
136
|
+
systemPrompt = assembled.renderWithDate(date);
|
|
137
|
+
return systemPrompt;
|
|
138
|
+
};
|
|
99
139
|
const promptBlocks = assembled.blocks;
|
|
100
140
|
const collisionAudit = auditToolCollisions(tools);
|
|
101
141
|
for (const y of collisionAudit.yields) {
|
|
@@ -104,38 +144,34 @@ export async function preparePromptAssembly(input) {
|
|
|
104
144
|
for (const c of collisionAudit.aliasCollisions) {
|
|
105
145
|
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
146
|
}
|
|
147
|
+
const promptIdentity = identityFor(centerAdoption);
|
|
148
|
+
const priorConversation = stored === undefined ? hasConversationContent(await session.getBranch()) : true;
|
|
149
|
+
const record = prepareEpochRecord(stored, promptIdentity.layers, { priorConversation, ...(promptIdentity.sourceRevision !== undefined ? { sourceRevision: promptIdentity.sourceRevision } : {}) });
|
|
150
|
+
if (record !== undefined)
|
|
151
|
+
await session.appendPromptEpoch(record);
|
|
152
|
+
const current = record ?? (stored?.kind === "pin" ? stored.descriptor : undefined);
|
|
107
153
|
const saltedHash = (text) => createHash("sha256").update(PROMPT_HASH_SALT).update(text).digest("hex").slice(0, 12);
|
|
154
|
+
const contentHashOf = (s) => s.renderer !== undefined || s.chain.some((l) => l.source === "task")
|
|
155
|
+
? `salted:${createHash("sha256").update(PROMPT_HASH_SALT).update(s.text).digest("hex")}`
|
|
156
|
+
: `sha256:${createHash("sha256").update(s.text).digest("hex")}`;
|
|
108
157
|
const promptManifest = {
|
|
109
|
-
|
|
158
|
+
identity: { artifact: current.identity, layers: current.layers, epoch: current.epoch, activatedBy: current.activatedBy },
|
|
159
|
+
selectors: selectorRecord,
|
|
110
160
|
blocks: promptBlocks.map((b) => ({ id: b.id, chars: b.text.length, hash: saltedHash(b.text) })),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
:
|
|
161
|
+
sections: assembled.sections.map((s) => ({
|
|
162
|
+
id: s.id,
|
|
163
|
+
band: s.band,
|
|
164
|
+
rank: s.rank,
|
|
165
|
+
...(s.variant !== undefined ? { variant: s.variant } : {}),
|
|
166
|
+
...(s.renderer !== undefined ? { renderer: { ...s.renderer } } : {}),
|
|
167
|
+
chars: s.text.length,
|
|
168
|
+
locale: s.chain.some((l) => l.source !== "bundled" && l.superseded !== true) ? "overlay" : "canonical",
|
|
169
|
+
contentHash: contentHashOf(s),
|
|
170
|
+
chain: s.chain.map((l) => ({ ...l })),
|
|
171
|
+
})),
|
|
172
|
+
...(assembled.superseded.length > 0 ? { superseded: assembled.superseded.map((s) => ({ ...s })) } : {}),
|
|
114
173
|
tools: projectToolManifest(tools, (t) => protocolOf(t.name)?.id ?? "caller"),
|
|
115
174
|
};
|
|
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
175
|
return {
|
|
140
176
|
systemPromptSeat: {
|
|
141
177
|
get current() {
|
|
@@ -148,9 +184,10 @@ export async function preparePromptAssembly(input) {
|
|
|
148
184
|
renderWithDate,
|
|
149
185
|
systemBlocks: assembled.systemBlocks,
|
|
150
186
|
promptManifest,
|
|
151
|
-
|
|
152
|
-
epochArtifactDigestForSnapshot,
|
|
187
|
+
promptIdentity,
|
|
153
188
|
buildAssembleInputs,
|
|
189
|
+
identityFor,
|
|
190
|
+
adoptsCandidates: topLevel,
|
|
154
191
|
centerAdoptionRef: {
|
|
155
192
|
get current() {
|
|
156
193
|
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,12 +19,15 @@
|
|
|
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";
|
|
30
|
+
import type { RosterBuilder } from "../tool-roster.js";
|
|
28
31
|
import type { ResolvedRole } from "../roles.js";
|
|
29
32
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
30
33
|
import type { SessionTreeEntry } from "../../internal/harness-types.js";
|
|
@@ -33,14 +36,15 @@ import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
|
33
36
|
import { type GitStatusLaneRef } from "./git-status-frame.js";
|
|
34
37
|
import { type ContextWindowOverlay } from "../context-settings.js";
|
|
35
38
|
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
|
-
|
|
39
|
+
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `systemPrompt` / `appendSystemPrompt` (handed whole to the
|
|
40
|
+
* request-body sugar), `clientContext` (zone, email), `envFacts` (the deployment's sandbox + resume facts),
|
|
41
|
+
* `compaction` (the within-task flag), `excludeAllTools` (the valve's whole-face switch). Never mutated. */
|
|
42
|
+
spec: Pick<TaskSpec, "systemPrompt" | "appendSystemPrompt" | "clientContext" | "envFacts" | "compaction" | "excludeAllTools">;
|
|
43
|
+
/** borrowed-readonly — deployment deps: `onError` (the operator lane: fail-closed advisory, cwd misalignment,
|
|
44
|
+
* git-lane degrade), `modelKnowledgeCutoffs`. Receiver preserved (`deps.onError?.(…)`). */
|
|
45
|
+
deps: Pick<RunnerDeps, "onError" | "modelKnowledgeCutoffs">;
|
|
46
|
+
/** borrowed-readonly — the leg's mods bus (the harness-context block's "hooks may intercept" claim reads it). */
|
|
47
|
+
modBus: LegModBus;
|
|
44
48
|
/** borrowed-readonly — the self-orchestration fail-closed advisory (null = nothing to announce),
|
|
45
49
|
* evaluated by the DRIVER against the whole spec/deps (see the module header). */
|
|
46
50
|
failClosedReason: string | null;
|
|
@@ -58,14 +62,15 @@ export interface PreparePromptInputsInput {
|
|
|
58
62
|
resolvedReadFace: ContainmentFace | undefined;
|
|
59
63
|
/** borrowed-readonly — the resolved write face (the open-writes flag + the structured env fact). */
|
|
60
64
|
resolvedWriteFace: ContainmentFace | undefined;
|
|
61
|
-
/** borrowed-readonly — the frozen tool face;
|
|
62
|
-
|
|
65
|
+
/** borrowed-readonly — the frozen tool face; `defer` (the Workflow short-pointer flag) and `selector` (with the spec's whole-face
|
|
66
|
+
* switch, the valve's reading that decides which servers' instructions are taught). */
|
|
67
|
+
toolFaceSnapshot: Pick<ToolFaceSnapshot, "defer" | "selector">;
|
|
63
68
|
/** borrowed-readonly — the resolved prompt profile (rides the flags to the legacy ctx). */
|
|
64
69
|
promptProfile: "simple" | "classic";
|
|
65
70
|
/** borrowed-readonly — the fable-mitigations profile axis (rides the flags with the profile). */
|
|
66
71
|
fableMitigations: boolean;
|
|
67
72
|
/** borrowed-readonly — trusted internals: `goalMode` (goal flag), `isolation` (worktree flag),
|
|
68
|
-
* `defaultSystemPrompt` (the third
|
|
73
|
+
* `defaultSystemPrompt` (the sugar's third source). `undefined` on a standalone prepare. */
|
|
69
74
|
internals: Pick<RunInternals, "goalMode" | "isolation" | "defaultSystemPrompt"> | undefined;
|
|
70
75
|
/** borrowed-readonly — the resolved, role-folded reasoning tier (the awareness flag's input). */
|
|
71
76
|
thinking: ThinkingLevel | undefined;
|
|
@@ -78,8 +83,12 @@ export interface PreparePromptInputsInput {
|
|
|
78
83
|
};
|
|
79
84
|
/** borrowed-readonly — the resolved role; only its `systemPrompt` preset is read (second source). */
|
|
80
85
|
resolvedRole: Pick<ResolvedRole, "systemPrompt">;
|
|
81
|
-
/** borrowed-
|
|
82
|
-
|
|
86
|
+
/** borrowed-mutable — the materialized MCP roster; `serverInstructions` (the disposed entries) and `tools` (each server's listing: did it list
|
|
87
|
+
* any tool) are read, and the instructions lane's ledger is stated: the block is what the model is told at the run's start. */
|
|
88
|
+
mcp: Pick<MaterializedMcp, "serverInstructions" | "tools" | "instructionsDelta">;
|
|
89
|
+
/** borrowed-readonly — the run's roster as the protocol-tools phase mounted it (the deployment's overlay applied, the valve not yet):
|
|
90
|
+
* the tools the teaching answer reads, with the valve's predicate. */
|
|
91
|
+
roster: Pick<RosterBuilder, "tools">;
|
|
83
92
|
/** borrowed-readonly — the resolved model (id for the env line + the cutoff lookup). */
|
|
84
93
|
model: Model;
|
|
85
94
|
/** borrowed-readonly — the run's external-content-target fold (the single-source disclosure fact). */
|
|
@@ -111,14 +120,10 @@ export interface PreparePromptInputsInput {
|
|
|
111
120
|
contextOverlay?: ContextWindowOverlay;
|
|
112
121
|
}
|
|
113
122
|
export interface PreparePromptInputsResult {
|
|
114
|
-
/** owned — the prompt provider in force (`spec` ?? `deps` ?? the default). */
|
|
115
|
-
provider: PromptProvider;
|
|
116
123
|
/** owned — the runtime feature flags (see {@link PromptFeatureFlags}). */
|
|
117
124
|
featureFlags: PromptFeatureFlags;
|
|
118
|
-
/** owned — the
|
|
119
|
-
|
|
120
|
-
/** owned — the caller's append block (`spec.appendSystemPrompt`). */
|
|
121
|
-
userAppendSystemPrompt: string | undefined;
|
|
125
|
+
/** owned — the request-body sugar's overlays (the task class's first contributions), in application order. */
|
|
126
|
+
sugar: readonly SourcedOverlay[];
|
|
122
127
|
/** owned — the fenced MCP server-instructions block, or undefined when no server declared any. */
|
|
123
128
|
mcpInstructionsBlock: string | undefined;
|
|
124
129
|
/** owned — the environment facts the env tail renders from. Filled here; no later phase writes it
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { formatLocalDate, isValidTimeZone
|
|
1
|
+
import { formatLocalDate, isValidTimeZone } from "../../prompts/default.js";
|
|
2
|
+
import { sugarOverlays } from "../../prompt-assembly/sugar.js";
|
|
3
|
+
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
4
|
+
import { instructionsTaught, toldAtStart } from "../mounted-mcp.js";
|
|
2
5
|
import { isIsolated } from "../remote-env.js";
|
|
3
6
|
import { readDateAnchor } from "./announce-once-ledger.js";
|
|
4
7
|
import { probeGitStatusLane } from "./git-status-frame.js";
|
|
@@ -7,10 +10,8 @@ const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
|
|
|
7
10
|
import { compactionEnabled } from "../context-settings.js";
|
|
8
11
|
export async function preparePromptInputs(input) {
|
|
9
12
|
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
13
|
const promptPolicyEnabled = Boolean(lockedPreflight.toolPolicy);
|
|
12
|
-
const
|
|
13
|
-
const promptHooksEnabled = Boolean(promptHooks?.preToolUse || promptHooks?.postToolUse);
|
|
14
|
+
const promptHooksEnabled = input.modBus.hasHandlers("classic.PreToolUse") || input.modBus.hasHandlers("classic.PostToolUse");
|
|
14
15
|
if (failClosedReason) {
|
|
15
16
|
deps.onError?.(new Error(failClosedReason), { phase: "config", sessionId });
|
|
16
17
|
}
|
|
@@ -31,11 +32,11 @@ export async function preparePromptInputs(input) {
|
|
|
31
32
|
withinTaskCompactionEnabled: compactionEnabled(spec.compaction?.enabled, input.contextOverlay) && (spec.compaction?.withinTask ?? true),
|
|
32
33
|
isSubagent: delegation.isNonForkChild,
|
|
33
34
|
};
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const sugar = sugarOverlays({ spec, resolvedRole, ...(internals !== undefined ? { internals } : {}) });
|
|
36
|
+
const valveLeft = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
37
|
+
const taught = mcp.serverInstructions.filter((entry) => instructionsTaught(valveLeft, entry.server, input.roster.tools, mcp.tools));
|
|
38
|
+
toldAtStart(mcp.instructionsDelta, new Set(taught.map((entry) => entry.server)));
|
|
39
|
+
const mcpInstructionsBlock = taught.length ? `# MCP Server Instructions\n${taught.map(renderMcpInstructionsEntry).join("\n\n")}` : undefined;
|
|
39
40
|
const userTz = spec.clientContext?.timeZone;
|
|
40
41
|
const tzValid = userTz !== undefined && isValidTimeZone(userTz);
|
|
41
42
|
const dateAnchor = await readDateAnchor(session);
|
|
@@ -143,5 +144,5 @@ export async function preparePromptInputs(input) {
|
|
|
143
144
|
taskRoot: taskRootFinal,
|
|
144
145
|
onDegrade: (reason) => deps.onError?.(new Error(`env git snapshot degraded — ${reason}`), { phase: "degraded", sessionId, classification: "env-git-snapshot" }),
|
|
145
146
|
});
|
|
146
|
-
return {
|
|
147
|
+
return { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz, dateAnchor, gitStatusRef };
|
|
147
148
|
}
|