sliccy 6.165.0 → 6.166.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 (172) hide show
  1. package/dist/node-server/_shared/computer-protocol.d.ts +108 -0
  2. package/dist/node-server/_shared/computer-protocol.d.ts.map +1 -0
  3. package/dist/node-server/_shared/computer-protocol.js +10 -0
  4. package/dist/node-server/_shared/computer-protocol.js.map +1 -0
  5. package/dist/node-server/_shared/index.d.ts +1 -0
  6. package/dist/node-server/_shared/index.d.ts.map +1 -1
  7. package/dist/node-server/_shared/index.js +1 -0
  8. package/dist/node-server/_shared/index.js.map +1 -1
  9. package/dist/ui/.vite/manifest.json +184 -174
  10. package/dist/ui/assets/{SKILL-C8DJkgFD.js → SKILL-BGEZa-y0.js} +1 -1
  11. package/dist/ui/assets/SKILL-DB5CVwyu.js +1 -0
  12. package/dist/ui/assets/SKILL-DEFDsScb.js +1 -0
  13. package/dist/ui/assets/{SKILL-0AeLgxT3.js → SKILL-DZoCcID_.js} +1 -1
  14. package/dist/ui/assets/{account-store-lzZlhljv.js → account-store-BEqmysw9.js} +1 -1
  15. package/dist/ui/assets/{account-store-CJHBoL7P.js → account-store-C35GYvum.js} +1 -1
  16. package/dist/ui/assets/{adobe-DbBJWbF9.js → adobe-BDH5oLAN.js} +1 -1
  17. package/dist/ui/assets/{adobe-DUaaJHme.js → adobe-BcTGFCnQ.js} +1 -1
  18. package/dist/ui/assets/{agent-panels-DQh4wRpa.js → agent-panels-DvqNnkLk.js} +1 -1
  19. package/dist/ui/assets/{almost-bash-shell-headless-DdfO5taA.js → almost-bash-shell-headless-DqTtE9CM.js} +506 -508
  20. package/dist/ui/assets/{apply-layout-DeIHdw5o.js → apply-layout-CjYRGs37.js} +1 -1
  21. package/dist/ui/assets/{apps-X6cH7Ngi.js → apps-dzoLZ_5W.js} +1 -1
  22. package/dist/ui/assets/{azure-openai-DS5DA5ql.js → azure-openai-BffwoCtp.js} +1 -1
  23. package/dist/ui/assets/{azure-openai-DoDPxnFq.js → azure-openai-DKGdcr4S.js} +1 -1
  24. package/dist/ui/assets/{backend-hostfs-9Xwjq8kU.js → backend-hostfs-CWIlIhve.js} +1 -1
  25. package/dist/ui/assets/bridge-protocol-31SWTdS5.js +1 -0
  26. package/dist/ui/assets/{cdp-Bi4OGeyp.js → cdp-DXT6yEL1.js} +1 -1
  27. package/dist/ui/assets/{cerebras-D9Xp_f8D.js → cerebras-BF5efkRL.js} +1 -1
  28. package/dist/ui/assets/{cerebras-BzQeaK2Z.js → cerebras-By0l7t0i.js} +1 -1
  29. package/dist/ui/assets/{composer-speech-BVpldTNH.js → composer-speech-DIEePbQC.js} +1 -1
  30. package/dist/ui/assets/{connect-surface-CyUMMhhU.js → connect-surface-DBqs7oHf.js} +1 -1
  31. package/dist/ui/assets/{directed-approval-CaEocD9T.js → directed-approval-D1lGElvD.js} +1 -1
  32. package/dist/ui/assets/{ensure-speech-assets-B9REkBI_.js → ensure-speech-assets-BJXemBO4.js} +1 -1
  33. package/dist/ui/assets/fake-computer-1f2_4vxY.js +65 -0
  34. package/dist/ui/assets/{frozen-archive-writer-BWuT2QtJ.js → frozen-archive-writer-DYPhPMg7.js} +1 -1
  35. package/dist/ui/assets/{fs-C3QG5M_q.js → fs-BapOupIM.js} +2 -2
  36. package/dist/ui/assets/{fs-CmCsE1zE.js → fs-CBH-hQcI.js} +1 -1
  37. package/dist/ui/assets/{gelatiere-store-ijXRupBc.js → gelatiere-store-C2u47uk0.js} +1 -1
  38. package/dist/ui/assets/{gelatiere-unit-BlRXo_Ch.js → gelatiere-unit-wvDEO7gH.js} +1 -1
  39. package/dist/ui/assets/{github-2vLuAY6J.js → github-Bx7_6LBm.js} +2 -2
  40. package/dist/ui/assets/{github-Zcx-gHTn.js → github-Db015Tee.js} +1 -1
  41. package/dist/ui/assets/{github-auth-87ZWWpe-.js → github-auth-DtKS6UIX.js} +1 -1
  42. package/dist/ui/assets/{github-copilot-DaHQ2cTA.js → github-copilot-CtOjxhqK.js} +1 -1
  43. package/dist/ui/assets/{github-copilot-CdwPARvl.js → github-copilot-eCfmryv6.js} +1 -1
  44. package/dist/ui/assets/{github-install-CCQJ7A9f.js → github-install-B6W4-xcc.js} +1 -1
  45. package/dist/ui/assets/{github-zip-D4jSHksq.js → github-zip-Bv1smNmy.js} +1 -1
  46. package/dist/ui/assets/{handoff-link-NCw3cxSG.js → handoff-link-B3It6xQY.js} +1 -1
  47. package/dist/ui/assets/{hear-CovWNOND.js → hear-BZHckZJM.js} +1 -1
  48. package/dist/ui/assets/{help-BmMJZSmm.js → help-BU2Hjl0P.js} +1 -1
  49. package/dist/ui/assets/host-BQ2qKD-D.js +1 -0
  50. package/dist/ui/assets/{installer-BOAaojqu.js → installer-BbtH3u7z.js} +1 -1
  51. package/dist/ui/assets/js-realm-worker-BT3mfq3w.js +50 -0
  52. package/dist/ui/assets/jsh-CrSWPG4t.js +1 -0
  53. package/dist/ui/assets/jsh-executor-BWlgcE2N.js +18 -0
  54. package/dist/ui/assets/jsh-runtime-extensions-BnLXkzqP.js +1 -0
  55. package/dist/ui/assets/{kernel-worker-CrTnmx6N.js → kernel-worker-Dseu067f.js} +38 -38
  56. package/dist/ui/assets/keys-n5_C9sHW.js +1 -0
  57. package/dist/ui/assets/{lick-ws-bridge-56mwSRdV.js → lick-ws-bridge-Cc9sToY7.js} +1 -1
  58. package/dist/ui/assets/{lick-ws-bridge-D4FyZHWP.js → lick-ws-bridge-ChigxI36.js} +1 -1
  59. package/dist/ui/assets/{live-session-snapshot-ZXxxxzvO.js → live-session-snapshot-B70raB09.js} +1 -1
  60. package/dist/ui/assets/{local-llm-B6tgSQ84.js → local-llm-Dcp5IIP-.js} +1 -1
  61. package/dist/ui/assets/{local-llm-BDbJaGUp.js → local-llm-DpSg-Oe3.js} +1 -1
  62. package/dist/ui/assets/{main-Dxem3Ydy.js → main-CfF8CFBr.js} +3 -3
  63. package/dist/ui/assets/{main-cherry-D1lfDTVL.js → main-cherry-VckJPHm5.js} +1 -1
  64. package/dist/ui/assets/{memory-curation-seam-ZGh8tSbe.js → memory-curation-seam-DUaZFZG9.js} +1 -1
  65. package/dist/ui/assets/{memory-health-CZHaK5wO.js → memory-health-D7uEvfAx.js} +1 -1
  66. package/dist/ui/assets/memory-v2-flag-BHVbti6Z.js +1 -0
  67. package/dist/ui/assets/{memory-write-execute-Csx1-nfE.js → memory-write-execute-rXtR1z76.js} +1 -1
  68. package/dist/ui/assets/{mount-DCCYSZwW.js → mount-8lU2iH4k.js} +3 -3
  69. package/dist/ui/assets/{mount-ByktCqqU.js → mount-DoM0CLGG.js} +1 -1
  70. package/dist/ui/assets/{new-session-CG_ht0Kw.js → new-session-DEhAjxP1.js} +2 -2
  71. package/dist/ui/assets/{oauth-bootstrap-CQmrSZN1.js → oauth-bootstrap-DNTgbEZF.js} +2 -2
  72. package/dist/ui/assets/{onboarding-orchestrator-DZFSsW4q.js → onboarding-orchestrator-DzPQ0pVG.js} +1 -1
  73. package/dist/ui/assets/{openai-codex-dKSgjDc_.js → openai-codex-CsAhfz0D.js} +1 -1
  74. package/dist/ui/assets/{openai-codex-ebHt4iSf.js → openai-codex-DYRKYWTe.js} +1 -1
  75. package/dist/ui/assets/{openrouter-CsPQehN8.js → openrouter-D9T6tXUF.js} +1 -1
  76. package/dist/ui/assets/{openrouter-BQhA4-TP.js → openrouter-IyZlRHg4.js} +1 -1
  77. package/dist/ui/assets/{openrouter-free-kxAwjRgT.js → openrouter-free-CPshAgQD.js} +1 -1
  78. package/dist/ui/assets/{openrouter-free-BppbTow1.js → openrouter-free-DfbYsnmf.js} +1 -1
  79. package/dist/ui/assets/{openrouter-oauth-D0vfD1T8.js → openrouter-oauth-hZg6oH0A.js} +1 -1
  80. package/dist/ui/assets/{openrouter-oauth-B3y32yAJ.js → openrouter-oauth-xKlWi_wI.js} +1 -1
  81. package/dist/ui/assets/{opfs-mount-ld8qlksz.js → opfs-mount-C9Iamj6N.js} +1 -1
  82. package/dist/ui/assets/panel-rpc-handlers-Nu-wOrG9.js +2 -0
  83. package/dist/ui/assets/{panelize-shell-BdV-wKTx.js → panelize-shell-tFElgHWF.js} +1 -1
  84. package/dist/ui/assets/{pi-edit-execution-CoRFZcs7.js → pi-edit-execution-D6vx5LyF.js} +1 -1
  85. package/dist/ui/assets/{provider-CNKZIWc1.js → provider-3--cEcAF.js} +1 -1
  86. package/dist/ui/assets/{provider-DE1pR-oR.js → provider-Z5aj7SzG.js} +2 -2
  87. package/dist/ui/assets/{provider-settings-D8qwiWrG.js → provider-settings-D9sjEfYE.js} +1 -1
  88. package/dist/ui/assets/provider-store-access-M0PvJ08M.js +1 -0
  89. package/dist/ui/assets/provider-store-access-RxIHhH6d.js +1 -0
  90. package/dist/ui/assets/{providers-InF4o-U9.js → providers-CnoKdyLc.js} +2 -2
  91. package/dist/ui/assets/{providers-CUF9nsUE.js → providers-DVvrXbtx.js} +1 -1
  92. package/dist/ui/assets/{quick-llm-CQWR6xvc.js → quick-llm-DjWE-wQw.js} +1 -1
  93. package/dist/ui/assets/realm-inprocess-D0iWBQzz.js +30 -0
  94. package/dist/ui/assets/{recovery-screen-DWMb8zIg.js → recovery-screen-Y1CSyfR-.js} +1 -1
  95. package/dist/ui/assets/registry-Bq_j-EXx.js +1 -0
  96. package/dist/ui/assets/{restore-PqiSHlx3.js → restore-DOkDX8BI.js} +1 -1
  97. package/dist/ui/assets/{run-F7Bv3Fcu.js → run-B-fA26ea.js} +1 -1
  98. package/dist/ui/assets/run-BEt0RS3J.js +52 -0
  99. package/dist/ui/assets/{run-DJQAmghw.js → run-BOc9XLhg.js} +1 -1
  100. package/dist/ui/assets/{run-Bqg_NW7f.js → run-BWJSDhS7.js} +2 -2
  101. package/dist/ui/assets/{run-Do5pAlQf.js → run-DgNh1E56.js} +2 -2
  102. package/dist/ui/assets/{run-DoD-L3x8.js → run-a67LpkRp.js} +2 -2
  103. package/dist/ui/assets/{run-w1tdYqAg.js → run-vEDh-Me-.js} +2 -2
  104. package/dist/ui/assets/{session-command-memory-BKzFoCAZ.js → session-command-memory-DB2GmPSU.js} +2 -2
  105. package/dist/ui/assets/{session-jsonl-DjDV9zx6.js → session-jsonl-DFC-2T76.js} +1 -1
  106. package/dist/ui/assets/{session-jsonl-C7a0swa5.js → session-jsonl-D_pTYppB.js} +1 -1
  107. package/dist/ui/assets/{session-search-index-CMRSS2CP.js → session-search-index-CN1zDLlx.js} +1 -1
  108. package/dist/ui/assets/{setup-feature-flags-remote-BmKhybEI.js → setup-feature-flags-remote-BVd31Z12.js} +1 -1
  109. package/dist/ui/assets/{signed-fetch-DDtJ0TE5.js → signed-fetch-BY2Mdjqe.js} +1 -1
  110. package/dist/ui/assets/{silent-renew-backoff-CBUhiIba.js → silent-renew-backoff-CKAAh6GN.js} +1 -1
  111. package/dist/ui/assets/{silent-renew-backoff-DIMz5UqB.js → silent-renew-backoff-Dmz3DJHb.js} +1 -1
  112. package/dist/ui/assets/slicc-version-BZyTvfoc.js +1 -0
  113. package/dist/ui/assets/{snapshot-features-BIG7eB0k.js → snapshot-features-DjMJkCGq.js} +1 -1
  114. package/dist/ui/assets/{snapshot-DyCo7e-C.js → snapshot-gi8tDzvN.js} +1 -1
  115. package/dist/ui/assets/{soundscape-bHynTI4A.js → soundscape-Bl3LhUk9.js} +1 -1
  116. package/dist/ui/assets/{speak-DbL0fEQT.js → speak-BY_fDou2.js} +1 -1
  117. package/dist/ui/assets/{sprinkle-manager-Bhwou11b.js → sprinkle-manager-C-NUJqPy.js} +1 -1
  118. package/dist/ui/assets/{sprinkle-renderer-CEIEQSMS.js → sprinkle-renderer-CcA6ie5u.js} +1 -1
  119. package/dist/ui/assets/{state-BdNtTsoR.js → state-z3wOHLww.js} +1 -1
  120. package/dist/ui/assets/{store-CJD-1zaX.js → store-ByUcAFUa.js} +1 -1
  121. package/dist/ui/assets/{store-BRXCCWDC.js → store-ChWzn_H8.js} +1 -1
  122. package/dist/ui/assets/{sudo-QHJEgCZR.js → sudo-DNZFIZ-H.js} +1 -1
  123. package/dist/ui/assets/{supervisor-DILjXQCB.js → supervisor-BtH2-9sE.js} +1 -1
  124. package/dist/ui/assets/{sync-dialog-8D9LiBVV.js → sync-dialog-Jqz74VkZ.js} +1 -1
  125. package/dist/ui/assets/tab-ToMhjbM4.js +1 -0
  126. package/dist/ui/assets/{transformers-env-jBVeNAIF.js → transformers-env-pq1E2H6B.js} +1 -1
  127. package/dist/ui/assets/{tray-leader-BxfP0EC1.js → tray-leader-Bas0lH9O.js} +1 -1
  128. package/dist/ui/assets/{tray-leave-runtime-1j0s9Yqq.js → tray-leave-runtime-B9aV_guA.js} +1 -1
  129. package/dist/ui/assets/tray-runtime-config-BZoJXfW0.js +1 -0
  130. package/dist/ui/assets/{tray-sidecar-BUsex5hw.js → tray-sidecar-DA8NfCV6.js} +1 -1
  131. package/dist/ui/assets/{upgrade-detection-DCwNWWGX.js → upgrade-detection-B5ym__Gu.js} +1 -1
  132. package/dist/ui/assets/{upskill-lick-skip-C9u8AmfA.js → upskill-lick-skip-CZGM2OFA.js} +1 -1
  133. package/dist/ui/assets/v86-DseFx8Yp.js +1 -0
  134. package/dist/ui/assets/v86-vm-DCm7zA2r.js +2 -0
  135. package/dist/ui/assets/{voice-reply-CgvrHu7l.js → voice-reply-CL5tDo0l.js} +1 -1
  136. package/dist/ui/assets/{wc-attach-CJV3boxa.js → wc-attach-C5yXIQNU.js} +2 -2
  137. package/dist/ui/assets/{wc-detached-BZT3Rtc5.js → wc-detached-f_qit-5b.js} +1 -1
  138. package/dist/ui/assets/{wc-extension-CZ1sQn79.js → wc-extension-DRx21-cq.js} +2 -2
  139. package/dist/ui/assets/{wc-follower-DO4HcEvu.js → wc-follower-DcKt92kM.js} +3 -3
  140. package/dist/ui/assets/{wc-follower-oauth-CEpYsbPr.js → wc-follower-oauth-BF3qXDTt.js} +1 -1
  141. package/dist/ui/assets/{wc-gelatiere-C4XI_usG.js → wc-gelatiere-qAW7lWGW.js} +1 -1
  142. package/dist/ui/assets/{wc-live-Dz2OSXcJ.js → wc-live-DOMCfDT6.js} +6 -6
  143. package/dist/ui/assets/{wc-nav-ClJyDfXq.js → wc-nav-DzPuXq_n.js} +2 -2
  144. package/dist/ui/assets/{wc-onboarding-BUUyiqjJ.js → wc-onboarding-CXM-z-7_.js} +2 -2
  145. package/dist/ui/assets/{wc-placeholder-Sji0t7ST.js → wc-placeholder-BBqbsuml.js} +3 -3
  146. package/dist/ui/assets/{wc-secret-request-IsuAxr4v.js → wc-secret-request-BSUlxVVi.js} +1 -1
  147. package/dist/ui/assets/{wc-settings-lgNdcEqb.js → wc-settings-55mC-jVS.js} +3 -3
  148. package/dist/ui/assets/{wc-shell-Cj705NBI.js → wc-shell-C71iKreG.js} +3 -3
  149. package/dist/ui/assets/{wc-shortcut-config-ByZ7W9gP.js → wc-shortcut-config-Crjq_rF1.js} +1 -1
  150. package/dist/ui/assets/{wc-sprinkles-D7Cv7m3r.js → wc-sprinkles-Caji5y7n.js} +2 -2
  151. package/dist/ui/assets/{wc-transcript-export-IV61nDvZ.js → wc-transcript-export-Dqe3SH1t.js} +2 -2
  152. package/dist/ui/assets/{wc-tray-XTl0wqt5.js → wc-tray-B7ayzT1W.js} +4 -4
  153. package/dist/ui/assets/welcome-detection-CEARSpAq.js +1 -0
  154. package/dist/ui/assets/{whisper-session-FGrrhHcr.js → whisper-session-DfILe4Yb.js} +2 -2
  155. package/dist/ui/assets/{xai-grok-BdK9whs2.js → xai-grok-CVLBrxdD.js} +1 -1
  156. package/dist/ui/assets/{xai-grok-Z7FTSyzw.js → xai-grok-Dp8n52fO.js} +1 -1
  157. package/dist/ui/index.html +3 -3
  158. package/dist/ui/packages/webapp/index.html +3 -3
  159. package/package.json +1 -1
  160. package/dist/ui/assets/SKILL-CtxHowg1.js +0 -96
  161. package/dist/ui/assets/bridge-protocol-DdqxTTSu.js +0 -1
  162. package/dist/ui/assets/js-realm-worker-Dfep1BlZ.js +0 -50
  163. package/dist/ui/assets/jsh-executor-D4Y05hfn.js +0 -18
  164. package/dist/ui/assets/jsh-runtime-extensions-Bcb8_nba.js +0 -1
  165. package/dist/ui/assets/memory-v2-flag-BkWGkfSv.js +0 -1
  166. package/dist/ui/assets/panel-rpc-handlers-DpxMB-do.js +0 -2
  167. package/dist/ui/assets/provider-store-access-BCysAaQ-.js +0 -1
  168. package/dist/ui/assets/provider-store-access-D-QWySrs.js +0 -1
  169. package/dist/ui/assets/realm-inprocess-BdTkrnDI.js +0 -30
  170. package/dist/ui/assets/slicc-version-Cu6HjDRg.js +0 -1
  171. package/dist/ui/assets/tray-runtime-config-CRZxBChd.js +0 -1
  172. package/dist/ui/assets/welcome-detection-B6Zr7LKu.js +0 -1
