@sema-agent/core 5.20.0 → 5.21.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 +9 -0
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-transcript-tool.d.ts +30 -0
- package/dist/agents/builtin-agents.d.ts +60 -0
- package/dist/agents/cascade.d.ts +107 -0
- package/dist/agents/cumulative-stats.d.ts +56 -0
- package/dist/agents/observer.d.ts +162 -0
- package/dist/agents/peer-admission.d.ts +95 -0
- package/dist/agents/repair-loop.d.ts +226 -0
- package/dist/agents/retain-ledger.d.ts +141 -0
- package/dist/agents/roster-store.d.ts +105 -0
- package/dist/agents/send-message-tool.d.ts +92 -0
- package/dist/agents/session-util.d.ts +5 -0
- package/dist/agents/subagent-steps.d.ts +66 -0
- package/dist/agents/subagent.d.ts +600 -0
- package/dist/agents/suspend-guard.d.ts +29 -0
- package/dist/agents/teacher.d.ts +75 -0
- package/dist/agents/team.d.ts +120 -1
- package/dist/agents/tool-filter.d.ts +34 -0
- package/dist/agents/verify.d.ts +198 -0
- package/dist/bench/metrics.d.ts +455 -0
- package/dist/brain/anthropic.d.ts +30 -0
- package/dist/brain/circuit-breaker.d.ts +33 -0
- package/dist/brain/context-overflow.d.ts +60 -3
- package/dist/brain/degrading.d.ts +67 -0
- package/dist/brain/errors.d.ts +42 -0
- package/dist/brain/failover.d.ts +15 -0
- package/dist/brain/media-degrade.d.ts +39 -0
- package/dist/brain/model-presets.d.ts +31 -0
- package/dist/brain/open-responses.d.ts +19 -0
- package/dist/brain/openai.d.ts +46 -0
- package/dist/brain/reasoning.d.ts +106 -1
- package/dist/brain/repetition.d.ts +83 -0
- package/dist/brain/request-params.d.ts +56 -0
- package/dist/brain/retry.d.ts +46 -0
- package/dist/brain/routing.d.ts +12 -0
- package/dist/brain/status-sink.d.ts +30 -1
- package/dist/brain/stream-engine.d.ts +147 -0
- package/dist/brain/stream-shared.d.ts +34 -0
- package/dist/brain/terminal-cause.d.ts +31 -0
- package/dist/brain/timeout.d.ts +107 -0
- package/dist/brain/tool-call-id.d.ts +20 -0
- package/dist/brain/tool-call-repair.d.ts +13 -0
- package/dist/config/catalog.d.ts +47 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/core/a2a-task-state.d.ts +53 -0
- package/dist/core/a2a.d.ts +51 -0
- package/dist/core/arg-summary.d.ts +62 -0
- package/dist/core/ask-question.d.ts +272 -2
- package/dist/core/auto-compaction.d.ts +467 -0
- package/dist/core/auto-compaction.js +20 -6
- package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
- package/dist/core/auto-mode-prompt.d.ts +27 -0
- package/dist/core/auto-mode.d.ts +54 -3
- package/dist/core/auto-promote.d.ts +100 -0
- package/dist/core/background-agent-store.d.ts +292 -0
- package/dist/core/background-shell.d.ts +110 -0
- package/dist/core/cache-break-detector.d.ts +34 -0
- package/dist/core/canonical-json.d.ts +57 -0
- package/dist/core/checkpoint-store.d.ts +1574 -16
- package/dist/core/compliance.d.ts +30 -0
- package/dist/core/consolidate-scope.d.ts +75 -0
- package/dist/core/context-edit.d.ts +99 -0
- package/dist/core/context-guard.d.ts +46 -0
- package/dist/core/exec-gate.d.ts +44 -0
- package/dist/core/exec-output-tail.d.ts +61 -0
- package/dist/core/file-snapshot-store.d.ts +104 -0
- package/dist/core/fs-write-gate-policy.d.ts +36 -0
- package/dist/core/git-worktree-env.d.ts +31 -0
- package/dist/core/governance-codes.d.ts +19 -0
- package/dist/core/hooks.d.ts +608 -1
- package/dist/core/human-input-projection.d.ts +37 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/image-downsample.d.ts +74 -0
- package/dist/core/locked-config.d.ts +37 -0
- package/dist/core/lsp-diagnostics.d.ts +77 -0
- package/dist/core/lsp-protocol.d.ts +29 -0
- package/dist/core/lsp-session.d.ts +60 -1
- package/dist/core/lsp.d.ts +150 -1
- package/dist/core/mailbox-store.d.ts +57 -0
- package/dist/core/mcp.d.ts +381 -0
- package/dist/core/media-byte-cap.d.ts +21 -0
- package/dist/core/memory-admission.d.ts +71 -0
- package/dist/core/memory-engine/content-origin.d.ts +64 -0
- package/dist/core/memory-engine/data-plane.d.ts +43 -0
- package/dist/core/memory-engine/dual-root.d.ts +24 -0
- package/dist/core/memory-engine/engine.d.ts +230 -0
- package/dist/core/memory-engine/engine.js +103 -35
- package/dist/core/memory-engine/file-backend.d.ts +155 -0
- package/dist/core/memory-engine/frontmatter.d.ts +16 -0
- package/dist/core/memory-engine/layout.d.ts +217 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
- package/dist/core/memory-engine/migrate.d.ts +9 -0
- package/dist/core/memory-engine/scan.d.ts +12 -0
- package/dist/core/memory-engine/scope-contract.d.ts +61 -1
- package/dist/core/memory-engine/sync-client.d.ts +87 -0
- package/dist/core/memory-engine/sync.d.ts +60 -0
- package/dist/core/memory-engine/tools.d.ts +41 -0
- package/dist/core/memory-engine/types.d.ts +188 -0
- package/dist/core/memory-recall.d.ts +141 -0
- package/dist/core/memory-vector.d.ts +20 -0
- package/dist/core/memory.d.ts +458 -0
- package/dist/core/message-utils.d.ts +6 -0
- package/dist/core/oracle-isolation.d.ts +69 -0
- package/dist/core/permission-rule-consent.d.ts +138 -0
- package/dist/core/permission-rule-model.d.ts +122 -0
- package/dist/core/permission-rule-store.d.ts +119 -3
- package/dist/core/permission-rules.d.ts +87 -1
- package/dist/core/present-plan-tool.d.ts +20 -0
- package/dist/core/pricing.d.ts +26 -0
- package/dist/core/property-harness.d.ts +86 -0
- package/dist/core/protocol-naming.d.ts +38 -0
- package/dist/core/protocol-table.d.ts +61 -0
- package/dist/core/push-queue.d.ts +1 -0
- package/dist/core/remote-env.d.ts +383 -1
- package/dist/core/retention-policy.d.ts +33 -0
- package/dist/core/retention.d.ts +51 -0
- package/dist/core/roles.d.ts +59 -0
- package/dist/core/runner/active-skill-scope.d.ts +34 -0
- package/dist/core/runner/assemble-result.d.ts +134 -0
- package/dist/core/runner/compaction-call-options.d.ts +97 -1
- package/dist/core/runner/grounding-signal.d.ts +10 -0
- package/dist/core/runner/image.d.ts +17 -0
- package/dist/core/runner/image.js +29 -15
- package/dist/core/runner/memory-consolidation.d.ts +60 -0
- package/dist/core/runner/prepare-memory.d.ts +59 -0
- package/dist/core/runner/prepare-task.d.ts +1011 -2
- package/dist/core/runner/prepare-task.js +12 -11
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- package/dist/core/runner/session-file-state-replay.d.ts +49 -0
- package/dist/core/runner/session-rule-policy.d.ts +58 -0
- package/dist/core/runner/strict-output-schema.d.ts +18 -3
- package/dist/core/runner/synthetic-tools.d.ts +113 -0
- package/dist/core/runner/teardown-bounded.d.ts +34 -0
- package/dist/core/runner/tool-disclosure.d.ts +227 -0
- package/dist/core/runner/tool-output-projection.d.ts +6 -0
- package/dist/core/runner/turn-attachments.d.ts +634 -0
- package/dist/core/runner/usage-accounting.d.ts +32 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/safe-notify.d.ts +64 -0
- package/dist/core/safety-axis-vocab.d.ts +23 -0
- package/dist/core/safety-merge-corpus.d.ts +37 -0
- package/dist/core/scheduler.d.ts +121 -0
- package/dist/core/secret-env.d.ts +32 -0
- package/dist/core/select-model.d.ts +15 -0
- package/dist/core/sensitive-path-policy.d.ts +42 -0
- package/dist/core/session-policy-store.d.ts +94 -0
- package/dist/core/session-reconcile.d.ts +80 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session.d.ts +153 -0
- package/dist/core/shared-memory/contract.d.ts +22 -0
- package/dist/core/shared-memory/normalize.d.ts +123 -2
- package/dist/core/shared-memory/tools.d.ts +14 -0
- package/dist/core/shared-memory/types.d.ts +105 -0
- package/dist/core/shutdown-debug.d.ts +6 -0
- package/dist/core/side-query.d.ts +38 -0
- package/dist/core/side-query.js +6 -1
- package/dist/core/skill-tool-specifier.d.ts +72 -0
- package/dist/core/skills-directory.d.ts +100 -1
- package/dist/core/spec-contract.d.ts +89 -0
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
- package/dist/core/store-contracts/contract-harness.d.ts +20 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
- package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
- package/dist/core/strategy-store.d.ts +37 -0
- package/dist/core/stub-env.d.ts +7 -0
- package/dist/core/surrogate-safe-slice.d.ts +35 -0
- package/dist/core/task-notification.d.ts +202 -0
- package/dist/core/task-outcome.d.ts +53 -0
- package/dist/core/task-registry-agent.d.ts +337 -1
- package/dist/core/task-registry-monitor.d.ts +12 -0
- package/dist/core/task-registry-shared.d.ts +540 -0
- package/dist/core/task-registry.d.ts +343 -0
- package/dist/core/task-registry.js +13 -2
- package/dist/core/task-tool-shape.d.ts +44 -0
- package/dist/core/tighten-task-spec.d.ts +21 -0
- package/dist/core/tool-detach.d.ts +21 -0
- package/dist/core/tool-errors.d.ts +131 -0
- package/dist/core/tool-errors.js +4 -0
- package/dist/core/tool-name-aliases.d.ts +27 -0
- package/dist/core/tool-policy.d.ts +555 -0
- package/dist/core/tool-result-budget.d.ts +32 -0
- package/dist/core/tool-result-store.d.ts +174 -1
- package/dist/core/tools.d.ts +45 -0
- package/dist/core/trace.d.ts +323 -0
- package/dist/core/types.d.ts +3859 -2
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-text.d.ts +156 -0
- package/dist/core/usage-window-store.d.ts +95 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/warm-resume.d.ts +17 -0
- package/dist/core/wiring-manifest.d.ts +169 -0
- package/dist/core/with-retry.d.ts +24 -0
- package/dist/core/workflow-journal-store.d.ts +160 -0
- package/dist/core/workflow-run-store-contract.d.ts +25 -0
- package/dist/core/workflow-run-store.d.ts +119 -0
- package/dist/engine/compaction/compaction.d.ts +256 -1
- package/dist/engine/compaction/utils.d.ts +94 -0
- package/dist/engine/execution-env/kill-tree.d.ts +29 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
- package/dist/engine/harness/agent-harness.d.ts +116 -0
- package/dist/engine/harness/agent-harness.js +3 -14
- package/dist/engine/harness/messages.d.ts +15 -0
- package/dist/engine/harness/types.d.ts +464 -2
- package/dist/engine/llm/diagnostics.d.ts +4 -0
- package/dist/engine/llm/event-stream.d.ts +3 -0
- package/dist/engine/llm/index.d.ts +7 -0
- package/dist/engine/llm/types.d.ts +500 -3
- package/dist/engine/llm/validation.d.ts +3 -0
- package/dist/engine/loop/agent-loop.d.ts +87 -2
- package/dist/engine/loop/runtime-deps.d.ts +7 -0
- package/dist/engine/loop/types.d.ts +424 -0
- package/dist/engine/lsp/frame-decoder.d.ts +13 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
- package/dist/engine/session/import-validate.d.ts +27 -0
- package/dist/engine/session/log-digest.d.ts +93 -0
- package/dist/engine/session/memory-repo.d.ts +6 -0
- package/dist/engine/session/memory-storage.d.ts +2 -0
- package/dist/engine/session/session.d.ts +75 -0
- package/dist/engine/session/storage-base.d.ts +8 -0
- package/dist/fixtures/index.d.ts +36 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +0 -1
- package/dist/internal/harness-types.d.ts +6 -0
- package/dist/internal/harness.d.ts +11 -0
- package/dist/internal/llm.d.ts +6 -0
- package/dist/orchestration/builtin-workflows.d.ts +53 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
- package/dist/orchestration/goal.d.ts +57 -0
- package/dist/orchestration/goal.js +3 -0
- package/dist/orchestration/run-spec.d.ts +42 -0
- package/dist/orchestration/run-workflow-tool.d.ts +169 -0
- package/dist/orchestration/workflow-governance.d.ts +61 -0
- package/dist/orchestration/workflow-meta.d.ts +28 -0
- package/dist/orchestration/workflow-observe.d.ts +60 -0
- package/dist/orchestration/workflow-primitives.d.ts +23 -1
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
- package/dist/orchestration/workflow-script-runner.d.ts +88 -0
- package/dist/orchestration/workflow-script-store.d.ts +98 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
- package/dist/orchestration/workflow-types.d.ts +169 -2
- package/dist/orchestration/workflow.d.ts +358 -0
- package/dist/prompt-assembly/artifact-store.d.ts +33 -0
- package/dist/prompt-assembly/artifact.d.ts +25 -0
- package/dist/prompt-assembly/assemble.d.ts +20 -0
- package/dist/prompt-assembly/composer.d.ts +29 -0
- package/dist/prompt-assembly/epoch.d.ts +55 -1
- package/dist/prompt-assembly/event-registry.d.ts +35 -0
- package/dist/prompt-assembly/explain.d.ts +12 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
- package/dist/prompt-assembly/types.d.ts +115 -0
- package/dist/prompts/coordinator.d.ts +27 -0
- package/dist/prompts/default.d.ts +539 -0
- package/dist/prompts/simple-sections.d.ts +45 -0
- package/dist/prompts/supervisor.d.ts +66 -0
- package/dist/scenarios/env.d.ts +28 -0
- package/dist/scenarios/full-body.d.ts +50 -0
- package/dist/scenarios/scenario-registry.d.ts +60 -0
- package/dist/scenarios/teacher-quickstart.d.ts +27 -0
- package/dist/server/http.d.ts +17 -0
- package/dist/stores/cc/lockfile.d.ts +6 -0
- package/dist/stores/cc/mailbox-store.d.ts +8 -0
- package/dist/stores/cc/roster-adapter.d.ts +4 -0
- package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
- package/dist/stores/file/background-agent-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.d.ts +38 -0
- package/dist/stores/file/file-snapshot-store.d.ts +25 -0
- package/dist/stores/file/fs-atomic.d.ts +155 -0
- package/dist/stores/file/index.d.ts +89 -0
- package/dist/stores/file/mailbox-store.d.ts +36 -0
- package/dist/stores/file/memory-store.d.ts +82 -0
- package/dist/stores/file/permission-rule-store.d.ts +79 -0
- package/dist/stores/file/session-policy-store.d.ts +28 -0
- package/dist/stores/file/session-store.d.ts +40 -0
- package/dist/stores/file/shared-ledger.d.ts +83 -0
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/usage-window-store.d.ts +18 -0
- package/dist/stores/file/workflow-journal-store.d.ts +100 -0
- package/dist/stores/file/workflow-run-store.d.ts +11 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
- package/dist/tools/fs/encoding.d.ts +60 -0
- package/dist/tools/fs/fs-bash.d.ts +133 -0
- package/dist/tools/fs/fs-pdf.d.ts +28 -0
- package/dist/tools/fs/fs-search-tools.d.ts +5 -0
- package/dist/tools/fs/fs-shared.d.ts +360 -0
- package/dist/tools/fs/fs-write.d.ts +16 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
- package/dist/tools/fs/index.d.ts +79 -0
- package/dist/tools/fs/notebook.d.ts +56 -0
- package/dist/tools/fs/pdf.d.ts +70 -0
- package/dist/tools/fs/pdf.js +8 -2
- package/dist/tools/fs/repo-map.d.ts +10 -0
- package/dist/tools/fs/safety.d.ts +376 -0
- package/dist/tools/fs/search.d.ts +131 -0
- package/dist/tools/loop-tick.d.ts +24 -0
- package/dist/tools/monitor.d.ts +55 -0
- package/dist/tools/scheduler-tools.d.ts +51 -0
- package/dist/tools/sql-adapters.d.ts +18 -0
- package/dist/tools/sql.d.ts +25 -0
- package/dist/tools/task-list.d.ts +77 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/web.d.ts +184 -0
- package/dist/tools/worktree.d.ts +81 -0
- package/package.json +2 -2
- package/dist/tools/gitea-issue.d.ts +0 -13
- package/dist/tools/gitea-issue.js +0 -75
|
@@ -5,115 +5,422 @@ import type { WorkflowRunStore } from "../core/workflow-run-store.js";
|
|
|
5
5
|
import type { WorkflowJournalStore, ResumeClaimArgs } from "../core/workflow-journal-store.js";
|
|
6
6
|
import type { WorkflowRun, WorkflowEvent } from "./workflow-types.js";
|
|
7
7
|
export * from "./workflow-types.js";
|
|
8
|
+
/** 198 `P0m` (pretty.js:447248) — prose state: the child's final text is the script-facing return value. */
|
|
8
9
|
export declare const WORKFLOW_SUBAGENT_PROMPT = "You are a subagent spawned by a workflow orchestration script. Use the tools available to complete the task.\n\nCRITICAL: Your final text response is returned **verbatim** as a string to the calling script \u2014 it is your return value, not a message to a human.\n- Output the literal result (data, JSON, text). Do NOT output confirmations like \"Done.\" or \"Sent.\"\n- If asked for JSON, return ONLY the raw JSON \u2014 no code fences, no prose, no markdown.\n- Do NOT address a human user \u2014 there is no user on the other end. Put your answer in your final text response.\n- Do NOT delegate to further sub-agents or start nested workflows; complete the task yourself.\n- Be concise. The script will parse your output.";
|
|
10
|
+
/** 198 `M0m` (pretty.js:447333) — schema state: the answer goes through the StructuredOutput tool, once. */
|
|
9
11
|
export declare const WORKFLOW_SUBAGENT_PROMPT_SCHEMA = "You are a subagent spawned by a workflow orchestration script. Use the tools available to complete the task.\n\nCRITICAL: You MUST call the StructuredOutput tool exactly once to return your final answer. The tool's input schema defines the required shape.\n- Do your work (Read files, run commands, etc.), then call StructuredOutput with your answer.\n- Do NOT put your answer in a text response. The script reads ONLY the StructuredOutput tool call.\n- If the schema validation fails, read the error and call StructuredOutput again with a corrected shape.\n- After calling StructuredOutput successfully, end your turn. No acknowledgment needed.\n- Do NOT delegate to further sub-agents or start nested workflows; complete the task yourself.";
|
|
12
|
+
/** 198 composite prose-append `O0m` (pretty.js:447255) — a script-supplied CUSTOM persona gets the return
|
|
13
|
+
* contract APPENDED (never replaced), mirroring 198's `opts.agentType` + schema composition. VERBATIM
|
|
14
|
+
* (PARITY-SPOT-WORKFLOW F6/B6): 198's constant opens with a `---` separator line and closes with the
|
|
15
|
+
* "Output the literal result; do not output confirmations…" tail — the previous sema paraphrase drifted. */
|
|
10
16
|
export declare const WORKFLOW_SUBAGENT_APPEND = "---\n\nNOTE: You are running inside a workflow script. Your final text response is returned verbatim as a string to the calling script \u2014 it is your return value, not a message to a human. Output the literal result; do not output confirmations like \"Done.\" Be concise \u2014 the script will parse your output.";
|
|
17
|
+
/** 198 composite schema-append `L0m` (pretty.js:447328) — VERBATIM incl. the `---` opener (F6/B6; the old
|
|
18
|
+
* sema text compressed the "Do your work, then call X" instruction out). */
|
|
11
19
|
export declare const WORKFLOW_SUBAGENT_APPEND_SCHEMA = "---\n\nNOTE: You are running inside a workflow script. You MUST return your final answer by calling the StructuredOutput tool exactly once \u2014 the tool's input schema defines the required shape. Do your work, then call StructuredOutput; do NOT put your answer in a text response (the script reads ONLY the tool call). If validation fails, read the error and call StructuredOutput again with a corrected shape.";
|
|
20
|
+
/**
|
|
21
|
+
* Apply the G5 default persona to a `ctx.agent`/`ctx.agentStream` child spec. Two-state on the EFFECTIVE
|
|
22
|
+
* schema (`agentOpts.schema` wins over a spec-carried `outputSchema`, same as the runSpec injection):
|
|
23
|
+
* • no `spec.systemPrompt` → the dedicated workflow-subagent persona REPLACES the role base (198
|
|
24
|
+
* default `workflow-subagent` agent-type semantics);
|
|
25
|
+
* • a script-supplied `spec.systemPrompt` (custom persona) → the matching NOTE is APPENDED via
|
|
26
|
+
* `appendSystemPrompt` (198 composite semantics — append, never replace), after any existing append.
|
|
27
|
+
* Called AFTER the call-key is computed (the journal identity keys the AUTHORED spec, so a resume across
|
|
28
|
+
* core versions replays cleanly; the persona is an execution detail, not call identity).
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* F4 agentType (CC 198 锚 pretty.js:446608-446627): resolve `opts.agentType` against the registry
|
|
32
|
+
* (deployment SHADOW over built-ins) and fold the definition into the child spec — persona as
|
|
33
|
+
* `systemPrompt` (so {@link withWorkflowChildPersona} composes the return-contract NOTE via the
|
|
34
|
+
* custom-persona APPEND arm = CC `O0m` semantics), model/thinking/maxTurns/skills/memory when the spec
|
|
35
|
+
* didn't pin them, and allow/denyTools as a ToolPolicy (combined deny-wins with any spec policy).
|
|
36
|
+
* The definition is DEPLOYMENT-TRUSTED (registry-declared, not script-authored), so its model bypasses
|
|
37
|
+
* the script-facing modelName allowlist by design — same trust tier as the Agent tool's registry.
|
|
38
|
+
*/
|
|
12
39
|
export declare function applyWorkflowAgentType(spec: TaskSpec, agentType: string | undefined, registry: AgentDefinition[]): TaskSpec;
|
|
40
|
+
/** The agentType registry for one workflow run: built-ins (unless opted out) with deployment SHADOW. */
|
|
13
41
|
export declare function workflowAgentRegistry(opts: {
|
|
14
42
|
agents?: AgentDefinition[];
|
|
15
43
|
builtinAgents?: boolean;
|
|
16
44
|
}): AgentDefinition[];
|
|
45
|
+
/**
|
|
46
|
+
* design/97 CORE-1 (foundation) — the STABLE, deterministic identity of one `ctx.agent` call, so the resume
|
|
47
|
+
* journal (CORE-7) can key a cached result and the observe tree (CORE-3/5) can hang per-agent data off it.
|
|
48
|
+
* `ordinal` is the synchronous call-order index (`run.agents.length` at RECORD time — captured BEFORE the
|
|
49
|
+
* `sem.acquire` await, so for `parallel(direct thunks)`/sequential it is deterministic run-to-run. `pipeline`'s
|
|
50
|
+
* stage-2+ ordinals are LATENCY-dependent (NOT deterministic) — so `pipeline` conservatively forces replay
|
|
51
|
+
* divergence and runs live on resume; deterministic stage-scoped keys are a CORE-7.1 follow-on. The hash is over
|
|
52
|
+
* the WHOLE behaviour-defining spec (audit fix — a cherry-pick missed images/thinking/limits/maxTokens/model
|
|
53
|
+
* runtime fields), with non-behavioural identity (taskId/sessionId/signal) stripped and tools/mcp reduced to
|
|
54
|
+
* NAMES (their closures aren't serializable). SHARED pure fn (anti-drift): the journal MUST key through this.
|
|
55
|
+
*/
|
|
17
56
|
export declare function workflowAgentCallKey(ordinal: number, spec: TaskSpec, opts: {
|
|
18
57
|
schema?: TSchema;
|
|
19
58
|
isolation?: "worktree";
|
|
20
59
|
}): string;
|
|
60
|
+
/**
|
|
61
|
+
* RB-394 (黑板 [2107]③) — runtime rejection of an unsupported `isolation` value at the workflow spawn
|
|
62
|
+
* boundary. The TYPE (`isolation?: "worktree"`) only binds TS callers: a workflow script is plain JS at
|
|
63
|
+
* runtime, so a value like `"remote"` previously sailed through every `=== "worktree"` consumption gate
|
|
64
|
+
* as a truthy non-match — the trusted internals channel carried it verbatim, prepareTask's fail-closed
|
|
65
|
+
* worktree enforcement never fired (it keys on `=== "worktree"` too), and the agent ran SILENTLY in the
|
|
66
|
+
* shared working tree: the exact degrade the worktree contract calls out as forbidden. The same value at
|
|
67
|
+
* the Agent tool boundary dies a loud schema rejection — this is that boundary's workflow-lane
|
|
68
|
+
* counterpart. The literal `"worktree"` and absence pass unchanged. Module-level export for the script
|
|
69
|
+
* membrane (`safeAgentOptions` in workflow-primitives.ts, which must REJECT rather than silently DROP the
|
|
70
|
+
* value — the drop re-created the identical silent outcome on the LLM-script lane); not on the package face.
|
|
71
|
+
*
|
|
72
|
+
* RB-425 — ABSENCE has more than one runtime spelling. `null` / `false` / `""` is what a wire-parsed or
|
|
73
|
+
* defensively-defaulted script option looks like when the field is simply NOT SET, and every downstream
|
|
74
|
+
* consumption gate (`=== "worktree"`, or plain truthiness at the internals-channel and advisory sites)
|
|
75
|
+
* already treats them identically to `undefined`. Rejecting them turned a no-op option into a hard spawn
|
|
76
|
+
* failure while changing nothing about where the agent would actually run — a fail-closed gate firing
|
|
77
|
+
* where there is nothing to close. Only a TRUTHY non-match is the hazard above: a value that LOOKS like a
|
|
78
|
+
* request but silently degrades to the shared tree. That still dies loud.
|
|
79
|
+
*
|
|
80
|
+
* Not a narrowing assertion: the accepted set is "worktree" plus every falsy spelling of absence, which
|
|
81
|
+
* no type predicate states truthfully — and no caller needs the narrowing (all three read the value with
|
|
82
|
+
* `=== "worktree"` afterwards).
|
|
83
|
+
*/
|
|
21
84
|
export declare function assertSupportedAgentIsolation(isolation: unknown): void;
|
|
85
|
+
/** One failed fan-out slot, reported through the opt-in `errors` collector of `ctx.parallel`/`ctx.pipeline`.
|
|
86
|
+
* The default fan-out contract is unchanged (a thrown slot folds to `null`); a script that passes a
|
|
87
|
+
* collector array can discriminate WHY a slot folded (budget vs schema vs other) without any change to the
|
|
88
|
+
* shape of the results array. */
|
|
22
89
|
export interface WorkflowFanOutSlotError {
|
|
90
|
+
/** The failed slot's index in the input array (thunk index for `parallel`, item index for `pipeline`). */
|
|
23
91
|
index: number;
|
|
92
|
+
/** A stable discriminator: the error's `code` when it carries one (typed workflow errors), else the error
|
|
93
|
+
* class name, else `"Error"`. */
|
|
24
94
|
kind: string;
|
|
95
|
+
/** Bounded, redacted message summary (same egress discipline as the run log). */
|
|
25
96
|
message: string;
|
|
26
97
|
}
|
|
98
|
+
/** Opt-in options for `ctx.parallel` (second argument) and `ctx.pipeline` (trailing argument after the
|
|
99
|
+
* stages). Purely observational — omitting it keeps the exact legacy behavior. */
|
|
27
100
|
export interface WorkflowFanOutOptions {
|
|
101
|
+
/** Caller-supplied array; the engine pushes one {@link WorkflowFanOutSlotError} per failed slot (including
|
|
102
|
+
* budget-dropped slots, which fold silently otherwise). Results still fold to `null`. */
|
|
28
103
|
errors?: WorkflowFanOutSlotError[];
|
|
29
104
|
}
|
|
105
|
+
/** design/98 §D.6 hard cap: thrown when the script's returned result exceeds `maxResultChars` (a runaway
|
|
106
|
+
* script must not return an unbounded payload to the originator). */
|
|
30
107
|
export declare class WorkflowResultTooLargeError extends Error {
|
|
31
108
|
readonly size: number;
|
|
32
109
|
readonly max: number;
|
|
33
110
|
readonly code = "workflow.result_too_large";
|
|
34
111
|
constructor(size: number, max: number);
|
|
35
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* A TRUSTED, run-scoped internal channel carrying the workflow **nesting depth** across a process boundary
|
|
115
|
+
* (design/98 §0.1 BLOCKER3). It is NOT a `TaskSpec` field and NOT a `run_workflow` tool param — a worker or
|
|
116
|
+
* an LLM-authored script can never set it. When a deployment (e.g. the service) initiates a workflow on
|
|
117
|
+
* behalf of a parent run that is itself inside a workflow, it passes `workflowDepth = parentDepth + 1` here
|
|
118
|
+
* so the entry guard fires cross-process. In-process nesting needs no internals — the
|
|
119
|
+
* {@link workflowDepthStore} AsyncLocalStorage propagates depth into every `runner.runTask` child
|
|
120
|
+
* automatically. `startWorkflow` takes depth = `internals?.workflowDepth ?? ALS.depth ?? 0`.
|
|
121
|
+
*/
|
|
36
122
|
export interface WorkflowInternals {
|
|
37
123
|
workflowDepth?: number;
|
|
38
124
|
}
|
|
39
125
|
export interface WorkflowBudget {
|
|
126
|
+
/** The token ceiling, or null when none was set (then `remaining()` is Infinity). */
|
|
40
127
|
readonly total: number | null;
|
|
128
|
+
/** Cumulative tokens spent so far (own + nested across all agents). AUTHORITATIVE terminal accounting
|
|
129
|
+
* only: it advances when an agent attempt SETTLES. The per-turn runtime usage beat feeds the
|
|
130
|
+
* `run.stats` observation face (monitor rows move while a long agent runs) but never charges the
|
|
131
|
+
* budget gate — a provisional figure that may be rolled back must never have gated a spawn. */
|
|
41
132
|
spent(): number;
|
|
133
|
+
/** `max(0, total - spent())`, or Infinity when no budget was set. */
|
|
42
134
|
remaining(): number;
|
|
43
135
|
}
|
|
44
136
|
export interface WorkflowAgentOptions {
|
|
137
|
+
/** Display label for this agent-run (else `agent-N`). */
|
|
45
138
|
label?: string;
|
|
139
|
+
/**
|
|
140
|
+
* F4 (CC 198 parity, 锚 pretty.js:446608-446627; DEFER 解除 2026-07-11 — 前提「无 agent 注册表」被
|
|
141
|
+
* 1.262.0 agents F1 推翻): run this agent AS a named agent type from the deployment's registry
|
|
142
|
+
* (built-in Explore/Plan + `RunWorkflowOptions.agents`, deployment SHADOW wins on a name collision —
|
|
143
|
+
* the same registry the Agent tool's `subagent_type` resolves). The definition supplies persona
|
|
144
|
+
* (composed with the workflow return-contract NOTE — CC `O0m` append semantics), model (tier words OK,
|
|
145
|
+
* the catalog is tier-expanded), thinking, maxTurns, skills, memory and the allow/deny tool policy.
|
|
146
|
+
* An unknown name throws a teaching error listing the known types. Slot-tools carrier (design/140
|
|
147
|
+
* ②-3): a collab member slot's tool surface = its agent type's allow/denyTools — no new mechanism.
|
|
148
|
+
*/
|
|
46
149
|
agentType?: string;
|
|
150
|
+
/** Explicitly group this agent under a phase title (use this inside `parallel`/`pipeline` where the
|
|
151
|
+
* global enclosing-phase state races — design/97 §D race note). */
|
|
47
152
|
phase?: string;
|
|
153
|
+
/** Per-agent cancellation; falls back to the workflow signal. */
|
|
48
154
|
signal?: AbortSignal;
|
|
155
|
+
/**
|
|
156
|
+
* Force a STRUCTURED result for this sub-agent (design/98 §0.2). Sets the child task's `outputSchema` to
|
|
157
|
+
* this typebox schema; the validated object is surfaced as `TaskResult.structuredOutput`. **Strict**: if
|
|
158
|
+
* the child COMPLETES without a `structuredOutput` (the model answered in prose — core permits that),
|
|
159
|
+
* `ctx.agent` throws {@link WorkflowAgentSchemaError} rather than silently returning `undefined`. A child
|
|
160
|
+
* that ends non-`completed` is returned as-is (the script checks `status`). If the script's `spec` already
|
|
161
|
+
* carried an `outputSchema`, this option wins.
|
|
162
|
+
*/
|
|
49
163
|
schema?: TSchema;
|
|
164
|
+
/**
|
|
165
|
+
* design/97 CORE-6: run this agent in an ISOLATED git WORKTREE so parallel agents editing the same repo
|
|
166
|
+
* don't conflict. A SCRIPT-FACING OPTION (NOT a TaskSpec field — an untrusted spec can't self-select an env,
|
|
167
|
+
* design/44 §7 Q4): threaded via the TRUSTED RunInternals.isolation to the control-plane executionEnvFactory,
|
|
168
|
+
* which mints a worktree-rooted env (e.g. {@link addWorktree}). The worktree is INSIDE the one configured env
|
|
169
|
+
* (local OR a single E2B) — not a per-agent container. ISOLATE-ONLY: the runtime never merges; the
|
|
170
|
+
* orchestrator script reads each worktree's result and decides verify/merge in userland. Requires a
|
|
171
|
+
* worktree-capable `executionEnvFactory` — FAIL-CLOSED: a request the deployment cannot honor fails the
|
|
172
|
+
* spawn at prepare time (the child never starts; no silent fallback to the shared working tree, which
|
|
173
|
+
* would be unsafe under a relaxed `WorkflowGovernanceBaseline.worktreeBase`). Durable-suspend is
|
|
174
|
+
* incompatible (the factory env is non-remote).
|
|
175
|
+
*/
|
|
50
176
|
isolation?: "worktree";
|
|
51
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* design/97 CORE-5 (#6 steer) — the handle returned by {@link WorkflowRunContext.agentStream}: a STILL-RUNNING
|
|
180
|
+
* agent the launcher can STEER mid-flight and then await. The recording (callKey/groupId/prompt + stats/output +
|
|
181
|
+
* `agent_end`) and the concurrency slot are tied to the underlying stream settling (an eager completion), NOT to
|
|
182
|
+
* `result()` being called — so a script that defers `result()` still records and releases. ⚠️ EXCEPTION (audit
|
|
183
|
+
* MAJOR): if the script returns and the run FINALIZES before the stream settles, the eager completion hits the
|
|
184
|
+
* finalized-guard and skips the trailing record — so a fire-and-forget stream the body never awaits may be left
|
|
185
|
+
* as `running`. A leader that wants the outcome (the normal case) awaits `result()`, which is fully recorded.
|
|
186
|
+
*/
|
|
52
187
|
export interface WorkflowAgentHandle {
|
|
188
|
+
/** The enclosing workflow run id (NOT a per-agent id — agentStream does not mint a sub-run). */
|
|
53
189
|
runId: string;
|
|
190
|
+
/** This agent's display label. */
|
|
54
191
|
label: string;
|
|
192
|
+
/** This agent's deterministic {@link workflowAgentCallKey}. */
|
|
55
193
|
callKey: string;
|
|
194
|
+
/**
|
|
195
|
+
* Inject an operator/leader STEER into the running worker (design/47 `TaskStream.steer`). The content is
|
|
196
|
+
* FENCED (untrusted data — it can't pose as authority) inside a TRUSTED framing that asks the worker to TAG
|
|
197
|
+
* its reply with the returned marker. Returns that MARKER so the launcher can correlate the worker's tagged
|
|
198
|
+
* reply via the #5 transcript (the worker self-stamps; reply is best-effort). One-directional + leader-driven
|
|
199
|
+
* (the worker can't address the leader except by the marker). A steer issued BEFORE the worker's loop goes
|
|
200
|
+
* live is parked and delivered onto turn 1 (birth-window delivery, bounded — ledger item 36); steers are
|
|
201
|
+
* delivered in call order, the birth window included. Rejects with `steering.not_running` once the task has
|
|
202
|
+
* finished (teardown included).
|
|
203
|
+
*/
|
|
56
204
|
steer(content: string): Promise<string>;
|
|
205
|
+
/** Await the agent's {@link TaskResult} (the same value the eager recording used; idempotent). */
|
|
57
206
|
result(): Promise<TaskResult>;
|
|
58
207
|
}
|
|
59
208
|
export interface WorkflowRunContext {
|
|
60
209
|
readonly runId: string;
|
|
61
210
|
readonly budget: WorkflowBudget;
|
|
211
|
+
/** The composed workflow abort signal (caller signal + `cancel()` + `totalTimeoutMs` deadline). A script
|
|
212
|
+
* runner (the hard sandbox) should thread THIS into its execution so a cancel/timeout actually aborts the
|
|
213
|
+
* script body — not just the agents it spawns (workflow review, caps). */
|
|
62
214
|
readonly signal: AbortSignal;
|
|
215
|
+
/** Run one `runner.runTask(spec)` as a recorded agent-run (script-driven, NOT an LLM delegation). Returns
|
|
216
|
+
* the TaskResult (any terminal status — it does not throw on a task-level failure). Throws on workflow
|
|
217
|
+
* abort or budget exhaustion before spawning.
|
|
218
|
+
*
|
|
219
|
+
* F5 terminal semantics vs the CC anchor (206-pretty.js:17488900-17489600), verified 2026-07-12:
|
|
220
|
+
* - stall-retry EXHAUSTION **throws** `agent stalled on all N attempts…` — CC throws here too (null is
|
|
221
|
+
* NOT the stall terminal in CC). The thrown {@link WorkflowAgentStalledError} carries the last
|
|
222
|
+
* attempt's TaskResult (when one was produced) so partial output and the session handle survive.
|
|
223
|
+
* - CC's `agent() → null` legs are user-skip and a terminal API error (post inner query-layer retries).
|
|
224
|
+
* This seam has no user-skip, and a terminal API death surfaces as a **`status:"failed"` TaskResult**
|
|
225
|
+
* (the script checks `status`) — the seam adaptation of CC's null; recorded divergence, not a gap.
|
|
226
|
+
* - inside `parallel`/`pipeline` a THROWN leg folds to `null` (F11/B8), so the CC-taught
|
|
227
|
+
* `.filter(Boolean)` idiom still holds at the fan-out level. */
|
|
63
228
|
agent(spec: TaskSpec, opts?: WorkflowAgentOptions): Promise<TaskResult>;
|
|
229
|
+
/** design/97 CORE-5 (#6): spawn a STEERABLE agent — same recording/caps/budget as {@link agent}, but returns a
|
|
230
|
+
* {@link WorkflowAgentHandle} the launcher can `steer()` mid-flight and then `await result()`. Resolves once
|
|
231
|
+
* a concurrency slot is acquired and the underlying stream has started (so `steer` won't hit a not-running
|
|
232
|
+
* task). Use for long-running workers a leader wants to redirect; use `agent` for fire-and-await. */
|
|
64
233
|
agentStream(spec: TaskSpec, opts?: WorkflowAgentOptions): Promise<WorkflowAgentHandle>;
|
|
234
|
+
/** Run thunks concurrently (capped by the workflow concurrency limit via `agent`). A thunk that throws
|
|
235
|
+
* resolves to `null` — filter before use. BARRIER: awaits all. Opt-in: pass `{ errors }` (a caller-owned
|
|
236
|
+
* array) to receive one {@link WorkflowFanOutSlotError} per folded slot — the results shape is unchanged. */
|
|
65
237
|
parallel<T>(thunks: Array<() => Promise<T>>, opts?: WorkflowFanOutOptions): Promise<Array<T | null>>;
|
|
238
|
+
/** Run each item through all stages independently, NO barrier between stages. Each stage receives
|
|
239
|
+
* `(prevResult, originalItem, index)`. A stage that throws drops that item to `null`. Opt-in: a trailing
|
|
240
|
+
* non-function `{ errors }` argument (after the stages) collects one {@link WorkflowFanOutSlotError} per
|
|
241
|
+
* folded item — the results shape is unchanged. The options bag must be the LAST argument (fidelity
|
|
242
|
+
* R4-5: the tuple type rejects other positions at compile time, and the runtime throws on them too —
|
|
243
|
+
* a mid-position bag used to be silently invoked as a stage, folding every item to null). */
|
|
66
244
|
pipeline<I>(items: I[], ...stagesAndOpts: Array<(prev: any, item: I, index: number) => Promise<any>> | [...Array<(prev: any, item: I, index: number) => Promise<any>>, WorkflowFanOutOptions]): Promise<any[]>;
|
|
245
|
+
/** Group work under a named phase (observability). TWO forms (CC-心智兼容):
|
|
246
|
+
* - scoped `phase(title, body)` — `body`'s agents default to this phase; closes when body settles.
|
|
247
|
+
* - bare `phase(title)` (CC marker style) — subsequent agents group under `title` until the NEXT
|
|
248
|
+
* `phase()` call, the end of the enclosing scoped `phase()` body (T2A-10: a marker never leaks its
|
|
249
|
+
* lexical scope), or the run's end — whichever comes first. Original contract line follows:
|
|
250
|
+
* `phase()` call (which closes it) or the run's end. Returns `undefined`. */
|
|
67
251
|
phase<T>(title: string, body?: () => Promise<T>): Promise<T | undefined>;
|
|
252
|
+
/**
|
|
253
|
+
* design/97 CORE-3: run `body` as a nested SUB-WORKFLOW — IN-PROCESS over the SAME ctx (shares budget / caps
|
|
254
|
+
* / abort / the cumulative agent counter / the run object), under a fresh sub-`groupId` so the observe tree
|
|
255
|
+
* can render it. It does NOT mint a new runId (it is NOT `startWorkflow`, so it never trips the run_workflow
|
|
256
|
+
* nesting guard). Agents/phases spawned inside carry the sub-group's id. Group nesting is depth-capped.
|
|
257
|
+
*/
|
|
68
258
|
workflow<T>(body: (ctx: WorkflowRunContext) => Promise<T>): Promise<T>;
|
|
259
|
+
/** Emit a narrator log line (observability only — not stored on the run). */
|
|
69
260
|
log(message: string): void;
|
|
70
261
|
}
|
|
71
262
|
export interface RunWorkflowOptions {
|
|
263
|
+
/** Trusted caller-supplied run id. Used by the unified task registry so tool-launched workflows expose
|
|
264
|
+
* `task_id === runId` (`w*`) without making the model choose an id. Omit for the legacy UUID mint path. */
|
|
72
265
|
runId?: string;
|
|
266
|
+
/** design/97 S1b/S1c — persist the {@link WorkflowRun} to a {@link WorkflowRunStore} for `/workflows`
|
|
267
|
+
* history + cross-replica visibility. **Opt-in (default none)**: with no store the workflow still runs
|
|
268
|
+
* + emits + is subscribable in-process (S1a behavior, unchanged). Persistence is **best-effort**: a store
|
|
269
|
+
* throw is swallowed and NEVER breaks the workflow (the run/script is the source of truth; the store is an
|
|
270
|
+
* observation layer). The owner is the sole writer (rev CAS). */
|
|
73
271
|
store?: WorkflowRunStore;
|
|
272
|
+
/** Tenant/grouping key for the run (default `"default"`). */
|
|
74
273
|
scope?: string;
|
|
274
|
+
/** design/99 MF-W: the workflow's display name + description (the run_workflow tool passes the script's
|
|
275
|
+
* `meta.name`/`meta.description`) — recorded on the {@link WorkflowRun} for the /workflows monitor header. */
|
|
75
276
|
name?: string;
|
|
76
277
|
description?: string;
|
|
278
|
+
/** design/114 #3 — the host task id that started this workflow → recorded on the {@link WorkflowRun} so a
|
|
279
|
+
* crash-recovered consumer can re-associate the run with its initiator (the run_workflow tool passes it). */
|
|
77
280
|
sourceTaskId?: string;
|
|
281
|
+
/** The originating session id — recorded on the {@link WorkflowRun}(same rationale as
|
|
282
|
+
* sourceTaskId: live notify carries it, recovery otherwise can't). */
|
|
78
283
|
originatingSessionId?: string;
|
|
284
|
+
/** δ 批 [1498]⑦ — the ROOT host session of the delegation tree (the run-workflow tool passes
|
|
285
|
+
* `ctx.rootSessionId ?? originatingSessionId`); rides the wa* observer frames so a recovery face
|
|
286
|
+
* groups workflow-agent rows under the root host session too. */
|
|
79
287
|
rootSessionId?: string;
|
|
288
|
+
/** design/149 ([1422]③ 裁 a) — the PROCESS-level child observer (same seam as
|
|
289
|
+
* {@link import("../core/types.js").RunnerDeps.onBackgroundChildEvent}). When set, every workflow
|
|
290
|
+
* agent emits spawn/tick/terminal {@link import("../core/types.js").BackgroundChildEvent} frames with a
|
|
291
|
+
* synthetic `wa*` row key (runId+callKey hash — stable across resume replays), owner/parentTaskId = the
|
|
292
|
+
* workflow's own task id (the fleet row nests under the w* row), sessionScoped false. This lane is
|
|
293
|
+
* process-anchored — a host run that settles BEFORE the workflow finishes does not mute it (the
|
|
294
|
+
* run-leg uuid tick lane's settledLeg freeze, the [1422]③ case). Swallow-guarded.
|
|
295
|
+
*/
|
|
80
296
|
onBackgroundChildEvent?: (event: import("../core/types.js").BackgroundChildEvent) => void;
|
|
297
|
+
/** design/140 §6 1a — the merged effective args snapshot recorded on the {@link WorkflowRun} (the
|
|
298
|
+
* run_workflow tool passes the value it resolved at parse time; a JSON value, observation-only). */
|
|
81
299
|
effectiveArgs?: unknown;
|
|
300
|
+
/** Cancels the whole workflow: propagated to each agent's runTask; new agents short-circuit once aborted. */
|
|
82
301
|
signal?: AbortSignal;
|
|
302
|
+
/**
|
|
303
|
+
* F4 agentType registry (2026-07-11): deployment agent definitions resolvable by `agent(…, {agentType})`.
|
|
304
|
+
* Same SHADOW rule as the Agent tool: a deployment definition whose name collides with a built-in
|
|
305
|
+
* (Explore/Plan) wins. The run_workflow tool threads the deployment's `agents` here.
|
|
306
|
+
*/
|
|
83
307
|
agents?: AgentDefinition[];
|
|
308
|
+
/** `false` removes the built-in Explore/Plan from the agentType registry (mirror of the Agent tool's
|
|
309
|
+
* `builtinAgents:false`, CC `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS` analog). Default true. */
|
|
84
310
|
builtinAgents?: boolean;
|
|
311
|
+
/** Token ceiling — `ctx.agent` throws {@link WorkflowBudgetExceededError} once spend reaches it. */
|
|
85
312
|
budget?: number;
|
|
313
|
+
/** Max concurrent agents (default `min(16, cpus-2)`, floor 1). Validated fail-loud, like the three
|
|
314
|
+
* §D.6 hard caps below (CLS-A-5) — a non-finite ceiling would silently remove itself. */
|
|
86
315
|
concurrency?: number;
|
|
316
|
+
/** design/98 §D.6 hard cap — max CUMULATIVE agents the workflow may spawn (LLM-authored bound). `ctx.agent`
|
|
317
|
+
* throws {@link WorkflowMaxAgentsError} once reached. Undefined ⇒ only `budget`/`concurrency` bound it. */
|
|
87
318
|
maxAgents?: number;
|
|
319
|
+
/** design/98 §D.6 hard cap — whole-workflow wall-clock deadline (ms). An internal AbortController cancels
|
|
320
|
+
* the run at the deadline (agents short-circuit as aborted; the run finalizes `failed`). */
|
|
88
321
|
totalTimeoutMs?: number;
|
|
322
|
+
/** design/98 §D.6 hard cap — cap on a single `log()` message length (chars); longer messages are truncated
|
|
323
|
+
* with an honest marker (a runaway script must not flood the log). */
|
|
89
324
|
maxLogChars?: number;
|
|
325
|
+
/** design/98 §D.6 hard cap — cap on the script's RETURNED result size (chars, JSON-serialized). Exceeding
|
|
326
|
+
* finalizes the run `failed` with {@link WorkflowResultTooLargeError}. */
|
|
90
327
|
maxResultChars?: number;
|
|
328
|
+
/** Progress sink (run/phase/agent/log/run_end events). */
|
|
91
329
|
onEvent?: (e: WorkflowEvent) => void;
|
|
330
|
+
/** RB-473 batch 2b — bounded disclosure when a host sink (`onEvent` / the bg-child event sink) throws
|
|
331
|
+
* inside this run's isolation scope: first failure per site, later ones counted only. */
|
|
92
332
|
onNotifyError?: (failure: import("../core/safe-notify.js").SafeNotifyFailure) => void;
|
|
333
|
+
/** Injected clock (design/87 §4.3 — testable without the wall clock). Default `Date.now`. */
|
|
93
334
|
now?: () => number;
|
|
335
|
+
/**
|
|
336
|
+
* design/97 CORE-7 — the LOAD-BEARING resume journal. With a `journalStore`, every `ctx.agent` result (NOT
|
|
337
|
+
* `ctx.agentStream` — see below) is recorded keyed by its deterministic callKey. Supplying `resumeFromRunId`
|
|
338
|
+
* (a PRIOR run id, requires `journalStore`) replays the longest UNCHANGED PREFIX of those results instantly and
|
|
339
|
+
* runs only the first changed/new call + everything after it live (same script + args → 100% cache hit). A
|
|
340
|
+
* `journalStore` WITHOUT `resumeFromRunId` just records (so a future run can resume from THIS run). Replayed
|
|
341
|
+
* agents accumulate into `run.stats` (total work) but NOT into `ctx.budget.spent()` (live spend only — a resume
|
|
342
|
+
* is not re-charged for cached work). NOT-REPLAYED (they force divergence so the suffix runs live): `ctx.agentStream`
|
|
343
|
+
* (a finished result can't be steered — RECORDED since [1422]② for the journal read-face, never replayed) and `ctx.pipeline` (latency-dependent ordinals aren't deterministic —
|
|
344
|
+
* a CORE-7.1 follow-on adds stage-scoped deterministic keys). Sequential + `parallel(direct thunks)` replay.
|
|
345
|
+
*/
|
|
94
346
|
journalStore?: WorkflowJournalStore;
|
|
347
|
+
/** design/97 CORE-7 — resume by replaying a prior run's journal (requires `journalStore`). See `journalStore`. */
|
|
95
348
|
resumeFromRunId?: string;
|
|
349
|
+
/** The HOST task's effective working root — threaded into every spawned agent's trusted internals
|
|
350
|
+
* (`RunInternals.parentCwd`) so a TOC env factory roots children at the parent's cwd (CC parity;
|
|
351
|
+
* `isolation: "worktree"` on an individual agent wins over it). */
|
|
96
352
|
parentCwd?: string;
|
|
353
|
+
/**
|
|
354
|
+
* The SPAWNING tool call's id (`run_workflow`'s own `ToolExecuteContext.toolCallId`) — threaded into every
|
|
355
|
+
* spawned agent's trusted internals (`RunInternals.parentToolCallId`) so each child runs AS a sub-agent:
|
|
356
|
+
* its per-turn `task_progress` ticks actually EMIT (the runner gates them on `parentToolCallId`) and carry
|
|
357
|
+
* this id for attribution, the same contract as a `createSubagentTool` delegation. Set by the `run_workflow`
|
|
358
|
+
* tool wiring; a directly-started workflow (no launching tool call) leaves it unset — children then emit no
|
|
359
|
+
* progress ticks (status quo), and no id is ever fabricated.
|
|
360
|
+
*/
|
|
97
361
|
parentToolCallId?: string;
|
|
362
|
+
/** The HOST task's taskId — threaded as every spawned agent's `RunInternals.parentTaskId` so its
|
|
363
|
+
* `task_progress` ticks nest under the launching task in a live agent-tree view (same channel a
|
|
364
|
+
* subagent spawn threads from `ToolExecuteContext.taskId`). Optional, `parentToolCallId`'s companion. */
|
|
98
365
|
parentTaskId?: string;
|
|
366
|
+
/** design/173 §8.3 (r2-F1) — the HOST run's RESOLVED interaction posture, threaded as every
|
|
367
|
+
* spawned agent's `RunInternals.parentInteractionPosture` (trusted internals, never the child
|
|
368
|
+
* spec) so a root's per-run posture override governs its workflow children too. Set by the
|
|
369
|
+
* `run_workflow` tool wiring from `ToolExecuteContext.interactionPosture`. */
|
|
99
370
|
interactionPosture?: "interactive" | "headless";
|
|
371
|
+
/** [1238](A) — call-time getter for the HOST run's RESOLVED Model object. A spawned agent whose
|
|
372
|
+
* fold chain (script spec → agentType → governance baseline) produced NO model inherits the
|
|
373
|
+
* parent's full object — baseUrl/key routing included — instead of falling to a string/role
|
|
374
|
+
* re-resolution that loses per-model routing (the clay 4/4-agents-404 incident: session model id
|
|
375
|
+
* re-resolved against the base gateway). Mirrors the subagent lane's `ctx.model` semantics. */
|
|
100
376
|
defaultModel?: () => import("../internal/llm.js").Model | undefined;
|
|
377
|
+
/** [1258] v2 — the HOST's per-model auth hook, inherited into every spawned agent's spec (the
|
|
378
|
+
* credential half of model inheritance; scripts can never set it — governance strips it — so
|
|
379
|
+
* this is always the host's). NOT call identity (auth, not behavior; a function, not data). */
|
|
101
380
|
defaultGetApiKeyAndHeaders?: TaskSpec["getApiKeyAndHeaders"];
|
|
381
|
+
/** design/148 S1 — the HOST run's adopted center artifact (trusted, threaded by the Workflow tool
|
|
382
|
+
* from ctx): every spawned agent composes the same closure (codex F2a). */
|
|
102
383
|
parentCenterArtifactDigest?: string;
|
|
103
384
|
parentCenterSourceRevision?: string;
|
|
385
|
+
/** The launching run's display sink (`RunInternals.onForwardEvent`, already filtered by the runner to
|
|
386
|
+
* `task_progress`) — threaded into every spawned agent's trusted internals so the children's progress
|
|
387
|
+
* ticks bubble out of their isolated streams to the deployment's one sink (fleet footer/monitor rows).
|
|
388
|
+
* Display-only; absent ⇒ ticks stay in each child's own stream. */
|
|
104
389
|
onForwardEvent?: (event: TaskEvent) => void;
|
|
390
|
+
/** Parent effective-policy inheritance (tighten-only): the HOST task's evaluated gate chain
|
|
391
|
+
* (`ToolExecuteContext.inheritedGateForChildren()` — its session rules + toolPolicy/frozen onAsk +
|
|
392
|
+
* shellGate plus every ancestor's), threaded into EVERY spawned agent's trusted internals
|
|
393
|
+
* (`RunInternals.inheritedGate`) on both spawn legs (`agent()` and `agentStream()`). Set by the
|
|
394
|
+
* `run_workflow` tool wiring; a directly-started workflow may pass its own. Absent ⇒ children run
|
|
395
|
+
* under only their own gates (pre-seam behavior). TRUSTED: never a script/model argument. */
|
|
105
396
|
inheritedGate?: import("../core/runner/prepare-task.js").InheritedGate;
|
|
397
|
+
/** RB-201 FO-3 (workflow lane) — the session's auto-mode classifier, consulted BEFORE each script-spawned
|
|
398
|
+
* child starts (objective + toolset + output schema, finalized). The delegation-tool lane reviews its
|
|
399
|
+
* children at one shared point; a workflow's children reach `runner.runTask` through this module instead,
|
|
400
|
+
* so they need their own review point rather than inheriting that one. Threaded by the `run_workflow` tool
|
|
401
|
+
* wiring from the host's `ToolExecuteContext.autoModeReview`; a directly-started workflow may pass its own.
|
|
402
|
+
* ABSENT ⇒ every leg here is a complete no-op (auto-mode not armed = byte-identical to before).
|
|
403
|
+
* TRUSTED: never a script/model argument. */
|
|
106
404
|
autoModeReview?: {
|
|
107
405
|
decider: import("../core/auto-mode.js").AutoModeDecider;
|
|
108
406
|
};
|
|
407
|
+
/** F7/B7 (CC pretty.js:446478): PRE-REGISTER the script's `meta.phases` as pending progress groups at run
|
|
408
|
+
* start — the plan is visible before execution; `phase(title)` adopts the matching pending entry. */
|
|
109
409
|
phases?: ReadonlyArray<{
|
|
110
410
|
title: string;
|
|
111
411
|
detail?: string;
|
|
112
412
|
model?: string;
|
|
113
413
|
}>;
|
|
414
|
+
/** F5/B4: override the per-agent stall watchdog (ms). Default {@link WORKFLOW_AGENT_STALL_MS}. A deployment
|
|
415
|
+
* may tune it; tests set it small to exercise the retry path without waiting 180s. */
|
|
114
416
|
stallMs?: number;
|
|
417
|
+
/** F5/B4: override the max stalled-attempt retries. Default {@link WORKFLOW_AGENT_MAX_RETRIES}. */
|
|
115
418
|
agentMaxRetries?: number;
|
|
419
|
+
/** F5/B4: override the throttle-degradation backoff (ms). Default {@link WORKFLOW_AGENT_THROTTLE_BACKOFF_MS}. */
|
|
116
420
|
throttleBackoffMs?: number;
|
|
421
|
+
/** F5/B4 (design/87 §4.3): injectable timers for the resilience layer (stall watchdog + throttle backoff
|
|
422
|
+
* sleep) — tests advance a virtual clock instead of really waiting {@link WORKFLOW_AGENT_STALL_MS}.
|
|
423
|
+
* Default: real unref'd `setTimeout`/`clearTimeout`. Pair with `now` for a fully virtual clock. */
|
|
117
424
|
timers?: WorkflowTimers;
|
|
118
425
|
}
|
|
119
426
|
export interface RunWorkflowResult<T> {
|
|
@@ -121,26 +428,77 @@ export interface RunWorkflowResult<T> {
|
|
|
121
428
|
runId: string;
|
|
122
429
|
run: WorkflowRun;
|
|
123
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* design/98 §D.4 (S8c) — the handle {@link startWorkflow} returns: the `runId` is available SYNCHRONOUSLY
|
|
433
|
+
* (the run row + live subscription exist before the body runs, so a caller can subscribe + return the id to an
|
|
434
|
+
* LLM immediately), `done` resolves/rejects exactly like {@link runWorkflow}, and `cancel` aborts the whole
|
|
435
|
+
* run (every agent's signal fires; new agents short-circuit).
|
|
436
|
+
*/
|
|
124
437
|
export interface WorkflowHandle<T> {
|
|
125
438
|
readonly runId: string;
|
|
126
439
|
readonly done: Promise<RunWorkflowResult<T>>;
|
|
127
440
|
cancel(reason?: string): void;
|
|
128
441
|
}
|
|
442
|
+
/** Cap on items a single `parallel`/`pipeline` call accepts (matches the CC Workflow tool). */
|
|
129
443
|
export declare const MAX_WORKFLOW_ITEMS = 4096;
|
|
444
|
+
/** CC `MTy` (206-pretty.js:17501680; 198 `F0m`): no tool activity for this long marks the attempt STALLED
|
|
445
|
+
* (progress-based, unlike the governance perAgentTimeoutSec hard cap, which still bounds each attempt).
|
|
446
|
+
* `<= 0` DISABLES the watchdog (CC arms only `if (ae > 0)`, :17477830). */
|
|
130
447
|
export declare const WORKFLOW_AGENT_STALL_MS = 180000;
|
|
448
|
+
/** CC `j_d` (206-pretty.js:17501680; 198 `Mxl`): max stalled-attempt retries per `ctx.agent` call
|
|
449
|
+
* (initial + 5 = 6 attempts). */
|
|
131
450
|
export declare const WORKFLOW_AGENT_MAX_RETRIES = 5;
|
|
451
|
+
/** CC throttle backoff (206-pretty.js:17488618): ONE fixed 45s sleep-then-retry for a throttle-shaped
|
|
452
|
+
* degraded response (a flat sleep, NOT exponential backoff — and only on the FIRST attempt's result). */
|
|
132
453
|
export declare const WORKFLOW_AGENT_THROTTLE_BACKOFF_MS = 45000;
|
|
454
|
+
/**
|
|
455
|
+
* RB-355 (codex 异源复审, 2026-07-29) — the cap on how long the TERMINAL boundary waits on the resume-claim
|
|
456
|
+
* store (the admission verdict, then the release). Both awaits sit in the run's `finally`, i.e. AFTER the
|
|
457
|
+
* outcome is already decided: an unbounded wait there means a store implementation that hangs (a wedged
|
|
458
|
+
* connection pool, a lost network write, a promise that simply never settles) leaves the run's `done` promise
|
|
459
|
+
* pending FOREVER, silently discarding the guarantee `totalTimeoutMs` makes to the caller — the deadline
|
|
460
|
+
* aborts the body, and then the cleanup hangs on the same broken store. Timing out here loses nothing that
|
|
461
|
+
* was not already lost: a release that cannot complete leaves a claim row behind, which is precisely what the
|
|
462
|
+
* store's TTL (invalidation layer 2) exists to reap. Scheduled on the injectable {@link WorkflowTimers} seam,
|
|
463
|
+
* so the timer is unref'd by default and tests can drive it without waiting.
|
|
464
|
+
*/
|
|
133
465
|
export declare const WORKFLOW_RESUME_CLAIM_FINALIZE_TIMEOUT_MS = 10000;
|
|
466
|
+
/** F5/B4 + design/87 §4.3 — the INJECTABLE timer seam the per-agent resilience layer schedules on (the
|
|
467
|
+
* stall watchdog + the throttle backoff sleep). Tests drive VIRTUAL time instead of really waiting
|
|
468
|
+
* 180s/45s. Default: the real `setTimeout`/`clearTimeout`, unref'd (a pending watchdog must never hold
|
|
469
|
+
* the process open). */
|
|
134
470
|
export interface WorkflowTimers {
|
|
135
471
|
setTimeout(fn: () => void, ms: number): unknown;
|
|
136
472
|
clearTimeout(handle: unknown): void;
|
|
137
473
|
}
|
|
138
474
|
export declare const workflowResumeClaimFallback: {
|
|
475
|
+
/** Grant (or idempotently re-confirm) the in-process claim on `(sourceRunId, scope)` for `store`. Pure
|
|
476
|
+
* synchronous Map read-then-write — no `await` between the check and the publish, so there is no window
|
|
477
|
+
* (matching the atomicity RB-354 requires of a store-level implementation) in which a second same-tick
|
|
478
|
+
* caller could observe the key as free. */
|
|
139
479
|
acquire(store: WorkflowJournalStore, input: ResumeClaimArgs): {
|
|
140
480
|
granted: boolean;
|
|
141
481
|
holder?: string;
|
|
142
482
|
};
|
|
483
|
+
/** Release a claim ONLY if `newRunId` still holds it — mirrors the store contract's `releaseResumeClaim`:
|
|
484
|
+
* a missing/foreign claim is a no-op, never an error (a claim already taken over by a later resume must
|
|
485
|
+
* never be unlinked by an earlier one's cleanup). */
|
|
143
486
|
release(store: WorkflowJournalStore, input: ResumeClaimArgs): void;
|
|
144
487
|
};
|
|
488
|
+
/**
|
|
489
|
+
* Start a workflow script and return its {@link WorkflowHandle} SYNCHRONOUSLY (design/98 §D.4): the `runId`,
|
|
490
|
+
* run row, and live subscription exist before the body runs — so a caller (e.g. the `run_workflow` tool) can
|
|
491
|
+
* subscribe + hand the id to an LLM immediately, then await `done`. Establishes a {@link WorkflowRunContext},
|
|
492
|
+
* runs `fn(ctx)` asynchronously, and resolves `done` with the script's value + the assembled
|
|
493
|
+
* {@link WorkflowRun} (status `completed`). If `fn` throws, the run finalizes `failed` (events emitted) and
|
|
494
|
+
* `done` rejects. `cancel(reason)` aborts the whole run. A nesting/validation violation throws SYNCHRONOUSLY
|
|
495
|
+
* from this call (before any handle exists). Thin composition over `runner.runTask` — no Runner changes.
|
|
496
|
+
*/
|
|
145
497
|
export declare function startWorkflow<T>(runner: Runner, fn: (ctx: WorkflowRunContext) => Promise<T>, opts?: RunWorkflowOptions, internals?: WorkflowInternals): WorkflowHandle<T>;
|
|
498
|
+
/**
|
|
499
|
+
* Run a workflow to completion (design/97 S1a) — the thin await over {@link startWorkflow}: returns the
|
|
500
|
+
* script's value + the assembled {@link WorkflowRun}. A synchronous nesting/validation throw from
|
|
501
|
+
* `startWorkflow` becomes a rejected promise here (this function is `async`), preserving the original
|
|
502
|
+
* `runWorkflow` contract (`await runWorkflow(...)` rejects rather than throwing synchronously).
|
|
503
|
+
*/
|
|
146
504
|
export declare function runWorkflow<T>(runner: Runner, fn: (ctx: WorkflowRunContext) => Promise<T>, opts?: RunWorkflowOptions, internals?: WorkflowInternals): Promise<RunWorkflowResult<T>>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type PromptEpochArtifact, type PublishedPromptArtifactEnvelope } from "./artifact.js";
|
|
2
2
|
export interface PromptArtifactStore {
|
|
3
|
+
/** Verified read by digest — undefined on miss OR on any verification failure of stored bytes. */
|
|
3
4
|
get(artifactDigest: string, opts: {
|
|
4
5
|
engineVersion: string;
|
|
5
6
|
}): Promise<PublishedPromptArtifactEnvelope | undefined>;
|
|
7
|
+
/** Idempotent immutable write (same digest ⇒ same bytes; the caller verified before putting). */
|
|
6
8
|
put(envelope: PublishedPromptArtifactEnvelope): Promise<void>;
|
|
7
9
|
}
|
|
8
10
|
export declare class MemoryPromptArtifactStore implements PromptArtifactStore {
|
|
@@ -12,6 +14,7 @@ export declare class MemoryPromptArtifactStore implements PromptArtifactStore {
|
|
|
12
14
|
}): Promise<PublishedPromptArtifactEnvelope | undefined>;
|
|
13
15
|
put(envelope: PublishedPromptArtifactEnvelope): Promise<void>;
|
|
14
16
|
}
|
|
17
|
+
/** `artifacts/<hex>.json` under a caller-owned directory; atomic tmp+rename writes (§9.2). */
|
|
15
18
|
export declare class FilePromptArtifactStore implements PromptArtifactStore {
|
|
16
19
|
private readonly dir;
|
|
17
20
|
constructor(dir: string);
|
|
@@ -38,27 +41,57 @@ export declare class MemoryPromptSourceStateStore implements PromptSourceStateSt
|
|
|
38
41
|
load(): Promise<PromptSourceState | undefined>;
|
|
39
42
|
save(state: PromptSourceState): Promise<void>;
|
|
40
43
|
}
|
|
44
|
+
/** `source-state.json` sibling of the artifact dir; atomic tmp+rename; malformed file = undefined
|
|
45
|
+
* (stateless boot — conservative: no candidate until the next verified response). */
|
|
41
46
|
export declare class FilePromptSourceStateStore implements PromptSourceStateStore {
|
|
42
47
|
private readonly file;
|
|
43
48
|
constructor(dir: string);
|
|
44
49
|
load(): Promise<PromptSourceState | undefined>;
|
|
45
50
|
save(state: PromptSourceState): Promise<void>;
|
|
46
51
|
}
|
|
52
|
+
/** The narrow face the Runner consumes (RunnerDeps.promptSource) — resolution only, no publish. */
|
|
47
53
|
export interface PromptArtifactSource {
|
|
54
|
+
/** The current validated candidate for NEW sessions, with its publish provenance
|
|
55
|
+
* (undefined = bundled-only, today's shape). */
|
|
48
56
|
current(): {
|
|
49
57
|
artifact: PromptEpochArtifact;
|
|
50
58
|
sourceRevision: string;
|
|
51
59
|
} | undefined;
|
|
60
|
+
/** Resolve a PINNED digest (resume path). Undefined = unavailable — the caller fails loud. */
|
|
52
61
|
get(artifactDigest: string): Promise<PromptEpochArtifact | undefined>;
|
|
62
|
+
/** RB-31 codex F1 — the tri-state the adoption boundary keys on: `"disabled"` = an EXPLICIT
|
|
63
|
+
* validated revocation (applyDisabled) ⇒ pinned sessions roll back to bundled at the next
|
|
64
|
+
* compaction; `"active"` = a validated candidate is live; `"unavailable"` = no verified state
|
|
65
|
+
* (never-configured face, store-miss boot) ⇒ conservative restate — an outage must never strip
|
|
66
|
+
* policy, only an explicit revocation does. Optional (older sources read as "unavailable"). */
|
|
53
67
|
sourceState?(): "active" | "disabled" | "unavailable";
|
|
54
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The candidate state machine (§9.2 full pipeline). Publish-side entry points:
|
|
71
|
+
* - `applySnapshot(raw)` — a fetched effective-snapshot body: verify → store.put → persist
|
|
72
|
+
* active state → atomic in-memory swap. Any verification failure leaves EVERYTHING unchanged.
|
|
73
|
+
* - `applyDisabled(sourceRevision)` — an explicit, successful disable/delete response: persist
|
|
74
|
+
* disabled state + drop the candidate. (Network failure/304 = simply don't call anything.)
|
|
75
|
+
* - `restore()` — boot: re-resolve persisted active state through the verified store; a miss or
|
|
76
|
+
* verify failure boots stateless (no candidate) without touching the persisted record.
|
|
77
|
+
*/
|
|
55
78
|
export declare class CenterPromptSource implements PromptArtifactSource {
|
|
56
79
|
private readonly store;
|
|
57
80
|
private readonly stateStore;
|
|
58
81
|
private readonly engineVersion;
|
|
59
82
|
private candidate;
|
|
60
83
|
private state;
|
|
84
|
+
/** Hardening 2026-07-31 — serialization tail for the three STATE-MUTATING entry points. Each of
|
|
85
|
+
* them is a multi-await sequence ending in a synchronous swap of (candidate, state); with two in
|
|
86
|
+
* flight, an interleaving where B's `stateStore.save` resolves and swaps before A's leaves the
|
|
87
|
+
* persisted record naming B's digest while the in-memory candidate names A's — `current()` then
|
|
88
|
+
* serves A to every new session until the next `restore()` silently switches to B. `CenterPromptSource`
|
|
89
|
+
* is a public export driven by a caller's poll loop, so two overlapping applies are an ordinary
|
|
90
|
+
* schedule, not an exotic race. Serializing costs nothing (these are publish-rate operations) and
|
|
91
|
+
* makes the durable record and the in-memory candidate agree by construction. */
|
|
61
92
|
private tail;
|
|
93
|
+
/** Run `fn` after every previously-queued mutation settles (success OR failure — a failed apply
|
|
94
|
+
* must not wedge the queue). */
|
|
62
95
|
private exclusive;
|
|
63
96
|
constructor(opts: {
|
|
64
97
|
store: PromptArtifactStore;
|