@astralyn/pi 0.87.5 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (786) hide show
  1. package/CHANGELOG.md +51 -6
  2. package/README.md +3 -3
  3. package/dist/bun/runtime-setup.js +4 -1
  4. package/dist/bun/runtime-setup.js.map +1 -1
  5. package/dist/bundle/chunks/anthropic-messages-KIXY7EDT.js +6 -0
  6. package/dist/bundle/chunks/anthropic.js +2 -2
  7. package/dist/bundle/chunks/azure-openai-responses-RPBERDXD.js +2 -0
  8. package/dist/bundle/chunks/bedrock-converse-stream.js +8 -8
  9. package/dist/bundle/chunks/{chunk-LPQCB2VJ.js → chunk-A576H74Y.js} +2 -2
  10. package/dist/bundle/chunks/{chunk-NW5FIDD7.js → chunk-ABVRAYXT.js} +3 -3
  11. package/dist/bundle/chunks/{chunk-I5IVW2WS.js → chunk-CLLDCO64.js} +1 -1
  12. package/dist/bundle/chunks/chunk-DEWXBB6W.js +2 -0
  13. package/dist/bundle/chunks/chunk-G4RY3GN7.js +11 -0
  14. package/dist/bundle/chunks/chunk-GCKVOFWP.js +2 -0
  15. package/dist/bundle/chunks/chunk-MPDALHNJ.js +2 -0
  16. package/dist/bundle/chunks/chunk-OO6DJ3CL.js +31 -0
  17. package/dist/bundle/chunks/{chunk-EWLAVDVN.js → chunk-VW2P3X6P.js} +921 -293
  18. package/dist/bundle/chunks/chunk-VWCWZD6E.js +2 -0
  19. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-ZYSAFXXL.js +2 -0
  20. package/dist/bundle/chunks/codemode-worker.js +295 -0
  21. package/dist/bundle/chunks/github-copilot.js +1 -1
  22. package/dist/bundle/chunks/google-generative-ai-SDNQVVXA.js +2 -0
  23. package/dist/bundle/chunks/google-vertex-LZXOLBIO.js +2 -0
  24. package/dist/bundle/chunks/llama-cpp-classify-7IYGGPND.js +22 -0
  25. package/dist/bundle/chunks/meta.js +2 -0
  26. package/dist/bundle/chunks/mistral-conversations-VYKPSSAM.js +5 -0
  27. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  28. package/dist/bundle/chunks/openai-codex-responses-HZ4VUDXD.js +10 -0
  29. package/dist/bundle/chunks/openai-codex.js +2 -2
  30. package/dist/bundle/chunks/openai-completions-SKDGF6OE.js +7 -0
  31. package/dist/bundle/chunks/openai-responses-FPML4SSG.js +3 -0
  32. package/dist/bundle/chunks/{openrouter-images-6XDE2CEW.js → openrouter-images-5524IQHX.js} +1 -1
  33. package/dist/bundle/chunks/openrouter.js +2 -2
  34. package/dist/bundle/chunks/{pi-messages-MQMPIPNC.js → pi-messages-HZZ7GEEW.js} +2 -2
  35. package/dist/bundle/chunks/radius.js +2 -2
  36. package/dist/bundle/chunks/typesafe-system-one-Z2CDLKEY.js +2 -0
  37. package/dist/bundle/chunks/virtual-modules-TQRORWJQ.js +2 -0
  38. package/dist/bundle/cli.js +1 -1
  39. package/dist/bundle/index.js +1 -1
  40. package/dist/bundle/rpc-entry.js +1 -1
  41. package/dist/cli/args.d.ts.map +1 -1
  42. package/dist/cli/args.js +4 -3
  43. package/dist/cli/args.js.map +1 -1
  44. package/dist/cli/startup-ui.d.ts.map +1 -1
  45. package/dist/cli/startup-ui.js +38 -30
  46. package/dist/cli/startup-ui.js.map +1 -1
  47. package/dist/config.d.ts +18 -4
  48. package/dist/config.d.ts.map +1 -1
  49. package/dist/config.js +30 -4
  50. package/dist/config.js.map +1 -1
  51. package/dist/core/agent-session-runtime.d.ts +1 -1
  52. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  53. package/dist/core/agent-session-runtime.js +13 -13
  54. package/dist/core/agent-session-runtime.js.map +1 -1
  55. package/dist/core/agent-session-services.d.ts +2 -2
  56. package/dist/core/agent-session-services.d.ts.map +1 -1
  57. package/dist/core/agent-session-services.js +14 -1
  58. package/dist/core/agent-session-services.js.map +1 -1
  59. package/dist/core/agent-session.d.ts +107 -58
  60. package/dist/core/agent-session.d.ts.map +1 -1
  61. package/dist/core/agent-session.js +505 -298
  62. package/dist/core/agent-session.js.map +1 -1
  63. package/dist/core/bug-report.js +1 -1
  64. package/dist/core/bug-report.js.map +1 -1
  65. package/dist/core/compaction/compaction.d.ts.map +1 -1
  66. package/dist/core/compaction/compaction.js +1 -22
  67. package/dist/core/compaction/compaction.js.map +1 -1
  68. package/dist/core/compaction/utils.d.ts +2 -1
  69. package/dist/core/compaction/utils.d.ts.map +1 -1
  70. package/dist/core/compaction/utils.js +25 -18
  71. package/dist/core/compaction/utils.js.map +1 -1
  72. package/dist/core/context-snapshot.d.ts +17 -4
  73. package/dist/core/context-snapshot.d.ts.map +1 -1
  74. package/dist/core/context-snapshot.js +48 -50
  75. package/dist/core/context-snapshot.js.map +1 -1
  76. package/dist/core/crash-log.d.ts.map +1 -1
  77. package/dist/core/crash-log.js +2 -1
  78. package/dist/core/crash-log.js.map +1 -1
  79. package/dist/core/export-html/template.css +10 -0
  80. package/dist/core/export-html/template.js +66 -17
  81. package/dist/core/extensions/distribution-api.d.ts +1 -8
  82. package/dist/core/extensions/distribution-api.d.ts.map +1 -1
  83. package/dist/core/extensions/distribution-api.js +6 -6
  84. package/dist/core/extensions/distribution-api.js.map +1 -1
  85. package/dist/core/extensions/index.d.ts +3 -3
  86. package/dist/core/extensions/index.d.ts.map +1 -1
  87. package/dist/core/extensions/index.js +1 -1
  88. package/dist/core/extensions/index.js.map +1 -1
  89. package/dist/core/extensions/loader.d.ts +1 -1
  90. package/dist/core/extensions/loader.d.ts.map +1 -1
  91. package/dist/core/extensions/loader.js +58 -7
  92. package/dist/core/extensions/loader.js.map +1 -1
  93. package/dist/core/extensions/runner.d.ts +22 -3
  94. package/dist/core/extensions/runner.d.ts.map +1 -1
  95. package/dist/core/extensions/runner.js +124 -8
  96. package/dist/core/extensions/runner.js.map +1 -1
  97. package/dist/core/extensions/types.d.ts +306 -30
  98. package/dist/core/extensions/types.d.ts.map +1 -1
  99. package/dist/core/extensions/types.js +1 -1
  100. package/dist/core/extensions/types.js.map +1 -1
  101. package/dist/core/extensions/wrapper.d.ts +2 -2
  102. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  103. package/dist/core/extensions/wrapper.js +3 -3
  104. package/dist/core/extensions/wrapper.js.map +1 -1
  105. package/dist/core/keybindings.d.ts +40 -5
  106. package/dist/core/keybindings.d.ts.map +1 -1
  107. package/dist/core/keybindings.js +10 -1
  108. package/dist/core/keybindings.js.map +1 -1
  109. package/dist/core/mcp-servers.d.ts +98 -0
  110. package/dist/core/mcp-servers.d.ts.map +1 -0
  111. package/dist/core/mcp-servers.js +158 -0
  112. package/dist/core/mcp-servers.js.map +1 -0
  113. package/dist/core/model-registry.d.ts +13 -1
  114. package/dist/core/model-registry.d.ts.map +1 -1
  115. package/dist/core/model-registry.js +25 -0
  116. package/dist/core/model-registry.js.map +1 -1
  117. package/dist/core/model-resolver.d.ts +2 -2
  118. package/dist/core/model-resolver.d.ts.map +1 -1
  119. package/dist/core/model-resolver.js +5 -5
  120. package/dist/core/model-resolver.js.map +1 -1
  121. package/dist/core/model-runtime.d.ts +41 -3
  122. package/dist/core/model-runtime.d.ts.map +1 -1
  123. package/dist/core/model-runtime.js +167 -17
  124. package/dist/core/model-runtime.js.map +1 -1
  125. package/dist/core/nested-tool-calls.d.ts +102 -0
  126. package/dist/core/nested-tool-calls.d.ts.map +1 -0
  127. package/dist/core/nested-tool-calls.js +177 -0
  128. package/dist/core/nested-tool-calls.js.map +1 -0
  129. package/dist/core/package-manager.d.ts +4 -0
  130. package/dist/core/package-manager.d.ts.map +1 -1
  131. package/dist/core/package-manager.js +58 -12
  132. package/dist/core/package-manager.js.map +1 -1
  133. package/dist/core/provider-composer.d.ts +40 -21
  134. package/dist/core/provider-composer.d.ts.map +1 -1
  135. package/dist/core/provider-composer.js +92 -40
  136. package/dist/core/provider-composer.js.map +1 -1
  137. package/dist/core/remote-catalog-provider.d.ts +8 -1
  138. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  139. package/dist/core/remote-catalog-provider.js +18 -3
  140. package/dist/core/remote-catalog-provider.js.map +1 -1
  141. package/dist/core/resource-loader.d.ts +7 -1
  142. package/dist/core/resource-loader.d.ts.map +1 -1
  143. package/dist/core/resource-loader.js +160 -35
  144. package/dist/core/resource-loader.js.map +1 -1
  145. package/dist/core/sdk.d.ts +3 -3
  146. package/dist/core/sdk.d.ts.map +1 -1
  147. package/dist/core/sdk.js +84 -14
  148. package/dist/core/sdk.js.map +1 -1
  149. package/dist/core/session-manager.d.ts +9 -0
  150. package/dist/core/session-manager.d.ts.map +1 -1
  151. package/dist/core/session-manager.js +22 -22
  152. package/dist/core/session-manager.js.map +1 -1
  153. package/dist/core/settings-manager.d.ts +36 -1
  154. package/dist/core/settings-manager.d.ts.map +1 -1
  155. package/dist/core/settings-manager.js +108 -2
  156. package/dist/core/settings-manager.js.map +1 -1
  157. package/dist/core/slash-commands.d.ts.map +1 -1
  158. package/dist/core/slash-commands.js +1 -0
  159. package/dist/core/slash-commands.js.map +1 -1
  160. package/dist/core/source-info.d.ts +8 -0
  161. package/dist/core/source-info.d.ts.map +1 -1
  162. package/dist/core/source-info.js +16 -0
  163. package/dist/core/source-info.js.map +1 -1
  164. package/dist/core/system-prompt.js +1 -1
  165. package/dist/core/system-prompt.js.map +1 -1
  166. package/dist/core/tasks/delivery.d.ts +40 -0
  167. package/dist/core/tasks/delivery.d.ts.map +1 -0
  168. package/dist/core/tasks/delivery.js +157 -0
  169. package/dist/core/tasks/delivery.js.map +1 -0
  170. package/dist/core/tasks/history.d.ts +4 -0
  171. package/dist/core/tasks/history.d.ts.map +1 -0
  172. package/dist/core/{background → tasks}/history.js +24 -48
  173. package/dist/core/tasks/history.js.map +1 -0
  174. package/dist/core/{background → tasks}/output.d.ts +4 -4
  175. package/dist/core/tasks/output.d.ts.map +1 -0
  176. package/dist/core/{background → tasks}/output.js +11 -11
  177. package/dist/core/tasks/output.js.map +1 -0
  178. package/dist/core/tasks/presentation.d.ts +9 -0
  179. package/dist/core/tasks/presentation.d.ts.map +1 -0
  180. package/dist/core/{background → tasks}/presentation.js +53 -51
  181. package/dist/core/tasks/presentation.js.map +1 -0
  182. package/dist/core/{background/service.d.ts → tasks/runtime.d.ts} +22 -23
  183. package/dist/core/tasks/runtime.d.ts.map +1 -0
  184. package/dist/core/{background/service.js → tasks/runtime.js} +154 -198
  185. package/dist/core/tasks/runtime.js.map +1 -0
  186. package/dist/core/tasks/session.d.ts +49 -0
  187. package/dist/core/tasks/session.d.ts.map +1 -0
  188. package/dist/core/tasks/session.js +129 -0
  189. package/dist/core/tasks/session.js.map +1 -0
  190. package/dist/core/tasks/store.d.ts +32 -0
  191. package/dist/core/tasks/store.d.ts.map +1 -0
  192. package/dist/core/tasks/store.js +135 -0
  193. package/dist/core/tasks/store.js.map +1 -0
  194. package/dist/core/{background → tasks}/types.d.ts +80 -62
  195. package/dist/core/tasks/types.d.ts.map +1 -0
  196. package/dist/core/{background → tasks}/types.js +9 -9
  197. package/dist/core/tasks/types.js.map +1 -0
  198. package/dist/core/tasks/view-data.d.ts +8 -0
  199. package/dist/core/tasks/view-data.d.ts.map +1 -0
  200. package/dist/core/tasks/view-data.js +61 -0
  201. package/dist/core/tasks/view-data.js.map +1 -0
  202. package/dist/core/tasks/view.d.ts +30 -0
  203. package/dist/core/tasks/view.d.ts.map +1 -0
  204. package/dist/core/tasks/view.js +50 -0
  205. package/dist/core/tasks/view.js.map +1 -0
  206. package/dist/core/tools/bash.d.ts +8 -95
  207. package/dist/core/tools/bash.d.ts.map +1 -1
  208. package/dist/core/tools/bash.js +8 -240
  209. package/dist/core/tools/bash.js.map +1 -1
  210. package/dist/core/tools/find.d.ts.map +1 -1
  211. package/dist/core/tools/find.js +0 -1
  212. package/dist/core/tools/find.js.map +1 -1
  213. package/dist/core/tools/grep.d.ts +2 -0
  214. package/dist/core/tools/grep.d.ts.map +1 -1
  215. package/dist/core/tools/grep.js +2 -1
  216. package/dist/core/tools/grep.js.map +1 -1
  217. package/dist/core/tools/index.d.ts +2 -1
  218. package/dist/core/tools/index.d.ts.map +1 -1
  219. package/dist/core/tools/index.js +9 -0
  220. package/dist/core/tools/index.js.map +1 -1
  221. package/dist/core/tools/ls.d.ts.map +1 -1
  222. package/dist/core/tools/ls.js +0 -1
  223. package/dist/core/tools/ls.js.map +1 -1
  224. package/dist/core/tools/output-accumulator.d.ts +11 -0
  225. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  226. package/dist/core/tools/output-accumulator.js +36 -0
  227. package/dist/core/tools/output-accumulator.js.map +1 -1
  228. package/dist/core/tools/powershell.d.ts +6 -2
  229. package/dist/core/tools/powershell.d.ts.map +1 -1
  230. package/dist/core/tools/powershell.js +1 -1
  231. package/dist/core/tools/powershell.js.map +1 -1
  232. package/dist/core/tools/read.d.ts.map +1 -1
  233. package/dist/core/tools/read.js +0 -1
  234. package/dist/core/tools/read.js.map +1 -1
  235. package/dist/core/tools/render-utils.d.ts +6 -7
  236. package/dist/core/tools/render-utils.d.ts.map +1 -1
  237. package/dist/core/tools/render-utils.js +26 -11
  238. package/dist/core/tools/render-utils.js.map +1 -1
  239. package/dist/core/tools/renderers/bash.d.ts +1 -1
  240. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  241. package/dist/core/tools/renderers/bash.js +65 -12
  242. package/dist/core/tools/renderers/bash.js.map +1 -1
  243. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  244. package/dist/core/tools/renderers/edit.js +4 -22
  245. package/dist/core/tools/renderers/edit.js.map +1 -1
  246. package/dist/core/tools/renderers/find.d.ts.map +1 -1
  247. package/dist/core/tools/renderers/find.js +7 -6
  248. package/dist/core/tools/renderers/find.js.map +1 -1
  249. package/dist/core/tools/renderers/grep.d.ts.map +1 -1
  250. package/dist/core/tools/renderers/grep.js +8 -7
  251. package/dist/core/tools/renderers/grep.js.map +1 -1
  252. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  253. package/dist/core/tools/renderers/index.js +5 -7
  254. package/dist/core/tools/renderers/index.js.map +1 -1
  255. package/dist/core/tools/renderers/ls.d.ts.map +1 -1
  256. package/dist/core/tools/renderers/ls.js +3 -2
  257. package/dist/core/tools/renderers/ls.js.map +1 -1
  258. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  259. package/dist/core/tools/renderers/read.js +10 -14
  260. package/dist/core/tools/renderers/read.js.map +1 -1
  261. package/dist/core/tools/renderers/shell-task.d.ts +4 -0
  262. package/dist/core/tools/renderers/shell-task.d.ts.map +1 -0
  263. package/dist/core/tools/renderers/shell-task.js +35 -0
  264. package/dist/core/tools/renderers/shell-task.js.map +1 -0
  265. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  266. package/dist/core/tools/renderers/write.js +3 -2
  267. package/dist/core/tools/renderers/write.js.map +1 -1
  268. package/dist/core/tools/shell-execution.d.ts +4 -5
  269. package/dist/core/tools/shell-execution.d.ts.map +1 -1
  270. package/dist/core/tools/shell-execution.js +19 -3
  271. package/dist/core/tools/shell-execution.js.map +1 -1
  272. package/dist/core/tools/shell-tool.d.ts +93 -0
  273. package/dist/core/tools/shell-tool.d.ts.map +1 -0
  274. package/dist/core/tools/shell-tool.js +251 -0
  275. package/dist/core/tools/shell-tool.js.map +1 -0
  276. package/dist/core/tools/tasks/actions.d.ts +12 -0
  277. package/dist/core/tools/tasks/actions.d.ts.map +1 -0
  278. package/dist/{extensions/background → core/tools/tasks}/actions.js +20 -19
  279. package/dist/core/tools/tasks/actions.js.map +1 -0
  280. package/dist/core/tools/tasks/constants.d.ts +24 -0
  281. package/dist/core/tools/tasks/constants.d.ts.map +1 -0
  282. package/dist/{extensions/background → core/tools/tasks}/constants.js +11 -9
  283. package/dist/core/tools/tasks/constants.js.map +1 -0
  284. package/dist/{extensions/background → core/tools/tasks}/schema.d.ts +6 -6
  285. package/dist/core/tools/tasks/schema.d.ts.map +1 -0
  286. package/dist/{extensions/background → core/tools/tasks}/schema.js +17 -17
  287. package/dist/core/tools/tasks/schema.js.map +1 -0
  288. package/dist/{extensions/background → core/tools/tasks}/types.d.ts +15 -17
  289. package/dist/core/tools/tasks/types.d.ts.map +1 -0
  290. package/dist/core/tools/tasks/types.js.map +1 -0
  291. package/dist/core/tools/tasks.d.ts +14 -0
  292. package/dist/core/tools/tasks.d.ts.map +1 -0
  293. package/dist/core/tools/tasks.js +40 -0
  294. package/dist/core/tools/tasks.js.map +1 -0
  295. package/dist/core/tools/tool-definition-wrapper.d.ts +5 -8
  296. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  297. package/dist/core/tools/tool-definition-wrapper.js +4 -4
  298. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  299. package/dist/core/tools/truncate.d.ts +14 -0
  300. package/dist/core/tools/truncate.d.ts.map +1 -1
  301. package/dist/core/tools/truncate.js +29 -0
  302. package/dist/core/tools/truncate.js.map +1 -1
  303. package/dist/core/trust-manager.d.ts.map +1 -1
  304. package/dist/core/trust-manager.js +1 -0
  305. package/dist/core/trust-manager.js.map +1 -1
  306. package/dist/core/usage-totals.d.ts +5 -3
  307. package/dist/core/usage-totals.d.ts.map +1 -1
  308. package/dist/core/usage-totals.js +27 -4
  309. package/dist/core/usage-totals.js.map +1 -1
  310. package/dist/core/virtual-models.d.ts +115 -0
  311. package/dist/core/virtual-models.d.ts.map +1 -0
  312. package/dist/core/virtual-models.js +117 -0
  313. package/dist/core/virtual-models.js.map +1 -0
  314. package/dist/extensions/codemode/execute.d.ts +16 -0
  315. package/dist/extensions/codemode/execute.d.ts.map +1 -0
  316. package/dist/extensions/codemode/execute.js +390 -0
  317. package/dist/extensions/codemode/execute.js.map +1 -0
  318. package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
  319. package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
  320. package/dist/extensions/codemode/execute.lazy.js +3 -0
  321. package/dist/extensions/codemode/execute.lazy.js.map +1 -0
  322. package/dist/extensions/codemode/index.d.ts +21 -0
  323. package/dist/extensions/codemode/index.d.ts.map +1 -0
  324. package/dist/extensions/codemode/index.js +36 -0
  325. package/dist/extensions/codemode/index.js.map +1 -0
  326. package/dist/extensions/codemode/renderer.d.ts +12 -0
  327. package/dist/extensions/codemode/renderer.d.ts.map +1 -0
  328. package/dist/extensions/codemode/renderer.js +119 -0
  329. package/dist/extensions/codemode/renderer.js.map +1 -0
  330. package/dist/extensions/codemode/search.d.ts +33 -0
  331. package/dist/extensions/codemode/search.d.ts.map +1 -0
  332. package/dist/extensions/codemode/search.js +117 -0
  333. package/dist/extensions/codemode/search.js.map +1 -0
  334. package/dist/extensions/codemode/tool.d.ts +122 -0
  335. package/dist/extensions/codemode/tool.d.ts.map +1 -0
  336. package/dist/extensions/codemode/tool.js +324 -0
  337. package/dist/extensions/codemode/tool.js.map +1 -0
  338. package/dist/extensions/codemode/worker.d.ts +7 -0
  339. package/dist/extensions/codemode/worker.d.ts.map +1 -0
  340. package/dist/extensions/codemode/worker.js +7 -0
  341. package/dist/extensions/codemode/worker.js.map +1 -0
  342. package/dist/extensions/deepwiki/schema.d.ts +1 -1
  343. package/dist/extensions/index.d.ts.map +1 -1
  344. package/dist/extensions/index.js +14 -12
  345. package/dist/extensions/index.js.map +1 -1
  346. package/dist/extensions/llama/provider.d.ts +1 -1
  347. package/dist/extensions/llama/provider.d.ts.map +1 -1
  348. package/dist/extensions/llama/provider.js +65 -13
  349. package/dist/extensions/llama/provider.js.map +1 -1
  350. package/dist/extensions/mcp/cli.d.ts +21 -0
  351. package/dist/extensions/mcp/cli.d.ts.map +1 -0
  352. package/dist/extensions/mcp/cli.js +485 -0
  353. package/dist/extensions/mcp/cli.js.map +1 -0
  354. package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
  355. package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
  356. package/dist/extensions/mcp/cli.lazy.js +3 -0
  357. package/dist/extensions/mcp/cli.lazy.js.map +1 -0
  358. package/dist/extensions/mcp/config.d.ts +70 -0
  359. package/dist/extensions/mcp/config.d.ts.map +1 -0
  360. package/dist/extensions/mcp/config.js +146 -0
  361. package/dist/extensions/mcp/config.js.map +1 -0
  362. package/dist/extensions/mcp/index.d.ts +52 -0
  363. package/dist/extensions/mcp/index.d.ts.map +1 -0
  364. package/dist/extensions/mcp/index.js +904 -0
  365. package/dist/extensions/mcp/index.js.map +1 -0
  366. package/dist/extensions/mcp/log.d.ts +16 -0
  367. package/dist/extensions/mcp/log.d.ts.map +1 -0
  368. package/dist/extensions/mcp/log.js +64 -0
  369. package/dist/extensions/mcp/log.js.map +1 -0
  370. package/dist/extensions/mcp/oauth.d.ts +94 -0
  371. package/dist/extensions/mcp/oauth.d.ts.map +1 -0
  372. package/dist/extensions/mcp/oauth.js +330 -0
  373. package/dist/extensions/mcp/oauth.js.map +1 -0
  374. package/dist/extensions/mcp/resources.d.ts +43 -0
  375. package/dist/extensions/mcp/resources.d.ts.map +1 -0
  376. package/dist/extensions/mcp/resources.js +262 -0
  377. package/dist/extensions/mcp/resources.js.map +1 -0
  378. package/dist/extensions/mcp/runtime.d.ts +96 -0
  379. package/dist/extensions/mcp/runtime.d.ts.map +1 -0
  380. package/dist/extensions/mcp/runtime.js +372 -0
  381. package/dist/extensions/mcp/runtime.js.map +1 -0
  382. package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
  383. package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
  384. package/dist/extensions/mcp/runtime.lazy.js +3 -0
  385. package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
  386. package/dist/extensions/mcp/tools.d.ts +83 -0
  387. package/dist/extensions/mcp/tools.d.ts.map +1 -0
  388. package/dist/extensions/mcp/tools.js +233 -0
  389. package/dist/extensions/mcp/tools.js.map +1 -0
  390. package/dist/extensions/mcp/ui.d.ts +60 -0
  391. package/dist/extensions/mcp/ui.d.ts.map +1 -0
  392. package/dist/extensions/mcp/ui.js +166 -0
  393. package/dist/extensions/mcp/ui.js.map +1 -0
  394. package/dist/extensions/question/detail-pane.d.ts +12 -0
  395. package/dist/extensions/question/detail-pane.d.ts.map +1 -0
  396. package/dist/extensions/question/detail-pane.js +42 -0
  397. package/dist/extensions/question/detail-pane.js.map +1 -0
  398. package/dist/extensions/question/dialog.d.ts.map +1 -1
  399. package/dist/extensions/question/dialog.js +175 -105
  400. package/dist/extensions/question/dialog.js.map +1 -1
  401. package/dist/extensions/question/option-window.d.ts +26 -0
  402. package/dist/extensions/question/option-window.d.ts.map +1 -0
  403. package/dist/extensions/question/option-window.js +53 -0
  404. package/dist/extensions/question/option-window.js.map +1 -0
  405. package/dist/extensions/question/render-cache.d.ts +4 -4
  406. package/dist/extensions/question/render-cache.d.ts.map +1 -1
  407. package/dist/extensions/question/render-cache.js +10 -11
  408. package/dist/extensions/question/render-cache.js.map +1 -1
  409. package/dist/extensions/statusline/index.js +2 -2
  410. package/dist/extensions/statusline/index.js.map +1 -1
  411. package/dist/extensions/todo/index.d.ts.map +1 -1
  412. package/dist/extensions/todo/index.js +12 -8
  413. package/dist/extensions/todo/index.js.map +1 -1
  414. package/dist/extensions/todo/view.d.ts +3 -3
  415. package/dist/extensions/todo/view.d.ts.map +1 -1
  416. package/dist/extensions/todo/view.js +7 -6
  417. package/dist/extensions/todo/view.js.map +1 -1
  418. package/dist/extensions/tool-search/index.d.ts +12 -0
  419. package/dist/extensions/tool-search/index.d.ts.map +1 -0
  420. package/dist/extensions/tool-search/index.js +20 -0
  421. package/dist/extensions/tool-search/index.js.map +1 -0
  422. package/dist/extensions/tool-search/tool.d.ts +72 -0
  423. package/dist/extensions/tool-search/tool.d.ts.map +1 -0
  424. package/dist/extensions/tool-search/tool.js +208 -0
  425. package/dist/extensions/tool-search/tool.js.map +1 -0
  426. package/dist/index.d.ts +13 -4
  427. package/dist/index.d.ts.map +1 -1
  428. package/dist/index.js +7 -1
  429. package/dist/index.js.map +1 -1
  430. package/dist/main.d.ts.map +1 -1
  431. package/dist/main.js +10 -0
  432. package/dist/main.js.map +1 -1
  433. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  434. package/dist/modes/interactive/components/config-selector.js +13 -3
  435. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  436. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  437. package/dist/modes/interactive/components/custom-message.js +3 -1
  438. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  439. package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
  440. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  441. package/dist/modes/interactive/components/first-time-setup.js +8 -2
  442. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  443. package/dist/modes/interactive/components/footer.d.ts +7 -0
  444. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  445. package/dist/modes/interactive/components/footer.js +42 -3
  446. package/dist/modes/interactive/components/footer.js.map +1 -1
  447. package/dist/modes/interactive/components/index.d.ts +1 -1
  448. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  449. package/dist/modes/interactive/components/index.js +1 -1
  450. package/dist/modes/interactive/components/index.js.map +1 -1
  451. package/dist/modes/interactive/components/pi-logo.d.ts +12 -0
  452. package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -0
  453. package/dist/modes/interactive/components/pi-logo.js +25 -0
  454. package/dist/modes/interactive/components/pi-logo.js.map +1 -0
  455. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  456. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  457. package/dist/modes/interactive/components/settings-selector.js +28 -6
  458. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  459. package/dist/modes/interactive/components/status-marker.d.ts +4 -4
  460. package/dist/modes/interactive/components/status-marker.js +4 -4
  461. package/dist/modes/interactive/components/status-marker.js.map +1 -1
  462. package/dist/modes/interactive/components/themed-text.d.ts +17 -0
  463. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
  464. package/dist/modes/interactive/components/themed-text.js +28 -0
  465. package/dist/modes/interactive/components/themed-text.js.map +1 -0
  466. package/dist/modes/interactive/interactive-mode.d.ts +2 -4
  467. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  468. package/dist/modes/interactive/interactive-mode.js +221 -173
  469. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  470. package/dist/modes/interactive/tasks/completion-render.d.ts +8 -0
  471. package/dist/modes/interactive/tasks/completion-render.d.ts.map +1 -0
  472. package/dist/{extensions/background → modes/interactive/tasks}/completion-render.js +33 -30
  473. package/dist/modes/interactive/tasks/completion-render.js.map +1 -0
  474. package/dist/modes/interactive/tasks/fallback-view.d.ts +4 -0
  475. package/dist/modes/interactive/tasks/fallback-view.d.ts.map +1 -0
  476. package/dist/modes/interactive/tasks/fallback-view.js +27 -0
  477. package/dist/modes/interactive/tasks/fallback-view.js.map +1 -0
  478. package/dist/modes/interactive/tasks/index.d.ts +12 -0
  479. package/dist/modes/interactive/tasks/index.d.ts.map +1 -0
  480. package/dist/modes/interactive/tasks/index.js +97 -0
  481. package/dist/modes/interactive/tasks/index.js.map +1 -0
  482. package/dist/modes/interactive/tasks/manager.d.ts +67 -0
  483. package/dist/modes/interactive/tasks/manager.d.ts.map +1 -0
  484. package/dist/modes/interactive/tasks/manager.js +380 -0
  485. package/dist/modes/interactive/tasks/manager.js.map +1 -0
  486. package/dist/{extensions/background → modes/interactive/tasks}/render.d.ts +13 -13
  487. package/dist/modes/interactive/tasks/render.d.ts.map +1 -0
  488. package/dist/{extensions/background → modes/interactive/tasks}/render.js +18 -18
  489. package/dist/modes/interactive/tasks/render.js.map +1 -0
  490. package/dist/{extensions/background → modes/interactive/tasks}/task-view.d.ts +7 -7
  491. package/dist/modes/interactive/tasks/task-view.d.ts.map +1 -0
  492. package/dist/{extensions/background → modes/interactive/tasks}/task-view.js +4 -4
  493. package/dist/modes/interactive/tasks/task-view.js.map +1 -0
  494. package/dist/{extensions/background → modes/interactive/tasks}/text.d.ts +1 -1
  495. package/dist/modes/interactive/tasks/text.d.ts.map +1 -0
  496. package/dist/{extensions/background → modes/interactive/tasks}/text.js +1 -1
  497. package/dist/modes/interactive/tasks/text.js.map +1 -0
  498. package/dist/modes/interactive/tasks/viewport.d.ts +15 -0
  499. package/dist/modes/interactive/tasks/viewport.d.ts.map +1 -0
  500. package/dist/modes/interactive/tasks/viewport.js +49 -0
  501. package/dist/modes/interactive/tasks/viewport.js.map +1 -0
  502. package/dist/modes/interactive/theme/dark.json +59 -72
  503. package/dist/modes/interactive/theme/light.json +57 -69
  504. package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
  505. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  506. package/dist/modes/interactive/theme/system-theme.js +535 -0
  507. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  508. package/dist/modes/interactive/theme/theme-controller.d.ts +46 -6
  509. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  510. package/dist/modes/interactive/theme/theme-controller.js +125 -47
  511. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  512. package/dist/modes/interactive/theme/theme-json.d.ts +1 -0
  513. package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -1
  514. package/dist/modes/interactive/theme/theme-json.js +3 -1
  515. package/dist/modes/interactive/theme/theme-json.js.map +1 -1
  516. package/dist/modes/interactive/theme/theme-schema.json +7 -2
  517. package/dist/modes/interactive/theme/theme.d.ts +70 -39
  518. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  519. package/dist/modes/interactive/theme/theme.js +247 -314
  520. package/dist/modes/interactive/theme/theme.js.map +1 -1
  521. package/dist/modes/interactive/tool-view/chat.d.ts +20 -0
  522. package/dist/modes/interactive/tool-view/chat.d.ts.map +1 -0
  523. package/dist/modes/interactive/tool-view/chat.js +46 -0
  524. package/dist/modes/interactive/tool-view/chat.js.map +1 -0
  525. package/dist/modes/interactive/tool-view/fallback.d.ts +14 -0
  526. package/dist/modes/interactive/tool-view/fallback.d.ts.map +1 -0
  527. package/dist/modes/interactive/tool-view/fallback.js +55 -0
  528. package/dist/modes/interactive/tool-view/fallback.js.map +1 -0
  529. package/dist/modes/interactive/tool-view/style.d.ts +63 -0
  530. package/dist/modes/interactive/tool-view/style.d.ts.map +1 -0
  531. package/dist/modes/interactive/tool-view/style.js +83 -0
  532. package/dist/modes/interactive/tool-view/style.js.map +1 -0
  533. package/dist/modes/interactive/{components → tool-view}/tool-execution.d.ts +17 -24
  534. package/dist/modes/interactive/tool-view/tool-execution.d.ts.map +1 -0
  535. package/dist/modes/interactive/{components → tool-view}/tool-execution.js +42 -116
  536. package/dist/modes/interactive/tool-view/tool-execution.js.map +1 -0
  537. package/dist/modes/interactive/tui-renderer.d.ts +2 -1
  538. package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
  539. package/dist/modes/interactive/tui-renderer.js +1 -0
  540. package/dist/modes/interactive/tui-renderer.js.map +1 -1
  541. package/dist/modes/rpc/rpc-client.d.ts +6 -6
  542. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  543. package/dist/modes/rpc/rpc-client.js +12 -8
  544. package/dist/modes/rpc/rpc-client.js.map +1 -1
  545. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  546. package/dist/modes/rpc/rpc-mode.js +7 -9
  547. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  548. package/dist/modes/rpc/rpc-types.d.ts +10 -1
  549. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  550. package/dist/modes/rpc/rpc-types.js.map +1 -1
  551. package/dist/package-manager-cli.d.ts.map +1 -1
  552. package/dist/package-manager-cli.js +6 -2
  553. package/dist/package-manager-cli.js.map +1 -1
  554. package/dist/utils/clipboard-image.d.ts.map +1 -1
  555. package/dist/utils/clipboard-image.js +14 -17
  556. package/dist/utils/clipboard-image.js.map +1 -1
  557. package/dist/utils/clipboard.d.ts +2 -0
  558. package/dist/utils/clipboard.d.ts.map +1 -1
  559. package/dist/utils/clipboard.js +5 -0
  560. package/dist/utils/clipboard.js.map +1 -1
  561. package/dist/utils/paths.d.ts +3 -3
  562. package/dist/utils/paths.d.ts.map +1 -1
  563. package/dist/utils/paths.js +5 -4
  564. package/dist/utils/paths.js.map +1 -1
  565. package/dist/utils/shell.d.ts +1 -3
  566. package/dist/utils/shell.d.ts.map +1 -1
  567. package/dist/utils/shell.js +3 -30
  568. package/dist/utils/shell.js.map +1 -1
  569. package/docs/bundled/README.md +22 -8
  570. package/docs/bundled/extensions/question.md +6 -5
  571. package/docs/bundled/extensions/statusline.md +2 -2
  572. package/docs/bundled/tasks.md +141 -0
  573. package/docs/bundled/tool-presentation.md +41 -31
  574. package/docs/custom-provider.md +44 -0
  575. package/docs/docs.json +10 -6
  576. package/docs/extensions.md +90 -90
  577. package/docs/index.md +2 -1
  578. package/docs/keybindings.md +19 -7
  579. package/docs/llama-cpp.md +12 -1
  580. package/docs/mcp.md +188 -0
  581. package/docs/models.md +35 -0
  582. package/docs/packages.md +4 -0
  583. package/docs/providers.md +6 -0
  584. package/docs/rpc.md +5 -3
  585. package/docs/sdk.md +26 -16
  586. package/docs/security.md +4 -0
  587. package/docs/session-format.md +18 -11
  588. package/docs/settings.md +26 -2
  589. package/docs/themes.md +27 -5
  590. package/docs/tui.md +20 -0
  591. package/docs/usage.md +61 -3
  592. package/docs/virtual-models.md +114 -0
  593. package/docs/windows.md +2 -0
  594. package/examples/README.md +1 -1
  595. package/examples/extensions/README.md +2 -0
  596. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  597. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  598. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  599. package/examples/extensions/custom-provider-gitlab-duo/test.ts +4 -4
  600. package/examples/extensions/debug-provider.ts +90 -0
  601. package/examples/extensions/gondolin/package-lock.json +2 -2
  602. package/examples/extensions/gondolin/package.json +1 -1
  603. package/examples/extensions/jev-router.ts +113 -0
  604. package/examples/extensions/sandbox/package-lock.json +2 -2
  605. package/examples/extensions/sandbox/package.json +1 -1
  606. package/examples/extensions/with-deps/package-lock.json +2 -2
  607. package/examples/extensions/with-deps/package.json +1 -1
  608. package/examples/rpc-client.ts +1 -1
  609. package/examples/rpc-extension-ui.ts +1 -1
  610. package/examples/sdk/14-codemode-mcp.ts +61 -0
  611. package/examples/sdk/README.md +1 -0
  612. package/npm-shrinkwrap.json +409 -423
  613. package/package.json +13 -10
  614. package/dist/bundle/chunks/anthropic-messages-XWFTZP2N.js +0 -6
  615. package/dist/bundle/chunks/azure-openai-responses-HS35BQV6.js +0 -2
  616. package/dist/bundle/chunks/chunk-2IO5GDBS.js +0 -11
  617. package/dist/bundle/chunks/chunk-APQ4ACY3.js +0 -2
  618. package/dist/bundle/chunks/chunk-EDBLK2JQ.js +0 -2
  619. package/dist/bundle/chunks/chunk-NUHFSC37.js +0 -25
  620. package/dist/bundle/chunks/google-generative-ai-NOVAJBFC.js +0 -2
  621. package/dist/bundle/chunks/google-vertex-4VHCZJV5.js +0 -2
  622. package/dist/bundle/chunks/mistral-conversations-WC6A2WCJ.js +0 -5
  623. package/dist/bundle/chunks/openai-codex-responses-XCDG75W2.js +0 -10
  624. package/dist/bundle/chunks/openai-completions-SHS3CAEL.js +0 -7
  625. package/dist/bundle/chunks/openai-responses-UT6XFKC7.js +0 -2
  626. package/dist/bundle/chunks/virtual-modules-W3OGMIX7.js +0 -2
  627. package/dist/core/background/history.d.ts +0 -4
  628. package/dist/core/background/history.d.ts.map +0 -1
  629. package/dist/core/background/history.js.map +0 -1
  630. package/dist/core/background/output.d.ts.map +0 -1
  631. package/dist/core/background/output.js.map +0 -1
  632. package/dist/core/background/presentation.d.ts +0 -9
  633. package/dist/core/background/presentation.d.ts.map +0 -1
  634. package/dist/core/background/presentation.js.map +0 -1
  635. package/dist/core/background/service.d.ts.map +0 -1
  636. package/dist/core/background/service.js.map +0 -1
  637. package/dist/core/background/session.d.ts +0 -63
  638. package/dist/core/background/session.d.ts.map +0 -1
  639. package/dist/core/background/session.js +0 -222
  640. package/dist/core/background/session.js.map +0 -1
  641. package/dist/core/background/types.d.ts.map +0 -1
  642. package/dist/core/background/types.js.map +0 -1
  643. package/dist/core/model-stream-options.d.ts +0 -6
  644. package/dist/core/model-stream-options.d.ts.map +0 -1
  645. package/dist/core/model-stream-options.js +0 -20
  646. package/dist/core/model-stream-options.js.map +0 -1
  647. package/dist/extensions/background/actions.d.ts +0 -11
  648. package/dist/extensions/background/actions.d.ts.map +0 -1
  649. package/dist/extensions/background/actions.js.map +0 -1
  650. package/dist/extensions/background/completion-render.d.ts +0 -8
  651. package/dist/extensions/background/completion-render.d.ts.map +0 -1
  652. package/dist/extensions/background/completion-render.js.map +0 -1
  653. package/dist/extensions/background/constants.d.ts +0 -22
  654. package/dist/extensions/background/constants.d.ts.map +0 -1
  655. package/dist/extensions/background/constants.js.map +0 -1
  656. package/dist/extensions/background/index.d.ts +0 -7
  657. package/dist/extensions/background/index.d.ts.map +0 -1
  658. package/dist/extensions/background/index.js +0 -109
  659. package/dist/extensions/background/index.js.map +0 -1
  660. package/dist/extensions/background/keybindings.d.ts +0 -10
  661. package/dist/extensions/background/keybindings.d.ts.map +0 -1
  662. package/dist/extensions/background/keybindings.js +0 -14
  663. package/dist/extensions/background/keybindings.js.map +0 -1
  664. package/dist/extensions/background/manager.d.ts +0 -80
  665. package/dist/extensions/background/manager.d.ts.map +0 -1
  666. package/dist/extensions/background/manager.js +0 -673
  667. package/dist/extensions/background/manager.js.map +0 -1
  668. package/dist/extensions/background/render.d.ts.map +0 -1
  669. package/dist/extensions/background/render.js.map +0 -1
  670. package/dist/extensions/background/schema.d.ts.map +0 -1
  671. package/dist/extensions/background/schema.js.map +0 -1
  672. package/dist/extensions/background/task-view.d.ts.map +0 -1
  673. package/dist/extensions/background/task-view.js.map +0 -1
  674. package/dist/extensions/background/text.d.ts.map +0 -1
  675. package/dist/extensions/background/text.js.map +0 -1
  676. package/dist/extensions/background/types.d.ts.map +0 -1
  677. package/dist/extensions/background/types.js.map +0 -1
  678. package/dist/extensions/subagent/activity.d.ts +0 -34
  679. package/dist/extensions/subagent/activity.d.ts.map +0 -1
  680. package/dist/extensions/subagent/activity.js +0 -192
  681. package/dist/extensions/subagent/activity.js.map +0 -1
  682. package/dist/extensions/subagent/agents-command.d.ts +0 -4
  683. package/dist/extensions/subagent/agents-command.d.ts.map +0 -1
  684. package/dist/extensions/subagent/agents-command.js +0 -230
  685. package/dist/extensions/subagent/agents-command.js.map +0 -1
  686. package/dist/extensions/subagent/agents.d.ts +0 -6
  687. package/dist/extensions/subagent/agents.d.ts.map +0 -1
  688. package/dist/extensions/subagent/agents.js +0 -53
  689. package/dist/extensions/subagent/agents.js.map +0 -1
  690. package/dist/extensions/subagent/budget.d.ts +0 -15
  691. package/dist/extensions/subagent/budget.d.ts.map +0 -1
  692. package/dist/extensions/subagent/budget.js +0 -123
  693. package/dist/extensions/subagent/budget.js.map +0 -1
  694. package/dist/extensions/subagent/cancellation.d.ts +0 -29
  695. package/dist/extensions/subagent/cancellation.d.ts.map +0 -1
  696. package/dist/extensions/subagent/cancellation.js +0 -91
  697. package/dist/extensions/subagent/cancellation.js.map +0 -1
  698. package/dist/extensions/subagent/constants.d.ts +0 -25
  699. package/dist/extensions/subagent/constants.d.ts.map +0 -1
  700. package/dist/extensions/subagent/constants.js +0 -50
  701. package/dist/extensions/subagent/constants.js.map +0 -1
  702. package/dist/extensions/subagent/index.d.ts +0 -3
  703. package/dist/extensions/subagent/index.d.ts.map +0 -1
  704. package/dist/extensions/subagent/index.js +0 -151
  705. package/dist/extensions/subagent/index.js.map +0 -1
  706. package/dist/extensions/subagent/model-selection.d.ts +0 -16
  707. package/dist/extensions/subagent/model-selection.d.ts.map +0 -1
  708. package/dist/extensions/subagent/model-selection.js +0 -51
  709. package/dist/extensions/subagent/model-selection.js.map +0 -1
  710. package/dist/extensions/subagent/render.d.ts +0 -24
  711. package/dist/extensions/subagent/render.d.ts.map +0 -1
  712. package/dist/extensions/subagent/render.js +0 -336
  713. package/dist/extensions/subagent/render.js.map +0 -1
  714. package/dist/extensions/subagent/resolve.d.ts +0 -31
  715. package/dist/extensions/subagent/resolve.d.ts.map +0 -1
  716. package/dist/extensions/subagent/resolve.js +0 -111
  717. package/dist/extensions/subagent/resolve.js.map +0 -1
  718. package/dist/extensions/subagent/runner.d.ts +0 -35
  719. package/dist/extensions/subagent/runner.d.ts.map +0 -1
  720. package/dist/extensions/subagent/runner.js +0 -255
  721. package/dist/extensions/subagent/runner.js.map +0 -1
  722. package/dist/extensions/subagent/schema.d.ts +0 -28
  723. package/dist/extensions/subagent/schema.d.ts.map +0 -1
  724. package/dist/extensions/subagent/schema.js +0 -58
  725. package/dist/extensions/subagent/schema.js.map +0 -1
  726. package/dist/extensions/subagent/sdk-runner.d.ts +0 -33
  727. package/dist/extensions/subagent/sdk-runner.d.ts.map +0 -1
  728. package/dist/extensions/subagent/sdk-runner.js +0 -331
  729. package/dist/extensions/subagent/sdk-runner.js.map +0 -1
  730. package/dist/extensions/subagent/settings.d.ts +0 -8
  731. package/dist/extensions/subagent/settings.d.ts.map +0 -1
  732. package/dist/extensions/subagent/settings.js +0 -206
  733. package/dist/extensions/subagent/settings.js.map +0 -1
  734. package/dist/extensions/subagent/state.d.ts +0 -102
  735. package/dist/extensions/subagent/state.d.ts.map +0 -1
  736. package/dist/extensions/subagent/state.js +0 -383
  737. package/dist/extensions/subagent/state.js.map +0 -1
  738. package/dist/extensions/subagent/text.d.ts +0 -6
  739. package/dist/extensions/subagent/text.d.ts.map +0 -1
  740. package/dist/extensions/subagent/text.js +0 -66
  741. package/dist/extensions/subagent/text.js.map +0 -1
  742. package/dist/extensions/subagent/types.d.ts +0 -91
  743. package/dist/extensions/subagent/types.d.ts.map +0 -1
  744. package/dist/extensions/subagent/types.js +0 -2
  745. package/dist/extensions/subagent/types.js.map +0 -1
  746. package/dist/extensions/subagent/ui/agents-dialog.d.ts +0 -4
  747. package/dist/extensions/subagent/ui/agents-dialog.d.ts.map +0 -1
  748. package/dist/extensions/subagent/ui/agents-dialog.js +0 -84
  749. package/dist/extensions/subagent/ui/agents-dialog.js.map +0 -1
  750. package/dist/extensions/subagent/ui/choice-menu.d.ts +0 -39
  751. package/dist/extensions/subagent/ui/choice-menu.d.ts.map +0 -1
  752. package/dist/extensions/subagent/ui/choice-menu.js +0 -93
  753. package/dist/extensions/subagent/ui/choice-menu.js.map +0 -1
  754. package/dist/extensions/subagent/ui/choices.d.ts +0 -36
  755. package/dist/extensions/subagent/ui/choices.d.ts.map +0 -1
  756. package/dist/extensions/subagent/ui/choices.js +0 -54
  757. package/dist/extensions/subagent/ui/choices.js.map +0 -1
  758. package/dist/extensions/subagent/ui/model-list.d.ts +0 -66
  759. package/dist/extensions/subagent/ui/model-list.d.ts.map +0 -1
  760. package/dist/extensions/subagent/ui/model-list.js +0 -235
  761. package/dist/extensions/subagent/ui/model-list.js.map +0 -1
  762. package/dist/extensions/subagent/ui/model-picker.d.ts +0 -47
  763. package/dist/extensions/subagent/ui/model-picker.d.ts.map +0 -1
  764. package/dist/extensions/subagent/ui/model-picker.js +0 -143
  765. package/dist/extensions/subagent/ui/model-picker.js.map +0 -1
  766. package/dist/extensions/subagent/ui/profile-settings-menu.d.ts +0 -41
  767. package/dist/extensions/subagent/ui/profile-settings-menu.d.ts.map +0 -1
  768. package/dist/extensions/subagent/ui/profile-settings-menu.js +0 -98
  769. package/dist/extensions/subagent/ui/profile-settings-menu.js.map +0 -1
  770. package/dist/modes/interactive/components/tool-chrome.d.ts +0 -28
  771. package/dist/modes/interactive/components/tool-chrome.d.ts.map +0 -1
  772. package/dist/modes/interactive/components/tool-chrome.js +0 -84
  773. package/dist/modes/interactive/components/tool-chrome.js.map +0 -1
  774. package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
  775. package/dist/modes/interactive/components/tool-execution.js.map +0 -1
  776. package/dist/modes/interactive/components/tool-group.d.ts +0 -17
  777. package/dist/modes/interactive/components/tool-group.d.ts.map +0 -1
  778. package/dist/modes/interactive/components/tool-group.js +0 -78
  779. package/dist/modes/interactive/components/tool-group.js.map +0 -1
  780. package/dist/modes/interactive/tool-chat.d.ts +0 -21
  781. package/dist/modes/interactive/tool-chat.d.ts.map +0 -1
  782. package/dist/modes/interactive/tool-chat.js +0 -58
  783. package/dist/modes/interactive/tool-chat.js.map +0 -1
  784. package/docs/bundled/extensions/background.md +0 -132
  785. package/docs/bundled/extensions/subagent.md +0 -148
  786. /package/dist/{extensions/background → core/tools/tasks}/types.js +0 -0
