@bastani/atomic 0.9.8 → 0.9.9-alpha.1

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 (348) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +6 -0
  3. package/dist/builtin/cursor/package.json +2 -2
  4. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  5. package/dist/builtin/intercom/package.json +1 -1
  6. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  9. package/dist/builtin/subagents/package.json +1 -1
  10. package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +2 -0
  11. package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +7 -1
  12. package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
  13. package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +8 -2
  14. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +2 -0
  15. package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +2 -0
  16. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +2 -1
  17. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +2 -0
  18. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
  19. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
  20. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
  21. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +6 -0
  22. package/dist/builtin/subagents/src/shared/types-config.ts +4 -0
  23. package/dist/builtin/subagents/src/shared/types-depth.ts +29 -2
  24. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  25. package/dist/builtin/web-access/package.json +1 -1
  26. package/dist/builtin/workflows/CHANGELOG.md +22 -0
  27. package/dist/builtin/workflows/README.md +17 -8
  28. package/dist/builtin/workflows/builtin/goal-prompts.ts +8 -2
  29. package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +26 -9
  30. package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +1 -1
  31. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +8 -3
  32. package/dist/builtin/workflows/builtin/ralph-runner.ts +2 -0
  33. package/dist/builtin/workflows/builtin/shared-prompts.ts +24 -1
  34. package/dist/builtin/workflows/package.json +1 -1
  35. package/dist/builtin/workflows/src/durable/backend.ts +53 -15
  36. package/dist/builtin/workflows/src/durable/completed-catalog.ts +245 -0
  37. package/dist/builtin/workflows/src/durable/completed-inspection.ts +213 -0
  38. package/dist/builtin/workflows/src/durable/dbos-backend.ts +120 -170
  39. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +84 -8
  40. package/dist/builtin/workflows/src/durable/dbos-metadata.ts +98 -0
  41. package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +27 -0
  42. package/dist/builtin/workflows/src/durable/factory.ts +1 -1
  43. package/dist/builtin/workflows/src/durable/file-backend.ts +247 -241
  44. package/dist/builtin/workflows/src/durable/file-lock.ts +153 -0
  45. package/dist/builtin/workflows/src/durable/file-state.ts +104 -0
  46. package/dist/builtin/workflows/src/durable/format-version.ts +12 -0
  47. package/dist/builtin/workflows/src/durable/index.ts +12 -0
  48. package/dist/builtin/workflows/src/durable/resume-catalog.ts +16 -27
  49. package/dist/builtin/workflows/src/durable/resume-eligibility.ts +20 -0
  50. package/dist/builtin/workflows/src/durable/resume-runtime.ts +29 -29
  51. package/dist/builtin/workflows/src/durable/scoped-backend.ts +20 -3
  52. package/dist/builtin/workflows/src/durable/stage-primitive.ts +29 -8
  53. package/dist/builtin/workflows/src/durable/types.ts +3 -0
  54. package/dist/builtin/workflows/src/engine/primitives/task.ts +1 -0
  55. package/dist/builtin/workflows/src/engine/run.ts +14 -14
  56. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +39 -9
  57. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +10 -0
  58. package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +133 -0
  59. package/dist/builtin/workflows/src/extension/runtime.ts +15 -40
  60. package/dist/builtin/workflows/src/extension/wiring.ts +9 -6
  61. package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +226 -0
  62. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +1 -0
  63. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +66 -112
  64. package/dist/builtin/workflows/src/extension/workflow-schema.ts +5 -5
  65. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +16 -1
  66. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +50 -43
  67. package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +91 -0
  68. package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +95 -46
  69. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +3 -1
  70. package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +1 -1
  71. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +3 -0
  72. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +1 -1
  73. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +36 -7
  74. package/dist/builtin/workflows/src/runs/shared/worktree-cache-lifecycle.ts +25 -0
  75. package/dist/builtin/workflows/src/runs/shared/worktree-cwd.ts +103 -0
  76. package/dist/builtin/workflows/src/runs/shared/worktree-generation.ts +57 -0
  77. package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +134 -8
  78. package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -0
  79. package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +43 -0
  80. package/dist/builtin/workflows/src/shared/timing.ts +4 -0
  81. package/dist/builtin/workflows/src/shared/types.ts +5 -3
  82. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -0
  83. package/dist/builtin/workflows/src/tui/graph-view-input.ts +24 -14
  84. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +43 -13
  85. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  86. package/dist/core/agent-session-auto-compaction.js +5 -7
  87. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  88. package/dist/core/agent-session-compaction.d.ts +6 -34
  89. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  90. package/dist/core/agent-session-compaction.js +95 -233
  91. package/dist/core/agent-session-compaction.js.map +1 -1
  92. package/dist/core/agent-session-message-queue.d.ts +0 -4
  93. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  94. package/dist/core/agent-session-message-queue.js +1 -5
  95. package/dist/core/agent-session-message-queue.js.map +1 -1
  96. package/dist/core/agent-session-methods.d.ts +5 -6
  97. package/dist/core/agent-session-methods.d.ts.map +1 -1
  98. package/dist/core/agent-session-methods.js.map +1 -1
  99. package/dist/core/agent-session-types.d.ts +2 -12
  100. package/dist/core/agent-session-types.d.ts.map +1 -1
  101. package/dist/core/agent-session-types.js.map +1 -1
  102. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  103. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  104. package/dist/core/compaction/branch-summarization.js +1 -2
  105. package/dist/core/compaction/branch-summarization.js.map +1 -1
  106. package/dist/core/compaction/compaction-boundary.d.ts +9 -0
  107. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -0
  108. package/dist/core/compaction/compaction-boundary.js +115 -0
  109. package/dist/core/compaction/compaction-boundary.js.map +1 -0
  110. package/dist/core/compaction/compaction-parameters.d.ts +5 -0
  111. package/dist/core/compaction/compaction-parameters.d.ts.map +1 -0
  112. package/dist/core/compaction/compaction-parameters.js +27 -0
  113. package/dist/core/compaction/compaction-parameters.js.map +1 -0
  114. package/dist/core/compaction/compaction-runner.d.ts +14 -0
  115. package/dist/core/compaction/compaction-runner.d.ts.map +1 -0
  116. package/dist/core/compaction/compaction-runner.js +29 -0
  117. package/dist/core/compaction/compaction-runner.js.map +1 -0
  118. package/dist/core/compaction/compaction-types.d.ts +79 -0
  119. package/dist/core/compaction/compaction-types.d.ts.map +1 -0
  120. package/dist/core/compaction/compaction-types.js +6 -0
  121. package/dist/core/compaction/compaction-types.js.map +1 -0
  122. package/dist/core/compaction/deleted-ranges.d.ts +6 -0
  123. package/dist/core/compaction/deleted-ranges.d.ts.map +1 -0
  124. package/dist/core/compaction/deleted-ranges.js +134 -0
  125. package/dist/core/compaction/deleted-ranges.js.map +1 -0
  126. package/dist/core/compaction/index.d.ts +7 -1
  127. package/dist/core/compaction/index.d.ts.map +1 -1
  128. package/dist/core/compaction/index.js +7 -1
  129. package/dist/core/compaction/index.js.map +1 -1
  130. package/dist/core/compaction/range-planner.d.ts +21 -0
  131. package/dist/core/compaction/range-planner.d.ts.map +1 -0
  132. package/dist/core/compaction/range-planner.js +145 -0
  133. package/dist/core/compaction/range-planner.js.map +1 -0
  134. package/dist/core/compaction/transcript-serialization.d.ts +11 -0
  135. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -0
  136. package/dist/core/compaction/transcript-serialization.js +104 -0
  137. package/dist/core/compaction/transcript-serialization.js.map +1 -0
  138. package/dist/core/extensions/context-types.d.ts +2 -2
  139. package/dist/core/extensions/context-types.d.ts.map +1 -1
  140. package/dist/core/extensions/context-types.js.map +1 -1
  141. package/dist/core/extensions/event-results.d.ts +2 -2
  142. package/dist/core/extensions/event-results.d.ts.map +1 -1
  143. package/dist/core/extensions/event-results.js.map +1 -1
  144. package/dist/core/extensions/session-events.d.ts +7 -7
  145. package/dist/core/extensions/session-events.d.ts.map +1 -1
  146. package/dist/core/extensions/session-events.js.map +1 -1
  147. package/dist/core/index.d.ts +1 -1
  148. package/dist/core/index.d.ts.map +1 -1
  149. package/dist/core/index.js.map +1 -1
  150. package/dist/core/messages.d.ts +4 -0
  151. package/dist/core/messages.d.ts.map +1 -1
  152. package/dist/core/messages.js +11 -0
  153. package/dist/core/messages.js.map +1 -1
  154. package/dist/core/provider-context-usage.d.ts.map +1 -1
  155. package/dist/core/provider-context-usage.js +1 -2
  156. package/dist/core/provider-context-usage.js.map +1 -1
  157. package/dist/core/session-manager-archive.d.ts +2 -1
  158. package/dist/core/session-manager-archive.d.ts.map +1 -1
  159. package/dist/core/session-manager-archive.js +2 -2
  160. package/dist/core/session-manager-archive.js.map +1 -1
  161. package/dist/core/session-manager-classification.d.ts +9 -0
  162. package/dist/core/session-manager-classification.d.ts.map +1 -0
  163. package/dist/core/session-manager-classification.js +37 -0
  164. package/dist/core/session-manager-classification.js.map +1 -0
  165. package/dist/core/session-manager-core.d.ts +4 -4
  166. package/dist/core/session-manager-core.d.ts.map +1 -1
  167. package/dist/core/session-manager-core.js +13 -8
  168. package/dist/core/session-manager-core.js.map +1 -1
  169. package/dist/core/session-manager-entries.d.ts +4 -3
  170. package/dist/core/session-manager-entries.d.ts.map +1 -1
  171. package/dist/core/session-manager-entries.js +12 -10
  172. package/dist/core/session-manager-entries.js.map +1 -1
  173. package/dist/core/session-manager-history.d.ts +6 -23
  174. package/dist/core/session-manager-history.d.ts.map +1 -1
  175. package/dist/core/session-manager-history.js +23 -256
  176. package/dist/core/session-manager-history.js.map +1 -1
  177. package/dist/core/session-manager-list.d.ts.map +1 -1
  178. package/dist/core/session-manager-list.js +3 -3
  179. package/dist/core/session-manager-list.js.map +1 -1
  180. package/dist/core/session-manager-storage.d.ts +1 -1
  181. package/dist/core/session-manager-storage.d.ts.map +1 -1
  182. package/dist/core/session-manager-storage.js +3 -2
  183. package/dist/core/session-manager-storage.js.map +1 -1
  184. package/dist/core/session-manager-types.d.ts +14 -15
  185. package/dist/core/session-manager-types.d.ts.map +1 -1
  186. package/dist/core/session-manager-types.js.map +1 -1
  187. package/dist/core/session-manager.d.ts +3 -2
  188. package/dist/core/session-manager.d.ts.map +1 -1
  189. package/dist/core/session-manager.js +1 -1
  190. package/dist/core/session-manager.js.map +1 -1
  191. package/dist/core/slash-commands.d.ts.map +1 -1
  192. package/dist/core/slash-commands.js +1 -1
  193. package/dist/core/slash-commands.js.map +1 -1
  194. package/dist/index.d.ts +3 -2
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +2 -1
  197. package/dist/index.js.map +1 -1
  198. package/dist/main-session.d.ts +1 -0
  199. package/dist/main-session.d.ts.map +1 -1
  200. package/dist/main-session.js +7 -0
  201. package/dist/main-session.js.map +1 -1
  202. package/dist/main.d.ts.map +1 -1
  203. package/dist/main.js +2 -2
  204. package/dist/main.js.map +1 -1
  205. package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -1
  206. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  207. package/dist/modes/interactive/components/chat-message-renderer.js +12 -22
  208. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  209. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  210. package/dist/modes/interactive/components/chat-session-host-events.js +5 -11
  211. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  212. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  213. package/dist/modes/interactive/components/chat-session-host-rendering.js +3 -0
  214. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  215. package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
  216. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  217. package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
  218. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  219. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  220. package/dist/modes/interactive/components/chat-session-host-utils.js +1 -1
  221. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  222. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  223. package/dist/modes/interactive/components/chat-session-host.js +1 -0
  224. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  225. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +20 -0
  226. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -0
  227. package/dist/modes/interactive/components/compaction-boundary-message.js +48 -0
  228. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -0
  229. package/dist/modes/interactive/components/index.d.ts +1 -1
  230. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  231. package/dist/modes/interactive/components/index.js +1 -1
  232. package/dist/modes/interactive/components/index.js.map +1 -1
  233. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  234. package/dist/modes/interactive/components/session-selector-list.js +3 -0
  235. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  236. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  237. package/dist/modes/interactive/interactive-agent-events.js +3 -47
  238. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  239. package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
  240. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  241. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  242. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  243. package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -3
  244. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  245. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  246. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  247. package/dist/modes/interactive/interactive-render-chat.js +21 -12
  248. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  249. package/dist/modes/rpc/rpc-client.d.ts +3 -5
  250. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  251. package/dist/modes/rpc/rpc-client.js +1 -6
  252. package/dist/modes/rpc/rpc-client.js.map +1 -1
  253. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  254. package/dist/modes/rpc/rpc-command-handler.js +0 -4
  255. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  256. package/dist/modes/rpc/rpc-types.d.ts +2 -11
  257. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  258. package/dist/modes/rpc/rpc-types.js.map +1 -1
  259. package/docs/compaction.md +97 -772
  260. package/docs/extensions.md +25 -29
  261. package/docs/json.md +2 -2
  262. package/docs/rpc.md +32 -24
  263. package/docs/sdk.md +3 -3
  264. package/docs/session-format.md +49 -30
  265. package/docs/sessions.md +5 -3
  266. package/docs/settings.md +14 -4
  267. package/docs/usage.md +1 -1
  268. package/docs/workflows.md +30 -15
  269. package/examples/extensions/custom-compaction.ts +14 -58
  270. package/examples/extensions/handoff.ts +2 -3
  271. package/npm-shrinkwrap.json +23 -23
  272. package/package.json +2 -2
  273. package/dist/core/compaction/context-assistant-turns.d.ts +0 -42
  274. package/dist/core/compaction/context-assistant-turns.d.ts.map +0 -1
  275. package/dist/core/compaction/context-assistant-turns.js +0 -87
  276. package/dist/core/compaction/context-assistant-turns.js.map +0 -1
  277. package/dist/core/compaction/context-compaction-critical.d.ts +0 -15
  278. package/dist/core/compaction/context-compaction-critical.d.ts.map +0 -1
  279. package/dist/core/compaction/context-compaction-critical.js +0 -57
  280. package/dist/core/compaction/context-compaction-critical.js.map +0 -1
  281. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +0 -18
  282. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +0 -1
  283. package/dist/core/compaction/context-compaction-eviction-alternates.js +0 -186
  284. package/dist/core/compaction/context-compaction-eviction-alternates.js.map +0 -1
  285. package/dist/core/compaction/context-compaction-eviction.d.ts +0 -12
  286. package/dist/core/compaction/context-compaction-eviction.d.ts.map +0 -1
  287. package/dist/core/compaction/context-compaction-eviction.js +0 -222
  288. package/dist/core/compaction/context-compaction-eviction.js.map +0 -1
  289. package/dist/core/compaction/context-compaction-metrics.d.ts +0 -28
  290. package/dist/core/compaction/context-compaction-metrics.d.ts.map +0 -1
  291. package/dist/core/compaction/context-compaction-metrics.js +0 -107
  292. package/dist/core/compaction/context-compaction-metrics.js.map +0 -1
  293. package/dist/core/compaction/context-compaction-prompt.d.ts +0 -9
  294. package/dist/core/compaction/context-compaction-prompt.d.ts.map +0 -1
  295. package/dist/core/compaction/context-compaction-prompt.js +0 -163
  296. package/dist/core/compaction/context-compaction-prompt.js.map +0 -1
  297. package/dist/core/compaction/context-compaction-runner.d.ts +0 -11
  298. package/dist/core/compaction/context-compaction-runner.d.ts.map +0 -1
  299. package/dist/core/compaction/context-compaction-runner.js +0 -273
  300. package/dist/core/compaction/context-compaction-runner.js.map +0 -1
  301. package/dist/core/compaction/context-compaction-strategy.d.ts +0 -5
  302. package/dist/core/compaction/context-compaction-strategy.d.ts.map +0 -1
  303. package/dist/core/compaction/context-compaction-strategy.js +0 -27
  304. package/dist/core/compaction/context-compaction-strategy.js.map +0 -1
  305. package/dist/core/compaction/context-compaction-types.d.ts +0 -75
  306. package/dist/core/compaction/context-compaction-types.d.ts.map +0 -1
  307. package/dist/core/compaction/context-compaction-types.js +0 -6
  308. package/dist/core/compaction/context-compaction-types.js.map +0 -1
  309. package/dist/core/compaction/context-compaction.d.ts +0 -10
  310. package/dist/core/compaction/context-compaction.d.ts.map +0 -1
  311. package/dist/core/compaction/context-compaction.js +0 -8
  312. package/dist/core/compaction/context-compaction.js.map +0 -1
  313. package/dist/core/compaction/context-deletion-application.d.ts +0 -14
  314. package/dist/core/compaction/context-deletion-application.d.ts.map +0 -1
  315. package/dist/core/compaction/context-deletion-application.js +0 -261
  316. package/dist/core/compaction/context-deletion-application.js.map +0 -1
  317. package/dist/core/compaction/context-deletion-store.d.ts +0 -78
  318. package/dist/core/compaction/context-deletion-store.d.ts.map +0 -1
  319. package/dist/core/compaction/context-deletion-store.js +0 -162
  320. package/dist/core/compaction/context-deletion-store.js.map +0 -1
  321. package/dist/core/compaction/context-deletion-targets.d.ts +0 -43
  322. package/dist/core/compaction/context-deletion-targets.d.ts.map +0 -1
  323. package/dist/core/compaction/context-deletion-targets.js +0 -292
  324. package/dist/core/compaction/context-deletion-targets.js.map +0 -1
  325. package/dist/core/compaction/context-deletion-tool-definitions.d.ts +0 -193
  326. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +0 -1
  327. package/dist/core/compaction/context-deletion-tool-definitions.js +0 -98
  328. package/dist/core/compaction/context-deletion-tool-definitions.js.map +0 -1
  329. package/dist/core/compaction/context-deletion-tool-helpers.d.ts +0 -19
  330. package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +0 -1
  331. package/dist/core/compaction/context-deletion-tool-helpers.js +0 -210
  332. package/dist/core/compaction/context-deletion-tool-helpers.js.map +0 -1
  333. package/dist/core/compaction/context-deletion-tools.d.ts +0 -4
  334. package/dist/core/compaction/context-deletion-tools.d.ts.map +0 -1
  335. package/dist/core/compaction/context-deletion-tools.js +0 -403
  336. package/dist/core/compaction/context-deletion-tools.js.map +0 -1
  337. package/dist/core/compaction/context-transcript-analysis.d.ts +0 -11
  338. package/dist/core/compaction/context-transcript-analysis.d.ts.map +0 -1
  339. package/dist/core/compaction/context-transcript-analysis.js +0 -228
  340. package/dist/core/compaction/context-transcript-analysis.js.map +0 -1
  341. package/dist/core/session-manager-tool-dependencies.d.ts +0 -10
  342. package/dist/core/session-manager-tool-dependencies.d.ts.map +0 -1
  343. package/dist/core/session-manager-tool-dependencies.js +0 -133
  344. package/dist/core/session-manager-tool-dependencies.js.map +0 -1
  345. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +0 -17
  346. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +0 -1
  347. package/dist/modes/interactive/components/context-compaction-summary-message.js +0 -83
  348. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +0 -1
