@sema-agent/core 5.19.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.
Files changed (329) hide show
  1. package/CHANGELOG.md +102 -4
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/roster-store.js +3 -0
  13. package/dist/agents/send-message-tool.d.ts +92 -0
  14. package/dist/agents/session-util.d.ts +5 -0
  15. package/dist/agents/subagent-steps.d.ts +66 -0
  16. package/dist/agents/subagent.d.ts +600 -0
  17. package/dist/agents/suspend-guard.d.ts +29 -0
  18. package/dist/agents/teacher.d.ts +75 -0
  19. package/dist/agents/team.d.ts +120 -1
  20. package/dist/agents/tool-filter.d.ts +34 -0
  21. package/dist/agents/verify.d.ts +198 -0
  22. package/dist/bench/metrics.d.ts +455 -0
  23. package/dist/brain/anthropic.d.ts +30 -0
  24. package/dist/brain/circuit-breaker.d.ts +33 -0
  25. package/dist/brain/circuit-breaker.js +14 -3
  26. package/dist/brain/context-overflow.d.ts +60 -3
  27. package/dist/brain/degrading.d.ts +67 -0
  28. package/dist/brain/errors.d.ts +42 -0
  29. package/dist/brain/failover.d.ts +15 -0
  30. package/dist/brain/media-degrade.d.ts +39 -0
  31. package/dist/brain/model-presets.d.ts +31 -0
  32. package/dist/brain/open-responses.d.ts +19 -0
  33. package/dist/brain/openai.d.ts +46 -0
  34. package/dist/brain/reasoning.d.ts +106 -1
  35. package/dist/brain/repetition.d.ts +83 -0
  36. package/dist/brain/request-params.d.ts +56 -0
  37. package/dist/brain/retry.d.ts +46 -0
  38. package/dist/brain/routing.d.ts +12 -0
  39. package/dist/brain/status-sink.d.ts +30 -1
  40. package/dist/brain/stream-engine.d.ts +147 -0
  41. package/dist/brain/stream-shared.d.ts +34 -0
  42. package/dist/brain/terminal-cause.d.ts +31 -0
  43. package/dist/brain/timeout.d.ts +108 -0
  44. package/dist/brain/timeout.js +11 -0
  45. package/dist/brain/tool-call-id.d.ts +20 -0
  46. package/dist/brain/tool-call-repair.d.ts +13 -0
  47. package/dist/config/catalog.d.ts +47 -0
  48. package/dist/config/defaults.d.ts +33 -0
  49. package/dist/core/a2a-task-state.d.ts +53 -0
  50. package/dist/core/a2a.d.ts +51 -0
  51. package/dist/core/arg-summary.d.ts +62 -0
  52. package/dist/core/ask-question.d.ts +272 -2
  53. package/dist/core/auto-compaction.d.ts +467 -0
  54. package/dist/core/auto-compaction.js +20 -6
  55. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  56. package/dist/core/auto-mode-prompt.d.ts +27 -0
  57. package/dist/core/auto-mode.d.ts +54 -3
  58. package/dist/core/auto-promote.d.ts +100 -0
  59. package/dist/core/background-agent-store.d.ts +293 -0
  60. package/dist/core/background-agent-store.js +5 -0
  61. package/dist/core/background-shell.d.ts +110 -0
  62. package/dist/core/cache-break-detector.d.ts +34 -0
  63. package/dist/core/canonical-json.d.ts +57 -0
  64. package/dist/core/checkpoint-store.d.ts +1574 -16
  65. package/dist/core/compliance.d.ts +30 -0
  66. package/dist/core/consolidate-scope.d.ts +75 -0
  67. package/dist/core/context-edit.d.ts +99 -0
  68. package/dist/core/context-guard.d.ts +46 -0
  69. package/dist/core/exec-gate.d.ts +44 -0
  70. package/dist/core/exec-output-tail.d.ts +61 -0
  71. package/dist/core/file-snapshot-store.d.ts +104 -0
  72. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  73. package/dist/core/git-worktree-env.d.ts +31 -0
  74. package/dist/core/governance-codes.d.ts +19 -0
  75. package/dist/core/hooks.d.ts +609 -1
  76. package/dist/core/human-input-projection.d.ts +37 -0
  77. package/dist/core/human-input-projection.js +13 -0
  78. package/dist/core/image-downsample.d.ts +74 -0
  79. package/dist/core/locked-config.d.ts +37 -0
  80. package/dist/core/lsp-diagnostics.d.ts +77 -0
  81. package/dist/core/lsp-protocol.d.ts +29 -0
  82. package/dist/core/lsp-session.d.ts +60 -1
  83. package/dist/core/lsp.d.ts +150 -1
  84. package/dist/core/mailbox-store.d.ts +57 -0
  85. package/dist/core/mailbox-store.js +2 -0
  86. package/dist/core/mcp.d.ts +385 -0
  87. package/dist/core/mcp.js +58 -11
  88. package/dist/core/media-byte-cap.d.ts +21 -0
  89. package/dist/core/memory-admission.d.ts +71 -0
  90. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  91. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  92. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  93. package/dist/core/memory-engine/engine.d.ts +230 -0
  94. package/dist/core/memory-engine/engine.js +103 -35
  95. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  96. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  97. package/dist/core/memory-engine/layout.d.ts +217 -0
  98. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  99. package/dist/core/memory-engine/migrate.d.ts +9 -0
  100. package/dist/core/memory-engine/scan.d.ts +12 -0
  101. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  102. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  103. package/dist/core/memory-engine/sync.d.ts +60 -0
  104. package/dist/core/memory-engine/tools.d.ts +41 -0
  105. package/dist/core/memory-engine/types.d.ts +188 -0
  106. package/dist/core/memory-recall.d.ts +141 -0
  107. package/dist/core/memory-vector.d.ts +20 -0
  108. package/dist/core/memory.d.ts +458 -0
  109. package/dist/core/message-utils.d.ts +6 -0
  110. package/dist/core/oracle-isolation.d.ts +69 -0
  111. package/dist/core/permission-rule-consent.d.ts +138 -0
  112. package/dist/core/permission-rule-model.d.ts +122 -0
  113. package/dist/core/permission-rule-store.d.ts +119 -3
  114. package/dist/core/permission-rules.d.ts +87 -1
  115. package/dist/core/present-plan-tool.d.ts +20 -0
  116. package/dist/core/pricing.d.ts +26 -0
  117. package/dist/core/property-harness.d.ts +86 -0
  118. package/dist/core/protocol-naming.d.ts +38 -0
  119. package/dist/core/protocol-table.d.ts +61 -0
  120. package/dist/core/push-queue.d.ts +1 -0
  121. package/dist/core/remote-env.d.ts +383 -1
  122. package/dist/core/retention-policy.d.ts +40 -0
  123. package/dist/core/retention-policy.js +21 -0
  124. package/dist/core/retention.d.ts +51 -0
  125. package/dist/core/roles.d.ts +59 -0
  126. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  127. package/dist/core/runner/assemble-result.d.ts +134 -0
  128. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  129. package/dist/core/runner/grounding-signal.d.ts +10 -0
  130. package/dist/core/runner/image.d.ts +17 -0
  131. package/dist/core/runner/image.js +29 -15
  132. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  133. package/dist/core/runner/prepare-memory.d.ts +59 -0
  134. package/dist/core/runner/prepare-task.d.ts +1011 -2
  135. package/dist/core/runner/prepare-task.js +51 -14
  136. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  137. package/dist/core/runner/runtask.d.ts +304 -3
  138. package/dist/core/runner/runtask.js +17 -2
  139. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  140. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  141. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  142. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  143. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  144. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  145. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  146. package/dist/core/runner/turn-attachments.d.ts +634 -0
  147. package/dist/core/runner/usage-accounting.d.ts +32 -0
  148. package/dist/core/runtime.d.ts +9 -0
  149. package/dist/core/safe-notify.d.ts +64 -0
  150. package/dist/core/safety-axis-vocab.d.ts +23 -0
  151. package/dist/core/safety-merge-corpus.d.ts +37 -0
  152. package/dist/core/scheduler.d.ts +121 -0
  153. package/dist/core/secret-env.d.ts +32 -0
  154. package/dist/core/select-model.d.ts +15 -0
  155. package/dist/core/sensitive-path-policy.d.ts +42 -0
  156. package/dist/core/session-policy-store.d.ts +94 -0
  157. package/dist/core/session-reconcile.d.ts +80 -0
  158. package/dist/core/session-store.d.ts +85 -0
  159. package/dist/core/session.d.ts +153 -0
  160. package/dist/core/shared-memory/contract.d.ts +22 -0
  161. package/dist/core/shared-memory/normalize.d.ts +123 -2
  162. package/dist/core/shared-memory/tools.d.ts +14 -0
  163. package/dist/core/shared-memory/types.d.ts +105 -0
  164. package/dist/core/shutdown-debug.d.ts +6 -0
  165. package/dist/core/side-query.d.ts +38 -0
  166. package/dist/core/side-query.js +6 -1
  167. package/dist/core/skill-tool-specifier.d.ts +72 -0
  168. package/dist/core/skills-directory.d.ts +100 -1
  169. package/dist/core/spec-contract.d.ts +89 -0
  170. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  171. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  172. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  173. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  174. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  175. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  176. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  177. package/dist/core/strategy-store.d.ts +37 -0
  178. package/dist/core/stub-env.d.ts +7 -0
  179. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  180. package/dist/core/task-notification.d.ts +202 -0
  181. package/dist/core/task-outcome.d.ts +53 -0
  182. package/dist/core/task-registry-agent.d.ts +337 -1
  183. package/dist/core/task-registry-agent.js +2 -0
  184. package/dist/core/task-registry-monitor.d.ts +12 -0
  185. package/dist/core/task-registry-shared.d.ts +540 -0
  186. package/dist/core/task-registry.d.ts +343 -0
  187. package/dist/core/task-registry.js +13 -2
  188. package/dist/core/task-tool-shape.d.ts +44 -0
  189. package/dist/core/tighten-task-spec.d.ts +21 -0
  190. package/dist/core/tool-detach.d.ts +21 -0
  191. package/dist/core/tool-errors.d.ts +131 -0
  192. package/dist/core/tool-errors.js +4 -0
  193. package/dist/core/tool-name-aliases.d.ts +27 -0
  194. package/dist/core/tool-policy.d.ts +555 -0
  195. package/dist/core/tool-policy.js +3 -0
  196. package/dist/core/tool-result-budget.d.ts +32 -0
  197. package/dist/core/tool-result-store.d.ts +174 -1
  198. package/dist/core/tools.d.ts +45 -0
  199. package/dist/core/trace.d.ts +323 -0
  200. package/dist/core/types.d.ts +3859 -2
  201. package/dist/core/untrusted-egress.d.ts +8 -0
  202. package/dist/core/untrusted-text.d.ts +156 -0
  203. package/dist/core/usage-window-store.d.ts +95 -0
  204. package/dist/core/version.d.ts +1 -0
  205. package/dist/core/warm-resume.d.ts +17 -0
  206. package/dist/core/wiring-manifest.d.ts +169 -0
  207. package/dist/core/with-retry.d.ts +24 -0
  208. package/dist/core/workflow-journal-store.d.ts +160 -0
  209. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  210. package/dist/core/workflow-run-store.d.ts +119 -0
  211. package/dist/core/workflow-run-store.js +2 -0
  212. package/dist/engine/compaction/compaction.d.ts +256 -1
  213. package/dist/engine/compaction/utils.d.ts +94 -0
  214. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  215. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  216. package/dist/engine/harness/agent-harness.d.ts +116 -0
  217. package/dist/engine/harness/agent-harness.js +3 -14
  218. package/dist/engine/harness/messages.d.ts +15 -0
  219. package/dist/engine/harness/types.d.ts +464 -2
  220. package/dist/engine/llm/diagnostics.d.ts +4 -0
  221. package/dist/engine/llm/event-stream.d.ts +3 -0
  222. package/dist/engine/llm/index.d.ts +7 -0
  223. package/dist/engine/llm/types.d.ts +500 -3
  224. package/dist/engine/llm/validation.d.ts +3 -0
  225. package/dist/engine/loop/agent-loop.d.ts +87 -2
  226. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  227. package/dist/engine/loop/types.d.ts +424 -0
  228. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  229. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  230. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  231. package/dist/engine/session/import-validate.d.ts +27 -0
  232. package/dist/engine/session/log-digest.d.ts +93 -0
  233. package/dist/engine/session/memory-repo.d.ts +6 -0
  234. package/dist/engine/session/memory-storage.d.ts +2 -0
  235. package/dist/engine/session/session.d.ts +75 -0
  236. package/dist/engine/session/storage-base.d.ts +8 -0
  237. package/dist/fixtures/index.d.ts +36 -0
  238. package/dist/index.d.ts +17 -2
  239. package/dist/index.js +1 -2
  240. package/dist/internal/harness-types.d.ts +6 -0
  241. package/dist/internal/harness.d.ts +11 -0
  242. package/dist/internal/llm.d.ts +6 -0
  243. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  244. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  245. package/dist/orchestration/goal.d.ts +57 -0
  246. package/dist/orchestration/goal.js +3 -0
  247. package/dist/orchestration/run-spec.d.ts +42 -0
  248. package/dist/orchestration/run-spec.js +4 -0
  249. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  250. package/dist/orchestration/workflow-governance.d.ts +61 -0
  251. package/dist/orchestration/workflow-meta.d.ts +28 -0
  252. package/dist/orchestration/workflow-observe.d.ts +60 -0
  253. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  254. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  255. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  256. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  257. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  258. package/dist/orchestration/workflow-types.d.ts +169 -2
  259. package/dist/orchestration/workflow.d.ts +358 -0
  260. package/dist/orchestration/workflow.js +13 -2
  261. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  262. package/dist/prompt-assembly/artifact.d.ts +25 -0
  263. package/dist/prompt-assembly/assemble.d.ts +20 -0
  264. package/dist/prompt-assembly/composer.d.ts +29 -0
  265. package/dist/prompt-assembly/epoch.d.ts +55 -1
  266. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  267. package/dist/prompt-assembly/explain.d.ts +12 -0
  268. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  269. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  270. package/dist/prompt-assembly/types.d.ts +115 -0
  271. package/dist/prompts/coordinator.d.ts +27 -0
  272. package/dist/prompts/default.d.ts +539 -0
  273. package/dist/prompts/simple-sections.d.ts +45 -0
  274. package/dist/prompts/supervisor.d.ts +66 -0
  275. package/dist/scenarios/env.d.ts +28 -0
  276. package/dist/scenarios/full-body.d.ts +50 -0
  277. package/dist/scenarios/scenario-registry.d.ts +60 -0
  278. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  279. package/dist/server/http.d.ts +17 -0
  280. package/dist/stores/cc/lockfile.d.ts +6 -0
  281. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  282. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  283. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  284. package/dist/stores/file/background-agent-store.d.ts +24 -0
  285. package/dist/stores/file/background-agent-store.js +2 -1
  286. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  287. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  288. package/dist/stores/file/fs-atomic.d.ts +155 -0
  289. package/dist/stores/file/index.d.ts +89 -0
  290. package/dist/stores/file/mailbox-store.d.ts +36 -0
  291. package/dist/stores/file/mailbox-store.js +2 -0
  292. package/dist/stores/file/memory-store.d.ts +82 -0
  293. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  294. package/dist/stores/file/session-policy-store.d.ts +28 -0
  295. package/dist/stores/file/session-store.d.ts +40 -0
  296. package/dist/stores/file/shared-ledger.d.ts +83 -0
  297. package/dist/stores/file/tool-result-store.d.ts +11 -0
  298. package/dist/stores/file/usage-window-store.d.ts +18 -0
  299. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  300. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  301. package/dist/stores/file/workflow-run-store.js +2 -0
  302. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  303. package/dist/tools/fs/encoding.d.ts +60 -0
  304. package/dist/tools/fs/fs-bash.d.ts +133 -0
  305. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  306. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  307. package/dist/tools/fs/fs-shared.d.ts +360 -0
  308. package/dist/tools/fs/fs-write.d.ts +16 -0
  309. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  310. package/dist/tools/fs/index.d.ts +79 -0
  311. package/dist/tools/fs/notebook.d.ts +56 -0
  312. package/dist/tools/fs/pdf.d.ts +70 -0
  313. package/dist/tools/fs/pdf.js +8 -2
  314. package/dist/tools/fs/repo-map.d.ts +10 -0
  315. package/dist/tools/fs/safety.d.ts +376 -0
  316. package/dist/tools/fs/search.d.ts +131 -0
  317. package/dist/tools/loop-tick.d.ts +24 -0
  318. package/dist/tools/monitor.d.ts +55 -0
  319. package/dist/tools/scheduler-tools.d.ts +51 -0
  320. package/dist/tools/sql-adapters.d.ts +18 -0
  321. package/dist/tools/sql.d.ts +25 -0
  322. package/dist/tools/task-list.d.ts +77 -0
  323. package/dist/tools/todo.d.ts +8 -0
  324. package/dist/tools/web.d.ts +184 -0
  325. package/dist/tools/web.js +32 -5
  326. package/dist/tools/worktree.d.ts +81 -0
  327. package/package.json +2 -2
  328. package/dist/tools/gitea-issue.d.ts +0 -13
  329. package/dist/tools/gitea-issue.js +0 -75
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Pure-type re-exports split out of harness.ts (S1, design/157) — see harness.ts for the full
3
+ * design/33 + design/118 facade narrative. This file exists to break an engine-import SCC: consumers
4
+ * that only need harness types (not the NodeExecutionEnv value export) import from here instead, so
5
+ * their compile-time dependency graph never has to reach the value side of the facade.
6
+ */
1
7
  export type { CompactionPreparation, SummarizationClampDryRun } from "../engine/compaction/compaction.js";
