sliccy 3.31.2 → 3.32.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 (86) hide show
  1. package/dist/ui/assets/{adobe-q1ynSkgJ.js → adobe-Bst4BHL-.js} +1 -1
  2. package/dist/ui/assets/{adobe-CNsjY_V1.js → adobe-DCdXi0ew.js} +2 -2
  3. package/dist/ui/assets/{agent-bridge-DaY3lEr8.js → agent-bridge-BmPNQNyp.js} +1 -1
  4. package/dist/ui/assets/{agent-message-to-chat-QxmVsZHN.js → agent-message-to-chat-BULzciH_.js} +1 -1
  5. package/dist/ui/assets/{anthropic-C29fNa0p.js → anthropic-C0qwC7-w.js} +1 -1
  6. package/dist/ui/assets/{anthropic-BcxNFOMf.js → anthropic-CHHtdLPy.js} +1 -1
  7. package/dist/ui/assets/{apps-DEr5_QVi.js → apps-YH9ldD25.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-BOAQMret.js → azure-openai-C9P5DkS8.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-BgjK3tAI.js → azure-openai-DXygs5O6.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-responses-B_ZHPZQ_.js → azure-openai-responses-CpWuZozQ.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-responses-D9aG5ZZZ.js → azure-openai-responses-Dh9R4d9u.js} +1 -1
  12. package/dist/ui/assets/{biome_wasm-DFR1VZSE.js → biome_wasm-CRr4JjWn.js} +1 -1
  13. package/dist/ui/assets/{bsh-watchdog-DOvowpMJ.js → bsh-watchdog-DaXpKHAi.js} +1 -1
  14. package/dist/ui/assets/{cdp-DLzkpHPR.js → cdp-C2e8AyZy.js} +3 -3
  15. package/dist/ui/assets/{cdp-ws-page-bridge-DbNf5VhA.js → cdp-ws-page-bridge-Cj43vtty.js} +1 -1
  16. package/dist/ui/assets/{common-Ce3nKdPG.js → common-Bec07QCB.js} +1 -1
  17. package/dist/ui/assets/{connect-surface-BfntsfUz.js → connect-surface-Ck_vQoam.js} +1 -1
  18. package/dist/ui/assets/cost-command-B7V2Fi3m.js +1 -0
  19. package/dist/ui/assets/{es-Gkir_CGN.js → es-BVu1-m9n.js} +1 -1
  20. package/dist/ui/assets/{follower-sprinkle-bridge-Bsb9Um7I.js → follower-sprinkle-bridge-YKWY4PSL.js} +1 -1
  21. package/dist/ui/assets/{github-tMItzRHe.js → github-4lYWHWy0.js} +2 -2
  22. package/dist/ui/assets/{github-C2uMRSdr.js → github-B2MUYew1.js} +1 -1
  23. package/dist/ui/assets/{github-copilot-DsrWwQfK.js → github-copilot-C52RjIpK.js} +2 -2
  24. package/dist/ui/assets/{github-copilot-BdAJesOB.js → github-copilot-Uft2j7Oa.js} +1 -1
  25. package/dist/ui/assets/{google-BCVpl33Q.js → google-DgtutA97.js} +1 -1
  26. package/dist/ui/assets/{google-BJtxAJct.js → google-Dx52dHvK.js} +1 -1
  27. package/dist/ui/assets/{google-shared-CaucmB5i.js → google-shared-BHU6i1pu.js} +1 -1
  28. package/dist/ui/assets/{google-shared-BEVjYKj2.js → google-shared-BLw0sd3s.js} +1 -1
  29. package/dist/ui/assets/{google-vertex-Di3B-unZ.js → google-vertex-BOYR0o6q.js} +1 -1
  30. package/dist/ui/assets/{google-vertex-BrfIL2f8.js → google-vertex-DRWaCSkn.js} +1 -1
  31. package/dist/ui/assets/{intercepted-oauth-Ap0NXgFY.js → intercepted-oauth-CkihOC6W.js} +1 -1
  32. package/dist/ui/assets/{kernel-worker-aL7clsM2.js → kernel-worker-thcJSaI4.js} +880 -879
  33. package/dist/ui/assets/{lick-ws-bridge-2FLXq2tY.js → lick-ws-bridge-DxWBoA9l.js} +1 -1
  34. package/dist/ui/assets/{local-llm-CABjY-eT.js → local-llm-CuKgZah9.js} +1 -1
  35. package/dist/ui/assets/{magick-wasm-DojPv_bG.js → magick-wasm-CeJKAHiV.js} +1 -1
  36. package/dist/ui/assets/{main-BtoNCPyQ.js → main-B17wOcQm.js} +242 -187
  37. package/dist/ui/assets/{main-cherry-BtqehQbg.js → main-cherry-BXAxhSxS.js} +1 -1
  38. package/dist/ui/assets/{mistral-D13sQ4B4.js → mistral-BAZMIGs3.js} +1 -1
  39. package/dist/ui/assets/{mistral-DmQtCAV6.js → mistral-COQuTqqc.js} +1 -1
  40. package/dist/ui/assets/{nodejs-CqTAsRQj.js → nodejs-BGy5U4JR.js} +1 -1
  41. package/dist/ui/assets/{nuke-command-WSharcWR.js → nuke-command-DbDnIGqI.js} +1 -1
  42. package/dist/ui/assets/{oauth-C6A6yZED.js → oauth-1TWJ9Lpq.js} +1 -1
  43. package/dist/ui/assets/{oauth-bootstrap-ac4aWs2_.js → oauth-bootstrap-Dchkv1Zk.js} +2 -2
  44. package/dist/ui/assets/{oauth-service-7-jMR6uA.js → oauth-service-CsTUDTTA.js} +1 -1
  45. package/dist/ui/assets/{oauth-service-0c_TknIC.js → oauth-service-DUdG4vOP.js} +1 -1
  46. package/dist/ui/assets/offscreen-client-CbnPqFcd.js +1 -0
  47. package/dist/ui/assets/{onboarding-orchestrator-BOYZUUXo.js → onboarding-orchestrator-OseBY3e8.js} +1 -1
  48. package/dist/ui/assets/{openai-codex-CfooJWr6.js → openai-codex-ChsSa-S2.js} +1 -1
  49. package/dist/ui/assets/{openai-codex-BvRU1nKe.js → openai-codex-CsEBtkzj.js} +1 -1
  50. package/dist/ui/assets/{openai-codex-responses-Cb4wO_aM.js → openai-codex-responses-BKsBblPU.js} +1 -1
  51. package/dist/ui/assets/{openai-codex-responses-DxuvnQBg.js → openai-codex-responses-BwePkD6g.js} +1 -1
  52. package/dist/ui/assets/{openai-completions-DkS2zVD3.js → openai-completions-zkTKSpSn.js} +1 -1
  53. package/dist/ui/assets/{openai-responses-C4PfIrGV.js → openai-responses-BDGEO7hH.js} +1 -1
  54. package/dist/ui/assets/{openai-responses-FJRVWCAN.js → openai-responses-CUDxDKLP.js} +1 -1
  55. package/dist/ui/assets/{openai-responses-shared-C3n9ip32.js → openai-responses-shared-CefvrRUw.js} +1 -1
  56. package/dist/ui/assets/{openai-responses-shared-BYmbH8Nn.js → openai-responses-shared-DVDbpbYT.js} +1 -1
  57. package/dist/ui/assets/{openrouter-B7t4AFIg.js → openrouter-CaSZyKf5.js} +1 -1
  58. package/dist/ui/assets/{openrouter-D_bhNbxi.js → openrouter-D-MziO8t.js} +1 -1
  59. package/dist/ui/assets/{panel-rpc-handlers-B5pMQ8y2.js → panel-rpc-handlers-ChvAu4GP.js} +1 -1
  60. package/dist/ui/assets/{provider-Dy70twsR.js → provider-Bdb6y9pT.js} +1 -1
  61. package/dist/ui/assets/{provider-D86wGnIQ.js → provider-BiuAThHu.js} +2 -2
  62. package/dist/ui/assets/provider-store-access-CN7MwCrJ.js +1 -0
  63. package/dist/ui/assets/provider-store-access-CWJRpyK3.js +1 -0
  64. package/dist/ui/assets/{proxied-fetch-CAbygDUy.js → proxied-fetch-CtGAzJEA.js} +1 -1
  65. package/dist/ui/assets/{pyodide-Cj1nQzdj.js → pyodide-DFilkaFa.js} +2 -2
  66. package/dist/ui/assets/{remote-terminal-view-Di-2iBd0.js → remote-terminal-view-B4qSW6nT.js} +1 -1
  67. package/dist/ui/assets/{secret-env-Kl69LC-B.js → secret-env-BVFnqist.js} +1 -1
  68. package/dist/ui/assets/{slicc-editor-BpfdHOM4.js → slicc-editor-BoFhrpq6.js} +1 -1
  69. package/dist/ui/assets/{spawn-D7jaToJ9.js → spawn-CctKIs7F.js} +1 -1
  70. package/dist/ui/assets/{sql-wasm-rW6OuYUy.js → sql-wasm-CiP_iqtv.js} +1 -1
  71. package/dist/ui/assets/{store-BYZoB9Pz.js → store-Cb6Dcgd1.js} +1 -1
  72. package/dist/ui/assets/{tray-leave-runtime-Bl06YhqQ.js → tray-leave-runtime-nxy6Ftte.js} +1 -1
  73. package/dist/ui/assets/{typescript-BGABsOjF.js → typescript-C2iCtGbY.js} +1 -1
  74. package/dist/ui/assets/{upgrade-detection-D6N4MRCp.js → upgrade-detection-DdhyD4vU.js} +1 -1
  75. package/dist/ui/assets/{web-DUSjmrph.js → web-BcJ-CPfm.js} +1 -1
  76. package/dist/ui/assets/{ws-subscribers-Ctp0G6_t.js → ws-subscribers-D75-mu3V.js} +1 -1
  77. package/dist/ui/assets/{xai-grok-COpIZ456.js → xai-grok-BMnAJaG6.js} +1 -1
  78. package/dist/ui/assets/{xai-grok-DIrGQApI.js → xai-grok-DPkerKvQ.js} +1 -1
  79. package/dist/ui/electron-overlay-entry.js +4 -4
  80. package/dist/ui/index.html +1 -1
  81. package/dist/ui/packages/webapp/index.html +1 -1
  82. package/package.json +1 -1
  83. package/dist/ui/assets/cost-command-CfSpaR6u.js +0 -1
  84. package/dist/ui/assets/offscreen-client-ltzgalb5.js +0 -1
  85. package/dist/ui/assets/provider-store-access-D_YGmkw4.js +0 -1
  86. package/dist/ui/assets/provider-store-access-iZ8Jszhq.js +0 -1
