sliccy 6.167.0 → 6.168.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 (215) hide show
  1. package/README.md +1 -0
  2. package/dist/node-server/_shared/computer-protocol.d.ts +2 -0
  3. package/dist/node-server/_shared/computer-protocol.d.ts.map +1 -1
  4. package/dist/node-server/computer-demo.d.ts +36 -0
  5. package/dist/node-server/computer-demo.js +126 -0
  6. package/dist/node-server/index.js +13 -3
  7. package/dist/node-server/runtime-flags.d.ts +2 -0
  8. package/dist/node-server/runtime-flags.js +5 -0
  9. package/dist/ui/.vite/manifest.json +260 -251
  10. package/dist/ui/assets/SKILL-CQxpe2fi.js +1 -0
  11. package/dist/ui/assets/{account-store-B05_LKnj.js → account-store-jjUZwcjI.js} +1 -1
  12. package/dist/ui/assets/{account-store-CNTI4kr_.js → account-store-pXgYgQVx.js} +2 -2
  13. package/dist/ui/assets/{adobe-nu3irXcy.js → adobe-C42_geSB.js} +1 -1
  14. package/dist/ui/assets/{adobe-CRRWEbtf.js → adobe-CKCos4Yf.js} +2 -2
  15. package/dist/ui/assets/{agent-panels-DvH_qfTh.js → agent-panels-C34MxFav.js} +1 -1
  16. package/dist/ui/assets/{almost-bash-shell-headless-BA5r_r61.js → almost-bash-shell-headless-B5YFQ1wh.js} +521 -548
  17. package/dist/ui/assets/{apply-layout-CASSSWEy.js → apply-layout-D2V9rxZu.js} +1 -1
  18. package/dist/ui/assets/approval-timeout-BQ29Z0gf.js +1 -0
  19. package/dist/ui/assets/{apps-BGe9_zJ7.js → apps-CVkFAyGJ.js} +1 -1
  20. package/dist/ui/assets/{azure-openai-C-Iw82HZ.js → azure-openai-DucxGbzT.js} +1 -1
  21. package/dist/ui/assets/{azure-openai-DuJciOKd.js → azure-openai-yAg-vpgC.js} +1 -1
  22. package/dist/ui/assets/{backend-hostfs-DdAVlPMP.js → backend-hostfs-Ls-A2H2N.js} +1 -1
  23. package/dist/ui/assets/browser-DuyhpHbR.js +1 -0
  24. package/dist/ui/assets/{capability-C2eJ1wdx.js → capability-SIitRcq_.js} +2 -2
  25. package/dist/ui/assets/{cdp-DG8TVjf3.js → cdp-DDYzhKE6.js} +1 -1
  26. package/dist/ui/assets/{cerebras-BXwtUxTj.js → cerebras-CNR3k849.js} +1 -1
  27. package/dist/ui/assets/{cerebras-Xadzrxfp.js → cerebras-_--8Umtj.js} +1 -1
  28. package/dist/ui/assets/{client-BDN4zG90.js → client-_vVqanZy.js} +1 -1
  29. package/dist/ui/assets/{composer-speech-_uq5e0Bo.js → composer-speech-D8IeaPdq.js} +1 -1
  30. package/dist/ui/assets/{connect-surface-odDz37TJ.js → connect-surface-Bnfiw-HT.js} +1 -1
  31. package/dist/ui/assets/{core-BoFWHLIW.js → core-eZ1aR21T.js} +1 -1
  32. package/dist/ui/assets/core-vzw5Cr8B.js +36 -0
  33. package/dist/ui/assets/{directed-approval-D_AXAvuz.js → directed-approval-CtbQZigA.js} +1 -1
  34. package/dist/ui/assets/{discovery-preference-TziZ7Yxu.js → discovery-preference-G3mw_EUO.js} +1 -1
  35. package/dist/ui/assets/{ensure-speech-assets-DTj236n-.js → ensure-speech-assets-BGvEg25e.js} +1 -1
  36. package/dist/ui/assets/es-DJTRBqjm.js +52 -0
  37. package/dist/ui/assets/{extension-ops-DNPAsYbK.js → extension-ops-B2RMipFn.js} +1 -1
  38. package/dist/ui/assets/{float-topology-CurCyQFy.js → float-topology-CyZCUfkj.js} +1 -1
  39. package/dist/ui/assets/{follower-navigate-watcher-C98XMw_C.js → follower-navigate-watcher-BAstHBQ5.js} +1 -1
  40. package/dist/ui/assets/frames-FHlUaNCs.js +1 -0
  41. package/dist/ui/assets/{frozen-archive-writer-BIzZxx8R.js → frozen-archive-writer-DFE4MYD-.js} +1 -1
  42. package/dist/ui/assets/{fs-Bq8bUwe2.js → fs-BLqkdQnU.js} +1 -1
  43. package/dist/ui/assets/{fs-CJs9n90Q.js → fs-DRouAGaW.js} +2 -2
  44. package/dist/ui/assets/{gelatiere-store-BY0hZvSS.js → gelatiere-store-D_JKXdpV.js} +1 -1
  45. package/dist/ui/assets/{gelatiere-unit-DrQwRL3O.js → gelatiere-unit-Q-gB5yVf.js} +1 -1
  46. package/dist/ui/assets/{github-uDwUwz5H.js → github-Cfpmwf1n.js} +1 -1
  47. package/dist/ui/assets/{github-D1gd3q6u.js → github-DLAFwQdm.js} +2 -2
  48. package/dist/ui/assets/{github-auth-CzzE1eDf.js → github-auth-DnIBV6_3.js} +1 -1
  49. package/dist/ui/assets/{github-copilot-Bx2lXrwK.js → github-copilot-BFfPdiKK.js} +1 -1
  50. package/dist/ui/assets/{github-copilot-DidNEEe_.js → github-copilot-EtGePnlq.js} +1 -1
  51. package/dist/ui/assets/{github-install--_xp8s-S.js → github-install-1nDy7YKR.js} +1 -1
  52. package/dist/ui/assets/{github-zip-Bs35nBig.js → github-zip-B-FKgUOX.js} +1 -1
  53. package/dist/ui/assets/{guest-tool-gate-B-lZT9hl.js → guest-tool-gate-GANtsowg.js} +1 -1
  54. package/dist/ui/assets/{hear-BNmJphKg.js → hear-BMEHlsdb.js} +1 -1
  55. package/dist/ui/assets/{help-C7Nq107k.js → help-DWGffc9y.js} +1 -1
  56. package/dist/ui/assets/{host-iTtS0MRF.js → host-AggLcUuh.js} +1 -1
  57. package/dist/ui/assets/host-command-XUdketMY.js +28 -0
  58. package/dist/ui/assets/{installer-C0xiAs69.js → installer-BHkUBh6r.js} +1 -1
  59. package/dist/ui/assets/{isomorphic-git-D2fV6xS-.js → isomorphic-git-B8-ayEVu.js} +7 -7
  60. package/dist/ui/assets/{isomorphic-git-B7et_8Xe.js → isomorphic-git-DuHitnAl.js} +10 -10
  61. package/dist/ui/assets/{js-realm-worker-B9Rz0g1p.js → js-realm-worker-Zk_Jd1kr.js} +1 -1
  62. package/dist/ui/assets/{jsh-executor-C7QPZ2Qr.js → jsh-executor-K5sbbmbA.js} +2 -2
  63. package/dist/ui/assets/{kernel-worker-4aPSVJ1C.js → kernel-worker-Bq9IjFw5.js} +34 -34
  64. package/dist/ui/assets/lick-urls-CgPiVwD-.js +1 -0
  65. package/dist/ui/assets/lick-ws-bridge-8HhoCHq8.js +1 -0
  66. package/dist/ui/assets/{lick-ws-bridge-BcAhlead.js → lick-ws-bridge-Ra_w6naR.js} +1 -1
  67. package/dist/ui/assets/{live-session-snapshot-COMr2v0o.js → live-session-snapshot-lUnl-mYx.js} +1 -1
  68. package/dist/ui/assets/{local-llm-DdGb9WMG.js → local-llm-B80bjN-D.js} +1 -1
  69. package/dist/ui/assets/{local-llm-DqeU7kV3.js → local-llm-OcOXhJKt.js} +1 -1
  70. package/dist/ui/assets/{main-jc6OS8lz.js → main-BRoNZPBl.js} +3 -3
  71. package/dist/ui/assets/{main-cherry-BGZmJFd_.js → main-cherry-DD2gWq8O.js} +1 -1
  72. package/dist/ui/assets/{memory-curation-seam-B8pprlUo.js → memory-curation-seam-CcNJCyMJ.js} +1 -1
  73. package/dist/ui/assets/{memory-health-CGkpyA7o.js → memory-health-DZmKH-IW.js} +1 -1
  74. package/dist/ui/assets/memory-v2-flag-DK0lPu0X.js +1 -0
  75. package/dist/ui/assets/{memory-write-execute-B-ahXjaO.js → memory-write-execute-6yK_MOdy.js} +1 -1
  76. package/dist/ui/assets/{mount-BzdPNQoA.js → mount-CQBa9QoF.js} +3 -3
  77. package/dist/ui/assets/{mount-FkNAB0be.js → mount-Dz-lPlKf.js} +1 -1
  78. package/dist/ui/assets/{mount-bridge-client-BO0N4wwP.js → mount-bridge-client-BOZDQLbT.js} +1 -1
  79. package/dist/ui/assets/{mount-bridge-client-CRnohfom.js → mount-bridge-client-BRywSH1d.js} +1 -1
  80. package/dist/ui/assets/{mv-DRuZuDHt.js → mv-C7mk2zT1.js} +1 -1
  81. package/dist/ui/assets/{new-session-B8iOhaK0.js → new-session-CXbgg4am.js} +2 -2
  82. package/dist/ui/assets/{oauth-bootstrap-B9PwK4-d.js → oauth-bootstrap-1lsyWJGc.js} +2 -2
  83. package/dist/ui/assets/{oauth-service-UTPOqIwj.js → oauth-service-CRmx6zI1.js} +1 -1
  84. package/dist/ui/assets/{oauth-service-Bkaz0Dt4.js → oauth-service-WTeDvR5m.js} +1 -1
  85. package/dist/ui/assets/{onboarding-orchestrator-Cc8Glrem.js → onboarding-orchestrator-SsjiVLB2.js} +1 -1
  86. package/dist/ui/assets/{openai-codex-BrQ1tsgu.js → openai-codex-BJzpp5yt.js} +1 -1
  87. package/dist/ui/assets/{openai-codex-DmHr_2RR.js → openai-codex-DDer9WGr.js} +1 -1
  88. package/dist/ui/assets/{openrouter-C6WDBJvB.js → openrouter-CdsU1YkP.js} +1 -1
  89. package/dist/ui/assets/{openrouter-free-CUKlyrhq.js → openrouter-free-D1H2Ji7e.js} +1 -1
  90. package/dist/ui/assets/{openrouter-free-CFBzPY5J.js → openrouter-free-zplQAXSX.js} +1 -1
  91. package/dist/ui/assets/{openrouter-oauth-DOdpRMfw.js → openrouter-oauth-Bu3uuWMP.js} +1 -1
  92. package/dist/ui/assets/{openrouter-oauth-RC0CxY4X.js → openrouter-oauth-CrvWvUZV.js} +1 -1
  93. package/dist/ui/assets/{openrouter-BvM36eS5.js → openrouter-xGsvfFPH.js} +1 -1
  94. package/dist/ui/assets/{opfs-mount-B78yj9gx.js → opfs-mount-BqBx391V.js} +1 -1
  95. package/dist/ui/assets/{page-approval-service-Dy-UA1aK.js → page-approval-service-BkqDCbBQ.js} +1 -1
  96. package/dist/ui/assets/panel-rpc-handlers-CXr7dAtk.js +2 -0
  97. package/dist/ui/assets/{panelize-shell-CFPiIneK.js → panelize-shell-DjnrzeLU.js} +1 -1
  98. package/dist/ui/assets/{pi-edit-execution-BDl_Xp_M.js → pi-edit-execution-Dn7wc7f8.js} +1 -1
  99. package/dist/ui/assets/{port-bridge-client-ff8DctEN.js → port-bridge-client-CZFX4fUT.js} +1 -1
  100. package/dist/ui/assets/{port-bridge-client-H03Pohgj.js → port-bridge-client-CkkC3v5w.js} +1 -1
  101. package/dist/ui/assets/{provider-1ByYSphI.js → provider-BCNJf9_1.js} +2 -2
  102. package/dist/ui/assets/{provider-Df8LFEZ7.js → provider-DiIrGlmw.js} +1 -1
  103. package/dist/ui/assets/{provider-settings-Bk-fk9dp.js → provider-settings-DSf8xD9N.js} +1 -1
  104. package/dist/ui/assets/provider-store-access-CsczvZfg.js +1 -0
  105. package/dist/ui/assets/provider-store-access-et-xszx-.js +1 -0
  106. package/dist/ui/assets/{providers-Q92pCQ8h.js → providers-CFveri5U.js} +2 -2
  107. package/dist/ui/assets/{providers-T_FH_8cU.js → providers-CfE8Z8rn.js} +1 -1
  108. package/dist/ui/assets/{proxied-fetch-DARKNygr.js → proxied-fetch-CPL8wJM2.js} +1 -1
  109. package/dist/ui/assets/{proxied-fetch-Bl8AeYdt.js → proxied-fetch-CnCvBaGV.js} +1 -1
  110. package/dist/ui/assets/{quick-llm-CbGHjrhX.js → quick-llm-t6CBwwSm.js} +1 -1
  111. package/dist/ui/assets/{realm-inprocess-CWMnXeN3.js → realm-inprocess-CmaGqRYS.js} +1 -1
  112. package/dist/ui/assets/{recovery-screen-DhUqOdby.js → recovery-screen-DdKutJyi.js} +1 -1
  113. package/dist/ui/assets/{redirect-uri-Dd0j1fSp.js → redirect-uri-D2aDPCyB.js} +1 -1
  114. package/dist/ui/assets/{remote-terminal-view-D4Ah4AQY.js → remote-terminal-view-CA-SfvvZ.js} +2 -2
  115. package/dist/ui/assets/{rest-ops-CQOwDiTR.js → rest-ops-Yu_dXm4T.js} +1 -1
  116. package/dist/ui/assets/{rest-ops-DkUeDpiM.js → rest-ops-aP40ni1y.js} +1 -1
  117. package/dist/ui/assets/{restore-CVkulBmU.js → restore-Dk9r9feA.js} +1 -1
  118. package/dist/ui/assets/{run-B-t7kWH3.js → run-BEs473Sp.js} +1 -1
  119. package/dist/ui/assets/run-CHjRjdbt.js +75 -0
  120. package/dist/ui/assets/{run-DgVV_DFr.js → run-CNldrNje.js} +3 -3
  121. package/dist/ui/assets/{run-ZmpHaamT.js → run-CyYVrNXy.js} +2 -2
  122. package/dist/ui/assets/{run-BX9uHbIi.js → run-D5s_jfOL.js} +1 -1
  123. package/dist/ui/assets/{run-COfTem8j.js → run-QfYlwe2c.js} +1 -1
  124. package/dist/ui/assets/{run-IexPmM2B.js → run-V-RPlN7V.js} +2 -2
  125. package/dist/ui/assets/{run-CUCg2cJM.js → run-wxYu-gUG.js} +2 -2
  126. package/dist/ui/assets/screen-s6LdF1JP.js +1 -0
  127. package/dist/ui/assets/screen-share-approval-live-D388fVD9.js +1 -0
  128. package/dist/ui/assets/screencapture-media-BjmoKpyn.js +1 -0
  129. package/dist/ui/assets/screencapture-media-CM5E2g6c.js +1 -0
  130. package/dist/ui/assets/screencapture-media-shared-DlK1Wqh8.js +1 -0
  131. package/dist/ui/assets/{screencapture-run-yMA5c_HS.js → screencapture-run-zmx5QKf_.js} +2 -2
  132. package/dist/ui/assets/{secret-env-BhWGz7yx.js → secret-env-DgrZZVFU.js} +1 -1
  133. package/dist/ui/assets/secret-topology-BrobAGSV.js +1 -0
  134. package/dist/ui/assets/{secrets-bridge-client-C0tvQeuX.js → secrets-bridge-client-BJqZCK6Q.js} +1 -1
  135. package/dist/ui/assets/{secrets-bridge-client-BS3V1JBF.js → secrets-bridge-client-CeK7HpDf.js} +1 -1
  136. package/dist/ui/assets/{session-command-memory-DzuRy-nC.js → session-command-memory-x5HxxZtb.js} +2 -2
  137. package/dist/ui/assets/{session-jsonl-iOOR_32X.js → session-jsonl-3Y2sXuNG.js} +1 -1
  138. package/dist/ui/assets/{session-jsonl-D01HYAS2.js → session-jsonl-DI8wVUpH.js} +1 -1
  139. package/dist/ui/assets/{session-search-index-CABvtt-r.js → session-search-index-DRFKeHXl.js} +1 -1
  140. package/dist/ui/assets/{setup-feature-flags-remote-CvstKwBW.js → setup-feature-flags-remote-CEtNYgED.js} +1 -1
  141. package/dist/ui/assets/{signed-fetch-7NwdVmf1.js → signed-fetch-E-2q08XL.js} +1 -1
  142. package/dist/ui/assets/{silent-renew-backoff-CXHqSiPb.js → silent-renew-backoff-Ddlf2gAw.js} +1 -1
  143. package/dist/ui/assets/slicc-version-bYxfYms3.js +1 -0
  144. package/dist/ui/assets/{snapshot-BcYaw9Ip.js → snapshot-Dv7-7kFE.js} +1 -1
  145. package/dist/ui/assets/{snapshot-features-3xslkGtL.js → snapshot-features-rlYmVQ8i.js} +1 -1
  146. package/dist/ui/assets/{soundscape-TygolFwj.js → soundscape-CyBhtUGQ.js} +1 -1
  147. package/dist/ui/assets/{speak-BCLm04Z2.js → speak-qRc1po5e.js} +1 -1
  148. package/dist/ui/assets/{sprinkle-manager-DDzNanda.js → sprinkle-manager-DT2AYalc.js} +1 -1
  149. package/dist/ui/assets/{sprinkle-renderer-B-CADNjq.js → sprinkle-renderer-DF4JYgsw.js} +1 -1
  150. package/dist/ui/assets/ssh-BQqlQVXQ.js +6 -0
  151. package/dist/ui/assets/{state-BCTAzK_L.js → state-RVr0GidF.js} +1 -1
  152. package/dist/ui/assets/{store-C-AW4ogv.js → store-BlFQl8dG.js} +1 -1
  153. package/dist/ui/assets/{store-CzlK9KIc.js → store-CYwEydJ4.js} +1 -1
  154. package/dist/ui/assets/{sudo-BtkDnUA_.js → sudo-BqpeZUOO.js} +1 -1
  155. package/dist/ui/assets/sudo-fs-C6r_MIIY.js +3 -0
  156. package/dist/ui/assets/{supervisor-B6-QPxI3.js → supervisor-C1sPrIbH.js} +1 -1
  157. package/dist/ui/assets/{sync-dialog-B4G7kCwj.js → sync-dialog-sC277gbg.js} +1 -1
  158. package/dist/ui/assets/tool-ui-DRnUkp2g.js +1 -0
  159. package/dist/ui/assets/{transformers-env-1TbBNkOp.js → transformers-env-BzsQpYgD.js} +1 -1
  160. package/dist/ui/assets/{tray-leader-_KISvFyF.js → tray-leader-Gx_yzXFX.js} +1 -1
  161. package/dist/ui/assets/{lick-urls-DdKPDlgq.js → tray-leader-status-CpkFr6n7.js} +1 -1
  162. package/dist/ui/assets/{tray-leave-runtime-CRsRkPHc.js → tray-leave-runtime-Cuj-CStD.js} +1 -1
  163. package/dist/ui/assets/{tray-runtime-config-BVgVR3H2.js → tray-runtime-config-dyxCfUex.js} +1 -1
  164. package/dist/ui/assets/{tray-sidecar-BRvCb-i7.js → tray-sidecar-BCAds1ts.js} +1 -1
  165. package/dist/ui/assets/{upgrade-detection-C5daiUbn.js → upgrade-detection-CXNgKpwK.js} +1 -1
  166. package/dist/ui/assets/{upskill-lick-skip-C2ZQ0c2-.js → upskill-lick-skip-wDM3Vdyq.js} +1 -1
  167. package/dist/ui/assets/url-Dq7PTmNp.js +1 -0
  168. package/dist/ui/assets/v86-Cv7l0TeZ.js +1 -0
  169. package/dist/ui/assets/{voice-reply-Dk4ztuZL.js → voice-reply-DPbxkmsy.js} +1 -1
  170. package/dist/ui/assets/{wc-attach-CFj2ZF5_.js → wc-attach-C-7ZwxKV.js} +2 -2
  171. package/dist/ui/assets/{wc-browser-BFL2Tl8W.js → wc-browser-D-03DBqa.js} +1 -1
  172. package/dist/ui/assets/wc-computers-m_Qiklfg.js +3 -0
  173. package/dist/ui/assets/{wc-detached-ncc8KuL1.js → wc-detached-D5_bAfyn.js} +1 -1
  174. package/dist/ui/assets/{wc-extension-DppNe2VK.js → wc-extension-DSvNnUY6.js} +2 -2
  175. package/dist/ui/assets/{wc-follower-CcxFCW-y.js → wc-follower-1feBQ0f-.js} +3 -3
  176. package/dist/ui/assets/{wc-follower-oauth-DQ-JPxl6.js → wc-follower-oauth-JZo8mi8y.js} +1 -1
  177. package/dist/ui/assets/{wc-gelatiere-CANPh9TU.js → wc-gelatiere-Wr8PEKDG.js} +1 -1
  178. package/dist/ui/assets/{wc-live-BLozTZsg.js → wc-live-DT1WB50h.js} +17 -17
  179. package/dist/ui/assets/{wc-nav-BlLpBAJG.js → wc-nav-BCq8EXtI.js} +2 -2
  180. package/dist/ui/assets/{wc-onboarding-OKaUOQ3X.js → wc-onboarding-1l4fZpDo.js} +2 -2
  181. package/dist/ui/assets/{wc-permissions-BsGMi4OQ.js → wc-permissions-CCA-0PP4.js} +2 -2
  182. package/dist/ui/assets/{wc-placeholder-BrX9-mPv.js → wc-placeholder-ODIHzW-8.js} +3 -3
  183. package/dist/ui/assets/{wc-secret-request-QPmTs_eW.js → wc-secret-request-CWyoYT_T.js} +1 -1
  184. package/dist/ui/assets/{wc-settings-BFgFDtTk.js → wc-settings-Df49ivPm.js} +3 -3
  185. package/dist/ui/assets/{wc-shell-CCKjmASt.js → wc-shell-CZ95TYrc.js} +4 -4
  186. package/dist/ui/assets/{wc-shortcut-config-CeUoljrV.js → wc-shortcut-config-CmRCkDN0.js} +1 -1
  187. package/dist/ui/assets/{wc-sprinkles-BNp18_jW.js → wc-sprinkles-Cm0F47mC.js} +2 -2
  188. package/dist/ui/assets/{wc-transcript-export-DJnnZ8L-.js → wc-transcript-export-CMdPvQk4.js} +2 -2
  189. package/dist/ui/assets/{wc-tray-f1LxbB98.js → wc-tray-2XQPor_4.js} +4 -4
  190. package/dist/ui/assets/welcome-detection-CouG8kRR.js +1 -0
  191. package/dist/ui/assets/{whisper-session-CMiImrJg.js → whisper-session-z9qnQTAM.js} +2 -2
  192. package/dist/ui/assets/{xai-grok-BMr5udF6.js → xai-grok-BmuhN83h.js} +1 -1
  193. package/dist/ui/assets/{xai-grok-Dzeo18XM.js → xai-grok-CaNUqqnT.js} +1 -1
  194. package/dist/ui/index.html +9 -9
  195. package/dist/ui/packages/webapp/index.html +9 -9
  196. package/package.json +1 -1
  197. package/dist/ui/assets/SKILL-CWR-bsvH.js +0 -1
  198. package/dist/ui/assets/browser-2rCVqcqy.js +0 -1
  199. package/dist/ui/assets/core-Bvc89tkf.js +0 -36
  200. package/dist/ui/assets/es-DwGGEZle.js +0 -51
  201. package/dist/ui/assets/keys-Dexx8cLD.js +0 -1
  202. package/dist/ui/assets/lick-ws-bridge-DZ0vVYNF.js +0 -1
  203. package/dist/ui/assets/memory-v2-flag-DVbOtPFF.js +0 -1
  204. package/dist/ui/assets/panel-rpc-handlers-CQ_iaU6N.js +0 -2
  205. package/dist/ui/assets/provider-store-access-BJPbOUku.js +0 -1
  206. package/dist/ui/assets/provider-store-access-BrjCBzpb.js +0 -1
  207. package/dist/ui/assets/run-DvD576xV.js +0 -53
  208. package/dist/ui/assets/screencapture-media-DL5YxrlG.js +0 -1
  209. package/dist/ui/assets/screencapture-media-YBE2VnLF.js +0 -1
  210. package/dist/ui/assets/secret-topology-CVneCnID.js +0 -1
  211. package/dist/ui/assets/slicc-version-CN6V2aMa.js +0 -1
  212. package/dist/ui/assets/sudo-fs-D620mZry.js +0 -3
  213. package/dist/ui/assets/v86-BfdTUFBK.js +0 -1
  214. package/dist/ui/assets/wc-computers-CcJuQUyG.js +0 -3
  215. package/dist/ui/assets/welcome-detection-Dg9THpkh.js +0 -1
