sliccy 3.32.2 → 3.34.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.
- package/dist/ui/assets/adobe-BkTvvNWq.js +1 -0
- package/dist/ui/assets/{adobe-0hBB-cvI.js → adobe-C_KbKd0n.js} +2 -2
- package/dist/ui/assets/{agent-bridge-B4fMRTq4.js → agent-bridge-FF6kv2fb.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-BtGucQZb.js → agent-message-to-chat-DkR9NV9t.js} +1 -1
- package/dist/ui/assets/anthropic-DfZXQaUp.js +39 -0
- package/dist/ui/assets/{anthropic-BtADBMTr.js → anthropic-HYC-Omg5.js} +1 -1
- package/dist/ui/assets/{apps-JmnZT0_d.js → apps-BxS_QnGn.js} +1 -1
- package/dist/ui/assets/azure-openai-CLWQP72f.js +1 -0
- package/dist/ui/assets/{azure-openai-BF07BSkG.js → azure-openai-Vm01DpT_.js} +1 -1
- package/dist/ui/assets/azure-openai-responses-33r3NvaZ.js +1 -0
- package/dist/ui/assets/{azure-openai-responses-DAwt8x-O.js → azure-openai-responses-DUgZZ6eN.js} +1 -1
- package/dist/ui/assets/{biome_wasm-CwT46YkP.js → biome_wasm-CvSAK_uf.js} +1 -1
- package/dist/ui/assets/{bsh-watchdog-DOS3grX1.js → bsh-watchdog-Du7KRjWw.js} +1 -1
- package/dist/ui/assets/{cdp-B0CbWj0b.js → cdp-BMZH9kfw.js} +3 -3
- package/dist/ui/assets/{cdp-ws-page-bridge-BaREToXn.js → cdp-ws-page-bridge-DYY56Jqj.js} +1 -1
- package/dist/ui/assets/{common-DPijqIuN.js → common-BG1B2pGi.js} +1 -1
- package/dist/ui/assets/{connect-surface-B8X2BxSx.js → connect-surface-0lxpf-5t.js} +1 -1
- package/dist/ui/assets/cost-command-DNDC9f5s.js +1 -0
- package/dist/ui/assets/dist-BanEKbJr.js +18 -0
- package/dist/ui/assets/dist-CfHbsibs.js +2 -0
- package/dist/ui/assets/dist-JjJ6duRw.js +12 -0
- package/dist/ui/assets/dist-Yxhff45Z.js +2 -0
- package/dist/ui/assets/{es-BvNkEnLt.js → es-CMFNtJSL.js} +5 -5
- package/dist/ui/assets/{follower-sprinkle-bridge-i8o45Iz0.js → follower-sprinkle-bridge-CszKWKEN.js} +1 -1
- package/dist/ui/assets/{github-BHPt4SGX.js → github-D5chbBco.js} +1 -1
- package/dist/ui/assets/github-copilot-DB_-fjnz.js +1 -0
- package/dist/ui/assets/{github-copilot-C1p7G_lc.js → github-copilot-Hxxj6MFv.js} +2 -2
- package/dist/ui/assets/{github-D3FUw7Ft.js → github-lQAdGX0Z.js} +2 -2
- package/dist/ui/assets/{google-vnvvxTni.js → google-6xMZvOez.js} +1 -1
- package/dist/ui/assets/google-CbHlbByo.js +1 -0
- package/dist/ui/assets/{google-shared-DNHwaM2i.js → google-shared-CR-aIyZa.js} +1 -1
- package/dist/ui/assets/{google-shared-Ck5bpSOw.js → google-shared-DX0yj3UK.js} +3 -3
- package/dist/ui/assets/{google-vertex-CkktMzxu.js → google-vertex-BHOYutHi.js} +1 -1
- package/dist/ui/assets/{google-vertex-CwyKiWDF.js → google-vertex-Dpr6tNZD.js} +1 -1
- package/dist/ui/assets/{hosted-config-apply-CAtsa6WM.js → hosted-config-apply-LNWPnWio.js} +1 -1
- package/dist/ui/assets/{intercepted-oauth-CGJydQlU.js → intercepted-oauth-D41iguEu.js} +1 -1
- package/dist/ui/assets/{kernel-worker-Cjl8fjr8.js → kernel-worker-ApBe2nsN.js} +1089 -1062
- package/dist/ui/assets/{lick-ws-bridge-Ca7uAWlQ.js → lick-ws-bridge-DLkh-q6E.js} +1 -1
- package/dist/ui/assets/{local-llm-YcdPZyUH.js → local-llm-BUHqKQIs.js} +1 -1
- package/dist/ui/assets/{magick-wasm-C8lW0-35.js → magick-wasm-WfPf-mzW.js} +1 -1
- package/dist/ui/assets/main-CiPLuc4Y.js +1683 -0
- package/dist/ui/assets/{main-cherry-CfIm_qBH.js → main-cherry-CvuKVZgJ.js} +1 -1
- package/dist/ui/assets/migration-run-CjK_K6H_.js +1 -0
- package/dist/ui/assets/migration-splash-D-cAt2r9.js +1 -0
- package/dist/ui/assets/{mistral-Dgd8b7W0.js → mistral-3BOt-kpO.js} +2 -2
- package/dist/ui/assets/{mistral-DeuCdnLs.js → mistral-7zIzaf30.js} +1 -1
- package/dist/ui/assets/nodejs-BOWNwnaN.js +1 -0
- package/dist/ui/assets/{nuke-command-alibr6is.js → nuke-command-D8Fh0gbL.js} +1 -1
- package/dist/ui/assets/{oauth-BvQKYNNy.js → oauth-DLszIWW7.js} +1 -1
- package/dist/ui/assets/{oauth-bootstrap-BAnHB1H5.js → oauth-bootstrap-Bkf6-I68.js} +2 -2
- package/dist/ui/assets/{oauth-service-2Bm2tu9h.js → oauth-service-DclCNOyC.js} +1 -1
- package/dist/ui/assets/{oauth-service-HBkDeXXf.js → oauth-service-IRbgSoZf.js} +1 -1
- package/dist/ui/assets/offscreen-client-WfjjyTww.js +1 -0
- package/dist/ui/assets/{onboarding-orchestrator-VipPxQM9.js → onboarding-orchestrator-Cj4wwL1r.js} +1 -1
- package/dist/ui/assets/{openai-codex-BOCOi8v3.js → openai-codex-DQpjVOFB.js} +1 -1
- package/dist/ui/assets/openai-codex-o1t-m8rL.js +1 -0
- package/dist/ui/assets/{openai-codex-responses-2_MR5Im1.js → openai-codex-responses-DGMmjslY.js} +1 -1
- package/dist/ui/assets/{openai-codex-responses-XAgywVT2.js → openai-codex-responses-DhoTOdH3.js} +4 -4
- package/dist/ui/assets/{openai-completions-aOEJoPfR.js → openai-completions-CTH4LB2F.js} +1 -1
- package/dist/ui/assets/openai-responses-D68JIQf1.js +1 -0
- package/dist/ui/assets/{openai-responses-DV7QYgXj.js → openai-responses-Hs-gRUiN.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-BK_I3ssh.js → openai-responses-shared-S3zguGjk.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-CU6P3yaz.js → openai-responses-shared-yJFA8VNU.js} +5 -5
- package/dist/ui/assets/{openrouter-C8oMEs0J.js → openrouter-B2BsIHza.js} +1 -1
- package/dist/ui/assets/openrouter-UArPIjqO.js +1 -0
- package/dist/ui/assets/opfs-leader-election-BJDtxHPr.js +1 -0
- package/dist/ui/assets/opfs-readonly-banner-BwveszbN.js +1 -0
- package/dist/ui/assets/{panel-rpc-handlers-DHlnRnNz.js → panel-rpc-handlers-CkCiX7Tp.js} +1 -1
- package/dist/ui/assets/panel-vfs-guard-1E455_lR.js +1 -0
- package/dist/ui/assets/provider-BYq4p5If.js +1 -0
- package/dist/ui/assets/{provider-DB2BpoXt.js → provider-Cs2-iVKM.js} +2 -2
- package/dist/ui/assets/provider-store-access-G9HYvkSk.js +1 -0
- package/dist/ui/assets/provider-store-access-Mcnc2eQL.js +1 -0
- package/dist/ui/assets/{proxied-fetch-ChX8PtVt.js → proxied-fetch-B31wB0pw.js} +1 -1
- package/dist/ui/assets/py-realm-worker-DhXHapes.js +23 -0
- package/dist/ui/assets/pyodide-BXKIZesR.js +3 -0
- package/dist/ui/assets/{remote-terminal-view-BYUBsOyw.js → remote-terminal-view-D8Lym4ke.js} +1 -1
- package/dist/ui/assets/remote-vfs-client-CX-U7Vpk.js +1 -0
- package/dist/ui/assets/{secret-env-yupQt_od.js → secret-env-We7YhnkP.js} +1 -1
- package/dist/ui/assets/{slicc-editor-Bdty0qFW.js → slicc-editor-D1shQp3f.js} +1 -1
- package/dist/ui/assets/spawn-BROIpDuE.js +1 -0
- package/dist/ui/assets/{sql-wasm-D0KJBRcf.js → sql-wasm-BKOzFTaN.js} +2 -2
- package/dist/ui/assets/src-LhD223BJ.js +3 -0
- package/dist/ui/assets/{store-CoqxzWD_.js → store-DcwzvMDt.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-DgzvG0cq.js → tray-leave-runtime-D0wlJrCA.js} +1 -1
- package/dist/ui/assets/{typescript-D8obSBRU.js → typescript-BegR4udl.js} +9 -9
- package/dist/ui/assets/{upgrade-detection-SLtjojQ6.js → upgrade-detection-fcwNs12W.js} +1 -1
- package/dist/ui/assets/{web-2nwzshjs.js → web-VQMyUYjU.js} +1 -1
- package/dist/ui/assets/writable-vfs-client-C-OKNpFf.js +1 -0
- package/dist/ui/assets/{ws-subscribers-D0P6rQ_C.js → ws-subscribers-CWuwl3YA.js} +1 -1
- package/dist/ui/assets/{xai-grok-CGuHGhwm.js → xai-grok-DEMNJsqQ.js} +1 -1
- package/dist/ui/assets/xai-grok-g5ns0DU5.js +1 -0
- package/dist/ui/electron-overlay-entry.js +10 -10
- package/dist/ui/index.html +1 -1
- package/dist/ui/packages/webapp/index.html +1 -1
- package/dist/ui/preview-sw.js +1 -4
- package/package.json +1 -1
- package/dist/ui/assets/adobe-Siq458HU.js +0 -1
- package/dist/ui/assets/anthropic-ClPBBm6O.js +0 -39
- package/dist/ui/assets/azure-openai-BadnFKYq.js +0 -1
- package/dist/ui/assets/azure-openai-responses-PyfCX2VE.js +0 -1
- package/dist/ui/assets/cost-command-CEPNh0VO.js +0 -1
- package/dist/ui/assets/github-copilot-C7jxXCHT.js +0 -1
- package/dist/ui/assets/google-DS3rVZP1.js +0 -1
- package/dist/ui/assets/main-BccCPfVs.js +0 -1685
- package/dist/ui/assets/nodejs-D_wR4YhI.js +0 -1
- package/dist/ui/assets/offscreen-client-ijhP4Z8j.js +0 -1
- package/dist/ui/assets/openai-codex-BquojmIo.js +0 -1
- package/dist/ui/assets/openai-responses-CSMuG2OA.js +0 -1
- package/dist/ui/assets/openrouter-ybLvFVQF.js +0 -1
- package/dist/ui/assets/provider-CuDhBMAi.js +0 -1
- package/dist/ui/assets/provider-store-access-C_cZs2wy.js +0 -1
- package/dist/ui/assets/provider-store-access-DGBFQqC5.js +0 -1
- package/dist/ui/assets/py-realm-worker-BDTXsbRf.js +0 -23
- package/dist/ui/assets/pyodide-CjGywQ7Z.js +0 -3
- package/dist/ui/assets/spawn-BQL7p7C6.js +0 -1
- package/dist/ui/assets/xai-grok-24FXuNvx.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{St as e,_t as t,j as n,l as r}from"./kernel-worker-ApBe2nsN.js";var i=t(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),a=t((e=>{var t=i();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),o=t(((e,t)=>{t.exports=a()})),s=e(t(((e,t)=>{let n=o(),r=[`Failed to fetch`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`];var i=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=Error(e),this.originalError.stack=this.stack),this.name=`AbortError`,this.message=e}};let a=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},s=e=>r.includes(e),c=(e,t)=>new Promise((r,o)=>{t={onFailedAttempt:()=>{},retries:10,...t};let c=n.operation(t);c.attempt(async n=>{try{r(await e(n))}catch(e){if(!(e instanceof Error)){o(TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));return}if(e instanceof i)c.stop(),o(e.originalError);else if(e instanceof TypeError&&!s(e.message))c.stop(),o(e);else{a(e,n,t);try{await t.onFailedAttempt(e)}catch(e){o(e);return}c.retry(e)||o(c.mainError())}}})});t.exports=c,t.exports.default=c,t.exports.AbortError=i}))(),1)
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2025 Google LLC
|
|
@@ -360,5 +360,5 @@ const eu=`x-goog-api-key`;var tu=class{constructor(e){this.apiKey=e}async addAut
|
|
|
360
360
|
* Copyright 2025 Google LLC
|
|
361
361
|
* SPDX-License-Identifier: Apache-2.0
|
|
362
362
|
*/
|
|
363
|
-
if(this._interactions!==void 0)return this._interactions;console.warn(`GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.`);let e=this.httpOptions;e?.extraBody&&console.warn(`GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.`);let t=new $({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:e?.timeout,maxRetries:e?.retryOptions?.attempts});return this._interactions=t.interactions,this._interactions}constructor(e){if(e.apiKey==null)throw Error(`An API Key must be set when running in a browser`);if(e.project||e.location)throw Error(`Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.`);this.vertexai=e.vertexai??!1,this.apiKey=e.apiKey;let t=l(e.httpOptions,e.vertexai,void 0,void 0);t&&(e.httpOptions?e.httpOptions.baseUrl=t:e.httpOptions={baseUrl:t}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let n=new tu(this.apiKey);this.apiClient=new $o({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new Zl,downloader:new Wl}),this.models=new Ss(this.apiClient),this.live=new ps(this.apiClient,n,new Ql),this.batches=new sr(this.apiClient),this.chats=new qr(this.models,this.apiClient),this.caches=new Br(this.apiClient),this.files=new oi(this.apiClient),this.operations=new Cs(this.apiClient),this.authTokens=new zs(this.apiClient),this.tunings=new Ul(this.apiClient),this.fileSearchStores=new qs(this.apiClient)}};function ru(e){return e.thought===!0}function iu(e,t){return typeof t==`string`&&t.length>0?t:e}const au=/^[A-Za-z0-9+/]+={0,2}$/;function ou(e){return!e||e.length%4!=0?!1:au.test(e)}function su(e,t){return e&&ou(t)?t:void 0}function cu(e){return e.startsWith(`claude-`)||e.startsWith(`gpt-oss-`)}function lu(e){let t=e.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(t)return Number.parseInt(t[1],10)}function uu(e){let t=lu(e);return t===void 0?!0:t>=3}function du(
|
|
364
|
-
`),a=
|
|
363
|
+
if(this._interactions!==void 0)return this._interactions;console.warn(`GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.`);let e=this.httpOptions;e?.extraBody&&console.warn(`GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.`);let t=new $({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:e?.timeout,maxRetries:e?.retryOptions?.attempts});return this._interactions=t.interactions,this._interactions}constructor(e){if(e.apiKey==null)throw Error(`An API Key must be set when running in a browser`);if(e.project||e.location)throw Error(`Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.`);this.vertexai=e.vertexai??!1,this.apiKey=e.apiKey;let t=l(e.httpOptions,e.vertexai,void 0,void 0);t&&(e.httpOptions?e.httpOptions.baseUrl=t:e.httpOptions={baseUrl:t}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let n=new tu(this.apiKey);this.apiClient=new $o({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new Zl,downloader:new Wl}),this.models=new Ss(this.apiClient),this.live=new ps(this.apiClient,n,new Ql),this.batches=new sr(this.apiClient),this.chats=new qr(this.models,this.apiClient),this.caches=new Br(this.apiClient),this.files=new oi(this.apiClient),this.operations=new Cs(this.apiClient),this.authTokens=new zs(this.apiClient),this.tunings=new Ul(this.apiClient),this.fileSearchStores=new qs(this.apiClient)}};function ru(e){return e.thought===!0}function iu(e,t){return typeof t==`string`&&t.length>0?t:e}const au=/^[A-Za-z0-9+/]+={0,2}$/;function ou(e){return!e||e.length%4!=0?!1:au.test(e)}function su(e,t){return e&&ou(t)?t:void 0}function cu(e){return e.startsWith(`claude-`)||e.startsWith(`gpt-oss-`)}function lu(e){let t=e.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(t)return Number.parseInt(t[1],10)}function uu(e){let t=lu(e);return t===void 0?!0:t>=3}function du(e,t){let i=[],a=n(t.messages,e,t=>cu(e.id)?t.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64):t);for(let t of a)if(t.role===`user`)if(typeof t.content==`string`)i.push({role:`user`,parts:[{text:r(t.content)}]});else{let e=t.content.map(e=>e.type===`text`?{text:r(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}});if(e.length===0)continue;i.push({role:`user`,parts:e})}else if(t.role===`assistant`){let n=[],a=t.provider===e.provider&&t.model===e.id;for(let i of t.content)if(i.type===`text`){if(!i.text||i.text.trim()===``)continue;let e=su(a,i.textSignature);n.push({text:r(i.text),...e&&{thoughtSignature:e}})}else if(i.type===`thinking`){if(!i.thinking||i.thinking.trim()===``)continue;if(a){let e=su(a,i.thinkingSignature);n.push({thought:!0,text:r(i.thinking),...e&&{thoughtSignature:e}})}else n.push({text:r(i.thinking)})}else if(i.type===`toolCall`){let t=su(a,i.thoughtSignature),r={functionCall:{name:i.name,args:i.arguments??{},...cu(e.id)?{id:i.id}:{}},...t&&{thoughtSignature:t}};n.push(r)}if(n.length===0)continue;i.push({role:`model`,parts:n})}else if(t.role===`toolResult`){let n=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
364
|
+
`),a=e.input.includes(`image`)?t.content.filter(e=>e.type===`image`):[],o=n.length>0,s=a.length>0,c=uu(e.id),l=o?r(n):s?`(see attached image)`:``,u=a.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),d=cu(e.id),f={functionResponse:{name:t.toolName,response:t.isError?{error:l}:{output:l},...s&&c&&{parts:u},...d?{id:t.toolCallId}:{}}},p=i[i.length-1];p?.role===`user`&&p.parts?.some(e=>e.functionResponse)?p.parts.push(f):i.push({role:`user`,parts:[f]}),s&&!c&&i.push({role:`user`,parts:[{text:`Tool result image:`},...u]})}return i}const fu=new Set([`$schema`,`$id`,`$anchor`,`$dynamicAnchor`,`$vocabulary`,`$comment`,`$defs`,`definitions`]);function pu(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={};for(let[n,r]of Object.entries(e))fu.has(n)||(t[n]=pu(r));return t}function mu(e,t=!1){if(e.length!==0)return[{functionDeclarations:e.map(e=>({name:e.name,description:e.description,...t?{parameters:pu(e.parameters)}:{parametersJsonSchema:e.parameters}}))}]}function hu(e){switch(e){case`auto`:return ue.AUTO;case`none`:return ue.NONE;case`any`:return ue.ANY;default:return ue.AUTO}}function gu(e){switch(e){case M.STOP:return`stop`;case M.MAX_TOKENS:return`length`;case M.BLOCKLIST:case M.PROHIBITED_CONTENT:case M.SPII:case M.SAFETY:case M.IMAGE_SAFETY:case M.IMAGE_PROHIBITED_CONTENT:case M.IMAGE_RECITATION:case M.IMAGE_OTHER:case M.RECITATION:case M.FINISH_REASON_UNSPECIFIED:case M.OTHER:case M.LANGUAGE:case M.MALFORMED_FUNCTION_CALL:case M.UNEXPECTED_TOOL_CALL:case M.NO_IMAGE:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}export{hu as a,De as c,gu as i,de as l,mu as n,iu as o,ru as r,nu as s,du as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,et as n,y as r}from"./main-
|
|
1
|
+
import{$ as e,Z as t,et as n,y as r}from"./main-CiPLuc4Y.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-CR-aIyZa.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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{J as e,N as t,X as n,Z as r,l as i}from"./kernel-worker-ApBe2nsN.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-DX0yj3UK.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,r,i)=>{let a=new e;return(async()=>{let e={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,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: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}},n(t,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,n,i)=>{let a=t(e,i,void 0);if(!i?.reasoning)return g(e,n,{...a,thinking:{enabled:!1}});let o=r(e,i.reasoning),s=o===`off`?`high`:o,c=e;return O(c)||k(c)?g(e,n,{...a,thinking:{enabled:!0,level:j(s,c)}}):g(e,n,{...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{I as e}from"./main-
|
|
1
|
+
import{I as e}from"./main-CiPLuc4Y.js";var t=e(`hosted-config`);async function n(e,t){let n=new Set(e.map(e=>e.providerId));for(let n of e)n.kind===`oauth`?await t.saveOAuthAccount({providerId:n.providerId,accessToken:n.accessToken,refreshToken:n.refreshToken,tokenExpiresAt:n.tokenExpiresAt,userName:n.userName,baseUrl:n.baseUrl}):t.addAccount(n.providerId,n.apiKey,n.baseUrl,n.deployment,n.apiVersion);let r=new Set(t.previouslyManaged());for(let e of t.currentProviderIds())r.has(e)&&!n.has(e)&&await t.removeAccount(e)}async function r(e,n,r=5e3){await Promise.all(e.map(async e=>{if(e.kind!==`oauth`||!e.accessToken)return;let i=n.getRefreshModels(e.providerId);if(i)try{await Promise.race([i(e.accessToken),new Promise(e=>setTimeout(e,r))])}catch(n){t.warn(`prewarm: refreshModels failed; cone boots with cold model metadata`,{providerId:e.providerId,error:n instanceof Error?n.message:String(n)})}}))}export{n as applyHostedAccounts,r as prewarmHostedModels};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{yt as e}from"./kernel-worker-ApBe2nsN.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};
|