@astralyn/pi 1.4.11 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (564) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/dist/bundle/chunks/anthropic-messages-G5ZGBHOH.js +6 -0
  3. package/dist/bundle/chunks/azure-openai-responses-EMPTMYNF.js +2 -0
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +22 -15
  5. package/dist/bundle/chunks/{chunk-TH3QDDPD.js → chunk-3YGNXVKM.js} +1 -1
  6. package/dist/bundle/chunks/chunk-AXX7FFFD.js +2 -0
  7. package/dist/bundle/chunks/chunk-FNGB3ASD.js +2 -0
  8. package/dist/bundle/chunks/chunk-FPALVF3F.js +4 -0
  9. package/dist/bundle/chunks/chunk-H3UF54OB.js +9 -0
  10. package/dist/bundle/chunks/{chunk-NUQMVNKQ.js → chunk-HLVMLRZJ.js} +58 -62
  11. package/dist/bundle/chunks/chunk-IC6JXX2J.js +10 -0
  12. package/dist/bundle/chunks/{chunk-MZJC45TM.js → chunk-J7L6O5XA.js} +3 -3
  13. package/dist/bundle/chunks/{chunk-DLVLAQEG.js → chunk-KBFO53OG.js} +3 -3
  14. package/dist/bundle/chunks/chunk-M3D4ADUT.js +1503 -0
  15. package/dist/bundle/chunks/{chunk-TPVFPFJP.js → chunk-P7VXFB2M.js} +1 -1
  16. package/dist/bundle/chunks/chunk-PSYLMRL6.js +9 -0
  17. package/dist/bundle/chunks/chunk-QNZARXLE.js +82 -0
  18. package/dist/bundle/chunks/chunk-RAIYJ5FC.js +4 -0
  19. package/dist/bundle/chunks/{chunk-OV2VMHBX.js → chunk-SR6EWNPW.js} +1 -1
  20. package/dist/bundle/chunks/chunk-TA3YH2ZI.js +16 -0
  21. package/dist/bundle/chunks/{chunk-24FY4C5S.js → chunk-TRSJS3FM.js} +1 -1
  22. package/dist/bundle/chunks/chunk-ZRI3ICDE.js +2 -0
  23. package/dist/bundle/chunks/{cli-MBFCFGI2.js → cli-LAZQG54B.js} +11 -9
  24. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-7BKATOEJ.js → cloudflare-workers-ai-system-one-4L2ABUJE.js} +1 -1
  25. package/dist/bundle/chunks/{execute-VLAIP26K.js → execute-SSRW6NGS.js} +1 -1
  26. package/dist/bundle/chunks/github-copilot.js +1 -1
  27. package/dist/bundle/chunks/{google-generative-ai-HTUSU45F.js → google-generative-ai-OOVDGS5W.js} +1 -1
  28. package/dist/bundle/chunks/{google-vertex-AVQV4P76.js → google-vertex-IK5RNG7J.js} +1 -1
  29. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  30. package/dist/bundle/chunks/kimi-coding.js +1 -1
  31. package/dist/bundle/chunks/{llama-cpp-classify-27QYLJZY.js → llama-cpp-classify-XHAVT37C.js} +1 -1
  32. package/dist/bundle/chunks/meta.js +1 -1
  33. package/dist/bundle/chunks/mistral-conversations-Z56KY4OJ.js +5 -0
  34. package/dist/bundle/chunks/{openai-codex-responses-Q25MHDFX.js → openai-codex-responses-5NAH3SK6.js} +1 -1
  35. package/dist/bundle/chunks/openai-completions-S7S6PO3J.js +7 -0
  36. package/dist/bundle/chunks/{openai-decisions-3WYFPGSK.js → openai-decisions-7A36EAHE.js} +1 -1
  37. package/dist/bundle/chunks/{openai-responses-E4BNZIQK.js → openai-responses-ZQRZJKH4.js} +1 -1
  38. package/dist/bundle/chunks/{openrouter-images-CBP3OPOD.js → openrouter-images-X7PX72ON.js} +1 -1
  39. package/dist/bundle/chunks/pi-messages-TXNWPLI4.js +8 -0
  40. package/dist/bundle/chunks/radius.js +1 -1
  41. package/dist/bundle/chunks/{runtime-3RPOJS5T.js → runtime-X3XOMNXQ.js} +1 -1
  42. package/dist/bundle/chunks/{typesafe-system-one-BNICP2LS.js → typesafe-system-one-XJGMSHWL.js} +1 -1
  43. package/dist/bundle/chunks/virtual-modules-NFDW2JKH.js +2 -0
  44. package/dist/bundle/cli.js +1 -1
  45. package/dist/bundle/index.js +1 -1
  46. package/dist/bundle/rpc-entry.js +1 -1
  47. package/dist/cli/args.d.ts.map +1 -1
  48. package/dist/cli/args.js +8 -7
  49. package/dist/cli/args.js.map +1 -1
  50. package/dist/config.d.ts +10 -0
  51. package/dist/config.d.ts.map +1 -1
  52. package/dist/config.js +24 -5
  53. package/dist/config.js.map +1 -1
  54. package/dist/core/agent-session-runtime.d.ts +0 -5
  55. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  56. package/dist/core/agent-session-runtime.js +12 -28
  57. package/dist/core/agent-session-runtime.js.map +1 -1
  58. package/dist/core/agent-session.d.ts +21 -14
  59. package/dist/core/agent-session.d.ts.map +1 -1
  60. package/dist/core/agent-session.js +67 -93
  61. package/dist/core/agent-session.js.map +1 -1
  62. package/dist/core/compaction/branch-summarization.d.ts +4 -2
  63. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  64. package/dist/core/compaction/branch-summarization.js +16 -4
  65. package/dist/core/compaction/branch-summarization.js.map +1 -1
  66. package/dist/core/exec.d.ts +9 -1
  67. package/dist/core/exec.d.ts.map +1 -1
  68. package/dist/core/exec.js +104 -60
  69. package/dist/core/exec.js.map +1 -1
  70. package/dist/core/export-html/template.css +9 -0
  71. package/dist/core/export-html/template.js +165 -45
  72. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  73. package/dist/core/export-html/tool-renderer.js +5 -0
  74. package/dist/core/export-html/tool-renderer.js.map +1 -1
  75. package/dist/core/extensions/index.d.ts +1 -1
  76. package/dist/core/extensions/index.d.ts.map +1 -1
  77. package/dist/core/extensions/index.js.map +1 -1
  78. package/dist/core/extensions/loader.d.ts.map +1 -1
  79. package/dist/core/extensions/loader.js +7 -6
  80. package/dist/core/extensions/loader.js.map +1 -1
  81. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  82. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  83. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  84. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  85. package/dist/core/extensions/runner.d.ts +0 -1
  86. package/dist/core/extensions/runner.d.ts.map +1 -1
  87. package/dist/core/extensions/runner.js +7 -12
  88. package/dist/core/extensions/runner.js.map +1 -1
  89. package/dist/core/extensions/types.d.ts +41 -23
  90. package/dist/core/extensions/types.d.ts.map +1 -1
  91. package/dist/core/extensions/types.js.map +1 -1
  92. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  93. package/dist/core/extensions/virtual-modules.js +8 -7
  94. package/dist/core/extensions/virtual-modules.js.map +1 -1
  95. package/dist/core/mcp-servers.d.ts +11 -4
  96. package/dist/core/mcp-servers.d.ts.map +1 -1
  97. package/dist/core/mcp-servers.js +15 -5
  98. package/dist/core/mcp-servers.js.map +1 -1
  99. package/dist/core/model-config.d.ts +1678 -2029
  100. package/dist/core/model-config.d.ts.map +1 -1
  101. package/dist/core/model-config.js +2 -3
  102. package/dist/core/model-config.js.map +1 -1
  103. package/dist/core/model-resolver.d.ts.map +1 -1
  104. package/dist/core/model-resolver.js +16 -10
  105. package/dist/core/model-resolver.js.map +1 -1
  106. package/dist/core/package-manager.d.ts +14 -0
  107. package/dist/core/package-manager.d.ts.map +1 -1
  108. package/dist/core/package-manager.js +160 -46
  109. package/dist/core/package-manager.js.map +1 -1
  110. package/dist/core/pi-ai-schemas.d.ts +163 -0
  111. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  112. package/dist/core/pi-ai-schemas.js +21 -0
  113. package/dist/core/pi-ai-schemas.js.map +1 -0
  114. package/dist/core/pi-manifest.d.ts +1 -0
  115. package/dist/core/pi-manifest.d.ts.map +1 -1
  116. package/dist/core/pi-manifest.js +4 -0
  117. package/dist/core/pi-manifest.js.map +1 -1
  118. package/dist/core/project-trust.js +1 -1
  119. package/dist/core/project-trust.js.map +1 -1
  120. package/dist/core/quiescence.d.ts +24 -0
  121. package/dist/core/quiescence.d.ts.map +1 -0
  122. package/dist/core/quiescence.js +81 -0
  123. package/dist/core/quiescence.js.map +1 -0
  124. package/dist/core/resource-loader.d.ts +4 -1
  125. package/dist/core/resource-loader.d.ts.map +1 -1
  126. package/dist/core/resource-loader.js +41 -28
  127. package/dist/core/resource-loader.js.map +1 -1
  128. package/dist/core/sdk.d.ts.map +1 -1
  129. package/dist/core/sdk.js +3 -1
  130. package/dist/core/sdk.js.map +1 -1
  131. package/dist/core/session-manager.d.ts +7 -0
  132. package/dist/core/session-manager.d.ts.map +1 -1
  133. package/dist/core/session-manager.js +32 -13
  134. package/dist/core/session-manager.js.map +1 -1
  135. package/dist/core/settings-manager.d.ts +2 -0
  136. package/dist/core/settings-manager.d.ts.map +1 -1
  137. package/dist/core/settings-manager.js +11 -0
  138. package/dist/core/settings-manager.js.map +1 -1
  139. package/dist/core/settings-schema.d.ts +4 -2
  140. package/dist/core/settings-schema.d.ts.map +1 -1
  141. package/dist/core/settings-schema.js +8 -1
  142. package/dist/core/settings-schema.js.map +1 -1
  143. package/dist/core/skills.d.ts.map +1 -1
  144. package/dist/core/skills.js +6 -14
  145. package/dist/core/skills.js.map +1 -1
  146. package/dist/core/slash-command-name.d.ts +6 -0
  147. package/dist/core/slash-command-name.d.ts.map +1 -0
  148. package/dist/core/slash-command-name.js +11 -0
  149. package/dist/core/slash-command-name.js.map +1 -0
  150. package/dist/core/slash-commands.js +2 -2
  151. package/dist/core/slash-commands.js.map +1 -1
  152. package/dist/core/source-info.d.ts +9 -0
  153. package/dist/core/source-info.d.ts.map +1 -1
  154. package/dist/core/source-info.js +13 -0
  155. package/dist/core/source-info.js.map +1 -1
  156. package/dist/core/system-prompt.d.ts.map +1 -1
  157. package/dist/core/system-prompt.js +5 -6
  158. package/dist/core/system-prompt.js.map +1 -1
  159. package/dist/core/tasks/activity.d.ts +14 -0
  160. package/dist/core/tasks/activity.d.ts.map +1 -0
  161. package/dist/core/tasks/activity.js +58 -0
  162. package/dist/core/tasks/activity.js.map +1 -0
  163. package/dist/core/tasks/codec.d.ts +14 -0
  164. package/dist/core/tasks/codec.d.ts.map +1 -1
  165. package/dist/core/tasks/codec.js +57 -4
  166. package/dist/core/tasks/codec.js.map +1 -1
  167. package/dist/core/tasks/execution.d.ts.map +1 -1
  168. package/dist/core/tasks/execution.js +2 -2
  169. package/dist/core/tasks/execution.js.map +1 -1
  170. package/dist/core/tasks/output.d.ts +4 -1
  171. package/dist/core/tasks/output.d.ts.map +1 -1
  172. package/dist/core/tasks/output.js +33 -0
  173. package/dist/core/tasks/output.js.map +1 -1
  174. package/dist/core/tasks/record.d.ts +1 -7
  175. package/dist/core/tasks/record.d.ts.map +1 -1
  176. package/dist/core/tasks/record.js +0 -18
  177. package/dist/core/tasks/record.js.map +1 -1
  178. package/dist/core/tasks/reminder.d.ts +3 -2
  179. package/dist/core/tasks/reminder.d.ts.map +1 -1
  180. package/dist/core/tasks/reminder.js +4 -3
  181. package/dist/core/tasks/reminder.js.map +1 -1
  182. package/dist/core/tasks/runtime.d.ts +0 -2
  183. package/dist/core/tasks/runtime.d.ts.map +1 -1
  184. package/dist/core/tasks/runtime.js +2 -15
  185. package/dist/core/tasks/runtime.js.map +1 -1
  186. package/dist/core/tasks/session.d.ts +9 -2
  187. package/dist/core/tasks/session.d.ts.map +1 -1
  188. package/dist/core/tasks/session.js +23 -9
  189. package/dist/core/tasks/session.js.map +1 -1
  190. package/dist/core/tasks/types.d.ts +20 -20
  191. package/dist/core/tasks/types.d.ts.map +1 -1
  192. package/dist/core/tasks/types.js +1 -1
  193. package/dist/core/tasks/types.js.map +1 -1
  194. package/dist/core/tools/bash.d.ts +8 -7
  195. package/dist/core/tools/bash.d.ts.map +1 -1
  196. package/dist/core/tools/bash.js +6 -5
  197. package/dist/core/tools/bash.js.map +1 -1
  198. package/dist/core/tools/edit.d.ts +3 -3
  199. package/dist/core/tools/edit.d.ts.map +1 -1
  200. package/dist/core/tools/edit.js +2 -4
  201. package/dist/core/tools/edit.js.map +1 -1
  202. package/dist/core/tools/find.d.ts +2 -2
  203. package/dist/core/tools/find.d.ts.map +1 -1
  204. package/dist/core/tools/find.js.map +1 -1
  205. package/dist/core/tools/grep.d.ts +2 -2
  206. package/dist/core/tools/grep.d.ts.map +1 -1
  207. package/dist/core/tools/grep.js +1 -1
  208. package/dist/core/tools/grep.js.map +1 -1
  209. package/dist/core/tools/ls.d.ts +2 -2
  210. package/dist/core/tools/ls.d.ts.map +1 -1
  211. package/dist/core/tools/ls.js.map +1 -1
  212. package/dist/core/tools/powershell.d.ts +1 -5
  213. package/dist/core/tools/powershell.d.ts.map +1 -1
  214. package/dist/core/tools/read.d.ts +2 -2
  215. package/dist/core/tools/read.d.ts.map +1 -1
  216. package/dist/core/tools/read.js.map +1 -1
  217. package/dist/core/tools/render-utils.d.ts +4 -6
  218. package/dist/core/tools/render-utils.d.ts.map +1 -1
  219. package/dist/core/tools/render-utils.js +19 -41
  220. package/dist/core/tools/render-utils.js.map +1 -1
  221. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  222. package/dist/core/tools/renderers/bash.js +3 -25
  223. package/dist/core/tools/renderers/bash.js.map +1 -1
  224. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  225. package/dist/core/tools/renderers/write.js +18 -19
  226. package/dist/core/tools/renderers/write.js.map +1 -1
  227. package/dist/core/tools/shell-execution.d.ts +20 -13
  228. package/dist/core/tools/shell-execution.d.ts.map +1 -1
  229. package/dist/core/tools/shell-execution.js +165 -183
  230. package/dist/core/tools/shell-execution.js.map +1 -1
  231. package/dist/core/tools/shell-tool.d.ts +9 -14
  232. package/dist/core/tools/shell-tool.d.ts.map +1 -1
  233. package/dist/core/tools/shell-tool.js +38 -66
  234. package/dist/core/tools/shell-tool.js.map +1 -1
  235. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -4
  236. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  237. package/dist/core/tools/tool-definition-wrapper.js +2 -3
  238. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  239. package/dist/core/tools/write.d.ts +2 -2
  240. package/dist/core/tools/write.d.ts.map +1 -1
  241. package/dist/core/tools/write.js.map +1 -1
  242. package/dist/core/trust-manager.d.ts.map +1 -1
  243. package/dist/core/trust-manager.js +30 -13
  244. package/dist/core/trust-manager.js.map +1 -1
  245. package/dist/core/usage-totals.d.ts +0 -9
  246. package/dist/core/usage-totals.d.ts.map +1 -1
  247. package/dist/core/usage-totals.js +24 -91
  248. package/dist/core/usage-totals.js.map +1 -1
  249. package/dist/extensions/agent/activity-lines.d.ts +2 -7
  250. package/dist/extensions/agent/activity-lines.d.ts.map +1 -1
  251. package/dist/extensions/agent/activity-lines.js +6 -74
  252. package/dist/extensions/agent/activity-lines.js.map +1 -1
  253. package/dist/extensions/agent/activity.d.ts +0 -21
  254. package/dist/extensions/agent/activity.d.ts.map +1 -1
  255. package/dist/extensions/agent/activity.js +0 -63
  256. package/dist/extensions/agent/activity.js.map +1 -1
  257. package/dist/extensions/agent/progress.d.ts +0 -3
  258. package/dist/extensions/agent/progress.d.ts.map +1 -1
  259. package/dist/extensions/agent/progress.js +11 -10
  260. package/dist/extensions/agent/progress.js.map +1 -1
  261. package/dist/extensions/agent/render.js +1 -1
  262. package/dist/extensions/agent/render.js.map +1 -1
  263. package/dist/extensions/agent/tool.d.ts.map +1 -1
  264. package/dist/extensions/agent/tool.js +0 -6
  265. package/dist/extensions/agent/tool.js.map +1 -1
  266. package/dist/extensions/agent/types.d.ts +3 -11
  267. package/dist/extensions/agent/types.d.ts.map +1 -1
  268. package/dist/extensions/agent/types.js.map +1 -1
  269. package/dist/{core/isolated-session.d.ts → extensions/agent/worker-session.d.ts} +6 -6
  270. package/dist/extensions/agent/worker-session.d.ts.map +1 -0
  271. package/dist/{core/isolated-session.js → extensions/agent/worker-session.js} +9 -9
  272. package/dist/extensions/agent/worker-session.js.map +1 -0
  273. package/dist/extensions/agent/worker.d.ts +0 -3
  274. package/dist/extensions/agent/worker.d.ts.map +1 -1
  275. package/dist/extensions/agent/worker.js +2 -3
  276. package/dist/extensions/agent/worker.js.map +1 -1
  277. package/dist/extensions/btw/agent.d.ts.map +1 -1
  278. package/dist/extensions/btw/agent.js +2 -1
  279. package/dist/extensions/btw/agent.js.map +1 -1
  280. package/dist/extensions/cached-compaction/render.d.ts.map +1 -1
  281. package/dist/extensions/cached-compaction/render.js +3 -3
  282. package/dist/extensions/cached-compaction/render.js.map +1 -1
  283. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  284. package/dist/extensions/codemode/renderer.js +6 -2
  285. package/dist/extensions/codemode/renderer.js.map +1 -1
  286. package/dist/extensions/codemode/tool.d.ts +2 -1
  287. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  288. package/dist/extensions/codemode/tool.js +33 -8
  289. package/dist/extensions/codemode/tool.js.map +1 -1
  290. package/dist/extensions/deepwiki/schema.d.ts.map +1 -1
  291. package/dist/extensions/deepwiki/schema.js +1 -1
  292. package/dist/extensions/deepwiki/schema.js.map +1 -1
  293. package/dist/extensions/llama/ui.d.ts.map +1 -1
  294. package/dist/extensions/llama/ui.js +16 -4
  295. package/dist/extensions/llama/ui.js.map +1 -1
  296. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  297. package/dist/extensions/mcp/cli.js +34 -8
  298. package/dist/extensions/mcp/cli.js.map +1 -1
  299. package/dist/extensions/mcp/oauth.d.ts +1 -1
  300. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  301. package/dist/extensions/mcp/oauth.js +36 -13
  302. package/dist/extensions/mcp/oauth.js.map +1 -1
  303. package/dist/extensions/mcp/ui.d.ts +1 -0
  304. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  305. package/dist/extensions/mcp/ui.js +33 -24
  306. package/dist/extensions/mcp/ui.js.map +1 -1
  307. package/dist/extensions/run-summary/index.d.ts +1 -1
  308. package/dist/extensions/run-summary/index.d.ts.map +1 -1
  309. package/dist/extensions/run-summary/index.js +11 -23
  310. package/dist/extensions/run-summary/index.js.map +1 -1
  311. package/dist/extensions/statusline/usage.d.ts.map +1 -1
  312. package/dist/extensions/statusline/usage.js +2 -1
  313. package/dist/extensions/statusline/usage.js.map +1 -1
  314. package/dist/extensions/tasks/tool/schema.d.ts.map +1 -1
  315. package/dist/extensions/tasks/tool/schema.js +1 -1
  316. package/dist/extensions/tasks/tool/schema.js.map +1 -1
  317. package/dist/extensions/tasks/ui/completion-render.d.ts +5 -1
  318. package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -1
  319. package/dist/extensions/tasks/ui/completion-render.js +25 -70
  320. package/dist/extensions/tasks/ui/completion-render.js.map +1 -1
  321. package/dist/extensions/tasks/ui/inspector.d.ts +1 -1
  322. package/dist/extensions/tasks/ui/inspector.d.ts.map +1 -1
  323. package/dist/extensions/tasks/ui/inspector.js +3 -7
  324. package/dist/extensions/tasks/ui/inspector.js.map +1 -1
  325. package/dist/extensions/tasks/ui/manager.d.ts +1 -1
  326. package/dist/extensions/tasks/ui/manager.d.ts.map +1 -1
  327. package/dist/extensions/tasks/ui/manager.js.map +1 -1
  328. package/dist/extensions/tasks/ui/views.d.ts +3 -4
  329. package/dist/extensions/tasks/ui/views.d.ts.map +1 -1
  330. package/dist/extensions/tasks/ui/views.js +15 -14
  331. package/dist/extensions/tasks/ui/views.js.map +1 -1
  332. package/dist/extensions/tool-presentation/fallback.d.ts.map +1 -0
  333. package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/fallback.js +5 -5
  334. package/dist/extensions/tool-presentation/fallback.js.map +1 -0
  335. package/dist/extensions/tool-presentation/index.js +1 -1
  336. package/dist/extensions/tool-presentation/index.js.map +1 -1
  337. package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/shell.d.ts +1 -1
  338. package/dist/extensions/tool-presentation/shell.d.ts.map +1 -0
  339. package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/shell.js +3 -3
  340. package/dist/extensions/tool-presentation/shell.js.map +1 -0
  341. package/dist/extensions/tool-search/tool.d.ts +21 -6
  342. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  343. package/dist/extensions/tool-search/tool.js +104 -36
  344. package/dist/extensions/tool-search/tool.js.map +1 -1
  345. package/dist/index.d.ts +3 -3
  346. package/dist/index.d.ts.map +1 -1
  347. package/dist/index.js.map +1 -1
  348. package/dist/main.d.ts.map +1 -1
  349. package/dist/main.js +15 -8
  350. package/dist/main.js.map +1 -1
  351. package/dist/modes/interactive/components/assistant-message.d.ts +5 -3
  352. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  353. package/dist/modes/interactive/components/assistant-message.js +61 -45
  354. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  355. package/dist/modes/interactive/components/config-selector-skills.d.ts +54 -0
  356. package/dist/modes/interactive/components/config-selector-skills.d.ts.map +1 -0
  357. package/dist/modes/interactive/components/config-selector-skills.js +178 -0
  358. package/dist/modes/interactive/components/config-selector-skills.js.map +1 -0
  359. package/dist/modes/interactive/components/config-selector.d.ts +2 -11
  360. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  361. package/dist/modes/interactive/components/config-selector.js +31 -181
  362. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  363. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  364. package/dist/modes/interactive/components/custom-editor.js +7 -0
  365. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  366. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  367. package/dist/modes/interactive/components/custom-entry.js +2 -1
  368. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  369. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  370. package/dist/modes/interactive/components/custom-message.js +2 -1
  371. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  372. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  373. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  374. package/dist/modes/interactive/components/extension-editor.js +4 -0
  375. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  376. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  377. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  378. package/dist/modes/interactive/components/login-dialog.js +103 -10
  379. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  380. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  381. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  382. package/dist/modes/interactive/components/markdown-transform.js +3 -2
  383. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  384. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  385. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  386. package/dist/modes/interactive/components/model-selector.js +17 -6
  387. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  388. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
  389. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  390. package/dist/modes/interactive/components/oauth-selector.js +13 -4
  391. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  392. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  393. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  394. package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
  395. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  396. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  397. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  398. package/dist/modes/interactive/components/session-selector-search.js +86 -22
  399. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  400. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  401. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  402. package/dist/modes/interactive/components/session-selector.js +15 -23
  403. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  404. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  405. package/dist/modes/interactive/components/settings-submenu.js +2 -0
  406. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  407. package/dist/modes/interactive/components/task-activity-list.d.ts +5 -0
  408. package/dist/modes/interactive/components/task-activity-list.d.ts.map +1 -0
  409. package/dist/modes/interactive/components/task-activity-list.js +68 -0
  410. package/dist/modes/interactive/components/task-activity-list.js.map +1 -0
  411. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  412. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/tool-execution.js +48 -9
  414. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  415. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  416. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  417. package/dist/modes/interactive/components/tree-selector.js +5 -6
  418. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  419. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  420. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  421. package/dist/modes/interactive/components/user-message-selector.js +9 -1
  422. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  423. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  424. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  425. package/dist/modes/interactive/components/user-message.js +4 -2
  426. package/dist/modes/interactive/components/user-message.js.map +1 -1
  427. package/dist/modes/interactive/editor-host.d.ts.map +1 -1
  428. package/dist/modes/interactive/editor-host.js +3 -2
  429. package/dist/modes/interactive/editor-host.js.map +1 -1
  430. package/dist/modes/interactive/external-editor.d.ts +1 -0
  431. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  432. package/dist/modes/interactive/external-editor.js +17 -5
  433. package/dist/modes/interactive/external-editor.js.map +1 -1
  434. package/dist/modes/interactive/interactive-mode.d.ts +8 -12
  435. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  436. package/dist/modes/interactive/interactive-mode.js +169 -112
  437. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  438. package/dist/modes/interactive/model-search.d.ts +10 -0
  439. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  440. package/dist/modes/interactive/model-search.js +21 -0
  441. package/dist/modes/interactive/model-search.js.map +1 -1
  442. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  443. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  444. package/dist/modes/interactive/theme/theme.js +30 -23
  445. package/dist/modes/interactive/theme/theme.js.map +1 -1
  446. package/dist/modes/interactive/tool-view/chat.d.ts +2 -2
  447. package/dist/modes/interactive/tool-view/chat.d.ts.map +1 -1
  448. package/dist/modes/interactive/tool-view/chat.js +22 -19
  449. package/dist/modes/interactive/tool-view/chat.js.map +1 -1
  450. package/dist/modes/interactive/transcript-layout.d.ts +2 -0
  451. package/dist/modes/interactive/transcript-layout.d.ts.map +1 -1
  452. package/dist/modes/interactive/transcript-layout.js +5 -2
  453. package/dist/modes/interactive/transcript-layout.js.map +1 -1
  454. package/dist/modes/rpc/rpc-client.d.ts +9 -1
  455. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  456. package/dist/modes/rpc/rpc-client.js +23 -23
  457. package/dist/modes/rpc/rpc-client.js.map +1 -1
  458. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  459. package/dist/modes/rpc/rpc-mode.js +0 -3
  460. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  461. package/dist/package-manager-cli.d.ts.map +1 -1
  462. package/dist/package-manager-cli.js +55 -4
  463. package/dist/package-manager-cli.js.map +1 -1
  464. package/dist/utils/ansi.d.ts.map +1 -1
  465. package/dist/utils/ansi.js +5 -2
  466. package/dist/utils/ansi.js.map +1 -1
  467. package/dist/utils/clipboard-command.d.ts.map +1 -1
  468. package/dist/utils/clipboard-command.js +4 -0
  469. package/dist/utils/clipboard-command.js.map +1 -1
  470. package/dist/utils/git.d.ts +1 -1
  471. package/dist/utils/git.d.ts.map +1 -1
  472. package/dist/utils/git.js.map +1 -1
  473. package/dist/utils/image-resize-core.d.ts.map +1 -1
  474. package/dist/utils/image-resize-core.js +5 -3
  475. package/dist/utils/image-resize-core.js.map +1 -1
  476. package/dist/utils/open-browser.d.ts.map +1 -1
  477. package/dist/utils/open-browser.js +4 -1
  478. package/dist/utils/open-browser.js.map +1 -1
  479. package/dist/utils/paths.d.ts +17 -0
  480. package/dist/utils/paths.d.ts.map +1 -1
  481. package/dist/utils/paths.js +42 -1
  482. package/dist/utils/paths.js.map +1 -1
  483. package/dist/utils/shell.d.ts.map +1 -1
  484. package/dist/utils/shell.js +14 -0
  485. package/dist/utils/shell.js.map +1 -1
  486. package/dist/utils/syntax-highlight.d.ts +5 -0
  487. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  488. package/dist/utils/syntax-highlight.js +7 -0
  489. package/dist/utils/syntax-highlight.js.map +1 -1
  490. package/dist/utils/tools-manager.d.ts.map +1 -1
  491. package/dist/utils/tools-manager.js +30 -35
  492. package/dist/utils/tools-manager.js.map +1 -1
  493. package/dist/utils/usage.d.ts +5 -0
  494. package/dist/utils/usage.d.ts.map +1 -0
  495. package/dist/utils/usage.js +16 -0
  496. package/dist/utils/usage.js.map +1 -0
  497. package/docs/bundled/README.md +1 -1
  498. package/docs/bundled/extensions/agent.md +5 -5
  499. package/docs/bundled/extensions/run-summary.md +4 -4
  500. package/docs/bundled/tasks.md +2 -4
  501. package/docs/bundled/tool-presentation.md +2 -2
  502. package/docs/custom-provider.md +1 -1
  503. package/docs/environment-variables.md +2 -0
  504. package/docs/extensions.md +38 -21
  505. package/docs/keybindings.md +1 -1
  506. package/docs/llama-cpp.md +17 -12
  507. package/docs/mcp.md +6 -4
  508. package/docs/packages.md +26 -1
  509. package/docs/rpc.md +1 -1
  510. package/docs/sdk.md +7 -5
  511. package/docs/session-format.md +2 -2
  512. package/docs/sessions.md +10 -0
  513. package/docs/settings.md +5 -4
  514. package/docs/terminal-setup.md +2 -2
  515. package/docs/tmux.md +6 -0
  516. package/docs/tui.md +12 -7
  517. package/docs/usage.md +19 -9
  518. package/docs/windows.md +29 -0
  519. package/examples/extensions/README.md +2 -1
  520. package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  521. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  522. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  523. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  524. package/examples/extensions/debug-provider.ts +2 -2
  525. package/examples/extensions/gondolin/package-lock.json +19 -29
  526. package/examples/extensions/gondolin/package.json +2 -2
  527. package/examples/extensions/preset.ts +2 -0
  528. package/examples/extensions/reload-runtime.ts +17 -5
  529. package/examples/extensions/tools.ts +2 -0
  530. package/examples/extensions/with-deps/package-lock.json +2 -2
  531. package/examples/extensions/with-deps/package.json +1 -1
  532. package/package.json +9 -9
  533. package/schemas/models.schema.json +36 -36
  534. package/schemas/settings.schema.json +17 -0
  535. package/dist/bundle/chunks/anthropic-messages-HWL6AS7T.js +0 -6
  536. package/dist/bundle/chunks/azure-openai-responses-4YYPDYV5.js +0 -2
  537. package/dist/bundle/chunks/chunk-6JS2SOFO.js +0 -11
  538. package/dist/bundle/chunks/chunk-ANCZPKX7.js +0 -2
  539. package/dist/bundle/chunks/chunk-FEZ5RM2B.js +0 -2
  540. package/dist/bundle/chunks/chunk-LPF7HQ3S.js +0 -4
  541. package/dist/bundle/chunks/chunk-MMNIHCU7.js +0 -2
  542. package/dist/bundle/chunks/chunk-PUU43PDV.js +0 -1484
  543. package/dist/bundle/chunks/chunk-R267VV5T.js +0 -82
  544. package/dist/bundle/chunks/chunk-RVKT7OUB.js +0 -9
  545. package/dist/bundle/chunks/chunk-SA2AQYEI.js +0 -7
  546. package/dist/bundle/chunks/chunk-ZAIGBRV5.js +0 -16
  547. package/dist/bundle/chunks/mistral-conversations-V2JJTMJ5.js +0 -5
  548. package/dist/bundle/chunks/openai-completions-TXZXILJR.js +0 -7
  549. package/dist/bundle/chunks/pi-messages-LBJQ4NGP.js +0 -8
  550. package/dist/bundle/chunks/virtual-modules-63XNTSVN.js +0 -2
  551. package/dist/core/isolated-session.d.ts.map +0 -1
  552. package/dist/core/isolated-session.js.map +0 -1
  553. package/dist/modes/interactive/tool-view/fallback.d.ts.map +0 -1
  554. package/dist/modes/interactive/tool-view/fallback.js.map +0 -1
  555. package/dist/modes/interactive/tool-view/shell.d.ts.map +0 -1
  556. package/dist/modes/interactive/tool-view/shell.js.map +0 -1
  557. package/dist/utils/path-identity.d.ts +0 -12
  558. package/dist/utils/path-identity.d.ts.map +0 -1
  559. package/dist/utils/path-identity.js +0 -63
  560. package/dist/utils/path-identity.js.map +0 -1
  561. package/examples/extensions/sandbox/index.ts +0 -321
  562. package/examples/extensions/sandbox/package-lock.json +0 -92
  563. package/examples/extensions/sandbox/package.json +0 -19
  564. /package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/fallback.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tools-manager.js","sourceRoot":"","sources":["../../src/utils/tools-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC1G,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAC9B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAEpC,SAAS,oBAAoB;IAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,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port { chmodSync, createWriteStream, existsSync, mkdirSync, readdirSync, renameSync, rmSync } from \"fs\";\nimport { arch, platform } from \"os\";\nimport { join } from \"path\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { getBinDir, VERSION } from \"../config.ts\";\nimport { fetchWithRetry } from \"./management-http.ts\";\nimport { getPiUserAgent } from \"./pi-user-agent.ts\";\n\nconst TOOLS_DIR = getBinDir();\nconst NETWORK_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.PI_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ninterface ToolConfig {\n\tname: string;\n\trepo: string; // GitHub repo (e.g., \"sharkdp/fd\")\n\tbinaryName: string; // Name of the binary inside the archive\n\tsystemBinaryNames?: string[]; // Alternative system command names to try before downloading\n\ttagPrefix: string; // Prefix for tags (e.g., \"v\" for v1.0.0, \"\" for 1.0.0)\n\tgetAssetName: (version: string, plat: string, architecture: string) => string | null;\n}\n\nconst TOOLS: Record<string, ToolConfig> = {\n\tfd: {\n\t\tname: \"fd\",\n\t\trepo: \"sharkdp/fd\",\n\t\tbinaryName: \"fd\",\n\t\tsystemBinaryNames: [\"fd\", \"fdfind\"],\n\t\ttagPrefix: \"v\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-unknown-linux-musl.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\trg: {\n\t\tname: \"ripgrep\",\n\t\trepo: \"BurntSushi/ripgrep\",\n\t\tbinaryName: \"rg\",\n\t\ttagPrefix: \"\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-unknown-linux-musl.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n};\n\n// Check if a command exists in PATH by trying to run it\nfunction commandExists(cmd: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(cmd, [\"--version\"], { stdio: \"pipe\" });\n\t\t// Check for ENOENT error (command not found)\n\t\treturn result.error === undefined || result.error === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Get the path to a tool (system-wide or in our tools dir)\nexport function getToolPath(tool: \"fd\" | \"rg\"): string | null {\n\tconst config = TOOLS[tool];\n\tif (!config) return null;\n\n\t// Check our tools directory first\n\tconst localPath = join(TOOLS_DIR, config.binaryName + (platform() === \"win32\" ? \".exe\" : \"\"));\n\tif (existsSync(localPath)) {\n\t\treturn localPath;\n\t}\n\n\t// Check system PATH - if found, just return the command name (it's in PATH)\n\tconst systemBinaryNames = config.systemBinaryNames ?? [config.binaryName];\n\tfor (const systemBinaryName of systemBinaryNames) {\n\t\tif (commandExists(systemBinaryName)) {\n\t\t\treturn systemBinaryName;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n// Resolve the latest release version from the release page redirect.\n// The api.github.com releases endpoint counts against the anonymous API\n// quota (60 requests/hour per IP), which is permanently exhausted behind\n// shared egress IPs such as corporate proxies and CI runners. The web\n// endpoint answers with a redirect to the tagged release at no quota cost\n// and lives on the same origin as the binary download itself.\nexport async function getLatestVersion(repo: string): Promise<string> {\n\tconst response = await fetchWithRetry(\n\t\t`https://github.com/${repo}/releases/latest`,\n\t\t{\n\t\t\theaders: { \"User-Agent\": getPiUserAgent(VERSION) },\n\t\t\tredirect: \"manual\",\n\t\t},\n\t\t{ timeoutMs: NETWORK_TIMEOUT_MS },\n\t);\n\n\t// Only the status and headers matter here. Discard the body so the\n\t// connection can be reused.\n\ttry {\n\t\tawait response.body?.cancel();\n\t} catch {\n\t\t// Discarding the body is best-effort.\n\t}\n\n\tconst location = response.status >= 300 && response.status < 400 ? response.headers.get(\"location\") : null;\n\tif (!location) {\n\t\tthrow new Error(`Failed to resolve latest ${repo} release: HTTP ${response.status} without redirect`);\n\t}\n\n\tconst tag = new URL(location, \"https://github.com\").pathname.split(\"/\").pop();\n\tif (!tag || !location.includes(\"/releases/tag/\")) {\n\t\tthrow new Error(`Failed to resolve latest ${repo} release: unexpected redirect to ${location}`);\n\t}\n\treturn decodeURIComponent(tag).replace(/^v/, \"\");\n}\n\n// Download a file from URL\nasync function downloadFile(url: string, dest: string): Promise<void> {\n\tconst response = await fetchWithRetry(url, undefined, { timeoutMs: DOWNLOAD_TIMEOUT_MS });\n\n\tif (!response.ok) {\n\t\tthrow new Error(`Download failed with HTTP ${response.status}: ${url}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error(\"No response body\");\n\t}\n\n\tconst fileStream = createWriteStream(dest);\n\tawait pipeline(Readable.fromWeb(response.body as any), fileStream);\n}\n\nfunction findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {\n\tconst stack: string[] = [rootDir];\n\n\twhile (stack.length > 0) {\n\t\tconst currentDir = stack.pop();\n\t\tif (!currentDir) continue;\n\n\t\tconst entries = readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(currentDir, entry.name);\n\t\t\tif (entry.isFile() && entry.name === binaryFileName) {\n\t\t\t\treturn fullPath;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tstack.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction formatSpawnFailure(result: SpawnSyncReturns<Buffer>): string {\n\tif (result.error?.message) {\n\t\treturn result.error.message;\n\t}\n\tconst stderr = result.stderr?.toString().trim();\n\tif (stderr) {\n\t\treturn stderr;\n\t}\n\tconst stdout = result.stdout?.toString().trim();\n\tif (stdout) {\n\t\treturn stdout;\n\t}\n\treturn `exit status ${result.status ?? \"unknown\"}`;\n}\n\nfunction runExtractionCommand(command: string, args: string[]): string | null {\n\tconst result = spawnSync(command, args, { stdio: \"pipe\" });\n\tif (!result.error && result.status === 0) {\n\t\treturn null;\n\t}\n\treturn `${command}: ${formatSpawnFailure(result)}`;\n}\n\nfunction extractTarGzArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failure = runExtractionCommand(\"tar\", [\"xzf\", archivePath, \"-C\", extractDir]);\n\tif (failure) {\n\t\tthrow new Error(`Failed to extract ${assetName}: ${failure}`);\n\t}\n}\n\nfunction getWindowsTarCommand(): string {\n\tconst systemRoot = process.env.SystemRoot;\n\tif (systemRoot) {\n\t\tconst systemTar = join(systemRoot, \"System32\", \"tar.exe\");\n\t\tif (existsSync(systemTar)) {\n\t\t\treturn systemTar;\n\t\t}\n\t}\n\treturn \"tar.exe\";\n}\n\nfunction extractZipArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failures: string[] = [];\n\n\tif (platform() === \"win32\") {\n\t\t// Windows ships bsdtar as tar.exe, which supports zip files. Prefer the\n\t\t// System32 binary over Git Bash's GNU tar, which does not handle zip archives.\n\t\tconst tarFailure = runExtractionCommand(getWindowsTarCommand(), [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\n\t\tconst script =\n\t\t\t\"& { param($archive, $destination) $ErrorActionPreference = 'Stop'; Expand-Archive -LiteralPath $archive -DestinationPath $destination -Force }\";\n\t\tconst powershellFailure = runExtractionCommand(\"powershell.exe\", [\n\t\t\t\"-NoLogo\",\n\t\t\t\"-NoProfile\",\n\t\t\t\"-NonInteractive\",\n\t\t\t\"-ExecutionPolicy\",\n\t\t\t\"Bypass\",\n\t\t\t\"-Command\",\n\t\t\tscript,\n\t\t\tarchivePath,\n\t\t\textractDir,\n\t\t]);\n\t\tif (!powershellFailure) return;\n\t\tfailures.push(powershellFailure);\n\t} else {\n\t\tconst unzipFailure = runExtractionCommand(\"unzip\", [\"-q\", archivePath, \"-d\", extractDir]);\n\t\tif (!unzipFailure) return;\n\t\tfailures.push(unzipFailure);\n\n\t\tconst tarFailure = runExtractionCommand(\"tar\", [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\t}\n\n\tthrow new Error(`Failed to extract ${assetName}: ${failures.join(\"; \")}`);\n}\n\n// Download and install a tool\nasync function downloadTool(tool: \"fd\" | \"rg\"): Promise<string> {\n\tconst config = TOOLS[tool];\n\tif (!config) throw new Error(`Unknown tool: ${tool}`);\n\n\tconst plat = platform();\n\tconst architecture = arch();\n\n\t// fd is pinned on darwin/x64, so skip the version lookup there.\n\tconst version =\n\t\ttool === \"fd\" && plat === \"darwin\" && architecture === \"x64\" ? \"10.3.0\" : await getLatestVersion(config.repo);\n\n\t// Get asset name for this platform\n\tconst assetName = config.getAssetName(version, plat, architecture);\n\tif (!assetName) {\n\t\tthrow new Error(`Unsupported platform: ${plat}/${architecture}`);\n\t}\n\n\t// Create tools directory\n\tmkdirSync(TOOLS_DIR, { recursive: true });\n\n\tconst downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;\n\tconst archivePath = join(TOOLS_DIR, assetName);\n\tconst binaryExt = plat === \"win32\" ? \".exe\" : \"\";\n\tconst binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);\n\n\t// Download\n\tawait downloadFile(downloadUrl, archivePath);\n\n\t// Extract into a unique temp directory. fd and rg downloads can run concurrently\n\t// during startup, so sharing a fixed directory causes races.\n\tconst extractDir = join(\n\t\tTOOLS_DIR,\n\t\t`extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,\n\t);\n\tmkdirSync(extractDir, { recursive: true });\n\n\ttry {\n\t\tif (assetName.endsWith(\".tar.gz\")) {\n\t\t\textractTarGzArchive(archivePath, extractDir, assetName);\n\t\t} else if (assetName.endsWith(\".zip\")) {\n\t\t\textractZipArchive(archivePath, extractDir, assetName);\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported archive format: ${assetName}`);\n\t\t}\n\n\t\t// Find the binary in extracted files. Some archives contain files directly\n\t\t// at root, others nest under a versioned subdirectory.\n\t\tconst binaryFileName = config.binaryName + binaryExt;\n\t\tconst extractedDir = join(extractDir, assetName.replace(/\\.(tar\\.gz|zip)$/, \"\"));\n\t\tconst extractedBinaryCandidates = [join(extractedDir, binaryFileName), join(extractDir, binaryFileName)];\n\t\tlet extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));\n\n\t\tif (!extractedBinary) {\n\t\t\textractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;\n\t\t}\n\n\t\tif (extractedBinary) {\n\t\t\trenameSync(extractedBinary, binaryPath);\n\t\t} else {\n\t\t\tthrow new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);\n\t\t}\n\n\t\t// Make executable (Unix only)\n\t\tif (plat !== \"win32\") {\n\t\t\tchmodSync(binaryPath, 0o755);\n\t\t}\n\t} finally {\n\t\t// Cleanup\n\t\trmSync(archivePath, { force: true });\n\t\trmSync(extractDir, { recursive: true, force: true });\n\t}\n\n\treturn binaryPath;\n}\n\n// Termux package names for tools\nconst TERMUX_PACKAGES: Record<string, string> = {\n\tfd: \"fd\",\n\trg: \"ripgrep\",\n};\n\nexport interface ToolStatus {\n\ttype: \"info\" | \"warning\";\n\tmessage: string;\n}\n\n/**\n * Ensure a tool is available, downloading if necessary.\n * Reports progress through `onStatus`; status messages are otherwise silent.\n * Returns the tool path, or undefined if unavailable.\n */\nexport async function ensureTool(\n\ttool: \"fd\" | \"rg\",\n\tonStatus?: (status: ToolStatus) => void,\n): Promise<string | undefined> {\n\tconst existingPath = getToolPath(tool);\n\tif (existingPath) {\n\t\treturn existingPath;\n\t}\n\n\tconst config = TOOLS[tool];\n\tif (!config) return undefined;\n\n\tif (isOfflineModeEnabled()) {\n\t\tonStatus?.({ type: \"warning\", message: `${config.name} not found. Offline mode enabled, skipping download.` });\n\t\treturn undefined;\n\t}\n\n\t// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.\n\t// Users must install via pkg.\n\tif (platform() === \"android\") {\n\t\tconst pkgName = TERMUX_PACKAGES[tool] ?? tool;\n\t\tonStatus?.({ type: \"warning\", message: `${config.name} not found. Install with: pkg install ${pkgName}` });\n\t\treturn undefined;\n\t}\n\n\t// Tool not found - download it\n\tonStatus?.({ type: \"info\", message: `${config.name} not found. Downloading...` });\n\n\ttry {\n\t\tconst path = await downloadTool(tool);\n\t\tonStatus?.({ type: \"info\", message: `${config.name} installed to ${path}` });\n\t\treturn path;\n\t} catch (e) {\n\t\t// Include the error cause chain: fetch failures surface as a bare\n\t\t// \"fetch failed\" TypeError with the actionable detail (DNS, TLS,\n\t\t// timeout) hidden in the cause. Depth-capped to guard against\n\t\t// circular cause chains.\n\t\tconst messages: string[] = [];\n\t\tfor (\n\t\t\tlet current: unknown = e, depth = 0;\n\t\t\tcurrent instanceof Error && depth < 5;\n\t\t\tcurrent = current.cause, depth++\n\t\t) {\n\t\t\tif (!messages.includes(current.message)) messages.push(current.message);\n\t\t}\n\t\tonStatus?.({\n\t\t\ttype: \"warning\",\n\t\t\tmessage: `Failed to download ${config.name}: ${messages.length > 0 ? messages.join(\": \") : String(e)}`,\n\t\t});\n\t\treturn undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tools-manager.js","sourceRoot":"","sources":["../../src/utils/tools-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC1G,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAC9B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAEpC,SAAS,oBAAoB;IAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACrC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;AACzF,CAAC;AAWD,kFAAkF;AAClF,gFAAgF;AAChF,kDAAkD;AAClD,SAAS,gBAAgB,CAAC,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EACnC,OAAO,YAAY,KAAK,IAAI,KAAK,GAAG,CAAC,EACrC,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,EAC/B,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzE,CAAC;QACD,QAAQ,EAAE,CAAC;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,sBAAsB,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;SACtG,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import { type SpawnSyncReturns, spawnSync } from \"child_process\";\nimport { chmodSync, createWriteStream, existsSync, mkdirSync, readdirSync, renameSync, rmSync } from \"fs\";\nimport { arch, platform } from \"os\";\nimport { join } from \"path\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { getBinDir, VERSION } from \"../config.ts\";\nimport { fetchWithRetry } from \"./management-http.ts\";\nimport { getPiUserAgent } from \"./pi-user-agent.ts\";\n\nconst TOOLS_DIR = getBinDir();\nconst NETWORK_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.PI_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ninterface ToolConfig {\n\tname: string;\n\trepo: string; // GitHub repo (e.g., \"sharkdp/fd\")\n\tbinaryName: string; // Name of the binary inside the archive\n\tsystemBinaryNames?: string[]; // Alternative system command names to try before downloading\n\ttagPrefix: string; // Prefix for tags (e.g., \"v\" for v1.0.0, \"\" for 1.0.0)\n\tgetAssetName: (version: string, target: string) => string;\n}\n\n// Map Node's platform/arch to the release target suffix shared by fd and ripgrep.\n// Only x64 and arm64 are mapped. Other architectures (e.g. ARM32 `arm`, `ia32`)\n// must not fall back to x86-64 binaries (#11209).\nfunction getReleaseTarget(plat: string, architecture: string): string | undefined {\n\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : architecture === \"x64\" ? \"x86_64\" : undefined;\n\tif (!archStr) return undefined;\n\tif (plat === \"darwin\") return `${archStr}-apple-darwin.tar.gz`;\n\tif (plat === \"linux\") return `${archStr}-unknown-linux-musl.tar.gz`;\n\tif (plat === \"win32\") return `${archStr}-pc-windows-msvc.zip`;\n\treturn undefined;\n}\n\nconst TOOLS: Record<string, ToolConfig> = {\n\tfd: {\n\t\tname: \"fd\",\n\t\trepo: \"sharkdp/fd\",\n\t\tbinaryName: \"fd\",\n\t\tsystemBinaryNames: [\"fd\", \"fdfind\"],\n\t\ttagPrefix: \"v\",\n\t\tgetAssetName: (version, target) => `fd-v${version}-${target}`,\n\t},\n\trg: {\n\t\tname: \"ripgrep\",\n\t\trepo: \"BurntSushi/ripgrep\",\n\t\tbinaryName: \"rg\",\n\t\ttagPrefix: \"\",\n\t\tgetAssetName: (version, target) => `ripgrep-${version}-${target}`,\n\t},\n};\n\n// Check if a command exists in PATH by trying to run it\nfunction commandExists(cmd: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(cmd, [\"--version\"], { stdio: \"pipe\" });\n\t\t// Check for ENOENT error (command not found)\n\t\treturn result.error === undefined || result.error === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Get the path to a tool (system-wide or in our tools dir)\nexport function getToolPath(tool: \"fd\" | \"rg\"): string | null {\n\tconst config = TOOLS[tool];\n\tif (!config) return null;\n\n\t// Check our tools directory first\n\tconst localPath = join(TOOLS_DIR, config.binaryName + (platform() === \"win32\" ? \".exe\" : \"\"));\n\tif (existsSync(localPath)) {\n\t\treturn localPath;\n\t}\n\n\t// Check system PATH - if found, just return the command name (it's in PATH)\n\tconst systemBinaryNames = config.systemBinaryNames ?? [config.binaryName];\n\tfor (const systemBinaryName of systemBinaryNames) {\n\t\tif (commandExists(systemBinaryName)) {\n\t\t\treturn systemBinaryName;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n// Resolve the latest release version from the release page redirect.\n// The api.github.com releases endpoint counts against the anonymous API\n// quota (60 requests/hour per IP), which is permanently exhausted behind\n// shared egress IPs such as corporate proxies and CI runners. The web\n// endpoint answers with a redirect to the tagged release at no quota cost\n// and lives on the same origin as the binary download itself.\nexport async function getLatestVersion(repo: string): Promise<string> {\n\tconst response = await fetchWithRetry(\n\t\t`https://github.com/${repo}/releases/latest`,\n\t\t{\n\t\t\theaders: { \"User-Agent\": getPiUserAgent(VERSION) },\n\t\t\tredirect: \"manual\",\n\t\t},\n\t\t{ timeoutMs: NETWORK_TIMEOUT_MS },\n\t);\n\n\t// Only the status and headers matter here. Discard the body so the\n\t// connection can be reused.\n\ttry {\n\t\tawait response.body?.cancel();\n\t} catch {\n\t\t// Discarding the body is best-effort.\n\t}\n\n\tconst location = response.status >= 300 && response.status < 400 ? response.headers.get(\"location\") : null;\n\tif (!location) {\n\t\tthrow new Error(`Failed to resolve latest ${repo} release: HTTP ${response.status} without redirect`);\n\t}\n\n\tconst tag = new URL(location, \"https://github.com\").pathname.split(\"/\").pop();\n\tif (!tag || !location.includes(\"/releases/tag/\")) {\n\t\tthrow new Error(`Failed to resolve latest ${repo} release: unexpected redirect to ${location}`);\n\t}\n\treturn decodeURIComponent(tag).replace(/^v/, \"\");\n}\n\n// Download a file from URL\nasync function downloadFile(url: string, dest: string): Promise<void> {\n\tconst response = await fetchWithRetry(url, undefined, { timeoutMs: DOWNLOAD_TIMEOUT_MS });\n\n\tif (!response.ok) {\n\t\tthrow new Error(`Download failed with HTTP ${response.status}: ${url}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error(\"No response body\");\n\t}\n\n\tconst fileStream = createWriteStream(dest);\n\tawait pipeline(Readable.fromWeb(response.body as any), fileStream);\n}\n\nfunction findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {\n\tconst stack: string[] = [rootDir];\n\n\twhile (stack.length > 0) {\n\t\tconst currentDir = stack.pop();\n\t\tif (!currentDir) continue;\n\n\t\tconst entries = readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(currentDir, entry.name);\n\t\t\tif (entry.isFile() && entry.name === binaryFileName) {\n\t\t\t\treturn fullPath;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tstack.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction formatSpawnFailure(result: SpawnSyncReturns<Buffer>): string {\n\tif (result.error?.message) {\n\t\treturn result.error.message;\n\t}\n\tconst stderr = result.stderr?.toString().trim();\n\tif (stderr) {\n\t\treturn stderr;\n\t}\n\tconst stdout = result.stdout?.toString().trim();\n\tif (stdout) {\n\t\treturn stdout;\n\t}\n\treturn `exit status ${result.status ?? \"unknown\"}`;\n}\n\nfunction runExtractionCommand(command: string, args: string[]): string | null {\n\tconst result = spawnSync(command, args, { stdio: \"pipe\" });\n\tif (!result.error && result.status === 0) {\n\t\treturn null;\n\t}\n\treturn `${command}: ${formatSpawnFailure(result)}`;\n}\n\nfunction extractTarGzArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failure = runExtractionCommand(\"tar\", [\"xzf\", archivePath, \"-C\", extractDir]);\n\tif (failure) {\n\t\tthrow new Error(`Failed to extract ${assetName}: ${failure}`);\n\t}\n}\n\nfunction getWindowsTarCommand(): string {\n\tconst systemRoot = process.env.SystemRoot;\n\tif (systemRoot) {\n\t\tconst systemTar = join(systemRoot, \"System32\", \"tar.exe\");\n\t\tif (existsSync(systemTar)) {\n\t\t\treturn systemTar;\n\t\t}\n\t}\n\treturn \"tar.exe\";\n}\n\nfunction extractZipArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failures: string[] = [];\n\n\tif (platform() === \"win32\") {\n\t\t// Windows ships bsdtar as tar.exe, which supports zip files. Prefer the\n\t\t// System32 binary over Git Bash's GNU tar, which does not handle zip archives.\n\t\tconst tarFailure = runExtractionCommand(getWindowsTarCommand(), [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\n\t\tconst script =\n\t\t\t\"& { param($archive, $destination) $ErrorActionPreference = 'Stop'; Expand-Archive -LiteralPath $archive -DestinationPath $destination -Force }\";\n\t\tconst powershellFailure = runExtractionCommand(\"powershell.exe\", [\n\t\t\t\"-NoLogo\",\n\t\t\t\"-NoProfile\",\n\t\t\t\"-NonInteractive\",\n\t\t\t\"-ExecutionPolicy\",\n\t\t\t\"Bypass\",\n\t\t\t\"-Command\",\n\t\t\tscript,\n\t\t\tarchivePath,\n\t\t\textractDir,\n\t\t]);\n\t\tif (!powershellFailure) return;\n\t\tfailures.push(powershellFailure);\n\t} else {\n\t\tconst unzipFailure = runExtractionCommand(\"unzip\", [\"-q\", archivePath, \"-d\", extractDir]);\n\t\tif (!unzipFailure) return;\n\t\tfailures.push(unzipFailure);\n\n\t\tconst tarFailure = runExtractionCommand(\"tar\", [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\t}\n\n\tthrow new Error(`Failed to extract ${assetName}: ${failures.join(\"; \")}`);\n}\n\n// Download and install a tool\nasync function downloadTool(tool: \"fd\" | \"rg\"): Promise<string> {\n\tconst config = TOOLS[tool];\n\tif (!config) throw new Error(`Unknown tool: ${tool}`);\n\n\tconst plat = platform();\n\tconst architecture = arch();\n\tconst target = getReleaseTarget(plat, architecture);\n\tif (!target) {\n\t\tthrow new Error(`Unsupported platform: ${plat}/${architecture}`);\n\t}\n\n\t// fd is pinned on darwin/x64, so skip the version lookup there.\n\tconst version =\n\t\ttool === \"fd\" && plat === \"darwin\" && architecture === \"x64\" ? \"10.3.0\" : await getLatestVersion(config.repo);\n\tconst assetName = config.getAssetName(version, target);\n\n\t// Create tools directory\n\tmkdirSync(TOOLS_DIR, { recursive: true });\n\n\tconst downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;\n\tconst archivePath = join(TOOLS_DIR, assetName);\n\tconst binaryExt = plat === \"win32\" ? \".exe\" : \"\";\n\tconst binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);\n\n\t// Download\n\tawait downloadFile(downloadUrl, archivePath);\n\n\t// Extract into a unique temp directory. fd and rg downloads can run concurrently\n\t// during startup, so sharing a fixed directory causes races.\n\tconst extractDir = join(\n\t\tTOOLS_DIR,\n\t\t`extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,\n\t);\n\tmkdirSync(extractDir, { recursive: true });\n\n\ttry {\n\t\tif (assetName.endsWith(\".tar.gz\")) {\n\t\t\textractTarGzArchive(archivePath, extractDir, assetName);\n\t\t} else if (assetName.endsWith(\".zip\")) {\n\t\t\textractZipArchive(archivePath, extractDir, assetName);\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported archive format: ${assetName}`);\n\t\t}\n\n\t\t// Find the binary in extracted files. Some archives contain files directly\n\t\t// at root, others nest under a versioned subdirectory.\n\t\tconst binaryFileName = config.binaryName + binaryExt;\n\t\tconst extractedDir = join(extractDir, assetName.replace(/\\.(tar\\.gz|zip)$/, \"\"));\n\t\tconst extractedBinaryCandidates = [join(extractedDir, binaryFileName), join(extractDir, binaryFileName)];\n\t\tlet extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));\n\n\t\tif (!extractedBinary) {\n\t\t\textractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;\n\t\t}\n\n\t\tif (extractedBinary) {\n\t\t\trenameSync(extractedBinary, binaryPath);\n\t\t} else {\n\t\t\tthrow new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);\n\t\t}\n\n\t\t// Make executable (Unix only)\n\t\tif (plat !== \"win32\") {\n\t\t\tchmodSync(binaryPath, 0o755);\n\t\t}\n\t} finally {\n\t\t// Cleanup\n\t\trmSync(archivePath, { force: true });\n\t\trmSync(extractDir, { recursive: true, force: true });\n\t}\n\n\treturn binaryPath;\n}\n\n// Termux package names for tools\nconst TERMUX_PACKAGES: Record<string, string> = {\n\tfd: \"fd\",\n\trg: \"ripgrep\",\n};\n\nexport interface ToolStatus {\n\ttype: \"info\" | \"warning\";\n\tmessage: string;\n}\n\n/**\n * Ensure a tool is available, downloading if necessary.\n * Reports progress through `onStatus`; status messages are otherwise silent.\n * Returns the tool path, or undefined if unavailable.\n */\nexport async function ensureTool(\n\ttool: \"fd\" | \"rg\",\n\tonStatus?: (status: ToolStatus) => void,\n): Promise<string | undefined> {\n\tconst existingPath = getToolPath(tool);\n\tif (existingPath) {\n\t\treturn existingPath;\n\t}\n\n\tconst config = TOOLS[tool];\n\tif (!config) return undefined;\n\n\tif (isOfflineModeEnabled()) {\n\t\tonStatus?.({ type: \"warning\", message: `${config.name} not found. Offline mode enabled, skipping download.` });\n\t\treturn undefined;\n\t}\n\n\t// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.\n\t// Users must install via pkg.\n\tif (platform() === \"android\") {\n\t\tconst pkgName = TERMUX_PACKAGES[tool] ?? tool;\n\t\tonStatus?.({ type: \"warning\", message: `${config.name} not found. Install with: pkg install ${pkgName}` });\n\t\treturn undefined;\n\t}\n\n\t// Prebuilt downloads only exist for the targets mapped in getReleaseTarget.\n\tif (!getReleaseTarget(platform(), arch())) {\n\t\tonStatus?.({\n\t\t\ttype: \"warning\",\n\t\t\tmessage: `${config.name} not found. Automatic download is not supported on ${platform()}/${arch()}. Install ${config.name} with your system package manager.`,\n\t\t});\n\t\treturn undefined;\n\t}\n\n\t// Tool not found - download it\n\tonStatus?.({ type: \"info\", message: `${config.name} not found. Downloading...` });\n\n\ttry {\n\t\tconst path = await downloadTool(tool);\n\t\tonStatus?.({ type: \"info\", message: `${config.name} installed to ${path}` });\n\t\treturn path;\n\t} catch (e) {\n\t\t// Include the error cause chain: fetch failures surface as a bare\n\t\t// \"fetch failed\" TypeError with the actionable detail (DNS, TLS,\n\t\t// timeout) hidden in the cause. Depth-capped to guard against\n\t\t// circular cause chains.\n\t\tconst messages: string[] = [];\n\t\tfor (\n\t\t\tlet current: unknown = e, depth = 0;\n\t\t\tcurrent instanceof Error && depth < 5;\n\t\t\tcurrent = current.cause, depth++\n\t\t) {\n\t\t\tif (!messages.includes(current.message)) messages.push(current.message);\n\t\t}\n\t\tonStatus?.({\n\t\t\ttype: \"warning\",\n\t\t\tmessage: `Failed to download ${config.name}: ${messages.length > 0 ? messages.join(\": \") : String(e)}`,\n\t\t});\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Usage } from "@earendil-works/pi-ai/compat";
2
+ export declare function emptyUsage(): Usage;
3
+ /** Share of one request's prompt served from cache, or undefined when it reported no cache activity. */
4
+ export declare function cacheHitPercent({ input, cacheRead, cacheWrite, }: Pick<Usage, "input" | "cacheRead" | "cacheWrite">): number | undefined;
5
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/utils/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,wBAAgB,UAAU,IAAI,KAAK,CASlC;AAED,wGAAwG;AACxG,wBAAgB,eAAe,CAAC,EAC/B,KAAK,EACL,SAAS,EACT,UAAU,GACV,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG,MAAM,GAAG,SAAS,CAGxE"}
@@ -0,0 +1,16 @@
1
+ export function emptyUsage() {
2
+ return {
3
+ input: 0,
4
+ output: 0,
5
+ cacheRead: 0,
6
+ cacheWrite: 0,
7
+ totalTokens: 0,
8
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
9
+ };
10
+ }
11
+ /** Share of one request's prompt served from cache, or undefined when it reported no cache activity. */
12
+ export function cacheHitPercent({ input, cacheRead, cacheWrite, }) {
13
+ const promptTokens = input + cacheRead + cacheWrite;
14
+ return (cacheRead > 0 || cacheWrite > 0) && promptTokens > 0 ? (cacheRead / promptTokens) * 100 : undefined;
15
+ }
16
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/utils/usage.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU;IACzB,OAAO;QACN,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACpE,CAAC;AACH,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,eAAe,CAAC,EAC/B,KAAK,EACL,SAAS,EACT,UAAU,GACyC;IACnD,MAAM,YAAY,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;IACpD,OAAO,CAAC,SAAS,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7G,CAAC","sourcesContent":["import type { Usage } from \"@earendil-works/pi-ai/compat\";\n\nexport function emptyUsage(): Usage {\n\treturn {\n\t\tinput: 0,\n\t\toutput: 0,\n\t\tcacheRead: 0,\n\t\tcacheWrite: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t};\n}\n\n/** Share of one request's prompt served from cache, or undefined when it reported no cache activity. */\nexport function cacheHitPercent({\n\tinput,\n\tcacheRead,\n\tcacheWrite,\n}: Pick<Usage, \"input\" | \"cacheRead\" | \"cacheWrite\">): number | undefined {\n\tconst promptTokens = input + cacheRead + cacheWrite;\n\treturn (cacheRead > 0 || cacheWrite > 0) && promptTokens > 0 ? (cacheRead / promptTokens) * 100 : undefined;\n}\n"]}
@@ -23,7 +23,7 @@ The following extensions are additions maintained by `@astralyn/pi`:
23
23
  | [BTW](extensions/btw.md) | `/btw [question]` | Ask temporary side questions with the current context while the main task continues |
