open-multi-agent-kit 0.78.7 → 0.79.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 (2267) hide show
  1. package/CHANGELOG.md +4258 -391
  2. package/README.md +541 -267
  3. package/dist/bun/cli.d.ts +3 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +10 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/register-bedrock.d.ts +2 -0
  8. package/dist/bun/register-bedrock.d.ts.map +1 -0
  9. package/dist/bun/register-bedrock.js +4 -0
  10. package/dist/bun/register-bedrock.js.map +1 -0
  11. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  12. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  13. package/dist/bun/restore-sandbox-env.js +32 -0
  14. package/dist/bun/restore-sandbox-env.js.map +1 -0
  15. package/dist/cli/args.d.ts +56 -0
  16. package/dist/cli/args.d.ts.map +1 -0
  17. package/dist/cli/args.js +392 -0
  18. package/dist/cli/args.js.map +1 -0
  19. package/dist/cli/config-selector.d.ts +14 -0
  20. package/dist/cli/config-selector.d.ts.map +1 -0
  21. package/dist/cli/config-selector.js +31 -0
  22. package/dist/cli/config-selector.js.map +1 -0
  23. package/dist/cli/file-processor.d.ts +15 -0
  24. package/dist/cli/file-processor.d.ts.map +1 -0
  25. package/dist/cli/file-processor.js +82 -0
  26. package/dist/cli/file-processor.js.map +1 -0
  27. package/dist/cli/initial-message.d.ts +18 -0
  28. package/dist/cli/initial-message.d.ts.map +1 -0
  29. package/dist/cli/initial-message.js +22 -0
  30. package/dist/cli/initial-message.js.map +1 -0
  31. package/dist/cli/list-models.d.ts +9 -0
  32. package/dist/cli/list-models.d.ts.map +1 -0
  33. package/dist/cli/list-models.js +98 -0
  34. package/dist/cli/list-models.js.map +1 -0
  35. package/dist/cli/session-picker.d.ts +9 -0
  36. package/dist/cli/session-picker.d.ts.map +1 -0
  37. package/dist/cli/session-picker.js +35 -0
  38. package/dist/cli/session-picker.js.map +1 -0
  39. package/dist/cli.d.ts +1 -0
  40. package/dist/cli.d.ts.map +1 -0
  41. package/dist/cli.js +17 -16
  42. package/dist/cli.js.map +1 -0
  43. package/dist/config.d.ts +132 -0
  44. package/dist/config.d.ts.map +1 -0
  45. package/dist/config.js +529 -0
  46. package/dist/config.js.map +1 -0
  47. package/dist/core/adaptive-runtime.d.ts +150 -0
  48. package/dist/core/adaptive-runtime.d.ts.map +1 -0
  49. package/dist/core/adaptive-runtime.js +378 -0
  50. package/dist/core/adaptive-runtime.js.map +1 -0
  51. package/dist/core/agent-session-runtime.d.ts +117 -0
  52. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  53. package/dist/core/agent-session-runtime.js +300 -0
  54. package/dist/core/agent-session-runtime.js.map +1 -0
  55. package/dist/core/agent-session-services.d.ts +87 -0
  56. package/dist/core/agent-session-services.d.ts.map +1 -0
  57. package/dist/core/agent-session-services.js +119 -0
  58. package/dist/core/agent-session-services.js.map +1 -0
  59. package/dist/core/agent-session.d.ts +604 -0
  60. package/dist/core/agent-session.d.ts.map +1 -0
  61. package/dist/core/agent-session.js +2535 -0
  62. package/dist/core/agent-session.js.map +1 -0
  63. package/dist/core/auth-guidance.d.ts +5 -0
  64. package/dist/core/auth-guidance.d.ts.map +1 -0
  65. package/dist/core/auth-guidance.js +21 -0
  66. package/dist/core/auth-guidance.js.map +1 -0
  67. package/dist/core/auth-storage.d.ts +141 -0
  68. package/dist/core/auth-storage.d.ts.map +1 -0
  69. package/dist/core/auth-storage.js +445 -0
  70. package/dist/core/auth-storage.js.map +1 -0
  71. package/dist/core/bash-executor.d.ts +32 -0
  72. package/dist/core/bash-executor.d.ts.map +1 -0
  73. package/dist/core/bash-executor.js +111 -0
  74. package/dist/core/bash-executor.js.map +1 -0
  75. package/dist/core/compaction/branch-summarization.d.ts +90 -0
  76. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  77. package/dist/core/compaction/branch-summarization.js +249 -0
  78. package/dist/core/compaction/branch-summarization.js.map +1 -0
  79. package/dist/core/compaction/compaction.d.ts +132 -0
  80. package/dist/core/compaction/compaction.d.ts.map +1 -0
  81. package/dist/core/compaction/compaction.js +635 -0
  82. package/dist/core/compaction/compaction.js.map +1 -0
  83. package/dist/core/compaction/index.d.ts +7 -0
  84. package/dist/core/compaction/index.d.ts.map +1 -0
  85. package/dist/core/compaction/index.js +7 -0
  86. package/dist/core/compaction/index.js.map +1 -0
  87. package/dist/core/compaction/utils.d.ts +38 -0
  88. package/dist/core/compaction/utils.d.ts.map +1 -0
  89. package/dist/core/compaction/utils.js +153 -0
  90. package/dist/core/compaction/utils.js.map +1 -0
  91. package/dist/core/defaults.d.ts +3 -0
  92. package/dist/core/defaults.d.ts.map +1 -0
  93. package/dist/core/defaults.js +2 -0
  94. package/dist/core/defaults.js.map +1 -0
  95. package/dist/core/diagnostics.d.ts +15 -0
  96. package/dist/core/diagnostics.d.ts.map +1 -0
  97. package/dist/core/diagnostics.js +2 -0
  98. package/dist/core/diagnostics.js.map +1 -0
  99. package/dist/core/event-bus.d.ts +9 -0
  100. package/dist/core/event-bus.d.ts.map +1 -0
  101. package/dist/core/event-bus.js +25 -0
  102. package/dist/core/event-bus.js.map +1 -0
  103. package/dist/core/exec.d.ts +29 -0
  104. package/dist/core/exec.d.ts.map +1 -0
  105. package/dist/core/exec.js +75 -0
  106. package/dist/core/exec.js.map +1 -0
  107. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  108. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  109. package/dist/core/export-html/ansi-to-html.js +249 -0
  110. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  111. package/dist/core/export-html/index.d.ts +37 -0
  112. package/dist/core/export-html/index.d.ts.map +1 -0
  113. package/dist/core/export-html/index.js +226 -0
  114. package/dist/core/export-html/index.js.map +1 -0
  115. package/dist/core/export-html/template.css +1066 -0
  116. package/dist/core/export-html/template.html +55 -0
  117. package/dist/core/export-html/template.js +1864 -0
  118. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  119. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  120. package/dist/core/export-html/tool-renderer.js +108 -0
  121. package/dist/core/export-html/tool-renderer.js.map +1 -0
  122. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  123. package/dist/core/export-html/vendor/marked.min.js +6 -0
  124. package/dist/core/extensions/index.d.ts +12 -0
  125. package/dist/core/extensions/index.d.ts.map +1 -0
  126. package/dist/core/extensions/index.js +9 -0
  127. package/dist/core/extensions/index.js.map +1 -0
  128. package/dist/core/extensions/loader.d.ts +24 -0
  129. package/dist/core/extensions/loader.d.ts.map +1 -0
  130. package/dist/core/extensions/loader.js +494 -0
  131. package/dist/core/extensions/loader.js.map +1 -0
  132. package/dist/core/extensions/runner.d.ts +161 -0
  133. package/dist/core/extensions/runner.d.ts.map +1 -0
  134. package/dist/core/extensions/runner.js +842 -0
  135. package/dist/core/extensions/runner.js.map +1 -0
  136. package/dist/core/extensions/types.d.ts +1181 -0
  137. package/dist/core/extensions/types.d.ts.map +1 -0
  138. package/dist/core/extensions/types.js +45 -0
  139. package/dist/core/extensions/types.js.map +1 -0
  140. package/dist/core/extensions/wrapper.d.ts +20 -0
  141. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  142. package/dist/core/extensions/wrapper.js +22 -0
  143. package/dist/core/extensions/wrapper.js.map +1 -0
  144. package/dist/core/footer-data-provider.d.ts +54 -0
  145. package/dist/core/footer-data-provider.d.ts.map +1 -0
  146. package/dist/core/footer-data-provider.js +338 -0
  147. package/dist/core/footer-data-provider.js.map +1 -0
  148. package/dist/core/http-dispatcher.d.ts +21 -0
  149. package/dist/core/http-dispatcher.d.ts.map +1 -0
  150. package/dist/core/http-dispatcher.js +48 -0
  151. package/dist/core/http-dispatcher.js.map +1 -0
  152. package/dist/core/index.d.ts +12 -0
  153. package/dist/core/index.d.ts.map +1 -0
  154. package/dist/core/index.js +12 -0
  155. package/dist/core/index.js.map +1 -0
  156. package/dist/core/keybindings.d.ts +353 -0
  157. package/dist/core/keybindings.d.ts.map +1 -0
  158. package/dist/core/keybindings.js +295 -0
  159. package/dist/core/keybindings.js.map +1 -0
  160. package/dist/core/messages.d.ts +77 -0
  161. package/dist/core/messages.d.ts.map +1 -0
  162. package/dist/core/messages.js +123 -0
  163. package/dist/core/messages.js.map +1 -0
  164. package/dist/core/model-registry.d.ts +150 -0
  165. package/dist/core/model-registry.d.ts.map +1 -0
  166. package/dist/core/model-registry.js +789 -0
  167. package/dist/core/model-registry.js.map +1 -0
  168. package/dist/core/model-resolver.d.ts +110 -0
  169. package/dist/core/model-resolver.d.ts.map +1 -0
  170. package/dist/core/model-resolver.js +495 -0
  171. package/dist/core/model-resolver.js.map +1 -0
  172. package/dist/core/omk-control.d.ts +62 -0
  173. package/dist/core/omk-control.d.ts.map +1 -0
  174. package/dist/core/omk-control.js +190 -0
  175. package/dist/core/omk-control.js.map +1 -0
  176. package/dist/core/omk-subagent.d.ts +17 -0
  177. package/dist/core/omk-subagent.d.ts.map +1 -0
  178. package/dist/core/omk-subagent.js +704 -0
  179. package/dist/core/omk-subagent.js.map +1 -0
  180. package/dist/core/output-guard.d.ts +7 -0
  181. package/dist/core/output-guard.d.ts.map +1 -0
  182. package/dist/core/output-guard.js +89 -0
  183. package/dist/core/output-guard.js.map +1 -0
  184. package/dist/core/package-manager.d.ts +206 -0
  185. package/dist/core/package-manager.d.ts.map +1 -0
  186. package/dist/core/package-manager.js +2056 -0
  187. package/dist/core/package-manager.js.map +1 -0
  188. package/dist/core/prompt-templates.d.ts +52 -0
  189. package/dist/core/prompt-templates.d.ts.map +1 -0
  190. package/dist/core/prompt-templates.js +238 -0
  191. package/dist/core/prompt-templates.js.map +1 -0
  192. package/dist/core/provider-attribution.d.ts +4 -0
  193. package/dist/core/provider-attribution.d.ts.map +1 -0
  194. package/dist/core/provider-attribution.js +78 -0
  195. package/dist/core/provider-attribution.js.map +1 -0
  196. package/dist/core/provider-display-names.d.ts +2 -0
  197. package/dist/core/provider-display-names.d.ts.map +1 -0
  198. package/dist/core/provider-display-names.js +35 -0
  199. package/dist/core/provider-display-names.js.map +1 -0
  200. package/dist/core/resolve-config-value.d.ts +31 -0
  201. package/dist/core/resolve-config-value.d.ts.map +1 -0
  202. package/dist/core/resolve-config-value.js +249 -0
  203. package/dist/core/resolve-config-value.js.map +1 -0
  204. package/dist/core/resource-loader.d.ts +194 -0
  205. package/dist/core/resource-loader.d.ts.map +1 -0
  206. package/dist/core/resource-loader.js +740 -0
  207. package/dist/core/resource-loader.js.map +1 -0
  208. package/dist/core/runtime-defaults.d.ts +14 -0
  209. package/dist/core/runtime-defaults.d.ts.map +1 -0
  210. package/dist/core/runtime-defaults.js +15 -0
  211. package/dist/core/runtime-defaults.js.map +1 -0
  212. package/dist/core/sdk.d.ts +109 -0
  213. package/dist/core/sdk.d.ts.map +1 -0
  214. package/dist/core/sdk.js +270 -0
  215. package/dist/core/sdk.js.map +1 -0
  216. package/dist/core/session-cwd.d.ts +19 -0
  217. package/dist/core/session-cwd.d.ts.map +1 -0
  218. package/dist/core/session-cwd.js +38 -0
  219. package/dist/core/session-cwd.js.map +1 -0
  220. package/dist/core/session-manager.d.ts +332 -0
  221. package/dist/core/session-manager.d.ts.map +1 -0
  222. package/dist/core/session-manager.js +1218 -0
  223. package/dist/core/session-manager.js.map +1 -0
  224. package/dist/core/settings-manager.d.ts +273 -0
  225. package/dist/core/settings-manager.d.ts.map +1 -0
  226. package/dist/core/settings-manager.js +839 -0
  227. package/dist/core/settings-manager.js.map +1 -0
  228. package/dist/core/skills.d.ts +60 -0
  229. package/dist/core/skills.d.ts.map +1 -0
  230. package/dist/core/skills.js +387 -0
  231. package/dist/core/skills.js.map +1 -0
  232. package/dist/core/slash-commands.d.ts +26 -0
  233. package/dist/core/slash-commands.d.ts.map +1 -0
  234. package/dist/core/slash-commands.js +98 -0
  235. package/dist/core/slash-commands.js.map +1 -0
  236. package/dist/core/source-info.d.ts +18 -0
  237. package/dist/core/source-info.d.ts.map +1 -0
  238. package/dist/core/source-info.js +19 -0
  239. package/dist/core/source-info.js.map +1 -0
  240. package/dist/core/system-prompt.d.ts +28 -0
  241. package/dist/core/system-prompt.d.ts.map +1 -0
  242. package/dist/core/system-prompt.js +120 -0
  243. package/dist/core/system-prompt.js.map +1 -0
  244. package/dist/core/telemetry.d.ts +3 -0
  245. package/dist/core/telemetry.d.ts.map +1 -0
  246. package/dist/core/telemetry.js +10 -0
  247. package/dist/core/telemetry.js.map +1 -0
  248. package/dist/core/timings.d.ts +4 -0
  249. package/dist/core/timings.d.ts.map +1 -0
  250. package/dist/core/timings.js +32 -0
  251. package/dist/core/timings.js.map +1 -0
  252. package/dist/core/tools/bash.d.ts +68 -0
  253. package/dist/core/tools/bash.d.ts.map +1 -0
  254. package/dist/core/tools/bash.js +337 -0
  255. package/dist/core/tools/bash.js.map +1 -0
  256. package/dist/core/tools/edit-diff.d.ts +87 -0
  257. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  258. package/dist/core/tools/edit-diff.js +345 -0
  259. package/dist/core/tools/edit-diff.js.map +1 -0
  260. package/dist/core/tools/edit.d.ts +51 -0
  261. package/dist/core/tools/edit.d.ts.map +1 -0
  262. package/dist/core/tools/edit.js +284 -0
  263. package/dist/core/tools/edit.js.map +1 -0
  264. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  265. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  266. package/dist/core/tools/file-mutation-queue.js +52 -0
  267. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  268. package/dist/core/tools/find.d.ts +35 -0
  269. package/dist/core/tools/find.d.ts.map +1 -0
  270. package/dist/core/tools/find.js +297 -0
  271. package/dist/core/tools/find.js.map +1 -0
  272. package/dist/core/tools/grep.d.ts +37 -0
  273. package/dist/core/tools/grep.d.ts.map +1 -0
  274. package/dist/core/tools/grep.js +304 -0
  275. package/dist/core/tools/grep.js.map +1 -0
  276. package/dist/core/tools/index.d.ts +40 -0
  277. package/dist/core/tools/index.d.ts.map +1 -0
  278. package/dist/core/tools/index.js +112 -0
  279. package/dist/core/tools/index.js.map +1 -0
  280. package/dist/core/tools/ls.d.ts +37 -0
  281. package/dist/core/tools/ls.d.ts.map +1 -0
  282. package/dist/core/tools/ls.js +167 -0
  283. package/dist/core/tools/ls.js.map +1 -0
  284. package/dist/core/tools/output-accumulator.d.ts +52 -0
  285. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  286. package/dist/core/tools/output-accumulator.js +184 -0
  287. package/dist/core/tools/output-accumulator.js.map +1 -0
  288. package/dist/core/tools/path-utils.d.ts +10 -0
  289. package/dist/core/tools/path-utils.d.ts.map +1 -0
  290. package/dist/core/tools/path-utils.js +99 -0
  291. package/dist/core/tools/path-utils.js.map +1 -0
  292. package/dist/core/tools/read.d.ts +35 -0
  293. package/dist/core/tools/read.d.ts.map +1 -0
  294. package/dist/core/tools/read.js +289 -0
  295. package/dist/core/tools/read.js.map +1 -0
  296. package/dist/core/tools/render-utils.d.ts +24 -0
  297. package/dist/core/tools/render-utils.d.ts.map +1 -0
  298. package/dist/core/tools/render-utils.js +65 -0
  299. package/dist/core/tools/render-utils.js.map +1 -0
  300. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  301. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  302. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  303. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  304. package/dist/core/tools/truncate.d.ts +70 -0
  305. package/dist/core/tools/truncate.d.ts.map +1 -0
  306. package/dist/core/tools/truncate.js +215 -0
  307. package/dist/core/tools/truncate.js.map +1 -0
  308. package/dist/core/tools/write.d.ts +26 -0
  309. package/dist/core/tools/write.d.ts.map +1 -0
  310. package/dist/core/tools/write.js +197 -0
  311. package/dist/core/tools/write.js.map +1 -0
  312. package/dist/index.d.ts +32 -0
  313. package/dist/index.d.ts.map +1 -0
  314. package/dist/index.js +45 -0
  315. package/dist/index.js.map +1 -0
  316. package/dist/main.d.ts +12 -0
  317. package/dist/main.d.ts.map +1 -0
  318. package/dist/main.js +673 -0
  319. package/dist/main.js.map +1 -0
  320. package/dist/migrations.d.ts +35 -0
  321. package/dist/migrations.d.ts.map +1 -0
  322. package/dist/migrations.js +401 -0
  323. package/dist/migrations.js.map +1 -0
  324. package/dist/modes/index.d.ts +9 -0
  325. package/dist/modes/index.d.ts.map +1 -0
  326. package/dist/modes/index.js +8 -0
  327. package/dist/modes/index.js.map +1 -0
  328. package/dist/modes/interactive/assets/clankolas.png +0 -0
  329. package/dist/modes/interactive/cockpit-scroll.d.ts +54 -0
  330. package/dist/modes/interactive/cockpit-scroll.d.ts.map +1 -0
  331. package/dist/modes/interactive/cockpit-scroll.js +133 -0
  332. package/dist/modes/interactive/cockpit-scroll.js.map +1 -0
  333. package/dist/modes/interactive/components/armin.d.ts +34 -0
  334. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  335. package/dist/modes/interactive/components/armin.js +333 -0
  336. package/dist/modes/interactive/components/armin.js.map +1 -0
  337. package/dist/modes/interactive/components/assistant-message.d.ts +20 -0
  338. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  339. package/dist/modes/interactive/components/assistant-message.js +121 -0
  340. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  341. package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
  342. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  343. package/dist/modes/interactive/components/bash-execution.js +175 -0
  344. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  345. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  346. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  347. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  348. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  349. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  350. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  351. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  352. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  353. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  354. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  355. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  356. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  357. package/dist/modes/interactive/components/config-selector.d.ts +71 -0
  358. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  359. package/dist/modes/interactive/components/config-selector.js +506 -0
  360. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  361. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  362. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  363. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  364. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  365. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  366. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  367. package/dist/modes/interactive/components/custom-editor.js +70 -0
  368. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  369. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  370. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  371. package/dist/modes/interactive/components/custom-message.js +79 -0
  372. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  373. package/dist/modes/interactive/components/diff.d.ts +12 -0
  374. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  375. package/dist/modes/interactive/components/diff.js +133 -0
  376. package/dist/modes/interactive/components/diff.js.map +1 -0
  377. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  378. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  379. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  380. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  381. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  382. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  383. package/dist/modes/interactive/components/earendil-announcement.js +42 -0
  384. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  385. package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
  386. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  387. package/dist/modes/interactive/components/extension-editor.js +119 -0
  388. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  389. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  390. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  391. package/dist/modes/interactive/components/extension-input.js +61 -0
  392. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  393. package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
  394. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  395. package/dist/modes/interactive/components/extension-selector.js +83 -0
  396. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  397. package/dist/modes/interactive/components/footer.d.ts +35 -0
  398. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  399. package/dist/modes/interactive/components/footer.js +223 -0
  400. package/dist/modes/interactive/components/footer.js.map +1 -0
  401. package/dist/modes/interactive/components/index.d.ts +36 -0
  402. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  403. package/dist/modes/interactive/components/index.js +37 -0
  404. package/dist/modes/interactive/components/index.js.map +1 -0
  405. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  406. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  407. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  408. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  409. package/dist/modes/interactive/components/login-dialog.d.ts +51 -0
  410. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  411. package/dist/modes/interactive/components/login-dialog.js +174 -0
  412. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  413. package/dist/modes/interactive/components/model-selector.d.ts +69 -0
  414. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  415. package/dist/modes/interactive/components/model-selector.js +411 -0
  416. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  417. package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
  418. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  419. package/dist/modes/interactive/components/oauth-selector.js +165 -0
  420. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  421. package/dist/modes/interactive/components/omk-brand-surface.d.ts +58 -0
  422. package/dist/modes/interactive/components/omk-brand-surface.d.ts.map +1 -0
  423. package/dist/modes/interactive/components/omk-brand-surface.js +330 -0
  424. package/dist/modes/interactive/components/omk-brand-surface.js.map +1 -0
  425. package/dist/modes/interactive/components/omk-brand.d.ts +10 -0
  426. package/dist/modes/interactive/components/omk-brand.d.ts.map +1 -0
  427. package/dist/modes/interactive/components/omk-brand.js +12 -0
  428. package/dist/modes/interactive/components/omk-brand.js.map +1 -0
  429. package/dist/modes/interactive/components/omk-control-dashboard.d.ts +36 -0
  430. package/dist/modes/interactive/components/omk-control-dashboard.d.ts.map +1 -0
  431. package/dist/modes/interactive/components/omk-control-dashboard.js +348 -0
  432. package/dist/modes/interactive/components/omk-control-dashboard.js.map +1 -0
  433. package/dist/modes/interactive/components/omk-control-layout.d.ts +34 -0
  434. package/dist/modes/interactive/components/omk-control-layout.d.ts.map +1 -0
  435. package/dist/modes/interactive/components/omk-control-layout.js +85 -0
  436. package/dist/modes/interactive/components/omk-control-layout.js.map +1 -0
  437. package/dist/modes/interactive/components/omk-history-panel.d.ts +27 -0
  438. package/dist/modes/interactive/components/omk-history-panel.d.ts.map +1 -0
  439. package/dist/modes/interactive/components/omk-history-panel.js +162 -0
  440. package/dist/modes/interactive/components/omk-history-panel.js.map +1 -0
  441. package/dist/modes/interactive/components/omk-neon-hud.d.ts +19 -0
  442. package/dist/modes/interactive/components/omk-neon-hud.d.ts.map +1 -0
  443. package/dist/modes/interactive/components/omk-neon-hud.js +75 -0
  444. package/dist/modes/interactive/components/omk-neon-hud.js.map +1 -0
  445. package/dist/modes/interactive/components/omk-tabbed-panel.d.ts +30 -0
  446. package/dist/modes/interactive/components/omk-tabbed-panel.d.ts.map +1 -0
  447. package/dist/modes/interactive/components/omk-tabbed-panel.js +99 -0
  448. package/dist/modes/interactive/components/omk-tabbed-panel.js.map +1 -0
  449. package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
  450. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  451. package/dist/modes/interactive/components/scoped-models-selector.js +290 -0
  452. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  453. package/dist/modes/interactive/components/scrollable-transcript.d.ts +20 -0
  454. package/dist/modes/interactive/components/scrollable-transcript.d.ts.map +1 -0
  455. package/dist/modes/interactive/components/scrollable-transcript.js +25 -0
  456. package/dist/modes/interactive/components/scrollable-transcript.js.map +1 -0
  457. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  458. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  459. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  460. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  461. package/dist/modes/interactive/components/session-selector.d.ts +96 -0
  462. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  463. package/dist/modes/interactive/components/session-selector.js +861 -0
  464. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  465. package/dist/modes/interactive/components/settings-selector.d.ts +69 -0
  466. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  467. package/dist/modes/interactive/components/settings-selector.js +391 -0
  468. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  469. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  470. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  471. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  472. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  473. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  474. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  475. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  476. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  477. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  478. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  479. package/dist/modes/interactive/components/theme-selector.js +50 -0
  480. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  481. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  482. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  483. package/dist/modes/interactive/components/thinking-selector.js +52 -0
  484. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  485. package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
  486. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  487. package/dist/modes/interactive/components/tool-execution.js +317 -0
  488. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  489. package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
  490. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  491. package/dist/modes/interactive/components/tree-selector.js +1093 -0
  492. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  493. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  494. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  495. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  496. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  497. package/dist/modes/interactive/components/user-message.d.ts +10 -0
  498. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  499. package/dist/modes/interactive/components/user-message.js +29 -0
  500. package/dist/modes/interactive/components/user-message.js.map +1 -0
  501. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  502. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  503. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  504. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  505. package/dist/modes/interactive/interactive-mode.d.ts +422 -0
  506. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  507. package/dist/modes/interactive/interactive-mode.js +5388 -0
  508. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  509. package/dist/modes/interactive/theme/dark.json +87 -0
  510. package/dist/modes/interactive/theme/light.json +86 -0
  511. package/dist/modes/interactive/theme/omk-control.json +92 -0
  512. package/dist/modes/interactive/theme/omk-rust.json +94 -0
  513. package/dist/modes/interactive/theme/theme-schema.json +340 -0
  514. package/dist/modes/interactive/theme/theme.d.ts +102 -0
  515. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  516. package/dist/modes/interactive/theme/theme.js +1093 -0
  517. package/dist/modes/interactive/theme/theme.js.map +1 -0
  518. package/dist/modes/print-mode.d.ts +28 -0
  519. package/dist/modes/print-mode.d.ts.map +1 -0
  520. package/dist/modes/print-mode.js +132 -0
  521. package/dist/modes/print-mode.js.map +1 -0
  522. package/dist/modes/rpc/jsonl.d.ts +17 -0
  523. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  524. package/dist/modes/rpc/jsonl.js +49 -0
  525. package/dist/modes/rpc/jsonl.js.map +1 -0
  526. package/dist/modes/rpc/rpc-client.d.ts +227 -0
  527. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  528. package/dist/modes/rpc/rpc-client.js +467 -0
  529. package/dist/modes/rpc/rpc-client.js.map +1 -0
  530. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  531. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  532. package/dist/modes/rpc/rpc-mode.js +616 -0
  533. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  534. package/dist/modes/rpc/rpc-types.d.ts +420 -0
  535. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  536. package/dist/modes/rpc/rpc-types.js +8 -0
  537. package/dist/modes/rpc/rpc-types.js.map +1 -0
  538. package/dist/omk-env.d.ts +2 -0
  539. package/dist/omk-env.d.ts.map +1 -0
  540. package/dist/omk-env.js +3 -0
  541. package/dist/omk-env.js.map +1 -0
  542. package/dist/omk.d.ts +4 -0
  543. package/dist/omk.d.ts.map +1 -0
  544. package/dist/omk.js +4 -0
  545. package/dist/omk.js.map +1 -0
  546. package/dist/package-manager-cli.d.ts +4 -0
  547. package/dist/package-manager-cli.d.ts.map +1 -0
  548. package/dist/package-manager-cli.js +528 -0
  549. package/dist/package-manager-cli.js.map +1 -0
  550. package/dist/package.json +97 -0
  551. package/dist/utils/ansi.d.ts +2 -0
  552. package/dist/utils/ansi.d.ts.map +1 -0
  553. package/dist/utils/ansi.js +52 -0
  554. package/dist/utils/ansi.js.map +1 -0
  555. package/dist/utils/changelog.d.ts +21 -0
  556. package/dist/utils/changelog.d.ts.map +1 -0
  557. package/dist/utils/changelog.js +87 -0
  558. package/dist/utils/changelog.js.map +1 -0
  559. package/dist/utils/child-process.d.ts +15 -0
  560. package/dist/utils/child-process.d.ts.map +1 -0
  561. package/dist/utils/child-process.js +88 -0
  562. package/dist/utils/child-process.js.map +1 -0
  563. package/dist/utils/clipboard-image.d.ts +11 -0
  564. package/dist/utils/clipboard-image.d.ts.map +1 -0
  565. package/dist/utils/clipboard-image.js +249 -0
  566. package/dist/utils/clipboard-image.js.map +1 -0
  567. package/dist/utils/clipboard-native.d.ts +10 -0
  568. package/dist/utils/clipboard-native.d.ts.map +1 -0
  569. package/dist/utils/clipboard-native.js +20 -0
  570. package/dist/utils/clipboard-native.js.map +1 -0
  571. package/dist/utils/clipboard.d.ts +2 -0
  572. package/dist/utils/clipboard.d.ts.map +1 -0
  573. package/dist/utils/clipboard.js +117 -0
  574. package/dist/utils/clipboard.js.map +1 -0
  575. package/dist/utils/deprecation.d.ts +4 -0
  576. package/dist/utils/deprecation.d.ts.map +1 -0
  577. package/dist/utils/deprecation.js +13 -0
  578. package/dist/utils/deprecation.js.map +1 -0
  579. package/dist/utils/exif-orientation.d.ts +5 -0
  580. package/dist/utils/exif-orientation.d.ts.map +1 -0
  581. package/dist/utils/exif-orientation.js +158 -0
  582. package/dist/utils/exif-orientation.js.map +1 -0
  583. package/dist/utils/frontmatter.d.ts +8 -0
  584. package/dist/utils/frontmatter.d.ts.map +1 -0
  585. package/dist/utils/frontmatter.js +26 -0
  586. package/dist/utils/frontmatter.js.map +1 -0
  587. package/dist/utils/fs-watch.d.ts +5 -0
  588. package/dist/utils/fs-watch.d.ts.map +1 -0
  589. package/dist/utils/fs-watch.js +25 -0
  590. package/dist/utils/fs-watch.js.map +1 -0
  591. package/dist/utils/git.d.ts +26 -0
  592. package/dist/utils/git.d.ts.map +1 -0
  593. package/dist/utils/git.js +195 -0
  594. package/dist/utils/git.js.map +1 -0
  595. package/dist/utils/html.d.ts +7 -0
  596. package/dist/utils/html.d.ts.map +1 -0
  597. package/dist/utils/html.js +40 -0
  598. package/dist/utils/html.js.map +1 -0
  599. package/dist/utils/image-convert.d.ts +9 -0
  600. package/dist/utils/image-convert.d.ts.map +1 -0
  601. package/dist/utils/image-convert.js +39 -0
  602. package/dist/utils/image-convert.js.map +1 -0
  603. package/dist/utils/image-resize-core.d.ts +30 -0
  604. package/dist/utils/image-resize-core.d.ts.map +1 -0
  605. package/dist/utils/image-resize-core.js +124 -0
  606. package/dist/utils/image-resize-core.js.map +1 -0
  607. package/dist/utils/image-resize-worker.d.ts +2 -0
  608. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  609. package/dist/utils/image-resize-worker.js +31 -0
  610. package/dist/utils/image-resize-worker.js.map +1 -0
  611. package/dist/utils/image-resize.d.ts +16 -0
  612. package/dist/utils/image-resize.d.ts.map +1 -0
  613. package/dist/utils/image-resize.js +97 -0
  614. package/dist/utils/image-resize.js.map +1 -0
  615. package/dist/utils/json.d.ts +3 -0
  616. package/dist/utils/json.d.ts.map +1 -0
  617. package/dist/utils/json.js +7 -0
  618. package/dist/utils/json.js.map +1 -0
  619. package/dist/utils/mime.d.ts +3 -0
  620. package/dist/utils/mime.d.ts.map +1 -0
  621. package/dist/utils/mime.js +69 -0
  622. package/dist/utils/mime.js.map +1 -0
  623. package/dist/utils/open-browser.d.ts +9 -0
  624. package/dist/utils/open-browser.d.ts.map +1 -0
  625. package/dist/utils/open-browser.js +22 -0
  626. package/dist/utils/open-browser.js.map +1 -0
  627. package/dist/utils/paths.d.ts +31 -0
  628. package/dist/utils/paths.d.ts.map +1 -0
  629. package/dist/utils/paths.js +92 -0
  630. package/dist/utils/paths.js.map +1 -0
  631. package/dist/utils/photon.d.ts +21 -0
  632. package/dist/utils/photon.d.ts.map +1 -0
  633. package/dist/utils/photon.js +121 -0
  634. package/dist/utils/photon.js.map +1 -0
  635. package/dist/utils/pi-user-agent.d.ts +2 -0
  636. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  637. package/dist/utils/pi-user-agent.js +6 -0
  638. package/dist/utils/pi-user-agent.js.map +1 -0
  639. package/dist/utils/shell.d.ts +30 -0
  640. package/dist/utils/shell.d.ts.map +1 -0
  641. package/dist/utils/shell.js +195 -0
  642. package/dist/utils/shell.js.map +1 -0
  643. package/dist/utils/sleep.d.ts +5 -0
  644. package/dist/utils/sleep.d.ts.map +1 -0
  645. package/dist/utils/sleep.js +17 -0
  646. package/dist/utils/sleep.js.map +1 -0
  647. package/dist/utils/syntax-highlight.d.ts +12 -0
  648. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  649. package/dist/utils/syntax-highlight.js +118 -0
  650. package/dist/utils/syntax-highlight.js.map +1 -0
  651. package/dist/utils/tools-manager.d.ts +3 -0
  652. package/dist/utils/tools-manager.d.ts.map +1 -0
  653. package/dist/utils/tools-manager.js +325 -0
  654. package/dist/utils/tools-manager.js.map +1 -0
  655. package/dist/utils/version-check.d.ts +15 -0
  656. package/dist/utils/version-check.d.ts.map +1 -0
  657. package/dist/utils/version-check.js +85 -0
  658. package/dist/utils/version-check.js.map +1 -0
  659. package/dist/utils/windows-self-update.d.ts +3 -0
  660. package/dist/utils/windows-self-update.d.ts.map +1 -0
  661. package/dist/utils/windows-self-update.js +77 -0
  662. package/dist/utils/windows-self-update.js.map +1 -0
  663. package/docs/compaction.md +394 -0
  664. package/docs/containerization.md +111 -0
  665. package/docs/custom-provider.md +736 -0
  666. package/docs/development.md +71 -0
  667. package/docs/docs.json +152 -0
  668. package/docs/extensions.md +2627 -0
  669. package/docs/images/doom-extension.png +0 -0
  670. package/docs/images/exy.png +0 -0
  671. package/docs/images/interactive-mode.png +0 -0
  672. package/docs/images/tree-view.png +0 -0
  673. package/docs/index.md +81 -0
  674. package/docs/json.md +82 -0
  675. package/docs/keybindings.md +197 -0
  676. package/docs/models.md +493 -0
  677. package/docs/packages.md +226 -0
  678. package/docs/prompt-templates.md +88 -0
  679. package/docs/providers.md +256 -0
  680. package/docs/quickstart.md +165 -0
  681. package/docs/rpc.md +1408 -0
  682. package/docs/sdk.md +1137 -0
  683. package/docs/session-format.md +412 -0
  684. package/docs/sessions.md +145 -0
  685. package/docs/settings.md +281 -0
  686. package/docs/shell-aliases.md +13 -0
  687. package/docs/skills.md +231 -0
  688. package/docs/terminal-setup.md +114 -0
  689. package/docs/termux.md +127 -0
  690. package/docs/themes.md +297 -0
  691. package/docs/tmux.md +61 -0
  692. package/docs/tui.md +927 -0
  693. package/docs/usage.md +288 -0
  694. package/docs/windows.md +17 -0
  695. package/examples/README.md +25 -0
  696. package/examples/extensions/README.md +210 -0
  697. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  698. package/examples/extensions/bash-spawn-hook.ts +30 -0
  699. package/examples/extensions/bookmark.ts +50 -0
  700. package/examples/extensions/border-status-editor.ts +150 -0
  701. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  702. package/examples/extensions/claude-rules.ts +86 -0
  703. package/examples/extensions/commands.ts +72 -0
  704. package/examples/extensions/confirm-destructive.ts +59 -0
  705. package/examples/extensions/custom-compaction.ts +127 -0
  706. package/examples/extensions/custom-footer.ts +64 -0
  707. package/examples/extensions/custom-header.ts +73 -0
  708. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  709. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  710. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  711. package/examples/extensions/custom-provider-gitlab-duo/index.ts +400 -0
  712. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  713. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  714. package/examples/extensions/dirty-repo-guard.ts +56 -0
  715. package/examples/extensions/doom-overlay/README.md +46 -0
  716. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  717. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  718. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  719. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  720. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  721. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  722. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  723. package/examples/extensions/doom-overlay/index.ts +74 -0
  724. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  725. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  726. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  727. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  728. package/examples/extensions/dynamic-resources/index.ts +15 -0
  729. package/examples/extensions/dynamic-tools.ts +74 -0
  730. package/examples/extensions/event-bus.ts +43 -0
  731. package/examples/extensions/file-trigger.ts +41 -0
  732. package/examples/extensions/git-checkpoint.ts +53 -0
  733. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  734. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  735. package/examples/extensions/gondolin/index.ts +531 -0
  736. package/examples/extensions/gondolin/package-lock.json +185 -0
  737. package/examples/extensions/gondolin/package.json +19 -0
  738. package/examples/extensions/handoff.ts +191 -0
  739. package/examples/extensions/hello.ts +26 -0
  740. package/examples/extensions/hidden-thinking-label.ts +53 -0
  741. package/examples/extensions/inline-bash.ts +94 -0
  742. package/examples/extensions/input-transform-streaming.ts +39 -0
  743. package/examples/extensions/input-transform.ts +43 -0
  744. package/examples/extensions/interactive-shell.ts +196 -0
  745. package/examples/extensions/mac-system-theme.ts +47 -0
  746. package/examples/extensions/message-renderer.ts +59 -0
  747. package/examples/extensions/minimal-mode.ts +426 -0
  748. package/examples/extensions/modal-editor.ts +85 -0
  749. package/examples/extensions/model-status.ts +31 -0
  750. package/examples/extensions/notify.ts +55 -0
  751. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  752. package/examples/extensions/overlay-test.ts +153 -0
  753. package/examples/extensions/permission-gate.ts +34 -0
  754. package/examples/extensions/pirate.ts +47 -0
  755. package/examples/extensions/plan-mode/README.md +65 -0
  756. package/examples/extensions/plan-mode/index.ts +340 -0
  757. package/examples/extensions/plan-mode/utils.ts +168 -0
  758. package/examples/extensions/preset.ts +430 -0
  759. package/examples/extensions/prompt-customizer.ts +97 -0
  760. package/examples/extensions/protected-paths.ts +30 -0
  761. package/examples/extensions/provider-payload.ts +18 -0
  762. package/examples/extensions/qna.ts +122 -0
  763. package/examples/extensions/question.ts +264 -0
  764. package/examples/extensions/questionnaire.ts +427 -0
  765. package/examples/extensions/rainbow-editor.ts +88 -0
  766. package/examples/extensions/reload-runtime.ts +37 -0
  767. package/examples/extensions/rpc-demo.ts +118 -0
  768. package/examples/extensions/sandbox/index.ts +321 -0
  769. package/examples/extensions/sandbox/package-lock.json +92 -0
  770. package/examples/extensions/sandbox/package.json +19 -0
  771. package/examples/extensions/send-user-message.ts +97 -0
  772. package/examples/extensions/session-name.ts +27 -0
  773. package/examples/extensions/shutdown-command.ts +63 -0
  774. package/examples/extensions/snake.ts +343 -0
  775. package/examples/extensions/space-invaders.ts +560 -0
  776. package/examples/extensions/ssh.ts +220 -0
  777. package/examples/extensions/status-line.ts +32 -0
  778. package/examples/extensions/structured-output.ts +65 -0
  779. package/examples/extensions/subagent/README.md +175 -0
  780. package/examples/extensions/subagent/agents/planner.md +37 -0
  781. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  782. package/examples/extensions/subagent/agents/scout.md +50 -0
  783. package/examples/extensions/subagent/agents/worker.md +24 -0
  784. package/examples/extensions/subagent/agents.ts +126 -0
  785. package/examples/extensions/subagent/index.ts +1009 -0
  786. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  787. package/examples/extensions/subagent/prompts/implement.md +10 -0
  788. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  789. package/examples/extensions/summarize.ts +206 -0
  790. package/examples/extensions/system-prompt-header.ts +17 -0
  791. package/examples/extensions/tic-tac-toe.ts +1008 -0
  792. package/examples/extensions/timed-confirm.ts +70 -0
  793. package/examples/extensions/titlebar-spinner.ts +58 -0
  794. package/examples/extensions/todo.ts +297 -0
  795. package/examples/extensions/tool-override.ts +144 -0
  796. package/examples/extensions/tools.ts +146 -0
  797. package/examples/extensions/trigger-compact.ts +50 -0
  798. package/examples/extensions/truncated-tool.ts +195 -0
  799. package/examples/extensions/widget-placement.ts +9 -0
  800. package/examples/extensions/with-deps/index.ts +32 -0
  801. package/examples/extensions/with-deps/package-lock.json +31 -0
  802. package/examples/extensions/with-deps/package.json +22 -0
  803. package/examples/extensions/working-indicator.ts +123 -0
  804. package/examples/extensions/working-message-test.ts +25 -0
  805. package/examples/rpc-extension-ui.ts +632 -0
  806. package/examples/sdk/01-minimal.ts +26 -0
  807. package/examples/sdk/02-custom-model.ts +53 -0
  808. package/examples/sdk/03-custom-prompt.ts +75 -0
  809. package/examples/sdk/04-skills.ts +55 -0
  810. package/examples/sdk/05-tools.ts +48 -0
  811. package/examples/sdk/06-extensions.ts +99 -0
  812. package/examples/sdk/07-context-files.ts +47 -0
  813. package/examples/sdk/08-prompt-templates.ts +51 -0
  814. package/examples/sdk/09-api-keys-and-oauth.ts +52 -0
  815. package/examples/sdk/10-settings.ts +53 -0
  816. package/examples/sdk/11-sessions.ts +52 -0
  817. package/examples/sdk/12-full-control.ts +77 -0
  818. package/examples/sdk/13-session-runtime.ts +67 -0
  819. package/examples/sdk/README.md +144 -0
  820. package/npm-shrinkwrap.json +512 -0
  821. package/package.json +97 -191
  822. package/AGENTS.md +0 -550
  823. package/CLAUDE.md +0 -8
  824. package/DESIGN.md +0 -334
  825. package/GEMINI.md +0 -8
  826. package/LICENSE +0 -21
  827. package/MATURITY.md +0 -81
  828. package/ROADMAP.md +0 -138
  829. package/SECURITY.md +0 -83
  830. package/WORKER_MANIFEST.md +0 -35
  831. package/dist/adapters/commandcode/commandcode-cli-adapter.d.ts +0 -10
  832. package/dist/adapters/commandcode/commandcode-cli-adapter.js +0 -57
  833. package/dist/adapters/kimi/ascii-art.d.ts +0 -1
  834. package/dist/adapters/kimi/ascii-art.js +0 -23
  835. package/dist/adapters/kimi/banner.d.ts +0 -53
  836. package/dist/adapters/kimi/banner.js +0 -284
  837. package/dist/adapters/kimi/bug-filter.d.ts +0 -15
  838. package/dist/adapters/kimi/bug-filter.js +0 -150
  839. package/dist/adapters/kimi/capability.d.ts +0 -25
  840. package/dist/adapters/kimi/capability.js +0 -68
  841. package/dist/adapters/kimi/continue-prompt-guard.d.ts +0 -20
  842. package/dist/adapters/kimi/continue-prompt-guard.js +0 -70
  843. package/dist/adapters/kimi/isolated-home.d.ts +0 -21
  844. package/dist/adapters/kimi/isolated-home.js +0 -270
  845. package/dist/adapters/kimi/runner.d.ts +0 -71
  846. package/dist/adapters/kimi/runner.js +0 -1084
  847. package/dist/adapters/kimi/simple-art.d.ts +0 -1
  848. package/dist/adapters/kimi/simple-art.js +0 -1
  849. package/dist/adapters/kimi/statusline.d.ts +0 -26
  850. package/dist/adapters/kimi/statusline.js +0 -142
  851. package/dist/adapters/kimi/usage.d.ts +0 -52
  852. package/dist/adapters/kimi/usage.js +0 -481
  853. package/dist/adapters/kimi/wire-client.d.ts +0 -142
  854. package/dist/adapters/kimi/wire-client.js +0 -725
  855. package/dist/adapters/kimi/wire-protocol-types.d.ts +0 -549
  856. package/dist/adapters/kimi/wire-protocol-types.js +0 -59
  857. package/dist/adapters/opencode/opencode-cli-adapter.d.ts +0 -9
  858. package/dist/adapters/opencode/opencode-cli-adapter.js +0 -43
  859. package/dist/awareness/classifiers/browser-console-classifier.d.ts +0 -3
  860. package/dist/awareness/classifiers/browser-console-classifier.js +0 -47
  861. package/dist/awareness/classifiers/evidence-gap-classifier.d.ts +0 -3
  862. package/dist/awareness/classifiers/evidence-gap-classifier.js +0 -31
  863. package/dist/awareness/classifiers/stalled-run-classifier.d.ts +0 -2
  864. package/dist/awareness/classifiers/stalled-run-classifier.js +0 -24
  865. package/dist/awareness/notice-store.d.ts +0 -6
  866. package/dist/awareness/notice-store.js +0 -91
  867. package/dist/awareness/notice.d.ts +0 -17
  868. package/dist/awareness/notice.js +0 -1
  869. package/dist/awareness/noticer-engine.d.ts +0 -42
  870. package/dist/awareness/noticer-engine.js +0 -63
  871. package/dist/awareness/router.d.ts +0 -6
  872. package/dist/awareness/router.js +0 -46
  873. package/dist/benchmark/contracts.d.ts +0 -116
  874. package/dist/benchmark/contracts.js +0 -6
  875. package/dist/benchmark/fixtures.d.ts +0 -11
  876. package/dist/benchmark/fixtures.js +0 -124
  877. package/dist/benchmark/harness.d.ts +0 -13
  878. package/dist/benchmark/harness.js +0 -191
  879. package/dist/benchmark/shadow-mode.d.ts +0 -17
  880. package/dist/benchmark/shadow-mode.js +0 -95
  881. package/dist/brand/matrix-rain.d.ts +0 -15
  882. package/dist/brand/matrix-rain.js +0 -132
  883. package/dist/brand/night-city.theme.json +0 -80
  884. package/dist/brand/omk-matrix-art.d.ts +0 -1
  885. package/dist/brand/omk-matrix-art.js +0 -10
  886. package/dist/brand/omk-simple-art.d.ts +0 -7
  887. package/dist/brand/omk-simple-art.js +0 -13
  888. package/dist/brand/palette.d.ts +0 -90
  889. package/dist/brand/palette.js +0 -129
  890. package/dist/brand/rust-forge.theme.json +0 -216
  891. package/dist/brand/theme-compiled.d.ts +0 -61
  892. package/dist/brand/theme-compiled.js +0 -241
  893. package/dist/brand/theme.d.ts +0 -41
  894. package/dist/brand/theme.js +0 -275
  895. package/dist/browser/browser-feedback.d.ts +0 -10
  896. package/dist/browser/browser-feedback.js +0 -84
  897. package/dist/browser/browser-observer.d.ts +0 -21
  898. package/dist/browser/browser-observer.js +0 -159
  899. package/dist/browser/browser-session.d.ts +0 -26
  900. package/dist/browser/browser-session.js +0 -63
  901. package/dist/cli/command-registry.d.ts +0 -2
  902. package/dist/cli/command-registry.js +0 -20
  903. package/dist/cli/input/argv-parser.d.ts +0 -16
  904. package/dist/cli/input/argv-parser.js +0 -50
  905. package/dist/cli/input/command-envelope.d.ts +0 -16
  906. package/dist/cli/input/command-envelope.js +0 -64
  907. package/dist/cli/input/config-loader.d.ts +0 -16
  908. package/dist/cli/input/config-loader.js +0 -48
  909. package/dist/cli/input/index.d.ts +0 -8
  910. package/dist/cli/input/index.js +0 -8
  911. package/dist/cli/input/input-resolver.d.ts +0 -13
  912. package/dist/cli/input/input-resolver.js +0 -50
  913. package/dist/cli/input/validator.d.ts +0 -10
  914. package/dist/cli/input/validator.js +0 -37
  915. package/dist/cli/main.d.ts +0 -4
  916. package/dist/cli/main.js +0 -34
  917. package/dist/cli/output/error-renderer.d.ts +0 -10
  918. package/dist/cli/output/error-renderer.js +0 -68
  919. package/dist/cli/output/hash.d.ts +0 -1
  920. package/dist/cli/output/hash.js +0 -10
  921. package/dist/cli/output/index.d.ts +0 -9
  922. package/dist/cli/output/index.js +0 -9
  923. package/dist/cli/output/json-renderer.d.ts +0 -7
  924. package/dist/cli/output/json-renderer.js +0 -35
  925. package/dist/cli/output/markdown-renderer.d.ts +0 -5
  926. package/dist/cli/output/markdown-renderer.js +0 -86
  927. package/dist/cli/output/nlp-renderer.d.ts +0 -7
  928. package/dist/cli/output/nlp-renderer.js +0 -96
  929. package/dist/cli/output/output-router.d.ts +0 -5
  930. package/dist/cli/output/output-router.js +0 -33
  931. package/dist/cli/register-awareness-commands.d.ts +0 -2
  932. package/dist/cli/register-awareness-commands.js +0 -133
  933. package/dist/cli/register-basic-commands.d.ts +0 -2
  934. package/dist/cli/register-basic-commands.js +0 -488
  935. package/dist/cli/register-integration-commands.d.ts +0 -2
  936. package/dist/cli/register-integration-commands.js +0 -59
  937. package/dist/cli/register-mcp-dag-cron-screenshot-commands.d.ts +0 -2
  938. package/dist/cli/register-mcp-dag-cron-screenshot-commands.js +0 -275
  939. package/dist/cli/register-openai-codex-commands.d.ts +0 -2
  940. package/dist/cli/register-openai-codex-commands.js +0 -55
  941. package/dist/cli/register-provider-commands.d.ts +0 -2
  942. package/dist/cli/register-provider-commands.js +0 -244
  943. package/dist/cli/register-spec-agent-goal-commands.d.ts +0 -2
  944. package/dist/cli/register-spec-agent-goal-commands.js +0 -486
  945. package/dist/cli/register-tool-commands.d.ts +0 -2
  946. package/dist/cli/register-tool-commands.js +0 -202
  947. package/dist/cli/register-workflow-commands.d.ts +0 -2
  948. package/dist/cli/register-workflow-commands.js +0 -158
  949. package/dist/cli/registry/core.d.ts +0 -2
  950. package/dist/cli/registry/core.js +0 -27
  951. package/dist/cli/registry/session.d.ts +0 -2
  952. package/dist/cli/registry/session.js +0 -137
  953. package/dist/cli/registry/system.d.ts +0 -2
  954. package/dist/cli/registry/system.js +0 -95
  955. package/dist/cli/registry/tooling.d.ts +0 -2
  956. package/dist/cli/registry/tooling.js +0 -112
  957. package/dist/cli/registry/visual.d.ts +0 -2
  958. package/dist/cli/registry/visual.js +0 -91
  959. package/dist/cli/release-promotion-gate.d.ts +0 -21
  960. package/dist/cli/release-promotion-gate.js +0 -93
  961. package/dist/cli/root.d.ts +0 -11
  962. package/dist/cli/root.js +0 -119
  963. package/dist/cli/runtime/capability-selector.d.ts +0 -18
  964. package/dist/cli/runtime/capability-selector.js +0 -208
  965. package/dist/cli/runtime/cli-runtime.d.ts +0 -10
  966. package/dist/cli/runtime/cli-runtime.js +0 -35
  967. package/dist/cli/runtime/cli-writer.d.ts +0 -18
  968. package/dist/cli/runtime/cli-writer.js +0 -87
  969. package/dist/cli/runtime/command-bus.d.ts +0 -45
  970. package/dist/cli/runtime/command-bus.js +0 -132
  971. package/dist/cli/runtime/event-bus.d.ts +0 -12
  972. package/dist/cli/runtime/event-bus.js +0 -31
  973. package/dist/cli/runtime/generic-provider-adapter.d.ts +0 -24
  974. package/dist/cli/runtime/generic-provider-adapter.js +0 -38
  975. package/dist/cli/runtime/index.d.ts +0 -17
  976. package/dist/cli/runtime/index.js +0 -18
  977. package/dist/cli/runtime/intent-classifier.d.ts +0 -16
  978. package/dist/cli/runtime/intent-classifier.js +0 -113
  979. package/dist/cli/runtime/plan-controller.d.ts +0 -7
  980. package/dist/cli/runtime/plan-controller.js +0 -29
  981. package/dist/cli/runtime/provider-adapter-registry.d.ts +0 -32
  982. package/dist/cli/runtime/provider-adapter-registry.js +0 -60
  983. package/dist/cli/runtime/provider-event-normalizer.d.ts +0 -19
  984. package/dist/cli/runtime/provider-event-normalizer.js +0 -150
  985. package/dist/cli/runtime/run-controller.d.ts +0 -7
  986. package/dist/cli/runtime/run-controller.js +0 -30
  987. package/dist/cli/runtime/runtime-sidecar.d.ts +0 -17
  988. package/dist/cli/runtime/runtime-sidecar.js +0 -138
  989. package/dist/cli/runtime/task-controller.d.ts +0 -7
  990. package/dist/cli/runtime/task-controller.js +0 -29
  991. package/dist/cli/runtime/types.d.ts +0 -312
  992. package/dist/cli/runtime/types.js +0 -6
  993. package/dist/cli/theme/index.d.ts +0 -18
  994. package/dist/cli/theme/index.js +0 -11
  995. package/dist/cli/theme/oklab-quantize.d.ts +0 -29
  996. package/dist/cli/theme/oklab-quantize.js +0 -105
  997. package/dist/cli/theme/render-table.d.ts +0 -59
  998. package/dist/cli/theme/render-table.js +0 -112
  999. package/dist/cli/theme/status-frame.d.ts +0 -10
  1000. package/dist/cli/theme/status-frame.js +0 -22
  1001. package/dist/cli/theme/terminal-capability.d.ts +0 -23
  1002. package/dist/cli/theme/terminal-capability.js +0 -104
  1003. package/dist/cli/theme/theme-doc.d.ts +0 -22
  1004. package/dist/cli/theme/theme-doc.js +0 -97
  1005. package/dist/cli/theme/theme-registry.d.ts +0 -25
  1006. package/dist/cli/theme/theme-registry.js +0 -357
  1007. package/dist/cli/theme/theme-resolver.d.ts +0 -12
  1008. package/dist/cli/theme/theme-resolver.js +0 -38
  1009. package/dist/cli/theme/tier-explain.d.ts +0 -21
  1010. package/dist/cli/theme/tier-explain.js +0 -60
  1011. package/dist/cli/ui/event.d.ts +0 -65
  1012. package/dist/cli/ui/event.js +0 -1
  1013. package/dist/cli/ui/green-rain-renderer.d.ts +0 -17
  1014. package/dist/cli/ui/green-rain-renderer.js +0 -97
  1015. package/dist/cli/ui/neon-grid-renderer.d.ts +0 -17
  1016. package/dist/cli/ui/neon-grid-renderer.js +0 -100
  1017. package/dist/cli/ui/plain-renderer.d.ts +0 -37
  1018. package/dist/cli/ui/plain-renderer.js +0 -160
  1019. package/dist/cli/ui/renderer.d.ts +0 -7
  1020. package/dist/cli/ui/renderer.js +0 -1
  1021. package/dist/cli/ui/rich-renderer.d.ts +0 -32
  1022. package/dist/cli/ui/rich-renderer.js +0 -234
  1023. package/dist/cli/ui/route-blocked-panel.d.ts +0 -5
  1024. package/dist/cli/ui/route-blocked-panel.js +0 -67
  1025. package/dist/cli/ui/rust-forge-renderer.d.ts +0 -19
  1026. package/dist/cli/ui/rust-forge-renderer.js +0 -143
  1027. package/dist/cli/ui/system24-renderer.d.ts +0 -96
  1028. package/dist/cli/ui/system24-renderer.js +0 -531
  1029. package/dist/cli/v2/chat-repl.d.ts +0 -37
  1030. package/dist/cli/v2/chat-repl.js +0 -282
  1031. package/dist/cli/v2/cli-v2-skeleton.d.ts +0 -105
  1032. package/dist/cli/v2/cli-v2-skeleton.js +0 -462
  1033. package/dist/cli/v2/interactive-prompt.d.ts +0 -52
  1034. package/dist/cli/v2/interactive-prompt.js +0 -191
  1035. package/dist/cli/v2/persistent-memory.d.ts +0 -70
  1036. package/dist/cli/v2/persistent-memory.js +0 -229
  1037. package/dist/cli/v2/provider-commands.d.ts +0 -120
  1038. package/dist/cli/v2/provider-commands.js +0 -244
  1039. package/dist/cli/v2/release-commands.d.ts +0 -29
  1040. package/dist/cli/v2/release-commands.js +0 -95
  1041. package/dist/cli/v2/workflow-commands.d.ts +0 -72
  1042. package/dist/cli/v2/workflow-commands.js +0 -198
  1043. package/dist/cockpit/git-numstat.d.ts +0 -10
  1044. package/dist/cockpit/git-numstat.js +0 -97
  1045. package/dist/cockpit/lsp-status.d.ts +0 -5
  1046. package/dist/cockpit/lsp-status.js +0 -51
  1047. package/dist/cockpit/types.d.ts +0 -66
  1048. package/dist/cockpit/types.js +0 -4
  1049. package/dist/cockpit/views/rail-view.d.ts +0 -9
  1050. package/dist/cockpit/views/rail-view.js +0 -160
  1051. package/dist/commands/agent.d.ts +0 -6
  1052. package/dist/commands/agent.js +0 -263
  1053. package/dist/commands/appshot.d.ts +0 -15
  1054. package/dist/commands/appshot.js +0 -122
  1055. package/dist/commands/auth.d.ts +0 -43
  1056. package/dist/commands/auth.js +0 -167
  1057. package/dist/commands/browser.d.ts +0 -18
  1058. package/dist/commands/browser.js +0 -110
  1059. package/dist/commands/chat/chat-turn-dag.d.ts +0 -21
  1060. package/dist/commands/chat/chat-turn-dag.js +0 -72
  1061. package/dist/commands/chat/core.d.ts +0 -27
  1062. package/dist/commands/chat/core.js +0 -423
  1063. package/dist/commands/chat/index.d.ts +0 -5
  1064. package/dist/commands/chat/index.js +0 -5
  1065. package/dist/commands/chat/native-root-loop.d.ts +0 -57
  1066. package/dist/commands/chat/native-root-loop.js +0 -1114
  1067. package/dist/commands/chat/runtime.d.ts +0 -46
  1068. package/dist/commands/chat/runtime.js +0 -397
  1069. package/dist/commands/chat/slash/commands/control.d.ts +0 -2
  1070. package/dist/commands/chat/slash/commands/control.js +0 -196
  1071. package/dist/commands/chat/slash/commands/diagnostics.d.ts +0 -2
  1072. package/dist/commands/chat/slash/commands/diagnostics.js +0 -64
  1073. package/dist/commands/chat/slash/commands/harness.d.ts +0 -2
  1074. package/dist/commands/chat/slash/commands/harness.js +0 -21
  1075. package/dist/commands/chat/slash/commands/index.d.ts +0 -2
  1076. package/dist/commands/chat/slash/commands/index.js +0 -18
  1077. package/dist/commands/chat/slash/commands/routing.d.ts +0 -2
  1078. package/dist/commands/chat/slash/commands/routing.js +0 -355
  1079. package/dist/commands/chat/slash/commands/session.d.ts +0 -2
  1080. package/dist/commands/chat/slash/commands/session.js +0 -104
  1081. package/dist/commands/chat/slash/commands/tool-plane.d.ts +0 -2
  1082. package/dist/commands/chat/slash/commands/tool-plane.js +0 -64
  1083. package/dist/commands/chat/slash/commands/ui.d.ts +0 -2
  1084. package/dist/commands/chat/slash/commands/ui.js +0 -108
  1085. package/dist/commands/chat/slash/context.d.ts +0 -3
  1086. package/dist/commands/chat/slash/context.js +0 -9
  1087. package/dist/commands/chat/slash/format.d.ts +0 -3
  1088. package/dist/commands/chat/slash/format.js +0 -19
  1089. package/dist/commands/chat/slash/parser.d.ts +0 -15
  1090. package/dist/commands/chat/slash/parser.js +0 -97
  1091. package/dist/commands/chat/slash/registry.d.ts +0 -13
  1092. package/dist/commands/chat/slash/registry.js +0 -38
  1093. package/dist/commands/chat/slash/result.d.ts +0 -7
  1094. package/dist/commands/chat/slash/result.js +0 -35
  1095. package/dist/commands/chat/slash/types.d.ts +0 -32
  1096. package/dist/commands/chat/slash/types.js +0 -1
  1097. package/dist/commands/chat/startup.d.ts +0 -68
  1098. package/dist/commands/chat/startup.js +0 -150
  1099. package/dist/commands/chat/state.d.ts +0 -3
  1100. package/dist/commands/chat/state.js +0 -100
  1101. package/dist/commands/chat/utils.d.ts +0 -25
  1102. package/dist/commands/chat/utils.js +0 -216
  1103. package/dist/commands/chat.d.ts +0 -2
  1104. package/dist/commands/chat.js +0 -2
  1105. package/dist/commands/cockpit/core.d.ts +0 -5
  1106. package/dist/commands/cockpit/core.js +0 -91
  1107. package/dist/commands/cockpit/render.d.ts +0 -5
  1108. package/dist/commands/cockpit/render.js +0 -969
  1109. package/dist/commands/cockpit/scroll.d.ts +0 -39
  1110. package/dist/commands/cockpit/scroll.js +0 -87
  1111. package/dist/commands/cockpit/telemetry.d.ts +0 -30
  1112. package/dist/commands/cockpit/telemetry.js +0 -361
  1113. package/dist/commands/cockpit/update-loop.d.ts +0 -54
  1114. package/dist/commands/cockpit/update-loop.js +0 -285
  1115. package/dist/commands/cockpit/utils.d.ts +0 -233
  1116. package/dist/commands/cockpit/utils.js +0 -388
  1117. package/dist/commands/cockpit.d.ts +0 -8
  1118. package/dist/commands/cockpit.js +0 -7
  1119. package/dist/commands/codex.d.ts +0 -70
  1120. package/dist/commands/codex.js +0 -597
  1121. package/dist/commands/consent.d.ts +0 -24
  1122. package/dist/commands/consent.js +0 -255
  1123. package/dist/commands/cron.d.ts +0 -16
  1124. package/dist/commands/cron.js +0 -187
  1125. package/dist/commands/dag-from-spec.d.ts +0 -31
  1126. package/dist/commands/dag-from-spec.js +0 -344
  1127. package/dist/commands/dag.d.ts +0 -10
  1128. package/dist/commands/dag.js +0 -467
  1129. package/dist/commands/design.d.ts +0 -73
  1130. package/dist/commands/design.js +0 -1253
  1131. package/dist/commands/diff-runs.d.ts +0 -3
  1132. package/dist/commands/diff-runs.js +0 -36
  1133. package/dist/commands/do.d.ts +0 -29
  1134. package/dist/commands/do.js +0 -196
  1135. package/dist/commands/doctor/checks.d.ts +0 -19
  1136. package/dist/commands/doctor/checks.js +0 -861
  1137. package/dist/commands/doctor/core.d.ts +0 -2
  1138. package/dist/commands/doctor/core.js +0 -53
  1139. package/dist/commands/doctor/fix-plan.d.ts +0 -69
  1140. package/dist/commands/doctor/fix-plan.js +0 -78
  1141. package/dist/commands/doctor/fix.d.ts +0 -5
  1142. package/dist/commands/doctor/fix.js +0 -1002
  1143. package/dist/commands/doctor/report.d.ts +0 -7
  1144. package/dist/commands/doctor/report.js +0 -140
  1145. package/dist/commands/doctor/utils.d.ts +0 -52
  1146. package/dist/commands/doctor/utils.js +0 -124
  1147. package/dist/commands/doctor.d.ts +0 -2
  1148. package/dist/commands/doctor.js +0 -1
  1149. package/dist/commands/goal-interview.d.ts +0 -18
  1150. package/dist/commands/goal-interview.js +0 -396
  1151. package/dist/commands/goal.d.ts +0 -46
  1152. package/dist/commands/goal.js +0 -492
  1153. package/dist/commands/google.d.ts +0 -1
  1154. package/dist/commands/google.js +0 -27
  1155. package/dist/commands/graph.d.ts +0 -71
  1156. package/dist/commands/graph.js +0 -208
  1157. package/dist/commands/hud.d.ts +0 -57
  1158. package/dist/commands/hud.js +0 -1031
  1159. package/dist/commands/image.d.ts +0 -16
  1160. package/dist/commands/image.js +0 -102
  1161. package/dist/commands/init/config.d.ts +0 -8
  1162. package/dist/commands/init/config.js +0 -97
  1163. package/dist/commands/init/constants.d.ts +0 -7
  1164. package/dist/commands/init/constants.js +0 -49
  1165. package/dist/commands/init/content.d.ts +0 -12
  1166. package/dist/commands/init/content.js +0 -1775
  1167. package/dist/commands/init/core.d.ts +0 -2
  1168. package/dist/commands/init/core.js +0 -298
  1169. package/dist/commands/init/interactive.d.ts +0 -9
  1170. package/dist/commands/init/interactive.js +0 -170
  1171. package/dist/commands/init/scaffold.d.ts +0 -17
  1172. package/dist/commands/init/scaffold.js +0 -146
  1173. package/dist/commands/init/types.d.ts +0 -35
  1174. package/dist/commands/init/types.js +0 -1
  1175. package/dist/commands/init/utils.d.ts +0 -13
  1176. package/dist/commands/init/utils.js +0 -107
  1177. package/dist/commands/init.d.ts +0 -32
  1178. package/dist/commands/init.js +0 -2581
  1179. package/dist/commands/inspect.d.ts +0 -9
  1180. package/dist/commands/inspect.js +0 -12
  1181. package/dist/commands/lsp.d.ts +0 -8
  1182. package/dist/commands/lsp.js +0 -60
  1183. package/dist/commands/mcp/config.d.ts +0 -32
  1184. package/dist/commands/mcp/config.js +0 -264
  1185. package/dist/commands/mcp/doctor-fix.d.ts +0 -12
  1186. package/dist/commands/mcp/doctor-fix.js +0 -261
  1187. package/dist/commands/mcp/doctor.d.ts +0 -55
  1188. package/dist/commands/mcp/doctor.js +0 -401
  1189. package/dist/commands/mcp/list.d.ts +0 -1
  1190. package/dist/commands/mcp/list.js +0 -56
  1191. package/dist/commands/mcp/shared.d.ts +0 -47
  1192. package/dist/commands/mcp/shared.js +0 -192
  1193. package/dist/commands/mcp/test.d.ts +0 -5
  1194. package/dist/commands/mcp/test.js +0 -457
  1195. package/dist/commands/mcp.d.ts +0 -8
  1196. package/dist/commands/mcp.js +0 -5
  1197. package/dist/commands/menu.d.ts +0 -4
  1198. package/dist/commands/menu.js +0 -213
  1199. package/dist/commands/merge.d.ts +0 -9
  1200. package/dist/commands/merge.js +0 -363
  1201. package/dist/commands/mode.d.ts +0 -3
  1202. package/dist/commands/mode.js +0 -60
  1203. package/dist/commands/model.d.ts +0 -15
  1204. package/dist/commands/model.js +0 -215
  1205. package/dist/commands/notice.d.ts +0 -7
  1206. package/dist/commands/notice.js +0 -76
  1207. package/dist/commands/open-design-agent.d.ts +0 -46
  1208. package/dist/commands/open-design-agent.js +0 -569
  1209. package/dist/commands/orchestrate.d.ts +0 -18
  1210. package/dist/commands/orchestrate.js +0 -284
  1211. package/dist/commands/parallel/core.d.ts +0 -34
  1212. package/dist/commands/parallel/core.js +0 -296
  1213. package/dist/commands/parallel/index.d.ts +0 -5
  1214. package/dist/commands/parallel/index.js +0 -5
  1215. package/dist/commands/parallel/interactive.d.ts +0 -27
  1216. package/dist/commands/parallel/interactive.js +0 -172
  1217. package/dist/commands/parallel/orchestrator.d.ts +0 -40
  1218. package/dist/commands/parallel/orchestrator.js +0 -564
  1219. package/dist/commands/parallel/utils.d.ts +0 -12
  1220. package/dist/commands/parallel/utils.js +0 -114
  1221. package/dist/commands/parallel/worker.d.ts +0 -43
  1222. package/dist/commands/parallel/worker.js +0 -276
  1223. package/dist/commands/parallel.d.ts +0 -4
  1224. package/dist/commands/parallel.js +0 -3
  1225. package/dist/commands/plan.d.ts +0 -6
  1226. package/dist/commands/plan.js +0 -113
  1227. package/dist/commands/project-index.d.ts +0 -18
  1228. package/dist/commands/project-index.js +0 -312
  1229. package/dist/commands/provider.d.ts +0 -65
  1230. package/dist/commands/provider.js +0 -621
  1231. package/dist/commands/rail.d.ts +0 -6
  1232. package/dist/commands/rail.js +0 -7
  1233. package/dist/commands/replay.d.ts +0 -7
  1234. package/dist/commands/replay.js +0 -10
  1235. package/dist/commands/research.d.ts +0 -5
  1236. package/dist/commands/research.js +0 -48
  1237. package/dist/commands/run.d.ts +0 -15
  1238. package/dist/commands/run.js +0 -312
  1239. package/dist/commands/runs.d.ts +0 -36
  1240. package/dist/commands/runs.js +0 -504
  1241. package/dist/commands/screenshot.d.ts +0 -10
  1242. package/dist/commands/screenshot.js +0 -72
  1243. package/dist/commands/skill.d.ts +0 -28
  1244. package/dist/commands/skill.js +0 -382
  1245. package/dist/commands/snip.d.ts +0 -8
  1246. package/dist/commands/snip.js +0 -77
  1247. package/dist/commands/spec.d.ts +0 -17
  1248. package/dist/commands/spec.js +0 -262
  1249. package/dist/commands/specify.d.ts +0 -18
  1250. package/dist/commands/specify.js +0 -111
  1251. package/dist/commands/star.d.ts +0 -3
  1252. package/dist/commands/star.js +0 -35
  1253. package/dist/commands/summary.d.ts +0 -5
  1254. package/dist/commands/summary.js +0 -445
  1255. package/dist/commands/sync.d.ts +0 -6
  1256. package/dist/commands/sync.js +0 -129
  1257. package/dist/commands/team.d.ts +0 -8
  1258. package/dist/commands/team.js +0 -302
  1259. package/dist/commands/verify.d.ts +0 -4
  1260. package/dist/commands/verify.js +0 -320
  1261. package/dist/commands/version.d.ts +0 -6
  1262. package/dist/commands/version.js +0 -83
  1263. package/dist/commands/web-bridge.d.ts +0 -12
  1264. package/dist/commands/web-bridge.js +0 -75
  1265. package/dist/commands/why.d.ts +0 -14
  1266. package/dist/commands/why.js +0 -46
  1267. package/dist/commands/workflow.d.ts +0 -13
  1268. package/dist/commands/workflow.js +0 -385
  1269. package/dist/contracts/dag.d.ts +0 -134
  1270. package/dist/contracts/dag.js +0 -4
  1271. package/dist/contracts/decision.d.ts +0 -23
  1272. package/dist/contracts/decision.js +0 -1
  1273. package/dist/contracts/envelope.d.ts +0 -29
  1274. package/dist/contracts/envelope.js +0 -1
  1275. package/dist/contracts/errors.d.ts +0 -13
  1276. package/dist/contracts/errors.js +0 -15
  1277. package/dist/contracts/evidence.d.ts +0 -23
  1278. package/dist/contracts/evidence.js +0 -1
  1279. package/dist/contracts/goal.d.ts +0 -169
  1280. package/dist/contracts/goal.js +0 -4
  1281. package/dist/contracts/hud.d.ts +0 -17
  1282. package/dist/contracts/hud.js +0 -4
  1283. package/dist/contracts/index.d.ts +0 -8
  1284. package/dist/contracts/index.js +0 -8
  1285. package/dist/contracts/interview.d.ts +0 -106
  1286. package/dist/contracts/interview.js +0 -9
  1287. package/dist/contracts/orchestration.d.ts +0 -215
  1288. package/dist/contracts/orchestration.js +0 -4
  1289. package/dist/contracts/proof.d.ts +0 -32
  1290. package/dist/contracts/proof.js +0 -1
  1291. package/dist/contracts/provider-health.d.ts +0 -79
  1292. package/dist/contracts/provider-health.js +0 -57
  1293. package/dist/contracts/provider.d.ts +0 -35
  1294. package/dist/contracts/provider.js +0 -1
  1295. package/dist/contracts/replay.d.ts +0 -95
  1296. package/dist/contracts/replay.js +0 -7
  1297. package/dist/contracts/run.d.ts +0 -34
  1298. package/dist/contracts/run.js +0 -1
  1299. package/dist/contracts/safety.d.ts +0 -10
  1300. package/dist/contracts/safety.js +0 -4
  1301. package/dist/contracts/version.d.ts +0 -21
  1302. package/dist/contracts/version.js +0 -1
  1303. package/dist/contracts/web-bridge.d.ts +0 -95
  1304. package/dist/contracts/web-bridge.js +0 -168
  1305. package/dist/contracts/worker-context.d.ts +0 -70
  1306. package/dist/contracts/worker-context.js +0 -1
  1307. package/dist/evidence/attempt-record.d.ts +0 -78
  1308. package/dist/evidence/attempt-record.js +0 -16
  1309. package/dist/evidence/context-snapshot.d.ts +0 -20
  1310. package/dist/evidence/context-snapshot.js +0 -81
  1311. package/dist/evidence/decision-trace.d.ts +0 -14
  1312. package/dist/evidence/decision-trace.js +0 -54
  1313. package/dist/evidence/diagnosis.d.ts +0 -15
  1314. package/dist/evidence/diagnosis.js +0 -279
  1315. package/dist/evidence/evidence-recorder.d.ts +0 -19
  1316. package/dist/evidence/evidence-recorder.js +0 -55
  1317. package/dist/evidence/evidence-trust-score.d.ts +0 -101
  1318. package/dist/evidence/evidence-trust-score.js +0 -408
  1319. package/dist/evidence/index.d.ts +0 -21
  1320. package/dist/evidence/index.js +0 -10
  1321. package/dist/evidence/proof-trust-cli.d.ts +0 -8
  1322. package/dist/evidence/proof-trust-cli.js +0 -27
  1323. package/dist/evidence/proof-trust.d.ts +0 -14
  1324. package/dist/evidence/proof-trust.js +0 -381
  1325. package/dist/evidence/regression-proof-matrix.d.ts +0 -42
  1326. package/dist/evidence/regression-proof-matrix.js +0 -72
  1327. package/dist/evidence/run-trace.d.ts +0 -103
  1328. package/dist/evidence/run-trace.js +0 -191
  1329. package/dist/goal/compiler.d.ts +0 -5
  1330. package/dist/goal/compiler.js +0 -350
  1331. package/dist/goal/control-loop.d.ts +0 -124
  1332. package/dist/goal/control-loop.js +0 -1123
  1333. package/dist/goal/ensemble-memory.d.ts +0 -26
  1334. package/dist/goal/ensemble-memory.js +0 -55
  1335. package/dist/goal/eval-criteria.d.ts +0 -3
  1336. package/dist/goal/eval-criteria.js +0 -72
  1337. package/dist/goal/evidence.d.ts +0 -20
  1338. package/dist/goal/evidence.js +0 -321
  1339. package/dist/goal/goal-daemon.d.ts +0 -40
  1340. package/dist/goal/goal-daemon.js +0 -318
  1341. package/dist/goal/intake.d.ts +0 -48
  1342. package/dist/goal/intake.js +0 -561
  1343. package/dist/goal/intent-analyzer.d.ts +0 -9
  1344. package/dist/goal/intent-analyzer.js +0 -322
  1345. package/dist/goal/intent-frame.d.ts +0 -65
  1346. package/dist/goal/intent-frame.js +0 -596
  1347. package/dist/goal/interview-assimilation.d.ts +0 -13
  1348. package/dist/goal/interview-assimilation.js +0 -383
  1349. package/dist/goal/interview-question-bank.d.ts +0 -11
  1350. package/dist/goal/interview-question-bank.js +0 -225
  1351. package/dist/goal/interview-scoring.d.ts +0 -31
  1352. package/dist/goal/interview-scoring.js +0 -187
  1353. package/dist/goal/interview-session.d.ts +0 -25
  1354. package/dist/goal/interview-session.js +0 -116
  1355. package/dist/goal/persistence.d.ts +0 -11
  1356. package/dist/goal/persistence.js +0 -134
  1357. package/dist/goal/prompt-digest.d.ts +0 -13
  1358. package/dist/goal/prompt-digest.js +0 -111
  1359. package/dist/goal/scoring.d.ts +0 -2
  1360. package/dist/goal/scoring.js +0 -69
  1361. package/dist/goal/wake-policy.d.ts +0 -26
  1362. package/dist/goal/wake-policy.js +0 -58
  1363. package/dist/harness/create-harness-task-runner.d.ts +0 -43
  1364. package/dist/harness/create-harness-task-runner.js +0 -56
  1365. package/dist/harness/execute-harness-run.d.ts +0 -34
  1366. package/dist/harness/execute-harness-run.js +0 -109
  1367. package/dist/hooks/events.d.ts +0 -71
  1368. package/dist/hooks/events.js +0 -1
  1369. package/dist/hooks/hook-bus.d.ts +0 -13
  1370. package/dist/hooks/hook-bus.js +0 -59
  1371. package/dist/hooks/hook-registry.d.ts +0 -6
  1372. package/dist/hooks/hook-registry.js +0 -64
  1373. package/dist/hooks/index.d.ts +0 -3
  1374. package/dist/hooks/index.js +0 -2
  1375. package/dist/hud/index.d.ts +0 -9
  1376. package/dist/hud/index.js +0 -11
  1377. package/dist/hud/live-renderer.d.ts +0 -17
  1378. package/dist/hud/live-renderer.js +0 -52
  1379. package/dist/hud/render.d.ts +0 -64
  1380. package/dist/hud/render.js +0 -960
  1381. package/dist/hud/types.d.ts +0 -58
  1382. package/dist/hud/types.js +0 -7
  1383. package/dist/input/input-artifacts.d.ts +0 -10
  1384. package/dist/input/input-artifacts.js +0 -19
  1385. package/dist/input/input-envelope.d.ts +0 -86
  1386. package/dist/input/input-envelope.js +0 -87
  1387. package/dist/integrations/servarr/adapter.d.ts +0 -29
  1388. package/dist/integrations/servarr/adapter.js +0 -156
  1389. package/dist/integrations/servarr/commands.d.ts +0 -15
  1390. package/dist/integrations/servarr/commands.js +0 -119
  1391. package/dist/integrations/servarr/schema.d.ts +0 -34
  1392. package/dist/integrations/servarr/schema.js +0 -149
  1393. package/dist/kimi/ascii-art.d.ts +0 -1
  1394. package/dist/kimi/ascii-art.js +0 -23
  1395. package/dist/kimi/banner.d.ts +0 -53
  1396. package/dist/kimi/banner.js +0 -284
  1397. package/dist/kimi/bug-filter.d.ts +0 -15
  1398. package/dist/kimi/bug-filter.js +0 -150
  1399. package/dist/kimi/capability.d.ts +0 -25
  1400. package/dist/kimi/capability.js +0 -68
  1401. package/dist/kimi/isolated-home.d.ts +0 -21
  1402. package/dist/kimi/isolated-home.js +0 -270
  1403. package/dist/kimi/runner.d.ts +0 -74
  1404. package/dist/kimi/runner.js +0 -1052
  1405. package/dist/kimi/simple-art.d.ts +0 -1
  1406. package/dist/kimi/simple-art.js +0 -1
  1407. package/dist/kimi/statusline.d.ts +0 -26
  1408. package/dist/kimi/statusline.js +0 -142
  1409. package/dist/kimi/usage.d.ts +0 -52
  1410. package/dist/kimi/usage.js +0 -481
  1411. package/dist/kimi/wire-client.d.ts +0 -95
  1412. package/dist/kimi/wire-client.js +0 -338
  1413. package/dist/lsp/default-config.d.ts +0 -16
  1414. package/dist/lsp/default-config.js +0 -26
  1415. package/dist/mcp/acp-server.d.ts +0 -2
  1416. package/dist/mcp/acp-server.js +0 -357
  1417. package/dist/mcp/autoconnect.d.ts +0 -60
  1418. package/dist/mcp/autoconnect.js +0 -192
  1419. package/dist/mcp/client.d.ts +0 -112
  1420. package/dist/mcp/client.js +0 -276
  1421. package/dist/mcp/config-permissions.d.ts +0 -23
  1422. package/dist/mcp/config-permissions.js +0 -66
  1423. package/dist/mcp/consent-flow.d.ts +0 -152
  1424. package/dist/mcp/consent-flow.js +0 -329
  1425. package/dist/mcp/filesystem-readonly-server.d.ts +0 -2
  1426. package/dist/mcp/filesystem-readonly-server.js +0 -320
  1427. package/dist/mcp/governance.d.ts +0 -292
  1428. package/dist/mcp/governance.js +0 -602
  1429. package/dist/mcp/host.d.ts +0 -154
  1430. package/dist/mcp/host.js +0 -792
  1431. package/dist/mcp/omk-project-server.d.ts +0 -2
  1432. package/dist/mcp/omk-project-server.js +0 -1632
  1433. package/dist/mcp/omk-web-bridge-server.d.ts +0 -14
  1434. package/dist/mcp/omk-web-bridge-server.js +0 -154
  1435. package/dist/mcp/permission-resolver.d.ts +0 -67
  1436. package/dist/mcp/permission-resolver.js +0 -124
  1437. package/dist/mcp/quality-gate.d.ts +0 -36
  1438. package/dist/mcp/quality-gate.js +0 -247
  1439. package/dist/mcp/quarantine.d.ts +0 -11
  1440. package/dist/mcp/quarantine.js +0 -79
  1441. package/dist/mcp/secret-scanner.d.ts +0 -195
  1442. package/dist/mcp/secret-scanner.js +0 -742
  1443. package/dist/mcp/server-catalog.d.ts +0 -36
  1444. package/dist/mcp/server-catalog.js +0 -168
  1445. package/dist/mcp/shared-secret-registry.d.ts +0 -61
  1446. package/dist/mcp/shared-secret-registry.js +0 -171
  1447. package/dist/mcp/transports/stdio.d.ts +0 -22
  1448. package/dist/mcp/transports/stdio.js +0 -165
  1449. package/dist/mcp/transports/streamable-http.d.ts +0 -31
  1450. package/dist/mcp/transports/streamable-http.js +0 -289
  1451. package/dist/mcp/transports/transport.d.ts +0 -20
  1452. package/dist/mcp/transports/transport.js +0 -3
  1453. package/dist/memory/embedding.d.ts +0 -11
  1454. package/dist/memory/embedding.js +0 -24
  1455. package/dist/memory/graph-delta-log.d.ts +0 -137
  1456. package/dist/memory/graph-delta-log.js +0 -650
  1457. package/dist/memory/graph-viewer.d.ts +0 -72
  1458. package/dist/memory/graph-viewer.js +0 -383
  1459. package/dist/memory/kuzu-memory-store.d.ts +0 -37
  1460. package/dist/memory/kuzu-memory-store.js +0 -453
  1461. package/dist/memory/local-graph-memory-store.d.ts +0 -189
  1462. package/dist/memory/local-graph-memory-store.js +0 -1305
  1463. package/dist/memory/memory-config.d.ts +0 -51
  1464. package/dist/memory/memory-config.js +0 -187
  1465. package/dist/memory/memory-store.d.ts +0 -66
  1466. package/dist/memory/memory-store.js +0 -228
  1467. package/dist/memory/ontology-model.d.ts +0 -175
  1468. package/dist/memory/ontology-model.js +0 -131
  1469. package/dist/openai/image-client.d.ts +0 -103
  1470. package/dist/openai/image-client.js +0 -380
  1471. package/dist/orchestration/adaptorch-topology.d.ts +0 -59
  1472. package/dist/orchestration/adaptorch-topology.js +0 -194
  1473. package/dist/orchestration/agent-worker.d.ts +0 -72
  1474. package/dist/orchestration/agent-worker.js +0 -278
  1475. package/dist/orchestration/capability-agents.d.ts +0 -14
  1476. package/dist/orchestration/capability-agents.js +0 -180
  1477. package/dist/orchestration/capability-routing.d.ts +0 -65
  1478. package/dist/orchestration/capability-routing.js +0 -121
  1479. package/dist/orchestration/compiled-dag-executor.d.ts +0 -56
  1480. package/dist/orchestration/compiled-dag-executor.js +0 -88
  1481. package/dist/orchestration/completion-artifacts.d.ts +0 -37
  1482. package/dist/orchestration/completion-artifacts.js +0 -84
  1483. package/dist/orchestration/completion-sentinel.d.ts +0 -37
  1484. package/dist/orchestration/completion-sentinel.js +0 -66
  1485. package/dist/orchestration/contracts/index.d.ts +0 -45
  1486. package/dist/orchestration/contracts/index.js +0 -6
  1487. package/dist/orchestration/dag-artifacts.d.ts +0 -11
  1488. package/dist/orchestration/dag-artifacts.js +0 -42
  1489. package/dist/orchestration/dag-compiler-presets.d.ts +0 -20
  1490. package/dist/orchestration/dag-compiler-presets.js +0 -476
  1491. package/dist/orchestration/dag-compiler-types.d.ts +0 -43
  1492. package/dist/orchestration/dag-compiler-types.js +0 -1
  1493. package/dist/orchestration/dag-compiler.d.ts +0 -3
  1494. package/dist/orchestration/dag-compiler.js +0 -135
  1495. package/dist/orchestration/dag.d.ts +0 -158
  1496. package/dist/orchestration/dag.js +0 -310
  1497. package/dist/orchestration/diagnostics.d.ts +0 -27
  1498. package/dist/orchestration/diagnostics.js +0 -262
  1499. package/dist/orchestration/enhanced-modes.d.ts +0 -116
  1500. package/dist/orchestration/enhanced-modes.js +0 -231
  1501. package/dist/orchestration/enhanced-parallel-orchestrator.d.ts +0 -127
  1502. package/dist/orchestration/enhanced-parallel-orchestrator.js +0 -734
  1503. package/dist/orchestration/ensemble-decision.d.ts +0 -40
  1504. package/dist/orchestration/ensemble-decision.js +0 -297
  1505. package/dist/orchestration/ensemble.d.ts +0 -22
  1506. package/dist/orchestration/ensemble.js +0 -558
  1507. package/dist/orchestration/eta.d.ts +0 -10
  1508. package/dist/orchestration/eta.js +0 -75
  1509. package/dist/orchestration/evidence-check.d.ts +0 -36
  1510. package/dist/orchestration/evidence-check.js +0 -257
  1511. package/dist/orchestration/evidence-gate.d.ts +0 -34
  1512. package/dist/orchestration/evidence-gate.js +0 -501
  1513. package/dist/orchestration/execution-planner.d.ts +0 -40
  1514. package/dist/orchestration/execution-planner.js +0 -252
  1515. package/dist/orchestration/executor.d.ts +0 -11
  1516. package/dist/orchestration/executor.js +0 -979
  1517. package/dist/orchestration/interactive-orchestrator.d.ts +0 -134
  1518. package/dist/orchestration/interactive-orchestrator.js +0 -450
  1519. package/dist/orchestration/log-streamer.d.ts +0 -104
  1520. package/dist/orchestration/log-streamer.js +0 -293
  1521. package/dist/orchestration/loop-artifacts.d.ts +0 -14
  1522. package/dist/orchestration/loop-artifacts.js +0 -20
  1523. package/dist/orchestration/loop-controller.d.ts +0 -14
  1524. package/dist/orchestration/loop-controller.js +0 -311
  1525. package/dist/orchestration/loop-guard.d.ts +0 -28
  1526. package/dist/orchestration/loop-guard.js +0 -104
  1527. package/dist/orchestration/loop-state.d.ts +0 -86
  1528. package/dist/orchestration/loop-state.js +0 -1
  1529. package/dist/orchestration/merge-arbiter.d.ts +0 -91
  1530. package/dist/orchestration/merge-arbiter.js +0 -376
  1531. package/dist/orchestration/node-monitor.d.ts +0 -18
  1532. package/dist/orchestration/node-monitor.js +0 -98
  1533. package/dist/orchestration/orchestrate-prompt.d.ts +0 -43
  1534. package/dist/orchestration/orchestrate-prompt.js +0 -533
  1535. package/dist/orchestration/orchestration-state.d.ts +0 -3
  1536. package/dist/orchestration/orchestration-state.js +0 -2
  1537. package/dist/orchestration/parallel-orchestrator.d.ts +0 -165
  1538. package/dist/orchestration/parallel-orchestrator.js +0 -607
  1539. package/dist/orchestration/parallel-ui.d.ts +0 -51
  1540. package/dist/orchestration/parallel-ui.js +0 -470
  1541. package/dist/orchestration/repair-policy.d.ts +0 -20
  1542. package/dist/orchestration/repair-policy.js +0 -221
  1543. package/dist/orchestration/routing/inventory.d.ts +0 -9
  1544. package/dist/orchestration/routing/inventory.js +0 -273
  1545. package/dist/orchestration/routing/mcp-config.d.ts +0 -17
  1546. package/dist/orchestration/routing/mcp-config.js +0 -154
  1547. package/dist/orchestration/routing/types.d.ts +0 -38
  1548. package/dist/orchestration/routing/types.js +0 -4
  1549. package/dist/orchestration/routing.d.ts +0 -35
  1550. package/dist/orchestration/routing.js +0 -986
  1551. package/dist/orchestration/run-state.d.ts +0 -36
  1552. package/dist/orchestration/run-state.js +0 -176
  1553. package/dist/orchestration/scheduler.d.ts +0 -9
  1554. package/dist/orchestration/scheduler.js +0 -85
  1555. package/dist/orchestration/skill-assigner.d.ts +0 -22
  1556. package/dist/orchestration/skill-assigner.js +0 -345
  1557. package/dist/orchestration/state-machine/index.d.ts +0 -3
  1558. package/dist/orchestration/state-machine/index.js +0 -3
  1559. package/dist/orchestration/state-machine/node-state-machine.d.ts +0 -24
  1560. package/dist/orchestration/state-machine/node-state-machine.js +0 -35
  1561. package/dist/orchestration/state-machine/run-state-machine.d.ts +0 -38
  1562. package/dist/orchestration/state-machine/run-state-machine.js +0 -161
  1563. package/dist/orchestration/state-machine/run-state-manager.d.ts +0 -108
  1564. package/dist/orchestration/state-machine/run-state-manager.js +0 -314
  1565. package/dist/orchestration/state-persister.d.ts +0 -7
  1566. package/dist/orchestration/state-persister.js +0 -84
  1567. package/dist/orchestration/task-graph.d.ts +0 -29
  1568. package/dist/orchestration/task-graph.js +0 -261
  1569. package/dist/orchestration/verification-only.d.ts +0 -28
  1570. package/dist/orchestration/verification-only.js +0 -94
  1571. package/dist/providers/anthropic-messages-runner.d.ts +0 -17
  1572. package/dist/providers/anthropic-messages-runner.js +0 -197
  1573. package/dist/providers/attempt-recorder.d.ts +0 -10
  1574. package/dist/providers/attempt-recorder.js +0 -38
  1575. package/dist/providers/codex-cli-runner.d.ts +0 -11
  1576. package/dist/providers/codex-cli-runner.js +0 -129
  1577. package/dist/providers/context-preflight.d.ts +0 -47
  1578. package/dist/providers/context-preflight.js +0 -134
  1579. package/dist/providers/deepseek/deepseek-balance.d.ts +0 -29
  1580. package/dist/providers/deepseek/deepseek-balance.js +0 -80
  1581. package/dist/providers/deepseek/deepseek-client.d.ts +0 -53
  1582. package/dist/providers/deepseek/deepseek-client.js +0 -164
  1583. package/dist/providers/deepseek/deepseek-config.d.ts +0 -89
  1584. package/dist/providers/deepseek/deepseek-config.js +0 -272
  1585. package/dist/providers/deepseek/deepseek-errors.d.ts +0 -5
  1586. package/dist/providers/deepseek/deepseek-errors.js +0 -48
  1587. package/dist/providers/deepseek/deepseek-provider.d.ts +0 -10
  1588. package/dist/providers/deepseek/deepseek-provider.js +0 -162
  1589. package/dist/providers/deepseek/deepseek-super-config.d.ts +0 -31
  1590. package/dist/providers/deepseek/deepseek-super-config.js +0 -136
  1591. package/dist/providers/deepseek-provider.d.ts +0 -8
  1592. package/dist/providers/deepseek-provider.js +0 -78
  1593. package/dist/providers/health.d.ts +0 -16
  1594. package/dist/providers/health.js +0 -101
  1595. package/dist/providers/index.d.ts +0 -23
  1596. package/dist/providers/index.js +0 -23
  1597. package/dist/providers/kimi-provider-failure.d.ts +0 -8
  1598. package/dist/providers/kimi-provider-failure.js +0 -56
  1599. package/dist/providers/kimi-provider.d.ts +0 -7
  1600. package/dist/providers/kimi-provider.js +0 -27
  1601. package/dist/providers/model-registry.d.ts +0 -103
  1602. package/dist/providers/model-registry.js +0 -605
  1603. package/dist/providers/model-table.d.ts +0 -24
  1604. package/dist/providers/model-table.js +0 -140
  1605. package/dist/providers/model-tabs.d.ts +0 -33
  1606. package/dist/providers/model-tabs.js +0 -98
  1607. package/dist/providers/openai-compatible-runner.d.ts +0 -17
  1608. package/dist/providers/openai-compatible-runner.js +0 -180
  1609. package/dist/providers/provider-health.d.ts +0 -46
  1610. package/dist/providers/provider-health.js +0 -200
  1611. package/dist/providers/provider-router.d.ts +0 -8
  1612. package/dist/providers/provider-router.js +0 -174
  1613. package/dist/providers/provider-runtime.d.ts +0 -17
  1614. package/dist/providers/provider-runtime.js +0 -262
  1615. package/dist/providers/provider-stats.d.ts +0 -56
  1616. package/dist/providers/provider-stats.js +0 -303
  1617. package/dist/providers/provider-task-runner.d.ts +0 -23
  1618. package/dist/providers/provider-task-runner.js +0 -1202
  1619. package/dist/providers/provider.d.ts +0 -76
  1620. package/dist/providers/provider.js +0 -9
  1621. package/dist/providers/router.d.ts +0 -14
  1622. package/dist/providers/router.js +0 -563
  1623. package/dist/providers/runner/deepseek-helpers.d.ts +0 -38
  1624. package/dist/providers/runner/deepseek-helpers.js +0 -150
  1625. package/dist/providers/runner/env.d.ts +0 -12
  1626. package/dist/providers/runner/env.js +0 -98
  1627. package/dist/providers/runner/execution.d.ts +0 -26
  1628. package/dist/providers/runner/execution.js +0 -42
  1629. package/dist/providers/runner/helpers.d.ts +0 -9
  1630. package/dist/providers/runner/helpers.js +0 -38
  1631. package/dist/providers/runner/results.d.ts +0 -26
  1632. package/dist/providers/runner/results.js +0 -104
  1633. package/dist/providers/thinking-levels.d.ts +0 -7
  1634. package/dist/providers/thinking-levels.js +0 -70
  1635. package/dist/providers/types.d.ts +0 -143
  1636. package/dist/providers/types.js +0 -60
  1637. package/dist/replay/differ.d.ts +0 -5
  1638. package/dist/replay/differ.js +0 -314
  1639. package/dist/replay/index.d.ts +0 -6
  1640. package/dist/replay/index.js +0 -4
  1641. package/dist/replay/inspector.d.ts +0 -14
  1642. package/dist/replay/inspector.js +0 -264
  1643. package/dist/replay/manifest-builder.d.ts +0 -11
  1644. package/dist/replay/manifest-builder.js +0 -184
  1645. package/dist/replay/replay-engine.d.ts +0 -18
  1646. package/dist/replay/replay-engine.js +0 -265
  1647. package/dist/runtime/adapter.d.ts +0 -77
  1648. package/dist/runtime/adapter.js +0 -28
  1649. package/dist/runtime/advanced-control-loop.d.ts +0 -60
  1650. package/dist/runtime/advanced-control-loop.js +0 -136
  1651. package/dist/runtime/agent-runtime.d.ts +0 -133
  1652. package/dist/runtime/agent-runtime.js +0 -18
  1653. package/dist/runtime/blast-radius.d.ts +0 -10
  1654. package/dist/runtime/blast-radius.js +0 -14
  1655. package/dist/runtime/cache-stable-session.d.ts +0 -55
  1656. package/dist/runtime/cache-stable-session.js +0 -108
  1657. package/dist/runtime/capability-injection.d.ts +0 -39
  1658. package/dist/runtime/capability-injection.js +0 -93
  1659. package/dist/runtime/chat-advisory-runtime.d.ts +0 -2
  1660. package/dist/runtime/chat-advisory-runtime.js +0 -71
  1661. package/dist/runtime/child-env.d.ts +0 -31
  1662. package/dist/runtime/child-env.js +0 -131
  1663. package/dist/runtime/codex-cli-runtime.d.ts +0 -10
  1664. package/dist/runtime/codex-cli-runtime.js +0 -78
  1665. package/dist/runtime/codex-runtime.d.ts +0 -35
  1666. package/dist/runtime/codex-runtime.js +0 -264
  1667. package/dist/runtime/command-bus.d.ts +0 -13
  1668. package/dist/runtime/command-bus.js +0 -57
  1669. package/dist/runtime/context-broker-converter.d.ts +0 -9
  1670. package/dist/runtime/context-broker-converter.js +0 -96
  1671. package/dist/runtime/context-broker.d.ts +0 -34
  1672. package/dist/runtime/context-broker.js +0 -321
  1673. package/dist/runtime/context-budget-optimizer.d.ts +0 -73
  1674. package/dist/runtime/context-budget-optimizer.js +0 -300
  1675. package/dist/runtime/context-capsule.d.ts +0 -81
  1676. package/dist/runtime/context-capsule.js +0 -46
  1677. package/dist/runtime/contracts/command-envelope.d.ts +0 -99
  1678. package/dist/runtime/contracts/command-envelope.js +0 -5
  1679. package/dist/runtime/contracts/evidence.d.ts +0 -87
  1680. package/dist/runtime/contracts/evidence.js +0 -7
  1681. package/dist/runtime/contracts/reasoning-trace.d.ts +0 -120
  1682. package/dist/runtime/contracts/reasoning-trace.js +0 -10
  1683. package/dist/runtime/contracts/router-v2.d.ts +0 -44
  1684. package/dist/runtime/contracts/router-v2.js +0 -4
  1685. package/dist/runtime/contracts/shared.d.ts +0 -34
  1686. package/dist/runtime/contracts/shared.js +0 -12
  1687. package/dist/runtime/contracts/weakness-remediation.d.ts +0 -83
  1688. package/dist/runtime/contracts/weakness-remediation.js +0 -44
  1689. package/dist/runtime/core-verified-preset.d.ts +0 -37
  1690. package/dist/runtime/core-verified-preset.js +0 -205
  1691. package/dist/runtime/debloat-nlp.d.ts +0 -140
  1692. package/dist/runtime/debloat-nlp.js +0 -398
  1693. package/dist/runtime/deepseek-runtime.d.ts +0 -28
  1694. package/dist/runtime/deepseek-runtime.js +0 -270
  1695. package/dist/runtime/external-cli-adapter.d.ts +0 -29
  1696. package/dist/runtime/external-cli-adapter.js +0 -283
  1697. package/dist/runtime/headroom-policy.d.ts +0 -37
  1698. package/dist/runtime/headroom-policy.js +0 -122
  1699. package/dist/runtime/index.d.ts +0 -8
  1700. package/dist/runtime/index.js +0 -8
  1701. package/dist/runtime/kimi-api-runtime.d.ts +0 -52
  1702. package/dist/runtime/kimi-api-runtime.js +0 -425
  1703. package/dist/runtime/kimi-print-runtime.d.ts +0 -10
  1704. package/dist/runtime/kimi-print-runtime.js +0 -87
  1705. package/dist/runtime/kimi-wire-protocol-runtime.d.ts +0 -44
  1706. package/dist/runtime/kimi-wire-protocol-runtime.js +0 -436
  1707. package/dist/runtime/kimi-wire-runtime.d.ts +0 -17
  1708. package/dist/runtime/kimi-wire-runtime.js +0 -112
  1709. package/dist/runtime/legacy-bridge.d.ts +0 -14
  1710. package/dist/runtime/legacy-bridge.js +0 -27
  1711. package/dist/runtime/local-llm-runtime.d.ts +0 -29
  1712. package/dist/runtime/local-llm-runtime.js +0 -231
  1713. package/dist/runtime/mimo-api-runtime.d.ts +0 -13
  1714. package/dist/runtime/mimo-api-runtime.js +0 -24
  1715. package/dist/runtime/nlg-renderer.d.ts +0 -38
  1716. package/dist/runtime/nlg-renderer.js +0 -132
  1717. package/dist/runtime/ouroboros-policy.d.ts +0 -57
  1718. package/dist/runtime/ouroboros-policy.js +0 -134
  1719. package/dist/runtime/output-router.d.ts +0 -20
  1720. package/dist/runtime/output-router.js +0 -171
  1721. package/dist/runtime/process-session.d.ts +0 -27
  1722. package/dist/runtime/process-session.js +0 -35
  1723. package/dist/runtime/prompt-envelope.d.ts +0 -28
  1724. package/dist/runtime/prompt-envelope.js +0 -78
  1725. package/dist/runtime/proof-bundle-trust.d.ts +0 -74
  1726. package/dist/runtime/proof-bundle-trust.js +0 -100
  1727. package/dist/runtime/provider-event-normalizer.d.ts +0 -117
  1728. package/dist/runtime/provider-event-normalizer.js +0 -454
  1729. package/dist/runtime/provider-maturity-gate.d.ts +0 -43
  1730. package/dist/runtime/provider-maturity-gate.js +0 -127
  1731. package/dist/runtime/provider-tool-contracts.d.ts +0 -24
  1732. package/dist/runtime/provider-tool-contracts.js +0 -56
  1733. package/dist/runtime/public-surface.d.ts +0 -93
  1734. package/dist/runtime/public-surface.js +0 -146
  1735. package/dist/runtime/reasoning-trace.d.ts +0 -46
  1736. package/dist/runtime/reasoning-trace.js +0 -289
  1737. package/dist/runtime/renderers.d.ts +0 -33
  1738. package/dist/runtime/renderers.js +0 -221
  1739. package/dist/runtime/router-v2-scoring.d.ts +0 -16
  1740. package/dist/runtime/router-v2-scoring.js +0 -156
  1741. package/dist/runtime/runtime-backed-task-runner.d.ts +0 -20
  1742. package/dist/runtime/runtime-backed-task-runner.js +0 -174
  1743. package/dist/runtime/runtime-bootstrap.d.ts +0 -21
  1744. package/dist/runtime/runtime-bootstrap.js +0 -208
  1745. package/dist/runtime/runtime-registry.d.ts +0 -23
  1746. package/dist/runtime/runtime-registry.js +0 -95
  1747. package/dist/runtime/runtime-router.d.ts +0 -56
  1748. package/dist/runtime/runtime-router.js +0 -652
  1749. package/dist/runtime/sandbox-profile.d.ts +0 -54
  1750. package/dist/runtime/sandbox-profile.js +0 -136
  1751. package/dist/runtime/slash-commands.d.ts +0 -46
  1752. package/dist/runtime/slash-commands.js +0 -619
  1753. package/dist/runtime/stable-json.d.ts +0 -9
  1754. package/dist/runtime/stable-json.js +0 -45
  1755. package/dist/runtime/tool-call-repair.d.ts +0 -35
  1756. package/dist/runtime/tool-call-repair.js +0 -181
  1757. package/dist/runtime/tool-dispatch-contracts.d.ts +0 -100
  1758. package/dist/runtime/tool-dispatch-contracts.js +0 -160
  1759. package/dist/runtime/tool-plane.d.ts +0 -31
  1760. package/dist/runtime/tool-plane.js +0 -112
  1761. package/dist/runtime/tool-proxy.d.ts +0 -20
  1762. package/dist/runtime/tool-proxy.js +0 -109
  1763. package/dist/runtime/tool-registry-contract.d.ts +0 -40
  1764. package/dist/runtime/tool-registry-contract.js +0 -52
  1765. package/dist/runtime/ui-components.d.ts +0 -64
  1766. package/dist/runtime/ui-components.js +0 -232
  1767. package/dist/runtime/weakness-remediation-index.d.ts +0 -27
  1768. package/dist/runtime/weakness-remediation-index.js +0 -37
  1769. package/dist/runtime/weights-config.d.ts +0 -90
  1770. package/dist/runtime/weights-config.js +0 -249
  1771. package/dist/runtime/worker-manifest.d.ts +0 -34
  1772. package/dist/runtime/worker-manifest.js +0 -204
  1773. package/dist/safety/approval-policy.d.ts +0 -4
  1774. package/dist/safety/approval-policy.js +0 -33
  1775. package/dist/safety/enforcement-engine.d.ts +0 -89
  1776. package/dist/safety/enforcement-engine.js +0 -279
  1777. package/dist/safety/guard-hooks.d.ts +0 -3
  1778. package/dist/safety/guard-hooks.js +0 -64
  1779. package/dist/safety/tool-authority-gate.d.ts +0 -102
  1780. package/dist/safety/tool-authority-gate.js +0 -200
  1781. package/dist/schema/decision.schema.d.ts +0 -57
  1782. package/dist/schema/decision.schema.js +0 -32
  1783. package/dist/schema/envelope.schema.d.ts +0 -216
  1784. package/dist/schema/envelope.schema.js +0 -38
  1785. package/dist/schema/error.schema.d.ts +0 -51
  1786. package/dist/schema/error.schema.js +0 -12
  1787. package/dist/schema/evidence.schema.d.ts +0 -58
  1788. package/dist/schema/evidence.schema.js +0 -31
  1789. package/dist/schema/index.d.ts +0 -8
  1790. package/dist/schema/index.js +0 -8
  1791. package/dist/schema/proof-bundle.schema.d.ts +0 -150
  1792. package/dist/schema/proof-bundle.schema.js +0 -41
  1793. package/dist/schema/provider.schema.d.ts +0 -138
  1794. package/dist/schema/provider.schema.js +0 -35
  1795. package/dist/schema/run-manifest.schema.d.ts +0 -168
  1796. package/dist/schema/run-manifest.schema.js +0 -35
  1797. package/dist/schema/version.schema.d.ts +0 -64
  1798. package/dist/schema/version.schema.js +0 -21
  1799. package/dist/theme/ansi.d.ts +0 -15
  1800. package/dist/theme/ansi.js +0 -48
  1801. package/dist/theme/colors.d.ts +0 -87
  1802. package/dist/theme/colors.js +0 -105
  1803. package/dist/theme/extended-palette.d.ts +0 -85
  1804. package/dist/theme/extended-palette.js +0 -108
  1805. package/dist/theme/hud-theme.d.ts +0 -6
  1806. package/dist/theme/hud-theme.js +0 -41
  1807. package/dist/theme/index.d.ts +0 -12
  1808. package/dist/theme/index.js +0 -20
  1809. package/dist/theme/layout.d.ts +0 -24
  1810. package/dist/theme/layout.js +0 -160
  1811. package/dist/theme/metrics.d.ts +0 -23
  1812. package/dist/theme/metrics.js +0 -93
  1813. package/dist/theme/parallel.d.ts +0 -68
  1814. package/dist/theme/parallel.js +0 -355
  1815. package/dist/theme/working-indicator.d.ts +0 -38
  1816. package/dist/theme/working-indicator.js +0 -149
  1817. package/dist/tui/model.d.ts +0 -28
  1818. package/dist/tui/model.js +0 -1
  1819. package/dist/tui/terminal-frame-renderer.d.ts +0 -19
  1820. package/dist/tui/terminal-frame-renderer.js +0 -60
  1821. package/dist/tui/views/capabilities-view.d.ts +0 -3
  1822. package/dist/tui/views/capabilities-view.js +0 -13
  1823. package/dist/tui/views/common.d.ts +0 -11
  1824. package/dist/tui/views/common.js +0 -35
  1825. package/dist/tui/views/dag-view.d.ts +0 -3
  1826. package/dist/tui/views/dag-view.js +0 -12
  1827. package/dist/tui/views/evidence-view.d.ts +0 -3
  1828. package/dist/tui/views/evidence-view.js +0 -18
  1829. package/dist/tui/views/index.d.ts +0 -4
  1830. package/dist/tui/views/index.js +0 -3
  1831. package/dist/ui/omk-sigil.d.ts +0 -13
  1832. package/dist/ui/omk-sigil.js +0 -268
  1833. package/dist/ui/omk-working-sweep.d.ts +0 -61
  1834. package/dist/ui/omk-working-sweep.js +0 -406
  1835. package/dist/util/agent-schema.d.ts +0 -24
  1836. package/dist/util/agent-schema.js +0 -293
  1837. package/dist/util/appshot-store.d.ts +0 -68
  1838. package/dist/util/appshot-store.js +0 -506
  1839. package/dist/util/chat-agent-mode.d.ts +0 -184
  1840. package/dist/util/chat-agent-mode.js +0 -938
  1841. package/dist/util/chat-cockpit.d.ts +0 -54
  1842. package/dist/util/chat-cockpit.js +0 -350
  1843. package/dist/util/chat-startup.d.ts +0 -35
  1844. package/dist/util/chat-startup.js +0 -330
  1845. package/dist/util/chat-state.d.ts +0 -27
  1846. package/dist/util/chat-state.js +0 -105
  1847. package/dist/util/checkpoint.d.ts +0 -21
  1848. package/dist/util/checkpoint.js +0 -238
  1849. package/dist/util/cli-contract.d.ts +0 -46
  1850. package/dist/util/cli-contract.js +0 -72
  1851. package/dist/util/clipboard-image.d.ts +0 -49
  1852. package/dist/util/clipboard-image.js +0 -263
  1853. package/dist/util/cron-engine.d.ts +0 -24
  1854. package/dist/util/cron-engine.js +0 -227
  1855. package/dist/util/events-logger.d.ts +0 -30
  1856. package/dist/util/events-logger.js +0 -135
  1857. package/dist/util/execution-selection.d.ts +0 -13
  1858. package/dist/util/execution-selection.js +0 -82
  1859. package/dist/util/first-run-star.d.ts +0 -58
  1860. package/dist/util/first-run-star.js +0 -264
  1861. package/dist/util/fs/core.d.ts +0 -5
  1862. package/dist/util/fs/core.js +0 -35
  1863. package/dist/util/fs/internal.d.ts +0 -14
  1864. package/dist/util/fs/internal.js +0 -169
  1865. package/dist/util/fs/kimi-sync.d.ts +0 -41
  1866. package/dist/util/fs/kimi-sync.js +0 -495
  1867. package/dist/util/fs/logo.d.ts +0 -2
  1868. package/dist/util/fs/logo.js +0 -78
  1869. package/dist/util/fs/manifest.d.ts +0 -6
  1870. package/dist/util/fs/manifest.js +0 -40
  1871. package/dist/util/fs/mcp-diagnose.d.ts +0 -15
  1872. package/dist/util/fs/mcp-diagnose.js +0 -204
  1873. package/dist/util/fs/mcp-runtime-config.d.ts +0 -23
  1874. package/dist/util/fs/mcp-runtime-config.js +0 -412
  1875. package/dist/util/fs/paths.d.ts +0 -13
  1876. package/dist/util/fs/paths.js +0 -82
  1877. package/dist/util/fs/preflight.d.ts +0 -27
  1878. package/dist/util/fs/preflight.js +0 -271
  1879. package/dist/util/fs.d.ts +0 -8
  1880. package/dist/util/fs.js +0 -8
  1881. package/dist/util/git.d.ts +0 -11
  1882. package/dist/util/git.js +0 -39
  1883. package/dist/util/help-text.d.ts +0 -1
  1884. package/dist/util/help-text.js +0 -60
  1885. package/dist/util/i18n.d.ts +0 -10
  1886. package/dist/util/i18n.js +0 -848
  1887. package/dist/util/json-envelope.d.ts +0 -15
  1888. package/dist/util/json-envelope.js +0 -28
  1889. package/dist/util/mcp-preflight.d.ts +0 -26
  1890. package/dist/util/mcp-preflight.js +0 -29
  1891. package/dist/util/mode-preset.d.ts +0 -29
  1892. package/dist/util/mode-preset.js +0 -222
  1893. package/dist/util/mode-selector.d.ts +0 -6
  1894. package/dist/util/mode-selector.js +0 -74
  1895. package/dist/util/output-buffer.d.ts +0 -12
  1896. package/dist/util/output-buffer.js +0 -59
  1897. package/dist/util/process-tree.d.ts +0 -18
  1898. package/dist/util/process-tree.js +0 -102
  1899. package/dist/util/project-root.d.ts +0 -27
  1900. package/dist/util/project-root.js +0 -382
  1901. package/dist/util/provider-usage.d.ts +0 -2
  1902. package/dist/util/provider-usage.js +0 -1
  1903. package/dist/util/reasoning-nlp.d.ts +0 -84
  1904. package/dist/util/reasoning-nlp.js +0 -325
  1905. package/dist/util/resource-profile.d.ts +0 -32
  1906. package/dist/util/resource-profile.js +0 -219
  1907. package/dist/util/run-store.d.ts +0 -38
  1908. package/dist/util/run-store.js +0 -151
  1909. package/dist/util/run-view-model.d.ts +0 -111
  1910. package/dist/util/run-view-model.js +0 -333
  1911. package/dist/util/runtime-profile.d.ts +0 -34
  1912. package/dist/util/runtime-profile.js +0 -149
  1913. package/dist/util/runtime-scope.d.ts +0 -2
  1914. package/dist/util/runtime-scope.js +0 -19
  1915. package/dist/util/scoped-agent-file.d.ts +0 -47
  1916. package/dist/util/scoped-agent-file.js +0 -121
  1917. package/dist/util/screenshot-store.d.ts +0 -35
  1918. package/dist/util/screenshot-store.js +0 -310
  1919. package/dist/util/secret-mask.d.ts +0 -5
  1920. package/dist/util/secret-mask.js +0 -41
  1921. package/dist/util/session.d.ts +0 -19
  1922. package/dist/util/session.js +0 -80
  1923. package/dist/util/shell.d.ts +0 -30
  1924. package/dist/util/shell.js +0 -350
  1925. package/dist/util/snippet.d.ts +0 -17
  1926. package/dist/util/snippet.js +0 -110
  1927. package/dist/util/sync-manifest.d.ts +0 -13
  1928. package/dist/util/sync-manifest.js +0 -22
  1929. package/dist/util/terminal-input.d.ts +0 -45
  1930. package/dist/util/terminal-input.js +0 -67
  1931. package/dist/util/terminal-layout.d.ts +0 -18
  1932. package/dist/util/terminal-layout.js +0 -112
  1933. package/dist/util/terminal-owner.d.ts +0 -19
  1934. package/dist/util/terminal-owner.js +0 -64
  1935. package/dist/util/theme.d.ts +0 -9
  1936. package/dist/util/theme.js +0 -9
  1937. package/dist/util/timeout-config.d.ts +0 -18
  1938. package/dist/util/timeout-config.js +0 -101
  1939. package/dist/util/todo-sync.d.ts +0 -58
  1940. package/dist/util/todo-sync.js +0 -473
  1941. package/dist/util/update-check.d.ts +0 -94
  1942. package/dist/util/update-check.js +0 -355
  1943. package/dist/util/usage-view-model.d.ts +0 -22
  1944. package/dist/util/usage-view-model.js +0 -57
  1945. package/dist/util/user-visible-output.d.ts +0 -19
  1946. package/dist/util/user-visible-output.js +0 -48
  1947. package/dist/util/version.d.ts +0 -4
  1948. package/dist/util/version.js +0 -52
  1949. package/dist/util/worktree.d.ts +0 -10
  1950. package/dist/util/worktree.js +0 -165
  1951. package/dist/ux/explain-loop-decision.d.ts +0 -4
  1952. package/dist/ux/explain-loop-decision.js +0 -55
  1953. package/dist/ux/intent-router.d.ts +0 -15
  1954. package/dist/ux/intent-router.js +0 -64
  1955. package/dist/ux/natural-entrypoint.d.ts +0 -21
  1956. package/dist/ux/natural-entrypoint.js +0 -122
  1957. package/dist/version.d.ts +0 -11
  1958. package/dist/version.js +0 -18
  1959. package/dist/web-bridge/host.d.ts +0 -8
  1960. package/dist/web-bridge/host.js +0 -109
  1961. package/dist/web-bridge/native-host.d.ts +0 -6
  1962. package/dist/web-bridge/native-host.js +0 -40
  1963. package/dist/web-bridge/status.d.ts +0 -84
  1964. package/dist/web-bridge/status.js +0 -201
  1965. package/docs/2026-05-01-16gb-lite-mode.md +0 -37
  1966. package/docs/2026-05-01-critical-issues-and-improvements.md +0 -361
  1967. package/docs/2026-05-01-dag-ensemble-runtime.md +0 -74
  1968. package/docs/2026-05-02-p1-p2-hardening-handoff.md +0 -139
  1969. package/docs/2026-05-05-adjustable-timeouts-and-cron-jobs.md +0 -252
  1970. package/docs/2026-05-08-omk-hardening-plan.md +0 -62
  1971. package/docs/2026-05-14/critical-issues.md +0 -20
  1972. package/docs/2026-05-14/improvements.md +0 -14
  1973. package/docs/2026-05-14/init-checklist.md +0 -25
  1974. package/docs/2026-05-14/plan.md +0 -20
  1975. package/docs/2026-05-15/critical-issues.md +0 -20
  1976. package/docs/2026-05-15/improvements.md +0 -14
  1977. package/docs/2026-05-15/init-checklist.md +0 -25
  1978. package/docs/2026-05-15/plan.md +0 -20
  1979. package/docs/2026-05-16/critical-issues.md +0 -20
  1980. package/docs/2026-05-16/improvements.md +0 -14
  1981. package/docs/2026-05-16/init-checklist.md +0 -25
  1982. package/docs/2026-05-16/plan.md +0 -20
  1983. package/docs/2026-05-17/critical-issues.md +0 -20
  1984. package/docs/2026-05-17/improvements.md +0 -14
  1985. package/docs/2026-05-17/init-checklist.md +0 -25
  1986. package/docs/2026-05-17/plan.md +0 -20
  1987. package/docs/2026-05-18/improvements.md +0 -14
  1988. package/docs/2026-05-18/init-checklist.md +0 -25
  1989. package/docs/2026-05-18/plan.md +0 -20
  1990. package/docs/2026-05-18-critical-issues-and-improvements.md +0 -441
  1991. package/docs/2026-05-18-project-direction.md +0 -223
  1992. package/docs/2026-05-19/critical-issues.md +0 -20
  1993. package/docs/2026-05-19/improvements.md +0 -14
  1994. package/docs/2026-05-19/init-checklist.md +0 -25
  1995. package/docs/2026-05-19/plan.md +0 -20
  1996. package/docs/2026-05-20/critical-issues.md +0 -20
  1997. package/docs/2026-05-20/improvements.md +0 -14
  1998. package/docs/2026-05-20/init-checklist.md +0 -25
  1999. package/docs/2026-05-20/plan.md +0 -20
  2000. package/docs/2026-05-21/critical-issues.md +0 -20
  2001. package/docs/2026-05-21/improvements.md +0 -14
  2002. package/docs/2026-05-21/init-checklist.md +0 -25
  2003. package/docs/2026-05-21/plan.md +0 -20
  2004. package/docs/2026-05-22/critical-issues.md +0 -20
  2005. package/docs/2026-05-22/improvements.md +0 -14
  2006. package/docs/2026-05-22/init-checklist.md +0 -25
  2007. package/docs/2026-05-22/plan.md +0 -20
  2008. package/docs/2026-05-23/critical-issues.md +0 -20
  2009. package/docs/2026-05-23/improvements.md +0 -14
  2010. package/docs/2026-05-23/init-checklist.md +0 -25
  2011. package/docs/2026-05-23/plan.md +0 -20
  2012. package/docs/2026-05-24/critical-issues.md +0 -30
  2013. package/docs/2026-05-24/improvements.md +0 -23
  2014. package/docs/2026-05-24/init-checklist.md +0 -25
  2015. package/docs/2026-05-24/plan.md +0 -22
  2016. package/docs/2026-05-25/critical-issues.md +0 -20
  2017. package/docs/2026-05-25/improvements.md +0 -14
  2018. package/docs/2026-05-25/init-checklist.md +0 -25
  2019. package/docs/2026-05-25/plan.md +0 -20
  2020. package/docs/2026-05-26/critical-issues.md +0 -20
  2021. package/docs/2026-05-26/improvements.md +0 -14
  2022. package/docs/2026-05-26/init-checklist.md +0 -25
  2023. package/docs/2026-05-26/plan.md +0 -20
  2024. package/docs/2026-05-27/critical-issues.md +0 -20
  2025. package/docs/2026-05-27/improvements.md +0 -14
  2026. package/docs/2026-05-27/init-checklist.md +0 -25
  2027. package/docs/2026-05-27/plan.md +0 -20
  2028. package/docs/2026-05-28/critical-issues.md +0 -20
  2029. package/docs/2026-05-28/improvements.md +0 -14
  2030. package/docs/2026-05-28/init-checklist.md +0 -25
  2031. package/docs/2026-05-28/plan.md +0 -20
  2032. package/docs/2026-05-29/critical-issues.md +0 -20
  2033. package/docs/2026-05-29/improvements.md +0 -14
  2034. package/docs/2026-05-29/init-checklist.md +0 -25
  2035. package/docs/2026-05-29/plan.md +0 -20
  2036. package/docs/2026-05-30/critical-issues.md +0 -20
  2037. package/docs/2026-05-30/improvements.md +0 -14
  2038. package/docs/2026-05-30/init-checklist.md +0 -25
  2039. package/docs/2026-05-30/plan.md +0 -20
  2040. package/docs/2026-05-31/critical-issues.md +0 -20
  2041. package/docs/2026-05-31/improvements.md +0 -14
  2042. package/docs/2026-05-31/init-checklist.md +0 -25
  2043. package/docs/2026-05-31/plan.md +0 -20
  2044. package/docs/2026-06-01/critical-issues.md +0 -20
  2045. package/docs/2026-06-01/improvements.md +0 -14
  2046. package/docs/2026-06-01/init-checklist.md +0 -25
  2047. package/docs/2026-06-01/plan.md +0 -20
  2048. package/docs/2026-06-02/critical-issues.md +0 -20
  2049. package/docs/2026-06-02/improvements.md +0 -14
  2050. package/docs/2026-06-02/init-checklist.md +0 -25
  2051. package/docs/2026-06-02/plan.md +0 -20
  2052. package/docs/2026-06-03/critical-issues.md +0 -20
  2053. package/docs/2026-06-03/improvements.md +0 -14
  2054. package/docs/2026-06-03/init-checklist.md +0 -25
  2055. package/docs/2026-06-03/plan.md +0 -20
  2056. package/docs/2026-06-04/critical-issues.md +0 -20
  2057. package/docs/2026-06-04/improvements.md +0 -14
  2058. package/docs/2026-06-04/init-checklist.md +0 -25
  2059. package/docs/2026-06-04/plan.md +0 -20
  2060. package/docs/2026-06-05/critical-issues.md +0 -20
  2061. package/docs/2026-06-05/improvements.md +0 -14
  2062. package/docs/2026-06-05/init-checklist.md +0 -25
  2063. package/docs/2026-06-05/plan.md +0 -20
  2064. package/docs/2026-06-06/critical-issues.md +0 -20
  2065. package/docs/2026-06-06/improvements.md +0 -14
  2066. package/docs/2026-06-06/init-checklist.md +0 -25
  2067. package/docs/2026-06-06/plan.md +0 -20
  2068. package/docs/2026-06-07/critical-issues.md +0 -20
  2069. package/docs/2026-06-07/improvements.md +0 -14
  2070. package/docs/2026-06-07/init-checklist.md +0 -25
  2071. package/docs/2026-06-07/plan.md +0 -20
  2072. package/docs/2026-06-08/critical-issues.md +0 -20
  2073. package/docs/2026-06-08/improvements.md +0 -14
  2074. package/docs/2026-06-08/init-checklist.md +0 -25
  2075. package/docs/2026-06-08/plan.md +0 -20
  2076. package/docs/2026-06-09/critical-issues.md +0 -20
  2077. package/docs/2026-06-09/improvements.md +0 -14
  2078. package/docs/2026-06-09/init-checklist.md +0 -25
  2079. package/docs/2026-06-09/plan.md +0 -20
  2080. package/docs/2026-06-10/critical-issues.md +0 -20
  2081. package/docs/2026-06-10/improvements.md +0 -14
  2082. package/docs/2026-06-10/init-checklist.md +0 -25
  2083. package/docs/2026-06-10/plan.md +0 -20
  2084. package/docs/2026-06-11/critical-issues.md +0 -20
  2085. package/docs/2026-06-11/improvements.md +0 -14
  2086. package/docs/2026-06-11/init-checklist.md +0 -25
  2087. package/docs/2026-06-11/plan.md +0 -20
  2088. package/docs/ARCHITECTURE_ANALYSIS_CODEGRAPH.md +0 -223
  2089. package/docs/GSTACK_MIGRATION.md +0 -169
  2090. package/docs/OMK_CLI_V2_RUNTIME_ARCHITECTURE.md +0 -2058
  2091. package/docs/adr/0001-no-native-rust-lane.md +0 -52
  2092. package/docs/benchmark-design.md +0 -122
  2093. package/docs/cli-v2-migration.md +0 -87
  2094. package/docs/codex-oauth-setup.md +0 -62
  2095. package/docs/decisions/2026-06-10-git-history-bloat.md +0 -61
  2096. package/docs/decisions/ADR-theme-dark-only-assets.md +0 -43
  2097. package/docs/demo/verified-run/README.md +0 -32
  2098. package/docs/demo/verified-run/artifacts/README.md +0 -18
  2099. package/docs/demo/verified-run/capture-plan.md +0 -51
  2100. package/docs/demo/verified-run/generated-diff.md +0 -27
  2101. package/docs/demo/verified-run/raw-prompt.md +0 -21
  2102. package/docs/demo/verified-run/video-shot-list.md +0 -14
  2103. package/docs/design-md.md +0 -35
  2104. package/docs/getting-started.md +0 -65
  2105. package/docs/github-organic-promotion.md +0 -127
  2106. package/docs/headroom-omk-final-summary.md +0 -188
  2107. package/docs/headroom-omk-integration.md +0 -394
  2108. package/docs/headroom-omk-setup-guide.md +0 -422
  2109. package/docs/headroom-omk-usage-examples.md +0 -371
  2110. package/docs/hud-and-parallel-ux.md +0 -155
  2111. package/docs/integrations/ouroboros.md +0 -96
  2112. package/docs/kimi-oauth-usage-status.md +0 -33
  2113. package/docs/kimi-okabe-dmail.md +0 -44
  2114. package/docs/local-graph-memory.md +0 -102
  2115. package/docs/lsp.md +0 -48
  2116. package/docs/mcp-ontology-proposal.md +0 -12
  2117. package/docs/native-root-runtime-algorithms.md +0 -703
  2118. package/docs/native-root-runtime-hardening.md +0 -131
  2119. package/docs/neo4j-memory.md +0 -5
  2120. package/docs/openai-platform-image-keys.md +0 -23
  2121. package/docs/phase1-final-report.md +0 -154
  2122. package/docs/provider-maturity.md +0 -44
  2123. package/docs/runtime-architecture.md +0 -89
  2124. package/docs/versioning.md +0 -49
  2125. package/llms.txt +0 -38
  2126. package/readmeasset/.npmignore +0 -22
  2127. package/readmeasset/ASSET_INDEX.md +0 -39
  2128. package/readmeasset/ASSET_PROVENANCE.md +0 -110
  2129. package/readmeasset/omk-control-surfaces.svg +0 -55
  2130. package/readmeasset/omk-core-loop.svg +0 -26
  2131. package/readmeasset/omk-evidence-gate-card.png +0 -0
  2132. package/readmeasset/omk-github-banner.webp +0 -0
  2133. package/readmeasset/omk-github-header.webp +0 -0
  2134. package/readmeasset/omk-install-card.png +0 -0
  2135. package/readmeasset/omk-logo-512.png +0 -0
  2136. package/readmeasset/omk-logo-mark.svg +0 -8
  2137. package/readmeasset/omk-provider-router-card.png +0 -0
  2138. package/readmeasset/omk-release-assertions.svg +0 -51
  2139. package/readmeasset/omk-runtime-flow-0.78.0.webp +0 -0
  2140. package/readmeasset/omk-social-preview.png +0 -0
  2141. package/readmeasset/omk-tui-0.78.0.webp +0 -0
  2142. package/readmeasset/omk_tui.png +0 -0
  2143. package/templates/.kimi/AGENTS.md +0 -93
  2144. package/templates/.omk/agents/okabe.yaml +0 -30
  2145. package/templates/.omk/agents/roles/aggregator.yaml +0 -13
  2146. package/templates/.omk/agents/roles/architect.yaml +0 -13
  2147. package/templates/.omk/agents/roles/coder.yaml +0 -9
  2148. package/templates/.omk/agents/roles/explorer.yaml +0 -13
  2149. package/templates/.omk/agents/roles/integrator.yaml +0 -13
  2150. package/templates/.omk/agents/roles/interviewer.yaml +0 -13
  2151. package/templates/.omk/agents/roles/ontology.yaml +0 -18
  2152. package/templates/.omk/agents/roles/planner.yaml +0 -13
  2153. package/templates/.omk/agents/roles/qa.yaml +0 -12
  2154. package/templates/.omk/agents/roles/researcher.yaml +0 -13
  2155. package/templates/.omk/agents/roles/reviewer.yaml +0 -13
  2156. package/templates/.omk/agents/roles/router.yaml +0 -13
  2157. package/templates/.omk/agents/roles/security.yaml +0 -12
  2158. package/templates/.omk/agents/roles/tester.yaml +0 -12
  2159. package/templates/.omk/agents/roles/vision-debugger.yaml +0 -12
  2160. package/templates/.omk/agents/root.yaml +0 -62
  2161. package/templates/.omk/lsp.json +0 -27
  2162. package/templates/.omk/prompts/root.md +0 -74
  2163. package/templates/AGENTS.md +0 -510
  2164. package/templates/skills/agents/agentmemory/SKILL.md +0 -40
  2165. package/templates/skills/agents/andrej-karpathy-skills/SKILL.md +0 -41
  2166. package/templates/skills/agents/claude-for-legal/SKILL.md +0 -63
  2167. package/templates/skills/agents/claude-for-legal/references/workflow-catalog.md +0 -38
  2168. package/templates/skills/agents/matt-pocock-skills/SKILL.md +0 -40
  2169. package/templates/skills/agents/multica/SKILL.md +0 -40
  2170. package/templates/skills/agents/omk-agent-reach-websearch/SKILL.md +0 -55
  2171. package/templates/skills/agents/omk-backend-api-review/SKILL.md +0 -30
  2172. package/templates/skills/agents/omk-code-review/SKILL.md +0 -40
  2173. package/templates/skills/agents/omk-context-broker/SKILL.md +0 -57
  2174. package/templates/skills/agents/omk-control-loop-debugger/SKILL.md +0 -49
  2175. package/templates/skills/agents/omk-design-system/SKILL.md +0 -22
  2176. package/templates/skills/agents/omk-docs-release/SKILL.md +0 -42
  2177. package/templates/skills/agents/omk-evidence-contract/SKILL.md +0 -52
  2178. package/templates/skills/agents/omk-frontend-implementation/SKILL.md +0 -13
  2179. package/templates/skills/agents/omk-frontend-ui-review/SKILL.md +0 -29
  2180. package/templates/skills/agents/omk-git-commit-pr/SKILL.md +0 -45
  2181. package/templates/skills/agents/omk-industrial-control-loop/SKILL.md +0 -33
  2182. package/templates/skills/agents/omk-plan-first/SKILL.md +0 -39
  2183. package/templates/skills/agents/omk-project-rules/SKILL.md +0 -46
  2184. package/templates/skills/agents/omk-python-typing/SKILL.md +0 -33
  2185. package/templates/skills/agents/omk-quality-gate/SKILL.md +0 -54
  2186. package/templates/skills/agents/omk-repo-explorer/SKILL.md +0 -33
  2187. package/templates/skills/agents/omk-research-verify/SKILL.md +0 -30
  2188. package/templates/skills/agents/omk-secret-guard/SKILL.md +0 -23
  2189. package/templates/skills/agents/omk-security-review/SKILL.md +0 -49
  2190. package/templates/skills/agents/omk-test-debug-loop/SKILL.md +0 -43
  2191. package/templates/skills/agents/omk-troubleshooting/SKILL.md +0 -14
  2192. package/templates/skills/agents/omk-typescript-strict/SKILL.md +0 -38
  2193. package/templates/skills/agents/omk-worktree-team/SKILL.md +0 -44
  2194. package/templates/skills/agents/react-doctor/SKILL.md +0 -46
  2195. package/templates/skills/kimi/agentmemory/SKILL.md +0 -40
  2196. package/templates/skills/kimi/andrej-karpathy-skills/SKILL.md +0 -41
  2197. package/templates/skills/kimi/awesome-design-md/SKILL.md +0 -54
  2198. package/templates/skills/kimi/claude-for-legal/SKILL.md +0 -63
  2199. package/templates/skills/kimi/claude-for-legal/references/workflow-catalog.md +0 -38
  2200. package/templates/skills/kimi/deepseek-api/SKILL.md +0 -27
  2201. package/templates/skills/kimi/deepseek-disable/SKILL.md +0 -20
  2202. package/templates/skills/kimi/deepseek-enable/SKILL.md +0 -20
  2203. package/templates/skills/kimi/deepseekset/SKILL.md +0 -27
  2204. package/templates/skills/kimi/graph-view/SKILL.md +0 -29
  2205. package/templates/skills/kimi/matt-pocock-skills/SKILL.md +0 -40
  2206. package/templates/skills/kimi/multica/SKILL.md +0 -40
  2207. package/templates/skills/kimi/omk-agent-reach-websearch/SKILL.md +0 -55
  2208. package/templates/skills/kimi/omk-backend-api-review/SKILL.md +0 -30
  2209. package/templates/skills/kimi/omk-code-review/SKILL.md +0 -34
  2210. package/templates/skills/kimi/omk-context-broker/SKILL.md +0 -57
  2211. package/templates/skills/kimi/omk-control-loop-debugger/SKILL.md +0 -49
  2212. package/templates/skills/kimi/omk-design-md/SKILL.md +0 -55
  2213. package/templates/skills/kimi/omk-design-system/SKILL.md +0 -22
  2214. package/templates/skills/kimi/omk-docs-release/SKILL.md +0 -42
  2215. package/templates/skills/kimi/omk-evidence-contract/SKILL.md +0 -52
  2216. package/templates/skills/kimi/omk-flow-bugfix/SKILL.md +0 -20
  2217. package/templates/skills/kimi/omk-flow-design-to-code/SKILL.md +0 -23
  2218. package/templates/skills/kimi/omk-flow-feature-dev/SKILL.md +0 -24
  2219. package/templates/skills/kimi/omk-flow-pr-review/SKILL.md +0 -17
  2220. package/templates/skills/kimi/omk-flow-refactor/SKILL.md +0 -21
  2221. package/templates/skills/kimi/omk-flow-release/SKILL.md +0 -20
  2222. package/templates/skills/kimi/omk-flow-team-run/SKILL.md +0 -24
  2223. package/templates/skills/kimi/omk-frontend-implementation/SKILL.md +0 -13
  2224. package/templates/skills/kimi/omk-frontend-ui-review/SKILL.md +0 -29
  2225. package/templates/skills/kimi/omk-git-commit-pr/SKILL.md +0 -45
  2226. package/templates/skills/kimi/omk-global-rules/SKILL.md +0 -31
  2227. package/templates/skills/kimi/omk-industrial-control-loop/SKILL.md +0 -33
  2228. package/templates/skills/kimi/omk-kimi-runtime/SKILL.md +0 -46
  2229. package/templates/skills/kimi/omk-multimodal-ui-review/SKILL.md +0 -26
  2230. package/templates/skills/kimi/omk-plan-first/SKILL.md +0 -39
  2231. package/templates/skills/kimi/omk-project-rules/SKILL.md +0 -21
  2232. package/templates/skills/kimi/omk-python-typing/SKILL.md +0 -33
  2233. package/templates/skills/kimi/omk-quality-gate/SKILL.md +0 -36
  2234. package/templates/skills/kimi/omk-repo-explorer/SKILL.md +0 -33
  2235. package/templates/skills/kimi/omk-research-verify/SKILL.md +0 -30
  2236. package/templates/skills/kimi/omk-secret-guard/SKILL.md +0 -23
  2237. package/templates/skills/kimi/omk-security-review/SKILL.md +0 -49
  2238. package/templates/skills/kimi/omk-task-router/SKILL.md +0 -27
  2239. package/templates/skills/kimi/omk-test-debug-loop/SKILL.md +0 -43
  2240. package/templates/skills/kimi/omk-typescript-strict/SKILL.md +0 -38
  2241. package/templates/skills/kimi/omk-worktree-team/SKILL.md +0 -44
  2242. package/templates/skills/kimi/open-design/SKILL.md +0 -56
  2243. package/templates/skills/kimi/provider/SKILL.md +0 -47
  2244. package/templates/skills/kimi/react-doctor/SKILL.md +0 -46
  2245. package/templates/skills/kimi/speckit-analyze/SKILL.md +0 -255
  2246. package/templates/skills/kimi/speckit-checklist/SKILL.md +0 -367
  2247. package/templates/skills/kimi/speckit-clarify/SKILL.md +0 -249
  2248. package/templates/skills/kimi/speckit-constitution/SKILL.md +0 -152
  2249. package/templates/skills/kimi/speckit-implement/SKILL.md +0 -204
  2250. package/templates/skills/kimi/speckit-plan/SKILL.md +0 -147
  2251. package/templates/skills/kimi/speckit-specify/SKILL.md +0 -325
  2252. package/templates/skills/kimi/speckit-tasks/SKILL.md +0 -197
  2253. package/templates/skills/kimi/speckit-taskstoissues/SKILL.md +0 -101
  2254. package/templates/skills/kimi/think/SKILL.md +0 -41
  2255. package/templates/spec-kit-omk-preset/commands/plan.md +0 -21
  2256. package/templates/spec-kit-omk-preset/commands/tasks.md +0 -21
  2257. package/templates/spec-kit-omk-preset/preset.yml +0 -12
  2258. package/templates/spec-kit-omk-preset/templates/plan-template.md +0 -75
  2259. package/templates/spec-kit-omk-preset/templates/spec-template.md +0 -80
  2260. package/templates/spec-kit-omk-preset/templates/tasks-template.md +0 -160
  2261. package/templates/web-bridge/chrome-extension/README.md +0 -18
  2262. package/templates/web-bridge/chrome-extension/background.js +0 -57
  2263. package/templates/web-bridge/chrome-extension/content-script.js +0 -46
  2264. package/templates/web-bridge/chrome-extension/manifest.json +0 -16
  2265. package/templates/web-bridge/chrome-extension/popup.html +0 -21
  2266. package/templates/web-bridge/chrome-extension/popup.js +0 -9
  2267. /package/{readmeasset → dist/modes/interactive/assets}/omk-control.webp +0 -0
