@bastani/atomic 0.9.18-alpha.5 → 0.9.18-alpha.7

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 (376) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +3 -3
  3. package/dist/builtin/intercom/CHANGELOG.md +39 -0
  4. package/dist/builtin/intercom/README.md +22 -2
  5. package/dist/builtin/intercom/broker/broker.ts +676 -128
  6. package/dist/builtin/intercom/broker/client.ts +151 -35
  7. package/dist/builtin/intercom/broker/delivered-message-cache.ts +497 -37
  8. package/dist/builtin/intercom/broker/framing.ts +4 -2
  9. package/dist/builtin/intercom/broker/paths.ts +10 -0
  10. package/dist/builtin/intercom/broker/pending-send-registry.ts +1 -2
  11. package/dist/builtin/intercom/broker/send-handler.ts +311 -52
  12. package/dist/builtin/intercom/broker/send-signature.ts +4 -2
  13. package/dist/builtin/intercom/broker/socket-writes.ts +103 -0
  14. package/dist/builtin/intercom/broker/spawn.ts +9 -4
  15. package/dist/builtin/intercom/index.bundle.mjs +1410 -212
  16. package/dist/builtin/intercom/package.json +2 -2
  17. package/dist/builtin/intercom/recoverable-disconnect.ts +52 -0
  18. package/dist/builtin/intercom/retry-policy.ts +8 -0
  19. package/dist/builtin/intercom/skills/intercom/SKILL.md +17 -9
  20. package/dist/builtin/intercom/types.ts +27 -8
  21. package/dist/builtin/intercom/workflow-stage-path-matching.ts +90 -0
  22. package/dist/builtin/intercom/workflow-stage-target.ts +57 -0
  23. package/dist/builtin/mcp/index.bundle.mjs +427 -126
  24. package/dist/builtin/mcp/package.json +2 -2
  25. package/dist/builtin/subagents/CHANGELOG.md +19 -0
  26. package/dist/builtin/subagents/README.md +3 -3
  27. package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
  28. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
  29. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  30. package/dist/builtin/subagents/agents/codebase-online-researcher.md +11 -11
  31. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  32. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
  33. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  34. package/dist/builtin/subagents/agents/debugger.md +3 -3
  35. package/dist/builtin/subagents/agents/worker.md +2 -2
  36. package/dist/builtin/subagents/package.json +3 -3
  37. package/dist/builtin/subagents/skills/qlty/SKILL.md +29 -101
  38. package/dist/builtin/subagents/skills/qlty/references/manual-configuration.md +52 -0
  39. package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
  40. package/dist/builtin/subagents/src/extension/index.bundle.mjs +49 -132
  41. package/dist/builtin/web-access/package.json +2 -2
  42. package/dist/builtin/workflows/CHANGELOG.md +46 -0
  43. package/dist/builtin/workflows/README.md +7 -7
  44. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  45. package/dist/builtin/workflows/builtin/{chunk-szz1ajz9.js → chunk-42s7sw0b.js} +9 -2
  46. package/dist/builtin/workflows/builtin/{chunk-2dqb5s2q.js → chunk-79fjkcvh.js} +1 -1
  47. package/dist/builtin/workflows/builtin/{chunk-n58a7v26.js → chunk-b0v2xab1.js} +181 -10
  48. package/dist/builtin/workflows/builtin/{chunk-fghhy2a5.js → chunk-ed4jfn5t.js} +23 -5
  49. package/dist/builtin/workflows/builtin/{chunk-h3r2vkzc.js → chunk-hqpe2cyx.js} +60 -21
  50. package/dist/builtin/workflows/builtin/{chunk-hzzn6adg.js → chunk-k3w87x8y.js} +1 -1
  51. package/dist/builtin/workflows/builtin/{chunk-82ha8p41.js → chunk-n8h4yyew.js} +1 -1
  52. package/dist/builtin/workflows/builtin/{chunk-qwzvgxnq.js → chunk-reqr3sr3.js} +1 -1
  53. package/dist/builtin/workflows/builtin/{chunk-c53y8bdh.js → chunk-wgccch41.js} +1 -1
  54. package/dist/builtin/workflows/builtin/{chunk-0x6e303p.js → chunk-zbekjqew.js} +20 -7
  55. package/dist/builtin/workflows/builtin/{chunk-29wrp38a.js → chunk-ze5x3d1r.js} +1 -1
  56. package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
  57. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
  58. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  59. package/dist/builtin/workflows/builtin/goal.js +3 -3
  60. package/dist/builtin/workflows/builtin/index.js +11 -11
  61. package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
  62. package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
  63. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  64. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  65. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  66. package/dist/builtin/workflows/package.json +2 -2
  67. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +39 -52
  68. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +9 -37
  69. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +49 -0
  70. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +57 -0
  71. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +57 -0
  72. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +47 -0
  73. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +57 -0
  74. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +60 -0
  75. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +58 -0
  76. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +58 -0
  77. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +18 -4
  78. package/dist/builtin/workflows/src/extension/index.bundle.mjs +3194 -737
  79. package/dist/builtin/workflows/src/index.js +899 -436
  80. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -10
  81. package/dist/cli/list-models.d.ts.map +1 -1
  82. package/dist/cli/list-models.js +4 -0
  83. package/dist/cli/list-models.js.map +1 -1
  84. package/dist/client/index.d.ts +1 -2
  85. package/dist/client/index.d.ts.map +1 -1
  86. package/dist/client/index.js +1 -2
  87. package/dist/client/index.js.map +1 -1
  88. package/dist/config.d.ts +0 -9
  89. package/dist/config.d.ts.map +1 -1
  90. package/dist/config.js +0 -45
  91. package/dist/config.js.map +1 -1
  92. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  93. package/dist/core/agent-session-compaction.js +8 -6
  94. package/dist/core/agent-session-compaction.js.map +1 -1
  95. package/dist/core/agent-session-methods.d.ts +1 -0
  96. package/dist/core/agent-session-methods.d.ts.map +1 -1
  97. package/dist/core/agent-session-methods.js.map +1 -1
  98. package/dist/core/agent-session-models.d.ts.map +1 -1
  99. package/dist/core/agent-session-models.js +3 -4
  100. package/dist/core/agent-session-models.js.map +1 -1
  101. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  102. package/dist/core/agent-session-queue-pause.js +6 -0
  103. package/dist/core/agent-session-queue-pause.js.map +1 -1
  104. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  105. package/dist/core/agent-session-runtime.js +13 -5
  106. package/dist/core/agent-session-runtime.js.map +1 -1
  107. package/dist/core/agent-session-tool-hooks.js +1 -1
  108. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  109. package/dist/core/agent-session-tree.d.ts.map +1 -1
  110. package/dist/core/agent-session-tree.js +8 -0
  111. package/dist/core/agent-session-tree.js.map +1 -1
  112. package/dist/core/agent-session.d.ts +2 -0
  113. package/dist/core/agent-session.d.ts.map +1 -1
  114. package/dist/core/agent-session.js +2 -0
  115. package/dist/core/agent-session.js.map +1 -1
  116. package/dist/core/compaction/branch-summarization.d.ts +2 -2
  117. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  118. package/dist/core/compaction/branch-summarization.js +4 -4
  119. package/dist/core/compaction/branch-summarization.js.map +1 -1
  120. package/dist/core/extensions/api-types.d.ts +8 -2
  121. package/dist/core/extensions/api-types.d.ts.map +1 -1
  122. package/dist/core/extensions/api-types.js.map +1 -1
  123. package/dist/core/extensions/context-types.d.ts +12 -0
  124. package/dist/core/extensions/context-types.d.ts.map +1 -1
  125. package/dist/core/extensions/context-types.js.map +1 -1
  126. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  127. package/dist/core/extensions/runner-shortcuts.js +0 -1
  128. package/dist/core/extensions/runner-shortcuts.js.map +1 -1
  129. package/dist/core/fast-model-routing-transport.d.ts +12 -0
  130. package/dist/core/fast-model-routing-transport.d.ts.map +1 -0
  131. package/dist/core/{codex-fast-mode-transport.js → fast-model-routing-transport.js} +29 -29
  132. package/dist/core/fast-model-routing-transport.js.map +1 -0
  133. package/dist/core/fast-model-routing.d.ts +57 -0
  134. package/dist/core/fast-model-routing.d.ts.map +1 -0
  135. package/dist/core/fast-model-routing.js +201 -0
  136. package/dist/core/fast-model-routing.js.map +1 -0
  137. package/dist/core/fast-model-variants.d.ts +98 -0
  138. package/dist/core/fast-model-variants.d.ts.map +1 -0
  139. package/dist/core/fast-model-variants.js +148 -0
  140. package/dist/core/fast-model-variants.js.map +1 -0
  141. package/dist/core/http-dispatcher.d.ts.map +1 -1
  142. package/dist/core/http-dispatcher.js +4 -2
  143. package/dist/core/http-dispatcher.js.map +1 -1
  144. package/dist/core/keybindings.d.ts +0 -10
  145. package/dist/core/keybindings.d.ts.map +1 -1
  146. package/dist/core/keybindings.js +0 -8
  147. package/dist/core/keybindings.js.map +1 -1
  148. package/dist/core/messages.d.ts +1 -1
  149. package/dist/core/messages.d.ts.map +1 -1
  150. package/dist/core/messages.js.map +1 -1
  151. package/dist/core/model-config.d.ts +15 -0
  152. package/dist/core/model-config.d.ts.map +1 -1
  153. package/dist/core/model-config.js +3 -0
  154. package/dist/core/model-config.js.map +1 -1
  155. package/dist/core/model-resolver-initial.js +1 -1
  156. package/dist/core/model-resolver-initial.js.map +1 -1
  157. package/dist/core/model-runtime-streaming.d.ts +14 -1
  158. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  159. package/dist/core/model-runtime-streaming.js +25 -3
  160. package/dist/core/model-runtime-streaming.js.map +1 -1
  161. package/dist/core/model-runtime.d.ts +39 -2
  162. package/dist/core/model-runtime.d.ts.map +1 -1
  163. package/dist/core/model-runtime.js +91 -7
  164. package/dist/core/model-runtime.js.map +1 -1
  165. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  166. package/dist/core/provider-composer-internal.js +8 -2
  167. package/dist/core/provider-composer-internal.js.map +1 -1
  168. package/dist/core/sdk.d.ts.map +1 -1
  169. package/dist/core/sdk.js +18 -18
  170. package/dist/core/sdk.js.map +1 -1
  171. package/dist/core/session-manager-archive.d.ts.map +1 -1
  172. package/dist/core/session-manager-archive.js +25 -2
  173. package/dist/core/session-manager-archive.js.map +1 -1
  174. package/dist/core/settings-manager-core.d.ts +0 -2
  175. package/dist/core/settings-manager-core.d.ts.map +1 -1
  176. package/dist/core/settings-manager-core.js +2 -9
  177. package/dist/core/settings-manager-core.js.map +1 -1
  178. package/dist/core/settings-manager-internals.d.ts +0 -1
  179. package/dist/core/settings-manager-internals.d.ts.map +1 -1
  180. package/dist/core/settings-manager-internals.js.map +1 -1
  181. package/dist/core/settings-manager-ui-accessors.d.ts +0 -8
  182. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  183. package/dist/core/settings-manager-ui-accessors.js +0 -53
  184. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  185. package/dist/core/settings-manager.d.ts +1 -1
  186. package/dist/core/settings-manager.d.ts.map +1 -1
  187. package/dist/core/settings-manager.js.map +1 -1
  188. package/dist/core/settings-types.d.ts +0 -5
  189. package/dist/core/settings-types.d.ts.map +1 -1
  190. package/dist/core/settings-types.js.map +1 -1
  191. package/dist/core/skills.d.ts +1 -1
  192. package/dist/core/skills.d.ts.map +1 -1
  193. package/dist/core/skills.js +4 -2
  194. package/dist/core/skills.js.map +1 -1
  195. package/dist/core/slash-commands.d.ts.map +1 -1
  196. package/dist/core/slash-commands.js +0 -1
  197. package/dist/core/slash-commands.js.map +1 -1
  198. package/dist/core/system-prompt.js +7 -7
  199. package/dist/core/system-prompt.js.map +1 -1
  200. package/dist/core/tools/edit.d.ts +1 -1
  201. package/dist/core/tools/edit.d.ts.map +1 -1
  202. package/dist/core/tools/edit.js +128 -3
  203. package/dist/core/tools/edit.js.map +1 -1
  204. package/dist/core/tools/hashline.d.ts +2 -2
  205. package/dist/core/tools/hashline.d.ts.map +1 -1
  206. package/dist/core/tools/hashline.js +40 -10
  207. package/dist/core/tools/hashline.js.map +1 -1
  208. package/dist/core/tools/write.d.ts.map +1 -1
  209. package/dist/core/tools/write.js +8 -8
  210. package/dist/core/tools/write.js.map +1 -1
  211. package/dist/core/workflow-stage-admission.d.ts +6 -0
  212. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  213. package/dist/core/workflow-stage-admission.js +14 -0
  214. package/dist/core/workflow-stage-admission.js.map +1 -1
  215. package/dist/index-extensions.d.ts +1 -1
  216. package/dist/index-extensions.d.ts.map +1 -1
  217. package/dist/index-extensions.js.map +1 -1
  218. package/dist/index.d.ts +5 -5
  219. package/dist/index.d.ts.map +1 -1
  220. package/dist/index.js +4 -5
  221. package/dist/index.js.map +1 -1
  222. package/dist/modes/interactive/components/atomic-working-status.d.ts +4 -0
  223. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  224. package/dist/modes/interactive/components/atomic-working-status.js +26 -1
  225. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  226. package/dist/modes/interactive/components/custom-editor.d.ts +7 -0
  227. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/custom-editor.js +43 -0
  229. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  230. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  231. package/dist/modes/interactive/components/footer.js +0 -6
  232. package/dist/modes/interactive/components/footer.js.map +1 -1
  233. package/dist/modes/interactive/components/index.d.ts +1 -2
  234. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  235. package/dist/modes/interactive/components/index.js +0 -1
  236. package/dist/modes/interactive/components/index.js.map +1 -1
  237. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  238. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  239. package/dist/modes/interactive/components/model-selector.js +6 -11
  240. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  241. package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -5
  242. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  243. package/dist/modes/interactive/components/scoped-models-selector.js +3 -19
  244. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  245. package/dist/modes/interactive/components/settings-selector-items.js +1 -1
  246. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  247. package/dist/modes/interactive/components/thinking-selector.d.ts +1 -2
  248. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/thinking-selector.js +4 -11
  250. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  251. package/dist/modes/interactive/components/transcript-follow-indicator.js +3 -3
  252. package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
  253. package/dist/modes/interactive/interactive-agent-events.js +8 -8
  254. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  255. package/dist/modes/interactive/interactive-autocomplete.js +5 -16
  256. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  257. package/dist/modes/interactive/interactive-bash-compact.js +2 -9
  258. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  259. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  260. package/dist/modes/interactive/interactive-deferred-startup.js +3 -0
  261. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  262. package/dist/modes/interactive/interactive-editor-actions.js +2 -2
  263. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  264. package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
  265. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  266. package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
  267. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  268. package/dist/modes/interactive/interactive-extension-runtime.js +20 -10
  269. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  270. package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -5
  271. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  272. package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
  273. package/dist/modes/interactive/interactive-initial-session-binding.js +3 -0
  274. package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
  275. package/dist/modes/interactive/interactive-input-handling.js +0 -8
  276. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  277. package/dist/modes/interactive/interactive-mode-base.d.ts +5 -1
  278. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  279. package/dist/modes/interactive/interactive-mode-base.js +15 -9
  280. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  281. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -3
  282. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  283. package/dist/modes/interactive/interactive-mode-deps.js +1 -3
  284. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  285. package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -12
  286. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  287. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  288. package/dist/modes/interactive/interactive-model-routing.js +10 -13
  289. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  290. package/dist/modes/interactive/interactive-render-chat.js +29 -0
  291. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  292. package/dist/modes/interactive/interactive-selectors.js +2 -32
  293. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  294. package/dist/modes/interactive/interactive-session-routing.js +1 -5
  295. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  296. package/dist/modes/interactive/interactive-session-runtime.js +1 -5
  297. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  298. package/dist/modes/interactive/interactive-slash-commands.js +6 -13
  299. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  300. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  301. package/dist/modes/interactive/interactive-startup.js +19 -13
  302. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  303. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  304. package/dist/modes/interactive/interactive-tui.js +27 -3
  305. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  306. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  307. package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
  308. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  309. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  310. package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
  311. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  312. package/dist/utils/child-process.d.ts.map +1 -1
  313. package/dist/utils/child-process.js +13 -6
  314. package/dist/utils/child-process.js.map +1 -1
  315. package/dist/utils/exif-orientation.d.ts.map +1 -1
  316. package/dist/utils/exif-orientation.js +2 -3
  317. package/dist/utils/exif-orientation.js.map +1 -1
  318. package/dist/utils/tools-manager.d.ts +1 -0
  319. package/dist/utils/tools-manager.d.ts.map +1 -1
  320. package/dist/utils/tools-manager.js +33 -18
  321. package/dist/utils/tools-manager.js.map +1 -1
  322. package/docs/custom-provider.md +2 -0
  323. package/docs/development.md +17 -0
  324. package/docs/docs.json +14 -2
  325. package/docs/extensions.md +9 -4
  326. package/docs/intercom.md +41 -7
  327. package/docs/keybindings.md +8 -6
  328. package/docs/models/evals.md +394 -0
  329. package/docs/models/model-selection.md +54 -27
  330. package/docs/models/pareto-efficiency.md +33 -16
  331. package/docs/models.md +37 -1
  332. package/docs/packages.md +2 -2
  333. package/docs/providers.md +44 -20
  334. package/docs/quickstart.md +8 -6
  335. package/docs/rpc.md +3 -3
  336. package/docs/sdk.md +2 -16
  337. package/docs/settings.md +19 -22
  338. package/docs/skills.md +4 -2
  339. package/docs/subagents.md +9 -3
  340. package/docs/tools/edit.md +373 -0
  341. package/docs/tools.md +3 -7
  342. package/docs/tui.md +2 -1
  343. package/docs/usage.md +3 -5
  344. package/docs/workflows/api-reference.md +1395 -0
  345. package/docs/workflows/authoring.md +678 -0
  346. package/docs/workflows/builtins.md +245 -0
  347. package/docs/workflows/operations.md +811 -0
  348. package/docs/workflows/reliable-design.md +2099 -0
  349. package/docs/workflows/verification.md +62 -0
  350. package/docs/workflows.md +15 -5183
  351. package/npm-shrinkwrap.json +584 -69
  352. package/package.json +7 -7
  353. package/dist/client/remote-session.d.ts +0 -64
  354. package/dist/client/remote-session.d.ts.map +0 -1
  355. package/dist/client/remote-session.js +0 -351
  356. package/dist/client/remote-session.js.map +0 -1
  357. package/dist/client/transcript.d.ts +0 -12
  358. package/dist/client/transcript.d.ts.map +0 -1
  359. package/dist/client/transcript.js +0 -98
  360. package/dist/client/transcript.js.map +0 -1
  361. package/dist/core/codex-fast-mode-transport.d.ts +0 -12
  362. package/dist/core/codex-fast-mode-transport.d.ts.map +0 -1
  363. package/dist/core/codex-fast-mode-transport.js.map +0 -1
  364. package/dist/core/codex-fast-mode.d.ts +0 -53
  365. package/dist/core/codex-fast-mode.d.ts.map +0 -1
  366. package/dist/core/codex-fast-mode.js +0 -249
  367. package/dist/core/codex-fast-mode.js.map +0 -1
  368. package/dist/modes/interactive/components/fast-mode-selector.d.ts +0 -27
  369. package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +0 -1
  370. package/dist/modes/interactive/components/fast-mode-selector.js +0 -107
  371. package/dist/modes/interactive/components/fast-mode-selector.js.map +0 -1
  372. package/dist/server/create-harness.d.ts +0 -53
  373. package/dist/server/create-harness.d.ts.map +0 -1
  374. package/dist/server/create-harness.js +0 -360
  375. package/dist/server/create-harness.js.map +0 -1
  376. package/docs/models/artificial-analysis-index.md +0 -83
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.18-alpha.5",
3
+ "version": "0.9.18-alpha.7",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {
@@ -79,13 +79,13 @@
79
79
  "prepublishOnly": "bun run clean && bun run build && bun run shrinkwrap"
80
80
  },