24
24
  | [DeepWiki](extensions/deepwiki.md) | `deepwiki` | Query indexed public GitHub repository documentation |
25
25
  | [Question](extensions/question.md) | `question` | Ask structured questions through native interactive UI |
26
- | [Run summary](extensions/run-summary.md) | Transcript note | Show elapsed and completion time after each continuous agent run |
26
+ | [Run summary](extensions/run-summary.md) | Transcript line | Show elapsed and completion time after each continuous agent run |
27
27
  | [Provider](extensions/provider.md) | `/provider` | Edit models.json providers: connection, API type, and models |
28
28
  | [Statusline](extensions/statusline.md) | Footer status | Show concise extension-managed activity state |
29
29
  | [Search](extensions/search.md) | `code_search`, `web_search` | Devin-driven semantic code search and web search with one shared key |
@@ -66,14 +66,14 @@ In `/tasks`, each Agent remains an independent row:
66
66
 
67
67
  ```text
68
68
  … 12 earlier tool calls
69
- ✓ read src/core/tasks/store.ts · 4ms
70
- ✓ bash npm test · 6.2s
71
- × bash npm run check · 41.0s
69
+ ✓ read src/core/tasks/store.ts · 4ms
70
+ ✓ bash npm test · 6.2s
71
+ × bash npm run check · 41.0s
72
72
  src/index.ts:12:5 - error TS2322
73
- ✶ read README.md · 3.1s
73
+ › read README.md
74
74
  ```
