@astralyn/pi 0.87.6 → 1.0.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 (924) hide show
  1. package/CHANGELOG.md +69 -9
  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-CG2BSDQS.js +6 -0
  6. package/dist/bundle/chunks/anthropic.js +2 -2
  7. package/dist/bundle/chunks/azure-openai-responses-PBA4QKCM.js +2 -0
  8. package/dist/bundle/chunks/bedrock-converse-stream.js +8 -8
  9. package/dist/bundle/chunks/{chunk-NW5FIDD7.js → chunk-6UFFVA7M.js} +3 -3
  10. package/dist/bundle/chunks/chunk-G4RY3GN7.js +11 -0
  11. package/dist/bundle/chunks/chunk-GCKVOFWP.js +2 -0
  12. package/dist/bundle/chunks/chunk-GIG5IHES.js +2 -0
  13. package/dist/bundle/chunks/{chunk-4W4Q2H6W.js → chunk-HESRDUKO.js} +1000 -625
  14. package/dist/bundle/chunks/chunk-MPDALHNJ.js +2 -0
  15. package/dist/bundle/chunks/chunk-OO6DJ3CL.js +31 -0
  16. package/dist/bundle/chunks/{chunk-LPQCB2VJ.js → chunk-PFZKRUMO.js} +2 -2
  17. package/dist/bundle/chunks/chunk-SGLYRVQL.js +2 -0
  18. package/dist/bundle/chunks/chunk-TRHTWM3C.js +2 -0
  19. package/dist/bundle/chunks/chunk-V66VGGOM.js +2 -0
  20. package/dist/bundle/chunks/chunk-Z2RKSI3O.js +2 -0
  21. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-YB7XPPP4.js +2 -0
  22. package/dist/bundle/chunks/codemode-worker.js +354 -0
  23. package/dist/bundle/chunks/github-copilot.js +1 -1
  24. package/dist/bundle/chunks/google-generative-ai-V5ZM5MCL.js +2 -0
  25. package/dist/bundle/chunks/google-vertex-22THOFP5.js +2 -0
  26. package/dist/bundle/chunks/llama-cpp-classify-R7DQLTQN.js +22 -0
  27. package/dist/bundle/chunks/meta.js +2 -0
  28. package/dist/bundle/chunks/mistral-conversations-WHSCJJWP.js +5 -0
  29. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  30. package/dist/bundle/chunks/openai-codex-responses-N7GDPBPP.js +10 -0
  31. package/dist/bundle/chunks/openai-codex.js +2 -2
  32. package/dist/bundle/chunks/openai-completions-RGGQK5UW.js +7 -0
  33. package/dist/bundle/chunks/openai-responses-3ZLD5JYI.js +3 -0
  34. package/dist/bundle/chunks/{openrouter-images-6XDE2CEW.js → openrouter-images-YP3YVB54.js} +1 -1
  35. package/dist/bundle/chunks/openrouter.js +2 -2
  36. package/dist/bundle/chunks/{pi-messages-MQMPIPNC.js → pi-messages-HZZ7GEEW.js} +2 -2
  37. package/dist/bundle/chunks/radius.js +2 -2
  38. package/dist/bundle/chunks/typesafe-system-one-RREJAKWB.js +2 -0
  39. package/dist/bundle/chunks/virtual-modules-4RQ2L6W4.js +2 -0
  40. package/dist/bundle/cli.js +1 -1
  41. package/dist/bundle/index.js +1 -1
  42. package/dist/bundle/rpc-entry.js +1 -1
  43. package/dist/cli/args.d.ts.map +1 -1
  44. package/dist/cli/args.js +5 -4
  45. package/dist/cli/args.js.map +1 -1
  46. package/dist/cli/startup-ui.d.ts.map +1 -1
  47. package/dist/cli/startup-ui.js +38 -30
  48. package/dist/cli/startup-ui.js.map +1 -1
  49. package/dist/config.d.ts +15 -4
  50. package/dist/config.d.ts.map +1 -1
  51. package/dist/config.js +33 -4
  52. package/dist/config.js.map +1 -1
  53. package/dist/core/agent-session-runtime.d.ts +1 -1
  54. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  55. package/dist/core/agent-session-runtime.js +13 -13
  56. package/dist/core/agent-session-runtime.js.map +1 -1
  57. package/dist/core/agent-session-services.d.ts +2 -2
  58. package/dist/core/agent-session-services.d.ts.map +1 -1
  59. package/dist/core/agent-session-services.js +14 -1
  60. package/dist/core/agent-session-services.js.map +1 -1
  61. package/dist/core/agent-session.d.ts +121 -36
  62. package/dist/core/agent-session.d.ts.map +1 -1
  63. package/dist/core/agent-session.js +518 -203
  64. package/dist/core/agent-session.js.map +1 -1
  65. package/dist/core/bug-report.js +1 -1
  66. package/dist/core/bug-report.js.map +1 -1
  67. package/dist/core/compaction/compaction.d.ts.map +1 -1
  68. package/dist/core/compaction/compaction.js +1 -22
  69. package/dist/core/compaction/compaction.js.map +1 -1
  70. package/dist/core/compaction/utils.d.ts +2 -1
  71. package/dist/core/compaction/utils.d.ts.map +1 -1
  72. package/dist/core/compaction/utils.js +25 -18
  73. package/dist/core/compaction/utils.js.map +1 -1
  74. package/dist/core/crash-log.d.ts.map +1 -1
  75. package/dist/core/crash-log.js +2 -1
  76. package/dist/core/crash-log.js.map +1 -1
  77. package/dist/core/export-html/template.css +10 -0
  78. package/dist/core/export-html/template.js +66 -17
  79. package/dist/core/extensions/distribution-api.d.ts +1 -1
  80. package/dist/core/extensions/distribution-api.d.ts.map +1 -1
  81. package/dist/core/extensions/distribution-api.js.map +1 -1
  82. package/dist/core/extensions/index.d.ts +2 -2
  83. package/dist/core/extensions/index.d.ts.map +1 -1
  84. package/dist/core/extensions/index.js.map +1 -1
  85. package/dist/core/extensions/loader.d.ts.map +1 -1
  86. package/dist/core/extensions/loader.js +67 -5
  87. package/dist/core/extensions/loader.js.map +1 -1
  88. package/dist/core/extensions/runner.d.ts +22 -3
  89. package/dist/core/extensions/runner.d.ts.map +1 -1
  90. package/dist/core/extensions/runner.js +124 -8
  91. package/dist/core/extensions/runner.js.map +1 -1
  92. package/dist/core/extensions/types.d.ts +310 -25
  93. package/dist/core/extensions/types.d.ts.map +1 -1
  94. package/dist/core/extensions/types.js.map +1 -1
  95. package/dist/core/extensions/wrapper.d.ts +2 -2
  96. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  97. package/dist/core/extensions/wrapper.js +3 -3
  98. package/dist/core/extensions/wrapper.js.map +1 -1
  99. package/dist/core/keybindings.d.ts +70 -5
  100. package/dist/core/keybindings.d.ts.map +1 -1
  101. package/dist/core/keybindings.js +15 -1
  102. package/dist/core/keybindings.js.map +1 -1
  103. package/dist/core/mcp-servers.d.ts +125 -0
  104. package/dist/core/mcp-servers.d.ts.map +1 -0
  105. package/dist/core/mcp-servers.js +199 -0
  106. package/dist/core/mcp-servers.js.map +1 -0
  107. package/dist/core/model-registry.d.ts +15 -1
  108. package/dist/core/model-registry.d.ts.map +1 -1
  109. package/dist/core/model-registry.js +29 -0
  110. package/dist/core/model-registry.js.map +1 -1
  111. package/dist/core/model-resolver.d.ts +2 -2
  112. package/dist/core/model-resolver.d.ts.map +1 -1
  113. package/dist/core/model-resolver.js +5 -5
  114. package/dist/core/model-resolver.js.map +1 -1
  115. package/dist/core/model-runtime.d.ts +47 -3
  116. package/dist/core/model-runtime.d.ts.map +1 -1
  117. package/dist/core/model-runtime.js +189 -35
  118. package/dist/core/model-runtime.js.map +1 -1
  119. package/dist/core/nested-tool-calls.d.ts +102 -0
  120. package/dist/core/nested-tool-calls.d.ts.map +1 -0
  121. package/dist/core/nested-tool-calls.js +177 -0
  122. package/dist/core/nested-tool-calls.js.map +1 -0
  123. package/dist/core/package-manager.d.ts +4 -0
  124. package/dist/core/package-manager.d.ts.map +1 -1
  125. package/dist/core/package-manager.js +58 -12
  126. package/dist/core/package-manager.js.map +1 -1
  127. package/dist/core/provider-composer.d.ts +40 -21
  128. package/dist/core/provider-composer.d.ts.map +1 -1
  129. package/dist/core/provider-composer.js +92 -40
  130. package/dist/core/provider-composer.js.map +1 -1
  131. package/dist/core/radius.d.ts +2 -0
  132. package/dist/core/radius.d.ts.map +1 -1
  133. package/dist/core/radius.js +2 -0
  134. package/dist/core/radius.js.map +1 -1
  135. package/dist/core/remote-catalog-provider.d.ts +8 -1
  136. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  137. package/dist/core/remote-catalog-provider.js +21 -11
  138. package/dist/core/remote-catalog-provider.js.map +1 -1
  139. package/dist/core/resource-loader.d.ts +7 -1
  140. package/dist/core/resource-loader.d.ts.map +1 -1
  141. package/dist/core/resource-loader.js +160 -35
  142. package/dist/core/resource-loader.js.map +1 -1
  143. package/dist/core/sdk.d.ts +3 -3
  144. package/dist/core/sdk.d.ts.map +1 -1
  145. package/dist/core/sdk.js +26 -7
  146. package/dist/core/sdk.js.map +1 -1
  147. package/dist/core/session-manager.d.ts +9 -0
  148. package/dist/core/session-manager.d.ts.map +1 -1
  149. package/dist/core/session-manager.js +22 -22
  150. package/dist/core/session-manager.js.map +1 -1
  151. package/dist/core/settings-manager.d.ts +41 -4
  152. package/dist/core/settings-manager.d.ts.map +1 -1
  153. package/dist/core/settings-manager.js +110 -3
  154. package/dist/core/settings-manager.js.map +1 -1
  155. package/dist/core/slash-commands.d.ts.map +1 -1
  156. package/dist/core/slash-commands.js +1 -0
  157. package/dist/core/slash-commands.js.map +1 -1
  158. package/dist/core/source-info.d.ts +8 -0
  159. package/dist/core/source-info.d.ts.map +1 -1
  160. package/dist/core/source-info.js +16 -0
  161. package/dist/core/source-info.js.map +1 -1
  162. package/dist/core/system-prompt.js +1 -1
  163. package/dist/core/system-prompt.js.map +1 -1
  164. package/dist/core/tasks/delivery.d.ts +40 -0
  165. package/dist/core/tasks/delivery.d.ts.map +1 -0
  166. package/dist/core/tasks/delivery.js +157 -0
  167. package/dist/core/tasks/delivery.js.map +1 -0
  168. package/dist/core/tasks/format.d.ts +7 -0
  169. package/dist/core/tasks/format.d.ts.map +1 -0
  170. package/dist/core/tasks/format.js +14 -0
  171. package/dist/core/tasks/format.js.map +1 -0
  172. package/dist/core/tasks/history.d.ts +4 -0
  173. package/dist/core/tasks/history.d.ts.map +1 -0
  174. package/dist/core/{background → tasks}/history.js +8 -51
  175. package/dist/core/tasks/history.js.map +1 -0
  176. package/dist/core/{background → tasks}/output.d.ts +12 -4
  177. package/dist/core/tasks/output.d.ts.map +1 -0
  178. package/dist/core/{background → tasks}/output.js +30 -11
  179. package/dist/core/tasks/output.js.map +1 -0
  180. package/dist/core/tasks/presentation.d.ts +7 -0
  181. package/dist/core/tasks/presentation.d.ts.map +1 -0
  182. package/dist/core/tasks/presentation.js +226 -0
  183. package/dist/core/tasks/presentation.js.map +1 -0
  184. package/dist/core/tasks/runtime.d.ts +74 -0
  185. package/dist/core/tasks/runtime.d.ts.map +1 -0
  186. package/dist/core/tasks/runtime.js +580 -0
  187. package/dist/core/tasks/runtime.js.map +1 -0
  188. package/dist/core/tasks/session.d.ts +49 -0
  189. package/dist/core/tasks/session.d.ts.map +1 -0
  190. package/dist/core/tasks/session.js +138 -0
  191. package/dist/core/tasks/session.js.map +1 -0
  192. package/dist/core/tasks/store.d.ts +46 -0
  193. package/dist/core/tasks/store.d.ts.map +1 -0
  194. package/dist/core/tasks/store.js +162 -0
  195. package/dist/core/tasks/store.js.map +1 -0
  196. package/dist/core/{background → tasks}/types.d.ts +64 -86
  197. package/dist/core/tasks/types.d.ts.map +1 -0
  198. package/dist/core/tasks/types.js +27 -0
  199. package/dist/core/tasks/types.js.map +1 -0
  200. package/dist/core/tools/bash.d.ts +8 -93
  201. package/dist/core/tools/bash.d.ts.map +1 -1
  202. package/dist/core/tools/bash.js +8 -240
  203. package/dist/core/tools/bash.js.map +1 -1
  204. package/dist/core/tools/grep.d.ts +2 -0
  205. package/dist/core/tools/grep.d.ts.map +1 -1
  206. package/dist/core/tools/grep.js +2 -0
  207. package/dist/core/tools/grep.js.map +1 -1
  208. package/dist/core/tools/index.d.ts +2 -1
  209. package/dist/core/tools/index.d.ts.map +1 -1
  210. package/dist/core/tools/index.js +9 -0
  211. package/dist/core/tools/index.js.map +1 -1
  212. package/dist/core/tools/output-accumulator.d.ts +11 -0
  213. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  214. package/dist/core/tools/output-accumulator.js +36 -0
  215. package/dist/core/tools/output-accumulator.js.map +1 -1
  216. package/dist/core/tools/powershell.d.ts +6 -2
  217. package/dist/core/tools/powershell.d.ts.map +1 -1
  218. package/dist/core/tools/powershell.js +1 -1
  219. package/dist/core/tools/powershell.js.map +1 -1
  220. package/dist/core/tools/render-utils.d.ts +6 -0
  221. package/dist/core/tools/render-utils.d.ts.map +1 -1
  222. package/dist/core/tools/render-utils.js +26 -0
  223. package/dist/core/tools/render-utils.js.map +1 -1
  224. package/dist/core/tools/renderers/bash.d.ts +1 -1
  225. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  226. package/dist/core/tools/renderers/bash.js +11 -35
  227. package/dist/core/tools/renderers/bash.js.map +1 -1
  228. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  229. package/dist/core/tools/renderers/index.js +5 -7
  230. package/dist/core/tools/renderers/index.js.map +1 -1
  231. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  232. package/dist/core/tools/renderers/read.js +3 -2
  233. package/dist/core/tools/renderers/read.js.map +1 -1
  234. package/dist/core/tools/shell-execution.d.ts +4 -6
  235. package/dist/core/tools/shell-execution.d.ts.map +1 -1
  236. package/dist/core/tools/shell-execution.js +22 -13
  237. package/dist/core/tools/shell-execution.js.map +1 -1
  238. package/dist/core/tools/shell-tool.d.ts +93 -0
  239. package/dist/core/tools/shell-tool.d.ts.map +1 -0
  240. package/dist/core/tools/shell-tool.js +249 -0
  241. package/dist/core/tools/shell-tool.js.map +1 -0
  242. package/dist/core/tools/tasks/actions.d.ts +12 -0
  243. package/dist/core/tools/tasks/actions.d.ts.map +1 -0
  244. package/dist/{extensions/background → core/tools/tasks}/actions.js +44 -29
  245. package/dist/core/tools/tasks/actions.js.map +1 -0
  246. package/dist/core/tools/tasks/constants.d.ts +20 -0
  247. package/dist/core/tools/tasks/constants.d.ts.map +1 -0
  248. package/dist/core/tools/tasks/constants.js +20 -0
  249. package/dist/core/tools/tasks/constants.js.map +1 -0
  250. package/dist/{extensions/background → core/tools/tasks}/schema.d.ts +7 -7
  251. package/dist/core/tools/tasks/schema.d.ts.map +1 -0
  252. package/dist/{extensions/background → core/tools/tasks}/schema.js +21 -20
  253. package/dist/core/tools/tasks/schema.js.map +1 -0
  254. package/dist/core/tools/tasks/types.d.ts +53 -0
  255. package/dist/core/tools/tasks/types.d.ts.map +1 -0
  256. package/dist/core/tools/tasks/types.js +12 -0
  257. package/dist/core/tools/tasks/types.js.map +1 -0
  258. package/dist/core/tools/tasks.d.ts +14 -0
  259. package/dist/core/tools/tasks.d.ts.map +1 -0
  260. package/dist/core/tools/tasks.js +40 -0
  261. package/dist/core/tools/tasks.js.map +1 -0
  262. package/dist/core/tools/tool-definition-wrapper.d.ts +4 -3
  263. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  264. package/dist/core/tools/tool-definition-wrapper.js +4 -2
  265. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  266. package/dist/core/tools/truncate.d.ts +14 -0
  267. package/dist/core/tools/truncate.d.ts.map +1 -1
  268. package/dist/core/tools/truncate.js +29 -0
  269. package/dist/core/tools/truncate.js.map +1 -1
  270. package/dist/core/trust-manager.d.ts.map +1 -1
  271. package/dist/core/trust-manager.js +1 -0
  272. package/dist/core/trust-manager.js.map +1 -1
  273. package/dist/core/usage-totals.d.ts +5 -3
  274. package/dist/core/usage-totals.d.ts.map +1 -1
  275. package/dist/core/usage-totals.js +27 -4
  276. package/dist/core/usage-totals.js.map +1 -1
  277. package/dist/core/virtual-models.d.ts +117 -0
  278. package/dist/core/virtual-models.d.ts.map +1 -0
  279. package/dist/core/virtual-models.js +124 -0
  280. package/dist/core/virtual-models.js.map +1 -0
  281. package/dist/extensions/btw/agent.d.ts +17 -8
  282. package/dist/extensions/btw/agent.d.ts.map +1 -1
  283. package/dist/extensions/btw/agent.js +74 -76
  284. package/dist/extensions/btw/agent.js.map +1 -1
  285. package/dist/extensions/btw/controller.d.ts +0 -1
  286. package/dist/extensions/btw/controller.d.ts.map +1 -1
  287. package/dist/extensions/btw/controller.js +26 -33
  288. package/dist/extensions/btw/controller.js.map +1 -1
  289. package/dist/extensions/btw/panel.d.ts +13 -14
  290. package/dist/extensions/btw/panel.d.ts.map +1 -1
  291. package/dist/extensions/btw/panel.js +38 -29
  292. package/dist/extensions/btw/panel.js.map +1 -1
  293. package/dist/extensions/codemode/execute.d.ts +16 -0
  294. package/dist/extensions/codemode/execute.d.ts.map +1 -0
  295. package/dist/extensions/codemode/execute.js +536 -0
  296. package/dist/extensions/codemode/execute.js.map +1 -0
  297. package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
  298. package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
  299. package/dist/extensions/codemode/execute.lazy.js +3 -0
  300. package/dist/extensions/codemode/execute.lazy.js.map +1 -0
  301. package/dist/extensions/codemode/index.d.ts +21 -0
  302. package/dist/extensions/codemode/index.d.ts.map +1 -0
  303. package/dist/extensions/codemode/index.js +36 -0
  304. package/dist/extensions/codemode/index.js.map +1 -0
  305. package/dist/extensions/codemode/renderer.d.ts +12 -0
  306. package/dist/extensions/codemode/renderer.d.ts.map +1 -0
  307. package/dist/extensions/codemode/renderer.js +137 -0
  308. package/dist/extensions/codemode/renderer.js.map +1 -0
  309. package/dist/extensions/codemode/search.d.ts +33 -0
  310. package/dist/extensions/codemode/search.d.ts.map +1 -0
  311. package/dist/extensions/codemode/search.js +117 -0
  312. package/dist/extensions/codemode/search.js.map +1 -0
  313. package/dist/extensions/codemode/tool.d.ts +123 -0
  314. package/dist/extensions/codemode/tool.d.ts.map +1 -0
  315. package/dist/extensions/codemode/tool.js +268 -0
  316. package/dist/extensions/codemode/tool.js.map +1 -0
  317. package/dist/extensions/codemode/worker.d.ts +7 -0
  318. package/dist/extensions/codemode/worker.d.ts.map +1 -0
  319. package/dist/extensions/codemode/worker.js +7 -0
  320. package/dist/extensions/codemode/worker.js.map +1 -0
  321. package/dist/extensions/deepwiki/schema.d.ts +1 -1
  322. package/dist/extensions/index.js +13 -13
  323. package/dist/extensions/index.js.map +1 -1
  324. package/dist/extensions/llama/provider.d.ts +1 -1
  325. package/dist/extensions/llama/provider.d.ts.map +1 -1
  326. package/dist/extensions/llama/provider.js +65 -13
  327. package/dist/extensions/llama/provider.js.map +1 -1
  328. package/dist/extensions/mcp/cli.d.ts +21 -0
  329. package/dist/extensions/mcp/cli.d.ts.map +1 -0
  330. package/dist/extensions/mcp/cli.js +500 -0
  331. package/dist/extensions/mcp/cli.js.map +1 -0
  332. package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
  333. package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
  334. package/dist/extensions/mcp/cli.lazy.js +3 -0
  335. package/dist/extensions/mcp/cli.lazy.js.map +1 -0
  336. package/dist/extensions/mcp/config.d.ts +72 -0
  337. package/dist/extensions/mcp/config.d.ts.map +1 -0
  338. package/dist/extensions/mcp/config.js +158 -0
  339. package/dist/extensions/mcp/config.js.map +1 -0
  340. package/dist/extensions/mcp/index.d.ts +76 -0
  341. package/dist/extensions/mcp/index.d.ts.map +1 -0
  342. package/dist/extensions/mcp/index.js +1078 -0
  343. package/dist/extensions/mcp/index.js.map +1 -0
  344. package/dist/extensions/mcp/log.d.ts +16 -0
  345. package/dist/extensions/mcp/log.d.ts.map +1 -0
  346. package/dist/extensions/mcp/log.js +64 -0
  347. package/dist/extensions/mcp/log.js.map +1 -0
  348. package/dist/extensions/mcp/oauth.d.ts +97 -0
  349. package/dist/extensions/mcp/oauth.d.ts.map +1 -0
  350. package/dist/extensions/mcp/oauth.js +355 -0
  351. package/dist/extensions/mcp/oauth.js.map +1 -0
  352. package/dist/extensions/mcp/resources.d.ts +43 -0
  353. package/dist/extensions/mcp/resources.d.ts.map +1 -0
  354. package/dist/extensions/mcp/resources.js +262 -0
  355. package/dist/extensions/mcp/resources.js.map +1 -0
  356. package/dist/extensions/mcp/runtime.d.ts +98 -0
  357. package/dist/extensions/mcp/runtime.d.ts.map +1 -0
  358. package/dist/extensions/mcp/runtime.js +379 -0
  359. package/dist/extensions/mcp/runtime.js.map +1 -0
  360. package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
  361. package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
  362. package/dist/extensions/mcp/runtime.lazy.js +3 -0
  363. package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
  364. package/dist/extensions/mcp/tools.d.ts +84 -0
  365. package/dist/extensions/mcp/tools.d.ts.map +1 -0
  366. package/dist/extensions/mcp/tools.js +251 -0
  367. package/dist/extensions/mcp/tools.js.map +1 -0
  368. package/dist/extensions/mcp/ui.d.ts +60 -0
  369. package/dist/extensions/mcp/ui.d.ts.map +1 -0
  370. package/dist/extensions/mcp/ui.js +168 -0
  371. package/dist/extensions/mcp/ui.js.map +1 -0
  372. package/dist/extensions/provider/catalog.d.ts +8 -1
  373. package/dist/extensions/provider/catalog.d.ts.map +1 -1
  374. package/dist/extensions/provider/catalog.js +31 -0
  375. package/dist/extensions/provider/catalog.js.map +1 -1
  376. package/dist/extensions/provider/connection.d.ts +4 -1
  377. package/dist/extensions/provider/connection.d.ts.map +1 -1
  378. package/dist/extensions/provider/connection.js +1 -5
  379. package/dist/extensions/provider/connection.js.map +1 -1
  380. package/dist/extensions/provider/editing.d.ts +36 -0
  381. package/dist/extensions/provider/editing.d.ts.map +1 -0
  382. package/dist/extensions/provider/editing.js +99 -0
  383. package/dist/extensions/provider/editing.js.map +1 -0
  384. package/dist/extensions/provider/json-fields.d.ts +5 -0
  385. package/dist/extensions/provider/json-fields.d.ts.map +1 -0
  386. package/dist/extensions/provider/json-fields.js +31 -0
  387. package/dist/extensions/provider/json-fields.js.map +1 -0
  388. package/dist/extensions/provider/store.d.ts +1 -4
  389. package/dist/extensions/provider/store.d.ts.map +1 -1
  390. package/dist/extensions/provider/store.js +2 -30
  391. package/dist/extensions/provider/store.js.map +1 -1
  392. package/dist/extensions/provider/ui/builtin-data.d.ts +0 -2
  393. package/dist/extensions/provider/ui/builtin-data.d.ts.map +1 -1
  394. package/dist/extensions/provider/ui/builtin-data.js +14 -79
  395. package/dist/extensions/provider/ui/builtin-data.js.map +1 -1
  396. package/dist/extensions/provider/ui/compat.d.ts.map +1 -1
  397. package/dist/extensions/provider/ui/compat.js +6 -9
  398. package/dist/extensions/provider/ui/compat.js.map +1 -1
  399. package/dist/extensions/provider/ui/controls.d.ts +48 -0
  400. package/dist/extensions/provider/ui/controls.d.ts.map +1 -0
  401. package/dist/extensions/provider/ui/controls.js +108 -0
  402. package/dist/extensions/provider/ui/controls.js.map +1 -0
  403. package/dist/extensions/provider/ui/dictionary.d.ts.map +1 -1
  404. package/dist/extensions/provider/ui/dictionary.js +6 -9
  405. package/dist/extensions/provider/ui/dictionary.js.map +1 -1
  406. package/dist/extensions/provider/ui/editor.d.ts +3 -3
  407. package/dist/extensions/provider/ui/editor.d.ts.map +1 -1
  408. package/dist/extensions/provider/ui/editor.js +35 -140
  409. package/dist/extensions/provider/ui/editor.js.map +1 -1
  410. package/dist/extensions/provider/ui/fetch-models.d.ts +0 -3
  411. package/dist/extensions/provider/ui/fetch-models.d.ts.map +1 -1
  412. package/dist/extensions/provider/ui/fetch-models.js +49 -44
  413. package/dist/extensions/provider/ui/fetch-models.js.map +1 -1
  414. package/dist/extensions/provider/ui/model-fields.d.ts.map +1 -1
  415. package/dist/extensions/provider/ui/model-fields.js +11 -14
  416. package/dist/extensions/provider/ui/model-fields.js.map +1 -1
  417. package/dist/extensions/provider/ui/model-options.d.ts +4 -34
  418. package/dist/extensions/provider/ui/model-options.d.ts.map +1 -1
  419. package/dist/extensions/provider/ui/model-options.js +90 -271
  420. package/dist/extensions/provider/ui/model-options.js.map +1 -1
  421. package/dist/extensions/provider/ui/pane.d.ts +4 -18
  422. package/dist/extensions/provider/ui/pane.d.ts.map +1 -1
  423. package/dist/extensions/provider/ui/pane.js.map +1 -1
  424. package/dist/extensions/provider/ui/provider-fields.d.ts +2 -19
  425. package/dist/extensions/provider/ui/provider-fields.d.ts.map +1 -1
  426. package/dist/extensions/provider/ui/provider-fields.js +58 -171
  427. package/dist/extensions/provider/ui/provider-fields.js.map +1 -1
  428. package/dist/extensions/provider/ui/thinking-map.d.ts.map +1 -1
  429. package/dist/extensions/provider/ui/thinking-map.js +6 -9
  430. package/dist/extensions/provider/ui/thinking-map.js.map +1 -1
  431. package/dist/extensions/question/detail-pane.d.ts +7 -2
  432. package/dist/extensions/question/detail-pane.d.ts.map +1 -1
  433. package/dist/extensions/question/detail-pane.js +16 -5
  434. package/dist/extensions/question/detail-pane.js.map +1 -1
  435. package/dist/extensions/question/dialog-view.d.ts +41 -0
  436. package/dist/extensions/question/dialog-view.d.ts.map +1 -0
  437. package/dist/extensions/question/dialog-view.js +329 -0
  438. package/dist/extensions/question/dialog-view.js.map +1 -0
  439. package/dist/extensions/question/dialog.d.ts +3 -3
  440. package/dist/extensions/question/dialog.d.ts.map +1 -1
  441. package/dist/extensions/question/dialog.js +220 -634
  442. package/dist/extensions/question/dialog.js.map +1 -1
  443. package/dist/extensions/question/index.d.ts.map +1 -1
  444. package/dist/extensions/question/index.js +2 -3
  445. package/dist/extensions/question/index.js.map +1 -1
  446. package/dist/extensions/question/render.d.ts.map +1 -1
  447. package/dist/extensions/question/render.js +22 -32
  448. package/dist/extensions/question/render.js.map +1 -1
  449. package/dist/extensions/question/results.d.ts.map +1 -1
  450. package/dist/extensions/question/results.js +56 -12
  451. package/dist/extensions/question/results.js.map +1 -1
  452. package/dist/extensions/question/schema.d.ts +21 -6
  453. package/dist/extensions/question/schema.d.ts.map +1 -1
  454. package/dist/extensions/question/schema.js.map +1 -1
  455. package/dist/extensions/question/state.d.ts +9 -7
  456. package/dist/extensions/question/state.d.ts.map +1 -1
  457. package/dist/extensions/question/state.js +63 -54
  458. package/dist/extensions/question/state.js.map +1 -1
  459. package/dist/extensions/question/types.d.ts +41 -18
  460. package/dist/extensions/question/types.d.ts.map +1 -1
  461. package/dist/extensions/question/types.js.map +1 -1
  462. package/dist/extensions/statusline/index.d.ts +4 -0
  463. package/dist/extensions/statusline/index.d.ts.map +1 -1
  464. package/dist/extensions/statusline/index.js +18 -355
  465. package/dist/extensions/statusline/index.js.map +1 -1
  466. package/dist/extensions/statusline/render.d.ts +19 -0
  467. package/dist/extensions/statusline/render.d.ts.map +1 -0
  468. package/dist/extensions/statusline/render.js +163 -0
  469. package/dist/extensions/statusline/render.js.map +1 -0
  470. package/dist/extensions/statusline/usage.d.ts +12 -0
  471. package/dist/extensions/statusline/usage.d.ts.map +1 -0
  472. package/dist/extensions/statusline/usage.js +36 -0
  473. package/dist/extensions/statusline/usage.js.map +1 -0
  474. package/dist/extensions/tool-search/index.d.ts +12 -0
  475. package/dist/extensions/tool-search/index.d.ts.map +1 -0
  476. package/dist/extensions/tool-search/index.js +20 -0
  477. package/dist/extensions/tool-search/index.js.map +1 -0
  478. package/dist/extensions/tool-search/tool.d.ts +73 -0
  479. package/dist/extensions/tool-search/tool.d.ts.map +1 -0
  480. package/dist/extensions/tool-search/tool.js +187 -0
  481. package/dist/extensions/tool-search/tool.js.map +1 -0
  482. package/dist/extensions/web-search/execute.d.ts +1 -5
  483. package/dist/extensions/web-search/execute.d.ts.map +1 -1
  484. package/dist/extensions/web-search/execute.js +4 -9
  485. package/dist/extensions/web-search/execute.js.map +1 -1
  486. package/dist/extensions/web-search/format.d.ts +12 -3
  487. package/dist/extensions/web-search/format.d.ts.map +1 -1
  488. package/dist/extensions/web-search/format.js +33 -25
  489. package/dist/extensions/web-search/format.js.map +1 -1
  490. package/dist/extensions/web-search/index.d.ts.map +1 -1
  491. package/dist/extensions/web-search/index.js +6 -29
  492. package/dist/extensions/web-search/index.js.map +1 -1
  493. package/dist/extensions/web-search/providers/deepseek.d.ts.map +1 -1
  494. package/dist/extensions/web-search/providers/deepseek.js +0 -1
  495. package/dist/extensions/web-search/providers/deepseek.js.map +1 -1
  496. package/dist/extensions/web-search/providers/http.d.ts +1 -1
  497. package/dist/extensions/web-search/providers/http.d.ts.map +1 -1
  498. package/dist/extensions/web-search/providers/http.js.map +1 -1
  499. package/dist/extensions/web-search/providers/minimax.d.ts.map +1 -1
  500. package/dist/extensions/web-search/providers/minimax.js +0 -1
  501. package/dist/extensions/web-search/providers/minimax.js.map +1 -1
  502. package/dist/extensions/web-search/render.d.ts +7 -2
  503. package/dist/extensions/web-search/render.d.ts.map +1 -1
  504. package/dist/extensions/web-search/render.js +32 -4
  505. package/dist/extensions/web-search/render.js.map +1 -1
  506. package/dist/extensions/web-search/results.d.ts.map +1 -1
  507. package/dist/extensions/web-search/results.js +3 -8
  508. package/dist/extensions/web-search/results.js.map +1 -1
  509. package/dist/extensions/web-search/types.d.ts +4 -2
  510. package/dist/extensions/web-search/types.d.ts.map +1 -1
  511. package/dist/extensions/web-search/types.js.map +1 -1
  512. package/dist/index.d.ts +12 -5
  513. package/dist/index.d.ts.map +1 -1
  514. package/dist/index.js +6 -1
  515. package/dist/index.js.map +1 -1
  516. package/dist/main.d.ts.map +1 -1
  517. package/dist/main.js +16 -0
  518. package/dist/main.js.map +1 -1
  519. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  520. package/dist/modes/interactive/components/config-selector.js +13 -3
  521. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  522. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/custom-message.js +3 -1
  524. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  525. package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
  526. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  527. package/dist/modes/interactive/components/first-time-setup.js +8 -2
  528. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  529. package/dist/modes/interactive/components/footer.d.ts +7 -0
  530. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  531. package/dist/modes/interactive/components/footer.js +42 -3
  532. package/dist/modes/interactive/components/footer.js.map +1 -1
  533. package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
  534. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  535. package/dist/modes/interactive/components/oauth-selector.js +24 -21
  536. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  537. package/dist/modes/interactive/components/pi-logo-animation.d.ts +68 -0
  538. package/dist/modes/interactive/components/pi-logo-animation.d.ts.map +1 -0
  539. package/dist/modes/interactive/components/pi-logo-animation.js +1076 -0
  540. package/dist/modes/interactive/components/pi-logo-animation.js.map +1 -0
  541. package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts +7 -0
  542. package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts.map +1 -0
  543. package/dist/modes/interactive/components/pi-logo-animation.lazy.js +12 -0
  544. package/dist/modes/interactive/components/pi-logo-animation.lazy.js.map +1 -0
  545. package/dist/modes/interactive/components/pi-logo.d.ts +19 -0
  546. package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -0
  547. package/dist/modes/interactive/components/pi-logo.js +37 -0
  548. package/dist/modes/interactive/components/pi-logo.js.map +1 -0
  549. package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
  550. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
  551. package/dist/modes/interactive/components/radius-login-selector.js +83 -0
  552. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
  553. package/dist/modes/interactive/components/settings-selector.d.ts +6 -4
  554. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  555. package/dist/modes/interactive/components/settings-selector.js +33 -11
  556. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  557. package/dist/modes/interactive/components/status-marker.d.ts +2 -4
  558. package/dist/modes/interactive/components/status-marker.d.ts.map +1 -1
  559. package/dist/modes/interactive/components/status-marker.js +2 -6
  560. package/dist/modes/interactive/components/status-marker.js.map +1 -1
  561. package/dist/modes/interactive/components/themed-text.d.ts +17 -0
  562. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
  563. package/dist/modes/interactive/components/themed-text.js +28 -0
  564. package/dist/modes/interactive/components/themed-text.js.map +1 -0
  565. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  566. package/dist/modes/interactive/components/user-message.js +5 -4
  567. package/dist/modes/interactive/components/user-message.js.map +1 -1
  568. package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
  569. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  570. package/dist/modes/interactive/components/visual-truncate.js +36 -6
  571. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  572. package/dist/modes/interactive/interactive-mode.d.ts +12 -4
  573. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  574. package/dist/modes/interactive/interactive-mode.js +377 -199
  575. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  576. package/dist/modes/interactive/tasks/completion-render.d.ts +8 -0
  577. package/dist/modes/interactive/tasks/completion-render.d.ts.map +1 -0
  578. package/dist/{extensions/background → modes/interactive/tasks}/completion-render.js +41 -91
  579. package/dist/modes/interactive/tasks/completion-render.js.map +1 -0
  580. package/dist/modes/interactive/tasks/index.d.ts +12 -0
  581. package/dist/modes/interactive/tasks/index.d.ts.map +1 -0
  582. package/dist/modes/interactive/tasks/index.js +102 -0
  583. package/dist/modes/interactive/tasks/index.js.map +1 -0
  584. package/dist/modes/interactive/tasks/inspector.d.ts +35 -0
  585. package/dist/modes/interactive/tasks/inspector.d.ts.map +1 -0
  586. package/dist/modes/interactive/tasks/inspector.js +93 -0
  587. package/dist/modes/interactive/tasks/inspector.js.map +1 -0
  588. package/dist/modes/interactive/tasks/layout.d.ts +40 -0
  589. package/dist/modes/interactive/tasks/layout.d.ts.map +1 -0
  590. package/dist/modes/interactive/tasks/layout.js +212 -0
  591. package/dist/modes/interactive/tasks/layout.js.map +1 -0
  592. package/dist/modes/interactive/tasks/list.d.ts +21 -0
  593. package/dist/modes/interactive/tasks/list.d.ts.map +1 -0
  594. package/dist/modes/interactive/tasks/list.js +96 -0
  595. package/dist/modes/interactive/tasks/list.js.map +1 -0
  596. package/dist/modes/interactive/tasks/manager.d.ts +60 -0
  597. package/dist/modes/interactive/tasks/manager.d.ts.map +1 -0
  598. package/dist/modes/interactive/tasks/manager.js +380 -0
  599. package/dist/modes/interactive/tasks/manager.js.map +1 -0
  600. package/dist/modes/interactive/tasks/model.d.ts +21 -0
  601. package/dist/modes/interactive/tasks/model.d.ts.map +1 -0
  602. package/dist/modes/interactive/tasks/model.js +41 -0
  603. package/dist/modes/interactive/tasks/model.js.map +1 -0
  604. package/dist/modes/interactive/tasks/render.d.ts +28 -0
  605. package/dist/modes/interactive/tasks/render.d.ts.map +1 -0
  606. package/dist/modes/interactive/tasks/render.js +141 -0
  607. package/dist/modes/interactive/tasks/render.js.map +1 -0
  608. package/dist/modes/interactive/tasks/task-view.d.ts +13 -0
  609. package/dist/modes/interactive/tasks/task-view.d.ts.map +1 -0
  610. package/dist/modes/interactive/tasks/task-view.js +20 -0
  611. package/dist/modes/interactive/tasks/task-view.js.map +1 -0
  612. package/dist/modes/interactive/tasks/text.d.ts +6 -0
  613. package/dist/modes/interactive/tasks/text.d.ts.map +1 -0
  614. package/dist/modes/interactive/tasks/text.js +16 -0
  615. package/dist/modes/interactive/tasks/text.js.map +1 -0
  616. package/dist/modes/interactive/tasks/viewport.d.ts +17 -0
  617. package/dist/modes/interactive/tasks/viewport.d.ts.map +1 -0
  618. package/dist/modes/interactive/tasks/viewport.js +59 -0
  619. package/dist/modes/interactive/tasks/viewport.js.map +1 -0
  620. package/dist/modes/interactive/tasks/views.d.ts +9 -0
  621. package/dist/modes/interactive/tasks/views.d.ts.map +1 -0
  622. package/dist/modes/interactive/tasks/views.js +42 -0
  623. package/dist/modes/interactive/tasks/views.js.map +1 -0
  624. package/dist/modes/interactive/theme/dark.json +59 -72
  625. package/dist/modes/interactive/theme/light.json +57 -69
  626. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  627. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  628. package/dist/modes/interactive/theme/system-theme.js +546 -0
  629. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  630. package/dist/modes/interactive/theme/theme-controller.d.ts +46 -6
  631. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  632. package/dist/modes/interactive/theme/theme-controller.js +125 -47
  633. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  634. package/dist/modes/interactive/theme/theme-json.d.ts +1 -0
  635. package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -1
  636. package/dist/modes/interactive/theme/theme-json.js +3 -1
  637. package/dist/modes/interactive/theme/theme-json.js.map +1 -1
  638. package/dist/modes/interactive/theme/theme-schema.json +7 -2
  639. package/dist/modes/interactive/theme/theme.d.ts +70 -39
  640. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  641. package/dist/modes/interactive/theme/theme.js +247 -313
  642. package/dist/modes/interactive/theme/theme.js.map +1 -1
  643. package/dist/modes/interactive/tool-view/fallback.d.ts +1 -1
  644. package/dist/modes/interactive/tool-view/fallback.d.ts.map +1 -1
  645. package/dist/modes/interactive/tool-view/fallback.js +4 -1
  646. package/dist/modes/interactive/tool-view/fallback.js.map +1 -1
  647. package/dist/modes/interactive/tool-view/tool-execution.js +2 -2
  648. package/dist/modes/interactive/tool-view/tool-execution.js.map +1 -1
  649. package/dist/modes/interactive/tui-renderer.d.ts +2 -1
  650. package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
  651. package/dist/modes/interactive/tui-renderer.js +1 -0
  652. package/dist/modes/interactive/tui-renderer.js.map +1 -1
  653. package/dist/modes/rpc/rpc-client.d.ts +6 -6
  654. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  655. package/dist/modes/rpc/rpc-client.js +12 -8
  656. package/dist/modes/rpc/rpc-client.js.map +1 -1
  657. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  658. package/dist/modes/rpc/rpc-mode.js +7 -9
  659. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  660. package/dist/modes/rpc/rpc-types.d.ts +10 -1
  661. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  662. package/dist/modes/rpc/rpc-types.js.map +1 -1
  663. package/dist/package-manager-cli.d.ts.map +1 -1
  664. package/dist/package-manager-cli.js +6 -2
  665. package/dist/package-manager-cli.js.map +1 -1
  666. package/dist/utils/clipboard-image.d.ts.map +1 -1
  667. package/dist/utils/clipboard-image.js +14 -17
  668. package/dist/utils/clipboard-image.js.map +1 -1
  669. package/dist/utils/clipboard.d.ts +2 -0
  670. package/dist/utils/clipboard.d.ts.map +1 -1
  671. package/dist/utils/clipboard.js +5 -0
  672. package/dist/utils/clipboard.js.map +1 -1
  673. package/dist/utils/paths.d.ts +3 -3
  674. package/dist/utils/paths.d.ts.map +1 -1
  675. package/dist/utils/paths.js +5 -4
  676. package/dist/utils/paths.js.map +1 -1
  677. package/dist/utils/shell.d.ts +1 -3
  678. package/dist/utils/shell.d.ts.map +1 -1
  679. package/dist/utils/shell.js +3 -30
  680. package/dist/utils/shell.js.map +1 -1
  681. package/docs/bundled/README.md +22 -9
  682. package/docs/bundled/extensions/question.md +2 -2
  683. package/docs/bundled/extensions/statusline.md +26 -17
  684. package/docs/bundled/tasks.md +127 -0
  685. package/docs/bundled/tool-presentation.md +1 -1
  686. package/docs/codemode.md +207 -0
  687. package/docs/custom-provider.md +44 -0
  688. package/docs/docs.json +14 -10
  689. package/docs/environment-variables.md +1 -1
  690. package/docs/extensions.md +94 -93
  691. package/docs/index.md +2 -1
  692. package/docs/keybindings.md +17 -9
  693. package/docs/llama-cpp.md +12 -1
  694. package/docs/mcp.md +248 -0
  695. package/docs/models.md +56 -0
  696. package/docs/packages.md +4 -0
  697. package/docs/providers.md +14 -0
  698. package/docs/rpc.md +5 -3
  699. package/docs/sdk.md +26 -16
  700. package/docs/security.md +4 -0
  701. package/docs/session-format.md +20 -23
  702. package/docs/settings.md +29 -3
  703. package/docs/themes.md +27 -5
  704. package/docs/tui.md +21 -1
  705. package/docs/usage.md +52 -4
  706. package/docs/virtual-models.md +114 -0
  707. package/docs/windows.md +2 -0
  708. package/examples/README.md +2 -2
  709. package/examples/extensions/README.md +3 -2
  710. package/examples/extensions/built-in-tool-renderer.ts +16 -40
  711. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  712. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  713. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  714. package/examples/extensions/custom-provider-gitlab-duo/test.ts +4 -4
  715. package/examples/extensions/debug-provider.ts +90 -0
  716. package/examples/extensions/gondolin/package-lock.json +2 -2
  717. package/examples/extensions/gondolin/package.json +1 -1
  718. package/examples/extensions/jev-router.ts +113 -0
  719. package/examples/extensions/minimal-mode.ts +24 -96
  720. package/examples/extensions/sandbox/package-lock.json +2 -2
  721. package/examples/extensions/sandbox/package.json +1 -1
  722. package/examples/extensions/with-deps/package-lock.json +2 -2
  723. package/examples/extensions/with-deps/package.json +1 -1
  724. package/examples/rpc-client.ts +1 -1
  725. package/examples/rpc-extension-ui.ts +1 -1
  726. package/examples/sdk/14-codemode-mcp.ts +61 -0
  727. package/examples/sdk/README.md +1 -0
  728. package/npm-shrinkwrap.json +420 -423
  729. package/package.json +14 -10
  730. package/dist/bundle/chunks/anthropic-messages-XWFTZP2N.js +0 -6
  731. package/dist/bundle/chunks/azure-openai-responses-HS35BQV6.js +0 -2
  732. package/dist/bundle/chunks/chunk-2IO5GDBS.js +0 -11
  733. package/dist/bundle/chunks/chunk-EDBLK2JQ.js +0 -2
  734. package/dist/bundle/chunks/chunk-I5IVW2WS.js +0 -2
  735. package/dist/bundle/chunks/chunk-IORR2FW4.js +0 -2
  736. package/dist/bundle/chunks/chunk-NUHFSC37.js +0 -25
  737. package/dist/bundle/chunks/chunk-UUSTLCVC.js +0 -2
  738. package/dist/bundle/chunks/google-generative-ai-NOVAJBFC.js +0 -2
  739. package/dist/bundle/chunks/google-vertex-4VHCZJV5.js +0 -2
  740. package/dist/bundle/chunks/mistral-conversations-WC6A2WCJ.js +0 -5
  741. package/dist/bundle/chunks/openai-codex-responses-XCDG75W2.js +0 -10
  742. package/dist/bundle/chunks/openai-completions-SHS3CAEL.js +0 -7
  743. package/dist/bundle/chunks/openai-responses-UT6XFKC7.js +0 -2
  744. package/dist/bundle/chunks/virtual-modules-KUEIEAZN.js +0 -2
  745. package/dist/core/background/history.d.ts +0 -4
  746. package/dist/core/background/history.d.ts.map +0 -1
  747. package/dist/core/background/history.js.map +0 -1
  748. package/dist/core/background/output.d.ts.map +0 -1
  749. package/dist/core/background/output.js.map +0 -1
  750. package/dist/core/background/presentation.d.ts +0 -9
  751. package/dist/core/background/presentation.d.ts.map +0 -1
  752. package/dist/core/background/presentation.js +0 -311
  753. package/dist/core/background/presentation.js.map +0 -1
  754. package/dist/core/background/service.d.ts +0 -68
  755. package/dist/core/background/service.d.ts.map +0 -1
  756. package/dist/core/background/service.js +0 -641
  757. package/dist/core/background/service.js.map +0 -1
  758. package/dist/core/background/session.d.ts +0 -67
  759. package/dist/core/background/session.d.ts.map +0 -1
  760. package/dist/core/background/session.js +0 -248
  761. package/dist/core/background/session.js.map +0 -1
  762. package/dist/core/background/types.d.ts.map +0 -1
  763. package/dist/core/background/types.js +0 -31
  764. package/dist/core/background/types.js.map +0 -1
  765. package/dist/extensions/background/actions.d.ts +0 -11
  766. package/dist/extensions/background/actions.d.ts.map +0 -1
  767. package/dist/extensions/background/actions.js.map +0 -1
  768. package/dist/extensions/background/completion-render.d.ts +0 -8
  769. package/dist/extensions/background/completion-render.d.ts.map +0 -1
  770. package/dist/extensions/background/completion-render.js.map +0 -1
  771. package/dist/extensions/background/constants.d.ts +0 -24
  772. package/dist/extensions/background/constants.d.ts.map +0 -1
  773. package/dist/extensions/background/constants.js +0 -24
  774. package/dist/extensions/background/constants.js.map +0 -1
  775. package/dist/extensions/background/index.d.ts +0 -7
  776. package/dist/extensions/background/index.d.ts.map +0 -1
  777. package/dist/extensions/background/index.js +0 -135
  778. package/dist/extensions/background/index.js.map +0 -1
  779. package/dist/extensions/background/keybindings.d.ts +0 -10
  780. package/dist/extensions/background/keybindings.d.ts.map +0 -1
  781. package/dist/extensions/background/keybindings.js +0 -14
  782. package/dist/extensions/background/keybindings.js.map +0 -1
  783. package/dist/extensions/background/manager.d.ts +0 -80
  784. package/dist/extensions/background/manager.d.ts.map +0 -1
  785. package/dist/extensions/background/manager.js +0 -673
  786. package/dist/extensions/background/manager.js.map +0 -1
  787. package/dist/extensions/background/render.d.ts +0 -42
  788. package/dist/extensions/background/render.d.ts.map +0 -1
  789. package/dist/extensions/background/render.js +0 -225
  790. package/dist/extensions/background/render.js.map +0 -1
  791. package/dist/extensions/background/schema.d.ts.map +0 -1
  792. package/dist/extensions/background/schema.js.map +0 -1
  793. package/dist/extensions/background/task-view.d.ts +0 -53
  794. package/dist/extensions/background/task-view.d.ts.map +0 -1
  795. package/dist/extensions/background/task-view.js +0 -60
  796. package/dist/extensions/background/task-view.js.map +0 -1
  797. package/dist/extensions/background/text.d.ts +0 -12
  798. package/dist/extensions/background/text.d.ts.map +0 -1
  799. package/dist/extensions/background/text.js +0 -39
  800. package/dist/extensions/background/text.js.map +0 -1
  801. package/dist/extensions/background/types.d.ts +0 -85
  802. package/dist/extensions/background/types.d.ts.map +0 -1
  803. package/dist/extensions/background/types.js +0 -17
  804. package/dist/extensions/background/types.js.map +0 -1
  805. package/dist/extensions/subagent/activity.d.ts +0 -34
  806. package/dist/extensions/subagent/activity.d.ts.map +0 -1
  807. package/dist/extensions/subagent/activity.js +0 -192
  808. package/dist/extensions/subagent/activity.js.map +0 -1
  809. package/dist/extensions/subagent/agents-command.d.ts +0 -4
  810. package/dist/extensions/subagent/agents-command.d.ts.map +0 -1
  811. package/dist/extensions/subagent/agents-command.js +0 -230
  812. package/dist/extensions/subagent/agents-command.js.map +0 -1
  813. package/dist/extensions/subagent/agents.d.ts +0 -6
  814. package/dist/extensions/subagent/agents.d.ts.map +0 -1
  815. package/dist/extensions/subagent/agents.js +0 -53
  816. package/dist/extensions/subagent/agents.js.map +0 -1
  817. package/dist/extensions/subagent/budget.d.ts +0 -15
  818. package/dist/extensions/subagent/budget.d.ts.map +0 -1
  819. package/dist/extensions/subagent/budget.js +0 -123
  820. package/dist/extensions/subagent/budget.js.map +0 -1
  821. package/dist/extensions/subagent/cancellation.d.ts +0 -29
  822. package/dist/extensions/subagent/cancellation.d.ts.map +0 -1
  823. package/dist/extensions/subagent/cancellation.js +0 -91
  824. package/dist/extensions/subagent/cancellation.js.map +0 -1
  825. package/dist/extensions/subagent/constants.d.ts +0 -25
  826. package/dist/extensions/subagent/constants.d.ts.map +0 -1
  827. package/dist/extensions/subagent/constants.js +0 -50
  828. package/dist/extensions/subagent/constants.js.map +0 -1
  829. package/dist/extensions/subagent/index.d.ts +0 -3
  830. package/dist/extensions/subagent/index.d.ts.map +0 -1
  831. package/dist/extensions/subagent/index.js +0 -151
  832. package/dist/extensions/subagent/index.js.map +0 -1
  833. package/dist/extensions/subagent/model-selection.d.ts +0 -16
  834. package/dist/extensions/subagent/model-selection.d.ts.map +0 -1
  835. package/dist/extensions/subagent/model-selection.js +0 -51
  836. package/dist/extensions/subagent/model-selection.js.map +0 -1
  837. package/dist/extensions/subagent/render.d.ts +0 -24
  838. package/dist/extensions/subagent/render.d.ts.map +0 -1
  839. package/dist/extensions/subagent/render.js +0 -336
  840. package/dist/extensions/subagent/render.js.map +0 -1
  841. package/dist/extensions/subagent/resolve.d.ts +0 -31
  842. package/dist/extensions/subagent/resolve.d.ts.map +0 -1
  843. package/dist/extensions/subagent/resolve.js +0 -111
  844. package/dist/extensions/subagent/resolve.js.map +0 -1
  845. package/dist/extensions/subagent/runner.d.ts +0 -35
  846. package/dist/extensions/subagent/runner.d.ts.map +0 -1
  847. package/dist/extensions/subagent/runner.js +0 -255
  848. package/dist/extensions/subagent/runner.js.map +0 -1
  849. package/dist/extensions/subagent/schema.d.ts +0 -28
  850. package/dist/extensions/subagent/schema.d.ts.map +0 -1
  851. package/dist/extensions/subagent/schema.js +0 -58
  852. package/dist/extensions/subagent/schema.js.map +0 -1
  853. package/dist/extensions/subagent/sdk-runner.d.ts +0 -33
  854. package/dist/extensions/subagent/sdk-runner.d.ts.map +0 -1
  855. package/dist/extensions/subagent/sdk-runner.js +0 -331
  856. package/dist/extensions/subagent/sdk-runner.js.map +0 -1
  857. package/dist/extensions/subagent/settings.d.ts +0 -8
  858. package/dist/extensions/subagent/settings.d.ts.map +0 -1
  859. package/dist/extensions/subagent/settings.js +0 -206
  860. package/dist/extensions/subagent/settings.js.map +0 -1
  861. package/dist/extensions/subagent/state.d.ts +0 -102
  862. package/dist/extensions/subagent/state.d.ts.map +0 -1
  863. package/dist/extensions/subagent/state.js +0 -383
  864. package/dist/extensions/subagent/state.js.map +0 -1
  865. package/dist/extensions/subagent/text.d.ts +0 -6
  866. package/dist/extensions/subagent/text.d.ts.map +0 -1
  867. package/dist/extensions/subagent/text.js +0 -66
  868. package/dist/extensions/subagent/text.js.map +0 -1
  869. package/dist/extensions/subagent/types.d.ts +0 -91
  870. package/dist/extensions/subagent/types.d.ts.map +0 -1
  871. package/dist/extensions/subagent/types.js +0 -2
  872. package/dist/extensions/subagent/types.js.map +0 -1
  873. package/dist/extensions/subagent/ui/agents-dialog.d.ts +0 -4
  874. package/dist/extensions/subagent/ui/agents-dialog.d.ts.map +0 -1
  875. package/dist/extensions/subagent/ui/agents-dialog.js +0 -84
  876. package/dist/extensions/subagent/ui/agents-dialog.js.map +0 -1
  877. package/dist/extensions/subagent/ui/choice-menu.d.ts +0 -39
  878. package/dist/extensions/subagent/ui/choice-menu.d.ts.map +0 -1
  879. package/dist/extensions/subagent/ui/choice-menu.js +0 -93
  880. package/dist/extensions/subagent/ui/choice-menu.js.map +0 -1
  881. package/dist/extensions/subagent/ui/choices.d.ts +0 -36
  882. package/dist/extensions/subagent/ui/choices.d.ts.map +0 -1
  883. package/dist/extensions/subagent/ui/choices.js +0 -54
  884. package/dist/extensions/subagent/ui/choices.js.map +0 -1
  885. package/dist/extensions/subagent/ui/model-list.d.ts +0 -66
  886. package/dist/extensions/subagent/ui/model-list.d.ts.map +0 -1
  887. package/dist/extensions/subagent/ui/model-list.js +0 -235
  888. package/dist/extensions/subagent/ui/model-list.js.map +0 -1
  889. package/dist/extensions/subagent/ui/model-picker.d.ts +0 -47
  890. package/dist/extensions/subagent/ui/model-picker.d.ts.map +0 -1
  891. package/dist/extensions/subagent/ui/model-picker.js +0 -143
  892. package/dist/extensions/subagent/ui/model-picker.js.map +0 -1
  893. package/dist/extensions/subagent/ui/profile-settings-menu.d.ts +0 -41
  894. package/dist/extensions/subagent/ui/profile-settings-menu.d.ts.map +0 -1
  895. package/dist/extensions/subagent/ui/profile-settings-menu.js +0 -98
  896. package/dist/extensions/subagent/ui/profile-settings-menu.js.map +0 -1
  897. package/dist/extensions/todo/constants.d.ts +0 -16
  898. package/dist/extensions/todo/constants.d.ts.map +0 -1
  899. package/dist/extensions/todo/constants.js +0 -30
  900. package/dist/extensions/todo/constants.js.map +0 -1
  901. package/dist/extensions/todo/index.d.ts +0 -3
  902. package/dist/extensions/todo/index.d.ts.map +0 -1
  903. package/dist/extensions/todo/index.js +0 -98
  904. package/dist/extensions/todo/index.js.map +0 -1
  905. package/dist/extensions/todo/schema.d.ts +0 -60
  906. package/dist/extensions/todo/schema.d.ts.map +0 -1
  907. package/dist/extensions/todo/schema.js +0 -56
  908. package/dist/extensions/todo/schema.js.map +0 -1
  909. package/dist/extensions/todo/state.d.ts +0 -34
  910. package/dist/extensions/todo/state.d.ts.map +0 -1
  911. package/dist/extensions/todo/state.js +0 -425
  912. package/dist/extensions/todo/state.js.map +0 -1
  913. package/dist/extensions/todo/view.d.ts +0 -36
  914. package/dist/extensions/todo/view.d.ts.map +0 -1
  915. package/dist/extensions/todo/view.js +0 -580
  916. package/dist/extensions/todo/view.js.map +0 -1
  917. package/dist/extensions/todo/widget.d.ts +0 -15
  918. package/dist/extensions/todo/widget.d.ts.map +0 -1
  919. package/dist/extensions/todo/widget.js +0 -50
  920. package/dist/extensions/todo/widget.js.map +0 -1
  921. package/docs/bundled/extensions/background.md +0 -132
  922. package/docs/bundled/extensions/subagent.md +0 -148
  923. package/docs/bundled/extensions/todo.md +0 -104
  924. package/examples/extensions/todo.ts +0 -297