@@ -1 +1 @@
1
- import{_ as e,r as t}from"./account-store-B05_LKnj.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r,n as i,r as a}from"./compat-uEPf6-XW.js";import{a as o,c as s,i as c,r as l,s as u,t as d}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-Bk-fk9dp.js";function f(e){if(!e||typeof e!=`object`)return null;let t=e.quota_snapshots?.premium_interactions;return!t||t.unlimited||typeof t.percent_remaining!=`number`?null:{percent:Math.max(0,100-t.percent_remaining),status:t.percent_remaining<=0&&t.overage_permitted!==!0?`rate-limited`:`ok`,window:`monthly`,resetsAt:e.quota_reset_date_utc}}async function p(e,t,n={}){let r=typeof AbortController==`function`?new AbortController:null,i=r?setTimeout(()=>r.abort(),n.timeoutMs??8e3):null;try{let i=await t(`https://api.github.com/copilot_internal/user`,{headers:{...n.headers,Authorization:`Bearer ${e}`},...r?{signal:r.signal}:{}});if(i.status===404||i.status===501)return null;if(!i.ok)throw Error(`GitHub Copilot /copilot_internal/user returned ${i.status}`);return f(await i.json())}finally{i&&clearTimeout(i)}}const m=`github-copilot`,h=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),g={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},_={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function v(){return t().find(e=>e.providerId===m)}async function y(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:_,body:new URLSearchParams({client_id:h,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function b(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await x(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:_,body:new URLSearchParams({client_id:h,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function x(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function S(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function C(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...g,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-3e5,apiBaseUrl:S(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const w=`github-copilot.models.v1`;function T(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function E(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:T(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function D(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...g,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return E(await t.json())}function O(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(w);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function k(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(w,JSON.stringify(e))}catch{}}function A(e){return O().find(t=>t.id===e)??null}async function j(e){let t;try{t=await D(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}k(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...g,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),k(t)}async function M(t,n){await e({providerId:m,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function N(){let e=v();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await C(e.refreshToken);return await M(n,e.userName),n.copilotToken}const P=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function F(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!P.some(e=>t.some(t=>t.includes(e)))}function I(){if(!v()?.accessToken)return[];let e=O();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>F(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=a(`github-copilot`)}catch{return[]}return t.filter(e=>F({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function L(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:m,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const R={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function z(e){let t=v(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=A(e);if(r)return{api:r.api,baseUrl:n,headers:{...R}};try{let n=i(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...R}}}catch{return null}}function B(e,t){let n=O(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},k(n))}function V(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function H(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function U(e,t){return e===`anthropic-messages`?t?o:d:e===`openai-responses`?t?s:c:t?u:l}function W(e,t,n){let r=H(n);if(r&&/model_not_supported/i.test(r)){B(t.id,`model_not_supported`);let n=V(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(L(t,Error(n))),e.end(),!0}return e.push(n),!1}function G(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(B(t.id,`model_not_supported`),i=Error(V(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(L(t,i)),e.end()}async function K(e,t,n,r,i){try{let a=await N(),o=z(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=U(o.api,i)(s,n,c);for await(let n of l)if(W(e,t,n))return;e.end()}catch(n){G(e,t,n)}}function q(e){return(t,r,i={})=>{let a=n();return K(a,t,r,i,e),a}}const J=q(!1),Y=q(!0),X=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./provider-settings-Bk-fk9dp.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)});async function Z(){let e=v();return e?.refreshToken?p(e.refreshToken,fetch,{headers:g}):null}const Q={id:m,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:I,getBudgetUsage:Z,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await y(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??X)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await b(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await C(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await M(c,l),await j(c),t()},onOAuthLogout:async()=>{await e({providerId:m,accessToken:``})},onSilentRenew:async()=>{let e=v();if(!e?.refreshToken)return null;try{let t=await C(e.refreshToken);return await M(t,e.userName),await j(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function $(){r({api:`github-copilot-anthropic`,stream:J,streamSimple:Y}),r({api:`github-copilot-openai`,stream:J,streamSimple:Y})}export{Q as config,F as isCopilotConeCompatible,$ as register};
1
+ import{_ as e,r as t}from"./account-store-jjUZwcjI.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r,n as i,r as a}from"./compat-uEPf6-XW.js";import{a as o,c as s,i as c,r as l,s as u,t as d}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-DSf8xD9N.js";function f(e){if(!e||typeof e!=`object`)return null;let t=e.quota_snapshots?.premium_interactions;return!t||t.unlimited||typeof t.percent_remaining!=`number`?null:{percent:Math.max(0,100-t.percent_remaining),status:t.percent_remaining<=0&&t.overage_permitted!==!0?`rate-limited`:`ok`,window:`monthly`,resetsAt:e.quota_reset_date_utc}}async function p(e,t,n={}){let r=typeof AbortController==`function`?new AbortController:null,i=r?setTimeout(()=>r.abort(),n.timeoutMs??8e3):null;try{let i=await t(`https://api.github.com/copilot_internal/user`,{headers:{...n.headers,Authorization:`Bearer ${e}`},...r?{signal:r.signal}:{}});if(i.status===404||i.status===501)return null;if(!i.ok)throw Error(`GitHub Copilot /copilot_internal/user returned ${i.status}`);return f(await i.json())}finally{i&&clearTimeout(i)}}const m=`github-copilot`,h=atob(`SXYxLmI1MDdhMDhjODdlY2ZlOTg=`),g={Accept:`application/json`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`},_={Accept:`application/json`,"Content-Type":`application/x-www-form-urlencoded`};function v(){return t().find(e=>e.providerId===m)}async function y(){let e=await fetch(`https://github.com/login/device/code`,{method:`POST`,headers:_,body:new URLSearchParams({client_id:h,scope:`read:user`})});if(!e.ok)throw Error(`GitHub device-code request failed: ${e.status} ${e.statusText} — ${await e.text().catch(()=>``)}`);let t=await e.json();if(typeof t.device_code!=`string`||typeof t.user_code!=`string`||typeof t.verification_uri!=`string`||typeof t.expires_in!=`number`||typeof t.interval!=`number`)throw Error(`GitHub device-code response had an unexpected shape`);return t}async function b(e,t){let n=Date.now()+e.expires_in*1e3,r=Math.max(1e3,Math.floor(e.interval*1e3)),i=1.2;for(;Date.now()<n;){if(t.aborted)throw Error(`Copilot login cancelled`);await x(Math.ceil(r*i),t);let n=await fetch(`https://github.com/login/oauth/access_token`,{method:`POST`,headers:_,body:new URLSearchParams({client_id:h,device_code:e.device_code,grant_type:`urn:ietf:params:oauth:grant-type:device_code`})});if(!n.ok)throw Error(`GitHub token poll failed: ${n.status} ${n.statusText} — ${await n.text().catch(()=>``)}`);let a=await n.json();if(typeof a.access_token==`string`&&a.access_token.length>0)return a.access_token;if(a.error!==`authorization_pending`){if(a.error===`slow_down`){r=typeof a.interval==`number`?a.interval*1e3:r+5e3,i=1.4;continue}if(a.error){let e=a.error_description?`: ${a.error_description}`:``;throw Error(`Device flow failed (${a.error})${e}`)}}}throw Error(`Copilot device flow timed out (device code expired)`)}function x(e,t){return new Promise((n,r)=>{if(t.aborted){r(Error(`Copilot login cancelled`));return}let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Copilot login cancelled`))},{once:!0})})}function S(e){let t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,`api.`)}`:null}async function C(e){let t=await fetch(`https://api.github.com/copilot_internal/v2/token`,{headers:{...g,Authorization:`Bearer ${e}`}});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Copilot token exchange failed: ${t.status} ${t.statusText} — ${e.slice(0,300)}`)}let n=await t.json();if(typeof n.token!=`string`||typeof n.expires_at!=`number`)throw Error(`Copilot token exchange returned an unexpected payload`);if(n.chat_enabled===!1)throw Error(`GitHub Copilot Chat is disabled for this account (no chat features granted)`);return{copilotToken:n.token,expiresAtMs:n.expires_at*1e3-3e5,apiBaseUrl:S(n.token)??`https://api.individual.githubcopilot.com`,githubAccessToken:e}}const w=`github-copilot.models.v1`;function T(e){let t=e.supported_endpoints??[],n=(e.vendor??``).toLowerCase(),r=e.id;return n===`anthropic`&&t.includes(`/v1/messages`)?`anthropic-messages`:n===`openai`&&(/^gpt-5/i.test(r)||/codex/i.test(r)||/^o\d/i.test(r))?`openai-responses`:`openai-completions`}function E(e){if(!e||typeof e!=`object`)return[];let t=e.data;if(!Array.isArray(t))return[];let n=[];for(let e of t)e.capabilities?.type&&e.capabilities.type!==`chat`||e.model_picker_enabled!==!1&&e.id&&n.push({id:e.id,name:e.name??e.id,vendor:e.vendor??``,api:T(e),contextWindow:e.capabilities?.limits?.max_context_window_tokens??e.capabilities?.limits?.max_prompt_tokens??128e3,maxTokens:e.capabilities?.limits?.max_output_tokens??8192,supportsTools:e.capabilities?.supports?.tool_calls===!0,supportsStreaming:e.capabilities?.supports?.streaming!==!1,supportsVision:e.capabilities?.supports?.vision===!0,supportsReasoning:e.capabilities?.supports?.adaptive_thinking===!0||Array.isArray(e.capabilities?.supports?.reasoning_effort),policyState:e.policy?.state??`enabled`});return n}async function D(e){let t=await fetch(`${e.apiBaseUrl}/models`,{headers:{...g,Authorization:`Bearer ${e.copilotToken}`,Accept:`application/json`}});if(!t.ok)throw Error(`Copilot /models returned ${t.status} ${t.statusText}`);return E(await t.json())}function O(){if(typeof localStorage>`u`)return[];try{let e=localStorage.getItem(w);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function k(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(w,JSON.stringify(e))}catch{}}function A(e){return O().find(t=>t.id===e)??null}async function j(e){let t;try{t=await D(e)}catch(e){console.warn(`[github-copilot] Catalog refresh failed; keeping previous cache.`,e instanceof Error?e.message:String(e));return}k(t),await Promise.all(t.filter(e=>e.policyState===`disabled`).map(async t=>{let n=`${e.apiBaseUrl}/models/${encodeURIComponent(t.id)}/policy`;try{let r=await fetch(n,{method:`POST`,headers:{...g,"Content-Type":`application/json`,Authorization:`Bearer ${e.copilotToken}`,"openai-intent":`chat-policy`,"x-interaction-type":`chat-policy`},body:JSON.stringify({state:`enabled`})});r.ok?t.policyState=`enabled`:r.status!==404&&r.status!==400&&console.warn(`[github-copilot] enable policy for ${t.id} returned ${r.status} ${r.statusText}`)}catch(e){console.warn(`[github-copilot] enable policy for ${t.id} failed:`,e instanceof Error?e.message:String(e))}})),k(t)}async function M(t,n){await e({providerId:m,accessToken:t.copilotToken,refreshToken:t.githubAccessToken,tokenExpiresAt:t.expiresAtMs,baseUrl:t.apiBaseUrl,userName:n})}async function N(){let e=v();if(!e?.accessToken||!e.refreshToken)throw Error(`Not logged in to GitHub Copilot — click "Login" in the provider settings`);let t=e.tokenExpiresAt??0;if(Date.now()<t-6e4)return e.accessToken;let n=await C(e.refreshToken);return await M(n,e.userName),n.copilotToken}const P=[`mini`,`nano`,`flash`,`haiku`,`lite`,`embedding`];function F(e){let t=[e.id,e.name??``].flatMap(e=>{let t=e.toLowerCase();return[t,t.replace(/[\s_.:]+/g,`-`)]});return!P.some(e=>t.some(t=>t.includes(e)))}function I(){if(!v()?.accessToken)return[];let e=O();if(e.length>0)return e.filter(e=>!e.policyState.startsWith(`unavailable:`)).filter(e=>F(e)).map(e=>({id:e.id,name:e.name,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.supportsReasoning,input:e.supportsVision?[`text`,`image`]:[`text`]}));let t;try{t=a(`github-copilot`)}catch{return[]}return t.filter(e=>F({id:e.id,name:e.name})).map(e=>({id:e.id,name:e.name??e.id,api:e.api===`anthropic-messages`?`anthropic`:`openai`,context_window:e.contextWindow,max_tokens:e.maxTokens,reasoning:e.reasoning,input:e.input}))}function L(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:e.api,provider:m,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const R={"User-Agent":`GitHubCopilotChat/0.35.0`,"Editor-Version":`vscode/1.107.0`,"Editor-Plugin-Version":`copilot-chat/0.35.0`,"Copilot-Integration-Id":`vscode-chat`};function z(e){let t=v(),n=t?.baseUrl??`https://api.individual.githubcopilot.com`,r=A(e);if(r)return{api:r.api,baseUrl:n,headers:{...R}};try{let n=i(`github-copilot`,e);return{api:n.api,baseUrl:t?.baseUrl??n.baseUrl,headers:{...n.headers??{},...R}}}catch{return null}}function B(e,t){let n=O(),r=n.findIndex(t=>t.id===e);r<0||(n[r]={...n[r],policyState:`unavailable:${t}`},k(n))}function V(e,t){return`GitHub Copilot rejected "${e}" with model_not_supported. This usually means the model isn't included in your Copilot plan (Opus and other premium models require Copilot Pro / Pro+ / Business / Enterprise). Try Claude Sonnet 4.6 or another model that appears in the picker after a fresh login. Original error: ${t}`}function H(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.type!==`error`)return null;if(t.error&&typeof t.error==`object`){let e=t.error.errorMessage;if(typeof e==`string`)return e}return typeof t.errorMessage==`string`?t.errorMessage:null}function U(e,t){return e===`anthropic-messages`?t?o:d:e===`openai-responses`?t?s:c:t?u:l}function W(e,t,n){let r=H(n);if(r&&/model_not_supported/i.test(r)){B(t.id,`model_not_supported`);let n=V(t.id,r);return console.error(`[github-copilot] Plan-gated model rejection:`,n),e.push(L(t,Error(n))),e.end(),!0}return e.push(n),!1}function G(e,t,n){let r=n instanceof Error?n.message:String(n),i=n;/model_not_supported/i.test(r)&&(B(t.id,`model_not_supported`),i=Error(V(t.id,r))),console.error(`[github-copilot] Stream error:`,i instanceof Error?i.message:String(i)),e.push(L(t,i)),e.end()}async function K(e,t,n,r,i){try{let a=await N(),o=z(t.id);if(!o)throw Error(`GitHub Copilot does not recognize "${t.id}" — open the picker (the model list refreshes on login) and pick a current model.`);let s={...t,api:o.api,baseUrl:o.baseUrl,headers:o.headers,provider:`github-copilot`},c={...r,apiKey:a},l=U(o.api,i)(s,n,c);for await(let n of l)if(W(e,t,n))return;e.end()}catch(n){G(e,t,n)}}function q(e){return(t,r,i={})=>{let a=n();return K(a,t,r,i,e),a}}const J=q(!1),Y=q(!0),X=({userCode:e,verificationUrl:t})=>typeof document>`u`?(console.info(`[github-copilot] Device verification code: ${e} — open ${t} in a browser to authorize.`),Promise.resolve(`continue`)):new Promise(t=>{let n=document.createElement(`div`);n.setAttribute(`data-slicc-overlay`,`github-copilot-device`),n.style.cssText=[`position:fixed`,`top:24px`,`right:24px`,`z-index:2147483647`,`background:#0d1117`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:10px`,`padding:16px 18px`,`box-shadow:0 8px 32px rgba(0,0,0,0.45)`,`font:13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,`min-width:260px`,`max-width:340px`].join(`;`);let r=document.createElement(`div`);r.textContent=`GitHub Copilot — verification code`,r.style.cssText=`font-weight:600;margin-bottom:8px;color:#7ee787`;let i=document.createElement(`div`);i.textContent=e,i.style.cssText=[`font:600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing:2px`,`background:#161b22`,`border:1px solid #30363d`,`border-radius:6px`,`padding:10px 12px`,`text-align:center`,`margin-bottom:10px`,`user-select:all`,`cursor:text`].join(`;`);let a=document.createElement(`div`);a.style.cssText=`color:#8b949e;font-size:12px;line-height:1.5`,a.textContent=`Copy the code, then click Continue to open the GitHub authorization page in a new tab.`;let o=document.createElement(`div`);o.style.cssText=`display:flex;gap:8px;margin-top:12px;justify-content:flex-end`;let s=document.createElement(`button`);s.type=`button`,s.textContent=`Cancel`,s.style.cssText=[`background:transparent`,`color:#e6edf3`,`border:1px solid #30363d`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let c=document.createElement(`button`);c.type=`button`,c.textContent=`Copy & Continue`,c.style.cssText=[`background:#238636`,`color:#fff`,`border:0`,`border-radius:6px`,`padding:6px 12px`,`font:600 12px inherit`,`cursor:pointer`].join(`;`);let l=()=>{try{n.remove()}catch{}};s.addEventListener(`click`,()=>{l(),t(`cancel`)}),c.addEventListener(`click`,()=>{(async()=>{try{let{copyTextToClipboard:t}=await import(`./provider-settings-DSf8xD9N.js`).then(e=>e.t);await t(e)}catch{}l(),t(`continue`)})()}),o.appendChild(s),o.appendChild(c),n.appendChild(r),n.appendChild(i),n.appendChild(a),n.appendChild(o),document.body.appendChild(n)});async function Z(){let e=v();return e?.refreshToken?p(e.refreshToken,fetch,{headers:g}):null}const Q={id:m,name:`GitHub Copilot`,description:`Use your GitHub Copilot subscription to access Claude, GPT-5, Codex, Gemini, and Grok models. Sign in with the GitHub device-code flow.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`claude-sonnet-4.6`,oauthTokenDomains:[`*.githubcopilot.com`,`api.individual.githubcopilot.com`,`api.business.githubcopilot.com`,`api.enterprise.githubcopilot.com`],getModelIds:I,getBudgetUsage:Z,onOAuthLoginIntercepted:async(e,t,n)=>{let r=await y(),i=new URL(r.verification_uri);if(i.searchParams.set(`user_code`,r.user_code),await(n?.presentDeviceCode??X)({userCode:r.user_code,verificationUrl:i.toString(),expiresInSeconds:r.expires_in})===`cancel`)throw Error(`GitHub Copilot login cancelled`);let a=new AbortController,o=e({authorizeUrl:i.toString(),redirectUriPattern:`https://github.com/login/device/success*`,onCapture:`close`,timeoutMs:r.expires_in*1e3}).catch(e=>(console.warn(`[github-copilot] Launcher failed:`,e instanceof Error?e.message:String(e)),null)),s;try{s=await b(r,a.signal)}catch(e){throw a.abort(),await o,e}await o;let c=await C(s),l;try{let e=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${s}`,Accept:`application/json`}});if(e.ok){let t=await e.json();l=t.name||t.login}}catch{}await M(c,l),await j(c),t()},onOAuthLogout:async()=>{await e({providerId:m,accessToken:``})},onSilentRenew:async()=>{let e=v();if(!e?.refreshToken)return null;try{let t=await C(e.refreshToken);return await M(t,e.userName),await j(t),t.copilotToken}catch(e){return console.warn(`[github-copilot] Silent renew failed:`,e instanceof Error?e.message:String(e)),null}}};function $(){r({api:`github-copilot-anthropic`,stream:J,streamSimple:Y}),r({api:`github-copilot-openai`,stream:J,streamSimple:Y})}export{Q as config,F as isCopilotConeCompatible,$ as register};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./fetch-body-CuwTaJC_.js";import{a as n}from"./types-Dzr0qYl3.js";import{a as r,c as i,l as a,o,r as s,s as c,t as l,u}from"./github-zip-Bs35nBig.js";import{i as d,o as f,r as p}from"./provenance-DdmsQ3Nr.js";async function m(){try{let e=(typeof window<`u`?window:globalThis).__slicc_reloadSkills;if(typeof e==`function`){await e();return}typeof chrome<`u`&&chrome?.runtime?.sendMessage&&chrome.runtime.sendMessage({source:`panel`,payload:{type:`reload-skills`}})}catch{}}async function h(){try{let e=globalThis.__slicc_sprinkleManager;typeof e?.openNewAutoOpenSprinkles==`function`&&await e.openNewAutoOpenSprinkles()}catch{}}async function g(){await h(),await m()}async function _(e,t,r,o,s=!1,c){let l=`${n}/${t}`,d=!1;try{if(await o.stat(l),!s)return{ok:!1,error:`skill "${t}" already exists (use --force to overwrite)`};d=!0,await u(o,l,await v(o,t))}catch{}let p=e.replace(/^\/|\/$/g,``),m=p?p+`/`:``;await o.mkdir(l,{recursive:!0});let h=0,g=[];try{for(let[e,t]of Object.entries(r)){if(!e.startsWith(m))continue;let n=e.slice(m.length);if(!n||e.endsWith(`/`)||!await a(o,l,n)||!i(n))continue;let r=`${l}/${n}`,s=r.substring(0,r.lastIndexOf(`/`));s!==l&&await o.mkdir(s,{recursive:!0}),await o.writeFile(r,t),g.push(n),h++}}catch(e){throw await y(o,l,d),e}return h===0?(await y(o,l,d),{ok:!1,error:`no files found for skill "${t}" in ZIP`}):(c&&await f(o,t,{...c,skill:t,files:g.sort()}),{ok:!0})}async function v(e,t){let n=await p(e,t);return n?.files?.length?new Set(n.files):void 0}async function y(e,t,n){if(n){await u(e,t).catch(()=>!1);return}await e.rm(t,{recursive:!0}).catch(()=>{})}var b=e({installFromGitHub:()=>w,listGitHubSkills:()=>S,parseGitHubRef:()=>T,parseGitHubUrl:()=>x});function x(e){let t=e.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,``)}:null}async function S(e,n,i,a,o,l){if(o){let t=await s(e,n,o,l);if(t.status===`ok`){let e=r(t.files),n=[],i=a?a.replace(/^\/|\/$/g,``)+`/`:``;for(let t of Object.keys(e))if(t.startsWith(i)&&(t.split(`/`).pop()||``)===`SKILL.md`){let e=t.replace(/\/SKILL\.md$/,``),r=e.split(`/`).pop()||e;n.push({name:r,path:e})}return{skills:n}}}let u=[];async function d(r){let a=`https://api.github.com/repos/${e}/${n}/contents/${r}`,o=l?`${a}?ref=${encodeURIComponent(l)}`:a,s=await i.request(o);if(s.status!==200)throw Error(c(s,`${e}/${n}${r?`/${r}`:``}`,i.hasToken));let f=t(s.body);for(let e of f)if(e.type===`file`&&e.name===`SKILL.md`){let t=e.path.replace(`/SKILL.md`,``),n=t.split(`/`).pop()||t;u.push({name:n,path:t})}else e.type===`dir`&&await d(e.path)}try{return await d(a||``),{skills:u}}catch(e){return{skills:[],error:e instanceof Error?e.message:String(e)}}}async function C(e,t,n,r,i,a,o,s){let c=await d(t,n,a,o,!0,r.replace(/^\/+|\/+$/g,``));await f(e,i,{kind:`github`,source:`${t}/${n}`,skill:i,ref:a,path:r.replace(/^\/|\/$/g,``),sha:c,files:s})}async function w(e,i,a,d,f,p,_=!1,b,x){let S=!1;try{let w=`${n}/${d}`;try{if(await f.stat(w),!_)return{stdout:``,stderr:`upskill: skill "${d}" already exists (use --force to overwrite)\n`,exitCode:1};S=!0,await u(f,w,await v(f,d))}catch{}if(b){let t=await s(e,i,b,x);if(t.status===`ok`){let n=r(t.files),s=a.replace(/^\/|\/$/g,``)+`/`;await f.mkdir(w,{recursive:!0});let c=await o(n,s,w,f);if(c.length>0)return await C(f,e,i,a,d,x,p,c),await h(),await m(),{stdout:`Installed skill "${d}" from ${e}/${i}\n`,stderr:``,exitCode:0}}}let T=`https://api.github.com/repos/${e}/${i}/contents/${a}`,E=x?`${T}?ref=${encodeURIComponent(x)}`:T,D=await p.request(E);if(D.status!==200)return{stdout:``,stderr:`upskill: ${c(D,`${e}/${i}/${a}`,p.hasToken)}\n`,exitCode:1};let O=t(D.body);await f.mkdir(w,{recursive:!0});let k;try{k=await l(O,w,e,i,x,f,p)}catch(e){throw await y(f,w,S),e}return await C(f,e,i,a,d,x,p,k),await g(),{stdout:`Installed skill "${d}" from ${e}/${i}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`upskill: failed to install from GitHub: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function T(e){let t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+?)(?:\/(.+?))?)?\/?$/);if(t)return{owner:t[1],repo:t[2],branch:t[3],path:t[4]};let n=e.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:@([a-zA-Z0-9_./-]+))?$/);return n?{owner:n[1],repo:n[2],branch:n[3]}:null}export{x as a,g as c,T as i,w as n,_ as o,S as r,v as s,b as t};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./fetch-body-CuwTaJC_.js";import{a as n}from"./types-Dzr0qYl3.js";import{a as r,c as i,l as a,o,r as s,s as c,t as l,u}from"./github-zip-B-FKgUOX.js";import{i as d,o as f,r as p}from"./provenance-DdmsQ3Nr.js";async function m(){try{let e=(typeof window<`u`?window:globalThis).__slicc_reloadSkills;if(typeof e==`function`){await e();return}typeof chrome<`u`&&chrome?.runtime?.sendMessage&&chrome.runtime.sendMessage({source:`panel`,payload:{type:`reload-skills`}})}catch{}}async function h(){try{let e=globalThis.__slicc_sprinkleManager;typeof e?.openNewAutoOpenSprinkles==`function`&&await e.openNewAutoOpenSprinkles()}catch{}}async function g(){await h(),await m()}async function _(e,t,r,o,s=!1,c){let l=`${n}/${t}`,d=!1;try{if(await o.stat(l),!s)return{ok:!1,error:`skill "${t}" already exists (use --force to overwrite)`};d=!0,await u(o,l,await v(o,t))}catch{}let p=e.replace(/^\/|\/$/g,``),m=p?p+`/`:``;await o.mkdir(l,{recursive:!0});let h=0,g=[];try{for(let[e,t]of Object.entries(r)){if(!e.startsWith(m))continue;let n=e.slice(m.length);if(!n||e.endsWith(`/`)||!await a(o,l,n)||!i(n))continue;let r=`${l}/${n}`,s=r.substring(0,r.lastIndexOf(`/`));s!==l&&await o.mkdir(s,{recursive:!0}),await o.writeFile(r,t),g.push(n),h++}}catch(e){throw await y(o,l,d),e}return h===0?(await y(o,l,d),{ok:!1,error:`no files found for skill "${t}" in ZIP`}):(c&&await f(o,t,{...c,skill:t,files:g.sort()}),{ok:!0})}async function v(e,t){let n=await p(e,t);return n?.files?.length?new Set(n.files):void 0}async function y(e,t,n){if(n){await u(e,t).catch(()=>!1);return}await e.rm(t,{recursive:!0}).catch(()=>{})}var b=e({installFromGitHub:()=>w,listGitHubSkills:()=>S,parseGitHubRef:()=>T,parseGitHubUrl:()=>x});function x(e){let t=e.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,``)}:null}async function S(e,n,i,a,o,l){if(o){let t=await s(e,n,o,l);if(t.status===`ok`){let e=r(t.files),n=[],i=a?a.replace(/^\/|\/$/g,``)+`/`:``;for(let t of Object.keys(e))if(t.startsWith(i)&&(t.split(`/`).pop()||``)===`SKILL.md`){let e=t.replace(/\/SKILL\.md$/,``),r=e.split(`/`).pop()||e;n.push({name:r,path:e})}return{skills:n}}}let u=[];async function d(r){let a=`https://api.github.com/repos/${e}/${n}/contents/${r}`,o=l?`${a}?ref=${encodeURIComponent(l)}`:a,s=await i.request(o);if(s.status!==200)throw Error(c(s,`${e}/${n}${r?`/${r}`:``}`,i.hasToken));let f=t(s.body);for(let e of f)if(e.type===`file`&&e.name===`SKILL.md`){let t=e.path.replace(`/SKILL.md`,``),n=t.split(`/`).pop()||t;u.push({name:n,path:t})}else e.type===`dir`&&await d(e.path)}try{return await d(a||``),{skills:u}}catch(e){return{skills:[],error:e instanceof Error?e.message:String(e)}}}async function C(e,t,n,r,i,a,o,s){let c=await d(t,n,a,o,!0,r.replace(/^\/+|\/+$/g,``));await f(e,i,{kind:`github`,source:`${t}/${n}`,skill:i,ref:a,path:r.replace(/^\/|\/$/g,``),sha:c,files:s})}async function w(e,i,a,d,f,p,_=!1,b,x){let S=!1;try{let w=`${n}/${d}`;try{if(await f.stat(w),!_)return{stdout:``,stderr:`upskill: skill "${d}" already exists (use --force to overwrite)\n`,exitCode:1};S=!0,await u(f,w,await v(f,d))}catch{}if(b){let t=await s(e,i,b,x);if(t.status===`ok`){let n=r(t.files),s=a.replace(/^\/|\/$/g,``)+`/`;await f.mkdir(w,{recursive:!0});let c=await o(n,s,w,f);if(c.length>0)return await C(f,e,i,a,d,x,p,c),await h(),await m(),{stdout:`Installed skill "${d}" from ${e}/${i}\n`,stderr:``,exitCode:0}}}let T=`https://api.github.com/repos/${e}/${i}/contents/${a}`,E=x?`${T}?ref=${encodeURIComponent(x)}`:T,D=await p.request(E);if(D.status!==200)return{stdout:``,stderr:`upskill: ${c(D,`${e}/${i}/${a}`,p.hasToken)}\n`,exitCode:1};let O=t(D.body);await f.mkdir(w,{recursive:!0});let k;try{k=await l(O,w,e,i,x,f,p)}catch(e){throw await y(f,w,S),e}return await C(f,e,i,a,d,x,p,k),await g(),{stdout:`Installed skill "${d}" from ${e}/${i}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`upskill: failed to install from GitHub: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}function T(e){let t=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+?)(?:\/(.+?))?)?\/?$/);if(t)return{owner:t[1],repo:t[2],branch:t[3],path:t[4]};let n=e.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:@([a-zA-Z0-9_./-]+))?$/);return n?{owner:n[1],repo:n[2],branch:n[3]}:null}export{x as a,g as c,T as i,w as n,_ as o,S as r,v as s,b as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./binary-cache-bSOhqXB1.js";import{i as n,n as r,r as i}from"./fetch-body-CuwTaJC_.js";import{r as a}from"./browser-2rCVqcqy.js";import{i as o,n as s}from"./github-auth-CzzE1eDf.js";function c(e){return e.split(`/`).some(e=>e.startsWith(`.`))}async function l(e,t,n){return!c(n)||!await e.exists(`${t}/${n}`)}async function u(e,t,n,r=``){let i;try{i=await e.readDir(t)}catch{return!1}let a=!1;for(let o of i){let i=`${t}/${o.name}`,s=r?`${r}/${o.name}`:o.name;if(o.name.startsWith(`.`)){a=!0;continue}o.type===`directory`?await u(e,i,n,s)?a=!0:await e.rm(i,{recursive:!0}):n&&!n.has(s)?a=!0:await e.rm(i)}return a}async function d(e,t,n=!1,r=``){let i;try{i=await e.readDir(t)}catch{return[]}let a=[];for(let o of i){if(!n&&o.name.startsWith(`.`))continue;let i=r?`${r}/${o.name}`:o.name;o.type===`directory`?a.push(...await d(e,`${t}/${o.name}`,n,i)):a.push(i)}return a.sort()}function f(e){return!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)?!1:!e.split(`/`).some(e=>e===``||e===`.`||e===`..`)}function p(e){let t=r(e);if(!t)return;try{let e=JSON.parse(t);if(typeof e.message==`string`&&e.message.trim())return e.message.trim()}catch{}let n=t.trim();if(n)return n.slice(0,200)}function m(e,t,n){let r=p(e.body),i=r?` GitHub said: ${r}`:``,a=s(e.headers,`retry-after`),o=s(e.headers,`x-ratelimit-remaining`),c=r?.toLowerCase()??``;if(e.status===429||o===`0`||c.includes(`rate limit`))return n?`GitHub rate-limited access to ${t} (HTTP ${e.status}). The configured github.token was used, so retry later${a?` after about ${a} seconds`:``}.${i}`:`GitHub rate-limited anonymous access to ${t} (HTTP ${e.status}). This often happens on shared VPNs or corporate egress IPs because unauthenticated GitHub API requests are limited per IP. Configure a token with: git config github.token <PAT>, then retry. You can also retry off VPN or later.${i}`;if(e.status===401)return n?`GitHub rejected the configured github.token while accessing ${t} (HTTP 401). Update it with: git config github.token <PAT>, then retry.${i}`:`GitHub requires authentication to access ${t} (HTTP 401). Configure a token with: git config github.token <PAT>, then retry.${i}`;if(e.status===404)return`GitHub could not find ${t} (HTTP 404). Check the repository, path, and permissions.${i}`;if(e.status===403)return n?`GitHub denied access to ${t} (HTTP 403). Check that your github.token can access this repository or retry later if GitHub is throttling requests.${i}`:`GitHub denied anonymous access to ${t} (HTTP 403). If this repo is public on a shared VPN, you may have hit GitHub's shared IP limit; otherwise the repository or path may require authentication. Configure a token with: git config github.token <PAT>, then retry.${i}`;let l=e.statusText?` ${e.statusText}`:``;return`GitHub request for ${t} failed (HTTP ${e.status}${l}).${i}`}var h=e({downloadGitHubDir:()=>b,fetchGitHubDirFiles:()=>y,fetchRepoZip:()=>g,stripZipPrefix:()=>_,writeZipFilesToDir:()=>v});async function g(e,n,r,s=`main`){let c=`https://codeload.github.com/${e}/${n}/zip/refs/heads/${s}`,l;try{l=await r(c,{headers:{"User-Agent":`slicc-upskill`}})}catch(e){return{status:`error`,message:o(e,c)}}if(l.status===404)return s===`main`?g(e,n,r,`master`):{status:`error`,message:`codeload returned HTTP 404`};if(l.status!==200)return{status:`error`,message:`codeload returned HTTP ${l.status}`};let u=t(c);u||=i(l.body);try{return{status:`ok`,files:a(u)}}catch(e){return{status:`error`,message:`failed to unzip: ${e instanceof Error?e.message:String(e)}`}}}function _(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.indexOf(`/`);if(e<0)continue;let i=n.slice(e+1);i&&(t[i]=r)}return t}async function v(e,t,n,r,i=!0){let a=[];for(let[o,s]of Object.entries(e)){if(!o.startsWith(t))continue;let e=o.slice(t.length);if(o.endsWith(`/`)||!f(e)||i&&!await l(r,n,e))continue;let c=`${n}/${e}`,u=c.substring(0,c.lastIndexOf(`/`));u!==n&&await r.mkdir(u,{recursive:!0}),await r.writeFile(c,s),a.push(e)}return a.sort()}async function y(e,r,a,o,s,c=new Map,l=``){let u=`https://api.github.com/repos/${e}/${r}/contents/${a}`,d=o?`${u}?ref=${encodeURIComponent(o)}`:u,p=await s.request(d);if(p.status!==200)throw Error(m(p,`${e}/${r}${a?`/${a}`:``}`,s.hasToken));for(let a of n(p.body)){let n=l?`${l}/${a.name}`:a.name;if(f(n)){if(a.type===`file`&&a.download_url){let o=await s.request(a.download_url,`*/*`);if(o.status!==200)throw Error(m(o,`${e}/${r}/${a.path}`,s.hasToken));let l=t(a.download_url);c.set(n,l??i(o.body))}else a.type===`dir`&&await y(e,r,a.path,o,s,c,n)}}return c}async function b(e,r,i,a,o,s,l,u=[],d=``){for(let p of e){let e=d?`${d}/${p.name}`:p.name;if(f(e)){if(p.type===`file`&&p.download_url){if(c(e)&&await s.exists(`${r}/${p.name}`))continue;let n=await l.request(p.download_url,`*/*`);if(n.status!==200)throw Error(m(n,`${i}/${a}/${p.path}`,l.hasToken));let o=t(p.download_url);await s.writeFile(`${r}/${p.name}`,o??n.body),u.push(e)}else if(p.type===`dir`){let t=`https://api.github.com/repos/${i}/${a}/contents/${p.path}`,c=o?`${t}?ref=${encodeURIComponent(o)}`:t,d=await l.request(c);if(d.status!==200)throw Error(m(d,`${i}/${a}/${p.path}`,l.hasToken));let f=n(d.body);await s.mkdir(`${r}/${p.name}`,{recursive:!0}),await b(f,`${r}/${p.name}`,i,a,o,s,l,u,e)}}}return u.sort()}export{_ as a,f as c,c as d,d as f,h as i,l,y as n,v as o,g as r,m as s,b as t,u};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t}from"./binary-cache-bSOhqXB1.js";import{i as n,n as r,r as i}from"./fetch-body-CuwTaJC_.js";import{i as a}from"./browser-DuyhpHbR.js";import{i as o,n as s}from"./github-auth-DnIBV6_3.js";function c(e){return e.split(`/`).some(e=>e.startsWith(`.`))}async function l(e,t,n){return!c(n)||!await e.exists(`${t}/${n}`)}async function u(e,t,n,r=``){let i;try{i=await e.readDir(t)}catch{return!1}let a=!1;for(let o of i){let i=`${t}/${o.name}`,s=r?`${r}/${o.name}`:o.name;if(o.name.startsWith(`.`)){a=!0;continue}o.type===`directory`?await u(e,i,n,s)?a=!0:await e.rm(i,{recursive:!0}):n&&!n.has(s)?a=!0:await e.rm(i)}return a}async function d(e,t,n=!1,r=``){let i;try{i=await e.readDir(t)}catch{return[]}let a=[];for(let o of i){if(!n&&o.name.startsWith(`.`))continue;let i=r?`${r}/${o.name}`:o.name;o.type===`directory`?a.push(...await d(e,`${t}/${o.name}`,n,i)):a.push(i)}return a.sort()}function f(e){return!e||e.startsWith(`/`)||e.includes(`\0`)||e.includes(`\\`)||/^[A-Za-z]:/.test(e)?!1:!e.split(`/`).some(e=>e===``||e===`.`||e===`..`)}function p(e){let t=r(e);if(!t)return;try{let e=JSON.parse(t);if(typeof e.message==`string`&&e.message.trim())return e.message.trim()}catch{}let n=t.trim();if(n)return n.slice(0,200)}function m(e,t,n){let r=p(e.body),i=r?` GitHub said: ${r}`:``,a=s(e.headers,`retry-after`),o=s(e.headers,`x-ratelimit-remaining`),c=r?.toLowerCase()??``;if(e.status===429||o===`0`||c.includes(`rate limit`))return n?`GitHub rate-limited access to ${t} (HTTP ${e.status}). The configured github.token was used, so retry later${a?` after about ${a} seconds`:``}.${i}`:`GitHub rate-limited anonymous access to ${t} (HTTP ${e.status}). This often happens on shared VPNs or corporate egress IPs because unauthenticated GitHub API requests are limited per IP. Configure a token with: git config github.token <PAT>, then retry. You can also retry off VPN or later.${i}`;if(e.status===401)return n?`GitHub rejected the configured github.token while accessing ${t} (HTTP 401). Update it with: git config github.token <PAT>, then retry.${i}`:`GitHub requires authentication to access ${t} (HTTP 401). Configure a token with: git config github.token <PAT>, then retry.${i}`;if(e.status===404)return`GitHub could not find ${t} (HTTP 404). Check the repository, path, and permissions.${i}`;if(e.status===403)return n?`GitHub denied access to ${t} (HTTP 403). Check that your github.token can access this repository or retry later if GitHub is throttling requests.${i}`:`GitHub denied anonymous access to ${t} (HTTP 403). If this repo is public on a shared VPN, you may have hit GitHub's shared IP limit; otherwise the repository or path may require authentication. Configure a token with: git config github.token <PAT>, then retry.${i}`;let l=e.statusText?` ${e.statusText}`:``;return`GitHub request for ${t} failed (HTTP ${e.status}${l}).${i}`}var h=e({downloadGitHubDir:()=>b,fetchGitHubDirFiles:()=>y,fetchRepoZip:()=>g,stripZipPrefix:()=>_,writeZipFilesToDir:()=>v});async function g(e,n,r,s=`main`){let c=`https://codeload.github.com/${e}/${n}/zip/refs/heads/${s}`,l;try{l=await r(c,{headers:{"User-Agent":`slicc-upskill`}})}catch(e){return{status:`error`,message:o(e,c)}}if(l.status===404)return s===`main`?g(e,n,r,`master`):{status:`error`,message:`codeload returned HTTP 404`};if(l.status!==200)return{status:`error`,message:`codeload returned HTTP ${l.status}`};let u=t(c);u||=i(l.body);try{return{status:`ok`,files:a(u)}}catch(e){return{status:`error`,message:`failed to unzip: ${e instanceof Error?e.message:String(e)}`}}}function _(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.indexOf(`/`);if(e<0)continue;let i=n.slice(e+1);i&&(t[i]=r)}return t}async function v(e,t,n,r,i=!0){let a=[];for(let[o,s]of Object.entries(e)){if(!o.startsWith(t))continue;let e=o.slice(t.length);if(o.endsWith(`/`)||!f(e)||i&&!await l(r,n,e))continue;let c=`${n}/${e}`,u=c.substring(0,c.lastIndexOf(`/`));u!==n&&await r.mkdir(u,{recursive:!0}),await r.writeFile(c,s),a.push(e)}return a.sort()}async function y(e,r,a,o,s,c=new Map,l=``){let u=`https://api.github.com/repos/${e}/${r}/contents/${a}`,d=o?`${u}?ref=${encodeURIComponent(o)}`:u,p=await s.request(d);if(p.status!==200)throw Error(m(p,`${e}/${r}${a?`/${a}`:``}`,s.hasToken));for(let a of n(p.body)){let n=l?`${l}/${a.name}`:a.name;if(f(n)){if(a.type===`file`&&a.download_url){let o=await s.request(a.download_url,`*/*`);if(o.status!==200)throw Error(m(o,`${e}/${r}/${a.path}`,s.hasToken));let l=t(a.download_url);c.set(n,l??i(o.body))}else a.type===`dir`&&await y(e,r,a.path,o,s,c,n)}}return c}async function b(e,r,i,a,o,s,l,u=[],d=``){for(let p of e){let e=d?`${d}/${p.name}`:p.name;if(f(e)){if(p.type===`file`&&p.download_url){if(c(e)&&await s.exists(`${r}/${p.name}`))continue;let n=await l.request(p.download_url,`*/*`);if(n.status!==200)throw Error(m(n,`${i}/${a}/${p.path}`,l.hasToken));let o=t(p.download_url);await s.writeFile(`${r}/${p.name}`,o??n.body),u.push(e)}else if(p.type===`dir`){let t=`https://api.github.com/repos/${i}/${a}/contents/${p.path}`,c=o?`${t}?ref=${encodeURIComponent(o)}`:t,d=await l.request(c);if(d.status!==200)throw Error(m(d,`${i}/${a}/${p.path}`,l.hasToken));let f=n(d.body);await s.mkdir(`${r}/${p.name}`,{recursive:!0}),await b(f,`${r}/${p.name}`,i,a,o,s,l,u,e)}}}return u.sort()}export{_ as a,f as c,c as d,d as f,h as i,l,y as n,v as o,g as r,m as s,b as t,u};
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{n as t}from"./core-Bvc89tkf.js";const n=e(`guest-tool-gate`);async function r(e,t,r,a){if(!a)return n.warn(`Guest-caused turn with no approval route — refusing tool call`,{tool:t}),!1;let o=i(t,r);for(let t of e)if((await a({kind:`guest-tool`,detail:o,requester:t.requester,...t.approver?{approver:t.approver}:{}})).decision===`deny`)return!1;return!0}function i(e,n){let[r]=t(n);return r?`${e}: ${r.replace(/\s+/g,` `).trim().slice(0,300)}`:e}export{r as approveToolCallForGuests};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{n as t}from"./core-vzw5Cr8B.js";const n=e(`guest-tool-gate`);async function r(e,t,r,a){if(!a)return n.warn(`Guest-caused turn with no approval route — refusing tool call`,{tool:t}),!1;let o=i(t,r);for(let t of e)if((await a({kind:`guest-tool`,detail:o,requester:t.requester,...t.approver?{approver:t.approver}:{}})).decision===`deny`)return!1;return!0}function i(e,n){let[r]=t(n);return r?`${e}: ${r.replace(/\s+/g,` `).trim().slice(0,300)}`:e}export{r as approveToolCallForGuests};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./permissions-surface-registry-CilCRwhh.js";import{a as n,i as r,n as i,o as a,r as o}from"./whisper-session-CMiImrJg.js";var s=e(`speech:hear`),c={};function l(){return c.getPermissionSurface?c.getPermissionSurface():t()||null}var u=3e4;function d(){if(typeof window>`u`)return null;let{SpeechRecognition:e,webkitSpeechRecognition:t}=window;return e??t??null}var f=class extends Error{code;constructor(e){super(p(e)),this.name=`SpeechRecognitionError`,this.code=e}};function p(e){switch(e){case`network`:case`service-not-allowed`:return"builtin speech recognition is unsupported in this browser (no Web Speech cloud backend) — use `hear --engine enhanced`";case`not-allowed`:return`microphone permission denied for builtin speech recognition`;case`audio-capture`:return`no microphone available for builtin speech recognition`;case`no-speech`:return`no speech detected`;case`aborted`:return`speech recognition aborted`;default:return`speech recognition error: ${e}`}}function m(e){return e instanceof f&&(e.code===`network`||e.code===`service-not-allowed`)}function h(e,t){let n=d();return n?new Promise((r,i)=>{let a=Date.now(),o=()=>Date.now()-a,c=new n;c.continuous=!1,c.interimResults=!1,e&&(c.lang=e),s.debug(`builtinOnce: recognizer constructed`,{lang:e??`(browser default)`,timeoutMs:t});let l=``,u=!1,d=setTimeout(()=>{s.debug(`builtinOnce: timeout reached — stopping recognizer`,{elapsedMs:o()});try{c.stop()}catch{}},t);c.onstart=()=>s.debug(`builtinOnce: onstart (recognition service active)`,{elapsedMs:o()}),c.onaudiostart=()=>s.debug(`builtinOnce: onaudiostart (capturing audio)`,{elapsedMs:o()}),c.onspeechstart=()=>s.debug(`builtinOnce: onspeechstart (speech detected)`,{elapsedMs:o()}),c.onspeechend=()=>s.debug(`builtinOnce: onspeechend (speech ended)`,{elapsedMs:o()}),c.onnomatch=()=>s.debug(`builtinOnce: onnomatch (no recognizable speech)`,{elapsedMs:o()}),c.onresult=e=>{let t=[];for(let n=0;n<e.results.length;n++)t.push(e.results[n][0]?.transcript??``);l=t.join(` `).trim(),s.debug(`builtinOnce: onresult`,{elapsedMs:o(),resultCount:e.results.length,transcriptLength:l.length})},c.onerror=e=>{if(e.error===`no-speech`||e.error===`aborted`){s.debug(`builtinOnce: onerror (non-fatal — ends with empty transcript)`,{elapsedMs:o(),code:e.error});return}u=!0,clearTimeout(d),s.error(`builtinOnce: onerror (fatal)`,{elapsedMs:o(),code:e.error}),i(new f(e.error))},c.onend=()=>{clearTimeout(d),u?s.debug(`builtinOnce: onend after fatal error (already rejected)`,{elapsedMs:o()}):(s.debug(`builtinOnce: onend — resolving`,{elapsedMs:o(),transcriptLength:l.length,empty:l.length===0}),r(l))},s.debug(`builtinOnce: calling recognizer.start()`,{elapsedMs:o()}),c.start()}):Promise.reject(Error(`speech recognition unavailable in this environment`))}async function g(e){let t={audio:!e||{deviceId:{exact:e}}},n=l();if(n){s.debug(`acquireMicrophoneStream: requesting microphone via permission surface`,{hasDeviceId:!!e});let r=await n.prompt({kinds:[`microphone`],description:`The hear command needs your microphone to transcribe speech.`,requestOptions:{microphone:{constraints:t}},skipIfGranted:!0});if(r.status!==`granted`){s.error(`acquireMicrophoneStream: microphone permission not granted`,{status:r.status,reason:r.reason});let e=r.message?`: ${r.message}`:``;throw Error(`microphone permission ${r.reason??r.status}${e}`)}let i=r.grants.find(e=>e.kind===`microphone`);if(!i)throw s.error(`acquireMicrophoneStream: permission granted without a microphone stream`),Error(`microphone permission granted without a stream`);return s.debug(`acquireMicrophoneStream: microphone stream acquired via surface`),i.stream}if(!navigator.mediaDevices?.getUserMedia)throw s.error(`acquireMicrophoneStream: getUserMedia unavailable in this realm`),Error(`microphone capture unavailable in this realm`);s.debug(`acquireMicrophoneStream: no permission surface; calling getUserMedia directly`);try{let e=await navigator.mediaDevices.getUserMedia(t);return s.debug(`acquireMicrophoneStream: getUserMedia succeeded (direct)`),e}catch(e){throw s.error(`acquireMicrophoneStream: getUserMedia failed (direct)`,e),e}}async function _(e){let t=await g(e),n=new MediaRecorder(t),r=[];n.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},n.start(500);let i=()=>{for(let e of t.getTracks())e.stop()};return{stop:()=>new Promise(e=>{n.onstop=()=>{i(),e(r.length?new Blob(r,{type:n.mimeType||`audio/webm`}):null)};try{n.stop()}catch{i(),e(null)}}),cancel:()=>{try{n.stop()}catch{}i()}}}async function v(e){if(!l())return s.debug(`primeBuiltinPermission: no permission surface; recognizer drives its own prompt`),null;s.debug(`primeBuiltinPermission: priming microphone grant via permission surface`,{hasDeviceId:!!e});let t=await g(e);return s.debug(`primeBuiltinPermission: microphone primed; holding stream open for recognizer`),t}function y(e){if(e){for(let t of e.getTracks())t.stop();s.debug(`primeBuiltinPermission: released primed microphone stream`)}}async function b(e,t){let n=await _(e.deviceId),a=``;try{a=await h(e.lang,t)}catch(e){s.warn(`builtin endpointing failed; transcribing captured audio anyway`,e)}let c=await n.stop();if(!c)return{transcript:a,engine:`builtin`};try{let t=await r(),n=await o(await c.arrayBuffer()),a=await t.transcribe(n,{language:i(e.lang)});if(a)return{transcript:a,engine:`enhanced`}}catch(e){s.warn(`whisper transcription failed; falling back to builtin text`,e)}return{transcript:a,engine:`builtin`}}async function x(e={}){let t=e.timeoutMs??u,n=e.engine??`auto`,r=a()===`ready`;if(n===`enhanced`&&!r)throw s.error(`hearCapture: enhanced engine requested but whisper is not ready`),Error("enhanced engine not ready — run `hear --warmup` (check progress with `hear --status`)");let i=n!==`builtin`&&r;if(s.debug(`hearCapture: engine dispatch`,{requested:n,enhancedReady:r,resolved:i?`enhanced`:`builtin`}),i)return b(e,t);let o=await v(e.deviceId);try{let n=await h(e.lang,t);return s.debug(`hearCapture: builtin recognition produced a transcript`),{transcript:n,engine:`builtin`}}catch(n){if(!m(n))throw s.error(`hearCapture: builtin recognition failed`,n),n;if(r)return s.debug(`hearCapture: builtin unsupported in this browser; falling back to enhanced whisper`),y(o),o=null,b(e,t);throw s.error(`hearCapture: builtin unsupported and whisper not ready`,{code:n.code}),n}finally{y(o)}}async function S(e,t){let n=await r(),a=await o(e);return{transcript:await n.transcribe(a,{language:i(t)}),engine:`enhanced`}}function C(){let e=n();return{state:a(),...e?{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}:{}}}function w(){return r().catch(()=>{}),C()}export{x as hearCapture,C as hearStatus,S as hearTranscribe,w as hearWarmup};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{t}from"./permissions-surface-registry-CilCRwhh.js";import{a as n,i as r,n as i,o as a,r as o}from"./whisper-session-z9qnQTAM.js";var s=e(`speech:hear`),c={};function l(){return c.getPermissionSurface?c.getPermissionSurface():t()||null}var u=3e4;function d(){if(typeof window>`u`)return null;let{SpeechRecognition:e,webkitSpeechRecognition:t}=window;return e??t??null}var f=class extends Error{code;constructor(e){super(p(e)),this.name=`SpeechRecognitionError`,this.code=e}};function p(e){switch(e){case`network`:case`service-not-allowed`:return"builtin speech recognition is unsupported in this browser (no Web Speech cloud backend) — use `hear --engine enhanced`";case`not-allowed`:return`microphone permission denied for builtin speech recognition`;case`audio-capture`:return`no microphone available for builtin speech recognition`;case`no-speech`:return`no speech detected`;case`aborted`:return`speech recognition aborted`;default:return`speech recognition error: ${e}`}}function m(e){return e instanceof f&&(e.code===`network`||e.code===`service-not-allowed`)}function h(e,t){let n=d();return n?new Promise((r,i)=>{let a=Date.now(),o=()=>Date.now()-a,c=new n;c.continuous=!1,c.interimResults=!1,e&&(c.lang=e),s.debug(`builtinOnce: recognizer constructed`,{lang:e??`(browser default)`,timeoutMs:t});let l=``,u=!1,d=setTimeout(()=>{s.debug(`builtinOnce: timeout reached — stopping recognizer`,{elapsedMs:o()});try{c.stop()}catch{}},t);c.onstart=()=>s.debug(`builtinOnce: onstart (recognition service active)`,{elapsedMs:o()}),c.onaudiostart=()=>s.debug(`builtinOnce: onaudiostart (capturing audio)`,{elapsedMs:o()}),c.onspeechstart=()=>s.debug(`builtinOnce: onspeechstart (speech detected)`,{elapsedMs:o()}),c.onspeechend=()=>s.debug(`builtinOnce: onspeechend (speech ended)`,{elapsedMs:o()}),c.onnomatch=()=>s.debug(`builtinOnce: onnomatch (no recognizable speech)`,{elapsedMs:o()}),c.onresult=e=>{let t=[];for(let n=0;n<e.results.length;n++)t.push(e.results[n][0]?.transcript??``);l=t.join(` `).trim(),s.debug(`builtinOnce: onresult`,{elapsedMs:o(),resultCount:e.results.length,transcriptLength:l.length})},c.onerror=e=>{if(e.error===`no-speech`||e.error===`aborted`){s.debug(`builtinOnce: onerror (non-fatal — ends with empty transcript)`,{elapsedMs:o(),code:e.error});return}u=!0,clearTimeout(d),s.error(`builtinOnce: onerror (fatal)`,{elapsedMs:o(),code:e.error}),i(new f(e.error))},c.onend=()=>{clearTimeout(d),u?s.debug(`builtinOnce: onend after fatal error (already rejected)`,{elapsedMs:o()}):(s.debug(`builtinOnce: onend — resolving`,{elapsedMs:o(),transcriptLength:l.length,empty:l.length===0}),r(l))},s.debug(`builtinOnce: calling recognizer.start()`,{elapsedMs:o()}),c.start()}):Promise.reject(Error(`speech recognition unavailable in this environment`))}async function g(e){let t={audio:!e||{deviceId:{exact:e}}},n=l();if(n){s.debug(`acquireMicrophoneStream: requesting microphone via permission surface`,{hasDeviceId:!!e});let r=await n.prompt({kinds:[`microphone`],description:`The hear command needs your microphone to transcribe speech.`,requestOptions:{microphone:{constraints:t}},skipIfGranted:!0});if(r.status!==`granted`){s.error(`acquireMicrophoneStream: microphone permission not granted`,{status:r.status,reason:r.reason});let e=r.message?`: ${r.message}`:``;throw Error(`microphone permission ${r.reason??r.status}${e}`)}let i=r.grants.find(e=>e.kind===`microphone`);if(!i)throw s.error(`acquireMicrophoneStream: permission granted without a microphone stream`),Error(`microphone permission granted without a stream`);return s.debug(`acquireMicrophoneStream: microphone stream acquired via surface`),i.stream}if(!navigator.mediaDevices?.getUserMedia)throw s.error(`acquireMicrophoneStream: getUserMedia unavailable in this realm`),Error(`microphone capture unavailable in this realm`);s.debug(`acquireMicrophoneStream: no permission surface; calling getUserMedia directly`);try{let e=await navigator.mediaDevices.getUserMedia(t);return s.debug(`acquireMicrophoneStream: getUserMedia succeeded (direct)`),e}catch(e){throw s.error(`acquireMicrophoneStream: getUserMedia failed (direct)`,e),e}}async function _(e){let t=await g(e),n=new MediaRecorder(t),r=[];n.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},n.start(500);let i=()=>{for(let e of t.getTracks())e.stop()};return{stop:()=>new Promise(e=>{n.onstop=()=>{i(),e(r.length?new Blob(r,{type:n.mimeType||`audio/webm`}):null)};try{n.stop()}catch{i(),e(null)}}),cancel:()=>{try{n.stop()}catch{}i()}}}async function v(e){if(!l())return s.debug(`primeBuiltinPermission: no permission surface; recognizer drives its own prompt`),null;s.debug(`primeBuiltinPermission: priming microphone grant via permission surface`,{hasDeviceId:!!e});let t=await g(e);return s.debug(`primeBuiltinPermission: microphone primed; holding stream open for recognizer`),t}function y(e){if(e){for(let t of e.getTracks())t.stop();s.debug(`primeBuiltinPermission: released primed microphone stream`)}}async function b(e,t){let n=await _(e.deviceId),a=``;try{a=await h(e.lang,t)}catch(e){s.warn(`builtin endpointing failed; transcribing captured audio anyway`,e)}let c=await n.stop();if(!c)return{transcript:a,engine:`builtin`};try{let t=await r(),n=await o(await c.arrayBuffer()),a=await t.transcribe(n,{language:i(e.lang)});if(a)return{transcript:a,engine:`enhanced`}}catch(e){s.warn(`whisper transcription failed; falling back to builtin text`,e)}return{transcript:a,engine:`builtin`}}async function x(e={}){let t=e.timeoutMs??u,n=e.engine??`auto`,r=a()===`ready`;if(n===`enhanced`&&!r)throw s.error(`hearCapture: enhanced engine requested but whisper is not ready`),Error("enhanced engine not ready — run `hear --warmup` (check progress with `hear --status`)");let i=n!==`builtin`&&r;if(s.debug(`hearCapture: engine dispatch`,{requested:n,enhancedReady:r,resolved:i?`enhanced`:`builtin`}),i)return b(e,t);let o=await v(e.deviceId);try{let n=await h(e.lang,t);return s.debug(`hearCapture: builtin recognition produced a transcript`),{transcript:n,engine:`builtin`}}catch(n){if(!m(n))throw s.error(`hearCapture: builtin recognition failed`,n),n;if(r)return s.debug(`hearCapture: builtin unsupported in this browser; falling back to enhanced whisper`),y(o),o=null,b(e,t);throw s.error(`hearCapture: builtin unsupported and whisper not ready`,{code:n.code}),n}finally{y(o)}}async function S(e,t){let n=await r(),a=await o(e);return{transcript:await n.transcribe(a,{language:i(t)}),engine:`enhanced`}}function C(){let e=n();return{state:a(),...e?{loaded:e.loaded,total:e.total,etaSeconds:e.etaSeconds}:{}}}function w(){return r().catch(()=>{}),C()}export{x as hearCapture,C as hearStatus,S as hearTranscribe,w as hearWarmup};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./subcommand-help-CgO7wRS5.js";import{r as t}from"./state-BCTAzK_L.js";function n(e){return`Usage: ${e} <command> [args...]
1
+ import{r as e}from"./subcommand-help-CgO7wRS5.js";import{r as t}from"./state-RVr0GidF.js";function n(e){return`Usage: ${e} <command> [args...]
2
2
 
3
3
  Most commands operate on a tab and REQUIRE --tab=<targetId>. There is no
4
4
  implicit "current tab" — run "${e} tab-list" to get tab IDs.
@@ -1 +1 @@
1
- import{r as e}from"./encode-frame-B8GkHc2t.js";import{installComputerRegistry as t}from"./registry-Bq_j-EXx.js";function n(e){if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength))}return Array.isArray(e)?Uint8Array.from(e):e&&typeof e==`object`?i(e):new Uint8Array}function r(e){if(typeof e.byteLength==`number`)return e.byteLength;if(typeof e.length==`number`)return e.length;let t=-1;for(let n of Object.keys(e)){if(!/^\d+$/.test(n))continue;let e=Number(n);e>t&&(t=e)}return t+1}function i(e){let t=r(e),n=new Uint8Array(t);for(let r=0;r<t;r++){let t=e[r];typeof t==`number`&&(n[r]=t&255)}return n}let a=null;function o(){return a}function s(r){let i=t(r.processManager),o=new Map,s=r.pollTimeoutMs??8e3,l=i.list(),u=(e,t)=>{r.transport.send(e,t)},d=i.onChange(e=>{l=e,u({type:`computers`,computers:e})}),f=(e,t,n)=>{p(e,t,n)},p=async(t,r,i)=>{let a=o.get(t);if(!a||a.generation!==i)return;let s=await e(r,a.maxWidth);if(a.generation!==i||s.seq<=a.lastSentSeq)return;a.lastSentSeq=s.seq;let c=n(s.bytes);u({type:`computer-frame`,id:t,seq:s.seq,mime:s.mime,width:s.width,height:s.height,bytes:c,...s.overCap?{overCap:!0}:{}},[c.buffer])},m=e=>{let t=o.get(e);t&&(t.generation+=1,o.delete(e),t.unsub?.(),t.timer&&clearInterval(t.timer))},h=e=>{m(e.id);let t=i.get(e.id);if(!t)return;let n=Math.max(1,Math.min(10,Math.round(e.fps)||2)),r=e.maxWidth>0?e.maxWidth:768,a={id:e.id,fps:n,maxWidth:r,generation:1,lastSentSeq:-1/0,unsub:null,timer:null,inFlight:!1};if(o.set(e.id,a),t.subscribe){a.unsub=t.subscribe(n,t=>f(e.id,t,a.generation),r);return}let l=Math.round(1e3/n),u=()=>{c(a,t,s,t=>f(e.id,t,a.generation))};a.timer=setInterval(u,l),u()},g=r.transport.onMessage(e=>{if(!e||typeof e!=`object`||!(`source`in e)||e.source!==`panel`)return;let t=e.payload;if(t.type===`computer-watch`)h(t);else if(t.type===`computer-unwatch`)m(t.id);else if(t.type===`computer-input`){let e=t;i.get(e.id)?.input(e.events)}});u({type:`computers`,computers:l});let _={watch:(e,t,n)=>h({type:`computer-watch`,id:e,fps:t,maxWidth:n}),unwatch:m,stop:()=>{g(),d();for(let e of[...o.keys()])m(e);a===_&&(a=null)}};return a=_,_}async function c(e,t,n,r){if(e.inFlight)return;e.inFlight=!0;let i=e.generation;try{let a=await l(t.screenshot({format:`jpeg`,maxWidth:e.maxWidth}),n);if(e.generation!==i)return;r(a)}catch{}finally{e.generation===i&&(e.inFlight=!1)}}function l(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>r(Error(`computer poll timed out`)),t);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}export{o as getComputersHost,s as startComputersHost};
1
+ import{r as e}from"./encode-frame-B8GkHc2t.js";import{installComputerRegistry as t}from"./registry-Bq_j-EXx.js";function n(e){if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength))}return Array.isArray(e)?Uint8Array.from(e):e&&typeof e==`object`?i(e):new Uint8Array}function r(e){if(typeof e.byteLength==`number`)return e.byteLength;if(typeof e.length==`number`)return e.length;let t=-1;for(let n of Object.keys(e)){if(!/^\d+$/.test(n))continue;let e=Number(n);e>t&&(t=e)}return t+1}function i(e){let t=r(e),n=new Uint8Array(t);for(let r=0;r<t;r++){let t=e[r];typeof t==`number`&&(n[r]=t&255)}return n}let a=null;function o(){return a}function s(r){let i=t(r.processManager),o=new Map,s=r.pollTimeoutMs??8e3,l=i.list(),u=(e,t)=>{r.transport.send(e,t)},d=i.onChange(e=>{l=e,u({type:`computers`,computers:e})}),f=(e,t,n)=>{p(e,t,n)},p=async(t,r,i)=>{let a=o.get(t);if(!a||a.generation!==i)return;let s=await e(r,a.maxWidth);if(a.generation!==i||s.seq<=a.lastSentSeq)return;a.lastSentSeq=s.seq;let c=n(s.bytes);u({type:`computer-frame`,id:t,seq:s.seq,mime:s.mime,width:s.width,height:s.height,bytes:c,...s.overCap?{overCap:!0}:{}},[c.buffer])},m=e=>{let t=o.get(e);t&&(t.generation+=1,o.delete(e),t.unsub?.(),t.timer&&clearInterval(t.timer))},h=e=>{m(e.id);let t=i.get(e.id);if(!t)return;let n=Math.max(1,Math.min(10,Math.round(e.fps)||2)),r=e.maxWidth>0?e.maxWidth:768,a={id:e.id,fps:n,maxWidth:r,generation:1,lastSentSeq:-1/0,unsub:null,timer:null,inFlight:!1};if(o.set(e.id,a),t.subscribe){a.unsub=t.subscribe(n,t=>f(e.id,t,a.generation),r);return}let l=Math.round(1e3/n),u=()=>{c(a,t,s,t=>f(e.id,t,a.generation))};a.timer=setInterval(u,l),u()},g=r.transport.onMessage(e=>{if(!e||typeof e!=`object`||!(`source`in e)||e.source!==`panel`)return;let t=e.payload;if(t.type===`computer-watch`)h(t);else if(t.type===`computer-unwatch`)m(t.id);else if(t.type===`computer-input`){let e=t;i.get(e.id)?.input(e.events)}});u({type:`computers`,computers:l});let _={watch:(e,t,n)=>h({type:`computer-watch`,id:e,fps:t,maxWidth:n}),unwatch:m,stop:()=>{g(),d();for(let e of[...o.keys()])m(e);a===_&&(a=null)}};return a=_,_}async function c(e,t,n,r){if(e.inFlight)return;e.inFlight=!0;let i=e.generation,a=new AbortController;try{let o=await l(t.screenshot({format:`jpeg`,maxWidth:e.maxWidth,signal:a.signal}),n);if(e.generation!==i)return;r(o)}catch{a.abort()}finally{e.generation===i&&(e.inFlight=!1)}}function l(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>r(Error(`computer poll timed out`)),t);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}export{o as getComputersHost,s as startComputersHost};
@@ -0,0 +1,28 @@
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{n as t}from"./panel-rpc-BPwAqRch.js";import{i as n,t as r}from"./tray-leader-status-CpkFr6n7.js";import{r as i}from"./browser-eoO4vY7w.js";function a(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``,t.pathname!==`/`&&(t.pathname=t.pathname.replace(/\/+$/,``)||`/`);let n=t.toString();return n.endsWith(`/`)?n.slice(0,-1):n}catch{return null}}function o(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.toString(),r=t.pathname.split(`/`).filter(Boolean);if(r.length<2||r.at(-2)!==`join`)return null;let[i,o,...s]=decodeURIComponent(r.at(-1)).split(`.`);if(!i||!o||s.length>0)return null;r.splice(-2,2),t.pathname=r.length>0?`/${r.join(`/`)}`:`/`;let c=a(t.toString());return c?{workerBaseUrl:c,trayId:i,joinUrl:n}:null}catch{return null}}let s={state:`inactive`,joinUrl:null,trayId:null,error:null,lastPingTime:null,reconnectAttempts:0,attachAttempts:0,lastAttachCode:null,connectingSince:null,lastError:null};function c(){return{...s}}function l(){let e=c();if(e.state!==`inactive`)return e;try{let e=globalThis.localStorage?.getItem(n);if(e){let t=JSON.parse(e);if(t?.state&&t.state!==`inactive`)return t}}catch{}return e}const u=new Set;function d(e){return u.add(e),()=>{u.delete(e)}}const f=`slicc.trayWorkerBaseUrl`,p=`slicc.trayJoinUrl`;function m(e){if(!e)return null;try{let t=new URL(e.trim());t.search=``,t.hash=``;let n=t.pathname.split(`/`).filter(Boolean),r=null;if(n.length>=2&&n.at(-2)===`tray`)r=decodeURIComponent(n.at(-1)),n.splice(-2,2),t.pathname=n.length>0?`/${n.join(`/`)}`:`/`;else if(n.length>=2&&n.at(-2)===`join`)return o(t.toString());let i=a(t.toString());return i?{workerBaseUrl:i,trayId:r,joinUrl:null}:null}catch{return null}}function h(e){let t=m(e);return t?.joinUrl?t:null}const g=e(`scoops.tray-leave`);function _(){let e=globalThis.localStorage,t=e&&typeof e.setItem==`function`&&typeof e.removeItem==`function`?e:null;return typeof window<`u`&&typeof window.dispatchEvent==`function`?{wire:{kind:`standalone-page`,dispatchEvent:e=>window.dispatchEvent(e)},storage:t}:{wire:null,storage:t}}async function v(e={},t=_()){let n=e.workerBaseUrl??null;if(t.storage)try{t.storage.removeItem(p),n===null?t.storage.removeItem(f):t.storage.setItem(f,n)}catch(t){g.error(`tray-leave storage write failed`,{workerBaseUrl:n,requestId:e.requestId,error:t instanceof Error?t.message:String(t)})}if(!t.wire)throw Error(`leaveTray: no transport available — inject a panelRpcClient (worker) or run in a context with window`);switch(t.wire.kind){case`standalone-worker`:await t.wire.panelRpcClient.call(`tray-leave`,{workerBaseUrl:n,requestId:e.requestId});return;case`standalone-page`:t.wire.dispatchEvent(new CustomEvent(`slicc:tray-leave`,{detail:{workerBaseUrl:n,requestId:e.requestId}}));return}}const y=e(`scoops.tray-join`);async function b(e,t={},n=_()){if(n.storage){let r=h(e);try{n.storage.setItem(p,r?.joinUrl??e),r&&n.storage.setItem(f,r.workerBaseUrl)}catch(e){y.error(`tray-join storage write failed`,{requestId:t.requestId,error:e instanceof Error?e.message:String(e)})}}if(!n.wire)throw Error(`joinTray: no transport available — inject a panelRpcClient (worker) or run in a context with window`);switch(n.wire.kind){case`standalone-page`:n.wire.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:e,requestId:t.requestId}}));return;case`standalone-worker`:throw Error(`joinTray: standalone-worker transport must be driven via panel-RPC tray-join`)}}function x(){return S()}function S(){try{let e=globalThis.localStorage?.getItem(`slicc.leaderTrayFollowers`);if(e)return JSON.parse(e)}catch{}return[]}function C(){let e=t();if(e)return async()=>await e.call(`tray-reset`,void 0)}function w(){return{stdout:`host - display or manage the current tray host status
2
+
3
+ Usage: host [join <join-url> | reset | leave [--leader <worker-url>]]
4
+
5
+ Shows the current tray state (leader or follower) and, when available, the join URL and connected followers.
6
+
7
+ Subcommands:
8
+ join <join-url> Follow another browser's tray as a follower (paste its https://…/join/<token> URL)
9
+ reset Disconnect all followers and create a fresh tray session with a new join URL
10
+ leave Leave the current tray (drops follower or stops leader; clears stored URLs)
11
+ leave --leader <worker-url> Leave the current role and immediately become a leader on <worker-url>
12
+ `,stderr:``,exitCode:0}}function T(e){if(e<60)return`${e}s ago`;let t=Math.floor(e/60);if(t<60)return`${t}m ago`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}h ago`:`${n}h ${r}m ago`}function E(e){let t=[e.runtimeId];if(e.runtime&&t.push(`(${e.runtime})`),e.connectedAt){let n=Math.round((Date.now()-new Date(e.connectedAt).getTime())/1e3);t.push(`connected ${T(n)}`)}let n=[];e.exec&&n.push(`[ssh]`),e.cdp&&n.push(`[playwright]`),n.length>0&&t.push(n.join(` `));let r=[` - ${t.join(` `)}`];return e.exec&&e.motd&&r.push(` ${e.motd}`),r}function D(e){let t=e.filter(e=>e.exec||e.cdp),n=e.length-t.length,r=[];if(t.length>0){r.push(`followers:`);for(let e of t)r.push(...E(e))}return n>0&&r.push(`(${n} other follower${n===1?``:`s`} with no exec/browser capability)`),r}function O(e,t){let n=[`status: ${e.state}`];return e.session?n.push(`join_url: ${e.session.joinUrl}`):n.push(`join_url: unavailable`),e.error&&n.push(`error: ${e.error}`),e.session&&n.push(...D(t)),`${n.join(`
13
+ `)}\n`}function k(e){let t=[`status: follower (${e.state})`];if(e.joinUrl&&t.push(`join_url: ${e.joinUrl}`),e.state===`connecting`){if(e.connectingSince!=null){let n=Math.round((Date.now()-e.connectingSince)/1e3);t.push(`connecting_for: ${T(n).replace(` ago`,``)}`)}e.attachAttempts>0&&t.push(`attach_attempts: ${e.attachAttempts}`),e.lastAttachCode&&t.push(`last_code: ${e.lastAttachCode}`)}if(e.state===`connected`&&e.lastPingTime!=null){let n=Math.round((Date.now()-e.lastPingTime)/1e3);t.push(`last_ping: ${n}s ago`)}return e.state===`reconnecting`&&e.reconnectAttempts>0&&t.push(`reconnect_attempts: ${e.reconnectAttempts}`),e.lastError&&t.push(`last_error: ${e.lastError}`),e.error&&t.push(`error: ${e.error}`),`${t.join(`
14
+ `)}\n`}function A(e={}){let t=e.getStatus??r,n=e.getFollowerStatus??l,a=e.getFollowers??S;return i(`host`,async r=>{if(r.includes(`--help`)||r.includes(`-h`))return w();if(r[0]===`reset`){let r=e.resetTray??void 0??C();return z(n,t,r)}if(r[0]===`join`){let t=e.joinTray??P();return F(r.slice(1),t)}if(r[0]===`leave`){let i=e.leaveTray??j();return I(r.slice(1),t,n,i)}if(r.length>0)return{stdout:``,stderr:`host: unsupported arguments
15
+ `,exitCode:1};let i=n();return i.state===`inactive`?{stdout:O(t(),a()),stderr:``,exitCode:0}:{stdout:k(i),stderr:``,exitCode:0}})}function j(){return async({workerBaseUrl:e,requestId:n})=>{let i=t();if(i)return await i.call(`tray-leave`,{workerBaseUrl:e,requestId:n});let a=c(),o=r(),s=a.state===`inactive`?o.state===`inactive`?`inactive`:`leader`:`follower`;return await v({workerBaseUrl:e,requestId:n}),e===null?s===`inactive`?{kind:`noop`}:{kind:`left`,previousMode:s}:{kind:`switched`,previousMode:s,workerBaseUrl:e}}}function M(){return`host-leave-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function N(){return`host-join-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function P(){return async({joinUrl:e,requestId:n})=>{let r=t();if(r){await r.call(`tray-join`,{joinUrl:e,requestId:n});return}await b(e,{requestId:n})}}async function F(e,t){let n;for(let t of e){if(t.startsWith(`-`)||n!==void 0)return{stdout:``,stderr:`host join: unexpected argument: ${t}\n`,exitCode:1};n=t}if(!n)return{stdout:``,stderr:`host join: missing join URL
16
+ Usage: host join <join-url>
17
+ `,exitCode:1};let r=h(n);if(!r)return{stdout:``,stderr:`host join: invalid join URL: ${n}\nExpected an https://…/join/<token> link from the leader’s "Copy tray join URL".
18
+ `,exitCode:1};try{return await t({joinUrl:r.joinUrl,requestId:N()}),{stdout:`Joining tray as follower: ${r.joinUrl}\nRun \`host\` to check connection status.
19
+ `,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`host join: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function I(e,t,n,r){let i=null;for(let t=0;t<e.length;t++){let n=e[t];if(n===`--leader`||n===`--as-leader`){let r=e[t+1];if(!r)return{stdout:``,stderr:`host leave: ${n} requires a worker base URL argument\n`,exitCode:1};let o=a(r);if(!o)return{stdout:``,stderr:`host leave: invalid worker base URL: ${r}\n`,exitCode:1};i=o,t+=1;continue}return{stdout:``,stderr:`host leave: unexpected argument: ${n}\n`,exitCode:1}}if(i===null){let e=t(),r=n();if(e.state===`inactive`&&r.state===`inactive`)return{stdout:``,stderr:`host leave: no active tray session
20
+ `,exitCode:0}}try{return{stdout:L(await r({workerBaseUrl:i,requestId:M()})),stderr:``,exitCode:0}}catch(e){let t=e instanceof Error?e.message:String(e);return i===null?{stdout:``,stderr:`host leave: ${t}\n`,exitCode:1}:{stdout:``,stderr:`host leave: left the tray, but failed to become leader on ${i}: ${t}\nTray runtime is now dormant.
21
+ `,exitCode:1}}}function L(e){switch(e.kind){case`noop`:return`No active tray session.
22
+ `;case`left`:{let t=e.previousMode;switch(t){case`leader`:return`Stopped leader. Tray runtime is now dormant.
23
+ `;case`follower`:return`Disconnected from leader. Tray runtime is now dormant.
24
+ `;default:return R(t)}}case`switched`:{let t=e.previousMode;switch(t){case`leader`:return`Stopped leader. Now leader on ${e.workerBaseUrl}\n`;case`follower`:return`Disconnected from leader. Now leader on ${e.workerBaseUrl}\n`;case`inactive`:return`Now leader on ${e.workerBaseUrl}\n`;default:return R(t)}}default:return R(e)}}function R(e){throw Error(`formatLeaveResult: unhandled variant ${JSON.stringify(e)}`)}async function z(e,t,n){if(e().state!==`inactive`)return{stdout:``,stderr:`host reset: only the leader can reset the tray session
25
+ `,exitCode:1};let r=t();if(r.state!==`leader`&&r.state!==`error`)return{stdout:``,stderr:`host reset: no active tray session to reset
26
+ `,exitCode:1};if(!n)return{stdout:``,stderr:`host reset: tray reset is not available in this environment
27
+ `,exitCode:1};try{return{stdout:`Tray session reset. All followers disconnected.
28
+ `+O(await n(),[]),stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`host reset: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}export{d as i,x as n,c as r,A as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./types-D8gIX-W-.js";import"./fs-Bq8bUwe2.js";import{n as t,t as n}from"./browser-2rCVqcqy.js";import{A as r,D as i,E as a,M as o,O as s,T as c,j as l,k as u,w as d}from"./shared-C_68vn79.js";const f=`https://${[`huggingface`,`co`].join(`.`)}`;function p(e){let t=e?.trim();if(!t)return f;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?f:e.href.replace(/\/+$/,``)}catch{return f}}function m(e,t,n){return`${e}/api/models/${t}/tree/${n}?recursive=true`}function h(e,t,n,r){return`${e}/${t}/resolve/${n}/${r}`}function g(e){try{return new URL(e).host}catch{return e}}async function _(e,t,n){try{return await e(t,n)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`request to ${g(t)} failed (${n}); check the bridge fetch-proxy is reachable`)}}async function v(e,t,n,r=f){let i=await _(e,m(r,t,n),{method:`GET`});if(i.status<200||i.status>=300)throw Error(`HF API ${i.status} ${i.statusText} for ${t}@${n}`);let a=new TextDecoder(`utf-8`).decode(i.body);return JSON.parse(a).filter(e=>e.type===`file`).map(e=>({path:e.path,size:typeof e.size==`number`?e.size:0}))}async function y(e,t){let n=t.lastIndexOf(`/`);if(n<=0)return;let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}async function ee(e,t,n,r,i,a,o,s,c){let l=`${a}/${i}`;if(!o&&await t.exists(l))try{let e=await t.stat(l);if(c===void 0||c<=0||e.size===c)return{status:`skipped`,bytes:e.size??0}}catch{}let u=await _(e,h(s,n,r,i),{method:`GET`});if(u.status<200||u.status>=300)throw Error(`HTTP ${u.status} ${u.statusText} for ${i}`);return await y(t,l),await t.writeFile(l,u.body),{status:`downloaded`,bytes:u.body.byteLength}}function te(e,t,n){let r=t??`/workspace/models/${e}`;return(r.startsWith(`/`)?r:`${n.replace(/\/+$/,``)}/${r}`).replace(/\/+$/,``)}var ne=class extends Error{file;constructor(e,t){super(t instanceof Error?t.message:String(t)),this.name=`HfFileDownloadError`,this.file=e}};async function re(e){let t=e.revision??`main`,n=e.force??!1,r=p(e.endpoint),i=e.files??[],a=new Map;if(i.length===0){let n=await v(e.fetch,e.repo,t,r);if(n.length===0)throw Error(`repo ${e.repo}@${t} has no files`);i=n.map(e=>e.path);for(let e of n)a.set(e.path,e.size);let o=n.reduce((e,t)=>e+t.size,0);e.progress?.onListed?.({files:i,totalBytes:o})}await e.fs.mkdir(e.targetDir,{recursive:!0});let o=0,s=0,c=0;for(let l=0;l<i.length;l++){let u=i[l],d;try{d=await ee(e.fetch,e.fs,e.repo,t,u,e.targetDir,n,r,a.get(u))}catch(e){throw new ne(u,e)}c+=d.bytes,d.status===`downloaded`?o+=1:s+=1,e.progress?.onFile?.({file:u,status:d.status,bytes:d.bytes,index:l+1,total:i.length})}return{repo:e.repo,revision:t,targetDir:e.targetDir,files:i,downloaded:o,skipped:s,totalBytes:c}}function b(e,...t){return`/${[e,...t].join(`/`).split(`/`).filter(e=>e.length>0).join(`/`)}`}function ie(e){let t=JSON.stringify(e);return[`// ${s}`,`const { start } = require('sliccy:exec');`,`const __bin = ${t};`,`const __argv = ['ipx', '--global', __bin, ...process.argv.slice(2)];`,`const __stdin = typeof stdin !== 'undefined' ? stdin : undefined;`,`const __h = start(__argv, __stdin !== undefined ? { stdin: __stdin } : undefined);`,`__h.stdin.end();`,`const __r = await __h.done;`,`if (__r.stdout) process.stdout.write(__r.stdout);`,`if (__r.stderr) process.stderr.write(__r.stderr);`,`process.exit(__r.exitCode);`,``].join(`
1
+ import{t as e}from"./types-D8gIX-W-.js";import"./fs-BLqkdQnU.js";import{n as t,t as n}from"./browser-DuyhpHbR.js";import{A as r,D as i,E as a,M as o,O as s,T as c,j as l,k as u,w as d}from"./shared-C_68vn79.js";const f=`https://${[`huggingface`,`co`].join(`.`)}`;function p(e){let t=e?.trim();if(!t)return f;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?f:e.href.replace(/\/+$/,``)}catch{return f}}function m(e,t,n){return`${e}/api/models/${t}/tree/${n}?recursive=true`}function h(e,t,n,r){return`${e}/${t}/resolve/${n}/${r}`}function g(e){try{return new URL(e).host}catch{return e}}async function _(e,t,n){try{return await e(t,n)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`request to ${g(t)} failed (${n}); check the bridge fetch-proxy is reachable`)}}async function v(e,t,n,r=f){let i=await _(e,m(r,t,n),{method:`GET`});if(i.status<200||i.status>=300)throw Error(`HF API ${i.status} ${i.statusText} for ${t}@${n}`);let a=new TextDecoder(`utf-8`).decode(i.body);return JSON.parse(a).filter(e=>e.type===`file`).map(e=>({path:e.path,size:typeof e.size==`number`?e.size:0}))}async function y(e,t){let n=t.lastIndexOf(`/`);if(n<=0)return;let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}async function ee(e,t,n,r,i,a,o,s,c){let l=`${a}/${i}`;if(!o&&await t.exists(l))try{let e=await t.stat(l);if(c===void 0||c<=0||e.size===c)return{status:`skipped`,bytes:e.size??0}}catch{}let u=await _(e,h(s,n,r,i),{method:`GET`});if(u.status<200||u.status>=300)throw Error(`HTTP ${u.status} ${u.statusText} for ${i}`);return await y(t,l),await t.writeFile(l,u.body),{status:`downloaded`,bytes:u.body.byteLength}}function te(e,t,n){let r=t??`/workspace/models/${e}`;return(r.startsWith(`/`)?r:`${n.replace(/\/+$/,``)}/${r}`).replace(/\/+$/,``)}var ne=class extends Error{file;constructor(e,t){super(t instanceof Error?t.message:String(t)),this.name=`HfFileDownloadError`,this.file=e}};async function re(e){let t=e.revision??`main`,n=e.force??!1,r=p(e.endpoint),i=e.files??[],a=new Map;if(i.length===0){let n=await v(e.fetch,e.repo,t,r);if(n.length===0)throw Error(`repo ${e.repo}@${t} has no files`);i=n.map(e=>e.path);for(let e of n)a.set(e.path,e.size);let o=n.reduce((e,t)=>e+t.size,0);e.progress?.onListed?.({files:i,totalBytes:o})}await e.fs.mkdir(e.targetDir,{recursive:!0});let o=0,s=0,c=0;for(let l=0;l<i.length;l++){let u=i[l],d;try{d=await ee(e.fetch,e.fs,e.repo,t,u,e.targetDir,n,r,a.get(u))}catch(e){throw new ne(u,e)}c+=d.bytes,d.status===`downloaded`?o+=1:s+=1,e.progress?.onFile?.({file:u,status:d.status,bytes:d.bytes,index:l+1,total:i.length})}return{repo:e.repo,revision:t,targetDir:e.targetDir,files:i,downloaded:o,skipped:s,totalBytes:c}}function b(e,...t){return`/${[e,...t].join(`/`).split(`/`).filter(e=>e.length>0).join(`/`)}`}function ie(e){let t=JSON.stringify(e);return[`// ${s}`,`const { start } = require('sliccy:exec');`,`const __bin = ${t};`,`const __argv = ['ipx', '--global', __bin, ...process.argv.slice(2)];`,`const __stdin = typeof stdin !== 'undefined' ? stdin : undefined;`,`const __h = start(__argv, __stdin !== undefined ? { stdin: __stdin } : undefined);`,`__h.stdin.end();`,`const __r = await __h.done;`,`if (__r.stdout) process.stdout.write(__r.stdout);`,`if (__r.stderr) process.stderr.write(__r.stderr);`,`process.exit(__r.exitCode);`,``].join(`
2
2
  `)}var ae=class extends Error{binName;path;constructor(e,t){super(`ipk: refusing to overwrite user script at ${t} (bin '${e}')`),this.binName=e,this.path=t,this.name=`GlobalBinCollisionError`}};async function x(e,t){if(t.size!==0){await e.exists(`/shared/bin`)||await e.mkdir(u,{recursive:!0});for(let n of t){if(!n||n.includes(`/`))continue;let t=b(u,`${n}.jsh`);if(await e.exists(t)&&!await S(e,t))throw new ae(n,t)}}}async function S(e,t){try{let n=await e.readFile(t);return(typeof n==`string`?n:new TextDecoder().decode(n)).includes(s)}catch{return!1}}async function C(e,t){if(!await e.exists(`/shared/bin`)){if(t.size===0)return;await e.mkdir(u,{recursive:!0})}let n=[];try{n=await e.readDir(u)}catch{n=[]}for(let r of n){if(r.type!==`file`||!r.name.endsWith(`.jsh`))continue;let n=r.name.slice(0,-4);if(t.has(n))continue;let i=b(u,r.name);await S(e,i)&&await e.rm(i)}for(let n of t){if(!n||n.includes(`/`))continue;let t=b(u,`${n}.jsh`);if(await e.exists(t)&&!await S(e,t))throw new ae(n,t);await e.writeFile(t,ie(n))}}const oe={0:`file`,1:`hardLink`,2:`symbolicLink`,3:`characterDevice`,4:`blockDevice`,5:`directory`,6:`fifo`,7:`contiguousFile`,g:`globalExtendedHeader`,x:`extendedHeader`,D:`gnuDirectory`,I:`gnuInodeMetadata`,K:`gnuLongLinkName`,L:`gnuLongFileName`,N:`gnuOldLongFileName`,M:`gnuMultiVolume`,S:`gnuSparseFile`,E:`gnuExtendedSparse`,A:`solarisAcl`,V:`solarisVolumeLabel`,X:`solarisOldExtendedHeader`};function se(e,t){let n=e.buffer||e,r=[],i=0,a,o;for(;i<n.byteLength-512;){let e=w(n,i,100);if(e.length===0)break;if(a){let t=a.path||a.linkpath;t&&(e=t)}let s=w(n,i+100,8).trim(),c=Number.parseInt(w(n,i+108,8)),l=Number.parseInt(w(n,i+116,8)),u=le(n,i+124,12),d=512+512*Math.trunc(u/512)+(u%512?512:0),f=le(n,i+136,12),p=w(n,i+156,1)||`0`,m=oe[p]||p;switch(m){case`extendedHeader`:case`globalExtendedHeader`:{let e=ue(new Uint8Array(n,i+512,u));m===`extendedHeader`?a=e:(a=void 0,o={...o,...e}),i+=d;continue}case`gnuLongFileName`:case`gnuOldLongFileName`:case`gnuLongLinkName`:a={path:w(n,i+512,u)},i+=d;continue}let h=w(n,i+265,32),g=w(n,i+297,32);e=ce(e);let _={name:e,type:m,size:u,attrs:{...o,...a,mode:s,uid:c,gid:l,mtime:f,user:h,group:g}};if(a=void 0,t?.filter&&!t.filter(_)){i+=d;continue}if(t?.metaOnly){r.push(_),i+=d;continue}let v=u===0?void 0:new Uint8Array(n,i+512,u);r.push({..._,data:v,get text(){return new TextDecoder().decode(this.data)}}),i+=d}return r}function ce(e){let t=e.replace(/\\/g,`/`);t=t.replace(/^[a-zA-Z]:\//,``),t=t.replace(/^\/+/,``);let n=t.startsWith(`./`),r=t.split(`/`),i=[];for(let e of r)e===`..`?i.pop():e!==`.`&&e!==``&&i.push(e);let a=i.join(`/`);return n&&!a.startsWith(`./`)&&(a=`./`+a),e.endsWith(`/`)&&!a.endsWith(`/`)&&(a+=`/`),a}function w(e,t,n){let r=new Uint8Array(e,t,n),i=r.indexOf(0);return new TextDecoder().decode(i===-1?r:r.slice(0,i))}function le(e,t,n){let r=new Uint8Array(e,t,n),i=``;for(let e=0;e<n;e++)i+=String.fromCodePoint(r[e]);return Number.parseInt(i,8)}function ue(e){let t=new TextDecoder().decode(e),n={};for(let e of t.split(`
3
3
  `)){let t=e.split(` `)[1]?.split(`=`);t&&(n[t[0]]=t[1])}return n}function de(e,t={}){let n=e.map(e=>{let t=fe(e.data);return{...e,data:t,size:t?.length||0}}),r=0;for(let t=0;t<e.length;t++){let e=n[t].data?.length??0;r+=512+512*Math.trunc(e/512),e%512&&(r+=512)}let i=10240*Math.trunc(r/10240);r%10240&&(i+=10240);let a=new ArrayBuffer(i),o=0;for(let e of n){let n=!e.data;T(a,e.name,o,100),T(a,E(e.attrs?.mode??t.attrs?.mode??(n?`775`:`664`),7),o+100,8),T(a,E((e.attrs?.uid??t.attrs?.uid??1e3).toString(8),7),o+108,8),T(a,E((e.attrs?.gid??t.attrs?.gid??1e3).toString(8),7),o+116,8),T(a,E(e.size.toString(8),11),o+124,12);let r=e.attrs?.mtime??t.attrs?.mtime??Date.now();T(a,E(Math.trunc(r/1e3).toString(8),11),o+136,12),T(a,n?`5`:`0`,o+156,1),T(a,`ustar`,o+257,6),T(a,`00`,o+263,2),T(a,e.attrs?.user??t.attrs?.user??``,o+265,32),T(a,e.attrs?.group??t.attrs?.group??``,o+297,32),T(a,` `,o+148,8);let i=new Uint8Array(a,o,512),s=0;for(let e=0;e<512;e++)s+=i[e];if(T(a,s.toString(8),o+148,8),!n){let t=new Uint8Array(a,o+512,e.size);for(let n=0;n<e.size;n++)t[n]=e.data[n];o+=512*Math.trunc(e.size/512),e.size%512&&(o+=512)}o+=512}return new Uint8Array(a)}function T(e,t,n,r){let i=new Uint8Array(e,n,r),a=new TextEncoder().encodeInto(t,i).written;for(let e=a;e<r;e++)i[e]=0}function E(e,t){return String(e).padStart(t,`0`)}function fe(e){if(e!=null)return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function pe(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e:new Uint8Array(e)}function D(e){if(!(e instanceof Uint8Array))throw Error(`gunzip: input must be a Uint8Array`);if(e.length<18||e[0]!==31||e[1]!==139)throw Error(`gunzip: input is not a valid gzip stream (bad magic)`);try{return n(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`gunzip: failed to decompress (${t})`)}}function me(e){if(!(e instanceof Uint8Array))throw Error(`gzip: input must be a Uint8Array`);try{return t(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`gzip: failed to compress (${t})`)}}function he(e){if(!Array.isArray(e))throw Error(`writeTar: entries must be an array`);try{return de(e.map(e=>({name:e.path,...e.directory?{}:{data:e.bytes}})))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`writeTar: failed to create tar archive (${t})`)}}function ge(e){return e.startsWith(`package/`)?e.slice(8):e}function O(e,t,n){let r=new Uint8Array(e,t,n),i=r.indexOf(0);return new TextDecoder().decode(i===-1?r:r.subarray(0,i))}function _e(e,t,n){let r=new Uint8Array(e,t,n),i=``;for(let e=0;e<n;e++)i+=String.fromCodePoint(r[e]);return Number.parseInt(i,8)}function ve(e,t,n){let r=new TextDecoder().decode(new Uint8Array(e,t,n)),i,a;for(let e of r.split(`
4
4
  `)){let t=e.split(` `)[1]?.split(`=`);t&&(t[0]===`path`?i=t[1]:t[0]===`linkpath`&&(a=t[1]))}return i||a}function ye(e){let t=e.replace(/\\/g,`/`);t=t.replace(/^[a-zA-Z]:\//,``),t=t.replace(/^\/+/,``);let n=t.startsWith(`./`),r=t.split(`/`),i=[];for(let e of r)e===`..`?i.pop():e!==`.`&&e!==``&&i.push(e);let a=i.join(`/`);return n&&!a.startsWith(`./`)&&(a=`./`+a),e.endsWith(`/`)&&!a.endsWith(`/`)&&(a+=`/`),a}function be(e,t){let n=e.buffer,r=[],i=0,a;for(;i<n.byteLength-512;){let e=O(n,i,100);if(e.length===0)break;let o=_e(n,i+124,12),s=512+512*Math.trunc(o/512)+(o%512?512:0),c=O(n,i+156,1)||`0`;if(c===`x`||c===`g`){a=c===`x`?ve(n,i+512,o):void 0,i+=s;continue}if(c===`L`||c===`N`||c===`K`){a=O(n,i+512,o),i+=s;continue}let l;if(a)l=a;else{let t=O(n,i+345,155);l=t.length>0?`${t}/${e}`:e}r.push(t?l:ye(l)),a=void 0,i+=s}return r}function k(e,t={}){if(!(e instanceof Uint8Array))throw Error(`readTar: input must be a Uint8Array`);let n=pe(e),r;try{r=se(n)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`readTar: failed to parse tar archive (${t})`)}let i=t.stripNpmPrefix??!0,a=t.includeDirectories??!1,o=be(n,t.preserveRawPaths??!1),s=o.length===r.length;if(t.preserveRawPaths&&!s)throw Error(`readTar: raw path resolution did not align with archive entries`);let c=[];return r.forEach((e,t)=>{let n=e.type===`directory`;if(!n&&e.type!==`file`&&e.type!==`contiguousFile`||n&&!a)return;let r=s?o[t]:e.name;c.push({path:i?ge(r):r,bytes:e.data?e.data.slice():new Uint8Array,...n?{directory:!0}:{}})}),c}function A(e){let t=(e??``).trim();if(!t)throw Error(`ipk: package spec is required`);if(t.startsWith(`@`)){let e=t.indexOf(`/`);if(e===-1)throw Error(`ipk: scoped spec '${t}' is missing a name (expected @scope/name)`);let n=t.slice(e+1),r=n.indexOf(`@`),i=t.slice(0,e);return r===-1?{name:`${i}/${n}`,range:``}:{name:`${i}/${n.slice(0,r)}`,range:n.slice(r+1)}}let n=t.indexOf(`@`);return n===-1?{name:t,range:``}:{name:t.slice(0,n),range:t.slice(n+1)}}function j(e,...t){return`/${[e,...t].join(`/`).split(`/`).filter(e=>e.length>0).join(`/`)}`}function M(e,t){if(t.startsWith(`@`)){let[n,r]=t.split(`/`,2);return j(e,n,r)}return j(e,t)}async function N(e,t){await e.mkdir(t,{recursive:!0})}async function P(e,t){await e.exists(t)&&await e.rm(t,{recursive:!0})}function xe(e){return`^${e}`}function Se(e,t){let n=e.range.trim();return n===``||n===`*`||n===`latest`||/^[A-Za-z][A-Za-z0-9_-]*$/.test(n)?xe(t):n}async function Ce(e,t,n){for(let r of n){if(!r.path)continue;let n=r.path.replace(/\\/g,`/`).replace(/^\/+/,``);if(n.split(`/`).some(e=>e===`..`))throw Error(`installer: refusing to extract entry escaping package root: ${r.path}`);let i=j(t,n),a=i.lastIndexOf(`/`);a>0&&await N(e,i.slice(0,a)),await e.writeFile(i,r.bytes)}}async function F(t,n,r){let i;try{i=await t.readFile(n)}catch(t){if(t instanceof e&&t.code===`ENOENT`)return r;throw t}return JSON.parse(i)}async function I(t,n,r){let i;try{i=await t.readFile(n)}catch(t){if(t instanceof e&&t.code===`ENOENT`)return r;throw t}if(!i?.trim())return r;try{return JSON.parse(i)}catch{return r}}const L=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`];function R(e,t){return e!==void 0&&Object.hasOwn(e,t)}function z(e,t,n){return n||R(e.devDependencies,t)?`devDependencies`:R(e.optionalDependencies,t)?`optionalDependencies`:R(e.peerDependencies,t)?`peerDependencies`:`dependencies`}function we(e,t){let n=e[z(e,t,!1)]?.[t];return typeof n==`string`&&n.trim()!==``?n:void 0}function Te(e,t){if(e.range.trim()!==``)return e;let n=we(t,e.name);return n===void 0?e:{name:e.name,range:n}}function Ee(e,t){let n={dependencies:{...e.dependencies??{}},devDependencies:{...e.devDependencies??{}},optionalDependencies:{...e.optionalDependencies??{}},peerDependencies:{...e.peerDependencies??{}}},r=new Set;for(let e of t){for(let t of L)delete n[t][e.name];n[e.section][e.name]=e.range,r.add(e.section)}let i={...e};for(let t of L)(e[t]!==void 0||r.has(t))&&(i[t]=n[t]);return i}function B(e,t){let n=new Map;return{supplier:async r=>{let i=n.get(r);return i||(i=await c(r,e,{timeoutMs:t}),n.set(r,i),i)},cache:n}}async function De(e,t,n){let r=[],a=[],o=new Set;for(let s of e){let e;try{e=A(s)}catch(e){a.push({spec:s,error:V(e)});continue}if(n&&(e=Te(e,n)),o.has(e.name)){let t=r.findIndex(t=>t.parsed.name===e.name);t>=0&&r.splice(t,1)}try{let n=await t(e.name);i(n,e.range)}catch(e){a.push({spec:s,error:V(e)});continue}r.push({spec:s,parsed:e}),o.add(e.name)}return{directs:r,errors:a}}function V(e){return e instanceof Error?e:Error(String(e))}async function H(e,t,n,r,i){let o=M(t,n.name),s=j(o,`package.json`),c=!1;if(await e.exists(s)&&(await I(e,s,null))?.version===n.version&&(c=!0),!c){let t=k(D(await a(n.resolved,r,{timeoutMs:i})));await P(e,o),await N(e,o);try{await Ce(e,o,t)}catch(t){throw await P(e,o),t}}let l=Object.keys(n.dependencies);if(l.length>0){let t=j(o,`node_modules`);await N(e,t);for(let a of l)await H(e,t,n.dependencies[a],r,i)}}async function U(e,t,n,r,i){let a=Object.keys(n.root);if(a.length!==0){await N(e,t);for(let o of a)await H(e,t,n.root[o],r,i)}}function Oe(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t!==-1)return e.slice(t+1)}return e}function W(e,t){return typeof e==`string`?{[Oe(t)]:e}:e}function ke(e){return e.replace(/^\.\//,``).replace(/^\/+/,``)}function Ae(e){return`#!/usr/bin/env node\nrequire(${JSON.stringify(e)});\n`}async function G(e,t){let n=[];return await K(e,t,0,n),n}async function K(e,t,n,r){if(!await e.exists(t))return;let i;try{i=await e.readDir(t)}catch{return}for(let a of i){if(a.type!==`directory`||a.name===`.bin`)continue;if(a.name.startsWith(`@`)){let i=j(t,a.name),o;try{o=await e.readDir(i)}catch{continue}for(let t of o){if(t.type!==`directory`)continue;let o=`${a.name}/${t.name}`;await q(e,j(i,t.name),o,n,r)}continue}let i=a.name;await q(e,j(t,a.name),i,n,r)}}async function q(e,t,n,r,i){let a=await I(e,j(t,`package.json`),null);if(a?.bin!==void 0&&a.bin!==null){let e=W(a.bin,n);for(let[a,o]of Object.entries(e))typeof a==`string`&&a.length!==0&&typeof o==`string`&&o.length!==0&&i.push({binName:a,pkgName:n,installDir:t,binPath:o,depth:r})}await K(e,j(t,`node_modules`),r+1,i)}function J(e){let t=new Map;for(let n of e){let e=t.get(n.binName);if(!e){t.set(n.binName,n);continue}(n.depth<e.depth||n.depth===e.depth&&n.pkgName<e.pkgName)&&t.set(n.binName,n)}return t}function je(e,t,n,r){let i=M(e,t.name);if(t.bin!==void 0&&t.bin!==null){let e=W(t.bin,t.name);for(let[a,o]of Object.entries(e))typeof a==`string`&&a.length!==0&&typeof o==`string`&&o.length!==0&&r.push({binName:a,pkgName:t.name,installDir:i,binPath:o,depth:n})}let a=j(i,`node_modules`);for(let e of Object.values(t.dependencies))je(a,e,n+1,r)}function Me(e,t){let n=[];for(let r of Object.values(e.root))je(t,r,0,n);return n}function Ne(e,t){return new Set(J(Me(e,t)).keys())}function Pe(e,t,n){return`..${t.slice(e.length)}/${ke(n)}`}async function Y(e,t){let n=J(await G(e,t)),r=j(t,`.bin`);if(await e.exists(r)){let t;try{t=await e.readDir(r)}catch{t=[]}for(let i of t)i.type===`file`&&(n.has(i.name)||await e.rm(j(r,i.name)))}if(n.size!==0){await N(e,r);for(let i of n.values()){let n=j(r,i.binName),a=Ae(Pe(t,i.installDir,i.binPath));await e.writeFile(n,a)}}}async function Fe(e,t,n){let r=j(t,`package.json`),i=Ee(await F(e,r,{}),n);return await e.writeFile(r,`${JSON.stringify(i,null,2)}\n`),r}async function Ie(e,t){let{fs:n,fetch:i,cwd:a,timeoutMs:o,global:s=!1,saveDev:c=!1}=t;if(e.length===0)return{results:[],errors:[]};let u=s?l:a,f=await F(n,j(u,`package.json`),{}),{supplier:p}=B(i,o),{directs:m,errors:h}=await De(e,p,f);if(m.length===0)return{results:[],errors:h};let g={};if(s)for(let e of Q(f))g[e.name]=e.range;for(let e of m)g[e.parsed.name]=e.parsed.range;let _=await d({rootDependencies:g,fetchPackument:p}),v=s?r:j(a,`node_modules`);if(s&&(await $(n,v,new Set(Object.keys(_.root))),await x(n,Ne(_,v))),await U(n,v,_,i,o),await Y(n,v),s){let e=J(await G(n,v));await C(n,new Set(e.keys()))}let y=await Fe(n,u,m.map(e=>{let t=_.root[e.parsed.name];if(!t)throw Error(`installer: resolved node missing for ${e.parsed.name}`);return{name:e.parsed.name,range:Se(e.parsed,t.version),section:z(f,e.parsed.name,c)}}));return{results:m.map(e=>{let t=_.root[e.parsed.name],n=M(v,e.parsed.name);return{ok:!0,name:e.parsed.name,version:t.version,installPath:n,range:Se(e.parsed,t.version),manifestPath:y}}),errors:h}}var X=class extends Error{constructor(e){super(`no package.json found at ${e} (run 'ipk install <pkg>' to create one, or add a package.json)`),this.name=`ManifestNotFoundError`}};function Z(e,t){if(!(!t||typeof t!=`object`))for(let[n,r]of Object.entries(t))typeof n==`string`&&typeof r==`string`&&e.set(n,r)}function Le(e){let t=new Map;return Z(t,e.devDependencies),Z(t,e.dependencies),Array.from(t.entries()).map(([e,t])=>({name:e,range:t}))}function Q(e){let t=new Map;return Z(t,e.dependencies),Z(t,e.peerDependencies),Z(t,e.optionalDependencies),Z(t,e.devDependencies),Array.from(t.entries()).map(([e,t])=>({name:e,range:t}))}async function Re(e){let{fs:t,fetch:n,cwd:r,timeoutMs:a}=e,o=j(r,`package.json`);if(!await t.exists(o))throw new X(o);let s=Le(await F(t,o,{}));if(s.length===0)return{results:[],errors:[],empty:!0};let{supplier:c}=B(n,a),l=[],u=[];for(let e of s)try{let t=await c(e.name);i(t,e.range),l.push(e)}catch(t){u.push({spec:`${e.name}@${e.range}`,error:V(t)})}if(l.length===0)return{results:[],errors:u,empty:!1};let f={};for(let e of l)f[e.name]=e.range;let p=await d({rootDependencies:f,fetchPackument:c}),m=j(r,`node_modules`);return await U(t,m,p,n,a),await Y(t,m),{results:l.map(e=>{let t=p.root[e.name];return t?{ok:!0,name:e.name,version:t.version,installPath:M(m,e.name),range:e.range,manifestPath:o}:null}).filter(e=>e!==null),errors:u,empty:!1}}function ze(e,t){return L.some(n=>R(e[n],t))}function Be(e,t){let n={...e};for(let r of L){let i={...e[r]??{}};for(let e of t)delete i[e];e[r]!==void 0&&(n[r]=i)}return n}async function Ve(e,t,n){await e.writeFile(t,`${JSON.stringify(n,null,2)}\n`)}async function $(e,t,n){if(!await e.exists(t))return;let r;try{r=await e.readDir(t)}catch{return}for(let i of r)if(i.name!==`.bin`&&i.type===`directory`){if(i.name.startsWith(`@`)){let r=j(t,i.name),a;try{a=await e.readDir(r)}catch{continue}for(let t of a){if(t.type!==`directory`)continue;let a=`${i.name}/${t.name}`;n.has(a)||await P(e,j(r,t.name))}continue}n.has(i.name)||await P(e,j(t,i.name))}}async function He(e,t,n,i){let a=Q(i??await F(e,o,{}));if(a.length===0){await P(e,r),await C(e,new Set);return}let{supplier:s}=B(t,n),c={};for(let e of a)c[e.name]=e.range;let l=await d({rootDependencies:c,fetchPackument:s});await $(e,r,new Set(Object.keys(l.root))),await x(e,Ne(l,r)),await U(e,r,l,t,n),await Y(e,r);let u=J(await G(e,r));await C(e,new Set(u.keys()))}async function Ue(e,t){let{fs:n,fetch:r,cwd:i,timeoutMs:a,global:o=!1}=t;if(e.length===0)return{results:[],errors:[]};let s=new Set,c=[];for(let t of e)try{s.add(A(t).name)}catch(e){c.push({spec:t,error:V(e)})}if(s.size===0)return{results:[],errors:c};let u=j(o?l:i,`package.json`);if(!await n.exists(u)){for(let t of e)c.push({spec:t,error:new X(u)});return{results:[],errors:c}}let d=await F(n,u,{}),f=[];for(let e of s)f.push({name:e,removed:ze(d,e)});let p=Be(d,s);try{o?await He(n,r,a,p):await We(n,r,i,a,p)}catch(t){return c.push({spec:e.join(` `),error:V(t)}),{results:f,errors:c}}return await Ve(n,u,p),{results:f,errors:c}}async function We(e,t,n,r,i){let a=j(n,`package.json`),o=Q(i??await F(e,a,{})),s=j(n,`node_modules`);if(o.length===0){await P(e,s);return}let{supplier:c}=B(t,r),l={};for(let e of o)l[e.name]=e.range;let u=await d({rootDependencies:l,fetchPackument:c});await $(e,s,new Set(Object.keys(u.root))),await U(e,s,u,t,r),await Y(e,s)}async function Ge(e){let t=Q(await F(e,o,{})),n=[];for(let i of t){let t=await I(e,j(M(r,i.name),`package.json`),{});n.push({name:i.name,version:typeof t.version==`string`?t.version:`?`,range:i.range})}return n.sort((e,t)=>e.name.localeCompare(t.name)),n}async function Ke(e,t){let n=j(t,`package.json`);if(!await e.exists(n))return[];let r=Q(await F(e,n,{})),i=j(t,`node_modules`),a=[];for(let t of r){let n=await I(e,j(M(i,t.name),`package.json`),{});a.push({name:t.name,version:typeof n.version==`string`?n.version:`?`,range:t.range})}return a.sort((e,t)=>e.name.localeCompare(t.name)),a}export{Ke as a,me as c,ne as d,re as f,Ge as i,k as l,Re as n,Ue as o,te as p,Ie as r,D as s,X as t,he as u};