75
75
 
76
- Each call is `glyph tool target · duration`, with the tool-name column padded to the longest shown name (at most 8 characters) so targets line up, and the durations right-aligned in one column at the end of the longest row. The glyphs are the task status markers used throughout `/tasks`: `✓` for success, `×` for failure, `○` for cancellation, and for a running call the same animated spinner as a running task. When more than the latest 50 calls happened, the first line counts the earlier ones. A failed call adds one line under its target holding the first non-empty line of its error, clipped to about 160 characters. Durations read `42ms` under a second, `6.2s` under a minute, then `1m 5s`. While the Agent runs, the list is styled with the theme: the glyph in its task status color (running accent, success green, failure red, cancellation warning), the tool name as a tool title, the target muted and the duration dim, with the error line in the error color. Targets are clipped to the panel width, never the duration, and the running call shows how long it has been running. The plain-text fallback uses the same markers with `›` for a running call and no column alignment. The Transcript's expanded row renders the same rows through the same code, so the two always agree. The model never sees this list; `tasks read` still returns the one-line status. Once the Agent finishes, whatever its outcome, Output shows only its final report (Markdown for a completed report) or, for a failed or cancelled Agent, its report so far and diagnostic. Oversized reports remain available through their managed output file.
76
+ Each call is `glyph tool target · duration`, with the tool-name column padded to the longest shown name (at most 8 characters) so targets line up. The glyphs are `✓` for success, `×` for failure, `○` for cancellation and `›` for a running call. When more than the latest 50 calls happened, the first line counts the earlier ones. A failed call adds one line under its target holding the first non-empty line of its error, clipped to about 160 characters. Durations read `42ms` under a second, `6.2s` under a minute, then `1m 5s`. Both `/tasks` and the Transcript's expanded row render the same structured activity data with the theme: status-colored glyphs, tool-title names, muted targets, dim right-aligned durations and error lines, plus a running call's animated marker and elapsed time. The plain display uses `›` for a running call and remains the fallback outside these live views. The model never sees this list; `tasks read` still returns the one-line status. Once the Agent finishes, whatever its outcome, Output shows only its final report (Markdown for a completed report) or, for a failed or cancelled Agent, its report so far and diagnostic. Oversized reports remain available through their managed output file.
77
77
  - **Details** shows the full Prompt, working directory, model, and thinking level. Once the Agent settles, it also shows `Tool calls` (every call, for example `23 · 2 failed`), `Edited` (see below) and, in a saved session, the `Report` and `Transcript` paths.
