@ashx-j/lunr-dev 0.2.13-dev.8.1 → 0.2.16-dev.9.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 (339) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/dist/builtin-extensions/ashxj-tui.d.ts +14 -0
  3. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  4. package/dist/builtin-extensions/ashxj-tui.js +37 -3
  5. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  6. package/dist/builtin-extensions/index.d.ts +1 -15
  7. package/dist/builtin-extensions/index.d.ts.map +1 -1
  8. package/dist/builtin-extensions/index.js +7 -21
  9. package/dist/builtin-extensions/index.js.map +1 -1
  10. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
  11. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +6 -2
  12. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
  13. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +4 -0
  14. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
  15. package/dist/builtin-extensions/pi-lsp-extension/src/index.js +163 -169
  16. package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
  17. package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts +46 -0
  18. package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts.map +1 -0
  19. package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js +109 -0
  20. package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js.map +1 -0
  21. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts +7 -0
  22. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -0
  23. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +211 -0
  24. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -0
  25. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +0 -5
  26. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
  27. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +0 -202
  28. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
  29. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
  30. package/dist/builtin-extensions/pi-mcp-adapter/index.js +251 -94
  31. package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
  32. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +4 -1
  33. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
  34. package/dist/builtin-extensions/pi-mcp-adapter/init.js +10 -3
  35. package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
  36. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts.map +1 -1
  37. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js +6 -1
  38. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js.map +1 -1
  39. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
  40. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +2 -1
  41. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
  42. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +1 -1
  43. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
  44. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +1 -1
  45. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
  46. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
  47. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  48. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +38 -14
  49. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -1
  51. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -1
  53. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  55. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +1 -1
  56. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  57. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -1
  58. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  59. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +2 -1
  60. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  61. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +1 -1
  62. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
  63. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +2 -1
  64. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
  65. package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
  66. package/dist/builtin-extensions/pi-web-access/extract.js +105 -54
  67. package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
  68. package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +1 -1
  69. package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -1
  70. package/dist/builtin-extensions/pi-web-access/gemini-search.js +82 -65
  71. package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -1
  72. package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
  73. package/dist/builtin-extensions/pi-web-access/github-extract.js +2 -0
  74. package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
  75. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  76. package/dist/builtin-extensions/pi-web-access/index.js +167 -77
  77. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  78. package/dist/builtin-extensions/pi-web-access/lazy.d.ts +18 -0
  79. package/dist/builtin-extensions/pi-web-access/lazy.d.ts.map +1 -0
  80. package/dist/builtin-extensions/pi-web-access/lazy.js +19 -0
  81. package/dist/builtin-extensions/pi-web-access/lazy.js.map +1 -0
  82. package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +6 -0
  83. package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -0
  84. package/dist/builtin-extensions/pi-web-access/session-cleanup.js +17 -0
  85. package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -0
  86. package/dist/catalog/publication.json +12 -12
  87. package/dist/cli-runtime.d.ts +3 -0
  88. package/dist/cli-runtime.d.ts.map +1 -0
  89. package/dist/cli-runtime.js +73 -0
  90. package/dist/cli-runtime.js.map +1 -0
  91. package/dist/cli.d.ts.map +1 -1
  92. package/dist/cli.js +14 -53
  93. package/dist/cli.js.map +1 -1
  94. package/dist/config.d.ts +1 -0
  95. package/dist/config.d.ts.map +1 -1
  96. package/dist/config.js +1 -0
  97. package/dist/config.js.map +1 -1
  98. package/dist/core/agent-session.d.ts +3 -0
  99. package/dist/core/agent-session.d.ts.map +1 -1
  100. package/dist/core/agent-session.js +56 -12
  101. package/dist/core/agent-session.js.map +1 -1
  102. package/dist/core/compaction/compaction.d.ts.map +1 -1
  103. package/dist/core/compaction/compaction.js +10 -5
  104. package/dist/core/compaction/compaction.js.map +1 -1
  105. package/dist/core/extensions/host-static.d.ts.map +1 -1
  106. package/dist/core/extensions/host-static.js +34 -12
  107. package/dist/core/extensions/host-static.js.map +1 -1
  108. package/dist/core/extensions/loader.d.ts +1 -2
  109. package/dist/core/extensions/loader.d.ts.map +1 -1
  110. package/dist/core/extensions/loader.js +10 -64
  111. package/dist/core/extensions/loader.js.map +1 -1
  112. package/dist/core/extensions/types.d.ts +2 -2
  113. package/dist/core/extensions/types.d.ts.map +1 -1
  114. package/dist/core/extensions/types.js.map +1 -1
  115. package/dist/core/footer-data-provider.d.ts.map +1 -1
  116. package/dist/core/footer-data-provider.js +2 -0
  117. package/dist/core/footer-data-provider.js.map +1 -1
  118. package/dist/core/permissions.d.ts +0 -2
  119. package/dist/core/permissions.d.ts.map +1 -1
  120. package/dist/core/permissions.js +10 -18
  121. package/dist/core/permissions.js.map +1 -1
  122. package/dist/core/sdk.d.ts +1 -1
  123. package/dist/core/sdk.d.ts.map +1 -1
  124. package/dist/core/sdk.js +1 -1
  125. package/dist/core/sdk.js.map +1 -1
  126. package/dist/core/slash-commands.d.ts.map +1 -1
  127. package/dist/core/slash-commands.js +0 -1
  128. package/dist/core/slash-commands.js.map +1 -1
  129. package/dist/core/timings.d.ts +2 -1
  130. package/dist/core/timings.d.ts.map +1 -1
  131. package/dist/core/timings.js +17 -2
  132. package/dist/core/timings.js.map +1 -1
  133. package/dist/gateway/commands.d.ts +1 -1
  134. package/dist/gateway/commands.d.ts.map +1 -1
  135. package/dist/gateway/commands.js +1 -18
  136. package/dist/gateway/commands.js.map +1 -1
  137. package/dist/main.d.ts +2 -2
  138. package/dist/main.d.ts.map +1 -1
  139. package/dist/main.js +57 -48
  140. package/dist/main.js.map +1 -1
  141. package/dist/modes/interactive/interactive-mode.d.ts +12 -21
  142. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  143. package/dist/modes/interactive/interactive-mode.js +120 -144
  144. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  145. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  146. package/dist/modes/interactive/theme/theme.js +95 -84
  147. package/dist/modes/interactive/theme/theme.js.map +1 -1
  148. package/dist/node-runtime/agent-session-services-IFJMSX7Z.js +36 -0
  149. package/dist/node-runtime/benchmark-request-UC7PD3V3.js +57 -0
  150. package/dist/node-runtime/brave-UWDA3I22.js +143 -0
  151. package/dist/node-runtime/builtin-extensions-LYZ3BFWQ.js +28 -0
  152. package/dist/node-runtime/chunk-2QKLKMKC.js +173 -0
  153. package/dist/node-runtime/chunk-3GHXVUAK.js +21 -0
  154. package/dist/node-runtime/chunk-3RCWXWAY.js +466 -0
  155. package/dist/node-runtime/chunk-3WFAEVKS.js +115 -0
  156. package/dist/node-runtime/chunk-3X3KZKMI.js +49 -0
  157. package/dist/node-runtime/chunk-4HXHDDCF.js +16 -0
  158. package/dist/node-runtime/chunk-4TLO4PO2.js +3427 -0
  159. package/dist/node-runtime/chunk-4ZWGEEAS.js +69 -0
  160. package/dist/node-runtime/chunk-53YJI7JU.js +137 -0
  161. package/dist/node-runtime/chunk-5P7PZMRU.js +610 -0
  162. package/dist/node-runtime/chunk-7N3YHTYF.js +26 -0
  163. package/dist/node-runtime/chunk-7NBZ5P7I.js +24 -0
  164. package/dist/node-runtime/chunk-A2KQXUJD.js +105 -0
  165. package/dist/node-runtime/chunk-AD6VXAO7.js +342 -0
  166. package/dist/node-runtime/chunk-AHSTJBIB.js +64 -0
  167. package/dist/node-runtime/chunk-AJX357CL.js +20211 -0
  168. package/dist/node-runtime/chunk-ARC4KOTI.js +11178 -0
  169. package/dist/node-runtime/chunk-AUXVGBO4.js +19 -0
  170. package/dist/node-runtime/chunk-AY6CAJSL.js +30 -0
  171. package/dist/node-runtime/chunk-BHO7O6E5.js +296 -0
  172. package/dist/node-runtime/chunk-BI3DHYCN.js +8845 -0
  173. package/dist/node-runtime/chunk-BR7YDUKA.js +109 -0
  174. package/dist/node-runtime/chunk-BRJX2PRC.js +53 -0
  175. package/dist/node-runtime/chunk-C4O2RSQQ.js +37 -0
  176. package/dist/node-runtime/chunk-CCZJ3PYY.js +17 -0
  177. package/dist/node-runtime/chunk-CDFZEWPU.js +8388 -0
  178. package/dist/node-runtime/chunk-CGBXPL3E.js +1171 -0
  179. package/dist/node-runtime/chunk-CJECDQKP.js +19 -0
  180. package/dist/node-runtime/chunk-DAPBPCBP.js +53 -0
  181. package/dist/node-runtime/chunk-DDGMHUOW.js +305 -0
  182. package/dist/node-runtime/chunk-DMMTJQMQ.js +43 -0
  183. package/dist/node-runtime/chunk-DVGWF6A2.js +1180 -0
  184. package/dist/node-runtime/chunk-ECD5L7YI.js +1369 -0
  185. package/dist/node-runtime/chunk-EDBJNRSM.js +46 -0
  186. package/dist/node-runtime/chunk-F4VQFJI2.js +1269 -0
  187. package/dist/node-runtime/chunk-FVDOXRUD.js +96 -0
  188. package/dist/node-runtime/chunk-GZQHMEWL.js +126 -0
  189. package/dist/node-runtime/chunk-H2EOZYMP.js +57 -0
  190. package/dist/node-runtime/chunk-HQCKFM2O.js +56 -0
  191. package/dist/node-runtime/chunk-HYHJIRDW.js +19 -0
  192. package/dist/node-runtime/chunk-I6R76AG7.js +22 -0
  193. package/dist/node-runtime/chunk-IPA627GP.js +296 -0
  194. package/dist/node-runtime/chunk-JHYKXIMM.js +378 -0
  195. package/dist/node-runtime/chunk-KKSIVROT.js +88 -0
  196. package/dist/node-runtime/chunk-LZAW4ZX3.js +633 -0
  197. package/dist/node-runtime/chunk-M3LZLQW2.js +98 -0
  198. package/dist/node-runtime/chunk-MGWCVY6Y.js +47 -0
  199. package/dist/node-runtime/chunk-MJQDX3BA.js +72 -0
  200. package/dist/node-runtime/chunk-MKKH27PH.js +8956 -0
  201. package/dist/node-runtime/chunk-MX3GJNXJ.js +986 -0
  202. package/dist/node-runtime/chunk-N77MY65L.js +966 -0
  203. package/dist/node-runtime/chunk-NUIFPZWX.js +209 -0
  204. package/dist/node-runtime/chunk-OBMWP3I5.js +68 -0
  205. package/dist/node-runtime/chunk-OR4L3IB2.js +42 -0
  206. package/dist/node-runtime/chunk-PBC2Y6GS.js +903 -0
  207. package/dist/node-runtime/chunk-PCGNAY2O.js +1324 -0
  208. package/dist/node-runtime/chunk-PCIGF2XK.js +250 -0
  209. package/dist/node-runtime/chunk-PGAJ5MO5.js +7558 -0
  210. package/dist/node-runtime/chunk-PL6JKXWI.js +3622 -0
  211. package/dist/node-runtime/chunk-PVCDKGR6.js +55 -0
  212. package/dist/node-runtime/chunk-Q4Q6D4IY.js +364 -0
  213. package/dist/node-runtime/chunk-Q5ZU2VRT.js +83 -0
  214. package/dist/node-runtime/chunk-QFWG2RVL.js +5477 -0
  215. package/dist/node-runtime/chunk-QH42CDX3.js +9451 -0
  216. package/dist/node-runtime/chunk-RQ2Q5IYR.js +72 -0
  217. package/dist/node-runtime/chunk-RQ5DNUNG.js +429 -0
  218. package/dist/node-runtime/chunk-RRIZE6QQ.js +17 -0
  219. package/dist/node-runtime/chunk-SN6G4OU6.js +4753 -0
  220. package/dist/node-runtime/chunk-SWSN6HAB.js +53 -0
  221. package/dist/node-runtime/chunk-TQNSPERU.js +949 -0
  222. package/dist/node-runtime/chunk-VRB2IYGG.js +53 -0
  223. package/dist/node-runtime/chunk-VSELYKWU.js +772 -0
  224. package/dist/node-runtime/chunk-W3CVH5RX.js +62 -0
  225. package/dist/node-runtime/chunk-WJVFOIB5.js +24921 -0
  226. package/dist/node-runtime/chunk-WOVTOV5P.js +5653 -0
  227. package/dist/node-runtime/chunk-XBWPBZBN.js +125 -0
  228. package/dist/node-runtime/chunk-XTHQ7XR7.js +509 -0
  229. package/dist/node-runtime/chunk-YF63P5ZT.js +864 -0
  230. package/dist/node-runtime/chunk-YSKSB3BJ.js +295 -0
  231. package/dist/node-runtime/chunk-ZCHMJ34K.js +130 -0
  232. package/dist/node-runtime/chunk-ZKMFUD3Q.js +2834 -0
  233. package/dist/node-runtime/cli-runtime.js +81 -0
  234. package/dist/node-runtime/clipboard-OZ63BBC6.js +12 -0
  235. package/dist/node-runtime/clipboard-image-7QR6GXVA.js +13 -0
  236. package/dist/node-runtime/command-L3LAHDIH.js +13 -0
  237. package/dist/node-runtime/commands-RL5YBW5I.js +291 -0
  238. package/dist/node-runtime/config-FMEOZSWE.js +77 -0
  239. package/dist/node-runtime/curator-server-XCM43VEF.js +3816 -0
  240. package/dist/node-runtime/customize-XEXL2DGQ.js +12 -0
  241. package/dist/node-runtime/direct-tool-executor-JVDXTO7A.js +188 -0
  242. package/dist/node-runtime/exa-LL64QZR2.js +329 -0
  243. package/dist/node-runtime/export-html-KR26FOUZ.js +150 -0
  244. package/dist/node-runtime/extension-input-RV5N6APL.js +14 -0
  245. package/dist/node-runtime/extension-selector-CPD5LWDD.js +14 -0
  246. package/dist/node-runtime/extract-XLQSJN4V.js +17 -0
  247. package/dist/node-runtime/file-sync-HCOP2QVF.js +117 -0
  248. package/dist/node-runtime/gateway-X2TI5X7F.js +2484 -0
  249. package/dist/node-runtime/gemini-api-QE7ANVDZ.js +29 -0
  250. package/dist/node-runtime/gemini-search-U7SUMPQA.js +330 -0
  251. package/dist/node-runtime/gemini-url-context-PXWCBQHK.js +103 -0
  252. package/dist/node-runtime/gemini-web-MM446SEH.js +14 -0
  253. package/dist/node-runtime/github-extract-F64RZOEA.js +619 -0
  254. package/dist/node-runtime/goal-CZQ7FFQJ.js +1831 -0
  255. package/dist/node-runtime/index.js +859 -0
  256. package/dist/node-runtime/init-NJV2T55N.js +28 -0
  257. package/dist/node-runtime/install-cli-TH7IJJQQ.js +308 -0
  258. package/dist/node-runtime/interactive-mode-KOM35YF2.js +56 -0
  259. package/dist/node-runtime/interactive-view-U6OILKF3.js +249 -0
  260. package/dist/node-runtime/lsp-manager-3ASUSO4T.js +1104 -0
  261. package/dist/node-runtime/lunr-cron-YJ5UHYRD.js +268 -0
  262. package/dist/node-runtime/main.js +54 -0
  263. package/dist/node-runtime/mcp-auth-flow-QIXHW6QN.js +32 -0
  264. package/dist/node-runtime/mcp-panel-IIGMXQGP.js +501 -0
  265. package/dist/node-runtime/mcp-setup-panel-FEK7663I.js +355 -0
  266. package/dist/node-runtime/memory-cap-3S4XRLNP.js +20 -0
  267. package/dist/node-runtime/model-tiers-NJLHUEGK.js +20 -0
  268. package/dist/node-runtime/openai-search-B3MSNCQA.js +288 -0
  269. package/dist/node-runtime/package-manager-cli-TZZHJCVI.js +749 -0
  270. package/dist/node-runtime/parallel-AI2MNSCU.js +265 -0
  271. package/dist/node-runtime/parser-manager-TQHWYDH7.js +152 -0
  272. package/dist/node-runtime/pdf-extract-IPE6H4HP.js +57 -0
  273. package/dist/node-runtime/perplexity-QVJW3I35.js +12 -0
  274. package/dist/node-runtime/pi-intercom-EEMBGQID.js +2215 -0
  275. package/dist/node-runtime/pi-mcp-adapter-QFB37AVN.js +422 -0
  276. package/dist/node-runtime/pi-ollama-cloud-4VZRMULP.js +1440 -0
  277. package/dist/node-runtime/pi-prompt-template-model-4QT4LLXF.js +3946 -0
  278. package/dist/node-runtime/pi-subagents-7XJ4H53P.js +6023 -0
  279. package/dist/node-runtime/pi-web-access-DPGAVKOA.js +1864 -0
  280. package/dist/node-runtime/print-mode-VWIRFDAC.js +12 -0
  281. package/dist/node-runtime/proxy-modes-HEEFK4KC.js +685 -0
  282. package/dist/node-runtime/rpc-entry.js +62 -0
  283. package/dist/node-runtime/rpc-mode-SJNSOA4G.js +13 -0
  284. package/dist/node-runtime/runtime-bridges-PPHNBFWL.js +14 -0
  285. package/dist/node-runtime/session-manager-MQNBYACL.js +35 -0
  286. package/dist/node-runtime/session-selector-5AZLJS6U.js +14 -0
  287. package/dist/node-runtime/settings-manager-5LF2VQWC.js +21 -0
  288. package/dist/node-runtime/src-Y7JSCK64.js +2407 -0
  289. package/dist/node-runtime/subagent-executor-5RNDEPIJ.js +8483 -0
  290. package/dist/node-runtime/summary-review-YSMXKITO.js +228 -0
  291. package/dist/node-runtime/tavily-WEZFVFP7.js +154 -0
  292. package/dist/node-runtime/timings-UAD5BEAS.js +16 -0
  293. package/dist/node-runtime/tool-renderer-MV5O452K.js +204 -0
  294. package/dist/node-runtime/update-cli-A253SZ7P.js +73 -0
  295. package/dist/node-runtime/v4-5MNC3H7G.js +424 -0
  296. package/dist/node-runtime/video-extract-OYT5WKS5.js +304 -0
  297. package/dist/node-runtime/workspace-index-6DBXSTJ6.js +163 -0
  298. package/dist/node-runtime/youtube-extract-TQYKGFGS.js +264 -0
  299. package/dist/startup/benchmark-request.d.ts +3 -0
  300. package/dist/startup/benchmark-request.d.ts.map +1 -0
  301. package/dist/startup/benchmark-request.js +65 -0
  302. package/dist/startup/benchmark-request.js.map +1 -0
  303. package/dist/startup/interactive-view.d.ts +55 -0
  304. package/dist/startup/interactive-view.d.ts.map +1 -0
  305. package/dist/startup/interactive-view.js +332 -0
  306. package/dist/startup/interactive-view.js.map +1 -0
  307. package/dist/startup/launch-routing.d.ts.map +1 -1
  308. package/dist/startup/launch-routing.js +9 -10
  309. package/dist/startup/launch-routing.js.map +1 -1
  310. package/dist/startup/startup-milestones.d.ts +1 -1
  311. package/dist/startup/startup-milestones.d.ts.map +1 -1
  312. package/dist/startup/startup-milestones.js +3 -2
  313. package/dist/startup/startup-milestones.js.map +1 -1
  314. package/dist/utils/await-with-abort.d.ts +2 -0
  315. package/dist/utils/await-with-abort.d.ts.map +1 -0
  316. package/dist/utils/await-with-abort.js +19 -0
  317. package/dist/utils/await-with-abort.js.map +1 -0
  318. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  319. package/dist/utils/syntax-highlight.js +10 -4
  320. package/dist/utils/syntax-highlight.js.map +1 -1
  321. package/docs/compaction.md +5 -3
  322. package/docs/development.md +5 -1
  323. package/docs/features.md +0 -1
  324. package/docs/interactive-startup.md +98 -0
  325. package/docs/usage.md +0 -1
  326. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  327. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  328. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  329. package/examples/extensions/gondolin/package-lock.json +2 -2
  330. package/examples/extensions/gondolin/package.json +1 -1
  331. package/examples/extensions/sandbox/package-lock.json +2 -2
  332. package/examples/extensions/sandbox/package.json +1 -1
  333. package/examples/extensions/with-deps/package-lock.json +2 -2
  334. package/examples/extensions/with-deps/package.json +1 -1
  335. package/package.json +20 -20
  336. package/dist/core/swarm.d.ts +0 -23
  337. package/dist/core/swarm.d.ts.map +0 -1
  338. package/dist/core/swarm.js +0 -45
  339. package/dist/core/swarm.js.map +0 -1