2
8
  export type { InvokedSkillRetention } from "../engine/compaction/utils.js";
3
9
  export type { AgentCoreRuntimeDeps } from "../engine/loop/runtime-deps.js";
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Internal boundary to the engine's harness layer (design/33; de-vendored by design/118). Everything
3
+ * in `src/` (outside `src/internal/`) imports these symbols from HERE, never via a deep
4
+ * `../engine/...` path — one auditable coupling point (CI-guarded by test/vendor-insulation.test.ts).
5
+ * The vendored tree this facade used to front is fully retired (design/118 ⓪-⑤); the facade stays so
6
+ * consumers never notice which module a symbol lives in.
7
+ *
8
+ * Pure-type re-exports live in ./harness-types.js (S1, design/157) — split out to break an
9
+ * engine-import SCC for type-only consumers. Re-exported here too so existing `harness.js` imports
10
+ * keep working unchanged.
11
+ */
1
12
  export * from "./harness-types.js";
2
13
  export { AgentHarness } from "../engine/harness/agent-harness.js";
3
14
  export { CompactionError, ExecutionError, FileError, ok, err } from "../engine/harness/types.js";
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Internal boundary to the llm layer (design/33). Everything in `src/` (outside `src/internal/`)
3
+ * imports these symbols from HERE, never via a deep path — one auditable coupling point (CI-guarded).
4
+ * design/118 ①②: the layer is now first-party (`src/engine/llm/`, naturalized out of the vendored
5
+ * llm-core); the facade stays so consumers never notice which side a symbol lives on.
6
+ */
1
7
  export { createAssistantMessageEventStream, snapshotActorAssertion, stripEngineMetadata } from "../engine/llm/index.js";