78
78
 
79
79
  Use `tasks read` or `tasks kill` with the Task ID; the report arrives automatically when the Agent finishes. Reading requires no view options: the status line or report is the model projection, while the `/tasks` panel adds the human-only tool-call list while the Agent runs. Selection, scrolling, cancellation, foreground detach, history, and completion delivery are owned by the shared Tasks implementation. Parent cancellation stops foreground-owned work, including cancellation received during startup; detached work continues until it finishes or is killed. Reload, session replacement, and shutdown cancel active Agents.
@@ -1,6 +1,6 @@
1
1
  # Run summary
2
2
 
3
- Shows one dim transcript note after each continuous agent run in interactive mode:
3
+ Shows one dim transcript line after each continuous agent run in interactive mode:
4
4
 
5
5
  ```text
6
6
  Worked for 1m 52s · Done 2026/10/28 13:14
@@ -10,8 +10,8 @@ The elapsed time covers the whole run, including model requests, tool execution,
10
10
 
11
11
  Durations use the same compact format as Tasks: zero components are omitted, for example `8s`, `1m`, `1m 5s`, and `1h 5m`. The completion timestamp is local time in `YYYY/MM/DD HH:mm` format.
12
12
 
13
- Each settled run appends a small `run-summary` custom entry containing the anchor entry ID, start and finish times, and outcome. These records are bookkeeping, not chat messages: they have no entry renderer, do not enter model context, and are hidden by the default tree filter. Display text is reconstructed from the record rather than stored.
13
+ Each settled run appends a small `run-summary` custom entry containing the anchor entry ID, start and finish times, and outcome, and the extension's entry renderer draws that entry as the dim line above. The entries do not enter model context and are hidden by the default tree filter. Display text is reconstructed from the record rather than stored, and the line follows the `outputPad` setting.
14
14
 
15
- On startup, `/reload`, and branch navigation, Pi scans the active branch and projects valid records back into transcript notes. The notes survive compaction and branch navigation whenever their anchors remain visible. Runs recorded before this feature existed are not estimated or backfilled.
15
+ Because the line is the entry itself, it reappears in place whenever Pi rebuilds the transcript, such as on startup, `/reload` and branch navigation, as long as the entry is on the active branch. Navigating to the run's last message leaves the summary entry off the branch, so the line is not shown there. Runs recorded before this feature existed are not estimated or backfilled.
16
16
 
17
- Disable `builtin:run-summary` to hide these notes.
17
+ Disable `builtin:run-summary` to hide these lines.
@@ -94,13 +94,11 @@ The statusline counts only queued, running and stopping background tasks: `1 bac
94
94
 