@@ -1 +1 @@
1
- import{l as e}from"./main-Dxem3Ydy.js";async function t(){try{let e=await navigator.serviceWorker?.getRegistrations?.();e&&await Promise.all(e.map(e=>e.unregister().catch(()=>!1)))}catch{}try{let e=await indexedDB.databases();await Promise.all(e.filter(e=>!!e.name).map(e=>new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})))}catch{}try{let e=navigator.storage;if(typeof e?.getDirectory==`function`){let t=await e.getDirectory(),n=[];for await(let e of t.keys())n.push(e);await Promise.all(n.map(e=>t.removeEntry(e,{recursive:!0}).catch(()=>{})))}}catch{}}function n(n,r,i={}){if(n.dataset.recoveryBusy===`1`)return;let a=i.wipe??t,o=i.reload??(()=>location.reload()),s=r instanceof Error?r.message:String(r),c=i.verdict===`browser-wedged`,l=document.createElement(`div`);l.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let u=document.createElement(`h1`);u.style.color=`var(--s2-negative, #e34850)`,u.textContent=c?`Your browser needs a restart`:`Failed to start`;let d=document.createElement(`p`);d.style.color=`var(--s2-content-tertiary, #717171)`,d.textContent=s;let f=document.createElement(`div`);f.style.cssText=`display:flex;gap:0.75rem;justify-content:center;flex-wrap:wrap;margin-top:1.5rem;`;let p=document.createElement(`button`);p.type=`button`,p.textContent=`Reset local data & reload`,p.dataset.variant=c?`demoted`:`destructive`,p.style.cssText=c?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-negative, #e34850);background:var(--s2-negative, #e34850);color:#fff;border-radius:4px;`;let m=document.createElement(`button`);if(m.type=`button`,m.textContent=`Reload`,m.style.cssText=c?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-accent, #0265dc);background:var(--s2-accent, #0265dc);color:#fff;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`,p.addEventListener(`click`,()=>{p.disabled=!0,m.disabled=!0,p.textContent=`Resetting…`,n.dataset.recoveryBusy=`1`,(async()=>{try{await a()}catch{}for(let t of e)try{localStorage.removeItem(t)}catch{}o()})()}),m.addEventListener(`click`,()=>{o()}),c){let e=document.createElement(`p`);e.style.cssText=`max-width:34rem;margin:1rem auto 0;`,e.textContent=`This browser has stopped starting web workers — a browser process issue, not a problem with your data. Quit the browser completely, reopen it, and come back. Your local data is intact; resetting it will not fix this.`,l.append(u,d,e),f.append(m,p)}else l.append(u,d),f.append(p,m);for(l.append(f);n.firstChild;)n.removeChild(n.firstChild);n.appendChild(l)}export{n as renderBootRecoveryScreen};
1
+ import{l as e}from"./main-CfF8CFBr.js";async function t(){try{let e=await navigator.serviceWorker?.getRegistrations?.();e&&await Promise.all(e.map(e=>e.unregister().catch(()=>!1)))}catch{}try{let e=await indexedDB.databases();await Promise.all(e.filter(e=>!!e.name).map(e=>new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})))}catch{}try{let e=navigator.storage;if(typeof e?.getDirectory==`function`){let t=await e.getDirectory(),n=[];for await(let e of t.keys())n.push(e);await Promise.all(n.map(e=>t.removeEntry(e,{recursive:!0}).catch(()=>{})))}}catch{}}function n(n,r,i={}){if(n.dataset.recoveryBusy===`1`)return;let a=i.wipe??t,o=i.reload??(()=>location.reload()),s=r instanceof Error?r.message:String(r),c=i.verdict===`browser-wedged`,l=document.createElement(`div`);l.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let u=document.createElement(`h1`);u.style.color=`var(--s2-negative, #e34850)`,u.textContent=c?`Your browser needs a restart`:`Failed to start`;let d=document.createElement(`p`);d.style.color=`var(--s2-content-tertiary, #717171)`,d.textContent=s;let f=document.createElement(`div`);f.style.cssText=`display:flex;gap:0.75rem;justify-content:center;flex-wrap:wrap;margin-top:1.5rem;`;let p=document.createElement(`button`);p.type=`button`,p.textContent=`Reset local data & reload`,p.dataset.variant=c?`demoted`:`destructive`,p.style.cssText=c?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-negative, #e34850);background:var(--s2-negative, #e34850);color:#fff;border-radius:4px;`;let m=document.createElement(`button`);if(m.type=`button`,m.textContent=`Reload`,m.style.cssText=c?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-accent, #0265dc);background:var(--s2-accent, #0265dc);color:#fff;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`,p.addEventListener(`click`,()=>{p.disabled=!0,m.disabled=!0,p.textContent=`Resetting…`,n.dataset.recoveryBusy=`1`,(async()=>{try{await a()}catch{}for(let t of e)try{localStorage.removeItem(t)}catch{}o()})()}),m.addEventListener(`click`,()=>{o()}),c){let e=document.createElement(`p`);e.style.cssText=`max-width:34rem;margin:1rem auto 0;`,e.textContent=`This browser has stopped starting web workers — a browser process issue, not a problem with your data. Quit the browser completely, reopen it, and come back. Your local data is intact; resetting it will not fix this.`,l.append(u,d,e),f.append(m,p)}else l.append(u,d),f.append(p,m);for(l.append(f);n.firstChild;)n.removeChild(n.firstChild);n.appendChild(l)}export{n as renderBootRecoveryScreen};
@@ -0,0 +1 @@
1
+ var e=class{entries=new Map;listeners=new Set;usedId=null;pm;constructor(e=null){this.pm=e}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}list(){return[...this.entries.values()].map(e=>this.decorate(e)).sort((e,t)=>e.id.localeCompare(t.id))}get(e){return this.entries.get(e)?.backend??null}getEntry(e){let t=this.entries.get(e);return t?{backend:t.backend,descriptor:this.decorate(t)}:null}lastUsedId(){return this.usedId}use(e){let t=this.entries.get(e);return t?(this.usedId=e,this.decorate(t)):null}rememberShot(e,t,n){let r=this.entries.get(e);r&&(r.lastShot=t,n&&(r.lastFrame=n,r.seq=n.seq),this.emitChange())}nextSeq(e){let t=this.entries.get(e);return t?(t.seq+=1,t.seq):1}lastFrame(e){return this.entries.get(e)?.lastFrame??null}register(e,t={}){let n=e.describe(),r=n.id,i=this.entries.get(r);i&&this.dropEntry(r,i,{closeBackend:!0,exitOwned:!0});let a=t.pid??n.pid??null,o=!1;a==null&&this.pm&&(a=this.pm.spawn({kind:`computer`,argv:t.argv??[`computer`,r],cwd:t.cwd??`/`,owner:{kind:`system`}}).pid,o=!0);let s={backend:e,pid:a,ownsPid:o,lastShot:n.lastShot,lastFrame:null,seq:0,unsubAbort:null};if(a!=null&&this.pm){let e=this.pm.get(a);if(e){let t=()=>{this.closeFromSignal(r)};e.abort.signal.addEventListener(`abort`,t),s.unsubAbort=()=>e.abort.signal.removeEventListener(`abort`,t)}}return this.entries.set(r,s),this.emitChange(),this.decorate(s)}async unregister(e){let t=this.entries.get(e);return t?(await this.dropEntry(e,t,{closeBackend:!0,exitOwned:!0}),this.emitChange(),!0):!1}refresh(e){let t=this.entries.get(e);return t?(this.emitChange(),this.decorate(t)):null}async closeFromSignal(e){let t=this.entries.get(e);t&&(await this.dropEntry(e,t,{closeBackend:!0,exitOwned:!1}),this.emitChange())}async dropEntry(e,t,n){if(this.entries.delete(e),this.usedId===e&&(this.usedId=null),this.detach(t),n.exitOwned&&t.ownsPid&&t.pid!=null&&this.pm&&this.pm.exit(t.pid,0),n.closeBackend)try{await t.backend.close()}catch{}}detach(e){e.unsubAbort?.(),e.unsubAbort=null}decorate(e){let t=e.backend.describe();return{...t,pid:e.pid,lastShot:e.lastShot??t.lastShot}}emitChange(){let e=this.list();for(let t of[...this.listeners])try{t(e)}catch{}}resetForTests(){for(let[e,t]of[...this.entries])this.detach(t),t.backend.close().catch(()=>{}),t.ownsPid&&t.pid!=null&&this.pm&&this.pm.exit(t.pid,0),this.entries.delete(e);this.usedId=null,this.listeners.clear()}};let t=null;function n(n){return t||=new e(n),t}function r(){return t}function i(){if(!t)throw Error(`computer registry is not installed`);return t}function a(){t?.resetForTests(),t=null}export{e as ComputerRegistry,r as getComputerRegistry,n as installComputerRegistry,i as requireComputerRegistry,a as resetComputerRegistryForTests};
@@ -1 +1 @@
1
- import{c as e,n as t,t as n}from"./almost-bash-shell-headless-DdfO5taA.js";import{n as r}from"./browser-eoO4vY7w.js";import{c as i}from"./sudoers-BdBYQPUn.js";import{r as a}from"./sudo-fs-D620mZry.js";import{n as o}from"./jsh-discovery-D3Gk1cKA.js";import{o as s}from"./just-bash-compat-B-SPHuh_.js";import{n as c,r as l}from"./supervisor-DILjXQCB.js";function u(t,n){return new Map(Object.entries({HOME:e,PATH:o,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t.cwd,...n,...t.env}))}function d(e,t,n,i){let a=u(t,i);return r({fs:e,cwd:t.cwd,env:a,stdin:s(``),exec:(e,r)=>n.exec(e,{env:r?.env??Object.fromEntries(a),cwd:r?.cwd??t.cwd,args:r?.args,...r?.env===void 0?{}:{replaceEnv:!0}})})}const f={requestApproval:async()=>({decision:`deny`})};async function p(e){let r=h(e.fs,e.sudo),i=new t(r),a=new n({fs:r,cwd:`/workspace`,processManager:e.processManager,processOwner:{kind:`jshd`}}),o={exec:(e,t)=>a.getBash().exec(e,{env:t?.env??a.getEnv(),cwd:t?.cwd??`/workspace`,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})},s=c({fs:e.fs,processManager:e.processManager,lickManager:e.lickManager,...e.realmFactory?{realmFactory:e.realmFactory}:{},buildContext:e=>m(i,e,o)}),u=(await l(e.fs)).filter(e=>e.enabled);if(u.length===0)return[];let d=[];for(let e of u)try{await s.start(e),d.push(e.name)}catch{}return d}function m(e,t,n){return d(e,t,n)}function h(e,t){return a(e,{broker:t?.broker??f,getPolicy:t?.getPolicy??i,defaultDisposition:`allow`})}export{p as restoreEnabledJshdUnits};
1
+ import{c as e,n as t,t as n}from"./almost-bash-shell-headless-DqTtE9CM.js";import{n as r}from"./browser-eoO4vY7w.js";import{c as i}from"./sudoers-BdBYQPUn.js";import{r as a}from"./sudo-fs-D620mZry.js";import{n as o}from"./jsh-discovery-D3Gk1cKA.js";import{o as s}from"./just-bash-compat-B-SPHuh_.js";import{n as c,r as l}from"./supervisor-BtH2-9sE.js";function u(t,n){return new Map(Object.entries({HOME:e,PATH:o,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t.cwd,...n,...t.env}))}function d(e,t,n,i){let a=u(t,i);return r({fs:e,cwd:t.cwd,env:a,stdin:s(``),exec:(e,r)=>n.exec(e,{env:r?.env??Object.fromEntries(a),cwd:r?.cwd??t.cwd,args:r?.args,...r?.env===void 0?{}:{replaceEnv:!0}})})}const f={requestApproval:async()=>({decision:`deny`})};async function p(e){let r=h(e.fs,e.sudo),i=new t(r),a=new n({fs:r,cwd:`/workspace`,processManager:e.processManager,processOwner:{kind:`jshd`}}),o={exec:(e,t)=>a.getBash().exec(e,{env:t?.env??a.getEnv(),cwd:t?.cwd??`/workspace`,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})},s=c({fs:e.fs,processManager:e.processManager,lickManager:e.lickManager,...e.realmFactory?{realmFactory:e.realmFactory}:{},buildContext:e=>m(i,e,o)}),u=(await l(e.fs)).filter(e=>e.enabled);if(u.length===0)return[];let d=[];for(let e of u)try{await s.start(e),d.push(e.name)}catch{}return d}function m(e,t,n){return d(e,t,n)}function h(e,t){return a(e,{broker:t?.broker??f,getPolicy:t?.getPolicy??i,defaultDisposition:`allow`})}export{p as restoreEnabledJshdUnits};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./base64-DzRgusa4.js";import{m as t}from"./state-BdNtTsoR.js";import{t as n}from"./realm-browser-fetch-V3uggGbM.js";const r=new TextEncoder;function i(e){return typeof e==`object`&&!!e&&`exitCode`in e}async function a(e,t){try{return await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}catch{return{message:`curlwright: cannot read ${t}`,exitCode:26}}}function o(e){let t=new Uint8Array(e.length),n=0;for(let r of e)r!==10&&r!==13&&(t[n++]=r);return t.subarray(0,n)}async function s(e,t){let n=t.indexOf(`=`),o=t.indexOf(`@`),s=o!==-1&&(n===-1||o<n),c=s?o:n,l=c===-1?``:t.slice(0,c),u=c===-1?t:t.slice(c+1),d=u;if(s){let t=await a(e,u);if(i(t))return t;d=new TextDecoder().decode(t)}let f=encodeURIComponent(d);return r.encode(l===``?f:`${l}=${f}`)}async function c(e,t){if(t.kind===`urlencode`)return s(e,t.value);if(t.kind===`raw`||!t.value.startsWith(`@`))return r.encode(t.value);let n=await a(e,t.value.slice(1));return i(n)||t.kind===`binary`?n:o(n)}function l(e){let t=Math.max(0,e.length-1),n=e.reduce((e,t)=>e+t.length,0)+t,r=new Uint8Array(n),i=0;return e.forEach((e,t)=>{t>0&&(r[i++]=38),r.set(e,i),i+=e.length}),r}function u(e){let t=e.split(`;`);return{value:t[0],options:t.slice(1)}}function d(e,t){for(let n of e){let e=n.trim();if(e.startsWith(`${t}=`))return e.slice(t.length+1)}return null}function f(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?t:t.slice(n+1)}async function p(e,t,n){let r=n.value.indexOf(`=`);if(r===-1)return{message:`curlwright: -F requires name=content (got "${n.value}")`,exitCode:2};let o=n.value.slice(0,r),s=n.value.slice(r+1);if(n.literal||s[0]!==`@`&&s[0]!==`<`)return t.append(o,s),null;let{value:c,options:l}=u(s.slice(1)),p=await a(e,c);if(i(p))return p;if(s[0]===`<`)return t.append(o,new TextDecoder().decode(p)),null;let m=d(l,`type`)??`application/octet-stream`,h=d(l,`filename`)??f(c);return t.append(o,new Blob([p],{type:m}),h),null}async function m(e,t,n){if(t.length>0&&n.length>0)return{message:`curlwright: -F cannot be combined with -d`,exitCode:2};if(n.length>0){let t=new FormData;for(let r of n){let n=await p(e,t,r);if(n)return n}return{bytes:null,form:t,contentType:null,accept:null}}if(t.length===0)return{bytes:null,form:null,contentType:null,accept:null};let r=[];for(let n of t){let t=await c(e,n);if(i(t))return t;r.push(t)}let a=t.some(e=>e.kind===`json`);return{bytes:l(r),form:null,contentType:a?`application/json`:`application/x-www-form-urlencoded`,accept:a?`application/json`:null}}const h=new Set([`request`,`header`,`data`,`data-raw`,`data-binary`,`data-ascii`,`data-urlencode`,`json`,`form`,`form-string`,`output`,`dump-header`,`write-out`,`max-time`,`user`,`referer`,`range`,`url`,`tab`,`frame`]),g=new Set([`silent`,`show-error`,`include`,`head`,`verbose`,`fail`,`location`,`remote-name`,`get`,`no-credentials`,`help`]),_={X:`request`,H:`header`,d:`data`,F:`form`,o:`output`,D:`dump-header`,w:`write-out`,m:`max-time`,u:`user`,e:`referer`,r:`range`},v={s:`silent`,S:`show-error`,i:`include`,I:`head`,v:`verbose`,f:`fail`,L:`location`,O:`remote-name`,G:`get`,h:`help`},y={cert:`client certificates are the browser profile's to present, not the shell's`,"cert-type":`client certificates are the browser profile's to present, not the shell's`,key:`client certificates are the browser profile's to present, not the shell's`,cacert:`the browser decides which roots to trust`,capath:`the browser decides which roots to trust`,insecure:`the browser enforces TLS verification; a page cannot opt out`,proxy:`proxying is configured on the browser, not per request`,"proxy-user":`proxying is configured on the browser, not per request`,interface:`a page cannot choose an outgoing interface`,"unix-socket":`a page cannot dial a unix socket`,resolve:`a page cannot override DNS resolution`,compressed:`always on — the browser negotiates encoding itself`,cookie:"the tab's own cookies are already sent; set one with `playwright-cli cookie-set`","cookie-jar":"cookies live in the browser profile; read them with `playwright-cli cookies`","limit-rate":`a page cannot throttle a fetch`,"continue-at":"a page fetch cannot resume; use `-H 'Range: bytes=N-'`","connect-timeout":"a page fetch cannot time the connect phase alone; use `--max-time`","http1.1":`the browser negotiates the HTTP version`,http2:`the browser negotiates the HTTP version`,http3:`the browser negotiates the HTTP version`,"no-buffer":`responses are read whole, never streamed to stdout`,"trace-ascii":"no wire trace exists; use `playwright-cli network-requests`",trace:"no wire trace exists; use `playwright-cli network-requests`","user-agent":`User-Agent is a forbidden header name for fetch(); the tab sets it`},b={k:`insecure`,x:`proxy`,b:`cookie`,c:`cookie-jar`,E:`cert`,C:`continue-at`,N:`no-buffer`,A:`user-agent`};function ee(){return{url:null,requestMethod:null,headers:[],data:[],form:[],get:!1,output:null,remoteName:!1,include:!1,head:!1,dumpHeader:null,writeOut:null,silent:!1,showError:!1,verbose:!1,failOnError:!1,maxTimeSeconds:null,credentials:`include`,tab:null,frame:null,user:null,referer:null,range:null,help:!1}}function x(e,t){return{message:`curlwright: option ${e} is not supported in a page context — ${y[t]}`,exitCode:2}}function S(e){return{message:`curlwright: unknown option ${e}\nRun 'curlwright --help' for the supported flags.`,exitCode:2}}function C(e){let t=e.indexOf(`:`);if(t===-1)return e.endsWith(`;`)?{name:e.slice(0,-1).trim(),value:``,unset:!1}:{name:e.trim(),value:``,unset:!1};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return{name:n,value:r,unset:r===``}}function w(e,t,n,r){switch(t){case`request`:return e.requestMethod=n,null;case`header`:return e.headers.push(C(n??``)),null;case`data`:case`data-ascii`:return e.data.push({kind:`ascii`,value:n??``}),null;case`data-raw`:return e.data.push({kind:`raw`,value:n??``}),null;case`data-binary`:return e.data.push({kind:`binary`,value:n??``}),null;case`data-urlencode`:return e.data.push({kind:`urlencode`,value:n??``}),null;case`json`:return e.data.push({kind:`json`,value:n??``}),null;case`form`:return e.form.push({value:n??``,literal:!1}),null;case`form-string`:return e.form.push({value:n??``,literal:!0}),null;case`output`:return e.output=n,null;case`dump-header`:return e.dumpHeader=n,null;case`write-out`:return e.writeOut=n,null;case`max-time`:return T(e,n,r);case`user`:return e.user=n,null;case`referer`:return e.referer=n,null;case`range`:return e.range=n,null;case`url`:return e.url=n,null;case`tab`:return e.tab=n,null;case`frame`:return e.frame=n,null;default:return E(e,t,r)}}function T(e,t,n){let r=Number(t);return!Number.isFinite(r)||r<=0?{message:`curlwright: ${n} expects a positive number of seconds`,exitCode:2}:(e.maxTimeSeconds=r,null)}function E(e,t,n){switch(t){case`silent`:return e.silent=!0,null;case`show-error`:return e.showError=!0,null;case`include`:return e.include=!0,null;case`head`:return e.head=!0,null;case`verbose`:return e.verbose=!0,null;case`fail`:return e.failOnError=!0,null;case`location`:return null;case`remote-name`:return e.remoteName=!0,null;case`get`:return e.get=!0,null;case`no-credentials`:return e.credentials=`omit`,null;case`help`:return e.help=!0,null;default:return S(n)}}function te(e,t,n){let r=t[n],i=r.indexOf(`=`),a=(i===-1?r.slice(2):r.slice(2,i)).trim(),o=i===-1?null:r.slice(i+1);if(a in y)return x(`--${a}`,a);if(h.has(a)){let r=o??t[n+1];return r===void 0?{message:`curlwright: option --${a} requires a value`,exitCode:2}:w(e,a,r,`--${a}`)??{next:o===null?n+2:n+1}}return g.has(a)?w(e,a,null,`--${a}`)??{next:n+1}:S(`--${a}`)}function ne(e,t,n){let r=t[n];for(let i=1;i<r.length;i++){let a=r[i];if(a in b)return x(`-${a}`,b[a]);if(a in _){let o=r.slice(i+1),s=o===``?t[n+1]:o;return s===void 0?{message:`curlwright: option -${a} requires a value`,exitCode:2}:w(e,_[a],s,`-${a}`)??{next:o===``?n+2:n+1}}if(!(a in v))return S(`-${a}`);let o=w(e,v[a],null,`-${a}`);if(o)return o}return{next:n+1}}function re(e,t){return e.url!==null&&e.url!==t?{message:`curlwright: only one URL is supported (got "${e.url}" and "${t}")`,exitCode:2}:(e.url=t,null)}function ie(e){let t=ee(),n=0,r=!1;for(;n<e.length;){let i=e[n];if(!r&&i===`--`){r=!0,n++;continue}if(!r&&i.startsWith(`--`)){let r=te(t,e,n);if(`message`in r)return r;n=r.next;continue}if(!r&&i.startsWith(`-`)&&i.length>1){let r=ne(t,e,n);if(`message`in r)return r;n=r.next;continue}let a=re(t,i);if(a)return a;n++}return t}function ae(e){return`message`in e}const D={"accept-charset":`the browser sets it`,"accept-encoding":`the browser negotiates encoding`,connection:`the browser owns the connection`,"content-length":`derived from the body`,cookie:"the tab's cookies are sent already; set one with `playwright-cli cookie-set`",cookie2:`the tab's cookies are sent already`,date:`the browser sets it`,dnt:`the browser sets it`,expect:`a page fetch cannot send it`,host:`derived from the URL`,"keep-alive":`the browser owns the connection`,origin:`the tab's own origin is sent automatically`,referer:`use -e/--referer, which sets the fetch referrer`,te:`the browser owns transfer encoding`,trailer:`the browser owns transfer encoding`,"transfer-encoding":`the browser owns transfer encoding`,upgrade:`the browser owns the connection`,via:`the browser sets it`};function oe(e){let t=e.toLowerCase();return t in D?D[t]:t.startsWith(`proxy-`)?`proxying is configured on the browser`:t.startsWith(`sec-`)?`Sec- headers are reserved for the browser`:null}function se(e){for(let t of e){let e=oe(t.name);if(e)return{message:`curlwright: header "${t.name}" cannot be set from a page — ${e}`,exitCode:2}}return null}function O(e,t){let n=t.toLowerCase();return Object.keys(e).some(e=>e.toLowerCase()===n)}function k(e){let t={},n=new Set;for(let r of e.headers)if(r.name!==``){if(r.unset){n.add(r.name.toLowerCase());continue}t[r.name]=r.value}return{headers:t,suppressed:n}}function A(e,t,n){return!O(e,n)&&!t.has(n)}function j(e){return/^[a-zA-Z]+=/.test(e)?e:`bytes=${e}`}function M(e,t,n,r){n.user!==null&&A(e,t,`authorization`)&&(e.Authorization=`Basic ${btoa(n.user)}`),n.range!==null&&A(e,t,`range`)&&(e.Range=j(n.range)),r.contentType&&A(e,t,`content-type`)&&(e[`Content-Type`]=r.contentType),r.accept&&A(e,t,`accept`)&&(e.Accept=r.accept)}function N(e,t){if(t===``)return e;let[n,r]=P(e);return`${n}${n.includes(`?`)?`&`:`?`}${t}${r}`}function P(e){let t=e.indexOf(`#`);return t===-1?[e,``]:[e.slice(0,t),e.slice(t)]}function F(e,t){return e.requestMethod?e.requestMethod:e.head?`HEAD`:t?`POST`:`GET`}function I(e,t,n){let r=e.toUpperCase();return!t||r!==`GET`&&r!==`HEAD`?null:{message:`curlwright: ${n.requestMethod?`-X ${n.requestMethod}`:`-I`} cannot carry a request body — a page fetch rejects a ${r} with one. Drop the data, or use -G to send it as a query string.`,exitCode:2}}function L(e,t){if(e.url===null)return{message:`curlwright: no URL specified`,exitCode:2};let{headers:n,suppressed:r}=k(e),i=e.get&&t.bytes!==null,a=i?{...t,bytes:null,contentType:null}:t;M(n,r,e,a);let o=i?N(e.url,new TextDecoder().decode(t.bytes??new Uint8Array)):e.url,s=a.bytes!==null||a.form!==null,c=F(e,s),l=I(c,s,e);if(l)return l;let u={method:c,headers:n,credentials:e.credentials,responseType:`binary`};return a.form?u.body=a.form:a.bytes&&(u.body=a.bytes),e.referer!==null&&(u.referrer=e.referer),e.maxTimeSeconds!==null&&(u.timeoutMs=e.maxTimeSeconds*1e3),{url:o,method:c,fetchOptions:u,uploadSize:a.bytes?.length??0}}function R(e){let t=e.fetchOptions.headers??{},n=[`> ${e.method} ${e.url}`];for(let[e,r]of Object.entries(t))n.push(`> ${e}: ${r}`);return n.push(`> `),`${n.join(`
1
+ import{t as e}from"./base64-DzRgusa4.js";import{m as t}from"./state-z3wOHLww.js";import{t as n}from"./realm-browser-fetch-V3uggGbM.js";const r=new TextEncoder;function i(e){return typeof e==`object`&&!!e&&`exitCode`in e}async function a(e,t){try{return await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}catch{return{message:`curlwright: cannot read ${t}`,exitCode:26}}}function o(e){let t=new Uint8Array(e.length),n=0;for(let r of e)r!==10&&r!==13&&(t[n++]=r);return t.subarray(0,n)}async function s(e,t){let n=t.indexOf(`=`),o=t.indexOf(`@`),s=o!==-1&&(n===-1||o<n),c=s?o:n,l=c===-1?``:t.slice(0,c),u=c===-1?t:t.slice(c+1),d=u;if(s){let t=await a(e,u);if(i(t))return t;d=new TextDecoder().decode(t)}let f=encodeURIComponent(d);return r.encode(l===``?f:`${l}=${f}`)}async function c(e,t){if(t.kind===`urlencode`)return s(e,t.value);if(t.kind===`raw`||!t.value.startsWith(`@`))return r.encode(t.value);let n=await a(e,t.value.slice(1));return i(n)||t.kind===`binary`?n:o(n)}function l(e){let t=Math.max(0,e.length-1),n=e.reduce((e,t)=>e+t.length,0)+t,r=new Uint8Array(n),i=0;return e.forEach((e,t)=>{t>0&&(r[i++]=38),r.set(e,i),i+=e.length}),r}function u(e){let t=e.split(`;`);return{value:t[0],options:t.slice(1)}}function d(e,t){for(let n of e){let e=n.trim();if(e.startsWith(`${t}=`))return e.slice(t.length+1)}return null}function f(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?t:t.slice(n+1)}async function p(e,t,n){let r=n.value.indexOf(`=`);if(r===-1)return{message:`curlwright: -F requires name=content (got "${n.value}")`,exitCode:2};let o=n.value.slice(0,r),s=n.value.slice(r+1);if(n.literal||s[0]!==`@`&&s[0]!==`<`)return t.append(o,s),null;let{value:c,options:l}=u(s.slice(1)),p=await a(e,c);if(i(p))return p;if(s[0]===`<`)return t.append(o,new TextDecoder().decode(p)),null;let m=d(l,`type`)??`application/octet-stream`,h=d(l,`filename`)??f(c);return t.append(o,new Blob([p],{type:m}),h),null}async function m(e,t,n){if(t.length>0&&n.length>0)return{message:`curlwright: -F cannot be combined with -d`,exitCode:2};if(n.length>0){let t=new FormData;for(let r of n){let n=await p(e,t,r);if(n)return n}return{bytes:null,form:t,contentType:null,accept:null}}if(t.length===0)return{bytes:null,form:null,contentType:null,accept:null};let r=[];for(let n of t){let t=await c(e,n);if(i(t))return t;r.push(t)}let a=t.some(e=>e.kind===`json`);return{bytes:l(r),form:null,contentType:a?`application/json`:`application/x-www-form-urlencoded`,accept:a?`application/json`:null}}const h=new Set([`request`,`header`,`data`,`data-raw`,`data-binary`,`data-ascii`,`data-urlencode`,`json`,`form`,`form-string`,`output`,`dump-header`,`write-out`,`max-time`,`user`,`referer`,`range`,`url`,`tab`,`frame`]),g=new Set([`silent`,`show-error`,`include`,`head`,`verbose`,`fail`,`location`,`remote-name`,`get`,`no-credentials`,`help`]),_={X:`request`,H:`header`,d:`data`,F:`form`,o:`output`,D:`dump-header`,w:`write-out`,m:`max-time`,u:`user`,e:`referer`,r:`range`},v={s:`silent`,S:`show-error`,i:`include`,I:`head`,v:`verbose`,f:`fail`,L:`location`,O:`remote-name`,G:`get`,h:`help`},y={cert:`client certificates are the browser profile's to present, not the shell's`,"cert-type":`client certificates are the browser profile's to present, not the shell's`,key:`client certificates are the browser profile's to present, not the shell's`,cacert:`the browser decides which roots to trust`,capath:`the browser decides which roots to trust`,insecure:`the browser enforces TLS verification; a page cannot opt out`,proxy:`proxying is configured on the browser, not per request`,"proxy-user":`proxying is configured on the browser, not per request`,interface:`a page cannot choose an outgoing interface`,"unix-socket":`a page cannot dial a unix socket`,resolve:`a page cannot override DNS resolution`,compressed:`always on — the browser negotiates encoding itself`,cookie:"the tab's own cookies are already sent; set one with `playwright-cli cookie-set`","cookie-jar":"cookies live in the browser profile; read them with `playwright-cli cookies`","limit-rate":`a page cannot throttle a fetch`,"continue-at":"a page fetch cannot resume; use `-H 'Range: bytes=N-'`","connect-timeout":"a page fetch cannot time the connect phase alone; use `--max-time`","http1.1":`the browser negotiates the HTTP version`,http2:`the browser negotiates the HTTP version`,http3:`the browser negotiates the HTTP version`,"no-buffer":`responses are read whole, never streamed to stdout`,"trace-ascii":"no wire trace exists; use `playwright-cli network-requests`",trace:"no wire trace exists; use `playwright-cli network-requests`","user-agent":`User-Agent is a forbidden header name for fetch(); the tab sets it`},b={k:`insecure`,x:`proxy`,b:`cookie`,c:`cookie-jar`,E:`cert`,C:`continue-at`,N:`no-buffer`,A:`user-agent`};function ee(){return{url:null,requestMethod:null,headers:[],data:[],form:[],get:!1,output:null,remoteName:!1,include:!1,head:!1,dumpHeader:null,writeOut:null,silent:!1,showError:!1,verbose:!1,failOnError:!1,maxTimeSeconds:null,credentials:`include`,tab:null,frame:null,user:null,referer:null,range:null,help:!1}}function x(e,t){return{message:`curlwright: option ${e} is not supported in a page context — ${y[t]}`,exitCode:2}}function S(e){return{message:`curlwright: unknown option ${e}\nRun 'curlwright --help' for the supported flags.`,exitCode:2}}function C(e){let t=e.indexOf(`:`);if(t===-1)return e.endsWith(`;`)?{name:e.slice(0,-1).trim(),value:``,unset:!1}:{name:e.trim(),value:``,unset:!1};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return{name:n,value:r,unset:r===``}}function w(e,t,n,r){switch(t){case`request`:return e.requestMethod=n,null;case`header`:return e.headers.push(C(n??``)),null;case`data`:case`data-ascii`:return e.data.push({kind:`ascii`,value:n??``}),null;case`data-raw`:return e.data.push({kind:`raw`,value:n??``}),null;case`data-binary`:return e.data.push({kind:`binary`,value:n??``}),null;case`data-urlencode`:return e.data.push({kind:`urlencode`,value:n??``}),null;case`json`:return e.data.push({kind:`json`,value:n??``}),null;case`form`:return e.form.push({value:n??``,literal:!1}),null;case`form-string`:return e.form.push({value:n??``,literal:!0}),null;case`output`:return e.output=n,null;case`dump-header`:return e.dumpHeader=n,null;case`write-out`:return e.writeOut=n,null;case`max-time`:return T(e,n,r);case`user`:return e.user=n,null;case`referer`:return e.referer=n,null;case`range`:return e.range=n,null;case`url`:return e.url=n,null;case`tab`:return e.tab=n,null;case`frame`:return e.frame=n,null;default:return E(e,t,r)}}function T(e,t,n){let r=Number(t);return!Number.isFinite(r)||r<=0?{message:`curlwright: ${n} expects a positive number of seconds`,exitCode:2}:(e.maxTimeSeconds=r,null)}function E(e,t,n){switch(t){case`silent`:return e.silent=!0,null;case`show-error`:return e.showError=!0,null;case`include`:return e.include=!0,null;case`head`:return e.head=!0,null;case`verbose`:return e.verbose=!0,null;case`fail`:return e.failOnError=!0,null;case`location`:return null;case`remote-name`:return e.remoteName=!0,null;case`get`:return e.get=!0,null;case`no-credentials`:return e.credentials=`omit`,null;case`help`:return e.help=!0,null;default:return S(n)}}function te(e,t,n){let r=t[n],i=r.indexOf(`=`),a=(i===-1?r.slice(2):r.slice(2,i)).trim(),o=i===-1?null:r.slice(i+1);if(a in y)return x(`--${a}`,a);if(h.has(a)){let r=o??t[n+1];return r===void 0?{message:`curlwright: option --${a} requires a value`,exitCode:2}:w(e,a,r,`--${a}`)??{next:o===null?n+2:n+1}}return g.has(a)?w(e,a,null,`--${a}`)??{next:n+1}:S(`--${a}`)}function ne(e,t,n){let r=t[n];for(let i=1;i<r.length;i++){let a=r[i];if(a in b)return x(`-${a}`,b[a]);if(a in _){let o=r.slice(i+1),s=o===``?t[n+1]:o;return s===void 0?{message:`curlwright: option -${a} requires a value`,exitCode:2}:w(e,_[a],s,`-${a}`)??{next:o===``?n+2:n+1}}if(!(a in v))return S(`-${a}`);let o=w(e,v[a],null,`-${a}`);if(o)return o}return{next:n+1}}function re(e,t){return e.url!==null&&e.url!==t?{message:`curlwright: only one URL is supported (got "${e.url}" and "${t}")`,exitCode:2}:(e.url=t,null)}function ie(e){let t=ee(),n=0,r=!1;for(;n<e.length;){let i=e[n];if(!r&&i===`--`){r=!0,n++;continue}if(!r&&i.startsWith(`--`)){let r=te(t,e,n);if(`message`in r)return r;n=r.next;continue}if(!r&&i.startsWith(`-`)&&i.length>1){let r=ne(t,e,n);if(`message`in r)return r;n=r.next;continue}let a=re(t,i);if(a)return a;n++}return t}function ae(e){return`message`in e}const D={"accept-charset":`the browser sets it`,"accept-encoding":`the browser negotiates encoding`,connection:`the browser owns the connection`,"content-length":`derived from the body`,cookie:"the tab's cookies are sent already; set one with `playwright-cli cookie-set`",cookie2:`the tab's cookies are sent already`,date:`the browser sets it`,dnt:`the browser sets it`,expect:`a page fetch cannot send it`,host:`derived from the URL`,"keep-alive":`the browser owns the connection`,origin:`the tab's own origin is sent automatically`,referer:`use -e/--referer, which sets the fetch referrer`,te:`the browser owns transfer encoding`,trailer:`the browser owns transfer encoding`,"transfer-encoding":`the browser owns transfer encoding`,upgrade:`the browser owns the connection`,via:`the browser sets it`};function oe(e){let t=e.toLowerCase();return t in D?D[t]:t.startsWith(`proxy-`)?`proxying is configured on the browser`:t.startsWith(`sec-`)?`Sec- headers are reserved for the browser`:null}function se(e){for(let t of e){let e=oe(t.name);if(e)return{message:`curlwright: header "${t.name}" cannot be set from a page — ${e}`,exitCode:2}}return null}function O(e,t){let n=t.toLowerCase();return Object.keys(e).some(e=>e.toLowerCase()===n)}function k(e){let t={},n=new Set;for(let r of e.headers)if(r.name!==``){if(r.unset){n.add(r.name.toLowerCase());continue}t[r.name]=r.value}return{headers:t,suppressed:n}}function A(e,t,n){return!O(e,n)&&!t.has(n)}function j(e){return/^[a-zA-Z]+=/.test(e)?e:`bytes=${e}`}function M(e,t,n,r){n.user!==null&&A(e,t,`authorization`)&&(e.Authorization=`Basic ${btoa(n.user)}`),n.range!==null&&A(e,t,`range`)&&(e.Range=j(n.range)),r.contentType&&A(e,t,`content-type`)&&(e[`Content-Type`]=r.contentType),r.accept&&A(e,t,`accept`)&&(e.Accept=r.accept)}function N(e,t){if(t===``)return e;let[n,r]=P(e);return`${n}${n.includes(`?`)?`&`:`?`}${t}${r}`}function P(e){let t=e.indexOf(`#`);return t===-1?[e,``]:[e.slice(0,t),e.slice(t)]}function F(e,t){return e.requestMethod?e.requestMethod:e.head?`HEAD`:t?`POST`:`GET`}function I(e,t,n){let r=e.toUpperCase();return!t||r!==`GET`&&r!==`HEAD`?null:{message:`curlwright: ${n.requestMethod?`-X ${n.requestMethod}`:`-I`} cannot carry a request body — a page fetch rejects a ${r} with one. Drop the data, or use -G to send it as a query string.`,exitCode:2}}function L(e,t){if(e.url===null)return{message:`curlwright: no URL specified`,exitCode:2};let{headers:n,suppressed:r}=k(e),i=e.get&&t.bytes!==null,a=i?{...t,bytes:null,contentType:null}:t;M(n,r,e,a);let o=i?N(e.url,new TextDecoder().decode(t.bytes??new Uint8Array)):e.url,s=a.bytes!==null||a.form!==null,c=F(e,s),l=I(c,s,e);if(l)return l;let u={method:c,headers:n,credentials:e.credentials,responseType:`binary`};return a.form?u.body=a.form:a.bytes&&(u.body=a.bytes),e.referer!==null&&(u.referrer=e.referer),e.maxTimeSeconds!==null&&(u.timeoutMs=e.maxTimeSeconds*1e3),{url:o,method:c,fetchOptions:u,uploadSize:a.bytes?.length??0}}function R(e){let t=e.fetchOptions.headers??{},n=[`> ${e.method} ${e.url}`];for(let[e,r]of Object.entries(t))n.push(`> ${e}: ${r}`);return n.push(`> `),`${n.join(`
2
2
  `)}\n`}function z(e,t){let n=[`< ${e}`];for(let[e,r]of Object.entries(t))n.push(`< ${e}: ${r}`);return n.push(`< `),`${n.join(`
3
3
  `)}\n`}function B(t,n){return typeof t==`string`?n===`base64`?e(t):new TextEncoder().encode(t):new Uint8Array}function V(e,t){return t?`HTTP/1.1 ${e} ${t}`:`HTTP/1.1 ${e}`}function H(e,t,n){let r=[V(e,t)];for(let[e,t]of Object.entries(n))r.push(`${e}: ${t}`);return`${r.join(`\r
4
4
  `)}\r\n\r\n`}function U(e){if(e.includes(0))return!0;try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e),!1}catch{return!0}}function W(e){let t;try{t=new URL(e).pathname}catch{t=e.split(`?`)[0]}return t.replace(/\/+$/,``).split(`/`).pop()||null}function G(e,t,n){return new TextEncoder().encode(H(e,t,n)).length}function K(e){try{return new URL(e).origin}catch{return null}}function q(e){return e.map(e=>` --tab=${e.targetId} ${e.url}`).join(`
@@ -0,0 +1,52 @@
1
+ import{n as e}from"./panel-rpc-BPwAqRch.js";import{r as t}from"./base64-DzRgusa4.js";import"./bridge-protocol-31SWTdS5.js";import{r as n,t as r}from"./subcommand-help-CgO7wRS5.js";import{d as i,i as a,l as o,n as s,o as c,r as l,s as u,u as d}from"./keys-n5_C9sHW.js";import{getComputerRegistry as f,installComputerRegistry as p}from"./registry-Bq_j-EXx.js";import{getComputersHost as m}from"./host-BQ2qKD-D.js";const ee=[`bridgeToken`,`bridge`,`tray`],te=[`cherry`,`connect`],ne=[`/join/`,`/tray/`],re=[``,`/`,`/cloud`,`/connect`];function ie(e){let t=e.replace(/\/index\.html$/,`/`);return t.length>1?t.replace(/\/$/,``):t}function h(e,t={}){let n;try{n=new URL(e)}catch{return!1}for(let e of ee)if(n.searchParams.has(e))return!0;for(let e of te)if(n.searchParams.get(e)===`1`)return!0;if(!new Set([`https://www.sliccy.ai`,`https://slicc-tray-hub-staging.minivelos.workers.dev`,...t.selfOrigins??[]]).has(n.origin))return!1;let r=ie(n.pathname);return re.includes(r)?!0:ne.some(e=>`${r}/`.startsWith(e))}function g(e={x:0,y:0}){return{x:e.x,y:e.y}}function ae(e,t){return t.x!==void 0&&t.y!==void 0&&(e.x=t.x,e.y=t.y),e}function _(e,t){return t.x!==void 0&&t.y!==void 0?(e.x=t.x,e.y=t.y,{x:t.x,y:t.y}):{x:e.x,y:e.y}}function oe(e,t){return t.map(t=>{if(t.type===`mousemove`||t.type===`click`||t.type===`button`||t.type===`scroll`){let n=_(e,t);return{...t,x:n.x,y:n.y}}return t.type===`drag`&&ae(e,{x:t.x2,y:t.y2}),t})}function v(e){return`tab:${e}`}const y={screenshot:!0,text:!1,frames:`poll`,keyboard:!0,mouse:`absolute`,scroll:!0,exec:!1,inputAllowed:!0},b={1:`left`,2:`middle`,3:`right`};function x(e){if(h(e.url))throw Error(`refusing SLICC app tab '${e.title??e.url}'`)}var S=class{browser;targetId;seq=0;title;url;size=null;pointer=g();constructor(e,t,n={title:t,url:``}){this.browser=e,this.targetId=t,this.title=n.title,this.url=n.url}describe(){return{id:v(this.targetId),kind:`tab`,title:this.title,size:this.size,state:`live`,capabilities:y,pid:null}}async screenshot(e){return await this.refreshInfo(),x({url:this.url,title:this.title}),this.browser.withTab(this.targetId,async t=>{let n=await C(t,e);return n.native&&(this.size=n.native),this.seq+=1,{seq:this.seq,mime:n.mime,width:n.width,height:n.height,bytes:n.bytes}})}async input(e){await this.refreshInfo(),x({url:this.url,title:this.title}),await this.browser.withTab(this.targetId,async t=>{for(let n of e)await T(t,n,this.pointer)})}async close(){}async refreshInfo(){let e=await fe(this.browser,this.targetId);e&&(this.title=e.title||this.title,this.url=e.url||this.url)}};async function C(e,t){let n=await e.screenshot({format:`png`}),r=u(n),a=i(r)??o(r),s=r;t.maxWidth&&a&&a.width>t.maxWidth?s=u(await e.screenshot({format:`png`,maxWidth:t.maxWidth})):t.format!==`png`&&(s=u(await e.screenshot({format:`jpeg`,quality:70})));let c=i(s)??o(s)??a??{width:0,height:0};return t.format!==`png`&&!o(s)&&(s=await d(s)),{mime:o(s)?`image/jpeg`:`image/png`,bytes:s,width:c.width,height:c.height,native:a}}var w=class{rpc;targetId;seq=0;title;url;size=null;pointer=g();constructor(e,t,n={title:t,url:``}){this.rpc=e,this.targetId=t,this.title=n.title,this.url=n.url}describe(){return{id:v(this.targetId),kind:`tab`,title:this.title,size:this.size,state:`live`,capabilities:y,pid:null}}async screenshot(e){let t=await this.rpc.call(`computer-tab-screenshot`,{targetId:this.targetId,maxWidth:e.maxWidth,format:e.format});return this.title=t.title,this.url=t.url,this.size=t.nativeWidth&&t.nativeHeight?{width:t.nativeWidth,height:t.nativeHeight}:{width:t.width,height:t.height},this.seq+=1,{seq:this.seq,mime:t.mime,width:t.width,height:t.height,bytes:u(t.base64)}}async input(e){let t=oe(this.pointer,e);await this.rpc.call(`computer-tab-input`,{targetId:this.targetId,events:t})}async close(){}};async function T(e,t,n=g()){switch(t.type){case`mousemove`:{let r=_(n,t);await e.send(`Input.dispatchMouseEvent`,{type:`mouseMoved`,x:r.x,y:r.y});return}case`button`:await se(e,t,n);return;case`click`:await ce(e,t,n);return;case`drag`:await le(e,t,n);return;case`scroll`:{let r=_(n,t);await e.send(`Input.dispatchMouseEvent`,{type:`mouseWheel`,x:r.x,y:r.y,deltaX:t.dx,deltaY:t.dy});return}case`key`:await ue(e,t);return;case`text`:await e.send(`Input.insertText`,{text:t.text});return;case`wait`:await E(Math.max(0,t.ms));return}}async function se(e,t,n){let r=_(n,t);await e.send(`Input.dispatchMouseEvent`,{type:t.down?`mousePressed`:`mouseReleased`,x:r.x,y:r.y,button:b[t.button],clickCount:1})}async function ce(e,t,n){let r=_(n,t),i=Math.max(1,t.count);for(let n=1;n<=i;n++)await e.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:r.x,y:r.y,button:b[t.button],clickCount:n}),t.holdMs&&t.holdMs>0&&await E(t.holdMs),await e.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r.x,y:r.y,button:b[t.button],clickCount:n})}async function le(e,t,n){await T(e,{type:`mousemove`,x:t.x1,y:t.y1},n),await T(e,{type:`button`,button:1,down:!0,x:t.x1,y:t.y1},n),await T(e,{type:`mousemove`,x:t.x2,y:t.y2},n),await T(e,{type:`button`,button:1,down:!1,x:t.x2,y:t.y2},n)}async function ue(e,t){let n=s(t.keysym);if(!n)throw Error(`unknown keysym '${t.keysym}'`);for(let r of l(n,t.down))await e.send(`Input.dispatchKeyEvent`,{type:r.type,key:r.key,code:r.code,modifiers:r.modifiers,...r.text===void 0?{}:{text:r.text}})}function de(e,t){let n=e.find(e=>e.targetId===t);if(n)return n;let r=e.filter(e=>e.url===t||e.url.startsWith(t));if(r.length===1)return r[0];if(r.length>1)return{error:`ambiguous url '${t}' matches ${r.length} tabs`};let i=e.filter(e=>e.title===t);return i.length===1?i[0]:{error:`no tab matching '${t}'`}}async function fe(e,t){let n=(await e.listAllTargets()).find(e=>e.targetId===t);return n?{title:n.title,url:n.url}:null}function E(e){return new Promise(t=>setTimeout(t,e))}function pe(e,t){for(let n of t){let t=me(e,n);if(t)return t}return null}function me(e,t){return t.type===`wait`?null:e.inputAllowed?t.type===`key`||t.type===`text`?e.keyboard?null:`keyboard input is not supported`:t.type===`scroll`?e.scroll?null:`scroll is not supported`:(t.type===`mousemove`||t.type===`button`||t.type===`click`||t.type===`drag`)&&e.mouse===`none`?`mouse input is not supported`:null:`input is not allowed`}const D={low:256,medium:768,high:1536};function O(e){if(!e)return D.medium;if(e in D)return D[e];let t=/^(\d+)(?:x\d+)?$/u.exec(e);if(t){let e=Number.parseInt(t[1],10);if(e>0)return e}return D.medium}function k(e,t){let n=e.width>0?e.width:t.width,r=e.height>0?e.height:t.height,i=t.width,a=t.height,o=n>0?i/n:1;return{nativeWidth:n,nativeHeight:r,shotWidth:i,shotHeight:a,scale:o>0?o:1}}function he(e){let t=e.scale===1?`1`:e.scale.toFixed(2).replace(/0+$/u,``).replace(/\.$/u,``);return`${e.nativeWidth}x${e.nativeHeight} → ${e.shotWidth}x${e.shotHeight} (scale ${t})`}function A(e,t){return{width:e.shotWidth,height:e.shotHeight,scale:e.scale,at:t}}function ge(e,t,n,r){return r||!n||n.scale===0?{x:e,y:t}:{x:Math.round(e/n.scale),y:Math.round(t/n.scale)}}const j=`computer — look at and poke a screen (xdotool grammar)
2
+
3
+ Usage:
4
+ computer [-c <id>] [--json] [--native] <verb> [args] [verb ...]
5
+
6
+ Target: -c / --computer, else $COMPUTER, else last \`computer use\`, else
7
+ the only registered computer. \`computer ls\` lists ids.
8
+
9
+ Lifecycle:
10
+ ls list registered computers
11
+ add tab <targetId|url> [-n name]
12
+ register a browser tab (refuses SLICC app tabs)
13
+ rm [id] unregister (does not stop a v86 guest)
14
+ use <id> set the default computer
15
+ info descriptor for the current target
16
+
17
+ Look:
18
+ screenshot [--size low|medium|high|<N>] [--view] [file]
19
+ JPEG; prints WxH → wxh (scale s) and a frozen frame
20
+ text text-mode dump when the backend supports it
21
+ watch [--fps N] [--stop] live frames to the page (phase 2 UI)
22
+
23
+ Poke (xdotool; every verb ends with a frozen-frame line):
24
+ mousemove <x> <y> [--relative]
25
+ click [1|2|3] [--at x,y] [--hold MS] [--repeat N]
26
+ mousedown [1|2|3] [--at x,y]
27
+ mouseup [1|2|3] [--at x,y]
28
+ drag <x1> <y1> <x2> <y2>
29
+ scroll <dx> <dy> [--at x,y]
30
+ key <keysym> [keysym...] ctrl+alt+Delete, Return, F5, super+space
31
+ keydown <keysym>
32
+ keyup <keysym>
33
+ type <text...>
34
+ wait <ms>
35
+ exec <command...> when the backend supports it
36
+
37
+ Anthropic aliases (same verbs):
38
+ left_click right_click middle_click double_click triple_click
39
+ left_click_drag mouse_move scroll key type screenshot wait
40
+
41
+ Coordinates are screenshot-space of the last shot unless --native.
42
+ Buttons: 1 left, 2 middle, 3 right. Chain verbs: computer click 1 type hello
43
+
44
+ v86 guests register as v86:<name> on \`v86 start\`. Prefer this command;
45
+ \`v86 type|key|mouse|screenshot|text\` remain as thin aliases.
46
+ `,_e=[`-c`,`--computer`,`--size`,`--at`,`--hold`,`--repeat`,`--fps`,`-n`,`--name`],M=new Set([`ls`,`add`,`rm`,`use`,`info`,`screenshot`,`text`,`watch`,`mousemove`,`click`,`mousedown`,`mouseup`,`drag`,`scroll`,`key`,`keydown`,`keyup`,`type`,`wait`,`exec`]),N={left_click:`click`,right_click:`click`,middle_click:`click`,double_click:`click`,triple_click:`click`,left_click_drag:`drag`,mouse_move:`mousemove`,screenshot:`screenshot`,wait:`wait`,key:`key`,type:`type`,scroll:`scroll`},P=new Set([`type`,`key`,`exec`,`add`]),F=new Set([`--size`,`--at`,`--hold`,`--repeat`,`--fps`,`-n`,`--name`,`-c`,`--computer`]);function I(e){return M.has(e)||e in N}function ve(e){return M.has(e)?e:N[e]??null}function ye(e){let t=[],n,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`--`){t.push(...e.slice(a));break}if(o===`--json`){r=!0;continue}if(o===`--native`){i=!0;continue}if(o===`-c`||o===`--computer`){n=e[++a];continue}t.push(o)}return{computer:n,json:r,native:i,rest:t}}function be(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`--`){n+=1;continue}let i=ve(r);if(!i)throw Error(`unknown verb '${r}' — see \`computer --help\``);n+=1;let{args:a,next:o}=Se(i,e,n);t.push({verb:i,alias:r,args:xe(r,i,a)}),n=o}return t}function xe(e,t,n){return t===`click`?e===`left_click`?L(n,`1`):e===`middle_click`?L(n,`2`):e===`right_click`?L(n,`3`):e===`double_click`?[...L(n,`1`),`--repeat`,`2`]:e===`triple_click`?[...L(n,`1`),`--repeat`,`3`]:n:n}function L(e,t){return e[0]===`1`||e[0]===`2`||e[0]===`3`?e:[t,...e]}function Se(e,t,n){return P.has(e)?Ce(t,n):we(Ee(e),t,n)}function Ce(e,t){let n=[],r=t,i=!1;for(;r<e.length;){let t=e[r];if(!i&&t===`--`){i=!0,r+=1;continue}if(!i&&I(t))break;n.push(t),r+=1}return{args:n,next:r}}function R(e){return e.startsWith(`--`)||e===`-n`||e===`-c`}function z(e,t,n){let r=e[t];return n.push(r),t+=1,F.has(r)&&t<e.length&&(n.push(e[t]),t+=1),t}function we(e,t,n){let r=[],i=n,a=0;for(;i<t.length;){let n=t[i];if(n===`--`){i+=1;continue}if(R(n)){i=z(t,i,r);continue}if(I(n))break;if(r.push(n),a+=1,i+=1,a>=e&&e>0){i=Te(t,i,r);break}}return{args:r,next:i}}function Te(e,t,n){let r=t;for(;r<e.length&&R(e[r]);)r=z(e,r,n);return r}function Ee(e){switch(e){case`mousemove`:return 2;case`drag`:return 4;case`scroll`:return 2;case`click`:case`mousedown`:case`mouseup`:return 3;case`wait`:case`keydown`:case`keyup`:case`rm`:case`use`:return 1;case`screenshot`:return 1;default:return 0}}function B(e){let t=e.indexOf(`--at`);if(t===-1)return;let n=e[t+1],r=n?/^(-?\d+),(-?\d+)$/u.exec(n):null;if(!r)throw Error(`--at requires x,y`);return{x:Number(r[1]),y:Number(r[2])}}function V(e,t){let n=e.indexOf(t);if(n===-1)return;let r=Number.parseInt(e[n+1]??``,10);if(!Number.isFinite(r))throw Error(`${t} requires a number`);return r}function H(e,t){return e.includes(t)}function U(e,t){for(let n of t){let t=e.indexOf(n);if(t!==-1)return e[t+1]}}function W(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`){t.push(...e.slice(n+1));break}if(r.startsWith(`--`)||r===`-n`||r===`-c`){F.has(r)&&(n+=1);continue}t.push(r)}return t}function G(e,t,n){let r=e.list();if(t)return K(r,t);let i=n.get(`COMPUTER`);if(i)return K(r,i);let a=e.lastUsedId();return a&&e.get(a)?{id:a}:r.length===1?{id:r[0].id}:r.length===0?{error:"no computers registered — `computer add tab <id>` or `v86 start`"}:{error:`which computer? pass -c <id> or \`computer use\`. registered: ${r.map(e=>e.id).join(`, `)}`}}function K(e,t){let n=e.find(e=>e.id===t);if(n)return{id:n.id};let r=e.filter(e=>e.id.endsWith(`:${t}`)||e.title===t||e.id===`v86:${t}`||e.id===`tab:${t}`);if(r.length===1)return{id:r[0].id};if(r.length>1)return{error:`ambiguous computer '${t}' matches ${r.map(e=>e.id).join(`, `)}`};let i=e.map(e=>e.id).join(`, `);return{error:`unknown computer '${t}'${i?` — registered: ${i}`:` — none registered`}`}}function q(e){return{stdout:``,stderr:`computer: ${e}\n`,exitCode:1}}function J(e=``){return{stdout:e,stderr:``,exitCode:0}}function De(){return globalThis.__slicc_pm??null}function Oe(e){return e.browser??globalThis.__slicc_browser??null}function ke(t){return t.panelRpc??globalThis.__slicc_panelRpc??e()}function Ae(e){return e.registry?e.registry:f()??p(e.processManager??De())}async function je(e,t,i={}){if(e.length===0||e[0]===`--help`||e[0]===`-h`||e[0]===`help`)return J(j);let a=ye(e);if(a.rest.length===0)return J(j);let o=a.rest[0];if(r(a.rest.slice(1),{valueFlags:[..._e]}))return J(n(`computer`,o,j,{prefix:`computer`}));let s;try{s=be(a.rest)}catch(e){return q(e instanceof Error?e.message:String(e))}let c=Ae(i),l=[];for(let e of s)try{let n=await Me(e,a,t,i,c);if(n.exitCode!==0)return n;n.stdout&&l.push(n.stdout.replace(/\n$/u,``))}catch(e){return q(e instanceof Error?e.message:String(e))}let u=l.filter(Boolean).join(`
47
+ `);return J(u?`${u}\n`:``)}async function Me(e,t,n,r,i){switch(e.verb){case`ls`:return Ne(i,t.json);case`add`:return Pe(e.args,n,r,i);case`rm`:return Fe(e.args,t.computer,n,i);case`use`:return Ie(e.args,i);case`info`:return Le(t,n,i);case`screenshot`:return Re(e.args,t,n,i);case`text`:return ze(t,n,i);case`watch`:return Be(e.args,t,n,i,r);case`exec`:return He(e.args,t,n,i);default:return Ue(e,t,n,i)}}function Ne(e,t){let n=e.list();if(t)return J(`${JSON.stringify(n)}\n`);if(n.length===0)return J(`no computers registered
48
+ `);let r=[`ID KIND STATE TITLE`];for(let e of n)r.push(`${e.id.padEnd(20)} ${e.kind.padEnd(5)} ${e.state.padEnd(9)} ${e.title}`);return J(`${r.join(`
49
+ `)}\n`)}async function Pe(e,t,n,r){let i=e[0];if(i!==`tab`)return q(`add: unknown kind '${i??``}' — phase 1 supports \`computer add tab\``);let a=U(e,[`-n`,`--name`]),o=W(e).slice(1)[0];if(!o)return q(`add tab: requires <targetId|url>`);let s=Oe(n);if(!s)return q(`add tab: no browser API in this float`);let c=de(await s.listAllTargets(),o);if(`error`in c)return q(c.error);try{x(c)}catch(e){return q(e instanceof Error?e.message:String(e))}let l={title:a??c.title,url:c.url},u=n.browser&&!n.panelRpc?null:ke(n),d=u?new w(u,c.targetId,l):new S(s,c.targetId,l),f=r.register(d);return r.use(f.id),J(`registered ${f.id} (${f.title})\n`)}async function Fe(e,t,n,r){let i=G(r,W(e)[0]??t,Q(n));return`error`in i?q(i.error):await r.unregister(i.id)?J(`unregistered ${i.id}\n`):q(`unknown computer '${i.id}'`)}function Ie(e,t){let n=W(e)[0];if(!n)return q(`use: requires <id>`);let r=G(t,n,new Map);return`error`in r?q(r.error):(t.use(r.id),J(`using ${r.id}\n`))}function Le(e,t,n){let r=G(n,e.computer,Q(t));if(`error`in r)return q(r.error);let i=n.getEntry(r.id);if(!i)return q(`unknown computer '${r.id}'`);if(e.json)return J(`${JSON.stringify(i.descriptor)}\n`);let a=i.descriptor,o=a.size?`${a.size.width}x${a.size.height}`:`-`;return J(`id: ${a.id}\nkind: ${a.kind}\ntitle: ${a.title}\nstate: ${a.state}\nsize: ${o}\npid: ${a.pid??`-`}\n`)}async function Re(e,n,r,i){let o=Z(i,n.computer,r);if(`exitCode`in o)return o;let s=O(U(e,[`--size`])),l=await o.backend.screenshot({format:`jpeg`,maxWidth:s}),u=k(o.backend.describe().size??{width:l.width,height:l.height},{width:l.width,height:l.height});i.rememberShot(o.id,A(u,Date.now()),l);let d=l.seq>0?l.seq:i.nextSeq(o.id),f=await c({fs:r.fs,cwd:r.cwd,env:r.env,name:$(o.descriptor),seq:d,frame:l}),p=W(e)[0];if(p){let e=r.fs.resolvePath(r.cwd,p);await r.fs.writeFile(e,l.bytes)}let m=[he(u),a(f)];return(H(e,`--view`)||H(e,`-v`))&&m.push(`<img:data:${l.mime};base64,${t(l.bytes)}>`),n.json?J(`${JSON.stringify({id:o.id,path:f,mapping:u})}\n`):J(`${m.join(`
50
+ `)}\n`)}async function ze(e,t,n){let r=Z(n,e.computer,t);if(`exitCode`in r)return r;if(!r.backend.text)return q(`text: '${r.id}' has no text dump`);let i=await r.backend.text();return i===null?q(`text: unavailable for '${r.id}'`):J(`${i}\n`)}async function Be(e,t,n,r,i){let a=Z(r,t.computer,n);if(`exitCode`in a)return a;let o=Ve(i);if(!o)return q(`watch: computers host is not running`);if(H(e,`--stop`))return o.unwatch(a.id),J(`unwatched ${a.id}\n`);let s=V(e,`--fps`)??2,c=O(U(e,[`--size`]));return o.watch(a.id,s,c),J(`watching ${a.id} at ${s} fps\n`)}function Ve(e){if(e.watch)return{watch:e.watch,unwatch:e.unwatch??(()=>void 0)};let t=m();return t?{watch:t.watch,unwatch:t.unwatch}:null}async function He(e,t,n,r){let i=Z(r,t.computer,n);if(`exitCode`in i)return i;if(!i.backend.exec)return q(`exec: '${i.id}' does not support exec`);let a=e.join(` `);if(!a)return q(`exec: requires a command`);let o=await i.backend.exec(a),s=[o.stdout,o.stderr].filter(Boolean).join(`
51
+ `);return{stdout:s?`${s}\n`:``,stderr:``,exitCode:o.exitCode}}async function Ue(e,t,n,r){let i=Z(r,t.computer,n);if(`exitCode`in i)return i;let a=Y(e,t.native,i.descriptor),o=pe(i.descriptor.capabilities,a);return o?q(`${e.verb}: ${o}`):(await i.backend.input(a),We(i,n,r))}async function We(e,t,n){let r=e.descriptor.lastShot?.width??768,i;try{i=await Ge(e.backend.screenshot({format:`jpeg`,maxWidth:r}),5e3)}catch(e){return q(`screenshot failed after input: ${e instanceof Error?e.message:String(e)}`)}let o=k(e.backend.describe().size??{width:i.width,height:i.height},{width:i.width,height:i.height}),s=n.nextSeq(e.id),l={...i,seq:s};n.rememberShot(e.id,A(o,Date.now()),l);let u=await c({fs:t.fs,cwd:t.cwd,env:t.env,name:$(e.descriptor),seq:s,frame:l});return J(`${a(u)}\n`)}function Ge(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>r(Error(`timed out`)),t);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}function Y(e,t,n){let r=(e,r)=>ge(e,r,n.lastShot,t);switch(e.verb){case`mousemove`:return Ke(e.args,r);case`click`:case`mousedown`:case`mouseup`:return qe(e.verb,e.args,r);case`drag`:return Je(e.args,r,n.capabilities.mouse);case`scroll`:return Ye(e.args,r);case`key`:case`keydown`:case`keyup`:return Xe(e.verb,e.args);case`type`:return Ze(e.args);case`wait`:return Qe(e.args);default:throw Error(`internal: ${e.verb} is not an input verb`)}}function Ke(e,t){let n=W(e),r=Number(n[0]),i=Number(n[1]);if(!Number.isFinite(r)||!Number.isFinite(i))throw Error(`mousemove: requires <x> <y>`);let a=H(e,`--relative`),o=a?{x:r,y:i}:t(r,i);return[{type:`mousemove`,x:o.x,y:o.y,relative:a}]}function qe(e,t,n){let r=W(t),{button:i,skip:a}=$e(r),o=B(t)??tt(r,a),s=o?n(o.x,o.y):void 0;if(e===`mousedown`)return[{type:`button`,button:i,down:!0,...X(s)}];if(e===`mouseup`)return[{type:`button`,button:i,down:!1,...X(s)}];let c=V(t,`--hold`);return[{type:`click`,button:i,count:V(t,`--repeat`)??1,...c===void 0?{}:{holdMs:c},...X(s)}]}function Je(e,t,n){let r=W(e).map(Number);if(r.length<4||r.some(e=>!Number.isFinite(e)))throw Error(`drag: requires <x1> <y1> <x2> <y2>`);let i=t(r[0],r[1]),a=t(r[2],r[3]);return n===`touch`?[{type:`drag`,x1:i.x,y1:i.y,x2:a.x,y2:a.y}]:[{type:`mousemove`,x:i.x,y:i.y},{type:`button`,button:1,down:!0,x:i.x,y:i.y},{type:`mousemove`,x:a.x,y:a.y},{type:`button`,button:1,down:!1,x:a.x,y:a.y}]}function Ye(e,t){let n=W(e),r=Number(n[0]),i=Number(n[1]);if(!Number.isFinite(r)||!Number.isFinite(i))throw Error(`scroll: requires <dx> <dy>`);let a=B(e);return[{type:`scroll`,dx:r,dy:i,...X(a?t(a.x,a.y):void 0)}]}function Xe(e,t){if(e===`key`){if(t.length===0)throw Error(`key: no keysym supplied`);return t.map(e=>({type:`key`,keysym:e}))}let n=W(t)[0];if(!n)throw Error(`${e}: no keysym supplied`);return[{type:`key`,keysym:n,down:e===`keydown`}]}function Ze(e){let t=e.join(` `).replace(/\\n/gu,`
52
+ `).replace(/\\t/gu,` `);if(!t)throw Error(`type: no text supplied`);return[{type:`text`,text:t}]}function Qe(e){let t=Number(W(e)[0]);if(!Number.isFinite(t))throw Error(`wait: requires <ms>`);return[{type:`wait`,ms:t}]}function $e(e){return e[0]===void 0?{button:1,skip:0}:e[0]===`left`||e[0]===`middle`||e[0]===`right`||e[0]===`1`||e[0]===`2`||e[0]===`3`?{button:et(e[0]),skip:1}:{button:1,skip:0}}function et(e){if(!e||e===`left`||e===`1`)return 1;if(e===`middle`||e===`2`)return 2;if(e===`right`||e===`3`)return 3;let t=Number.parseInt(e,10);if(t===1||t===2||t===3)return t;throw Error(`unknown button '${e}' (use 1|2|3)`)}function tt(e,t){let n=Number(e[t]),r=Number(e[t+1]);if(Number.isFinite(n)&&Number.isFinite(r))return{x:n,y:r}}function X(e){return e?{x:e.x,y:e.y}:{}}function Z(e,t,n){let r=G(e,t,Q(n));if(`error`in r)return q(r.error);let i=e.getEntry(r.id);return i?{id:r.id,backend:i.backend,descriptor:i.descriptor}:q(`unknown computer '${r.id}'`)}function Q(e){let t=e.env;if(t instanceof Map)return t;let n=new Map;if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))r!==void 0&&n.set(e,r);return n}function $(e){return e.id.replace(/[/:]/gu,`_`)}export{je as runComputer};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./slicc-version-Cu6HjDRg.js";import{a as t}from"./just-bash-compat-B-SPHuh_.js";const n=`/dev/null`;function r(e){return e.oldName===n}function i(e){return e.newName===n}function a(e){let t=e.indexOf(` `);return(t===-1?e.replace(/\s+\d{4}-\d\d-\d\d[ T].*$/,``):e.slice(0,t)).trimEnd()}const o=/^@@+ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function s(e){let t=o.exec(e);return t?{oldStart:Number(t[1]),oldCount:t[2]===void 0?1:Number(t[2]),newStart:Number(t[3]),newCount:t[4]===void 0?1:Number(t[4])}:null}function c(e,t){return{...e,oldLines:[],newLines:[],oldSeen:0,newSeen:0,changeSeen:!1,leadingContext:0,trailingContext:0,lastSide:null,oldNoNewlineAtEof:!1,newNoNewlineAtEof:!1,raw:[t]}}function l(e){return{oldStart:e.oldStart,newStart:e.newStart,oldLines:e.oldLines,newLines:e.newLines,leadingContext:e.leadingContext,trailingContext:e.trailingContext,oldNoNewlineAtEof:e.oldNoNewlineAtEof,newNoNewlineAtEof:e.newNoNewlineAtEof,raw:e.raw}}function u(e){return e.oldSeen>=e.oldCount&&e.newSeen>=e.newCount}function d(e,t){e.oldLines.push(t),e.newLines.push(t),e.oldSeen++,e.newSeen++,e.lastSide=`both`,e.changeSeen?e.trailingContext++:e.leadingContext++}function f(e,t,n){t===`old`?(e.oldLines.push(n),e.oldSeen++):(e.newLines.push(n),e.newSeen++),e.lastSide=t,e.changeSeen=!0,e.trailingContext=0}function p(e,t){if(t.startsWith(`\\`))return(e.lastSide===`old`||e.lastSide===`both`)&&(e.oldNoNewlineAtEof=!0),(e.lastSide===`new`||e.lastSide===`both`)&&(e.newNoNewlineAtEof=!0),e.raw.push(t),!0;if(t===``)return d(e,``),e.raw.push(` `),!0;let n=t.slice(1);switch(t[0]){case` `:d(e,n);break;case`-`:f(e,`old`,n);break;case`+`:f(e,`new`,n);break;default:return!1}return e.raw.push(t),!0}function m(e){e.hunk&&e.current&&e.current.hunks.push(l(e.hunk)),e.hunk=null,e.complete=!1}function h(e,t){let n=e.hunk;if(!n)return!1;if(e.complete){let r=t.startsWith(`\\`);return r&&p(n,t),m(e),r}return p(n,t)?(u(n)&&(e.complete=!0),!0):(m(e),!1)}function g(e){let t={files:[],current:null,hunk:null,complete:!1,pendingOld:null};for(let n of e.split(`
1
+ import{n as e}from"./slicc-version-BZyTvfoc.js";import{a as t}from"./just-bash-compat-B-SPHuh_.js";const n=`/dev/null`;function r(e){return e.oldName===n}function i(e){return e.newName===n}function a(e){let t=e.indexOf(` `);return(t===-1?e.replace(/\s+\d{4}-\d\d-\d\d[ T].*$/,``):e.slice(0,t)).trimEnd()}const o=/^@@+ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function s(e){let t=o.exec(e);return t?{oldStart:Number(t[1]),oldCount:t[2]===void 0?1:Number(t[2]),newStart:Number(t[3]),newCount:t[4]===void 0?1:Number(t[4])}:null}function c(e,t){return{...e,oldLines:[],newLines:[],oldSeen:0,newSeen:0,changeSeen:!1,leadingContext:0,trailingContext:0,lastSide:null,oldNoNewlineAtEof:!1,newNoNewlineAtEof:!1,raw:[t]}}function l(e){return{oldStart:e.oldStart,newStart:e.newStart,oldLines:e.oldLines,newLines:e.newLines,leadingContext:e.leadingContext,trailingContext:e.trailingContext,oldNoNewlineAtEof:e.oldNoNewlineAtEof,newNoNewlineAtEof:e.newNoNewlineAtEof,raw:e.raw}}function u(e){return e.oldSeen>=e.oldCount&&e.newSeen>=e.newCount}function d(e,t){e.oldLines.push(t),e.newLines.push(t),e.oldSeen++,e.newSeen++,e.lastSide=`both`,e.changeSeen?e.trailingContext++:e.leadingContext++}function f(e,t,n){t===`old`?(e.oldLines.push(n),e.oldSeen++):(e.newLines.push(n),e.newSeen++),e.lastSide=t,e.changeSeen=!0,e.trailingContext=0}function p(e,t){if(t.startsWith(`\\`))return(e.lastSide===`old`||e.lastSide===`both`)&&(e.oldNoNewlineAtEof=!0),(e.lastSide===`new`||e.lastSide===`both`)&&(e.newNoNewlineAtEof=!0),e.raw.push(t),!0;if(t===``)return d(e,``),e.raw.push(` `),!0;let n=t.slice(1);switch(t[0]){case` `:d(e,n);break;case`-`:f(e,`old`,n);break;case`+`:f(e,`new`,n);break;default:return!1}return e.raw.push(t),!0}function m(e){e.hunk&&e.current&&e.current.hunks.push(l(e.hunk)),e.hunk=null,e.complete=!1}function h(e,t){let n=e.hunk;if(!n)return!1;if(e.complete){let r=t.startsWith(`\\`);return r&&p(n,t),m(e),r}return p(n,t)?(u(n)&&(e.complete=!0),!0):(m(e),!1)}function g(e){let t={files:[],current:null,hunk:null,complete:!1,pendingOld:null};for(let n of e.split(`
2
2
  `)){if(h(t,n))continue;if(n.startsWith(`--- `)){t.pendingOld=a(n.slice(4));continue}if(n.startsWith(`+++ `)&&t.pendingOld!==null){t.current={oldName:t.pendingOld,newName:a(n.slice(4)),hunks:[]},t.files.push(t.current),t.pendingOld=null;continue}t.pendingOld=null;let e=s(n);e&&t.current&&(t.hunk=c(e,n))}return m(t),t.files.filter(e=>e.hunks.length>0)}function _(e){return{oldName:e.newName,newName:e.oldName,hunks:e.hunks.map(e=>({oldStart:e.newStart,newStart:e.oldStart,oldLines:e.newLines,newLines:e.oldLines,leadingContext:e.leadingContext,trailingContext:e.trailingContext,oldNoNewlineAtEof:e.newNoNewlineAtEof,newNoNewlineAtEof:e.oldNoNewlineAtEof,raw:v(e)}))}}function v(e){return e.raw.map((t,n)=>n===0?`@@ -${e.newStart},${e.newLines.length} +${e.oldStart},${e.oldLines.length} @@`:t.startsWith(`-`)?`+${t.slice(1)}`:t.startsWith(`+`)?`-${t.slice(1)}`:t)}function y(e){if(e===``)return{lines:[],newlineAtEof:!0};let t=e.endsWith(`
3
3
  `),n=e.split(`
4
4
  `);return t&&n.pop(),{lines:n,newlineAtEof:t}}function b(e){return e.lines.length===0?``:e.lines.join(`
@@ -42,7 +42,7 @@ Examples:
42
42
  gelatiere suggest "$TMPDIR/candidates.json" && gelatiere deliver
43
43
  gelatiere dismiss skill-github
44
44
  gelatiere use-cases --limit 3 --json
45
- `,i=[`--scoop`],a=[`--limit`],o=[...i,...a];function s(e){return{stdout:e,stderr:``,exitCode:0}}function c(e){return{stdout:``,stderr:`gelatiere: ${e}\n`,exitCode:1}}const l=`kernel host has not booted yet — try again in a moment`;function u(){let e=globalThis.__slicc_gelatiere;return e&&typeof e.roots==`function`?e:null}function d(){return import(`./gelatiere-store-ijXRupBc.js`)}async function f(t,n){let r=e(t,{bool:[`--reset`]});if(`error`in r)return c(r.error);let i=u();if(!i)return c(l);let a=await(await d()).loadGelatiereConfig(n),o=``;if(r.bools.has(`--reset`)){let e=await i.unregisterOwned();o=e.length?`Dropped ${e.length} gelatiere unit(s): ${e.join(`, `)}\n`:``}let f;try{f=await i.ensureUnit(a.allowedCommands)}catch(e){return c(e instanceof Error?e.message:String(e))}let m=await i.ensureNightly(a.nightly);return s(o+`${f.created?`Created`:`Found`} the gelatiere (${f.jid}, folder ${f.folder})\n`+p(f.allowList)+`${m.created?`Registered`:`Found`} nightly pass: cron "${m.cron}" (${m.id})\nSuggestions render in the suggestions card; \`gelatiere run\` asks for a pass now.
45
+ `,i=[`--scoop`],a=[`--limit`],o=[...i,...a];function s(e){return{stdout:e,stderr:``,exitCode:0}}function c(e){return{stdout:``,stderr:`gelatiere: ${e}\n`,exitCode:1}}const l=`kernel host has not booted yet — try again in a moment`;function u(){let e=globalThis.__slicc_gelatiere;return e&&typeof e.roots==`function`?e:null}function d(){return import(`./gelatiere-store-C2u47uk0.js`)}async function f(t,n){let r=e(t,{bool:[`--reset`]});if(`error`in r)return c(r.error);let i=u();if(!i)return c(l);let a=await(await d()).loadGelatiereConfig(n),o=``;if(r.bools.has(`--reset`)){let e=await i.unregisterOwned();o=e.length?`Dropped ${e.length} gelatiere unit(s): ${e.join(`, `)}\n`:``}let f;try{f=await i.ensureUnit(a.allowedCommands)}catch(e){return c(e instanceof Error?e.message:String(e))}let m=await i.ensureNightly(a.nightly);return s(o+`${f.created?`Created`:`Found`} the gelatiere (${f.jid}, folder ${f.folder})\n`+p(f.allowList)+`${m.created?`Registered`:`Found`} nightly pass: cron "${m.cron}" (${m.id})\nSuggestions render in the suggestions card; \`gelatiere run\` asks for a pass now.
46
46
  `)}function p(e){return e===`updated`?`Updated its command allow-list from GELATIERE.md
47
47
  `:e===`deferred`?`Left its command allow-list alone: the gelatiere is mid-pass and applying it would
48
48
  cancel the pass — run \`gelatiere init\` again once it is idle
@@ -50,5 +50,5 @@ cancel the pass — run \`gelatiere init\` again once it is idle
50
50
  `),s(l)}async function g(t,n){let r=e(t,{value:i,bool:[`--force`]});if(`error`in r)return c(r.error);let a=u();if(!a)return c(l);let o=await d(),f=await o.readGelatiereSuggestions(n),p=o.openSuggestions(f),m=await o.readGelatiereState(n);if(o.suggestionsSince(f,m.lastDeliveredAt).length===0&&!r.bools.has(`--force`))return s(`Nothing new since the last delivery; no lick sent (use --force to resend).
51
51
  `);let h=a.roots();if(h.length===0)return c(`no cone is running to deliver to`);let g=r.values.get(`--scoop`),v=g?h.find(e=>e.folder===g||e.name===g||e.jid===g):void 0;if(g&&!v)return c(`unknown delivery target "${g}" (cones: ${h.map(e=>e.folder).join(`, `)})`);let y=await _(a,h,v?[v]:h,{since:m.lastDeliveredAt,open:p,force:r.bools.has(`--force`),alias:g});g||await o.writeGelatiereState(n,{...m,lastDeliveredAt:new Date().toISOString()});let b=g?` (targeted; the delivery watermark is unchanged)`:``;return y.length===0?s(`Nothing addressed to ${g??`any running cone`}; no lick sent${b}\n`):s(`Delivered to ${y.length} cone(s): ${y.join(`, `)}${b}\n`)}async function _(e,t,n,r){let i=await d(),a=new Set(t.map(e=>e.folder)),o=t[0].folder,s=[];for(let t of n){let n=i.suggestionsForCone(r.open,t.folder,o,a),c=n.filter(e=>i.isNewSince(e,r.since,t.folder));if(c.length===0&&!(r.force&&n.length>0))continue;let l=r.alias??t.folder;e.lick(l,i.buildGelatiereLickBody(c,n)),s.push(`${l} (${c.length} new, ${n.length} open)`)}return s}async function v(t,n){let r=e(t,{bool:[`--all`,`--json`]});if(`error`in r)return c(r.error);let i=await d(),a=await i.readGelatiereSuggestions(n),o=r.bools.has(`--all`)?a:i.openSuggestions(a);if(r.bools.has(`--json`))return s(`${JSON.stringify(o,null,2)}\n`);if(o.length===0)return s(a.length===0?"No suggestions yet. `gelatiere run` asks for a pass now.\n":"No open suggestions (every one has been taken or dismissed; `--all` lists them).\n");let l=``;for(let e of o){let t=e.dismissedAt?` (dismissed)`:e.takenAt?` (taken)`:``;l+=`${e.id} [${e.kind}]${t}\n ${e.title}\n`,e.install&&(l+=` install: ${e.install}\n`),e.prompt&&(l+=` try: ${e.prompt}\n`)}return s(l)}async function y(e,t){let n=e[0];return n?await(await d()).dismissGelatiereSuggestion(t,n)?s(`Dismissed ${n}.\n`):c(`no open suggestion with id "${n}"`):c("dismiss requires a suggestion id (see `gelatiere list`)")}const b=`https://www.sliccy.com`,x=512e3,S=/^[a-z0-9][a-z0-9-]*$/;async function C(e,t){let n=await fetch(`${b}${e}`,{signal:AbortSignal.timeout(15e3)});if(!n.ok)throw Error(`${e}: HTTP ${n.status}`);let r=await n.text();return r.length>t?r.slice(0,t):r}async function w(){try{let e=await C(`/skills/catalog.json`,x);return s(e.endsWith(`
52
52
  `)?e:`${e}\n`)}catch(e){return c(`catalog fetch failed: ${e instanceof Error?e.message:String(e)}`)}}async function T(){try{let e=[...(await C(`/sitemap.xml`,x)).matchAll(/<loc>[^<]*\/man\/([a-z0-9-]+)(?:\.html)?<\/loc>/g)].map(e=>e[1]).sort();return e.length===0?c(`no man pages found in the sitemap`):s(`${[...new Set(e)].join(` `)}\n`)}catch(e){return c(`sitemap fetch failed: ${e instanceof Error?e.message:String(e)}`)}}async function E(e){let t=e[0];if(!t)return c(`man requires a command name: gelatiere man <command>`);if(!S.test(t))return c(`not a command name: "${t}"`);try{let e=await C(`/man/${t}.plain.html`,16e3);return s(e.endsWith(`
53
- `)?e:`${e}\n`)}catch(e){return c(`man fetch failed: ${e instanceof Error?e.message:String(e)}`)}}function D(e,t,n){let r=e=>{let t=n.match(RegExp(`<meta[^>]+name=["']${e}["'][^>]+content=(["'])((?:(?!\\1).)*)\\1`,`i`));return t?k(t[2]).trim():``},i=n.match(/<title[^>]*>([^<]*)<\/title>/i);return{slug:e,url:t,title:i?k(i[1]).trim():A(e),description:r(`description`),skills:r(`slicc-upskill`).split(`,`).map(e=>e.trim()).filter(Boolean)}}const O={amp:`&`,lt:`<`,gt:`>`,quot:`"`,"#39":`'`,"#x27":`'`};function k(e){return e.replace(/&(#x?[0-9a-fA-F]+|[a-z]+);/g,(e,t)=>{let n=O[t.toLowerCase()];if(n)return n;let r=t.match(/^#(x?)([0-9a-fA-F]+)$/i);if(!r)return e;let i=Number.parseInt(r[2],r[1]?16:10);return Number.isFinite(i)?String.fromCodePoint(i):e})}function A(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function j(e,t){return e<=0?0:Math.floor(t/864e5)%e}function M(e,t,n){if(t>=e.length)return[...e];let r=j(e.length,n);return Array.from({length:t},(t,n)=>e[(r+n)%e.length])}async function N(e,t){let n=Array(e.length),r=0,i=async()=>{for(;r<e.length;){let i=r++;n[i]=await t(e[i])}};return await Promise.all(Array.from({length:Math.min(4,e.length)},()=>i())),n}async function P(t){let n=e(t,{value:a,bool:[`--json`]});if(`error`in n)return c(n.error);let r=n.values.get(`--limit`),i=r===void 0?12:Number(r);if(!Number.isInteger(i)||i<=0)return c(`--limit must be a positive whole number, not "${r}"`);let o;try{let e=await C(`/sitemap.xml`,x);o=[...new Set([...e.matchAll(/<loc>[^<]*\/use-cases\/([a-z0-9-]+)(?:\.html)?<\/loc>/g)].map(e=>e[1]))].sort()}catch(e){return c(`sitemap fetch failed: ${e instanceof Error?e.message:String(e)}`)}if(o.length===0)return c(`no use cases found in the sitemap`);let l=await N(M(o,Math.min(i,12),Date.now()),async e=>{let t=`${b}/use-cases/${e}`;try{return D(e,t,await C(`/use-cases/${e}`,24e3))}catch{return{slug:e,url:t,title:A(e),description:``,skills:[]}}});if(n.bools.has(`--json`))return s(`${JSON.stringify(l,null,2)}\n`);let u=``;for(let e of l)u+=`${e.slug}\t${e.title}\n ${e.url}\n`,e.description&&(u+=` ${e.description}\n`),e.skills.length&&(u+=` skills: ${e.skills.join(` `)}\n`);return s(u)}async function F(e){let t=await d(),n=u(),r=n?.unit(),i=await t.loadGelatiereConfig(e),a=await t.readGelatiereState(e),o=await t.readGelatiereSuggestions(e),c=``,{isMemoryV2Enabled:l}=await import(`./memory-v2-flag-BkWGkfSv.js`);l()||(c+=`Memory v2: OFF — the nightly is unscheduled and session ends do not trigger passes
53
+ `)?e:`${e}\n`)}catch(e){return c(`man fetch failed: ${e instanceof Error?e.message:String(e)}`)}}function D(e,t,n){let r=e=>{let t=n.match(RegExp(`<meta[^>]+name=["']${e}["'][^>]+content=(["'])((?:(?!\\1).)*)\\1`,`i`));return t?k(t[2]).trim():``},i=n.match(/<title[^>]*>([^<]*)<\/title>/i);return{slug:e,url:t,title:i?k(i[1]).trim():A(e),description:r(`description`),skills:r(`slicc-upskill`).split(`,`).map(e=>e.trim()).filter(Boolean)}}const O={amp:`&`,lt:`<`,gt:`>`,quot:`"`,"#39":`'`,"#x27":`'`};function k(e){return e.replace(/&(#x?[0-9a-fA-F]+|[a-z]+);/g,(e,t)=>{let n=O[t.toLowerCase()];if(n)return n;let r=t.match(/^#(x?)([0-9a-fA-F]+)$/i);if(!r)return e;let i=Number.parseInt(r[2],r[1]?16:10);return Number.isFinite(i)?String.fromCodePoint(i):e})}function A(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function j(e,t){return e<=0?0:Math.floor(t/864e5)%e}function M(e,t,n){if(t>=e.length)return[...e];let r=j(e.length,n);return Array.from({length:t},(t,n)=>e[(r+n)%e.length])}async function N(e,t){let n=Array(e.length),r=0,i=async()=>{for(;r<e.length;){let i=r++;n[i]=await t(e[i])}};return await Promise.all(Array.from({length:Math.min(4,e.length)},()=>i())),n}async function P(t){let n=e(t,{value:a,bool:[`--json`]});if(`error`in n)return c(n.error);let r=n.values.get(`--limit`),i=r===void 0?12:Number(r);if(!Number.isInteger(i)||i<=0)return c(`--limit must be a positive whole number, not "${r}"`);let o;try{let e=await C(`/sitemap.xml`,x);o=[...new Set([...e.matchAll(/<loc>[^<]*\/use-cases\/([a-z0-9-]+)(?:\.html)?<\/loc>/g)].map(e=>e[1]))].sort()}catch(e){return c(`sitemap fetch failed: ${e instanceof Error?e.message:String(e)}`)}if(o.length===0)return c(`no use cases found in the sitemap`);let l=await N(M(o,Math.min(i,12),Date.now()),async e=>{let t=`${b}/use-cases/${e}`;try{return D(e,t,await C(`/use-cases/${e}`,24e3))}catch{return{slug:e,url:t,title:A(e),description:``,skills:[]}}});if(n.bools.has(`--json`))return s(`${JSON.stringify(l,null,2)}\n`);let u=``;for(let e of l)u+=`${e.slug}\t${e.title}\n ${e.url}\n`,e.description&&(u+=` ${e.description}\n`),e.skills.length&&(u+=` skills: ${e.skills.join(` `)}\n`);return s(u)}async function F(e){let t=await d(),n=u(),r=n?.unit(),i=await t.loadGelatiereConfig(e),a=await t.readGelatiereState(e),o=await t.readGelatiereSuggestions(e),c=``,{isMemoryV2Enabled:l}=await import(`./memory-v2-flag-BHVbti6Z.js`);l()||(c+=`Memory v2: OFF — the nightly is unscheduled and session ends do not trigger passes
54
54
  `),c+=`Unit: ${r?`${r.jid} (folder ${r.folder})`:"not created — run `gelatiere init`"}\n`;let f=n?.nightly();return c+=`Nightly: ${f?`registered, cron "${f.cron}" (${f.id})`:`not registered — run \`gelatiere init\` (cron "${i.nightly}")`}\n`,c+=`Interval: ${i.intervalHours}h between session-end passes\n`,c+=I(i.allowedCommands,n?.unitAllowedCommands(),t),c+=`Passes: ${a.passes}\n`,c+=`Last pass: ${a.lastPassAt??`never`}\n`,c+=`Last trigger: ${a.lastTriggeredAt??`never`}\n`,c+=`Last delivery: ${a.lastDeliveredAt??`never`}\n`,c+=`Suggestions: ${t.openSuggestions(o).length} open, ${t.takenSuggestions(o).length} taken, ${o.length} total\n`,s(c)}function I(e,t,n){let r=e=>{let t=e.filter(e=>!n.GELATIERE_BASE_ALLOWED_COMMANDS.includes(e));return t.length?` (+${t.join(`, `)} from GELATIERE.md)`:``};return t?t.length===e.length&&t.every((t,n)=>t===e[n])?`Commands: ${t.length} allowed without approval${r(t)}\n`:`Commands: ${t.length} in force${r(t)}; GELATIERE.md asks for ${e.length}${r(e)} — run \`gelatiere init\`\n`:`Commands: ${e.length} configured${r(e)}, pending — run \`gelatiere init\`\n`}async function L(e,n,i){let a=e[0];if(!a||t(e,{valueFlags:o}))return s(r);let l=e.slice(1);switch(a){case`init`:return f(l,i.fs);case`run`:return m(n.env);case`suggest`:return h(l,i.fs);case`deliver`:return g(l,i.fs);case`list`:return v(l,i.fs);case`dismiss`:return y(l,i.fs);case`status`:return F(i.fs);case`catalog`:return w();case`commands`:return T();case`man`:return E(l);case`use-cases`:return P(l);default:return c(`unknown command: ${a}\n${r}`)}}export{L as runGelatiere};
@@ -92,7 +92,7 @@ Examples:
92
92
  --authorize-url 'https://auth.x.ai/oauth2/auth?...' \\
93
93
  --redirect-pattern 'http://127.0.0.1:56121/*'
94
94
  curl -H "Authorization: Bearer $(oauth-token github)" https://api.github.com/user
95
- `}async function d(n,r){let i=await import(`./account-store-lzZlhljv.js`).then(e=>e.t),a=await import(`./providers-CUF9nsUE.js`).then(e=>e.r);if(t(n,{valueFlags:c}))return{stdout:u(),stderr:``,exitCode:0};let o=e(n,{value:c,bool:l});if(`error`in o)return H(`oauth-token: ${o.error}`);if(o.bools.has(`--list`))return U(i.getAccounts,a.getRegisteredProviderIds,a.getRegisteredProviderConfig,i.getOAuthAccountInfo);if(o.bools.has(`--check`))return T(o.positionals);if(o.bools.has(`--expire`))return O(o.positionals);if(o.bools.has(`--renew`))return k(o.positionals);if(o.values.has(`--from-file`)||o.bools.has(`--intercept`))return L(o,n,r);let s=f(o);if(!s.ok)return s.result;let d=o.bools.has(`--force-login`),m=p(o,i,a);if(!m.ok)return m.result;let _=h(m.value,a.getRegisteredProviderConfig);if(!_.ok)return _.result;if(!d){let e=await g(m.value,_.value,i.getOAuthAccountInfo,i.ensureOAuthMaskReplica,s.value);if(e?.ok)return e.value;if(e)return e.result}return b(m.value,_.value,s.value,i.getOAuthAccountInfo,i.ensureOAuthMaskReplica)}function f(e){if(!e.values.has(`--scope`))return{ok:!0,value:void 0};let t=e.values.get(`--scope`)?.trim();return!t||t.startsWith(`-`)?{ok:!1,result:H(`oauth-token: --scope requires a value`)}:{ok:!0,value:t}}function p(e,t,n){if(e.values.has(`--provider`)){let t=e.values.get(`--provider`);return t?{ok:!0,value:t}:{ok:!1,result:H(`oauth-token: --provider requires a value`)}}if(e.positionals.length>0)return{ok:!0,value:e.positionals[0]};let r=t.getSelectedProvider();if(m(n.getRegisteredProviderConfig(r)))return{ok:!0,value:r};let i=n.getRegisteredProviderIds().find(e=>m(n.getRegisteredProviderConfig(e)));return i?{ok:!0,value:i}:{ok:!1,result:H(`oauth-token: no OAuth providers configured`)}}function m(e){return!!(e?.isOAuth&&(e.onOAuthLogin||e.onOAuthLoginIntercepted))}function h(e,t){let n=t(e);return n?m(n)?{ok:!0,value:n}:{ok:!1,result:H(`oauth-token: provider "${e}" is not an OAuth provider`)}:{ok:!1,result:H(`oauth-token: unknown provider "${e}"`)}}async function g(e,t,n,r,i){let a=n(e);return a&&!a.expired?_(e,a,i,r):!a?.expired||!t.onSilentRenew||!await C(t.onSilentRenew)?null:_(e,n(e),i,r)}async function _(e,t,n,r){if(n&&!s(t?.scopes,n))return null;let i=v(t?.maskedValue,t?.token);if(i)return{ok:!0,value:i};if(!t?.token)return null;let a=await r(e)??{},o=v(a.maskedValue,t.token);return o?{ok:!0,value:o}:{ok:!1,result:y(e,a.error)}}function v(e,t){return!e||t&&e===t?null:{stdout:`${e}\n`,stderr:``,exitCode:0}}function y(e,t){return H(`oauth-token: token held for ${e} but no masked replica${t?` (${t})`:``}`)}async function b(e,t,n,r,i){try{let a=await x(e,t,n);return a.error?a.error:S(e,r,i,a.succeeded)}catch(t){let n=t instanceof Error?t.message:String(t);return t instanceof Error&&t.name===`OAuthLaunchError`?(console.error(`[oauth-token] Provider ${e}: login could not be shown:`,n),H(`oauth-token: ${n}`)):(console.error(`[oauth-token] Provider ${e}: login failed:`,n),H(`oauth-token: login failed: ${n}`))}}async function x(e,t,n){let r=n?{scopes:n}:void 0,i=!1,a=()=>{i=!0};if(t.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:n}=await import(`./oauth-service-IlBYPvwr.js`),o=await n();return o?(await t.onOAuthLoginIntercepted(o,a,r),{error:null,succeeded:i}):{error:H(`oauth-token: provider "${e}" needs the controlled-browser interceptor, but no CDP transport is available in this runtime.`),succeeded:!1}}if(t.onOAuthLogin){let{createOAuthLauncher:e}=await import(`./oauth-service-IlBYPvwr.js`);return await t.onOAuthLogin(e(),a,r),{error:null,succeeded:i}}return{error:H(`oauth-token: provider "${e}" has no OAuth login hook`),succeeded:!1}}async function S(e,t,n,r){if(!r)return console.error(`[oauth-token] Provider ${e}: interactive login was not completed`),H(`oauth-token: interactive login was not completed (cancelled, timed out, or no one could approve it)`);let i=t(e);if(i?.token&&!i.expired){let t=v(i.maskedValue,i.token);if(t)return t;let r=await n(e)??{};return v(r.maskedValue,i.token)||y(e,r.error)}return i?.token?H(`oauth-token: login completed but the saved token is already expired`):(console.error(`[oauth-token] Provider ${e}: login completed but no token was saved`),H(`oauth-token: login completed but no token was saved`))}async function C(e){try{return await e()!==null}catch{return!1}}function w(e,t,n,r,i){let a=e[0];if(a)return a;let o=n();return r(o)?.[t]?o:i().find(e=>r(e)?.[t])}async function T(e){let{getSelectedProvider:t,getOAuthAccountInfo:n}=await import(`./account-store-lzZlhljv.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-CUF9nsUE.js`).then(e=>e.r),a=w(e,`onValidateToken`,t,r,i);if(!a)return H(`oauth-token --check: no provider supports an upstream token check`);let o=r(a);if(!o)return H(`oauth-token --check: unknown provider "${a}"`);if(!o.onValidateToken)return H(`oauth-token --check: provider "${a}" cannot be checked upstream (no onValidateToken hook); only locally stored state is known.`);let s=n(a),c=[`oauth-token --check ${a}`,` stored token: ${F(s)}`];if(!s)return c.push(` upstream check: skipped — nothing to check`,...M(a)),{stdout:c.join(`
95
+ `}async function d(n,r){let i=await import(`./account-store-BEqmysw9.js`).then(e=>e.t),a=await import(`./providers-DVvrXbtx.js`).then(e=>e.r);if(t(n,{valueFlags:c}))return{stdout:u(),stderr:``,exitCode:0};let o=e(n,{value:c,bool:l});if(`error`in o)return H(`oauth-token: ${o.error}`);if(o.bools.has(`--list`))return U(i.getAccounts,a.getRegisteredProviderIds,a.getRegisteredProviderConfig,i.getOAuthAccountInfo);if(o.bools.has(`--check`))return T(o.positionals);if(o.bools.has(`--expire`))return O(o.positionals);if(o.bools.has(`--renew`))return k(o.positionals);if(o.values.has(`--from-file`)||o.bools.has(`--intercept`))return L(o,n,r);let s=f(o);if(!s.ok)return s.result;let d=o.bools.has(`--force-login`),m=p(o,i,a);if(!m.ok)return m.result;let _=h(m.value,a.getRegisteredProviderConfig);if(!_.ok)return _.result;if(!d){let e=await g(m.value,_.value,i.getOAuthAccountInfo,i.ensureOAuthMaskReplica,s.value);if(e?.ok)return e.value;if(e)return e.result}return b(m.value,_.value,s.value,i.getOAuthAccountInfo,i.ensureOAuthMaskReplica)}function f(e){if(!e.values.has(`--scope`))return{ok:!0,value:void 0};let t=e.values.get(`--scope`)?.trim();return!t||t.startsWith(`-`)?{ok:!1,result:H(`oauth-token: --scope requires a value`)}:{ok:!0,value:t}}function p(e,t,n){if(e.values.has(`--provider`)){let t=e.values.get(`--provider`);return t?{ok:!0,value:t}:{ok:!1,result:H(`oauth-token: --provider requires a value`)}}if(e.positionals.length>0)return{ok:!0,value:e.positionals[0]};let r=t.getSelectedProvider();if(m(n.getRegisteredProviderConfig(r)))return{ok:!0,value:r};let i=n.getRegisteredProviderIds().find(e=>m(n.getRegisteredProviderConfig(e)));return i?{ok:!0,value:i}:{ok:!1,result:H(`oauth-token: no OAuth providers configured`)}}function m(e){return!!(e?.isOAuth&&(e.onOAuthLogin||e.onOAuthLoginIntercepted))}function h(e,t){let n=t(e);return n?m(n)?{ok:!0,value:n}:{ok:!1,result:H(`oauth-token: provider "${e}" is not an OAuth provider`)}:{ok:!1,result:H(`oauth-token: unknown provider "${e}"`)}}async function g(e,t,n,r,i){let a=n(e);return a&&!a.expired?_(e,a,i,r):!a?.expired||!t.onSilentRenew||!await C(t.onSilentRenew)?null:_(e,n(e),i,r)}async function _(e,t,n,r){if(n&&!s(t?.scopes,n))return null;let i=v(t?.maskedValue,t?.token);if(i)return{ok:!0,value:i};if(!t?.token)return null;let a=await r(e)??{},o=v(a.maskedValue,t.token);return o?{ok:!0,value:o}:{ok:!1,result:y(e,a.error)}}function v(e,t){return!e||t&&e===t?null:{stdout:`${e}\n`,stderr:``,exitCode:0}}function y(e,t){return H(`oauth-token: token held for ${e} but no masked replica${t?` (${t})`:``}`)}async function b(e,t,n,r,i){try{let a=await x(e,t,n);return a.error?a.error:S(e,r,i,a.succeeded)}catch(t){let n=t instanceof Error?t.message:String(t);return t instanceof Error&&t.name===`OAuthLaunchError`?(console.error(`[oauth-token] Provider ${e}: login could not be shown:`,n),H(`oauth-token: ${n}`)):(console.error(`[oauth-token] Provider ${e}: login failed:`,n),H(`oauth-token: login failed: ${n}`))}}async function x(e,t,n){let r=n?{scopes:n}:void 0,i=!1,a=()=>{i=!0};if(t.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:n}=await import(`./oauth-service-IlBYPvwr.js`),o=await n();return o?(await t.onOAuthLoginIntercepted(o,a,r),{error:null,succeeded:i}):{error:H(`oauth-token: provider "${e}" needs the controlled-browser interceptor, but no CDP transport is available in this runtime.`),succeeded:!1}}if(t.onOAuthLogin){let{createOAuthLauncher:e}=await import(`./oauth-service-IlBYPvwr.js`);return await t.onOAuthLogin(e(),a,r),{error:null,succeeded:i}}return{error:H(`oauth-token: provider "${e}" has no OAuth login hook`),succeeded:!1}}async function S(e,t,n,r){if(!r)return console.error(`[oauth-token] Provider ${e}: interactive login was not completed`),H(`oauth-token: interactive login was not completed (cancelled, timed out, or no one could approve it)`);let i=t(e);if(i?.token&&!i.expired){let t=v(i.maskedValue,i.token);if(t)return t;let r=await n(e)??{};return v(r.maskedValue,i.token)||y(e,r.error)}return i?.token?H(`oauth-token: login completed but the saved token is already expired`):(console.error(`[oauth-token] Provider ${e}: login completed but no token was saved`),H(`oauth-token: login completed but no token was saved`))}async function C(e){try{return await e()!==null}catch{return!1}}function w(e,t,n,r,i){let a=e[0];if(a)return a;let o=n();return r(o)?.[t]?o:i().find(e=>r(e)?.[t])}async function T(e){let{getSelectedProvider:t,getOAuthAccountInfo:n}=await import(`./account-store-BEqmysw9.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-DVvrXbtx.js`).then(e=>e.r),a=w(e,`onValidateToken`,t,r,i);if(!a)return H(`oauth-token --check: no provider supports an upstream token check`);let o=r(a);if(!o)return H(`oauth-token --check: unknown provider "${a}"`);if(!o.onValidateToken)return H(`oauth-token --check: provider "${a}" cannot be checked upstream (no onValidateToken hook); only locally stored state is known.`);let s=n(a),c=[`oauth-token --check ${a}`,` stored token: ${F(s)}`];if(!s)return c.push(` upstream check: skipped — nothing to check`,...M(a)),{stdout:c.join(`
96
96
  `)+`
97
97
  `,stderr:``,exitCode:3};let l=await j(o);if(l?.status===`accepted`){let e=l.userName?` (as ${l.userName})`:``;return c.push(` upstream check: ACCEPTED${e} — the provider honoured the token`),{stdout:c.join(`
98
98
  `)+`
@@ -100,7 +100,7 @@ Examples:
100
100
  `)+`
101
101
  `,stderr:``,exitCode:e}}return c.push(` upstream check: UNKNOWN — the check itself could not run${D(l?.detail)}`,` This says nothing about the token. Retry when the provider is reachable.`),{stdout:c.join(`
102
102
  `)+`
103
- `,stderr:``,exitCode:1}}function E(e,t,n){let r=` upstream check: REJECTED — the provider refused the token${D(n)}`;return t?[r,` A stored refresh token may still be able to replace it — silent renewal`,` has not been tried yet.`,``,` → Next: oauth-token ${e} --renew`,` If that is declined too: oauth-token ${e} --force-login (needs a human).`]:[r,` This provider has no silent renewal, so nothing automated is left.`,...M(e)]}function D(e){return e?` (${e})`:``}async function O(e){let{getAccounts:t,getSelectedProvider:n,saveOAuthAccount:r}=await import(`./account-store-lzZlhljv.js`).then(e=>e.t),{getRegisteredProviderConfig:i,getRegisteredProviderIds:a}=await import(`./providers-CUF9nsUE.js`).then(e=>e.r),o=w(e,`onSilentRenew`,n,i,a);if(!o)return H(`oauth-token --expire: no provider supports silent renewal`);let s=i(o);if(!s)return H(`oauth-token --expire: unknown provider "${o}"`);if(!s.onSilentRenew)return H(`oauth-token --expire: provider "${o}" has no onSilentRenew hook`);let c=t().find(e=>e.providerId===o);if(!c?.accessToken)return H(`oauth-token --expire: no stored OAuth account for "${o}"`);try{await r({...c,accessToken:c.accessToken,tokenExpiresAt:Date.now()-1e3})}catch(e){return H(`oauth-token --expire: failed to update "${o}": ${e instanceof Error?e.message:String(e)}`)}return{stdout:`oauth-token ${o}: stored token marked expired; next network op will trigger silent renewal.\n`,stderr:``,exitCode:0}}async function k(e){let{getSelectedProvider:t,getOAuthAccountInfo:n}=await import(`./account-store-lzZlhljv.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-CUF9nsUE.js`).then(e=>e.r),a=w(e,`onSilentRenew`,t,r,i);if(!a)return H(`oauth-token --renew: no provider supports silent renewal`);let o=r(a);if(!o)return H(`oauth-token --renew: unknown provider "${a}"`);if(!o.onSilentRenew)return H(`oauth-token --renew: provider "${a}" has no onSilentRenew hook`);let s=n(a),c=s?.token,l=[`oauth-token --renew ${a}`];l.push(` stored token: ${F(s)}`);let u=null,d=null;try{u=await o.onSilentRenew()}catch(e){d=e instanceof Error?e.message:String(e)}if(u){let e=n(a),t=!!(c&&e?.token&&c!==e.token);return l.push(` silent renewal: SUCCESS${t?` — token refreshed`:` (token unchanged)`}`),l.push(` renewed token: ${F(e)}`),{stdout:l.join(`
103
+ `,stderr:``,exitCode:1}}function E(e,t,n){let r=` upstream check: REJECTED — the provider refused the token${D(n)}`;return t?[r,` A stored refresh token may still be able to replace it — silent renewal`,` has not been tried yet.`,``,` → Next: oauth-token ${e} --renew`,` If that is declined too: oauth-token ${e} --force-login (needs a human).`]:[r,` This provider has no silent renewal, so nothing automated is left.`,...M(e)]}function D(e){return e?` (${e})`:``}async function O(e){let{getAccounts:t,getSelectedProvider:n,saveOAuthAccount:r}=await import(`./account-store-BEqmysw9.js`).then(e=>e.t),{getRegisteredProviderConfig:i,getRegisteredProviderIds:a}=await import(`./providers-DVvrXbtx.js`).then(e=>e.r),o=w(e,`onSilentRenew`,n,i,a);if(!o)return H(`oauth-token --expire: no provider supports silent renewal`);let s=i(o);if(!s)return H(`oauth-token --expire: unknown provider "${o}"`);if(!s.onSilentRenew)return H(`oauth-token --expire: provider "${o}" has no onSilentRenew hook`);let c=t().find(e=>e.providerId===o);if(!c?.accessToken)return H(`oauth-token --expire: no stored OAuth account for "${o}"`);try{await r({...c,accessToken:c.accessToken,tokenExpiresAt:Date.now()-1e3})}catch(e){return H(`oauth-token --expire: failed to update "${o}": ${e instanceof Error?e.message:String(e)}`)}return{stdout:`oauth-token ${o}: stored token marked expired; next network op will trigger silent renewal.\n`,stderr:``,exitCode:0}}async function k(e){let{getSelectedProvider:t,getOAuthAccountInfo:n}=await import(`./account-store-BEqmysw9.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-DVvrXbtx.js`).then(e=>e.r),a=w(e,`onSilentRenew`,t,r,i);if(!a)return H(`oauth-token --renew: no provider supports silent renewal`);let o=r(a);if(!o)return H(`oauth-token --renew: unknown provider "${a}"`);if(!o.onSilentRenew)return H(`oauth-token --renew: provider "${a}" has no onSilentRenew hook`);let s=n(a),c=s?.token,l=[`oauth-token --renew ${a}`];l.push(` stored token: ${F(s)}`);let u=null,d=null;try{u=await o.onSilentRenew()}catch(e){d=e instanceof Error?e.message:String(e)}if(u){let e=n(a),t=!!(c&&e?.token&&c!==e.token);return l.push(` silent renewal: SUCCESS${t?` — token refreshed`:` (token unchanged)`}`),l.push(` renewed token: ${F(e)}`),{stdout:l.join(`
104
104
  `)+`
105
105
  `,stderr:``,exitCode:0}}if(d)return l.push(` silent renewal: ERROR — ${d}`,...P(a)),{stdout:l.join(`
106
106
  `)+`
@@ -1,4 +1,4 @@
1
- import{t as e}from"./subcommand-flags-BZi7j78Q.js";import{r as t,t as n}from"./subcommand-help-CgO7wRS5.js";import{i as r,r as i}from"./jsh-discovery-D3Gk1cKA.js";import{a,i as o,r as s,s as c,t as l}from"./supervisor-DILjXQCB.js";const u=`usage: jshd <command> [options]
1
+ import{t as e}from"./subcommand-flags-BZi7j78Q.js";import{r as t,t as n}from"./subcommand-help-CgO7wRS5.js";import{i as r,r as i}from"./jsh-discovery-D3Gk1cKA.js";import{a,i as o,r as s,s as c,t as l}from"./supervisor-BtH2-9sE.js";const u=`usage: jshd <command> [options]
2
2
 
3
3
  Durable background jsh units: one realm worker each, restored on reload
4
4
  when --enable is set. Keep-alive follows the realm (pending timers and
@@ -34,7 +34,7 @@ Notes:
34
34
  `)+`
35
35
  `)}async function A(e,t,n,r){let i=t[0];if(!i)return Y(`missing unit name`);let o=L(n);if(o)return o;let s=P(n,r);if(!s)return Y(`kernel host has not booted yet — try again in a moment`);if(e===`stop`)return await s.stop(i)?J(`jshd: stopped '${i}'\n`):await a(n.fs,i)?J(`jshd: unit '${i}' is not running\n`):Y(`unknown unit '${i}'`);if(e===`restart`){let e=await s.restart(i);return e?J(`jshd: restarted '${i}' (pid ${e.pid})\n`):Y(`unknown unit '${i}'`)}return!await a(n.fs,i)&&!s.status(i)?Y(`unknown unit '${i}'`):(await s.rm(i),J(`jshd: removed '${i}'\n`))}async function j(t,n,r){let i=e(t,{value:T,bool:[`-f`,`--follow`]});if(`error`in i)return Y(i.error);let a=i.positionals[0];if(!a)return Y(`missing unit name`);let s=i.bools.has(`-f`)||i.bools.has(`--follow`),c=i.values.get(`-n`)??i.values.get(`--lines`),l=c===void 0?void 0:Number.parseInt(c,10);if(c!==void 0&&(!Number.isFinite(l)||l<0))return Y(`-n must be a non-negative integer`);let u=await o(n.fs,a),d=l===void 0?u:H(u,l);if(!s)return J(d.endsWith(`
36
36
  `)||d.length===0?d:`${d}\n`);let f=W(n),p=G(n);return f?U({ctx:n,name:a,displayed:d,seen:u.length,signal:f,sink:p}):(p?.(d),J(p?``:d.endsWith(`
37
- `)||d.length===0?d:`${d}\n`))}async function M(e,t,n,r){let i=e[0];if(!i)return Y(`missing unit name`);let a=L(t);if(a)return a;let o=P(t,n);return(o?await o.setEnabled(i,r):await N(t,i,r))?J(`jshd: ${r?`enabled`:`disabled`} '${i}'\n`):Y(`unknown unit '${i}'`)}async function N(e,t,n){let r=await a(e.fs,t);if(!r)return null;let i={...r,enabled:n},{writeUnitRecord:o}=await import(`./supervisor-DILjXQCB.js`).then(e=>e.o);return await o(e.fs,i),i}function P(e,t){let n=l();if(n)return n;let r=t.processManager??K();if(!r)return null;let i=q();return l({fs:e.fs,processManager:r,...i?{lickManager:i}:{},...t.realmFactory?{realmFactory:t.realmFactory}:{},buildContext:t=>F(e,t)})}function F(e,t){let n=new Map(e.env);for(let[e,r]of Object.entries(t.env))n.set(e,r);return{...e,cwd:t.cwd,env:n}}function I(e){if(typeof e!=`object`||!e)return!1;let t=e.canWrite;return typeof t==`function`&&!t.call(e,`/workspace/.jshd`)}function L(e){return I(e.fs)?Y(`not available inside a restricted scoop`):null}function R(e,t,n){let r=new Map(t.map(e=>[e.name,e]));return[...new Set([...e.map(e=>e.name),...r.keys()])].sort().map(t=>r.get(t)||z(e.find(e=>e.name===t),n))}function z(e,t){return{name:e.name,pid:null,state:`stopped`,restarts:0,uptimeMs:null,enabled:e.enabled,restart:e.restart,argv:e.argv,cwd:e.cwd,durable:t,lastExitCode:null}}function B(e){let t=e.pid===null?`-`:String(e.pid),n=V(e.uptimeMs);return[e.name.padEnd(15),t.padEnd(7),e.state.padEnd(9),String(e.restarts).padEnd(9),n.padEnd(6),String(e.enabled).padEnd(8),String(e.durable)].join(` `)}function V(e){if(e===null)return`-`;let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`}function H(e,t){if(t===0)return``;let n=e.split(`
37
+ `)||d.length===0?d:`${d}\n`))}async function M(e,t,n,r){let i=e[0];if(!i)return Y(`missing unit name`);let a=L(t);if(a)return a;let o=P(t,n);return(o?await o.setEnabled(i,r):await N(t,i,r))?J(`jshd: ${r?`enabled`:`disabled`} '${i}'\n`):Y(`unknown unit '${i}'`)}async function N(e,t,n){let r=await a(e.fs,t);if(!r)return null;let i={...r,enabled:n},{writeUnitRecord:o}=await import(`./supervisor-BtH2-9sE.js`).then(e=>e.o);return await o(e.fs,i),i}function P(e,t){let n=l();if(n)return n;let r=t.processManager??K();if(!r)return null;let i=q();return l({fs:e.fs,processManager:r,...i?{lickManager:i}:{},...t.realmFactory?{realmFactory:t.realmFactory}:{},buildContext:t=>F(e,t)})}function F(e,t){let n=new Map(e.env);for(let[e,r]of Object.entries(t.env))n.set(e,r);return{...e,cwd:t.cwd,env:n}}function I(e){if(typeof e!=`object`||!e)return!1;let t=e.canWrite;return typeof t==`function`&&!t.call(e,`/workspace/.jshd`)}function L(e){return I(e.fs)?Y(`not available inside a restricted scoop`):null}function R(e,t,n){let r=new Map(t.map(e=>[e.name,e]));return[...new Set([...e.map(e=>e.name),...r.keys()])].sort().map(t=>r.get(t)||z(e.find(e=>e.name===t),n))}function z(e,t){return{name:e.name,pid:null,state:`stopped`,restarts:0,uptimeMs:null,enabled:e.enabled,restart:e.restart,argv:e.argv,cwd:e.cwd,durable:t,lastExitCode:null}}function B(e){let t=e.pid===null?`-`:String(e.pid),n=V(e.uptimeMs);return[e.name.padEnd(15),t.padEnd(7),e.state.padEnd(9),String(e.restarts).padEnd(9),n.padEnd(6),String(e.enabled).padEnd(8),String(e.durable)].join(` `)}function V(e){if(e===null)return`-`;let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`}function H(e,t){if(t===0)return``;let n=e.split(`
38
38
  `);return n[n.length-1]===``&&n.pop(),`${n.slice(-t).join(`
39
39
  `)}${e.endsWith(`
40
40
  `)?`
@@ -1,4 +1,4 @@
1
- import{t as e}from"./record-ChU1ND2B.js";import{t,u as n}from"./descriptor-S4Jug1iP.js";import{t as r}from"./subcommand-flags-BZi7j78Q.js";import{t as i}from"./subcommand-help-CgO7wRS5.js";import{a,r as o,t as s}from"./memory-budget-Bcf7Eolo.js";import{d as c}from"./kernel-worker-CrTnmx6N.js";const l=`usage: memory <command> [options]
1
+ import{t as e}from"./record-ChU1ND2B.js";import{t,u as n}from"./descriptor-S4Jug1iP.js";import{t as r}from"./subcommand-flags-BZi7j78Q.js";import{t as i}from"./subcommand-help-CgO7wRS5.js";import{a,r as o,t as s}from"./memory-budget-Bcf7Eolo.js";import{d as c}from"./kernel-worker-Dseu067f.js";const l=`usage: memory <command> [options]
2
2
 
3
3
  Durable cone memory: one file per cone, rewritten by the memory-curator
4
4
  scoop after a chat freezes. This command inspects that system and pokes it.
@@ -38,7 +38,7 @@ Examples:
38
38
  memory log --limit 5
39
39
  memory curate --archive 2026-09-11T08-30-00Z-fix-build.md
40
40
  memory dream --all
41
- `,u=[`--cone`,`--archive`,`--limit`];function d(e){return{stdout:e,stderr:``,exitCode:0}}function f(e){return{stdout:``,stderr:`memory: ${e}\n`,exitCode:1}}function p(){let e=globalThis.__slicc_memory;return e&&typeof e.curate==`function`&&typeof e.dream==`function`?e:null}async function m(){let{isMemoryV2Enabled:e}=await import(`./memory-v2-flag-BkWGkfSv.js`);return!e()}async function h(e,t){try{let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}catch{return null}}async function g(n){let r=[e];try{let e=await n.readDir(t);for(let t of e)t.type===`directory`&&r.push(t.name)}catch{}return r}function _(e){return n({parentJid:null,folder:e}).memoryPath}async function v(e,t){let n=await g(e);return n.includes(t)?{folder:t}:{error:`unknown cone "${t}" (cones: ${n.join(`, `)})`}}function y(e){return e.memoryFailed===void 0?e.memoryPending?`pending`:e.memoryCuratedAt===void 0?e.memorySkipped?`skipped`:`none`:`curated`:`failed`}async function b(e,t){let n=r(e,{value:[`--cone`]});if(`error`in n)return f(n.error);let i=await v(t,n.values.get(`--cone`)??`cone`);if(`error`in i)return f(i.error);let a=_(i.folder),o=await h(t,a);return o===null?f(`no memory file at ${a}`):d(o.endsWith(`
41
+ `,u=[`--cone`,`--archive`,`--limit`];function d(e){return{stdout:e,stderr:``,exitCode:0}}function f(e){return{stdout:``,stderr:`memory: ${e}\n`,exitCode:1}}function p(){let e=globalThis.__slicc_memory;return e&&typeof e.curate==`function`&&typeof e.dream==`function`?e:null}async function m(){let{isMemoryV2Enabled:e}=await import(`./memory-v2-flag-BHVbti6Z.js`);return!e()}async function h(e,t){try{let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}catch{return null}}async function g(n){let r=[e];try{let e=await n.readDir(t);for(let t of e)t.type===`directory`&&r.push(t.name)}catch{}return r}function _(e){return n({parentJid:null,folder:e}).memoryPath}async function v(e,t){let n=await g(e);return n.includes(t)?{folder:t}:{error:`unknown cone "${t}" (cones: ${n.join(`, `)})`}}function y(e){return e.memoryFailed===void 0?e.memoryPending?`pending`:e.memoryCuratedAt===void 0?e.memorySkipped?`skipped`:`none`:`curated`:`failed`}async function b(e,t){let n=r(e,{value:[`--cone`]});if(`error`in n)return f(n.error);let i=await v(t,n.values.get(`--cone`)??`cone`);if(`error`in i)return f(i.error);let a=_(i.folder),o=await h(t,a);return o===null?f(`no memory file at ${a}`):d(o.endsWith(`
42
42
  `)||o===``?o:`${o}\n`)}const x=`/sessions/.curation/health.json`;async function S(e){let t=await h(e,x);if(t===null)return null;try{let e=JSON.parse(t);return typeof e.at!=`string`||!Array.isArray(e.failures)?null:{at:e.at,failures:e.failures.map(String)}}catch{return null}}async function C(e){let t=await c(e),n=[];for(let t of await g(e)){let r=_(t),i=await h(e,r);n.push({folder:t,path:r,chars:i===null?null:i.length})}let r={curated:0,failed:0,pending:0,skipped:0,none:0},i=new Map;for(let e of t){let t=y(e);if(r[t]++,t===`curated`){let t=e.cone??`cone`;i.set(t,(i.get(t)??0)+1)}}let l=[];r.failed>0&&l.push(`${r.failed} archive(s) whose last curation attempt failed — see \`memory log\``);for(let t of s)await h(e,t)!==null&&l.push(`${t} is no longer read — memory instructions live in ${o}; carry any customization over, then delete it`);for(let e of n){let t=i.get(e.folder)??0;t===0||(e.chars??0)>0||l.push(e.folder===`cone`?`${t} archive(s) report successful curation but the primary memory file is missing or empty`:`${t} archive(s) from cone "${e.folder}" report successful curation but its memory file (${e.path}) is missing or empty`)}return{memoryV2:!await m(),sessions:t.length,budgetChars:a(t.length),cones:n,curation:r,checks:l,scheduledCheck:await S(e)}}async function w(e,t){let n=r(e,{bool:[`--json`,`--check`]});if(`error`in n)return f(n.error);let i=await C(t),a=n.bools.has(`--check`)&&i.checks.length>0;if(n.bools.has(`--json`))return{stdout:`${JSON.stringify(i,null,2)}\n`,stderr:``,exitCode:+!!a};let o=`Memory v2: ${i.memoryV2?`ON`:`OFF — curation surfaces beyond the freezer pass are disabled`}\n`;o+=`Sessions: ${i.sessions} archived (memory budget ${i.budgetChars} chars)\n`,o+=`Memory files:
43
43
  `;for(let e of i.cones){let t=e.chars===null?`missing`:`${e.chars} chars`;o+=` ${e.folder.padEnd(14)}${e.path} (${t})\n`}let{curated:s,failed:c,pending:l,skipped:u,none:d}=i.curation;if(o+=`Curation: ${s} curated, ${c} failed, ${l} pending, ${u} skipped, ${d} unmarked\n`,i.checks.length>0){o+=`Health:
44
44
  `;for(let e of i.checks)o+=` FAIL ${e}\n`}else o+=`Health: ok
@@ -18,5 +18,5 @@ import{r as e,t}from"./subcommand-help-CgO7wRS5.js";const n=`session — export
18
18
  usage: session search <query> [--limit N]
19
19
  `}}function i(e,t,n){if(!e||e.startsWith(`-`))return{ok:!1,stderr:`session read: ${t} requires a number\n`};let r=Number(e);return!Number.isFinite(r)||r<n?{ok:!1,stderr:`session read: ${t} must be ${n===0?`a non-negative integer`:`a positive integer`}\n`}:{ok:!0,n:Math.floor(r)}}function a(e){let t=e.slice(1),n,r,a;for(let e=0;e<t.length;e++){let o=t[e];if(o===`--from`||o===`--count`){let n=i(t[e+1],o,o===`--from`?0:1);if(!n.ok)return n;o===`--from`?r=n.n:a=n.n,e++}else if(o.startsWith(`-`))return{ok:!1,stderr:`session read: unknown flag ${o}\n`};else if(n===void 0)n=o;else return{ok:!1,stderr:`session read: unexpected argument ${JSON.stringify(o)}\n`}}return n?{ok:!0,id:n,from:r,count:a}:{ok:!1,stderr:`session read: missing id
20
20
  usage: session read <id> [--from N --count M]
21
- `}}async function o(e,t){let n=r(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{searchSessions:e}=await import(`./session-search-index-CMRSS2CP.js`),r=await e(t.fs,n.query,{limit:n.limit});if(r.length===0)return{stdout:`# session search: ${n.query} (0 hits)\nNo matching messages in /sessions.\n`,stderr:``,exitCode:0};let i=[`# session search: ${n.query} (${r.length} hits)`];for(let e of r)i.push(`id=${e.id} score=${e.score.toFixed(2)} kind=${e.echoKind} role=${e.role}`),i.push(` session=${JSON.stringify(e.sessionTitle)} path=${e.path}`),i.push(` ${e.excerpt}`),i.push(``);return i.push(`Use: session read <id> [--from N --count M]`),{stdout:`${i.join(`
22
- `)}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`session search: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function s(e,t){let n=a(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{readSessionHit:e,SESSION_READ_BYTE_CAP:r}=await import(`./session-search-index-CMRSS2CP.js`),i=await e(t.fs,n.id,{from:n.from,count:n.count});return i?{stdout:`# session read: ${n.id}\npath=${i.hit.path} title=${JSON.stringify(i.hit.sessionTitle)}\nmessages ${i.from}–${i.from+i.count-1} of ${i.total} (remaining: ${i.remaining}${i.truncated?`, truncated to byte cap`:``})\nbyteCap=${r}\n\n`+i.text,stderr:``,exitCode:0}:{stdout:``,stderr:`session read: unknown id ${JSON.stringify(n.id)}\n`,exitCode:1}}catch(e){return{stdout:``,stderr:`session read: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function c(r,i,a,c){return r===`help`?{stdout:c?e(`session`,c,n):n,stderr:``,exitCode:0}:t(i.slice(1))?{stdout:e(`session`,r,n),stderr:``,exitCode:0}:r===`search`?o(i,a):s(i,a)}async function l(e,n,r){let{isMemoryV2Enabled:i}=await import(`./memory-v2-flag-BkWGkfSv.js`),a=i();if(t(e)){if(!a)return{stdout:r,stderr:``,exitCode:0};let t=e[0];return c(`help`,e,n,t&&t!==`--help`&&t!==`-h`?t:void 0)}let o=e[0];return o===`search`||o===`read`?a?c(o,e,n):{stdout:``,stderr:`session export: unknown subcommand ${JSON.stringify(o)} — usage: session export [--id <id>] [--output <path>]\n`,exitCode:1}:a?{stdout:``,stderr:`session: unknown subcommand ${JSON.stringify(o??``)} — usage: session export|search|read (see session --help)\n`,exitCode:1}:{stdout:``,stderr:`session export: unknown subcommand ${JSON.stringify(o??``)} — usage: session export [--id <id>] [--output <path>]\n`,exitCode:1}}export{l as dispatchSessionMemoryAware};
21
+ `}}async function o(e,t){let n=r(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{searchSessions:e}=await import(`./session-search-index-CN1zDLlx.js`),r=await e(t.fs,n.query,{limit:n.limit});if(r.length===0)return{stdout:`# session search: ${n.query} (0 hits)\nNo matching messages in /sessions.\n`,stderr:``,exitCode:0};let i=[`# session search: ${n.query} (${r.length} hits)`];for(let e of r)i.push(`id=${e.id} score=${e.score.toFixed(2)} kind=${e.echoKind} role=${e.role}`),i.push(` session=${JSON.stringify(e.sessionTitle)} path=${e.path}`),i.push(` ${e.excerpt}`),i.push(``);return i.push(`Use: session read <id> [--from N --count M]`),{stdout:`${i.join(`
22
+ `)}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`session search: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function s(e,t){let n=a(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{readSessionHit:e,SESSION_READ_BYTE_CAP:r}=await import(`./session-search-index-CN1zDLlx.js`),i=await e(t.fs,n.id,{from:n.from,count:n.count});return i?{stdout:`# session read: ${n.id}\npath=${i.hit.path} title=${JSON.stringify(i.hit.sessionTitle)}\nmessages ${i.from}–${i.from+i.count-1} of ${i.total} (remaining: ${i.remaining}${i.truncated?`, truncated to byte cap`:``})\nbyteCap=${r}\n\n`+i.text,stderr:``,exitCode:0}:{stdout:``,stderr:`session read: unknown id ${JSON.stringify(n.id)}\n`,exitCode:1}}catch(e){return{stdout:``,stderr:`session read: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function c(r,i,a,c){return r===`help`?{stdout:c?e(`session`,c,n):n,stderr:``,exitCode:0}:t(i.slice(1))?{stdout:e(`session`,r,n),stderr:``,exitCode:0}:r===`search`?o(i,a):s(i,a)}async function l(e,n,r){let{isMemoryV2Enabled:i}=await import(`./memory-v2-flag-BHVbti6Z.js`),a=i();if(t(e)){if(!a)return{stdout:r,stderr:``,exitCode:0};let t=e[0];return c(`help`,e,n,t&&t!==`--help`&&t!==`-h`?t:void 0)}let o=e[0];return o===`search`||o===`read`?a?c(o,e,n):{stdout:``,stderr:`session export: unknown subcommand ${JSON.stringify(o)} — usage: session export [--id <id>] [--output <path>]\n`,exitCode:1}:a?{stdout:``,stderr:`session: unknown subcommand ${JSON.stringify(o??``)} — usage: session export|search|read (see session --help)\n`,exitCode:1}:{stdout:``,stderr:`session export: unknown subcommand ${JSON.stringify(o??``)} — usage: session export [--id <id>] [--output <path>]\n`,exitCode:1}}export{l as dispatchSessionMemoryAware};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{St as t,et as n}from"./wc-shell-Cj705NBI.js";import{t as r}from"./slugify-BYJ6QVAt.js";import{t as i}from"./types-D8gIX-W-.js";var a=[{category:`jwt`,source:String.raw`ey[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`,flags:`g`},{category:`private-key`,source:`-----BEGIN [A-Z ]* PRIVATE KEY-----`+String.raw`[\s\S]*?`+`-----END [A-Z ]* PRIVATE KEY-----`,flags:`g`},{category:`bearer-token`,source:`Bearer [A-Za-z0-9._~+/=!-]+`,flags:`gi`},{category:`api-key`,source:`(?:sk-(?:live|test|prod|proj)-[A-Za-z0-9]{8,}|sk-ant-[A-Za-z0-9-]{8,}|xoxb-[A-Za-z0-9-]{10,}|xoxp-[A-Za-z0-9-]{10,}|AKIA[A-Z0-9]{16}|ghp_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{34})`,flags:`g`},{category:`password`,source:String.raw`\b(?:password|passwd|token|secret|api_key)\s*[=:]\s*\S+`,flags:`gi`}],o=`⟦REDACTED:[^⟧]*⟧`;function s(e,t){return e.start<t.end&&t.start<e.end}function c(e){let t=[];for(let n of e.matchAll(new RegExp(o,`g`))){let e=n.index;e!==void 0&&t.push({start:e,end:e+n[0].length})}return t}function l(e,t,n=1,r){let i=c(e),o=[],l=n,u=r?.categories?a.filter(e=>r.categories?.includes(e.category)):a;for(let{category:n,source:r,flags:a}of u)for(let c of e.matchAll(new RegExp(r,a))){let e=c.index;if(e===void 0)continue;let r={start:e,end:e+c[0].length};i.some(e=>s(e,r))||o.some(e=>s(e,r))||o.push({...r,id:`${t}${l++}`,category:n})}o.sort((e,t)=>e.start-t.start);let d=``,f=0;for(let{start:t,end:n,id:r,category:i}of o)d+=e.slice(f,t),d+=`⟦REDACTED:${i}:${r}⟧`,f=n;return d+=e.slice(f),{text:d,matches:o.map(({id:e,category:t})=>({id:e,category:t})),nextId:l}}var u=[`jwt`,`private-key`,`bearer-token`,`api-key`],d=`ar`;function f(){return{nextId:1}}function p(e,t){let{text:n,nextId:r}=l(e,d,t.nextId,{categories:u});return t.nextId=r,n}function m(e,t){if(typeof e==`string`)return p(e,t);if(Array.isArray(e)){let n=!1,r=[];for(let i of e){let e=m(i,t);e!==i&&(n=!0),r.push(e)}return n?r:e}if(typeof e==`object`&&e){let n=!1,r={};for(let[i,a]of Object.entries(e)){let e=m(a,t);e!==a&&(n=!0),r[i]=e}return n?r:e}return e}function h(e,t=f()){return m(e,t)}var g=`/sessions`,_=`/sessions/index.json`;async function ee(e){try{let t=await e.readFile(_,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function v(e){return`${g}/${e.filename}`}function y(e){let t=e,n=`Untitled`,r={},i=t.match(/^---\n([\s\S]*?)\n---\n+/);if(i){t=t.slice(i[0].length),Object.assign(r,te(i[1]));let e=i[1].match(/^title:\s*(.+?)\s*$/m);e&&(n=b(e[1]))}let a=t.match(/<!-- slicc:session-data\n([\s\S]*?)\n-->\n*/);if(a){try{let e=a[1].replace(/-- >/g,`-->`),t=JSON.parse(e);if(Array.isArray(t))return{title:n,messages:t,...r}}catch{}t=t.replace(/<!-- slicc:session-data\n[\s\S]*?\n-->\n*/,``)}return r.sidecar?{title:n,messages:[],...r}:(t=t.replace(/^#\s+[^\n]*\n+/,``),{title:n,messages:S(t),...r})}function te(e){let t={},n=x(e,`cost`),r=x(e,`models`);n&&(t.cost=n),r&&(t.models=r);let i=e.match(/^cone:\s*(.+?)\s*$/m)?.[1];i&&(t.cone=i);let a=e.match(/^coneLabel:\s*(.+?)\s*$/m)?.[1];a&&(t.coneLabel=b(a)),/^memorySkipped:\s*true\s*$/m.test(e)&&(t.memorySkipped=!0),/^live:\s*true\s*$/m.test(e)&&(t.live=!0);let o=Number(e.match(/^liveThrough:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(o)&&o>0&&(t.liveThrough=o);let s=Number(e.match(/^compactions:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(s)&&s>0&&(t.compactions=s);let c=e.match(/^id:\s*(\S+)\s*$/m)?.[1];c&&(t.id=c);let l=e.match(/^sidecar:\s*(\S+)\s*$/m)?.[1];return l&&(t.sidecar=l),t}function b(e){let t=e.trim();if(!t.startsWith(`"`))return t;try{let e=JSON.parse(t);if(typeof e==`string`)return e}catch{}return t.replace(/^"|"$/g,``)}function x(e,t){let n=RegExp(`^${t}:\\s*(.+?)\\s*$`,`m`).exec(e)?.[1];if(n)try{return JSON.parse(n)}catch{return}}function S(e){let t=[],n=/^## (User|Assistant)\s*\n/gm,r=[],i;for(;(i=n.exec(e))!==null;)r.push({role:i[1]===`User`?`user`:`assistant`,start:i.index,bodyStart:i.index+i[0].length});for(let n=0;n<r.length;n++){let i=n+1<r.length?r[n+1].start:e.length,a=e.slice(r[n].bodyStart,i).trim();t.push({id:`frozen-${n}`,role:r[n].role,content:a,timestamp:0})}return t}function C(e){let r=``;for(let i of e){let e=i.role===`user`?`User`:`Assistant`,a=i.role===`user`?n(i.content):i.content;if(r+=`## ${e}\n${a}\n\n`,i.attachments?.length&&(r+=`Attachments:\n${i.attachments.map(e=>`- ${t(e)}`).join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{St as t,et as n}from"./wc-shell-C71iKreG.js";import{t as r}from"./slugify-BYJ6QVAt.js";import{t as i}from"./types-D8gIX-W-.js";var a=[{category:`jwt`,source:String.raw`ey[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`,flags:`g`},{category:`private-key`,source:`-----BEGIN [A-Z ]* PRIVATE KEY-----`+String.raw`[\s\S]*?`+`-----END [A-Z ]* PRIVATE KEY-----`,flags:`g`},{category:`bearer-token`,source:`Bearer [A-Za-z0-9._~+/=!-]+`,flags:`gi`},{category:`api-key`,source:`(?:sk-(?:live|test|prod|proj)-[A-Za-z0-9]{8,}|sk-ant-[A-Za-z0-9-]{8,}|xoxb-[A-Za-z0-9-]{10,}|xoxp-[A-Za-z0-9-]{10,}|AKIA[A-Z0-9]{16}|ghp_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{34})`,flags:`g`},{category:`password`,source:String.raw`\b(?:password|passwd|token|secret|api_key)\s*[=:]\s*\S+`,flags:`gi`}],o=`⟦REDACTED:[^⟧]*⟧`;function s(e,t){return e.start<t.end&&t.start<e.end}function c(e){let t=[];for(let n of e.matchAll(new RegExp(o,`g`))){let e=n.index;e!==void 0&&t.push({start:e,end:e+n[0].length})}return t}function l(e,t,n=1,r){let i=c(e),o=[],l=n,u=r?.categories?a.filter(e=>r.categories?.includes(e.category)):a;for(let{category:n,source:r,flags:a}of u)for(let c of e.matchAll(new RegExp(r,a))){let e=c.index;if(e===void 0)continue;let r={start:e,end:e+c[0].length};i.some(e=>s(e,r))||o.some(e=>s(e,r))||o.push({...r,id:`${t}${l++}`,category:n})}o.sort((e,t)=>e.start-t.start);let d=``,f=0;for(let{start:t,end:n,id:r,category:i}of o)d+=e.slice(f,t),d+=`⟦REDACTED:${i}:${r}⟧`,f=n;return d+=e.slice(f),{text:d,matches:o.map(({id:e,category:t})=>({id:e,category:t})),nextId:l}}var u=[`jwt`,`private-key`,`bearer-token`,`api-key`],d=`ar`;function f(){return{nextId:1}}function p(e,t){let{text:n,nextId:r}=l(e,d,t.nextId,{categories:u});return t.nextId=r,n}function m(e,t){if(typeof e==`string`)return p(e,t);if(Array.isArray(e)){let n=!1,r=[];for(let i of e){let e=m(i,t);e!==i&&(n=!0),r.push(e)}return n?r:e}if(typeof e==`object`&&e){let n=!1,r={};for(let[i,a]of Object.entries(e)){let e=m(a,t);e!==a&&(n=!0),r[i]=e}return n?r:e}return e}function h(e,t=f()){return m(e,t)}var g=`/sessions`,_=`/sessions/index.json`;async function ee(e){try{let t=await e.readFile(_,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function v(e){return`${g}/${e.filename}`}function y(e){let t=e,n=`Untitled`,r={},i=t.match(/^---\n([\s\S]*?)\n---\n+/);if(i){t=t.slice(i[0].length),Object.assign(r,te(i[1]));let e=i[1].match(/^title:\s*(.+?)\s*$/m);e&&(n=b(e[1]))}let a=t.match(/<!-- slicc:session-data\n([\s\S]*?)\n-->\n*/);if(a){try{let e=a[1].replace(/-- >/g,`-->`),t=JSON.parse(e);if(Array.isArray(t))return{title:n,messages:t,...r}}catch{}t=t.replace(/<!-- slicc:session-data\n[\s\S]*?\n-->\n*/,``)}return r.sidecar?{title:n,messages:[],...r}:(t=t.replace(/^#\s+[^\n]*\n+/,``),{title:n,messages:S(t),...r})}function te(e){let t={},n=x(e,`cost`),r=x(e,`models`);n&&(t.cost=n),r&&(t.models=r);let i=e.match(/^cone:\s*(.+?)\s*$/m)?.[1];i&&(t.cone=i);let a=e.match(/^coneLabel:\s*(.+?)\s*$/m)?.[1];a&&(t.coneLabel=b(a)),/^memorySkipped:\s*true\s*$/m.test(e)&&(t.memorySkipped=!0),/^live:\s*true\s*$/m.test(e)&&(t.live=!0);let o=Number(e.match(/^liveThrough:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(o)&&o>0&&(t.liveThrough=o);let s=Number(e.match(/^compactions:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(s)&&s>0&&(t.compactions=s);let c=e.match(/^id:\s*(\S+)\s*$/m)?.[1];c&&(t.id=c);let l=e.match(/^sidecar:\s*(\S+)\s*$/m)?.[1];return l&&(t.sidecar=l),t}function b(e){let t=e.trim();if(!t.startsWith(`"`))return t;try{let e=JSON.parse(t);if(typeof e==`string`)return e}catch{}return t.replace(/^"|"$/g,``)}function x(e,t){let n=RegExp(`^${t}:\\s*(.+?)\\s*$`,`m`).exec(e)?.[1];if(n)try{return JSON.parse(n)}catch{return}}function S(e){let t=[],n=/^## (User|Assistant)\s*\n/gm,r=[],i;for(;(i=n.exec(e))!==null;)r.push({role:i[1]===`User`?`user`:`assistant`,start:i.index,bodyStart:i.index+i[0].length});for(let n=0;n<r.length;n++){let i=n+1<r.length?r[n+1].start:e.length,a=e.slice(r[n].bodyStart,i).trim();t.push({id:`frozen-${n}`,role:r[n].role,content:a,timestamp:0})}return t}function C(e){let r=``;for(let i of e){let e=i.role===`user`?`User`:`Assistant`,a=i.role===`user`?n(i.content):i.content;if(r+=`## ${e}\n${a}\n\n`,i.attachments?.length&&(r+=`Attachments:\n${i.attachments.map(e=>`- ${t(e)}`).join(`
2
2
  `)}\n\n`),i.toolCalls)for(let e of i.toolCalls)r+=`### Tool: ${e.name}\nInput: ${JSON.stringify(e.input,null,2)}\nResult: ${e.result??``}\n\n`}return r}var ne=`<!-- slicc:session-data
3
3
  `,re=`
4
4
  -->`;function ie(e){return e.startsWith(`pending-`)||e.startsWith(`live-`)}function ae(e,t){return e.find(e=>e.live===!0&&(e.cone??`cone`)===t)}function w(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function T(e){return r(e,{maxLen:48,fallback:`session`})}function E(e){let t=e.find(e=>e.role===`user`);if(!t?.content)return`untitled-session`;let n=t.content.trim().replace(/\s+/g,` `);return n.length>60?`${n.slice(0,60)}…`:n||`untitled-session`}function D(e){return e.map(e=>{let t={id:e.id,role:e.role,content:e.content,timestamp:e.timestamp};return e.attachments?.length&&(t.attachments=e.attachments),e.toolCalls?.length&&(t.toolCalls=e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,...e.result===void 0?{}:{result:e.result},...e.isError?{isError:e.isError}:{}}))),e.source&&(t.source=e.source),e.channel&&(t.channel=e.channel),e.compaction&&(t.compaction=e.compaction),t})}function O(e,t,n){return!t||t===n?e:e.split(t).join(n)}function k(e){let t=f(),n={...e,title:p(e.title,t),messages:h(e.messages,t)},r=(n.cost?`cost: ${JSON.stringify(n.cost)}\n`:``)+(n.models?`models: ${JSON.stringify(n.models)}\n`:``),i=(n.cone?`cone: ${n.cone}\n`:``)+(n.coneLabel?`coneLabel: ${JSON.stringify(n.coneLabel)}\n`:``)+(n.memorySkipped?`memorySkipped: true
@@ -1,3 +1,3 @@
1
- import{t as e}from"./types-D8gIX-W-.js";import{c as t,u as n}from"./kernel-worker-CrTnmx6N.js";import"./frozen-archive-writer-BWuT2QtJ.js";function r(e){let n=`${e.endsWith(`.md`)?e.slice(0,-3):e.replace(/\.md$/i,``)}.jsonl`;return n.startsWith(`/`)?n:`${t}/${n}`}async function i(e,t,r){let i=n(t);if(i.messages.length>0||!i.sidecar)return i;let a=await u(e,r??i.sidecar.replace(/\.jsonl$/i,`.md`));return a?{...i,messages:a}:i}function a(e){let t=[],n=null;for(let r of e.split(`
1
+ import{t as e}from"./types-D8gIX-W-.js";import{c as t,u as n}from"./kernel-worker-Dseu067f.js";import"./frozen-archive-writer-DYPhPMg7.js";function r(e){let n=`${e.endsWith(`.md`)?e.slice(0,-3):e.replace(/\.md$/i,``)}.jsonl`;return n.startsWith(`/`)?n:`${t}/${n}`}async function i(e,t,r){let i=n(t);if(i.messages.length>0||!i.sidecar)return i;let a=await u(e,r??i.sidecar.replace(/\.jsonl$/i,`.md`));return a?{...i,messages:a}:i}function a(e){let t=[],n=null;for(let r of e.split(`
2
2
  `)){let e=r.trim();if(!e)continue;let i=o(e);if(i){if(i.role===`user`)t.push(s(i)),n=null;else if(i.role===`assistant`){let e=c(i);t.push(e),n=e}else i.role===`toolResult`&&l(n,i)}}return t}function o(e){try{return JSON.parse(e)}catch{return null}}function s(e){return{id:e.id??m(`u`),role:`user`,content:f(e.content),timestamp:e.timestamp??0,...e.source?{source:e.source}:{},...e.channel?{channel:e.channel}:{},...e.attachments?.length?{attachments:e.attachments}:{}}}function c(e){let t=p(e.content);return{id:e.id??m(`a`),role:`assistant`,content:f(e.content),timestamp:e.timestamp??0,...t.length?{toolCalls:t}:{},...e.source?{source:e.source}:{},...e.compaction?{compaction:e.compaction}:{},...e.attachments?.length?{attachments:e.attachments}:{}}}function l(e,t){if(!t.toolCallId||!e?.toolCalls)return;let n=e.toolCalls.find(e=>e.id===t.toolCallId);n&&(n.result=f(t.content),t.isError&&(n.isError=!0))}async function u(t,n){let i=r(n);try{let e=await t.readFile(i,{encoding:`utf-8`});return a(typeof e==`string`?e:new TextDecoder().decode(e))}catch(t){if(t instanceof e&&t.code===`ENOENT`)return null;throw t}}async function d(t,n){let i=r(n);try{await t.rm(i)}catch(t){if(t instanceof e&&t.code===`ENOENT`)return;throw t}}function f(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
3
3
  `)}function p(e){return typeof e==`string`?[]:e.filter(e=>e.type===`toolCall`).map(e=>({id:e.id,name:e.name,input:e.arguments}))}function m(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}export{i as loadFrozenArchive,d as removeSessionJsonl};
@@ -1,3 +1,3 @@
1
- import{c as e,d as t}from"./kernel-worker-CrTnmx6N.js";import{loadFrozenArchive as n}from"./session-jsonl-C7a0swa5.js";const r=`/sessions/.search-index.json`,i=12e3,a=4e3;async function o(e,t){return typeof e.readdir==`function`?e.readdir(t):typeof e.readDir==`function`?(await e.readDir(t)).map(e=>e.name):[]}const s={fields:[`title`,`body`],storeFields:[`title`,`body`,`sessionId`,`sessionTitle`,`filename`,`messageId`,`messageIndex`,`role`,`echoKind`,`path`],idField:`id`,processTerm:e=>{let t=e.toLowerCase();return t.length<2?null:j(t)},searchOptions:{boost:{title:4,body:1},prefix:!0}},c={original:1,summary:.35,echo:.15};function l(e){if(e.compaction)return`summary`;let t=e.content??``;return/<context-summary>/i.test(t)||/Earlier conversation messages were compacted/i.test(t)||/full transcript of the conversation before this compaction is saved at/i.test(t)?`summary`:/^# session (search|read):/m.test(t)||/\bid=sess\/[^\s]+/.test(t)||e.role===`assistant`&&e.toolCalls?.some(e=>e.name===`bash`&&typeof e.input==`object`&&e.input!==null&&/session\s+(search|read)\b/.test(String(e.input.command??``)))?`echo`:`original`}function u(e,t){return`sess/${e}/msg/${t}`}function d(e){let t=/^sess\/([^/]+)\/msg\/(.+)$/.exec(e);return t?{sessionId:t[1],messageId:t[2]}:null}function f(e){let t=`${e.sessionsDir??`/sessions`}/${e.filename}`,n=[];return e.messages.forEach((r,i)=>{let o=r.id||`i${i}`,s=[k(r.content??``,a)];for(let e of r.toolCalls??[])s.push(e.name,k(A(e.input),a)),e.result&&s.push(k(e.result,a));let c=k(s.filter(Boolean).join(`
1
+ import{c as e,d as t}from"./kernel-worker-Dseu067f.js";import{loadFrozenArchive as n}from"./session-jsonl-D_pTYppB.js";const r=`/sessions/.search-index.json`,i=12e3,a=4e3;async function o(e,t){return typeof e.readdir==`function`?e.readdir(t):typeof e.readDir==`function`?(await e.readDir(t)).map(e=>e.name):[]}const s={fields:[`title`,`body`],storeFields:[`title`,`body`,`sessionId`,`sessionTitle`,`filename`,`messageId`,`messageIndex`,`role`,`echoKind`,`path`],idField:`id`,processTerm:e=>{let t=e.toLowerCase();return t.length<2?null:j(t)},searchOptions:{boost:{title:4,body:1},prefix:!0}},c={original:1,summary:.35,echo:.15};function l(e){if(e.compaction)return`summary`;let t=e.content??``;return/<context-summary>/i.test(t)||/Earlier conversation messages were compacted/i.test(t)||/full transcript of the conversation before this compaction is saved at/i.test(t)?`summary`:/^# session (search|read):/m.test(t)||/\bid=sess\/[^\s]+/.test(t)||e.role===`assistant`&&e.toolCalls?.some(e=>e.name===`bash`&&typeof e.input==`object`&&e.input!==null&&/session\s+(search|read)\b/.test(String(e.input.command??``)))?`echo`:`original`}function u(e,t){return`sess/${e}/msg/${t}`}function d(e){let t=/^sess\/([^/]+)\/msg\/(.+)$/.exec(e);return t?{sessionId:t[1],messageId:t[2]}:null}function f(e){let t=`${e.sessionsDir??`/sessions`}/${e.filename}`,n=[];return e.messages.forEach((r,i)=>{let o=r.id||`i${i}`,s=[k(r.content??``,a)];for(let e of r.toolCalls??[])s.push(e.name,k(A(e.input),a)),e.result&&s.push(k(e.result,a));let c=k(s.filter(Boolean).join(`
2
2
  `),a);!c.trim()&&!r.compaction||n.push({id:u(e.sessionId,o),title:e.sessionTitle,body:c,sessionId:e.sessionId,sessionTitle:e.sessionTitle,filename:e.filename,messageId:o,messageIndex:i,role:r.role,echoKind:l(r),path:t})}),n}const p=`/scoops`;async function m(e){let t;try{t=await o(e,p)}catch{return[]}let n=[];for(let r of t)try{let t=await o(e,`${p}/${r}/sessions`);for(let e of t)n.push(`${p}/${r}/sessions/${e}`)}catch{}return n.sort()}async function h(n){let r=(await t(n)).map(t=>({entry:t,sessionsDir:e}));for(let e of await m(n))for(let t of await g(n,e))r.push({entry:t,sessionsDir:e});return r}async function g(e,t){try{let n=await e.readFile(`${t}/index.json`,{encoding:`utf-8`}),r=typeof n==`string`?n:new TextDecoder().decode(n),i=JSON.parse(r);return Array.isArray(i)?i:[]}catch{return[]}}async function _(e){let t=(await import(`./es-BR4l6CGS.js`)).default,n=await h(e),i=[],a=new Set;for(let{entry:t,sessionsDir:r}of n)for(let n of await x(e,t,r))a.has(n.id)||(a.add(n.id),i.push(n));let o=new t(s);i.length&&o.addAll(i);let c={version:1,builtAt:Date.now(),archiveCount:n.length,fingerprint:C(n)};return await e.writeFile(r,JSON.stringify({meta:c,index:o.toJSON()})),{docs:i.length,archives:n.length}}async function v(e){let t=(await import(`./es-BR4l6CGS.js`)).default,n=C(await h(e));try{let i=await e.readFile(r,{encoding:`utf-8`}),a=typeof i==`string`?i:new TextDecoder().decode(i),o=JSON.parse(a);if(o.meta?.fingerprint===n&&o.index)return t.loadJS(o.index,s)}catch{}await _(e);let i=await e.readFile(r,{encoding:`utf-8`}),a=typeof i==`string`?i:new TextDecoder().decode(i),o=JSON.parse(a);return t.loadJS(o.index,s)}async function y(e,t,n={}){let r=Math.min(Math.max(1,n.limit??8),20),i=t.trim();if(!i)return[];let a=await v(e),o=a.search(i,{boost:{title:4,body:1},prefix:!0}),s=[];for(let e of o){let t=a.getStoredFields(e.id);if(!t)continue;let n=t.echoKind??`original`,r=e.score*(c[n]??1);s.push({id:String(e.id),score:r,echoKind:n,sessionId:t.sessionId,sessionTitle:t.sessionTitle,filename:t.filename,messageId:t.messageId,messageIndex:t.messageIndex,role:t.role,path:t.path,excerpt:w(t.body,i)})}return s.sort((e,t)=>t.score-e.score),s.slice(0,r)}async function b(e,t,n={}){let r=d(t);if(!r)return null;let i=await h(e),a=i.find(({entry:e})=>e.sessionId===r.sessionId)??i.find(({entry:e})=>e.filename.replace(/\.md$/i,``)===r.sessionId);if(!a)return null;let{entry:o,sessionsDir:s}=a,c=await S(e,o,s),l=c.findIndex((e,t)=>(e.id||`i${t}`)===r.messageId),u=Math.max(0,n.from??Math.max(0,l)),f=Math.max(1,n.count??3),p=c.slice(u,u+f),m=T(p,u),g=!1;for(;O(m)>12e3&&p.length>1;)p=p.slice(0,-1),m=T(p,u),g=!0;O(m)>12e3&&(m=`${k(m,11980)}\n…[truncated]\n`,g=!0);let _=p.length,v=Math.max(0,c.length-(u+_));return{hit:{sessionId:o.sessionId??r.sessionId,messageId:r.messageId,sessionTitle:o.title,path:`${s}/${o.filename}`},messages:p,from:u,count:_,total:c.length,remaining:v,truncated:g,text:m}}async function x(t,n,r=e){let i=await S(t,n,r);return f({sessionId:n.sessionId??n.filename.replace(/\.md$/i,``),sessionTitle:n.title,filename:n.filename,messages:i,sessionsDir:r})}async function S(t,r,i=e){try{let e=`${i}/${r.filename}`,a=await t.readFile(e,{encoding:`utf-8`}),o=typeof a==`string`?a:new TextDecoder().decode(a);return(await n(t,o,e)).messages}catch{return[]}}function C(e){return e.map(({entry:e,sessionsDir:t})=>`${t}/${e.filename}:${e.messageCount}:${e.frozenAt}:${e.sessionId??``}`).sort().join(`|`)}function w(e,t,n=80){let r=e.replace(/\s+/g,` `).trim();if(!r)return``;let i=t.toLowerCase().split(/\s+/).filter(e=>e.length>1),a=-1;for(let e of i)if(a=r.toLowerCase().indexOf(e),a>=0)break;if(a<0)return r.slice(0,n*2)+(r.length>n*2?`…`:``);let o=Math.max(0,a-n),s=Math.min(r.length,a+n);return`${o>0?`…`:``}${r.slice(o,s)}${s<r.length?`…`:``}`}function T(e,t){let n=[];return e.forEach((e,r)=>{let i=t+r,a=e.id||`i${i}`;n.push(`## [${i}] ${e.role} id=${a}`),e.content&&n.push(e.content);for(let t of e.toolCalls??[])n.push(`### tool ${t.name} (${t.id})${t.isError?` ERROR`:``}`),n.push(A(t.input)),t.result&&n.push(t.result);n.push(``)}),n.join(`
3
3
  `)}async function E(e){try{await e.rm(r)}catch{}}const D=new TextEncoder;function O(e){return D.encode(e).byteLength}function k(e,t){if(t<=0)return``;let n=D.encode(e);if(n.byteLength<=t)return e;let r=t;for(;r>0&&(n[r]&192)==128;)r--;return new TextDecoder().decode(n.subarray(0,r))}function A(e){try{return JSON.stringify(e)}catch{return String(e)}}function j(e){if(e.length<3)return e;let t=e;if(t.endsWith(`sses`)||t.endsWith(`ies`)?t=`${t.slice(0,-2)}`:t.endsWith(`ss`)||t.endsWith(`s`)&&t.length>3&&(t=t.slice(0,-1)),t.endsWith(`eed`))M(t.slice(0,-3))>0&&(t=t.slice(0,-1));else if(/(ed|ing)$/.test(t)){let e=t.replace(/(ed|ing)$/,``);/[aeiouy]/.test(e)&&(t=e,/(at|bl|iz)$/.test(t)?t=`${t}e`:/(.)\1$/.test(t)&&!/[lsz]$/.test(t)?t=t.slice(0,-1):M(t)===1&&N(t)&&(t=`${t}e`))}return t.endsWith(`y`)&&/[aeiouy]/.test(t.slice(0,-1))&&(t=`${t.slice(0,-1)}i`),t}function M(e){return(e.toLowerCase().replace(/[^aeiouy]+/g,`C`).replace(/[aeiouy]+/g,`V`).replace(/^C/,``).replace(/V$/,``).match(/VC/g)??[]).length}function N(e){if(e.length<3)return!1;let t=e[e.length-3],n=e[e.length-2],r=e[e.length-1],i=e=>/[aeiouy]/.test(e);return!i(t)&&i(n)&&!i(r)&&!/[wxy]/.test(r)}export{i as SESSION_READ_BYTE_CAP,E as invalidateSessionSearchIndex,b as readSessionHit,y as searchSessions};
@@ -1 +1 @@
1
- import{C as e,M as t,d as n,j as r,u as i,w as a}from"./main-Dxem3Ydy.js";var o=3e3;async function s(t,n){let i=e(n.storage);try{let e=new URL(`/api/flags`,`${n.workerBaseUrl.replace(/\/+$/,``)}/`);e.searchParams.set(`float`,t);let s=await c(e.toString(),n.fetchImpl??fetch,n.timeoutMs??o);if(!s)return;a(i,t,s),r(t,s)}catch{}}async function c(e,t,n){let r=new AbortController,i;try{let a=new Promise(e=>{i=setTimeout(()=>{r.abort(),e(null)},n)}),o=t(e,{cache:`no-store`,headers:{Accept:`application/json`},signal:r.signal}).then(async e=>e.ok?l(await e.json()):null).catch(()=>null);return await Promise.race([o,a])}catch{return null}finally{i!==void 0&&clearTimeout(i)}}function l(e){if(!u(e))return null;let t=e.flags;return!u(t)||Object.values(t).some(e=>typeof e!=`string`)?null:t}function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e,t){return s(e,{workerBaseUrl:g(t),storage:t.storage})}var f=18e5,p=null;function m(e,t,n=f){return h(),p=setInterval(()=>{d(e,t)},n),h}function h(){p!==null&&(clearInterval(p),p=null)}function g(e){let r=_(e.storage),a=t(e.envBaseUrl??null);if(r)return r;if(a)return a;if(!e.isDev)try{let t=new URL(e.locationHref);if(t.protocol===`http:`||t.protocol===`https:`)return t.origin}catch{}return e.isDev?n:i}function _(e){try{return t(e?.getItem(`slicc.trayWorkerBaseUrl`)??null)}catch{return null}}export{d as refreshFeatureFlagsForPage,m as scheduleFeatureFlagsRefresh};
1
+ import{C as e,M as t,d as n,j as r,u as i,w as a}from"./main-CfF8CFBr.js";var o=3e3;async function s(t,n){let i=e(n.storage);try{let e=new URL(`/api/flags`,`${n.workerBaseUrl.replace(/\/+$/,``)}/`);e.searchParams.set(`float`,t);let s=await c(e.toString(),n.fetchImpl??fetch,n.timeoutMs??o);if(!s)return;a(i,t,s),r(t,s)}catch{}}async function c(e,t,n){let r=new AbortController,i;try{let a=new Promise(e=>{i=setTimeout(()=>{r.abort(),e(null)},n)}),o=t(e,{cache:`no-store`,headers:{Accept:`application/json`},signal:r.signal}).then(async e=>e.ok?l(await e.json()):null).catch(()=>null);return await Promise.race([o,a])}catch{return null}finally{i!==void 0&&clearTimeout(i)}}function l(e){if(!u(e))return null;let t=e.flags;return!u(t)||Object.values(t).some(e=>typeof e!=`string`)?null:t}function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e,t){return s(e,{workerBaseUrl:g(t),storage:t.storage})}var f=18e5,p=null;function m(e,t,n=f){return h(),p=setInterval(()=>{d(e,t)},n),h}function h(){p!==null&&(clearInterval(p),p=null)}function g(e){let r=_(e.storage),a=t(e.envBaseUrl??null);if(r)return r;if(a)return a;if(!e.isDev)try{let t=new URL(e.locationHref);if(t.protocol===`http:`||t.protocol===`https:`)return t.origin}catch{}return e.isDev?n:i}function _(e){try{return t(e?.getItem(`slicc.trayWorkerBaseUrl`)??null)}catch{return null}}export{d as refreshFeatureFlagsForPage,m as scheduleFeatureFlagsRefresh};
@@ -1 +1 @@
1
- import{r as e,t}from"./base64-DzRgusa4.js";import{t as n}from"./mime-types-D7IV6i7k.js";import{t as r}from"./types-D8gIX-W-.js";import{n as i}from"./multipart-form-data-DopbgwRR.js";const a=`https://api.aem.live`;function o(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 s(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function c(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function l(e){return e.map(e=>e[`content-type`]===`application/folder`||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:s(e[`last-modified`]),lastModified:c(e[`last-modified`])})}var u=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=o(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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:a,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 i=await this.request(`GET`,this.toSourcePath(t));if(i.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem readFile failed: ${i.status}`,e);let a=new Uint8Array(await i.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,s(i.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let i=await this.request(`HEAD`,this.toSourcePath(t));if(i.status===404)return;if(i.status>=400)throw new r(`EIO`,`aem precondition HEAD failed: ${i.status}`,e);let a=s(i.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new r(`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 r(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),i=await this.cache.getBody(n);await this.assertUnchanged(e,n,i?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new r(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new r(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let i=await this.request(`GET`,this.toListPath(t));if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem list failed: ${i.status}`,e);let a=l(await i.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new r(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new r(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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=l(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}};function d(e,t,n){let r=i([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function f(e){return e.split(`/`).pop()||`data`}function p(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 m=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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`da access denied`,e);if(a.status>=400)throw new r(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=d(f(e),n(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(n.status>=400)throw new r(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let a=n.headers.get(`etag`)??``;await this.cache.putBody(i,t,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new r(`EACCES`,`da write denied`,e);if(l.status>=400)throw new r(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(i,t,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new r(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new r(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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 h(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 g=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new r(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status>=400)throw new r(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new r(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new r(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(i.status>=400)throw new r(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new r(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status===404)throw new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new r(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:e}=await import(`./account-store-lzZlhljv.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let y;function b(e){y=e}function x(){return y}const S=t,C=e,w=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),T=new Set([101,103,204,205,304]);function E(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new r(`EACCES`,e.error):e.errorCode===`invalid_request`?new r(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||w.has(String(e.errorCode))?new r(`EIO`,e.error):new r(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=S(e.bodyBase64)}catch(e){throw new r(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=T.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function D(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function O(e){let t=x();if(!t)throw new r(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new r(`EIO`,`mount transport failed: ${n.message}${D(t.adapter,e)}`)}return n.value}function k(e){return async t=>E(await O({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?C(t.body):void 0}}))}function A(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new r(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return E(await O({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?C(e.body):void 0}}))}}export{m as a,g as i,k as n,a as o,b as r,u as s,A as t};
1
+ import{r as e,t}from"./base64-DzRgusa4.js";import{t as n}from"./mime-types-D7IV6i7k.js";import{t as r}from"./types-D8gIX-W-.js";import{n as i}from"./multipart-form-data-DopbgwRR.js";const a=`https://api.aem.live`;function o(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 s(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function c(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function l(e){return e.map(e=>e[`content-type`]===`application/folder`||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:s(e[`last-modified`]),lastModified:c(e[`last-modified`])})}var u=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=o(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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:a,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 i=await this.request(`GET`,this.toSourcePath(t));if(i.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem readFile failed: ${i.status}`,e);let a=new Uint8Array(await i.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,s(i.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let i=await this.request(`HEAD`,this.toSourcePath(t));if(i.status===404)return;if(i.status>=400)throw new r(`EIO`,`aem precondition HEAD failed: ${i.status}`,e);let a=s(i.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new r(`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 r(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),i=await this.cache.getBody(n);await this.assertUnchanged(e,n,i?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new r(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new r(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let i=await this.request(`GET`,this.toListPath(t));if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem list failed: ${i.status}`,e);let a=l(await i.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new r(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new r(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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=l(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}};function d(e,t,n){let r=i([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function f(e){return e.split(`/`).pop()||`data`}function p(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 m=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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`da access denied`,e);if(a.status>=400)throw new r(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=d(f(e),n(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(n.status>=400)throw new r(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let a=n.headers.get(`etag`)??``;await this.cache.putBody(i,t,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new r(`EACCES`,`da write denied`,e);if(l.status>=400)throw new r(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(i,t,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new r(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new r(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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 h(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 g=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new r(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status>=400)throw new r(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new r(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new r(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(i.status>=400)throw new r(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new r(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status===404)throw new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new r(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:e}=await import(`./account-store-BEqmysw9.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let y;function b(e){y=e}function x(){return y}const S=t,C=e,w=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),T=new Set([101,103,204,205,304]);function E(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new r(`EACCES`,e.error):e.errorCode===`invalid_request`?new r(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||w.has(String(e.errorCode))?new r(`EIO`,e.error):new r(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=S(e.bodyBase64)}catch(e){throw new r(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=T.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function D(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function O(e){let t=x();if(!t)throw new r(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new r(`EIO`,`mount transport failed: ${n.message}${D(t.adapter,e)}`)}return n.value}function k(e){return async t=>E(await O({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?C(t.body):void 0}}))}function A(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new r(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return E(await O({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?C(e.body):void 0}}))}}export{m as a,g as i,k as n,a as o,b as r,u as s,A as t};