sliccy 1.23.2 → 1.23.4
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/{___vite-browser-external_commonjs-proxy-DJjtBAzT.js → ___vite-browser-external_commonjs-proxy-BZRJ6_X4.js} +1 -1
- package/dist/ui/assets/{anthropic-D2LAO3ec.js → anthropic-CFRG0Hfe.js} +1 -1
- package/dist/ui/assets/anthropic-h0YkYJvY.js +2 -0
- package/dist/ui/assets/azure-openai-responses-B72ahkq2.js +1 -0
- package/dist/ui/assets/{azure-openai-responses-CRZc4-49.js → azure-openai-responses-DiuVg7QC.js} +1 -1
- package/dist/ui/assets/{bsh-watchdog-DF1jz7YG.js → bsh-watchdog-BHj7Fs8o.js} +1 -1
- package/dist/ui/assets/client-CLc9DbbF.js +23 -0
- package/dist/ui/assets/github-copilot-headers-Dz44zqGk.js +1 -0
- package/dist/ui/assets/google-CVSsY19W.js +1 -0
- package/dist/ui/assets/{google-U_C7Pazm.js → google-FJTEoy_e.js} +1 -1
- package/dist/ui/assets/google-gemini-cli-T80C305w.js +2 -0
- package/dist/ui/assets/{google-gemini-cli-CzBfYt4_.js → google-gemini-cli-gF7kFWc4.js} +1 -1
- package/dist/ui/assets/{google-shared-FSIbZjLZ.js → google-shared-BjArPveV.js} +1 -1
- package/dist/ui/assets/google-shared-CYYiav7i.js +2 -0
- package/dist/ui/assets/google-vertex-6VDNXf5n.js +1 -0
- package/dist/ui/assets/{google-vertex-C732IhNh.js → google-vertex-CjjOIg6q.js} +1 -1
- package/dist/ui/assets/hash-k-C9KAKF.js +1 -0
- package/dist/ui/assets/{index-BfTbMhIq.js → index-BTBHJQVY.js} +1 -1
- package/dist/ui/assets/{index-DknnmEPX.js → index-BbFB6aZt.js} +2 -2
- package/dist/ui/assets/{index-YmeV9Jqf.js → index-C7KXlIoI.js} +1 -1
- package/dist/ui/assets/{index-CNJf5i_6.js → index-C9qsgFXA.js} +1 -1
- package/dist/ui/assets/{index-B-xljX2v.js → index-CMitoXJI.js} +1 -1
- package/dist/ui/assets/index-CYH9nDaE.js +15023 -0
- package/dist/ui/assets/{index-CaNBjh71.js → index-CmZETbUD.js} +1 -1
- package/dist/ui/assets/{index-CKEflIkf.js → index-Et7zk9Rb.js} +2 -2
- package/dist/ui/assets/{index-CeyfbT1z.js → index-TCK0ykMx.js} +1 -1
- package/dist/ui/assets/index-uz_REvSi.js +5 -0
- package/dist/ui/assets/{json-parse-BCE40htG.js → json-parse-BRxcI2Wj.js} +1 -1
- package/dist/ui/assets/json-parse-zqPLE5kv.js +1 -0
- package/dist/ui/assets/{mistral-BDvM3VUI.js → mistral-BnNh3LzR.js} +8 -8
- package/dist/ui/assets/mistral-DBk4zmZV.js +8 -0
- package/dist/ui/assets/{offscreen-client-L-9S-Lfw.js → offscreen-client-DdMA5sAC.js} +1 -1
- package/dist/ui/assets/openai-codex-responses-BRTJp-Ny.js +7 -0
- package/dist/ui/assets/{openai-codex-responses-B17sbyI5.js → openai-codex-responses-DXePmJ37.js} +1 -1
- package/dist/ui/assets/{openai-completions-4N9csiit.js → openai-completions-BJ5tXvNF.js} +1 -1
- package/dist/ui/assets/openai-completions-CFS00Zu3.js +6 -0
- package/dist/ui/assets/openai-responses-D0cbe-PZ.js +1 -0
- package/dist/ui/assets/{openai-responses-j29whBIs.js → openai-responses-GLrZ6X81.js} +1 -1
- package/dist/ui/assets/openai-responses-shared-B_0Hvupy.js +10 -0
- package/dist/ui/assets/{openai-responses-shared-CNs3k_0q.js → openai-responses-shared-CCp4pUoS.js} +1 -1
- package/dist/ui/assets/{sql-wasm-D8k4OLXL.js → sql-wasm-WyohJvyK.js} +1 -1
- package/dist/ui/assets/transform-messages-DqxXnsXK.js +1 -0
- package/dist/ui/index.html +1 -1
- package/dist/ui/packages/webapp/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-BKFeHvuQ.js +0 -15079
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as r,d as g}from"./index-
|
|
1
|
+
import{F as r,d as g}from"./index-CYH9nDaE.js";import{t as O,s as l}from"./transform-messages-BkE2P08Y.js";function F(t){return t.thought===!0}function G(t,n){return typeof n=="string"&&n.length>0?n:t}const _=/^[A-Za-z0-9+/]+={0,2}$/,x="skip_thought_signature_validator";function N(t){return!t||t.length%4!==0?!1:_.test(t)}function m(t,n){return t&&N(n)?n:void 0}function T(t){return t.startsWith("claude-")||t.startsWith("gpt-oss-")}function R(t){const n=t.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(n)return Number.parseInt(n[1],10)}function M(t){const n=R(t);return n!==void 0?n>=3:!0}function L(t,n){const a=[],I=s=>T(t.id)?s.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64):s,A=O(n.messages,t,I);for(const s of A)if(s.role==="user")if(typeof s.content=="string")a.push({role:"user",parts:[{text:l(s.content)}]});else{const i=s.content.map(e=>e.type==="text"?{text:l(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}}),o=t.input.includes("image")?i:i.filter(e=>e.text!==void 0);if(o.length===0)continue;a.push({role:"user",parts:o})}else if(s.role==="assistant"){const i=[],o=s.provider===t.provider&&s.model===t.id;for(const e of s.content)if(e.type==="text"){if(!e.text||e.text.trim()==="")continue;const c=m(o,e.textSignature);i.push({text:l(e.text),...c&&{thoughtSignature:c}})}else if(e.type==="thinking"){if(!e.thinking||e.thinking.trim()==="")continue;if(o){const c=m(o,e.thinkingSignature);i.push({thought:!0,text:l(e.thinking),...c&&{thoughtSignature:c}})}else i.push({text:l(e.thinking)})}else if(e.type==="toolCall"){const c=m(o,e.thoughtSignature),p=t.id.toLowerCase().includes("gemini-3"),f=c||(p?x:void 0),h={functionCall:{name:e.name,args:e.arguments??{},...T(t.id)?{id:e.id}:{}},...f&&{thoughtSignature:f}};i.push(h)}if(i.length===0)continue;a.push({role:"model",parts:i})}else if(s.role==="toolResult"){const o=s.content.filter(u=>u.type==="text").map(u=>u.text).join(`
|
|
2
2
|
`),e=t.input.includes("image")?s.content.filter(u=>u.type==="image"):[],c=o.length>0,p=e.length>0,f=M(t.id),h=c?l(o):p?"(see attached image)":"",S=e.map(u=>({inlineData:{mimeType:u.mimeType,data:u.data}})),C=T(t.id),E={functionResponse:{name:s.toolName,response:s.isError?{error:h}:{output:h},...p&&f&&{parts:S},...C?{id:s.toolCallId}:{}}},d=a[a.length-1];d?.role==="user"&&d.parts?.some(u=>u.functionResponse)?d.parts.push(E):a.push({role:"user",parts:[E]}),p&&!f&&a.push({role:"user",parts:[{text:"Tool result image:"},...S]})}return a}function v(t,n=!1){if(t.length!==0)return[{functionDeclarations:t.map(a=>({name:a.name,description:a.description,...n?{parameters:a.parameters}:{parametersJsonSchema:a.parameters}}))}]}function U(t){switch(t){case"auto":return g.AUTO;case"none":return g.NONE;case"any":return g.ANY;default:return g.AUTO}}function k(t){switch(t){case r.STOP:return"stop";case r.MAX_TOKENS:return"length";case r.BLOCKLIST:case r.PROHIBITED_CONTENT:case r.SPII:case r.SAFETY:case r.IMAGE_SAFETY:case r.IMAGE_PROHIBITED_CONTENT:case r.IMAGE_RECITATION:case r.IMAGE_OTHER:case r.RECITATION:case r.FINISH_REASON_UNSPECIFIED:case r.OTHER:case r.LANGUAGE:case r.MALFORMED_FUNCTION_CALL:case r.UNEXPECTED_TOOL_CALL:case r.NO_IMAGE:return"error";default:{const n=t;throw new Error(`Unhandled stop reason: ${n}`)}}}function D(t){switch(t){case"STOP":return"stop";case"MAX_TOKENS":return"length";default:return"error"}}export{v as a,U as b,L as c,D as d,F as i,k as m,G as r};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{F as r,d as g}from"./index-CYH9nDaE.js";import{t as O,s as l}from"./transform-messages-DqxXnsXK.js";function F(t){return t.thought===!0}function G(t,n){return typeof n=="string"&&n.length>0?n:t}const _=/^[A-Za-z0-9+/]+={0,2}$/,x="skip_thought_signature_validator";function N(t){return!t||t.length%4!==0?!1:_.test(t)}function m(t,n){return t&&N(n)?n:void 0}function T(t){return t.startsWith("claude-")||t.startsWith("gpt-oss-")}function R(t){const n=t.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(n)return Number.parseInt(n[1],10)}function M(t){const n=R(t);return n!==void 0?n>=3:!0}function L(t,n){const a=[],I=s=>T(t.id)?s.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64):s,A=O(n.messages,t,I);for(const s of A)if(s.role==="user")if(typeof s.content=="string")a.push({role:"user",parts:[{text:l(s.content)}]});else{const i=s.content.map(e=>e.type==="text"?{text:l(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}}),o=t.input.includes("image")?i:i.filter(e=>e.text!==void 0);if(o.length===0)continue;a.push({role:"user",parts:o})}else if(s.role==="assistant"){const i=[],o=s.provider===t.provider&&s.model===t.id;for(const e of s.content)if(e.type==="text"){if(!e.text||e.text.trim()==="")continue;const c=m(o,e.textSignature);i.push({text:l(e.text),...c&&{thoughtSignature:c}})}else if(e.type==="thinking"){if(!e.thinking||e.thinking.trim()==="")continue;if(o){const c=m(o,e.thinkingSignature);i.push({thought:!0,text:l(e.thinking),...c&&{thoughtSignature:c}})}else i.push({text:l(e.thinking)})}else if(e.type==="toolCall"){const c=m(o,e.thoughtSignature),p=t.id.toLowerCase().includes("gemini-3"),f=c||(p?x:void 0),h={functionCall:{name:e.name,args:e.arguments??{},...T(t.id)?{id:e.id}:{}},...f&&{thoughtSignature:f}};i.push(h)}if(i.length===0)continue;a.push({role:"model",parts:i})}else if(s.role==="toolResult"){const o=s.content.filter(u=>u.type==="text").map(u=>u.text).join(`
|
|
2
|
+
`),e=t.input.includes("image")?s.content.filter(u=>u.type==="image"):[],c=o.length>0,p=e.length>0,f=M(t.id),h=c?l(o):p?"(see attached image)":"",S=e.map(u=>({inlineData:{mimeType:u.mimeType,data:u.data}})),C=T(t.id),E={functionResponse:{name:s.toolName,response:s.isError?{error:h}:{output:h},...p&&f&&{parts:S},...C?{id:s.toolCallId}:{}}},d=a[a.length-1];d?.role==="user"&&d.parts?.some(u=>u.functionResponse)?d.parts.push(E):a.push({role:"user",parts:[E]}),p&&!f&&a.push({role:"user",parts:[{text:"Tool result image:"},...S]})}return a}function v(t,n=!1){if(t.length!==0)return[{functionDeclarations:t.map(a=>({name:a.name,description:a.description,...n?{parameters:a.parameters}:{parametersJsonSchema:a.parameters}}))}]}function U(t){switch(t){case"auto":return g.AUTO;case"none":return g.NONE;case"any":return g.ANY;default:return g.AUTO}}function k(t){switch(t){case r.STOP:return"stop";case r.MAX_TOKENS:return"length";case r.BLOCKLIST:case r.PROHIBITED_CONTENT:case r.SPII:case r.SAFETY:case r.IMAGE_SAFETY:case r.IMAGE_PROHIBITED_CONTENT:case r.IMAGE_RECITATION:case r.IMAGE_OTHER:case r.RECITATION:case r.FINISH_REASON_UNSPECIFIED:case r.OTHER:case r.LANGUAGE:case r.MALFORMED_FUNCTION_CALL:case r.UNEXPECTED_TOOL_CALL:case r.NO_IMAGE:return"error";default:{const n=t;throw new Error(`Unhandled stop reason: ${n}`)}}}function D(t){switch(t){case"STOP":return"stop";case"MAX_TOKENS":return"length";default:return"error"}}export{v as a,U as b,L as c,D as d,F as i,k as m,G as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as b,i as E,G as v,T as h}from"./index-CYH9nDaE.js";import{b as w,c as G,s as M}from"./transform-messages-DqxXnsXK.js";import{i as S,r as x,m as R,c as N,a as P,b as A}from"./google-shared-CYYiav7i.js";var f={};const _="v1",D={THINKING_LEVEL_UNSPECIFIED:h.THINKING_LEVEL_UNSPECIFIED,MINIMAL:h.MINIMAL,LOW:h.LOW,MEDIUM:h.MEDIUM,HIGH:h.HIGH};let U=0;const m=(e,i,n)=>{const a=new b;return(async()=>{const t={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{const r=V(n),d=r?K(e,r,n?.headers):H(e,j(n),B(n),n?.headers);let u=J(e,i,n);const C=await n?.onPayload?.(u,e);C!==void 0&&(u=C);const T=await d.models.generateContentStream(u);a.push({type:"start",partial:t});let o=null;const O=t.content,l=()=>O.length-1;for await(const c of T){t.responseId||=c.responseId;const p=c.candidates?.[0];if(p?.content?.parts)for(const s of p.content.parts){if(s.text!==void 0){const g=S(s);(!o||g&&o.type!=="thinking"||!g&&o.type!=="text")&&(o&&(o.type==="text"?a.push({type:"text_end",contentIndex:O.length-1,content:o.text,partial:t}):a.push({type:"thinking_end",contentIndex:l(),content:o.thinking,partial:t})),g?(o={type:"thinking",thinking:"",thinkingSignature:void 0},t.content.push(o),a.push({type:"thinking_start",contentIndex:l(),partial:t})):(o={type:"text",text:""},t.content.push(o),a.push({type:"text_start",contentIndex:l(),partial:t}))),o.type==="thinking"?(o.thinking+=s.text,o.thinkingSignature=x(o.thinkingSignature,s.thoughtSignature),a.push({type:"thinking_delta",contentIndex:l(),delta:s.text,partial:t})):(o.text+=s.text,o.textSignature=x(o.textSignature,s.thoughtSignature),a.push({type:"text_delta",contentIndex:l(),delta:s.text,partial:t}))}if(s.functionCall){o&&(o.type==="text"?a.push({type:"text_end",contentIndex:l(),content:o.text,partial:t}):a.push({type:"thinking_end",contentIndex:l(),content:o.thinking,partial:t}),o=null);const g=s.functionCall.id,k={type:"toolCall",id:!g||t.content.some(y=>y.type==="toolCall"&&y.id===g)?`${s.functionCall.name}_${Date.now()}_${++U}`:g,name:s.functionCall.name||"",arguments:s.functionCall.args??{},...s.thoughtSignature&&{thoughtSignature:s.thoughtSignature}};t.content.push(k),a.push({type:"toolcall_start",contentIndex:l(),partial:t}),a.push({type:"toolcall_delta",contentIndex:l(),delta:JSON.stringify(k.arguments),partial:t}),a.push({type:"toolcall_end",contentIndex:l(),toolCall:k,partial:t})}}p?.finishReason&&(t.stopReason=R(p.finishReason),t.content.some(s=>s.type==="toolCall")&&(t.stopReason="toolUse")),c.usageMetadata&&(t.usage={input:c.usageMetadata.promptTokenCount||0,output:(c.usageMetadata.candidatesTokenCount||0)+(c.usageMetadata.thoughtsTokenCount||0),cacheRead:c.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:c.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},E(e,t.usage))}if(o&&(o.type==="text"?a.push({type:"text_end",contentIndex:l(),content:o.text,partial:t}):a.push({type:"thinking_end",contentIndex:l(),content:o.thinking,partial:t})),n?.signal?.aborted)throw new Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw new Error("An unknown error occurred");a.push({type:"done",reason:t.stopReason,message:t}),a.end()}catch(r){for(const d of t.content)"index"in d&&delete d.index;t.stopReason=n?.signal?.aborted?"aborted":"error",t.errorMessage=r instanceof Error?r.message:JSON.stringify(r),a.push({type:"error",reason:t.stopReason,error:t}),a.end()}})(),a},tt=(e,i,n)=>{const a=w(e,n,void 0);if(!n?.reasoning)return m(e,i,{...a,thinking:{enabled:!1}});const t=G(n.reasoning),r=e;return I(r)||L(r)?m(e,i,{...a,thinking:{enabled:!0,level:$(t,r)}}):m(e,i,{...a,thinking:{enabled:!0,budgetTokens:F(r,t,n.thinkingBudgets)}})};function H(e,i,n,a){const t={};(e.headers||a)&&(t.headers={...e.headers,...a});const r=Object.values(t).some(Boolean);return new v({vertexai:!0,project:i,location:n,apiVersion:_,httpOptions:r?t:void 0})}function K(e,i,n){const a={};(e.headers||n)&&(a.headers={...e.headers,...n});const t=Object.values(a).some(Boolean);return new v({vertexai:!0,apiKey:i,apiVersion:_,httpOptions:t?a:void 0})}function V(e){const i=e?.apiKey?.trim()||f.GOOGLE_CLOUD_API_KEY?.trim();if(!(!i||W(i)))return i}function W(e){return/^<[^>]+>$/.test(e)}function j(e){const i=e?.project||f.GOOGLE_CLOUD_PROJECT||f.GCLOUD_PROJECT;if(!i)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return i}function B(e){const i=e?.location||f.GOOGLE_CLOUD_LOCATION;if(!i)throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return i}function J(e,i,n={}){const a=N(e,i),t={};n.temperature!==void 0&&(t.temperature=n.temperature),n.maxTokens!==void 0&&(t.maxOutputTokens=n.maxTokens);const r={...Object.keys(t).length>0&&t,...i.systemPrompt&&{systemInstruction:M(i.systemPrompt)},...i.tools&&i.tools.length>0&&{tools:P(i.tools)}};if(i.tools&&i.tools.length>0&&n.toolChoice?r.toolConfig={functionCallingConfig:{mode:A(n.toolChoice)}}:r.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){const u={includeThoughts:!0};n.thinking.level!==void 0?u.thinkingLevel=D[n.thinking.level]:n.thinking.budgetTokens!==void 0&&(u.thinkingBudget=n.thinking.budgetTokens),r.thinkingConfig=u}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(r.thinkingConfig=q(e));if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");r.abortSignal=n.signal}return{model:e.id,contents:a,config:r}}function I(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function L(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function q(e){const i=e;return I(i)?{thinkingLevel:h.LOW}:L(i)?{thinkingLevel:h.MINIMAL}:{thinkingBudget:0}}function $(e,i){if(I(i))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 F(e,i,n){return n?.[i]!==void 0?n[i]:e.id.includes("2.5-pro")?{minimal:128,low:2048,medium:8192,high:32768}[i]:e.id.includes("2.5-flash")?{minimal:128,low:2048,medium:8192,high:24576}[i]:-1}export{m as streamGoogleVertex,tt as streamSimpleGoogleVertex};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as b,a as E,G as v,T as h}from"./index-
|
|
1
|
+
import{A as b,a as E,G as v,T as h}from"./index-CYH9nDaE.js";import{b as w,c as G,s as M}from"./transform-messages-BkE2P08Y.js";import{i as S,r as x,m as R,c as N,a as A,b as P}from"./google-shared-BjArPveV.js";var f={};const _="v1",D={THINKING_LEVEL_UNSPECIFIED:h.THINKING_LEVEL_UNSPECIFIED,MINIMAL:h.MINIMAL,LOW:h.LOW,MEDIUM:h.MEDIUM,HIGH:h.HIGH};let U=0;const m=(e,i,n)=>{const a=new b;return(async()=>{const t={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{const r=V(n),d=r?K(e,r,n?.headers):H(e,j(n),B(n),n?.headers);let u=J(e,i,n);const C=await n?.onPayload?.(u,e);C!==void 0&&(u=C);const T=await d.models.generateContentStream(u);a.push({type:"start",partial:t});let o=null;const O=t.content,l=()=>O.length-1;for await(const c of T){t.responseId||=c.responseId;const p=c.candidates?.[0];if(p?.content?.parts)for(const s of p.content.parts){if(s.text!==void 0){const g=S(s);(!o||g&&o.type!=="thinking"||!g&&o.type!=="text")&&(o&&(o.type==="text"?a.push({type:"text_end",contentIndex:O.length-1,content:o.text,partial:t}):a.push({type:"thinking_end",contentIndex:l(),content:o.thinking,partial:t})),g?(o={type:"thinking",thinking:"",thinkingSignature:void 0},t.content.push(o),a.push({type:"thinking_start",contentIndex:l(),partial:t})):(o={type:"text",text:""},t.content.push(o),a.push({type:"text_start",contentIndex:l(),partial:t}))),o.type==="thinking"?(o.thinking+=s.text,o.thinkingSignature=x(o.thinkingSignature,s.thoughtSignature),a.push({type:"thinking_delta",contentIndex:l(),delta:s.text,partial:t})):(o.text+=s.text,o.textSignature=x(o.textSignature,s.thoughtSignature),a.push({type:"text_delta",contentIndex:l(),delta:s.text,partial:t}))}if(s.functionCall){o&&(o.type==="text"?a.push({type:"text_end",contentIndex:l(),content:o.text,partial:t}):a.push({type:"thinking_end",contentIndex:l(),content:o.thinking,partial:t}),o=null);const g=s.functionCall.id,k={type:"toolCall",id:!g||t.content.some(y=>y.type==="toolCall"&&y.id===g)?`${s.functionCall.name}_${Date.now()}_${++U}`:g,name:s.functionCall.name||"",arguments:s.functionCall.args??{},...s.thoughtSignature&&{thoughtSignature:s.thoughtSignature}};t.content.push(k),a.push({type:"toolcall_start",contentIndex:l(),partial:t}),a.push({type:"toolcall_delta",contentIndex:l(),delta:JSON.stringify(k.arguments),partial:t}),a.push({type:"toolcall_end",contentIndex:l(),toolCall:k,partial:t})}}p?.finishReason&&(t.stopReason=R(p.finishReason),t.content.some(s=>s.type==="toolCall")&&(t.stopReason="toolUse")),c.usageMetadata&&(t.usage={input:c.usageMetadata.promptTokenCount||0,output:(c.usageMetadata.candidatesTokenCount||0)+(c.usageMetadata.thoughtsTokenCount||0),cacheRead:c.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:c.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},E(e,t.usage))}if(o&&(o.type==="text"?a.push({type:"text_end",contentIndex:l(),content:o.text,partial:t}):a.push({type:"thinking_end",contentIndex:l(),content:o.thinking,partial:t})),n?.signal?.aborted)throw new Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw new Error("An unknown error occurred");a.push({type:"done",reason:t.stopReason,message:t}),a.end()}catch(r){for(const d of t.content)"index"in d&&delete d.index;t.stopReason=n?.signal?.aborted?"aborted":"error",t.errorMessage=r instanceof Error?r.message:JSON.stringify(r),a.push({type:"error",reason:t.stopReason,error:t}),a.end()}})(),a},tt=(e,i,n)=>{const a=w(e,n,void 0);if(!n?.reasoning)return m(e,i,{...a,thinking:{enabled:!1}});const t=G(n.reasoning),r=e;return I(r)||L(r)?m(e,i,{...a,thinking:{enabled:!0,level:$(t,r)}}):m(e,i,{...a,thinking:{enabled:!0,budgetTokens:F(r,t,n.thinkingBudgets)}})};function H(e,i,n,a){const t={};(e.headers||a)&&(t.headers={...e.headers,...a});const r=Object.values(t).some(Boolean);return new v({vertexai:!0,project:i,location:n,apiVersion:_,httpOptions:r?t:void 0})}function K(e,i,n){const a={};(e.headers||n)&&(a.headers={...e.headers,...n});const t=Object.values(a).some(Boolean);return new v({vertexai:!0,apiKey:i,apiVersion:_,httpOptions:t?a:void 0})}function V(e){const i=e?.apiKey?.trim()||f.GOOGLE_CLOUD_API_KEY?.trim();if(!(!i||W(i)))return i}function W(e){return/^<[^>]+>$/.test(e)}function j(e){const i=e?.project||f.GOOGLE_CLOUD_PROJECT||f.GCLOUD_PROJECT;if(!i)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return i}function B(e){const i=e?.location||f.GOOGLE_CLOUD_LOCATION;if(!i)throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return i}function J(e,i,n={}){const a=N(e,i),t={};n.temperature!==void 0&&(t.temperature=n.temperature),n.maxTokens!==void 0&&(t.maxOutputTokens=n.maxTokens);const r={...Object.keys(t).length>0&&t,...i.systemPrompt&&{systemInstruction:M(i.systemPrompt)},...i.tools&&i.tools.length>0&&{tools:A(i.tools)}};if(i.tools&&i.tools.length>0&&n.toolChoice?r.toolConfig={functionCallingConfig:{mode:P(n.toolChoice)}}:r.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){const u={includeThoughts:!0};n.thinking.level!==void 0?u.thinkingLevel=D[n.thinking.level]:n.thinking.budgetTokens!==void 0&&(u.thinkingBudget=n.thinking.budgetTokens),r.thinkingConfig=u}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(r.thinkingConfig=q(e));if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");r.abortSignal=n.signal}return{model:e.id,contents:a,config:r}}function I(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function L(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function q(e){const i=e;return I(i)?{thinkingLevel:h.LOW}:L(i)?{thinkingLevel:h.MINIMAL}:{thinkingBudget:0}}function $(e,i){if(I(i))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 F(e,i,n){return n?.[i]!==void 0?n[i]:e.id.includes("2.5-pro")?{minimal:128,low:2048,medium:8192,high:32768}[i]:e.id.includes("2.5-flash")?{minimal:128,low:2048,medium:8192,high:24576}[i]:-1}export{m as streamGoogleVertex,tt as streamSimpleGoogleVertex};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(a){let t=3735928559,h=1103547991;for(let e=0;e<a.length;e++){const i=a.charCodeAt(e);t=Math.imul(t^i,2654435761),h=Math.imul(h^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(h^h>>>13,3266489909),h=Math.imul(h^h>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(h>>>0).toString(36)+(t>>>0).toString(36)}export{l as s};
|