2
8
  export type { ActorAssertion, AnthropicMessagesCompat, OpenAICompletionsCompat, OpenAIResponsesCompat, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, CompleteSimpleFn, Context, DocumentContent, ImageContent, Message, Model, ResilienceOptions, SimpleStreamOptions, StallTimeouts, StopReason, StreamFn, TextContent, ThinkingContent, Tool, ToolCall, ToolResultMessage, Usage, UserMessage, } from "../engine/llm/index.js";
@@ -1,10 +1,63 @@
1
+ /**
2
+ * design/140 §6 1c — BUILT-IN named workflows offered by the `Workflow` tool's `{name}` calling surface,
3
+ * mirroring the built-in agents precedent (src/agents/builtin-agents.ts: GA default-on, opt out via a
4
+ * deployment config flag, same-name deployment registration SHADOWS the built-in):
5
+ * - `RunWorkflowToolDeps.builtinWorkflows: false` (threaded from `RunnerDeps.builtinWorkflows`) removes
6
+ * them wholesale;
7
+ * - a deployment `WorkflowScriptStore.resolveName` hit for the SAME NAME wins (the built-in is consulted
8
+ * only when the deployment registry does not resolve the name).
9
+ *
10
+ * The first built-in is `team-discussion` — the round-based collab profile design/140 §1 verified live
11
+ * (docs/DESIGN-140-VERIFICATION-2026-07-11.md B 面: 2 members × 2 rounds + finalizer, 8.2s/10.5K tokens,
12
+ * round 2 genuinely responding to round 1). It is pure SCRIPT CONTENT over the existing primitives — zero
13
+ * new runtime mechanism:
14
+ * - args schema (ALL optional — zero-config must run): `{ topic, members?: [{ role, prompt?, model? }],
15
+ * rounds?, finalizer?: { prompt?, model? } }`; a bare STRING args is accepted as the topic.
16
+ * - budget: reuses the workflow `budget` hard ceiling + DETERMINISTIC in-script truncation (a rounds/member
17
+ * cap and a `budget.remaining()` early-stop — never an evaluator agent; design/140 §1 "预算" row).
18
+ * - `meta.whenToUse` carries the REQUIRED negative boundary (when-NOT-to-use: single factual question /
19
+ * budget-sensitive runs — design/140 §4 "两投影").
20
+ */
1
21
  import type { NamedWorkflowListing } from "./workflow-script-store.js";
22
+ /** The built-in round-based team-discussion workflow's registered name. */
2
23
  export declare const TEAM_DISCUSSION_WORKFLOW_NAME = "team-discussion";
24
+ /**
25
+ * The `team-discussion` script source (design/140 §1 table row 1, live-verified shape: for-loop rounds +
26
+ * `agent()` members with transcript re-feed + a schema'd finalizer). Deterministic by construction — no
27
+ * clock/randomness reads (locked by test against `workflowScriptReadsClockOrRandom`).
28
+ */
3
29
  export declare const TEAM_DISCUSSION_SCRIPT = "export const meta = {\n name: \"team-discussion\",\n description: \"Round-based team discussion: configurable members debate a topic across rounds (each member sees the transcript so far), then a finalizer synthesizes a structured verdict.\",\n whenToUse: \"Use for a genuinely contested question that benefits from several perspectives arguing across rounds - design trade-offs, plan or risk reviews, adversarial critique of a proposal. Do NOT use it for a single factual question, a task with one obvious answer, or a budget-sensitive run: every round costs one agent call per member, so a discussion is never cheaper than asking once. args (all optional): { topic, members?: [{ role, prompt?, model? }], rounds?, finalizer?: { prompt?, model? } }. Hard ceilings: members is capped at 6 and rounds is capped at 5 regardless of what you pass; the run reports it via log() and a capped field on the result when a request exceeds either.\",\n phases: [\n { title: \"Discussion\" },\n { title: \"Synthesis\" },\n ],\n};\n// Zero-config runnable (design/140 \u00A76 1c): every arg has an opinionated fallback.\nconst raw = args;\nconst a = raw !== null && typeof raw === \"object\" && !Array.isArray(raw) ? raw : {};\nconst topic =\n typeof a.topic === \"string\" && a.topic.trim() !== \"\"\n ? a.topic\n : typeof raw === \"string\" && raw.trim() !== \"\"\n ? raw // ergonomic form: a bare string args IS the topic\n : \"No topic was provided. Discuss: what information should a caller supply to make a team discussion like this productive, and when should they NOT convene one?\";\nconst defaultMembers = [\n { role: \"advocate\", prompt: \"Make the strongest constructive case. Propose concrete options and argue their benefits with specifics.\" },\n { role: \"skeptic\", prompt: \"Stress-test every claim made so far. Surface risks, hidden costs, failure modes, and cheaper alternatives.\" },\n];\nconst rawMembers = Array.isArray(a.members) && a.members.length > 0 ? a.members : defaultMembers;\nconst members = rawMembers.slice(0, 6).map((m, i) => {\n const mm = m !== null && typeof m === \"object\" ? m : {};\n const member = {\n role: typeof mm.role === \"string\" && mm.role.trim() !== \"\" ? mm.role : \"member-\" + (i + 1),\n prompt: typeof mm.prompt === \"string\" && mm.prompt.trim() !== \"\" ? mm.prompt : \"Contribute your own distinct perspective: be concrete, give reasons, and engage with what others said.\",\n };\n if (typeof mm.model === \"string\" && mm.model.trim() !== \"\") member.model = mm.model;\n // Slot-tools carrier (design/140 \u2461-3 + F4): a member may BE a registered agent type ({agent:\"reviewer\"}) \u2014\n // persona/tools/model then come from the deployment's AgentDefinition (role library), args stay thin.\n if (typeof mm.agent === \"string\" && mm.agent.trim() !== \"\") member.agent = mm.agent;\n return member;\n});\n// Deterministic budget truncation (design/140 \u00A71 \u9884\u7B97 row): a HARD rounds ceiling + member cap \u2014 never an\n// evaluator agent. The engine's budget/maxAgents hard stops remain the backstop.\nconst requestedRounds = Math.floor(Number(a.rounds));\nconst normalizedRounds = Number.isFinite(requestedRounds) && requestedRounds >= 1 ? requestedRounds : 2;\nconst rounds = Math.min(normalizedRounds, 5);\n// RB-380 disclosure: the member/round slices above are silent by construction (Array.prototype.slice /\n// Math.min just drop the excess) \u2014 record + surface it instead of a caller finding out only by counting\n// transcript entries. Fires only when a request actually exceeded a ceiling (never on the common path).\nconst capNotes = [];\nif (rawMembers.length > 6) capNotes.push(\"requested \" + rawMembers.length + \" members, capped at 6\");\nif (normalizedRounds > 5) capNotes.push(\"requested \" + normalizedRounds + \" rounds, capped at 5\");\nfor (const note of capNotes) log(\"team-discussion: \" + note);\nconst fin = a.finalizer !== null && typeof a.finalizer === \"object\" && !Array.isArray(a.finalizer) ? a.finalizer : {};\nconst finalizerPrompt = typeof fin.prompt === \"string\" && fin.prompt.trim() !== \"\"\n ? fin.prompt\n : \"You are the synthesis lead. Read the full discussion transcript and produce the final verdict: the decision/answer, the key supporting points, and the strongest unresolved dissent (if any). Do not introduce new arguments of your own.\";\nconst clip = (s) => { const t = String(s); return t.length > 4000 ? t.slice(0, 4000) + \" ...[truncated]\" : t; };\nconst isBudgetStop = (e) => e !== null && typeof e === \"object\" && e.code === \"workflow.budget_exceeded\";\n\nphase(\"Discussion\");\nconst transcript = [];\nlet truncated = null;\nfor (let r = 1; r <= rounds && truncated === null; r++) {\n // Deterministic early stop on an exhausted budget (a live read of the engine budget; the engine's\n // hard WorkflowBudgetExceededError remains the backstop if a member call itself crosses the line).\n if (budget.total !== null && budget.remaining() <= 0) { truncated = \"budget exhausted before round \" + r; break; }\n for (const m of members) {\n const history = transcript.length === 0 ? \"(none yet - you open the discussion)\" : transcript.join(\"\\n\\n\");\n const spec = {\n objective:\n \"Team discussion on: \" + topic + \"\\n\\n\" +\n 'You are \"' + m.role + '\" in round ' + r + \" of \" + rounds + \".\\n\" +\n \"Your brief: \" + m.prompt + \"\\n\\n\" +\n \"Transcript so far:\\n\" + history + \"\\n\\n\" +\n \"Respond to the strongest points others made (do not repeat yourself), then advance your own position. Be concise: a few tight paragraphs at most.\",\n };\n if (m.model !== undefined) spec.modelName = m.model;\n let res;\n try {\n res = await agent(spec, m.agent !== undefined ? { label: m.role + \"-r\" + r, phase: \"Discussion\", agentType: m.agent } : { label: m.role + \"-r\" + r, phase: \"Discussion\" });\n } catch (e) {\n // The engine's budget hard stop: keep what the discussion already produced instead of failing the run.\n if (isBudgetStop(e)) { truncated = \"budget exhausted at \" + m.role + \", round \" + r; break; }\n throw e;\n }\n const text = res && res.status === \"completed\" ? clip(res.result) : \"(no contribution - agent ended \" + (res ? res.status : \"unknown\") + \")\";\n transcript.push(m.role + \" (round \" + r + \"): \" + text);\n }\n}\n\nphase(\"Synthesis\");\nconst finalSpec = {\n objective:\n finalizerPrompt + \"\\n\\nTopic: \" + topic + \"\\n\\nFull transcript:\\n\" +\n (transcript.length === 0 ? \"(the discussion produced no contributions)\" : transcript.join(\"\\n\\n\")) +\n (truncated ? \"\\n\\nNote: the discussion was cut short (\" + truncated + \").\" : \"\"),\n};\nif (typeof fin.model === \"string\" && fin.model.trim() !== \"\") finalSpec.modelName = fin.model;\nlet verdict = null;\ntry {\n verdict = await agent(finalSpec, {\n label: \"finalizer\",\n phase: \"Synthesis\",\n schema: {\n type: \"object\",\n properties: {\n decision: { type: \"string\", description: \"The final answer/decision, one paragraph.\" },\n keyPoints: { type: \"array\", items: { type: \"string\" }, description: \"The strongest supporting points from the discussion.\" },\n dissent: { type: \"string\", description: \"The strongest unresolved counter-position, if any.\" },\n },\n required: [\"decision\", \"keyPoints\"],\n },\n });\n} catch (e) {\n // Budget died before synthesis: return the transcript honestly rather than failing the whole run.\n if (!isBudgetStop(e)) throw e;\n truncated = truncated === null ? \"budget exhausted before synthesis\" : truncated;\n}\n\nreturn {\n topic,\n rounds,\n members: members.map((m) => m.role),\n ...(capNotes.length > 0 ? { capped: capNotes } : {}),\n ...(truncated ? { truncated } : {}),\n transcript,\n verdict: verdict && verdict.structuredOutput !== undefined ? verdict.structuredOutput : (verdict ? verdict.result : null),\n};\n";
