@bastani/atomic 0.8.26-alpha.6 → 0.8.26-alpha.8

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 (260) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +5 -5
  3. package/dist/builtin/intercom/CHANGELOG.md +12 -0
  4. package/dist/builtin/intercom/package.json +2 -2
  5. package/dist/builtin/mcp/CHANGELOG.md +12 -0
  6. package/dist/builtin/mcp/package.json +3 -3
  7. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  8. package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
  9. package/dist/builtin/subagents/agents/debugger.md +6 -6
  10. package/dist/builtin/subagents/package.json +4 -4
  11. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +1 -1
  12. package/dist/builtin/subagents/skills/browser/EXAMPLES.md +151 -0
  13. package/dist/builtin/subagents/skills/browser/LICENSE.txt +21 -0
  14. package/dist/builtin/subagents/skills/browser/REFERENCE.md +451 -0
  15. package/dist/builtin/subagents/skills/browser/SKILL.md +170 -0
  16. package/dist/builtin/subagents/skills/subagent/SKILL.md +4 -4
  17. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  18. package/dist/builtin/web-access/package.json +2 -2
  19. package/dist/builtin/workflows/CHANGELOG.md +17 -0
  20. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +4 -1
  21. package/dist/builtin/workflows/builtin/goal.ts +127 -99
  22. package/dist/builtin/workflows/builtin/open-claude-design.ts +224 -147
  23. package/dist/builtin/workflows/builtin/ralph.ts +160 -197
  24. package/dist/builtin/workflows/package.json +2 -2
  25. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  26. package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
  27. package/dist/builtin/workflows/src/runs/foreground/executor.ts +12 -6
  28. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +2 -2
  29. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
  30. package/dist/builtin/workflows/src/shared/types.ts +3 -3
  31. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +2 -1
  32. package/dist/core/agent-session.d.ts +33 -6
  33. package/dist/core/agent-session.d.ts.map +1 -1
  34. package/dist/core/agent-session.js +155 -182
  35. package/dist/core/agent-session.js.map +1 -1
  36. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  37. package/dist/core/atomic-guide-command.js +1 -1
  38. package/dist/core/atomic-guide-command.js.map +1 -1
  39. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  40. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  41. package/dist/core/compaction/branch-summarization.js +6 -3
  42. package/dist/core/compaction/branch-summarization.js.map +1 -1
  43. package/dist/core/compaction/compaction.d.ts.map +1 -1
  44. package/dist/core/compaction/compaction.js +23 -10
  45. package/dist/core/compaction/compaction.js.map +1 -1
  46. package/dist/core/compaction/context-compaction.d.ts +61 -0
  47. package/dist/core/compaction/context-compaction.d.ts.map +1 -0
  48. package/dist/core/compaction/context-compaction.js +602 -0
  49. package/dist/core/compaction/context-compaction.js.map +1 -0
  50. package/dist/core/compaction/index.d.ts +1 -0
  51. package/dist/core/compaction/index.d.ts.map +1 -1
  52. package/dist/core/compaction/index.js +1 -0
  53. package/dist/core/compaction/index.js.map +1 -1
  54. package/dist/core/extensions/types.d.ts +3 -2
  55. package/dist/core/extensions/types.d.ts.map +1 -1
  56. package/dist/core/extensions/types.js.map +1 -1
  57. package/dist/core/index.d.ts +1 -1
  58. package/dist/core/index.d.ts.map +1 -1
  59. package/dist/core/index.js.map +1 -1
  60. package/dist/core/session-manager.d.ts +41 -1
  61. package/dist/core/session-manager.d.ts.map +1 -1
  62. package/dist/core/session-manager.js +146 -7
  63. package/dist/core/session-manager.js.map +1 -1
  64. package/dist/core/slash-commands.d.ts.map +1 -1
  65. package/dist/core/slash-commands.js +1 -1
  66. package/dist/core/slash-commands.js.map +1 -1
  67. package/dist/index.d.ts +3 -3
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +2 -2
  70. package/dist/index.js.map +1 -1
  71. package/dist/modes/index.d.ts +1 -1
  72. package/dist/modes/index.d.ts.map +1 -1
  73. package/dist/modes/index.js.map +1 -1
  74. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  75. package/dist/modes/interactive/components/chat-session-host.js +17 -0
  76. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  77. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
  78. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
  79. package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
  80. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
  81. package/dist/modes/interactive/components/index.d.ts +1 -0
  82. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/index.js +1 -0
  84. package/dist/modes/interactive/components/index.js.map +1 -1
  85. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  86. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  87. package/dist/modes/interactive/interactive-mode.js +72 -8
  88. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  89. package/dist/modes/rpc/rpc-client.d.ts +13 -8
  90. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  91. package/dist/modes/rpc/rpc-client.js +8 -1
  92. package/dist/modes/rpc/rpc-client.js.map +1 -1
  93. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  94. package/dist/modes/rpc/rpc-mode.js +4 -0
  95. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  96. package/dist/modes/rpc/rpc-types.d.ts +14 -3
  97. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  98. package/dist/modes/rpc/rpc-types.js.map +1 -1
  99. package/docs/compaction.md +89 -37
  100. package/docs/custom-provider.md +11 -9
  101. package/docs/extensions.md +44 -40
  102. package/docs/index.md +2 -9
  103. package/docs/json.md +15 -12
  104. package/docs/packages.md +2 -0
  105. package/docs/providers.md +4 -1
  106. package/docs/quickstart.md +5 -12
  107. package/docs/rpc.md +38 -23
  108. package/docs/sdk.md +3 -10
  109. package/docs/session-format.md +26 -13
  110. package/docs/sessions.md +3 -3
  111. package/docs/settings.md +2 -2
  112. package/docs/skills.md +1 -15
  113. package/docs/termux.md +9 -10
  114. package/docs/themes.md +2 -2
  115. package/docs/tmux.md +3 -3
  116. package/docs/tui.md +19 -32
  117. package/docs/usage.md +2 -2
  118. package/docs/workflows.md +44 -2
  119. package/package.json +4 -12
  120. package/dist/builtin/subagents/skills/browser-use/SKILL.md +0 -234
  121. package/dist/builtin/subagents/skills/browser-use/references/cdp-python.md +0 -76
  122. package/dist/builtin/subagents/skills/browser-use/references/multi-session.md +0 -92
  123. package/node_modules/@earendil-works/pi-tui/README.md +0 -779
  124. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +0 -54
  125. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +0 -1
  126. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -632
  127. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +0 -1
  128. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +0 -22
  129. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +0 -1
  130. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +0 -104
  131. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +0 -1
  132. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +0 -22
  133. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +0 -1
  134. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +0 -35
  135. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +0 -1
  136. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +0 -249
  137. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +0 -1
  138. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +0 -1857
  139. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +0 -1
  140. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +0 -28
  141. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +0 -1
  142. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -89
  143. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +0 -1
  144. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +0 -37
  145. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +0 -1
  146. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +0 -378
  147. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +0 -1
  148. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +0 -31
  149. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +0 -1
  150. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +0 -69
  151. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +0 -1
  152. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +0 -96
  153. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +0 -1
  154. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -644
  155. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +0 -1
  156. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +0 -50
  157. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +0 -1
  158. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +0 -159
  159. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +0 -1
  160. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +0 -50
  161. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +0 -1
  162. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +0 -185
  163. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +0 -1
  164. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +0 -12
  165. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +0 -1
  166. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -23
  167. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +0 -1
  168. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +0 -19
  169. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +0 -1
  170. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -89
  171. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +0 -1
  172. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +0 -13
  173. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +0 -1
  174. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -51
  175. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +0 -1
  176. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +0 -39
  177. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +0 -1
  178. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +0 -2
  179. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +0 -1
  180. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +0 -16
  181. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +0 -1
  182. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +0 -110
  183. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +0 -1
  184. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +0 -23
  185. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +0 -1
  186. package/node_modules/@earendil-works/pi-tui/dist/index.js +0 -32
  187. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +0 -1
  188. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +0 -193
  189. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +0 -1
  190. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +0 -174
  191. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +0 -1
  192. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +0 -184
  193. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +0 -1
  194. package/node_modules/@earendil-works/pi-tui/dist/keys.js +0 -1173
  195. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +0 -1
  196. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +0 -28
  197. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +0 -1
  198. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +0 -44
  199. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +0 -1
  200. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts +0 -3
  201. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +0 -1
  202. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +0 -53
  203. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +0 -1
  204. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +0 -50
  205. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +0 -1
  206. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +0 -361
  207. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +0 -1
  208. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -90
  209. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +0 -1
  210. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -366
  211. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +0 -1
  212. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +0 -113
  213. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +0 -1
  214. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +0 -472
  215. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +0 -1
  216. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +0 -227
  217. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +0 -1
  218. package/node_modules/@earendil-works/pi-tui/dist/tui.js +0 -1106
  219. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +0 -1
  220. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +0 -17
  221. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +0 -1
  222. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +0 -25
  223. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +0 -1
  224. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -84
  225. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +0 -1
  226. package/node_modules/@earendil-works/pi-tui/dist/utils.js +0 -1029
  227. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +0 -1
  228. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts +0 -25
  229. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +0 -1
  230. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js +0 -96
  231. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +0 -1
  232. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  233. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  234. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  235. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  236. package/node_modules/@earendil-works/pi-tui/package.json +0 -47
  237. package/node_modules/get-east-asian-width/index.d.ts +0 -60
  238. package/node_modules/get-east-asian-width/index.js +0 -30
  239. package/node_modules/get-east-asian-width/license +0 -9
  240. package/node_modules/get-east-asian-width/lookup-data.js +0 -21
  241. package/node_modules/get-east-asian-width/lookup.js +0 -138
  242. package/node_modules/get-east-asian-width/package.json +0 -71
  243. package/node_modules/get-east-asian-width/readme.md +0 -65
  244. package/node_modules/get-east-asian-width/utilities.js +0 -24
  245. package/node_modules/marked/LICENSE.md +0 -44
  246. package/node_modules/marked/README.md +0 -106
  247. package/node_modules/marked/bin/main.js +0 -282
  248. package/node_modules/marked/bin/marked.js +0 -15
  249. package/node_modules/marked/lib/marked.cjs +0 -2211
  250. package/node_modules/marked/lib/marked.cjs.map +0 -7
  251. package/node_modules/marked/lib/marked.d.cts +0 -728
  252. package/node_modules/marked/lib/marked.d.ts +0 -728
  253. package/node_modules/marked/lib/marked.esm.js +0 -2189
  254. package/node_modules/marked/lib/marked.esm.js.map +0 -7
  255. package/node_modules/marked/lib/marked.umd.js +0 -2213
  256. package/node_modules/marked/lib/marked.umd.js.map +0 -7
  257. package/node_modules/marked/man/marked.1 +0 -111
  258. package/node_modules/marked/man/marked.1.md +0 -92
  259. package/node_modules/marked/marked.min.js +0 -69
  260. package/node_modules/marked/package.json +0 -111
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-compaction.js","sourceRoot":"","sources":["../../../src/core/compaction/context-compaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,gCAAgC,EAChC,2BAA2B,GAI3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,i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AAW,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC/G,MAAM,SAAS,GAAG,2BAA2B,CAAC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5E,IAAI,SAAS,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, Model, ToolCall } from \"@earendil-works/pi-ai\";\nimport { completeSimple, StringEnum } from \"@earendil-works/pi-ai\";\nimport { Type } from \"typebox\";\nimport {\n\tcreateBranchSummaryMessage,\n\tcreateCompactionSummaryMessage,\n\tcreateCustomMessage,\n} from \"../messages.ts\";\nimport {\n\tbuildContextDeletionFilteredPath,\n\tbuildContextDeletionFilters,\n\ttype ContextCompactionStats,\n\ttype ContextDeletionTarget,\n\ttype SessionEntry,\n} from \"../session-manager.ts\";\nimport type { CompactionSettings } from \"./compaction.ts\";\nimport { estimateTokens } from \"./compaction.ts\";\n\nexport const CONTEXT_COMPACTION_PROMPT_VERSION = 1 as const;\n\nexport interface RawContextDeletionPlan {\n\tdeletions: Array<{\n\t\tkind: \"entry\" | \"content_block\";\n\t\tentryId: string;\n\t\tblockIndex?: number;\n\t\trationale?: string;\n\t}>;\n}\n\nexport interface CompactableContentBlock {\n\tentryId: string;\n\tblockIndex: number;\n\ttype: string;\n\ttext: string;\n\ttokenEstimate: number;\n\tprotected: boolean;\n\ttoolCallId?: string;\n}\n\nexport interface CompactableTranscriptEntry {\n\tentryId: string;\n\tentryType: SessionEntry[\"type\"];\n\trole: AgentMessage[\"role\"];\n\ttext: string;\n\ttokenEstimate: number;\n\tprotected: boolean;\n\tcontentBlocks: CompactableContentBlock[];\n\tmessage: AgentMessage;\n\ttoolCallIds: string[];\n\ttoolResultFor?: string;\n}\n\nexport interface CompactableTranscript {\n\tentries: CompactableTranscriptEntry[];\n\tprotectedEntryIds: string[];\n\ttokensBefore: number;\n\tsettings: CompactionSettings;\n}\n\nexport interface ContextCompactionPreparation {\n\ttranscript: CompactableTranscript;\n\tbranchEntries: SessionEntry[];\n}\n\nexport interface ValidatedContextDeletionPlan {\n\tdeletedTargets: ContextDeletionTarget[];\n\tprotectedEntryIds: string[];\n\tstats: ContextCompactionStats;\n}\n\nexport interface ContextCompactionResult extends ValidatedContextDeletionPlan {\n\tpromptVersion: typeof CONTEXT_COMPACTION_PROMPT_VERSION;\n\tbackupPath?: string;\n}\n\nconst CONTEXT_DELETION_PLAN_TOOL_NAME = \"context_deletion_plan\";\n\nconst ContextDeletionPlanToolParameters = Type.Object(\n\t{\n\t\tdeletions: Type.Array(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tkind: StringEnum([\"entry\", \"content_block\"] as const, {\n\t\t\t\t\t\tdescription: \"Delete an entire transcript entry or a single content block within one entry.\",\n\t\t\t\t\t}),\n\t\t\t\t\tentryId: Type.String({ minLength: 1, description: \"Stable transcript entry id to delete from.\" }),\n\t\t\t\t\tblockIndex: Type.Optional(\n\t\t\t\t\t\tType.Integer({\n\t\t\t\t\t\t\tminimum: 0,\n\t\t\t\t\t\t\tdescription: \"Required when kind is content_block; omit when kind is entry.\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t\t{ description: \"Deletion targets only. Protected entries and recent active context must not be included.\" },\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst CONTEXT_DELETION_PLAN_TOOL = {\n\tname: CONTEXT_DELETION_PLAN_TOOL_NAME,\n\tdescription: \"Emit the final context compaction deletion plan as structured data.\",\n\tparameters: ContextDeletionPlanToolParameters,\n} as const;\n\nconst CONTEXT_COMPACTION_SYSTEM_PROMPT =\n\t\"You are a context compaction planner for an AI coding assistant transcript. Call the context_deletion_plan tool with deletion targets only.\";\n\nconst CONTEXT_COMPACTION_FIXED_PROMPT = `You are a context compaction planner for an AI coding assistant transcript.\n\nYour task is deletion-only verbatim compaction.\n\nYou MUST NOT summarize.\nYou MUST NOT paraphrase.\nYou MUST NOT generate replacement context.\nYou MUST NOT mutate retained transcript objects or content.\nAnother step will apply deletions locally. Return only deletion targets by stable ID.\n\nWhat Gets Deleted:\n- Redundant tool outputs: file reads already acted on, grep/search results already processed, passing test output no longer needed.\n- Exploratory dead ends: irrelevant files read, unhelpful or empty searches.\n- Verbose boilerplate: license headers, import blocks the agent isn't modifying, configuration files read for reference.\n- Superseded information: earlier versions of files that have since been edited, old error messages from bugs already fixed.\n\nWhat Survives:\n- Active file paths and line numbers: Any reference the agent might need to navigate.\n- Current error messages: Unresolved bugss and their exact text.\n- Reasoning decisions: Why the agent chose approach A over B. An agent's chain of thought (why it chose this file, what pattern it noticed, what fix it decided on) carries more information-per-token than the raw grep output or file content that informed those decisions.\n- Recent tool calls and their results: The last 3-5 operations.\n- User instructions: The original task and any clarifications.\n\n<output_format>\nCall the context_deletion_plan tool exactly once with deletion targets in this shape:\n{ \"deletions\": [{ \"kind\": \"entry\", \"entryId\": \"...\" }] }\n\nFor content-block deletions, use:\n{ \"kind\": \"content_block\", \"entryId\": \"...\", \"blockIndex\": 0 }\n\nDo not write JSON or prose in a text response. The tool call is the final answer.\n</output_format>`;\n\nfunction getMessageFromEntry(entry: SessionEntry): AgentMessage | undefined {\n\tif (entry.type === \"message\") {\n\t\treturn entry.message;\n\t}\n\tif (entry.type === \"custom_message\") {\n\t\treturn createCustomMessage(\n\t\t\tentry.customType,\n\t\t\tentry.content,\n\t\t\tentry.display,\n\t\t\tentry.details,\n\t\t\tentry.timestamp,\n\t\t\tentry.excludeFromContext,\n\t\t);\n\t}\n\tif (entry.type === \"branch_summary\") {\n\t\treturn createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp);\n\t}\n\treturn undefined;\n}\n\nfunction isExcludedFromLlmContext(message: AgentMessage): boolean {\n\tswitch (message.role) {\n\t\tcase \"bashExecution\":\n\t\t\treturn Boolean(message.excludeFromContext);\n\t\tcase \"custom\":\n\t\t\treturn (message as { excludeFromContext?: boolean }).excludeFromContext === true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction getContextEligibleMessageFromEntry(entry: SessionEntry): AgentMessage | undefined {\n\tconst message = getMessageFromEntry(entry);\n\tif (!message || isExcludedFromLlmContext(message)) return undefined;\n\treturn message;\n}\n\nfunction textFromUnknownContent(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (!Array.isArray(content)) return JSON.stringify(content);\n\treturn content.map((block) => textFromContentBlock(block)).join(\"\\n\");\n}\n\nfunction textFromContentBlock(block: unknown): string {\n\tif (!block || typeof block !== \"object\") return String(block);\n\tconst record = block as Record<string, unknown>;\n\tif (record.type === \"text\" && typeof record.text === \"string\") return record.text;\n\tif (record.type === \"thinking\" && typeof record.thinking === \"string\") return record.thinking;\n\tif (record.type === \"toolCall\") {\n\t\tconst name = typeof record.name === \"string\" ? record.name : \"tool\";\n\t\tconst id = typeof record.id === \"string\" ? record.id : \"unknown\";\n\t\tconst args = \"arguments\" in record ? JSON.stringify(record.arguments) : \"\";\n\t\treturn `toolCall ${id} ${name} ${args}`.trim();\n\t}\n\tif (record.type === \"image\") return \"[image]\";\n\treturn JSON.stringify(record);\n}\n\nconst IMAGE_BLOCK_CHAR_ESTIMATE = 4800;\nconst IMAGE_BLOCK_TOKEN_ESTIMATE = Math.ceil(IMAGE_BLOCK_CHAR_ESTIMATE / 4);\n\nfunction estimateTextTokens(text: string): number {\n\treturn Math.max(1, Math.ceil(text.length / 4));\n}\n\nfunction estimateContentBlockTokens(block: unknown, text: string): number {\n\tif (block && typeof block === \"object\" && (block as { type?: unknown }).type === \"image\") {\n\t\treturn IMAGE_BLOCK_TOKEN_ESTIMATE;\n\t}\n\treturn estimateTextTokens(text);\n}\n\nfunction getToolCallIdFromBlock(block: unknown): string | undefined {\n\tif (!block || typeof block !== \"object\") return undefined;\n\tconst record = block as Record<string, unknown>;\n\tif (record.type !== \"toolCall\") return undefined;\n\treturn typeof record.id === \"string\" ? record.id : undefined;\n}\n\nfunction getToolResultCallId(message: AgentMessage): string | undefined {\n\tif (message.role !== \"toolResult\") return undefined;\n\tconst callId = (message as { toolCallId?: unknown }).toolCallId;\n\treturn typeof callId === \"string\" ? callId : undefined;\n}\n\nfunction contentBlocksForEntry(\n\tentryId: string,\n\tmessage: AgentMessage,\n\tprotectedEntry: boolean,\n\texistingDeletedBlocks: ReadonlySet<number> | undefined,\n): CompactableContentBlock[] {\n\tif (message.role === \"compactionSummary\") {\n\t\tconst text = message.summary;\n\t\treturn [\n\t\t\t{\n\t\t\t\tentryId,\n\t\t\t\tblockIndex: 0,\n\t\t\t\ttype: \"summary\",\n\t\t\t\ttext,\n\t\t\t\ttokenEstimate: estimateTextTokens(text),\n\t\t\t\tprotected: protectedEntry,\n\t\t\t},\n\t\t];\n\t}\n\n\tconst content = (message as { content?: unknown }).content;\n\tif (!Array.isArray(content)) return [];\n\n\treturn content\n\t\t.map((block, blockIndex): CompactableContentBlock | undefined => {\n\t\t\tif (existingDeletedBlocks?.has(blockIndex)) return undefined;\n\t\t\tconst text = textFromContentBlock(block);\n\t\t\treturn {\n\t\t\t\tentryId,\n\t\t\t\tblockIndex,\n\t\t\t\ttype:\n\t\t\t\t\tblock && typeof block === \"object\" && typeof (block as { type?: unknown }).type === \"string\"\n\t\t\t\t\t\t? ((block as { type: string }).type)\n\t\t\t\t\t\t: \"unknown\",\n\t\t\t\ttext,\n\t\t\t\ttokenEstimate: estimateContentBlockTokens(block, text),\n\t\t\t\tprotected: protectedEntry,\n\t\t\t\ttoolCallId: getToolCallIdFromBlock(block),\n\t\t\t};\n\t\t})\n\t\t.filter((block): block is CompactableContentBlock => block !== undefined);\n}\n\nfunction messageText(message: AgentMessage): string {\n\tswitch (message.role) {\n\t\tcase \"bashExecution\":\n\t\t\treturn `Ran ${message.command}\\n${message.output}`;\n\t\tcase \"branchSummary\":\n\t\tcase \"compactionSummary\":\n\t\t\treturn message.summary;\n\t\tcase \"custom\":\n\t\tcase \"toolResult\":\n\t\tcase \"user\":\n\t\t\treturn textFromUnknownContent(message.content);\n\t\tcase \"assistant\":\n\t\t\treturn textFromUnknownContent(message.content);\n\t}\n}\n\nfunction hasAssistantError(message: AgentMessage): boolean {\n\treturn message.role === \"assistant\" && (message as AssistantMessage).stopReason === \"error\";\n}\n\nfunction hasToolResultError(message: AgentMessage): boolean {\n\treturn message.role === \"toolResult\" && (message as { isError?: unknown }).isError === true;\n}\n\nfunction hasFailedBashExecution(message: AgentMessage): boolean {\n\treturn message.role === \"bashExecution\" && typeof message.exitCode === \"number\" && message.exitCode !== 0;\n}\n\nfunction collectLatestSummaryCompactionIndex(pathEntries: SessionEntry[]): number {\n\tfor (let i = pathEntries.length - 1; i >= 0; i--) {\n\t\tif (pathEntries[i].type === \"compaction\") return i;\n\t}\n\treturn -1;\n}\n\nfunction collectActiveEntryIndices(pathEntries: SessionEntry[], latestCompactionIndex: number): number[] {\n\tif (latestCompactionIndex < 0) {\n\t\treturn pathEntries.map((_, index) => index);\n\t}\n\n\tconst latestCompaction = pathEntries[latestCompactionIndex];\n\tif (latestCompaction.type !== \"compaction\") return pathEntries.map((_, index) => index);\n\n\tconst indices: number[] = [];\n\tlet foundFirstKept = false;\n\tfor (let i = 0; i < latestCompactionIndex; i++) {\n\t\tconst entry = pathEntries[i];\n\t\tif (entry.id === latestCompaction.firstKeptEntryId) {\n\t\t\tfoundFirstKept = true;\n\t\t}\n\t\tif (foundFirstKept) indices.push(i);\n\t}\n\tfor (let i = latestCompactionIndex + 1; i < pathEntries.length; i++) {\n\t\tindices.push(i);\n\t}\n\treturn indices;\n}\n\nfunction isProtectedEntry(\n\tentry: SessionEntry,\n\tmessage: AgentMessage,\n\trecentEntryIds: ReadonlySet<string>,\n): boolean {\n\tif (recentEntryIds.has(entry.id)) return true;\n\tif (message.role === \"user\") return true;\n\tif (message.role === \"custom\") return true;\n\tif (message.role === \"branchSummary\" || message.role === \"compactionSummary\") return true;\n\tif (hasAssistantError(message) || hasToolResultError(message)) return true;\n\tif (hasFailedBashExecution(message)) return true;\n\tif (entry.type === \"branch_summary\") return true;\n\treturn false;\n}\n\nexport function prepareContextCompaction(\n\tpathEntries: SessionEntry[],\n\tsettings: CompactionSettings,\n): ContextCompactionPreparation | undefined {\n\tif (pathEntries.length === 0) return undefined;\n\n\tconst latestCompactionIndex = collectLatestSummaryCompactionIndex(pathEntries);\n\tconst deletionFilters = buildContextDeletionFilters(pathEntries);\n\tconst filteredPathEntries = buildContextDeletionFilteredPath(pathEntries, deletionFilters);\n\tconst filteredEntryById = new Map(filteredPathEntries.map((entry) => [entry.id, entry]));\n\tconst activeEntryIndices = collectActiveEntryIndices(pathEntries, latestCompactionIndex);\n\tconst messageEntryIds = activeEntryIndices\n\t\t.map((index) => filteredEntryById.get(pathEntries[index].id))\n\t\t.filter((entry): entry is SessionEntry => entry !== undefined && getContextEligibleMessageFromEntry(entry) !== undefined)\n\t\t.map((entry) => entry.id);\n\tconst recentEntryIds = new Set(messageEntryIds.slice(-5));\n\tconst protectedEntryIds = new Set<string>();\n\tconst entries: CompactableTranscriptEntry[] = [];\n\n\tif (latestCompactionIndex >= 0) {\n\t\tconst latestCompaction = pathEntries[latestCompactionIndex];\n\t\tif (latestCompaction.type === \"compaction\") {\n\t\t\tconst message = createCompactionSummaryMessage(\n\t\t\t\tlatestCompaction.summary,\n\t\t\t\tlatestCompaction.tokensBefore,\n\t\t\t\tlatestCompaction.timestamp,\n\t\t\t);\n\t\t\tconst contentBlocks = contentBlocksForEntry(latestCompaction.id, message, true, undefined);\n\t\t\tprotectedEntryIds.add(latestCompaction.id);\n\t\t\tentries.push({\n\t\t\t\tentryId: latestCompaction.id,\n\t\t\t\tentryType: latestCompaction.type,\n\t\t\t\trole: message.role,\n\t\t\t\ttext: messageText(message),\n\t\t\t\ttokenEstimate: estimateTokens(message),\n\t\t\t\tprotected: true,\n\t\t\t\tcontentBlocks,\n\t\t\t\tmessage,\n\t\t\t\ttoolCallIds: [],\n\t\t\t\ttoolResultFor: undefined,\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const index of activeEntryIndices) {\n\t\tconst rawEntry = pathEntries[index];\n\t\tconst entry = filteredEntryById.get(rawEntry.id);\n\t\tif (!entry || entry.type === \"context_compaction\") continue;\n\t\tconst message = getContextEligibleMessageFromEntry(entry);\n\t\tif (!message) continue;\n\t\tconst protectedEntry = isProtectedEntry(entry, message, recentEntryIds);\n\t\tif (protectedEntry) protectedEntryIds.add(entry.id);\n\t\tconst rawMessage = getContextEligibleMessageFromEntry(rawEntry) ?? message;\n\t\tconst contentBlocks = contentBlocksForEntry(\n\t\t\tentry.id,\n\t\t\trawMessage,\n\t\t\tprotectedEntry,\n\t\t\tdeletionFilters.deletedContentBlocks.get(entry.id),\n\t\t);\n\t\tconst toolCallIds = contentBlocks.map((block) => block.toolCallId).filter((id): id is string => id !== undefined);\n\t\tconst text = contentBlocks.length > 0 ? contentBlocks.map((block) => block.text).join(\"\\n\") : messageText(message);\n\t\tentries.push({\n\t\t\tentryId: entry.id,\n\t\t\tentryType: entry.type,\n\t\t\trole: message.role,\n\t\t\ttext,\n\t\t\ttokenEstimate: estimateTokens(message),\n\t\t\tprotected: protectedEntry,\n\t\t\tcontentBlocks,\n\t\t\tmessage,\n\t\t\ttoolCallIds,\n\t\t\ttoolResultFor: getToolResultCallId(message),\n\t\t});\n\t}\n\n\tif (entries.length < 2) return undefined;\n\n\treturn {\n\t\tbranchEntries: pathEntries,\n\t\ttranscript: {\n\t\t\tentries,\n\t\t\tprotectedEntryIds: [...protectedEntryIds],\n\t\t\ttokensBefore: entries.reduce((total, entry) => total + entry.tokenEstimate, 0),\n\t\t\tsettings,\n\t\t},\n\t};\n}\n\nfunction targetKey(target: ContextDeletionTarget): string {\n\treturn target.kind === \"entry\" ? `entry:${target.entryId}` : `content_block:${target.entryId}:${target.blockIndex}`;\n}\n\nfunction rawTargetKey(target: RawContextDeletionPlan[\"deletions\"][number]): string {\n\treturn target.kind === \"entry\" ? `entry:${target.entryId}` : `content_block:${target.entryId}:${target.blockIndex}`;\n}\n\nfunction normalizeRawTarget(target: RawContextDeletionPlan[\"deletions\"][number]): ContextDeletionTarget {\n\tif (target.kind === \"entry\") return { kind: \"entry\", entryId: target.entryId };\n\treturn { kind: \"content_block\", entryId: target.entryId, blockIndex: target.blockIndex as number };\n}\n\nfunction getDeletedEntryIds(targets: readonly ContextDeletionTarget[]): Set<string> {\n\treturn new Set(targets.filter((target) => target.kind === \"entry\").map((target) => target.entryId));\n}\n\nfunction getDeletedContentBlocks(targets: readonly ContextDeletionTarget[]): Map<string, Set<number>> {\n\tconst blocksByEntry = new Map<string, Set<number>>();\n\tfor (const target of targets) {\n\t\tif (target.kind !== \"content_block\") continue;\n\t\tconst blocks = blocksByEntry.get(target.entryId) ?? new Set<number>();\n\t\tblocks.add(target.blockIndex);\n\t\tblocksByEntry.set(target.entryId, blocks);\n\t}\n\treturn blocksByEntry;\n}\n\nfunction isToolCallBlockDeleted(\n\tentry: CompactableTranscriptEntry,\n\tcallId: string,\n\tdeletedEntryIds: ReadonlySet<string>,\n\tdeletedContentBlocks: ReadonlyMap<string, ReadonlySet<number>>,\n): boolean {\n\tif (deletedEntryIds.has(entry.entryId)) return true;\n\tconst deletedBlocks = deletedContentBlocks.get(entry.entryId);\n\tif (!deletedBlocks) return false;\n\treturn entry.contentBlocks.some((block) => block.toolCallId === callId && deletedBlocks.has(block.blockIndex));\n}\n\nfunction validateToolDependencies(transcript: CompactableTranscript, targets: readonly ContextDeletionTarget[]): void {\n\tconst deletedEntryIds = getDeletedEntryIds(targets);\n\tconst deletedContentBlocks = getDeletedContentBlocks(targets);\n\tconst callEntries = new Map<string, CompactableTranscriptEntry>();\n\tconst resultEntries = new Map<string, CompactableTranscriptEntry[]>();\n\n\tfor (const entry of transcript.entries) {\n\t\tfor (const callId of entry.toolCallIds) {\n\t\t\tcallEntries.set(callId, entry);\n\t\t}\n\t\tif (entry.toolResultFor) {\n\t\t\tconst results = resultEntries.get(entry.toolResultFor) ?? [];\n\t\t\tresults.push(entry);\n\t\t\tresultEntries.set(entry.toolResultFor, results);\n\t\t}\n\t}\n\n\tfor (const [callId, callEntry] of callEntries) {\n\t\tconst callDeleted = isToolCallBlockDeleted(callEntry, callId, deletedEntryIds, deletedContentBlocks);\n\t\tconst results = resultEntries.get(callId) ?? [];\n\t\tif (callDeleted) {\n\t\t\tconst danglingResult = results.find((entry) => !deletedEntryIds.has(entry.entryId));\n\t\t\tif (danglingResult) {\n\t\t\t\tthrow new Error(`Deleting tool call ${callId} would leave tool result entry ${danglingResult.entryId} orphaned`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst deletedResult = results.find((entry) => deletedEntryIds.has(entry.entryId));\n\t\tif (deletedResult) {\n\t\t\tthrow new Error(`Deleting tool result entry ${deletedResult.entryId} would leave tool call ${callId} dangling`);\n\t\t}\n\t}\n}\n\nfunction computeContextCompactionStats(\n\ttranscript: CompactableTranscript,\n\ttargets: readonly ContextDeletionTarget[],\n): ContextCompactionStats {\n\tconst entryById = new Map(transcript.entries.map((entry) => [entry.entryId, entry]));\n\tconst deletedEntryIds = getDeletedEntryIds(targets);\n\tlet deletedTokens = 0;\n\tlet objectsDeleted = 0;\n\n\tfor (const entryId of deletedEntryIds) {\n\t\tconst entry = entryById.get(entryId);\n\t\tif (!entry) continue;\n\t\tdeletedTokens += entry.tokenEstimate;\n\t\tobjectsDeleted += 1 + entry.contentBlocks.length;\n\t}\n\n\tfor (const target of targets) {\n\t\tif (target.kind !== \"content_block\" || deletedEntryIds.has(target.entryId)) continue;\n\t\tconst entry = entryById.get(target.entryId);\n\t\tif (!entry) continue;\n\t\tconst block = entry.contentBlocks.find((item) => item.blockIndex === target.blockIndex);\n\t\tif (!block) continue;\n\t\tdeletedTokens += block.tokenEstimate;\n\t\tobjectsDeleted += 1;\n\t}\n\n\tconst objectsBefore = transcript.entries.length + transcript.entries.reduce((total, entry) => total + entry.contentBlocks.length, 0);\n\tconst tokensBefore = transcript.tokensBefore;\n\tconst tokensAfter = Math.max(0, tokensBefore - deletedTokens);\n\tconst percentReduction = tokensBefore > 0 ? Math.round(((tokensBefore - tokensAfter) / tokensBefore) * 1000) / 10 : 0;\n\treturn {\n\t\tobjectsBefore,\n\t\tobjectsAfter: Math.max(0, objectsBefore - objectsDeleted),\n\t\tobjectsDeleted,\n\t\ttokensBefore,\n\t\ttokensAfter,\n\t\tpercentReduction,\n\t};\n}\n\nexport function validateContextDeletionPlan(\n\tplan: RawContextDeletionPlan,\n\ttranscript: CompactableTranscript,\n): ValidatedContextDeletionPlan {\n\tif (!plan || typeof plan !== \"object\" || !Array.isArray(plan.deletions)) {\n\t\tthrow new Error(\"Context deletion plan must be an object with a deletions array\");\n\t}\n\n\tconst entryById = new Map(transcript.entries.map((entry) => [entry.entryId, entry]));\n\tconst seen = new Set<string>();\n\tconst deletedEntryIds = new Set<string>();\n\tconst deletedTargets: ContextDeletionTarget[] = [];\n\n\tfor (const deletion of plan.deletions) {\n\t\tif (!deletion || typeof deletion !== \"object\") {\n\t\t\tthrow new Error(\"Deletion target must be an object\");\n\t\t}\n\t\tif (deletion.kind !== \"entry\" && deletion.kind !== \"content_block\") {\n\t\t\tthrow new Error(`Unsupported deletion target kind: ${String((deletion as { kind?: unknown }).kind)}`);\n\t\t}\n\t\tif (typeof deletion.entryId !== \"string\" || deletion.entryId.length === 0) {\n\t\t\tthrow new Error(\"Deletion target entryId must be a non-empty string\");\n\t\t}\n\t\tconst entry = entryById.get(deletion.entryId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Unknown deletion target entryId: ${deletion.entryId}`);\n\t\t}\n\t\tif (entry.protected) {\n\t\t\tthrow new Error(`Deletion target ${deletion.entryId} is protected`);\n\t\t}\n\n\t\tif (deletion.kind === \"content_block\") {\n\t\t\tif (!Number.isInteger(deletion.blockIndex) || deletion.blockIndex === undefined || deletion.blockIndex < 0) {\n\t\t\t\tthrow new Error(`Invalid content block index for entry ${deletion.entryId}`);\n\t\t\t}\n\t\t\tconst block = entry.contentBlocks.find((item) => item.blockIndex === deletion.blockIndex);\n\t\t\tif (!block) {\n\t\t\t\tthrow new Error(`Unknown content block ${deletion.blockIndex} for entry ${deletion.entryId}`);\n\t\t\t}\n\t\t\tif (block.protected) {\n\t\t\t\tthrow new Error(`Content block ${deletion.entryId}:${deletion.blockIndex} is protected`);\n\t\t\t}\n\t\t\tif (entry.contentBlocks.length <= 1) {\n\t\t\t\tthrow new Error(`Deleting the only content block of ${deletion.entryId} must be an entry deletion`);\n\t\t\t}\n\t\t}\n\n\t\tconst key = rawTargetKey(deletion);\n\t\tif (seen.has(key)) {\n\t\t\tthrow new Error(`Duplicate deletion target: ${key}`);\n\t\t}\n\t\tseen.add(key);\n\t\tconst normalized = normalizeRawTarget(deletion);\n\t\tdeletedTargets.push(normalized);\n\t\tif (normalized.kind === \"entry\") deletedEntryIds.add(normalized.entryId);\n\t}\n\n\tfor (const target of deletedTargets) {\n\t\tif (target.kind === \"content_block\" && deletedEntryIds.has(target.entryId)) {\n\t\t\tthrow new Error(`Deletion target ${targetKey(target)} overlaps with entry deletion`);\n\t\t}\n\t}\n\n\tconst deletedContentBlocks = getDeletedContentBlocks(deletedTargets);\n\tfor (const [entryId, blockIndexes] of deletedContentBlocks) {\n\t\tconst entry = entryById.get(entryId);\n\t\tif (entry?.contentBlocks.every((block) => blockIndexes.has(block.blockIndex))) {\n\t\t\tthrow new Error(`Content-block deletions for ${entryId} would remove every content block`);\n\t\t}\n\t}\n\n\tvalidateToolDependencies(transcript, deletedTargets);\n\n\tconst remainingEntries = transcript.entries.filter((entry) => !deletedEntryIds.has(entry.entryId));\n\tif (remainingEntries.length === 0) {\n\t\tthrow new Error(\"Deletion plan would remove all context entries\");\n\t}\n\tconst hasTaskBearingContext = remainingEntries.some(\n\t\t(entry) => entry.role === \"user\" || (entry.role === \"compactionSummary\" && entry.protected),\n\t);\n\tif (!hasTaskBearingContext) {\n\t\tthrow new Error(\"Deletion plan would leave no user task in context\");\n\t}\n\n\treturn {\n\t\tdeletedTargets,\n\t\tprotectedEntryIds: [...transcript.protectedEntryIds],\n\t\tstats: computeContextCompactionStats(transcript, deletedTargets),\n\t};\n}\n\nfunction stripJsonFence(text: string): string {\n\tconst trimmed = text.trim();\n\tif (!trimmed.startsWith(\"```\") || !trimmed.endsWith(\"```\")) return trimmed;\n\n\tconst firstLineEnd = trimmed.indexOf(\"\\n\");\n\tif (firstLineEnd < 0) return trimmed;\n\n\tconst fenceInfo = trimmed.slice(3, firstLineEnd).trim().toLowerCase();\n\tif (fenceInfo !== \"\" && fenceInfo !== \"json\") return trimmed;\n\n\treturn trimmed.slice(firstLineEnd + 1, -3).trim();\n}\n\nfunction rawContextDeletionPlanFromObject(value: unknown, source: string): RawContextDeletionPlan {\n\tif (!value || typeof value !== \"object\" || !Array.isArray((value as { deletions?: unknown }).deletions)) {\n\t\tthrow new Error(`${source} must contain a deletions array`);\n\t}\n\treturn value as RawContextDeletionPlan;\n}\n\nexport function parseContextDeletionPlan(text: string): RawContextDeletionPlan {\n\tconst stripped = stripJsonFence(text);\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(stripped);\n\t} catch (error) {\n\t\tthrow new Error(`Failed to parse context deletion plan JSON: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n\treturn rawContextDeletionPlanFromObject(parsed, \"Context deletion plan JSON\");\n}\n\nfunction isContextDeletionPlanToolCall(content: AssistantMessage[\"content\"][number]): content is ToolCall {\n\treturn content.type === \"toolCall\" && content.name === CONTEXT_DELETION_PLAN_TOOL_NAME;\n}\n\nfunction textContentFromResponse(response: AssistantMessage): string {\n\treturn response.content\n\t\t.filter((content): content is { type: \"text\"; text: string } => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\");\n}\n\nexport function parseContextDeletionPlanResponse(response: AssistantMessage): RawContextDeletionPlan {\n\tconst toolCalls = response.content.filter(isContextDeletionPlanToolCall);\n\tif (toolCalls.length > 1) {\n\t\tthrow new Error(`Context compaction planner called ${CONTEXT_DELETION_PLAN_TOOL_NAME} more than once`);\n\t}\n\tconst toolCall = toolCalls[0];\n\tif (toolCall) {\n\t\treturn rawContextDeletionPlanFromObject(toolCall.arguments, `${CONTEXT_DELETION_PLAN_TOOL_NAME} arguments`);\n\t}\n\n\tconst textContent = textContentFromResponse(response);\n\tif (textContent.trim().length === 0) {\n\t\tthrow new Error(`Context compaction planner did not call ${CONTEXT_DELETION_PLAN_TOOL_NAME}`);\n\t}\n\treturn parseContextDeletionPlan(textContent);\n}\n\nfunction truncateForPrompt(text: string, maxChars: number): string {\n\tif (text.length <= maxChars) return text;\n\treturn `${text.slice(0, maxChars)}\\n[... ${text.length - maxChars} more characters omitted from planner prompt]`;\n}\n\nfunction plannerTranscriptPayload(transcript: CompactableTranscript): unknown {\n\treturn transcript.entries\n\t\t.filter((entry) => !isExcludedFromLlmContext(entry.message))\n\t\t.map((entry) => ({\n\t\t\tentryId: entry.entryId,\n\t\t\trole: entry.role,\n\t\t\tprotected: entry.protected,\n\t\t\ttokenEstimate: entry.tokenEstimate,\n\t\t\ttoolCallIds: entry.toolCallIds,\n\t\t\ttoolResultFor: entry.toolResultFor,\n\t\t\tcontentBlocks: entry.contentBlocks.map((block) => ({\n\t\t\t\tblockIndex: block.blockIndex,\n\t\t\t\ttype: block.type,\n\t\t\t\tprotected: block.protected,\n\t\t\t\ttoolCallId: block.toolCallId,\n\t\t\t\ttext: truncateForPrompt(block.text, 2000),\n\t\t\t})),\n\t\t\ttext: truncateForPrompt(entry.text, 4000),\n\t\t}));\n}\n\nexport function buildContextCompactionPrompt(transcript: CompactableTranscript): string {\n\treturn `${CONTEXT_COMPACTION_FIXED_PROMPT}\\n\\n<transcript-json>\\n${JSON.stringify(plannerTranscriptPayload(transcript), null, 2)}\\n</transcript-json>`;\n}\n\nexport async function planContextDeletions(\n\ttranscript: CompactableTranscript,\n\tmodel: Model<Api>,\n\tapiKey: string,\n\theaders?: Record<string, string>,\n\tsignal?: AbortSignal,\n\tthinkingLevel?: ThinkingLevel,\n): Promise<RawContextDeletionPlan> {\n\tconst maxTokens = Math.min(4096, model.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY);\n\tconst messages = [\n\t\t{\n\t\t\trole: \"user\" as const,\n\t\t\tcontent: [{ type: \"text\" as const, text: buildContextCompactionPrompt(transcript) }],\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t];\n\tconst options =\n\t\tmodel.reasoning && thinkingLevel && thinkingLevel !== \"off\"\n\t\t\t? { maxTokens, signal, apiKey, headers, reasoning: thinkingLevel }\n\t\t\t: { maxTokens, signal, apiKey, headers };\n\tconst response = await completeSimple(\n\t\tmodel,\n\t\t{ systemPrompt: CONTEXT_COMPACTION_SYSTEM_PROMPT, messages, tools: [CONTEXT_DELETION_PLAN_TOOL] },\n\t\toptions,\n\t);\n\tif (response.stopReason === \"error\") {\n\t\tthrow new Error(`Context compaction planning failed: ${response.errorMessage || \"Unknown error\"}`);\n\t}\n\treturn parseContextDeletionPlanResponse(response);\n}\n\nexport async function contextCompact(\n\tpreparation: ContextCompactionPreparation,\n\tmodel: Model<Api>,\n\tapiKey: string,\n\theaders?: Record<string, string>,\n\tsignal?: AbortSignal,\n\tthinkingLevel?: ThinkingLevel,\n): Promise<ValidatedContextDeletionPlan> {\n\tconst plan = await planContextDeletions(preparation.transcript, model, apiKey, headers, signal, thinkingLevel);\n\tconst validated = validateContextDeletionPlan(plan, preparation.transcript);\n\tif (validated.deletedTargets.length === 0) {\n\t\tthrow new Error(\"No safe context deletions proposed\");\n\t}\n\treturn validated;\n}\n"]}
@@ -3,5 +3,6 @@
3
3
  */
