sliccy 6.122.0 → 6.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +15 -3
  2. package/dist/node-server/_shared/tray-sync-protocol.d.ts +20 -3
  3. package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
  4. package/dist/node-server/_shared/tray-sync-protocol.js +9 -1
  5. package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
  6. package/dist/ui/.vite/manifest.json +154 -154
  7. package/dist/ui/assets/{CLAUDE-CgpX4Q5m.js → CLAUDE-BG8Wfdn_.js} +1 -1
  8. package/dist/ui/assets/SKILL-C6co9TnL.js +1 -0
  9. package/dist/ui/assets/SKILL-DA3Jh760.js +1 -0
  10. package/dist/ui/assets/{account-store-BeWWaisz.js → account-store-BRlVG3UL.js} +1 -1
  11. package/dist/ui/assets/{account-store-CrzQRVmk.js → account-store-C209lUzH.js} +1 -1
  12. package/dist/ui/assets/{adobe-CU3EGPi1.js → adobe-CMK4xkCW.js} +1 -1
  13. package/dist/ui/assets/{adobe-CmJQOCEG.js → adobe-Dk8OecoO.js} +1 -1
  14. package/dist/ui/assets/{agent-bridge-CxtEwZsO.js → agent-bridge-BcZ3aGA4.js} +1 -1
  15. package/dist/ui/assets/{agent-panels-D2g8j4Sb.js → agent-panels-ZPsCQbMA.js} +1 -1
  16. package/dist/ui/assets/{apply-layout-M6igfUeQ.js → apply-layout-DNyrVRDt.js} +1 -1
  17. package/dist/ui/assets/{apps-Dcr6dP3A.js → apps-jBBgm8_4.js} +1 -1
  18. package/dist/ui/assets/{azure-openai-B2ax_lID.js → azure-openai-BLxcD-7a.js} +1 -1
  19. package/dist/ui/assets/{azure-openai-BtyN3IoK.js → azure-openai-C8vGZXPU.js} +1 -1
  20. package/dist/ui/assets/bunny-probe-Bgz20a1s.js +1 -0
  21. package/dist/ui/assets/bunny-run-BsOugqIU.js +1 -0
  22. package/dist/ui/assets/{cerebras-DUaxfafs.js → cerebras-Db8_4GyD.js} +1 -1
  23. package/dist/ui/assets/{cerebras-BsKWOUNG.js → cerebras-wdXrxFyb.js} +1 -1
  24. package/dist/ui/assets/{connect-surface-DVIB7kxf.js → connect-surface-cgxkTjpV.js} +1 -1
  25. package/dist/ui/assets/{directed-approval-Dm0LtHV8.js → directed-approval-xC1V3zAu.js} +1 -1
  26. package/dist/ui/assets/engine-BnH9pfmR.js +1 -0
  27. package/dist/ui/assets/extension-media-capture-BBMLU8BH.js +1 -0
  28. package/dist/ui/assets/fast-path-DAj2lYgU.js +2 -0
  29. package/dist/ui/assets/fs-C7jYaof5.js +1 -0
  30. package/dist/ui/assets/fs-CsZ7MYNO.js +2 -0
  31. package/dist/ui/assets/{github-BcG9_uX5.js → github-BvJIYopa.js} +2 -2
  32. package/dist/ui/assets/{github-copilot-OGxtOON4.js → github-copilot-Bj-20g_v.js} +1 -1
  33. package/dist/ui/assets/{github-copilot-DNYQa3vN.js → github-copilot-Ciuo95cM.js} +1 -1
  34. package/dist/ui/assets/{github-C-8X0lJB.js → github-dtnxTwqR.js} +1 -1
  35. package/dist/ui/assets/{github-install-ByCG7pmU.js → github-install-CximMnm8.js} +1 -1
  36. package/dist/ui/assets/{github-zip-Dy4vkVfQ.js → github-zip-q4uFjpYq.js} +1 -1
  37. package/dist/ui/assets/{help-xL2fSGd3.js → help-ZIOFUhJ1.js} +1 -1
  38. package/dist/ui/assets/idle-compaction-settings-wK6JTbJh.js +1 -0
  39. package/dist/ui/assets/{js-realm-worker-prMqenKt.js → js-realm-worker-BJzPI8aP.js} +1 -1
  40. package/dist/ui/assets/{kernel-worker-DdroKmZo.js → kernel-worker-BhD51TLL.js} +374 -374
  41. package/dist/ui/assets/{keys-D83Hgky0.js → keys-BMebW-sj.js} +18 -8
  42. package/dist/ui/assets/{lick-ws-bridge-BUAhV4Ba.js → lick-ws-bridge-CBhfAWcP.js} +1 -1
  43. package/dist/ui/assets/{local-llm-D0mTvY7N.js → local-llm-Bij_qoT6.js} +1 -1
  44. package/dist/ui/assets/{local-llm-Drh6gTi0.js → local-llm-rga3xbUM.js} +1 -1
  45. package/dist/ui/assets/{main-DSsincSj.js → main-Bpl4dJEr.js} +3 -3
  46. package/dist/ui/assets/{mount-DnkQM4H_.js → mount-8Huy3epY.js} +3 -3
  47. package/dist/ui/assets/{mount-CxIOoyoX.js → mount-DHQXC9Xw.js} +1 -1
  48. package/dist/ui/assets/mount-index-D9w_zMSm.js +1 -0
  49. package/dist/ui/assets/{mount-recovery-pP0t0B5R.js → mount-recovery-BPMhSg0P.js} +1 -1
  50. package/dist/ui/assets/{new-session-TJkrfdmM.js → new-session-BEspVRtG.js} +2 -2
  51. package/dist/ui/assets/{oauth-bootstrap-Cflkal2z.js → oauth-bootstrap-BnDmRwFR.js} +2 -2
  52. package/dist/ui/assets/{openai-codex-WrMiquZ6.js → openai-codex-CBT0YEJe.js} +1 -1
  53. package/dist/ui/assets/{openai-codex-LMiNXBpR.js → openai-codex-CGTymTwB.js} +1 -1
  54. package/dist/ui/assets/{openrouter-CF6GBIsh.js → openrouter-BHVD0eo2.js} +1 -1
  55. package/dist/ui/assets/{openrouter-Y72OhjGZ.js → openrouter-C-SgoqG6.js} +1 -1
  56. package/dist/ui/assets/{openrouter-oauth-pLAIH3V3.js → openrouter-oauth-BlRAjEY7.js} +1 -1
  57. package/dist/ui/assets/{openrouter-oauth-iH7sVKzz.js → openrouter-oauth-DjaBUhhf.js} +1 -1
  58. package/dist/ui/assets/{panel-rpc-handlers-E0Tvr752.js → panel-rpc-handlers-2NN2S3Am.js} +2 -2
  59. package/dist/ui/assets/{panelize-shell-Hn2-TJc6.js → panelize-shell-DTDMhbf1.js} +4 -4
  60. package/dist/ui/assets/{provider-BxxPfI5S.js → provider-CiL_QWYN.js} +1 -1
  61. package/dist/ui/assets/{provider-DZDGqjz1.js → provider-D09664Ko.js} +2 -2
  62. package/dist/ui/assets/{provider-settings-BFUPdbhi.js → provider-settings-1lsoYpNh.js} +1 -1
  63. package/dist/ui/assets/{provider-settings-Cr_y3ZO3.js → provider-settings-BQqRKwG3.js} +1 -1
  64. package/dist/ui/assets/{provider-store-access-BgIb6-X8.js → provider-store-access-117y9N_1.js} +2 -2
  65. package/dist/ui/assets/provider-store-access-CDCik5Nq.js +1 -0
  66. package/dist/ui/assets/{providers-Rty0Ovfq.js → providers-Cg-S0rLK.js} +1 -1
  67. package/dist/ui/assets/{providers-Dz3RSRQx.js → providers-G9XcYrxe.js} +2 -2
  68. package/dist/ui/assets/{quick-llm-CvqNttpI.js → quick-llm-CLyaja5O.js} +1 -1
  69. package/dist/ui/assets/{recovery-screen-DX5Owqre.js → recovery-screen-CtX9bOfH.js} +1 -1
  70. package/dist/ui/assets/run-BjsANk42.js +46 -0
  71. package/dist/ui/assets/{run-5X_LUY3w.js → run-DUGHJZQF.js} +2 -2
  72. package/dist/ui/assets/{run-BcjWAfpv.js → run-DrjoHDwC.js} +1 -1
  73. package/dist/ui/assets/run-DuzDBKj0.js +91 -0
  74. package/dist/ui/assets/{session-freezer-DK9G_IkB.js → session-freezer-BDQV7q_1.js} +3 -3
  75. package/dist/ui/assets/{setup-feature-flags-remote-BcUIm2b6.js → setup-feature-flags-remote-BSFcT1UK.js} +1 -1
  76. package/dist/ui/assets/{setup-standalone-prelude-l7nnbPF5.js → setup-standalone-prelude-dOyp9mG7.js} +2 -2
  77. package/dist/ui/assets/{setup-sudo-BSQT2Dh-.js → setup-sudo-B5ZH0Kx5.js} +2 -2
  78. package/dist/ui/assets/{skills-CnWQfgYe.js → skills-D13FXiOZ.js} +1 -1
  79. package/dist/ui/assets/slicc-version-DxnagBBZ.js +1 -0
  80. package/dist/ui/assets/{snapshot-DWBFaMd4.js → snapshot-Dl64sTfT.js} +1 -1
  81. package/dist/ui/assets/{snapshot-features-c8X_wCzy.js → snapshot-features-DjHbV5hw.js} +1 -1
  82. package/dist/ui/assets/src-CM1l0mgT.js +575 -0
  83. package/dist/ui/assets/{state-UQWwnZ8X.js → state-C2jLMw6E.js} +1 -1
  84. package/dist/ui/assets/{store-B-BowqJY.js → store-CL5DnZMF.js} +1 -1
  85. package/dist/ui/assets/{store-D426O4iV.js → store-DVGzP_2X.js} +1 -1
  86. package/dist/ui/assets/{sudo-B8CRodhJ.js → sudo-Bh43BxYg.js} +1 -1
  87. package/dist/ui/assets/{tray-leader-BfzB60pu.js → tray-leader-DqvI6bbT.js} +1 -1
  88. package/dist/ui/assets/{tray-sidecar-au4iFVvJ.js → tray-sidecar-qdu5dxlJ.js} +1 -1
  89. package/dist/ui/assets/{tray-sync-protocol-BlwQKL0e.js → tray-sync-protocol-CGp1cRWg.js} +1 -1
  90. package/dist/ui/assets/{upgrade-detection-WvRCLHXP.js → upgrade-detection-BMEwG2xa.js} +1 -1
  91. package/dist/ui/assets/{wc-attach-CQIHVqTH.js → wc-attach-B-ZvIPA_.js} +2 -2
  92. package/dist/ui/assets/{wc-extension-DDlPWYwq.js → wc-extension-BS4yITQI.js} +2 -2
  93. package/dist/ui/assets/{wc-float-label-CE5oCxJ4.js → wc-float-label-C6LaROga.js} +1 -1
  94. package/dist/ui/assets/{wc-floatbar-online-BBRpuOSH.js → wc-floatbar-online-CD6-Sh48.js} +1 -1
  95. package/dist/ui/assets/{wc-follower-TkW182aB.js → wc-follower-DFGFCDEX.js} +3 -3
  96. package/dist/ui/assets/{wc-follower-oauth-BPhDEzGv.js → wc-follower-oauth-CXDzdz3J.js} +2 -2
  97. package/dist/ui/assets/wc-live-IKLl5Ipp.js +8 -0
  98. package/dist/ui/assets/wc-nav-CMskySEX.js +2 -0
  99. package/dist/ui/assets/{wc-onboarding-xIF0sbif.js → wc-onboarding-CgOSx-31.js} +2 -2
  100. package/dist/ui/assets/{wc-placeholder-v2B6i349.js → wc-placeholder-Cd9dJPCz.js} +2 -2
  101. package/dist/ui/assets/wc-settings-DMpMbGfM.js +59 -0
  102. package/dist/ui/assets/{wc-shell-CxUba4CU.js → wc-shell-BIfK3lAT.js} +7 -7
  103. package/dist/ui/assets/wc-shortcut-config-C36sw_tK.js +59 -0
  104. package/dist/ui/assets/{wc-sprinkles-IRaAZH5E.js → wc-sprinkles-Bd7HmrQl.js} +2 -2
  105. package/dist/ui/assets/wc-tray-CwN-XT9_.js +5 -0
  106. package/dist/ui/assets/{xai-grok-BnPIwUZr.js → xai-grok-Bd4-jPZx.js} +1 -1
  107. package/dist/ui/assets/{xai-grok-Dgkd5vUZ.js → xai-grok-Bf7yeQJK.js} +1 -1
  108. package/dist/ui/index.html +6 -6
  109. package/dist/ui/packages/webapp/index.html +6 -6
  110. package/package.json +1 -1
  111. package/dist/ui/assets/SKILL-Boj7N1xe.js +0 -1
  112. package/dist/ui/assets/SKILL-CxxQT4Lx.js +0 -75
  113. package/dist/ui/assets/ffmpeg-command-eHNhx1yC.js +0 -66
  114. package/dist/ui/assets/fs-BkxAKjex.js +0 -2
  115. package/dist/ui/assets/fs-C3q6Q4sP.js +0 -1
  116. package/dist/ui/assets/idle-compaction-settings-C0aQ4CrR.js +0 -1
  117. package/dist/ui/assets/mount-index-BiTaSCAQ.js +0 -1
  118. package/dist/ui/assets/provider-store-access-CJG-qJev.js +0 -1
  119. package/dist/ui/assets/run-B0Qw82nE.js +0 -42
  120. package/dist/ui/assets/slicc-version-B8zEDiZF.js +0 -1
  121. package/dist/ui/assets/wc-live-8nXQgC09.js +0 -8
  122. package/dist/ui/assets/wc-nav-DjyjVmrX.js +0 -2
  123. package/dist/ui/assets/wc-settings-DvrfTqdG.js +0 -51
  124. package/dist/ui/assets/wc-shortcut-config-BLk3x477.js +0 -49
  125. package/dist/ui/assets/wc-tray-DCHo1uuz.js +0 -5
