@bastani/atomic 0.8.27 → 0.8.28-alpha.2

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 (397) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +120 -118
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +2 -2
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/web-access/package.json +1 -1
  7. package/dist/builtin/workflows/CHANGELOG.md +22 -0
  8. package/dist/builtin/workflows/README.md +11 -9
  9. package/dist/builtin/workflows/builtin/open-claude-design.ts +150 -13
  10. package/dist/builtin/workflows/package.json +1 -1
  11. package/dist/builtin/workflows/src/authoring.d.ts +5 -2
  12. package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +3 -1
  13. package/dist/builtin/workflows/src/extension/hil-answer-notifications.ts +17 -25
  14. package/dist/builtin/workflows/src/extension/index.ts +133 -18
  15. package/dist/builtin/workflows/src/extension/render-result.ts +22 -2
  16. package/dist/builtin/workflows/src/extension/workflow-schema.ts +3 -3
  17. package/dist/builtin/workflows/src/runs/foreground/executor.ts +210 -16
  18. package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
  19. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +42 -5
  20. package/dist/builtin/workflows/src/shared/store-types.ts +8 -2
  21. package/dist/builtin/workflows/src/shared/store.ts +51 -0
  22. package/dist/builtin/workflows/src/shared/types.ts +14 -4
  23. package/dist/builtin/workflows/src/tui/chat-surface.ts +32 -33
  24. package/dist/builtin/workflows/src/tui/graph-view.ts +4 -1
  25. package/dist/builtin/workflows/src/tui/prompt-card.ts +6 -0
  26. package/dist/builtin/workflows/src/tui/run-detail.ts +11 -4
  27. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +11 -1
  28. package/dist/builtin/workflows/src/tui/status-list.ts +32 -2
  29. package/dist/cli/args.d.ts +4 -0
  30. package/dist/cli/args.d.ts.map +1 -1
  31. package/dist/cli/args.js +35 -0
  32. package/dist/cli/args.js.map +1 -1
  33. package/dist/cli/project-trust.d.ts +10 -0
  34. package/dist/cli/project-trust.d.ts.map +1 -0
  35. package/dist/cli/project-trust.js +36 -0
  36. package/dist/cli/project-trust.js.map +1 -0
  37. package/dist/cli/startup-ui.d.ts +7 -0
  38. package/dist/cli/startup-ui.d.ts.map +1 -0
  39. package/dist/cli/startup-ui.js +57 -0
  40. package/dist/cli/startup-ui.js.map +1 -0
  41. package/dist/config.d.ts.map +1 -1
  42. package/dist/config.js +24 -3
  43. package/dist/config.js.map +1 -1
  44. package/dist/core/agent-session-runtime.d.ts +3 -1
  45. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  46. package/dist/core/agent-session-runtime.js +1 -0
  47. package/dist/core/agent-session-runtime.js.map +1 -1
  48. package/dist/core/agent-session-services.d.ts +2 -1
  49. package/dist/core/agent-session-services.d.ts.map +1 -1
  50. package/dist/core/agent-session-services.js +2 -2
  51. package/dist/core/agent-session-services.js.map +1 -1
  52. package/dist/core/agent-session.d.ts +9 -5
  53. package/dist/core/agent-session.d.ts.map +1 -1
  54. package/dist/core/agent-session.js +205 -51
  55. package/dist/core/agent-session.js.map +1 -1
  56. package/dist/core/auth-guidance.d.ts +10 -1
  57. package/dist/core/auth-guidance.d.ts.map +1 -1
  58. package/dist/core/auth-guidance.js +26 -1
  59. package/dist/core/auth-guidance.js.map +1 -1
  60. package/dist/core/auth-storage.d.ts.map +1 -1
  61. package/dist/core/auth-storage.js +4 -3
  62. package/dist/core/auth-storage.js.map +1 -1
  63. package/dist/core/compaction/branch-summarization.d.ts +5 -3
  64. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  65. package/dist/core/compaction/branch-summarization.js +16 -10
  66. package/dist/core/compaction/branch-summarization.js.map +1 -1
  67. package/dist/core/compaction/compaction.d.ts +4 -84
  68. package/dist/core/compaction/compaction.d.ts.map +1 -1
  69. package/dist/core/compaction/compaction.js +20 -502
  70. package/dist/core/compaction/compaction.js.map +1 -1
  71. package/dist/core/compaction/context-compaction.d.ts.map +1 -1
  72. package/dist/core/compaction/context-compaction.js +39 -82
  73. package/dist/core/compaction/context-compaction.js.map +1 -1
  74. package/dist/core/compaction/index.d.ts +1 -1
  75. package/dist/core/compaction/index.d.ts.map +1 -1
  76. package/dist/core/compaction/index.js +1 -1
  77. package/dist/core/compaction/index.js.map +1 -1
  78. package/dist/core/compaction/utils.d.ts +1 -1
  79. package/dist/core/compaction/utils.d.ts.map +1 -1
  80. package/dist/core/compaction/utils.js +1 -1
  81. package/dist/core/compaction/utils.js.map +1 -1
  82. package/dist/core/experimental.d.ts +2 -0
  83. package/dist/core/experimental.d.ts.map +1 -0
  84. package/dist/core/experimental.js +5 -0
  85. package/dist/core/experimental.js.map +1 -0
  86. package/dist/core/export-html/template.js +19 -6
  87. package/dist/core/extensions/index.d.ts +1 -1
  88. package/dist/core/extensions/index.d.ts.map +1 -1
  89. package/dist/core/extensions/index.js.map +1 -1
  90. package/dist/core/extensions/loader.d.ts +1 -1
  91. package/dist/core/extensions/loader.d.ts.map +1 -1
  92. package/dist/core/extensions/loader.js +6 -4
  93. package/dist/core/extensions/loader.js.map +1 -1
  94. package/dist/core/extensions/runner.d.ts +11 -4
  95. package/dist/core/extensions/runner.d.ts.map +1 -1
  96. package/dist/core/extensions/runner.js +53 -3
  97. package/dist/core/extensions/runner.js.map +1 -1
  98. package/dist/core/extensions/types.d.ts +44 -12
  99. package/dist/core/extensions/types.d.ts.map +1 -1
  100. package/dist/core/extensions/types.js.map +1 -1
  101. package/dist/core/footer-data-provider.d.ts +2 -0
  102. package/dist/core/footer-data-provider.d.ts.map +1 -1
  103. package/dist/core/footer-data-provider.js +27 -1
  104. package/dist/core/footer-data-provider.js.map +1 -1
  105. package/dist/core/index.d.ts +2 -1
  106. package/dist/core/index.d.ts.map +1 -1
  107. package/dist/core/index.js +1 -0
  108. package/dist/core/index.js.map +1 -1
  109. package/dist/core/messages.d.ts +1 -11
  110. package/dist/core/messages.d.ts.map +1 -1
  111. package/dist/core/messages.js +10 -25
  112. package/dist/core/messages.js.map +1 -1
  113. package/dist/core/model-registry.d.ts.map +1 -1
  114. package/dist/core/model-registry.js +64 -7
  115. package/dist/core/model-registry.js.map +1 -1
  116. package/dist/core/model-resolver.d.ts.map +1 -1
  117. package/dist/core/model-resolver.js +1 -0
  118. package/dist/core/model-resolver.js.map +1 -1
  119. package/dist/core/output-guard.d.ts +1 -0
  120. package/dist/core/output-guard.d.ts.map +1 -1
  121. package/dist/core/output-guard.js +52 -22
  122. package/dist/core/output-guard.js.map +1 -1
  123. package/dist/core/package-manager.d.ts +1 -0
  124. package/dist/core/package-manager.d.ts.map +1 -1
  125. package/dist/core/package-manager.js +20 -8
  126. package/dist/core/package-manager.js.map +1 -1
  127. package/dist/core/project-trust.d.ts +15 -0
  128. package/dist/core/project-trust.d.ts.map +1 -0
  129. package/dist/core/project-trust.js +58 -0
  130. package/dist/core/project-trust.js.map +1 -0
  131. package/dist/core/prompt-templates.d.ts +5 -4
  132. package/dist/core/prompt-templates.d.ts.map +1 -1
  133. package/dist/core/prompt-templates.js +30 -29
  134. package/dist/core/prompt-templates.js.map +1 -1
  135. package/dist/core/provider-attribution.d.ts +4 -0
  136. package/dist/core/provider-attribution.d.ts.map +1 -0
  137. package/dist/core/provider-attribution.js +73 -0
  138. package/dist/core/provider-attribution.js.map +1 -0
  139. package/dist/core/provider-display-names.d.ts.map +1 -1
  140. package/dist/core/provider-display-names.js +3 -0
  141. package/dist/core/provider-display-names.js.map +1 -1
  142. package/dist/core/resolve-config-value.d.ts +9 -1
  143. package/dist/core/resolve-config-value.d.ts.map +1 -1
  144. package/dist/core/resolve-config-value.js +134 -11
  145. package/dist/core/resolve-config-value.js.map +1 -1
  146. package/dist/core/resource-loader.d.ts +12 -2
  147. package/dist/core/resource-loader.d.ts.map +1 -1
  148. package/dist/core/resource-loader.js +108 -18
  149. package/dist/core/resource-loader.js.map +1 -1
  150. package/dist/core/sdk.d.ts.map +1 -1
  151. package/dist/core/sdk.js +12 -42
  152. package/dist/core/sdk.js.map +1 -1
  153. package/dist/core/session-manager.d.ts +11 -15
  154. package/dist/core/session-manager.d.ts.map +1 -1
  155. package/dist/core/session-manager.js +111 -111
  156. package/dist/core/session-manager.js.map +1 -1
  157. package/dist/core/settings-manager.d.ts +15 -5
  158. package/dist/core/settings-manager.d.ts.map +1 -1
  159. package/dist/core/settings-manager.js +69 -14
  160. package/dist/core/settings-manager.js.map +1 -1
  161. package/dist/core/slash-commands.d.ts.map +1 -1
  162. package/dist/core/slash-commands.js +1 -0
  163. package/dist/core/slash-commands.js.map +1 -1
  164. package/dist/core/system-prompt.d.ts.map +1 -1
  165. package/dist/core/system-prompt.js +0 -3
  166. package/dist/core/system-prompt.js.map +1 -1
  167. package/dist/core/tools/bash.d.ts.map +1 -1
  168. package/dist/core/tools/bash.js +2 -1
  169. package/dist/core/tools/bash.js.map +1 -1
  170. package/dist/core/tools/edit.d.ts.map +1 -1
  171. package/dist/core/tools/edit.js +7 -10
  172. package/dist/core/tools/edit.js.map +1 -1
  173. package/dist/core/tools/find.d.ts.map +1 -1
  174. package/dist/core/tools/find.js +1 -1
  175. package/dist/core/tools/find.js.map +1 -1
  176. package/dist/core/tools/grep.d.ts.map +1 -1
  177. package/dist/core/tools/grep.js +1 -1
  178. package/dist/core/tools/grep.js.map +1 -1
  179. package/dist/core/tools/ls.d.ts.map +1 -1
  180. package/dist/core/tools/ls.js +1 -1
  181. package/dist/core/tools/ls.js.map +1 -1
  182. package/dist/core/tools/oversized-tool-result.d.ts +53 -0
  183. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -0
  184. package/dist/core/tools/oversized-tool-result.js +206 -0
  185. package/dist/core/tools/oversized-tool-result.js.map +1 -0
  186. package/dist/core/tools/read.d.ts +12 -0
  187. package/dist/core/tools/read.d.ts.map +1 -1
  188. package/dist/core/tools/read.js +99 -34
  189. package/dist/core/tools/read.js.map +1 -1
  190. package/dist/core/tools/render-utils.d.ts +6 -0
  191. package/dist/core/tools/render-utils.d.ts.map +1 -1
  192. package/dist/core/tools/render-utils.js +17 -1
  193. package/dist/core/tools/render-utils.js.map +1 -1
  194. package/dist/core/tools/tool-definition-wrapper.d.ts +6 -0
  195. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  196. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  197. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  198. package/dist/core/tools/tool-limits.d.ts +25 -0
  199. package/dist/core/tools/tool-limits.d.ts.map +1 -0
  200. package/dist/core/tools/tool-limits.js +25 -0
  201. package/dist/core/tools/tool-limits.js.map +1 -0
  202. package/dist/core/tools/write.d.ts.map +1 -1
  203. package/dist/core/tools/write.js +1 -1
  204. package/dist/core/tools/write.js.map +1 -1
  205. package/dist/core/trust-manager.d.ts +31 -0
  206. package/dist/core/trust-manager.d.ts.map +1 -0
  207. package/dist/core/trust-manager.js +196 -0
  208. package/dist/core/trust-manager.js.map +1 -0
  209. package/dist/index.d.ts +12 -7
  210. package/dist/index.d.ts.map +1 -1
  211. package/dist/index.js +8 -4
  212. package/dist/index.js.map +1 -1
  213. package/dist/main.d.ts.map +1 -1
  214. package/dist/main.js +142 -30
  215. package/dist/main.js.map +1 -1
  216. package/dist/migrations.d.ts +3 -1
  217. package/dist/migrations.d.ts.map +1 -1
  218. package/dist/migrations.js +325 -7
  219. package/dist/migrations.js.map +1 -1
  220. package/dist/modes/index.d.ts +1 -1
  221. package/dist/modes/index.d.ts.map +1 -1
  222. package/dist/modes/index.js.map +1 -1
  223. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  224. package/dist/modes/interactive/components/bash-execution.js +2 -2
  225. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  226. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -5
  227. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/chat-message-renderer.js +5 -9
  229. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  230. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  231. package/dist/modes/interactive/components/chat-session-host.js +0 -3
  232. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  233. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  234. package/dist/modes/interactive/components/footer.js +6 -0
  235. package/dist/modes/interactive/components/footer.js.map +1 -1
  236. package/dist/modes/interactive/components/index.d.ts +1 -1
  237. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  238. package/dist/modes/interactive/components/index.js +1 -1
  239. package/dist/modes/interactive/components/index.js.map +1 -1
  240. package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
  241. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  242. package/dist/modes/interactive/components/login-dialog.js +9 -16
  243. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  244. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  245. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  246. package/dist/modes/interactive/components/settings-selector.js +20 -0
  247. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  248. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/tool-execution.js +22 -0
  250. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  251. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  252. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  253. package/dist/modes/interactive/components/trust-selector.js +85 -0
  254. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  255. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/user-message.js +1 -1
  257. package/dist/modes/interactive/components/user-message.js.map +1 -1
  258. package/dist/modes/interactive/interactive-mode.d.ts +9 -0
  259. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  260. package/dist/modes/interactive/interactive-mode.js +134 -36
  261. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  262. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  263. package/dist/modes/interactive/theme/theme.js +10 -0
  264. package/dist/modes/interactive/theme/theme.js.map +1 -1
  265. package/dist/modes/print-mode.d.ts.map +1 -1
  266. package/dist/modes/print-mode.js +1 -0
  267. package/dist/modes/print-mode.js.map +1 -1
  268. package/dist/modes/rpc/rpc-client.d.ts +4 -1
  269. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  270. package/dist/modes/rpc/rpc-client.js +52 -8
  271. package/dist/modes/rpc/rpc-client.js.map +1 -1
  272. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  273. package/dist/modes/rpc/rpc-mode.js +24 -5
  274. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  275. package/dist/modes/rpc/rpc-types.d.ts +1 -1
  276. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  277. package/dist/modes/rpc/rpc-types.js.map +1 -1
  278. package/dist/package-manager-cli.d.ts +6 -2
  279. package/dist/package-manager-cli.d.ts.map +1 -1
  280. package/dist/package-manager-cli.js +104 -10
  281. package/dist/package-manager-cli.js.map +1 -1
  282. package/dist/utils/changelog.d.ts +1 -0
  283. package/dist/utils/changelog.d.ts.map +1 -1
  284. package/dist/utils/changelog.js +72 -0
  285. package/dist/utils/changelog.js.map +1 -1
  286. package/dist/utils/deprecation.d.ts +4 -0
  287. package/dist/utils/deprecation.d.ts.map +1 -0
  288. package/dist/utils/deprecation.js +13 -0
  289. package/dist/utils/deprecation.js.map +1 -0
  290. package/dist/utils/git.d.ts.map +1 -1
  291. package/dist/utils/git.js +54 -22
  292. package/dist/utils/git.js.map +1 -1
  293. package/dist/utils/json.d.ts +3 -0
  294. package/dist/utils/json.d.ts.map +1 -0
  295. package/dist/utils/json.js +7 -0
  296. package/dist/utils/json.js.map +1 -0
  297. package/dist/utils/open-browser.d.ts +9 -0
  298. package/dist/utils/open-browser.d.ts.map +1 -0
  299. package/dist/utils/open-browser.js +22 -0
  300. package/dist/utils/open-browser.js.map +1 -0
  301. package/docs/compaction.md +210 -181
  302. package/docs/containerization.md +111 -0
  303. package/docs/custom-provider.md +9 -9
  304. package/docs/development.md +1 -1
  305. package/docs/docs.json +2 -0
  306. package/docs/extensions.md +71 -24
  307. package/docs/index.md +2 -0
  308. package/docs/json.md +3 -4
  309. package/docs/models.md +10 -10
  310. package/docs/packages.md +1 -1
  311. package/docs/prompt-templates.md +9 -2
  312. package/docs/providers.md +18 -5
  313. package/docs/quickstart.md +1 -0
  314. package/docs/rpc.md +3 -2
  315. package/docs/sdk.md +5 -0
  316. package/docs/security.md +56 -0
  317. package/docs/session-format.md +14 -23
  318. package/docs/sessions.md +11 -1
  319. package/docs/settings.md +23 -9
  320. package/docs/skills.md +1 -1
  321. package/docs/terminal-setup.md +44 -2
  322. package/docs/themes.md +1 -1
  323. package/docs/tmux.md +4 -2
  324. package/docs/tui.md +14 -5
  325. package/docs/usage.md +17 -3
  326. package/docs/workflows.md +11 -9
  327. package/examples/README.md +1 -1
  328. package/examples/extensions/README.md +9 -6
  329. package/examples/extensions/bash-spawn-hook.ts +1 -1
  330. package/examples/extensions/built-in-tool-renderer.ts +1 -1
  331. package/examples/extensions/claude-rules.ts +1 -1
  332. package/examples/extensions/commands.ts +1 -1
  333. package/examples/extensions/custom-compaction.ts +43 -106
  334. package/examples/extensions/custom-header.ts +1 -1
  335. package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
  336. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  337. package/examples/extensions/custom-provider-anthropic/package.json +6 -6
  338. package/examples/extensions/custom-provider-gitlab-duo/index.ts +55 -4
  339. package/examples/extensions/custom-provider-gitlab-duo/package.json +3 -3
  340. package/examples/extensions/doom-overlay/README.md +1 -1
  341. package/examples/extensions/doom-overlay/index.ts +2 -2
  342. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  343. package/examples/extensions/gondolin/index.ts +523 -0
  344. package/examples/extensions/gondolin/package-lock.json +185 -0
  345. package/examples/extensions/gondolin/package.json +19 -0
  346. package/examples/extensions/handoff.ts +7 -45
  347. package/examples/extensions/hidden-thinking-label.ts +1 -1
  348. package/examples/extensions/inline-bash.ts +2 -2
  349. package/examples/extensions/input-transform-streaming.ts +39 -0
  350. package/examples/extensions/input-transform.ts +3 -3
  351. package/examples/extensions/interactive-shell.ts +2 -2
  352. package/examples/extensions/mac-system-theme.ts +2 -2
  353. package/examples/extensions/minimal-mode.ts +1 -1
  354. package/examples/extensions/modal-editor.ts +1 -1
  355. package/examples/extensions/model-status.ts +1 -1
  356. package/examples/extensions/overlay-qa-tests.ts +198 -179
  357. package/examples/extensions/overlay-test.ts +1 -1
  358. package/examples/extensions/pirate.ts +1 -1
  359. package/examples/extensions/preset.ts +14 -12
  360. package/examples/extensions/project-trust.ts +64 -0
  361. package/examples/extensions/prompt-customizer.ts +1 -1
  362. package/examples/extensions/qna.ts +1 -1
  363. package/examples/extensions/question.ts +1 -1
  364. package/examples/extensions/questionnaire.ts +1 -1
  365. package/examples/extensions/rainbow-editor.ts +1 -1
  366. package/examples/extensions/sandbox/index.ts +16 -14
  367. package/examples/extensions/sandbox/package-lock.json +90 -90
  368. package/examples/extensions/sandbox/package.json +17 -17
  369. package/examples/extensions/snake.ts +1 -1
  370. package/examples/extensions/space-invaders.ts +1 -1
  371. package/examples/extensions/ssh.ts +2 -2
  372. package/examples/extensions/subagent/README.md +13 -13
  373. package/examples/extensions/subagent/agents.ts +4 -2
  374. package/examples/extensions/subagent/index.ts +6 -6
  375. package/examples/extensions/summarize.ts +1 -1
  376. package/examples/extensions/tic-tac-toe.ts +1 -1
  377. package/examples/extensions/titlebar-spinner.ts +1 -1
  378. package/examples/extensions/todo.ts +1 -1
  379. package/examples/extensions/tool-override.ts +1 -1
  380. package/examples/extensions/tools.ts +6 -1
  381. package/examples/extensions/trigger-compact.ts +5 -4
  382. package/examples/extensions/with-deps/package-lock.json +4 -4
  383. package/examples/extensions/with-deps/package.json +7 -7
  384. package/examples/extensions/working-indicator.ts +4 -4
  385. package/examples/extensions/working-message-test.ts +1 -1
  386. package/examples/sdk/01-minimal.ts +1 -1
  387. package/examples/sdk/03-custom-prompt.ts +1 -1
  388. package/examples/sdk/04-skills.ts +1 -1
  389. package/examples/sdk/06-extensions.ts +2 -2
  390. package/examples/sdk/08-prompt-templates.ts +1 -1
  391. package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
  392. package/examples/sdk/README.md +2 -2
  393. package/package.json +8 -8
  394. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
  395. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  396. package/dist/modes/interactive/components/compaction-summary-message.js +0 -43
  397. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
