@provos/ironcurtain 0.9.1 → 0.11.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 (502) hide show
  1. package/README.md +69 -10
  2. package/dist/auth/oauth-provider.js +1 -4
  3. package/dist/auth/oauth-provider.js.map +1 -1
  4. package/dist/cli.js +40 -2
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config/config-command.js +174 -10
  7. package/dist/config/config-command.js.map +1 -1
  8. package/dist/config/first-start.js +61 -0
  9. package/dist/config/first-start.js.map +1 -1
  10. package/dist/config/generated/compiled-policy.json +528 -161
  11. package/dist/config/generated/test-scenarios.json +4810 -170
  12. package/dist/config/generated/tool-annotations.json +34 -47
  13. package/dist/config/index.d.ts +58 -0
  14. package/dist/config/index.js +97 -15
  15. package/dist/config/index.js.map +1 -1
  16. package/dist/config/mcp-servers.json +2 -2
  17. package/dist/config/model-provider.d.ts +8 -2
  18. package/dist/config/model-provider.js +52 -9
  19. package/dist/config/model-provider.js.map +1 -1
  20. package/dist/config/paths.d.ts +181 -0
  21. package/dist/config/paths.js +326 -23
  22. package/dist/config/paths.js.map +1 -1
  23. package/dist/config/types.d.ts +7 -1
  24. package/dist/config/user-config.d.ts +61 -4
  25. package/dist/config/user-config.js +108 -21
  26. package/dist/config/user-config.js.map +1 -1
  27. package/dist/config/validate-policy-dir.d.ts +10 -0
  28. package/dist/config/validate-policy-dir.js +59 -0
  29. package/dist/config/validate-policy-dir.js.map +1 -0
  30. package/dist/cron/compile-task-policy.js +1 -0
  31. package/dist/cron/compile-task-policy.js.map +1 -1
  32. package/dist/cron/job-commands.js +22 -2
  33. package/dist/cron/job-commands.js.map +1 -1
  34. package/dist/cron/types.d.ts +16 -2
  35. package/dist/cron/types.js +1 -3
  36. package/dist/cron/types.js.map +1 -1
  37. package/dist/daemon/daemon-command.js +16 -2
  38. package/dist/daemon/daemon-command.js.map +1 -1
  39. package/dist/daemon/ironcurtain-daemon.d.ts +44 -1
  40. package/dist/daemon/ironcurtain-daemon.js +210 -8
  41. package/dist/daemon/ironcurtain-daemon.js.map +1 -1
  42. package/dist/docker/adapters/claude-code.d.ts +2 -1
  43. package/dist/docker/adapters/claude-code.js +320 -131
  44. package/dist/docker/adapters/claude-code.js.map +1 -1
  45. package/dist/docker/adapters/goose.d.ts +12 -11
  46. package/dist/docker/adapters/goose.js +80 -27
  47. package/dist/docker/adapters/goose.js.map +1 -1
  48. package/dist/docker/agent-adapter.d.ts +178 -4
  49. package/dist/docker/agent-adapter.js +14 -0
  50. package/dist/docker/agent-adapter.js.map +1 -1
  51. package/dist/docker/agent-registry.js +3 -2
  52. package/dist/docker/agent-registry.js.map +1 -1
  53. package/dist/docker/code-mode-proxy.d.ts +27 -0
  54. package/dist/docker/code-mode-proxy.js +3 -0
  55. package/dist/docker/code-mode-proxy.js.map +1 -1
  56. package/dist/docker/container-lifecycle.d.ts +15 -0
  57. package/dist/docker/container-lifecycle.js +32 -0
  58. package/dist/docker/container-lifecycle.js.map +1 -0
  59. package/dist/docker/docker-agent-session.d.ts +113 -62
  60. package/dist/docker/docker-agent-session.js +241 -300
  61. package/dist/docker/docker-agent-session.js.map +1 -1
  62. package/dist/docker/docker-infrastructure.d.ts +256 -21
  63. package/dist/docker/docker-infrastructure.js +585 -30
  64. package/dist/docker/docker-infrastructure.js.map +1 -1
  65. package/dist/docker/docker-manager.d.ts +36 -1
  66. package/dist/docker/docker-manager.js +168 -26
  67. package/dist/docker/docker-manager.js.map +1 -1
  68. package/dist/docker/docker-progress-sink.d.ts +43 -0
  69. package/dist/docker/docker-progress-sink.js +299 -0
  70. package/dist/docker/docker-progress-sink.js.map +1 -0
  71. package/dist/docker/mitm-proxy.d.ts +90 -1
  72. package/dist/docker/mitm-proxy.js +720 -40
  73. package/dist/docker/mitm-proxy.js.map +1 -1
  74. package/dist/docker/oauth-credentials.d.ts +46 -3
  75. package/dist/docker/oauth-credentials.js +56 -14
  76. package/dist/docker/oauth-credentials.js.map +1 -1
  77. package/dist/docker/oauth-token-manager.js +2 -2
  78. package/dist/docker/oauth-token-manager.js.map +1 -1
  79. package/dist/docker/orientation.d.ts +1 -1
  80. package/dist/docker/provider-config.d.ts +81 -2
  81. package/dist/docker/provider-config.js +222 -28
  82. package/dist/docker/provider-config.js.map +1 -1
  83. package/dist/docker/proxy-tools.d.ts +0 -2
  84. package/dist/docker/proxy-tools.js +2 -7
  85. package/dist/docker/proxy-tools.js.map +1 -1
  86. package/dist/docker/pty-session.d.ts +49 -1
  87. package/dist/docker/pty-session.js +212 -90
  88. package/dist/docker/pty-session.js.map +1 -1
  89. package/dist/docker/pty-types.d.ts +0 -2
  90. package/dist/docker/pty-types.js +0 -2
  91. package/dist/docker/pty-types.js.map +1 -1
  92. package/dist/docker/resource-limits.d.ts +125 -0
  93. package/dist/docker/resource-limits.js +200 -0
  94. package/dist/docker/resource-limits.js.map +1 -0
  95. package/dist/docker/spawn-with-idle-timeout.d.ts +39 -0
  96. package/dist/docker/spawn-with-idle-timeout.js +152 -0
  97. package/dist/docker/spawn-with-idle-timeout.js.map +1 -0
  98. package/dist/docker/sse-extractor.d.ts +51 -0
  99. package/dist/docker/sse-extractor.js +303 -0
  100. package/dist/docker/sse-extractor.js.map +1 -0
  101. package/dist/docker/token-stream-bus.d.ts +83 -0
  102. package/dist/docker/token-stream-bus.js +98 -0
  103. package/dist/docker/token-stream-bus.js.map +1 -0
  104. package/dist/docker/token-stream-types.d.ts +71 -0
  105. package/dist/docker/token-stream-types.js +8 -0
  106. package/dist/docker/token-stream-types.js.map +1 -0
  107. package/dist/docker/types.d.ts +61 -6
  108. package/dist/doctor/checks.d.ts +138 -0
  109. package/dist/doctor/checks.js +511 -0
  110. package/dist/doctor/checks.js.map +1 -0
  111. package/dist/doctor/doctor-command.d.ts +29 -0
  112. package/dist/doctor/doctor-command.js +160 -0
  113. package/dist/doctor/doctor-command.js.map +1 -0
  114. package/dist/doctor/mcp-liveness.d.ts +28 -0
  115. package/dist/doctor/mcp-liveness.js +84 -0
  116. package/dist/doctor/mcp-liveness.js.map +1 -0
  117. package/dist/doctor/oauth-checks.d.ts +23 -0
  118. package/dist/doctor/oauth-checks.js +157 -0
  119. package/dist/doctor/oauth-checks.js.map +1 -0
  120. package/dist/doctor/output.d.ts +26 -0
  121. package/dist/doctor/output.js +82 -0
  122. package/dist/doctor/output.js.map +1 -0
  123. package/dist/escalation/listener-command.js +0 -3
  124. package/dist/escalation/listener-command.js.map +1 -1
  125. package/dist/event-bus/typed-event-bus.d.ts +26 -0
  126. package/dist/event-bus/typed-event-bus.js +35 -0
  127. package/dist/event-bus/typed-event-bus.js.map +1 -0
  128. package/dist/index.js +32 -9
  129. package/dist/index.js.map +1 -1
  130. package/dist/logger.js +31 -2
  131. package/dist/logger.js.map +1 -1
  132. package/dist/memory/auto-save.d.ts +18 -4
  133. package/dist/memory/auto-save.js +46 -6
  134. package/dist/memory/auto-save.js.map +1 -1
  135. package/dist/memory/memory-policy.d.ts +41 -0
  136. package/dist/memory/memory-policy.js +36 -0
  137. package/dist/memory/memory-policy.js.map +1 -0
  138. package/dist/mux/mux-app.d.ts +2 -0
  139. package/dist/mux/mux-app.js +30 -34
  140. package/dist/mux/mux-app.js.map +1 -1
  141. package/dist/mux/mux-command.d.ts +10 -1
  142. package/dist/mux/mux-command.js +62 -35
  143. package/dist/mux/mux-command.js.map +1 -1
  144. package/dist/mux/mux-renderer.js +22 -17
  145. package/dist/mux/mux-renderer.js.map +1 -1
  146. package/dist/mux/pty-bridge.d.ts +2 -0
  147. package/dist/mux/pty-bridge.js +3 -0
  148. package/dist/mux/pty-bridge.js.map +1 -1
  149. package/dist/mux/session-scanner.d.ts +7 -0
  150. package/dist/mux/session-scanner.js +21 -2
  151. package/dist/mux/session-scanner.js.map +1 -1
  152. package/dist/mux/types.d.ts +0 -4
  153. package/dist/mux/types.js.map +1 -1
  154. package/dist/{pipeline → observability}/llm-logger.d.ts +9 -3
  155. package/dist/{pipeline → observability}/llm-logger.js +16 -4
  156. package/dist/observability/llm-logger.js.map +1 -0
  157. package/dist/observe/observe-command.d.ts +12 -0
  158. package/dist/observe/observe-command.js +298 -0
  159. package/dist/observe/observe-command.js.map +1 -0
  160. package/dist/observe/observe-renderer.d.ts +24 -0
  161. package/dist/observe/observe-renderer.js +87 -0
  162. package/dist/observe/observe-renderer.js.map +1 -0
  163. package/dist/observe/observe-tui-rain.d.ts +42 -0
  164. package/dist/observe/observe-tui-rain.js +531 -0
  165. package/dist/observe/observe-tui-rain.js.map +1 -0
  166. package/dist/observe/observe-tui-text-panel.d.ts +46 -0
  167. package/dist/observe/observe-tui-text-panel.js +525 -0
  168. package/dist/observe/observe-tui-text-panel.js.map +1 -0
  169. package/dist/observe/observe-tui-types.d.ts +270 -0
  170. package/dist/observe/observe-tui-types.js +200 -0
  171. package/dist/observe/observe-tui-types.js.map +1 -0
  172. package/dist/observe/observe-tui-word-scorer.d.ts +143 -0
  173. package/dist/observe/observe-tui-word-scorer.js +572 -0
  174. package/dist/observe/observe-tui-word-scorer.js.map +1 -0
  175. package/dist/observe/observe-tui.d.ts +59 -0
  176. package/dist/observe/observe-tui.js +592 -0
  177. package/dist/observe/observe-tui.js.map +1 -0
  178. package/dist/persona/compile-persona-policy.js +1 -0
  179. package/dist/persona/compile-persona-policy.js.map +1 -1
  180. package/dist/persona/memory-gate.d.ts +19 -0
  181. package/dist/persona/memory-gate.js +33 -0
  182. package/dist/persona/memory-gate.js.map +1 -0
  183. package/dist/persona/persona-command.js +41 -6
  184. package/dist/persona/persona-command.js.map +1 -1
  185. package/dist/persona/resolve.d.ts +22 -0
  186. package/dist/persona/resolve.js +45 -2
  187. package/dist/persona/resolve.js.map +1 -1
  188. package/dist/persona/types.d.ts +16 -0
  189. package/dist/pipeline/annotate.d.ts +7 -1
  190. package/dist/pipeline/annotate.js +92 -2
  191. package/dist/pipeline/annotate.js.map +1 -1
  192. package/dist/pipeline/compile.js +2 -0
  193. package/dist/pipeline/compile.js.map +1 -1
  194. package/dist/pipeline/constitution-compiler.d.ts +25 -14
  195. package/dist/pipeline/constitution-compiler.js +107 -38
  196. package/dist/pipeline/constitution-compiler.js.map +1 -1
  197. package/dist/pipeline/dynamic-list-types.d.ts +3 -6
  198. package/dist/pipeline/dynamic-list-types.js +3 -16
  199. package/dist/pipeline/dynamic-list-types.js.map +1 -1
  200. package/dist/pipeline/parallel-progress.d.ts +59 -0
  201. package/dist/pipeline/parallel-progress.js +263 -0
  202. package/dist/pipeline/parallel-progress.js.map +1 -0
  203. package/dist/pipeline/pipeline-runner.d.ts +49 -8
  204. package/dist/pipeline/pipeline-runner.js +419 -231
  205. package/dist/pipeline/pipeline-runner.js.map +1 -1
  206. package/dist/pipeline/pipeline-shared.d.ts +59 -1
  207. package/dist/pipeline/pipeline-shared.js +127 -12
  208. package/dist/pipeline/pipeline-shared.js.map +1 -1
  209. package/dist/pipeline/policy-verifier.js +16 -3
  210. package/dist/pipeline/policy-verifier.js.map +1 -1
  211. package/dist/pipeline/proxy-mcp-connections.js +17 -2
  212. package/dist/pipeline/proxy-mcp-connections.js.map +1 -1
  213. package/dist/pipeline/scenario-generator.d.ts +4 -8
  214. package/dist/pipeline/scenario-generator.js +13 -46
  215. package/dist/pipeline/scenario-generator.js.map +1 -1
  216. package/dist/pipeline/server-prefilter.d.ts +31 -0
  217. package/dist/pipeline/server-prefilter.js +115 -0
  218. package/dist/pipeline/server-prefilter.js.map +1 -0
  219. package/dist/pipeline/types.d.ts +5 -0
  220. package/dist/sandbox/index.d.ts +14 -0
  221. package/dist/sandbox/index.js +335 -116
  222. package/dist/sandbox/index.js.map +1 -1
  223. package/dist/sandbox/ironcurtain-protocol.d.ts +52 -0
  224. package/dist/sandbox/ironcurtain-protocol.js +185 -0
  225. package/dist/sandbox/ironcurtain-protocol.js.map +1 -0
  226. package/dist/session/agent-session.d.ts +6 -0
  227. package/dist/session/agent-session.js +16 -5
  228. package/dist/session/agent-session.js.map +1 -1
  229. package/dist/session/cli-transport.js +0 -6
  230. package/dist/session/cli-transport.js.map +1 -1
  231. package/dist/session/index.d.ts +35 -14
  232. package/dist/session/index.js +324 -130
  233. package/dist/session/index.js.map +1 -1
  234. package/dist/session/preflight.d.ts +50 -13
  235. package/dist/session/preflight.js +252 -80
  236. package/dist/session/preflight.js.map +1 -1
  237. package/dist/session/prompts.d.ts +2 -5
  238. package/dist/session/prompts.js.map +1 -1
  239. package/dist/session/session-manager.d.ts +61 -6
  240. package/dist/session/session-manager.js +72 -10
  241. package/dist/session/session-manager.js.map +1 -1
  242. package/dist/session/session-metadata.d.ts +21 -5
  243. package/dist/session/session-metadata.js +34 -12
  244. package/dist/session/session-metadata.js.map +1 -1
  245. package/dist/session/types.d.ts +311 -5
  246. package/dist/session/types.js +57 -1
  247. package/dist/session/types.js.map +1 -1
  248. package/dist/signal/setup-signal.js +13 -21
  249. package/dist/signal/setup-signal.js.map +1 -1
  250. package/dist/signal/signal-bot-daemon.d.ts +16 -1
  251. package/dist/signal/signal-bot-daemon.js +39 -27
  252. package/dist/signal/signal-bot-daemon.js.map +1 -1
  253. package/dist/signal/signal-container.js +7 -1
  254. package/dist/signal/signal-container.js.map +1 -1
  255. package/dist/skills/discovery.d.ts +77 -0
  256. package/dist/skills/discovery.js +206 -0
  257. package/dist/skills/discovery.js.map +1 -0
  258. package/dist/skills/index.d.ts +4 -0
  259. package/dist/skills/index.js +3 -0
  260. package/dist/skills/index.js.map +1 -0
  261. package/dist/skills/staging.d.ts +28 -0
  262. package/dist/skills/staging.js +68 -0
  263. package/dist/skills/staging.js.map +1 -0
  264. package/dist/skills/types.d.ts +46 -0
  265. package/dist/skills/types.js +2 -0
  266. package/dist/skills/types.js.map +1 -0
  267. package/dist/trusted-process/approval-whitelist.d.ts +0 -2
  268. package/dist/trusted-process/approval-whitelist.js +17 -17
  269. package/dist/trusted-process/approval-whitelist.js.map +1 -1
  270. package/dist/trusted-process/async-mutex.d.ts +32 -0
  271. package/dist/trusted-process/async-mutex.js +50 -0
  272. package/dist/trusted-process/async-mutex.js.map +1 -0
  273. package/dist/trusted-process/audit-log.d.ts +38 -1
  274. package/dist/trusted-process/audit-log.js +82 -13
  275. package/dist/trusted-process/audit-log.js.map +1 -1
  276. package/dist/trusted-process/call-circuit-breaker.js +2 -1
  277. package/dist/trusted-process/call-circuit-breaker.js.map +1 -1
  278. package/dist/trusted-process/control-server.d.ts +101 -0
  279. package/dist/trusted-process/control-server.js +282 -0
  280. package/dist/trusted-process/control-server.js.map +1 -0
  281. package/dist/trusted-process/domain-utils.d.ts +6 -6
  282. package/dist/trusted-process/domain-utils.js +7 -23
  283. package/dist/trusted-process/domain-utils.js.map +1 -1
  284. package/dist/trusted-process/error-prefixes.d.ts +16 -0
  285. package/dist/trusted-process/error-prefixes.js +17 -0
  286. package/dist/trusted-process/error-prefixes.js.map +1 -0
  287. package/dist/trusted-process/index.d.ts +40 -23
  288. package/dist/trusted-process/index.js +131 -225
  289. package/dist/trusted-process/index.js.map +1 -1
  290. package/dist/trusted-process/list-matcher.d.ts +17 -0
  291. package/dist/trusted-process/list-matcher.js +31 -0
  292. package/dist/trusted-process/list-matcher.js.map +1 -0
  293. package/dist/trusted-process/mcp-client-manager.d.ts +35 -6
  294. package/dist/trusted-process/mcp-client-manager.js +40 -45
  295. package/dist/trusted-process/mcp-client-manager.js.map +1 -1
  296. package/dist/trusted-process/mcp-proxy-server.d.ts +31 -120
  297. package/dist/trusted-process/mcp-proxy-server.js +166 -657
  298. package/dist/trusted-process/mcp-proxy-server.js.map +1 -1
  299. package/dist/trusted-process/policy-engine.d.ts +16 -4
  300. package/dist/trusted-process/policy-engine.js +90 -45
  301. package/dist/trusted-process/policy-engine.js.map +1 -1
  302. package/dist/trusted-process/policy-roots.d.ts +6 -0
  303. package/dist/trusted-process/policy-roots.js +20 -0
  304. package/dist/trusted-process/policy-roots.js.map +1 -1
  305. package/dist/trusted-process/sandbox-integration.d.ts +12 -0
  306. package/dist/trusted-process/sandbox-integration.js +26 -0
  307. package/dist/trusted-process/sandbox-integration.js.map +1 -1
  308. package/dist/trusted-process/tool-call-coordinator.d.ts +269 -0
  309. package/dist/trusted-process/tool-call-coordinator.js +508 -0
  310. package/dist/trusted-process/tool-call-coordinator.js.map +1 -0
  311. package/dist/trusted-process/tool-call-pipeline.d.ts +205 -0
  312. package/dist/trusted-process/tool-call-pipeline.js +798 -0
  313. package/dist/trusted-process/tool-call-pipeline.js.map +1 -0
  314. package/dist/trusted-process/tool-description-hints.d.ts +1 -1
  315. package/dist/types/argument-roles.d.ts +1 -1
  316. package/dist/types/argument-roles.js +14 -1
  317. package/dist/types/argument-roles.js.map +1 -1
  318. package/dist/types/audit.d.ts +9 -0
  319. package/dist/{session → types}/errors.d.ts +8 -2
  320. package/dist/{session → types}/errors.js +8 -2
  321. package/dist/types/errors.js.map +1 -0
  322. package/dist/types/reserved-servers.d.ts +11 -0
  323. package/dist/types/reserved-servers.js +12 -0
  324. package/dist/types/reserved-servers.js.map +1 -0
  325. package/dist/types/server-listing.d.ts +14 -0
  326. package/dist/types/server-listing.js +2 -0
  327. package/dist/types/server-listing.js.map +1 -0
  328. package/dist/types/slug.d.ts +2 -0
  329. package/dist/types/slug.js +2 -0
  330. package/dist/types/slug.js.map +1 -1
  331. package/dist/types/url-normalize.d.ts +16 -0
  332. package/dist/types/url-normalize.js +33 -0
  333. package/dist/types/url-normalize.js.map +1 -0
  334. package/dist/utils/error-message.d.ts +8 -0
  335. package/dist/utils/error-message.js +11 -0
  336. package/dist/utils/error-message.js.map +1 -0
  337. package/dist/utils/exec-error.d.ts +19 -0
  338. package/dist/utils/exec-error.js +16 -0
  339. package/dist/utils/exec-error.js.map +1 -0
  340. package/dist/utils/is-plain-object.d.ts +7 -0
  341. package/dist/utils/is-plain-object.js +12 -0
  342. package/dist/utils/is-plain-object.js.map +1 -0
  343. package/dist/utils/preflight-checks.d.ts +16 -0
  344. package/dist/utils/preflight-checks.js +178 -0
  345. package/dist/utils/preflight-checks.js.map +1 -0
  346. package/dist/web-ui/__tests__/json-rpc-dispatch.test.d.ts +7 -0
  347. package/dist/web-ui/__tests__/json-rpc-dispatch.test.js +725 -0
  348. package/dist/web-ui/__tests__/json-rpc-dispatch.test.js.map +1 -0
  349. package/dist/web-ui/dispatch/escalation-dispatch.d.ts +7 -0
  350. package/dist/web-ui/dispatch/escalation-dispatch.js +52 -0
  351. package/dist/web-ui/dispatch/escalation-dispatch.js.map +1 -0
  352. package/dist/web-ui/dispatch/job-dispatch.d.ts +8 -0
  353. package/dist/web-ui/dispatch/job-dispatch.js +83 -0
  354. package/dist/web-ui/dispatch/job-dispatch.js.map +1 -0
  355. package/dist/web-ui/dispatch/persona-dispatch.d.ts +6 -0
  356. package/dist/web-ui/dispatch/persona-dispatch.js +116 -0
  357. package/dist/web-ui/dispatch/persona-dispatch.js.map +1 -0
  358. package/dist/web-ui/dispatch/session-dispatch.d.ts +9 -0
  359. package/dist/web-ui/dispatch/session-dispatch.js +201 -0
  360. package/dist/web-ui/dispatch/session-dispatch.js.map +1 -0
  361. package/dist/web-ui/dispatch/token-stream-dispatch.d.ts +15 -0
  362. package/dist/web-ui/dispatch/token-stream-dispatch.js +55 -0
  363. package/dist/web-ui/dispatch/token-stream-dispatch.js.map +1 -0
  364. package/dist/web-ui/dispatch/types.d.ts +31 -0
  365. package/dist/web-ui/dispatch/types.js +68 -0
  366. package/dist/web-ui/dispatch/types.js.map +1 -0
  367. package/dist/web-ui/dispatch/workflow-dispatch.d.ts +103 -0
  368. package/dist/web-ui/dispatch/workflow-dispatch.js +925 -0
  369. package/dist/web-ui/dispatch/workflow-dispatch.js.map +1 -0
  370. package/dist/web-ui/json-rpc-dispatch.d.ts +12 -0
  371. package/dist/web-ui/json-rpc-dispatch.js +34 -0
  372. package/dist/web-ui/json-rpc-dispatch.js.map +1 -0
  373. package/dist/web-ui/state-graph.d.ts +13 -0
  374. package/dist/web-ui/state-graph.js +82 -0
  375. package/dist/web-ui/state-graph.js.map +1 -0
  376. package/dist/web-ui/token-stream-bridge.d.ts +76 -0
  377. package/dist/web-ui/token-stream-bridge.js +265 -0
  378. package/dist/web-ui/token-stream-bridge.js.map +1 -0
  379. package/dist/web-ui/web-event-bus.d.ts +152 -0
  380. package/dist/web-ui/web-event-bus.js +19 -0
  381. package/dist/web-ui/web-event-bus.js.map +1 -0
  382. package/dist/web-ui/web-session-transport.d.ts +31 -0
  383. package/dist/web-ui/web-session-transport.js +109 -0
  384. package/dist/web-ui/web-session-transport.js.map +1 -0
  385. package/dist/web-ui/web-ui-server.d.ts +76 -0
  386. package/dist/web-ui/web-ui-server.js +461 -0
  387. package/dist/web-ui/web-ui-server.js.map +1 -0
  388. package/dist/web-ui/web-ui-types.d.ts +290 -0
  389. package/dist/web-ui/web-ui-types.js +32 -0
  390. package/dist/web-ui/web-ui-types.js.map +1 -0
  391. package/dist/web-ui/ws-utils.d.ts +5 -0
  392. package/dist/web-ui/ws-utils.js +12 -0
  393. package/dist/web-ui/ws-utils.js.map +1 -0
  394. package/dist/web-ui-static/assets/index-BFO5z1js.js +76 -0
  395. package/dist/web-ui-static/assets/index-CCUwrkIL.css +1 -0
  396. package/dist/web-ui-static/assets/orbitron-latin-700-normal-4jsRXGGJ.woff2 +0 -0
  397. package/dist/web-ui-static/assets/orbitron-latin-700-normal-DmYOh-W9.woff +0 -0
  398. package/dist/web-ui-static/index.html +14 -0
  399. package/dist/workflow/artifacts.d.ts +59 -0
  400. package/dist/workflow/artifacts.js +188 -0
  401. package/dist/workflow/artifacts.js.map +1 -0
  402. package/dist/workflow/checkpoint-selection.d.ts +34 -0
  403. package/dist/workflow/checkpoint-selection.js +48 -0
  404. package/dist/workflow/checkpoint-selection.js.map +1 -0
  405. package/dist/workflow/checkpoint.d.ts +35 -0
  406. package/dist/workflow/checkpoint.js +84 -0
  407. package/dist/workflow/checkpoint.js.map +1 -0
  408. package/dist/workflow/cli-support.d.ts +92 -0
  409. package/dist/workflow/cli-support.js +423 -0
  410. package/dist/workflow/cli-support.js.map +1 -0
  411. package/dist/workflow/definition-loader.d.ts +32 -0
  412. package/dist/workflow/definition-loader.js +56 -0
  413. package/dist/workflow/definition-loader.js.map +1 -0
  414. package/dist/workflow/discovery.d.ts +78 -0
  415. package/dist/workflow/discovery.js +203 -0
  416. package/dist/workflow/discovery.js.map +1 -0
  417. package/dist/workflow/errors.d.ts +66 -0
  418. package/dist/workflow/errors.js +49 -0
  419. package/dist/workflow/errors.js.map +1 -0
  420. package/dist/workflow/guards.d.ts +8 -0
  421. package/dist/workflow/guards.js +38 -0
  422. package/dist/workflow/guards.js.map +1 -0
  423. package/dist/workflow/lint-integration.d.ts +64 -0
  424. package/dist/workflow/lint-integration.js +56 -0
  425. package/dist/workflow/lint-integration.js.map +1 -0
  426. package/dist/workflow/lint.d.ts +66 -0
  427. package/dist/workflow/lint.js +410 -0
  428. package/dist/workflow/lint.js.map +1 -0
  429. package/dist/workflow/machine-builder.d.ts +90 -0
  430. package/dist/workflow/machine-builder.js +485 -0
  431. package/dist/workflow/machine-builder.js.map +1 -0
  432. package/dist/workflow/message-log.d.ts +85 -0
  433. package/dist/workflow/message-log.js +40 -0
  434. package/dist/workflow/message-log.js.map +1 -0
  435. package/dist/workflow/orchestrator.d.ts +450 -0
  436. package/dist/workflow/orchestrator.js +1941 -0
  437. package/dist/workflow/orchestrator.js.map +1 -0
  438. package/dist/workflow/prompt-builder.d.ts +39 -0
  439. package/dist/workflow/prompt-builder.js +242 -0
  440. package/dist/workflow/prompt-builder.js.map +1 -0
  441. package/dist/workflow/run-state-command.d.ts +9 -0
  442. package/dist/workflow/run-state-command.js +414 -0
  443. package/dist/workflow/run-state-command.js.map +1 -0
  444. package/dist/workflow/run-state-debug-capture.d.ts +40 -0
  445. package/dist/workflow/run-state-debug-capture.js +101 -0
  446. package/dist/workflow/run-state-debug-capture.js.map +1 -0
  447. package/dist/workflow/status-parser.d.ts +68 -0
  448. package/dist/workflow/status-parser.js +259 -0
  449. package/dist/workflow/status-parser.js.map +1 -0
  450. package/dist/workflow/types.d.ts +498 -0
  451. package/dist/workflow/types.js +83 -0
  452. package/dist/workflow/types.js.map +1 -0
  453. package/dist/workflow/validate.d.ts +58 -0
  454. package/dist/workflow/validate.js +499 -0
  455. package/dist/workflow/validate.js.map +1 -0
  456. package/dist/workflow/workflow-command.d.ts +26 -0
  457. package/dist/workflow/workflow-command.js +648 -0
  458. package/dist/workflow/workflow-command.js.map +1 -0
  459. package/dist/workflow/workflow-discovery.d.ts +25 -0
  460. package/dist/workflow/workflow-discovery.js +100 -0
  461. package/dist/workflow/workflow-discovery.js.map +1 -0
  462. package/dist/workflow/workflow-manager.d.ts +122 -0
  463. package/dist/workflow/workflow-manager.js +308 -0
  464. package/dist/workflow/workflow-manager.js.map +1 -0
  465. package/dist/workflow/workflows/design-and-code/workflow.yaml +169 -0
  466. package/dist/workflow/workflows/test-email-summary/skills/email-formatting/SKILL.md +55 -0
  467. package/dist/workflow/workflows/test-email-summary/skills/gmail-query-syntax/SKILL.md +63 -0
  468. package/dist/workflow/workflows/test-email-summary/skills/json-schema-emails/SKILL.md +41 -0
  469. package/dist/workflow/workflows/test-email-summary/skills/json-schema-emails/schema.json +34 -0
  470. package/dist/workflow/workflows/test-email-summary/skills/summary-style-guide/SKILL.md +51 -0
  471. package/dist/workflow/workflows/test-email-summary/workflow.yaml +89 -0
  472. package/dist/workflow/workflows/vuln-discovery/skills/harness-design-fuzzing/SKILL.md +201 -0
  473. package/dist/workflow/workflows/vuln-discovery/skills/memory-safety-c-cpp/SKILL.md +166 -0
  474. package/dist/workflow/workflows/vuln-discovery/skills/vulnerability-triage/SKILL.md +185 -0
  475. package/dist/workflow/workflows/vuln-discovery/workflow.yaml +920 -0
  476. package/dist/workflow/worktree.d.ts +43 -0
  477. package/dist/workflow/worktree.js +106 -0
  478. package/dist/workflow/worktree.js.map +1 -0
  479. package/docker/Dockerfile.base +12 -1
  480. package/docker/Dockerfile.base.arm64 +17 -1
  481. package/docker/entrypoint-claude-code.sh +46 -0
  482. package/docker/entrypoint-goose.sh +25 -0
  483. package/package.json +22 -8
  484. package/packages/web-ui/README.md +113 -0
  485. package/packages/web-ui/docs/workflow-state-machine.png +0 -0
  486. package/src/config/generated/compiled-policy.json +528 -161
  487. package/src/config/generated/test-scenarios.json +4810 -170
  488. package/src/config/generated/tool-annotations.json +34 -47
  489. package/src/config/mcp-servers.json +2 -2
  490. package/src/workflow/workflows/design-and-code/workflow.yaml +169 -0
  491. package/src/workflow/workflows/test-email-summary/skills/email-formatting/SKILL.md +55 -0
  492. package/src/workflow/workflows/test-email-summary/skills/gmail-query-syntax/SKILL.md +63 -0
  493. package/src/workflow/workflows/test-email-summary/skills/json-schema-emails/SKILL.md +41 -0
  494. package/src/workflow/workflows/test-email-summary/skills/json-schema-emails/schema.json +34 -0
  495. package/src/workflow/workflows/test-email-summary/skills/summary-style-guide/SKILL.md +51 -0
  496. package/src/workflow/workflows/test-email-summary/workflow.yaml +89 -0
  497. package/src/workflow/workflows/vuln-discovery/skills/harness-design-fuzzing/SKILL.md +201 -0
  498. package/src/workflow/workflows/vuln-discovery/skills/memory-safety-c-cpp/SKILL.md +166 -0
  499. package/src/workflow/workflows/vuln-discovery/skills/vulnerability-triage/SKILL.md +185 -0
  500. package/src/workflow/workflows/vuln-discovery/workflow.yaml +920 -0
  501. package/dist/pipeline/llm-logger.js.map +0 -1
  502. package/dist/session/errors.js.map +0 -1