@@ -1,12 +1,19 @@
1
1
  var e=`{
2
2
  "//": [
3
- "Keyboard-mode shortcuts. Press Esc anywhere in SLICC to enter keyboard mode;",
4
- "the keys then work on their own, with no modifier. Edit this file and reload",
5
- "the tab to change them — it is read once at startup.",
3
+ "Keyboard-mode shortcuts. How the mode is entered is controlled by",
4
+ "\\"trigger\\" (also switchable in Theme settings):",
5
+ " \\"auto\\" — on whenever nothing is focused for typing (default; today's behavior)",
6
+ " \\"esc\\" — only Escape enters the mode; blur does not",
7
+ " null — keyboard mode disabled",
6
8
  "",
7
- "This file holds OVERRIDES only, and ships empty: the shipped keymap lives in",
8
- "SLICC itself, so whatever you do not mention here follows it, including any",
9
- "keys a later version adds. Press ? in keyboard mode to see what is bound.",
9
+ "Inside the mode the keys work on their own, with no modifier. Edit this",
10
+ "file and reload the tab to change them — it is read once at startup",
11
+ "(Theme settings writes \\"trigger\\" live without a reload).",
12
+ "",
13
+ "This file holds OVERRIDES only for key bindings, and ships with an empty",
14
+ "bindings object: the shipped keymap lives in SLICC itself, so whatever",
15
+ "you do not mention here follows it, including any keys a later version",
16
+ "adds. Press ? in keyboard mode to see what is bound.",
10
17
  "",
11
18
  "Each entry is \\"key\\": \\"command\\". A key is a single character (\\"x\\") or a named",
12
19
  "key (\\"Enter\\", \\"Tab\\", \\"Backspace\\", \\"Delete\\", \\"Home\\", \\"End\\", \\"ArrowLeft\\",",
@@ -19,7 +26,8 @@ var e=`{
19
26
  "Commands: composer, nextAgent, prevAgent, newConversation,",
20
27
  "newConversationErase, newCone, dropCone, sessions, stop, approvals, attach,",
21
28
  "copyReply, copyChat, voice, nextItem, prevItem, leftRail, rightRail, files,",
22
- "tabs, peek, terminal, memory, monitor, sprinkles, zoom, model, accounts, help.",
29
+ "tabs, peek, terminal, memory, monitor, sprinkles, zoom, model, cycleModel,",
30
+ "cycleThinking, accounts, help.",
23
31
  "",
24
32
  "Some commands own a list, and the keys pressed straight after them address",
25
33
  "THAT list instead of the tab strip: files, memory, sessions and sprinkles.",
@@ -42,8 +50,10 @@ var e=`{
42
50
  " \\"l\\": \\"model\\", \\"a\\": \\"accounts\\", \\"h\\": \\"help\\", \\"/\\": \\"help\\"",
43
51
  " }",
44
52
  "",
45
- "This file is yours — SLICC only writes it when it is missing."
53
+ "This file is yours — SLICC only writes it when it is missing, or when Theme",
54
+ "settings updates \\"trigger\\"."
46
55
  ],
56
+ "trigger": "auto",
47
57
  "bindings": {}
48
58
  }
49
59
  `;export{e as default};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./logger-BoSvu4mW.js";import"./tray-leader-BfzB60pu.js";e(`lick-ws-bridge`);function t(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function n(e){let t=typeof e.discoveryOrigin==`string`?e.discoveryOrigin:null,n=e.discoveryKind===`ai-catalog`||e.discoveryKind===`llms-txt`?e.discoveryKind:null,r=typeof e.discoveryUrl==`string`&&e.discoveryUrl.length>0?e.discoveryUrl:null;if(!t||!n||!r)return null;let i=typeof e.url==`string`?e.url:void 0;return{type:`discovery`,discoveryOrigin:t,discoveryKind:n,discoveryUrl:r,discoverySource:`live-navigation`,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:{origin:t,kind:n,url:r,...i?{pageUrl:i}:{}}}}export{n as mapDiscoveryPayloadToLickEvent,t as mapNavigatePayloadToLickEvent};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import"./logger-BoSvu4mW.js";import"./tray-leader-DqvI6bbT.js";e(`lick-ws-bridge`);function t(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function n(e){let t=typeof e.discoveryOrigin==`string`?e.discoveryOrigin:null,n=e.discoveryKind===`ai-catalog`||e.discoveryKind===`llms-txt`?e.discoveryKind:null,r=typeof e.discoveryUrl==`string`&&e.discoveryUrl.length>0?e.discoveryUrl:null;if(!t||!n||!r)return null;let i=typeof e.url==`string`?e.url:void 0;return{type:`discovery`,discoveryOrigin:t,discoveryKind:n,discoveryUrl:r,discoverySource:`live-navigation`,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:{origin:t,kind:n,url:r,...i?{pageUrl:i}:{}}}}export{n as mapDiscoveryPayloadToLickEvent,t as mapNavigatePayloadToLickEvent};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{s as n}from"./account-store-BeWWaisz.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,s as o}from"./legacy-api-aliases-jKEvBgOL.js";var s=e({config:()=>d,detectRuntime:()=>T,discoverModels:()=>w,originOf:()=>S,register:()=>y,verifyConnection:()=>O});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{s as n}from"./account-store-BRlVG3UL.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,s as o}from"./legacy-api-aliases-jKEvBgOL.js";var s=e({config:()=>d,detectRuntime:()=>T,discoverModels:()=>w,originOf:()=>S,register:()=>y,verifyConnection:()=>O});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let e=f(n(l));return e.length===0?[{id:u,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:e.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function f(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}const p=`${l}-openai`;function m(e){return{...e,api:`openai-completions`}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:`local`}:t}const g=(e,t,n={})=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?a(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?o(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,t){let n=r(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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,timestamp:Date.now()};return queueMicrotask(()=>{n.push({type:`error`,reason:`error`,error:i}),n.end()}),n}function y(){i({api:p,stream:g,streamSimple:_})}function b(e){return typeof e==`object`&&!!e&&`object`in e&&e.object===`list`}function x(e){return typeof e==`object`&&!!e&&`build_info`in e}function S(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function C(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function w(e,t,n){let r=`${C(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function T(e,t){let n=S(e),r=await D(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};if(b(await D(`${n}/api/v0/models`,t)))return{kind:`lmstudio`};let i=await D(`${n}/props`,t);if(x(i))return{kind:`llamacpp`,version:i.build_info?.version};let a=E(e);return a===`11434`?{kind:`ollama`}:a===`1234`?{kind:`lmstudio`}:a===`8000`?{kind:`vllm`}:a===`1337`?{kind:`jan`}:{kind:`unknown`}}function E(e){try{return new URL(e).port||null}catch{return null}}async function D(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function O(e,t,n){let r={kind:`unknown`};try{r=await T(e,n)}catch{}try{let i=await w(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=k(n,r.kind);return c.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function k(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{s as n,d as t};
