sliccy 6.167.0 → 6.169.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 (250) hide show
  1. package/README.md +6 -5
  2. package/dist/node-server/_shared/agent-wire-types.d.ts +9 -1
  3. package/dist/node-server/_shared/agent-wire-types.d.ts.map +1 -1
  4. package/dist/node-server/_shared/computer-protocol.d.ts +2 -0
  5. package/dist/node-server/_shared/computer-protocol.d.ts.map +1 -1
  6. package/dist/node-server/_shared/tray-sync-protocol.d.ts +119 -3
  7. package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
  8. package/dist/node-server/_shared/tray-sync-protocol.js +132 -2
  9. package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
  10. package/dist/node-server/computer-demo.d.ts +36 -0
  11. package/dist/node-server/computer-demo.js +126 -0
  12. package/dist/node-server/index.js +13 -3
  13. package/dist/node-server/runtime-flags.d.ts +2 -0
  14. package/dist/node-server/runtime-flags.js +5 -0
  15. package/dist/ui/.vite/manifest.json +275 -260
  16. package/dist/ui/assets/{SKILL-BGEZa-y0.js → SKILL-BTHo2BzY.js} +1 -1
  17. package/dist/ui/assets/{SKILL-Bpepfqq0.js → SKILL-BULOq3ys.js} +1 -1
  18. package/dist/ui/assets/{SKILL-DEFDsScb.js → SKILL-CLL4Q13w.js} +1 -1
  19. package/dist/ui/assets/SKILL-maxwOcxi.js +1 -0
  20. package/dist/ui/assets/{account-store-B05_LKnj.js → account-store-C0smCH0b.js} +1 -1
  21. package/dist/ui/assets/{account-store-CNTI4kr_.js → account-store-_oWY-N-g.js} +2 -2
  22. package/dist/ui/assets/{adobe-nu3irXcy.js → adobe-D8bfhWFa.js} +1 -1
  23. package/dist/ui/assets/{adobe-CRRWEbtf.js → adobe-i2veKh2G.js} +2 -2
  24. package/dist/ui/assets/{agent-panels-DvH_qfTh.js → agent-panels-Bt83ejkl.js} +1 -1
  25. package/dist/ui/assets/{almost-bash-shell-headless-BA5r_r61.js → almost-bash-shell-headless-CXYALRet.js} +521 -582
  26. package/dist/ui/assets/{apply-layout-CASSSWEy.js → apply-layout-C4DuaXQ1.js} +1 -1
  27. package/dist/ui/assets/approval-timeout-BQ29Z0gf.js +1 -0
  28. package/dist/ui/assets/{apps-BGe9_zJ7.js → apps-DpExQYs8.js} +1 -1
  29. package/dist/ui/assets/{azure-openai-C-Iw82HZ.js → azure-openai-CGgFuiTh.js} +1 -1
  30. package/dist/ui/assets/{azure-openai-DuJciOKd.js → azure-openai-Cm0dqkf0.js} +1 -1
  31. package/dist/ui/assets/{backend-hostfs-DdAVlPMP.js → backend-hostfs-BZXs8PNk.js} +1 -1
  32. package/dist/ui/assets/browser-DuyhpHbR.js +1 -0
  33. package/dist/ui/assets/{capability-C2eJ1wdx.js → capability-SIitRcq_.js} +2 -2
  34. package/dist/ui/assets/{cdp-DG8TVjf3.js → cdp-UL1FYYjc.js} +2 -2
  35. package/dist/ui/assets/{cerebras-Xadzrxfp.js → cerebras-BEKAS5HH.js} +1 -1
  36. package/dist/ui/assets/{cerebras-BXwtUxTj.js → cerebras-nQZqQsKF.js} +1 -1
  37. package/dist/ui/assets/{client-BDN4zG90.js → client-_vVqanZy.js} +1 -1
  38. package/dist/ui/assets/{composer-speech-_uq5e0Bo.js → composer-speech-BPb0h67H.js} +1 -1
  39. package/dist/ui/assets/{connect-surface-odDz37TJ.js → connect-surface-EJ0FRStY.js} +1 -1
  40. package/dist/ui/assets/context-compaction-Dpr7xgBZ.js +58 -0
  41. package/dist/ui/assets/core-DWdpOAZd.js +62 -0
  42. package/dist/ui/assets/core-w0-0FXns.js +36 -0
  43. package/dist/ui/assets/{directed-approval-D_AXAvuz.js → directed-approval-CPSbebEZ.js} +1 -1
  44. package/dist/ui/assets/{discovery-preference-TziZ7Yxu.js → discovery-preference-G3mw_EUO.js} +1 -1
  45. package/dist/ui/assets/encode-frame-30wbFN-H.js +1 -0
  46. package/dist/ui/assets/engine-CzMNXd8U.js +1 -0
  47. package/dist/ui/assets/{ensure-speech-assets-DTj236n-.js → ensure-speech-assets-DPjgwmlG.js} +1 -1
  48. package/dist/ui/assets/es-DJTRBqjm.js +52 -0
  49. package/dist/ui/assets/{extension-ops-DNPAsYbK.js → extension-ops-B2RMipFn.js} +1 -1
  50. package/dist/ui/assets/{float-topology-CurCyQFy.js → float-topology-CyZCUfkj.js} +1 -1
  51. package/dist/ui/assets/{follower-navigate-watcher-C98XMw_C.js → follower-navigate-watcher-BAstHBQ5.js} +1 -1
  52. package/dist/ui/assets/frames-7E6RloFP.js +1 -0
  53. package/dist/ui/assets/{frozen-archive-writer-BIzZxx8R.js → frozen-archive-writer-rq_r_D3R.js} +2 -2
  54. package/dist/ui/assets/{fs-CJs9n90Q.js → fs-B9TgYyVA.js} +2 -2
  55. package/dist/ui/assets/{fs-Bq8bUwe2.js → fs-KJBUdRz_.js} +1 -1
  56. package/dist/ui/assets/{gelatiere-store-BY0hZvSS.js → gelatiere-store-DIE4b-Va.js} +1 -1
  57. package/dist/ui/assets/gelatiere-unit-wx8F8dnF.js +1 -0
  58. package/dist/ui/assets/{github-D1gd3q6u.js → github-CgEE40ok.js} +2 -2
  59. package/dist/ui/assets/{github-uDwUwz5H.js → github-_GgWC1Vq.js} +1 -1
  60. package/dist/ui/assets/{github-auth-CzzE1eDf.js → github-auth-Ba7C_Kly.js} +1 -1
  61. package/dist/ui/assets/{github-copilot-Bx2lXrwK.js → github-copilot-jobL3_Cf.js} +1 -1
  62. package/dist/ui/assets/{github-copilot-DidNEEe_.js → github-copilot-rsfkYfvK.js} +1 -1
  63. package/dist/ui/assets/{github-install--_xp8s-S.js → github-install-DtlYn56m.js} +1 -1
  64. package/dist/ui/assets/{github-zip-Bs35nBig.js → github-zip-BanSb9qW.js} +1 -1
  65. package/dist/ui/assets/{guest-tool-gate-B-lZT9hl.js → guest-tool-gate-C6sp1l3H.js} +1 -1
  66. package/dist/ui/assets/{hear-BNmJphKg.js → hear-zSghqsv6.js} +1 -1
  67. package/dist/ui/assets/{help-C7Nq107k.js → help-BkjaKwT1.js} +1 -1
  68. package/dist/ui/assets/{host-iTtS0MRF.js → host-BjOvrhMS.js} +1 -1
  69. package/dist/ui/assets/host-command-XUdketMY.js +28 -0
  70. package/dist/ui/assets/icons-BMNa26vG.js +1 -0
  71. package/dist/ui/assets/idle-compaction-CwYw083A.js +1 -0
  72. package/dist/ui/assets/{installer-C0xiAs69.js → installer-CYXMipeW.js} +1 -1
  73. package/dist/ui/assets/interrupted-work-recovery-p8rpTJ6o.js +1 -0
  74. package/dist/ui/assets/{isomorphic-git-B7et_8Xe.js → isomorphic-git-B9eVtfwq.js} +10 -10
  75. package/dist/ui/assets/{isomorphic-git-D2fV6xS-.js → isomorphic-git-DXMEKpHT.js} +7 -7
  76. package/dist/ui/assets/{js-realm-worker-B9Rz0g1p.js → js-realm-worker-B9VuUz7Q.js} +2 -2
  77. package/dist/ui/assets/{jsh-executor-C7QPZ2Qr.js → jsh-executor-BhNH2E0v.js} +4 -4
  78. package/dist/ui/assets/{jsh-runtime-extensions-ddeGEOUw.js → jsh-runtime-extensions-CmdnQhXG.js} +1 -1
  79. package/dist/ui/assets/kernel-worker-CBI5EKGn.js +1186 -0
  80. package/dist/ui/assets/keys-Bluq5eTH.js +1 -0
  81. package/dist/ui/assets/lick-urls-CgPiVwD-.js +1 -0
  82. package/dist/ui/assets/{lick-ws-bridge-BcAhlead.js → lick-ws-bridge-BFrcBnVV.js} +1 -1
  83. package/dist/ui/assets/lick-ws-bridge-DVoxwaqS.js +1 -0
  84. package/dist/ui/assets/{live-session-snapshot-COMr2v0o.js → live-session-snapshot-Cw5xb5EQ.js} +1 -1
  85. package/dist/ui/assets/{local-llm-DdGb9WMG.js → local-llm-BRe_Kttg.js} +1 -1
  86. package/dist/ui/assets/{local-llm-DqeU7kV3.js → local-llm-C7T1M_NI.js} +1 -1
  87. package/dist/ui/assets/{main-jc6OS8lz.js → main-BfonTdzP.js} +3 -3
  88. package/dist/ui/assets/{main-cherry-BGZmJFd_.js → main-cherry-Cty_ShgD.js} +1 -1
  89. package/dist/ui/assets/{memory-curation-seam-B8pprlUo.js → memory-curation-seam-dmTVk3Ov.js} +1 -1
  90. package/dist/ui/assets/{memory-health-CGkpyA7o.js → memory-health-9iNdh0Ac.js} +1 -1
  91. package/dist/ui/assets/memory-v2-flag-D4biUAiV.js +1 -0
  92. package/dist/ui/assets/{memory-write-execute-B-ahXjaO.js → memory-write-execute-C9xS6Q1z.js} +1 -1
  93. package/dist/ui/assets/{mount-FkNAB0be.js → mount-B_VZbcPY.js} +1 -1
  94. package/dist/ui/assets/{mount-BzdPNQoA.js → mount-Bq4ov4Wg.js} +3 -3
  95. package/dist/ui/assets/{mount-bridge-client-BO0N4wwP.js → mount-bridge-client-BOZDQLbT.js} +1 -1
  96. package/dist/ui/assets/{mount-bridge-client-CRnohfom.js → mount-bridge-client-BRywSH1d.js} +1 -1
  97. package/dist/ui/assets/{mv-DRuZuDHt.js → mv-BE_lEtyG.js} +1 -1
  98. package/dist/ui/assets/{new-session-B8iOhaK0.js → new-session-BJqFQPRu.js} +2 -2
  99. package/dist/ui/assets/{oauth-bootstrap-B9PwK4-d.js → oauth-bootstrap-CFXmccC5.js} +2 -2
  100. package/dist/ui/assets/{oauth-service-UTPOqIwj.js → oauth-service-CRmx6zI1.js} +1 -1
  101. package/dist/ui/assets/{oauth-service-Bkaz0Dt4.js → oauth-service-WTeDvR5m.js} +1 -1
  102. package/dist/ui/assets/{onboarding-orchestrator-Cc8Glrem.js → onboarding-orchestrator-M3HJvymL.js} +1 -1
  103. package/dist/ui/assets/{openai-codex-BrQ1tsgu.js → openai-codex-BWGWiycb.js} +1 -1
  104. package/dist/ui/assets/{openai-codex-DmHr_2RR.js → openai-codex-NAo35j43.js} +1 -1
  105. package/dist/ui/assets/{openrouter-BvM36eS5.js → openrouter-Bhxgi8JW.js} +1 -1
  106. package/dist/ui/assets/{openrouter-free-CFBzPY5J.js → openrouter-free-DersFAEc.js} +1 -1
  107. package/dist/ui/assets/{openrouter-free-CUKlyrhq.js → openrouter-free-Dl2pScMt.js} +1 -1
  108. package/dist/ui/assets/{openrouter-oauth-DOdpRMfw.js → openrouter-oauth-C3bVnGt2.js} +1 -1
  109. package/dist/ui/assets/{openrouter-oauth-RC0CxY4X.js → openrouter-oauth-DW4_wGaN.js} +1 -1
  110. package/dist/ui/assets/{openrouter-C6WDBJvB.js → openrouter-sloSkMqY.js} +1 -1
  111. package/dist/ui/assets/{opfs-mount-B78yj9gx.js → opfs-mount-FspqzE40.js} +1 -1
  112. package/dist/ui/assets/{page-approval-service-Dy-UA1aK.js → page-approval-service-BkqDCbBQ.js} +1 -1
  113. package/dist/ui/assets/panel-rpc-handlers-CwCdqXzk.js +2 -0
  114. package/dist/ui/assets/{panelize-shell-CFPiIneK.js → panelize-shell-c-tVlGNY.js} +1 -1
  115. package/dist/ui/assets/{pi-edit-execution-BDl_Xp_M.js → pi-edit-execution-Brw1YFDp.js} +1 -1
  116. package/dist/ui/assets/{port-bridge-client-ff8DctEN.js → port-bridge-client-CZFX4fUT.js} +1 -1
  117. package/dist/ui/assets/{port-bridge-client-H03Pohgj.js → port-bridge-client-CkkC3v5w.js} +1 -1
  118. package/dist/ui/assets/{provider-1ByYSphI.js → provider-C7zRpxoe.js} +2 -2
  119. package/dist/ui/assets/{provider-Df8LFEZ7.js → provider-DsHcYBTa.js} +1 -1
  120. package/dist/ui/assets/{provider-settings-Bk-fk9dp.js → provider-settings-BKCma-Jb.js} +1 -1
  121. package/dist/ui/assets/provider-store-access-BfDZO7Ly.js +1 -0
  122. package/dist/ui/assets/provider-store-access-CYticOn7.js +1 -0
  123. package/dist/ui/assets/{providers-T_FH_8cU.js → providers-DDnH2Ikl.js} +1 -1
  124. package/dist/ui/assets/{providers-Q92pCQ8h.js → providers-DEiO6D-5.js} +2 -2
  125. package/dist/ui/assets/{proxied-fetch-DARKNygr.js → proxied-fetch-CPL8wJM2.js} +1 -1
  126. package/dist/ui/assets/{proxied-fetch-Bl8AeYdt.js → proxied-fetch-CnCvBaGV.js} +1 -1
  127. package/dist/ui/assets/{quick-llm-CbGHjrhX.js → quick-llm-tSDpCXxR.js} +1 -1
  128. package/dist/ui/assets/{realm-inprocess-CWMnXeN3.js → realm-inprocess-BKygqrOz.js} +6 -6
  129. package/dist/ui/assets/{recovery-screen-DhUqOdby.js → recovery-screen-D6-sXNj7.js} +1 -1
  130. package/dist/ui/assets/{redirect-uri-Dd0j1fSp.js → redirect-uri-D2aDPCyB.js} +1 -1
  131. package/dist/ui/assets/{remote-terminal-view-D4Ah4AQY.js → remote-terminal-view-CA-SfvvZ.js} +2 -2
  132. package/dist/ui/assets/{rest-ops-CQOwDiTR.js → rest-ops-Yu_dXm4T.js} +1 -1
  133. package/dist/ui/assets/{rest-ops-DkUeDpiM.js → rest-ops-aP40ni1y.js} +1 -1
  134. package/dist/ui/assets/{restore-CVkulBmU.js → restore-C-ey_KSq.js} +1 -1
  135. package/dist/ui/assets/{run-B-t7kWH3.js → run-BEs473Sp.js} +1 -1
  136. package/dist/ui/assets/{run-COfTem8j.js → run-BSBxWJ5B.js} +1 -1
  137. package/dist/ui/assets/{run-ZmpHaamT.js → run-C3DRjgOJ.js} +2 -2
  138. package/dist/ui/assets/run-C_dx5nR2.js +91 -0
  139. package/dist/ui/assets/{run-IexPmM2B.js → run-CeJrX6mR.js} +2 -2
  140. package/dist/ui/assets/{run-DuW-7oJj.js → run-CfS1uOdY.js} +4 -4
  141. package/dist/ui/assets/{run-BX9uHbIi.js → run-DZtlriWZ.js} +1 -1
  142. package/dist/ui/assets/{run-CUCg2cJM.js → run-TEAp1X-0.js} +2 -2
  143. package/dist/ui/assets/run-ywBpFa_c.js +77 -0
  144. package/dist/ui/assets/{run-DgVV_DFr.js → run-zO91KPbj.js} +3 -3
  145. package/dist/ui/assets/screen-s6LdF1JP.js +1 -0
  146. package/dist/ui/assets/screen-share-approval-live-D388fVD9.js +1 -0
  147. package/dist/ui/assets/screencapture-media-BjmoKpyn.js +1 -0
  148. package/dist/ui/assets/screencapture-media-CM5E2g6c.js +1 -0
  149. package/dist/ui/assets/screencapture-media-shared-DlK1Wqh8.js +1 -0
  150. package/dist/ui/assets/{screencapture-run-yMA5c_HS.js → screencapture-run-zmx5QKf_.js} +2 -2
  151. package/dist/ui/assets/{secret-env-BhWGz7yx.js → secret-env-DgrZZVFU.js} +1 -1
  152. package/dist/ui/assets/secret-topology-BrobAGSV.js +1 -0
  153. package/dist/ui/assets/{secrets-bridge-client-C0tvQeuX.js → secrets-bridge-client-BJqZCK6Q.js} +1 -1
  154. package/dist/ui/assets/{secrets-bridge-client-BS3V1JBF.js → secrets-bridge-client-CeK7HpDf.js} +1 -1
  155. package/dist/ui/assets/{session-command-memory-DzuRy-nC.js → session-command-memory-B0lDqCR9.js} +2 -2
  156. package/dist/ui/assets/{session-jsonl-iOOR_32X.js → session-jsonl-C8ClVNxB.js} +1 -1
  157. package/dist/ui/assets/{session-jsonl-D01HYAS2.js → session-jsonl-DQNfKRsT.js} +1 -1
  158. package/dist/ui/assets/{session-search-index-CABvtt-r.js → session-search-index-BT4ZJZt7.js} +2 -2
  159. package/dist/ui/assets/{setup-feature-flags-remote-CvstKwBW.js → setup-feature-flags-remote-BGRjwc3Y.js} +1 -1
  160. package/dist/ui/assets/{signed-fetch-7NwdVmf1.js → signed-fetch-CNiA3vB6.js} +1 -1
  161. package/dist/ui/assets/{silent-renew-backoff-CXHqSiPb.js → silent-renew-backoff-DrQ0_tES.js} +1 -1
  162. package/dist/ui/assets/slicc-version-nVz--RAg.js +1 -0
  163. package/dist/ui/assets/{snapshot-BcYaw9Ip.js → snapshot-DXOlM8V_.js} +1 -1
  164. package/dist/ui/assets/{snapshot-features-3xslkGtL.js → snapshot-features-D_DeQAxH.js} +1 -1
  165. package/dist/ui/assets/{soundscape-TygolFwj.js → soundscape-CYcg-DKm.js} +1 -1
  166. package/dist/ui/assets/{speak-BCLm04Z2.js → speak-Br_kDtG8.js} +1 -1
  167. package/dist/ui/assets/{sprinkle-manager-DDzNanda.js → sprinkle-manager-DpsA1UkN.js} +1 -1
  168. package/dist/ui/assets/{sprinkle-renderer-B-CADNjq.js → sprinkle-renderer-q0STe7tk.js} +5 -2
  169. package/dist/ui/assets/ssh-CrZ29b93.js +6 -0
  170. package/dist/ui/assets/{state-BCTAzK_L.js → state-edQbuMHp.js} +1 -1
  171. package/dist/ui/assets/{store-C-AW4ogv.js → store-BJb3HsiM.js} +1 -1
  172. package/dist/ui/assets/{store-CzlK9KIc.js → store-BYzp8NI8.js} +1 -1
  173. package/dist/ui/assets/{sudo-BtkDnUA_.js → sudo-DaUFGZ5z.js} +1 -1
  174. package/dist/ui/assets/sudo-fs-C6r_MIIY.js +3 -0
  175. package/dist/ui/assets/{supervisor-B6-QPxI3.js → supervisor-BGSiMwrr.js} +1 -1
  176. package/dist/ui/assets/{sync-dialog-B4G7kCwj.js → sync-dialog-D72P64lv.js} +1 -1
  177. package/dist/ui/assets/tab-CgwpvlHH.js +1 -0
  178. package/dist/ui/assets/tool-ui-DRnUkp2g.js +1 -0
  179. package/dist/ui/assets/{transformers-env-1TbBNkOp.js → transformers-env-BKCNBfWr.js} +1 -1
  180. package/dist/ui/assets/{tray-leader-_KISvFyF.js → tray-leader-DEBMxUkS.js} +1 -1
  181. package/dist/ui/assets/{lick-urls-DdKPDlgq.js → tray-leader-status-CpkFr6n7.js} +1 -1
  182. package/dist/ui/assets/{tray-leave-runtime-CRsRkPHc.js → tray-leave-runtime-D3LaARDy.js} +1 -1
  183. package/dist/ui/assets/{tray-runtime-config-BVgVR3H2.js → tray-runtime-config-dyxCfUex.js} +1 -1
  184. package/dist/ui/assets/{tray-sidecar-BRvCb-i7.js → tray-sidecar-Bfcy9pO0.js} +1 -1
  185. package/dist/ui/assets/turn-journal-CyInnakf.js +1 -0
  186. package/dist/ui/assets/{upgrade-detection-C5daiUbn.js → upgrade-detection-BZooMFxg.js} +1 -1
  187. package/dist/ui/assets/{upskill-lick-skip-C2ZQ0c2-.js → upskill-lick-skip-H5RyeNIq.js} +1 -1
  188. package/dist/ui/assets/url-SK-_tyJs.js +1 -0
  189. package/dist/ui/assets/v86-BinbB-8j.js +1 -0
  190. package/dist/ui/assets/{voice-reply-Dk4ztuZL.js → voice-reply-ClwwZfjh.js} +1 -1
  191. package/dist/ui/assets/{wc-attach-CFj2ZF5_.js → wc-attach-DpNELhNG.js} +2 -2
  192. package/dist/ui/assets/{wc-browser-BFL2Tl8W.js → wc-browser-6X1_NRym.js} +1 -1
  193. package/dist/ui/assets/wc-computers-2bCwocOU.js +3 -0
  194. package/dist/ui/assets/{wc-detached-ncc8KuL1.js → wc-detached-sDWnNsaX.js} +1 -1
  195. package/dist/ui/assets/{wc-extension-DppNe2VK.js → wc-extension-CF_DQHCJ.js} +2 -2
  196. package/dist/ui/assets/{wc-follower-CcxFCW-y.js → wc-follower-BlgNQHR9.js} +3 -3
  197. package/dist/ui/assets/wc-follower-oauth-BBtoYPP3.js +5 -0
  198. package/dist/ui/assets/{wc-gelatiere-CANPh9TU.js → wc-gelatiere-Pgs78krZ.js} +1 -1
  199. package/dist/ui/assets/wc-live-D3BfBbnn.js +427 -0
  200. package/dist/ui/assets/{wc-nav-BlLpBAJG.js → wc-nav-CDV8ylGr.js} +2 -2
  201. package/dist/ui/assets/{wc-onboarding-OKaUOQ3X.js → wc-onboarding-CpKS7u3d.js} +2 -2
  202. package/dist/ui/assets/{wc-permissions-BsGMi4OQ.js → wc-permissions-CCA-0PP4.js} +2 -2
  203. package/dist/ui/assets/{wc-placeholder-BrX9-mPv.js → wc-placeholder-BwY4p0ld.js} +3 -3
  204. package/dist/ui/assets/{wc-secret-request-QPmTs_eW.js → wc-secret-request-HU2msCsY.js} +1 -1
  205. package/dist/ui/assets/{wc-settings-BFgFDtTk.js → wc-settings-OTZDaEtj.js} +3 -3
  206. package/dist/ui/assets/{wc-shell-CCKjmASt.js → wc-shell-M1btJNO6.js} +9 -5
  207. package/dist/ui/assets/{wc-shortcut-config-CeUoljrV.js → wc-shortcut-config-BgTHSt0X.js} +1 -1
  208. package/dist/ui/assets/{wc-sprinkles-BNp18_jW.js → wc-sprinkles-DoKzhGCE.js} +2 -2
  209. package/dist/ui/assets/{wc-transcript-export-DJnnZ8L-.js → wc-transcript-export-CxB6cd8_.js} +2 -2
  210. package/dist/ui/assets/wc-tray-BTgAee3m.js +5 -0
  211. package/dist/ui/assets/welcome-detection-Bvx3sh1_.js +1 -0
  212. package/dist/ui/assets/{whisper-session-CMiImrJg.js → whisper-session-Bjyp9kUa.js} +2 -2
  213. package/dist/ui/assets/{xai-grok-BMr5udF6.js → xai-grok-BSR4EP1b.js} +1 -1
  214. package/dist/ui/assets/{xai-grok-Dzeo18XM.js → xai-grok-Drl4j3ci.js} +1 -1
  215. package/dist/ui/index.html +9 -9
  216. package/dist/ui/lucide-icons.js +261 -247
  217. package/dist/ui/packages/webapp/index.html +9 -9
  218. package/package.json +8 -1
  219. package/dist/ui/assets/SKILL-CWR-bsvH.js +0 -1
  220. package/dist/ui/assets/browser-2rCVqcqy.js +0 -1
  221. package/dist/ui/assets/context-compaction-DRymamfD.js +0 -58
  222. package/dist/ui/assets/core-BoFWHLIW.js +0 -62
  223. package/dist/ui/assets/core-Bvc89tkf.js +0 -36
  224. package/dist/ui/assets/encode-frame-B8GkHc2t.js +0 -1
  225. package/dist/ui/assets/engine-D531XNHE.js +0 -1
  226. package/dist/ui/assets/es-DwGGEZle.js +0 -51
  227. package/dist/ui/assets/gelatiere-unit-DrQwRL3O.js +0 -1
  228. package/dist/ui/assets/icons-BM2l-_K7.js +0 -1
  229. package/dist/ui/assets/idle-compaction-B9i1duyd.js +0 -1
  230. package/dist/ui/assets/kernel-worker-4aPSVJ1C.js +0 -1185
  231. package/dist/ui/assets/keys-Dexx8cLD.js +0 -1
  232. package/dist/ui/assets/lick-ws-bridge-DZ0vVYNF.js +0 -1
  233. package/dist/ui/assets/memory-v2-flag-DVbOtPFF.js +0 -1
  234. package/dist/ui/assets/panel-rpc-handlers-CQ_iaU6N.js +0 -2
  235. package/dist/ui/assets/provider-store-access-BJPbOUku.js +0 -1
  236. package/dist/ui/assets/provider-store-access-BrjCBzpb.js +0 -1
  237. package/dist/ui/assets/run-1aYSFTwj.js +0 -91
  238. package/dist/ui/assets/run-DvD576xV.js +0 -53
  239. package/dist/ui/assets/screencapture-media-DL5YxrlG.js +0 -1
  240. package/dist/ui/assets/screencapture-media-YBE2VnLF.js +0 -1
  241. package/dist/ui/assets/secret-topology-CVneCnID.js +0 -1
  242. package/dist/ui/assets/slicc-version-CN6V2aMa.js +0 -1
  243. package/dist/ui/assets/sudo-fs-D620mZry.js +0 -3
  244. package/dist/ui/assets/tab-ToMhjbM4.js +0 -1
  245. package/dist/ui/assets/v86-BfdTUFBK.js +0 -1
  246. package/dist/ui/assets/wc-computers-CcJuQUyG.js +0 -3
  247. package/dist/ui/assets/wc-follower-oauth-DQ-JPxl6.js +0 -5
  248. package/dist/ui/assets/wc-live-BLozTZsg.js +0 -427
  249. package/dist/ui/assets/wc-tray-f1LxbB98.js +0 -5
  250. package/dist/ui/assets/welcome-detection-Dg9THpkh.js +0 -1