@@ -0,0 +1,966 @@
1
+ import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
2
+ import {
3
+ lightBuiltinExtensions,
4
+ loadAllBuiltinExtensions
5
+ } from "./chunk-PCGNAY2O.js";
6
+ import {
7
+ createProjectTrustContext,
8
+ createStartupTui,
9
+ resolveProjectTrusted,
10
+ shouldRunFirstTimeSetup,
11
+ showFirstTimeSetup,
12
+ showStartupSelector,
13
+ startStartupTui
14
+ } from "./chunk-IPA627GP.js";
15
+ import {
16
+ ProjectTrustStore,
17
+ hasTrustRequiringProjectResources
18
+ } from "./chunk-2QKLKMKC.js";
19
+ import {
20
+ applyInheritedSubagentPermissions
21
+ } from "./chunk-EDBJNRSM.js";
22
+ import {
23
+ MissingSessionCwdError,
24
+ createAgentSessionFromServices,
25
+ createAgentSessionRuntime,
26
+ createAgentSessionServices,
27
+ formatMissingSessionCwdPrompt,
28
+ formatNoModelsAvailableMessage,
29
+ getMissingSessionCwdIssue
30
+ } from "./chunk-WOVTOV5P.js";
31
+ import {
32
+ resolveCliModel,
33
+ resolveModelScope
34
+ } from "./chunk-TQNSPERU.js";
35
+ import {
36
+ restoreStdout,
37
+ takeOverStdout
38
+ } from "./chunk-OBMWP3I5.js";
39
+ import {
40
+ detectSupportedImageMimeTypeFromFile,
41
+ resolveReadPath
42
+ } from "./chunk-ZKMFUD3Q.js";
43
+ import {
44
+ processImage
45
+ } from "./chunk-AD6VXAO7.js";
46
+ import {
47
+ migrateLegacyGlobalInstructions
48
+ } from "./chunk-M3LZLQW2.js";
49
+ import {
50
+ SettingsManager,
51
+ applyHttpProxySettings,
52
+ configureHttpDispatcher
53
+ } from "./chunk-AJX357CL.js";
54
+ import {
55
+ SessionManager,
56
+ assertValidSessionId
57
+ } from "./chunk-PBC2Y6GS.js";
58
+ import {
59
+ bindRuntimeBridges
60
+ } from "./chunk-AHSTJBIB.js";
61
+ import {
62
+ registerModelTierBridge
63
+ } from "./chunk-W3CVH5RX.js";
64
+ import {
65
+ printTimings,
66
+ resetTimings,
67
+ time
68
+ } from "./chunk-PVCDKGR6.js";
69
+ import {
70
+ registerCustomizeBridge
71
+ } from "./chunk-HQCKFM2O.js";
72
+ import {
73
+ registerMemoryCapBridge
74
+ } from "./chunk-AY6CAJSL.js";
75
+ import {
76
+ parseArgs,
77
+ printHelp
78
+ } from "./chunk-DDGMHUOW.js";
79
+ import {
80
+ markStartupMilestone
81
+ } from "./chunk-CCZJ3PYY.js";
82
+ import {
83
+ SessionSelectorComponent
84
+ } from "./chunk-5P7PZMRU.js";
85
+ import {
86
+ KeybindingsManager,
87
+ migrateKeybindingsConfig
88
+ } from "./chunk-YSKSB3BJ.js";
89
+ import {
90
+ initTheme,
91
+ stopThemeWatcher
92
+ } from "./chunk-MX3GJNXJ.js";
93
+ import {
94
+ APP_NAME,
95
+ CONFIG_DIR_NAME,
96
+ ENV_SESSION_DIR,
97
+ VERSION,
98
+ appendDebugLog,
99
+ expandTildePath,
100
+ getAgentDir,
101
+ getBinDir,
102
+ getSessionsDir,
103
+ isLocalPath,
104
+ normalizePath,
105
+ resolvePath
106
+ } from "./chunk-PCIGF2XK.js";
107
+
108
+ // packages/coding-agent/dist/main.js
109
+ import { createInterface } from "node:readline";
110
+ import { modelsAreEqual } from "@ashx-j/lunr-ai";
111
+ import chalk4 from "chalk";
112
+
113
+ // packages/coding-agent/dist/cli/file-processor.js
114
+ import { access, readFile, stat } from "node:fs/promises";
115
+ import chalk from "chalk";
116
+ import { resolve } from "path";
117
+ async function processFileArguments(fileArgs, options) {
118
+ let autoResizeImages = options?.autoResizeImages ?? !0, text = "", images = [];
119
+ for (let fileArg of fileArgs) {
120
+ let absolutePath = resolve(resolveReadPath(fileArg, process.cwd()));
121
+ try {
122
+ await access(absolutePath);
123
+ } catch {
124
+ console.error(chalk.red(`Error: File not found: ${absolutePath}`)), process.exit(1);
125
+ }
126
+ if ((await stat(absolutePath)).size === 0)
127
+ continue;
128
+ let mimeType = await detectSupportedImageMimeTypeFromFile(absolutePath);
129
+ if (mimeType) {
130
+ let content = await readFile(absolutePath), processed = await processImage(content, mimeType, { autoResizeImages });
131
+ if (!processed.ok) {
132
+ text += `<file name="${absolutePath}">${processed.message}</file>
133
+ `;
134
+ continue;
135
+ }
136
+ let attachment = {
137
+ type: "image",
138
+ mimeType: processed.mimeType,
139
+ data: processed.data
140
+ };
141
+ images.push(attachment), processed.hints.length > 0 ? text += `<file name="${absolutePath}">${processed.hints.join(`
142
+ `)}</file>
143
+ ` : text += `<file name="${absolutePath}"></file>
144
+ `;
145
+ } else
146
+ try {
147
+ let content = await readFile(absolutePath, "utf-8");
148
+ text += `<file name="${absolutePath}">
149
+ ${content}
150
+ </file>
151
+ `;
152
+ } catch (error) {
153
+ let message = error instanceof Error ? error.message : String(error);
154
+ console.error(chalk.red(`Error: Could not read file ${absolutePath}: ${message}`)), process.exit(1);
155
+ }
156
+ }
157
+ return { text, images };
158
+ }
159
+
160
+ // packages/coding-agent/dist/cli/initial-message.js
161
+ function buildInitialMessage({ parsed, fileText, fileImages, stdinContent }) {
162
+ let parts = [];
163
+ return stdinContent !== void 0 && parts.push(stdinContent), fileText && parts.push(fileText), parsed.messages.length > 0 && (parts.push(parsed.messages[0]), parsed.messages.shift()), {
164
+ initialMessage: parts.length > 0 ? parts.join("") : void 0,
165
+ initialImages: fileImages && fileImages.length > 0 ? fileImages : void 0
166
+ };
167
+ }
168
+
169
+ // packages/coding-agent/dist/cli/list-models.js
170
+ import { fuzzyFilter } from "@ashx-j/lunr-tui";
171
+ import chalk2 from "chalk";
172
+ function formatTokenCount(count) {
173
+ if (count >= 1e6) {
174
+ let millions = count / 1e6;
175
+ return millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;
176
+ }
177
+ if (count >= 1e3) {
178
+ let thousands = count / 1e3;
179
+ return thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;
180
+ }
181
+ return count.toString();
182
+ }
183
+ async function listModels(modelRuntime, searchPattern) {
184
+ await modelRuntime.refreshIfStale();
185
+ let loadError = modelRuntime.getError();
186
+ loadError && console.error(chalk2.yellow(`Warning: errors loading models.json:
187
+ ${loadError}`));
188
+ let models = [...await modelRuntime.getAvailable()];
189
+ if (models.length === 0) {
190
+ console.log(formatNoModelsAvailableMessage());
191
+ return;
192
+ }
193
+ let filteredModels = models;
194
+ if (searchPattern && (filteredModels = fuzzyFilter(models, searchPattern, (m) => `${m.provider} ${m.id}`)), filteredModels.length === 0) {
195
+ console.log(`No models matching "${searchPattern}"`);
196
+ return;
197
+ }
198
+ filteredModels.sort((a, b) => {
199
+ let providerCmp = a.provider.localeCompare(b.provider);
200
+ return providerCmp !== 0 ? providerCmp : a.id.localeCompare(b.id);
201
+ });
202
+ let rows = filteredModels.map((m) => ({
203
+ provider: m.provider,
204
+ model: m.id,
205
+ context: formatTokenCount(m.contextWindow),
206
+ maxOut: formatTokenCount(m.maxTokens),
207
+ thinking: m.reasoning ? "yes" : "no",
208
+ images: m.input.includes("image") ? "yes" : "no"
209
+ })), headers = {
210
+ provider: "provider",
211
+ model: "model",
212
+ context: "context",
213
+ maxOut: "max-out",
214
+ thinking: "thinking",
215
+ images: "images"
216
+ }, widths = {
217
+ provider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),
218
+ model: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),
219
+ context: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),
220
+ maxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),
221
+ thinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),
222
+ images: Math.max(headers.images.length, ...rows.map((r) => r.images.length))
223
+ }, headerLine = [
224
+ headers.provider.padEnd(widths.provider),
225
+ headers.model.padEnd(widths.model),
226
+ headers.context.padEnd(widths.context),
227
+ headers.maxOut.padEnd(widths.maxOut),
228
+ headers.thinking.padEnd(widths.thinking),
229
+ headers.images.padEnd(widths.images)
230
+ ].join(" ");
231
+ console.log(headerLine);
232
+ for (let row of rows) {
233
+ let line = [
234
+ row.provider.padEnd(widths.provider),
235
+ row.model.padEnd(widths.model),
236
+ row.context.padEnd(widths.context),
237
+ row.maxOut.padEnd(widths.maxOut),
238
+ row.thinking.padEnd(widths.thinking),
239
+ row.images.padEnd(widths.images)
240
+ ].join(" ");
241
+ console.log(line);
242
+ }
243
+ }
244
+
245
+ // packages/coding-agent/dist/cli/session-picker.js
246
+ import { setKeybindings } from "@ashx-j/lunr-tui";
247
+ async function selectSession(currentSessionsLoader, allSessionsLoader, settingsManager) {
248
+ let ui = await createStartupTui(settingsManager);
249
+ return new Promise((resolve3) => {
250
+ let keybindings = KeybindingsManager.create();
251
+ setKeybindings(keybindings);
252
+ let resolved = !1, selector = new SessionSelectorComponent(currentSessionsLoader, allSessionsLoader, (path) => {
253
+ resolved || (resolved = !0, ui.stop(), resolve3(path));
254
+ }, () => {
255
+ resolved || (resolved = !0, ui.stop(), resolve3(null));
256
+ }, () => {
257
+ ui.stop(), process.exit(0);
258
+ }, () => ui.requestRender(), { showRenameHint: !1, keybindings });
259
+ ui.addChild(selector), ui.setFocus(selector.getSessionList()), startStartupTui(ui, settingsManager);
260
+ });
261
+ }
262
+
263
+ // packages/coding-agent/dist/core/session-retention.js
264
+ import { readdir, stat as stat2, unlink } from "node:fs/promises";
265
+ import { join, resolve as resolve2 } from "node:path";
266
+ var DAY_MS = 1440 * 60 * 1e3;
267
+ function sameFile(a, b) {
268
+ let ra = resolve2(a), rb = resolve2(b);
269
+ return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
270
+ }
271
+ async function pruneDir(dir, cutoffMs, excludeFile, deleted) {
272
+ let entries;
273
+ try {
274
+ entries = await readdir(dir, { withFileTypes: !0 });
275
+ } catch {
276
+ return;
277
+ }
278
+ for (let entry of entries) {
279
+ if (!entry.isFile() || !entry.name.endsWith(".jsonl"))
280
+ continue;
281
+ let filePath = join(dir, entry.name);
282
+ if (!(excludeFile && sameFile(filePath, excludeFile)))
283
+ try {
284
+ (await stat2(filePath)).mtimeMs < cutoffMs && (await unlink(filePath), deleted.push(filePath));
285
+ } catch {
286
+ }
287
+ }
288
+ }
289
+ async function pruneOldSessions(sessionsRoot, retentionDays, options = {}) {
290
+ let deleted = [];
291
+ if (!Number.isFinite(retentionDays) || retentionDays <= 0)
292
+ return { deleted };
293
+ let cutoffMs = (options.now ?? Date.now()) - retentionDays * DAY_MS;
294
+ await pruneDir(sessionsRoot, cutoffMs, options.excludeFile, deleted);
295
+ let subdirs;
296
+ try {
297
+ subdirs = await readdir(sessionsRoot, { withFileTypes: !0 });
298
+ } catch {
299
+ return { deleted };
300
+ }
301
+ for (let entry of subdirs)
302
+ entry.isDirectory() && await pruneDir(join(sessionsRoot, entry.name), cutoffMs, options.excludeFile, deleted);
303
+ return { deleted };
304
+ }
305
+
306
+ // packages/coding-agent/dist/migrations.js
307
+ import chalk3 from "chalk";
308
+ import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
309
+ import { homedir } from "os";
310
+ import { dirname, join as join2 } from "path";
311
+ var MIGRATION_GUIDE_URL = "https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/CHANGELOG.md#extensions-migration", EXTENSIONS_DOC_URL = "https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/extensions.md";
312
+ function migrateAuthToAuthJson() {
313
+ let agentDir = getAgentDir(), authPath = join2(agentDir, "auth.json"), oauthPath = join2(agentDir, "oauth.json"), settingsPath = join2(agentDir, "settings.json");
314
+ if (existsSync(authPath))
315
+ return [];
316
+ let migrated = {}, providers = [];
317
+ if (existsSync(oauthPath))
318
+ try {
319
+ let oauth = JSON.parse(readFileSync(oauthPath, "utf-8"));
320
+ for (let [provider, cred] of Object.entries(oauth))
321
+ migrated[provider] = { type: "oauth", ...cred }, providers.push(provider);
322
+ renameSync(oauthPath, `${oauthPath}.migrated`);
323
+ } catch {
324
+ }
325
+ if (existsSync(settingsPath))
326
+ try {
327
+ let content = readFileSync(settingsPath, "utf-8"), settings = JSON.parse(content);
328
+ if (settings.apiKeys && typeof settings.apiKeys == "object") {
329
+ for (let [provider, key] of Object.entries(settings.apiKeys))
330
+ !migrated[provider] && typeof key == "string" && (migrated[provider] = { type: "api_key", key }, providers.push(provider));
331
+ delete settings.apiKeys, writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
332
+ }
333
+ } catch {
334
+ }
335
+ return Object.keys(migrated).length > 0 && (mkdirSync(dirname(authPath), { recursive: !0 }), writeFileSync(authPath, JSON.stringify(migrated, null, 2), { mode: 384 })), providers;
336
+ }
337
+ function removeRetiredGlobalSettings(keys, agentDir = getAgentDir()) {
338
+ let settingsPath = join2(agentDir, "settings.json");
339
+ if (!existsSync(settingsPath))
340
+ return !1;
341
+ try {
342
+ let parsed = JSON.parse(readFileSync(settingsPath, "utf-8"));
343
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
344
+ return !1;
345
+ let settings = parsed, retired = keys.filter((key) => key in settings);
346
+ if (retired.length === 0)
347
+ return !1;
348
+ for (let key of retired)
349
+ delete settings[key];
350
+ return writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}
351
+ `, "utf-8"), !0;
352
+ } catch {
353
+ return !1;
354
+ }
355
+ }
356
+ function removeRetiredBehaviorPresetSetting(agentDir = getAgentDir()) {
357
+ return removeRetiredGlobalSettings(["behaviorPreset"], agentDir);
358
+ }
359
+ function removeRetiredTuiSettings(agentDir = getAgentDir()) {
360
+ return removeRetiredGlobalSettings(["gutterRail", "promptSymbol"], agentDir);
361
+ }
362
+ function migrateSessionsFromAgentRoot() {
363
+ let agentDir = getAgentDir(), files;
364
+ try {
365
+ files = readdirSync(agentDir).filter((f) => f.endsWith(".jsonl")).map((f) => join2(agentDir, f));
366
+ } catch {
367
+ return;
368
+ }
369
+ if (files.length !== 0)
370
+ for (let file of files)
371
+ try {
372
+ let firstLine = readFileSync(file, "utf8").split(`
373
+ `)[0];
374
+ if (!firstLine?.trim())
375
+ continue;
376
+ let header = JSON.parse(firstLine);
377
+ if (header.type !== "session" || !header.cwd)
378
+ continue;
379
+ let safePath = `--${header.cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`, correctDir = join2(agentDir, "sessions", safePath);
380
+ existsSync(correctDir) || mkdirSync(correctDir, { recursive: !0 });
381
+ let fileName = file.split("/").pop() || file.split("\\").pop(), newPath = join2(correctDir, fileName);
382
+ if (existsSync(newPath))
383
+ continue;
384
+ renameSync(file, newPath);
385
+ } catch {
386
+ }
387
+ }
388
+ function migrateCommandsToPrompts(baseDir, label) {
389
+ let commandsDir = join2(baseDir, "commands"), promptsDir = join2(baseDir, "prompts");
390
+ if (existsSync(commandsDir) && !existsSync(promptsDir))
391
+ try {
392
+ return renameSync(commandsDir, promptsDir), console.log(chalk3.green(`Migrated ${label} commands/ \u2192 prompts/`)), !0;
393
+ } catch (err) {
394
+ console.log(chalk3.yellow(`Warning: Could not migrate ${label} commands/ to prompts/: ${err instanceof Error ? err.message : err}`));
395
+ }
396
+ return !1;
397
+ }
398
+ function migrateKeybindingsConfigFile() {
399
+ let configPath = join2(getAgentDir(), "keybindings.json");
400
+ if (existsSync(configPath))
401
+ try {
402
+ let parsed = JSON.parse(readFileSync(configPath, "utf-8"));
403
+ if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
404
+ return;
405
+ let { config, migrated } = migrateKeybindingsConfig(parsed);
406
+ if (!migrated)
407
+ return;
408
+ writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
409
+ `, "utf-8");
410
+ } catch {
411
+ }
412
+ }
413
+ function migrateToolsToBin() {
414
+ let agentDir = getAgentDir(), toolsDir = join2(agentDir, "tools"), binDir = getBinDir();
415
+ if (!existsSync(toolsDir))
416
+ return;
417
+ let binaries = ["fd", "rg", "fd.exe", "rg.exe"], movedAny = !1;
418
+ for (let bin of binaries) {
419
+ let oldPath = join2(toolsDir, bin), newPath = join2(binDir, bin);
420
+ if (existsSync(oldPath))
421
+ if (existsSync(binDir) || mkdirSync(binDir, { recursive: !0 }), existsSync(newPath))
422
+ try {
423
+ rmSync?.(oldPath, { force: !0 });
424
+ } catch {
425
+ }
426
+ else
427
+ try {
428
+ renameSync(oldPath, newPath), movedAny = !0;
429
+ } catch {
430
+ }
431
+ }
432
+ movedAny && console.log(chalk3.green("Migrated managed binaries tools/ \u2192 bin/"));
433
+ }
434
+ function checkDeprecatedExtensionDirs(baseDir, label) {
435
+ let hooksDir = join2(baseDir, "hooks"), toolsDir = join2(baseDir, "tools"), warnings = [];
436
+ if (existsSync(hooksDir) && warnings.push(`${label} hooks/ directory found. Hooks have been renamed to extensions.`), existsSync(toolsDir))
437
+ try {
438
+ readdirSync(toolsDir).filter((e) => {
439
+ let lower = e.toLowerCase();
440
+ return lower !== "fd" && lower !== "rg" && lower !== "fd.exe" && lower !== "rg.exe" && !e.startsWith(".");
441
+ }).length > 0 && warnings.push(`${label} tools/ directory contains custom tools. Custom tools have been merged into extensions.`);
442
+ } catch {
443
+ }
444
+ return warnings;
445
+ }
446
+ function migrateExtensionSystem(cwd) {
447
+ let agentDir = getAgentDir(), projectDir = join2(cwd, CONFIG_DIR_NAME);
448
+ return migrateCommandsToPrompts(agentDir, "Global"), migrateCommandsToPrompts(projectDir, "Project"), [
449
+ ...checkDeprecatedExtensionDirs(agentDir, "Global"),
450
+ ...checkDeprecatedExtensionDirs(projectDir, "Project")
451
+ ];
452
+ }
453
+ async function showDeprecationWarnings(warnings) {
454
+ if (warnings.length !== 0) {
455
+ for (let warning of warnings)
456
+ console.log(chalk3.yellow(`Warning: ${warning}`));
457
+ console.log(chalk3.yellow(`
458
+ Move your extensions to the extensions/ directory.`)), console.log(chalk3.yellow(`Migration guide: ${MIGRATION_GUIDE_URL}`)), console.log(chalk3.yellow(`Documentation: ${EXTENSIONS_DOC_URL}`)), process.stdin.isTTY && (console.log(chalk3.dim(`
459
+ Press any key to continue...`)), await new Promise((resolve3) => {
460
+ process.stdin.setRawMode?.(!0), process.stdin.resume(), process.stdin.once("data", () => {
461
+ process.stdin.setRawMode?.(!1), process.stdin.pause(), resolve3();
462
+ });
463
+ }), console.log());
464
+ }
465
+ }
466
+ function migratePiStateToLunr(piHome = join2(homedir(), ".pi"), lunrAgentDir = getAgentDir()) {
467
+ let copied = [], copyFileIfMissing = (src, dest) => {
468
+ try {
469
+ if (!existsSync(src) || existsSync(dest))
470
+ return;
471
+ mkdirSync(dirname(dest), { recursive: !0 }), copyFileSync(src, dest), copied.push(dest);
472
+ } catch {
473
+ }
474
+ }, copyDirIfMissing = (srcDir, destDir) => {
475
+ try {
476
+ if (!existsSync(srcDir))
477
+ return;
478
+ for (let entry of readdirSync(srcDir, { withFileTypes: !0 })) {
479
+ let src = join2(srcDir, entry.name), dest = join2(destDir, entry.name);
480
+ entry.isDirectory() ? copyDirIfMissing(src, dest) : entry.isFile() && copyFileIfMissing(src, dest);
481
+ }
482
+ } catch {
483
+ }
484
+ };
485
+ try {
486
+ let piAgent = join2(piHome, "agent");
487
+ for (let name of [
488
+ "mcp.json",
489
+ "mcp-cache.json",
490
+ "mcp-npx-cache.json",
491
+ "mcp-onboarding.json",
492
+ "pi-goal-state.json"
493
+ ])
494
+ copyFileIfMissing(join2(piAgent, name), join2(lunrAgentDir, name));
495
+ copyDirIfMissing(join2(piAgent, "mcp-oauth"), join2(lunrAgentDir, "mcp-oauth")), copyFileIfMissing(join2(piHome, "web-search.json"), join2(lunrAgentDir, "web-search.json"));
496
+ let lunrMemoryDir = join2(dirname(lunrAgentDir), "simple-memory");
497
+ for (let name of ["memory.md", "config.json"])
498
+ copyFileIfMissing(join2(piHome, "simple-memory", name), join2(lunrMemoryDir, name));
499
+ } catch {
500
+ }
501
+ return copied;
502
+ }
503
+ function runMigrations(cwd) {
504
+ let migratedAuthProviders = migrateAuthToAuthJson();
505
+ removeRetiredBehaviorPresetSetting(), removeRetiredTuiSettings(), migrateSessionsFromAgentRoot(), migrateToolsToBin(), migrateKeybindingsConfigFile(), migratePiStateToLunr();
506
+ let instructionMigration = migrateLegacyGlobalInstructions(getAgentDir());
507
+ instructionMigration.diagnostic && console.warn(chalk3.yellow(`Warning: ${instructionMigration.diagnostic}`));
508
+ let deprecationWarnings = migrateExtensionSystem(cwd);
509
+ return { migratedAuthProviders, deprecationWarnings };
510
+ }
511
+
512
+ // packages/coding-agent/dist/main.js
513
+ var EXTENSION_LOAD_FAILURE_HINT = `Hint: Start without extensions using "${APP_NAME} -ne".`, PIPED_STDIN_FIRST_CHUNK_MS = 50, PIPED_STDIN_IDLE_MS = 2e3;
514
+ async function readPipedStdin(stream = process.stdin, options = {}) {
515
+ if (stream.isTTY)
516
+ return;
517
+ let firstChunkMs = options.firstChunkMs ?? PIPED_STDIN_FIRST_CHUNK_MS, idleMs = options.idleMs ?? PIPED_STDIN_IDLE_MS;
518
+ return new Promise((resolve3) => {
519
+ let data = "", settled = !1, sawData = !1, idleTimer, firstChunkTimer = setTimeout(() => {
520
+ sawData || finish(void 0);
521
+ }, firstChunkMs), finish = (value) => {
522
+ settled || (settled = !0, clearTimeout(firstChunkTimer), idleTimer && clearTimeout(idleTimer), stream.off("data", onData), stream.off("end", onEnd), stream.off("error", onEnd), resolve3(value));
523
+ }, onEnd = () => finish(data.trim() || void 0), onData = (chunk) => {
524
+ sawData = !0, data += typeof chunk == "string" ? chunk : chunk.toString("utf8"), idleTimer && clearTimeout(idleTimer), idleTimer = setTimeout(onEnd, idleMs);
525
+ };
526
+ stream.setEncoding("utf8"), stream.on("data", onData), stream.on("end", onEnd), stream.on("error", onEnd), stream.resume();
527
+ });
528
+ }
529
+ function collectSettingsDiagnostics(settingsManager, context) {
530
+ return settingsManager.drainErrors().map(({ scope, error }) => ({
531
+ type: "warning",
532
+ message: `(${context}, ${scope} settings) ${error.message}`
533
+ }));
534
+ }
535
+ function reportDiagnostics(diagnostics) {
536
+ for (let diagnostic of diagnostics) {
537
+ let color = diagnostic.type === "error" ? chalk4.red : diagnostic.type === "warning" ? chalk4.yellow : chalk4.dim, prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
538
+ console.error(color(`${prefix}${diagnostic.message}`));
539
+ }
540
+ }
541
+ function isTruthyEnvFlag(value) {
542
+ return value ? value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes" : !1;
543
+ }
544
+ function resolveAppMode(parsed, stdinIsTTY, stdoutIsTTY) {
545
+ return parsed.mode === "rpc" ? "rpc" : parsed.mode === "json" ? "json" : isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK) && !parsed.print ? "interactive" : parsed.print || !stdinIsTTY || !stdoutIsTTY ? "print" : "interactive";
546
+ }
547
+ function toPrintOutputMode(appMode) {
548
+ return appMode === "json" ? "json" : "text";
549
+ }
550
+ function isPlainRuntimeMetadataCommand(parsed) {
551
+ return !parsed.print && parsed.mode === void 0 && (parsed.help === !0 || parsed.listModels !== void 0);
552
+ }
553
+ async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
554
+ if (parsed.fileArgs.length === 0)
555
+ return buildInitialMessage({ parsed, stdinContent });
556
+ let { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });
557
+ return buildInitialMessage({
558
+ parsed,
559
+ fileText: text,
560
+ fileImages: images,
561
+ stdinContent
562
+ });
563
+ }
564
+ async function findLocalSessionByExactId(sessionId, cwd, sessionDir) {
565
+ let localMatch = (await SessionManager.list(cwd, sessionDir)).find((s) => s.id === sessionId);
566
+ return localMatch ? { type: "local", path: localMatch.path } : void 0;
567
+ }
568
+ async function resolveSessionPath(sessionArg, cwd, sessionDir) {
569
+ if (sessionArg.includes("/") || sessionArg.includes("\\") || sessionArg.endsWith(".jsonl"))
570
+ return { type: "path", path: resolvePath(sessionArg, cwd) };
571
+ let localSessions = await SessionManager.list(cwd, sessionDir), localMatch = localSessions.find((s) => s.id === sessionArg) ?? localSessions.find((s) => s.id.startsWith(sessionArg));
572
+ if (localMatch)
573
+ return { type: "local", path: localMatch.path };
574
+ let allSessions = await SessionManager.listAll(sessionDir), globalMatch = allSessions.find((s) => s.id === sessionArg) ?? allSessions.find((s) => s.id.startsWith(sessionArg));
575
+ return globalMatch ? { type: "global", path: globalMatch.path, cwd: globalMatch.cwd } : { type: "not_found", arg: sessionArg };
576
+ }
577
+ async function promptConfirm(message, startupView) {
578
+ return startupView ? startupView.confirm("Confirm", message) : new Promise((resolve3) => {
579
+ let rl = createInterface({
580
+ input: process.stdin,
581
+ output: process.stdout
582
+ });
583
+ rl.question(`${message} [y/N] `, (answer) => {
584
+ rl.close(), resolve3(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
585
+ });
586
+ });
587
+ }
588
+ function validateForkFlags(parsed) {
589
+ if (!parsed.fork)
590
+ return;
591
+ let conflictingFlags = [
592
+ parsed.session ? "--session" : void 0,
593
+ parsed.continue ? "--continue" : void 0,
594
+ parsed.resume ? "--resume" : void 0,
595
+ parsed.noSession ? "--no-session" : void 0
596
+ ].filter((flag) => flag !== void 0);
597
+ conflictingFlags.length > 0 && (console.error(chalk4.red(`Error: --fork cannot be combined with ${conflictingFlags.join(", ")}`)), process.exit(1));
598
+ }
599
+ function validateSessionIdFlags(parsed) {
600
+ if (parsed.sessionId === void 0)
601
+ return;
602
+ let conflictingFlags = [
603
+ parsed.session ? "--session" : void 0,
604
+ parsed.continue ? "--continue" : void 0,
605
+ parsed.resume ? "--resume" : void 0
606
+ ].filter((flag) => flag !== void 0);
607
+ conflictingFlags.length > 0 && (console.error(chalk4.red(`Error: --session-id cannot be combined with ${conflictingFlags.join(", ")}`)), process.exit(1));
608
+ try {
609
+ assertValidSessionId(parsed.sessionId);
610
+ } catch (error) {
611
+ let message = error instanceof Error ? error.message : String(error);
612
+ console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
613
+ }
614
+ }
615
+ function openSessionOrExit(path, sessionDir) {
616
+ try {
617
+ return SessionManager.open(path, sessionDir);
618
+ } catch (error) {
619
+ let message = error instanceof Error ? error.message : String(error);
620
+ console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
621
+ }
622
+ }
623
+ function forkSessionOrExit(sourcePath, cwd, sessionDir, sessionId) {
624
+ try {
625
+ return SessionManager.forkFrom(sourcePath, cwd, sessionDir, { id: sessionId });
626
+ } catch (error) {
627
+ let message = error instanceof Error ? error.message : String(error);
628
+ console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
629
+ }
630
+ }
631
+ async function createSessionManager(parsed, cwd, sessionDir, settingsManager, startupView) {
632
+ if (parsed.noSession || parsed.help || parsed.listModels !== void 0)
633
+ return SessionManager.inMemory(cwd, parsed.sessionId !== void 0 ? { id: parsed.sessionId } : void 0);
634
+ if (parsed.fork) {
635
+ parsed.sessionId && await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir) && (console.error(chalk4.red(`Session already exists with id '${parsed.sessionId}'`)), process.exit(1));
636
+ let resolved = await resolveSessionPath(parsed.fork, cwd, sessionDir);
637
+ switch (resolved.type) {
638
+ case "path":
639
+ case "local":
640
+ case "global":
641
+ return forkSessionOrExit(resolved.path, cwd, sessionDir, parsed.sessionId);
642
+ case "not_found":
643
+ console.error(chalk4.red(`No session found matching '${resolved.arg}'`)), process.exit(1);
644
+ }
645
+ }
646
+ if (parsed.session) {
647
+ let resolved = await resolveSessionPath(parsed.session, cwd, sessionDir);
648
+ switch (resolved.type) {
649
+ case "path":
650
+ case "local":
651
+ return openSessionOrExit(resolved.path, sessionDir);
652
+ case "global":
653
+ return console.log(chalk4.yellow(`Session found in different project: ${resolved.cwd}`)), await promptConfirm("Fork this session into current directory?", startupView) || (console.log(chalk4.dim("Aborted.")), process.exit(0)), forkSessionOrExit(resolved.path, cwd, sessionDir);
654
+ case "not_found":
655
+ console.error(chalk4.red(`No session found matching '${resolved.arg}'`)), process.exit(1);
656
+ }
657
+ }
658
+ if (parsed.resume)
659
+ try {
660
+ let currentSessionsLoader = (onProgress) => SessionManager.list(cwd, sessionDir, onProgress), allSessionsLoader = (onProgress) => SessionManager.listAll(sessionDir, onProgress), selectedPath = startupView ? await startupView.selectSession(currentSessionsLoader, allSessionsLoader) : await selectSession(currentSessionsLoader, allSessionsLoader, settingsManager);
661
+ return selectedPath || (console.log(chalk4.dim("No session selected")), process.exit(0)), SessionManager.open(selectedPath, sessionDir);
662
+ } finally {
663
+ stopThemeWatcher();
664
+ }
665
+ if (parsed.continue)
666
+ return SessionManager.continueRecent(cwd, sessionDir);
667
+ if (parsed.sessionId) {
668
+ let existingSession = await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir);
669
+ if (existingSession)
670
+ return SessionManager.open(existingSession.path, sessionDir);
671
+ console.error(chalk4.yellow(`Warning: No project session found with id '${parsed.sessionId}'; creating a new session with that id.`));
672
+ }
673
+ return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
674
+ }
675
+ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRuntime, settingsManager) {
676
+ let options = {}, diagnostics = [], cliThinkingFromModel = !1;
677
+ if (parsed.model) {
678
+ let resolved = resolveCliModel({
679
+ cliProvider: parsed.provider,
680
+ cliModel: parsed.model,
681
+ cliThinking: parsed.thinking,
682
+ modelRuntime
683
+ });
684
+ resolved.warning && diagnostics.push({ type: "warning", message: resolved.warning }), resolved.error && diagnostics.push({ type: "error", message: resolved.error }), resolved.model && (options.model = resolved.model, !parsed.thinking && resolved.thinkingLevel && (options.thinkingLevel = resolved.thinkingLevel, cliThinkingFromModel = !0));
685
+ }
686
+ if (!options.model && scopedModels.length > 0 && !hasExistingSession) {
687
+ let savedProvider = settingsManager.getDefaultProvider(), savedModelId = settingsManager.getDefaultModel(), savedModel = savedProvider && savedModelId ? modelRuntime.getModel(savedProvider, savedModelId) : void 0, savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : void 0;
688
+ savedInScope ? (options.model = savedInScope.model, !parsed.thinking && savedInScope.thinkingLevel && (options.thinkingLevel = savedInScope.thinkingLevel)) : (options.model = scopedModels[0].model, !parsed.thinking && scopedModels[0].thinkingLevel && (options.thinkingLevel = scopedModels[0].thinkingLevel));
689
+ }
690
+ return parsed.thinking && (options.thinkingLevel = parsed.thinking), scopedModels.length > 0 && (options.scopedModels = scopedModels.map((sm) => ({
691
+ model: sm.model,
692
+ thinkingLevel: sm.thinkingLevel
693
+ }))), parsed.noTools ? options.noTools = "all" : parsed.noBuiltinTools && (options.noTools = "builtin"), parsed.tools && (options.tools = [...parsed.tools]), parsed.excludeTools && (options.excludeTools = [...parsed.excludeTools]), { options, cliThinkingFromModel, diagnostics };
694
+ }
695
+ function resolveCliPaths(cwd, paths) {
696
+ return paths?.map((value) => isLocalPath(value) ? resolvePath(value, cwd) : value);
697
+ }
698
+ function createStartupViewTrustContext(cwd, startupView) {
699
+ return {
700
+ cwd,
701
+ mode: "tui",
702
+ hasUI: !0,
703
+ ui: {
704
+ select: (title, options) => startupView.select(title, options.map((option) => ({ label: option, value: option }))),
705
+ confirm: (title, message) => startupView.confirm(title, message),
706
+ input: (title, placeholder) => startupView.input(title, placeholder),
707
+ notify: () => {
708
+ }
709
+ }
710
+ };
711
+ }
712
+ async function promptForMissingSessionCwd(issue, settingsManager, startupView) {
713
+ let options = [
714
+ { label: "Continue", value: issue.fallbackCwd },
715
+ { label: "Cancel", value: void 0 }
716
+ ];
717
+ return startupView ? startupView.select(formatMissingSessionCwdPrompt(issue), options) : showStartupSelector(settingsManager, formatMissingSessionCwdPrompt(issue), options);
718
+ }
719
+ async function main(args, options) {
720
+ resetTimings(), (args.includes("--offline") || isTruthyEnvFlag(process.env.PI_OFFLINE)) && (process.env.PI_OFFLINE = "1");
721
+ let cwd = process.cwd(), agentDir = getAgentDir(), bootstrapSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: !1 });
722
+ if (applyHttpProxySettings(bootstrapSettingsManager.getGlobalSettings().httpProxy), configureHttpDispatcher(), ["setup", "features", "uninstall"].includes(args[0])) {
723
+ let { handleInstallCli } = await import("./install-cli-TH7IJJQQ.js");
724
+ if (await handleInstallCli(args))
725
+ return;
726
+ }
727
+ if (args[0] === "update") {
728
+ let { handleUpdateCli } = await import("./update-cli-A253SZ7P.js");
729
+ if (await handleUpdateCli(args))
730
+ return;
731
+ }
732
+ if (["install", "remove", "uninstall", "list", "config"].includes(args[0])) {
733
+ let { handleConfigCommand, handlePackageCommand } = await import("./package-manager-cli-TZZHJCVI.js");
734
+ if (await handlePackageCommand(args, { extensionFactories: options?.extensionFactories })) {
735
+ process.exit(process.exitCode ?? 0);
736
+ return;
737
+ }
738
+ if (await handleConfigCommand(args, { extensionFactories: options?.extensionFactories }))
739
+ return;
740
+ }
741
+ if (args[0] === "gateway") {
742
+ let { handleGatewayCommand } = await import("./command-L3LAHDIH.js");
743
+ if (await handleGatewayCommand(args))
744
+ return;
745
+ }
746
+ let parsed = parseArgs(args);
747
+ if (parsed.diagnostics.length > 0) {
748
+ for (let d of parsed.diagnostics) {
749
+ let color = d.type === "error" ? chalk4.red : chalk4.yellow;
750
+ console.error(color(`${d.type === "error" ? "Error" : "Warning"}: ${d.message}`));
751
+ }
752
+ parsed.diagnostics.some((d) => d.type === "error") && process.exit(1);
753
+ }
754
+ if (time("parseArgs"), parsed.version && (console.log(VERSION), process.exit(0)), parsed.export) {
755
+ let result;
756
+ try {
757
+ let { exportFromFile } = await import("./export-html-KR26FOUZ.js"), outputPath = parsed.messages.length > 0 ? parsed.messages[0] : void 0;
758
+ result = await exportFromFile(parsed.export, outputPath);
759
+ } catch (error) {
760
+ let message = error instanceof Error ? error.message : "Failed to export session";
761
+ console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
762
+ }
763
+ console.log(`Exported to: ${result}`), process.exit(0);
764
+ }
765
+ let appMode = resolveAppMode(parsed, process.stdin.isTTY, process.stdout.isTTY), interactiveModeImport = appMode === "interactive" ? import("./interactive-mode-KOM35YF2.js") : void 0, startupView = appMode === "interactive" ? options?.startupView : void 0;
766
+ options?.startupView && !startupView && options.startupView.stop(), applyInheritedSubagentPermissions(), appMode !== "interactive" && !isPlainRuntimeMetadataCommand(parsed) && takeOverStdout(), parsed.mode === "rpc" && parsed.fileArgs.length > 0 && (console.error(chalk4.red("Error: @file arguments are not supported in RPC mode")), process.exit(1)), validateForkFlags(parsed), validateSessionIdFlags(parsed);
767
+ let { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(cwd);
768
+ time("runMigrations");
769
+ let startupSettingsManager = SettingsManager.create(cwd, agentDir);
770
+ reportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, "startup session lookup")), registerModelTierBridge(startupSettingsManager), registerMemoryCapBridge(startupSettingsManager), registerCustomizeBridge(startupSettingsManager), appMode === "interactive" && !parsed.help && parsed.listModels === void 0 && shouldRunFirstTimeSetup() && (startupView?.pause(), await showFirstTimeSetup(startupSettingsManager), startupView?.resume(), time("firstTimeSetup"));
771
+ let envSessionDir = process.env[ENV_SESSION_DIR], sessionDir = (parsed.sessionDir ? normalizePath(parsed.sessionDir) : void 0) ?? (envSessionDir ? expandTildePath(envSessionDir) : void 0) ?? startupSettingsManager.getSessionDir(), sessionManager = await createSessionManager(parsed, cwd, sessionDir, startupSettingsManager, startupView), missingSessionCwdIssue = getMissingSessionCwdIssue(sessionManager, cwd);
772
+ if (missingSessionCwdIssue)
773
+ if (appMode === "interactive") {
774
+ let selectedCwd = await promptForMissingSessionCwd(missingSessionCwdIssue, startupSettingsManager, startupView);
775
+ selectedCwd || process.exit(0), sessionManager = SessionManager.open(missingSessionCwdIssue.sessionFile, sessionDir, selectedCwd);
776
+ } else
777
+ console.error(chalk4.red(new MissingSessionCwdError(missingSessionCwdIssue).message)), process.exit(1);
778
+ if (parsed.name !== void 0) {
779
+ let name = parsed.name.trim();
780
+ name || (console.error(chalk4.red("Error: --name requires a non-empty value")), process.exit(1)), sessionManager.appendSessionInfo(name);
781
+ }
782
+ time("createSessionManager");
783
+ let runSessionRetention = async () => {
784
+ try {
785
+ let retentionDays = startupSettingsManager.getSessionRetentionDays();
786
+ if (retentionDays <= 0)
787
+ return;
788
+ let activeSessionFile = sessionManager.getSessionFile(), { deleted } = await pruneOldSessions(getSessionsDir(), retentionDays, {
789
+ excludeFile: activeSessionFile
790
+ });
791
+ if (sessionDir) {
792
+ let extra = await pruneOldSessions(sessionDir, retentionDays, { excludeFile: activeSessionFile });
793
+ deleted.push(...extra.deleted);
794
+ }
795
+ deleted.length > 0 && appendDebugLog(`session-retention: deleted ${deleted.length} file(s):
796
+ ${deleted.map((path) => ` ${path}`).join(`
797
+ `)}`);
798
+ } catch (error) {
799
+ appendDebugLog(`session-retention: prune failed: ${error instanceof Error ? error.message : String(error)}`);
800
+ }
801
+ }, trustStore = new ProjectTrustStore(agentDir), sessionCwd = sessionManager.getCwd(), autoTrustOnReloadCwd = parsed.projectTrustOverride === void 0 && !hasTrustRequiringProjectResources(sessionCwd) ? sessionCwd : void 0, trustPromptMode = parsed.help || parsed.listModels !== void 0 ? "print" : appMode, projectTrustByCwd = /* @__PURE__ */ new Map(), resolvedExtensionPaths = resolveCliPaths(cwd, parsed.extensions), resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills), resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates), resolvedThemePaths = resolveCliPaths(cwd, parsed.themes), builtinRoster = appMode === "interactive" ? [...lightBuiltinExtensions] : await loadAllBuiltinExtensions(), rememberAttachedFactories = (factories) => {
802
+ let seen = new Set(builtinRoster.map((entry) => typeof entry == "function" ? void 0 : entry.name).filter(Boolean));
803
+ for (let factory of factories) {
804
+ let name = typeof factory == "function" ? void 0 : factory.name;
805
+ name && seen.has(name) || (name && seen.add(name), builtinRoster.push(factory));
806
+ }
807
+ }, createRuntime = async ({ cwd: cwd2, agentDir: agentDir2, sessionManager: sessionManager2, sessionStartEvent, projectTrustContext }) => {
808
+ let isInitialRuntime = sessionStartEvent === void 0, projectTrustDiagnostics = [], cachedProjectTrust = projectTrustByCwd.get(cwd2), hasTrustRequiringResources = hasTrustRequiringProjectResources(cwd2), shouldResolveProjectTrust = parsed.projectTrustOverride === void 0 && cachedProjectTrust === void 0 && hasTrustRequiringResources, projectTrusted = shouldResolveProjectTrust ? !1 : cachedProjectTrust ?? parsed.projectTrustOverride ?? (!hasTrustRequiringResources || trustStore.get(cwd2) === !0), runtimeSettingsManager = SettingsManager.create(cwd2, agentDir2, { projectTrusted }), skipMissingPackageInstall = isInitialRuntime && appMode === "interactive", services2 = await createAgentSessionServices({
809
+ cwd: cwd2,
810
+ agentDir: agentDir2,
811
+ settingsManager: runtimeSettingsManager,
812
+ extensionFlagValues: parsed.unknownFlags,
813
+ resourceLoaderReloadOptions: shouldResolveProjectTrust ? {
814
+ skipMissingPackageInstall,
815
+ resolveProjectTrust: async ({ extensionsResult }) => {
816
+ let trusted = await resolveProjectTrusted({
817
+ cwd: cwd2,
818
+ trustStore,
819
+ trustOverride: parsed.projectTrustOverride,
820
+ defaultProjectTrust: startupSettingsManager.getDefaultProjectTrust(),
821
+ extensionsResult,
822
+ projectTrustContext: projectTrustContext ?? (isInitialRuntime && startupView ? createStartupViewTrustContext(cwd2, startupView) : createProjectTrustContext({
823
+ cwd: cwd2,
824
+ mode: isInitialRuntime ? trustPromptMode : appMode,
825
+ settingsManager: startupSettingsManager,
826
+ hasUI: isInitialRuntime && trustPromptMode === "interactive"
827
+ })),
828
+ onExtensionError: (message) => projectTrustDiagnostics.push({ type: "warning", message })
829
+ });
830
+ return projectTrustByCwd.set(cwd2, trusted), trusted;
831
+ }
832
+ } : skipMissingPackageInstall ? { skipMissingPackageInstall } : void 0,
833
+ resourceLoaderOptions: {
834
+ additionalExtensionPaths: resolvedExtensionPaths,
835
+ additionalSkillPaths: resolvedSkillPaths,
836
+ additionalPromptTemplatePaths: resolvedPromptTemplatePaths,
837
+ additionalThemePaths: resolvedThemePaths,
838
+ noExtensions: parsed.noExtensions,
839
+ noSkills: parsed.noSkills,
840
+ noPromptTemplates: parsed.noPromptTemplates,
841
+ noThemes: parsed.noThemes,
842
+ noContextFiles: parsed.noContextFiles,
843
+ systemPrompt: parsed.systemPrompt,
844
+ appendSystemPrompt: parsed.appendSystemPrompt,
845
+ extensionFactories: [...builtinRoster, ...options?.extensionFactories ?? []]
846
+ }
847
+ }), { settingsManager: settingsManager2, modelRuntime: modelRuntime2, resourceLoader: resourceLoader2 } = services2;
848
+ parsed.model && !resolveCliModel({
849
+ cliProvider: parsed.provider,
850
+ cliModel: parsed.model,
851
+ cliThinking: parsed.thinking,
852
+ modelRuntime: modelRuntime2
853
+ }).model && await modelRuntime2.refreshIfStale();
854
+ let diagnostics = [
855
+ ...projectTrustDiagnostics,
856
+ ...services2.diagnostics,
857
+ ...collectSettingsDiagnostics(settingsManager2, "runtime creation"),
858
+ ...resourceLoader2.getExtensions().errors.map(({ path, error }) => ({
859
+ type: "error",
860
+ message: `Failed to load extension "${path}": ${error}`
861
+ }))
862
+ ], modelPatterns = parsed.models ?? settingsManager2.getEnabledModels(), scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRuntime2) : [], { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics } = buildSessionOptions(parsed, scopedModels, sessionManager2.buildSessionContext().messages.length > 0, modelRuntime2, settingsManager2);
863
+ diagnostics.push(...sessionOptionDiagnostics), parsed.apiKey && (sessionOptions.model ? await modelRuntime2.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey, {
864
+ allowNetwork: !1
865
+ }) : diagnostics.push({
866
+ type: "error",
867
+ message: "--api-key requires a model to be specified via --model, --provider/--model, or --models"
868
+ }));
869
+ let created = await createAgentSessionFromServices({
870
+ services: services2,
871
+ sessionManager: sessionManager2,
872
+ sessionStartEvent,
873
+ model: sessionOptions.model,
874
+ thinkingLevel: sessionOptions.thinkingLevel,
875
+ scopedModels: sessionOptions.scopedModels,
876
+ tools: sessionOptions.tools,
877
+ excludeTools: sessionOptions.excludeTools,
878
+ noTools: sessionOptions.noTools,
879
+ customTools: sessionOptions.customTools
880
+ }), cliThinkingOverride = parsed.thinking !== void 0 || cliThinkingFromModel;
881
+ return created.session.model && cliThinkingOverride && created.session.setThinkingLevel(created.session.thinkingLevel), {
882
+ ...created,
883
+ services: services2,
884
+ diagnostics
885
+ };
886
+ };
887
+ time("createRuntime");
888
+ let runtime = await createAgentSessionRuntime(createRuntime, {
889
+ cwd: sessionManager.getCwd(),
890
+ agentDir,
891
+ sessionManager,
892
+ onRuntimeApplied: bindRuntimeBridges
893
+ });
894
+ if (startupView?.isExitRequested) {
895
+ await runtime.dispose();
896
+ return;
897
+ }
898
+ markStartupMilestone("runtime_hydrated"), time("createAgentSessionRuntime"), appMode !== "interactive" && await runSessionRetention();
899
+ let { services, session, modelFallbackMessage } = runtime, { settingsManager, modelRuntime, resourceLoader } = services;
900
+ if (applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy), configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs()), parsed.help) {
901
+ let extensionFlags = resourceLoader.getExtensions().extensions.flatMap((extension) => Array.from(extension.flags.values()));
902
+ printHelp(extensionFlags), process.exit(0);
903
+ }
904
+ if (parsed.listModels !== void 0) {
905
+ let searchPattern = typeof parsed.listModels == "string" ? parsed.listModels : void 0;
906
+ await listModels(modelRuntime, searchPattern), process.exit(0);
907
+ }
908
+ let stdinContent, startupBenchmark = isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK);
909
+ appMode !== "rpc" && !startupBenchmark && (stdinContent = await readPipedStdin(), stdinContent !== void 0 && appMode === "interactive" && (appMode = "print")), time("readPipedStdin");
910
+ let { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize(), stdinContent);
911
+ if (time("prepareInitialMessage"), initTheme(settingsManager.getTheme(), appMode === "interactive"), time("initTheme"), appMode === "interactive" && !startupView && deprecationWarnings.length > 0 && await showDeprecationWarnings(deprecationWarnings), time("resolveModelScope"), appMode === "interactive" && startupView || reportDiagnostics(runtime.diagnostics), runtime.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
912
+ let extensionHint = runtime.diagnostics.some((diagnostic) => diagnostic.message.includes("Failed to load extension")) ? `
913
+ ${EXTENSION_LOAD_FAILURE_HINT}` : "";
914
+ if (startupView) {
915
+ process.exitCode = 1, await startupView.fail(`${runtime.diagnostics.map((diagnostic) => diagnostic.message).join(`
916
+ `)}${extensionHint}`);
917
+ return;
918
+ }
919
+ extensionHint && console.error(chalk4.yellow(EXTENSION_LOAD_FAILURE_HINT)), process.exit(1);
920
+ }
921
+ if (time("createAgentSession"), appMode !== "interactive" && !session.model && (console.error(chalk4.red(formatNoModelsAvailableMessage())), process.exit(1)), startupBenchmark && appMode !== "interactive" && (console.error(chalk4.red("Error: PI_STARTUP_BENCHMARK only supports interactive mode")), process.exit(1)), appMode === "rpc") {
922
+ let { runRpcMode } = await import("./rpc-mode-SJNSOA4G.js");
923
+ printTimings(), await runRpcMode(runtime);
924
+ } else if (appMode === "interactive") {
925
+ let [{ InteractiveMode }, { loadDeferredBuiltinExtensions }] = await Promise.all([
926
+ interactiveModeImport,
927
+ import("./builtin-extensions-LYZ3BFWQ.js")
928
+ ]), interactiveMode = new InteractiveMode(runtime, {
929
+ migratedProviders,
930
+ modelFallbackMessage,
931
+ autoTrustOnReloadCwd,
932
+ initialMessage,
933
+ initialImages,
934
+ initialMessages: parsed.messages,
935
+ verbose: parsed.verbose,
936
+ deprecationWarnings: startupView ? deprecationWarnings : void 0,
937
+ startupDiagnostics: startupView ? runtime.diagnostics.filter((diagnostic) => diagnostic.type !== "error") : void 0,
938
+ startupView: startupView?.binding(),
939
+ deferredMaintenance: runSessionRetention,
940
+ deferredBuiltinFactories: parsed.noExtensions ? void 0 : loadDeferredBuiltinExtensions,
941
+ onDeferredBuiltinsAttached: rememberAttachedFactories
942
+ });
943
+ if (startupBenchmark) {
944
+ let { prepareBenchmarkRequest } = await import("./benchmark-request-UC7PD3V3.js"), request = await prepareBenchmarkRequest(session);
945
+ await interactiveMode.init(), time("interactiveMode.init"), await interactiveMode.waitForStartupReady(), time("promptBarrier"), await request(), await new Promise((resolve3) => setTimeout(resolve3, 150)), interactiveMode.stop(), await runtime.dispose(), stopThemeWatcher(), printTimings(), process.stdout.writableLength > 0 && await new Promise((resolve3) => process.stdout.once("drain", resolve3)), process.stderr.writableLength > 0 && await new Promise((resolve3) => process.stderr.once("drain", resolve3));
946
+ return;
947
+ }
948
+ await interactiveMode.init(), time("interactiveMode.init"), printTimings(), await interactiveMode.run();
949
+ } else {
950
+ let { runPrintMode } = await import("./print-mode-VWIRFDAC.js");
951
+ printTimings();
952
+ let exitCode = await runPrintMode(runtime, {
953
+ mode: toPrintOutputMode(appMode),
954
+ messages: parsed.messages,
955
+ initialMessage,
956
+ initialImages
957
+ });
958
+ stopThemeWatcher(), restoreStdout(), exitCode !== 0 && (process.exitCode = exitCode);
959
+ return;
960
+ }
961
+ }
962
+
963
+ export {
964
+ readPipedStdin,
965
+ main
966
+ };