@@ -0,0 +1,2535 @@
1
+ /**
2
+ * AgentSession - Core abstraction for agent lifecycle and session management.
3
+ *
4
+ * This class is shared between all run modes (interactive, print, rpc).
5
+ * It encapsulates:
6
+ * - Agent state access
7
+ * - Event subscription with automatic session persistence
8
+ * - Model and thinking level management
9
+ * - Compaction (manual and auto)
10
+ * - Bash execution
11
+ * - Session switching and branching
12
+ *
13
+ * Modes use this class and add their own I/O layer on top.
14
+ */
15
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
16
+ import { basename, dirname } from "node:path";
17
+ import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, modelsAreEqual, resetApiProviders, streamSimple, } from "@earendil-works/omk-ai";
18
+ import { theme } from "../modes/interactive/theme/theme.js";
19
+ import { stripFrontmatter } from "../utils/frontmatter.js";
20
+ import { resolvePath } from "../utils/paths.js";
21
+ import { sleep } from "../utils/sleep.js";
22
+ import { resolveAdaptiveHeadroomThreshold } from "./adaptive-runtime.js";
23
+ import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
24
+ import { executeBashWithOperations } from "./bash-executor.js";
25
+ import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
26
+ import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
27
+ import { exportSessionToHtml } from "./export-html/index.js";
28
+ import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
29
+ import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
30
+ import { emitSessionShutdownEvent } from "./extensions/runner.js";
31
+ import { expandPromptTemplate } from "./prompt-templates.js";
32
+ import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
33
+ import { createSyntheticSourceInfo } from "./source-info.js";
34
+ import { buildSystemPrompt } from "./system-prompt.js";
35
+ import { createLocalBashOperations } from "./tools/bash.js";
36
+ import { createAllToolDefinitions } from "./tools/index.js";
37
+ import { createToolDefinitionFromAgentTool } from "./tools/tool-definition-wrapper.js";
38
+ /**
39
+ * Parse a skill block from message text.
40
+ * Returns null if the text doesn't contain a skill block.
41
+ */
42
+ export function parseSkillBlock(text) {
43
+ const match = text.match(/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/);
44
+ if (!match)
45
+ return null;
46
+ return {
47
+ name: match[1],
48
+ location: match[2],
49
+ content: match[3],
50
+ userMessage: match[4]?.trim() || undefined,
51
+ };
52
+ }
53
+ // ============================================================================
54
+ // Constants
55
+ // ============================================================================
56
+ /** Standard thinking levels */
57
+ const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
58
+ // ============================================================================
59
+ // AgentSession Class
60
+ // ============================================================================
61
+ export class AgentSession {
62
+ agent;
63
+ sessionManager;
64
+ settingsManager;
65
+ _scopedModels;
66
+ // Event subscription state
67
+ _unsubscribeAgent;
68
+ _eventListeners = [];
69
+ /** Tracks pending steering messages for UI display. Removed when delivered. */
70
+ _steeringMessages = [];
71
+ /** Tracks pending follow-up messages for UI display. Removed when delivered. */
72
+ _followUpMessages = [];
73
+ /** Messages queued to be included with the next user prompt as context ("asides"). */
74
+ _pendingNextTurnMessages = [];
75
+ // Compaction state
76
+ _compactionAbortController = undefined;
77
+ _autoCompactionAbortController = undefined;
78
+ _overflowRecoveryAttempted = false;
79
+ // Branch summarization state
80
+ _branchSummaryAbortController = undefined;
81
+ // Retry state
82
+ _retryAbortController = undefined;
83
+ _retryAttempt = 0;
84
+ // Bash execution state
85
+ _bashAbortController = undefined;
86
+ _pendingBashMessages = [];
87
+ // Extension system
88
+ _extensionRunner;
89
+ _turnIndex = 0;
90
+ _resourceLoader;
91
+ _customTools;
92
+ _baseToolDefinitions = new Map();
93
+ _cwd;
94
+ _extensionRunnerRef;
95
+ _initialActiveToolNames;
96
+ _allowedToolNames;
97
+ _excludedToolNames;
98
+ _baseToolsOverride;
99
+ _sessionStartEvent;
100
+ _extensionUIContext;
101
+ _extensionMode = "print";
102
+ _extensionCommandContextActions;
103
+ _extensionAbortHandler;
104
+ _extensionShutdownHandler;
105
+ _extensionErrorListener;
106
+ _extensionErrorUnsubscriber;
107
+ // Model registry for API key resolution
108
+ _modelRegistry;
109
+ // Tool registry for extension getTools/setTools
110
+ _toolRegistry = new Map();
111
+ _toolDefinitions = new Map();
112
+ _toolPromptSnippets = new Map();
113
+ _toolPromptGuidelines = new Map();
114
+ // Base system prompt (without extension appends) - used to apply fresh appends each turn
115
+ _baseSystemPrompt = "";
116
+ _baseSystemPromptOptions;
117
+ constructor(config) {
118
+ this.agent = config.agent;
119
+ this.sessionManager = config.sessionManager;
120
+ this.settingsManager = config.settingsManager;
121
+ this._scopedModels = config.scopedModels ?? [];
122
+ this._resourceLoader = config.resourceLoader;
123
+ this._customTools = config.customTools ?? [];
124
+ this._cwd = config.cwd;
125
+ this._modelRegistry = config.modelRegistry;
126
+ this._extensionRunnerRef = config.extensionRunnerRef;
127
+ this._initialActiveToolNames = config.initialActiveToolNames;
128
+ this._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;
129
+ this._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;
130
+ this._baseToolsOverride = config.baseToolsOverride;
131
+ this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
132
+ // Always subscribe to agent events for internal handling
133
+ // (session persistence, extensions, auto-compaction, retry logic)
134
+ this._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);
135
+ this._installAgentToolHooks();
136
+ this._buildRuntime({
137
+ activeToolNames: this._initialActiveToolNames,
138
+ includeAllExtensionTools: true,
139
+ });
140
+ }
141
+ /** Model registry for API key resolution and model discovery */
142
+ get modelRegistry() {
143
+ return this._modelRegistry;
144
+ }
145
+ async _getRequiredRequestAuth(model) {
146
+ const result = await this._modelRegistry.getApiKeyAndHeaders(model);
147
+ if (!result.ok) {
148
+ if (result.error.startsWith("No API key found")) {
149
+ throw new Error(formatNoApiKeyFoundMessage(model.provider));
150
+ }
151
+ throw new Error(result.error);
152
+ }
153
+ if (result.apiKey) {
154
+ return { apiKey: result.apiKey, headers: result.headers };
155
+ }
156
+ const isOAuth = this._modelRegistry.isUsingOAuth(model);
157
+ if (isOAuth) {
158
+ throw new Error(`Authentication failed for "${model.provider}". ` +
159
+ `Credentials may have expired or network is unavailable. ` +
160
+ `Run '/login ${model.provider}' to re-authenticate.`);
161
+ }
162
+ throw new Error(formatNoApiKeyFoundMessage(model.provider));
163
+ }
164
+ async _getCompactionRequestAuth(model) {
165
+ if (this.agent.streamFn === streamSimple) {
166
+ return this._getRequiredRequestAuth(model);
167
+ }
168
+ const result = await this._modelRegistry.getApiKeyAndHeaders(model);
169
+ return result.ok ? { apiKey: result.apiKey, headers: result.headers } : {};
170
+ }
171
+ /**
172
+ * Install tool hooks once on the Agent instance.
173
+ *
174
+ * The callbacks read `this._extensionRunner` at execution time, so extension reload swaps in the
175
+ * new runner without reinstalling hooks. Extension-specific tool wrappers are still used to adapt
176
+ * registered tool execution to the extension context. Tool call and tool result interception now
177
+ * happens here instead of in wrappers.
178
+ */
179
+ _installAgentToolHooks() {
180
+ this.agent.beforeToolCall = async ({ toolCall, args }) => {
181
+ const runner = this._extensionRunner;
182
+ if (!runner.hasHandlers("tool_call")) {
183
+ return undefined;
184
+ }
185
+ try {
186
+ return await runner.emitToolCall({
187
+ type: "tool_call",
188
+ toolName: toolCall.name,
189
+ toolCallId: toolCall.id,
190
+ input: args,
191
+ });
192
+ }
193
+ catch (err) {
194
+ if (err instanceof Error) {
195
+ throw err;
196
+ }
197
+ throw new Error(`Extension failed, blocking execution: ${String(err)}`);
198
+ }
199
+ };
200
+ this.agent.afterToolCall = async ({ toolCall, args, result, isError }) => {
201
+ const runner = this._extensionRunner;
202
+ if (!runner.hasHandlers("tool_result")) {
203
+ return undefined;
204
+ }
205
+ const hookResult = await runner.emitToolResult({
206
+ type: "tool_result",
207
+ toolName: toolCall.name,
208
+ toolCallId: toolCall.id,
209
+ input: args,
210
+ content: result.content,
211
+ details: result.details,
212
+ isError,
213
+ });
214
+ if (!hookResult) {
215
+ return undefined;
216
+ }
217
+ return {
218
+ content: hookResult.content,
219
+ details: hookResult.details,
220
+ isError: hookResult.isError ?? isError,
221
+ };
222
+ };
223
+ }
224
+ // =========================================================================
225
+ // Event Subscription
226
+ // =========================================================================
227
+ /** Emit an event to all listeners */
228
+ _emit(event) {
229
+ for (const l of this._eventListeners) {
230
+ l(event);
231
+ }
232
+ }
233
+ _emitQueueUpdate() {
234
+ this._emit({
235
+ type: "queue_update",
236
+ steering: [...this._steeringMessages],
237
+ followUp: [...this._followUpMessages],
238
+ });
239
+ }
240
+ // Track last assistant message for auto-compaction check
241
+ _lastAssistantMessage = undefined;
242
+ /** Internal handler for agent events - shared by subscribe and reconnect */
243
+ _handleAgentEvent = async (event) => {
244
+ // When a user message starts, check if it's from either queue and remove it BEFORE emitting
245
+ // This ensures the UI sees the updated queue state
246
+ if (event.type === "message_start" && event.message.role === "user") {
247
+ this._overflowRecoveryAttempted = false;
248
+ const messageText = this._getUserMessageText(event.message);
249
+ if (messageText) {
250
+ // Check steering queue first
251
+ const steeringIndex = this._steeringMessages.indexOf(messageText);
252
+ if (steeringIndex !== -1) {
253
+ this._steeringMessages.splice(steeringIndex, 1);
254
+ this._emitQueueUpdate();
255
+ }
256
+ else {
257
+ // Check follow-up queue
258
+ const followUpIndex = this._followUpMessages.indexOf(messageText);
259
+ if (followUpIndex !== -1) {
260
+ this._followUpMessages.splice(followUpIndex, 1);
261
+ this._emitQueueUpdate();
262
+ }
263
+ }
264
+ }
265
+ }
266
+ // Emit to extensions first
267
+ await this._emitExtensionEvent(event);
268
+ // Notify all listeners
269
+ this._emit(event.type === "agent_end" ? { ...event, willRetry: this._willRetryAfterAgentEnd(event) } : event);
270
+ // Handle session persistence
271
+ if (event.type === "message_end") {
272
+ // Check if this is a custom message from extensions
273
+ if (event.message.role === "custom") {
274
+ // Persist as CustomMessageEntry
275
+ this.sessionManager.appendCustomMessageEntry(event.message.customType, event.message.content, event.message.display, event.message.details);
276
+ }
277
+ else if (event.message.role === "user" ||
278
+ event.message.role === "assistant" ||
279
+ event.message.role === "toolResult") {
280
+ // Regular LLM message - persist as SessionMessageEntry
281
+ this.sessionManager.appendMessage(event.message);
282
+ }
283
+ // Other message types (bashExecution, compactionSummary, branchSummary) are persisted elsewhere
284
+ // Track assistant message for auto-compaction (checked on agent_end)
285
+ if (event.message.role === "assistant") {
286
+ this._lastAssistantMessage = event.message;
287
+ const assistantMsg = event.message;
288
+ if (assistantMsg.stopReason !== "error") {
289
+ this._overflowRecoveryAttempted = false;
290
+ }
291
+ // Reset retry counter immediately on successful assistant response
292
+ // This prevents accumulation across multiple LLM calls within a turn
293
+ if (assistantMsg.stopReason !== "error" && this._retryAttempt > 0) {
294
+ this._emit({
295
+ type: "auto_retry_end",
296
+ success: true,
297
+ attempt: this._retryAttempt,
298
+ });
299
+ this._retryAttempt = 0;
300
+ }
301
+ }
302
+ }
303
+ };
304
+ _willRetryAfterAgentEnd(event) {
305
+ const settings = this.settingsManager.getRetrySettings();
306
+ if (!settings.enabled || this._retryAttempt >= settings.maxRetries) {
307
+ return false;
308
+ }
309
+ for (let i = event.messages.length - 1; i >= 0; i--) {
310
+ const message = event.messages[i];
311
+ if (message.role === "assistant") {
312
+ return this._isRetryableError(message);
313
+ }
314
+ }
315
+ return false;
316
+ }
317
+ /** Extract text content from a message */
318
+ _getUserMessageText(message) {
319
+ if (message.role !== "user")
320
+ return "";
321
+ const content = message.content;
322
+ if (typeof content === "string")
323
+ return content;
324
+ const textBlocks = content.filter((c) => c.type === "text");
325
+ return textBlocks.map((c) => c.text).join("");
326
+ }
327
+ /** Find the last assistant message in agent state (including aborted ones) */
328
+ _findLastAssistantMessage() {
329
+ const messages = this.agent.state.messages;
330
+ for (let i = messages.length - 1; i >= 0; i--) {
331
+ const msg = messages[i];
332
+ if (msg.role === "assistant") {
333
+ return msg;
334
+ }
335
+ }
336
+ return undefined;
337
+ }
338
+ _replaceMessageInPlace(target, replacement) {
339
+ // Agent-core stores the finalized message object in its state before emitting message_end.
340
+ // SessionManager persistence happens later in _handleAgentEvent() with event.message.
341
+ // Mutating this object in place keeps agent state, later turn/agent events, listeners,
342
+ // and the eventual SessionManager.appendMessage(event.message) persistence in sync.
343
+ if (target === replacement) {
344
+ return;
345
+ }
346
+ const targetRecord = target;
347
+ for (const key of Object.keys(targetRecord)) {
348
+ delete targetRecord[key];
349
+ }
350
+ Object.assign(targetRecord, replacement);
351
+ }
352
+ /** Emit extension events based on agent events */
353
+ async _emitExtensionEvent(event) {
354
+ if (event.type === "agent_start") {
355
+ this._turnIndex = 0;
356
+ await this._extensionRunner.emit({ type: "agent_start" });
357
+ }
358
+ else if (event.type === "agent_end") {
359
+ await this._extensionRunner.emit({ type: "agent_end", messages: event.messages });
360
+ }
361
+ else if (event.type === "turn_start") {
362
+ const extensionEvent = {
363
+ type: "turn_start",
364
+ turnIndex: this._turnIndex,
365
+ timestamp: Date.now(),
366
+ };
367
+ await this._extensionRunner.emit(extensionEvent);
368
+ }
369
+ else if (event.type === "turn_end") {
370
+ const extensionEvent = {
371
+ type: "turn_end",
372
+ turnIndex: this._turnIndex,
373
+ message: event.message,
374
+ toolResults: event.toolResults,
375
+ };
376
+ await this._extensionRunner.emit(extensionEvent);
377
+ this._turnIndex++;
378
+ }
379
+ else if (event.type === "message_start") {
380
+ const extensionEvent = {
381
+ type: "message_start",
382
+ message: event.message,
383
+ };
384
+ await this._extensionRunner.emit(extensionEvent);
385
+ }
386
+ else if (event.type === "message_update") {
387
+ const extensionEvent = {
388
+ type: "message_update",
389
+ message: event.message,
390
+ assistantMessageEvent: event.assistantMessageEvent,
391
+ };
392
+ await this._extensionRunner.emit(extensionEvent);
393
+ }
394
+ else if (event.type === "message_end") {
395
+ const extensionEvent = {
396
+ type: "message_end",
397
+ message: event.message,
398
+ };
399
+ const replacement = await this._extensionRunner.emitMessageEnd(extensionEvent);
400
+ if (replacement) {
401
+ this._replaceMessageInPlace(event.message, replacement);
402
+ }
403
+ }
404
+ else if (event.type === "tool_execution_start") {
405
+ const extensionEvent = {
406
+ type: "tool_execution_start",
407
+ toolCallId: event.toolCallId,
408
+ toolName: event.toolName,
409
+ args: event.args,
410
+ };
411
+ await this._extensionRunner.emit(extensionEvent);
412
+ }
413
+ else if (event.type === "tool_execution_update") {
414
+ const extensionEvent = {
415
+ type: "tool_execution_update",
416
+ toolCallId: event.toolCallId,
417
+ toolName: event.toolName,
418
+ args: event.args,
419
+ partialResult: event.partialResult,
420
+ };
421
+ await this._extensionRunner.emit(extensionEvent);
422
+ }
423
+ else if (event.type === "tool_execution_end") {
424
+ const extensionEvent = {
425
+ type: "tool_execution_end",
426
+ toolCallId: event.toolCallId,
427
+ toolName: event.toolName,
428
+ result: event.result,
429
+ isError: event.isError,
430
+ };
431
+ await this._extensionRunner.emit(extensionEvent);
432
+ }
433
+ }
434
+ /**
435
+ * Subscribe to agent events.
436
+ * Session persistence is handled internally (saves messages on message_end).
437
+ * Multiple listeners can be added. Returns unsubscribe function for this listener.
438
+ */
439
+ subscribe(listener) {
440
+ this._eventListeners.push(listener);
441
+ // Return unsubscribe function for this specific listener
442
+ return () => {
443
+ const index = this._eventListeners.indexOf(listener);
444
+ if (index !== -1) {
445
+ this._eventListeners.splice(index, 1);
446
+ }
447
+ };
448
+ }
449
+ /**
450
+ * Temporarily disconnect from agent events.
451
+ * User listeners are preserved and will receive events again after resubscribe().
452
+ * Used internally during operations that need to pause event processing.
453
+ */
454
+ _disconnectFromAgent() {
455
+ if (this._unsubscribeAgent) {
456
+ this._unsubscribeAgent();
457
+ this._unsubscribeAgent = undefined;
458
+ }
459
+ }
460
+ /**
461
+ * Reconnect to agent events after _disconnectFromAgent().
462
+ * Preserves all existing listeners.
463
+ */
464
+ _reconnectToAgent() {
465
+ if (this._unsubscribeAgent)
466
+ return; // Already connected
467
+ this._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);
468
+ }
469
+ /**
470
+ * Remove all listeners and disconnect from agent.
471
+ * Call this when completely done with the session.
472
+ */
473
+ dispose() {
474
+ try {
475
+ this.abortRetry();
476
+ this.abortCompaction();
477
+ this.abortBranchSummary();
478
+ this.abortBash();
479
+ this.agent.abort();
480
+ }
481
+ catch {
482
+ // Dispose must succeed even if an abort hook throws.
483
+ }
484
+ this._extensionRunner.invalidate("This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().");
485
+ this._disconnectFromAgent();
486
+ this._eventListeners = [];
487
+ cleanupSessionResources(this.sessionId);
488
+ }
489
+ // =========================================================================
490
+ // Read-only State Access
491
+ // =========================================================================
492
+ /** Full agent state */
493
+ get state() {
494
+ return this.agent.state;
495
+ }
496
+ /** Current model (may be undefined if not yet selected) */
497
+ get model() {
498
+ return this.agent.state.model;
499
+ }
500
+ /** Current thinking level */
501
+ get thinkingLevel() {
502
+ return this.agent.state.thinkingLevel;
503
+ }
504
+ /** Whether agent is currently streaming a response */
505
+ get isStreaming() {
506
+ return this.agent.state.isStreaming;
507
+ }
508
+ /** Current effective system prompt (includes any per-turn extension modifications) */
509
+ get systemPrompt() {
510
+ return this.agent.state.systemPrompt;
511
+ }
512
+ /** Current retry attempt (0 if not retrying) */
513
+ get retryAttempt() {
514
+ return this._retryAttempt;
515
+ }
516
+ /**
517
+ * Get the names of currently active tools.
518
+ * Returns the names of tools currently set on the agent.
519
+ */
520
+ getActiveToolNames() {
521
+ return this.agent.state.tools.map((t) => t.name);
522
+ }
523
+ /**
524
+ * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.
525
+ */
526
+ getAllTools() {
527
+ return Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({
528
+ name: definition.name,
529
+ description: definition.description,
530
+ parameters: definition.parameters,
531
+ promptGuidelines: definition.promptGuidelines,
532
+ sourceInfo,
533
+ }));
534
+ }
535
+ getToolDefinition(name) {
536
+ return this._toolDefinitions.get(name)?.definition;
537
+ }
538
+ /**
539
+ * Set active tools by name.
540
+ * Only tools in the registry can be enabled. Unknown tool names are ignored.
541
+ * Also rebuilds the system prompt to reflect the new tool set.
542
+ * Changes take effect on the next agent turn.
543
+ */
544
+ setActiveToolsByName(toolNames) {
545
+ const tools = [];
546
+ const validToolNames = [];
547
+ for (const name of toolNames) {
548
+ const tool = this._toolRegistry.get(name);
549
+ if (tool) {
550
+ tools.push(tool);
551
+ validToolNames.push(name);
552
+ }
553
+ }
554
+ this.agent.state.tools = tools;
555
+ // Rebuild base system prompt with new tool set
556
+ this._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);
557
+ this.agent.state.systemPrompt = this._baseSystemPrompt;
558
+ }
559
+ /** Whether compaction or branch summarization is currently running */
560
+ get isCompacting() {
561
+ return (this._autoCompactionAbortController !== undefined ||
562
+ this._compactionAbortController !== undefined ||
563
+ this._branchSummaryAbortController !== undefined);
564
+ }
565
+ /** All messages including custom types like BashExecutionMessage */
566
+ get messages() {
567
+ return this.agent.state.messages;
568
+ }
569
+ /** Current steering mode */
570
+ get steeringMode() {
571
+ return this.agent.steeringMode;
572
+ }
573
+ /** Current follow-up mode */
574
+ get followUpMode() {
575
+ return this.agent.followUpMode;
576
+ }
577
+ /** Current session file path, or undefined if sessions are disabled */
578
+ get sessionFile() {
579
+ return this.sessionManager.getSessionFile();
580
+ }
581
+ /** Current session ID */
582
+ get sessionId() {
583
+ return this.sessionManager.getSessionId();
584
+ }
585
+ /** Current session display name, if set */
586
+ get sessionName() {
587
+ return this.sessionManager.getSessionName();
588
+ }
589
+ /** Scoped models for cycling (from --models flag) */
590
+ get scopedModels() {
591
+ return this._scopedModels;
592
+ }
593
+ /** Update scoped models for cycling */
594
+ setScopedModels(scopedModels) {
595
+ this._scopedModels = scopedModels;
596
+ }
597
+ /** File-based prompt templates */
598
+ get promptTemplates() {
599
+ return this._resourceLoader.getPrompts().prompts;
600
+ }
601
+ _normalizePromptSnippet(text) {
602
+ if (!text)
603
+ return undefined;
604
+ const oneLine = text
605
+ .replace(/[\r\n]+/g, " ")
606
+ .replace(/\s+/g, " ")
607
+ .trim();
608
+ return oneLine.length > 0 ? oneLine : undefined;
609
+ }
610
+ _normalizePromptGuidelines(guidelines) {
611
+ if (!guidelines || guidelines.length === 0) {
612
+ return [];
613
+ }
614
+ const unique = new Set();
615
+ for (const guideline of guidelines) {
616
+ const normalized = guideline.trim();
617
+ if (normalized.length > 0) {
618
+ unique.add(normalized);
619
+ }
620
+ }
621
+ return Array.from(unique);
622
+ }
623
+ _rebuildSystemPrompt(toolNames) {
624
+ const validToolNames = toolNames.filter((name) => this._toolRegistry.has(name));
625
+ const toolSnippets = {};
626
+ const promptGuidelines = [];
627
+ for (const name of validToolNames) {
628
+ const snippet = this._toolPromptSnippets.get(name);
629
+ if (snippet) {
630
+ toolSnippets[name] = snippet;
631
+ }
632
+ const toolGuidelines = this._toolPromptGuidelines.get(name);
633
+ if (toolGuidelines) {
634
+ promptGuidelines.push(...toolGuidelines);
635
+ }
636
+ }
637
+ const loaderSystemPrompt = this._resourceLoader.getSystemPrompt();
638
+ const loaderAppendSystemPrompt = this._resourceLoader.getAppendSystemPrompt();
639
+ const appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join("\n\n") : undefined;
640
+ const loadedSkills = this._resourceLoader.getSkills().skills;
641
+ const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
642
+ this._baseSystemPromptOptions = {
643
+ cwd: this._cwd,
644
+ skills: loadedSkills,
645
+ contextFiles: loadedContextFiles,
646
+ customPrompt: loaderSystemPrompt,
647
+ appendSystemPrompt,
648
+ selectedTools: validToolNames,
649
+ toolSnippets,
650
+ promptGuidelines,
651
+ };
652
+ return buildSystemPrompt(this._baseSystemPromptOptions);
653
+ }
654
+ // =========================================================================
655
+ // Prompting
656
+ // =========================================================================
657
+ async _runAgentPrompt(messages) {
658
+ try {
659
+ await this.agent.prompt(messages);
660
+ while (await this._handlePostAgentRun()) {
661
+ await this.agent.continue();
662
+ }
663
+ }
664
+ finally {
665
+ this._flushPendingBashMessages();
666
+ }
667
+ }
668
+ async _handlePostAgentRun() {
669
+ const msg = this._lastAssistantMessage;
670
+ this._lastAssistantMessage = undefined;
671
+ if (!msg) {
672
+ return false;
673
+ }
674
+ if (this._isRetryableError(msg) && (await this._prepareRetry(msg))) {
675
+ return true;
676
+ }
677
+ if (msg.stopReason === "error" && this._retryAttempt > 0) {
678
+ this._emit({
679
+ type: "auto_retry_end",
680
+ success: false,
681
+ attempt: this._retryAttempt,
682
+ finalError: msg.errorMessage,
683
+ });
684
+ this._retryAttempt = 0;
685
+ }
686
+ if (await this._checkCompaction(msg)) {
687
+ return true;
688
+ }
689
+ // The agent loop drains both queues before emitting agent_end. Any messages
690
+ // here were queued by agent_end extension handlers and need a continuation.
691
+ return this.agent.hasQueuedMessages();
692
+ }
693
+ /**
694
+ * Send a prompt to the agent.
695
+ * - Handles extension commands (registered via pi.registerCommand) immediately, even during streaming
696
+ * - Expands file-based prompt templates by default
697
+ * - During streaming, queues via steer() or followUp() based on streamingBehavior option
698
+ * - Validates model and API key before sending (when not streaming)
699
+ * @throws Error if streaming and no streamingBehavior specified
700
+ * @throws Error if no model selected or no API key available (when not streaming)
701
+ */
702
+ async prompt(text, options) {
703
+ const expandPromptTemplates = options?.expandPromptTemplates ?? true;
704
+ const preflightResult = options?.preflightResult;
705
+ let messages;
706
+ try {
707
+ // Handle extension commands first (execute immediately, even during streaming)
708
+ // Extension commands manage their own LLM interaction via pi.sendMessage()
709
+ if (expandPromptTemplates && text.startsWith("/")) {
710
+ const handled = await this._tryExecuteExtensionCommand(text);
711
+ if (handled) {
712
+ // Extension command executed, no prompt to send
713
+ preflightResult?.(true);
714
+ return;
715
+ }
716
+ }
717
+ // Emit input event for extension interception (before skill/template expansion)
718
+ let currentText = text;
719
+ let currentImages = options?.images;
720
+ if (this._extensionRunner.hasHandlers("input")) {
721
+ const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive", this.isStreaming ? options?.streamingBehavior : undefined);
722
+ if (inputResult.action === "handled") {
723
+ preflightResult?.(true);
724
+ return;
725
+ }
726
+ if (inputResult.action === "transform") {
727
+ currentText = inputResult.text;
728
+ currentImages = inputResult.images ?? currentImages;
729
+ }
730
+ }
731
+ // Expand skill commands (/skill:name args) and prompt templates (/template args)
732
+ let expandedText = currentText;
733
+ if (expandPromptTemplates) {
734
+ expandedText = this._expandSkillCommand(expandedText);
735
+ expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
736
+ }
737
+ // If streaming, queue via steer() or followUp() based on option
738
+ if (this.isStreaming) {
739
+ if (!options?.streamingBehavior) {
740
+ throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
741
+ }
742
+ if (options.streamingBehavior === "followUp") {
743
+ await this._queueFollowUp(expandedText, currentImages);
744
+ }
745
+ else {
746
+ await this._queueSteer(expandedText, currentImages);
747
+ }
748
+ preflightResult?.(true);
749
+ return;
750
+ }
751
+ // Flush any pending bash messages before the new prompt
752
+ this._flushPendingBashMessages();
753
+ // Validate model
754
+ if (!this.model) {
755
+ throw new Error(formatNoModelSelectedMessage());
756
+ }
757
+ if (!this._modelRegistry.hasConfiguredAuth(this.model)) {
758
+ const isOAuth = this._modelRegistry.isUsingOAuth(this.model);
759
+ if (isOAuth) {
760
+ throw new Error(`Authentication failed for "${this.model.provider}". ` +
761
+ `Credentials may have expired or network is unavailable. ` +
762
+ `Run '/login ${this.model.provider}' to re-authenticate.`);
763
+ }
764
+ throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
765
+ }
766
+ // Check if we need to compact before sending (catches aborted responses)
767
+ const lastAssistant = this._findLastAssistantMessage();
768
+ if (lastAssistant && (await this._checkCompaction(lastAssistant, false))) {
769
+ try {
770
+ await this.agent.continue();
771
+ while (await this._handlePostAgentRun()) {
772
+ await this.agent.continue();
773
+ }
774
+ }
775
+ finally {
776
+ this._flushPendingBashMessages();
777
+ }
778
+ }
779
+ // Build messages array (custom message if any, then user message)
780
+ messages = [];
781
+ // Add user message
782
+ const userContent = [{ type: "text", text: expandedText }];
783
+ if (currentImages) {
784
+ userContent.push(...currentImages);
785
+ }
786
+ messages.push({
787
+ role: "user",
788
+ content: userContent,
789
+ timestamp: Date.now(),
790
+ });
791
+ // Inject any pending "nextTurn" messages as context alongside the user message
792
+ for (const msg of this._pendingNextTurnMessages) {
793
+ messages.push(msg);
794
+ }
795
+ this._pendingNextTurnMessages = [];
796
+ // Emit before_agent_start extension event
797
+ const result = await this._extensionRunner.emitBeforeAgentStart(expandedText, currentImages, this._baseSystemPrompt, this._baseSystemPromptOptions);
798
+ // Add all custom messages from extensions
799
+ if (result?.messages) {
800
+ for (const msg of result.messages) {
801
+ messages.push({
802
+ role: "custom",
803
+ customType: msg.customType,
804
+ content: msg.content,
805
+ display: msg.display,
806
+ details: msg.details,
807
+ timestamp: Date.now(),
808
+ });
809
+ }
810
+ }
811
+ // Apply extension-modified system prompt, or reset to base
812
+ if (result?.systemPrompt) {
813
+ this.agent.state.systemPrompt = result.systemPrompt;
814
+ }
815
+ else {
816
+ // Ensure we're using the base prompt (in case previous turn had modifications)
817
+ this.agent.state.systemPrompt = this._baseSystemPrompt;
818
+ }
819
+ }
820
+ catch (error) {
821
+ preflightResult?.(false);
822
+ throw error;
823
+ }
824
+ if (!messages) {
825
+ return;
826
+ }
827
+ preflightResult?.(true);
828
+ await this._runAgentPrompt(messages);
829
+ }
830
+ /**
831
+ * Try to execute an extension command. Returns true if command was found and executed.
832
+ */
833
+ async _tryExecuteExtensionCommand(text) {
834
+ // Parse command name and args
835
+ const spaceIndex = text.indexOf(" ");
836
+ const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
837
+ const args = spaceIndex === -1 ? "" : text.slice(spaceIndex + 1);
838
+ const command = this._extensionRunner.getCommand(commandName);
839
+ if (!command)
840
+ return false;
841
+ // Get command context from extension runner (includes session control methods)
842
+ const ctx = this._extensionRunner.createCommandContext();
843
+ try {
844
+ await command.handler(args, ctx);
845
+ return true;
846
+ }
847
+ catch (err) {
848
+ // Emit error via extension runner
849
+ this._extensionRunner.emitError({
850
+ extensionPath: `command:${commandName}`,
851
+ event: "command",
852
+ error: err instanceof Error ? err.message : String(err),
853
+ });
854
+ return true;
855
+ }
856
+ }
857
+ /**
858
+ * Expand skill commands (/skill:name args) to their full content.
859
+ * Returns the expanded text, or the original text if not a skill command or skill not found.
860
+ * Emits errors via extension runner if file read fails.
861
+ */
862
+ _expandSkillCommand(text) {
863
+ if (!text.startsWith("/skill:"))
864
+ return text;
865
+ const spaceIndex = text.indexOf(" ");
866
+ const skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);
867
+ const args = spaceIndex === -1 ? "" : text.slice(spaceIndex + 1).trim();
868
+ const skill = this.resourceLoader.getSkills().skills.find((s) => s.name === skillName);
869
+ if (!skill)
870
+ return text; // Unknown skill, pass through
871
+ try {
872
+ const content = readFileSync(skill.filePath, "utf-8");
873
+ const body = stripFrontmatter(content).trim();
874
+ const skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">\nReferences are relative to ${skill.baseDir}.\n\n${body}\n</skill>`;
875
+ return args ? `${skillBlock}\n\n${args}` : skillBlock;
876
+ }
877
+ catch (err) {
878
+ // Emit error like extension commands do
879
+ this._extensionRunner.emitError({
880
+ extensionPath: skill.filePath,
881
+ event: "skill_expansion",
882
+ error: err instanceof Error ? err.message : String(err),
883
+ });
884
+ return text; // Return original on error
885
+ }
886
+ }
887
+ /**
888
+ * Queue a steering message while the agent is running.
889
+ * Delivered after the current assistant turn finishes executing its tool calls,
890
+ * before the next LLM call.
891
+ * Expands skill commands and prompt templates. Errors on extension commands.
892
+ * @param images Optional image attachments to include with the message
893
+ * @throws Error if text is an extension command
894
+ */
895
+ async steer(text, images) {
896
+ // Check for extension commands (cannot be queued)
897
+ if (text.startsWith("/")) {
898
+ this._throwIfExtensionCommand(text);
899
+ }
900
+ // Expand skill commands and prompt templates
901
+ let expandedText = this._expandSkillCommand(text);
902
+ expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
903
+ await this._queueSteer(expandedText, images);
904
+ }
905
+ /**
906
+ * Queue a follow-up message to be processed after the agent finishes.
907
+ * Delivered only when agent has no more tool calls or steering messages.
908
+ * Expands skill commands and prompt templates. Errors on extension commands.
909
+ * @param images Optional image attachments to include with the message
910
+ * @throws Error if text is an extension command
911
+ */
912
+ async followUp(text, images) {
913
+ // Check for extension commands (cannot be queued)
914
+ if (text.startsWith("/")) {
915
+ this._throwIfExtensionCommand(text);
916
+ }
917
+ // Expand skill commands and prompt templates
918
+ let expandedText = this._expandSkillCommand(text);
919
+ expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
920
+ await this._queueFollowUp(expandedText, images);
921
+ }
922
+ /**
923
+ * Internal: Queue a steering message (already expanded, no extension command check).
924
+ */
925
+ async _queueSteer(text, images) {
926
+ this._steeringMessages.push(text);
927
+ this._emitQueueUpdate();
928
+ const content = [{ type: "text", text }];
929
+ if (images) {
930
+ content.push(...images);
931
+ }
932
+ this.agent.steer({
933
+ role: "user",
934
+ content,
935
+ timestamp: Date.now(),
936
+ });
937
+ }
938
+ /**
939
+ * Internal: Queue a follow-up message (already expanded, no extension command check).
940
+ */
941
+ async _queueFollowUp(text, images) {
942
+ this._followUpMessages.push(text);
943
+ this._emitQueueUpdate();
944
+ const content = [{ type: "text", text }];
945
+ if (images) {
946
+ content.push(...images);
947
+ }
948
+ this.agent.followUp({
949
+ role: "user",
950
+ content,
951
+ timestamp: Date.now(),
952
+ });
953
+ }
954
+ /**
955
+ * Throw an error if the text is an extension command.
956
+ */
957
+ _throwIfExtensionCommand(text) {
958
+ const spaceIndex = text.indexOf(" ");
959
+ const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
960
+ const command = this._extensionRunner.getCommand(commandName);
961
+ if (command) {
962
+ throw new Error(`Extension command "/${commandName}" cannot be queued. Use prompt() or execute the command when not streaming.`);
963
+ }
964
+ }
965
+ /**
966
+ * Send a custom message to the session. Creates a CustomMessageEntry.
967
+ *
968
+ * Handles three cases:
969
+ * - Streaming: queues message, processed when loop pulls from queue
970
+ * - Not streaming + triggerTurn: appends to state/session, starts new turn
971
+ * - Not streaming + no trigger: appends to state/session, no turn
972
+ *
973
+ * @param message Custom message with customType, content, display, details
974
+ * @param options.triggerTurn If true and not streaming, triggers a new LLM turn
975
+ * @param options.deliverAs Delivery mode: "steer", "followUp", or "nextTurn"
976
+ */
977
+ async sendCustomMessage(message, options) {
978
+ const appMessage = {
979
+ role: "custom",
980
+ customType: message.customType,
981
+ content: message.content,
982
+ display: message.display,
983
+ details: message.details,
984
+ timestamp: Date.now(),
985
+ };
986
+ if (options?.deliverAs === "nextTurn") {
987
+ this._pendingNextTurnMessages.push(appMessage);
988
+ }
989
+ else if (this.isStreaming) {
990
+ if (options?.deliverAs === "followUp") {
991
+ this.agent.followUp(appMessage);
992
+ }
993
+ else {
994
+ this.agent.steer(appMessage);
995
+ }
996
+ }
997
+ else if (options?.triggerTurn) {
998
+ await this._runAgentPrompt(appMessage);
999
+ }
1000
+ else {
1001
+ this.agent.state.messages.push(appMessage);
1002
+ this.sessionManager.appendCustomMessageEntry(message.customType, message.content, message.display, message.details);
1003
+ this._emit({ type: "message_start", message: appMessage });
1004
+ this._emit({ type: "message_end", message: appMessage });
1005
+ }
1006
+ }
1007
+ /**
1008
+ * Send a user message to the agent. Always triggers a turn.
1009
+ * When the agent is streaming, use deliverAs to specify how to queue the message.
1010
+ *
1011
+ * @param content User message content (string or content array)
1012
+ * @param options.deliverAs Delivery mode when streaming: "steer" or "followUp"
1013
+ */
1014
+ async sendUserMessage(content, options) {
1015
+ // Normalize content to text string + optional images
1016
+ let text;
1017
+ let images;
1018
+ if (typeof content === "string") {
1019
+ text = content;
1020
+ }
1021
+ else {
1022
+ const textParts = [];
1023
+ images = [];
1024
+ for (const part of content) {
1025
+ if (part.type === "text") {
1026
+ textParts.push(part.text);
1027
+ }
1028
+ else {
1029
+ images.push(part);
1030
+ }
1031
+ }
1032
+ text = textParts.join("\n");
1033
+ if (images.length === 0)
1034
+ images = undefined;
1035
+ }
1036
+ // Use prompt() with expandPromptTemplates: false to skip command handling and template expansion
1037
+ await this.prompt(text, {
1038
+ expandPromptTemplates: false,
1039
+ streamingBehavior: options?.deliverAs,
1040
+ images,
1041
+ source: "extension",
1042
+ });
1043
+ }
1044
+ /**
1045
+ * Clear all queued messages and return them.
1046
+ * Useful for restoring to editor when user aborts.
1047
+ * @returns Object with steering and followUp arrays
1048
+ */
1049
+ clearQueue() {
1050
+ const steering = [...this._steeringMessages];
1051
+ const followUp = [...this._followUpMessages];
1052
+ this._steeringMessages = [];
1053
+ this._followUpMessages = [];
1054
+ this.agent.clearAllQueues();
1055
+ this._emitQueueUpdate();
1056
+ return { steering, followUp };
1057
+ }
1058
+ /** Number of pending messages (includes both steering and follow-up) */
1059
+ get pendingMessageCount() {
1060
+ return this._steeringMessages.length + this._followUpMessages.length;
1061
+ }
1062
+ /** Get pending steering messages (read-only) */
1063
+ getSteeringMessages() {
1064
+ return this._steeringMessages;
1065
+ }
1066
+ /** Get pending follow-up messages (read-only) */
1067
+ getFollowUpMessages() {
1068
+ return this._followUpMessages;
1069
+ }
1070
+ get resourceLoader() {
1071
+ return this._resourceLoader;
1072
+ }
1073
+ /**
1074
+ * Abort current operation and wait for agent to become idle.
1075
+ */
1076
+ async abort() {
1077
+ this.abortRetry();
1078
+ this.agent.abort();
1079
+ await this.agent.waitForIdle();
1080
+ }
1081
+ // =========================================================================
1082
+ // Model Management
1083
+ // =========================================================================
1084
+ async _emitModelSelect(nextModel, previousModel, source) {
1085
+ if (modelsAreEqual(previousModel, nextModel))
1086
+ return;
1087
+ await this._extensionRunner.emit({
1088
+ type: "model_select",
1089
+ model: nextModel,
1090
+ previousModel,
1091
+ source,
1092
+ });
1093
+ }
1094
+ /**
1095
+ * Set model directly.
1096
+ * Validates that auth is configured, saves to session and settings.
1097
+ * @throws Error if no auth is configured for the model
1098
+ */
1099
+ async setModel(model) {
1100
+ if (!this._modelRegistry.hasConfiguredAuth(model)) {
1101
+ throw new Error(`No API key for ${model.provider}/${model.id}`);
1102
+ }
1103
+ const previousModel = this.model;
1104
+ const thinkingLevel = this._getThinkingLevelForModelSwitch(model);
1105
+ this.agent.state.model = model;
1106
+ this.sessionManager.appendModelChange(model.provider, model.id);
1107
+ this.settingsManager.setDefaultModelAndProvider(model.provider, model.id);
1108
+ // Re-clamp thinking level for new model's capabilities
1109
+ this.setThinkingLevel(thinkingLevel);
1110
+ await this._emitModelSelect(model, previousModel, "set");
1111
+ }
1112
+ /**
1113
+ * Cycle to next/previous model.
1114
+ * Uses scoped models (from --models flag) if available, otherwise all available models.
1115
+ * @param direction - "forward" (default) or "backward"
1116
+ * @returns The new model info, or undefined if only one model available
1117
+ */
1118
+ async cycleModel(direction = "forward") {
1119
+ if (this._scopedModels.length > 0) {
1120
+ return this._cycleScopedModel(direction);
1121
+ }
1122
+ return this._cycleAvailableModel(direction);
1123
+ }
1124
+ async _cycleScopedModel(direction) {
1125
+ const scopedModels = this._scopedModels.filter((scoped) => this._modelRegistry.hasConfiguredAuth(scoped.model));
1126
+ if (scopedModels.length <= 1)
1127
+ return undefined;
1128
+ const currentModel = this.model;
1129
+ let currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
1130
+ if (currentIndex === -1)
1131
+ currentIndex = 0;
1132
+ const len = scopedModels.length;
1133
+ const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
1134
+ const next = scopedModels[nextIndex];
1135
+ const thinkingLevel = this._getThinkingLevelForModelSwitch(next.model, next.thinkingLevel);
1136
+ // Apply model
1137
+ this.agent.state.model = next.model;
1138
+ this.sessionManager.appendModelChange(next.model.provider, next.model.id);
1139
+ this.settingsManager.setDefaultModelAndProvider(next.model.provider, next.model.id);
1140
+ // Apply thinking level.
1141
+ // - Explicit scoped model thinking level overrides current session level
1142
+ // - Undefined scoped model thinking level inherits the current session preference
1143
+ // setThinkingLevel clamps to model capabilities.
1144
+ this.setThinkingLevel(thinkingLevel);
1145
+ await this._emitModelSelect(next.model, currentModel, "cycle");
1146
+ return { model: next.model, thinkingLevel: this.thinkingLevel, isScoped: true };
1147
+ }
1148
+ async _cycleAvailableModel(direction) {
1149
+ const availableModels = await this._modelRegistry.getAvailable();
1150
+ if (availableModels.length <= 1)
1151
+ return undefined;
1152
+ const currentModel = this.model;
1153
+ let currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
1154
+ if (currentIndex === -1)
1155
+ currentIndex = 0;
1156
+ const len = availableModels.length;
1157
+ const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
1158
+ const nextModel = availableModels[nextIndex];
1159
+ const thinkingLevel = this._getThinkingLevelForModelSwitch(nextModel);
1160
+ this.agent.state.model = nextModel;
1161
+ this.sessionManager.appendModelChange(nextModel.provider, nextModel.id);
1162
+ this.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);
1163
+ // Re-clamp thinking level for new model's capabilities
1164
+ this.setThinkingLevel(thinkingLevel);
1165
+ await this._emitModelSelect(nextModel, currentModel, "cycle");
1166
+ return { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: false };
1167
+ }
1168
+ // =========================================================================
1169
+ // Thinking Level Management
1170
+ // =========================================================================
1171
+ /**
1172
+ * Set thinking level.
1173
+ * Clamps to model capabilities based on available thinking levels.
1174
+ * Saves to session and settings only if the level actually changes.
1175
+ */
1176
+ setThinkingLevel(level) {
1177
+ const availableLevels = this.getAvailableThinkingLevels();
1178
+ const effectiveLevel = availableLevels.includes(level) ? level : this._clampThinkingLevel(level, availableLevels);
1179
+ // Only persist if actually changing
1180
+ const previousLevel = this.agent.state.thinkingLevel;
1181
+ const isChanging = effectiveLevel !== previousLevel;
1182
+ this.agent.state.thinkingLevel = effectiveLevel;
1183
+ if (isChanging) {
1184
+ this.sessionManager.appendThinkingLevelChange(effectiveLevel);
1185
+ if (this.supportsThinking() || effectiveLevel !== "off") {
1186
+ this.settingsManager.setDefaultThinkingLevel(effectiveLevel);
1187
+ }
1188
+ this._emit({ type: "thinking_level_changed", level: effectiveLevel });
1189
+ void this._extensionRunner.emit({
1190
+ type: "thinking_level_select",
1191
+ level: effectiveLevel,
1192
+ previousLevel,
1193
+ });
1194
+ }
1195
+ }
1196
+ /**
1197
+ * Cycle to next thinking level.
1198
+ * @returns New level, or undefined if model doesn't support thinking
1199
+ */
1200
+ cycleThinkingLevel() {
1201
+ if (!this.supportsThinking())
1202
+ return undefined;
1203
+ const levels = this.getAvailableThinkingLevels();
1204
+ const currentIndex = levels.indexOf(this.thinkingLevel);
1205
+ const nextIndex = (currentIndex + 1) % levels.length;
1206
+ const nextLevel = levels[nextIndex];
1207
+ this.setThinkingLevel(nextLevel);
1208
+ return nextLevel;
1209
+ }
1210
+ /**
1211
+ * Get available thinking levels for current model.
1212
+ * The provider will clamp to what the specific model supports internally.
1213
+ */
1214
+ getAvailableThinkingLevels() {
1215
+ if (!this.model)
1216
+ return THINKING_LEVELS;
1217
+ return getSupportedThinkingLevels(this.model);
1218
+ }
1219
+ /**
1220
+ * Check if current model supports thinking/reasoning.
1221
+ */
1222
+ supportsThinking() {
1223
+ return !!this.model?.reasoning;
1224
+ }
1225
+ _getThinkingLevelForModelSwitch(targetModel, explicitLevel) {
1226
+ if (explicitLevel !== undefined) {
1227
+ return explicitLevel;
1228
+ }
1229
+ const modelThinkingLevel = targetModel ? this.settingsManager.getModelThinkingLevel(targetModel) : undefined;
1230
+ if (modelThinkingLevel) {
1231
+ return modelThinkingLevel;
1232
+ }
1233
+ if (!this.supportsThinking()) {
1234
+ return this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;
1235
+ }
1236
+ return this.thinkingLevel;
1237
+ }
1238
+ _clampThinkingLevel(level, _availableLevels) {
1239
+ return this.model ? clampThinkingLevel(this.model, level) : "off";
1240
+ }
1241
+ // =========================================================================
1242
+ // Queue Mode Management
1243
+ // =========================================================================
1244
+ /**
1245
+ * Set steering message mode.
1246
+ * Saves to settings.
1247
+ */
1248
+ setSteeringMode(mode) {
1249
+ this.agent.steeringMode = mode;
1250
+ this.settingsManager.setSteeringMode(mode);
1251
+ }
1252
+ /**
1253
+ * Set follow-up message mode.
1254
+ * Saves to settings.
1255
+ */
1256
+ setFollowUpMode(mode) {
1257
+ this.agent.followUpMode = mode;
1258
+ this.settingsManager.setFollowUpMode(mode);
1259
+ }
1260
+ // =========================================================================
1261
+ // Compaction
1262
+ // =========================================================================
1263
+ /**
1264
+ * Manually compact the session context.
1265
+ * Aborts current agent operation first.
1266
+ * @param customInstructions Optional instructions for the compaction summary
1267
+ */
1268
+ async compact(customInstructions) {
1269
+ this._disconnectFromAgent();
1270
+ await this.abort();
1271
+ this._compactionAbortController = new AbortController();
1272
+ this._emit({ type: "compaction_start", reason: "manual" });
1273
+ try {
1274
+ if (!this.model) {
1275
+ throw new Error(formatNoModelSelectedMessage());
1276
+ }
1277
+ const { apiKey, headers } = await this._getCompactionRequestAuth(this.model);
1278
+ const pathEntries = this.sessionManager.getBranch();
1279
+ const settings = this.settingsManager.getCompactionSettings();
1280
+ const preparation = prepareCompaction(pathEntries, settings);
1281
+ if (!preparation) {
1282
+ // Check why we can't compact
1283
+ const lastEntry = pathEntries[pathEntries.length - 1];
1284
+ if (lastEntry?.type === "compaction") {
1285
+ throw new Error("Already compacted");
1286
+ }
1287
+ throw new Error("Nothing to compact (session too small)");
1288
+ }
1289
+ let extensionCompaction;
1290
+ let fromExtension = false;
1291
+ if (this._extensionRunner.hasHandlers("session_before_compact")) {
1292
+ const result = (await this._extensionRunner.emit({
1293
+ type: "session_before_compact",
1294
+ preparation,
1295
+ branchEntries: pathEntries,
1296
+ customInstructions,
1297
+ signal: this._compactionAbortController.signal,
1298
+ }));
1299
+ if (result?.cancel) {
1300
+ throw new Error("Compaction cancelled");
1301
+ }
1302
+ if (result?.compaction) {
1303
+ extensionCompaction = result.compaction;
1304
+ fromExtension = true;
1305
+ }
1306
+ }
1307
+ let summary;
1308
+ let firstKeptEntryId;
1309
+ let tokensBefore;
1310
+ let details;
1311
+ if (extensionCompaction) {
1312
+ // Extension provided compaction content
1313
+ summary = extensionCompaction.summary;
1314
+ firstKeptEntryId = extensionCompaction.firstKeptEntryId;
1315
+ tokensBefore = extensionCompaction.tokensBefore;
1316
+ details = extensionCompaction.details;
1317
+ }
1318
+ else {
1319
+ // Generate compaction result
1320
+ const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFn);
1321
+ summary = result.summary;
1322
+ firstKeptEntryId = result.firstKeptEntryId;
1323
+ tokensBefore = result.tokensBefore;
1324
+ details = result.details;
1325
+ }
1326
+ if (this._compactionAbortController.signal.aborted) {
1327
+ throw new Error("Compaction cancelled");
1328
+ }
1329
+ this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension);
1330
+ const newEntries = this.sessionManager.getEntries();
1331
+ const sessionContext = this.sessionManager.buildSessionContext();
1332
+ this.agent.state.messages = sessionContext.messages;
1333
+ // Get the saved compaction entry for the extension event
1334
+ const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
1335
+ if (this._extensionRunner && savedCompactionEntry) {
1336
+ await this._extensionRunner.emit({
1337
+ type: "session_compact",
1338
+ compactionEntry: savedCompactionEntry,
1339
+ fromExtension,
1340
+ });
1341
+ }
1342
+ const compactionResult = {
1343
+ summary,
1344
+ firstKeptEntryId,
1345
+ tokensBefore,
1346
+ details,
1347
+ };
1348
+ this._emit({
1349
+ type: "compaction_end",
1350
+ reason: "manual",
1351
+ result: compactionResult,
1352
+ aborted: false,
1353
+ willRetry: false,
1354
+ });
1355
+ return compactionResult;
1356
+ }
1357
+ catch (error) {
1358
+ const message = error instanceof Error ? error.message : String(error);
1359
+ const aborted = message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError");
1360
+ this._emit({
1361
+ type: "compaction_end",
1362
+ reason: "manual",
1363
+ result: undefined,
1364
+ aborted,
1365
+ willRetry: false,
1366
+ errorMessage: aborted ? undefined : `Compaction failed: ${message}`,
1367
+ });
1368
+ throw error;
1369
+ }
1370
+ finally {
1371
+ this._compactionAbortController = undefined;
1372
+ this._reconnectToAgent();
1373
+ }
1374
+ }
1375
+ /**
1376
+ * Cancel in-progress compaction (manual or auto).
1377
+ */
1378
+ abortCompaction() {
1379
+ this._compactionAbortController?.abort();
1380
+ this._autoCompactionAbortController?.abort();
1381
+ }
1382
+ /**
1383
+ * Cancel in-progress branch summarization.
1384
+ */
1385
+ abortBranchSummary() {
1386
+ this._branchSummaryAbortController?.abort();
1387
+ }
1388
+ /**
1389
+ * Check if compaction is needed and run it.
1390
+ * Called after agent_end and before prompt submission.
1391
+ *
1392
+ * Two cases:
1393
+ * 1. Overflow: LLM returned context overflow error, remove error message from agent state, compact, auto-retry
1394
+ * 2. Threshold: Context over threshold, compact, NO auto-retry (user continues manually)
1395
+ *
1396
+ * @param assistantMessage The assistant message to check
1397
+ * @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true
1398
+ */
1399
+ async _checkCompaction(assistantMessage, skipAbortedCheck = true) {
1400
+ const settings = this.settingsManager.getCompactionSettings();
1401
+ if (!settings.enabled)
1402
+ return false;
1403
+ // Skip if message was aborted (user cancelled) - unless skipAbortedCheck is false
1404
+ if (skipAbortedCheck && assistantMessage.stopReason === "aborted")
1405
+ return false;
1406
+ const contextWindow = this.model?.contextWindow ?? 0;
1407
+ // Skip overflow check if the message came from a different model.
1408
+ // This handles the case where user switched from a smaller-context model (e.g. opus)
1409
+ // to a larger-context model (e.g. codex) - the overflow error from the old model
1410
+ // shouldn't trigger compaction for the new model.
1411
+ const sameModel = this.model && assistantMessage.provider === this.model.provider && assistantMessage.model === this.model.id;
1412
+ // Skip compaction checks if this assistant message is older than the latest
1413
+ // compaction boundary. This prevents a stale pre-compaction usage/error
1414
+ // from retriggering compaction on the first prompt after compaction.
1415
+ const compactionEntry = getLatestCompactionEntry(this.sessionManager.getBranch());
1416
+ const assistantIsFromBeforeCompaction = compactionEntry !== null && assistantMessage.timestamp <= new Date(compactionEntry.timestamp).getTime();
1417
+ if (assistantIsFromBeforeCompaction) {
1418
+ return false;
1419
+ }
1420
+ // Case 1: Overflow - LLM returned context overflow error
1421
+ if (sameModel && isContextOverflow(assistantMessage, contextWindow)) {
1422
+ if (this._overflowRecoveryAttempted) {
1423
+ this._emit({
1424
+ type: "compaction_end",
1425
+ reason: "overflow",
1426
+ result: undefined,
1427
+ aborted: false,
1428
+ willRetry: false,
1429
+ errorMessage: "Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.",
1430
+ });
1431
+ return false;
1432
+ }
1433
+ this._overflowRecoveryAttempted = true;
1434
+ // Remove the error message from agent state (it IS saved to session for history,
1435
+ // but we don't want it in context for the retry)
1436
+ const messages = this.agent.state.messages;
1437
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
1438
+ this.agent.state.messages = messages.slice(0, -1);
1439
+ }
1440
+ return await this._runAutoCompaction("overflow", true);
1441
+ }
1442
+ // Case 2: Threshold - context is getting large
1443
+ // For error messages (no usage data), estimate from last successful response.
1444
+ // This ensures sessions that hit persistent API errors (e.g. 529) can still compact.
1445
+ let contextTokens;
1446
+ if (assistantMessage.stopReason === "error") {
1447
+ const messages = this.agent.state.messages;
1448
+ const estimate = estimateContextTokens(messages);
1449
+ if (estimate.lastUsageIndex === null)
1450
+ return false; // No usage data at all
1451
+ // Verify the usage source is post-compaction. Kept pre-compaction messages
1452
+ // have stale usage reflecting the old (larger) context and would falsely
1453
+ // trigger compaction right after one just finished.
1454
+ const usageMsg = messages[estimate.lastUsageIndex];
1455
+ if (compactionEntry &&
1456
+ usageMsg.role === "assistant" &&
1457
+ usageMsg.timestamp <= new Date(compactionEntry.timestamp).getTime()) {
1458
+ return false;
1459
+ }
1460
+ contextTokens = estimate.tokens;
1461
+ }
1462
+ else {
1463
+ contextTokens = calculateContextTokens(assistantMessage.usage);
1464
+ }
1465
+ // Adaptive headroom threshold (default 90%); falls back to the compaction default when disabled.
1466
+ const headroomThreshold = resolveAdaptiveHeadroomThreshold(process.env);
1467
+ if (shouldCompact(contextTokens, contextWindow, settings, headroomThreshold > 0 ? headroomThreshold : undefined)) {
1468
+ return await this._runAutoCompaction("threshold", false);
1469
+ }
1470
+ return false;
1471
+ }
1472
+ /**
1473
+ * Internal: Run auto-compaction with events.
1474
+ */
1475
+ async _runAutoCompaction(reason, willRetry) {
1476
+ const settings = this.settingsManager.getCompactionSettings();
1477
+ this._emit({ type: "compaction_start", reason });
1478
+ this._autoCompactionAbortController = new AbortController();
1479
+ try {
1480
+ if (!this.model) {
1481
+ this._emit({
1482
+ type: "compaction_end",
1483
+ reason,
1484
+ result: undefined,
1485
+ aborted: false,
1486
+ willRetry: false,
1487
+ });
1488
+ return false;
1489
+ }
1490
+ let apiKey;
1491
+ let headers;
1492
+ if (this.agent.streamFn === streamSimple) {
1493
+ const authResult = await this._modelRegistry.getApiKeyAndHeaders(this.model);
1494
+ if (!authResult.ok || !authResult.apiKey) {
1495
+ this._emit({
1496
+ type: "compaction_end",
1497
+ reason,
1498
+ result: undefined,
1499
+ aborted: false,
1500
+ willRetry: false,
1501
+ });
1502
+ return false;
1503
+ }
1504
+ apiKey = authResult.apiKey;
1505
+ headers = authResult.headers;
1506
+ }
1507
+ else {
1508
+ ({ apiKey, headers } = await this._getCompactionRequestAuth(this.model));
1509
+ }
1510
+ const pathEntries = this.sessionManager.getBranch();
1511
+ const preparation = prepareCompaction(pathEntries, settings);
1512
+ if (!preparation) {
1513
+ this._emit({
1514
+ type: "compaction_end",
1515
+ reason,
1516
+ result: undefined,
1517
+ aborted: false,
1518
+ willRetry: false,
1519
+ });
1520
+ return false;
1521
+ }
1522
+ let extensionCompaction;
1523
+ let fromExtension = false;
1524
+ if (this._extensionRunner.hasHandlers("session_before_compact")) {
1525
+ const extensionResult = (await this._extensionRunner.emit({
1526
+ type: "session_before_compact",
1527
+ preparation,
1528
+ branchEntries: pathEntries,
1529
+ customInstructions: undefined,
1530
+ signal: this._autoCompactionAbortController.signal,
1531
+ }));
1532
+ if (extensionResult?.cancel) {
1533
+ this._emit({
1534
+ type: "compaction_end",
1535
+ reason,
1536
+ result: undefined,
1537
+ aborted: true,
1538
+ willRetry: false,
1539
+ });
1540
+ return false;
1541
+ }
1542
+ if (extensionResult?.compaction) {
1543
+ extensionCompaction = extensionResult.compaction;
1544
+ fromExtension = true;
1545
+ }
1546
+ }
1547
+ let summary;
1548
+ let firstKeptEntryId;
1549
+ let tokensBefore;
1550
+ let details;
1551
+ if (extensionCompaction) {
1552
+ // Extension provided compaction content
1553
+ summary = extensionCompaction.summary;
1554
+ firstKeptEntryId = extensionCompaction.firstKeptEntryId;
1555
+ tokensBefore = extensionCompaction.tokensBefore;
1556
+ details = extensionCompaction.details;
1557
+ }
1558
+ else {
1559
+ // Generate compaction result
1560
+ const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFn);
1561
+ summary = compactResult.summary;
1562
+ firstKeptEntryId = compactResult.firstKeptEntryId;
1563
+ tokensBefore = compactResult.tokensBefore;
1564
+ details = compactResult.details;
1565
+ }
1566
+ if (this._autoCompactionAbortController.signal.aborted) {
1567
+ this._emit({
1568
+ type: "compaction_end",
1569
+ reason,
1570
+ result: undefined,
1571
+ aborted: true,
1572
+ willRetry: false,
1573
+ });
1574
+ return false;
1575
+ }
1576
+ this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension);
1577
+ const newEntries = this.sessionManager.getEntries();
1578
+ const sessionContext = this.sessionManager.buildSessionContext();
1579
+ this.agent.state.messages = sessionContext.messages;
1580
+ // Get the saved compaction entry for the extension event
1581
+ const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
1582
+ if (this._extensionRunner && savedCompactionEntry) {
1583
+ await this._extensionRunner.emit({
1584
+ type: "session_compact",
1585
+ compactionEntry: savedCompactionEntry,
1586
+ fromExtension,
1587
+ });
1588
+ }
1589
+ const result = {
1590
+ summary,
1591
+ firstKeptEntryId,
1592
+ tokensBefore,
1593
+ details,
1594
+ };
1595
+ this._emit({ type: "compaction_end", reason, result, aborted: false, willRetry });
1596
+ if (willRetry) {
1597
+ const messages = this.agent.state.messages;
1598
+ const lastMsg = messages[messages.length - 1];
1599
+ if (lastMsg?.role === "assistant" && lastMsg.stopReason === "error") {
1600
+ this.agent.state.messages = messages.slice(0, -1);
1601
+ }
1602
+ return true;
1603
+ }
1604
+ // Auto-compaction can complete while follow-up/steering/custom messages are waiting.
1605
+ // Continue once so queued messages are delivered.
1606
+ return this.agent.hasQueuedMessages();
1607
+ }
1608
+ catch (error) {
1609
+ const errorMessage = error instanceof Error ? error.message : "compaction failed";
1610
+ this._emit({
1611
+ type: "compaction_end",
1612
+ reason,
1613
+ result: undefined,
1614
+ aborted: false,
1615
+ willRetry: false,
1616
+ errorMessage: reason === "overflow"
1617
+ ? `Context overflow recovery failed: ${errorMessage}`
1618
+ : `Auto-compaction failed: ${errorMessage}`,
1619
+ });
1620
+ return false;
1621
+ }
1622
+ finally {
1623
+ this._autoCompactionAbortController = undefined;
1624
+ }
1625
+ }
1626
+ /**
1627
+ * Toggle auto-compaction setting.
1628
+ */
1629
+ setAutoCompactionEnabled(enabled) {
1630
+ this.settingsManager.setCompactionEnabled(enabled);
1631
+ }
1632
+ /** Whether auto-compaction is enabled */
1633
+ get autoCompactionEnabled() {
1634
+ return this.settingsManager.getCompactionEnabled();
1635
+ }
1636
+ async bindExtensions(bindings) {
1637
+ if (bindings.uiContext !== undefined) {
1638
+ this._extensionUIContext = bindings.uiContext;
1639
+ }
1640
+ if (bindings.mode !== undefined) {
1641
+ this._extensionMode = bindings.mode;
1642
+ }
1643
+ if (bindings.commandContextActions !== undefined) {
1644
+ this._extensionCommandContextActions = bindings.commandContextActions;
1645
+ }
1646
+ if (bindings.abortHandler !== undefined) {
1647
+ this._extensionAbortHandler = bindings.abortHandler;
1648
+ }
1649
+ if (bindings.shutdownHandler !== undefined) {
1650
+ this._extensionShutdownHandler = bindings.shutdownHandler;
1651
+ }
1652
+ if (bindings.onError !== undefined) {
1653
+ this._extensionErrorListener = bindings.onError;
1654
+ }
1655
+ this._applyExtensionBindings(this._extensionRunner);
1656
+ await this._extensionRunner.emit(this._sessionStartEvent);
1657
+ await this.extendResourcesFromExtensions(this._sessionStartEvent.reason === "reload" ? "reload" : "startup");
1658
+ }
1659
+ async extendResourcesFromExtensions(reason) {
1660
+ if (!this._extensionRunner.hasHandlers("resources_discover")) {
1661
+ return;
1662
+ }
1663
+ const { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(this._cwd, reason);
1664
+ if (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {
1665
+ return;
1666
+ }
1667
+ const extensionPaths = {
1668
+ skillPaths: this.buildExtensionResourcePaths(skillPaths),
1669
+ promptPaths: this.buildExtensionResourcePaths(promptPaths),
1670
+ themePaths: this.buildExtensionResourcePaths(themePaths),
1671
+ };
1672
+ this._resourceLoader.extendResources(extensionPaths);
1673
+ this._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());
1674
+ this.agent.state.systemPrompt = this._baseSystemPrompt;
1675
+ }
1676
+ buildExtensionResourcePaths(entries) {
1677
+ return entries.map((entry) => {
1678
+ const source = this.getExtensionSourceLabel(entry.extensionPath);
1679
+ const baseDir = entry.extensionPath.startsWith("<") ? undefined : dirname(entry.extensionPath);
1680
+ return {
1681
+ path: entry.path,
1682
+ metadata: {
1683
+ source,
1684
+ scope: "temporary",
1685
+ origin: "top-level",
1686
+ baseDir,
1687
+ },
1688
+ };
1689
+ });
1690
+ }
1691
+ getExtensionSourceLabel(extensionPath) {
1692
+ if (extensionPath.startsWith("<")) {
1693
+ return `extension:${extensionPath.replace(/[<>]/g, "")}`;
1694
+ }
1695
+ const base = basename(extensionPath);
1696
+ const name = base.replace(/\.(ts|js)$/, "");
1697
+ return `extension:${name}`;
1698
+ }
1699
+ _applyExtensionBindings(runner) {
1700
+ runner.setUIContext(this._extensionUIContext, this._extensionMode);
1701
+ runner.bindCommandContext(this._extensionCommandContextActions);
1702
+ this._extensionErrorUnsubscriber?.();
1703
+ this._extensionErrorUnsubscriber = this._extensionErrorListener
1704
+ ? runner.onError(this._extensionErrorListener)
1705
+ : undefined;
1706
+ }
1707
+ _refreshCurrentModelFromRegistry() {
1708
+ const currentModel = this.model;
1709
+ if (!currentModel) {
1710
+ return;
1711
+ }
1712
+ const refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);
1713
+ if (!refreshedModel || refreshedModel === currentModel) {
1714
+ return;
1715
+ }
1716
+ this.agent.state.model = refreshedModel;
1717
+ }
1718
+ _bindExtensionCore(runner) {
1719
+ const getCommands = () => {
1720
+ const extensionCommands = runner.getRegisteredCommands().map((command) => ({
1721
+ name: command.invocationName,
1722
+ description: command.description,
1723
+ source: "extension",
1724
+ sourceInfo: command.sourceInfo,
1725
+ }));
1726
+ const templates = this.promptTemplates.map((template) => ({
1727
+ name: template.name,
1728
+ description: template.description,
1729
+ source: "prompt",
1730
+ sourceInfo: template.sourceInfo,
1731
+ }));
1732
+ const skills = this._resourceLoader.getSkills().skills.map((skill) => ({
1733
+ name: `skill:${skill.name}`,
1734
+ description: skill.description,
1735
+ source: "skill",
1736
+ sourceInfo: skill.sourceInfo,
1737
+ }));
1738
+ return [...extensionCommands, ...templates, ...skills];
1739
+ };
1740
+ runner.bindCore({
1741
+ sendMessage: (message, options) => {
1742
+ this.sendCustomMessage(message, options).catch((err) => {
1743
+ runner.emitError({
1744
+ extensionPath: "<runtime>",
1745
+ event: "send_message",
1746
+ error: err instanceof Error ? err.message : String(err),
1747
+ });
1748
+ });
1749
+ },
1750
+ sendUserMessage: (content, options) => {
1751
+ this.sendUserMessage(content, options).catch((err) => {
1752
+ runner.emitError({
1753
+ extensionPath: "<runtime>",
1754
+ event: "send_user_message",
1755
+ error: err instanceof Error ? err.message : String(err),
1756
+ });
1757
+ });
1758
+ },
1759
+ appendEntry: (customType, data) => {
1760
+ this.sessionManager.appendCustomEntry(customType, data);
1761
+ },
1762
+ setSessionName: (name) => {
1763
+ this.setSessionName(name);
1764
+ },
1765
+ getSessionName: () => {
1766
+ return this.sessionManager.getSessionName();
1767
+ },
1768
+ setLabel: (entryId, label) => {
1769
+ this.sessionManager.appendLabelChange(entryId, label);
1770
+ },
1771
+ getActiveTools: () => this.getActiveToolNames(),
1772
+ getAllTools: () => this.getAllTools(),
1773
+ setActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),
1774
+ refreshTools: () => this._refreshToolRegistry(),
1775
+ getCommands,
1776
+ setModel: async (model) => {
1777
+ if (!this.modelRegistry.hasConfiguredAuth(model))
1778
+ return false;
1779
+ await this.setModel(model);
1780
+ return true;
1781
+ },
1782
+ getThinkingLevel: () => this.thinkingLevel,
1783
+ setThinkingLevel: (level) => this.setThinkingLevel(level),
1784
+ }, {
1785
+ getModel: () => this.model,
1786
+ isIdle: () => !this.isStreaming,
1787
+ getSignal: () => this.agent.signal,
1788
+ abort: () => {
1789
+ if (this._extensionAbortHandler) {
1790
+ this._extensionAbortHandler();
1791
+ return;
1792
+ }
1793
+ void this.abort();
1794
+ },
1795
+ hasPendingMessages: () => this.pendingMessageCount > 0,
1796
+ shutdown: () => {
1797
+ this._extensionShutdownHandler?.();
1798
+ },
1799
+ getContextUsage: () => this.getContextUsage(),
1800
+ compact: (options) => {
1801
+ void (async () => {
1802
+ try {
1803
+ const result = await this.compact(options?.customInstructions);
1804
+ options?.onComplete?.(result);
1805
+ }
1806
+ catch (error) {
1807
+ const err = error instanceof Error ? error : new Error(String(error));
1808
+ options?.onError?.(err);
1809
+ }
1810
+ })();
1811
+ },
1812
+ getSystemPrompt: () => this.systemPrompt,
1813
+ getSystemPromptOptions: () => this._baseSystemPromptOptions,
1814
+ }, {
1815
+ registerProvider: (name, config) => {
1816
+ this._modelRegistry.registerProvider(name, config);
1817
+ this._refreshCurrentModelFromRegistry();
1818
+ },
1819
+ unregisterProvider: (name) => {
1820
+ this._modelRegistry.unregisterProvider(name);
1821
+ this._refreshCurrentModelFromRegistry();
1822
+ },
1823
+ });
1824
+ }
1825
+ _refreshToolRegistry(options) {
1826
+ const previousRegistryNames = new Set(this._toolRegistry.keys());
1827
+ const previousActiveToolNames = this.getActiveToolNames();
1828
+ const allowedToolNames = this._allowedToolNames;
1829
+ const excludedToolNames = this._excludedToolNames;
1830
+ const isAllowedTool = (name) => (!allowedToolNames || allowedToolNames.has(name)) && !excludedToolNames?.has(name);
1831
+ const registeredTools = this._extensionRunner.getAllRegisteredTools();
1832
+ const allCustomTools = [
1833
+ ...registeredTools,
1834
+ ...this._customTools.map((definition) => ({
1835
+ definition,
1836
+ sourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: "sdk" }),
1837
+ })),
1838
+ ].filter((tool) => isAllowedTool(tool.definition.name));
1839
+ const definitionRegistry = new Map(Array.from(this._baseToolDefinitions.entries())
1840
+ .filter(([name]) => isAllowedTool(name))
1841
+ .map(([name, definition]) => [
1842
+ name,
1843
+ {
1844
+ definition,
1845
+ sourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: "builtin" }),
1846
+ },
1847
+ ]));
1848
+ for (const tool of allCustomTools) {
1849
+ definitionRegistry.set(tool.definition.name, {
1850
+ definition: tool.definition,
1851
+ sourceInfo: tool.sourceInfo,
1852
+ });
1853
+ }
1854
+ this._toolDefinitions = definitionRegistry;
1855
+ this._toolPromptSnippets = new Map(Array.from(definitionRegistry.values())
1856
+ .map(({ definition }) => {
1857
+ const snippet = this._normalizePromptSnippet(definition.promptSnippet);
1858
+ return snippet ? [definition.name, snippet] : undefined;
1859
+ })
1860
+ .filter((entry) => entry !== undefined));
1861
+ this._toolPromptGuidelines = new Map(Array.from(definitionRegistry.values())
1862
+ .map(({ definition }) => {
1863
+ const guidelines = this._normalizePromptGuidelines(definition.promptGuidelines);
1864
+ return guidelines.length > 0 ? [definition.name, guidelines] : undefined;
1865
+ })
1866
+ .filter((entry) => entry !== undefined));
1867
+ const runner = this._extensionRunner;
1868
+ const wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);
1869
+ const wrappedBuiltInTools = wrapRegisteredTools(Array.from(this._baseToolDefinitions.values())
1870
+ .filter((definition) => isAllowedTool(definition.name))
1871
+ .map((definition) => ({
1872
+ definition,
1873
+ sourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: "builtin" }),
1874
+ })), runner);
1875
+ const toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));
1876
+ for (const tool of wrappedExtensionTools) {
1877
+ toolRegistry.set(tool.name, tool);
1878
+ }
1879
+ this._toolRegistry = toolRegistry;
1880
+ const nextActiveToolNames = (options?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]).filter((name) => isAllowedTool(name));
1881
+ if (allowedToolNames) {
1882
+ for (const toolName of this._toolRegistry.keys()) {
1883
+ if (allowedToolNames.has(toolName)) {
1884
+ nextActiveToolNames.push(toolName);
1885
+ }
1886
+ }
1887
+ }
1888
+ else if (options?.includeAllExtensionTools) {
1889
+ for (const tool of wrappedExtensionTools) {
1890
+ nextActiveToolNames.push(tool.name);
1891
+ }
1892
+ }
1893
+ else if (!options?.activeToolNames) {
1894
+ for (const toolName of this._toolRegistry.keys()) {
1895
+ if (!previousRegistryNames.has(toolName)) {
1896
+ nextActiveToolNames.push(toolName);
1897
+ }
1898
+ }
1899
+ }
1900
+ this.setActiveToolsByName([...new Set(nextActiveToolNames)]);
1901
+ }
1902
+ _buildRuntime(options) {
1903
+ const autoResizeImages = this.settingsManager.getImageAutoResize();
1904
+ const shellCommandPrefix = this.settingsManager.getShellCommandPrefix();
1905
+ const shellPath = this.settingsManager.getShellPath();
1906
+ const baseToolDefinitions = this._baseToolsOverride
1907
+ ? Object.fromEntries(Object.entries(this._baseToolsOverride).map(([name, tool]) => [
1908
+ name,
1909
+ createToolDefinitionFromAgentTool(tool),
1910
+ ]))
1911
+ : createAllToolDefinitions(this._cwd, {
1912
+ read: { autoResizeImages },
1913
+ bash: { commandPrefix: shellCommandPrefix, shellPath },
1914
+ });
1915
+ this._baseToolDefinitions = new Map(Object.entries(baseToolDefinitions).map(([name, tool]) => [name, tool]));
1916
+ const extensionsResult = this._resourceLoader.getExtensions();
1917
+ if (options.flagValues) {
1918
+ for (const [name, value] of options.flagValues) {
1919
+ extensionsResult.runtime.flagValues.set(name, value);
1920
+ }
1921
+ }
1922
+ this._extensionRunner = new ExtensionRunner(extensionsResult.extensions, extensionsResult.runtime, this._cwd, this.sessionManager, this._modelRegistry);
1923
+ if (this._extensionRunnerRef) {
1924
+ this._extensionRunnerRef.current = this._extensionRunner;
1925
+ }
1926
+ this._bindExtensionCore(this._extensionRunner);
1927
+ this._applyExtensionBindings(this._extensionRunner);
1928
+ const defaultActiveToolNames = this._baseToolsOverride
1929
+ ? Object.keys(this._baseToolsOverride)
1930
+ : ["read", "bash", "edit", "write"];
1931
+ const baseActiveToolNames = options.activeToolNames ?? defaultActiveToolNames;
1932
+ this._refreshToolRegistry({
1933
+ activeToolNames: baseActiveToolNames,
1934
+ includeAllExtensionTools: options.includeAllExtensionTools,
1935
+ });
1936
+ }
1937
+ async reload() {
1938
+ const previousFlagValues = this._extensionRunner.getFlagValues();
1939
+ await emitSessionShutdownEvent(this._extensionRunner, { type: "session_shutdown", reason: "reload" });
1940
+ await this.settingsManager.reload();
1941
+ resetApiProviders();
1942
+ await this._resourceLoader.reload();
1943
+ this._buildRuntime({
1944
+ activeToolNames: this.getActiveToolNames(),
1945
+ flagValues: previousFlagValues,
1946
+ includeAllExtensionTools: true,
1947
+ });
1948
+ const hasBindings = this._extensionUIContext ||
1949
+ this._extensionCommandContextActions ||
1950
+ this._extensionShutdownHandler ||
1951
+ this._extensionErrorListener;
1952
+ if (hasBindings) {
1953
+ await this._extensionRunner.emit({ type: "session_start", reason: "reload" });
1954
+ await this.extendResourcesFromExtensions("reload");
1955
+ }
1956
+ }
1957
+ // =========================================================================
1958
+ // Auto-Retry
1959
+ // =========================================================================
1960
+ _isNonRetryableProviderLimitError(errorMessage) {
1961
+ return /GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(errorMessage);
1962
+ }
1963
+ /**
1964
+ * Check if an error is retryable (overloaded, rate limit, server errors).
1965
+ * Context overflow errors are NOT retryable (handled by compaction instead).
1966
+ */
1967
+ _isRetryableError(message) {
1968
+ if (message.stopReason !== "error" || !message.errorMessage)
1969
+ return false;
1970
+ // Context overflow is handled by compaction, not retry
1971
+ const contextWindow = this.model?.contextWindow ?? 0;
1972
+ if (isContextOverflow(message, contextWindow))
1973
+ return false;
1974
+ const err = message.errorMessage;
1975
+ if (this._isNonRetryableProviderLimitError(err))
1976
+ return false;
1977
+ // Match: overloaded_error, provider returned error, rate limit, 429, 500, 502, 503, 504, service unavailable, network/connection errors (including connection lost), WebSocket transport closes/errors, fetch failed, premature stream endings, HTTP/2 closed before response, terminated, retry delay exceeded
1978
+ return /overloaded|provider.?returned.?error|rate.?limit|too many requests|429|500|502|503|504|service.?unavailable|server.?error|internal.?error|network.?error|connection.?error|connection.?refused|connection.?lost|websocket.?closed|websocket.?error|other side closed|fetch failed|upstream.?connect|reset before headers|socket hang up|ended without|stream ended before message_stop|http2 request did not get a response|timed? out|timeout|terminated|retry delay/i.test(err);
1979
+ }
1980
+ /**
1981
+ * Prepare a retryable error for continuation with exponential backoff.
1982
+ * @returns true if the caller should continue the agent, false otherwise
1983
+ */
1984
+ async _prepareRetry(message) {
1985
+ const settings = this.settingsManager.getRetrySettings();
1986
+ if (!settings.enabled) {
1987
+ return false;
1988
+ }
1989
+ this._retryAttempt++;
1990
+ if (this._retryAttempt > settings.maxRetries) {
1991
+ // Preserve the completed attempt count so post-run handling can emit the final failure.
1992
+ this._retryAttempt--;
1993
+ return false;
1994
+ }
1995
+ const delayMs = settings.baseDelayMs * 2 ** (this._retryAttempt - 1);
1996
+ this._emit({
1997
+ type: "auto_retry_start",
1998
+ attempt: this._retryAttempt,
1999
+ maxAttempts: settings.maxRetries,
2000
+ delayMs,
2001
+ errorMessage: message.errorMessage || "Unknown error",
2002
+ });
2003
+ // Remove error message from agent state (keep in session for history)
2004
+ const messages = this.agent.state.messages;
2005
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
2006
+ this.agent.state.messages = messages.slice(0, -1);
2007
+ }
2008
+ // Wait with exponential backoff (abortable)
2009
+ this._retryAbortController = new AbortController();
2010
+ try {
2011
+ await sleep(delayMs, this._retryAbortController.signal);
2012
+ }
2013
+ catch {
2014
+ // Aborted during sleep - emit end event so UI can clean up
2015
+ const attempt = this._retryAttempt;
2016
+ this._retryAttempt = 0;
2017
+ this._emit({
2018
+ type: "auto_retry_end",
2019
+ success: false,
2020
+ attempt,
2021
+ finalError: "Retry cancelled",
2022
+ });
2023
+ return false;
2024
+ }
2025
+ finally {
2026
+ this._retryAbortController = undefined;
2027
+ }
2028
+ return true;
2029
+ }
2030
+ /**
2031
+ * Cancel in-progress retry.
2032
+ */
2033
+ abortRetry() {
2034
+ this._retryAbortController?.abort();
2035
+ }
2036
+ /** Whether auto-retry is currently in progress */
2037
+ get isRetrying() {
2038
+ return this._retryAbortController !== undefined;
2039
+ }
2040
+ /** Whether auto-retry is enabled */
2041
+ get autoRetryEnabled() {
2042
+ return this.settingsManager.getRetryEnabled();
2043
+ }
2044
+ /**
2045
+ * Toggle auto-retry setting.
2046
+ */
2047
+ setAutoRetryEnabled(enabled) {
2048
+ this.settingsManager.setRetryEnabled(enabled);
2049
+ }
2050
+ // =========================================================================
2051
+ // Bash Execution
2052
+ // =========================================================================
2053
+ /**
2054
+ * Execute a bash command.
2055
+ * Adds result to agent context and session.
2056
+ * @param command The bash command to execute
2057
+ * @param onChunk Optional streaming callback for output
2058
+ * @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
2059
+ * @param options.operations Custom BashOperations for remote execution
2060
+ */
2061
+ async executeBash(command, onChunk, options) {
2062
+ this._bashAbortController = new AbortController();
2063
+ // Apply command prefix if configured (e.g., "shopt -s expand_aliases" for alias support)
2064
+ const prefix = this.settingsManager.getShellCommandPrefix();
2065
+ const shellPath = this.settingsManager.getShellPath();
2066
+ const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
2067
+ try {
2068
+ const result = await executeBashWithOperations(resolvedCommand, this.sessionManager.getCwd(), options?.operations ?? createLocalBashOperations({ shellPath }), {
2069
+ onChunk,
2070
+ signal: this._bashAbortController.signal,
2071
+ });
2072
+ this.recordBashResult(command, result, options);
2073
+ return result;
2074
+ }
2075
+ finally {
2076
+ this._bashAbortController = undefined;
2077
+ }
2078
+ }
2079
+ /**
2080
+ * Record a bash execution result in session history.
2081
+ * Used by executeBash and by extensions that handle bash execution themselves.
2082
+ */
2083
+ recordBashResult(command, result, options) {
2084
+ const bashMessage = {
2085
+ role: "bashExecution",
2086
+ command,
2087
+ output: result.output,
2088
+ exitCode: result.exitCode,
2089
+ cancelled: result.cancelled,
2090
+ truncated: result.truncated,
2091
+ fullOutputPath: result.fullOutputPath,
2092
+ timestamp: Date.now(),
2093
+ excludeFromContext: options?.excludeFromContext,
2094
+ };
2095
+ // If agent is streaming, defer adding to avoid breaking tool_use/tool_result ordering
2096
+ if (this.isStreaming) {
2097
+ // Queue for later - will be flushed on agent_end
2098
+ this._pendingBashMessages.push(bashMessage);
2099
+ }
2100
+ else {
2101
+ // Add to agent state immediately
2102
+ this.agent.state.messages.push(bashMessage);
2103
+ // Save to session
2104
+ this.sessionManager.appendMessage(bashMessage);
2105
+ }
2106
+ }
2107
+ /**
2108
+ * Cancel running bash command.
2109
+ */
2110
+ abortBash() {
2111
+ this._bashAbortController?.abort();
2112
+ }
2113
+ /** Whether a bash command is currently running */
2114
+ get isBashRunning() {
2115
+ return this._bashAbortController !== undefined;
2116
+ }
2117
+ /** Whether there are pending bash messages waiting to be flushed */
2118
+ get hasPendingBashMessages() {
2119
+ return this._pendingBashMessages.length > 0;
2120
+ }
2121
+ /**
2122
+ * Flush pending bash messages to agent state and session.
2123
+ * Called after agent turn completes to maintain proper message ordering.
2124
+ */
2125
+ _flushPendingBashMessages() {
2126
+ if (this._pendingBashMessages.length === 0)
2127
+ return;
2128
+ for (const bashMessage of this._pendingBashMessages) {
2129
+ // Add to agent state
2130
+ this.agent.state.messages.push(bashMessage);
2131
+ // Save to session
2132
+ this.sessionManager.appendMessage(bashMessage);
2133
+ }
2134
+ this._pendingBashMessages = [];
2135
+ }
2136
+ // =========================================================================
2137
+ // Session Management
2138
+ // =========================================================================
2139
+ /**
2140
+ * Set a display name for the current session.
2141
+ */
2142
+ setSessionName(name) {
2143
+ this.sessionManager.appendSessionInfo(name);
2144
+ this._emit({ type: "session_info_changed", name: this.sessionManager.getSessionName() });
2145
+ }
2146
+ // =========================================================================
2147
+ // Tree Navigation
2148
+ // =========================================================================
2149
+ /**
2150
+ * Navigate to a different node in the session tree.
2151
+ * Unlike fork() which creates a new session file, this stays in the same file.
2152
+ *
2153
+ * @param targetId The entry ID to navigate to
2154
+ * @param options.summarize Whether user wants to summarize abandoned branch
2155
+ * @param options.customInstructions Custom instructions for summarizer
2156
+ * @param options.replaceInstructions If true, customInstructions replaces the default prompt
2157
+ * @param options.label Label to attach to the branch summary entry
2158
+ * @returns Result with editorText (if user message) and cancelled status
2159
+ */
2160
+ async navigateTree(targetId, options = {}) {
2161
+ const oldLeafId = this.sessionManager.getLeafId();
2162
+ // No-op if already at target
2163
+ if (targetId === oldLeafId) {
2164
+ return { cancelled: false };
2165
+ }
2166
+ // Model required for summarization
2167
+ if (options.summarize && !this.model) {
2168
+ throw new Error("No model available for summarization");
2169
+ }
2170
+ const targetEntry = this.sessionManager.getEntry(targetId);
2171
+ if (!targetEntry) {
2172
+ throw new Error(`Entry ${targetId} not found`);
2173
+ }
2174
+ // Collect entries to summarize (from old leaf to common ancestor)
2175
+ const { entries: entriesToSummarize, commonAncestorId } = collectEntriesForBranchSummary(this.sessionManager, oldLeafId, targetId);
2176
+ // Prepare event data - mutable so extensions can override
2177
+ let customInstructions = options.customInstructions;
2178
+ let replaceInstructions = options.replaceInstructions;
2179
+ let label = options.label;
2180
+ const preparation = {
2181
+ targetId,
2182
+ oldLeafId,
2183
+ commonAncestorId,
2184
+ entriesToSummarize,
2185
+ userWantsSummary: options.summarize ?? false,
2186
+ customInstructions,
2187
+ replaceInstructions,
2188
+ label,
2189
+ };
2190
+ // Set up abort controller for summarization
2191
+ this._branchSummaryAbortController = new AbortController();
2192
+ try {
2193
+ let extensionSummary;
2194
+ let fromExtension = false;
2195
+ // Emit session_before_tree event
2196
+ if (this._extensionRunner.hasHandlers("session_before_tree")) {
2197
+ const result = (await this._extensionRunner.emit({
2198
+ type: "session_before_tree",
2199
+ preparation,
2200
+ signal: this._branchSummaryAbortController.signal,
2201
+ }));
2202
+ if (result?.cancel) {
2203
+ return { cancelled: true };
2204
+ }
2205
+ if (result?.summary && options.summarize) {
2206
+ extensionSummary = result.summary;
2207
+ fromExtension = true;
2208
+ }
2209
+ // Allow extensions to override instructions and label
2210
+ if (result?.customInstructions !== undefined) {
2211
+ customInstructions = result.customInstructions;
2212
+ }
2213
+ if (result?.replaceInstructions !== undefined) {
2214
+ replaceInstructions = result.replaceInstructions;
2215
+ }
2216
+ if (result?.label !== undefined) {
2217
+ label = result.label;
2218
+ }
2219
+ }
2220
+ // Run default summarizer if needed
2221
+ let summaryText;
2222
+ let summaryDetails;
2223
+ if (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {
2224
+ const model = this.model;
2225
+ const { apiKey, headers } = await this._getRequiredRequestAuth(model);
2226
+ const branchSummarySettings = this.settingsManager.getBranchSummarySettings();
2227
+ const result = await generateBranchSummary(entriesToSummarize, {
2228
+ model,
2229
+ apiKey,
2230
+ headers,
2231
+ signal: this._branchSummaryAbortController.signal,
2232
+ customInstructions,
2233
+ replaceInstructions,
2234
+ reserveTokens: branchSummarySettings.reserveTokens,
2235
+ streamFn: this.agent.streamFn,
2236
+ });
2237
+ if (result.aborted) {
2238
+ return { cancelled: true, aborted: true };
2239
+ }
2240
+ if (result.error) {
2241
+ throw new Error(result.error);
2242
+ }
2243
+ summaryText = result.summary;
2244
+ summaryDetails = {
2245
+ readFiles: result.readFiles || [],
2246
+ modifiedFiles: result.modifiedFiles || [],
2247
+ };
2248
+ }
2249
+ else if (extensionSummary) {
2250
+ summaryText = extensionSummary.summary;
2251
+ summaryDetails = extensionSummary.details;
2252
+ }
2253
+ // Determine the new leaf position based on target type
2254
+ let newLeafId;
2255
+ let editorText;
2256
+ if (targetEntry.type === "message" && targetEntry.message.role === "user") {
2257
+ // User message: leaf = parent (null if root), text goes to editor
2258
+ newLeafId = targetEntry.parentId;
2259
+ editorText = this._extractUserMessageText(targetEntry.message.content);
2260
+ }
2261
+ else if (targetEntry.type === "custom_message") {
2262
+ // Custom message: leaf = parent (null if root), text goes to editor
2263
+ newLeafId = targetEntry.parentId;
2264
+ editorText =
2265
+ typeof targetEntry.content === "string"
2266
+ ? targetEntry.content
2267
+ : targetEntry.content
2268
+ .filter((c) => c.type === "text")
2269
+ .map((c) => c.text)
2270
+ .join("");
2271
+ }
2272
+ else {
2273
+ // Non-user message: leaf = selected node
2274
+ newLeafId = targetId;
2275
+ }
2276
+ // Switch leaf (with or without summary)
2277
+ // Summary is attached at the navigation target position (newLeafId), not the old branch
2278
+ let summaryEntry;
2279
+ if (summaryText) {
2280
+ // Create summary at target position (can be null for root)
2281
+ const summaryId = this.sessionManager.branchWithSummary(newLeafId, summaryText, summaryDetails, fromExtension);
2282
+ summaryEntry = this.sessionManager.getEntry(summaryId);
2283
+ // Attach label to the summary entry
2284
+ if (label) {
2285
+ this.sessionManager.appendLabelChange(summaryId, label);
2286
+ }
2287
+ }
2288
+ else if (newLeafId === null) {
2289
+ // No summary, navigating to root - reset leaf
2290
+ this.sessionManager.resetLeaf();
2291
+ }
2292
+ else {
2293
+ // No summary, navigating to non-root
2294
+ this.sessionManager.branch(newLeafId);
2295
+ }
2296
+ // Attach label to target entry when not summarizing (no summary entry to label)
2297
+ if (label && !summaryText) {
2298
+ this.sessionManager.appendLabelChange(targetId, label);
2299
+ }
2300
+ // Update agent state
2301
+ const sessionContext = this.sessionManager.buildSessionContext();
2302
+ this.agent.state.messages = sessionContext.messages;
2303
+ // Emit session_tree event
2304
+ await this._extensionRunner.emit({
2305
+ type: "session_tree",
2306
+ newLeafId: this.sessionManager.getLeafId(),
2307
+ oldLeafId,
2308
+ summaryEntry,
2309
+ fromExtension: summaryText ? fromExtension : undefined,
2310
+ });
2311
+ // Emit to custom tools
2312
+ return { editorText, cancelled: false, summaryEntry };
2313
+ }
2314
+ finally {
2315
+ this._branchSummaryAbortController = undefined;
2316
+ }
2317
+ }
2318
+ /**
2319
+ * Get all user messages from session for fork selector.
2320
+ */
2321
+ getUserMessagesForForking() {
2322
+ const entries = this.sessionManager.getEntries();
2323
+ const result = [];
2324
+ for (const entry of entries) {
2325
+ if (entry.type !== "message")
2326
+ continue;
2327
+ if (entry.message.role !== "user")
2328
+ continue;
2329
+ const text = this._extractUserMessageText(entry.message.content);
2330
+ if (text) {
2331
+ result.push({ entryId: entry.id, text });
2332
+ }
2333
+ }
2334
+ return result;
2335
+ }
2336
+ _extractUserMessageText(content) {
2337
+ if (typeof content === "string")
2338
+ return content;
2339
+ if (Array.isArray(content)) {
2340
+ return content
2341
+ .filter((c) => c.type === "text")
2342
+ .map((c) => c.text)
2343
+ .join("");
2344
+ }
2345
+ return "";
2346
+ }
2347
+ /**
2348
+ * Get session statistics.
2349
+ */
2350
+ getSessionStats() {
2351
+ const state = this.state;
2352
+ const userMessages = state.messages.filter((m) => m.role === "user").length;
2353
+ const assistantMessages = state.messages.filter((m) => m.role === "assistant").length;
2354
+ const toolResults = state.messages.filter((m) => m.role === "toolResult").length;
2355
+ let toolCalls = 0;
2356
+ let totalInput = 0;
2357
+ let totalOutput = 0;
2358
+ let totalCacheRead = 0;
2359
+ let totalCacheWrite = 0;
2360
+ let totalCost = 0;
2361
+ for (const message of state.messages) {
2362
+ if (message.role === "assistant") {
2363
+ const assistantMsg = message;
2364
+ toolCalls += assistantMsg.content.filter((c) => c.type === "toolCall").length;
2365
+ totalInput += assistantMsg.usage.input;
2366
+ totalOutput += assistantMsg.usage.output;
2367
+ totalCacheRead += assistantMsg.usage.cacheRead;
2368
+ totalCacheWrite += assistantMsg.usage.cacheWrite;
2369
+ totalCost += assistantMsg.usage.cost.total;
2370
+ }
2371
+ }
2372
+ return {
2373
+ sessionFile: this.sessionFile,
2374
+ sessionId: this.sessionId,
2375
+ userMessages,
2376
+ assistantMessages,
2377
+ toolCalls,
2378
+ toolResults,
2379
+ totalMessages: state.messages.length,
2380
+ tokens: {
2381
+ input: totalInput,
2382
+ output: totalOutput,
2383
+ cacheRead: totalCacheRead,
2384
+ cacheWrite: totalCacheWrite,
2385
+ total: totalInput + totalOutput + totalCacheRead + totalCacheWrite,
2386
+ },
2387
+ cost: totalCost,
2388
+ contextUsage: this.getContextUsage(),
2389
+ };
2390
+ }
2391
+ getContextUsage() {
2392
+ const model = this.model;
2393
+ if (!model)
2394
+ return undefined;
2395
+ const contextWindow = model.contextWindow ?? 0;
2396
+ if (contextWindow <= 0)
2397
+ return undefined;
2398
+ // After compaction, the last assistant usage reflects pre-compaction context size.
2399
+ // We can only trust usage from an assistant that responded after the latest compaction.
2400
+ // If no such assistant exists, context token count is unknown until the next LLM response.
2401
+ const branchEntries = this.sessionManager.getBranch();
2402
+ const latestCompaction = getLatestCompactionEntry(branchEntries);
2403
+ if (latestCompaction) {
2404
+ // Check if there's a valid assistant usage after the compaction boundary
2405
+ const compactionIndex = branchEntries.lastIndexOf(latestCompaction);
2406
+ let hasPostCompactionUsage = false;
2407
+ for (let i = branchEntries.length - 1; i > compactionIndex; i--) {
2408
+ const entry = branchEntries[i];
2409
+ if (entry.type === "message" && entry.message.role === "assistant") {
2410
+ const assistant = entry.message;
2411
+ if (assistant.stopReason !== "aborted" && assistant.stopReason !== "error") {
2412
+ const contextTokens = calculateContextTokens(assistant.usage);
2413
+ if (contextTokens > 0) {
2414
+ hasPostCompactionUsage = true;
2415
+ }
2416
+ break;
2417
+ }
2418
+ }
2419
+ }
2420
+ if (!hasPostCompactionUsage) {
2421
+ return { tokens: null, contextWindow, percent: null };
2422
+ }
2423
+ }
2424
+ const estimate = estimateContextTokens(this.messages);
2425
+ const percent = (estimate.tokens / contextWindow) * 100;
2426
+ return {
2427
+ tokens: estimate.tokens,
2428
+ contextWindow,
2429
+ percent,
2430
+ };
2431
+ }
2432
+ /**
2433
+ * Export session to HTML.
2434
+ * @param outputPath Optional output path (defaults to session directory)
2435
+ * @returns Path to exported file
2436
+ */
2437
+ async exportToHtml(outputPath) {
2438
+ const themeName = this.settingsManager.getTheme();
2439
+ // Create tool renderer if we have an extension runner (for custom tool HTML rendering)
2440
+ const toolRenderer = createToolHtmlRenderer({
2441
+ getToolDefinition: (name) => this.getToolDefinition(name),
2442
+ theme,
2443
+ cwd: this.sessionManager.getCwd(),
2444
+ });
2445
+ return await exportSessionToHtml(this.sessionManager, this.state, {
2446
+ outputPath,
2447
+ themeName,
2448
+ toolRenderer,
2449
+ });
2450
+ }
2451
+ /**
2452
+ * Export the current session branch to a JSONL file.
2453
+ * Writes the session header followed by all entries on the current branch path.
2454
+ * @param outputPath Target file path. If omitted, generates a timestamped file in cwd.
2455
+ * @returns The resolved output file path.
2456
+ */
2457
+ exportToJsonl(outputPath) {
2458
+ const filePath = resolvePath(outputPath ?? `session-${new Date().toISOString().replace(/[:.]/g, "-")}.jsonl`, process.cwd());
2459
+ const dir = dirname(filePath);
2460
+ if (!existsSync(dir)) {
2461
+ mkdirSync(dir, { recursive: true });
2462
+ }
2463
+ const header = {
2464
+ type: "session",
2465
+ version: CURRENT_SESSION_VERSION,
2466
+ id: this.sessionManager.getSessionId(),
2467
+ timestamp: new Date().toISOString(),
2468
+ cwd: this.sessionManager.getCwd(),
2469
+ };
2470
+ const branchEntries = this.sessionManager.getBranch();
2471
+ const lines = [JSON.stringify(header)];
2472
+ // Re-chain parentIds to form a linear sequence
2473
+ let prevId = null;
2474
+ for (const entry of branchEntries) {
2475
+ const linear = { ...entry, parentId: prevId };
2476
+ lines.push(JSON.stringify(linear));
2477
+ prevId = entry.id;
2478
+ }
2479
+ writeFileSync(filePath, `${lines.join("\n")}\n`);
2480
+ return filePath;
2481
+ }
2482
+ // =========================================================================
2483
+ // Utilities
2484
+ // =========================================================================
2485
+ /**
2486
+ * Get text content of last assistant message.
2487
+ * Useful for /copy command.
2488
+ * @returns Text content, or undefined if no assistant message exists
2489
+ */
2490
+ getLastAssistantText() {
2491
+ const lastAssistant = this.messages
2492
+ .slice()
2493
+ .reverse()
2494
+ .find((m) => {
2495
+ if (m.role !== "assistant")
2496
+ return false;
2497
+ const msg = m;
2498
+ // Skip aborted messages with no content
2499
+ if (msg.stopReason === "aborted" && msg.content.length === 0)
2500
+ return false;
2501
+ return true;
2502
+ });
2503
+ if (!lastAssistant)
2504
+ return undefined;
2505
+ let text = "";
2506
+ for (const content of lastAssistant.content) {
2507
+ if (content.type === "text") {
2508
+ text += content.text;
2509
+ }
2510
+ }
2511
+ return text.trim() || undefined;
2512
+ }
2513
+ // =========================================================================
2514
+ // Extension System
2515
+ // =========================================================================
2516
+ createReplacedSessionContext() {
2517
+ const context = Object.defineProperties({}, Object.getOwnPropertyDescriptors(this._extensionRunner.createCommandContext()));
2518
+ context.sendMessage = (message, options) => this.sendCustomMessage(message, options);
2519
+ context.sendUserMessage = (content, options) => this.sendUserMessage(content, options);
2520
+ return context;
2521
+ }
2522
+ /**
2523
+ * Check if extensions have handlers for a specific event type.
2524
+ */
2525
+ hasExtensionHandlers(eventType) {
2526
+ return this._extensionRunner.hasHandlers(eventType);
2527
+ }
2528
+ /**
2529
+ * Get the extension runner (for setting UI context and error handlers).
2530
+ */
2531
+ get extensionRunner() {
2532
+ return this._extensionRunner;
2533
+ }
2534
+ }
2535
+ //# sourceMappingURL=agent-session.js.map