@@ -0,0 +1,498 @@
1
+ import type { AgentConversationId } from '../session/types.js';
2
+ /**
3
+ * Directory name for workflow artifacts inside the agent workspace.
4
+ * All artifact subdirectories (plan/, code/, reviews/, etc.) live under this.
5
+ */
6
+ export declare const WORKFLOW_ARTIFACT_DIR = ".workflow";
7
+ /**
8
+ * Reserved persona alias meaning "use the global policy".
9
+ * When a workflow state specifies this as its persona, the session
10
+ * factory strips the persona field (same as undefined), so the
11
+ * session uses the default global compiled policy and memory.
12
+ *
13
+ * Any other persona value is passed through to `createSession()`,
14
+ * which resolves it to a per-persona policy, memory, and prompt.
15
+ */
16
+ export declare const GLOBAL_PERSONA = "global";
17
+ /**
18
+ * Sentinel value for an agent state's `skills:` field meaning "no skills
19
+ * of any kind". Strictly stronger than `[]` (which still loads
20
+ * user-global + persona skills); this disables every layer.
21
+ */
22
+ export declare const SKILLS_NONE = "none";
23
+ /**
24
+ * Translate an agent state's `skills:` field into the subset of
25
+ * `WorkflowBorrowOptions` that controls skill resolution. `disableAllSkills`
26
+ * is mutually exclusive with `skillsDir` / `skillFilter`: when the sentinel
27
+ * is present, only `disableAllSkills: true` is set; otherwise `skillsDir`
28
+ * and `skillFilter` may co-occur. Used by both the orchestrator and the
29
+ * run-state CLI so the invariant lives in one place.
30
+ */
31
+ export declare function resolveWorkflowSkillsOptions(skills: readonly string[] | typeof SKILLS_NONE | undefined, skillsDir: string | undefined): {
32
+ skillsDir?: string;
33
+ skillFilter?: ReadonlySet<string>;
34
+ disableAllSkills?: true;
35
+ };
36
+ /**
37
+ * Default `containerScope` value assigned to agent states that do not
38
+ * declare one explicitly. Every such state shares the workflow's primary
39
+ * bundle. The orchestrator's scope-lookup path resolves
40
+ * `stateConfig.containerScope ?? DEFAULT_CONTAINER_SCOPE` before dispatch.
41
+ *
42
+ * Scope strings are opaque Map lookup keys — they are never embedded in
43
+ * filesystem paths (bundle directory names use the UUID `bundleId`).
44
+ *
45
+ * See `docs/designs/workflow-session-identity.md` §2.4 / §6.
46
+ */
47
+ export declare const DEFAULT_CONTAINER_SCOPE = "primary";
48
+ /**
49
+ * Unique identifier for a workflow instance. Branded to prevent accidental
50
+ * mixing with other string identifiers.
51
+ */
52
+ export type WorkflowId = string & {
53
+ readonly __brand: 'WorkflowId';
54
+ };
55
+ /** Creates a new unique WorkflowId. */
56
+ export declare function createWorkflowId(): WorkflowId;
57
+ export interface WorkflowDefinition {
58
+ readonly name: string;
59
+ readonly description: string;
60
+ readonly initial: string;
61
+ readonly states: Record<string, WorkflowStateDefinition>;
62
+ readonly settings?: WorkflowSettings;
63
+ }
64
+ export interface WorkflowSettings {
65
+ /** Session mode. Default: 'docker'. */
66
+ readonly mode?: 'docker' | 'builtin';
67
+ /** Agent ID for Docker mode. Default: 'claude-code'. */
68
+ readonly dockerAgent?: string;
69
+ /** Default max rounds for iterative loops. Default: 4. */
70
+ readonly maxRounds?: number;
71
+ /** Git repository path for worktree management. */
72
+ readonly gitRepoPath?: string;
73
+ /** Max parallel agent sessions. Default: 3. */
74
+ readonly maxParallelism?: number;
75
+ /**
76
+ * Optional system prompt text appended to the base system prompt
77
+ * for ALL agent states in this workflow. Use for workspace
78
+ * conventions, project-level context, or shared instructions.
79
+ * Sent via --append-system-prompt.
80
+ */
81
+ readonly systemPrompt?: string;
82
+ /**
83
+ * Per-turn wall-clock timeout in seconds for agent sessions.
84
+ * Overrides the global resourceBudget.maxSessionSeconds for this workflow.
85
+ * Default: uses the global setting (1800s / 30 minutes).
86
+ */
87
+ readonly maxSessionSeconds?: number;
88
+ /** Output artifact names excluded from versioning (e.g., append-only journals). */
89
+ readonly unversionedArtifacts?: readonly string[];
90
+ /**
91
+ * Default model ID for all agent states in this workflow.
92
+ * Format: "provider:model-name" (e.g., "anthropic:claude-sonnet-4-6").
93
+ * Can be overridden per state via `states.<name>.model`.
94
+ * Takes precedence over `agentModelId` from user config but is
95
+ * overridden by the `--model` CLI flag.
96
+ */
97
+ readonly model?: string;
98
+ /**
99
+ * When true, the workflow runs in shared-container mode: the engine
100
+ * creates one DockerInfrastructure bundle at workflow start and
101
+ * reuses it across all states. When false (default), each state
102
+ * gets a fresh container (today's behavior).
103
+ *
104
+ * Shared-container mode is the prerequisite for policy hot-swap at
105
+ * state transitions. See docs/designs/workflow-container-lifecycle.md.
106
+ *
107
+ * Ignored for builtin workflows (no Docker infrastructure to share).
108
+ */
109
+ readonly sharedContainer?: boolean;
110
+ }
111
+ /**
112
+ * State definition. Discriminated on `type`.
113
+ */
114
+ export type WorkflowStateDefinition = AgentStateDefinition | HumanGateStateDefinition | DeterministicStateDefinition | TerminalStateDefinition;
115
+ export interface AgentStateDefinition {
116
+ readonly type: 'agent';
117
+ readonly description: string;
118
+ readonly persona: string;
119
+ /**
120
+ * Role instructions for the agent. Embedded in the full prompt assembled
121
+ * by the orchestrator; see `buildFirstVisitPrompt` / `buildReVisitPrompt`
122
+ * in prompt-builder.ts for the section layout. The role prompt is
123
+ * positioned for recency bias on first visit; re-invocations reuse the
124
+ * conversation history via `--continue`.
125
+ */
126
+ readonly prompt: string;
127
+ /**
128
+ * Input artifact names assembled into the agent's command.
129
+ * Trailing `?` marks optional inputs (no error if absent).
130
+ */
131
+ readonly inputs: readonly string[];
132
+ /** Output artifact names the agent is expected to produce. */
133
+ readonly outputs: readonly string[];
134
+ /** Transitions evaluated in order; first match wins. */
135
+ readonly transitions: readonly AgentTransitionDefinition[];
136
+ /** When true, each parallel instance gets a dedicated git worktree. */
137
+ readonly worktree?: boolean;
138
+ /**
139
+ * When false, re-invocations of this state resume the previous agent
140
+ * session via --continue, receiving an abbreviated re-visit prompt.
141
+ * Use this for iterative refinement loops where the agent benefits
142
+ * from retaining its prior reasoning (e.g., harness design/build after
143
+ * critique feedback).
144
+ *
145
+ * Default: true (each invocation starts a fresh session, bootstrapping
146
+ * from artifacts on disk).
147
+ */
148
+ readonly freshSession?: boolean;
149
+ /**
150
+ * Per-state model override. Format: "provider:model-name".
151
+ * Takes precedence over `settings.model` at the workflow level.
152
+ * Overridden only by the `--model` CLI flag.
153
+ */
154
+ readonly model?: string;
155
+ /**
156
+ * Per-state visit cap. When set, the `isStateVisitLimitReached` guard
157
+ * returns true once `context.visitCounts[stateId] >= maxVisits`. Use
158
+ * this to bound an iterative loop (e.g., harness_design_review) and
159
+ * route to a human gate once the cap is reached. Independent of the
160
+ * workflow-level `maxRounds` setting.
161
+ *
162
+ * Because visit counts are incremented on state entry (before
163
+ * `invoke`), the guard fires on the onDone transitions of the Nth
164
+ * visit — i.e., after the Nth invocation completes.
165
+ */
166
+ readonly maxVisits?: number;
167
+ /**
168
+ * Container scope label. States sharing a scope share a bundle (one
169
+ * container, one coordinator, one audit log, one control socket);
170
+ * states with different scopes live in different bundles. When unset,
171
+ * defaults to `"primary"`, so every state lands on the workflow's
172
+ * primary bundle by default.
173
+ *
174
+ * Meaningful only under `sharedContainer: true`. Under
175
+ * `sharedContainer: false` (legacy default, one container per state)
176
+ * declaring a `containerScope` is a validation error — silent no-ops
177
+ * are footguns; we reject at validate.ts.
178
+ *
179
+ * Charset: `/^[a-zA-Z0-9_-]+$/`. Scope strings are opaque Map lookup
180
+ * keys — they are NEVER embedded in filesystem paths; the on-disk
181
+ * bundle directory name is the UUID `bundleId`, not the scope.
182
+ *
183
+ * See `docs/designs/workflow-session-identity.md` §2.4.
184
+ */
185
+ readonly containerScope?: string;
186
+ /**
187
+ * Per-state filter on workflow-package skills (`<workflow-pkg>/skills/`).
188
+ * When omitted (default), the state receives every workflow-package
189
+ * skill. When set to an array, only the named entries from the
190
+ * workflow package are layered in — referenced names that do not
191
+ * exist as `<workflow-pkg>/skills/<name>/SKILL.md` fail validation at
192
+ * workflow load. User-global skills always apply regardless of this
193
+ * field. The literal sentinel `'none'` is a true off-switch: no skills
194
+ * of any kind (workflow-package, user-global, or persona) are loaded
195
+ * for the state.
196
+ */
197
+ readonly skills?: readonly string[] | typeof SKILLS_NONE;
198
+ }
199
+ export interface HumanGateStateDefinition {
200
+ readonly type: 'human_gate';
201
+ readonly description: string;
202
+ /** Event types this gate accepts. Each maps to a HUMAN_* WorkflowEvent. */
203
+ readonly acceptedEvents: readonly HumanGateEventType[];
204
+ /** Artifact names to present to the human for review. */
205
+ readonly present?: readonly string[];
206
+ /**
207
+ * Transitions keyed by accepted event type.
208
+ * Each transition specifies which event triggers it and where to go.
209
+ */
210
+ readonly transitions: readonly HumanGateTransitionDefinition[];
211
+ }
212
+ export interface DeterministicStateDefinition {
213
+ readonly type: 'deterministic';
214
+ readonly description: string;
215
+ /**
216
+ * Commands to execute. Each command is an array of [binary, ...args].
217
+ * Never a shell string -- per CLAUDE.md safe coding rules.
218
+ */
219
+ readonly run: readonly (readonly string[])[];
220
+ readonly transitions: readonly AgentTransitionDefinition[];
221
+ }
222
+ export interface TerminalStateDefinition {
223
+ readonly type: 'terminal';
224
+ readonly description: string;
225
+ readonly outputs?: readonly string[];
226
+ readonly cleanup?: readonly (readonly string[])[];
227
+ }
228
+ /** Allowed value types in a `when` clause. Matches AgentOutput field types. */
229
+ export type WhenValue = string | number | boolean | null;
230
+ /**
231
+ * Per-key typed shape for `when` clauses. Using a mapped type here
232
+ * enforces compile-time validation of both key names (must be in
233
+ * AgentOutput) and value types (must match the field's type, e.g.
234
+ * `completed` must be boolean, `verdict` must be a valid union member).
235
+ *
236
+ * Prefer this type over `Readonly<Record<string, WhenValue>>` when
237
+ * writing workflow definitions in TypeScript.
238
+ */
239
+ export type WhenClause = {
240
+ readonly [K in keyof AgentOutput]?: AgentOutput[K];
241
+ };
242
+ /**
243
+ * Action executed on a transition, in addition to the default context
244
+ * update actions (updateContextFromAgentResult / ...). Discriminated on
245
+ * `type`. Implementations live in `machine-builder.ts` — this is a
246
+ * closed set, not an open extension point.
247
+ *
248
+ * Today there is only a single variant, but the discriminated-union
249
+ * shape is retained so new action types can be added without changing
250
+ * the surrounding shape of transition definitions.
251
+ */
252
+ export type WorkflowTransitionAction = {
253
+ readonly type: 'resetVisitCounts';
254
+ readonly stateIds: readonly string[];
255
+ };
256
+ export interface AgentTransitionDefinition {
257
+ readonly to: string;
258
+ /**
259
+ * Guard name matching a registered XState guard. No translation
260
+ * layer -- use names directly: isRoundLimitReached, isStalled, isPassed,
261
+ * isStateVisitLimitReached. For verdict-based routing, prefer `when`
262
+ * clauses instead. Mutually exclusive with `when`.
263
+ */
264
+ readonly guard?: string;
265
+ /**
266
+ * Declarative field-match condition on AgentOutput.
267
+ * Keys must be valid AgentOutput field names and values must match
268
+ * the field's type (enforced at compile time via the mapped type).
269
+ * All entries must match (AND semantics).
270
+ * Mutually exclusive with `guard`.
271
+ */
272
+ readonly when?: WhenClause;
273
+ /**
274
+ * Optional ordered list of actions to run on this transition, in
275
+ * addition to the default context-update action. Actions execute
276
+ * in the order listed.
277
+ */
278
+ readonly actions?: readonly WorkflowTransitionAction[];
279
+ }
280
+ export interface HumanGateTransitionDefinition {
281
+ readonly to: string;
282
+ /** The accepted event type that triggers this transition. */
283
+ readonly event: HumanGateEventType;
284
+ /**
285
+ * Optional ordered list of actions to run on this transition, in
286
+ * addition to the default gate context-update actions (storeHumanPrompt,
287
+ * clearError). Actions execute in the order listed.
288
+ */
289
+ readonly actions?: readonly WorkflowTransitionAction[];
290
+ }
291
+ export type HumanGateEventType = 'APPROVE' | 'FORCE_REVISION' | 'REPLAN' | 'ABORT';
292
+ export declare const CONFIDENCE_VALUES: readonly ["high", "medium", "low"];
293
+ export type Confidence = (typeof CONFIDENCE_VALUES)[number];
294
+ /** Structured output parsed from the agent's response text. */
295
+ export interface AgentOutput {
296
+ /**
297
+ * @deprecated Maintained for backward compatibility. Defaults to `true`
298
+ * at parse time. Workflows should use free-form `verdict` strings for
299
+ * routing decisions instead of relying on this boolean.
300
+ */
301
+ readonly completed: boolean;
302
+ /** Free-form verdict string. Well-known values: approved, rejected, blocked, spec_flaw. Workflows may define custom verdicts for direct routing. */
303
+ readonly verdict: string;
304
+ /**
305
+ * @deprecated Maintained for backward compatibility. Defaults to `'high'`
306
+ * at parse time. Should not be relied upon for routing decisions; use
307
+ * `verdict` and `notes` instead.
308
+ */
309
+ readonly confidence: Confidence;
310
+ /**
311
+ * @deprecated Maintained for backward compatibility. Defaults to `null`
312
+ * at parse time. Use `notes` for inter-agent context instead.
313
+ */
314
+ readonly escalation: string | null;
315
+ /**
316
+ * @deprecated Maintained for backward compatibility. Defaults to `null`
317
+ * at parse time. Should not be relied upon for routing decisions.
318
+ */
319
+ readonly testCount: number | null;
320
+ readonly notes: string | null;
321
+ }
322
+ /** Valid keys for `when` clauses. Must match AgentOutput field names. */
323
+ export declare const AGENT_OUTPUT_FIELDS: readonly ["completed", "verdict", "confidence", "escalation", "testCount", "notes"];
324
+ export type WorkflowEvent = {
325
+ readonly type: 'AGENT_COMPLETED';
326
+ readonly output: AgentOutput;
327
+ } | {
328
+ readonly type: 'VALIDATION_PASSED';
329
+ readonly testCount: number;
330
+ } | {
331
+ readonly type: 'VALIDATION_FAILED';
332
+ readonly errors: string;
333
+ } | {
334
+ readonly type: 'HUMAN_APPROVE';
335
+ readonly prompt?: string;
336
+ } | {
337
+ readonly type: 'HUMAN_FORCE_REVISION';
338
+ readonly prompt?: string;
339
+ } | {
340
+ readonly type: 'HUMAN_REPLAN';
341
+ readonly prompt?: string;
342
+ } | {
343
+ readonly type: 'HUMAN_ABORT';
344
+ } | {
345
+ readonly type: 'PARALLEL_ALL_COMPLETED';
346
+ readonly results: readonly ParallelSlotResult[];
347
+ } | {
348
+ readonly type: 'PARALLEL_SLOT_FAILED';
349
+ readonly key: string;
350
+ readonly error: string;
351
+ } | {
352
+ readonly type: 'MERGE_SUCCEEDED';
353
+ } | {
354
+ readonly type: 'MERGE_CONFLICT';
355
+ readonly conflictDetails: string;
356
+ };
357
+ export interface WorkflowContext {
358
+ readonly taskDescription: string;
359
+ readonly artifacts: Record<string, string>;
360
+ readonly round: number;
361
+ readonly maxRounds: number;
362
+ /** Per-role output hash for stall detection. */
363
+ readonly previousOutputHashes: Record<string, string>;
364
+ readonly previousTestCount: number | null;
365
+ readonly humanPrompt: string | null;
366
+ readonly reviewHistory: readonly string[];
367
+ readonly parallelResults: Record<string, ParallelSlotResult>;
368
+ readonly worktreeBranches: readonly string[];
369
+ readonly totalTokens: number;
370
+ readonly lastError: string | null;
371
+ /**
372
+ * Maps a stateId to the agent-CLI conversation id assigned on the last
373
+ * successful invocation of that state. Consumed by `freshSession: false`
374
+ * re-entries so the CLI can `--resume` the prior conversation.
375
+ *
376
+ * See `docs/designs/workflow-session-identity.md` §2.4.
377
+ */
378
+ readonly agentConversationsByState: Record<string, AgentConversationId>;
379
+ /**
380
+ * Response text from the last completed agent state, with the trailing
381
+ * `agent_status` YAML block stripped. Truncated at 32KB. Used as the
382
+ * "body" portion of the "Scoping from the previous agent" section in the
383
+ * next agent's prompt — carries the full directive, not just the summary.
384
+ */
385
+ readonly previousAgentOutput: string | null;
386
+ /**
387
+ * The `notes` field from the last agent's `agent_status` block. Rendered
388
+ * as the "Notes" sub-section under "Scoping from the previous agent".
389
+ * When the orchestrator writes a bare status block with no directive, this
390
+ * is often the only surviving scoping signal.
391
+ */
392
+ readonly previousAgentNotes: string | null;
393
+ /**
394
+ * The state name that produced `previousAgentOutput`. Used to
395
+ * label the output in the next agent's prompt.
396
+ */
397
+ readonly previousStateName: string | null;
398
+ /**
399
+ * Per-state visit counter. Maps state ID to the number of times
400
+ * that state has been entered. Used for first-visit vs re-visit
401
+ * prompt selection and per-state round limit checking.
402
+ */
403
+ readonly visitCounts: Readonly<Record<string, number>>;
404
+ }
405
+ export type WorkflowStatus = {
406
+ readonly phase: 'running';
407
+ readonly currentState: string;
408
+ readonly activeAgents: readonly AgentSlot[];
409
+ } | {
410
+ readonly phase: 'waiting_human';
411
+ readonly gate: HumanGateRequest;
412
+ } | {
413
+ readonly phase: 'completed';
414
+ readonly result: WorkflowResult;
415
+ } | {
416
+ readonly phase: 'failed';
417
+ readonly error: string;
418
+ readonly lastState: string;
419
+ } | {
420
+ readonly phase: 'aborted';
421
+ readonly reason: string;
422
+ };
423
+ export interface AgentSlot {
424
+ readonly stateId: string;
425
+ readonly persona: string;
426
+ }
427
+ export interface WorkflowResult {
428
+ readonly finalArtifacts: Record<string, string>;
429
+ }
430
+ export interface ParallelSlotResult {
431
+ readonly key: string;
432
+ readonly status: 'success' | 'failed';
433
+ readonly error?: string;
434
+ readonly worktreeBranch?: string;
435
+ }
436
+ export interface HumanGateRequest {
437
+ readonly gateId: string;
438
+ readonly workflowId: string;
439
+ readonly stateName: string;
440
+ readonly acceptedEvents: readonly HumanGateEventType[];
441
+ readonly presentedArtifacts: ReadonlyMap<string, string>;
442
+ readonly summary: string;
443
+ }
444
+ /**
445
+ * JSON-serializable view of HumanGateRequest. The domain type's
446
+ * `presentedArtifacts` is a `ReadonlyMap` which doesn't JSON-encode;
447
+ * the DTO replaces it with the artifact names as a plain array.
448
+ */
449
+ export interface HumanGateRequestDto {
450
+ readonly gateId: string;
451
+ readonly workflowId: string;
452
+ readonly stateName: string;
453
+ readonly acceptedEvents: readonly string[];
454
+ /** Artifact names only (not content). */
455
+ readonly presentedArtifacts: readonly string[];
456
+ readonly summary: string;
457
+ }
458
+ export declare function toHumanGateRequestDto(gate: HumanGateRequest): HumanGateRequestDto;
459
+ export interface HumanGateEvent {
460
+ readonly type: HumanGateEventType;
461
+ readonly prompt?: string;
462
+ }
463
+ export interface WorkflowCheckpoint {
464
+ /** Serialized XState snapshot.value (string or nested object). */
465
+ readonly machineState: unknown;
466
+ readonly context: WorkflowContext;
467
+ readonly timestamp: string;
468
+ readonly transitionHistory: readonly TransitionRecord[];
469
+ readonly definitionPath: string;
470
+ /** Workspace root directory. Used on resume to reconstruct artifactDir. */
471
+ readonly workspacePath?: string;
472
+ /**
473
+ * Per-run staged copy of the workflow package's `skills/` tree (when
474
+ * the package shipped one). The orchestrator copies this at start
475
+ * under `<baseDir>/<workflowId>/workflow-skills/` so the run is
476
+ * self-contained: resume reads from the staged copy regardless of
477
+ * whether the original package path is still on disk. Absent when
478
+ * the workflow ships no skills, and absent on legacy checkpoints
479
+ * written before this field existed (resume falls back to re-staging
480
+ * from `definitionPath`'s package dir).
481
+ */
482
+ readonly workflowSkillsDir?: string;
483
+ /**
484
+ * Terminal-phase status, populated only when the workflow has reached a terminal
485
+ * phase (completed / aborted / failed / waiting_human). Absent for mid-run
486
+ * checkpoints and for legacy retained checkpoints written before this field existed.
487
+ */
488
+ readonly finalStatus?: WorkflowStatus;
489
+ }
490
+ export interface TransitionRecord {
491
+ readonly from: string;
492
+ readonly to: string;
493
+ readonly event: string;
494
+ readonly timestamp: string;
495
+ readonly duration_ms: number;
496
+ /** Summary of the agent's output that produced this transition (if any). */
497
+ readonly agentMessage?: string;
498
+ }
@@ -0,0 +1,83 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ // ---------------------------------------------------------------------------
3
+ // Constants
4
+ // ---------------------------------------------------------------------------
5
+ /**
6
+ * Directory name for workflow artifacts inside the agent workspace.
7
+ * All artifact subdirectories (plan/, code/, reviews/, etc.) live under this.
8
+ */
9
+ export const WORKFLOW_ARTIFACT_DIR = '.workflow';
10
+ /**
11
+ * Reserved persona alias meaning "use the global policy".
12
+ * When a workflow state specifies this as its persona, the session
13
+ * factory strips the persona field (same as undefined), so the
14
+ * session uses the default global compiled policy and memory.
15
+ *
16
+ * Any other persona value is passed through to `createSession()`,
17
+ * which resolves it to a per-persona policy, memory, and prompt.
18
+ */
19
+ export const GLOBAL_PERSONA = 'global';
20
+ /**
21
+ * Sentinel value for an agent state's `skills:` field meaning "no skills
22
+ * of any kind". Strictly stronger than `[]` (which still loads
23
+ * user-global + persona skills); this disables every layer.
24
+ */
25
+ export const SKILLS_NONE = 'none';
26
+ /**
27
+ * Translate an agent state's `skills:` field into the subset of
28
+ * `WorkflowBorrowOptions` that controls skill resolution. `disableAllSkills`
29
+ * is mutually exclusive with `skillsDir` / `skillFilter`: when the sentinel
30
+ * is present, only `disableAllSkills: true` is set; otherwise `skillsDir`
31
+ * and `skillFilter` may co-occur. Used by both the orchestrator and the
32
+ * run-state CLI so the invariant lives in one place.
33
+ */
34
+ export function resolveWorkflowSkillsOptions(skills, skillsDir) {
35
+ if (skills === SKILLS_NONE)
36
+ return { disableAllSkills: true };
37
+ const result = {};
38
+ if (skillsDir !== undefined)
39
+ result.skillsDir = skillsDir;
40
+ if (Array.isArray(skills))
41
+ result.skillFilter = new Set(skills);
42
+ return result;
43
+ }
44
+ /**
45
+ * Default `containerScope` value assigned to agent states that do not
46
+ * declare one explicitly. Every such state shares the workflow's primary
47
+ * bundle. The orchestrator's scope-lookup path resolves
48
+ * `stateConfig.containerScope ?? DEFAULT_CONTAINER_SCOPE` before dispatch.
49
+ *
50
+ * Scope strings are opaque Map lookup keys — they are never embedded in
51
+ * filesystem paths (bundle directory names use the UUID `bundleId`).
52
+ *
53
+ * See `docs/designs/workflow-session-identity.md` §2.4 / §6.
54
+ */
55
+ export const DEFAULT_CONTAINER_SCOPE = 'primary';
56
+ /** Creates a new unique WorkflowId. */
57
+ export function createWorkflowId() {
58
+ return randomUUID();
59
+ }
60
+ // ---------------------------------------------------------------------------
61
+ // Agent output
62
+ // ---------------------------------------------------------------------------
63
+ export const CONFIDENCE_VALUES = ['high', 'medium', 'low'];
64
+ /** Valid keys for `when` clauses. Must match AgentOutput field names. */
65
+ export const AGENT_OUTPUT_FIELDS = [
66
+ 'completed',
67
+ 'verdict',
68
+ 'confidence',
69
+ 'escalation',
70
+ 'testCount',
71
+ 'notes',
72
+ ];
73
+ export function toHumanGateRequestDto(gate) {
74
+ return {
75
+ gateId: gate.gateId,
76
+ workflowId: gate.workflowId,
77
+ stateName: gate.stateName,
78
+ acceptedEvents: gate.acceptedEvents,
79
+ presentedArtifacts: Array.from(gate.presentedArtifacts.keys()),
80
+ summary: gate.summary,
81
+ };
82
+ }
83
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/workflow/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAA0D,EAC1D,SAA6B;IAM7B,IAAI,MAAM,KAAK,WAAW;QAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;IAC9D,MAAM,MAAM,GAA8D,EAAE,CAAC;IAC7E,IAAI,SAAS,KAAK,SAAS;QAAE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,MAAM,CAAC,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAChE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AAYjD,uCAAuC;AACvC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,UAAU,EAAgB,CAAC;AACpC,CAAC;AAoQD,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAgCpE,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW;IACX,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,OAAO;CAC0C,CAAC;AA+HpD,MAAM,UAAU,qBAAqB,CAAC,IAAsB;IAC1D,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAC9D,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { WorkflowDefinition, WorkflowStateDefinition } from './types.js';
2
+ export declare class WorkflowValidationError extends Error {
3
+ readonly issues: readonly string[];
4
+ constructor(issues: readonly string[]);
5
+ }
6
+ /**
7
+ * Parses a workflow input artifact reference. A trailing `?` marks the
8
+ * input as optional — the consumer may skip it if the artifact isn't
9
+ * produced.
10
+ */
11
+ export declare function parseArtifactRef(ref: string): {
12
+ readonly name: string;
13
+ readonly isOptional: boolean;
14
+ };
15
+ export declare function collectOutputArtifacts(states: Record<string, WorkflowStateDefinition>): Set<string>;
16
+ export declare function findReachableStates(initial: string, states: Record<string, WorkflowStateDefinition>): Set<string>;
17
+ /**
18
+ * One issue produced by {@link iterateSkillRefIssues}. Surface code
19
+ * (validate vs lint) formats the user-facing wording.
20
+ */
21
+ export type SkillRefIssue = {
22
+ kind: 'invalid-name';
23
+ stateId: string;
24
+ name: string;
25
+ detail: string;
26
+ } | {
27
+ kind: 'unknown-name';
28
+ stateId: string;
29
+ name: string;
30
+ };
31
+ /**
32
+ * Walks every agent state's `skills[]` and yields a structured issue
33
+ * per offending entry, classifying shape failures (`invalid-name`)
34
+ * separately from membership failures (`unknown-name`). Shape-first:
35
+ * an entry that fails the shape check is yielded as such and not
36
+ * checked for membership, which would otherwise emit a confusing
37
+ * "skill not found" message for inputs that were never valid names.
38
+ */
39
+ export declare function iterateSkillRefIssues(definition: WorkflowDefinition, discoveredNames: ReadonlySet<string>): Generator<SkillRefIssue>;
40
+ /**
41
+ * Verifies every `skills[]` entry on an agent state matches a SKILL.md
42
+ * frontmatter `name:` under `<packageDir>/skills/`. Membership is
43
+ * keyed on the frontmatter name (also what `workflowSkillFilter` in
44
+ * `src/skills/discovery.ts` matches), not the directory name —
45
+ * `existsSync` on the dir would miss dir-vs-frontmatter mismatches.
46
+ * Called from orchestrator `start()` only.
47
+ *
48
+ * @throws {WorkflowValidationError} when any entry is invalid or unknown
49
+ */
50
+ export declare function validateWorkflowSkillReferences(definition: WorkflowDefinition, packageDir: string): void;
51
+ /**
52
+ * Validates a parsed object as a WorkflowDefinition.
53
+ * Performs structural parsing (Zod) then semantic checks.
54
+ * The input can come from JSON.parse() or YAML.parse().
55
+ *
56
+ * @throws {WorkflowValidationError} with structured list of issues
57
+ */
58
+ export declare function validateDefinition(raw: unknown): WorkflowDefinition;