sliccy 5.57.0 → 5.57.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/ui/assets/{account-store-CEVSQiDX.js → account-store-BYbcAgX7.js} +2 -2
  2. package/dist/ui/assets/{account-store-CiUrO2oO.js → account-store-EkiJZvDb.js} +1 -1
  3. package/dist/ui/assets/{adobe-2u5YgpqD.js → adobe-DMuIRBCQ.js} +1 -1
  4. package/dist/ui/assets/{adobe-vjUIJSuz.js → adobe-igqMI1_L.js} +1 -1
  5. package/dist/ui/assets/{adobe-oauth-state-Duf65tF_.js → adobe-oauth-state-eyWQK3Db.js} +1 -1
  6. package/dist/ui/assets/{agent-message-to-chat-C3cZZEnY.js → agent-message-to-chat-CdGdh6Me.js} +1 -1
  7. package/dist/ui/assets/{apps-Xr2HxvXF.js → apps-Emj7UfBa.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-BR4NBU1S.js → azure-openai-CEn91GJx.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-DQsuTqRc.js → azure-openai-DQWYUC5j.js} +1 -1
  10. package/dist/ui/assets/{cerebras-DZlKKnms.js → cerebras-DLspT9p8.js} +1 -1
  11. package/dist/ui/assets/{cerebras-De8Z8J0X.js → cerebras-DjKubgMp.js} +1 -1
  12. package/dist/ui/assets/clipboard-DFF1k7iL.js +1 -0
  13. package/dist/ui/assets/{connect-surface-COlfXpaW.js → connect-surface-x3n9svUp.js} +1 -1
  14. package/dist/ui/assets/dip-Ew0wNwe6.js +1 -0
  15. package/dist/ui/assets/{dist-BeXbje4K.js → dist-BraUFRGP.js} +1 -1
  16. package/dist/ui/assets/{dist-DHYPyff4.js → dist-C0XFYJFy.js} +1 -1
  17. package/dist/ui/assets/{ensure-speech-assets-DHsIj3AZ.js → ensure-speech-assets-B7Ss5vVA.js} +1 -1
  18. package/dist/ui/assets/{fs-BR_pL1Pu.js → fs-BnnBRngY.js} +1 -1
  19. package/dist/ui/assets/{fs-BA_NlNLk.js → fs-VHevPF88.js} +2 -2
  20. package/dist/ui/assets/{github-CEe-BrWT.js → github-Bko-qYFj.js} +2 -2
  21. package/dist/ui/assets/{github-copilot-CTJAedD6.js → github-copilot-B5DGMnJQ.js} +1 -1
  22. package/dist/ui/assets/{github-copilot-mJJDA6yl.js → github-copilot-xTbOqOvQ.js} +1 -1
  23. package/dist/ui/assets/{github-MVL2z3v8.js → github-ut2NnHeQ.js} +1 -1
  24. package/dist/ui/assets/{hear-Co6m2SFp.js → hear-C2OS428l.js} +1 -1
  25. package/dist/ui/assets/{js-realm-worker-YxHAWyF7.js → js-realm-worker-Bi5UIEMG.js} +1 -1
  26. package/dist/ui/assets/{kernel-worker-Dw-oab8q.js → kernel-worker-BcsAuImy.js} +1008 -1009
  27. package/dist/ui/assets/{kokoro-engine-CjStioz-.js → kokoro-engine-CNvfDdFE.js} +1 -1
  28. package/dist/ui/assets/{lick-ws-bridge-BcF8LHQF.js → lick-ws-bridge-DZSVTsLH.js} +1 -1
  29. package/dist/ui/assets/{lick-ws-bridge-uE08lRKe.js → lick-ws-bridge-rLyxnHzf.js} +1 -1
  30. package/dist/ui/assets/{local-llm-wpr_CcAM.js → local-llm-BwofnZP_.js} +1 -1
  31. package/dist/ui/assets/{main-UdqM0h7Y.js → main-Dn8bgiA6.js} +4 -4
  32. package/dist/ui/assets/{mount-Ce1djury.js → mount-B2oKVbNo.js} +1 -1
  33. package/dist/ui/assets/{mount-DDtFtcY1.js → mount-DnReidtr.js} +2 -2
  34. package/dist/ui/assets/{new-session-Cmwle_SJ.js → new-session-BMIV1D1R.js} +2 -2
  35. package/dist/ui/assets/{oauth-bootstrap-Cd4FYsM_.js → oauth-bootstrap-rk54U1XV.js} +2 -2
  36. package/dist/ui/assets/{openai-codex-BL7lwbPQ.js → openai-codex-BgAN6_Qw.js} +1 -1
  37. package/dist/ui/assets/{openai-codex-3RFd2dtu.js → openai-codex-Wx21S4UT.js} +1 -1
  38. package/dist/ui/assets/{page-follower-tray-BsuMLSII.js → page-follower-tray-Df7PCTWs.js} +1 -1
  39. package/dist/ui/assets/{panel-rpc-handlers-CFq536w-.js → panel-rpc-handlers-DYskdWzQ.js} +2 -2
  40. package/dist/ui/assets/{provider-BDLBACK7.js → provider-C1hd8MrJ.js} +2 -2
  41. package/dist/ui/assets/{provider-WwKzqYBv.js → provider-lwmBuH_H.js} +1 -1
  42. package/dist/ui/assets/{provider-settings-Co-joDtJ.js → provider-settings-c9dGiKca.js} +1 -1
  43. package/dist/ui/assets/provider-store-access-CkEGo_9g.js +1 -0
  44. package/dist/ui/assets/provider-store-access-D-x4-dcp.js +1 -0
  45. package/dist/ui/assets/{providers-Dq4BfZ-N.js → providers-6RSF12nO.js} +2 -2
  46. package/dist/ui/assets/{providers-BDH30zTY.js → providers-CsEVgN3c.js} +1 -1
  47. package/dist/ui/assets/{quick-llm-CV6h2NvJ.js → quick-llm-Dc_7dVli.js} +1 -1
  48. package/dist/ui/assets/session-freezer-IBnu6nM1.js +1 -0
  49. package/dist/ui/assets/{speak-MOuTGBj5.js → speak-DC8ptVJL.js} +1 -1
  50. package/dist/ui/assets/{sprinkle-manager-PYCDZeIj.js → sprinkle-manager-DoYhlu8O.js} +1 -1
  51. package/dist/ui/assets/sprinkle-renderer-Bk_e6Kbr.js +192 -0
  52. package/dist/ui/assets/{store-BySJ73L7.js → store-DGSI1qzi.js} +1 -1
  53. package/dist/ui/assets/{sudo-ryTLrYfY.js → sudo-wMWKNcpq.js} +1 -1
  54. package/dist/ui/assets/{transformers-env-BhPFrIRH.js → transformers-env-dWV6LRaJ.js} +1 -1
  55. package/dist/ui/assets/{tray-leader-baQbEptu.js → tray-leader-X9_I01bE.js} +1 -1
  56. package/dist/ui/assets/{tray-leave-runtime-BlVLa2FO.js → tray-leave-runtime-Dmyhw5vM.js} +1 -1
  57. package/dist/ui/assets/{upgrade-detection-Djr_fxY8.js → upgrade-detection-DfVhb93y.js} +1 -1
  58. package/dist/ui/assets/{voice-reply-CF7oVByb.js → voice-reply-Dkrp4bDM.js} +1 -1
  59. package/dist/ui/assets/{wc-attach-Bfk3We4Q.js → wc-attach-BUJpM91I.js} +2 -2
  60. package/dist/ui/assets/{wc-extension-DgVa3eO9.js → wc-extension-Vn2_Lt9D.js} +2 -2
  61. package/dist/ui/assets/{wc-follower-DRSZd-X5.js → wc-follower-C9lTIhGW.js} +3 -3
  62. package/dist/ui/assets/{wc-live-Bxi8xGiv.js → wc-live-TXJxtPKc.js} +5 -5
  63. package/dist/ui/assets/{wc-nav-CTOBFIrg.js → wc-nav-XMX7q2dM.js} +2 -2
  64. package/dist/ui/assets/{wc-onboarding-Blv6lYeG.js → wc-onboarding-DbGx3EvO.js} +2 -2
  65. package/dist/ui/assets/{wc-placeholder-mp-DZGDr.js → wc-placeholder-BjPMYGhP.js} +3 -3
  66. package/dist/ui/assets/{wc-settings-BoPLwHEJ.js → wc-settings-BW0hO_kO.js} +3 -3
  67. package/dist/ui/assets/{wc-shell-KX1I3Q0c.js → wc-shell-D1_4xP-C.js} +3 -3
  68. package/dist/ui/assets/{wc-sprinkles-Ee8dnBb5.js → wc-sprinkles-B_2bqTmh.js} +2 -2
  69. package/dist/ui/assets/{wc-tray-Dx08dZ6k.js → wc-tray-DKOXOmlH.js} +2 -2
  70. package/dist/ui/assets/{whisper-engine-Bu67yIcD.js → whisper-engine-GZAusomQ.js} +1 -1
  71. package/dist/ui/assets/{xai-grok-i1f6noj7.js → xai-grok-C1FhJfKh.js} +1 -1
  72. package/dist/ui/assets/{xai-grok-CK7W826t.js → xai-grok-DqdH-Jr1.js} +1 -1
  73. package/dist/ui/index.html +3 -3
  74. package/dist/ui/packages/webapp/index.html +3 -3
  75. package/package.json +1 -1
  76. package/dist/ui/assets/clipboard-DqCJeCL8.js +0 -1
  77. package/dist/ui/assets/dip-DYiCUWEu.js +0 -1
  78. package/dist/ui/assets/provider-store-access-BSkCbZy7.js +0 -1
  79. package/dist/ui/assets/provider-store-access-CH72xTU9.js +0 -1
  80. package/dist/ui/assets/session-freezer-C5-2JCLc.js +0 -1
  81. package/dist/ui/assets/sprinkle-renderer-CTKWW81m.js +0 -192
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./wc-permissions-registry-C7PhTX3c.js";import{i as n,n as r,r as i}from"./whisper-engine-Bu67yIcD.js";const a=16e3;async function o(e){if(typeof AudioContext>`u`||typeof OfflineAudioContext>`u`)throw Error(`audio decoding requires a window/page realm (AudioContext unavailable)`);let t=new AudioContext,n;try{n=await t.decodeAudioData(e.slice(0))}finally{await t.close().catch(()=>{})}let r=Math.max(1,Math.ceil(n.duration*a)),i=new OfflineAudioContext(1,r,a),o=i.createBufferSource();return o.buffer=n,o.connect(i.destination),o.start(),(await i.startRendering()).getChannelData(0).slice(0)}e(`speech:whisper-session`);function s(e){return e?.split(`-`)[0]?.toLowerCase()||void 0}const c=e(`speech:hear`);let l={};function u(){return l.getPermissionSurface?l.getPermissionSurface():t()||null}function d(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??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,s=new n;s.continuous=!1,s.interimResults=!1,e&&(s.lang=e),c.debug(`builtinOnce: recognizer constructed`,{lang:e??`(browser default)`,timeoutMs:t});let l=``,u=!1,d=setTimeout(()=>{c.debug(`builtinOnce: timeout reached — stopping recognizer`,{elapsedMs:o()});try{s.stop()}catch{}},t);s.onstart=()=>c.debug(`builtinOnce: onstart (recognition service active)`,{elapsedMs:o()}),s.onaudiostart=()=>c.debug(`builtinOnce: onaudiostart (capturing audio)`,{elapsedMs:o()}),s.onspeechstart=()=>c.debug(`builtinOnce: onspeechstart (speech detected)`,{elapsedMs:o()}),s.onspeechend=()=>c.debug(`builtinOnce: onspeechend (speech ended)`,{elapsedMs:o()}),s.onnomatch=()=>c.debug(`builtinOnce: onnomatch (no recognizable speech)`,{elapsedMs:o()}),s.onresult=e=>{let t=[];for(let n=0;n<e.results.length;n++)t.push(e.results[n][0]?.transcript??``);l=t.join(` `).trim(),c.debug(`builtinOnce: onresult`,{elapsedMs:o(),resultCount:e.results.length,transcriptLength:l.length})},s.onerror=e=>{if(e.error===`no-speech`||e.error===`aborted`){c.debug(`builtinOnce: onerror (non-fatal — ends with empty transcript)`,{elapsedMs:o(),code:e.error});return}u=!0,clearTimeout(d),c.error(`builtinOnce: onerror (fatal)`,{elapsedMs:o(),code:e.error}),i(new f(e.error))},s.onend=()=>{clearTimeout(d),u?c.debug(`builtinOnce: onend after fatal error (already rejected)`,{elapsedMs:o()}):(c.debug(`builtinOnce: onend — resolving`,{elapsedMs:o(),transcriptLength:l.length,empty:l.length===0}),r(l))},c.debug(`builtinOnce: calling recognizer.start()`,{elapsedMs:o()}),s.start()}):Promise.reject(Error(`speech recognition unavailable in this environment`))}async function g(e){let t={audio:e?{deviceId:{exact:e}}:!0},n=u();if(n){c.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`){c.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 c.error(`acquireMicrophoneStream: permission granted without a microphone stream`),Error(`microphone permission granted without a stream`);return c.debug(`acquireMicrophoneStream: microphone stream acquired via surface`),i.stream}if(!navigator.mediaDevices?.getUserMedia)throw c.error(`acquireMicrophoneStream: getUserMedia unavailable in this realm`),Error(`microphone capture unavailable in this realm`);c.debug(`acquireMicrophoneStream: no permission surface; calling getUserMedia directly`);try{let e=await navigator.mediaDevices.getUserMedia(t);return c.debug(`acquireMicrophoneStream: getUserMedia succeeded (direct)`),e}catch(e){throw c.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(!u())return c.debug(`primeBuiltinPermission: no permission surface; recognizer drives its own prompt`),null;c.debug(`primeBuiltinPermission: priming microphone grant via permission surface`,{hasDeviceId:!!e});let t=await g(e);return c.debug(`primeBuiltinPermission: microphone primed; holding stream open for recognizer`),t}function y(e){if(e){for(let t of e.getTracks())t.stop();c.debug(`primeBuiltinPermission: released primed microphone stream`)}}async function b(e,t){let n=await _(e.deviceId),i=``;try{i=await h(e.lang,t)}catch(e){c.warn(`builtin endpointing failed; transcribing captured audio anyway`,e)}let a=await n.stop();if(!a)return{transcript:i,engine:`builtin`};try{let t=await r(),n=await o(await a.arrayBuffer()),i=await t.transcribe(n,{language:s(e.lang)});if(i)return{transcript:i,engine:`enhanced`}}catch(e){c.warn(`whisper transcription failed; falling back to builtin text`,e)}return{transcript:i,engine:`builtin`}}async function x(e={}){let t=e.timeoutMs??3e4,r=e.engine??`auto`,i=n()===`ready`;if(r===`enhanced`&&!i)throw c.error(`hearCapture: enhanced engine requested but whisper is not ready`),Error("enhanced engine not ready — run `hear --warmup` (check progress with `hear --status`)");let a=r!==`builtin`&&i;if(c.debug(`hearCapture: engine dispatch`,{requested:r,enhancedReady:i,resolved:a?`enhanced`:`builtin`}),a)return b(e,t);let o=await v(e.deviceId);try{let n=await h(e.lang,t);return c.debug(`hearCapture: builtin recognition produced a transcript`),{transcript:n,engine:`builtin`}}catch(n){if(!m(n))throw c.error(`hearCapture: builtin recognition failed`,n),n;if(i)return c.debug(`hearCapture: builtin unsupported in this browser; falling back to enhanced whisper`),y(o),o=null,b(e,t);throw c.error(`hearCapture: builtin unsupported and whisper not ready`,{code:n.code}),n}finally{y(o)}}async function S(e,t){let n=await r(),i=await o(e);return{transcript:await n.transcribe(i,{language:s(t)}),engine:`enhanced`}}function C(){let e=i();return{state:n(),...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-LESFN7Hj.js";import{t}from"./wc-permissions-registry-C7PhTX3c.js";import{i as n,n as r,r as i}from"./whisper-engine-GZAusomQ.js";const a=16e3;async function o(e){if(typeof AudioContext>`u`||typeof OfflineAudioContext>`u`)throw Error(`audio decoding requires a window/page realm (AudioContext unavailable)`);let t=new AudioContext,n;try{n=await t.decodeAudioData(e.slice(0))}finally{await t.close().catch(()=>{})}let r=Math.max(1,Math.ceil(n.duration*a)),i=new OfflineAudioContext(1,r,a),o=i.createBufferSource();return o.buffer=n,o.connect(i.destination),o.start(),(await i.startRendering()).getChannelData(0).slice(0)}e(`speech:whisper-session`);function s(e){return e?.split(`-`)[0]?.toLowerCase()||void 0}const c=e(`speech:hear`);let l={};function u(){return l.getPermissionSurface?l.getPermissionSurface():t()||null}function d(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??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,s=new n;s.continuous=!1,s.interimResults=!1,e&&(s.lang=e),c.debug(`builtinOnce: recognizer constructed`,{lang:e??`(browser default)`,timeoutMs:t});let l=``,u=!1,d=setTimeout(()=>{c.debug(`builtinOnce: timeout reached — stopping recognizer`,{elapsedMs:o()});try{s.stop()}catch{}},t);s.onstart=()=>c.debug(`builtinOnce: onstart (recognition service active)`,{elapsedMs:o()}),s.onaudiostart=()=>c.debug(`builtinOnce: onaudiostart (capturing audio)`,{elapsedMs:o()}),s.onspeechstart=()=>c.debug(`builtinOnce: onspeechstart (speech detected)`,{elapsedMs:o()}),s.onspeechend=()=>c.debug(`builtinOnce: onspeechend (speech ended)`,{elapsedMs:o()}),s.onnomatch=()=>c.debug(`builtinOnce: onnomatch (no recognizable speech)`,{elapsedMs:o()}),s.onresult=e=>{let t=[];for(let n=0;n<e.results.length;n++)t.push(e.results[n][0]?.transcript??``);l=t.join(` `).trim(),c.debug(`builtinOnce: onresult`,{elapsedMs:o(),resultCount:e.results.length,transcriptLength:l.length})},s.onerror=e=>{if(e.error===`no-speech`||e.error===`aborted`){c.debug(`builtinOnce: onerror (non-fatal — ends with empty transcript)`,{elapsedMs:o(),code:e.error});return}u=!0,clearTimeout(d),c.error(`builtinOnce: onerror (fatal)`,{elapsedMs:o(),code:e.error}),i(new f(e.error))},s.onend=()=>{clearTimeout(d),u?c.debug(`builtinOnce: onend after fatal error (already rejected)`,{elapsedMs:o()}):(c.debug(`builtinOnce: onend — resolving`,{elapsedMs:o(),transcriptLength:l.length,empty:l.length===0}),r(l))},c.debug(`builtinOnce: calling recognizer.start()`,{elapsedMs:o()}),s.start()}):Promise.reject(Error(`speech recognition unavailable in this environment`))}async function g(e){let t={audio:e?{deviceId:{exact:e}}:!0},n=u();if(n){c.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`){c.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 c.error(`acquireMicrophoneStream: permission granted without a microphone stream`),Error(`microphone permission granted without a stream`);return c.debug(`acquireMicrophoneStream: microphone stream acquired via surface`),i.stream}if(!navigator.mediaDevices?.getUserMedia)throw c.error(`acquireMicrophoneStream: getUserMedia unavailable in this realm`),Error(`microphone capture unavailable in this realm`);c.debug(`acquireMicrophoneStream: no permission surface; calling getUserMedia directly`);try{let e=await navigator.mediaDevices.getUserMedia(t);return c.debug(`acquireMicrophoneStream: getUserMedia succeeded (direct)`),e}catch(e){throw c.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(!u())return c.debug(`primeBuiltinPermission: no permission surface; recognizer drives its own prompt`),null;c.debug(`primeBuiltinPermission: priming microphone grant via permission surface`,{hasDeviceId:!!e});let t=await g(e);return c.debug(`primeBuiltinPermission: microphone primed; holding stream open for recognizer`),t}function y(e){if(e){for(let t of e.getTracks())t.stop();c.debug(`primeBuiltinPermission: released primed microphone stream`)}}async function b(e,t){let n=await _(e.deviceId),i=``;try{i=await h(e.lang,t)}catch(e){c.warn(`builtin endpointing failed; transcribing captured audio anyway`,e)}let a=await n.stop();if(!a)return{transcript:i,engine:`builtin`};try{let t=await r(),n=await o(await a.arrayBuffer()),i=await t.transcribe(n,{language:s(e.lang)});if(i)return{transcript:i,engine:`enhanced`}}catch(e){c.warn(`whisper transcription failed; falling back to builtin text`,e)}return{transcript:i,engine:`builtin`}}async function x(e={}){let t=e.timeoutMs??3e4,r=e.engine??`auto`,i=n()===`ready`;if(r===`enhanced`&&!i)throw c.error(`hearCapture: enhanced engine requested but whisper is not ready`),Error("enhanced engine not ready — run `hear --warmup` (check progress with `hear --status`)");let a=r!==`builtin`&&i;if(c.debug(`hearCapture: engine dispatch`,{requested:r,enhancedReady:i,resolved:a?`enhanced`:`builtin`}),a)return b(e,t);let o=await v(e.deviceId);try{let n=await h(e.lang,t);return c.debug(`hearCapture: builtin recognition produced a transcript`),{transcript:n,engine:`builtin`}}catch(n){if(!m(n))throw c.error(`hearCapture: builtin recognition failed`,n),n;if(i)return c.debug(`hearCapture: builtin unsupported in this browser; falling back to enhanced whisper`),y(o),o=null,b(e,t);throw c.error(`hearCapture: builtin unsupported and whisper not ready`,{code:n.code}),n}finally{y(o)}}async function S(e,t){let n=await r(),i=await o(e);return{transcript:await n.transcribe(i,{language:s(t)}),engine:`enhanced`}}function C(){let e=i();return{state:n(),...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};
@@ -39,7 +39,7 @@ let r=t(),i=n(),a=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbo
39
39
  `)?t:`${t}\n`);return}try{e.writeStdout(`${JSON.stringify(t,null,2)}\n`)}catch{e.writeStdout(`${String(t)}\n`)}},warn(n,i){let a=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0;e.writeStderr(r(a,t(n)))},help(t){throw e.writeStdout(t.endsWith(`
40
40
  `)?t:`${t}\n`),e.exit(0),Error(`unreachable`)}}}const cr={reset:`\x1B[0m`,green:`\x1B[32m`,red:`\x1B[31m`,yellow:`\x1B[33m`,gray:`\x1B[90m`,bold:`\x1B[1m`,cyan:`\x1B[36m`,dim:`\x1B[2m`};function lr(e){let t=e.isTTY&&!e.noColor,n=e=>n=>t?`${e}${n}${cr.reset}`:String(n);return{enabled:t,green:n(cr.green),red:n(cr.red),yellow:n(cr.yellow),gray:n(cr.gray),bold:n(cr.bold),cyan:n(cr.cyan),dim:n(cr.dim)}}const ur={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,M:26298e5,y:315576e5};function dr(e){if(typeof e==`number`&&Number.isFinite(e))return Math.trunc(e);if(typeof e!=`string`)throw TypeError(`time.parseDuration: spec must be string or number`);let t=e.trim(),n=/^([0-9]+(?:\.[0-9]+)?)\s*(ms|s|m|h|d|w|M|y)?$/.exec(t);if(!n)throw RangeError(`time.parseDuration: unrecognized spec "${e}"`);let r=Number(n[1]),i=n[2]??`ms`;return Math.trunc(r*ur[i])}function fr(e){return e<10?`0${e}`:String(e)}const pr={parseDuration:dr,ago(e,t=new Date){return new Date(t.getTime()-dr(e))},range(e,t=new Date){let n=new Date(t.getTime());return{start:new Date(n.getTime()-dr(e)),end:n}},future(e,t=new Date){let n=new Date(t.getTime());return{start:n,end:new Date(n.getTime()+dr(e))}},gmailDate(e,t=new Date){let n=new Date(t.getTime()-dr(e));return`${n.getFullYear()}/${fr(n.getMonth()+1)}/${fr(n.getDate())}`}},mr=/\u001b\[[0-9;]*m/g;function hr(e){return e.replace(mr,``)}function gr(e){return hr(e).length}function _r(e,t){let n=String(e??``);return t<=0?``:gr(n)<=t?n:t<=1?n.slice(0,t):`${hr(n).slice(0,t-1)}…`}function vr(e,t){let n=String(e??``),r=gr(n);return r===t?n:r>t?_r(n,t):n+` `.repeat(t-r)}function yr(e,t){if(!e.length)return``;let n=Math.max(...e.map(e=>e.length)),r=[];for(let i=0;i<n;i++)if(t&&t[i]!==void 0)r[i]=t[i];else{let t=0;for(let n of e){let e=i<n.length?String(n[i]??``):``;t=Math.max(t,gr(e))}r[i]=t}return e.map(e=>r.map((t,n)=>vr(n<e.length?String(e[n]??``):``,t)).join(` `).replace(/\s+$/,``)).join(`
41
41
  `)}function br(e){return e instanceof Date?e:new Date(e)}function xr(e,t=`short`){let n=br(e);if(Number.isNaN(n.getTime()))return String(e);if(t===`iso`)return n.toISOString();if(t===`locale`)return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(n);if(t===`human`){let e=Date.now()-n.getTime(),t=Math.abs(e);if(t<6e4)return e>=0?`just now`:`in a moment`;let r=(t,n)=>e>=0?`${t} ${n}${t===1?``:`s`} ago`:`in ${t} ${n}${t===1?``:`s`}`;return t<36e5?r(Math.round(t/6e4),`minute`):t<864e5?r(Math.round(t/36e5),`hour`):t<26298e5?r(Math.round(t/864e5),`day`):t<315576e5?r(Math.round(t/26298e5),`month`):r(Math.round(t/315576e5),`year`)}return`${n.getFullYear()}-${fr(n.getMonth()+1)}-${fr(n.getDate())}`}const Sr={trunc:_r,col:vr,table:yr,date:xr},Cr=async(e,t,n)=>{let r=Math.max(1,Math.trunc(e)||1),i=Array(t.length),a=0,o=[],s=async()=>{for(;;){let e=a++;if(e>=t.length)return;i[e]=await n(t[e],e)}};for(let e=0;e<Math.min(r,t.length);e++)o.push(s());return await Promise.all(o),i};function wr(e,t){let n=[];for(let r of e)r===``||r===`.`||(r===`..`?n.length>0&&n[n.length-1]!==`..`?n.pop():t&&n.push(`..`):n.push(r));return n}function Tr(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=wr(e.split(`/`),!t).join(`/`);return r.length===0&&!t&&(r=`.`),r.length>0&&n&&(r+=`/`),(t?`/`:``)+r}function Er(...e){let t=e.filter(e=>typeof e==`string`&&e.length>0).join(`/`);return t.length===0?`.`:Tr(t)}function Dr(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;t--)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function Or(e,t){let n=0,r=-1,i=!0;for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)===47){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);let a=r===-1?``:e.slice(n,r);return t&&a.endsWith(t)&&a!==t?a.slice(0,a.length-t.length):a}function kr(e){let t=Or(e),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n)}function Ar(...e){let t=``,n=!1;for(let r=e.length-1;r>=0&&!n;r--){let i=e[r];typeof i!=`string`||i.length===0||(t=t.length>0?`${i}/${t}`:i,n=i.charCodeAt(0)===47)}n||(t=t.length>0?`/${t}`:`/`);let r=wr(t.split(`/`),!1).join(`/`);return r.length>0?`/${r}`:`/`}function jr(e,t){let n=Ar(e),r=Ar(t);if(n===r)return``;let i=n.split(`/`).filter(Boolean),a=r.split(`/`).filter(Boolean),o=0;for(;o<i.length&&o<a.length&&i[o]===a[o];)o++;return[...i.slice(o).map(()=>`..`),...a.slice(o)].join(`/`)}function Mr(e){let t=e.charCodeAt(0)===47?`/`:``,n=Or(e),r=kr(e),i=r?n.slice(0,n.length-r.length):n,a=Dr(e);return a===`.`&&t===``&&(a=``),{root:t,dir:a,base:n,ext:r,name:i}}function Nr(e){let t=e.dir||e.root||``,n=e.base||`${e.name||``}${e.ext||``}`;return t?t===e.root?`${t}${n}`:`${t}/${n}`:n}const Pr={sep:`/`,delimiter:`:`,basename:Or,dirname:Dr,extname:kr,isAbsolute:e=>e.length>0&&e.charCodeAt(0)===47,join:Er,normalize:Tr,resolve:Ar,relative:jr,parse:Mr,format:Nr},Fr=65536,Ir={md5:y.md5,sha1:b.sha1,sha256:x.sha256};function Lr(e,t){let n=globalThis.Buffer;if(!n)throw Error(`crypto.createHash: Buffer is unavailable in this environment`);return t?n.from(e,t):n.from(e)}function Rr(e,t){return typeof e==`string`?t===`hex`||t===`base64`||t===`base64url`||t===`latin1`||t===`binary`?new Uint8Array(Lr(e,t===`binary`?`latin1`:t)):e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function zr(e){let t=Ir[String(e).toLowerCase().replace(`-`,``)];if(!t)throw Error(`Digest method not supported: ${e}`);let n=t.create(),r=!1,i={update(e,t){if(r)throw Error(`Digest already called`);return n.update(Rr(e,t)),i},digest(e){r=!0;let t=Lr(n.array());return e?t.toString(e):t}};return i}function Br(){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!=`function`)throw Error(`crypto: globalThis.crypto is unavailable in this environment`);return e}function Vr(e){return Br().getRandomValues(e)}function Hr(e){for(let t=0;t<e.length;t+=Fr){let n=Math.min(t+Fr,e.length);Vr(e.subarray(t,n))}}function Ur(e){return e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}const X=Array.from({length:256},(e,t)=>(t+256).toString(16).slice(1));function Wr(){let e=Br();if(typeof e.randomUUID==`function`)return e.randomUUID();let t=Vr(new Uint8Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,`${X[t[0]]}${X[t[1]]}${X[t[2]]}${X[t[3]]}-${X[t[4]]}${X[t[5]]}-${X[t[6]]}${X[t[7]]}-${X[t[8]]}${X[t[9]]}-${X[t[10]]}${X[t[11]]}${X[t[12]]}${X[t[13]]}${X[t[14]]}${X[t[15]]}`}const Gr={randomFillSync(e,t=0,n){let r=Ur(e),i=t,a=n===void 0?r.length:i+n;return Hr(r.subarray(i,a)),e},randomBytes(e){let t=globalThis.Buffer,n=t&&typeof t.allocUnsafe==`function`?t.allocUnsafe(e):new Uint8Array(e);return Hr(Ur(n)),n},randomUUID:Wr,getRandomValues(e){return Vr(e)},createHash:zr,get webcrypto(){return Br()},get subtle(){return Br().subtle}};var Z=class extends Error{actual;expected;operator;generatedMessage;code;constructor(e={}){let t=!e.message;super(e.message||`${Kr(e.actual)} ${e.operator||`!=`} ${Kr(e.expected)}`),this.name=`AssertionError`,this.actual=e.actual,this.expected=e.expected,this.operator=e.operator||``,this.generatedMessage=t,this.code=`ERR_ASSERTION`}};function Kr(e){if(typeof e==`string`)return JSON.stringify(e);if(e==null)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function Q(e,t){return e instanceof Error?e:typeof e==`string`?new Z({message:e}):t()}function qr(e,t,n,r){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Yr(e[i],t[i],n,r))return!1;return!0}function Jr(e,t,n,r){let i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let a of i){if(!Object.prototype.hasOwnProperty.call(t,a))return!1;let i=e[a],o=t[a];if(!Yr(i,o,n,r))return!1}return!0}function Yr(e,t,n,r){if((n?Object.is(e,t):e===t)||!n&&e==t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;let i=e,a=t;return n&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(a)?!1:r.get(i)===a?!0:(r.set(i,a),Array.isArray(e)===Array.isArray(t)?Array.isArray(e)&&Array.isArray(t)?qr(e,t,n,r):Jr(i,a,n,r):!1)}function Xr(e,t){try{if(e instanceof t)return!0}catch{}try{return!!t(e)}catch{return!1}}function Zr(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(r instanceof RegExp){if(typeof t!=`string`||!r.test(t))return!1}else if(t!==r)return!1}return!0}function Qr(e,t){if(t===void 0)return!0;if(t instanceof RegExp){let n=e instanceof Error?e.message:String(e);return t.test(n)}return typeof t==`function`?Xr(e,t):t&&typeof t==`object`?!e||typeof e!=`object`?!1:Zr(e,t):!1}function $r(e){let t=(e,t)=>{if(!e)throw Q(t,()=>new Z({message:`The expression evaluated to a falsy value`,actual:e,expected:!0,operator:`==`}))},n=((e,n)=>t(e,n)),r=(e,t,n)=>{if(!Object.is(e,t))throw Q(n,()=>new Z({actual:e,expected:t,operator:`strictEqual`}))},i=(t,n,i)=>{if(e){r(t,n,i);return}if(t!=n)throw Q(i,()=>new Z({actual:t,expected:n,operator:`==`}))},a=(e,t,n)=>{if(Object.is(e,t))throw Q(n,()=>new Z({actual:e,expected:t,operator:`notStrictEqual`}))},o=(t,n,r)=>{if(e){a(t,n,r);return}if(t==n)throw Q(r,()=>new Z({actual:t,expected:n,operator:`!=`}))},s=(e,t,n)=>{if(!Yr(e,t,!0,new WeakMap))throw Q(n,()=>new Z({actual:e,expected:t,operator:`deepStrictEqual`}))},c=(t,n,r)=>{if(e){s(t,n,r);return}if(!Yr(t,n,!1,new WeakMap))throw Q(r,()=>new Z({actual:t,expected:n,operator:`deepEqual`}))},l=(e,t,n)=>{if(Yr(e,t,!0,new WeakMap))throw Q(n,()=>new Z({actual:e,expected:t,operator:`notDeepStrictEqual`}))};return n.ok=t,n.equal=i,n.notEqual=o,n.strictEqual=r,n.notStrictEqual=a,n.deepEqual=c,n.deepStrictEqual=s,n.notDeepEqual=(t,n,r)=>{if(e){l(t,n,r);return}if(Yr(t,n,!1,new WeakMap))throw Q(r,()=>new Z({actual:t,expected:n,operator:`notDeepEqual`}))},n.notDeepStrictEqual=l,n.throws=(e,t,n)=>{let r,i=!1;try{e()}catch(e){r=e,i=!0}if(!i)throw Q(typeof t==`string`?t:n,()=>new Z({message:`Missing expected exception`,operator:`throws`}));if(!(typeof t==`string`||t instanceof Error)&&!Qr(r,t))throw Q(n,()=>new Z({message:`Got unwanted exception`,actual:r,operator:`throws`}))},n.doesNotThrow=(e,t)=>{try{e()}catch(e){throw Q(t,()=>new Z({message:`Got unwanted exception`,actual:e,operator:`doesNotThrow`}))}},n.fail=e=>{throw Q(e,()=>new Z({message:`Failed`,operator:`fail`}))},n.AssertionError=Z,n}const ei=$r(!0);ei.strict=ei;const ti=$r(!1);ti.strict=ei;const ni=Symbol.for(`nodejs.util.inspect.custom`),ri=Symbol.for(`nodejs.util.promisify.custom`);function ii(e){return`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}function ai(e){if(e===null)return`null`;let t=typeof e;if(t===`string`)return ii(e);if(t===`number`)return Object.is(e,-0)?`-0`:String(e);if(t===`bigint`)return`${String(e)}n`;if(t===`boolean`||t===`undefined`)return String(e);if(t===`symbol`)return e.toString();if(t===`function`){let t=e.name;return t?`[Function: ${t}]`:`[Function (anonymous)]`}return null}function oi(e){return e instanceof RegExp?e.toString():e instanceof Date?Number.isNaN(e.getTime())?`Invalid Date`:e.toISOString():e instanceof Error?e.stack||`${e.name}: ${e.message}`:null}function si(e,t,n){if(Array.isArray(e))return e.length===0?`[]`:`[ ${e.map(e=>ci(e,t+1,n)).join(`, `)} ]`;if(e instanceof Map){let r=[...e].map(([e,r])=>`${ci(e,t+1,n)} => ${ci(r,t+1,n)}`);return`Map(${e.size}) {${r.length?` ${r.join(`, `)} `:``}}`}if(e instanceof Set){let r=[...e].map(e=>ci(e,t+1,n));return`Set(${e.size}) {${r.length?` ${r.join(`, `)} `:``}}`}let r=Object.keys(e),i=e.constructor?e.constructor.name:``,a=i&&i!==`Object`?`${i} `:``;return r.length===0?`${a}{}`:`${a}{ ${r.map(r=>`${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(r)?r:ii(r)}: ${ci(e[r],t+1,n)}`).join(`, `)} }`}function ci(e,t,n){let r=ai(e);if(r!==null)return r;let i=e,a=oi(i);if(a!==null)return a;let o=i[ni];if(typeof o==`function`)try{return String(o.call(i,n.maxDepth,n.opts))}catch{}if(n.seen.has(e))return`[Circular *1]`;if(n.maxDepth!==null&&t>n.maxDepth)return Array.isArray(e)?`[Array]`:`[Object]`;n.seen.add(e);try{return si(i,t,n)}finally{n.seen.delete(e)}}function li(e,t={}){let n=t.depth===void 0?2:t.depth;return ci(e,0,{seen:new Set,maxDepth:n,opts:t})}function ui(e,t,n,r){if(e===`%%`)return`%`;if(n.i>=t.length)return e;let i=t[n.i];switch(e){case`%s`:return n.i++,typeof i==`string`?i:typeof i==`bigint`?`${String(i)}n`:i==null||typeof i==`number`||typeof i==`boolean`?String(i):li(i,{depth:r.depth===void 0?2:r.depth});case`%d`:return n.i++,typeof i==`bigint`?`${String(i)}n`:Number.isNaN(Number(i))?`NaN`:String(Number(i));case`%i`:return n.i++,typeof i==`bigint`?`${String(i)}n`:String(Number.parseInt(i,10));case`%f`:return n.i++,String(typeof i==`bigint`?i:Number.parseFloat(i));case`%j`:n.i++;try{return JSON.stringify(i)??`undefined`}catch{return`[Circular]`}case`%o`:return n.i++,li(i,{depth:4});case`%O`:return n.i++,li(i,{depth:null});case`%c`:return n.i++,``;default:return e}}function di(e,...t){let n=t[0];if(typeof n!=`string`)return t.map(e=>typeof e==`string`?e:li(e)).join(` `);let r={i:1},i=n.replace(/%[sdifjoOc%]/g,n=>ui(n,t,r,e));for(;r.i<t.length;r.i++){let e=t[r.i];i+=` ${typeof e==`string`?e:li(e)}`}return i}function fi(...e){return di({},...e)}function pi(e,t){if(e==null)throw TypeError(`The constructor to "inherits" must not be null or undefined`);if(t==null)throw TypeError(`The super constructor to "inherits" must not be null or undefined`);if(t.prototype===void 0)throw TypeError(`The super constructor to "inherits" must have a prototype`);e.super_=t,Object.setPrototypeOf(e.prototype,t.prototype)}function mi(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type function`);let t=e[ri];if(t){if(typeof t!=`function`)throw TypeError(`The [util.promisify.custom] property must be of type function`);return t}function n(...t){return new Promise((n,r)=>{e.call(this,...t,(e,...t)=>{if(e){r(e);return}n(t.length>1?t:t[0])})})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)),n}const hi=li;hi.custom=ni;const gi=mi;gi.custom=ri;const _i={format:fi,formatWithOptions:di,inspect:hi,inherits:pi,promisify:gi};function vi(e){return typeof e==`string`?new Uint8Array(Lr(e,`utf8`)):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function yi(e){let t={};return e&&(typeof e.level==`number`&&(t.level=e.level),typeof e.windowBits==`number`&&(t.windowBits=e.windowBits),typeof e.memLevel==`number`&&(t.memLevel=e.memLevel),typeof e.strategy==`number`&&(t.strategy=e.strategy)),t}function bi(e,t,n){return Lr(e(vi(t),yi(n)))}function xi(e,t,n,r){let i=typeof n==`function`?n:r,a=typeof n==`function`?void 0:n;if(typeof i!=`function`)throw TypeError(`zlib: callback is required`);let o;try{o=bi(e,t,a)}catch(e){queueMicrotask(()=>i(e instanceof Error?e:Error(String(e))));return}queueMicrotask(()=>i(null,o))}const Si={gzipSync:(e,t)=>bi($n,e,t),gunzipSync:(e,t)=>bi(rr,e,t),deflateSync:(e,t)=>bi(Zn,e,t),inflateSync:(e,t)=>bi(rr,e,t),deflateRawSync:(e,t)=>bi(Qn,e,t),inflateRawSync:(e,t)=>bi(ir,e,t),gzip:(e,t,n)=>xi($n,e,t,n),gunzip:(e,t,n)=>xi(rr,e,t,n),deflate:(e,t,n)=>xi(Zn,e,t,n),inflate:(e,t,n)=>xi(rr,e,t,n),deflateRaw:(e,t,n)=>xi(Qn,e,t,n),inflateRaw:(e,t,n)=>xi(ir,e,t,n),constants:{Z_NO_FLUSH:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1}},Ci={tmpdir:()=>`/tmp`,homedir:()=>`/home/user`,platform:()=>`linux`,arch:()=>`x64`,EOL:`
42
- `,cpus:()=>[{model:`virtual`,speed:0}],hostname:()=>`slicc`,type:()=>`Linux`,release:()=>`0.0.0`};function wi(e){let t=typeof e==`string`?e:e.href;if(!t.startsWith(`file://`))throw TypeError(`fileURLToPath: not a file URL`);let n=t.slice(7);return decodeURIComponent(n)}function Ti(e){let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return new URL(`file://${t}`)}const Ei={URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams,fileURLToPath:wi,pathToFileURL:Ti};var Di=class{_events=new Map;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}addListener(e,t){return this.on(e,t)}off(e,t){let n=this._events.get(e);if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&this._events.delete(e)}return this}removeListener(e,t){return this.off(e,t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}removeAllListeners(e){return e===void 0?this._events.clear():this._events.delete(e),this}listenerCount(e){return this._events.get(e)?.length??0}listeners(e){return[...this._events.get(e)??[]]}};const Oi=Object.assign(Di,{EventEmitter:Di,default:Di});var ki=class{_events=new Map;writable=!0;readable=!0;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this._events.get(e);if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}return this}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}pipe(e){return e}removeListener(e,t){return this.off(e,t)}removeAllListeners(){return this._events.clear(),this}},Ai=class extends ki{read(){return null}destroy(){return this}},ji=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}destroy(){return this}},Mi=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}read(){return null}destroy(){return this}};const Ni={Readable:Ai,Writable:ji,Transform:Mi,PassThrough:class extends Mi{},Stream:ki};let Pi=1;function Fi(e){if(typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}return e==null?``:String(e)}function Ii(e,t){return t===void 0||t===`utf8`||t===`utf-8`?e:t===`buffer`||t===null?Lr(e):Lr(e).toString(t)}function Li(e,t){if(e.length===0)return Ii(``,t);if(typeof e[0]==`string`)return e.join(``);let n=globalThis.Buffer;return n?n.concat(e):e[0]}function Ri(e,t,n){t.length>0&&e.emit(`data`,Ii(t,n)),e.readable=!1,e.emit(`end`)}function zi(e){let t=e=>{typeof e==`function`&&queueMicrotask(e)};return{writable:!0,write(n,r,i){return e.stdin.write(Fi(n)),t(typeof r==`function`?r:i),!0},end(n,r,i){n!==void 0&&typeof n!=`function`&&e.stdin.write(Fi(n)),e.stdin.end(),this.writable=!1,t(typeof n==`function`?n:typeof r==`function`?r:i)}}}var Bi=class extends Di{stdout;stderr;stdin;pid;exitCode=null;signalCode=null;killed=!1;spawnfile;spawnargs;handle;constructor(e,t,n,r){super(),this.handle=e,this.pid=Pi++,this.spawnfile=n,this.spawnargs=r,this.stdout=new Ai,this.stderr=new Ai,this.stdin=zi(e),e.done.then(e=>this.finish(e,t),e=>this.emit(`error`,e instanceof Error?e:Error(String(e))))}finish(e,t){Ri(this.stdout,e.stdout,t),Ri(this.stderr,e.stderr,t),this.exitCode=e.exitCode;let n=this.killed?null:e.exitCode,r=this.killed?this.signalCode:null;this.emit(`exit`,n,r),this.emit(`close`,n,r)}kill(e=`SIGTERM`){return this.killed=!0,this.signalCode=e,this.handle.kill(e).catch(()=>{}),!0}};function Vi(e){let t=(t,n,r,i,a)=>{let o=e.start(t),s=new Bi(o,r,i,a);return n.input!==void 0&&s.stdin.write(Fi(n.input)),queueMicrotask(()=>o.stdin.end()),s},n=(e,t,n,r)=>{if(typeof r!=`function`)return;let i=[],a=[];e.stdout.on(`data`,e=>i.push(e)),e.stderr.on(`data`,e=>a.push(e)),e.once(`error`,e=>r(e,Li(i,t),Li(a,t))),e.once(`close`,(o,s)=>{let c=Li(i,t),l=Li(a,t);if(o===0){r(null,c,l);return}r(Object.assign(Error(`Command failed: ${n}\n${Fi(l)}`),{code:o===null?void 0:o,killed:e.killed,signal:s??null,cmd:n}),c,l)})},r=(e,r,i)=>{let a=typeof r==`function`?r:i,o=r&&typeof r==`object`?r:{},s=o.encoding===void 0?`utf8`:o.encoding,c=t(e,o,s,e,[]);return n(c,s,e,a),c},i=(e,r,i,a)=>{let o=[],s={},c;Array.isArray(r)?(o=r,typeof i==`function`?c=i:(s=i??{},c=typeof a==`function`?a:void 0)):typeof r==`function`?c=r:r&&typeof r==`object`&&(s=r,c=typeof i==`function`?i:void 0);let l=s.encoding===void 0?`utf8`:s.encoding,u=[e,...o],d=t(u,s,l,e,o);return n(d,l,u.join(` `),c),d},a=(e,n,r)=>{let i=[],a={};Array.isArray(n)?(i=n,a=r??{}):n&&typeof n==`object`&&(a=n);let o=a.encoding===void 0?`buffer`:a.encoding;return t(a.shell?`${e}${i.length?` ${i.join(` `)}`:``}`:[e,...i],a,o,e,i)},o=(e,t)=>new Promise((n,i)=>{r(e,t,(e,t,r)=>{if(e){i(Object.assign(e,{stdout:t,stderr:r}));return}n({stdout:t,stderr:r})})}),s=(e,t,n)=>new Promise((r,a)=>{i(e,Array.isArray(t)?t:[],Array.isArray(t)?n:t,(e,t,n)=>{if(e){a(Object.assign(e,{stdout:t,stderr:n}));return}r({stdout:t,stderr:n})})}),c=e=>()=>{throw Error(`child_process.${e} is not available in the browser realm`)},l=(e,t)=>{Object.defineProperty(e,ri,{value:t,enumerable:!1,configurable:!0})};return l(r,o),l(i,s),{exec:r,execFile:i,spawn:a,execSync:c(`execSync`),spawnSync:c(`spawnSync`),execFileSync:c(`execFileSync`),fork:c(`fork`),ChildProcess:Bi}}const Hi=new Set([`child_process`,`events`,`fs`,`fs/promises`,`os`,`path`,`stream`,`url`,`crypto`,`process`,`buffer`,`assert`,`assert/strict`,`util`]),Ui=new Set([...new Set(`assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`))].filter(e=>!Hi.has(e)));function Wi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Gi=class{rpc;targetId;selector;index;constructor(e,t,n,r){this.rpc=e,this.targetId=t,this.selector=n,this.index=r}evalOnElement(e){let t=`(() => { const els = document.querySelectorAll(${JSON.stringify(this.selector)}); const el = els[${this.index}]; ${e} })()`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t])}async textContent(){return this.evalOnElement(`return el ? el.textContent : null;`)}async getAttribute(e){return this.evalOnElement(`return el ? el.getAttribute(${JSON.stringify(e)}) : null;`)}async isVisible(){return this.evalOnElement(`if (!el) return false; const s = getComputedStyle(el); if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0;`)}async boundingBox(){return this.evalOnElement(`if (!el) return null; const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height };`)}},Ki=class{rpc;targetId;constructor(e,t){this.rpc=e,this.targetId=t}async goto(e,t){await this.rpc.call(`browser`,`navigateTab`,[this.targetId,e])}async waitForLoadState(e){await this.rpc.call(`browser`,`waitForLoadState`,[this.targetId,e??`load`])}async evaluate(e,...t){let n=typeof e==`string`?e:`(${e.toString()})(${t.map(e=>JSON.stringify(e)).join(`, `)})`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,n])}async screenshot(e){let t={};e?.fullPage!==void 0&&(t.fullPage=e.fullPage);let n=Wi(await this.rpc.call(`browser`,`screenshotTab`,[this.targetId,t]));return e?.path&&await this.rpc.call(`vfs`,`writeFileBinary`,[e.path,n]),n}async $(e){return await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`!!document.querySelector(${JSON.stringify(e)})`])?new Gi(this.rpc,this.targetId,e,0):null}async $$(e){let t=await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.querySelectorAll(${JSON.stringify(e)}).length`]),n=[];for(let r=0;r<t;r++)n.push(new Gi(this.rpc,this.targetId,e,r));return n}async content(){return this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.documentElement.outerHTML`])}async setViewportSize(e){await this.rpc.call(`browser`,`setViewport`,[this.targetId,e.width,e.height])}async close(){await this.rpc.call(`browser`,`closeTab`,[this.targetId])}},qi=class{rpc;pageTargetIds=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);return this.pageTargetIds.push(t),e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]),new Ki(this.rpc,t)}async close(){let e=this.pageTargetIds.splice(0,this.pageTargetIds.length);for(let t of e)await this.rpc.call(`browser`,`closeTab`,[t])}};function Ji(e){let t=async t=>new qi(e);return{chromium:{launch:t},firefox:{launch:t},webkit:{launch:t}}}var Yi=class{port;nextId=1;pending=new Map;eventSubscribers=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{let t=e.data;if(t?.type===`realm-rpc-res`){let t=e.data,n=this.pending.get(t.id);if(!n)return;this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result);return}if(t?.type===`realm-event`){let t=e.data,n=this.eventSubscribers.get(t.channel);if(!n)return;for(let e of[...n])try{e(t.payload)}catch{}}},e.addEventListener(`message`,this.handler),e.start?.()}get pendingCount(){return this.pending.size}call(e,t,n=[]){if(this.disposed)return Promise.reject(Error(`realm-rpc: client disposed`));let r=this.nextId++,i={type:`realm-rpc-req`,id:r,channel:e,op:t,args:n};return new Promise((e,t)=>{this.pending.set(r,{resolve:e,reject:t}),this.port.postMessage(i)})}onEvent(e,t){if(this.disposed)return()=>{};let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{let n=this.eventSubscribers.get(e);n&&(n.delete(t),n.size===0&&this.eventSubscribers.delete(e))}}dispose(){if(this.disposed)return;this.disposed=!0,this.port.removeEventListener(`message`,this.handler);let e=Error(`realm-rpc: client disposed`);for(let t of this.pending.values())t.reject(e);this.pending.clear(),this.eventSubscribers.clear()}};const Xi=new Set([`bcrypt`,`better-sqlite3`,`canvas`,`cpu-features`,`fsevents`,`leveldown`,`libxmljs`,`libxmljs2`,`node-gyp-build`,`node-sass`,`puppeteer`,`robotjs`,`sass-embedded`,`sharp`,`snappy`,`sqlite3`,`tree-sitter`,`usb`]),Zi={sharp:` Use the built-in 'convert' shell command for image work.`,canvas:` Use the built-in 'convert' / OffscreenCanvas for image work.`,"better-sqlite3":` Use the built-in 'sqlite3' shell command (sql.js WASM).`,sqlite3:` Use the built-in 'sqlite3' shell command (sql.js WASM).`,bcrypt:` Use crypto.subtle.digest() with PBKDF2 / Argon2 in pure JS.`,puppeteer:` Use the built-in browser-automation shell commands.`};function Qi(e,t){let n=Zi[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${n}`)}function $i(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function ea(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function ta(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function na(e){let t=$i(e.argv[1]??``),n=ta(t,`references`),r=ta(t,`assets`),i=ta(t,`.config`);async function a(){let t;try{t=await e.fs.exists(i)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(i)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let a;try{a=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${i}: ${t}`)}if(a&&typeof a==`object`&&!Array.isArray(a))return a;throw Error(`skill.config(): ${i} must contain a JSON object`)}async function o(t){let n=await a();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(i,JSON.stringify(r,null,2)+`
42
+ `,cpus:()=>[{model:`virtual`,speed:0}],hostname:()=>`slicc`,type:()=>`Linux`,release:()=>`0.0.0`};function wi(e){let t=typeof e==`string`?e:e.href;if(!t.startsWith(`file://`))throw TypeError(`fileURLToPath: not a file URL`);let n=t.slice(7);return decodeURIComponent(n)}function Ti(e){let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return new URL(`file://${t}`)}const Ei={URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams,fileURLToPath:wi,pathToFileURL:Ti};var Di=class{_events=new Map;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}addListener(e,t){return this.on(e,t)}off(e,t){let n=this._events.get(e);if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&this._events.delete(e)}return this}removeListener(e,t){return this.off(e,t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}removeAllListeners(e){return e===void 0?this._events.clear():this._events.delete(e),this}listenerCount(e){return this._events.get(e)?.length??0}listeners(e){return[...this._events.get(e)??[]]}};const Oi=Object.assign(Di,{EventEmitter:Di,default:Di});var ki=class{_events=new Map;writable=!0;readable=!0;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this._events.get(e);if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}return this}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}pipe(e){return e}removeListener(e,t){return this.off(e,t)}removeAllListeners(){return this._events.clear(),this}},Ai=class extends ki{read(){return null}destroy(){return this}},ji=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}destroy(){return this}},Mi=class extends ki{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}read(){return null}destroy(){return this}};const Ni={Readable:Ai,Writable:ji,Transform:Mi,PassThrough:class extends Mi{},Stream:ki};let Pi=1;function Fi(e){if(typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}return e==null?``:String(e)}function Ii(e,t){return t===void 0||t===`utf8`||t===`utf-8`?e:t===`buffer`||t===null?Lr(e):Lr(e).toString(t)}function Li(e,t){if(e.length===0)return Ii(``,t);if(typeof e[0]==`string`)return e.join(``);let n=globalThis.Buffer;return n?n.concat(e):e[0]}function Ri(e,t,n){t.length>0&&e.emit(`data`,Ii(t,n)),e.readable=!1,e.emit(`end`)}function zi(e){let t=e=>{typeof e==`function`&&queueMicrotask(e)};return{writable:!0,write(n,r,i){return e.stdin.write(Fi(n)),t(typeof r==`function`?r:i),!0},end(n,r,i){n!==void 0&&typeof n!=`function`&&e.stdin.write(Fi(n)),e.stdin.end(),this.writable=!1,t(typeof n==`function`?n:typeof r==`function`?r:i)}}}var Bi=class extends Di{stdout;stderr;stdin;pid;exitCode=null;signalCode=null;killed=!1;spawnfile;spawnargs;handle;constructor(e,t,n,r){super(),this.handle=e,this.pid=Pi++,this.spawnfile=n,this.spawnargs=r,this.stdout=new Ai,this.stderr=new Ai,this.stdin=zi(e),e.done.then(e=>this.finish(e,t),e=>this.emit(`error`,e instanceof Error?e:Error(String(e))))}finish(e,t){Ri(this.stdout,e.stdout,t),Ri(this.stderr,e.stderr,t),this.exitCode=e.exitCode;let n=this.killed?null:e.exitCode,r=this.killed?this.signalCode:null;this.emit(`exit`,n,r),this.emit(`close`,n,r)}kill(e=`SIGTERM`){return this.killed=!0,this.signalCode=e,this.handle.kill(e).catch(()=>{}),!0}};function Vi(e){let t=(t,n,r,i,a)=>{let o=e.start(t),s=new Bi(o,r,i,a);return n.input!==void 0&&s.stdin.write(Fi(n.input)),queueMicrotask(()=>o.stdin.end()),s},n=(e,t,n,r)=>{if(typeof r!=`function`)return;let i=[],a=[];e.stdout.on(`data`,e=>i.push(e)),e.stderr.on(`data`,e=>a.push(e)),e.once(`error`,e=>r(e,Li(i,t),Li(a,t))),e.once(`close`,(o,s)=>{let c=Li(i,t),l=Li(a,t);if(o===0){r(null,c,l);return}r(Object.assign(Error(`Command failed: ${n}\n${Fi(l)}`),{code:o===null?void 0:o,killed:e.killed,signal:s??null,cmd:n}),c,l)})},r=(e,r,i)=>{let a=typeof r==`function`?r:i,o=r&&typeof r==`object`?r:{},s=o.encoding===void 0?`utf8`:o.encoding,c=t(e,o,s,e,[]);return n(c,s,e,a),c},i=(e,r,i,a)=>{let o=[],s={},c;Array.isArray(r)?(o=r,typeof i==`function`?c=i:(s=i??{},c=typeof a==`function`?a:void 0)):typeof r==`function`?c=r:r&&typeof r==`object`&&(s=r,c=typeof i==`function`?i:void 0);let l=s.encoding===void 0?`utf8`:s.encoding,u=[e,...o],d=t(u,s,l,e,o);return n(d,l,u.join(` `),c),d},a=(e,n,r)=>{let i=[],a={};Array.isArray(n)?(i=n,a=r??{}):n&&typeof n==`object`&&(a=n);let o=a.encoding===void 0?`buffer`:a.encoding;return t(a.shell?`${e}${i.length?` ${i.join(` `)}`:``}`:[e,...i],a,o,e,i)},o=(e,t)=>new Promise((n,i)=>{r(e,t,(e,t,r)=>{if(e){i(Object.assign(e,{stdout:t,stderr:r}));return}n({stdout:t,stderr:r})})}),s=(e,t,n)=>new Promise((r,a)=>{i(e,Array.isArray(t)?t:[],Array.isArray(t)?n:t,(e,t,n)=>{if(e){a(Object.assign(e,{stdout:t,stderr:n}));return}r({stdout:t,stderr:n})})}),c=e=>()=>{throw Error(`child_process.${e} is not available in the browser realm`)},l=(e,t)=>{Object.defineProperty(e,ri,{value:t,enumerable:!1,configurable:!0})};return l(r,o),l(i,s),{exec:r,execFile:i,spawn:a,execSync:c(`execSync`),spawnSync:c(`spawnSync`),execFileSync:c(`execFileSync`),fork:c(`fork`),ChildProcess:Bi}}const Hi=new Set([`child_process`,`events`,`fs`,`fs/promises`,`os`,`path`,`stream`,`url`,`crypto`,`process`,`buffer`,`assert`,`assert/strict`,`util`]),Ui=new Set([...new Set(`assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`))].filter(e=>!Hi.has(e)));function Wi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Gi=class{rpc;targetId;selector;index;constructor(e,t,n,r){this.rpc=e,this.targetId=t,this.selector=n,this.index=r}evalOnElement(e){let t=`(() => { const els = document.querySelectorAll(${JSON.stringify(this.selector)}); const el = els[${this.index}]; ${e} })()`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t])}async textContent(){return this.evalOnElement(`return el ? el.textContent : null;`)}async getAttribute(e){return this.evalOnElement(`return el ? el.getAttribute(${JSON.stringify(e)}) : null;`)}async isVisible(){return this.evalOnElement(`if (!el) return false; const s = getComputedStyle(el); if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0;`)}async boundingBox(){return this.evalOnElement(`if (!el) return null; const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height };`)}},Ki=class{rpc;targetId;onClose;constructor(e,t,n){this.rpc=e,this.targetId=t,this.onClose=n}async goto(e,t){await this.rpc.call(`browser`,`navigateTab`,[this.targetId,e])}async waitForLoadState(e){await this.rpc.call(`browser`,`waitForLoadState`,[this.targetId,e??`load`])}async evaluate(e,...t){let n=typeof e==`string`?e:`(${e.toString()}).apply(null, JSON.parse(${JSON.stringify(JSON.stringify(t))}))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,n])}async screenshot(e){let t={};e?.fullPage!==void 0&&(t.fullPage=e.fullPage);let n=Wi(await this.rpc.call(`browser`,`screenshotTab`,[this.targetId,t]));return e?.path&&await this.rpc.call(`vfs`,`writeFileBinary`,[e.path,n]),n}async $(e){return await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`!!document.querySelector(${JSON.stringify(e)})`])?new Gi(this.rpc,this.targetId,e,0):null}async $$(e){let t=await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.querySelectorAll(${JSON.stringify(e)}).length`]),n=[];for(let r=0;r<t;r++)n.push(new Gi(this.rpc,this.targetId,e,r));return n}async content(){return this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.documentElement.outerHTML`])}async setViewportSize(e){await this.rpc.call(`browser`,`setViewport`,[this.targetId,e.width,e.height])}async close(){await this.rpc.call(`browser`,`closeTab`,[this.targetId]),this.onClose?.(this.targetId)}},qi=class{rpc;pageTargetIds=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);return this.pageTargetIds.push(t),e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]),new Ki(this.rpc,t,e=>{let t=this.pageTargetIds.indexOf(e);t!==-1&&this.pageTargetIds.splice(t,1)})}async close(){let e=this.pageTargetIds.splice(0,this.pageTargetIds.length);for(let t of e)await this.rpc.call(`browser`,`closeTab`,[t])}};function Ji(e){let t=async t=>new qi(e);return{chromium:{launch:t},firefox:{launch:t},webkit:{launch:t}}}var Yi=class{port;nextId=1;pending=new Map;eventSubscribers=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{let t=e.data;if(t?.type===`realm-rpc-res`){let t=e.data,n=this.pending.get(t.id);if(!n)return;this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result);return}if(t?.type===`realm-event`){let t=e.data,n=this.eventSubscribers.get(t.channel);if(!n)return;for(let e of[...n])try{e(t.payload)}catch{}}},e.addEventListener(`message`,this.handler),e.start?.()}get pendingCount(){return this.pending.size}call(e,t,n=[]){if(this.disposed)return Promise.reject(Error(`realm-rpc: client disposed`));let r=this.nextId++,i={type:`realm-rpc-req`,id:r,channel:e,op:t,args:n};return new Promise((e,t)=>{this.pending.set(r,{resolve:e,reject:t}),this.port.postMessage(i)})}onEvent(e,t){if(this.disposed)return()=>{};let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{let n=this.eventSubscribers.get(e);n&&(n.delete(t),n.size===0&&this.eventSubscribers.delete(e))}}dispose(){if(this.disposed)return;this.disposed=!0,this.port.removeEventListener(`message`,this.handler);let e=Error(`realm-rpc: client disposed`);for(let t of this.pending.values())t.reject(e);this.pending.clear(),this.eventSubscribers.clear()}};const Xi=new Set([`bcrypt`,`better-sqlite3`,`canvas`,`cpu-features`,`fsevents`,`leveldown`,`libxmljs`,`libxmljs2`,`node-gyp-build`,`node-sass`,`puppeteer`,`robotjs`,`sass-embedded`,`sharp`,`snappy`,`sqlite3`,`tree-sitter`,`usb`]),Zi={sharp:` Use the built-in 'convert' shell command for image work.`,canvas:` Use the built-in 'convert' / OffscreenCanvas for image work.`,"better-sqlite3":` Use the built-in 'sqlite3' shell command (sql.js WASM).`,sqlite3:` Use the built-in 'sqlite3' shell command (sql.js WASM).`,bcrypt:` Use crypto.subtle.digest() with PBKDF2 / Argon2 in pure JS.`,puppeteer:` Use the built-in browser-automation shell commands.`};function Qi(e,t){let n=Zi[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${n}`)}function $i(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function ea(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function ta(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function na(e){let t=$i(e.argv[1]??``),n=ta(t,`references`),r=ta(t,`assets`),i=ta(t,`.config`);async function a(){let t;try{t=await e.fs.exists(i)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(i)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let a;try{a=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${i}: ${t}`)}if(a&&typeof a==`object`&&!Array.isArray(a))return a;throw Error(`skill.config(): ${i} must contain a JSON object`)}async function o(t){let n=await a();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(i,JSON.stringify(r,null,2)+`
43
43
  `),r}async function s(t){if(typeof t!=`string`||!t.trim())throw TypeError(`skill.token(providerId): providerId must be a non-empty string`);let n=`oauth-token ${ea(t)}`,{stdout:r,stderr:i,exitCode:a}=await e.exec(n);if(a!==0){let e=i.trim()||`oauth-token exited with code ${a}`;throw Error(`skill.token('${t}'): ${e}`)}return r.replace(/\r?\n+$/,``)}return Object.freeze({dir:t,refs:n,assets:r,config:o,token:s})}function $(e){if(!e||e===`/`)return`/`;e.startsWith(`/`)||(e=`/`+e);let t=e.split(`/`),n=[];for(let e of t)e===``||e===`.`||(e===`..`?n.pop():n.push(e));return`/`+n.join(`/`)}function ra(e){let t=$(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n===0?`/`:t.slice(0,n)}function ia(e){return Object.assign(Error(`ENOENT: no such file or directory, '${e}'`),{code:`ENOENT`})}function aa(e){return Object.assign(Error(`ENOSYNC: file too large for sync access, '${e}' — use async readFile() instead`),{code:`ENOSYNC`})}function oa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var sa=class{tree=new Map;initialPaths=new Set;initialContent=new Map;initialIsDirectory=new Map;mkdtempCounter=0;touched=!1;constructor(e){this.loadSnapshot(e)}loadSnapshot(e){this.tree=new Map,this.initialPaths=new Set,this.initialContent=new Map,this.initialIsDirectory=new Map,this.tree.set(`/`,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(`/`),this.initialIsDirectory.set(`/`,!0);for(let t of e.entries){let e=$(t.path);this.tree.set(e,{content:t.content,isDirectory:t.isDirectory,truncated:t.truncated}),this.initialPaths.add(e),this.initialIsDirectory.set(e,t.isDirectory),t.isDirectory||this.initialContent.set(e,t.content)}for(let t of e.entries){let e=ra($(t.path));for(;e!==`/`&&!this.tree.has(e);)this.tree.set(e,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(e),this.initialIsDirectory.set(e,!0),e=ra(e)}}wasUsed(){return this.touched}applySnapshot(e){this.loadSnapshot(e)}applySnapshotPreservingMutations(e){let t=this.getMutations();this.loadSnapshot(e);for(let e of t.deleted){if(this.tree.get(e)?.isDirectory){let t=e===`/`?`/`:e+`/`;for(let n of Array.from(this.tree.keys()))n!==e&&n.startsWith(t)&&this.tree.delete(n)}this.tree.delete(e)}for(let e of t.created)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:e.isDirectory});for(let e of t.modified)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:!1})}resetBaseline(){this.initialPaths=new Set,this.initialContent=new Map,this.initialIsDirectory=new Map;for(let[e,t]of this.tree.entries())this.initialPaths.add(e),this.initialIsDirectory.set(e,t.isDirectory),t.isDirectory||this.initialContent.set(e,t.content)}ensureParentDirs(e){let t=ra(e);t!==`/`&&(this.tree.has(t)||this.mkdir(t,!0))}readFile(e){this.touched=!0;let t=$(e),n=this.tree.get(t);if(!n||n.isDirectory)throw ia(t);if(n.truncated)throw aa(t);return n.content}writeFile(e,t){this.touched=!0;let n=$(e);this.ensureParentDirs(n),this.tree.set(n,{content:t,isDirectory:!1})}exists(e){this.touched=!0;let t=$(e);return this.tree.has(t)}stat(e){this.touched=!0;let t=$(e),n=this.tree.get(t);if(!n)throw ia(t);return{isFile:!n.isDirectory,isDirectory:n.isDirectory,size:n.isDirectory?0:n.content.byteLength}}readdir(e){this.touched=!0;let t=$(e);if(!this.tree.get(t)?.isDirectory)throw ia(t);let n=t===`/`?`/`:t+`/`,r=new Set;for(let e of this.tree.keys()){if(e===t||e===`/`||!e.startsWith(n))continue;let i=e.slice(n.length).split(`/`)[0];i&&r.add(i)}return Array.from(r)}mkdir(e,t){this.touched=!0;let n=$(e);if(this.tree.has(n)){if(this.tree.get(n).isDirectory)return;throw Object.assign(Error(`EEXIST: file already exists, '${n}'`),{code:`EEXIST`})}let r=ra(n);if(r!==`/`&&!this.tree.has(r)){if(!t)throw ia(n);this.mkdir(r,!0)}this.tree.set(n,{content:new Uint8Array,isDirectory:!0})}rm(e,t){this.touched=!0;let n=$(e),r=this.tree.get(n);if(!r)throw ia(n);if(r.isDirectory){let e=n===`/`?`/`:n+`/`,r=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));if(r.length>0&&!t)throw Object.assign(Error(`ENOTEMPTY: directory not empty, '${n}'`),{code:`ENOTEMPTY`});for(let e of r)this.tree.delete(e)}this.tree.delete(n)}copyFile(e,t){this.touched=!0;let n=$(e),r=this.tree.get(n);if(!r||r.isDirectory)throw ia(n);let i=$(t);this.ensureParentDirs(i),this.tree.set(i,{content:r.content.slice(),isDirectory:!1})}rename(e,t){this.touched=!0;let n=$(e),r=this.tree.get(n);if(!r)throw ia(n);let i=$(t);if(r.isDirectory){let e=n===`/`?`/`:n+`/`,t=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n);for(let e of t){let t=this.tree.get(e),r=i+e.slice(n.length);this.tree.set(r,t),this.tree.delete(e)}return}this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n)}unlink(e){this.touched=!0;let t=$(e),n=this.tree.get(t);if(!n)throw ia(t);if(n.isDirectory)throw Object.assign(Error(`EISDIR: illegal operation on a directory, unlink '${t}'`),{code:`EISDIR`});this.tree.delete(t)}mkdtemp(e){this.touched=!0;for(let t=0;t<100;t++){let t=`_${String(this.mkdtempCounter).padStart(6,`0`)}`;this.mkdtempCounter++;let n=$(e+t);if(!this.tree.has(n))return this.mkdir(n,!0),n}throw Error(`mkdtemp: failed to create unique directory after 100 attempts`)}getMutations(){let e=[],t=[],n=[];for(let[r,i]of this.tree.entries()){if(r===`/`)continue;if(!this.initialPaths.has(r)){e.push({path:r,content:i.content,isDirectory:i.isDirectory});continue}let a=this.initialIsDirectory.get(r);if(a!==void 0&&a!==i.isDirectory){n.push(r),e.push({path:r,content:i.content,isDirectory:i.isDirectory});continue}if(!i.isDirectory){let e=this.initialContent.get(r);e&&!oa(e,i.content)&&t.push({path:r,content:i.content})}}for(let e of this.initialPaths)e!==`/`&&(this.tree.has(e)||n.push(e));return{created:e,modified:t,deleted:n}}};function ca(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}var la=class extends Error{code;constructor(e){super(`Process exited with code ${e}`),this.code=e,this.name=`NodeExitError`}};function ua(e){if(typeof e==`string`)return e;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}async function da(e,t){let n;try{n=await e.call(`vfs`,`snapshot`,[t])}catch{n={entries:[]}}return new sa(n)}function fa(e){return{usbBridge:no(e),serialBridge:io(e),hidBridge:oo(e)}}async function pa(e,t){let n=[],r=[],i=e=>{n.push(typeof e==`string`?e:String(e))},a=e=>{r.push(typeof e==`string`?e:String(e))},o=ga(i,a),{processShim:s,getDidCallProcessExit:c}=_a(e,i,a),l=!!e.env?.NO_COLOR,u=lr({isTTY:!l,noColor:l}),d=sr({writeStdout:i,writeStderr:a,exit:e=>{throw new la(e)},color:u}),f=new Yi(t),p=Ta(f,w),h=await da(f,e.cwd);Object.assign(p,Ea(h,e.cwd));let g=ya(f,h,e.cwd),_=Sa(g,{cwd:e.cwd}),v=na({argv:e.argv,fs:p,exec:g}),y=Ba(f),{usbBridge:b,serialBridge:x,hidBridge:S}=fa(f),C=m({fetch:w});async function w(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e),r=await f.call(`fetch`,`request`,[n,za(t,e)]),i=r.body.byteLength===0?null:r.body.buffer.slice(r.body.byteOffset,r.body.byteOffset+r.body.byteLength),a=new Response(i,{status:r.status,statusText:r.statusText,headers:r.headers});return Object.defineProperty(a,"url",{value:r.url||n}),a}let T=Ca({exec:g,agent:_,skill:v,http:C,browser:y,usb:b,serial:x,hid:S,cli:d,color:u}),E=e.filename,D=ca(E),O=await ka(f,e.code,e.cwd,E),k=Ma({graph:O,fsBridge:p,processShim:s,childProcess:Vi(g),nodeConsole:o,sliccyModules:T,shimmedPackages:ja(f)}).require,A={exports:{},filename:e.filename},j=O.entrySource!==void 0,ee=O.entrySource??e.code,M=globalThis;M.__slicc_compileWasm=e=>f.call(`wasm`,`compile`,[e]);let te=await Ra(ee,{process:s,console:o,require:k,module:A,exports:A.exports,fetch:w,__dirname:D,__filename:E},a,j);await ma(f,h,a),c()||await ha(f),delete M.__slicc_compileWasm,f.dispose(),t.postMessage({type:`realm-done`,stdout:n.join(``),stderr:r.join(``),exitCode:te})}async function ma(e,t,n){let r=t.getMutations();if(r.created.length||r.modified.length||r.deleted.length)try{await e.call(`vfs`,`flushWrites`,[r])}catch(e){n(`[sync-fs] flush failed: ${e instanceof Error?e.message:String(e)}\n`)}}async function ha(e){let t=Date.now()+1e3,n=0;do await new Promise(e=>setTimeout(e,0)),n++;while(e.pendingCount>0&&n<50&&Date.now()<t)}function ga(e,t){return{log:(...t)=>e(`${t.map(ua).join(` `)}
44
44
  `),info:(...t)=>e(`${t.map(ua).join(` `)}
45
45
  `),warn:(...e)=>t(`${e.map(ua).join(` `)}