95
95
  ## Completion notifications
96
96
 
97
- Interactive `task-completion` messages have a compact collapsed summary: the executor's label, outcome, duration, short ID, and the task title. Failures retain a short reason; log paths, output and worker reports stay out of the collapsed view. In fullscreen mode, left-click the notification to expand or collapse that message independently. The blank spacer above it is not a click target. The configured tool-output expansion binding (default Ctrl+O) remains available for toggling output expansion across the transcript.
98
-
99
- Expanded notifications separate the input under its own label, such as **Command** or **Prompt** (or **Task** without one), **Details** with the declared facts such as directory and exit code, **Result** or **Error**, a bounded plain-text **Output** preview, **Log** and the full execution ID. A log's saved output keeps its end, where the outcome is; a report's keeps its beginning, where the conclusion is. Both carry an explicit truncation flag. Screen line limits are independent of source truncation. The card ends with the task ID; it carries no separate closing line. A failed shell task's card states its error once: the output holds only what the command printed.
97
+ Interactive `task-completion` messages are notifications, not a second details viewer: the executor's label, outcome, duration, short ID, and the first line of the task title. A failure adds its saved reason, stated once. Expanding the message, by clicking it or with the tool-output expansion binding (default Ctrl+O), adds nothing, so a background Agent's notification looks the same as its settled foreground result. The input, facts, log path, output and full report stay in `/tasks`.
100
98
 
