@handy_wote/pi-coding-agent 0.81.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 (863) hide show
  1. package/CHANGELOG.md +5107 -0
  2. package/README.md +694 -0
  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 +11 -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 +17 -0
  12. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  13. package/dist/bun/restore-sandbox-env.js +36 -0
  14. package/dist/bun/restore-sandbox-env.js.map +1 -0
  15. package/dist/cli/args.d.ts +57 -0
  16. package/dist/cli/args.d.ts.map +1 -0
  17. package/dist/cli/args.js +381 -0
  18. package/dist/cli/args.js.map +1 -0
  19. package/dist/cli/config-selector.d.ts +16 -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 +70 -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 +95 -0
  34. package/dist/cli/list-models.js.map +1 -0
  35. package/dist/cli/project-trust.d.ts +10 -0
  36. package/dist/cli/project-trust.d.ts.map +1 -0
  37. package/dist/cli/project-trust.js +48 -0
  38. package/dist/cli/project-trust.js.map +1 -0
  39. package/dist/cli/session-picker.d.ts +10 -0
  40. package/dist/cli/session-picker.d.ts.map +1 -0
  41. package/dist/cli/session-picker.js +36 -0
  42. package/dist/cli/session-picker.js.map +1 -0
  43. package/dist/cli/startup-ui.d.ts +20 -0
  44. package/dist/cli/startup-ui.d.ts.map +1 -0
  45. package/dist/cli/startup-ui.js +184 -0
  46. package/dist/cli/startup-ui.js.map +1 -0
  47. package/dist/cli.d.ts +3 -0
  48. package/dist/cli.d.ts.map +1 -0
  49. package/dist/cli.js +18 -0
  50. package/dist/cli.js.map +1 -0
  51. package/dist/config.d.ts +98 -0
  52. package/dist/config.d.ts.map +1 -0
  53. package/dist/config.js +459 -0
  54. package/dist/config.js.map +1 -0
  55. package/dist/core/agent-session-runtime.d.ts +119 -0
  56. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  57. package/dist/core/agent-session-runtime.js +306 -0
  58. package/dist/core/agent-session-runtime.js.map +1 -0
  59. package/dist/core/agent-session-services.d.ts +85 -0
  60. package/dist/core/agent-session-services.d.ts.map +1 -0
  61. package/dist/core/agent-session-services.js +133 -0
  62. package/dist/core/agent-session-services.js.map +1 -0
  63. package/dist/core/agent-session.d.ts +642 -0
  64. package/dist/core/agent-session.d.ts.map +1 -0
  65. package/dist/core/agent-session.js +2684 -0
  66. package/dist/core/agent-session.js.map +1 -0
  67. package/dist/core/auth-storage.d.ts +56 -0
  68. package/dist/core/auth-storage.d.ts.map +1 -0
  69. package/dist/core/auth-storage.js +232 -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/cache-stats.d.ts +49 -0
  76. package/dist/core/cache-stats.d.ts.map +1 -0
  77. package/dist/core/cache-stats.js +101 -0
  78. package/dist/core/cache-stats.js.map +1 -0
  79. package/dist/core/compaction/branch-summarization.d.ts +98 -0
  80. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  81. package/dist/core/compaction/branch-summarization.js +246 -0
  82. package/dist/core/compaction/branch-summarization.js.map +1 -0
  83. package/dist/core/compaction/compaction.d.ts +137 -0
  84. package/dist/core/compaction/compaction.d.ts.map +1 -0
  85. package/dist/core/compaction/compaction.js +637 -0
  86. package/dist/core/compaction/compaction.js.map +1 -0
  87. package/dist/core/compaction/index.d.ts +7 -0
  88. package/dist/core/compaction/index.d.ts.map +1 -0
  89. package/dist/core/compaction/index.js +7 -0
  90. package/dist/core/compaction/index.js.map +1 -0
  91. package/dist/core/compaction/utils.d.ts +38 -0
  92. package/dist/core/compaction/utils.d.ts.map +1 -0
  93. package/dist/core/compaction/utils.js +142 -0
  94. package/dist/core/compaction/utils.js.map +1 -0
  95. package/dist/core/defaults.d.ts +3 -0
  96. package/dist/core/defaults.d.ts.map +1 -0
  97. package/dist/core/defaults.js +2 -0
  98. package/dist/core/defaults.js.map +1 -0
  99. package/dist/core/diagnostics.d.ts +15 -0
  100. package/dist/core/diagnostics.d.ts.map +1 -0
  101. package/dist/core/diagnostics.js +2 -0
  102. package/dist/core/diagnostics.js.map +1 -0
  103. package/dist/core/event-bus.d.ts +9 -0
  104. package/dist/core/event-bus.d.ts.map +1 -0
  105. package/dist/core/event-bus.js +25 -0
  106. package/dist/core/event-bus.js.map +1 -0
  107. package/dist/core/exec.d.ts +29 -0
  108. package/dist/core/exec.d.ts.map +1 -0
  109. package/dist/core/exec.js +75 -0
  110. package/dist/core/exec.js.map +1 -0
  111. package/dist/core/experimental.d.ts +2 -0
  112. package/dist/core/experimental.d.ts.map +1 -0
  113. package/dist/core/experimental.js +4 -0
  114. package/dist/core/experimental.js.map +1 -0
  115. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  116. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  117. package/dist/core/export-html/ansi-to-html.js +249 -0
  118. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  119. package/dist/core/export-html/index.d.ts +37 -0
  120. package/dist/core/export-html/index.d.ts.map +1 -0
  121. package/dist/core/export-html/index.js +226 -0
  122. package/dist/core/export-html/index.js.map +1 -0
  123. package/dist/core/export-html/template.css +1066 -0
  124. package/dist/core/export-html/template.html +55 -0
  125. package/dist/core/export-html/template.js +1864 -0
  126. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  127. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  128. package/dist/core/export-html/tool-renderer.js +108 -0
  129. package/dist/core/export-html/tool-renderer.js.map +1 -0
  130. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  131. package/dist/core/export-html/vendor/marked.min.js +78 -0
  132. package/dist/core/extensions/index.d.ts +12 -0
  133. package/dist/core/extensions/index.d.ts.map +1 -0
  134. package/dist/core/extensions/index.js +9 -0
  135. package/dist/core/extensions/index.js.map +1 -0
  136. package/dist/core/extensions/loader.d.ts +23 -0
  137. package/dist/core/extensions/loader.d.ts.map +1 -0
  138. package/dist/core/extensions/loader.js +586 -0
  139. package/dist/core/extensions/loader.js.map +1 -0
  140. package/dist/core/extensions/runner.d.ts +171 -0
  141. package/dist/core/extensions/runner.d.ts.map +1 -0
  142. package/dist/core/extensions/runner.js +953 -0
  143. package/dist/core/extensions/runner.js.map +1 -0
  144. package/dist/core/extensions/types.d.ts +1259 -0
  145. package/dist/core/extensions/types.d.ts.map +1 -0
  146. package/dist/core/extensions/types.js +45 -0
  147. package/dist/core/extensions/types.js.map +1 -0
  148. package/dist/core/extensions/wrapper.d.ts +20 -0
  149. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  150. package/dist/core/extensions/wrapper.js +41 -0
  151. package/dist/core/extensions/wrapper.js.map +1 -0
  152. package/dist/core/footer-data-provider.d.ts +54 -0
  153. package/dist/core/footer-data-provider.d.ts.map +1 -0
  154. package/dist/core/footer-data-provider.js +338 -0
  155. package/dist/core/footer-data-provider.js.map +1 -0
  156. package/dist/core/http-dispatcher.d.ts +22 -0
  157. package/dist/core/http-dispatcher.d.ts.map +1 -0
  158. package/dist/core/http-dispatcher.js +91 -0
  159. package/dist/core/http-dispatcher.js.map +1 -0
  160. package/dist/core/index.d.ts +13 -0
  161. package/dist/core/index.d.ts.map +1 -0
  162. package/dist/core/index.js +13 -0
  163. package/dist/core/index.js.map +1 -0
  164. package/dist/core/keybindings.d.ts +390 -0
  165. package/dist/core/keybindings.d.ts.map +1 -0
  166. package/dist/core/keybindings.js +296 -0
  167. package/dist/core/keybindings.js.map +1 -0
  168. package/dist/core/messages.d.ts +77 -0
  169. package/dist/core/messages.d.ts.map +1 -0
  170. package/dist/core/messages.js +123 -0
  171. package/dist/core/messages.js.map +1 -0
  172. package/dist/core/model-metadata.d.ts +30 -0
  173. package/dist/core/model-metadata.d.ts.map +1 -0
  174. package/dist/core/model-metadata.js +139 -0
  175. package/dist/core/model-metadata.js.map +1 -0
  176. package/dist/core/model-registry.d.ts +48 -0
  177. package/dist/core/model-registry.d.ts.map +1 -0
  178. package/dist/core/model-registry.js +105 -0
  179. package/dist/core/model-registry.js.map +1 -0
  180. package/dist/core/model-resolver.d.ts +121 -0
  181. package/dist/core/model-resolver.d.ts.map +1 -0
  182. package/dist/core/model-resolver.js +534 -0
  183. package/dist/core/model-resolver.js.map +1 -0
  184. package/dist/core/model-runtime.d.ts +84 -0
  185. package/dist/core/model-runtime.d.ts.map +1 -0
  186. package/dist/core/model-runtime.js +453 -0
  187. package/dist/core/model-runtime.js.map +1 -0
  188. package/dist/core/models-store.d.ts +17 -0
  189. package/dist/core/models-store.d.ts.map +1 -0
  190. package/dist/core/models-store.js +45 -0
  191. package/dist/core/models-store.js.map +1 -0
  192. package/dist/core/output-guard.d.ts +7 -0
  193. package/dist/core/output-guard.d.ts.map +1 -0
  194. package/dist/core/output-guard.js +89 -0
  195. package/dist/core/output-guard.js.map +1 -0
  196. package/dist/core/package-manager.d.ts +210 -0
  197. package/dist/core/package-manager.d.ts.map +1 -0
  198. package/dist/core/package-manager.js +2135 -0
  199. package/dist/core/package-manager.js.map +1 -0
  200. package/dist/core/profile-runtime.d.ts +4 -0
  201. package/dist/core/profile-runtime.d.ts.map +1 -0
  202. package/dist/core/profile-runtime.js +57 -0
  203. package/dist/core/profile-runtime.js.map +1 -0
  204. package/dist/core/profiles-store.d.ts +17 -0
  205. package/dist/core/profiles-store.d.ts.map +1 -0
  206. package/dist/core/profiles-store.js +100 -0
  207. package/dist/core/profiles-store.js.map +1 -0
  208. package/dist/core/profiles-types.d.ts +31 -0
  209. package/dist/core/profiles-types.d.ts.map +1 -0
  210. package/dist/core/profiles-types.js +4 -0
  211. package/dist/core/profiles-types.js.map +1 -0
  212. package/dist/core/project-trust.d.ts +15 -0
  213. package/dist/core/project-trust.d.ts.map +1 -0
  214. package/dist/core/project-trust.js +59 -0
  215. package/dist/core/project-trust.js.map +1 -0
  216. package/dist/core/prompt-templates.d.ts +54 -0
  217. package/dist/core/prompt-templates.d.ts.map +1 -0
  218. package/dist/core/prompt-templates.js +236 -0
  219. package/dist/core/prompt-templates.js.map +1 -0
  220. package/dist/core/provider-attribution.d.ts +4 -0
  221. package/dist/core/provider-attribution.d.ts.map +1 -0
  222. package/dist/core/provider-attribution.js +72 -0
  223. package/dist/core/provider-attribution.js.map +1 -0
  224. package/dist/core/radius.d.ts +2 -0
  225. package/dist/core/radius.d.ts.map +1 -0
  226. package/dist/core/radius.js +2 -0
  227. package/dist/core/radius.js.map +1 -0
  228. package/dist/core/resource-loader.d.ts +206 -0
  229. package/dist/core/resource-loader.d.ts.map +1 -0
  230. package/dist/core/resource-loader.js +817 -0
  231. package/dist/core/resource-loader.js.map +1 -0
  232. package/dist/core/sdk.d.ts +106 -0
  233. package/dist/core/sdk.d.ts.map +1 -0
  234. package/dist/core/sdk.js +269 -0
  235. package/dist/core/sdk.js.map +1 -0
  236. package/dist/core/session-cwd.d.ts +19 -0
  237. package/dist/core/session-cwd.d.ts.map +1 -0
  238. package/dist/core/session-cwd.js +38 -0
  239. package/dist/core/session-cwd.js.map +1 -0
  240. package/dist/core/session-manager.d.ts +356 -0
  241. package/dist/core/session-manager.d.ts.map +1 -0
  242. package/dist/core/session-manager.js +1338 -0
  243. package/dist/core/session-manager.js.map +1 -0
  244. package/dist/core/settings-manager.d.ts +297 -0
  245. package/dist/core/settings-manager.d.ts.map +1 -0
  246. package/dist/core/settings-manager.js +902 -0
  247. package/dist/core/settings-manager.js.map +1 -0
  248. package/dist/core/skills.d.ts +60 -0
  249. package/dist/core/skills.d.ts.map +1 -0
  250. package/dist/core/skills.js +387 -0
  251. package/dist/core/skills.js.map +1 -0
  252. package/dist/core/slash-commands.d.ts +15 -0
  253. package/dist/core/slash-commands.d.ts.map +1 -0
  254. package/dist/core/slash-commands.js +25 -0
  255. package/dist/core/slash-commands.js.map +1 -0
  256. package/dist/core/source-info.d.ts +18 -0
  257. package/dist/core/source-info.d.ts.map +1 -0
  258. package/dist/core/source-info.js +19 -0
  259. package/dist/core/source-info.js.map +1 -0
  260. package/dist/core/system-prompt.d.ts +28 -0
  261. package/dist/core/system-prompt.d.ts.map +1 -0
  262. package/dist/core/system-prompt.js +110 -0
  263. package/dist/core/system-prompt.js.map +1 -0
  264. package/dist/core/telemetry.d.ts +3 -0
  265. package/dist/core/telemetry.d.ts.map +1 -0
  266. package/dist/core/telemetry.js +9 -0
  267. package/dist/core/telemetry.js.map +1 -0
  268. package/dist/core/timings.d.ts +10 -0
  269. package/dist/core/timings.d.ts.map +1 -0
  270. package/dist/core/timings.js +41 -0
  271. package/dist/core/timings.js.map +1 -0
  272. package/dist/core/tools/bash.d.ts +68 -0
  273. package/dist/core/tools/bash.d.ts.map +1 -0
  274. package/dist/core/tools/bash.js +361 -0
  275. package/dist/core/tools/bash.js.map +1 -0
  276. package/dist/core/tools/edit-diff.d.ts +106 -0
  277. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  278. package/dist/core/tools/edit-diff.js +424 -0
  279. package/dist/core/tools/edit-diff.js.map +1 -0
  280. package/dist/core/tools/edit.d.ts +51 -0
  281. package/dist/core/tools/edit.d.ts.map +1 -0
  282. package/dist/core/tools/edit.js +284 -0
  283. package/dist/core/tools/edit.js.map +1 -0
  284. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  285. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  286. package/dist/core/tools/file-mutation-queue.js +52 -0
  287. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  288. package/dist/core/tools/find.d.ts +35 -0
  289. package/dist/core/tools/find.d.ts.map +1 -0
  290. package/dist/core/tools/find.js +305 -0
  291. package/dist/core/tools/find.js.map +1 -0
  292. package/dist/core/tools/grep.d.ts +37 -0
  293. package/dist/core/tools/grep.d.ts.map +1 -0
  294. package/dist/core/tools/grep.js +304 -0
  295. package/dist/core/tools/grep.js.map +1 -0
  296. package/dist/core/tools/index.d.ts +40 -0
  297. package/dist/core/tools/index.d.ts.map +1 -0
  298. package/dist/core/tools/index.js +112 -0
  299. package/dist/core/tools/index.js.map +1 -0
  300. package/dist/core/tools/ls.d.ts +37 -0
  301. package/dist/core/tools/ls.d.ts.map +1 -0
  302. package/dist/core/tools/ls.js +167 -0
  303. package/dist/core/tools/ls.js.map +1 -0
  304. package/dist/core/tools/output-accumulator.d.ts +52 -0
  305. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  306. package/dist/core/tools/output-accumulator.js +184 -0
  307. package/dist/core/tools/output-accumulator.js.map +1 -0
  308. package/dist/core/tools/path-utils.d.ts +10 -0
  309. package/dist/core/tools/path-utils.d.ts.map +1 -0
  310. package/dist/core/tools/path-utils.js +99 -0
  311. package/dist/core/tools/path-utils.js.map +1 -0
  312. package/dist/core/tools/read.d.ts +35 -0
  313. package/dist/core/tools/read.d.ts.map +1 -0
  314. package/dist/core/tools/read.js +276 -0
  315. package/dist/core/tools/read.js.map +1 -0
  316. package/dist/core/tools/render-utils.d.ts +24 -0
  317. package/dist/core/tools/render-utils.d.ts.map +1 -0
  318. package/dist/core/tools/render-utils.js +65 -0
  319. package/dist/core/tools/render-utils.js.map +1 -0
  320. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  321. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  322. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  323. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  324. package/dist/core/tools/truncate.d.ts +70 -0
  325. package/dist/core/tools/truncate.d.ts.map +1 -0
  326. package/dist/core/tools/truncate.js +215 -0
  327. package/dist/core/tools/truncate.js.map +1 -0
  328. package/dist/core/tools/write.d.ts +26 -0
  329. package/dist/core/tools/write.d.ts.map +1 -0
  330. package/dist/core/tools/write.js +197 -0
  331. package/dist/core/tools/write.js.map +1 -0
  332. package/dist/core/trust-manager.d.ts +36 -0
  333. package/dist/core/trust-manager.d.ts.map +1 -0
  334. package/dist/core/trust-manager.js +202 -0
  335. package/dist/core/trust-manager.js.map +1 -0
  336. package/dist/core/usage-totals.d.ts +19 -0
  337. package/dist/core/usage-totals.d.ts.map +1 -0
  338. package/dist/core/usage-totals.js +52 -0
  339. package/dist/core/usage-totals.js.map +1 -0
  340. package/dist/extensions/index.d.ts +3 -0
  341. package/dist/extensions/index.d.ts.map +1 -0
  342. package/dist/extensions/index.js +3 -0
  343. package/dist/extensions/index.js.map +1 -0
  344. package/dist/extensions/llama/client.d.ts +61 -0
  345. package/dist/extensions/llama/client.d.ts.map +1 -0
  346. package/dist/extensions/llama/client.js +302 -0
  347. package/dist/extensions/llama/client.js.map +1 -0
  348. package/dist/extensions/llama/huggingface.d.ts +23 -0
  349. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  350. package/dist/extensions/llama/huggingface.js +141 -0
  351. package/dist/extensions/llama/huggingface.js.map +1 -0
  352. package/dist/extensions/llama/index.d.ts +3 -0
  353. package/dist/extensions/llama/index.d.ts.map +1 -0
  354. package/dist/extensions/llama/index.js +208 -0
  355. package/dist/extensions/llama/index.js.map +1 -0
  356. package/dist/extensions/llama/provider.d.ts +10 -0
  357. package/dist/extensions/llama/provider.d.ts.map +1 -0
  358. package/dist/extensions/llama/provider.js +102 -0
  359. package/dist/extensions/llama/provider.js.map +1 -0
  360. package/dist/extensions/llama/ui.d.ts +42 -0
  361. package/dist/extensions/llama/ui.d.ts.map +1 -0
  362. package/dist/extensions/llama/ui.js +416 -0
  363. package/dist/extensions/llama/ui.js.map +1 -0
  364. package/dist/index.d.ts +35 -0
  365. package/dist/index.d.ts.map +1 -0
  366. package/dist/index.js +47 -0
  367. package/dist/index.js.map +1 -0
  368. package/dist/main.d.ts +12 -0
  369. package/dist/main.d.ts.map +1 -0
  370. package/dist/main.js +706 -0
  371. package/dist/main.js.map +1 -0
  372. package/dist/migrations.d.ts +33 -0
  373. package/dist/migrations.d.ts.map +1 -0
  374. package/dist/migrations.js +281 -0
  375. package/dist/migrations.js.map +1 -0
  376. package/dist/modes/index.d.ts +9 -0
  377. package/dist/modes/index.d.ts.map +1 -0
  378. package/dist/modes/index.js +8 -0
  379. package/dist/modes/index.js.map +1 -0
  380. package/dist/modes/interactive/assets/clankolas.png +0 -0
  381. package/dist/modes/interactive/components/armin.d.ts +34 -0
  382. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  383. package/dist/modes/interactive/components/armin.js +333 -0
  384. package/dist/modes/interactive/components/armin.js.map +1 -0
  385. package/dist/modes/interactive/components/assistant-message.d.ts +22 -0
  386. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  387. package/dist/modes/interactive/components/assistant-message.js +141 -0
  388. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  389. package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
  390. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  391. package/dist/modes/interactive/components/bash-execution.js +175 -0
  392. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  393. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  394. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  395. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  396. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  397. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  398. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  399. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  400. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  401. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  402. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  403. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  404. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  405. package/dist/modes/interactive/components/config-selector.d.ts +102 -0
  406. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  407. package/dist/modes/interactive/components/config-selector.js +761 -0
  408. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  409. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  410. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  411. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  412. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  413. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  414. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  415. package/dist/modes/interactive/components/custom-editor.js +70 -0
  416. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  417. package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
  418. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  419. package/dist/modes/interactive/components/custom-entry.js +52 -0
  420. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  421. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  422. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  423. package/dist/modes/interactive/components/custom-message.js +79 -0
  424. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  425. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  426. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  427. package/dist/modes/interactive/components/daxnuts.js +140 -0
  428. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  429. package/dist/modes/interactive/components/diff.d.ts +12 -0
  430. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  431. package/dist/modes/interactive/components/diff.js +133 -0
  432. package/dist/modes/interactive/components/diff.js.map +1 -0
  433. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  434. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  435. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  436. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  437. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  438. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  439. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  440. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  441. package/dist/modes/interactive/components/entity-list-theme.d.ts +3 -0
  442. package/dist/modes/interactive/components/entity-list-theme.d.ts.map +1 -0
  443. package/dist/modes/interactive/components/entity-list-theme.js +17 -0
  444. package/dist/modes/interactive/components/entity-list-theme.js.map +1 -0
  445. package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
  446. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  447. package/dist/modes/interactive/components/extension-editor.js +128 -0
  448. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  449. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  450. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  451. package/dist/modes/interactive/components/extension-input.js +61 -0
  452. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  453. package/dist/modes/interactive/components/extension-selector.d.ts +22 -0
  454. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  455. package/dist/modes/interactive/components/extension-selector.js +61 -0
  456. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  457. package/dist/modes/interactive/components/first-time-setup.d.ts +24 -0
  458. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
  459. package/dist/modes/interactive/components/first-time-setup.js +92 -0
  460. package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
  461. package/dist/modes/interactive/components/footer.d.ts +32 -0
  462. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  463. package/dist/modes/interactive/components/footer.js +222 -0
  464. package/dist/modes/interactive/components/footer.js.map +1 -0
  465. package/dist/modes/interactive/components/index.d.ts +32 -0
  466. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  467. package/dist/modes/interactive/components/index.js +33 -0
  468. package/dist/modes/interactive/components/index.js.map +1 -0
  469. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  470. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  471. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  472. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  473. package/dist/modes/interactive/components/model-selector.d.ts +50 -0
  474. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  475. package/dist/modes/interactive/components/model-selector.js +240 -0
  476. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  477. package/dist/modes/interactive/components/scoped-models-selector.d.ts +36 -0
  478. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  479. package/dist/modes/interactive/components/scoped-models-selector.js +222 -0
  480. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  481. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  482. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  483. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  484. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  485. package/dist/modes/interactive/components/session-selector.d.ts +95 -0
  486. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  487. package/dist/modes/interactive/components/session-selector.js +779 -0
  488. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  489. package/dist/modes/interactive/components/settings-selector.d.ts +77 -0
  490. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  491. package/dist/modes/interactive/components/settings-selector.js +593 -0
  492. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  493. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  494. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  495. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  496. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  497. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  498. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  499. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  500. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  501. package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
  502. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
  503. package/dist/modes/interactive/components/status-indicator.js +60 -0
  504. package/dist/modes/interactive/components/status-indicator.js.map +1 -0
  505. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  506. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  507. package/dist/modes/interactive/components/theme-selector.js +46 -0
  508. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  509. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  510. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  511. package/dist/modes/interactive/components/thinking-selector.js +47 -0
  512. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  513. package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
  514. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  515. package/dist/modes/interactive/components/tool-execution.js +317 -0
  516. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  517. package/dist/modes/interactive/components/tree-selector.d.ts +94 -0
  518. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  519. package/dist/modes/interactive/components/tree-selector.js +1245 -0
  520. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  521. package/dist/modes/interactive/components/trust-selector.d.ts +21 -0
  522. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  523. package/dist/modes/interactive/components/trust-selector.js +72 -0
  524. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  525. package/dist/modes/interactive/components/user-message-selector.d.ts +16 -0
  526. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  527. package/dist/modes/interactive/components/user-message-selector.js +53 -0
  528. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  529. package/dist/modes/interactive/components/user-message.d.ts +14 -0
  530. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  531. package/dist/modes/interactive/components/user-message.js +42 -0
  532. package/dist/modes/interactive/components/user-message.js.map +1 -0
  533. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  534. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  535. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  536. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  537. package/dist/modes/interactive/interactive-mode.d.ts +391 -0
  538. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  539. package/dist/modes/interactive/interactive-mode.js +4996 -0
  540. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  541. package/dist/modes/interactive/model-search.d.ts +12 -0
  542. package/dist/modes/interactive/model-search.d.ts.map +1 -0
  543. package/dist/modes/interactive/model-search.js +15 -0
  544. package/dist/modes/interactive/model-search.js.map +1 -0
  545. package/dist/modes/interactive/theme/dark.json +87 -0
  546. package/dist/modes/interactive/theme/light.json +86 -0
  547. package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
  548. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  549. package/dist/modes/interactive/theme/theme-controller.js +102 -0
  550. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  551. package/dist/modes/interactive/theme/theme-schema.json +340 -0
  552. package/dist/modes/interactive/theme/theme.d.ts +120 -0
  553. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  554. package/dist/modes/interactive/theme/theme.js +1063 -0
  555. package/dist/modes/interactive/theme/theme.js.map +1 -0
  556. package/dist/modes/print-mode.d.ts +28 -0
  557. package/dist/modes/print-mode.d.ts.map +1 -0
  558. package/dist/modes/print-mode.js +132 -0
  559. package/dist/modes/print-mode.js.map +1 -0
  560. package/dist/modes/rpc/jsonl.d.ts +17 -0
  561. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  562. package/dist/modes/rpc/jsonl.js +49 -0
  563. package/dist/modes/rpc/jsonl.js.map +1 -0
  564. package/dist/modes/rpc/rpc-client.d.ts +246 -0
  565. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  566. package/dist/modes/rpc/rpc-client.js +488 -0
  567. package/dist/modes/rpc/rpc-client.js.map +1 -0
  568. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  569. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  570. package/dist/modes/rpc/rpc-mode.js +639 -0
  571. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  572. package/dist/modes/rpc/rpc-types.d.ts +457 -0
  573. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  574. package/dist/modes/rpc/rpc-types.js +8 -0
  575. package/dist/modes/rpc/rpc-types.js.map +1 -0
  576. package/dist/package-manager-cli.d.ts +8 -0
  577. package/dist/package-manager-cli.d.ts.map +1 -0
  578. package/dist/package-manager-cli.js +775 -0
  579. package/dist/package-manager-cli.js.map +1 -0
  580. package/dist/rpc-entry.d.ts +3 -0
  581. package/dist/rpc-entry.d.ts.map +1 -0
  582. package/dist/rpc-entry.js +10 -0
  583. package/dist/rpc-entry.js.map +1 -0
  584. package/dist/utils/ansi.d.ts +2 -0
  585. package/dist/utils/ansi.d.ts.map +1 -0
  586. package/dist/utils/ansi.js +52 -0
  587. package/dist/utils/ansi.js.map +1 -0
  588. package/dist/utils/changelog.d.ts +22 -0
  589. package/dist/utils/changelog.d.ts.map +1 -0
  590. package/dist/utils/changelog.js +165 -0
  591. package/dist/utils/changelog.js.map +1 -0
  592. package/dist/utils/child-process.d.ts +18 -0
  593. package/dist/utils/child-process.d.ts.map +1 -0
  594. package/dist/utils/child-process.js +106 -0
  595. package/dist/utils/child-process.js.map +1 -0
  596. package/dist/utils/clipboard-image.d.ts +11 -0
  597. package/dist/utils/clipboard-image.d.ts.map +1 -0
  598. package/dist/utils/clipboard-image.js +245 -0
  599. package/dist/utils/clipboard-image.js.map +1 -0
  600. package/dist/utils/clipboard-native.d.ts +11 -0
  601. package/dist/utils/clipboard-native.d.ts.map +1 -0
  602. package/dist/utils/clipboard-native.js +20 -0
  603. package/dist/utils/clipboard-native.js.map +1 -0
  604. package/dist/utils/clipboard.d.ts +4 -0
  605. package/dist/utils/clipboard.d.ts.map +1 -0
  606. package/dist/utils/clipboard.js +130 -0
  607. package/dist/utils/clipboard.js.map +1 -0
  608. package/dist/utils/deprecation.d.ts +4 -0
  609. package/dist/utils/deprecation.d.ts.map +1 -0
  610. package/dist/utils/deprecation.js +13 -0
  611. package/dist/utils/deprecation.js.map +1 -0
  612. package/dist/utils/exif-orientation.d.ts +5 -0
  613. package/dist/utils/exif-orientation.d.ts.map +1 -0
  614. package/dist/utils/exif-orientation.js +158 -0
  615. package/dist/utils/exif-orientation.js.map +1 -0
  616. package/dist/utils/frontmatter.d.ts +8 -0
  617. package/dist/utils/frontmatter.d.ts.map +1 -0
  618. package/dist/utils/frontmatter.js +26 -0
  619. package/dist/utils/frontmatter.js.map +1 -0
  620. package/dist/utils/fs-watch.d.ts +5 -0
  621. package/dist/utils/fs-watch.d.ts.map +1 -0
  622. package/dist/utils/fs-watch.js +25 -0
  623. package/dist/utils/fs-watch.js.map +1 -0
  624. package/dist/utils/git.d.ts +26 -0
  625. package/dist/utils/git.d.ts.map +1 -0
  626. package/dist/utils/git.js +195 -0
  627. package/dist/utils/git.js.map +1 -0
  628. package/dist/utils/html.d.ts +7 -0
  629. package/dist/utils/html.d.ts.map +1 -0
  630. package/dist/utils/html.js +40 -0
  631. package/dist/utils/html.js.map +1 -0
  632. package/dist/utils/image-convert.d.ts +10 -0
  633. package/dist/utils/image-convert.d.ts.map +1 -0
  634. package/dist/utils/image-convert.js +45 -0
  635. package/dist/utils/image-convert.js.map +1 -0
  636. package/dist/utils/image-process.d.ts +18 -0
  637. package/dist/utils/image-process.d.ts.map +1 -0
  638. package/dist/utils/image-process.js +83 -0
  639. package/dist/utils/image-process.js.map +1 -0
  640. package/dist/utils/image-resize-core.d.ts +30 -0
  641. package/dist/utils/image-resize-core.d.ts.map +1 -0
  642. package/dist/utils/image-resize-core.js +124 -0
  643. package/dist/utils/image-resize-core.js.map +1 -0
  644. package/dist/utils/image-resize-worker.d.ts +2 -0
  645. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  646. package/dist/utils/image-resize-worker.js +31 -0
  647. package/dist/utils/image-resize-worker.js.map +1 -0
  648. package/dist/utils/image-resize.d.ts +16 -0
  649. package/dist/utils/image-resize.d.ts.map +1 -0
  650. package/dist/utils/image-resize.js +97 -0
  651. package/dist/utils/image-resize.js.map +1 -0
  652. package/dist/utils/json.d.ts +3 -0
  653. package/dist/utils/json.d.ts.map +1 -0
  654. package/dist/utils/json.js +7 -0
  655. package/dist/utils/json.js.map +1 -0
  656. package/dist/utils/mime.d.ts +3 -0
  657. package/dist/utils/mime.d.ts.map +1 -0
  658. package/dist/utils/mime.js +110 -0
  659. package/dist/utils/mime.js.map +1 -0
  660. package/dist/utils/open-browser.d.ts +9 -0
  661. package/dist/utils/open-browser.d.ts.map +1 -0
  662. package/dist/utils/open-browser.js +22 -0
  663. package/dist/utils/open-browser.js.map +1 -0
  664. package/dist/utils/paths.d.ts +31 -0
  665. package/dist/utils/paths.d.ts.map +1 -0
  666. package/dist/utils/paths.js +92 -0
  667. package/dist/utils/paths.js.map +1 -0
  668. package/dist/utils/photon.d.ts +21 -0
  669. package/dist/utils/photon.d.ts.map +1 -0
  670. package/dist/utils/photon.js +121 -0
  671. package/dist/utils/photon.js.map +1 -0
  672. package/dist/utils/pi-user-agent.d.ts +2 -0
  673. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  674. package/dist/utils/pi-user-agent.js +5 -0
  675. package/dist/utils/pi-user-agent.js.map +1 -0
  676. package/dist/utils/shell.d.ts +31 -0
  677. package/dist/utils/shell.d.ts.map +1 -0
  678. package/dist/utils/shell.js +202 -0
  679. package/dist/utils/shell.js.map +1 -0
  680. package/dist/utils/sleep.d.ts +5 -0
  681. package/dist/utils/sleep.d.ts.map +1 -0
  682. package/dist/utils/sleep.js +17 -0
  683. package/dist/utils/sleep.js.map +1 -0
  684. package/dist/utils/syntax-highlight.d.ts +12 -0
  685. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  686. package/dist/utils/syntax-highlight.js +118 -0
  687. package/dist/utils/syntax-highlight.js.map +1 -0
  688. package/dist/utils/tools-manager.d.ts +3 -0
  689. package/dist/utils/tools-manager.d.ts.map +1 -0
  690. package/dist/utils/tools-manager.js +328 -0
  691. package/dist/utils/tools-manager.js.map +1 -0
  692. package/dist/utils/version-check.d.ts +15 -0
  693. package/dist/utils/version-check.d.ts.map +1 -0
  694. package/dist/utils/version-check.js +59 -0
  695. package/dist/utils/version-check.js.map +1 -0
  696. package/dist/utils/windows-self-update.d.ts +3 -0
  697. package/dist/utils/windows-self-update.d.ts.map +1 -0
  698. package/dist/utils/windows-self-update.js +77 -0
  699. package/dist/utils/windows-self-update.js.map +1 -0
  700. package/docs/compaction.md +401 -0
  701. package/docs/containerization.md +111 -0
  702. package/docs/custom-provider.md +763 -0
  703. package/docs/development.md +71 -0
  704. package/docs/docs.json +156 -0
  705. package/docs/extensions.md +2953 -0
  706. package/docs/images/doom-extension.png +0 -0
  707. package/docs/images/exy.png +0 -0
  708. package/docs/images/interactive-mode.png +0 -0
  709. package/docs/images/tree-view.png +0 -0
  710. package/docs/index.md +83 -0
  711. package/docs/json.md +86 -0
  712. package/docs/keybindings.md +198 -0
  713. package/docs/llama-cpp.md +99 -0
  714. package/docs/models.md +540 -0
  715. package/docs/packages.md +228 -0
  716. package/docs/prompt-templates.md +96 -0
  717. package/docs/providers.md +301 -0
  718. package/docs/quickstart.md +165 -0
  719. package/docs/rpc.md +1559 -0
  720. package/docs/sdk.md +1186 -0
  721. package/docs/security.md +59 -0
  722. package/docs/session-format.md +436 -0
  723. package/docs/sessions.md +145 -0
  724. package/docs/settings.md +319 -0
  725. package/docs/shell-aliases.md +13 -0
  726. package/docs/skills.md +231 -0
  727. package/docs/terminal-setup.md +142 -0
  728. package/docs/termux.md +127 -0
  729. package/docs/themes.md +297 -0
  730. package/docs/tmux.md +63 -0
  731. package/docs/tui.md +942 -0
  732. package/docs/usage.md +311 -0
  733. package/docs/windows.md +17 -0
  734. package/examples/README.md +25 -0
  735. package/examples/extensions/README.md +213 -0
  736. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  737. package/examples/extensions/bash-spawn-hook.ts +30 -0
  738. package/examples/extensions/bookmark.ts +50 -0
  739. package/examples/extensions/border-status-editor.ts +150 -0
  740. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  741. package/examples/extensions/claude-rules.ts +86 -0
  742. package/examples/extensions/commands.ts +72 -0
  743. package/examples/extensions/confirm-destructive.ts +59 -0
  744. package/examples/extensions/custom-compaction.ts +129 -0
  745. package/examples/extensions/custom-footer.ts +64 -0
  746. package/examples/extensions/custom-header.ts +73 -0
  747. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  748. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  749. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  750. package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -0
  751. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  752. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  753. package/examples/extensions/dirty-repo-guard.ts +56 -0
  754. package/examples/extensions/doom-overlay/README.md +46 -0
  755. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  756. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  757. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  758. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  759. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  760. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  761. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  762. package/examples/extensions/doom-overlay/index.ts +74 -0
  763. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  764. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  765. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  766. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  767. package/examples/extensions/dynamic-resources/index.ts +15 -0
  768. package/examples/extensions/dynamic-tools.ts +74 -0
  769. package/examples/extensions/entry-renderer.ts +41 -0
  770. package/examples/extensions/event-bus.ts +43 -0
  771. package/examples/extensions/file-trigger.ts +41 -0
  772. package/examples/extensions/git-checkpoint.ts +53 -0
  773. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  774. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  775. package/examples/extensions/gondolin/index.ts +531 -0
  776. package/examples/extensions/gondolin/package-lock.json +185 -0
  777. package/examples/extensions/gondolin/package.json +19 -0
  778. package/examples/extensions/handoff.ts +191 -0
  779. package/examples/extensions/hello.ts +26 -0
  780. package/examples/extensions/hidden-thinking-label.ts +53 -0
  781. package/examples/extensions/inline-bash.ts +94 -0
  782. package/examples/extensions/input-transform-streaming.ts +39 -0
  783. package/examples/extensions/input-transform.ts +43 -0
  784. package/examples/extensions/interactive-shell.ts +196 -0
  785. package/examples/extensions/kimi-deferred-tools.ts +61 -0
  786. package/examples/extensions/mac-system-theme.ts +47 -0
  787. package/examples/extensions/message-renderer.ts +59 -0
  788. package/examples/extensions/minimal-mode.ts +426 -0
  789. package/examples/extensions/modal-editor.ts +85 -0
  790. package/examples/extensions/model-status.ts +31 -0
  791. package/examples/extensions/notify.ts +55 -0
  792. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  793. package/examples/extensions/overlay-test.ts +153 -0
  794. package/examples/extensions/permission-gate.ts +34 -0
  795. package/examples/extensions/pirate.ts +47 -0
  796. package/examples/extensions/plan-mode/README.md +66 -0
  797. package/examples/extensions/plan-mode/index.ts +390 -0
  798. package/examples/extensions/plan-mode/utils.ts +168 -0
  799. package/examples/extensions/preset.ts +436 -0
  800. package/examples/extensions/project-trust.ts +64 -0
  801. package/examples/extensions/prompt-customizer.ts +97 -0
  802. package/examples/extensions/protected-paths.ts +30 -0
  803. package/examples/extensions/provider-payload.ts +18 -0
  804. package/examples/extensions/qna.ts +122 -0
  805. package/examples/extensions/question.ts +278 -0
  806. package/examples/extensions/questionnaire.ts +440 -0
  807. package/examples/extensions/rainbow-editor.ts +88 -0
  808. package/examples/extensions/reload-runtime.ts +37 -0
  809. package/examples/extensions/rpc-demo.ts +118 -0
  810. package/examples/extensions/sandbox/index.ts +321 -0
  811. package/examples/extensions/sandbox/package-lock.json +92 -0
  812. package/examples/extensions/sandbox/package.json +19 -0
  813. package/examples/extensions/send-user-message.ts +97 -0
  814. package/examples/extensions/session-name.ts +27 -0
  815. package/examples/extensions/shutdown-command.ts +63 -0
  816. package/examples/extensions/snake.ts +343 -0
  817. package/examples/extensions/space-invaders.ts +560 -0
  818. package/examples/extensions/ssh.ts +220 -0
  819. package/examples/extensions/status-line.ts +32 -0
  820. package/examples/extensions/structured-output.ts +65 -0
  821. package/examples/extensions/subagent/README.md +175 -0
  822. package/examples/extensions/subagent/agents/planner.md +37 -0
  823. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  824. package/examples/extensions/subagent/agents/scout.md +50 -0
  825. package/examples/extensions/subagent/agents/worker.md +24 -0
  826. package/examples/extensions/subagent/agents.ts +126 -0
  827. package/examples/extensions/subagent/index.ts +1015 -0
  828. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  829. package/examples/extensions/subagent/prompts/implement.md +10 -0
  830. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  831. package/examples/extensions/summarize.ts +207 -0
  832. package/examples/extensions/system-prompt-header.ts +17 -0
  833. package/examples/extensions/tic-tac-toe.ts +1008 -0
  834. package/examples/extensions/timed-confirm.ts +70 -0
  835. package/examples/extensions/titlebar-spinner.ts +58 -0
  836. package/examples/extensions/todo.ts +297 -0
  837. package/examples/extensions/tool-override.ts +144 -0
  838. package/examples/extensions/tools.ts +146 -0
  839. package/examples/extensions/trigger-compact.ts +50 -0
  840. package/examples/extensions/truncated-tool.ts +195 -0
  841. package/examples/extensions/widget-placement.ts +9 -0
  842. package/examples/extensions/with-deps/index.ts +32 -0
  843. package/examples/extensions/with-deps/package-lock.json +31 -0
  844. package/examples/extensions/with-deps/package.json +22 -0
  845. package/examples/extensions/working-indicator.ts +123 -0
  846. package/examples/extensions/working-message-test.ts +25 -0
  847. package/examples/rpc-extension-ui.ts +632 -0
  848. package/examples/sdk/01-minimal.ts +26 -0
  849. package/examples/sdk/02-custom-model.ts +50 -0
  850. package/examples/sdk/03-custom-prompt.ts +70 -0
  851. package/examples/sdk/04-skills.ts +55 -0
  852. package/examples/sdk/05-tools.ts +48 -0
  853. package/examples/sdk/06-extensions.ts +94 -0
  854. package/examples/sdk/07-context-files.ts +42 -0
  855. package/examples/sdk/08-prompt-templates.ts +51 -0
  856. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  857. package/examples/sdk/10-settings.ts +53 -0
  858. package/examples/sdk/11-sessions.ts +52 -0
  859. package/examples/sdk/12-full-control.ts +72 -0
  860. package/examples/sdk/13-session-runtime.ts +67 -0
  861. package/examples/sdk/README.md +140 -0
  862. package/npm-shrinkwrap.json +1824 -0
  863. package/package.json +100 -0