81
81
  "dependencies": {
82
- "@bastani/atomic-natives": "0.9.18-alpha.5",
83
- "@bastani/pi-ai": "0.9.18-alpha.5",
82
+ "@bastani/atomic-natives": "0.9.18-alpha.7",
83
+ "@bastani/pi-ai": "0.9.18-alpha.7",
84
84
  "@dbos-inc/dbos-sdk": "4.25.14",
85
- "@earendil-works/pi-agent-core": "^0.84.4",
86
- "@earendil-works/pi-client": "^0.84.4",
87
- "@earendil-works/pi-protocol": "^0.84.4",
88
- "@earendil-works/pi-tui": "^0.84.4",
85
+ "@earendil-works/pi-agent-core": "0.85.1",
86
+ "@earendil-works/pi-client": "0.85.1",
87
+ "@earendil-works/pi-protocol": "0.85.1",
88
+ "@earendil-works/pi-tui": "0.85.1",
89
89
  "@modelcontextprotocol/ext-apps": "^1.7.5",
90
90
  "@modelcontextprotocol/sdk": "^1.30.0",
91
91
  "@mozilla/readability": "^0.6.0",
@@ -1,64 +0,0 @@
1
- import type { ConnectionState, ConnectionStateChange, PiClient, Unsubscribe } from "@earendil-works/pi-client";
2
- import type { ModelMetadata, ModelRef, SessionMetadata, SessionPhase, SessionSnapshot, ThinkingLevel, TranscriptItem } from "@earendil-works/pi-protocol";
3
- export type RemoteSessionOperation = "open" | "create" | "submit" | "abort" | "setModel" | "setThinking" | "reconnect";
4
- export type RemoteSessionLifecycle = {
5
- readonly status: "unbound";
6
- } | {
7
- readonly status: "ready";
8
- } | {
9
- readonly status: "busy";
10
- readonly operation: RemoteSessionOperation;
11
- } | {
12
- readonly status: "disposed";
13
- };
14
- export interface RemoteSessionState {
15
- readonly lifecycle: RemoteSessionLifecycle;
16
- readonly snapshot?: SessionSnapshot;
17
- readonly transcript: readonly TranscriptItem[];
18
- }
19
- export interface CreateRemoteSessionOptions {
20
- cwd: string;
21
- model?: ModelRef;
22
- thinkingLevel?: ThinkingLevel;
23
- }
24
- export interface RemoteSessionOptions {
25
- onListenerError?: (error: Error) => void;
26
- }
27
- /**
28
- * Owns one upstream pi-client SessionLease and its protocol-facing state.
29
- *
30
- * This surface deliberately does not adapt Atomic's isolated interactive engine:
31
- * the client uses pi-protocol snapshots and the engine uses Atomic's child-process
32
- * RPC facade and recovery controls. Keep the two lifecycles independent.
33
- */
34
- export declare class RemoteSession {
35
- #private;
36
- private constructor();
37
- get id(): string | undefined;
38
- get state(): RemoteSessionState;
39
- get snapshot(): SessionSnapshot | undefined;
40
- get phase(): SessionPhase | undefined;
41
- get operation(): RemoteSessionOperation | undefined;
42
- get models(): readonly ModelMetadata[];
43
- /**
44
- * Durable identities only. Runtime phase, model, thinking, attachment, and
45
- * lock state come from the acquired lease's `snapshot`, not this catalog.
46
- */
47
- get sessions(): readonly SessionMetadata[];
48
- get connectionState(): ConnectionState;
49
- get disposed(): boolean;
50
- subscribe(listener: (state: RemoteSessionState) => void): Unsubscribe;
51
- onConnectionStateChange(listener: (change: ConnectionStateChange) => void): Unsubscribe;
52
- static open(client: PiClient, sessionId: string, options?: RemoteSessionOptions): Promise<RemoteSession>;
53
- open(sessionId: string): Promise<void>;
54
- static create(client: PiClient, createOptions: CreateRemoteSessionOptions, options?: RemoteSessionOptions): Promise<RemoteSession>;
55
- create(options: CreateRemoteSessionOptions): Promise<void>;
56
- submit(text: string): Promise<void>;
57
- abort(): Promise<void>;
58
- setModel(model: ModelRef): Promise<void>;
59
- setThinking(thinkingLevel: ThinkingLevel): Promise<void>;
60
- reconnect(): Promise<void>;
61
- dispose(): Promise<void>;
62
- [Symbol.asyncDispose](): Promise<void>;
63
- }
64
- //# sourceMappingURL=remote-session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-session.d.ts","sourceRoot":"","sources":["../../src/client/remote-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,qBAAqB,EACrB,QAAQ,EAER,WAAW,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACX,aAAa,EACb,QAAQ,EAER,eAAe,EACf,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,MAAM,6BAA6B,CAAC;AASrC,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,WAAW,CAAC;AAEvH,MAAM,MAAM,sBAAsB,GAC/B;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,0BAA0B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACpC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACzC;AAkBD;;;;;;GAMG;AACH,q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C;IAEK,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7D;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAW/B;IAED,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAcvB;IAED,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAErC;CAgLD"}
@@ -1,351 +0,0 @@
1
- import { applyTranscriptProgress, applyTranscriptSnapshot, createTranscriptState, selectTranscript, } from "./transcript.js";
2
- class RemoteSessionDisposedError extends Error {
3
- constructor() {
4
- super("Remote session is disposed");
5
- this.name = "RemoteSessionDisposedError";
6
- }
7
- }
8
- async function settleRemoteSessionDisposal(cleanup) {
9
- const results = await Promise.allSettled(cleanup);
10
- const errors = results.flatMap((result) => result.status === "rejected" && !(result.reason instanceof RemoteSessionDisposedError) ? [result.reason] : []);
11
- if (errors.length === 1)
12
- throw errors[0];
13
- if (errors.length > 1)
14
- throw new AggregateError(errors, "Failed to dispose remote session");
15
- }
16
- /**
17
- * Owns one upstream pi-client SessionLease and its protocol-facing state.
18
- *
19
- * This surface deliberately does not adapt Atomic's isolated interactive engine:
20
- * the client uses pi-protocol snapshots and the engine uses Atomic's child-process
21
- * RPC facade and recovery controls. Keep the two lifecycles independent.
22
- */
23
- export class RemoteSession {
24
- #client;
25
- #onListenerError;
26
- #lifecycle = { status: "unbound" };
27
- #handle;
28
- #transcript;
29
- #unsubscribeSnapshot;
30
- #unsubscribeEvents;
31
- #listeners = new Set();
32
- #pendingAttachmentOperations = new Set();
33
- #activeOperationStates = new Set();
34
- #disposePromise;
35
- #resolveDisposeSignal = () => { };
36
- #disposeSignal = new Promise((resolve) => {
37
- this.#resolveDisposeSignal = resolve;
38
- });
39
- constructor(client, options = {}) {
40
- this.#client = client;
41
- this.#onListenerError = options.onListenerError;
42
- }
43
- get id() {
44
- return this.#handle?.id;
45
- }
46
- get state() {
47
- return {
48
- lifecycle: this.#lifecycle,
49
- snapshot: this.#transcript?.snapshot,
50
- transcript: this.#transcript ? selectTranscript(this.#transcript) : [],
51
- };
52
- }
53
- get snapshot() {
54
- return this.#transcript?.snapshot;
55
- }
56
- get phase() {
57
- return this.snapshot?.phase;
58
- }
59
- get operation() {
60
- return this.#lifecycle.status === "busy" ? this.#lifecycle.operation : undefined;
61
- }
62
- get models() {
63
- return this.#client.snapshot?.models ?? [];
64
- }
65
- /**
66
- * Durable identities only. Runtime phase, model, thinking, attachment, and
67
- * lock state come from the acquired lease's `snapshot`, not this catalog.
68
- */
69
- get sessions() {
70
- return this.#client.snapshot?.sessions ?? [];
71
- }
72
- get connectionState() {
73
- return this.#client.connectionState;
74
- }
75
- get disposed() {
76
- return this.#lifecycle.status === "disposed";
77
- }
78
- subscribe(listener) {
79
- this.#assertNotDisposed();
80
- this.#listeners.add(listener);
81
- this.#callListener(listener, this.state);
82
- return () => this.#listeners.delete(listener);
83
- }
84
- onConnectionStateChange(listener) {
85
- this.#assertNotDisposed();
86
- return this.#client.onConnectionStateChange(listener);
87
- }
88
- static async open(client, sessionId, options = {}) {
89
- const session = new RemoteSession(client, options);
90
- try {
91
- await session.open(sessionId);
92
- return session;
93
- }
94
- catch (error) {
95
- await session.dispose();
96
- throw error;
97
- }
98
- }
99
- async open(sessionId) {
100
- if (this.#handle?.id === sessionId && this.#lifecycle.status === "ready")
101
- return;
102
- await this.#replace("open", () => this.#client.acquireSession(sessionId, { mode: "exclusive" }));
103
- }
104
- static async create(client, createOptions, options = {}) {
105
- const session = new RemoteSession(client, options);
106
- try {
107
- await session.create(createOptions);
108
- return session;
109
- }
110
- catch (error) {
111
- await session.dispose();
112
- throw error;
113
- }
114
- }
115
- async create(options) {
116
- await this.#replace("create", () => this.#client.createSession(options));
117
- }
118
- async submit(text) {
119
- const normalized = text.trim();
120
- if (!normalized)
121
- return;
122
- this.#assertAvailable();
123
- const handle = this.#requireHandle();
124
- if (this.phase !== "idle" && this.phase !== "turn") {
125
- throw new Error(`Session cannot accept input during ${this.phase ?? "unknown"} phase`);
126
- }
127
- await this.#runOperation("submit", () => (this.phase === "idle" ? handle.prompt(normalized) : handle.steer(normalized)).then(() => undefined));
128
- }
129
- async abort() {
130
- const preemptingSubmit = this.#lifecycle.status === "busy" && this.#lifecycle.operation === "submit";
131
- if (preemptingSubmit)
132
- this.#assertNotDisposed();
133
- else
134
- this.#assertAvailable();
135
- const handle = this.#requireHandle();
136
- if (this.phase === "idle" && !preemptingSubmit)
137
- return;
138
- await this.#runOperation("abort", () => handle.abort().then(() => undefined), preemptingSubmit);
139
- }
140
- async setModel(model) {
141
- await this.#runIdleOperation("setModel", "change model", () => this.#requireHandle()
142
- .setModel(model)
143
- .then(() => undefined));
144
- }
145
- async setThinking(thinkingLevel) {
146
- await this.#runIdleOperation("setThinking", "change thinking level", () => this.#requireHandle()
147
- .setThinking(thinkingLevel)
148
- .then(() => undefined));
149
- }
150
- async reconnect() {
151
- this.#assertAvailable();
152
- const sessionId = this.#requireHandle().id;
153
- await this.#runOperation("reconnect", () => this.#trackAttachmentOperation(async () => {
154
- await this.#client.reconnect();
155
- const handle = await this.#client.acquireSession(sessionId, { mode: "exclusive" });
156
- await this.#assertNotDisposedAfterAwait(handle);
157
- this.#bind(handle);
158
- }));
159
- }
160
- dispose() {
161
- if (this.#disposePromise)
162
- return this.#disposePromise;
163
- const handle = this.#handle;
164
- this.#lifecycle = { status: "disposed" };
165
- this.#resolveDisposeSignal();
166
- this.#clearSubscriptions();
167
- this.#handle = undefined;
168
- this.#transcript = undefined;
169
- const cleanup = [...this.#pendingAttachmentOperations];
170
- if (handle)
171
- cleanup.push(handle.dispose());
172
- this.#disposePromise = settleRemoteSessionDisposal(cleanup);
173
- this.#notify();
174
- this.#listeners.clear();
175
- return this.#disposePromise;
176
- }
177
- [Symbol.asyncDispose]() {
178
- return this.dispose();
179
- }
180
- async #replace(operation, prepare) {
181
- this.#assertAvailable();
182
- if (this.#handle && this.phase !== "idle") {
183
- throw new Error(`Cannot ${operation} a session while session is ${this.phase ?? "unavailable"}`);
184
- }
185
- await this.#runOperation(operation, () => this.#trackAttachmentOperation(() => this.#prepareReplacement(operation, prepare)));
186
- }
187
- async #trackAttachmentOperation(run) {
188
- const pending = run();
189
- this.#pendingAttachmentOperations.add(pending);
190
- try {
191
- await pending;
192
- }
193
- finally {
194
- this.#pendingAttachmentOperations.delete(pending);
195
- }
196
- }
197
- async #prepareReplacement(operation, prepare) {
198
- const previous = this.#handle;
199
- const next = await prepare();
200
- await this.#assertNotDisposedAfterAwait(next);
201
- const snapshot = next.snapshot;
202
- if (!snapshot) {
203
- await this.#detach(next);
204
- throw new Error(`Session ${next.id} did not provide a snapshot`);
205
- }
206
- if (previous && previous.id !== next.id && previous.attached && this.phase !== "idle") {
207
- await this.#detach(next);
208
- throw new Error(`Cannot ${operation} a session while session is ${this.phase ?? "unavailable"}`);
209
- }
210
- if (previous && previous.id !== next.id && previous.attached) {
211
- try {
212
- await previous.detach();
213
- }
214
- catch (error) {
215
- try {
216
- await this.#detach(next);
217
- }
218
- catch (cleanupError) {
219
- throw new AggregateError([error, cleanupError], "Failed to replace remote session attachment");
220
- }
221
- throw error;
222
- }
223
- }
224
- await this.#assertNotDisposedAfterAwait(next);
225
- this.#bind(next, snapshot);
226
- }
227
- async #runIdleOperation(operation, description, run) {
228
- this.#assertAvailable();
229
- this.#requireHandle();
230
- if (this.phase !== "idle") {
231
- throw new Error(`Cannot ${description} while session is ${this.phase ?? "unavailable"}`);
232
- }
233
- await this.#runOperation(operation, run);
234
- }
235
- async #runOperation(operation, run, preempt = false) {
236
- if (preempt)
237
- this.#assertNotDisposed();
238
- else
239
- this.#assertAvailable();
240
- const previous = this.#lifecycle;
241
- const busy = { status: "busy", operation };
242
- this.#lifecycle = busy;
243
- this.#activeOperationStates.add(busy);
244
- this.#notify();
245
- const running = run();
246
- try {
247
- await Promise.race([
248
- running,
249
- this.#disposeSignal.then(() => {
250
- throw new Error("Remote session is disposed");
251
- }),
252
- ]);
253
- }
254
- finally {
255
- this.#activeOperationStates.delete(busy);
256
- if (!this.disposed && this.#lifecycle === busy) {
257
- this.#lifecycle =
258
- preempt && this.#activeOperationStates.has(previous)
259
- ? previous
260
- : this.#handle
261
- ? { status: "ready" }
262
- : { status: "unbound" };
263
- this.#notify();
264
- }
265
- }
266
- }
267
- #bind(handle, knownSnapshot) {
268
- const snapshot = knownSnapshot ?? handle.snapshot;
269
- if (!snapshot)
270
- throw new Error(`Session ${handle.id} did not provide a snapshot`);
271
- this.#clearSubscriptions();
272
- this.#handle = handle;
273
- this.#transcript = createTranscriptState(snapshot);
274
- this.#unsubscribeSnapshot = handle.subscribe((next) => {
275
- if (!this.#transcript)
276
- return;
277
- this.#transcript = applyTranscriptSnapshot(this.#transcript, next);
278
- this.#notify();
279
- });
280
- this.#unsubscribeEvents = handle.onEvent((event) => this.#handleEvent(event));
281
- }
282
- #handleEvent(event) {
283
- if (event.type === "session_removed") {
284
- this.#clearSubscriptions();
285
- this.#handle = undefined;
286
- this.#transcript = undefined;
287
- if (this.#lifecycle.status !== "busy")
288
- this.#lifecycle = { status: "unbound" };
289
- this.#notify();
290
- return;
291
- }
292
- if (event.type !== "session_progress" || !this.#transcript)
293
- return;
294
- this.#transcript = applyTranscriptProgress(this.#transcript, event.progress);
295
- this.#notify();
296
- }
297
- #notify() {
298
- const state = this.state;
299
- for (const listener of this.#listeners)
300
- this.#callListener(listener, state);
301
- }
302
- #callListener(listener, state) {
303
- try {
304
- listener(state);
305
- }
306
- catch (error) {
307
- this.#reportListenerError(error);
308
- }
309
- }
310
- #reportListenerError(error) {
311
- if (!this.#onListenerError)
312
- return;
313
- try {
314
- this.#onListenerError(error instanceof Error ? error : new Error(String(error)));
315
- }
316
- catch {
317
- // Diagnostics cannot affect session or transport state.
318
- }
319
- }
320
- #clearSubscriptions() {
321
- this.#unsubscribeSnapshot?.();
322
- this.#unsubscribeEvents?.();
323
- this.#unsubscribeSnapshot = undefined;
324
- this.#unsubscribeEvents = undefined;
325
- }
326
- #requireHandle() {
327
- if (!this.#handle)
328
- throw new Error("No remote session is attached");
329
- return this.#handle;
330
- }
331
- #assertAvailable() {
332
- this.#assertNotDisposed();
333
- if (this.#lifecycle.status === "busy") {
334
- throw new Error(`Remote session is busy with ${this.#lifecycle.operation}`);
335
- }
336
- }
337
- #assertNotDisposed() {
338
- if (this.disposed)
339
- throw new Error("Remote session is disposed");
340
- }
341
- async #assertNotDisposedAfterAwait(handle) {
342
- if (!this.disposed)
343
- return;
344
- await this.#detach(handle);
345
- throw new RemoteSessionDisposedError();
346
- }
347
- async #detach(handle) {
348
- await handle.dispose();
349
- }
350
- }
351
- //# sourceMappingURL=remote-session.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-session.js","sourceRoot":"","sources":["../../src/client/remote-session.ts"],"names":[],"mappings":"AAiBA,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,GAEhB,MAAM,iBAAiB,CAAC;AA0BzB,MAAM,0BAA2B,SAAQ,KAAK;IAC7C;QACC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC1C,CAAC;CACD;AAED,KAAK,UAAU,2BAA2B,CAAC,OAAiC;IAC3E,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACzC,MAAM,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,YAAY,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAC7G,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CA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K,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC;QAAC,MAAM,CAAC;YACR,wDAAwD;QACzD,CAAC;IACF,CAAC;IAED,mBAAmB;QAClB,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;QAC9B,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACrC,CAAC;IAED,cAAc;QACb,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,gBAAgB;QACf,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7E,CAAC;IACF,CAAC;IAED,kBAAkB;QACjB,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,MAAoB;QACtD,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC3B,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,IAAI,0BAA0B,EAAE,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAoB;QACjC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import type {\n\tConnectionState,\n\tConnectionStateChange,\n\tPiClient,\n\tSessionLease,\n\tUnsubscribe,\n} from \"@earendil-works/pi-client\";\nimport type {\n\tModelMetadata,\n\tModelRef,\n\tServerEvent,\n\tSessionMetadata,\n\tSessionPhase,\n\tSessionSnapshot,\n\tThinkingLevel,\n\tTranscriptItem,\n} from \"@earendil-works/pi-protocol\";\nimport {\n\tapplyTranscriptProgress,\n\tapplyTranscriptSnapshot,\n\tcreateTranscriptState,\n\tselectTranscript,\n\ttype TranscriptState,\n} from \"./transcript.ts\";\n\nexport type RemoteSessionOperation = \"open\" | \"create\" | \"submit\" | \"abort\" | \"setModel\" | \"setThinking\" | \"reconnect\";\n\nexport type RemoteSessionLifecycle =\n\t| { readonly status: \"unbound\" }\n\t| { readonly status: \"ready\" }\n\t| { readonly status: \"busy\"; readonly operation: RemoteSessionOperation }\n\t| { readonly status: \"disposed\" };\n\nexport interface RemoteSessionState {\n\treadonly lifecycle: RemoteSessionLifecycle;\n\treadonly snapshot?: SessionSnapshot;\n\treadonly transcript: readonly TranscriptItem[];\n}\n\nexport interface CreateRemoteSessionOptions {\n\tcwd: string;\n\tmodel?: ModelRef;\n\tthinkingLevel?: ThinkingLevel;\n}\n\nexport interface RemoteSessionOptions {\n\tonListenerError?: (error: Error) => void;\n}\n\nclass RemoteSessionDisposedError extends Error {\n\tconstructor() {\n\t\tsuper(\"Remote session is disposed\");\n\t\tthis.name = \"RemoteSessionDisposedError\";\n\t}\n}\n\nasync function settleRemoteSessionDisposal(cleanup: readonly Promise<void>[]): Promise<void> {\n\tconst results = await Promise.allSettled(cleanup);\n\tconst errors = results.flatMap((result) =>\n\t\tresult.status === \"rejected\" && !(result.reason instanceof RemoteSessionDisposedError) ? [result.reason] : [],\n\t);\n\tif (errors.length === 1) throw errors[0];\n\tif (errors.length > 1) throw new AggregateError(errors, \"Failed to dispose remote session\");\n}\n\n/**\n * Owns one upstream pi-client SessionLease and its protocol-facing state.\n *\n * This surface deliberately does not adapt Atomic's isolated interactive engine:\n * the client uses pi-protocol snapshots and the engine uses Atomic's child-process\n * RPC facade and recovery controls. Keep the two lifecycles independent.\n */\nexport class RemoteSession {\n\treadonly #client: PiClient;\n\treadonly #onListenerError: ((error: Error) => void) | undefined;\n\t#lifecycle: RemoteSessionLifecycle = { status: \"unbound\" };\n\t#handle: SessionLease | undefined;\n\t#transcript: TranscriptState | undefined;\n\t#unsubscribeSnapshot: Unsubscribe | undefined;\n\t#unsubscribeEvents: Unsubscribe | undefined;\n\treadonly #listeners = new Set<(state: RemoteSessionState) => void>();\n\treadonly #pendingAttachmentOperations = new Set<Promise<void>>();\n\treadonly #activeOperationStates = new Set<RemoteSessionLifecycle>();\n\t#disposePromise: Promise<void> | undefined;\n\t#resolveDisposeSignal: () => void = () => {};\n\treadonly #disposeSignal = new Promise<void>((resolve) => {\n\t\tthis.#resolveDisposeSignal = resolve;\n\t});\n\n\tprivate constructor(client: PiClient, options: RemoteSessionOptions = {}) {\n\t\tthis.#client = client;\n\t\tthis.#onListenerError = options.onListenerError;\n\t}\n\n\tget id(): string | undefined {\n\t\treturn this.#handle?.id;\n\t}\n\n\tget state(): RemoteSessionState {\n\t\treturn {\n\t\t\tlifecycle: this.#lifecycle,\n\t\t\tsnapshot: this.#transcript?.snapshot,\n\t\t\ttranscript: this.#transcript ? selectTranscript(this.#transcript) : [],\n\t\t};\n\t}\n\n\tget snapshot(): SessionSnapshot | undefined {\n\t\treturn this.#transcript?.snapshot;\n\t}\n\n\tget phase(): SessionPhase | undefined {\n\t\treturn this.snapshot?.phase;\n\t}\n\n\tget operation(): RemoteSessionOperation | undefined {\n\t\treturn this.#lifecycle.status === \"busy\" ? this.#lifecycle.operation : undefined;\n\t}\n\n\tget models(): readonly ModelMetadata[] {\n\t\treturn this.#client.snapshot?.models ?? [];\n\t}\n\n\t/**\n\t * Durable identities only. Runtime phase, model, thinking, attachment, and\n\t * lock state come from the acquired lease's `snapshot`, not this catalog.\n\t */\n\tget sessions(): readonly SessionMetadata[] {\n\t\treturn this.#client.snapshot?.sessions ?? [];\n\t}\n\n\tget connectionState(): ConnectionState {\n\t\treturn this.#client.connectionState;\n\t}\n\n\tget disposed(): boolean {\n\t\treturn this.#lifecycle.status === \"disposed\";\n\t}\n\n\tsubscribe(listener: (state: RemoteSessionState) => void): Unsubscribe {\n\t\tthis.#assertNotDisposed();\n\t\tthis.#listeners.add(listener);\n\t\tthis.#callListener(listener, this.state);\n\t\treturn () => this.#listeners.delete(listener);\n\t}\n\n\tonConnectionStateChange(listener: (change: ConnectionStateChange) => void): Unsubscribe {\n\t\tthis.#assertNotDisposed();\n\t\treturn this.#client.onConnectionStateChange(listener);\n\t}\n\n\tstatic async open(client: PiClient, sessionId: string, options: RemoteSessionOptions = {}): Promise<RemoteSession> {\n\t\tconst session = new RemoteSession(client, options);\n\t\ttry {\n\t\t\tawait session.open(sessionId);\n\t\t\treturn session;\n\t\t} catch (error) {\n\t\t\tawait session.dispose();\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync open(sessionId: string): Promise<void> {\n\t\tif (this.#handle?.id === sessionId && this.#lifecycle.status === \"ready\") return;\n\t\tawait this.#replace(\"open\", () => this.#client.acquireSession(sessionId, { mode: \"exclusive\" }));\n\t}\n\n\tstatic async create(\n\t\tclient: PiClient,\n\t\tcreateOptions: CreateRemoteSessionOptions,\n\t\toptions: RemoteSessionOptions = {},\n\t): Promise<RemoteSession> {\n\t\tconst session = new RemoteSession(client, options);\n\t\ttry {\n\t\t\tawait session.create(createOptions);\n\t\t\treturn session;\n\t\t} catch (error) {\n\t\t\tawait session.dispose();\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync create(options: CreateRemoteSessionOptions): Promise<void> {\n\t\tawait this.#replace(\"create\", () => this.#client.createSession(options));\n\t}\n\n\tasync submit(text: string): Promise<void> {\n\t\tconst normalized = text.trim();\n\t\tif (!normalized) return;\n\t\tthis.#assertAvailable();\n\t\tconst handle = this.#requireHandle();\n\t\tif (this.phase !== \"idle\" && this.phase !== \"turn\") {\n\t\t\tthrow new Error(`Session cannot accept input during ${this.phase ?? \"unknown\"} phase`);\n\t\t}\n\t\tawait this.#runOperation(\"submit\", () =>\n\t\t\t(this.phase === \"idle\" ? handle.prompt(normalized) : handle.steer(normalized)).then(() => undefined),\n\t\t);\n\t}\n\n\tasync abort(): Promise<void> {\n\t\tconst preemptingSubmit = this.#lifecycle.status === \"busy\" && this.#lifecycle.operation === \"submit\";\n\t\tif (preemptingSubmit) this.#assertNotDisposed();\n\t\telse this.#assertAvailable();\n\t\tconst handle = this.#requireHandle();\n\t\tif (this.phase === \"idle\" && !preemptingSubmit) return;\n\t\tawait this.#runOperation(\"abort\", () => handle.abort().then(() => undefined), preemptingSubmit);\n\t}\n\n\tasync setModel(model: ModelRef): Promise<void> {\n\t\tawait this.#runIdleOperation(\"setModel\", \"change model\", () =>\n\t\t\tthis.#requireHandle()\n\t\t\t\t.setModel(model)\n\t\t\t\t.then(() => undefined),\n\t\t);\n\t}\n\n\tasync setThinking(thinkingLevel: ThinkingLevel): Promise<void> {\n\t\tawait this.#runIdleOperation(\"setThinking\", \"change thinking level\", () =>\n\t\t\tthis.#requireHandle()\n\t\t\t\t.setThinking(thinkingLevel)\n\t\t\t\t.then(() => undefined),\n\t\t);\n\t}\n\n\tasync reconnect(): Promise<void> {\n\t\tthis.#assertAvailable();\n\t\tconst sessionId = this.#requireHandle().id;\n\t\tawait this.#runOperation(\"reconnect\", () =>\n\t\t\tthis.#trackAttachmentOperation(async () => {\n\t\t\t\tawait this.#client.reconnect();\n\t\t\t\tconst handle = await this.#client.acquireSession(sessionId, { mode: \"exclusive\" });\n\t\t\t\tawait this.#assertNotDisposedAfterAwait(handle);\n\t\t\t\tthis.#bind(handle);\n\t\t\t}),\n\t\t);\n\t}\n\n\tdispose(): Promise<void> {\n\t\tif (this.#disposePromise) return this.#disposePromise;\n\t\tconst handle = this.#handle;\n\t\tthis.#lifecycle = { status: \"disposed\" };\n\t\tthis.#resolveDisposeSignal();\n\t\tthis.#clearSubscriptions();\n\t\tthis.#handle = undefined;\n\t\tthis.#transcript = undefined;\n\t\tconst cleanup = [...this.#pendingAttachmentOperations];\n\t\tif (handle) cleanup.push(handle.dispose());\n\t\tthis.#disposePromise = settleRemoteSessionDisposal(cleanup);\n\t\tthis.#notify();\n\t\tthis.#listeners.clear();\n\t\treturn this.#disposePromise;\n\t}\n\n\t[Symbol.asyncDispose](): Promise<void> {\n\t\treturn this.dispose();\n\t}\n\n\tasync #replace(operation: \"open\" | \"create\", prepare: () => Promise<SessionLease>): Promise<void> {\n\t\tthis.#assertAvailable();\n\t\tif (this.#handle && this.phase !== \"idle\") {\n\t\t\tthrow new Error(`Cannot ${operation} a session while session is ${this.phase ?? \"unavailable\"}`);\n\t\t}\n\t\tawait this.#runOperation(operation, () =>\n\t\t\tthis.#trackAttachmentOperation(() => this.#prepareReplacement(operation, prepare)),\n\t\t);\n\t}\n\n\tasync #trackAttachmentOperation(run: () => Promise<void>): Promise<void> {\n\t\tconst pending = run();\n\t\tthis.#pendingAttachmentOperations.add(pending);\n\t\ttry {\n\t\t\tawait pending;\n\t\t} finally {\n\t\t\tthis.#pendingAttachmentOperations.delete(pending);\n\t\t}\n\t}\n\n\tasync #prepareReplacement(operation: \"open\" | \"create\", prepare: () => Promise<SessionLease>): Promise<void> {\n\t\tconst previous = this.#handle;\n\t\tconst next = await prepare();\n\t\tawait this.#assertNotDisposedAfterAwait(next);\n\t\tconst snapshot = next.snapshot;\n\t\tif (!snapshot) {\n\t\t\tawait this.#detach(next);\n\t\t\tthrow new Error(`Session ${next.id} did not provide a snapshot`);\n\t\t}\n\t\tif (previous && previous.id !== next.id && previous.attached && this.phase !== \"idle\") {\n\t\t\tawait this.#detach(next);\n\t\t\tthrow new Error(`Cannot ${operation} a session while session is ${this.phase ?? \"unavailable\"}`);\n\t\t}\n\t\tif (previous && previous.id !== next.id && previous.attached) {\n\t\t\ttry {\n\t\t\t\tawait previous.detach();\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.#detach(next);\n\t\t\t\t} catch (cleanupError) {\n\t\t\t\t\tthrow new AggregateError([error, cleanupError], \"Failed to replace remote session attachment\");\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.#assertNotDisposedAfterAwait(next);\n\t\tthis.#bind(next, snapshot);\n\t}\n\n\tasync #runIdleOperation(\n\t\toperation: \"setModel\" | \"setThinking\",\n\t\tdescription: string,\n\t\trun: () => Promise<void>,\n\t): Promise<void> {\n\t\tthis.#assertAvailable();\n\t\tthis.#requireHandle();\n\t\tif (this.phase !== \"idle\") {\n\t\t\tthrow new Error(`Cannot ${description} while session is ${this.phase ?? \"unavailable\"}`);\n\t\t}\n\t\tawait this.#runOperation(operation, run);\n\t}\n\n\tasync #runOperation(operation: RemoteSessionOperation, run: () => Promise<void>, preempt = false): Promise<void> {\n\t\tif (preempt) this.#assertNotDisposed();\n\t\telse this.#assertAvailable();\n\t\tconst previous = this.#lifecycle;\n\t\tconst busy: RemoteSessionLifecycle = { status: \"busy\", operation };\n\t\tthis.#lifecycle = busy;\n\t\tthis.#activeOperationStates.add(busy);\n\t\tthis.#notify();\n\t\tconst running = run();\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\trunning,\n\t\t\t\tthis.#disposeSignal.then(() => {\n\t\t\t\t\tthrow new Error(\"Remote session is disposed\");\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tthis.#activeOperationStates.delete(busy);\n\t\t\tif (!this.disposed && this.#lifecycle === busy) {\n\t\t\t\tthis.#lifecycle =\n\t\t\t\t\tpreempt && this.#activeOperationStates.has(previous)\n\t\t\t\t\t\t? previous\n\t\t\t\t\t\t: this.#handle\n\t\t\t\t\t\t\t? { status: \"ready\" }\n\t\t\t\t\t\t\t: { status: \"unbound\" };\n\t\t\t\tthis.#notify();\n\t\t\t}\n\t\t}\n\t}\n\n\t#bind(handle: SessionLease, knownSnapshot?: SessionSnapshot): void {\n\t\tconst snapshot = knownSnapshot ?? handle.snapshot;\n\t\tif (!snapshot) throw new Error(`Session ${handle.id} did not provide a snapshot`);\n\t\tthis.#clearSubscriptions();\n\t\tthis.#handle = handle;\n\t\tthis.#transcript = createTranscriptState(snapshot);\n\t\tthis.#unsubscribeSnapshot = handle.subscribe((next) => {\n\t\t\tif (!this.#transcript) return;\n\t\t\tthis.#transcript = applyTranscriptSnapshot(this.#transcript, next);\n\t\t\tthis.#notify();\n\t\t});\n\t\tthis.#unsubscribeEvents = handle.onEvent((event) => this.#handleEvent(event));\n\t}\n\n\t#handleEvent(event: ServerEvent): void {\n\t\tif (event.type === \"session_removed\") {\n\t\t\tthis.#clearSubscriptions();\n\t\t\tthis.#handle = undefined;\n\t\t\tthis.#transcript = undefined;\n\t\t\tif (this.#lifecycle.status !== \"busy\") this.#lifecycle = { status: \"unbound\" };\n\t\t\tthis.#notify();\n\t\t\treturn;\n\t\t}\n\t\tif (event.type !== \"session_progress\" || !this.#transcript) return;\n\t\tthis.#transcript = applyTranscriptProgress(this.#transcript, event.progress);\n\t\tthis.#notify();\n\t}\n\n\t#notify(): void {\n\t\tconst state = this.state;\n\t\tfor (const listener of this.#listeners) this.#callListener(listener, state);\n\t}\n\n\t#callListener(listener: (state: RemoteSessionState) => void, state: RemoteSessionState): void {\n\t\ttry {\n\t\t\tlistener(state);\n\t\t} catch (error) {\n\t\t\tthis.#reportListenerError(error);\n\t\t}\n\t}\n\n\t#reportListenerError(error: unknown): void {\n\t\tif (!this.#onListenerError) return;\n\t\ttry {\n\t\t\tthis.#onListenerError(error instanceof Error ? error : new Error(String(error)));\n\t\t} catch {\n\t\t\t// Diagnostics cannot affect session or transport state.\n\t\t}\n\t}\n\n\t#clearSubscriptions(): void {\n\t\tthis.#unsubscribeSnapshot?.();\n\t\tthis.#unsubscribeEvents?.();\n\t\tthis.#unsubscribeSnapshot = undefined;\n\t\tthis.#unsubscribeEvents = undefined;\n\t}\n\n\t#requireHandle(): SessionLease {\n\t\tif (!this.#handle) throw new Error(\"No remote session is attached\");\n\t\treturn this.#handle;\n\t}\n\n\t#assertAvailable(): void {\n\t\tthis.#assertNotDisposed();\n\t\tif (this.#lifecycle.status === \"busy\") {\n\t\t\tthrow new Error(`Remote session is busy with ${this.#lifecycle.operation}`);\n\t\t}\n\t}\n\n\t#assertNotDisposed(): void {\n\t\tif (this.disposed) throw new Error(\"Remote session is disposed\");\n\t}\n\n\tasync #assertNotDisposedAfterAwait(handle: SessionLease): Promise<void> {\n\t\tif (!this.disposed) return;\n\t\tawait this.#detach(handle);\n\t\tthrow new RemoteSessionDisposedError();\n\t}\n\n\tasync #detach(handle: SessionLease): Promise<void> {\n\t\tawait handle.dispose();\n\t}\n}\n"]}
@@ -1,12 +0,0 @@
1
- import type { SessionSnapshot, TranscriptItem, TranscriptProgress } from "@earendil-works/pi-protocol";
2
- export interface TranscriptState {
3
- readonly snapshot: SessionSnapshot;
4
- readonly progressItems: ReadonlyMap<string, TranscriptItem>;
5
- readonly progressOrder: readonly string[];
6
- readonly toolCallBuffers: ReadonlyMap<string, string>;
7
- }
8
- export declare function createTranscriptState(snapshot: SessionSnapshot): TranscriptState;
9
- export declare function applyTranscriptSnapshot(state: TranscriptState, snapshot: SessionSnapshot): TranscriptState;
10
- export declare function applyTranscriptProgress(state: TranscriptState, progress: TranscriptProgress): TranscriptState;
11
- export declare function selectTranscript(state: TranscriptState): readonly TranscriptItem[];
12
- //# sourceMappingURL=transcript.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/client/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAElH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5D,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtD;AAoBD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,eAAe,CAOhF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe,CAG1G;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,kBAAkB,GAAG,eAAe,CAiC7G;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,cAAc,EAAE,CAiBlF"}
@@ -1,98 +0,0 @@
1
- function isJsonValue(value) {
2
- if (value === null || typeof value === "boolean" || typeof value === "string")
3
- return true;
4
- if (typeof value === "number")
5
- return Number.isFinite(value);
6
- if (Array.isArray(value))
7
- return value.every(isJsonValue);
8
- if (typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype)
9
- return false;
10
- return Object.values(value).every(isJsonValue);
11
- }
12
- function parsePartialToolInput(value) {
13
- try {
14
- const parsed = JSON.parse(value);
15
- if (isJsonValue(parsed))
16
- return parsed;
17
- }
18
- catch {
19
- // Tool arguments are incomplete while streaming. Preserve their raw prefix until they form valid JSON.
20
- }
21
- return value;
22
- }
23
- export function createTranscriptState(snapshot) {
24
- return {
25
- snapshot: structuredClone(snapshot),
26
- progressItems: new Map(),
27
- progressOrder: [],
28
- toolCallBuffers: new Map(),
29
- };
30
- }
31
- export function applyTranscriptSnapshot(state, snapshot) {
32
- if (state.snapshot.id === snapshot.id && snapshot.revision < state.snapshot.revision)
33
- return state;
34
- return createTranscriptState(snapshot);
35
- }
36
- export function applyTranscriptProgress(state, progress) {
37
- if (progress.type === "item_started" || progress.type === "item_updated") {
38
- return setProgressItem(state, progress.item);
39
- }
40
- if (progress.type === "item_finished") {
41
- const toolCallBuffers = new Map(state.toolCallBuffers);
42
- for (const key of toolCallBuffers.keys()) {
43
- if (key.startsWith(`${progress.item.id}:`))
44
- toolCallBuffers.delete(key);
45
- }
46
- return setProgressItem({ ...state, toolCallBuffers }, progress.item);
47
- }
48
- const item = state.progressItems.get(progress.messageId) ??
49
- state.snapshot.transcript.find(({ id }) => id === progress.messageId);
50
- if (item?.role !== "assistant")
51
- return state;
52
- let toolCallBuffers = state.toolCallBuffers;
53
- const content = item.content.map((part, index) => {
54
- if (index !== progress.contentIndex)
55
- return structuredClone(part);
56
- if (progress.kind === "text" && part.type === "text")
57
- return { ...part, text: part.text + progress.delta };
58
- if (progress.kind === "thinking" && part.type === "thinking") {
59
- return { ...part, thinking: part.thinking + progress.delta };
60
- }
61
- if (progress.kind === "toolCall" && part.type === "toolCall") {
62
- const key = `${progress.messageId}:${progress.contentIndex}`;
63
- const existing = state.toolCallBuffers.get(key) ?? (typeof part.input === "string" ? part.input : "");
64
- const buffer = existing + progress.delta;
65
- toolCallBuffers = new Map(state.toolCallBuffers).set(key, buffer);
66
- return { ...part, input: parsePartialToolInput(buffer) };
67
- }
68
- return structuredClone(part);
69
- });
70
- return setProgressItem({ ...state, toolCallBuffers }, { ...item, content });
71
- }
72
- export function selectTranscript(state) {
73
- const transcript = state.snapshot.transcript.map((item) => state.progressItems.get(item.id) ?? item);
74
- const ids = new Set(transcript.map((item) => item.id));
75
- for (const id of state.progressOrder) {
76
- if (ids.has(id))
77
- continue;
78
- const item = state.progressItems.get(id);
79
- if (item) {
80
- transcript.push(item);
81
- ids.add(id);
82
- }
83
- }
84
- for (const item of state.snapshot.queuedSteer) {
85
- if (ids.has(item.id))
86
- continue;
87
- transcript.push(item);
88
- ids.add(item.id);
89
- }
90
- return transcript;
91
- }
92
- function setProgressItem(state, item) {
93
- const progressItems = new Map(state.progressItems);
94
- const progressOrder = progressItems.has(item.id) ? state.progressOrder : [...state.progressOrder, item.id];
95
- progressItems.set(item.id, structuredClone(item));
96
- return { ...state, progressItems, progressOrder };
97
- }
98
- //# sourceMappingURL=transcript.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/client/transcript.ts"],"names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C,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3G,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,OAAO,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AACnD,CAAC","sourcesContent":["import type { JsonValue, SessionSnapshot, TranscriptItem, TranscriptProgress } from \"@earendil-works/pi-protocol\";\n\nexport interface TranscriptState {\n\treadonly snapshot: SessionSnapshot;\n\treadonly progressItems: ReadonlyMap<string, TranscriptItem>;\n\treadonly progressOrder: readonly string[];\n\treadonly toolCallBuffers: ReadonlyMap<string, string>;\n}\n\nfunction isJsonValue(value: unknown): value is JsonValue {\n\tif (value === null || typeof value === \"boolean\" || typeof value === \"string\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every(isJsonValue);\n\tif (typeof value !== \"object\" || Object.getPrototypeOf(value) !== Object.prototype) return false;\n\treturn Object.values(value).every(isJsonValue);\n}\n\nfunction parsePartialToolInput(value: string): JsonValue {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(value);\n\t\tif (isJsonValue(parsed)) return parsed;\n\t} catch {\n\t\t// Tool arguments are incomplete while streaming. Preserve their raw prefix until they form valid JSON.\n\t}\n\treturn value;\n}\n\nexport function createTranscriptState(snapshot: SessionSnapshot): TranscriptState {\n\treturn {\n\t\tsnapshot: structuredClone(snapshot),\n\t\tprogressItems: new Map(),\n\t\tprogressOrder: [],\n\t\ttoolCallBuffers: new Map(),\n\t};\n}\n\nexport function applyTranscriptSnapshot(state: TranscriptState, snapshot: SessionSnapshot): TranscriptState {\n\tif (state.snapshot.id === snapshot.id && snapshot.revision < state.snapshot.revision) return state;\n\treturn createTranscriptState(snapshot);\n}\n\nexport function applyTranscriptProgress(state: TranscriptState, progress: TranscriptProgress): TranscriptState {\n\tif (progress.type === \"item_started\" || progress.type === \"item_updated\") {\n\t\treturn setProgressItem(state, progress.item);\n\t}\n\tif (progress.type === \"item_finished\") {\n\t\tconst toolCallBuffers = new Map(state.toolCallBuffers);\n\t\tfor (const key of toolCallBuffers.keys()) {\n\t\t\tif (key.startsWith(`${progress.item.id}:`)) toolCallBuffers.delete(key);\n\t\t}\n\t\treturn setProgressItem({ ...state, toolCallBuffers }, progress.item);\n\t}\n\n\tconst item =\n\t\tstate.progressItems.get(progress.messageId) ??\n\t\tstate.snapshot.transcript.find(({ id }) => id === progress.messageId);\n\tif (item?.role !== \"assistant\") return state;\n\tlet toolCallBuffers = state.toolCallBuffers;\n\tconst content = item.content.map((part, index) => {\n\t\tif (index !== progress.contentIndex) return structuredClone(part);\n\t\tif (progress.kind === \"text\" && part.type === \"text\") return { ...part, text: part.text + progress.delta };\n\t\tif (progress.kind === \"thinking\" && part.type === \"thinking\") {\n\t\t\treturn { ...part, thinking: part.thinking + progress.delta };\n\t\t}\n\t\tif (progress.kind === \"toolCall\" && part.type === \"toolCall\") {\n\t\t\tconst key = `${progress.messageId}:${progress.contentIndex}`;\n\t\t\tconst existing = state.toolCallBuffers.get(key) ?? (typeof part.input === \"string\" ? part.input : \"\");\n\t\t\tconst buffer = existing + progress.delta;\n\t\t\ttoolCallBuffers = new Map(state.toolCallBuffers).set(key, buffer);\n\t\t\treturn { ...part, input: parsePartialToolInput(buffer) };\n\t\t}\n\t\treturn structuredClone(part);\n\t});\n\treturn setProgressItem({ ...state, toolCallBuffers }, { ...item, content });\n}\n\nexport function selectTranscript(state: TranscriptState): readonly TranscriptItem[] {\n\tconst transcript = state.snapshot.transcript.map((item) => state.progressItems.get(item.id) ?? item);\n\tconst ids = new Set(transcript.map((item) => item.id));\n\tfor (const id of state.progressOrder) {\n\t\tif (ids.has(id)) continue;\n\t\tconst item = state.progressItems.get(id);\n\t\tif (item) {\n\t\t\ttranscript.push(item);\n\t\t\tids.add(id);\n\t\t}\n\t}\n\tfor (const item of state.snapshot.queuedSteer) {\n\t\tif (ids.has(item.id)) continue;\n\t\ttranscript.push(item);\n\t\tids.add(item.id);\n\t}\n\treturn transcript;\n}\n\nfunction setProgressItem(state: TranscriptState, item: TranscriptItem): TranscriptState {\n\tconst progressItems = new Map(state.progressItems);\n\tconst progressOrder = progressItems.has(item.id) ? state.progressOrder : [...state.progressOrder, item.id];\n\tprogressItems.set(item.id, structuredClone(item));\n\treturn { ...state, progressItems, progressOrder };\n}\n"]}