30
+ /** One built-in named workflow: the registered name + its self-contained script source. The name is the
31
+ * routing key of the `{name}` calling surface; the script's `meta.name` matches it (locked by test). */
4
32
  export interface BuiltinWorkflowDefinition {
5
33
  name: string;
6
34
  script: string;
7
35
  }
36
+ /**
37
+ * The built-in named-workflow registry. Order = card listing order.
38
+ *
39
+ * RB-342 (2026-07-29): the previous note called this a "CC `HCe`-analog shape". `HCe` is not a workflow
40
+ * symbol in the 220 corpus at all (it is a memoized JSX local in a renderer, pretty220 885850+) — the name
41
+ * came from an older bundle and drifted, the standing hazard with minified identifiers. The real 220
42
+ * counterpart is the built-in workflow list behind `Rsn()` / `Dft()` (451216 / 454626), and the shape
43
+ * matches only PARTLY:
44
+ *
45
+ * - **Registry, not literal.** 220's backing array is initialised EMPTY (`kSd = []`, 451221) and filled at
46
+ * startup by feature-gated registrars (`DRo`, 451207 — two callers, `code-review` @496716 and
47
+ * `deep-research` @497127, each behind its own enablement check); `Rsn()` additionally returns `[]`
48
+ * wholesale when its gate is off. sema's list is a compile-time literal with no gating. Same role,
49
+ * different lifecycle — do not read "CC ships these built-ins unconditionally" out of this function.
50
+ * - **Shadowing holds; ordering does not transfer.** 220 resolves by concatenating
51
+ * `[...builtins.filter(name not taken), ...userLevel, ...projectLevel]` (454641-454647): a
52
+ * deployment-defined workflow of the same name REMOVES the built-in, which is the same net rule as
53
+ * {@link resolveBuiltinWorkflow} being the second lookup. But 220 lists built-ins FIRST and enforces the
54
+ * shadow by filtering, while sema enforces it by lookup order — so the listing order here is sema's own
55
+ * choice, not a parity constraint.
56
+ */
8
57
  export declare function builtinWorkflowDefinitions(): BuiltinWorkflowDefinition[];
58
+ /** Resolve a built-in workflow by name (the `{name}` surface's SECOND lookup — a deployment
59
+ * `scriptStore.resolveName` hit for the same name shadows this, design/140 §6 1c). */
9
60
  export declare function resolveBuiltinWorkflow(name: string): BuiltinWorkflowDefinition | undefined;
61
+ /** design/140 §6 1b — the built-ins' listing projection rows (name + description + whenToUse, parsed from
62
+ * each script's static meta). Consumed by the Workflow tool card renderer. */
10
63
  export declare function builtinWorkflowListings(): NamedWorkflowListing[];
@@ -1,3 +1,22 @@
1
+ /**
2
+ * design/98 §2.2 (S8b) — a `WorkflowScriptRunner` backed by Node's `vm`, for TRUSTED, DEVELOPER-authored
3
+ * workflow scripts ONLY.
4
+ *
5
+ * 🔴🔴 NOT A SECURITY BOUNDARY. Node `vm` does NOT isolate untrusted code: a script can reach the host realm
6
+ * through the prototype chain of ANY injected host object —
7
+ * `agent.constructor.constructor("return process")()`
8
+ * yields the host `process` (the injected `agent` is a host function; its `.constructor.constructor` is the
9
+ * HOST `Function`, evaluated in the host realm where code-generation is unrestricted). The
10
+ * `codeGeneration:{strings:false}` below hardens the vm context's OWN eval/Function but CANNOT close that
11
+ * constructor-chain escape — see `test/workflow-vm-escape.test.ts`, which PROVES the escape so no one ever
12
+ * mistakes this for a sandbox.
13
+ *
14
+ * Therefore `safeForUntrustedScripts === false`: the S8 self-orchestration gate (design/98 §C) refuses to
15
+ * mount `run_workflow` with this runner. An LLM-authored script REQUIRES a runner whose
16
+ * `safeForUntrustedScripts === true` (isolated-vm / separate process + container), supplied by the deployment
17
+ * or a separate `@ai-only/workflow-sandbox` package. Core ships this dev runner + the conformance contract a
18
+ * hard runner must pass ({@link import("./workflow-sandbox-conformance.js").assertWorkflowSandboxConformance}).
19
+ */
1
20
  import type { WorkflowScriptRunner } from "./workflow-script-runner.js";
2
21
  export declare const WORKFLOW_DATE_ERR = "Date.now() / new Date() are unavailable in workflow scripts (breaks resume). Stamp results after the workflow returns, or pass timestamps via args.";
3
22
  export declare const WORKFLOW_RANDOM_ERR = "Math.random() is unavailable in workflow scripts (breaks resume). For N independent samples, include the index in the agent label or prompt.";
