sliccy 6.135.4 → 6.136.1

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 (96) hide show
  1. package/dist/ui/.vite/manifest.json +140 -139
  2. package/dist/ui/assets/{SKILL-CLNwFz3P.js → SKILL-Dkk5iZlJ.js} +1 -1
  3. package/dist/ui/assets/{account-store-DB2oZS70.js → account-store-BzCpAbzU.js} +1 -1
  4. package/dist/ui/assets/{account-store-BsMvCC37.js → account-store-IBc-Swl2.js} +1 -1
  5. package/dist/ui/assets/{adobe-rxfG4yj9.js → adobe-BlUDEEVT.js} +1 -1
  6. package/dist/ui/assets/{adobe-B437LgG3.js → adobe-xtVVXp2q.js} +1 -1
  7. package/dist/ui/assets/{agent-bridge-pHw1j9qj.js → agent-bridge-Bgb7xaDh.js} +1 -1
  8. package/dist/ui/assets/{apply-layout-D5Ypbc6D.js → apply-layout-l78p8Bos.js} +1 -1
  9. package/dist/ui/assets/{apps-DT4Fwxx1.js → apps-DDo9wnih.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-CCd_M_WS.js → azure-openai-CRb9ZtBO.js} +2 -2
  11. package/dist/ui/assets/{azure-openai-E8vIVvVG.js → azure-openai-zWPF524s.js} +1 -1
  12. package/dist/ui/assets/{cdp-0LZ0nstT.js → cdp-DKhmYptD.js} +1 -1
  13. package/dist/ui/assets/{cerebras-EOmAJ59C.js → cerebras-COu_QlOd.js} +1 -1
  14. package/dist/ui/assets/{cerebras-C3WC-BhF.js → cerebras-DtLUDEbM.js} +1 -1
  15. package/dist/ui/assets/{connect-surface-C2xUF4cH.js → connect-surface-B4G8l--y.js} +1 -1
  16. package/dist/ui/assets/{dip-DjZvvl_D.js → dip-DySyh98z.js} +4 -4
  17. package/dist/ui/assets/{directed-approval-BkPuNNcH.js → directed-approval-CZK0YFwX.js} +1 -1
  18. package/dist/ui/assets/{fs-C--wKCDU.js → fs-BXsWV91k.js} +2 -2
  19. package/dist/ui/assets/fs-D5rn9Yg2.js +1 -0
  20. package/dist/ui/assets/github-CJd5WOrc.js +1 -0
  21. package/dist/ui/assets/{github-C88Uo8-d.js → github-DzUDXVwm.js} +2 -2
  22. package/dist/ui/assets/{github-copilot-mvnnOUoz.js → github-copilot-CPDNi2pJ.js} +1 -1
  23. package/dist/ui/assets/{github-copilot-D9KXM2BW.js → github-copilot-OMKzjJ2o.js} +1 -1
  24. package/dist/ui/assets/{github-install-DMlFqTOg.js → github-install-DY3uazWz.js} +1 -1
  25. package/dist/ui/assets/{github-zip-BgcBpqoF.js → github-zip-BGeyA2Li.js} +1 -1
  26. package/dist/ui/assets/{help-ByiTHJKX.js → help-CjuK8HDa.js} +1 -1
  27. package/dist/ui/assets/js-realm-worker-Ca9s6UEK.js +51 -0
  28. package/dist/ui/assets/{kernel-worker-eUytAV7E.js → kernel-worker-CC7asGg9.js} +482 -482
  29. package/dist/ui/assets/{local-llm-Chsflh7y.js → local-llm-C4lmoelF.js} +1 -1
  30. package/dist/ui/assets/{local-llm-xGIskTcr.js → local-llm-DZ9jctP2.js} +1 -1
  31. package/dist/ui/assets/{main-DfPJYwPb.js → main-CcfFeq6P.js} +3 -3
  32. package/dist/ui/assets/{main-cherry-BRvnemBM.js → main-cherry-Ibu56rin.js} +1 -1
  33. package/dist/ui/assets/{mount-C9vCIIl4.js → mount-DbUK_ouC.js} +3 -3
  34. package/dist/ui/assets/{mount-recovery-BWcmygRH.js → mount-recovery-Dzskgqa7.js} +1 -1
  35. package/dist/ui/assets/{mount-VGhtmdQd.js → mount-vbEbpo4N.js} +1 -1
  36. package/dist/ui/assets/{new-session-wIxUVJgm.js → new-session-BscrQvQH.js} +2 -2
  37. package/dist/ui/assets/{oauth-bootstrap-DJVc7bTA.js → oauth-bootstrap-CCnmEqBW.js} +2 -2
  38. package/dist/ui/assets/{openai-codex-BXBL_bO-.js → openai-codex-B-7bpkdM.js} +1 -1
  39. package/dist/ui/assets/{openai-codex-BSACORJ5.js → openai-codex-BO7ubdvf.js} +1 -1
  40. package/dist/ui/assets/{openrouter-D7_ajh7G.js → openrouter-C2yH1Eg2.js} +1 -1
  41. package/dist/ui/assets/{openrouter-BEwOzhw5.js → openrouter-c4UnAH0g.js} +1 -1
  42. package/dist/ui/assets/{openrouter-oauth-Bz1ngFXu.js → openrouter-oauth-DOOgBCk9.js} +1 -1
  43. package/dist/ui/assets/{openrouter-oauth-BUsmms-T.js → openrouter-oauth-SIQYiorE.js} +1 -1
  44. package/dist/ui/assets/{panel-rpc-handlers-DzjXHY5p.js → panel-rpc-handlers-DAdmCiAM.js} +2 -2
  45. package/dist/ui/assets/{provider-DJraYgih.js → provider-DHmZizbV.js} +1 -1
  46. package/dist/ui/assets/{provider-D_pr8tql.js → provider-DSOEMASd.js} +2 -2
  47. package/dist/ui/assets/provider-settings-BS8lFD1q.js +1 -0
  48. package/dist/ui/assets/{provider-settings-TF5REgnM.js → provider-settings-CGwq2ZSe.js} +1 -1
  49. package/dist/ui/assets/{provider-store-access-B0S6bKh3.js → provider-store-access-CMRf7M8N.js} +2 -2
  50. package/dist/ui/assets/provider-store-access-CVOw7bhE.js +1 -0
  51. package/dist/ui/assets/{providers-CMjEAZHS.js → providers-DEZ_uN7Q.js} +2 -2
  52. package/dist/ui/assets/{providers-DjJtAUeo.js → providers-DfgkYKp3.js} +1 -1
  53. package/dist/ui/assets/{quick-llm-qbsQP3cQ.js → quick-llm-CTm8kfpN.js} +1 -1
  54. package/dist/ui/assets/{recovery-screen-D7TaTQRL.js → recovery-screen-D7czDrGy.js} +1 -1
  55. package/dist/ui/assets/{run-DQIxH6Gz.js → run-BbwmmE0l.js} +1 -1
  56. package/dist/ui/assets/{run-CoLgAoL0.js → run-CMPmBjRA.js} +1 -1
  57. package/dist/ui/assets/{run-CW8MuQ_R.js → run-kHiTfPA_.js} +2 -2
  58. package/dist/ui/assets/{session-freezer-Dk3ak7tg.js → session-freezer-C7H1VByB.js} +3 -3
  59. package/dist/ui/assets/{setup-feature-flags-remote-BMYYBmhp.js → setup-feature-flags-remote-J95n02lO.js} +1 -1
  60. package/dist/ui/assets/{setup-standalone-prelude-CgvlSbx3.js → setup-standalone-prelude-L6dqa7or.js} +2 -2
  61. package/dist/ui/assets/{setup-sudo-BnO7N96i.js → setup-sudo-DXCFEDCh.js} +2 -2
  62. package/dist/ui/assets/{skills-Cj_hq0v6.js → skills-DLlIa_OZ.js} +1 -1
  63. package/dist/ui/assets/slicc-version-C8iZhVsg.js +1 -0
  64. package/dist/ui/assets/{snapshot-CvzMbnTT.js → snapshot-BWdwScwG.js} +1 -1
  65. package/dist/ui/assets/{snapshot-features-CdZegAkf.js → snapshot-features-CHwnS5pR.js} +1 -1
  66. package/dist/ui/assets/sprinkle-bridge-CeRz-DjR.js +2 -0
  67. package/dist/ui/assets/{sprinkle-manager-CtUCzppZ.js → sprinkle-manager-jHNM2oxy.js} +1 -1
  68. package/dist/ui/assets/{sprinkle-renderer-DJyQFvKt.js → sprinkle-renderer-Ce6YjEek.js} +72 -13
  69. package/dist/ui/assets/{state-BhdJ8PNE.js → state-BaXCc20k.js} +1 -1
  70. package/dist/ui/assets/{store-DJO-poBl.js → store-BDD3IHgP.js} +1 -1
  71. package/dist/ui/assets/{store-AEicwNpr.js → store-Ca4Dnbdu.js} +1 -1
  72. package/dist/ui/assets/{sudo-DpwodOie.js → sudo-CA0RFOLj.js} +1 -1
  73. package/dist/ui/assets/{upgrade-detection-BMzQvRz7.js → upgrade-detection-C145Khtm.js} +1 -1
  74. package/dist/ui/assets/{wc-extension-kJGIPZHt.js → wc-extension-Bi0TRT8Q.js} +2 -2
  75. package/dist/ui/assets/{wc-follower-vZo_LDlH.js → wc-follower-Bo_J3jq5.js} +3 -3
  76. package/dist/ui/assets/{wc-follower-oauth-ClOA_w6r.js → wc-follower-oauth-DCz20htV.js} +1 -1
  77. package/dist/ui/assets/{wc-live-6eWgRCar.js → wc-live-NRwfoCVf.js} +3 -3
  78. package/dist/ui/assets/{wc-nav-BQZlGn7o.js → wc-nav-DrHMR3BW.js} +2 -2
  79. package/dist/ui/assets/{wc-onboarding-D8PKDTEv.js → wc-onboarding-De4Igl1i.js} +2 -2
  80. package/dist/ui/assets/{wc-placeholder-DmUJ9hms.js → wc-placeholder-DPzXeItf.js} +2 -2
  81. package/dist/ui/assets/{wc-settings-NF_5qb5I.js → wc-settings-CVX_pOD-.js} +2 -2
  82. package/dist/ui/assets/{wc-shell-BQOMI3mp.js → wc-shell-DgmtA7sH.js} +2 -2
  83. package/dist/ui/assets/{wc-sprinkles-C3zuciBq.js → wc-sprinkles-FfifZkuL.js} +2 -2
  84. package/dist/ui/assets/{wc-tray-CZuEUn2F.js → wc-tray-DJF61Czu.js} +4 -4
  85. package/dist/ui/assets/{xai-grok-Ds1uYtNW.js → xai-grok-9c2GZFuB.js} +1 -1
  86. package/dist/ui/assets/{xai-grok-geWlI5px.js → xai-grok-DrI5c3BY.js} +1 -1
  87. package/dist/ui/index.html +6 -6
  88. package/dist/ui/packages/webapp/index.html +6 -6
  89. package/package.json +1 -1
  90. package/dist/ui/assets/fs-BuQbCfx0.js +0 -1
  91. package/dist/ui/assets/github-6HYQf4Kr.js +0 -1
  92. package/dist/ui/assets/js-realm-worker-BnCzFc2s.js +0 -51
  93. package/dist/ui/assets/provider-settings-C5lbBYtm.js +0 -1
  94. package/dist/ui/assets/provider-store-access-DR49Nq-F.js +0 -1
  95. package/dist/ui/assets/slicc-version-B0QcPqhs.js +0 -1
  96. package/dist/ui/assets/sprinkle-bridge-B8DKuaxn.js +0 -2
