@cortex-agent/server 2026.10.25 → 2026.10.28

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 (1877) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -5
  3. package/THIRD_PARTY_NOTICES.txt +16546 -0
  4. package/defaults/prompts/clean-workspace.md +21 -0
  5. package/dist/agent-adapter/claude/remote-mcp-proxy.js +4 -66
  6. package/dist/chunks/anthropic-SUZWKBRW.js +4 -0
  7. package/dist/chunks/anthropic-messages-M3SMXACA.js +8 -0
  8. package/dist/chunks/api-GM53PHIL-GFHEXXE6.js +4 -0
  9. package/dist/chunks/azure-openai-responses-76YWXHSB.js +4 -0
  10. package/dist/chunks/bedrock-converse-stream-5UPX4NTQ.js +58 -0
  11. package/dist/chunks/child-runner-3GHOWGZP.js +4 -0
  12. package/dist/chunks/chunk-23PRJECN.js +4 -0
  13. package/dist/chunks/chunk-2ZNLUY2U.js +128 -0
  14. package/dist/chunks/chunk-3F6WW7HR.js +13 -0
  15. package/dist/chunks/chunk-3OKHUVEM.js +7 -0
  16. package/dist/chunks/chunk-3TGQSGG4.js +8 -0
  17. package/dist/chunks/chunk-3THJYAEF.js +4 -0
  18. package/dist/chunks/chunk-3YHOCPQU.js +10 -0
  19. package/dist/chunks/chunk-4EX2JJWB.js +4 -0
  20. package/dist/chunks/chunk-4LLH5OWM.js +10 -0
  21. package/dist/chunks/chunk-4U7XXM4W.js +4 -0
  22. package/dist/chunks/chunk-52T37Y47.js +8 -0
  23. package/dist/chunks/chunk-5M4PFLRW.js +4 -0
  24. package/dist/chunks/chunk-5NRGVROY.js +4 -0
  25. package/dist/chunks/chunk-5T7IX5KN.js +4 -0
  26. package/dist/chunks/chunk-6AKUD3CF.js +4 -0
  27. package/dist/chunks/chunk-6LZK4DDH.js +4 -0
  28. package/dist/chunks/chunk-6R73ICDB.js +4 -0
  29. package/dist/chunks/chunk-7MU2AKNM.js +4 -0
  30. package/dist/chunks/chunk-A34TDMIC.js +7 -0
  31. package/dist/chunks/chunk-AAA3UBIS.js +4 -0
  32. package/dist/chunks/chunk-ASYQHJVQ.js +9 -0
  33. package/dist/chunks/chunk-AWFUHWQK.js +4 -0
  34. package/dist/chunks/chunk-B3XBQEFM.js +4 -0
  35. package/dist/chunks/chunk-BGVHA2D4.js +4 -0
  36. package/dist/chunks/chunk-BGYR4ID3.js +4 -0
  37. package/dist/chunks/chunk-BKHDWCRT.js +79 -0
  38. package/dist/chunks/chunk-BR7A5SWM.js +23 -0
  39. package/dist/chunks/chunk-CQLH4UVX.js +4 -0
  40. package/dist/chunks/chunk-CVC66CFV.js +33 -0
  41. package/dist/chunks/chunk-CXT5IR5T.js +4 -0
  42. package/dist/chunks/chunk-D3NXKK2L.js +4 -0
  43. package/dist/chunks/chunk-D6UA4BZC.js +19 -0
  44. package/dist/chunks/chunk-D6VMBA4C.js +4 -0
  45. package/dist/chunks/chunk-DGMNI4AO.js +4 -0
  46. package/dist/chunks/chunk-DHSA5ACV.js +125 -0
  47. package/dist/chunks/chunk-DPQPXBTP.js +68 -0
  48. package/dist/chunks/chunk-DQJ6LLAS.js +4 -0
  49. package/dist/chunks/chunk-DXBSQXJL.js +18 -0
  50. package/dist/chunks/chunk-E6BYRULL.js +4 -0
  51. package/dist/chunks/chunk-E7ZMYIY6.js +30 -0
  52. package/dist/chunks/chunk-EQIMHXC4.js +5 -0
  53. package/dist/chunks/chunk-EQITBTJC.js +10 -0
  54. package/dist/chunks/chunk-EXJA5RIX.js +357 -0
  55. package/dist/chunks/chunk-FF7UELTU.js +4 -0
  56. package/dist/chunks/chunk-FH74NME3.js +115 -0
  57. package/dist/chunks/chunk-FOJQXLL2.js +6 -0
  58. package/dist/chunks/chunk-FOQ7VLIL.js +17 -0
  59. package/dist/chunks/chunk-FX6MOGLR.js +11 -0
  60. package/dist/chunks/chunk-FXDIR3SQ.js +4 -0
  61. package/dist/chunks/chunk-G2V65UBA.js +4 -0
  62. package/dist/chunks/chunk-H2FP6DG4.js +5 -0
  63. package/dist/chunks/chunk-HALUQ7ZF.js +4 -0
  64. package/dist/chunks/chunk-HGPBHTVD.js +6 -0
  65. package/dist/chunks/chunk-HU6UIDEJ.js +6 -0
  66. package/dist/chunks/chunk-I6OPDRVF.js +4 -0
  67. package/dist/chunks/chunk-ILEML5IP.js +4 -0
  68. package/dist/chunks/chunk-IRWZ7UPF.js +77 -0
  69. package/dist/chunks/chunk-J5DVLUKY.js +6 -0
  70. package/dist/chunks/chunk-JERCOLY3.js +142 -0
  71. package/dist/chunks/chunk-JW2HFMTF.js +4 -0
  72. package/dist/chunks/chunk-JXFG66UN.js +4 -0
  73. package/dist/chunks/chunk-K4NTZEDJ.js +4 -0
  74. package/dist/chunks/chunk-KDYEGGMW.js +4 -0
  75. package/dist/chunks/chunk-KENCMLRE.js +4 -0
  76. package/dist/chunks/chunk-KGJZAYQD.js +4 -0
  77. package/dist/chunks/chunk-KIGMAATV.js +23 -0
  78. package/dist/chunks/chunk-KIU5FAPY.js +5 -0
  79. package/dist/chunks/chunk-KIWMQPH7.js +739 -0
  80. package/dist/chunks/chunk-KRXTI4JO.js +3 -0
  81. package/dist/chunks/chunk-L6VCIGWS.js +11 -0
  82. package/dist/chunks/chunk-LACGULCN.js +10 -0
  83. package/dist/chunks/chunk-LCKVYFMD.js +4 -0
  84. package/dist/chunks/chunk-LEUENXI2.js +6 -0
  85. package/dist/chunks/chunk-LMDWRRX4.js +4 -0
  86. package/dist/chunks/chunk-LMSQZ6TQ.js +4 -0
  87. package/dist/chunks/chunk-MEPASGPP.js +6 -0
  88. package/dist/chunks/chunk-MFAEUHMV.js +28 -0
  89. package/dist/chunks/chunk-N6BTQN7R.js +8 -0
  90. package/dist/chunks/chunk-NAA7GF6Q.js +5 -0
  91. package/dist/chunks/chunk-NHD2ESHA.js +4 -0
  92. package/dist/chunks/chunk-NKDMKRSB.js +68 -0
  93. package/dist/chunks/chunk-NKXV32S6.js +4 -0
  94. package/dist/chunks/chunk-NR6U3WIZ.js +4 -0
  95. package/dist/chunks/chunk-NT32UURL.js +4 -0
  96. package/dist/chunks/chunk-NVX5IPRN.js +4 -0
  97. package/dist/chunks/chunk-O3JW2F7D.js +8 -0
  98. package/dist/chunks/chunk-OE4KH3NJ.js +4 -0
  99. package/dist/chunks/chunk-OISO5JXB.js +4 -0
  100. package/dist/chunks/chunk-OKRK6JPY.js +4 -0
  101. package/dist/chunks/chunk-OPYXNSMY.js +4 -0
  102. package/dist/chunks/chunk-OSEIQ7SS.js +4 -0
  103. package/dist/chunks/chunk-OZGBWAT2.js +4 -0
  104. package/dist/chunks/chunk-P52RMIYX.js +6 -0
  105. package/dist/chunks/chunk-PBJ5MPPX.js +60 -0
  106. package/dist/chunks/chunk-PFMEUFJ7.js +4 -0
  107. package/dist/chunks/chunk-PMG4YGDU.js +7 -0
  108. package/dist/chunks/chunk-PXS5SHOV.js +4 -0
  109. package/dist/chunks/chunk-PZMGBKUR.js +13 -0
  110. package/dist/chunks/chunk-PZMXHA6X.js +9 -0
  111. package/dist/chunks/chunk-Q4UGYGU5.js +4 -0
  112. package/dist/chunks/chunk-Q7CE3UIE.js +133 -0
  113. package/dist/chunks/chunk-QBKCAIJG.js +4 -0
  114. package/dist/chunks/chunk-QEOFEETJ.js +4 -0
  115. package/dist/chunks/chunk-QN44UXQR.js +11 -0
  116. package/dist/chunks/chunk-QUUEQRIT.js +4 -0
  117. package/dist/chunks/chunk-QWAQHHRS.js +4 -0
  118. package/dist/chunks/chunk-RA6HKFBV.js +4 -0
  119. package/dist/chunks/chunk-REBNWCKI.js +4 -0
  120. package/dist/chunks/chunk-REPYBMQS.js +4 -0
  121. package/dist/chunks/chunk-RO4C2MJP.js +4 -0
  122. package/dist/chunks/chunk-SKHLZ6XY.js +9 -0
  123. package/dist/chunks/chunk-STUHNKQS.js +4 -0
  124. package/dist/chunks/chunk-SUFW24P4.js +7 -0
  125. package/dist/chunks/chunk-TAWLERZA.js +4 -0
  126. package/dist/chunks/chunk-TCAEECDI.js +4 -0
  127. package/dist/chunks/chunk-TJ4GQRT6.js +8 -0
  128. package/dist/chunks/chunk-TURBFBYN.js +4 -0
  129. package/dist/chunks/chunk-TWAEABGG.js +52 -0
  130. package/dist/chunks/chunk-TZFLHVOQ.js +7 -0
  131. package/dist/chunks/chunk-TZGNSHOL.js +4 -0
  132. package/dist/chunks/chunk-UD3NMUHR.js +12 -0
  133. package/dist/chunks/chunk-UNVEZI57.js +4 -0
  134. package/dist/chunks/chunk-USBJFDJ6.js +4 -0
  135. package/dist/chunks/chunk-V3AQJSWR.js +4 -0
  136. package/dist/chunks/chunk-VQUPKMDR.js +4 -0
  137. package/dist/chunks/chunk-W25TB3PU.js +4 -0
  138. package/dist/chunks/chunk-W5LGYSPZ.js +4 -0
  139. package/dist/chunks/chunk-WEZWKMYU.js +4 -0
  140. package/dist/chunks/chunk-WHC7AYZD.js +4 -0
  141. package/dist/chunks/chunk-X2GYYRVM.js +22 -0
  142. package/dist/chunks/chunk-XAJLZR7C.js +28 -0
  143. package/dist/chunks/chunk-XAXWLYH5.js +4 -0
  144. package/dist/chunks/chunk-XBJOYU5Y.js +4 -0
  145. package/dist/chunks/chunk-XH6FMP3N.js +71 -0
  146. package/dist/chunks/chunk-XIECJESP.js +4 -0
  147. package/dist/chunks/chunk-XNSSUVT6.js +4 -0
  148. package/dist/chunks/chunk-XSRZHN63.js +4 -0
  149. package/dist/chunks/chunk-Y3GFB5XM.js +8 -0
  150. package/dist/chunks/chunk-Y6ZEVVL5.js +4 -0
  151. package/dist/chunks/chunk-YAEVYJAR.js +4 -0
  152. package/dist/chunks/chunk-YG7OEPR2.js +6 -0
  153. package/dist/chunks/chunk-YHIWOGVL.js +4 -0
  154. package/dist/chunks/chunk-YKKEI5GI.js +4 -0
  155. package/dist/chunks/chunk-YPK2CAIZ.js +8 -0
  156. package/dist/chunks/chunk-YZSHTWNM.js +92 -0
  157. package/dist/chunks/chunk-Z2Q2NR46.js +34 -0
  158. package/dist/chunks/chunk-Z4H3VDHI.js +4 -0
  159. package/dist/chunks/chunk-ZFPMIQA3.js +6 -0
  160. package/dist/chunks/chunk-ZNZFWSPH.js +4 -0
  161. package/dist/chunks/chunk-ZQ7LGTSN.js +8 -0
  162. package/dist/chunks/chunk-ZSV6TO7Q.js +4 -0
  163. package/dist/chunks/cli-5DBTRMHU.js +53 -0
  164. package/dist/chunks/client-XOGYH5UR.js +4 -0
  165. package/dist/chunks/cloudflare-workers-ai-system-one-32JCFHI3.js +4 -0
  166. package/dist/chunks/config-DJSQI77S-335IXHSM.js +4 -0
  167. package/dist/chunks/context-VCQH5OB6.js +4 -0
  168. package/dist/chunks/cost-PGGFI7QJ.js +5 -0
  169. package/dist/chunks/dist-7RWW7YH4.js +11 -0
  170. package/dist/chunks/dist-PUKMZ7GW.js +4 -0
  171. package/dist/chunks/easter-egg-3d-MO4MOEVF.js +4 -0
  172. package/dist/chunks/es5-VNTQPCKX.js +4 -0
  173. package/dist/chunks/event-streams-3JSFPOTZ.js +4 -0
  174. package/dist/chunks/execution-repo-ZLJTBWFC.js +4 -0
  175. package/dist/chunks/executions-6ARGR3IO.js +9 -0
  176. package/dist/chunks/file-7BN7RCAY.js +4 -0
  177. package/dist/chunks/gateway-UCRPMR75.js +36 -0
  178. package/dist/chunks/github-copilot-HAI2DA62.js +4 -0
  179. package/dist/chunks/google-generative-ai-2VXWLHWI.js +4 -0
  180. package/dist/chunks/google-vertex-UA36QP2U.js +4 -0
  181. package/dist/chunks/init-HA7FAQ73.js +4 -0
  182. package/dist/chunks/install-cli-4IZCSDFZ.js +16 -0
  183. package/dist/chunks/interaction-ask-G5T3H3CG.js +9 -0
  184. package/dist/chunks/interaction-plan-E5V42MUP.js +11 -0
  185. package/dist/chunks/jiti-loader-WANUXUDO.js +4 -0
  186. package/dist/chunks/jiti-static-loader-W3QZ4GDS.js +476 -0
  187. package/dist/chunks/kimi-coding-HMJRKCPA.js +4 -0
  188. package/dist/chunks/lib-RSOU34HQ.js +11 -0
  189. package/dist/chunks/llama-cpp-classify-OTXZWCMW.js +24 -0
  190. package/dist/chunks/local-client-stop-SQRU7ZZM.js +4 -0
  191. package/dist/chunks/memory-cli-PYOILNN5.js +11 -0
  192. package/dist/chunks/meta-KY3LNFV2.js +4 -0
  193. package/dist/chunks/mistral-conversations-34F66L3O.js +7 -0
  194. package/dist/chunks/model-resolver-N3DTAQ2S.js +4 -0
  195. package/dist/chunks/models-L5VF4I5O-XXNJYQMQ.js +4 -0
  196. package/dist/chunks/multipart-parser-GEHG6YAR.js +5 -0
  197. package/dist/chunks/node-PTK2HCDV.js +18 -0
  198. package/dist/chunks/node-VLVSZ76W.js +4 -0
  199. package/dist/chunks/openai-chatgpt-PETGIJOZ.js +4 -0
  200. package/dist/chunks/openai-codex-2REL6UQU.js +4 -0
  201. package/dist/chunks/openai-codex-responses-ZBVHREB3.js +12 -0
  202. package/dist/chunks/openai-completions-VVIB26SH.js +9 -0
  203. package/dist/chunks/openai-decisions-2N6ZRPZC.js +7 -0
  204. package/dist/chunks/openai-responses-735XA2ZX.js +6 -0
  205. package/dist/chunks/openrouter-GDY3BLT2.js +4 -0
  206. package/dist/chunks/openrouter-images-3IKETHAC.js +4 -0
  207. package/dist/chunks/pi-messages-I3E4ZFHA.js +10 -0
  208. package/dist/chunks/radius-HXRZVBDB.js +4 -0
  209. package/dist/chunks/remote-ops-BALZYKH6.js +14 -0
  210. package/dist/chunks/runner-PLVZDGHB.js +4 -0
  211. package/dist/chunks/runtime-6YLTA2ZD.js +4 -0
  212. package/dist/chunks/schedule-cli-OLASBBYJ.js +4 -0
  213. package/dist/chunks/slack-WAGSPZUX.js +4 -0
  214. package/dist/chunks/src-CCI7P7AI.js +6 -0
  215. package/dist/chunks/start-ui-http-QALT7C3P.js +43 -0
  216. package/dist/chunks/subagent-E3UC7ZHC.js +4 -0
  217. package/dist/chunks/time-KEHDQT6K.js +4 -0
  218. package/dist/chunks/tool-shims-Q6P6UXVC.js +4 -0
  219. package/dist/chunks/typesafe-system-one-6ULACYD4.js +4 -0
  220. package/dist/chunks/ui-board-4GYW6KKW.js +5 -0
  221. package/dist/chunks/ui-decision-U2FXSEC2.js +4 -0
  222. package/dist/chunks/ui-file-GVH53O3X.js +5 -0
  223. package/dist/chunks/ui-view-O7PLANT7.js +4 -0
  224. package/dist/chunks/virtual-modules-IDC5YKZJ.js +4 -0
  225. package/dist/chunks/waitpoint-2FGQBIAC.js +5 -0
  226. package/dist/chunks/workers-XN4PSTH6.js +4 -0
  227. package/dist/chunks/xai-KEVUJTFV.js +4 -0
  228. package/dist/client-bundle/manifest.json +1 -1
  229. package/dist/core/pi-sdk.js +4 -73
  230. package/dist/domain/auth/cc-auth-cli.js +4 -248
  231. package/dist/domain/mcp/bundled-server.js +4 -146
  232. package/dist/entry/app.js +601 -611
  233. package/dist/entry/browser-cli.js +14 -316
  234. package/dist/entry/cli.js +4 -587
  235. package/dist/entry/cortex-cli.js +4 -2
  236. package/dist/entry/daemon.js +7 -909
  237. package/dist/entry/hook-cli.js +6 -401
  238. package/dist/entry/production-app-bootstrap.js +5 -42
  239. package/dist/entry/production-evidence-export-cli.js +12 -99
  240. package/dist/entry/signal-cli.js +6 -198
  241. package/dist/tui/index.js +114 -306
  242. package/package.json +11 -50
  243. package/scripts/bundle-prune-browser.mjs +52 -0
  244. package/scripts/postinstall-restart-trigger.mjs +8 -0
  245. package/vendor/aistatus/gateway-cli.js +21 -0
  246. package/vendor/pi/CHANGELOG.md +6365 -0
  247. package/vendor/pi/README.md +95 -0
  248. package/vendor/pi/dist/codemode-worker.js +478 -0
  249. package/vendor/pi/dist/core/export-html/ansi-to-html.js +249 -0
  250. package/vendor/pi/dist/core/export-html/index.js +228 -0
  251. package/vendor/pi/dist/core/export-html/template.css +1076 -0
  252. package/vendor/pi/dist/core/export-html/template.html +56 -0
  253. package/vendor/pi/dist/core/export-html/template.js +1924 -0
  254. package/vendor/pi/dist/core/export-html/tool-renderer.js +110 -0
  255. package/vendor/pi/dist/core/export-html/vendor/highlight.min.js +1213 -0
  256. package/vendor/pi/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  257. package/vendor/pi/dist/core/export-html/vendor/marked.min.js +79 -0
  258. package/vendor/pi/dist/core/extensions/loader.js +4 -0
  259. package/vendor/pi/dist/extensions/codemode/execute.js +507 -0
  260. package/vendor/pi/dist/modes/interactive/assets/clankolas.png +0 -0
  261. package/vendor/pi/dist/modes/interactive/theme/dark.json +78 -0
  262. package/vendor/pi/dist/modes/interactive/theme/light.json +78 -0
  263. package/vendor/pi/dist/modes/interactive/theme/system-theme.js +546 -0
  264. package/vendor/pi/dist/modes/interactive/theme/theme-controller.js +210 -0
  265. package/vendor/pi/dist/modes/interactive/theme/theme-schema.js +105 -0
  266. package/vendor/pi/dist/modes/interactive/theme/theme-tokens.js +94 -0
  267. package/vendor/pi/dist/modes/interactive/theme/theme.js +905 -0
  268. package/vendor/pi/dist/utils/image-resize-worker.js +4 -0
  269. package/vendor/pi/dist/utils/image-resize.js +4 -0
  270. package/vendor/pi/docs/cli-integration.md +106 -0
  271. package/vendor/pi/docs/cli.md +333 -0
  272. package/vendor/pi/docs/codemode.md +230 -0
  273. package/vendor/pi/docs/compaction.md +463 -0
  274. package/vendor/pi/docs/configuration.md +47 -0
  275. package/vendor/pi/docs/containerization.md +183 -0
  276. package/vendor/pi/docs/custom-provider.md +225 -0
  277. package/vendor/pi/docs/docs.json +220 -0
  278. package/vendor/pi/docs/environment-variables.md +101 -0
  279. package/vendor/pi/docs/extensions.md +400 -0
  280. package/vendor/pi/docs/how-pi-works.md +49 -0
  281. package/vendor/pi/docs/images/doom-extension.png +0 -0
  282. package/vendor/pi/docs/images/exy.png +0 -0
  283. package/vendor/pi/docs/images/interactive-mode.png +0 -0
  284. package/vendor/pi/docs/images/tree-view.png +0 -0
  285. package/vendor/pi/docs/index.md +39 -0
  286. package/vendor/pi/docs/json.md +226 -0
  287. package/vendor/pi/docs/keybindings.md +195 -0
  288. package/vendor/pi/docs/llama-cpp.md +121 -0
  289. package/vendor/pi/docs/mcp.md +272 -0
  290. package/vendor/pi/docs/message-types.md +279 -0
  291. package/vendor/pi/docs/models-configuration.md +196 -0
  292. package/vendor/pi/docs/models.md +225 -0
  293. package/vendor/pi/docs/nvidia-rtx-llama-cpp.md +96 -0
  294. package/vendor/pi/docs/packages.md +129 -0
  295. package/vendor/pi/docs/prompt-templates.md +59 -0
  296. package/vendor/pi/docs/providers.md +247 -0
  297. package/vendor/pi/docs/quickstart.md +136 -0
  298. package/vendor/pi/docs/rpc-commands.md +860 -0
  299. package/vendor/pi/docs/rpc-extension-ui.md +200 -0
  300. package/vendor/pi/docs/rpc.md +193 -0
  301. package/vendor/pi/docs/sdk.md +147 -0
  302. package/vendor/pi/docs/security.md +99 -0
  303. package/vendor/pi/docs/session-format.md +293 -0
  304. package/vendor/pi/docs/sessions.md +66 -0
  305. package/vendor/pi/docs/settings.md +172 -0
  306. package/vendor/pi/docs/shell-aliases.md +93 -0
  307. package/vendor/pi/docs/skills.md +93 -0
  308. package/vendor/pi/docs/slash-commands.md +60 -0
  309. package/vendor/pi/docs/terminal-setup.md +233 -0
  310. package/vendor/pi/docs/termux.md +117 -0
  311. package/vendor/pi/docs/themes.md +138 -0
  312. package/vendor/pi/docs/tmux.md +55 -0
  313. package/vendor/pi/docs/tui.md +195 -0
  314. package/vendor/pi/docs/usage.md +94 -0
  315. package/vendor/pi/docs/virtual-models.md +114 -0
  316. package/vendor/pi/docs/windows.md +81 -0
  317. package/vendor/pi/examples/README.md +36 -0
  318. package/vendor/pi/examples/extensions/README.md +214 -0
  319. package/vendor/pi/examples/extensions/auto-commit-on-exit.ts +49 -0
  320. package/vendor/pi/examples/extensions/bash-spawn-hook.ts +30 -0
  321. package/vendor/pi/examples/extensions/bookmark.ts +50 -0
  322. package/vendor/pi/examples/extensions/border-status-editor.ts +150 -0
  323. package/vendor/pi/examples/extensions/built-in-tool-renderer.ts +225 -0
  324. package/vendor/pi/examples/extensions/claude-rules.ts +86 -0
  325. package/vendor/pi/examples/extensions/commands.ts +72 -0
  326. package/vendor/pi/examples/extensions/confirm-destructive.ts +59 -0
  327. package/vendor/pi/examples/extensions/custom-compaction.ts +117 -0
  328. package/vendor/pi/examples/extensions/custom-footer.ts +64 -0
  329. package/vendor/pi/examples/extensions/custom-header.ts +73 -0
  330. package/vendor/pi/examples/extensions/custom-provider-anthropic/index.ts +617 -0
  331. package/vendor/pi/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  332. package/vendor/pi/examples/extensions/custom-provider-anthropic/package.json +19 -0
  333. package/vendor/pi/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  334. package/vendor/pi/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  335. package/vendor/pi/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  336. package/vendor/pi/examples/extensions/debug-provider.ts +90 -0
  337. package/vendor/pi/examples/extensions/dirty-repo-guard.ts +56 -0
  338. package/vendor/pi/examples/extensions/doom-overlay/README.md +46 -0
  339. package/vendor/pi/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  340. package/vendor/pi/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  341. package/vendor/pi/examples/extensions/doom-overlay/doom/build.sh +152 -0
  342. package/vendor/pi/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  343. package/vendor/pi/examples/extensions/doom-overlay/doom-component.ts +132 -0
  344. package/vendor/pi/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  345. package/vendor/pi/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  346. package/vendor/pi/examples/extensions/doom-overlay/index.ts +74 -0
  347. package/vendor/pi/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  348. package/vendor/pi/examples/extensions/dynamic-resources/SKILL.md +8 -0
  349. package/vendor/pi/examples/extensions/dynamic-resources/dynamic.json +81 -0
  350. package/vendor/pi/examples/extensions/dynamic-resources/dynamic.md +5 -0
  351. package/vendor/pi/examples/extensions/dynamic-resources/index.ts +15 -0
  352. package/vendor/pi/examples/extensions/dynamic-tools.ts +74 -0
  353. package/vendor/pi/examples/extensions/entry-renderer.ts +41 -0
  354. package/vendor/pi/examples/extensions/event-bus.ts +43 -0
  355. package/vendor/pi/examples/extensions/file-trigger.ts +41 -0
  356. package/vendor/pi/examples/extensions/git-checkpoint.ts +53 -0
  357. package/vendor/pi/examples/extensions/git-merge-and-resolve.ts +115 -0
  358. package/vendor/pi/examples/extensions/github-issue-autocomplete.ts +185 -0
  359. package/vendor/pi/examples/extensions/gondolin/index.ts +531 -0
  360. package/vendor/pi/examples/extensions/gondolin/package-lock.json +185 -0
  361. package/vendor/pi/examples/extensions/gondolin/package.json +19 -0
  362. package/vendor/pi/examples/extensions/handoff.ts +190 -0
  363. package/vendor/pi/examples/extensions/hello.ts +26 -0
  364. package/vendor/pi/examples/extensions/hidden-thinking-label.ts +53 -0
  365. package/vendor/pi/examples/extensions/inline-bash.ts +94 -0
  366. package/vendor/pi/examples/extensions/input-transform-streaming.ts +39 -0
  367. package/vendor/pi/examples/extensions/input-transform.ts +43 -0
  368. package/vendor/pi/examples/extensions/interactive-shell.ts +196 -0
  369. package/vendor/pi/examples/extensions/jev-router.ts +113 -0
  370. package/vendor/pi/examples/extensions/mac-system-theme.ts +47 -0
  371. package/vendor/pi/examples/extensions/message-renderer.ts +59 -0
  372. package/vendor/pi/examples/extensions/minimal-mode.ts +353 -0
  373. package/vendor/pi/examples/extensions/modal-editor.ts +85 -0
  374. package/vendor/pi/examples/extensions/model-status.ts +31 -0
  375. package/vendor/pi/examples/extensions/notify.ts +57 -0
  376. package/vendor/pi/examples/extensions/overlay-qa-tests.ts +1450 -0
  377. package/vendor/pi/examples/extensions/overlay-test.ts +153 -0
  378. package/vendor/pi/examples/extensions/permission-gate.ts +34 -0
  379. package/vendor/pi/examples/extensions/pirate.ts +47 -0
  380. package/vendor/pi/examples/extensions/plan-mode/README.md +66 -0
  381. package/vendor/pi/examples/extensions/plan-mode/index.ts +394 -0
  382. package/vendor/pi/examples/extensions/plan-mode/utils.ts +168 -0
  383. package/vendor/pi/examples/extensions/preset.ts +436 -0
  384. package/vendor/pi/examples/extensions/project-trust.ts +64 -0
  385. package/vendor/pi/examples/extensions/prompt-customizer.ts +49 -0
  386. package/vendor/pi/examples/extensions/protected-paths.ts +30 -0
  387. package/vendor/pi/examples/extensions/provider-payload.ts +18 -0
  388. package/vendor/pi/examples/extensions/qna.ts +118 -0
  389. package/vendor/pi/examples/extensions/question.ts +286 -0
  390. package/vendor/pi/examples/extensions/questionnaire.ts +448 -0
  391. package/vendor/pi/examples/extensions/rainbow-editor.ts +88 -0
  392. package/vendor/pi/examples/extensions/reload-runtime.ts +37 -0
  393. package/vendor/pi/examples/extensions/rpc-demo.ts +118 -0
  394. package/vendor/pi/examples/extensions/sandbox/index.ts +321 -0
  395. package/vendor/pi/examples/extensions/sandbox/package-lock.json +92 -0
  396. package/vendor/pi/examples/extensions/sandbox/package.json +19 -0
  397. package/vendor/pi/examples/extensions/send-user-message.ts +97 -0
  398. package/vendor/pi/examples/extensions/session-name.ts +27 -0
  399. package/vendor/pi/examples/extensions/shutdown-command.ts +63 -0
  400. package/vendor/pi/examples/extensions/snake.ts +343 -0
  401. package/vendor/pi/examples/extensions/space-invaders.ts +560 -0
  402. package/vendor/pi/examples/extensions/ssh.ts +220 -0
  403. package/vendor/pi/examples/extensions/status-line.ts +32 -0
  404. package/vendor/pi/examples/extensions/structured-output.ts +65 -0
  405. package/vendor/pi/examples/extensions/subagent/README.md +177 -0
  406. package/vendor/pi/examples/extensions/subagent/agents/planner.md +37 -0
  407. package/vendor/pi/examples/extensions/subagent/agents/reviewer.md +35 -0
  408. package/vendor/pi/examples/extensions/subagent/agents/scout.md +50 -0
  409. package/vendor/pi/examples/extensions/subagent/agents/worker.md +24 -0
  410. package/vendor/pi/examples/extensions/subagent/agents.ts +157 -0
  411. package/vendor/pi/examples/extensions/subagent/index.ts +1036 -0
  412. package/vendor/pi/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  413. package/vendor/pi/examples/extensions/subagent/prompts/implement.md +10 -0
  414. package/vendor/pi/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  415. package/vendor/pi/examples/extensions/summarize.ts +199 -0
  416. package/vendor/pi/examples/extensions/system-prompt-header.ts +17 -0
  417. package/vendor/pi/examples/extensions/tic-tac-toe.ts +1008 -0
  418. package/vendor/pi/examples/extensions/timed-confirm.ts +70 -0
  419. package/vendor/pi/examples/extensions/titlebar-spinner.ts +58 -0
  420. package/vendor/pi/examples/extensions/todo.ts +297 -0
  421. package/vendor/pi/examples/extensions/tool-override.ts +144 -0
  422. package/vendor/pi/examples/extensions/tools.ts +146 -0
  423. package/vendor/pi/examples/extensions/trigger-compact.ts +50 -0
  424. package/vendor/pi/examples/extensions/truncated-tool.ts +195 -0
  425. package/vendor/pi/examples/extensions/widget-placement.ts +9 -0
  426. package/vendor/pi/examples/extensions/with-deps/index.ts +32 -0
  427. package/vendor/pi/examples/extensions/with-deps/package-lock.json +31 -0
  428. package/vendor/pi/examples/extensions/with-deps/package.json +22 -0
  429. package/vendor/pi/examples/extensions/working-indicator.ts +123 -0
  430. package/vendor/pi/examples/extensions/working-message-test.ts +25 -0
  431. package/vendor/pi/examples/rpc-client.ts +35 -0
  432. package/vendor/pi/examples/rpc-extension-ui.ts +661 -0
  433. package/vendor/pi/examples/sdk/01-minimal.ts +26 -0
  434. package/vendor/pi/examples/sdk/02-custom-model.ts +49 -0
  435. package/vendor/pi/examples/sdk/03-custom-prompt.ts +75 -0
  436. package/vendor/pi/examples/sdk/04-skills.ts +55 -0
  437. package/vendor/pi/examples/sdk/05-tools.ts +48 -0
  438. package/vendor/pi/examples/sdk/06-extensions.ts +99 -0
  439. package/vendor/pi/examples/sdk/07-context-files.ts +47 -0
  440. package/vendor/pi/examples/sdk/08-prompt-templates.ts +51 -0
  441. package/vendor/pi/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  442. package/vendor/pi/examples/sdk/10-settings.ts +53 -0
  443. package/vendor/pi/examples/sdk/11-sessions.ts +52 -0
  444. package/vendor/pi/examples/sdk/12-full-control.ts +74 -0
  445. package/vendor/pi/examples/sdk/13-session-runtime.ts +67 -0
  446. package/vendor/pi/examples/sdk/14-codemode-mcp.ts +61 -0
  447. package/vendor/pi/examples/sdk/README.md +141 -0
  448. package/vendor/pi/package.json +98 -0
  449. package/vendor/pi/schemas/keybindings.schema.json +393 -0
  450. package/vendor/pi/schemas/models.schema.json +1211 -0
  451. package/vendor/pi/schemas/settings.schema.json +783 -0
  452. package/vendor/pi/schemas/theme.schema.json +365 -0
  453. package/vendor/pi-ai/bedrock.js +4 -0
  454. package/vendor/pi-ai/oauth-load.js +4 -0
  455. package/vendor/quickjs.wasm +0 -0
  456. package/web/dist/assets/board-math-css-BPXakv_3.js +2 -0
  457. package/web/dist/assets/index-BHZpFXhc.js +525 -0
  458. package/web/dist/assets/index-DqWMdMkh.css +1 -0
  459. package/web/dist/assets/index-WCm6wwmM.js +1 -0
  460. package/web/dist/index.html +2 -2
  461. package/dist/agent-adapter/bg-wait.d.ts +0 -11
  462. package/dist/agent-adapter/bg-wait.js +0 -32
  463. package/dist/agent-adapter/capabilities.d.ts +0 -18
  464. package/dist/agent-adapter/capabilities.js +0 -39
  465. package/dist/agent-adapter/claude/active-capture-registry.d.ts +0 -7
  466. package/dist/agent-adapter/claude/active-capture-registry.js +0 -42
  467. package/dist/agent-adapter/claude/adapter.d.ts +0 -170
  468. package/dist/agent-adapter/claude/adapter.js +0 -459
  469. package/dist/agent-adapter/claude/assistant-blocks.d.ts +0 -5
  470. package/dist/agent-adapter/claude/assistant-blocks.js +0 -61
  471. package/dist/agent-adapter/claude/bg-task-tracker.d.ts +0 -105
  472. package/dist/agent-adapter/claude/bg-task-tracker.js +0 -168
  473. package/dist/agent-adapter/claude/cache-refresh.d.ts +0 -58
  474. package/dist/agent-adapter/claude/cache-refresh.js +0 -145
  475. package/dist/agent-adapter/claude/cache-touch.d.ts +0 -12
  476. package/dist/agent-adapter/claude/cache-touch.js +0 -75
  477. package/dist/agent-adapter/claude/compact-window.d.ts +0 -18
  478. package/dist/agent-adapter/claude/compact-window.js +0 -49
  479. package/dist/agent-adapter/claude/context-usage.d.ts +0 -28
  480. package/dist/agent-adapter/claude/context-usage.js +0 -173
  481. package/dist/agent-adapter/claude/defaults.d.ts +0 -42
  482. package/dist/agent-adapter/claude/defaults.js +0 -59
  483. package/dist/agent-adapter/claude/engine.d.ts +0 -75
  484. package/dist/agent-adapter/claude/engine.js +0 -139
  485. package/dist/agent-adapter/claude/event-parser.d.ts +0 -60
  486. package/dist/agent-adapter/claude/event-parser.js +0 -259
  487. package/dist/agent-adapter/claude/event-translator.d.ts +0 -45
  488. package/dist/agent-adapter/claude/event-translator.js +0 -98
  489. package/dist/agent-adapter/claude/hooks-builder.d.ts +0 -19
  490. package/dist/agent-adapter/claude/hooks-builder.js +0 -57
  491. package/dist/agent-adapter/claude/mcp-config.d.ts +0 -11
  492. package/dist/agent-adapter/claude/mcp-config.js +0 -142
  493. package/dist/agent-adapter/claude/remote-mcp-proxy.d.ts +0 -1
  494. package/dist/agent-adapter/claude/session-options.d.ts +0 -70
  495. package/dist/agent-adapter/claude/session-options.js +0 -148
  496. package/dist/agent-adapter/claude/spawn-args.d.ts +0 -70
  497. package/dist/agent-adapter/claude/spawn-args.js +0 -367
  498. package/dist/agent-adapter/claude/tool-summarizers.d.ts +0 -2
  499. package/dist/agent-adapter/claude/tool-summarizers.js +0 -20
  500. package/dist/agent-adapter/claude/transcript-clear.d.ts +0 -42
  501. package/dist/agent-adapter/claude/transcript-clear.js +0 -217
  502. package/dist/agent-adapter/claude/transcript-path.d.ts +0 -39
  503. package/dist/agent-adapter/claude/transcript-path.js +0 -114
  504. package/dist/agent-adapter/claude/turn-machine.d.ts +0 -220
  505. package/dist/agent-adapter/claude/turn-machine.js +0 -731
  506. package/dist/agent-adapter/claude/window-warmup.d.ts +0 -13
  507. package/dist/agent-adapter/claude/window-warmup.js +0 -38
  508. package/dist/agent-adapter/continuation-phase.d.ts +0 -131
  509. package/dist/agent-adapter/continuation-phase.js +0 -345
  510. package/dist/agent-adapter/engine-injections.d.ts +0 -47
  511. package/dist/agent-adapter/engine-injections.js +0 -80
  512. package/dist/agent-adapter/mcp-remote-fetch.d.ts +0 -1
  513. package/dist/agent-adapter/mcp-remote-fetch.js +0 -32
  514. package/dist/agent-adapter/normalize/event-types.d.ts +0 -125
  515. package/dist/agent-adapter/normalize/event-types.js +0 -1
  516. package/dist/agent-adapter/normalize/prompt-builder.d.ts +0 -22
  517. package/dist/agent-adapter/normalize/prompt-builder.js +0 -41
  518. package/dist/agent-adapter/normalize/tool-result-images.d.ts +0 -11
  519. package/dist/agent-adapter/normalize/tool-result-images.js +0 -32
  520. package/dist/agent-adapter/pi/adapter.d.ts +0 -125
  521. package/dist/agent-adapter/pi/adapter.js +0 -275
  522. package/dist/agent-adapter/pi/agent-dir.d.ts +0 -57
  523. package/dist/agent-adapter/pi/agent-dir.js +0 -154
  524. package/dist/agent-adapter/pi/background-subagent.d.ts +0 -26
  525. package/dist/agent-adapter/pi/background-subagent.js +0 -1
  526. package/dist/agent-adapter/pi/child-events.d.ts +0 -13
  527. package/dist/agent-adapter/pi/child-events.js +0 -96
  528. package/dist/agent-adapter/pi/child-runner.d.ts +0 -31
  529. package/dist/agent-adapter/pi/child-runner.js +0 -133
  530. package/dist/agent-adapter/pi/child-session.d.ts +0 -28
  531. package/dist/agent-adapter/pi/child-session.js +0 -70
  532. package/dist/agent-adapter/pi/custom-catalog.d.ts +0 -10
  533. package/dist/agent-adapter/pi/custom-catalog.js +0 -38
  534. package/dist/agent-adapter/pi/defaults.d.ts +0 -7
  535. package/dist/agent-adapter/pi/defaults.js +0 -11
  536. package/dist/agent-adapter/pi/discovery.d.ts +0 -37
  537. package/dist/agent-adapter/pi/discovery.js +0 -33
  538. package/dist/agent-adapter/pi/engine.d.ts +0 -66
  539. package/dist/agent-adapter/pi/engine.js +0 -180
  540. package/dist/agent-adapter/pi/event-parser.d.ts +0 -43
  541. package/dist/agent-adapter/pi/event-parser.js +0 -446
  542. package/dist/agent-adapter/pi/extensions.d.ts +0 -33
  543. package/dist/agent-adapter/pi/extensions.js +0 -58
  544. package/dist/agent-adapter/pi/hook-bridge.d.ts +0 -54
  545. package/dist/agent-adapter/pi/hook-bridge.js +0 -394
  546. package/dist/agent-adapter/pi/image-first.d.ts +0 -3
  547. package/dist/agent-adapter/pi/image-first.js +0 -31
  548. package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +0 -32
  549. package/dist/agent-adapter/pi/mcp-bridge-logic.js +0 -63
  550. package/dist/agent-adapter/pi/mcp-bridge.d.ts +0 -65
  551. package/dist/agent-adapter/pi/mcp-bridge.js +0 -389
  552. package/dist/agent-adapter/pi/native-tool-policy.d.ts +0 -3
  553. package/dist/agent-adapter/pi/native-tool-policy.js +0 -11
  554. package/dist/agent-adapter/pi/pi-session.d.ts +0 -185
  555. package/dist/agent-adapter/pi/pi-session.js +0 -656
  556. package/dist/agent-adapter/pi/providers-config.d.ts +0 -60
  557. package/dist/agent-adapter/pi/providers-config.js +0 -96
  558. package/dist/agent-adapter/pi/quota-probe.d.ts +0 -12
  559. package/dist/agent-adapter/pi/quota-probe.js +0 -33
  560. package/dist/agent-adapter/pi/quota-sink.d.ts +0 -33
  561. package/dist/agent-adapter/pi/quota-sink.js +0 -57
  562. package/dist/agent-adapter/pi/runtime-settings.d.ts +0 -9
  563. package/dist/agent-adapter/pi/runtime-settings.js +0 -53
  564. package/dist/agent-adapter/pi/runtime.d.ts +0 -48
  565. package/dist/agent-adapter/pi/runtime.js +0 -163
  566. package/dist/agent-adapter/pi/session-files.d.ts +0 -2
  567. package/dist/agent-adapter/pi/session-files.js +0 -15
  568. package/dist/agent-adapter/pi/session-options.d.ts +0 -86
  569. package/dist/agent-adapter/pi/session-options.js +0 -162
  570. package/dist/agent-adapter/pi/session-support.d.ts +0 -54
  571. package/dist/agent-adapter/pi/session-support.js +0 -101
  572. package/dist/agent-adapter/pi/subagent-bridge.d.ts +0 -17
  573. package/dist/agent-adapter/pi/subagent-bridge.js +0 -1
  574. package/dist/agent-adapter/pi/subagent.d.ts +0 -100
  575. package/dist/agent-adapter/pi/subagent.js +0 -199
  576. package/dist/agent-adapter/pi/tool-shims.d.ts +0 -32
  577. package/dist/agent-adapter/pi/tool-shims.js +0 -148
  578. package/dist/agent-adapter/pi/ui-context.d.ts +0 -20
  579. package/dist/agent-adapter/pi/ui-context.js +0 -92
  580. package/dist/agent-adapter/pi/web-fetch.d.ts +0 -13
  581. package/dist/agent-adapter/pi/web-fetch.js +0 -196
  582. package/dist/agent-adapter/pi/web-search.d.ts +0 -9
  583. package/dist/agent-adapter/pi/web-search.js +0 -517
  584. package/dist/agent-adapter/run-events.d.ts +0 -169
  585. package/dist/agent-adapter/run-events.js +0 -119
  586. package/dist/agent-adapter/types.d.ts +0 -330
  587. package/dist/agent-adapter/types.js +0 -3
  588. package/dist/core/agents/roles.d.ts +0 -50
  589. package/dist/core/agents/roles.js +0 -176
  590. package/dist/core/agents/subagent/attribution.d.ts +0 -15
  591. package/dist/core/agents/subagent/attribution.js +0 -60
  592. package/dist/core/agents/subagent/catalog.d.ts +0 -65
  593. package/dist/core/agents/subagent/catalog.js +0 -200
  594. package/dist/core/agents/subagent/model-spec.d.ts +0 -28
  595. package/dist/core/agents/subagent/model-spec.js +0 -39
  596. package/dist/core/agents/subagent/orchestrate.d.ts +0 -25
  597. package/dist/core/agents/subagent/orchestrate.js +0 -92
  598. package/dist/core/agents/subagent/schema.d.ts +0 -12
  599. package/dist/core/agents/subagent/schema.js +0 -51
  600. package/dist/core/agents/subagent/types.d.ts +0 -84
  601. package/dist/core/agents/subagent/types.js +0 -1
  602. package/dist/core/agents/subagent/usage.d.ts +0 -8
  603. package/dist/core/agents/subagent/usage.js +0 -32
  604. package/dist/core/anthropic-model-discovery.d.ts +0 -54
  605. package/dist/core/anthropic-model-discovery.js +0 -156
  606. package/dist/core/anthropic-models.d.ts +0 -1
  607. package/dist/core/anthropic-models.js +0 -13
  608. package/dist/core/async-mutex.d.ts +0 -6
  609. package/dist/core/async-mutex.js +0 -32
  610. package/dist/core/atomic-write.d.ts +0 -9
  611. package/dist/core/atomic-write.js +0 -104
  612. package/dist/core/auth.d.ts +0 -40
  613. package/dist/core/auth.js +0 -94
  614. package/dist/core/board-action.d.ts +0 -19
  615. package/dist/core/board-action.js +0 -24
  616. package/dist/core/builtin-layer.d.ts +0 -22
  617. package/dist/core/builtin-layer.js +0 -45
  618. package/dist/core/cached-scan.d.ts +0 -42
  619. package/dist/core/cached-scan.js +0 -95
  620. package/dist/core/calver.d.ts +0 -1
  621. package/dist/core/calver.js +0 -25
  622. package/dist/core/claude-credentials.d.ts +0 -91
  623. package/dist/core/claude-credentials.js +0 -242
  624. package/dist/core/cli-utils.d.ts +0 -56
  625. package/dist/core/cli-utils.js +0 -70
  626. package/dist/core/codex-quota.d.ts +0 -27
  627. package/dist/core/codex-quota.js +0 -55
  628. package/dist/core/codex-token.d.ts +0 -4
  629. package/dist/core/codex-token.js +0 -26
  630. package/dist/core/config-generator.d.ts +0 -17
  631. package/dist/core/config-generator.js +0 -181
  632. package/dist/core/debug-mode.d.ts +0 -15
  633. package/dist/core/debug-mode.js +0 -22
  634. package/dist/core/exec-async.d.ts +0 -28
  635. package/dist/core/exec-async.js +0 -48
  636. package/dist/core/file-lock.d.ts +0 -15
  637. package/dist/core/file-lock.js +0 -164
  638. package/dist/core/format-duration.d.ts +0 -7
  639. package/dist/core/format-duration.js +0 -23
  640. package/dist/core/gateway-generator.d.ts +0 -152
  641. package/dist/core/gateway-generator.js +0 -559
  642. package/dist/core/git-availability.d.ts +0 -2
  643. package/dist/core/git-availability.js +0 -43
  644. package/dist/core/hook-bus.d.ts +0 -25
  645. package/dist/core/hook-bus.js +0 -99
  646. package/dist/core/hook-exec.d.ts +0 -15
  647. package/dist/core/hook-exec.js +0 -86
  648. package/dist/core/hook-scripts.d.ts +0 -19
  649. package/dist/core/hook-scripts.js +0 -30
  650. package/dist/core/i18n.d.ts +0 -19
  651. package/dist/core/i18n.js +0 -42
  652. package/dist/core/icons.d.ts +0 -72
  653. package/dist/core/icons.js +0 -71
  654. package/dist/core/json-repository.d.ts +0 -78
  655. package/dist/core/json-repository.js +0 -154
  656. package/dist/core/locales/en.d.ts +0 -911
  657. package/dist/core/locales/en.js +0 -32
  658. package/dist/core/locales/slices/commands.d.ts +0 -301
  659. package/dist/core/locales/slices/commands.js +0 -634
  660. package/dist/core/locales/slices/init.d.ts +0 -153
  661. package/dist/core/locales/slices/init.js +0 -431
  662. package/dist/core/locales/slices/interactions.d.ts +0 -47
  663. package/dist/core/locales/slices/interactions.js +0 -99
  664. package/dist/core/locales/slices/lang.d.ts +0 -8
  665. package/dist/core/locales/slices/lang.js +0 -15
  666. package/dist/core/locales/slices/notices.d.ts +0 -78
  667. package/dist/core/locales/slices/notices.js +0 -156
  668. package/dist/core/locales/slices/providers.d.ts +0 -43
  669. package/dist/core/locales/slices/providers.js +0 -87
  670. package/dist/core/locales/slices/scheduling.d.ts +0 -33
  671. package/dist/core/locales/slices/scheduling.js +0 -65
  672. package/dist/core/locales/slices/startup.d.ts +0 -10
  673. package/dist/core/locales/slices/startup.js +0 -19
  674. package/dist/core/locales/slices/status.d.ts +0 -48
  675. package/dist/core/locales/slices/status.js +0 -109
  676. package/dist/core/locales/slices/tui.d.ts +0 -93
  677. package/dist/core/locales/slices/tui.js +0 -192
  678. package/dist/core/locales/slices/uiextra.d.ts +0 -49
  679. package/dist/core/locales/slices/uiextra.js +0 -102
  680. package/dist/core/locales/slices/uimsg.d.ts +0 -74
  681. package/dist/core/locales/slices/uimsg.js +0 -158
  682. package/dist/core/locales/zh.d.ts +0 -5
  683. package/dist/core/locales/zh.js +0 -30
  684. package/dist/core/log.d.ts +0 -16
  685. package/dist/core/log.js +0 -174
  686. package/dist/core/loopback-http.d.ts +0 -6
  687. package/dist/core/loopback-http.js +0 -43
  688. package/dist/core/mcp-bundles.d.ts +0 -8
  689. package/dist/core/mcp-bundles.js +0 -47
  690. package/dist/core/mcp-timeout.d.ts +0 -1
  691. package/dist/core/mcp-timeout.js +0 -1
  692. package/dist/core/mcp-tool-gate.d.ts +0 -25
  693. package/dist/core/mcp-tool-gate.js +0 -97
  694. package/dist/core/media-types.d.ts +0 -20
  695. package/dist/core/media-types.js +0 -63
  696. package/dist/core/models-generator.d.ts +0 -29
  697. package/dist/core/models-generator.js +0 -82
  698. package/dist/core/native-name.d.ts +0 -4
  699. package/dist/core/native-name.js +0 -57
  700. package/dist/core/paths.d.ts +0 -63
  701. package/dist/core/paths.js +0 -105
  702. package/dist/core/pi-sdk.d.ts +0 -38
  703. package/dist/core/pi-session-filename.d.ts +0 -10
  704. package/dist/core/pi-session-filename.js +0 -49
  705. package/dist/core/platform-settings-spec.d.ts +0 -47
  706. package/dist/core/platform-settings-spec.js +0 -28
  707. package/dist/core/private-dir.d.ts +0 -13
  708. package/dist/core/private-dir.js +0 -48
  709. package/dist/core/process-command-line.d.ts +0 -6
  710. package/dist/core/process-command-line.js +0 -39
  711. package/dist/core/prompt-template.d.ts +0 -14
  712. package/dist/core/prompt-template.js +0 -29
  713. package/dist/core/rebuild-progress.d.ts +0 -59
  714. package/dist/core/rebuild-progress.js +0 -106
  715. package/dist/core/resilient-watch.d.ts +0 -28
  716. package/dist/core/resilient-watch.js +0 -108
  717. package/dist/core/resume-reminder.d.ts +0 -5
  718. package/dist/core/resume-reminder.js +0 -12
  719. package/dist/core/run-registry.d.ts +0 -134
  720. package/dist/core/run-registry.js +0 -256
  721. package/dist/core/runtime-env.d.ts +0 -1
  722. package/dist/core/runtime-env.js +0 -11
  723. package/dist/core/session-holds.d.ts +0 -88
  724. package/dist/core/session-holds.js +0 -168
  725. package/dist/core/session-state.d.ts +0 -32
  726. package/dist/core/session-state.js +0 -39
  727. package/dist/core/session-todos.d.ts +0 -12
  728. package/dist/core/session-todos.js +0 -44
  729. package/dist/core/settings-migration.d.ts +0 -5
  730. package/dist/core/settings-migration.js +0 -128
  731. package/dist/core/settings-spec.d.ts +0 -301
  732. package/dist/core/settings-spec.js +0 -309
  733. package/dist/core/settings.d.ts +0 -19
  734. package/dist/core/settings.js +0 -492
  735. package/dist/core/short-session-id.d.ts +0 -2
  736. package/dist/core/short-session-id.js +0 -4
  737. package/dist/core/singleton-lock.d.ts +0 -39
  738. package/dist/core/singleton-lock.js +0 -127
  739. package/dist/core/status-format.d.ts +0 -70
  740. package/dist/core/status-format.js +0 -59
  741. package/dist/core/subagent-spawn.d.ts +0 -40
  742. package/dist/core/subagent-spawn.js +0 -47
  743. package/dist/core/team-action.d.ts +0 -28
  744. package/dist/core/team-action.js +0 -65
  745. package/dist/core/todo.d.ts +0 -18
  746. package/dist/core/todo.js +0 -79
  747. package/dist/core/tool-names.d.ts +0 -12
  748. package/dist/core/tool-names.js +0 -65
  749. package/dist/core/types/agent-types.d.ts +0 -173
  750. package/dist/core/types/agent-types.js +0 -1
  751. package/dist/core/types/environment-types.d.ts +0 -45
  752. package/dist/core/types/environment-types.js +0 -1
  753. package/dist/core/utils.d.ts +0 -72
  754. package/dist/core/utils.js +0 -176
  755. package/dist/core/version.d.ts +0 -6
  756. package/dist/core/version.js +0 -11
  757. package/dist/core/workspace-filenames.d.ts +0 -9
  758. package/dist/core/workspace-filenames.js +0 -61
  759. package/dist/domain/agents/agent-state.d.ts +0 -19
  760. package/dist/domain/agents/agent-state.js +0 -73
  761. package/dist/domain/agents/agent-switch.d.ts +0 -16
  762. package/dist/domain/agents/agent-switch.js +0 -30
  763. package/dist/domain/agents/config.d.ts +0 -20
  764. package/dist/domain/agents/config.js +0 -89
  765. package/dist/domain/agents/engine-selection.d.ts +0 -21
  766. package/dist/domain/agents/engine-selection.js +0 -37
  767. package/dist/domain/agents/environments/entities.d.ts +0 -50
  768. package/dist/domain/agents/environments/entities.js +0 -94
  769. package/dist/domain/agents/environments/file-refs.d.ts +0 -20
  770. package/dist/domain/agents/environments/file-refs.js +0 -51
  771. package/dist/domain/agents/environments/index.d.ts +0 -7
  772. package/dist/domain/agents/environments/index.js +0 -9
  773. package/dist/domain/agents/environments/paths.d.ts +0 -7
  774. package/dist/domain/agents/environments/paths.js +0 -9
  775. package/dist/domain/agents/environments/prompt-includes.d.ts +0 -1
  776. package/dist/domain/agents/environments/prompt-includes.js +0 -91
  777. package/dist/domain/agents/environments/registry.d.ts +0 -17
  778. package/dist/domain/agents/environments/registry.js +0 -163
  779. package/dist/domain/agents/environments/resolve.d.ts +0 -11
  780. package/dist/domain/agents/environments/resolve.js +0 -36
  781. package/dist/domain/agents/environments/schema.d.ts +0 -69
  782. package/dist/domain/agents/environments/schema.js +0 -115
  783. package/dist/domain/agents/environments/schema.parity.d.ts +0 -1
  784. package/dist/domain/agents/environments/schema.parity.js +0 -7
  785. package/dist/domain/agents/environments/system-prompt.d.ts +0 -37
  786. package/dist/domain/agents/environments/system-prompt.js +0 -110
  787. package/dist/domain/agents/index.d.ts +0 -6
  788. package/dist/domain/agents/index.js +0 -7
  789. package/dist/domain/agents/model-selection.d.ts +0 -30
  790. package/dist/domain/agents/model-selection.js +0 -111
  791. package/dist/domain/agents/models.d.ts +0 -12
  792. package/dist/domain/agents/models.js +0 -94
  793. package/dist/domain/agents/provider-run-lifecycle.d.ts +0 -11
  794. package/dist/domain/agents/provider-run-lifecycle.js +0 -17
  795. package/dist/domain/agents/subagent/background-spend.d.ts +0 -17
  796. package/dist/domain/agents/subagent/background-spend.js +0 -42
  797. package/dist/domain/agents/subagent/foreign.d.ts +0 -13
  798. package/dist/domain/agents/subagent/foreign.js +0 -30
  799. package/dist/domain/agents/subagent/registry.d.ts +0 -106
  800. package/dist/domain/agents/subagent/registry.js +0 -272
  801. package/dist/domain/agents/subagent/runner.d.ts +0 -61
  802. package/dist/domain/agents/subagent/runner.js +0 -301
  803. package/dist/domain/agents/subagent/service.d.ts +0 -26
  804. package/dist/domain/agents/subagent/service.js +0 -68
  805. package/dist/domain/auth/anthropic-env.d.ts +0 -20
  806. package/dist/domain/auth/anthropic-env.js +0 -132
  807. package/dist/domain/auth/auth-events.d.ts +0 -18
  808. package/dist/domain/auth/auth-events.js +0 -34
  809. package/dist/domain/auth/auth-format.d.ts +0 -2
  810. package/dist/domain/auth/auth-format.js +0 -53
  811. package/dist/domain/auth/auth-status.d.ts +0 -63
  812. package/dist/domain/auth/auth-status.js +0 -286
  813. package/dist/domain/auth/auth-watch.d.ts +0 -16
  814. package/dist/domain/auth/auth-watch.js +0 -166
  815. package/dist/domain/auth/cc-auth-cli.d.ts +0 -30
  816. package/dist/domain/auth/cc-login.d.ts +0 -7
  817. package/dist/domain/auth/cc-login.js +0 -20
  818. package/dist/domain/auth/cc-subscription.d.ts +0 -18
  819. package/dist/domain/auth/cc-subscription.js +0 -54
  820. package/dist/domain/auth/claude-account-credentials.d.ts +0 -13
  821. package/dist/domain/auth/claude-account-credentials.js +0 -22
  822. package/dist/domain/auth/claude-user-settings.d.ts +0 -22
  823. package/dist/domain/auth/claude-user-settings.js +0 -104
  824. package/dist/domain/auth/codex-credentials.d.ts +0 -13
  825. package/dist/domain/auth/codex-credentials.js +0 -25
  826. package/dist/domain/auth/gateway-sync.d.ts +0 -19
  827. package/dist/domain/auth/gateway-sync.js +0 -46
  828. package/dist/domain/auth/index.d.ts +0 -14
  829. package/dist/domain/auth/index.js +0 -14
  830. package/dist/domain/auth/login-flow.d.ts +0 -141
  831. package/dist/domain/auth/login-flow.js +0 -339
  832. package/dist/domain/auth/login-service.d.ts +0 -33
  833. package/dist/domain/auth/login-service.js +0 -65
  834. package/dist/domain/auth/logout.d.ts +0 -32
  835. package/dist/domain/auth/logout.js +0 -156
  836. package/dist/domain/auth/pi-login.d.ts +0 -26
  837. package/dist/domain/auth/pi-login.js +0 -70
  838. package/dist/domain/auth/pi-oauth.d.ts +0 -26
  839. package/dist/domain/auth/pi-oauth.js +0 -85
  840. package/dist/domain/auth/pi-runtime.d.ts +0 -82
  841. package/dist/domain/auth/pi-runtime.js +0 -40
  842. package/dist/domain/benchmark/accounting-reconciliation.d.ts +0 -117
  843. package/dist/domain/benchmark/accounting-reconciliation.js +0 -174
  844. package/dist/domain/benchmark/atif.d.ts +0 -42
  845. package/dist/domain/benchmark/atif.js +0 -263
  846. package/dist/domain/benchmark/attempt-record.d.ts +0 -167
  847. package/dist/domain/benchmark/attempt-record.js +0 -113
  848. package/dist/domain/benchmark/benchmark-types.d.ts +0 -17
  849. package/dist/domain/benchmark/benchmark-types.js +0 -1
  850. package/dist/domain/benchmark/composite-manifest.d.ts +0 -117
  851. package/dist/domain/benchmark/composite-manifest.js +0 -477
  852. package/dist/domain/benchmark/decimal-text.d.ts +0 -22
  853. package/dist/domain/benchmark/decimal-text.js +0 -42
  854. package/dist/domain/benchmark/identity.d.ts +0 -39
  855. package/dist/domain/benchmark/identity.js +0 -70
  856. package/dist/domain/benchmark/journal.d.ts +0 -47
  857. package/dist/domain/benchmark/journal.js +0 -254
  858. package/dist/domain/benchmark/manifest-contract.d.ts +0 -30
  859. package/dist/domain/benchmark/manifest-contract.js +0 -118
  860. package/dist/domain/benchmark/production-attempt-identity.d.ts +0 -73
  861. package/dist/domain/benchmark/production-attempt-identity.js +0 -372
  862. package/dist/domain/benchmark/production-attempt-journal.d.ts +0 -38
  863. package/dist/domain/benchmark/production-attempt-journal.js +0 -267
  864. package/dist/domain/benchmark/production-benchmark-evidence.d.ts +0 -2
  865. package/dist/domain/benchmark/production-benchmark-evidence.js +0 -67
  866. package/dist/domain/benchmark/production-evidence-export.d.ts +0 -14
  867. package/dist/domain/benchmark/production-evidence-export.js +0 -134
  868. package/dist/domain/benchmark/production-evidence-journal.d.ts +0 -11
  869. package/dist/domain/benchmark/production-evidence-journal.js +0 -81
  870. package/dist/domain/benchmark/production-evidence-projection.d.ts +0 -39
  871. package/dist/domain/benchmark/production-evidence-projection.js +0 -392
  872. package/dist/domain/benchmark/role-surface.d.ts +0 -4
  873. package/dist/domain/benchmark/role-surface.js +0 -117
  874. package/dist/domain/benchmark/session-evidence.d.ts +0 -7
  875. package/dist/domain/benchmark/session-evidence.js +0 -34
  876. package/dist/domain/boards/board-context.d.ts +0 -17
  877. package/dist/domain/boards/board-context.js +0 -11
  878. package/dist/domain/boards/board-paths.d.ts +0 -18
  879. package/dist/domain/boards/board-paths.js +0 -32
  880. package/dist/domain/boards/board-service.d.ts +0 -50
  881. package/dist/domain/boards/board-service.js +0 -146
  882. package/dist/domain/boards/board-watcher.d.ts +0 -36
  883. package/dist/domain/boards/board-watcher.js +0 -284
  884. package/dist/domain/boards/decision-projection.d.ts +0 -46
  885. package/dist/domain/boards/decision-projection.js +0 -44
  886. package/dist/domain/browser/broker.d.ts +0 -99
  887. package/dist/domain/browser/broker.js +0 -487
  888. package/dist/domain/costs/account-reset.d.ts +0 -30
  889. package/dist/domain/costs/account-reset.js +0 -98
  890. package/dist/domain/costs/aistatus-config.d.ts +0 -27
  891. package/dist/domain/costs/aistatus-config.js +0 -56
  892. package/dist/domain/costs/claude-account.d.ts +0 -34
  893. package/dist/domain/costs/claude-account.js +0 -170
  894. package/dist/domain/costs/codex-account.d.ts +0 -55
  895. package/dist/domain/costs/codex-account.js +0 -155
  896. package/dist/domain/costs/cost-tracker.d.ts +0 -181
  897. package/dist/domain/costs/cost-tracker.js +0 -350
  898. package/dist/domain/costs/gateway-manager.d.ts +0 -6
  899. package/dist/domain/costs/gateway-manager.js +0 -225
  900. package/dist/domain/costs/rate-limit-throttle.d.ts +0 -78
  901. package/dist/domain/costs/rate-limit-throttle.js +0 -502
  902. package/dist/domain/costs/reset-account.d.ts +0 -36
  903. package/dist/domain/costs/reset-account.js +0 -5
  904. package/dist/domain/costs/resume-registry.d.ts +0 -30
  905. package/dist/domain/costs/resume-registry.js +0 -108
  906. package/dist/domain/costs/usage-service.d.ts +0 -80
  907. package/dist/domain/costs/usage-service.js +0 -618
  908. package/dist/domain/costs/usage-store.d.ts +0 -83
  909. package/dist/domain/costs/usage-store.js +0 -104
  910. package/dist/domain/executions/registry.d.ts +0 -47
  911. package/dist/domain/executions/registry.js +0 -100
  912. package/dist/domain/hooks/hook-view.d.ts +0 -22
  913. package/dist/domain/hooks/hook-view.js +0 -34
  914. package/dist/domain/mcp/bundled-server.d.ts +0 -19
  915. package/dist/domain/mcp/feishu/client.d.ts +0 -46
  916. package/dist/domain/mcp/feishu/client.js +0 -91
  917. package/dist/domain/mcp/feishu/file.d.ts +0 -14
  918. package/dist/domain/mcp/feishu/file.js +0 -88
  919. package/dist/domain/mcp/feishu/types.d.ts +0 -31
  920. package/dist/domain/mcp/feishu/types.js +0 -34
  921. package/dist/domain/mcp/feishu/user-auth.d.ts +0 -140
  922. package/dist/domain/mcp/feishu/user-auth.js +0 -278
  923. package/dist/domain/mcp/tools/agents-md.d.ts +0 -16
  924. package/dist/domain/mcp/tools/agents-md.js +0 -34
  925. package/dist/domain/mcp/tools/catalog-owner.d.ts +0 -3
  926. package/dist/domain/mcp/tools/catalog-owner.js +0 -23
  927. package/dist/domain/mcp/tools/context.d.ts +0 -69
  928. package/dist/domain/mcp/tools/context.js +0 -106
  929. package/dist/domain/mcp/tools/cost.d.ts +0 -2
  930. package/dist/domain/mcp/tools/cost.js +0 -56
  931. package/dist/domain/mcp/tools/executions.d.ts +0 -2
  932. package/dist/domain/mcp/tools/executions.js +0 -71
  933. package/dist/domain/mcp/tools/interaction-ask.d.ts +0 -37
  934. package/dist/domain/mcp/tools/interaction-ask.js +0 -131
  935. package/dist/domain/mcp/tools/interaction-plan.d.ts +0 -34
  936. package/dist/domain/mcp/tools/interaction-plan.js +0 -116
  937. package/dist/domain/mcp/tools/remote-devices.d.ts +0 -9
  938. package/dist/domain/mcp/tools/remote-devices.js +0 -28
  939. package/dist/domain/mcp/tools/remote-file.d.ts +0 -24
  940. package/dist/domain/mcp/tools/remote-file.js +0 -52
  941. package/dist/domain/mcp/tools/remote-ops.d.ts +0 -3
  942. package/dist/domain/mcp/tools/remote-ops.js +0 -359
  943. package/dist/domain/mcp/tools/slack.d.ts +0 -23
  944. package/dist/domain/mcp/tools/slack.js +0 -106
  945. package/dist/domain/mcp/tools/subagent.d.ts +0 -23
  946. package/dist/domain/mcp/tools/subagent.js +0 -179
  947. package/dist/domain/mcp/tools/time.d.ts +0 -2
  948. package/dist/domain/mcp/tools/time.js +0 -62
  949. package/dist/domain/mcp/tools/ui-board.d.ts +0 -12
  950. package/dist/domain/mcp/tools/ui-board.js +0 -48
  951. package/dist/domain/mcp/tools/ui-decision.d.ts +0 -3
  952. package/dist/domain/mcp/tools/ui-decision.js +0 -37
  953. package/dist/domain/mcp/tools/ui-file.d.ts +0 -3
  954. package/dist/domain/mcp/tools/ui-file.js +0 -70
  955. package/dist/domain/mcp/tools/ui-view.d.ts +0 -3
  956. package/dist/domain/mcp/tools/ui-view.js +0 -44
  957. package/dist/domain/mcp/tools/waitpoint.d.ts +0 -28
  958. package/dist/domain/mcp/tools/waitpoint.js +0 -109
  959. package/dist/domain/mcp/tools/workers.d.ts +0 -5
  960. package/dist/domain/mcp/tools/workers.js +0 -77
  961. package/dist/domain/memory/agents-md-injector.d.ts +0 -25
  962. package/dist/domain/memory/agents-md-injector.js +0 -58
  963. package/dist/domain/memory/consolidate.d.ts +0 -56
  964. package/dist/domain/memory/consolidate.js +0 -419
  965. package/dist/domain/memory/index-regen.d.ts +0 -30
  966. package/dist/domain/memory/index-regen.js +0 -334
  967. package/dist/domain/memory/rules-loader.d.ts +0 -6
  968. package/dist/domain/memory/rules-loader.js +0 -13
  969. package/dist/domain/memory/user-context.d.ts +0 -5
  970. package/dist/domain/memory/user-context.js +0 -32
  971. package/dist/domain/memory/watcher.d.ts +0 -8
  972. package/dist/domain/memory/watcher.js +0 -135
  973. package/dist/domain/monitor/disk-monitor.d.ts +0 -17
  974. package/dist/domain/monitor/disk-monitor.js +0 -117
  975. package/dist/domain/monitor/event-loop-monitor.d.ts +0 -35
  976. package/dist/domain/monitor/event-loop-monitor.js +0 -64
  977. package/dist/domain/monitor/gpu-monitor.d.ts +0 -26
  978. package/dist/domain/monitor/gpu-monitor.js +0 -132
  979. package/dist/domain/pi-providers/custom-provider-model.d.ts +0 -49
  980. package/dist/domain/pi-providers/custom-provider-model.js +0 -116
  981. package/dist/domain/pi-providers/custom-provider-service.d.ts +0 -57
  982. package/dist/domain/pi-providers/custom-provider-service.js +0 -153
  983. package/dist/domain/pi-providers/gateway-route-store.d.ts +0 -23
  984. package/dist/domain/pi-providers/gateway-route-store.js +0 -74
  985. package/dist/domain/pi-providers/index.d.ts +0 -3
  986. package/dist/domain/pi-providers/index.js +0 -3
  987. package/dist/domain/pi-providers/models-json-store.d.ts +0 -6
  988. package/dist/domain/pi-providers/models-json-store.js +0 -73
  989. package/dist/domain/plugins/agent-plugins-v1.d.ts +0 -58
  990. package/dist/domain/plugins/agent-plugins-v1.js +0 -84
  991. package/dist/domain/plugins/authoring.d.ts +0 -46
  992. package/dist/domain/plugins/authoring.js +0 -335
  993. package/dist/domain/plugins/builtin.d.ts +0 -25
  994. package/dist/domain/plugins/builtin.js +0 -44
  995. package/dist/domain/plugins/catalog-types.d.ts +0 -89
  996. package/dist/domain/plugins/catalog-types.js +0 -39
  997. package/dist/domain/plugins/catalog.d.ts +0 -39
  998. package/dist/domain/plugins/catalog.js +0 -482
  999. package/dist/domain/plugins/conversation-skills.d.ts +0 -10
  1000. package/dist/domain/plugins/conversation-skills.js +0 -22
  1001. package/dist/domain/plugins/fs-helpers.d.ts +0 -9
  1002. package/dist/domain/plugins/fs-helpers.js +0 -107
  1003. package/dist/domain/plugins/mcp.d.ts +0 -6
  1004. package/dist/domain/plugins/mcp.js +0 -223
  1005. package/dist/domain/plugins/runtime-gc.d.ts +0 -17
  1006. package/dist/domain/plugins/runtime-gc.js +0 -101
  1007. package/dist/domain/plugins/runtime.d.ts +0 -21
  1008. package/dist/domain/plugins/runtime.js +0 -555
  1009. package/dist/domain/plugins/skill-projection.d.ts +0 -19
  1010. package/dist/domain/plugins/skill-projection.js +0 -193
  1011. package/dist/domain/plugins/skill.d.ts +0 -14
  1012. package/dist/domain/plugins/skill.js +0 -145
  1013. package/dist/domain/projects/index.d.ts +0 -3
  1014. package/dist/domain/projects/index.js +0 -3
  1015. package/dist/domain/projects/project-store.d.ts +0 -72
  1016. package/dist/domain/projects/project-store.js +0 -240
  1017. package/dist/domain/projects/project-types.d.ts +0 -11
  1018. package/dist/domain/projects/project-types.js +0 -1
  1019. package/dist/domain/remote/client-bootstrap.d.ts +0 -1
  1020. package/dist/domain/remote/client-bootstrap.js +0 -126
  1021. package/dist/domain/remote/client-hot-reload.d.ts +0 -40
  1022. package/dist/domain/remote/client-hot-reload.js +0 -269
  1023. package/dist/domain/remote/client-lifecycle.d.ts +0 -32
  1024. package/dist/domain/remote/client-lifecycle.js +0 -382
  1025. package/dist/domain/remote/client-manager.d.ts +0 -54
  1026. package/dist/domain/remote/client-manager.js +0 -325
  1027. package/dist/domain/remote/client-pids.d.ts +0 -13
  1028. package/dist/domain/remote/client-pids.js +0 -43
  1029. package/dist/domain/remote/client-protocol.d.ts +0 -1
  1030. package/dist/domain/remote/client-protocol.js +0 -1
  1031. package/dist/domain/remote/client-remove.d.ts +0 -61
  1032. package/dist/domain/remote/client-remove.js +0 -129
  1033. package/dist/domain/remote/client-ssh-tunnel.d.ts +0 -79
  1034. package/dist/domain/remote/client-ssh-tunnel.js +0 -352
  1035. package/dist/domain/remote/device-browser.d.ts +0 -38
  1036. package/dist/domain/remote/device-browser.js +0 -158
  1037. package/dist/domain/remote/device-chrome-commands.d.ts +0 -18
  1038. package/dist/domain/remote/device-chrome-commands.js +0 -125
  1039. package/dist/domain/remote/device-file.d.ts +0 -51
  1040. package/dist/domain/remote/device-file.js +0 -193
  1041. package/dist/domain/remote/device-port.d.ts +0 -23
  1042. package/dist/domain/remote/device-port.js +0 -192
  1043. package/dist/domain/remote/local-client-install.d.ts +0 -32
  1044. package/dist/domain/remote/local-client-install.js +0 -168
  1045. package/dist/domain/remote/local-client-stop.d.ts +0 -37
  1046. package/dist/domain/remote/local-client-stop.js +0 -101
  1047. package/dist/domain/remote/machine-registry.d.ts +0 -54
  1048. package/dist/domain/remote/machine-registry.js +0 -184
  1049. package/dist/domain/remote/owned-local-launch.d.ts +0 -22
  1050. package/dist/domain/remote/owned-local-launch.js +0 -75
  1051. package/dist/domain/remote/package-client-bundle.d.ts +0 -14
  1052. package/dist/domain/remote/package-client-bundle.js +0 -37
  1053. package/dist/domain/remote/reverse-stream.d.ts +0 -42
  1054. package/dist/domain/remote/reverse-stream.js +0 -95
  1055. package/dist/domain/remote/ssh-exec.d.ts +0 -10
  1056. package/dist/domain/remote/ssh-exec.js +0 -25
  1057. package/dist/domain/runs/adapters.d.ts +0 -15
  1058. package/dist/domain/runs/adapters.js +0 -59
  1059. package/dist/domain/runs/attempt.d.ts +0 -37
  1060. package/dist/domain/runs/attempt.js +0 -232
  1061. package/dist/domain/runs/builders.d.ts +0 -27
  1062. package/dist/domain/runs/builders.js +0 -47
  1063. package/dist/domain/runs/compact.d.ts +0 -30
  1064. package/dist/domain/runs/compact.js +0 -43
  1065. package/dist/domain/runs/config-resolver.d.ts +0 -26
  1066. package/dist/domain/runs/config-resolver.js +0 -38
  1067. package/dist/domain/runs/engine-spec.d.ts +0 -40
  1068. package/dist/domain/runs/engine-spec.js +0 -215
  1069. package/dist/domain/runs/engines.d.ts +0 -71
  1070. package/dist/domain/runs/engines.js +0 -181
  1071. package/dist/domain/runs/events.d.ts +0 -2
  1072. package/dist/domain/runs/events.js +0 -1
  1073. package/dist/domain/runs/fallback.d.ts +0 -11
  1074. package/dist/domain/runs/fallback.js +0 -18
  1075. package/dist/domain/runs/mode-env.d.ts +0 -16
  1076. package/dist/domain/runs/mode-env.js +0 -48
  1077. package/dist/domain/runs/notices.d.ts +0 -44
  1078. package/dist/domain/runs/notices.js +0 -109
  1079. package/dist/domain/runs/observers/resume-recorder.d.ts +0 -26
  1080. package/dist/domain/runs/observers/resume-recorder.js +0 -27
  1081. package/dist/domain/runs/prompt.d.ts +0 -78
  1082. package/dist/domain/runs/prompt.js +0 -98
  1083. package/dist/domain/runs/request.d.ts +0 -99
  1084. package/dist/domain/runs/request.js +0 -1
  1085. package/dist/domain/runs/retryable-errors.d.ts +0 -5
  1086. package/dist/domain/runs/retryable-errors.js +0 -24
  1087. package/dist/domain/runs/run.d.ts +0 -238
  1088. package/dist/domain/runs/run.js +0 -574
  1089. package/dist/domain/runs/service.d.ts +0 -3
  1090. package/dist/domain/runs/service.js +0 -63
  1091. package/dist/domain/runs/spec-loader.d.ts +0 -75
  1092. package/dist/domain/runs/spec-loader.js +0 -58
  1093. package/dist/domain/runs/spend.d.ts +0 -16
  1094. package/dist/domain/runs/spend.js +0 -31
  1095. package/dist/domain/scheduling/builtin-job-controller.d.ts +0 -21
  1096. package/dist/domain/scheduling/builtin-job-controller.js +0 -106
  1097. package/dist/domain/scheduling/builtin-job-migration.d.ts +0 -23
  1098. package/dist/domain/scheduling/builtin-job-migration.js +0 -64
  1099. package/dist/domain/scheduling/builtin-jobs.d.ts +0 -2
  1100. package/dist/domain/scheduling/builtin-jobs.js +0 -44
  1101. package/dist/domain/scheduling/job-registry.d.ts +0 -22
  1102. package/dist/domain/scheduling/job-registry.js +0 -16
  1103. package/dist/domain/scheduling/jobs/auth-expiry-scan.d.ts +0 -15
  1104. package/dist/domain/scheduling/jobs/auth-expiry-scan.js +0 -75
  1105. package/dist/domain/scheduling/jobs/scheduled-task.d.ts +0 -24
  1106. package/dist/domain/scheduling/jobs/scheduled-task.js +0 -112
  1107. package/dist/domain/scheduling/jobs/sync-public.d.ts +0 -4
  1108. package/dist/domain/scheduling/jobs/sync-public.js +0 -40
  1109. package/dist/domain/scheduling/run-guards.d.ts +0 -6
  1110. package/dist/domain/scheduling/run-guards.js +0 -18
  1111. package/dist/domain/scheduling/runner.d.ts +0 -17
  1112. package/dist/domain/scheduling/runner.js +0 -22
  1113. package/dist/domain/scheduling/schedule-ops.d.ts +0 -15
  1114. package/dist/domain/scheduling/schedule-ops.js +0 -43
  1115. package/dist/domain/scheduling/schedule-selection.d.ts +0 -3
  1116. package/dist/domain/scheduling/schedule-selection.js +0 -16
  1117. package/dist/domain/scheduling/schedule-spec.d.ts +0 -79
  1118. package/dist/domain/scheduling/schedule-spec.js +0 -169
  1119. package/dist/domain/scheduling/scheduler.d.ts +0 -75
  1120. package/dist/domain/scheduling/scheduler.js +0 -312
  1121. package/dist/domain/sessions/session-backup.d.ts +0 -44
  1122. package/dist/domain/sessions/session-backup.js +0 -138
  1123. package/dist/domain/sessions/session-hooks.d.ts +0 -130
  1124. package/dist/domain/sessions/session-hooks.js +0 -347
  1125. package/dist/domain/sessions/session-lifecycle.d.ts +0 -91
  1126. package/dist/domain/sessions/session-lifecycle.js +0 -82
  1127. package/dist/domain/sessions/session-retention.d.ts +0 -50
  1128. package/dist/domain/sessions/session-retention.js +0 -466
  1129. package/dist/domain/sessions/session-use.d.ts +0 -28
  1130. package/dist/domain/sessions/session-use.js +0 -45
  1131. package/dist/domain/sessions/session.d.ts +0 -3
  1132. package/dist/domain/sessions/session.js +0 -13
  1133. package/dist/domain/sessions/team.d.ts +0 -26
  1134. package/dist/domain/sessions/team.js +0 -30
  1135. package/dist/domain/system/doctor.d.ts +0 -82
  1136. package/dist/domain/system/doctor.js +0 -484
  1137. package/dist/domain/system/github-release.d.ts +0 -16
  1138. package/dist/domain/system/github-release.js +0 -101
  1139. package/dist/domain/system/install-cli.d.ts +0 -7
  1140. package/dist/domain/system/install-cli.js +0 -107
  1141. package/dist/domain/system/notice-history.d.ts +0 -18
  1142. package/dist/domain/system/notice-history.js +0 -23
  1143. package/dist/domain/system/own-bin-path.d.ts +0 -13
  1144. package/dist/domain/system/own-bin-path.js +0 -36
  1145. package/dist/domain/system/preferences.d.ts +0 -30
  1146. package/dist/domain/system/preferences.js +0 -59
  1147. package/dist/domain/system/rebuild-hold.d.ts +0 -36
  1148. package/dist/domain/system/rebuild-hold.js +0 -83
  1149. package/dist/domain/system/server-update-check.d.ts +0 -24
  1150. package/dist/domain/system/server-update-check.js +0 -89
  1151. package/dist/domain/system/server-update-coordinator.d.ts +0 -46
  1152. package/dist/domain/system/server-update-coordinator.js +0 -155
  1153. package/dist/domain/system/server-update-install.d.ts +0 -16
  1154. package/dist/domain/system/server-update-install.js +0 -65
  1155. package/dist/domain/system/system-notice.d.ts +0 -24
  1156. package/dist/domain/system/system-notice.js +0 -31
  1157. package/dist/domain/system/terminal-cli/index.d.ts +0 -58
  1158. package/dist/domain/system/terminal-cli/index.js +0 -100
  1159. package/dist/domain/system/terminal-cli/posix-profiles.d.ts +0 -23
  1160. package/dist/domain/system/terminal-cli/posix-profiles.js +0 -74
  1161. package/dist/domain/system/terminal-cli/registrar.d.ts +0 -12
  1162. package/dist/domain/system/terminal-cli/registrar.js +0 -1
  1163. package/dist/domain/system/terminal-cli/shims.d.ts +0 -27
  1164. package/dist/domain/system/terminal-cli/shims.js +0 -108
  1165. package/dist/domain/system/terminal-cli/state.d.ts +0 -7
  1166. package/dist/domain/system/terminal-cli/state.js +0 -36
  1167. package/dist/domain/system/terminal-cli/windows-user-path.d.ts +0 -13
  1168. package/dist/domain/system/terminal-cli/windows-user-path.js +0 -67
  1169. package/dist/domain/system/update-prompt.d.ts +0 -8
  1170. package/dist/domain/system/update-prompt.js +0 -1
  1171. package/dist/domain/system/update-state.d.ts +0 -9
  1172. package/dist/domain/system/update-state.js +0 -22
  1173. package/dist/domain/system/update-ui-state.d.ts +0 -39
  1174. package/dist/domain/system/update-ui-state.js +0 -70
  1175. package/dist/domain/telemetry/bus-collector.d.ts +0 -3
  1176. package/dist/domain/telemetry/bus-collector.js +0 -22
  1177. package/dist/domain/telemetry/child-exit.d.ts +0 -11
  1178. package/dist/domain/telemetry/child-exit.js +0 -36
  1179. package/dist/domain/telemetry/client-kind.d.ts +0 -4
  1180. package/dist/domain/telemetry/client-kind.js +0 -7
  1181. package/dist/domain/telemetry/crash-limits.d.ts +0 -15
  1182. package/dist/domain/telemetry/crash-limits.js +0 -50
  1183. package/dist/domain/telemetry/crash.d.ts +0 -25
  1184. package/dist/domain/telemetry/crash.js +0 -70
  1185. package/dist/domain/telemetry/daily-upload.d.ts +0 -5
  1186. package/dist/domain/telemetry/daily-upload.js +0 -20
  1187. package/dist/domain/telemetry/daily.d.ts +0 -5
  1188. package/dist/domain/telemetry/daily.js +0 -104
  1189. package/dist/domain/telemetry/endpoint.d.ts +0 -7
  1190. package/dist/domain/telemetry/endpoint.js +0 -40
  1191. package/dist/domain/telemetry/envelope.d.ts +0 -6
  1192. package/dist/domain/telemetry/envelope.js +0 -35
  1193. package/dist/domain/telemetry/error-digest.d.ts +0 -7
  1194. package/dist/domain/telemetry/error-digest.js +0 -43
  1195. package/dist/domain/telemetry/funnel.d.ts +0 -6
  1196. package/dist/domain/telemetry/funnel.js +0 -22
  1197. package/dist/domain/telemetry/gate.d.ts +0 -19
  1198. package/dist/domain/telemetry/gate.js +0 -67
  1199. package/dist/domain/telemetry/heartbeat.d.ts +0 -17
  1200. package/dist/domain/telemetry/heartbeat.js +0 -49
  1201. package/dist/domain/telemetry/info.d.ts +0 -9
  1202. package/dist/domain/telemetry/info.js +0 -12
  1203. package/dist/domain/telemetry/init-answer.d.ts +0 -12
  1204. package/dist/domain/telemetry/init-answer.js +0 -42
  1205. package/dist/domain/telemetry/install-id.d.ts +0 -5
  1206. package/dist/domain/telemetry/install-id.js +0 -42
  1207. package/dist/domain/telemetry/normalize.d.ts +0 -33
  1208. package/dist/domain/telemetry/normalize.js +0 -88
  1209. package/dist/domain/telemetry/outbox.d.ts +0 -18
  1210. package/dist/domain/telemetry/outbox.js +0 -93
  1211. package/dist/domain/telemetry/panic-group.d.ts +0 -4
  1212. package/dist/domain/telemetry/panic-group.js +0 -51
  1213. package/dist/domain/telemetry/paths.d.ts +0 -7
  1214. package/dist/domain/telemetry/paths.js +0 -11
  1215. package/dist/domain/telemetry/redact.d.ts +0 -18
  1216. package/dist/domain/telemetry/redact.js +0 -109
  1217. package/dist/domain/telemetry/rollup-types.d.ts +0 -81
  1218. package/dist/domain/telemetry/rollup-types.js +0 -31
  1219. package/dist/domain/telemetry/rollup.d.ts +0 -16
  1220. package/dist/domain/telemetry/rollup.js +0 -102
  1221. package/dist/domain/telemetry/schema.d.ts +0 -931
  1222. package/dist/domain/telemetry/schema.js +0 -275
  1223. package/dist/domain/telemetry/service.d.ts +0 -34
  1224. package/dist/domain/telemetry/service.js +0 -146
  1225. package/dist/domain/telemetry/state.d.ts +0 -17
  1226. package/dist/domain/telemetry/state.js +0 -29
  1227. package/dist/domain/telemetry/turns.d.ts +0 -17
  1228. package/dist/domain/telemetry/turns.js +0 -176
  1229. package/dist/domain/telemetry/upgrade.d.ts +0 -14
  1230. package/dist/domain/telemetry/upgrade.js +0 -87
  1231. package/dist/domain/telemetry/uploader.d.ts +0 -21
  1232. package/dist/domain/telemetry/uploader.js +0 -82
  1233. package/dist/domain/telemetry/usage.d.ts +0 -25
  1234. package/dist/domain/telemetry/usage.js +0 -153
  1235. package/dist/domain/telemetry/web-report.d.ts +0 -8
  1236. package/dist/domain/telemetry/web-report.js +0 -15
  1237. package/dist/domain/tui-session/index.d.ts +0 -2
  1238. package/dist/domain/tui-session/index.js +0 -1
  1239. package/dist/domain/tui-session/tui-session-service.d.ts +0 -2
  1240. package/dist/domain/tui-session/tui-session-service.js +0 -85
  1241. package/dist/domain/tui-session/types.d.ts +0 -40
  1242. package/dist/domain/tui-session/types.js +0 -1
  1243. package/dist/domain/ui-service/app-router.d.ts +0 -1180
  1244. package/dist/domain/ui-service/app-router.js +0 -312
  1245. package/dist/domain/ui-service/assistant-snapshots.d.ts +0 -10
  1246. package/dist/domain/ui-service/assistant-snapshots.js +0 -45
  1247. package/dist/domain/ui-service/contract.parity.d.ts +0 -19
  1248. package/dist/domain/ui-service/contract.parity.js +0 -1
  1249. package/dist/domain/ui-service/index.d.ts +0 -4
  1250. package/dist/domain/ui-service/index.js +0 -1
  1251. package/dist/domain/ui-service/inline-media-types.d.ts +0 -18
  1252. package/dist/domain/ui-service/inline-media-types.js +0 -1
  1253. package/dist/domain/ui-service/input-schemas.d.ts +0 -1132
  1254. package/dist/domain/ui-service/input-schemas.js +0 -710
  1255. package/dist/domain/ui-service/mutate/approvals.d.ts +0 -33
  1256. package/dist/domain/ui-service/mutate/approvals.js +0 -134
  1257. package/dist/domain/ui-service/mutate/auth.d.ts +0 -15
  1258. package/dist/domain/ui-service/mutate/auth.js +0 -103
  1259. package/dist/domain/ui-service/mutate/config.d.ts +0 -18
  1260. package/dist/domain/ui-service/mutate/config.js +0 -108
  1261. package/dist/domain/ui-service/mutate/custom-providers.d.ts +0 -8
  1262. package/dist/domain/ui-service/mutate/custom-providers.js +0 -33
  1263. package/dist/domain/ui-service/mutate/environments.d.ts +0 -27
  1264. package/dist/domain/ui-service/mutate/environments.js +0 -66
  1265. package/dist/domain/ui-service/mutate/errors.d.ts +0 -7
  1266. package/dist/domain/ui-service/mutate/errors.js +0 -14
  1267. package/dist/domain/ui-service/mutate/executions.d.ts +0 -4
  1268. package/dist/domain/ui-service/mutate/executions.js +0 -15
  1269. package/dist/domain/ui-service/mutate/hooks.d.ts +0 -12
  1270. package/dist/domain/ui-service/mutate/hooks.js +0 -110
  1271. package/dist/domain/ui-service/mutate/issues.d.ts +0 -18
  1272. package/dist/domain/ui-service/mutate/issues.js +0 -100
  1273. package/dist/domain/ui-service/mutate/models.d.ts +0 -13
  1274. package/dist/domain/ui-service/mutate/models.js +0 -137
  1275. package/dist/domain/ui-service/mutate/notes.d.ts +0 -6
  1276. package/dist/domain/ui-service/mutate/notes.js +0 -32
  1277. package/dist/domain/ui-service/mutate/platform-settings.d.ts +0 -6
  1278. package/dist/domain/ui-service/mutate/platform-settings.js +0 -17
  1279. package/dist/domain/ui-service/mutate/plugin-packages.d.ts +0 -10
  1280. package/dist/domain/ui-service/mutate/plugin-packages.js +0 -152
  1281. package/dist/domain/ui-service/mutate/plugins.d.ts +0 -2
  1282. package/dist/domain/ui-service/mutate/plugins.js +0 -38
  1283. package/dist/domain/ui-service/mutate/projects.d.ts +0 -4
  1284. package/dist/domain/ui-service/mutate/projects.js +0 -7
  1285. package/dist/domain/ui-service/mutate/resolve-media.d.ts +0 -4
  1286. package/dist/domain/ui-service/mutate/resolve-media.js +0 -17
  1287. package/dist/domain/ui-service/mutate/schedules.d.ts +0 -12
  1288. package/dist/domain/ui-service/mutate/schedules.js +0 -75
  1289. package/dist/domain/ui-service/mutate/session-metadata.d.ts +0 -3
  1290. package/dist/domain/ui-service/mutate/session-metadata.js +0 -22
  1291. package/dist/domain/ui-service/mutate/sessions.d.ts +0 -19
  1292. package/dist/domain/ui-service/mutate/sessions.js +0 -307
  1293. package/dist/domain/ui-service/mutate/system.d.ts +0 -10
  1294. package/dist/domain/ui-service/mutate/system.js +0 -120
  1295. package/dist/domain/ui-service/mutate/telemetry.d.ts +0 -5
  1296. package/dist/domain/ui-service/mutate/telemetry.js +0 -6
  1297. package/dist/domain/ui-service/mutate/usage-sharing.d.ts +0 -8
  1298. package/dist/domain/ui-service/mutate/usage-sharing.js +0 -16
  1299. package/dist/domain/ui-service/mutate/waitpoints.d.ts +0 -2
  1300. package/dist/domain/ui-service/mutate/waitpoints.js +0 -13
  1301. package/dist/domain/ui-service/platform-settings.d.ts +0 -5
  1302. package/dist/domain/ui-service/platform-settings.js +0 -72
  1303. package/dist/domain/ui-service/plugins-shared.d.ts +0 -29
  1304. package/dist/domain/ui-service/plugins-shared.js +0 -176
  1305. package/dist/domain/ui-service/query/approvals.d.ts +0 -10
  1306. package/dist/domain/ui-service/query/approvals.js +0 -119
  1307. package/dist/domain/ui-service/query/auth.d.ts +0 -6
  1308. package/dist/domain/ui-service/query/auth.js +0 -8
  1309. package/dist/domain/ui-service/query/boards.d.ts +0 -14
  1310. package/dist/domain/ui-service/query/boards.js +0 -111
  1311. package/dist/domain/ui-service/query/config.d.ts +0 -9
  1312. package/dist/domain/ui-service/query/config.js +0 -167
  1313. package/dist/domain/ui-service/query/cost.d.ts +0 -3
  1314. package/dist/domain/ui-service/query/cost.js +0 -3
  1315. package/dist/domain/ui-service/query/custom-providers.d.ts +0 -8
  1316. package/dist/domain/ui-service/query/custom-providers.js +0 -9
  1317. package/dist/domain/ui-service/query/environments.d.ts +0 -12
  1318. package/dist/domain/ui-service/query/environments.js +0 -73
  1319. package/dist/domain/ui-service/query/executions.d.ts +0 -3
  1320. package/dist/domain/ui-service/query/executions.js +0 -61
  1321. package/dist/domain/ui-service/query/hooks.d.ts +0 -9
  1322. package/dist/domain/ui-service/query/hooks.js +0 -92
  1323. package/dist/domain/ui-service/query/issues.d.ts +0 -14
  1324. package/dist/domain/ui-service/query/issues.js +0 -78
  1325. package/dist/domain/ui-service/query/machine-detail.d.ts +0 -2
  1326. package/dist/domain/ui-service/query/machine-detail.js +0 -30
  1327. package/dist/domain/ui-service/query/machine-probe.d.ts +0 -18
  1328. package/dist/domain/ui-service/query/machine-probe.js +0 -133
  1329. package/dist/domain/ui-service/query/machines.d.ts +0 -2
  1330. package/dist/domain/ui-service/query/machines.js +0 -21
  1331. package/dist/domain/ui-service/query/memory.d.ts +0 -7
  1332. package/dist/domain/ui-service/query/memory.js +0 -191
  1333. package/dist/domain/ui-service/query/models.d.ts +0 -27
  1334. package/dist/domain/ui-service/query/models.js +0 -125
  1335. package/dist/domain/ui-service/query/notes.d.ts +0 -3
  1336. package/dist/domain/ui-service/query/notes.js +0 -15
  1337. package/dist/domain/ui-service/query/plugin-source.d.ts +0 -4
  1338. package/dist/domain/ui-service/query/plugin-source.js +0 -58
  1339. package/dist/domain/ui-service/query/plugins.d.ts +0 -2
  1340. package/dist/domain/ui-service/query/plugins.js +0 -28
  1341. package/dist/domain/ui-service/query/projects.d.ts +0 -2
  1342. package/dist/domain/ui-service/query/projects.js +0 -27
  1343. package/dist/domain/ui-service/query/schedules.d.ts +0 -5
  1344. package/dist/domain/ui-service/query/schedules.js +0 -28
  1345. package/dist/domain/ui-service/query/sessions.d.ts +0 -6
  1346. package/dist/domain/ui-service/query/sessions.js +0 -430
  1347. package/dist/domain/ui-service/query/skills.d.ts +0 -5
  1348. package/dist/domain/ui-service/query/skills.js +0 -16
  1349. package/dist/domain/ui-service/query/system.d.ts +0 -6
  1350. package/dist/domain/ui-service/query/system.js +0 -120
  1351. package/dist/domain/ui-service/query/telemetry.d.ts +0 -3
  1352. package/dist/domain/ui-service/query/telemetry.js +0 -4
  1353. package/dist/domain/ui-service/query/usage-sharing.d.ts +0 -4
  1354. package/dist/domain/ui-service/query/usage-sharing.js +0 -5
  1355. package/dist/domain/ui-service/query/waitpoints.d.ts +0 -10
  1356. package/dist/domain/ui-service/query/waitpoints.js +0 -37
  1357. package/dist/domain/ui-service/query-input-schemas.d.ts +0 -73
  1358. package/dist/domain/ui-service/query-input-schemas.js +0 -70
  1359. package/dist/domain/ui-service/session-metadata-schemas.d.ts +0 -13
  1360. package/dist/domain/ui-service/session-metadata-schemas.js +0 -9
  1361. package/dist/domain/ui-service/subscribe.d.ts +0 -6
  1362. package/dist/domain/ui-service/subscribe.js +0 -125
  1363. package/dist/domain/ui-service/trpc.d.ts +0 -52
  1364. package/dist/domain/ui-service/trpc.js +0 -43
  1365. package/dist/domain/ui-service/types.d.ts +0 -1808
  1366. package/dist/domain/ui-service/types.js +0 -1
  1367. package/dist/domain/ui-service/ui-service.d.ts +0 -541
  1368. package/dist/domain/ui-service/ui-service.js +0 -235
  1369. package/dist/domain/waitpoints/notices.d.ts +0 -25
  1370. package/dist/domain/waitpoints/notices.js +0 -125
  1371. package/dist/domain/waitpoints/service.d.ts +0 -107
  1372. package/dist/domain/waitpoints/service.js +0 -276
  1373. package/dist/domain/waitpoints/view.d.ts +0 -29
  1374. package/dist/domain/waitpoints/view.js +0 -97
  1375. package/dist/entry/admin-channel-hot-reload.d.ts +0 -4
  1376. package/dist/entry/admin-channel-hot-reload.js +0 -17
  1377. package/dist/entry/app.d.ts +0 -1
  1378. package/dist/entry/auth-cli.d.ts +0 -9
  1379. package/dist/entry/auth-cli.js +0 -55
  1380. package/dist/entry/auth-login-cli.d.ts +0 -20
  1381. package/dist/entry/auth-login-cli.js +0 -153
  1382. package/dist/entry/auth-login-terminal.d.ts +0 -16
  1383. package/dist/entry/auth-login-terminal.js +0 -59
  1384. package/dist/entry/boot-jobs.d.ts +0 -7
  1385. package/dist/entry/boot-jobs.js +0 -16
  1386. package/dist/entry/browser-cli.d.ts +0 -39
  1387. package/dist/entry/cli-help.d.ts +0 -10
  1388. package/dist/entry/cli-help.js +0 -290
  1389. package/dist/entry/cli.d.ts +0 -19
  1390. package/dist/entry/client-cli.d.ts +0 -4
  1391. package/dist/entry/client-cli.js +0 -62
  1392. package/dist/entry/cortex-cli.d.ts +0 -1
  1393. package/dist/entry/daemon-notice.d.ts +0 -26
  1394. package/dist/entry/daemon-notice.js +0 -38
  1395. package/dist/entry/daemon.d.ts +0 -120
  1396. package/dist/entry/doctor-cli.d.ts +0 -8
  1397. package/dist/entry/doctor-cli.js +0 -70
  1398. package/dist/entry/draft-attachments.d.ts +0 -8
  1399. package/dist/entry/draft-attachments.js +0 -79
  1400. package/dist/entry/fast-install.d.ts +0 -49
  1401. package/dist/entry/fast-install.js +0 -192
  1402. package/dist/entry/feishu-login.d.ts +0 -21
  1403. package/dist/entry/feishu-login.js +0 -209
  1404. package/dist/entry/hook-cli.d.ts +0 -14
  1405. package/dist/entry/init-auth.d.ts +0 -4
  1406. package/dist/entry/init-auth.js +0 -42
  1407. package/dist/entry/init-git.d.ts +0 -6
  1408. package/dist/entry/init-git.js +0 -36
  1409. package/dist/entry/init-local-client.d.ts +0 -11
  1410. package/dist/entry/init-local-client.js +0 -34
  1411. package/dist/entry/init.d.ts +0 -151
  1412. package/dist/entry/init.js +0 -1292
  1413. package/dist/entry/local-ui.d.ts +0 -38
  1414. package/dist/entry/local-ui.js +0 -107
  1415. package/dist/entry/memory-cli.d.ts +0 -3
  1416. package/dist/entry/memory-cli.js +0 -79
  1417. package/dist/entry/path-cli.d.ts +0 -4
  1418. package/dist/entry/path-cli.js +0 -65
  1419. package/dist/entry/platform-connect.d.ts +0 -23
  1420. package/dist/entry/platform-connect.js +0 -94
  1421. package/dist/entry/production-app-bootstrap.d.ts +0 -1
  1422. package/dist/entry/production-evidence-export-cli.d.ts +0 -13
  1423. package/dist/entry/provider-cli.d.ts +0 -12
  1424. package/dist/entry/provider-cli.js +0 -199
  1425. package/dist/entry/schedule-cli.d.ts +0 -10
  1426. package/dist/entry/schedule-cli.js +0 -166
  1427. package/dist/entry/shutdown.d.ts +0 -32
  1428. package/dist/entry/shutdown.js +0 -84
  1429. package/dist/entry/signal-cli.d.ts +0 -25
  1430. package/dist/entry/start-ui-http.d.ts +0 -24
  1431. package/dist/entry/start-ui-http.js +0 -188
  1432. package/dist/entry/startup-helpers.d.ts +0 -2
  1433. package/dist/entry/startup-helpers.js +0 -15
  1434. package/dist/entry/startup-notify.d.ts +0 -6
  1435. package/dist/entry/startup-notify.js +0 -18
  1436. package/dist/entry/telemetry-wiring.d.ts +0 -12
  1437. package/dist/entry/telemetry-wiring.js +0 -56
  1438. package/dist/entry/ui-cli.d.ts +0 -2
  1439. package/dist/entry/ui-cli.js +0 -87
  1440. package/dist/entry/ui-http-gate.d.ts +0 -17
  1441. package/dist/entry/ui-http-gate.js +0 -17
  1442. package/dist/entry/ui-service-wiring.d.ts +0 -12
  1443. package/dist/entry/ui-service-wiring.js +0 -144
  1444. package/dist/events/event-bus.d.ts +0 -47
  1445. package/dist/events/event-bus.js +0 -83
  1446. package/dist/events/event-logger.d.ts +0 -12
  1447. package/dist/events/event-logger.js +0 -144
  1448. package/dist/events/event-types.d.ts +0 -259
  1449. package/dist/events/event-types.js +0 -1
  1450. package/dist/events/index.d.ts +0 -5
  1451. package/dist/events/index.js +0 -2
  1452. package/dist/orchestration/agent-decision-send.d.ts +0 -42
  1453. package/dist/orchestration/agent-decision-send.js +0 -62
  1454. package/dist/orchestration/agent-file-send.d.ts +0 -58
  1455. package/dist/orchestration/agent-file-send.js +0 -69
  1456. package/dist/orchestration/agent-runner.d.ts +0 -52
  1457. package/dist/orchestration/agent-runner.js +0 -230
  1458. package/dist/orchestration/agent-view-send.d.ts +0 -66
  1459. package/dist/orchestration/agent-view-send.js +0 -103
  1460. package/dist/orchestration/attachments-store.d.ts +0 -31
  1461. package/dist/orchestration/attachments-store.js +0 -156
  1462. package/dist/orchestration/benchmark-session-webhook.d.ts +0 -19
  1463. package/dist/orchestration/benchmark-session-webhook.js +0 -142
  1464. package/dist/orchestration/board-webhook.d.ts +0 -7
  1465. package/dist/orchestration/board-webhook.js +0 -38
  1466. package/dist/orchestration/browser-webhook.d.ts +0 -11
  1467. package/dist/orchestration/browser-webhook.js +0 -28
  1468. package/dist/orchestration/busy-tracker.d.ts +0 -15
  1469. package/dist/orchestration/busy-tracker.js +0 -38
  1470. package/dist/orchestration/cache-keep-warm.d.ts +0 -77
  1471. package/dist/orchestration/cache-keep-warm.js +0 -213
  1472. package/dist/orchestration/claude-window-warmup.d.ts +0 -40
  1473. package/dist/orchestration/claude-window-warmup.js +0 -126
  1474. package/dist/orchestration/conduit-queue.d.ts +0 -14
  1475. package/dist/orchestration/conduit-queue.js +0 -53
  1476. package/dist/orchestration/conversation-request.d.ts +0 -163
  1477. package/dist/orchestration/conversation-request.js +0 -276
  1478. package/dist/orchestration/delta-coalescer.d.ts +0 -69
  1479. package/dist/orchestration/delta-coalescer.js +0 -120
  1480. package/dist/orchestration/durable-helpers.d.ts +0 -3
  1481. package/dist/orchestration/durable-helpers.js +0 -38
  1482. package/dist/orchestration/edit-retry.d.ts +0 -35
  1483. package/dist/orchestration/edit-retry.js +0 -127
  1484. package/dist/orchestration/injection-ledger.d.ts +0 -56
  1485. package/dist/orchestration/injection-ledger.js +0 -270
  1486. package/dist/orchestration/inline-media-eager.d.ts +0 -13
  1487. package/dist/orchestration/inline-media-eager.js +0 -58
  1488. package/dist/orchestration/inline-media.d.ts +0 -22
  1489. package/dist/orchestration/inline-media.js +0 -151
  1490. package/dist/orchestration/interactions/answer-question.d.ts +0 -16
  1491. package/dist/orchestration/interactions/answer-question.js +0 -38
  1492. package/dist/orchestration/interactions/ask-user-question.d.ts +0 -34
  1493. package/dist/orchestration/interactions/ask-user-question.js +0 -179
  1494. package/dist/orchestration/interactions/ask-user-resume.d.ts +0 -11
  1495. package/dist/orchestration/interactions/ask-user-resume.js +0 -57
  1496. package/dist/orchestration/interactions/command-action-router.d.ts +0 -31
  1497. package/dist/orchestration/interactions/command-action-router.js +0 -48
  1498. package/dist/orchestration/interactions/interaction-handlers.d.ts +0 -5
  1499. package/dist/orchestration/interactions/interaction-handlers.js +0 -288
  1500. package/dist/orchestration/interactions/interaction-records.d.ts +0 -57
  1501. package/dist/orchestration/interactions/interaction-records.js +0 -142
  1502. package/dist/orchestration/interactions/plan-approvals.d.ts +0 -38
  1503. package/dist/orchestration/interactions/plan-approvals.js +0 -73
  1504. package/dist/orchestration/interactions/plan-handler.d.ts +0 -3
  1505. package/dist/orchestration/interactions/plan-handler.js +0 -13
  1506. package/dist/orchestration/interactions/plan-response.d.ts +0 -9
  1507. package/dist/orchestration/interactions/plan-response.js +0 -23
  1508. package/dist/orchestration/interactions/ui-update-prompt.d.ts +0 -8
  1509. package/dist/orchestration/interactions/ui-update-prompt.js +0 -39
  1510. package/dist/orchestration/interactions/update-prompt.d.ts +0 -6
  1511. package/dist/orchestration/interactions/update-prompt.js +0 -150
  1512. package/dist/orchestration/mid-turn-inject.d.ts +0 -64
  1513. package/dist/orchestration/mid-turn-inject.js +0 -103
  1514. package/dist/orchestration/orchestrator.d.ts +0 -23
  1515. package/dist/orchestration/orchestrator.js +0 -12
  1516. package/dist/orchestration/outputs-store.d.ts +0 -40
  1517. package/dist/orchestration/outputs-store.js +0 -83
  1518. package/dist/orchestration/pending-injection-recovery.d.ts +0 -36
  1519. package/dist/orchestration/pending-injection-recovery.js +0 -88
  1520. package/dist/orchestration/pi-background-subagent.d.ts +0 -15
  1521. package/dist/orchestration/pi-background-subagent.js +0 -34
  1522. package/dist/orchestration/resume-dispatcher.d.ts +0 -20
  1523. package/dist/orchestration/resume-dispatcher.js +0 -97
  1524. package/dist/orchestration/resume-target-sink.d.ts +0 -37
  1525. package/dist/orchestration/resume-target-sink.js +0 -68
  1526. package/dist/orchestration/routing/commands/cancel.d.ts +0 -58
  1527. package/dist/orchestration/routing/commands/cancel.js +0 -212
  1528. package/dist/orchestration/routing/commands/channel.d.ts +0 -7
  1529. package/dist/orchestration/routing/commands/channel.js +0 -229
  1530. package/dist/orchestration/routing/commands/command-context.d.ts +0 -14
  1531. package/dist/orchestration/routing/commands/command-context.js +0 -1
  1532. package/dist/orchestration/routing/commands/compact.d.ts +0 -6
  1533. package/dist/orchestration/routing/commands/compact.js +0 -22
  1534. package/dist/orchestration/routing/commands/cost.d.ts +0 -11
  1535. package/dist/orchestration/routing/commands/cost.js +0 -101
  1536. package/dist/orchestration/routing/commands/device.d.ts +0 -4
  1537. package/dist/orchestration/routing/commands/device.js +0 -70
  1538. package/dist/orchestration/routing/commands/index.d.ts +0 -22
  1539. package/dist/orchestration/routing/commands/index.js +0 -160
  1540. package/dist/orchestration/routing/commands/lang.d.ts +0 -9
  1541. package/dist/orchestration/routing/commands/lang.js +0 -34
  1542. package/dist/orchestration/routing/commands/login-custom.d.ts +0 -26
  1543. package/dist/orchestration/routing/commands/login-custom.js +0 -85
  1544. package/dist/orchestration/routing/commands/login-notice.d.ts +0 -23
  1545. package/dist/orchestration/routing/commands/login-notice.js +0 -84
  1546. package/dist/orchestration/routing/commands/login.d.ts +0 -12
  1547. package/dist/orchestration/routing/commands/login.js +0 -560
  1548. package/dist/orchestration/routing/commands/mode.d.ts +0 -10
  1549. package/dist/orchestration/routing/commands/mode.js +0 -302
  1550. package/dist/orchestration/routing/commands/nvtop.d.ts +0 -3
  1551. package/dist/orchestration/routing/commands/nvtop.js +0 -107
  1552. package/dist/orchestration/routing/commands/orient.d.ts +0 -2
  1553. package/dist/orchestration/routing/commands/orient.js +0 -5
  1554. package/dist/orchestration/routing/commands/restart.d.ts +0 -18
  1555. package/dist/orchestration/routing/commands/restart.js +0 -31
  1556. package/dist/orchestration/routing/commands/schedule.d.ts +0 -6
  1557. package/dist/orchestration/routing/commands/schedule.js +0 -206
  1558. package/dist/orchestration/routing/commands/sendfile.d.ts +0 -2
  1559. package/dist/orchestration/routing/commands/sendfile.js +0 -97
  1560. package/dist/orchestration/routing/commands/session.d.ts +0 -18
  1561. package/dist/orchestration/routing/commands/session.js +0 -131
  1562. package/dist/orchestration/routing/commands/status.d.ts +0 -5
  1563. package/dist/orchestration/routing/commands/status.js +0 -165
  1564. package/dist/orchestration/routing/commands/tail.d.ts +0 -2
  1565. package/dist/orchestration/routing/commands/tail.js +0 -79
  1566. package/dist/orchestration/routing/commands/time-ago.d.ts +0 -2
  1567. package/dist/orchestration/routing/commands/time-ago.js +0 -14
  1568. package/dist/orchestration/routing/commands/usage-format.d.ts +0 -5
  1569. package/dist/orchestration/routing/commands/usage-format.js +0 -107
  1570. package/dist/orchestration/routing/commands/usage-reset.d.ts +0 -20
  1571. package/dist/orchestration/routing/commands/usage-reset.js +0 -123
  1572. package/dist/orchestration/routing/commands/usage.d.ts +0 -10
  1573. package/dist/orchestration/routing/commands/usage.js +0 -54
  1574. package/dist/orchestration/routing/edit-handler.d.ts +0 -27
  1575. package/dist/orchestration/routing/edit-handler.js +0 -205
  1576. package/dist/orchestration/routing/file-handler.d.ts +0 -15
  1577. package/dist/orchestration/routing/file-handler.js +0 -39
  1578. package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +0 -14
  1579. package/dist/orchestration/routing/hook-bridge-subscribers.js +0 -174
  1580. package/dist/orchestration/routing/hook-bridge.d.ts +0 -28
  1581. package/dist/orchestration/routing/hook-bridge.js +0 -104
  1582. package/dist/orchestration/routing/message-router.d.ts +0 -6
  1583. package/dist/orchestration/routing/message-router.js +0 -62
  1584. package/dist/orchestration/routing/webhook.d.ts +0 -10
  1585. package/dist/orchestration/routing/webhook.js +0 -434
  1586. package/dist/orchestration/runtime.d.ts +0 -30
  1587. package/dist/orchestration/runtime.js +0 -37
  1588. package/dist/orchestration/session-compact.d.ts +0 -50
  1589. package/dist/orchestration/session-compact.js +0 -84
  1590. package/dist/orchestration/session-events.d.ts +0 -173
  1591. package/dist/orchestration/session-events.js +0 -140
  1592. package/dist/orchestration/session-gateway.d.ts +0 -52
  1593. package/dist/orchestration/session-gateway.js +0 -87
  1594. package/dist/orchestration/session-retention-controller.d.ts +0 -14
  1595. package/dist/orchestration/session-retention-controller.js +0 -88
  1596. package/dist/orchestration/session-retention-liveness.d.ts +0 -13
  1597. package/dist/orchestration/session-retention-liveness.js +0 -31
  1598. package/dist/orchestration/session-rewind.d.ts +0 -79
  1599. package/dist/orchestration/session-rewind.js +0 -147
  1600. package/dist/orchestration/status-helpers.d.ts +0 -40
  1601. package/dist/orchestration/status-helpers.js +0 -177
  1602. package/dist/orchestration/subagent-adopt.d.ts +0 -20
  1603. package/dist/orchestration/subagent-adopt.js +0 -43
  1604. package/dist/orchestration/subagent-attribution.d.ts +0 -42
  1605. package/dist/orchestration/subagent-attribution.js +0 -130
  1606. package/dist/orchestration/subagent-delivery.d.ts +0 -43
  1607. package/dist/orchestration/subagent-delivery.js +0 -112
  1608. package/dist/orchestration/subagent-rows.d.ts +0 -11
  1609. package/dist/orchestration/subagent-rows.js +0 -16
  1610. package/dist/orchestration/subagent-webhook.d.ts +0 -6
  1611. package/dist/orchestration/subagent-webhook.js +0 -89
  1612. package/dist/orchestration/team-delivery.d.ts +0 -81
  1613. package/dist/orchestration/team-delivery.js +0 -284
  1614. package/dist/orchestration/team-inbox.d.ts +0 -18
  1615. package/dist/orchestration/team-inbox.js +0 -49
  1616. package/dist/orchestration/team-state.d.ts +0 -74
  1617. package/dist/orchestration/team-state.js +0 -219
  1618. package/dist/orchestration/team-webhook.d.ts +0 -57
  1619. package/dist/orchestration/team-webhook.js +0 -293
  1620. package/dist/orchestration/transcript-sink.d.ts +0 -83
  1621. package/dist/orchestration/transcript-sink.js +0 -267
  1622. package/dist/orchestration/turn/active-turns.d.ts +0 -49
  1623. package/dist/orchestration/turn/active-turns.js +0 -76
  1624. package/dist/orchestration/turn/background-hold.d.ts +0 -158
  1625. package/dist/orchestration/turn/background-hold.js +0 -240
  1626. package/dist/orchestration/turn/hold-render-platform.d.ts +0 -35
  1627. package/dist/orchestration/turn/hold-render-platform.js +0 -105
  1628. package/dist/orchestration/turn/hold-render-web.d.ts +0 -17
  1629. package/dist/orchestration/turn/hold-render-web.js +0 -51
  1630. package/dist/orchestration/turn/terminal.d.ts +0 -105
  1631. package/dist/orchestration/turn/terminal.js +0 -194
  1632. package/dist/orchestration/turn/turn-prep.d.ts +0 -33
  1633. package/dist/orchestration/turn/turn-prep.js +0 -44
  1634. package/dist/orchestration/turn/turn-tracking.d.ts +0 -22
  1635. package/dist/orchestration/turn/turn-tracking.js +0 -89
  1636. package/dist/orchestration/turn/turn.d.ts +0 -199
  1637. package/dist/orchestration/turn/turn.js +0 -586
  1638. package/dist/orchestration/turn-mutation-lock.d.ts +0 -3
  1639. package/dist/orchestration/turn-mutation-lock.js +0 -32
  1640. package/dist/orchestration/turn-notify.d.ts +0 -22
  1641. package/dist/orchestration/turn-notify.js +0 -50
  1642. package/dist/orchestration/waitpoint-ingress.d.ts +0 -36
  1643. package/dist/orchestration/waitpoint-ingress.js +0 -183
  1644. package/dist/orchestration/waitpoint-notifier.d.ts +0 -32
  1645. package/dist/orchestration/waitpoint-notifier.js +0 -140
  1646. package/dist/orchestration/waitpoint-remote-drain.d.ts +0 -22
  1647. package/dist/orchestration/waitpoint-remote-drain.js +0 -134
  1648. package/dist/orchestration/waitpoint-sweep.d.ts +0 -43
  1649. package/dist/orchestration/waitpoint-sweep.js +0 -84
  1650. package/dist/platform/adapter.d.ts +0 -48
  1651. package/dist/platform/adapter.js +0 -1
  1652. package/dist/platform/adapters/chunked-output-stream.d.ts +0 -71
  1653. package/dist/platform/adapters/chunked-output-stream.js +0 -382
  1654. package/dist/platform/adapters/composite-adapter.d.ts +0 -99
  1655. package/dist/platform/adapters/composite-adapter.js +0 -369
  1656. package/dist/platform/adapters/feishu-http.d.ts +0 -46
  1657. package/dist/platform/adapters/feishu-http.js +0 -108
  1658. package/dist/platform/adapters/feishu-image.d.ts +0 -19
  1659. package/dist/platform/adapters/feishu-image.js +0 -64
  1660. package/dist/platform/adapters/feishu-output-stream.d.ts +0 -11
  1661. package/dist/platform/adapters/feishu-output-stream.js +0 -29
  1662. package/dist/platform/adapters/feishu.d.ts +0 -167
  1663. package/dist/platform/adapters/feishu.js +0 -1059
  1664. package/dist/platform/adapters/index.d.ts +0 -19
  1665. package/dist/platform/adapters/index.js +0 -108
  1666. package/dist/platform/adapters/project-conduits.d.ts +0 -9
  1667. package/dist/platform/adapters/project-conduits.js +0 -36
  1668. package/dist/platform/adapters/slack-output-stream.d.ts +0 -15
  1669. package/dist/platform/adapters/slack-output-stream.js +0 -33
  1670. package/dist/platform/adapters/slack.d.ts +0 -106
  1671. package/dist/platform/adapters/slack.js +0 -733
  1672. package/dist/platform/adapters/tui/index.d.ts +0 -2
  1673. package/dist/platform/adapters/tui/index.js +0 -2
  1674. package/dist/platform/adapters/tui/ports.d.ts +0 -46
  1675. package/dist/platform/adapters/tui/ports.js +0 -1
  1676. package/dist/platform/adapters/tui/tui-connection.d.ts +0 -20
  1677. package/dist/platform/adapters/tui/tui-connection.js +0 -44
  1678. package/dist/platform/adapters/tui/tui-gateway.d.ts +0 -90
  1679. package/dist/platform/adapters/tui/tui-gateway.js +0 -884
  1680. package/dist/platform/adapters/tui/tui-output-stream.d.ts +0 -35
  1681. package/dist/platform/adapters/tui/tui-output-stream.js +0 -94
  1682. package/dist/platform/adapters/tui/tui-transcript.d.ts +0 -8
  1683. package/dist/platform/adapters/tui/tui-transcript.js +0 -42
  1684. package/dist/platform/browser/agent-browser.d.ts +0 -50
  1685. package/dist/platform/browser/agent-browser.js +0 -165
  1686. package/dist/platform/browser/display.d.ts +0 -48
  1687. package/dist/platform/browser/display.js +0 -188
  1688. package/dist/platform/browser/managed-browser.d.ts +0 -23
  1689. package/dist/platform/browser/managed-browser.js +0 -357
  1690. package/dist/platform/index.d.ts +0 -10
  1691. package/dist/platform/index.js +0 -6
  1692. package/dist/platform/interactive-builder.d.ts +0 -34
  1693. package/dist/platform/interactive-builder.js +0 -138
  1694. package/dist/platform/output-stream-chunk.d.ts +0 -6
  1695. package/dist/platform/output-stream-chunk.js +0 -42
  1696. package/dist/platform/output-stream-helpers.d.ts +0 -8
  1697. package/dist/platform/output-stream-helpers.js +0 -19
  1698. package/dist/platform/output-stream.d.ts +0 -35
  1699. package/dist/platform/output-stream.js +0 -1
  1700. package/dist/platform/testing.d.ts +0 -136
  1701. package/dist/platform/testing.js +0 -286
  1702. package/dist/platform/tool-trace.d.ts +0 -35
  1703. package/dist/platform/tool-trace.js +0 -287
  1704. package/dist/platform/tui/protocol.d.ts +0 -352
  1705. package/dist/platform/tui/protocol.js +0 -146
  1706. package/dist/platform/types.d.ts +0 -223
  1707. package/dist/platform/types.js +0 -22
  1708. package/dist/platform/ui-http/access-jwt.d.ts +0 -28
  1709. package/dist/platform/ui-http/access-jwt.js +0 -53
  1710. package/dist/platform/ui-http/app-update.d.ts +0 -69
  1711. package/dist/platform/ui-http/app-update.js +0 -143
  1712. package/dist/platform/ui-http/browser-stream.d.ts +0 -110
  1713. package/dist/platform/ui-http/browser-stream.js +0 -447
  1714. package/dist/platform/ui-http/device-ports.d.ts +0 -34
  1715. package/dist/platform/ui-http/device-ports.js +0 -102
  1716. package/dist/platform/ui-http/file-routes.d.ts +0 -23
  1717. package/dist/platform/ui-http/file-routes.js +0 -224
  1718. package/dist/platform/ui-http/http-json.d.ts +0 -24
  1719. package/dist/platform/ui-http/http-json.js +0 -109
  1720. package/dist/platform/ui-http/listening-ports.d.ts +0 -98
  1721. package/dist/platform/ui-http/listening-ports.js +0 -239
  1722. package/dist/platform/ui-http/port-forward.d.ts +0 -40
  1723. package/dist/platform/ui-http/port-forward.js +0 -130
  1724. package/dist/platform/ui-http/ui-auth-routes.d.ts +0 -51
  1725. package/dist/platform/ui-http/ui-auth-routes.js +0 -120
  1726. package/dist/platform/ui-http/ui-device-routes.d.ts +0 -13
  1727. package/dist/platform/ui-http/ui-device-routes.js +0 -81
  1728. package/dist/platform/ui-http/ui-devices.d.ts +0 -24
  1729. package/dist/platform/ui-http/ui-devices.js +0 -107
  1730. package/dist/platform/ui-http/ui-http-server.d.ts +0 -100
  1731. package/dist/platform/ui-http/ui-http-server.js +0 -310
  1732. package/dist/platform/ui-http/ui-ota.d.ts +0 -22
  1733. package/dist/platform/ui-http/ui-ota.js +0 -151
  1734. package/dist/platform/ui-http/ui-pairing.d.ts +0 -25
  1735. package/dist/platform/ui-http/ui-pairing.js +0 -98
  1736. package/dist/platform/ui-http/ui-session.d.ts +0 -33
  1737. package/dist/platform/ui-http/ui-session.js +0 -124
  1738. package/dist/platform/ui-http/zip-writer.d.ts +0 -13
  1739. package/dist/platform/ui-http/zip-writer.js +0 -93
  1740. package/dist/platform/utils/rate-limiter.d.ts +0 -90
  1741. package/dist/platform/utils/rate-limiter.js +0 -203
  1742. package/dist/platform/utils/reaction-diagnostics.d.ts +0 -9
  1743. package/dist/platform/utils/reaction-diagnostics.js +0 -19
  1744. package/dist/platform/utils/readable-file.d.ts +0 -9
  1745. package/dist/platform/utils/readable-file.js +0 -18
  1746. package/dist/store/board-migration.d.ts +0 -21
  1747. package/dist/store/board-migration.js +0 -217
  1748. package/dist/store/board-repo.d.ts +0 -35
  1749. package/dist/store/board-repo.js +0 -62
  1750. package/dist/store/builtin-overlay-migration.d.ts +0 -11
  1751. package/dist/store/builtin-overlay-migration.js +0 -308
  1752. package/dist/store/claude-transcript-migration.d.ts +0 -32
  1753. package/dist/store/claude-transcript-migration.js +0 -119
  1754. package/dist/store/conversation-display-projection.d.ts +0 -36
  1755. package/dist/store/conversation-display-projection.js +0 -180
  1756. package/dist/store/conversation-history-reader.d.ts +0 -30
  1757. package/dist/store/conversation-history-reader.js +0 -440
  1758. package/dist/store/conversation-history-repo.d.ts +0 -449
  1759. package/dist/store/conversation-history-repo.js +0 -632
  1760. package/dist/store/conversation-ledger-repo.d.ts +0 -76
  1761. package/dist/store/conversation-ledger-repo.js +0 -219
  1762. package/dist/store/cost-repo.d.ts +0 -88
  1763. package/dist/store/cost-repo.js +0 -233
  1764. package/dist/store/execution-repo.d.ts +0 -169
  1765. package/dist/store/execution-repo.js +0 -329
  1766. package/dist/store/gitignore-migration.d.ts +0 -2
  1767. package/dist/store/gitignore-migration.js +0 -16
  1768. package/dist/store/hook-registry.d.ts +0 -101
  1769. package/dist/store/hook-registry.js +0 -319
  1770. package/dist/store/hook-writer.d.ts +0 -43
  1771. package/dist/store/hook-writer.js +0 -133
  1772. package/dist/store/models-repo.d.ts +0 -18
  1773. package/dist/store/models-repo.js +0 -74
  1774. package/dist/store/outbound-queue.d.ts +0 -67
  1775. package/dist/store/outbound-queue.js +0 -284
  1776. package/dist/store/pending-injection-repo.d.ts +0 -29
  1777. package/dist/store/pending-injection-repo.js +0 -52
  1778. package/dist/store/project-dir-repo.d.ts +0 -17
  1779. package/dist/store/project-dir-repo.js +0 -44
  1780. package/dist/store/project-notes-repo.d.ts +0 -27
  1781. package/dist/store/project-notes-repo.js +0 -219
  1782. package/dist/store/prompt-migration-replacements.d.ts +0 -3
  1783. package/dist/store/prompt-migration-replacements.js +0 -96
  1784. package/dist/store/provider-state-repo.d.ts +0 -22
  1785. package/dist/store/provider-state-repo.js +0 -115
  1786. package/dist/store/retention-candidate-repo.d.ts +0 -12
  1787. package/dist/store/retention-candidate-repo.js +0 -47
  1788. package/dist/store/retire-profiles-migration.d.ts +0 -28
  1789. package/dist/store/retire-profiles-migration.js +0 -335
  1790. package/dist/store/schedule-repo.d.ts +0 -53
  1791. package/dist/store/schedule-repo.js +0 -121
  1792. package/dist/store/session-registry-import.d.ts +0 -34
  1793. package/dist/store/session-registry-import.js +0 -173
  1794. package/dist/store/session-registry-journal.d.ts +0 -195
  1795. package/dist/store/session-registry-journal.js +0 -871
  1796. package/dist/store/session-registry-repo.d.ts +0 -169
  1797. package/dist/store/session-registry-repo.js +0 -530
  1798. package/dist/store/session-totals-repo.d.ts +0 -45
  1799. package/dist/store/session-totals-repo.js +0 -104
  1800. package/dist/store/session-totals.d.ts +0 -69
  1801. package/dist/store/session-totals.js +0 -93
  1802. package/dist/store/team-inbox-repo.d.ts +0 -34
  1803. package/dist/store/team-inbox-repo.js +0 -72
  1804. package/dist/store/team-outbox-repo.d.ts +0 -20
  1805. package/dist/store/team-outbox-repo.js +0 -39
  1806. package/dist/store/tool-image-files.d.ts +0 -12
  1807. package/dist/store/tool-image-files.js +0 -40
  1808. package/dist/store/version-migrations.d.ts +0 -120
  1809. package/dist/store/version-migrations.js +0 -1408
  1810. package/dist/store/waitpoint-repo.d.ts +0 -111
  1811. package/dist/store/waitpoint-repo.js +0 -83
  1812. package/dist/tui/App.d.ts +0 -27
  1813. package/dist/tui/App.js +0 -406
  1814. package/dist/tui/components/AskUserModal.d.ts +0 -10
  1815. package/dist/tui/components/AskUserModal.js +0 -362
  1816. package/dist/tui/components/ConfirmModal.d.ts +0 -12
  1817. package/dist/tui/components/ConfirmModal.js +0 -29
  1818. package/dist/tui/components/Dashboard.d.ts +0 -24
  1819. package/dist/tui/components/Dashboard.js +0 -89
  1820. package/dist/tui/components/DashboardCostTab.d.ts +0 -7
  1821. package/dist/tui/components/DashboardCostTab.js +0 -32
  1822. package/dist/tui/components/DashboardExecutionsTab.d.ts +0 -11
  1823. package/dist/tui/components/DashboardExecutionsTab.js +0 -112
  1824. package/dist/tui/components/DashboardSchedulesTab.d.ts +0 -11
  1825. package/dist/tui/components/DashboardSchedulesTab.js +0 -132
  1826. package/dist/tui/components/InputBox.d.ts +0 -26
  1827. package/dist/tui/components/InputBox.js +0 -266
  1828. package/dist/tui/components/Notifications.d.ts +0 -12
  1829. package/dist/tui/components/Notifications.js +0 -59
  1830. package/dist/tui/components/ProjectSwitcher.d.ts +0 -17
  1831. package/dist/tui/components/ProjectSwitcher.js +0 -40
  1832. package/dist/tui/components/SessionPicker.d.ts +0 -13
  1833. package/dist/tui/components/SessionPicker.js +0 -42
  1834. package/dist/tui/components/SidePanel.d.ts +0 -19
  1835. package/dist/tui/components/SidePanel.js +0 -8
  1836. package/dist/tui/components/SlashMenu.d.ts +0 -8
  1837. package/dist/tui/components/SlashMenu.js +0 -15
  1838. package/dist/tui/components/StatusLine.d.ts +0 -19
  1839. package/dist/tui/components/StatusLine.js +0 -39
  1840. package/dist/tui/components/Transcript.d.ts +0 -21
  1841. package/dist/tui/components/Transcript.js +0 -150
  1842. package/dist/tui/components/dashboard-constants.d.ts +0 -1
  1843. package/dist/tui/components/dashboard-constants.js +0 -1
  1844. package/dist/tui/hooks/useDashboardData.d.ts +0 -24
  1845. package/dist/tui/hooks/useDashboardData.js +0 -75
  1846. package/dist/tui/hooks/useKeybindings.d.ts +0 -19
  1847. package/dist/tui/hooks/useKeybindings.js +0 -75
  1848. package/dist/tui/hooks/useMouseHandler.d.ts +0 -15
  1849. package/dist/tui/hooks/useMouseHandler.js +0 -90
  1850. package/dist/tui/hooks/useMutate.d.ts +0 -22
  1851. package/dist/tui/hooks/useMutate.js +0 -54
  1852. package/dist/tui/hooks/useNotifications.d.ts +0 -26
  1853. package/dist/tui/hooks/useNotifications.js +0 -60
  1854. package/dist/tui/hooks/useTranscript.d.ts +0 -42
  1855. package/dist/tui/hooks/useTranscript.js +0 -277
  1856. package/dist/tui/index.d.ts +0 -2
  1857. package/dist/tui/logic.d.ts +0 -144
  1858. package/dist/tui/logic.js +0 -388
  1859. package/dist/tui/raf-batch.d.ts +0 -31
  1860. package/dist/tui/raf-batch.js +0 -89
  1861. package/dist/tui/render/inline-markdown.d.ts +0 -22
  1862. package/dist/tui/render/inline-markdown.js +0 -99
  1863. package/dist/tui/render/markdown.d.ts +0 -10
  1864. package/dist/tui/render/markdown.js +0 -35
  1865. package/dist/tui/render-output.d.ts +0 -42
  1866. package/dist/tui/render-output.js +0 -81
  1867. package/dist/tui/slash-commands.d.ts +0 -21
  1868. package/dist/tui/slash-commands.js +0 -71
  1869. package/dist/tui/turn-status.d.ts +0 -10
  1870. package/dist/tui/turn-status.js +0 -48
  1871. package/dist/tui/ws-client.d.ts +0 -39
  1872. package/dist/tui/ws-client.js +0 -139
  1873. package/scripts/install-bundled-dependencies.mjs +0 -54
  1874. package/web/dist/assets/board-math-css-spk7yR6n.js +0 -2
  1875. package/web/dist/assets/index-BQ69u-92.css +0 -1
  1876. package/web/dist/assets/index-CKNLatCd.js +0 -1
  1877. package/web/dist/assets/index-CkzWfC98.js +0 -525
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{L as M,o as O}from"./chunk-PZMGBKUR.js";var f=class extends Error{},D=["$ref","$defs","definitions","allOf","oneOf","patternProperties","dependentSchemas","dependencies","unevaluatedProperties","propertyNames","contains","prefixItems","not","if","then","else"];function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function L(e){if(!y(e))return!1;let r=typeof e.type=="string"?[e.type]:Array.isArray(e.type)?e.type:[];return r.includes("object")||r.includes("array")||e.properties!==void 0||e.items!==void 0}function R(e){return y(e)?e.type==="null"||Array.isArray(e.type)&&e.type.includes("null")||e.const===null||Array.isArray(e.enum)&&e.enum.includes(null)?!0:Array.isArray(e.anyOf)&&e.anyOf.some(r=>R(r)):!1}function w(e,r){if(!y(e))throw new f("boolean schemas are unsupported");for(let a of D)if(e[a]!==void 0)throw new f(`${a} schemas are unsupported`);if(r){for(let[a,l]of Object.entries(e))if(r(a,l))throw new f(`${a}: ${JSON.stringify(l)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new f("anyOf must contain at least one schema");for(let a of e.anyOf){if(L(a))throw new f("object and array unions are unsupported");w(a,r)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new f("tuple schemas are unsupported");w(e.items,r)}let t=e.type==="object";if(e.properties!==void 0&&!t)throw new f("properties require type object");if(!t)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new f("schema-valued or true additionalProperties is unsupported");if(e.properties!==void 0&&!y(e.properties))throw new f("object properties must be a schema map");if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(a=>typeof a!="string")))throw new f("object required must be a string array");let n=e.properties??{},o=Object.keys(n),i=new Set(Array.isArray(e.required)?e.required:[]);if([...i].some(a=>!o.includes(a)))throw new f("required contains an unknown property");for(let[a,l]of Object.entries(n))w(l,r),!i.has(a)&&!R(l)&&(n[a]={anyOf:[l,{type:"null"}]});e.required=o,e.additionalProperties=!1}function k(e,r){let t=structuredClone(e);if(!y(t))throw new f("root schema must have type object");if(w(t,r),t.type!=="object")throw new f("root schema must have type object");return t}function re(e,r){return r===!0?k(e.parameters):e.parameters}function ne(e,r,t){let n=r[t];if(typeof n!="string")throw new Error(`Grammar tool call "${e}" requires argument "${t}" to be a string.`);return n}function oe(e,r,t,n){if(e.closed){if(n&&t===e.input)return;throw new Error(`grammar tool input for property "${r}" changed after it was closed`)}if(!t.startsWith(e.input))throw new Error(`grammar tool input for property "${r}" changed non-monotonically`);let o=t.slice(e.input.length);if(!n&&o.length===0)return;let i="";return e.started||(i+=`{${JSON.stringify(r)}:"`,e.started=!0),i+=JSON.stringify(o).slice(1,-1),e.input=t,n&&(i+='"}',e.closed=!0),i}function b(e){let r=e.parameters;if(r.type!=="object")throw new Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(r.required)||r.required.length!==1||typeof r.required[0]!="string")throw new Error("grammar constrained sampling requires exactly one required string property");let t=r.required[0];if(!r.properties?.[t])throw new Error(`grammar constrained sampling requires a properties entry for ${t}`);if(r.properties[t]?.type!=="string")throw new Error(`grammar constrained sampling property ${t} must have type string`);return t}function ie(e,r,t){let n=e.constrainedSampling;if(!(!n||n.type!=="json_schema")){if(r)try{return k(e.parameters,t),!0}catch(o){if(!(o instanceof f))throw o;if(n.strict!=="require")return;throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${o.message}.`)}if(n.strict==="require")throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}function G(e,r){let t=e.constrainedSampling;if(!t||t.type!=="grammar"||!r)return;let n=t.variants.openai_lark,o=t.variants.openai_regex,i=typeof n=="string"&&n.trim().length>0,a=typeof o=="string"&&o.trim().length>0;if(!i&&!a)throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:i?"lark":"regex",definition:i?n:o,inputProperty:b(e)}}catch(l){let d=l instanceof Error?l.message:String(l);throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${d}.`)}}function ae(e,r){let t=new Map;for(let n of e??[]){let o=G(n,r);o&&t.set(n.name,o.inputProperty)}return t}var E=3.5,J=4800;function P(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}function _(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}function H(e){if(typeof e=="string")return e.length;let r=0;for(let t of e)r+=t.type==="text"?t.text.length:J;return r}function q(e){return Math.ceil(e.length/E)}function N(e){return Math.ceil(H(e)/E)}function C(e){let r=0;if(e.role==="system")return q(O(e))+v(e.toolsAdded)+v(e.toolsRemoved);if(e.role==="user"||e.role==="toolResult")return N(e.content);for(let t of e.content)t.type==="text"?r+=t.text.length:t.type==="thinking"?r+=t.thinking.length:r+=t.name.length+_(t.arguments).length;return Math.ceil(r/E)}function W(e){let r=Number.NEGATIVE_INFINITY,t;for(let n=0;n<e.length;n++){let o=e[n];if(o.role==="assistant"){let i=o;i.timestamp>=r&&i.stopReason!=="aborted"&&i.stopReason!=="error"&&P(i.usage)>0&&(t={usage:i.usage,index:n})}r=Math.max(r,o.timestamp)}return t}function $(e){let r="messages"in e?e.messages:e,t=W(r);if(t){let o=P(t.usage),i=0;for(let a=t.index+1;a<r.length;a++)i+=C(r[a]);return{tokens:o+i,usageTokens:o,trailingTokens:i,lastUsageIndex:t.index}}let n=0;for(let o of r)n+=C(o);return{tokens:n,usageTokens:0,trailingTokens:n,lastUsageIndex:null}}function v(e){return!e||e.length===0?0:q(_(e))}var B=4096,j=1;function F(e,r,t){if(e.contextWindow<=0)return Math.max(j,t);let n=e.contextWindow-$(r).tokens-B;return Math.min(t,Math.max(j,n))}function z(e,r,t){let n=M(e,r),o=e.samplingParamsByThinkingLevel?.[n];return e.samplingParams||o||t?{...e.samplingParams,...o,...t}:void 0}function ce(e,r,t,n){let o=z(e,t?.reasoning??"off",t?.samplingParams);return{temperature:t?.temperature,samplingParams:o,maxTokens:F(e,r,t?.maxTokens??e.maxTokens),signal:t?.signal,telemetry:t?.telemetry,apiKey:n||t?.apiKey,fetch:t?.fetch,transport:t?.transport,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,headers:t?.headers,identity:t?.identity,onPayload:t?.onPayload,onResponse:t?.onResponse,onProviderStreamEvent:t?.onProviderStreamEvent,timeoutMs:t?.timeoutMs,websocketConnectTimeoutMs:t?.websocketConnectTimeoutMs,maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata,env:t?.env}}var K=1024,U={minimal:1024,low:2048,medium:8192,high:16384};function V(e){return e==="xhigh"||e==="max"?"high":e}function Y(e,r){let t={...U,...r},n=V(e);return t[n]}function X(e,r){return Math.min(e,Math.max(0,r-K))}function de(e,r,t,n){let o=Y(t,n),i=e===void 0?r:Math.min(e+o,r);return i<=o&&(o=X(o,i)),{maxTokens:i,thinkingBudget:o}}var Q="(image omitted: model does not support images)",Z="(tool image omitted: model does not support images)",ee="(image attached after the tool results)";function ge(e){if(!e.isError)return;let r=e.content.filter(t=>t.type==="image");if(r.length!==0)return{content:I(e.content,ee),caption:`Images from the error result of tool call ${e.toolCallId} (${e.toolName}):`,images:r}}function I(e,r){let t=[],n=!1;for(let o of e){if(o.type==="image"){n||t.push({type:"text",text:r}),n=!0;continue}t.push(o),n=o.text===r}return t}function te(e,r){return r.input.includes("image")?e:e.map(t=>t.role==="user"&&Array.isArray(t.content)?{...t,content:I(t.content,Q)}:t.role==="toolResult"?{...t,content:I(t.content,Z)}:t)}function ye(e,r,t){let n=new Map,o=e.map(s=>s.content==null?{...s,content:[]}:s),a=te(o,r).map(s=>{if(s.role==="system"||s.role==="user")return s;if(s.role==="toolResult"){let u=n.get(s.toolCallId);return u&&u!==s.toolCallId?{...s,toolCallId:u}:s}if(s.role==="assistant"){let u=s,c=u.provider===r.provider&&u.api===r.api&&u.model===r.id,x=u.content.flatMap(p=>{if(p.type==="thinking")return c?p.redacted||p.thinkingSignature?p:!p.thinking||p.thinking.trim()===""?[]:p:[];if(p.type==="text")return c?p:{type:"text",text:p.text};if(p.type==="toolCall"){let m=p,g=m;if(!c&&m.thoughtSignature&&(g={...m},delete g.thoughtSignature),!c&&t){let A=t(m.id,r,u);A!==m.id&&(n.set(m.id,A),g={...g,id:A})}return g}return p});return{...u,content:x}}return s}),l=[],d=[],h=new Set,T=[],S=()=>{if(d.length>0){for(let s of d)h.has(s.id)||l.push({role:"toolResult",toolCallId:s.id,toolName:s.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});d=[],h=new Set}l.push(...T),T.length=0};for(let s=0;s<a.length;s++){let u=a[s];if(u.role==="assistant"){S();let c=u;if(c.stopReason==="error"||c.stopReason==="aborted")continue;let x=c.content.filter(p=>p.type==="toolCall");x.length>0&&(d=x,h=new Set),l.push(u)}else u.role==="toolResult"?(h.add(u.toolCallId),l.push(u)):u.role==="system"?d.length>0?T.push(u):l.push(u):(u.role==="user"&&S(),l.push(u))}return S(),l}export{re as a,ne as b,oe as c,ie as d,G as e,ae as f,F as g,z as h,ce as i,V as j,Y as k,X as l,de as m,ge as n,ye as o};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ function a(t){let e=(t.CORTEX_UI_HTTP||"").trim().toLowerCase();return e==="1"||e==="true"||e==="on"||e==="yes"}async function m(t){if(!a(process.env))return null;let{startUiHttpServer:e}=await import("./start-ui-http-QALT7C3P.js");return e({uiService:t})}import{accessSync as c,constants as p,realpathSync as u,statSync as l}from"node:fs";import{execFileSync as r}from"node:child_process";import*as n from"node:path";function i(t){try{return c(t,p.X_OK),l(t).isFile()}catch{return!1}}function f(){let t=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];return(process.env.PATH||"").split(n.delimiter).flatMap(s=>t.map(o=>n.resolve(s,`git${o}`))).find(i)??null}function d(t){if(process.platform!=="darwin"||u(t)!=="/usr/bin/git")return!0;let e=r("/usr/bin/xcode-select",["-p"],{encoding:"utf8",stdio:"pipe",timeout:5e3}).trim();return!!e&&i(n.join(e,"usr/bin/git"))}function b(){try{let t=f();return!t||!d(t)?!1:r(t,["--version"],{encoding:"utf8",stdio:"pipe",timeout:5e3}).startsWith("git version ")}catch{return!1}}export{b as a,a as b,m as c};
@@ -0,0 +1,11 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{a as c,c as v}from"./chunk-WHC7AYZD.js";var b=v((N,$)=>{var T=c("buffer"),S=T.Buffer;function Z(e,r){for(var t in e)r[t]=e[t]}S.from&&S.alloc&&S.allocUnsafe&&S.allocUnsafeSlow?$.exports=T:(Z(T,N),N.Buffer=g);function g(e,r,t){return S(e,r,t)}g.prototype=Object.create(S.prototype);Z(S,g);g.from=function(e,r,t){if(typeof e=="number")throw new TypeError("Argument must not be a number");return S(e,r,t)};g.alloc=function(e,r,t){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=S(e);return r!==void 0?typeof t=="string"?n.fill(r,t):n.fill(r):n.fill(0),n};g.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return S(e)};g.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return T.SlowBuffer(e)}});var X=v((br,Q)=>{"use strict";function H(e){var r=(e/8|0)+(e%8===0?0:1);return r}var Ve={ES256:H(256),ES384:H(384),ES512:H(521)};function Ke(e){var r=Ve[e];if(r)return r;throw new Error('Unknown algorithm "'+e+'"')}Q.exports=Ke});var ne=v((wr,te)=>{"use strict";var I=b().Buffer,z=X(),P=128,k=0,Ne=32,He=16,Ge=2,ee=He|Ne|k<<6,x=Ge|k<<6;function Je(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function re(e){if(I.isBuffer(e))return e;if(typeof e=="string")return I.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function Me(e,r){e=re(e);var t=z(r),n=t+1,a=e.length,i=0;if(e[i++]!==ee)throw new Error('Could not find expected "seq"');var u=e[i++];if(u===(P|1)&&(u=e[i++]),a-i<u)throw new Error('"seq" specified length of "'+u+'", only "'+(a-i)+'" remaining');if(e[i++]!==x)throw new Error('Could not find expected "int" for "r"');var s=e[i++];if(a-i-2<s)throw new Error('"r" specified length of "'+s+'", only "'+(a-i-2)+'" available');if(n<s)throw new Error('"r" specified length of "'+s+'", max of "'+n+'" is acceptable');var m=i;if(i+=s,e[i++]!==x)throw new Error('Could not find expected "int" for "s"');var h=e[i++];if(a-i!==h)throw new Error('"s" specified length of "'+h+'", expected "'+(a-i)+'"');if(n<h)throw new Error('"s" specified length of "'+h+'", max of "'+n+'" is acceptable');var o=i;if(i+=h,i!==a)throw new Error('Expected to consume entire buffer, but "'+(a-i)+'" bytes remain');var f=t-s,K=t-h,y=I.allocUnsafe(f+s+K+h);for(i=0;i<f;++i)y[i]=0;e.copy(y,i,m+Math.max(-f,0),m+s),i=t;for(var De=i;i<De+K;++i)y[i]=0;return e.copy(y,i,o+Math.max(-K,0),o+h),y=y.toString("base64"),y=Je(y),y}function Y(e,r,t){for(var n=0;r+n<t&&e[r+n]===0;)++n;var a=e[r+n]>=P;return a&&--n,n}function je(e,r){e=re(e);var t=z(r),n=e.length;if(n!==t*2)throw new TypeError('"'+r+'" signatures must be "'+t*2+'" bytes, saw "'+n+'"');var a=Y(e,0,t),i=Y(e,t,e.length),u=t-a,s=t-i,m=2+u+1+1+s,h=m<P,o=I.allocUnsafe((h?2:3)+m),f=0;return o[f++]=ee,h?o[f++]=m:(o[f++]=P|1,o[f++]=m&255),o[f++]=x,o[f++]=u,a<0?(o[f++]=0,f+=e.copy(o,f,0,t)):f+=e.copy(o,f,a,t),o[f++]=x,o[f++]=s,i<0?(o[f++]=0,e.copy(o,f,t)):e.copy(o,f,t+i),o}te.exports={derToJose:Me,joseToDer:je}});var G=v((Er,ie)=>{var L=b().Buffer,Ce=c("stream"),Fe=c("util");function R(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=L.alloc(0),this;if(typeof e.pipe=="function")return this.buffer=L.alloc(0),e.pipe(this),this;if(e.length||typeof e=="object")return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}Fe.inherits(R,Ce);R.prototype.write=function(r){this.buffer=L.concat([this.buffer,L.from(r)]),this.emit("data",r)};R.prototype.end=function(r){r&&this.write(r),this.emit("end",r),this.emit("close"),this.writable=!1,this.readable=!1};ie.exports=R});var fe=v((qr,ae)=>{"use strict";var A=c("buffer").Buffer,J=c("buffer").SlowBuffer;ae.exports=O;function O(e,r){if(!A.isBuffer(e)||!A.isBuffer(r)||e.length!==r.length)return!1;for(var t=0,n=0;n<e.length;n++)t|=e[n]^r[n];return t===0}O.install=function(){A.prototype.equal=J.prototype.equal=function(r){return O(this,r)}};var Ue=A.prototype.equal,We=J.prototype.equal;O.restore=function(){A.prototype.equal=Ue,J.prototype.equal=We}});var F=v((Ar,Se)=>{var E=b().Buffer,l=c("crypto"),ue=ne(),oe=c("util"),Ze=`"%s" is not a valid algorithm.
5
+ Supported algorithms are:
6
+ "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,B="secret must be a string or buffer",w="key must be a string or a buffer",$e="key must be a string, a buffer or an object",j=typeof l.createPublicKey=="function";j&&(w+=" or a KeyObject",B+="or a KeyObject");function se(e){if(!E.isBuffer(e)&&typeof e!="string"&&(!j||typeof e!="object"||typeof e.type!="string"||typeof e.asymmetricKeyType!="string"||typeof e.export!="function"))throw p(w)}function ce(e){if(!E.isBuffer(e)&&typeof e!="string"&&typeof e!="object")throw p($e)}function Qe(e){if(!E.isBuffer(e)){if(typeof e=="string")return e;if(!j||typeof e!="object"||e.type!=="secret"||typeof e.export!="function")throw p(B)}}function C(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function le(e){e=e.toString();var r=4-e.length%4;if(r!==4)for(var t=0;t<r;++t)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function p(e){var r=[].slice.call(arguments,1),t=oe.format.bind(oe,e).apply(null,r);return new TypeError(t)}function Xe(e){return E.isBuffer(e)||typeof e=="string"}function _(e){return Xe(e)||(e=JSON.stringify(e)),e}function he(e){return function(t,n){Qe(n),t=_(t);var a=l.createHmac("sha"+e,n),i=(a.update(t),a.digest("base64"));return C(i)}}var M,Ye="timingSafeEqual"in l?function(r,t){return r.byteLength!==t.byteLength?!1:l.timingSafeEqual(r,t)}:function(r,t){return M||(M=fe()),M(r,t)};function ze(e){return function(t,n,a){var i=he(e)(t,a);return Ye(E.from(n),E.from(i))}}function pe(e){return function(t,n){ce(n),t=_(t);var a=l.createSign("RSA-SHA"+e),i=(a.update(t),a.sign(n,"base64"));return C(i)}}function ve(e){return function(t,n,a){se(a),t=_(t),n=le(n);var i=l.createVerify("RSA-SHA"+e);return i.update(t),i.verify(a,n,"base64")}}function ke(e){return function(t,n){ce(n),t=_(t);var a=l.createSign("RSA-SHA"+e),i=(a.update(t),a.sign({key:n,padding:l.constants.RSA_PKCS1_PSS_PADDING,saltLength:l.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return C(i)}}function er(e){return function(t,n,a){se(a),t=_(t),n=le(n);var i=l.createVerify("RSA-SHA"+e);return i.update(t),i.verify({key:a,padding:l.constants.RSA_PKCS1_PSS_PADDING,saltLength:l.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function rr(e){var r=pe(e);return function(){var n=r.apply(null,arguments);return n=ue.derToJose(n,"ES"+e),n}}function tr(e){var r=ve(e);return function(n,a,i){a=ue.joseToDer(a,"ES"+e).toString("base64");var u=r(n,a,i);return u}}function nr(){return function(){return""}}function ir(){return function(r,t){return t===""}}Se.exports=function(r){var t={hs:he,rs:pe,ps:ke,es:rr,none:nr},n={hs:ze,rs:ve,ps:er,es:tr,none:ir},a=r.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!a)throw p(Ze,r);var i=(a[1]||a[3]).toLowerCase(),u=a[2];return{sign:t[i](u),verify:n[i](u)}}});var U=v((Br,ye)=>{var ar=c("buffer").Buffer;ye.exports=function(r){return typeof r=="string"?r:typeof r=="number"||ar.isBuffer(r)?r.toString():JSON.stringify(r)}});var Ee=v((_r,we)=>{var fr=b().Buffer,de=G(),or=F(),ur=c("stream"),me=U(),W=c("util");function ge(e,r){return fr.from(e,r).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function sr(e,r,t){t=t||"utf8";var n=ge(me(e),"binary"),a=ge(me(r),t);return W.format("%s.%s",n,a)}function be(e){var r=e.header,t=e.payload,n=e.secret||e.privateKey,a=e.encoding,i=or(r.alg),u=sr(r,t,a),s=i.sign(u,n);return W.format("%s.%s",u,s)}function D(e){var r=e.secret;if(r=r??e.privateKey,r=r??e.key,/^hs/i.test(e.header.alg)===!0&&r==null)throw new TypeError("secret must be a string or buffer or a KeyObject");var t=new de(r);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=t,this.payload=new de(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}W.inherits(D,ur);D.prototype.sign=function(){try{var r=be({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",r),this.emit("data",r),this.emit("end"),this.readable=!1,r}catch(t){this.readable=!1,this.emit("error",t),this.emit("close")}};D.sign=be;we.exports=D});var Re=v((Tr,Le)=>{var Ae=b().Buffer,qe=G(),cr=F(),lr=c("stream"),Be=U(),hr=c("util"),pr=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function vr(e){return Object.prototype.toString.call(e)==="[object Object]"}function Sr(e){if(vr(e))return e;try{return JSON.parse(e)}catch{return}}function _e(e){var r=e.split(".",1)[0];return Sr(Ae.from(r,"base64").toString("binary"))}function yr(e){return e.split(".",2).join(".")}function Te(e){return e.split(".")[2]}function dr(e,r){r=r||"utf8";var t=e.split(".")[1];return Ae.from(t,"base64").toString(r)}function Ie(e){return pr.test(e)&&!!_e(e)}function Pe(e,r,t){if(!r){var n=new Error("Missing algorithm parameter for jws.verify");throw n.code="MISSING_ALGORITHM",n}e=Be(e);var a=Te(e),i=yr(e),u=cr(r);return u.verify(i,a,t)}function xe(e,r){if(r=r||{},e=Be(e),!Ie(e))return null;var t=_e(e);if(!t)return null;var n=dr(e);return(t.typ==="JWT"||r.json)&&(n=JSON.parse(n,r.encoding)),{header:t,payload:n,signature:Te(e)}}function q(e){e=e||{};var r=e.secret;if(r=r??e.publicKey,r=r??e.key,/^hs/i.test(e.algorithm)===!0&&r==null)throw new TypeError("secret must be a string or buffer or a KeyObject");var t=new qe(r);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=t,this.signature=new qe(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}hr.inherits(q,lr);q.prototype.verify=function(){try{var r=Pe(this.signature.buffer,this.algorithm,this.key.buffer),t=xe(this.signature.buffer,this.encoding);return this.emit("done",r,t),this.emit("data",r),this.emit("end"),this.readable=!1,r}catch(n){this.readable=!1,this.emit("error",n),this.emit("close")}};q.decode=xe;q.isValid=Ie;q.verify=Pe;Le.exports=q});var gr=v(d=>{var Oe=Ee(),V=Re(),mr=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];d.ALGORITHMS=mr;d.sign=Oe.sign;d.verify=V.verify;d.decode=V.decode;d.isValid=V.isValid;d.createSign=function(r){return new Oe(r)};d.createVerify=function(r){return new V(r)}});export{ne as a,gr as b};
7
+ /*! Bundled license information:
8
+
9
+ safe-buffer/index.js:
10
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
11
+ */
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{a as ae}from"./chunk-B3XBQEFM.js";import{e as ie}from"./chunk-WHC7AYZD.js";import{realpathSync as pe,statSync as fe}from"node:fs";import{homedir as le}from"node:os";import{isAbsolute as B,join as me,resolve as j,relative as ge,sep as F}from"node:path";import{fileURLToPath as he}from"node:url";var R=ie(ae(),1);import{spawn as ce,spawnSync as ue}from"node:child_process";var de=100;function Oe(e,t,n){return process.platform==="win32"?(0,R.default)(e,t,n):ce(e,t,n)}function w(e,t,n){return process.platform==="win32"?R.default.sync(e,t,n):ue(e,t,n)}function je(e){return new Promise((t,n)=>{let r=!1,o=!1,i=null,a,p=e.stdout===null,d=e.stderr===null,l=()=>{a&&(clearTimeout(a),a=void 0),e.removeListener("error",W),e.removeListener("exit",T),e.removeListener("close",O),e.stdout?.removeListener("end",N),e.stderr?.removeListener("end",L),e.stdout?.removeListener("data",y),e.stderr?.removeListener("data",y)},P=m=>{r||(r=!0,l(),e.stdout?.destroy(),e.stderr?.destroy(),t(m))},k=()=>{!o||r||p&&d&&P(i)},$=()=>{a&&clearTimeout(a),a=setTimeout(()=>P(i),de)},y=()=>{o&&!r&&$()},N=()=>{p=!0,k()},L=()=>{d=!0,k()},W=m=>{r||(r=!0,l(),n(m))},T=m=>{o=!0,i=m,k(),r||$()},O=m=>{P(m)};e.stdout?.once("end",N),e.stderr?.once("end",L),e.stdout?.on("data",y),e.stderr?.on("data",y),e.once("error",W),e.once("exit",T),e.once("close",O)})}var xe=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;function qe(e){try{return pe(e)}catch{return e}}function Ve(e){try{let t=fe(e,{bigint:!0});return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch{return}}function He(e){let t=e.trim();return!(t.startsWith("npm:")||t.startsWith("git:")||t.startsWith("github:")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("ssh:")||t.startsWith("builtin:"))}function be(e){if(!e.startsWith("/")||e.startsWith("//")||e.includes("\\"))return e;let t=e.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);if(!t)return e;let n=t[2]?.replaceAll("/","\\");return`${t[1].toUpperCase()}:\\${n??""}`}function _(e,t={}){let n=t.trim?e.trim():e;if(t.normalizeUnicodeSpaces&&(n=n.replace(xe," ")),t.stripAtPrefix&&n.startsWith("@")&&(n=n.slice(1)),process.platform==="win32"&&(n=be(n)),t.expandTilde??!0){let r=t.homeDir??le();if(n==="~")return r;if(n.startsWith("~/")||process.platform==="win32"&&n.startsWith("~\\"))return me(r,n.slice(2))}return/^file:\/\//.test(n)?he(n):n}function U(e,t=process.cwd(),n={}){let r=_(e,n),o=_(t);return B(r)?j(r):j(o,r)}function Pe(e,t){let n=U(t),r=U(e,n),o=ge(n,r);return o===""||o!==".."&&!o.startsWith(`..${F}`)&&!B(o)?o||".":void 0}function Ke(e,t){let n=U(e,t);return(Pe(n,t)??n).split(F).join("/")}function Qe(e){let t=process.platform==="darwin"?["com.dropbox.ignored","com.apple.fileprovider.ignore#P"]:process.platform==="linux"?["user.com.dropbox.ignored"]:[];for(let n of t)process.platform==="darwin"?w("xattr",["-w",n,"1",e],{encoding:"utf-8",stdio:"ignore"}):w("setfattr",["-n",n,"-v","1",e],{encoding:"utf-8",stdio:"ignore"})}import{accessSync as z,constants as G,existsSync as g,readFileSync as I,realpathSync as _e}from"fs";import{homedir as C}from"os";import{basename as K,dirname as u,join as s,resolve as S,sep as M,win32 as Se}from"path";import{fileURLToPath as Q}from"url";function we(e){return e.startsWith("\uFEFF")?{bom:"\uFEFF",text:e.slice(1)}:{bom:"",text:e}}function A(e){return we(e).text}var ve=Q(new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href),X=u(ve),h=new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href.includes("$bunfs")||new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href.includes("~BUN")||new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href.includes("%7EBUN"),ye=!!process.versions.bun,Ee=!0;function Y(e){return typeof e=="string"?{packageName:e,installSpec:e}:{packageName:e.packageName,installSpec:e.installSpec??e.packageName}}function E(e,t){return t?{...e,display:`${t.display} && ${e.display}`,steps:[t,e]}:e}function f(e,t){return{command:e,args:t,display:[e,...t].map(n=>/\s/.test(n)?`"${n}"`:n).join(" ")}}function Z(){if(h)return"bun-binary";let e=`${X}\0${process.execPath||""}`.toLowerCase().replace(/\\/g,"/");return e.includes("/pnpm/")||e.includes("/.pnpm/")?"pnpm":e.includes("/yarn/")||e.includes("/.yarn/")?"yarn":ye||e.includes("/install/global/node_modules/")?"bun":e.includes("/npm/")||e.includes("/node_modules/")?"npm":"unknown"}function ee(){let e=c(),t=process.platform==="win32"||e.includes("\\")?Se:{basename:K,dirname:u},n=t.dirname(e),r;if(t.basename(n).startsWith("@")&&t.basename(t.dirname(n))==="node_modules"?r=t.dirname(n):t.basename(n)==="node_modules"&&(r=n),!r)return;let o=t.dirname(r);if(t.basename(o)==="lib")return{root:r,prefix:t.dirname(o)}}function te(e,t,n=t,r){let o=Y(n);switch(e){case"bun-binary":return;case"pnpm":{let i=x("pnpm",["root","-g"])?void 0:/^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(c()),a=i?[`--config.global-bin-dir=${process.env.PNPM_HOME||u(u(i[1]))}`]:[];return E(f("pnpm",["install","-g","--ignore-scripts","--config.minimumReleaseAge=0",...a,o.installSpec]),o.packageName===t?void 0:f("pnpm",["remove","-g",...a,t]))}case"yarn":return E(f("yarn",["global","add","--ignore-scripts",o.installSpec]),o.packageName===t?void 0:f("yarn",["global","remove",t]));case"bun":return E(f("bun",["install","-g","--ignore-scripts","--minimum-release-age=0",o.installSpec]),o.packageName===t?void 0:f("bun",["uninstall","-g",t]));case"npm":{let[i="npm",...a]=r??[],p=r?.length?void 0:ee(),d=[...a,...p?["--prefix",p.prefix]:[]],l=f(i,[...d,"install","-g","--ignore-scripts","--min-release-age=0",o.installSpec]),P=o.packageName===t?void 0:f(i,[...d,"uninstall","-g",t]);return E(l,P)}case"unknown":return}}function x(e,t,n={}){let r=w(e,t,{encoding:"utf-8",stdio:["ignore","pipe","pipe"]});if(r.status===0)return r.stdout.trim()||void 0;if(n.requireSuccess){let o=r.error?.message||r.stderr.trim()||`exit code ${r.status??"unknown"}`;throw new Error(`Failed to run ${[e,...t].join(" ")}: ${o}`)}}function De(e,t,n){switch(e){case"npm":{let r=!!n?.length,[o="npm",...i]=n??[];if(r&&o==="bun"){let d=x(o,[...i,"pm","bin","-g"],{requireSuccess:!0}),l=[s(C(),".bun","install","global","node_modules")];return d&&l.push(s(u(d),"install","global","node_modules")),l}let a=x(o,[...i,"root","-g"],{requireSuccess:r}),p=r?void 0:ee();return[a,p?.root].filter(d=>!!d)}case"pnpm":{let r=x("pnpm",["root","-g"]);if(r)return[r,u(r)];let o=/^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(c());return o?[o[1]]:[]}case"yarn":{let r=x("yarn",["global","dir"]);return r?[r,s(r,"node_modules")]:[]}case"bun":{let r=x("bun",["pm","bin","-g"]),o=[s(C(),".bun","install","global","node_modules")];return r&&o.push(s(u(r),"install","global","node_modules")),o}case"bun-binary":case"unknown":return[]}}function J(e,t){let n=S(e);if(!g(n))return;let r=n;if(t)try{r=_e(n)}catch{return}return process.platform==="win32"&&(r=r.toLowerCase()),r}function q(e){return Array.from(new Set([J(e,!1),J(e,!0)].filter(t=>!!t)))}function ke(){let e=process.argv[1];if(!e)return;let t=u(e);for(;t!==u(t);){if(g(s(t,"package.json")))return t;t=u(t)}}function ne(){let e=c();try{return z(e,G.W_OK),z(u(e),G.W_OK),!0}catch{return!1}}function re(e,t,n){let o=[c(),ke()].filter(i=>!!i).flatMap(i=>q(i));return De(e,t,n).some(i=>q(i).some(a=>{let p=a.endsWith(M)?a:`${a}${M}`;return o.some(d=>d.startsWith(p))}))}function it(e,t,n=e){let r=Z(),o=te(r,e,n,t);if(!(!o||!re(r,e,t)||!ne()))return o}function at(e,t,n=e){let r=Z(),o=Y(n);if(r==="bun-binary")return"Download from: https://github.com/earendil-works/pi/releases/latest";let i=te(r,e,o,t);return i?re(r,e,t)&&!ne()?`This installation is managed by a global ${r} install, but the install path is not writable. Update it yourself with: ${i.display}`:`This installation is not managed by a global ${r} install. Update it with the package manager, wrapper, or source checkout that provides it.`:`Update ${o.installSpec} using the package manager, wrapper, or source checkout that provides this installation.`}function Re(e){let t=e;for(;t!==u(t);){if(g(s(t,"package.json"))){let n=u(t);return K(t)==="dist"&&g(s(n,"package.json"))?n:t}t=u(t)}return e}function c(){let e=process.env.PI_PACKAGE_DIR;return e?_(e):h?u(process.execPath):Re(X)}function ct(){if(h)return s(c(),"theme");let e=c(),t=g(s(e,"src"))?"src":"dist";return s(e,t,"modes","interactive","theme")}function ut(){if(h)return s(c(),"export-html");let e=c(),t=g(s(e,"src"))?"src":"dist";return s(e,t,"core","export-html")}function Ue(){return s(c(),"package.json")}function dt(){return S(s(c(),"README.md"))}function pt(){return S(s(c(),"docs"))}function ft(){return S(s(c(),"examples"))}function lt(){return S(s(c(),"CHANGELOG.md"))}function Ae(){if(h)return s(c(),"assets");let e=c(),t=g(s(e,"src"))?"src":"dist";return s(e,t,"modes","interactive","assets")}function mt(e){return s(Ae(),e)}var V;function gt(){return V??=Q(new URL("vendor/quickjs.wasm",__cortexPackageRoot)),V}function Ce(e,t){if(e==="bun-binary")return"./src/extensions/codemode/worker.ts";if(e==="bundled-node")return new URL("./codemode-worker.js",t)}var H;function ht(){let e=h?"bun-binary":Ee?"bundled-node":"unbundled",t=Ce(e,new URL("vendor/pi/dist/config.js",__cortexPackageRoot).href);return e!=="bundled-node"||!(t instanceof URL)?t:(H??=new URL(`data:text/javascript;base64,${I(t).toString("base64")}`),H)}function xt(e=oe){if(h||!e)return;let t;try{t=JSON.parse(A(I(e,"utf-8")))}catch(n){return n.code==="ENOENT"?{kind:"removed"}:void 0}return t.version&&t.version!==$e?{kind:"updated",version:t.version}:void 0}var v={},oe;try{let e=Ue();v=JSON.parse(A(I(e,"utf-8"))),oe=e}catch(e){if(e.code!=="ENOENT")throw e}var se=v.piConfig?.name,bt=v.name||"@earendil-works/pi-coding-agent",D=se||"pi",Pt=se?D:"\u03C0",Ie=v.piConfig?.configDir||".pi",$e=v.version||"0.0.0",Ne=`${D.toUpperCase()}_CODING_AGENT_DIR`,wt=`${D.toUpperCase()}_CODING_AGENT_SESSION_DIR`;function Le(e){return _(e)}var We="https://pi.dev/session/";function _t(e){return`${process.env.PI_SHARE_VIEWER_URL||We}#${e}`}function b(){let e=process.env[Ne];return e?Le(e):s(C(),Ie,"agent")}function St(){return s(b(),"themes")}function vt(){return s(b(),"auth.json")}function yt(){return s(b(),"settings.json")}function Et(){return s(b(),"bin")}function Dt(){return s(b(),"sessions")}function kt(){return s(b(),`${D}-debug.log`)}export{Oe as a,w as b,je as c,qe as d,Ve as e,He as f,_ as g,U as h,Pe as i,Ke as j,Qe as k,we as l,A as m,h as n,Ee as o,Z as p,it as q,at as r,c as s,ct as t,ut as u,dt as v,pt as w,ft as x,lt as y,mt as z,gt as A,ht as B,xt as C,bt as D,D as E,Pt as F,Ie as G,$e as H,Ne as I,wt as J,Le as K,_t as L,b as M,St as N,vt as O,yt as P,Et as Q,Dt as R,kt as S};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{c as u}from"./chunk-J5DVLUKY.js";import*as a from"fs";import*as r from"path";import{fileURLToPath as l}from"url";function x(e){return r.dirname(l(e))}function _(e){if(!process.argv[1])return!1;let t=l(e),n=r.resolve(process.argv[1]);if(n===t)return!0;try{return a.realpathSync(n)===t}catch{return!1}}function $(){let e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}_${t(e.getHours())}-${t(e.getMinutes())}-${t(e.getSeconds())}`}function v(e){if(e<60)return`${Math.round(e)}s`;let t=Math.floor(e/60),n=Math.round(e%60);return n>0?`${t}m ${n}s`:`${t}m`}function f(e,t={}){let n=(t.override??process.env.CORTEX_NPM_PREFIX)?.trim();if(n)return n;let o=t.exists??a.existsSync,i=t.pathEnv??process.env.PATH??"";for(let s of i.split(r.delimiter)){if(!s||!o(r.join(s,e)))continue;let c=r.dirname(s);if(o(r.join(c,"lib","node_modules")))return c}return null}function m(e,t,n=process.platform){let o=n==="win32"?r.win32:r.posix,i=o.resolve(e);for(let c of t.split("/").reverse()){if(o.basename(i)!==c)return null;i=o.dirname(i)}if(o.basename(i)!=="node_modules")return null;let s=o.dirname(i);return n==="win32"?s:o.basename(s)==="lib"?o.dirname(s):null}function w(e,t=u){let n=process.env.CORTEX_NPM_PREFIX?.trim()||m(t,"@cortex-agent/server")||f("cortex");return n?[...e,"--prefix",n]:e}function S(e,t=process.platform,n=process.execPath,o=a.existsSync){if(t!=="win32")return{command:"npm",args:e,shell:!1};let i=r.win32.join(r.win32.dirname(n),"node_modules","npm","bin","npm-cli.js");return o(i)?{command:n,args:[i,...e],shell:!1}:{command:"npm.cmd",args:e.map(p),shell:!0}}function p(e){return`"${e.replace(/(\\*)"/g,'$1$1\\"').replace(/(\\+)$/g,"$1$1")}"`}var E="cortex-gateway-managed";export{x as a,_ as b,$ as c,v as d,m as e,w as f,S as g,E as h};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ function R(e){let t=e.split("*").map(r=>r.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`)}function k(e){let t=new Set(e.filter(n=>!n.includes("*"))),r=e.filter(n=>n.includes("*")).map(R);return n=>t.has(n)||r.some(o=>o.test(n))}var U="list_mcp_resources",x="list_mcp_resource_templates",_="read_mcp_resource",y=new Set([U,x,_]);function T(e){return e.startsWith("mcp__")||y.has(e)}var E=["codemode","deferred","direct","hidden"],$={"codemode-deferred":"codemode"},f=["localhost","127.0.0.1","[::1]"];function L(e){if(!URL.canParse(e))return!1;let t=new URL(e);return t.protocol==="http:"&&f.includes(t.hostname)&&t.search===""&&t.hash===""}var S=/^[A-Za-z0-9_-]+$/;function w(e){return`mcp__${e.replace(/-/g,"_")}`}function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function h(e){return c(e)&&Object.values(e).every(t=>typeof t=="string")}function O(e){if(e===void 0)return;if(!c(e))return"oauth must be an object";if(e.clientId!==void 0&&typeof e.clientId!="string")return"oauth.clientId must be a string";if(e.clientSecret!==void 0&&typeof e.clientSecret!="string")return"oauth.clientSecret must be a string";let t=e.callbackPort;if(t!==void 0&&(typeof t!="number"||!Number.isInteger(t)||t<1||t>65535))return"oauth.callbackPort must be a port number";if(e.callbackUrl!==void 0){if(typeof e.callbackUrl!="string"||!L(e.callbackUrl))return"oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment";let n=new URL(e.callbackUrl).port;if(n&&t!==void 0&&Number(n)!==t)return"oauth.callbackUrl and oauth.callbackPort name different ports"}if(e.scope!==void 0&&typeof e.scope!="string")return"oauth.scope must be a string";if(e.clientName!==void 0&&(typeof e.clientName!="string"||!e.clientName.trim()))return"oauth.clientName must be a non-empty string";if(e.clientRegistration!==void 0&&e.clientRegistration!=="dcr"){if(e.clientRegistration!=="cimd")return'oauth.clientRegistration must be "dcr" or "cimd"';if(e.clientId!==void 0||e.clientName!==void 0)return'oauth.clientRegistration "cimd" cannot be combined with oauth.clientId or oauth.clientName';let n=typeof e.callbackUrl=="string"?new URL(e.callbackUrl):void 0;if(n&&(n.hostname==="[::1]"||n.pathname!=="/callback"))return'oauth.clientRegistration "cimd" requires oauth.callbackUrl on localhost or 127.0.0.1 with path /callback'}let r=e.authServerMetadataUrl;if(r!==void 0){let n=typeof r=="string"&&URL.canParse(r)?new URL(r):void 0;if(!n||!(n.protocol==="https:"||n.protocol==="http:"&&f.includes(n.hostname)))return"oauth.authServerMetadataUrl must be an https URL, or http on localhost, 127.0.0.1, or [::1]"}}function m(e){return typeof e=="string"&&E.includes(e)}function b(e){return typeof e=="string"?$[e]??e:e}function P(e){let{exposure:t,toolExposure:r}=e,n={...e};return t!==void 0&&(n.exposure=b(t)),c(r)&&(n.toolExposure=Object.fromEntries(Object.entries(r).map(([o,i])=>[o,b(i)]))),n}function A(e,t){let r=e.toolExposure??{},n=r[t];if(n!==void 0)return n;for(let[o,i]of Object.entries(r))if(o.includes("*")&&R(o).test(t))return i;return e.exposure??"codemode"}function C(e,t){if(!S.test(e))return`invalid server name "${e}" (use letters, digits, "_" and "-")`;if(!c(t))return`server "${e}" must be an object`;let r=P(t),{type:n,exposure:o,enabled:i,timeout:a,toolExposure:d,description:p}=r,l=E.map(s=>`"${s}"`).join(", ");if(o!==void 0&&!m(o))return`server "${e}": exposure must be one of ${l}`;if(d!==void 0){if(!c(d))return`server "${e}": toolExposure must map tool names to exposures`;for(let[s,u]of Object.entries(d))if(!m(u))return`server "${e}": toolExposure "${s}" must be one of ${l}`}if(i!==void 0&&typeof i!="boolean")return`server "${e}": enabled must be a boolean`;if(p!==void 0&&typeof p!="string")return`server "${e}": description must be a string`;if(a!==void 0&&(typeof a!="number"||!(a>0)))return`server "${e}": timeout must be a positive number of seconds`;if(n==="sse")return`server "${e}": legacy SSE transport is not supported; use the streamable HTTP URL`;if(typeof r.url=="string"&&(n===void 0||n==="http"||n==="streamable-http")){if(!URL.canParse(r.url)||!/^https?:$/.test(new URL(r.url).protocol))return`server "${e}": url must be an http or https URL`;if(r.headers!==void 0&&!h(r.headers))return`server "${e}": headers must map names to strings`;let s=O(r.oauth);if(s)return`server "${e}": ${s}`;if(r.auth!==void 0){if(!c(r.auth)||typeof r.auth.provider!="string"||!r.auth.provider)return`server "${e}": auth.provider must be a provider name`;let u=new URL(r.url);if(u.protocol!=="https:"&&!f.includes(u.hostname))return`server "${e}": auth requires an https URL, or http on localhost, 127.0.0.1, or [::1]`}return r}return typeof r.command=="string"&&(n===void 0||n==="stdio")?r.args!==void 0&&!(Array.isArray(r.args)&&r.args.every(s=>typeof s=="string"))?`server "${e}": args must be an array of strings`:r.env!==void 0&&!h(r.env)?`server "${e}": env must map names to strings`:r.cwd!==void 0&&typeof r.cwd!="string"?`server "${e}": cwd must be a string`:r:`server "${e}" needs either "command" (stdio) or "url" (streamable HTTP)`}var g=class{servers=new Map;changeListener;register(t){this.servers.set(t.name,t),this.changeListener?.()}unregister(t,r){this.servers.get(t)?.extensionPath===r&&(this.servers.delete(t),this.changeListener?.())}get(t){return this.servers.get(t)}list(){return[...this.servers.values()].map(t=>({...t,config:structuredClone(t.config)}))}setChangeListener(t){this.changeListener=t}};export{k as a,U as b,x as c,_ as d,T as e,w as f,A as g,C as h,g as i};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{e as a}from"./chunk-NAA7GF6Q.js";import*as p from"crypto";import{mkdirSync as m,readFileSync as y,renameSync as g,writeFileSync as S}from"fs";import*as d from"path";var f=a("ui-http"),x="ui-pairing.json",A=600*1e3,w=20,i="0123456789ABCDEFGHJKMNPQRSTVWXYZ",l=8,I={O:"0",I:"1",L:"1"};function E(r){let n=r.toUpperCase().replace(/[\s-]/g,"");if(n.length!==l)return null;let e=[...n].map(o=>I[o]??o).join("");return[...e].every(o=>i.includes(o))?e:null}function L(r){return`${r.slice(0,4)}-${r.slice(4)}`}function N(){return[...p.randomBytes(l)].map(n=>i[n%i.length]).join("")}function u(r,n){let e=null;try{e=JSON.parse(y(r,"utf8"))}catch{}let o={};for(let[t,s]of Object.entries(e?.codes??{}))typeof s=="number"&&s>n&&(o[t]=s);return{codes:o,failures:typeof e?.failures=="number"?e.failures:0}}function c(r,n){try{m(d.dirname(r),{recursive:!0});let e=`${r}.${process.pid}.tmp`;S(e,JSON.stringify(n),{mode:384}),g(e,r)}catch(e){f.warn(`could not persist pairing codes: ${e.message}`)}}function C(r){let n=r.now??(()=>Date.now()),{file:e}=r;return{create(){let o=n(),t=u(e,o),s=N();return t.codes[s]=o+A,t.failures=0,c(e,t),{code:L(s),expiresAt:t.codes[s]}},redeem(o){let t=u(e,n()),s=E(o);return s&&s in t.codes?(delete t.codes[s],c(e,t),!0):(t.failures+=1,t.failures>=w&&(f.warn("too many wrong pairing codes \u2014 voiding every outstanding code"),t.codes={},t.failures=0),c(e,t),!1)}}}export{x as a,A as b,E as c,C as d};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{d as c}from"./chunk-52T37Y47.js";import{d as a}from"./chunk-W5LGYSPZ.js";import{a as S,m as l}from"./chunk-J5DVLUKY.js";import{e as g}from"./chunk-WHC7AYZD.js";var u=g(S(),1),E=new Set(["CLAUDE_CODE_OAUTH_TOKEN_EXPIRES_AT"]);function O(n,t=process.env){let e={};u.config({path:n,processEnv:e});for(let r of E)delete e[r];u.populate(t,e)}var x="CORTEX_CHILD_EXIT";function I(n){return JSON.stringify(n)}function y(n){if(!n)return null;try{let t=JSON.parse(n);if(typeof t.uptimeMs!="number"||typeof t.backoffMs!="number")return null;let e=Number.isInteger(t.code)?t.code:null,r=typeof t.signal=="string"?t.signal.slice(0,20):null;return{code:e,signal:r,uptimeMs:Math.max(0,t.uptimeMs),backoffMs:Math.max(0,Math.round(t.backoffMs))}}catch{return null}}function M(n=process.env){let t=y(n[x]);t&&c({component:"server",kind:"childExit",errorName:"ChildExit",message:t.signal?`signal ${t.signal}`:`exit code ${t.code??"unknown"}`,stack:"",uptimeS:Math.round(t.uptimeMs/1e3),exit:{code:t.code,signal:t.signal,backoffMs:t.backoffMs}})}import{existsSync as b,readFileSync as h}from"node:fs";import*as d from"node:path";var p=d.join(l,"daemon-rebuild.json");function C(n){let t=(n.now??(()=>new Date))().toISOString();return{status:"running",reason:n.reason,current:null,steps:n.names.map(e=>({name:e,status:"pending",detail:null,startedAt:null,endedAt:null})),startedAt:t,updatedAt:t,endedAt:null,detail:null,daemonPid:n.daemonPid}}function f(n,t,e,r){return{...n,updatedAt:r,steps:n.steps.map(o=>o.name===t?{...o,...e}:o)}}function P(n,t,e=()=>new Date){let r=e().toISOString();return{...f(n,t,{status:"running",startedAt:r,endedAt:null},r),current:t}}function w(n,t,e,r=null,o=()=>new Date){let s=o().toISOString(),i=f(n,t,{status:e,detail:r,endedAt:s},s);return i.current!==t?i:{...i,current:i.steps.filter(m=>m.status==="running").at(-1)?.name??null}}function L(n,t,e=null,r=()=>new Date){let o=r().toISOString();return{...n,status:t,current:null,detail:e,updatedAt:o,endedAt:o,steps:n.steps.map(s=>s.status==="pending"?{...s,status:"skipped"}:s)}}function A(n){if(!n||typeof n!="object")return!1;let t=n;return typeof t.status=="string"&&typeof t.reason=="string"&&typeof t.startedAt=="string"&&Array.isArray(t.steps)}function T(n=p){try{if(!b(n))return null;let t=JSON.parse(h(n,"utf8"));return A(t)?t:null}catch{return null}}function F(n,t=p){try{return a(t,JSON.stringify(n,null,2)),!0}catch{return!1}}export{O as a,x as b,I as c,M as d,C as e,P as f,w as g,L as h,T as i,F as j};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import*as o from"node:child_process";import*as r from"node:crypto";import*as m from"node:fs";import*as s from"node:os";import*as t from"node:path";import*as p from"node:stream";import*as a from"node:util";export{o as a,r as b,m as c,s as d,t as e,p as f,a as g};
@@ -0,0 +1,9 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{c as h,e as C}from"./chunk-WHC7AYZD.js";var p=h(r=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.Allow=r.ALL=r.COLLECTION=r.ATOM=r.SPECIAL=r.INF=r._INFINITY=r.INFINITY=r.NAN=r.BOOL=r.NULL=r.OBJ=r.ARR=r.NUM=r.STR=void 0;r.STR=1;r.NUM=2;r.ARR=4;r.OBJ=8;r.NULL=16;r.BOOL=32;r.NAN=64;r.INFINITY=128;r._INFINITY=256;r.INF=r.INFINITY|r._INFINITY;r.SPECIAL=r.NULL|r.BOOL|r.INF|r.NAN;r.ATOM=r.STR|r.NUM|r.SPECIAL;r.COLLECTION=r.ARR|r.OBJ;r.ALL=r.ATOM|r.COLLECTION;r.Allow={STR:r.STR,NUM:r.NUM,ARR:r.ARR,OBJ:r.OBJ,NULL:r.NULL,BOOL:r.BOOL,NAN:r.NAN,INFINITY:r.INFINITY,_INFINITY:r._INFINITY,INF:r.INF,SPECIAL:r.SPECIAL,ATOM:r.ATOM,COLLECTION:r.COLLECTION,ALL:r.ALL};r.default=r.Allow});var y=h(a=>{"use strict";var E=a&&a.__createBinding||(Object.create?(function(t,n,u,e){e===void 0&&(e=u);var i=Object.getOwnPropertyDescriptor(n,u);(!i||("get"in i?!n.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return n[u]}}),Object.defineProperty(t,e,i)}):(function(t,n,u,e){e===void 0&&(e=u),t[e]=n[u]})),R=a&&a.__exportStar||function(t,n){for(var u in t)u!=="default"&&!Object.prototype.hasOwnProperty.call(n,u)&&E(n,t,u)};Object.defineProperty(a,"__esModule",{value:!0});a.Allow=a.MalformedJSON=a.PartialJSON=a.parseJSON=a.parse=void 0;var c=p();Object.defineProperty(a,"Allow",{enumerable:!0,get:function(){return c.Allow}});R(p(),a);var I=class extends Error{};a.PartialJSON=I;var A=class extends Error{};a.MalformedJSON=A;function L(t,n=c.Allow.ALL){if(typeof t!="string")throw new TypeError(`expecting str, got ${typeof t}`);if(!t.trim())throw new Error(`${t} is empty`);return B(t.trim(),n)}a.parseJSON=L;var B=(t,n)=>{let u=t.length,e=0,i=s=>{throw new I(`${s} at position ${e}`)},N=s=>{throw new A(`${s} at position ${e}`)},o=()=>(O(),e>=u&&i("Unexpected end of input"),t[e]==='"'?d():t[e]==="{"?J():t[e]==="["?m():t.substring(e,e+4)==="null"||c.Allow.NULL&n&&u-e<4&&"null".startsWith(t.substring(e))?(e+=4,null):t.substring(e,e+4)==="true"||c.Allow.BOOL&n&&u-e<4&&"true".startsWith(t.substring(e))?(e+=4,!0):t.substring(e,e+5)==="false"||c.Allow.BOOL&n&&u-e<5&&"false".startsWith(t.substring(e))?(e+=5,!1):t.substring(e,e+8)==="Infinity"||c.Allow.INFINITY&n&&u-e<8&&"Infinity".startsWith(t.substring(e))?(e+=8,1/0):t.substring(e,e+9)==="-Infinity"||c.Allow._INFINITY&n&&1<u-e&&u-e<9&&"-Infinity".startsWith(t.substring(e))?(e+=9,-1/0):t.substring(e,e+3)==="NaN"||c.Allow.NAN&n&&u-e<3&&"NaN".startsWith(t.substring(e))?(e+=3,NaN):_()),d=()=>{let s=e,f=!1;for(e++;e<u&&(t[e]!=='"'||f&&t[e-1]==="\\");)f=t[e]==="\\"?!f:!1,e++;if(t.charAt(e)=='"')try{return JSON.parse(t.substring(s,++e-Number(f)))}catch(l){N(String(l))}else if(c.Allow.STR&n)try{return JSON.parse(t.substring(s,e-Number(f))+'"')}catch{return JSON.parse(t.substring(s,t.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},J=()=>{e++,O();let s={};try{for(;t[e]!=="}";){if(O(),e>=u&&c.Allow.OBJ&n)return s;let f=d();O(),e++;try{let l=o();s[f]=l}catch(l){if(c.Allow.OBJ&n)return s;throw l}O(),t[e]===","&&e++}}catch{if(c.Allow.OBJ&n)return s;i("Expected '}' at end of object")}return e++,s},m=()=>{e++;let s=[];try{for(;t[e]!=="]";)s.push(o()),O(),t[e]===","&&e++}catch{if(c.Allow.ARR&n)return s;i("Expected ']' at end of array")}return e++,s},_=()=>{if(e===0){t==="-"&&N("Not sure what '-' is");try{return JSON.parse(t)}catch(f){if(c.Allow.NUM&n)try{return JSON.parse(t.substring(0,t.lastIndexOf("e")))}catch{}N(String(f))}}let s=e;for(t[e]==="-"&&e++;t[e]&&",]}".indexOf(t[e])===-1;)e++;e==u&&!(c.Allow.NUM&n)&&i("Unterminated number literal");try{return JSON.parse(t.substring(s,e))}catch{t.substring(s,e)==="-"&&i("Not sure what '-' is");try{return JSON.parse(t.substring(s,t.lastIndexOf("e")))}catch(l){N(String(l))}}},O=()=>{for(;e<u&&`
5
+ \r `.includes(t[e]);)e++};return o()},F=L;a.parse=F});var b=C(y(),1),P=new Set(['"',"\\","/","b","f","n","r","t"]);function M(t){let n=t.codePointAt(0);return n!==void 0&&n>=0&&n<=31}function x(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
6
+ `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${t.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function w(t){let n="",u=!1;for(let e=0;e<t.length;e++){let i=t[e];if(!u){n+=i,i==='"'&&(u=!0);continue}if(i==='"'){n+=i,u=!1;continue}if(i==="\\"){let N=t[e+1];if(N===void 0){n+="\\\\";continue}if(N==="u"){let o=t.slice(e+2,e+6);if(/^[0-9a-fA-F]{4}$/.test(o)){n+=`\\u${o}`,e+=5;continue}}if(P.has(N)){n+=`\\${N}`,e+=1;continue}n+="\\\\";continue}n+=M(i)?x(i):i}return n}function T(t){try{return JSON.parse(t)}catch(n){let u=w(t);if(u!==t)return JSON.parse(u);throw n}}function $(t){if(!t?.trim())return{arguments:{}};try{let n=T(t);if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("Tool arguments must be a JSON object");return{arguments:n}}catch(n){return{arguments:{},argumentsError:`${n instanceof Error?n.message:String(n)}
7
+
8
+ Received arguments:
9
+ ${t}`}}}function v(t){if(!t||t.trim()==="")return{};try{return T(t)}catch{try{return(0,b.parse)(t)??{}}catch{try{return(0,b.parse)(w(t))??{}}catch{return{}}}}}export{w as a,T as b,$ as c,v as d};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{statSync as h,watch as s}from"node:fs";import c from"node:path";var o=5e3;function i(e){if(!(e instanceof Error))return String(e);let r=e.code;return r?`${r}: ${e.message}`:e.message}function f(e){for(let r of e.splice(0))try{r.close()}catch{}}function u(e,r){try{e.poll?.()}catch(t){r(`${e.label} polling failed (${i(t)})`)}}function m(e,r,t){e.pollTimer=setInterval(()=>u(r,t),o),e.pollTimer.unref?.()}function w(e,r,t,n){if(e.failed||e.closed)return;e.failed=!0,f(e.watchers);let l=i(n);if(!r.poll)return t(`${r.label} watcher failed (${l}); watcher disabled`);t(`${r.label} watcher failed (${l}); polling every ${o}ms`),m(e,r,t)}function d(e){e.closed=!0,f(e.watchers),e.pollTimer&&clearInterval(e.pollTimer),e.pollTimer=null}function g(e){let r={watchers:[],pollTimer:null,failed:!1,closed:!1},t=e.warn??console.warn,n=l=>w(r,e,t,l);try{r.watchers=e.startWatching();for(let l of r.watchers)l.on("error",n)}catch(l){n(l)}return{close:()=>d(r)}}function $(e){let r=e.snapshot(),t=()=>{let l=e.snapshot();l!==r&&(r=l,e.onChange())},n=g({label:e.label,startWatching:()=>e.startWatching(t),poll:t,warn:e.warn});return t(),n}function W(e){try{let r=h(e);return`${r.size}:${r.mtimeMs}:${r.ctimeMs}:${r.ino}`}catch{return null}}function S(e){let r=c.basename(e.filePath);return $({label:e.label,snapshot:()=>W(e.filePath),onChange:e.onChange,warn:e.warn,startWatching:t=>{let n=s(c.dirname(e.filePath),(l,a)=>{(a===null||a.toString()===r)&&t()});return e.unref&&n.unref(),[n]}})}export{g as a,$ as b,S as c};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{e as T}from"./chunk-NAA7GF6Q.js";import{l as m}from"./chunk-J5DVLUKY.js";import*as f from"crypto";import{readFileSync as g,appendFileSync as E,mkdirSync as d}from"fs";import*as a from"path";var v=T("auth"),y="x-cortex-token",c="CORTEX_CLIENT_TOKEN",u="CORTEX_WEBHOOK_TOKEN",s=null;function S(t,n){let o=Buffer.from(t||""),e=Buffer.from(n||"");return o.length===0||e.length!==o.length?!1:f.timingSafeEqual(o,e)}function B(){return s?.clientToken??(process.env[c]||"").trim()}function w(){return s?.webhookToken??(process.env[u]||"").trim()}function A(t={}){let n=t.env??process.env,o=n[c]?.trim(),e=n[u]?.trim();if(!o||!e)throw new Error("cannot capture missing auth tokens");let r=s;return s={clientToken:o,webhookToken:e},t.scrubEnv&&(delete n[c],delete n[u]),()=>{s=r}}function x(){return f.randomBytes(32).toString("hex")}function O(t,n,o){let e="";try{e=g(t,"utf-8")}catch{}let r=["","# Auth tokens (auto-generated) \u2014 WS client + webhook bearer"];for(let i of n)r.push(`${i}=${o[i]}`);r.push("");let p=(e.length>0&&!e.endsWith(`
5
+ `)?`
6
+ `:"")+r.join(`
7
+ `);d(a.dirname(t),{recursive:!0}),E(t,p)}function C(t={}){let n=t.env??process.env,o=t.envPath??a.join(m,".env"),e=[],r=i=>{let h=n[i]?.trim();if(h)return h;let k=x();return n[i]=k,e.push(i),k},l=r(c),p=r(u);return e.length>0&&(O(o,e,n),v.info(`Generated auth token(s): ${e.join(", ")} \u2192 ${o}`)),{clientToken:l,webhookToken:p,generated:e}}export{y as a,c as b,u as c,S as d,B as e,w as f,A as g,C as h};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{k as l}from"./chunk-CQLH4UVX.js";import{a as d,h as p}from"./chunk-OE4KH3NJ.js";import*as E from"node:http";function O(e,o,t,n={},s=183e4){let a=t===void 0?null:JSON.stringify(t),T=new URL(o);return new Promise((_,h)=>{let i=E.request(b(e,T,a,n,s),c=>{let u=[];c.on("data",f=>u.push(Buffer.from(f))),c.on("end",()=>_({status:c.statusCode??0,body:k(Buffer.concat(u).toString("utf8"))}))});i.on("error",h),i.on("timeout",()=>i.destroy(new Error(`Loopback request timed out after ${s}ms`))),a!==null&&i.write(a),i.end()})}function b(e,o,t,n,s){return{hostname:o.hostname,port:o.port,path:`${o.pathname}${o.search}`,method:e,headers:t===null?n:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(t),...n},timeout:s}}function k(e){if(!e)return null;try{return JSON.parse(e)}catch{return{_raw:e}}}var m=3001;function r(e){return e===void 0||e===""?null:e}function S(e,o){let t=parseInt(e??"",10);return Number.isFinite(t)&&t>0?t:o}function R(e){let o=e.CORTEX_BACKEND,t=r(e.CORTEX_MODEL);return o!=="claude"&&o!=="pi"||!t?null:{backend:o,model:t,provider:o==="pi"?r(e.CORTEX_PROVIDER):null,thinking:r(e.CORTEX_THINKING),mode:e.CORTEX_MODE??""}}function U(e=process.env){return{channel:r(e.SLACK_CHANNEL)??r(e.FEISHU_CHANNEL),sessionId:r(e.CORTEX_SESSION_ID),selection:R(e),project:r(e.CORTEX_PROJECT),backend:r(e.CORTEX_BACKEND),claudeModel:r(e.CORTEX_CLAUDE_MODEL),subagentPiModels:l(e.CORTEX_SUBAGENT_PI_MODELS),subagentClaudeModels:l(e.CORTEX_SUBAGENT_CLAUDE_MODELS),scheduleTaskId:r(e.CORTEX_SCHEDULE_TASK_ID),callbackSource:r(e.CORTEX_CALLBACK_SOURCE),webhookBaseUrl:`http://127.0.0.1:${S(e.WEBHOOK_PORT,m)}`,webhookToken:e.CORTEX_WEBHOOK_TOKEN||"",slackBotToken:r(e.SLACK_BOT_TOKEN),toolAllowlist:p(e[d])}}function L(e){return{"x-cortex-token":e.webhookToken}}function I(e){return e.sessionId?e.sessionId:e.channel?.startsWith("web:")?e.channel.slice(4):null}var w=async(e,o)=>{let{body:t}=await O("POST",`${e.webhookBaseUrl}/webhook/board`,{sessionId:o,action:"status"},L(e));if(!t?.success)throw new Error(t?.error||"board status failed");let n=t.data;return n?{id:n.id,title:n.title,dir:n.dir??null}:null};async function A(e,o=w){let t={channel:e.channel,sessionId:e.sessionId,model:e.selection?.model??null,thinking:e.selection?.thinking??null,mode:e.selection?.mode??null,project:e.project,backend:e.backend,scheduleTaskId:e.scheduleTaskId,callbackSource:e.callbackSource},n=I(e);if(n)try{t.board=await o(e,n)}catch{}return t}function X(e,o){e.tool("cortex_context","Get current session identity, backend, model, thinking, mode, project, bound board and trigger context.",{},{readOnlyHint:!0},async()=>{try{let t=await A(o),{channel:n,...s}=t;return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}catch(t){return{content:[{type:"text",text:`Failed to resolve context: ${t.message}`}],isError:!0}}})}export{O as a,m as b,U as c,L as d,I as e,A as f,X as g};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ function l(f,b){let t=p=>{let r=p.split("."),x=Number(r[0]),y=Number(r[1]),c=r[2]?.split("-")??["0"],d=Number(c[0]),N=Number(c[1]??"0");return[x,y,d,N]},[n,s,e,i]=t(f),[o,u,a,m]=t(b);return n!==o?n-o:s!==u?s-u:e!==a?e-a:i-m}export{l as a};
@@ -0,0 +1,8 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{closeSync as _,mkdirSync as S,openSync as w,readdirSync as x,readFileSync as E,renameSync as g,rmSync as l,statSync as f,writeFileSync as A}from"node:fs";import{dirname as h,join as a}from"node:path";import{fileURLToPath as T}from"node:url";var M=/^[A-Za-z0-9._-]+$/,R=10080*60*1e3,C=9500,L=250,$=5e3,I=new Int32Array(new SharedArrayBuffer(4));function V(t){return a(t,"tmp","cortexmd-cache")}function O(t){return typeof t=="string"&&M.test(t)}function Y(t,e){return`${String(t).trim().toLowerCase()}:${e}`}function Z(t,e=R){let n;try{n=x(t)}catch{return}let r=Date.now();for(let c of n){let o=a(t,c);try{let s=f(o);s.isFile()&&r-s.mtimeMs>e&&l(o,{force:!0})}catch{}}}function b(t){try{return JSON.parse(E(t,"utf8"))}catch{return null}}function v(t,e){try{S(h(t),{recursive:!0});let n=`${t}.${process.pid}.tmp`;A(n,JSON.stringify(e),"utf8"),g(n,t)}catch{}}function F(t){let e=new Map,n=b(t);if(!n||typeof n!="object"||Array.isArray(n))return e;for(let[r,c]of Object.entries(n))typeof c=="number"&&e.set(r,c);return e}function k(t){try{Date.now()-f(t).mtimeMs>$&&l(t,{force:!0})}catch{}}function N(t){let e=Date.now()+L;do try{return S(h(t),{recursive:!0}),w(t,"wx")}catch(n){if(n?.code!=="EEXIST")return null;k(t),Atomics.wait(I,0,0,5)}while(Date.now()<=e);return null}function W(t,e){try{_(e)}catch{}try{l(t,{force:!0})}catch{}}function Q(t,e,n,r=new Map){if(!O(e))return n(r).value;let c=a(t,`${e}.json`),o=`${c}.lock`,s=N(o);try{let i=F(c),u=n(i);return s!==null&&u.changed&&v(c,Object.fromEntries(i)),u.value}finally{s!==null&&W(o,s)}}function tt(t,e,n=C){let r=[],c=[],o=[],s=0;for(let i of t){let u=e(i);if(o.length>0||s+u.length>n){o.push(i);continue}r.push(i),c.push(u),s+=u.length}return{included:r,blocks:c,truncated:o}}function et(t){return`<system-reminder>
5
+ \u26A0\uFE0F ${t.length} AGENTS rule file(s) were too large to inline here. Read EACH of the following files now to load their rules before proceeding:
6
+ ${t.map(e=>`- ${e}`).join(`
7
+ `)}
8
+ </system-reminder>`}var j=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,D=/^paths:[ \t]*(.*)$/,K=/^\s+-\s+(.*?)\s*$/,B=/"((?:[^"\\]|\\.)*)"|'([^']*)'|([^,\s][^,]*)/g;function y(t){let e=t.trim();return e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))?e.slice(1,-1):e}function H(t){let e=[];for(let n of t.matchAll(B)){let r=n[1]??n[2]??n[3].trim();r&&e.push(r)}return e}function J(t){let e=j.exec(t);if(!e)return{paths:[],body:t};let n=t.slice(e[0].length),r=e[1].split(/\r?\n/),c=[];for(let o=0;o<r.length;o++){let s=D.exec(r[o]);if(!s)continue;let i=s[1].replace(/\s+#.*$/,"").trim();if(i.startsWith("[")&&i.endsWith("]"))c.push(...H(i.slice(1,-1)));else if(i)c.push(y(i));else for(o+=1;o<r.length;o++){let u=r[o];if(!u.trim()||/^\s+#/.test(u))continue;let p=K.exec(u);if(!p)break;let m=y(p[1]);m&&c.push(m)}break}return{paths:c,body:n}}function d(t){try{return x(t).filter(e=>e.endsWith(".md"))}catch{return[]}}function U(t,e){try{if(!f(e).isFile())return null;let{paths:n,body:r}=J(E(e,"utf8"));return{file:t,path:e,paths:n,body:r}}catch{return null}}var X=a(h(T(import.meta.url)),"..","rules");function q(){return process.env.CORTEX_CONFIG_IMMUTABLE==="1"?null:X}function nt(t,e=q()){let n=new Map;if(e)for(let r of d(e))n.set(r,a(e,r));for(let r of d(t))n.set(r,a(t,r));return[...n.keys()].sort().map(r=>U(r,n.get(r))).filter(r=>r!==null)}export{V as a,Y as b,Z as c,Q as d,tt as e,et as f,q as g,nt as h};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ function a(t){return(t.split("__").at(-1)?.split(".").at(-1)??t)==="board_open"}var o="Created",r="Attached to";function c(t){return`${t.created?o:r} board "${t.title}" (${t.id}).`}var n=new RegExp(`^(${o}|${r}) board "([\\s\\S]*)" \\(([^\\s()]+)\\)\\.\\nBoard directory: `);function d(t){let e=n.exec(t);return e?{op:"open",boardId:e[3],title:e[2],created:e[1]===o}:null}export{a,c as b,d as c};
@@ -0,0 +1,52 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{d as He,e as Ke,f as Ve,g as Je,h as g,i as Be,l as We,w as Ye}from"./chunk-2ZNLUY2U.js";import{a as qe,b as Xe,c as ze,d as Qe,e as Ze,f as et,i as I,j as U}from"./chunk-PZMXHA6X.js";import{a as pe,b as fe,d as me}from"./chunk-REBNWCKI.js";import{a as De,b as _e,c as Re,d as je,e as Te,f as Oe,i as Ne,j as Fe,k as Le,l as Me,m as Ge}from"./chunk-MFAEUHMV.js";import{A as Ee,C as _,w as Ae,x as Pe,z as b}from"./chunk-ASYQHJVQ.js";import{G as $e,f as ye}from"./chunk-O3JW2F7D.js";import{F as ke,G as Se,m as ve,o as Ce,p as we,q as be}from"./chunk-TZFLHVOQ.js";import{a as Ie}from"./chunk-5NRGVROY.js";import{a as P}from"./chunk-YHIWOGVL.js";import{a as ge}from"./chunk-QEOFEETJ.js";import{b as ue,c as ce,h as de}from"./chunk-SUFW24P4.js";import{a as R,b as f,c as Ue}from"./chunk-PMG4YGDU.js";import{a as w,b as xe,c as A,e as G}from"./chunk-KENCMLRE.js";import{a as M}from"./chunk-PFMEUFJ7.js";import{d as ne}from"./chunk-W5LGYSPZ.js";import{e as l}from"./chunk-E7ZMYIY6.js";import{e as le}from"./chunk-NAA7GF6Q.js";import{b as he,h as E}from"./chunk-QWAQHHRS.js";import{a as Ot,c as re,f as C,j as D,k as ie,l as oe,m as se,p as h,q as L,r as ae}from"./chunk-J5DVLUKY.js";import{e as Tt}from"./chunk-WHC7AYZD.js";import{fork as T}from"child_process";import*as d from"path";import*as Rt from"net";import{fileURLToPath as Un}from"url";import{existsSync as m,readdirSync as Hn,readFileSync as Q,unlinkSync as Z}from"fs";var rt=Tt(Ot(),1);import*as c from"node:fs";import*as u from"node:path";import*as nt from"node:http";import{fileURLToPath as Nt}from"node:url";function Ft(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||t==="null"||t==="undefined"))return t}function Lt(e){let t=e.match(/^v?(\d+)/);return t?Number(t[1]):0}function Mt(e){let t=u.join(e.paths.CONFIG_DIR,".env"),n={},r=e.readText(t);if(r!=null)try{n=e.parseDotenv(r)}catch{n={}}return i=>Ft(e.env[i]??n[i])}function Gt(e){let t=e.defaultSelection()?.backend??"claude";return t==="pi"?{id:"backend-runtime",label:"Backend runtime",status:"pass",detail:"backend: pi runs in-process from the bundled SDK (no CLI needed)"}:e.commandExists("claude")?{id:"backend-runtime",label:"Backend runtime",status:"pass",detail:`claude found on PATH (backend: ${t})`}:{id:"backend-runtime",label:"Backend runtime",status:"warn",detail:`claude not on PATH (backend: ${t})`,hint:"Install/login the claude CLI"}}function Ut(e){return e.commandExists("git")?{id:"git",label:"git",status:"pass",detail:"usable on PATH"}:(e.platform??process.platform)==="win32"?{id:"git",label:"git",status:"fail",detail:"unavailable",hint:"Install Git for Windows \u2014 shell tools require Git Bash"}:{id:"git",label:"git",status:"warn",detail:"unavailable (optional)",hint:"Install Git to enable version history and Git-sourced extensions"}}function Ht(e){let t=[],n=Lt(e.nodeVersion);t.push(n>=e.requiredNodeMajor?{id:"node-version",label:"Node version",status:"pass",detail:`${e.nodeVersion} (>=${e.requiredNodeMajor})`}:{id:"node-version",label:"Node version",status:"warn",detail:`${e.nodeVersion} \u2014 Cortex requires Node >=${e.requiredNodeMajor}`,hint:"Upgrade Node.js"}),t.push(Ut(e)),t.push(Gt(e));let r=u.join(e.paths.STORE_DIR,u.basename(h)),i=e.fileExists(r)?e.readText(r):null,o=i?Number(i.trim()):NaN;return Number.isFinite(o)&&e.pidAlive(o)?t.push({id:"daemon",label:"Daemon",status:"pass",detail:`running (pid ${o})`}):t.push({id:"daemon",label:"Daemon",status:"skip",detail:"not running",hint:"Start with `cortex daemon`"}),{title:"Runtime & Process",checks:t}}function Kt(e,t){let n=[];for(let[r,i]of Object.entries(t.paths))t.fileExists(i)?t.isWritable(i)||n.push(`${r} not writable (${i})`):n.push(`${r} missing (${i})`);e.push(n.length===0?{id:"dirs",label:"Data directories",status:"pass",detail:"present and writable"}:{id:"dirs",label:"Data directories",status:"fail",detail:n.join("; "),hint:"run `cortex doctor --fix` or `cortex init`",fixable:!0})}function Vt(e,t,n){let r=u.join(t.paths.CONFIG_DIR,".env");e.push(t.fileExists(r)?{id:"env-file",label:".env file",status:"pass",detail:r}:{id:"env-file",label:".env file",status:"fail",detail:`missing (${r})`,hint:"run `cortex init`"});let i=[ue,ce].filter(o=>!n(o));e.push(i.length===0?{id:"auth-tokens",label:"Auth tokens",status:"pass",detail:"client + webhook tokens set"}:{id:"auth-tokens",label:"Auth tokens",status:"fail",detail:`missing: ${i.join(", ")}`,hint:"run `cortex doctor --fix` to generate",fixable:!0})}function Jt(e){let t=e.defaultSelection();return t?.backend==="claude"&&(t.mode||"api")!=="plan"}function Bt(e,t,n){let r=t("ANTHROPIC_API_KEY");return n&&(!r||r===E)&&Jt(e)}function Wt(e,t,n){let r=t("ANTHROPIC_API_KEY");if(n)e.push({id:"anthropic-key",label:"Anthropic API key",status:"pass",detail:"managed by healthy gateway"});else if(r){let i=r===E?"managed by gateway":"set";e.push({id:"anthropic-key",label:"Anthropic API key",status:"pass",detail:i})}else e.push({id:"anthropic-key",label:"Anthropic API key",status:"warn",detail:"not set \u2014 required for API mode (plan/subscription mode can ignore)",hint:"set ANTHROPIC_API_KEY in .env or run `cortex init`"})}function Yt(e,t){let{CONFIG_DIR:n,STORE_DIR:r}=t.paths,i=u.join(r,"agent-state.json"),o=t.fileExists(i)?"agent-state.json":"mode.json";tn(e,t,t.fileExists(i)?i:u.join(r,"mode.json"),"mode-json",o,"warn"),e.push(nn(t,u.join(n,"models.json")));let s=u.join(n,"mcp-config.json");t.fileExists(s)?it(t.readText(s))?e.push({id:"mcp-config",label:"mcp-config.json",status:"pass",detail:"valid"}):e.push({id:"mcp-config",label:"mcp-config.json",status:"warn",detail:"invalid JSON",hint:"run `cortex doctor --fix` to regenerate",fixable:!0}):e.push({id:"mcp-config",label:"mcp-config.json",status:"warn",detail:`missing (${s})`,hint:"run `cortex doctor --fix` to regenerate",fixable:!0})}var H="See docs/backends.md#remote-login",qt=new Set(["expired","logged-out"]),Xt="Reinstall the Cortex server package \u2014 the PI SDK ships with it";async function zt(e){let t=e.resolvePiSdk();if(!t)return{id:"pi-runtime",label:"PI runtime",status:"warn",detail:`bundled PI SDK not resolvable (${b})`,hint:Xt};try{let n=await e.loadPiRuntime();if(n.available&&typeof n.runtime.login=="function"){let r=n.version??t.version,i=r?` ${r}`:"";return{id:"pi-runtime",label:"PI runtime",status:"pass",detail:`in-process SDK ${t.package}${i}; login export found`}}}catch{}return{id:"pi-runtime",label:"PI runtime",status:"warn",detail:"bundled PI runtime or login export unavailable",hint:H}}function tt(e,t){return t&&e.backend==="claude"&&e.provider==="anthropic"&&e.state==="logged-out"}function Qt(e,t){let n=e.accounts.filter(a=>a.inUse),r=n.filter(a=>tt(a,t)),i=n.filter(a=>qt.has(a.state)&&!tt(a,t)),o=[...new Set(i.map(a=>a.provider))].sort();if(i.length>0)return{id:"backend-auth",label:"Backend authentication",status:"warn",detail:`${n.length} in use; ${i.length} expired or logged out: ${o.join(", ")}`,hint:H};let s=r.length>0?"; gateway-backed: anthropic":"";return{id:"backend-auth",label:"Backend authentication",status:"pass",detail:`${n.length} in use; 0 expired or logged out${s}`}}async function Zt(e,t){try{return Qt(await e.getAuthStatus(),t)}catch{return{id:"backend-auth",label:"Backend authentication",status:"warn",detail:"authentication summary unavailable",hint:H}}}async function en(e,t,n){let r=[],i=Bt(e,t,n);return Kt(r,e),Vt(r,e,t),Wt(r,t,i),Yt(r,e),r.push(...await Promise.all([zt(e),Zt(e,i)])),{title:"Backend Install / Login",checks:r}}function it(e){if(e==null)return!1;try{return JSON.parse(e),!0}catch{return!1}}function tn(e,t,n,r,i,o){if(!t.fileExists(n)){e.push({id:r,label:i,status:o,detail:`missing (${n})`});return}e.push(it(t.readText(n))?{id:r,label:i,status:"pass",detail:"valid"}:{id:r,label:i,status:o,detail:"invalid JSON"})}function nn(e,t){let n={id:"models",label:"models.json"};if(!e.fileExists(t))return{...n,status:"warn",detail:`missing (${t})`,hint:"run `cortex setup-gateway`"};try{let r=JSON.parse(e.readText(t)??"");if(Se(r?.default),!Array.isArray(r?.favorites))throw new Error("missing `favorites` array");return r.favorites.forEach(ke),{...n,status:"pass",detail:`default: ${r.default.model}; favorites: ${r.favorites.length}`}}catch(r){return{...n,status:"fail",detail:r.message,hint:"re-run `cortex setup-gateway`"}}}function rn(e,t){let n=[],i=(t("CORTEX_PLATFORM")??"slack").split(",").map(o=>o.trim().toLowerCase()).filter(Boolean);n.push({id:"platform",label:"Platform",status:"pass",detail:`configured: ${i.join(", ")||"(none)"}`});for(let o of i)if(o==="slack"){let s=[],a=t("SLACK_BOT_TOKEN"),p=t("SLACK_SIGNING_SECRET"),F=t("SLACK_APP_TOKEN");a?a.startsWith("xoxb-")||s.push("SLACK_BOT_TOKEN should start with xoxb-"):s.push("SLACK_BOT_TOKEN missing"),p||s.push("SLACK_SIGNING_SECRET missing"),F?F.startsWith("xapp-")||s.push("SLACK_APP_TOKEN should start with xapp-"):s.push("SLACK_APP_TOKEN missing"),n.push(s.length===0?{id:"slack-creds",label:"Slack credentials",status:"pass",detail:"bot / signing / app tokens present"}:{id:"slack-creds",label:"Slack credentials",status:"fail",detail:s.join("; "),hint:"set Slack tokens in .env (see `cortex init`)"})}else if(o==="feishu"){let s=[];t("FEISHU_APP_ID")||s.push("FEISHU_APP_ID missing"),t("FEISHU_APP_SECRET")||s.push("FEISHU_APP_SECRET missing"),n.push(s.length===0?{id:"feishu-creds",label:"Feishu credentials",status:"pass",detail:"app id / secret present"}:{id:"feishu-creds",label:"Feishu credentials",status:"fail",detail:s.join("; "),hint:"set FEISHU_APP_ID / FEISHU_APP_SECRET in .env"})}else o==="test"?n.push({id:"test-platform",label:"Test platform",status:"skip",detail:"mock adapter (test only)"}):n.push({id:`platform-${o}`,label:`Platform: ${o}`,status:"warn",detail:"unknown platform name"});return{title:"Messaging Platform",checks:n}}function on(e,t,n){let r=[],i=u.join(e.aistatusDir,"gateway.yaml"),o=e.fileExists(i),s=new URL(e.gatewayUrl??D.url).host,a=D.home?i:"~/.aistatus/gateway.yaml";r.push(o?{id:"gateway-config",label:"Gateway config",status:"pass",detail:i}:{id:"gateway-config",label:"Gateway config",status:"skip",detail:`not configured (no ${a})`,hint:"run `cortex setup-gateway` if you use the gateway"});let p=t("ANTHROPIC_API_KEY")===E||o;return n?r.push({id:"gateway-health",label:"Gateway health",status:"pass",detail:`responding at ${s}`}):p?r.push({id:"gateway-health",label:"Gateway health",status:"fail",detail:`no response at ${s}/status`,hint:"check gateway.log or restart Cortex (the server auto-starts the gateway)"}):r.push({id:"gateway-health",label:"Gateway health",status:"skip",detail:"not running (not required for current backend)"}),{title:"Gateway",checks:r}}async function K(e){let t=Mt(e),n=await e.probeGateway(),r=[Ht(e),await en(e,t,n),rn(e,t),on(e,t,n)],i={pass:0,warn:0,fail:0,skip:0};for(let o of r)for(let s of o.checks)i[s.status]++;return{sections:r,counts:i,ok:i.fail===0}}async function ot(e,t,n){let r=new Map;for(let s of e.sections)for(let a of s.checks)a.fixable&&(a.status==="fail"||a.status==="warn")&&r.set(a.id,a);let i=[],o=u.join(t.paths.CONFIG_DIR,".env");if(r.has("dirs")){for(let s of[t.paths.DATA_DIR,t.paths.CONFIG_DIR,t.paths.STORE_DIR])n.mkdirp(s);i.push({id:"dirs",label:"Data directories",applied:!0,detail:"created missing directories"})}if(r.has("auth-tokens")){n.ensureEnvFile(o);let s=n.ensureAuthTokens(o);i.push({id:"auth-tokens",label:"Auth tokens",applied:s.length>0,detail:s.length>0?`generated: ${s.join(", ")}`:"already present"})}return r.has("mcp-config")&&(n.regenerateMcpConfig(),i.push({id:"mcp-config",label:"mcp-config.json",applied:!0,detail:"regenerated"})),i}function sn(e){if(e==="git")return ge();let t=process.env.PATH||"",n=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];for(let r of t.split(u.delimiter))if(r)for(let i of n){let o=u.join(r,e+i);try{if(c.existsSync(o))return!0}catch{}}return!1}function an(){let e;try{e=u.dirname(Nt(import.meta.resolve(b)))}catch{return null}for(;;){try{let n=JSON.parse(c.readFileSync(u.join(e,"package.json"),"utf8"));if(n?.name===b)return{package:b,version:typeof n.version=="string"?n.version:null}}catch{}let t=u.dirname(e);if(t===e)return{package:b,version:null};e=t}}function ln(){return new Promise(e=>{let t=nt.get(`${D.url}/status`,{timeout:5e3},n=>{n.resume(),e(n.statusCode===200)});t.on("error",()=>e(!1)),t.on("timeout",()=>{t.destroy(),e(!1)})})}function st(){return{env:process.env,paths:{DATA_DIR:C,CONFIG_DIR:oe,STORE_DIR:se},aistatusDir:ie,gatewayUrl:D.url,nodeVersion:process.version,requiredNodeMajor:20,fileExists:e=>{try{return c.existsSync(e)}catch{return!1}},isWritable:e=>{try{return c.accessSync(e,c.constants.W_OK),!0}catch{return!1}},readText:e=>{try{return c.readFileSync(e,"utf8")}catch{return null}},parseDotenv:e=>(0,rt.parse)(e),commandExists:sn,pidAlive:w,probeGateway:ln,resolvePiSdk:an,loadPiRuntime:()=>Ee(),getAuthStatus:()=>_(),defaultSelection:un}}function un(){try{return $e()}catch{return null}}function at(){return{mkdirp:e=>{c.mkdirSync(e,{recursive:!0})},ensureEnvFile:e=>{c.existsSync(e)||(c.mkdirSync(u.dirname(e),{recursive:!0}),c.writeFileSync(e,""))},ensureAuthTokens:e=>de({envPath:e}).generated,regenerateMcpConfig:()=>ye()}}function cn(){return R({name:"cortex doctor",description:"Health-check the Cortex installation \u2014 runtime, backend/login, messaging platform, gateway.",usage:"cortex doctor [options]",options:[{flag:"--fix",description:"Apply safe, idempotent repairs (generate missing tokens, create dirs, rebuild mcp-config)"},{flag:"--json",description:"Emit the report as JSON"},{flag:"--help, -h",description:"Show this help"}],examples:[{description:"Run a read-only diagnosis",command:"cortex doctor"},{description:"Diagnose and auto-repair fixable issues",command:"cortex doctor --fix"},{description:"Machine-readable output",command:"cortex doctor --json"}]})}var dn={pass:"[OK] ",warn:"[WARN]",fail:"[FAIL]",skip:"[--] "};function pn(e,t){let n=["Cortex Doctor",""];for(let s of e.sections){n.push(s.title);for(let a of s.checks)n.push(` ${dn[a.status]} ${a.label} \u2014 ${a.detail}`),a.hint&&(a.status==="fail"||a.status==="warn")&&n.push(` \u21B3 ${a.hint}`);n.push("")}if(t.length>0){n.push("Fixes applied:");for(let s of t)n.push(` ${s.applied?"[OK] ":"[--] "} ${s.label} \u2014 ${s.detail}`);n.push("")}let{pass:r,warn:i,fail:o}=e.counts;return n.push(`Summary: ${r} passed, ${i} warning${i===1?"":"s"}, ${o} failed`),(o>0||i>0)&&e.sections.some(a=>a.checks.some(p=>p.fixable&&(p.status==="fail"||p.status==="warn")))&&n.push("Run `cortex doctor --fix` to auto-repair fixable issues."),n.join(`
5
+ `).trimEnd()+`
6
+ `}async function lt(e,t){if(e.includes("--help")||e.includes("-h"))return{exitCode:0,stdout:cn(),stderr:""};let n=e.includes("--json"),r=e.includes("--fix"),i=t?.diag??st(),o=t?.fix??at(),s=await K(i),a=[];r&&(a=await ot(s,i,o),s=await K(i));let p=n?JSON.stringify({...s,fixes:r?a:void 0},null,2)+`
7
+ `:pn(s,a);return{exitCode:s.ok?0:1,stdout:p,stderr:""}}var ut=["list","add","remove"];function fn(){return{validValues:l("provider.cli.validValues"),hint:l("provider.cli.hint")}}function x(e,t){return{exitCode:1,stdout:"",stderr:f(e,{...t,labels:fn()})}}function ct(){return R({name:"cortex auth provider",description:l("provider.cli.description"),usage:"cortex auth provider <list|add|remove> [options]",commands:[{name:"list",description:l("provider.cli.listDescription")},{name:"add",description:l("provider.cli.addDescription")},{name:"remove",description:l("provider.cli.removeDescription")}],options:[{flag:"--name <name>",description:l("provider.cli.nameDescription")},{flag:"--api <api>",description:`${l("provider.cli.apiDescription")} (${P.join(" | ")})`},{flag:"--url <url>",description:l("provider.cli.urlDescription")},{flag:"--key <key|->",description:l("provider.cli.keyDescription")},{flag:"--model <id>",description:l("provider.cli.modelDescription")},{flag:"--dry-run",description:l("provider.cli.dryRunDescription")},{flag:"--json",description:l("provider.cli.jsonDescription")},{flag:"--help, -h",description:l("provider.cli.helpDescription")}],examples:[{description:l("provider.cli.exampleAdd"),command:"cortex auth provider add --name my-vllm --api anthropic-messages --url http://127.0.0.1:8100 --model Model-27B"},{description:l("provider.cli.exampleAddPiped"),command:"pass show my-endpoint | cortex auth provider add --name my-proxy --api openai-completions --url https://proxy.example.com/v1 --model small --key -"},{description:l("provider.cli.exampleList"),command:"cortex auth provider list --json"},{description:l("provider.cli.exampleRemove"),command:"cortex auth provider remove --name my-vllm --dry-run"}],labels:{usage:l("cmd.auth.cli.helpUsage"),commands:l("cmd.auth.cli.helpCommands"),options:l("cmd.auth.cli.helpOptions"),examples:l("cmd.auth.cli.helpExamples")}})}var mn=new Set(["--name","--api","--url","--key"]);function hn(e){let t=new Map,n=[],r=!1,i=!1;for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--json"){r=!0;continue}if(s==="--dry-run"){i=!0;continue}if(s==="--model"||mn.has(s)){let a=e[o+1];if(a===void 0||a.startsWith("--"))return x(l("provider.cli.flagNeedsValue",{flag:s}),{hint:"cortex auth provider --help"});o+=1,s==="--model"?n.push(a):t.set(s,a);continue}return x(l("provider.cli.unknownFlag",{flag:s}),{validValues:["--name","--api","--url","--key","--model","--dry-run","--json"],hint:"cortex auth provider --help"})}return{values:t,models:n,json:r,dryRun:i}}function V(e){return l(`provider.issue.${e}`)}function gn(e){return e.routed?l("provider.cli.listItem",{name:e.name,api:e.api,upstream:e.upstreamUrl??""}):l("provider.cli.listItemUnrouted",{name:e.name,api:e.api})}function xn(e,t){let n=Re(t);return e.json?{exitCode:0,stdout:JSON.stringify({ok:!0,providers:n},null,2),stderr:""}:{exitCode:0,stdout:n.length===0?l("provider.cli.listEmpty"):n.map(gn).join(`
8
+ `),stderr:""}}function yn(e,t){let n=e.values.get("--key");return n===void 0?void 0:n!=="-"?n:(t.readSecret??Ue)().trim()}function vn(e,t,n){for(let s of["--name","--api","--url"])if(!e.values.has(s))return x(l("provider.cli.missingFlag",{flag:s}),{hint:"cortex auth provider add --help"});let r=e.values.get("--api");if(!P.includes(r))return x(V("api-invalid"),{validValues:[...P],hint:"cortex auth provider add --help"});let i=Te(t,{name:e.values.get("--name"),api:r,upstreamUrl:e.values.get("--url"),apiKey:yn(e,n),models:e.models.map(s=>({id:s}))});return i.ok===!1?x(i.errors.map(V).join(`
9
+ `),{hint:"cortex auth provider add --help"}):{exitCode:0,stdout:e.json?JSON.stringify({ok:!0,provider:i.provider},null,2):l("provider.cli.added",{name:i.provider.name,upstream:i.provider.upstreamUrl??""}),stderr:""}}function Cn(e,t){let n=e.values.get("--name");if(!n)return x(l("provider.cli.missingFlag",{flag:"--name"}),{hint:"cortex auth provider remove --help"});let r=je(t,n);if(!r)return x(l("provider.cli.notFound",{name:n}),{hint:"cortex auth provider list"});if(e.dryRun)return{exitCode:0,stdout:JSON.stringify({dry_run:!0,would_remove:r},null,2),stderr:""};let i=Oe(t,n);return i.ok===!1?x(i.errors.map(V).join(`
10
+ `),{hint:"cortex auth provider list"}):{exitCode:0,stdout:e.json?JSON.stringify({ok:!0,name:n},null,2):l("provider.cli.removed",{name:n}),stderr:""}}function dt(e,t,n={}){if(e.length===0||e[0]==="--help"||e[0]==="-h")return{exitCode:0,stdout:ct(),stderr:""};let r=e[0];if(!ut.includes(r))return x(l("provider.cli.unknownSubcommand",{command:r}),{validValues:[...ut],hint:"cortex auth provider --help"});let i=e.slice(1);if(i.includes("--help")||i.includes("-h"))return{exitCode:0,stdout:ct(),stderr:""};let o=hn(i);return"values"in o?r==="list"?xn(o,t):r==="add"?vn(o,t,n):Cn(o,t):o}function pt(){return{validValues:l("cmd.auth.cli.validValues"),hint:l("cmd.auth.cli.hint")}}function wn(e){if(e.length===0||e[0]==="--help"||e[0]==="-h")return{exitCode:0,stdout:U(),stderr:""};if(e[0]==="status")return e.slice(1);let t=l("cmd.auth.cli.unknownSubcommand",{command:e[0]});return{exitCode:1,stdout:"",stderr:f(t,{validValues:["status","login","provider"],hint:"cortex auth --help",labels:pt()})}}function bn(e){if(e.includes("--help")||e.includes("-h"))return{exitCode:0,stdout:U(),stderr:""};let t=e.find(i=>i!=="--json");if(!t)return null;let n=l("cmd.auth.cli.unknownFlag",{flag:t});return{exitCode:1,stdout:"",stderr:f(n,{validValues:["--json"],hint:"cortex auth status --help",labels:pt()})}}async function ft(e,t,n){if(e[0]==="login")return Ke(e.slice(1));if(e[0]==="provider")return dt(e.slice(1),n);let r=wn(e);if(!Array.isArray(r))return r;let i=bn(r);if(i)return i;let o=await t();return{exitCode:0,stdout:r.includes("--json")?JSON.stringify(o,null,2):De(o),stderr:""}}import*as gt from"node:path";var mt=["enable","pair"];function J(e,t){let n=e.indexOf(t);return n!==-1&&e[n+1]?e[n+1]:void 0}function B(e,t){return{exitCode:1,stdout:"",stderr:f(e,t)}}async function In(e){let t=e.includes("--json"),n=J(e,"--port"),r=n===void 0?void 0:Number(n);if(r!==void 0&&(!Number.isInteger(r)||r<1||r>65535))return B(`Invalid --port: '${n}'.`,{validValues:["an integer in 1-65535"],hint:"cortex ui enable --port 3004"});let i=g(J(e,"--home"));try{let o=await Je({configDir:i.CONFIG_DIR,port:r});if(t){let a={ok:!0,home:i.DATA_DIR,...o};return{exitCode:0,stdout:`${JSON.stringify(a,null,2)}
11
+ `,stderr:""}}return{exitCode:0,stdout:`${[`Web UI endpoint enabled: ${o.url}`,`Home: ${i.DATA_DIR}`,o.changed?"Configuration changed \u2014 restart the daemon to apply (cortex daemon restart).":"Already configured \u2014 no restart needed.","Connect another app or browser with a one-time code from `cortex ui pair`."].join(`
12
+ `)}
13
+ `,stderr:""}}catch(o){return{exitCode:1,stdout:"",stderr:o.message||String(o)}}}async function kn(e){let t=g(J(e,"--home")),n=me({file:gt.join(t.STORE_DIR,pe)}),{code:r,expiresAt:i}=n.create();return e.includes("--json")?{exitCode:0,stdout:`${JSON.stringify({ok:!0,code:r,expiresAt:i},null,2)}
14
+ `,stderr:""}:{exitCode:0,stdout:`${[`Pairing code: ${r}`,`Valid for ${fe/6e4} minutes, once.`,"Enter it with this server's address in the Cortex app, or on the browser sign-in page."].join(`
15
+ `)}
16
+ `,stderr:""}}var ht={enable:In,pair:kn};async function xt(e){if(e.length===0)return B("Missing subcommand for 'ui'.",{validValues:mt,hint:"cortex ui --help"});if(e.includes("--help")||e.includes("-h"))return{exitCode:0,stdout:Qe(),stderr:""};let t=Object.hasOwn(ht,e[0])?ht[e[0]]:void 0;return t?t(e):B(`Unknown subcommand: '${e[0]}'.`,{validValues:mt,hint:"cortex ui --help"})}import*as vt from"node:fs";import*as v from"node:path";var k=class extends Error{validValues;hint;constructor(t,n,r){super(t),this.validValues=n,this.hint=r}},Ct="client-pids.json",wt="client-routes.json";function j(e){try{return JSON.parse(vt.readFileSync(e,"utf8"))}catch{return{}}}function W(e,t,n=!1){let r=j(e);t in r&&(delete r[t],ne(e,`${JSON.stringify(r,null,2)}${n?`
17
+ `:""}`))}function Sn(e,t){return Ne(e,t,3e4)}var $n=/"([^"]+?)[\\/]client[\\/]current[\\/]client\.mjs"|(\S+?)[\\/]client[\\/]current[\\/]client\.mjs/;function bt(e){let t=e.clientCommand?.match($n),n=t?.[1]??t?.[2];return n||(e.win?"%USERPROFILE%\\.cortex":"$HOME/.cortex")}function Dn(e){return[`h="${e}"`,'k=$(pgrep -f "$h/client/current/client[.]mjs" | xargs); [ -n "$k" ] && kill $k; echo "killed=${k:-none}"','if [ -f "$h/config/machines.json" ]; then echo files=kept-server-home; else',' rm -rf "$h/client"; rm -f "$h/config/cortex-client.json" "$h"/logs/client-*.log',' rmdir "$h/logs" "$h/config" "$h" 2>/dev/null; echo files=removed',"fi"].join(`
18
+ `)}function An(e){let t=`powershell -NoProfile -Command "$k = @(Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*${e}\\client\\current\\client[.]mjs*' }); $k | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }; 'killed=' + (@($k | ForEach-Object { $_.ProcessId }) -join ' ')"`,n=`rmdir /s /q "${e}\\client" 2>nul & del /q "${e}\\config\\cortex-client.json" 2>nul & del /q "${e}\\logs\\client-*.log" 2>nul & echo files=removed`;return`${t} & if exist "${e}\\config\\machines.json" (echo files=kept-server-home) else (${n})`}function Pn(e){return(e.win?An:Dn)(bt(e))}function yt(e,t){return e.match(new RegExp(`^${t}=(.*)$`,"m"))?.[1]?.trim()||"none"}async function En(e,t){try{let n=await t(e.ssh,Pn(e));return{status:"cleaned",killed:yt(n,"killed"),files:yt(n,"files")}}catch(n){return{status:"unreachable",error:n.message}}}function _n(e,t){let n=e[t];if(!n){let r=Object.keys(e).filter(i=>e[i].ssh);throw new k(`Unknown device: '${t}'.`,r,"cortex client remove --device <name>")}if(!n.ssh)throw new k(`'${t}' is the server's local machine and has no remote client to remove.`,void 0,"edit config/machines.json by hand if this machine really should go");return n}function Rn(e,t){let n=j(v.join(t.configDir,"machines.json")),r=_n(n,e.device),i=j(v.join(t.storeDir,Ct))[e.device],o=j(v.join(t.storeDir,wt))[e.device];return{machine_entry:r,runtime:{pid:typeof i=="number"?i:null,route:typeof o=="string"?o:null},remote:e.keepRemote?null:{host:r.ssh,home:bt(r)}}}async function It(e,t){let n=Rn(e,t),{device:r}=e;if(e.dryRun)return{ok:!0,device:r,dry_run:!0,would_remove:n};W(v.join(t.configDir,"machines.json"),r,!0);let i=n.remote?await En(n.machine_entry,t.remoteExec??Sn):{status:"skipped"};return W(v.join(t.storeDir,Ct),r),W(v.join(t.storeDir,wt),r),{ok:!0,device:r,dry_run:!1,removed_at:new Date().toISOString(),machine_entry:n.machine_entry,runtime:n.runtime,remote:i}}var kt=["--device","--home"],St=["--keep-remote","--dry-run"];function S(e,t,n="cortex client remove --help"){return{exitCode:1,stdout:"",stderr:f(e,{validValues:t,hint:n})}}function jn(e){let t={};for(let n=0;n<e.length;n+=1){let r=e[n];if(St.includes(r)){t[r]=!0;continue}if(!kt.includes(r))return S(`Unknown option: '${r}'.`,[...kt,...St]);let i=e[n+1];if(!i||i.startsWith("--"))return S(`Missing value for ${r}.`);t[r]=i,n+=1}return t}async function Tn(e,t){let n=jn(e);if("exitCode"in n)return n;if(typeof n["--device"]!="string")return S("Missing --device.",void 0,"cortex client remove --device <name>");let r=g(n["--home"]);try{let i=await It({device:n["--device"],keepRemote:n["--keep-remote"]===!0,dryRun:n["--dry-run"]===!0},{configDir:r.CONFIG_DIR,storeDir:r.STORE_DIR,remoteExec:t}),o=i.remote?.status==="unreachable"?`Warning: '${i.device}' was removed locally, but its machine could not be reached; the remote client was not uninstalled.`:"";return{exitCode:0,stdout:`${JSON.stringify(i,null,2)}
19
+ `,stderr:o}}catch(i){return i instanceof k?S(i.message,i.validValues,i.hint):{exitCode:1,stdout:"",stderr:i.message}}}async function $t(e,t){return e.includes("--help")||e.includes("-h")?{exitCode:0,stdout:et(),stderr:""}:e.length===0?S("Missing subcommand for 'client'.",["remove"],"cortex client --help"):e[0]!=="remove"?S(`Unknown subcommand: '${e[0]}'.`,["remove"],"cortex client --help"):Tn(e.slice(1),t)}var On=["install","remove","status"];function Nn(e,t){let n=e.indexOf(t);return n!==-1&&e[n+1]?e[n+1]:void 0}var Dt=e=>({exitCode:1,stdout:"",stderr:f(e,{validValues:On,hint:"cortex path --help"})});function Y(e,t,n){let r=e.path_targets.filter(i=>i[t]).map(i=>i.target);return`${n}: ${r.length?r.join(", "):"none"}`}function Fn(e){let t=[`${e.dry_run?"Would install":"Installed"} terminal commands in ${e.dir}`,Y(e,"changed",e.dry_run?"PATH would change in":"PATH updated in"),"Open a new terminal to use `cortex`."];return e.shadowed.length&&t.push(`New terminals will use this install instead of: ${e.shadowed.join(", ")}`),process.env.SHELL?.endsWith("fish")&&t.push(`fish is not configured automatically; run: fish_add_path ${e.dir}`),t}function Ln(e){return[`${e.dry_run?"Would remove":"Removed"} ${e.removed.length} command file(s) from ${e.dir}`,Y(e,"changed",e.dry_run?"PATH would change in":"PATH restored in")]}function Mn(e){return[`Terminal commands: ${e.installed?"installed":"not installed"} (${e.dir})`,...e.stale.length?[`Out of date: ${e.stale.join(", ")} \u2014 rerun cortex path install`]:[],Y(e,"registered","On PATH via")]}var Gn={install:(e,t)=>{let n=Le(e,t);return{report:n,text:Fn(n)}},remove:(e,t)=>{let n=Me(e,t);return{report:n,text:Ln(n)}},status:e=>{let t=Ge(e);return{report:t,text:Mn(t)}}};function At(e,t=Fe){if(e.includes("--help")||e.includes("-h"))return{exitCode:0,stdout:Ze(),stderr:""};if(e.length===0)return Dt("Missing subcommand for 'path'.");let n=Gn[e[0]];if(!n)return Dt(`Unknown subcommand: '${e[0]}'.`);try{let r=t(g(Nn(e,"--home")).DATA_DIR),{report:i,text:o}=n(r,e.includes("--dry-run"));return{exitCode:0,stdout:e.includes("--json")?`${JSON.stringify(i,null,2)}
20
+ `:`${o.join(`
21
+ `)}
22
+ `,stderr:""}}catch(r){return{exitCode:1,stdout:"",stderr:`cortex path ${e[0]} failed: ${r?.message??String(r)}
23
+ `}}}var y=le("cli"),ee=d.dirname(Un(new URL("dist/entry/cli.js",__cortexPackageRoot).href)),q=d.join(ee,"app.js"),$=d.join(ee,"daemon.js"),X=d.join(ee,"..","tui","index.js");function Kn(e){let t={resume:!1};for(let n=0;n<e.length;n++)switch(e[n]){case"--resume":t.resume=!0;break;case"--project":t.project=e[++n];break;case"--port":t.port=Number(e[++n]);break}return t}function Vn(e){return new Promise(t=>{let n=Rt.connect({host:"127.0.0.1",port:e},()=>{n.end(),t(!0)});n.setTimeout(500),n.on("timeout",()=>{n.destroy(),t(!1)}),n.on("error",()=>t(!1))})}async function Jn(e){let t=Kn(e),n=t.port??(Number(process.env.CORTEX_TUI_PORT)||3003);await Vn(n)||(process.stderr.write(`Cortex daemon is not running on port ${n}.
24
+ Start it with: cortex daemon
25
+ `),process.exit(1)),m(X)||(y.error(`TUI entry not found: ${X}`),y.error("Run `npm run build` first."),process.exit(1));let r=[];t.resume&&r.push("--resume"),t.project&&r.push("--project",t.project),T(X,r,{stdio:"inherit",env:{...process.env,CORTEX_TUI_PORT:String(n)}}).on("exit",o=>process.exit(o??0)),await new Promise(()=>{})}function N(){if(!m(h))return{result:{exitCode:0,stdout:`Cortex daemon is not running.
26
+ `,stderr:""}};let e=A(h);if(e===null){try{Z(h)}catch{}return{result:{exitCode:0,stdout:`Cortex daemon is not running (removed corrupted PID file).
27
+ `,stderr:""}}}if(!xe(h,e)){try{Z(h)}catch{}return{result:{exitCode:0,stdout:`Cortex daemon is not running (removed stale PID file for PID ${e}).
28
+ `,stderr:""}}}return{pid:e}}async function Bn(){let e=N();if("result"in e)return Pt(e.result);let t=await Wn(e.pid);return t.daemonGone?Pt(t.result):t.result}async function Pt(e){let{exitCode:t,stdout:n,stderr:r}=e;try{let{stopLaunchedLocalClients:i}=await import("./local-client-stop-SQRU7ZZM.js");for(let{device:o,pid:s,outcome:a}of await i())a==="stopped"&&(n+=`Stopped local client ${o} (PID ${s}).
29
+ `),a==="unverified"&&(r+=`Left local client ${o} (PID ${s}) running: could not confirm the process is its client.
30
+ `),a==="survived"&&(t=1,r+=`Local client ${o} (PID ${s}) did not exit.
31
+ `)}catch(i){r+=`Could not stop the local client: ${i.message||String(i)}
32
+ `}return{exitCode:t,stdout:n,stderr:r}}async function Wn(e){try{process.kill(e,"SIGTERM")}catch(i){return{daemonGone:!1,result:{exitCode:1,stdout:"",stderr:`Failed to send signal to daemon (PID ${e}): ${i.message}
33
+ `}}}let t=1e4,n=200,r=Date.now()+t;for(;Date.now()<r;){await new Promise(i=>setTimeout(i,n));try{process.kill(e,0)}catch{break}}try{process.kill(e,0);try{process.kill(e,"SIGKILL")}catch{}return{daemonGone:!w(e),result:{exitCode:1,stdout:"",stderr:`Daemon (PID ${e}) did not stop within ${t/1e3}s. Forcibly killed (SIGKILL).
34
+ `}}}catch{}try{A(h)===e&&Z(h)}catch{}return{daemonGone:!0,result:{exitCode:0,stdout:`Cortex daemon stopped (PID ${e}).
35
+ `,stderr:""}}}function Et(e){try{let t=`/proc/${e}/stat`;if(!m(t))return"unknown";let n=Q(t,"utf8"),r=n.lastIndexOf(")"),i=n.substring(r+2).split(" "),o=parseInt(i[19],10);if(!Number.isFinite(o))return"unknown";let s=Q("/proc/uptime","utf8"),a=parseFloat(s.split(" ")[0]),jt=Date.now()-a*1e3+o/100*1e3,te=Date.now()-jt;return te<0?"unknown":Ie(te)}catch{return"unknown"}}function Yn(){let e=N();if("result"in e)return e.result;let{pid:t}=e,n=Et(t),r=["Cortex daemon is running.",` PID: ${t}`,` Uptime: ${n}`],i=A(L);return i===null?r.push(" Child: starting..."):w(i)?r.push(` Child: app.js (PID ${i}, uptime ${Et(i)})`):r.push(` Child: none (stale PID ${i} \u2014 daemon will restart)`),{exitCode:0,stdout:r.join(`
36
+ `)+`
37
+ `,stderr:""}}function qn(){let e=N();if("result"in e)return{exitCode:1,stdout:"",stderr:`Cortex daemon is not running. Nothing to restart.
38
+ `};try{return G(),{exitCode:0,stdout:`Restart signal sent to daemon (PID ${e.pid}).
39
+ `,stderr:""}}catch(t){return{exitCode:1,stdout:"",stderr:`Failed to signal daemon restart: ${t.message||String(t)}
40
+ `}}}function _t(e){if("result"in N())return{exitCode:1,stdout:"",stderr:`Cortex daemon is not running.
41
+ `};let t=A(L);if(t===null)return{exitCode:1,stdout:"",stderr:`No child PID file found. Is app.js running?
42
+ `};if(!w(t))return{exitCode:1,stdout:"",stderr:`Child process (PID ${t}) is not running.
43
+ `};let n=e?"SIGKILL":"SIGTERM";try{process.kill(t,n)}catch(r){return{exitCode:1,stdout:"",stderr:`Failed to send ${n} to app.js (PID ${t}): ${r.message}
44
+ `}}return{exitCode:0,stdout:`Sent ${n} to app.js (PID ${t}). Daemon will restart it automatically.
45
+ `,stderr:""}}function Xn(){let e={INSTALL_ROOT:re,...g()},t=d.join(e.CONFIG_DIR,".env"),n=d.join(e.CONFIG_DIR,"mcp-config.json"),r=d.join(e.STORE_DIR,"agent-state.json"),i=d.join(e.STORE_DIR,"mode.json"),o=0;try{o=Hn(e.STORE_DIR).length}catch{}let s={dataDirExists:m(e.DATA_DIR)&&o>0,dotEnvExists:m(t),mcpConfigExists:m(n),modeJsonExists:m(r)||m(i)};return We(e,s)}function O(e,t){let n=e.indexOf(t);return n!==-1&&e[n+1]?e[n+1]:void 0}async function zn(e){if(e.includes("--help")||e.includes("-h"))return{exitCode:0,stdout:qe(),stderr:""};let t=O(e,"--home"),n=O(e,"--gateway-config-dir"),r=O(e,"--answers");try{let i=r?Be(Q(d.resolve(r),"utf-8")):void 0;return await Ye({homeDir:t,gatewayConfigDir:n,force:e.includes("--force"),answers:i,jsonEvents:e.includes("--json")}),{exitCode:0,stdout:"",stderr:""}}catch(i){return i instanceof He&&i.exitCode===130?{exitCode:130,stdout:"",stderr:l("init.cancel")}:{exitCode:1,stdout:"",stderr:i.message||String(i)}}}function Qn(){let e=ae;try{return G(e),{exitCode:0,stdout:`Restart trigger touched: ${e}
46
+ If a daemon is running it will drain and respawn app.js.
47
+ `,stderr:""}}catch(t){return{exitCode:1,stdout:"",stderr:`Could not write ${e}: ${t.message||String(t)}`}}}function Zn(e,t){if(t.droppedFromDiscovery.length===0)return;let n=t.droppedFromDiscovery.map(r=>`${r.mode}/${r.endpoint}`).join(", ");e.push(`WARNING: preserved ${t.droppedFromDiscovery.length} existing gateway mode(s) not reported by discovery: ${n}`),e.push(" (if these should auto-detect, check `cortex auth status` and log the provider in)")}function er(e,t){if(t.length!==0){e.push(`WARNING: ${t.length} model selection(s) reference an unconfigured gateway route:`);for(let n of t)e.push(` - ${n.model}: ${n.reason}`)}}function tr(e,t,n,r,i){let o=Ae(d.dirname(r)),s=o.favorites.map(p=>p.model).join(", "),a=[t?`[TEST MODE] Output directory: ${t}`:"",`Gateway config: ${n}`,`Models: ${r}`,`Discovered ${e.length} endpoint modes`,`Favorites: ${s} (default: ${o.default.model})`];return Zn(a,i),er(a,we(i.endpoints,t)),a.filter(Boolean).join(`
48
+ `)}async function nr(e){let t=await ve();if(!t.some(o=>o.models.length>0))return{exitCode:0,stdout:`No backends discovered. Log into Claude Code and/or PI first.
49
+ `,stderr:""};let{path:n,result:r}=Ce(t,e),i=Pe(t,{outputDir:e});return{exitCode:0,stdout:tr(t,e,n,i,r),stderr:""}}async function rr(e){if(e.includes("--help")||e.includes("-h"))return{exitCode:0,stdout:Xe(),stderr:""};try{return e.includes("--dry-run")?{exitCode:0,stdout:await be(),stderr:""}:await nr(O(e,"--output-dir"))}catch(t){return{exitCode:1,stdout:"",stderr:t.message||String(t)}}}async function ir(e){let{runCli:t,getInstallHelp:n}=await import("./install-cli-4IZCSDFZ.js");return e.includes("--help")||e.includes("-h")?{exitCode:0,stdout:n(),stderr:""}:t(e)}function or(e){return e[1]==="--hard"?_t(!1):e[1]==="--force"?_t(!0):qn()}function sr(e){return e[0]==="stop"?Bn():e[0]==="status"?Yn():e[0]==="restart"?or(e):null}async function ar(e){let t=sr(e);return t||(e.includes("--help")||e.includes("-h")?{exitCode:0,stdout:I(),stderr:""}:e.includes("--version")||e.includes("-V")?{exitCode:0,stdout:`${M}
50
+ `,stderr:""}:{exitCode:0,stdout:"",stderr:`'daemon' must be run from the main entry point, not imported.
51
+ Use: node dist/entry/cli.js daemon`})}var lr={init:e=>zn(e),config:()=>({exitCode:0,stdout:Xn(),stderr:""}),auth:(e,t)=>ft(e,t.getAuthStatus??_,t.customProviderStores??_e()),doctor:e=>lt(e),feishu:e=>Ve(e),restart:()=>Qn(),"setup-gateway":e=>rr(e),ui:e=>xt(e),client:e=>$t(e),path:e=>At(e),install:e=>ir(e),schedule:async e=>(await import("./schedule-cli-OLASBBYJ.js")).runScheduleCli(e),memory:async e=>(await import("./memory-cli-PYOILNN5.js")).runMemoryCli(e),start:()=>({exitCode:0,stdout:"",stderr:`'start' must be run from the main entry point, not imported.
52
+ Use: node dist/entry/cli.js start`}),daemon:e=>ar(e)};async function z(e,t={}){if(e.length===0||e[0]==="--help"||e[0]==="-h")return{exitCode:0,stdout:I(),stderr:""};let n=lr[e[0]];return n?n(e.slice(1),t):{exitCode:1,stdout:"",stderr:`Unknown command: '${e[0]}'. Use --help to see available commands.`}}function ur(){let e=process.argv.slice(2);(e.length===0||e[0]==="--help"||e[0]==="-h")&&(console.log(I()),process.exit(0));let t=e[0],n=e.slice(1);if((n.includes("--help")||n.includes("-h"))&&(t==="daemon"&&(console.log(I()),process.exit(0)),t==="start"&&(console.log(I()),process.exit(0)),t==="tui"&&(console.log(ze()),process.exit(0))),(n.includes("--version")||n.includes("-V"))&&t==="daemon"&&(console.log(M),process.exit(0)),t==="start"){m(q)||(y.error(`Entry not found: ${q}`),y.error("Run `npm run build` first."),process.exit(1)),T(q,[],{cwd:C,stdio:"inherit",env:{...process.env}}).on("exit",i=>process.exit(i??0));return}if(t==="daemon"){if(n[0]==="restart-self"){z(["daemon","stop"]).then(async i=>{i.stdout&&console.log(i.stdout),i.stderr&&console.error(i.stderr),m($)||(y.error(`Entry not found: ${$}`),y.error("Run `npm run build` first."),process.exit(1)),console.log("Starting daemon..."),T($,[],{cwd:C,detached:!0,stdio:"ignore",env:{...process.env}}),process.exit(0)});return}if(n[0]==="stop"||n[0]==="status"||n[0]==="restart"){z(e).then(i=>{i.stdout&&console.log(i.stdout),i.stderr&&console.error(i.stderr),process.exit(i.exitCode)});return}m($)||(y.error(`Entry not found: ${$}`),y.error("Run `npm run build` first."),process.exit(1));let r={cwd:C,windowsHide:!0,detached:!0,stdio:"ignore",env:{...process.env}};T($,[],r),process.exit(0)}if(t==="tui"){Jn(n);return}z(e).then(r=>{r.stdout&&console.log(r.stdout),r.stderr&&console.error(r.stderr),process.exit(r.exitCode)})}he(new URL("dist/entry/cli.js",__cortexPackageRoot).href)&&ur();export{Kn as a,Vn as b,Jn as c,Xn as d,z as e,ur as f};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{a as Ze}from"./chunk-JERCOLY3.js";import{a as O}from"./chunk-OKRK6JPY.js";import{a as he,b as me,e as ge,f as ye}from"./chunk-BGVHA2D4.js";import{a as P}from"./chunk-LCKVYFMD.js";import{c as pe}from"./chunk-STUHNKQS.js";import{a as ue}from"./chunk-Q4UGYGU5.js";import{d as v}from"./chunk-W5LGYSPZ.js";import{e as l}from"./chunk-NAA7GF6Q.js";import{h as fe}from"./chunk-QWAQHHRS.js";import{a as Qe,b as A,j as p,k as F,l as h,m as le,n as de}from"./chunk-J5DVLUKY.js";import{e as ce}from"./chunk-WHC7AYZD.js";var I=ce(Ze(),1);import{copyFileSync as Pe,existsSync as z,readFileSync as Fe}from"fs";import*as M from"path";function et(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}var m=class{options;entries=[];nextRefreshAt=0;inFlight=null;refreshQueued=!1;now;constructor(t){this.options=t,this.now=t.now??Date.now}peek(){let t=this.options.clone;return t?this.entries.map(t):[...this.entries]}get(){let t=this.peek();return this.now()>=this.nextRefreshAt&&!this.inFlight&&this.startRefresh(),t}async ensure(t){if(this.entries.length>0)return this.get();!this.inFlight&&this.now()>=this.nextRefreshAt&&this.startRefresh();let n=this.inFlight;return n&&await Promise.race([n,et(t)]),this.peek()}refresh(){if(!this.inFlight){this.startRefresh();return}this.refreshQueued=!0}startRefresh(){let t=Promise.resolve().then(this.options.scan).then(n=>this.accept(n)).catch(n=>this.reject(n)).finally(()=>this.finishRefresh(t));this.inFlight=t}finishRefresh(t){this.inFlight===t&&(this.inFlight=null,this.refreshQueued&&(this.refreshQueued=!1,this.startRefresh()))}accept(t){let{key:n,clone:o}=this.options,r=new Set,i=[];for(let s of t){if(n){let a=n(s);if(r.has(a))continue;r.add(a)}i.push(o?o(s):s)}this.entries=i,this.nextRefreshAt=this.now()+this.options.cacheTtlMs}reject(t){this.nextRefreshAt=this.now()+this.options.retryMs;let n=t instanceof Error?t.message:"unknown";this.options.logFailure?.(n)}};var Ae=ce(Qe(),1);import{execFile as tt,execFileSync as nt}from"child_process";import{createHash as ot}from"crypto";import{readFileSync as rt}from"fs";import*as S from"path";var it="oauth-2025-04-20",Ee="2023-06-01",st=6e4,at=2e3,ct=5e3;function L(e,t){try{return e(t)}catch{return null}}function j(e){return e.readFile??(t=>rt(t,"utf8"))}function g(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||t==="undefined"||t==="null"))return t}function H(e){let t=g(e);return t===fe?void 0:t}function ut(e){let t=L(e,S.join(h,".env"));if(t===null)return{};try{return(0,Ae.parse)(t)}catch{return{}}}function be(e={}){let t=ut(j(e)),n=g(t.CLAUDE_CODE_OAUTH_TOKEN);return{ANTHROPIC_API_KEY:H(t.ANTHROPIC_API_KEY),ANTHROPIC_BASE_URL:g(t.ANTHROPIC_BASE_URL),CLAUDE_CODE_OAUTH_TOKEN:n,CLAUDE_CODE_OAUTH_TOKEN_EXPIRES_AT:n?g(t.CLAUDE_CODE_OAUTH_TOKEN_EXPIRES_AT):void 0}}function we(e={}){let t=e.env??process.env;return H(t.ANTHROPIC_API_KEY)??be(e).ANTHROPIC_API_KEY??null}function _e(e){return{"x-api-key":e,"anthropic-version":Ee}}function E(e){return{authorization:`Bearer ${e}`,"anthropic-beta":it,"anthropic-version":Ee}}function U(e={}){return e.claudeConfigDir??de}function lt(e={}){return S.join(U(e),".credentials.json")}function $(e){return typeof e=="string"&&e.trim()?e.trim():null}function ve(e){return typeof e!="number"||!Number.isFinite(e)||Number.isNaN(new Date(e).getTime())?null:e}function ke(e){let t;try{t=JSON.parse(e)?.claudeAiOauth}catch{return null}if(!t||typeof t!="object"||Array.isArray(t))return null;let n=t,o={accessToken:$(n.accessToken),refreshToken:$(n.refreshToken),expiresAt:ve(n.expiresAt),refreshExpiresAt:ve(n.refreshTokenExpiresAt)};return o.accessToken||o.refreshToken?o:null}function xe(e={}){let t=L(j(e),lt(e));return t===null?null:ke(t)}function Oe(e,t){if(!e?.accessToken)return null;let n=(t.now??Date.now)();return e.expiresAt!==null&&e.expiresAt-st<=n?null:e.accessToken}function Se(e){return Oe(xe(e),e)}function Mn(e={}){let t=Se(e);return t?E(t):null}function In(e={}){let t=L(j(e),S.join(U(e),".claude.json"));if(t===null)return null;try{let n=JSON.parse(t)?.oauthAccount;return $(n?.organizationUuid)}catch{return null}}function K(e={}){let t=e.env??process.env,n=H(t.ANTHROPIC_API_KEY);if(n)return{headers:_e(n),source:"env-api-key"};let o=be(e);if(o.ANTHROPIC_API_KEY)return{headers:_e(o.ANTHROPIC_API_KEY),source:"dotenv-api-key"};let r=Se(e);if(r)return{headers:E(r),source:"claude-credentials"};let i=g(t.CLAUDE_CODE_OAUTH_TOKEN);return i?{headers:E(i),source:"env-oauth-token"}:o.CLAUDE_CODE_OAUTH_TOKEN?{headers:E(o.CLAUDE_CODE_OAUTH_TOKEN),source:"dotenv-oauth-token"}:null}function Te(e={}){return`Claude Code-credentials-${ot("sha256").update(U(e).normalize("NFC")).digest("hex").slice(0,8)}`}function dt(e){try{return nt("security",["find-generic-password","-s",e],{stdio:"ignore",timeout:at}),!0}catch{return!1}}function pt(e){return new Promise(t=>{try{tt("security",["find-generic-password","-s",e,"-w"],{encoding:"utf8",timeout:ct},(n,o)=>t(n?null:o.trim()||null))}catch{t(null)}})}async function Me(e={}){if((e.platform??process.platform)!=="darwin")return null;let o=await(e.readKeychain??pt)(Te(e)),r=Oe(o===null?null:ke(o),e);return r?{headers:E(r),source:"claude-keychain"}:null}function G(e={}){return xe(e)?!0:(e.platform??process.platform)!=="darwin"?!1:(e.probeKeychain??dt)(Te(e))}function Cn(e={}){let t=e.env??process.env;return g(t.ANTHROPIC_AUTH_TOKEN)?!0:K(e)!==null||G(e)}var Ie=l("anthropic-models"),ft=30*6e4,ht=5*6e4,mt=8e3,gt=1e4,yt=1e3,_t=1e6,T="[1m]",vt=["low","medium","high","xhigh","max"];function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function At(e){return((e.env??process.env).ANTHROPIC_BASE_URL?.trim()||"https://api.anthropic.com").replace(/\/+$/,"")}function Et(e){if(!b(e))return null;let t=e.effort;if(!b(t)||t.supported!==!0)return null;let n=vt.filter(o=>{let r=t[o];return b(r)&&r.supported===!0});return n.length>0?[...n]:null}function bt(e){if(!b(e))return null;let t=typeof e.id=="string"?e.id.trim():"";if(!t)return null;let n=typeof e.display_name=="string"?e.display_name.trim():"",o=e.max_input_tokens;return{id:t,displayName:n||null,maxInputTokens:typeof o=="number"&&Number.isFinite(o)?o:null,effortLevels:Et(e.capabilities)}}async function wt(e={}){let t=K(e)??await Me(e);if(!t)throw new Error("no Anthropic credential available to the daemon");let n=e.fetchImpl??fetch,o=`${At(e)}/v1/models?limit=${yt}`,r=await n(o,{method:"GET",headers:t.headers,signal:AbortSignal.timeout(gt)});if(!r.ok)throw new Error(`models request failed: HTTP ${r.status}`);let i=await r.json(),s=b(i)?i.data:null;if(!Array.isArray(s))throw new Error("models response carried no data array");let a=[];for(let u of s){let ae=bt(u);ae&&a.push(ae)}return Ie.debug(`discovered ${a.length} Anthropic models via ${t.source}`),a}function kt(e){return e.endsWith(T)?e.slice(0,-T.length):e}function xt(e,t){return e.startsWith(`${t}-`)&&/^\d{8}$/.test(e.slice(t.length+1))}function Ce(e,t=O){let n=[],o=new Set,r=i=>{o.has(i)||(o.add(i),n.push(i))};for(let i of e)r(i.id),(i.maxInputTokens??0)>=_t&&r(`${i.id}${T}`);for(let i of t){let s=kt(i);e.some(u=>u.id===s||xt(u.id,s))||r(i)}return n}function $n(e){let t={};for(let n of e)n.effortLevels&&(t[n.id]=[...n.effortLevels],t[`${n.id}${T}`]=[...n.effortLevels]);return t}function Ot(e={}){let t=new m({scan:e.fetchModels??(()=>wt()),now:e.now,cacheTtlMs:e.cacheTtlMs??ft,retryMs:e.retryMs??ht,key:n=>n.id,clone:n=>({...n,effortLevels:n.effortLevels?[...n.effortLevels]:null}),logFailure:n=>Ie.info(`Anthropic model discovery failed: ${n}`)});return{get:()=>t.get(),ensure:(n=mt)=>t.ensure(n)}}var De=Ot();var f=l("gateway-generator"),St=new Set(["host","port","mode","auth","status_check","max_body_size_mb","endpoint_modes","endpoints"]),B=100,Tt=["keys","base_url","auth_style","passthrough","fallbacks","model_fallbacks"],Y="default",$e={anthropic:{url:"https://api.anthropic.com",auth_style:"bearer"},fireworks:{url:"https://api.fireworks.ai/inference",auth_style:"bearer"},"github-copilot":{url:"https://api.individual.githubcopilot.com",auth_style:"bearer"},minimax:{url:"https://api.minimax.io/anthropic",auth_style:"bearer"},"minimax-cn":{url:"https://api.minimaxi.com/anthropic",auth_style:"bearer"},opencode:{url:"https://opencode.ai/inference",auth_style:"bearer"},"vercel-ai-gateway":{url:"https://ai-gateway.vercel.sh",auth_style:"bearer"},cerebras:{url:"https://api.cerebras.ai/v1",auth_style:"bearer"},deepseek:{url:"https://api.deepseek.com",auth_style:"bearer"},groq:{url:"https://api.groq.com/openai/v1",auth_style:"bearer"},huggingface:{url:"https://router.huggingface.co/v1",auth_style:"bearer"},"kimi-coding":{url:"https://api.kimi.com/coding/v1",auth_style:"bearer"},mistral:{url:"https://api.mistral.ai",auth_style:"bearer"},openai:{url:"https://api.openai.com/v1",auth_style:"bearer"},"opencode-go":{url:"https://opencode.ai/inference/go/v1",auth_style:"bearer"},openrouter:{url:"https://openrouter.ai/api/v1",auth_style:"bearer"},xai:{url:"https://api.x.ai/v1",auth_style:"bearer"},zai:{url:"https://api.z.ai/api/coding/paas/v4",auth_style:"bearer"},"openai-codex":{url:"https://chatgpt.com/backend-api",auth_style:"bearer"},"google-gemini-cli":{url:"https://cloudcode-pa.googleapis.com",auth_style:"bearer"},"google-antigravity":{url:"https://daily-cloudcode-pa.sandbox.googleapis.com",auth_style:"bearer"},google:{url:"https://generativelanguage.googleapis.com/v1beta",auth_style:"bearer"}},Mt={"kimi-coding":["https://api.kimi.com/coding"],opencode:["https://opencode.ai/zen"],"opencode-go":["https://opencode.ai/zen/go/v1"]};function It(e){let t=0;for(let[n,o]of Object.entries(Mt))for(let r of Object.values(e[n]??{}))o.includes(r.base_url)&&(r.base_url=$e[n].url,t+=1);return t}function Vn(e=M.join(F,"gateway.yaml")){let t=y(e);if(!t)return 0;let n=It(t.endpoints);return n===0?0:(Pe(e,`${e}.bak`),v(e,C({endpoints:t.endpoints,top:t.top,preservedCustom:[],droppedFromDiscovery:[]})),f.info(`Moved ${n} gateway route(s) off retired PI upstream URLs in ${e}`),n)}var Ct=["off","minimal","low","medium","high","xhigh","max"];function Dt(e){let t=e;if(!t||typeof t!="object"||!("reasoning"in t)&&!("thinkingLevelMap"in t))return;if(!t.reasoning)return[];let n=t.thinkingLevelMap;return Ct.filter(o=>{let r=n?.[o];return r===null?!1:o==="xhigh"||o==="max"?r!==void 0:!0})}async function W(){let{ModelRuntime:e}=await he();return(await(await e.create({authPath:ge(),modelsPath:ye(),allowModelNetwork:!1})).getAvailable()).map(o=>{let r=Dt(o);return{provider:o.provider,model:o.id,...r?{thinkingLevels:r}:{}}})}async function Rt(){try{return await W()}catch(e){let t=e instanceof Error?e.message:String(e);return f.info(`PI model scan failed \u2014 skipping PI provider discovery: ${t}`),[]}}async function Nt(e,t={}){let n=i=>!e||e.includes(i),o=n("claude")?await Pt(t):[],r=n("pi")?await $t(t):[];return[...o,...r]}function Re(e,t,n){let o=e==="api";return{mode:e,endpoint:"anthropic",base_url:"https://api.anthropic.com",auth_style:o?"anthropic":"bearer",keys:o?["$ANTHROPIC_API_KEY"]:[],passthrough:!0,models:[...t],gatewayManaged:!0,...n?{defaultModel:n}:{}}}async function Pt(e){let t=(e.claudeSubscription??(()=>G()))(),n=we()!==null;if(!t&&!n)return[];let o=e.anthropicModels??(()=>De.ensure()),r=Ce(await o()),i=O.find(a=>r.includes(a))??r[0],s=[];return t&&s.push(Re("plan",r,i)),n&&s.push(Re("api",r,i)),s}function Ft(e,t,n){let o=$e[e];return{mode:e,endpoint:e,base_url:o?.url??"",auth_style:o?.auth_style??"bearer",keys:[],passthrough:!0,models:t,gatewayManaged:!!o,...n&&t.includes(n)?{defaultModel:n}:{}}}async function $t(e){let t=new Map;for(let{provider:o,model:r}of await Rt())t.has(o)||t.set(o,[]),t.get(o).push(r);if(t.delete("anthropic"),t.size===0)return[];let n=await(e.piDefaultModels??(()=>me()))();return[...t].map(([o,r])=>Ft(o,r,n[o]))}function Lt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function jt(e,t){let n=e.filter(i=>i.gatewayManaged!==!1),o={};for(let i of n)(o[i.endpoint]||=[]).push(i);let r=Ht(n,e,t);return Ut(r,o),Yt(r,e),r.push(""),r.join(`
5
+ `)}function Ht(e,t,n){let o=[];o.push("# aistatus gateway \u2014 auto-generated by cortex init"),o.push(`# Generated: ${new Date().toISOString()}`),o.push("#"),o.push("# Per-mode routing: each mode maps to an endpoint + auth config."),o.push("# Managed keys are used first (with round-robin on 429/5xx),"),o.push("# then passthrough of the caller's own key when passthrough: true."),o.push("#"),o.push("# Docs: https://aistatus.cc/docs"),o.push("");let r=n||e[0]?.mode||t[0]?.mode||"api",i=e.map(s=>s.mode).filter((s,a,u)=>u.indexOf(s)===a);return o.push(`port: ${p.port}`),o.push(`mode: ${r}${i.length>0?` # active billing mode: ${i.join(" | ")}`:""}`),o.push("status_check: true"),o.push(`max_body_size_mb: ${B} # buffered request limit in MiB`),o}function Ut(e,t){for(let[n,o]of Object.entries(t)){e.push(""),e.push(`${n}:`);for(let r of o)Kt(e,r)}}function Kt(e,t){let n=t.mode==="plan"?"Anthropic Claude (OAuth passthrough, billed via subscription)":t.mode==="api"?"Anthropic Claude (API key, billed via API credits)":`${Lt(t.mode)} (PI-managed auth, routed through gateway)`;e.push(` # \u2500\u2500 ${n} \u2500\u2500`),e.push(` ${t.mode}:`),e.push(` base_url: ${t.base_url}`),e.push(` auth_style: ${t.auth_style}`),Gt(e,t)}function Gt(e,t){if(t.keys.length>0){e.push(" keys:");for(let n of t.keys)e.push(` - ${n}`)}else e.push(` # No managed keys \u2014 ${t.passthrough?"caller key passthrough":"waiting for key configuration"}`);t.passthrough&&t.keys.length>0&&e.push(" passthrough: true")}function Yt(e,t){let n=t.filter(o=>o.gatewayManaged===!1);if(n.length>0){e.push(""),e.push("# Skipped (no known upstream URL in PI_PROVIDER_UPSTREAM):");for(let o of n)e.push(`# ${o.mode} (${o.models.length} model${o.models.length===1?"":"s"})`);e.push("# These providers appear in models.json but are not routed through this gateway.")}}function w(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function zt(e){return Tt.some(t=>t in e)}function Ne(e){return JSON.parse(JSON.stringify(e))}function y(e){if(!z(e))return null;let t;try{t=(0,I.parse)(Fe(e,"utf-8"))}catch(r){return f.warn(`Failed to parse existing gateway.yaml (${e}): ${r.message} \u2014 regenerating from scratch`),null}if(!w(t))return null;let n={},o={};for(let[r,i]of Object.entries(t)){if(St.has(r)){n[r]=i;continue}if(w(i)){if(zt(i)){o[r]??={},o[r][Y]=i;continue}for(let[s,a]of Object.entries(i))w(a)&&(o[r]??={},o[r][s]=a)}}return{top:n,endpoints:o}}function Bt(e){let t={};for(let n of e){if(n.gatewayManaged===!1)continue;let o={base_url:n.base_url,auth_style:n.auth_style};n.keys.length>0&&(o.keys=[...n.keys],n.passthrough&&(o.passthrough=!0)),t[n.endpoint]??={},t[n.endpoint][n.mode]=o}return t}function Wt(e,t,n){let o=Bt(e),r=t?Ne(t.endpoints):{},{preservedCustom:i,droppedFromDiscovery:s}=Vt(r,o);Jt(r,o);let a=qt(r,e,n,t?.top.mode),u=t?Ne(t.top):{};return u.port=A(p,u.port),u.mode=a,u.status_check=u.status_check??!0,u.max_body_size_mb=u.max_body_size_mb??B,{endpoints:r,top:u,preservedCustom:i,droppedFromDiscovery:s}}function Vt(e,t){let n=[],o=[];for(let[r,i]of Object.entries(e))for(let s of Object.keys(i)){if(t[r]?.[s])continue;n.push({endpoint:r,mode:s}),r==="anthropic"&&(s==="plan"||s==="api")||o.push({endpoint:r,mode:s})}return{preservedCustom:n,droppedFromDiscovery:o}}function Jt(e,t){for(let[n,o]of Object.entries(t)){e[n]??={};for(let[r,i]of Object.entries(o))e[n][r]||(e[n][r]=i)}}function qt(e,t,n,o){let r=new Set;for(let a of Object.values(e))for(let u of Object.keys(a))r.add(u);let i=typeof o=="string"?o:void 0,s=t.find(a=>a.gatewayManaged!==!1)?.mode;return[n,i,s].find(a=>a&&r.has(a))??r.values().next().value??"api"}function C(e){let t={};t.port=A(p,e.top.port),t.mode=e.top.mode,t.status_check=e.top.status_check??!0,t.max_body_size_mb=e.top.max_body_size_mb??B;for(let n of["host","auth","endpoint_modes","endpoints"])e.top[n]!==void 0&&(t[n]=e.top[n]);return Xt(t,e.endpoints),Qt()+(0,I.stringify)(t,{lineWidth:0})}function Xt(e,t){for(let[n,o]of Object.entries(t)){let r=Object.keys(o);r.length===1&&r[0]===Y?e[n]=o[Y]:e[n]=o}}function Qt(){return["# aistatus gateway \u2014 managed by cortex (merge mode).",`# Generated: ${new Date().toISOString()}`,"#","# `cortex init` / `cortex setup-gateway` ADD newly discovered modes; existing modes and their","# keys are preserved as-is (never overwritten). Edit a route here to change its URL/keys.","# NOTE: inline comments inside existing blocks are not retained across regeneration.","#","# Docs: https://aistatus.cc/docs",""].join(`
6
+ `)}function Jn(e,t,n){let o=M.join(t||F,"gateway.yaml"),r=y(o),i=Wt(e,r,n),s=C(i);if(z(o))try{Pe(o,o+".bak"),f.info(`Backed up existing gateway.yaml to ${o}.bak`)}catch(a){f.warn(`Failed to backup existing gateway.yaml: ${a.message}`)}return v(o,s),f.info(`Written merged gateway.yaml to ${o}`),{path:o,result:i}}function qn(e,t=h){let n=M.join(t,"models.json"),o;try{if(!z(n))return[];o=JSON.parse(Fe(n,"utf8"))}catch(i){return f.warn(`Failed to read models.json for validation: ${i.message}`),[]}return w(o)?[o.default,...Array.isArray(o.favorites)?o.favorites:[]].filter(w).flatMap(i=>Zt(i,e)):[]}function Zt(e,t){let n=typeof e.provider=="string"?e.provider:void 0,o=e.backend==="claude"?"anthropic":n,r=typeof e.mode=="string"?e.mode:"",i=String(e.model??"(unknown)");if(!o)return[{model:i,mode:r,reason:"PI model is missing a provider (cannot resolve gateway endpoint)"}];let s=t[o]??{};return(r?!!s[r]:Object.keys(s).length>0)?[]:[{model:i,mode:r,provider:n,reason:`endpoint "${o}" has no configured ${r?`mode "${r}"`:"route"} in gateway.yaml`}]}async function Xn(){let e=await Nt();return e.length===0?`# No backends discovered. Log into Claude Code and/or PI first.
7
+ `:jt(e)}import{readFileSync as Le}from"node:fs";import*as je from"node:path";var V=l("models-repo"),X=0,He=je.join(h,"models.json"),io=new ue;function so(){return X}var J=class{filePath;cache=null;constructor(t=He){this.filePath=t}readSync(){return this.cache||(this.cache=JSON.parse(Le(this.filePath,"utf8"))),this.cache}readIfPresent(){try{return this.readSync()}catch(t){if(t.code==="ENOENT")return null;throw t}}invalidate(){this.cache=null,X+=1}reload(){let t=JSON.parse(Le(this.filePath,"utf8"));this.cache=t}},Q=new J,q=null;function ao(e){q=e}function en(e,t){try{e.reload(),X+=1,t?.(),V.info("Hot-reload: models.json reloaded"),q?.(`${P.refresh} \`models.json\` hot-reloaded`)}catch(n){V.error(`Hot-reload models.json failed: ${n.message} \u2014 keeping previous config`),q?.(`${P.warning} \`models.json\` hot-reload FAILED \u2014 keeping previous config`)}}function co(e=Q,t=He,n){let o=null,i=pe({label:"models.json",filePath:t,onChange:()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,en(e,n)},300)},warn:s=>V.error(s)});return()=>{i.close(),o&&clearTimeout(o),o=null}}var tn=l("pi-adapter"),nn=5*6e4,on=3e4,rn=12e3;function sn(e={}){let t=new m({scan:e.scan??W,now:e.now,cacheTtlMs:e.cacheTtlMs??nn,retryMs:e.retryMs??on,key:o=>`${o.provider}\0${o.model}`,clone:o=>({...o}),logFailure:o=>tn.info(`PI provider refresh failed: ${o}`)}),n=()=>t.get();return{getProviders:()=>Array.from(new Set(n().map(o=>o.provider))),getModels:n,peekModels:()=>t.peek(),ensureModels:(o=rn)=>t.ensure(o),refresh:()=>t.refresh()}}var Ue=sn();import{copyFileSync as an,existsSync as cn}from"fs";var un=l("pi-custom-providers"),Ke=p.configPath;function Z(e){let t=y(e);return t?{top:{...t.top},endpoints:t.endpoints}:{top:{},endpoints:{}}}function Ge(e,t){if(cn(e))try{an(e,`${e}.bak`)}catch(o){un.warn(`Failed to back up ${e}: ${o.message}`)}let n=C({endpoints:t.endpoints,top:t.top,preservedCustom:[],droppedFromDiscovery:[]});v(e,n)}function Eo(e,t,n){let{endpoints:o}=Z(e);return o[t]?.[n]??null}function bo(e,t){let n=Z(e),o={base_url:t.base_url,auth_style:t.auth_style,passthrough:t.passthrough};t.keys.length>0&&(o.keys=[...t.keys]),n.endpoints[t.endpoint]={...n.endpoints[t.endpoint],[t.mode]:o},n.top.port=A(p,n.top.port),n.top.status_check??=!0,(typeof n.top.mode!="string"||n.top.mode==="")&&(n.top.mode=t.mode),Ge(e,n)}function wo(e,t,n){let o=Z(e),r=o.endpoints[t];if(!r||!(n in r))return!1;let i={...r};return delete i[n],Object.keys(i).length===0?delete o.endpoints[t]:o.endpoints[t]=i,Ge(e,o),!0}function k(e){return JSON.stringify([e.backend,e.provider,e.model])}var ln={claude:["low","medium","high","xhigh","max"],pi:["off","minimal","low","medium","high","xhigh","max"]};function dn(e,t){return ln[e]?.includes(t)??!1}var Ye=/^[a-zA-Z0-9_-]+$/;function x(e){let t=e;if(!t||t.backend!=="claude"&&t.backend!=="pi")throw new Error("Invalid backend");if(typeof t.model!="string"||!t.model.trim())throw new Error("Model must be a non-empty string");if(!(t.backend==="claude"?t.provider===null:typeof t.provider=="string"&&Ye.test(t.provider)))throw new Error("Invalid provider: PI requires a provider; Claude requires null")}function D(e){x(e);let t=e;if(t.thinking!==null&&!dn(t.backend,t.thinking))throw new Error(`Invalid thinking for backend '${t.backend}'`);if(typeof t.mode!="string"||!Ye.test(t.mode))throw new Error("Invalid mode")}function d(e){let{backend:t,provider:n,model:o,thinking:r,mode:i}=e;return{backend:t,provider:n,model:o,thinking:r,mode:i}}var ze=null;function pn(e){let t=e;if(D(t?.default),!Array.isArray(t.favorites))throw new Error("favorites must be an array");let n=new Set;for(let o of t.favorites){x(o);let r=k(o);if(n.has(r))throw new Error(`Duplicate favorite: ${o.model}`);n.add(r)}}function R(){try{let e=Q.readSync();return e!==ze&&(pn(e),ze=e),{default:d(e.default),favorites:e.favorites.map(ee)}}catch(e){throw new Error(`Failed to load models.json: ${e.message}`)}}function ee({backend:e,provider:t,model:n}){return{backend:e,provider:t,model:n}}function te(){return R().default}function Do(){return R().favorites}function We(e){let t;try{t=R()}catch{return null}if(t.default.backend===e)return t.default;let n=t.favorites.find(o=>o.backend===e);return n?fn(n):null}function fn(e){x(e);let t=Be()[k(e)];return{...ee(e),...t??{thinking:null,mode:hn(e)}}}function hn(e,t=()=>y(Ke)){if(e.backend==="pi")return e.provider;let n=t()?.endpoints?.anthropic;return Object.keys(n??{})[0]??"plan"}function mn(e){let t=e.indexOf("/");if(t<0)return null;let n={backend:"pi",provider:e.slice(0,t),model:e.slice(t+1)};return x(n),n}function gn(e,t){let o=[t.default,...t.favorites,...Ue.peekModels().map(r=>({...r,backend:"pi"}))].find(r=>r.backend==="pi"&&r.model===e);if(o)return ee(o);if(t.default.backend==="pi")return{backend:"pi",provider:t.default.provider,model:e};throw new Error(`Unknown PI model '${e}': specify provider/model or favorite a model first`)}function Ro(e,t){let n=e.trim();if(!n)throw new Error("Model must be a non-empty string");let o=mn(n);if(o)return o;let r=R();return(t??r.default.backend)==="claude"?{backend:"claude",provider:null,model:n}:gn(n,r)}import{readFileSync as yn,renameSync as _n,writeFileSync as vn}from"node:fs";import*as qe from"node:path";var re=qe.join(le,"agent-state.json");function N(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Ve(e){try{return D(e),d(e)}catch{return null}}function ne(e,t){let n=Object.entries(N(e)).map(([o,r])=>[o,t(r)]);return Object.fromEntries(n.filter(([,o])=>o!==null))}function An(e){let t=N(e);return!(t.thinking===null||typeof t.thinking=="string"&&!!t.thinking)||typeof t.mode!="string"||!t.mode?null:{thinking:t.thinking,mode:t.mode}}function oe(e){return typeof e=="string"&&e?e:null}function Je(e){let t=N(e),n={channelSelections:ne(t.channelSelections,Ve),modelMemory:ne(t.modelMemory,An),defaultAgent:oe(t.defaultAgent),channelAgents:ne(t.channelAgents,oe)},o=Ve(t.selectionDefault);if(o){n.selectionDefault=o;let r=oe(N(t.selectionDefault).agentName);r&&(n.selectionDefault.agentName=r)}return n}function ie(){try{return Je(JSON.parse(yn(re,"utf8")))}catch{return Je(null)}}function Xe(e){let t={};for(let o of["channelSelections","modelMemory","channelAgents"])Object.keys(e[o]).length&&(t[o]=e[o]);e.defaultAgent&&(t.defaultAgent=e.defaultAgent),e.selectionDefault&&(t.selectionDefault=e.selectionDefault);let n=`${re}.tmp`;vn(n,JSON.stringify(t)),_n(n,re)}var c=ie();function Ko(){c=ie()}function _(e){Xe(e),c=e}function se(e,t,n){let o={...e};return n!==null?o[t]=n:delete o[t],o}function En(e){let t=e?c.channelSelections[e]:null;return t?d(t):null}function Go(e,t){let n=t?d(t):null;_({...c,channelSelections:se(c.channelSelections,e,n)})}function Be(){return Object.fromEntries(Object.entries(c.modelMemory).map(([e,t])=>[e,{...t}]))}function Yo(e){let t={thinking:e.thinking,mode:e.mode};_({...c,modelMemory:se(c.modelMemory,k(e),t)})}function zo(){try{return We("claude")?.model??"opus"}catch{return"opus"}}function Bo(e){let t=En(e);if(t)return t.backend;try{return te().backend}catch{return"claude"}}function Wo(e){let t=e?.agentName??c.selectionDefault?.agentName,n=e?{...d(e),...t?{agentName:t}:{}}:void 0;_({...c,selectionDefault:n})}function Vo(e){let t={...c.selectionDefault??te()};e?t.agentName=e:delete t.agentName,_({...c,selectionDefault:t})}function Jo(){return c.selectionDefault?{...c.selectionDefault}:null}function qo(e){return e&&c.channelAgents[e]||c.defaultAgent}function bn(e,t){if(!t)return _({...c,defaultAgent:e});_({...c,channelAgents:se(c.channelAgents,t,e)})}function Xo(e){c.channelAgents[e]&&bn(null,e)}function Qo(){return{...c.channelAgents}}export{g as a,H as b,be as c,xe as d,Mn as e,In as f,G as g,Cn as h,Ce as i,$n as j,De as k,Vn as l,Nt as m,y as n,Jn as o,qn as p,Xn as q,Ue as r,He as s,io as t,so as u,Q as v,ao as w,co as x,Ke as y,Eo as z,bo as A,wo as B,k as C,ln as D,dn as E,x as F,D as G,Ko as H,En as I,Go as J,Be as K,Yo as L,zo as M,Bo as N,Wo as O,Vo as P,Jo as Q,qo as R,bn as S,Xo as T,Qo as U,te as V,Do as W,We as X,fn as Y,hn as Z,Ro as _};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ var s="handshake.hello",i="handshake.ack",p="session.switch",u="session.switched",c="ping",H="pong",a="close",x="chat.post",d="chat.update",f="chat.delete",l="chat.markQueued",I="msg.user",E="msg.edit",y="stream.text",S="stream.mutableOpen",T="stream.mutableUpdate",U="stream.flush",_="interactive.post",A="modal.open",m="modal.ack",R="action.click",M="modal.submit",h="transcript.replay",C="notification",O="ui.query",q="ui.queryResult",N="ui.mutate",g="ui.mutateResult",b="ui.subscribe",k="ui.event",L="ui.unsubscribe",P="error";function v(t){return t.type===s}function F(t){return t.type===i}function Q(t){return t.type===p}function B(t){return t.type===u}function V(t){return t.type===c}function K(t){return t.type===a}function j(t){return t.type===x}function w(t){return t.type===d}function G(t){return t.type===f}function Y(t){return t.type===l}function J(t){return t.type===I}function W(t){return t.type===E}function X(t){return t.type===y}function z(t){return t.type===S}function Z(t){return t.type===T}function $(t){return t.type===U}function tt(t){return t.type===_}function et(t){return t.type===A}function rt(t){return t.type===m}function nt(t){return t.type===R}function ot(t){return t.type===M}function st(t){return t.type===h}function it(t){return t.type===C}function pt(t){return t.type===O}function ut(t){return t.type===q}function ct(t){return t.type===N}function at(t){return t.type===g}function xt(t){return t.type===b}function dt(t){return t.type===k}function ft(t){return t.type===L}function lt(t){return t.type===P}var D={[s]:["protocolVersion","clientName","clientVersion"],[i]:["protocolVersion","serverVersion","conduitId","defaultProjectId","seq"],[p]:["id","projectId"],[u]:["id","projectId","sessionId","isFresh","seq"],[c]:["ts"],[H]:["ts"],[a]:[],[x]:["ref","content","seq"],[d]:["ref","content","seq"],[f]:["ref","seq"],[l]:["ref","seq"],[I]:["id","text"],[E]:["id","ref","newText"],[y]:["streamId","text","seq"],[S]:["streamId","regionId","text","seq"],[T]:["streamId","regionId","text","seq"],[U]:["streamId","seq"],[_]:["ref","content","actions","seq"],[A]:["triggerId","modal","seq"],[m]:["id","seq"],[R]:["id","actionId","value","triggerId","userId"],[M]:["id","callbackId","privateMetadata","values","userId"],[h]:["sessionId","items","seqStart","seqEnd","isCatchUp"],[C]:["kind","projectId","title","body","seq"],[O]:["id","scope"],[q]:["id","ok"],[N]:["id","op","args"],[g]:["id","ok"],[b]:["id","filter"],[k]:["id","event","seq"],[L]:["id"],[P]:["code","message"]};function It(t){let e;try{e=JSON.parse(t)}catch{return null}if(typeof e!="object"||e===null)return null;let r=e;if(typeof r.type!="string")return null;let n=D[r.type];if(!n)return null;for(let o of n)if(r[o]===void 0||r[o]===null)return null;return e}function Et(t){return JSON.stringify(t)}function St(t){return t.slice(0,8)}export{v as a,F as b,Q as c,B as d,V as e,K as f,j as g,w as h,G as i,Y as j,J as k,W as l,X as m,z as n,Z as o,$ as p,tt as q,et as r,rt as s,nt as t,ot as u,st as v,it as w,pt as x,ut as y,ct as z,at as A,xt as B,dt as C,ft as D,lt as E,It as F,Et as G,St as H};
@@ -0,0 +1,12 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{a as V,c as Q}from"./chunk-HALUQ7ZF.js";import{a as H}from"./chunk-Q4UGYGU5.js";import{c as K}from"./chunk-W5LGYSPZ.js";import{e as a}from"./chunk-E7ZMYIY6.js";import{l as W,m as X}from"./chunk-J5DVLUKY.js";import*as k from"path";import w from"node:fs/promises";var at=2160*60*60*1e3,A={daily_usd:300,monthly_usd:8e3,projects:{}};function M(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function ct(t){if(!t||typeof t!="object"||Array.isArray(t))return{};let e={};for(let[o,n]of Object.entries(t)){if(!o||!n||typeof n!="object")continue;let{daily_usd:s,monthly_usd:i}=n;!M(s)||!M(i)||(e[o]={daily_usd:s,monthly_usd:i})}return e}function ut(t){let e=t&&typeof t=="object"?t:{};return{daily_usd:M(e.daily_usd)?e.daily_usd:A.daily_usd,monthly_usd:M(e.monthly_usd)?e.monthly_usd:A.monthly_usd,projects:ct(e.projects)}}function dt(){return process.env.CORTEX_COSTS_FILE||k.join(X,"costs.jsonl")}function lt(){return process.env.CORTEX_BUDGET_FILE||k.join(W,"budget.json")}var z=class{costMutex=new H;_ready=!1;_cache=null;_budgetRepo=null;_costsPath;_budgetPath;constructor(e={}){this._costsPath=e.costsPath??null,this._budgetPath=e.budgetPath??null}get costFilePath(){return this._costsPath??dt()}get budgetRepo(){return this._budgetRepo||(this._budgetRepo=new Q({filePath:this._budgetPath??lt(),defaultValue:()=>({...A,projects:{}}),migrate:ut})),this._budgetRepo}async _ensureReady(){if(this._ready)return;let e=this.costFilePath;await w.mkdir(k.dirname(e),{recursive:!0});let o=await this._readFileEntries(e),n=Date.now()-at,s=o.filter(i=>new Date(i.timestamp).getTime()>n);if(s.length<o.length){let i=s.map(c=>JSON.stringify(c)).join(`
5
+ `)+`
6
+ `;await K(e,i)}this._ready=!0}async _readEntriesRange(e,o,n){if(n<=o)return{entries:[],consumedTo:o};let s=await w.open(e,"r");try{let i=Buffer.allocUnsafe(n-o),{bytesRead:c}=await s.read(i,0,i.length,o),u=c>0?i.lastIndexOf(10,c-1):-1;return u<0?{entries:[],consumedTo:o}:{entries:i.toString("utf8",0,u+1).split(`
7
+ `).filter(h=>h.trim()!=="").map(h=>JSON.parse(h)),consumedTo:o+u+1}}finally{await s.close()}}async _readFileEntries(e){try{return(await w.readFile(e,"utf8")).split(`
8
+ `).filter(n=>n.trim()!=="").map(n=>JSON.parse(n))}catch(o){if(o.code==="ENOENT")return[];throw o}}async recordEntry(e){await this.costMutex.run(async()=>{await this._ensureReady(),await w.appendFile(this.costFilePath,JSON.stringify(e)+`
9
+ `,"utf8")})}async recordEntryBatch(e){if(e.length===0)return;let o=e.map(n=>JSON.stringify(n)).join(`
10
+ `)+`
11
+ `;await this.costMutex.run(async()=>{await this._ensureReady(),await w.appendFile(this.costFilePath,o,"utf8")})}async readCosts(){await this._ensureReady();let e=this.costFilePath,o,n,s;try{let d=await w.stat(e);o=d.ino,n=d.size,s=d.mtimeMs}catch(d){if(d.code!=="ENOENT")throw d;return this._cache=null,{entries:[]}}let i=this._cache?.path===e&&this._cache.ino===o?this._cache:null;if(i&&n===i.size&&s===i.mtimeMs)return{entries:i.entries.slice()};if(i&&n>i.size){let{entries:d,consumedTo:h}=await this._readEntriesRange(e,i.size,n),l=i.entries.concat(d);return this._cache={path:e,ino:o,size:h,mtimeMs:s,entries:l},{entries:l.slice()}}let{entries:c,consumedTo:u}=await this._readEntriesRange(e,0,n);return this._cache={path:e,ino:o,size:u,mtimeMs:s,entries:c},{entries:c.slice()}}async readBudget(){return this.budgetRepo.read()}async writeBudget(e){await this.budgetRepo.write(e)}invalidateBudget(){this._budgetRepo?.invalidate()}async flush(){await this.costMutex.run(async()=>{}),this._budgetRepo&&await this._budgetRepo.flush()}_testReset(){this._budgetRepo=null,this._ready=!1,this._cache=null}},y=new z;V(y);function ht(t,e){let o=e?t.projects?.[e]:void 0;return o?{daily_usd:o.daily_usd,monthly_usd:o.monthly_usd,scope:"project"}:{daily_usd:t.daily_usd,monthly_usd:t.monthly_usd,scope:"global"}}var yt=["total","api","plan"];function st(t){return t==="plan"?"plan":"api"}function j(){return{today:0,week:0,month:0,total:0}}function E(){return Object.fromEntries(yt.map(t=>[t,0]))}function O(t,e,o){t.total+=o,t[e]+=o}async function Rt(t){let e=t.source||"estimate",o=[t.input_tokens,t.output_tokens,t.cache_read_tokens,t.cache_creation_tokens,t.provider_requests].some(s=>s!=null);if(e==="estimate"&&!t.cost_usd&&!o)return;let n={timestamp:new Date().toISOString(),project:t.project||"general",trigger:t.trigger||"unknown",cost_usd:t.cost_usd??null,num_turns:t.num_turns??null,duration_s:t.duration_s??null,backend:t.backend||"claude",mode:st(t.mode),source:e,input_tokens:t.input_tokens??null,output_tokens:t.output_tokens??null,cache_read_tokens:t.cache_read_tokens??null,cache_creation_tokens:t.cache_creation_tokens??null,provider_requests:Number.isSafeInteger(t.provider_requests)&&Number(t.provider_requests)>0?t.provider_requests:null,session_id:t.session_id??null,execution_id:t.execution_id??null,attempt_id:t.attempt_id??null,root_attempt_id:t.root_attempt_id??null,trial_id:t.trial_id??null,root_run_id:t.root_run_id??null};t.prompt_tokens!==void 0&&(n.prompt_tokens=t.prompt_tokens),t.provider&&(n.provider=t.provider),t.model&&(n.model=t.model),await y.recordEntry(n)}function L(){return{input:0,output:0}}var Z=1440*60*1e3,mt=14;function tt(t){let e=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${o}-${n}`}function S(t,e,o,n,s){t.total+=e,o&&(t.today+=e),n&&(t.week+=e),s&&(t.month+=e)}async function it(t,e){let o=await y.readCosts(),n=await y.readBudget(),s=e?.now??Date.now(),i=new Date(s);i.setHours(0,0,0,0);let c=new Date(s-7*Z),u=new Date(s);u.setDate(1),u.setHours(0,0,0,0);let d=[];for(let r=mt-1;r>=0;r--){let p=new Date(i);p.setDate(p.getDate()-r),d.push(tt(p))}let h=new Map(d.map(r=>[r,0])),l={today:E(),week:E(),month:E(),total:E()},B={},x={},R={},F={},T={},_={today:L(),month:L(),total:L()},Y=0,q=0;for(let r of o.entries){let p=st(r.mode),m=r.cost_usd||0,v=r.source||"estimate",$=r.backend||"claude",P=new Date(r.timestamp),f=P>=i,b=P>=c,g=P>=u;if(!t||r.project===t){Y++,r.cost_usd==null&&q++,O(l.total,p,m),f&&O(l.today,p,m),b&&O(l.week,p,m),g&&O(l.month,p,m);let C=Object.hasOwn(r,"prompt_tokens")?r.prompt_tokens||0:r.input_tokens||0,N=r.output_tokens||0;_.total.input+=C,_.total.output+=N,f&&(_.today.input+=C,_.today.output+=N),g&&(_.month.input+=C,_.month.output+=N);let I=tt(P);h.has(I)&&h.set(I,h.get(I)+m),R[r.trigger]||(R[r.trigger]=j()),S(R[r.trigger],m,f,b,g)}B[r.project]||(B[r.project]=j()),x[r.trigger]||(x[r.trigger]=j()),F[v]||(F[v]=j()),T[$]||(T[$]=j()),S(B[r.project],m,f,b,g),S(x[r.trigger],m,f,b,g),S(F[v],m,f,b,g),S(T[$],m,f,b,g)}let U=l.today.total,G=(s-i.getTime())/Z,rt=G>0?U/G:U,D=ht(n,t);return{today:l.today.total,week:l.week.total,month:l.month.total,total:l.total.total,byMode:l,byProject:B,byTrigger:x,bySource:F,byBackend:T,tokens:_,entryCount:Y,unpricedCount:q,dailyBudget:D.daily_usd,monthlyBudget:D.monthly_usd,budgetScope:D.scope,forecastToday:rt,dailyCost:d.map(r=>({date:r,cost:h.get(r)})),byTriggerScoped:R}}async function Ft(t){let e=t??null,o=await it(e),{dailyBudget:n,monthlyBudget:s}=o;return{withinBudget:o.today<n&&o.month<s,dailyBudget:n,dailySpent:o.today,dailyRemaining:Math.max(0,n-o.today),monthlyBudget:s,monthlySpent:o.month,monthlyRemaining:Math.max(0,s-o.month),byMode:o.byMode,project:e,scope:o.budgetScope}}async function Tt({daily_usd:t,monthly_usd:e,project:o}){let n=await y.readBudget();if(o){if(t==null||e==null)throw Object.assign(new Error("A per-project budget must set both daily and monthly limits"),{code:"invalid-args"});return n.projects={...n.projects,[o]:{daily_usd:t,monthly_usd:e}},await y.writeBudget(n),{daily_usd:t,monthly_usd:e,scope:"project"}}return t!=null&&(n.daily_usd=t),e!=null&&(n.monthly_usd=e),await y.writeBudget(n),{daily_usd:n.daily_usd,monthly_usd:n.monthly_usd,scope:"global"}}async function Pt(t){let e=await y.readBudget();if(!e.projects?.[t])return!1;let{[t]:o,...n}=e.projects;return e.projects=n,await y.writeBudget(e),!0}async function Mt(){let t=await y.readBudget();return Object.entries(t.projects??{}).map(([e,o])=>({project:e,...o})).sort((e,o)=>e.project.localeCompare(o.project))}function et(t,e){return{today:t.today[e],week:t.week[e],month:t.month[e],total:t.total[e]}}function ot(t,e){return` - ${a("notice.cost.modeLine",{label:t,today:e.today.toFixed(2),week:e.week.toFixed(2),month:e.month.toFixed(2),total:e.total.toFixed(2)})}`}function nt(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function pt(t,e){return`\u2022 ${a("notice.cost.statsLine",{name:t,today:e.today.toFixed(2),month:e.month.toFixed(2),total:e.total.toFixed(2)})}`}function J(t,e,o){t.push(""),t.push(`_${e}_`);for(let[n,s]of Object.entries(o).sort((i,c)=>c[1].total-i[1].total))t.push(pt(n,s))}function _t(t,e){if(!t)return`*${a("notice.cost.title")}*`;let o=e==="project"?a("notice.cost.scopeProject"):a("notice.cost.scopeInherited");return`*${a("notice.cost.titleProject",{project:t})}* _(${o})_`}async function Et(t=null){let e=await it(t),o=Math.max(0,e.dailyBudget-e.today),n=Math.max(0,e.monthlyBudget-e.month),s=[];s.push(_t(t,e.budgetScope)),s.push(`\u2022 ${a("notice.cost.today",{spent:e.today.toFixed(2),budget:e.dailyBudget,remaining:o.toFixed(2)})}`),s.push(`\u2022 ${a("notice.cost.month",{spent:e.month.toFixed(2),budget:e.monthlyBudget,remaining:n.toFixed(2)})}`),s.push(`\u2022 ${a("notice.cost.week",{spent:e.week.toFixed(2)})}`),s.push(`\u2022 ${a("notice.cost.total",{spent:e.total.toFixed(2)})}`),s.push(""),s.push(`_${a("notice.cost.byMode")}_`),s.push(ot("API",et(e.byMode,"api"))),s.push(ot("Plan",et(e.byMode,"plan"))),Object.keys(e.bySource).length>0&&J(s,a("notice.cost.bySource"),e.bySource),"pi"in e.byBackend&&J(s,a("notice.cost.byBackend"),e.byBackend);let i=e.tokens;if(i.total.input>0||i.total.output>0){s.push(""),s.push(`_${a("notice.cost.tokenUsage")}_`);for(let[c,u]of[["notice.cost.tokensToday",i.today],["notice.cost.tokensMonth",i.month],["notice.cost.tokensTotal",i.total]])s.push(`\u2022 ${a(c,{input:nt(u.input),output:nt(u.output)})}`)}if(!t&&Object.keys(e.byProject).length>0){s.push(""),s.push(`_${a("notice.cost.byProject")}_`);for(let[c,u]of Object.entries(e.byProject).sort((d,h)=>h[1].month-d[1].month))s.push(`\u2022 ${a("notice.cost.projectLine",{name:c,today:u.today.toFixed(2),month:u.month.toFixed(2)})}`)}return Object.keys(e.byTrigger).length>0&&J(s,a("notice.cost.byTrigger"),e.byTrigger),s.join(`
12
+ `)}export{y as a,Rt as b,it as c,Ft as d,Tt as e,Pt as f,Mt as g,nt as h,Et as i};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ import{b as e}from"./chunk-OSEIQ7SS.js";var r;function i(t){r=t}var n=()=>e(async()=>r??await import("./bedrock-converse-stream-5UPX4NTQ.js"));export{i as a,n as b};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ function F(u){return u.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}export{F as a};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cortexCreateRequire } from 'node:module';
2
+ const require = __cortexCreateRequire(import.meta.url);
3
+ const __cortexPackageRoot = new URL("../../", import.meta.url);
4
+ function a(i){let t=3735928559,h=1103547991;for(let e=0;e<i.length;e++){let l=i.charCodeAt(e);t=Math.imul(t^l,2654435761),h=Math.imul(h^l,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(h^h>>>13,3266489909),h=Math.imul(h^h>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(h>>>0).toString(36)+(t>>>0).toString(36)}export{a};