@@ -23,9 +23,10 @@ import type {
23
23
  DurableUiCheckpoint,
24
24
  UiPromptKind,
25
25
  } from "./types.js";
26
+ import { classifyDurableFormatVersion, DURABLE_FORMAT_VERSION } from "./format-version.js";
26
27
 
27
28
  /** Envelope schema version. */
28
- export const DBOS_ENVELOPE_VERSION = 1;
29
+ export const DBOS_ENVELOPE_VERSION = DURABLE_FORMAT_VERSION;
29
30
 
30
31
  /** Marker key present on every envelope payload. */
31
32
  const ENVELOPE_MARKER = "__dbos_checkpoint__";
@@ -105,9 +106,35 @@ export function encodeCheckpoint(cp: DurableCheckpoint): DbosCheckpointEnvelope
105
106
  * Type guard: is this value a checkpoint envelope?
106
107
  */
107
108
  export function isCheckpointEnvelope(value: WorkflowSerializableValue | undefined): value is DbosCheckpointEnvelope {
109
+ if (!hasCheckpointEnvelopeMarker(value)) return false;
110
+ return value.v === DBOS_ENVELOPE_VERSION;
111
+ }
112
+
113
+ function hasCheckpointEnvelopeMarker(value: WorkflowSerializableValue | undefined): value is Record<string, WorkflowSerializableValue> {
108
114
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
109
- const obj = value as Record<string, unknown>;
110
- return obj[ENVELOPE_MARKER] === ENVELOPE_MARKER;
115
+ return (value as Record<string, WorkflowSerializableValue>)[ENVELOPE_MARKER] === ENVELOPE_MARKER;
116
+ }
117
+ export type DbosCheckpointCompatibility =
118
+ | { readonly kind: "current"; readonly checkpoint: DurableCheckpoint }
119
+ | { readonly kind: "legacy" }
120
+ | { readonly kind: "unknown" };
121
+
122
+ /** Classify and decode one DBOS checkpoint payload without reinterpreting marked formats. */
123
+ export function classifyCheckpointPayload(
124
+ workflowId: string,
125
+ stepName: string,
126
+ value: WorkflowSerializableValue,
127
+ ): DbosCheckpointCompatibility {
128
+ if (!hasCheckpointEnvelopeMarker(value)) return { kind: "current", checkpoint: decodeLegacy(workflowId, stepName, value) };
129
+ const compatibility = classifyDurableFormatVersion(value.v);
130
+ if (compatibility !== "current") return { kind: compatibility };
131
+ const hasOutput = value["hasOutput"];
132
+ const containsOutput = value["output"] !== undefined;
133
+ if (value["checkpointId"] !== stepName || typeof hasOutput !== "boolean" || hasOutput !== containsOutput) {
134
+ return { kind: "unknown" };
135
+ }
136
+ const checkpoint = decodeEnvelope(workflowId, value as DbosCheckpointEnvelope);
137
+ return checkpoint === undefined ? { kind: "unknown" } : { kind: "current", checkpoint };
111
138
  }