@@ -0,0 +1,77 @@
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t,t as n}from"./panel-rpc-BPwAqRch.js";import{r}from"./base64-BPBW1Gzr.js";import"./bridge-protocol-31SWTdS5.js";import{n as i}from"./host-command-XUdketMY.js";import{a,i as o,n as s}from"./tool-ui-DRnUkp2g.js";import{r as c,t as l}from"./subcommand-help-CgO7wRS5.js";import{t as u}from"./approval-timeout-BQ29Z0gf.js";import{t as d}from"./tmpdir-env-ate4iNcK.js";import{n as f}from"./screencapture-media-shared-DlK1Wqh8.js";import{c as p,o as m,s as ee,t as h}from"./encode-frame-30wbFN-H.js";import{i as te,n as ne,o as re,s as ie,t as ae}from"./frames-7E6RloFP.js";import{getComputerRegistry as oe,installComputerRegistry as se}from"./registry-Bq_j-EXx.js";import{getComputersHost as ce}from"./host-BjOvrhMS.js";import{t as le}from"./engine-CzMNXd8U.js";const ue=[`bridgeToken`,`bridge`,`tray`],de=[`cherry`,`connect`],fe=[`/join/`,`/tray/`],pe=[``,`/`,`/cloud`,`/connect`];function me(e){let t=e.replace(/\/index\.html$/,`/`);return t.length>1?t.replace(/\/$/,``):t}function he(e,t={}){let n;try{n=new URL(e)}catch{return!1}for(let e of ue)if(n.searchParams.has(e))return!0;for(let e of de)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=me(n.pathname);return pe.includes(r)?!0:fe.some(e=>`${r}/`.startsWith(e))}function g(e={x:0,y:0}){return{x:e.x,y:e.y}}function ge(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 _e(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`&&ge(e,{x:t.x2,y:t.y2}),t})}function ve(e){return`tab:${e}`}const ye={screenshot:!0,text:!1,frames:`poll`,keyboard:!0,mouse:`absolute`,scroll:!0,exec:!1,inputAllowed:!0},v={1:`left`,2:`middle`,3:`right`};function y(e){if(he(e.url))throw Error(`refusing SLICC app tab '${e.title??e.url}'`)}var be=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:ve(this.targetId),kind:`tab`,title:this.title,size:this.size,state:`live`,capabilities:ye,pid:null}}async screenshot(e){return await this.refreshInfo(),y({url:this.url,title:this.title}),this.browser.withTab(this.targetId,async t=>{let n=await xe(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(),y({url:this.url,title:this.title}),await this.browser.withTab(this.targetId,async t=>{for(let n of e)await b(t,n,this.pointer)})}async close(){}async refreshInfo(){let e=await Oe(this.browser,this.targetId);e&&(this.title=e.title||this.title,this.url=e.url||this.url)}};async function xe(e,t){let n=await e.screenshot({format:`png`}),r=h(n),i=p(r)??m(r),a=r;t.maxWidth&&i&&i.width>t.maxWidth?a=h(await e.screenshot({format:`png`,maxWidth:t.maxWidth})):t.format!==`png`&&(a=h(await e.screenshot({format:`jpeg`,quality:70})));let o=p(a)??m(a)??i??{width:0,height:0};return t.format!==`png`&&!m(a)&&(a=await ee(a)),{mime:m(a)?`image/jpeg`:`image/png`,bytes:a,width:o.width,height:o.height,native:i}}var Se=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:ve(this.targetId),kind:`tab`,title:this.title,size:this.size,state:`live`,capabilities:ye,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:h(t.base64)}}async input(e){let t=_e(this.pointer,e);await this.rpc.call(`computer-tab-input`,{targetId:this.targetId,events:t})}async close(){}};async function b(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 Ce(e,t,n);return;case`click`:await we(e,t,n);return;case`drag`:await Te(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 Ee(e,t);return;case`text`:await e.send(`Input.insertText`,{text:t.text});return;case`wait`:await x(Math.max(0,t.ms));return}}async function Ce(e,t,n){let r=_(n,t);await e.send(`Input.dispatchMouseEvent`,{type:t.down?`mousePressed`:`mouseReleased`,x:r.x,y:r.y,button:v[t.button],clickCount:1})}async function we(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:v[t.button],clickCount:n}),t.holdMs&&t.holdMs>0&&await x(t.holdMs),await e.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:r.x,y:r.y,button:v[t.button],clickCount:n})}async function Te(e,t,n){await b(e,{type:`mousemove`,x:t.x1,y:t.y1},n),await b(e,{type:`button`,button:1,down:!0,x:t.x1,y:t.y1},n),await b(e,{type:`mousemove`,x:t.x2,y:t.y2},n),await b(e,{type:`button`,button:1,down:!1,x:t.x2,y:t.y2},n)}async function Ee(e,t){let n=re(t.keysym);if(!n)throw Error(`unknown keysym '${t.keysym}'`);for(let r of ie(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 Oe(e,t){let n=(await e.listAllTargets()).find(e=>e.targetId===t);return n?{title:n.title,url:n.url}:null}function x(e){return new Promise(t=>setTimeout(t,e))}function ke(e,t){for(let n of t){let t=Ae(e,n);if(t)return t}return null}function Ae(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 S={low:256,medium:768,high:1536};function C(e){if(!e)return S.medium;if(e in S)return S[e];let t=/^(\d+)(?:x\d+)?$/u.exec(e);if(t){let e=Number.parseInt(t[1],10);if(e>0)return e}return S.medium}function w(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 je(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 T(e,t){return{width:e.shotWidth,height:e.shotHeight,scale:e.scale,at:t}}function Me(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 E=`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
+ add screen [-n name] share this display (needs a user gesture)
14
+ add ssh <follower> [--sim <udid>] [--allow-input] [-n name]
15
+ follower desktop (or iOS Simulator on a Mac).
16
+ --allow-input needs sudo (phone can Face ID).
17
+ The iOS follower itself is never a computer.
18
+ add url <http(s)://base> [-n name]
19
+ HTTP remote computer (GET /computer). Trailing
20
+ /computer is stripped. node-server --computer-demo
21
+ is the in-tree reference.
22
+ rm [id] unregister (stops a live screen share)
23
+ use <id> set the default computer
24
+ info descriptor for the current target
25
+
26
+ Look:
27
+ screenshot [--size low|medium|high|<N>] [--view] [file]
28
+ JPEG; prints WxH → wxh (scale s) and a frozen frame
29
+ text text-mode dump when the backend supports it
30
+ watch [--fps N] [--stop] live frames to the page (phase 2 UI)
31
+ record [-V|--duration SEC] [--fps N] [file]
32
+ timed clip (screen: live session; other kinds:
33
+ JPEG stills through ffmpeg -f image2pipe, max 60s,
34
+ --fps ≤10, streamed into the encoder)
35
+
36
+ Poke (xdotool; every verb ends with a frozen-frame line):
37
+ mousemove <x> <y> [--relative]
38
+ click [1|2|3] [--at x,y] [--hold MS] [--repeat N]
39
+ mousedown [1|2|3] [--at x,y]
40
+ mouseup [1|2|3] [--at x,y]
41
+ drag <x1> <y1> <x2> <y2>
42
+ scroll <dx> <dy> [--at x,y]
43
+ key <keysym> [keysym...] ctrl+alt+Delete, Return, F5, super+space
44
+ keydown <keysym>
45
+ keyup <keysym>
46
+ type <text...>
47
+ wait <ms>
48
+ exec <command...> when the backend supports it
49
+
50
+ Anthropic aliases (same verbs):
51
+ left_click right_click middle_click double_click triple_click
52
+ left_click_drag mouse_move scroll key type screenshot wait
53
+
54
+ Coordinates are screenshot-space of the last shot unless --native.
55
+ Buttons: 1 left, 2 middle, 3 right. Chain verbs: computer click 1 type hello
56
+
57
+ v86 guests register as v86:<name> on \`v86 start\`. Prefer this command;
58
+ \`v86 type|key|mouse|screenshot|text\` remain as thin aliases.
59
+ `,Ne=[`-c`,`--computer`,`--size`,`--at`,`--hold`,`--repeat`,`--fps`,`-n`,`--name`,`--__resolved`,`-V`,`--duration`,`--sim`],D=new Set([`ls`,`add`,`rm`,`use`,`info`,`screenshot`,`text`,`watch`,`record`,`mousemove`,`click`,`mousedown`,`mouseup`,`drag`,`scroll`,`key`,`keydown`,`keyup`,`type`,`wait`,`exec`]),O={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`},Pe=new Set([`type`,`key`,`exec`,`add`]),k=new Set([`--size`,`--at`,`--hold`,`--repeat`,`--fps`,`-n`,`--name`,`-c`,`--computer`,`--__resolved`,`-V`,`--duration`,`--sim`]);function A(e){return D.has(e)||e in O}function Fe(e){return D.has(e)?e:O[e]??null}function Ie(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 Le(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`--`){n+=1;continue}let i=Fe(r);if(!i)throw Error(`unknown verb '${r}' — see \`computer --help\``);n+=1;let{args:a,next:o}=ze(i,e,n);t.push({verb:i,alias:r,args:Re(r,i,a)}),n=o}return t}function Re(e,t,n){return t===`click`?e===`left_click`?j(n,`1`):e===`middle_click`?j(n,`2`):e===`right_click`?j(n,`3`):e===`double_click`?[...j(n,`1`),`--repeat`,`2`]:e===`triple_click`?[...j(n,`1`),`--repeat`,`3`]:n:n}function j(e,t){return e[0]===`1`||e[0]===`2`||e[0]===`3`?e:[t,...e]}function ze(e,t,n){return Pe.has(e)?Be(t,n):Ve(Ue(e),t,n)}function Be(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&&A(t))break;n.push(t),r+=1}return{args:n,next:r}}function M(e){return e.startsWith(`--`)||e===`-n`||e===`-c`||e===`-V`}function N(e,t,n){let r=e[t];return n.push(r),t+=1,k.has(r)&&t<e.length&&(n.push(e[t]),t+=1),t}function Ve(e,t,n){let r=[],i=n,a=0;for(;i<t.length;){let n=t[i];if(n===`--`){i+=1;continue}if(M(n)){i=N(t,i,r);continue}if(A(n))break;if(r.push(n),a+=1,i+=1,a>=e&&e>0){i=He(t,i,r);break}}return{args:r,next:i}}function He(e,t,n){let r=t;for(;r<e.length&&M(e[r]);)r=N(e,r,n);return r}function Ue(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;case`record`:return 1;default:return 0}}function P(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 F(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 I(e,t){return e.includes(t)}function L(e,t){for(let n of t){let t=e.indexOf(n);if(t!==-1)return e[t+1]}}function R(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`||r===`-V`){k.has(r)&&(n+=1);continue}t.push(r)}return t}function We(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function Ge(e){return new Promise(t=>{setTimeout(t,e)})}function z(e){return Math.min(10,Math.max(1,e))}async function Ke(e,t,n){let r=e;if(typeof r.appendFile==`function`){await r.appendFile(t,n);return}let i=new Uint8Array;if(typeof r.readFile==`function`)try{let e=await r.readFile(t,{encoding:`binary`});e instanceof Uint8Array&&(i=Uint8Array.from(e))}catch{}let a=new Uint8Array(i.byteLength+n.byteLength);a.set(i,0),a.set(n,i.byteLength),await e.writeFile(t,a)}async function qe(e){let t=z(e.fps),n=Math.max(1,Math.round(1e3/t)),r=e.now??Date.now,i=e.sleep??Ge,a=r()+e.durationMs,o=0,s=0,c=0,l=0,u=!1;for(;;){let d=await e.screenshot(),f=l+d.bytes.byteLength;if(c>0&&(c>=600||f>8388608)){u=!0;break}o=d.width,s=d.height,await e.onFrame?.(d.bytes),c+=1,l=f;let p=c>=600||l>=8388608,m=r()+n>=a;if(p||m){u=p&&Math.round(c/t*1e3)<e.durationMs;break}await i(n)}return{width:o,height:s,frameCount:c,byteLength:l,durationMs:u?Math.round(c/t*1e3):e.durationMs,truncated:u}}function B(e){let t=d(e.env).replace(/\/$/u,``),n=crypto.randomUUID();return e.fs.resolvePath(e.cwd,`${t}/computer-record-${n}.mjpeg`)}async function V(e,t){let n=e;typeof n.rm==`function`&&await n.rm(t,{force:!0}).catch(()=>void 0)}function Je(e){let t=e instanceof Map?new Map(e):new Map;return t.set(le,`wasm`),t}async function Ye(e){let{runFfmpeg:t}=await import(`./run-C_dx5nR2.js`),n=!e.sourcePath,r=e.sourcePath??B(e.ctx);n&&(await e.ctx.fs.mkdir(r.slice(0,r.lastIndexOf(`/`)),{recursive:!0}),await e.ctx.fs.writeFile(r,We(e.frames)));try{let n=await t([`-y`,`-hide_banner`,`-nostdin`,`-f`,`image2pipe`,`-c:v`,`mjpeg`,`-framerate`,String(e.fps),`-i`,r,`-an`,`-vf`,`scale=trunc(iw/2)*2:trunc(ih/2)*2`,`-c:v`,`libvpx`,`-b:v`,`1M`,`-pix_fmt`,`yuv420p`,e.dest],{...e.ctx,env:Je(e.ctx.env)});if(n.exitCode!==0){let e=n.stderr.trim()||`ffmpeg failed`;throw Error(e)}return{mime:`video/webm`}}finally{n&&await V(e.ctx.fs,r)}}async function Xe(e,t){let n=await e.fs.readFile(t,{encoding:`binary`});return n instanceof Uint8Array?Uint8Array.from(n):new Uint8Array}async function Ze(e){let t=z(e.fps),n=B(e.ctx);await e.ctx.fs.mkdir(n.slice(0,n.lastIndexOf(`/`)),{recursive:!0}),await e.ctx.fs.writeFile(n,new Uint8Array);try{let r=await qe({screenshot:e.screenshot,durationMs:e.durationMs,fps:t,now:e.now,sleep:e.sleep,onFrame:t=>Ke(e.ctx.fs,n,t)}),{mime:i}=await(e.encode??Ye)({frames:[],sourcePath:n,fps:t,dest:e.dest,width:r.width,height:r.height,durationMs:r.durationMs,ctx:e.ctx}),a=new Uint8Array;try{a=await Xe(e.ctx,e.dest)}catch{}return{bytes:a,mime:i,width:r.width,height:r.height,durationMs:r.durationMs,...r.truncated?{truncated:!0}:{}}}finally{await V(e.ctx.fs,n)}}const H=new Set;let U;function Qe(e){if(typeof e!=`object`||!e)return!1;let t=Object.getOwnPropertyDescriptor(e,`type`)?.value,n=Object.getOwnPropertyDescriptor(e,`id`)?.value;return(t===`begin`||t===`end`)&&typeof n==`string`}function W(e){e.type===`begin`?H.add(e.id):H.delete(e.id)}function $e(){if(U===void 0){if(typeof BroadcastChannel!=`function`){U=null;return}try{U=new BroadcastChannel(`slicc-screen-share-approval`)}catch{U=null;return}U.onmessage=e=>{Qe(e.data)&&W(e.data)}}}function et(e){$e(),W(e);try{U?.postMessage(e)}catch{}}function tt(e){et({type:`begin`,id:e})}function nt(e){et({type:`end`,id:e})}const G=Symbol(`screen-share-approval-timeout`);function rt(){return`
60
+ <div class="sprinkle-action-card">
61
+ <div class="sprinkle-action-card__header">
62
+ <div class="sprinkle-action-card__title-group">Share this display</div>
63
+ <span class="sprinkle-badge sprinkle-badge--notice">approval</span>
64
+ </div>
65
+ <div class="sprinkle-action-card__actions">
66
+ <button class="sprinkle-btn sprinkle-btn--secondary" data-action="deny">Deny</button>
67
+ <button class="sprinkle-btn sprinkle-btn--primary" data-action="approve" data-picker="screenshare">Share screen</button>
68
+ </div>
69
+ </div>
70
+ `}async function it(){let e=a();if(!e)throw Error("add screen: needs a user gesture — type `computer add screen` in the panel terminal, or run it from a cone tool call so an approval card can open the picker");let t=o.generateId(),n=!1;tt(t);try{let r=s({id:t,html:rt(),onAction:async(e,t)=>{if(e!==`approve`)return{denied:!0};let n=t;return n?.cancelled?{cancelled:!0}:n?.error?{error:String(n.error)}:n?.granted&&typeof n.handle==`string`?{approved:!0,handle:n.handle}:{error:`screen share returned an unexpected response`}}},e.onUpdate).catch(e=>{if(n)return G;throw e}),i,a=new Promise(e=>{i=setTimeout(()=>{n=!0,o.cancel(t,`screen share: timed out`),e(G)},12e4)}),c=await Promise.race([r,a]);if(i&&clearTimeout(i),c===G)throw Error(`add screen: timed out after 120s waiting for user approval`);let l=c;if(l.denied)throw Error(`add screen: denied by user`);if(l.cancelled)throw Error(`add screen: cancelled`);if(l.error)throw Error(`add screen: ${l.error}`);if(!l.approved||!l.handle)throw Error(`add screen: no display selected`);return{handle:l.handle}}finally{nt(t)}}function K(e,t,n){let r=e.list();if(t)return at(r,t);let i=n.get(`COMPUTER`);if(i)return at(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>`, `computer add screen`, `computer add ssh <follower>`, `computer add url <http(s)://base>`, or `v86 start`"}:{error:`which computer? pass -c <id> or \`computer use\`. registered: ${r.map(e=>e.id).join(`, `)}`}}function at(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}`||e.id===`screen:${t}`||e.id===`ssh:${t}`||e.id===`url:${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`}`}}var ot=e({runComputer:()=>yt});function q(e){return{stdout:``,stderr:`computer: ${e}\n`,exitCode:1}}function J(e=``){return{stdout:e,stderr:``,exitCode:0}}function st(){return globalThis.__slicc_pm??null}function ct(e){return e.browser??globalThis.__slicc_browser??null}function Y(e){return e.panelRpc??globalThis.__slicc_panelRpc??t()}function lt(e){return e.sudoBroker?e.sudoBroker:globalThis.__slicc_sudo??null}function ut(e,t){let n=Y(e);if(n)return{async capture(e){let r=await n.call(`tray-computer-native`,{runtimeId:t,action:`capture`,fps:e.fps,maxWidth:e.maxWidth,watch:e.watch},{timeoutMs:6e4});if(!r.jpeg)throw Error(`empty native screenshot from follower`);let{bytesFromBase64:i}=await import(`./encode-frame-30wbFN-H.js`).then(e=>e.r);return{bytes:i(r.jpeg),mime:`image/jpeg`,width:r.width??0,height:r.height??0,nativeWidth:r.nativeWidth??r.width??0,nativeHeight:r.nativeHeight??r.height??0}},unwatch(){n.call(`tray-computer-native`,{runtimeId:t,action:`unwatch`}).catch(()=>{})},async input(e){await n.call(`tray-computer-native`,{runtimeId:t,action:`input`,events:e})}}}function dt(e){return e.listFollowers?.()??i()}const ft={platform:`darwin`,tools:[],capture:null,input:`none`};async function pt(e,t,n,r,i){if(!n)return ft;try{return await i(e,t)}catch(e){let t=e instanceof Error?e.message:String(e);return r?ft:{error:t.startsWith(`add ssh:`)?t:`add ssh: ${t}`}}}async function mt(e,t,n,r,i){if(i===`none`&&!r)return q(`add ssh: --allow-input needs cliclick, xdotool, ydotool, or idb on the follower (screenshot-only otherwise)`);let a=lt(e);if(!a)return q(`add ssh: --allow-input needs sudo approval (not configured)`);let o=await a.requestApproval({kind:`command`,detail:`computer add ssh ${t.runtimeId}${n?` --sim ${n}`:``} --allow-input`,reason:`grant pointer and keyboard control of the follower desktop`});return o.decision===`deny`?q(u(`add ssh`,o)):null}async function ht(e,t,r,i){if(e.sshExec)return e.sshExec(t,r,i);let a=Y(e);if(!a)throw Error(`no panel RPC in this float`);let o=i??3e4,s=await a.call(`tray-exec`,{runtimeId:t,command:r,execToken:`computer-ssh-${Date.now().toString(36)}`,timeoutMs:o},{timeoutMs:o+n});if(s.error)throw Error(s.error);return{stdout:s.stdout,stderr:s.stderr,exitCode:s.exitCode}}function gt(e,t){let n=t.filter(e=>e.exec||e.computer),r=n.find(t=>t.runtimeId===e);if(r)return r;let i=n.filter(t=>t.runtimeId.endsWith(e)||t.runtimeId.includes(e));return i.length===1?i[0]:i.length>1?{error:`add ssh: ambiguous follower '${e}'`}:{error:`add ssh: no exec-capable or computer-capable follower '${e}' — try \`ssh --list\``}}function _t(e){let t=[];return e.kind===`screen`&&t.push(`display slot`),e.kind===`ssh`&&t.push(e.capabilities.inputAllowed?`input`:`view-only`),t.length>0?` [${t.join(`, `)}]`:``}function vt(e){return e.registry?e.registry:oe()??se(e.processManager??st())}async function yt(e,t,n={}){if(e.length===0||e[0]===`--help`||e[0]===`-h`||e[0]===`help`)return J(E);let r=Ie(e);if(r.rest.length===0)return J(E);let i=r.rest[0];if(l(r.rest.slice(1),{valueFlags:[...Ne]}))return J(c(`computer`,i,E,{prefix:`computer`}));let a;try{a=Le(r.rest)}catch(e){return q(e instanceof Error?e.message:String(e))}let o=vt(n),s=[];for(let e of a)try{let i=await bt(e,r,t,n,o);if(i.exitCode!==0)return i;i.stdout&&s.push(i.stdout.replace(/\n$/u,``))}catch(e){return q(e instanceof Error?e.message:String(e))}let u=tn(s.filter(Boolean).join(`
71
+ `),a,o,r.computer,t,r.json);return J(u?`${u}\n`:``)}async function bt(e,t,n,r,i){switch(e.verb){case`ls`:return xt(i,t.json);case`add`:return St(e.args,n,r,i);case`rm`:return Ot(e.args,t.computer,n,i);case`use`:return kt(e.args,i);case`info`:return At(t,n,i);case`screenshot`:return jt(e.args,t,n,i);case`text`:return Mt(t,n,i);case`watch`:return Nt(e.args,t,n,i,r);case`record`:return It(e.args,t,n,i,r);case`exec`:return zt(e.args,t,n,i);default:return Bt(e,t,n,i)}}function xt(e,t){let n=e.list();if(t)return J(`${JSON.stringify(n)}\n`);if(n.length===0)return J(`no computers registered
72
+ `);let r=[`ID KIND STATE TITLE`];for(let e of n)r.push(`${e.id.padEnd(20)} ${e.kind.padEnd(6)} ${e.state.padEnd(9)} ${e.title}${_t(e)}`);return J(`${r.join(`
73
+ `)}\n`)}async function St(e,t,n,r){let i=e[0];return i===`tab`?Et(e,t,n,r):i===`screen`?Dt(e,t,n,r):i===`ssh`?Tt(e,t,n,r):i===`url`?wt(e,t,n,r):q(`add: unknown kind '${i??``}' — phase 3 supports \`computer add tab\`, \`computer add screen\`, \`computer add ssh\`, and \`computer add url\``)}async function Ct(e){if(e.urlFetch)return e.urlFetch;let{createProxiedFetch:t}=await import(`./proxied-fetch-CPL8wJM2.js`).then(e=>e.i),{wrapUrlComputerFetch:n}=await import(`./url-SK-_tyJs.js`),r=t();return n((e,t)=>r(e,t))}async function wt(e,t,n,r){let i=L(e,[`-n`,`--name`]),a=R(e).slice(1)[0];if(!a)return q(`add url: requires <http(s)://base>`);let{UrlComputerBackend:o,probeUrlComputer:s,normalizeComputerBase:c}=await import(`./url-SK-_tyJs.js`),l;try{l=c(a)}catch(e){return q(`add url: ${e instanceof Error?e.message:String(e)}`)}let u=await Ct(n),d;try{d=await s(u,l)}catch(e){let t=e instanceof Error?e.message:String(e);return q(t.startsWith(`add url:`)?t:`add url: ${t}`)}i&&(d={...d,title:i});let f=new o(u,l,d),p=r.register(f);return r.use(p.id),J(`registered ${p.id} (${p.title})\n`)}async function Tt(e,t,n,r){let i=L(e,[`-n`,`--name`]),a=L(e,[`--sim`]),o=I(e,`--allow-input`),s=R(e).slice(1)[0];if(!s)return q(`add ssh: requires <follower>`);let c=gt(s,dt(n));if(`error`in c)return q(c.error);if(c.floatType===`ios`)return q(`add ssh: the iOS follower itself is not a driven computer (a real iPhone is out of scope; pass --sim <udid> on a Mac follower)`);if(a&&!c.exec)return q(`add ssh: --sim needs an exec-capable Mac follower`);let{SshComputerBackend:l,probeSsh:u}=await import(`./ssh-CrZ29b93.js`),d=c.computer?n.nativeComputer?.(c.runtimeId)??ut(n,c.runtimeId):void 0,f=c.exec?(e,t)=>ht(n,c.runtimeId,e,t?.timeoutMs):async()=>{throw Error(`follower has no exec capability`)},p=await pt(f,a,!!c.exec,!!d,u);if(`error`in p)return q(p.error);if(o){let e=await mt(n,c,a,!!d,p.input);if(e)return e}let m=i??(a?`${c.runtimeId} sim ${a}`:c.runtimeId),ee=new l(f,{runtimeId:c.runtimeId,title:m,probe:p,inputAllowed:o,sim:a,native:d}),h=r.register(ee);return r.use(h.id),J(`registered ${h.id} (${h.title})\n`)}async function Et(e,t,n,r){let i=L(e,[`-n`,`--name`]),a=R(e).slice(1)[0];if(!a)return q(`add tab: requires <targetId|url>`);let o=ct(n);if(!o)return q(`add tab: no browser API in this float`);let s=De(await o.listAllTargets(),a);if(`error`in s)return q(s.error);try{y(s)}catch(e){return q(e instanceof Error?e.message:String(e))}let c={title:i??s.title,url:s.url},l=n.browser&&!n.panelRpc?null:Y(n),u=l?new Se(l,s.targetId,c):new be(o,s.targetId,c),d=r.register(u);return r.use(d.id),J(`registered ${d.id} (${d.title})\n`)}async function Dt(e,t,n,r){let i=L(e,[`-n`,`--name`]),o=L(e,[`--__resolved`]);if(!o){if(!a())return q("add screen: needs a user gesture — type `computer add screen` in the panel terminal, or run it from a cone tool call so an approval card can open the picker");try{o=(await it()).handle}catch(e){return q(e instanceof Error?e.message:String(e))}}let s=Y(n);if(!s)return q(`add screen: no panel RPC in this float`);let{BridgedScreenComputerBackend:c,screenComputerId:l}=await import(`./screen-s6LdF1JP.js`),u=new c(s,o,{title:i??`Display`},()=>{r.refresh(l(o))}),d=r.register(u);return r.use(d.id),J(`registered ${d.id} (${d.title})\n`)}async function Ot(e,t,n,r){let i=K(r,R(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 kt(e,t){let n=R(e)[0];if(!n)return q(`use: requires <id>`);let r=K(t,n,new Map);return`error`in r?q(r.error):(t.use(r.id),J(`using ${r.id}\n`))}function At(e,t,n){let r=K(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 jt(e,t,n,i){let a=Z(i,t.computer,n);if(`exitCode`in a)return a;let o=C(L(e,[`--size`])),s=await a.backend.screenshot({format:`jpeg`,maxWidth:o}),c=w(a.backend.describe().size??{width:s.width,height:s.height},{width:s.width,height:s.height});i.rememberShot(a.id,T(c,Date.now()),s);let l=s.seq>0?s.seq:i.nextSeq(a.id),u=await te({fs:n.fs,cwd:n.cwd,env:n.env,name:$(a.descriptor),seq:l,frame:s}),d=R(e)[0];if(d){let e=n.fs.resolvePath(n.cwd,d);await n.fs.writeFile(e,s.bytes)}let f=[je(c),ne(u)];return(I(e,`--view`)||I(e,`-v`))&&f.push(`<img:data:${s.mime};base64,${r(s.bytes)}>`),t.json?J(`${JSON.stringify({id:a.id,path:u,mapping:c})}\n`):J(`${f.join(`
74
+ `)}\n`)}async function Mt(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 Nt(e,t,n,r,i){let a=Z(r,t.computer,n);if(`exitCode`in a)return a;let o=Rt(i);if(!o)return q(`watch: computers host is not running`);if(I(e,`--stop`))return o.unwatch(a.id),J(`unwatched ${a.id}\n`);let s=F(e,`--fps`)??2,c=C(L(e,[`--size`]));return o.watch(a.id,s,c),J(`watching ${a.id} at ${s} fps\n`)}function Pt(e){return`recordClip`in e&&typeof e.recordClip==`function`}function Ft(e){let t=L(e,[`-V`,`--duration`]);if(t===void 0)return 5;let n=Number(t);if(!Number.isFinite(n)||n<=0)throw Error(`-V/--duration requires a positive number of seconds`);return n}async function It(e,t,n,r,i){let a=Z(r,t.computer,n);if(`exitCode`in a)return a;let o,s;try{o=Ft(e),s=F(e,`--fps`)??2}catch(e){return q(e instanceof Error?e.message:String(e))}if(s<=0)return q(`--fps requires a positive number`);if(s>10)return q(`--fps exceeds 10`);let c=f(o*1e3),l=R(e)[0]??`clip.webm`,u=n.fs.resolvePath(n.cwd,l),d;try{d=Pt(a.backend)?await a.backend.recordClip(c):await Lt(a.backend,c,s,u,n,i)}catch(e){return q(`record: ${e instanceof Error?e.message:String(e)}`)}d.bytes.byteLength>0&&await n.fs.writeFile(u,d.bytes);let p=d.durationMs??c;if(t.json)return J(`${JSON.stringify({id:a.id,path:u,durationMs:p,mime:d.mime,...d.truncated?{truncated:!0}:{}})}\n`);let m=d.truncated?` (truncated)`:``;return J(`recorded ${p}ms ${d.width}x${d.height}${m} → ${u}\n`)}async function Lt(e,t,n,r,i,a){return Ze({screenshot:()=>e.screenshot({format:`jpeg`,maxWidth:768}),durationMs:t,fps:n,dest:r,ctx:i,encode:a.encodeRecordedFrames})}function Rt(e){if(e.watch)return{watch:e.watch,unwatch:e.unwatch??(()=>void 0)};let t=ce();return t?{watch:t.watch,unwatch:t.unwatch}:null}async function zt(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(`
75
+ `);return{stdout:s?`${s}\n`:``,stderr:``,exitCode:o.exitCode}}async function Bt(e,t,n,r){let i=Z(r,t.computer,n);if(`exitCode`in i)return i;let a=Ut(e,t.native,i.descriptor),o=ke(i.descriptor.capabilities,a);if(o)return q(`${e.verb}: ${o}`);try{await i.backend.input(a)}catch(t){return q(`${e.verb}: ${t instanceof Error?t.message:String(t)}`)}return Vt(i,n,r)}async function Vt(e,t,n){let r=e.descriptor.lastShot?.width??768,i=new AbortController,a;try{a=await Ht(e.backend.screenshot({format:`jpeg`,maxWidth:r,signal:i.signal}),5e3)}catch(e){return i.abort(),q(`screenshot failed after input: ${e instanceof Error?e.message:String(e)}`)}let o=w(e.backend.describe().size??{width:a.width,height:a.height},{width:a.width,height:a.height}),s=n.nextSeq(e.id),c={...a,seq:s};n.rememberShot(e.id,T(o,Date.now()),c);let l=await te({fs:t.fs,cwd:t.cwd,env:t.env,name:$(e.descriptor),seq:s,frame:c});return J(`${ne(l)}\n`)}function Ht(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 Ut(e,t,n){let r=(e,r)=>Me(e,r,n.lastShot,t);switch(e.verb){case`mousemove`:return Wt(e.args,r);case`click`:case`mousedown`:case`mouseup`:return Gt(e.verb,e.args,r);case`drag`:return Kt(e.args,r,n.capabilities.mouse);case`scroll`:return qt(e.args,r);case`key`:case`keydown`:case`keyup`:return Jt(e.verb,e.args);case`type`:return Yt(e.args);case`wait`:return Xt(e.args);default:throw Error(`internal: ${e.verb} is not an input verb`)}}function Wt(e,t){let n=R(e),r=Number(n[0]),i=Number(n[1]);if(!Number.isFinite(r)||!Number.isFinite(i))throw Error(`mousemove: requires <x> <y>`);let a=I(e,`--relative`),o=a?{x:r,y:i}:t(r,i);return[{type:`mousemove`,x:o.x,y:o.y,relative:a}]}function Gt(e,t,n){let r=R(t),{button:i,skip:a}=Zt(r),o=P(t)??$t(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=F(t,`--hold`);return[{type:`click`,button:i,count:F(t,`--repeat`)??1,...c===void 0?{}:{holdMs:c},...X(s)}]}function Kt(e,t,n){let r=R(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 qt(e,t){let n=R(e),r=Number(n[0]),i=Number(n[1]);if(!Number.isFinite(r)||!Number.isFinite(i))throw Error(`scroll: requires <dx> <dy>`);let a=P(e);return[{type:`scroll`,dx:r,dy:i,...X(a?t(a.x,a.y):void 0)}]}function Jt(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=R(t)[0];if(!n)throw Error(`${e}: no keysym supplied`);return[{type:`key`,keysym:n,down:e===`keydown`}]}function Yt(e){let t=e.join(` `).replace(/\\n/gu,`
76
+ `).replace(/\\t/gu,` `);if(!t)throw Error(`type: no text supplied`);return[{type:`text`,text:t}]}function Xt(e){let t=Number(R(e)[0]);if(!Number.isFinite(t))throw Error(`wait: requires <ms>`);return[{type:`wait`,ms:t}]}function Zt(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:Qt(e[0]),skip:1}:{button:1,skip:0}}function Qt(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 $t(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}:{}}const en=new Set([`ls`,`add`,`rm`,`use`]);function tn(e,t,n,r,i,a){if(a||!t.some(e=>!en.has(e.verb)))return e;let o=K(n,r,Q(i));if(`error`in o)return e;let s=ae(o.id);return e.split(`
77
+ `).some(e=>e.trim()===s)?e:e?`${s}\n${e}`:s}function Z(e,t,n){let r=K(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{_e as n,g as r,yt as runComputer,ot as t};
@@ -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-B05_LKnj.js`).then(e=>e.t),a=await import(`./providers-T_FH_8cU.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-UTPOqIwj.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-UTPOqIwj.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-B05_LKnj.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-T_FH_8cU.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-C0smCH0b.js`).then(e=>e.t),a=await import(`./providers-DDnH2Ikl.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-CRmx6zI1.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-CRmx6zI1.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-C0smCH0b.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-DDnH2Ikl.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,13 +100,13 @@ 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-B05_LKnj.js`).then(e=>e.t),{getRegisteredProviderConfig:i,getRegisteredProviderIds:a}=await import(`./providers-T_FH_8cU.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-B05_LKnj.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-T_FH_8cU.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-C0smCH0b.js`).then(e=>e.t),{getRegisteredProviderConfig:i,getRegisteredProviderIds:a}=await import(`./providers-DDnH2Ikl.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-C0smCH0b.js`).then(e=>e.t),{getRegisteredProviderConfig:r,getRegisteredProviderIds:i}=await import(`./providers-DDnH2Ikl.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
  `)+`
107
107
  `,stderr:``,exitCode:1};let f=A(a,await j(o));return l.push(...f.lines),{stdout:l.join(`
108
108
  `)+`
109
- `,stderr:``,exitCode:f.exitCode}}function A(e,t){let n=[` silent renewal: DECLINED — the provider returned no token without user`,` interaction (typically login_required: the upstream session has ended).`];if(t?.status===`rejected`)return{lines:[...n,` upstream check: REJECTED — the provider no longer accepts the stored`,` token${D(t.detail)}. Local expiry was never proof of validity.`,...M(e)],exitCode:3};if(t?.status===`accepted`){let e=t.userName?` (as ${t.userName})`:``;return{lines:[...n,` upstream check: ACCEPTED${e} — the stored token still works, so callers`,` are not blocked; only the renewal itself did not happen. No login needed.`],exitCode:1}}let r=[` Unconfirmed: provider renewal hooks also return no token when the renewal`,` call itself fails, so this alone does not prove the session ended.`];return t?.detail&&r.push(` (upstream check: ${t.detail})`),{lines:[...n,...r,...N(e)],exitCode:1}}async function j(e){return e.onValidateToken?e.onValidateToken().catch(e=>({status:`unknown`,detail:e instanceof Error?e.message:String(e)})):null}function M(e){return[``,` → Fix: oauth-token ${e} --force-login`,` Opens a consent window, so a human has to be at the keyboard: an`,` unattended agent should stop and ask the user to re-authorise rather`,` than retrying or probing further.`,` (Diagnostics, if a human is present: browser DevTools console,`,` "[oauth-service] Extension OAuth error".)`]}function N(e){return[``,` → Likely fix: oauth-token ${e} --force-login`,` Opens a consent window, so a human has to be at the keyboard. If the`,` failure was transient instead, a later retry succeeds on its own.`,` (Diagnostics: browser DevTools console, "[oauth-service] Extension`,` OAuth error".)`]}function P(e){return[``,` → The renewal call failed rather than being declined; this is often`,` transient (offline, 5xx, bridge not up). Retry it.`,` If it keeps failing: oauth-token ${e} --force-login (needs a human).`]}function F(e){return e?e.expired?`present, ${I(e.expiresAt)} — renewal needed`:`present, ${I(e.expiresAt)}, not validated upstream`:`none stored`}function I(e){if(!e)return`no local expiry recorded`;let t=e-Date.now();if(t<=0)return`past its local expiry`;if(t<6e4)return`local expiry in under a minute`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return`local expiry in ${n>0?`${n}h ${r}m`:`${r}m`}`}async function L(e,t,n){let{parseInterceptOAuthConfig:r}=await import(`./intercepted-oauth-B0tP4D7f.js`).then(e=>e.n),{createInterceptingOAuthLauncherForCurrentRuntime:i}=await import(`./oauth-service-UTPOqIwj.js`),a=await R(e,t,n);if(!a.ok)return a.result;let o=r(a.value);if(!o.ok)return H(`oauth-token: invalid intercept config: ${o.error}`);let s=await i();if(!s)return H(`oauth-token: no CDP transport available in this runtime; --intercept needs the controlled browser.`);let c=await s(o.config);return c?{stdout:`${c}\n`,stderr:``,exitCode:0}:H(`oauth-token: intercept timed out or was cancelled`)}function R(e,t,n){return e.values.has(`--from-file`)?z(e.values.get(`--from-file`),n):B(e,t)}async function z(e,t){if(!e)return{ok:!1,result:H(`oauth-token: --from-file requires a path`)};try{let n=t.fs.resolvePath(t.cwd,e),r=await t.fs.readFile(n),i=typeof r==`string`?r:new TextDecoder().decode(r);return{ok:!0,value:JSON.parse(i)}}catch(t){return{ok:!1,result:H(`oauth-token: failed to read ${e}: ${t instanceof Error?t.message:String(t)}`)}}}function B(e,t){let n=e.values.get(`--authorize-url`),r=e.values.get(`--redirect-pattern`);if(!n)return{ok:!1,result:H(`oauth-token: --authorize-url is required`)};if(!r)return{ok:!1,result:H(`oauth-token: --redirect-pattern is required`)};let i=V(t);return i.ok?{ok:!0,value:{authorizeUrl:n,redirectUriPattern:r,onCapture:e.bools.has(`--leave-tab`)?`leave`:`close`,...i.value.length>0?{rewrite:i.value}:{}}}:i}function V(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)break;if(r!==`--rewrite`&&!r.startsWith(`--rewrite=`))continue;let i=r===`--rewrite`?e[++n]:r.slice(10);if(!i)return{ok:!1,result:H(`oauth-token: --rewrite requires a value`)};let a=i.split(`=`);if(a.length<3)return{ok:!1,result:H(`oauth-token: --rewrite "${i}" must be "<match>=<key>=<value>"`)};let[o,s,...c]=a;t.push({match:o,appendParams:{[s]:c.join(`=`)}})}return{ok:!0,value:t}}function H(e){return{stdout:``,stderr:`${e}\n`,exitCode:1}}function U(e,t,n,r){let i=t().filter(e=>n(e)?.isOAuth);if(i.length===0)return{stdout:`No OAuth providers configured.
109
+ `,stderr:``,exitCode:f.exitCode}}function A(e,t){let n=[` silent renewal: DECLINED — the provider returned no token without user`,` interaction (typically login_required: the upstream session has ended).`];if(t?.status===`rejected`)return{lines:[...n,` upstream check: REJECTED — the provider no longer accepts the stored`,` token${D(t.detail)}. Local expiry was never proof of validity.`,...M(e)],exitCode:3};if(t?.status===`accepted`){let e=t.userName?` (as ${t.userName})`:``;return{lines:[...n,` upstream check: ACCEPTED${e} — the stored token still works, so callers`,` are not blocked; only the renewal itself did not happen. No login needed.`],exitCode:1}}let r=[` Unconfirmed: provider renewal hooks also return no token when the renewal`,` call itself fails, so this alone does not prove the session ended.`];return t?.detail&&r.push(` (upstream check: ${t.detail})`),{lines:[...n,...r,...N(e)],exitCode:1}}async function j(e){return e.onValidateToken?e.onValidateToken().catch(e=>({status:`unknown`,detail:e instanceof Error?e.message:String(e)})):null}function M(e){return[``,` → Fix: oauth-token ${e} --force-login`,` Opens a consent window, so a human has to be at the keyboard: an`,` unattended agent should stop and ask the user to re-authorise rather`,` than retrying or probing further.`,` (Diagnostics, if a human is present: browser DevTools console,`,` "[oauth-service] Extension OAuth error".)`]}function N(e){return[``,` → Likely fix: oauth-token ${e} --force-login`,` Opens a consent window, so a human has to be at the keyboard. If the`,` failure was transient instead, a later retry succeeds on its own.`,` (Diagnostics: browser DevTools console, "[oauth-service] Extension`,` OAuth error".)`]}function P(e){return[``,` → The renewal call failed rather than being declined; this is often`,` transient (offline, 5xx, bridge not up). Retry it.`,` If it keeps failing: oauth-token ${e} --force-login (needs a human).`]}function F(e){return e?e.expired?`present, ${I(e.expiresAt)} — renewal needed`:`present, ${I(e.expiresAt)}, not validated upstream`:`none stored`}function I(e){if(!e)return`no local expiry recorded`;let t=e-Date.now();if(t<=0)return`past its local expiry`;if(t<6e4)return`local expiry in under a minute`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return`local expiry in ${n>0?`${n}h ${r}m`:`${r}m`}`}async function L(e,t,n){let{parseInterceptOAuthConfig:r}=await import(`./intercepted-oauth-B0tP4D7f.js`).then(e=>e.n),{createInterceptingOAuthLauncherForCurrentRuntime:i}=await import(`./oauth-service-CRmx6zI1.js`),a=await R(e,t,n);if(!a.ok)return a.result;let o=r(a.value);if(!o.ok)return H(`oauth-token: invalid intercept config: ${o.error}`);let s=await i();if(!s)return H(`oauth-token: no CDP transport available in this runtime; --intercept needs the controlled browser.`);let c=await s(o.config);return c?{stdout:`${c}\n`,stderr:``,exitCode:0}:H(`oauth-token: intercept timed out or was cancelled`)}function R(e,t,n){return e.values.has(`--from-file`)?z(e.values.get(`--from-file`),n):B(e,t)}async function z(e,t){if(!e)return{ok:!1,result:H(`oauth-token: --from-file requires a path`)};try{let n=t.fs.resolvePath(t.cwd,e),r=await t.fs.readFile(n),i=typeof r==`string`?r:new TextDecoder().decode(r);return{ok:!0,value:JSON.parse(i)}}catch(t){return{ok:!1,result:H(`oauth-token: failed to read ${e}: ${t instanceof Error?t.message:String(t)}`)}}}function B(e,t){let n=e.values.get(`--authorize-url`),r=e.values.get(`--redirect-pattern`);if(!n)return{ok:!1,result:H(`oauth-token: --authorize-url is required`)};if(!r)return{ok:!1,result:H(`oauth-token: --redirect-pattern is required`)};let i=V(t);return i.ok?{ok:!0,value:{authorizeUrl:n,redirectUriPattern:r,onCapture:e.bools.has(`--leave-tab`)?`leave`:`close`,...i.value.length>0?{rewrite:i.value}:{}}}:i}function V(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)break;if(r!==`--rewrite`&&!r.startsWith(`--rewrite=`))continue;let i=r===`--rewrite`?e[++n]:r.slice(10);if(!i)return{ok:!1,result:H(`oauth-token: --rewrite requires a value`)};let a=i.split(`=`);if(a.length<3)return{ok:!1,result:H(`oauth-token: --rewrite "${i}" must be "<match>=<key>=<value>"`)};let[o,s,...c]=a;t.push({match:o,appendParams:{[s]:c.join(`=`)}})}return{ok:!0,value:t}}function H(e){return{stdout:``,stderr:`${e}\n`,exitCode:1}}function U(e,t,n,r){let i=t().filter(e=>n(e)?.isOAuth);if(i.length===0)return{stdout:`No OAuth providers configured.
110
110
  `,stderr:``,exitCode:0};let a=[],o=!1;for(let e of i){let t=r(e);if(!t){a.push(`${e} (no token)`);continue}o=!0,a.push(`${e} (${W(t).join(`, `)})`)}return o&&a.push(``,`Local state only — a held token can already be rejected upstream.`,`Verify with "oauth-token --check <id>"; re-consent with "oauth-token <id> --force-login".`),{stdout:a.join(`
111
111
  `)+`
112
112
  `,stderr:``,exitCode:0}}function W(e){let t=[e.userName?`token held for ${e.userName}`:`token held`];return t.push(I(e.expiresAt)),e.expired&&t.push(`renewal needed`),e.scopes&&t.push(`scopes: ${e.scopes}`),t}export{d as runOAuthToken};
@@ -0,0 +1 @@
1
+ import{t as e}from"./panel-rpc-BPwAqRch.js";import{n as t,t as n}from"./screencapture-media-shared-DlK1Wqh8.js";function r(e){return`screen:${e}`}const i={screenshot:!0,text:!1,frames:`poll`,keyboard:!1,mouse:`none`,scroll:!1,exec:!1,inputAllowed:!1};function a(e){return e.includes(`png`)?`image/png`:`image/jpeg`}function o(e){return new Uint8Array(e)}function s(e){if(typeof e!=`object`||!e)return null;let t=Object.getOwnPropertyDescriptor(e,`handle`)?.value;return typeof t==`string`?t:null}var c=class{rpc;handle;onGone;seq=0;title;size;state=`live`;offEnded;constructor(e,t,r={title:t},i){this.rpc=e,this.handle=t,this.onGone=i,this.title=r.title,this.size=r.width&&r.height&&r.width>0&&r.height>0?{width:r.width,height:r.height}:null,this.offEnded=e.onEvent?e.onEvent(n,e=>{s(e)===this.handle&&this.markGone()}):()=>void 0}describe(){return{id:r(this.handle),kind:`screen`,title:this.title,size:this.size,state:this.state,capabilities:i,pid:null}}async screenshot(e){let t;try{t=await this.rpc.call(`screencapture`,{mimeType:e.format===`png`?`image/png`:`image/jpeg`,quality:.7,mode:`session`,session:`frame`,handle:this.handle,maxWidth:e.maxWidth})}catch(e){throw(e instanceof Error?e.message:String(e)).includes(`no screen-share session`)&&this.markGone(),e}return t.width>0&&t.height>0&&(this.size={width:t.width,height:t.height}),this.seq+=1,{seq:this.seq,mime:a(t.mimeType),width:t.width,height:t.height,bytes:o(t.bytes)}}async input(e){throw Error(`input is not allowed`)}async recordClip(n){let r=t(n),i=await this.rpc.call(`screencapture`,{mimeType:`video/webm`,quality:1,mode:`session`,session:`record`,handle:this.handle,durationMs:r},{timeoutMs:r+e});return{bytes:o(i.bytes),mime:i.mimeType||`video/webm`,width:i.width,height:i.height,...i.durationMs===void 0?{}:{durationMs:i.durationMs}}}async close(){this.offEnded();try{await this.rpc.call(`screencapture`,{mimeType:`application/octet-stream`,quality:1,mode:`session`,session:`stop`,handle:this.handle})}catch{}}markGone(){this.state!==`gone`&&(this.state=`gone`,this.onGone?.())}};export{c as BridgedScreenComputerBackend,r as screenComputerId};
@@ -0,0 +1 @@
1
+ var e=new Set,t=!1,n;function r(e){if(typeof e!=`object`||!e)return!1;let t=Object.getOwnPropertyDescriptor(e,`type`)?.value,n=Object.getOwnPropertyDescriptor(e,`id`)?.value;return(t===`begin`||t===`end`)&&typeof n==`string`}function i(n){t=!0,n.type===`begin`?e.add(n.id):e.delete(n.id)}function a(){if(n===void 0){if(typeof BroadcastChannel!=`function`){n=null;return}try{n=new BroadcastChannel(`slicc-screen-share-approval`)}catch{n=null;return}n.onmessage=e=>{r(e.data)&&i(e.data)}}}function o(){return a(),e.size>0||!t}function s(e,t){return o()?!0:(t(e),!1)}export{s as keepAdoptedScreenShare,a as listenScreenShareApprovalChannel};
@@ -0,0 +1 @@
1
+ import{i as e,n as t,r as n}from"./screencapture-media-shared-DlK1Wqh8.js";const r=new class{sessions=new Map;endedListeners=new Set;nextId=1;unloadHooked=!1;ids(){return[...this.sessions.keys()]}get(e){return this.sessions.get(e)}add(e,t){let n=`screen${this.nextId++}`;this.sessions.set(n,{handle:n,stream:e,video:t}),this.hookUnload();for(let t of e.getTracks())t.addEventListener(`ended`,()=>{this.stop(n)},{once:!0});return n}stop(e){let t=this.sessions.get(e);return t?(this.sessions.delete(e),t.video.srcObject=null,i(t.stream),this.notifyEnded(e),!0):!1}onEnded(e){return this.endedListeners.add(e),()=>{this.endedListeners.delete(e)}}stopAll(){for(let e of[...this.sessions.keys()])this.stop(e)}hookUnload(){this.unloadHooked||typeof window>`u`||(this.unloadHooked=!0,window.addEventListener(`pagehide`,()=>{this.stopAll()}))}notifyEnded(e){for(let t of[...this.endedListeners])try{t(e)}catch{}}};function i(e){for(let t of e.getTracks())try{t.stop()}catch{}}async function a(e){if(e.mode===`session`)return o(e);if(!navigator.mediaDevices?.getDisplayMedia)throw Error(`screen capture is not supported in this browser`);await g();let t=e.mode===`video`&&!!e.audio,r;try{r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:t})}catch(e){throw Error(n(e))}try{return e.mode===`video`?await p(r,e):await d(r,e)}finally{i(r)}}async function o(e){if(e.action===`start`)return s();if(e.action===`frame`)return l(e);if(e.action===`record`)return u(e);if(!r.stop(e.handle))throw Error(`no screen-share session '${e.handle}'`);return{bytes:new Uint8Array,mimeType:`application/octet-stream`,width:0,height:0,handle:e.handle}}async function s(){if(!navigator.mediaDevices?.getDisplayMedia)throw Error(`screen capture is not supported in this browser`);await g();let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1})}catch(e){throw Error(n(e))}return c(e)}async function c(e){let t;try{t=await h(e),await new Promise(e=>setTimeout(e,100))}catch(t){throw i(e),t}let n=r.add(e,t);return{bytes:new Uint8Array,mimeType:`application/octet-stream`,width:t.videoWidth,height:t.videoHeight,handle:n}}async function l(e){let t=r.get(e.handle);if(!t)throw Error(`no screen-share session '${e.handle}'`);return f(t.video,{mimeType:e.mimeType??`image/jpeg`,quality:e.quality??.7,maxWidth:e.maxWidth})}async function u(e){let t=r.get(e.handle);if(!t)throw Error(`no screen-share session '${e.handle}'`);return p(t.stream,{mode:`video`,mimeType:e.mimeType??`video/webm`,durationMs:e.durationMs})}async function d(e,t){let n=await h(e);try{return await new Promise(e=>setTimeout(e,100)),await f(n,{mimeType:t.mimeType,quality:t.quality})}finally{n.srcObject=null}}async function f(t,n){let r=t.videoWidth,i=t.videoHeight,{width:a,height:o}=e(r,i,n.maxWidth),s=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);if(!c)throw Error(`Failed to get canvas context`);c.drawImage(t,0,0,a,o);let l=await new Promise((e,t)=>{s.toBlob(n=>n?e(n):t(Error(`Failed to create image blob`)),n.mimeType,n.quality)});return{bytes:new Uint8Array(await l.arrayBuffer()),mimeType:l.type||n.mimeType,width:a,height:o}}async function p(e,n){if(typeof MediaRecorder>`u`)throw Error(`MediaRecorder is not supported in this browser`);let r=await h(e),i=r.videoWidth,a=r.videoHeight,o=t(n.durationMs),s=m(n.mimeType),c=new MediaRecorder(e,{mimeType:s}),l=[];c.ondataavailable=e=>{e.data&&e.data.size>0&&l.push(e.data)};let u=new Promise(e=>{c.onstop=()=>e()}),d=new Promise(t=>{let n=e.getTracks(),r=n.length;if(r===0){t();return}for(let e of n)e.addEventListener(`ended`,()=>{--r,r<=0&&t()},{once:!0})}),f=Date.now();c.start(),await Promise.race([new Promise(e=>setTimeout(e,o)),d]),c.state!==`inactive`&&c.stop(),await u;let p=Math.max(100,Date.now()-f);r.srcObject=null;let g=new Blob(l,{type:s});if(g.size===0)throw Error(`video capture produced no data (was sharing stopped immediately?)`);return{bytes:new Uint8Array(await g.arrayBuffer()),mimeType:g.type||s,width:i,height:a,durationMs:Math.min(p,o)}}function m(e){if(MediaRecorder.isTypeSupported(e))return e;for(let e of[`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`])if(MediaRecorder.isTypeSupported(e))return e;return`video/webm`}async function h(e){let t=document.createElement(`video`);return t.srcObject=e,t.muted=!0,t.playsInline=!0,await new Promise((e,n)=>{t.onloadedmetadata=()=>t.play().then(()=>e()).catch(n),t.onerror=()=>n(Error(`Failed to load video stream`))}),t}async function g(e=5e3){if(typeof document>`u`)return;let t=()=>typeof document.visibilityState!=`string`||document.visibilityState===`visible`,n=typeof document.hasFocus==`function`?()=>document.hasFocus():()=>!0;t()&&n()||await new Promise(r=>{let i=()=>{window.removeEventListener(`focus`,a),document.removeEventListener(`visibilitychange`,a),clearTimeout(o)},a=()=>{t()&&n()&&(i(),r())},o=setTimeout(()=>{i(),r()},e);window.addEventListener(`focus`,a),document.addEventListener(`visibilitychange`,a),a()})}export{a as captureDisplayMedia};
@@ -0,0 +1 @@
1
+ function e(e){return Math.max(100,Math.min(e??5e3,6e4))}function t(e){let t=e instanceof DOMException?e.name:void 0,n=e instanceof Error?e.message:String(e);return t===`InvalidStateError`||/^Invalid state$/i.test(n.trim())||/InvalidStateError/i.test(n)?"display capture unavailable (Invalid state): another tab or page may still hold a screen-share session, or this page is not focused/visible. `computer ls` lists a live `screen` computer if one holds this page's display slot — `computer rm` it to stop the tracks. Otherwise stop other getDisplayMedia captures, focus the SLICC window, and retry; if it stays wedged, reload the session":t===`NotAllowedError`||/Permission denied|NotAllowedError/i.test(n)?`user cancelled or permission denied`:t===`NotFoundError`?`no screen, window, or tab was available to capture`:t===`NotReadableError`||t===`AbortError`?n||t:n}function n(e,t,n){if(!n||e<=n||e<=0)return{width:e,height:t};let r=n/e;return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function r(e){let t=e.session;if(t===`start`)return{mode:`session`,action:`start`};if(t!==`frame`&&t!==`stop`&&t!==`record`)throw Error(`screencapture session requires action start|frame|stop|record`);if(!e.handle)throw Error(`screencapture session ${t} requires handle`);if(t===`frame`)return{mode:`session`,action:`frame`,handle:e.handle,maxWidth:e.maxWidth,mimeType:e.mimeType,quality:e.quality};if(t===`stop`)return{mode:`session`,action:`stop`,handle:e.handle};if(t===`record`)return{mode:`session`,action:`record`,handle:e.handle,durationMs:e.durationMs??5e3,mimeType:e.mimeType};throw Error(`screencapture session requires action start|frame|stop|record`)}var i=`screencapture-session-ended`,a=new class{sessions=new Map;endedListeners=new Set;nextId=1;unloadHooked=!1;ids(){return[...this.sessions.keys()]}get(e){return this.sessions.get(e)}add(e,t){let n=`screen${this.nextId++}`;this.sessions.set(n,{handle:n,stream:e,video:t}),this.hookUnload();for(let t of e.getTracks())t.addEventListener(`ended`,()=>{this.stop(n)},{once:!0});return n}stop(e){let t=this.sessions.get(e);return t?(this.sessions.delete(e),t.video.srcObject=null,o(t.stream),this.notifyEnded(e),!0):!1}onEnded(e){return this.endedListeners.add(e),()=>{this.endedListeners.delete(e)}}stopAll(){for(let e of[...this.sessions.keys()])this.stop(e)}hookUnload(){this.unloadHooked||typeof window>`u`||(this.unloadHooked=!0,window.addEventListener(`pagehide`,()=>{this.stopAll()}))}notifyEnded(e){for(let t of[...this.endedListeners])try{t(e)}catch{}}};function o(e){for(let t of e.getTracks())try{t.stop()}catch{}}async function s(e){if(e.mode===`session`)return c(e);if(!navigator.mediaDevices?.getDisplayMedia)throw Error(`screen capture is not supported in this browser`);await v();let n=e.mode===`video`&&!!e.audio,r;try{r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:n})}catch(e){throw Error(t(e))}try{return e.mode===`video`?await h(r,e):await p(r,e)}finally{o(r)}}async function c(e){if(e.action===`start`)return l();if(e.action===`frame`)return d(e);if(e.action===`record`)return f(e);if(!a.stop(e.handle))throw Error(`no screen-share session '${e.handle}'`);return{bytes:new Uint8Array,mimeType:`application/octet-stream`,width:0,height:0,handle:e.handle}}async function l(){if(!navigator.mediaDevices?.getDisplayMedia)throw Error(`screen capture is not supported in this browser`);await v();let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1})}catch(e){throw Error(t(e))}return u(e)}async function u(e){let t;try{t=await _(e),await new Promise(e=>setTimeout(e,100))}catch(t){throw o(e),t}let n=a.add(e,t);return{bytes:new Uint8Array,mimeType:`application/octet-stream`,width:t.videoWidth,height:t.videoHeight,handle:n}}async function d(e){let t=a.get(e.handle);if(!t)throw Error(`no screen-share session '${e.handle}'`);return m(t.video,{mimeType:e.mimeType??`image/jpeg`,quality:e.quality??.7,maxWidth:e.maxWidth})}async function f(e){let t=a.get(e.handle);if(!t)throw Error(`no screen-share session '${e.handle}'`);return h(t.stream,{mode:`video`,mimeType:e.mimeType??`video/webm`,durationMs:e.durationMs})}async function p(e,t){let n=await _(e);try{return await new Promise(e=>setTimeout(e,100)),await m(n,{mimeType:t.mimeType,quality:t.quality})}finally{n.srcObject=null}}async function m(e,t){let r=e.videoWidth,i=e.videoHeight,{width:a,height:o}=n(r,i,t.maxWidth),s=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);if(!c)throw Error(`Failed to get canvas context`);c.drawImage(e,0,0,a,o);let l=await new Promise((e,n)=>{s.toBlob(t=>t?e(t):n(Error(`Failed to create image blob`)),t.mimeType,t.quality)});return{bytes:new Uint8Array(await l.arrayBuffer()),mimeType:l.type||t.mimeType,width:a,height:o}}async function h(t,n){if(typeof MediaRecorder>`u`)throw Error(`MediaRecorder is not supported in this browser`);let r=await _(t),i=r.videoWidth,a=r.videoHeight,o=e(n.durationMs),s=g(n.mimeType),c=new MediaRecorder(t,{mimeType:s}),l=[];c.ondataavailable=e=>{e.data&&e.data.size>0&&l.push(e.data)};let u=new Promise(e=>{c.onstop=()=>e()}),d=new Promise(e=>{let n=t.getTracks(),r=n.length;if(r===0){e();return}for(let t of n)t.addEventListener(`ended`,()=>{--r,r<=0&&e()},{once:!0})}),f=Date.now();c.start(),await Promise.race([new Promise(e=>setTimeout(e,o)),d]),c.state!==`inactive`&&c.stop(),await u;let p=Math.max(100,Date.now()-f);r.srcObject=null;let m=new Blob(l,{type:s});if(m.size===0)throw Error(`video capture produced no data (was sharing stopped immediately?)`);return{bytes:new Uint8Array(await m.arrayBuffer()),mimeType:m.type||s,width:i,height:a,durationMs:Math.min(p,o)}}function g(e){if(MediaRecorder.isTypeSupported(e))return e;for(let e of[`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`])if(MediaRecorder.isTypeSupported(e))return e;return`video/webm`}async function _(e){let t=document.createElement(`video`);return t.srcObject=e,t.muted=!0,t.playsInline=!0,await new Promise((e,n)=>{t.onloadedmetadata=()=>t.play().then(()=>e()).catch(n),t.onerror=()=>n(Error(`Failed to load video stream`))}),t}async function v(e=5e3){if(typeof document>`u`)return;let t=()=>typeof document.visibilityState!=`string`||document.visibilityState===`visible`,n=typeof document.hasFocus==`function`?()=>document.hasFocus():()=>!0;t()&&n()||await new Promise(r=>{let i=()=>{window.removeEventListener(`focus`,a),document.removeEventListener(`visibilitychange`,a),clearTimeout(o)},a=()=>{t()&&n()&&(i(),r())},o=setTimeout(()=>{i(),r()},e);window.addEventListener(`focus`,a),document.addEventListener(`visibilitychange`,a),a()})}export{i as SCREENCAPTURE_SESSION_ENDED_CHANNEL,u as adoptDisplayStream,s as captureDisplayMedia,a as displaySessions,r as sessionCaptureRequest};
@@ -0,0 +1 @@
1
+ function e(e){return Math.max(100,Math.min(e??5e3,6e4))}function t(e){let t=e instanceof DOMException?e.name:void 0,n=e instanceof Error?e.message:String(e);return t===`InvalidStateError`||/^Invalid state$/i.test(n.trim())||/InvalidStateError/i.test(n)?"display capture unavailable (Invalid state): another tab or page may still hold a screen-share session, or this page is not focused/visible. `computer ls` lists a live `screen` computer if one holds this page's display slot — `computer rm` it to stop the tracks. Otherwise stop other getDisplayMedia captures, focus the SLICC window, and retry; if it stays wedged, reload the session":t===`NotAllowedError`||/Permission denied|NotAllowedError/i.test(n)?`user cancelled or permission denied`:t===`NotFoundError`?`no screen, window, or tab was available to capture`:t===`NotReadableError`||t===`AbortError`?n||t:n}function n(e,t,n){if(!n||e<=n||e<=0)return{width:e,height:t};let r=n/e;return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}const r=`screencapture-session-ended`;export{n as i,e as n,t as r,r as t};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./panel-rpc-BPwAqRch.js";import{r as n}from"./base64-BPBW1Gzr.js";import{t as r}from"./subcommand-flags-BZi7j78Q.js";import{t as i}from"./subcommand-help-CgO7wRS5.js";import{i as a}from"./shared-C_68vn79.js";import{n as o,t as s}from"./extension-media-capture-DMB4r9UQ.js";function c(e){return Math.max(100,Math.min(e??5e3,6e4))}function l(e){let t=e instanceof DOMException?e.name:void 0,n=e instanceof Error?e.message:String(e);return t===`InvalidStateError`||/^Invalid state$/i.test(n.trim())||/InvalidStateError/i.test(n)?`display capture unavailable (Invalid state): another tab or page may still hold a screen-share session, or this page is not focused/visible. Stop other getDisplayMedia captures, focus the SLICC window, and retry; if it stays wedged, reload the session`:t===`NotAllowedError`||/Permission denied|NotAllowedError/i.test(n)?`user cancelled or permission denied`:t===`NotFoundError`?`no screen, window, or tab was available to capture`:t===`NotReadableError`||t===`AbortError`?n||t:n}const u=[`--clipboard`,`-c`,`--view`,`-v`,`--video`,`--audio`,`-g`],d=[`-V`,`--duration`];function f(e){let t=[];for(let n of e){let e=/^-V(\d+(?:\.\d+)?)$/.exec(n);if(e){t.push(`-V`,e[1]);continue}t.push(n)}return t}function p(e){return{stdout:``,stderr:`screencapture: ${e}\n`,exitCode:1}}function m(e,t){return!e&&!t?p(`browser APIs are unavailable in this environment`):e&&!o()&&!navigator.mediaDevices?.getDisplayMedia?p(`screen capture is not supported in this browser`):null}function h(e){let t=e.split(`.`).pop()?.toLowerCase();return t===`webm`||t===`mp4`||t===`mkv`}function g(e){switch(e.split(`.`).pop()?.toLowerCase()){case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return`image/png`}}function _(e){return e.split(`.`).pop()?.toLowerCase()===`mp4`&&typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(`video/mp4`)?`video/mp4`:`video/webm`}async function v(e,t,n){try{if(o()){let e=await s({kind:`screen`,mimeType:n.mimeType,quality:n.mode===`image`?n.quality:1,mode:n.mode,...n.mode===`video`?{durationMs:n.durationMs,audio:!!n.audio}:{}});return{bytes:e.bytes,mimeType:e.mimeType,...e.durationMs===void 0?{}:{durationMs:e.durationMs}}}if(e){let{captureDisplayMedia:e}=await import(`./screencapture-media-DL5YxrlG.js`),t=await e(n);return{bytes:t.bytes,mimeType:t.mimeType,...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}let r=await t.call(`screencapture`,{mimeType:n.mimeType,quality:n.mode===`image`?n.quality:1,mode:n.mode,...n.mode===`video`?{durationMs:n.durationMs,audio:!!n.audio}:{}},{timeoutMs:n.mode===`video`?3e5+n.durationMs:3e5});return{bytes:new Uint8Array(r.bytes),mimeType:r.mimeType,...r.durationMs===void 0?{}:{durationMs:r.durationMs}}}catch(e){return{error:p(l(e))}}}async function y(e,t,n,r){try{if(o()&&typeof document<`u`&&typeof document.hasFocus==`function`&&!document.hasFocus())return p(`clipboard capture needs a focused window; save to a file instead`);if(n){let n=await O(e,t),r=new ArrayBuffer(n.byteLength);new Uint8Array(r).set(n);let i=new Blob([r],{type:`image/png`});return await k(),await navigator.clipboard.write([new ClipboardItem({"image/png":i})]),{stdout:`captured ${Math.round(i.size/1024)} KB to clipboard\n`,stderr:``,exitCode:0}}return await r.call(`clipboard-write-image`,{bytes:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),mimeType:t},{timeoutMs:3e5}),{stdout:`captured ${Math.round(e.byteLength/1024)} KB to clipboard\n`,stderr:``,exitCode:0}}catch(e){return p(`failed to copy to clipboard: ${e instanceof Error?e.message:String(e)}`)}}async function b(e,t,r,i,o,s,c){let l=c.fs.resolvePath(c.cwd,t);try{await c.fs.writeFile(l,e)}catch(e){return p(`failed to write file: ${e instanceof Error?e.message:String(e)}`)}let u=Math.round(e.length/1024);return i&&!o?{stdout:`${l} (${u} KB)\n<img:data:${r};base64,${n(e)}>`,stderr:``,exitCode:0}:o?{stdout:`captured ${u} KB${s===void 0?``:` (${Math.round(s/100)/10}s)`} video to ${a(l)}\n`,stderr:``,exitCode:0}:{stdout:`captured ${u} KB to ${a(l)}\n`,stderr:``,exitCode:0}}function x(){return{stdout:`screencapture - capture screen, window, or tab using browser screen sharing
1
+ import{n as e,r as t}from"./panel-rpc-BPwAqRch.js";import{r as n}from"./base64-BPBW1Gzr.js";import{t as r}from"./subcommand-flags-BZi7j78Q.js";import{t as i}from"./subcommand-help-CgO7wRS5.js";import{i as a}from"./shared-C_68vn79.js";import{n as o,r as s}from"./screencapture-media-shared-DlK1Wqh8.js";import{n as c,t as l}from"./extension-media-capture-DMB4r9UQ.js";const u=[`--clipboard`,`-c`,`--view`,`-v`,`--video`,`--audio`,`-g`],d=[`-V`,`--duration`];function f(e){let t=[];for(let n of e){let e=/^-V(\d+(?:\.\d+)?)$/.exec(n);if(e){t.push(`-V`,e[1]);continue}t.push(n)}return t}function p(e){return{stdout:``,stderr:`screencapture: ${e}\n`,exitCode:1}}function m(e,t){return!e&&!t?p(`browser APIs are unavailable in this environment`):e&&!c()&&!navigator.mediaDevices?.getDisplayMedia?p(`screen capture is not supported in this browser`):null}function h(e){let t=e.split(`.`).pop()?.toLowerCase();return t===`webm`||t===`mp4`||t===`mkv`}function g(e){switch(e.split(`.`).pop()?.toLowerCase()){case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return`image/png`}}function _(e){return e.split(`.`).pop()?.toLowerCase()===`mp4`&&typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(`video/mp4`)?`video/mp4`:`video/webm`}async function v(e,t,n){try{if(c()){let e=await l({kind:`screen`,mimeType:n.mimeType,quality:n.mode===`image`?n.quality:1,mode:n.mode,...n.mode===`video`?{durationMs:n.durationMs,audio:!!n.audio}:{}});return{bytes:e.bytes,mimeType:e.mimeType,...e.durationMs===void 0?{}:{durationMs:e.durationMs}}}if(e){let{captureDisplayMedia:e}=await import(`./screencapture-media-BjmoKpyn.js`),t=await e(n);return{bytes:t.bytes,mimeType:t.mimeType,...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}let r=await t.call(`screencapture`,{mimeType:n.mimeType,quality:n.mode===`image`?n.quality:1,mode:n.mode,...n.mode===`video`?{durationMs:n.durationMs,audio:!!n.audio}:{}},{timeoutMs:n.mode===`video`?3e5+n.durationMs:3e5});return{bytes:new Uint8Array(r.bytes),mimeType:r.mimeType,...r.durationMs===void 0?{}:{durationMs:r.durationMs}}}catch(e){return{error:p(s(e))}}}async function y(e,t,n,r){try{if(c()&&typeof document<`u`&&typeof document.hasFocus==`function`&&!document.hasFocus())return p(`clipboard capture needs a focused window; save to a file instead`);if(n){let n=await O(e,t),r=new ArrayBuffer(n.byteLength);new Uint8Array(r).set(n);let i=new Blob([r],{type:`image/png`});return await k(),await navigator.clipboard.write([new ClipboardItem({"image/png":i})]),{stdout:`captured ${Math.round(i.size/1024)} KB to clipboard\n`,stderr:``,exitCode:0}}return await r.call(`clipboard-write-image`,{bytes:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),mimeType:t},{timeoutMs:3e5}),{stdout:`captured ${Math.round(e.byteLength/1024)} KB to clipboard\n`,stderr:``,exitCode:0}}catch(e){return p(`failed to copy to clipboard: ${e instanceof Error?e.message:String(e)}`)}}async function b(e,t,r,i,o,s,c){let l=c.fs.resolvePath(c.cwd,t);try{await c.fs.writeFile(l,e)}catch(e){return p(`failed to write file: ${e instanceof Error?e.message:String(e)}`)}let u=Math.round(e.length/1024);return i&&!o?{stdout:`${l} (${u} KB)\n<img:data:${r};base64,${n(e)}>`,stderr:``,exitCode:0}:o?{stdout:`captured ${u} KB${s===void 0?``:` (${Math.round(s/100)/10}s)`} video to ${a(l)}\n`,stderr:``,exitCode:0}:{stdout:`captured ${u} KB to ${a(l)}\n`,stderr:``,exitCode:0}}function x(){return{stdout:`screencapture - capture screen, window, or tab using browser screen sharing
2
2
 
3
3
  Usage: screencapture [options] <output-file>
4
4
 
@@ -22,4 +22,4 @@ Examples:
22
22
  screencapture -v capture.png # Capture still for agent vision
23
23
  screencapture --video -V 10 clip.webm # 10s screen recording
24
24
  screencapture -V5 clip.webm # .webm implies video; 5s limit
25
- `,stderr:``,exitCode:0}}function S(e,t){return t.has(`-V`)||t.has(`--duration`)?!1:e.some(e=>e===`-V`||e===`--duration`)}function C(e){let t=f(e),n=r(t,{bool:u,value:d});if(`error`in n)return p(n.error);if(S(t,n.values))return p(`-V/--duration requires a value`);let i=n.bools.has(`--clipboard`)||n.bools.has(`-c`),a=n.bools.has(`--view`)||n.bools.has(`-v`),o=n.bools.has(`--audio`)||n.bools.has(`-g`),s=n.positionals[0],c=n.values.get(`-V`)??n.values.get(`--duration`);if(!i&&!s)return p(`output file required (or use -c for clipboard)`);let l=s||`screenshot.png`,m=n.bools.has(`--video`)||c!==void 0||h(l),g=w({wantVideo:m,toClipboard:i,view:a,audio:o,filename:l});if(g)return g;let _=T(m,c);return`error`in _?_.error:{toClipboard:i,view:a,audio:o,wantVideo:m,filename:l,..._.durationMs===void 0?{}:{durationMs:_.durationMs}}}function w(e){return e.wantVideo&&e.toClipboard?p(`video capture cannot go to the clipboard; save to a .webm file`):e.wantVideo&&e.view?p(`video capture cannot use --view; save to a file and open it`):e.audio&&!e.wantVideo?p(`-g/--audio requires video mode (--video or a .webm/.mp4 file)`):e.wantVideo&&!/\.(webm|mp4|mkv)$/i.test(e.filename)?p(`video capture requires a .webm (preferred), .mp4, or .mkv output file`):null}function T(e,t){if(t!==void 0){let e=Number(t);return!Number.isFinite(e)||e<=0?{error:p(`-V/--duration requires a positive number of seconds (got ${t})`)}:{durationMs:c(e*1e3)}}return e?{durationMs:c(void 0)}:{}}function E(e){if(e.wantVideo)return{mode:`video`,mimeType:_(e.filename),durationMs:e.durationMs??c(void 0),audio:e.audio};let t=g(e.filename);return{mode:`image`,mimeType:t,quality:t===`image/png`?1:.92}}async function D(n,r){if(i(n,{valueFlags:[...d]}))return x();let a=C(n);if(`exitCode`in a)return a;let o=t(),s=e(),c=m(o,s);if(c)return c;let l=await v(o,s,E(a));return`error`in l?l.error:a.toClipboard?y(l.bytes,l.mimeType,o,s):b(l.bytes,a.filename,l.mimeType,a.view,a.wantVideo,l.durationMs,r)}async function O(e,t){if(t===`image/png`)return e;let n=new ArrayBuffer(e.byteLength);new Uint8Array(n).set(e);let r=new Blob([n],{type:t}),i=URL.createObjectURL(r);try{let e=new Image;await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`Failed to load image for conversion`)),e.src=i});let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);if(!n)throw Error(`Failed to get canvas context`);n.drawImage(e,0,0);let r=await new Promise((e,n)=>{t.toBlob(t=>t?e(t):n(Error(`Failed to create PNG blob`)),`image/png`)});return new Uint8Array(await r.arrayBuffer())}finally{URL.revokeObjectURL(i)}}async function k(e=3e5){typeof document>`u`||typeof document.hasFocus==`function`&&(document.hasFocus()||await new Promise((t,n)=>{let r=()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,a),clearTimeout(o)},i=()=>{document.hasFocus()&&(r(),t())},a=()=>{document.visibilityState===`visible`&&document.hasFocus()&&(r(),t())},o=setTimeout(()=>{r(),n(Error(`timed out waiting for window focus`))},e);window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,a)}))}export{l as n,D as runScreencapture,c as t};
25
+ `,stderr:``,exitCode:0}}function S(e,t){return t.has(`-V`)||t.has(`--duration`)?!1:e.some(e=>e===`-V`||e===`--duration`)}function C(e){let t=f(e),n=r(t,{bool:u,value:d});if(`error`in n)return p(n.error);if(S(t,n.values))return p(`-V/--duration requires a value`);let i=n.bools.has(`--clipboard`)||n.bools.has(`-c`),a=n.bools.has(`--view`)||n.bools.has(`-v`),o=n.bools.has(`--audio`)||n.bools.has(`-g`),s=n.positionals[0],c=n.values.get(`-V`)??n.values.get(`--duration`);if(!i&&!s)return p(`output file required (or use -c for clipboard)`);let l=s||`screenshot.png`,m=n.bools.has(`--video`)||c!==void 0||h(l),g=w({wantVideo:m,toClipboard:i,view:a,audio:o,filename:l});if(g)return g;let _=T(m,c);return`error`in _?_.error:{toClipboard:i,view:a,audio:o,wantVideo:m,filename:l,..._.durationMs===void 0?{}:{durationMs:_.durationMs}}}function w(e){return e.wantVideo&&e.toClipboard?p(`video capture cannot go to the clipboard; save to a .webm file`):e.wantVideo&&e.view?p(`video capture cannot use --view; save to a file and open it`):e.audio&&!e.wantVideo?p(`-g/--audio requires video mode (--video or a .webm/.mp4 file)`):e.wantVideo&&!/\.(webm|mp4|mkv)$/i.test(e.filename)?p(`video capture requires a .webm (preferred), .mp4, or .mkv output file`):null}function T(e,t){if(t!==void 0){let e=Number(t);return!Number.isFinite(e)||e<=0?{error:p(`-V/--duration requires a positive number of seconds (got ${t})`)}:{durationMs:o(e*1e3)}}return e?{durationMs:o(void 0)}:{}}function E(e){if(e.wantVideo)return{mode:`video`,mimeType:_(e.filename),durationMs:e.durationMs??o(void 0),audio:e.audio};let t=g(e.filename);return{mode:`image`,mimeType:t,quality:t===`image/png`?1:.92}}async function D(n,r){if(i(n,{valueFlags:[...d]}))return x();let a=C(n);if(`exitCode`in a)return a;let o=t(),s=e(),c=m(o,s);if(c)return c;let l=await v(o,s,E(a));return`error`in l?l.error:a.toClipboard?y(l.bytes,l.mimeType,o,s):b(l.bytes,a.filename,l.mimeType,a.view,a.wantVideo,l.durationMs,r)}async function O(e,t){if(t===`image/png`)return e;let n=new ArrayBuffer(e.byteLength);new Uint8Array(n).set(e);let r=new Blob([n],{type:t}),i=URL.createObjectURL(r);try{let e=new Image;await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`Failed to load image for conversion`)),e.src=i});let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);if(!n)throw Error(`Failed to get canvas context`);n.drawImage(e,0,0);let r=await new Promise((e,n)=>{t.toBlob(t=>t?e(t):n(Error(`Failed to create PNG blob`)),`image/png`)});return new Uint8Array(await r.arrayBuffer())}finally{URL.revokeObjectURL(i)}}async function k(e=3e5){typeof document>`u`||typeof document.hasFocus==`function`&&(document.hasFocus()||await new Promise((t,n)=>{let r=()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,a),clearTimeout(o)},i=()=>{document.hasFocus()&&(r(),t())},a=()=>{document.visibilityState===`visible`&&document.hasFocus()&&(r(),t())},o=setTimeout(()=>{r(),n(Error(`timed out waiting for window focus`))},e);window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,a)}))}export{D as runScreencapture};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./proxied-fetch-Bl8AeYdt.js";import{a as t,t as n}from"./api-endpoint-DGxXvrur.js";import{n as r}from"./float-topology-CurCyQFy.js";import"./secret-topology-CVneCnID.js";import{n as i}from"./secrets-bridge-client-C0tvQeuX.js";function a(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}var o=e(`secret-env`),s=1e4;function c(e){let t={},n;for(let r of e)!r?.name||!r?.maskedValue||(r.name===`oauth.github.token`&&(n=r.maskedValue),a(r.name)&&(t[r.name]=r.maskedValue));return n&&(t.GITHUB_TOKEN===void 0&&(t.GITHUB_TOKEN=n),t.GH_TOKEN===void 0&&(t.GH_TOKEN=n)),t}async function l(){let e=r();if(e===`extension-direct`)return new Promise(e=>{chrome.runtime.sendMessage({type:`secrets.list-masked-entries`},t=>{let n=c(t?.entries??[]);Object.keys(n).length>0&&o.info(`Loaded masked secrets into shell env from SW`,{count:Object.keys(n).length}),e(n)})});if(e===`extension-delegate`)try{let e=c((await i(`secrets.list-masked-entries`))?.entries??[]);return Object.keys(e).length>0&&o.info(`Loaded masked secrets into shell env from bridge`,{count:Object.keys(e).length}),e}catch(e){return o.debug(`Bridge list-masked-entries failed`,{error:e instanceof Error?e.message:String(e)}),{}}if(e===`connect`)return{};try{let e=await fetch(t(`/api/secrets/masked`),{headers:n(),signal:AbortSignal.timeout(s)});if(!e.ok)return o.warn(`Failed to fetch masked secrets`,{status:e.status}),{};let r=await e.json();if(!Array.isArray(r)||r.length===0)return{};let i=c(r);return Object.keys(i).length>0&&o.info(`Loaded masked secrets into shell env`,{count:Object.keys(i).length}),i}catch(e){return o.debug(`Could not fetch masked secrets (server may be unavailable)`,{error:e instanceof Error?e.message:String(e)}),{}}}export{l as fetchSecretEnvVars};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import"./proxied-fetch-CnCvBaGV.js";import{a as t,t as n}from"./api-endpoint-DGxXvrur.js";import{n as r}from"./float-topology-CyZCUfkj.js";import"./secret-topology-BrobAGSV.js";import{n as i}from"./secrets-bridge-client-BJqZCK6Q.js";function a(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}var o=e(`secret-env`),s=1e4;function c(e){let t={},n;for(let r of e)!r?.name||!r?.maskedValue||(r.name===`oauth.github.token`&&(n=r.maskedValue),a(r.name)&&(t[r.name]=r.maskedValue));return n&&(t.GITHUB_TOKEN===void 0&&(t.GITHUB_TOKEN=n),t.GH_TOKEN===void 0&&(t.GH_TOKEN=n)),t}async function l(){let e=r();if(e===`extension-direct`)return new Promise(e=>{chrome.runtime.sendMessage({type:`secrets.list-masked-entries`},t=>{let n=c(t?.entries??[]);Object.keys(n).length>0&&o.info(`Loaded masked secrets into shell env from SW`,{count:Object.keys(n).length}),e(n)})});if(e===`extension-delegate`)try{let e=c((await i(`secrets.list-masked-entries`))?.entries??[]);return Object.keys(e).length>0&&o.info(`Loaded masked secrets into shell env from bridge`,{count:Object.keys(e).length}),e}catch(e){return o.debug(`Bridge list-masked-entries failed`,{error:e instanceof Error?e.message:String(e)}),{}}if(e===`connect`)return{};try{let e=await fetch(t(`/api/secrets/masked`),{headers:n(),signal:AbortSignal.timeout(s)});if(!e.ok)return o.warn(`Failed to fetch masked secrets`,{status:e.status}),{};let r=await e.json();if(!Array.isArray(r)||r.length===0)return{};let i=c(r);return Object.keys(i).length>0&&o.info(`Loaded masked secrets into shell env`,{count:Object.keys(i).length}),i}catch(e){return o.debug(`Could not fetch masked secrets (server may be unavailable)`,{error:e instanceof Error?e.message:String(e)}),{}}}export{l as fetchSecretEnvVars};
@@ -0,0 +1 @@
1
+ import"./float-topology-CyZCUfkj.js";
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./port-bridge-client-ff8DctEN.js";var n=t({portName:`secrets.crud`,panelRpcOp:`secrets-bridge`,timeoutMs:1e4,onUnavailable:`resolve-undefined`,makeError:e=>Error(e),logNamespace:`secrets-bridge`,toPortMessage:({type:e,payload:t})=>({type:e,...t}),toPanelRpcPayload:({type:e,payload:t})=>({type:e,payload:t})});function r(e,t){return n({type:e,payload:t})}var i=e({callSecretsBridge:()=>r});export{r as n,i as t};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./port-bridge-client-CZFX4fUT.js";var n=t({portName:`secrets.crud`,panelRpcOp:`secrets-bridge`,timeoutMs:1e4,onUnavailable:`resolve-undefined`,makeError:e=>Error(e),logNamespace:`secrets-bridge`,toPortMessage:({type:e,payload:t})=>({type:e,...t}),toPanelRpcPayload:({type:e,payload:t})=>({type:e,payload:t})});function r(e,t){return n({type:e,payload:t})}var i=e({callSecretsBridge:()=>r});export{r as n,i as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./port-bridge-client-H03Pohgj.js";var n=e({callSecretsBridge:()=>i});const r=t({portName:`secrets.crud`,panelRpcOp:`secrets-bridge`,timeoutMs:1e4,onUnavailable:`resolve-undefined`,makeError:e=>Error(e),logNamespace:`secrets-bridge`,toPortMessage:({type:e,payload:t})=>({type:e,...t}),toPanelRpcPayload:({type:e,payload:t})=>({type:e,payload:t})});function i(e,t){return r({type:e,payload:t})}export{n,i as t};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./port-bridge-client-CkkC3v5w.js";var n=e({callSecretsBridge:()=>i});const r=t({portName:`secrets.crud`,panelRpcOp:`secrets-bridge`,timeoutMs:1e4,onUnavailable:`resolve-undefined`,makeError:e=>Error(e),logNamespace:`secrets-bridge`,toPortMessage:({type:e,payload:t})=>({type:e,...t}),toPanelRpcPayload:({type:e,payload:t})=>({type:e,payload:t})});function i(e,t){return r({type:e,payload:t})}export{n,i as t};
@@ -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-CABvtt-r.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-CABvtt-r.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-DVbOtPFF.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-BT4ZJZt7.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-BT4ZJZt7.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-D4biUAiV.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,3 +1,3 @@
1
- import{t as e}from"./types-D8gIX-W-.js";import{c as t,u as n}from"./kernel-worker-4aPSVJ1C.js";import"./frozen-archive-writer-BIzZxx8R.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{a as t,r as n}from"./kernel-worker-CBI5EKGn.js";import"./frozen-archive-writer-rq_r_D3R.js";function r(e){let t=`${e.endsWith(`.md`)?e.slice(0,-3):e.replace(/\.md$/i,``)}.jsonl`;return t.startsWith(`/`)?t:`${n}/${t}`}async function i(e,n,r){let i=t(n);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,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{Tt as t,rt as n}from"./wc-shell-CCKjmASt.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{Tt as t,rt as n}from"./wc-shell-M1btJNO6.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{c as e,d as t}from"./kernel-worker-4aPSVJ1C.js";import{loadFrozenArchive as n}from"./session-jsonl-iOOR_32X.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
- `),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(`
1
+ import{o as e,r as t}from"./kernel-worker-CBI5EKGn.js";import{loadFrozenArchive as n}from"./session-jsonl-C8ClVNxB.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
+ `),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 e(n)).map(e=>({entry:e,sessionsDir:t}));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(e,n,r=t){let i=await S(e,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(e,r,i=t){try{let t=`${i}/${r.filename}`,a=await e.readFile(t,{encoding:`utf-8`}),o=typeof a==`string`?a:new TextDecoder().decode(a);return(await n(e,o,t)).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-jc6OS8lz.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-BfonTdzP.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-BPBW1Gzr.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-B05_LKnj.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-BPBW1Gzr.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-C0smCH0b.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};