@@ -1,76 +1,10 @@
1
1
  /**
2
- * Context compaction for long sessions.
3
- *
4
- * Pure functions for compaction logic. The session manager handles I/O,
5
- * and after compaction the session is reloaded.
2
+ * Neutral context-usage metrics for deciding when a session needs compaction.
6
3
  */
7
- import { completeSimple } from "@earendil-works/pi-ai";
8
- import { convertToLlm, createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage, } from "../messages.js";
9
- import { buildContextDeletionFilteredPath, buildSessionContext, } from "../session-manager.js";
10
- import { computeFileLists, createFileOps, extractFileOpsFromMessage, formatFileOperations, SUMMARIZATION_SYSTEM_PROMPT, serializeConversation, } from "./utils.js";
11
- /**
12
- * Extract file operations from messages and previous compaction entries.
13
- */
14
- function extractFileOperations(messages, entries, prevCompactionIndex) {
15
- const fileOps = createFileOps();
16
- // Collect from previous compaction's details (if pi-generated)
17
- if (prevCompactionIndex >= 0) {
18
- const prevCompaction = entries[prevCompactionIndex];
19
- if (!prevCompaction.fromHook && prevCompaction.details) {
20
- // fromHook field kept for session file compatibility
21
- const details = prevCompaction.details;
22
- if (Array.isArray(details.readFiles)) {
23
- for (const f of details.readFiles)
24
- fileOps.read.add(f);
25
- }
26
- if (Array.isArray(details.modifiedFiles)) {
27
- for (const f of details.modifiedFiles)
28
- fileOps.edited.add(f);
29
- }
30
- }
31
- }
32
- // Extract from tool calls in messages
33
- for (const msg of messages) {
34
- extractFileOpsFromMessage(msg, fileOps);
35
- }
36
- return fileOps;
37
- }
38
- // ============================================================================
39
- // Message Extraction
40
- // ============================================================================
41
- /**
42
- * Extract AgentMessage from an entry if it produces one.
43
- * Returns undefined for entries that don't contribute to LLM context.
44
- */
45
- function getMessageFromEntry(entry) {
46
- if (entry.type === "message") {
47
- return entry.message;
48
- }
49
- if (entry.type === "custom_message") {
50
- return createCustomMessage(entry.customType, entry.content, entry.display, entry.details, entry.timestamp, entry.excludeFromContext);
51
- }
52
- if (entry.type === "branch_summary") {
53
- return createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp);
54
- }
55
- if (entry.type === "compaction") {
56
- return createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp);
57
- }
58
- return undefined;
59
- }
60
- function getMessageFromEntryForCompaction(entry) {
61
- if (entry.type === "compaction") {
62
- return undefined;
63
- }
64
- return getMessageFromEntry(entry);
65
- }
66
4
  export const DEFAULT_COMPACTION_SETTINGS = {
67
5
  enabled: true,
68
6
  reserveTokens: 16384,
69
- keepRecentTokens: 20000,
70
7
  };
