botmux 2.111.0 → 2.112.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 (1041) hide show
  1. package/README.en.md +19 -7
  2. package/README.md +19 -7
  3. package/dist/adapters/adopt-route.d.ts.map +1 -1
  4. package/dist/adapters/adopt-route.js +2 -1
  5. package/dist/adapters/adopt-route.js.map +1 -1
  6. package/dist/adapters/backend/herdr-backend.d.ts +29 -0
  7. package/dist/adapters/backend/herdr-backend.d.ts.map +1 -1
  8. package/dist/adapters/backend/herdr-backend.js +167 -0
  9. package/dist/adapters/backend/herdr-backend.js.map +1 -1
  10. package/dist/adapters/backend/riff-backend.js +2 -2
  11. package/dist/adapters/backend/sandbox.d.ts +61 -6
  12. package/dist/adapters/backend/sandbox.d.ts.map +1 -1
  13. package/dist/adapters/backend/sandbox.js +235 -43
  14. package/dist/adapters/backend/sandbox.js.map +1 -1
  15. package/dist/adapters/backend/tmux-backend.d.ts +1 -0
  16. package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
  17. package/dist/adapters/backend/tmux-backend.js +1 -0
  18. package/dist/adapters/backend/tmux-backend.js.map +1 -1
  19. package/dist/adapters/cli/claude-code.d.ts +2 -0
  20. package/dist/adapters/cli/claude-code.d.ts.map +1 -1
  21. package/dist/adapters/cli/claude-code.js +7 -0
  22. package/dist/adapters/cli/claude-code.js.map +1 -1
  23. package/dist/adapters/cli/codex-app-turn.d.ts +16 -0
  24. package/dist/adapters/cli/codex-app-turn.d.ts.map +1 -1
  25. package/dist/adapters/cli/codex-app-turn.js +26 -0
  26. package/dist/adapters/cli/codex-app-turn.js.map +1 -1
  27. package/dist/adapters/cli/codex.d.ts.map +1 -1
  28. package/dist/adapters/cli/codex.js +1 -0
  29. package/dist/adapters/cli/codex.js.map +1 -1
  30. package/dist/adapters/cli/grok.d.ts +8 -6
  31. package/dist/adapters/cli/grok.d.ts.map +1 -1
  32. package/dist/adapters/cli/grok.js +14 -6
  33. package/dist/adapters/cli/grok.js.map +1 -1
  34. package/dist/adapters/cli/read-isolation.d.ts +40 -14
  35. package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
  36. package/dist/adapters/cli/read-isolation.js +116 -19
  37. package/dist/adapters/cli/read-isolation.js.map +1 -1
  38. package/dist/adapters/cli/runner-control-channel.d.ts +32 -0
  39. package/dist/adapters/cli/runner-control-channel.d.ts.map +1 -0
  40. package/dist/adapters/cli/runner-control-channel.js +104 -0
  41. package/dist/adapters/cli/runner-control-channel.js.map +1 -0
  42. package/dist/adapters/cli/shared-hints.d.ts +1 -1
  43. package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
  44. package/dist/adapters/cli/shared-hints.js +9 -0
  45. package/dist/adapters/cli/shared-hints.js.map +1 -1
  46. package/dist/adapters/cli/traex.d.ts.map +1 -1
  47. package/dist/adapters/cli/traex.js +100 -64
  48. package/dist/adapters/cli/traex.js.map +1 -1
  49. package/dist/adapters/cli/types.d.ts +13 -0
  50. package/dist/adapters/cli/types.d.ts.map +1 -1
  51. package/dist/bot-registry.d.ts +36 -27
  52. package/dist/bot-registry.d.ts.map +1 -1
  53. package/dist/bot-registry.js +354 -8
  54. package/dist/bot-registry.js.map +1 -1
  55. package/dist/cli/saved-workflow.d.ts +25 -0
  56. package/dist/cli/saved-workflow.d.ts.map +1 -0
  57. package/dist/cli/saved-workflow.js +338 -0
  58. package/dist/cli/saved-workflow.js.map +1 -0
  59. package/dist/cli/send-dispatch.d.ts +18 -3
  60. package/dist/cli/send-dispatch.d.ts.map +1 -1
  61. package/dist/cli/send-dispatch.js +22 -3
  62. package/dist/cli/send-dispatch.js.map +1 -1
  63. package/dist/cli/v3-run-cancel.d.ts +47 -0
  64. package/dist/cli/v3-run-cancel.d.ts.map +1 -0
  65. package/dist/cli/v3-run-cancel.js +96 -0
  66. package/dist/cli/v3-run-cancel.js.map +1 -0
  67. package/dist/cli/vc-agent.d.ts.map +1 -1
  68. package/dist/cli/vc-agent.js +54 -1
  69. package/dist/cli/vc-agent.js.map +1 -1
  70. package/dist/cli/workflow-migration.d.ts +39 -0
  71. package/dist/cli/workflow-migration.d.ts.map +1 -0
  72. package/dist/cli/workflow-migration.js +302 -0
  73. package/dist/cli/workflow-migration.js.map +1 -0
  74. package/dist/cli/workflow-run-archive.d.ts +29 -0
  75. package/dist/cli/workflow-run-archive.d.ts.map +1 -0
  76. package/dist/cli/workflow-run-archive.js +183 -0
  77. package/dist/cli/workflow-run-archive.js.map +1 -0
  78. package/dist/cli/workflow.d.ts +5 -10
  79. package/dist/cli/workflow.d.ts.map +1 -1
  80. package/dist/cli/workflow.js +85 -764
  81. package/dist/cli/workflow.js.map +1 -1
  82. package/dist/cli.d.ts.map +1 -1
  83. package/dist/cli.js +1018 -191
  84. package/dist/cli.js.map +1 -1
  85. package/dist/codex-app-runner.js +30 -21
  86. package/dist/codex-app-runner.js.map +1 -1
  87. package/dist/core/command-handler.d.ts.map +1 -1
  88. package/dist/core/command-handler.js +21 -9
  89. package/dist/core/command-handler.js.map +1 -1
  90. package/dist/core/current-turn-provenance.d.ts +39 -0
  91. package/dist/core/current-turn-provenance.d.ts.map +1 -0
  92. package/dist/core/current-turn-provenance.js +122 -0
  93. package/dist/core/current-turn-provenance.js.map +1 -0
  94. package/dist/core/daemon-ipc-auth.d.ts +20 -0
  95. package/dist/core/daemon-ipc-auth.d.ts.map +1 -0
  96. package/dist/core/daemon-ipc-auth.js +44 -0
  97. package/dist/core/daemon-ipc-auth.js.map +1 -0
  98. package/dist/core/daemon-ipc-session-auth.d.ts +37 -0
  99. package/dist/core/daemon-ipc-session-auth.d.ts.map +1 -0
  100. package/dist/core/daemon-ipc-session-auth.js +35 -0
  101. package/dist/core/daemon-ipc-session-auth.js.map +1 -0
  102. package/dist/core/dashboard-command/index.d.ts +0 -2
  103. package/dist/core/dashboard-command/index.d.ts.map +1 -1
  104. package/dist/core/dashboard-command/index.js +2 -2
  105. package/dist/core/dashboard-command/index.js.map +1 -1
  106. package/dist/core/dashboard-command/stub.d.ts +1 -1
  107. package/dist/core/dashboard-command/stub.d.ts.map +1 -1
  108. package/dist/core/dashboard-command/stub.js +0 -1
  109. package/dist/core/dashboard-command/stub.js.map +1 -1
  110. package/dist/core/dashboard-ipc-server.d.ts +11 -2
  111. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  112. package/dist/core/dashboard-ipc-server.js +266 -41
  113. package/dist/core/dashboard-ipc-server.js.map +1 -1
  114. package/dist/core/dashboard-secret.d.ts +3 -0
  115. package/dist/core/dashboard-secret.d.ts.map +1 -0
  116. package/dist/core/dashboard-secret.js +7 -0
  117. package/dist/core/dashboard-secret.js.map +1 -0
  118. package/dist/core/data-dir.d.ts +24 -0
  119. package/dist/core/data-dir.d.ts.map +1 -0
  120. package/dist/core/data-dir.js +48 -0
  121. package/dist/core/data-dir.js.map +1 -0
  122. package/dist/core/inflight-input-tracker.d.ts +4 -2
  123. package/dist/core/inflight-input-tracker.d.ts.map +1 -1
  124. package/dist/core/inflight-input-tracker.js +6 -5
  125. package/dist/core/inflight-input-tracker.js.map +1 -1
  126. package/dist/core/inject-queue-policy.d.ts +70 -0
  127. package/dist/core/inject-queue-policy.d.ts.map +1 -0
  128. package/dist/core/inject-queue-policy.js +30 -0
  129. package/dist/core/inject-queue-policy.js.map +1 -0
  130. package/dist/core/maintenance.d.ts +1 -1
  131. package/dist/core/maintenance.d.ts.map +1 -1
  132. package/dist/core/maintenance.js +3 -2
  133. package/dist/core/maintenance.js.map +1 -1
  134. package/dist/core/managed-origin-capability.d.ts +30 -0
  135. package/dist/core/managed-origin-capability.d.ts.map +1 -0
  136. package/dist/core/managed-origin-capability.js +88 -0
  137. package/dist/core/managed-origin-capability.js.map +1 -0
  138. package/dist/core/role-library.d.ts +15 -0
  139. package/dist/core/role-library.d.ts.map +1 -0
  140. package/dist/core/role-library.js +75 -0
  141. package/dist/core/role-library.js.map +1 -0
  142. package/dist/core/session-cwd.d.ts +14 -0
  143. package/dist/core/session-cwd.d.ts.map +1 -0
  144. package/dist/core/session-cwd.js +17 -0
  145. package/dist/core/session-cwd.js.map +1 -0
  146. package/dist/core/session-manager.d.ts +4 -1
  147. package/dist/core/session-manager.d.ts.map +1 -1
  148. package/dist/core/session-manager.js +27 -8
  149. package/dist/core/session-manager.js.map +1 -1
  150. package/dist/core/session-marker.d.ts +22 -0
  151. package/dist/core/session-marker.d.ts.map +1 -1
  152. package/dist/core/session-marker.js +185 -20
  153. package/dist/core/session-marker.js.map +1 -1
  154. package/dist/core/slash-inject.d.ts +15 -0
  155. package/dist/core/slash-inject.d.ts.map +1 -0
  156. package/dist/core/slash-inject.js +25 -0
  157. package/dist/core/slash-inject.js.map +1 -0
  158. package/dist/core/terminal-url.d.ts +1 -0
  159. package/dist/core/terminal-url.d.ts.map +1 -1
  160. package/dist/core/terminal-url.js +14 -8
  161. package/dist/core/terminal-url.js.map +1 -1
  162. package/dist/core/terminal-write-auth.d.ts +26 -0
  163. package/dist/core/terminal-write-auth.d.ts.map +1 -1
  164. package/dist/core/terminal-write-auth.js +48 -3
  165. package/dist/core/terminal-write-auth.js.map +1 -1
  166. package/dist/core/trigger-session.d.ts +24 -1
  167. package/dist/core/trigger-session.d.ts.map +1 -1
  168. package/dist/core/trigger-session.js +106 -15
  169. package/dist/core/trigger-session.js.map +1 -1
  170. package/dist/core/types.d.ts +26 -1
  171. package/dist/core/types.d.ts.map +1 -1
  172. package/dist/core/types.js +10 -0
  173. package/dist/core/types.js.map +1 -1
  174. package/dist/core/worker-pool.d.ts +65 -2
  175. package/dist/core/worker-pool.d.ts.map +1 -1
  176. package/dist/core/worker-pool.js +459 -39
  177. package/dist/core/worker-pool.js.map +1 -1
  178. package/dist/daemon.d.ts +249 -8
  179. package/dist/daemon.d.ts.map +1 -1
  180. package/dist/daemon.js +7383 -1195
  181. package/dist/daemon.js.map +1 -1
  182. package/dist/dashboard/aggregator.d.ts +1 -1
  183. package/dist/dashboard/aggregator.d.ts.map +1 -1
  184. package/dist/dashboard/aggregator.js +2 -2
  185. package/dist/dashboard/aggregator.js.map +1 -1
  186. package/dist/dashboard/auth.d.ts +3 -8
  187. package/dist/dashboard/auth.d.ts.map +1 -1
  188. package/dist/dashboard/auth.js +63 -22
  189. package/dist/dashboard/auth.js.map +1 -1
  190. package/dist/dashboard/bot-onboarding.d.ts +5 -0
  191. package/dist/dashboard/bot-onboarding.d.ts.map +1 -1
  192. package/dist/dashboard/bot-onboarding.js +37 -0
  193. package/dist/dashboard/bot-onboarding.js.map +1 -1
  194. package/dist/dashboard/connector-api.d.ts.map +1 -1
  195. package/dist/dashboard/connector-api.js +42 -2
  196. package/dist/dashboard/connector-api.js.map +1 -1
  197. package/dist/dashboard/daemon-internal-api.d.ts +0 -2
  198. package/dist/dashboard/daemon-internal-api.d.ts.map +1 -1
  199. package/dist/dashboard/daemon-internal-api.js +26 -93
  200. package/dist/dashboard/daemon-internal-api.js.map +1 -1
  201. package/dist/dashboard/daemon-internal-client.d.ts.map +1 -1
  202. package/dist/dashboard/daemon-internal-client.js +2 -3
  203. package/dist/dashboard/daemon-internal-client.js.map +1 -1
  204. package/dist/dashboard/federation-api.js +1 -1
  205. package/dist/dashboard/federation-api.js.map +1 -1
  206. package/dist/dashboard/federation-spoke-api.js +1 -1
  207. package/dist/dashboard/federation-spoke-api.js.map +1 -1
  208. package/dist/dashboard/history-senders.d.ts +3 -0
  209. package/dist/dashboard/history-senders.d.ts.map +1 -1
  210. package/dist/dashboard/history-senders.js.map +1 -1
  211. package/dist/dashboard/http.d.ts +4 -0
  212. package/dist/dashboard/http.d.ts.map +1 -0
  213. package/dist/dashboard/http.js +6 -0
  214. package/dist/dashboard/http.js.map +1 -0
  215. package/dist/dashboard/registry.d.ts +4 -0
  216. package/dist/dashboard/registry.d.ts.map +1 -1
  217. package/dist/dashboard/registry.js.map +1 -1
  218. package/dist/dashboard/trigger-api.js +1 -1
  219. package/dist/dashboard/trigger-api.js.map +1 -1
  220. package/dist/dashboard/v3-runs-api.d.ts +13 -10
  221. package/dist/dashboard/v3-runs-api.d.ts.map +1 -1
  222. package/dist/dashboard/v3-runs-api.js +121 -4
  223. package/dist/dashboard/v3-runs-api.js.map +1 -1
  224. package/dist/dashboard/vc-consumer-profiles-api.d.ts +105 -0
  225. package/dist/dashboard/vc-consumer-profiles-api.d.ts.map +1 -0
  226. package/dist/dashboard/vc-consumer-profiles-api.js +312 -0
  227. package/dist/dashboard/vc-consumer-profiles-api.js.map +1 -0
  228. package/dist/dashboard/web/app.d.ts.map +1 -1
  229. package/dist/dashboard/web/app.js +7 -6
  230. package/dist/dashboard/web/app.js.map +1 -1
  231. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  232. package/dist/dashboard/web/bot-defaults-page.js +9 -14
  233. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  234. package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
  235. package/dist/dashboard/web/bot-onboarding.js +7 -3
  236. package/dist/dashboard/web/bot-onboarding.js.map +1 -1
  237. package/dist/dashboard/web/connectors-page.d.ts +5 -0
  238. package/dist/dashboard/web/connectors-page.d.ts.map +1 -1
  239. package/dist/dashboard/web/connectors-page.js +16 -12
  240. package/dist/dashboard/web/connectors-page.js.map +1 -1
  241. package/dist/dashboard/web/create-session-entry.d.ts +4 -0
  242. package/dist/dashboard/web/create-session-entry.d.ts.map +1 -0
  243. package/dist/dashboard/web/create-session-entry.js +17 -0
  244. package/dist/dashboard/web/create-session-entry.js.map +1 -0
  245. package/dist/dashboard/web/dashboard-components.d.ts +5 -0
  246. package/dist/dashboard/web/dashboard-components.d.ts.map +1 -1
  247. package/dist/dashboard/web/dashboard-components.js +29 -4
  248. package/dist/dashboard/web/dashboard-components.js.map +1 -1
  249. package/dist/dashboard/web/dashboard-routes.d.ts.map +1 -1
  250. package/dist/dashboard/web/dashboard-routes.js +0 -1
  251. package/dist/dashboard/web/dashboard-routes.js.map +1 -1
  252. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  253. package/dist/dashboard/web/i18n.js +192 -382
  254. package/dist/dashboard/web/i18n.js.map +1 -1
  255. package/dist/dashboard/web/preferences.d.ts +3 -0
  256. package/dist/dashboard/web/preferences.d.ts.map +1 -1
  257. package/dist/dashboard/web/preferences.js +18 -0
  258. package/dist/dashboard/web/preferences.js.map +1 -1
  259. package/dist/dashboard/web/schedules-page.d.ts.map +1 -1
  260. package/dist/dashboard/web/schedules-page.js +4 -1
  261. package/dist/dashboard/web/schedules-page.js.map +1 -1
  262. package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
  263. package/dist/dashboard/web/sessions-page.js +64 -18
  264. package/dist/dashboard/web/sessions-page.js.map +1 -1
  265. package/dist/dashboard/web/settings-page.d.ts.map +1 -1
  266. package/dist/dashboard/web/settings-page.js +2 -1
  267. package/dist/dashboard/web/settings-page.js.map +1 -1
  268. package/dist/dashboard/web/v3-api.d.ts +12 -2
  269. package/dist/dashboard/web/v3-api.d.ts.map +1 -1
  270. package/dist/dashboard/web/v3-api.js +34 -6
  271. package/dist/dashboard/web/v3-api.js.map +1 -1
  272. package/dist/dashboard/web/v3-components.d.ts +6 -0
  273. package/dist/dashboard/web/v3-components.d.ts.map +1 -1
  274. package/dist/dashboard/web/v3-components.js +66 -23
  275. package/dist/dashboard/web/v3-components.js.map +1 -1
  276. package/dist/dashboard/web/v3-model.js +1 -1
  277. package/dist/dashboard/web/v3-model.js.map +1 -1
  278. package/dist/dashboard/web/v3-terminal.js +2 -2
  279. package/dist/dashboard/web/v3-terminal.js.map +1 -1
  280. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts +19 -0
  281. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -0
  282. package/dist/dashboard/web/vc-consumer-profiles-section.js +382 -0
  283. package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -0
  284. package/dist/dashboard/webhook-routes.d.ts.map +1 -1
  285. package/dist/dashboard/webhook-routes.js +29 -6
  286. package/dist/dashboard/webhook-routes.js.map +1 -1
  287. package/dist/dashboard-web/app.js +1 -1
  288. package/dist/dashboard-web/chunks/bot-defaults-page-RYBL4ZYE.js +4 -0
  289. package/dist/dashboard-web/chunks/{chunk-OEJIT66L.js → chunk-CMDPZOPK.js} +1 -1
  290. package/dist/dashboard-web/chunks/chunk-I35DXGM4.js +1 -0
  291. package/dist/dashboard-web/chunks/chunk-NYZHARIU.js +47 -0
  292. package/dist/dashboard-web/chunks/chunk-SZOB6VK2.js +1 -0
  293. package/dist/dashboard-web/chunks/{chunk-YQFXGRSD.js → chunk-YBOHL7T7.js} +1 -1
  294. package/dist/dashboard-web/chunks/chunk-YWCPDL4S.js +1 -0
  295. package/dist/dashboard-web/chunks/connectors-page-DAMP7TTV.js +1 -0
  296. package/dist/dashboard-web/chunks/{groups-page-5AJPPJH2.js → groups-page-BPFA356N.js} +1 -1
  297. package/dist/dashboard-web/chunks/{insights-page-R3DFECX4.js → insights-page-SHOPHTWY.js} +1 -1
  298. package/dist/dashboard-web/chunks/{monitor-room-NLMKJLDY.js → monitor-room-PXPJGZCN.js} +1 -1
  299. package/dist/dashboard-web/chunks/{monitoring-page-EHSOX4GV.js → monitoring-page-4DF54M5Y.js} +1 -1
  300. package/dist/dashboard-web/chunks/{office-page-OXJKFJ4R.js → office-page-6OHU6KMZ.js} +1 -1
  301. package/dist/dashboard-web/chunks/{overview-page-GJHIVXJF.js → overview-page-IHIZ6F5M.js} +1 -1
  302. package/dist/dashboard-web/chunks/{roles-page-6ZODQISW.js → roles-page-JYTBYKEF.js} +1 -1
  303. package/dist/dashboard-web/chunks/{schedules-page-DAGMHVCH.js → schedules-page-WJ72T7KV.js} +1 -1
  304. package/dist/dashboard-web/chunks/sessions-page-QC56OIAI.js +3 -0
  305. package/dist/dashboard-web/chunks/settings-page-TCKWEXTN.js +2 -0
  306. package/dist/dashboard-web/chunks/{skills-page-J7EVUHXP.js → skills-page-RJJNIECW.js} +1 -1
  307. package/dist/dashboard-web/chunks/{team-federation-page-YM5JBIII.js → team-federation-page-ZMDX3E7K.js} +1 -1
  308. package/dist/dashboard-web/chunks/v3-page-VLLAUQ33.js +94 -0
  309. package/dist/dashboard-web/chunks/{whiteboards-page-75N2U6W4.js → whiteboards-page-NAO53CKM.js} +1 -1
  310. package/dist/dashboard-web/style.css +363 -274
  311. package/dist/dashboard.js +194 -78
  312. package/dist/dashboard.js.map +1 -1
  313. package/dist/global-config.d.ts +1 -1
  314. package/dist/i18n/en.d.ts.map +1 -1
  315. package/dist/i18n/en.js +12 -87
  316. package/dist/i18n/en.js.map +1 -1
  317. package/dist/i18n/zh.d.ts.map +1 -1
  318. package/dist/i18n/zh.js +12 -87
  319. package/dist/i18n/zh.js.map +1 -1
  320. package/dist/im/lark/brand-template.d.ts +15 -0
  321. package/dist/im/lark/brand-template.d.ts.map +1 -0
  322. package/dist/im/lark/brand-template.js +114 -0
  323. package/dist/im/lark/brand-template.js.map +1 -0
  324. package/dist/im/lark/card-handler.d.ts +6 -3
  325. package/dist/im/lark/card-handler.d.ts.map +1 -1
  326. package/dist/im/lark/card-handler.js +23 -39
  327. package/dist/im/lark/card-handler.js.map +1 -1
  328. package/dist/im/lark/client.d.ts +8 -2
  329. package/dist/im/lark/client.d.ts.map +1 -1
  330. package/dist/im/lark/client.js +33 -31
  331. package/dist/im/lark/client.js.map +1 -1
  332. package/dist/im/lark/doc-comment.d.ts +18 -0
  333. package/dist/im/lark/doc-comment.d.ts.map +1 -1
  334. package/dist/im/lark/doc-comment.js +119 -5
  335. package/dist/im/lark/doc-comment.js.map +1 -1
  336. package/dist/im/lark/event-dispatcher.d.ts +18 -2
  337. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  338. package/dist/im/lark/event-dispatcher.js +41 -19
  339. package/dist/im/lark/event-dispatcher.js.map +1 -1
  340. package/dist/im/lark/merge-forward.d.ts.map +1 -1
  341. package/dist/im/lark/merge-forward.js +7 -2
  342. package/dist/im/lark/merge-forward.js.map +1 -1
  343. package/dist/im/lark/message-parser.d.ts.map +1 -1
  344. package/dist/im/lark/message-parser.js +7 -0
  345. package/dist/im/lark/message-parser.js.map +1 -1
  346. package/dist/im/lark/overview-card.d.ts +1 -2
  347. package/dist/im/lark/overview-card.d.ts.map +1 -1
  348. package/dist/im/lark/overview-card.js +1 -48
  349. package/dist/im/lark/overview-card.js.map +1 -1
  350. package/dist/im/lark/v3-blocked-card-handler.d.ts.map +1 -1
  351. package/dist/im/lark/v3-blocked-card-handler.js +5 -5
  352. package/dist/im/lark/v3-blocked-card-handler.js.map +1 -1
  353. package/dist/im/lark/v3-blocked-card.d.ts +1 -0
  354. package/dist/im/lark/v3-blocked-card.d.ts.map +1 -1
  355. package/dist/im/lark/v3-blocked-card.js +19 -2
  356. package/dist/im/lark/v3-blocked-card.js.map +1 -1
  357. package/dist/im/lark/v3-distillation-card-handler.d.ts +12 -0
  358. package/dist/im/lark/v3-distillation-card-handler.d.ts.map +1 -0
  359. package/dist/im/lark/v3-distillation-card-handler.js +107 -0
  360. package/dist/im/lark/v3-distillation-card-handler.js.map +1 -0
  361. package/dist/im/lark/v3-distillation-card.d.ts +42 -0
  362. package/dist/im/lark/v3-distillation-card.d.ts.map +1 -0
  363. package/dist/im/lark/v3-distillation-card.js +206 -0
  364. package/dist/im/lark/v3-distillation-card.js.map +1 -0
  365. package/dist/im/lark/v3-gate-card-handler.d.ts +1 -1
  366. package/dist/im/lark/v3-gate-card-handler.d.ts.map +1 -1
  367. package/dist/im/lark/v3-gate-card-handler.js +6 -5
  368. package/dist/im/lark/v3-gate-card-handler.js.map +1 -1
  369. package/dist/im/lark/v3-gate-card.d.ts +8 -1
  370. package/dist/im/lark/v3-gate-card.d.ts.map +1 -1
  371. package/dist/im/lark/v3-gate-card.js +38 -7
  372. package/dist/im/lark/v3-gate-card.js.map +1 -1
  373. package/dist/im/lark/v3-loop-grant-card-handler.d.ts.map +1 -1
  374. package/dist/im/lark/v3-loop-grant-card-handler.js +3 -4
  375. package/dist/im/lark/v3-loop-grant-card-handler.js.map +1 -1
  376. package/dist/im/lark/v3-loop-grant-card.js +1 -1
  377. package/dist/im/lark/v3-loop-grant-card.js.map +1 -1
  378. package/dist/im/lark/v3-progress-card-manager.d.ts +79 -0
  379. package/dist/im/lark/v3-progress-card-manager.d.ts.map +1 -0
  380. package/dist/im/lark/v3-progress-card-manager.js +444 -0
  381. package/dist/im/lark/v3-progress-card-manager.js.map +1 -0
  382. package/dist/im/lark/v3-progress-card.d.ts +26 -0
  383. package/dist/im/lark/v3-progress-card.d.ts.map +1 -0
  384. package/dist/im/lark/v3-progress-card.js +211 -0
  385. package/dist/im/lark/v3-progress-card.js.map +1 -0
  386. package/dist/im/lark/v3-revisit-grant-card-handler.d.ts.map +1 -1
  387. package/dist/im/lark/v3-revisit-grant-card-handler.js +3 -4
  388. package/dist/im/lark/v3-revisit-grant-card-handler.js.map +1 -1
  389. package/dist/im/lark/v3-revisit-grant-card.js +1 -1
  390. package/dist/im/lark/v3-revisit-grant-card.js.map +1 -1
  391. package/dist/im/lark/v3-run-save-card-handler.d.ts +12 -0
  392. package/dist/im/lark/v3-run-save-card-handler.d.ts.map +1 -0
  393. package/dist/im/lark/v3-run-save-card-handler.js +160 -0
  394. package/dist/im/lark/v3-run-save-card-handler.js.map +1 -0
  395. package/dist/im/lark/v3-run-save-card.d.ts +38 -0
  396. package/dist/im/lark/v3-run-save-card.d.ts.map +1 -0
  397. package/dist/im/lark/v3-run-save-card.js +125 -0
  398. package/dist/im/lark/v3-run-save-card.js.map +1 -0
  399. package/dist/im/lark/v3-saved-workflow-command.d.ts +36 -0
  400. package/dist/im/lark/v3-saved-workflow-command.d.ts.map +1 -0
  401. package/dist/im/lark/v3-saved-workflow-command.js +186 -0
  402. package/dist/im/lark/v3-saved-workflow-command.js.map +1 -0
  403. package/dist/im/lark/v3-saved-workflow-handler.d.ts +89 -0
  404. package/dist/im/lark/v3-saved-workflow-handler.d.ts.map +1 -0
  405. package/dist/im/lark/v3-saved-workflow-handler.js +212 -0
  406. package/dist/im/lark/v3-saved-workflow-handler.js.map +1 -0
  407. package/dist/im/lark/workflow-slash-command.d.ts +7 -110
  408. package/dist/im/lark/workflow-slash-command.d.ts.map +1 -1
  409. package/dist/im/lark/workflow-slash-command.js +16 -230
  410. package/dist/im/lark/workflow-slash-command.js.map +1 -1
  411. package/dist/index-daemon.js +1 -1
  412. package/dist/index-daemon.js.map +1 -1
  413. package/dist/mir-runner.js +11 -15
  414. package/dist/mir-runner.js.map +1 -1
  415. package/dist/mira-runner.js +8 -12
  416. package/dist/mira-runner.js.map +1 -1
  417. package/dist/services/bridge-turn-queue.d.ts +29 -12
  418. package/dist/services/bridge-turn-queue.d.ts.map +1 -1
  419. package/dist/services/bridge-turn-queue.js +59 -23
  420. package/dist/services/bridge-turn-queue.js.map +1 -1
  421. package/dist/services/claude-transcript.d.ts +15 -0
  422. package/dist/services/claude-transcript.d.ts.map +1 -1
  423. package/dist/services/claude-transcript.js +24 -0
  424. package/dist/services/claude-transcript.js.map +1 -1
  425. package/dist/services/codex-bridge-queue.d.ts +13 -2
  426. package/dist/services/codex-bridge-queue.d.ts.map +1 -1
  427. package/dist/services/codex-bridge-queue.js +20 -3
  428. package/dist/services/codex-bridge-queue.js.map +1 -1
  429. package/dist/services/codex-transcript.d.ts +6 -0
  430. package/dist/services/codex-transcript.d.ts.map +1 -1
  431. package/dist/services/codex-transcript.js.map +1 -1
  432. package/dist/services/grok-transcript.d.ts +3 -2
  433. package/dist/services/grok-transcript.d.ts.map +1 -1
  434. package/dist/services/grok-transcript.js +73 -22
  435. package/dist/services/grok-transcript.js.map +1 -1
  436. package/dist/services/hook-runner.d.ts.map +1 -1
  437. package/dist/services/hook-runner.js +26 -3
  438. package/dist/services/hook-runner.js.map +1 -1
  439. package/dist/services/schedule-store.d.ts +37 -0
  440. package/dist/services/schedule-store.d.ts.map +1 -1
  441. package/dist/services/schedule-store.js +259 -141
  442. package/dist/services/schedule-store.js.map +1 -1
  443. package/dist/services/send-policy.d.ts +50 -0
  444. package/dist/services/send-policy.d.ts.map +1 -1
  445. package/dist/services/send-policy.js +65 -0
  446. package/dist/services/send-policy.js.map +1 -1
  447. package/dist/services/session-lifecycle-hooks.d.ts.map +1 -1
  448. package/dist/services/session-lifecycle-hooks.js +12 -0
  449. package/dist/services/session-lifecycle-hooks.js.map +1 -1
  450. package/dist/services/traex-transcript.d.ts +11 -2
  451. package/dist/services/traex-transcript.d.ts.map +1 -1
  452. package/dist/services/traex-transcript.js +142 -8
  453. package/dist/services/traex-transcript.js.map +1 -1
  454. package/dist/services/trigger-types.d.ts +6 -1
  455. package/dist/services/trigger-types.d.ts.map +1 -1
  456. package/dist/services/trigger-types.js.map +1 -1
  457. package/dist/services/turn-terminal-deduper.d.ts +14 -0
  458. package/dist/services/turn-terminal-deduper.d.ts.map +1 -0
  459. package/dist/services/turn-terminal-deduper.js +34 -0
  460. package/dist/services/turn-terminal-deduper.js.map +1 -0
  461. package/dist/services/vc-meeting-action-gate.d.ts +246 -0
  462. package/dist/services/vc-meeting-action-gate.d.ts.map +1 -0
  463. package/dist/services/vc-meeting-action-gate.js +756 -0
  464. package/dist/services/vc-meeting-action-gate.js.map +1 -0
  465. package/dist/services/vc-meeting-action-store.d.ts +222 -0
  466. package/dist/services/vc-meeting-action-store.d.ts.map +1 -0
  467. package/dist/services/vc-meeting-action-store.js +806 -0
  468. package/dist/services/vc-meeting-action-store.js.map +1 -0
  469. package/dist/services/vc-meeting-consumer-isolation.d.ts +27 -0
  470. package/dist/services/vc-meeting-consumer-isolation.d.ts.map +1 -0
  471. package/dist/services/vc-meeting-consumer-isolation.js +37 -0
  472. package/dist/services/vc-meeting-consumer-isolation.js.map +1 -0
  473. package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts +72 -0
  474. package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts.map +1 -0
  475. package/dist/services/vc-meeting-consumer-profile-bootstrap.js +343 -0
  476. package/dist/services/vc-meeting-consumer-profile-bootstrap.js.map +1 -0
  477. package/dist/services/vc-meeting-consumer-profile-store.d.ts +39 -0
  478. package/dist/services/vc-meeting-consumer-profile-store.d.ts.map +1 -0
  479. package/dist/services/vc-meeting-consumer-profile-store.js +190 -0
  480. package/dist/services/vc-meeting-consumer-profile-store.js.map +1 -0
  481. package/dist/services/vc-meeting-daemon-auth.d.ts +29 -0
  482. package/dist/services/vc-meeting-daemon-auth.d.ts.map +1 -0
  483. package/dist/services/vc-meeting-daemon-auth.js +117 -0
  484. package/dist/services/vc-meeting-daemon-auth.js.map +1 -0
  485. package/dist/services/vc-meeting-delivery-feed.d.ts +52 -0
  486. package/dist/services/vc-meeting-delivery-feed.d.ts.map +1 -0
  487. package/dist/services/vc-meeting-delivery-feed.js +231 -0
  488. package/dist/services/vc-meeting-delivery-feed.js.map +1 -0
  489. package/dist/services/vc-meeting-delivery-hub-store.d.ts +213 -0
  490. package/dist/services/vc-meeting-delivery-hub-store.d.ts.map +1 -0
  491. package/dist/services/vc-meeting-delivery-hub-store.js +1230 -0
  492. package/dist/services/vc-meeting-delivery-hub-store.js.map +1 -0
  493. package/dist/services/vc-meeting-delivery-protocol.d.ts +159 -0
  494. package/dist/services/vc-meeting-delivery-protocol.d.ts.map +1 -0
  495. package/dist/services/vc-meeting-delivery-protocol.js +443 -0
  496. package/dist/services/vc-meeting-delivery-protocol.js.map +1 -0
  497. package/dist/services/vc-meeting-delivery-receiver.d.ts +80 -0
  498. package/dist/services/vc-meeting-delivery-receiver.d.ts.map +1 -0
  499. package/dist/services/vc-meeting-delivery-receiver.js +543 -0
  500. package/dist/services/vc-meeting-delivery-receiver.js.map +1 -0
  501. package/dist/services/vc-meeting-delivery-store.d.ts +339 -0
  502. package/dist/services/vc-meeting-delivery-store.d.ts.map +1 -0
  503. package/dist/services/vc-meeting-delivery-store.js +1024 -0
  504. package/dist/services/vc-meeting-delivery-store.js.map +1 -0
  505. package/dist/services/vc-meeting-feed-metadata-store.d.ts +58 -0
  506. package/dist/services/vc-meeting-feed-metadata-store.d.ts.map +1 -0
  507. package/dist/services/vc-meeting-feed-metadata-store.js +356 -0
  508. package/dist/services/vc-meeting-feed-metadata-store.js.map +1 -0
  509. package/dist/services/vc-meeting-im-reply.d.ts +55 -0
  510. package/dist/services/vc-meeting-im-reply.d.ts.map +1 -0
  511. package/dist/services/vc-meeting-im-reply.js +279 -0
  512. package/dist/services/vc-meeting-im-reply.js.map +1 -0
  513. package/dist/services/vc-meeting-im-routing.d.ts +131 -0
  514. package/dist/services/vc-meeting-im-routing.d.ts.map +1 -0
  515. package/dist/services/vc-meeting-im-routing.js +449 -0
  516. package/dist/services/vc-meeting-im-routing.js.map +1 -0
  517. package/dist/services/vc-meeting-listener-message-store.d.ts +23 -0
  518. package/dist/services/vc-meeting-listener-message-store.d.ts.map +1 -0
  519. package/dist/services/vc-meeting-listener-message-store.js +142 -0
  520. package/dist/services/vc-meeting-listener-message-store.js.map +1 -0
  521. package/dist/services/vc-meeting-member-policy.d.ts +37 -0
  522. package/dist/services/vc-meeting-member-policy.d.ts.map +1 -0
  523. package/dist/services/vc-meeting-member-policy.js +102 -0
  524. package/dist/services/vc-meeting-member-policy.js.map +1 -0
  525. package/dist/services/vc-meeting-profile-instructions.d.ts +22 -0
  526. package/dist/services/vc-meeting-profile-instructions.d.ts.map +1 -0
  527. package/dist/services/vc-meeting-profile-instructions.js +64 -0
  528. package/dist/services/vc-meeting-profile-instructions.js.map +1 -0
  529. package/dist/services/vc-meeting-runtime-store.d.ts +63 -0
  530. package/dist/services/vc-meeting-runtime-store.d.ts.map +1 -1
  531. package/dist/services/vc-meeting-runtime-store.js +605 -116
  532. package/dist/services/vc-meeting-runtime-store.js.map +1 -1
  533. package/dist/services/vc-meeting-send-policy.d.ts +89 -0
  534. package/dist/services/vc-meeting-send-policy.d.ts.map +1 -0
  535. package/dist/services/vc-meeting-send-policy.js +150 -0
  536. package/dist/services/vc-meeting-send-policy.js.map +1 -0
  537. package/dist/services/vc-meeting-terminal-reconciler.d.ts +93 -0
  538. package/dist/services/vc-meeting-terminal-reconciler.d.ts.map +1 -0
  539. package/dist/services/vc-meeting-terminal-reconciler.js +198 -0
  540. package/dist/services/vc-meeting-terminal-reconciler.js.map +1 -0
  541. package/dist/setup/open-platform-automation.d.ts +2 -0
  542. package/dist/setup/open-platform-automation.d.ts.map +1 -1
  543. package/dist/setup/open-platform-automation.js +1 -0
  544. package/dist/setup/open-platform-automation.js.map +1 -1
  545. package/dist/setup/open-platform-outcome.d.ts +50 -0
  546. package/dist/setup/open-platform-outcome.d.ts.map +1 -0
  547. package/dist/setup/open-platform-outcome.js +56 -0
  548. package/dist/setup/open-platform-outcome.js.map +1 -0
  549. package/dist/setup/setup-args.d.ts +7 -2
  550. package/dist/setup/setup-args.d.ts.map +1 -1
  551. package/dist/setup/setup-args.js +21 -5
  552. package/dist/setup/setup-args.js.map +1 -1
  553. package/dist/skills/definitions.d.ts.map +1 -1
  554. package/dist/skills/definitions.js +66 -54
  555. package/dist/skills/definitions.js.map +1 -1
  556. package/dist/skills/injection-mode.d.ts +5 -4
  557. package/dist/skills/injection-mode.d.ts.map +1 -1
  558. package/dist/skills/injection-mode.js +19 -10
  559. package/dist/skills/injection-mode.js.map +1 -1
  560. package/dist/types.d.ts +187 -0
  561. package/dist/types.d.ts.map +1 -1
  562. package/dist/utils/canonical-input-hash.d.ts +5 -0
  563. package/dist/utils/canonical-input-hash.d.ts.map +1 -0
  564. package/dist/utils/canonical-input-hash.js +43 -0
  565. package/dist/utils/canonical-input-hash.js.map +1 -0
  566. package/dist/utils/canonical-json.d.ts +10 -0
  567. package/dist/utils/canonical-json.d.ts.map +1 -0
  568. package/dist/utils/canonical-json.js +23 -0
  569. package/dist/utils/canonical-json.js.map +1 -0
  570. package/dist/utils/child-env.d.ts +1 -1
  571. package/dist/utils/child-env.d.ts.map +1 -1
  572. package/dist/utils/child-env.js +8 -0
  573. package/dist/utils/child-env.js.map +1 -1
  574. package/dist/utils/daemon-discovery.d.ts +4 -0
  575. package/dist/utils/daemon-discovery.d.ts.map +1 -1
  576. package/dist/utils/daemon-discovery.js +12 -6
  577. package/dist/utils/daemon-discovery.js.map +1 -1
  578. package/dist/utils/file-lock.d.ts.map +1 -1
  579. package/dist/utils/file-lock.js +696 -102
  580. package/dist/utils/file-lock.js.map +1 -1
  581. package/dist/utils/fs-durability.d.ts +20 -0
  582. package/dist/utils/fs-durability.d.ts.map +1 -0
  583. package/dist/utils/fs-durability.js +84 -0
  584. package/dist/utils/fs-durability.js.map +1 -0
  585. package/dist/utils/global-install.d.ts +5 -2
  586. package/dist/utils/global-install.d.ts.map +1 -1
  587. package/dist/utils/global-install.js +22 -4
  588. package/dist/utils/global-install.js.map +1 -1
  589. package/dist/utils/herdr-web-history.d.ts +12 -0
  590. package/dist/utils/herdr-web-history.d.ts.map +1 -0
  591. package/dist/utils/herdr-web-history.js +74 -0
  592. package/dist/utils/herdr-web-history.js.map +1 -0
  593. package/dist/utils/herdr-web-terminal-binding.d.ts +39 -0
  594. package/dist/utils/herdr-web-terminal-binding.d.ts.map +1 -0
  595. package/dist/utils/herdr-web-terminal-binding.js +56 -0
  596. package/dist/utils/herdr-web-terminal-binding.js.map +1 -0
  597. package/dist/utils/pending-input-queue.d.ts +30 -1
  598. package/dist/utils/pending-input-queue.d.ts.map +1 -1
  599. package/dist/utils/pending-input-queue.js +45 -5
  600. package/dist/utils/pending-input-queue.js.map +1 -1
  601. package/dist/vc-agent/cards.d.ts +49 -4
  602. package/dist/vc-agent/cards.d.ts.map +1 -1
  603. package/dist/vc-agent/cards.js +460 -70
  604. package/dist/vc-agent/cards.js.map +1 -1
  605. package/dist/vc-agent/polling-source.d.ts +6 -1
  606. package/dist/vc-agent/polling-source.d.ts.map +1 -1
  607. package/dist/vc-agent/polling-source.js +17 -4
  608. package/dist/vc-agent/polling-source.js.map +1 -1
  609. package/dist/worker.js +1333 -283
  610. package/dist/worker.js.map +1 -1
  611. package/dist/workflows/definition.d.ts +28 -35
  612. package/dist/workflows/definition.d.ts.map +1 -1
  613. package/dist/workflows/definition.js +7 -24
  614. package/dist/workflows/definition.js.map +1 -1
  615. package/dist/workflows/events/payloads.d.ts +28 -28
  616. package/dist/workflows/events/replay.d.ts +5 -0
  617. package/dist/workflows/events/replay.d.ts.map +1 -1
  618. package/dist/workflows/events/replay.js +6 -1
  619. package/dist/workflows/events/replay.js.map +1 -1
  620. package/dist/workflows/events/schema.d.ts +663 -663
  621. package/dist/workflows/events/schema.d.ts.map +1 -1
  622. package/dist/workflows/events/schema.js +1 -4
  623. package/dist/workflows/events/schema.js.map +1 -1
  624. package/dist/workflows/hostExecutors/botmux-schedule.d.ts +5 -4
  625. package/dist/workflows/hostExecutors/botmux-schedule.d.ts.map +1 -1
  626. package/dist/workflows/hostExecutors/botmux-schedule.js +80 -35
  627. package/dist/workflows/hostExecutors/botmux-schedule.js.map +1 -1
  628. package/dist/workflows/hostExecutors/feishu-im.d.ts +3 -3
  629. package/dist/workflows/hostExecutors/feishu-im.d.ts.map +1 -1
  630. package/dist/workflows/hostExecutors/feishu-im.js +3 -3
  631. package/dist/workflows/hostExecutors/feishu-im.js.map +1 -1
  632. package/dist/workflows/hostExecutors/feishu-reply.d.ts +1 -1
  633. package/dist/workflows/hostExecutors/feishu-reply.d.ts.map +1 -1
  634. package/dist/workflows/hostExecutors/feishu-reply.js +1 -1
  635. package/dist/workflows/hostExecutors/feishu-reply.js.map +1 -1
  636. package/dist/workflows/hostExecutors/feishu-send.d.ts +1 -1
  637. package/dist/workflows/hostExecutors/feishu-send.d.ts.map +1 -1
  638. package/dist/workflows/hostExecutors/feishu-send.js +1 -1
  639. package/dist/workflows/hostExecutors/feishu-send.js.map +1 -1
  640. package/dist/workflows/hostExecutors/index.d.ts +0 -1
  641. package/dist/workflows/hostExecutors/index.d.ts.map +1 -1
  642. package/dist/workflows/hostExecutors/index.js +0 -1
  643. package/dist/workflows/hostExecutors/index.js.map +1 -1
  644. package/dist/workflows/hostExecutors/registry.d.ts +1 -1
  645. package/dist/workflows/hostExecutors/registry.d.ts.map +1 -1
  646. package/dist/workflows/hostExecutors/types.d.ts +21 -29
  647. package/dist/workflows/hostExecutors/types.d.ts.map +1 -1
  648. package/dist/workflows/migration/v2-definition-paths.d.ts +3 -0
  649. package/dist/workflows/migration/v2-definition-paths.d.ts.map +1 -0
  650. package/dist/workflows/migration/v2-definition-paths.js +10 -0
  651. package/dist/workflows/migration/v2-definition-paths.js.map +1 -0
  652. package/dist/workflows/migration/v2-ledger.d.ts +138 -0
  653. package/dist/workflows/migration/v2-ledger.d.ts.map +1 -0
  654. package/dist/workflows/migration/v2-ledger.js +599 -0
  655. package/dist/workflows/migration/v2-ledger.js.map +1 -0
  656. package/dist/workflows/migration/v2-migration-service.d.ts +40 -0
  657. package/dist/workflows/migration/v2-migration-service.d.ts.map +1 -0
  658. package/dist/workflows/migration/v2-migration-service.js +454 -0
  659. package/dist/workflows/migration/v2-migration-service.js.map +1 -0
  660. package/dist/workflows/migration/v2-read-only-ids.d.ts +7 -0
  661. package/dist/workflows/migration/v2-read-only-ids.d.ts.map +1 -0
  662. package/dist/workflows/migration/v2-read-only-ids.js +9 -0
  663. package/dist/workflows/migration/v2-read-only-ids.js.map +1 -0
  664. package/dist/workflows/migration/v2-run-archive-schema.d.ts +976 -0
  665. package/dist/workflows/migration/v2-run-archive-schema.d.ts.map +1 -0
  666. package/dist/workflows/migration/v2-run-archive-schema.js +113 -0
  667. package/dist/workflows/migration/v2-run-archive-schema.js.map +1 -0
  668. package/dist/workflows/migration/v2-run-archive.d.ts +92 -0
  669. package/dist/workflows/migration/v2-run-archive.d.ts.map +1 -0
  670. package/dist/workflows/migration/v2-run-archive.js +1220 -0
  671. package/dist/workflows/migration/v2-run-archive.js.map +1 -0
  672. package/dist/workflows/migration/v2-scanner.d.ts +22 -0
  673. package/dist/workflows/migration/v2-scanner.d.ts.map +1 -0
  674. package/dist/workflows/migration/v2-scanner.js +114 -0
  675. package/dist/workflows/migration/v2-scanner.js.map +1 -0
  676. package/dist/workflows/migration/v2-to-v3.d.ts +32 -0
  677. package/dist/workflows/migration/v2-to-v3.d.ts.map +1 -0
  678. package/dist/workflows/migration/v2-to-v3.js +494 -0
  679. package/dist/workflows/migration/v2-to-v3.js.map +1 -0
  680. package/dist/workflows/ops-projection.d.ts.map +1 -1
  681. package/dist/workflows/ops-projection.js +4 -3
  682. package/dist/workflows/ops-projection.js.map +1 -1
  683. package/dist/workflows/shared/idempotency-key.d.ts +19 -0
  684. package/dist/workflows/shared/idempotency-key.d.ts.map +1 -0
  685. package/dist/workflows/shared/idempotency-key.js +23 -0
  686. package/dist/workflows/shared/idempotency-key.js.map +1 -0
  687. package/dist/workflows/{params.d.ts → shared/params.d.ts} +42 -6
  688. package/dist/workflows/shared/params.d.ts.map +1 -0
  689. package/dist/workflows/{params.js → shared/params.js} +91 -4
  690. package/dist/workflows/shared/params.js.map +1 -0
  691. package/dist/workflows/shared/provider-reconciler.d.ts +47 -0
  692. package/dist/workflows/shared/provider-reconciler.d.ts.map +1 -0
  693. package/dist/workflows/shared/provider-reconciler.js +17 -0
  694. package/dist/workflows/shared/provider-reconciler.js.map +1 -0
  695. package/dist/workflows/{spawn-policy.d.ts → shared/sandbox-policy.d.ts} +2 -2
  696. package/dist/workflows/shared/sandbox-policy.d.ts.map +1 -0
  697. package/dist/workflows/{spawn-policy.js → shared/sandbox-policy.js} +1 -1
  698. package/dist/workflows/shared/sandbox-policy.js.map +1 -0
  699. package/dist/workflows/shared/worker-process.d.ts +29 -0
  700. package/dist/workflows/shared/worker-process.d.ts.map +1 -0
  701. package/dist/workflows/shared/worker-process.js +56 -0
  702. package/dist/workflows/shared/worker-process.js.map +1 -0
  703. package/dist/workflows/v3/architect.d.ts.map +1 -1
  704. package/dist/workflows/v3/architect.js +16 -4
  705. package/dist/workflows/v3/architect.js.map +1 -1
  706. package/dist/workflows/v3/attempt-ledger.d.ts +23 -0
  707. package/dist/workflows/v3/attempt-ledger.d.ts.map +1 -0
  708. package/dist/workflows/v3/attempt-ledger.js +74 -0
  709. package/dist/workflows/v3/attempt-ledger.js.map +1 -0
  710. package/dist/workflows/v3/bot-resolve.d.ts +19 -1
  711. package/dist/workflows/v3/bot-resolve.d.ts.map +1 -1
  712. package/dist/workflows/v3/bot-resolve.js +129 -3
  713. package/dist/workflows/v3/bot-resolve.js.map +1 -1
  714. package/dist/workflows/v3/cli-daemon-command-authority.d.ts +59 -0
  715. package/dist/workflows/v3/cli-daemon-command-authority.d.ts.map +1 -0
  716. package/dist/workflows/v3/cli-daemon-command-authority.js +175 -0
  717. package/dist/workflows/v3/cli-daemon-command-authority.js.map +1 -0
  718. package/dist/workflows/v3/cli-run.d.ts +27 -0
  719. package/dist/workflows/v3/cli-run.d.ts.map +1 -1
  720. package/dist/workflows/v3/cli-run.js +113 -29
  721. package/dist/workflows/v3/cli-run.js.map +1 -1
  722. package/dist/workflows/v3/contract.d.ts +16 -16
  723. package/dist/workflows/v3/contract.d.ts.map +1 -1
  724. package/dist/workflows/v3/contract.js +15 -11
  725. package/dist/workflows/v3/contract.js.map +1 -1
  726. package/dist/workflows/v3/daemon-ipc-auth.d.ts +113 -0
  727. package/dist/workflows/v3/daemon-ipc-auth.d.ts.map +1 -0
  728. package/dist/workflows/v3/daemon-ipc-auth.js +294 -0
  729. package/dist/workflows/v3/daemon-ipc-auth.js.map +1 -0
  730. package/dist/workflows/v3/daemon-ipc-body.d.ts +30 -0
  731. package/dist/workflows/v3/daemon-ipc-body.d.ts.map +1 -0
  732. package/dist/workflows/v3/daemon-ipc-body.js +65 -0
  733. package/dist/workflows/v3/daemon-ipc-body.js.map +1 -0
  734. package/dist/workflows/v3/daemon-ipc-client.d.ts +32 -0
  735. package/dist/workflows/v3/daemon-ipc-client.d.ts.map +1 -0
  736. package/dist/workflows/v3/daemon-ipc-client.js +74 -0
  737. package/dist/workflows/v3/daemon-ipc-client.js.map +1 -0
  738. package/dist/workflows/v3/daemon-run.d.ts +87 -2
  739. package/dist/workflows/v3/daemon-run.d.ts.map +1 -1
  740. package/dist/workflows/v3/daemon-run.js +863 -68
  741. package/dist/workflows/v3/daemon-run.js.map +1 -1
  742. package/dist/workflows/v3/dag.d.ts +22 -8
  743. package/dist/workflows/v3/dag.d.ts.map +1 -1
  744. package/dist/workflows/v3/dag.js +214 -22
  745. package/dist/workflows/v3/dag.js.map +1 -1
  746. package/dist/workflows/v3/distillation-compiler.d.ts +36 -0
  747. package/dist/workflows/v3/distillation-compiler.d.ts.map +1 -0
  748. package/dist/workflows/v3/distillation-compiler.js +704 -0
  749. package/dist/workflows/v3/distillation-compiler.js.map +1 -0
  750. package/dist/workflows/v3/distillation-private-root.d.ts +10 -0
  751. package/dist/workflows/v3/distillation-private-root.d.ts.map +1 -0
  752. package/dist/workflows/v3/distillation-private-root.js +34 -0
  753. package/dist/workflows/v3/distillation-private-root.js.map +1 -0
  754. package/dist/workflows/v3/distillation-runner.d.ts +64 -0
  755. package/dist/workflows/v3/distillation-runner.d.ts.map +1 -0
  756. package/dist/workflows/v3/distillation-runner.js +1028 -0
  757. package/dist/workflows/v3/distillation-runner.js.map +1 -0
  758. package/dist/workflows/v3/distillation-schema.d.ts +63 -0
  759. package/dist/workflows/v3/distillation-schema.d.ts.map +1 -0
  760. package/dist/workflows/v3/distillation-schema.js +184 -0
  761. package/dist/workflows/v3/distillation-schema.js.map +1 -0
  762. package/dist/workflows/v3/distillation-service.d.ts +78 -0
  763. package/dist/workflows/v3/distillation-service.d.ts.map +1 -0
  764. package/dist/workflows/v3/distillation-service.js +416 -0
  765. package/dist/workflows/v3/distillation-service.js.map +1 -0
  766. package/dist/workflows/v3/distillation-source.d.ts +35 -0
  767. package/dist/workflows/v3/distillation-source.d.ts.map +1 -0
  768. package/dist/workflows/v3/distillation-source.js +118 -0
  769. package/dist/workflows/v3/distillation-source.js.map +1 -0
  770. package/dist/workflows/v3/distillation-store.d.ts +185 -0
  771. package/dist/workflows/v3/distillation-store.d.ts.map +1 -0
  772. package/dist/workflows/v3/distillation-store.js +1127 -0
  773. package/dist/workflows/v3/distillation-store.js.map +1 -0
  774. package/dist/workflows/v3/drive-lease.d.ts +7 -0
  775. package/dist/workflows/v3/drive-lease.d.ts.map +1 -0
  776. package/dist/workflows/v3/drive-lease.js +10 -0
  777. package/dist/workflows/v3/drive-lease.js.map +1 -0
  778. package/dist/workflows/v3/ephemeral-pool.d.ts +1 -1
  779. package/dist/workflows/v3/ephemeral-pool.d.ts.map +1 -1
  780. package/dist/workflows/v3/ephemeral-pool.js +222 -37
  781. package/dist/workflows/v3/ephemeral-pool.js.map +1 -1
  782. package/dist/workflows/v3/grill-state.d.ts +18 -3
  783. package/dist/workflows/v3/grill-state.d.ts.map +1 -1
  784. package/dist/workflows/v3/grill-state.js +22 -5
  785. package/dist/workflows/v3/grill-state.js.map +1 -1
  786. package/dist/workflows/v3/host-bindings.d.ts +40 -0
  787. package/dist/workflows/v3/host-bindings.d.ts.map +1 -0
  788. package/dist/workflows/v3/host-bindings.js +272 -0
  789. package/dist/workflows/v3/host-bindings.js.map +1 -0
  790. package/dist/workflows/v3/host-effect-ledger.d.ts +22 -0
  791. package/dist/workflows/v3/host-effect-ledger.d.ts.map +1 -0
  792. package/dist/workflows/v3/host-effect-ledger.js +110 -0
  793. package/dist/workflows/v3/host-effect-ledger.js.map +1 -0
  794. package/dist/workflows/v3/host-execution.d.ts +142 -0
  795. package/dist/workflows/v3/host-execution.d.ts.map +1 -0
  796. package/dist/workflows/v3/host-execution.js +424 -0
  797. package/dist/workflows/v3/host-execution.js.map +1 -0
  798. package/dist/workflows/v3/host.d.ts +46 -10
  799. package/dist/workflows/v3/host.d.ts.map +1 -1
  800. package/dist/workflows/v3/host.js +419 -140
  801. package/dist/workflows/v3/host.js.map +1 -1
  802. package/dist/workflows/v3/human-gate.d.ts +19 -1
  803. package/dist/workflows/v3/human-gate.d.ts.map +1 -1
  804. package/dist/workflows/v3/human-gate.js +145 -19
  805. package/dist/workflows/v3/human-gate.js.map +1 -1
  806. package/dist/workflows/v3/journal.d.ts +125 -7
  807. package/dist/workflows/v3/journal.d.ts.map +1 -1
  808. package/dist/workflows/v3/journal.js +154 -38
  809. package/dist/workflows/v3/journal.js.map +1 -1
  810. package/dist/workflows/v3/library-materialize.d.ts +88 -0
  811. package/dist/workflows/v3/library-materialize.d.ts.map +1 -0
  812. package/dist/workflows/v3/library-materialize.js +294 -0
  813. package/dist/workflows/v3/library-materialize.js.map +1 -0
  814. package/dist/workflows/v3/library-schema.d.ts +138 -0
  815. package/dist/workflows/v3/library-schema.d.ts.map +1 -0
  816. package/dist/workflows/v3/library-schema.js +573 -0
  817. package/dist/workflows/v3/library-schema.js.map +1 -0
  818. package/dist/workflows/v3/library-service.d.ts +126 -0
  819. package/dist/workflows/v3/library-service.d.ts.map +1 -0
  820. package/dist/workflows/v3/library-service.js +542 -0
  821. package/dist/workflows/v3/library-service.js.map +1 -0
  822. package/dist/workflows/v3/library-store.d.ts +124 -0
  823. package/dist/workflows/v3/library-store.d.ts.map +1 -0
  824. package/dist/workflows/v3/library-store.js +665 -0
  825. package/dist/workflows/v3/library-store.js.map +1 -0
  826. package/dist/workflows/v3/orchestrator.d.ts +9 -1
  827. package/dist/workflows/v3/orchestrator.d.ts.map +1 -1
  828. package/dist/workflows/v3/orchestrator.js +2 -1
  829. package/dist/workflows/v3/orchestrator.js.map +1 -1
  830. package/dist/workflows/v3/progress-projection.d.ts +99 -0
  831. package/dist/workflows/v3/progress-projection.d.ts.map +1 -0
  832. package/dist/workflows/v3/progress-projection.js +197 -0
  833. package/dist/workflows/v3/progress-projection.js.map +1 -0
  834. package/dist/workflows/v3/run-envelope.d.ts +1279 -0
  835. package/dist/workflows/v3/run-envelope.d.ts.map +1 -0
  836. package/dist/workflows/v3/run-envelope.js +681 -0
  837. package/dist/workflows/v3/run-envelope.js.map +1 -0
  838. package/dist/workflows/v3/runtime.d.ts +39 -7
  839. package/dist/workflows/v3/runtime.d.ts.map +1 -1
  840. package/dist/workflows/v3/runtime.js +1992 -100
  841. package/dist/workflows/v3/runtime.js.map +1 -1
  842. package/dist/workflows/v3/session-relay-client.d.ts +61 -0
  843. package/dist/workflows/v3/session-relay-client.d.ts.map +1 -0
  844. package/dist/workflows/v3/session-relay-client.js +92 -0
  845. package/dist/workflows/v3/session-relay-client.js.map +1 -0
  846. package/dist/workflows/v3/session-relay.d.ts +66 -0
  847. package/dist/workflows/v3/session-relay.d.ts.map +1 -0
  848. package/dist/workflows/v3/session-relay.js +157 -0
  849. package/dist/workflows/v3/session-relay.js.map +1 -0
  850. package/dist/workflows/v3/start-intent.d.ts +8 -0
  851. package/dist/workflows/v3/start-intent.d.ts.map +1 -0
  852. package/dist/workflows/v3/start-intent.js +34 -0
  853. package/dist/workflows/v3/start-intent.js.map +1 -0
  854. package/dist/workflows/v3/state.d.ts +11 -2
  855. package/dist/workflows/v3/state.d.ts.map +1 -1
  856. package/dist/workflows/v3/state.js +182 -10
  857. package/dist/workflows/v3/state.js.map +1 -1
  858. package/dist/workflows/v3/template-bindings.d.ts +22 -0
  859. package/dist/workflows/v3/template-bindings.d.ts.map +1 -0
  860. package/dist/workflows/v3/template-bindings.js +204 -0
  861. package/dist/workflows/v3/template-bindings.js.map +1 -0
  862. package/dist/workflows/v3/worker-fence.d.ts +158 -0
  863. package/dist/workflows/v3/worker-fence.d.ts.map +1 -0
  864. package/dist/workflows/v3/worker-fence.js +685 -0
  865. package/dist/workflows/v3/worker-fence.js.map +1 -0
  866. package/package.json +3 -2
  867. package/dist/core/dashboard-command/workflows.d.ts +0 -20
  868. package/dist/core/dashboard-command/workflows.d.ts.map +0 -1
  869. package/dist/core/dashboard-command/workflows.js +0 -45
  870. package/dist/core/dashboard-command/workflows.js.map +0 -1
  871. package/dist/dashboard/web/legacy-workflow-link.d.ts +0 -2
  872. package/dist/dashboard/web/legacy-workflow-link.d.ts.map +0 -1
  873. package/dist/dashboard/web/legacy-workflow-link.js +0 -12
  874. package/dist/dashboard/web/legacy-workflow-link.js.map +0 -1
  875. package/dist/dashboard/web/legacy-workflow-page.d.ts +0 -3
  876. package/dist/dashboard/web/legacy-workflow-page.d.ts.map +0 -1
  877. package/dist/dashboard/web/legacy-workflow-page.js +0 -717
  878. package/dist/dashboard/web/legacy-workflow-page.js.map +0 -1
  879. package/dist/dashboard/web/workflow-version-switch.d.ts +0 -8
  880. package/dist/dashboard/web/workflow-version-switch.d.ts.map +0 -1
  881. package/dist/dashboard/web/workflow-version-switch.js +0 -9
  882. package/dist/dashboard/web/workflow-version-switch.js.map +0 -1
  883. package/dist/dashboard/web/workflows.d.ts +0 -273
  884. package/dist/dashboard/web/workflows.d.ts.map +0 -1
  885. package/dist/dashboard/web/workflows.js +0 -436
  886. package/dist/dashboard/web/workflows.js.map +0 -1
  887. package/dist/dashboard/workflow-api.d.ts +0 -30
  888. package/dist/dashboard/workflow-api.d.ts.map +0 -1
  889. package/dist/dashboard/workflow-api.js +0 -397
  890. package/dist/dashboard/workflow-api.js.map +0 -1
  891. package/dist/dashboard/workflow-card-model.d.ts +0 -127
  892. package/dist/dashboard/workflow-card-model.d.ts.map +0 -1
  893. package/dist/dashboard/workflow-card-model.js +0 -186
  894. package/dist/dashboard/workflow-card-model.js.map +0 -1
  895. package/dist/dashboard/workflows-action-helpers.d.ts +0 -105
  896. package/dist/dashboard/workflows-action-helpers.d.ts.map +0 -1
  897. package/dist/dashboard/workflows-action-helpers.js +0 -196
  898. package/dist/dashboard/workflows-action-helpers.js.map +0 -1
  899. package/dist/dashboard-web/chunks/bot-defaults-page-7T7DPOV6.js +0 -4
  900. package/dist/dashboard-web/chunks/chunk-IGXYYRYJ.js +0 -1
  901. package/dist/dashboard-web/chunks/chunk-ISOD7VDX.js +0 -1
  902. package/dist/dashboard-web/chunks/chunk-PNK3HQBI.js +0 -37
  903. package/dist/dashboard-web/chunks/chunk-SRIE4MLQ.js +0 -1
  904. package/dist/dashboard-web/chunks/connectors-page-UQ4QBE45.js +0 -1
  905. package/dist/dashboard-web/chunks/legacy-workflow-page-QMC7OZXH.js +0 -2
  906. package/dist/dashboard-web/chunks/sessions-page-NNZIDHZM.js +0 -3
  907. package/dist/dashboard-web/chunks/settings-page-LJIXX5LQ.js +0 -2
  908. package/dist/dashboard-web/chunks/v3-page-YLYVHGKD.js +0 -94
  909. package/dist/dashboard-web/terminal-replay.html +0 -227
  910. package/dist/im/lark/workflow-card-handler.d.ts +0 -51
  911. package/dist/im/lark/workflow-card-handler.d.ts.map +0 -1
  912. package/dist/im/lark/workflow-card-handler.js +0 -163
  913. package/dist/im/lark/workflow-card-handler.js.map +0 -1
  914. package/dist/im/lark/workflow-cards.d.ts +0 -47
  915. package/dist/im/lark/workflow-cards.d.ts.map +0 -1
  916. package/dist/im/lark/workflow-cards.js +0 -231
  917. package/dist/im/lark/workflow-cards.js.map +0 -1
  918. package/dist/im/lark/workflow-progress-card.d.ts +0 -81
  919. package/dist/im/lark/workflow-progress-card.d.ts.map +0 -1
  920. package/dist/im/lark/workflow-progress-card.js +0 -336
  921. package/dist/im/lark/workflow-progress-card.js.map +0 -1
  922. package/dist/im/lark/workflows-card.d.ts +0 -102
  923. package/dist/im/lark/workflows-card.d.ts.map +0 -1
  924. package/dist/im/lark/workflows-card.js +0 -737
  925. package/dist/im/lark/workflows-card.js.map +0 -1
  926. package/dist/workflows/attempt-resume.d.ts +0 -119
  927. package/dist/workflows/attempt-resume.d.ts.map +0 -1
  928. package/dist/workflows/attempt-resume.js +0 -392
  929. package/dist/workflows/attempt-resume.js.map +0 -1
  930. package/dist/workflows/blob.d.ts +0 -27
  931. package/dist/workflows/blob.d.ts.map +0 -1
  932. package/dist/workflows/blob.js +0 -40
  933. package/dist/workflows/blob.js.map +0 -1
  934. package/dist/workflows/cancel-run.d.ts +0 -45
  935. package/dist/workflows/cancel-run.d.ts.map +0 -1
  936. package/dist/workflows/cancel-run.js +0 -99
  937. package/dist/workflows/cancel-run.js.map +0 -1
  938. package/dist/workflows/cancel.d.ts +0 -111
  939. package/dist/workflows/cancel.d.ts.map +0 -1
  940. package/dist/workflows/cancel.js +0 -120
  941. package/dist/workflows/cancel.js.map +0 -1
  942. package/dist/workflows/catalog.d.ts +0 -60
  943. package/dist/workflows/catalog.d.ts.map +0 -1
  944. package/dist/workflows/catalog.js +0 -119
  945. package/dist/workflows/catalog.js.map +0 -1
  946. package/dist/workflows/cold-attach.d.ts +0 -30
  947. package/dist/workflows/cold-attach.d.ts.map +0 -1
  948. package/dist/workflows/cold-attach.js +0 -40
  949. package/dist/workflows/cold-attach.js.map +0 -1
  950. package/dist/workflows/cold-scan.d.ts +0 -21
  951. package/dist/workflows/cold-scan.d.ts.map +0 -1
  952. package/dist/workflows/cold-scan.js +0 -70
  953. package/dist/workflows/cold-scan.js.map +0 -1
  954. package/dist/workflows/daemon-spawn.d.ts +0 -119
  955. package/dist/workflows/daemon-spawn.d.ts.map +0 -1
  956. package/dist/workflows/daemon-spawn.js +0 -564
  957. package/dist/workflows/daemon-spawn.js.map +0 -1
  958. package/dist/workflows/effect-input.d.ts +0 -4
  959. package/dist/workflows/effect-input.d.ts.map +0 -1
  960. package/dist/workflows/effect-input.js +0 -19
  961. package/dist/workflows/effect-input.js.map +0 -1
  962. package/dist/workflows/events/append.d.ts +0 -77
  963. package/dist/workflows/events/append.d.ts.map +0 -1
  964. package/dist/workflows/events/append.js +0 -214
  965. package/dist/workflows/events/append.js.map +0 -1
  966. package/dist/workflows/events/idempotency.d.ts +0 -77
  967. package/dist/workflows/events/idempotency.d.ts.map +0 -1
  968. package/dist/workflows/events/idempotency.js +0 -116
  969. package/dist/workflows/events/idempotency.js.map +0 -1
  970. package/dist/workflows/events/index.d.ts +0 -7
  971. package/dist/workflows/events/index.d.ts.map +0 -1
  972. package/dist/workflows/events/index.js +0 -7
  973. package/dist/workflows/events/index.js.map +0 -1
  974. package/dist/workflows/fanout.d.ts +0 -36
  975. package/dist/workflows/fanout.d.ts.map +0 -1
  976. package/dist/workflows/fanout.js +0 -115
  977. package/dist/workflows/fanout.js.map +0 -1
  978. package/dist/workflows/hostExecutors/protocol.d.ts +0 -42
  979. package/dist/workflows/hostExecutors/protocol.d.ts.map +0 -1
  980. package/dist/workflows/hostExecutors/protocol.js +0 -181
  981. package/dist/workflows/hostExecutors/protocol.js.map +0 -1
  982. package/dist/workflows/loader.d.ts +0 -30
  983. package/dist/workflows/loader.d.ts.map +0 -1
  984. package/dist/workflows/loader.js +0 -84
  985. package/dist/workflows/loader.js.map +0 -1
  986. package/dist/workflows/loop.d.ts +0 -50
  987. package/dist/workflows/loop.d.ts.map +0 -1
  988. package/dist/workflows/loop.js +0 -408
  989. package/dist/workflows/loop.js.map +0 -1
  990. package/dist/workflows/orchestrator.d.ts +0 -171
  991. package/dist/workflows/orchestrator.d.ts.map +0 -1
  992. package/dist/workflows/orchestrator.js +0 -609
  993. package/dist/workflows/orchestrator.js.map +0 -1
  994. package/dist/workflows/output-binding.d.ts +0 -77
  995. package/dist/workflows/output-binding.d.ts.map +0 -1
  996. package/dist/workflows/output-binding.js +0 -329
  997. package/dist/workflows/output-binding.js.map +0 -1
  998. package/dist/workflows/params.d.ts.map +0 -1
  999. package/dist/workflows/params.js.map +0 -1
  1000. package/dist/workflows/resume.d.ts +0 -263
  1001. package/dist/workflows/resume.d.ts.map +0 -1
  1002. package/dist/workflows/resume.js +0 -808
  1003. package/dist/workflows/resume.js.map +0 -1
  1004. package/dist/workflows/run-id.d.ts +0 -2
  1005. package/dist/workflows/run-id.d.ts.map +0 -1
  1006. package/dist/workflows/run-id.js +0 -7
  1007. package/dist/workflows/run-id.js.map +0 -1
  1008. package/dist/workflows/run-init.d.ts +0 -48
  1009. package/dist/workflows/run-init.d.ts.map +0 -1
  1010. package/dist/workflows/run-init.js +0 -100
  1011. package/dist/workflows/run-init.js.map +0 -1
  1012. package/dist/workflows/runs-dir.d.ts +0 -4
  1013. package/dist/workflows/runs-dir.d.ts.map +0 -1
  1014. package/dist/workflows/runs-dir.js +0 -15
  1015. package/dist/workflows/runs-dir.js.map +0 -1
  1016. package/dist/workflows/runtime.d.ts +0 -215
  1017. package/dist/workflows/runtime.d.ts.map +0 -1
  1018. package/dist/workflows/runtime.js +0 -630
  1019. package/dist/workflows/runtime.js.map +0 -1
  1020. package/dist/workflows/spawn-bot.d.ts +0 -165
  1021. package/dist/workflows/spawn-bot.d.ts.map +0 -1
  1022. package/dist/workflows/spawn-bot.js +0 -215
  1023. package/dist/workflows/spawn-bot.js.map +0 -1
  1024. package/dist/workflows/spawn-policy.d.ts.map +0 -1
  1025. package/dist/workflows/spawn-policy.js.map +0 -1
  1026. package/dist/workflows/system.d.ts +0 -49
  1027. package/dist/workflows/system.d.ts.map +0 -1
  1028. package/dist/workflows/system.js +0 -48
  1029. package/dist/workflows/system.js.map +0 -1
  1030. package/dist/workflows/trigger-from-envelope.d.ts +0 -13
  1031. package/dist/workflows/trigger-from-envelope.d.ts.map +0 -1
  1032. package/dist/workflows/trigger-from-envelope.js +0 -68
  1033. package/dist/workflows/trigger-from-envelope.js.map +0 -1
  1034. package/dist/workflows/trigger-run.d.ts +0 -70
  1035. package/dist/workflows/trigger-run.d.ts.map +0 -1
  1036. package/dist/workflows/trigger-run.js +0 -88
  1037. package/dist/workflows/trigger-run.js.map +0 -1
  1038. package/dist/workflows/wait.d.ts +0 -141
  1039. package/dist/workflows/wait.d.ts.map +0 -1
  1040. package/dist/workflows/wait.js +0 -203
  1041. package/dist/workflows/wait.js.map +0 -1