@@ -1,39 +1,96 @@
1
+ /**
2
+ * design/96 §C (S2) — **Goal 模式**:LLM 自报完成 + core 校验续跑(CC goal 对标:目标 + 完成判定 + 续跑)。
3
+ * `runGoal` 是 `runRepairLoop`/`verifyCompleted` 的 SIBLING —— thin composition over `runner.runTask`,零
4
+ * Runner core 改动。详 `design/96-references/GOAL-IMPLEMENTER-SPEC.md`(v3,codex r1+r2 异源对抗收敛)。
5
+ *
6
+ * 🔴 **完成判定双闸(reward-hack 红线)**:① LLM 自报完成 = 调内置 `declare_done` 工具(或 `submit_output`,有
7
+ * outputSchema 时)= **机器信号**,非泛化 `completed`;② core `doneCheck`(机械/oracle 校验)。**AND**:仅二者
8
+ * 都满足才停 —— LLM 自报但 doneCheck 否决 → 续跑(把 reason 围栏喂回),这是防"模型说我完成了就算数"的核心。
9
+ *
10
+ * 🔴 **G1 脱钩(不可绕)**:`status:"achieved"` = 双闸过 → **停迭代 + SURFACE**,`accepted` 恒 false。runGoal
11
+ * **无任何 commit/accept 副作用**(纯 loop,同 runRepairLoop SAFE-tier 永不 `fixed`)。要 accept,caller 自走
12
+ * design/77 Gate-1 out-of-process oracle 隔离边界,不在 goal helper 开后门。
13
+ */
1
14
  import type { Runner } from "../core/runner/runtask.js";
2
15
  import type { CheckpointToken } from "../core/checkpoint-store.js";
3
16
  import type { TaskResult, TaskSpec } from "../core/types.js";
17
+ /** Read-only snapshot a `doneCheck` sees after one iteration. */
4
18
  export interface GoalTurnState {
19
+ /** This iteration's full {@link TaskResult}. */
5
20
  readonly result: TaskResult;
21
+ /** 1-based iteration index. */
6
22
  readonly iteration: number;
23
+ /** The session threaded through the whole goal (so a doneCheck can read the session/working tree). */
7
24
  readonly sessionId: string;
25
+ /** Cumulative tokens (own + nested) across iterations — observe-only (the budget gate is in the engine). */
8
26
  readonly cumulativeTokens: number;
9
27
  }
10
28
  export interface GoalVerdict {
29
+ /** core verification passed? (AND-ed with the LLM self-report — the double gate). */
11
30
  readonly done: boolean;
31
+ /** When not done: the specific feedback fed back to the LLM (fenced as untrusted data). */
12
32
  readonly reason: string;
13
33
  }
34
+ /** The caller's HONEST declaration of how `doneCheck` verifies — surfaced on the result so a
35
+ * `self_report_only` "achieved" is never mistaken for a mechanically-verified one (G1, reward-hack honesty). */
14
36
  export type GoalVerificationKind = "mechanical" | "self_report_only";
15
37
  export interface GoalSpec {
38
+ /** The goal (injected as iteration 1's objective + GOAL_COMPLETION_GUIDANCE via the trusted goalMode flag). */
16
39
  objective: string;
40
+ /**
41
+ * 🔴 The CORE completion gate (REQUIRED). The LLM self-report (gate 1) is necessary but NOT sufficient: the
42
+ * goal stops as `achieved` only when gate 1 AND `doneCheck.done`. Provide a PURE read-check (it may read the
43
+ * session/working tree but must have no side effects — it can be cancelled/timed out). A throw/reject
44
+ * fail-closes to `failed`/`goal.donecheck_error` (never treated as achieved). Core ships no default —
45
+ * supplying it forces the caller to confront the reward-hack red line.
46
+ */
17
47
  doneCheck: (state: GoalTurnState, signal: AbortSignal) => Promise<GoalVerdict>;
48
+ /** Honest declaration of `doneCheck`'s substance (§3.2). `self_report_only` ⇒ surfaced on the result. */
18
49
  verificationKind: GoalVerificationKind;
50
+ /** Hard iteration cap (≥1) — exceeding without the double gate → `max_iterations` (NOT achieved). */
19
51
  maxIterations: number;
52
+ /** Per-iteration base spec (model/tools/toolPolicy/principal/env/outputSchema/…). `objective` is overridden
53
+ * per iteration; `sessionId` is minted to thread the whole goal if absent; `signal` is set by the engine. */
20
54
  taskSpec: Omit<TaskSpec, "objective">;
55
+ /** Cumulative token ceiling (own + nested); reaching it stops with `budget`. */
21
56
  budgetTokens?: number;
57
+ /** Whole-goal wall-clock ceiling (ms); reaching it stops with `budget`. */
22
58
  totalTimeoutMs?: number;
59
+ /** Cancels the whole goal (folded into each iteration's signal + the doneCheck). */
23
60
  signal?: AbortSignal;
61
+ /**
62
+ * design/73 §1 — aggregation key of the `TaskOutcome` emitted at the goal's terminal state (only when
63
+ * `verificationKind:"mechanical"` — the red line). Default: `goal:<sha256(objective) first 16 hex>`,
64
+ * deterministic per objective. Set it when the "same task" spans differently-worded objectives.
65
+ */
24
66
  taskSignature?: string;
25
67
  }
26
68
  export type GoalStatus = "achieved" | "max_iterations" | "budget" | "blocked" | "suspended" | "needs_review" | "failed" | "aborted";
27
69
  export interface GoalResult {
28
70
  readonly status: GoalStatus;
71
+ /** Last iteration's result; absent on a preflight-terminate (a stop BEFORE iteration 1 ran). */
29
72
  readonly result?: TaskResult;
30
73
  readonly iterations: number;
74
+ /** The last `doneCheck` verdict (present once a doneCheck ran). */
31
75
  readonly lastVerdict?: GoalVerdict;
76
+ /** The caller's declared verification kind (always present — replaces the ambiguous "verifiedBy"). */
32
77
  readonly verificationKind: GoalVerificationKind;
78
+ /** 🔴 G1 explicit: runGoal NEVER accepts the artifact. Always false. `achieved` = "stopped + awaiting
79
+ * review"; the caller decides acceptance (via a Gate-1 boundary), never runGoal. */
33
80
  readonly accepted: false;
34
81
  readonly cumulativeTokens: number;
82
+ /** Carried up on suspended/needs_review so the caller can resume the underlying task. */
35
83
  readonly checkpointToken?: CheckpointToken;
84
+ /** Set on `failed` (incl. `goal.donecheck_error`). */
36
85
  readonly errorCode?: string;
37
86
  }
87
+ /** Reserved name of the goal-completion signal tool (injected by `runGoal` when there is no outputSchema). */
38
88
  export declare const DECLARE_DONE_TOOL_NAME = "DeclareDone";
89
+ /**
90
+ * Run a goal to a double-gated completion (or a bound). Iterates `runner.runTask` on ONE session: each
91
+ * iteration the LLM works and signals completion (declare_done / submit_output); `doneCheck` then verifies.
92
+ * Only `declare_done` AND `doneCheck.done` → `achieved` (surfaced, NEVER auto-accepted, G1). A rejected
93
+ * doneCheck feeds its reason back (fenced) and continues. Bounded by maxIterations / budget / wall-clock /
94
+ * cancel; a durable pause (suspended/needs_review) is a hard boundary that surfaces the checkpointToken.
95
+ */
39
96
  export declare function runGoal(runner: Runner, spec: GoalSpec): Promise<GoalResult>;