101
99
  Rendering reads the self-contained terminal snapshot in message `details`, so `/reload`, history eviction, expired logs and restart do not require a live task lookup. The session generates model-facing `content` from the same facts; `details` never enters model context or usage accounting. Replay details retain up to 40 KiB of output. A shell task's result holds the command's output only; its failure is the separate error, which the notification states once on its `Error:` line instead of repeating it at the end of the output. The automatic model-facing notification includes only an 8 KiB tail of a log, plus the log path and truncation guidance for `tasks read`; a report arrives from its beginning, whole when it fits the 48 KiB budget, as its foreground result would. Commands containing `Output:` and literal truncation notices remain ordinary data. See the [snapshot contract](../session-format.md#background-records).
102
100
 
103
- Only the current structured completion format (version 2) is specialized. Older completions, including version-1 shell and report completions, and malformed details receive a bounded plain **Details** view of their saved message; no text reconstruction or migration is performed. Legacy `background-task` notifications show as plain messages. HTML export and `/tree` selector labels continue to display the saved message content.
101
+ Only the current structured completion format (version 2) is specialized. Older completions, including version-1 shell and report completions, and malformed details show the first few lines of their saved message under a **Notification** header; no text reconstruction or migration is performed. Legacy `background-task` notifications show as plain messages. HTML export and `/tree` selector labels continue to display the saved message content.
104
102
 
105
103
  ## Lifetime
106
104
 
@@ -39,9 +39,9 @@ The `Ctrl+B` background hint is not part of a tool row. Once a foreground manage
39
39
 
40
40
  The look is defined in one place, `src/modes/interactive/tool-view/style.ts`: the marker and rail glyphs, their colors, the spacing between blocks, and which tools fold their result. `FramedComponent` in the same file hangs a component's lines off the marker or the rail and derives the gutter width from the glyphs.
41
41
 
42
- The upstream `components/tool-execution.ts` owns one call's lifecycle: pending, success and error states, expansion, image placement and Kitty conversion, and renderer disposal. The bundled `tool-presentation` extension attaches a TUI-only shell through the existing tool renderer resolver; `tool-view/shell.ts` maps the visual policy to that shell. Direct constructors can attach the same shell with `withToolShell()` from `tool-view/shell.ts`; there is no second lifecycle implementation.
42
+ The upstream `components/tool-execution.ts` owns one call's lifecycle: pending, success and error states, expansion, image placement and Kitty conversion, and renderer disposal. The bundled `tool-presentation` extension attaches a TUI-only shell through the existing tool renderer resolver; its `shell.ts` maps the visual policy to that shell, and `fallback.ts` draws a call or result whose renderer slot is empty or fails. Direct constructors can attach the same shell with `withToolShell()` from `src/extensions/tool-presentation/shell.ts`; there is no second lifecycle implementation.
43
43
 
44
- `tool-view/chat.ts` owns the chat container that measures tool blocks for spacing and disposes rows when the chat clears. It reads each row's gap policy: upstream rows keep one blank line, while the distribution shell uses the compact policy above. Extension tools and built-in tools use the same shell unless they explicitly own a self shell.
44
+ `tool-view/chat.ts` owns the chat container that spaces tool blocks while rendering them, in one pass, and disposes rows when the chat clears. It reads each row's gap policy: upstream rows keep one blank line, while the distribution shell uses the compact policy above. Extension tools and built-in tools use the same shell unless they explicitly own a self shell.
45
45
 
46
46
  Built-in renderers remain responsible for semantic content such as file paths, syntax highlighting, search results, Diff previews, and command output. They return plain components; the native component passes them to the shell without wrapping their renderer functions. HTML export uses only those renderers and ignores the TUI shell, so it retains its existing output. Disable `builtin:tool-presentation` (for example with `-builtin:tool-presentation` in extension settings) to use the upstream Box presentation instead.
47
47
 
@@ -252,7 +252,7 @@ Return credentials with `refresh`, `access`, and `expires` (a millisecond timest
252
252
  `OAuthLoginCallbacks` provides these UI-neutral operations:
253
253
 
254
254
  - `onAuth({ url, instructions? })` opens/displays an authorization URL.
255
- - `onDeviceCode({ userCode, verificationUri, intervalSeconds?, expiresInSeconds? })` displays a device flow code.
255
+ - `onDeviceCode({ userCode, verificationUri, intervalSeconds?, expiresInSeconds? })` displays a device flow code. Pressing Enter (`tui.select.confirm`) opens the verification URL and copies the code; pass `openBrowserOnConfirm: false` or `copyCodeOnConfirm: false` to turn either action off.
256
256
  - `onPrompt({ message, placeholder?, allowEmpty? })` asks for text and resolves to the entered string.
257
257
  - `onSelect({ message, options: [{ id, label }] })` resolves to an option ID or `undefined`.
258
258
  - `onManualCodeInput?.()` optionally requests a manually pasted code.
@@ -83,11 +83,13 @@ These variables are read by Pi itself:
83
83
  | `PI_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
84
84
  | `PI_OFFLINE` | Disable startup network operations, including npm version checks, package update checks, and model refresh |
85
85
  | `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the npm registry latest-version request |
86
+ | `PI_SELF_UPDATE_COMMAND` | Command `pi update` runs to update Pi itself, split on whitespace, with `{packageName}`, `{version}`, and `{installSpec}` placeholders. Takes precedence over the `selfUpdateCommand` setting. See [Custom update command](usage.md#custom-update-command) |
86
87
  | `PI_TELEMETRY` | Override optional provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable version checks |
87
88
  | `PI_CODEMODE_MAX_WORKERS` | Maximum codemode workers alive at once across all sessions in the process; default `2`. Each worker's script may use up to 256 MB. Raise it when one process runs several sessions, such as in-process subagents. Further scripts wait for a free worker. See [Codemode](codemode.md) |
88
89
  | `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
89
90
  | `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
90
91
  | `PI_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads |
92
+ | `PI_CLEAR_ON_SHRINK` | Set to `1` to clear empty rows when rendered content shrinks; the `terminal.clearOnShrink` setting takes precedence. See [Settings](settings.md) |
91
93
  | `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
92
94
  | `PI_CLIPBOARD_OSC52` | Set to `1` to also send copied text to the terminal with OSC 52 after the local clipboard write, as Pi does over SSH. Use it when a remote client reaches Pi without SSH variables, such as a multiplexer attached from another machine or a remote IDE daemon |
93
95
  | `PI_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
@@ -143,7 +143,7 @@ To share extensions via npm or git as pi packages, see [packages.md](packages.md
143
143
  |---------|---------|
144
144
  | `@astralyn/pi` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) |
145
145
  | `typebox` | Schema definitions for tool parameters |
146
- | `@earendil-works/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums) |
146
+ | `@earendil-works/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums). Inside pi it also exports TypeBox's `Type`, `Static` and `TSchema`, which the published package no longer re-exports; import them from `typebox` in new code |
147
147
  | `@earendil-works/pi-agent-core` | Agent-core types for advanced integrations |
148
148
  | `@earendil-works/pi-tui` | TUI components for custom rendering |
149
149
 
@@ -153,6 +153,18 @@ For distributed pi packages installed with `pi install` (npm or git), runtime de
153
153
 
154
154
  Node.js built-ins (`node:fs`, `node:path`, etc.) are also available.
155
155
 
156
+ ### Tool parameter schemas and TypeBox
157
+
158
+ Pi validates tool arguments as JSON Schema with `@earendil-works/pi-schema`, whatever built the schema; TypeBox schemas are JSON Schema and work unchanged. Before validation, loosely typed arguments are coerced: numeric strings to numbers, `"true"` to `true`, a single value to a one-item array, `null` in an optional property dropped. TypeBox features outside JSON Schema do not apply to tool arguments:
159
+
160
+ - `Type.Refine()` refinements are not run. Check such constraints in `execute()`.
161
+ - `Type.BigInt()`, `Type.Undefined()` and `Type.Void()` reject every argument, since JSON has no such values. Codecs (`Type.Codec()`) do not decode: `execute()` receives the JSON value.
162
+ - Formats registered with TypeBox's `Format.Set()` are not checked. The standard formats are, plus `url` and `json-pointer-uri-fragment`.
163
+ - Property names are matched as names, not as regular expressions, and `additionalProperties` applies only to properties the object does not declare.
164
+ - A `$ref` that names nothing rejects only arguments at its place.
165
+
166
+ Validation errors the model sees use pi-schema's messages, such as `- path: missing` or `- limit: expected number, got string`, followed by field hints that name the legal fields and a bounded echo of the received arguments.
167
+
156
168
  ## Writing an Extension
157
169
 
158
170
  An extension exports a default factory function that receives `ExtensionAPI`. The factory can be synchronous or asynchronous:
@@ -1259,7 +1271,6 @@ Session-bound `TasksContext` supervises native and extension-owned execution. Fo
1259
1271
  |---|---|
1260
1272
  | `execute<T>(execution)` | Returns `{ kind: "result", result, status, error? }` or `{ kind: "background", task, reason }`, where `reason` is `"submitted"` when the caller asked for `background` and `"detached"` when it was moved while the work ran |
1261
1273
  | `list()` / `get(id)` | Bounded, read-only (frozen) retained snapshots; IDs support unique prefixes |
1262
- | `presentOutput(id, width, theme)` | The running task's live Output lines from its executor's `present` (below), or `undefined` for an unknown, settled or presenter-less task, or when the presenter throws. Hosts that render task Output, such as `/tasks`, call it on every repaint and use the default view when it returns nothing |
1263
1274
  | `read(id, options?)` | Bounded head, tail, or byte-offset model-readable output; excludes human-only display text. `options`: `mode`, `bytes`, `sinceBytes`. Without `mode`, a `report` is read from its start and a `log` from its end. With `sinceBytes`, `head` continues forward from that offset and `tail` keeps the newest window at or after it. Returned ranges and `endByte` use raw source bytes |
1264
1275
  | `kill(id)` | Requests cancellation; `stopping` is not a terminal status |
1265
1276
  | `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. Returns `false` / `0` while the host cannot supervise background work (see below) |
@@ -1273,13 +1284,12 @@ Session-bound `TasksContext` supervises native and extension-owned execution. Fo
1273
1284
  |---|---|
1274
1285
  | `label` | Human source name for the panel and completion card, such as `Bash` or `Agent`; defaults to `kind` |
1275
1286
  | `output` | `"log"` (default) or `"report"`. A log's outcome is at its end, so a background completion gives the model an 8 KiB tail, and `read()` returns its end unless `mode` says otherwise. A report leads with its conclusion, so it arrives from its beginning, whole when it fits the 48 KiB context budget, as its foreground result would, and `read()` returns its start unless `mode` says otherwise; a completed report renders as Markdown in `/tasks` |
1276
- | `input` | `{ label, text, truncated, language? }`: what the task was asked to do, such as a command or briefing. Shown in Details and the expanded completion card, highlighted when `language` is set |
1287
+ | `input` | `{ label, text, truncated, language? }`: what the task was asked to do, such as a command or briefing. Shown in `/tasks` Details, highlighted when `language` is set |
1277
1288
  | `facts` | Up to 16 labelled `[label, value]` Details rows, such as `["Directory", cwd]` |
1278
1289
  | `concurrency` | `{ key, limit }`: at most `limit` executions sharing `key` run at once. Lanes belong to one `kind`, so another executor can reuse the key. Later ones wait as `queued` tasks and `run` starts when a slot frees |
1279
1290
  | `background`, `signal`, `onUpdate` | Requested handoff, parent cancellation, and foreground progress forwarding |
1280
- | `present` | `(width, theme)` returning `string[]` or `undefined`: renders the running task's Output in `/tasks` with its own styling, such as colored columns or an elapsed time. Return lines already fitted to `width` (the panel clips any that are wider), or `undefined` for the default view. It runs synchronously on every repaint, so keep it cheap, and it must not return untrusted text without removing terminal sequences. It exists in memory for this execution only: never persisted, not part of any `TaskSnapshot`, dropped at settlement and absent after a restore. A throwing presenter is ignored. `display` stays the plain fallback for other consumers |
1281
1291
 
1282
- `kind` is an executor-owned source label matching `[a-z][a-z0-9-]{0,63}`; the runtime never dispatches on it. Presentation is declared data: the panel and completion card render `label`, `input`, `facts`, and `output` the same way for every executor. Input and facts restore with terminal task history; facts also appear in the completion notification. At most eight background executions, queued ones included, are retained as active at once; foreground executions are not limited by them. Foreground and background results have separate history quotas.
1292
+ `kind` is an executor-owned source label matching `[a-z][a-z0-9-]{0,63}`; the runtime never dispatches on it. Presentation is declared data: the panel renders `label`, `input`, `facts`, and `output` the same way for every executor, and the completion notification shows only the label, outcome, title and error. Input and facts restore with terminal task history; facts also appear in the model-facing completion text. At most eight background executions, queued ones included, are retained as active at once; foreground executions are not limited by them. Foreground and background results have separate history quotas.
1283
1293
 
1284
1294
  A caller can be handed off to the background while its task is queued, before `run` starts, or after `run` calls `accept()`. A release requested while `run` is still preparing (a `background: true` submission, or a user detach) waits for `accept()`; if `run` settles first, the caller gets the result inline and the task stays `foreground`. `mode` is therefore `background` exactly when the caller was released with a background outcome. A queued task becomes `running` when its `run` starts; cancelling it settles it as `cancelled` without starting it.
1285
1295
 
@@ -1289,6 +1299,8 @@ Background work is admitted, submitted or detached, only while the host can supe
1289
1299
 
1290
1300
  `TaskControl<T>` exposes `id`, `signal`, `mode`, `onModeChange(listener)`, `accept()`, `publish(update)`, `attachOutput(path, cleanup?)`, and `cancel()`. `publish({ result, display?, usage? })` replaces the bounded model-readable result and optionally the live human-only display and cumulative usage; while it runs `/tasks` shows the display in place of the result, while model reads and completion notifications use only the result. A task with an attached output file is read from that file instead. Call `accept()` after whole-invocation preflight, before allowing a background handoff; `onModeChange` listeners run when the mode becomes `background`. 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.
1291
1301
 
1302
+ A live `display` can be a string or a `TaskDisplay`: `{ text, truncated, activities?, earlierActivities? }`. The text is always the portable fallback. Each optional `TaskActivity` is `{ name, target?, status, startedAt?, durationMs?, error? }`, where `status` is `running`, `ok`, `error`, or `cancelled`; times are epoch/elapsed milliseconds. `/tasks` renders retained activities with the shared themed status markers, fitted columns, failure excerpts, and repaint-time running durations, using `earlierActivities` for the omitted-count line. The runtime bounds and freezes this data just like text; it stores no renderer or Theme dependency. Structured activities are live-only: settlement replaces or clears the progress display exactly as for a string display, and persisted terminal displays remain `{ text, truncated }`.
1303
+
1292
1304
  Completion messages store `{ version: 3, task }` in `details`, a bounded terminal `TaskSnapshot`; only their bounded `content` enters model context. Reads do not acknowledge delivery, and arbitrary tool-result detail fields cannot acknowledge a task. An undelivered completion is a retention lease the session holds on its task: the record and its output stay available until the model has it, and a runtime embedded without a session never holds one, so its settled records are ordinary bounded history.
1293
1305
 
1294
1306
  ```typescript
@@ -1911,6 +1923,7 @@ The transformer receives the Markdown string and a context with:
1911
1923
  - `messageType` — `"user"`, `"assistant"`, or `"assistant-thinking"`
1912
1924
  - `isStreaming` — `true` for partial assistant updates; `false` for user, finalized assistant, and restored messages
1913
1925
  - `availableWidth` — exact terminal columns available for the transformed Markdown content
1926
+ - `messageId`, `timestamp` — session-entry ID and ISO timestamp when rendering from persisted session entries; `undefined` for live messages
1914
1927
 
1915
1928
  Return the transformed Markdown:
1916
1929
 
@@ -1943,6 +1956,8 @@ pi.registerEntryRenderer("status-card", (entry, { expanded }, theme) => {
1943
1956
  pi.appendEntry("status-card", { title: "Indexed files", count: 17 });
1944
1957
  ```
1945
1958
 
1959
+ `options.expanded` follows the transcript's expand toggle. `options.outputPad` is the horizontal padding from the `outputPad` setting; inset unboxed content by it to line up with the rest of the transcript.
1960
+
1946
1961
  ### pi.registerShortcut(shortcut, options)
1947
1962
 
1948
1963
  Register a keyboard shortcut. See [keybindings.md](keybindings.md) for the shortcut format and built-in keybindings.
@@ -1975,13 +1990,15 @@ if (profile) {
1975
1990
 
1976
1991
  ### pi.exec(command, args, options?)
1977
1992
 
1978
- Execute a shell command.
1993
+ Execute a command without a shell.
1979
1994
 
1980
1995
  ```typescript
1981
1996
  const result = await pi.exec("git", ["status"], { signal, timeout: 5000 });
1982
- // result.stdout, result.stderr, result.code, result.killed
1997
+ // result.stdout, result.stderr, result.code, result.killed, result.truncated
1983
1998
  ```
1984
1999
 
2000
+ Options: `signal` and `timeout` terminate the command, `cwd` sets the working directory, and `maxBuffer` limits stdout and stderr combined (default 256 MiB). When output exceeds `maxBuffer`, pi terminates the command and returns the output up to the limit with `truncated: true`, `killed: true`, and a nonzero `code`. `killed` is true whenever pi terminated the command: timeout, abort, or `maxBuffer`. A command that ignores SIGTERM gets SIGKILL after 5 seconds.
2001
+
1985
2002
  ### pi.getActiveTools() / pi.getAllTools() / pi.setActiveTools(names)
1986
2003
 
1987
2004
  Manage active tools. This works for both built-in tools and dynamically registered tools. `pi.getActiveTools()` returns the active tool names as `string[]`; `pi.getAllTools()` returns metadata for all configured tools.
@@ -2566,7 +2583,7 @@ By default, tool output is wrapped in the active call/result shell, which owns t
2566
2583
 
2567
2584
  Set `renderShell: "self"` when the tool should render its own shell instead of using the native shell. This is useful for tools that need complete control over framing or background behavior, for example large previews that must stay visually stable after the tool settles.
2568
2585
 
2569
- For live progress UI (elapsed time, retry countdowns), schedule repaints from the renderer itself: store a timer handle in `context.state`, arm a `setTimeout` that calls `context.invalidate()` only while the current view contains changing text, and clear it on the first static or settled render. Set `context.state.dispose` to the same idempotent cleanup function when a timer may still be armed; the shell invokes it when the row is disposed.
2586
+ For live progress UI (elapsed time, retry countdowns), schedule repaints from the renderer itself: store a timer handle in `context.state`, arm a `setTimeout` that calls `context.invalidate()` only while the current view contains changing text, and clear it on the first static or settled render. When you arm a timer, register its cleanup with `context.onDispose(cleanup)`: the shell runs it once when the row is disposed, or immediately if the row already was. Register when you create the resource rather than on every render.
2570
2587
 
2571
2588
  Derive displayed time from an absolute timestamp or deadline (`Date.now()`), not by decrementing a counter on every refresh. A refresh is only a repaint opportunity; event-loop stalls and machine sleep must not extend a wall-clock timeout.
2572
2589
 
@@ -2588,13 +2605,15 @@ pi.registerTool({
2588
2605
 
2589
2606
  `renderCall` and `renderResult` each receive a `context` object with:
2590
2607
  - `args` - the current tool call arguments
2591
- - `state` - shared row-local state across `renderCall` and `renderResult`; an optional `dispose()` cleanup is called when the row is disposed
2608
+ - `state` - shared row-local state across `renderCall` and `renderResult`
2609
+ - `onDispose(cleanup)` - run `cleanup` once when the row is disposed, such as clearing a refresh timer; a cleanup that throws does not affect the row or its siblings
2592
2610
  - `lastComponent` - the previously returned component for that slot, if any
2593
2611
  - `invalidate()` - request a rerender of this tool row
2594
2612
  - `toolCallId`, `cwd`, `executionStarted`, `argsComplete`, `isPartial`, `expanded`, `showImages`, `isError`
2595
2613
  - `durationMs` - how long the tool's execution took, from the final result; `undefined` while it runs, when it did not run, or for results stored before durations were recorded
2596
2614
  - `outputPad` - horizontal padding from the `outputPad` setting; renderers with `renderShell: "self"` apply it themselves
2597
2615
  - `result` - the current partial or final result, if one has arrived
2616
+ - `keyText()`, `keyHint()` - format the user's configured keybindings, see [Keybinding Hints](#keybinding-hints)
2598
2617
 
2599
2618
  Use `context.state` for cross-slot shared state. Keep slot-local caches on the returned component instance when you want to reuse and mutate the same component across renders.
2600
2619
 
@@ -2645,24 +2664,24 @@ If a slot intentionally has no visible content, return an empty `Component` such
2645
2664
 
2646
2665
  #### Keybinding Hints
2647
2666
 
2648
- Use `keyHint()` to display keybinding hints that respect the active keybinding configuration:
2667
+ Use `keyHint()` and `keyText()` from the render context to display keybinding hints that respect the user's keybinding configuration:
2649
2668
 
2650
2669
  ```typescript
2651
- import { keyHint } from "@astralyn/pi";
2652
-
2653
2670
  renderResult(result, { expanded }, theme, context) {
2654
2671
  let text = theme.fg("success", "✓ Done");
2655
2672
  if (!expanded) {
2656
- text += ` (${keyHint("app.tools.expand", "to expand")})`;
2673
+ text += ` (${context.keyHint("app.tools.expand", "to expand")})`;
2657
2674
  }
2658
2675
  return new Text(text, 0, 0);
2659
2676
  }
2660
2677
  ```
2661
2678
 
2662
- Available functions:
2663
- - `keyHint(keybinding, description)` - Formats a configured keybinding id such as `"app.tools.expand"` or `"tui.select.confirm"`
2664
- - `keyText(keybinding)` - Returns the raw configured key text for a keybinding id
2665
- - `rawKeyHint(key, description)` - Format a raw key string
2679
+ The same functions are available as `options.keyHint()`/`options.keyText()` in message and entry renderers:
2680
+
2681
+ - `keyHint(keybinding, description)` - Formats a configured keybinding id such as `"app.tools.expand"` or `"tui.select.confirm"`, followed by the description
2682
+ - `keyText(keybinding)` - Returns the raw configured key text for a keybinding id, or `""` if the id has no keys
2683
+
2684
+ In renderers, use these instead of importing `keyHint()` or `keyText()` from `@astralyn/pi`. An extension can resolve its own copy of the package, for example from its own `node_modules`, and that copy does not see pi's configured keybindings: `app.*` ids then format as `""`. `rawKeyHint(key, description)` formats a literal key string and is safe to import.
2666
2685
 
2667
2686
  Use namespaced keybinding ids:
2668
2687
  - Coding-agent ids use the `app.*` namespace, for example `app.tools.expand`, `app.editor.external`, `app.session.rename`
@@ -2814,7 +2833,6 @@ Extensions can interact with users via `ctx.ui` methods and customize how messag
2814
2833
  - Status indicators (setStatus)
2815
2834
  - Working message, visibility, and indicator during streaming (`setWorkingMessage`, `setWorkingVisible`, `setWorkingIndicator`)
2816
2835
  - Widgets above/below editor (setWidget)
2817
- - Ephemeral transcript notes (addTranscriptNote)
2818
2836
  - Autocomplete providers layered on top of built-in slash/path completion (addAutocompleteProvider)
2819
2837
  - Custom footers (setFooter)
2820
2838
 
@@ -2987,9 +3005,6 @@ ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"], { placement: "belowEditor" }
2987
3005
  ctx.ui.setWidget("my-widget", (tui, theme) => new Text(theme.fg("accent", "Custom"), 0, 0));
2988
3006
  ctx.ui.setWidget("my-widget", undefined); // Clear
2989
3007
 
2990
- // Ephemeral note after a session entry; not persisted or sent to the model
2991
- ctx.ui.addTranscriptNote("my-note", "Worked for 8s", { afterEntryId: ctx.sessionManager.getLeafId()! });
2992
-
2993
3008
  // Custom footer (replaces built-in footer entirely)
2994
3009
  ctx.ui.setFooter((_tui, theme, footerData) => ({
2995
3010
  render(_width) {
@@ -3245,6 +3260,8 @@ pi.registerMessageRenderer("my-extension", (message, options, theme) => {
3245
3260
 
3246
3261
  if (expanded && message.details) {
3247
3262
  text += "\n" + theme.fg("dim", JSON.stringify(message.details, null, 2));
3263
+ } else if (message.details) {
3264
+ text += ` (${options.keyHint("app.tools.expand", "to expand")})`;
3248
3265
  }
3249
3266
 
3250
3267
  return new Text(text, outputPad, 0);
@@ -90,7 +90,7 @@ These actions apply when interactive mode uses `--tui-mode fullscreen` and targe
90
90
 
91
91
  Hold Alt while scrolling the mouse wheel for five-times-faster scrolling. Hovering over autocomplete or settings lists keeps their selection and scroll position unchanged; click an item to select it.
92
92
 
93
- Fullscreen transcript bindings take precedence over editor bindings using the same key. `pageUp` and `pageDown` therefore control the transcript in fullscreen mode while their `ctrl` variants keep controlling the editor; `home` and `end` always control the editor, while `ctrl+home` and `ctrl+end` control the transcript in fullscreen mode. Outside fullscreen mode, all of these keys control the editor.
93
+ Fullscreen transcript bindings take precedence over editor bindings using the same key. `pageUp` and `pageDown` therefore control the transcript in fullscreen mode while their `ctrl` variants keep controlling the editor; `home` and `end` always control the editor, while `ctrl+home` and `ctrl+end` control the transcript in fullscreen mode. Outside fullscreen mode, all of these keys control the editor. While an overlay or a scrollable list such as autocomplete, `/settings`, or the model selector has focus, the scrolling and prompt-jump actions go to it instead of the transcript, so `tui.select.pageUp` and `tui.select.pageDown` move the list selection. Transcript search actions keep working.
94
94
 
95
95
  | Key | Default mode | Fullscreen mode |
96
96
  |-----|--------------|-----------------|
package/docs/llama-cpp.md CHANGED
@@ -1,31 +1,36 @@
1
1
  # llama.cpp
2
2
 
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.
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://llama.app) router server, which discovers multiple GGUF models and loads or unloads them on demand.
4
4
 
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.
5
+ ## Install llama.cpp
6
+
7
+ Install llama.cpp with the [official installer](https://llama.app/docs/installation):
8
+
9
+ ```bash
10
+ curl -LsSf https://llama.app/install.sh | sh
11
+ ```
12
+
13
+ Verify the installation with `llama cli --version`. See [llama.app](https://llama.app) for other installation methods, including package managers and building from source.
6
14
 
7
15
  ## Start the router
8
16
 
9
- Start `llama-server` without `--model` or `-m`. Passing a model starts single-model mode instead of router mode.
17
+ Start `llama serve` without `--model`, `-m`, or `-hf`. Passing a model starts single-model mode instead of router mode. See the [llama.cpp server guide](https://llama.app/docs/serve#serving-multiple-models-router-mode) for router configuration.
10
18
 
11
19
  ```bash
12
- llama-server \
13
- --models-dir ~/models \
20
+ llama serve \
14
21
  --no-models-autoload \
15
- --jinja \
16
22
  --host 127.0.0.1 \
17
23
  --port 8080 \
18
- -ngl 999 \
24
+ -ngl all \
19
25
  -c 32768
20
26
  ```
21
27
 
22
28
  Important options:
23
29
 
24
- - `--models-dir ~/models` discovers local GGUF files.
25
30
  - `--no-models-autoload` keeps loading explicit through `/llama`.
26
31
  - `--jinja` enables compatible chat templates and tool calling.
27
- - `-ngl 999` offloads as many layers as possible to the GPU.
28
- - `-c 32768` sets the context window for each loaded model. Omit it to use the model's native context, which may require substantially more memory.
32
+ - `-ngl all` offloads all layers to the GPU. Omit it to use automatic GPU offloading.
33
+ - `-c 32768` sets the context size in tokens. Use `-c 0` for the model's full context window, which may require substantially more memory. Context is shared across parallel server slots.
29
34
 
30
35
  A single-file model can sit directly in the model directory. Put multimodal and multi-shard models in separate subdirectories:
31
36
 
@@ -41,7 +46,7 @@ A single-file model can sit directly in the model directory. Put multimodal and
41
46
  └── large-model-Q4_K_M-00003-of-00003.gguf
42
47
  ```
43
48
 
44
- Restart the router after manually adding files. For per-model context sizes and other options, use [llama.cpp model presets](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md#model-presets). For settings tuned to a specific NVIDIA GPU and model, see [Run Pi with NVIDIA RTX and llama.cpp](nvidia-rtx-llama-cpp.md).
49
+ Restart the router after manually adding files. The router also supports cached models and preset files via `--models-preset`, as described in the [server guide](https://llama.app/docs/serve#serving-multiple-models-router-mode). For settings tuned to a specific NVIDIA GPU and model, see [Run Pi with NVIDIA RTX and llama.cpp](nvidia-rtx-llama-cpp.md).
45
50
 
46
51
  ## Configure Pi
47
52
 
@@ -63,7 +68,7 @@ export LLAMA_API_KEY=optional-secret
63
68
  pi
64
69
  ```
65
70
 
66
- If the server uses an API key, start `llama-server` with the matching `--api-key` value. Keep `--host 127.0.0.1` for local-only access.
71
+ If the server uses an API key, start `llama serve` with the matching `--api-key` value. Keep `--host 127.0.0.1` for local-only access.
67
72
 
68
73
  ## Manage models
69
74