@@ -0,0 +1,1220 @@
1
+ /**
2
+ * One-time, read-only-to-the-source archive for retired v2 workflow runs.
3
+ *
4
+ * The archive deliberately stores both the byte-exact legacy tree and the
5
+ * current ops projection. The legacy replay implementation can be deleted only
6
+ * after `verifyV2RunArchive(..., { sourceRunsDir })` proves that both views
7
+ * still match the live source.
8
+ */
9
+ import { createHash, randomBytes } from 'node:crypto';
10
+ import { chmodSync, closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, linkSync, mkdirSync, openSync, readdirSync, readSync, realpathSync, renameSync, rmSync, unlinkSync, writeSync, } from 'node:fs';
11
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve } from 'node:path';
12
+ import { canonicalJsonStringify } from '../../utils/canonical-json.js';
13
+ import { fsyncDirectorySyncPortable } from '../../utils/fs-durability.js';
14
+ import { withFileLock } from '../../utils/file-lock.js';
15
+ import { parseEvent } from '../events/schema.js';
16
+ import { isValidRunId, readRunSnapshot, } from '../ops-projection.js';
17
+ import { V2_RUN_ARCHIVE_COMMIT_SCHEMA_VERSION, V2_RUN_ARCHIVE_KIND, V2_RUN_ARCHIVE_SCHEMA_VERSION, V2_RUN_RETIREMENT_KIND, V2_RUN_RETIREMENT_SCHEMA_VERSION, archiveDirectoryName, parseV2RunArchiveCommitMarker, parseV2RunArchiveManifest, parseV2RunRetirementReceipt, sha256Ref, v2RunArchiveId, } from './v2-run-archive-schema.js';
18
+ const READ_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);
19
+ const CREATE_FLAGS = constants.O_WRONLY |
20
+ constants.O_CREAT |
21
+ constants.O_EXCL |
22
+ (constants.O_NOFOLLOW ?? 0);
23
+ const DIRECTORY_FLAGS = constants.O_RDONLY | (constants.O_DIRECTORY ?? 0) | (constants.O_NOFOLLOW ?? 0);
24
+ const BUFFER_BYTES = 64 * 1024;
25
+ const MANIFEST_FILE = 'manifest.json';
26
+ const COMMIT_FILE = 'COMMITTED';
27
+ const STAGING_PREFIX = '.staging-v2-run-archive-';
28
+ const STAGE_MARKER = 'stage.json';
29
+ const PUBLICATION_LOCK_BASENAME = '.v2-run-archive-publication';
30
+ const RETIREMENT_RECEIPT_PREFIX = 'v2-run-retirement-';
31
+ export class V2RunArchiveError extends Error {
32
+ code;
33
+ constructor(code, message) {
34
+ super(`${code}: ${message}`);
35
+ this.code = code;
36
+ this.name = 'V2RunArchiveError';
37
+ }
38
+ }
39
+ function fail(code, message) {
40
+ throw new V2RunArchiveError(code, message);
41
+ }
42
+ function assertSafeRelativePath(path, label) {
43
+ if (!path ||
44
+ path.length > 4096 ||
45
+ isAbsolute(path) ||
46
+ path.includes('\\') ||
47
+ path.split('/').some((segment) => !segment || segment === '.' || segment === '..')) {
48
+ fail('UNSAFE_ARCHIVE_PATH', `${label} is not a normalized relative path: ${path}`);
49
+ }
50
+ }
51
+ function assertPathInside(parent, child, label) {
52
+ const rel = relative(resolve(parent), resolve(child));
53
+ if (!rel || rel === '.')
54
+ return;
55
+ if (rel.startsWith('..') || isAbsolute(rel)) {
56
+ fail('PATH_ESCAPE', `${label} escapes ${parent}: ${child}`);
57
+ }
58
+ }
59
+ function assertPlainDirectory(path, label) {
60
+ let stat;
61
+ try {
62
+ stat = lstatSync(path);
63
+ }
64
+ catch (err) {
65
+ fail('DIRECTORY_UNREADABLE', `${label} ${path}: ${err instanceof Error ? err.message : String(err)}`);
66
+ }
67
+ if (stat.isSymbolicLink() || !stat.isDirectory()) {
68
+ fail('UNSAFE_DIRECTORY', `${label} must be a real directory, not a symlink/special entry: ${path}`);
69
+ }
70
+ const fd = openSync(path, DIRECTORY_FLAGS);
71
+ try {
72
+ const opened = fstatSync(fd);
73
+ if (!opened.isDirectory() || opened.dev !== stat.dev || opened.ino !== stat.ino) {
74
+ fail('DIRECTORY_RACED', `${label} changed while opening: ${path}`);
75
+ }
76
+ }
77
+ finally {
78
+ closeSync(fd);
79
+ }
80
+ }
81
+ function ensurePrivateDirectory(path) {
82
+ mkdirSync(path, { recursive: true, mode: 0o700 });
83
+ assertPlainDirectory(path, 'archive directory');
84
+ chmodSync(path, 0o700);
85
+ }
86
+ /**
87
+ * Create the dedicated archive base privately, but never chmod a caller-owned
88
+ * existing directory such as /tmp or $HOME. An existing base must already
89
+ * satisfy the private-mode contract or the operator must choose a child path.
90
+ */
91
+ function ensurePrivateArchiveBase(path) {
92
+ const created = mkdirSync(path, { recursive: true, mode: 0o700 });
93
+ assertPlainDirectory(path, 'archive base directory');
94
+ if (created !== undefined)
95
+ chmodSync(path, 0o700);
96
+ else
97
+ assertPrivateMode(path, 0o700, 'archive base directory');
98
+ }
99
+ /**
100
+ * Publication and retirement deliberately share one non-reentrant lock.
101
+ * Keep all callers on this helper so a basename change cannot split the
102
+ * serialization domain and never call it from inside another invocation.
103
+ */
104
+ export function withV2RunArchivePublicationLock(archiveBaseDir, fn) {
105
+ return withFileLock(join(resolve(archiveBaseDir), PUBLICATION_LOCK_BASENAME), fn);
106
+ }
107
+ function assertPrivateMode(path, wanted, label) {
108
+ if (process.platform === 'win32')
109
+ return;
110
+ const mode = lstatSync(path).mode & 0o777;
111
+ if (mode !== wanted)
112
+ fail('ARCHIVE_MODE_MISMATCH', `${label} ${path} mode=${mode.toString(8)}, expected ${wanted.toString(8)}`);
113
+ }
114
+ function readSecureFile(path) {
115
+ const before = lstatSync(path);
116
+ if (before.isSymbolicLink() || !before.isFile()) {
117
+ fail('UNSAFE_SOURCE_ENTRY', `expected regular file: ${path}`);
118
+ }
119
+ if (before.nlink !== 1)
120
+ fail('SOURCE_HARDLINK', `hard-linked source file is not archive-safe: ${path}`);
121
+ const fd = openSync(path, READ_FLAGS);
122
+ try {
123
+ const opened = fstatSync(fd);
124
+ if (!opened.isFile() || opened.nlink !== 1 || opened.dev !== before.dev || opened.ino !== before.ino)
125
+ fail('SOURCE_FILE_RACED', `source file changed while opening: ${path}`);
126
+ const chunks = [];
127
+ const buffer = Buffer.alloc(BUFFER_BYTES);
128
+ let total = 0;
129
+ while (true) {
130
+ const count = readSync(fd, buffer, 0, buffer.length, null);
131
+ if (count === 0)
132
+ break;
133
+ chunks.push(Buffer.from(buffer.subarray(0, count)));
134
+ total += count;
135
+ }
136
+ const after = fstatSync(fd);
137
+ if (after.dev !== opened.dev || after.ino !== opened.ino || after.nlink !== 1 ||
138
+ after.size !== opened.size || after.size !== total || after.mtimeMs !== opened.mtimeMs)
139
+ fail('SOURCE_FILE_CHANGED', `source file changed while reading: ${path}`);
140
+ return Buffer.concat(chunks, total);
141
+ }
142
+ finally {
143
+ closeSync(fd);
144
+ }
145
+ }
146
+ function hashSecureFile(path) {
147
+ const before = lstatSync(path);
148
+ if (before.isSymbolicLink() || !before.isFile()) {
149
+ fail('UNSAFE_SOURCE_ENTRY', `expected regular file: ${path}`);
150
+ }
151
+ if (before.nlink !== 1)
152
+ fail('SOURCE_HARDLINK', `hard-linked file is not archive-safe: ${path}`);
153
+ const fd = openSync(path, READ_FLAGS);
154
+ try {
155
+ const opened = fstatSync(fd);
156
+ if (!opened.isFile() || opened.nlink !== 1 || opened.dev !== before.dev || opened.ino !== before.ino)
157
+ fail('SOURCE_FILE_RACED', `file changed while opening: ${path}`);
158
+ const hash = createHash('sha256');
159
+ const buffer = Buffer.alloc(BUFFER_BYTES);
160
+ let bytes = 0;
161
+ while (true) {
162
+ const count = readSync(fd, buffer, 0, buffer.length, null);
163
+ if (count === 0)
164
+ break;
165
+ hash.update(buffer.subarray(0, count));
166
+ bytes += count;
167
+ }
168
+ const after = fstatSync(fd);
169
+ if (after.dev !== opened.dev || after.ino !== opened.ino || after.nlink !== 1 ||
170
+ after.size !== opened.size || after.size !== bytes || after.mtimeMs !== opened.mtimeMs)
171
+ fail('SOURCE_FILE_CHANGED', `file changed while hashing: ${path}`);
172
+ return { bytes, sha256: `sha256:${hash.digest('hex')}` };
173
+ }
174
+ finally {
175
+ closeSync(fd);
176
+ }
177
+ }
178
+ function writeAll(fd, data) {
179
+ let offset = 0;
180
+ while (offset < data.length)
181
+ offset += writeSync(fd, data, offset, data.length - offset);
182
+ }
183
+ function writeNewPrivateFile(path, data) {
184
+ assertPathInside(dirname(path), path, 'archive file');
185
+ const fd = openSync(path, CREATE_FLAGS, 0o600);
186
+ try {
187
+ fchmodSync(fd, 0o600);
188
+ writeAll(fd, data);
189
+ fsyncSync(fd);
190
+ const stat = fstatSync(fd);
191
+ if (!stat.isFile() || stat.nlink !== 1 || stat.size !== data.length) {
192
+ fail('ARCHIVE_WRITE_INVALID', `new archive file is not a private regular inode: ${path}`);
193
+ }
194
+ }
195
+ finally {
196
+ closeSync(fd);
197
+ }
198
+ }
199
+ function copyRegularFileSecure(copy, payloadRoot) {
200
+ assertSafeRelativePath(copy.archivePath, 'copy destination');
201
+ const destination = join(payloadRoot, ...copy.archivePath.split('/'));
202
+ assertPathInside(payloadRoot, destination, 'copy destination');
203
+ const before = lstatSync(copy.sourcePath);
204
+ if (before.isSymbolicLink() || !before.isFile()) {
205
+ fail('UNSAFE_SOURCE_ENTRY', `expected regular source file: ${copy.sourcePath}`);
206
+ }
207
+ if (before.nlink !== 1)
208
+ fail('SOURCE_HARDLINK', `hard-linked source file is not archive-safe: ${copy.sourcePath}`);
209
+ const sourceFd = openSync(copy.sourcePath, READ_FLAGS);
210
+ const destinationFd = openSync(destination, CREATE_FLAGS, 0o600);
211
+ try {
212
+ fchmodSync(destinationFd, 0o600);
213
+ const opened = fstatSync(sourceFd);
214
+ if (!opened.isFile() || opened.nlink !== 1 || opened.dev !== before.dev || opened.ino !== before.ino)
215
+ fail('SOURCE_FILE_RACED', `source file changed while opening: ${copy.sourcePath}`);
216
+ const hash = createHash('sha256');
217
+ const buffer = Buffer.alloc(BUFFER_BYTES);
218
+ let bytes = 0;
219
+ while (true) {
220
+ const count = readSync(sourceFd, buffer, 0, buffer.length, null);
221
+ if (count === 0)
222
+ break;
223
+ hash.update(buffer.subarray(0, count));
224
+ writeAll(destinationFd, buffer.subarray(0, count));
225
+ bytes += count;
226
+ }
227
+ fsyncSync(destinationFd);
228
+ const afterSource = fstatSync(sourceFd);
229
+ const destinationStat = fstatSync(destinationFd);
230
+ const sha256 = `sha256:${hash.digest('hex')}`;
231
+ if (afterSource.dev !== opened.dev || afterSource.ino !== opened.ino || afterSource.nlink !== 1 ||
232
+ afterSource.size !== opened.size || afterSource.size !== bytes || afterSource.mtimeMs !== opened.mtimeMs)
233
+ fail('SOURCE_FILE_CHANGED', `source file changed while copying: ${copy.sourcePath}`);
234
+ if (!destinationStat.isFile() || destinationStat.nlink !== 1 || destinationStat.size !== bytes) {
235
+ fail('ARCHIVE_COPY_INVALID', `destination file identity is unsafe: ${destination}`);
236
+ }
237
+ if (bytes !== copy.expected.bytes || sha256 !== copy.expected.sha256) {
238
+ fail('SOURCE_CHANGED_DURING_ARCHIVE', `source bytes changed after first capture: ${copy.sourcePath}`);
239
+ }
240
+ }
241
+ finally {
242
+ closeSync(sourceFd);
243
+ closeSync(destinationFd);
244
+ }
245
+ }
246
+ function captureDirectoryTree(root) {
247
+ assertPlainDirectory(root, 'source tree');
248
+ const directories = [];
249
+ const files = [];
250
+ const visit = (directory, relativeDirectory) => {
251
+ assertPlainDirectory(directory, 'source tree directory');
252
+ const entries = readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
253
+ for (const entry of entries) {
254
+ if (entry.name === '.' || entry.name === '..' || entry.name.includes('/') || entry.name.includes('\\')) {
255
+ fail('UNSAFE_SOURCE_NAME', `unsafe source entry name in ${directory}: ${entry.name}`);
256
+ }
257
+ const absolute = join(directory, entry.name);
258
+ const relativePath = relativeDirectory ? posix.join(relativeDirectory, entry.name) : entry.name;
259
+ assertSafeRelativePath(relativePath, 'source tree entry');
260
+ const stat = lstatSync(absolute);
261
+ if (stat.isSymbolicLink())
262
+ fail('SOURCE_SYMLINK', `symlinks are forbidden in the archive source: ${absolute}`);
263
+ if (stat.isDirectory()) {
264
+ directories.push(relativePath);
265
+ visit(absolute, relativePath);
266
+ continue;
267
+ }
268
+ if (!stat.isFile())
269
+ fail('SOURCE_SPECIAL_ENTRY', `special filesystem entry is forbidden: ${absolute}`);
270
+ if (stat.nlink !== 1)
271
+ fail('SOURCE_HARDLINK', `hard-linked source file is forbidden: ${absolute}`);
272
+ const hashed = hashSecureFile(absolute);
273
+ files.push({ relativePath, sourcePath: absolute, ...hashed });
274
+ }
275
+ };
276
+ visit(root, '');
277
+ directories.sort();
278
+ files.sort((a, b) => a.relativePath.localeCompare(b.relativePath));
279
+ return { directories, files };
280
+ }
281
+ function captureTopFile(path, name) {
282
+ const stat = lstatSync(path);
283
+ if (stat.isSymbolicLink() || !stat.isFile())
284
+ fail('SOURCE_SPECIAL_ENTRY', `unsafe top-level entry: ${path}`);
285
+ if (stat.nlink !== 1)
286
+ fail('SOURCE_HARDLINK', `hard-linked top-level file is forbidden: ${path}`);
287
+ const hashed = hashSecureFile(path);
288
+ return { directories: [], files: [{ relativePath: name, sourcePath: path, ...hashed }] };
289
+ }
290
+ function treeDigest(tree) {
291
+ return sha256Ref(canonicalJsonStringify({
292
+ directories: tree.directories,
293
+ files: tree.files.map(({ relativePath: path, bytes, sha256 }) => ({ path, bytes, sha256 })),
294
+ }));
295
+ }
296
+ function strictReadJournal(runDir, runId) {
297
+ const path = join(runDir, 'events.ndjson');
298
+ const raw = readSecureFile(path).toString('utf-8');
299
+ if (!raw.endsWith('\n')) {
300
+ fail('TORN_EVENT_LOG', `${path} has no final newline (possible partial append)`);
301
+ }
302
+ const events = [];
303
+ let lineNumber = 0;
304
+ const lines = raw.split('\n');
305
+ lines.pop(); // exactly one final empty segment is required above
306
+ for (const line of lines) {
307
+ lineNumber++;
308
+ if (!line)
309
+ fail('CORRUPT_EVENT_LOG', `${path}:${lineNumber}: blank journal line`);
310
+ let value;
311
+ try {
312
+ value = JSON.parse(line);
313
+ }
314
+ catch (err) {
315
+ fail('CORRUPT_EVENT_LOG', `${path}:${lineNumber}: ${err instanceof Error ? err.message : String(err)}`);
316
+ }
317
+ let event;
318
+ try {
319
+ event = parseEvent(value);
320
+ }
321
+ catch (err) {
322
+ fail('CORRUPT_EVENT_LOG', `${path}:${lineNumber}: ${err instanceof Error ? err.message : String(err)}`);
323
+ }
324
+ const expectedEventId = `${runId}-${events.length + 1}`;
325
+ if (event.runId !== runId || event.eventId !== expectedEventId) {
326
+ fail('RUN_IDENTITY_MISMATCH', `${path}:${lineNumber} expected runId/eventId ${runId}/${expectedEventId}, got ${event.runId}/${event.eventId}`);
327
+ }
328
+ events.push(event);
329
+ }
330
+ if (events.length === 0)
331
+ fail('EMPTY_EVENT_LOG', `${path} has no workflow events`);
332
+ return events;
333
+ }
334
+ function presenceInTree(tree) {
335
+ const files = new Set(tree.files.map((file) => file.relativePath));
336
+ const directories = new Set(tree.directories);
337
+ return {
338
+ workflowJson: files.has('workflow.json'),
339
+ chatBindingJson: files.has('chat-binding.json'),
340
+ attemptsDir: directories.has('attempts'),
341
+ blobsDir: directories.has('blobs'),
342
+ };
343
+ }
344
+ function projectionWarnings(snapshot, presence) {
345
+ const warnings = [];
346
+ const danglingCount = snapshot.dangling.activities.length +
347
+ snapshot.dangling.effectAttempted.length +
348
+ snapshot.dangling.waits.length +
349
+ snapshot.dangling.cancels.length;
350
+ const liveTerminals = Object.values(snapshot.attemptIO).filter((item) => item.terminal?.status === 'live').length;
351
+ if (danglingCount > 0) {
352
+ warnings.push({
353
+ code: 'TERMINAL_RUN_HAS_DANGLING_STATE',
354
+ message: `Terminal run retains ${danglingCount} dangling replay item(s); raw bytes and projection are preserved.`,
355
+ });
356
+ }
357
+ if (liveTerminals > 0) {
358
+ warnings.push({
359
+ code: 'TERMINAL_RUN_HAS_LIVE_SIDECAR',
360
+ message: `Terminal run retains ${liveTerminals} terminal sidecar(s) marked live; treated as historical metadata.`,
361
+ });
362
+ }
363
+ if (!presence.workflowJson) {
364
+ warnings.push({
365
+ code: 'WORKFLOW_SNAPSHOT_MISSING',
366
+ message: 'Historical run has no workflow.json snapshot; the archive preserves all bytes that remain.',
367
+ });
368
+ }
369
+ return warnings;
370
+ }
371
+ function addTreeToPayload(input) {
372
+ assertSafeRelativePath(input.archiveRoot, 'archive raw root');
373
+ addDirectoryWithParents(input.directories, input.archiveRoot);
374
+ for (const sourceDirectory of input.tree.directories) {
375
+ addDirectoryWithParents(input.directories, posix.join(input.archiveRoot, sourceDirectory));
376
+ }
377
+ for (const sourceFile of input.tree.files) {
378
+ const archivePath = posix.join(input.archiveRoot, sourceFile.relativePath);
379
+ const expected = { path: archivePath, bytes: sourceFile.bytes, sha256: sourceFile.sha256 };
380
+ input.files.push(expected);
381
+ input.copies.push({ sourcePath: sourceFile.sourcePath, archivePath, expected });
382
+ }
383
+ }
384
+ function addDirectoryWithParents(directories, path) {
385
+ assertSafeRelativePath(path, 'archive directory');
386
+ const segments = path.split('/');
387
+ for (let index = 1; index <= segments.length; index++) {
388
+ directories.add(segments.slice(0, index).join('/'));
389
+ }
390
+ }
391
+ async function captureSource(runsDirInput) {
392
+ const absoluteRunsDir = resolve(runsDirInput);
393
+ assertPlainDirectory(absoluteRunsDir, 'workflow runs root');
394
+ const sourceRunsDir = realpathSync(absoluteRunsDir);
395
+ const runs = [];
396
+ const residuals = [];
397
+ const directories = new Set();
398
+ const files = [];
399
+ const copies = [];
400
+ const projections = new Map();
401
+ const entries = readdirSync(sourceRunsDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
402
+ for (const entry of entries) {
403
+ if (entry.name.includes('/') || entry.name.includes('\\') || entry.name === '.' || entry.name === '..') {
404
+ fail('UNSAFE_SOURCE_NAME', `unsafe top-level entry name: ${entry.name}`);
405
+ }
406
+ const sourcePath = join(sourceRunsDir, entry.name);
407
+ const stat = lstatSync(sourcePath);
408
+ if (stat.isSymbolicLink())
409
+ fail('SOURCE_SYMLINK', `top-level symlink is forbidden: ${sourcePath}`);
410
+ if (!stat.isDirectory() && !stat.isFile())
411
+ fail('SOURCE_SPECIAL_ENTRY', `top-level special entry is forbidden: ${sourcePath}`);
412
+ if (stat.isFile()) {
413
+ const tree = captureTopFile(sourcePath, entry.name);
414
+ const rawRoot = posix.join('residual', entry.name, 'raw');
415
+ addTreeToPayload({ tree, archiveRoot: rawRoot, directories, files, copies });
416
+ residuals.push({
417
+ name: entry.name,
418
+ sourceType: 'file',
419
+ reason: 'top-level-file',
420
+ rawRoot,
421
+ fileCount: tree.files.length,
422
+ totalBytes: tree.files.reduce((sum, file) => sum + file.bytes, 0),
423
+ treeSha256: treeDigest(tree),
424
+ });
425
+ continue;
426
+ }
427
+ const tree = captureDirectoryTree(sourcePath);
428
+ const hasEvents = tree.files.some((file) => file.relativePath === 'events.ndjson');
429
+ if (!hasEvents) {
430
+ const rawRoot = posix.join('residual', entry.name, 'raw');
431
+ addTreeToPayload({ tree, archiveRoot: rawRoot, directories, files, copies });
432
+ residuals.push({
433
+ name: entry.name,
434
+ sourceType: 'directory',
435
+ reason: 'directory-without-events',
436
+ rawRoot,
437
+ fileCount: tree.files.length,
438
+ totalBytes: tree.files.reduce((sum, file) => sum + file.bytes, 0),
439
+ treeSha256: treeDigest(tree),
440
+ });
441
+ continue;
442
+ }
443
+ if (!isValidRunId(entry.name))
444
+ fail('INVALID_RUN_ID', `event-bearing directory has unsafe runId '${entry.name}'`);
445
+ const events = strictReadJournal(sourcePath, entry.name);
446
+ const snapshot = await readRunSnapshot(sourceRunsDir, entry.name);
447
+ if (!snapshot)
448
+ fail('UNPROJECTABLE_RUN', `current ops projection cannot read run ${entry.name}`);
449
+ if (snapshot.runId !== entry.name || snapshot.run.runId !== entry.name) {
450
+ fail('RUN_IDENTITY_MISMATCH', `projection identity for ${entry.name} does not match its directory`);
451
+ }
452
+ if (snapshot.lastSeq !== events.length) {
453
+ fail('EVENT_SEQUENCE_MISMATCH', `projection lastSeq=${snapshot.lastSeq}, strict journal count=${events.length} for ${entry.name}`);
454
+ }
455
+ if (!['succeeded', 'failed', 'cancelled'].includes(snapshot.run.status)) {
456
+ fail('NONTERMINAL_RUN', `run ${entry.name} is ${snapshot.run.status}; drain it before archiving`);
457
+ }
458
+ const projection = Buffer.from(`${canonicalJsonStringify(snapshot)}\n`, 'utf-8');
459
+ const projectionPath = posix.join('runs', entry.name, 'projection.json');
460
+ const projectionFile = { path: projectionPath, bytes: projection.length, sha256: sha256Ref(projection) };
461
+ const rawRoot = posix.join('runs', entry.name, 'raw');
462
+ addTreeToPayload({ tree, archiveRoot: rawRoot, directories, files, copies });
463
+ addDirectoryWithParents(directories, posix.dirname(projectionPath));
464
+ files.push(projectionFile);
465
+ projections.set(projectionPath, projection);
466
+ const presence = presenceInTree(tree);
467
+ const liveTerminalSidecars = Object.values(snapshot.attemptIO)
468
+ .filter((item) => item.terminal?.status === 'live').length;
469
+ runs.push({
470
+ runId: entry.name,
471
+ rawRoot,
472
+ projectionPath,
473
+ projectionSha256: projectionFile.sha256,
474
+ presence,
475
+ missingOptional: [
476
+ ...(!presence.chatBindingJson ? ['chat-binding.json'] : []),
477
+ ...(!presence.attemptsDir ? ['attempts'] : []),
478
+ ],
479
+ warnings: projectionWarnings(snapshot, presence),
480
+ verdict: {
481
+ status: snapshot.run.status,
482
+ workflowId: snapshot.run.workflowId ?? 'unknown',
483
+ ...(snapshot.run.revisionId ? { revisionId: snapshot.run.revisionId } : {}),
484
+ lastSeq: snapshot.lastSeq,
485
+ updatedAt: snapshot.updatedAt,
486
+ dangling: {
487
+ activities: snapshot.dangling.activities.length,
488
+ effectAttempted: snapshot.dangling.effectAttempted.length,
489
+ waits: snapshot.dangling.waits.length,
490
+ cancels: snapshot.dangling.cancels.length,
491
+ },
492
+ liveTerminalSidecars,
493
+ },
494
+ });
495
+ }
496
+ if (runs.length === 0 && residuals.length === 0) {
497
+ fail('NO_WORKFLOW_RUNS', `${sourceRunsDir} has no v2 workflow-run bytes to archive`);
498
+ }
499
+ runs.sort((a, b) => a.runId.localeCompare(b.runId));
500
+ residuals.sort((a, b) => a.name.localeCompare(b.name));
501
+ const payloadDirectories = [...directories].sort();
502
+ const payloadFiles = files.sort((a, b) => a.path.localeCompare(b.path));
503
+ assertUnique(payloadDirectories, 'payload directory');
504
+ assertUnique(payloadFiles.map((file) => file.path), 'payload file');
505
+ return {
506
+ sourceRunsDir,
507
+ content: { runs, residuals, payloadDirectories, payloadFiles },
508
+ copies: copies.sort((a, b) => a.archivePath.localeCompare(b.archivePath)),
509
+ projections,
510
+ };
511
+ }
512
+ function assertUnique(values, label) {
513
+ const seen = new Set();
514
+ for (const value of values) {
515
+ if (seen.has(value))
516
+ fail('DUPLICATE_ARCHIVE_ENTRY', `duplicate ${label}: ${value}`);
517
+ seen.add(value);
518
+ }
519
+ }
520
+ function comparableContent(left, right) {
521
+ return canonicalJsonStringify(left) === canonicalJsonStringify(right);
522
+ }
523
+ export async function planV2RunArchive(input) {
524
+ const capture = await captureSource(input.runsDir);
525
+ return {
526
+ sourceRunsDir: capture.sourceRunsDir,
527
+ content: capture.content,
528
+ runCount: capture.content.runs.length,
529
+ residualCount: capture.content.residuals.length,
530
+ totalPayloadBytes: capture.content.payloadFiles.reduce((sum, file) => sum + file.bytes, 0),
531
+ };
532
+ }
533
+ function materializePayload(payloadRoot, capture) {
534
+ ensurePrivateDirectory(payloadRoot);
535
+ for (const directory of capture.content.payloadDirectories) {
536
+ assertSafeRelativePath(directory, 'payload directory');
537
+ const absolute = join(payloadRoot, ...directory.split('/'));
538
+ assertPathInside(payloadRoot, absolute, 'payload directory');
539
+ mkdirSync(absolute, { recursive: true, mode: 0o700 });
540
+ chmodSync(absolute, 0o700);
541
+ }
542
+ for (const copy of capture.copies)
543
+ copyRegularFileSecure(copy, payloadRoot);
544
+ for (const [path, projection] of capture.projections) {
545
+ const absolute = join(payloadRoot, ...path.split('/'));
546
+ writeNewPrivateFile(absolute, projection);
547
+ }
548
+ for (const directory of [...capture.content.payloadDirectories].sort((a, b) => b.split('/').length - a.split('/').length)) {
549
+ fsyncDirectorySyncPortable(join(payloadRoot, ...directory.split('/')));
550
+ }
551
+ fsyncDirectorySyncPortable(payloadRoot);
552
+ }
553
+ function canonicalFile(value) {
554
+ return Buffer.from(`${canonicalJsonStringify(value)}\n`, 'utf-8');
555
+ }
556
+ function publishCommitMarker(archiveDir, stageDir, marker) {
557
+ const path = join(archiveDir, COMMIT_FILE);
558
+ const bytes = canonicalFile(marker);
559
+ // Keep the link source outside the immutable archive tree. A process crash
560
+ // after writing this inode but before link/unlink must not leave an extra
561
+ // file that makes the content-address target unverifiable forever. The
562
+ // owned staging transaction is safely reclaimed on the next invocation.
563
+ const tmp = join(stageDir, `COMMITTED.${process.pid}.${randomBytes(6).toString('hex')}.tmp`);
564
+ try {
565
+ writeNewPrivateFile(tmp, bytes);
566
+ try {
567
+ linkSync(tmp, path);
568
+ unlinkSync(tmp);
569
+ fsyncDirectorySyncPortable(archiveDir);
570
+ }
571
+ catch (err) {
572
+ if (err.code !== 'EEXIST')
573
+ throw err;
574
+ const existing = readSecureFile(path);
575
+ if (!existing.equals(bytes))
576
+ fail('COMMIT_MARKER_CONFLICT', `existing ${path} differs from expected marker`);
577
+ unlinkSync(tmp);
578
+ }
579
+ }
580
+ finally {
581
+ try {
582
+ unlinkSync(tmp);
583
+ }
584
+ catch { /* best effort */ }
585
+ }
586
+ }
587
+ function stageMarkerBytes(sourceRunsDir) {
588
+ return canonicalFile({
589
+ schemaVersion: 1,
590
+ kind: V2_RUN_ARCHIVE_KIND,
591
+ sourceRunsDir,
592
+ });
593
+ }
594
+ function cleanOwnedStaging(archiveBaseDir) {
595
+ for (const entry of readdirSync(archiveBaseDir, { withFileTypes: true })) {
596
+ if (!entry.name.startsWith(STAGING_PREFIX))
597
+ continue;
598
+ const path = join(archiveBaseDir, entry.name);
599
+ const stat = lstatSync(path);
600
+ if (stat.isSymbolicLink() || !stat.isDirectory()) {
601
+ fail('UNSAFE_STAGING_ENTRY', `refusing to clean non-directory staging path ${path}`);
602
+ }
603
+ const markerPath = join(path, STAGE_MARKER);
604
+ let parsed;
605
+ try {
606
+ parsed = JSON.parse(readSecureFile(markerPath).toString('utf-8'));
607
+ }
608
+ catch (err) {
609
+ fail('UNKNOWN_STAGING_ENTRY', `staging directory lacks a valid ownership marker: ${path} (${err instanceof Error ? err.message : String(err)})`);
610
+ }
611
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed) ||
612
+ parsed.schemaVersion !== 1 ||
613
+ parsed.kind !== V2_RUN_ARCHIVE_KIND)
614
+ fail('UNKNOWN_STAGING_ENTRY', `staging ownership marker is not recognized: ${path}`);
615
+ rmSync(path, { recursive: true, force: false });
616
+ fsyncDirectorySyncPortable(archiveBaseDir);
617
+ }
618
+ }
619
+ function ensureDisjoint(source, archiveBase) {
620
+ const sourceToArchive = relative(source, archiveBase);
621
+ const archiveToSource = relative(archiveBase, source);
622
+ const inside = (rel) => rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
623
+ if (inside(sourceToArchive) || inside(archiveToSource)) {
624
+ fail('ARCHIVE_SOURCE_OVERLAP', `source and archive directories must be disjoint: ${source} <> ${archiveBase}`);
625
+ }
626
+ }
627
+ /** Resolve a path that may not exist yet without creating any ancestor. */
628
+ function realpathProspective(path) {
629
+ let cursor = resolve(path);
630
+ const missing = [];
631
+ while (true) {
632
+ try {
633
+ const stat = lstatSync(cursor);
634
+ if (stat.isSymbolicLink()) {
635
+ // realpath below is allowed to resolve existing ancestors, but the
636
+ // archive base itself must never be a symlink.
637
+ if (missing.length === 0)
638
+ fail('ARCHIVE_BASE_SYMLINK', `archive base must not be a symlink: ${cursor}`);
639
+ const realAncestor = realpathSync(cursor);
640
+ if (!lstatSync(realAncestor).isDirectory()) {
641
+ fail('ARCHIVE_PARENT_INVALID', `archive symlink ancestor is not a directory: ${cursor}`);
642
+ }
643
+ return join(realAncestor, ...missing);
644
+ }
645
+ if (!stat.isDirectory())
646
+ fail('ARCHIVE_PARENT_INVALID', `archive parent is not a directory: ${cursor}`);
647
+ return join(realpathSync(cursor), ...missing);
648
+ }
649
+ catch (err) {
650
+ if (err instanceof V2RunArchiveError)
651
+ throw err;
652
+ if (err.code !== 'ENOENT')
653
+ throw err;
654
+ const parent = dirname(cursor);
655
+ if (parent === cursor)
656
+ throw err;
657
+ missing.unshift(basename(cursor));
658
+ cursor = parent;
659
+ }
660
+ }
661
+ }
662
+ export async function commitV2RunArchive(input) {
663
+ const archiveBaseDir = resolve(input.archiveBaseDir);
664
+ // Preflight overlap before *any* archive mkdir/chmod/lock write. Resolve
665
+ // the nearest existing archive ancestor so a symlinked parent cannot hide
666
+ // that the requested output actually lives inside the source tree.
667
+ const sourceInput = resolve(input.runsDir);
668
+ assertPlainDirectory(sourceInput, 'workflow runs root');
669
+ const sourceReal = realpathSync(sourceInput);
670
+ ensureDisjoint(sourceInput, archiveBaseDir);
671
+ ensureDisjoint(sourceReal, realpathProspective(archiveBaseDir));
672
+ ensurePrivateArchiveBase(archiveBaseDir);
673
+ return withV2RunArchivePublicationLock(archiveBaseDir, async () => {
674
+ cleanOwnedStaging(archiveBaseDir);
675
+ const first = await captureSource(input.runsDir);
676
+ ensureDisjoint(first.sourceRunsDir, archiveBaseDir);
677
+ await input.onPhase?.('after-first-capture');
678
+ const stageDir = join(archiveBaseDir, `${STAGING_PREFIX}${process.pid}-${randomBytes(8).toString('hex')}`);
679
+ mkdirSync(stageDir, { mode: 0o700 });
680
+ chmodSync(stageDir, 0o700);
681
+ writeNewPrivateFile(join(stageDir, STAGE_MARKER), stageMarkerBytes(first.sourceRunsDir));
682
+ const payloadRoot = join(stageDir, 'payload');
683
+ materializePayload(payloadRoot, first);
684
+ await input.onPhase?.('after-copy');
685
+ const second = await captureSource(first.sourceRunsDir);
686
+ if (!comparableContent(first.content, second.content)) {
687
+ fail('SOURCE_CHANGED_DURING_ARCHIVE', 'source tree or live projection changed between the two captures');
688
+ }
689
+ await input.onPhase?.('after-second-capture');
690
+ const archiveId = v2RunArchiveId(first.content);
691
+ const manifest = {
692
+ schemaVersion: V2_RUN_ARCHIVE_SCHEMA_VERSION,
693
+ kind: V2_RUN_ARCHIVE_KIND,
694
+ archiveId,
695
+ createdAt: (input.now ?? new Date()).toISOString(),
696
+ sourceRunsDir: first.sourceRunsDir,
697
+ containsSensitiveData: true,
698
+ content: first.content,
699
+ };
700
+ // Validate the exact persisted shape before publication; a path-length or
701
+ // enum drift must strand only staging bytes, never an unopenable archive.
702
+ parseV2RunArchiveManifest(manifest);
703
+ const manifestBytes = canonicalFile(manifest);
704
+ writeNewPrivateFile(join(payloadRoot, MANIFEST_FILE), manifestBytes);
705
+ fsyncDirectorySyncPortable(payloadRoot);
706
+ await input.onPhase?.('after-manifest');
707
+ const archiveDir = join(archiveBaseDir, archiveDirectoryName(archiveId));
708
+ let reused = false;
709
+ try {
710
+ const existing = lstatSync(archiveDir);
711
+ if (existing.isSymbolicLink() || !existing.isDirectory()) {
712
+ fail('ARCHIVE_TARGET_UNSAFE', `content-address target is not a real directory: ${archiveDir}`);
713
+ }
714
+ const existingVerification = await verifyV2RunArchive({
715
+ archiveDir,
716
+ allowMissingCommitMarker: true,
717
+ });
718
+ if (!comparableContent(existingVerification.manifest.content, manifest.content)) {
719
+ fail('ARCHIVE_TARGET_CONFLICT', `existing content-address target does not match ${archiveId}`);
720
+ }
721
+ reused = true;
722
+ }
723
+ catch (err) {
724
+ if (err.code !== 'ENOENT')
725
+ throw err;
726
+ renameSync(payloadRoot, archiveDir);
727
+ fsyncDirectorySyncPortable(archiveBaseDir);
728
+ }
729
+ await input.onPhase?.('after-publish');
730
+ const publishedManifestBytes = readSecureFile(join(archiveDir, MANIFEST_FILE));
731
+ const marker = {
732
+ schemaVersion: V2_RUN_ARCHIVE_COMMIT_SCHEMA_VERSION,
733
+ archiveId,
734
+ manifestSha256: sha256Ref(publishedManifestBytes),
735
+ };
736
+ publishCommitMarker(archiveDir, stageDir, marker);
737
+ await input.onPhase?.('after-commit-marker');
738
+ try {
739
+ rmSync(stageDir, { recursive: true, force: true });
740
+ }
741
+ catch { /* committed archive is already durable */ }
742
+ fsyncDirectorySyncPortable(archiveBaseDir);
743
+ const verification = await verifyV2RunArchive({
744
+ archiveDir,
745
+ sourceRunsDir: first.sourceRunsDir,
746
+ });
747
+ return { archiveDir, manifest: verification.manifest, reused, verification };
748
+ });
749
+ }
750
+ function walkArchiveTree(root) {
751
+ assertPlainDirectory(root, 'archive root');
752
+ const directories = [];
753
+ const files = [];
754
+ const visit = (dir, relDir) => {
755
+ assertPlainDirectory(dir, 'archive directory');
756
+ assertPrivateMode(dir, 0o700, 'archive directory');
757
+ for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
758
+ if (entry.name.includes('/') || entry.name.includes('\\') || entry.name === '.' || entry.name === '..') {
759
+ fail('UNSAFE_ARCHIVE_ENTRY', `unsafe archive entry name in ${dir}: ${entry.name}`);
760
+ }
761
+ const absolute = join(dir, entry.name);
762
+ const rel = relDir ? posix.join(relDir, entry.name) : entry.name;
763
+ assertSafeRelativePath(rel, 'archive entry');
764
+ const stat = lstatSync(absolute);
765
+ if (stat.isSymbolicLink())
766
+ fail('ARCHIVE_SYMLINK', `archive contains symlink: ${absolute}`);
767
+ if (stat.isDirectory()) {
768
+ directories.push(rel);
769
+ visit(absolute, rel);
770
+ }
771
+ else if (stat.isFile()) {
772
+ if (stat.nlink !== 1)
773
+ fail('ARCHIVE_HARDLINK', `archive contains hard-linked file: ${absolute}`);
774
+ assertPrivateMode(absolute, 0o600, 'archive file');
775
+ files.push(rel);
776
+ }
777
+ else {
778
+ fail('ARCHIVE_SPECIAL_ENTRY', `archive contains special filesystem entry: ${absolute}`);
779
+ }
780
+ }
781
+ };
782
+ visit(root, '');
783
+ return { directories: directories.sort(), files: files.sort() };
784
+ }
785
+ function assertProjectionMatchesVerdict(archiveDir, run) {
786
+ const path = join(archiveDir, ...run.projectionPath.split('/'));
787
+ let projection;
788
+ try {
789
+ projection = JSON.parse(readSecureFile(path).toString('utf-8'));
790
+ }
791
+ catch (err) {
792
+ fail('ARCHIVE_PROJECTION_INVALID', `${path}: ${err instanceof Error ? err.message : String(err)}`);
793
+ }
794
+ if (projection.runId !== run.runId || projection.run.runId !== run.runId ||
795
+ projection.run.status !== run.verdict.status ||
796
+ (projection.run.workflowId ?? 'unknown') !== run.verdict.workflowId ||
797
+ projection.lastSeq !== run.verdict.lastSeq || projection.updatedAt !== run.verdict.updatedAt)
798
+ fail('ARCHIVE_VERDICT_MISMATCH', `projection and manifest verdict disagree for ${run.runId}`);
799
+ }
800
+ function optionalLstat(path) {
801
+ try {
802
+ return lstatSync(path);
803
+ }
804
+ catch (err) {
805
+ if (err.code === 'ENOENT')
806
+ return undefined;
807
+ throw err;
808
+ }
809
+ }
810
+ function archiveHex(archiveId) {
811
+ const match = /^sha256:([0-9a-f]{64})$/.exec(archiveId);
812
+ if (!match)
813
+ fail('ARCHIVE_ID_INVALID', `invalid archive id ${archiveId}`);
814
+ return match[1];
815
+ }
816
+ function quarantinePathFor(sourceRunsDir, archiveId) {
817
+ return join(dirname(sourceRunsDir), `.${basename(sourceRunsDir)}.retired-${archiveHex(archiveId)}`);
818
+ }
819
+ function retirementReceiptPathFor(archiveBaseDir, archiveId) {
820
+ return join(resolve(archiveBaseDir), `${RETIREMENT_RECEIPT_PREFIX}${archiveHex(archiveId)}.json`);
821
+ }
822
+ function hasRetirementArtifacts(sourcePath, archiveBaseDir) {
823
+ const quarantinePrefix = `.${basename(sourcePath)}.retired-`;
824
+ const sourceParent = dirname(sourcePath);
825
+ const checks = [
826
+ { directory: sourceParent, prefix: quarantinePrefix, label: 'quarantine' },
827
+ { directory: archiveBaseDir, prefix: RETIREMENT_RECEIPT_PREFIX, label: 'receipt' },
828
+ ];
829
+ let found = false;
830
+ for (const check of checks) {
831
+ const stat = optionalLstat(check.directory);
832
+ if (!stat)
833
+ continue;
834
+ if (stat.isSymbolicLink() || !stat.isDirectory()) {
835
+ fail('RETIREMENT_PARENT_UNSAFE', `${check.label} parent must be a real directory: ${check.directory}`);
836
+ }
837
+ for (const entry of readdirSync(check.directory, { withFileTypes: true })) {
838
+ if (!entry.name.startsWith(check.prefix))
839
+ continue;
840
+ const path = join(check.directory, entry.name);
841
+ const artifact = lstatSync(path);
842
+ if (artifact.isSymbolicLink() || (!artifact.isDirectory() && !artifact.isFile())) {
843
+ fail('RETIREMENT_ARTIFACT_UNSAFE', `unsafe ${check.label} artifact: ${path}`);
844
+ }
845
+ found = true;
846
+ }
847
+ }
848
+ return found;
849
+ }
850
+ function expectedRawTree(manifest, rawRoot) {
851
+ if (!manifest.content.payloadDirectories.includes(rawRoot)) {
852
+ fail('ARCHIVE_RAW_ROOT_MISSING', `manifest does not contain raw root ${rawRoot}`);
853
+ }
854
+ const prefix = `${rawRoot}/`;
855
+ return {
856
+ directories: manifest.content.payloadDirectories
857
+ .filter((path) => path.startsWith(prefix))
858
+ .map((path) => path.slice(prefix.length))
859
+ .sort(),
860
+ files: manifest.content.payloadFiles
861
+ .filter((file) => file.path.startsWith(prefix))
862
+ .map((file) => ({
863
+ relativePath: file.path.slice(prefix.length),
864
+ bytes: file.bytes,
865
+ sha256: file.sha256,
866
+ }))
867
+ .sort((a, b) => a.relativePath.localeCompare(b.relativePath)),
868
+ };
869
+ }
870
+ function comparableRawTree(tree) {
871
+ return canonicalJsonStringify({
872
+ directories: tree.directories,
873
+ files: tree.files.map(({ relativePath, bytes, sha256 }) => ({ relativePath, bytes, sha256 })),
874
+ });
875
+ }
876
+ /**
877
+ * Verify relocated bytes without replaying projections.
878
+ *
879
+ * Historical OutputRef.outputPath values are absolute and intentionally
880
+ * remain byte-exact inside the quarantine. Replaying them after rename would
881
+ * reinterpret those paths relative to the new root and create false drift.
882
+ * The two pre-rename source-aware passes already prove projection parity;
883
+ * post-rename recovery must instead prove the complete raw topology/hashes.
884
+ */
885
+ function verifyRelocatedRawSourceAgainstManifest(sourceDir, manifest) {
886
+ assertPlainDirectory(sourceDir, 'retired workflow runs root');
887
+ const expected = new Map();
888
+ for (const run of manifest.content.runs) {
889
+ if (expected.has(run.runId))
890
+ fail('ARCHIVE_SOURCE_TOPOLOGY_MISMATCH', `duplicate source entry ${run.runId}`);
891
+ expected.set(run.runId, { sourceType: 'directory', rawRoot: run.rawRoot });
892
+ }
893
+ for (const residual of manifest.content.residuals) {
894
+ if (expected.has(residual.name))
895
+ fail('ARCHIVE_SOURCE_TOPOLOGY_MISMATCH', `duplicate source entry ${residual.name}`);
896
+ expected.set(residual.name, { sourceType: residual.sourceType, rawRoot: residual.rawRoot });
897
+ }
898
+ const actualNames = readdirSync(sourceDir, { withFileTypes: true })
899
+ .map((entry) => entry.name)
900
+ .sort();
901
+ const expectedNames = [...expected.keys()].sort();
902
+ if (canonicalJsonStringify(actualNames) !== canonicalJsonStringify(expectedNames)) {
903
+ fail('ARCHIVE_SOURCE_TOPOLOGY_MISMATCH', 'retired source top-level entries differ from manifest');
904
+ }
905
+ for (const name of expectedNames) {
906
+ const spec = expected.get(name);
907
+ const path = join(sourceDir, name);
908
+ const stat = lstatSync(path);
909
+ if (stat.isSymbolicLink())
910
+ fail('SOURCE_SYMLINK', `retired source contains symlink: ${path}`);
911
+ let captured;
912
+ if (spec.sourceType === 'directory') {
913
+ if (!stat.isDirectory())
914
+ fail('ARCHIVE_SOURCE_TOPOLOGY_MISMATCH', `${name} must remain a directory`);
915
+ captured = captureDirectoryTree(path);
916
+ }
917
+ else {
918
+ if (!stat.isFile())
919
+ fail('ARCHIVE_SOURCE_TOPOLOGY_MISMATCH', `${name} must remain a regular file`);
920
+ captured = captureTopFile(path, name);
921
+ }
922
+ const expectedTree = expectedRawTree(manifest, spec.rawRoot);
923
+ if (comparableRawTree(captured) !== canonicalJsonStringify(expectedTree)) {
924
+ fail('ARCHIVE_SOURCE_CHANGED', `retired source bytes/topology differ for ${name}`);
925
+ }
926
+ }
927
+ }
928
+ function readRetirementReceipt(path) {
929
+ const stat = lstatSync(path);
930
+ if (stat.isSymbolicLink() || !stat.isFile() || stat.nlink !== 1) {
931
+ fail('RETIREMENT_RECEIPT_UNSAFE', `receipt must be a single-link regular file: ${path}`);
932
+ }
933
+ assertPrivateMode(path, 0o600, 'retirement receipt');
934
+ try {
935
+ return parseV2RunRetirementReceipt(JSON.parse(readSecureFile(path).toString('utf-8')));
936
+ }
937
+ catch (err) {
938
+ if (err instanceof V2RunArchiveError)
939
+ throw err;
940
+ fail('RETIREMENT_RECEIPT_INVALID', `${path}: ${err instanceof Error ? err.message : String(err)}`);
941
+ }
942
+ }
943
+ function assertReceiptMatches(receipt, expected) {
944
+ for (const key of [
945
+ 'schemaVersion',
946
+ 'kind',
947
+ 'archiveId',
948
+ 'manifestSha256',
949
+ 'sourceRunsDir',
950
+ 'quarantineDir',
951
+ ]) {
952
+ if (receipt[key] !== expected[key]) {
953
+ fail('RETIREMENT_RECEIPT_CONFLICT', `receipt ${key} does not match the verified retirement`);
954
+ }
955
+ }
956
+ }
957
+ function publishRetirementReceipt(receiptPath, expected, now) {
958
+ const existing = optionalLstat(receiptPath);
959
+ if (existing) {
960
+ const receipt = readRetirementReceipt(receiptPath);
961
+ assertReceiptMatches(receipt, expected);
962
+ return { receipt, reused: true };
963
+ }
964
+ const receipt = {
965
+ ...expected,
966
+ retiredAt: now.toISOString(),
967
+ };
968
+ parseV2RunRetirementReceipt(receipt);
969
+ const bytes = canonicalFile(receipt);
970
+ const tmp = join(dirname(receiptPath), `.${basename(receiptPath)}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`);
971
+ try {
972
+ writeNewPrivateFile(tmp, bytes);
973
+ try {
974
+ linkSync(tmp, receiptPath);
975
+ unlinkSync(tmp);
976
+ fsyncDirectorySyncPortable(dirname(receiptPath));
977
+ return { receipt, reused: false };
978
+ }
979
+ catch (err) {
980
+ if (err.code !== 'EEXIST')
981
+ throw err;
982
+ unlinkSync(tmp);
983
+ const raced = readRetirementReceipt(receiptPath);
984
+ assertReceiptMatches(raced, expected);
985
+ return { receipt: raced, reused: true };
986
+ }
987
+ }
988
+ finally {
989
+ try {
990
+ unlinkSync(tmp);
991
+ }
992
+ catch { /* best effort */ }
993
+ }
994
+ }
995
+ /**
996
+ * Linearize v2 run-source retirement without deleting bytes.
997
+ *
998
+ * The advisory publication lock coordinates Botmux archive/retire commands,
999
+ * but it cannot stop an old daemon from appending to an already-open journal.
1000
+ * Therefore non-empty retirement additionally requires an explicit operator
1001
+ * acknowledgement that all v2 writers are stopped, verifies source parity
1002
+ * twice immediately before rename, and verifies the relocated tree once more.
1003
+ */
1004
+ export async function retireV2RunSource(input) {
1005
+ const archiveBaseDir = resolve(input.archiveBaseDir);
1006
+ const sourceInput = resolve(input.runsDir);
1007
+ const archiveDir = resolve(input.archiveDir);
1008
+ const initialSourceStat = optionalLstat(sourceInput);
1009
+ if (initialSourceStat && (initialSourceStat.isSymbolicLink() || !initialSourceStat.isDirectory())) {
1010
+ fail('UNSAFE_DIRECTORY', `workflow runs root must be a real directory: ${sourceInput}`);
1011
+ }
1012
+ const initiallyEmpty = !initialSourceStat || readdirSync(sourceInput).length === 0;
1013
+ // A fresh install has no archive contract to verify and retirement should
1014
+ // be a genuine zero-write no-op. Only enter the publication transaction
1015
+ // when live bytes or a prior quarantine/receipt prove there is work.
1016
+ if (initiallyEmpty && !hasRetirementArtifacts(sourceInput, archiveBaseDir)) {
1017
+ return { status: 'nothing_to_retire', sourceRunsDir: realpathProspective(sourceInput) };
1018
+ }
1019
+ ensureDisjoint(sourceInput, archiveBaseDir);
1020
+ ensureDisjoint(realpathProspective(sourceInput), realpathProspective(archiveBaseDir));
1021
+ ensurePrivateArchiveBase(archiveBaseDir);
1022
+ return withV2RunArchivePublicationLock(archiveBaseDir, async () => {
1023
+ const archiveStat = optionalLstat(archiveDir);
1024
+ const sourceStat = optionalLstat(sourceInput);
1025
+ if (sourceStat && (sourceStat.isSymbolicLink() || !sourceStat.isDirectory())) {
1026
+ fail('UNSAFE_DIRECTORY', `workflow runs root must be a real directory: ${sourceInput}`);
1027
+ }
1028
+ if (!archiveStat) {
1029
+ if (!sourceStat || readdirSync(sourceInput).length === 0) {
1030
+ fail('RETIREMENT_STATE_REQUIRES_ARCHIVE', 'found a retirement quarantine/receipt but the referenced committed archive is missing');
1031
+ }
1032
+ fail('RETIREMENT_ARCHIVE_REQUIRED', `non-empty v2 source requires a committed archive: ${archiveDir}`);
1033
+ }
1034
+ if (archiveStat.isSymbolicLink() || !archiveStat.isDirectory()) {
1035
+ fail('ARCHIVE_TARGET_UNSAFE', `retirement archive must be a real directory: ${archiveDir}`);
1036
+ }
1037
+ if (dirname(archiveDir) !== archiveBaseDir) {
1038
+ fail('RETIREMENT_ARCHIVE_OUTSIDE_BASE', `retirement archive must be a direct child of ${archiveBaseDir}`);
1039
+ }
1040
+ const staticVerification = await verifyV2RunArchive({ archiveDir });
1041
+ const manifest = staticVerification.manifest;
1042
+ const expectedSourcePath = realpathProspective(sourceInput);
1043
+ if (expectedSourcePath !== manifest.sourceRunsDir) {
1044
+ fail('ARCHIVE_SOURCE_MISMATCH', `manifest source ${manifest.sourceRunsDir} != requested source ${expectedSourcePath}`);
1045
+ }
1046
+ const quarantineDir = quarantinePathFor(manifest.sourceRunsDir, manifest.archiveId);
1047
+ const receiptPath = retirementReceiptPathFor(archiveBaseDir, manifest.archiveId);
1048
+ const quarantineStat = optionalLstat(quarantineDir);
1049
+ const receiptStat = optionalLstat(receiptPath);
1050
+ if (quarantineStat && (quarantineStat.isSymbolicLink() || !quarantineStat.isDirectory())) {
1051
+ fail('RETIREMENT_QUARANTINE_UNSAFE', `quarantine must be a real directory: ${quarantineDir}`);
1052
+ }
1053
+ if (receiptStat && (receiptStat.isSymbolicLink() || !receiptStat.isFile() || receiptStat.nlink !== 1)) {
1054
+ fail('RETIREMENT_RECEIPT_UNSAFE', `receipt must be a single-link regular file: ${receiptPath}`);
1055
+ }
1056
+ if (sourceStat && quarantineStat) {
1057
+ fail('RETIREMENT_SOURCE_RESURRECTED', `source and quarantine both exist; an old writer may still be active`);
1058
+ }
1059
+ if ((!sourceStat || readdirSync(sourceInput).length === 0) &&
1060
+ !quarantineStat && !receiptStat &&
1061
+ hasRetirementArtifacts(sourceInput, archiveBaseDir)) {
1062
+ fail('RETIREMENT_STATE_REQUIRES_ARCHIVE', 'existing retirement artifacts do not belong to the selected committed archive');
1063
+ }
1064
+ if (sourceStat && readdirSync(sourceInput).length === 0) {
1065
+ if (receiptStat)
1066
+ fail('RETIREMENT_RECEIPT_WITH_LIVE_SOURCE', `receipt exists while source directory is present`);
1067
+ return { status: 'nothing_to_retire', sourceRunsDir: realpathSync(sourceInput) };
1068
+ }
1069
+ if (!sourceStat && !quarantineStat) {
1070
+ if (receiptStat)
1071
+ fail('RETIREMENT_QUARANTINE_MISSING', `receipt exists but quarantine is missing`);
1072
+ return { status: 'nothing_to_retire', sourceRunsDir: expectedSourcePath };
1073
+ }
1074
+ if (!input.daemonStoppedAcknowledged) {
1075
+ fail('DAEMON_STOP_ACK_REQUIRED', 'non-empty v2 retirement requires --ack-daemon-stopped; the archive lock does not exclude old daemon writers');
1076
+ }
1077
+ const manifestSha256 = sha256Ref(readSecureFile(join(archiveDir, MANIFEST_FILE)));
1078
+ const expectedReceipt = {
1079
+ schemaVersion: V2_RUN_RETIREMENT_SCHEMA_VERSION,
1080
+ kind: V2_RUN_RETIREMENT_KIND,
1081
+ archiveId: manifest.archiveId,
1082
+ manifestSha256,
1083
+ sourceRunsDir: manifest.sourceRunsDir,
1084
+ quarantineDir,
1085
+ };
1086
+ if (!sourceStat) {
1087
+ verifyRelocatedRawSourceAgainstManifest(quarantineDir, manifest);
1088
+ chmodSync(quarantineDir, 0o700);
1089
+ fsyncDirectorySyncPortable(dirname(quarantineDir));
1090
+ const published = publishRetirementReceipt(receiptPath, expectedReceipt, input.now ?? new Date());
1091
+ await input.onPhase?.('after-retirement-receipt');
1092
+ return {
1093
+ status: published.reused ? 'already_retired' : 'retired',
1094
+ archiveDir,
1095
+ quarantineDir,
1096
+ receiptPath,
1097
+ receipt: published.receipt,
1098
+ verification: { ...staticVerification, sourceVerified: true },
1099
+ };
1100
+ }
1101
+ if (receiptStat) {
1102
+ fail('RETIREMENT_RECEIPT_WITH_LIVE_SOURCE', `receipt exists while source directory is present`);
1103
+ }
1104
+ await verifyV2RunArchive({
1105
+ archiveDir,
1106
+ sourceRunsDir: sourceInput,
1107
+ });
1108
+ await input.onPhase?.('after-first-source-verification');
1109
+ const secondVerification = await verifyV2RunArchive({
1110
+ archiveDir,
1111
+ sourceRunsDir: sourceInput,
1112
+ });
1113
+ await input.onPhase?.('before-source-rename');
1114
+ renameSync(sourceInput, quarantineDir);
1115
+ fsyncDirectorySyncPortable(dirname(sourceInput));
1116
+ await input.onPhase?.('after-source-rename');
1117
+ chmodSync(quarantineDir, 0o700);
1118
+ verifyRelocatedRawSourceAgainstManifest(quarantineDir, manifest);
1119
+ fsyncDirectorySyncPortable(dirname(quarantineDir));
1120
+ await input.onPhase?.('after-quarantine-verification');
1121
+ const published = publishRetirementReceipt(receiptPath, expectedReceipt, input.now ?? new Date());
1122
+ await input.onPhase?.('after-retirement-receipt');
1123
+ return {
1124
+ status: 'retired',
1125
+ archiveDir,
1126
+ quarantineDir,
1127
+ receiptPath,
1128
+ receipt: published.receipt,
1129
+ verification: secondVerification,
1130
+ };
1131
+ });
1132
+ }
1133
+ export async function verifyV2RunArchive(input) {
1134
+ const archiveDir = resolve(input.archiveDir);
1135
+ assertPlainDirectory(archiveDir, 'archive root');
1136
+ const manifestPath = join(archiveDir, MANIFEST_FILE);
1137
+ const manifestBytes = readSecureFile(manifestPath);
1138
+ let manifest;
1139
+ try {
1140
+ manifest = parseV2RunArchiveManifest(JSON.parse(manifestBytes.toString('utf-8')));
1141
+ }
1142
+ catch (err) {
1143
+ fail('ARCHIVE_MANIFEST_INVALID', `${manifestPath}: ${err instanceof Error ? err.message : String(err)}`);
1144
+ }
1145
+ if (v2RunArchiveId(manifest.content) !== manifest.archiveId) {
1146
+ fail('ARCHIVE_ID_MISMATCH', `manifest content does not derive ${manifest.archiveId}`);
1147
+ }
1148
+ if (basename(archiveDir) !== archiveDirectoryName(manifest.archiveId)) {
1149
+ fail('ARCHIVE_DIRECTORY_MISMATCH', `archive directory name does not match ${manifest.archiveId}`);
1150
+ }
1151
+ assertUnique(manifest.content.payloadDirectories, 'manifest payload directory');
1152
+ assertUnique(manifest.content.payloadFiles.map((file) => file.path), 'manifest payload file');
1153
+ assertUnique(manifest.content.runs.map((run) => run.runId), 'manifest runId');
1154
+ assertUnique(manifest.content.residuals.map((residual) => residual.name), 'manifest residual name');
1155
+ const tree = walkArchiveTree(archiveDir);
1156
+ const expectedDirectories = [...manifest.content.payloadDirectories].sort();
1157
+ if (canonicalJsonStringify(tree.directories) !== canonicalJsonStringify(expectedDirectories)) {
1158
+ fail('ARCHIVE_DIRECTORY_TOPOLOGY_MISMATCH', 'archive directory topology differs from manifest');
1159
+ }
1160
+ const expectedFiles = [...manifest.content.payloadFiles.map((file) => file.path), MANIFEST_FILE];
1161
+ const hasCommitMarker = tree.files.includes(COMMIT_FILE);
1162
+ if (hasCommitMarker)
1163
+ expectedFiles.push(COMMIT_FILE);
1164
+ if (!hasCommitMarker && !input.allowMissingCommitMarker) {
1165
+ fail('ARCHIVE_NOT_COMMITTED', `${archiveDir} has no ${COMMIT_FILE} marker`);
1166
+ }
1167
+ expectedFiles.sort();
1168
+ if (canonicalJsonStringify(tree.files) !== canonicalJsonStringify(expectedFiles)) {
1169
+ fail('ARCHIVE_FILE_TOPOLOGY_MISMATCH', 'archive file topology differs from manifest');
1170
+ }
1171
+ let totalBytes = 0;
1172
+ for (const expected of manifest.content.payloadFiles) {
1173
+ const absolute = join(archiveDir, ...expected.path.split('/'));
1174
+ assertPathInside(archiveDir, absolute, 'manifest payload file');
1175
+ const actual = hashSecureFile(absolute);
1176
+ if (actual.bytes !== expected.bytes || actual.sha256 !== expected.sha256) {
1177
+ fail('ARCHIVE_FILE_HASH_MISMATCH', `${expected.path} differs from its manifest digest`);
1178
+ }
1179
+ totalBytes += actual.bytes;
1180
+ }
1181
+ for (const run of manifest.content.runs) {
1182
+ const projected = manifest.content.payloadFiles.find((file) => file.path === run.projectionPath);
1183
+ if (!projected || projected.sha256 !== run.projectionSha256) {
1184
+ fail('ARCHIVE_PROJECTION_HASH_MISMATCH', `projection file record is inconsistent for ${run.runId}`);
1185
+ }
1186
+ assertProjectionMatchesVerdict(archiveDir, run);
1187
+ }
1188
+ if (hasCommitMarker) {
1189
+ let marker;
1190
+ try {
1191
+ marker = parseV2RunArchiveCommitMarker(JSON.parse(readSecureFile(join(archiveDir, COMMIT_FILE)).toString('utf-8')));
1192
+ }
1193
+ catch (err) {
1194
+ fail('COMMIT_MARKER_INVALID', `${archiveDir}: ${err instanceof Error ? err.message : String(err)}`);
1195
+ }
1196
+ if (marker.archiveId !== manifest.archiveId || marker.manifestSha256 !== sha256Ref(manifestBytes)) {
1197
+ fail('COMMIT_MARKER_MISMATCH', `${COMMIT_FILE} does not authenticate manifest.json`);
1198
+ }
1199
+ }
1200
+ let sourceVerified = false;
1201
+ if (input.sourceRunsDir) {
1202
+ const live = await captureSource(input.sourceRunsDir);
1203
+ if (live.sourceRunsDir !== manifest.sourceRunsDir) {
1204
+ fail('ARCHIVE_SOURCE_MISMATCH', `manifest source ${manifest.sourceRunsDir} != live source ${live.sourceRunsDir}`);
1205
+ }
1206
+ if (!comparableContent(live.content, manifest.content)) {
1207
+ fail('ARCHIVE_SOURCE_CHANGED', 'live source bytes or current ops projections differ from the archive');
1208
+ }
1209
+ sourceVerified = true;
1210
+ }
1211
+ return {
1212
+ archiveDir,
1213
+ manifest,
1214
+ staticVerified: true,
1215
+ sourceVerified,
1216
+ fileCount: manifest.content.payloadFiles.length,
1217
+ totalBytes,
1218
+ };
1219
+ }
1220
+ //# sourceMappingURL=v2-run-archive.js.map