sliccy 3.14.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +1 -1
  2. package/dist/ui/assets/adobe-Ao50jPgP.js +2 -0
  3. package/dist/ui/assets/{adobe-D3TSV3kT.js → adobe-CE1Bs7rN.js} +1 -1
  4. package/dist/ui/assets/agent-bridge-BBzAl1L_.js +1 -0
  5. package/dist/ui/assets/{agent-message-to-chat-CZ3vc3bx.js → agent-message-to-chat-DRR_n3Cd.js} +1 -1
  6. package/dist/ui/assets/{anthropic-CofiZ926.js → anthropic-BOzXuoM3.js} +4 -4
  7. package/dist/ui/assets/{anthropic-CrL-9fq_.js → anthropic-Dpnd1zvp.js} +2 -2
  8. package/dist/ui/assets/{apps-CnC39rsl.js → apps-CFqoQvbx.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-dfn0k8O2.js → azure-openai-CDpywqUS.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-H9tUkZch.js → azure-openai-cgi4Kkfa.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-responses-4xLTbaxa.js → azure-openai-responses-Be1SnJhA.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-responses-CBDYvga9.js → azure-openai-responses-DGyHiI9b.js} +1 -1
  13. package/dist/ui/assets/{biome_wasm-fowPz8Sr.js → biome_wasm-CCl4-by8.js} +1 -1
  14. package/dist/ui/assets/{bsh-watchdog-fE5_b2Sq.js → bsh-watchdog-CtN1RuOo.js} +1 -1
  15. package/dist/ui/assets/{cdp-CgZFCzZg.js → cdp-B2PbN6cJ.js} +4 -4
  16. package/dist/ui/assets/cdp-ws-page-bridge-BLnWRj3d.js +1 -0
  17. package/dist/ui/assets/{common-FClSnnke.js → common-D0tS4JvG.js} +1 -1
  18. package/dist/ui/assets/cost-command-CVFVVo3Y.js +1 -0
  19. package/dist/ui/assets/{es-BRxUc8Vk.js → es-CSl2NTTK.js} +5 -5
  20. package/dist/ui/assets/{follower-sprinkle-bridge-CMfDukox.js → follower-sprinkle-bridge-CdcQ2GYa.js} +1 -1
  21. package/dist/ui/assets/github-CsLVmRjl.js +2 -0
  22. package/dist/ui/assets/github-DBqo8Qbh.js +1 -0
  23. package/dist/ui/assets/github-copilot-BhCBOl5C.js +2 -0
  24. package/dist/ui/assets/{github-copilot-DRoJFAqF.js → github-copilot-DnyK8Sst.js} +1 -1
  25. package/dist/ui/assets/{google-CkZKyXlq.js → google-DVlDjlsv.js} +1 -1
  26. package/dist/ui/assets/google-Yi7CN08j.js +1 -0
  27. package/dist/ui/assets/{google-shared-Bp7lj-mL.js → google-shared-DdWQkQdM.js} +3 -3
  28. package/dist/ui/assets/{google-shared-COqJ9Mzr.js → google-shared-WXij02uY.js} +1 -1
  29. package/dist/ui/assets/{google-vertex-uoM62NXW.js → google-vertex-B6bpaSVL.js} +1 -1
  30. package/dist/ui/assets/{google-vertex-DUBYT0hU.js → google-vertex-BLJOblZE.js} +1 -1
  31. package/dist/ui/assets/{intercepted-oauth-C7BvcVue.js → intercepted-oauth-B6zxgQQV.js} +1 -1
  32. package/dist/ui/assets/js-realm-worker-BnCys20m.js +5 -0
  33. package/dist/ui/assets/{kernel-worker-DAzmsd_P.js → kernel-worker-B_VVPiix.js} +981 -976
  34. package/dist/ui/assets/{lick-ws-bridge-DodmEt0x.js → lick-ws-bridge-nuf5FOHB.js} +1 -1
  35. package/dist/ui/assets/{local-llm-CHt3tYD7.js → local-llm-DGirMEN6.js} +2 -2
  36. package/dist/ui/assets/magick-wasm-CC7NYyop.js +1 -0
  37. package/dist/ui/assets/{main-D5X3QDGB.js → main-QvcnxvtS.js} +137 -137
  38. package/dist/ui/assets/{mistral-DPYBk73s.js → mistral-Bh1GJbf4.js} +2 -2
  39. package/dist/ui/assets/{mistral-BKvYXyPT.js → mistral-CaxcS-53.js} +2 -2
  40. package/dist/ui/assets/{nodejs-DxYbOAAg.js → nodejs-BV7kLKbo.js} +1 -1
  41. package/dist/ui/assets/{nuke-command-BQafnkbJ.js → nuke-command-BLiX1He8.js} +1 -1
  42. package/dist/ui/assets/{oauth-D7OIwNl9.js → oauth-DDRapyi2.js} +1 -1
  43. package/dist/ui/assets/oauth-bootstrap-BfMlMOez.js +2 -0
  44. package/dist/ui/assets/{oauth-service-OqxBClV5.js → oauth-service-BIFoyZr9.js} +1 -1
  45. package/dist/ui/assets/oauth-service-DbDCWx7N.js +1 -0
  46. package/dist/ui/assets/offscreen-client-j2kdvCUZ.js +1 -0
  47. package/dist/ui/assets/onboarding-orchestrator-Bf46cpkt.js +1 -0
  48. package/dist/ui/assets/openai-codex-BJyWKtaP.js +1 -0
  49. package/dist/ui/assets/openai-codex-D6S4-dHf.js +1 -0
  50. package/dist/ui/assets/{openai-codex-responses-Cu_vWr0H.js → openai-codex-responses-B3W7YrEb.js} +2 -2
  51. package/dist/ui/assets/{openai-codex-responses-BREco7pI.js → openai-codex-responses-CObQU668.js} +1 -1
  52. package/dist/ui/assets/{openai-completions-Ci7sD1x5.js → openai-completions-flDaecKI.js} +2 -2
  53. package/dist/ui/assets/openai-responses-Ds-HVP9y.js +1 -0
  54. package/dist/ui/assets/{openai-responses-D_vwRv5E.js → openai-responses-I8H7uEaU.js} +1 -1
  55. package/dist/ui/assets/{openai-responses-shared-Dzt049Et.js → openai-responses-shared-Bm2eSiHi.js} +1 -1
  56. package/dist/ui/assets/{openai-responses-shared-nH4CP3pN.js → openai-responses-shared-CCsAMrca.js} +4 -4
  57. package/dist/ui/assets/{openrouter-ByWpF3QR.js → openrouter-BgKegqZJ.js} +1 -1
  58. package/dist/ui/assets/{openrouter-DhbDa0RV.js → openrouter-DBnJ7Lgv.js} +1 -1
  59. package/dist/ui/assets/{panel-rpc-handlers-CJJVKyDn.js → panel-rpc-handlers-BefCNYz6.js} +1 -1
  60. package/dist/ui/assets/provider-CK0z722U.js +2 -0
  61. package/dist/ui/assets/{provider-BF3c28PT.js → provider-DGgbt705.js} +1 -1
  62. package/dist/ui/assets/provider-store-access-CCLf7kRi.js +1 -0
  63. package/dist/ui/assets/provider-store-access-CPQLutIJ.js +1 -0
  64. package/dist/ui/assets/{proxied-fetch-D5COXh2X.js → proxied-fetch-duisWF6F.js} +1 -1
  65. package/dist/ui/assets/{pyodide-CV9NAQLd.js → pyodide-DMuot7oT.js} +2 -2
  66. package/dist/ui/assets/{remote-terminal-view-C6kvlCSG.js → remote-terminal-view-BTeU52uN.js} +3 -3
  67. package/dist/ui/assets/secret-env-DiKtpIpU.js +1 -0
  68. package/dist/ui/assets/slicc-editor-C19_5HZS.js +12 -0
  69. package/dist/ui/assets/{spawn-Ceu4Eobz.js → spawn-DhHtj4w1.js} +1 -1
  70. package/dist/ui/assets/{sql-wasm-m982m9_Q.js → sql-wasm-BhN2AaSY.js} +1 -1
  71. package/dist/ui/assets/store-DHtr0thS.js +1 -0
  72. package/dist/ui/assets/{tray-leave-runtime-BPKauUzE.js → tray-leave-runtime-CL5BI1fS.js} +1 -1
  73. package/dist/ui/assets/{typescript-DAR2DYZE.js → typescript-D-sYRkTp.js} +1 -1
  74. package/dist/ui/assets/{upgrade-detection-BFH_1S02.js → upgrade-detection-Cd14niwX.js} +1 -1
  75. package/dist/ui/assets/{web-CHeaLi6o.js → web-D-HTAm7L.js} +1 -1
  76. package/dist/ui/assets/ws-subscribers-BEnP0PDu.js +1 -0
  77. package/dist/ui/assets/{xai-grok-boiAoDrf.js → xai-grok-CnXU8B16.js} +1 -1
  78. package/dist/ui/assets/{xai-grok-NOPU6OE9.js → xai-grok-Dw7pEkZb.js} +1 -1
  79. package/dist/ui/index.html +1 -1
  80. package/dist/ui/packages/webapp/index.html +1 -1
  81. package/package.json +1 -1
  82. package/dist/ui/assets/adobe-gIu_dHEG.js +0 -2
  83. package/dist/ui/assets/agent-bridge-B5pC19EY.js +0 -1
  84. package/dist/ui/assets/cost-command-Lkmo5sFk.js +0 -1
  85. package/dist/ui/assets/github-CVI9tHpF.js +0 -1
  86. package/dist/ui/assets/github-CqwY8-fW.js +0 -2
  87. package/dist/ui/assets/github-copilot-Bxa6l3W-.js +0 -2
  88. package/dist/ui/assets/google-hTg-69ln.js +0 -1
  89. package/dist/ui/assets/js-realm-worker-C2Z2nmxV.js +0 -1
  90. package/dist/ui/assets/magick-wasm-D4_CNcmL.js +0 -1
  91. package/dist/ui/assets/oauth-bootstrap-BESg8J5Z.js +0 -2
  92. package/dist/ui/assets/oauth-service-CiXJHPbX.js +0 -1
  93. package/dist/ui/assets/offscreen-client-DEBYLCUe.js +0 -1
  94. package/dist/ui/assets/onboarding-orchestrator-BK3dCmny.js +0 -1
  95. package/dist/ui/assets/openai-responses-DnXBqFVI.js +0 -1
  96. package/dist/ui/assets/provider-m0UE-mDj.js +0 -2
  97. package/dist/ui/assets/provider-store-access-CnMVjgjB.js +0 -1
  98. package/dist/ui/assets/provider-store-access-DgGBEsNi.js +0 -1
  99. package/dist/ui/assets/secret-env-Dk00psrH.js +0 -1
  100. package/dist/ui/assets/slicc-editor-CwbowpzS.js +0 -12
  101. package/dist/ui/assets/store-Biy2Dk5S.js +0 -1