@@ -1,4 +1,4 @@
1
- import{a as e,s as t}from"./account-store-BsMvCC37.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-4WTk3EBD.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,t as o}from"./transform-messages-Jn8bw4-u.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e);let S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De;const Oe=65536;var ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
1
+ import{c as e,o as t}from"./account-store-IBc-Swl2.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-4WTk3EBD.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,t as o}from"./transform-messages-Jn8bw4-u.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e);let S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De;const Oe=65536;var ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Ee=new WeakMap,Te=new WeakSet,De=function(e){if(c(this,D,`f`)+e.length>c(this,T,`f`).length){let t=c(this,D,`f`)-c(this,E,`f`);if(c(this,E,`f`)>=c(this,T,`f`).length/2&&t+e.length<=c(this,T,`f`).length)c(this,T,`f`).copyWithin(0,c(this,E,`f`),c(this,D,`f`));else{let n=Math.max(c(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,r,`f`)}s(this,O,c(this,O,`f`)-c(this,E,`f`),`f`),s(this,D,t,`f`),s(this,E,0,`f`)}c(this,T,`f`).set(e,c(this,D,`f`)),s(this,D,c(this,D,`f`)+e.length,`f`)},ke.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),ke.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ae(e,t,n){for(let r=t;r<n;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function je(e){for(let t=0;t<e.length-1;t++){let n=Me(e,t);if(n>0){let r=t+n,i=Me(e,r);if(i>0)return r+i}}return-1}function Me(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}const Ne={off:0,error:200,warn:300,info:400,debug:500},Pe=(e,t,n)=>{if(e){if(pe(Ne,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ne))}`)}};function Fe(){}function Ie(e,t,n){return!t||Ne[e]>Ne[n]?Fe:t[e].bind(t)}const Le={error:Fe,warn:Fe,info:Fe,debug:Fe};let Re=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Le;let r=Re.get(t);if(r&&r[0]===n)return r[1];let i={error:Ie(`error`,t,n),warn:Ie(`warn`,t,n),info:Ie(`info`,t,n),debug:Ie(`debug`,t,n)};return Re.set(t,[n,i]),i}const ze=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var Be,Ve=class e{constructor(e,t,n){Be.set(this,void 0),this.iterator=e,this.controller=t,s(this,Be,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1,r=!1;try{for await(let e of He(t,n)){if(e.data.startsWith(`[DONE]`)){r=!0;break}if(e.event===null||!e.event.startsWith(`thread.`)){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&n.error)throw new p(void 0,n.error,void 0,t.headers);yield i?{event:e.event,data:n}:n}else{let t;try{t=JSON.parse(e.data)}catch(t){throw console.error(`Could not parse message into JSON:`,e.data),console.error(`From chunk:`,e.raw),t}if(e.event===`error`)throw new p(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||u(e)||n.signal.aborted&&e===n.signal.reason)return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ke,r=t.getReader(),i=!1,a,o=()=>{a??=r.cancel(),a.catch(()=>void 0)};n.signal.addEventListener(`abort`,o,{once:!0});try{if(n.signal.aborted){o();return}for(;;){let{value:t,done:a}=await r.read();if(a){i=!0;break}if(n.signal.aborted)return;for(let r of e.decode(t)){if(n.signal.aborted)return;yield r}}if(n.signal.aborted)return;for(let t of e.flush()){if(n.signal.aborted)return;yield t}}finally{n.signal.removeEventListener(`abort`,o),i||o(),r.releaseLock()}}async function*o(){if(i)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(n.signal.aborted||u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Be=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,c(this,Be,`f`)),new e(()=>i(n),this.controller,c(this,Be,`f`))]}toReadableStream(){let e;return ve({start:async()=>{e=this[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=w(JSON.stringify(n)+`
4
4
  `);t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}};async function*He(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new f(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new f(`Attempted to iterate over a response with no body`);let n=new We,r=new ke,i=be(e.body);for await(let e of Ue(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Ue(e){let t=new Uint8Array,n=0,r=0,i=0;for await(let a of e){if(a==null)continue;let e;if(e=a instanceof ArrayBuffer?new Uint8Array(a):typeof a==`string`?w(a):a,r+e.length>t.length){let a=r-n;if(n>=t.length/2&&a+e.length<=t.length)t.copyWithin(0,n,r);else{let i=new Uint8Array(Math.max(t.length*2,a+e.length));i.set(t.subarray(n,r)),t=i}i-=n,n=0,r=a}t.set(e,r),r+=e.length;let o;for(;(o=je(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-3)}r>n&&(yield t.slice(n,r))}var We=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.slice(0,-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -15,4 +15,4 @@ new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
15
15
 
16
16
  https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
17
17
  `);this.baseURL=p.baseURL,this.timeout=p.timeout??ps.DEFAULT_TIMEOUT,this.logger=p.logger??console;let m=`warn`;this.logLevel=m,this.logLevel=Pe(p.logLevel,`ClientOptions.logLevel`,this)??Pe(W(`OPENAI_LOG`),`process.env['OPENAI_LOG']`,this)??m,this.fetchOptions=p.fetchOptions,this.maxRetries=p.maxRetries??2,this.fetch=p.fetch??_e(),s(this,ms,it,`f`);let h=t?void 0:W(`OPENAI_CUSTOM_HEADERS`);if(h){let e={};for(let t of h.split(`
18
- `)){let n=t.indexOf(`:`);n>=0&&(e[t.substring(0,n).trim()]=t.substring(n+1).trim())}p.defaultHeaders=N([e,p.defaultHeaders])}this._options=p,this._provider=d,l&&(this._workloadIdentityAuth=new Mt(l,this.fetch)),this.apiKey=typeof r==`string`?r:null,this.adminAPIKey=i,this.organization=a,this.project=o,this.webhookSecret=c}withOptions(e){let t=this._options.provider,n=e.provider??t,r={...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret};return n&&(delete r.apiKey,delete r.adminAPIKey,delete r.workloadIdentity,delete r.baseURL,n!==t&&(delete r.organization,delete r.project,delete r.defaultHeaders)),new this.constructor({...r,...e,provider:n})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t},n={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(e.get(`authorization`)||e.get(`api-key`))&&!(t.has(`authorization`)||t.has(`api-key`))&&!(this._workloadIdentityAuth&&n.bearerAuth))throw Error(`Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted`)}async authHeaders(e,t={bearerAuth:!0,adminAPIKeyAuth:!0}){return N([t.bearerAuth?await this.bearerAuth(e):null,t.adminAPIKeyAuth?await this.adminAPIKeyAuth(e):null])}async bearerAuth(e){if(this._workloadIdentityAuth)return N([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey!=null)return N([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(e){if(this.adminAPIKey!=null)return N([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(e){return Ct(e)}getUserAgent(){return`${this.constructor.name}/JS ${Ye}`}defaultIdempotencyKey(){return`stainless-node-retry-${l()}`}makeStatusError(e,t,n,r){let i=t&&typeof t==`object`&&t.error==null?{error:t}:t;return p.generate(e,i,n,r)}async _callApiKey(){if(this._provider)return!1;let e=this._options.apiKey;if(typeof e!=`function`)return!1;let t;try{t=await e()}catch(e){throw e instanceof f?e:new f(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if(typeof t!=`string`||!t)throw new f(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){let r=!c(this,fs,`m`,gs).call(this)&&n||this.baseURL,i=le(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!fe(a)||!fe(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){this._provider||(e.__security??{bearerAuth:!0}).bearerAuth&&await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return this.responsePromise(this.makeRequest(e,t,void 0))}responsePromise(e,t=(e,t)=>this.parseResponseWithTimeout(e,t)){let n=new Tt(this,e,t);return n.withResponse=async()=>{let t=await n,{response:r}=await e;return{data:t,response:r,request_id:r.headers.get(`x-request-id`)}},n._thenUnwrap=n=>this.responsePromise(e,async(e,r)=>Je(n(await t(e,r),r),r.response)),n}async parseResponseWithTimeout(e,t){if(t.options.stream||t.options.__binaryResponse||t.response.status===204||t.response.headers.get(`content-length`)===`0`)return Ke(e,t);for(;;){let n=c(this,hs,`f`).get(t.controller),r=n?.timeout??t.options.timeout??this.timeout,i=Math.max(0,t.startTime+r-Date.now()),a=t.options.signal,o,s,l=!1;try{if(a?.aborted&&t.options.__metadata?.helperMethod!==`runTools`)throw new m;let n=new Promise((e,n)=>{o=setTimeout(()=>{l=!0,t.controller.abort(),n(new g)},i),a&&(s=()=>n(new m),a.addEventListener(`abort`,s,{once:!0}))});return await Promise.race([Ke(e,t),n])}catch(e){if(a?.aborted)throw new m;if(!l)throw e;let r=n?.retriesRemaining??0;if(!r||t.options.__metadata?.hasStreamingBody||globalThis.ReadableStream&&t.options.body instanceof globalThis.ReadableStream||typeof t.options.body==`object`&&t.options.body!==null&&(Symbol.asyncIterator in t.options.body||Symbol.iterator in t.options.body&&`next`in t.options.body&&typeof t.options.body.next==`function`))throw new g;o!==void 0&&clearTimeout(o),s&&a?.removeEventListener(`abort`,s),s=void 0;let i=await this.retryRequest(t.options,r,t.retryOfRequestLogID??t.requestLogID);Object.assign(t,i)}finally{o!==void 0&&clearTimeout(o),s&&a?.removeEventListener(`abort`,s)}}}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t}),l=r.__metadata?.hasStreamingBody===!0;await this.prepareRequest(a,{url:o,options:r}),await this._provider?.prepareRequest?.(a,{url:o,options:r});let f=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),p=n===void 0?``:`, retryOf: ${n}`,m=Date.now();if(k(this).debug(`[${f}] sending request`,ze({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted||a.signal?.aborted)throw this._makeUserAbortError(r.signal?.aborted?r.signal:a.signal);let _=r.__security??{bearerAuth:!0},v=this.fetchWithTimeout===ps.prototype.fetchWithTimeout?ys(a.signal):new AbortController,y=await this.fetchWithAuth(o,a,s,v,_).catch(d),b=Date.now();if(y instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted||a.signal?.aborted)throw this._makeUserAbortError(r.signal?.aborted?r.signal:a.signal);let i=u(y)||/timed? ?out/i.test(String(y)+(`cause`in y?String(y.cause):``));if(t&&!l)return k(this).info(`[${f}] connection ${i?`timed out`:`failed`} - ${e}`),k(this).debug(`[${f}] connection ${i?`timed out`:`failed`} (${e})`,ze({retryOfRequestLogID:n,url:o,durationMs:b-m,message:y.message})),this.retryRequest(r,t,n??f);let s=l?`error; streaming body cannot be retried`:`error; no more retries left`;if(k(this).info(`[${f}] connection ${i?`timed out`:`failed`} - ${s}`),k(this).debug(`[${f}] connection ${i?`timed out`:`failed`} (${s})`,ze({retryOfRequestLogID:n,url:o,durationMs:b-m,message:y.message})),y instanceof oe||y instanceof se)throw y;if(i){let e=`cause`in y?y.cause:void 0,t=typeof e==`object`&&e&&`code`in e&&e.code===`UND_ERR_HEADERS_TIMEOUT`?new g({message:`Request timed out. Node.js fetch timed out waiting for response headers; configure a matching undici fetch and fetchOptions.dispatcher with an Agent whose headersTimeout is at least the SDK timeout.`}):new g;throw Object.assign(t,{cause:y})}throw new h({message:bs(y),cause:y})}let x=`[${f}${p}${[...y.headers.entries()].filter(([e])=>e===`x-request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${y.ok?`succeeded`:`failed`} with status ${y.status} in ${b-m}ms`;if(!y.ok){if(y.status===401&&this._workloadIdentityAuth&&_.bearerAuth&&!r.__metadata?.hasStreamingBody&&!r.__metadata?.workloadIdentityTokenRefreshed)return await xe(y.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...r,__metadata:{...r.__metadata,workloadIdentityTokenRefreshed:!0}},t,n??f);let e=await this.shouldRetry(y);if(t&&e&&!l){let e=`retrying, ${t} attempts remaining`;return await xe(y.body),k(this).info(`${x} - ${e}`),k(this).debug(`[${f}] response error (${e})`,ze({retryOfRequestLogID:n,url:y.url,status:y.status,headers:y.headers,durationMs:b-m})),this.retryRequest(r,t,n??f,y.headers)}let i=e?l?`error; streaming body cannot be retried`:`error; no more retries left`:`error; not retryable`;k(this).info(`${x} - ${i}`);let a=await y.text().catch(e=>d(e).message),o=he(a),s=o?void 0:a;throw k(this).debug(`[${f}] response error (${i})`,ze({retryOfRequestLogID:n,url:y.url,status:y.status,headers:y.headers,message:s,durationMs:Date.now()-m})),this.makeStatusError(y.status,o,s,y.headers)}return k(this).info(x),k(this).debug(`[${f}] response start`,ze({retryOfRequestLogID:n,url:y.url,status:y.status,headers:y.headers,durationMs:b-m})),c(this,hs,`f`).set(v,{timeout:s,retriesRemaining:t}),{response:y,options:r,controller:v,requestLogID:f,retryOfRequestLogID:n,startTime:m}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0),r=new Ot(this,n,e),i=this.responsePromise(n,async(t,n)=>{let r=await this.parseResponseWithTimeout(t,n);return new e(t,n.response,r,n.options)});return r.then=i.then.bind(i),r.catch=i.catch.bind(i),r.finally=i.finally.bind(i),r.withResponse=i.withResponse.bind(i),r._thenUnwrap=i._thenUnwrap.bind(i),r}async fetchWithAuth(e,t,n,r,i={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&i.bearerAuth){let e=t.headers,n=e.get(`Authorization`);if(!n||n===`Bearer workload-identity-auth`){let t=await this._workloadIdentityAuth.getToken();e.set(`Authorization`,`Bearer ${t}`)}}return await this.fetchWithTimeout(e,t,n,r)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r),c=!!i&&vs.get(r)===i;i&&!c&&i.addEventListener(`abort`,s,{once:!0});let l=setTimeout(s,n),u=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,d={signal:r.signal,...u?{duplex:`half`}:{},method:`GET`,...o};a&&(d.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,d)}catch(e){throw i&&!c&&i.removeEventListener(`abort`,s),e}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&i===void 0){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0||!Number.isFinite(i)||i<0||i>6e4){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await ge(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&me(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l,isStreamingBody:u}=this.buildBody({options:n});return u&&(e.__metadata={...e.__metadata,hasStreamingBody:!0}),{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=e.__metadata?.helperMethod,o=N([i,{Accept:`application/json`,..._s()?void 0:{"User-Agent":this.getUserAgent()},"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...rt(),...typeof a==`string`?{"X-Stainless-Helper-Method":a}:{},"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},this._provider?void 0:await this.authHeaders(e,e.__security??{bearerAuth:!0}),this._options.defaultHeaders,n,e.headers]);return this._provider||this.validateHeaders(o,e.__security??{bearerAuth:!0}),o.values}_makeAbort(e){return()=>e.abort()}_makeUserAbortError(e){let t=new m;return Object.defineProperty(t,"cause",{value:e.reason,writable:!0,configurable:!0}),t}buildBody({options:e}){let{body:t,headers:n}=e;if(!t)return t===void 0&&`body`in e?{...c(this,ms,`f`).call(this,{body:t,headers:N([n])}),isStreamingBody:!1}:{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let r=N([n]),i=globalThis.ReadableStream!==void 0&&t instanceof globalThis.ReadableStream,a=!i&&(typeof t==`string`||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||globalThis.Blob!==void 0&&t instanceof globalThis.Blob||t instanceof URLSearchParams||t instanceof FormData);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t==`string`&&r.values.has(`content-type`)||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||i?{bodyHeaders:void 0,body:t,isStreamingBody:!a}:typeof t==`object`&&(Symbol.asyncIterator in t||Symbol.iterator in t&&`next`in t&&typeof t.next==`function`)?{bodyHeaders:void 0,body:ye(t),isStreamingBody:!0}:typeof t==`object`&&r.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(t),isStreamingBody:!1}:{...c(this,ms,`f`).call(this,{body:t,headers:r}),isStreamingBody:!1}}};ps=$,ms=new WeakMap,hs=new WeakMap,fs=new WeakSet,gs=function(){return this._provider!==void 0||this.baseURL!==`https://api.openai.com/v1`},$.OpenAI=ps,$.DEFAULT_TIMEOUT=6e5,$.OpenAIError=f,$.APIError=p,$.APIConnectionError=h,$.APIConnectionTimeoutError=g,$.APIUserAbortError=m,$.NotFoundError=b,$.ConflictError=x,$.RateLimitError=te,$.BadRequestError=_,$.AuthenticationError=v,$.InternalServerError=ne,$.PermissionDeniedError=y,$.UnprocessableEntityError=ee,$.InvalidWebhookSignatureError=ae,$.toFile=_n,$.toStreamingFile=Lt,$.Completions=Sa,$.Chat=Rr,$.Embeddings=ka,$.Files=Na,$.Images=Wa,$.ContentProvenanceChecks=Ea,$.Audio=vi,$.Moderations=Ka,$.Models=Ga,$.FineTuning=Va,$.Graders=Ua,$.VectorStores=ts,$.Webhooks=os,$.Beta=xa,$.Batches=yi,$.Uploads=Zo,$.Admin=mi,$.Responses=Go,$.Realtime=Ya,$.Conversations=Oa,$.Evals=Ma,$.Containers=Ta,$.Skills=Yo,$.Videos=ns;const vs=new WeakMap;function ys(e){let t=new AbortController;if(!e)return t;let n=globalThis.AbortSignal;if(typeof n?.any!=`function`||!(e instanceof n))return t;try{let r=n.any([t.signal,e]);Object.defineProperty(t,"signal",{value:r,configurable:!0}),vs.set(t,e)}catch{}return t}function bs(e){if(xs(e))return`Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });`}function xs(e){let t=e;for(let e=0;e<8&&t&&typeof t==`object`;e++){let e=t;if(e.code===`UND_ERR_INVALID_ARG`&&typeof e.message==`string`&&e.message.includes(`invalid onRequestStart method`))return!0;t=e.cause}return!1}var Ss=class extends ${constructor({baseURL:e=W(`OPENAI_BASE_URL`),apiKey:t=W(`AZURE_OPENAI_API_KEY`),apiVersion:n=W(`OPENAI_API_VERSION`),endpoint:r,deployment:i,azureADTokenProvider:a,dangerouslyAllowBrowser:o,...s}={}){if(!n)throw new f(`The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).`);if(typeof a==`function`&&(o??=!0),!a&&!t)throw new f("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(a&&t)throw new f("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(s.defaultQuery={...s.defaultQuery,"api-version":n},!e){if(r||={}.AZURE_OPENAI_ENDPOINT,!r)throw new f("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");let t=r.length;for(;t>0&&r[t-1]===`/`;)t--;e=`${r.slice(0,t)}/openai`}else if(r)throw new f(`baseURL and endpoint are mutually exclusive`);super({apiKey:a??t,baseURL:e,...s,...o===void 0?{}:{dangerouslyAllowBrowser:o}}),this.apiVersion=``,this.apiVersion=n,this.deploymentName=i}async buildRequest(e,t={}){if(Cs.has(e.path)&&e.method===`post`&&e.body!==void 0){if(!C(e.body))throw Error(`Expected request body to be an object`);let t=this.deploymentName||e.body.model||e.__metadata?.model;t!==void 0&&!this.baseURL.includes(`/deployments`)&&(e.path=I`/deployments/${t}`+e.path)}let n=await super.buildRequest(e,t);return n.req.headers.has(`api-key`)&&(n.req.redirect=`manual`),n}async fetchWithAuth(e,t,n,r,i){return new Headers(t.headers).has(`api-key`)&&(t.redirect=`manual`),super.fetchWithAuth(e,t,n,r,i)}async authHeaders(e,t){let n=t??{bearerAuth:!0,adminAPIKeyAuth:!0};return n.bearerAuth&&typeof this._options.apiKey==`string`?N([{"api-key":this.apiKey}]):super.authHeaders(e,n)}};const Cs=new Set([`/completions`,`/chat/completions`,`/embeddings`,`/audio/transcriptions`,`/audio/translations`,`/audio/speech`,`/images/generations`,`/batches`,`/images/edits`]),ws=`azure-openai`,Ts=`2024-12-01-preview`,Es={id:ws,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:Ts,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=t(ws);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function Ds(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Os(e,t){let n=o(e.messages,t,Ds),r=[];for(let e of n)if(e.role===`user`){if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function ks(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function As(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function js(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}function Ms(e){return{role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:ws,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:`stop`,timestamp:Date.now()}}function Ns(t,n){let r=n.apiKey;if(!r)throw Error(`Azure API key is required`);let i=t.baseUrl;if(!i)throw Error(`Azure endpoint is required`);let a={};t.headers&&Object.assign(a,t.headers),n.headers&&Object.assign(a,n.headers);let o=e(ws)||Ts,s=t.id;return{client:new Ss({endpoint:i.replace(/\/+$/,``),apiKey:r,deployment:s,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:a}),deployment:s}}function Ps(e,t){return[...e.systemPrompt?[{role:`system`,content:e.systemPrompt}]:[],...Os(e,t)]}function Fs(e,t,n){n&&(e.usage.input=n.prompt_tokens??0,e.usage.output=n.completion_tokens??0,e.usage.totalTokens=n.total_tokens??0,r(t,e.usage))}function Is(e){return e===`tool_calls`?`toolUse`:e===`length`?`length`:`stop`}function Ls(e,t,n){let{block:r,index:i}=As(t);r.text===``&&e.push({type:`text_start`,contentIndex:i,partial:t}),r.text+=n,e.push({type:`text_delta`,contentIndex:i,delta:n,partial:t})}function Rs(e,t,n){let r=n.id?js(t,n.id):void 0;if(r||!n.id)return r;let i={type:`toolCall`,id:n.id,name:n.function?.name??``,arguments:{},_partialJson:``};return t.content.push(i),e.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}),i}function zs(e,t,n,r){n._partialJson+=r;try{n.arguments=JSON.parse(n._partialJson)}catch{}e.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:r,partial:t})}function Bs(e,t,n){for(let r of n){let n=Rs(e,t,r);n&&r.function?.arguments&&zs(e,t,n,r.function.arguments)}}function Vs(e,t,n){let r=n.delta;r&&(r.content&&Ls(e,t,r.content),r.tool_calls&&Bs(e,t,r.tool_calls),n.finish_reason&&(t.stopReason=Is(n.finish_reason)))}function Hs(e,t,n,r){try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,e.push({type:`toolcall_end`,contentIndex:r,toolCall:n,partial:t})}function Us(e,t){for(let n=0;n<t.content.length;n+=1){let r=t.content[n];r.type===`toolCall`?Hs(e,t,r,n):r.type===`text`&&e.push({type:`text_end`,contentIndex:n,content:r.text,partial:t})}}async function Ws(e,t,n,r,i){let{client:a,deployment:o}=Ns(n,i),s=ks(r.tools),c=await a.chat.completions.create({model:o,messages:Ps(r,n),stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...s?{tools:s}:{}});e.push({type:`start`,partial:t});for await(let r of c){Fs(t,n,r.usage);for(let n of r.choices??[])Vs(e,t,n)}Us(e,t),e.push({type:`done`,reason:t.stopReason,message:t}),e.end()}function Gs(e,t,n,r){t.stopReason=r?`aborted`:`error`,t.errorMessage=n instanceof Error?n.message:JSON.stringify(n),e.push({type:`error`,reason:t.stopReason,error:t}),e.end()}const Ks=(e,t,r={})=>{let i=n(),a=Ms(e);return Ws(i,a,e,t,r).catch(e=>{Gs(i,a,e,!!r.signal?.aborted)}),i},qs=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);let i=a(e,n,r);return Ks(e,t,{...i})};function Js(){i({api:`azure-openai-anthropic`,stream:Ks,streamSimple:qs})}export{Es as config,Js as register};
18
+ `)){let n=t.indexOf(`:`);n>=0&&(e[t.substring(0,n).trim()]=t.substring(n+1).trim())}p.defaultHeaders=N([e,p.defaultHeaders])}this._options=p,this._provider=d,l&&(this._workloadIdentityAuth=new Mt(l,this.fetch)),this.apiKey=typeof r==`string`?r:null,this.adminAPIKey=i,this.organization=a,this.project=o,this.webhookSecret=c}withOptions(e){let t=this._options.provider,n=e.provider??t,r={...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret};return n&&(delete r.apiKey,delete r.adminAPIKey,delete r.workloadIdentity,delete r.baseURL,n!==t&&(delete r.organization,delete r.project,delete r.defaultHeaders)),new this.constructor({...r,...e,provider:n})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t},n={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(e.get(`authorization`)||e.get(`api-key`))&&!(t.has(`authorization`)||t.has(`api-key`))&&!(this._workloadIdentityAuth&&n.bearerAuth))throw Error(`Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted`)}async authHeaders(e,t={bearerAuth:!0,adminAPIKeyAuth:!0}){return N([t.bearerAuth?await this.bearerAuth(e):null,t.adminAPIKeyAuth?await this.adminAPIKeyAuth(e):null])}async bearerAuth(e){if(this._workloadIdentityAuth)return N([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey!=null)return N([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(e){if(this.adminAPIKey!=null)return N([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(e){return Ct(e)}getUserAgent(){return`${this.constructor.name}/JS ${Ye}`}defaultIdempotencyKey(){return`stainless-node-retry-${l()}`}makeStatusError(e,t,n,r){let i=t&&typeof t==`object`&&t.error==null?{error:t}:t;return p.generate(e,i,n,r)}async _callApiKey(){if(this._provider)return!1;let e=this._options.apiKey;if(typeof e!=`function`)return!1;let t;try{t=await e()}catch(e){throw e instanceof f?e:new f(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if(typeof t!=`string`||!t)throw new f(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){let r=!c(this,fs,`m`,gs).call(this)&&n||this.baseURL,i=le(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!fe(a)||!fe(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){this._provider||(e.__security??{bearerAuth:!0}).bearerAuth&&await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return this.responsePromise(this.makeRequest(e,t,void 0))}responsePromise(e,t=(e,t)=>this.parseResponseWithTimeout(e,t)){let n=new Tt(this,e,t);return n.withResponse=async()=>{let t=await n,{response:r}=await e;return{data:t,response:r,request_id:r.headers.get(`x-request-id`)}},n._thenUnwrap=n=>this.responsePromise(e,async(e,r)=>Je(n(await t(e,r),r),r.response)),n}async parseResponseWithTimeout(e,t){if(t.options.stream||t.options.__binaryResponse||t.response.status===204||t.response.headers.get(`content-length`)===`0`)return Ke(e,t);for(;;){let n=c(this,hs,`f`).get(t.controller),r=n?.timeout??t.options.timeout??this.timeout,i=Math.max(0,t.startTime+r-Date.now()),a=t.options.signal,o,s,l=!1;try{if(a?.aborted&&t.options.__metadata?.helperMethod!==`runTools`)throw new m;let n=new Promise((e,n)=>{o=setTimeout(()=>{l=!0,t.controller.abort(),n(new g)},i),a&&(s=()=>n(new m),a.addEventListener(`abort`,s,{once:!0}))});return await Promise.race([Ke(e,t),n])}catch(e){if(a?.aborted)throw new m;if(!l)throw e;let r=n?.retriesRemaining??0;if(!r||t.options.__metadata?.hasStreamingBody||globalThis.ReadableStream&&t.options.body instanceof globalThis.ReadableStream||typeof t.options.body==`object`&&t.options.body!==null&&(Symbol.asyncIterator in t.options.body||Symbol.iterator in t.options.body&&`next`in t.options.body&&typeof t.options.body.next==`function`))throw new g;o!==void 0&&clearTimeout(o),s&&a?.removeEventListener(`abort`,s),s=void 0;let i=await this.retryRequest(t.options,r,t.retryOfRequestLogID??t.requestLogID);Object.assign(t,i)}finally{o!==void 0&&clearTimeout(o),s&&a?.removeEventListener(`abort`,s)}}}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t}),l=r.__metadata?.hasStreamingBody===!0;await this.prepareRequest(a,{url:o,options:r}),await this._provider?.prepareRequest?.(a,{url:o,options:r});let f=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),p=n===void 0?``:`, retryOf: ${n}`,m=Date.now();if(k(this).debug(`[${f}] sending request`,ze({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted||a.signal?.aborted)throw this._makeUserAbortError(r.signal?.aborted?r.signal:a.signal);let _=r.__security??{bearerAuth:!0},v=this.fetchWithTimeout===ps.prototype.fetchWithTimeout?ys(a.signal):new AbortController,y=await this.fetchWithAuth(o,a,s,v,_).catch(d),b=Date.now();if(y instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted||a.signal?.aborted)throw this._makeUserAbortError(r.signal?.aborted?r.signal:a.signal);let i=u(y)||/timed? ?out/i.test(String(y)+(`cause`in y?String(y.cause):``));if(t&&!l)return k(this).info(`[${f}] connection ${i?`timed out`:`failed`} - ${e}`),k(this).debug(`[${f}] connection ${i?`timed out`:`failed`} (${e})`,ze({retryOfRequestLogID:n,url:o,durationMs:b-m,message:y.message})),this.retryRequest(r,t,n??f);let s=l?`error; streaming body cannot be retried`:`error; no more retries left`;if(k(this).info(`[${f}] connection ${i?`timed out`:`failed`} - ${s}`),k(this).debug(`[${f}] connection ${i?`timed out`:`failed`} (${s})`,ze({retryOfRequestLogID:n,url:o,durationMs:b-m,message:y.message})),y instanceof oe||y instanceof se)throw y;if(i){let e=`cause`in y?y.cause:void 0,t=typeof e==`object`&&e&&`code`in e&&e.code===`UND_ERR_HEADERS_TIMEOUT`?new g({message:`Request timed out. Node.js fetch timed out waiting for response headers; configure a matching undici fetch and fetchOptions.dispatcher with an Agent whose headersTimeout is at least the SDK timeout.`}):new g;throw Object.assign(t,{cause:y})}throw new h({message:bs(y),cause:y})}let x=`[${f}${p}${[...y.headers.entries()].filter(([e])=>e===`x-request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${y.ok?`succeeded`:`failed`} with status ${y.status} in ${b-m}ms`;if(!y.ok){if(y.status===401&&this._workloadIdentityAuth&&_.bearerAuth&&!r.__metadata?.hasStreamingBody&&!r.__metadata?.workloadIdentityTokenRefreshed)return await xe(y.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...r,__metadata:{...r.__metadata,workloadIdentityTokenRefreshed:!0}},t,n??f);let e=await this.shouldRetry(y);if(t&&e&&!l){let e=`retrying, ${t} attempts remaining`;return await xe(y.body),k(this).info(`${x} - ${e}`),k(this).debug(`[${f}] response error (${e})`,ze({retryOfRequestLogID:n,url:y.url,status:y.status,headers:y.headers,durationMs:b-m})),this.retryRequest(r,t,n??f,y.headers)}let i=e?l?`error; streaming body cannot be retried`:`error; no more retries left`:`error; not retryable`;k(this).info(`${x} - ${i}`);let a=await y.text().catch(e=>d(e).message),o=he(a),s=o?void 0:a;throw k(this).debug(`[${f}] response error (${i})`,ze({retryOfRequestLogID:n,url:y.url,status:y.status,headers:y.headers,message:s,durationMs:Date.now()-m})),this.makeStatusError(y.status,o,s,y.headers)}return k(this).info(x),k(this).debug(`[${f}] response start`,ze({retryOfRequestLogID:n,url:y.url,status:y.status,headers:y.headers,durationMs:b-m})),c(this,hs,`f`).set(v,{timeout:s,retriesRemaining:t}),{response:y,options:r,controller:v,requestLogID:f,retryOfRequestLogID:n,startTime:m}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0),r=new Ot(this,n,e),i=this.responsePromise(n,async(t,n)=>{let r=await this.parseResponseWithTimeout(t,n);return new e(t,n.response,r,n.options)});return r.then=i.then.bind(i),r.catch=i.catch.bind(i),r.finally=i.finally.bind(i),r.withResponse=i.withResponse.bind(i),r._thenUnwrap=i._thenUnwrap.bind(i),r}async fetchWithAuth(e,t,n,r,i={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&i.bearerAuth){let e=t.headers,n=e.get(`Authorization`);if(!n||n===`Bearer workload-identity-auth`){let t=await this._workloadIdentityAuth.getToken();e.set(`Authorization`,`Bearer ${t}`)}}return await this.fetchWithTimeout(e,t,n,r)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r),c=!!i&&vs.get(r)===i;i&&!c&&i.addEventListener(`abort`,s,{once:!0});let l=setTimeout(s,n),u=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,d={signal:r.signal,...u?{duplex:`half`}:{},method:`GET`,...o};a&&(d.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,d)}catch(e){throw i&&!c&&i.removeEventListener(`abort`,s),e}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&i===void 0){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0||!Number.isFinite(i)||i<0||i>6e4){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await ge(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&me(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l,isStreamingBody:u}=this.buildBody({options:n});return u&&(e.__metadata={...e.__metadata,hasStreamingBody:!0}),{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=e.__metadata?.helperMethod,o=N([i,{Accept:`application/json`,..._s()?void 0:{"User-Agent":this.getUserAgent()},"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...rt(),...typeof a==`string`?{"X-Stainless-Helper-Method":a}:{},"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},this._provider?void 0:await this.authHeaders(e,e.__security??{bearerAuth:!0}),this._options.defaultHeaders,n,e.headers]);return this._provider||this.validateHeaders(o,e.__security??{bearerAuth:!0}),o.values}_makeAbort(e){return()=>e.abort()}_makeUserAbortError(e){let t=new m;return Object.defineProperty(t,"cause",{value:e.reason,writable:!0,configurable:!0}),t}buildBody({options:e}){let{body:t,headers:n}=e;if(!t)return t===void 0&&`body`in e?{...c(this,ms,`f`).call(this,{body:t,headers:N([n])}),isStreamingBody:!1}:{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let r=N([n]),i=globalThis.ReadableStream!==void 0&&t instanceof globalThis.ReadableStream,a=!i&&(typeof t==`string`||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||globalThis.Blob!==void 0&&t instanceof globalThis.Blob||t instanceof URLSearchParams||t instanceof FormData);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t==`string`&&r.values.has(`content-type`)||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||i?{bodyHeaders:void 0,body:t,isStreamingBody:!a}:typeof t==`object`&&(Symbol.asyncIterator in t||Symbol.iterator in t&&`next`in t&&typeof t.next==`function`)?{bodyHeaders:void 0,body:ye(t),isStreamingBody:!0}:typeof t==`object`&&r.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(t),isStreamingBody:!1}:{...c(this,ms,`f`).call(this,{body:t,headers:r}),isStreamingBody:!1}}};ps=$,ms=new WeakMap,hs=new WeakMap,fs=new WeakSet,gs=function(){return this._provider!==void 0||this.baseURL!==`https://api.openai.com/v1`},$.OpenAI=ps,$.DEFAULT_TIMEOUT=6e5,$.OpenAIError=f,$.APIError=p,$.APIConnectionError=h,$.APIConnectionTimeoutError=g,$.APIUserAbortError=m,$.NotFoundError=b,$.ConflictError=x,$.RateLimitError=te,$.BadRequestError=_,$.AuthenticationError=v,$.InternalServerError=ne,$.PermissionDeniedError=y,$.UnprocessableEntityError=ee,$.InvalidWebhookSignatureError=ae,$.toFile=_n,$.toStreamingFile=Lt,$.Completions=Sa,$.Chat=Rr,$.Embeddings=ka,$.Files=Na,$.Images=Wa,$.ContentProvenanceChecks=Ea,$.Audio=vi,$.Moderations=Ka,$.Models=Ga,$.FineTuning=Va,$.Graders=Ua,$.VectorStores=ts,$.Webhooks=os,$.Beta=xa,$.Batches=yi,$.Uploads=Zo,$.Admin=mi,$.Responses=Go,$.Realtime=Ya,$.Conversations=Oa,$.Evals=Ma,$.Containers=Ta,$.Skills=Yo,$.Videos=ns;const vs=new WeakMap;function ys(e){let t=new AbortController;if(!e)return t;let n=globalThis.AbortSignal;if(typeof n?.any!=`function`||!(e instanceof n))return t;try{let r=n.any([t.signal,e]);Object.defineProperty(t,"signal",{value:r,configurable:!0}),vs.set(t,e)}catch{}return t}function bs(e){if(xs(e))return`Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });`}function xs(e){let t=e;for(let e=0;e<8&&t&&typeof t==`object`;e++){let e=t;if(e.code===`UND_ERR_INVALID_ARG`&&typeof e.message==`string`&&e.message.includes(`invalid onRequestStart method`))return!0;t=e.cause}return!1}var Ss=class extends ${constructor({baseURL:e=W(`OPENAI_BASE_URL`),apiKey:t=W(`AZURE_OPENAI_API_KEY`),apiVersion:n=W(`OPENAI_API_VERSION`),endpoint:r,deployment:i,azureADTokenProvider:a,dangerouslyAllowBrowser:o,...s}={}){if(!n)throw new f(`The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).`);if(typeof a==`function`&&(o??=!0),!a&&!t)throw new f("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(a&&t)throw new f("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(s.defaultQuery={...s.defaultQuery,"api-version":n},!e){if(r||={}.AZURE_OPENAI_ENDPOINT,!r)throw new f("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");let t=r.length;for(;t>0&&r[t-1]===`/`;)t--;e=`${r.slice(0,t)}/openai`}else if(r)throw new f(`baseURL and endpoint are mutually exclusive`);super({apiKey:a??t,baseURL:e,...s,...o===void 0?{}:{dangerouslyAllowBrowser:o}}),this.apiVersion=``,this.apiVersion=n,this.deploymentName=i}async buildRequest(e,t={}){if(Cs.has(e.path)&&e.method===`post`&&e.body!==void 0){if(!C(e.body))throw Error(`Expected request body to be an object`);let t=this.deploymentName||e.body.model||e.__metadata?.model;t!==void 0&&!this.baseURL.includes(`/deployments`)&&(e.path=I`/deployments/${t}`+e.path)}let n=await super.buildRequest(e,t);return n.req.headers.has(`api-key`)&&(n.req.redirect=`manual`),n}async fetchWithAuth(e,t,n,r,i){return new Headers(t.headers).has(`api-key`)&&(t.redirect=`manual`),super.fetchWithAuth(e,t,n,r,i)}async authHeaders(e,t){let n=t??{bearerAuth:!0,adminAPIKeyAuth:!0};return n.bearerAuth&&typeof this._options.apiKey==`string`?N([{"api-key":this.apiKey}]):super.authHeaders(e,n)}};const Cs=new Set([`/completions`,`/chat/completions`,`/embeddings`,`/audio/transcriptions`,`/audio/translations`,`/audio/speech`,`/images/generations`,`/batches`,`/images/edits`]),ws=`azure-openai`,Ts=`2024-12-01-preview`,Es={id:ws,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:Ts,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(ws);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function Ds(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Os(e,t){let n=o(e.messages,t,Ds),r=[];for(let e of n)if(e.role===`user`){if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function ks(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function As(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function js(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}function Ms(e){return{role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:ws,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:`stop`,timestamp:Date.now()}}function Ns(e,n){let r=n.apiKey;if(!r)throw Error(`Azure API key is required`);let i=e.baseUrl;if(!i)throw Error(`Azure endpoint is required`);let a={};e.headers&&Object.assign(a,e.headers),n.headers&&Object.assign(a,n.headers);let o=t(ws)||Ts,s=e.id;return{client:new Ss({endpoint:i.replace(/\/+$/,``),apiKey:r,deployment:s,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:a}),deployment:s}}function Ps(e,t){return[...e.systemPrompt?[{role:`system`,content:e.systemPrompt}]:[],...Os(e,t)]}function Fs(e,t,n){n&&(e.usage.input=n.prompt_tokens??0,e.usage.output=n.completion_tokens??0,e.usage.totalTokens=n.total_tokens??0,r(t,e.usage))}function Is(e){return e===`tool_calls`?`toolUse`:e===`length`?`length`:`stop`}function Ls(e,t,n){let{block:r,index:i}=As(t);r.text===``&&e.push({type:`text_start`,contentIndex:i,partial:t}),r.text+=n,e.push({type:`text_delta`,contentIndex:i,delta:n,partial:t})}function Rs(e,t,n){let r=n.id?js(t,n.id):void 0;if(r||!n.id)return r;let i={type:`toolCall`,id:n.id,name:n.function?.name??``,arguments:{},_partialJson:``};return t.content.push(i),e.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}),i}function zs(e,t,n,r){n._partialJson+=r;try{n.arguments=JSON.parse(n._partialJson)}catch{}e.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:r,partial:t})}function Bs(e,t,n){for(let r of n){let n=Rs(e,t,r);n&&r.function?.arguments&&zs(e,t,n,r.function.arguments)}}function Vs(e,t,n){let r=n.delta;r&&(r.content&&Ls(e,t,r.content),r.tool_calls&&Bs(e,t,r.tool_calls),n.finish_reason&&(t.stopReason=Is(n.finish_reason)))}function Hs(e,t,n,r){try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,e.push({type:`toolcall_end`,contentIndex:r,toolCall:n,partial:t})}function Us(e,t){for(let n=0;n<t.content.length;n+=1){let r=t.content[n];r.type===`toolCall`?Hs(e,t,r,n):r.type===`text`&&e.push({type:`text_end`,contentIndex:n,content:r.text,partial:t})}}async function Ws(e,t,n,r,i){let{client:a,deployment:o}=Ns(n,i),s=ks(r.tools),c=await a.chat.completions.create({model:o,messages:Ps(r,n),stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...s?{tools:s}:{}});e.push({type:`start`,partial:t});for await(let r of c){Fs(t,n,r.usage);for(let n of r.choices??[])Vs(e,t,n)}Us(e,t),e.push({type:`done`,reason:t.stopReason,message:t}),e.end()}function Gs(e,t,n,r){t.stopReason=r?`aborted`:`error`,t.errorMessage=n instanceof Error?n.message:JSON.stringify(n),e.push({type:`error`,reason:t.stopReason,error:t}),e.end()}const Ks=(e,t,r={})=>{let i=n(),a=Ms(e);return Ws(i,a,e,t,r).catch(e=>{Gs(i,a,e,!!r.signal?.aborted)}),i},qs=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);let i=a(e,n,r);return Ks(e,t,{...i})};function Js(){i({api:`azure-openai-anthropic`,stream:Ks,streamSimple:qs})}export{Es as config,Js as register};
@@ -1,4 +1,4 @@
1
- import{_ as e,x as t}from"./account-store-DB2oZS70.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-BSkXF4T6.js";import{u as i}from"./claude-model-version-BJLrDjmH.js";import{r as a,t as o}from"./transform-messages-BsQjTIEJ.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De,Oe=65536,ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
1
+ import{_ as e,x as t}from"./account-store-BzCpAbzU.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-BSkXF4T6.js";import{u as i}from"./claude-model-version-BJLrDjmH.js";import{r as a,t as o}from"./transform-messages-BsQjTIEJ.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De,Oe=65536,ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Ee=new WeakMap,Te=new WeakSet,De=function(e){if(c(this,D,`f`)+e.length>c(this,T,`f`).length){let t=c(this,D,`f`)-c(this,E,`f`);if(c(this,E,`f`)>=c(this,T,`f`).length/2&&t+e.length<=c(this,T,`f`).length)c(this,T,`f`).copyWithin(0,c(this,E,`f`),c(this,D,`f`));else{let n=Math.max(c(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,r,`f`)}s(this,O,c(this,O,`f`)-c(this,E,`f`),`f`),s(this,D,t,`f`),s(this,E,0,`f`)}c(this,T,`f`).set(e,c(this,D,`f`)),s(this,D,c(this,D,`f`)+e.length,`f`)},ke.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),ke.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ae(e,t,n){for(let r=t;r<n;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function je(e){for(let t=0;t<e.length-1;t++){let n=Me(e,t);if(n>0){let r=t+n,i=Me(e,r);if(i>0)return r+i}}return-1}function Me(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}var Ne={off:0,error:200,warn:300,info:400,debug:500},Pe=(e,t,n)=>{if(e){if(pe(Ne,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ne))}`)}};function Fe(){}function Ie(e,t,n){return!t||Ne[e]>Ne[n]?Fe:t[e].bind(t)}var Le={error:Fe,warn:Fe,info:Fe,debug:Fe},Re=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Le;let r=Re.get(t);if(r&&r[0]===n)return r[1];let i={error:Ie(`error`,t,n),warn:Ie(`warn`,t,n),info:Ie(`info`,t,n),debug:Ie(`debug`,t,n)};return Re.set(t,[n,i]),i}var ze=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Be,Ve=class e{constructor(e,t,n){Be.set(this,void 0),this.iterator=e,this.controller=t,s(this,Be,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1,r=!1;try{for await(let e of He(t,n)){if(e.data.startsWith(`[DONE]`)){r=!0;break}if(e.event===null||!e.event.startsWith(`thread.`)){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&n.error)throw new p(void 0,n.error,void 0,t.headers);yield i?{event:e.event,data:n}:n}else{let t;try{t=JSON.parse(e.data)}catch(t){throw console.error(`Could not parse message into JSON:`,e.data),console.error(`From chunk:`,e.raw),t}if(e.event===`error`)throw new p(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||u(e)||n.signal.aborted&&e===n.signal.reason)return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ke,r=t.getReader(),i=!1,a,o=()=>{a??=r.cancel(),a.catch(()=>void 0)};n.signal.addEventListener(`abort`,o,{once:!0});try{if(n.signal.aborted){o();return}for(;;){let{value:t,done:a}=await r.read();if(a){i=!0;break}if(n.signal.aborted)return;for(let r of e.decode(t)){if(n.signal.aborted)return;yield r}}if(n.signal.aborted)return;for(let t of e.flush()){if(n.signal.aborted)return;yield t}}finally{n.signal.removeEventListener(`abort`,o),i||o(),r.releaseLock()}}async function*o(){if(i)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(n.signal.aborted||u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Be=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,c(this,Be,`f`)),new e(()=>i(n),this.controller,c(this,Be,`f`))]}toReadableStream(){let e;return ve({start:async()=>{e=this[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=w(JSON.stringify(n)+`
4
4
  `);t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}};async function*He(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new f(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new f(`Attempted to iterate over a response with no body`);let n=new Ge,r=new ke,i=be(e.body);for await(let e of We(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}var Ue=3;async function*We(e){let t=new Uint8Array,n=0,r=0,i=0;for await(let a of e){if(a==null)continue;let e;if(e=a instanceof ArrayBuffer?new Uint8Array(a):typeof a==`string`?w(a):a,r+e.length>t.length){let a=r-n;if(n>=t.length/2&&a+e.length<=t.length)t.copyWithin(0,n,r);else{let i=new Uint8Array(Math.max(t.length*2,a+e.length));i.set(t.subarray(n,r)),t=i}i-=n,n=0,r=a}t.set(e,r),r+=e.length;let o;for(;(o=je(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-Ue)}r>n&&(yield t.slice(n,r))}var Ge=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.slice(0,-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-C8xRyQBd.js";import"./wc-follower-oauth-ClOA_w6r.js";import{n as t,t as n}from"./pending-request-table-Dgn6qYdL.js";var r=e(`cdp`),i=4001,a=class{ws=null;nextId=1;_superseded=!1;pending=new n;listeners=new Map;_state=`disconnected`;get state(){return this._state}get superseded(){return this._superseded}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3,protocols:i}=e;return this._state=`connecting`,new Promise((e,a)=>{let o=setTimeout(()=>{this.cleanup(),a(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=i===void 0?new WebSocket(t):new WebSocket(t,i)}catch(e){clearTimeout(o),this._state=`disconnected`,a(e);return}this.ws.onopen=()=>{clearTimeout(o),this._state=`connected`,this._superseded=!1,r.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(o),this._state===`connecting`&&(r.error(`Connection failed`,{url:t}),this.cleanup(),a(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=e=>{this.handleClose(e?.code)}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this._superseded=!1,this.cleanup(),r.info(`Disconnected`)}async send(e,t,n,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};t&&(o.params=t),n&&(o.sessionId=n),r.debug(`Send`,{method:e,id:a,sessionId:n});let s=this.pending.issue(a,i,`CDP command timed out after ${i}ms: ${e}`);return this.ws.send(JSON.stringify(o)),s}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,n=3e4){return t(t=>(this.on(e,t),()=>this.off(e,t)),n,`Timed out waiting for event: ${e}`)}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;r.debug(`Response`,{id:e.id,hasError:!!e.error}),e.error?(r.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),this.pending.reject(e.id,Error(`CDP error: ${e.error.message} (${e.error.code})`))):this.pending.resolve(e.id,e.result??{});return}if(`method`in t){let e=t;r.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(e){let t=e===i;t?(this._superseded=!0,r.warn(`CDP slot superseded by another SLICC tab/window on this instance`,{code:e})):r.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});let n=t?`CDP connection superseded by another SLICC tab/window on this instance`:`CDP connection closed`;this.pending.rejectAll(n),this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.rejectAll(`CDP client disconnected`)}},o=e(`har-recorder`),s=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n){let r=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await this.client.send(`Network.enable`,{},t),await this.client.send(`Page.enable`,{},t);let i=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,a={id:r,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:i,snapshotCount:0};return this.recordings.set(r,a),this.setupEventListeners(a),await this.ensureDir(`/recordings/${r}`),o.debug(`Started recording`,{recordingId:r,targetId:e,currentUrl:i}),r}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{let r=n;r.sessionId===t&&this.handleRequestWillBeSent(e,r)},i=n=>{let r=n;r.sessionId===t&&this.handleResponseReceived(e,r)},a=r=>{let i=r;i.sessionId===t&&this.handleLoadingFinished(e,i).catch(e=>{o.error(`Failed to process loadingFinished event`,{recordingId:n,requestId:i.requestId,error:e instanceof Error?e.message:String(e)})})},s=n=>{let r=n;r.sessionId===t&&this.handleLoadingFailed(e,r)},c=r=>{let i=r;if(i.sessionId!==t)return;let a=i.frame;if(!a?.parentId&&a?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=a.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{o.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,s),this.client.on(`Page.frameNavigated`,c),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,s),this.client.off(`Page.frameNavigated`,c)})}handleRequestWillBeSent(e,t){let{requestId:n,request:r,timestamp:i}=t;!n||!r||i==null||e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let{requestId:n,response:r}=t;if(!n||!r)return;let i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let{requestId:n,timestamp:r}=t;if(!n||r==null)return;let i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded===!0}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let{requestId:n}=t;n&&e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){return c(e,t)}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return o.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return o.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),s=this.urlToSlug(r),c=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${s}.har`,l=`/recordings/${e.id}/${c}`,u={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(l,JSON.stringify(u,null,2)),o.debug(`Saved HAR snapshot`,{recordingId:e.id,path:l,entryCount:i.length}),l}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return o.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}};function c(e,t){try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){o.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return o.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}var l=`(function() {
1
+ import{t as e}from"./logger-DDBAeTLF.js";import"./navigation-watcher-C8xRyQBd.js";import"./wc-follower-oauth-DCz20htV.js";import{n as t,t as n}from"./pending-request-table-Dgn6qYdL.js";var r=e(`cdp`),i=4001,a=class{ws=null;nextId=1;_superseded=!1;pending=new n;listeners=new Map;_state=`disconnected`;get state(){return this._state}get superseded(){return this._superseded}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:n=5e3,protocols:i}=e;return this._state=`connecting`,new Promise((e,a)=>{let o=setTimeout(()=>{this.cleanup(),a(Error(`CDP connection timed out after ${n}ms`))},n);try{this.ws=i===void 0?new WebSocket(t):new WebSocket(t,i)}catch(e){clearTimeout(o),this._state=`disconnected`,a(e);return}this.ws.onopen=()=>{clearTimeout(o),this._state=`connected`,this._superseded=!1,r.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(o),this._state===`connecting`&&(r.error(`Connection failed`,{url:t}),this.cleanup(),a(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=e=>{this.handleClose(e?.code)}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this._superseded=!1,this.cleanup(),r.info(`Disconnected`)}async send(e,t,n,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};t&&(o.params=t),n&&(o.sessionId=n),r.debug(`Send`,{method:e,id:a,sessionId:n});let s=this.pending.issue(a,i,`CDP command timed out after ${i}ms: ${e}`);return this.ws.send(JSON.stringify(o)),s}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,n=3e4){return t(t=>(this.on(e,t),()=>this.off(e,t)),n,`Timed out waiting for event: ${e}`)}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;r.debug(`Response`,{id:e.id,hasError:!!e.error}),e.error?(r.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),this.pending.reject(e.id,Error(`CDP error: ${e.error.message} (${e.error.code})`))):this.pending.resolve(e.id,e.result??{});return}if(`method`in t){let e=t;r.debug(`Event`,{method:e.method,sessionId:e.sessionId});let n=this.listeners.get(e.method);if(n){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of n)try{e(t)}catch{}}}}handleClose(e){let t=e===i;t?(this._superseded=!0,r.warn(`CDP slot superseded by another SLICC tab/window on this instance`,{code:e})):r.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});let n=t?`CDP connection superseded by another SLICC tab/window on this instance`:`CDP connection closed`;this.pending.rejectAll(n),this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.rejectAll(`CDP client disconnected`)}},o=e(`har-recorder`),s=class{recordings=new Map;client;fs;eventCleanup=new Map;constructor(e,t){this.client=e,this.fs=t}async startRecording(e,t,n){let r=`rec-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await this.client.send(`Network.enable`,{},t),await this.client.send(`Page.enable`,{},t);let i=(await this.client.send(`Runtime.evaluate`,{expression:`location.href`,returnByValue:!0},t)).result?.value??`about:blank`,a={id:r,targetId:e,sessionId:t,filterCode:n,pendingRequests:new Map,entries:[],startTime:Date.now(),currentUrl:i,snapshotCount:0};return this.recordings.set(r,a),this.setupEventListeners(a),await this.ensureDir(`/recordings/${r}`),o.debug(`Started recording`,{recordingId:r,targetId:e,currentUrl:i}),r}setupEventListeners(e){let{sessionId:t,id:n}=e,r=n=>{let r=n;r.sessionId===t&&this.handleRequestWillBeSent(e,r)},i=n=>{let r=n;r.sessionId===t&&this.handleResponseReceived(e,r)},a=r=>{let i=r;i.sessionId===t&&this.handleLoadingFinished(e,i).catch(e=>{o.error(`Failed to process loadingFinished event`,{recordingId:n,requestId:i.requestId,error:e instanceof Error?e.message:String(e)})})},s=n=>{let r=n;r.sessionId===t&&this.handleLoadingFailed(e,r)},c=r=>{let i=r;if(i.sessionId!==t)return;let a=i.frame;if(!a?.parentId&&a?.url){let t=[...e.entries],r=e.currentUrl;e.currentUrl=a.url,e.entries=[],e.pendingRequests.clear(),this.saveSnapshotWithEntries(e,`navigation`,t,r).catch(e=>{o.error(`Failed to save navigation snapshot`,{recordingId:n,error:e instanceof Error?e.message:String(e)})})}};this.client.on(`Network.requestWillBeSent`,r),this.client.on(`Network.responseReceived`,i),this.client.on(`Network.loadingFinished`,a),this.client.on(`Network.loadingFailed`,s),this.client.on(`Page.frameNavigated`,c),this.eventCleanup.set(n,()=>{this.client.off(`Network.requestWillBeSent`,r),this.client.off(`Network.responseReceived`,i),this.client.off(`Network.loadingFinished`,a),this.client.off(`Network.loadingFailed`,s),this.client.off(`Page.frameNavigated`,c)})}handleRequestWillBeSent(e,t){let{requestId:n,request:r,timestamp:i}=t;!n||!r||i==null||e.pendingRequests.set(n,{requestId:n,startTime:i*1e3,request:{method:r.method,url:r.url,headers:r.headers,postData:r.postData}})}handleResponseReceived(e,t){let{requestId:n,response:r}=t;if(!n||!r)return;let i=e.pendingRequests.get(n);i&&(i.response={status:r.status,statusText:r.statusText,headers:r.headers,mimeType:r.mimeType},i.timing=r.timing)}async handleLoadingFinished(e,t){let{requestId:n,timestamp:r}=t;if(!n||r==null)return;let i=e.pendingRequests.get(n);if(!i)return;i.endTime=r*1e3;try{let t=await this.client.send(`Network.getResponseBody`,{requestId:n},e.sessionId);i.responseBody=t.body,i.responseBodyBase64=t.base64Encoded===!0}catch{}let a=this.buildHarEntry(i);a&&e.entries.push(a),e.pendingRequests.delete(n)}handleLoadingFailed(e,t){let{requestId:n}=t;n&&e.pendingRequests.delete(n)}buildHarEntry(e){if(!e.response)return null;let{request:t,response:n,timing:r,startTime:i,endTime:a,responseBody:o,responseBodyBase64:s}=e,c=a?a-i:0,l=[];try{let e=new URL(t.url);l=Array.from(e.searchParams.entries()).map(([e,t])=>({name:e,value:t}))}catch{}let u=r?(()=>{let e=(e,t)=>{if(e==null||t==null||e<0||t<0)return-1;let n=t-e;return n>=0?n:-1},t=r.dnsStart>=0?r.dnsStart:r.connectStart>=0?r.connectStart:0;return{blocked:t>0?t:-1,dns:e(r.dnsStart,r.dnsEnd),connect:e(r.connectStart,r.connectEnd),ssl:e(r.sslStart,r.sslEnd),send:e(r.sendStart,r.sendEnd),wait:e(r.sendEnd,r.receiveHeadersStart),receive:e(r.receiveHeadersStart,r.receiveHeadersEnd)}})():{blocked:-1,dns:-1,connect:-1,ssl:-1,send:0,wait:c,receive:0},d={size:o?.length??0,mimeType:n.mimeType??`application/octet-stream`};o&&(d.text=o,s&&(d.encoding=`base64`));let f;return t.postData&&(f={mimeType:t.headers[`content-type`]??t.headers[`Content-Type`]??`text/plain`,text:t.postData}),{startedDateTime:new Date(i).toISOString(),time:c,request:{method:t.method,url:t.url,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(t.headers).map(([e,t])=>({name:e,value:t})),queryString:l,postData:f,headersSize:-1,bodySize:t.postData?.length??0},response:{status:n.status,statusText:n.statusText,httpVersion:`HTTP/1.1`,cookies:[],headers:Object.entries(n.headers).map(([e,t])=>({name:e,value:t})),content:d,redirectURL:n.headers.location??n.headers.Location??``,headersSize:-1,bodySize:d.size},cache:{},timings:u}}async saveSnapshot(e,t){return this.saveSnapshotWithEntries(e,t,e.entries,e.currentUrl)}async applyFilter(e,t){return c(e,t)}async saveSnapshotWithEntries(e,t,n,r){if(n.length===0)return o.debug(`No entries to save`,{recordingId:e.id,trigger:t}),null;let i=e.filterCode?await this.applyFilter(n,e.filterCode):n;if(i.length===0)return o.debug(`All entries filtered out`,{recordingId:e.id,trigger:t}),null;e.snapshotCount++;let a=new Date().toISOString().replace(/[:.]/g,`-`),s=this.urlToSlug(r),c=`${e.snapshotCount.toString().padStart(3,`0`)}-${a}-${t}-${s}.har`,l=`/recordings/${e.id}/${c}`,u={log:{version:`1.2`,creator:{name:`SLICC HAR Recorder`,version:`1.0.0`},entries:i}};return await this.fs.writeFile(l,JSON.stringify(u,null,2)),o.debug(`Saved HAR snapshot`,{recordingId:e.id,path:l,entryCount:i.length}),l}urlToSlug(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`.replace(/[^a-zA-Z0-9]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,50)||`page`}catch{return`page`}}async stopRecording(e){let t=this.recordings.get(e);if(!t)throw Error(`Recording not found: ${e}`);await this.saveSnapshot(t,`close`);let n=this.eventCleanup.get(e);n&&(n(),this.eventCleanup.delete(e));try{await this.client.send(`Network.disable`,{},t.sessionId)}catch{}this.recordings.delete(e);let r=`/recordings/${e}`;return o.debug(`Stopped recording`,{recordingId:e,snapshotCount:t.snapshotCount}),r}getRecording(e){return this.recordings.get(e)}getRecordingByTarget(e){for(let[t,n]of this.recordings)if(n.targetId===e)return t}async ensureDir(e){await this.fs.mkdir(e,{recursive:!0})}};function c(e,t){try{let n=Function(`entry`,`return (${t})(entry);`),r=[];for(let t of e)try{let e=n(t);if(e===!1)continue;typeof e==`object`&&e?r.push(e):r.push(t)}catch(e){o.error(`Filter function error on entry, keeping it`,{error:e instanceof Error?e.message:String(e)}),r.push(t)}return r}catch(t){return o.error(`Failed to compile filter, returning unfiltered`,{error:t instanceof Error?t.message:String(t)}),e}}var l=`(function() {
2
2
  'use strict';
3
3
 
4
4
  // ===== DOM Utilities =====
@@ -1 +1 @@
1
- import{g as e}from"./account-store-DB2oZS70.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function _(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
1
+ import{g as e}from"./account-store-BzCpAbzU.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";var a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`,u=[],d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function _(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}var v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}var S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
@@ -1 +1 @@
1
- import{i as e}from"./account-store-BsMvCC37.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function _(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
1
+ import{a as e}from"./account-store-IBc-Swl2.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";const a=`cerebras`,o=`https://api.cerebras.ai/v1`,s=`openai-completions`,c=`${a}-openai`,l=`slicc-cerebras-models`;let u=[];const d=[{id:`gpt-oss-120b`,name:`GPT OSS 120B`,api:`openai`,reasoning:!0,input:[`text`],context_window:131072,max_tokens:40960},{id:`gemma-4-31b`,name:`Gemma 4 31B`,api:`openai`,reasoning:!1,input:[`text`,`image`],context_window:131072,max_tokens:40960},{id:`zai-glm-4.7`,name:`Z.AI GLM-4.7`,api:`openai`,reasoning:!1,input:[`text`],context_window:131072,max_tokens:40960}];function f(e){try{localStorage.setItem(l,JSON.stringify(e))}catch{}}function p(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)&&t.length>0?t:[]}catch{return[]}}function m(e){let t=e.id??``,n=d.find(e=>e.id===t);return{id:t,name:e.name??n?.name??t,api:`openai`,reasoning:e.capabilities?.reasoning??n?.reasoning??!1,input:e.capabilities?.vision?[`text`,`image`]:n?.input??[`text`],context_window:e.limits?.max_context_length??n?.context_window??8192,max_tokens:e.limits?.max_completion_tokens??n?.max_tokens??4096}}async function h(e){let t=await fetch(`${o}/models`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`GET /v1/models → ${t.status} ${t.statusText}`);let n=((await t.json()).data??[]).map(m).filter(e=>e.id.length>0);n.length>0&&(u=n,f(n))}function g(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:c,provider:a,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function _(e){console.error(`[cerebras] Stream error:`,e instanceof Error?e.message:String(e))}const v=(e,n,r={})=>{let i=t();return y(i,e,n,r).catch(_),i};async function y(e,t,n,i){try{let a={...t,baseUrl:o,api:s},c=r(a,n,i);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const b=(e,n,r)=>{let i=t();return x(i,e,n,r).catch(_),i};async function x(e,t,n,r){try{let a={...t,baseUrl:o,api:s},c=i(a,n,r);for await(let t of c)e.push(t);e.end()}catch(n){_(n),e.push(g(t,n)),e.end()}}const S={id:a,name:`Cerebras`,description:`Ultra-fast inference on Cerebras hardware. Get an API key at cloud.cerebras.ai.`,requiresApiKey:!0,requiresBaseUrl:!1,getModelIds:()=>{if(u.length>0)return u;let e=p();return e.length>0?e:d},refreshModels:async t=>{let n=t??e(a)??``;if(n)try{await h(n)}catch(e){console.warn(`[cerebras] Failed to refresh model list:`,e instanceof Error?e.message:String(e))}}};function C(){n({api:c,stream:v,streamSimple:b})}export{S as config,C as register};
@@ -1,4 +1,4 @@
1
- import{R as e,f as t,p as n,w as r}from"./account-store-DB2oZS70.js";import{n as i}from"./provider-settings-TF5REgnM.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let t=r(e);return!(t.hidden||t.onOAuthLoginIntercepted)}function c(){try{let e=n().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(n){for(;n.firstChild;)n.removeChild(n.firstChild);n.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,n.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,n.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,n.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let n=t().filter(e=>e.providerId!==o);if(n.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let t=document.createElement(`div`);t.className=`connect-surface__accounts-list`;for(let i of n){let n=r(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=n.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,l.textContent=i.userName?i.userName:i.accessToken?`Logged in`:i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await e(i.providerId),c(),d()},a.appendChild(u),t.appendChild(a)}u.appendChild(t)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=n.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),n.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
1
+ import{R as e,f as t,p as n,w as r}from"./account-store-BzCpAbzU.js";import{n as i}from"./provider-settings-CGwq2ZSe.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let t=r(e);return!(t.hidden||t.onOAuthLoginIntercepted)}function c(){try{let e=n().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(e))}catch{}}async function l(n){for(;n.firstChild;)n.removeChild(n.firstChild);n.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,n.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,n.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,n.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let n=t().filter(e=>e.providerId!==o);if(n.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let t=document.createElement(`div`);t.className=`connect-surface__accounts-list`;for(let i of n){let n=r(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=n.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,l.textContent=i.userName?i.userName:i.accessToken?`Logged in`:i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await e(i.providerId),c(),d()},a.appendChild(u),t.appendChild(a)}u.appendChild(t)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=n.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),n.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
2
2
  .connect-surface {
3
3
  padding: 2rem;
4
4
  max-width: 560px;
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mount-picker-popup--ijSfN8u.js","assets/logger-DDBAeTLF.js","assets/picker-popup-sQtXmfAo.js","assets/runtime-env-Dlaokqg1.js","assets/usb-picker-Cbm0jfjl.js","assets/serial-picker-BQF_Eitc.js","assets/hid-picker-sFJ8vzUj.js","assets/usb-device-registry-DmUBqrA-.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/serial-port-registry-CCqklAEr.js","assets/hid-device-registry-B2R-0rNt.js"])))=>i.map(i=>d[i]);
2
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./preload-helper-Czpn1I53.js";import{i as n,n as r,r as i}from"./sprinkle-renderer-DJyQFvKt.js";import{n as a}from"./runtime-env-Dlaokqg1.js";import{t as o}from"./permissions-surface-registry-CilCRwhh.js";import{n as s,r as c}from"./hid-device-registry-B2R-0rNt.js";import{a as l,i as u}from"./serial-port-registry-CCqklAEr.js";import{A as d,C as f,D as ee,O as te,S as p,T as m,_ as ne,b as re,c as ie,g as ae,h as oe,o as se,r as ce,s as le,u as ue,v as h,w as de}from"./usb-operations-BsAiCAWF.js";import{i as fe,r as g}from"./usb-device-registry-DmUBqrA-.js";import{n as pe}from"./sprinkle-bridge-B8DKuaxn.js";import{a as _,n as v,r as y}from"./theme-CXRqxpw6.js";var me=e({broadcastToDips:()=>L,disposeDips:()=>X,handleDipPickerAction:()=>Z,hydrateDips:()=>Y,mountDip:()=>K,setDipExecHandler:()=>_e}),b=a();function he(e){if(typeof e!=`object`||!e||Array.isArray(e))return[];let t=e.filters;return Array.isArray(t)?t:[]}async function x(e,t){if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);let n=await C(e,!0,t);if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);if(n===null)throw Error(`VFS read failed: ${e}`);return typeof n==`string`?n:new TextDecoder().decode(n)}var S=null;function ge(){if(S)return S;if(typeof BroadcastChannel>`u`)return null;try{S=new BroadcastChannel(`preview-vfs`)}catch{return null}return S}async function C(e,t,n){let r=ge();if(!r)return null;let i=`dip-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise(a=>{let o=!1,s=()=>{r.removeEventListener(`message`,c),n?.removeEventListener(`abort`,l)},c=e=>{if(!o&&e.data?.type===`preview-vfs-response`&&e.data.id===i){if(o=!0,s(),e.data.error){a(null);return}a(e.data.content??null)}},l=()=>{o||(o=!0,s(),a(null))};r.addEventListener(`message`,c),n?.addEventListener(`abort`,l),setTimeout(()=>{o||(o=!0,s(),a(null))},5e3),r.postMessage({type:`preview-vfs-read`,id:i,path:e,asText:t})})}var w=[`/shared/sprinkles/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`],T=[`/shared/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`];function E(e){return w.some(t=>e.startsWith(t))}function D(e){return typeof e!=`string`||!e.startsWith(`/`)||e.includes(`..`)?!1:T.some(t=>e.startsWith(t))}var O=new WeakSet,k=`,
2
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./preload-helper-Czpn1I53.js";import{a as n,i as r,n as i}from"./sprinkle-renderer-Ce6YjEek.js";import{n as a}from"./runtime-env-Dlaokqg1.js";import{t as o}from"./permissions-surface-registry-CilCRwhh.js";import{n as s,r as c}from"./hid-device-registry-B2R-0rNt.js";import{a as l,i as u}from"./serial-port-registry-CCqklAEr.js";import{A as d,C as f,D as ee,O as te,S as p,T as m,_ as ne,b as re,c as ie,g as ae,h as oe,o as se,r as ce,s as le,u as ue,v as h,w as de}from"./usb-operations-BsAiCAWF.js";import{i as fe,r as g}from"./usb-device-registry-DmUBqrA-.js";import{n as pe}from"./sprinkle-bridge-CeRz-DjR.js";import{a as _,n as v,r as y}from"./theme-CXRqxpw6.js";var me=e({broadcastToDips:()=>L,disposeDips:()=>X,handleDipPickerAction:()=>Z,hydrateDips:()=>Y,mountDip:()=>K,setDipExecHandler:()=>_e}),b=a();function he(e){if(typeof e!=`object`||!e||Array.isArray(e))return[];let t=e.filters;return Array.isArray(t)?t:[]}async function x(e,t){if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);let n=await C(e,!0,t);if(t?.aborted)throw new DOMException(`aborted`,`AbortError`);if(n===null)throw Error(`VFS read failed: ${e}`);return typeof n==`string`?n:new TextDecoder().decode(n)}var S=null;function ge(){if(S)return S;if(typeof BroadcastChannel>`u`)return null;try{S=new BroadcastChannel(`preview-vfs`)}catch{return null}return S}async function C(e,t,n){let r=ge();if(!r)return null;let i=`dip-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise(a=>{let o=!1,s=()=>{r.removeEventListener(`message`,c),n?.removeEventListener(`abort`,l)},c=e=>{if(!o&&e.data?.type===`preview-vfs-response`&&e.data.id===i){if(o=!0,s(),e.data.error){a(null);return}a(e.data.content??null)}},l=()=>{o||(o=!0,s(),a(null))};r.addEventListener(`message`,c),n?.addEventListener(`abort`,l),setTimeout(()=>{o||(o=!0,s(),a(null))},5e3),r.postMessage({type:`preview-vfs-read`,id:i,path:e,asText:t})})}var w=[`/shared/sprinkles/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`],T=[`/shared/`,`/workspace/skills/sprinkles/`,`/workspace/sprinkles/`];function E(e){return w.some(t=>e.startsWith(t))}function D(e){return typeof e!=`string`||!e.startsWith(`/`)||e.includes(`..`)?!1:T.some(t=>e.startsWith(t))}var O=new WeakSet,k=`,
3
3
  exec: Object.assign(function(cmd) {
4
4
  return _vfsCall('dip-exec', { cmd: cmd }, function(m) { return m.result; });
5
5
  }, { spawn: function(argv) {
@@ -218,10 +218,10 @@ mark{background:color-mix(in srgb,var(--s2-accent) 25%,transparent);color:inheri
218
218
  try { window.lucide.createIcons(); } catch(ex){}
219
219
  }
220
220
  });
221
- })();`;function F(e,t,n=!1){let i=r(),a=v()?` class="theme-light"`:``,o=t||e.includes(`<slicc-editor`),s=t||e.includes(`<slicc-diff`),c=t?`<script>${P}<\/script>`:``;return`<!DOCTYPE html>
221
+ })();`;function F(e,t,n=!1){let r=i(),a=v()?` class="theme-light"`:``,o=t||e.includes(`<slicc-editor`),s=t||e.includes(`<slicc-diff`),c=t?`<script>${P}<\/script>`:``;return`<!DOCTYPE html>
222
222
  <html${a}><head>
223
223
  <meta charset="utf-8">
224
- <style>${i}</style>
224
+ <style>${r}</style>
225
225
  <style>${N}</style>
226
226
  <script>${M(n&&!t)}<\/script>
227
227
  ${c}
@@ -230,4 +230,4 @@ ${s?`<script src="/slicc-diff.js"><\/script>`:``}
230
230
  <script src="/lucide-icons.js"><\/script>
231
231
  </head>
232
232
  <body class="sprinkle-inline">${e}</body></html>`}var I=new Set;function L(e){if(typeof e?.type!=`string`||e.type.indexOf(`slicc-`)!==0)throw Error(`broadcastToDips: payload.type must start with 'slicc-'`);for(let t of I)try{t.postMessage(e,`*`)}catch{}}var R;function _e(e){R=e}function z(e){return e.length===0?`''`:`'${e.replace(/'/g,`'\\''`)}'`}function ve(e,t){let n=t?.cwd??`.`,r=t?.allowedCommands??`*`,i=[`agent`];return t?.model&&i.push(`--model`,z(t.model)),t?.thinking&&i.push(`--thinking`,z(t.thinking)),t?.readOnly&&i.push(`--read-only`,z(t.readOnly)),i.push(z(n),z(r),z(e)),i.join(` `)}async function B(e){if(!R)return{stdout:``,stderr:`exec: shell bridge not available
233
- `,exitCode:127};try{return await R(e)}catch(e){return{stdout:``,stderr:`exec: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function ye(e,t){let n=await B(ve(e,t));return{stdout:n.stdout||n.stderr,exitCode:n.exitCode}}async function be(e,t){let n=await pe(B,e,t);if(e===`fetch`){let e=n,t=atob(e.bodyBase64),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return{...e,body:new TextDecoder(`utf-8`).decode(r)}}return n}var V=new WeakMap;function H(e,t){try{e.postMessage({type:`dip-device-event`,channel:`hid:inputreport`,payload:t},`*`)}catch{}}async function xe(e,t){let n=V.get(e);if(n||(n=new Map,V.set(e,n)),n.has(t))return;let r=await f(c(),t,n=>{let r=n.bytes instanceof Uint8Array?n.bytes:new Uint8Array(n.bytes);H(e,{handle:t,reportId:n.reportId,data:r})});n.set(t,r)}async function Se(e,t){let n=V.get(e);if(!n)return;let r=n.get(t);if(r){n.delete(t);try{await Promise.resolve(r())}catch{}}n.size===0&&V.delete(e)}function U(e){let t=V.get(e);if(t){for(let e of t.values())try{Promise.resolve(e()).catch(()=>{})}catch{}V.delete(e)}}function Ce(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(Array.isArray(e))return new Uint8Array(e);throw Error(`expected Uint8Array, ArrayBuffer, or number[]`)}async function we(e,t,n){let r=c();switch(t){case`list`:{let e=s();if(!e)throw Error(`WebHID is unavailable in this browser`);return ne(r,e)}case`request`:{let e=s();if(!e)throw Error(`WebHID is unavailable in this browser`);return re(r,e,n[0]??[])}case`info`:return ae(r,n[0]);case`open`:{let t=n[0];return await h(r,t),await xe(e,t),{ok:!0}}case`close`:{let t=n[0];return await Se(e,t),await oe(r,t),{ok:!0}}case`sendReport`:{let e=n[0],t=n[1],i=Ce(n[2]),a=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);return await p(r,e,t,a),{ok:!0}}default:throw Error(`hid: unknown op '${t}'`)}}async function Te(e,t){let n=l();switch(e){case`list`:{let e=u();if(!e)throw Error(`Web Serial is unavailable in this browser`);return ee(n,e)}case`request`:{let e=u();if(!e)throw Error(`Web Serial is unavailable in this browser`);return d(n,e,t[0]??[])}case`info`:return m(n,t[0]);case`open`:{let e=t[0],r=t[1]??{baudRate:9600};return await te(n,e,r),{ok:!0}}case`close`:return await de(n,t[0]),{ok:!0};default:throw Error(`serial: unknown op '${e}'`)}}async function Ee(e,t){let n=fe();switch(e){case`list`:{let e=g();if(!e)throw Error(`WebUSB is unavailable in this browser`);return le(n,e)}case`request`:{let e=g();if(!e)throw Error(`WebUSB is unavailable in this browser`);return ue(n,e,t[0]??[])}case`info`:return se(n,t[0]);case`open`:return await ie(n,t[0]),{ok:!0};case`close`:return await ce(n,t[0]),{ok:!0};default:throw Error(`usb: unknown op '${e}'`)}}async function De(e,t,n,r){switch(t){case`hid`:return we(e,n,r);case`serial`:return Te(n,r);case`usb`:return Ee(n,r);default:throw Error(`unknown device channel '${t}'`)}}async function W(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!O.has(e))return n({type:`dip-device-op-response`,error:`device access not allowed for this dip`}),!0;let r=t.channel;if(r!==`hid`&&r!==`serial`&&r!==`usb`)return n({type:`dip-device-op-response`,error:`unknown device channel '${r}'`}),!0;try{n({type:`dip-device-op-response`,result:await De(e,r,typeof t.op==`string`?t.op:``,Array.isArray(t.args)?t.args:[])})}catch(e){n({type:`dip-device-op-response`,error:e instanceof Error?e.message:String(e)})}return!0}async function G(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!O.has(e))return n({type:`${t.type}-response`,error:`exec not allowed for this dip`}),!0;if(t.type===`dip-exec`)return n({type:`dip-exec-response`,result:await B(typeof t.cmd==`string`?t.cmd:``)}),!0;if(t.type===`dip-agent`)return n({type:`dip-agent-response`,result:await ye(typeof t.prompt==`string`?t.prompt:``,t.opts)}),!0;if(t.type===`dip-jsh`){try{n({type:`dip-jsh-response`,result:await be(typeof t.op==`string`?t.op:``,Array.isArray(t.args)?t.args:[])})}catch(e){n({type:`dip-jsh-response`,error:e instanceof Error?e.message:String(e)})}return!0}return!1}function K(e,t,r,a=!1){let o=F(t,!1,a);if(b)return Ne(e,o,r,a);let s=document.createElement(`iframe`);s.setAttribute(`sandbox`,`allow-scripts allow-same-origin`),s.style.cssText=`width:100%;border:none;overflow:hidden;display:block;`,s.srcdoc=o,e.appendChild(s),s.contentWindow&&(y(s.contentWindow),I.add(s.contentWindow),a&&O.add(s.contentWindow)),s.addEventListener(`load`,()=>{y(s.contentWindow),s.contentWindow&&(I.add(s.contentWindow),a&&O.add(s.contentWindow)),i()&&n(s)},{once:!0});let c=e=>{if(e.source!==s.contentWindow)return;let t=e.data;t?.type&&(t.type===`dip-lick`?r(t.action,t.data):t.type===`dip-height`?s.style.height=t.height+`px`:t.type===`dip-open-link`?J(t.url):t.type===`dip-picker-action`?Z(t,r):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?q(s.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?G(s.contentWindow,t):t.type===`dip-device-op`&&W(s.contentWindow,t))};window.addEventListener(`message`,c);let l=null;if(i()&&typeof IntersectionObserver<`u`){let e=!1,t=new IntersectionObserver(r=>{if(r[r.length-1].isIntersecting){if(e){e=!1;return}t.unobserve(s),n(s,()=>{e=!0,t.observe(s)})}});l=t,t.observe(s)}return{dispose(){l?.disconnect(),window.removeEventListener(`message`,c),_(s.contentWindow),s.contentWindow&&(I.delete(s.contentWindow),O.delete(s.contentWindow),U(s.contentWindow)),s.remove()}}}async function q(e,t){if(!e||typeof t.id!=`number`)return!1;let n=typeof t.path==`string`?t.path:``,r=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!O.has(e))return r({type:`${t.type}-response`,error:`VFS access not allowed for this dip`}),!0;if(!D(n))return r({type:`${t.type}-response`,error:`VFS path not allowed: ${n}`}),!0;if(t.type===`dip-readfile`){let e=await C(n,!0);return e===null?(r({type:`dip-readfile-response`,error:`Read failed`}),!0):(r({type:`dip-readfile-response`,content:typeof e==`string`?e:new TextDecoder().decode(e)}),!0)}if(t.type===`dip-exists`)return r({type:`dip-exists-response`,exists:await C(n,!0)!==null}),!0;if(t.type===`dip-stat`){let e=await C(n,!1);return e===null?(r({type:`dip-stat-response`,error:`Stat failed`}),!0):(r({type:`dip-stat-response`,stat:{isFile:!0,isDirectory:!1,size:typeof e==`string`?e.length:e.byteLength,mtimeMs:0}}),!0)}return!1}function J(e){if(!(typeof e!=`string`||!e)&&/^(https?:|mailto:)/i.test(e))try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function Y(e,t){let n=[],r=e.querySelectorAll(`pre > code.language-shtml`);for(let e of r){let r=e.parentElement,i=e.textContent??``,a=document.createElement(`div`);a.className=`msg__dip`,r.replaceWith(a),n.push(K(a,i,t,!1))}let i=e.querySelectorAll(`img[src$=".shtml"]`);for(let e of i){let r=e.getAttribute(`src`);if(!r)continue;let i=document.createElement(`div`);i.className=`msg__dip`,e.alt&&i.setAttribute(`title`,e.alt),e.replaceWith(i);let a=new AbortController,o=null,s=!1;n.push({dispose(){s=!0,a.abort(),o&&=(o.dispose(),null)}});let c=r.startsWith(`/`),l=typeof navigator<`u`&&!!navigator.serviceWorker?.controller,u=c?`/preview${r}`:r,d=async()=>{if(c&&!l)return x(r,a.signal);let e;try{e=await fetch(u,{signal:a.signal})}catch(e){if(e?.name===`AbortError`)throw e;if(c)return x(r,a.signal);throw e}if(e.ok)return e.text();if(c)return x(r,a.signal);throw Error(`HTTP ${e.status}`)},f=c&&E(r);d().then(e=>{s||!i.isConnected||(o=K(i,e,t,f))}).catch(e=>{s||e?.name===`AbortError`||(i.textContent=`Failed to load dip: ${r}`,i.style.cssText=`padding:8px;font-size:12px;color:var(--s2-negative);font-family:var(--s2-font-mono)`)})}return n}function X(e){for(let t of e)try{t.dispose()}catch{}e.length=0}async function Z(e,t){let n=he(e.data);if(b){await Oe(e.picker,e.action,n,t);return}switch(e.picker){case`directory`:await ke(e.action,t);return;case`usb-device`:await Ae(e.action,n,t);return;case`serial-port`:await je(e.action,n,t);return;case`hid-device`:await Me(e.action,n,t);return;default:t(e.action,e.data);return}}async function Oe(e,n,r,i){try{switch(e){case`directory`:{let{openMountPickerPopup:e}=await t(async()=>{let{openMountPickerPopup:e}=await import(`./mount-picker-popup--ijSfN8u.js`);return{openMountPickerPopup:e}},__vite__mapDeps([0,1,2,3])),r=await e();r.cancelled?i(n,{cancelled:!0}):r.error?i(n,{error:r.error}):r.idbKey?i(n,{handleInIdb:!0,idbKey:r.idbKey,dirName:r.dirName??``}):i(n,{error:`mount picker returned no handle key`});return}case`usb-device`:{let{openUsbPickerPopup:e}=await t(async()=>{let{openUsbPickerPopup:e}=await import(`./usb-picker-Cbm0jfjl.js`);return{openUsbPickerPopup:e}},__vite__mapDeps([4,2,3])),a=await e(r);`cancelled`in a?i(n,{cancelled:!0}):`error`in a?i(n,{error:a.error}):i(n,{granted:!0,info:a.info});return}case`serial-port`:{let{openSerialPickerPopup:e}=await t(async()=>{let{openSerialPickerPopup:e}=await import(`./serial-picker-BQF_Eitc.js`);return{openSerialPickerPopup:e}},__vite__mapDeps([5,2,3])),a=await e(r);`cancelled`in a?i(n,{cancelled:!0}):`error`in a?i(n,{error:a.error}):i(n,{granted:!0,info:a.info});return}case`hid-device`:{let{openHidPickerPopup:e}=await t(async()=>{let{openHidPickerPopup:e}=await import(`./hid-picker-sFJ8vzUj.js`);return{openHidPickerPopup:e}},__vite__mapDeps([6,2,3])),a=await e(r);`cancelled`in a?i(n,{cancelled:!0}):`error`in a?i(n,{error:a.error}):i(n,{granted:!0,info:a.info});return}default:i(n,{error:`unknown picker kind: ${e??`(none)`}`});return}}catch(e){i(n,{error:e instanceof Error?e.message:String(e)})}}async function Q(e,t){let n=o();if(!n)return null;let r={current:null},i=t=>{let n=t.detail;n.kind===e&&(r.current=n)};n.addEventListener(`slicc-permission-deny`,i);try{let i=await n.request(e,t);if(i)return{ok:!0,grant:i};let a=r.current;return{ok:!1,reason:a?.reason??`error`,...a?.message?{message:a.message}:{}}}finally{n.removeEventListener(`slicc-permission-deny`,i)}}function $(e,t,n,r){if(t.reason===`cancelled`){r(e,{cancelled:!0});return}if(t.reason===`unavailable`){r(e,{error:n});return}r(e,{error:t.message??`unknown error`})}async function ke(e,n){let r=await Q(`filesystem`);if(!r){n(e,{error:`File System Access API not available`});return}if(!r.ok){$(e,r,`File System Access API not available`,n);return}let i=r.grant.handle,a=`pendingMount:dip-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{let{storePendingHandle:e}=await t(async()=>{let{storePendingHandle:e}=await import(`./mount-picker-popup--ijSfN8u.js`);return{storePendingHandle:e}},__vite__mapDeps([0,1,2,3]));await e(a,i)}catch(t){n(e,{error:`failed to store directory handle: ${t instanceof Error?t.message:String(t)}`});return}n(e,{handleInIdb:!0,idbKey:a,dirName:i.name})}async function Ae(e,n,r){let i=await Q(`usb`,{filters:n});if(!i){r(e,{error:`WebUSB is not available`});return}if(!i.ok){$(e,i,`WebUSB is not available`,r);return}let a=i.grant,{getSharedUsbRegistry:o,deviceToInfo:s}=await t(async()=>{let{getSharedUsbRegistry:e,deviceToInfo:t}=await import(`./usb-device-registry-DmUBqrA-.js`).then(e=>e.a);return{getSharedUsbRegistry:e,deviceToInfo:t}},__vite__mapDeps([7,8])),c=o().register(a.device);r(e,{granted:!0,handle:c,info:s(c,a.device)})}async function je(e,n,r){let i=await Q(`serial`,n.length?{filters:n}:void 0);if(!i){r(e,{error:`Web Serial is not available`});return}if(!i.ok){$(e,i,`Web Serial is not available`,r);return}let a=i.grant,o=await t(()=>import(`./serial-port-registry-CCqklAEr.js`).then(e=>e.o),__vite__mapDeps([9,8])),s=o.getSharedSerialRegistry(),c=s.register(a.port),l=s.get(c);r(e,{granted:!0,handle:c,info:l?o.deviceToInfo(c,l):{handle:c}})}async function Me(e,n,r){let i=await Q(`hid`,{filters:n});if(!i){r(e,{error:`WebHID is not available`});return}if(!i.ok){$(e,i,`WebHID is not available`,r);return}let a=i.grant,{getSharedHidRegistry:o,hidDeviceToInfo:s}=await t(async()=>{let{getSharedHidRegistry:e,hidDeviceToInfo:t}=await import(`./hid-device-registry-B2R-0rNt.js`).then(e=>e.a);return{getSharedHidRegistry:e,hidDeviceToInfo:t}},__vite__mapDeps([10,8])),c=o(),l=a.devices.map(e=>{let t=c.register(e);return s(t,e)}),u=l[0];r(e,{granted:!0,handle:u.handle,info:u,devices:l})}function Ne(e,t,n,r=!1){let i=document.createElement(`iframe`);i.src=chrome.runtime.getURL(`sprinkle-sandbox.html`),i.style.cssText=`width:100%;border:none;overflow:hidden;display:block;`,e.appendChild(i);let a=e=>{if(e.source!==i.contentWindow)return;let t=e.data;t?.type&&(t.type===`dip-lick`?n(t.action,t.data):t.type===`dip-height`?i.style.height=t.height+`px`:t.type===`dip-open-link`?J(t.url):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?q(i.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?G(i.contentWindow,t):t.type===`dip-device-op`?W(i.contentWindow,t):t.type===`dip-picker-action`&&Z(t,n))};return window.addEventListener(`message`,a),i.addEventListener(`load`,()=>{y(i.contentWindow),i.contentWindow&&(I.add(i.contentWindow),r&&O.add(i.contentWindow)),i.contentWindow?.postMessage({type:`dip-render`,srcdoc:t,isLight:v()},`*`)},{once:!0}),{dispose(){window.removeEventListener(`message`,a),_(i.contentWindow),i.contentWindow&&(I.delete(i.contentWindow),O.delete(i.contentWindow),U(i.contentWindow)),i.remove()}}}export{K as a,Y as i,me as n,X as r,L as t};
233
+ `,exitCode:127};try{return await R(e)}catch(e){return{stdout:``,stderr:`exec: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function ye(e,t){let n=await B(ve(e,t));return{stdout:n.stdout||n.stderr,exitCode:n.exitCode}}async function be(e,t){let n=await pe(B,e,t);if(e===`fetch`){let e=n,t=atob(e.bodyBase64),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return{...e,body:new TextDecoder(`utf-8`).decode(r)}}return n}var V=new WeakMap;function H(e,t){try{e.postMessage({type:`dip-device-event`,channel:`hid:inputreport`,payload:t},`*`)}catch{}}async function xe(e,t){let n=V.get(e);if(n||(n=new Map,V.set(e,n)),n.has(t))return;let r=await f(c(),t,n=>{let r=n.bytes instanceof Uint8Array?n.bytes:new Uint8Array(n.bytes);H(e,{handle:t,reportId:n.reportId,data:r})});n.set(t,r)}async function Se(e,t){let n=V.get(e);if(!n)return;let r=n.get(t);if(r){n.delete(t);try{await Promise.resolve(r())}catch{}}n.size===0&&V.delete(e)}function U(e){let t=V.get(e);if(t){for(let e of t.values())try{Promise.resolve(e()).catch(()=>{})}catch{}V.delete(e)}}function Ce(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(Array.isArray(e))return new Uint8Array(e);throw Error(`expected Uint8Array, ArrayBuffer, or number[]`)}async function we(e,t,n){let r=c();switch(t){case`list`:{let e=s();if(!e)throw Error(`WebHID is unavailable in this browser`);return ne(r,e)}case`request`:{let e=s();if(!e)throw Error(`WebHID is unavailable in this browser`);return re(r,e,n[0]??[])}case`info`:return ae(r,n[0]);case`open`:{let t=n[0];return await h(r,t),await xe(e,t),{ok:!0}}case`close`:{let t=n[0];return await Se(e,t),await oe(r,t),{ok:!0}}case`sendReport`:{let e=n[0],t=n[1],i=Ce(n[2]),a=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);return await p(r,e,t,a),{ok:!0}}default:throw Error(`hid: unknown op '${t}'`)}}async function Te(e,t){let n=l();switch(e){case`list`:{let e=u();if(!e)throw Error(`Web Serial is unavailable in this browser`);return ee(n,e)}case`request`:{let e=u();if(!e)throw Error(`Web Serial is unavailable in this browser`);return d(n,e,t[0]??[])}case`info`:return m(n,t[0]);case`open`:{let e=t[0],r=t[1]??{baudRate:9600};return await te(n,e,r),{ok:!0}}case`close`:return await de(n,t[0]),{ok:!0};default:throw Error(`serial: unknown op '${e}'`)}}async function Ee(e,t){let n=fe();switch(e){case`list`:{let e=g();if(!e)throw Error(`WebUSB is unavailable in this browser`);return le(n,e)}case`request`:{let e=g();if(!e)throw Error(`WebUSB is unavailable in this browser`);return ue(n,e,t[0]??[])}case`info`:return se(n,t[0]);case`open`:return await ie(n,t[0]),{ok:!0};case`close`:return await ce(n,t[0]),{ok:!0};default:throw Error(`usb: unknown op '${e}'`)}}async function De(e,t,n,r){switch(t){case`hid`:return we(e,n,r);case`serial`:return Te(n,r);case`usb`:return Ee(n,r);default:throw Error(`unknown device channel '${t}'`)}}async function W(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!O.has(e))return n({type:`dip-device-op-response`,error:`device access not allowed for this dip`}),!0;let r=t.channel;if(r!==`hid`&&r!==`serial`&&r!==`usb`)return n({type:`dip-device-op-response`,error:`unknown device channel '${r}'`}),!0;try{n({type:`dip-device-op-response`,result:await De(e,r,typeof t.op==`string`?t.op:``,Array.isArray(t.args)?t.args:[])})}catch(e){n({type:`dip-device-op-response`,error:e instanceof Error?e.message:String(e)})}return!0}async function G(e,t){if(!e||typeof t.id!=`number`)return!1;let n=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!O.has(e))return n({type:`${t.type}-response`,error:`exec not allowed for this dip`}),!0;if(t.type===`dip-exec`)return n({type:`dip-exec-response`,result:await B(typeof t.cmd==`string`?t.cmd:``)}),!0;if(t.type===`dip-agent`)return n({type:`dip-agent-response`,result:await ye(typeof t.prompt==`string`?t.prompt:``,t.opts)}),!0;if(t.type===`dip-jsh`){try{n({type:`dip-jsh-response`,result:await be(typeof t.op==`string`?t.op:``,Array.isArray(t.args)?t.args:[])})}catch(e){n({type:`dip-jsh-response`,error:e instanceof Error?e.message:String(e)})}return!0}return!1}function K(e,t,i,a=!1){let o=F(t,!1,a);if(b)return Ne(e,o,i,a);let s=document.createElement(`iframe`);s.setAttribute(`sandbox`,`allow-scripts allow-same-origin`),s.style.cssText=`width:100%;border:none;overflow:hidden;display:block;`,s.srcdoc=o,e.appendChild(s),s.contentWindow&&(y(s.contentWindow),I.add(s.contentWindow),a&&O.add(s.contentWindow)),s.addEventListener(`load`,()=>{y(s.contentWindow),s.contentWindow&&(I.add(s.contentWindow),a&&O.add(s.contentWindow)),r()&&n(s)},{once:!0});let c=e=>{if(e.source!==s.contentWindow)return;let t=e.data;t?.type&&(t.type===`dip-lick`?i(t.action,t.data):t.type===`dip-height`?s.style.height=t.height+`px`:t.type===`dip-open-link`?J(t.url):t.type===`dip-picker-action`?Z(t,i):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?q(s.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?G(s.contentWindow,t):t.type===`dip-device-op`&&W(s.contentWindow,t))};window.addEventListener(`message`,c);let l=null;if(r()&&typeof IntersectionObserver<`u`){let e=!1,t=new IntersectionObserver(r=>{if(r[r.length-1].isIntersecting){if(e){e=!1;return}t.unobserve(s),n(s,()=>{e=!0,t.observe(s)})}});l=t,t.observe(s)}return{dispose(){l?.disconnect(),window.removeEventListener(`message`,c),_(s.contentWindow),s.contentWindow&&(I.delete(s.contentWindow),O.delete(s.contentWindow),U(s.contentWindow)),s.remove()}}}async function q(e,t){if(!e||typeof t.id!=`number`)return!1;let n=typeof t.path==`string`?t.path:``,r=n=>{try{e.postMessage({...n,id:t.id},`*`)}catch{}};if(!O.has(e))return r({type:`${t.type}-response`,error:`VFS access not allowed for this dip`}),!0;if(!D(n))return r({type:`${t.type}-response`,error:`VFS path not allowed: ${n}`}),!0;if(t.type===`dip-readfile`){let e=await C(n,!0);return e===null?(r({type:`dip-readfile-response`,error:`Read failed`}),!0):(r({type:`dip-readfile-response`,content:typeof e==`string`?e:new TextDecoder().decode(e)}),!0)}if(t.type===`dip-exists`)return r({type:`dip-exists-response`,exists:await C(n,!0)!==null}),!0;if(t.type===`dip-stat`){let e=await C(n,!1);return e===null?(r({type:`dip-stat-response`,error:`Stat failed`}),!0):(r({type:`dip-stat-response`,stat:{isFile:!0,isDirectory:!1,size:typeof e==`string`?e.length:e.byteLength,mtimeMs:0}}),!0)}return!1}function J(e){if(!(typeof e!=`string`||!e)&&/^(https?:|mailto:)/i.test(e))try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function Y(e,t){let n=[],r=e.querySelectorAll(`pre > code.language-shtml`);for(let e of r){let r=e.parentElement,i=e.textContent??``,a=document.createElement(`div`);a.className=`msg__dip`,r.replaceWith(a),n.push(K(a,i,t,!1))}let i=e.querySelectorAll(`img[src$=".shtml"]`);for(let e of i){let r=e.getAttribute(`src`);if(!r)continue;let i=document.createElement(`div`);i.className=`msg__dip`,e.alt&&i.setAttribute(`title`,e.alt),e.replaceWith(i);let a=new AbortController,o=null,s=!1;n.push({dispose(){s=!0,a.abort(),o&&=(o.dispose(),null)}});let c=r.startsWith(`/`),l=typeof navigator<`u`&&!!navigator.serviceWorker?.controller,u=c?`/preview${r}`:r,d=async()=>{if(c&&!l)return x(r,a.signal);let e;try{e=await fetch(u,{signal:a.signal})}catch(e){if(e?.name===`AbortError`)throw e;if(c)return x(r,a.signal);throw e}if(e.ok)return e.text();if(c)return x(r,a.signal);throw Error(`HTTP ${e.status}`)},f=c&&E(r);d().then(e=>{s||!i.isConnected||(o=K(i,e,t,f))}).catch(e=>{s||e?.name===`AbortError`||(i.textContent=`Failed to load dip: ${r}`,i.style.cssText=`padding:8px;font-size:12px;color:var(--s2-negative);font-family:var(--s2-font-mono)`)})}return n}function X(e){for(let t of e)try{t.dispose()}catch{}e.length=0}async function Z(e,t){let n=he(e.data);if(b){await Oe(e.picker,e.action,n,t);return}switch(e.picker){case`directory`:await ke(e.action,t);return;case`usb-device`:await Ae(e.action,n,t);return;case`serial-port`:await je(e.action,n,t);return;case`hid-device`:await Me(e.action,n,t);return;default:t(e.action,e.data);return}}async function Oe(e,n,r,i){try{switch(e){case`directory`:{let{openMountPickerPopup:e}=await t(async()=>{let{openMountPickerPopup:e}=await import(`./mount-picker-popup--ijSfN8u.js`);return{openMountPickerPopup:e}},__vite__mapDeps([0,1,2,3])),r=await e();r.cancelled?i(n,{cancelled:!0}):r.error?i(n,{error:r.error}):r.idbKey?i(n,{handleInIdb:!0,idbKey:r.idbKey,dirName:r.dirName??``}):i(n,{error:`mount picker returned no handle key`});return}case`usb-device`:{let{openUsbPickerPopup:e}=await t(async()=>{let{openUsbPickerPopup:e}=await import(`./usb-picker-Cbm0jfjl.js`);return{openUsbPickerPopup:e}},__vite__mapDeps([4,2,3])),a=await e(r);`cancelled`in a?i(n,{cancelled:!0}):`error`in a?i(n,{error:a.error}):i(n,{granted:!0,info:a.info});return}case`serial-port`:{let{openSerialPickerPopup:e}=await t(async()=>{let{openSerialPickerPopup:e}=await import(`./serial-picker-BQF_Eitc.js`);return{openSerialPickerPopup:e}},__vite__mapDeps([5,2,3])),a=await e(r);`cancelled`in a?i(n,{cancelled:!0}):`error`in a?i(n,{error:a.error}):i(n,{granted:!0,info:a.info});return}case`hid-device`:{let{openHidPickerPopup:e}=await t(async()=>{let{openHidPickerPopup:e}=await import(`./hid-picker-sFJ8vzUj.js`);return{openHidPickerPopup:e}},__vite__mapDeps([6,2,3])),a=await e(r);`cancelled`in a?i(n,{cancelled:!0}):`error`in a?i(n,{error:a.error}):i(n,{granted:!0,info:a.info});return}default:i(n,{error:`unknown picker kind: ${e??`(none)`}`});return}}catch(e){i(n,{error:e instanceof Error?e.message:String(e)})}}async function Q(e,t){let n=o();if(!n)return null;let r={current:null},i=t=>{let n=t.detail;n.kind===e&&(r.current=n)};n.addEventListener(`slicc-permission-deny`,i);try{let i=await n.request(e,t);if(i)return{ok:!0,grant:i};let a=r.current;return{ok:!1,reason:a?.reason??`error`,...a?.message?{message:a.message}:{}}}finally{n.removeEventListener(`slicc-permission-deny`,i)}}function $(e,t,n,r){if(t.reason===`cancelled`){r(e,{cancelled:!0});return}if(t.reason===`unavailable`){r(e,{error:n});return}r(e,{error:t.message??`unknown error`})}async function ke(e,n){let r=await Q(`filesystem`);if(!r){n(e,{error:`File System Access API not available`});return}if(!r.ok){$(e,r,`File System Access API not available`,n);return}let i=r.grant.handle,a=`pendingMount:dip-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{let{storePendingHandle:e}=await t(async()=>{let{storePendingHandle:e}=await import(`./mount-picker-popup--ijSfN8u.js`);return{storePendingHandle:e}},__vite__mapDeps([0,1,2,3]));await e(a,i)}catch(t){n(e,{error:`failed to store directory handle: ${t instanceof Error?t.message:String(t)}`});return}n(e,{handleInIdb:!0,idbKey:a,dirName:i.name})}async function Ae(e,n,r){let i=await Q(`usb`,{filters:n});if(!i){r(e,{error:`WebUSB is not available`});return}if(!i.ok){$(e,i,`WebUSB is not available`,r);return}let a=i.grant,{getSharedUsbRegistry:o,deviceToInfo:s}=await t(async()=>{let{getSharedUsbRegistry:e,deviceToInfo:t}=await import(`./usb-device-registry-DmUBqrA-.js`).then(e=>e.a);return{getSharedUsbRegistry:e,deviceToInfo:t}},__vite__mapDeps([7,8])),c=o().register(a.device);r(e,{granted:!0,handle:c,info:s(c,a.device)})}async function je(e,n,r){let i=await Q(`serial`,n.length?{filters:n}:void 0);if(!i){r(e,{error:`Web Serial is not available`});return}if(!i.ok){$(e,i,`Web Serial is not available`,r);return}let a=i.grant,o=await t(()=>import(`./serial-port-registry-CCqklAEr.js`).then(e=>e.o),__vite__mapDeps([9,8])),s=o.getSharedSerialRegistry(),c=s.register(a.port),l=s.get(c);r(e,{granted:!0,handle:c,info:l?o.deviceToInfo(c,l):{handle:c}})}async function Me(e,n,r){let i=await Q(`hid`,{filters:n});if(!i){r(e,{error:`WebHID is not available`});return}if(!i.ok){$(e,i,`WebHID is not available`,r);return}let a=i.grant,{getSharedHidRegistry:o,hidDeviceToInfo:s}=await t(async()=>{let{getSharedHidRegistry:e,hidDeviceToInfo:t}=await import(`./hid-device-registry-B2R-0rNt.js`).then(e=>e.a);return{getSharedHidRegistry:e,hidDeviceToInfo:t}},__vite__mapDeps([10,8])),c=o(),l=a.devices.map(e=>{let t=c.register(e);return s(t,e)}),u=l[0];r(e,{granted:!0,handle:u.handle,info:u,devices:l})}function Ne(e,t,n,r=!1){let i=document.createElement(`iframe`);i.src=chrome.runtime.getURL(`sprinkle-sandbox.html`),i.style.cssText=`width:100%;border:none;overflow:hidden;display:block;`,e.appendChild(i);let a=e=>{if(e.source!==i.contentWindow)return;let t=e.data;t?.type&&(t.type===`dip-lick`?n(t.action,t.data):t.type===`dip-height`?i.style.height=t.height+`px`:t.type===`dip-open-link`?J(t.url):t.type===`dip-readfile`||t.type===`dip-exists`||t.type===`dip-stat`?q(i.contentWindow,t):t.type===`dip-exec`||t.type===`dip-agent`||t.type===`dip-jsh`?G(i.contentWindow,t):t.type===`dip-device-op`?W(i.contentWindow,t):t.type===`dip-picker-action`&&Z(t,n))};return window.addEventListener(`message`,a),i.addEventListener(`load`,()=>{y(i.contentWindow),i.contentWindow&&(I.add(i.contentWindow),r&&O.add(i.contentWindow)),i.contentWindow?.postMessage({type:`dip-render`,srcdoc:t,isLight:v()},`*`)},{once:!0}),{dispose(){window.removeEventListener(`message`,a),_(i.contentWindow),i.contentWindow&&(I.delete(i.contentWindow),O.delete(i.contentWindow),U(i.contentWindow)),i.remove()}}}export{K as a,Y as i,me as n,X as r,L as t};
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./agent-bridge-pHw1j9qj.js";import{x as n}from"./record-CUBwpX6h.js";const r=e(`directed-approval`);function i(e,t){if(e.kind===`user`)return a(`the user tier is not a directed approval`);if(e.kind===`agent`)return a(`agent approvals are not enqueued to a unit`);let r=e.unitJid;if(!t.scoops.has(r))return a(`the requesting unit is not registered`);let i=t.ownerRootOf(r);if(!i)return a(`no owning cone for the requesting unit`);let o=e.kind===`cone`?i:[...t.scoops.values()].find(t=>t.parentJid===i.jid&&(t.name===e.scoopName||t.folder===e.scoopName));return o?n(o).canResolveApprovals?{ok:!0,requesterJid:r,approver:o}:a(`the named approver cannot resolve approvals`):a(`delegated approver not found under this cone`)}function a(e){return r.warn(`Directed approval failing closed`,{reason:e}),{ok:!1,reason:e}}const o={decision:`deny`};async function s(e,n){let a=e.approver;if(a?.kind===`agent`){let i=globalThis[t];if(!i)return r.warn(`No agent bridge available for an approver agent — denying`),o;let{approverRunnerFor:s}=await import(`./approver-agent-CDzqjgJM.js`),c=n.getSharedFs(),l=await s({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!c)return null;try{let t=await c.readFile(e,{encoding:`utf-8`});return typeof t==`string`?t:null}catch{return null}},findUnit:e=>{let t=n.scoops.get(e);return t?{workspace:n.workspaceFor(t),folder:t.folder}:void 0}})({kind:e.kind===`guest-tool`?`guest-tool`:`guest-message`,requester:e.requester??`an unidentified requester`,detail:e.detail},a.unitJid);return r.info(`Approver agent verdict`,{decision:l.decision,reason:l.reason}),l.decision===`allow`?{decision:`allow`}:o}if(a&&a.kind!==`user`){let t=i(a,n);return t.ok?n.enqueue(t.requesterJid,e,{approver:t.approver}):o}return n.approveAsUser(e)}export{s as runDirectedApproval};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./agent-bridge-Bgb7xaDh.js";import{x as n}from"./record-CUBwpX6h.js";const r=e(`directed-approval`);function i(e,t){if(e.kind===`user`)return a(`the user tier is not a directed approval`);if(e.kind===`agent`)return a(`agent approvals are not enqueued to a unit`);let r=e.unitJid;if(!t.scoops.has(r))return a(`the requesting unit is not registered`);let i=t.ownerRootOf(r);if(!i)return a(`no owning cone for the requesting unit`);let o=e.kind===`cone`?i:[...t.scoops.values()].find(t=>t.parentJid===i.jid&&(t.name===e.scoopName||t.folder===e.scoopName));return o?n(o).canResolveApprovals?{ok:!0,requesterJid:r,approver:o}:a(`the named approver cannot resolve approvals`):a(`delegated approver not found under this cone`)}function a(e){return r.warn(`Directed approval failing closed`,{reason:e}),{ok:!1,reason:e}}const o={decision:`deny`};async function s(e,n){let a=e.approver;if(a?.kind===`agent`){let i=globalThis[t];if(!i)return r.warn(`No agent bridge available for an approver agent — denying`),o;let{approverRunnerFor:s}=await import(`./approver-agent-CDzqjgJM.js`),c=n.getSharedFs(),l=await s({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!c)return null;try{let t=await c.readFile(e,{encoding:`utf-8`});return typeof t==`string`?t:null}catch{return null}},findUnit:e=>{let t=n.scoops.get(e);return t?{workspace:n.workspaceFor(t),folder:t.folder}:void 0}})({kind:e.kind===`guest-tool`?`guest-tool`:`guest-message`,requester:e.requester??`an unidentified requester`,detail:e.detail},a.unitJid);return r.info(`Approver agent verdict`,{decision:l.decision,reason:l.reason}),l.decision===`allow`?{decision:`allow`}:o}if(a&&a.kind!==`user`){let t=i(a,n);return t.ok?n.enqueue(t.requesterJid,e,{approver:t.approver}):o}return n.approveAsUser(e)}export{s as runDirectedApproval};