4
4
  export * from "./branch-summarization.ts";
5
5
  export * from "./compaction.ts";
6
+ export * from "./context-compaction.ts";
6
7
  export * from "./utils.ts";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/compaction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC","sourcesContent":["/**\n * Compaction and summarization utilities.\n */\n\nexport * from \"./branch-summarization.ts\";\nexport * from \"./compaction.ts\";\nexport * from \"./utils.ts\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/compaction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC","sourcesContent":["/**\n * Compaction and summarization utilities.\n */\n\nexport * from \"./branch-summarization.ts\";\nexport * from \"./compaction.ts\";\nexport * from \"./context-compaction.ts\";\nexport * from \"./utils.ts\";\n"]}
@@ -3,5 +3,6 @@
3
3
  */
4
4
  export * from "./branch-summarization.js";
5
5
  export * from "./compaction.js";
6
+ export * from "./context-compaction.js";
6
7
  export * from "./utils.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/compaction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC","sourcesContent":["/**\n * Compaction and summarization utilities.\n */\n\nexport * from \"./branch-summarization.ts\";\nexport * from \"./compaction.ts\";\nexport * from \"./utils.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/compaction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC","sourcesContent":["/**\n * Compaction and summarization utilities.\n */\n\nexport * from \"./branch-summarization.ts\";\nexport * from \"./compaction.ts\";\nexport * from \"./context-compaction.ts\";\nexport * from \"./utils.ts\";\n"]}
@@ -14,7 +14,7 @@ import type { Static, TSchema } from "typebox";
14
14
  import type { Theme } from "../../modes/interactive/theme/theme.ts";
15
15
  import type { ResolvedResource } from "../package-manager.ts";
16
16
  import type { BashResult } from "../bash-executor.ts";
17
- import type { CompactionPreparation, CompactionResult } from "../compaction/index.ts";
17
+ import type { CompactionPreparation, CompactionResult, ContextCompactionResult } from "../compaction/index.ts";
18
18
  import type { EventBus } from "../event-bus.ts";
19
19
  import type { ExecOptions, ExecResult } from "../exec.ts";
20
20
  import type { ReadonlyFooterDataProvider } from "../footer-data-provider.ts";
@@ -229,8 +229,9 @@ export interface ContextUsage {
229
229
  percent: number | null;
230
230
  }
231
231
  export interface CompactOptions {
232
+ /** @deprecated Default compaction is deletion-only and does not accept custom instructions. */
232
233
  customInstructions?: string;
233
- onComplete?: (result: CompactionResult) => void;
234
+ onComplete?: (result: ContextCompactionResult) => void;
234
235
  onError?: (error: Error) => void;
235
236
  }
236
237
  export interface WorkflowStageOrchestrationContext {