@tomsun28/pizza 0.0.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/README.md +20 -143
  2. package/README.zh-CN.md +36 -0
  3. package/dist/bun/cli.d.ts +2 -0
  4. package/dist/bun/cli.js +6 -0
  5. package/dist/bun/register-bedrock.d.ts +1 -0
  6. package/dist/bun/register-bedrock.js +3 -0
  7. package/dist/cli/args.d.ts +48 -0
  8. package/dist/cli/args.js +330 -0
  9. package/dist/cli/config-selector.d.ts +13 -0
  10. package/dist/cli/config-selector.js +30 -0
  11. package/dist/cli/file-processor.d.ts +14 -0
  12. package/dist/cli/file-processor.js +82 -0
  13. package/dist/cli/initial-message.d.ts +17 -0
  14. package/dist/cli/initial-message.js +21 -0
  15. package/dist/cli/list-models.d.ts +8 -0
  16. package/dist/cli/list-models.js +96 -0
  17. package/dist/cli.d.ts +2 -0
  18. package/dist/cli.js +68 -0
  19. package/dist/config.d.ts +79 -0
  20. package/dist/config.js +223 -0
  21. package/dist/core/agent/index.d.ts +6 -0
  22. package/dist/core/agent/index.js +6 -0
  23. package/dist/core/agent/types.d.ts +202 -0
  24. package/dist/core/agent/types.js +51 -0
  25. package/dist/core/auth-storage.d.ts +135 -0
  26. package/dist/core/auth-storage.js +417 -0
  27. package/dist/core/bash-executor.d.ts +31 -0
  28. package/dist/core/bash-executor.js +107 -0
  29. package/dist/core/compaction/branch-summarization.d.ts +87 -0
  30. package/dist/core/compaction/branch-summarization.js +242 -0
  31. package/dist/core/compaction/compaction-engine.d.ts +40 -0
  32. package/dist/core/compaction/compaction-engine.js +292 -0
  33. package/dist/core/compaction/compaction.d.ts +106 -0
  34. package/dist/core/compaction/compaction.js +295 -0
  35. package/dist/core/compaction/index.d.ts +7 -0
  36. package/dist/core/compaction/index.js +7 -0
  37. package/dist/core/compaction/utils.d.ts +37 -0
  38. package/dist/core/compaction/utils.js +152 -0
  39. package/dist/core/defaults.d.ts +2 -0
  40. package/dist/core/defaults.js +1 -0
  41. package/dist/core/diagnostics.d.ts +14 -0
  42. package/dist/core/diagnostics.js +1 -0
  43. package/dist/core/event-bus.d.ts +8 -0
  44. package/dist/core/event-bus.js +24 -0
  45. package/dist/core/event-store/events.d.ts +465 -0
  46. package/dist/core/event-store/events.js +6 -0
  47. package/dist/core/event-store/index.d.ts +10 -0
  48. package/dist/core/event-store/index.js +10 -0
  49. package/dist/core/event-store/sqlite-store.d.ts +27 -0
  50. package/dist/core/event-store/sqlite-store.js +275 -0
  51. package/dist/core/event-store/store.d.ts +91 -0
  52. package/dist/core/event-store/store.js +7 -0
  53. package/dist/core/event-store/thread-scoped-store.d.ts +29 -0
  54. package/dist/core/event-store/thread-scoped-store.js +50 -0
  55. package/dist/core/event-store/types.d.ts +70 -0
  56. package/dist/core/event-store/types.js +7 -0
  57. package/dist/core/event-store/workspace.d.ts +37 -0
  58. package/dist/core/event-store/workspace.js +71 -0
  59. package/dist/core/exec.d.ts +28 -0
  60. package/dist/core/exec.js +74 -0
  61. package/dist/core/export-html/ansi-to-html.d.ts +21 -0
  62. package/dist/core/export-html/ansi-to-html.js +248 -0
  63. package/dist/core/export-html/index.d.ts +29 -0
  64. package/dist/core/export-html/index.js +186 -0
  65. package/dist/core/export-html/template.css +1017 -0
  66. package/dist/core/export-html/template.html +55 -0
  67. package/dist/core/export-html/template.js +1742 -0
  68. package/dist/core/export-html/tool-renderer.d.ts +39 -0
  69. package/dist/core/export-html/tool-renderer.js +94 -0
  70. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  71. package/dist/core/export-html/vendor/marked.min.js +6 -0
  72. package/dist/core/extensions/index.d.ts +12 -0
  73. package/dist/core/extensions/index.js +9 -0
  74. package/dist/core/extensions/loader.d.ts +24 -0
  75. package/dist/core/extensions/loader.js +492 -0
  76. package/dist/core/extensions/runner.d.ts +167 -0
  77. package/dist/core/extensions/runner.js +898 -0
  78. package/dist/core/extensions/session-context.d.ts +67 -0
  79. package/dist/core/extensions/session-context.js +272 -0
  80. package/dist/core/extensions/types.d.ts +1147 -0
  81. package/dist/core/extensions/types.js +44 -0
  82. package/dist/core/extensions/wrapper.d.ts +19 -0
  83. package/dist/core/extensions/wrapper.js +21 -0
  84. package/dist/core/footer-data-provider.d.ts +47 -0
  85. package/dist/core/footer-data-provider.js +321 -0
  86. package/dist/core/goal/index.d.ts +3 -0
  87. package/dist/core/goal/index.js +1 -0
  88. package/dist/core/goal/scheduler.d.ts +83 -0
  89. package/dist/core/goal/scheduler.js +154 -0
  90. package/dist/core/goal/types.d.ts +182 -0
  91. package/dist/core/goal/types.js +11 -0
  92. package/dist/core/index.d.ts +8 -0
  93. package/dist/core/index.js +8 -0
  94. package/dist/core/intent/classifier.d.ts +53 -0
  95. package/dist/core/intent/classifier.js +353 -0
  96. package/dist/core/intent/index.d.ts +8 -0
  97. package/dist/core/intent/index.js +8 -0
  98. package/dist/core/intent/tool-adapter.d.ts +31 -0
  99. package/dist/core/intent/tool-adapter.js +168 -0
  100. package/dist/core/intent/types.d.ts +71 -0
  101. package/dist/core/intent/types.js +6 -0
  102. package/dist/core/keybindings.d.ts +297 -0
  103. package/dist/core/keybindings.js +250 -0
  104. package/dist/core/messages.d.ts +30 -0
  105. package/dist/core/messages.js +134 -0
  106. package/dist/core/model-registry.d.ts +131 -0
  107. package/dist/core/model-registry.js +634 -0
  108. package/dist/core/model-resolver.d.ts +109 -0
  109. package/dist/core/model-resolver.js +486 -0
  110. package/dist/core/output-guard.d.ts +5 -0
  111. package/dist/core/output-guard.js +58 -0
  112. package/dist/core/package-manager.d.ts +196 -0
  113. package/dist/core/package-manager.js +1873 -0
  114. package/dist/core/projection/boundary-inferrer.d.ts +58 -0
  115. package/dist/core/projection/boundary-inferrer.js +122 -0
  116. package/dist/core/projection/event-to-message.d.ts +35 -0
  117. package/dist/core/projection/event-to-message.js +253 -0
  118. package/dist/core/projection/goal-projection.d.ts +67 -0
  119. package/dist/core/projection/goal-projection.js +339 -0
  120. package/dist/core/projection/index.d.ts +13 -0
  121. package/dist/core/projection/index.js +13 -0
  122. package/dist/core/projection/session-manager.d.ts +100 -0
  123. package/dist/core/projection/session-manager.js +331 -0
  124. package/dist/core/projection/session-projection.d.ts +58 -0
  125. package/dist/core/projection/session-projection.js +257 -0
  126. package/dist/core/projection/task-history.d.ts +13 -0
  127. package/dist/core/projection/task-history.js +61 -0
  128. package/dist/core/projection/timeline-projection.d.ts +82 -0
  129. package/dist/core/projection/timeline-projection.js +276 -0
  130. package/dist/core/projection/types.d.ts +69 -0
  131. package/dist/core/projection/types.js +6 -0
  132. package/dist/core/prompt-templates.d.ts +51 -0
  133. package/dist/core/prompt-templates.js +249 -0
  134. package/dist/core/resolve-config-value.d.ts +22 -0
  135. package/dist/core/resolve-config-value.js +125 -0
  136. package/dist/core/resource-loader.d.ts +193 -0
  137. package/dist/core/resource-loader.js +685 -0
  138. package/dist/core/runtime/ai-client.d.ts +12 -0
  139. package/dist/core/runtime/ai-client.js +153 -0
  140. package/dist/core/runtime/checkpoint.d.ts +12 -0
  141. package/dist/core/runtime/checkpoint.js +78 -0
  142. package/dist/core/runtime/index.d.ts +12 -0
  143. package/dist/core/runtime/index.js +12 -0
  144. package/dist/core/runtime/llm-types.d.ts +99 -0
  145. package/dist/core/runtime/llm-types.js +6 -0
  146. package/dist/core/runtime/local-runtime.d.ts +23 -0
  147. package/dist/core/runtime/local-runtime.js +59 -0
  148. package/dist/core/runtime/policies.d.ts +72 -0
  149. package/dist/core/runtime/policies.js +37 -0
  150. package/dist/core/runtime/reactor.d.ts +213 -0
  151. package/dist/core/runtime/reactor.js +992 -0
  152. package/dist/core/runtime/runtime.d.ts +191 -0
  153. package/dist/core/runtime/runtime.js +449 -0
  154. package/dist/core/runtime/types.d.ts +42 -0
  155. package/dist/core/runtime/types.js +1 -0
  156. package/dist/core/sdk.d.ts +12 -0
  157. package/dist/core/sdk.js +10 -0
  158. package/dist/core/session-context-builder.d.ts +9 -0
  159. package/dist/core/session-context-builder.js +87 -0
  160. package/dist/core/session-cwd.d.ts +18 -0
  161. package/dist/core/session-cwd.js +36 -0
  162. package/dist/core/session-facade-factory.d.ts +79 -0
  163. package/dist/core/session-facade-factory.js +460 -0
  164. package/dist/core/session-facade.d.ts +57 -0
  165. package/dist/core/session-facade.js +91 -0
  166. package/dist/core/session-listing.d.ts +30 -0
  167. package/dist/core/session-listing.js +168 -0
  168. package/dist/core/session-reader.d.ts +19 -0
  169. package/dist/core/session-reader.js +101 -0
  170. package/dist/core/session-ref.d.ts +7 -0
  171. package/dist/core/session-ref.js +25 -0
  172. package/dist/core/session-services.d.ts +51 -0
  173. package/dist/core/session-services.js +90 -0
  174. package/dist/core/session-stats.d.ts +43 -0
  175. package/dist/core/session-stats.js +41 -0
  176. package/dist/core/settings-manager.d.ts +236 -0
  177. package/dist/core/settings-manager.js +706 -0
  178. package/dist/core/skill-block-parser.d.ts +12 -0
  179. package/dist/core/skill-block-parser.js +15 -0
  180. package/dist/core/skills.d.ts +59 -0
  181. package/dist/core/skills.js +408 -0
  182. package/dist/core/slash-commands.d.ts +13 -0
  183. package/dist/core/slash-commands.js +17 -0
  184. package/dist/core/source-info.d.ts +17 -0
  185. package/dist/core/source-info.js +18 -0
  186. package/dist/core/system-prompt.d.ts +27 -0
  187. package/dist/core/system-prompt.js +179 -0
  188. package/dist/core/timings.d.ts +7 -0
  189. package/dist/core/timings.js +30 -0
  190. package/dist/core/tools/bash.d.ts +95 -0
  191. package/dist/core/tools/bash.js +513 -0
  192. package/dist/core/tools/builtin-commands.d.ts +75 -0
  193. package/dist/core/tools/builtin-commands.js +503 -0
  194. package/dist/core/tools/compat-commands.d.ts +12 -0
  195. package/dist/core/tools/compat-commands.js +1280 -0
  196. package/dist/core/tools/edit-diff.d.ts +59 -0
  197. package/dist/core/tools/edit-diff.js +263 -0
  198. package/dist/core/tools/edit.d.ts +49 -0
  199. package/dist/core/tools/edit.js +340 -0
  200. package/dist/core/tools/file-mutation-queue.d.ts +5 -0
  201. package/dist/core/tools/file-mutation-queue.js +36 -0
  202. package/dist/core/tools/find.d.ts +34 -0
  203. package/dist/core/tools/find.js +459 -0
  204. package/dist/core/tools/grep.d.ts +36 -0
  205. package/dist/core/tools/grep.js +422 -0
  206. package/dist/core/tools/index.d.ts +70 -0
  207. package/dist/core/tools/index.js +129 -0
  208. package/dist/core/tools/line-anchors.d.ts +33 -0
  209. package/dist/core/tools/line-anchors.js +151 -0
  210. package/dist/core/tools/ls.d.ts +36 -0
  211. package/dist/core/tools/ls.js +268 -0
  212. package/dist/core/tools/path-utils.d.ts +7 -0
  213. package/dist/core/tools/path-utils.js +80 -0
  214. package/dist/core/tools/read.d.ts +35 -0
  215. package/dist/core/tools/read.js +244 -0
  216. package/dist/core/tools/render-utils.d.ts +20 -0
  217. package/dist/core/tools/render-utils.js +48 -0
  218. package/dist/core/tools/session-split.d.ts +9 -0
  219. package/dist/core/tools/session-split.js +77 -0
  220. package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
  221. package/dist/core/tools/tool-definition-wrapper.js +32 -0
  222. package/dist/core/tools/truncate.d.ts +69 -0
  223. package/dist/core/tools/truncate.js +204 -0
  224. package/dist/core/tools/write.d.ts +25 -0
  225. package/dist/core/tools/write.js +211 -0
  226. package/dist/core/types/session-types.d.ts +123 -0
  227. package/dist/core/types/session-types.js +8 -0
  228. package/dist/index.d.ts +27 -0
  229. package/dist/index.js +38 -0
  230. package/dist/main.d.ts +11 -2
  231. package/dist/main.js +577 -149
  232. package/dist/modes/event-mapper.d.ts +115 -0
  233. package/dist/modes/event-mapper.js +200 -0
  234. package/dist/modes/gui/server.d.ts +14 -0
  235. package/dist/modes/gui/server.js +1032 -0
  236. package/dist/modes/index.d.ts +10 -0
  237. package/dist/modes/index.js +9 -0
  238. package/dist/modes/interactive/assets/clankolas.png +0 -0
  239. package/dist/modes/interactive/components/armin.d.ts +33 -0
  240. package/dist/modes/interactive/components/armin.js +328 -0
  241. package/dist/modes/interactive/components/assistant-message.d.ts +19 -0
  242. package/dist/modes/interactive/components/assistant-message.js +115 -0
  243. package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
  244. package/dist/modes/interactive/components/bash-execution.js +169 -0
  245. package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
  246. package/dist/modes/interactive/components/bordered-loader.js +50 -0
  247. package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
  248. package/dist/modes/interactive/components/branch-summary-message.js +41 -0
  249. package/dist/modes/interactive/components/brand-header.d.ts +33 -0
  250. package/dist/modes/interactive/components/brand-header.js +235 -0
  251. package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
  252. package/dist/modes/interactive/components/compaction-summary-message.js +42 -0
  253. package/dist/modes/interactive/components/config-selector.d.ts +70 -0
  254. package/dist/modes/interactive/components/config-selector.js +469 -0
  255. package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
  256. package/dist/modes/interactive/components/countdown-timer.js +27 -0
  257. package/dist/modes/interactive/components/custom-editor.d.ts +27 -0
  258. package/dist/modes/interactive/components/custom-editor.js +94 -0
  259. package/dist/modes/interactive/components/custom-message.d.ts +19 -0
  260. package/dist/modes/interactive/components/custom-message.js +73 -0
  261. package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
  262. package/dist/modes/interactive/components/daxnuts.js +137 -0
  263. package/dist/modes/interactive/components/diff.d.ts +11 -0
  264. package/dist/modes/interactive/components/diff.js +132 -0
  265. package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
  266. package/dist/modes/interactive/components/dynamic-border.js +19 -0
  267. package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
  268. package/dist/modes/interactive/components/earendil-announcement.js +39 -0
  269. package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
  270. package/dist/modes/interactive/components/extension-editor.js +105 -0
  271. package/dist/modes/interactive/components/extension-input.d.ts +22 -0
  272. package/dist/modes/interactive/components/extension-input.js +54 -0
  273. package/dist/modes/interactive/components/extension-selector.d.ts +23 -0
  274. package/dist/modes/interactive/components/extension-selector.js +70 -0
  275. package/dist/modes/interactive/components/footer.d.ts +55 -0
  276. package/dist/modes/interactive/components/footer.js +207 -0
  277. package/dist/modes/interactive/components/index.d.ts +31 -0
  278. package/dist/modes/interactive/components/index.js +32 -0
  279. package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
  280. package/dist/modes/interactive/components/keybinding-hints.js +21 -0
  281. package/dist/modes/interactive/components/login-dialog.d.ts +41 -0
  282. package/dist/modes/interactive/components/login-dialog.js +138 -0
  283. package/dist/modes/interactive/components/model-selector.d.ts +32 -0
  284. package/dist/modes/interactive/components/model-selector.js +209 -0
  285. package/dist/modes/interactive/components/oauth-selector.d.ts +18 -0
  286. package/dist/modes/interactive/components/oauth-selector.js +91 -0
  287. package/dist/modes/interactive/components/settings-selector.d.ts +57 -0
  288. package/dist/modes/interactive/components/settings-selector.js +299 -0
  289. package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
  290. package/dist/modes/interactive/components/show-images-selector.js +37 -0
  291. package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
  292. package/dist/modes/interactive/components/skill-invocation-message.js +44 -0
  293. package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
  294. package/dist/modes/interactive/components/theme-selector.js +47 -0
  295. package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
  296. package/dist/modes/interactive/components/thinking-selector.js +50 -0
  297. package/dist/modes/interactive/components/timeline-view.d.ts +31 -0
  298. package/dist/modes/interactive/components/timeline-view.js +81 -0
  299. package/dist/modes/interactive/components/tool-execution.d.ts +64 -0
  300. package/dist/modes/interactive/components/tool-execution.js +305 -0
  301. package/dist/modes/interactive/components/tree-selector.d.ts +88 -0
  302. package/dist/modes/interactive/components/tree-selector.js +1072 -0
  303. package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
  304. package/dist/modes/interactive/components/user-message-selector.js +110 -0
  305. package/dist/modes/interactive/components/user-message.d.ts +9 -0
  306. package/dist/modes/interactive/components/user-message.js +27 -0
  307. package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
  308. package/dist/modes/interactive/components/visual-truncate.js +32 -0
  309. package/dist/modes/interactive/interactive-mode.d.ts +394 -0
  310. package/dist/modes/interactive/interactive-mode.js +4116 -0
  311. package/dist/modes/interactive/theme/dark.json +85 -0
  312. package/dist/modes/interactive/theme/light.json +84 -0
  313. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  314. package/dist/modes/interactive/theme/theme.d.ts +80 -0
  315. package/dist/modes/interactive/theme/theme.js +973 -0
  316. package/dist/modes/print-mode.d.ts +27 -0
  317. package/dist/modes/print-mode.js +102 -0
  318. package/dist/modes/rpc/jsonl.d.ts +16 -0
  319. package/dist/modes/rpc/jsonl.js +48 -0
  320. package/dist/modes/rpc/rpc-client.d.ts +219 -0
  321. package/dist/modes/rpc/rpc-client.js +405 -0
  322. package/dist/modes/rpc/rpc-mode.d.ts +19 -0
  323. package/dist/modes/rpc/rpc-mode.js +381 -0
  324. package/dist/modes/rpc/rpc-types.d.ts +406 -0
  325. package/dist/modes/rpc/rpc-types.js +7 -0
  326. package/dist/package-manager-cli.d.ts +3 -0
  327. package/dist/package-manager-cli.js +233 -0
  328. package/dist/utils/changelog.d.ts +20 -0
  329. package/dist/utils/changelog.js +86 -0
  330. package/dist/utils/child-process.d.ts +10 -0
  331. package/dist/utils/child-process.js +77 -0
  332. package/dist/utils/clipboard-image.d.ts +10 -0
  333. package/dist/utils/clipboard-image.js +244 -0
  334. package/dist/utils/clipboard-native.d.ts +7 -0
  335. package/dist/utils/clipboard-native.js +13 -0
  336. package/dist/utils/clipboard.d.ts +1 -0
  337. package/dist/utils/clipboard.js +77 -0
  338. package/dist/utils/exif-orientation.d.ts +4 -0
  339. package/dist/utils/exif-orientation.js +157 -0
  340. package/dist/utils/frontmatter.d.ts +7 -0
  341. package/dist/utils/frontmatter.js +25 -0
  342. package/dist/utils/git.d.ts +25 -0
  343. package/dist/utils/git.js +162 -0
  344. package/dist/utils/image-convert.d.ts +8 -0
  345. package/dist/utils/image-convert.js +38 -0
  346. package/dist/utils/image-resize.d.ts +35 -0
  347. package/dist/utils/image-resize.js +136 -0
  348. package/dist/utils/mime.d.ts +1 -0
  349. package/dist/utils/mime.js +25 -0
  350. package/dist/utils/path-shims.d.ts +1 -0
  351. package/dist/utils/path-shims.js +90 -0
  352. package/dist/utils/paths.d.ts +6 -0
  353. package/dist/utils/paths.js +18 -0
  354. package/dist/utils/photon.d.ts +20 -0
  355. package/dist/utils/photon.js +120 -0
  356. package/dist/utils/shell.d.ts +29 -0
  357. package/dist/utils/shell.js +189 -0
  358. package/dist/utils/sleep.d.ts +4 -0
  359. package/dist/utils/sleep.js +16 -0
  360. package/dist/utils/tools-manager.d.ts +3 -0
  361. package/dist/utils/tools-manager.js +101 -0
  362. package/dist/vendor/bin/darwin-arm64/fd +0 -0
  363. package/dist/vendor/bin/darwin-arm64/rg +0 -0
  364. package/dist/vendor/bin/darwin-x64/fd +0 -0
  365. package/dist/vendor/bin/darwin-x64/rg +0 -0
  366. package/dist/vendor/bin/linux-arm64/fd +0 -0
  367. package/dist/vendor/bin/linux-arm64/rg +0 -0
  368. package/dist/vendor/bin/linux-x64/fd +0 -0
  369. package/dist/vendor/bin/linux-x64/rg +0 -0
  370. package/dist/vendor/bin/win32-arm64/fd.exe +0 -0
  371. package/dist/vendor/bin/win32-arm64/rg.exe +0 -0
  372. package/dist/vendor/bin/win32-x64/fd.exe +0 -0
  373. package/dist/vendor/bin/win32-x64/rg.exe +0 -0
  374. package/package.json +90 -26
  375. package/dist/extension/core.d.ts +0 -69
  376. package/dist/extension/core.js +0 -270
  377. package/dist/extension/core.js.map +0 -1
  378. package/dist/extension/index.d.ts +0 -25
  379. package/dist/extension/index.js +0 -303
  380. package/dist/extension/index.js.map +0 -1
  381. package/dist/main.js.map +0 -1
  382. package/themes/pizza.json +0 -87
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Session Boundary Inferrer
3
+ *
4
+ * Automatically infers session boundaries based on signals like:
5
+ * - Time gaps
6
+ * - User message semantic shifts
7
+ * - File set drift
8
+ * - Tool usage pattern changes
9
+ */
10
+ import type { EventBase } from "../event-store/types.js";
11
+ /** Boundary inference decision */
12
+ export interface BoundaryDecision {
13
+ should_split: boolean;
14
+ reason?: "intent_shift" | "file_drift" | "time_gap" | "tool_pattern_change";
15
+ suggested_name?: string;
16
+ confidence?: number;
17
+ }
18
+ export interface BoundaryConfig {
19
+ /** Time gap threshold in milliseconds */
20
+ time_gap_ms: number;
21
+ /** File drift threshold (0-1, fraction of new files) */
22
+ file_drift_threshold: number;
23
+ /** Minimum events for a session */
24
+ min_events_for_session: number;
25
+ /** Enable file drift detection */
26
+ enable_file_drift: boolean;
27
+ /** Enable intent shift detection */
28
+ enable_intent_shift: boolean;
29
+ /** Enable tool pattern change detection */
30
+ enable_tool_pattern_change: boolean;
31
+ }
32
+ /**
33
+ * Automatically infers session boundaries.
34
+ *
35
+ * Phase 1: Time gap only
36
+ * Phase 2: + File drift, tool pattern change
37
+ * Phase 3: + Intent shift (semantic comparison)
38
+ */
39
+ export declare class SessionBoundaryInferrer {
40
+ private config;
41
+ constructor(config?: BoundaryConfig);
42
+ /**
43
+ * Evaluate whether to create a new session boundary.
44
+ *
45
+ * @param recentEvents Recent events in the current session (most recent last)
46
+ * @param newEvent The new event being added
47
+ * @returns Decision whether to split
48
+ */
49
+ evaluate(recentEvents: EventBase[], newEvent: EventBase): BoundaryDecision;
50
+ /**
51
+ * Update configuration.
52
+ */
53
+ updateConfig(updates: Partial<BoundaryConfig>): void;
54
+ private _hasTimeGap;
55
+ private _hasFileDrift;
56
+ private _hasIntentShift;
57
+ private _hasToolPatternChange;
58
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Session Boundary Inferrer
3
+ *
4
+ * Automatically infers session boundaries based on signals like:
5
+ * - Time gaps
6
+ * - User message semantic shifts
7
+ * - File set drift
8
+ * - Tool usage pattern changes
9
+ */
10
+ const DEFAULT_BOUNDARY_CONFIG = {
11
+ time_gap_ms: 2 * 60 * 60 * 1000, // 2 hours
12
+ file_drift_threshold: 0.8,
13
+ min_events_for_session: 3,
14
+ enable_file_drift: false, // Phase 2
15
+ enable_intent_shift: false, // Phase 3
16
+ enable_tool_pattern_change: false, // Phase 2
17
+ };
18
+ // ============================================================================
19
+ // Session Boundary Inferrer
20
+ // ============================================================================
21
+ /**
22
+ * Automatically infers session boundaries.
23
+ *
24
+ * Phase 1: Time gap only
25
+ * Phase 2: + File drift, tool pattern change
26
+ * Phase 3: + Intent shift (semantic comparison)
27
+ */
28
+ export class SessionBoundaryInferrer {
29
+ constructor(config = DEFAULT_BOUNDARY_CONFIG) {
30
+ this.config = config;
31
+ }
32
+ /**
33
+ * Evaluate whether to create a new session boundary.
34
+ *
35
+ * @param recentEvents Recent events in the current session (most recent last)
36
+ * @param newEvent The new event being added
37
+ * @returns Decision whether to split
38
+ */
39
+ evaluate(recentEvents, newEvent) {
40
+ // Don't split if we don't have enough events yet
41
+ if (recentEvents.length < this.config.min_events_for_session) {
42
+ return { should_split: false };
43
+ }
44
+ // 1. Time gap check
45
+ if (this._hasTimeGap(recentEvents, newEvent)) {
46
+ return {
47
+ should_split: true,
48
+ reason: "time_gap",
49
+ confidence: 1.0,
50
+ };
51
+ }
52
+ // 2. File drift check (Phase 2)
53
+ if (this.config.enable_file_drift && this._hasFileDrift(recentEvents, newEvent)) {
54
+ return {
55
+ should_split: true,
56
+ reason: "file_drift",
57
+ confidence: 0.7,
58
+ };
59
+ }
60
+ // 3. Intent shift check (Phase 3)
61
+ if (this.config.enable_intent_shift && this._hasIntentShift(recentEvents, newEvent)) {
62
+ return {
63
+ should_split: true,
64
+ reason: "intent_shift",
65
+ confidence: 0.6,
66
+ };
67
+ }
68
+ // 4. Tool pattern change (Phase 2)
69
+ if (this.config.enable_tool_pattern_change && this._hasToolPatternChange(recentEvents, newEvent)) {
70
+ return {
71
+ should_split: true,
72
+ reason: "tool_pattern_change",
73
+ confidence: 0.5,
74
+ };
75
+ }
76
+ return { should_split: false };
77
+ }
78
+ /**
79
+ * Update configuration.
80
+ */
81
+ updateConfig(updates) {
82
+ Object.assign(this.config, updates);
83
+ }
84
+ // =========================================================================
85
+ // Private Detection Methods
86
+ // =========================================================================
87
+ _hasTimeGap(recent, next) {
88
+ if (recent.length === 0)
89
+ return false;
90
+ const last = recent[recent.length - 1];
91
+ return next.timestamp - last.timestamp > this.config.time_gap_ms;
92
+ }
93
+ _hasFileDrift(recent, _next) {
94
+ // Phase 2: Compare file sets in recent tool executions vs new event
95
+ const recentFiles = new Set();
96
+ for (const event of recent) {
97
+ if (event.type === "TOOL_EXECUTION_END") {
98
+ const payload = event.payload;
99
+ if (payload.file_mutations) {
100
+ for (const mutation of payload.file_mutations) {
101
+ recentFiles.add(mutation.path);
102
+ }
103
+ }
104
+ }
105
+ }
106
+ // If no files recently, no drift
107
+ if (recentFiles.size === 0)
108
+ return false;
109
+ // Phase 2: implement actual drift detection
110
+ // For now, return false to avoid false positives
111
+ return false;
112
+ }
113
+ _hasIntentShift(_recent, _next) {
114
+ // Phase 3: Semantic comparison of user messages
115
+ // Requires LLM-based topic comparison
116
+ return false;
117
+ }
118
+ _hasToolPatternChange(_recent, _next) {
119
+ // Phase 2: Compare tool usage patterns
120
+ return false;
121
+ }
122
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Event to Message Converter
3
+ *
4
+ * Converts EventStore events to AgentMessage format for LLM consumption.
5
+ */
6
+ import type { AgentMessage } from "../agent/types.js";
7
+ import type { EventBase } from "../event-store/types.js";
8
+ /**
9
+ * Convert events to messages for LLM context.
10
+ *
11
+ * Handles:
12
+ * - USER_MESSAGE → user message
13
+ * - AGENT_MESSAGE_END → assistant message
14
+ * - TOOL_EXECUTION_END → tool result message
15
+ * - COMPACTION_END → system summary message
16
+ * - FILE_MUTATION_APPLIED → custom notification message
17
+ */
18
+ export declare function eventsToMessages(events: EventBase[]): AgentMessage[];
19
+ /**
20
+ * Convert a single event to an AgentMessage.
21
+ * Returns null if the event doesn't produce a message.
22
+ */
23
+ export declare function eventToMessage(event: EventBase): AgentMessage | null;
24
+ /**
25
+ * Extract tool calls from content blocks.
26
+ */
27
+ export declare function extractToolCalls(content: unknown[]): Array<{
28
+ id: string;
29
+ name: string;
30
+ arguments: Record<string, unknown>;
31
+ }>;
32
+ /**
33
+ * Extract text content from a message.
34
+ */
35
+ export declare function extractTextContent(content: string | unknown[]): string;
@@ -0,0 +1,253 @@
1
+ /**
2
+ * Event to Message Converter
3
+ *
4
+ * Converts EventStore events to AgentMessage format for LLM consumption.
5
+ */
6
+ // ============================================================================
7
+ // Event to Message Conversion
8
+ // ============================================================================
9
+ /**
10
+ * Convert events to messages for LLM context.
11
+ *
12
+ * Handles:
13
+ * - USER_MESSAGE → user message
14
+ * - AGENT_MESSAGE_END → assistant message
15
+ * - TOOL_EXECUTION_END → tool result message
16
+ * - COMPACTION_END → system summary message
17
+ * - FILE_MUTATION_APPLIED → custom notification message
18
+ */
19
+ export function eventsToMessages(events) {
20
+ const messages = [];
21
+ for (const event of events) {
22
+ const msg = eventToMessage(event);
23
+ if (msg) {
24
+ messages.push(msg);
25
+ }
26
+ }
27
+ return messages;
28
+ }
29
+ /**
30
+ * Convert a single event to an AgentMessage.
31
+ * Returns null if the event doesn't produce a message.
32
+ */
33
+ export function eventToMessage(event) {
34
+ switch (event.type) {
35
+ case "USER_MESSAGE": {
36
+ const payload = event.payload;
37
+ // Merge images into content array if present
38
+ let content = payload.content;
39
+ if (payload.images && payload.images.length > 0) {
40
+ if (typeof content === "string") {
41
+ content = [{ type: "text", text: content }, ...payload.images];
42
+ }
43
+ else {
44
+ content = [...content, ...payload.images];
45
+ }
46
+ }
47
+ return {
48
+ role: "user",
49
+ content,
50
+ timestamp: event.timestamp,
51
+ };
52
+ }
53
+ case "AGENT_MESSAGE_END": {
54
+ const payload = event.payload;
55
+ // Convert content - AGENT_MESSAGE_END from our event store
56
+ // contains text/image blocks from the LLM response
57
+ const rawContent = payload.content;
58
+ const content = rawContent
59
+ .filter((block) => {
60
+ const b = block;
61
+ return b.type === "text" || b.type === "thinking" || b.type === "tool_call" || b.type === "toolCall";
62
+ })
63
+ .map((block) => {
64
+ const blockType = block.type;
65
+ if (blockType !== "tool_call" && blockType !== "toolCall") {
66
+ return block;
67
+ }
68
+ const toolCall = block;
69
+ return {
70
+ type: "toolCall",
71
+ id: String(toolCall.id ?? toolCall.tool_call_id ?? ""),
72
+ name: String(toolCall.name ?? toolCall.tool_name ?? ""),
73
+ arguments: toolCall.arguments ?? {},
74
+ };
75
+ });
76
+ // Convert stop_reason to StopReason
77
+ const stopReason = (payload.stop_reason === "tool_use" ? "toolUse" : payload.stop_reason);
78
+ // Convert TokenUsage to Usage
79
+ const usage = {
80
+ input: payload.usage.input,
81
+ output: payload.usage.output,
82
+ cacheRead: payload.usage.cache_read,
83
+ cacheWrite: payload.usage.cache_write,
84
+ totalTokens: payload.usage.total,
85
+ cost: {
86
+ input: payload.usage.cost * 0.5,
87
+ output: payload.usage.cost * 0.5,
88
+ cacheRead: 0,
89
+ cacheWrite: 0,
90
+ total: payload.usage.cost,
91
+ },
92
+ };
93
+ return {
94
+ role: "assistant",
95
+ content,
96
+ api: payload.model.provider,
97
+ provider: payload.model.provider,
98
+ model: payload.model.model_id,
99
+ usage,
100
+ stopReason,
101
+ errorMessage: payload.error_message,
102
+ timestamp: event.timestamp,
103
+ };
104
+ }
105
+ case "TOOL_EXECUTION_END": {
106
+ const payload = event.payload;
107
+ const content = formatToolResult(payload.result, payload.is_error);
108
+ return {
109
+ role: "toolResult",
110
+ toolCallId: payload.tool_call_id,
111
+ toolName: payload.tool_name,
112
+ content,
113
+ isError: payload.is_error,
114
+ details: payload.details,
115
+ timestamp: event.timestamp,
116
+ };
117
+ }
118
+ case "COMPACTION_END": {
119
+ const payload = event.payload;
120
+ return {
121
+ role: "compactionSummary",
122
+ summary: payload.summary,
123
+ tokensBefore: payload.tokens_before,
124
+ timestamp: event.timestamp,
125
+ };
126
+ }
127
+ case "FILE_MUTATION_APPLIED": {
128
+ const mutation = normalizeFileMutationPayload(event.payload);
129
+ const operation = mutation.operation ?? "modify";
130
+ const path = mutation.path ?? "file";
131
+ return {
132
+ role: "custom",
133
+ customType: "runtime:file_mutation",
134
+ content: `File ${operation}: ${path}`,
135
+ display: true,
136
+ details: mutation,
137
+ timestamp: event.timestamp,
138
+ };
139
+ }
140
+ case "BASH_EXECUTION": {
141
+ const payload = event.payload;
142
+ return {
143
+ role: "bashExecution",
144
+ command: payload.command,
145
+ output: payload.output ?? "",
146
+ stdout: payload.stdout,
147
+ stderr: payload.stderr,
148
+ exitCode: payload.exit_code,
149
+ durationMs: payload.duration_ms,
150
+ cwd: payload.cwd,
151
+ cancelled: payload.cancelled ?? false,
152
+ truncated: payload.truncated ?? false,
153
+ fullOutputPath: payload.full_output_path,
154
+ excludeFromContext: payload.exclude_from_context,
155
+ timestamp: event.timestamp,
156
+ };
157
+ }
158
+ case "CUSTOM_MESSAGE": {
159
+ const payload = event.payload;
160
+ // Transform event data into CustomMessage shape
161
+ let content = "";
162
+ let details = payload.data;
163
+ if (typeof payload.data === "string") {
164
+ content = payload.data;
165
+ details = undefined;
166
+ }
167
+ else if (Array.isArray(payload.data)) {
168
+ content = payload.data;
169
+ }
170
+ return {
171
+ role: "custom",
172
+ customType: `${payload.extension_id}:${payload.kind}`,
173
+ content,
174
+ display: payload.display,
175
+ details,
176
+ timestamp: event.timestamp,
177
+ };
178
+ }
179
+ case "BRANCH_SUMMARY": {
180
+ const payload = event.payload;
181
+ return {
182
+ role: "branchSummary",
183
+ summary: payload.summary,
184
+ fromId: payload.from_id,
185
+ timestamp: event.timestamp,
186
+ };
187
+ }
188
+ // Skip other event types - they don't produce messages
189
+ default:
190
+ return null;
191
+ }
192
+ }
193
+ function normalizeFileMutationPayload(payload) {
194
+ const nested = payload.mutation;
195
+ return {
196
+ path: payload.path ?? nested?.path,
197
+ operation: payload.operation ?? nested?.operation,
198
+ diff: payload.diff ?? nested?.diff,
199
+ toolCallId: payload.tool_call_id,
200
+ toolName: payload.tool_name,
201
+ };
202
+ }
203
+ /**
204
+ * Format tool result content for message.
205
+ */
206
+ function formatToolResult(result, is_error) {
207
+ return result
208
+ .filter((block) => {
209
+ const b = block;
210
+ return b.type === "text" || b.type === "image";
211
+ })
212
+ .map((block) => {
213
+ if (block.type === "text") {
214
+ return {
215
+ type: "text",
216
+ text: is_error ? `Error: ${block.text}` : block.text,
217
+ };
218
+ }
219
+ return block;
220
+ });
221
+ }
222
+ /**
223
+ * Extract tool calls from content blocks.
224
+ */
225
+ export function extractToolCalls(content) {
226
+ const calls = [];
227
+ for (const block of content) {
228
+ const b = block;
229
+ if (b.type === "tool_call" || b.type === "toolCall") {
230
+ calls.push({
231
+ id: String(b.id ?? b.tool_call_id ?? ""),
232
+ name: String(b.name ?? b.tool_name ?? ""),
233
+ arguments: b.arguments ?? {},
234
+ });
235
+ }
236
+ }
237
+ return calls;
238
+ }
239
+ /**
240
+ * Extract text content from a message.
241
+ */
242
+ export function extractTextContent(content) {
243
+ if (typeof content === "string") {
244
+ return content;
245
+ }
246
+ return content
247
+ .filter((block) => {
248
+ const b = block;
249
+ return b.type === "text" && typeof b.text === "string";
250
+ })
251
+ .map((block) => block.text)
252
+ .join(" ");
253
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Goal Projection
3
+ *
4
+ * Derives goal and task state by scanning events from the EventStore.
5
+ * A projection is a read-only view — it can be rebuilt at any time
6
+ * by replaying the event log.
7
+ */
8
+ import type { EventStore } from "../event-store/store.js";
9
+ import type { GoalDescriptor, TaskDescriptor } from "../goal/types.js";
10
+ /**
11
+ * GoalProjection derives current goal and task state from the EventStore.
12
+ *
13
+ * Usage:
14
+ * const projection = new GoalProjection(store);
15
+ * projection.rebuild(); // scan all events
16
+ * const goals = projection.listGoals();
17
+ * const tasks = projection.getTasksForGoal(goalId);
18
+ */
19
+ export declare class GoalProjection {
20
+ private store;
21
+ private goals;
22
+ private tasks;
23
+ private unsubscribe?;
24
+ constructor(store: EventStore);
25
+ /**
26
+ * Rebuild the projection from scratch by scanning all events.
27
+ */
28
+ rebuild(): void;
29
+ /**
30
+ * Start live-updating the projection by subscribing to new events.
31
+ */
32
+ startLive(): void;
33
+ /**
34
+ * Stop live updates.
35
+ */
36
+ stopLive(): void;
37
+ /** Get all goals */
38
+ listGoals(): GoalDescriptor[];
39
+ /** Get active (non-terminal) goals */
40
+ listActiveGoals(): GoalDescriptor[];
41
+ /** Get a specific goal */
42
+ getGoal(goalId: string): GoalDescriptor | undefined;
43
+ /** Get all tasks for a goal */
44
+ getTasksForGoal(goalId: string): TaskDescriptor[];
45
+ /** Get all tasks */
46
+ listTasks(): TaskDescriptor[];
47
+ /** Get a specific task */
48
+ getTask(taskId: string): TaskDescriptor | undefined;
49
+ /** Get tasks that are ready to start (all dependencies completed/accepted) */
50
+ getReadyTasks(goalId: string): TaskDescriptor[];
51
+ /** Get tasks blocked by dependencies */
52
+ getBlockedTasks(goalId: string): TaskDescriptor[];
53
+ private _applyEvent;
54
+ private _onGoalCreated;
55
+ private _onGoalClassified;
56
+ private _onGoalPlanned;
57
+ private _onGoalStatusChange;
58
+ private _onTaskCreated;
59
+ private _onTaskAssigned;
60
+ private _onTaskStarted;
61
+ private _onTaskProgress;
62
+ private _onTaskFailed;
63
+ private _onTaskRework;
64
+ private _onTaskCompleted;
65
+ private _onTaskCancelled;
66
+ private _onTaskStatusChange;
67
+ }