@@ -0,0 +1,84 @@
1
+ import { type Api, type AssistantMessage, type AssistantMessageEventStream, type AuthCheck, type AuthInteraction, type AuthResult, type AuthType, type Context, type Credential, type CredentialInfo, type CredentialStore, type Model, type Models, type ModelsApiStreamOptions, type ModelsRefreshOptions, type ModelsRefreshResult, type ModelsSimpleStreamOptions, type ModelsStore, type Provider } from "@handy_wote/pi-ai";
2
+ import type { ProviderConfig } from "./extensions/types.ts";
3
+ import type { Profile } from "./profiles-types.ts";
4
+ export interface CreateModelRuntimeOptions {
5
+ credentials?: CredentialStore;
6
+ authPath?: string;
7
+ profilesPath?: string;
8
+ modelsStore?: ModelsStore;
9
+ modelsStorePath?: string;
10
+ /** @deprecated Use profiles instead. */
11
+ modelsPath?: string | null;
12
+ /** @deprecated No-op in profile mode. */
13
+ allowModelNetwork?: boolean;
14
+ /** @deprecated No-op in profile mode. */
15
+ catalogBaseUrl?: string;
16
+ /** @deprecated No-op in profile mode. */
17
+ modelRefreshTimeoutMs?: number;
18
+ }
19
+ export interface ModelRuntimeAuthOverrides {
20
+ apiKey?: string;
21
+ env?: Record<string, string>;
22
+ }
23
+ export declare class ModelRuntime implements Models {
24
+ private readonly models;
25
+ private readonly credentials;
26
+ private readonly profilesStore;
27
+ private readonly registeredProviderConfigs;
28
+ private readonly registeredNativeProviders;
29
+ private snapshot;
30
+ private availabilityRefresh;
31
+ private availabilityError;
32
+ private constructor();
33
+ static create(options?: CreateModelRuntimeOptions): Promise<ModelRuntime>;
34
+ private rebuildProviders;
35
+ private updateModelSnapshot;
36
+ private runAvailabilityRefresh;
37
+ private queueAvailabilityRefresh;
38
+ private refreshAvailability;
39
+ private forceRefreshAvailability;
40
+ getProfiles(): readonly Profile[];
41
+ getProfile(id: string): Profile | undefined;
42
+ createProfile(profile: Profile): Promise<void>;
43
+ updateProfile(id: string, fn: (p: Profile) => Profile): Promise<void>;
44
+ deleteProfile(id: string): Promise<void>;
45
+ setActiveProfile(id: string | undefined): void;
46
+ getActiveProfile(): Profile | undefined;
47
+ getProviders(): readonly Provider[];
48
+ getProvider(providerId: string): Provider | undefined;
49
+ getModels(providerId?: string): readonly Model<Api>[];
50
+ getModel(providerId: string, modelId: string): Model<Api> | undefined;
51
+ checkAuth(providerId: string): Promise<AuthCheck | undefined>;
52
+ getAvailable(providerId?: string): Promise<readonly Model<Api>[]>;
53
+ getAvailableSnapshot(): readonly Model<Api>[];
54
+ getError(): string | undefined;
55
+ hasConfiguredAuth(providerId: string): boolean;
56
+ getProviderAuthStatus(providerId: string): {
57
+ configured: boolean;
58
+ source?: "stored" | "runtime" | "environment" | "fallback" | "models_json_key" | "models_json_command";
59
+ label?: string;
60
+ };
61
+ isUsingOAuth(providerId: string): boolean;
62
+ getAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
63
+ getAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;
64
+ listCredentials(): Promise<readonly CredentialInfo[]>;
65
+ login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential>;
66
+ logout(providerId: string): Promise<void>;
67
+ reloadConfig(): Promise<void>;
68
+ refresh(options?: ModelsRefreshOptions): Promise<ModelsRefreshResult>;
69
+ registerNativeProvider(provider: Provider): void;
70
+ registerProvider(providerId: string, config: ProviderConfig): void;
71
+ unregisterProvider(providerId: string): void;
72
+ getRegisteredProviderConfig(providerId: string): ProviderConfig | undefined;
73
+ getRegisteredProviderIds(): readonly string[];
74
+ getRegisteredNativeProvider(providerId: string): Provider | undefined;
75
+ getCompatibilityRequestConfig(_model: Model<Api>): any;
76
+ setRuntimeApiKey(providerId: string, apiKey: string, refreshOptions?: ModelsRefreshOptions): Promise<void>;
77
+ removeRuntimeApiKey(providerId: string): Promise<void>;
78
+ private prepareRequest;
79
+ stream<TApi extends Api>(model: Model<TApi>, context: Context, options?: ModelsApiStreamOptions<TApi>): AssistantMessageEventStream;
80
+ complete<TApi extends Api>(model: Model<TApi>, context: Context, options?: ModelsApiStreamOptions<TApi>): Promise<AssistantMessage>;
81
+ streamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream;
82
+ completeSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage>;
83
+ }
84
+ //# sourceMappingURL=model-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-runtime.d.ts","sourceRoot":"","sources":["../../src/core/model-runtime.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n\ttype Api,\n\ttype ApiStreamOptions,\n\ttype AssistantMessage,\n\ttype AssistantMessageEventStream,\n\ttype AuthCheck,\n\ttype AuthInteraction,\n\ttype AuthResult,\n\ttype AuthType,\n\ttype Context,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tcreateModels,\n\tcreateProvider,\n\tlazyStream,\n\ttype Model,\n\ttype Models,\n\ttype ModelsApiStreamOptions,\n\tModelsError,\n\ttype ModelsRefreshOptions,\n\ttype ModelsRefreshResult,\n\ttype ModelsSimpleStreamOptions,\n\ttype ModelsStore,\n\ttype ModelsStreamTransforms,\n\ttype MutableModels,\n\ttype Provider,\n\ttype ProviderHeaders,\n\ttype ProviderStreams,\n\ttype SimpleStreamOptions,\n\ttype StreamOptions,\n} from \"@handy_wote/pi-ai\";\nimport { anthropicMessagesApi } from \"@handy_wote/pi-ai/api/anthropic-messages.lazy\";\nimport { openAICompletionsApi } from \"@handy_wote/pi-ai/api/openai-completions.lazy\";\nimport { openAIResponsesApi } from \"@handy_wote/pi-ai/api/openai-responses.lazy\";\nimport type { ProviderConfig, ProviderModelConfig } from \"./extensions/types.ts\";\nimport { FileModelsStore, InMemoryCodingAgentModelsStore } from \"./models-store.ts\";\nimport { createProfileProvider } from \"./profile-runtime.ts\";\nimport { ProfilesStore } from \"./profiles-store.ts\";\nimport type { Profile } from \"./profiles-types.ts\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nclass RuntimeCredentials {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tasync read(_provider: string): Promise<any> {\n\t\treturn undefined;\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tasync modify(_provider: string, fn: any): Promise<any> {\n\t\treturn fn(undefined);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tasync delete(_provider: string): Promise<void> {}\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tasync list(): Promise<readonly any[]> {\n\t\treturn [];\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\n\tsetRuntimeApiKey(_providerId: string, _apiKey: string): void {}\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\n\tremoveRuntimeApiKey(_providerId: string): void {}\n}\n\ninterface ModelRuntimeSnapshot {\n\tall: readonly Model<Api>[];\n\tavailable: readonly Model<Api>[];\n\tconfiguredProviders: ReadonlySet<string>;\n\tstoredProviders: ReadonlySet<string>;\n\tauth: ReadonlyMap<string, AuthCheck | undefined>;\n}\n\nexport interface CreateModelRuntimeOptions {\n\tcredentials?: CredentialStore;\n\tauthPath?: string;\n\tprofilesPath?: string;\n\tmodelsStore?: ModelsStore;\n\tmodelsStorePath?: string;\n\t/** @deprecated Use profiles instead. */\n\tmodelsPath?: string | null;\n\t/** @deprecated No-op in profile mode. */\n\tallowModelNetwork?: boolean;\n\t/** @deprecated No-op in profile mode. */\n\tcatalogBaseUrl?: string;\n\t/** @deprecated No-op in profile mode. */\n\tmodelRefreshTimeoutMs?: number;\n}\n\nexport interface ModelRuntimeAuthOverrides {\n\tapiKey?: string;\n\tenv?: Record<string, string>;\n}\n\nfunction mergeHeaders(\n\tbase: ProviderHeaders | undefined,\n\toverride: ProviderHeaders | undefined,\n): ProviderHeaders | undefined {\n\tif (!base && !override) return undefined;\n\tconst merged = { ...base };\n\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\tconst lowerName = name.toLowerCase();\n\t\tfor (const existingName of Object.keys(merged)) {\n\t\t\tif (existingName.toLowerCase() === lowerName) delete merged[existingName];\n\t\t}\n\t\tmerged[name] = value;\n\t}\n\treturn merged;\n}\n\nfunction resolveConfiguredApiKey(\n\tvalue: string | undefined,\n\tenv: Record<string, string | undefined>,\n): string | undefined {\n\tif (!value) return undefined;\n\tif (value.startsWith(\"${\") && value.endsWith(\"}\")) return env[value.slice(2, -1)];\n\tif (value.startsWith(\"$\")) return env[value.slice(1)];\n\treturn value;\n}\n\nfunction getBuiltInApi(api: Api): ProviderStreams | undefined {\n\tif (api === \"anthropic-messages\") return anthropicMessagesApi();\n\tif (api === \"openai-completions\") return openAICompletionsApi();\n\tif (api === \"openai-responses\") return openAIResponsesApi();\n\treturn undefined;\n}\n\nfunction providerModelConfigToModel(\n\tproviderId: string,\n\tconfig: ProviderConfig,\n\tmodelConfig: ProviderModelConfig,\n): Model<Api> {\n\tconst api = modelConfig.api ?? config.api;\n\tif (!api) {\n\t\tthrow new Error(`Provider ${providerId}: \"api\" is required when registering models.`);\n\t}\n\tconst baseUrl = modelConfig.baseUrl ?? config.baseUrl;\n\tif (!baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when registering models.`);\n\t}\n\treturn {\n\t\tid: modelConfig.id,\n\t\tname: modelConfig.name,\n\t\tprovider: providerId,\n\t\tapi,\n\t\tbaseUrl,\n\t\treasoning: modelConfig.reasoning,\n\t\tthinkingLevelMap: modelConfig.thinkingLevelMap,\n\t\tinput: modelConfig.input,\n\t\tcost: modelConfig.cost,\n\t\tcontextWindow: modelConfig.contextWindow,\n\t\tmaxTokens: modelConfig.maxTokens,\n\t\theaders: modelConfig.headers,\n\t\tcompat: modelConfig.compat,\n\t} as Model<Api>;\n}\n\nfunction createExtensionProvider(providerId: string, config: ProviderConfig): Provider {\n\tif (config.streamSimple && !config.api) {\n\t\tthrow new Error(`Provider ${providerId}: \"api\" is required when registering streamSimple.`);\n\t}\n\n\tconst models = (config.models ?? []).map((modelConfig) =>\n\t\tproviderModelConfigToModel(providerId, config, modelConfig),\n\t);\n\tconst api =\n\t\tconfig.streamSimple && config.api\n\t\t\t? ({\n\t\t\t\t\tstream: (model, context, options) => config.streamSimple!(model, context, options),\n\t\t\t\t\tstreamSimple: config.streamSimple,\n\t\t\t\t} satisfies ProviderStreams)\n\t\t\t: Object.fromEntries(\n\t\t\t\t\tArray.from(new Set(models.map((model) => model.api)))\n\t\t\t\t\t\t.map((modelApi) => [modelApi, getBuiltInApi(modelApi)] as const)\n\t\t\t\t\t\t.filter((entry): entry is readonly [Api, ProviderStreams] => entry[1] !== undefined),\n\t\t\t\t);\n\n\treturn createProvider({\n\t\tid: providerId,\n\t\tname: config.name ?? providerId,\n\t\tbaseUrl: config.baseUrl,\n\t\theaders: config.headers,\n\t\tauth: {\n\t\t\tapiKey: {\n\t\t\t\tname: \"API Key\",\n\t\t\t\tresolve: async ({ ctx, credential }) => {\n\t\t\t\t\tconst env: Record<string, string | undefined> = {};\n\t\t\t\t\tif (config.apiKey?.startsWith(\"$\")) {\n\t\t\t\t\t\tconst envName =\n\t\t\t\t\t\t\tconfig.apiKey.startsWith(\"${\") && config.apiKey.endsWith(\"}\")\n\t\t\t\t\t\t\t\t? config.apiKey.slice(2, -1)\n\t\t\t\t\t\t\t\t: config.apiKey.slice(1);\n\t\t\t\t\t\tenv[envName] = await ctx.env(envName);\n\t\t\t\t\t}\n\t\t\t\t\tconst apiKey =\n\t\t\t\t\t\tcredential?.type === \"api_key\" ? credential.key : resolveConfiguredApiKey(config.apiKey, env);\n\t\t\t\t\tconst headers = { ...(config.headers ?? {}) };\n\t\t\t\t\tif (config.authHeader && apiKey) headers.Authorization = `Bearer ${apiKey}`;\n\t\t\t\t\treturn { auth: { apiKey, headers, baseUrl: config.baseUrl } };\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tmodels,\n\t\tfetchModels: config.refreshModels\n\t\t\t? async (context) =>\n\t\t\t\t\t(await config.refreshModels!(context)).map((modelConfig) =>\n\t\t\t\t\t\tproviderModelConfigToModel(providerId, config, modelConfig),\n\t\t\t\t\t)\n\t\t\t: undefined,\n\t\tapi,\n\t});\n}\n\nexport class ModelRuntime implements Models {\n\tprivate readonly models: MutableModels;\n\tprivate readonly credentials: RuntimeCredentials;\n\tprivate readonly profilesStore: ProfilesStore;\n\tprivate readonly registeredProviderConfigs = new Map<string, ProviderConfig>();\n\tprivate readonly registeredNativeProviders = new Map<string, Provider>();\n\tprivate snapshot: ModelRuntimeSnapshot = {\n\t\tall: [],\n\t\tavailable: [],\n\t\tconfiguredProviders: new Set(),\n\t\tstoredProviders: new Set(),\n\t\tauth: new Map(),\n\t};\n\tprivate availabilityRefresh: Promise<void> | undefined;\n\tprivate availabilityError: string | undefined;\n\n\tprivate constructor(credentials: RuntimeCredentials, profilesStore: ProfilesStore, modelsStore: ModelsStore) {\n\t\tthis.credentials = credentials;\n\t\tthis.profilesStore = profilesStore;\n\t\tthis.models = createModels({ credentials, modelsStore });\n\t\tthis.rebuildProviders();\n\t}\n\n\tstatic async create(options: CreateModelRuntimeOptions = {}): Promise<ModelRuntime> {\n\t\tconst credentials = new RuntimeCredentials();\n\t\tconst profilesStore = new ProfilesStore(options.profilesPath);\n\t\tconst modelsStore =\n\t\t\toptions.modelsStore ??\n\t\t\t(options.modelsStorePath\n\t\t\t\t? new FileModelsStore(options.modelsStorePath)\n\t\t\t\t: new InMemoryCodingAgentModelsStore());\n\t\tconst runtime = new ModelRuntime(credentials, profilesStore, modelsStore);\n\t\tawait runtime.forceRefreshAvailability();\n\t\treturn runtime;\n\t}\n\n\tprivate rebuildProviders(): void {\n\t\tthis.models.clearProviders();\n\t\tconst profiles = this.profilesStore.list();\n\t\tfor (const profile of profiles) {\n\t\t\ttry {\n\t\t\t\tconst provider = createProfileProvider(profile);\n\t\t\t\tthis.models.setProvider(provider);\n\t\t\t} catch {\n\t\t\t\t// Skip broken profiles; error is available via getError()\n\t\t\t}\n\t\t}\n\t\tfor (const [providerId, config] of this.registeredProviderConfigs) {\n\t\t\ttry {\n\t\t\t\tthis.models.setProvider(createExtensionProvider(providerId, config));\n\t\t\t} catch {\n\t\t\t\t// Skip broken extension providers; registration reports errors synchronously.\n\t\t\t}\n\t\t}\n\t\tfor (const provider of this.registeredNativeProviders.values()) {\n\t\t\tthis.models.setProvider(provider);\n\t\t}\n\t\tthis.updateModelSnapshot();\n\t}\n\n\tprivate updateModelSnapshot(): void {\n\t\tconst all = [...this.models.getModels()];\n\t\tthis.snapshot = {\n\t\t\t...this.snapshot,\n\t\t\tall,\n\t\t\tavailable: all.filter((model) => this.snapshot.configuredProviders.has(model.provider)),\n\t\t};\n\t}\n\n\tprivate async runAvailabilityRefresh(): Promise<void> {\n\t\tconst providers = this.models.getProviders();\n\t\tconst profiles = this.profilesStore.list();\n\t\tconst profileIds = new Set(profiles.map((p) => p.id));\n\n\t\tconst configuredProviders = new Set<string>();\n\t\tconst auth = new Map<string, AuthCheck | undefined>();\n\n\t\t// All loaded profiles are \"configured\" since they include apiKey\n\t\tfor (const profileId of profileIds) {\n\t\t\tconfiguredProviders.add(profileId);\n\t\t\tauth.set(profileId, { type: \"api_key\", source: \"profile\" });\n\t\t}\n\n\t\t// Also check providers that may not have profiles (extension providers)\n\t\tfor (const provider of providers) {\n\t\t\tif (!profileIds.has(provider.id)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst check = await this.models.checkAuth(provider.id);\n\t\t\t\t\tauth.set(provider.id, check);\n\t\t\t\t\tif (check) configuredProviders.add(provider.id);\n\t\t\t\t} catch {\n\t\t\t\t\tauth.set(provider.id, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst [available, credentials] = await Promise.all([this.models.getAvailable(), this.credentials.list()]);\n\n\t\tthis.snapshot = {\n\t\t\tall: [...this.models.getModels()],\n\t\t\tavailable: [...available],\n\t\t\tconfiguredProviders,\n\t\t\tstoredProviders: new Set(credentials.map((entry: { providerId: string }) => entry.providerId)),\n\t\t\tauth,\n\t\t};\n\t\tthis.availabilityError = undefined;\n\t}\n\n\tprivate queueAvailabilityRefresh(after: Promise<void> | undefined): Promise<void> {\n\t\tconst refresh = (after ?? Promise.resolve()).catch(() => {}).then(() => this.runAvailabilityRefresh());\n\t\tconst recorded = refresh.catch((error) => {\n\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\tthrow error;\n\t\t});\n\t\tconst tracked = recorded.finally(() => {\n\t\t\tif (this.availabilityRefresh === tracked) this.availabilityRefresh = undefined;\n\t\t});\n\t\tthis.availabilityRefresh = tracked;\n\t\treturn tracked;\n\t}\n\n\tprivate refreshAvailability(): Promise<void> {\n\t\treturn this.availabilityRefresh ?? this.queueAvailabilityRefresh(undefined);\n\t}\n\n\tprivate forceRefreshAvailability(): Promise<void> {\n\t\treturn this.queueAvailabilityRefresh(this.availabilityRefresh);\n\t}\n\n\t// Profile management\n\n\tgetProfiles(): readonly Profile[] {\n\t\treturn this.profilesStore.list();\n\t}\n\n\tgetProfile(id: string): Profile | undefined {\n\t\treturn this.profilesStore.get(id);\n\t}\n\n\tasync createProfile(profile: Profile): Promise<void> {\n\t\tthis.profilesStore.create(profile);\n\t\tthis.rebuildProviders();\n\t\tawait this.runAvailabilityRefresh();\n\t}\n\n\tasync updateProfile(id: string, fn: (p: Profile) => Profile): Promise<void> {\n\t\tthis.profilesStore.update(id, fn);\n\t\tthis.rebuildProviders();\n\t\tawait this.runAvailabilityRefresh();\n\t}\n\n\tasync deleteProfile(id: string): Promise<void> {\n\t\tthis.profilesStore.delete(id);\n\t\tthis.rebuildProviders();\n\t\tawait this.runAvailabilityRefresh();\n\t}\n\n\tsetActiveProfile(id: string | undefined): void {\n\t\tthis.profilesStore.setActive(id);\n\t}\n\n\tgetActiveProfile(): Profile | undefined {\n\t\treturn this.profilesStore.getActive();\n\t}\n\n\t// Models interface\n\n\tgetProviders(): readonly Provider[] {\n\t\treturn this.models.getProviders();\n\t}\n\n\tgetProvider(providerId: string): Provider | undefined {\n\t\treturn this.models.getProvider(providerId);\n\t}\n\n\tgetModels(providerId?: string): readonly Model<Api>[] {\n\t\treturn this.models.getModels(providerId);\n\t}\n\n\tgetModel(providerId: string, modelId: string): Model<Api> | undefined {\n\t\treturn this.models.getModel(providerId, modelId);\n\t}\n\n\tasync checkAuth(providerId: string): Promise<AuthCheck | undefined> {\n\t\treturn this.models.checkAuth(providerId);\n\t}\n\n\tasync getAvailable(providerId?: string): Promise<readonly Model<Api>[]> {\n\t\tif (providerId) {\n\t\t\tif (this.availabilityRefresh) {\n\t\t\t\tawait this.availabilityRefresh;\n\t\t\t\treturn this.snapshot.available.filter((model) => model.provider === providerId);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn await this.models.getAvailable(providerId);\n\t\t\t} catch (error) {\n\t\t\t\tthis.availabilityError = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tawait this.refreshAvailability();\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetAvailableSnapshot(): readonly Model<Api>[] {\n\t\treturn this.snapshot.available;\n\t}\n\n\tgetError(): string | undefined {\n\t\tif (this.availabilityError) return `Availability refresh: ${this.availabilityError}`;\n\t\treturn undefined;\n\t}\n\n\thasConfiguredAuth(providerId: string): boolean {\n\t\treturn this.snapshot.configuredProviders.has(providerId);\n\t}\n\n\tgetProviderAuthStatus(providerId: string): {\n\t\tconfigured: boolean;\n\t\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\t\tlabel?: string;\n\t} {\n\t\tif (this.snapshot.configuredProviders.has(providerId)) {\n\t\t\treturn { configured: true, source: \"stored\" };\n\t\t}\n\t\treturn { configured: false };\n\t}\n\n\tisUsingOAuth(providerId: string): boolean {\n\t\treturn this.snapshot.auth.get(providerId)?.type === \"oauth\";\n\t}\n\n\tgetAuth(providerId: string, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tgetAuth(model: Model<Api>, overrides?: ModelRuntimeAuthOverrides): Promise<AuthResult | undefined>;\n\tasync getAuth(\n\t\tproviderOrModel: string | Model<Api>,\n\t\toverrides: ModelRuntimeAuthOverrides = {},\n\t): Promise<AuthResult | undefined> {\n\t\tif (typeof providerOrModel === \"string\") return this.models.getAuth(providerOrModel, overrides);\n\t\treturn this.models.getAuth(providerOrModel, overrides);\n\t}\n\n\tlistCredentials(): Promise<readonly CredentialInfo[]> {\n\t\treturn this.credentials.list();\n\t}\n\n\tasync login(providerId: string, type: AuthType, interaction: AuthInteraction): Promise<Credential> {\n\t\treturn this.models.login(providerId, type, interaction);\n\t}\n\n\tasync logout(providerId: string): Promise<void> {\n\t\tawait this.models.logout(providerId);\n\t\tawait this.refresh({ allowNetwork: false });\n\t}\n\n\tasync reloadConfig(): Promise<void> {\n\t\tthis.rebuildProviders();\n\t\tawait this.refresh({ allowNetwork: false });\n\t}\n\n\tasync refresh(options: ModelsRefreshOptions = {}): Promise<ModelsRefreshResult> {\n\t\tconst result = ((await this.models.refresh(options)) as ModelsRefreshResult | undefined) ?? {\n\t\t\taborted: options.signal?.aborted ?? false,\n\t\t\terrors: new Map(),\n\t\t};\n\t\tthis.updateModelSnapshot();\n\t\ttry {\n\t\t\tawait this.forceRefreshAvailability();\n\t\t} catch {\n\t\t\t// Availability errors are recorded; models remain usable.\n\t\t}\n\t\treturn result;\n\t}\n\n\t// Extension support — kept for backward compatibility\n\n\tregisterNativeProvider(provider: Provider): void {\n\t\tthis.registeredNativeProviders.set(provider.id, provider);\n\t\tthis.registeredProviderConfigs.delete(provider.id);\n\t\tthis.models.setProvider(provider);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.runAvailabilityRefresh();\n\t}\n\n\tregisterProvider(providerId: string, config: ProviderConfig): void {\n\t\tconst provider = createExtensionProvider(providerId, config);\n\t\tthis.registeredProviderConfigs.set(providerId, config);\n\t\tthis.registeredNativeProviders.delete(providerId);\n\t\tthis.models.setProvider(provider);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.runAvailabilityRefresh();\n\t}\n\n\tunregisterProvider(providerId: string): void {\n\t\tthis.registeredProviderConfigs.delete(providerId);\n\t\tthis.registeredNativeProviders.delete(providerId);\n\t\tthis.models.deleteProvider(providerId);\n\t\tthis.updateModelSnapshot();\n\t\tvoid this.runAvailabilityRefresh();\n\t}\n\n\tgetRegisteredProviderConfig(providerId: string): ProviderConfig | undefined {\n\t\treturn this.registeredProviderConfigs.get(providerId);\n\t}\n\n\tgetRegisteredProviderIds(): readonly string[] {\n\t\treturn Array.from(new Set([...this.registeredProviderConfigs.keys(), ...this.registeredNativeProviders.keys()]));\n\t}\n\n\tgetRegisteredNativeProvider(providerId: string): Provider | undefined {\n\t\treturn this.registeredNativeProviders.get(providerId);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tgetCompatibilityRequestConfig(_model: Model<Api>): any {\n\t\treturn {};\n\t}\n\n\tasync setRuntimeApiKey(\n\t\tproviderId: string,\n\t\tapiKey: string,\n\t\trefreshOptions: ModelsRefreshOptions = {},\n\t): Promise<void> {\n\t\tthis.credentials.setRuntimeApiKey(providerId, apiKey);\n\t\tawait this.runAvailabilityRefresh();\n\t\tif (refreshOptions.allowNetwork) await this.refresh(refreshOptions);\n\t}\n\n\tasync removeRuntimeApiKey(providerId: string): Promise<void> {\n\t\tthis.credentials.removeRuntimeApiKey(providerId);\n\t\tawait this.runAvailabilityRefresh();\n\t}\n\n\tprivate async prepareRequest(\n\t\tmodel: Model<Api>,\n\t\toptions: (StreamOptions & ModelsStreamTransforms) | undefined,\n\t): Promise<{ provider: Provider; model: Model<Api>; options: StreamOptions }> {\n\t\tconst provider = this.models.getProvider(model.provider);\n\t\tif (!provider) throw new ModelsError(\"provider\", `Unknown provider: ${model.provider}`);\n\t\tconst resolution = await this.getAuth(model, { apiKey: options?.apiKey, env: options?.env });\n\t\tif (!resolution) throw new ModelsError(\"auth\", `Provider is not configured: ${model.provider}`);\n\n\t\tconst { transformHeaders, ...providerOptions } = options ?? {};\n\t\tlet headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);\n\t\tif (transformHeaders) headers = await transformHeaders(headers ?? {});\n\t\tconst env =\n\t\t\tresolution.env || providerOptions.env\n\t\t\t\t? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }\n\t\t\t\t: undefined;\n\t\treturn {\n\t\t\tprovider,\n\t\t\tmodel: resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,\n\t\t\toptions: {\n\t\t\t\t...providerOptions,\n\t\t\t\tapiKey: providerOptions.apiKey ?? resolution.auth.apiKey,\n\t\t\t\theaders,\n\t\t\t\tenv,\n\t\t\t},\n\t\t};\n\t}\n\n\tstream<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(\n\t\t\t\tmodel,\n\t\t\t\toptions as (StreamOptions & ModelsStreamTransforms) | undefined,\n\t\t\t);\n\t\t\treturn prepared.provider.stream(\n\t\t\t\tprepared.model as Model<TApi>,\n\t\t\t\tcontext,\n\t\t\t\tprepared.options as ApiStreamOptions<TApi>,\n\t\t\t);\n\t\t});\n\t}\n\n\tcomplete<TApi extends Api>(\n\t\tmodel: Model<TApi>,\n\t\tcontext: Context,\n\t\toptions?: ModelsApiStreamOptions<TApi>,\n\t): Promise<AssistantMessage> {\n\t\treturn this.stream(model, context, options).result();\n\t}\n\n\tstreamSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): AssistantMessageEventStream {\n\t\treturn lazyStream(model, async () => {\n\t\t\tconst prepared = await this.prepareRequest(model, options);\n\t\t\treturn prepared.provider.streamSimple(prepared.model, context, prepared.options as SimpleStreamOptions);\n\t\t});\n\t}\n\n\tcompleteSimple(model: Model<Api>, context: Context, options?: ModelsSimpleStreamOptions): Promise<AssistantMessage> {\n\t\treturn this.streamSimple(model, context, options).result();\n\t}\n}\n"]}
@@ -0,0 +1,453 @@
1
+ import { createModels, createProvider, lazyStream, ModelsError, } from "@handy_wote/pi-ai";
2
+ import { anthropicMessagesApi } from "@handy_wote/pi-ai/api/anthropic-messages.lazy";
3
+ import { openAICompletionsApi } from "@handy_wote/pi-ai/api/openai-completions.lazy";
4
+ import { openAIResponsesApi } from "@handy_wote/pi-ai/api/openai-responses.lazy";
5
+ import { FileModelsStore, InMemoryCodingAgentModelsStore } from "./models-store.js";
6
+ import { createProfileProvider } from "./profile-runtime.js";
7
+ import { ProfilesStore } from "./profiles-store.js";
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ class RuntimeCredentials {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ async read(_provider) {
12
+ return undefined;
13
+ }
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ async modify(_provider, fn) {
16
+ return fn(undefined);
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ async delete(_provider) { }
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ async list() {
22
+ return [];
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
25
+ setRuntimeApiKey(_providerId, _apiKey) { }
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
27
+ removeRuntimeApiKey(_providerId) { }
28
+ }
29
+ function mergeHeaders(base, override) {
30
+ if (!base && !override)
31
+ return undefined;
32
+ const merged = { ...base };
33
+ for (const [name, value] of Object.entries(override ?? {})) {
34
+ const lowerName = name.toLowerCase();
35
+ for (const existingName of Object.keys(merged)) {
36
+ if (existingName.toLowerCase() === lowerName)
37
+ delete merged[existingName];
38
+ }
39
+ merged[name] = value;
40
+ }
41
+ return merged;
42
+ }
43
+ function resolveConfiguredApiKey(value, env) {
44
+ if (!value)
45
+ return undefined;
46
+ if (value.startsWith("${") && value.endsWith("}"))
47
+ return env[value.slice(2, -1)];
48
+ if (value.startsWith("$"))
49
+ return env[value.slice(1)];
50
+ return value;
51
+ }
52
+ function getBuiltInApi(api) {
53
+ if (api === "anthropic-messages")
54
+ return anthropicMessagesApi();
55
+ if (api === "openai-completions")
56
+ return openAICompletionsApi();
57
+ if (api === "openai-responses")
58
+ return openAIResponsesApi();
59
+ return undefined;
60
+ }
61
+ function providerModelConfigToModel(providerId, config, modelConfig) {
62
+ const api = modelConfig.api ?? config.api;
63
+ if (!api) {
64
+ throw new Error(`Provider ${providerId}: "api" is required when registering models.`);
65
+ }
66
+ const baseUrl = modelConfig.baseUrl ?? config.baseUrl;
67
+ if (!baseUrl) {
68
+ throw new Error(`Provider ${providerId}: "baseUrl" is required when registering models.`);
69
+ }
70
+ return {
71
+ id: modelConfig.id,
72
+ name: modelConfig.name,
73
+ provider: providerId,
74
+ api,
75
+ baseUrl,
76
+ reasoning: modelConfig.reasoning,
77
+ thinkingLevelMap: modelConfig.thinkingLevelMap,
78
+ input: modelConfig.input,
79
+ cost: modelConfig.cost,
80
+ contextWindow: modelConfig.contextWindow,
81
+ maxTokens: modelConfig.maxTokens,
82
+ headers: modelConfig.headers,
83
+ compat: modelConfig.compat,
84
+ };
85
+ }
86
+ function createExtensionProvider(providerId, config) {
87
+ if (config.streamSimple && !config.api) {
88
+ throw new Error(`Provider ${providerId}: "api" is required when registering streamSimple.`);
89
+ }
90
+ const models = (config.models ?? []).map((modelConfig) => providerModelConfigToModel(providerId, config, modelConfig));
91
+ const api = config.streamSimple && config.api
92
+ ? {
93
+ stream: (model, context, options) => config.streamSimple(model, context, options),
94
+ streamSimple: config.streamSimple,
95
+ }
96
+ : Object.fromEntries(Array.from(new Set(models.map((model) => model.api)))
97
+ .map((modelApi) => [modelApi, getBuiltInApi(modelApi)])
98
+ .filter((entry) => entry[1] !== undefined));
99
+ return createProvider({
100
+ id: providerId,
101
+ name: config.name ?? providerId,
102
+ baseUrl: config.baseUrl,
103
+ headers: config.headers,
104
+ auth: {
105
+ apiKey: {
106
+ name: "API Key",
107
+ resolve: async ({ ctx, credential }) => {
108
+ const env = {};
109
+ if (config.apiKey?.startsWith("$")) {
110
+ const envName = config.apiKey.startsWith("${") && config.apiKey.endsWith("}")
111
+ ? config.apiKey.slice(2, -1)
112
+ : config.apiKey.slice(1);
113
+ env[envName] = await ctx.env(envName);
114
+ }
115
+ const apiKey = credential?.type === "api_key" ? credential.key : resolveConfiguredApiKey(config.apiKey, env);
116
+ const headers = { ...(config.headers ?? {}) };
117
+ if (config.authHeader && apiKey)
118
+ headers.Authorization = `Bearer ${apiKey}`;
119
+ return { auth: { apiKey, headers, baseUrl: config.baseUrl } };
120
+ },
121
+ },
122
+ },
123
+ models,
124
+ fetchModels: config.refreshModels
125
+ ? async (context) => (await config.refreshModels(context)).map((modelConfig) => providerModelConfigToModel(providerId, config, modelConfig))
126
+ : undefined,
127
+ api,
128
+ });
129
+ }
130
+ export class ModelRuntime {
131
+ models;
132
+ credentials;
133
+ profilesStore;
134
+ registeredProviderConfigs = new Map();
135
+ registeredNativeProviders = new Map();
136
+ snapshot = {
137
+ all: [],
138
+ available: [],
139
+ configuredProviders: new Set(),
140
+ storedProviders: new Set(),
141
+ auth: new Map(),
142
+ };
143
+ availabilityRefresh;
144
+ availabilityError;
145
+ constructor(credentials, profilesStore, modelsStore) {
146
+ this.credentials = credentials;
147
+ this.profilesStore = profilesStore;
148
+ this.models = createModels({ credentials, modelsStore });
149
+ this.rebuildProviders();
150
+ }
151
+ static async create(options = {}) {
152
+ const credentials = new RuntimeCredentials();
153
+ const profilesStore = new ProfilesStore(options.profilesPath);
154
+ const modelsStore = options.modelsStore ??
155
+ (options.modelsStorePath
156
+ ? new FileModelsStore(options.modelsStorePath)
157
+ : new InMemoryCodingAgentModelsStore());
158
+ const runtime = new ModelRuntime(credentials, profilesStore, modelsStore);
159
+ await runtime.forceRefreshAvailability();
160
+ return runtime;
161
+ }
162
+ rebuildProviders() {
163
+ this.models.clearProviders();
164
+ const profiles = this.profilesStore.list();
165
+ for (const profile of profiles) {
166
+ try {
167
+ const provider = createProfileProvider(profile);
168
+ this.models.setProvider(provider);
169
+ }
170
+ catch {
171
+ // Skip broken profiles; error is available via getError()
172
+ }
173
+ }
174
+ for (const [providerId, config] of this.registeredProviderConfigs) {
175
+ try {
176
+ this.models.setProvider(createExtensionProvider(providerId, config));
177
+ }
178
+ catch {
179
+ // Skip broken extension providers; registration reports errors synchronously.
180
+ }
181
+ }
182
+ for (const provider of this.registeredNativeProviders.values()) {
183
+ this.models.setProvider(provider);
184
+ }
185
+ this.updateModelSnapshot();
186
+ }
187
+ updateModelSnapshot() {
188
+ const all = [...this.models.getModels()];
189
+ this.snapshot = {
190
+ ...this.snapshot,
191
+ all,
192
+ available: all.filter((model) => this.snapshot.configuredProviders.has(model.provider)),
193
+ };
194
+ }
195
+ async runAvailabilityRefresh() {
196
+ const providers = this.models.getProviders();
197
+ const profiles = this.profilesStore.list();
198
+ const profileIds = new Set(profiles.map((p) => p.id));
199
+ const configuredProviders = new Set();
200
+ const auth = new Map();
201
+ // All loaded profiles are "configured" since they include apiKey
202
+ for (const profileId of profileIds) {
203
+ configuredProviders.add(profileId);
204
+ auth.set(profileId, { type: "api_key", source: "profile" });
205
+ }
206
+ // Also check providers that may not have profiles (extension providers)
207
+ for (const provider of providers) {
208
+ if (!profileIds.has(provider.id)) {
209
+ try {
210
+ const check = await this.models.checkAuth(provider.id);
211
+ auth.set(provider.id, check);
212
+ if (check)
213
+ configuredProviders.add(provider.id);
214
+ }
215
+ catch {
216
+ auth.set(provider.id, undefined);
217
+ }
218
+ }
219
+ }
220
+ const [available, credentials] = await Promise.all([this.models.getAvailable(), this.credentials.list()]);
221
+ this.snapshot = {
222
+ all: [...this.models.getModels()],
223
+ available: [...available],
224
+ configuredProviders,
225
+ storedProviders: new Set(credentials.map((entry) => entry.providerId)),
226
+ auth,
227
+ };
228
+ this.availabilityError = undefined;
229
+ }
230
+ queueAvailabilityRefresh(after) {
231
+ const refresh = (after ?? Promise.resolve()).catch(() => { }).then(() => this.runAvailabilityRefresh());
232
+ const recorded = refresh.catch((error) => {
233
+ this.availabilityError = error instanceof Error ? error.message : String(error);
234
+ throw error;
235
+ });
236
+ const tracked = recorded.finally(() => {
237
+ if (this.availabilityRefresh === tracked)
238
+ this.availabilityRefresh = undefined;
239
+ });
240
+ this.availabilityRefresh = tracked;
241
+ return tracked;
242
+ }
243
+ refreshAvailability() {
244
+ return this.availabilityRefresh ?? this.queueAvailabilityRefresh(undefined);
245
+ }
246
+ forceRefreshAvailability() {
247
+ return this.queueAvailabilityRefresh(this.availabilityRefresh);
248
+ }
249
+ // Profile management
250
+ getProfiles() {
251
+ return this.profilesStore.list();
252
+ }
253
+ getProfile(id) {
254
+ return this.profilesStore.get(id);
255
+ }
256
+ async createProfile(profile) {
257
+ this.profilesStore.create(profile);
258
+ this.rebuildProviders();
259
+ await this.runAvailabilityRefresh();
260
+ }
261
+ async updateProfile(id, fn) {
262
+ this.profilesStore.update(id, fn);
263
+ this.rebuildProviders();
264
+ await this.runAvailabilityRefresh();
265
+ }
266
+ async deleteProfile(id) {
267
+ this.profilesStore.delete(id);
268
+ this.rebuildProviders();
269
+ await this.runAvailabilityRefresh();
270
+ }
271
+ setActiveProfile(id) {
272
+ this.profilesStore.setActive(id);
273
+ }
274
+ getActiveProfile() {
275
+ return this.profilesStore.getActive();
276
+ }
277
+ // Models interface
278
+ getProviders() {
279
+ return this.models.getProviders();
280
+ }
281
+ getProvider(providerId) {
282
+ return this.models.getProvider(providerId);
283
+ }
284
+ getModels(providerId) {
285
+ return this.models.getModels(providerId);
286
+ }
287
+ getModel(providerId, modelId) {
288
+ return this.models.getModel(providerId, modelId);
289
+ }
290
+ async checkAuth(providerId) {
291
+ return this.models.checkAuth(providerId);
292
+ }
293
+ async getAvailable(providerId) {
294
+ if (providerId) {
295
+ if (this.availabilityRefresh) {
296
+ await this.availabilityRefresh;
297
+ return this.snapshot.available.filter((model) => model.provider === providerId);
298
+ }
299
+ try {
300
+ return await this.models.getAvailable(providerId);
301
+ }
302
+ catch (error) {
303
+ this.availabilityError = error instanceof Error ? error.message : String(error);
304
+ throw error;
305
+ }
306
+ }
307
+ await this.refreshAvailability();
308
+ return this.snapshot.available;
309
+ }
310
+ getAvailableSnapshot() {
311
+ return this.snapshot.available;
312
+ }
313
+ getError() {
314
+ if (this.availabilityError)
315
+ return `Availability refresh: ${this.availabilityError}`;
316
+ return undefined;
317
+ }
318
+ hasConfiguredAuth(providerId) {
319
+ return this.snapshot.configuredProviders.has(providerId);
320
+ }
321
+ getProviderAuthStatus(providerId) {
322
+ if (this.snapshot.configuredProviders.has(providerId)) {
323
+ return { configured: true, source: "stored" };
324
+ }
325
+ return { configured: false };
326
+ }
327
+ isUsingOAuth(providerId) {
328
+ return this.snapshot.auth.get(providerId)?.type === "oauth";
329
+ }
330
+ async getAuth(providerOrModel, overrides = {}) {
331
+ if (typeof providerOrModel === "string")
332
+ return this.models.getAuth(providerOrModel, overrides);
333
+ return this.models.getAuth(providerOrModel, overrides);
334
+ }
335
+ listCredentials() {
336
+ return this.credentials.list();
337
+ }
338
+ async login(providerId, type, interaction) {
339
+ return this.models.login(providerId, type, interaction);
340
+ }
341
+ async logout(providerId) {
342
+ await this.models.logout(providerId);
343
+ await this.refresh({ allowNetwork: false });
344
+ }
345
+ async reloadConfig() {
346
+ this.rebuildProviders();
347
+ await this.refresh({ allowNetwork: false });
348
+ }
349
+ async refresh(options = {}) {
350
+ const result = (await this.models.refresh(options)) ?? {
351
+ aborted: options.signal?.aborted ?? false,
352
+ errors: new Map(),
353
+ };
354
+ this.updateModelSnapshot();
355
+ try {
356
+ await this.forceRefreshAvailability();
357
+ }
358
+ catch {
359
+ // Availability errors are recorded; models remain usable.
360
+ }
361
+ return result;
362
+ }
363
+ // Extension support — kept for backward compatibility
364
+ registerNativeProvider(provider) {
365
+ this.registeredNativeProviders.set(provider.id, provider);
366
+ this.registeredProviderConfigs.delete(provider.id);
367
+ this.models.setProvider(provider);
368
+ this.updateModelSnapshot();
369
+ void this.runAvailabilityRefresh();
370
+ }
371
+ registerProvider(providerId, config) {
372
+ const provider = createExtensionProvider(providerId, config);
373
+ this.registeredProviderConfigs.set(providerId, config);
374
+ this.registeredNativeProviders.delete(providerId);
375
+ this.models.setProvider(provider);
376
+ this.updateModelSnapshot();
377
+ void this.runAvailabilityRefresh();
378
+ }
379
+ unregisterProvider(providerId) {
380
+ this.registeredProviderConfigs.delete(providerId);
381
+ this.registeredNativeProviders.delete(providerId);
382
+ this.models.deleteProvider(providerId);
383
+ this.updateModelSnapshot();
384
+ void this.runAvailabilityRefresh();
385
+ }
386
+ getRegisteredProviderConfig(providerId) {
387
+ return this.registeredProviderConfigs.get(providerId);
388
+ }
389
+ getRegisteredProviderIds() {
390
+ return Array.from(new Set([...this.registeredProviderConfigs.keys(), ...this.registeredNativeProviders.keys()]));
391
+ }
392
+ getRegisteredNativeProvider(providerId) {
393
+ return this.registeredNativeProviders.get(providerId);
394
+ }
395
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
396
+ getCompatibilityRequestConfig(_model) {
397
+ return {};
398
+ }
399
+ async setRuntimeApiKey(providerId, apiKey, refreshOptions = {}) {
400
+ this.credentials.setRuntimeApiKey(providerId, apiKey);
401
+ await this.runAvailabilityRefresh();
402
+ if (refreshOptions.allowNetwork)
403
+ await this.refresh(refreshOptions);
404
+ }
405
+ async removeRuntimeApiKey(providerId) {
406
+ this.credentials.removeRuntimeApiKey(providerId);
407
+ await this.runAvailabilityRefresh();
408
+ }
409
+ async prepareRequest(model, options) {
410
+ const provider = this.models.getProvider(model.provider);
411
+ if (!provider)
412
+ throw new ModelsError("provider", `Unknown provider: ${model.provider}`);
413
+ const resolution = await this.getAuth(model, { apiKey: options?.apiKey, env: options?.env });
414
+ if (!resolution)
415
+ throw new ModelsError("auth", `Provider is not configured: ${model.provider}`);
416
+ const { transformHeaders, ...providerOptions } = options ?? {};
417
+ let headers = mergeHeaders(resolution.auth.headers, providerOptions.headers);
418
+ if (transformHeaders)
419
+ headers = await transformHeaders(headers ?? {});
420
+ const env = resolution.env || providerOptions.env
421
+ ? { ...(resolution.env ?? {}), ...(providerOptions.env ?? {}) }
422
+ : undefined;
423
+ return {
424
+ provider,
425
+ model: resolution.auth.baseUrl ? { ...model, baseUrl: resolution.auth.baseUrl } : model,
426
+ options: {
427
+ ...providerOptions,
428
+ apiKey: providerOptions.apiKey ?? resolution.auth.apiKey,
429
+ headers,
430
+ env,
431
+ },
432
+ };
433
+ }
434
+ stream(model, context, options) {
435
+ return lazyStream(model, async () => {
436
+ const prepared = await this.prepareRequest(model, options);
437
+ return prepared.provider.stream(prepared.model, context, prepared.options);
438
+ });
439
+ }
440
+ complete(model, context, options) {
441
+ return this.stream(model, context, options).result();
442
+ }
443
+ streamSimple(model, context, options) {
444
+ return lazyStream(model, async () => {
445
+ const prepared = await this.prepareRequest(model, options);
446
+ return prepared.provider.streamSimple(prepared.model, context, prepared.options);
447
+ });
448
+ }
449
+ completeSimple(model, context, options) {
450
+ return this.streamSimple(model, context, options).result();
451
+ }
452
+ }
453
+ //# sourceMappingURL=model-runtime.js.map