@@ -1 +1 @@
1
- import{U as e,V as t,W as n,b as r}from"./main-D5X3QDGB.js";import{t as i}from"./sanitize-unicode-DmIE6hZJ.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./google-shared-COqJ9Mzr.js";var m=`v1`,h=`gcp-vertex-credentials`,g={THINKING_LEVEL_UNSPECIFIED:c.THINKING_LEVEL_UNSPECIFIED,MINIMAL:c.MINIMAL,LOW:c.LOW,MEDIUM:c.MEDIUM,HIGH:c.HIGH},_=0,v=(n,r,i)=>{let a=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-vertex`,provider:n.provider,model:n.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()};try{let o=T(i),c=o?x(n,o,i?.headers):b(n,D(i),O(i),i?.headers),l=k(n,r,i),f=await i?.onPayload?.(l,n);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:t});let m=null,h=t.content,g=()=>h.length-1;for await(let r of p){t.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let n=d(e);(!m||n&&m.type!==`thinking`||!n&&m.type!==`text`)&&(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:h.length-1,content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:g(),content:m.thinking,partial:t})),n?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(m),a.push({type:`thinking_start`,contentIndex:g(),partial:t})):(m={type:`text`,text:``},t.content.push(m),a.push({type:`text_start`,contentIndex:g(),partial:t}))),m.type===`thinking`?(m.thinking+=e.text,m.thinkingSignature=u(m.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:g(),delta:e.text,partial:t})):(m.text+=e.text,m.textSignature=u(m.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:g(),delta:e.text,partial:t}))}if(e.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:g(),content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:g(),content:m.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++_}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),a.push({type:`toolcall_start`,contentIndex:g(),partial:t}),a.push({type:`toolcall_delta`,contentIndex:g(),delta:JSON.stringify(r.arguments),partial:t}),a.push({type:`toolcall_end`,contentIndex:g(),toolCall:r,partial:t})}}i?.finishReason&&(t.stopReason=s(i.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),r.usageMetadata&&(t.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(n,t.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:g(),content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:g(),content:m.thinking,partial:t})),i?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:t.stopReason,message:t}),a.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=i?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:t.stopReason,error:t}),a.end()}})(),a},y=(e,t,i)=>{let a=r(e,i,void 0);if(!i?.reasoning)return v(e,t,{...a,thinking:{enabled:!1}});let o=n(e,i.reasoning),s=o===`off`?`high`:o,c=e;return A(c)||j(c)?v(e,t,{...a,thinking:{enabled:!0,level:N(s,c)}}):v(e,t,{...a,thinking:{enabled:!0,budgetTokens:P(c,s,i.thinkingBudgets)}})};function b(e,t,n,r){return new f({vertexai:!0,project:t,location:n,apiVersion:m,httpOptions:S(e,r)})}function x(e,t,n){return new f({vertexai:!0,apiKey:t,apiVersion:m,httpOptions:S(e,n)})}function S(e,t){let n={},r=C(e.baseUrl);return r&&(n.baseUrl=r,n.baseUrlResourceScope=o.COLLECTION,w(r)&&(n.apiVersion=``)),(e.headers||t)&&(n.headers={...e.headers,...t}),Object.keys(n).length>0?n:void 0}function C(e){let t=e.trim();if(!(!t||t.includes(`{location}`)))return t}function w(e){try{return new URL(e).pathname.split(`/`).some(e=>/^v\d+(?:beta\d*)?$/.test(e))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function T(e){let t=e?.apiKey?.trim()||{}.GOOGLE_CLOUD_API_KEY?.trim();if(!(!t||t===h||E(t)))return t}function E(e){return/^<[^>]+>$/.test(e)}function D(e){let t=e?.project||{}.GOOGLE_CLOUD_PROJECT||{}.GCLOUD_PROJECT;if(!t)throw Error(`Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.`);return t}function O(e){let t=e?.location||{}.GOOGLE_CLOUD_LOCATION;if(!t)throw Error(`Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.`);return t}function k(e,t,n={}){let r=p(e,t),o={};n.temperature!==void 0&&(o.temperature=n.temperature),n.maxTokens!==void 0&&(o.maxOutputTokens=n.maxTokens);let s={...Object.keys(o).length>0&&o,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:l(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:a(n.toolChoice)}}:s.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=g[n.thinking.level],s.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=M(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);s.abortSignal=n.signal}return{model:e.id,contents:r,config:s}}function A(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function j(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function M(e){let t=e;return A(t)?{thinkingLevel:c.LOW}:j(t)?{thinkingLevel:c.MINIMAL}:{thinkingBudget:0}}function N(e,t){if(A(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function P(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{v as streamGoogleVertex,y as streamSimpleGoogleVertex};
1
+ import{G as e,K as t,U as n,b as r}from"./main-QvcnxvtS.js";import{t as i}from"./sanitize-unicode-DmIE6hZJ.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./google-shared-WXij02uY.js";var m=`v1`,h=`gcp-vertex-credentials`,g={THINKING_LEVEL_UNSPECIFIED:c.THINKING_LEVEL_UNSPECIFIED,MINIMAL:c.MINIMAL,LOW:c.LOW,MEDIUM:c.MEDIUM,HIGH:c.HIGH},_=0,v=(t,r,i)=>{let a=new n;return(async()=>{let n={role:`assistant`,content:[],api:`google-vertex`,provider:t.provider,model:t.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()};try{let o=T(i),c=o?x(t,o,i?.headers):b(t,D(i),O(i),i?.headers),l=k(t,r,i),f=await i?.onPayload?.(l,t);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:n});let m=null,h=n.content,g=()=>h.length-1;for await(let r of p){n.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let t=d(e);(!m||t&&m.type!==`thinking`||!t&&m.type!==`text`)&&(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:h.length-1,content:m.text,partial:n}):a.push({type:`thinking_end`,contentIndex:g(),content:m.thinking,partial:n})),t?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},n.content.push(m),a.push({type:`thinking_start`,contentIndex:g(),partial:n})):(m={type:`text`,text:``},n.content.push(m),a.push({type:`text_start`,contentIndex:g(),partial:n}))),m.type===`thinking`?(m.thinking+=e.text,m.thinkingSignature=u(m.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:g(),delta:e.text,partial:n})):(m.text+=e.text,m.textSignature=u(m.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:g(),delta:e.text,partial:n}))}if(e.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:g(),content:m.text,partial:n}):a.push({type:`thinking_end`,contentIndex:g(),content:m.thinking,partial:n}),null);let t=e.functionCall.id,r={type:`toolCall`,id:!t||n.content.some(e=>e.type===`toolCall`&&e.id===t)?`${e.functionCall.name}_${Date.now()}_${++_}`:t,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};n.content.push(r),a.push({type:`toolcall_start`,contentIndex:g(),partial:n}),a.push({type:`toolcall_delta`,contentIndex:g(),delta:JSON.stringify(r.arguments),partial:n}),a.push({type:`toolcall_end`,contentIndex:g(),toolCall:r,partial:n})}}i?.finishReason&&(n.stopReason=s(i.finishReason),n.content.some(e=>e.type===`toolCall`)&&(n.stopReason=`toolUse`)),r.usageMetadata&&(n.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(t,n.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:g(),content:m.text,partial:n}):a.push({type:`thinking_end`,contentIndex:g(),content:m.thinking,partial:n})),i?.signal?.aborted)throw Error(`Request was aborted`);if(n.stopReason===`aborted`||n.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:n.stopReason,message:n}),a.end()}catch(e){for(let e of n.content)`index`in e&&delete e.index;n.stopReason=i?.signal?.aborted?`aborted`:`error`,n.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:n.stopReason,error:n}),a.end()}})(),a},y=(e,n,i)=>{let a=r(e,i,void 0);if(!i?.reasoning)return v(e,n,{...a,thinking:{enabled:!1}});let o=t(e,i.reasoning),s=o===`off`?`high`:o,c=e;return A(c)||j(c)?v(e,n,{...a,thinking:{enabled:!0,level:N(s,c)}}):v(e,n,{...a,thinking:{enabled:!0,budgetTokens:P(c,s,i.thinkingBudgets)}})};function b(e,t,n,r){return new f({vertexai:!0,project:t,location:n,apiVersion:m,httpOptions:S(e,r)})}function x(e,t,n){return new f({vertexai:!0,apiKey:t,apiVersion:m,httpOptions:S(e,n)})}function S(e,t){let n={},r=C(e.baseUrl);return r&&(n.baseUrl=r,n.baseUrlResourceScope=o.COLLECTION,w(r)&&(n.apiVersion=``)),(e.headers||t)&&(n.headers={...e.headers,...t}),Object.keys(n).length>0?n:void 0}function C(e){let t=e.trim();if(!(!t||t.includes(`{location}`)))return t}function w(e){try{return new URL(e).pathname.split(`/`).some(e=>/^v\d+(?:beta\d*)?$/.test(e))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function T(e){let t=e?.apiKey?.trim()||{}.GOOGLE_CLOUD_API_KEY?.trim();if(!(!t||t===h||E(t)))return t}function E(e){return/^<[^>]+>$/.test(e)}function D(e){let t=e?.project||{}.GOOGLE_CLOUD_PROJECT||{}.GCLOUD_PROJECT;if(!t)throw Error(`Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.`);return t}function O(e){let t=e?.location||{}.GOOGLE_CLOUD_LOCATION;if(!t)throw Error(`Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.`);return t}function k(e,t,n={}){let r=p(e,t),o={};n.temperature!==void 0&&(o.temperature=n.temperature),n.maxTokens!==void 0&&(o.maxOutputTokens=n.maxTokens);let s={...Object.keys(o).length>0&&o,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:l(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:a(n.toolChoice)}}:s.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=g[n.thinking.level],s.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=M(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);s.abortSignal=n.signal}return{model:e.id,contents:r,config:s}}function A(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function j(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function M(e){let t=e;return A(t)?{thinkingLevel:c.LOW}:j(t)?{thinkingLevel:c.MINIMAL}:{thinkingBudget:0}}function N(e,t){if(A(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function P(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{v as streamGoogleVertex,y as streamSimpleGoogleVertex};
@@ -1 +1 @@
1
- import{B as e,R as t,V as n,b as r,o as i}from"./kernel-worker-DAzmsd_P.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./google-shared-Bp7lj-mL.js";const m={THINKING_LEVEL_UNSPECIFIED:c.THINKING_LEVEL_UNSPECIFIED,MINIMAL:c.MINIMAL,LOW:c.LOW,MEDIUM:c.MEDIUM,HIGH:c.HIGH};let h=0;const g=(n,r,i)=>{let a=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-vertex`,provider:n.provider,model:n.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()};try{let o=C(i),c=o?y(n,o,i?.headers):v(n,T(i),E(i),i?.headers),l=D(n,r,i),f=await i?.onPayload?.(l,n);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:t});let m=null,g=t.content,_=()=>g.length-1;for await(let r of p){t.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let n=d(e);(!m||n&&m.type!==`thinking`||!n&&m.type!==`text`)&&(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:g.length-1,content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:t})),n?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(m),a.push({type:`thinking_start`,contentIndex:_(),partial:t})):(m={type:`text`,text:``},t.content.push(m),a.push({type:`text_start`,contentIndex:_(),partial:t}))),m.type===`thinking`?(m.thinking+=e.text,m.thinkingSignature=u(m.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:e.text,partial:t})):(m.text+=e.text,m.textSignature=u(m.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:e.text,partial:t}))}if(e.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++h}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),a.push({type:`toolcall_start`,contentIndex:_(),partial:t}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(r.arguments),partial:t}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:r,partial:t})}}i?.finishReason&&(t.stopReason=s(i.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),r.usageMetadata&&(t.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(n,t.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:t})),i?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:t.stopReason,message:t}),a.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=i?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:t.stopReason,error:t}),a.end()}})(),a},_=(e,t,i)=>{let a=r(e,i,void 0);if(!i?.reasoning)return g(e,t,{...a,thinking:{enabled:!1}});let o=n(e,i.reasoning),s=o===`off`?`high`:o,c=e;return O(c)||k(c)?g(e,t,{...a,thinking:{enabled:!0,level:j(s,c)}}):g(e,t,{...a,thinking:{enabled:!0,budgetTokens:M(c,s,i.thinkingBudgets)}})};function v(e,t,n,r){return new f({vertexai:!0,project:t,location:n,apiVersion:`v1`,httpOptions:b(e,r)})}function y(e,t,n){return new f({vertexai:!0,apiKey:t,apiVersion:`v1`,httpOptions:b(e,n)})}function b(e,t){let n={},r=x(e.baseUrl);return r&&(n.baseUrl=r,n.baseUrlResourceScope=o.COLLECTION,S(r)&&(n.apiVersion=``)),(e.headers||t)&&(n.headers={...e.headers,...t}),Object.keys(n).length>0?n:void 0}function x(e){let t=e.trim();if(!(!t||t.includes(`{location}`)))return t}function S(e){try{return new URL(e).pathname.split(`/`).some(e=>/^v\d+(?:beta\d*)?$/.test(e))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function C(e){let t=e?.apiKey?.trim()||{}.GOOGLE_CLOUD_API_KEY?.trim();if(!(!t||t===`gcp-vertex-credentials`||w(t)))return t}function w(e){return/^<[^>]+>$/.test(e)}function T(e){let t=e?.project||{}.GOOGLE_CLOUD_PROJECT||{}.GCLOUD_PROJECT;if(!t)throw Error(`Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.`);return t}function E(e){let t=e?.location||{}.GOOGLE_CLOUD_LOCATION;if(!t)throw Error(`Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.`);return t}function D(e,t,n={}){let r=p(e,t),o={};n.temperature!==void 0&&(o.temperature=n.temperature),n.maxTokens!==void 0&&(o.maxOutputTokens=n.maxTokens);let s={...Object.keys(o).length>0&&o,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:l(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:a(n.toolChoice)}}:s.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=m[n.thinking.level],s.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=A(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);s.abortSignal=n.signal}return{model:e.id,contents:r,config:s}}function O(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function k(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function A(e){let t=e;return O(t)?{thinkingLevel:c.LOW}:k(t)?{thinkingLevel:c.MINIMAL}:{thinkingBudget:0}}function j(e,t){if(O(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function M(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{g as streamGoogleVertex,_ as streamSimpleGoogleVertex};
1
+ import{B as e,H as t,U as n,b as r,o as i}from"./kernel-worker-B_VVPiix.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./google-shared-DdWQkQdM.js";const m={THINKING_LEVEL_UNSPECIFIED:c.THINKING_LEVEL_UNSPECIFIED,MINIMAL:c.MINIMAL,LOW:c.LOW,MEDIUM:c.MEDIUM,HIGH:c.HIGH};let h=0;const g=(n,r,i)=>{let a=new e;return(async()=>{let e={role:`assistant`,content:[],api:`google-vertex`,provider:n.provider,model:n.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()};try{let o=C(i),c=o?y(n,o,i?.headers):v(n,T(i),E(i),i?.headers),l=D(n,r,i),f=await i?.onPayload?.(l,n);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:e});let m=null,g=e.content,_=()=>g.length-1;for await(let r of p){e.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let t of i.content.parts){if(t.text!==void 0){let n=d(t);(!m||n&&m.type!==`thinking`||!n&&m.type!==`text`)&&(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:g.length-1,content:m.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:e})),n?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},e.content.push(m),a.push({type:`thinking_start`,contentIndex:_(),partial:e})):(m={type:`text`,text:``},e.content.push(m),a.push({type:`text_start`,contentIndex:_(),partial:e}))),m.type===`thinking`?(m.thinking+=t.text,m.thinkingSignature=u(m.thinkingSignature,t.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:t.text,partial:e})):(m.text+=t.text,m.textSignature=u(m.textSignature,t.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:t.text,partial:e}))}if(t.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:e}),null);let n=t.functionCall.id,r={type:`toolCall`,id:!n||e.content.some(e=>e.type===`toolCall`&&e.id===n)?`${t.functionCall.name}_${Date.now()}_${++h}`:n,name:t.functionCall.name||``,arguments:t.functionCall.args??{},...t.thoughtSignature&&{thoughtSignature:t.thoughtSignature}};e.content.push(r),a.push({type:`toolcall_start`,contentIndex:_(),partial:e}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(r.arguments),partial:e}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:r,partial:e})}}i?.finishReason&&(e.stopReason=s(i.finishReason),e.content.some(e=>e.type===`toolCall`)&&(e.stopReason=`toolUse`)),r.usageMetadata&&(e.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},t(n,e.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:e})),i?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)`index`in t&&delete t.index;e.stopReason=i?.signal?.aborted?`aborted`:`error`,e.errorMessage=t instanceof Error?t.message:JSON.stringify(t),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a},_=(e,t,i)=>{let a=r(e,i,void 0);if(!i?.reasoning)return g(e,t,{...a,thinking:{enabled:!1}});let o=n(e,i.reasoning),s=o===`off`?`high`:o,c=e;return O(c)||k(c)?g(e,t,{...a,thinking:{enabled:!0,level:j(s,c)}}):g(e,t,{...a,thinking:{enabled:!0,budgetTokens:M(c,s,i.thinkingBudgets)}})};function v(e,t,n,r){return new f({vertexai:!0,project:t,location:n,apiVersion:`v1`,httpOptions:b(e,r)})}function y(e,t,n){return new f({vertexai:!0,apiKey:t,apiVersion:`v1`,httpOptions:b(e,n)})}function b(e,t){let n={},r=x(e.baseUrl);return r&&(n.baseUrl=r,n.baseUrlResourceScope=o.COLLECTION,S(r)&&(n.apiVersion=``)),(e.headers||t)&&(n.headers={...e.headers,...t}),Object.keys(n).length>0?n:void 0}function x(e){let t=e.trim();if(!(!t||t.includes(`{location}`)))return t}function S(e){try{return new URL(e).pathname.split(`/`).some(e=>/^v\d+(?:beta\d*)?$/.test(e))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function C(e){let t=e?.apiKey?.trim()||{}.GOOGLE_CLOUD_API_KEY?.trim();if(!(!t||t===`gcp-vertex-credentials`||w(t)))return t}function w(e){return/^<[^>]+>$/.test(e)}function T(e){let t=e?.project||{}.GOOGLE_CLOUD_PROJECT||{}.GCLOUD_PROJECT;if(!t)throw Error(`Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.`);return t}function E(e){let t=e?.location||{}.GOOGLE_CLOUD_LOCATION;if(!t)throw Error(`Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.`);return t}function D(e,t,n={}){let r=p(e,t),o={};n.temperature!==void 0&&(o.temperature=n.temperature),n.maxTokens!==void 0&&(o.maxOutputTokens=n.maxTokens);let s={...Object.keys(o).length>0&&o,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:l(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:a(n.toolChoice)}}:s.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=m[n.thinking.level],s.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=A(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);s.abortSignal=n.signal}return{model:e.id,contents:r,config:s}}function O(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function k(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function A(e){let t=e;return O(t)?{thinkingLevel:c.LOW}:k(t)?{thinkingLevel:c.MINIMAL}:{thinkingBudget:0}}function j(e,t){if(O(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function M(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{g as streamGoogleVertex,_ as streamSimpleGoogleVertex};
@@ -1 +1 @@
1
- import{ut as e}from"./kernel-worker-DAzmsd_P.js";var t=e({applyRewrites:()=>o,createInterceptingOAuthLauncher:()=>s,parseInterceptOAuthConfig:()=>n});function n(e){if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,error:`expected a JSON object`};let t=e;if(typeof t.authorizeUrl!=`string`||t.authorizeUrl.length===0)return{ok:!1,error:`authorizeUrl must be a non-empty string`};if(typeof t.redirectUriPattern!=`string`||t.redirectUriPattern.length===0)return{ok:!1,error:`redirectUriPattern must be a non-empty string`};if(t.onCapture!==void 0&&t.onCapture!==`close`&&t.onCapture!==`leave`)return{ok:!1,error:`onCapture must be "close" or "leave"`};if(t.timeoutMs!==void 0&&(typeof t.timeoutMs!=`number`||t.timeoutMs<=0))return{ok:!1,error:`timeoutMs must be a positive number`};let n=r(t.rewrite);return n.ok?{ok:!0,config:{authorizeUrl:t.authorizeUrl,redirectUriPattern:t.redirectUriPattern,rewrite:n.rewrites,onCapture:t.onCapture,timeoutMs:t.timeoutMs}}:n}function r(e){if(e===void 0)return{ok:!0,rewrites:void 0};if(!Array.isArray(e))return{ok:!1,error:`rewrite must be an array`};let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`object`||!r)return{ok:!1,error:`rewrite[${n}] must be an object`};let i=r;if(typeof i.match!=`string`||i.match.length===0)return{ok:!1,error:`rewrite[${n}].match must be a non-empty string`};if(i.replaceUrl!==void 0&&typeof i.replaceUrl!=`string`)return{ok:!1,error:`rewrite[${n}].replaceUrl must be a string when present`};if(i.appendParams!==void 0){if(typeof i.appendParams!=`object`||i.appendParams===null||Array.isArray(i.appendParams))return{ok:!1,error:`rewrite[${n}].appendParams must be an object`};for(let[e,t]of Object.entries(i.appendParams))if(typeof t!=`string`)return{ok:!1,error:`rewrite[${n}].appendParams.${e} must be a string`}}t.push({match:i.match,appendParams:i.appendParams,replaceUrl:i.replaceUrl})}return{ok:!0,rewrites:t}}function i(e,t){return t.endsWith(`*`)?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}#`)}function a(e){return e.endsWith(`*`)?e:`${e}*`}function o(e,t){if(!t||t.length===0)return e;let n=e;for(let e of t)if(n.includes(e.match)){if(e.replaceUrl){n=e.replaceUrl;continue}if(e.appendParams)try{let t=new URL(n);for(let[n,r]of Object.entries(e.appendParams))t.searchParams.set(n,r);n=t.toString()}catch{}}return n}function s(e){return async t=>{let n=t.timeoutMs??12e4,r=t.rewrite??[],s=t.onCapture??`close`,c,l,u=!1,d=null,f=async()=>{if(l){try{await e.send(`Fetch.disable`,{},l)}catch{}try{await e.send(`Target.detachFromTarget`,{sessionId:l})}catch{}}if(c&&s===`close`)try{await e.send(`Target.closeTarget`,{targetId:c})}catch{}};return await new Promise(s=>{let p=async t=>{u||(u=!0,clearTimeout(h),e.off(`Fetch.requestPaused`,m),await f(),s(t))},m=n=>{let a=n;if(!a?.request?.url||!l||(typeof n.sessionId==`string`?n.sessionId:void 0)!==l)return;if(i(a.request.url,t.redirectUriPattern)){d=a.request.url,e.send(`Fetch.failRequest`,{requestId:a.requestId,errorReason:`Aborted`},l).catch(()=>{}),p(d);return}let s=o(a.request.url,r);if(s!==a.request.url){e.send(`Fetch.continueRequest`,{requestId:a.requestId,url:s},l).catch(e=>{console.warn(`[intercepted-oauth] continueRequest (rewrite) failed:`,e instanceof Error?e.message:String(e))});return}e.send(`Fetch.continueRequest`,{requestId:a.requestId},l).catch(()=>{})},h=setTimeout(()=>{p(null)},n);(async()=>{try{c=(await e.send(`Target.createTarget`,{url:`about:blank`})).targetId,l=(await e.send(`Target.attachToTarget`,{targetId:c,flatten:!0})).sessionId,e.on(`Fetch.requestPaused`,m),await e.send(`Fetch.enable`,{patterns:[{urlPattern:a(t.redirectUriPattern),requestStage:`Request`},...r.map(e=>({urlPattern:`*${e.match}*`,requestStage:`Request`}))]},l),await e.send(`Page.navigate`,{url:t.authorizeUrl},l)}catch(e){console.error(`[intercepted-oauth] setup failed:`,e instanceof Error?e.message:String(e)),p(null)}})()})}}export{t as n,s as t};
1
+ import{pt as e}from"./kernel-worker-B_VVPiix.js";var t=e({applyRewrites:()=>o,createInterceptingOAuthLauncher:()=>s,parseInterceptOAuthConfig:()=>n});function n(e){if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,error:`expected a JSON object`};let t=e;if(typeof t.authorizeUrl!=`string`||t.authorizeUrl.length===0)return{ok:!1,error:`authorizeUrl must be a non-empty string`};if(typeof t.redirectUriPattern!=`string`||t.redirectUriPattern.length===0)return{ok:!1,error:`redirectUriPattern must be a non-empty string`};if(t.onCapture!==void 0&&t.onCapture!==`close`&&t.onCapture!==`leave`)return{ok:!1,error:`onCapture must be "close" or "leave"`};if(t.timeoutMs!==void 0&&(typeof t.timeoutMs!=`number`||t.timeoutMs<=0))return{ok:!1,error:`timeoutMs must be a positive number`};let n=r(t.rewrite);return n.ok?{ok:!0,config:{authorizeUrl:t.authorizeUrl,redirectUriPattern:t.redirectUriPattern,rewrite:n.rewrites,onCapture:t.onCapture,timeoutMs:t.timeoutMs}}:n}function r(e){if(e===void 0)return{ok:!0,rewrites:void 0};if(!Array.isArray(e))return{ok:!1,error:`rewrite must be an array`};let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`object`||!r)return{ok:!1,error:`rewrite[${n}] must be an object`};let i=r;if(typeof i.match!=`string`||i.match.length===0)return{ok:!1,error:`rewrite[${n}].match must be a non-empty string`};if(i.replaceUrl!==void 0&&typeof i.replaceUrl!=`string`)return{ok:!1,error:`rewrite[${n}].replaceUrl must be a string when present`};if(i.appendParams!==void 0){if(typeof i.appendParams!=`object`||i.appendParams===null||Array.isArray(i.appendParams))return{ok:!1,error:`rewrite[${n}].appendParams must be an object`};for(let[e,t]of Object.entries(i.appendParams))if(typeof t!=`string`)return{ok:!1,error:`rewrite[${n}].appendParams.${e} must be a string`}}t.push({match:i.match,appendParams:i.appendParams,replaceUrl:i.replaceUrl})}return{ok:!0,rewrites:t}}function i(e,t){return t.endsWith(`*`)?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}#`)}function a(e){return e.endsWith(`*`)?e:`${e}*`}function o(e,t){if(!t||t.length===0)return e;let n=e;for(let e of t)if(n.includes(e.match)){if(e.replaceUrl){n=e.replaceUrl;continue}if(e.appendParams)try{let t=new URL(n);for(let[n,r]of Object.entries(e.appendParams))t.searchParams.set(n,r);n=t.toString()}catch{}}return n}function s(e){return async t=>{let n=t.timeoutMs??12e4,r=t.rewrite??[],s=t.onCapture??`close`,c,l,u=!1,d=null,f=async()=>{if(l){try{await e.send(`Fetch.disable`,{},l)}catch{}try{await e.send(`Target.detachFromTarget`,{sessionId:l})}catch{}}if(c&&s===`close`)try{await e.send(`Target.closeTarget`,{targetId:c})}catch{}};return await new Promise(s=>{let p=async t=>{u||(u=!0,clearTimeout(h),e.off(`Fetch.requestPaused`,m),await f(),s(t))},m=n=>{let a=n;if(!a?.request?.url||!l||(typeof n.sessionId==`string`?n.sessionId:void 0)!==l)return;if(i(a.request.url,t.redirectUriPattern)){d=a.request.url,e.send(`Fetch.failRequest`,{requestId:a.requestId,errorReason:`Aborted`},l).catch(()=>{}),p(d);return}let s=o(a.request.url,r);if(s!==a.request.url){e.send(`Fetch.continueRequest`,{requestId:a.requestId,url:s},l).catch(e=>{console.warn(`[intercepted-oauth] continueRequest (rewrite) failed:`,e instanceof Error?e.message:String(e))});return}e.send(`Fetch.continueRequest`,{requestId:a.requestId},l).catch(()=>{})},h=setTimeout(()=>{p(null)},n);(async()=>{try{c=(await e.send(`Target.createTarget`,{url:`about:blank`})).targetId,l=(await e.send(`Target.attachToTarget`,{targetId:c,flatten:!0})).sessionId,e.on(`Fetch.requestPaused`,m),await e.send(`Fetch.enable`,{patterns:[{urlPattern:a(t.redirectUriPattern),requestStage:`Request`},...r.map(e=>({urlPattern:`*${e.match}*`,requestStage:`Request`}))]},l),await e.send(`Page.navigate`,{url:t.authorizeUrl},l)}catch(e){console.error(`[intercepted-oauth] setup failed:`,e instanceof Error?e.message:String(e)),p(null)}})()})}}export{t as n,s as t};
@@ -0,0 +1,5 @@
1
+ var e=class{port;nextId=1;pending=new Map;handler;disposed=!1;constructor(e){this.port=e,this.handler=e=>{if(e.data?.type!==`realm-rpc-res`)return;let t=e.data,n=this.pending.get(t.id);n&&(this.pending.delete(t.id),typeof t.error==`string`?n.reject(Error(t.error)):n.resolve(t.result))},e.addEventListener(`message`,this.handler),e.start?.()}call(e,t,n=[]){if(this.disposed)return Promise.reject(Error(`realm-rpc: client disposed`));let r=this.nextId++,i={type:`realm-rpc-req`,id:r,channel:e,op:t,args:n};return new Promise((e,t)=>{this.pending.set(r,{resolve:e,reject:t}),this.port.postMessage(i)})}dispose(){if(this.disposed)return;this.disposed=!0,this.port.removeEventListener(`message`,this.handler);let e=Error(`realm-rpc: client disposed`);for(let t of this.pending.values())t.reject(e);this.pending.clear()}};const t=new Set([`bcrypt`,`better-sqlite3`,`canvas`,`cpu-features`,`fsevents`,`leveldown`,`libxmljs`,`libxmljs2`,`node-gyp-build`,`node-sass`,`puppeteer`,`robotjs`,`sass-embedded`,`sharp`,`snappy`,`sqlite3`,`tree-sitter`,`usb`]),n={sharp:` Use the built-in 'convert' shell command for image work.`,canvas:` Use the built-in 'convert' / OffscreenCanvas for image work.`,"better-sqlite3":` Use the built-in 'sqlite3' shell command (sql.js WASM).`,sqlite3:` Use the built-in 'sqlite3' shell command (sql.js WASM).`,bcrypt:` Use crypto.subtle.digest() with PBKDF2 / Argon2 in pure JS.`,puppeteer:` Use the built-in browser-automation shell commands.`};function r(e,t){let r=n[t]??``;return Error(`require('${e}'): '${t}' is a Node native module (C++ bindings) — it cannot run in the browser sandbox.${r}`)}function i(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timed out after ${t/1e3}s loading ${n}`))},t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})})}function a(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function o(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function s(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function c(e){let t=a(e.argv[1]??``),n=s(t,`references`),r=s(t,`assets`),i=s(t,`.config`);async function c(){let t;try{t=await e.fs.exists(i)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(i)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let a;try{a=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${i}: ${t}`)}if(a&&typeof a==`object`&&!Array.isArray(a))return a;throw Error(`skill.config(): ${i} must contain a JSON object`)}async function l(t){let n=await c();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(i,JSON.stringify(r,null,2)+`
2
+ `),r}async function u(t){if(typeof t!=`string`||!t.trim())throw TypeError(`skill.token(providerId): providerId must be a non-empty string`);let n=`oauth-token ${o(t)}`,{stdout:r,stderr:i,exitCode:a}=await e.exec(n);if(a!==0){let e=i.trim()||`oauth-token exited with code ${a}`;throw Error(`skill.token('${t}'): ${e}`)}return r.replace(/\r?\n+$/,``)}return Object.freeze({dir:t,refs:n,assets:r,config:l,token:u})}var l=class extends Error{status;statusText;url;body;constructor(e,t,n,r){let i=typeof r==`string`&&r?`: ${r.slice(0,200)}`:r&&typeof r==`object`?`: ${u(r).slice(0,200)}`:``;super(`HTTP ${e} ${t} ${n}${i}`),this.status=e,this.statusText=t,this.url=n,this.body=r,this.name=`HttpError`}};function u(e){try{return JSON.stringify(e)}catch{return String(e)}}function d(e){return new Promise(t=>setTimeout(t,e))}function f(e,t,n){let r;if(r=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:e?`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`:t,!n)return r;let i=[];for(let[e,t]of Object.entries(n))if(t!=null)if(Array.isArray(t))for(let n of t)n!=null&&i.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`);else i.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);return i.length===0?r:r+(r.includes(`?`)?`&`:`?`)+i.join(`&`)}function p(e,t){let n={};if(e)for(let[t,r]of Object.entries(e))n[t]=r;if(t)for(let[e,r]of Object.entries(t))n[e]=r;return n}function m(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`application/json`)||/[+/]json(;|$|\s)/.test(t)}function h(e){if(!e)return null;let t=e.trim();if(!t)return null;if(/^\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e)&&e>=0)return Math.round(e*1e3)}let n=Date.parse(t);if(Number.isFinite(n)){let e=n-Date.now();return e>0?e:0}return null}async function g(e){if(m(e.headers.get(`content-type`))){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e.text()}function _(e,t){if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||typeof FormData<`u`&&e instanceof FormData||typeof URLSearchParams<`u`&&e instanceof URLSearchParams||typeof ReadableStream<`u`&&e instanceof ReadableStream?e:typeof e==`object`?(Object.keys(t).some(e=>e.toLowerCase()===`content-type`)||(t[`Content-Type`]=`application/json`),JSON.stringify(e)):String(e)}function v(e){let t=e.sleep??d;function n(n){let r=new Set(n.retry?.on??[]),i=Math.max(1,Math.trunc(n.retry?.maxAttempts??1));async function a(a,o,s={}){let c=f(n.baseUrl,o,s.params),u=p(n.headers,s.headers);if(n.token){let e=await n.token({method:a,path:o,url:c});e&&(Object.keys(u).some(e=>e.toLowerCase()===`authorization`)||(u.Authorization=`Bearer ${e}`))}let d=_(s.body,u),m={method:a,headers:u};d!==void 0&&(m.body=d);let v=null;for(let a=0;a<i;a++){let o=n.timeoutMs?new AbortController:null,u=o?setTimeout(()=>o.abort(Error(`timeout`)),n.timeoutMs):null,d=s.signal&&o?.signal?AbortSignal.any([s.signal,o.signal]):s.signal??o?.signal,f=d?{...m,signal:d}:m,p;try{p=await e.fetch(c,f)}finally{u!==null&&clearTimeout(u)}if(v=p,p.ok){let e=await g(p);return s.raw?{body:e,headers:Object.fromEntries(p.headers.entries()),status:p.status}:e}if(!(a+1<i&&r.has(p.status))){let e=await g(p).catch(()=>null);throw new l(p.status,p.statusText,c,e)}let _=h(p.headers.get(`retry-after`)),y=500*2**a;await t(_===null?y:_)}if(v){let e=await g(v).catch(()=>null);throw new l(v.status,v.statusText,c,e)}throw Error(`http: no attempts made for ${a} ${c}`)}return Object.freeze({get:((e,t)=>a(`GET`,e,t)),post:((e,t)=>a(`POST`,e,t)),put:((e,t)=>a(`PUT`,e,t)),delete:((e,t)=>a(`DELETE`,e,t))})}return Object.freeze({client:n})}function y(e){let t=[],n={},r=[],i=(e,t)=>{if(e in n){let r=n[e];Array.isArray(r)?r.push(String(t)):n[e]=[String(r),String(t)]}else n[e]=t},a=2;for(;a<e.length;){let n=e[a];if(n===`--`){r.push(...e.slice(a+1));break}if(n.startsWith(`--`)){let t=n.slice(2),r=t.indexOf(`=`);if(r!==-1){i(t.slice(0,r),t.slice(r+1)),a++;continue}let o=e[a+1];if(o!==void 0&&!o.startsWith(`-`)){i(t,o),a+=2;continue}i(t,!0),a++;continue}if(n.startsWith(`-`)&&n.length>1){for(let e of n.slice(1))i(e,!0);a++;continue}t.push(n),a++}return{positional:t,flags:n,subcommand:t.length>0&&/^[a-z][\w-]*$/i.test(t[0])?t[0]:null,passthrough:r}}function b(e){let t=[...e];return Object.defineProperty(t,"parseFlags",{value:()=>y(t),enumerable:!1,writable:!1,configurable:!1}),t}function x(e){let t=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},n=(e,t,n)=>t===void 0?`${e(`Error:`)} ${n}\n`:t===``?`${e(n)}\n`:`${e(`${t}:`)} ${n}\n`,r=(t,n)=>t===void 0?`${e.color.yellow(`Warning:`)} ${n}\n`:t===``?`${e.color.yellow(n)}\n`:`${e.color.yellow(`${t}:`)} ${n}\n`;return{die(r,i){let a=typeof i==`number`?i:i?.exitCode??1,o=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0,s=t(r);throw e.writeStderr(n(e.color.red,o,s)),e.exit(a),Error(`unreachable`)},out(t){if(typeof t==`string`){e.writeStdout(t.endsWith(`
3
+ `)?t:`${t}\n`);return}try{e.writeStdout(`${JSON.stringify(t,null,2)}\n`)}catch{e.writeStdout(`${String(t)}\n`)}},warn(n,i){let a=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0;e.writeStderr(r(a,t(n)))},help(t){throw e.writeStdout(t.endsWith(`
4
+ `)?t:`${t}\n`),e.exit(0),Error(`unreachable`)}}}const S={reset:`\x1B[0m`,green:`\x1B[32m`,red:`\x1B[31m`,yellow:`\x1B[33m`,gray:`\x1B[90m`,bold:`\x1B[1m`,cyan:`\x1B[36m`,dim:`\x1B[2m`};function C(e){let t=e.isTTY&&!e.noColor,n=e=>n=>t?`${e}${n}${S.reset}`:String(n);return{enabled:t,green:n(S.green),red:n(S.red),yellow:n(S.yellow),gray:n(S.gray),bold:n(S.bold),cyan:n(S.cyan),dim:n(S.dim)}}const w={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5,M:26298e5,y:315576e5};function T(e){if(typeof e==`number`&&Number.isFinite(e))return Math.trunc(e);if(typeof e!=`string`)throw TypeError(`time.parseDuration: spec must be string or number`);let t=e.trim(),n=/^([0-9]+(?:\.[0-9]+)?)\s*(ms|s|m|h|d|w|M|y)?$/.exec(t);if(!n)throw RangeError(`time.parseDuration: unrecognized spec "${e}"`);let r=Number(n[1]),i=n[2]??`ms`;return Math.trunc(r*w[i])}function E(e){return e<10?`0${e}`:String(e)}const D={parseDuration:T,ago(e,t=new Date){return new Date(t.getTime()-T(e))},range(e,t=new Date){let n=new Date(t.getTime());return{start:new Date(n.getTime()-T(e)),end:n}},future(e,t=new Date){let n=new Date(t.getTime());return{start:n,end:new Date(n.getTime()+T(e))}},gmailDate(e,t=new Date){let n=new Date(t.getTime()-T(e));return`${n.getFullYear()}/${E(n.getMonth()+1)}/${E(n.getDate())}`}},O=/\u001b\[[0-9;]*m/g;function k(e){return e.replace(O,``)}function A(e){return k(e).length}function j(e,t){let n=String(e??``);return t<=0?``:A(n)<=t?n:t<=1?n.slice(0,t):`${k(n).slice(0,t-1)}…`}function M(e,t){let n=String(e??``),r=A(n);return r===t?n:r>t?j(n,t):n+` `.repeat(t-r)}function N(e,t){if(!e.length)return``;let n=Math.max(...e.map(e=>e.length)),r=[];for(let i=0;i<n;i++)if(t&&t[i]!==void 0)r[i]=t[i];else{let t=0;for(let n of e){let e=i<n.length?String(n[i]??``):``;t=Math.max(t,A(e))}r[i]=t}return e.map(e=>r.map((t,n)=>M(n<e.length?String(e[n]??``):``,t)).join(` `).replace(/\s+$/,``)).join(`
5
+ `)}function P(e){return e instanceof Date?e:new Date(e)}function F(e,t=`short`){let n=P(e);if(Number.isNaN(n.getTime()))return String(e);if(t===`iso`)return n.toISOString();if(t===`locale`)return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(n);if(t===`human`){let e=Date.now()-n.getTime(),t=Math.abs(e);if(t<6e4)return e>=0?`just now`:`in a moment`;let r=(t,n)=>e>=0?`${t} ${n}${t===1?``:`s`} ago`:`in ${t} ${n}${t===1?``:`s`}`;return t<36e5?r(Math.round(t/6e4),`minute`):t<864e5?r(Math.round(t/36e5),`hour`):t<26298e5?r(Math.round(t/864e5),`day`):t<315576e5?r(Math.round(t/26298e5),`month`):r(Math.round(t/315576e5),`year`)}return`${n.getFullYear()}-${E(n.getMonth()+1)}-${E(n.getDate())}`}const I={trunc:j,col:M,table:N,date:F},L=async(e,t,n)=>{let r=Math.max(1,Math.trunc(e)||1),i=Array(t.length),a=0,o=[],s=async()=>{for(;;){let e=a++;if(e>=t.length)return;i[e]=await n(t[e],e)}};for(let e=0;e<Math.min(r,t.length);e++)o.push(s());return await Promise.all(o),i},R=new Set([`http`,`https`,`net`,`tls`,`dgram`,`dns`,`cluster`,`worker_threads`,`child_process`,`crypto`,`os`,`stream`,`zlib`,`vm`,`v8`,`perf_hooks`,`readline`,`repl`,`tty`,`inspector`]),z=new Set([`fs`,`process`,`buffer`]);var B=class extends Error{code;constructor(e){super(`Process exited with code ${e}`),this.code=e,this.name=`NodeExitError`}};function V(e){let t=/\brequire\s*\(\s*(['"`])([^'"`\s]+)\1\s*\)/g,n=new Set,r;for(;(r=t.exec(e))!==null;)n.add(r[2]);return[...n]}function H(e){if(typeof e==`string`)return e;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}async function U(n,a,o=G){let s=[],l=[],u=e=>{s.push(typeof e==`string`?e:String(e))},d=e=>{l.push(typeof e==`string`?e:String(e))},f={log:(...e)=>u(`${e.map(H).join(` `)}\n`),info:(...e)=>u(`${e.map(H).join(` `)}\n`),warn:(...e)=>d(`${e.map(H).join(` `)}\n`),error:(...e)=>d(`${e.map(H).join(` `)}\n`)},p=n.stdin??``,m=!1,h={isTTY:!1,read(){return m?null:(m=!0,p)},toString(){return p},[Symbol.asyncIterator](){return{async next(){return m?{value:void 0,done:!0}:(m=!0,{value:p,done:!1})}}}},g=b(n.argv),_=!!n.env?.NO_COLOR,y={argv:g,env:n.env,cwd:()=>n.cwd,exit:e=>{throw new B(Number.isFinite(e)?Number(e):0)},stdin:h,stdout:{write:u,isTTY:!_},stderr:{write:d,isTTY:!_}},S=C({isTTY:!_,noColor:_}),w=x({writeStdout:u,writeStderr:d,exit:e=>{throw new B(e)},color:S}),T=new e(a),E={readFile:e=>T.call(`vfs`,`readFile`,[e]),readFileBinary:e=>T.call(`vfs`,`readFileBinary`,[e]),writeFile:(e,t)=>T.call(`vfs`,`writeFile`,[e,t]),writeFileBinary:(e,t)=>T.call(`vfs`,`writeFileBinary`,[e,t]),readDir:e=>T.call(`vfs`,`readDir`,[e]),exists:e=>T.call(`vfs`,`exists`,[e]),stat:e=>T.call(`vfs`,`stat`,[e]),mkdir:e=>T.call(`vfs`,`mkdir`,[e]),rm:e=>T.call(`vfs`,`rm`,[e]),fetchToFile:async(e,t)=>{let n=await M(e);if(!n.ok)throw Error(`fetch ${n.status} ${n.statusText}`);let r=new Uint8Array(await n.arrayBuffer());return await T.call(`vfs`,`writeFileBinary`,[t,r]),r.byteLength}},O=Object.assign(e=>T.call(`exec`,`run`,[e]),{spawn:e=>T.call(`exec`,`spawn`,[e])}),k=c({argv:n.argv,fs:E,exec:O}),A={findTab:e=>T.call(`browser`,`findTab`,[Y(e)]),ensureTab:(e,t={})=>T.call(`browser`,`ensureTab`,[e,X(t)]),eval:(e,t)=>T.call(`browser`,`eval`,[K(e),q(t,!1)]),evalAsync:(e,t)=>T.call(`browser`,`evalAsync`,[K(e),q(t,!0)]),cookie:(e,t)=>T.call(`browser`,`cookie`,[K(e),t]),localStorage:(e,t)=>T.call(`browser`,`localStorage`,[K(e),t]),fetch:(e,t,n={})=>T.call(`browser`,`evalAsync`,[K(e),J(t,n)]),websocket:ee(T)},j=v({fetch:M});async function M(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e),r=await T.call(`fetch`,`request`,[n,W(t,e)]),i=r.body.byteLength===0?null:r.body.buffer.slice(r.body.byteOffset,r.body.byteOffset+r.body.byteLength),a=new Response(i,{status:r.status,statusText:r.statusText,headers:r.headers});return Object.defineProperty(a,"url",{value:r.url||n}),a}let N=V(n.code).map(e=>e.startsWith(`node:`)?e.slice(5):e).filter(e=>!z.has(e)&&!R.has(e)),P=N.filter(e=>t.has(e)),F=N.filter(e=>!t.has(e));for(let e of P)d(`Warning: ${r(e,e).message}\n`);let U=Object.create(null);if(F.length>0){let e=await Promise.allSettled(F.map(async e=>{let t=await i(o(e),15e3,`require('${e}')`);U[e]=t&&`default`in t?t.default:t}));for(let t=0;t<e.length;t++){let n=e[t];if(n.status===`rejected`){let e=n.reason instanceof Error?n.reason.message:String(n.reason);d(`Warning: failed to pre-load require('${F[t]}'): ${e}\n`)}}}let Z=e=>{let n=e.startsWith(`node:`)?e.slice(5):e;if(n===`fs`)return E;if(n===`process`)return y;if(n===`buffer`)return{Buffer:globalThis.Buffer};if(n===`path`){if(`path`in U)return U.path;if(e in U)return U[e];throw Error(`require('${e}'): path module not pre-loaded. Add require('path') as a static import.`)}if(t.has(n))throw r(e,n);if(R.has(n))throw Error(`require('${e}'): Node built-in '${n}' is not available in the browser environment.${{http:` Use fetch() instead.`,https:` Use fetch() instead.`,child_process:` Use exec() which is available as a shell bridge.`,crypto:` Use globalThis.crypto (Web Crypto API) instead.`}[n]||``}`);if(e in U)return U[e];if(n in U)return U[n];throw Error(`require('${e}'): module not pre-loaded. Use a string literal so it can be pre-fetched, or use \`await import('https://esm.sh/${e}')\` directly.`)},Q={exports:{},filename:n.filename},$=0;try{let e=Object.getPrototypeOf(async function(){}).constructor;await new e(`fs`,`process`,`console`,`require`,`module`,`exports`,`exec`,`fetch`,`skill`,`http`,`browser`,`cli`,`c`,`time`,`fmt`,`pool`,`"use strict";\n${n.code}`)(E,y,f,Z,Q,Q.exports,O,M,k,j,A,w,S,D,I,L)}catch(e){e instanceof B?$=e.code:(d(`${e instanceof Error?e.stack??e.message:String(e)}\n`),$=1)}T.dispose();let te={type:`realm-done`,stdout:s.join(``),stderr:l.join(``),exitCode:$};a.postMessage(te)}function W(e,t){if(!e&&!(t instanceof Request))return;let n=t instanceof Request?t:null,r=(e?.method??n?.method??`GET`).toUpperCase(),i={};if(e?.headers)if(e.headers instanceof Headers)e.headers.forEach((e,t)=>{i[t]=e});else if(Array.isArray(e.headers))for(let[t,n]of e.headers)i[t]=n;else Object.assign(i,e.headers);else n&&n.headers.forEach((e,t)=>{i[t]=e});let a;return e?.body!==void 0&&e?.body!==null&&e?.body!==``&&(a=typeof e.body==`string`?e.body:String(e.body)),{method:r,headers:i,body:a}}async function G(e){return await import(`https://esm.sh/`+e)}function K(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`&&typeof e.targetId==`string`)return e.targetId;throw TypeError(`browser: expected a tab handle or targetId string`)}function q(e,t){if(typeof e==`function`)return`(${e.toString()})()`;if(typeof e==`string`)return e;throw TypeError(`browser.eval/evalAsync: source must be a function or string`)}function J(e,t={}){let n={},r=t.headers??{};for(let[e,t]of Object.entries(r))typeof t==`string`&&(n[e]=t);let i=typeof t.method==`string`?t.method:`GET`,a=t.credentials===`same-origin`||t.credentials===`omit`?t.credentials:`include`,o;t.body!==void 0&&t.body!==null&&(typeof t.body==`string`?o=t.body:(o=JSON.stringify(t.body),Object.keys(n).some(e=>e.toLowerCase()===`content-type`)||(n[`Content-Type`]=`application/json`)));let s={method:i,credentials:a,headers:n};o!==void 0&&(s.body=o);for(let e of[`mode`,`cache`,`redirect`,`referrer`,`referrerPolicy`,`integrity`,`keepalive`]){let n=t[e];n!==void 0&&(s[e]=n)}return`(async () => {const r = await fetch(`+JSON.stringify(e)+`, `+JSON.stringify(s)+`);const h = {};r.headers.forEach((v, k) => { h[k] = v; });const ct = r.headers.get('content-type') || '';let b;if (ct.indexOf('application/json') !== -1) {try { b = await r.json(); } catch (e) { b = await r.text(); }} else { b = await r.text(); }return { ok: r.ok, status: r.status, headers: h, body: b };})()`}function Y(e){let t={};return e.domain!==void 0&&(t.domain=e.domain),e.urlMatch!==void 0&&(t.urlMatch=e.urlMatch instanceof RegExp?e.urlMatch.source:e.urlMatch),t}function X(e){return e.matchUrl===void 0?{}:{matchUrl:e.matchUrl instanceof RegExp?e.matchUrl.source:e.matchUrl}}function ee(e){function t(t){return{...t,async update(n){let r={};return n.urlMatch!==void 0&&(r.urlMatch=n.urlMatch===null?null:n.urlMatch instanceof RegExp?n.urlMatch.source:n.urlMatch),n.filter!==void 0&&(r.filter=n.filter),e.call(`browser`,`wsUpdate`,[t.id,r])},async close(){return e.call(`browser`,`wsClose`,[t.id])}}}return{on(n,r={}){let i=K(n),a=r.urlMatch===void 0?void 0:r.urlMatch instanceof RegExp?r.urlMatch.source:r.urlMatch,o,s={filter(e){if(typeof e==`function`||typeof e==`string`)throw TypeError(`browser.websocket: filter must be a declarative JSON object, not a function or string`);return o=e,s},async forward(n){return t(await e.call(`browser`,`wsObserve`,[{targetId:i,urlMatch:a,filter:o,forward:n}]))}};return s},async list(){return e.call(`browser`,`wsList`,[])}}}const Z={postMessage:(e,t)=>t?self.postMessage(e,t):self.postMessage(e),addEventListener:(e,t)=>self.addEventListener(e,t),removeEventListener:(e,t)=>self.removeEventListener(e,t)};self.addEventListener(`message`,e=>{if(e.data?.type!==`realm-init`)return;let t=e.data;t.kind===`js`&&U(t,Z).catch(e=>{let t={type:`realm-error`,message:e instanceof Error?e.message:String(e)};self.postMessage(t)})});