112
139
 
113
140
  /**
@@ -124,15 +151,18 @@ export function decodeToCheckpoint(
124
151
  stepName: string,
125
152
  value: WorkflowSerializableValue,
126
153
  ): DurableCheckpoint | undefined {
127
- if (isCheckpointEnvelope(value)) return decodeEnvelope(workflowId, value);
128
- if (value === undefined) return undefined;
129
- return decodeLegacy(workflowId, stepName, value);
154
+ const classified = classifyCheckpointPayload(workflowId, stepName, value);
155
+ return classified.kind === "current" ? classified.checkpoint : undefined;
130
156
  }
131
157
 
132
158
  function decodeEnvelope(workflowId: string, env: DbosCheckpointEnvelope): DurableCheckpoint | undefined {
159
+ if (typeof env.checkpointId !== "string" || env.checkpointId.length === 0
160
+ || typeof env.completedAt !== "number" || !Number.isFinite(env.completedAt)
161
+ || (env.name !== undefined && typeof env.name !== "string")
162
+ || (env.hasOutput !== undefined && typeof env.hasOutput !== "boolean")) return undefined;
133
163
  const common = { workflowId, checkpointId: env.checkpointId, completedAt: env.completedAt };
134
164
  if (env.kind === "tool") {
135
- if (env.argsHash === undefined || env.output === undefined) return undefined;
165
+ if (typeof env.argsHash !== "string" || env.output === undefined) return undefined;
136
166
  return {
137
167
  kind: "tool",
138
168
  ...common,
@@ -142,7 +172,8 @@ function decodeEnvelope(workflowId: string, env: DbosCheckpointEnvelope): Durabl
142
172
  } as DurableToolCheckpoint;
143
173
  }
144
174
  if (env.kind === "ui") {
145
- if (env.promptHash === undefined || env.promptKind === undefined || env.output === undefined) return undefined;
175
+ if (typeof env.promptHash !== "string" || !isUiPromptKind(env.promptKind) || env.output === undefined
176
+ || (env.message !== undefined && typeof env.message !== "string")) return undefined;
146
177
  return {
147
178
  kind: "ui",
148
179
  ...common,
@@ -152,6 +183,18 @@ function decodeEnvelope(workflowId: string, env: DbosCheckpointEnvelope): Durabl
152
183
  response: env.output,
153
184
  } as DurableUiCheckpoint;
154
185
  }
186
+ if (env.kind !== "stage"
187
+ || (env.replayKey !== undefined && typeof env.replayKey !== "string")
188
+ || (env.sessionId !== undefined && typeof env.sessionId !== "string")
189
+ || (env.sessionFile !== undefined && typeof env.sessionFile !== "string")
190
+ || !isOptionalFiniteNumber(env.startedAt)
191
+ || !isOptionalFiniteNumber(env.endedAt)
192
+ || !isOptionalFiniteNumber(env.durationMs)
193
+ || (env.result !== undefined && typeof env.result !== "string")
194
+ || (env.model !== undefined && typeof env.model !== "string")
195
+ || (env.fastMode !== undefined && typeof env.fastMode !== "boolean")
196
+ || (env.attemptedModels !== undefined && !isStringArray(env.attemptedModels))
197
+ || (env.modelAttempts !== undefined && !isModelAttempts(env.modelAttempts))) return undefined;
155
198
  return {
156
199
  kind: "stage",
157
200
  ...common,
@@ -172,6 +215,39 @@ function decodeEnvelope(workflowId: string, env: DbosCheckpointEnvelope): Durabl
172
215
  }
173
216
 
174
217
 
218
+ function isModelAttempts(value: WorkflowSerializableValue | undefined): boolean {
219
+ return Array.isArray(value) && value.every((attempt) => {
220
+ if (typeof attempt !== "object" || attempt === null || Array.isArray(attempt)) return false;
221
+ const record = attempt as Record<string, WorkflowSerializableValue>;
222
+ return typeof record["model"] === "string"
223
+ && typeof record["success"] === "boolean"
224
+ && (record["reasoningLevel"] === undefined || isReasoningLevel(record["reasoningLevel"]))
225
+ && (record["error"] === undefined || typeof record["error"] === "string")
226
+ && (record["usage"] === undefined || isModelUsage(record["usage"]));
227
+ });
228
+ }
229
+
230
+ function isReasoningLevel(value: WorkflowSerializableValue): boolean {
231
+ return value === "off" || value === "minimal" || value === "low" || value === "medium"
232
+ || value === "high" || value === "xhigh" || value === "max";
233
+ }
234
+
235
+ function isModelUsage(value: WorkflowSerializableValue): boolean {
236
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
237
+ const usage = value as Record<string, WorkflowSerializableValue>;
238
+ return ["input", "output", "cacheRead", "cacheWrite", "cost", "turns"]
239
+ .every((key) => usage[key] === undefined || (typeof usage[key] === "number" && Number.isFinite(usage[key])));
240
+ }
241
+
242
+ function isUiPromptKind(value: WorkflowSerializableValue | undefined): value is UiPromptKind {
243
+ return value === "input" || value === "confirm" || value === "select"
244
+ || value === "editor" || value === "custom";
245
+ }
246
+
247
+ function isOptionalFiniteNumber(value: WorkflowSerializableValue | undefined): boolean {
248
+ return value === undefined || (typeof value === "number" && Number.isFinite(value));
249
+ }
250
+
175
251
  function isStringArray(value: WorkflowSerializableValue | undefined): value is readonly string[] {
176
252
  return Array.isArray(value) && value.every((item) => typeof item === "string");
177
253
  }
@@ -0,0 +1,98 @@
1
+ import type { WorkflowSerializableValue } from "../shared/types.js";
2
+ import type { DbosStepRecord } from "./dbos-backend.js";
3
+ import { classifyDurableFormatVersion, DURABLE_FORMAT_VERSION } from "./format-version.js";
4
+ import type { DurableCheckpointEntry, DurableWorkflowStatus } from "./types.js";
5
+
6
+ const METADATA_STEP_PREFIX = "__atomic_metadata";
7
+
8
+ export type DbosMetadataCompatibility =
9
+ | { readonly kind: "current"; readonly entry: DurableCheckpointEntry }
10
+ | { readonly kind: "legacy" }
11
+ | { readonly kind: "unknown" }
12
+ | { readonly kind: "unavailable" };
13
+
14
+ export function metadataStepName(ts: number): string {
15
+ return `${METADATA_STEP_PREFIX}:${ts}:${crypto.randomUUID()}`;
16
+ }
17
+
18
+ export function isMetadataStep(stepName: string): boolean {
19
+ return stepName === METADATA_STEP_PREFIX || stepName.startsWith(`${METADATA_STEP_PREFIX}:`);
20
+ }
21
+
22
+ export function encodeMetadata(entry: DurableCheckpointEntry): WorkflowSerializableValue {
23
+ return {
24
+ __atomicDurableMetadata: true,
25
+ version: DURABLE_FORMAT_VERSION,
26
+ entry: {
27
+ formatVersion: entry.formatVersion,
28
+ type: entry.type,
29
+ workflowId: entry.workflowId,
30
+ name: entry.name,
31
+ inputs: entry.inputs,
32
+ status: entry.status,
33
+ completedCheckpoints: entry.completedCheckpoints,
34
+ pendingPrompts: entry.pendingPrompts,
35
+ ...(entry.label !== undefined ? { label: entry.label } : {}),
36
+ ...(entry.rootWorkflowId !== undefined ? { rootWorkflowId: entry.rootWorkflowId } : {}),
37
+ ...(entry.resumable !== undefined ? { resumable: entry.resumable } : {}),
38
+ ...(entry.invocationCwd !== undefined ? { invocationCwd: entry.invocationCwd } : {}),
39
+ ...(entry.workflowCwd !== undefined ? { workflowCwd: entry.workflowCwd } : {}),
40
+ ...(entry.repositoryRoot !== undefined ? { repositoryRoot: entry.repositoryRoot } : {}),
41
+ ...(entry.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: entry.gitWorktreeRoot } : {}),
42
+ ts: entry.ts,
43
+ },
44
+ };
45
+ }
46
+
47
+ export function classifyLatestMetadata(records: readonly DbosStepRecord[], workflowId: string): DbosMetadataCompatibility {
48
+ const metadata = records.filter((record) => isMetadataStep(record.stepName));
49
+ if (metadata.length === 0) return { kind: "unavailable" };
50
+ const latest = metadata.reduce((selected, record) => metadataTimestamp(record) >= metadataTimestamp(selected) ? record : selected);
51
+ if (typeof latest.output !== "object" || latest.output === null || Array.isArray(latest.output)) return { kind: "unknown" };
52
+ const raw = latest.output as Record<string, WorkflowSerializableValue>;
53
+ if (raw["__atomicDurableMetadata"] !== true) return { kind: "unknown" };
54
+ const compatibility = classifyDurableFormatVersion(raw["version"]);
55
+ if (compatibility !== "current") return { kind: compatibility };
56
+ const entry = parseDurableCheckpointEntry(raw["entry"], workflowId);
57
+ return entry === undefined ? { kind: "unknown" } : { kind: "current", entry };
58
+ }
59
+
60
+ function metadataTimestamp(record: DbosStepRecord): number {
61
+ const segment = record.stepName.split(":")[1];
62
+ const fromName = segment === undefined ? Number.NaN : Number(segment);
63
+ return Number.isFinite(fromName) ? fromName : (record.completedAt ?? 0);
64
+ }
65
+
66
+ function parseDurableCheckpointEntry(
67
+ value: WorkflowSerializableValue | undefined,
68
+ workflowId: string,
69
+ ): DurableCheckpointEntry | undefined {
70
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return undefined;
71
+ const entry = value as Partial<DurableCheckpointEntry>;
72
+ if (entry.workflowId !== workflowId
73
+ || entry.formatVersion !== DURABLE_FORMAT_VERSION
74
+ || entry.type !== "workflow.durable.checkpoint"
75
+ || typeof entry.workflowId !== "string"
76
+ || typeof entry.name !== "string"
77
+ || typeof entry.inputs !== "object"
78
+ || entry.inputs === null
79
+ || Array.isArray(entry.inputs)
80
+ || typeof entry.status !== "string"
81
+ || !isDurableWorkflowStatus(entry.status)
82
+ || typeof entry.completedCheckpoints !== "number"
83
+ || typeof entry.pendingPrompts !== "number"
84
+ || typeof entry.ts !== "number"
85
+ || (entry.label !== undefined && typeof entry.label !== "string")
86
+ || (entry.rootWorkflowId !== undefined && typeof entry.rootWorkflowId !== "string")
87
+ || (entry.resumable !== undefined && typeof entry.resumable !== "boolean")
88
+ || (entry.invocationCwd !== undefined && typeof entry.invocationCwd !== "string")
89
+ || (entry.workflowCwd !== undefined && typeof entry.workflowCwd !== "string")
90
+ || (entry.repositoryRoot !== undefined && typeof entry.repositoryRoot !== "string")
91
+ || (entry.gitWorktreeRoot !== undefined && typeof entry.gitWorktreeRoot !== "string")) return undefined;
92
+ return entry as DurableCheckpointEntry;
93
+ }
94
+
95
+ function isDurableWorkflowStatus(value: string): value is DurableWorkflowStatus {
96
+ return value === "running" || value === "paused" || value === "completed"
97
+ || value === "failed" || value === "cancelled" || value === "blocked";
98
+ }
@@ -0,0 +1,27 @@
1
+ import type { WorkflowSerializableValue } from "../shared/types.js";
2
+ import type { DbosStepRecord } from "./dbos-backend.js";
3
+ import { classifyDurableFormatVersion, DURABLE_FORMAT_VERSION } from "./format-version.js";
4
+
5
+ export const DBOS_DELETION_STEP = "__atomic_deleted";
6
+
7
+ export type DbosDeletionCompatibility = "current" | "unknown" | "absent";
8
+
9
+ export function encodeDbosDeletionTombstone(workflowId: string): WorkflowSerializableValue {
10
+ return {
11
+ __atomicDurableDeleted: true,
12
+ version: DURABLE_FORMAT_VERSION,
13
+ workflowId,
14
+ };
15
+ }
16
+
17
+ export function classifyDbosDeletionTombstone(
18
+ records: readonly DbosStepRecord[],
19
+ workflowId: string,
20
+ ): DbosDeletionCompatibility {
21
+ const record = records.find((candidate) => candidate.stepName === DBOS_DELETION_STEP);
22
+ if (record === undefined) return "absent";
23
+ if (typeof record.output !== "object" || record.output === null || Array.isArray(record.output)) return "unknown";
24
+ const raw = record.output as Record<string, WorkflowSerializableValue>;
25
+ if (raw["__atomicDurableDeleted"] !== true || raw["workflowId"] !== workflowId) return "unknown";
26
+ return classifyDurableFormatVersion(raw["version"]) === "current" ? "current" : "unknown";
27
+ }
@@ -87,7 +87,7 @@ export function createDefaultFileBackend(): DurableWorkflowBackend {
87
87
  export function createWorkflowFileBackend(workflowId: string): DurableWorkflowBackend {
88
88
  const dir = defaultDurableStateDir();
89
89
  if (dir === undefined) return createInMemoryBackend();
90
- return new FileDurableBackend(durableStateFileFor(dir, workflowId));
90
+ return new FileDurableBackend(durableStateFileFor(dir, workflowId), workflowId);
91
91
  }
92
92
 
93
93
  function isDurabilityOptedOut(): boolean {