@@ -1,2 +1,2 @@
1
- import{b as e}from"./account-store-CrzQRVmk.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{b as e}from"./account-store-C209lUzH.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let t=d(e(s));return t.length===0?[{id:l,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:t.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function d(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}var f=`openai-completions`,p=`${s}-openai`;function m(e){return{...e,api:f}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:c}:t}var g=(e,t,n={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?i(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,n){let r=t(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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:n,timestamp:Date.now()};return queueMicrotask(()=>{r.push({type:`error`,reason:`error`,error:i}),r.end()}),r}function y(){n({api:p,stream:g,streamSimple:_})}function b(e){return typeof e==`object`&&!!e&&`object`in e&&e.object===`list`}function x(e){return typeof e==`object`&&!!e&&`build_info`in e}function S(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function C(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function w(e,t,n){let r=`${C(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function T(e,t){let n=S(e),r=await D(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};if(b(await D(`${n}/api/v0/models`,t)))return{kind:`lmstudio`};let i=await D(`${n}/props`,t);if(x(i))return{kind:`llamacpp`,version:i.build_info?.version};let a=E(e);return a===`11434`?{kind:`ollama`}:a===`1234`?{kind:`lmstudio`}:a===`8000`?{kind:`vllm`}:a===`1337`?{kind:`jan`}:{kind:`unknown`}}function E(e){try{return new URL(e).port||null}catch{return null}}async function D(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function O(e,t,n){let r={kind:`unknown`};try{r=await T(e,n)}catch{}try{let i=await w(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=k(n,r.kind);return o.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function k(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{u as config,T as detectRuntime,w as discoverModels,S as originOf,y as register,O as verifyConnection};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-BcUIm2b6.js","assets/feature-flags-DaSRRz0w.js","assets/tray-runtime-config-CI5NvXNM.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/messages-BD4p8GuF.js","assets/wc-shell-CxUba4CU.js","assets/logger-DDBAeTLF.js","assets/attachments-329cIT1j.js","assets/mime-types-k2E6ulyv.js","assets/image-markers-CxJ9ZBgw.js","assets/telemetry-BVzuNdvW.js","assets/runtime-env-CgsZ7LTp.js","assets/runtime-env-E-i2SW1s.js","assets/icons-BJsliYCh.js","assets/speech-C5U8h4In.js","assets/dictation-priming-CNllGgNq.js","assets/soundscape-cues-5_sT5Un6.js","assets/agent-message-to-chat-Cc7vTUN1.js","assets/timestamp-preference-sKwBl5I8.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-TkW182aB.js","assets/setup-standalone-prelude-l7nnbPF5.js","assets/setup-sudo-BSQT2Dh-.js","assets/tray-sync-protocol-BZ5yhJH9.js","assets/wc-live-8nXQgC09.js","assets/account-store-CrzQRVmk.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/float-topology-BYb7rxY5.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Dz3RSRQx.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/tray-follower-status-BAjnN7Ar.js","assets/src-BWaKqLvQ.js","assets/browser-DGwroBSO.js","assets/chat-session-store-pWb1-jNp.js","assets/tray-leader-BfzB60pu.js","assets/db-cKsBsMMN.js","assets/record-DJeuy9ob.js","assets/shared-2T6O01rS.js","assets/export-provider-BEHTjSYw.js","assets/dip-CwdsfUhQ.js","assets/permissions-surface-registry-CilCRwhh.js","assets/hid-device-registry-B2R-0rNt.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BBXJ4GF8.js","assets/usb-device-registry-CRsCisej.js","assets/sprinkle-renderer-1C1DNVyK.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/sprinkle-bridge-D4YmJlZ6.js","assets/session-freezer-DK9G_IkB.js","assets/types-Dgm4REV3.js","assets/follower-presentation-DqBw0YiV.js","assets/wc-unit-context-BCUZtzqm.js","assets/wc-follower-oauth-BPhDEzGv.js","assets/slicc-app-url-BsBryEhn.js","assets/tray-webrtc-CThDQcWx.js","assets/remote-cdp-transport-CgOXLjZ8.js","assets/pending-request-table-Dgn6qYdL.js","assets/tray-sync-protocol-BlwQKL0e.js","assets/export-spool-Eul4J1RP.js","assets/wc-sprinkles-IRaAZH5E.js","assets/wc-attach-CQIHVqTH.js","assets/wc-float-label-CE5oCxJ4.js","assets/wc-floatbar-online-BBRpuOSH.js","assets/wc-permissions-C77Upopt.js","assets/oauth-bootstrap-Cflkal2z.js","assets/provider-settings-Cr_y3ZO3.js","assets/clipboard-eqmn97SP.js","assets/tray-join-url-BIvzbiFR.js","assets/logger-BoSvu4mW.js","assets/legacy-styles-B3nS5QUo.js","assets/connect-surface-DVIB7kxf.js","assets/wc-extension-DDlPWYwq.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-P2Xu9kJm.js";import{a as e}from"./account-store-CrzQRVmk.js";import{t}from"./preload-helper-Czpn1I53.js";import{t as n}from"./logger-DDBAeTLF.js";import{c as r,o as i,s as a,t as o}from"./setup-standalone-prelude-l7nnbPF5.js";import{n as s,t as c}from"./runtime-env-Dlaokqg1.js";import"./runtime-env-CgsZ7LTp.js";import{t as l}from"./telemetry-BVzuNdvW.js";import{a as u}from"./providers-Dz3RSRQx.js";import{n as d}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-Cr_y3ZO3.js";var f=`slicc:bridge-config`,p=`slicc:extension-delegate-config`;function m(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var h=n(`boot/ext-fetch-delegate`);function g(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function _(e,t,n){let r=g();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function v(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!m(t.data))return;let n=t.ports?.[0];if(!n){h.warn(`delegated fetch envelope arrived without a response port`);return}_(t.data,n,e)})}var y=`slicc_feature_flags_remote`;function b(e){return`${y}:${e}`}function x(e,t){let n=C(t);d(e,w(n,e)??{})}function S(e,t,n){try{e?.setItem(b(t),JSON.stringify(n))}catch{}}function C(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function w(e,t){try{let n=e?.getItem(b(t));return n?T(JSON.parse(n)):null}catch{return null}}function T(e){return!E(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e,n){x(e,n.storage),t(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-BcUIm2b6.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:t})=>t(e,n)).catch(()=>{})}function O(e){let t=a(e.locationHref,e.isExtension,e.storage);return D(t,e),t}function k(){if(s())return;let e=new Blob([`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-BSFcT1UK.js","assets/feature-flags-DaSRRz0w.js","assets/tray-runtime-config-CI5NvXNM.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/messages-BD4p8GuF.js","assets/wc-shell-BIfK3lAT.js","assets/logger-DDBAeTLF.js","assets/attachments-329cIT1j.js","assets/mime-types-k2E6ulyv.js","assets/image-markers-CxJ9ZBgw.js","assets/telemetry-BVzuNdvW.js","assets/runtime-env-CgsZ7LTp.js","assets/runtime-env-E-i2SW1s.js","assets/icons-BJsliYCh.js","assets/speech-C5U8h4In.js","assets/dictation-priming-CNllGgNq.js","assets/soundscape-cues-5_sT5Un6.js","assets/agent-message-to-chat-Cc7vTUN1.js","assets/timestamp-preference-sKwBl5I8.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-DFGFCDEX.js","assets/setup-standalone-prelude-dOyp9mG7.js","assets/setup-sudo-B5ZH0Kx5.js","assets/tray-sync-protocol-BZ5yhJH9.js","assets/wc-live-IKLl5Ipp.js","assets/account-store-C209lUzH.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/float-topology-BYb7rxY5.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-G9XcYrxe.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/tray-follower-status-BAjnN7Ar.js","assets/src-BWaKqLvQ.js","assets/browser-DGwroBSO.js","assets/chat-session-store-pWb1-jNp.js","assets/tray-leader-DqvI6bbT.js","assets/db-cKsBsMMN.js","assets/record-DJeuy9ob.js","assets/shared-2T6O01rS.js","assets/export-provider-BEHTjSYw.js","assets/dip-CwdsfUhQ.js","assets/permissions-surface-registry-CilCRwhh.js","assets/hid-device-registry-B2R-0rNt.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BBXJ4GF8.js","assets/usb-device-registry-CRsCisej.js","assets/sprinkle-renderer-1C1DNVyK.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/sprinkle-bridge-D4YmJlZ6.js","assets/session-freezer-BDQV7q_1.js","assets/types-Dgm4REV3.js","assets/follower-presentation-DqBw0YiV.js","assets/wc-unit-context-BCUZtzqm.js","assets/wc-follower-oauth-CXDzdz3J.js","assets/slicc-app-url-BsBryEhn.js","assets/tray-webrtc-CThDQcWx.js","assets/remote-cdp-transport-CgOXLjZ8.js","assets/pending-request-table-Dgn6qYdL.js","assets/tray-sync-protocol-CGp1cRWg.js","assets/export-spool-Eul4J1RP.js","assets/wc-sprinkles-Bd7HmrQl.js","assets/wc-attach-B-ZvIPA_.js","assets/wc-float-label-C6LaROga.js","assets/wc-floatbar-online-CD6-Sh48.js","assets/wc-permissions-C77Upopt.js","assets/oauth-bootstrap-BnDmRwFR.js","assets/provider-settings-BQqRKwG3.js","assets/clipboard-eqmn97SP.js","assets/tray-join-url-BIvzbiFR.js","assets/logger-BoSvu4mW.js","assets/legacy-styles-B3nS5QUo.js","assets/connect-surface-cgxkTjpV.js","assets/wc-extension-BS4yITQI.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
+ import"./modulepreload-polyfill-P2Xu9kJm.js";import{a as e}from"./account-store-C209lUzH.js";import{t}from"./preload-helper-Czpn1I53.js";import{t as n}from"./logger-DDBAeTLF.js";import{c as r,o as i,s as a,t as o}from"./setup-standalone-prelude-dOyp9mG7.js";import{n as s,t as c}from"./runtime-env-Dlaokqg1.js";import"./runtime-env-CgsZ7LTp.js";import{t as l}from"./telemetry-BVzuNdvW.js";import{a as u}from"./providers-G9XcYrxe.js";import{n as d}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-BQqRKwG3.js";var f=`slicc:bridge-config`,p=`slicc:extension-delegate-config`;function m(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var h=n(`boot/ext-fetch-delegate`);function g(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function _(e,t,n){let r=g();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function v(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!m(t.data))return;let n=t.ports?.[0];if(!n){h.warn(`delegated fetch envelope arrived without a response port`);return}_(t.data,n,e)})}var y=`slicc_feature_flags_remote`;function b(e){return`${y}:${e}`}function x(e,t){let n=C(t);d(e,w(n,e)??{})}function S(e,t,n){try{e?.setItem(b(t),JSON.stringify(n))}catch{}}function C(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function w(e,t){try{let n=e?.getItem(b(t));return n?T(JSON.parse(n)):null}catch{return null}}function T(e){return!E(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e,n){x(e,n.storage),t(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-BSFcT1UK.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:t})=>t(e,n)).catch(()=>{})}function O(e){let t=a(e.locationHref,e.isExtension,e.storage);return D(t,e),t}function k(){if(s())return;let e=new Blob([`
3
3
  let lastPong = Date.now();
4
4
  let frozen = false;
5
5
  setInterval(() => {
@@ -19,4 +19,4 @@ import"./modulepreload-polyfill-P2Xu9kJm.js";import{a as e}from"./account-store-
19
19
  }
20
20
  }
21
21
  };
22
- `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var A=`slicc-nuke-control`,j=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function M(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(A),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var N=null;function P(){return N||(N=M(),N)}var F=n(`storage-persist`);function I(){try{return globalThis.navigator?.storage}catch{return}}async function L(e=I()){try{return typeof e?.persist==`function`?typeof e.persisted==`function`&&await e.persisted()?`already-persisted`:await e.persist()?`granted`:`denied`:`unsupported`}catch(e){return F.warn(`storage persistence check failed`,e),`failed`}}var R=!1;function z(){R||(R=!0,L().then(e=>{switch(e){case`granted`:F.info(`OPFS marked persistent — SLICC data is now exempt from disk-pressure eviction`);break;case`already-persisted`:F.debug(`OPFS already persistent`);break;case`denied`:F.warn(`Browser declined persistent storage — SLICC data can be evicted if the disk fills up`);break;case`unsupported`:F.debug(`navigator.storage.persist() unavailable in this runtime`)}}).catch(()=>{}))}var B=n(`boot/sw-registration`);async function V(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await W())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),B.info(`Preview SW registered`),!s())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),B.info(`LLM-proxy SW registered`)}catch(e){B.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),B.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(H(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{H(e)})),t&&(U(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{U(t)}))}catch(e){B.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function H(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:f,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function U(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:p,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function W(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),B.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){B.error(`connect-mode SW cleanup failed`,e)}return!1}var G=n(`main`);function K(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function q(){i();let n=document.getElementById(`app`);if(!n)throw Error(`#app element not found`);let a=s(),d=O({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:a});if(K(window.location.href)){let{mountWcUiPreview:e}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-CxUba4CU.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([12,5,6,13,14,15,7,3,16,17,8,18,19,20,21,22,23,24,25,26]));e(n);return}k(),P(),z(),d!==`connect`&&l().catch(()=>{});let f=r(window.location.search),p=d===`cherry`?null:o(window.location.search),m=!!p&&c();if(await V(f?{apiBaseUrl:f.apiBaseUrl,token:f.token}:null,m&&p?{extensionId:p.extensionId}:null)===`reload-pending`)return;if(!a&&(d===`follower`||d===`cherry`)){let{mountWcUiFollower:e}=await t(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-TkW182aB.js`);return{mountWcUiFollower:e}},__vite__mapDeps([27,6,13,3,28,4,5,7,8,9,10,18,19,11,2,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,46,47,17,1,48,49,50,12,14,15,20,21,22,23,24,25,26,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]));return e(n,G,d)}await u(),e();let{bootstrapOAuthReplicas:h}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-Cflkal2z.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([83,32,5,6,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,84,17,18,2,11,48,85,86,87]));if(await Promise.race([h().catch(e=>{G.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),d===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:e}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([88,6]));await e();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-DVIB7kxf.js`);return{mountConnectSurface:e}},__vite__mapDeps([89,32,5,6,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,84,17,18,2,11,48,85,86]));await r(n);return}if(a){let{mountWcUiExtension:e}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-DDlPWYwq.js`);return{mountWcUiExtension:e}},__vite__mapDeps([90,6,31,5,32,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,28,18,11,2,29,17,1,48,49,50,12,14,15,20,21,22,23,24,25,26,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,91,80,81]));return e(n,G,d===`extension-detached`)}m&&p&&v(p.extensionId);let{mountWcUiLive:g}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-8nXQgC09.js`).then(e=>e.r);return{mountWcUiLive:e}},__vite__mapDeps([31,5,32,6,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,28,18,11,2,29,17,1,48,49,50,12,14,15,20,21,22,23,24,25,26,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]));return g(n,G,d)}function J(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function Y(e,n){let r;try{({renderBootRecoveryScreen:r}=await t(()=>import(`./recovery-screen-DX5Owqre.js`),[]))}catch{J(e,n);return}if(r(e,n),n instanceof Error&&n.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:i}=await t(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),a=await i();a===`browser-wedged`&&r(e,n,{verdict:a})}catch{}}q().catch(e=>{G.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&Y(t,e)});export{C as n,S as r,j as t};
22
+ `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var A=`slicc-nuke-control`,j=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function M(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(A),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var N=null;function P(){return N||(N=M(),N)}var F=n(`storage-persist`);function I(){try{return globalThis.navigator?.storage}catch{return}}async function L(e=I()){try{return typeof e?.persist==`function`?typeof e.persisted==`function`&&await e.persisted()?`already-persisted`:await e.persist()?`granted`:`denied`:`unsupported`}catch(e){return F.warn(`storage persistence check failed`,e),`failed`}}var R=!1;function z(){R||(R=!0,L().then(e=>{switch(e){case`granted`:F.info(`OPFS marked persistent — SLICC data is now exempt from disk-pressure eviction`);break;case`already-persisted`:F.debug(`OPFS already persistent`);break;case`denied`:F.warn(`Browser declined persistent storage — SLICC data can be evicted if the disk fills up`);break;case`unsupported`:F.debug(`navigator.storage.persist() unavailable in this runtime`)}}).catch(()=>{}))}var B=n(`boot/sw-registration`);async function V(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await W())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),B.info(`Preview SW registered`),!s())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),B.info(`LLM-proxy SW registered`)}catch(e){B.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),B.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(H(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{H(e)})),t&&(U(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{U(t)}))}catch(e){B.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function H(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:f,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function U(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:p,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function W(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),B.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){B.error(`connect-mode SW cleanup failed`,e)}return!1}var G=n(`main`);function K(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function q(){i();let n=document.getElementById(`app`);if(!n)throw Error(`#app element not found`);let a=s(),d=O({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:a});if(K(window.location.href)){let{mountWcUiPreview:e}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-BIfK3lAT.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([12,5,6,13,14,15,7,3,16,17,8,18,19,20,21,22,23,24,25,26]));e(n);return}k(),P(),z(),d!==`connect`&&l().catch(()=>{});let f=r(window.location.search),p=d===`cherry`?null:o(window.location.search),m=!!p&&c();if(await V(f?{apiBaseUrl:f.apiBaseUrl,token:f.token}:null,m&&p?{extensionId:p.extensionId}:null)===`reload-pending`)return;if(!a&&(d===`follower`||d===`cherry`)){let{mountWcUiFollower:e}=await t(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-DFGFCDEX.js`);return{mountWcUiFollower:e}},__vite__mapDeps([27,6,13,3,28,4,5,7,8,9,10,18,19,11,2,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,46,47,17,1,48,49,50,12,14,15,20,21,22,23,24,25,26,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]));return e(n,G,d)}await u(),e();let{bootstrapOAuthReplicas:h}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-BnDmRwFR.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([83,32,5,6,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,84,17,18,2,11,48,85,86,87]));if(await Promise.race([h().catch(e=>{G.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),d===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:e}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([88,6]));await e();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-cgxkTjpV.js`);return{mountConnectSurface:e}},__vite__mapDeps([89,32,5,6,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,84,17,18,2,11,48,85,86]));await r(n);return}if(a){let{mountWcUiExtension:e}=await t(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-BS4yITQI.js`);return{mountWcUiExtension:e}},__vite__mapDeps([90,6,31,5,32,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,28,18,11,2,29,17,1,48,49,50,12,14,15,20,21,22,23,24,25,26,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,91,80,81]));return e(n,G,d===`extension-detached`)}m&&p&&v(p.extensionId);let{mountWcUiLive:g}=await t(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-IKLl5Ipp.js`).then(e=>e.r);return{mountWcUiLive:e}},__vite__mapDeps([31,5,32,6,33,34,35,36,37,38,39,13,3,4,7,8,9,10,40,19,41,42,43,16,44,45,46,47,28,18,11,2,29,17,1,48,49,50,12,14,15,20,21,22,23,24,25,26,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]));return g(n,G,d)}function J(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function Y(e,n){let r;try{({renderBootRecoveryScreen:r}=await t(()=>import(`./recovery-screen-CtX9bOfH.js`),[]))}catch{J(e,n);return}if(r(e,n),n instanceof Error&&n.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:i}=await t(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),a=await i();a===`browser-wedged`&&r(e,n,{verdict:a})}catch{}}q().catch(e=>{G.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&Y(t,e)});export{C as n,S as r,j as t};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-CrzQRVmk.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Dz3RSRQx.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-k2E6ulyv.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import"./src-CAWTvdAa.js";import{n as i}from"./runtime-env-Dlaokqg1.js";import{i as a,n as o,t as s}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-E-i2SW1s.js";import{t as c}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-BkxAKjex.js";import{t as l}from"./remote-cache-3KNT1gsp.js";import{t as u}from"./mount-bridge-client-XJGXnqiZ.js";var d=`https://api.aem.live`,f=`application/folder`,p=5242880;function m(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 h(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function g(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function _(e){return e.map(e=>e[`content-type`]===f||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:h(e[`last-modified`]),lastModified:g(e[`last-modified`])})}var v=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??p,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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:d,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 c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,h(r.headers.get(`last-modified`))),i}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 c(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=h(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new c(`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 c(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new c(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new c(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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 c(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem list failed: ${r.status}`,e);let i=_(await r.json());return await this.cache.putListing(t,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new c(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.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 c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new c(`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=_(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}},y=`\r
3
- `;function b(){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 x(e,t=b()){let n=new TextEncoder,r=[];for(let i of e){let e=C(S(i.name));if(`file`in i){let a=C(i.file.filename),o=w(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${y}Content-Disposition: form-data; name="${e}"; filename="${a}"${y}Content-Type: ${o}${y}${y}`)),r.push(i.file.bytes),r.push(n.encode(y))}else r.push(n.encode(`--${t}${y}Content-Disposition: form-data; name="${e}"${y}${y}${S(i.value)}${y}`))}return r.push(n.encode(`--${t}--${y}`)),{bytes:T(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function S(e){return e.replace(/\r\n|\r|\n/g,y)}function C(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function w(e){return(e??``).replace(/[\r\n]/g,``).trim()}function T(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 E(e,t,n){let r=x([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function D(e){return e.split(`/`).pop()||`data`}function O(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 k=5242880,A=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=O(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??k,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=E(D(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,u=1;try{l=await s()}catch{u=2,l=await s()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`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 c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.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 c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`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 j(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 M=26214400,N=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=j(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??M,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.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 c(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.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 c(`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 c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},P=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function F(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-CrzQRVmk.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new P(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var I=r,L=n,R=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),z=new Set([101,103,204,205,304]);function B(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||R.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=I(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=z.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function V(e,t){let n;try{n=await fetch(a(e),{method:`POST`,headers:s({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function H(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function U(e,t,n){return i()?H(e,n):o()?u(e,n):V(t,n)}function W(e){return async t=>B(await U(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?L(t.body):void 0}))}function G(e){let t=e?.getImsToken??(async()=>(await F()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return B(await U(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?L(e.body):void 0}))}}export{v as AemMountBackend,A as DaMountBackend,l as RemoteMountCache,N as S3MountBackend,G as makeSignedFetchDa,W as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-C209lUzH.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-G9XcYrxe.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-k2E6ulyv.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import"./src-CAWTvdAa.js";import{n as i}from"./runtime-env-Dlaokqg1.js";import{i as a,n as o,t as s}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-E-i2SW1s.js";import{t as c}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-CsZ7MYNO.js";import{t as l}from"./remote-cache-3KNT1gsp.js";import{t as u}from"./mount-bridge-client-XJGXnqiZ.js";var d=`https://api.aem.live`,f=`application/folder`,p=5242880;function m(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 h(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function g(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function _(e){return e.map(e=>e[`content-type`]===f||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:h(e[`last-modified`]),lastModified:g(e[`last-modified`])})}var v=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=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??p,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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:d,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 c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,h(r.headers.get(`last-modified`))),i}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 c(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=h(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new c(`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 c(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new c(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new c(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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 c(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem list failed: ${r.status}`,e);let i=_(await r.json());return await this.cache.putListing(t,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new c(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.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 c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new c(`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=_(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}},y=`\r
3
+ `;function b(){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 x(e,t=b()){let n=new TextEncoder,r=[];for(let i of e){let e=C(S(i.name));if(`file`in i){let a=C(i.file.filename),o=w(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${y}Content-Disposition: form-data; name="${e}"; filename="${a}"${y}Content-Type: ${o}${y}${y}`)),r.push(i.file.bytes),r.push(n.encode(y))}else r.push(n.encode(`--${t}${y}Content-Disposition: form-data; name="${e}"${y}${y}${S(i.value)}${y}`))}return r.push(n.encode(`--${t}--${y}`)),{bytes:T(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function S(e){return e.replace(/\r\n|\r|\n/g,y)}function C(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function w(e){return(e??``).replace(/[\r\n]/g,``).trim()}function T(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 E(e,t,n){let r=x([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function D(e){return e.split(`/`).pop()||`data`}function O(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 k=5242880,A=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=O(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??k,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=E(D(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,u=1;try{l=await s()}catch{u=2,l=await s()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`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 c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.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 c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`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 j(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 M=26214400,N=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=j(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??M,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.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 c(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.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 c(`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 c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},P=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function F(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-C209lUzH.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new P(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var I=r,L=n,R=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),z=new Set([101,103,204,205,304]);function B(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||R.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=I(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=z.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function V(e,t){let n;try{n=await fetch(a(e),{method:`POST`,headers:s({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function H(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function U(e,t,n){return i()?H(e,n):o()?u(e,n):V(t,n)}function W(e){return async t=>B(await U(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?L(t.body):void 0}))}function G(e){let t=e?.getImsToken??(async()=>(await F()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return B(await U(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?L(e.body):void 0}))}}export{v as AemMountBackend,A as DaMountBackend,l as RemoteMountCache,N as S3MountBackend,G as makeSignedFetchDa,W as makeSignedFetchS3};
@@ -9,4 +9,4 @@ Content-Disposition: form-data; name="${e}"\r
9
9
  ${x(i.value)}\r
10
10
  `))}return r.push(n.encode(`--${t}--\r
11
11
  `)),{bytes:w(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}async function b(e,t=_()){let n=[];for(let[t,r]of e.entries()){if(typeof r==`string`){n.push({name:t,value:r});continue}let e=typeof r.name==`string`?r.name:`blob`;n.push({name:t,file:{bytes:new Uint8Array(await r.arrayBuffer()),filename:e,contentType:r.type||void 0}})}return y(n,t)}function x(e){return e.replace(/\r\n|\r|\n/g,`\r
12
- `)}function S(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function C(e){return(e??``).replace(/[\r\n]/g,``).trim()}function w(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 T(e,t,n){let r=y([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function E(e){return e.split(`/`).pop()||`data`}function D(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 O=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=D(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`da access denied`,e);if(i.status>=400)throw new l(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``,u=c.startsWith(`W/`)?c.slice(2):c;return await this.cache.putBody(t,s,u),s}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=T(E(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let o=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),c,u=1;try{c=await o()}catch{u=2,c=await o()}if(c.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new l(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(c.status===401||c.status===403)throw new l(`EACCES`,`da write denied`,e);if(c.status>=400)throw new l(`EIO`,`da writeFile failed: ${c.status}`,e);let d=c.headers.get(`etag`)??``;await this.cache.putBody(n,t,d);let f=n.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 l(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new l(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`da stat failed: ${s.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 l(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new l(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new l(`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 k(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 A=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=k(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new l(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,c),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new l(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new l(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new l(`EIO`,`s3 writeFile failed: ${o.status}`,e);let c=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,c);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 l(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`s3 stat failed: ${s.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 l(`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 l(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new l(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},j=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function M(){let{getAccounts:e}=await import(`./account-store-BeWWaisz.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new j(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const N=c({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new l(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function P(e,t){return N({type:e,envelope:t})}const F=n,I=t,L=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),R=new Set([101,103,204,205,304]);function z(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new l(`EACCES`,e.error):e.errorCode===`invalid_request`?new l(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||L.has(String(e.errorCode))?new l(`EIO`,e.error):new l(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=F(e.bodyBase64)}catch(e){throw new l(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=R.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function B(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new l(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function V(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function H(e,t,n){return r()?V(e,n):a()?P(e,n):B(t,n)}function U(e){return async t=>z(await H(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?I(t.body):void 0}))}function W(e){let t=e?.getImsToken??(async()=>(await M()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new l(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return z(await H(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?I(e.body):void 0}))}}var G=e({AEM_SOURCE_BUS_ORIGIN:()=>d,AemMountBackend:()=>g,DaMountBackend:()=>O,RemoteMountCache:()=>u,S3MountBackend:()=>A,makeSignedFetchDa:()=>W,makeSignedFetchS3:()=>U});export{O as a,d as c,A as i,g as l,W as n,b as o,U as r,v as s,G as t};
12
+ `)}function S(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function C(e){return(e??``).replace(/[\r\n]/g,``).trim()}function w(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 T(e,t,n){let r=y([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function E(e){return e.split(`/`).pop()||`data`}function D(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 O=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=D(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`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 i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`da access denied`,e);if(i.status>=400)throw new l(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``,u=c.startsWith(`W/`)?c.slice(2):c;return await this.cache.putBody(t,s,u),s}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=T(E(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let o=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),c,u=1;try{c=await o()}catch{u=2,c=await o()}if(c.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new l(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(c.status===401||c.status===403)throw new l(`EACCES`,`da write denied`,e);if(c.status>=400)throw new l(`EIO`,`da writeFile failed: ${c.status}`,e);let d=c.headers.get(`etag`)??``;await this.cache.putBody(n,t,d);let f=n.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 l(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new l(`EIO`,`da list failed: ${r.status}`,e);let i=(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,i),i}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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`da stat failed: ${s.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 l(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new l(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new l(`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 k(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 A=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=k(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new l(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,c),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new l(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new l(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new l(`EIO`,`s3 writeFile failed: ${o.status}`,e);let c=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,c);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 l(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.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(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`s3 stat failed: ${s.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 l(`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 l(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new l(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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}},j=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function M(){let{getAccounts:e}=await import(`./account-store-BRlVG3UL.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new j(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const N=c({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new l(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function P(e,t){return N({type:e,envelope:t})}const F=n,I=t,L=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),R=new Set([101,103,204,205,304]);function z(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new l(`EACCES`,e.error):e.errorCode===`invalid_request`?new l(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||L.has(String(e.errorCode))?new l(`EIO`,e.error):new l(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=F(e.bodyBase64)}catch(e){throw new l(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=R.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function B(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new l(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function V(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function H(e,t,n){return r()?V(e,n):a()?P(e,n):B(t,n)}function U(e){return async t=>z(await H(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?I(t.body):void 0}))}function W(e){let t=e?.getImsToken??(async()=>(await M()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new l(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return z(await H(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?I(e.body):void 0}))}}var G=e({AEM_SOURCE_BUS_ORIGIN:()=>d,AemMountBackend:()=>g,DaMountBackend:()=>O,RemoteMountCache:()=>u,S3MountBackend:()=>A,makeSignedFetchDa:()=>W,makeSignedFetchS3:()=>U});export{O as a,d as c,A as i,g as l,W as n,b as o,U as r,v as s,G as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./types-Dgm4REV3.js";var n=class e{kind=`local`;listingStatsMatchStat=!0;source=void 0;profile=void 0;mountId;handle;dirCacheMax;dirCache=new Map;closed=!1;constructor(e,t){this.handle=e,this.mountId=t.mountId,this.dirCacheMax=t.dirCacheMax??512}static fromHandle(t,n){return new e(t,n)}getHandle(){return this.handle}assertOpen(e){if(this.closed)throw new t(`EBADF`,`mount closed`,e)}splitPath(e){return e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`).filter(e=>e.length>0)}cacheGet(e){let t=this.dirCache.get(e);if(t!==void 0)return this.dirCache.delete(e),this.dirCache.set(e,t),t}cacheSet(e,t){for(this.dirCache.has(e)&&this.dirCache.delete(e),this.dirCache.set(e,t);this.dirCache.size>this.dirCacheMax;){let e=this.dirCache.keys().next();if(e.done)break;this.dirCache.delete(e.value)}}invalidate(e){if(e===``){this.dirCache.clear();return}let t=`${e}/`;for(let n of[...this.dirCache.keys()])(n===e||n.startsWith(t))&&this.dirCache.delete(n)}getDirCacheSize(){return this.dirCache.size}async resolveDirFrom(e,t,n,r=!0){let i=this.handle,a=``,o=0;if(r)for(let t=e.length;t>0;t--){let n=e.slice(0,t).join(`/`),r=this.cacheGet(n);if(r){i=r,a=n,o=t;break}}let s=a;for(;o<e.length;o++){let r=e[o];try{i=await i.getDirectoryHandle(r,{create:n})}catch(r){if(n&&s!==``)return this.invalidate(s),this.resolveDirFrom(e,t,n,!1);throw this.toFsError(r,t)}a=a===``?r:`${a}/${r}`,this.cacheSet(a,i)}return i}async resolveDir(e,t=!1){return this.resolveDirFrom(this.splitPath(e),e,t)}async resolveParent(e,n){let r=this.splitPath(e);if(r.length===0)throw new t(`EISDIR`,`is a directory`,e);let i=r.pop();return{parent:await this.resolveDirFrom(r,e,n),name:i}}async resolveFile(e,t=!1){let{parent:n,name:r}=await this.resolveParent(e,t);try{return await n.getFileHandle(r,{create:t})}catch(t){throw this.toFsError(t,e)}}toFsError(e,n){if(e instanceof t)return e;if(e instanceof DOMException){if(e.name===`NotFoundError`)return new t(`ENOENT`,`no such file or directory`,n);if(e.name===`TypeMismatchError`)return new t(`ENOTDIR`,`not a directory`,n);if(e.name===`NotAllowedError`)return new t(`EACCES`,`permission denied`,n);if(e.name===`InvalidModificationError`)return new t(`ENOTEMPTY`,`directory not empty`,n)}if(e instanceof Error){if(e.name===`NotFound`||e.name===`NotFoundError`)return new t(`ENOENT`,`no such file or directory`,n);if(e.name===`TypeMismatch`||e.name===`TypeMismatchError`)return new t(`ENOTDIR`,`not a directory`,n);if(e.name===`InvalidModification`||e.name===`InvalidModificationError`)return new t(`ENOTEMPTY`,`directory not empty`,n)}return new t(`EINVAL`,e instanceof Error?e.message:String(e),n)}async readDir(e,t){this.assertOpen(e);let n=await this.resolveDir(e),r=[];for await(let[e,i]of n){if(i.kind!==`file`){r.push({name:e,kind:`directory`});continue}if(!t?.includeStats){r.push({name:e,kind:`file`});continue}let n=await i.getFile();r.push({name:e,kind:`file`,size:n.size,lastModified:n.lastModified})}return r}async readFile(e){this.assertOpen(e);let t=await(await this.resolveFile(e)).getFile();return new Uint8Array(await t.arrayBuffer())}async getNativeFile(e){this.assertOpen(e);try{return await(await this.resolveFile(e)).getFile()}catch{return null}}async writeFile(e,t){this.assertOpen(e);let n=await(await this.resolveFile(e,!0)).createWritable();await n.write(t),await n.close()}async stat(e){this.assertOpen(e);let t=this.splitPath(e);if(t.length===0)return{kind:`directory`,size:0,mtime:0};let n=t.pop(),r=await this.resolveDirFrom(t,e,!1);try{let e=await(await r.getFileHandle(n)).getFile();return{kind:`file`,size:e.size,mtime:e.lastModified}}catch(t){let n=this.toFsError(t,e);if(n.code!==`ENOENT`&&n.code!==`ENOTDIR`)throw n}try{let e=await r.getDirectoryHandle(n);this.cacheSet(t.length===0?n:`${t.join(`/`)}/${n}`,e)}catch(t){throw this.toFsError(t,e)}return{kind:`directory`,size:0,mtime:0}}async mkdir(e){this.assertOpen(e),await this.resolveDir(e,!0)}async remove(e,n){this.assertOpen(e);let r=this.splitPath(e);if(r.length===0)throw new t(`EINVAL`,`cannot remove mount root`,e);let i=r.pop(),a=await this.resolveDirFrom(r,e,!1);try{await a.removeEntry(i,{recursive:n?.recursive??!1})}catch(t){throw this.toFsError(t,e)}this.invalidate(r.length===0?i:`${r.join(`/`)}/${i}`)}async refresh(){return this.assertOpen(`/`),this.dirCache.clear(),{added:[],removed:[],changed:[],unchanged:0,errors:[]}}describe(){return{displayName:this.handle.name}}async close(){this.closed=!0,this.dirCache.clear()}};const r=new Set([`node_modules`,`dist`,`build`,`coverage`]);function i(e){return e.startsWith(`.`)||r.has(e)}const a=e(`mount-index`);var o=class extends Error{cause;constructor(e,t){super(e),this.name=`MountIndexAbortError`,this.cause=t}};function s(e){let t=e.map(([e,t])=>`${e}\u0000${t.kind}`).sort(),n=t.length>256?t.slice(0,256):t;return`${t.length}\u0001${n.join(``)}`}async function c(e,t){let n=e.isSameEntry;if(typeof n!=`function`)return!1;try{return await n.call(e,t)}catch{return!1}}const l={maxDepth:100,maxEntries:1e5,skipNoiseDirs:!0};function u(e,t){return e instanceof Map?e.get(t):e[t]}function d(e){let t=e.trim();if(t===``)return;let n=Number(t);if(!(!Number.isInteger(n)||n<=0))return n}function f(e,t,n){let r=u(e,t);if(r===void 0||r.trim()===``)return n;let i=d(r);return i===void 0?(a.warn(`Ignoring invalid ${t}; expected a positive integer, using default`,{value:r,fallback:n}),n):i}function p(e){return{maxDepth:f(e,`SLICC_MOUNT_INDEX_MAX_DEPTH`,400),maxEntries:f(e,`SLICC_MOUNT_INDEX_MAX_ENTRIES`,2e6),skipNoiseDirs:!0}}var m=class{mounts=new Map;listeners=new Set;registerMount(e,t,n=p({})){this.mounts.get(e)?.abortController?.abort();let r=new AbortController,i={handle:t,state:{status:`pending`,indexed:0},files:new Set,directories:new Set,childrenByDirectory:new Map,abortController:r,limits:n};this.mounts.set(e,i),this.notifyListeners(),this.indexMount(e,i,r.signal)}unregisterMount(e){let t=this.mounts.get(e);t&&(t.abortController?.abort(),this.mounts.delete(e),this.notifyListeners())}async refreshMount(e,t){let n=this.mounts.get(e);if(!n)throw Error(`No mount at ${e}`);n.abortController?.abort();let r=new AbortController;n.abortController=r,n.state={status:`pending`,indexed:0},n.files.clear(),n.directories.clear(),n.childrenByDirectory.clear(),t&&(n.limits=t),this.notifyListeners(),await this.indexMount(e,n,r.signal)}isReady(e){return this.mounts.get(e)?.state.status===`ready`}isAnyIndexing(){for(let e of this.mounts.values())if(e.state.status===`indexing`||e.state.status===`pending`)return!0;return!1}dispose(){for(let e of this.mounts.values())e.abortController?.abort();this.mounts.clear(),this.listeners.clear()}getState(e){return this.mounts.get(e)?.state}getFiles(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;if(!t)return[...n.files];let r=[];for(let e of n.files)t(e)&&r.push(e);return r}getDirectoryEntries(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;let r=n.childrenByDirectory.get(t);if(r)return[...r].map(([e,t])=>({name:e,type:t}))}hasPath(e,t){let n=this.mounts.get(e);if(n?.state.status===`ready`)return n.files.has(t)||n.directories.has(t)}notifyWrite(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`||this.isSkippedNoisePath(t,e,n,`file`))return;n.files.add(e),this.addPathToChildIndex(n,e,`file`);let r=this.parentPath(e);for(;(r===t||r.startsWith(`${t}/`))&&(n.directories.add(r),this.ensureDirectoryChildren(n,r),r!==t);)this.addPathToChildIndex(n,r,`directory`),r=this.parentPath(r)}notifyDelete(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`||this.isSkippedNoisePath(t,e,n,`unknown`))return;n.files.delete(e),n.directories.delete(e);let r=e+`/`;for(let e of n.files)e.startsWith(r)&&n.files.delete(e);for(let e of n.directories)e.startsWith(r)&&n.directories.delete(e);this.removePathFromChildIndex(n,e);for(let t of n.childrenByDirectory.keys())(t===e||t.startsWith(r))&&n.childrenByDirectory.delete(t)}notifyRename(e,t){let n=this.findMountForPath(e);if(!n)return;let r=this.mounts.get(n);if(r?.state.status!==`ready`)return;let i=r.files.has(e)?`file`:r.directories.has(e)?`directory`:`unknown`;if(i===`unknown`||this.isSkippedNoisePath(n,e,r,i))return;if(this.isSkippedNoisePath(n,t,r,i)){this.notifyDelete(e);return}if(i===`file`){r.files.delete(e),r.files.add(t),this.removePathFromChildIndex(r,e),this.addPathToChildIndex(r,t,`file`);return}r.directories.delete(e),r.directories.add(t);let a=e+`/`,o=t+`/`;for(let e of[...r.files])e.startsWith(a)&&(r.files.delete(e),r.files.add(o+e.slice(a.length)));for(let e of[...r.directories])e.startsWith(a)&&(r.directories.delete(e),r.directories.add(o+e.slice(a.length)));this.removePathFromChildIndex(r,e),this.addPathToChildIndex(r,t,`directory`);let s=[...r.childrenByDirectory.entries()].filter(([t])=>t===e||t.startsWith(a));for(let[e]of s)r.childrenByDirectory.delete(e);for(let[n,i]of s){let s=n===e?t:o+n.slice(a.length);r.childrenByDirectory.set(s,i)}}ensureDirectoryChildren(e,t){let n=e.childrenByDirectory.get(t);return n||(n=new Map,e.childrenByDirectory.set(t,n)),n}addPathToChildIndex(e,t,n){let r=t.slice(t.lastIndexOf(`/`)+1);r&&(this.ensureDirectoryChildren(e,this.parentPath(t)).set(r,n),n===`directory`&&this.ensureDirectoryChildren(e,t))}removePathFromChildIndex(e,t){let n=t.slice(t.lastIndexOf(`/`)+1);e.childrenByDirectory.get(this.parentPath(t))?.delete(n)}parentPath(e){let t=e.lastIndexOf(`/`);return t<=0?`/`:e.slice(0,t)}isSkippedNoisePath(e,t,n,r){if(!n.limits.skipNoiseDirs||!t.startsWith(`${e}/`))return!1;let a=t.slice(e.length+1).split(`/`),o=r===`unknown`?n.files.has(t)?`file`:n.directories.has(t)?`directory`:`unknown`:r;for(let e=0;e<a.length;e++){let t=e===a.length-1;if(!(t&&o===`file`)&&!(t&&o===`unknown`&&!i(a[e]))&&i(a[e]))return!0}return!1}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}findMountForPath(e){let t;for(let n of this.mounts.keys())(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.length)&&(t=n);return t}notifyListeners(){for(let e of this.listeners)try{e()}catch{}}async indexMount(e,t,n){t.state={status:`indexing`,indexed:0},this.notifyListeners();try{if(await this.walkHandle(e,t.handle,t,n),n.aborted)return;t.state={status:`ready`,indexed:t.files.size+t.directories.size,total:t.files.size+t.directories.size},t.abortController=null,a.info(`Mount indexed`,{path:e,files:t.files.size,directories:t.directories.size})}catch(r){if(n.aborted)return;let i=r instanceof Error?r.message:String(r),s=r instanceof o?r.cause:`indexing-error`;t.state={status:`error`,indexed:0,error:i,abortCause:s},a.error(`Mount indexing failed`,{path:e,error:i,abortCause:s})}this.notifyListeners()}async walkHandle(e,t,n,r,i=0,a=new Map){if(r.aborted)return;this.enforceWalkBounds(i,n),n.directories.add(e),this.ensureDirectoryChildren(n,e);let o=await this.readChildren(t,r,n);if(r.aborted)return;let s=await this.confirmNoCycle(e,t,o,a),c=this.pushAncestor(a,s,e,t);try{await this.walkChildren(e,o,n,r,i,a)}finally{this.popAncestor(a,s,c)}}enforceWalkBounds(e,t){if(e>t.limits.maxDepth)throw new o(`mount indexing aborted: directory nesting exceeded ${t.limits.maxDepth} levels`,`depth-exceeded`);if(t.directories.size+t.files.size>=t.limits.maxEntries)throw new o(`mount indexing aborted: exceeded ${t.limits.maxEntries} entries`,`entries-exceeded`)}async readChildren(e,t,n){let r=e,i=[];for await(let e of r){if(t.aborted)break;if(n.directories.size+n.files.size+i.length>=n.limits.maxEntries)throw new o(`mount indexing aborted: exceeded ${n.limits.maxEntries} entries`,`entries-exceeded`);i.push(e)}return i}async confirmNoCycle(e,t,n,r){let i=s(n),a=r.get(i);if(a){for(let n of a)if(await c(n.handle,t))throw new o(`mount indexing aborted: self-referential mount cycle detected at ${e} (re-exposes ${n.path})`,`cycle-detected`)}return i}pushAncestor(e,t,n,r){let i=e.get(t);return i||(i=[],e.set(t,i)),i.push({path:n,handle:r,signature:t}),i}popAncestor(e,t,n){n.pop(),n.length===0&&e.delete(t)}async walkChildren(e,t,n,r,a,o){for(let[s,c]of t){if(r.aborted)return;let t=e===`/`?`/${s}`:`${e}/${s}`;if(c.kind===`file`)n.files.add(t),this.addPathToChildIndex(n,t,`file`),n.state.indexed++;else if(c.kind===`directory`){if(n.limits.skipNoiseDirs&&i(s))continue;this.addPathToChildIndex(n,t,`directory`),await this.walkHandle(t,c,n,r,a+1,o)}n.state.indexed%500==0&&(this.notifyListeners(),await new Promise(e=>setTimeout(e,0)))}}};export{n as i,l as n,p as r,m as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-BiTaSCAQ.js";import{a as r,i,l as a,n as o,r as s}from"./mount-CxIOoyoX.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-BE5T1-53.js";var u=e({formatMountRecoveryPrompt:()=>_,mdInlineCode:()=>g,recoverMounts:()=>m,shellQuote:()=>h});function d(e){return e instanceof Error?e.message:String(e)}async function f(e,r,i,a){let o=await c(r.idbHandleKey),s=typeof o?.name==`string`?o.name:``,l={kind:`local`,path:e,dirName:s};if(!o||!(`queryPermission`in o))return{entry:l,ok:!1};let u;try{u=await o.queryPermission({mode:`readwrite`})}catch(t){return a?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}if(u!==`granted`)return{entry:l,ok:!1};try{let c=t.fromHandle(o,{mountId:r.mountId});return await i.mount(e,c,{limits:n}),a?.info?.(`Restored mount from previous session`,{path:e,name:s}),{entry:l,ok:!0}}catch(t){return a?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}}async function p(e,t,n,c){let{kind:u,source:f,profile:p,mountId:m}=t,h=u===`s3`?`S3`:u===`aem`?`AEM`:`DA`;try{let t={source:f,profile:p,cache:new l({mountId:m,ttlMs:3e4}),mountId:m},d=u===`s3`?new i({...t,signedFetch:s(p)}):u===`aem`?new a({...t,signedFetch:o()}):new r({...t,signedFetch:o()});return await n.mount(e,d),c?.info?.(`Restored ${h} mount from previous session`,{path:e,source:f}),{entry:{kind:u,path:e,source:f,profile:p,reason:``},ok:!0}}catch(t){let n=d(t);return c?.warn?.(`Failed to restore ${h} mount`,{path:e,error:n}),{entry:{kind:u,path:e,source:f,profile:p,reason:n},ok:!1}}}async function m(e,t,n){let r=[],i=[];for(let{targetPath:a,descriptor:o}of e){if(o.kind===`hostfs`)continue;let e=o.kind===`local`?await f(a,o,t,n):await p(a,o,t,n);(e.ok?r:i).push(e.entry)}return{restored:r,needsRecovery:i}}function h(e){return`'${e.replace(/'/g,`'\\''`)}'`}function g(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function _(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`||e.kind===`aem`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${g(t)})`:``;return`- ${g(e)}${n}`}),i=r.map(({path:e})=>` mount ${h(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n==="default"?``:` --profile ${h(n)}`,a=`mount --source ${h(t)}${i} ${h(e)}`;return`- ${g(e)} (${g(t)}, profile ${g(n)}) — ${r}\n Retry: ${g(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-D9w_zMSm.js";import{a as r,i,l as a,n as o,r as s}from"./mount-DHQXC9Xw.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-BE5T1-53.js";var u=e({formatMountRecoveryPrompt:()=>_,mdInlineCode:()=>g,recoverMounts:()=>m,shellQuote:()=>h});function d(e){return e instanceof Error?e.message:String(e)}async function f(e,r,i,a){let o=await c(r.idbHandleKey),s=typeof o?.name==`string`?o.name:``,l={kind:`local`,path:e,dirName:s};if(!o||!(`queryPermission`in o))return{entry:l,ok:!1};let u;try{u=await o.queryPermission({mode:`readwrite`})}catch(t){return a?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}if(u!==`granted`)return{entry:l,ok:!1};try{let c=t.fromHandle(o,{mountId:r.mountId});return await i.mount(e,c,{limits:n}),a?.info?.(`Restored mount from previous session`,{path:e,name:s}),{entry:l,ok:!0}}catch(t){return a?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}}async function p(e,t,n,c){let{kind:u,source:f,profile:p,mountId:m}=t,h=u===`s3`?`S3`:u===`aem`?`AEM`:`DA`;try{let t={source:f,profile:p,cache:new l({mountId:m,ttlMs:3e4}),mountId:m},d=u===`s3`?new i({...t,signedFetch:s(p)}):u===`aem`?new a({...t,signedFetch:o()}):new r({...t,signedFetch:o()});return await n.mount(e,d),c?.info?.(`Restored ${h} mount from previous session`,{path:e,source:f}),{entry:{kind:u,path:e,source:f,profile:p,reason:``},ok:!0}}catch(t){let n=d(t);return c?.warn?.(`Failed to restore ${h} mount`,{path:e,error:n}),{entry:{kind:u,path:e,source:f,profile:p,reason:n},ok:!1}}}async function m(e,t,n){let r=[],i=[];for(let{targetPath:a,descriptor:o}of e){if(o.kind===`hostfs`)continue;let e=o.kind===`local`?await f(a,o,t,n):await p(a,o,t,n);(e.ok?r:i).push(e.entry)}return{restored:r,needsRecovery:i}}function h(e){return`'${e.replace(/'/g,`'\\''`)}'`}function g(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function _(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`||e.kind===`aem`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${g(t)})`:``;return`- ${g(e)}${n}`}),i=r.map(({path:e})=>` mount ${h(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n==="default"?``:` --profile ${h(n)}`,a=`mount --source ${h(t)}${i} ${h(e)}`;return`- ${g(e)} (${g(t)}, profile ${g(n)}) — ${r}\n Retry: ${g(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
2
2
  `)}export{u as n,h as r,_ as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-CvqNttpI.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-CrzQRVmk.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Dz3RSRQx.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BJsliYCh.js"])))=>i.map(i=>d[i]);
2
- import{L as e,m as t}from"./account-store-CrzQRVmk.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{r as i}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-Cr_y3ZO3.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{t as o}from"./chat-session-store-pWb1-jNp.js";import{a as s,i as c,n as l,r as u,t as d}from"./session-freezer-DK9G_IkB.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let o;try{o=e()}catch{return}let c=o.provider===`adobe`?{"X-Session-Id":a(p)}:void 0;await s({vfs:r,model:o,apiKey:i,headers:c}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(i(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,a){let o=await u({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});if(!o)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(o)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),o.completeSnapshotUnavailable=!0;try{await c(e.vfs,o.filename)}catch{}}return x(e,t,n,r,i,a,o),o}async function x(e,t,r,i,a,o,s){let c=s;try{let t=await l(e.vfs,s,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-CvqNttpI.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])).then(({pickLucideIcon:t})=>t(e))});t&&(c={...t,archive:s.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:s.filename,error:e instanceof Error?e.message:String(e)})}let u=await d({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},c).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:c.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:c.filename,memoryPending:!u||u.memoryPending===!0}),e.onBackgroundEnriched?.(u)}function S(e){return e?.code===`ENOENT`}function C(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function w(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(S(e))continue;throw e}if(await w(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!S(e))throw e}}}}async function T(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>C(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 w(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function E(r){let i=r.enrichmentRaceMs??m,s=t()??void 0,d;try{d=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=d?.provider===`adobe`?{"X-Session-Id":a(p)}:void 0,g=new o;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&d?y(r):void 0;if(_)return await b(r,g,d,s,h,_);let v=await u({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await c(r.vfs,v.filename)}catch{}}if(!s||!d)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=d,S=l(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-CvqNttpI.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])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await D(S,i,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function D(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));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 O(e){return A(e,void 0)}async function k(e){return A(e,`skip`)}async function A(e,t){let n=new o;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await u({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await c(e.vfs,r.filename)}catch{}}return r}export{T as resetNewSessionTmp,k as runNewSessionArchiveOnly,E as runNewSessionFreeze,O as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-CLyaja5O.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-C209lUzH.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-G9XcYrxe.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BJsliYCh.js"])))=>i.map(i=>d[i]);
2
+ import{L as e,m as t}from"./account-store-C209lUzH.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{r as i}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-BQqRKwG3.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{t as o}from"./chat-session-store-pWb1-jNp.js";import{a as s,i as c,n as l,r as u,t as d}from"./session-freezer-BDQV7q_1.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let o;try{o=e()}catch{return}let c=o.provider===`adobe`?{"X-Session-Id":a(p)}:void 0;await s({vfs:r,model:o,apiKey:i,headers:c}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(i(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,a){let o=await u({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});if(!o)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(o)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),o.completeSnapshotUnavailable=!0;try{await c(e.vfs,o.filename)}catch{}}return x(e,t,n,r,i,a,o),o}async function x(e,t,r,i,a,o,s){let c=s;try{let t=await l(e.vfs,s,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-CLyaja5O.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])).then(({pickLucideIcon:t})=>t(e))});t&&(c={...t,archive:s.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:s.filename,error:e instanceof Error?e.message:String(e)})}let u=await d({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},c).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:c.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:c.filename,memoryPending:!u||u.memoryPending===!0}),e.onBackgroundEnriched?.(u)}function S(e){return e?.code===`ENOENT`}function C(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function w(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(S(e))continue;throw e}if(await w(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!S(e))throw e}}}}async function T(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>C(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 w(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function E(r){let i=r.enrichmentRaceMs??m,s=t()??void 0,d;try{d=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=d?.provider===`adobe`?{"X-Session-Id":a(p)}:void 0,g=new o;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&d?y(r):void 0;if(_)return await b(r,g,d,s,h,_);let v=await u({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await c(r.vfs,v.filename)}catch{}}if(!s||!d)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=d,S=l(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-CLyaja5O.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])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await D(S,i,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function D(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));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 O(e){return A(e,void 0)}async function k(e){return A(e,`skip`)}async function A(e,t){let n=new o;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await u({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await c(e.vfs,r.filename)}catch{}}return r}export{T as resetNewSessionTmp,k as runNewSessionArchiveOnly,E as runNewSessionFreeze,O as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-DZDGqjz1.js","assets/account-store-CrzQRVmk.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Dz3RSRQx.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/pkce-hGf_TEnP.js","assets/provider-store-access-BgIb6-X8.js","assets/global-db-CbuLl-zx.js","assets/types-Dgm4REV3.js"])))=>i.map(i=>d[i]);
2
- import{H as e,d as t}from"./account-store-CrzQRVmk.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-Dz3RSRQx.js";import"./provider-settings-Cr_y3ZO3.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-DZDGqjz1.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])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.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(t,n){try{await e({providerId:t.providerId,accessToken:n,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:s(e)})}}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=t();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-D09664Ko.js","assets/account-store-C209lUzH.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-G9XcYrxe.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/pkce-hGf_TEnP.js","assets/provider-store-access-117y9N_1.js","assets/global-db-CbuLl-zx.js","assets/types-Dgm4REV3.js"])))=>i.map(i=>d[i]);
2
+ import{H as e,d as t}from"./account-store-C209lUzH.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-G9XcYrxe.js";import"./provider-settings-BQqRKwG3.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-D09664Ko.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])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.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(t,n){try{await e({providerId:t.providerId,accessToken:n,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:s(e)})}}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=t();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
@@ -1 +1 @@
1
- import{H as e,d as t}from"./account-store-CrzQRVmk.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{u as r}from"./claude-model-version-BJLrDjmH.js";import{n as i,o as a}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-Cr_y3ZO3.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-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:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{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){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}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===l)}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:l,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:l,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(),o={...t,baseUrl:g,api:_},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)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(),o={...t,baseUrl:g,api:_},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}var 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:l,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=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,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{H as e,d as t}from"./account-store-C209lUzH.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{u as r}from"./claude-model-version-BJLrDjmH.js";import{n as i,o as a}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-BQqRKwG3.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-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:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{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){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}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===l)}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:l,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:l,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(),o={...t,baseUrl:g,api:_},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)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(),o={...t,baseUrl:g,api:_},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}var 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:l,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=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,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};