@@ -1 +1 @@
1
- import{G as e,K as t,O as n,U as r,l as i}from"./kernel-worker-aL7clsM2.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-CaucmB5i.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=(t,n,i)=>{let a=new r;return(async()=>{let r={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=C(i),c=o?y(t,o,i?.headers):v(t,T(i),E(i),i?.headers),l=D(t,n,i),f=await i?.onPayload?.(l,t);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:r});let m=null,g=r.content,_=()=>g.length-1;for await(let n of p){r.responseId||=n.responseId;let i=n.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:g.length-1,content:m.text,partial:r}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:r})),t?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},r.content.push(m),a.push({type:`thinking_start`,contentIndex:_(),partial:r})):(m={type:`text`,text:``},r.content.push(m),a.push({type:`text_start`,contentIndex:_(),partial:r}))),m.type===`thinking`?(m.thinking+=e.text,m.thinkingSignature=u(m.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:e.text,partial:r})):(m.text+=e.text,m.textSignature=u(m.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:e.text,partial:r}))}if(e.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:r}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:r}),null);let t=e.functionCall.id,n={type:`toolCall`,id:!t||r.content.some(e=>e.type===`toolCall`&&e.id===t)?`${e.functionCall.name}_${Date.now()}_${++h}`:t,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(n),a.push({type:`toolcall_start`,contentIndex:_(),partial:r}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(n.arguments),partial:r}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:n,partial:r})}}i?.finishReason&&(r.stopReason=s(i.finishReason),r.content.some(e=>e.type===`toolCall`)&&(r.stopReason=`toolUse`)),n.usageMetadata&&(r.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(t,r.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:r}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:r})),i?.signal?.aborted)throw Error(`Request was aborted`);if(r.stopReason===`aborted`||r.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:r.stopReason,message:r}),a.end()}catch(e){for(let e of r.content)`index`in e&&delete e.index;r.stopReason=i?.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:r.stopReason,error:r}),a.end()}})(),a},_=(e,r,i)=>{let a=n(e,i,void 0);if(!i?.reasoning)return g(e,r,{...a,thinking:{enabled:!1}});let o=t(e,i.reasoning),s=o===`off`?`high`:o,c=e;return O(c)||k(c)?g(e,r,{...a,thinking:{enabled:!0,level:j(s,c)}}):g(e,r,{...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{G as e,K as t,O as n,U as r,l as i}from"./kernel-worker-thcJSaI4.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-BHU6i1pu.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=(t,n,i)=>{let a=new r;return(async()=>{let r={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=C(i),c=o?y(t,o,i?.headers):v(t,T(i),E(i),i?.headers),l=D(t,n,i),f=await i?.onPayload?.(l,t);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:r});let m=null,g=r.content,_=()=>g.length-1;for await(let n of p){r.responseId||=n.responseId;let i=n.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:g.length-1,content:m.text,partial:r}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:r})),t?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},r.content.push(m),a.push({type:`thinking_start`,contentIndex:_(),partial:r})):(m={type:`text`,text:``},r.content.push(m),a.push({type:`text_start`,contentIndex:_(),partial:r}))),m.type===`thinking`?(m.thinking+=e.text,m.thinkingSignature=u(m.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:e.text,partial:r})):(m.text+=e.text,m.textSignature=u(m.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:e.text,partial:r}))}if(e.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:r}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:r}),null);let t=e.functionCall.id,n={type:`toolCall`,id:!t||r.content.some(e=>e.type===`toolCall`&&e.id===t)?`${e.functionCall.name}_${Date.now()}_${++h}`:t,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};r.content.push(n),a.push({type:`toolcall_start`,contentIndex:_(),partial:r}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(n.arguments),partial:r}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:n,partial:r})}}i?.finishReason&&(r.stopReason=s(i.finishReason),r.content.some(e=>e.type===`toolCall`)&&(r.stopReason=`toolUse`)),n.usageMetadata&&(r.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(t,r.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:r}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:r})),i?.signal?.aborted)throw Error(`Request was aborted`);if(r.stopReason===`aborted`||r.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:r.stopReason,message:r}),a.end()}catch(e){for(let e of r.content)`index`in e&&delete e.index;r.stopReason=i?.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:r.stopReason,error:r}),a.end()}})(),a},_=(e,r,i)=>{let a=n(e,i,void 0);if(!i?.reasoning)return g(e,r,{...a,thinking:{enabled:!1}});let o=t(e,i.reasoning),s=o===`off`?`high`:o,c=e;return O(c)||k(c)?g(e,r,{...a,thinking:{enabled:!0,level:j(s,c)}}):g(e,r,{...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{$ as e,Q as t,X as n,v as r}from"./main-BtoNCPyQ.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-BEVjYKj2.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=(e,r,i)=>{let a=new n;return(async()=>{let n={role:`assistant`,content:[],api:`google-vertex`,provider:e.provider,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()};try{let o=T(i),c=o?x(e,o,i?.headers):b(e,D(i),O(i),i?.headers),l=k(e,r,i),f=await i?.onPayload?.(l,e);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}},t(e,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=(t,n,i)=>{let a=r(t,i,void 0);if(!i?.reasoning)return v(t,n,{...a,thinking:{enabled:!1}});let o=e(t,i.reasoning),s=o===`off`?`high`:o,c=t;return A(c)||j(c)?v(t,n,{...a,thinking:{enabled:!0,level:N(s,c)}}):v(t,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
+ import{$ as e,Q as t,X as n,v as r}from"./main-B17wOcQm.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-BLw0sd3s.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=(e,r,i)=>{let a=new n;return(async()=>{let n={role:`assistant`,content:[],api:`google-vertex`,provider:e.provider,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()};try{let o=T(i),c=o?x(e,o,i?.headers):b(e,D(i),O(i),i?.headers),l=k(e,r,i),f=await i?.onPayload?.(l,e);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}},t(e,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=(t,n,i)=>{let a=r(t,i,void 0);if(!i?.reasoning)return v(t,n,{...a,thinking:{enabled:!1}});let o=e(t,i.reasoning),s=o===`off`?`high`:o,c=t;return A(c)||j(c)?v(t,n,{...a,thinking:{enabled:!0,level:N(s,c)}}):v(t,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{mt as e}from"./kernel-worker-aL7clsM2.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{mt as e}from"./kernel-worker-thcJSaI4.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};