71
- // ============================================================================
72
- // Token calculation
73
- // ============================================================================
74
8
  /**
75
9
  * Calculate total context tokens from usage.
76
10
  * Uses the native totalTokens field when available, falls back to computing from components.
@@ -151,9 +85,22 @@ export function shouldCompact(contextTokens, contextWindow, settings) {
151
85
  return false;
152
86
  return contextTokens > contextWindow - settings.reserveTokens;
153
87
  }
154
- // ============================================================================
155
- // Cut point detection
156
- // ============================================================================
88
+ const ESTIMATED_IMAGE_CHARS = 4800;
89
+ function estimateTextAndImageContentChars(content) {
90
+ if (typeof content === "string") {
91
+ return content.length;
92
+ }
93
+ let chars = 0;
94
+ for (const block of content) {
95
+ if (block.type === "text" && block.text) {
96
+ chars += block.text.length;
97
+ }
98
+ else if (block.type === "image") {
99
+ chars += ESTIMATED_IMAGE_CHARS;
100
+ }
101
+ }
102
+ return chars;
103
+ }
157
104
  /**
158
105
  * Estimate token count for a message using chars/4 heuristic.
159
106
  * This is conservative (overestimates tokens).
@@ -162,17 +109,7 @@ export function estimateTokens(message) {
162
109
  let chars = 0;
163
110
  switch (message.role) {
164
111
  case "user": {
165
- const content = message.content;
166
- if (typeof content === "string") {
167
- chars = content.length;
168
- }
169
- else if (Array.isArray(content)) {
170
- for (const block of content) {
171
- if (block.type === "text" && block.text) {
172
- chars += block.text.length;
173
- }
174
- }
175
- }
112
+ chars = estimateTextAndImageContentChars(message.content);
176
113
  return Math.ceil(chars / 4);
177
114
  }
178
115
  case "assistant": {
@@ -192,437 +129,18 @@ export function estimateTokens(message) {
192
129
  }
193
130
  case "custom":
194
131
  case "toolResult": {
195
- if (typeof message.content === "string") {
196
- chars = message.content.length;
197
- }
198
- else {
199
- for (const block of message.content) {
200
- if (block.type === "text" && block.text) {
201
- chars += block.text.length;
202
- }
203
- if (block.type === "image") {
204
- chars += 4800; // Estimate images as 4000 chars, or 1200 tokens
205
- }
206
- }
207
- }
132
+ chars = estimateTextAndImageContentChars(message.content);
208
133
  return Math.ceil(chars / 4);
209
134
  }
210
135
  case "bashExecution": {
211
136
  chars = message.command.length + message.output.length;
212
137
  return Math.ceil(chars / 4);
213
138
  }
214
- case "branchSummary":
215
- case "compactionSummary": {
139
+ case "branchSummary": {
216
140
  chars = message.summary.length;
217
141
  return Math.ceil(chars / 4);
218
142
  }
219
143
  }
220
144
  return 0;
221
145
  }
222
- /**
223
- * Find valid cut points: indices of user, assistant, custom, or bashExecution messages.
224
- * Never cut at tool results (they must follow their tool call).
225
- * When we cut at an assistant message with tool calls, its tool results follow it
226
- * and will be kept.
227
- * BashExecutionMessage is treated like a user message (user-initiated context).
228
- */
229
- function findValidCutPoints(entries, startIndex, endIndex) {
230
- const cutPoints = [];
231
- for (let i = startIndex; i < endIndex; i++) {
232
- const entry = entries[i];
233
- switch (entry.type) {
234
- case "message": {
235
- const role = entry.message.role;
236
- switch (role) {
237
- case "bashExecution":
238
- case "custom":
239
- case "branchSummary":
240
- case "compactionSummary":
241
- case "user":
242
- case "assistant":
243
- cutPoints.push(i);
244
- break;
245
- case "toolResult":
246
- break;
247
- }
248
- break;
249
- }
250
- case "thinking_level_change":
251
- case "model_change":
252
- case "compaction":
253
- case "context_compaction":
254
- case "branch_summary":
255
- case "custom":
256
- case "custom_message":
257
- case "label":
258
- case "session_info":
259
- break;
260
- }
261
- // branch_summary and custom_message are user-role messages, valid cut points
262
- if (entry.type === "branch_summary" || entry.type === "custom_message") {
263
- cutPoints.push(i);
264
- }
265
- }
266
- return cutPoints;
267
- }
268
- /**
269
- * Find the user message (or bashExecution) that starts the turn containing the given entry index.
270
- * Returns -1 if no turn start found before the index.
271
- * BashExecutionMessage is treated like a user message for turn boundaries.
272
- */
273
- export function findTurnStartIndex(entries, entryIndex, startIndex) {
274
- for (let i = entryIndex; i >= startIndex; i--) {
275
- const entry = entries[i];
276
- // branch_summary and custom_message are user-role messages, can start a turn
277
- if (entry.type === "branch_summary" || entry.type === "custom_message") {
278
- return i;
279
- }
280
- if (entry.type === "message") {
281
- const role = entry.message.role;
282
- if (role === "user" || role === "bashExecution") {
283
- return i;
284
- }
285
- }
286
- }
287
- return -1;
288
- }
289
- /**
290
- * Find the cut point in session entries that keeps approximately `keepRecentTokens`.
291
- *
292
- * Algorithm: Walk backwards from newest, accumulating estimated message sizes.
293
- * Stop when we've accumulated >= keepRecentTokens. Cut at that point.
294
- *
295
- * Can cut at user OR assistant messages (never tool results). When cutting at an
296
- * assistant message with tool calls, its tool results come after and will be kept.
297
- *
298
- * Returns CutPointResult with:
299
- * - firstKeptEntryIndex: the entry index to start keeping from
300
- * - turnStartIndex: if cutting mid-turn, the user message that started that turn
301
- * - isSplitTurn: whether we're cutting in the middle of a turn
302
- *
303
- * Only considers entries between `startIndex` and `endIndex` (exclusive).
304
- */
305
- export function findCutPoint(entries, startIndex, endIndex, keepRecentTokens) {
306
- const cutPoints = findValidCutPoints(entries, startIndex, endIndex);
307
- if (cutPoints.length === 0) {
308
- return { firstKeptEntryIndex: startIndex, turnStartIndex: -1, isSplitTurn: false };
309
- }
310
- // Walk backwards from newest, accumulating estimated message sizes
311
- let accumulatedTokens = 0;
312
- let cutIndex = cutPoints[0]; // Default: keep from first message (not header)
313
- for (let i = endIndex - 1; i >= startIndex; i--) {
314
- const entry = entries[i];
315
- if (entry.type !== "message")
316
- continue;
317
- // Estimate this message's size
318
- const messageTokens = estimateTokens(entry.message);
319
- accumulatedTokens += messageTokens;
320
- // Check if we've exceeded the budget
321
- if (accumulatedTokens >= keepRecentTokens) {
322
- // Find the closest valid cut point at or after this entry
323
- for (let c = 0; c < cutPoints.length; c++) {
324
- if (cutPoints[c] >= i) {
325
- cutIndex = cutPoints[c];
326
- break;
327
- }
328
- }
329
- break;
330
- }
331
- }
332
- // Scan backwards from cutIndex to include any non-message entries (bash, settings, etc.)
333
- while (cutIndex > startIndex) {
334
- const prevEntry = entries[cutIndex - 1];
335
- // Stop at session header or compaction boundaries
336
- if (prevEntry.type === "compaction" || prevEntry.type === "context_compaction") {
337
- break;
338
- }
339
- if (prevEntry.type === "message") {
340
- // Stop if we hit any message
341
- break;
342
- }
343
- // Include this non-message entry (bash, settings change, etc.)
344
- cutIndex--;
345
- }
346
- // Determine if this is a split turn
347
- const cutEntry = entries[cutIndex];
348
- const isUserMessage = cutEntry.type === "message" && cutEntry.message.role === "user";
349
- const turnStartIndex = isUserMessage ? -1 : findTurnStartIndex(entries, cutIndex, startIndex);
350
- return {
351
- firstKeptEntryIndex: cutIndex,
352
- turnStartIndex,
353
- isSplitTurn: !isUserMessage && turnStartIndex !== -1,
354
- };
355
- }
356
- // ============================================================================
357
- // Summarization
358
- // ============================================================================
359
- const SUMMARIZATION_PROMPT = `The messages above are a conversation to summarize. Create a structured context checkpoint summary that another LLM will use to continue the work.
360
-
361
- Use this EXACT format:
362
-
363
- ## Goal
364
- [What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
365
-
366
- ## Constraints & Preferences
367
- - [Any constraints, preferences, or requirements mentioned by user]
368
- - [Or "(none)" if none were mentioned]
369
-
370
- ## Progress
371
- ### Done
372
- - [x] [Completed tasks/changes]
373
-
374
- ### In Progress
375
- - [ ] [Current work]
376
-
377
- ### Blocked
378
- - [Issues preventing progress, if any]
379
-
380
- ## Key Decisions
381
- - **[Decision]**: [Brief rationale]
382
-
383
- ## Next Steps
384
- 1. [Ordered list of what should happen next]
385
-
386
- ## Critical Context
387
- - [Any data, examples, or references needed to continue]
388
- - [Or "(none)" if not applicable]
389
-
390
- Keep each section concise. Preserve exact file paths, function names, and error messages.`;
391
- const UPDATE_SUMMARIZATION_PROMPT = `The messages above are NEW conversation messages to incorporate into the existing summary provided in <previous-summary> tags.
392
-
393
- Update the existing structured summary with new information. RULES:
394
- - PRESERVE all existing information from the previous summary
395
- - ADD new progress, decisions, and context from the new messages
396
- - UPDATE the Progress section: move items from "In Progress" to "Done" when completed
397
- - UPDATE "Next Steps" based on what was accomplished
398
- - PRESERVE exact file paths, function names, and error messages
399
- - If something is no longer relevant, you may remove it
400
-
401
- Use this EXACT format:
402
-
403
- ## Goal
404
- [Preserve existing goals, add new ones if the task expanded]
405
-
406
- ## Constraints & Preferences
407
- - [Preserve existing, add new ones discovered]
408
-
409
- ## Progress
410
- ### Done
411
- - [x] [Include previously done items AND newly completed items]
412
-
413
- ### In Progress
414
- - [ ] [Current work - update based on progress]
415
-
416
- ### Blocked
417
- - [Current blockers - remove if resolved]
418
-
419
- ## Key Decisions
420
- - **[Decision]**: [Brief rationale] (preserve all previous, add new)
421
-
422
- ## Next Steps
423
- 1. [Update based on current state]
424
-
425
- ## Critical Context
426
- - [Preserve important context, add new if needed]
427
-
428
- Keep each section concise. Preserve exact file paths, function names, and error messages.`;
429
- /**
430
- * Generate a summary of the conversation using the LLM.
431
- * If previousSummary is provided, uses the update prompt to merge.
432
- */
433
- export async function generateSummary(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel) {
434
- const maxTokens = Math.min(Math.floor(0.8 * reserveTokens), model.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY);
435
- // Use update prompt if we have a previous summary, otherwise initial prompt
436
- let basePrompt = previousSummary ? UPDATE_SUMMARIZATION_PROMPT : SUMMARIZATION_PROMPT;
437
- if (customInstructions) {
438
- basePrompt = `${basePrompt}\n\nAdditional focus: ${customInstructions}`;
439
- }
440
- // Serialize conversation to text so model doesn't try to continue it
441
- // Convert to LLM messages first (handles custom types like bashExecution, custom, etc.)
442
- const llmMessages = convertToLlm(currentMessages);
443
- const conversationText = serializeConversation(llmMessages);
444
- // Build the prompt with conversation wrapped in tags
445
- let promptText = `<conversation>\n${conversationText}\n</conversation>\n\n`;
446
- if (previousSummary) {
447
- promptText += `<previous-summary>\n${previousSummary}\n</previous-summary>\n\n`;
448
- }
449
- promptText += basePrompt;
450
- const summarizationMessages = [
451
- {
452
- role: "user",
453
- content: [{ type: "text", text: promptText }],
454
- timestamp: Date.now(),
455
- },
456
- ];
457
- const completionOptions = model.reasoning && thinkingLevel && thinkingLevel !== "off"
458
- ? { maxTokens, signal, apiKey, headers, reasoning: thinkingLevel }
459
- : { maxTokens, signal, apiKey, headers };
460
- const response = await completeSimple(model, { systemPrompt: SUMMARIZATION_SYSTEM_PROMPT, messages: summarizationMessages }, completionOptions);
461
- if (response.stopReason === "error") {
462
- throw new Error(`Summarization failed: ${response.errorMessage || "Unknown error"}`);
463
- }
464
- const textContent = response.content
465
- .filter((c) => c.type === "text")
466
- .map((c) => c.text)
467
- .join("\n");
468
- return textContent;
469
- }
470
- export function prepareCompaction(pathEntries, settings) {
471
- if (pathEntries.length > 0 && pathEntries[pathEntries.length - 1].type === "compaction") {
472
- return undefined;
473
- }
474
- let prevCompactionIndex = -1;
475
- for (let i = pathEntries.length - 1; i >= 0; i--) {
476
- if (pathEntries[i].type === "compaction") {
477
- prevCompactionIndex = i;
478
- break;
479
- }
480
- }
481
- let previousSummary;
482
- let boundaryStart = 0;
483
- if (prevCompactionIndex >= 0) {
484
- const prevCompaction = pathEntries[prevCompactionIndex];
485
- previousSummary = prevCompaction.summary;
486
- const firstKeptEntryIndex = pathEntries.findIndex((entry) => entry.id === prevCompaction.firstKeptEntryId);
487
- boundaryStart = firstKeptEntryIndex >= 0 ? firstKeptEntryIndex : prevCompactionIndex + 1;
488
- }
489
- const filteredPathEntries = buildContextDeletionFilteredPath(pathEntries);
490
- const filteredIndexById = new Map(filteredPathEntries.map((entry, index) => [entry.id, index]));
491
- const findFilteredIndexAtOrAfter = (rawIndex) => {
492
- for (let i = rawIndex; i < pathEntries.length; i++) {
493
- const filteredIndex = filteredIndexById.get(pathEntries[i].id);
494
- if (filteredIndex !== undefined)
495
- return filteredIndex;
496
- }
497
- return filteredPathEntries.length;
498
- };
499
- const filteredBoundaryStart = findFilteredIndexAtOrAfter(boundaryStart);
500
- const filteredPrevCompactionIndex = prevCompactionIndex >= 0 ? (filteredIndexById.get(pathEntries[prevCompactionIndex].id) ?? -1) : -1;
501
- const boundaryEnd = filteredPathEntries.length;
502
- const tokensBefore = estimateContextTokens(buildSessionContext(pathEntries).messages).tokens;
503
- const cutPoint = findCutPoint(filteredPathEntries, filteredBoundaryStart, boundaryEnd, settings.keepRecentTokens);
504
- // Get UUID of first kept entry
505
- const firstKeptEntry = filteredPathEntries[cutPoint.firstKeptEntryIndex];
506
- if (!firstKeptEntry?.id) {
507
- return undefined; // Session needs migration
508
- }
509
- const firstKeptEntryId = firstKeptEntry.id;
510
- const historyEnd = cutPoint.isSplitTurn ? cutPoint.turnStartIndex : cutPoint.firstKeptEntryIndex;
511
- // Messages to summarize (will be discarded after summary)
512
- const messagesToSummarize = [];
513
- for (let i = filteredBoundaryStart; i < historyEnd; i++) {
514
- const msg = getMessageFromEntryForCompaction(filteredPathEntries[i]);
515
- if (msg)
516
- messagesToSummarize.push(msg);
517
- }
518
- // Messages for turn prefix summary (if splitting a turn)
519
- const turnPrefixMessages = [];
520
- if (cutPoint.isSplitTurn) {
521
- for (let i = cutPoint.turnStartIndex; i < cutPoint.firstKeptEntryIndex; i++) {
522
- const msg = getMessageFromEntryForCompaction(filteredPathEntries[i]);
523
- if (msg)
524
- turnPrefixMessages.push(msg);
525
- }
526
- }
527
- // Extract file operations from filtered messages and previous compaction
528
- const fileOps = extractFileOperations(messagesToSummarize, filteredPathEntries, filteredPrevCompactionIndex);
529
- // Also extract file ops from turn prefix if splitting
530
- if (cutPoint.isSplitTurn) {
531
- for (const msg of turnPrefixMessages) {
532
- extractFileOpsFromMessage(msg, fileOps);
533
- }
534
- }
535
- return {
536
- firstKeptEntryId,
537
- messagesToSummarize,
538
- turnPrefixMessages,
539
- isSplitTurn: cutPoint.isSplitTurn,
540
- tokensBefore,
541
- previousSummary,
542
- fileOps,
543
- settings,
544
- };
545
- }
546
- // ============================================================================
547
- // Main compaction function
548
- // ============================================================================
549
- const TURN_PREFIX_SUMMARIZATION_PROMPT = `This is the PREFIX of a turn that was too large to keep. The SUFFIX (recent work) is retained.
550
-
551
- Summarize the prefix to provide context for the retained suffix:
552
-
553
- ## Original Request
554
- [What did the user ask for in this turn?]
555
-
556
- ## Early Progress
557
- - [Key decisions and work done in the prefix]
558
-
559
- ## Context for Suffix
560
- - [Information needed to understand the retained recent work]
561
-
562
- Be concise. Focus on what's needed to understand the kept suffix.`;
563
- /**
564
- * Generate summaries for compaction using prepared data.
565
- * Returns CompactionResult - SessionManager adds uuid/parentUuid when saving.
566
- *
567
- * @param preparation - Pre-calculated preparation from prepareCompaction()
568
- * @param customInstructions - Optional custom focus for the summary
569
- */
570
- export async function compact(preparation, model, apiKey, headers, customInstructions, signal, thinkingLevel) {
571
- const { firstKeptEntryId, messagesToSummarize, turnPrefixMessages, isSplitTurn, tokensBefore, previousSummary, fileOps, settings, } = preparation;
572
- // Generate summaries (can be parallel if both needed) and merge into one
573
- let summary;
574
- if (isSplitTurn && turnPrefixMessages.length > 0) {
575
- // Generate both summaries in parallel
576
- const [historyResult, turnPrefixResult] = await Promise.all([
577
- messagesToSummarize.length > 0
578
- ? generateSummary(messagesToSummarize, model, settings.reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel)
579
- : Promise.resolve("No prior history."),
580
- generateTurnPrefixSummary(turnPrefixMessages, model, settings.reserveTokens, apiKey, headers, signal, thinkingLevel),
581
- ]);
582
- // Merge into single summary
583
- summary = `${historyResult}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult}`;
584
- }
585
- else {
586
- // Just generate history summary
587
- summary = await generateSummary(messagesToSummarize, model, settings.reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel);
588
- }
589
- // Compute file lists and append to summary
590
- const { readFiles, modifiedFiles } = computeFileLists(fileOps);
591
- summary += formatFileOperations(readFiles, modifiedFiles);
592
- if (!firstKeptEntryId) {
593
- throw new Error("First kept entry has no UUID - session may need migration");
594
- }
595
- return {
596
- summary,
597
- firstKeptEntryId,
598
- tokensBefore,
599
- details: { readFiles, modifiedFiles },
600
- };
601
- }
602
- /**
603
- * Generate a summary for a turn prefix (when splitting a turn).
604
- */
605
- async function generateTurnPrefixSummary(messages, model, reserveTokens, apiKey, headers, signal, thinkingLevel) {
606
- const maxTokens = Math.min(Math.floor(0.5 * reserveTokens), model.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY); // Smaller budget for turn prefix
607
- const llmMessages = convertToLlm(messages);
608
- const conversationText = serializeConversation(llmMessages);
609
- const promptText = `<conversation>\n${conversationText}\n</conversation>\n\n${TURN_PREFIX_SUMMARIZATION_PROMPT}`;
610
- const summarizationMessages = [
611
- {
612
- role: "user",
613
- content: [{ type: "text", text: promptText }],
614
- timestamp: Date.now(),
615
- },
616
- ];
617
- const response = await completeSimple(model, { systemPrompt: SUMMARIZATION_SYSTEM_PROMPT, messages: summarizationMessages }, model.reasoning && thinkingLevel && thinkingLevel !== "off"
618
- ? { maxTokens, signal, apiKey, headers, reasoning: thinkingLevel }
619
- : { maxTokens, signal, apiKey, headers });
620
- if (response.stopReason === "error") {
621
- throw new Error(`Turn prefix summarization failed: ${response.errorMessage || "Unknown error"}`);
622
- }
623
- return response.content
624
- .filter((c) => c.type === "text")
625
- .map((c) => c.text)
626
- .join("\n");
627
- }
628
146
  //# sourceMappingURL=compaction.js.map