@oh-my-pi/pi-coding-agent 15.12.3 → 15.13.0

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 (457) hide show
  1. package/CHANGELOG.md +347 -7
  2. package/dist/cli.js +1615 -1231
  3. package/dist/types/async/job-manager.d.ts +15 -0
  4. package/dist/types/autolearn/controller.d.ts +25 -0
  5. package/dist/types/autolearn/managed-skills.d.ts +45 -0
  6. package/dist/types/autoresearch/state.d.ts +1 -1
  7. package/dist/types/autoresearch/tools/init-experiment.d.ts +1 -1
  8. package/dist/types/autoresearch/tools/log-experiment.d.ts +1 -1
  9. package/dist/types/autoresearch/tools/run-experiment.d.ts +1 -1
  10. package/dist/types/autoresearch/tools/update-notes.d.ts +1 -1
  11. package/dist/types/autoresearch/types.d.ts +1 -1
  12. package/dist/types/cli/args.d.ts +19 -2
  13. package/dist/types/cli/models-cli.d.ts +49 -0
  14. package/dist/types/cli/session-picker.d.ts +1 -1
  15. package/dist/types/cli/setup-cli.d.ts +1 -1
  16. package/dist/types/cli/setup-model-picker.d.ts +14 -0
  17. package/dist/types/collab/protocol.d.ts +1 -1
  18. package/dist/types/commands/launch.d.ts +0 -3
  19. package/dist/types/commands/models.d.ts +33 -0
  20. package/dist/types/commands/say.d.ts +24 -0
  21. package/dist/types/commands/token.d.ts +25 -0
  22. package/dist/types/commit/agentic/tools/analyze-file.d.ts +1 -1
  23. package/dist/types/commit/agentic/tools/git-file-diff.d.ts +1 -1
  24. package/dist/types/commit/agentic/tools/git-hunk.d.ts +1 -1
  25. package/dist/types/commit/agentic/tools/git-overview.d.ts +1 -1
  26. package/dist/types/commit/agentic/tools/propose-changelog.d.ts +1 -1
  27. package/dist/types/commit/agentic/tools/propose-commit.d.ts +1 -1
  28. package/dist/types/commit/agentic/tools/recent-commits.d.ts +1 -1
  29. package/dist/types/commit/agentic/tools/schemas.d.ts +1 -1
  30. package/dist/types/commit/agentic/tools/split-commit.d.ts +1 -1
  31. package/dist/types/commit/changelog/generate.d.ts +1 -1
  32. package/dist/types/commit/shared-llm.d.ts +1 -1
  33. package/dist/types/config/keybindings.d.ts +3 -3
  34. package/dist/types/config/model-registry.d.ts +17 -0
  35. package/dist/types/config/models-config-schema.d.ts +13 -1
  36. package/dist/types/config/models-config.d.ts +8 -2
  37. package/dist/types/config/settings-schema.d.ts +281 -58
  38. package/dist/types/edit/hashline/params.d.ts +1 -1
  39. package/dist/types/edit/modes/apply-patch.d.ts +1 -1
  40. package/dist/types/edit/modes/patch.d.ts +1 -1
  41. package/dist/types/edit/modes/replace.d.ts +1 -1
  42. package/dist/types/export/html/index.d.ts +2 -1
  43. package/dist/types/extensibility/custom-commands/types.d.ts +2 -2
  44. package/dist/types/extensibility/custom-tools/types.d.ts +2 -2
  45. package/dist/types/extensibility/extensions/model-api.d.ts +17 -0
  46. package/dist/types/extensibility/extensions/runner.d.ts +3 -1
  47. package/dist/types/extensibility/extensions/types.d.ts +49 -3
  48. package/dist/types/extensibility/hooks/index.d.ts +2 -1
  49. package/dist/types/extensibility/hooks/types.d.ts +2 -2
  50. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +9 -0
  51. package/dist/types/extensibility/plugins/loader.d.ts +11 -0
  52. package/dist/types/extensibility/shared-events.d.ts +1 -1
  53. package/dist/types/extensibility/skills.d.ts +10 -0
  54. package/dist/types/goals/guided-setup.d.ts +18 -0
  55. package/dist/types/goals/state.d.ts +1 -1
  56. package/dist/types/goals/tools/goal-tool.d.ts +1 -1
  57. package/dist/types/hindsight/transcript.d.ts +1 -1
  58. package/dist/types/index.d.ts +5 -0
  59. package/dist/types/internal-urls/local-protocol.d.ts +4 -2
  60. package/dist/types/lsp/types.d.ts +1 -1
  61. package/dist/types/main.d.ts +4 -3
  62. package/dist/types/mcp/manager.d.ts +8 -0
  63. package/dist/types/mcp/startup-events.d.ts +11 -0
  64. package/dist/types/memories/index.d.ts +7 -0
  65. package/dist/types/memory-backend/local-backend.d.ts +4 -3
  66. package/dist/types/mnemopi/config.d.ts +28 -0
  67. package/dist/types/modes/acp/acp-agent.d.ts +1 -2
  68. package/dist/types/modes/components/agent-hub.d.ts +6 -0
  69. package/dist/types/modes/components/assistant-message.d.ts +1 -2
  70. package/dist/types/modes/components/compaction-summary-message.d.ts +15 -1
  71. package/dist/types/modes/components/custom-editor.d.ts +39 -1
  72. package/dist/types/modes/components/custom-editor.test.d.ts +1 -0
  73. package/dist/types/modes/components/index.d.ts +1 -0
  74. package/dist/types/modes/components/logout-account-selector.d.ts +8 -0
  75. package/dist/types/modes/components/session-selector.d.ts +1 -1
  76. package/dist/types/modes/components/status-line/component.d.ts +9 -5
  77. package/dist/types/modes/components/status-line/types.d.ts +2 -1
  78. package/dist/types/modes/components/tool-execution.d.ts +26 -16
  79. package/dist/types/modes/components/transcript-container.d.ts +23 -2
  80. package/dist/types/modes/components/tree-selector.d.ts +1 -1
  81. package/dist/types/modes/components/usage-row.d.ts +3 -0
  82. package/dist/types/modes/controllers/command-controller.d.ts +2 -2
  83. package/dist/types/modes/controllers/event-controller.d.ts +0 -17
  84. package/dist/types/modes/controllers/input-controller.d.ts +14 -0
  85. package/dist/types/modes/controllers/selector-controller.d.ts +3 -1
  86. package/dist/types/modes/gradient-highlight.d.ts +9 -4
  87. package/dist/types/modes/image-references.d.ts +6 -0
  88. package/dist/types/modes/interactive-mode.d.ts +27 -6
  89. package/dist/types/modes/magic-keywords.d.ts +13 -1
  90. package/dist/types/modes/rpc/rpc-mode.d.ts +35 -1
  91. package/dist/types/modes/rpc/rpc-types.d.ts +9 -1
  92. package/dist/types/modes/runtime-init.d.ts +4 -0
  93. package/dist/types/modes/theme/theme.d.ts +13 -2
  94. package/dist/types/modes/types.d.ts +8 -7
  95. package/dist/types/modes/utils/ui-helpers.d.ts +1 -1
  96. package/dist/types/registry/agent-registry.d.ts +17 -0
  97. package/dist/types/secrets/obfuscator.d.ts +1 -1
  98. package/dist/types/session/agent-session.d.ts +28 -35
  99. package/dist/types/session/agent-storage.d.ts +2 -1
  100. package/dist/types/session/indexed-session-storage.d.ts +3 -3
  101. package/dist/types/session/messages.d.ts +8 -10
  102. package/dist/types/session/session-context.d.ts +39 -0
  103. package/dist/types/session/session-entries.d.ts +159 -0
  104. package/dist/types/session/session-listing.d.ts +69 -0
  105. package/dist/types/session/session-loader.d.ts +16 -0
  106. package/dist/types/session/session-manager.d.ts +85 -462
  107. package/dist/types/session/session-migrations.d.ts +12 -0
  108. package/dist/types/session/session-paths.d.ts +25 -0
  109. package/dist/types/session/session-persistence.d.ts +8 -0
  110. package/dist/types/session/session-storage.d.ts +11 -7
  111. package/dist/types/session/snapcompact-inline.d.ts +12 -1
  112. package/dist/types/session/snapcompact-savings-journal.d.ts +46 -0
  113. package/dist/types/session/tool-choice-queue.d.ts +6 -6
  114. package/dist/types/slash-commands/helpers/logout.d.ts +15 -0
  115. package/dist/types/stt/asr-client.d.ts +90 -0
  116. package/dist/types/stt/asr-protocol.d.ts +97 -0
  117. package/dist/types/stt/asr-worker.d.ts +2 -0
  118. package/dist/types/stt/downloader.d.ts +38 -0
  119. package/dist/types/stt/endpointer.d.ts +59 -0
  120. package/dist/types/stt/index.d.ts +5 -1
  121. package/dist/types/stt/models.d.ts +120 -0
  122. package/dist/types/stt/recorder.d.ts +17 -0
  123. package/dist/types/stt/stt-controller.d.ts +6 -0
  124. package/dist/types/stt/transcriber.d.ts +5 -7
  125. package/dist/types/stt/wav.d.ts +29 -0
  126. package/dist/types/system-prompt.d.ts +4 -0
  127. package/dist/types/task/executor.d.ts +2 -0
  128. package/dist/types/task/index.d.ts +9 -1
  129. package/dist/types/task/types.d.ts +37 -1
  130. package/dist/types/tools/ask.d.ts +1 -1
  131. package/dist/types/tools/ast-edit.d.ts +1 -1
  132. package/dist/types/tools/ast-grep.d.ts +1 -1
  133. package/dist/types/tools/bash.d.ts +3 -3
  134. package/dist/types/tools/browser/cmux/cmux-tab.d.ts +202 -0
  135. package/dist/types/tools/browser/cmux/rpc.d.ts +70 -0
  136. package/dist/types/tools/browser/cmux/socket-client.d.ts +19 -0
  137. package/dist/types/tools/browser/registry.d.ts +16 -3
  138. package/dist/types/tools/browser/render.d.ts +2 -0
  139. package/dist/types/tools/browser/tab-protocol.d.ts +2 -0
  140. package/dist/types/tools/browser/tab-supervisor.d.ts +16 -4
  141. package/dist/types/tools/browser.d.ts +3 -1
  142. package/dist/types/tools/checkpoint.d.ts +1 -1
  143. package/dist/types/tools/debug.d.ts +1 -1
  144. package/dist/types/tools/eval-render.d.ts +1 -1
  145. package/dist/types/tools/eval.d.ts +1 -1
  146. package/dist/types/tools/find.d.ts +1 -1
  147. package/dist/types/tools/gh.d.ts +1 -1
  148. package/dist/types/tools/image-gen.d.ts +1 -1
  149. package/dist/types/tools/index.d.ts +14 -2
  150. package/dist/types/tools/inspect-image.d.ts +1 -1
  151. package/dist/types/tools/irc.d.ts +2 -1
  152. package/dist/types/tools/job.d.ts +1 -1
  153. package/dist/types/tools/learn.d.ts +51 -0
  154. package/dist/types/tools/manage-skill.d.ts +40 -0
  155. package/dist/types/tools/memory-edit.d.ts +1 -1
  156. package/dist/types/tools/memory-recall.d.ts +1 -1
  157. package/dist/types/tools/memory-reflect.d.ts +1 -1
  158. package/dist/types/tools/memory-retain.d.ts +1 -1
  159. package/dist/types/tools/plan-mode-guard.d.ts +10 -0
  160. package/dist/types/tools/read.d.ts +1 -1
  161. package/dist/types/tools/render-mermaid.d.ts +1 -1
  162. package/dist/types/tools/renderers.d.ts +7 -11
  163. package/dist/types/tools/resolve.d.ts +1 -1
  164. package/dist/types/tools/review.d.ts +1 -1
  165. package/dist/types/tools/search-tool-bm25.d.ts +1 -1
  166. package/dist/types/tools/search.d.ts +1 -1
  167. package/dist/types/tools/ssh.d.ts +2 -2
  168. package/dist/types/tools/todo.d.ts +2 -2
  169. package/dist/types/tools/tts.d.ts +26 -1
  170. package/dist/types/tools/write.d.ts +2 -2
  171. package/dist/types/tts/downloader.d.ts +20 -0
  172. package/dist/types/tts/index.d.ts +8 -0
  173. package/dist/types/tts/models.d.ts +82 -0
  174. package/dist/types/tts/player.d.ts +32 -0
  175. package/dist/types/tts/runtime.d.ts +6 -0
  176. package/dist/types/tts/streaming-player.d.ts +41 -0
  177. package/dist/types/tts/tts-client.d.ts +93 -0
  178. package/dist/types/tts/tts-protocol.d.ts +95 -0
  179. package/dist/types/tts/tts-worker.d.ts +2 -0
  180. package/dist/types/tts/vocalizer.d.ts +41 -0
  181. package/dist/types/tts/wav.d.ts +8 -0
  182. package/dist/types/utils/clipboard.d.ts +4 -3
  183. package/dist/types/utils/image-loading.d.ts +18 -1
  184. package/dist/types/utils/thinking-display.d.ts +17 -0
  185. package/dist/types/utils/tool-choice.d.ts +8 -0
  186. package/dist/types/utils/tools-manager.d.ts +2 -1
  187. package/dist/types/utils/tools-manager.test.d.ts +1 -0
  188. package/dist/types/web/scrapers/github.d.ts +1 -1
  189. package/dist/types/web/search/index.d.ts +1 -1
  190. package/package.json +17 -16
  191. package/src/async/job-manager.ts +49 -0
  192. package/src/autolearn/controller.ts +139 -0
  193. package/src/autolearn/managed-skills.ts +257 -0
  194. package/src/autoresearch/state.ts +1 -1
  195. package/src/autoresearch/storage.ts +2 -1
  196. package/src/autoresearch/tools/init-experiment.ts +1 -1
  197. package/src/autoresearch/tools/log-experiment.ts +1 -1
  198. package/src/autoresearch/tools/run-experiment.ts +1 -1
  199. package/src/autoresearch/tools/update-notes.ts +1 -1
  200. package/src/autoresearch/types.ts +1 -1
  201. package/src/cli/args.ts +56 -10
  202. package/src/cli/auth-gateway-cli.ts +1 -1
  203. package/src/cli/bench-cli.ts +1 -1
  204. package/src/cli/dry-balance-cli.ts +1 -1
  205. package/src/cli/models-cli.ts +427 -0
  206. package/src/cli/session-picker.ts +2 -1
  207. package/src/cli/setup-cli.ts +148 -47
  208. package/src/cli/setup-model-picker.ts +43 -0
  209. package/src/cli-commands.ts +3 -0
  210. package/src/cli.ts +45 -13
  211. package/src/collab/host.ts +10 -13
  212. package/src/collab/protocol.ts +1 -1
  213. package/src/commands/launch.ts +0 -3
  214. package/src/commands/models.ts +61 -0
  215. package/src/commands/say.ts +102 -0
  216. package/src/commands/setup.ts +1 -1
  217. package/src/commands/token.ts +89 -0
  218. package/src/commit/agentic/tools/analyze-file.ts +4 -1
  219. package/src/commit/agentic/tools/git-file-diff.ts +1 -1
  220. package/src/commit/agentic/tools/git-hunk.ts +1 -1
  221. package/src/commit/agentic/tools/git-overview.ts +1 -1
  222. package/src/commit/agentic/tools/propose-changelog.ts +1 -1
  223. package/src/commit/agentic/tools/propose-commit.ts +1 -1
  224. package/src/commit/agentic/tools/recent-commits.ts +1 -1
  225. package/src/commit/agentic/tools/schemas.ts +1 -1
  226. package/src/commit/agentic/tools/split-commit.ts +1 -1
  227. package/src/commit/analysis/summary.ts +1 -1
  228. package/src/commit/changelog/generate.ts +1 -1
  229. package/src/commit/shared-llm.ts +1 -1
  230. package/src/config/keybindings.ts +2 -2
  231. package/src/config/model-discovery.ts +11 -5
  232. package/src/config/model-registry.ts +79 -21
  233. package/src/config/model-resolver.ts +2 -2
  234. package/src/config/models-config-schema.ts +5 -2
  235. package/src/config/models-config.ts +2 -1
  236. package/src/config/settings-schema.ts +266 -32
  237. package/src/config/settings.ts +10 -0
  238. package/src/discovery/builtin.ts +23 -1
  239. package/src/discovery/claude-plugins.ts +44 -5
  240. package/src/discovery/helpers.ts +41 -1
  241. package/src/edit/hashline/params.ts +1 -1
  242. package/src/edit/modes/apply-patch.ts +1 -1
  243. package/src/edit/modes/patch.ts +1 -1
  244. package/src/edit/modes/replace.ts +1 -1
  245. package/src/eval/__tests__/budget-bridge.test.ts +1 -1
  246. package/src/eval/agent-bridge.ts +1 -1
  247. package/src/eval/completion-bridge.ts +1 -1
  248. package/src/eval/js/shared/prelude.txt +69 -17
  249. package/src/export/html/index.ts +3 -6
  250. package/src/export/html/template.js +24 -2
  251. package/src/export/html/tool-views.generated.js +2 -2
  252. package/src/extensibility/custom-commands/loader.ts +1 -1
  253. package/src/extensibility/custom-commands/types.ts +2 -2
  254. package/src/extensibility/custom-tools/loader.ts +1 -1
  255. package/src/extensibility/custom-tools/types.ts +2 -2
  256. package/src/extensibility/extensions/loader.ts +2 -2
  257. package/src/extensibility/extensions/model-api.ts +41 -0
  258. package/src/extensibility/extensions/runner.ts +4 -0
  259. package/src/extensibility/extensions/types.ts +54 -3
  260. package/src/extensibility/extensions/wrapper.ts +41 -5
  261. package/src/extensibility/hooks/index.ts +2 -1
  262. package/src/extensibility/hooks/loader.ts +1 -1
  263. package/src/extensibility/hooks/types.ts +2 -2
  264. package/src/extensibility/plugins/legacy-pi-compat.ts +43 -13
  265. package/src/extensibility/plugins/loader.ts +30 -19
  266. package/src/extensibility/plugins/manager.ts +221 -90
  267. package/src/extensibility/shared-events.ts +1 -1
  268. package/src/extensibility/skills.ts +101 -5
  269. package/src/goals/guided-setup.ts +133 -0
  270. package/src/goals/state.ts +1 -1
  271. package/src/goals/tools/goal-tool.ts +1 -1
  272. package/src/hindsight/transcript.ts +1 -1
  273. package/src/index.ts +5 -0
  274. package/src/internal-urls/docs-index.generated.ts +13 -10
  275. package/src/internal-urls/history-protocol.ts +1 -1
  276. package/src/internal-urls/local-protocol.ts +29 -7
  277. package/src/lsp/types.ts +1 -1
  278. package/src/main.ts +27 -32
  279. package/src/mcp/config-writer.ts +7 -3
  280. package/src/mcp/manager.ts +11 -0
  281. package/src/mcp/startup-events.ts +21 -0
  282. package/src/mcp/transports/stdio.ts +2 -1
  283. package/src/memories/index.ts +149 -12
  284. package/src/memories/storage.ts +2 -1
  285. package/src/memory-backend/local-backend.ts +11 -5
  286. package/src/mnemopi/backend.ts +1 -0
  287. package/src/mnemopi/config.ts +112 -12
  288. package/src/modes/acp/acp-agent.ts +8 -53
  289. package/src/modes/acp/acp-event-mapper.ts +5 -1
  290. package/src/modes/components/agent-hub.ts +51 -5
  291. package/src/modes/components/assistant-message.ts +12 -44
  292. package/src/modes/components/compaction-summary-message.ts +125 -26
  293. package/src/modes/components/custom-editor.test.ts +96 -0
  294. package/src/modes/components/custom-editor.ts +164 -8
  295. package/src/modes/components/index.ts +1 -0
  296. package/src/modes/components/logout-account-selector.ts +130 -0
  297. package/src/modes/components/mcp-add-wizard.ts +1 -1
  298. package/src/modes/components/model-selector.ts +2 -2
  299. package/src/modes/components/session-selector.ts +1 -1
  300. package/src/modes/components/settings-defs.ts +7 -0
  301. package/src/modes/components/status-line/component.ts +54 -157
  302. package/src/modes/components/status-line/segments.ts +1 -1
  303. package/src/modes/components/status-line/types.ts +2 -1
  304. package/src/modes/components/tool-execution.ts +82 -43
  305. package/src/modes/components/transcript-container.ts +70 -1
  306. package/src/modes/components/tree-selector.ts +1 -1
  307. package/src/modes/components/usage-row.ts +18 -0
  308. package/src/modes/components/user-message.ts +4 -2
  309. package/src/modes/controllers/command-controller.ts +14 -16
  310. package/src/modes/controllers/event-controller.ts +101 -73
  311. package/src/modes/controllers/extension-ui-controller.ts +6 -0
  312. package/src/modes/controllers/input-controller.ts +311 -57
  313. package/src/modes/controllers/mcp-command-controller.ts +44 -3
  314. package/src/modes/controllers/selector-controller.ts +68 -12
  315. package/src/modes/controllers/streaming-reveal.ts +4 -3
  316. package/src/modes/gradient-highlight.ts +21 -9
  317. package/src/modes/image-references.ts +20 -0
  318. package/src/modes/interactive-mode.ts +288 -48
  319. package/src/modes/magic-keywords.ts +27 -5
  320. package/src/modes/rpc/rpc-mode.ts +146 -14
  321. package/src/modes/rpc/rpc-subagents.ts +2 -2
  322. package/src/modes/rpc/rpc-types.ts +8 -2
  323. package/src/modes/runtime-init.ts +28 -3
  324. package/src/modes/theme/theme.ts +99 -51
  325. package/src/modes/types.ts +6 -7
  326. package/src/modes/utils/hotkeys-markdown.ts +1 -1
  327. package/src/modes/utils/ui-helpers.ts +36 -7
  328. package/src/priority.json +5 -1
  329. package/src/prompts/agents/task.md +1 -0
  330. package/src/prompts/goals/guided-goal-interview.md +8 -0
  331. package/src/prompts/goals/guided-goal-system.md +12 -0
  332. package/src/prompts/memories/read-path.md +6 -0
  333. package/src/prompts/system/autolearn-guidance-learn.md +1 -0
  334. package/src/prompts/system/autolearn-guidance.md +7 -0
  335. package/src/prompts/system/autolearn-nudge.md +3 -0
  336. package/src/prompts/system/eager-task.md +7 -0
  337. package/src/prompts/system/eager-todo.md +11 -6
  338. package/src/prompts/system/empty-stop-retry.md +4 -6
  339. package/src/prompts/system/subagent-system-prompt.md +4 -0
  340. package/src/prompts/system/system-prompt.md +10 -5
  341. package/src/prompts/system/title-marker-instruction.md +1 -0
  342. package/src/prompts/system/title-system-marker.md +16 -0
  343. package/src/prompts/tools/job.md +1 -0
  344. package/src/prompts/tools/learn.md +7 -0
  345. package/src/prompts/tools/manage-skill.md +9 -0
  346. package/src/prompts/tools/task.md +3 -0
  347. package/src/registry/agent-registry.ts +30 -0
  348. package/src/sdk.ts +103 -43
  349. package/src/secrets/obfuscator.ts +1 -1
  350. package/src/session/agent-session.ts +331 -318
  351. package/src/session/agent-storage.ts +18 -9
  352. package/src/session/history-storage.ts +3 -2
  353. package/src/session/indexed-session-storage.ts +7 -10
  354. package/src/session/messages.ts +9 -11
  355. package/src/session/session-context.ts +352 -0
  356. package/src/session/session-dump-format.ts +4 -2
  357. package/src/session/session-entries.ts +194 -0
  358. package/src/session/session-listing.ts +588 -0
  359. package/src/session/session-loader.ts +106 -0
  360. package/src/session/session-manager.ts +968 -3064
  361. package/src/session/session-migrations.ts +78 -0
  362. package/src/session/session-paths.ts +193 -0
  363. package/src/session/session-persistence.ts +131 -0
  364. package/src/session/session-storage.ts +91 -30
  365. package/src/session/snapcompact-inline.ts +21 -1
  366. package/src/session/snapcompact-savings-journal.ts +113 -0
  367. package/src/session/tool-choice-queue.ts +23 -11
  368. package/src/slash-commands/builtin-registry.ts +40 -4
  369. package/src/slash-commands/helpers/logout.ts +88 -0
  370. package/src/stt/asr-client.ts +520 -0
  371. package/src/stt/asr-protocol.ts +65 -0
  372. package/src/stt/asr-worker.ts +790 -0
  373. package/src/stt/downloader.ts +107 -47
  374. package/src/stt/endpointer.ts +259 -0
  375. package/src/stt/index.ts +5 -1
  376. package/src/stt/models.ts +150 -0
  377. package/src/stt/recorder.ts +247 -60
  378. package/src/stt/stt-controller.ts +201 -22
  379. package/src/stt/transcriber.ts +37 -68
  380. package/src/stt/wav.ts +173 -0
  381. package/src/system-prompt.ts +8 -0
  382. package/src/task/agents.ts +1 -2
  383. package/src/task/executor.ts +49 -15
  384. package/src/task/index.ts +60 -6
  385. package/src/task/render.ts +83 -8
  386. package/src/task/types.ts +54 -1
  387. package/src/tools/ask.ts +9 -1
  388. package/src/tools/ast-edit.ts +1 -1
  389. package/src/tools/ast-grep.ts +1 -1
  390. package/src/tools/bash.ts +5 -4
  391. package/src/tools/browser/cmux/cmux-tab.ts +1264 -0
  392. package/src/tools/browser/cmux/rpc.ts +156 -0
  393. package/src/tools/browser/cmux/socket-client.ts +309 -0
  394. package/src/tools/browser/registry.ts +37 -3
  395. package/src/tools/browser/render.ts +6 -1
  396. package/src/tools/browser/tab-protocol.ts +2 -0
  397. package/src/tools/browser/tab-supervisor.ts +189 -18
  398. package/src/tools/browser/tab-worker.ts +1 -1
  399. package/src/tools/browser.ts +16 -1
  400. package/src/tools/checkpoint.ts +1 -1
  401. package/src/tools/debug.ts +1 -1
  402. package/src/tools/eval-render.ts +4 -3
  403. package/src/tools/eval.ts +11 -6
  404. package/src/tools/fetch.ts +13 -2
  405. package/src/tools/find.ts +1 -1
  406. package/src/tools/gh.ts +1 -1
  407. package/src/tools/github-cache.ts +2 -1
  408. package/src/tools/image-gen.ts +1 -1
  409. package/src/tools/index.ts +43 -5
  410. package/src/tools/inspect-image.ts +3 -1
  411. package/src/tools/irc.ts +11 -3
  412. package/src/tools/job.ts +15 -3
  413. package/src/tools/learn.ts +144 -0
  414. package/src/tools/manage-skill.ts +104 -0
  415. package/src/tools/memory-edit.ts +1 -1
  416. package/src/tools/memory-recall.ts +1 -1
  417. package/src/tools/memory-reflect.ts +1 -1
  418. package/src/tools/memory-retain.ts +1 -1
  419. package/src/tools/plan-mode-guard.ts +53 -19
  420. package/src/tools/read.ts +8 -2
  421. package/src/tools/render-mermaid.ts +1 -1
  422. package/src/tools/renderers.ts +7 -11
  423. package/src/tools/report-tool-issue.ts +3 -2
  424. package/src/tools/resolve.ts +1 -1
  425. package/src/tools/review.ts +1 -1
  426. package/src/tools/search-tool-bm25.ts +1 -1
  427. package/src/tools/search.ts +1 -1
  428. package/src/tools/ssh.ts +5 -4
  429. package/src/tools/todo.ts +2 -2
  430. package/src/tools/tts.ts +204 -93
  431. package/src/tools/write.ts +19 -3
  432. package/src/tts/downloader.ts +64 -0
  433. package/src/tts/index.ts +8 -0
  434. package/src/tts/models.ts +137 -0
  435. package/src/tts/player.ts +137 -0
  436. package/src/tts/runtime.ts +21 -0
  437. package/src/tts/streaming-player.ts +266 -0
  438. package/src/tts/tts-client.ts +647 -0
  439. package/src/tts/tts-protocol.ts +60 -0
  440. package/src/tts/tts-worker.ts +497 -0
  441. package/src/tts/vocalizer.ts +162 -0
  442. package/src/tts/wav.ts +58 -0
  443. package/src/utils/clipboard.ts +35 -18
  444. package/src/utils/image-loading.ts +35 -4
  445. package/src/utils/thinking-display.ts +37 -0
  446. package/src/utils/title-generator.ts +48 -5
  447. package/src/utils/tool-choice.ts +16 -0
  448. package/src/utils/tools-manager.test.ts +25 -0
  449. package/src/utils/tools-manager.ts +19 -1
  450. package/src/web/scrapers/github.ts +96 -0
  451. package/src/web/search/index.ts +14 -1
  452. package/src/web/search/providers/searxng.ts +13 -1
  453. package/dist/types/cli/list-models.d.ts +0 -30
  454. package/dist/types/stt/setup.d.ts +0 -18
  455. package/src/cli/list-models.ts +0 -194
  456. package/src/stt/setup.ts +0 -52
  457. package/src/stt/transcribe.py +0 -70
