sliccy 6.232.1 → 6.232.2

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 (150) hide show
  1. package/dist/ui/.vite/manifest.json +182 -182
  2. package/dist/ui/assets/{account-store-B9NAiCud.js → account-store-B857f9Kw.js} +1 -1
  3. package/dist/ui/assets/{account-store-BjfGeTTt.js → account-store-C8W_QB2_.js} +1 -1
  4. package/dist/ui/assets/{adobe-Bz-ZNRYT.js → adobe-C2NABnF7.js} +1 -1
  5. package/dist/ui/assets/{adobe-Djo2u4ZW.js → adobe-hInWK-RG.js} +1 -1
  6. package/dist/ui/assets/{agent-panels-CP61MyvH.js → agent-panels-DjIYV1_V.js} +1 -1
  7. package/dist/ui/assets/{almost-bash-shell-headless-CSew1mj5.js → almost-bash-shell-headless-Cr-YVYbG.js} +27 -27
  8. package/dist/ui/assets/{apply-layout-C5tkEPIw.js → apply-layout-6y46WnDn.js} +1 -1
  9. package/dist/ui/assets/{apps-Dp0TUE_0.js → apps-DkZBf0EF.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-JkY4uYkc.js → azure-openai-BPC12gr1.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-CzOmuJGM.js → azure-openai-DaGSGR26.js} +1 -1
  12. package/dist/ui/assets/{backend-hostfs-DoiWbvcu.js → backend-hostfs-CyFczT_n.js} +1 -1
  13. package/dist/ui/assets/{cdp-38zgn7rv.js → cdp-Cp2ul1Xk.js} +1 -1
  14. package/dist/ui/assets/{cerebras-DTSHi-Ie.js → cerebras-BEDSf9Z2.js} +1 -1
  15. package/dist/ui/assets/{cerebras-j4mzqJoZ.js → cerebras-CAFxbAAH.js} +1 -1
  16. package/dist/ui/assets/{composer-speech-BeeuLGg2.js → composer-speech-BveIVRUb.js} +1 -1
  17. package/dist/ui/assets/{connect-surface-CeR_GM7x.js → connect-surface-ogo7Rv2Y.js} +1 -1
  18. package/dist/ui/assets/{directed-approval-CX_HvwXp.js → directed-approval-BoAbm3IJ.js} +1 -1
  19. package/dist/ui/assets/{emscripten-vfs-hook-CD4XHFnz.js → emscripten-vfs-hook-CYIDH-AN.js} +1 -1
  20. package/dist/ui/assets/{ensure-speech-assets-D_Xx-dcP.js → ensure-speech-assets-BvTOfAF9.js} +1 -1
  21. package/dist/ui/assets/{frozen-archive-writer-B2hU8rG5.js → frozen-archive-writer-Ce13R-3M.js} +1 -1
  22. package/dist/ui/assets/{fs-B-LLf0bG.js → fs-Bl4-flxd.js} +2 -2
  23. package/dist/ui/assets/{fs-BWRHmpI5.js → fs-CXdlfm9I.js} +1 -1
  24. package/dist/ui/assets/{gelatiere-unit-CSTPHfIX.js → gelatiere-unit-Cr5wm_Kg.js} +1 -1
  25. package/dist/ui/assets/{github-9cbMQjmV.js → github-DBc_eOzS.js} +2 -2
  26. package/dist/ui/assets/{github-j3XObHP4.js → github-DELN8f0M.js} +1 -1
  27. package/dist/ui/assets/{github-auth-BZVZ7x8a.js → github-auth-D7J-BVhH.js} +1 -1
  28. package/dist/ui/assets/{github-copilot-CoY3bmiB.js → github-copilot-D7W2tJJz.js} +1 -1
  29. package/dist/ui/assets/{github-copilot-BpQfJba9.js → github-copilot-kJD8s7l4.js} +1 -1
  30. package/dist/ui/assets/{github-install-D1o7qomc.js → github-install-Day-m9Yr.js} +1 -1
  31. package/dist/ui/assets/{github-zip-CF_1Mtat.js → github-zip-xnabOe2b.js} +1 -1
  32. package/dist/ui/assets/{go-driver-DKvMuQ4C.js → go-driver-xTPUsgZ_.js} +1 -1
  33. package/dist/ui/assets/{hear-BDEEoiSx.js → hear-CdqoxknG.js} +1 -1
  34. package/dist/ui/assets/{help-Dmz0iRDg.js → help-B1T-o5sr.js} +1 -1
  35. package/dist/ui/assets/{installer-vW0yDgjr.js → installer-Ce066nKI.js} +1 -1
  36. package/dist/ui/assets/{ipk-mamba-COgtFryU.js → ipk-mamba-fKbu5XN4.js} +1 -1
  37. package/dist/ui/assets/{js-realm-worker-b9Yx9oEC.js → js-realm-worker-DluaIwWT.js} +2 -2
  38. package/dist/ui/assets/{jsh-executor-By4DIUnQ.js → jsh-executor-D3BSRLFA.js} +2 -2
  39. package/dist/ui/assets/{kernel-worker-Cvf_O6Kr.js → kernel-worker-M218S0e9.js} +9 -9
  40. package/dist/ui/assets/{lick-ws-bridge-Bn8djfxu.js → lick-ws-bridge-B0AqTybW.js} +1 -1
  41. package/dist/ui/assets/{lick-ws-bridge-CIDrcFiD.js → lick-ws-bridge-k53YqSiL.js} +1 -1
  42. package/dist/ui/assets/{live-session-curation-kO8HahKE.js → live-session-curation-DtmCoogl.js} +1 -1
  43. package/dist/ui/assets/{live-session-snapshot-CabSfB3u.js → live-session-snapshot-CzH5VyWG.js} +1 -1
  44. package/dist/ui/assets/{local-llm-BncDAj1R.js → local-llm-BYFR1wMj.js} +1 -1
  45. package/dist/ui/assets/{local-llm-sQhI3SXN.js → local-llm-CUTYS-aa.js} +1 -1
  46. package/dist/ui/assets/{main-DFzXj4Ap.js → main-CxkrqswY.js} +3 -3
  47. package/dist/ui/assets/{main-cherry-DjaHu26a.js → main-cherry-DnV2EtCt.js} +1 -1
  48. package/dist/ui/assets/{mcp-command-BQXcGbwB.js → mcp-command-BoGKsJ--.js} +12 -12
  49. package/dist/ui/assets/{memory-curation-seam-B_qGv6QI.js → memory-curation-seam-CLon6-0I.js} +1 -1
  50. package/dist/ui/assets/{memory-health-Cr7zxx4A.js → memory-health-B8JnBJZW.js} +1 -1
  51. package/dist/ui/assets/{memory-write-execute-U7BM-a7_.js → memory-write-execute-D-eE12zu.js} +1 -1
  52. package/dist/ui/assets/{merge-folded-cost-into-frozen-DIIPiCza.js → merge-folded-cost-into-frozen-Cv81Es_U.js} +1 -1
  53. package/dist/ui/assets/{mount-CV-BVSM3.js → mount-DvlJAh57.js} +1 -1
  54. package/dist/ui/assets/{mount-D70lNd1N.js → mount-H5EgXlPD.js} +3 -3
  55. package/dist/ui/assets/{new-session-CQAuY4KE.js → new-session-DW8XeVxp.js} +2 -2
  56. package/dist/ui/assets/{oauth-bootstrap-BaNDvFJl.js → oauth-bootstrap-BNFgdYgz.js} +2 -2
  57. package/dist/ui/assets/{onboarding-orchestrator-CeGSoBBd.js → onboarding-orchestrator-Ca--LViR.js} +1 -1
  58. package/dist/ui/assets/{openai-codex-AiKZcdM6.js → openai-codex-BUS22UvF.js} +1 -1
  59. package/dist/ui/assets/{openai-codex-D8h522X1.js → openai-codex-CVRDijVn.js} +1 -1
  60. package/dist/ui/assets/{openrouter-w4y3GCPU.js → openrouter-CNys7eBu.js} +1 -1
  61. package/dist/ui/assets/{openrouter-D4UvvWjX.js → openrouter-DaY_PmOO.js} +1 -1
  62. package/dist/ui/assets/{openrouter-free-Dpl6B5fH.js → openrouter-free-CLv2guAs.js} +1 -1
  63. package/dist/ui/assets/{openrouter-free-Jo6JUMdn.js → openrouter-free-DLoVUZYB.js} +1 -1
  64. package/dist/ui/assets/{openrouter-oauth-BzcBCIMl.js → openrouter-oauth-Dy_qCqcN.js} +1 -1
  65. package/dist/ui/assets/{openrouter-oauth-CPpLFF4m.js → openrouter-oauth-YeISAtXv.js} +1 -1
  66. package/dist/ui/assets/{opfs-mount-CEISbLdP.js → opfs-mount-cbV6hAiM.js} +1 -1
  67. package/dist/ui/assets/{panel-rpc-handlers-COj4LAbm.js → panel-rpc-handlers-BNEtTGhT.js} +2 -2
  68. package/dist/ui/assets/{panelize-shell-gHzxRw9h.js → panelize-shell-zDW06WQ9.js} +1 -1
  69. package/dist/ui/assets/{pi-edit-execution-B-htZMe7.js → pi-edit-execution-Blmvyfch.js} +1 -1
  70. package/dist/ui/assets/{process-worker-BXcmjjns.js → process-worker-BKgTk6Wd.js} +1 -1
  71. package/dist/ui/assets/{provider-DqfbNx1g.js → provider-L54O0b3P.js} +1 -1
  72. package/dist/ui/assets/{provider-DV5A_7IM.js → provider-MDIcOntz.js} +2 -2
  73. package/dist/ui/assets/{provider-settings--5JFkAeb.js → provider-settings-5llrPtIb.js} +1 -1
  74. package/dist/ui/assets/provider-store-access-nagoWWb1.js +1 -0
  75. package/dist/ui/assets/provider-store-access-wdRnmqbS.js +1 -0
  76. package/dist/ui/assets/{providers-DRXtGsiH.js → providers-DSWENZNJ.js} +1 -1
  77. package/dist/ui/assets/{providers-DdxfStbH.js → providers-jygoVQBo.js} +2 -2
  78. package/dist/ui/assets/{quick-llm-BC2oDrme.js → quick-llm-D6Wr4TyZ.js} +1 -1
  79. package/dist/ui/assets/{realm-inprocess-9LFGFCcK.js → realm-inprocess-s4ChFcqp.js} +2 -2
  80. package/dist/ui/assets/{realm-unhandled-rejections-CAczZ0N0.js → realm-unhandled-rejections-BAiAaesU.js} +1 -1
  81. package/dist/ui/assets/{realm-unhandled-rejections-aM-BvJZR.js → realm-unhandled-rejections-Bju1msWn.js} +1 -1
  82. package/dist/ui/assets/{recovery-screen-ZhIfXWHL.js → recovery-screen-DLmHqUsS.js} +1 -1
  83. package/dist/ui/assets/{remote-terminal-view-BQ8uaUim.js → remote-terminal-view-WWBk5qFn.js} +2 -2
  84. package/dist/ui/assets/{restore-CTCRzvNh.js → restore-DTlvxkxE.js} +1 -1
  85. package/dist/ui/assets/{run-B8IAldKH.js → run-9qBbvzkW.js} +1 -1
  86. package/dist/ui/assets/{run-DuqDZMb3.js → run-BKv0GiVy.js} +1 -1
  87. package/dist/ui/assets/{run-CVZ8dV9Z.js → run-Bo0rlg63.js} +2 -2
  88. package/dist/ui/assets/{run-D7w8ut3l.js → run-CRimkv1y.js} +2 -2
  89. package/dist/ui/assets/{run-DemKXbNO.js → run-D31zYxYd.js} +1 -1
  90. package/dist/ui/assets/{run-g-X3dTSo.js → run-dFcc7q5n.js} +1 -1
  91. package/dist/ui/assets/{session-command-memory-wRVMs4Tj.js → session-command-memory-Df5JM1jy.js} +2 -2
  92. package/dist/ui/assets/{session-jsonl-BMe2gRCP.js → session-jsonl-CRg856OA.js} +1 -1
  93. package/dist/ui/assets/{session-jsonl-jHmA3Z8R.js → session-jsonl-DyYSpiR3.js} +1 -1
  94. package/dist/ui/assets/{session-search-index-CPxHdFiO.js → session-search-index-CxeajBYy.js} +1 -1
  95. package/dist/ui/assets/{setup-feature-flags-remote-CLK9RQld.js → setup-feature-flags-remote-B7EvE5WG.js} +1 -1
  96. package/dist/ui/assets/{setup-model-catalog-DzoZIXjc.js → setup-model-catalog-CojuaZXL.js} +1 -1
  97. package/dist/ui/assets/{signed-fetch-BYlgbN5-.js → signed-fetch-C1-081oc.js} +1 -1
  98. package/dist/ui/assets/{silent-renew-backoff-C_5vt7WN.js → silent-renew-backoff-BJestVXs.js} +1 -1
  99. package/dist/ui/assets/slicc-version-B0t7wsNA.js +1 -0
  100. package/dist/ui/assets/{snapshot-CRzAt7FE.js → snapshot-Cb2BkTl8.js} +1 -1
  101. package/dist/ui/assets/{snapshot-features-Dl5OZRRD.js → snapshot-features-CttxuZRc.js} +1 -1
  102. package/dist/ui/assets/{soundscape-B5wl6uNe.js → soundscape-CGPRupA1.js} +1 -1
  103. package/dist/ui/assets/{speak-CsDBSFSc.js → speak-CwevwRGG.js} +1 -1
  104. package/dist/ui/assets/{sprinkle-manager-ByegzK4g.js → sprinkle-manager-nQ3MRYze.js} +1 -1
  105. package/dist/ui/assets/{sprinkle-renderer-DEvWTy4j.js → sprinkle-renderer-DQe4_ykh.js} +1 -1
  106. package/dist/ui/assets/{state-UjVstscY.js → state-CRuL5BZp.js} +1 -1
  107. package/dist/ui/assets/{store-jaaK6Occ.js → store-Ct6T8_vC.js} +1 -1
  108. package/dist/ui/assets/{store-uM0i8Poo.js → store-N9OMacY2.js} +1 -1
  109. package/dist/ui/assets/{sudo-DhuLhnRd.js → sudo-CVBz7Hub.js} +1 -1
  110. package/dist/ui/assets/{supervisor-C1NKlIKp.js → supervisor-d43UzH63.js} +1 -1
  111. package/dist/ui/assets/{sync-dialog-yG1Kj0Ua.js → sync-dialog-DFEhMgmr.js} +1 -1
  112. package/dist/ui/assets/{transformers-env-CXVElXgN.js → transformers-env-BVWRXJj7.js} +1 -1
  113. package/dist/ui/assets/{tray-leader-B4LxY7F_.js → tray-leader-DjSQqusA.js} +1 -1
  114. package/dist/ui/assets/{tray-leave-runtime-CAdFVkVo.js → tray-leave-runtime-CZ1DjZNm.js} +1 -1
  115. package/dist/ui/assets/{tray-sidecar-C8CforeJ.js → tray-sidecar-CjNuAx0_.js} +1 -1
  116. package/dist/ui/assets/{upgrade-detection-QfynQMyL.js → upgrade-detection-j5O1jpk-.js} +1 -1
  117. package/dist/ui/assets/{upskill-lick-skip-B1oh3KFo.js → upskill-lick-skip-D9rXamQ_.js} +1 -1
  118. package/dist/ui/assets/{voice-reply-2rym12dk.js → voice-reply-DDhoSB_B.js} +1 -1
  119. package/dist/ui/assets/{wasi-runtime-DpCCpScc.js → wasi-runtime-Bc01Bdaa.js} +2 -2
  120. package/dist/ui/assets/{wc-attach-8DvAlvRk.js → wc-attach-VJjD6tJb.js} +2 -2
  121. package/dist/ui/assets/{wc-browser-Cc0wc7sK.js → wc-browser-H9i1tYs2.js} +1 -1
  122. package/dist/ui/assets/{wc-computers-D2WMYpRs.js → wc-computers-CZVMeb1a.js} +1 -1
  123. package/dist/ui/assets/{wc-detached-BYrJv1Pi.js → wc-detached-C3w-EnO2.js} +1 -1
  124. package/dist/ui/assets/{wc-extension-bGGA59Lc.js → wc-extension-BaXTVkwH.js} +2 -2
  125. package/dist/ui/assets/{wc-follower-BEFn4tDO.js → wc-follower-B2K4I2jj.js} +3 -3
  126. package/dist/ui/assets/{wc-follower-oauth-BITU1r1m.js → wc-follower-oauth-Dpz6kwmb.js} +1 -1
  127. package/dist/ui/assets/{wc-gelatiere-DpUliuo8.js → wc-gelatiere-DUqsrBPY.js} +1 -1
  128. package/dist/ui/assets/{wc-live-B3xfspeg.js → wc-live-DPQeITgQ.js} +5 -5
  129. package/dist/ui/assets/{wc-nav-BvM4z5jU.js → wc-nav-DKr3h3r5.js} +2 -2
  130. package/dist/ui/assets/{wc-onboarding-Cj-8agbG.js → wc-onboarding-nZO6VPxy.js} +2 -2
  131. package/dist/ui/assets/{wc-permissions-DC3jkato.js → wc-permissions-BncUPK23.js} +2 -2
  132. package/dist/ui/assets/{wc-placeholder-DLtjzvI2.js → wc-placeholder-D8F3dotr.js} +3 -3
  133. package/dist/ui/assets/{wc-secret-request-mkhCBMcE.js → wc-secret-request-BAhfbP9J.js} +1 -1
  134. package/dist/ui/assets/{wc-settings-MSj3TwSP.js → wc-settings-BnJRa_R9.js} +3 -3
  135. package/dist/ui/assets/{wc-shell-CjZMoCV4.js → wc-shell-BzYq0ESt.js} +3 -3
  136. package/dist/ui/assets/{wc-shortcut-config-D8qtJaB9.js → wc-shortcut-config-Dyjf2Wvu.js} +1 -1
  137. package/dist/ui/assets/{wc-sprinkles-CWh_QyqB.js → wc-sprinkles-qa2Yk76b.js} +2 -2
  138. package/dist/ui/assets/{wc-transcript-export-C4au4GRp.js → wc-transcript-export-Bk8nLIfQ.js} +2 -2
  139. package/dist/ui/assets/{wc-tray-Crx_RosL.js → wc-tray-BEN7TcmV.js} +4 -4
  140. package/dist/ui/assets/welcome-detection-DUIoHDqJ.js +1 -0
  141. package/dist/ui/assets/{whisper-session-DVySo8di.js → whisper-session-xH7lWXSW.js} +2 -2
  142. package/dist/ui/assets/{xai-grok-Dw3U-q7x.js → xai-grok-B11VgjUo.js} +1 -1
  143. package/dist/ui/assets/{xai-grok-BK3Rrluc.js → xai-grok-DgGOq90R.js} +1 -1
  144. package/dist/ui/index.html +3 -3
  145. package/dist/ui/packages/webapp/index.html +3 -3
  146. package/package.json +1 -1
  147. package/dist/ui/assets/provider-store-access-Dtozn27m.js +0 -1
  148. package/dist/ui/assets/provider-store-access-Dzd2VXlw.js +0 -1
  149. package/dist/ui/assets/slicc-version-BQjDBKr6.js +0 -1
  150. package/dist/ui/assets/welcome-detection-H8o_tuf3.js +0 -1