package/docs/rpc.md CHANGED
@@ -70,7 +70,7 @@ If the agent is streaming and no `streamingBehavior` is specified, the command r
70
70
 
71
71
  Response:
72
72
  ```json
73
- {"id": "req-1", "type": "response", "command": "prompt", "success": true}
73
+ {"id": "req-1", "type": "response", "command": "prompt", "success": true, "data": {"disposition": "started"}}
74
74
  ```
75
75
 
76
76
  `success: true` means the prompt was accepted, queued, or handled immediately. `success: false` means the prompt was rejected before acceptance. Failures after acceptance are reported through the normal event and message stream, not as a second `response` for the same request id.
@@ -94,7 +94,7 @@ The `images` field is optional. Each image uses `ImageContent` format (same as `
94
94
 
95
95
  Response:
96
96
  ```json
97
- {"type": "response", "command": "steer", "success": true}
97
+ {"type": "response", "command": "steer", "success": true, "data": {"disposition": "queued"}}
98
98
  ```
99
99
 
100
100
  See [set_steering_mode](#set_steering_mode) for controlling how steering messages are processed.
@@ -116,7 +116,7 @@ The `images` field is optional. Each image uses `ImageContent` format (same as `
116
116
 
117
117
  Response:
118
118
  ```json
119
- {"type": "response", "command": "follow_up", "success": true}
119
+ {"type": "response", "command": "follow_up", "success": true, "data": {"disposition": "queued"}}
120
120
  ```
121
121
 
122
122
  See [set_follow_up_mode](#set_follow_up_mode) for controlling how follow-up messages are processed.
@@ -1651,3 +1651,5 @@ process.on("SIGINT", () => {
1651
1651
  agent.stdin.write(JSON.stringify({ type: "abort" }) + "\n");
1652
1652
  });
1653
1653
  ```
1654
+
1655
+ Successful `prompt` responses include `data.disposition`: `handled`, `queued`, or `started`. `steer` and `follow_up` return `handled` or `queued`. This describes the submitted input, not completion. When an extension handles input, do not wait for a run to settle on its behalf.
package/docs/sdk.md CHANGED
@@ -111,8 +111,8 @@ interface AgentSession {
111
111
  abort(): Promise<void>;
112
112
 
113
113
  // Background host controls (see Background execution below)
114
- pauseBackgroundNotifications(): () => void;
115
- retryBackgroundNotifications(): void;
114
+ pauseTaskNotifications(): () => void;
115
+ retryTaskNotifications(): void;
116
116
  getSessionStats(): SessionStats;
117
117
 
118
118
  // Cleanup (does not await Background draining)
@@ -273,15 +273,15 @@ Both `steer()` and `followUp()` expand file-based prompt templates but error on
273
273
 
274
274
  ### Background execution
275
275
 
276
- Background is a session-owned capability, not a daemon or a flag on `createAgentSession()`. Interactive mode enables it. Ordinary SDK sessions and the built-in print, JSON, and RPC hosts leave it disabled and reject native shell or Subagent calls with `background: true`. Normal foreground tools still work, including standalone `createBashTool()` / `createPowerShellTool()` calls without a session context.
276
+ Background is a session-owned capability, not a daemon or a flag on `createAgentSession()`. Interactive mode enables it. Ordinary SDK sessions and the built-in print, JSON, and RPC hosts leave it disabled and reject native shell or extension calls with `background: true`. Normal foreground tools still work, including standalone `createBashTool()` / `createPowerShellTool()` calls without a session context.
277
277
 
278
- An embedding can opt in with `await session.bindExtensions({ backgroundEnabled: true })`. Bind before prompting; this also binds extensions and emits their session-start lifecycle. When using `AgentSessionRuntime`, rebind the replacement session through the runtime's rebind callback. Setting `mode` or providing a UI alone does not enable Background.
278
+ An embedding can opt in with `await session.bindExtensions({ tasksEnabled: true })`. Bind before prompting; this also binds extensions and emits their session-start lifecycle. When using `AgentSessionRuntime`, rebind the replacement session through the runtime's rebind callback. Setting `mode` or providing a UI alone does not enable Background.
279
279
 
280
280
  The host must choose:
281
281
 
282
- - **Lifetime and cancellation:** a settled main-agent turn is not the end of background work. `session.abort()` cancels foreground-owned work, not detached work. Use `session.background.kill(id)` for a whole execution, or `await session.background.shutdown(graceMs?)` to close admission, cancel all owned work and drain within a bounded grace period (default 2 seconds, maximum 60 seconds). A non-cooperating executor can outlive that grace period.
283
- - **Result-driven turns and cost:** automatic completions join the host's prompt queue, so a running turn receives them as steering and an idle session starts a completion turn. Use the nestable `session.pauseBackgroundNotifications()` to defer delivery; its returned release function is idempotent. Pausing does not stop execution or its costs. Budget worker activity and completion-triggered turns explicitly.
284
- - **Observation and delivery:** `session.background` exposes the [public supervision methods](extensions.md#ctxbackground). `read()` and `wait()` observe; a terminal snapshot alone does not acknowledge model delivery. The bundled `bg wait` result carries `details.backgroundTaskId`, which the host acknowledges only after persisting the tool result. A direct SDK waiter that consumes the result outside model history can explicitly call `session.background.markDelivered(task.id)` after successful consumption. A timeout or cancelled wait does not stop the execution. Failed notification delivery leaves the result available for inspection; after fixing the host failure, call `session.retryBackgroundNotifications()` explicitly. Pi does not retry a failed delivery forever on a timer.
282
+ - **Lifetime and cancellation:** a settled main-agent turn is not the end of background work. `session.abort()` cancels foreground-owned work, not detached work. Use `session.tasks.kill(id)` for a whole execution, or `await session.tasks.shutdown(graceMs?)` to close admission, cancel all owned work and drain within a bounded grace period (default 2 seconds, maximum 60 seconds). A non-cooperating executor can outlive that grace period.
283
+ - **Result-driven turns and cost:** automatic completions join the host's prompt queue, so a running turn receives them as steering and an idle session starts a completion turn. Use the nestable `session.pauseTaskNotifications()` to defer delivery; its returned release function is idempotent. Pausing does not stop execution or its costs. Budget worker activity and completion-triggered turns explicitly.
284
+ - **Observation and delivery:** `session.tasks` exposes the [public supervision methods](extensions.md#ctxtasks). `read()` and `wait()` observe; a terminal snapshot alone does not acknowledge model delivery. The built-in `tasks wait` tool binds a delivery receipt to its tool-call ID; the host confirms it only after persisting the result, even if extensions rewrite its details. A direct SDK waiter that consumes the result outside model history can explicitly call `session.tasks.markDelivered(task.id)` after successful consumption. A timeout or cancelled wait does not stop the execution. Failed notification delivery leaves the result available for inspection; after fixing the host failure, call `session.retryTaskNotifications()` explicitly. Pi does not retry a failed delivery forever on a timer.
285
285
  - **Shutdown:** `await runtime.dispose()` handles background shutdown and extension lifecycle when using the runtime API. For a directly owned session, drain Background, abort the main agent, then dispose; synchronous `session.dispose()` alone is not an awaited drain.
286
286
 
287
287
  A deliberately single-turn embedding can suppress completion-triggered turns and cancel leftover work on exit:
@@ -292,14 +292,14 @@ import { createAgentSession, SessionManager } from "@astralyn/pi";
292
292
  const { session } = await createAgentSession({
293
293
  sessionManager: SessionManager.inMemory(),
294
294
  });
295
- const resumeNotifications = session.pauseBackgroundNotifications();
295
+ const resumeNotifications = session.pauseTaskNotifications();
296
296
  try {
297
- await session.bindExtensions({ backgroundEnabled: true });
297
+ await session.bindExtensions({ tasksEnabled: true });
298
298
  await session.prompt("Inspect the project; delegate independent investigations if useful.");
299
299
  // Snapshot only: some executions may still be running.
300
- console.log(session.background.list());
300
+ console.log(session.tasks.list());
301
301
  } finally {
302
- await Promise.all([session.background.shutdown(), session.abort()]);
302
+ await Promise.all([session.tasks.shutdown(), session.abort()]);
303
303
  session.dispose();
304
304
  resumeNotifications();
305
305
  }
@@ -307,19 +307,19 @@ try {
307
307
 
308
308
  For a longer-lived embedding, keep the host alive, subscribe to snapshots and choose bounded waits or release notification delivery according to your model-turn policy. Do not use a panel or repeated reads as the billing or cleanup mechanism.
309
309
 
310
- Automatic completion messages carry a version-1 `BackgroundCompletionSnapshot` in `details`, with independent shell output or worker reports, diagnostics and explicit truncation flags. This snapshot is self-contained for transcript replay and is not sent to the model; `content` contains the separately bounded prose generated from it. Current terminal history uses version-2 `background-task-result` records, with no migration of earlier result records. The usage ledger remains independent. See [Background records](session-format.md#background-records).
310
+ Automatic completion messages carry a version-1 `TaskCompletionSnapshot` in `details`, with independent shell output or worker reports, diagnostics and explicit truncation flags. This snapshot is self-contained for transcript replay and is not sent to the model; `content` contains the separately bounded prose generated from it. Current terminal history uses version-2 `task-result` records, with no migration of earlier result records. The usage ledger remains independent. See [Background records](session-format.md#background-records).
311
311
 
312
- `executionRole: "subagent"` on `createAgentSession()` is a trusted host-assigned identity, not a model argument. It prevents enabling Background even through `bindExtensions`; built-in workers also receive a no-background prompt rule. Their shared shell schema retains the optional flag but runtime requests for `background: true` are rejected before startup. Foreground shell access remains normal. This capability restriction is not an OS sandbox.
312
+ `backgroundAllowed: false` on `createAgentSession()` is a host capability ceiling, independent of task kind. It prevents enabling background execution through `bindExtensions` or direct runtime activation, including after reload. Requests for `background: true` are rejected before startup; foreground execution remains available. Omitting this option permits host opt-in but does not enable background execution by itself. This capability restriction is not an OS sandbox.
313
313
 
314
- Reload, replacement/fork, shutdown and branch navigation enforce the [Background lifetime rules](bundled/extensions/background.md#lifetime). Saved terminal branch history is observational only: no live processes/workers resume, and restoration does not replay accounting or completion events. Managed logs expire with their runtime records; save anything needed before eviction or shutdown.
314
+ Reload, replacement/fork, shutdown and branch navigation enforce the [Background lifetime rules](bundled/tasks.md#lifetime). Saved terminal branch history is observational only: no live processes/workers resume, and restoration does not replay accounting or completion events. Managed logs expire with their runtime records; save anything needed before eviction or shutdown.
315
315
 
316
- An executor that ignores abort and settles after its originating runtime/branch has been retired is quarantined, not charged to the active session. The old session exposes the latest 32 bounded records through `quarantinedBackgroundSettlements`; persisted sessions also attempt to append them to `<session-file>.background-late.jsonl`, reporting a diagnostic if the write fails. This is an audit trail, not automatic reconciliation or a promise that the executor stopped. See [Background records](session-format.md#background-records).
316
+ An executor that ignores abort and settles after its originating runtime/branch has been retired is quarantined, not charged to the active session. The old session exposes the latest 32 bounded records through `quarantinedTaskSettlements`; persisted sessions also attempt to append them to `<session-file>.tasks-late.jsonl`, reporting a diagnostic if the write fails. This is an audit trail, not automatic reconciliation or a promise that the executor stopped. See [Background records](session-format.md#background-records).
317
317
 
318
318
  ### Session statistics
319
319
 
320
320
  `session.getSessionStats()` returns `sessionFile`, `sessionId`, `userMessages`, `assistantMessages`, `toolCalls`, `toolResults`, `totalMessages`, `tokens`, `cost`, and optional `contextUsage`. `tokens` contains `input`, `output`, `cacheRead`, `cacheWrite`, and `total` (the sum of those four categories); `cost` is accumulated reported cost.
321
321
 
322
- Usage totals cover all session entries, including other branches and compacted history: assistant requests, usage-bearing tool results, compaction/branch summaries, and the first valid `background-usage` record per execution ID. Managed foreground results omit duplicate usage. Background records do not increment message/tool counts, and reads, waits, handoff and history restoration do not add billing. Worker retry, failure, cancellation and compaction usage is included when supplied; missing provider usage is not fabricated. Quarantined late settlements are excluded.
322
+ Usage totals cover all session entries, including other branches and compacted history: assistant requests, usage-bearing tool results, compaction/branch summaries, and the first valid `task-usage` record per execution ID. Managed foreground results omit duplicate usage. Background records do not increment message/tool counts, and reads, waits, handoff and history restoration do not add billing. Worker retry, failure, cancellation and compaction usage is included when supplied; missing provider usage is not fabricated. Quarantined late settlements are excluded.
323
323
 
324
324
  This differs from the bundled Statusline's active-branch totals. Neither accumulated worker usage nor Background billing changes the parent context-occupancy estimate or the latest parent request's cache-hit ratio.
325
325
 
@@ -1261,3 +1261,13 @@ type PromptTemplate
1261
1261
  ```
1262
1262
 
1263
1263
  For extension types, see [extensions.md](extensions.md) for the full API.
1264
+
1265
+ ## Codemode and MCP
1266
+
1267
+ <a id="codemode-mcp"></a>
1268
+
1269
+ The CLI loads `codemode`, `tool_search`, and MCP as built-in extensions. SDK sessions do not; add `createCodemodeExtension()`, `createToolSearchExtension()`, and `createMcpExtension()` to the `extensionFactories` of `DefaultResourceLoader`. `codemode` and `tool_search` are registered inactive: enable them through the `defaultTools` setting (`["+codemode", "+tool_search"]` keeps the other default tools), or let the MCP extension activate them: `codemode` for servers with `codemode` or `codemode-deferred` exposure, `tool_search` for servers with `deferred` exposure. The MCP extension connects its servers on `session_start`, so call `session.bindExtensions()`. See [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts).
1270
+
1271
+ Named inline extensions accept `builtin: true` to load as `builtin:<name>`, with user/project configuration and `noExtensions` support. `replaceable: true` lets another extension replace one when its tool, command, or flag names overlap.
1272
+
1273
+ `steer()` and `followUp()` return `"queued"` when queued or `"handled"` when an extension consumes the input.
package/docs/security.md CHANGED
@@ -57,3 +57,7 @@ If you bind-mount a host workspace read/write, writes from inside the container
57
57
  For issues that also affect upstream Pi, follow the [upstream security policy](https://github.com/earendil-works/pi/blob/main/SECURITY.md). This distribution does not operate a separate security-reporting process.
58
58
 
59
59
  Expected local-agent behavior, lack of a built-in sandbox, prompt injection from untrusted content, and behavior of user-installed extensions or skills are generally outside the security boundary unless the report demonstrates a real privilege-boundary bypass or shows how pi grants access that the local user did not already have.
60
+
61
+ ## MCP configuration
62
+
63
+ Project `.pi/mcp.json` requires project trust before its servers are loaded. Trust permits stdio server commands to run. Global servers are configured in `~/.pi/agent/mcp.json`. See [MCP Servers](mcp.md).
@@ -339,30 +339,30 @@ Managed execution uses ordinary version-3 custom entries; it does not add a new
339
339
 
340
340
  | `customType` | `data` | Purpose |
341
341
  |---|---|---|
342
- | `background-usage` | `{ version: 1, taskId, usage }` | Independent settlement of provider-reported nested usage |
343
- | `background-task-result` | `{ version: 2, task }` | Bounded terminal `BackgroundTask` snapshot with structured presentation |
342
+ | `task-usage` | `{ version: 1, taskId, usage }` | Independent settlement of provider-reported nested usage |
343
+ | `task-result` | `{ version: 2, task }` | Bounded terminal `TaskSnapshot` snapshot with structured presentation |
344
344
 
345
345
  `taskId` is the execution/group ID, not a worker display number. `usage` has the `Usage` shape above. Consumers count only the first valid usage record per ID within the entries they aggregate; malformed records, unsupported versions, blank IDs, and non-finite or negative usage/cost values are ignored. A later valid duplicate is not an adjustment. Do not create these host-owned entries yourself or bill again from a result/read/notification.
346
346
 
347
- A `BackgroundTask` has `id`, `kind` (`bash` or `subagent`; PowerShell shares the shell kind), `title`, `toolCallId`, `anchorId`, `mode`, `status`, and numeric millisecond `startedAt`; optional fields include `endedAt`, `command`, `commandTruncated`, `cwd`, `outputPath`, `projection`, `result`, `resultTruncated`, and `error`. Truncation flags record clipping at the producing/retention boundary. Mode (`foreground` or `background`) is independent of status. Persisted terminal statuses are `completed`, `partial`, `failed`, `cancelled`, or `timeout`; live snapshots can also be `queued`, `running`, or `stopping`.
347
+ A `TaskSnapshot` has `id`, `kind` (executor-owned source label, such as `bash`, `powershell`, or an extension-defined label), `format` (`log` or `report`), `title`, `toolCallId`, `anchorId`, `mode`, `status`, and numeric millisecond `startedAt`; optional fields include `endedAt`, `command`, `commandTruncated`, `cwd`, `outputPath`, `projection`, `result`, `resultTruncated`, and `error`. Truncation flags record clipping at the producing/retention boundary. Mode (`foreground` or `background`) is independent of status. Persisted terminal statuses are `completed`, `partial`, `failed`, `cancelled`, or `timeout`; live snapshots can also be `queued`, `running`, or `stopping`.
348
348
 
349
- `projection` contains optional bounded status `text`, `shell: { name, output: { text, truncated } }`, and worker summaries. Each worker has `id`, `label`, `profile`, `description`, observed `status`, `report: { text, truncated }`, optional `error`, plus live `prompt`, `activity`, and optional `model`/`usage` display strings. The projection has no worker sessions or execution handles. Source truncation is explicit; the reader never recognizes truncation by matching output text.
349
+ `projection` contains optional bounded status `text`, `shell: { name, output: { text, truncated } }`, and report items. Each item has `id`, `label`, `category`, `description`, observed `status`, `report: { text, truncated }`, optional `error`, plus live `input`, `activity`, and optional `context`/`usage` display strings. The projection has no worker sessions or execution handles. Source truncation is explicit; the reader never recognizes truncation by matching output text.
350
350
 
351
- The retained tool result contains bounded text (up to 48 KiB) and bounded serializable private details (up to 120 KiB, otherwise omitted); images are replaced with a text omission marker. Completion cards use the public projection independently of those private details. `outputPath`, if present, points to an ephemeral executor-owned file which may already have been removed on eviction or runtime shutdown. Save important output separately.
351
+ The retained tool result contains bounded text (up to 48 KiB) and no executor-private details; images are replaced with a text omission marker. Completion cards use the public projection independently of those private details. `outputPath`, if present, points to an ephemeral executor-owned file which may already have been removed on eviction or runtime shutdown. Save important output separately.
352
352
 
353
353
  Terminal history is restored only from the selected branch's valid version-2 result records. Version-1 result records are ignored without migration; their independent usage entries still participate in accounting. This is read-only history: no processes or workers are restarted or reattached, and restoration does not replay usage settlement or completion events. Forks can carry historical entries on their copied path, never live execution handles.
354
354
 
355
- These `custom` entries do not enter model context. Automatic delivery creates a `custom_message` with `customType: "background-completion"`, `display: true`, and a self-contained `BackgroundCompletionSnapshot` in `details`. The session formats `content` from the same snapshot, with a total limit of 48 KiB and 2,000 lines. Each worker gets a share before formatting, so an early report cannot erase later workers. Only `content` is sent to the model.
355
+ These `custom` entries do not enter model context. Automatic delivery creates a `custom_message` with `customType: "task-completion"`, `display: true`, and a self-contained `TaskCompletionSnapshot` in `details`. The session formats `content` from the same snapshot, with a total limit of 48 KiB and 2,000 lines. Each worker gets a share before formatting, so an early report cannot erase later workers. Only `content` is sent to the model.
356
356
 
357
357
  Completion details use one format, `version: 1`, bounded to 120 KiB of serialized JSON including escaping:
358
358
 
359
359
  | Part | Fields |
360
360
  |---|---|
361
361
  | Common | `version`, `taskId`, `title`, terminal `status`, numeric millisecond `startedAt` and `endedAt`, optional `error` |
362
- | `kind: "bash"` | `output: { text, truncated }`; optional `shell` name, `command: { text, truncated }`, `cwd`, `outputPath` |
363
- | `kind: "subagent"` | `workers[]` with `id`, `label`, `profile`, `description`, observed `status`, `report: { text, truncated }`, optional `error`; optional plain `output` fallback for executors without a worker projection |
362
+ | `format: "log"` | `output: { text, truncated }`; optional `shell` name, `command: { text, truncated }`, `cwd`, `outputPath` |
363
+ | `format: "report"` | `items[]` with `id`, `label`, `category`, `description`, observed `status`, `report: { text, truncated }`, optional `error`; optional plain `output` fallback for executors without a worker projection |
364
364
 
365
- Shell output is bounded to 40 KiB, each worker report to 4 KiB, and worker count to eight. Field limits include JSON escaping; source flags survive further clipping. Completion worker snapshots omit live prompt/activity/model/usage fields. Missing shell metadata is left unspecified, and worker status is never inferred from the group verdict. The renderer sanitizes terminal control sequences and applies separate display row limits.
365
+ Shell output is bounded to 40 KiB, each worker report to 4 KiB, and worker count to eight. Field limits include JSON escaping; source flags survive further clipping. Completion item snapshots omit live input/activity/context/usage fields. Missing shell metadata is left unspecified, and worker status is never inferred from the group verdict. The renderer sanitizes terminal control sequences and applies separate display row limits.
366
366
 
367
367
  A shell completion's `details` can look like this:
368
368
 
@@ -371,6 +371,7 @@ A shell completion's `details` can look like this:
371
371
  "version": 1,
372
372
  "taskId": "bash-12345678-abcd-4321-abcd-123456789012",
373
373
  "kind": "bash",
374
+ "format": "log",
374
375
  "title": "Build",
375
376
  "status": "completed",
376
377
  "startedAt": 1733234400000,
@@ -385,11 +386,11 @@ A shell completion's `details` can look like this:
385
386
 
386
387
  The message carries everything needed for replay after `/reload`, branch navigation, history eviction or restart; rendering does not open the saved log or query a live task. Unsupported or malformed completion details use bounded plain message text. There is no legacy text parser, dual-format reconstruction or migration.
387
388
 
388
- A completion is acknowledged only after its message is persisted. A terminal `bg wait` result instead includes `details.backgroundTaskId`; only persisting that tool result acknowledges delivery, so aborting during an output read cannot consume a notification. Direct `BackgroundContext.wait()` is observational. Snapshots and repeated reads do not create more usage. Historical extension-owned `background-task` notifications and old `bg create` tool results remain transcript history, not new runnable tasks.
389
+ A completion is acknowledged only after its message is persisted. A terminal `tasks wait` binds a host-owned receipt to the tool-call ID. Only persisting that tool result acknowledges delivery, even if its details were rewritten; aborting during an output read cannot consume a notification. Direct `TasksContext.wait()` is observational. Snapshots and repeated reads do not create more usage. Historical extension-owned `background-task` notifications and old `bg create` tool results remain transcript history, not new runnable tasks.
389
390
 
390
391
  Session-wide statistics aggregate the ledger across all entries; the bundled Statusline uses the active branch. Accrued retries, failures, cancellations and worker compaction count when usage is reported. No usage is invented for a provider that does not expose it, and worker billing does not occupy the parent's context window. See [SDK session statistics](sdk.md#session-statistics).
391
392
 
392
- **Late settlement quarantine:** an executor that ignores cancellation and settles after its runtime or launch branch is retired cannot append to the replacement session or move its active leaf. The originating session retains the latest 32 bounded quarantine records in memory. For persisted sessions it also appends audit JSONL to `<session-file>.background-late.jsonl`, with `{ version: 1, sessionId, generation, task, usage? }`. A sidecar write failure is reported and leaves only the bounded in-memory record. This sidecar is separate from the session tree and active totals; it is not automatically reconciled, replayed or used to resume execution. Preserve it if you need to audit late provider costs, and manage its disk retention separately from the session file.
393
+ **Late settlement quarantine:** an executor that ignores cancellation and settles after its runtime or launch branch is retired cannot append to the replacement session or move its active leaf. The originating session retains the latest 32 bounded quarantine records in memory. For persisted sessions it also appends audit JSONL to `<session-file>.tasks-late.jsonl`, with `{ version: 1, sessionId, generation, task, usage? }`. A sidecar write failure is reported and leaves only the bounded in-memory record. This sidecar is separate from the session tree and active totals; it is not automatically reconciled, replayed or used to resume execution. Preserve it if you need to audit late provider costs, and manage its disk retention separately from the session file.
393
394
 
394
395
  ### CustomMessageEntry
395
396
 
@@ -572,3 +573,9 @@ All of these return the appended entry ID:
572
573
  - `getSessionName(): string | undefined`
573
574
  - `getCwd(): string`, `getSessionDir(): string`, `getSessionId(): string`, and `getSessionFile(): string | undefined`
574
575
  - `usesDefaultSessionDir(): boolean` and `isPersisted(): boolean`
576
+
577
+ ## Virtual selections and nested calls
578
+
579
+ The latest `model_change` records the selected model, including a [virtual model](virtual-models.md). Assistant messages record the physical model that answered and its `thinkingLevel`. Router state is stored in custom entries named `pi.virtual-model-state` with `{ provider, modelId, state }`.
580
+
581
+ Tool results can include bounded `nestedCalls` metadata for calls made through `ctx.executeTool()`. It records arguments and execution status, never nested results; compaction and HTML exports use it.
package/docs/settings.md CHANGED
@@ -77,7 +77,7 @@ Selecting a model or thinking level with Enter changes only the current session.
77
77
 
78
78
  | Setting | Type | Default | Description |
79
79
  |---------|------|---------|-------------|
80
- | `theme` | string | `"dark"` | Theme name (`"dark"`, `"light"`, or custom) |
80
+ | `theme` | string | `"system"` | Theme name (`"system"`, `"dark"`, `"light"`, bundled ice-cream themes, or custom) |
81
81
  | `externalEditor` | string | `$VISUAL`, then `$EDITOR`, then Notepad on Windows or `nano` elsewhere | Command for Ctrl+G external editor; takes precedence over environment variables |
82
82
  | `quietStartup` | boolean | `false` | Hide startup header |
83
83
  | `defaultProjectTrust` | string | `"ask"` | Fallback project trust behavior: `"ask"`, `"always"`, or `"never"`. Global setting only |
@@ -285,7 +285,7 @@ Windows paths in JSON must use forward slashes or escaped backslashes:
285
285
  |---------|------|---------|-------------|
286
286
  | `defaultTools` | string[] | - | Built-in tools enabled initially. When omitted, Pi uses its standard defaults |
287
287
 
288
- `defaultTools` selects the built-in tools enabled at startup. Extension and SDK custom tools remain enabled. Available built-ins are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`:
288
+ `defaultTools` selects tools enabled at startup; plain names replace the selection, while `+name` and `-name` modify it. It can also activate `codemode`, `tool_search`, and other inactive extension tools. Extension and SDK custom tools remain enabled. Available built-ins are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`:
289
289
 
290
290
  ```json
291
291
  {
@@ -427,3 +427,27 @@ Project settings (`.pi/settings.json`) override global settings. Nested objects
427
427
  "compaction": { "enabled": true, "triggerPercent": 70 }
428
428
  }
429
429
  ```
430
+
431
+ ## Codemode and tool selection
432
+
433
+ A list of only `+name` and `-name` entries changes the inherited selection instead of replacing it. For example, this enables `codemode` next to the default tools:
434
+
435
+ ```json
436
+ {
437
+ "defaultTools": ["+codemode"]
438
+ }
439
+ ```
440
+
441
+ This replaces `bash` with `powershell` and enables `grep`: `["-bash", "+powershell", "+grep"]`. Project settings apply on top of user settings: a project list with only `+name` and `-name` entries changes the user's selection, and a project list with a plain name replaces it. In one list, plain names form the selection, and `+name` and `-name` then apply in order.
442
+
443
+ CLI tool options override this setting for one invocation; `--tools` does not accept `+name` or `-name`. See [Command Line](usage.md#tools).
444
+
445
+ | Setting | Default | Meaning |
446
+ |---|---|---|
447
+ | `codemode.mode` | `"on"` | `on` keeps direct tool declarations; `only` hides callable tools from direct model access and lists them in codemode |
448
+ | `codemode.inlineBudget` | `3000` | Estimated tokens for inline tool declarations; scripts discover the rest with `searchTools()` |
449
+ | `fullscreenWheelScrollLines` | `"auto"` | 1–100 lines per wheel event, or automatic acceleration; Alt+wheel moves five times as far |
450
+
451
+ Built-in extensions can be disabled in `pi config` or with `"extensions": ["-builtin:mcp"]`. Project `+builtin:<name>` and `-builtin:<name>` entries override user settings. `--no-extensions` disables built-ins too; `-e builtin:mcp` loads one explicitly.
452
+
453
+ MCP servers live in `~/.pi/agent/mcp.json` or trusted project `.pi/mcp.json`; see [MCP Servers](mcp.md).
package/docs/themes.md CHANGED
@@ -18,7 +18,7 @@ Themes are JSON files that define colors for the TUI.
18
18
 
19
19
  Pi loads themes from:
20
20
 
21
- - Built-in: `dark`, `light`, `ice-cream-dark`, `ice-cream-light`
21
+ - Built-in: `system`, `dark`, `light`, `ice-cream-dark`, `ice-cream-light`
22
22
  - Global: `~/.pi/agent/themes/*.json`
23
23
  - Project: `.pi/themes/*.json` (only after the project is trusted)
24
24
  - Packages: `themes/` directories or `pi.themes` entries in `package.json`
@@ -37,7 +37,7 @@ Select a theme via `/settings` or in `settings.json`:
37
37
  }
38
38
  ```
39
39
 
40
- On first run, pi detects your terminal background and defaults to `dark` or `light`.
40
+ Without a saved theme setting, Pi uses `system`, which follows the terminal palette and appearance.
41
41
 
42
42
  ### Initial Theme
43
43
 
@@ -158,7 +158,8 @@ vim ~/.pi/agent/themes/my-theme.json
158
158
  }
159
159
  ```
160
160
 
161
- - `name` is required, must be unique, and must not contain `/`.
161
+ - `name` is required, must be unique, must not contain `/`, and cannot be `system`.
162
+ - `appearance` is optional: `"dark"` or `"light"`. Pi detects it from the colors when omitted.
162
163
  - `vars` is optional. Define reusable colors here, then reference them in `colors`.
163
164
  - `colors` must define all 51 required tokens. `thinkingMax`, `scrollbarThumb`, and the two search highlight tokens are optional and use the fallbacks listed below.
164
165
 
@@ -276,11 +277,13 @@ The `export` section controls colors for `/export` HTML output. If omitted, colo
276
277
 
277
278
  ## Color Values
278
279
 
279
- Four formats are supported:
280
+ Six formats are supported:
280
281
 
281
282
  | Format | Example | Description |
282
283
  |--------|---------|-------------|
283
- | Hex | `"#ff0000"` | 6-digit hex RGB |
284
+ | Hex | `"#f00"` or `"#ff0000"` | 3- or 6-digit hex RGB |
285
+ | OKLCH | `"oklch(62% 0.1 200)"` | Perceptual lightness, chroma, and hue |
286
+ | OKHSL | `"okhsl(250 60% 55%)"` | Hue, saturation, and lightness within the sRGB gamut |
284
287
  | 256-color | `39` | xterm 256-color palette index (0-255) |
285
288
  | Variable | `"primary"` | Reference to a `vars` entry |
286
289
  | Default | `""` | Terminal's default color |
@@ -318,3 +321,22 @@ echo $COLORTERM # Should output "truecolor" or "24bit"
318
321
  The built-in themes are selected by name: `dark`, `light`, `ice-cream-dark`, and `ice-cream-light`. When inspecting an installed package, their JSON assets are under `node_modules/@astralyn/pi/dist/modes/interactive/theme/` (the global-install equivalent is under Pi's npm package directory).
319
322
 
320
323
  The ice-cream palette and bundled design notes are documented in [Bundled themes](bundled/themes.md).
324
+
325
+ ## Use your terminal's colors
326
+
327
+ The `system` theme is the default. It builds Pi's colors from your terminal's theme, so Pi matches the terminal instead of bringing its own palette:
328
+
329
+ - Pi queries the terminal's default foreground and background colors and its 16 ANSI colors.
330
+ - Each Pi color takes its hue from one ANSI color, for example errors from red and links from blue.
331
+ - Pi sets each color's lightness so that it stands out from the background by a minimum contrast. Body text keeps at least a 4.5:1 WCAG contrast ratio on the background and every panel.
332
+ - When the terminal switches between light and dark, Pi queries the colors again and rebuilds the theme.
333
+
334
+ The theme adapts to what the terminal reports:
335
+
336
+ | Terminal reports | Result |
337
+ |---|---|
338
+ | Background and ANSI colors | Colors from the terminal palette, placed for the actual background. |
339
+ | Background only | Pi's own hues, placed for the actual background. |
340
+ | Nothing | ANSI color indices and the terminal's default colors, which the terminal renders itself. Secondary text is faint, and panels have no background color. |
341
+
342
+ Pi asks the terminal for its colors when it starts. Terminals usually answer within a few milliseconds, and Pi waits at most 100 ms before showing the startup header. If the terminal does not answer in time, Pi uses the ANSI color fallback, and it still applies the colors if they arrive later, for example over a slow SSH connection. `system` is a reserved name: a custom theme with that name is ignored.
package/docs/tui.md CHANGED
@@ -829,3 +829,23 @@ PI_TUI_WRITE_LOG=/tmp/tui-ansi.log pi
829
829
 
830
830
  - **Game loop and disposal:** [examples/extensions/snake.ts](../examples/extensions/snake.ts)
831
831
  - **Custom tool rendering:** [examples/extensions/todo.ts](../examples/extensions/todo.ts)
832
+
833
+ ## Combined theme styles
834
+
835
+ Use `theme.style()` to combine foreground and background colors with text attributes:
836
+
837
+ ```typescript
838
+ return new Text(
839
+ theme.style("Done!", {
840
+ fg: "success",
841
+ bg: "toolSuccessBg",
842
+ bold: true,
843
+ }),
844
+ 0,
845
+ 0,
846
+ );
847
+ ```
848
+
849
+ A style color can be a semantic theme token or a concrete `Color`. Foreground tokens are accepted as `fg` and background tokens as `bg`; to use a token's color in the other position, pass its concrete color, for example `{ fg: theme.colors.userMessageBg }`. Access concrete colors through `theme.colors` and use utilities such as `mixColors()` from `@earendil-works/pi-tui` when color math is needed. Tokens that a theme sets to the terminal default render with the terminal's own color; `theme.colors` reports the color the terminal announced for them, or a guess when it did not. Use `theme.appearance` (`"dark"` or `"light"`) to decide, for example, whether to lighten or darken a color. Pi converts the result to truecolor or 256-color output based on terminal capabilities. Theme tokens are converted once per theme; compute concrete colors outside the render path when possible.
850
+
851
+ The existing `theme.fg()` and `theme.bg()` helpers remain available for applying one semantic color.
package/docs/usage.md CHANGED
@@ -38,6 +38,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
38
38
  |---------|-------------|
39
39
  | `/login`, `/logout` | Manage OAuth or API-key credentials |
40
40
  | [`/llama`](llama-cpp.md) | Download, load, and unload llama.cpp router models |
41
+ | [`/mcp`](mcp.md) | Manage MCP servers, authentication, tools, and resources |
41
42
  | [`/btw [question]`](bundled/extensions/btw.md) | Open a temporary side conversation using the current context |
42
43
  | `/model` | Switch models; Ctrl+S in the picker saves the startup default |
43
44
  | `/thinking` | Switch thinking level; Ctrl+S in the picker saves the startup default |
@@ -219,8 +220,8 @@ Built-in tools: `read`, `bash`, `powershell` (Windows), `edit`, `write`, `grep`,
219
220
 
220
221
  | Option | Description |
221
222
  |--------|-------------|
222
- | `-e`, `--extension <source>` | Load an extension from path, npm, or git; repeatable |
223
- | `--no-extensions` | Disable extension discovery |
223
+ | `-e`, `--extension <source>` | Load an extension from path, npm, git, or `builtin:<name>`; repeatable |
224
+ | `--no-extensions` | Disable discovered, configured, and built-in extensions; explicit `-e` entries still load |
224
225
  | `--skill <path>` | Load a skill; repeatable |
225
226
  | `--no-skills` | Disable skill discovery |
226
227
  | `--prompt-template <path>` | Load a prompt template; repeatable |
@@ -305,6 +306,63 @@ pi --exclude-tools ask_question
305
306
 
306
307
  Pi keeps the core small and pushes workflow-specific behavior into extensions, skills, prompt templates, and packages.
307
308
 
308
- This distribution ships selected workflows as hidden built-in extensions, including sub-agents, to-dos, and background bash tasks. It does not include built-in MCP or permission popups. You can build or install additional workflows as extensions or packages, or use external tools such as containers and tmux.
309
+ Upstream Pi provides the llama.cpp integration, codemode, MCP, and tool search. This distribution adds Tasks, BTW, Todo, other workflow extensions, and its native tool presentation. See the [feature catalog](bundled/README.md) for their origins and usage. You can build or install additional workflows as extensions or packages.
309
310
 
310
311
  For the full rationale, read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/).
312
+
313
+ ## Codemode and tool search
314
+
315
+ Codemode and tool search are built-in extensions from [upstream Pi](https://github.com/earendil-works/pi), included in `@astralyn/pi`. Both tools are inactive by default; enable them explicitly or let the MCP extension activate them when needed.
316
+
317
+ ### Enable codemode
318
+
319
+ To turn on `codemode` for every session, add it to the default tools in `~/.pi/agent/settings.json` or a project's `.pi/settings.json`:
320
+
321
+ ```json
322
+ {
323
+ "defaultTools": ["+codemode"]
324
+ }
325
+ ```
326
+
327
+ This keeps `read`, `bash`, `edit`, and `write` and adds `codemode`. For one invocation, list every tool, since `--tools` replaces the selection:
328
+
329
+ ```sh
330
+ pi --tools read,bash,edit,write,codemode
331
+ ```
332
+
333
+ Codemode is useful without MCP: scripts can run several tool calls in parallel, filter large output before it reaches the model, and call classifier models such as TypeSafe's Jev through `models.classify()` (see [Classifier models](models.md#use-classifier-models)).
334
+
335
+ ### How codemode works
336
+
337
+ Codemode scripts run in a QuickJS sandbox that can only reach the other tools, through `tools.<name>(args)`; `ALL_TOOLS` lists them. Output comes from `text(value)`, `image(dataUrlOrImageContent)`, `console.*`, and a top-level `return value`; `exit()` ends the script early. The result starts with `Script completed` or `Script failed`, the wall time, and the output; a failed script keeps its partial output, followed by `Script error:` and the error.
338
+
339
+ A script may start with an options line such as `// @options: {"max_output_tokens": 2000, "timeout_ms": 60000}`. `max_output_tokens` (default 10000) limits the output: longer output keeps its start and end, and the full text is written to a temp file whose path is included in the result. `timeout_ms` is a hard deadline, unset by default.
340
+
341
+ While `codemode` is active, `codemode.mode` in [settings](settings.md#tools) decides how the other tools are presented. With `on` (default) declared tools keep being declared and their descriptions show how to call them from scripts. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts.
342
+
343
+ The `codemode` description lists the callable tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](settings.md#tools)); every namespace is still listed with its tool count, and the description says whether the list is complete. Scripts find the rest with `await searchTools(query, { limit, namespace })`, which ranks tools with BM25, and `await describeTool(name)`, or by filtering `ALL_TOOLS`.
344
+
345
+ Tools with an output schema resolve to structured values: `bash` to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes, and MCP tools to their `CallToolResult`. Other tools resolve to their text output. The `output` of `bash` is not limited to the 2000 lines or 50KB the model sees: it holds up to 1 MiB, and longer output keeps its first and last 512 KiB around an omission marker, with `truncated` set and the full output in `full_output_path`.
346
+
347
+ `store(key, value)` and `load(key)` keep JSON values across `codemode` calls: each successful script that stores values appends a `codemode-store` custom entry to the session, so resumed sessions keep the values and each branch sees only the values written on its path. Scripts can also use `models`: `getModelsOfType`, `getAvailableOfType`, and `getModelOfType` list the model catalog, and `classify(model, context)` runs a classifier model with the session's credentials, at most four at a time per script.
348
+
349
+ ### Tool search
350
+
351
+ `tool_search` is off by default; enable it with `"defaultTools": ["+tool_search"]` or `--tools`. It uses the same ranking as `searchTools()` over tools that are not declared yet and declares the matches for the next model call. Loaded tools are recorded in the session like other tool changes, so they stay declared on that branch.
352
+
353
+ ## MCP commands
354
+
355
+ These commands work outside a session, so agents can run them through `bash`. See [MCP Servers](mcp.md).
356
+
357
+ | Command | Description |
358
+ |---|---|
359
+ | `pi mcp add <server> [options] -- <command> [args...]` | Add or replace a stdio server in `mcp.json`; `--env KEY=VALUE` (repeatable) and `--cwd <dir>` set its environment and working directory. Arguments after the command are passed to it |
360
+ | `pi mcp add <server> [options] --url <url>` | Add or replace a streamable HTTP server; `--header KEY=VALUE` (repeatable), `--bearer-token-env-var <NAME>` (sends `Authorization: Bearer ${NAME}`), `--oauth-client-id`, `--oauth-client-secret`, and `--oauth-callback-port` configure authentication |
361
+ | `pi mcp remove <server>` | Remove a server from `mcp.json`; stored OAuth credentials are kept |
362
+ | `pi mcp list [--json]` | Connect to every enabled server and print its state, tools, and errors; exit with `1` when a config entry is invalid or an enabled server is not connected |
363
+ | `pi mcp login <server> [--timeout <seconds>]` | Sign in to an OAuth server: open the authorization page and wait for the browser (default 300 seconds); a terminal also accepts the pasted redirect URL |
364
+ | `pi mcp logout <server>` | Delete the stored OAuth credentials of a server |
365
+
366
+ `add` and `remove` change `~/.pi/agent/mcp.json`, or `.pi/mcp.json` in the current directory with `--local` (`-l`). `add` also takes `--exposure <mode>` (see [Exposure](mcp.md#exposure)) and does not connect; run `pi mcp list` to check the server.
367
+
368
+ Project `.pi/mcp.json` files are only read for projects that are already trusted.
@@ -0,0 +1,114 @@
1
+ # Virtual Models
2
+
3
+ A virtual model is a selectable model that picks a physical model for each request. Use one to route by task, cost, or conversation state. For example, a router can send quick questions to a small model and hard problems to a large one, while the user selects a single model.
4
+
5
+ Register virtual models from an [extension](extensions.md). They appear in `/model`, `--model`, scoped models, and settings like any other model. A virtual model can be listed under any provider, including one with physical models, such as `openai-codex/auto`.
6
+
7
+ ## Selection and dispatch
8
+
9
+ A virtual model selects a model and a thinking level. A router maps that pair to a physical pair for each request:
10
+
11
+ ```
12
+ selected (virtual model, virtual level) -> dispatched (physical model, physical level)
13
+ jev/auto:low -> anthropic/claude-sonnet-4-5:high
14
+ ```
15
+
16
+ The virtual thinking level is an input to the router. Its meaning is up to the router; it need not correspond to a reasoning budget.
17
+
18
+ Pi keeps the two pairs apart:
19
+
20
+ | | Selection | Dispatch |
21
+ |---|---|---|
22
+ | Recorded in | `model_change` and `thinking_level_change` entries | Each assistant message: `provider`, `api`, `model`, `thinkingLevel` |
23
+ | Visible as | `ctx.model`, `ctx.thinkingLevel`, `PI_MODEL`, `PI_REASONING_LEVEL`, `/model` | The assistant message of each response |
24
+
25
+ Providers only receive physical models. Assistant messages name the physical model, so replaying a conversation across different physical models works the same as after a manual model switch. Resuming a session restores the virtual selection from its latest `model_change` entry. If the virtual model is no longer registered, Pi falls back to the physical model that answered last.
26
+
27
+ In interactive mode, the footer shows the routed model next to the selection, for example `auto • high → gpt-5.6-luna • medium`. `/session` lists the cost for each physical model.
28
+
29
+ Context usage uses the limits of the physical model that produced the latest response, even if that response came before switching to the virtual model. Without such a response, it uses the limits declared on the virtual model, if any. Compaction checks the same limits, and again the limits of the model each request is routed to. If that model's context window is too small for the conversation, Pi compacts before sending the request; the route stays as the router chose it.
30
+
31
+ ## Register a virtual model
32
+
33
+ ```typescript
34
+ import type { ExtensionAPI } from "@astralyn/pi";
35
+
36
+ export default function (pi: ExtensionAPI) {
37
+ pi.registerVirtualModel({
38
+ provider: "router",
39
+ id: "auto",
40
+ name: "Auto",
41
+ thinkingLevels: ["low", "high"],
42
+ route(request, ctx) {
43
+ // Tool follow-ups and retries stay on the model that handled the turn.
44
+ const sticky = request.failed ?? request.previous;
45
+ if (request.reason !== "user" && sticky) {
46
+ return { model: sticky.model, thinkingLevel: sticky.thinkingLevel ?? "medium" };
47
+ }
48
+ const id = request.thinkingLevel === "high" ? "claude-sonnet-4-5" : "claude-haiku-4-5";
49
+ return { model: ctx.modelRegistry.find("anthropic", id)!, thinkingLevel: "medium" };
50
+ },
51
+ });
52
+ }
53
+ ```
54
+
55
+ - `provider` is the provider the model is listed under. It can be any provider ID. A provider can list several virtual models next to its physical ones. On a physical provider, the virtual model is available when that provider has credentials. Under an ID that no provider uses, it is always available.
56
+ - `id` must not be the ID of a physical model of that provider. If a catalog refresh later adds a physical model with the same ID, the virtual model hides it.
57
+ - `thinkingLevels` lists the levels offered for selection. It defaults to `["off"]`.
58
+ - `contextWindow` and `maxTokens` are shown before the first response. Unset limits are unknown.
59
+ - `input` lists the input types offered for selection. It defaults to text and images; physical models without image support receive placeholders.
60
+
61
+ Registration follows the same queuing and reload rules as `pi.registerProvider()`. Registering the same provider and ID again replaces the virtual model. `pi.unregisterVirtualModel(provider, id)` removes it; `pi.unregisterProvider()` does not. SDK code can register one without an extension: `modelRuntime.registerVirtualModel(definition)`.
62
+
63
+ ## Route requests
64
+
65
+ `route(request, ctx)` runs before every request made with the virtual model and returns `{ model, thinkingLevel }`. The model can be any physical model in the catalog whose provider has credentials; look it up with `ctx.modelRegistry`. A virtual model cannot route to another virtual model. Pi clamps the thinking level to the returned model.
66
+
67
+ | Field | Meaning |
68
+ |---|---|
69
+ | `model`, `thinkingLevel` | The selected virtual model and level |
70
+ | `reason` | Why the request is made, see below |
71
+ | `previous` | Physical model and thinking level of the latest successful response in `messages` |
72
+ | `failed` | For `retry`: physical model, thinking level, and assistant `message` of the failed request, which `messages` no longer contains. The message carries `stopReason` and `errorMessage`. Absent when routing itself failed |
73
+ | `state` | Router state last returned on this session branch, see below |
74
+ | `messages` | The conversation for this request, including system messages |
75
+ | `signal` | Abort signal of the request |
76
+
77
+ | `reason` | Request |
78
+ |---|---|
79
+ | `user` | First request after a message the user wrote, including steering and follow-up messages |
80
+ | `continuation` | Any other request in the agent loop, such as after tool results or extension messages |
81
+ | `retry` | Automatic retry after a failed request, including after compaction for a context overflow |
82
+ | `direct` | Request made outside the agent loop, such as a compaction summary or an extension calling `ctx.modelRegistry.streamSimple()` |
83
+
84
+ Returning `previous` for `continuation` and `failed` for `retry` keeps prompt caches and thinking signatures valid. Switching models between turns is allowed but loses the prompt cache. A retry can also switch to another model, for example when `failed.message.errorMessage` reports that a provider is overloaded or the context overflowed.
85
+
86
+ If `route()` throws, or returns a virtual model or a model without credentials, the request ends with an error response.
87
+
88
+ ## Keep routing state
89
+
90
+ `route()` can return `state` next to the model. Pi stores it on the session branch and passes it back as `request.state` on later requests. Use it for decisions the transcript does not record, such as classifier results or a routing phase:
91
+
92
+ ```typescript
93
+ pi.registerVirtualModel<{ phase: "plan" | "build" }>({
94
+ provider: "router",
95
+ id: "phased",
96
+ name: "Phased",
97
+ route(request, ctx) {
98
+ const state = request.state ?? { phase: "plan" };
99
+ const id = state.phase === "plan" ? "claude-opus-4-5" : "claude-haiku-4-5";
100
+ return { model: ctx.modelRegistry.find("anthropic", id)!, thinkingLevel: "medium", state };
101
+ },
102
+ });
103
+ ```
104
+
105
+ - State must be JSON-serializable. Returning `undefined` or `request.state` itself keeps the current state.
106
+ - Pi stores any other returned object as new state, before the request is sent, even when it equals the current state. Return a new object only when the state changes. The state stays stored if the request later fails.
107
+ - State follows the session tree, so forks and `/tree` navigation see the state of their branch. It survives compaction.
108
+ - `direct` requests have no state, and Pi ignores state they return.
109
+
110
+ The transcript already records the selection and every dispatched model, and `ctx.sessionManager.getBranch()` exposes both.
111
+
112
+ Routers can call other models through `ctx.modelRegistry`, for example `ctx.modelRegistry.classify()` with a classifier model from `ctx.modelRegistry.findOfType("classifier", provider, id)`. The call adds latency before the first token of the turn.
113
+
114
+ See [`jev-router.ts`](../examples/extensions/jev-router.ts) for a complete router. It plans on a strong OpenAI Codex model chosen by the Jev classifier, lets that model make the first edit, and then switches once to a cheaper model, accepting a single prompt-cache miss. It keeps the phase as router state.
package/docs/windows.md CHANGED
@@ -37,3 +37,5 @@ The `!` and `!!` editor commands still use Bash.
37
37
  "shellPath": "C:\\cygwin64\\bin\\bash.exe"
38
38
  }
39
39
  ```
40
+
41
+ `"defaultTools": ["-bash", "+powershell"]` replaces Bash while preserving other configured default tools.
@@ -10,7 +10,7 @@ Runs one prompt through a Pi RPC child process with the typed `RpcClient`: it st
10
10
  Build the package before running it from a repository checkout:
11
11
 
12
12
  ```bash
13
- npx tsx examples/rpc-client.ts "Explain this repository"
13
+ node examples/rpc-client.ts "Explain this repository"
14
14
  ```
15
15
 
16
16
  ### [rpc-extension-ui.ts](rpc-extension-ui.ts)
@@ -113,6 +113,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
113
113
  |-----------|-------------|
114
114
  | `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
115
115
  | `entry-renderer.ts` | TUI-only session entry rendering via `appendEntry` and `registerEntryRenderer` |
116
+ | `debug-provider.ts` | Toggle raw provider stream capture with `/debug-provider` and inspect each assistant message in a TUI-only session entry |
116
117
  | `event-bus.ts` | Inter-extension communication via `pi.events` |
117
118
 
118
119
  ### Session Metadata
@@ -128,6 +129,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
128
129
  |-----------|-------------|
129
130
  | `custom-provider-anthropic/` | Custom Anthropic provider with OAuth support and custom streaming implementation |
130
131
  | `custom-provider-gitlab-duo/` | GitLab Duo provider using pi-ai's built-in Anthropic/OpenAI streaming via proxy |
132
+ | `jev-router.ts` | Virtual model via `registerVirtualModel` that plans on Codex Sol or Terra (picked by the Jev classifier) and switches to Luna after the first edit |
131
133
 
132
134
  ### External Dependencies
133
135