@@ -60,6 +60,9 @@ export async function runGoal(runner, spec) {
60
60
  if (!Number.isFinite(spec.maxIterations) || spec.maxIterations < 1) {
61
61
  throw new Error(`runGoal: maxIterations must be a finite number ≥ 1 (got ${spec.maxIterations})`);
62
62
  }
63
+ if (spec.totalTimeoutMs !== undefined && (!Number.isFinite(spec.totalTimeoutMs) || spec.totalTimeoutMs < 0 || spec.totalTimeoutMs > 2_147_483_647)) {
64
+ throw new Error(`runGoal: totalTimeoutMs must be a finite number in [0, 2147483647] (got ${spec.totalTimeoutMs}) — a host timer clamps anything else and fires immediately. Omit it for no deadline.`);
65
+ }
63
66
  const hasOutputSchema = spec.taskSpec.outputSchema !== undefined;
64
67
  if (!hasOutputSchema && (spec.taskSpec.tools ?? []).some((t) => t.name === DECLARE_DONE_TOOL_NAME)) {
65
68
  const e = new Error(`Tool name "${DECLARE_DONE_TOOL_NAME}" is reserved in goal mode.`);
@@ -1,20 +1,62 @@
1
+ /**
2
+ * design/125 D2 — **`runSpec`**:SpecContract 的 thin 装配器(形态定死 = `runTask` + Stop hook;裁决
3
+ * 议题#1:不组合 runGoal —— doneCheck 只在模型自报后跑不适合外部强制,且 mechanical goal 终态自己发射
4
+ * TaskOutcome,组合 = 同 taskSignature 双发射,违反 design/73 红线③)。
5
+ *
6
+ * 装配五步(全部**组合而非覆盖**,codex-B1=fable-M4):
7
+ * 1. preflight:frozenPaths 校验+字节快照;亲跑三值 oracle;requireRedStart(默认 true)⇒ 必须 red
8
+ * (green→`spec.not_red`、error→`spec.oracle_error`,均 fail-loud);捕获 baseline 计数。
9
+ * 2. frozen deny policy 经 {@link combinePolicies} 合入部署基线(deny 短路不可被顶);绝不裸赋顶掉
10
+ * `taskSpec.toolPolicy`(TRAP #1)。
11
+ * 3. Hooks 多路复用:runSpec 的 stop gate 先跑(guard-restore → oracle 判)——red ⇒ block 短路(失败
12
+ * 尾部经 `delimitUntrusted` 围栏后置入:oracle 输出是模型可影响面);green ⇒ **链式调用**用户 stop
13
+ * (不吞其否决权);error ⇒ block 一次并注明 oracle 基础设施故障,**连续 2 次 error 放弃把关**走终态
14
+ * 判定(防 oracle 自坏死循环)。其它 hook 槽原样透传。
15
+ * 4. 收口:终态亲跑 oracle = 最终判定;`emitTaskOutcome`(mechanical):`oracleHadRedRun` = 任一
16
+ * 「真跑过且判 red」的观察(preflight ∨ stop-gate ∨ 终态;error 永不置位)。durable pause
17
+ * (suspended/needs_review)非终态,不发射(同 goal.ts 先例:无半事实、resume 不重复计数)。
18
+ * 5. objective 框架:spec 文本围栏置入 + frozenPaths 只读声明(框架 = 可信第一方,spec = DATA)。
19
+ *
20
+ * 已知两代价(fable,写明):① stop cap=8 引擎硬常量 —— >8 次红反馈的超长修复需拆任务;② stop gate 只在
21
+ * 自然结束点咨询,maxTurns/timeout/abort 结束不咨询 —— 终态亲跑兜住**判定**但不兜**续命**(预算配比
22
+ * 参考 harness 实战:maxTurns=60 / 自限 6)。
23
+ *
24
+ * runSpec **不接**的 harness 职责(fable-MIN1,显式留给使用方):JSONL 事件账本、不变量检查器、workcopy
25
+ * 生命周期(调用方保证起点是干净树 —— preflight 红才有意义)、模型/Runner 装配、chaos 包装。frozen 写入
26
+ * 面:policy 只挡 Write/Edit 族 = belt;bash 写入由快照恢复兜(suspenders);危险 bash deny 仍是使用方纪律。
27
+ */
1
28
  import type { Runner } from "../core/runner/runtask.js";
2
29
  import type { TaskResult, TaskSpec } from "../core/types.js";
3
30
  import type { TaskOutcome } from "../core/task-outcome.js";
4
31
  import { type OracleBaseline, type OracleGateResult, type OracleVerdict, type SpecContract } from "../core/spec-contract.js";
5
32
  export interface RunSpecOptions {
33
+ /** Workcopy root — the containment root for frozenPaths, oracle cwd, and `spec.path` resolution. */
6
34
  rootDir: string;
35
+ /** Per-run base spec (model/tools/toolPolicy/hooks/limits/…). `objective` is owned by runSpec (the
36
+ * spec framing); `toolPolicy` and `hooks` are COMPOSED with runSpec's, never replaced. */
7
37
  taskSpec: Omit<TaskSpec, "objective">;
8
38
  }
9
39
  export interface RunSpecOracleReport {
40
+ /** Terminal adjudication (the authoritative bit — the stop gate only advises mid-run). */
10
41
  final: OracleVerdict;
11
42
  perGate: OracleGateResult[];
43
+ /** Preflight counts backing `minPass:"baseline"` (empty when no gate parses counts). */
12
44
  baseline: OracleBaseline;
13
45
  }
14
46
  export interface RunSpecResult {
15
47
  result: TaskResult;
16
48
  oracle: RunSpecOracleReport;
49
+ /** The emitted outcome fact. Undefined on a durable pause (suspended/needs_review — not a terminal). */
17
50
  outcome?: TaskOutcome;
51
+ /** How many frozen files were byte-restored after tampering (stop gates + terminal sweep). */
18
52
  guardRestores: number;
19
53
  }
54
+ /**
55
+ * Run one task under a {@link SpecContract}. 🔴 CODE-tier input contract (fable-M3): `contract` must come
56
+ * from the deployment author / a trusted code path — its oracle commands are executed verbatim.
57
+ *
58
+ * Throws coded errors on contract violations before any model turn runs: `spec.no_oracle`,
59
+ * `spec.frozen_path_invalid`, `spec.frozen_missing`, `spec.spec_unreadable`, `spec.not_red`,
60
+ * `spec.oracle_error`.
61
+ */
20
62
  export declare function runSpec(runner: Pick<Runner, "runTask"> & Partial<Pick<Runner, "emitTaskOutcome" | "gateBaseline">>, contract: SpecContract, opts: RunSpecOptions): Promise<RunSpecResult>;
@@ -102,6 +102,9 @@ export async function runSpec(runner, contract, opts) {
102
102
  const userHooks = opts.taskSpec.hooks && deployBaseline?.hooks
103
103
  ? {
104
104
  preToolUse: (opts.taskSpec.hooks.preToolUse ?? deployBaseline.hooks.preToolUse)?.bind(opts.taskSpec.hooks.preToolUse ? opts.taskSpec.hooks : deployBaseline.hooks),
105
+ ...((opts.taskSpec.hooks.preToolUse ? opts.taskSpec.hooks : deployBaseline.hooks).preToolUseObservational === true
106
+ ? { preToolUseObservational: true }
107
+ : {}),
105
108
  postToolUse: (opts.taskSpec.hooks.postToolUse ?? deployBaseline.hooks.postToolUse)?.bind(opts.taskSpec.hooks.postToolUse ? opts.taskSpec.hooks : deployBaseline.hooks),
106
109
  userPromptSubmit: (opts.taskSpec.hooks.userPromptSubmit ?? deployBaseline.hooks.userPromptSubmit)?.bind(opts.taskSpec.hooks.userPromptSubmit ? opts.taskSpec.hooks : deployBaseline.hooks),
107
110
  stop: (opts.taskSpec.hooks.stop ?? deployBaseline.hooks.stop)?.bind(opts.taskSpec.hooks.stop ? opts.taskSpec.hooks : deployBaseline.hooks),
@@ -118,6 +121,7 @@ export async function runSpec(runner, contract, opts) {
118
121
  let gateAbandoned = false;
119
122
  const hooks = {
120
123
  ...(userHooks?.preToolUse && { preToolUse: userHooks.preToolUse.bind(userHooks) }),
124
+ ...(userHooks?.preToolUse && userHooks.preToolUseObservational === true ? { preToolUseObservational: true } : {}),
121
125
  ...(userHooks?.postToolUse && { postToolUse: userHooks.postToolUse.bind(userHooks) }),
122
126
  ...(userHooks?.userPromptSubmit && { userPromptSubmit: userHooks.userPromptSubmit.bind(userHooks) }),
123
127
  ...(userHooks?.postToolUseFailure && { postToolUseFailure: userHooks.postToolUseFailure.bind(userHooks) }),
@@ -1,3 +1,14 @@
1
+ /**
2
+ * design/98 §3.1 (S8c) — the `run_workflow` TOOL an LLM calls to author + run its own workflow. Mounted ONLY
3
+ * when self-orchestration is active (design/98 §1.2: opt-in + a HARD `WorkflowScriptRunner` + a governance
4
+ * baseline). Params are ONLY `{ script, args }` — it NEVER accepts `depth` (the nesting depth is a trusted
5
+ * internal channel, design/98 §0.1). `effect: "write"` (spawning agents is an irreversible side effect → it
6
+ * passes the design/37 policy gate; each spawned agent then passes its OWN governed gate).
7
+ *
8
+ * Flow: size-cap the script → statically validate `meta` (no eval) → `startWorkflow` with the GOVERNED
9
+ * primitives + hard caps → return `{ runId }` IMMEDIATELY → on completion, notify the originator via the
10
+ * {@link WorkflowCompletionNotifier} seam.
11
+ */
1
12
  import type { AgentTool } from "../internal/harness-types.js";
2
13
  import type { Model } from "../internal/llm.js";
3
14
  import type { Runner } from "../core/runner/runtask.js";
@@ -10,7 +21,17 @@ import type { WorkflowAgentHandle } from "./workflow.js";
10
21
  import type { WorkflowScriptRunner } from "./workflow-script-runner.js";
11
22
  import { type NamedWorkflowListing, type WorkflowScriptStore } from "./workflow-script-store.js";
12
23
  import { type WorkflowSizeGuideline } from "./workflow-size-guideline.js";
24
+ /** Reserved name of the injected self-orchestration tool. Audit 2026-07-07: CC's primary
25
+ * name is `Workflow` with `RunWorkflow` as the alias — CC-trained prompts address "Workflow", so the
26
+ * primary flipped to match. #181-F2 订正: since RB-476-A retired alias resolution, `RunWorkflow`/
27
+ * `run_workflow` are NOT callable — they live in RETIRED_TOOL_NAMES as validation data only (a call
28
+ * under either gets a loud roster miss), so every model-visible mention must use THIS constant. */
13
29
  export declare const RUN_WORKFLOW_TOOL_NAME = "Workflow";
30
+ /**
31
+ * design/98 §D.5 — the seam the deployment implements to RE-INVOKE the originating LLM when its workflow
32
+ * finishes. Core calls `notify` once per run (at most once — `runId` dedup) with a REDACTED, BOUNDED summary;
33
+ * the service routes it back through its task-notification path (cross-replica via the WorkflowRunStore).
34
+ */
14
35
  export interface WorkflowCompletionNotifier {
15
36
  notify(input: {
16
37
  runId: string;
@@ -18,15 +39,34 @@ export interface WorkflowCompletionNotifier {
18
39
  task_type?: "workflow";
19
40
  toolUseId?: string;
20
41
  sourceTaskId?: string;
42
+ /** The ORIGINATING session id (the run that spawned this workflow), threaded from the
43
+ * Runner so a deployment's completion inbox resolves the target session lookup-free. */
21
44
  originatingSessionId?: string;
22
45
  principal?: string;
23
46
  status: "completed" | "failed";
47
+ /** Redacted + length-bounded — never the host's internal paths/tokens. */
24
48
  summary: string;
25
49
  result?: string;
26
50
  usage?: unknown;
51
+ /** [1630]-sweep A-①: the diagnosis route (per-agent rows / journal locator / resumeFromRunId guidance).
52
+ * Added 1.353 on the payload but silently dropped at this hand-written subset seam until 1.404 —
53
+ * keep this interface in lockstep with the payload fields the settle legs mint. */
27
54
  diagnostics?: string;
55
+ /** P1-3(黑板 [1920]/[1921]/[1924]/[1925]) — see {@link "../core/task-notification.js".TaskNotificationPayload.completionId}.
56
+ * This CROSS-REPLICA seam is exactly one of the read faces the cross-channel correlation contract
57
+ * promises the same value on — added here in the same car specifically so this interface does not
58
+ * repeat the diagnostics field's own drift history (the comment right above this one). */
28
59
  completionId?: string;
29
60
  }): Promise<void> | void;
61
+ /**
62
+ * Poll-then-also-notify dedup: the ORIGINATING session was served this run's TERMINAL
63
+ * state IN-BAND (a `TaskOutput` poll through the task registry returned a non-running snapshot) —
64
+ * the deployment should ack/drop any still-pending completion-inbox entry for (originatingSessionId,
65
+ * runId), so a later stream-open doesn't re-deliver a `workflow_complete` the model already
66
+ * consumed. Fired at most once per run, AFTER `notify` may already have enqueued (the whole point:
67
+ * the poll usually wins the race in-turn). Optional; errors are swallowed. The shell-side same-process
68
+ * seed dedup remains the belt — this is the durable/cross-restart half.
69
+ */
30
70
  ackServed?(input: {
31
71
  runId: string;
32
72
  originatingSessionId?: string;
@@ -34,63 +74,192 @@ export interface WorkflowCompletionNotifier {
34
74
  principal?: string;
35
75
  }): Promise<void> | void;
36
76
  }
77
+ /** design/98 §D.6 — the deployment's hard CEILINGS for an LLM-authored workflow (the tool forces them; a
78
+ * script may only tighten). All optional; sensible defaults bound a runaway script. */
37
79
  export interface WorkflowLimits {
80
+ /** Max script source length (chars). Default 100_000. */
38
81
  maxScriptChars?: number;
82
+ /** Max cumulative agents. Default 50. */
39
83
  maxAgents?: number;
84
+ /** Whole-workflow wall-clock cap (ms). Default 600_000 (10 min). */
40
85
  totalTimeoutMs?: number;
86
+ /** design/164 — per-child wall-clock ceiling (ms). No default: unset means the children are not
87
+ * wall-clock bounded (state a ceiling to get one). */
41
88
  perAgentMaxWalltimeMs?: number;
89
+ /** Per-child cost ceiling (USD). Forced onto every child. */
42
90
  childMaxCostUsd?: number;
91
+ /** Per-child token ceiling. Forced onto every child. */
43
92
  childMaxTokens?: number;
93
+ /** Per-child turn ceiling. */
44
94
  childMaxTurns?: number;
95
+ /** Workflow token budget (`ctx.agent` throws once reached). */
45
96
  budget?: number;
97
+ /** Max returned-result size (chars). Default 100_000. */
46
98
  maxResultChars?: number;
99
+ /** Max single log-line length (chars). Default 10_000. */
47
100
  maxLogChars?: number;
101
+ /**
102
+ * CC 2.1.202+ config key `workflowSizeGuideline`: ADVISORY workflow size guidance
103
+ * (NOT a cap — the hard ceiling stays `maxAgents`). small/medium/large append CC's verbatim
104
+ * "keep workflows under N agents … guideline, not a hard limit" section to the Workflow tool card
105
+ * (matching observed CC behavior); an EXPLICIT "unrestricted" injects nothing, while unset resolves
106
+ * to the medium DEFAULT arm (RB-339 rebaseline — see workflow-size-guideline.ts).
107
+ * Lives on the limits object so it rides the EXISTING `RunnerDeps.workflowLimits` threading —
108
+ * deployments configure it as `workflowLimits: { sizeGuideline }` with no new prepare-task seam.
109
+ * `RunWorkflowToolDeps.sizeGuideline` (direct construction) takes precedence when both are set.
110
+ */
48
111
  sizeGuideline?: WorkflowSizeGuideline;
49
112
  }
113
+ /**
114
+ * design/140 §6 1b — pick the LLM-facing guidance text for one named workflow: `whenToUse` when declared,
115
+ * else the description (the agents-side `agentWhenToUseText`/CC `tIl` selection shape, workflows arm —
116
+ * workflows have no lean variant, so the fallback chain is just whenToUse → description).
117
+ */
50
118
  export declare function workflowWhenToUseText(m: {
51
119
  description?: string;
52
120
  whenToUse?: string;
53
121
  }): string | undefined;
122
+ /**
123
+ * design/140 §6 1b — render the named-workflow roster block appended to the Workflow tool card (the
124
+ * consumption face `meta.whenToUse` previously lacked). Line shape mirrors the agent roster (CC `tIl`,
125
+ * subagent.ts precedent): `- name: whenToUse-or-description`. Returns undefined when nothing is registered
126
+ * (the card stays byte-identical to the pre-140 form).
127
+ */
54
128
  export declare function renderNamedWorkflowListing(entries: ReadonlyArray<NamedWorkflowListing>): string | undefined;
55
129
  export interface RunWorkflowToolDeps {
130
+ /** The Runner that executes child tasks (the workflow's `ctx.agent` → `runner.runTask`). */
56
131
  runner: Runner;
132
+ /** The HARD sandbox (asserted `safeForUntrustedScripts:true`). */
57
133
  scriptRunner: WorkflowScriptRunner;
134
+ /** Deployment-trusted governance every spawned agent inherits (design/98 §2.5). */
58
135
  governanceBaseline: WorkflowGovernanceBaseline;
136
+ /** codex F6 (tool-face round 5): the HOST task's tool-face controls (prepare-time snapshot) — a
137
+ * scenario roster must survive the workflow delegation path exactly like the Agent path. Merged
138
+ * (union — tighten-only) into the baseline base for every child spec this workflow spawns. */
59
139
  parentExcludeTools?: readonly string[];
60
140
  parentDeferTools?: readonly string[];
141
+ /** DD-3 (RB-422): the defer face's subtract valve rides the same snapshot — a pin the operator
142
+ * declared for the tree must survive this direct-mount lane exactly like the deferral it exempts
143
+ * from. Union (widen-the-exemption never tightens the child beyond the parent's own face). */
61
144
  parentAlwaysLoadTools?: readonly string[];
145
+ /** R2 双形轴 — the HOST task's resolved prompt profile, inherited by every workflow-spawned child
146
+ * (base spec seat; the child's own explicit promptProfile would win in prepare, but workflow
147
+ * scripts cannot name this field, so in practice the tree speaks the host's profile). */
62
148
  parentPromptProfile?: "simple" | "classic";
149
+ /** Model catalog (for the name→Model allowlist resolution). */
63
150
  models?: Record<string, Model>;
151
+ /** F4 agentType registry: deployment agent definitions `agent(…, {agentType})` resolves (SHADOW over
152
+ * built-in Explore/Plan; `builtinAgents:false` removes the built-ins). Same registry the Agent tool uses. */
64
153
  agents?: import("../core/types.js").AgentDefinition[];
65
154
  builtinAgents?: boolean;
155
+ /** Optional run store for cross-replica `/workflows` observability (opt-in). */
66
156
  store?: WorkflowRunStore;
157
+ /** design/97 CORE-9 (Part A) — optional LOAD-BEARING resume journal: records each agent result so a
158
+ * `resumeFromRunId` re-run replays the unchanged prefix (durable cross-replica resume). Opt-in. */
67
159
  journalStore?: WorkflowJournalStore;
160
+ /** design/149 ([1422]③ 裁 a): the process-level BackgroundChildEvent sink — workflow-spawned agents
161
+ * mint synthetic `wa*` rows (spawn/tick/terminal) on the SAME observer bg subagents use
162
+ * (RunnerDeps.onBackgroundChildEvent), immune to any run-leg forwarding freeze. Opt-in. */
68
163
  onBackgroundChildEvent?: (event: import("../core/types.js").BackgroundChildEvent) => void;
164
+ /** design/97 CORE-9 (Part B) — optional steerable-handle sink. When set, the script's `agent()` primitive runs
165
+ * each agent STEERABLE and emits its {@link WorkflowAgentHandle} here (the script never sees the handle); the
166
+ * deployment registers it by runId+label to route a human/cross-replica steer. Unset ⇒ non-steerable. Opt-in. */
69
167
  onAgentSpawn?: (handle: WorkflowAgentHandle) => void;
168
+ /** Tenant/grouping key for the run. */
70
169
  scope?: string;
170
+ /** Completion re-invoke seam. */
71
171
  notifier?: WorkflowCompletionNotifier;
172
+ /** The originating session id, threaded into every completion notify. */
72
173
  originatingSessionId?: string;
174
+ /** δ 批 codex D-1 — the ROOT host session of the delegation tree (prepare-task passes
175
+ * `internals?.rootSessionId ?? sessionId` per task). The AUTO-MOUNTED tool's execute ctx is the
176
+ * harness-native one (no internals enrichment — that wrapper covers spec.tools only), so the
177
+ * root MUST ride deps; `ctx.rootSessionId` stays first for a deployment-composed mount that
178
+ * does get the enriched ctx. */
73
179
  rootSessionId?: string;
180
+ /** Process-local unified task registry. When present, RunWorkflow returns `task_id === runId` with a `w*` id. */
74
181
  taskRegistry?: TaskRegistry;
182
+ /** design/115 P2 core slice: run-local task-notification sink for SDK event + live model XML injection. */
75
183
  taskNotification?: (notification: TaskNotificationPayload) => void;
184
+ /** Runner-owned owner fallback for registry access when the execute context is unavailable. */
76
185
  taskOwner?: string;
186
+ /** Hard ceilings. */
77
187
  limits?: WorkflowLimits;
188
+ /** B5/F2 (CC scriptPath/name surface): optional script-persistence seam. When wired, EVERY invocation's
189
+ * resolved script is persisted (best-effort) and its path returned in the tool result; `scriptPath`
190
+ * re-runs a persisted file and `name` resolves a saved workflow. Absent ⇒ inline `script` only. */
78
191
  scriptStore?: WorkflowScriptStore;
192
+ /** design/140 §6 1c — `false` removes the BUILT-IN named workflows (`team-discussion`, …) wholesale (the
193
+ * `builtinAgents:false` analog). Default ON: `{name}` resolves a built-in even with NO deployment script
194
+ * store; a deployment `scriptStore.resolveName` hit for the same name always SHADOWS the built-in. */
79
195
  builtinWorkflows?: boolean;
196
+ /** CC `workflowSizeGuideline` — advisory size guideline appended to the tool card.
197
+ * Direct-construction face; wins over `limits.sizeGuideline` (the RunnerDeps-reachable channel).
198
+ * See {@link WorkflowLimits.sizeGuideline}. */
80
199
  sizeGuideline?: WorkflowSizeGuideline;
200
+ /** The originating task id + principal, threaded to the notifier. */
81
201
  sourceTaskId?: string;
82
202
  principal?: string;
203
+ /** 黑板 [1909]⑧/[1910]/[1911] — mirrors {@link "../core/types.js".TaskSpec.oneShot}: this submission has
204
+ * no later turn for an async notification to land in. Branches the launch receipt's `note` guidance
205
+ * (see {@link createRunWorkflowTool}'s `note` composition) toward an active block-wait instead of
206
+ * "end your turn and wait" — the latter is actively wrong for a one-shot caller. */
83
207
  oneShot?: boolean;
208
+ /** design/173 §8.3 (r3-F1) — the HOST run's RESOLVED interaction posture, threaded as a MOUNT
209
+ * dep because prepare-task's auto-mount seals this tool without the rich-ctx wrapper (the same
210
+ * reason `forwardEvent`/`inheritedGateForChildren` ride deps); `ctx.interactionPosture` still
211
+ * wins when a wrapping path provides it. */
84
212
  parentInteractionPosture?: "interactive" | "headless";
213
+ /** TRUSTED nesting depth from the run's internals (NOT a tool param) — passed to `startWorkflow` so a
214
+ * cross-process child workflow is rejected by the one-level guard. */
85
215
  workflowDepth?: number;
216
+ /** The HOST task's effective working root — threaded into every spawned agent's trusted internals so a
217
+ * TOC env factory can root the child at the parent's cwd (CC parity, 2026-07-03). */
86
218
  parentCwd?: string;
219
+ /** Call-time getter for the HOST task's current thinking level — a spawned agent with no explicit
220
+ * script/baseline `thinking` inherits it (the parentCwd/model-snapshot companion). */
87
221
  parentThinking?: () => import("../core/types.js").TaskSpec["thinking"];
222
+ /** [1238](A) — call-time getter for the HOST task's RESOLVED Model object: a spawned agent whose
223
+ * fold chain produced no model inherits the parent's full object (baseUrl/key routing included),
224
+ * mirroring the subagent lane's ctx.model semantics. */
88
225
  parentModel?: () => import("../internal/llm.js").Model | undefined;
226
+ /** [1258] v2 — the HOST task's per-model auth hook ([893]④a): the CREDENTIAL half of model
227
+ * inheritance. The Model object fixed the URL routing but the child brain still authenticated
228
+ * with the boot env token (clay rerun: 7/7 kimi-route 401s with the qwen key). The subagent lane
229
+ * has inherited this hook since [893]④a; the workflow lane never did — the governance whitelist
230
+ * rightly blocks SCRIPTS from setting it, but host inheritance is a different lane. */
89
231
  parentGetApiKeyAndHeaders?: import("../core/types.js").TaskSpec["getApiKeyAndHeaders"];
232
+ /** The HOST run's display sink (its `RunInternals.onForwardEvent`, already filtered to `task_progress`
233
+ * by the runner's ctx wrapper) — threaded via `startWorkflow` into every spawned agent's trusted
234
+ * internals so a workflow child's progress ticks bubble to the deployment's one sink, the same
235
+ * channel a `createSubagentTool` delegation threads. Display-only; absent ⇒ ticks stay in each
236
+ * child's own stream. (A dep, not read off the execute ctx: the mounted tool's `AgentTool.execute`
237
+ * wrapper builds a minimal `{toolCallId, signal}` ctx — the rich-ctx injection only wraps
238
+ * `spec.tools`. `ctx.forwardEvent` still wins when a wrapping path provides it.) */
90
239
  forwardEvent?: (event: import("../core/types.js").TaskEvent) => void;
240
+ /** Parent effective-policy inheritance: the HOST task's `inheritedGateForChildren` chain accessor,
241
+ * called at LAUNCH time and threaded via `RunWorkflowOptions.inheritedGate` into every spawned agent's
242
+ * trusted internals — workflow children inherit the host's evaluated gate exactly like a
243
+ * `createSubagentTool` delegation. (A dep for the same reason as `forwardEvent`: the direct mount's
244
+ * execute ctx is minimal; `ctx.inheritedGateForChildren` still wins when a wrapping path provides it.) */
91
245
  inheritedGateForChildren?: () => import("../core/runner/prepare-task.js").InheritedGate;
246
+ /** RB-201 FO-3 — the HOST session's auto-mode classifier, threaded via `RunWorkflowOptions.autoModeReview`
247
+ * so every child this workflow spawns is reviewed before it starts, exactly like a `createSubagentTool`
248
+ * delegation's child. (A dep for the same reason as `forwardEvent`/`inheritedGateForChildren`: the direct
249
+ * mount's execute ctx is minimal; `ctx.autoModeReview` still wins when a wrapping path provides it.)
250
+ * A call-time getter, not a value — the decider is built during prepare and this dep is read at launch.
251
+ * Absent on both seats ⇒ auto-mode is not armed and the review legs are a complete no-op. */
92
252
  autoModeReview?: () => {
93
253
  decider: import("../core/auto-mode.js").AutoModeDecider;
94
254
  } | undefined;
95
255
  }
256
+ /**
257
+ * Build the `run_workflow` tool. ASSERTS the runner is a hard sandbox (defense in depth — prepare-task only
258
+ * mounts it under the same gate). Returns a structured error (not a throw) for an LLM-correctable problem
259
+ * (oversized / malformed-meta / nesting), so the model can fix and retry.
260
+ *
261
+ * Async since codex F3: the card's named-workflow roster is derived from the SAME sources the execute path
262
+ * resolves against (built-ins probed through `resolveName` shadowing + awaited `list()`), so the card can
263
+ * never advertise a workflow the call would resolve differently.
264
+ */
96
265
  export declare function createRunWorkflowTool(d: RunWorkflowToolDeps): Promise<AgentTool>;