@@ -42,16 +42,16 @@ Options:
42
42
  server. Modes: codemode (default), codemode-deferred,
43
43
  deferred, direct, hidden. codemode-deferred is an alias
44
44
  for codemode.
45
- `);let n=r(e,{value:[`--exposure`]});if(`error`in n)return g(n.error);if(n.positionals.length<2)return h(`mcp add: expected <url> <name>`);let[a,o]=n.positionals,s=n.values.get(`--exposure`);if(s&&!c.has(s))return h(`mcp add: invalid exposure mode "${s}" (valid: ${[...c].join(`, `)})`);let l=s;if(!/^https?:\/\//i.test(a))return h(`mcp add: invalid URL "${a}" (must start with http:// or https://)`);if(!d(o))return h(`mcp add: invalid name "${o}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:u,listServers:f,setServer:_}=await import(`./store-uM0i8Poo.js`).then(e=>e.r);if(await u(o,t.fs))return h(`mcp add: a server named "${o}" already exists`);let v=o.replace(/[^A-Za-z0-9_]/g,`_`),y=Object.keys(await f(t.fs)).find(e=>e.replace(/[^A-Za-z0-9_]/g,`_`)===v);if(y)return h(`mcp add: server "${o}" conflicts with "${y}" after name normalization`);let{McpClient:x,McpAuthRequiredError:S}=await import(`./client-DWx5wn8j.js`),C=new x({url:a,fetchImpl:t.fetchImpl}),w;try{await C.initialize()}catch(e){if(!(e instanceof S))throw e;w=await b(a,o,e.resourceMetadataUrl,t),C=new x({url:a,fetchImpl:t.fetchImpl,getAuthHeader:()=>Y(o)}),await C.initialize()}let T=await C.toolsList(),E=await C.appsList(),D=new Date().toISOString(),O={url:a,protocolVersion:C.getNegotiatedProtocolVersion(),tools:T,apps:E,addedAt:D,lastRefreshedAt:D,...w?{auth:w}:{},...l?{exposure:l}:{}};await _(o,O,t.fs),await Q(o,t);let k=await $(o,E,t);if(w){let{registerMcpProvider:e}=await import(`./provider-DqfbNx1g.js`);e({name:o,serverUrl:a,auth:w})}return t.connectionManager&&await t.connectionManager.connect(o,O),m([`Added MCP server "${o}" → ${a}`,` tools: ${T.length}, apps: ${E.length} (${k} sprinkle${k===1?``:`s`})`,` alias: ${p}/${o}.jsh`,w?` auth: oauth (provider mcp:${o})`:` auth: none`,l?` exposure: ${l}`:` exposure: codemode (default)`].join(`
45
+ `);let n=r(e,{value:[`--exposure`]});if(`error`in n)return g(n.error);if(n.positionals.length<2)return h(`mcp add: expected <url> <name>`);let[a,o]=n.positionals,s=n.values.get(`--exposure`);if(s&&!c.has(s))return h(`mcp add: invalid exposure mode "${s}" (valid: ${[...c].join(`, `)})`);let l=s;if(!/^https?:\/\//i.test(a))return h(`mcp add: invalid URL "${a}" (must start with http:// or https://)`);if(!d(o))return h(`mcp add: invalid name "${o}" (letters, digits, _ and - only; must start with a letter)`);let{getServer:u,listServers:f,setServer:_}=await import(`./store-N9OMacY2.js`).then(e=>e.r);if(await u(o,t.fs))return h(`mcp add: a server named "${o}" already exists`);let v=o.replace(/[^A-Za-z0-9_]/g,`_`),y=Object.keys(await f(t.fs)).find(e=>e.replace(/[^A-Za-z0-9_]/g,`_`)===v);if(y)return h(`mcp add: server "${o}" conflicts with "${y}" after name normalization`);let{McpClient:x,McpAuthRequiredError:S}=await import(`./client-DWx5wn8j.js`),C=new x({url:a,fetchImpl:t.fetchImpl}),w;try{await C.initialize()}catch(e){if(!(e instanceof S))throw e;w=await b(a,o,e.resourceMetadataUrl,t),C=new x({url:a,fetchImpl:t.fetchImpl,getAuthHeader:()=>Y(o)}),await C.initialize()}let T=await C.toolsList(),E=await C.appsList(),D=new Date().toISOString(),O={url:a,protocolVersion:C.getNegotiatedProtocolVersion(),tools:T,apps:E,addedAt:D,lastRefreshedAt:D,...w?{auth:w}:{},...l?{exposure:l}:{}};await _(o,O,t.fs),await Q(o,t);let k=await $(o,E,t);if(w){let{registerMcpProvider:e}=await import(`./provider-L54O0b3P.js`);e({name:o,serverUrl:a,auth:w})}return t.connectionManager&&await t.connectionManager.connect(o,O),m([`Added MCP server "${o}" → ${a}`,` tools: ${T.length}, apps: ${E.length} (${k} sprinkle${k===1?``:`s`})`,` alias: ${p}/${o}.jsh`,w?` auth: oauth (provider mcp:${o})`:` auth: none`,l?` exposure: ${l}`:` exposure: codemode (default)`].join(`
46
46
  `)+`
47
- `)}async function b(e,n,r,i){let{discoverAuth:a,dynamicRegister:s,runAuthFlow:c}=await import(`./oauth-D20BEoY6.js`),{saveOAuthAccount:u}=await import(`./account-store-BjfGeTTt.js`).then(e=>e.t),d=await re(i.oauthFetchImpl),f=i.oauthLauncher??await X(),p=await a(e,r,d);l.debug(`MCP OAuth discovery succeeded`,{name:n,serverUrl:e,discoveryPath:p.discoveryPath,issuer:p.issuer});let m=await o(t()),h=await s(p,m,d),g=p.supportedScopes&&p.supportedScopes.length>0?p.supportedScopes.join(` `):void 0,_=await c({asMetadata:p,clientId:h.clientId,scope:g,redirectUri:m,launcher:f,fetchImpl:d}),v=`mcp:${n}`;return await u({providerId:v,accessToken:_.accessToken,refreshToken:_.refreshToken,tokenExpiresAt:_.expiresAt,scopes:_.scope}),{providerId:v,authorizationServer:p.issuer,clientId:h.clientId,redirectUri:m,scope:_.scope??g,registrationClientUri:h.registrationClientUri}}async function x(e,t){if(i(e))return m(`usage: mcp list [--json]
47
+ `)}async function b(e,n,r,i){let{discoverAuth:a,dynamicRegister:s,runAuthFlow:c}=await import(`./oauth-D20BEoY6.js`),{saveOAuthAccount:u}=await import(`./account-store-C8W_QB2_.js`).then(e=>e.t),d=await re(i.oauthFetchImpl),f=i.oauthLauncher??await X(),p=await a(e,r,d);l.debug(`MCP OAuth discovery succeeded`,{name:n,serverUrl:e,discoveryPath:p.discoveryPath,issuer:p.issuer});let m=await o(t()),h=await s(p,m,d),g=p.supportedScopes&&p.supportedScopes.length>0?p.supportedScopes.join(` `):void 0,_=await c({asMetadata:p,clientId:h.clientId,scope:g,redirectUri:m,launcher:f,fetchImpl:d}),v=`mcp:${n}`;return await u({providerId:v,accessToken:_.accessToken,refreshToken:_.refreshToken,tokenExpiresAt:_.expiresAt,scopes:_.scope}),{providerId:v,authorizationServer:p.issuer,clientId:h.clientId,redirectUri:m,scope:_.scope??g,registrationClientUri:h.registrationClientUri}}async function x(e,t){if(i(e))return m(`usage: mcp list [--json]
48
48
 
49
49
  Lists configured MCP servers with connection state, exposure mode,
50
50
  transport type, and tool counts.
51
51
 
52
52
  Options:
53
53
  --json Output as JSON instead of a table.
54
- `);let n=r(e,{bool:[`--json`]});if(`error`in n)return g(n.error);let a=n.bools.has(`--json`),{ensureAllMcpProvidersRegistered:o}=await import(`./provider-DqfbNx1g.js`);await o();let{listServers:s}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),c=await s(t.fs),l=Object.keys(c).sort();if(l.length===0)return m(a?`[]
54
+ `);let n=r(e,{bool:[`--json`]});if(`error`in n)return g(n.error);let a=n.bools.has(`--json`),{ensureAllMcpProvidersRegistered:o}=await import(`./provider-L54O0b3P.js`);await o();let{listServers:s}=await import(`./store-N9OMacY2.js`).then(e=>e.r),c=await s(t.fs),l=Object.keys(c).sort();if(l.length===0)return m(a?`[]
55
55
  `:"No MCP servers configured. Use `mcp add <url> <name>`.\n");if(a){let e=l.map(e=>{let n=c[e];return{name:e,url:n.url,state:t.connectionManager?.has(e)?`connected`:`disconnected`,exposure:n.exposure??`codemode`,transport:n.transport??`unknown`,auth:!!n.auth,tools:n.tools?.length??0,apps:n.apps?.length??0,addedAt:n.addedAt??null}});return m(JSON.stringify(e,null,2)+`
56
56
  `)}let u=[[`NAME`,`URL`,`STATE`,`EXPOSURE`,`TRANSPORT`,`AUTH`,`TOOLS`,`APPS`,`ADDED`]];for(let e of l){let n=c[e];u.push([e,n.url,t.connectionManager?.has(e)?`connected`:`-`,n.exposure??`codemode`,n.transport??`-`,n.auth?`yes`:`no`,String(n.tools?.length??0),String(n.apps?.length??0),n.addedAt?n.addedAt.slice(0,10):`-`])}return m(S(u))}function S(e){let t=e[0].map((t,n)=>e.reduce((e,t)=>Math.max(e,(t[n]??``).length),0));return e.map(e=>e.map((e,n)=>e.padEnd(t[n])).join(` `).trimEnd()).join(`
57
57
  `)+`
@@ -60,10 +60,10 @@ Options:
60
60
  Case-insensitive substring search across the cached tools of every
61
61
  registered MCP server. Matches tool name OR description and prints a
62
62
  table of (server, tool, description, match-field) rows.
63
- `);let n=r(e,{});if(`error`in n)return g(n.error);if(n.positionals.length===0)return h(`mcp search: expected <query>`);let a=n.positionals[0],o=a.toLowerCase(),{ensureAllMcpProvidersRegistered:s}=await import(`./provider-DqfbNx1g.js`);await s();let{listServers:c}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),l=await c(t.fs),u=Object.keys(l).sort();if(u.length===0)return m("No MCP servers configured. Use `mcp add <url> <name>`.\n");let d=[];for(let e of u){let t=l[e].tools??[];for(let n of t){let t=n.description??``,r=n.name.toLowerCase().includes(o),i=t.toLowerCase().includes(o);if(!r&&!i)continue;let a=r&&i?`name+description`:r?`name`:`description`;d.push({server:e,tool:n.name,description:t,match:a})}}if(d.length===0)return m(`No tools matched "${a}".\n`);d.sort((e,t)=>e.server===t.server?e.tool.localeCompare(t.tool):e.server.localeCompare(t.server));let f=[[`SERVER`,`TOOL`,`DESCRIPTION`,`MATCH`]];for(let e of d)f.push([e.server,e.tool,w(e.description),e.match]);return m(S(f))}function w(e){if(!e)return``;let t=e.replace(/\s+/g,` `).trim();return t.length<=60?t:t.slice(0,59)+`…`}async function T(e,t){if(e.length===0||i(e))return e.length===0?h(`mcp delete: expected <name>`):m(`usage: mcp delete <name>
64
- `);let n=r(e,{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:o,removeMcpProvider:s}=await import(`./provider-DqfbNx1g.js`);await o(a);let{deleteServer:c}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),u=await c(a,t.fs);t.connectionManager&&await t.connectionManager.disconnect(a),await ae(a,t),await oe(a,t);let d=`mcp:${a}`,f=!1;try{let{removeAccount:e,getAccounts:t}=await import(`./account-store-BjfGeTTt.js`).then(e=>e.t);t().some(e=>e.providerId===d)&&(await e(d),f=!0)}catch(e){l.warn(`mcp delete: OAuth removal failed`,{providerId:d,error:e instanceof Error?e.message:String(e)})}let p=s(a);return!u&&!f&&!p?h(`mcp delete: no server, alias, or account found for "${a}"`):m([`Removed MCP server "${a}"`,` servers.json: ${u?`removed`:`not present`}`,` alias: cleaned`,` sprinkles: cleaned`,` oauth: ${f?`removed`:`not present`}`,` provider: ${p?`unregistered`:`not registered`}`].join(`
63
+ `);let n=r(e,{});if(`error`in n)return g(n.error);if(n.positionals.length===0)return h(`mcp search: expected <query>`);let a=n.positionals[0],o=a.toLowerCase(),{ensureAllMcpProvidersRegistered:s}=await import(`./provider-L54O0b3P.js`);await s();let{listServers:c}=await import(`./store-N9OMacY2.js`).then(e=>e.r),l=await c(t.fs),u=Object.keys(l).sort();if(u.length===0)return m("No MCP servers configured. Use `mcp add <url> <name>`.\n");let d=[];for(let e of u){let t=l[e].tools??[];for(let n of t){let t=n.description??``,r=n.name.toLowerCase().includes(o),i=t.toLowerCase().includes(o);if(!r&&!i)continue;let a=r&&i?`name+description`:r?`name`:`description`;d.push({server:e,tool:n.name,description:t,match:a})}}if(d.length===0)return m(`No tools matched "${a}".\n`);d.sort((e,t)=>e.server===t.server?e.tool.localeCompare(t.tool):e.server.localeCompare(t.server));let f=[[`SERVER`,`TOOL`,`DESCRIPTION`,`MATCH`]];for(let e of d)f.push([e.server,e.tool,w(e.description),e.match]);return m(S(f))}function w(e){if(!e)return``;let t=e.replace(/\s+/g,` `).trim();return t.length<=60?t:t.slice(0,59)+`…`}async function T(e,t){if(e.length===0||i(e))return e.length===0?h(`mcp delete: expected <name>`):m(`usage: mcp delete <name>
64
+ `);let n=r(e,{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp delete: expected <name>`);let{ensureMcpProviderRegistered:o,removeMcpProvider:s}=await import(`./provider-L54O0b3P.js`);await o(a);let{deleteServer:c}=await import(`./store-N9OMacY2.js`).then(e=>e.r),u=await c(a,t.fs);t.connectionManager&&await t.connectionManager.disconnect(a),await ae(a,t),await oe(a,t);let d=`mcp:${a}`,f=!1;try{let{removeAccount:e,getAccounts:t}=await import(`./account-store-C8W_QB2_.js`).then(e=>e.t);t().some(e=>e.providerId===d)&&(await e(d),f=!0)}catch(e){l.warn(`mcp delete: OAuth removal failed`,{providerId:d,error:e instanceof Error?e.message:String(e)})}let p=s(a);return!u&&!f&&!p?h(`mcp delete: no server, alias, or account found for "${a}"`):m([`Removed MCP server "${a}"`,` servers.json: ${u?`removed`:`not present`}`,` alias: cleaned`,` sprinkles: cleaned`,` oauth: ${f?`removed`:`not present`}`,` provider: ${p?`unregistered`:`not registered`}`].join(`
65
65
  `)+`
66
- `)}async function E(e,t){if(e.length===0)return h(`mcp invoke: expected <name>`);if(i(e.slice(0,1)))return m(A());let n=r([e[0]],{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp invoke: expected <name>`);let o=e.slice(1),{ensureMcpProviderRegistered:s}=await import(`./provider-DqfbNx1g.js`);await s(a);let{getServer:c}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),l=await c(a,t.fs);if(!l)return h(`mcp invoke: unknown server "${a}" (run \`mcp add <url> ${a}\` first)`);let u=l.tools??[];if(o.length===0||i(o.slice(0,1)))return m(j(a,l,u));let d=r([o[0]],{});if(`error`in d)return g(d.error);let f=d.positionals[0];if(!f)return h(`mcp invoke: expected <tool>`);let p=u.find(e=>e.name===f);if(!p)return h(`mcp invoke: unknown tool "${f}" on "${a}" (run \`${a}\` to list tools)`);let{timeoutMs:_,remaining:v,warnings:y}=D(o.slice(1));if(i(v))return m(N(a,p));let{jsonFlag:b,remaining:x}=O(v),S=P(x,p.inputSchema);if(!S.ok)return h(`mcp invoke: ${S.error}`);let C;if(t.connectionManager){let{connection:e}=await t.connectionManager.connect(a,l),n=_===void 0?void 0:AbortSignal.timeout(_);C=await e.callTool(f,S.value,{signal:n})}else{let{McpClient:e}=await import(`./client-DWx5wn8j.js`),n=new e({url:l.url,fetchImpl:t.fetchImpl,headers:l.headers,getAuthHeader:l.auth?()=>Y(a):void 0,..._===void 0?{}:{timeoutMs:_}});await n.initialize(),C=await n.toolsCall(f,S.value)}if(b)return m(JSON.stringify(C,null,2)+`
66
+ `)}async function E(e,t){if(e.length===0)return h(`mcp invoke: expected <name>`);if(i(e.slice(0,1)))return m(A());let n=r([e[0]],{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp invoke: expected <name>`);let o=e.slice(1),{ensureMcpProviderRegistered:s}=await import(`./provider-L54O0b3P.js`);await s(a);let{getServer:c}=await import(`./store-N9OMacY2.js`).then(e=>e.r),l=await c(a,t.fs);if(!l)return h(`mcp invoke: unknown server "${a}" (run \`mcp add <url> ${a}\` first)`);let u=l.tools??[];if(o.length===0||i(o.slice(0,1)))return m(j(a,l,u));let d=r([o[0]],{});if(`error`in d)return g(d.error);let f=d.positionals[0];if(!f)return h(`mcp invoke: expected <tool>`);let p=u.find(e=>e.name===f);if(!p)return h(`mcp invoke: unknown tool "${f}" on "${a}" (run \`${a}\` to list tools)`);let{timeoutMs:_,remaining:v,warnings:y}=D(o.slice(1));if(i(v))return m(N(a,p));let{jsonFlag:b,remaining:x}=O(v),S=P(x,p.inputSchema);if(!S.ok)return h(`mcp invoke: ${S.error}`);let C;if(t.connectionManager){let{connection:e}=await t.connectionManager.connect(a,l),n=_===void 0?void 0:AbortSignal.timeout(_);C=await e.callTool(f,S.value,{signal:n})}else{let{McpClient:e}=await import(`./client-DWx5wn8j.js`),n=new e({url:l.url,fetchImpl:t.fetchImpl,headers:l.headers,getAuthHeader:l.auth?()=>Y(a):void 0,..._===void 0?{}:{timeoutMs:_}});await n.initialize(),C=await n.toolsCall(f,S.value)}if(b)return m(JSON.stringify(C,null,2)+`
67
67
  `);let w=K(C);return y.length>0&&(w.stderr=y.map(e=>`${e}\n`).join(``)+w.stderr),w}function D(e){let t=[],n=[],r,i=0;for(;i<e.length;){let a=e[i];if(a.startsWith(`--timeout=`)){let e=k(a.slice(10));e.ok?r=e.value:n.push(e.error),i+=1;continue}if(a===`--timeout`){let t=e[i+1];if(t===void 0||t.startsWith(`--`)){n.push(`mcp invoke: --timeout requires a value (got ${t===void 0?`nothing`:`"${t}"`}); using default.`),i+=1;continue}let a=k(t);a.ok?r=a.value:n.push(a.error),i+=2;continue}t.push(a),i+=1}return{timeoutMs:r,remaining:t,warnings:n}}function O(e){let t=[],n=!1;for(let r of e)r===`--json`?n=!0:t.push(r);return{jsonFlag:n,remaining:t}}function k(e){if(!/^-?\d+$/.test(e))return{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (expected positive integer seconds); using default.`};let t=Number(e);return!Number.isFinite(t)||t<1?{ok:!1,error:`mcp invoke: invalid --timeout value "${e}" (must be >= 1 second); using default.`}:{ok:!0,value:t*1e3}}function A(){return`usage: mcp invoke <name> [tool] [--timeout <seconds>] [--json] [--flag value …]
68
68
 
69
69
  mcp invoke <name> List tools on <name>.
@@ -99,7 +99,7 @@ Arguments are coerced according to the tool's JSON Schema:
99
99
 
100
100
  Re-fetches the tool catalog and \`apps/list\` for <name>. Does NOT refresh
101
101
  OAuth tokens — for OAuth token refresh use \`mcp auth <name>\`.
102
- `);let n=r(e,{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:o}=await import(`./provider-DqfbNx1g.js`);await o(a);let{getServer:s,setServer:c}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),l=await s(a,t.fs);if(!l)return h(`mcp refresh: unknown server "${a}"`);let u,d,f=l.protocolVersion;if(t.connectionManager){let e=await t.connectionManager.reconnect(a,l);u=await e.listTools(),d=await e.listApps?.()??[]}else{let{McpClient:e,McpAuthRequiredError:n}=await import(`./client-DWx5wn8j.js`),r=new e({url:l.url,fetchImpl:t.fetchImpl,headers:l.headers,getAuthHeader:l.auth?()=>Y(a):void 0});try{await r.initialize()}catch(e){if(e instanceof n)return h(`mcp refresh: server "${a}" returned 401 — token may have expired. Run \`mcp auth ${a}\` to re-authenticate.`);throw e}u=await r.toolsList(),d=await r.appsList(),f=r.getNegotiatedProtocolVersion()}await c(a,{...l,protocolVersion:f,tools:u,apps:d,lastRefreshedAt:new Date().toISOString()},t.fs);let p=await $(a,d,t);return m(`Refreshed "${a}" — tools: ${u.length}, apps: ${d.length} (${p} sprinkle${p===1?``:`s`})\n`)}async function ee(e,t){if(i(e))return m(`usage: mcp auth <name> [--silent | --interactive]
102
+ `);let n=r(e,{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp refresh: expected <name>`);let{ensureMcpProviderRegistered:o}=await import(`./provider-L54O0b3P.js`);await o(a);let{getServer:s,setServer:c}=await import(`./store-N9OMacY2.js`).then(e=>e.r),l=await s(a,t.fs);if(!l)return h(`mcp refresh: unknown server "${a}"`);let u,d,f=l.protocolVersion;if(t.connectionManager){let e=await t.connectionManager.reconnect(a,l);u=await e.listTools(),d=await e.listApps?.()??[]}else{let{McpClient:e,McpAuthRequiredError:n}=await import(`./client-DWx5wn8j.js`),r=new e({url:l.url,fetchImpl:t.fetchImpl,headers:l.headers,getAuthHeader:l.auth?()=>Y(a):void 0});try{await r.initialize()}catch(e){if(e instanceof n)return h(`mcp refresh: server "${a}" returned 401 — token may have expired. Run \`mcp auth ${a}\` to re-authenticate.`);throw e}u=await r.toolsList(),d=await r.appsList(),f=r.getNegotiatedProtocolVersion()}await c(a,{...l,protocolVersion:f,tools:u,apps:d,lastRefreshedAt:new Date().toISOString()},t.fs);let p=await $(a,d,t);return m(`Refreshed "${a}" — tools: ${u.length}, apps: ${d.length} (${p} sprinkle${p===1?``:`s`})\n`)}async function ee(e,t){if(i(e))return m(`usage: mcp auth <name> [--silent | --interactive]
103
103
 
104
104
  Re-authenticate an existing MCP server. By default, attempts a silent
105
105
  token renewal using the persisted refresh_token; if that returns no
@@ -111,7 +111,7 @@ Options:
111
111
  -i, --interactive Skip silent renewal and open the OAuth popup
112
112
  directly. Use after revoking a refresh token or
113
113
  when the AS no longer accepts the cached one.
114
- `);let n=r(e,{bool:s});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp auth: expected <name>`);let o=n.bools.has(`--silent`)||n.bools.has(`-s`),c=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(o&&c)return h(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:u}=await import(`./provider-DqfbNx1g.js`),d=await u(a,{fetchImpl:t.oauthFetchImpl,launcher:t.oauthLauncher}),{getServer:f}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),p=await f(a,t.fs);if(!p)return h(`mcp auth: unknown server "${a}" (run \`mcp list\` to see configured servers)`);if(!p.auth)return h(`mcp auth: server "${a}" does not use OAuth`);if(!d)return h(`mcp auth: failed to register provider for "${a}"`);let _=`mcp:${a}`,{getRegisteredProviderConfig:v}=await import(`./providers-DRXtGsiH.js`).then(e=>e.r),y=v(_);if(!y)return h(`mcp auth: provider "${_}" is not registered`);if(c)return await J(a,y,t);if(!y.onSilentRenew)return o?h(`mcp auth: provider "${_}" does not support silent renewal; retry without --silent`):await J(a,y,t);let b=null;try{b=await y.onSilentRenew()}catch(e){let t=e instanceof Error?e.message:String(e);if(o)return h(`mcp auth: silent renewal for "${a}" failed (${t}); retry without --silent to run the interactive flow`);l.debug(`mcp auth: silent renewal threw, falling back to interactive`,{name:a,error:t})}return b?m(`Re-authenticated "${a}" via silent renewal (provider ${_})\n`):o?h(`mcp auth: silent renewal for "${a}" returned no token; retry without --silent to run the interactive flow`):await J(a,y,t)}async function J(e,t,n){if(!t.onOAuthLogin)return h(`mcp auth: provider "${t.id}" does not support interactive OAuth login`);let r=n.oauthLauncher??await X(),i=!1;return await t.onOAuthLogin(r,()=>{i=!0}),i?m(`Re-authenticated "${e}" via interactive login (provider ${t.id})\n`):h(`mcp auth: interactive login for "${e}" did not complete`)}async function te(e,t){if(i(e)||e.length===0)return e.length===0?h(`mcp exposure: expected <name> <mode>`):m(`usage: mcp exposure <name> <mode> [--tool <glob>]
114
+ `);let n=r(e,{bool:s});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp auth: expected <name>`);let o=n.bools.has(`--silent`)||n.bools.has(`-s`),c=n.bools.has(`--interactive`)||n.bools.has(`-i`);if(o&&c)return h(`mcp auth: --silent and --interactive are mutually exclusive`);let{ensureMcpProviderRegistered:u}=await import(`./provider-L54O0b3P.js`),d=await u(a,{fetchImpl:t.oauthFetchImpl,launcher:t.oauthLauncher}),{getServer:f}=await import(`./store-N9OMacY2.js`).then(e=>e.r),p=await f(a,t.fs);if(!p)return h(`mcp auth: unknown server "${a}" (run \`mcp list\` to see configured servers)`);if(!p.auth)return h(`mcp auth: server "${a}" does not use OAuth`);if(!d)return h(`mcp auth: failed to register provider for "${a}"`);let _=`mcp:${a}`,{getRegisteredProviderConfig:v}=await import(`./providers-DSWENZNJ.js`).then(e=>e.r),y=v(_);if(!y)return h(`mcp auth: provider "${_}" is not registered`);if(c)return await J(a,y,t);if(!y.onSilentRenew)return o?h(`mcp auth: provider "${_}" does not support silent renewal; retry without --silent`):await J(a,y,t);let b=null;try{b=await y.onSilentRenew()}catch(e){let t=e instanceof Error?e.message:String(e);if(o)return h(`mcp auth: silent renewal for "${a}" failed (${t}); retry without --silent to run the interactive flow`);l.debug(`mcp auth: silent renewal threw, falling back to interactive`,{name:a,error:t})}return b?m(`Re-authenticated "${a}" via silent renewal (provider ${_})\n`):o?h(`mcp auth: silent renewal for "${a}" returned no token; retry without --silent to run the interactive flow`):await J(a,y,t)}async function J(e,t,n){if(!t.onOAuthLogin)return h(`mcp auth: provider "${t.id}" does not support interactive OAuth login`);let r=n.oauthLauncher??await X(),i=!1;return await t.onOAuthLogin(r,()=>{i=!0}),i?m(`Re-authenticated "${e}" via interactive login (provider ${t.id})\n`):h(`mcp auth: interactive login for "${e}" did not complete`)}async function te(e,t){if(i(e)||e.length===0)return e.length===0?h(`mcp exposure: expected <name> <mode>`):m(`usage: mcp exposure <name> <mode> [--tool <glob>]
115
115
 
116
116
  Set the exposure mode for an MCP server or individual tools.
117
117
 
@@ -127,7 +127,7 @@ Examples:
127
127
  mcp exposure weather direct Set all weather tools to direct
128
128
  mcp exposure weather hidden --tool 'delete_*' Hide delete tools
129
129
  mcp exposure weather codemode --tool '*' Reset all tool overrides
130
- `);let n=r(e,{value:[`--tool`]});if(`error`in n)return g(n.error);if(n.positionals.length<2)return h(`mcp exposure: expected <name> <mode>`);let[a,o]=n.positionals;if(!c.has(o))return h(`mcp exposure: invalid mode "${o}" (valid: ${[...c].join(`, `)})`);let s=o,l=n.values.get(`--tool`),{getServer:u,setServer:d}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),f=await u(a,t.fs);if(!f)return h(`mcp exposure: unknown server "${a}"`);if(l){if(l===`*`)f.toolExposure={"*":s};else{let e=f.toolExposure??{};e[l]=s,f.toolExposure=e}return await d(a,f,t.fs),t.connectionManager&&t.connectionManager.notifyToolsChanged(a),m(`Set tool exposure for "${l}" on "${a}" → ${s}\n`)}return f.exposure=s,await d(a,f,t.fs),t.connectionManager&&t.connectionManager.notifyToolsChanged(a),m(`Set server exposure for "${a}" → ${s}\n`)}async function ne(e,t){if(i(e)||e.length===0)return e.length===0?h(`mcp import: expected <file>`):m(`usage: mcp import <file>
130
+ `);let n=r(e,{value:[`--tool`]});if(`error`in n)return g(n.error);if(n.positionals.length<2)return h(`mcp exposure: expected <name> <mode>`);let[a,o]=n.positionals;if(!c.has(o))return h(`mcp exposure: invalid mode "${o}" (valid: ${[...c].join(`, `)})`);let s=o,l=n.values.get(`--tool`),{getServer:u,setServer:d}=await import(`./store-N9OMacY2.js`).then(e=>e.r),f=await u(a,t.fs);if(!f)return h(`mcp exposure: unknown server "${a}"`);if(l){if(l===`*`)f.toolExposure={"*":s};else{let e=f.toolExposure??{};e[l]=s,f.toolExposure=e}return await d(a,f,t.fs),t.connectionManager&&t.connectionManager.notifyToolsChanged(a),m(`Set tool exposure for "${l}" on "${a}" → ${s}\n`)}return f.exposure=s,await d(a,f,t.fs),t.connectionManager&&t.connectionManager.notifyToolsChanged(a),m(`Set server exposure for "${a}" → ${s}\n`)}async function ne(e,t){if(i(e)||e.length===0)return e.length===0?h(`mcp import: expected <file>`):m(`usage: mcp import <file>
131
131
 
132
132
  Import MCP servers from a Pi, Claude Desktop, or Cursor configuration
133
133
  file. Reads a JSON object with an \`mcpServers\` key containing server
@@ -140,9 +140,9 @@ in the browser.
140
140
  Examples:
141
141
  mcp import claude_desktop_config.json
142
142
  mcp import ~/.config/cursor/mcp.json
143
- `);let n=r(e,{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp import: expected <file>`);let o=await Z(t.fs),s;try{s=await o.readFile(a,{encoding:`utf-8`})}catch{return h(`mcp import: cannot read "${a}"`)}let c;try{c=JSON.parse(s)}catch{return h(`mcp import: "${a}" is not valid JSON`)}let l=c.mcpServers??{},u=Object.keys(l);if(u.length===0)return h(`mcp import: no mcpServers found in "${a}"`);let{getServer:f,listServers:p,setServer:_}=await import(`./store-uM0i8Poo.js`).then(e=>e.r),v=[],y=0,b=0;for(let e of u){if(!d(e)){v.push(` skip: "${e}" (invalid name)`),b++;continue}let n=l[e];if(n.command){v.push(` skip: "${e}" (stdio transport — not supported in browser)`),b++;continue}let r=n.url;if(!r||!/^https?:\/\//i.test(r)){v.push(` skip: "${e}" (no valid URL)`),b++;continue}if(await f(e,t.fs)){v.push(` skip: "${e}" (already exists)`),b++;continue}let i=e.replace(/[^A-Za-z0-9_]/g,`_`),a=Object.keys(await p(t.fs)).find(e=>e.replace(/[^A-Za-z0-9_]/g,`_`)===i);if(a){v.push(` skip: "${e}" (conflicts with "${a}" after name normalization)`),b++;continue}await _(e,{url:r,addedAt:new Date().toISOString(),...n.headers?{headers:n.headers}:{}},t.fs),await Q(e,t),v.push(` added: "${e}" → ${r}`),y++}return m([`Imported from "${a}": ${y} added, ${b} skipped`,...v].join(`
143
+ `);let n=r(e,{});if(`error`in n)return g(n.error);let a=n.positionals[0];if(!a)return h(`mcp import: expected <file>`);let o=await Z(t.fs),s;try{s=await o.readFile(a,{encoding:`utf-8`})}catch{return h(`mcp import: cannot read "${a}"`)}let c;try{c=JSON.parse(s)}catch{return h(`mcp import: "${a}" is not valid JSON`)}let l=c.mcpServers??{},u=Object.keys(l);if(u.length===0)return h(`mcp import: no mcpServers found in "${a}"`);let{getServer:f,listServers:p,setServer:_}=await import(`./store-N9OMacY2.js`).then(e=>e.r),v=[],y=0,b=0;for(let e of u){if(!d(e)){v.push(` skip: "${e}" (invalid name)`),b++;continue}let n=l[e];if(n.command){v.push(` skip: "${e}" (stdio transport — not supported in browser)`),b++;continue}let r=n.url;if(!r||!/^https?:\/\//i.test(r)){v.push(` skip: "${e}" (no valid URL)`),b++;continue}if(await f(e,t.fs)){v.push(` skip: "${e}" (already exists)`),b++;continue}let i=e.replace(/[^A-Za-z0-9_]/g,`_`),a=Object.keys(await p(t.fs)).find(e=>e.replace(/[^A-Za-z0-9_]/g,`_`)===i);if(a){v.push(` skip: "${e}" (conflicts with "${a}" after name normalization)`),b++;continue}await _(e,{url:r,addedAt:new Date().toISOString(),...n.headers?{headers:n.headers}:{}},t.fs),await Q(e,t),v.push(` added: "${e}" → ${r}`),y++}return m([`Imported from "${a}": ${y} added, ${b} skipped`,...v].join(`
144
144
  `)+`
145
- `)}async function Y(e){let t=`mcp:${e}`,{getOAuthAccountInfo:n}=await import(`./account-store-BjfGeTTt.js`).then(e=>e.t),r=n(t);if(!r)return null;if(r.expired){try{let{getRegisteredProviderConfig:e}=await import(`./providers-DRXtGsiH.js`).then(e=>e.r),n=await e(t)?.onSilentRenew?.();if(n)return`Bearer ${n}`}catch(e){l.debug(`silent renewal threw`,{providerId:t,error:e instanceof Error?e.message:String(e)})}return null}return`Bearer ${r.token}`}async function X(){let{createOAuthLauncher:e}=await import(`./oauth-service-Bx_Dy3GC.js`);return e()}async function re(e){if(e)return e;let{createProxiedFetch:t}=await import(`./proxied-fetch-CoZ8jHud.js`).then(e=>e.o),n=t();return async(e,t)=>{let r=await n(e,{method:t?.method,headers:t?.headers,body:t?.body}),i=new TextDecoder().decode(r.body);return{ok:r.status>=200&&r.status<300,status:r.status,statusText:r.statusText,text:async()=>i,json:async()=>JSON.parse(i),headers:{get:e=>r.headers[e.toLowerCase()]??null}}}}async function Z(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-BWRHmpI5.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return await t.create({dbName:n})}function ie(e){return`// MCP alias for "${e}" — forwards args to \`mcp invoke ${e}\`.
145
+ `)}async function Y(e){let t=`mcp:${e}`,{getOAuthAccountInfo:n}=await import(`./account-store-C8W_QB2_.js`).then(e=>e.t),r=n(t);if(!r)return null;if(r.expired){try{let{getRegisteredProviderConfig:e}=await import(`./providers-DSWENZNJ.js`).then(e=>e.r),n=await e(t)?.onSilentRenew?.();if(n)return`Bearer ${n}`}catch(e){l.debug(`silent renewal threw`,{providerId:t,error:e instanceof Error?e.message:String(e)})}return null}return`Bearer ${r.token}`}async function X(){let{createOAuthLauncher:e}=await import(`./oauth-service-Bx_Dy3GC.js`);return e()}async function re(e){if(e)return e;let{createProxiedFetch:t}=await import(`./proxied-fetch-CoZ8jHud.js`).then(e=>e.o),n=t();return async(e,t)=>{let r=await n(e,{method:t?.method,headers:t?.headers,body:t?.body}),i=new TextDecoder().decode(r.body);return{ok:r.status>=200&&r.status<300,status:r.status,statusText:r.statusText,text:async()=>i,json:async()=>JSON.parse(i),headers:{get:e=>r.headers[e.toLowerCase()]??null}}}}async function Z(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-CXdlfm9I.js`).then(e=>e.t),{GLOBAL_FS_DB_NAME:n}=await import(`./global-db-DJXlpNui.js`).then(e=>e.n);return await t.create({dbName:n})}function ie(e){return`// MCP alias for "${e}" — forwards args to \`mcp invoke ${e}\`.
146
146
  // Auto-generated by \`mcp add ${e}\`; do not edit by hand.
147
147
  const { promisify } = require('util');
148
148
  const { exec } = require('child_process');
@@ -171,4 +171,4 @@ try {
171
171
  if (stdout) process.stdout.write(stdout);
172
172
  if (stderr) process.stderr.write(stderr);
173
173
  process.exit(exitCode);
174
- `}async function Q(e,t){let n=await Z(t.fs);await n.mkdir(p,{recursive:!0}),await n.writeFile(`${p}/${e}.jsh`,ie(e)),t.scriptCatalog?.invalidateJsh()}async function ae(e,t){let n=await Z(t.fs),r=`${p}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){l.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function oe(e,t){let{removeAppSprinkles:n}=await import(`./apps-Dp0TUE_0.js`);await n(e,t.fs)}async function $(e,t,n){try{let{materializeAppSprinkles:r}=await import(`./apps-Dp0TUE_0.js`);return(await r(e,t,n.fs)).length}catch(t){return l.warn(`mcp: failed to materialize app sprinkles`,{name:e,error:t instanceof Error?t.message:String(t)}),0}}export{v as createMcpCommand,o as t};
174
+ `}async function Q(e,t){let n=await Z(t.fs);await n.mkdir(p,{recursive:!0}),await n.writeFile(`${p}/${e}.jsh`,ie(e)),t.scriptCatalog?.invalidateJsh()}async function ae(e,t){let n=await Z(t.fs),r=`${p}/${e}.jsh`;try{await n.exists(r)&&await n.rm(r)}catch(e){l.debug(`alias removal failed`,{path:r,error:e instanceof Error?e.message:String(e)})}t.scriptCatalog?.invalidateJsh()}async function oe(e,t){let{removeAppSprinkles:n}=await import(`./apps-DkZBf0EF.js`);await n(e,t.fs)}async function $(e,t,n){try{let{materializeAppSprinkles:r}=await import(`./apps-DkZBf0EF.js`);return(await r(e,t,n.fs)).length}catch(t){return l.warn(`mcp: failed to materialize app sprinkles`,{name:e,error:t instanceof Error?t.message:String(t)}),0}}export{v as createMcpCommand,o as t};
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import"./record-COQlaFL1.js";import{s as t}from"./kernel-worker-Cvf_O6Kr.js";import{a as n,i as r,n as i,o as a,s as o,t as s}from"./live-session-curation-kO8HahKE.js";const c=e(`memory-dreaming`),l={kind:`dream`,nameFor:n,rivalsFor:e=>[r(e)]};function u(e,t){return`dream-${e}-${t}.md`}async function d(e){let t=e.today??new Date().toISOString().slice(0,10),n=e.cone?.folder??`cone`;return await f(e,n),a({spawn:e.spawn,vfs:e.vfs,sessionArchivePath:`/sessions/${u(t,n)}`,sessionCount:e.sessionCount,today:t,instructions:l,...e.cone?{cone:e.cone}:{},...e.signal?{signal:e.signal}:{}})}async function f(e,t){if(i())try{await s({vfs:e.vfs,cone:e.cone??{folder:t},spawn:e.spawn,...e.signal?{signal:e.signal}:{}})}catch(e){c.warn(`Live transcript curation before dream failed`,{cone:t,error:e instanceof Error?e.message:String(e)})}}function p(e){return o(e),{async curate(t){let n=globalThis.__slicc_agent;return n?a({spawn:e=>n.spawn(e),vfs:e,sessionArchivePath:t.sessionArchivePath,sessionCount:t.sessionCount,...t.cone?{cone:t.cone}:{}}):{ok:!1,reason:`agent bridge not published yet`,legacyFallbackSafe:!1}},async dream(n){let r=globalThis.__slicc_agent;if(!r)return{ok:!1,reason:`agent bridge not published yet`,legacyFallbackSafe:!1};let i=(await t(e)).length;return d({spawn:e=>r.spawn(e),vfs:e,sessionCount:i,...n.cone?{cone:n.cone}:{},...n.today?{today:n.today}:{}})}}}function m(e){globalThis.__slicc_memory=e}export{p as createMemorySeam,m as publishMemorySeam};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import"./record-COQlaFL1.js";import{s as t}from"./kernel-worker-M218S0e9.js";import{a as n,i as r,n as i,o as a,s as o,t as s}from"./live-session-curation-DtmCoogl.js";const c=e(`memory-dreaming`),l={kind:`dream`,nameFor:n,rivalsFor:e=>[r(e)]};function u(e,t){return`dream-${e}-${t}.md`}async function d(e){let t=e.today??new Date().toISOString().slice(0,10),n=e.cone?.folder??`cone`;return await f(e,n),a({spawn:e.spawn,vfs:e.vfs,sessionArchivePath:`/sessions/${u(t,n)}`,sessionCount:e.sessionCount,today:t,instructions:l,...e.cone?{cone:e.cone}:{},...e.signal?{signal:e.signal}:{}})}async function f(e,t){if(i())try{await s({vfs:e.vfs,cone:e.cone??{folder:t},spawn:e.spawn,...e.signal?{signal:e.signal}:{}})}catch(e){c.warn(`Live transcript curation before dream failed`,{cone:t,error:e instanceof Error?e.message:String(e)})}}function p(e){return o(e),{async curate(t){let n=globalThis.__slicc_agent;return n?a({spawn:e=>n.spawn(e),vfs:e,sessionArchivePath:t.sessionArchivePath,sessionCount:t.sessionCount,...t.cone?{cone:t.cone}:{}}):{ok:!1,reason:`agent bridge not published yet`,legacyFallbackSafe:!1}},async dream(n){let r=globalThis.__slicc_agent;if(!r)return{ok:!1,reason:`agent bridge not published yet`,legacyFallbackSafe:!1};let i=(await t(e)).length;return d({spawn:e=>r.spawn(e),vfs:e,sessionCount:i,...n.cone?{cone:n.cone}:{},...n.today?{today:n.today}:{}})}}}function m(e){globalThis.__slicc_memory=e}export{p as createMemorySeam,m as publishMemorySeam};
@@ -1 +1 @@
1
- import{t as e}from"./record-COQlaFL1.js";import{t,u as n}from"./descriptor-CKLcFFX3.js";import{a as r}from"./kernel-worker-Cvf_O6Kr.js";const i=`/sessions/.curation/health.json`;async function a(e,t){try{return(await c(e,n({parentJid:null,folder:t}).memoryPath)).length}catch(e){if(s(e))return null;throw e}}async function o(e){if(!e.readDir)return null;try{let n=await e.readDir(t);return new Set(n.filter(e=>e.type===`directory`).map(e=>e.name))}catch{return new Set}}function s(e){return e?.code===`ENOENT`||e instanceof Error&&e.message.includes(`ENOENT`)}async function c(e,t){let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}async function l(e){let t;try{t=await c(e,r)}catch(e){return s(e)?{fresh:!0}:{failure:`sessions index unreadable at ${r}: ${e instanceof Error?e.message:String(e)}`}}try{let e=JSON.parse(t);return Array.isArray(e)?{entries:e}:{failure:`sessions index is not an array`}}catch{return{failure:`sessions index at ${r} is not valid JSON`}}}function u(e){return e.memoryFailed===void 0?e.memoryPending?`pending`:e.memoryCuratedAt===void 0?e.memorySkipped?`skipped`:`none`:`curated`:`failed`}function d(t){let n=new Map([[e,0]]);for(let e of t){if(u(e)!==`curated`)continue;let t=e.cone??`cone`;n.set(t,(n.get(t)??0)+1)}return n}async function f(e,t){let n=await o(e),r=[];for(let[i,o]of d(t))i!==`cone`&&n&&!n.has(i)||r.push({folder:i,curated:o,chars:await a(e,i)});return r}function p(e){return e.filter(e=>e.curated>0&&(e.chars??0)===0).map(e=>e.folder===`cone`?`${e.curated} archive(s) report successful curation but the primary memory file is missing or empty`:`${e.curated} archive(s) from cone "${e.folder}" report successful curation but its memory file is missing or empty`)}async function m(e,t=()=>new Date){let n={at:t().toISOString(),sessions:0,curation:{curated:0,failed:0,pending:0,skipped:0,none:0},primaryMemoryChars:null,cones:[],failures:[]};try{let t=await l(e);if(`failure`in t)return n.failures.push(t.failure),n;let r=`entries`in t?t.entries:[];n.sessions=r.length;for(let e of r)n.curation[u(e)]++;try{n.cones=await f(e,r)}catch(e){return n.failures.push(`memory file unreadable: ${e instanceof Error?e.message:String(e)}`),n}n.primaryMemoryChars=n.cones.find(e=>e.folder===`cone`)?.chars??null,n.curation.failed>0&&n.failures.push(`${n.curation.failed} archive(s) whose last curation attempt failed`),n.failures.push(...p(n.cones))}catch(e){n.failures.push(`health check itself failed: ${e instanceof Error?e.message:String(e)}`)}return n}async function h(e,t){let n=await m(e,t);return await e.mkdir(`/sessions/.curation`,{recursive:!0}),await e.writeFile(i,`${JSON.stringify(n,null,2)}\n`),n}function g(e,t){let{log:n}=t,r=async()=>{try{let t=await h(e);t.failures.length>0?(n.error??n.warn.bind(n))(`memory health check FAILED`,{failures:t.failures,report:i}):n.info(`memory health check ok`,{sessions:t.sessions,curation:t.curation})}catch(e){(n.error??n.warn.bind(n))(`memory health check could not persist its report`,e)}},a=setTimeout(()=>{r()},t.bootDelayMs??9e4),o=setInterval(()=>{r()},t.intervalMs??864e5);return()=>{clearTimeout(a),clearInterval(o)}}export{g as scheduleMemoryHealthChecks};
1
+ import{t as e}from"./record-COQlaFL1.js";import{t,u as n}from"./descriptor-CKLcFFX3.js";import{a as r}from"./kernel-worker-M218S0e9.js";const i=`/sessions/.curation/health.json`;async function a(e,t){try{return(await c(e,n({parentJid:null,folder:t}).memoryPath)).length}catch(e){if(s(e))return null;throw e}}async function o(e){if(!e.readDir)return null;try{let n=await e.readDir(t);return new Set(n.filter(e=>e.type===`directory`).map(e=>e.name))}catch{return new Set}}function s(e){return e?.code===`ENOENT`||e instanceof Error&&e.message.includes(`ENOENT`)}async function c(e,t){let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}async function l(e){let t;try{t=await c(e,r)}catch(e){return s(e)?{fresh:!0}:{failure:`sessions index unreadable at ${r}: ${e instanceof Error?e.message:String(e)}`}}try{let e=JSON.parse(t);return Array.isArray(e)?{entries:e}:{failure:`sessions index is not an array`}}catch{return{failure:`sessions index at ${r} is not valid JSON`}}}function u(e){return e.memoryFailed===void 0?e.memoryPending?`pending`:e.memoryCuratedAt===void 0?e.memorySkipped?`skipped`:`none`:`curated`:`failed`}function d(t){let n=new Map([[e,0]]);for(let e of t){if(u(e)!==`curated`)continue;let t=e.cone??`cone`;n.set(t,(n.get(t)??0)+1)}return n}async function f(e,t){let n=await o(e),r=[];for(let[i,o]of d(t))i!==`cone`&&n&&!n.has(i)||r.push({folder:i,curated:o,chars:await a(e,i)});return r}function p(e){return e.filter(e=>e.curated>0&&(e.chars??0)===0).map(e=>e.folder===`cone`?`${e.curated} archive(s) report successful curation but the primary memory file is missing or empty`:`${e.curated} archive(s) from cone "${e.folder}" report successful curation but its memory file is missing or empty`)}async function m(e,t=()=>new Date){let n={at:t().toISOString(),sessions:0,curation:{curated:0,failed:0,pending:0,skipped:0,none:0},primaryMemoryChars:null,cones:[],failures:[]};try{let t=await l(e);if(`failure`in t)return n.failures.push(t.failure),n;let r=`entries`in t?t.entries:[];n.sessions=r.length;for(let e of r)n.curation[u(e)]++;try{n.cones=await f(e,r)}catch(e){return n.failures.push(`memory file unreadable: ${e instanceof Error?e.message:String(e)}`),n}n.primaryMemoryChars=n.cones.find(e=>e.folder===`cone`)?.chars??null,n.curation.failed>0&&n.failures.push(`${n.curation.failed} archive(s) whose last curation attempt failed`),n.failures.push(...p(n.cones))}catch(e){n.failures.push(`health check itself failed: ${e instanceof Error?e.message:String(e)}`)}return n}async function h(e,t){let n=await m(e,t);return await e.mkdir(`/sessions/.curation`,{recursive:!0}),await e.writeFile(i,`${JSON.stringify(n,null,2)}\n`),n}function g(e,t){let{log:n}=t,r=async()=>{try{let t=await h(e);t.failures.length>0?(n.error??n.warn.bind(n))(`memory health check FAILED`,{failures:t.failures,report:i}):n.info(`memory health check ok`,{sessions:t.sessions,curation:t.curation})}catch(e){(n.error??n.warn.bind(n))(`memory health check could not persist its report`,e)}},a=setTimeout(()=>{r()},t.bootDelayMs??9e4),o=setInterval(()=>{r()},t.intervalMs??864e5);return()=>{clearTimeout(a),clearInterval(o)}}export{g as scheduleMemoryHealthChecks};
@@ -1 +1 @@
1
- import{n as e}from"./path-utils-DNJG-zQf.js";import{a as t,o as n}from"./memory-budget-CFfevxz_.js";import{n as r,t as i}from"./kernel-worker-Cvf_O6Kr.js";function a(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.oldText==`string`&&typeof e.newText==`string`)}function o(e,t){let n=e;for(let[e,r]of t.entries()){if(r.oldText.length===0)return{ok:!1,error:`edit ${e+1}: oldText must not be empty`};let t=n.indexOf(r.oldText);if(t===-1)return{ok:!1,error:`edit ${e+1}: oldText not found in the current file`};if(n.indexOf(r.oldText,t+1)!==-1)return{ok:!1,error:`edit ${e+1}: oldText occurs more than once; include more context to make it unique`};n=n.slice(0,t)+r.newText+n.slice(t+r.oldText.length)}return{ok:!0,content:n}}function s(e,t){return e<=t?`${e} chars, ${t-e} under the ${t}-char budget.`:`${e} chars, ${e-t} OVER the ${t}-char budget — the next write must be smaller than ${e} chars.`}function c(e,t,n){if(t<=n||t<e)return{allowed:!0};let r=t-n;return{allowed:!1,reason:`Rejected: the file would ${t===e?`stay at ${e} chars`:`grow from ${e} to ${t} chars`}, ${r} over the ${n}-char budget. Over budget, a write must shrink the file — cut a whole section rather than shaving characters, then write again.`}}function l(e,t){return`Rejected: this line records ${e} as absent or refuted, but ${e} is outside this pass's visiblePaths — every read of it answered "not visible", which means UNKNOWN, never absent. Keep the stored claim as it was, or name the unverifiable pair in your closing report instead. Line: ${t}`}async function u(e,t){try{let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}catch(e){if(e?.code===`ENOENT`)return null;throw e}}function d(e,t,n){if(typeof e.content==`string`)return{ok:!0,next:e.content};if(!a(e.edits))return{ok:!1,error:"`edits` must be a list of { oldText, newText }"};if(t===null)return{ok:!1,error:`${n} does not exist yet — pass \`content\` to create it`};let r=o(t,e.edits);return r.ok?{ok:!0,next:r.content}:r}async function f(a,o,f){if(typeof f.path!=`string`||f.path.length===0)return{content:"memory_write: `path` is required",isError:!0};let p=e(f.path);if(!n(p))return{content:`memory_write: ${p} is not a memory file — use write_file or edit for ordinary files`,isError:!0};if(typeof f.content==`string`==(f.edits!==void 0))return{content:"memory_write: pass exactly one of `content` (whole file) or `edits` (exact replacements)",isError:!0};try{let e=await u(a,p),n=d(f,e,p);if(!n.ok)return{content:`memory_write: ${n.error}`,isError:!0};let m=t(await o.readSessionCount()),h=c(e?.length??0,n.next.length,m);if(!h.allowed)return{content:`memory_write: ${h.reason}`,isError:!0};let g=r(e??``,n.next,o.blindPaths?.()??[]);if(g)return{content:`memory_write: ${l(g.path,g.line)}`,isError:!0};await a.writeFile(p,n.next);let _=await i(a,p,n.next);return _?{content:_,isError:!0}:{content:`Wrote ${p}: ${s(n.next.length,m)}`}}catch(e){return{content:e instanceof Error?e.message:String(e),isError:!0}}}export{f as executeMemoryWrite};
1
+ import{n as e}from"./path-utils-DNJG-zQf.js";import{a as t,o as n}from"./memory-budget-CFfevxz_.js";import{n as r,t as i}from"./kernel-worker-M218S0e9.js";function a(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.oldText==`string`&&typeof e.newText==`string`)}function o(e,t){let n=e;for(let[e,r]of t.entries()){if(r.oldText.length===0)return{ok:!1,error:`edit ${e+1}: oldText must not be empty`};let t=n.indexOf(r.oldText);if(t===-1)return{ok:!1,error:`edit ${e+1}: oldText not found in the current file`};if(n.indexOf(r.oldText,t+1)!==-1)return{ok:!1,error:`edit ${e+1}: oldText occurs more than once; include more context to make it unique`};n=n.slice(0,t)+r.newText+n.slice(t+r.oldText.length)}return{ok:!0,content:n}}function s(e,t){return e<=t?`${e} chars, ${t-e} under the ${t}-char budget.`:`${e} chars, ${e-t} OVER the ${t}-char budget — the next write must be smaller than ${e} chars.`}function c(e,t,n){if(t<=n||t<e)return{allowed:!0};let r=t-n;return{allowed:!1,reason:`Rejected: the file would ${t===e?`stay at ${e} chars`:`grow from ${e} to ${t} chars`}, ${r} over the ${n}-char budget. Over budget, a write must shrink the file — cut a whole section rather than shaving characters, then write again.`}}function l(e,t){return`Rejected: this line records ${e} as absent or refuted, but ${e} is outside this pass's visiblePaths — every read of it answered "not visible", which means UNKNOWN, never absent. Keep the stored claim as it was, or name the unverifiable pair in your closing report instead. Line: ${t}`}async function u(e,t){try{let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}catch(e){if(e?.code===`ENOENT`)return null;throw e}}function d(e,t,n){if(typeof e.content==`string`)return{ok:!0,next:e.content};if(!a(e.edits))return{ok:!1,error:"`edits` must be a list of { oldText, newText }"};if(t===null)return{ok:!1,error:`${n} does not exist yet — pass \`content\` to create it`};let r=o(t,e.edits);return r.ok?{ok:!0,next:r.content}:r}async function f(a,o,f){if(typeof f.path!=`string`||f.path.length===0)return{content:"memory_write: `path` is required",isError:!0};let p=e(f.path);if(!n(p))return{content:`memory_write: ${p} is not a memory file — use write_file or edit for ordinary files`,isError:!0};if(typeof f.content==`string`==(f.edits!==void 0))return{content:"memory_write: pass exactly one of `content` (whole file) or `edits` (exact replacements)",isError:!0};try{let e=await u(a,p),n=d(f,e,p);if(!n.ok)return{content:`memory_write: ${n.error}`,isError:!0};let m=t(await o.readSessionCount()),h=c(e?.length??0,n.next.length,m);if(!h.allowed)return{content:`memory_write: ${h.reason}`,isError:!0};let g=r(e??``,n.next,o.blindPaths?.()??[]);if(g)return{content:`memory_write: ${l(g.path,g.line)}`,isError:!0};await a.writeFile(p,n.next);let _=await i(a,p,n.next);return _?{content:_,isError:!0}:{content:`Wrote ${p}: ${s(n.next.length,m)}`}}catch(e){return{content:e instanceof Error?e.message:String(e),isError:!0}}}export{f as executeMemoryWrite};
@@ -1 +1 @@
1
- import"./record-COQlaFL1.js";import{s as e}from"./kernel-worker-Cvf_O6Kr.js";import{u as t}from"./frozen-archive-writer-B2hU8rG5.js";async function n(n,a,o){if(o.length===0)return!1;let s=a.folder||`cone`,c=(await e(n)).filter(e=>(e.cone??`cone`)===s);if(c.length===0)return!1;let l=c.reduce((e,t)=>t.frozenAt>e.frozenAt?t:e),u={...l,cost:r(l.cost,o),models:i(l.models,o)};return await t(n,u),!0}function r(e,t){let n=e?.total??0,r=e?.input??0,i=e?.output??0,a=e?.cacheRead??0,o=e?.cacheWrite??0;for(let e of t)n+=e.usage.cost.total,r+=e.usage.cost.input,i+=e.usage.cost.output,a+=e.usage.cost.cacheRead,o+=e.usage.cost.cacheWrite;return{total:n,input:r,output:i,cacheRead:a,cacheWrite:o}}function i(e,t){let n=new Map;for(let t of e??[])n.set(t.model,{...t});for(let e of t){let t=n.get(e.model)??{model:e.model,cost:0,turns:0,tokens:0};t.cost+=e.usage.cost.total,t.turns+=1,t.tokens+=e.usage.totalTokens,n.set(e.model,t)}return[...n.values()].sort((e,t)=>t.cost-e.cost)}export{n as mergeFoldedCostIntoLatestFrozen};
1
+ import"./record-COQlaFL1.js";import{s as e}from"./kernel-worker-M218S0e9.js";import{u as t}from"./frozen-archive-writer-Ce13R-3M.js";async function n(n,a,o){if(o.length===0)return!1;let s=a.folder||`cone`,c=(await e(n)).filter(e=>(e.cone??`cone`)===s);if(c.length===0)return!1;let l=c.reduce((e,t)=>t.frozenAt>e.frozenAt?t:e),u={...l,cost:r(l.cost,o),models:i(l.models,o)};return await t(n,u),!0}function r(e,t){let n=e?.total??0,r=e?.input??0,i=e?.output??0,a=e?.cacheRead??0,o=e?.cacheWrite??0;for(let e of t)n+=e.usage.cost.total,r+=e.usage.cost.input,i+=e.usage.cost.output,a+=e.usage.cost.cacheRead,o+=e.usage.cost.cacheWrite;return{total:n,input:r,output:i,cacheRead:a,cacheWrite:o}}function i(e,t){let n=new Map;for(let t of e??[])n.set(t.model,{...t});for(let e of t){let t=n.get(e.model)??{model:e.model,cost:0,turns:0,tokens:0};t.cost+=e.usage.cost.total,t.turns+=1,t.tokens+=e.usage.totalTokens,n.set(e.model,t)}return[...n.values()].sort((e,t)=>t.cost-e.cost)}export{n as mergeFoldedCostIntoLatestFrozen};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,i as n,n as r,s as i,t as a}from"./signed-fetch-BYlgbN5-.js";import{t as o}from"./remote-cache-UwMD8EkX.js";var s=e({AEM_SOURCE_BUS_ORIGIN:()=>AEM_SOURCE_BUS_ORIGIN,AemMountBackend:()=>i,DaMountBackend:()=>t,RemoteMountCache:()=>o,S3MountBackend:()=>n,makeSignedFetchDa:()=>a,makeSignedFetchS3:()=>r});export{s as t};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t,i as n,n as r,s as i,t as a}from"./signed-fetch-C1-081oc.js";import{t as o}from"./remote-cache-UwMD8EkX.js";var s=e({AEM_SOURCE_BUS_ORIGIN:()=>AEM_SOURCE_BUS_ORIGIN,AemMountBackend:()=>i,DaMountBackend:()=>t,RemoteMountCache:()=>o,S3MountBackend:()=>n,makeSignedFetchDa:()=>a,makeSignedFetchS3:()=>r});export{s as t};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-B9NAiCud.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/core-4boN-CgI.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/preload-helper-Czpn1I53.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-Cplb-Tee.js","assets/base64-ELzoYfwP.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-Dm_PZRZx.js","assets/float-topology-C9GjBEv-.js","assets/secrets-bridge-client-CWv2_nw7.js","assets/port-bridge-client-D_erEovW.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-DdxfStbH.js","assets/panel-rpc-D3EPRnmw.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-D0xZwlMO.js";import{r as n,t as r}from"./base64-ELzoYfwP.js";import{t as i}from"./types-D8gIX-W-.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-B-LLf0bG.js";import{t as a}from"./remote-cache-CuIV6-dC.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:o,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=f(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=`\r
3
- `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=5242880,T=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function E(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var D=26214400,O=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-B9NAiCud.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-B857f9Kw.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/core-4boN-CgI.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/preload-helper-Czpn1I53.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-Cplb-Tee.js","assets/base64-ELzoYfwP.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-Dm_PZRZx.js","assets/float-topology-C9GjBEv-.js","assets/secrets-bridge-client-CWv2_nw7.js","assets/port-bridge-client-D_erEovW.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-jygoVQBo.js","assets/panel-rpc-D3EPRnmw.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-D0xZwlMO.js";import{r as n,t as r}from"./base64-ELzoYfwP.js";import{t as i}from"./types-D8gIX-W-.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-Bl4-flxd.js";import{t as a}from"./remote-cache-CuIV6-dC.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:o,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=f(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=`\r
3
+ `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=5242880,T=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function E(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var D=26214400,O=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-B857f9Kw.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-BC2oDrme.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/preload-helper-Czpn1I53.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/logger-DDBAeTLF.js","assets/account-store-B9NAiCud.js","assets/core-4boN-CgI.js","assets/libesm-BypnjKEL.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-Cplb-Tee.js","assets/base64-ELzoYfwP.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-Dm_PZRZx.js","assets/float-topology-C9GjBEv-.js","assets/secrets-bridge-client-CWv2_nw7.js","assets/port-bridge-client-D_erEovW.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-DdxfStbH.js","assets/panel-rpc-D3EPRnmw.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-2DY2vYOc.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{a as n}from"./feature-flags-DvsApnS-.js";import{V as r,g as i}from"./account-store-B9NAiCud.js";import"./main-DFzXj4Ap.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{F as o,G as s,I as c,L as l,R as u,W as d,z as f}from"./wc-live-B3xfspeg.js";var p=t(`new-session`),m=`ui-new-session`,h=2e4,g=5e3,_=250;async function v(e){try{let t=await e.openVfs(),n=i()??void 0;if(!n)return;let o;try{o=r()}catch{return}let s=o.provider===`adobe`?{"X-Session-Id":a(m)}:void 0;await f({vfs:t,model:o,apiKey:n,headers:s}),e.onComplete?.()}catch(e){p.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function y(e){(e.schedule??b)(()=>{v(e)})}function b(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function x(e){if(n(`agentic-memory`)){if(!e.agenticMemorySpawn){p.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function S(e,t,n,r,i,a){let o=await l({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});return o?(await w(e,o),C(e,t,n,r,i,a,o),o):null}async function C(t,n,r,i,a,s,l){let u=l;try{let n=await c(t.vfs,l,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-BC2oDrme.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32])).then(({pickLucideIcon:e})=>e(t))});n&&(u={...n,archive:l.archive},t.onBackgroundEnriched?.(n))}catch(e){p.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:l.filename,error:e instanceof Error?e.message:String(e)})}let d=await o({sessionStore:n,vfs:t.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:s,cone:t.cone},u).catch(e=>(p.warn(`Agentic memory curator threw (entry stays pending)`,{filename:u.filename,error:e instanceof Error?e.message:String(e)}),null));p.info(`Agentic memory curator finished`,{filename:u.filename,memoryPending:!d||d.memoryPending===!0}),t.onBackgroundEnriched?.(d),t.onSessionSettled?.(d??u)}async function w(e,t){if(!e.captureCompleteSnapshot)return;let n=new AbortController,r,i=new Promise((e,t)=>{r=setTimeout(()=>{n.abort(),t(Object.assign(Error(`Complete snapshot timed out`),{code:`snapshot-timeout`}))},g)});try{await Promise.race([e.captureCompleteSnapshot(t,n.signal),i])}catch(n){let r=n?.code??`unknown`;p.warn(`captureCompleteSnapshot failed`,{code:r}),t.completeSnapshotUnavailable=!0;try{await u(e.vfs,t.filename)}catch{}}finally{r&&clearTimeout(r)}}function T(e){return e?.code===`ENOENT`}function E(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function D(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;if(!r.has(n)){if(i.type===`directory`){let t;try{t=await e.readDir(n)}catch(e){if(T(e))continue;throw e}if(await D(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!T(e))throw e}}}}async function O(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>E(e,t)))return;let r=new Set(n.filter(e=>e.startsWith(`${t}/`))),i;try{i=await e.readDir(t)}catch(n){if(n?.code!==`ENOENT`)throw n;await e.mkdir(t,{recursive:!0});return}await D(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function k(t){let n=t.enrichmentRaceMs??h,o=i()??void 0,u;try{u=r()}catch(e){p.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let f=u?.provider===`adobe`?{"X-Session-Id":a(m)}:void 0,g=new s(new d),_=o&&u?x(t):void 0;if(_)return await S(t,g,u,o,f,_);let v=await l({sessionStore:g,vfs:t.vfs,mode:`quick`,cone:t.cone});if(!v)return null;if(await w(t,v),!o||!u)return p.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),t.onSessionSettled?.(v),v;let y=u,b=c(t.vfs,v,{model:y,apiKey:o,headers:f,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-BC2oDrme.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(p.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await A(b,n,t.onProgress);if(C.kind===`llm`){let e=C.updated?{...C.updated,archive:v.archive}:v;return t.onSessionSettled?.(e),e}return b.then(e=>{p.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),t.onBackgroundEnriched?.(e),t.onSessionSettled?.(e??v)}),v}async function A(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},_));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function j(e){return N(e,void 0)}async function M(e){return N(e,`skip`)}async function N(e,t){let n=new s(new d),r=await l({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});return r&&await w(e,r),r&&e.onSessionSettled?.(r),r}export{O as resetNewSessionTmp,M as runNewSessionArchiveOnly,k as runNewSessionFreeze,j as runNewSessionFreezeQuick,y as schedulePendingSessionCatchup};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-D6Wr4TyZ.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/preload-helper-Czpn1I53.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/logger-DDBAeTLF.js","assets/account-store-B857f9Kw.js","assets/core-4boN-CgI.js","assets/libesm-BypnjKEL.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-Cplb-Tee.js","assets/base64-ELzoYfwP.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-Dm_PZRZx.js","assets/float-topology-C9GjBEv-.js","assets/secrets-bridge-client-CWv2_nw7.js","assets/port-bridge-client-D_erEovW.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-jygoVQBo.js","assets/panel-rpc-D3EPRnmw.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-2DY2vYOc.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{a as n}from"./feature-flags-DvsApnS-.js";import{V as r,g as i}from"./account-store-B857f9Kw.js";import"./main-CxkrqswY.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{F as o,G as s,I as c,L as l,R as u,W as d,z as f}from"./wc-live-DPQeITgQ.js";var p=t(`new-session`),m=`ui-new-session`,h=2e4,g=5e3,_=250;async function v(e){try{let t=await e.openVfs(),n=i()??void 0;if(!n)return;let o;try{o=r()}catch{return}let s=o.provider===`adobe`?{"X-Session-Id":a(m)}:void 0;await f({vfs:t,model:o,apiKey:n,headers:s}),e.onComplete?.()}catch(e){p.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function y(e){(e.schedule??b)(()=>{v(e)})}function b(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function x(e){if(n(`agentic-memory`)){if(!e.agenticMemorySpawn){p.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function S(e,t,n,r,i,a){let o=await l({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});return o?(await w(e,o),C(e,t,n,r,i,a,o),o):null}async function C(t,n,r,i,a,s,l){let u=l;try{let n=await c(t.vfs,l,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-D6Wr4TyZ.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32])).then(({pickLucideIcon:e})=>e(t))});n&&(u={...n,archive:l.archive},t.onBackgroundEnriched?.(n))}catch(e){p.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:l.filename,error:e instanceof Error?e.message:String(e)})}let d=await o({sessionStore:n,vfs:t.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:s,cone:t.cone},u).catch(e=>(p.warn(`Agentic memory curator threw (entry stays pending)`,{filename:u.filename,error:e instanceof Error?e.message:String(e)}),null));p.info(`Agentic memory curator finished`,{filename:u.filename,memoryPending:!d||d.memoryPending===!0}),t.onBackgroundEnriched?.(d),t.onSessionSettled?.(d??u)}async function w(e,t){if(!e.captureCompleteSnapshot)return;let n=new AbortController,r,i=new Promise((e,t)=>{r=setTimeout(()=>{n.abort(),t(Object.assign(Error(`Complete snapshot timed out`),{code:`snapshot-timeout`}))},g)});try{await Promise.race([e.captureCompleteSnapshot(t,n.signal),i])}catch(n){let r=n?.code??`unknown`;p.warn(`captureCompleteSnapshot failed`,{code:r}),t.completeSnapshotUnavailable=!0;try{await u(e.vfs,t.filename)}catch{}}finally{r&&clearTimeout(r)}}function T(e){return e?.code===`ENOENT`}function E(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function D(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;if(!r.has(n)){if(i.type===`directory`){let t;try{t=await e.readDir(n)}catch(e){if(T(e))continue;throw e}if(await D(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!T(e))throw e}}}}async function O(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>E(e,t)))return;let r=new Set(n.filter(e=>e.startsWith(`${t}/`))),i;try{i=await e.readDir(t)}catch(n){if(n?.code!==`ENOENT`)throw n;await e.mkdir(t,{recursive:!0});return}await D(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function k(t){let n=t.enrichmentRaceMs??h,o=i()??void 0,u;try{u=r()}catch(e){p.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let f=u?.provider===`adobe`?{"X-Session-Id":a(m)}:void 0,g=new s(new d),_=o&&u?x(t):void 0;if(_)return await S(t,g,u,o,f,_);let v=await l({sessionStore:g,vfs:t.vfs,mode:`quick`,cone:t.cone});if(!v)return null;if(await w(t,v),!o||!u)return p.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),t.onSessionSettled?.(v),v;let y=u,b=c(t.vfs,v,{model:y,apiKey:o,headers:f,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-D6Wr4TyZ.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(p.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await A(b,n,t.onProgress);if(C.kind===`llm`){let e=C.updated?{...C.updated,archive:v.archive}:v;return t.onSessionSettled?.(e),e}return b.then(e=>{p.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),t.onBackgroundEnriched?.(e),t.onSessionSettled?.(e??v)}),v}async function A(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},_));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function j(e){return N(e,void 0)}async function M(e){return N(e,`skip`)}async function N(e,t){let n=new s(new d),r=await l({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});return r&&await w(e,r),r&&e.onSessionSettled?.(r),r}export{O as resetNewSessionTmp,M as runNewSessionArchiveOnly,k as runNewSessionFreeze,j as runNewSessionFreezeQuick,y as schedulePendingSessionCatchup};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-DV5A_7IM.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/account-store-B9NAiCud.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/core-4boN-CgI.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/libesm-BypnjKEL.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-Cplb-Tee.js","assets/base64-ELzoYfwP.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-Dm_PZRZx.js","assets/float-topology-C9GjBEv-.js","assets/secrets-bridge-client-CWv2_nw7.js","assets/port-bridge-client-D_erEovW.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-DdxfStbH.js","assets/panel-rpc-D3EPRnmw.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js","assets/global-db-CbuLl-zx.js","assets/bridge-token-required-DMk2va9k.js","assets/pkce-hGf_TEnP.js","assets/types-D8gIX-W-.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{K as n,f as r}from"./account-store-B9NAiCud.js";import{t as i}from"./providers-DdxfStbH.js";import"./main-DFzXj4Ap.js";import"./logger-BoSvu4mW.js";var a=t(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-DV5A_7IM.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:s(e)})}}function l(e){return(e.tokenExpiresAt??1/0)-Date.now()<=o}async function u(e){let t=i(e.providerId);if(!t?.onSilentRenew){a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});return}try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});return}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId})}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:s(t)})}}async function d(e,t){try{await n({providerId:e.providerId,accessToken:t,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:s(t)})}}async function f(e){let t=e.accessToken;if(!t){a.debug(`Skipping account without token`,{providerId:e.providerId});return}if(l(e)){await u(e);return}await d(e,t)}async function p(){await c();let e=r();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-MDIcOntz.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/account-store-B857f9Kw.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/core-4boN-CgI.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/libesm-BypnjKEL.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-Cplb-Tee.js","assets/base64-ELzoYfwP.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/runtime-env-Dlaokqg1.js","assets/secret-topology-Dm_PZRZx.js","assets/float-topology-C9GjBEv-.js","assets/secrets-bridge-client-CWv2_nw7.js","assets/port-bridge-client-D_erEovW.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-jygoVQBo.js","assets/panel-rpc-D3EPRnmw.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js","assets/global-db-CbuLl-zx.js","assets/bridge-token-required-DMk2va9k.js","assets/pkce-hGf_TEnP.js","assets/types-D8gIX-W-.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{K as n,f as r}from"./account-store-B857f9Kw.js";import{t as i}from"./providers-jygoVQBo.js";import"./main-CxkrqswY.js";import"./logger-BoSvu4mW.js";var a=t(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-MDIcOntz.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:s(e)})}}function l(e){return(e.tokenExpiresAt??1/0)-Date.now()<=o}async function u(e){let t=i(e.providerId);if(!t?.onSilentRenew){a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});return}try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});return}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId})}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:s(t)})}}async function d(e,t){try{await n({providerId:e.providerId,accessToken:t,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:s(t)})}}async function f(e){let t=e.accessToken;if(!t){a.debug(`Skipping account without token`,{providerId:e.providerId});return}if(l(e)){await u(e);return}await d(e,t)}async function p(){await c();let e=r();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./slugify-BYJ6QVAt.js";import{i as n}from"./wc-onboarding-Cj-8agbG.js";var r={openai:{url:e=>`${(e??`https://api.openai.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},anthropic:{url:e=>`${(e??`https://api.anthropic.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({"x-api-key":e,"anthropic-version":`2023-06-01`})},groq:{url:e=>`${(e??`https://api.groq.com/openai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},cerebras:{url:e=>`${(e??`https://api.cerebras.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},mistral:{url:e=>`${(e??`https://api.mistral.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},"x-ai":{url:e=>`${(e??`https://api.x.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},deepseek:{url:e=>`${(e??`https://api.deepseek.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},openrouter:{url:e=>`${(e??`https://openrouter.ai/api`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},google:{url:e=>`${(e??`https://generativelanguage.googleapis.com`).replace(/\/$/,``)}/v1beta/models`,headers:()=>({})}};function i(e,t){if(e===401||e===403)return`Authentication failed — the key was rejected by the provider.`;if(e===404)return`Endpoint not found — check the base URL.`;if(e===429)return`Rate-limited — try again in a moment.`;if(e>=500)return`Provider returned a server error.`;let n=t.trim();return n?`${e}: ${n.slice(0,160)}`:`Provider responded with HTTP ${e}.`}async function a(e){let{provider:t,apiKey:n,baseUrl:a,signal:o}=e,s=e.fetchImpl??fetch,c=n.trim();if(!c)return{kind:`failed`,status:null,message:`API key is empty.`};let l=r[t];if(!l)return{kind:`skipped`,reason:`No live validation available for "${t}" — saving without testing.`};let u=l.url(a);if(t===`google`){let e=u.includes(`?`)?`&`:`?`;u=`${u}${e}key=${encodeURIComponent(c)}`}try{let e=await s(u,{method:`GET`,headers:l.headers(c),signal:o});if(e.ok)return{kind:`ok`};let t=``;try{t=await e.text()}catch{}return e.status===401||e.status,{kind:`failed`,status:e.status,message:i(e.status,t)}}catch(e){if(e?.name===`AbortError`)throw e;return{kind:`skipped`,reason:`Couldn't reach the provider (${e instanceof Error?e.message:String(e)}). Saving without live test — you can retry from Settings.`}}}var o=[e=>`Nice to meet you, ${e}.`,e=>`Hello ${e} — glad you stopped by.`,e=>`Hey ${e}, welcome aboard.`,e=>`${e}! Pleasure to make your acquaintance.`],s=[`Nice to meet you, mysterious stranger — I'll respect the incognito.`,`Hello, anonymous traveler. You can always tell me your name later if you change your mind.`,`An unnamed visitor — intriguing. Whenever you'd like to introduce yourself, just say the word.`,`Hey there, ghost — happy to keep things first-name-optional. The door's always open if you decide to drop the cloak.`],c={work:[`Work mode — let's make today productive.`,`On the clock? Same. Let's chip away at it.`],school:[`School business — I love a good study session.`,`Hitting the books? Glad to ride along.`],personal:[`Personal project energy is the best kind.`,`Tinkering for yourself is how the good stuff happens.`],"side-project":[`Side projects keep the lights on creatively.`,`Two-job life — respect.`],exploring:[`Just poking around? Excellent. The best discoveries start there.`,`Exploration mode — no agenda, no pressure.`]},l={developer:[`I can write code, run shell commands, drive a real browser, and ship pages.`,`Code, terminals, browsers, repos — I live in all of them.`],designer:[`I can prototype layouts, generate assets, and walk page editors with you.`,`Pixels, components, screenshots — design ops are my jam.`],"content-creator":[`I can draft copy, edit, scrape references, and stitch publish-ready pages.`,`Words, structure, SEO, polish — say the topic and I'll get moving.`],marketer:[`I can audit funnels, scrape competitors, and stand up landing pages quickly.`,`Campaigns, analytics, creatives — plug me in and I'll go.`],"product-pm":[`I can summarise research, draft specs, and crunch competitive intel.`,`Briefs, roadmaps, comparisons — I take the boring half off your plate.`],founder:[`I can prototype landing pages, automate ops, and prep investor decks.`,`Idea → MVP → repeat. I'll do the legwork between coffee refills.`],student:[`I can read papers with you, draft notes, and turn lectures into outlines.`,`Studying together makes it bearable — let me handle the busywork.`],researcher:[`I can scrape sources, summarise findings, and keep a running bibliography.`,`Lit reviews, datasets, write-ups — I'm all in.`],other:[`I'm flexible — give me a task and I'll figure out the right tools.`,`Whatever the role, I can probably help. Tell me what's on the docket.`]},u=[`I can browse the web, run commands, write code, and automate the boring parts.`,`I'm comfortable with terminals, browsers, files, and a long backlog of skills.`],d=[`But to be honest, I'm not really an AI yet — I'm an empty shell. You'll need to help me become intelligent. Pick a model and I'll wake up:`,`Confession time: I can't actually think yet. Wire me up to an LLM and I'll start earning my keep:`,`Plot twist — there's no brain in here. Choose a provider so I can do more than read this script:`,`Truthfully? I'm a very polite placeholder until you give me a model. Help me out:`];function f(e,t){return e[Math.floor(t()*e.length)%e.length]}function p(e){return e.replace(/-/g,` `)}function m(e){if(e.length===0)return``;if(e.length===1)return e[0];if(e.length===2)return`${e[0]} and ${e[1]}`;let t=e[e.length-1];return`${e.slice(0,-1).join(`, `)}, and ${t}`}function h(e,t=Math.random){let n=(e.name||``).trim(),r=e.purpose?c[e.purpose]:void 0;return n?`${f(o,t)(n)}${r?` ${f(r,t)}`:``}`:`${f(s,t)}${r?` ${f(r,t)}`:``}`}function g(e,t=Math.random){let n=e.role&&l[e.role]?e.role:``,r=f(n?l[n]:u,t),i=(e.tasks??[]).slice(0,3).map(p);return`I'm sliccy. ${r}${i.length>0?` Especially handy for ${m(i)}.`:``} I'm an AI agent.`}function _(e,t=Math.random){return f(d,t)}function v(e,t=Math.random){return[h(e,t),g(e,t),_(e,t)]}var y=e(`onboarding-orchestrator`),b=class{deps;stage=`idle`;profile={};constructor(e){this.deps=e}getStage(){return this.stage}getProfile(){return{...this.profile}}handleFirstRun(){this.stage===`idle`&&(this.stage=`collect-profile`,this.deps.postDipReference(`Welcome to SLICC — let's get you set up.`),this.deps.postDipReference(`![Welcome](/shared/sprinkles/welcome/welcome.shtml)`))}async handleOnboardingComplete(e){if(this.stage!==`idle`&&this.stage!==`collect-profile`)return y.debug(`Ignoring duplicate onboarding-complete`,{stage:this.stage}),!0;this.profile=e??{},this.stage=`awaiting-connect`,n(this.deps.fs).catch(e=>y.warn(`recordWelcomed failed`,e)),this.persistProfile(this.profile).catch(e=>y.warn(`persistProfile failed`,e));let t=v(this.profile,this.deps.rand);for(let e of t)this.deps.postSystemMessage(e);return this.deps.postDipReference(`![Connect a model](/shared/sprinkles/welcome/connect-llm.shtml)`),!0}handleConnectReady(){if(this.stage===`complete`)return;let e=this.deps.getProviderCatalogue();this.deps.broadcastToDip({type:`slicc-providers`,providers:e.providers,models:e.models})}async handleConnectAttempt(e){if(this.stage===`complete`)return;this.stage=`connecting`;let{provider:t,apiKey:n,baseUrl:r,deployment:i,apiVersion:o,model:s}=e;if(!t||typeof n!=`string`||!n.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Provider and API key are required.`}),this.stage=`awaiting-connect`;return}let c=this.validateProviderRequiredFields(t,r,i);if(c){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:c}),this.stage=`awaiting-connect`;return}let l;try{l=await a({provider:t,apiKey:n.trim(),baseUrl:r??void 0,fetchImpl:this.deps.fetchImpl})}catch(e){y.warn(`validateApiKey threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Validation request was aborted.`}),this.stage=`awaiting-connect`;return}if(l.kind===`failed`){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:l.message}),this.stage=`awaiting-connect`;return}let u=s||null;if(!u)try{let e=this.deps.getProviderCatalogue().models?.[t]?.[0]?.id;e&&(u=e)}catch(e){y.warn(`Failed to resolve fallback model for provider`,{provider:t,err:e})}try{this.deps.saveAccount(t,n.trim(),r?.trim()||void 0,i?.trim()||void 0,o?.trim()||void 0),u&&this.deps.setSelectedModel(x(t,u))}catch(e){y.warn(`saveAccount failed`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Failed to save credentials locally.`}),this.stage=`awaiting-connect`;return}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}let d=l.kind===`skipped`?`Saved — ${l.reason}`:`Validated against the provider. Ready when you are.`;this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:l.kind,note:d});let f=u&&this.deps.resolveModelLabel?.(t,u)?this.deps.resolveModelLabel?.(t,u):u||null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:t,model:u??null,modelLabel:f,validation:l.kind}})}async handleOAuthAttempt(e){if(this.stage===`complete`)return;if(!this.deps.launchOAuth){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`OAuth login is not available in this runtime.`});return}this.stage=`connecting`;let t;try{t=await this.deps.launchOAuth(e.provider,e.baseUrl??null)}catch(e){y.warn(`launchOAuth threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:e instanceof Error?e.message:`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(!t.ok){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:t.message||`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(t.model)try{this.deps.setSelectedModel(x(e.provider,t.model))}catch(e){y.warn(`setSelectedModel after OAuth failed`,e)}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:`ok`,note:t.message||`Logged in.`});let n=t.model&&this.deps.resolveModelLabel?.(e.provider,t.model)?this.deps.resolveModelLabel?.(e.provider,t.model):t.model??null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:e.provider,model:t.model??null,modelLabel:n,validation:`oauth`}})}validateProviderRequiredFields(e,t,n){let r;try{r=this.deps.getProviderCatalogue().providers.find(t=>t.id===e)}catch(e){return y.warn(`getProviderCatalogue threw during required-field gate`,e),`Could not load provider requirements. Please try again.`}return r?.requiresDeployment&&!n?.trim()?`${r.name} requires a deployment name.`:r?.requiresBaseUrl&&!t?.trim()?`${r.name} requires a base URL.`:null}async persistProfile(e){let n=t(e.name||`user`,{fallback:`user`});await this.deps.fs.writeFile(`/home/${n}/.welcome.json`,JSON.stringify(e,null,2))}};function x(e,t){return t.startsWith(`${e}:`)?t:`${e}:${t}`}export{b as OnboardingOrchestrator};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./slugify-BYJ6QVAt.js";import{i as n}from"./wc-onboarding-nZO6VPxy.js";var r={openai:{url:e=>`${(e??`https://api.openai.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},anthropic:{url:e=>`${(e??`https://api.anthropic.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({"x-api-key":e,"anthropic-version":`2023-06-01`})},groq:{url:e=>`${(e??`https://api.groq.com/openai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},cerebras:{url:e=>`${(e??`https://api.cerebras.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},mistral:{url:e=>`${(e??`https://api.mistral.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},"x-ai":{url:e=>`${(e??`https://api.x.ai`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},deepseek:{url:e=>`${(e??`https://api.deepseek.com`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},openrouter:{url:e=>`${(e??`https://openrouter.ai/api`).replace(/\/$/,``)}/v1/models`,headers:e=>({Authorization:`Bearer ${e}`})},google:{url:e=>`${(e??`https://generativelanguage.googleapis.com`).replace(/\/$/,``)}/v1beta/models`,headers:()=>({})}};function i(e,t){if(e===401||e===403)return`Authentication failed — the key was rejected by the provider.`;if(e===404)return`Endpoint not found — check the base URL.`;if(e===429)return`Rate-limited — try again in a moment.`;if(e>=500)return`Provider returned a server error.`;let n=t.trim();return n?`${e}: ${n.slice(0,160)}`:`Provider responded with HTTP ${e}.`}async function a(e){let{provider:t,apiKey:n,baseUrl:a,signal:o}=e,s=e.fetchImpl??fetch,c=n.trim();if(!c)return{kind:`failed`,status:null,message:`API key is empty.`};let l=r[t];if(!l)return{kind:`skipped`,reason:`No live validation available for "${t}" — saving without testing.`};let u=l.url(a);if(t===`google`){let e=u.includes(`?`)?`&`:`?`;u=`${u}${e}key=${encodeURIComponent(c)}`}try{let e=await s(u,{method:`GET`,headers:l.headers(c),signal:o});if(e.ok)return{kind:`ok`};let t=``;try{t=await e.text()}catch{}return e.status===401||e.status,{kind:`failed`,status:e.status,message:i(e.status,t)}}catch(e){if(e?.name===`AbortError`)throw e;return{kind:`skipped`,reason:`Couldn't reach the provider (${e instanceof Error?e.message:String(e)}). Saving without live test — you can retry from Settings.`}}}var o=[e=>`Nice to meet you, ${e}.`,e=>`Hello ${e} — glad you stopped by.`,e=>`Hey ${e}, welcome aboard.`,e=>`${e}! Pleasure to make your acquaintance.`],s=[`Nice to meet you, mysterious stranger — I'll respect the incognito.`,`Hello, anonymous traveler. You can always tell me your name later if you change your mind.`,`An unnamed visitor — intriguing. Whenever you'd like to introduce yourself, just say the word.`,`Hey there, ghost — happy to keep things first-name-optional. The door's always open if you decide to drop the cloak.`],c={work:[`Work mode — let's make today productive.`,`On the clock? Same. Let's chip away at it.`],school:[`School business — I love a good study session.`,`Hitting the books? Glad to ride along.`],personal:[`Personal project energy is the best kind.`,`Tinkering for yourself is how the good stuff happens.`],"side-project":[`Side projects keep the lights on creatively.`,`Two-job life — respect.`],exploring:[`Just poking around? Excellent. The best discoveries start there.`,`Exploration mode — no agenda, no pressure.`]},l={developer:[`I can write code, run shell commands, drive a real browser, and ship pages.`,`Code, terminals, browsers, repos — I live in all of them.`],designer:[`I can prototype layouts, generate assets, and walk page editors with you.`,`Pixels, components, screenshots — design ops are my jam.`],"content-creator":[`I can draft copy, edit, scrape references, and stitch publish-ready pages.`,`Words, structure, SEO, polish — say the topic and I'll get moving.`],marketer:[`I can audit funnels, scrape competitors, and stand up landing pages quickly.`,`Campaigns, analytics, creatives — plug me in and I'll go.`],"product-pm":[`I can summarise research, draft specs, and crunch competitive intel.`,`Briefs, roadmaps, comparisons — I take the boring half off your plate.`],founder:[`I can prototype landing pages, automate ops, and prep investor decks.`,`Idea → MVP → repeat. I'll do the legwork between coffee refills.`],student:[`I can read papers with you, draft notes, and turn lectures into outlines.`,`Studying together makes it bearable — let me handle the busywork.`],researcher:[`I can scrape sources, summarise findings, and keep a running bibliography.`,`Lit reviews, datasets, write-ups — I'm all in.`],other:[`I'm flexible — give me a task and I'll figure out the right tools.`,`Whatever the role, I can probably help. Tell me what's on the docket.`]},u=[`I can browse the web, run commands, write code, and automate the boring parts.`,`I'm comfortable with terminals, browsers, files, and a long backlog of skills.`],d=[`But to be honest, I'm not really an AI yet — I'm an empty shell. You'll need to help me become intelligent. Pick a model and I'll wake up:`,`Confession time: I can't actually think yet. Wire me up to an LLM and I'll start earning my keep:`,`Plot twist — there's no brain in here. Choose a provider so I can do more than read this script:`,`Truthfully? I'm a very polite placeholder until you give me a model. Help me out:`];function f(e,t){return e[Math.floor(t()*e.length)%e.length]}function p(e){return e.replace(/-/g,` `)}function m(e){if(e.length===0)return``;if(e.length===1)return e[0];if(e.length===2)return`${e[0]} and ${e[1]}`;let t=e[e.length-1];return`${e.slice(0,-1).join(`, `)}, and ${t}`}function h(e,t=Math.random){let n=(e.name||``).trim(),r=e.purpose?c[e.purpose]:void 0;return n?`${f(o,t)(n)}${r?` ${f(r,t)}`:``}`:`${f(s,t)}${r?` ${f(r,t)}`:``}`}function g(e,t=Math.random){let n=e.role&&l[e.role]?e.role:``,r=f(n?l[n]:u,t),i=(e.tasks??[]).slice(0,3).map(p);return`I'm sliccy. ${r}${i.length>0?` Especially handy for ${m(i)}.`:``} I'm an AI agent.`}function _(e,t=Math.random){return f(d,t)}function v(e,t=Math.random){return[h(e,t),g(e,t),_(e,t)]}var y=e(`onboarding-orchestrator`),b=class{deps;stage=`idle`;profile={};constructor(e){this.deps=e}getStage(){return this.stage}getProfile(){return{...this.profile}}handleFirstRun(){this.stage===`idle`&&(this.stage=`collect-profile`,this.deps.postDipReference(`Welcome to SLICC — let's get you set up.`),this.deps.postDipReference(`![Welcome](/shared/sprinkles/welcome/welcome.shtml)`))}async handleOnboardingComplete(e){if(this.stage!==`idle`&&this.stage!==`collect-profile`)return y.debug(`Ignoring duplicate onboarding-complete`,{stage:this.stage}),!0;this.profile=e??{},this.stage=`awaiting-connect`,n(this.deps.fs).catch(e=>y.warn(`recordWelcomed failed`,e)),this.persistProfile(this.profile).catch(e=>y.warn(`persistProfile failed`,e));let t=v(this.profile,this.deps.rand);for(let e of t)this.deps.postSystemMessage(e);return this.deps.postDipReference(`![Connect a model](/shared/sprinkles/welcome/connect-llm.shtml)`),!0}handleConnectReady(){if(this.stage===`complete`)return;let e=this.deps.getProviderCatalogue();this.deps.broadcastToDip({type:`slicc-providers`,providers:e.providers,models:e.models})}async handleConnectAttempt(e){if(this.stage===`complete`)return;this.stage=`connecting`;let{provider:t,apiKey:n,baseUrl:r,deployment:i,apiVersion:o,model:s}=e;if(!t||typeof n!=`string`||!n.trim()){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Provider and API key are required.`}),this.stage=`awaiting-connect`;return}let c=this.validateProviderRequiredFields(t,r,i);if(c){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:c}),this.stage=`awaiting-connect`;return}let l;try{l=await a({provider:t,apiKey:n.trim(),baseUrl:r??void 0,fetchImpl:this.deps.fetchImpl})}catch(e){y.warn(`validateApiKey threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Validation request was aborted.`}),this.stage=`awaiting-connect`;return}if(l.kind===`failed`){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:l.message}),this.stage=`awaiting-connect`;return}let u=s||null;if(!u)try{let e=this.deps.getProviderCatalogue().models?.[t]?.[0]?.id;e&&(u=e)}catch(e){y.warn(`Failed to resolve fallback model for provider`,{provider:t,err:e})}try{this.deps.saveAccount(t,n.trim(),r?.trim()||void 0,i?.trim()||void 0,o?.trim()||void 0),u&&this.deps.setSelectedModel(x(t,u))}catch(e){y.warn(`saveAccount failed`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`Failed to save credentials locally.`}),this.stage=`awaiting-connect`;return}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}let d=l.kind===`skipped`?`Saved — ${l.reason}`:`Validated against the provider. Ready when you are.`;this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:l.kind,note:d});let f=u&&this.deps.resolveModelLabel?.(t,u)?this.deps.resolveModelLabel?.(t,u):u||null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:t,model:u??null,modelLabel:f,validation:l.kind}})}async handleOAuthAttempt(e){if(this.stage===`complete`)return;if(!this.deps.launchOAuth){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:`OAuth login is not available in this runtime.`});return}this.stage=`connecting`;let t;try{t=await this.deps.launchOAuth(e.provider,e.baseUrl??null)}catch(e){y.warn(`launchOAuth threw`,e),this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:e instanceof Error?e.message:`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(!t.ok){this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!1,kind:`failed`,message:t.message||`Login was cancelled.`}),this.stage=`awaiting-connect`;return}if(t.model)try{this.deps.setSelectedModel(x(e.provider,t.model))}catch(e){y.warn(`setSelectedModel after OAuth failed`,e)}try{this.deps.onAccountsChanged?.()}catch(e){y.warn(`onAccountsChanged threw`,e)}this.deps.broadcastToDip({type:`slicc-connect-result`,ok:!0,kind:`ok`,note:t.message||`Logged in.`});let n=t.model&&this.deps.resolveModelLabel?.(e.provider,t.model)?this.deps.resolveModelLabel?.(e.provider,t.model):t.model??null;this.stage=`complete`,this.deps.fireFinalLick({action:`onboarding-complete-with-provider`,data:{profile:this.profile,provider:e.provider,model:t.model??null,modelLabel:n,validation:`oauth`}})}validateProviderRequiredFields(e,t,n){let r;try{r=this.deps.getProviderCatalogue().providers.find(t=>t.id===e)}catch(e){return y.warn(`getProviderCatalogue threw during required-field gate`,e),`Could not load provider requirements. Please try again.`}return r?.requiresDeployment&&!n?.trim()?`${r.name} requires a deployment name.`:r?.requiresBaseUrl&&!t?.trim()?`${r.name} requires a base URL.`:null}async persistProfile(e){let n=t(e.name||`user`,{fallback:`user`});await this.deps.fs.writeFile(`/home/${n}/.welcome.json`,JSON.stringify(e,null,2))}};function x(e,t){return t.startsWith(`${e}:`)?t:`${e}:${t}`}export{b as OnboardingOrchestrator};
@@ -1 +1 @@
1
- import{a as e}from"./diagnostics-Cag7MsZI.js";import{a as t}from"./compat-BAGLwgqY.js";import{n,o as r}from"./legacy-api-aliases-BjgG1CsY.js";import{K as i,f as a}from"./account-store-B9NAiCud.js";import"./main-DFzXj4Ap.js";import{n as o}from"./pi-transcript-context-miZCMig3.js";import{n as s,r as c}from"./bridge-token-required-DMk2va9k.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";var f=`openai-codex`,p=`app_EMoamEEZ73f0CkXaXp7hrann`,m=`https://auth.openai.com/oauth/authorize`,h=`https://auth.openai.com/oauth/token`,g=`openid profile email offline_access`,_=`http://localhost:1455/auth/callback`,v=`http://localhost:1455/auth/callback*`,y=`https://chatgpt.com/backend-api`,b=`openai-codex-responses`,x=`${f}-openai`,S={xhigh:`xhigh`,minimal:`low`},C=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:S}));async function w(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:p,code:e,code_verifier:t,redirect_uri:_}),r=await fetch(h,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function T(e){if(s())return null;try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:p}),n=await fetch(h,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text();return c(n.status,e)||console.error(`[openai-codex] refresh failed:`,n.status,e),null}return await n.json()}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function E(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function D(e){let t=E(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function O(e){let t=E(e)?.[`https://api.openai.com/auth`],n=D(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function k(e){let t=D(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function A(){return a().find(e=>e.providerId===f)}async function j(){let e=A();if(!e?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let t=e.tokenExpiresAt??0;if(t&&Date.now()+6e4<t)return e.accessToken;if(e.refreshToken){let t=await T(e.refreshToken);if(t?.access_token)return await i({providerId:f,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??3600)*1e3,baseUrl:y,userName:O(t.access_token),userAvatar:await k(t.access_token),scopes:t.scope??e.scopes}),t.access_token}return e.accessToken}function M(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:x,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function N(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function P(e,t,r,i){try{let a=await j(),s={...t,baseUrl:y,api:b},c=n(s,o(r),{...i,apiKey:a,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){N(n),e.push(M(t,n)),e.end()}}async function F(e,t,n,i){try{let a=await j(),s={...t,baseUrl:y,api:b},c=r(s,o(n),{...i,apiKey:a,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){N(n),e.push(M(t,n)),e.end()}}var I=(t,n,r={})=>{let i=e();return P(i,t,n,r).catch(N),i},L=(t,n,r)=>{let i=e();return F(i,t,n,r).catch(N),i},R={id:f,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>C,onOAuthLoginIntercepted:async(e,t,n)=>{let r=l(),a=await d(r),o=u(),s=new URL(m);s.searchParams.set(`response_type`,`code`),s.searchParams.set(`client_id`,p),s.searchParams.set(`redirect_uri`,_),s.searchParams.set(`scope`,n?.scopes??g),s.searchParams.set(`code_challenge`,a),s.searchParams.set(`code_challenge_method`,`S256`),s.searchParams.set(`state`,o),s.searchParams.set(`id_token_add_organizations`,`true`),s.searchParams.set(`codex_cli_simplified_flow`,`true`),s.searchParams.set(`originator`,`pi`);let c=await e({authorizeUrl:s.toString(),redirectUriPattern:v,onCapture:`close`});if(!c)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let h=new URL(c),b=h.searchParams.get(`code`),x=h.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(x!==o)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let S=await w(b,r);await i({providerId:f,accessToken:S.access_token,refreshToken:S.refresh_token,tokenExpiresAt:Date.now()+(S.expires_in??3600)*1e3,baseUrl:y,userName:O(S.access_token),userAvatar:await k(S.access_token),scopes:S.scope}),t()},onOAuthLogout:async()=>{await i({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=A();if(!e?.refreshToken)return null;let t=await T(e.refreshToken);return t?.access_token?(await i({providerId:f,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??3600)*1e3,baseUrl:y,userName:O(t.access_token),userAvatar:await k(t.access_token),scopes:t.scope??e.scopes}),t.access_token):null}};function z(){t({api:x,stream:I,streamSimple:L})}export{R as config,z as register};
1
+ import{a as e}from"./diagnostics-Cag7MsZI.js";import{a as t}from"./compat-BAGLwgqY.js";import{n,o as r}from"./legacy-api-aliases-BjgG1CsY.js";import{K as i,f as a}from"./account-store-B857f9Kw.js";import"./main-CxkrqswY.js";import{n as o}from"./pi-transcript-context-miZCMig3.js";import{n as s,r as c}from"./bridge-token-required-DMk2va9k.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";var f=`openai-codex`,p=`app_EMoamEEZ73f0CkXaXp7hrann`,m=`https://auth.openai.com/oauth/authorize`,h=`https://auth.openai.com/oauth/token`,g=`openid profile email offline_access`,_=`http://localhost:1455/auth/callback`,v=`http://localhost:1455/auth/callback*`,y=`https://chatgpt.com/backend-api`,b=`openai-codex-responses`,x=`${f}-openai`,S={xhigh:`xhigh`,minimal:`low`},C=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:S}));async function w(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:p,code:e,code_verifier:t,redirect_uri:_}),r=await fetch(h,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function T(e){if(s())return null;try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:p}),n=await fetch(h,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text();return c(n.status,e)||console.error(`[openai-codex] refresh failed:`,n.status,e),null}return await n.json()}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function E(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function D(e){let t=E(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function O(e){let t=E(e)?.[`https://api.openai.com/auth`],n=D(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function k(e){let t=D(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function A(){return a().find(e=>e.providerId===f)}async function j(){let e=A();if(!e?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let t=e.tokenExpiresAt??0;if(t&&Date.now()+6e4<t)return e.accessToken;if(e.refreshToken){let t=await T(e.refreshToken);if(t?.access_token)return await i({providerId:f,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??3600)*1e3,baseUrl:y,userName:O(t.access_token),userAvatar:await k(t.access_token),scopes:t.scope??e.scopes}),t.access_token}return e.accessToken}function M(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:x,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function N(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function P(e,t,r,i){try{let a=await j(),s={...t,baseUrl:y,api:b},c=n(s,o(r),{...i,apiKey:a,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){N(n),e.push(M(t,n)),e.end()}}async function F(e,t,n,i){try{let a=await j(),s={...t,baseUrl:y,api:b},c=r(s,o(n),{...i,apiKey:a,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){N(n),e.push(M(t,n)),e.end()}}var I=(t,n,r={})=>{let i=e();return P(i,t,n,r).catch(N),i},L=(t,n,r)=>{let i=e();return F(i,t,n,r).catch(N),i},R={id:f,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>C,onOAuthLoginIntercepted:async(e,t,n)=>{let r=l(),a=await d(r),o=u(),s=new URL(m);s.searchParams.set(`response_type`,`code`),s.searchParams.set(`client_id`,p),s.searchParams.set(`redirect_uri`,_),s.searchParams.set(`scope`,n?.scopes??g),s.searchParams.set(`code_challenge`,a),s.searchParams.set(`code_challenge_method`,`S256`),s.searchParams.set(`state`,o),s.searchParams.set(`id_token_add_organizations`,`true`),s.searchParams.set(`codex_cli_simplified_flow`,`true`),s.searchParams.set(`originator`,`pi`);let c=await e({authorizeUrl:s.toString(),redirectUriPattern:v,onCapture:`close`});if(!c)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let h=new URL(c),b=h.searchParams.get(`code`),x=h.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(x!==o)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let S=await w(b,r);await i({providerId:f,accessToken:S.access_token,refreshToken:S.refresh_token,tokenExpiresAt:Date.now()+(S.expires_in??3600)*1e3,baseUrl:y,userName:O(S.access_token),userAvatar:await k(S.access_token),scopes:S.scope}),t()},onOAuthLogout:async()=>{await i({providerId:f,accessToken:``})},onSilentRenew:async()=>{let e=A();if(!e?.refreshToken)return null;let t=await T(e.refreshToken);return t?.access_token?(await i({providerId:f,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??3600)*1e3,baseUrl:y,userName:O(t.access_token),userAvatar:await k(t.access_token),scopes:t.scope??e.scopes}),t.access_token):null}};function z(){t({api:x,stream:I,streamSimple:L})}export{R as config,z as register};
@@ -1 +1 @@
1
- import{_ as e,r as t}from"./account-store-BjfGeTTt.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{a as r}from"./compat-nGhSz-U1.js";import{n as i,o as a}from"./legacy-api-aliases--xyLjPgC.js";import{n as o}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings--5JFkAeb.js";import{n as s,r as c}from"./bridge-token-required-BYgoMwr7.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";const f=`openai-codex`,p=`app_EMoamEEZ73f0CkXaXp7hrann`,m=`https://auth.openai.com/oauth/token`,h=`http://localhost:1455/auth/callback`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${f}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:p,code:e,code_verifier:t,redirect_uri:h}),r=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){if(s())return null;try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:p}),n=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text();return c(n.status,e)||console.error(`[openai-codex] refresh failed:`,n.status,e),null}return await n.json()}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===f)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:f,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function A(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function j(e,t,n,r){try{let a=await O(),s={...t,baseUrl:g,api:_},c=i(s,o(n),{...r,apiKey:a,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}async function M(e,t,n,r){try{let i=await O(),s={...t,baseUrl:g,api:_},c=a(s,o(n),{...r,apiKey:i,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}const N=(e,t,r={})=>{let i=n();return j(i,e,t,r).catch(A),i},P=(e,t,r)=>{let i=n();return M(i,e,t,r).catch(A),i},F={id:f,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=l(),a=await d(i),o=u(),s=new URL(`https://auth.openai.com/oauth/authorize`);s.searchParams.set(`response_type`,`code`),s.searchParams.set(`client_id`,p),s.searchParams.set(`redirect_uri`,h),s.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),s.searchParams.set(`code_challenge`,a),s.searchParams.set(`code_challenge_method`,`S256`),s.searchParams.set(`state`,o),s.searchParams.set(`id_token_add_organizations`,`true`),s.searchParams.set(`codex_cli_simplified_flow`,`true`),s.searchParams.set(`originator`,`pi`);let c=await t({authorizeUrl:s.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!c)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let m=new URL(c),_=m.searchParams.get(`code`),v=m.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(v!==o)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let y=await x(_,i);await e({providerId:f,accessToken:y.access_token,refreshToken:y.refresh_token,tokenExpiresAt:Date.now()+(y.expires_in??3600)*1e3,baseUrl:g,userName:T(y.access_token),userAvatar:await E(y.access_token),scopes:y.scope}),n()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:f,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function I(){r({api:v,stream:N,streamSimple:P})}export{F as config,I as register};
1
+ import{_ as e,r as t}from"./account-store-C8W_QB2_.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{a as r}from"./compat-nGhSz-U1.js";import{n as i,o as a}from"./legacy-api-aliases--xyLjPgC.js";import{n as o}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings-5llrPtIb.js";import{n as s,r as c}from"./bridge-token-required-BYgoMwr7.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";const f=`openai-codex`,p=`app_EMoamEEZ73f0CkXaXp7hrann`,m=`https://auth.openai.com/oauth/token`,h=`http://localhost:1455/auth/callback`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${f}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:p,code:e,code_verifier:t,redirect_uri:h}),r=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){if(s())return null;try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:p}),n=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text();return c(n.status,e)||console.error(`[openai-codex] refresh failed:`,n.status,e),null}return await n.json()}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===f)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:f,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function A(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function j(e,t,n,r){try{let a=await O(),s={...t,baseUrl:g,api:_},c=i(s,o(n),{...r,apiKey:a,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}async function M(e,t,n,r){try{let i=await O(),s={...t,baseUrl:g,api:_},c=a(s,o(n),{...r,apiKey:i,transport:`sse`});for await(let t of c)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}const N=(e,t,r={})=>{let i=n();return j(i,e,t,r).catch(A),i},P=(e,t,r)=>{let i=n();return M(i,e,t,r).catch(A),i},F={id:f,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=l(),a=await d(i),o=u(),s=new URL(`https://auth.openai.com/oauth/authorize`);s.searchParams.set(`response_type`,`code`),s.searchParams.set(`client_id`,p),s.searchParams.set(`redirect_uri`,h),s.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),s.searchParams.set(`code_challenge`,a),s.searchParams.set(`code_challenge_method`,`S256`),s.searchParams.set(`state`,o),s.searchParams.set(`id_token_add_organizations`,`true`),s.searchParams.set(`codex_cli_simplified_flow`,`true`),s.searchParams.set(`originator`,`pi`);let c=await t({authorizeUrl:s.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!c)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let m=new URL(c),_=m.searchParams.get(`code`),v=m.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(v!==o)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let y=await x(_,i);await e({providerId:f,accessToken:y.access_token,refreshToken:y.refresh_token,tokenExpiresAt:Date.now()+(y.expires_in??3600)*1e3,baseUrl:g,userName:T(y.access_token),userAvatar:await E(y.access_token),scopes:y.scope}),n()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:f,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function I(){r({api:v,stream:N,streamSimple:P})}export{F as config,I as register};
@@ -1 +1 @@
1
- import{a as e}from"./compat-BAGLwgqY.js";import{r as t,s as n}from"./legacy-api-aliases-BjgG1CsY.js";import{K as r,_ as i}from"./account-store-B9NAiCud.js";import"./main-DFzXj4Ap.js";import{n as a}from"./pi-transcript-context-miZCMig3.js";import{fetchModels as o,getCatalog as s}from"./openrouter-models-DawLtPaY.js";import{loginIntercepted as c}from"./openrouter-oauth-BzcBCIMl.js";var l=`openrouter`,u=`https://openrouter.ai/api/v1`,d=`openai-completions`,f=`${l}-openai`,p={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function m(e){return{...e,baseUrl:u,api:d}}function h(e){return{...e??{},...p}}var g=(e,n,r={})=>t(m(e),a(n),{...r,apiKey:i(l)??r.apiKey,headers:h(r.headers)}),_=(e,t,r={})=>n(m(e),a(t),{...r,apiKey:i(l)??r.apiKey,headers:h(r.headers)}),v={id:l,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:s,refreshModels:async()=>{await o()},onOAuthLoginIntercepted:async(e,t,n)=>{await c(e,()=>void 0,n),await o().catch(()=>void 0),t()},onOAuthLogout:async()=>{await r({providerId:l,accessToken:``})}};function y(){e({api:f,stream:g,streamSimple:_})}export{v as config,y as register};
1
+ import{a as e}from"./compat-BAGLwgqY.js";import{r as t,s as n}from"./legacy-api-aliases-BjgG1CsY.js";import{K as r,_ as i}from"./account-store-B857f9Kw.js";import"./main-CxkrqswY.js";import{n as a}from"./pi-transcript-context-miZCMig3.js";import{fetchModels as o,getCatalog as s}from"./openrouter-models-DawLtPaY.js";import{loginIntercepted as c}from"./openrouter-oauth-Dy_qCqcN.js";var l=`openrouter`,u=`https://openrouter.ai/api/v1`,d=`openai-completions`,f=`${l}-openai`,p={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function m(e){return{...e,baseUrl:u,api:d}}function h(e){return{...e??{},...p}}var g=(e,n,r={})=>t(m(e),a(n),{...r,apiKey:i(l)??r.apiKey,headers:h(r.headers)}),_=(e,t,r={})=>n(m(e),a(t),{...r,apiKey:i(l)??r.apiKey,headers:h(r.headers)}),v={id:l,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:s,refreshModels:async()=>{await o()},onOAuthLoginIntercepted:async(e,t,n)=>{await c(e,()=>void 0,n),await o().catch(()=>void 0),t()},onOAuthLogout:async()=>{await r({providerId:l,accessToken:``})}};function y(){e({api:f,stream:g,streamSimple:_})}export{v as config,y as register};
@@ -1 +1 @@
1
- import{_ as e,a as t}from"./account-store-BjfGeTTt.js";import{a as n}from"./compat-nGhSz-U1.js";import{r,s as i}from"./legacy-api-aliases--xyLjPgC.js";import{n as a}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings--5JFkAeb.js";import{fetchModels as o,getCatalog as s}from"./openrouter-models-RwlwKz0P.js";import{loginIntercepted as c}from"./openrouter-oauth-CPpLFF4m.js";const l=`openrouter`,u=`${l}-openai`,d={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function f(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function p(e){return{...e??{},...d}}const m=(e,n,i={})=>r(f(e),a(n),{...i,apiKey:t(l)??i.apiKey,headers:p(i.headers)}),h=(e,n,r={})=>i(f(e),a(n),{...r,apiKey:t(l)??r.apiKey,headers:p(r.headers)}),g={id:l,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:s,refreshModels:async()=>{await o()},onOAuthLoginIntercepted:async(e,t,n)=>{await c(e,()=>void 0,n),await o().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})}};function _(){n({api:u,stream:m,streamSimple:h})}export{g as config,_ as register};
1
+ import{_ as e,a as t}from"./account-store-C8W_QB2_.js";import{a as n}from"./compat-nGhSz-U1.js";import{r,s as i}from"./legacy-api-aliases--xyLjPgC.js";import{n as a}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings-5llrPtIb.js";import{fetchModels as o,getCatalog as s}from"./openrouter-models-RwlwKz0P.js";import{loginIntercepted as c}from"./openrouter-oauth-YeISAtXv.js";const l=`openrouter`,u=`${l}-openai`,d={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function f(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function p(e){return{...e??{},...d}}const m=(e,n,i={})=>r(f(e),a(n),{...i,apiKey:t(l)??i.apiKey,headers:p(i.headers)}),h=(e,n,r={})=>i(f(e),a(n),{...r,apiKey:t(l)??r.apiKey,headers:p(r.headers)}),g={id:l,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:s,refreshModels:async()=>{await o()},onOAuthLoginIntercepted:async(e,t,n)=>{await c(e,()=>void 0,n),await o().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})}};function _(){n({api:u,stream:m,streamSimple:h})}export{g as config,_ as register};
@@ -1 +1 @@
1
- import{a as e}from"./diagnostics-Cag7MsZI.js";import{a as t}from"./compat-BAGLwgqY.js";import{r as n,s as r}from"./legacy-api-aliases-BjgG1CsY.js";import{K as i,_ as a}from"./account-store-B9NAiCud.js";import"./main-DFzXj4Ap.js";import{n as o}from"./pi-transcript-context-miZCMig3.js";import{FREE_ROUTER_FALLBACK as s,fetchModels as c,getFreeCatalog as l,isModelInFreeCatalog as u}from"./openrouter-models-DawLtPaY.js";import{loginIntercepted as d}from"./openrouter-oauth-BzcBCIMl.js";var f=`openrouter-free`,p=`https://openrouter.ai/api/v1`,m=`openai-completions`,h=`${f}-openai`,g={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function _(e){return{...e,baseUrl:p,api:m}}function v(e){return{...e??{},...g}}function y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function b(t){let n=e(),r=Error(`OpenRouter (Free) refused "${t.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{n.push(y(t,r)),n.end()}),n}var x=(e,t,r={})=>u(e.id)?n(_(e),o(t),{...r,apiKey:a(f)??r.apiKey,headers:v(r.headers)}):b(e),S=(e,t,n={})=>u(e.id)?r(_(e),o(t),{...n,apiKey:a(f)??n.apiKey,headers:v(n.headers)}):b(e),C={id:f,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:s.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:l,refreshModels:async()=>{await c()},onOAuthLoginIntercepted:async(e,t,n)=>{await d(e,()=>void 0,{...n,providerId:f}),await c().catch(()=>void 0),t()},onOAuthLogout:async()=>{await i({providerId:f,accessToken:``})}};function w(){t({api:h,stream:x,streamSimple:S})}export{C as config,w as register};
1
+ import{a as e}from"./diagnostics-Cag7MsZI.js";import{a as t}from"./compat-BAGLwgqY.js";import{r as n,s as r}from"./legacy-api-aliases-BjgG1CsY.js";import{K as i,_ as a}from"./account-store-B857f9Kw.js";import"./main-CxkrqswY.js";import{n as o}from"./pi-transcript-context-miZCMig3.js";import{FREE_ROUTER_FALLBACK as s,fetchModels as c,getFreeCatalog as l,isModelInFreeCatalog as u}from"./openrouter-models-DawLtPaY.js";import{loginIntercepted as d}from"./openrouter-oauth-Dy_qCqcN.js";var f=`openrouter-free`,p=`https://openrouter.ai/api/v1`,m=`openai-completions`,h=`${f}-openai`,g={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function _(e){return{...e,baseUrl:p,api:m}}function v(e){return{...e??{},...g}}function y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function b(t){let n=e(),r=Error(`OpenRouter (Free) refused "${t.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{n.push(y(t,r)),n.end()}),n}var x=(e,t,r={})=>u(e.id)?n(_(e),o(t),{...r,apiKey:a(f)??r.apiKey,headers:v(r.headers)}):b(e),S=(e,t,n={})=>u(e.id)?r(_(e),o(t),{...n,apiKey:a(f)??n.apiKey,headers:v(n.headers)}):b(e),C={id:f,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:s.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:l,refreshModels:async()=>{await c()},onOAuthLoginIntercepted:async(e,t,n)=>{await d(e,()=>void 0,{...n,providerId:f}),await c().catch(()=>void 0),t()},onOAuthLogout:async()=>{await i({providerId:f,accessToken:``})}};function w(){t({api:h,stream:x,streamSimple:S})}export{C as config,w as register};
@@ -1 +1 @@
1
- import{_ as e,a as t}from"./account-store-BjfGeTTt.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{a as r}from"./compat-nGhSz-U1.js";import{r as i,s as a}from"./legacy-api-aliases--xyLjPgC.js";import{n as o}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings--5JFkAeb.js";import{FREE_ROUTER_FALLBACK as s,fetchModels as c,getFreeCatalog as l,isModelInFreeCatalog as u}from"./openrouter-models-RwlwKz0P.js";import{loginIntercepted as d}from"./openrouter-oauth-CPpLFF4m.js";const f=`openrouter-free`,p=`${f}-openai`,m={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function h(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function g(e){return{...e??{},...m}}function _(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:p,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function v(e){let t=n(),r=Error(`OpenRouter (Free) refused "${e.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{t.push(_(e,r)),t.end()}),t}const y=(e,n,r={})=>u(e.id)?i(h(e),o(n),{...r,apiKey:t(f)??r.apiKey,headers:g(r.headers)}):v(e),b=(e,n,r={})=>u(e.id)?a(h(e),o(n),{...r,apiKey:t(f)??r.apiKey,headers:g(r.headers)}):v(e),x={id:f,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:s.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:l,refreshModels:async()=>{await c()},onOAuthLoginIntercepted:async(e,t,n)=>{await d(e,()=>void 0,{...n,providerId:f}),await c().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})}};function S(){r({api:p,stream:y,streamSimple:b})}export{x as config,S as register};
1
+ import{_ as e,a as t}from"./account-store-C8W_QB2_.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{a as r}from"./compat-nGhSz-U1.js";import{r as i,s as a}from"./legacy-api-aliases--xyLjPgC.js";import{n as o}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings-5llrPtIb.js";import{FREE_ROUTER_FALLBACK as s,fetchModels as c,getFreeCatalog as l,isModelInFreeCatalog as u}from"./openrouter-models-RwlwKz0P.js";import{loginIntercepted as d}from"./openrouter-oauth-YeISAtXv.js";const f=`openrouter-free`,p=`${f}-openai`,m={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function h(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function g(e){return{...e??{},...m}}function _(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:p,provider:f,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function v(e){let t=n(),r=Error(`OpenRouter (Free) refused "${e.id}" — it is not in the current free catalog. Choose another free model or refresh the catalog.`);return queueMicrotask(()=>{t.push(_(e,r)),t.end()}),t}const y=(e,n,r={})=>u(e.id)?i(h(e),o(n),{...r,apiKey:t(f)??r.apiKey,headers:g(r.headers)}):v(e),b=(e,n,r={})=>u(e.id)?a(h(e),o(n),{...r,apiKey:t(f)??r.apiKey,headers:g(r.headers)}):v(e),x={id:f,name:`OpenRouter (Free)`,description:`Currently free OpenRouter models that support vision and tools. Catalog refreshes from OpenRouter; paid models are excluded.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:s.id,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:l,refreshModels:async()=>{await c()},onOAuthLoginIntercepted:async(e,t,n)=>{await d(e,()=>void 0,{...n,providerId:f}),await c().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:f,accessToken:``})}};function S(){r({api:p,stream:y,streamSimple:b})}export{x as config,S as register};