@@ -0,0 +1,207 @@
1
+ # Codemode
2
+
3
+ The `codemode` tool lets the model write a JavaScript script that calls pi's other tools and runs non-LLM models, such as classifiers and image models. Only the script's output reaches the model, so a script can run calls in parallel and filter large results before the model sees them. To turn it on, see [Enable codemode](usage.md#enable-codemode).
4
+
5
+ ## Scripts
6
+
7
+ The tool input is raw JavaScript source, not JSON and not a markdown code fence. It runs as the body of an async function in a QuickJS sandbox, so top-level `await` and `return` work. The sandbox has no Node APIs, file system, network, or timers; scripts reach the outside world only through tools and `models`.
8
+
9
+ A script may start with an options line:
10
+
11
+ ```js
12
+ // @options: {"max_output_tokens": 2000, "timeout_ms": 60000}
13
+ ```
14
+
15
+ - `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.
16
+ - `timeout_ms` is a hard deadline for the whole script. It is unset by default. Image generation can take minutes, so do not set a short deadline for scripts that generate images.
17
+
18
+ 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. Tool calls are real: calls made before a failure are not undone. Calls still running when the script ends are cancelled, and unawaited promises are discarded.
19
+
20
+ ## Globals
21
+
22
+ | Global | Purpose |
23
+ |---|---|
24
+ | `tools.<name>(args)` | Call a tool. See [Call tools](#call-tools). |
25
+ | `text(value)` | Add a text item to the output. Strings are added as is, other values as JSON. |
26
+ | `image(value)` | Add an image to the output: a base64 `data:` URL, an `{ image_url }` object, or an image block `{ type: "image", data, mimeType }` such as those returned by MCP tools and `models.generateImages()`. Remote URLs are not supported. PNG, JPEG, GIF, and WebP are accepted. |
27
+ | `console.log(...)` | Like `text()`; `info`, `warn`, `error`, and `debug` do the same. |
28
+ | `return value` | A top-level `return` adds the value like `text()`. |
29
+ | `exit()` | End the script successfully. |
30
+ | `store(key, value)` / `load(key)` | Keep small JSON values across `codemode` calls. See [Store values](#store-values). |
31
+ | `ALL_TOOLS` | Every callable tool as `{ name, description }`, including tools the description does not list. |
32
+ | `searchTools(query, { limit?, namespace? })` | Rank callable tools by relevance (BM25, default limit 8). Resolves to `{ name, description }[]`. |
33
+ | `describeTool(name)` | Resolves to a tool's description and TypeScript declaration, or `undefined`. |
34
+ | `describeNamespace(name)` | Resolves to `{ name, description?, instructions?, tools }` for a namespace such as an MCP server, or `undefined`. |
35
+ | `models` | List and run non-LLM models. See [Models](#models). |
36
+
37
+ ## Call tools
38
+
39
+ Every tool the session can call is a method of `tools`, named by its identifier: characters that are not valid in a JavaScript identifier become `_`, so the MCP tool `mcp__dev-radius__search` is `tools.mcp__dev_radius__search`. Each method takes one object with the tool's arguments.
40
+
41
+ What a call resolves to depends on the tool:
42
+
43
+ - Tools with an output schema resolve to a structured value. `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes. Its `output` 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`. A command moved to the background resolves to `{ task_id, status }` instead; see [Tasks](bundled/tasks.md).
44
+ - MCP tools resolve to their `CallToolResult`, including `isError` and `structuredContent`.
45
+ - Other tools, such as `read`, `edit`, and `write`, resolve to their text output.
46
+
47
+ A call that fails, is blocked, or gets invalid arguments rejects with an `Error` that carries the tool's error text. Use `Promise.allSettled()` to keep the results of the calls that succeed.
48
+
49
+ The `codemode` description lists tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Tools with `deferred` exposure, which includes MCP tools with the default `codemode` exposure, are not listed, so the description stays the same while MCP servers connect. Listed declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](settings.md#tools)). Scripts find the other tools with `searchTools()`, `describeTool()`, `describeNamespace()`, or by filtering `ALL_TOOLS`.
50
+
51
+ While `codemode` is active, `codemode.mode` in [settings](settings.md#tools) decides how the other tools are presented. With `on` (default) declared tools stay declared, and their descriptions say 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.
52
+
53
+ ## Store values
54
+
55
+ `store(key, value)` keeps a JSON value under a string key for later `codemode` calls; storing `undefined` deletes the key. `load(key)` returns the value, or `undefined`. Writes are kept only when the script succeeds: 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.
56
+
57
+ The store is for small state such as IDs, cursors, or summaries. One value may have at most 262144 characters of JSON and all values together at most 1048576. Do not store image data; show images with `image()` or write them to a file with a tool.
58
+
59
+ ## Models
60
+
61
+ `models` reaches the model catalog and runs non-LLM models with the session's credentials: classifiers, which answer typed questions about JSON state, and image models, which generate images. Chat models are listed but cannot be run from scripts. Which classifier and image models exist is described in [Use classifier models](models.md#use-classifier-models) and [Use image models](models.md#use-image-models).
62
+
63
+ ```ts
64
+ type ModelType = "chat" | "image" | "classifier";
65
+
66
+ /** A catalog entry. `provider` and `id` identify it; other fields depend on the type. */
67
+ interface ModelInfo {
68
+ type?: ModelType;
69
+ provider: string;
70
+ id: string;
71
+ name: string;
72
+ api: string;
73
+ input: ("text" | "image")[];
74
+ contextWindow?: number;
75
+ [key: string]: unknown;
76
+ }
77
+
78
+ declare const models: {
79
+ /** Every known model of a type, optionally for one provider. */
80
+ getModelsOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
81
+ /** Models of a type whose provider has working credentials. */
82
+ getAvailableOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
83
+ /** One catalog entry, or undefined. */
84
+ getModelOfType(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>;
85
+ /** Answer `context.questions` about `context.state`; answers are in `result.answers` by question ID. */
86
+ classify(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>;
87
+ /** Generate images from `context.input` text and image blocks; show `result.output` blocks with image(). Can take minutes. */
88
+ generateImages(model: ModelInfo, context: ImagesContext): Promise<ImagesResult>;
89
+ };
90
+ ```
91
+
92
+ `classify()` and `generateImages()` use only the `provider` and `id` of `model`, so `{ provider, id }` works as well. They do not throw on provider errors: check `stopReason` and `errorMessage`. At most four such calls run at once per script; more calls wait for a free slot, so `Promise.all()` over many items is fine. Their usage is added to the `codemode` tool result and counts toward the session cost.
93
+
94
+ Model IDs differ between providers, for example `typesafe/jev-latest` and `openrouter/typesafe/jev-1.13`. Use `models.getAvailableOfType(type)` to find the IDs that work with the current credentials.
95
+
96
+ ### Classify
97
+
98
+ ```ts
99
+ interface ClassifierContext {
100
+ /** The data to classify. */
101
+ state: Record<string, unknown>;
102
+ /** Questions by ID. One call answers all of them. */
103
+ questions: Record<string, ClassifierQuestion>;
104
+ }
105
+
106
+ type ClassifierQuestion =
107
+ /** Pick one label. `criteria` maps each label to what it means. */
108
+ | { type: "choice"; instructions: string; criteria: Record<string, string> }
109
+ /** Score on an ordered scale. `criteria` describes each level, lowest first. */
110
+ | { type: "score"; instructions: string; criteria: string[] }
111
+ /** Yes or no. */
112
+ | { type: "bool"; instructions: string; criteria: { true: string; false: string } };
113
+
114
+ interface ClassifierResult {
115
+ provider: string;
116
+ model: string;
117
+ /** Answers by question ID. */
118
+ answers: Record<string, ClassifierAnswer>;
119
+ usage?: ModelUsage;
120
+ stopReason: "stop" | "error" | "aborted";
121
+ errorMessage?: string;
122
+ }
123
+
124
+ type ClassifierAnswer =
125
+ | { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number }
126
+ /** `score` is the expected level index, from 0 to `criteria.length - 1`. */
127
+ | { type: "score"; score: number; confidence: number }
128
+ /** Probability of `true`. */
129
+ | { type: "bool"; probability: number };
130
+
131
+ /** Token counts and cost in USD, when the service reports them. */
132
+ type ModelUsage = { input: number; output: number; totalTokens: number; cost: { total: number } };
133
+ ```
134
+
135
+ Classify several items by calling `classify()` once per item. This script sorts feedback messages, for example ones a tool returned earlier in the script:
136
+
137
+ ```js
138
+ const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
139
+ const results = await Promise.all(
140
+ messages.map((message) =>
141
+ models.classify(jev, {
142
+ state: { message },
143
+ questions: {
144
+ sentiment: {
145
+ type: "choice",
146
+ instructions: "How does the user feel about the product?",
147
+ criteria: { positive: "Satisfied or happy", negative: "Unhappy or frustrated", neutral: "Neither" },
148
+ },
149
+ urgency: {
150
+ type: "score",
151
+ instructions: "How urgently does this need a reply?",
152
+ criteria: ["no reply needed", "reply this week", "reply today"],
153
+ },
154
+ },
155
+ }),
156
+ ),
157
+ );
158
+ return results.map((result, i) =>
159
+ result.stopReason === "stop"
160
+ ? { message: messages[i], sentiment: result.answers.sentiment.choice, urgency: result.answers.urgency.score }
161
+ : { message: messages[i], error: result.errorMessage },
162
+ );
163
+ ```
164
+
165
+ ### Generate images
166
+
167
+ ```ts
168
+ interface ImagesContext {
169
+ /** The prompt as text blocks, plus image blocks to edit or use as references. */
170
+ input: (TextBlock | ImageBlock)[];
171
+ }
172
+
173
+ interface ImagesResult {
174
+ provider: string;
175
+ model: string;
176
+ /** Generated images, and text blocks for models that also return text. */
177
+ output: (TextBlock | ImageBlock)[];
178
+ usage?: ModelUsage;
179
+ stopReason: "stop" | "error" | "aborted";
180
+ errorMessage?: string;
181
+ }
182
+
183
+ type TextBlock = { type: "text"; text: string };
184
+ /** `data` is base64. */
185
+ type ImageBlock = { type: "image"; data: string; mimeType: string };
186
+ ```
187
+
188
+ Show generated images with `image(block)`. Do not print `data` with `text()`, `console`, or `return`: it is large and the model cannot read it as text. Generated images are not saved to disk; to keep one, write it to a file with a tool.
189
+
190
+ ```js
191
+ // @options: {"timeout_ms": 300000}
192
+ const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
193
+ const result = await models.generateImages(painter, {
194
+ input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
195
+ });
196
+ if (result.stopReason !== "stop") return result.errorMessage;
197
+ for (const block of result.output) {
198
+ if (block.type === "image") image(block);
199
+ else text(block.text);
200
+ }
201
+ ```
202
+
203
+ ## Limits
204
+
205
+ - A script's VM has 256 MB of memory. Running out throws `InternalError: out of memory`; filter or aggregate large data instead of accumulating it.
206
+ - A script that waits on a promise that can never settle (no tool call pending) fails immediately, since there are no timers.
207
+ - Scripts cannot start other `codemode` scripts.
@@ -614,3 +614,47 @@ interface ProviderModelConfig {
614
614
  `openrouter` sends `reasoning: { effort }`. `deepseek` sends `thinking: { type: "enabled" | "disabled" }` and `reasoning_effort` when enabled. `together` sends `reasoning: { enabled }` and also `reasoning_effort` when `supportsReasoningEffort` is enabled. `qwen` is for DashScope-style top-level `enable_thinking`. Use `qwen-chat-template` for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking` and need `preserve_thinking`. Use `chat-template` for configurable `chat_template_kwargs`, for example DeepSeek V3.x behind vLLM with `chatTemplateKwargs: { "thinking": { "$var": "thinking.enabled" } }`. Use `thinkingFormat: "baseten"` with `chatTemplateArgs` when the provider expects toggle values under `chat_template_args` and optionally supports top-level `reasoning_effort`.
615
615
  `thinkingTokenBudgetField` sends a clamped per-level thinking budget as a top-level request field (`thinking_token_budget` on vLLM, `thinking_budget` on Qwen/SGLang, `thinking_budget_tokens` on llama.cpp). `supportsThinkingTokenBudget: true` is an alias for the vLLM field name. Do not combine it with `reasoning_effort` on DashScope Qwen models.
616
616
  `cacheControlFormat: "anthropic"` applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content.
617
+
618
+ ## Image and classifier operations
619
+
620
+ Registering only `baseUrl` or `headers` for an existing provider preserves its built-in models. Supplying `models` in the legacy form replaces that provider's models across chat, image, and classifier operations. An omitted `type` means `"chat"`; image and classifier models require explicit discriminants and implementations keyed by their `api` values through the `images` and `classifiers` fields.
621
+
622
+ For example, a mixed-operation provider can register non-chat models and their implementations together:
623
+
624
+ ```typescript
625
+ pi.registerProvider("media-tools", {
626
+ apiKey: "$MEDIA_TOOLS_API_KEY",
627
+ models: [
628
+ {
629
+ type: "image",
630
+ id: "image-v1",
631
+ name: "Image V1",
632
+ api: "media-images",
633
+ baseUrl: "https://media.example.com/v1",
634
+ input: ["text"],
635
+ output: ["image"],
636
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
637
+ },
638
+ {
639
+ type: "classifier",
640
+ id: "classifier-v1",
641
+ name: "Classifier V1",
642
+ api: "media-classifier",
643
+ baseUrl: "https://media.example.com/v1",
644
+ input: ["text"],
645
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
646
+ contextWindow: 64000,
647
+ },
648
+ ],
649
+ images: {
650
+ "media-images": { generateImages: async (model, context, options) => result },
651
+ },
652
+ classifiers: {
653
+ "media-classifier": { classify: async (model, context, options) => result },
654
+ },
655
+ });
656
+ ```
657
+
658
+ Model-level `baseUrl` values take precedence over the provider endpoint. If no `models` list is supplied, built-in models of every operation remain registered. Equal model IDs in different operations remain distinct, including their model-specific headers.
659
+
660
+ Await `options.onProviderStreamEvent?.(providerEvent, model)` before normalizing each parsed stream event. Chat models need context and output limits; classifiers need a context window; image models declare output modalities. Legacy `refreshModels` returns a mixed-operation catalog.
package/docs/docs.json CHANGED
@@ -57,8 +57,8 @@
57
57
  "path": "bundled/README.md"
58
58
  },
59
59
  {
60
- "title": "Background",
61
- "path": "bundled/extensions/background.md"
60
+ "title": "Tasks",
61
+ "path": "bundled/tasks.md"
62
62
  },
63
63
  {
64
64
  "title": "BTW",
@@ -80,14 +80,6 @@
80
80
  "title": "Statusline",
81
81
  "path": "bundled/extensions/statusline.md"
82
82
  },
83
- {
84
- "title": "Subagent",
85
- "path": "bundled/extensions/subagent.md"
86
- },
87
- {
88
- "title": "Todo",
89
- "path": "bundled/extensions/todo.md"
90
- },
91
83
  {
92
84
  "title": "Web Search",
93
85
  "path": "bundled/extensions/web-search.md"
@@ -132,6 +124,18 @@
132
124
  {
133
125
  "title": "Custom Providers",
134
126
  "path": "custom-provider.md"
127
+ },
128
+ {
129
+ "title": "Codemode",
130
+ "path": "codemode.md"
131
+ },
132
+ {
133
+ "title": "MCP Servers",
134
+ "path": "mcp.md"
135
+ },
136
+ {
137
+ "title": "Virtual Models",
138
+ "path": "virtual-models.md"
135
139
  }
136
140
  ]
137
141
  },
@@ -95,6 +95,6 @@ These variables are read by Pi itself:
95
95
  | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
96
96
  | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
97
97
 
98
- Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
98
+ Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
99
99
 
100
100
  `PI_SERVER_DIR` and `PI_SERVER_ID` apply only to the source-only [experimental remote harness](development.md#experimental-remote-harness).
@@ -1152,104 +1152,48 @@ pi.on("tool_result", async (event, ctx) => {
1152
1152
  });
1153
1153
  ```
1154
1154
 
1155
- ### ctx.background
1155
+ ### ctx.tasks
1156
1156
 
1157
- Session-bound `BackgroundContext` for supervising shell tasks and whole Subagent invocations. The host owns execution lifetime; a tool can either wait for its final result or return a background reference. Check `ctx.background.enabled` before offering background work. Interactive mode enables it; ordinary SDK sessions and built-in print/JSON/RPC hosts leave it disabled. See [SDK host policy](sdk.md#background-execution) and [Background behavior](bundled/extensions/background.md).
1157
+ Session-bound `TasksContext` supervises native and extension-owned execution. Foreground work uses the same runtime even when background handoff is disabled. `ctx.tasks.enabled` tells whether this host permits handoff; interactive mode enables it. See [Tasks](bundled/tasks.md) and [SDK host policy](sdk.md#background-execution).
1158
1158
 
1159
- Public types are exported from `@astralyn/pi`: `BackgroundContext`, `BackgroundExecution<T>`, `BackgroundControl<T>`, `BackgroundCompletion<T>`, `BackgroundToolOutcome<T>`, `BackgroundTask`, `BackgroundRead`, `BackgroundProjection`, `BackgroundWorker`, `BackgroundWorkerReport`, `BackgroundText`, `BackgroundCompletionSnapshot`, `BackgroundKind`, `BackgroundMode`, `BackgroundStatus`, and `BackgroundTerminalStatus`.
1160
-
1161
- Use the optional projection in `control.publish(result, projection)` for portable presentation facts. `BackgroundText` is `{ text: string, truncated: boolean }`; record truncation where it happens instead of embedding a marker for the renderer to parse. Shell projections carry `shell: { name, output }`. Worker projections carry `id`, `label`, `profile`, `description`, observed `status`, `report`, optional `error`, plus `prompt`, `activity` and optional `model`/`usage` display strings. The host bounds each field, retaining at most eight workers, 40 KiB of shell output and 4 KiB per report.
1162
-
1163
- Automatic completions persist a terminal `BackgroundCompletionSnapshot` in message `details`, independently of the tool's private result details. Completion workers omit live prompt/activity/model/usage fields, and display metadata is never billed. The host generates bounded model prose from the same facts; renderers read the structured snapshot. Executors without a projection get a bounded plain result fallback. See [Background records](session-format.md#background-records) for the complete format and replay rules.
1164
-
1165
- | Member | Contract |
1159
+ | Method | Contract |
1166
1160
  |---|---|
1167
- | `enabled` | Whether this runtime/role permits managed execution |
1168
- | `execute<T>(execution)` | Returns `Promise<BackgroundToolOutcome<T>>`: `{ kind: "result", result }` or `{ kind: "background", task }` |
1169
- | `list()` / `get(id)` | Serializable retained `BackgroundTask` snapshots, not live handles |
1170
- | `read(id, options?)` | Bounded `BackgroundRead` with `task`, `text`, `totalBytes`, `truncated`, optional `fromByte` and `readError`; options: `mode`, `bytes`, `sinceBytes` |
1171
- | `wait(id, timeoutMs?, signal?)` | Bounded observational wait (default 20s, maximum 60s); expiry/abort does not kill execution, and returning a terminal snapshot does not itself acknowledge model delivery |
1172
- | `kill(id)` | Requests cancellation of one task or whole group; returns whether a new request was made |
1173
- | `subscribe(listener)` | Observation only; returns an `off()` function |
1174
- | `pin(id)` | Temporarily defers retained-record eviction; returns an idempotent release function |
1175
-
1176
- `BackgroundExecution<T>` supplies `kind` (`"bash"` or `"subagent"`), `title`, `toolCallId`, optional `command`, `cwd`, `background`, `signal`, `onUpdate`, and `run(control)`. This is supervision, not a generic executor registry: the extension still implements its own domain execution. `run` returns `{ result, status?, error?, usage? }`. Optional `error` is a bounded terminal diagnostic kept independently of log slices; optional `usage` is authoritative cumulative usage. Explicit terminal statuses are `completed`, `partial`, `failed`, `cancelled`, or `timeout`. Status and foreground/background mode are separate dimensions.
1177
-
1178
- Inside `run`, perform whole-invocation preflight, then call **`control.accept()`** before a handoff can return. Start no partial worker batch on failed preflight. Use **`control.signal`**, not the original parent signal, for ongoing work; detach releases the parent wait/cancellation link without restarting execution. `control.publish(result, projection?)` updates observers and forwards foreground progress only while the caller still waits. `control.setOutputPath(path, cleanup?)` registers one exclusively created, executor-owned output file. Never register a shared or pre-existing path. The optional cleanup callback must close its writer before removing only that file; the host invokes it on record eviction or runtime shutdown. A saved path is not a durable attachment. `control.id` and `control.mode` identify the execution and its current wait mode.
1179
-
1180
- Minimal supervised tool (a bounded result, no persistent log):
1181
-
1182
- ```typescript
1183
- import type { ExtensionAPI } from "@astralyn/pi";
1184
- import { truncateHead } from "@astralyn/pi";
1185
- import { Type } from "typebox";
1186
-
1187
- export default function (pi: ExtensionAPI) {
1188
- pi.registerTool({
1189
- name: "git_status_task",
1190
- label: "Git status task",
1191
- description: "Read Git status through the session Background host",
1192
- parameters: Type.Object({ background: Type.Optional(Type.Boolean()) }),
1193
- async execute(toolCallId, params, signal, onUpdate, ctx) {
1194
- if (!ctx.background.enabled) throw new Error("This tool requires an enabled Background host");
1195
- const outcome = await ctx.background.execute({
1196
- kind: "bash",
1197
- title: "Git status",
1198
- toolCallId,
1199
- background: params.background,
1200
- signal,
1201
- onUpdate,
1202
- async run(control) {
1203
- control.signal.throwIfAborted();
1204
- // All fixed-input preflight is complete; allow handoff.
1205
- control.accept();
1206
- const command = await pi.exec("git", ["status", "--short"], {
1207
- cwd: ctx.cwd,
1208
- signal: control.signal,
1209
- timeout: 10_000,
1210
- });
1211
- return {
1212
- status: command.code === 0 ? "completed" : "failed",
1213
- result: {
1214
- content: [{ type: "text", text: truncateHead(command.stdout + command.stderr).content }],
1215
- details: {},
1216
- },
1217
- };
1218
- },
1219
- });
1220
- if (outcome.kind === "result") return outcome.result;
1221
- return {
1222
- content: [{ type: "text", text: `Accepted: ${outcome.task.id}; use bg to read, wait, or stop.` }],
1223
- details: { taskId: outcome.task.id },
1224
- };
1225
- },
1226
- });
1227
- }
1228
- ```
1229
-
1230
- Return nested LLM `usage` on the completion (`completion.usage` or `completion.result.usage`), not on the submission reference. `completion.usage` takes precedence over result usage, which takes precedence over published partial usage. When publishing partial results, supply cumulative usage accrued by the whole execution, not per-update deltas; the latest published usage is the fallback if execution rejects without a final result. Include retries, failures, cancellation and provider-supplied worker compaction usage, but do not fabricate missing provider usage. The host persists independent usage once and removes it from the managed foreground return, so do not add it back or charge again from a notification/read. Keep results and projections bounded and serializable; never put SDK sessions, processes, abort controllers, functions, or timers into snapshot details. Shell commands should normally use the native Bash/PowerShell tool, which also preserves shell settings, session environment, output limits, and process-tree cleanup.
1231
-
1232
- A read can fall back to the stored bounded result when the log is unreadable or expired. Inspect `readError` separately from `text`, `fromByte` and `totalBytes`: a diagnostic is not log data and must not be hidden by byte-offset paging. Read failure does not turn a completed execution into a failed one.
1233
-
1234
- Subscriptions and pins have a lifetime independent of tool waiting. Release them when the view closes or the extension shuts down; capture only cleanup functions, not an old session context for later use:
1235
-
1236
- ```typescript
1237
- let off: (() => void) | undefined;
1238
- pi.on("session_start", (_event, ctx) => {
1239
- off?.();
1240
- const background = ctx.background;
1241
- off = background.subscribe(() => {
1242
- // Read snapshots or invalidate a visible view; do not inject progress messages.
1243
- background.list();
1244
- });
1245
- });
1246
- pi.on("session_shutdown", () => {
1247
- off?.();
1248
- off = undefined;
1161
+ | `execute<T>(execution)` | Returns `{ kind: "result", result, status?, error? }` or `{ kind: "background", task }` |
1162
+ | `list()` / `get(id)` | Bounded, read-only (frozen) retained snapshots; IDs support unique prefixes |
1163
+ | `read(id, options?)` | Bounded head, tail, or byte-offset output |
1164
+ | `wait(id, timeoutMs?, signal?)` | Observation only; timeout or cancellation ends the wait, not execution |
1165
+ | `kill(id)` | Requests cancellation; `stopping` is not a terminal status |
1166
+ | `detach(id)` / `detachForeground()` | Hands off one task, or eligible foreground tasks oldest first while background slots remain, without restarting them; throws when every background slot is taken |
1167
+ | `subscribe(listener)` | Observes task state and progress |
1168
+ | `retain(id)` | Returns an idempotent release function protecting retained data, without delaying notifications |
1169
+ | `holdDelivery(id)` | Explicitly retains data and delays automatic delivery until released |
1170
+
1171
+ `TaskExecution<T>` supplies `kind`, `title`, `toolCallId`, `run(control)`, optional `command`, `cwd`, `background`, `signal`, and `onUpdate`. `kind` is an executor-owned source label matching `[a-z][a-z0-9-]{0,63}`; the runtime never dispatches on it. At most eight background executions run at once; foreground executions are not limited by them. Foreground and background results have separate history quotas.
1172
+
1173
+ `run` returns `TaskCompletion<T>`: `{ result, status?, error?, exitCode?, usage? }`. The original tool result is returned to a foreground caller; private `result.details` is not copied into task history. Explicit terminal statuses are `completed`, `partial`, `failed`, `cancelled`, and `timeout`. Usage is settled by the host once; managed foreground results omit usage to avoid billing it twice.
1174
+
1175
+ `TaskControl<T>` exposes `id`, `signal`, `mode`, `accept()`, `publish(result)`, `setOutputPath(path, cleanup?)`, `onModeChange(listener)`, and `requestCancel()`. `publish` replaces the task's bounded text result, which the `/tasks` panel, `tasks read`, and the completion notification show; a task with an output path is read from that log instead. Call `accept()` after whole-invocation preflight, before allowing a background handoff. Use the control's signal throughout execution. Parent-call cancellation is disconnected after handoff, while runtime shutdown still cancels the task. Mode subscriptions concern only this task; executors do not need the global registry to observe their own handoff or cancel themselves.
1176
+
1177
+ Completion messages store a self-contained `TaskCompletionSnapshot`; only their bounded `content` enters model context. Built-in `tasks wait` binds delivery to the actual tool call, and the host confirms it after successful persistence. Ordinary extension reads/waits do not acknowledge delivery, and arbitrary tool-result detail fields cannot acknowledge a task.
1178
+
1179
+ ```typescript
1180
+ const outcome = await ctx.tasks.execute({
1181
+ kind: "report-job",
1182
+ title: "Inspect project",
1183
+ toolCallId,
1184
+ signal,
1185
+ background: params.background,
1186
+ async run(control) {
1187
+ control.accept();
1188
+ const report = await inspectProject(control.signal);
1189
+ return { result: { content: [{ type: "text", text: report }], details: undefined } };
1190
+ },
1249
1191
  });
1192
+ if (outcome.kind === "result") return outcome.result;
1193
+ return { content: [{ type: "text", text: `Task ${outcome.task.id} continues in the background.` }], details: undefined };
1250
1194
  ```
1251
1195
 
1252
- Captured capabilities belong to one runtime. Reload/replacement closes old execution admission and cancels its work; obtain a fresh `ctx.background` on the new `session_start`. A pin does not keep a runtime alive. A worker role cannot enable background execution even if its model supplies `background: true`; built-in workers also receive a no-background prompt rule. This is not an OS sandbox or a daemon, and persisted snapshots do not resume execution.
1196
+ `TaskRuntime`, `TaskRuntimeOptions`, and the public `Task*`/`TasksContext` types are exported from `@astralyn/pi`. Captured capabilities close with their runtime; obtain the replacement from the new session context after reload or session replacement.
1253
1197
 
1254
1198
  ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
1255
1199
 
@@ -2277,7 +2221,7 @@ pi.registerTool(myTool);
2277
2221
 
2278
2222
  **Constrained sampling:** `constrainedSampling: { type: "json_schema", strict: "prefer" }` requests provider-side schema enforcement when the active provider supports it, otherwise normal tool calling is used. Use `strict: "require"` only when the request should fail on unsupported providers. For provider-specific grammars, use `{ type: "grammar", variants: { openai_lark: "...", openai_regex: "..." } }`; each variant is optional, and unsupported providers fall back to normal function tools. `constrainedSampling: false` explicitly opts out (the same behavior as omitting it).
2279
2223
 
2280
- **Usage accounting:** For unmanaged tools, if a tool makes nested LLM calls, return their combined `Usage` as `usage`. Pi persists it on the tool result and includes it in footer, `/session`, and RPC session totals. `tool_result` handlers can inspect or replace this value. Managed executions instead settle usage independently through [`ctx.background`](#ctxbackground); do not duplicate it on the handoff or managed foreground result.
2224
+ **Usage accounting:** For unmanaged tools, if a tool makes nested LLM calls, return their combined `Usage` as `usage`. Pi persists it on the tool result and includes it in footer, `/session`, and RPC session totals. `tool_result` handlers can inspect or replace this value. Managed executions instead settle usage independently through [`ctx.tasks`](#ctxtasks); do not duplicate it on the handoff or managed foreground result.
2281
2225
 
2282
2226
  **Signaling errors:** To mark a tool execution as failed (sets `isError: true` on the result and reports it to the LLM), throw an error from `execute`. Returning a value never sets the error flag regardless of what properties you include in the return object.
2283
2227
 
@@ -3254,3 +3198,60 @@ Use `ctx.mode === "tui"` before TUI-specific features (`custom()`, component fac
3254
3198
  ## Examples
3255
3199
 
3256
3200
  The complete, maintained catalog is [examples/extensions/README.md](../examples/extensions/README.md). Use it to find a focused starting point by capability.
3201
+
3202
+ ## Tool orchestration
3203
+
3204
+ Declare `outputSchema` and return a matching `structuredContent` when the result is data. The model still receives `content`; programmatic callers such as codemode scripts receive `structuredContent` instead of the text. Tools without `outputSchema` are passed to scripts as their text content. To report a failure that still carries data, return the result with `isError: true` instead of throwing: the model sees an error, and scripts still receive `structuredContent`.
3205
+
3206
+ A tool can run other tools with `ctx.executeTool(name, args, { signal, onUpdate })`. Nested calls go through argument validation and the `tool_call` and `tool_result` handlers like model-issued calls, and emit `tool_execution_start`, `tool_execution_update`, and `tool_execution_end`; all of these events carry `parentToolCallId`, and their `toolCallId` is assigned by pi as `<parent id>/<n>`. These ids do not appear as tool calls or tool results in the transcript. Nested calls do not add transcript entries: their results only reach the calling tool, which reports them itself, for example through `onUpdate` and `details`. The session keeps a bounded record of them (name, arguments, status, duration, error; never results) as `nestedCalls` on the calling tool's result message. It is used for compaction file lists and shown in HTML exports. Arguments over 8 KiB per call or 32 KiB per tool result are omitted, at most 256 calls are kept, and `complete: false` marks a record that lost anything. The `usage` of nested results, at every depth, is added to the calling tool's result `usage`, so a tool reports only its own usage, not that of the tools it called. `ctx.tools` lists the tools `ctx.executeTool()` can call. `tool_result` handlers that redact `content` should also replace `structuredContent`; replacing only `content` drops it.
3207
+
3208
+ ### Tool exposure
3209
+
3210
+ `exposure` controls how the model reaches a tool. "Callable" means callable from other tools through `ctx.executeTool()` (`ctx.tools`), as the `codemode` tool's scripts do:
3211
+
3212
+ - `direct` (default): declared to the model while active, and callable while active.
3213
+ - `model-only`: declared to the model while active, never callable. Use it for tools that orchestrate other tools or ask the user.
3214
+ - `codemode`: callable whenever registered, and listed by the `codemode` tool. Not declared to the model unless activated explicitly.
3215
+ - `deferred`: like `codemode`, but codemode tools do not list it; `tool_search` can find and activate it.
3216
+ - `hidden`: registered but unreachable. Re-register a tool with `exposure: "hidden"` to withdraw it, since tools cannot be unregistered.
3217
+
3218
+ `namespace: { name, description, instructions }` groups related tools, as MCP servers do. Codemode tools list a namespace under one heading with its `description`. `instructions` holds longer usage guidance; it is not listed, and codemode scripts read it with `describeNamespace(name)`.
3219
+
3220
+ Registering a `direct` or `model-only` tool activates it; the other exposures are not activated on registration. The active set (`pi.getActiveTools()`, `pi.setActiveTools()`) is the set of tools declared to the model. `pi.getAllTools()` reports each tool's `exposure`, `namespace`, and `annotations`.
3221
+
3222
+ `annotations` are hints about what a tool does, with the meaning of MCP tool annotations: `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint`. MCP tools carry the hints their server declares. Missing hints take the MCP defaults: a tool is not read-only, and may be destructive and reach an open world. The hints are not verified, but a permission extension can use them to decide which calls to confirm. This confirms the calls Codex asks approval for:
3223
+
3224
+ ```typescript
3225
+ pi.on("tool_call", async (event, ctx) => {
3226
+ const hints = pi.getAllTools().find((tool) => tool.name === event.toolName)?.annotations;
3227
+ const needsApproval =
3228
+ hints?.destructiveHint === true ||
3229
+ (!hints?.readOnlyHint && ((hints?.destructiveHint ?? true) || (hints?.openWorldHint ?? true)));
3230
+ if (needsApproval && !(await ctx.ui.confirm("Allow tool call?", event.toolName))) {
3231
+ return { block: true, reason: `${event.toolName} was not approved` };
3232
+ }
3233
+ });
3234
+ ```
3235
+
3236
+ A tool that orchestrates other tools can adjust what the model sees while it is active with `prepareLoadout(loadout)`. It runs whenever the active tools change and receives the declared tools, the callable tools, and every registered tool with its exposure and namespace. It returns replacement `descriptions` for declared tools (including its own) and `hiddenDeclarations`: active tools whose declarations requests leave out while they stay active and callable. `codemode` uses only this hook, `exposure`, and `ctx.executeTool()`, so another tool can implement the same behavior under a different name.
3237
+
3238
+ ### MCP servers
3239
+
3240
+ `pi.registerMcpServer(name, config)` adds an MCP server for the current session. `config` has the shape of an `mcpServers` entry in [`mcp.json`](mcp.md): `command`, `args`, `env`, and `cwd` for stdio servers, `url`, `headers`, and `oauth` for HTTP servers, plus `exposure`, `toolExposure`, `description`, `enabled`, and `timeout`.
3241
+
3242
+ ```typescript
3243
+ pi.registerMcpServer("jira", { url: "https://mcp.example.com/jira", exposure: "codemode" });
3244
+ pi.unregisterMcpServer("jira");
3245
+ ```
3246
+
3247
+ Servers registered while the extension loads connect when the session starts, together with the `mcp.json` servers; servers registered later connect right away, and `pi.unregisterMcpServer()` closes the connection and makes the server's tools unreachable. Registrations are not saved: register again on every load, for example based on the extension's own settings. A server in `mcp.json` with the same name takes precedence, and `/mcp` shows the override. Registering the same name again replaces the extension's earlier registration; names registered by another extension, invalid names, and invalid configs throw.
3248
+
3249
+ The built-in MCP support connects registered servers. When nothing does, because another extension replaced it (see [MCP](mcp.md#other-mcp-extensions)), each registration is reported as an extension error. Other MCP extensions can connect registered servers too: read them with `pi.getMcpServers()` on `session_start` and handle the `mcp_servers_change` event for later changes.
3250
+
3251
+ ### Provider stream events
3252
+
3253
+ <a id="provider_stream_event"></a>
3254
+
3255
+ `provider_stream_event` fires for each parsed provider stream event before Pi normalizes it. The event identifies the provider, API, and model; `event.data` is the earliest structured value available to Pi, not necessarily the original HTTP bytes or SSE frame. Treat it as read-only because mutation can affect normalization. The event is notification-only and is not persisted.
3256
+
3257
+ Handlers are awaited in stream order, so slow handlers delay stream consumption. Handler errors are reported without changing the provider response. See [`debug-provider.ts`](../examples/extensions/debug-provider.ts) for an opt-in viewer that groups raw events by assistant message.
package/docs/index.md CHANGED
@@ -16,7 +16,8 @@ A task-oriented map for the installed package.
16
16
 
17
17
  ## Bundled package features
18
18
 
19
- - [Bundled features overview](bundled/README.md) — the complete shipped-feature and extension catalog.
19
+ - [Bundled features overview](bundled/README.md) — upstream Pi features and distribution-maintained additions.
20
+ - [llama.cpp](llama-cpp.md), [Codemode](usage.md#enable-codemode), [MCP](mcp.md), and [Tool search](usage.md#tool-search) — official upstream extensions included in this package.
20
21
 
21
22
  ## Customize and integrate
22
23
 
@@ -128,14 +128,22 @@ This routing remains configurable through the ordinary action bindings. For exam
128
128
  | `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
129
129
  | `app.editor.external` | `ctrl+g` | Open in external editor (`externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere) |
130
130
  | `app.clipboard.pasteImage` | `ctrl+v` (`alt+v` on Windows and WSL) | Paste image or text from clipboard |
131
- | `app.backgroundTasks.detach` | `ctrl+b` | Move all eligible current foreground shell tasks and Subagent groups to the background |
132
- | `app.backgroundTasks.focusList` | `left` | Focus the task list in `/bg` |
133
- | `app.backgroundTasks.focusPreview` | `right` | Focus the selected preview in `/bg` |
134
- | `app.backgroundTasks.kill` | `k` | Ask to stop the selected shell task or whole Subagent group in `/bg` (confirmed with `y`) |
135
-
136
- In `/bg`, Up/Down and Page Up/Page Down target the focused pane: row selection/list paging or preview scrolling/paging. Enter focuses the preview; Escape returns to the list before closing. Left/Right focus controls can be rebound independently of editor cursor actions. List paging uses `tui.select.pageUp`/`pageDown`; preview paging uses `tui.editor.pageUp`/`pageDown` (including their default Ctrl+Page Up/Down aliases).
137
-
138
- Ctrl+B also works while `/bg` owns focus. It does not restart execution, reset shell timeouts, detach individual workers, or affect user `!` commands. With no eligible work it only reports that nothing can be moved. See [Background tasks](bundled/extensions/background.md).
131
+ | `app.tasks.detach` | `ctrl+b` | Move all eligible current foreground managed tasks to the background |
132
+ | `app.tasks.nextFocus` | `tab` | Switch between task list and inspector |
133
+ | `app.tasks.previousFocus` | `shift+tab` | Switch between task inspector and list |
134
+ | `app.tasks.previousTab` | `left` | Show Output while the inspector has focus |
135
+ | `app.tasks.nextTab` | `right` | Show Details while the inspector has focus |
136
+ | `app.tasks.search` | `/` | Locate a retained task; Enter chooses, Escape restores selection |
137
+ | `app.tasks.follow` | `f` | Follow latest or final output while Output has focus |
138
+ | `app.tasks.top` / `app.tasks.bottom` | `home` / `end` | Beginning / end of the focused list or content |
139
+ | `app.tasks.kill` | `k` | Ask to stop the selected ongoing task |
140
+ | `app.tasks.confirmStop` | `enter` | Confirm stopping the task named in the confirmation |
141
+ | `app.tasks.detachSelected` | `b` | Move only the selected foreground task to the background |
142
+ | `app.tasks.help` | `?` | Show task controls |
143
+
144
+ In `/tasks`, Tab switches between two panes and preserves the inspector's Output/Details tab. Left/Right only change that tab while the inspector has focus. Up/Down and Page Up/Page Down select tasks or scroll the focused content. Escape closes the current search, help or confirmation first, and otherwise closes the panel from either pane. Narrow terminals use the same rules. List paging uses `tui.select.pageUp`/`pageDown`; inspector paging uses `tui.editor.pageUp`/`pageDown` (including their default Ctrl+Page Up/Down aliases).
145
+
146
+ Ctrl+B also works while `/tasks` owns focus. It does not restart execution, reset shell timeouts, or affect user `!` commands. With no eligible work the key falls through to other bindings. See [Background tasks](bundled/tasks.md).
139
147
 
140
148
  ### Question Details
141
149
 
@@ -254,7 +262,7 @@ Disable the detach action before restoring Ctrl+B as cursor-left (or rebind deta
254
262
  {
255
263
  "tui.editor.historyPrevious": "ctrl+p",
256
264
  "tui.editor.historyNext": "ctrl+n",
257
- "app.backgroundTasks.detach": [],
265
+ "app.tasks.detach": [],
258
266
  "tui.editor.cursorLeft": ["left", "ctrl+b"],
259
267
  "tui.editor.cursorRight": ["right", "ctrl+f"],
260
268
  "tui.editor.cursorWordLeft": ["alt+left", "alt+b"],
package/docs/llama-cpp.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # llama.cpp
2
2
 
3
- Pi supports the [llama.cpp](https://github.com/ggml-org/llama.cpp) router server. The router discovers multiple GGUF models and loads or unloads them on demand.
3
+ The llama.cpp integration is provided by [upstream Pi](https://github.com/earendil-works/pi) and included in `@astralyn/pi`. It supports the [llama.cpp](https://github.com/ggml-org/llama.cpp) router server, which discovers multiple GGUF models and loads or unloads them on demand.
4
4
 
5
5
  Use a current llama.cpp build with router support. Follow the [build instructions](https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md) or install a [prebuilt release](https://github.com/ggml-org/llama.cpp/releases) for your platform.
6
6
 
@@ -99,3 +99,14 @@ curl http://127.0.0.1:8080/models
99
99
  - **Model missing from `/model`:** Load it with `/llama` first and wait for loading to finish. Idle-sleeping models remain selectable.
100
100
  - **Load fails or uses too much memory:** Lower `-c` or unload another model.
101
101
  - **Server is not in router mode:** Start it without `--model`, `-m`, or `-hf`.
102
+
103
+ ## Classification
104
+
105
+ Every model listed for chat is also listed as a classifier model with the same ID and the `llama-cpp-classify` API. Classifier models answer typed `choice`, `bool`, and `score` questions about JSON state, like TypeSafe's Jev models. The model reaches them from [`codemode`](usage.md#enable-codemode) scripts, and extensions through `ctx.modelRegistry.classify()`; see [Classifier models](models.md#use-classifier-models).
106
+
107
+ The model does not generate an answer. Each question becomes one chat prompt: the state, every question of the request, the state again, and then the question with its answers under single-token labels. Labels are letters for a choice (up to 62 options), `Yes`/`No` for a bool, and digits for a score (up to 10 levels). The second copy of the state is read with the questions in view, which improved accuracy on JevBench with small models. Pi reads the probabilities of the labels as the next token and normalizes them. A choice returns every option's probability and a confidence of `(n * peak - 1) / (n - 1)`; a score returns the expected level.
108
+
109
+ - Raw label probabilities are usually overconfident. The per-request `temperature` option divides the label logits before normalizing; values above 1 soften the distribution. It changes no answer.
110
+ - Questions run one after another. Everything before the final question is the same for all questions of a request, so the server's prompt cache evaluates it once. The state appears twice, so it needs twice its size in context.
111
+ - Small models may follow instructions written inside the state. The prompt tells the model to judge the state as data, but that is not a guarantee.
112
+ - Hybrid models such as Qwen3.5 cannot rewind a partially cached prompt without context checkpoints. If each question reprocesses the whole state, start the router with `--ctx-checkpoints 32 --checkpoint-min-step 0`.