@@ -1,297 +1,12 @@
1
- import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
2
1
  import type { ImageContent, Message, MessageAttribution, ServiceTier, TextContent } from "@oh-my-pi/pi-ai";
3
2
  import { ArtifactManager } from "./artifacts";
4
3
  import { type BlobPutOptions, type BlobPutResult } from "./blob-store";
5
4
  import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
6
- import type { SessionStorage } from "./session-storage";
7
- export declare const CURRENT_SESSION_VERSION = 3;
8
- export interface SessionHeader {
9
- type: "session";
10
- version?: number;
11
- id: string;
12
- title?: string;
13
- titleSource?: "auto" | "user";
14
- timestamp: string;
15
- cwd: string;
16
- parentSession?: string;
17
- }
18
- export interface NewSessionOptions {
19
- parentSession?: string;
20
- /** Skip flushing the current session and delete it instead of saving. */
21
- drop?: boolean;
22
- }
23
- export interface SessionEntryBase {
24
- type: string;
25
- id: string;
26
- parentId: string | null;
27
- timestamp: string;
28
- }
29
- export interface SessionMessageEntry extends SessionEntryBase {
30
- type: "message";
31
- message: AgentMessage;
32
- }
33
- export interface ThinkingLevelChangeEntry extends SessionEntryBase {
34
- type: "thinking_level_change";
35
- thinkingLevel?: string | null;
36
- }
37
- export interface ModelChangeEntry extends SessionEntryBase {
38
- type: "model_change";
39
- /** Model in "provider/modelId" format */
40
- model: string;
41
- /** Role: "default", "smol", "slow", etc. Undefined treated as "default" */
42
- role?: string;
43
- }
44
- export interface ServiceTierChangeEntry extends SessionEntryBase {
45
- type: "service_tier_change";
46
- serviceTier: ServiceTier | null;
47
- }
48
- export interface CompactionEntry<T = unknown> extends SessionEntryBase {
49
- type: "compaction";
50
- summary: string;
51
- shortSummary?: string;
52
- firstKeptEntryId: string;
53
- tokensBefore: number;
54
- /** Extension-specific data (e.g., ArtifactIndex, version markers for structured compaction) */
55
- details?: T;
56
- /** Hook-provided data to persist across compaction */
57
- preserveData?: Record<string, unknown>;
58
- /** True if generated by an extension, undefined/false if pi-generated (backward compatible) */
59
- fromExtension?: boolean;
60
- }
61
- export interface BranchSummaryEntry<T = unknown> extends SessionEntryBase {
62
- type: "branch_summary";
63
- fromId: string;
64
- summary: string;
65
- /** Extension-specific data (not sent to LLM) */
66
- details?: T;
67
- /** True if generated by an extension, false if pi-generated */
68
- fromExtension?: boolean;
69
- }
70
- /**
71
- * Custom entry for extensions to store extension-specific data in the session.
72
- * Use customType to identify your extension's entries.
73
- *
74
- * Purpose: Persist extension state across session reloads. On reload, extensions can
75
- * scan entries for their customType and reconstruct internal state.
76
- *
77
- * Does NOT participate in LLM context (ignored by buildSessionContext).
78
- * For injecting content into context, see CustomMessageEntry.
79
- */
80
- export interface CustomEntry<T = unknown> extends SessionEntryBase {
81
- type: "custom";
82
- customType: string;
83
- data?: T;
84
- }
85
- /** Label entry for user-defined bookmarks/markers on entries. */
86
- export interface LabelEntry extends SessionEntryBase {
87
- type: "label";
88
- targetId: string;
89
- label: string | undefined;
90
- }
91
- /** TTSR injection entry - tracks which time-traveling rules have been injected this session. */
92
- export interface TtsrInjectionEntry extends SessionEntryBase {
93
- type: "ttsr_injection";
94
- /** Names of rules that were injected */
95
- injectedRules: string[];
96
- }
97
- /** Persisted MCP discovery selection state for a session branch. */
98
- export interface MCPToolSelectionEntry extends SessionEntryBase {
99
- type: "mcp_tool_selection";
100
- /** MCP tool names selected for visibility in discovery mode. */
101
- selectedToolNames: string[];
102
- }
103
- /** Session init entry - captures initial context for subagent sessions (debugging/replay). */
104
- export interface SessionInitEntry extends SessionEntryBase {
105
- type: "session_init";
106
- /** Full system prompt sent to the model */
107
- systemPrompt: string;
108
- /** Initial task/user message */
109
- task: string;
110
- /** Tools available to the agent */
111
- tools: string[];
112
- /** Output schema if structured output was requested */
113
- outputSchema?: unknown;
114
- }
115
- /** Mode change entry - tracks agent mode transitions (e.g. plan mode). */
116
- export interface ModeChangeEntry extends SessionEntryBase {
117
- type: "mode_change";
118
- /** Current mode name, or "none" when exiting a mode */
119
- mode: string;
120
- /** Optional mode-specific data (e.g. plan file path) */
121
- data?: Record<string, unknown>;
122
- }
123
- /**
124
- * Custom message entry for extensions to inject messages into LLM context.
125
- * Use customType to identify your extension's entries.
126
- *
127
- * Unlike CustomEntry, this DOES participate in LLM context.
128
- * The content participates in LLM context through convertToLlm().
129
- * Use details for extension-specific metadata (not sent to LLM).
130
- *
131
- * display controls TUI rendering:
132
- * - false: hidden entirely
133
- * - true: rendered with distinct styling (different from user messages)
134
- */
135
- export interface CustomMessageEntry<T = unknown> extends SessionEntryBase {
136
- type: "custom_message";
137
- customType: string;
138
- content: string | (TextContent | ImageContent)[];
139
- details?: T;
140
- display: boolean;
141
- /** Who initiated this message for billing/attribution semantics. */
142
- attribution?: MessageAttribution;
143
- }
144
- /** Session entry - has id/parentId for tree structure (returned by "read" methods in SessionManager) */
145
- export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | ServiceTierChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | TtsrInjectionEntry | MCPToolSelectionEntry | SessionInitEntry | ModeChangeEntry;
146
- /** Raw file entry (includes header) */
147
- export type FileEntry = SessionHeader | SessionEntry;
148
- /** Tree node for getTree() - defensive copy of session structure */
149
- export interface SessionTreeNode {
150
- entry: SessionEntry;
151
- children: SessionTreeNode[];
152
- /** Resolved label for this entry, if any */
153
- label?: string;
154
- }
155
- export interface SessionContext {
156
- messages: AgentMessage[];
157
- thinkingLevel?: string;
158
- serviceTier?: ServiceTier;
159
- /** Model roles: { default: "provider/modelId", small: "provider/modelId", ... } */
160
- models: Record<string, string>;
161
- /** Names of TTSR rules that have been injected this session */
162
- injectedTtsrRules: string[];
163
- /** MCP tool names selected through discovery for this session branch. */
164
- selectedMCPToolNames: string[];
165
- /** Whether this branch contains an explicit persisted MCP selection entry. */
166
- hasPersistedMCPToolSelection: boolean;
167
- /** Active mode (e.g. "plan") or "none" if no special mode is active */
168
- mode: string;
169
- /** Mode-specific data from the last mode_change entry */
170
- modeData?: Record<string, unknown>;
171
- }
172
- export declare const EPHEMERAL_MODEL_CHANGE_ROLE = "fallback";
173
- /** Lists session model strings to try when restoring, in fallback order. */
174
- export declare function getRestorableSessionModels(models: Readonly<Record<string, string>>, lastModelChangeRole: string | undefined): string[];
175
- /**
176
- * Coarse lifecycle status of a session, derived from its last persisted message.
177
- *
178
- * - `complete` — the last assistant turn ended with no unanswered tool calls, i.e.
179
- * the agent yielded control back to the user.
180
- * - `interrupted` — work was cut off mid-flight: a trailing assistant turn with
181
- * pending tool calls, a trailing tool result the agent never continued from, or
182
- * a length-truncated turn.
183
- * - `aborted` — the last assistant turn was cancelled by the user.
184
- * - `error` — the last assistant turn ended in an error.
185
- * - `pending` — a trailing user message with no assistant reply persisted after it.
186
- * - `unknown` — status could not be determined (empty/header-only session, or the
187
- * final message was larger than the tail window that was read).
188
- */
189
- export type SessionStatus = "complete" | "interrupted" | "aborted" | "error" | "pending" | "unknown";
190
- export interface SessionInfo {
191
- path: string;
192
- id: string;
193
- /** Working directory where the session was started. Empty string for old sessions. */
194
- cwd: string;
195
- title?: string;
196
- /** Path to the parent session (if this session was forked). */
197
- parentSessionPath?: string;
198
- created: Date;
199
- modified: Date;
200
- messageCount: number;
201
- /** File size in bytes on disk; used for compact list rendering. */
202
- size: number;
203
- firstMessage: string;
204
- allMessagesText: string;
205
- /**
206
- * Coarse lifecycle status from the session's last persisted message. Optional:
207
- * synthesized {@link SessionInfo}s (cross-project stubs, tests) leave it unset.
208
- */
209
- status?: SessionStatus;
210
- }
5
+ import { type BuildSessionContextOptions, type SessionContext } from "./session-context";
6
+ import { type NewSessionOptions, type SessionEntry, type SessionHeader, type SessionTreeNode, type UsageStatistics } from "./session-entries";
7
+ import { type SessionInfo } from "./session-listing";
8
+ import { type SessionStorage } from "./session-storage";
211
9
  export type ReadonlySessionManager = Pick<SessionManager, "getCwd" | "getSessionDir" | "getSessionId" | "getSessionFile" | "getSessionName" | "getArtifactsDir" | "getArtifactManager" | "allocateArtifactPath" | "saveArtifact" | "getArtifactPath" | "getLeafId" | "getLeafEntry" | "getEntry" | "getLabel" | "getBranch" | "getHeader" | "getEntries" | "getTree" | "getUsageStatistics" | "putBlob" | "putBlobSync">;
212
- /** Exported for testing */
213
- export declare function migrateSessionEntries(entries: FileEntry[]): void;
214
- /** Exported for compaction.test.ts */
215
- export declare function parseSessionEntries(content: string): FileEntry[];
216
- export declare function getLatestCompactionEntry(entries: SessionEntry[]): CompactionEntry | null;
217
- export interface BuildSessionContextOptions {
218
- /**
219
- * Build the full-history display transcript instead of the LLM context:
220
- * every path entry in chronological order, with each compaction emitted
221
- * inline as a `compactionSummary` message at the position it fired rather
222
- * than replacing the history before it. Display-only — never send the
223
- * result to a provider.
224
- */
225
- transcript?: boolean;
226
- }
227
- /**
228
- * Build the session context from entries using tree traversal.
229
- * If leafId is provided, walks from that entry to root.
230
- * Handles compaction and branch summaries along the path.
231
- */
232
- export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, options?: BuildSessionContextOptions): SessionContext;
233
- /** Exported for testing */
234
- export declare function loadEntriesFromFile(filePath: string, storage?: SessionStorage): Promise<FileEntry[]>;
235
- /**
236
- * Read-only message view of a session file: load entries, migrate to the
237
- * current version, resolve blob refs, and build the context along the
238
- * persisted leaf path (last entry). Does NOT create a writer or take the
239
- * session lock — safe to call against a file another session is writing.
240
- */
241
- export declare function loadSessionMessagesReadOnly(filePath: string): Promise<AgentMessage[]>;
242
- declare class RecentSessionInfo {
243
- #private;
244
- readonly path: string;
245
- readonly mtime: number;
246
- constructor(path: string, mtime: number, header: Record<string, unknown>, firstPrompt?: string);
247
- /** Display name. Falls back to a timestamp-based label, never the raw UUID. */
248
- get fullName(): string;
249
- /**
250
- * Display name without an arbitrary length cap. The renderer is responsible for
251
- * width-aware truncation so adjacent fields (e.g. the relative time) stay visible.
252
- */
253
- get name(): string;
254
- /** Human-readable relative time (e.g., "2 hours ago") */
255
- get timeAgo(): string;
256
- }
257
- /**
258
- * Promote orphaned `<basename>.jsonl.<snowflake>.bak` backups created by
259
- * `#replaceSessionFileAfterEperm` back to their primary path when the primary
260
- * is missing. This runs once per session-dir scan, before the main `*.jsonl`
261
- * glob, so a crash between the two renames in the EPERM-rewrite path does not
262
- * leave the user's last good state stranded outside the loader's view.
263
- *
264
- * Exported for testing.
265
- */
266
- export declare function recoverOrphanedBackups(sessionDir: string, storage: SessionStorage): Promise<void>;
267
- /** Exported for testing */
268
- export declare function findMostRecentSession(sessionDir: string, storage?: SessionStorage): Promise<string | null>;
269
- /** Get recent sessions for display in welcome screen (which reserves WELCOME_SESSION_SLOTS rows) */
270
- export declare function getRecentSessions(sessionDir: string, limit?: number, storage?: SessionStorage): Promise<RecentSessionInfo[]>;
271
- /**
272
- * Manages conversation sessions as append-only trees stored in JSONL files.
273
- *
274
- * Each session entry has an id and parentId forming a tree structure. The "leaf"
275
- * pointer tracks the current position. Appending creates a child of the current leaf.
276
- * Branching moves the leaf to an earlier entry, allowing new branches without
277
- * modifying history.
278
- *
279
- * Use buildSessionContext() to get the resolved message list for the LLM, which
280
- * handles compaction summaries and follows the path from root to current leaf.
281
- */
282
- export interface UsageStatistics {
283
- input: number;
284
- output: number;
285
- cacheRead: number;
286
- cacheWrite: number;
287
- premiumRequests: number;
288
- cost: number;
289
- }
290
- export interface ResolvedSessionMatch {
291
- session: SessionInfo;
292
- scope: "local" | "global";
293
- }
294
- export declare function resolveResumableSession(sessionArg: string, cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<ResolvedSessionMatch | undefined>;
295
10
  interface SessionManagerStateSnapshot {
296
11
  cwd: string;
297
12
  sessionDir: string;
@@ -299,78 +14,81 @@ interface SessionManagerStateSnapshot {
299
14
  sessionName: string | undefined;
300
15
  titleSource: "auto" | "user" | undefined;
301
16
  sessionFile: string | undefined;
302
- flushed: boolean;
303
- needsFullRewriteOnNextPersist: boolean;
304
- fileEntries: FileEntry[];
17
+ onDisk: boolean;
18
+ needsRewrite: boolean;
19
+ header: SessionHeader;
20
+ entries: SessionEntry[];
305
21
  }
22
+ /**
23
+ * Stores and navigates an append-only conversation journal.
24
+ *
25
+ * A session is a JSONL file: one header line followed by entries. Entries form a
26
+ * tree by `(id, parentId)`, and the mutable leaf pointer selects which path is
27
+ * active for future appends and for LLM context construction.
28
+ *
29
+ * Durability is software-crash safe but not power-loss safe: appends are handed
30
+ * to the OS synchronously in-body (so an entry survives an OOM/SIGKILL the
31
+ * instant `appendMessage` returns) but never `fsync`'d. Full-file rewrites go
32
+ * through the storage layer's atomic temp-write+rename so a crash mid-rewrite
33
+ * cannot truncate the prior good file.
34
+ */
306
35
  export declare class SessionManager {
307
36
  #private;
308
- private cwd;
309
- private sessionDir;
310
- private readonly persist;
311
- private readonly storage;
312
37
  /**
313
38
  * Collab replication tap: invoked for every appended entry with the
314
39
  * in-memory (pre-blob-externalization) entry, so inline images survive.
315
- * Failures are swallowed — a broadcast error must never break persistence.
316
40
  */
317
41
  onEntryAppended?: (entry: SessionEntry) => void;
318
42
  private constructor();
319
- /** Puts a binary blob into the blob store and returns the blob reference */
43
+ /** Puts a binary blob into the blob store and returns the blob reference. */
320
44
  putBlob(data: Buffer, options?: BlobPutOptions): Promise<BlobPutResult>;
321
45
  /** Synchronous variant of {@link putBlob} for rebuild-only render paths. */
322
46
  putBlobSync(data: Buffer, options?: BlobPutOptions): BlobPutResult;
323
47
  captureState(): SessionManagerStateSnapshot;
324
48
  restoreState(snapshot: SessionManagerStateSnapshot): void;
325
- /** Switch to a different session file (used for resume and branching) */
49
+ /** Switch to a different session file (resume / branch). */
326
50
  setSessionFile(sessionFile: string): Promise<void>;
327
- /** Start a new session. Closes any existing writer first. */
51
+ /** Start a new session. Drains and closes any existing writer first. */
328
52
  newSession(options?: NewSessionOptions): Promise<string | undefined>;
329
- /** Delete a session file and its artifacts. Drains the persist writer first to avoid EPERM on Windows. ENOENT is treated as success. */
53
+ /** Delete a session file and its artifact directory. ENOENT is treated as success. */
330
54
  dropSession(sessionPath: string): Promise<void>;
331
55
  /**
332
- * Fork the current session, creating a new session file with the same entries.
333
- * Returns both the old and new session file paths for artifact copying.
334
- * @returns { oldSessionFile, newSessionFile } or undefined if not persisting
56
+ * Fork the current session into a new file with the same entries.
57
+ * @returns the old and new session file paths, or undefined when not persisting.
335
58
  */
336
59
  fork(): Promise<{
337
60
  oldSessionFile: string;
338
61
  newSessionFile: string;
339
62
  } | undefined>;
340
63
  /**
341
- * Move the session to a new working directory.
342
- * Moves session files and artifacts on disk, updates all internal references,
343
- * and rewrites the session header with the new cwd. When provided,
344
- * `targetSessionDir` is used instead of deriving the default directory for
345
- * the new cwd (for `--continue --session-dir` / `--resume --session-dir`).
64
+ * Move the session to a new working directory: relocate the session file and
65
+ * artifacts on disk, update internal references, and rewrite the header cwd.
346
66
  */
347
67
  moveTo(newCwd: string, targetSessionDir?: string): Promise<void>;
348
- isPersisted(): boolean;
349
68
  /**
350
- * Force-persist all current entries to disk, even when no assistant message exists yet.
351
- * Used by ACP mode where session/new must create a discoverable session immediately.
69
+ * Force the session onto disk even with no assistant message yet (ACP
70
+ * session/new must create a discoverable file immediately).
352
71
  */
353
72
  ensureOnDisk(): Promise<void>;
354
- /** Flush pending writes to disk. Call before switching sessions or on shutdown. */
73
+ /** Flush pending writes. Call before switching sessions or on shutdown. */
355
74
  flush(): Promise<void>;
356
- /** Close the persistent writer after flushing all pending data. */
75
+ /**
76
+ * Synchronously flush all in-memory entries to disk. Use when the process may
77
+ * exit before an async flush settles (Ctrl+C in the TUI). Software-crash
78
+ * durable; not atomic and not power-loss safe — a same-process crash never
79
+ * lands mid-`writeFileSync`.
80
+ */
81
+ flushSync(): void;
82
+ /** Flush, then close the append writer. */
357
83
  close(): Promise<void>;
358
84
  getCwd(): string;
359
- /** Get usage statistics across all assistant messages in the session. */
360
85
  getUsageStatistics(): UsageStatistics;
361
86
  /**
362
87
  * Open a new per-turn budget window: snapshot the cumulative output baseline,
363
- * reset the eval-subagent counter, and set the (optional) ceiling. Called once
364
- * per real user message; `total` is null when no `+Nk` directive was present.
88
+ * reset the eval-subagent counter, and set the (optional) ceiling.
365
89
  */
366
90
  beginTurnBudget(total: number | null, hard: boolean): void;
367
- /** Record output tokens consumed by an eval-spawned subagent in the current turn. */
368
91
  recordEvalSubagentOutput(output: number): void;
369
- /**
370
- * Current turn budget for the eval `budget` helper: the ceiling (null = none),
371
- * output tokens spent this turn (main loop + eval-spawned subagents, no
372
- * double-count), and whether the ceiling is hard.
373
- */
374
92
  getTurnBudget(): {
375
93
  total: number | null;
376
94
  spent: number;
@@ -379,114 +97,67 @@ export declare class SessionManager {
379
97
  getSessionDir(): string;
380
98
  getSessionId(): string;
381
99
  getSessionFile(): string | undefined;
382
- /**
383
- * Returns the session artifacts directory path (session file path without .jsonl).
384
- * Returns null when the session is not persisted to a file.
385
- * When this session has adopted an external ArtifactManager (subagent case),
386
- * returns that manager's directory so reads/writes land in the shared parent
387
- * dir instead of a private (non-existent) subdir.
388
- */
389
100
  getArtifactsDir(): string | null;
390
- /**
391
- * Adopt an externally-owned ArtifactManager. Used by subagents to share
392
- * the parent session's artifact directory and ID counter.
393
- */
394
101
  adoptArtifactManager(manager: ArtifactManager): void;
395
- /**
396
- * Returns the ArtifactManager this session writes through. Lazily creates
397
- * one bound to the current session file unless an external manager was
398
- * adopted via `adoptArtifactManager`. Returns null only for non-persistent
399
- * sessions with no adopted manager.
400
- */
401
102
  getArtifactManager(): ArtifactManager | null;
402
- /**
403
- * Allocate a new artifact path and ID for the current session.
404
- * Returns an empty object when the session is not persisted.
405
- */
406
103
  allocateArtifactPath(toolType: string): Promise<{
407
104
  id?: string;
408
105
  path?: string;
409
106
  }>;
410
- /**
411
- * Save artifact content under the current session and return artifact ID.
412
- * Returns an artifact ID for all sessions (file-backed for persistent, in-memory fallback otherwise).
413
- */
414
107
  saveArtifact(content: string, toolType: string): Promise<string | undefined>;
415
- /**
416
- * Resolve an artifact ID to an on-disk path for the current session.
417
- * Returns null when missing or when the session is not persisted.
418
- */
419
108
  getArtifactPath(id: string): Promise<string | null>;
420
- /**
421
- * Persist (or clear) the current editor draft so the next resume of this
422
- * session can restore it. Empty text deletes any stale draft. No-op when the
423
- * session is not persisted.
424
- */
425
109
  saveDraft(text: string): Promise<void>;
426
- /**
427
- * Read and remove the saved draft. Returns the previously-saved text, or
428
- * null when no draft is pending. Single-shot: a successful read removes the
429
- * sidecar so a subsequent resume does not re-restore the same text.
430
- */
431
110
  consumeDraft(): Promise<string | null>;
432
- /** The source that set the session name: "user" (manual /rename or RPC) or "auto" (generated title). */
111
+ /** The source that set the session name: "user" (manual/RPC) or "auto" (generated title). */
433
112
  get titleSource(): "auto" | "user" | undefined;
434
113
  getSessionName(): string | undefined;
435
114
  onSessionNameChanged(cb: () => void): () => void;
436
115
  /**
437
116
  * Set the session display name.
438
- * @param source - "user" for explicit renames (/rename command, RPC); "auto" for generated titles.
439
- * Auto-generated titles are silently ignored when the user has already set a name.
117
+ * @param source "user" for explicit renames; "auto" for generated titles.
118
+ * Auto titles are ignored once the user has set a name.
440
119
  */
441
120
  setSessionName(name: string, source?: "auto" | "user"): Promise<boolean>;
442
- _persist(entry: SessionEntry): void;
443
121
  /**
444
122
  * Append a foreign (host-authored) entry verbatim, preserving its
445
- * `id`/`parentId` — no id minting. Used by collab guests to mirror the
446
- * host session into the local replica file.
123
+ * `id`/`parentId`. Used by collab guests to mirror the host session.
447
124
  */
448
125
  ingestReplicatedEntry(entry: SessionEntry): void;
449
126
  /**
450
127
  * Snapshot the session for collab replication: the live header plus a deep
451
- * copy of every entry (the host mutates entries in place on
452
- * truncation/rewrite paths, so guests must not share references).
128
+ * copy of every entry (the host mutates entries in place on rewrite paths, so
129
+ * guests must not share references).
453
130
  */
454
131
  snapshotForReplication(): {
455
132
  header: SessionHeader;
456
133
  entries: SessionEntry[];
457
134
  };
458
- /** Append a message as child of current leaf, then advance leaf. Returns entry id.
459
- * Does not allow writing CompactionSummaryMessage and BranchSummaryMessage directly.
460
- * Reason: we want these to be top-level entries in the session, not message session entries,
461
- * so it is easier to find them.
462
- * These need to be appended via appendCompaction() and appendBranchSummary() methods.
135
+ /**
136
+ * Append a message as a child of the current leaf, then advance the leaf.
137
+ * CompactionSummaryMessage / BranchSummaryMessage are rejected here they are
138
+ * top-level entries via appendCompaction()/branchWithSummary().
463
139
  */
464
140
  appendMessage(message: Message | CustomMessage | HookMessage | BashExecutionMessage | PythonExecutionMessage | FileMentionMessage): string;
465
- /** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
466
141
  appendThinkingLevelChange(thinkingLevel?: string): string;
467
142
  appendServiceTierChange(serviceTier: ServiceTier | null): string;
468
- /** Append a mode change as child of current leaf, then advance leaf. Returns entry id. */
469
143
  appendModeChange(mode: string, data?: Record<string, unknown>): string;
470
144
  /**
471
- * Append a model change as child of current leaf, then advance leaf. Returns entry id.
145
+ * Append a model change as a child of the current leaf, then advance the leaf.
472
146
  * @param model Model in "provider/modelId" format
473
147
  * @param role Optional role (default: "default")
474
148
  */
475
149
  appendModelChange(model: string, role?: string): string;
476
- /** Append session init metadata (for subagent debugging/replay). Returns entry id. */
477
150
  appendSessionInit(init: {
478
151
  systemPrompt: string;
479
152
  task: string;
480
153
  tools: string[];
481
154
  outputSchema?: unknown;
482
155
  }): string;
483
- /** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */
484
156
  appendCompaction<T = unknown>(summary: string, shortSummary: string | undefined, firstKeptEntryId: string, tokensBefore: number, details?: T, fromExtension?: boolean, preserveData?: Record<string, unknown>): string;
485
- /** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */
486
157
  appendCustomEntry(customType: string, data?: unknown): string;
487
158
  /**
488
- * Rewrite the session file after in-place entry updates.
489
- * Use sparingly (e.g., pruning old tool outputs).
159
+ * Rewrite the session file after in-place entry updates (e.g. pruning old tool
160
+ * outputs). Use sparingly.
490
161
  */
491
162
  rewriteEntries(): Promise<void>;
492
163
  /**
@@ -496,143 +167,95 @@ export declare class SessionManager {
496
167
  * @param display Whether to show in TUI (true = styled display, false = hidden)
497
168
  * @param details Optional extension-specific metadata (not sent to LLM)
498
169
  * @param attribution Who initiated this message for billing/attribution semantics
499
- * @returns Entry id
500
170
  */
501
171
  appendCustomMessageEntry<T = unknown>(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details?: T, attribution?: MessageAttribution): string;
502
172
  /**
503
173
  * Append an MCP tool selection entry recording the discovery-selected MCP tools.
504
- * @param selectedToolNames MCP tool names selected for this branch
505
- * @returns Entry id
506
174
  */
507
175
  appendMCPToolSelection(selectedToolNames: string[]): string;
508
- /**
509
- * Append a TTSR injection entry recording which rules were injected.
510
- * @param ruleNames Names of rules that were injected
511
- * @returns Entry id
512
- */
176
+ /** Append a TTSR injection entry recording which rules were injected. */
513
177
  appendTtsrInjection(ruleNames: string[]): string;
514
- /**
515
- * Get all unique TTSR rule names that have been injected in the current branch.
516
- * Scans from root to current leaf for ttsr_injection entries.
517
- */
178
+ /** All unique TTSR rule names injected on the current branch (root → leaf). */
518
179
  getInjectedTtsrRules(): string[];
519
180
  getLeafId(): string | null;
520
181
  getLeafEntry(): SessionEntry | undefined;
521
182
  /**
522
- * Get the most recent model role from the current session path.
523
- * Returns undefined if no model change has been recorded.
183
+ * The most recent model role on the current branch, or undefined when no
184
+ * model change has been recorded.
524
185
  */
525
186
  getLastModelChangeRole(): string | undefined;
526
187
  getEntry(id: string): SessionEntry | undefined;
527
- /**
528
- * Get all direct children of an entry.
529
- */
188
+ /** All direct children of an entry. */
530
189
  getChildren(parentId: string): SessionEntry[];
531
- /**
532
- * Get the label for an entry, if any.
533
- */
534
190
  getLabel(id: string): string | undefined;
535
191
  /**
536
- * Set or clear a label on an entry.
537
- * Labels are user-defined markers for bookmarking/navigation.
538
- * Pass undefined or empty string to clear the label.
192
+ * Set or clear a label on an entry. Pass undefined/empty to clear.
539
193
  */
540
194
  appendLabelChange(targetId: string, label: string | undefined): string;
541
195
  /**
542
- * Walk from entry to root, returning all entries in path order.
543
- * Includes all entry types (messages, compaction, model changes, etc.).
544
- * Use buildSessionContext() to get the resolved messages for the LLM.
196
+ * Walk from an entry to root, returning entries in path order. Includes all
197
+ * entry types; use buildSessionContext() for the resolved LLM messages.
545
198
  */
546
199
  getBranch(fromId?: string): SessionEntry[];
547
200
  /**
548
- * Build the session context (what gets sent to the LLM), or — with
549
- * `{ transcript: true }` the full-history display transcript.
550
- * Uses tree traversal from current leaf.
201
+ * Build the session context (LLM messages), or — with `{ transcript: true }` —
202
+ * the full-history display transcript, from the current leaf path.
551
203
  */
552
204
  buildSessionContext(options?: BuildSessionContextOptions): SessionContext;
553
- /** Strip stale OpenAI Responses assistant replay metadata from loaded in-memory entries. */
205
+ /** Strip stale OpenAI Responses assistant replay metadata from loaded entries. */
554
206
  sanitizeLoadedOpenAIResponsesReplayMetadata(): boolean;
555
- /**
556
- * Get session header.
557
- */
558
207
  getHeader(): SessionHeader | null;
559
- /**
560
- * Get all session entries (excludes header). Returns a shallow copy.
561
- * The session is append-only: use appendXXX() to add entries, branch() to
562
- * change the leaf pointer. Entries cannot be modified or deleted.
563
- */
208
+ /** All session entries (excludes header). Returns a shallow copy. */
564
209
  getEntries(): SessionEntry[];
565
210
  /**
566
- * Get the session as a tree structure. Returns a shallow defensive copy of all entries.
567
- * A well-formed session has exactly one root (first entry with parentId === null).
568
- * Orphaned entries (broken parent chain) are also returned as roots.
211
+ * The session as a tree. A well-formed session has exactly one root; orphaned
212
+ * entries (broken parent chain) are returned as roots too.
569
213
  */
570
214
  getTree(): SessionTreeNode[];
571
215
  /**
572
- * Start a new branch from an earlier entry.
573
- * Moves the leaf pointer to the specified entry. The next appendXXX() call
574
- * will create a child of that entry, forming a new branch. Existing entries
575
- * are not modified or deleted.
216
+ * Move the leaf to an earlier entry so the next append forms a new branch.
217
+ * Existing entries are never modified or deleted.
576
218
  */
577
219
  branch(branchFromId: string): void;
578
- /**
579
- * Reset the leaf pointer to null (before any entries).
580
- * The next appendXXX() call will create a new root entry (parentId = null).
581
- * Use this when navigating to re-edit the first user message.
582
- */
220
+ /** Reset the leaf to null so the next append creates a new root entry. */
583
221
  resetLeaf(): void;
584
- /**
585
- * Start a new branch with a summary of the abandoned path.
586
- * Same as branch(), but also appends a branch_summary entry that captures
587
- * context from the abandoned conversation path.
588
- */
222
+ /** Like branch(), but also records a branch_summary of the abandoned path. */
589
223
  branchWithSummary(branchFromId: string | null, summary: string, details?: unknown, fromExtension?: boolean): string;
590
224
  /**
591
- * Create a new session file containing only the path from root to the specified leaf.
592
- * Useful for extracting a single conversation path from a branched session.
593
- * Returns the new session file path, or undefined if not persisting.
225
+ * Create a new session file containing only the path from root to `leafId`.
226
+ * Returns the new file path, or undefined when not persisting.
594
227
  */
595
228
  createBranchedSession(leafId: string): string | undefined;
596
- /**
597
- * Resolve the canonical default session directory for a cwd.
598
- */
229
+ /** Resolve the canonical default session directory for a cwd. */
599
230
  static getDefaultSessionDir(cwd: string, agentDir?: string, storage?: SessionStorage): string;
600
231
  /**
601
232
  * Create a new session.
602
- * @param cwd Working directory (stored in session header)
603
- * @param sessionDir Optional session directory. If omitted, uses default (~/.omp/agent/sessions/<encoded-cwd>/).
233
+ * @param cwd Working directory (stored in the session header)
234
+ * @param sessionDir Optional session directory; defaults to the cwd-derived dir.
604
235
  */
605
236
  static create(cwd: string, sessionDir?: string, storage?: SessionStorage): SessionManager;
606
237
  /**
607
- * Fork a session into the current project directory.
608
- * Copies history from another session file while creating a new session file in the current sessionDir.
238
+ * Fork a session into the current project directory: copy history from another
239
+ * session file while creating a fresh session file in this sessionDir.
609
240
  */
610
241
  static forkFrom(sourcePath: string, cwd: string, sessionDir?: string, storage?: SessionStorage, options?: {
611
242
  suppressBreadcrumb?: boolean;
612
243
  }): Promise<SessionManager>;
613
244
  /**
614
245
  * Open a specific session file.
615
- * @param path Path to session file
616
- * @param sessionDir Optional session directory for /new or /branch. If omitted, derives from file's parent.
246
+ * @param sessionDir Optional dir for /new or /branch; defaults to the file's parent.
617
247
  */
618
248
  static open(filePath: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionManager>;
619
- /**
620
- * Continue the most recent session, or create new if none.
621
- * @param cwd Working directory
622
- * @param sessionDir Optional session directory. If omitted, uses default (~/.omp/agent/sessions/<encoded-cwd>/).
623
- */
249
+ /** Continue the most recent session, or create a new one if none exists. */
624
250
  static continueRecent(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionManager>;
625
- /** Create an in-memory session (no file persistence) */
251
+ /** Create an in-memory session (no file persistence). */
626
252
  static inMemory(cwd?: string, storage?: SessionStorage): SessionManager;
627
253
  /**
628
- * List all sessions.
629
- * @param cwd Working directory (used to compute default session directory)
630
- * @param sessionDir Optional session directory. If omitted, uses default (~/.omp/agent/sessions/<encoded-cwd>/).
254
+ * List sessions for a project directory.
255
+ * @param sessionDir Optional dir; defaults to the cwd-derived dir.
631
256
  */
632
257
  static list(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
633
- /**
634
- * List all sessions across all project directories.
635
- */
258
+ /** List all sessions across all project directories. */
636
259
  static listAll(storage?: SessionStorage): Promise<SessionInfo[]>;
637
260
  }
638
261
  export {};