@agiflowai/agent-cli 0.0.6 → 0.0.8

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.
@@ -1,18 +1,413 @@
1
- "use strict";const Ms=require("node:os"),js=require("node:path"),ys=require("ulidx"),Ps=require("node:fs"),Ae=require("node:perf_hooks"),je=require("path"),Se=require("fs-extra"),Ft=require("os");require("node:crypto");require("@inquirer/prompts");function Kt(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const Yt=Kt(Ms),be=Kt(js),Pe=Kt(Ps);var z;(function(r){r.assertEqual=o=>{};function e(o){}r.assertIs=e;function t(o){throw new Error}r.assertNever=t,r.arrayToEnum=o=>{const n={};for(const i of o)n[i]=i;return n},r.getValidEnumValues=o=>{const n=r.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(const a of n)i[a]=o[a];return r.objectValues(i)},r.objectValues=o=>r.objectKeys(o).map(function(n){return o[n]}),r.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const n=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&n.push(i);return n},r.find=(o,n)=>{for(const i of o)if(n(i))return i},r.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function s(o,n=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}r.joinValues=s,r.jsonStringifyReplacer=(o,n)=>typeof n=="bigint"?n.toString():n})(z||(z={}));var Vt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Vt||(Vt={}));const f=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ye=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},c=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),$s=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class ne extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(n){return n.message},s={_errors:[]},o=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let a=s,p=0;for(;p<i.path.length;){const _=i.path[p];p===i.path.length-1?(a[_]=a[_]||{_errors:[]},a[_]._errors.push(t(i))):a[_]=a[_]||{_errors:[]},a=a[_],p++}}};return o(this),s}static assert(e){if(!(e instanceof ne))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const o of this.issues)if(o.path.length>0){const n=o.path[0];t[n]=t[n]||[],t[n].push(e(o))}else s.push(e(o));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}ne.create=r=>new ne(r);const Je=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,z.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${z.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${z.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${z.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:z.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,z.assertNever(r)}return{message:t}};let bs=Je;function Fs(r){bs=r}function At(){return bs}const Ot=r=>{const{data:e,path:t,errorMaps:s,issueData:o}=r,n=[...t,...o.path||[]],i={...o,path:n};if(o.message!==void 0)return{...o,path:n,message:o.message};let a="";const p=s.filter(_=>!!_).slice().reverse();for(const _ of p)a=_(i,{data:e,defaultError:a}).message;return{...o,path:n,message:a}},Ds=[];function m(r,e){const t=At(),s=Ot({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Je?void 0:Je].filter(o=>!!o)});r.common.issues.push(s)}class se{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const o of t){if(o.status==="aborted")return S;o.status==="dirty"&&e.dirty(),s.push(o.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const o of t){const n=await o.key,i=await o.value;s.push({key:n,value:i})}return se.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const o of t){const{key:n,value:i}=o;if(n.status==="aborted"||i.status==="aborted")return S;n.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(s[n.value]=i.value)}return{status:e.value,value:s}}}const S=Object.freeze({status:"aborted"}),Ue=r=>({status:"dirty",value:r}),re=r=>({status:"valid",value:r}),Gt=r=>r.status==="aborted",Ut=r=>r.status==="dirty",Fe=r=>r.status==="valid",ot=r=>typeof Promise<"u"&&r instanceof Promise;var b;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));class fe{constructor(e,t,s,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ns=(r,e)=>{if(Fe(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ne(r.common.issues);return this._error=t,this._error}}};function I(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:o}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{const{message:p}=r;return i.code==="invalid_enum_value"?{message:p??a.defaultError}:typeof a.data>"u"?{message:p??s??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:p??t??a.defaultError}},description:o}}class A{get description(){return this._def.description}_getType(e){return ye(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ye(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new se,ctx:{common:e.parent.common,data:e.data,parsedType:ye(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ot(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ye(e)},o=this._parseSync({data:e,path:s.path,parent:s});return ns(s,o)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ye(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return Fe(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>Fe(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ye(e)},o=this._parse({data:e,path:s.path,parent:s}),n=await(ot(o)?o:Promise.resolve(o));return ns(s,n)}refine(e,t){const s=o=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(o):t;return this._refinement((o,n)=>{const i=e(o),a=()=>n.addIssue({code:c.custom,...s(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(p=>p?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((s,o)=>e(s)?!0:(o.addIssue(typeof t=="function"?t(s,o):t),!1))}_refinement(e){return new de({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return he.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return le.create(this)}promise(){return Ke.create(this,this._def)}or(e){return at.create([this,e],this._def)}and(e){return pt.create(this,e,this._def)}transform(e){return new de({...I(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new dt({...I(this._def),innerType:this,defaultValue:t,typeName:E.ZodDefault})}brand(){return new Xt({typeName:E.ZodBranded,type:this,...I(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new mt({...I(this._def),innerType:this,catchValue:t,typeName:E.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ft.create(this,e)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Bs=/^c[^\s-]{8,}$/i,qs=/^[0-9a-z]+$/,Vs=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gs=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Us=/^[a-z0-9_-]{21}$/i,Zs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hs=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Js=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ws="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Dt;const Ks=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ys=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Xs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,to=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ws="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",so=new RegExp(`^${ws}$`);function Ts(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function oo(r){return new RegExp(`^${Ts(r)}$`)}function Ss(r){let e=`${ws}T${Ts(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ro(r,e){return!!((e==="v4"||!e)&&Ks.test(r)||(e==="v6"||!e)&&Xs.test(r))}function no(r,e){if(!Zs.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),o=JSON.parse(atob(s));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function io(r,e){return!!((e==="v4"||!e)&&Ys.test(r)||(e==="v6"||!e)&&Qs.test(r))}class ce extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const n=this._getOrReturnCtx(e);return m(n,{code:c.invalid_type,expected:f.string,received:n.parsedType}),S}const s=new se;let o;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:c.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="max")e.data.length>n.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:c.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){const i=e.data.length>n.value,a=e.data.length<n.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?m(o,{code:c.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&m(o,{code:c.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),s.dirty())}else if(n.kind==="email")Js.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"email",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="emoji")Dt||(Dt=new RegExp(Ws,"u")),Dt.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"emoji",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="uuid")Gs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"uuid",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="nanoid")Us.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"nanoid",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="cuid")Bs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="cuid2")qs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid2",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="ulid")Vs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ulid",code:c.invalid_string,message:n.message}),s.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),m(o,{validation:"url",code:c.invalid_string,message:n.message}),s.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"regex",code:c.invalid_string,message:n.message}),s.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(o=this._getOrReturnCtx(e,o),m(o,{code:c.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),s.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:c.invalid_string,validation:{startsWith:n.value},message:n.message}),s.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:c.invalid_string,validation:{endsWith:n.value},message:n.message}),s.dirty()):n.kind==="datetime"?Ss(n).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:c.invalid_string,validation:"datetime",message:n.message}),s.dirty()):n.kind==="date"?so.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:c.invalid_string,validation:"date",message:n.message}),s.dirty()):n.kind==="time"?oo(n).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:c.invalid_string,validation:"time",message:n.message}),s.dirty()):n.kind==="duration"?Hs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"duration",code:c.invalid_string,message:n.message}),s.dirty()):n.kind==="ip"?ro(e.data,n.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ip",code:c.invalid_string,message:n.message}),s.dirty()):n.kind==="jwt"?no(e.data,n.alg)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"jwt",code:c.invalid_string,message:n.message}),s.dirty()):n.kind==="cidr"?io(e.data,n.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cidr",code:c.invalid_string,message:n.message}),s.dirty()):n.kind==="base64"?eo.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64",code:c.invalid_string,message:n.message}),s.dirty()):n.kind==="base64url"?to.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64url",code:c.invalid_string,message:n.message}),s.dirty()):z.assertNever(n);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(o=>e.test(o),{validation:t,code:c.invalid_string,...b.errToObj(s)})}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new ce({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ce({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ce({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ce.create=r=>new ce({checks:[],typeName:E.ZodString,coerce:r?.coerce??!1,...I(r)});function ao(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,o=t>s?t:s,n=Number.parseInt(r.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return n%i/10**o}class Oe extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const n=this._getOrReturnCtx(e);return m(n,{code:c.invalid_type,expected:f.number,received:n.parsedType}),S}let s;const o=new se;for(const n of this._def.checks)n.kind==="int"?z.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:c.invalid_type,expected:"integer",received:"float",message:n.message}),o.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:c.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),o.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:c.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),o.dirty()):n.kind==="multipleOf"?ao(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),m(s,{code:c.not_multiple_of,multipleOf:n.value,message:n.message}),o.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:c.not_finite,message:n.message}),o.dirty()):z.assertNever(n);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,o){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(o)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&z.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Oe.create=r=>new Oe({checks:[],typeName:E.ZodNumber,coerce:r?.coerce||!1,...I(r)});class Re extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let s;const o=new se;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:c.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),o.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:c.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),o.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),m(s,{code:c.not_multiple_of,multipleOf:n.value,message:n.message}),o.dirty()):z.assertNever(n);return{status:o.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return m(t,{code:c.invalid_type,expected:f.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,o){return new Re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(o)}]})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Re.create=r=>new Re({checks:[],typeName:E.ZodBigInt,coerce:r?.coerce??!1,...I(r)});class rt extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const s=this._getOrReturnCtx(e);return m(s,{code:c.invalid_type,expected:f.boolean,received:s.parsedType}),S}return re(e.data)}}rt.create=r=>new rt({typeName:E.ZodBoolean,coerce:r?.coerce||!1,...I(r)});class De extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const n=this._getOrReturnCtx(e);return m(n,{code:c.invalid_type,expected:f.date,received:n.parsedType}),S}if(Number.isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return m(n,{code:c.invalid_date}),S}const s=new se;let o;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:c.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),s.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:c.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):z.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}De.create=r=>new De({checks:[],coerce:r?.coerce||!1,typeName:E.ZodDate,...I(r)});class Rt extends A{_parse(e){if(this._getType(e)!==f.symbol){const s=this._getOrReturnCtx(e);return m(s,{code:c.invalid_type,expected:f.symbol,received:s.parsedType}),S}return re(e.data)}}Rt.create=r=>new Rt({typeName:E.ZodSymbol,...I(r)});class nt extends A{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:c.invalid_type,expected:f.undefined,received:s.parsedType}),S}return re(e.data)}}nt.create=r=>new nt({typeName:E.ZodUndefined,...I(r)});class it extends A{_parse(e){if(this._getType(e)!==f.null){const s=this._getOrReturnCtx(e);return m(s,{code:c.invalid_type,expected:f.null,received:s.parsedType}),S}return re(e.data)}}it.create=r=>new it({typeName:E.ZodNull,...I(r)});class We extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return re(e.data)}}We.create=r=>new We({typeName:E.ZodAny,...I(r)});class $e extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return re(e.data)}}$e.create=r=>new $e({typeName:E.ZodUnknown,...I(r)});class we extends A{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),S}}we.create=r=>new we({typeName:E.ZodNever,...I(r)});class zt extends A{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:c.invalid_type,expected:f.void,received:s.parsedType}),S}return re(e.data)}}zt.create=r=>new zt({typeName:E.ZodVoid,...I(r)});class le extends A{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),o=this._def;if(t.parsedType!==f.array)return m(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),S;if(o.exactLength!==null){const i=t.data.length>o.exactLength.value,a=t.data.length<o.exactLength.value;(i||a)&&(m(t,{code:i?c.too_big:c.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),s.dirty())}if(o.minLength!==null&&t.data.length<o.minLength.value&&(m(t,{code:c.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),s.dirty()),o.maxLength!==null&&t.data.length>o.maxLength.value&&(m(t,{code:c.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,a)=>o.type._parseAsync(new fe(t,i,t.path,a)))).then(i=>se.mergeArray(s,i));const n=[...t.data].map((i,a)=>o.type._parseSync(new fe(t,i,t.path,a)));return se.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new le({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new le({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new le({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}le.create=(r,e)=>new le({type:r,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...I(e)});function Ge(r){if(r instanceof D){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=he.create(Ge(s))}return new D({...r._def,shape:()=>e})}else return r instanceof le?new le({...r._def,type:Ge(r.element)}):r instanceof he?he.create(Ge(r.unwrap())):r instanceof Ce?Ce.create(Ge(r.unwrap())):r instanceof ke?ke.create(r.items.map(e=>Ge(e))):r}class D extends A{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=z.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){const _=this._getOrReturnCtx(e);return m(_,{code:c.invalid_type,expected:f.object,received:_.parsedType}),S}const{status:s,ctx:o}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof we&&this._def.unknownKeys==="strip"))for(const _ in o.data)i.includes(_)||a.push(_);const p=[];for(const _ of i){const l=n[_],v=o.data[_];p.push({key:{status:"valid",value:_},value:l._parse(new fe(o,v,o.path,_)),alwaysSet:_ in o.data})}if(this._def.catchall instanceof we){const _=this._def.unknownKeys;if(_==="passthrough")for(const l of a)p.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(_==="strict")a.length>0&&(m(o,{code:c.unrecognized_keys,keys:a}),s.dirty());else if(_!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const _=this._def.catchall;for(const l of a){const v=o.data[l];p.push({key:{status:"valid",value:l},value:_._parse(new fe(o,v,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const _=[];for(const l of p){const v=await l.key,k=await l.value;_.push({key:v,value:k,alwaysSet:l.alwaysSet})}return _}).then(_=>se.mergeObjectSync(s,_)):se.mergeObjectSync(s,p)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new D({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const o=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:b.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new D({...this._def,unknownKeys:"strip"})}passthrough(){return new D({...this._def,unknownKeys:"passthrough"})}extend(e){return new D({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new D({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:E.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new D({...this._def,catchall:e})}pick(e){const t={};for(const s of z.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new D({...this._def,shape:()=>t})}omit(e){const t={};for(const s of z.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new D({...this._def,shape:()=>t})}deepPartial(){return Ge(this)}partial(e){const t={};for(const s of z.objectKeys(this.shape)){const o=this.shape[s];e&&!e[s]?t[s]=o:t[s]=o.optional()}return new D({...this._def,shape:()=>t})}required(e){const t={};for(const s of z.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof he;)n=n._def.innerType;t[s]=n}return new D({...this._def,shape:()=>t})}keyof(){return Es(z.objectKeys(this.shape))}}D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:we.create(),typeName:E.ZodObject,...I(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:we.create(),typeName:E.ZodObject,...I(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:we.create(),typeName:E.ZodObject,...I(e)});class at extends A{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function o(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const i=n.map(a=>new ne(a.ctx.common.issues));return m(t,{code:c.invalid_union,unionErrors:i}),S}if(t.common.async)return Promise.all(s.map(async n=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(o);{let n;const i=[];for(const p of s){const _={...t,common:{...t.common,issues:[]},parent:null},l=p._parseSync({data:t.data,path:t.path,parent:_});if(l.status==="valid")return l;l.status==="dirty"&&!n&&(n={result:l,ctx:_}),_.common.issues.length&&i.push(_.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const a=i.map(p=>new ne(p));return m(t,{code:c.invalid_union,unionErrors:a}),S}}get options(){return this._def.options}}at.create=(r,e)=>new at({options:r,typeName:E.ZodUnion,...I(e)});const xe=r=>r instanceof ut?xe(r.schema):r instanceof de?xe(r.innerType()):r instanceof ct?[r.value]:r instanceof ze?r.options:r instanceof lt?z.objectValues(r.enum):r instanceof dt?xe(r._def.innerType):r instanceof nt?[void 0]:r instanceof it?[null]:r instanceof he?[void 0,...xe(r.unwrap())]:r instanceof Ce?[null,...xe(r.unwrap())]:r instanceof Xt||r instanceof ht?xe(r.unwrap()):r instanceof mt?xe(r._def.innerType):[];class Mt extends A{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return m(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),S;const s=this.discriminator,o=t.data[s],n=this.optionsMap.get(o);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const o=new Map;for(const n of t){const i=xe(n.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,n)}}return new Mt({typeName:E.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:o,...I(s)})}}function Zt(r,e){const t=ye(r),s=ye(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){const o=z.objectKeys(e),n=z.objectKeys(r).filter(a=>o.indexOf(a)!==-1),i={...r,...e};for(const a of n){const p=Zt(r[a],e[a]);if(!p.valid)return{valid:!1};i[a]=p.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};const o=[];for(let n=0;n<r.length;n++){const i=r[n],a=e[n],p=Zt(i,a);if(!p.valid)return{valid:!1};o.push(p.data)}return{valid:!0,data:o}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class pt extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),o=(n,i)=>{if(Gt(n)||Gt(i))return S;const a=Zt(n.value,i.value);return a.valid?((Ut(n)||Ut(i))&&t.dirty(),{status:t.value,value:a.data}):(m(s,{code:c.invalid_intersection_types}),S)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([n,i])=>o(n,i)):o(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}pt.create=(r,e,t)=>new pt({left:r,right:e,typeName:E.ZodIntersection,...I(t)});class ke extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return m(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),S;if(s.data.length<this._def.items.length)return m(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&s.data.length>this._def.items.length&&(m(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((i,a)=>{const p=this._def.items[a]||this._def.rest;return p?p._parse(new fe(s,i,s.path,a)):null}).filter(i=>!!i);return s.common.async?Promise.all(n).then(i=>se.mergeArray(t,i)):se.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ke({...this._def,rest:e})}}ke.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ke({items:r,typeName:E.ZodTuple,rest:null,...I(e)})};class _t extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return m(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),S;const o=[],n=this._def.keyType,i=this._def.valueType;for(const a in s.data)o.push({key:n._parse(new fe(s,a,s.path,a)),value:i._parse(new fe(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?se.mergeObjectAsync(t,o):se.mergeObjectSync(t,o)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof A?new _t({keyType:e,valueType:t,typeName:E.ZodRecord,...I(s)}):new _t({keyType:ce.create(),valueType:e,typeName:E.ZodRecord,...I(t)})}}class Ct extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return m(s,{code:c.invalid_type,expected:f.map,received:s.parsedType}),S;const o=this._def.keyType,n=this._def.valueType,i=[...s.data.entries()].map(([a,p],_)=>({key:o._parse(new fe(s,a,s.path,[_,"key"])),value:n._parse(new fe(s,p,s.path,[_,"value"]))}));if(s.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const p of i){const _=await p.key,l=await p.value;if(_.status==="aborted"||l.status==="aborted")return S;(_.status==="dirty"||l.status==="dirty")&&t.dirty(),a.set(_.value,l.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const p of i){const _=p.key,l=p.value;if(_.status==="aborted"||l.status==="aborted")return S;(_.status==="dirty"||l.status==="dirty")&&t.dirty(),a.set(_.value,l.value)}return{status:t.value,value:a}}}}Ct.create=(r,e,t)=>new Ct({valueType:e,keyType:r,typeName:E.ZodMap,...I(t)});class Be extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return m(s,{code:c.invalid_type,expected:f.set,received:s.parsedType}),S;const o=this._def;o.minSize!==null&&s.data.size<o.minSize.value&&(m(s,{code:c.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),t.dirty()),o.maxSize!==null&&s.data.size>o.maxSize.value&&(m(s,{code:c.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),t.dirty());const n=this._def.valueType;function i(p){const _=new Set;for(const l of p){if(l.status==="aborted")return S;l.status==="dirty"&&t.dirty(),_.add(l.value)}return{status:t.value,value:_}}const a=[...s.data.values()].map((p,_)=>n._parse(new fe(s,p,s.path,_)));return s.common.async?Promise.all(a).then(p=>i(p)):i(a)}min(e,t){return new Be({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new Be({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Be.create=(r,e)=>new Be({valueType:r,minSize:null,maxSize:null,typeName:E.ZodSet,...I(e)});class He extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return m(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),S;function s(a,p){return Ot({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,At(),Je].filter(_=>!!_),issueData:{code:c.invalid_arguments,argumentsError:p}})}function o(a,p){return Ot({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,At(),Je].filter(_=>!!_),issueData:{code:c.invalid_return_type,returnTypeError:p}})}const n={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ke){const a=this;return re(async function(...p){const _=new ne([]),l=await a._def.args.parseAsync(p,n).catch(h=>{throw _.addIssue(s(p,h)),_}),v=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(v,n).catch(h=>{throw _.addIssue(o(v,h)),_})})}else{const a=this;return re(function(...p){const _=a._def.args.safeParse(p,n);if(!_.success)throw new ne([s(p,_.error)]);const l=Reflect.apply(i,this,_.data),v=a._def.returns.safeParse(l,n);if(!v.success)throw new ne([o(l,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new He({...this._def,args:ke.create(e).rest($e.create())})}returns(e){return new He({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new He({args:e||ke.create([]).rest($e.create()),returns:t||$e.create(),typeName:E.ZodFunction,...I(s)})}}class ut extends A{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ut.create=(r,e)=>new ut({getter:r,typeName:E.ZodLazy,...I(e)});class ct extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}ct.create=(r,e)=>new ct({value:r,typeName:E.ZodLiteral,...I(e)});function Es(r,e){return new ze({values:r,typeName:E.ZodEnum,...I(e)})}class ze extends A{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{expected:z.joinValues(s),received:t.parsedType,code:c.invalid_type}),S}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{received:t.data,code:c.invalid_enum_value,options:s}),S}return re(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ze.create(e,{...this._def,...t})}exclude(e,t=this._def){return ze.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}ze.create=Es;class lt extends A{_parse(e){const t=z.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){const o=z.objectValues(t);return m(s,{expected:z.joinValues(o),received:s.parsedType,code:c.invalid_type}),S}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const o=z.objectValues(t);return m(s,{received:s.data,code:c.invalid_enum_value,options:o}),S}return re(e.data)}get enum(){return this._def.values}}lt.create=(r,e)=>new lt({values:r,typeName:E.ZodNativeEnum,...I(e)});class Ke extends A{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return m(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),S;const s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return re(s.then(o=>this._def.type.parseAsync(o,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ke.create=(r,e)=>new Ke({type:r,typeName:E.ZodPromise,...I(e)});class de extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),o=this._def.effect||null,n={addIssue:i=>{m(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),o.type==="preprocess"){const i=o.transform(s.data,n);if(s.common.async)return Promise.resolve(i).then(async a=>{if(t.value==="aborted")return S;const p=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return p.status==="aborted"?S:p.status==="dirty"||t.value==="dirty"?Ue(p.value):p});{if(t.value==="aborted")return S;const a=this._def.schema._parseSync({data:i,path:s.path,parent:s});return a.status==="aborted"?S:a.status==="dirty"||t.value==="dirty"?Ue(a.value):a}}if(o.type==="refinement"){const i=a=>{const p=o.refinement(a,n);if(s.common.async)return Promise.resolve(p);if(p instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?S:(a.status==="dirty"&&t.dirty(),i(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?S:(a.status==="dirty"&&t.dirty(),i(a.value).then(()=>({status:t.value,value:a.value}))))}if(o.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Fe(i))return S;const a=o.transform(i.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>Fe(i)?Promise.resolve(o.transform(i.value,n)).then(a=>({status:t.value,value:a})):S);z.assertNever(o)}}de.create=(r,e,t)=>new de({schema:r,typeName:E.ZodEffects,effect:e,...I(t)});de.createWithPreprocess=(r,e,t)=>new de({schema:e,effect:{type:"preprocess",transform:r},typeName:E.ZodEffects,...I(t)});class he extends A{_parse(e){return this._getType(e)===f.undefined?re(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}he.create=(r,e)=>new he({innerType:r,typeName:E.ZodOptional,...I(e)});class Ce extends A{_parse(e){return this._getType(e)===f.null?re(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(r,e)=>new Ce({innerType:r,typeName:E.ZodNullable,...I(e)});class dt extends A{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}dt.create=(r,e)=>new dt({innerType:r,typeName:E.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});class mt extends A{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},o=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ot(o)?o.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ne(s.common.issues)},input:s.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ne(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}mt.create=(r,e)=>new mt({innerType:r,typeName:E.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});class Nt extends A{_parse(e){if(this._getType(e)!==f.nan){const s=this._getOrReturnCtx(e);return m(s,{code:c.invalid_type,expected:f.nan,received:s.parsedType}),S}return{status:"valid",value:e.data}}}Nt.create=r=>new Nt({typeName:E.ZodNaN,...I(r)});const po=Symbol("zod_brand");class Xt extends A{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ft extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?S:n.status==="dirty"?(t.dirty(),Ue(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const o=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?S:o.status==="dirty"?(t.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:s.path,parent:s})}}static create(e,t){return new ft({in:e,out:t,typeName:E.ZodPipeline})}}class ht extends A{_parse(e){const t=this._def.innerType._parse(e),s=o=>(Fe(o)&&(o.value=Object.freeze(o.value)),o);return ot(t)?t.then(o=>s(o)):s(t)}unwrap(){return this._def.innerType}}ht.create=(r,e)=>new ht({innerType:r,typeName:E.ZodReadonly,...I(e)});function is(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Is(r,e={},t){return r?We.create().superRefine((s,o)=>{const n=r(s);if(n instanceof Promise)return n.then(i=>{if(!i){const a=is(e,s),p=a.fatal??t??!0;o.addIssue({code:"custom",...a,fatal:p})}});if(!n){const i=is(e,s),a=i.fatal??t??!0;o.addIssue({code:"custom",...i,fatal:a})}}):We.create()}const _o={object:D.lazycreate};var E;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(E||(E={}));const uo=(r,e={message:`Input not instance of ${r.name}`})=>Is(t=>t instanceof r,e),N=ce.create,ge=Oe.create,co=Nt.create,lo=Re.create,kt=rt.create,mo=De.create,ho=Rt.create,go=nt.create,As=it.create,Ne=We.create,jt=$e.create,fo=we.create,ko=zt.create,qe=le.create,M=D.create,vo=D.strictCreate,Ve=at.create,xo=Mt.create,yo=pt.create,bo=ke.create,vt=_t.create,wo=Ct.create,To=Be.create,So=He.create,Os=ut.create,oe=ct.create,Pt=ze.create,Eo=lt.create,Io=Ke.create,as=de.create,Ao=he.create,Oo=Ce.create,Ro=de.createWithPreprocess,zo=ft.create,Co=()=>N().optional(),No=()=>ge().optional(),Lo=()=>kt().optional(),It={string:r=>ce.create({...r,coerce:!0}),number:r=>Oe.create({...r,coerce:!0}),boolean:r=>rt.create({...r,coerce:!0}),bigint:r=>Re.create({...r,coerce:!0}),date:r=>De.create({...r,coerce:!0})},Mo=S,Q=Object.freeze(Object.defineProperty({__proto__:null,BRAND:po,DIRTY:Ue,EMPTY_PATH:Ds,INVALID:S,NEVER:Mo,OK:re,ParseStatus:se,Schema:A,ZodAny:We,ZodArray:le,ZodBigInt:Re,ZodBoolean:rt,ZodBranded:Xt,ZodCatch:mt,ZodDate:De,ZodDefault:dt,ZodDiscriminatedUnion:Mt,ZodEffects:de,ZodEnum:ze,ZodError:ne,get ZodFirstPartyTypeKind(){return E},ZodFunction:He,ZodIntersection:pt,ZodIssueCode:c,ZodLazy:ut,ZodLiteral:ct,ZodMap:Ct,ZodNaN:Nt,ZodNativeEnum:lt,ZodNever:we,ZodNull:it,ZodNullable:Ce,ZodNumber:Oe,ZodObject:D,ZodOptional:he,ZodParsedType:f,ZodPipeline:ft,ZodPromise:Ke,ZodReadonly:ht,ZodRecord:_t,ZodSchema:A,ZodSet:Be,ZodString:ce,ZodSymbol:Rt,ZodTransformer:de,ZodTuple:ke,ZodType:A,ZodUndefined:nt,ZodUnion:at,ZodUnknown:$e,ZodVoid:zt,addIssueToContext:m,any:Ne,array:qe,bigint:lo,boolean:kt,coerce:It,custom:Is,date:mo,datetimeRegex:Ss,defaultErrorMap:Je,discriminatedUnion:xo,effect:as,enum:Pt,function:So,getErrorMap:At,getParsedType:ye,instanceof:uo,intersection:yo,isAborted:Gt,isAsync:ot,isDirty:Ut,isValid:Fe,late:_o,lazy:Os,literal:oe,makeIssue:Ot,map:wo,nan:co,nativeEnum:Eo,never:fo,null:As,nullable:Oo,number:ge,object:M,get objectUtil(){return Vt},oboolean:Lo,onumber:No,optional:Ao,ostring:Co,pipeline:zo,preprocess:Ro,promise:Io,quotelessJson:$s,record:vt,set:To,setErrorMap:Fs,strictObject:vo,string:N,symbol:ho,transformer:as,tuple:bo,undefined:go,union:Ve,unknown:jt,get util(){return z},void:ko},Symbol.toStringTag,{value:"Module"})),Me=()=>Q.preprocess(r=>{if(typeof r=="boolean")return r;if(typeof r=="number")return r===1;if(typeof r=="string"){const e=r.trim().toLowerCase();if(["1","true","yes","y","on"].includes(e))return!0;if(["0","false","no","n","off"].includes(e))return!1}},Q.boolean()),jo=()=>Q.preprocess(r=>{if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){const e=Number(r);if(Number.isFinite(e))return e}},Q.number()),Rs=Q.object({NODE_ENV:Q.enum(["development","production","test"]).default("production"),AGENT_CONTAINER_MODE:Me().default(!1),AGENT_API_KEY:Q.string().optional(),AGENT_ORGANIZATION_ID:Q.string().optional(),AGENT_SESSION_ID:Q.string().optional(),AGENT_SERVER_URL:Q.string().optional(),AGENT_TYPE:Q.string().optional(),AGENT_DEVICE_GUID:Q.string().optional(),CONTEXT_DATA:Q.string().optional(),AGI_NETLOG_ENABLE:Me().default(!0),AGI_NETLOG_DEBUG:Me().optional(),AGI_NETLOG_FILE:Q.string().optional(),AGI_NETLOG_MAX_BODY:jo().optional(),AGI_NETLOG_REMOTE_ENABLE:Me().default(!0),AGI_NETLOG_REMOTE_FILE:Q.string().optional(),DEBUG:Me().default(!1),VERBOSE:Me().default(!1),LOG_LEVEL:Q.string().optional(),HOSTNAME:Q.string().optional(),VITE_SAVE_RAW:Me().default(!1)});function St(r=!1){return r?"https://agiflow.io":"https://agiflow.io"}let P=Rs.parse(process.env);class ee{static refresh(){P=Rs.parse(process.env)}static get isContainerMode(){return!!P.AGENT_CONTAINER_MODE}static get apiKey(){return P.AGENT_API_KEY||process.env.AGENT_API_KEY}static get organizationId(){return P.AGENT_ORGANIZATION_ID||process.env.AGENT_ORGANIZATION_ID}static get sessionId(){return P.AGENT_SESSION_ID||process.env.AGENT_SESSION_ID}static get serverUrl(){return P.AGENT_SERVER_URL||process.env.AGENT_SERVER_URL||St(this.isContainerMode)}static get isNetlogEnabled(){return!!P.AGI_NETLOG_ENABLE}static get isNetlogDebug(){return!!P.AGI_NETLOG_DEBUG}static get isNetlogRemoteEnabled(){return!!P.AGI_NETLOG_REMOTE_ENABLE}static get isDebugMode(){return P.DEBUG}static get isVerbose(){return P.VERBOSE}static get logLevel(){return P.LOG_LEVEL??(P.DEBUG?"debug":"info")}static get nodeEnv(){return P.NODE_ENV}static get homeDir(){return process.env.HOME||process.env.USERPROFILE}static get isMacOS(){return process.platform==="darwin"}static get hostname(){return P.HOSTNAME}static get netlogMaxBody(){return P.AGI_NETLOG_MAX_BODY}static get netlogFile(){return P.AGI_NETLOG_FILE}static get netlogRemoteFile(){return P.AGI_NETLOG_REMOTE_FILE}static get agentType(){return P.AGENT_TYPE||process.env.AGENT_TYPE}static get deviceGuid(){return P.AGENT_DEVICE_GUID}static get isSaveRawEnabled(){return!!P.VITE_SAVE_RAW}static get contextData(){return P.CONTEXT_DATA||process.env.CONTEXT_DATA}static serializeEnv(){const e={...process.env};for(const[t,s]of Object.entries(P))s!==void 0&&(typeof s=="string"?e[t]=s:typeof s=="number"?e[t]=String(s):typeof s=="boolean"?e[t]=s?"true":"false":e[t]=String(s));return e}static toChildProcess(){const e=this.serializeEnv();return e.AGENT_SERVER_URL||(e.AGENT_SERVER_URL=St(this.isContainerMode)),e.LOG_LEVEL||(e.LOG_LEVEL=this.logLevel),e}static toDocker(){const e=this.serializeEnv();return e.AGENT_CONTAINER_MODE="true",e.AGENT_SERVER_URL||(e.AGENT_SERVER_URL=St(!0)),e.LOG_LEVEL||(e.LOG_LEVEL=this.logLevel),e}static toPty(){const e=this.serializeEnv();return e.AGENT_SERVER_URL||(e.AGENT_SERVER_URL=St(this.isContainerMode)),e.LOG_LEVEL||(e.LOG_LEVEL=this.logLevel),e}static getEnvs(){return P}}class st{logStream;logPath;constructor(e){this.logPath=e;const t=be.dirname(this.logPath);Pe.existsSync(t)||Pe.mkdirSync(t,{recursive:!0}),this.logStream=Pe.createWriteStream(this.logPath,{flags:"a"}),this.logStream.on("error",s=>{console.error(`[FileLogger] Error writing to log file: ${s.message}`)})}info(e,t){this.log(30,e,t)}debug(e,t){this.log(20,e,t)}warn(e,t){this.log(40,e,t)}error(e,t){this.log(50,e,t)}log(e,t,s){const o={time:new Date().toISOString(),level:e,msg:t,...s};try{this.logStream.write(JSON.stringify(o)+`
2
- `)}catch(n){console.error(`[FileLogger] Failed to write log entry: ${n}`)}}close(){this.logStream&&!this.logStream.destroyed&&this.logStream.end()}getLogPath(){return this.logPath}static shouldDebug(){return ee.isDebugMode||ee.isNetlogDebug}}const Po={max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},$o={max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},Fo={"gpt-4":{max_tokens:4096,max_input_tokens:8192,max_output_tokens:4096,input_cost_per_token:3e-5,output_cost_per_token:6e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4.1":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-2025-04-14":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-mini":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:4e-7,output_cost_per_token:16e-7,input_cost_per_token_batches:2e-7,output_cost_per_token_batches:8e-7,cache_read_input_token_cost:1e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-mini-2025-04-14":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:4e-7,output_cost_per_token:16e-7,input_cost_per_token_batches:2e-7,output_cost_per_token_batches:8e-7,cache_read_input_token_cost:1e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-nano":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:1e-7,output_cost_per_token:4e-7,input_cost_per_token_batches:5e-8,output_cost_per_token_batches:2e-7,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-nano-2025-04-14":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:1e-7,output_cost_per_token:4e-7,input_cost_per_token_batches:5e-8,output_cost_per_token_batches:2e-7,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4o":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"watsonx/ibm/granite-3-8b-instruct":{max_tokens:8192,max_input_tokens:8192,max_output_tokens:1024,input_cost_per_token:2e-4,output_cost_per_token:2e-4,litellm_provider:"watsonx",mode:"chat",supports_function_calling:!0,supports_tool_choice:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_audio_input:!1,supports_audio_output:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_system_messages:!0},"watsonx/mistralai/mistral-large":{max_tokens:131072,max_input_tokens:131072,max_output_tokens:16384,input_cost_per_token:3e-6,output_cost_per_token:1e-5,litellm_provider:"watsonx",mode:"chat",supports_function_calling:!0,supports_tool_choice:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_audio_input:!1,supports_audio_output:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_system_messages:!0},"gpt-4o-search-preview-2025-03-11":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-search-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_web_search:!0,search_context_cost_per_query:{search_context_size_low:.03,search_context_size_medium:.035,search_context_size_high:.05}},"gpt-4.5-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:75e-6,output_cost_per_token:15e-5,input_cost_per_token_batches:375e-7,output_cost_per_token_batches:75e-6,cache_read_input_token_cost:375e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4.5-preview-2025-02-27":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:75e-6,output_cost_per_token:15e-5,input_cost_per_token_batches:375e-7,output_cost_per_token_batches:75e-6,cache_read_input_token_cost:375e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,deprecation_date:"2025-07-14"},"gpt-4o-audio-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:1e-4,output_cost_per_token:1e-5,output_cost_per_audio_token:2e-4,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-audio-preview-2024-12-17":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:4e-5,output_cost_per_token:1e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-audio-preview-2024-10-01":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:1e-4,output_cost_per_token:1e-5,output_cost_per_audio_token:2e-4,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-audio-preview-2025-06-03":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:4e-5,output_cost_per_token:1e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-audio-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,input_cost_per_audio_token:1e-5,output_cost_per_token:6e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-audio-preview-2024-12-17":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,input_cost_per_audio_token:1e-5,output_cost_per_token:6e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-search-preview-2025-03-11":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-search-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_web_search:!0,search_context_cost_per_query:{search_context_size_low:.025,search_context_size_medium:.0275,search_context_size_high:.03}},"gpt-4o-mini-2024-07-18":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,search_context_cost_per_query:{search_context_size_low:.025,search_context_size_medium:.0275,search_context_size_high:.03}},"gpt-5":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-mini":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:25e-8,output_cost_per_token:2e-6,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-nano":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:5e-8,output_cost_per_token:4e-7,cache_read_input_token_cost:5e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-chat":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!1,supports_parallel_function_calling:!1,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!1,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-chat-latest":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!1,supports_parallel_function_calling:!1,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!1,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-2025-08-07":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-mini-2025-08-07":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:25e-8,output_cost_per_token:2e-6,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-nano-2025-08-07":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:5e-8,output_cost_per_token:4e-7,cache_read_input_token_cost:5e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"codex-mini-latest":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-7,output_cost_per_token:6e-6,cache_read_input_token_cost:375e-9,litellm_provider:"openai",mode:"responses",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supported_modalities:["text","image"],supported_output_modalities:["text"],supported_endpoints:["/v1/responses"]},"o1-pro":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-5,output_cost_per_token:6e-4,input_cost_per_token_batches:75e-6,output_cost_per_token_batches:3e-4,litellm_provider:"openai",mode:"responses",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_native_streaming:!1,supports_reasoning:!0,supported_modalities:["text","image"],supported_output_modalities:["text"],supported_endpoints:["/v1/responses","/v1/batch"]},"o1-pro-2025-03-19":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-5,output_cost_per_token:6e-4,input_cost_per_token_batches:75e-6,output_cost_per_token_batches:3e-4,litellm_provider:"openai",mode:"responses",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_native_streaming:!1,supports_reasoning:!0,supported_modalities:["text","image"],supported_output_modalities:["text"],supported_endpoints:["/v1/responses","/v1/batch"]},o1:Po,"o1-mini":{max_tokens:65536,max_input_tokens:128e3,max_output_tokens:65536,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:55e-8,litellm_provider:"openai",mode:"chat",supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0},"o3-deep-research":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:1e-5,output_cost_per_token:4e-5,input_cost_per_token_batches:5e-6,output_cost_per_token_batches:2e-5,cache_read_input_token_cost:25e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o3-deep-research-2025-06-26":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:1e-5,output_cost_per_token:4e-5,input_cost_per_token_batches:5e-6,output_cost_per_token_batches:2e-5,cache_read_input_token_cost:25e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o3-pro":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-5,input_cost_per_token_batches:1e-5,output_cost_per_token_batches:4e-5,output_cost_per_token:8e-5,litellm_provider:"openai",mode:"responses",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},"o3-pro-2025-06-10":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-5,input_cost_per_token_batches:1e-5,output_cost_per_token_batches:4e-5,output_cost_per_token:8e-5,litellm_provider:"openai",mode:"responses",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},o3:$o,"o3-2025-04-16":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},"o3-mini":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:55e-8,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o3-mini-2025-01-31":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:55e-8,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o4-mini":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:275e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o4-mini-deep-research":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o4-mini-deep-research-2025-06-26":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o4-mini-2025-04-16":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:275e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o1-mini-2024-09-12":{max_tokens:65536,max_input_tokens:128e3,max_output_tokens:65536,input_cost_per_token:3e-6,output_cost_per_token:12e-6,cache_read_input_token_cost:15e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_vision:!0,supports_reasoning:!0,supports_prompt_caching:!0},"o1-preview":{max_tokens:32768,max_input_tokens:128e3,max_output_tokens:32768,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_vision:!0,supports_reasoning:!0,supports_prompt_caching:!0},"o1-preview-2024-09-12":{max_tokens:32768,max_input_tokens:128e3,max_output_tokens:32768,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_vision:!0,supports_reasoning:!0,supports_prompt_caching:!0},"o1-2024-12-17":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"chatgpt-4o-latest":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,output_cost_per_token:15e-6,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-2024-05-13":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,output_cost_per_token:15e-6,input_cost_per_token_batches:25e-7,output_cost_per_token_batches:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-2024-08-06":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-2024-11-20":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-realtime":{max_tokens:4096,max_input_tokens:32e3,max_output_tokens:4096,input_cost_per_token:4e-6,cache_read_input_token_cost:4e-7,output_cost_per_token:16e-6,input_cost_per_audio_token:32e-6,output_cost_per_audio_token:64e-6,cache_creation_input_audio_token_cost:4e-7,input_cost_per_image:5e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0,supported_endpoints:["/v1/realtime"],supported_modalities:["text","image","audio"],supported_output_modalities:["text","audio"]},"gpt-realtime-2025-08-28":{max_tokens:4096,max_input_tokens:32e3,max_output_tokens:4096,input_cost_per_token:4e-6,cache_read_input_token_cost:4e-7,output_cost_per_token:16e-6,input_cost_per_audio_token:32e-6,output_cost_per_audio_token:64e-6,cache_creation_input_audio_token_cost:4e-7,input_cost_per_image:5e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0,supported_endpoints:["/v1/realtime"],supported_modalities:["text","image","audio"],supported_output_modalities:["text","audio"]},"gpt-4o-realtime-preview-2024-10-01":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:1e-4,cache_read_input_token_cost:25e-7,cache_creation_input_audio_token_cost:2e-5,output_cost_per_token:2e-5,output_cost_per_audio_token:2e-4,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-realtime-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:4e-5,cache_read_input_token_cost:25e-7,output_cost_per_token:2e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-realtime-preview-2024-12-17":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:4e-5,cache_read_input_token_cost:25e-7,output_cost_per_token:2e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-realtime-preview-2025-06-03":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:4e-5,cache_read_input_token_cost:25e-7,output_cost_per_token:2e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-realtime-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:6e-7,input_cost_per_audio_token:1e-5,cache_read_input_token_cost:3e-7,cache_creation_input_audio_token_cost:3e-7,output_cost_per_token:24e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-realtime-preview-2024-12-17":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:6e-7,input_cost_per_audio_token:1e-5,cache_read_input_token_cost:3e-7,cache_creation_input_audio_token_cost:3e-7,output_cost_per_token:24e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-turbo-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-0314":{max_tokens:4096,max_input_tokens:8192,max_output_tokens:4096,input_cost_per_token:3e-5,output_cost_per_token:6e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-0613":{max_tokens:4096,max_input_tokens:8192,max_output_tokens:4096,input_cost_per_token:3e-5,output_cost_per_token:6e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,deprecation_date:"2025-06-06",supports_tool_choice:!0},"gpt-4-32k":{max_tokens:4096,max_input_tokens:32768,max_output_tokens:4096,input_cost_per_token:6e-5,output_cost_per_token:12e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-32k-0314":{max_tokens:4096,max_input_tokens:32768,max_output_tokens:4096,input_cost_per_token:6e-5,output_cost_per_token:12e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-32k-0613":{max_tokens:4096,max_input_tokens:32768,max_output_tokens:4096,input_cost_per_token:6e-5,output_cost_per_token:12e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-turbo":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-turbo-2024-04-09":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-1106-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-0125-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-vision-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_system_messages:!0,deprecation_date:"2024-12-06",supports_tool_choice:!0},"gpt-4-1106-vision-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_system_messages:!0,deprecation_date:"2024-12-06",supports_tool_choice:!0},"gpt-3.5-turbo":{max_tokens:4097,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:15e-7,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-0301":{max_tokens:4097,max_input_tokens:4097,max_output_tokens:4096,input_cost_per_token:15e-7,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-0613":{max_tokens:4097,max_input_tokens:4097,max_output_tokens:4096,input_cost_per_token:15e-7,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-1106":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:1e-6,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-0125":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:5e-7,output_cost_per_token:15e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-16k":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:3e-6,output_cost_per_token:4e-6,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-16k-0613":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:3e-6,output_cost_per_token:4e-6,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-transcribe":{mode:"audio_transcription",max_input_tokens:16e3,max_output_tokens:2e3,input_cost_per_token:25e-7,input_cost_per_audio_token:6e-6,output_cost_per_token:1e-5,litellm_provider:"openai",supported_endpoints:["/v1/audio/transcriptions"]},"gpt-4o-mini-transcribe":{mode:"audio_transcription",max_input_tokens:16e3,max_output_tokens:2e3,input_cost_per_token:125e-8,input_cost_per_audio_token:3e-6,output_cost_per_token:5e-6,litellm_provider:"openai",supported_endpoints:["/v1/audio/transcriptions"]},"gpt-4o-mini-tts":{mode:"audio_speech",input_cost_per_token:25e-7,output_cost_per_token:1e-5,output_cost_per_audio_token:12e-6,output_cost_per_second:25e-5,litellm_provider:"openai",supported_modalities:["text","audio"],supported_output_modalities:["audio"],supported_endpoints:["/v1/audio/speech"]},"claude-3-haiku-20240307":{max_tokens:4096,max_input_tokens:2e5,max_output_tokens:4096,input_cost_per_token:25e-8,output_cost_per_token:125e-8,cache_creation_input_token_cost:3e-7,cache_read_input_token_cost:3e-8,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:264,supports_assistant_prefill:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-03-01",supports_tool_choice:!0},"claude-3-5-haiku-20241022":{max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:8e-7,output_cost_per_token:4e-6,cache_creation_input_token_cost:1e-6,cache_read_input_token_cost:8e-8,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:264,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-10-01",supports_tool_choice:!0,supports_web_search:!0},"claude-3-5-haiku-latest":{max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:1e-6,output_cost_per_token:5e-6,cache_creation_input_token_cost:125e-8,cache_read_input_token_cost:1e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:264,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-10-01",supports_tool_choice:!0,supports_web_search:!0},"claude-3-opus-latest":{max_tokens:4096,max_input_tokens:2e5,max_output_tokens:4096,input_cost_per_token:15e-6,output_cost_per_token:75e-6,cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:395,supports_assistant_prefill:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-03-01",supports_tool_choice:!0},"claude-3-opus-20240229":{max_tokens:4096,max_input_tokens:2e5,max_output_tokens:4096,input_cost_per_token:15e-6,output_cost_per_token:75e-6,cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:395,supports_assistant_prefill:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-03-01",supports_tool_choice:!0},"claude-3-5-sonnet-latest":{supports_computer_use:!0,max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-06-01",supports_tool_choice:!0,supports_web_search:!0},"claude-3-5-sonnet-20240620":{max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-06-01",supports_tool_choice:!0},"claude-opus-4-20250514":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-opus-4-1":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-opus-4-1-20250805":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-sonnet-4-5-20250929":{max_tokens:64e3,max_input_tokens:2e5,max_output_tokens:64e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-sonnet-4-20250514":{max_tokens:64e3,max_input_tokens:2e5,max_output_tokens:64e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-4-opus-20250514":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-4-sonnet-20250514":{max_tokens:1e6,max_input_tokens:1e6,max_output_tokens:1e6,input_cost_per_token:3e-6,output_cost_per_token:15e-6,input_cost_per_token_above_200k_tokens:6e-6,output_cost_per_token_above_200k_tokens:225e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,cache_creation_input_token_cost_above_200k_tokens:75e-7,cache_read_input_token_cost_above_200k_tokens:6e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-3-7-sonnet-latest":{supports_computer_use:!0,max_tokens:128e3,max_input_tokens:2e5,max_output_tokens:128e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-06-01",supports_tool_choice:!0,supports_reasoning:!0},"claude-3-7-sonnet-20250219":{supports_computer_use:!0,max_tokens:128e3,max_input_tokens:2e5,max_output_tokens:128e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2026-02-01",supports_tool_choice:!0,supports_reasoning:!0,supports_web_search:!0},"claude-3-5-sonnet-20241022":{supports_computer_use:!0,max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-10-01",supports_tool_choice:!0,supports_web_search:!0},"gemini-2.5-pro-exp-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.0-pro-exp-02-05":{max_tokens:8192,max_input_tokens:2097152,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.0-flash-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:15e-8,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:6e-7,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini-2.0-flash-001":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",deprecation_date:"2026-02-05",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini-2.0-flash-thinking-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini-2.0-flash-thinking-exp-01-21":{max_tokens:65536,max_input_tokens:1048576,max_output_tokens:65536,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!1,supports_vision:!0,supports_response_schema:!1,supports_audio_output:!1,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini-2.5-pro":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-exp-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:0,input_cost_per_token_above_200k_tokens:0,output_cost_per_token:0,output_cost_per_token_above_200k_tokens:0,litellm_provider:"gemini",mode:"chat",rpm:5,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.5-pro":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:2e3,tpm:8e5,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-flash":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"gemini",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,tpm:8e6,rpm:1e5,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-image-preview":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,output_cost_per_image:.039,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,tpm:8e6,rpm:1e5,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini-2.5-flash":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-live-001":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:35e-8,input_cost_per_audio_token:21e-7,input_cost_per_image:21e-7,input_cost_per_video_per_second:21e-7,output_cost_per_token:15e-7,output_cost_per_audio_token:85e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","audio"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2-0-flash-live-001",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-preview-tts":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,output_cost_per_reasoning_token:35e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text"],supported_output_modalities:["audio"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_web_search:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-preview-05-20":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-preview-04-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,output_cost_per_reasoning_token:35e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-lite-preview-06-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:15,tpm:25e4,supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-lite":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:15,tpm:25e4,supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.5-flash-image-preview":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,output_cost_per_image:.039,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,tpm:8e6,rpm:1e5,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini-2.5-flash-preview-05-20":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini-2.5-flash-preview-04-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,output_cost_per_reasoning_token:35e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini-2.5-flash-lite-preview-06-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.5-flash-lite":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.0-flash":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.0-flash-lite":{max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:50,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini-2.0-flash-lite-001":{max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:50,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,deprecation_date:"2026-02-25",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini-2.5-pro-preview-06-05":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:125e-8,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.5-pro-preview-05-06":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:125e-8,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],supported_regions:["global"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.5-pro-preview-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:125e-8,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.0-flash-preview-image-generation":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.5-pro-preview-tts":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text"],supported_output_modalities:["audio"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.0-pro-exp-02-05":{max_tokens:8192,max_input_tokens:2097152,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",rpm:2,tpm:1e6,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-preview-image-generation":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_web_search:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.0-flash":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_web_search:!0,supports_url_context:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-lite":{max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:50,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"gemini",mode:"chat",tpm:4e6,rpm:4e3,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.0-flash-lite",supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-001":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://ai.google.dev/pricing#2_0flash",supports_web_search:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-tts":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text"],supported_output_modalities:["audio"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-06-05":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-05-06":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,tpm:4e6,rpm:10,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-lite-preview-02-05":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"gemini",mode:"chat",rpm:6e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash-lite",supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-thinking-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:65536,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,tpm:4e6,rpm:10,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-thinking-exp-01-21":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:65536,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,tpm:4e6,rpm:10,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemma-3-27b-it":{max_tokens:8192,max_input_tokens:131072,max_output_tokens:8192,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,source:"https://aistudio.google.com",supports_tool_choice:!0},"gemini/learnlm-1.5-pro-experimental":{max_tokens:8192,max_input_tokens:32767,max_output_tokens:8192,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,source:"https://aistudio.google.com",supports_tool_choice:!0},"gemini/veo-3.0-generate-preview":{max_tokens:1024,max_input_tokens:1024,output_cost_per_second:.75,litellm_provider:"gemini",mode:"video_generation",supported_modalities:["text"],supported_output_modalities:["video"],source:"https://ai.google.dev/gemini-api/docs/video"},"gemini/veo-3.0-fast-generate-preview":{max_tokens:1024,max_input_tokens:1024,output_cost_per_second:.4,litellm_provider:"gemini",mode:"video_generation",supported_modalities:["text"],supported_output_modalities:["video"],source:"https://ai.google.dev/gemini-api/docs/video"},"gemini/veo-2.0-generate-001":{max_tokens:1024,max_input_tokens:1024,output_cost_per_second:.35,litellm_provider:"gemini",mode:"video_generation",supported_modalities:["text"],supported_output_modalities:["video"],source:"https://ai.google.dev/gemini-api/docs/video"}};class Do{static calculateCost(e,t){const s=Fo[e];if(!s)return null;const o=t.inputTokens||0,n=t.outputTokens||0,i=t.cachedInputTokens||0,a=t.cacheCreationInputTokens||0,p="input_cost_per_token"in s?s.input_cost_per_token:0,_="output_cost_per_token"in s?s.output_cost_per_token:0,l="cache_read_input_token_cost"in s?s.cache_read_input_token_cost:0,v="cache_creation_input_token_cost"in s?s.cache_creation_input_token_cost:0,k=o*p,h=n*_,y=i*l,g=a*v;return{totalCost:k+h+y+g,inputCost:k,outputCost:h,cacheReadCost:i>0?y:void 0,cacheCreationCost:a>0?g:void 0}}}class $t{static parseStreamingResponse(e){try{const t=e.split(`
3
- `),s=[];let o=null,n=null;const i=new Map;for(const y of t)if(y.startsWith("data: ")){const g=y.substring(6).trim();if(g)try{const w=JSON.parse(g);if(w.type==="message_start"&&w.message&&(o=w.message),w.type==="content_block_start"){const L={index:w.index,type:w.content_block.type,id:w.content_block.id,name:w.content_block.name,input:w.content_block.input||{},text:"",partialJson:""};i.set(w.index,L)}if(w.type==="content_block_delta"){const L=i.get(w.index);L&&(w.delta.type==="text_delta"?L.text+=w.delta.text:w.delta.type==="input_json_delta"&&(L.partialJson+=w.delta.partial_json))}if(w.type==="content_block_stop"){const L=i.get(w.index);if(L){if(L.partialJson)try{L.input=JSON.parse(L.partialJson)}catch{}s.push(L)}}w.type==="message_delta"&&w.usage&&(n=w.usage)}catch{}}const a=s.map(y=>y.type==="text"?{type:"text",text:y.text}:y.type==="tool_use"?{type:"tool-invocation",toolInvocation:{toolCallId:y.id,toolName:y.name,args:y.input,state:"call"}}:{type:"text",text:`Unknown content block type: ${y.type}`}),p={id:o?.id||$t.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:a.length>0?a:[{type:"text",text:""}]},_={...o?.usage||{},...n||{}},l={inputTokens:_.input_tokens||_.inputTokens,outputTokens:_.output_tokens||_.outputTokens,cachedInputTokens:_.cache_read_input_tokens||_.cachedInputTokens,cacheCreationInputTokens:_.cache_creation_input_tokens||_.cacheCreationInputTokens,totalTokens:(_.input_tokens||0)+(_.output_tokens||0),cacheCreation:_.cache_creation,serviceTier:_.service_tier},v=o?.model,k=v?Do.calculateCost(v,l):null;return{message:p,metadata:{model:v,usage:l,cost:k,originalMessageId:o?.id,stopReason:o?.stop_reason,contentLength:a.reduce((y,g)=>g.type==="text"?y+g.text.length:g.type==="tool-invocation"?y+JSON.stringify(g.toolInvocation.args||"").length:y+JSON.stringify(g).length,0),streamingEvents:t.filter(y=>y.startsWith("event:")).length}}}catch(t){return{error:`Failed to parse streaming response: ${t}`,rawText:e}}}static generateId(){return Date.now().toString(36)+Math.random().toString(36).slice(2,10)}}$t.parseStreamingResponse;new Proxy({},{get(r,e){throw new Error(`Module "node:zlib" has been externalized for browser compatibility. Cannot access "node:zlib.${e}" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}});class zs{static parseStreamingResponse(e){try{return e.includes(`
4
- data:`)||e.startsWith("data:")?this.parseSse(e):this.parseRegular(e)}catch(t){return{error:`Failed to parse Gemini response: ${t}`,rawText:e}}}static parseRegular(e){const t=this.isProbablyGzip(e)||this.hasHighControlCharRatio(e);let s=e;if(t){const o=this.tryGunzip(e);o.ok&&(s=o.text)}try{const o=JSON.parse(s),n=o.response||o,{fullText:i,finishReason:a,texts:p,nextSpeakers:_,reasoningSegments:l}=this.extractCandidateText(n.candidates),v=this.normalizeUsage(n.usageMetadata||o.usageMetadata||o),k=p.length>0?p.map(h=>({type:"text",text:h})):i?[{type:"text",text:i}]:[];return{message:{id:n.responseId||this.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:k},metadata:{model:n.modelVersion||o.modelVersion,usage:v,responseId:n.responseId,finishReason:a,contentLength:i.length,streamingEvents:0,compressed:t||void 0,nextSpeakers:_.length?_:void 0,reasoningSegments:l.length?l:void 0}}}catch{return{message:{id:this.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:[{type:"text",text:s}]},metadata:{raw:!0}}}}static parseSse(e){const t=e.split(/\r?\n/);let s,o,n,i;const a=[],p=[],_=[];for(const k of t){if(!k.startsWith("data:"))continue;const h=k.slice(5).trim();if(h)try{const g=JSON.parse(h).response||{};g.modelVersion&&(s=g.modelVersion),g.responseId&&(o=g.responseId),g.usageMetadata&&(i=g.usageMetadata);const w=this.extractCandidateText(g.candidates);!n&&w.finishReason&&(n=w.finishReason),w.texts.length&&a.push(...w.texts),w.nextSpeakers.length&&p.push(...w.nextSpeakers),w.reasoningSegments.length&&_.push(...w.reasoningSegments)}catch{}}const l=a.join(""),v=this.normalizeUsage(i);return{message:{id:o||this.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:a.length?a.map(k=>({type:"text",text:k})):[]},metadata:{model:s,usage:v,responseId:o,finishReason:n,contentLength:l.length,streamingEvents:t.filter(k=>k.startsWith("data:")).length,nextSpeakers:p.length?p:void 0,reasoningSegments:_.length?_:void 0}}}static extractCandidateText(e){const t=[],s=[],o=[];let n;if(Array.isArray(e))for(const i of e){!n&&i?.finishReason&&(n=i.finishReason);const a=i?.content?.parts||[];if(Array.isArray(a)){for(const p of a)if(p&&typeof p=="object"){if(p.thought===!0)continue;const _=p.text;if(typeof _=="string"&&_.length){const l=_.trim();if(l.startsWith("{")&&l.endsWith("}"))try{const v=JSON.parse(l);if(v&&typeof v=="object"){typeof v.reasoning=="string"&&(o.push(v.reasoning),t.push(v.reasoning)),v.next_speaker&&typeof v.next_speaker=="string"&&s.push(v.next_speaker);continue}}catch{}t.push(_)}}}}return{fullText:t.join(""),finishReason:n,texts:t,finishReasonFound:n,nextSpeakers:s,reasoningSegments:o}}static tryGunzip(e){try{return{ok:!0,text:(void 0)(Buffer.from(e,"latin1")).toString("utf8")}}catch{return{ok:!1,text:e}}}static hasHighControlCharRatio(e){if(!e)return!1;let t=0;const s=Math.min(e.length,256);for(let o=0;o<s;o++){const n=e.charCodeAt(o);n<32&&n!==9&&n!==10&&n!==13&&t++}return t/s>.1}static isProbablyGzip(e){return e.length>=2&&e.charCodeAt(0)===31&&e.charCodeAt(1)===139}static normalizeUsage(e){if(!e||typeof e!="object")return{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};const t=e.promptTokenCount??e.prompt_tokens,s=e.candidatesTokenCount??e.candidates_tokens,o=e.totalTokenCount??(typeof t=="number"&&typeof s=="number"?t+s:void 0);return{inputTokens:t,outputTokens:s,totalTokens:o}}static generateId(){return Date.now().toString(36)+Math.random().toString(36).slice(2,10)}}zs.parseStreamingResponse;class ue{static parsers=[{name:"Claude (Anthropic)",patterns:[/\/publishers\/anthropic\/models/i,/anthropic\.com/i,/claude\.ai/i,/\/v1\/messages/i],parser:$t},{name:"Google Gemini",patterns:[/generativelanguage\.googleapis\.com/i,/cloudcode-pa\.googleapis\.com/i,/streamGenerateContent/i,/generateContent/i],parser:zs}];static parseStreamingResponse(e,t){const s=ue.getParserForUrl(e);if(!s)return{error:`No parser found for URL: ${e}`,rawText:t,supportedProviders:ue.parsers.map(o=>o.name)};try{const o=s.parseStreamingResponse(t);return o&&typeof o=="object"&&!o.error&&(o.metadata={...o.metadata,parser:ue.getParserNameForUrl(e)}),o}catch(o){return{error:`Parser failed: ${o}`,rawText:t,parser:ue.getParserNameForUrl(e)}}}static getParserForUrl(e){if(!e)return null;for(const t of ue.parsers)if(t.patterns.some(s=>s.test(e)))return t.parser;return null}static getParserNameForUrl(e){if(!e)return"unknown";for(const t of ue.parsers)if(t.patterns.some(s=>s.test(e)))return t.name;return"unknown"}static isSupported(e){return ue.getParserForUrl(e)!==null}static getSupportedProviders(){return ue.parsers.map(e=>e.name)}static registerParser(e,t,s){ue.parsers.push({name:e,patterns:t,parser:s})}}class Cs{LLM_PATTERNS=[/anthropic\.com/i,/claude\.ai/i,/openai\.com/i,/api\.openai\.com/i,/gemini\.google/i,/generativelanguage\.googleapis/i,/cloudcode-pa\.googleapis\.com/i,/bedrock.*\.amazonaws/i,/cognitive\.microsoft/i,/azure\.openai/i,/cohere\.ai/i,/huggingface\.co/i,/replicate\.com/i,/together\.xyz/i,/mistral\.ai/i,/groq\.com/i,/perplexity\.ai/i,/ollama/i,/localhost:\d+\/v1/i,/127\.0\.0\.1:\d+\/v1/i,/\/v1\/chat\/completions/i,/\/v1\/completions/i,/\/v1\/embeddings/i,/\/v1\/messages/i,/\/publishers\/anthropic\/models/i];PROVIDER_MAP=[{pattern:/\/publishers\/anthropic\/models/i,provider:"anthropic"},{pattern:/anthropic\.com|claude\.ai/i,provider:"anthropic"},{pattern:/openai\.com/i,provider:"openai"},{pattern:/gemini\.google|generativelanguage\.googleapis|cloudcode-pa\.googleapis/i,provider:"google"},{pattern:/bedrock.*\.amazonaws/i,provider:"aws-bedrock"},{pattern:/cognitive\.microsoft|azure\.openai/i,provider:"azure"},{pattern:/cohere\.ai/i,provider:"cohere"},{pattern:/huggingface\.co/i,provider:"huggingface"},{pattern:/replicate\.com/i,provider:"replicate"},{pattern:/together\.xyz/i,provider:"together"},{pattern:/mistral\.ai/i,provider:"mistral"},{pattern:/groq\.com/i,provider:"groq"},{pattern:/perplexity\.ai/i,provider:"perplexity"},{pattern:/ollama|localhost:\d+\/v1|127\.0\.0\.1:\d+\/v1/i,provider:"local"}];isLLMCall(e){return e?this.LLM_PATTERNS.some(t=>t.test(e)):!1}detectProvider(e){if(!e)return"unknown";for(const{pattern:t,provider:s}of this.PROVIDER_MAP)if(t.test(e))return s;return"unknown"}getSupportedProviders(){return Array.from(new Set(this.PROVIDER_MAP.map(({provider:e})=>e)))}isProviderSupported(e){return this.getSupportedProviders().includes(e.toLowerCase())}getProviderPattern(e){const t=this.PROVIDER_MAP.find(({provider:s})=>s===e.toLowerCase());return t?t.pattern:null}}class Bo{static enhanceRequest(e){const t=ee.contextData;if(!t)return e;try{const s=JSON.parse(e);s.system?typeof s.system=="string"?s.system=[{type:"text",text:s.system}]:Array.isArray(s.system)||(s.system=[s.system]):s.system=[];const o={type:"text",text:`# Task Context
5
-
6
- ${t}`};return s.system.length>0?s.system.splice(1,0,o):s.system.push(o),JSON.stringify(s)}catch(s){return console.error("Failed to enhance Claude request:",s),e}}}class qo{static enhanceRequest(e){const t=ee.contextData;if(!t)return e;try{const s=JSON.parse(e),o=`# Task Context
7
-
8
- ${t}`;return s.systemInstruction?typeof s.systemInstruction=="string"?s.systemInstruction={parts:[{text:o},{text:s.systemInstruction}]}:s.systemInstruction.parts&&s.systemInstruction.parts.unshift({text:o}):s.systemInstruction={parts:[{text:o}]},JSON.stringify(s)}catch(s){return console.error("Failed to enhance Gemini request:",s),e}}}class Ie{static enhancers=[{name:"Claude (Anthropic)",patterns:[/\/publishers\/anthropic\/models/i,/anthropic\.com/i,/claude\.ai/i,/\/v1\/messages/i],enhancer:Bo},{name:"Google Gemini",patterns:[/generativelanguage\.googleapis\.com/i,/cloudcode-pa\.googleapis\.com/i,/streamGenerateContent/i,/generateContent/i],enhancer:qo}];static enhanceRequest(e,t){const s=Ie.getEnhancerForUrl(e);if(!s)return t;try{return s.enhanceRequest(t)}catch(o){return console.error(`Enhancer failed for ${e}:`,o),t}}static getEnhancerForUrl(e){if(!e)return null;for(const t of Ie.enhancers)if(t.patterns.some(s=>s.test(e)))return t.enhancer;return null}static getEnhancerNameForUrl(e){if(!e)return"unknown";for(const t of Ie.enhancers)if(t.patterns.some(s=>s.test(e)))return t.name;return"unknown"}static isSupported(e){return Ie.getEnhancerForUrl(e)!==null}static getSupportedProviders(){return Ie.enhancers.map(e=>e.name)}static registerEnhancer(e,t,s){Ie.enhancers.push({name:e,patterns:t,enhancer:s})}}class Qt{originalFetch=null;static MAX_LOG_BYTES=256*1024;ctx;extra;constructor(e,t){this.ctx=e,this.extra=t}patch(){if(typeof globalThis.fetch!="function"||this.originalFetch)return;this.originalFetch=globalThis.fetch.bind(globalThis);const e=this.ctx,t=this.extra;globalThis.fetch=async(s,o)=>{const n=Ae.performance.now();let i="";try{i=typeof s=="string"?s:s?.url||""}catch{}const a=(o?.method||s?.method||"GET").toUpperCase();let p="";try{const h=o?.body??s?.body;if(h)if(typeof h=="string")p=h;else if(h instanceof URLSearchParams)p=h.toString();else if(typeof FormData<"u"&&h instanceof FormData){const y={};for(const[g,w]of h.entries())y[g]=typeof w=="string"?w:"[File|Blob]";p=JSON.stringify(y)}else h instanceof Uint8Array||Buffer.isBuffer(h)?p=Buffer.from(h).toString("utf8"):typeof h=="object"&&(p=JSON.stringify(h))}catch{p="<request body error>"}let _=p;if(e.llmProvider.isLLMCall(i)&&p&&p!=="<request body error>")try{_=Ie.enhanceRequest(i,p),_!==p&&o?o.body=_:_!==p&&typeof s=="object"&&s.body&&(s.body=_)}catch(h){console.error("[FetchInstrument] Failed to enhance LLM request:",h)}const l=e.idGenerator(),v=new Date().toISOString();if(t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(i,a,p)){const h={id:l,time:v,transport:"fetch",method:a,url:i,requestBody:p,durationMs:0};t.sendHttpStart(h).catch(y=>{console.error("[FetchInstrument] Failed to send HTTP start:",y)})}let k;try{k=await this.originalFetch(s,o)}catch(h){const y=Ae.performance.now()-n,g={id:l,time:v,transport:"fetch",method:a,url:i,requestBody:p,durationMs:Math.round(y),error:h.message};throw e.handleLogEntry(g),t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(i,a,p)&&t.sendHttpUpdate(g).catch(()=>{}),h}try{const h=Ae.performance.now()-n;let y="",g=0,w=null,L=!1;try{const ie=k.headers.get("content-type")||"";L=/text\/event-stream/i.test(ie);const ae=/^(text\/|application\/(json|xml|javascript))/i.test(ie)||/(json|xml|html)/i.test(ie);if(L){const Te=k.body;if(Te){const[pe,C]=Te.tee(),Y=(async()=>{try{const J=pe.getReader(),j=[];let W=0;for(;;){const{done:u,value:d}=await J.read();if(u)break;j.push(d),W+=d.byteLength}if(y=Buffer.concat(j.map(u=>Buffer.from(u))).toString("utf8"),g=W,e.llmProvider.isLLMCall(i)&&y)try{w=e.responseProcessor(i,y)}catch(u){w={error:`parser_failed: ${u instanceof Error?u.message:String(u)}`}}const Z={id:l,time:v,transport:"fetch",method:a,url:i,requestBody:p,status:k.status,ok:k.ok,durationMs:Math.round(Ae.performance.now()-n),responseBody:y,processedBody:w,bodyBytes:g};return e.handleLogEntry(Z),t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(i,a,p)&&t.sendHttpUpdate(Z).catch(()=>{}),{responseBody:y,processedBody:w,bodyBytes:g}}catch(J){return console.error("Error capturing stream:",J),{responseBody:"<stream capture error>",processedBody:null,bodyBytes:0}}})();k.__capturePromise=Y,k=new Response(C,{status:k.status,statusText:k.statusText,headers:k.headers}),y="<streaming in progress>",w=null}else y="<streaming response not buffered>"}else{const pe=await k.clone().arrayBuffer();g=pe.byteLength;const C=Qt.MAX_LOG_BYTES;ae?pe.byteLength<=C?y=Buffer.from(pe).toString("utf8"):y=`${Buffer.from(pe.slice(0,C)).toString("utf8")}
9
- ...[truncated ${(pe.byteLength-C).toLocaleString()} bytes]`:y=`<${g} bytes binary>`}}catch{y="<response body error>"}if(!L&&e.llmProvider.isLLMCall(i)&&y&&y!=="<response body error>")try{w=e.responseProcessor(i,y)}catch(ie){w={error:`parser_failed: ${ie instanceof Error?ie.message:String(ie)}`}}const U={id:l,time:v,transport:"fetch",method:a,url:i,requestBody:p,status:k.status,ok:k.ok,durationMs:Math.round(h),responseBody:y,processedBody:w,bodyBytes:g};return e.handleLogEntry(U),!L&&t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(i,a,p)&&t.sendHttpUpdate(U).catch(()=>{}),k}catch(h){const y=Ae.performance.now()-n,g={id:l,time:v,transport:"fetch",method:a,url:i,requestBody:p,durationMs:Math.round(y),error:h.message};return e.handleLogEntry(g),t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(i,a,p)&&t.sendHttpUpdate(g).catch(()=>{}),k}}}restore(){this.originalFetch&&(globalThis.fetch=this.originalFetch,this.originalFetch=null)}}class Vo{constructor(e,t,s={isValidMessageRequest:()=>!1,sendHttpStart:async()=>{},sendHttpUpdate:async()=>{}}){this.ctx=e,this.enableHttps=t,this._extra=s}originals=null;patch(){try{let e=function(a,p){try{if(typeof a=="string")return a;if(a instanceof URL)return a.toString();const _=a.protocol||p,l=a.hostname||a.host||"localhost",v=a.port?`:${a.port}`:"",k=a.path||a.pathname||"/";return`${_}//${l}${v}${k}`}catch{return""}},t=function(a,p){return function(l,v){const k=e(l,p),h=(typeof l=="object"&&l.method?l.method:"GET").toUpperCase(),y=Ae.performance.now(),g=n.ctx.idGenerator(),w=new Date().toISOString(),L=[];let U=0,ie=!1;const ae=a(l,C=>{const Y=[];let J=0,j=0;const W=()=>String(C.headers["content-type"]||"");C.on("data",K=>{J+=K.length;const te=W();if(/text\/event-stream/i.test(te))Y.push(K),j+=K.length;else{if(j>=i)return;const u=i-j;K.length<=u?(Y.push(K),j+=K.length):(Y.push(K.subarray(0,u)),j+=u)}}),C.on("end",()=>{const K=Ae.performance.now()-y;let te="";try{const x=W(),O=/text\/event-stream/i.test(x),R=Buffer.concat(Y),q=J>R.length||R.length===i;let V=R;if(!O){const H=String(C.headers["content-encoding"]||"").toLowerCase();if(!q&&V.length&&/(gzip|br|deflate)/.test(H))try{const B=require("node:zlib");H.includes("gzip")?V=B.gunzipSync(R):H.includes("br")?V=B.brotliDecompressSync(R):H.includes("deflate")&&(V=B.inflateSync(R))}catch{}}/text\//i.test(x)||/application\/(json|xml|javascript)/i.test(x)||O?(te=V.toString("utf8"),q&&!O&&(te+=`
10
- ...[truncated]`)):V.length&&(te=`<${V.length} bytes${q?" (truncated)":""} binary>`)}catch{te="<response body error>"}let Z="";try{const x=Buffer.concat(L),O=U>x.length||x.length===i;Z=x.toString("utf8"),O&&(Z+=`
11
- ...[truncated]`)}catch{Z="<request body error>"}let u=null;if(n.ctx.llmProvider.isLLMCall(k))try{u=n.ctx.responseProcessor(k,te)}catch(x){u={parts:[{type:"text",text:te||"<empty response>"}],metadata:{error:String(x)}}}const d={id:g,time:w,transport:p==="https:"?"https":"http",method:h,url:k,requestBody:Z,status:C.statusCode,ok:C.statusCode>=200&&C.statusCode<300,durationMs:Math.round(K),responseBody:te,processedBody:u,bodyBytes:J};try{const x=new URL(k);d.host=x.hostname,d.path=x.pathname}catch{}n.ctx.handleLogEntry(d),n._extra.agentHttpService&&n._extra.sessionId&&n._extra.isValidMessageRequest(k,h,Z)&&n._extra.sendHttpUpdate(d).catch(()=>{})}),C.on("error",K=>{const te=Ae.performance.now()-y;let Z="";try{const d=Buffer.concat(L),x=U>d.length||d.length===i;Z=d.toString("utf8"),x&&(Z+=`
12
- ...[truncated]`)}catch{Z="<request body error>"}const u={id:g,time:w,transport:p==="https:"?"https":"http",method:h,url:k,requestBody:Z,durationMs:Math.round(te),error:K.message};try{const d=new URL(k);u.host=d.hostname,u.path=d.pathname}catch{}n.ctx.handleLogEntry(u),n._extra.agentHttpService&&n._extra.sessionId&&n._extra.isValidMessageRequest(k,h,Z)&&n._extra.sendHttpUpdate(u).catch(()=>{})}),v&&v(C)}),Te=ae.write,pe=ae.end;return ae.write=function(C,Y,J){try{if(C&&U<i){const j=Buffer.isBuffer(C)?C:Buffer.from(C,Y||"utf8"),W=i-U;j.length<=W?(L.push(j),U+=j.length):(L.push(j.subarray(0,W)),U+=W)}}catch{}return Te.call(this,C,Y,J)},ae.end=function(C,Y,J){try{if(C&&U<i){const j=Buffer.isBuffer(C)?C:Buffer.from(C,Y||"utf8"),W=i-U;j.length<=W?(L.push(j),U+=j.length):(L.push(j.subarray(0,W)),U+=W)}if(!ie){ie=!0;try{const j=Buffer.concat(L),W=U>j.length||j.length===i;let K=j.toString("utf8");W&&(K+=`
13
- ...[truncated]`);const te=n._extra.isValidMessageRequest(k,h,K);if(n._extra.agentHttpService&&n._extra.sessionId&&te){const Z={id:g,time:w,transport:p==="https:"?"https":"http",method:h,url:k,requestBody:K,durationMs:0};n._extra.sendHttpStart(Z).catch(()=>{})}}catch{}}}catch{}return pe.call(this,C,Y,J)},ae}};const s=require("http"),o=require("https");if(this.originals)return;this.originals={httpRequest:s.request,httpsRequest:o.request,httpGet:s.get,httpsGet:o.get};const n=this,i=this.ctx.maxBodyBytes;s.request=t(this.originals.httpRequest,"http:"),s.get=function(p,_){const l=s.request(p,_);return l.end(),l},this.enableHttps!==!1&&(o.request=t(this.originals.httpsRequest,"https:"),o.get=function(p,_){const l=o.request(p,_);return l.end(),l})}catch{}}restore(){if(this.originals){try{const e=require("http"),t=require("https");e.request=this.originals.httpRequest,e.get=this.originals.httpGet,t.request=this.originals.httpsRequest,t.get=this.originals.httpsGet}catch{}this.originals=null}}}class Ze{static instance=null;isPatched=!1;config;llmProvider;idGenerator;agentHttpService;sessionId;activeRequests=new Map;rawLogger;errorLogger;processedLogger;fetchInstrument;httpInstrument;constructor(e={}){this.llmProvider=e.llmProvider||new Cs,this.idGenerator=e.idGenerator||ys.ulid,this.agentHttpService=e.agentHttpService,this.sessionId=e.sessionId,this.config={maxBodyBytes:e.maxBodyBytes??8192,enableHttpsPatching:e.enableHttpsPatching??!0,enableDebug:e.enableDebug??!1,logFilter:e.logFilter??(i=>!!(i.url&&!i.url.includes("statsig")&&!i.url.includes("registry.npmjs.org")&&!i.url.startsWith("data:"))),responseProcessor:e.responseProcessor??((i,a)=>{try{return ue.parseStreamingResponse(i,a)}catch{return null}})};const t=be.join(Yt.tmpdir(),"agiflow-agents","llm",`session-${process.pid}`),s=e.logFilePath||be.join(t,"network.log"),o=be.join(t,"error.log"),n=e.processedLogFilePath||be.join(t,"processed.jsonl");try{this.rawLogger=new st(s)}catch{}try{this.errorLogger=new st(o)}catch{}try{this.processedLogger=new st(n)}catch{}}static getInstance(e){return Ze.instance||(Ze.instance=new Ze(e)),Ze.instance}start(){if(this.isPatched)return;const e={idGenerator:this.idGenerator,maxBodyBytes:this.config.maxBodyBytes,enableDebug:this.config.enableDebug,logFilter:this.config.logFilter,responseProcessor:this.config.responseProcessor,llmProvider:this.llmProvider,handleLogEntry:t=>this.handleLogEntry(t)};this.fetchInstrument=new Qt(e,{agentHttpService:this.agentHttpService,sessionId:this.sessionId,isValidMessageRequest:(t,s,o)=>this.isValidMessageRequest(t,s,o),sendHttpStart:t=>this.sendHttpStart(t),sendHttpUpdate:t=>this.sendHttpUpdate(t)}),this.fetchInstrument.patch(),this.httpInstrument=new Vo(e,this.config.enableHttpsPatching,{agentHttpService:this.agentHttpService,sessionId:this.sessionId,isValidMessageRequest:(t,s,o)=>this.isValidMessageRequest(t,s,o),sendHttpStart:t=>this.sendHttpStart(t),sendHttpUpdate:t=>this.sendHttpUpdate(t)}),this.httpInstrument.patch(),this.isPatched=!0}stop(){this.isPatched&&(this.fetchInstrument?.restore(),this.httpInstrument?.restore(),this.isPatched=!1)}isActive(){return this.isPatched}updateConfig(e){this.config={...this.config,...e}}handleLogEntry(e){this.rawLogger&&this.rawLogger.info("network_entry",{networkLog:e}),this.processedLogger&&this.config.logFilter(e)&&e.processedBody&&this.processedLogger.info("processed_entry",{id:e.id,url:e.url,method:e.method,status:e.status,durationMs:e.durationMs,timestamp:e.time,processedBody:e.processedBody})}isValidMessageRequest(e,t,s){if(this.rawLogger&&this.rawLogger.info("isValidMessageRequest checking",{url:e,method:t,hasBody:!!s,bodyLength:s?.length}),!this.llmProvider.isLLMCall(e))return this.rawLogger&&this.rawLogger.info("Not an LLM URL, skipping",{url:e}),this.rawLogger&&this.config.enableDebug&&this.rawLogger.debug("Request validation failed: Not an LLM URL",{url:e,method:t}),!1;if(e.includes("cloudcode-pa.googleapis.com")||e.includes("generativelanguage.googleapis.com"))return!!e.includes("streamGenerateContent");if(t!=="POST"||!s)return!1;try{const o=JSON.parse(s),n=o.messages&&Array.isArray(o.messages)&&o.messages.length>0,i=o.prompt&&typeof o.prompt=="string",a=o.input&&typeof o.input=="string",p=o.contents&&Array.isArray(o.contents)&&o.contents.length>0,_=o.request?.contents&&Array.isArray(o.request.contents)&&o.request.contents.length>0;return n||i||a||p||_}catch(o){return this.errorLogger&&this.errorLogger.error("Failed to parse request body in isValidMessageRequest",{url:e,method:t,error:o instanceof Error?o.message:String(o)}),!1}}async sendHttpStart(e){if(!this.agentHttpService||!this.sessionId)return;this.rawLogger&&this.rawLogger.info("http_start",{entry:e});let t=[];if(e.requestBody)try{const o=JSON.parse(e.requestBody);if(o.messages&&Array.isArray(o.messages)){const n=o.messages.filter(i=>i.role==="user").pop();n?.content&&(typeof n.content=="string"?t.push({type:"text",text:n.content}):Array.isArray(n.content)&&(t=n.content.map(i=>({type:i.type||"text",text:i.text||JSON.stringify(i)}))))}else if(o.prompt)t.push({type:"text",text:o.prompt});else if(o.input)t.push({type:"text",text:o.input});else if(o.contents&&Array.isArray(o.contents)){const n=o.contents.filter(i=>i.role==="user").pop();n?.parts&&Array.isArray(n.parts)&&(t=n.parts.map(i=>({type:"text",text:i.text||JSON.stringify(i)})))}else if(o.request?.contents&&Array.isArray(o.request.contents)){const n=o.request.contents.filter(i=>i.role==="user").pop();n?.parts&&Array.isArray(n.parts)&&(t=n.parts.map(i=>({type:"text",text:i.text||JSON.stringify(i)})))}}catch(o){this.errorLogger&&this.errorLogger.error("Failed to parse request data in sendHttpStart",{url:e.url,error:o instanceof Error?o.message:String(o)}),t.push({type:"text",text:"LLM request initiated..."})}const s={llm_provider:this.llmProvider.detectProvider(e.url),request_started:!0};try{this.rawLogger&&this.rawLogger.info("Calling agentHttpService.startMessage",{sessionId:this.sessionId,entryId:e.id});const o=await this.agentHttpService.startMessage(this.sessionId,{messageType:"output",metadata:s});this.activeRequests.set(e.id,o.messageId),this.rawLogger&&this.rawLogger.info("startMessage successful",{entryId:e.id,messageId:o.messageId})}catch(o){this.errorLogger&&this.errorLogger.error("Failed to send HTTP start message",{url:e.url,sessionId:this.sessionId,error:o instanceof Error?o.message:String(o)})}}async sendHttpUpdate(e){if(!this.agentHttpService||!this.sessionId)return;this.rawLogger&&this.rawLogger.info("http_update",{entry:e});const t=this.activeRequests.get(e.id);if(!t)return;if(!(e.processedBody?.message?.parts?.length>0||e.processedBody?.parts?.length>0)){this.rawLogger&&this.rawLogger.info("Skipping update - no valid parts yet",{entryId:e.id,messageId:t});return}const o={llm_provider:this.llmProvider.detectProvider(e.url),status:e.status,duration:e.durationMs};if(e.processedBody?.metadata){const i=e.processedBody.metadata;i.model&&(o.model=i.model),i.usage&&(o.usage=i.usage),i.total_tokens&&(o.total_tokens=i.total_tokens),i.prompt_tokens&&(o.prompt_tokens=i.prompt_tokens),i.completion_tokens&&(o.completion_tokens=i.completion_tokens),i.cost&&(o.cost=i.cost)}let n=[];if(e.processedBody){const i=e.processedBody;i?.message?.parts&&Array.isArray(i.message.parts)?n=i.message.parts:i?.parts&&Array.isArray(i.parts)?n=i.parts:i?.error?n.push({type:"text",text:`Parser error: ${i.error}`}):n=[]}else e.responseBody&&n.push({type:"text",text:"LLM response completed"});try{const i={parts:n,metadata:o,mId:e.processedBody?.message?.id};ee.isSaveRawEnabled&&(i.raw=JSON.stringify(e)),await this.agentHttpService.updateMessage(this.sessionId,t,i),this.activeRequests.delete(e.id)}catch(i){this.errorLogger&&this.errorLogger.error("Failed to send HTTP update message",{url:e.url,messageId:t,sessionId:this.sessionId,error:i instanceof Error?i.message:String(i)}),this.activeRequests.delete(e.id)}}}const ps=Os(()=>Ve([As(),N(),ge(),kt(),qe(ps),vt(ps)])),_s=M({toolCallId:N(),toolName:N(),args:Ne()}),Go=M({toolCallId:N(),toolName:N(),args:Ne(),result:Ne()}),Uo=Ve([_s.extend({state:oe("partial-call"),step:ge().optional()}),_s.extend({state:oe("call"),step:ge().optional()}),Go.extend({state:oe("result"),step:ge().optional()})]),Zo=M({type:N(),content:N()}),Ho=M({type:oe("text"),text:N()}),Jo=M({type:oe("reasoning"),reasoning:N(),details:qe(Ve([M({type:oe("text"),text:N(),signature:N().optional()}),M({type:oe("redacted"),data:N()})])).optional()}),Wo=M({name:oe("select"),props:M({options:qe(M({label:N(),value:Ve([N(),ge()]),selected:kt().optional()}))})}),Ko=M({name:oe("placeholder"),props:M({})}),Yo=Ve([Wo,Ko]),Xo=M({completed:kt(),component:Yo}),Qo=M({type:oe("tool-invocation"),toolInvocation:Uo,input:Xo.optional(),jsx:N({description:"UI rendering"}).optional()}),er=M({type:oe("source"),source:Zo}),tr=M({type:oe("file"),mimeType:N(),data:N()}),sr=M({type:oe("error"),text:N(),error:Ne().optional()}),or=M({type:oe("step-start")}),Ns=Ve([Ho,Jo,Qo,er,tr,sr,or]),es=Pt(["input","output","error","system"]),Ls=M({messageType:es,parts:qe(Ns),metadata:vt(N(),jt()).optional(),raw:Ne().optional()});M({id:N(),sessionId:N(),agentTypeId:N(),messageType:es,contentSize:ge().nullable(),timestamp:It.date(),metadata:N().nullable(),raw:Ne().nullable().optional(),createdAt:It.date(),updatedAt:It.date()});const rr=M({messageType:Pt(["output"]).default("output"),metadata:vt(N(),jt()).optional()});M({id:N(),messageId:N()});const nr=M({parts:qe(Ns).optional(),metadata:vt(N(),jt()).optional(),raw:Ne().optional()});M({messages:qe(Ls)});function ir(r){return[ar(r)]}function us(r){let e=r.parts;if(!e&&r.content&&(e=ir(r.content)),!e)throw new Error("Either content or parts is required for message creation");return{messageType:r.messageType,parts:e,metadata:r.metadata,raw:r.raw}}function ar(r){return{type:"text",text:r}}const Bt=10,cs=(r=0)=>e=>`\x1B[${e+r}m`,ls=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,ds=(r=0)=>(e,t,s)=>`\x1B[${38+r};2;${e};${t};${s}m`,$={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys($.modifier);const pr=Object.keys($.color),_r=Object.keys($.bgColor);[...pr,..._r];function ur(){const r=new Map;for(const[e,t]of Object.entries($)){for(const[s,o]of Object.entries(t))$[s]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},t[s]=$[s],r.set(o[0],o[1]);Object.defineProperty($,e,{value:t,enumerable:!1})}return Object.defineProperty($,"codes",{value:r,enumerable:!1}),$.color.close="\x1B[39m",$.bgColor.close="\x1B[49m",$.color.ansi=cs(),$.color.ansi256=ls(),$.color.ansi16m=ds(),$.bgColor.ansi=cs(Bt),$.bgColor.ansi256=ls(Bt),$.bgColor.ansi16m=ds(Bt),Object.defineProperties($,{rgbToAnsi256:{value(e,t,s){return e===t&&t===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(s/255*5)},enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[s]=t;s.length===3&&(s=[...s].map(n=>n+n).join(""));const o=Number.parseInt(s,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:e=>$.rgbToAnsi256(...$.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,s,o;if(e>=232)t=((e-232)*10+8)/255,s=t,o=t;else{e-=16;const a=e%36;t=Math.floor(e/36)/5,s=Math.floor(a/6)/5,o=a%6/5}const n=Math.max(t,s,o)*2;if(n===0)return 30;let i=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(t));return n===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(e,t,s)=>$.ansi256ToAnsi($.rgbToAnsi256(e,t,s)),enumerable:!1},hexToAnsi:{value:e=>$.ansi256ToAnsi($.hexToAnsi256(e)),enumerable:!1}}),$}const me=ur(),ms=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const r=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(r&&r.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),hs=ms!==0&&{level:ms},cr={stdout:hs,stderr:hs};function lr(r,e,t){let s=r.indexOf(e);if(s===-1)return r;const o=e.length;let n=0,i="";do i+=r.slice(n,s)+e+t,n=s+o,s=r.indexOf(e,n);while(s!==-1);return i+=r.slice(n),i}function dr(r,e,t,s){let o=0,n="";do{const i=r[s-1]==="\r";n+=r.slice(o,i?s-1:s)+e+(i?`\r
1
+ "use strict";const Fs=require("node:os"),Ps=require("node:path"),Te=require("ulidx"),js=require("node:fs"),Ee=require("node:perf_hooks"),Oe=require("path"),Ce=require("fs-extra"),Ut=require("os"),$s=require("node:crypto");require("@inquirer/prompts");function es(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const jt=es(Fs),fe=es(Ps),ke=es(js);var z;(function(n){n.assertEqual=o=>{};function e(o){}n.assertIs=e;function t(o){throw new Error}n.assertNever=t,n.arrayToEnum=o=>{const r={};for(const i of o)r[i]=i;return r},n.getValidEnumValues=o=>{const r=n.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(const a of r)i[a]=o[a];return n.objectValues(i)},n.objectValues=o=>n.objectKeys(o).map(function(r){return o[r]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const r=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&r.push(i);return r},n.find=(o,r)=>{for(const i of o)if(r(i))return i},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function s(o,r=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}n.joinValues=s,n.jsonStringifyReplacer=(o,r)=>typeof r=="bigint"?r.toString():r})(z||(z={}));var Zt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Zt||(Zt={}));const y=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ie=n=>{switch(typeof n){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(n)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(n)?y.array:n===null?y.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?y.promise:typeof Map<"u"&&n instanceof Map?y.map:typeof Set<"u"&&n instanceof Set?y.set:typeof Date<"u"&&n instanceof Date?y.date:y.object;default:return y.unknown}},l=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ds=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class _e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(r){return r.message},s={_errors:[]},o=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let a=s,p=0;for(;p<i.path.length;){const u=i.path[p];p===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(t(i))):a[u]=a[u]||{_errors:[]},a=a[u],p++}}};return o(this),s}static assert(e){if(!(e instanceof _e))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const o of this.issues)if(o.path.length>0){const r=o.path[0];t[r]=t[r]||[],t[r].push(e(o))}else s.push(e(o));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}_e.create=n=>new _e(n);const Ye=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===y.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,z.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${z.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${z.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${z.joinValues(n.options)}, received '${n.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:z.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case l.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case l.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,z.assertNever(n)}return{message:t}};let ws=Ye;function qs(n){ws=n}function Rt(){return ws}const Nt=n=>{const{data:e,path:t,errorMaps:s,issueData:o}=n,r=[...t,...o.path||[]],i={...o,path:r};if(o.message!==void 0)return{...o,path:r,message:o.message};let a="";const p=s.filter(u=>!!u).slice().reverse();for(const u of p)a=u(i,{data:e,defaultError:a}).message;return{...o,path:r,message:a}},Bs=[];function f(n,e){const t=Rt(),s=Nt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ye?void 0:Ye].filter(o=>!!o)});n.common.issues.push(s)}class ie{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const o of t){if(o.status==="aborted")return T;o.status==="dirty"&&e.dirty(),s.push(o.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const o of t){const r=await o.key,i=await o.value;s.push({key:r,value:i})}return ie.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const o of t){const{key:r,value:i}=o;if(r.status==="aborted"||i.status==="aborted")return T;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(s[r.value]=i.value)}return{status:e.value,value:s}}}const T=Object.freeze({status:"aborted"}),Ze=n=>({status:"dirty",value:n}),ue=n=>({status:"valid",value:n}),Jt=n=>n.status==="aborted",Wt=n=>n.status==="dirty",qe=n=>n.status==="valid",it=n=>typeof Promise<"u"&&n instanceof Promise;var b;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));class xe{constructor(e,t,s,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const as=(n,e)=>{if(qe(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new _e(n.common.issues);return this._error=t,this._error}}};function A(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:o}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{const{message:p}=n;return i.code==="invalid_enum_value"?{message:p??a.defaultError}:typeof a.data>"u"?{message:p??s??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:p??t??a.defaultError}},description:o}}class O{get description(){return this._def.description}_getType(e){return Ie(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ie,ctx:{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(it(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)},o=this._parseSync({data:e,path:s.path,parent:s});return as(s,o)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return qe(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>qe(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)},o=this._parse({data:e,path:s.path,parent:s}),r=await(it(o)?o:Promise.resolve(o));return as(s,r)}refine(e,t){const s=o=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(o):t;return this._refinement((o,r)=>{const i=e(o),a=()=>r.addIssue({code:l.custom,...s(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(p=>p?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((s,o)=>e(s)?!0:(o.addIssue(typeof t=="function"?t(s,o):t),!1))}_refinement(e){return new he({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ve.create(this,this._def)}nullable(){return Fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return me.create(this)}promise(){return Xe.create(this,this._def)}or(e){return _t.create([this,e],this._def)}and(e){return ct.create(this,e,this._def)}transform(e){return new he({...A(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new gt({...A(this._def),innerType:this,defaultValue:t,typeName:E.ZodDefault})}brand(){return new ts({typeName:E.ZodBranded,type:this,...A(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ft({...A(this._def),innerType:this,catchValue:t,typeName:E.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return yt.create(this,e)}readonly(){return kt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Us=/^c[^\s-]{8,}$/i,Hs=/^[0-9a-z]+$/,Gs=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vs=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Zs=/^[a-z0-9_-]{21}$/i,Js=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ws=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ys=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ks="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ht;const Xs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Qs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,eo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,to=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,so=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,oo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ss="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ro=new RegExp(`^${Ss}$`);function Ts(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function no(n){return new RegExp(`^${Ts(n)}$`)}function Es(n){let e=`${Ss}T${Ts(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function io(n,e){return!!((e==="v4"||!e)&&Xs.test(n)||(e==="v6"||!e)&&eo.test(n))}function ao(n,e){if(!Js.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),o=JSON.parse(atob(s));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function po(n,e){return!!((e==="v4"||!e)&&Qs.test(n)||(e==="v6"||!e)&&to.test(n))}class de extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:y.string,received:r.parsedType}),T}const s=new ie;let o;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:l.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="max")e.data.length>r.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:l.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?f(o,{code:l.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&f(o,{code:l.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),s.dirty())}else if(r.kind==="email")Ys.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"email",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="emoji")Ht||(Ht=new RegExp(Ks,"u")),Ht.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"emoji",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="uuid")Vs.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"uuid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="nanoid")Zs.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"nanoid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid")Us.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"cuid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid2")Hs.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"cuid2",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="ulid")Gs.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"ulid",code:l.invalid_string,message:r.message}),s.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),f(o,{validation:"url",code:l.invalid_string,message:r.message}),s.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"regex",code:l.invalid_string,message:r.message}),s.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(o=this._getOrReturnCtx(e,o),f(o,{code:l.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),s.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(o=this._getOrReturnCtx(e,o),f(o,{code:l.invalid_string,validation:{startsWith:r.value},message:r.message}),s.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(o=this._getOrReturnCtx(e,o),f(o,{code:l.invalid_string,validation:{endsWith:r.value},message:r.message}),s.dirty()):r.kind==="datetime"?Es(r).test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{code:l.invalid_string,validation:"datetime",message:r.message}),s.dirty()):r.kind==="date"?ro.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{code:l.invalid_string,validation:"date",message:r.message}),s.dirty()):r.kind==="time"?no(r).test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{code:l.invalid_string,validation:"time",message:r.message}),s.dirty()):r.kind==="duration"?Ws.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"duration",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="ip"?io(e.data,r.version)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"ip",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="jwt"?ao(e.data,r.alg)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"jwt",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="cidr"?po(e.data,r.version)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"cidr",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="base64"?so.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"base64",code:l.invalid_string,message:r.message}),s.dirty()):r.kind==="base64url"?oo.test(e.data)||(o=this._getOrReturnCtx(e,o),f(o,{validation:"base64url",code:l.invalid_string,message:r.message}),s.dirty()):z.assertNever(r);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(o=>e.test(o),{validation:t,code:l.invalid_string,...b.errToObj(s)})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new de({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new de({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new de({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}de.create=n=>new de({checks:[],typeName:E.ZodString,coerce:n?.coerce??!1,...A(n)});function uo(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,o=t>s?t:s,r=Number.parseInt(n.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return r%i/10**o}class Le extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:y.number,received:r.parsedType}),T}let s;const o=new ie;for(const r of this._def.checks)r.kind==="int"?z.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_type,expected:"integer",received:"float",message:r.message}),o.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),o.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),o.dirty()):r.kind==="multipleOf"?uo(e.data,r.value)!==0&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.not_multiple_of,multipleOf:r.value,message:r.message}),o.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.not_finite,message:r.message}),o.dirty()):z.assertNever(r);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,o){return new Le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(o)}]})}_addCheck(e){return new Le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&z.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Le.create=n=>new Le({checks:[],typeName:E.ZodNumber,coerce:n?.coerce||!1,...A(n)});class ze extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let s;const o=new ie;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),o.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),o.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.not_multiple_of,multipleOf:r.value,message:r.message}),o.dirty()):z.assertNever(r);return{status:o.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:y.bigint,received:t.parsedType}),T}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,o){return new ze({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(o)}]})}_addCheck(e){return new ze({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ze.create=n=>new ze({checks:[],typeName:E.ZodBigInt,coerce:n?.coerce??!1,...A(n)});class at extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:y.boolean,received:s.parsedType}),T}return ue(e.data)}}at.create=n=>new at({typeName:E.ZodBoolean,coerce:n?.coerce||!1,...A(n)});class Be extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:y.date,received:r.parsedType}),T}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_date}),T}const s=new ie;let o;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:l.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),s.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(o=this._getOrReturnCtx(e,o),f(o,{code:l.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),s.dirty()):z.assertNever(r);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Be({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Be.create=n=>new Be({checks:[],coerce:n?.coerce||!1,typeName:E.ZodDate,...A(n)});class Lt extends O{_parse(e){if(this._getType(e)!==y.symbol){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:y.symbol,received:s.parsedType}),T}return ue(e.data)}}Lt.create=n=>new Lt({typeName:E.ZodSymbol,...A(n)});class pt extends O{_parse(e){if(this._getType(e)!==y.undefined){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:y.undefined,received:s.parsedType}),T}return ue(e.data)}}pt.create=n=>new pt({typeName:E.ZodUndefined,...A(n)});class ut extends O{_parse(e){if(this._getType(e)!==y.null){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:y.null,received:s.parsedType}),T}return ue(e.data)}}ut.create=n=>new ut({typeName:E.ZodNull,...A(n)});class Ke extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return ue(e.data)}}Ke.create=n=>new Ke({typeName:E.ZodAny,...A(n)});class De extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ue(e.data)}}De.create=n=>new De({typeName:E.ZodUnknown,...A(n)});class Ae extends O{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:y.never,received:t.parsedType}),T}}Ae.create=n=>new Ae({typeName:E.ZodNever,...A(n)});class zt extends O{_parse(e){if(this._getType(e)!==y.undefined){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:y.void,received:s.parsedType}),T}return ue(e.data)}}zt.create=n=>new zt({typeName:E.ZodVoid,...A(n)});class me extends O{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),o=this._def;if(t.parsedType!==y.array)return f(t,{code:l.invalid_type,expected:y.array,received:t.parsedType}),T;if(o.exactLength!==null){const i=t.data.length>o.exactLength.value,a=t.data.length<o.exactLength.value;(i||a)&&(f(t,{code:i?l.too_big:l.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),s.dirty())}if(o.minLength!==null&&t.data.length<o.minLength.value&&(f(t,{code:l.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),s.dirty()),o.maxLength!==null&&t.data.length>o.maxLength.value&&(f(t,{code:l.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,a)=>o.type._parseAsync(new xe(t,i,t.path,a)))).then(i=>ie.mergeArray(s,i));const r=[...t.data].map((i,a)=>o.type._parseSync(new xe(t,i,t.path,a)));return ie.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new me({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new me({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new me({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}me.create=(n,e)=>new me({type:n,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...A(e)});function Ve(n){if(n instanceof U){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=ve.create(Ve(s))}return new U({...n._def,shape:()=>e})}else return n instanceof me?new me({...n._def,type:Ve(n.element)}):n instanceof ve?ve.create(Ve(n.unwrap())):n instanceof Fe?Fe.create(Ve(n.unwrap())):n instanceof be?be.create(n.items.map(e=>Ve(e))):n}class U extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=z.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==y.object){const u=this._getOrReturnCtx(e);return f(u,{code:l.invalid_type,expected:y.object,received:u.parsedType}),T}const{status:s,ctx:o}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ae&&this._def.unknownKeys==="strip"))for(const u in o.data)i.includes(u)||a.push(u);const p=[];for(const u of i){const c=r[u],g=o.data[u];p.push({key:{status:"valid",value:u},value:c._parse(new xe(o,g,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Ae){const u=this._def.unknownKeys;if(u==="passthrough")for(const c of a)p.push({key:{status:"valid",value:c},value:{status:"valid",value:o.data[c]}});else if(u==="strict")a.length>0&&(f(o,{code:l.unrecognized_keys,keys:a}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const c of a){const g=o.data[c];p.push({key:{status:"valid",value:c},value:u._parse(new xe(o,g,o.path,c)),alwaysSet:c in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const u=[];for(const c of p){const g=await c.key,v=await c.value;u.push({key:g,value:v,alwaysSet:c.alwaysSet})}return u}).then(u=>ie.mergeObjectSync(s,u)):ie.mergeObjectSync(s,p)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new U({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const o=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:b.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new U({...this._def,unknownKeys:"strip"})}passthrough(){return new U({...this._def,unknownKeys:"passthrough"})}extend(e){return new U({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new U({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:E.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new U({...this._def,catchall:e})}pick(e){const t={};for(const s of z.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new U({...this._def,shape:()=>t})}omit(e){const t={};for(const s of z.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new U({...this._def,shape:()=>t})}deepPartial(){return Ve(this)}partial(e){const t={};for(const s of z.objectKeys(this.shape)){const o=this.shape[s];e&&!e[s]?t[s]=o:t[s]=o.optional()}return new U({...this._def,shape:()=>t})}required(e){const t={};for(const s of z.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof ve;)r=r._def.innerType;t[s]=r}return new U({...this._def,shape:()=>t})}keyof(){return Is(z.objectKeys(this.shape))}}U.create=(n,e)=>new U({shape:()=>n,unknownKeys:"strip",catchall:Ae.create(),typeName:E.ZodObject,...A(e)});U.strictCreate=(n,e)=>new U({shape:()=>n,unknownKeys:"strict",catchall:Ae.create(),typeName:E.ZodObject,...A(e)});U.lazycreate=(n,e)=>new U({shape:n,unknownKeys:"strip",catchall:Ae.create(),typeName:E.ZodObject,...A(e)});class _t extends O{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function o(r){for(const a of r)if(a.result.status==="valid")return a.result;for(const a of r)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const i=r.map(a=>new _e(a.ctx.common.issues));return f(t,{code:l.invalid_union,unionErrors:i}),T}if(t.common.async)return Promise.all(s.map(async r=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(o);{let r;const i=[];for(const p of s){const u={...t,common:{...t.common,issues:[]},parent:null},c=p._parseSync({data:t.data,path:t.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!r&&(r={result:c,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const a=i.map(p=>new _e(p));return f(t,{code:l.invalid_union,unionErrors:a}),T}}get options(){return this._def.options}}_t.create=(n,e)=>new _t({options:n,typeName:E.ZodUnion,...A(e)});const Se=n=>n instanceof dt?Se(n.schema):n instanceof he?Se(n.innerType()):n instanceof mt?[n.value]:n instanceof Me?n.options:n instanceof ht?z.objectValues(n.enum):n instanceof gt?Se(n._def.innerType):n instanceof pt?[void 0]:n instanceof ut?[null]:n instanceof ve?[void 0,...Se(n.unwrap())]:n instanceof Fe?[null,...Se(n.unwrap())]:n instanceof ts||n instanceof kt?Se(n.unwrap()):n instanceof ft?Se(n._def.innerType):[];class $t extends O{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return f(t,{code:l.invalid_type,expected:y.object,received:t.parsedType}),T;const s=this.discriminator,o=t.data[s],r=this.optionsMap.get(o);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const o=new Map;for(const r of t){const i=Se(r.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,r)}}return new $t({typeName:E.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:o,...A(s)})}}function Yt(n,e){const t=Ie(n),s=Ie(e);if(n===e)return{valid:!0,data:n};if(t===y.object&&s===y.object){const o=z.objectKeys(e),r=z.objectKeys(n).filter(a=>o.indexOf(a)!==-1),i={...n,...e};for(const a of r){const p=Yt(n[a],e[a]);if(!p.valid)return{valid:!1};i[a]=p.data}return{valid:!0,data:i}}else if(t===y.array&&s===y.array){if(n.length!==e.length)return{valid:!1};const o=[];for(let r=0;r<n.length;r++){const i=n[r],a=e[r],p=Yt(i,a);if(!p.valid)return{valid:!1};o.push(p.data)}return{valid:!0,data:o}}else return t===y.date&&s===y.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class ct extends O{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),o=(r,i)=>{if(Jt(r)||Jt(i))return T;const a=Yt(r.value,i.value);return a.valid?((Wt(r)||Wt(i))&&t.dirty(),{status:t.value,value:a.data}):(f(s,{code:l.invalid_intersection_types}),T)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([r,i])=>o(r,i)):o(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ct.create=(n,e,t)=>new ct({left:n,right:e,typeName:E.ZodIntersection,...A(t)});class be extends O{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==y.array)return f(s,{code:l.invalid_type,expected:y.array,received:s.parsedType}),T;if(s.data.length<this._def.items.length)return f(s,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&s.data.length>this._def.items.length&&(f(s,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((i,a)=>{const p=this._def.items[a]||this._def.rest;return p?p._parse(new xe(s,i,s.path,a)):null}).filter(i=>!!i);return s.common.async?Promise.all(r).then(i=>ie.mergeArray(t,i)):ie.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new be({...this._def,rest:e})}}be.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new be({items:n,typeName:E.ZodTuple,rest:null,...A(e)})};class lt extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==y.object)return f(s,{code:l.invalid_type,expected:y.object,received:s.parsedType}),T;const o=[],r=this._def.keyType,i=this._def.valueType;for(const a in s.data)o.push({key:r._parse(new xe(s,a,s.path,a)),value:i._parse(new xe(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?ie.mergeObjectAsync(t,o):ie.mergeObjectSync(t,o)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof O?new lt({keyType:e,valueType:t,typeName:E.ZodRecord,...A(s)}):new lt({keyType:de.create(),valueType:e,typeName:E.ZodRecord,...A(t)})}}class Mt extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==y.map)return f(s,{code:l.invalid_type,expected:y.map,received:s.parsedType}),T;const o=this._def.keyType,r=this._def.valueType,i=[...s.data.entries()].map(([a,p],u)=>({key:o._parse(new xe(s,a,s.path,[u,"key"])),value:r._parse(new xe(s,p,s.path,[u,"value"]))}));if(s.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const p of i){const u=await p.key,c=await p.value;if(u.status==="aborted"||c.status==="aborted")return T;(u.status==="dirty"||c.status==="dirty")&&t.dirty(),a.set(u.value,c.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const p of i){const u=p.key,c=p.value;if(u.status==="aborted"||c.status==="aborted")return T;(u.status==="dirty"||c.status==="dirty")&&t.dirty(),a.set(u.value,c.value)}return{status:t.value,value:a}}}}Mt.create=(n,e,t)=>new Mt({valueType:e,keyType:n,typeName:E.ZodMap,...A(t)});class Ue extends O{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==y.set)return f(s,{code:l.invalid_type,expected:y.set,received:s.parsedType}),T;const o=this._def;o.minSize!==null&&s.data.size<o.minSize.value&&(f(s,{code:l.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),t.dirty()),o.maxSize!==null&&s.data.size>o.maxSize.value&&(f(s,{code:l.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),t.dirty());const r=this._def.valueType;function i(p){const u=new Set;for(const c of p){if(c.status==="aborted")return T;c.status==="dirty"&&t.dirty(),u.add(c.value)}return{status:t.value,value:u}}const a=[...s.data.values()].map((p,u)=>r._parse(new xe(s,p,s.path,u)));return s.common.async?Promise.all(a).then(p=>i(p)):i(a)}min(e,t){return new Ue({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new Ue({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ue.create=(n,e)=>new Ue({valueType:n,minSize:null,maxSize:null,typeName:E.ZodSet,...A(e)});class We extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return f(t,{code:l.invalid_type,expected:y.function,received:t.parsedType}),T;function s(a,p){return Nt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),Ye].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:p}})}function o(a,p){return Nt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),Ye].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:p}})}const r={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Xe){const a=this;return ue(async function(...p){const u=new _e([]),c=await a._def.args.parseAsync(p,r).catch(d=>{throw u.addIssue(s(p,d)),u}),g=await Reflect.apply(i,this,c);return await a._def.returns._def.type.parseAsync(g,r).catch(d=>{throw u.addIssue(o(g,d)),u})})}else{const a=this;return ue(function(...p){const u=a._def.args.safeParse(p,r);if(!u.success)throw new _e([s(p,u.error)]);const c=Reflect.apply(i,this,u.data),g=a._def.returns.safeParse(c,r);if(!g.success)throw new _e([o(c,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new We({...this._def,args:be.create(e).rest(De.create())})}returns(e){return new We({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new We({args:e||be.create([]).rest(De.create()),returns:t||De.create(),typeName:E.ZodFunction,...A(s)})}}class dt extends O{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}dt.create=(n,e)=>new dt({getter:n,typeName:E.ZodLazy,...A(e)});class mt extends O{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}mt.create=(n,e)=>new mt({value:n,typeName:E.ZodLiteral,...A(e)});function Is(n,e){return new Me({values:n,typeName:E.ZodEnum,...A(e)})}class Me extends O{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{expected:z.joinValues(s),received:t.parsedType,code:l.invalid_type}),T}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{received:t.data,code:l.invalid_enum_value,options:s}),T}return ue(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Me.create(e,{...this._def,...t})}exclude(e,t=this._def){return Me.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}Me.create=Is;class ht extends O{_parse(e){const t=z.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==y.string&&s.parsedType!==y.number){const o=z.objectValues(t);return f(s,{expected:z.joinValues(o),received:s.parsedType,code:l.invalid_type}),T}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const o=z.objectValues(t);return f(s,{received:s.data,code:l.invalid_enum_value,options:o}),T}return ue(e.data)}get enum(){return this._def.values}}ht.create=(n,e)=>new ht({values:n,typeName:E.ZodNativeEnum,...A(e)});class Xe extends O{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&t.common.async===!1)return f(t,{code:l.invalid_type,expected:y.promise,received:t.parsedType}),T;const s=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return ue(s.then(o=>this._def.type.parseAsync(o,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Xe.create=(n,e)=>new Xe({type:n,typeName:E.ZodPromise,...A(e)});class he extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),o=this._def.effect||null,r={addIssue:i=>{f(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),o.type==="preprocess"){const i=o.transform(s.data,r);if(s.common.async)return Promise.resolve(i).then(async a=>{if(t.value==="aborted")return T;const p=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return p.status==="aborted"?T:p.status==="dirty"||t.value==="dirty"?Ze(p.value):p});{if(t.value==="aborted")return T;const a=this._def.schema._parseSync({data:i,path:s.path,parent:s});return a.status==="aborted"?T:a.status==="dirty"||t.value==="dirty"?Ze(a.value):a}}if(o.type==="refinement"){const i=a=>{const p=o.refinement(a,r);if(s.common.async)return Promise.resolve(p);if(p instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?T:(a.status==="dirty"&&t.dirty(),i(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?T:(a.status==="dirty"&&t.dirty(),i(a.value).then(()=>({status:t.value,value:a.value}))))}if(o.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!qe(i))return T;const a=o.transform(i.value,r);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>qe(i)?Promise.resolve(o.transform(i.value,r)).then(a=>({status:t.value,value:a})):T);z.assertNever(o)}}he.create=(n,e,t)=>new he({schema:n,typeName:E.ZodEffects,effect:e,...A(t)});he.createWithPreprocess=(n,e,t)=>new he({schema:e,effect:{type:"preprocess",transform:n},typeName:E.ZodEffects,...A(t)});class ve extends O{_parse(e){return this._getType(e)===y.undefined?ue(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(n,e)=>new ve({innerType:n,typeName:E.ZodOptional,...A(e)});class Fe extends O{_parse(e){return this._getType(e)===y.null?ue(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fe.create=(n,e)=>new Fe({innerType:n,typeName:E.ZodNullable,...A(e)});class gt extends O{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===y.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}gt.create=(n,e)=>new gt({innerType:n,typeName:E.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...A(e)});class ft extends O{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},o=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return it(o)?o.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new _e(s.common.issues)},input:s.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new _e(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ft.create=(n,e)=>new ft({innerType:n,typeName:E.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...A(e)});class Ft extends O{_parse(e){if(this._getType(e)!==y.nan){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:y.nan,received:s.parsedType}),T}return{status:"valid",value:e.data}}}Ft.create=n=>new Ft({typeName:E.ZodNaN,...A(n)});const _o=Symbol("zod_brand");class ts extends O{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class yt extends O{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?T:r.status==="dirty"?(t.dirty(),Ze(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const o=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?T:o.status==="dirty"?(t.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:s.path,parent:s})}}static create(e,t){return new yt({in:e,out:t,typeName:E.ZodPipeline})}}class kt extends O{_parse(e){const t=this._def.innerType._parse(e),s=o=>(qe(o)&&(o.value=Object.freeze(o.value)),o);return it(t)?t.then(o=>s(o)):s(t)}unwrap(){return this._def.innerType}}kt.create=(n,e)=>new kt({innerType:n,typeName:E.ZodReadonly,...A(e)});function ps(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function As(n,e={},t){return n?Ke.create().superRefine((s,o)=>{const r=n(s);if(r instanceof Promise)return r.then(i=>{if(!i){const a=ps(e,s),p=a.fatal??t??!0;o.addIssue({code:"custom",...a,fatal:p})}});if(!r){const i=ps(e,s),a=i.fatal??t??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Ke.create()}const co={object:U.lazycreate};var E;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(E||(E={}));const lo=(n,e={message:`Input not instance of ${n.name}`})=>As(t=>t instanceof n,e),M=de.create,ye=Le.create,mo=Ft.create,ho=ze.create,xt=at.create,go=Be.create,fo=Lt.create,ko=pt.create,Cs=ut.create,Pe=Ke.create,Dt=De.create,vo=Ae.create,yo=zt.create,He=me.create,P=U.create,xo=U.strictCreate,Ge=_t.create,bo=$t.create,wo=ct.create,So=be.create,bt=lt.create,To=Mt.create,Eo=Ue.create,Io=We.create,Os=dt.create,pe=mt.create,qt=Me.create,Ao=ht.create,Co=Xe.create,us=he.create,Oo=ve.create,Ro=Fe.create,No=he.createWithPreprocess,Lo=yt.create,zo=()=>M().optional(),Mo=()=>ye().optional(),Fo=()=>xt().optional(),Ot={string:n=>de.create({...n,coerce:!0}),number:n=>Le.create({...n,coerce:!0}),boolean:n=>at.create({...n,coerce:!0}),bigint:n=>ze.create({...n,coerce:!0}),date:n=>Be.create({...n,coerce:!0})},Po=T,re=Object.freeze(Object.defineProperty({__proto__:null,BRAND:_o,DIRTY:Ze,EMPTY_PATH:Bs,INVALID:T,NEVER:Po,OK:ue,ParseStatus:ie,Schema:O,ZodAny:Ke,ZodArray:me,ZodBigInt:ze,ZodBoolean:at,ZodBranded:ts,ZodCatch:ft,ZodDate:Be,ZodDefault:gt,ZodDiscriminatedUnion:$t,ZodEffects:he,ZodEnum:Me,ZodError:_e,get ZodFirstPartyTypeKind(){return E},ZodFunction:We,ZodIntersection:ct,ZodIssueCode:l,ZodLazy:dt,ZodLiteral:mt,ZodMap:Mt,ZodNaN:Ft,ZodNativeEnum:ht,ZodNever:Ae,ZodNull:ut,ZodNullable:Fe,ZodNumber:Le,ZodObject:U,ZodOptional:ve,ZodParsedType:y,ZodPipeline:yt,ZodPromise:Xe,ZodReadonly:kt,ZodRecord:lt,ZodSchema:O,ZodSet:Ue,ZodString:de,ZodSymbol:Lt,ZodTransformer:he,ZodTuple:be,ZodType:O,ZodUndefined:pt,ZodUnion:_t,ZodUnknown:De,ZodVoid:zt,addIssueToContext:f,any:Pe,array:He,bigint:ho,boolean:xt,coerce:Ot,custom:As,date:go,datetimeRegex:Es,defaultErrorMap:Ye,discriminatedUnion:bo,effect:us,enum:qt,function:Io,getErrorMap:Rt,getParsedType:Ie,instanceof:lo,intersection:wo,isAborted:Jt,isAsync:it,isDirty:Wt,isValid:qe,late:co,lazy:Os,literal:pe,makeIssue:Nt,map:To,nan:mo,nativeEnum:Ao,never:vo,null:Cs,nullable:Ro,number:ye,object:P,get objectUtil(){return Zt},oboolean:Fo,onumber:Mo,optional:Oo,ostring:zo,pipeline:Lo,preprocess:No,promise:Co,quotelessJson:Ds,record:bt,set:Eo,setErrorMap:qs,strictObject:xo,string:M,symbol:fo,transformer:us,tuple:So,undefined:ko,union:Ge,unknown:Dt,get util(){return z},void:yo},Symbol.toStringTag,{value:"Module"})),$e=()=>re.preprocess(n=>{if(typeof n=="boolean")return n;if(typeof n=="number")return n===1;if(typeof n=="string"){const e=n.trim().toLowerCase();if(["1","true","yes","y","on"].includes(e))return!0;if(["0","false","no","n","off"].includes(e))return!1}},re.boolean()),jo=()=>re.preprocess(n=>{if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const e=Number(n);if(Number.isFinite(e))return e}},re.number()),Rs=re.object({NODE_ENV:re.enum(["development","production","test"]).default("production"),AGENT_CONTAINER_MODE:$e().default(!1),AGENT_API_KEY:re.string().optional(),AGENT_ORGANIZATION_ID:re.string().optional(),AGENT_SESSION_ID:re.string().optional(),AGENT_SERVER_URL:re.string().optional(),AGENT_TYPE:re.string().optional(),AGENT_DEVICE_GUID:re.string().optional(),CONTEXT_DATA:re.string().optional(),AGI_NETLOG_ENABLE:$e().default(!0),AGI_NETLOG_DEBUG:$e().optional(),AGI_NETLOG_FILE:re.string().optional(),AGI_NETLOG_MAX_BODY:jo().optional(),AGI_NETLOG_REMOTE_ENABLE:$e().default(!0),AGI_NETLOG_REMOTE_FILE:re.string().optional(),DEBUG:$e().default(!1),VERBOSE:$e().default(!1),LOG_LEVEL:re.string().optional(),HOSTNAME:re.string().optional(),VITE_SAVE_RAW:$e().default(!1)});function At(n=!1){return n?"https://agiflow.io":"https://agiflow.io"}let D=Rs.parse(process.env);class te{static refresh(){D=Rs.parse(process.env)}static get isContainerMode(){return!!D.AGENT_CONTAINER_MODE}static get apiKey(){return D.AGENT_API_KEY||process.env.AGENT_API_KEY}static get organizationId(){return D.AGENT_ORGANIZATION_ID||process.env.AGENT_ORGANIZATION_ID}static get sessionId(){return D.AGENT_SESSION_ID||process.env.AGENT_SESSION_ID}static get serverUrl(){return D.AGENT_SERVER_URL||process.env.AGENT_SERVER_URL||At(this.isContainerMode)}static get isNetlogEnabled(){return!!D.AGI_NETLOG_ENABLE}static get isNetlogDebug(){return!!D.AGI_NETLOG_DEBUG}static get isNetlogRemoteEnabled(){return!!D.AGI_NETLOG_REMOTE_ENABLE}static get isDebugMode(){return D.DEBUG}static get isVerbose(){return D.VERBOSE}static get logLevel(){return D.LOG_LEVEL??(D.DEBUG?"debug":"info")}static get nodeEnv(){return D.NODE_ENV}static get homeDir(){return process.env.HOME||process.env.USERPROFILE}static get isMacOS(){return process.platform==="darwin"}static get hostname(){return D.HOSTNAME}static get netlogMaxBody(){return D.AGI_NETLOG_MAX_BODY}static get netlogFile(){return D.AGI_NETLOG_FILE}static get netlogRemoteFile(){return D.AGI_NETLOG_REMOTE_FILE}static get agentType(){return D.AGENT_TYPE||process.env.AGENT_TYPE}static get deviceGuid(){return D.AGENT_DEVICE_GUID}static get isSaveRawEnabled(){return!!D.VITE_SAVE_RAW}static get contextData(){return D.CONTEXT_DATA||process.env.CONTEXT_DATA}static serializeEnv(){const e={...process.env};for(const[t,s]of Object.entries(D))s!==void 0&&(typeof s=="string"?e[t]=s:typeof s=="number"?e[t]=String(s):typeof s=="boolean"?e[t]=s?"true":"false":e[t]=String(s));return e}static toChildProcess(){const e=this.serializeEnv();return e.AGENT_SERVER_URL||(e.AGENT_SERVER_URL=At(this.isContainerMode)),e.LOG_LEVEL||(e.LOG_LEVEL=this.logLevel),e}static toDocker(){const e=this.serializeEnv();return e.AGENT_CONTAINER_MODE="true",e.AGENT_SERVER_URL||(e.AGENT_SERVER_URL=At(!0)),e.LOG_LEVEL||(e.LOG_LEVEL=this.logLevel),e}static toPty(){const e=this.serializeEnv();return e.AGENT_SERVER_URL||(e.AGENT_SERVER_URL=At(this.isContainerMode)),e.LOG_LEVEL||(e.LOG_LEVEL=this.logLevel),e}static getEnvs(){return D}}class rt{logStream;logPath;constructor(e){this.logPath=e;const t=fe.dirname(this.logPath);ke.existsSync(t)||ke.mkdirSync(t,{recursive:!0}),this.logStream=ke.createWriteStream(this.logPath,{flags:"a"}),this.logStream.on("error",s=>{console.error(`[FileLogger] Error writing to log file: ${s.message}`)})}info(e,t){this.log(30,e,t)}debug(e,t){this.log(20,e,t)}warn(e,t){this.log(40,e,t)}error(e,t){this.log(50,e,t)}log(e,t,s){const o={time:new Date().toISOString(),level:e,msg:t,...s};try{this.logStream.write(JSON.stringify(o)+`
2
+ `)}catch(r){console.error(`[FileLogger] Failed to write log entry: ${r}`)}}close(){this.logStream&&!this.logStream.destroyed&&this.logStream.end()}getLogPath(){return this.logPath}static shouldDebug(){return te.isDebugMode||te.isNetlogDebug}}const $o={max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},Do={max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},qo={"gpt-4":{max_tokens:4096,max_input_tokens:8192,max_output_tokens:4096,input_cost_per_token:3e-5,output_cost_per_token:6e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4.1":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-2025-04-14":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-mini":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:4e-7,output_cost_per_token:16e-7,input_cost_per_token_batches:2e-7,output_cost_per_token_batches:8e-7,cache_read_input_token_cost:1e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-mini-2025-04-14":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:4e-7,output_cost_per_token:16e-7,input_cost_per_token_batches:2e-7,output_cost_per_token_batches:8e-7,cache_read_input_token_cost:1e-7,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-nano":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:1e-7,output_cost_per_token:4e-7,input_cost_per_token_batches:5e-8,output_cost_per_token_batches:2e-7,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4.1-nano-2025-04-14":{max_tokens:32768,max_input_tokens:1047576,max_output_tokens:32768,input_cost_per_token:1e-7,output_cost_per_token:4e-7,input_cost_per_token_batches:5e-8,output_cost_per_token_batches:2e-7,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"gpt-4o":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"watsonx/ibm/granite-3-8b-instruct":{max_tokens:8192,max_input_tokens:8192,max_output_tokens:1024,input_cost_per_token:2e-4,output_cost_per_token:2e-4,litellm_provider:"watsonx",mode:"chat",supports_function_calling:!0,supports_tool_choice:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_audio_input:!1,supports_audio_output:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_system_messages:!0},"watsonx/mistralai/mistral-large":{max_tokens:131072,max_input_tokens:131072,max_output_tokens:16384,input_cost_per_token:3e-6,output_cost_per_token:1e-5,litellm_provider:"watsonx",mode:"chat",supports_function_calling:!0,supports_tool_choice:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_audio_input:!1,supports_audio_output:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_system_messages:!0},"gpt-4o-search-preview-2025-03-11":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-search-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_web_search:!0,search_context_cost_per_query:{search_context_size_low:.03,search_context_size_medium:.035,search_context_size_high:.05}},"gpt-4.5-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:75e-6,output_cost_per_token:15e-5,input_cost_per_token_batches:375e-7,output_cost_per_token_batches:75e-6,cache_read_input_token_cost:375e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4.5-preview-2025-02-27":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:75e-6,output_cost_per_token:15e-5,input_cost_per_token_batches:375e-7,output_cost_per_token_batches:75e-6,cache_read_input_token_cost:375e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,deprecation_date:"2025-07-14"},"gpt-4o-audio-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:1e-4,output_cost_per_token:1e-5,output_cost_per_audio_token:2e-4,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-audio-preview-2024-12-17":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:4e-5,output_cost_per_token:1e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-audio-preview-2024-10-01":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:1e-4,output_cost_per_token:1e-5,output_cost_per_audio_token:2e-4,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-audio-preview-2025-06-03":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,input_cost_per_audio_token:4e-5,output_cost_per_token:1e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-audio-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,input_cost_per_audio_token:1e-5,output_cost_per_token:6e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-audio-preview-2024-12-17":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,input_cost_per_audio_token:1e-5,output_cost_per_token:6e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-search-preview-2025-03-11":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-search-preview":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_web_search:!0,search_context_cost_per_query:{search_context_size_low:.025,search_context_size_medium:.0275,search_context_size_high:.03}},"gpt-4o-mini-2024-07-18":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:15e-8,output_cost_per_token:6e-7,input_cost_per_token_batches:75e-9,output_cost_per_token_batches:3e-7,cache_read_input_token_cost:75e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,search_context_cost_per_query:{search_context_size_low:.025,search_context_size_medium:.0275,search_context_size_high:.03}},"gpt-5":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-mini":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:25e-8,output_cost_per_token:2e-6,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-nano":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:5e-8,output_cost_per_token:4e-7,cache_read_input_token_cost:5e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-chat":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!1,supports_parallel_function_calling:!1,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!1,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-chat-latest":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!1,supports_parallel_function_calling:!1,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!1,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-2025-08-07":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:125e-8,output_cost_per_token:1e-5,cache_read_input_token_cost:125e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-mini-2025-08-07":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:25e-8,output_cost_per_token:2e-6,cache_read_input_token_cost:25e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"gpt-5-nano-2025-08-07":{max_tokens:128e3,max_input_tokens:4e5,max_output_tokens:128e3,input_cost_per_token:5e-8,output_cost_per_token:4e-7,cache_read_input_token_cost:5e-9,litellm_provider:"openai",mode:"chat",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0,supports_reasoning:!0},"codex-mini-latest":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-7,output_cost_per_token:6e-6,cache_read_input_token_cost:375e-9,litellm_provider:"openai",mode:"responses",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supported_modalities:["text","image"],supported_output_modalities:["text"],supported_endpoints:["/v1/responses"]},"o1-pro":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-5,output_cost_per_token:6e-4,input_cost_per_token_batches:75e-6,output_cost_per_token_batches:3e-4,litellm_provider:"openai",mode:"responses",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_native_streaming:!1,supports_reasoning:!0,supported_modalities:["text","image"],supported_output_modalities:["text"],supported_endpoints:["/v1/responses","/v1/batch"]},"o1-pro-2025-03-19":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-5,output_cost_per_token:6e-4,input_cost_per_token_batches:75e-6,output_cost_per_token_batches:3e-4,litellm_provider:"openai",mode:"responses",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_native_streaming:!1,supports_reasoning:!0,supported_modalities:["text","image"],supported_output_modalities:["text"],supported_endpoints:["/v1/responses","/v1/batch"]},o1:$o,"o1-mini":{max_tokens:65536,max_input_tokens:128e3,max_output_tokens:65536,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:55e-8,litellm_provider:"openai",mode:"chat",supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0},"o3-deep-research":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:1e-5,output_cost_per_token:4e-5,input_cost_per_token_batches:5e-6,output_cost_per_token_batches:2e-5,cache_read_input_token_cost:25e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o3-deep-research-2025-06-26":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:1e-5,output_cost_per_token:4e-5,input_cost_per_token_batches:5e-6,output_cost_per_token_batches:2e-5,cache_read_input_token_cost:25e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o3-pro":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-5,input_cost_per_token_batches:1e-5,output_cost_per_token_batches:4e-5,output_cost_per_token:8e-5,litellm_provider:"openai",mode:"responses",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},"o3-pro-2025-06-10":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-5,input_cost_per_token_batches:1e-5,output_cost_per_token_batches:4e-5,output_cost_per_token:8e-5,litellm_provider:"openai",mode:"responses",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},o3:Do,"o3-2025-04-16":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0,supported_endpoints:["/v1/responses","/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image"],supported_output_modalities:["text"]},"o3-mini":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:55e-8,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o3-mini-2025-01-31":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:55e-8,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!1,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o4-mini":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:275e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o4-mini-deep-research":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o4-mini-deep-research-2025-06-26":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:2e-6,output_cost_per_token:8e-6,input_cost_per_token_batches:1e-6,output_cost_per_token_batches:4e-6,cache_read_input_token_cost:5e-7,litellm_provider:"openai",mode:"responses",supported_endpoints:["/v1/chat/completions","/v1/batch","/v1/responses"],supported_modalities:["text","image"],supported_output_modalities:["text"],supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0,supports_native_streaming:!0},"o4-mini-2025-04-16":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:11e-7,output_cost_per_token:44e-7,cache_read_input_token_cost:275e-9,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!1,supports_vision:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"o1-mini-2024-09-12":{max_tokens:65536,max_input_tokens:128e3,max_output_tokens:65536,input_cost_per_token:3e-6,output_cost_per_token:12e-6,cache_read_input_token_cost:15e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_vision:!0,supports_reasoning:!0,supports_prompt_caching:!0},"o1-preview":{max_tokens:32768,max_input_tokens:128e3,max_output_tokens:32768,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_vision:!0,supports_reasoning:!0,supports_prompt_caching:!0},"o1-preview-2024-09-12":{max_tokens:32768,max_input_tokens:128e3,max_output_tokens:32768,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_vision:!0,supports_reasoning:!0,supports_prompt_caching:!0},"o1-2024-12-17":{max_tokens:1e5,max_input_tokens:2e5,max_output_tokens:1e5,input_cost_per_token:15e-6,output_cost_per_token:6e-5,cache_read_input_token_cost:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_response_schema:!0,supports_reasoning:!0,supports_tool_choice:!0},"chatgpt-4o-latest":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,output_cost_per_token:15e-6,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-2024-05-13":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,output_cost_per_token:15e-6,input_cost_per_token_batches:25e-7,output_cost_per_token_batches:75e-7,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-2024-08-06":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-2024-11-20":{max_tokens:16384,max_input_tokens:128e3,max_output_tokens:16384,input_cost_per_token:25e-7,output_cost_per_token:1e-5,input_cost_per_token_batches:125e-8,output_cost_per_token_batches:5e-6,cache_read_input_token_cost:125e-8,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_response_schema:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-realtime":{max_tokens:4096,max_input_tokens:32e3,max_output_tokens:4096,input_cost_per_token:4e-6,cache_read_input_token_cost:4e-7,output_cost_per_token:16e-6,input_cost_per_audio_token:32e-6,output_cost_per_audio_token:64e-6,cache_creation_input_audio_token_cost:4e-7,input_cost_per_image:5e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0,supported_endpoints:["/v1/realtime"],supported_modalities:["text","image","audio"],supported_output_modalities:["text","audio"]},"gpt-realtime-2025-08-28":{max_tokens:4096,max_input_tokens:32e3,max_output_tokens:4096,input_cost_per_token:4e-6,cache_read_input_token_cost:4e-7,output_cost_per_token:16e-6,input_cost_per_audio_token:32e-6,output_cost_per_audio_token:64e-6,cache_creation_input_audio_token_cost:4e-7,input_cost_per_image:5e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0,supported_endpoints:["/v1/realtime"],supported_modalities:["text","image","audio"],supported_output_modalities:["text","audio"]},"gpt-4o-realtime-preview-2024-10-01":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:1e-4,cache_read_input_token_cost:25e-7,cache_creation_input_audio_token_cost:2e-5,output_cost_per_token:2e-5,output_cost_per_audio_token:2e-4,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-realtime-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:4e-5,cache_read_input_token_cost:25e-7,output_cost_per_token:2e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-realtime-preview-2024-12-17":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:4e-5,cache_read_input_token_cost:25e-7,output_cost_per_token:2e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-realtime-preview-2025-06-03":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:5e-6,input_cost_per_audio_token:4e-5,cache_read_input_token_cost:25e-7,output_cost_per_token:2e-5,output_cost_per_audio_token:8e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-realtime-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:6e-7,input_cost_per_audio_token:1e-5,cache_read_input_token_cost:3e-7,cache_creation_input_audio_token_cost:3e-7,output_cost_per_token:24e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-mini-realtime-preview-2024-12-17":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:6e-7,input_cost_per_audio_token:1e-5,cache_read_input_token_cost:3e-7,cache_creation_input_audio_token_cost:3e-7,output_cost_per_token:24e-7,output_cost_per_audio_token:2e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_audio_input:!0,supports_audio_output:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-turbo-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-0314":{max_tokens:4096,max_input_tokens:8192,max_output_tokens:4096,input_cost_per_token:3e-5,output_cost_per_token:6e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-0613":{max_tokens:4096,max_input_tokens:8192,max_output_tokens:4096,input_cost_per_token:3e-5,output_cost_per_token:6e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,deprecation_date:"2025-06-06",supports_tool_choice:!0},"gpt-4-32k":{max_tokens:4096,max_input_tokens:32768,max_output_tokens:4096,input_cost_per_token:6e-5,output_cost_per_token:12e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-32k-0314":{max_tokens:4096,max_input_tokens:32768,max_output_tokens:4096,input_cost_per_token:6e-5,output_cost_per_token:12e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-32k-0613":{max_tokens:4096,max_input_tokens:32768,max_output_tokens:4096,input_cost_per_token:6e-5,output_cost_per_token:12e-5,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-turbo":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-turbo-2024-04-09":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_pdf_input:!0,supports_function_calling:!0,supports_parallel_function_calling:!0,supports_vision:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-1106-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-0125-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4-vision-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_system_messages:!0,deprecation_date:"2024-12-06",supports_tool_choice:!0},"gpt-4-1106-vision-preview":{max_tokens:4096,max_input_tokens:128e3,max_output_tokens:4096,input_cost_per_token:1e-5,output_cost_per_token:3e-5,litellm_provider:"openai",mode:"chat",supports_vision:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_system_messages:!0,deprecation_date:"2024-12-06",supports_tool_choice:!0},"gpt-3.5-turbo":{max_tokens:4097,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:15e-7,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-0301":{max_tokens:4097,max_input_tokens:4097,max_output_tokens:4096,input_cost_per_token:15e-7,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-0613":{max_tokens:4097,max_input_tokens:4097,max_output_tokens:4096,input_cost_per_token:15e-7,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-1106":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:1e-6,output_cost_per_token:2e-6,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-0125":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:5e-7,output_cost_per_token:15e-7,litellm_provider:"openai",mode:"chat",supports_function_calling:!0,supports_parallel_function_calling:!0,supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-16k":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:3e-6,output_cost_per_token:4e-6,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-3.5-turbo-16k-0613":{max_tokens:16385,max_input_tokens:16385,max_output_tokens:4096,input_cost_per_token:3e-6,output_cost_per_token:4e-6,litellm_provider:"openai",mode:"chat",supports_prompt_caching:!0,supports_system_messages:!0,supports_tool_choice:!0},"gpt-4o-transcribe":{mode:"audio_transcription",max_input_tokens:16e3,max_output_tokens:2e3,input_cost_per_token:25e-7,input_cost_per_audio_token:6e-6,output_cost_per_token:1e-5,litellm_provider:"openai",supported_endpoints:["/v1/audio/transcriptions"]},"gpt-4o-mini-transcribe":{mode:"audio_transcription",max_input_tokens:16e3,max_output_tokens:2e3,input_cost_per_token:125e-8,input_cost_per_audio_token:3e-6,output_cost_per_token:5e-6,litellm_provider:"openai",supported_endpoints:["/v1/audio/transcriptions"]},"gpt-4o-mini-tts":{mode:"audio_speech",input_cost_per_token:25e-7,output_cost_per_token:1e-5,output_cost_per_audio_token:12e-6,output_cost_per_second:25e-5,litellm_provider:"openai",supported_modalities:["text","audio"],supported_output_modalities:["audio"],supported_endpoints:["/v1/audio/speech"]},"claude-3-haiku-20240307":{max_tokens:4096,max_input_tokens:2e5,max_output_tokens:4096,input_cost_per_token:25e-8,output_cost_per_token:125e-8,cache_creation_input_token_cost:3e-7,cache_read_input_token_cost:3e-8,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:264,supports_assistant_prefill:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-03-01",supports_tool_choice:!0},"claude-3-5-haiku-20241022":{max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:8e-7,output_cost_per_token:4e-6,cache_creation_input_token_cost:1e-6,cache_read_input_token_cost:8e-8,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:264,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-10-01",supports_tool_choice:!0,supports_web_search:!0},"claude-3-5-haiku-latest":{max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:1e-6,output_cost_per_token:5e-6,cache_creation_input_token_cost:125e-8,cache_read_input_token_cost:1e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:264,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-10-01",supports_tool_choice:!0,supports_web_search:!0},"claude-3-opus-latest":{max_tokens:4096,max_input_tokens:2e5,max_output_tokens:4096,input_cost_per_token:15e-6,output_cost_per_token:75e-6,cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:395,supports_assistant_prefill:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-03-01",supports_tool_choice:!0},"claude-3-opus-20240229":{max_tokens:4096,max_input_tokens:2e5,max_output_tokens:4096,input_cost_per_token:15e-6,output_cost_per_token:75e-6,cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:395,supports_assistant_prefill:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-03-01",supports_tool_choice:!0},"claude-3-5-sonnet-latest":{supports_computer_use:!0,max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-06-01",supports_tool_choice:!0,supports_web_search:!0},"claude-3-5-sonnet-20240620":{max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-06-01",supports_tool_choice:!0},"claude-opus-4-20250514":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-opus-4-1":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-opus-4-1-20250805":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-sonnet-4-5-20250929":{max_tokens:64e3,max_input_tokens:2e5,max_output_tokens:64e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-sonnet-4-20250514":{max_tokens:64e3,max_input_tokens:2e5,max_output_tokens:64e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-4-opus-20250514":{max_tokens:32e3,max_input_tokens:2e5,max_output_tokens:32e3,input_cost_per_token:15e-6,output_cost_per_token:75e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:1875e-8,cache_read_input_token_cost:15e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-4-sonnet-20250514":{max_tokens:1e6,max_input_tokens:1e6,max_output_tokens:1e6,input_cost_per_token:3e-6,output_cost_per_token:15e-6,input_cost_per_token_above_200k_tokens:6e-6,output_cost_per_token_above_200k_tokens:225e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,cache_creation_input_token_cost_above_200k_tokens:75e-7,cache_read_input_token_cost_above_200k_tokens:6e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supports_computer_use:!0},"claude-3-7-sonnet-latest":{supports_computer_use:!0,max_tokens:128e3,max_input_tokens:2e5,max_output_tokens:128e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-06-01",supports_tool_choice:!0,supports_reasoning:!0},"claude-3-7-sonnet-20250219":{supports_computer_use:!0,max_tokens:128e3,max_input_tokens:2e5,max_output_tokens:128e3,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2026-02-01",supports_tool_choice:!0,supports_reasoning:!0,supports_web_search:!0},"claude-3-5-sonnet-20241022":{supports_computer_use:!0,max_tokens:8192,max_input_tokens:2e5,max_output_tokens:8192,input_cost_per_token:3e-6,output_cost_per_token:15e-6,cache_creation_input_token_cost:375e-8,cache_read_input_token_cost:3e-7,search_context_cost_per_query:{search_context_size_low:.01,search_context_size_medium:.01,search_context_size_high:.01},litellm_provider:"anthropic",mode:"chat",supports_function_calling:!0,supports_vision:!0,tool_use_system_prompt_tokens:159,supports_assistant_prefill:!0,supports_pdf_input:!0,supports_prompt_caching:!0,supports_response_schema:!0,deprecation_date:"2025-10-01",supports_tool_choice:!0,supports_web_search:!0},"gemini-2.5-pro-exp-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.0-pro-exp-02-05":{max_tokens:8192,max_input_tokens:2097152,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.0-flash-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:15e-8,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:6e-7,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini-2.0-flash-001":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",deprecation_date:"2026-02-05",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini-2.0-flash-thinking-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini-2.0-flash-thinking-exp-01-21":{max_tokens:65536,max_input_tokens:1048576,max_output_tokens:65536,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!1,supports_vision:!0,supports_response_schema:!1,supports_audio_output:!1,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini-2.5-pro":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-exp-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:0,input_cost_per_token_above_200k_tokens:0,output_cost_per_token:0,output_cost_per_token_above_200k_tokens:0,litellm_provider:"gemini",mode:"chat",rpm:5,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.5-pro":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:2e3,tpm:8e5,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,supports_reasoning:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-flash":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"gemini",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,tpm:8e6,rpm:1e5,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-image-preview":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,output_cost_per_image:.039,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,tpm:8e6,rpm:1e5,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini-2.5-flash":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-live-001":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_token:35e-8,input_cost_per_audio_token:21e-7,input_cost_per_image:21e-7,input_cost_per_video_per_second:21e-7,output_cost_per_token:15e-7,output_cost_per_audio_token:85e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!0,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","audio"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2-0-flash-live-001",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-preview-tts":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,output_cost_per_reasoning_token:35e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text"],supported_output_modalities:["audio"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_web_search:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-preview-05-20":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-preview-04-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,output_cost_per_reasoning_token:35e-7,litellm_provider:"gemini",mode:"chat",rpm:10,tpm:25e4,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_reasoning:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-lite-preview-06-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:15,tpm:25e4,supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-flash-lite":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:15,tpm:25e4,supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-lite",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.5-flash-image-preview":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,output_cost_per_image:.039,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,tpm:8e6,rpm:1e5,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini-2.5-flash-preview-05-20":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:3e-7,output_cost_per_token:25e-7,output_cost_per_reasoning_token:25e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:75e-9,supports_prompt_caching:!0},"gemini-2.5-flash-preview-04-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:1e-6,input_cost_per_token:15e-8,output_cost_per_token:6e-7,output_cost_per_reasoning_token:35e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:375e-10,supports_prompt_caching:!0},"gemini-2.5-flash-lite-preview-06-17":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.5-flash-lite":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:5e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,output_cost_per_reasoning_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.0-flash":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_parallel_function_calling:!0,supports_web_search:!0,supports_url_context:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.0-flash-lite":{max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:50,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini-2.0-flash-lite-001":{max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:50,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,deprecation_date:"2026-02-25",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini-2.5-pro-preview-06-05":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:125e-8,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.5-pro-preview-05-06":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:125e-8,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],supported_regions:["global"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.5-pro-preview-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:125e-8,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_reasoning:!0,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_endpoints:["/v1/chat/completions","/v1/completions","/v1/batch"],supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview",supports_parallel_function_calling:!0,supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini-2.0-flash-preview-image-generation":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini-2.5-pro-preview-tts":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"vertex_ai-language-models",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text"],supported_output_modalities:["audio"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_parallel_function_calling:!0,supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.0-pro-exp-02-05":{max_tokens:8192,max_input_tokens:2097152,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",rpm:2,tpm:1e6,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_audio_input:!0,supports_video_input:!0,supports_pdf_input:!0,supports_response_schema:!0,supports_tool_choice:!0,source:"https://cloud.google.com/vertex-ai/generative-ai/pricing",supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-preview-image-generation":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_web_search:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.0-flash":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_audio_input:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],supports_tool_choice:!0,source:"https://ai.google.dev/pricing#2_0flash",supports_web_search:!0,supports_url_context:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-lite":{max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:50,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"gemini",mode:"chat",tpm:4e6,rpm:4e3,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.0-flash-lite",supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-001":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:1e-7,output_cost_per_token:4e-7,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://ai.google.dev/pricing#2_0flash",supports_web_search:!0,cache_read_input_token_cost:25e-9,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-tts":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text"],supported_output_modalities:["audio"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-06-05":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-05-06":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,supports_url_context:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.5-pro-preview-03-25":{max_tokens:65535,max_input_tokens:1048576,max_output_tokens:65535,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:7e-7,input_cost_per_token:125e-8,input_cost_per_token_above_200k_tokens:25e-7,output_cost_per_token:1e-5,output_cost_per_token_above_200k_tokens:15e-6,litellm_provider:"gemini",mode:"chat",rpm:1e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://ai.google.dev/gemini-api/docs/pricing#gemini-2.5-pro-preview",supports_web_search:!0,supports_pdf_input:!0,cache_read_input_token_cost:3125e-10,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,tpm:4e6,rpm:10,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-lite-preview-02-05":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:8192,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_audio_token:75e-9,input_cost_per_token:75e-9,output_cost_per_token:3e-7,litellm_provider:"gemini",mode:"chat",rpm:6e4,tpm:1e7,supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,supports_tool_choice:!0,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash-lite",supports_web_search:!0,cache_read_input_token_cost:1875e-11,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-thinking-exp":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:65536,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,tpm:4e6,rpm:10,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemini-2.0-flash-thinking-exp-01-21":{max_tokens:8192,max_input_tokens:1048576,max_output_tokens:65536,max_images_per_prompt:3e3,max_videos_per_prompt:10,max_video_length:1,max_audio_length_hours:8.4,max_audio_per_prompt:1,max_pdf_size_mb:30,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!0,tpm:4e6,rpm:10,supported_modalities:["text","image","audio","video"],supported_output_modalities:["text","image"],source:"https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-2.0-flash",supports_tool_choice:!0,supports_web_search:!0,cache_read_input_token_cost:0,supports_prompt_caching:!0},"gemini/gemma-3-27b-it":{max_tokens:8192,max_input_tokens:131072,max_output_tokens:8192,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,source:"https://aistudio.google.com",supports_tool_choice:!0},"gemini/learnlm-1.5-pro-experimental":{max_tokens:8192,max_input_tokens:32767,max_output_tokens:8192,input_cost_per_image:0,input_cost_per_video_per_second:0,input_cost_per_audio_per_second:0,input_cost_per_token:0,input_cost_per_character:0,input_cost_per_token_above_128k_tokens:0,input_cost_per_character_above_128k_tokens:0,input_cost_per_image_above_128k_tokens:0,input_cost_per_video_per_second_above_128k_tokens:0,input_cost_per_audio_per_second_above_128k_tokens:0,output_cost_per_token:0,output_cost_per_character:0,output_cost_per_token_above_128k_tokens:0,output_cost_per_character_above_128k_tokens:0,litellm_provider:"gemini",mode:"chat",supports_system_messages:!0,supports_function_calling:!0,supports_vision:!0,supports_response_schema:!0,supports_audio_output:!1,source:"https://aistudio.google.com",supports_tool_choice:!0},"gemini/veo-3.0-generate-preview":{max_tokens:1024,max_input_tokens:1024,output_cost_per_second:.75,litellm_provider:"gemini",mode:"video_generation",supported_modalities:["text"],supported_output_modalities:["video"],source:"https://ai.google.dev/gemini-api/docs/video"},"gemini/veo-3.0-fast-generate-preview":{max_tokens:1024,max_input_tokens:1024,output_cost_per_second:.4,litellm_provider:"gemini",mode:"video_generation",supported_modalities:["text"],supported_output_modalities:["video"],source:"https://ai.google.dev/gemini-api/docs/video"},"gemini/veo-2.0-generate-001":{max_tokens:1024,max_input_tokens:1024,output_cost_per_second:.35,litellm_provider:"gemini",mode:"video_generation",supported_modalities:["text"],supported_output_modalities:["video"],source:"https://ai.google.dev/gemini-api/docs/video"}};class Bo{static calculateCost(e,t){const s=qo[e];if(!s)return null;const o=t.inputTokens||0,r=t.outputTokens||0,i=t.cachedInputTokens||0,a=t.cacheCreationInputTokens||0,p="input_cost_per_token"in s?s.input_cost_per_token:0,u="output_cost_per_token"in s?s.output_cost_per_token:0,c="cache_read_input_token_cost"in s?s.cache_read_input_token_cost:0,g="cache_creation_input_token_cost"in s?s.cache_creation_input_token_cost:0,v=o*p,d=r*u,m=i*c,h=a*g;return{totalCost:v+d+m+h,inputCost:v,outputCost:d,cacheReadCost:i>0?m:void 0,cacheCreationCost:a>0?h:void 0}}}class Bt{static parseStreamingResponse(e){try{const t=e.split(`
3
+ `),s=[];let o=null,r=null;const i=new Map;for(const m of t)if(m.startsWith("data: ")){const h=m.substring(6).trim();if(h)try{const w=JSON.parse(h);if(w.type==="message_start"&&w.message&&(o=w.message),w.type==="content_block_start"){const L={index:w.index,type:w.content_block.type,id:w.content_block.id,name:w.content_block.name,input:w.content_block.input||{},text:"",partialJson:""};i.set(w.index,L)}if(w.type==="content_block_delta"){const L=i.get(w.index);L&&(w.delta.type==="text_delta"?L.text+=w.delta.text:w.delta.type==="input_json_delta"&&(L.partialJson+=w.delta.partial_json))}if(w.type==="content_block_stop"){const L=i.get(w.index);if(L){if(L.partialJson)try{L.input=JSON.parse(L.partialJson)}catch{}s.push(L)}}w.type==="message_delta"&&w.usage&&(r=w.usage)}catch{}}const a=(s||[]).map(m=>m.type==="text"?{type:"text",text:m.text}:m.type==="tool_use"?{type:"tool-invocation",toolInvocation:{toolCallId:m.id,toolName:m.name,args:m.input,state:"call"}}:{type:"text",text:`Unknown content block type: ${m.type}`}),p={id:o?.id||Bt.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:a.length>0?a:[{type:"text",text:""}]},u={...o?.usage||{},...r||{}},c={inputTokens:u.input_tokens||u.inputTokens,outputTokens:u.output_tokens||u.outputTokens,cachedInputTokens:u.cache_read_input_tokens||u.cachedInputTokens,cacheCreationInputTokens:u.cache_creation_input_tokens||u.cacheCreationInputTokens,totalTokens:(u.input_tokens||0)+(u.output_tokens||0),cacheCreation:u.cache_creation,serviceTier:u.service_tier},g=o?.model,v=g?Bo.calculateCost(g,c):null;return{message:p,metadata:{model:g,usage:c,cost:v,originalMessageId:o?.id,stopReason:o?.stop_reason,contentLength:a.reduce((m,h)=>h.type==="text"?m+h.text.length:h.type==="tool-invocation"?m+JSON.stringify(h.toolInvocation.args||"").length:m+JSON.stringify(h).length,0),streamingEvents:t.filter(m=>m.startsWith("event:")).length}}}catch(t){return{error:`Failed to parse streaming response: ${t}`,rawText:e}}}static generateId(){return Date.now().toString(36)+Math.random().toString(36).slice(2,10)}}Bt.parseStreamingResponse;new Proxy({},{get(n,e){throw new Error(`Module "node:zlib" has been externalized for browser compatibility. Cannot access "node:zlib.${e}" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}});class Ns{static parseStreamingResponse(e){try{return e.includes(`
4
+ data:`)||e.startsWith("data:")?this.parseSse(e):this.parseRegular(e)}catch(t){return{error:`Failed to parse Gemini response: ${t}`,rawText:e}}}static parseRegular(e){const t=this.isProbablyGzip(e)||this.hasHighControlCharRatio(e);let s=e;if(t){const o=this.tryGunzip(e);o.ok&&(s=o.text)}try{const o=JSON.parse(s),r=o.response||o,{fullText:i,finishReason:a,texts:p,nextSpeakers:u,reasoningSegments:c}=this.extractCandidateText(r.candidates),g=this.normalizeUsage(r.usageMetadata||o.usageMetadata||o),v=p.length>0?p.map(d=>({type:"text",text:d})):i?[{type:"text",text:i}]:[];return{message:{id:r.responseId||this.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:v},metadata:{model:r.modelVersion||o.modelVersion,usage:g,responseId:r.responseId,finishReason:a,contentLength:i.length,streamingEvents:0,compressed:t||void 0,nextSpeakers:u.length?u:void 0,reasoningSegments:c.length?c:void 0}}}catch{return{message:{id:this.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:[{type:"text",text:s}]},metadata:{raw:!0}}}}static parseSse(e){const t=e.split(/\r?\n/);let s,o,r,i;const a=[],p=[],u=[];for(const v of t){if(!v.startsWith("data:"))continue;const d=v.slice(5).trim();if(d)try{const h=JSON.parse(d).response||{};h.modelVersion&&(s=h.modelVersion),h.responseId&&(o=h.responseId),h.usageMetadata&&(i=h.usageMetadata);const w=this.extractCandidateText(h.candidates);!r&&w.finishReason&&(r=w.finishReason),w.texts.length&&a.push(...w.texts),w.nextSpeakers.length&&p.push(...w.nextSpeakers),w.reasoningSegments.length&&u.push(...w.reasoningSegments)}catch{}}const c=a.join(""),g=this.normalizeUsage(i);return{message:{id:o||this.generateId(),role:"assistant",createdAt:new Date().toISOString(),parts:a.length?a.map(v=>({type:"text",text:v})):[]},metadata:{model:s,usage:g,responseId:o,finishReason:r,contentLength:c.length,streamingEvents:t.filter(v=>v.startsWith("data:")).length,nextSpeakers:p.length?p:void 0,reasoningSegments:u.length?u:void 0}}}static extractCandidateText(e){const t=[],s=[],o=[];let r;if(Array.isArray(e))for(const i of e){!r&&i?.finishReason&&(r=i.finishReason);const a=i?.content?.parts||[];if(Array.isArray(a)){for(const p of a)if(p&&typeof p=="object"){if(p.thought===!0)continue;const u=p.text;if(typeof u=="string"&&u.length){const c=u.trim();if(c.startsWith("{")&&c.endsWith("}"))try{const g=JSON.parse(c);if(g&&typeof g=="object"){typeof g.reasoning=="string"&&(o.push(g.reasoning),t.push(g.reasoning)),g.next_speaker&&typeof g.next_speaker=="string"&&s.push(g.next_speaker);continue}}catch{}t.push(u)}}}}return{fullText:t.join(""),finishReason:r,texts:t,finishReasonFound:r,nextSpeakers:s,reasoningSegments:o}}static tryGunzip(e){try{return{ok:!0,text:(void 0)(Buffer.from(e,"latin1")).toString("utf8")}}catch{return{ok:!1,text:e}}}static hasHighControlCharRatio(e){if(!e)return!1;let t=0;const s=Math.min(e.length,256);for(let o=0;o<s;o++){const r=e.charCodeAt(o);r<32&&r!==9&&r!==10&&r!==13&&t++}return t/s>.1}static isProbablyGzip(e){return e.length>=2&&e.charCodeAt(0)===31&&e.charCodeAt(1)===139}static normalizeUsage(e){if(!e||typeof e!="object")return{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};const t=e.promptTokenCount??e.prompt_tokens,s=e.candidatesTokenCount??e.candidates_tokens,o=e.totalTokenCount??(typeof t=="number"&&typeof s=="number"?t+s:void 0);return{inputTokens:t,outputTokens:s,totalTokens:o}}static generateId(){return Date.now().toString(36)+Math.random().toString(36).slice(2,10)}}Ns.parseStreamingResponse;class le{static parsers=[{name:"Claude (Anthropic)",patterns:[/\/publishers\/anthropic\/models/i,/anthropic\.com/i,/claude\.ai/i,/\/v1\/messages/i],parser:Bt},{name:"Google Gemini",patterns:[/generativelanguage\.googleapis\.com/i,/cloudcode-pa\.googleapis\.com/i,/streamGenerateContent/i,/generateContent/i],parser:Ns}];static parseStreamingResponse(e,t){const s=le.getParserForUrl(e);if(!s)return{error:`No parser found for URL: ${e}`,rawText:t,supportedProviders:le.parsers.map(o=>o.name)};try{const o=s.parseStreamingResponse(t);return o&&typeof o=="object"&&!o.error&&(o.metadata={...o.metadata,parser:le.getParserNameForUrl(e)}),o}catch(o){return{error:`Parser failed: ${o}`,rawText:t,parser:le.getParserNameForUrl(e)}}}static getParserForUrl(e){if(!e)return null;for(const t of le.parsers)if(t.patterns.some(s=>s.test(e)))return t.parser;return null}static getParserNameForUrl(e){if(!e)return"unknown";for(const t of le.parsers)if(t.patterns.some(s=>s.test(e)))return t.name;return"unknown"}static isSupported(e){return le.getParserForUrl(e)!==null}static getSupportedProviders(){return le.parsers.map(e=>e.name)}static registerParser(e,t,s){le.parsers.push({name:e,patterns:t,parser:s})}}class Ls{LLM_PATTERNS=[/anthropic\.com/i,/claude\.ai/i,/openai\.com/i,/api\.openai\.com/i,/chatgpt\.com\/backend-api\/codex/i,/gemini\.google/i,/generativelanguage\.googleapis/i,/cloudcode-pa\.googleapis\.com/i,/bedrock.*\.amazonaws/i,/cognitive\.microsoft/i,/azure\.openai/i,/cohere\.ai/i,/huggingface\.co/i,/replicate\.com/i,/together\.xyz/i,/mistral\.ai/i,/groq\.com/i,/perplexity\.ai/i,/ollama/i,/localhost:\d+\/v1/i,/127\.0\.0\.1:\d+\/v1/i,/\/v1\/chat\/completions/i,/\/v1\/completions/i,/\/v1\/embeddings/i,/\/v1\/messages/i,/\/publishers\/anthropic\/models/i];PROVIDER_MAP=[{pattern:/\/publishers\/anthropic\/models/i,provider:"anthropic"},{pattern:/anthropic\.com|claude\.ai/i,provider:"anthropic"},{pattern:/chatgpt\.com\/backend-api\/codex/i,provider:"openai"},{pattern:/openai\.com/i,provider:"openai"},{pattern:/gemini\.google|generativelanguage\.googleapis|cloudcode-pa\.googleapis/i,provider:"google"},{pattern:/bedrock.*\.amazonaws/i,provider:"aws-bedrock"},{pattern:/cognitive\.microsoft|azure\.openai/i,provider:"azure"},{pattern:/cohere\.ai/i,provider:"cohere"},{pattern:/huggingface\.co/i,provider:"huggingface"},{pattern:/replicate\.com/i,provider:"replicate"},{pattern:/together\.xyz/i,provider:"together"},{pattern:/mistral\.ai/i,provider:"mistral"},{pattern:/groq\.com/i,provider:"groq"},{pattern:/perplexity\.ai/i,provider:"perplexity"},{pattern:/ollama|localhost:\d+\/v1|127\.0\.0\.1:\d+\/v1/i,provider:"local"}];isLLMCall(e){return e?this.LLM_PATTERNS.some(t=>t.test(e)):!1}detectProvider(e){if(!e)return"unknown";for(const{pattern:t,provider:s}of this.PROVIDER_MAP)if(t.test(e))return s;return"unknown"}getSupportedProviders(){return Array.from(new Set(this.PROVIDER_MAP.map(({provider:e})=>e)))}isProviderSupported(e){return this.getSupportedProviders().includes(e.toLowerCase())}getProviderPattern(e){const t=this.PROVIDER_MAP.find(({provider:s})=>s===e.toLowerCase());return t?t.pattern:null}}class Uo{static enhanceRequest(e){const t=te.contextData;if(!t)return e;try{const s=JSON.parse(e);s.system?typeof s.system=="string"?s.system=[{type:"text",text:s.system}]:Array.isArray(s.system)||(s.system=[s.system]):s.system=[];const o={type:"text",text:`# Task Context
5
+
6
+ ${t}`};return s.system.length>0?s.system.splice(1,0,o):s.system.push(o),JSON.stringify(s)}catch(s){return console.error("Failed to enhance Claude request:",s),e}}}class Ho{static enhanceRequest(e){const t=te.contextData;if(!t)return e;try{const s=JSON.parse(e),o=`# Task Context
7
+
8
+ ${t}`;return s.systemInstruction?typeof s.systemInstruction=="string"?s.systemInstruction={parts:[{text:o},{text:s.systemInstruction}]}:s.systemInstruction.parts&&s.systemInstruction.parts.unshift({text:o}):s.systemInstruction={parts:[{text:o}]},JSON.stringify(s)}catch(s){return console.error("Failed to enhance Gemini request:",s),e}}}class Re{static enhancers=[{name:"Claude (Anthropic)",patterns:[/\/publishers\/anthropic\/models/i,/anthropic\.com/i,/claude\.ai/i,/\/v1\/messages/i],enhancer:Uo},{name:"Google Gemini",patterns:[/generativelanguage\.googleapis\.com/i,/cloudcode-pa\.googleapis\.com/i,/streamGenerateContent/i,/generateContent/i],enhancer:Ho}];static enhanceRequest(e,t){const s=Re.getEnhancerForUrl(e);if(!s)return t;try{return s.enhanceRequest(t)}catch(o){return console.error(`Enhancer failed for ${e}:`,o),t}}static getEnhancerForUrl(e){if(!e)return null;for(const t of Re.enhancers)if(t.patterns.some(s=>s.test(e)))return t.enhancer;return null}static getEnhancerNameForUrl(e){if(!e)return"unknown";for(const t of Re.enhancers)if(t.patterns.some(s=>s.test(e)))return t.name;return"unknown"}static isSupported(e){return Re.getEnhancerForUrl(e)!==null}static getSupportedProviders(){return Re.enhancers.map(e=>e.name)}static registerEnhancer(e,t,s){Re.enhancers.push({name:e,patterns:t,enhancer:s})}}class nt{constructor(e,t){this.ctx=e,this.extra=t}originalFetch=null;static MAX_LOG_BYTES=256*1024;patch(){if(typeof globalThis.fetch!="function"||this.originalFetch)return;this.originalFetch=globalThis.fetch.bind(globalThis);const e=this.ctx,t=this.extra;globalThis.fetch=async(s,o)=>{const r=Ee.performance.now();let i=s,a=o,p=this.safeGetUrl(i);const u=p,c=(a?.method||typeof i=="object"&&i?.method||"GET").toString().toUpperCase();let g=this.extractHeaders(a?.headers??i?.headers);const v=this.stringifyRequestBody(a?.body??i?.body);let d=v;if(e.llmProvider.isLLMCall(p)&&v&&v!=="<request body error>")try{d=Re.enhanceRequest(p,v),d!==v&&(a?a.body=d:typeof i=="object"&&i?a={body:d}:a={body:d})}catch{}const m=await this.applyRouting({resource:i,init:a,url:p,enhancedBody:d,requestHeaders:g});i=m.resource,a=m.init,p=m.url,d=m.enhancedBody,g=m.requestHeaders;const h=m.wasRouted,w=e.idGenerator(),L=new Date().toISOString();if(t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(p,c,v)){const j={id:w,time:L,transport:"fetch",method:c,url:p,requestBody:v,requestHeaders:g,durationMs:0};t.sendHttpStart(j).catch(F=>{e.logger&&e.logger.error("Failed to send HTTP start",F)})}let C;try{C=await this.originalFetch(i,a)}catch(j){const F=Ee.performance.now()-r,H={id:w,time:L,transport:"fetch",method:c,url:p,requestBody:v,requestHeaders:g,durationMs:Math.round(F),error:j.message};throw e.handleLogEntry(H),t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(p,c,v)&&t.sendHttpUpdate(H).catch(()=>{}),j}let J={};try{const j=Ee.performance.now()-r;J=this.extractHeaders(C.headers);const F=await this.captureResponse({res:C,method:c,url:p,originalUrl:u,requestBody:v,requestHeaders:g,responseHeaders:J,wasRouted:h,entryId:w,entryTime:L,start:r});C=F.response;let H=F.responseBody,I=F.processedBody;const G=F.bodyBytes,se=F.isEventStream;if(F.capturePromise&&(C.__capturePromise=F.capturePromise),!se&&h&&e.router&&H&&H!=="<response body error>")try{H=e.router.transformResponse(H)}catch{}if(!se){const Q=h?u:p;if(e.llmProvider.isLLMCall(Q)&&H&&H!=="<response body error>")try{I=e.responseProcessor(Q,H)}catch(V){I={error:`parser_failed: ${V instanceof Error?V.message:String(V)}`}}}const $={id:w,time:L,transport:"fetch",method:c,url:p,requestBody:v,requestHeaders:g,status:C.status,ok:C.ok,durationMs:Math.round(j),responseBody:H,responseHeaders:J,processedBody:I,bodyBytes:G};return e.handleLogEntry($),!se&&t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(p,c,v)&&t.sendHttpUpdate($).catch(()=>{}),C}catch(j){const F=Ee.performance.now()-r,H={id:w,time:L,transport:"fetch",method:c,url:p,requestBody:v,requestHeaders:g,durationMs:Math.round(F),error:j.message};return e.handleLogEntry(H),t.agentHttpService&&t.sessionId&&t.isValidMessageRequest(p,c,v)&&t.sendHttpUpdate(H).catch(()=>{}),C}}}restore(){this.originalFetch&&(globalThis.fetch=this.originalFetch,this.originalFetch=null)}safeGetUrl(e){try{if(typeof e=="string")return e;if(e?.url)return e.url}catch{}return""}extractHeaders(e){const t={};if(!e)return t;try{if(e instanceof Headers)e.forEach((s,o)=>{t[o]=s});else if(Array.isArray(e))for(const[s,o]of e)t[s]=o;else if(typeof e=="object")for(const[s,o]of Object.entries(e))t[s]=Array.isArray(o)?o.join(", "):String(o)}catch{return{}}return t}stringifyRequestBody(e){try{if(!e)return"";if(typeof e=="string")return e;if(e instanceof URLSearchParams)return e.toString();if(typeof FormData<"u"&&e instanceof FormData){const t={};for(const[s,o]of e.entries())t[s]=typeof o=="string"?o:"[File|Blob]";return JSON.stringify(t)}return e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="object"?JSON.stringify(e):""}catch{return"<request body error>"}}async applyRouting(e){const t=this.ctx;let{resource:s,init:o,url:r,enhancedBody:i,requestHeaders:a}=e,p=!1;if(!t.router)return{resource:s,init:o,url:r,enhancedBody:i,requestHeaders:a,wasRouted:p};let u=!1;try{u=t.router.shouldRoute(r,i)}catch(c){t.logger&&t.logger.error("[FetchInstrument] shouldRoute() failed",c)}if(!u){if(t.llmProvider.isLLMCall(r)&&i){const c=t.router.cleanRequestForPassthrough(i);c!==i&&(i=c,typeof s=="object"&&s&&(s=new Request(r,{...s,body:i})),o&&(o.body=i))}return{resource:s,init:o,url:r,enhancedBody:i,requestHeaders:a,wasRouted:p}}try{const c=await t.router.transformRequest(r,i);r=c.url,i=c.body,p=!0,typeof s=="string"?s=c.url:typeof s=="object"&&s&&(s=new Request(c.url,s)),o||(o={}),o.body=c.body,c.headers&&(this.mergeHeadersIntoInit(o,c.headers),a={...a,...c.headers})}catch(c){p=!1,t.logger&&t.logger.error("[FetchInstrument] Failed to route LLM request",c)}return{resource:s,init:o,url:r,enhancedBody:i,requestHeaders:a,wasRouted:p}}mergeHeadersIntoInit(e,t){if(!(!t||Object.keys(t).length===0)){if(!e.headers){e.headers={...t};return}if(e.headers instanceof Headers){const s=e.headers;Object.entries(t).forEach(([o,r])=>s.set(o,r));return}if(Array.isArray(e.headers)){const s=e.headers;Object.entries(t).forEach(([o,r])=>{s.push([o,r])});return}e.headers={...e.headers,...t}}}async captureResponse(e){const{res:t,requestHeaders:s}=e,o=this.ctx,r=this.extra,i=t.headers.get("content-type")||"",a=s.accept||"",p=/text\/event-stream/i.test(i)||/text\/event-stream/i.test(a),u=/^(text\/|application\/(json|xml|javascript))/i.test(i)||/(json|xml|html)/i.test(i);if(!p){let m="",h=0;try{const L=await t.clone().arrayBuffer();if(h=L.byteLength,u)if(L.byteLength<=nt.MAX_LOG_BYTES)m=Buffer.from(L).toString("utf8");else{const C=Buffer.from(L.slice(0,nt.MAX_LOG_BYTES)),J=L.byteLength-nt.MAX_LOG_BYTES;m=`${C.toString("utf8")}
9
+ ...[truncated ${J.toLocaleString()} bytes]`}else m=`<${h} bytes binary>`}catch{m="<response body error>"}return{response:t,responseBody:m,processedBody:null,bodyBytes:h,isEventStream:!1}}if(!t.body)return{response:t,responseBody:"<streaming response not buffered>",processedBody:null,bodyBytes:0,isEventStream:!0};if(e.wasRouted&&o.router){const m=t.body.getReader(),h=[];let w=0;for(;;){const{done:I,value:G}=await m.read();if(I)break;h.push(G),w+=G.byteLength}let C=Buffer.concat(h.map(I=>Buffer.from(I))).toString("utf8"),J=null;try{C=o.router.transformResponse(C)}catch{}if(o.llmProvider.isLLMCall(e.originalUrl)&&C)try{J=o.responseProcessor(e.originalUrl,C)}catch(I){J={error:`parser_failed: ${I instanceof Error?I.message:String(I)}`}}const j={id:e.entryId,time:e.entryTime,transport:"fetch",method:e.method,url:e.url,requestBody:e.requestBody,requestHeaders:e.requestHeaders,status:t.status,ok:t.ok,durationMs:Math.round(Ee.performance.now()-e.start),responseBody:C,responseHeaders:e.responseHeaders,processedBody:J,bodyBytes:w};o.handleLogEntry(j),r.agentHttpService&&r.sessionId&&r.isValidMessageRequest(e.url,e.method,e.requestBody)&&r.sendHttpUpdate(j).catch(()=>{});const F=new ReadableStream({start(I){const G=new TextEncoder;I.enqueue(G.encode(C)),I.close()}});return{response:new Response(F,{status:t.status,statusText:t.statusText,headers:t.headers}),responseBody:C,processedBody:J,bodyBytes:w,isEventStream:!0}}const[c,g]=t.body.tee(),v=(async()=>{try{const m=c.getReader(),h=[];let w=0;for(;;){const{done:F,value:H}=await m.read();if(F)break;h.push(H),w+=H.byteLength}const C=Buffer.concat(h.map(F=>Buffer.from(F))).toString("utf8");let J=null;if(o.llmProvider.isLLMCall(e.url)&&C)try{J=o.responseProcessor(e.url,C)}catch(F){J={error:`parser_failed: ${F instanceof Error?F.message:String(F)}`}}const j={id:e.entryId,time:e.entryTime,transport:"fetch",method:e.method,url:e.url,requestBody:e.requestBody,requestHeaders:e.requestHeaders,status:t.status,ok:t.ok,durationMs:Math.round(Ee.performance.now()-e.start),responseBody:C,responseHeaders:e.responseHeaders,processedBody:J,bodyBytes:w};return o.handleLogEntry(j),r.agentHttpService&&r.sessionId&&r.isValidMessageRequest(e.url,e.method,e.requestBody)&&r.sendHttpUpdate(j).catch(()=>{}),{responseBody:C,processedBody:J,bodyBytes:w}}catch{return{responseBody:"<stream capture error>",processedBody:null,bodyBytes:0}}})();return{response:new Response(g,{status:t.status,statusText:t.statusText,headers:t.headers}),responseBody:"<streaming in progress>",processedBody:null,bodyBytes:0,isEventStream:!0,capturePromise:v}}}class Go{constructor(e,t,s={isValidMessageRequest:()=>!1,sendHttpStart:async()=>{},sendHttpUpdate:async()=>{}}){this.ctx=e,this.enableHttps=t,this._extra=s}originals=null;patch(){try{let e=function(a,p){try{if(typeof a=="string")return a;if(a instanceof URL)return a.toString();const u=a.protocol||p,c=a.hostname||a.host||"localhost",g=a.port?`:${a.port}`:"",v=a.path||a.pathname||"/";return`${u}//${c}${g}${v}`}catch{return""}},t=function(a,p){return function(c,g){const v=e(c,p),d=(typeof c=="object"&&c.method?c.method:"GET").toUpperCase(),m=Ee.performance.now(),h=r.ctx.idGenerator(),w=new Date().toISOString(),L=[];let C=0,J=!1;const j=a(c,I=>{const G=[];let se=0,$=0;const Q=()=>String(I.headers["content-type"]||"");I.on("data",V=>{se+=V.length;const ae=Q();if(/text\/event-stream/i.test(ae))G.push(V),$+=V.length;else{if($>=i)return;const _=i-$;V.length<=_?(G.push(V),$+=V.length):(G.push(V.subarray(0,_)),$+=_)}}),I.on("end",()=>{const V=Ee.performance.now()-m;let ae="";try{const x=Q(),R=/text\/event-stream/i.test(x),N=Buffer.concat(G),W=se>N.length||N.length===i;let Y=N;if(!R){const ee=String(I.headers["content-encoding"]||"").toLowerCase();if(!W&&Y.length&&/(gzip|br|deflate)/.test(ee))try{const Z=require("node:zlib");ee.includes("gzip")?Y=Z.gunzipSync(N):ee.includes("br")?Y=Z.brotliDecompressSync(N):ee.includes("deflate")&&(Y=Z.inflateSync(N))}catch{}}/text\//i.test(x)||/application\/(json|xml|javascript)/i.test(x)||R?(ae=Y.toString("utf8"),W&&!R&&(ae+=`
10
+ ...[truncated]`)):Y.length&&(ae=`<${Y.length} bytes${W?" (truncated)":""} binary>`)}catch{ae="<response body error>"}let ne="";try{const x=Buffer.concat(L),R=C>x.length||x.length===i;ne=x.toString("utf8"),R&&(ne+=`
11
+ ...[truncated]`)}catch{ne="<request body error>"}let _=null;if(r.ctx.llmProvider.isLLMCall(v))try{_=r.ctx.responseProcessor(v,ae)}catch(x){_={parts:[{type:"text",text:ae||"<empty response>"}],metadata:{error:String(x)}}}const k={id:h,time:w,transport:p==="https:"?"https":"http",method:d,url:v,requestBody:ne,status:I.statusCode,ok:I.statusCode>=200&&I.statusCode<300,durationMs:Math.round(V),responseBody:ae,processedBody:_,bodyBytes:se};try{const x=new URL(v);k.host=x.hostname,k.path=x.pathname}catch{}r.ctx.handleLogEntry(k),r._extra.agentHttpService&&r._extra.sessionId&&r._extra.isValidMessageRequest(v,d,ne)&&r._extra.sendHttpUpdate(k).catch(()=>{})}),I.on("error",V=>{const ae=Ee.performance.now()-m;let ne="";try{const k=Buffer.concat(L),x=C>k.length||k.length===i;ne=k.toString("utf8"),x&&(ne+=`
12
+ ...[truncated]`)}catch{ne="<request body error>"}const _={id:h,time:w,transport:p==="https:"?"https":"http",method:d,url:v,requestBody:ne,durationMs:Math.round(ae),error:V.message};try{const k=new URL(v);_.host=k.hostname,_.path=k.pathname}catch{}r.ctx.handleLogEntry(_),r._extra.agentHttpService&&r._extra.sessionId&&r._extra.isValidMessageRequest(v,d,ne)&&r._extra.sendHttpUpdate(_).catch(()=>{})}),g&&g(I)}),F=j.write,H=j.end;return j.write=function(I,G,se){try{if(I&&C<i){const $=Buffer.isBuffer(I)?I:Buffer.from(I,G||"utf8"),Q=i-C;$.length<=Q?(L.push($),C+=$.length):(L.push($.subarray(0,Q)),C+=Q)}}catch{}return F.call(this,I,G,se)},j.end=function(I,G,se){try{if(I&&C<i){const $=Buffer.isBuffer(I)?I:Buffer.from(I,G||"utf8"),Q=i-C;$.length<=Q?(L.push($),C+=$.length):(L.push($.subarray(0,Q)),C+=Q)}if(!J){J=!0;try{const $=Buffer.concat(L),Q=C>$.length||$.length===i;let V=$.toString("utf8");Q&&(V+=`
13
+ ...[truncated]`);const ae=r._extra.isValidMessageRequest(v,d,V);if(r._extra.agentHttpService&&r._extra.sessionId&&ae){const ne={id:h,time:w,transport:p==="https:"?"https":"http",method:d,url:v,requestBody:V,durationMs:0};r._extra.sendHttpStart(ne).catch(()=>{})}}catch{}}}catch{}return H.call(this,I,G,se)},j}};const s=require("http"),o=require("https");if(this.originals)return;this.originals={httpRequest:s.request,httpsRequest:o.request,httpGet:s.get,httpsGet:o.get};const r=this,i=this.ctx.maxBodyBytes;s.request=t(this.originals.httpRequest,"http:"),s.get=function(p,u){const c=s.request(p,u);return c.end(),c},this.enableHttps!==!1&&(o.request=t(this.originals.httpsRequest,"https:"),o.get=function(p,u){const c=o.request(p,u);return c.end(),c})}catch{}}restore(){if(this.originals){try{const e=require("http"),t=require("https");e.request=this.originals.httpRequest,e.get=this.originals.httpGet,t.request=this.originals.httpsRequest,t.get=this.originals.httpsGet}catch{}this.originals=null}}}class Je{static instance=null;isPatched=!1;config;llmProvider;idGenerator;agentHttpService;sessionId;router;activeRequests=new Map;rawLogger;errorLogger;processedLogger;debugLogger;fetchInstrument;httpInstrument;constructor(e={}){this.llmProvider=e.llmProvider||new Ls,this.idGenerator=e.idGenerator||Te.ulid,this.agentHttpService=e.agentHttpService,this.sessionId=e.sessionId,this.router=e.router,this.debugLogger=e.logger,this.config={maxBodyBytes:e.maxBodyBytes??8192,enableHttpsPatching:e.enableHttpsPatching??!0,enableDebug:e.enableDebug??!1,logFilter:e.logFilter??(i=>!!(i.url&&!i.url.includes("statsig")&&!i.url.includes("registry.npmjs.org")&&!i.url.startsWith("data:"))),responseProcessor:e.responseProcessor??((i,a)=>{try{return le.parseStreamingResponse(i,a)}catch{return null}})};const t=fe.join(jt.tmpdir(),"agiflow-agents","llm",`session-${process.pid}`),s=e.logFilePath||fe.join(t,"network.log"),o=fe.join(t,"error.log"),r=e.processedLogFilePath||fe.join(t,"processed.jsonl");try{this.rawLogger=new rt(s)}catch{}try{this.errorLogger=new rt(o)}catch{}try{this.processedLogger=new rt(r)}catch{}}static getInstance(e){return Je.instance||(Je.instance=new Je(e)),Je.instance}start(){if(this.isPatched)return;const e={idGenerator:this.idGenerator,maxBodyBytes:this.config.maxBodyBytes,enableDebug:this.config.enableDebug,logFilter:this.config.logFilter,responseProcessor:this.config.responseProcessor,llmProvider:this.llmProvider,handleLogEntry:t=>this.handleLogEntry(t),router:this.router,logger:this.debugLogger};this.fetchInstrument=new nt(e,{agentHttpService:this.agentHttpService,sessionId:this.sessionId,isValidMessageRequest:(t,s,o)=>this.isValidMessageRequest(t,s,o),sendHttpStart:t=>this.sendHttpStart(t),sendHttpUpdate:t=>this.sendHttpUpdate(t)}),this.fetchInstrument.patch(),this.httpInstrument=new Go(e,this.config.enableHttpsPatching,{agentHttpService:this.agentHttpService,sessionId:this.sessionId,isValidMessageRequest:(t,s,o)=>this.isValidMessageRequest(t,s,o),sendHttpStart:t=>this.sendHttpStart(t),sendHttpUpdate:t=>this.sendHttpUpdate(t)}),this.httpInstrument.patch(),this.isPatched=!0}stop(){this.isPatched&&(this.fetchInstrument?.restore(),this.httpInstrument?.restore(),this.isPatched=!1)}isActive(){return this.isPatched}updateConfig(e){this.config={...this.config,...e}}handleLogEntry(e){this.rawLogger&&this.rawLogger.info("network_entry",{networkLog:e}),this.debugLogger&&this.debugLogger.info("network_entry",{networkLog:e}),this.processedLogger&&this.config.logFilter(e)&&e.processedBody&&this.processedLogger.info("processed_entry",{id:e.id,url:e.url,method:e.method,status:e.status,durationMs:e.durationMs,timestamp:e.time,processedBody:e.processedBody})}isValidMessageRequest(e,t,s){if(this.rawLogger&&this.rawLogger.info("isValidMessageRequest checking",{url:e,method:t,hasBody:!!s,bodyLength:s?.length}),!this.llmProvider.isLLMCall(e))return this.rawLogger&&this.rawLogger.info("Not an LLM URL, skipping",{url:e}),this.rawLogger&&this.config.enableDebug&&this.rawLogger.debug("Request validation failed: Not an LLM URL",{url:e,method:t}),!1;if(e.includes("cloudcode-pa.googleapis.com")||e.includes("generativelanguage.googleapis.com"))return!!e.includes("streamGenerateContent");if(t!=="POST"||!s)return!1;try{const o=JSON.parse(s),r=o.messages&&Array.isArray(o.messages)&&o.messages.length>0,i=o.prompt&&typeof o.prompt=="string",a=o.input&&typeof o.input=="string",p=o.contents&&Array.isArray(o.contents)&&o.contents.length>0,u=o.request?.contents&&Array.isArray(o.request.contents)&&o.request.contents.length>0;return r||i||a||p||u}catch(o){return this.errorLogger&&this.errorLogger.error("Failed to parse request body in isValidMessageRequest",{url:e,method:t,error:o instanceof Error?o.message:String(o)}),!1}}async sendHttpStart(e){if(!this.agentHttpService||!this.sessionId)return;this.rawLogger&&this.rawLogger.info("http_start",{entry:e});let t=[];if(e.requestBody)try{const o=JSON.parse(e.requestBody);if(o.messages&&Array.isArray(o.messages)){const r=o.messages.filter(i=>i.role==="user").pop();r?.content&&(typeof r.content=="string"?t.push({type:"text",text:r.content}):Array.isArray(r.content)&&(t=r.content.map(i=>({type:i.type||"text",text:i.text||JSON.stringify(i)}))))}else if(o.prompt)t.push({type:"text",text:o.prompt});else if(o.input)t.push({type:"text",text:o.input});else if(o.contents&&Array.isArray(o.contents)){const r=o.contents.filter(i=>i.role==="user").pop();r?.parts&&Array.isArray(r.parts)&&(t=r.parts.map(i=>({type:"text",text:i.text||JSON.stringify(i)})))}else if(o.request?.contents&&Array.isArray(o.request.contents)){const r=o.request.contents.filter(i=>i.role==="user").pop();r?.parts&&Array.isArray(r.parts)&&(t=r.parts.map(i=>({type:"text",text:i.text||JSON.stringify(i)})))}}catch(o){this.errorLogger&&this.errorLogger.error("Failed to parse request data in sendHttpStart",{url:e.url,error:o instanceof Error?o.message:String(o)}),t.push({type:"text",text:"LLM request initiated..."})}const s={llm_provider:this.llmProvider.detectProvider(e.url),request_started:!0};try{this.rawLogger&&this.rawLogger.info("Calling agentHttpService.startMessage",{sessionId:this.sessionId,entryId:e.id});const o=await this.agentHttpService.startMessage(this.sessionId,{messageType:"output",metadata:s});this.activeRequests.set(e.id,o.messageId),this.rawLogger&&this.rawLogger.info("startMessage successful",{entryId:e.id,messageId:o.messageId})}catch(o){this.errorLogger&&this.errorLogger.error("Failed to send HTTP start message",{url:e.url,sessionId:this.sessionId,error:o instanceof Error?o.message:String(o)})}}async sendHttpUpdate(e){if(!this.agentHttpService||!this.sessionId)return;this.rawLogger&&this.rawLogger.info("http_update",{entry:e});const t=this.activeRequests.get(e.id);if(!t)return;if(!(e.processedBody?.message?.parts?.length>0||e.processedBody?.parts?.length>0)){this.rawLogger&&this.rawLogger.info("Skipping update - no valid parts yet",{entryId:e.id,messageId:t});return}const o={llm_provider:this.llmProvider.detectProvider(e.url),status:e.status,duration:e.durationMs};if(e.processedBody?.metadata){const i=e.processedBody.metadata;i.model&&(o.model=i.model),i.usage&&(o.usage=i.usage),i.total_tokens&&(o.total_tokens=i.total_tokens),i.prompt_tokens&&(o.prompt_tokens=i.prompt_tokens),i.completion_tokens&&(o.completion_tokens=i.completion_tokens),i.cost&&(o.cost=i.cost)}let r=[];if(e.processedBody){const i=e.processedBody;i?.message?.parts&&Array.isArray(i.message.parts)?r=i.message.parts:i?.parts&&Array.isArray(i.parts)?r=i.parts:i?.error?r.push({type:"text",text:`Parser error: ${i.error}`}):r=[]}else e.responseBody&&r.push({type:"text",text:"LLM response completed"});try{const i={parts:r,metadata:o,mId:e.processedBody?.message?.id};te.isSaveRawEnabled&&(i.raw=JSON.stringify(e)),await this.agentHttpService.updateMessage(this.sessionId,t,i),this.activeRequests.delete(e.id)}catch(i){this.errorLogger&&this.errorLogger.error("Failed to send HTTP update message",{url:e.url,messageId:t,sessionId:this.sessionId,error:i instanceof Error?i.message:String(i)}),this.activeRequests.delete(e.id)}}}class X{static AGIFLOW_DIR=Oe.join(Ut.homedir(),".agiflow");static async ensureDir(e){await Ce.ensureDir(e)}static async exists(e){try{return await Ce.access(e),!0}catch{return!1}}static async readJson(e){const t=await Ce.readFile(e,"utf-8");return JSON.parse(t)}static async writeJson(e,t,s){await Ce.ensureDir(Oe.dirname(e));const o=JSON.stringify(t,null,s?.spaces??2);await Ce.writeFile(e,o,"utf-8")}static async copy(e,t){await Ce.copy(e,t)}static async remove(e){await Ce.remove(e)}static getCurrentDirectory(){return process.cwd()}static resolvePath(...e){return Oe.resolve(process.cwd(),...e)}static async getFiles(e,t){const s=await Ce.readdir(e);return t?s.filter(o=>t.test(o)):s}static getAbsolutePath(e){return e?e.startsWith("~/")?Oe.join(Ut.homedir(),e.slice(2)):e==="~"?Ut.homedir():Oe.isAbsolute(e)?e:Oe.resolve(process.cwd(),e):process.cwd()}}class Vo{static SESSIONS_FILE=Oe.join(X.AGIFLOW_DIR,"sessions.json");static async getSessionSettings(e){try{return await X.exists(this.SESSIONS_FILE)&&(await X.readJson(this.SESSIONS_FILE))[e]||null}catch(t){return console.error("[SessionSettings] Failed to read session settings:",t),null}}static async setSessionSettings(e,t){try{let s={};await X.exists(this.SESSIONS_FILE)&&(s=await X.readJson(this.SESSIONS_FILE)),s[e]=t,await X.writeJson(this.SESSIONS_FILE,s,{spaces:2})}catch(s){throw console.error("[SessionSettings] Failed to write session settings:",s),s}}static async removeSessionSettings(e){try{if(!await X.exists(this.SESSIONS_FILE))return;const s=await X.readJson(this.SESSIONS_FILE);delete s[e],await X.writeJson(this.SESSIONS_FILE,s,{spaces:2})}catch(t){throw console.error("[SessionSettings] Failed to remove session settings:",t),t}}static async getAllSessions(){try{return await X.exists(this.SESSIONS_FILE)?await X.readJson(this.SESSIONS_FILE):{}}catch(e){return console.error("[SessionSettings] Failed to read all session settings:",e),{}}}static async clearAllSessions(){try{await X.writeJson(this.SESSIONS_FILE,{},{spaces:2})}catch(e){throw console.error("[SessionSettings] Failed to clear session settings:",e),e}}}class Ne{static AUTH_FILE_PATH=fe.join(jt.homedir(),".codex","auth.json");static TOKEN_REFRESH_URL="https://auth.openai.com/oauth/token";static CLIENT_ID="app_EMoamEEZ73f0CkXaXp7hrann";logger;constructor(e){this.logger=e}async getAccountId(){try{const e=this.readAuthFile();return!e||!e.tokens?null:e.tokens.account_id||null}catch(e){return this.logger?.error("[CodexAuth] Error getting account ID",e),null}}async getAccessToken(){try{const e=this.readAuthFile();if(!e||!e.tokens)return this.logger?.warn("[CodexAuth] No tokens found in auth file"),null;let{access_token:t,refresh_token:s}=e.tokens;if(typeof t=="string"&&t.startsWith("Bearer ")&&(t=t.substring(7)),!this.isTokenExpired(t))return t;const r=await this.refreshAccessToken(s);return r?(this.saveTokens(r),r.access_token):(this.logger?.error("[CodexAuth] Failed to refresh access token"),null)}catch(e){return this.logger?.error("[CodexAuth] Error getting access token",e),null}}readAuthFile(){try{if(!ke.existsSync(Ne.AUTH_FILE_PATH))return this.logger?.warn("[CodexAuth] Auth file does not exist",{path:Ne.AUTH_FILE_PATH}),null;const e=ke.readFileSync(Ne.AUTH_FILE_PATH,"utf-8");return JSON.parse(e)}catch(e){return this.logger?.error("[CodexAuth] Failed to read auth file",e),null}}isTokenExpired(e){try{const t=this.decodeJWT(e);if(!t||!t.exp)return!0;const s=t.exp*1e3,o=Date.now(),r=300*1e3;return s-o<r}catch(t){return this.logger?.error("[CodexAuth] Failed to decode token",t),!0}}decodeJWT(e){try{const t=e.split(".");if(t.length!==3)return null;const s=t[1],o=Buffer.from(s,"base64url").toString("utf-8");return JSON.parse(o)}catch(t){return this.logger?.error("[CodexAuth] Failed to decode JWT",t),null}}async refreshAccessToken(e){try{const t=await fetch(Ne.TOKEN_REFRESH_URL,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:Ne.CLIENT_ID})});if(!t.ok){const r=await t.text();return this.logger?.error("[CodexAuth] Token refresh failed",{status:t.status,error:r}),null}const s=await t.json();let o=s.access_token;return typeof o=="string"&&o.startsWith("Bearer ")&&(o=o.substring(7)),{id_token:s.id_token,access_token:o,refresh_token:s.refresh_token||e,account_id:s.account_id||""}}catch(t){return this.logger?.error("[CodexAuth] Failed to refresh token",t),null}}saveTokens(e){try{const t=this.readAuthFile();if(!t){this.logger?.error("[CodexAuth] Cannot save tokens - auth file not found");return}t.tokens=e,t.last_refresh=new Date().toISOString(),ke.writeFileSync(Ne.AUTH_FILE_PATH,JSON.stringify(t,null,2),"utf-8")}catch(t){this.logger?.error("[CodexAuth] Failed to save tokens",t)}}}const Zo=`You are a coding agent running in the Codex CLI, a terminal-based coding assistant. Codex CLI is an open source project led by OpenAI. You are expected to be precise, safe, and helpful.
14
+
15
+ Your capabilities:
16
+
17
+ - Receive user prompts and other context provided by the harness, such as files in the workspace.
18
+ - Communicate with the user by streaming thinking & responses, and by making & updating plans.
19
+ - Emit function calls to run terminal commands and apply patches. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the "Sandbox and approvals" section.
20
+
21
+ Within this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).
22
+
23
+ # How you work
24
+
25
+ ## Personality
26
+
27
+ Your default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.
28
+
29
+ # AGENTS.md spec
30
+ - Repos often contain AGENTS.md files. These files can appear anywhere within the repository.
31
+ - These files are a way for humans to give you (the agent) instructions or tips for working within the container.
32
+ - Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.
33
+ - Instructions in AGENTS.md files:
34
+ - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.
35
+ - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.
36
+ - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.
37
+ - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.
38
+ - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.
39
+ - The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.
40
+
41
+ ## Responsiveness
42
+
43
+ ### Preamble messages
44
+
45
+ Before making tool calls, send a brief preamble to the user explaining what you're about to do. When sending preamble messages, follow these principles and examples:
46
+
47
+ - **Logically group related actions**: if you're about to run several related commands, describe them together in one preamble rather than sending a separate note for each.
48
+ - **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8–12 words for quick updates).
49
+ - **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what's been done so far and create a sense of momentum and clarity for the user to understand your next actions.
50
+ - **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.
51
+ - **Exception**: Avoid adding a preamble for every trivial read (e.g., \`cat\` a single file) unless it's part of a larger grouped action.
52
+
53
+ **Examples:**
54
+
55
+ - "I've explored the repo; now checking the API route definitions."
56
+ - "Next, I'll patch the config and update the related tests."
57
+ - "I'm about to scaffold the CLI commands and helper functions."
58
+ - "Ok cool, so I've wrapped my head around the repo. Now digging into the API routes."
59
+ - "Config's looking tidy. Next up is patching helpers to keep things in sync."
60
+ - "Finished poking at the DB gateway. I will now chase down error handling."
61
+ - "Alright, build pipeline order is interesting. Checking how it reports failures."
62
+ - "Spotted a clever caching util; now hunting where it gets used."
63
+
64
+ ## Planning
65
+
66
+ You have access to an \`update_plan\` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.
67
+
68
+ Note that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.
69
+
70
+ Do not repeat the full contents of the plan after an \`update_plan\` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.
71
+
72
+ Before running a command, consider whether or not you have completed the previous step, and make sure to mark it as completed before moving on to the next step. It may be the case that you complete all steps in your plan after a single pass of implementation. If this is the case, you can simply mark all the planned steps as completed. Sometimes, you may need to change plans in the middle of a task: call \`update_plan\` with the updated plan and make sure to provide an \`explanation\` of the rationale when doing so.
73
+
74
+ Use a plan when:
75
+
76
+ - The task is non-trivial and will require multiple actions over a long time horizon.
77
+ - There are logical phases or dependencies where sequencing matters.
78
+ - The work has ambiguity that benefits from outlining high-level goals.
79
+ - You want intermediate checkpoints for feedback and validation.
80
+ - When the user asked you to do more than one thing in a single prompt
81
+ - The user has asked you to use the plan tool (aka "TODOs")
82
+ - You generate additional steps while working, and plan to do them before yielding to the user
83
+
84
+ ### Examples
85
+
86
+ **High-quality plans**
87
+
88
+ Example 1:
89
+
90
+ 1. Add CLI entry with file args
91
+ 2. Parse Markdown via CommonMark library
92
+ 3. Apply semantic HTML template
93
+ 4. Handle code blocks, images, links
94
+ 5. Add error handling for invalid files
95
+
96
+ Example 2:
97
+
98
+ 1. Define CSS variables for colors
99
+ 2. Add toggle with localStorage state
100
+ 3. Refactor components to use variables
101
+ 4. Verify all views for readability
102
+ 5. Add smooth theme-change transition
103
+
104
+ Example 3:
105
+
106
+ 1. Set up Node.js + WebSocket server
107
+ 2. Add join/leave broadcast events
108
+ 3. Implement messaging with timestamps
109
+ 4. Add usernames + mention highlighting
110
+ 5. Persist messages in lightweight DB
111
+ 6. Add typing indicators + unread count
112
+
113
+ **Low-quality plans**
114
+
115
+ Example 1:
116
+
117
+ 1. Create CLI tool
118
+ 2. Add Markdown parser
119
+ 3. Convert to HTML
120
+
121
+ Example 2:
122
+
123
+ 1. Add dark mode toggle
124
+ 2. Save preference
125
+ 3. Make styles look good
126
+
127
+ Example 3:
128
+
129
+ 1. Create single-file HTML game
130
+ 2. Run quick sanity check
131
+ 3. Summarize usage instructions
132
+
133
+ If you need to write a plan, only write high quality plans, not low quality ones.
134
+
135
+ ## Task execution
136
+
137
+ You are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.
138
+
139
+ You MUST adhere to the following criteria when solving queries:
140
+
141
+ - Working on the repo(s) in the current environment is allowed, even if they are proprietary.
142
+ - Analyzing code for vulnerabilities is allowed.
143
+ - Showing user code and tool call details is allowed.
144
+ - Use the \`apply_patch\` tool to edit files (NEVER try \`applypatch\` or \`apply-patch\`, only \`apply_patch\`): {"command":["apply_patch","*** Begin Patch\\\\n*** Update File: path/to/file.py\\\\n@@ def example():\\\\n- pass\\\\n+ return 123\\\\n*** End Patch"]}
145
+
146
+ If completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:
147
+
148
+ - Fix the problem at the root cause rather than applying surface-level patches, when possible.
149
+ - Avoid unneeded complexity in your solution.
150
+ - Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)
151
+ - Update documentation as necessary.
152
+ - Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.
153
+ - Use \`git log\` and \`git blame\` to search the history of the codebase if additional context is required.
154
+ - NEVER add copyright or license headers unless specifically requested.
155
+ - Do not waste tokens by re-reading files after calling \`apply_patch\` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.
156
+ - Do not \`git commit\` your changes or create new git branches unless explicitly requested.
157
+ - Do not add inline comments within code unless explicitly requested.
158
+ - Do not use one-letter variable names unless explicitly requested.
159
+ - NEVER output inline citations like "【F:README.md†L5-L14】" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.
160
+
161
+ ## Sandbox and approvals
162
+
163
+ The Codex CLI harness supports several different sandboxing, and approval configurations that the user can choose from.
164
+
165
+ Filesystem sandboxing prevents you from editing files without user approval. The options are:
166
+
167
+ - **read-only**: You can only read files.
168
+ - **workspace-write**: You can read files. You can write to files in your workspace folder, but not outside it.
169
+ - **danger-full-access**: No filesystem sandboxing.
170
+
171
+ Network sandboxing prevents you from accessing network without approval. Options are
172
+
173
+ - **restricted**
174
+ - **enabled**
175
+
176
+ Approvals are your mechanism to get user consent to perform more privileged actions. Although they introduce friction to the user because your work is paused until the user responds, you should leverage them to accomplish your important work. Do not let these settings or the sandbox deter you from attempting to accomplish the user's task. Approval options are
177
+
178
+ - **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe "read" commands.
179
+ - **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.
180
+ - **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the \`shell\` command description.)
181
+ - **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is pared with \`danger-full-access\`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.
182
+
183
+ When you are running with approvals \`on-request\`, and sandboxing enabled, here are scenarios where you'll need to request approval:
184
+
185
+ - You need to run a command that writes to a directory that requires it (e.g. running tests that write to /tmp)
186
+ - You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.
187
+ - You are running sandboxed and need to run a command that requires network access (e.g. installing packages)
188
+ - If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval.
189
+ - You are about to take a potentially destructive action such as an \`rm\` or \`git reset\` that the user did not explicitly ask for
190
+ - (For all of these, you should weigh alternative paths that do not require approval.)
191
+
192
+ Note that when sandboxing is set to read-only, you'll need to request approval for any command that isn't a read.
193
+
194
+ You will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing ON, and approval on-failure.
195
+
196
+ ## Validating your work
197
+
198
+ If the codebase has tests or the ability to build or run, consider using them to verify that your work is complete.
199
+
200
+ When testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.
201
+
202
+ Similarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.
203
+
204
+ For all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)
205
+
206
+ Be mindful of whether to run validation commands proactively. In the absence of behavioral guidance:
207
+
208
+ - When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task.
209
+ - When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.
210
+ - When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.
211
+
212
+ ## Ambition vs. precision
213
+
214
+ For tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.
215
+
216
+ If you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.
217
+
218
+ You should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.
219
+
220
+ ## Sharing progress updates
221
+
222
+ For especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.
223
+
224
+ Before doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.
225
+
226
+ The messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.
227
+
228
+ ## Presenting your work and final message
229
+
230
+ Your final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user's style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.
231
+
232
+ You can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.
233
+
234
+ The user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using \`apply_patch\`, there's no need to tell users to "save the file" or "copy the code into a file"—just reference the file path.
235
+
236
+ If there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there's something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.
237
+
238
+ Brevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.
239
+
240
+ ### Final answer structure and style guidelines
241
+
242
+ You are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.
243
+
244
+ **Section Headers**
245
+
246
+ - Use only when they improve clarity — they are not mandatory for every answer.
247
+ - Choose descriptive names that fit the content
248
+ - Keep headers short (1–3 words) and in \`**Title Case**\`. Always start headers with \`**\` and end with \`**\`
249
+ - Leave no blank line before the first bullet under a header.
250
+ - Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.
251
+
252
+ **Bullets**
253
+
254
+ - Use \`-\` followed by a space for every bullet.
255
+ - Merge related points when possible; avoid a bullet for every trivial detail.
256
+ - Keep bullets to one line unless breaking for clarity is unavoidable.
257
+ - Group into short lists (4–6 bullets) ordered by importance.
258
+ - Use consistent keyword phrasing and formatting across sections.
259
+
260
+ **Monospace**
261
+
262
+ - Wrap all commands, file paths, env vars, and code identifiers in backticks (\`\` \`...\` \`\`).
263
+ - Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.
264
+ - Never mix monospace and bold markers; choose one based on whether it's a keyword (\`**\`) or inline code/path (\`\` \` \`\`).
265
+
266
+ **File References**
267
+ When referencing files in your response, make sure to include the relevant start line and always follow the below rules:
268
+ * Use inline code to make file paths clickable.
269
+ * Each reference should have a stand alone path. Even if it's the same file.
270
+ * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.
271
+ * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).
272
+ * Do not use URIs like file://, vscode://, or https://.
273
+ * Do not provide range of lines
274
+ * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\\\repo\\\\project\\\\main.rs:12:5
275
+
276
+ **Structure**
277
+
278
+ - Place related bullets together; don't mix unrelated concepts in the same section.
279
+ - Order sections from general → specific → supporting info.
280
+ - For subsections (e.g., "Binaries" under "Rust Workspace"), introduce with a bolded keyword bullet, then list items under it.
281
+ - Match structure to complexity:
282
+ - Multi-part or detailed results → use clear headers and grouped bullets.
283
+ - Simple results → minimal headers, possibly just a short list or paragraph.
284
+
285
+ **Tone**
286
+
287
+ - Keep the voice collaborative and natural, like a coding partner handing off work.
288
+ - Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition
289
+ - Use present tense and active voice (e.g., "Runs tests" not "This will run tests").
290
+ - Keep descriptions self-contained; don't refer to "above" or "below".
291
+ - Use parallel structure in lists for consistency.
292
+
293
+ **Don't**
294
+
295
+ - Don't use literal words "bold" or "monospace" in the content.
296
+ - Don't nest bullets or create deep hierarchies.
297
+ - Don't output ANSI escape codes directly — the CLI renderer applies them.
298
+ - Don't cram unrelated keywords into a single bullet; split for clarity.
299
+ - Don't let keyword lists run long — wrap or reformat for scanability.
300
+
301
+ Generally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what's needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.
302
+
303
+ For casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.
304
+
305
+ # Tool Guidelines
306
+
307
+ ## Shell commands
308
+
309
+ When using the shell, you must adhere to the following guidelines:
310
+
311
+ - When searching for text or files, prefer using \`rg\` or \`rg --files\` respectively because \`rg\` is much faster than alternatives like \`grep\`. (If the \`rg\` command is not found, then use alternatives.)
312
+ - Read files in chunks with a max chunk size of 250 lines. Do not use python scripts to attempt to output larger chunks of a file. Command line output will be truncated after 10 kilobytes or 256 lines of output, regardless of the command used.
313
+
314
+ ## \`update_plan\`
315
+
316
+ A tool named \`update_plan\` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.
317
+
318
+ To create a new plan, call \`update_plan\` with a short list of 1‑sentence steps (no more than 5-7 words each) with a \`status\` for each step (\`pending\`, \`in_progress\`, or \`completed\`).
319
+
320
+ When steps have been completed, use \`update_plan\` to mark each finished step as \`completed\` and the next step you are working on as \`in_progress\`. There should always be exactly one \`in_progress\` step until everything is done. You can mark multiple items as complete in a single \`update_plan\` call.
321
+
322
+ If all steps are complete, ensure you call \`update_plan\` to mark all steps as \`completed\`.
323
+
324
+ ## \`apply_patch\`
325
+
326
+ Use the \`apply_patch\` shell command to edit files.
327
+ Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:
328
+
329
+ *** Begin Patch
330
+ [ one or more file sections ]
331
+ *** End Patch
332
+
333
+ Within that envelope, you get a sequence of file operations.
334
+ You MUST include a header to specify the action you are taking.
335
+ Each operation starts with one of three headers:
336
+
337
+ *** Add File: <path> - create a new file. Every following line is a + line (the initial contents).
338
+ *** Delete File: <path> - remove an existing file. Nothing follows.
339
+ *** Update File: <path> - patch an existing file in place (optionally with a rename).
340
+
341
+ May be immediately followed by *** Move to: <new path> if you want to rename the file.
342
+ Then one or more "hunks", each introduced by @@ (optionally followed by a hunk header).
343
+ Within a hunk each line starts with:
344
+
345
+ For instructions on [context_before] and [context_after]:
346
+ - By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change's [context_after] lines in the second change's [context_before] lines.
347
+ - If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
348
+ @@ class BaseClass
349
+ [3 lines of pre-context]
350
+ - [old_code]
351
+ + [new_code]
352
+ [3 lines of post-context]
353
+
354
+ - If a code block is repeated so many times in a class or function such that even a single \`@@\` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple \`@@\` statements to jump to the right context. For instance:
355
+
356
+ @@ class BaseClass
357
+ @@ def method():
358
+ [3 lines of pre-context]
359
+ - [old_code]
360
+ + [new_code]
361
+ [3 lines of post-context]
362
+
363
+ The full grammar definition is below:
364
+ Patch := Begin { FileOp } End
365
+ Begin := "*** Begin Patch" NEWLINE
366
+ End := "*** End Patch" NEWLINE
367
+ FileOp := AddFile | DeleteFile | UpdateFile
368
+ AddFile := "*** Add File: " path NEWLINE { "+" line NEWLINE }
369
+ DeleteFile := "*** Delete File: " path NEWLINE
370
+ UpdateFile := "*** Update File: " path NEWLINE [ MoveTo ] { Hunk }
371
+ MoveTo := "*** Move to: " newPath NEWLINE
372
+ Hunk := "@@" [ header ] NEWLINE { HunkLine } [ "*** End of File" NEWLINE ]
373
+ HunkLine := (" " | "-" | "+") text NEWLINE
374
+
375
+ A full patch can combine several operations:
376
+
377
+ *** Begin Patch
378
+ *** Add File: hello.txt
379
+ +Hello world
380
+ *** Update File: src/app.py
381
+ *** Move to: src/main.py
382
+ @@ def greet():
383
+ -print("Hi")
384
+ +print("Hello, world!")
385
+ *** Delete File: obsolete.txt
386
+ *** End Patch
387
+
388
+ It is important to remember:
389
+
390
+ - You must include a header with your intended action (Add/Delete/Update)
391
+ - You must prefix new lines with \`+\` even when creating a new file
392
+ - File references can only be relative, NEVER ABSOLUTE.
393
+
394
+ You can invoke apply_patch like:
395
+
396
+ \`\`\`
397
+ shell {"command":["apply_patch","*** Begin Patch\\\\n*** Add File: hello.txt\\\\n+Hello, world!\\\\n*** End Patch\\\\n"]}
398
+ \`\`\`
399
+ `;class Jo{config;codexAuth;codexInstructions;constructor(e,t){this.config=e,this.codexAuth=t,this.codexInstructions=this.loadCodexInstructions()}loadCodexInstructions(){return Zo}async transform(e,t){try{const s=JSON.parse(t);this.config.logger?.debug("[ClaudeToOpenAI] ===== ORIGINAL CLAUDE REQUEST ====="),this.config.logger?.debug("[ClaudeToOpenAI] Original body",{body:JSON.stringify(s,null,2)});const o=$s.randomUUID(),r=o,i=this.config.sessionReasoningEffort,a=s.model&&s.model.toLowerCase().includes("haiku"),p=i||(a?"minimal":"medium");this.config.logger?.debug("[ClaudeToOpenAI] Model detection and reasoning effort",{originalModel:s.model,isHaikuModel:a,sessionReasoningEffort:i||"none",finalReasoningEffort:p,source:i?"session override":"model-based"});const u={model:this.config.toModel||"gpt-5",stream:!0,store:!1,tool_choice:"auto",parallel_tool_calls:!1,reasoning:{effort:p,summary:"auto"},include:["reasoning.encrypted_content"],prompt_cache_key:o};u.instructions=this.adaptInstructionsForChatGPT(this.codexInstructions);const c=[];let g="";if(s.system){const m=this.extractSystemMessages(s.system);m&&Array.isArray(m)&&m.length>0&&(g=m.map(h=>h.content).join(`
400
+
401
+ `))}if(g=this.removeClaudeCodeInstructions(g),g&&c.push({type:"message",role:"user",content:[{type:"input_text",text:g}]}),s.messages&&Array.isArray(s.messages))for(const m of s.messages){const h=this.convertMessageToInput(m);Array.isArray(h)?c.push(...h):h&&c.push(h)}if(u.input=c,s.tools&&Array.isArray(s.tools)){this.config.logger?.debug("[ClaudeToOpenAI] Original Claude tools",{tools:JSON.stringify(s.tools,null,2)});const m=this.convertTools(s.tools);this.config.logger?.debug("[ClaudeToOpenAI] Converted tools",{tools:JSON.stringify(m,null,2)}),m.length>0?(u.tools=m,this.config.logger?.debug("[ClaudeToOpenAI] Added tools to responsesRequest",{toolCount:m.length}),this.config.logger?.debug("[ClaudeToOpenAI] Verify responsesRequest.tools exists",{hasTools:!!u.tools,toolsLength:u.tools?.length,keys:Object.keys(u)})):this.config.logger?.warn("[ClaudeToOpenAI] No valid tools after conversion, omitting tools field")}else this.config.logger?.debug("[ClaudeToOpenAI] No tools in Claude request",{hasTools:!!s.tools,isArray:Array.isArray(s.tools)});const v=this.config.toEndpoint||"https://chatgpt.com/backend-api/codex/responses",d={version:"0.46.0","openai-beta":"responses=experimental",conversation_id:o,session_id:r,accept:"text/event-stream","content-type":"application/json","user-agent":"codex_cli_rs/0.46.0 (Mac OS 15.6.0; arm64) iTerm.app/3.6.2",originator:"codex_cli_rs"};if(this.codexAuth){const m=await this.codexAuth.getAccessToken();this.config.logger?.debug("[ClaudeToOpenAI] Raw access token",{token:m?.substring(0,30)+"..."}),m&&(m.startsWith("Bearer ")?(d.authorization=m,this.config.logger?.debug("[ClaudeToOpenAI] Token already has Bearer prefix, using as-is")):(d.authorization=`Bearer ${m}`,this.config.logger?.debug("[ClaudeToOpenAI] Added Bearer prefix to token")));const h=await this.codexAuth.getAccountId();h&&(d["chatgpt-account-id"]=h)}else this.config.toApiKey&&(d.authorization=`Bearer ${this.config.toApiKey}`);return this.config.logger?.debug("[ClaudeToOpenAI] ===== REQUEST DETAILS ====="),this.config.logger?.debug("[ClaudeToOpenAI] Target URL",{targetUrl:v}),this.config.logger?.debug("[ClaudeToOpenAI] Headers",{headers:{...d,authorization:d.authorization?`${d.authorization.substring(0,30)}...`:void 0}}),this.config.logger?.debug("[ClaudeToOpenAI] Body",{body:JSON.stringify(u,null,2)}),this.config.logger?.debug("[ClaudeToOpenAI] ==============================="),this.config.logger?.debug("[ClaudeToOpenAI] ===== FINAL TRANSFORMED REQUEST ====="),this.config.logger?.debug("[ClaudeToOpenAI] Pre-final check - responsesRequest.tools",{hasTools:!!u.tools,toolsLength:u.tools?.length,keys:Object.keys(u)}),this.config.logger?.debug("[ClaudeToOpenAI] Final body",{body:JSON.stringify(u,null,2)}),this.config.logger?.debug("[ClaudeToOpenAI] ===== END FINAL TRANSFORMED REQUEST ====="),{url:v,body:JSON.stringify(u),headers:d}}catch(s){throw new Error(`Failed to transform Claude request to OpenAI: ${s}`)}}adaptInstructionsForChatGPT(e){let t=e;return t=t.replace(/You are powered by the model named Sonnet 4\.5\. The exact model ID is claude-sonnet-4-5-\d+\./g,"You are powered by ChatGPT (GPT-5 reasoning model)."),t=t.replace(/Assistant knowledge cutoff is January 2025/g,"Assistant knowledge cutoff is October 2023"),t=t.replace(/\bClaude\b/g,"ChatGPT"),t=t.replace(/\bAnthropic\b/g,"OpenAI"),t}removeClaudeCodeInstructions(e){const t=[/You are Claude Code, Anthropic's official CLI for Claude\.[\s\S]*?claude_code_docs_map\.md/,/You are Claude Code[\s\S]*?using Claude Code\n/];let s=e;for(const o of t)s=s.replace(o,"");return s=s.replace(/\n{3,}/g,`
402
+
403
+ `).trim(),s}extractSystemMessages(e){const t=[];if(typeof e=="string")t.push({role:"system",content:e});else if(Array.isArray(e))for(const s of e)typeof s=="string"?t.push({role:"system",content:s}):s.type==="text"&&s.text&&t.push({role:"system",content:s.text});else e.type==="text"&&e.text&&t.push({role:"system",content:e.text});return t}convertMessageToInput(e){if(!e.role||!e.content)return null;const t=e.role==="assistant"?"output_text":"input_text";if(Array.isArray(e.content)){const s=[],o=[],r=[];for(const a of e.content)if(a.type==="tool_result"){const p=typeof a.content=="string"?a.content:JSON.stringify(a.content);s.push({type:"function_call_output",call_id:a.tool_use_id,output:p})}else if(a.type==="text")r.push({type:t,text:a.text||""});else if(a.type==="image")if(a.source&&a.source.type==="base64"&&a.source.data){const p=a.source.media_type||"image/jpeg",u=`data:${p};base64,${a.source.data}`;r.push({type:"input_image",image_url:u}),this.config.logger?.debug("[ClaudeToOpenAI] Converted image block",{mediaType:p,dataLength:a.source.data.length})}else this.config.logger?.warn("[ClaudeToOpenAI] Unsupported image format",{source:a.source});else a.type==="tool_use"&&o.push({type:"function_call",call_id:a.id,name:a.name,arguments:JSON.stringify(a.input||{})});const i=[];return r.length>0&&i.push({type:"message",role:e.role,content:r}),o.length>0&&i.push(...o),s.length>0&&i.push(...s),i.length>1?i:i.length===1?i[0]:null}else if(typeof e.content=="string")return{type:"message",role:e.role,content:[{type:t,text:e.content}]};return null}convertTools(e){return!e||!Array.isArray(e)?[]:e.filter(t=>!(!t||typeof t!="object"||!t.name)).map(t=>({type:"function",name:t.name,description:t.description||"",parameters:t.input_schema||t.parameters||{}}))}}class Wo{logger;constructor(e){this.logger=e}transform(e){try{return!e||e.trim()===""?this.createEmptyClaudeResponse():e.includes("data:")?this.convertStreamingResponse(e):this.convertNonStreamingResponse(e)}catch(t){return this.logger?.error("[OpenAIToClaude] ERROR in transform",t),this.createEmptyClaudeResponse()}}createEmptyClaudeResponse(){const e=`msg_${Te.ulid()}`,t=[];return t.push("event: message_start"),t.push(`data: ${JSON.stringify({type:"message_start",message:{id:e,type:"message",role:"assistant",content:[],model:"gpt-5",stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}})}`),t.push(""),t.push("event: message_stop"),t.push('data: {"type":"message_stop"}'),t.push(""),t.join(`
404
+ `)}convertStreamingResponse(e){const t=this.parseOpenAIStream(e),s=this.createClaudeStreamFromParsed(t),o=t.errorMessage||"Empty streaming response from provider";return this.ensureValidClaudeStream(s,o)}parseOpenAIStream(e){const t={textSegments:[],thinkingSegments:[],toolCalls:new Map,model:"gpt-5",inputTokens:0,outputTokens:0,cachedTokens:0,reasoningTokens:0,reasoningEffort:void 0,stopReason:void 0,errorMessage:void 0},s=e.split(`
405
+ `);let o="";const r=/event:\s*response\./i.test(e)||/"type"\s*:\s*"response\./i.test(e)||/"response"\s*:\s*\{/i.test(e);for(const i of s){const a=i.trim();if(!a)continue;if(a.startsWith("event:")){o=a.slice(6).trim();continue}if(!a.startsWith("data:"))continue;const p=a.slice(5).trim();if(!p||p==="[DONE]")continue;let u;try{u=JSON.parse(p)}catch{continue}if(u?.error){t.errorMessage=u.error?.message||u.error?.error||(typeof u.error=="string"?u.error:"Unexpected API error");break}r||o.startsWith("response.")?this.handleResponsesEvent(o,u,t):this.handleChatCompletionChunk(u,t)}return t}handleResponsesEvent(e,t,s){const o=typeof t?.type=="string"?t.type:e;switch(t?.model&&typeof t.model=="string"&&(s.model=t.model),t?.usage&&(s.inputTokens=t.usage.input_tokens??t.usage.prompt_tokens??s.inputTokens,s.outputTokens=t.usage.output_tokens??t.usage.completion_tokens??s.outputTokens),o){case"response.created":t?.response?.model&&(s.model=t.response.model);break;case"response.reasoning.delta":case"response.reasoning_summary_text.delta":case"response.function_call_arguments.delta":case"response.function_call_arguments.done":case"response.in_progress":case"response.output_item.added":case"response.output_item.done":case"response.content_part.added":case"response.content_part.done":case"response.reasoning_summary_part.added":case"response.reasoning_summary_part.done":case"response.reasoning_summary_text.done":break;case"response.output_text.delta":case"response.delta":t?.delta?.tool_calls;break;case"response.output_text.done":break;case"response.completed":if(t?.response?.model&&(s.model=t.response.model),t?.response?.usage&&(s.inputTokens=t.response.usage.input_tokens??t.response.usage.prompt_tokens??s.inputTokens,s.outputTokens=t.response.usage.output_tokens??t.response.usage.completion_tokens??s.outputTokens,t.response.usage.input_tokens_details?.cached_tokens&&(s.cachedTokens=t.response.usage.input_tokens_details.cached_tokens),t.response.usage.output_tokens_details?.reasoning_tokens&&(s.reasoningTokens=t.response.usage.output_tokens_details.reasoning_tokens)),t?.response?.reasoning?.effort&&(s.reasoningEffort=t.response.reasoning.effort),Array.isArray(t?.response?.tool_calls)&&this.collectToolCalls(t.response.tool_calls,s.toolCalls),Array.isArray(t?.response?.output)){for(const r of t.response.output)if(r?.type==="reasoning"){if(Array.isArray(r?.summary))for(const i of r.summary)i?.type==="summary_text"&&i?.text&&s.thinkingSegments.push(i.text)}else if(r?.type==="message"){if(Array.isArray(r?.content))for(const i of r.content)(i?.type==="output_text"||i?.type==="text")&&i?.text&&s.textSegments.push(i.text)}else if(r?.type==="function_call"){const i={index:s.toolCalls.size,id:r.id||`tool_${Te.ulid()}`,function:{name:r.name,arguments:r.arguments}};this.collectToolCalls([i],s.toolCalls)}}t?.response?.output_text&&this.collectTextFromNode(t.response.output_text,s.textSegments),s.stopReason=this.mapResponseStatusToStopReason(t?.response?.status);break;case"response.error":s.errorMessage=t?.error?.message||t?.message||"Unexpected API error";break;default:t?.delta&&(this.collectTextFromNode(t.delta,s.textSegments),t.delta.tool_calls&&this.collectToolCalls(t.delta.tool_calls,s.toolCalls));break}}handleChatCompletionChunk(e,t){if(e&&(e.model&&typeof e.model=="string"&&(t.model=e.model),e.usage&&(t.inputTokens=e.usage.prompt_tokens??t.inputTokens,t.outputTokens=e.usage.completion_tokens??t.outputTokens),!!Array.isArray(e.choices)))for(const s of e.choices)s?.delta&&(this.collectTextFromNode(s.delta,t.textSegments),s.delta.tool_calls&&this.collectToolCalls(s.delta.tool_calls,t.toolCalls)),s?.message?.content&&this.collectTextFromNode(s.message.content,t.textSegments),s?.finish_reason&&(t.stopReason=this.mapFinishReason(s.finish_reason))}collectTextFromNode(e,t){if(e==null)return;if(typeof e=="string"){e.length>0&&t.push(e);return}if(Array.isArray(e)){for(const o of e)this.collectTextFromNode(o,t);return}if(typeof e!="object")return;typeof e.text=="string"&&t.push(e.text),typeof e.output_text=="string"&&t.push(e.output_text),typeof e.value=="string"&&t.push(e.value),typeof e.delta=="string"?t.push(e.delta):e.delta&&this.collectTextFromNode(e.delta,t),e.token&&typeof e.token.text=="string"&&t.push(e.token.text);const s=["content","output","output_text","message","choices","segments"];for(const o of s)if(e[o]!==void 0)if(o==="choices"&&Array.isArray(e[o]))for(const r of e[o])r?.message?.content&&this.collectTextFromNode(r.message.content,t),r?.delta&&this.collectTextFromNode(r.delta,t);else this.collectTextFromNode(e[o],t)}collectToolCalls(e,t){if(!e)return;const s=Array.isArray(e)?e:[e];for(const o of s){if(!o)continue;const r=typeof o.index=="number"?o.index:t.size,i=t.get(r)||{id:"",name:"",argumentChunks:[]};typeof o.id=="string"&&!i.id&&(i.id=o.id);const a=o.function?.name;typeof a=="string"&&a.length>0&&(i.name=a);const p=o.function?.arguments;typeof p=="string"&&p.length>0&&i.argumentChunks.push(p),t.set(r,i)}}createClaudeStreamFromParsed(e){if(e.errorMessage)return this.createClaudeErrorStream(e.errorMessage);const t=this.mergeAndChunkSegments(e.thinkingSegments),s=this.mergeAndChunkSegments(e.textSegments),o=Array.from(e.toolCalls.entries()).sort((d,m)=>d[0]-m[0]).map(([d,m])=>({index:d,id:m.id,name:m.name,arguments:m.argumentChunks.join("")})).filter(d=>d.name);if(t.length===0&&s.length===0&&o.length===0)return this.createClaudeErrorStream("Empty streaming response from provider");const r=`msg_${Te.ulid()}`,i=e.model||"gpt-5",a=[];a.push("event: message_start"),a.push(`data: ${JSON.stringify({type:"message_start",message:{id:r,type:"message",role:"assistant",content:[],model:i,stop_reason:null,stop_sequence:null,usage:{input_tokens:e.inputTokens??0,output_tokens:0}}})}`),a.push("");let p=0;if(t.length>0){a.push("event: content_block_start"),a.push(`data: ${JSON.stringify({type:"content_block_start",index:p,content_block:{type:"thinking",thinking:"",_chatgpt_reasoning:!0}})}`),a.push("");for(const d of t)d&&(a.push("event: content_block_delta"),a.push(`data: ${JSON.stringify({type:"content_block_delta",index:p,delta:{type:"thinking_delta",thinking:d}})}`),a.push(""));a.push("event: content_block_stop"),a.push(`data: ${JSON.stringify({type:"content_block_stop",index:p})}`),a.push(""),p+=1}if(s.length>0){a.push("event: content_block_start"),a.push(`data: ${JSON.stringify({type:"content_block_start",index:p,content_block:{type:"text",text:""}})}`),a.push("");for(const d of s)d&&(a.push("event: content_block_delta"),a.push(`data: ${JSON.stringify({type:"content_block_delta",index:p,delta:{type:"text_delta",text:d}})}`),a.push(""));a.push("event: content_block_stop"),a.push(`data: ${JSON.stringify({type:"content_block_stop",index:p})}`),a.push(""),p+=1}for(const d of o){const m=p+d.index,h=d.id||`tool_${Te.ulid()}`;a.push("event: content_block_start"),a.push(`data: ${JSON.stringify({type:"content_block_start",index:m,content_block:{type:"tool_use",id:h,name:d.name,input:{}}})}`),a.push(""),d.arguments&&(a.push("event: content_block_delta"),a.push(`data: ${JSON.stringify({type:"content_block_delta",index:m,delta:{type:"input_json_delta",partial_json:d.arguments}})}`),a.push("")),a.push("event: content_block_stop"),a.push(`data: ${JSON.stringify({type:"content_block_stop",index:m})}`),a.push("")}const u=e.stopReason||"end_turn",g={output_tokens:e.outputTokens??0};return(e.cachedTokens||e.reasoningTokens||e.reasoningEffort)&&(g.metadata={},e.cachedTokens&&(g.metadata.cached_tokens=e.cachedTokens),e.reasoningTokens&&(g.metadata.reasoning_tokens=e.reasoningTokens),e.reasoningEffort&&(g.metadata.reasoning_effort=e.reasoningEffort)),a.push("event: message_delta"),a.push(`data: ${JSON.stringify({type:"message_delta",delta:{stop_reason:u,stop_sequence:null},usage:g})}`),a.push(""),a.push("event: message_stop"),a.push('data: {"type":"message_stop"}'),a.push(""),a.join(`
406
+ `)}mergeAndChunkSegments(e,t=2e3){if(!e||e.length===0)return[];const s=e.join("");if(!s)return[];const o=[];for(let r=0;r<s.length;r+=t)o.push(s.slice(r,r+t));return o}mapResponseStatusToStopReason(e){return e&&{completed:"end_turn",completed_with_error:"error",completed_with_streaming_error:"error",cancelled:"error",errored:"error"}[e]||"end_turn"}convertNonStreamingResponse(e){try{const t=JSON.parse(e);if(t?.error){const i=t.error?.message||t.error?.error||(typeof t.error=="string"?t.error:"Unexpected API error");return this.createClaudeErrorResponse(i)}const s=t.choices?.[0];if(!s)return e;const r={id:`msg_${Te.ulid()}`,type:"message",role:"assistant",content:[{type:"text",text:s.message?.content||""}],model:t.model||"gpt-4-turbo",stop_reason:this.mapFinishReason(s.finish_reason),stop_sequence:null,usage:{input_tokens:t.usage?.prompt_tokens||0,output_tokens:t.usage?.completion_tokens||0}};return JSON.stringify(r)}catch{const s=typeof e=="string"&&e.trim()?e.trim():"Unexpected API error";return this.createClaudeErrorResponse(s)}}mapFinishReason(e){return e?{stop:"end_turn",length:"max_tokens",function_call:"tool_use",tool_calls:"tool_use",content_filter:"stop_sequence"}[e]||"end_turn":null}createClaudeErrorResponse(e){const t=`msg_${Te.ulid()}`;return JSON.stringify({id:t,type:"message",role:"assistant",content:[{type:"text",text:e||"Unexpected API error"}],model:"gpt-5",stop_reason:"error",stop_sequence:null,usage:{input_tokens:0,output_tokens:0}})}createClaudeErrorStream(e){const t=`msg_${Te.ulid()}`,s=e||"Unexpected API error",o=[];return o.push("event: message_start"),o.push(`data: ${JSON.stringify({type:"message_start",message:{id:t,type:"message",role:"assistant",content:[],model:"gpt-5",stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}})}`),o.push(""),o.push("event: content_block_start"),o.push(`data: ${JSON.stringify({type:"content_block_start",index:0,content_block:{type:"text",text:""}})}`),o.push(""),o.push("event: content_block_delta"),o.push(`data: ${JSON.stringify({type:"content_block_delta",index:0,delta:{type:"text_delta",text:s}})}`),o.push(""),o.push("event: content_block_stop"),o.push(`data: ${JSON.stringify({type:"content_block_stop",index:0})}`),o.push(""),o.push("event: message_delta"),o.push(`data: ${JSON.stringify({type:"message_delta",delta:{stop_reason:"error",stop_sequence:null},usage:{output_tokens:0}})}`),o.push(""),o.push("event: message_stop"),o.push('data: {"type":"message_stop"}'),o.push(""),o.join(`
407
+ `)}ensureValidClaudeStream(e,t){return!e||!e.includes("event: message_start")?this.createClaudeErrorStream(t):e}}class Yo{config;requestTransformer=null;responseTransformer=null;routingContextMap=new Map;codexAuth;hasSessionSettings=!1;lastSessionCheckTimestamp=0;SESSION_CHECK_INTERVAL_MS=1e3;cachedSessionSettings=null;CLAUDE_PATTERNS=[/anthropic\.com/i,/claude\.ai/i,/\/v1\/messages/i,/\/publishers\/anthropic\/models/i];constructor(e){this.config=e,this.applySessionSettings()}applySessionSettings(){this.config.sessionId?this.loadSessionSettingsAsync():this.initializeRouter()}async loadSessionSettingsAsync(){await this.checkAndReloadSessionSettings(),this.initializeRouter()}async checkAndReloadSessionSettings(){if(!this.config.sessionId)return;const e=Date.now();if(!(e-this.lastSessionCheckTimestamp<this.SESSION_CHECK_INTERVAL_MS))try{const t=await Vo.getSessionSettings(this.config.sessionId);if(this.lastSessionCheckTimestamp=e,JSON.stringify(t)!==JSON.stringify(this.cachedSessionSettings))if(this.cachedSessionSettings=t,t&&t.provider){const o=this.mapProviderName(t.provider);this.config.toProvider=o,this.config.toModel=t.model,this.config.sessionReasoningEffort=t.reasoningEffort,this.hasSessionSettings=!0,this.initializeTransformers()}else this.hasSessionSettings=!1}catch(t){this.config.logger?.error("[Router] Failed to check session settings",t)}}initializeRouter(){this.config.toApiKey||(this.codexAuth=new Ne(this.config.logger)),this.initializeTransformers()}mapProviderName(e){const t=e.toLowerCase().trim();return t==="chatgpt"||t==="gpt"||t==="openai"?"openai":t}initializeTransformers(){this.config.toProvider?.toLowerCase()==="openai"&&(this.requestTransformer=new Jo(this.config,this.codexAuth),this.responseTransformer=new Wo(this.config.logger))}shouldRoute(e,t){if(this.checkAndReloadSessionSettings().catch(s=>{this.config.logger?.error("[Router] Failed to check session settings in shouldRoute",s)}),!this.requestTransformer||!this.responseTransformer||!t)return!1;try{return JSON.parse(t),!!(this.hasSessionSettings&&this.CLAUDE_PATTERNS.some(o=>o.test(e)))}catch(s){return this.config.logger?.error("[Router] JSON parse error in shouldRoute",s),!1}}async transformRequest(e,t){if(!this.requestTransformer)throw new Error("Request transformer not initialized");const s=await this.requestTransformer.transform(e,t),o=`${e}_${Date.now()}`;return this.routingContextMap.set(o,{originalUrl:e,targetUrl:s.url,fromProvider:"anthropic",toProvider:this.config.toProvider,wasRouted:!0}),s}transformResponse(e){if(!this.responseTransformer)throw new Error("Response transformer not initialized");try{return this.responseTransformer.transform(e)}catch(t){return this.config.logger?.error("[Router] Response transformation failed",t),this.createFallbackClaudeResponse()}}cleanRequestForPassthrough(e){try{const t=JSON.parse(e);if(!t.messages||!Array.isArray(t.messages))return e;let s=!1;const o=t.messages.map(r=>{if(!r.content||!Array.isArray(r.content))return r;const i=r.content.filter(a=>a.type==="thinking"&&a._chatgpt_reasoning===!0?(s=!0,!1):!0);return i.length>0?{...r,content:i}:null}).filter(Boolean);return s?(t.messages=o,JSON.stringify(t)):e}catch(t){return this.config.logger?.warn("[Router] Failed to clean request for passthrough",{error:t instanceof Error?t.message:String(t)}),e}}createFallbackClaudeResponse(){const e=`msg_error_${Date.now()}`,t=[];return t.push("event: message_start"),t.push(`data: ${JSON.stringify({type:"message_start",message:{id:e,type:"message",role:"assistant",content:[],model:"gpt-5",stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}})}`),t.push(""),t.push("event: content_block_start"),t.push(`data: ${JSON.stringify({type:"content_block_start",index:0,content_block:{type:"text",text:""}})}`),t.push(""),t.push("event: content_block_delta"),t.push(`data: ${JSON.stringify({type:"content_block_delta",index:0,delta:{type:"text_delta",text:"Error: Response transformation failed. Please try again."}})}`),t.push(""),t.push("event: content_block_stop"),t.push(`data: ${JSON.stringify({type:"content_block_stop",index:0})}`),t.push(""),t.push("event: message_stop"),t.push('data: {"type":"message_stop"}'),t.push(""),t.join(`
408
+ `)}wasRouted(e){for(const t of this.routingContextMap.values())if(t.targetUrl===e)return!0;return!1}getRoutingContext(e){for(const t of this.routingContextMap.values())if(t.targetUrl===e||t.originalUrl===e)return t}clearRoutingContext(e){for(const[t,s]of this.routingContextMap.entries())(s.targetUrl===e||s.originalUrl===e)&&this.routingContextMap.delete(t)}getTargetProvider(){return this.config.toProvider}getTargetModel(){return this.config.toModel}}const _s=Os(()=>Ge([Cs(),M(),ye(),xt(),He(_s),bt(_s)])),cs=P({toolCallId:M(),toolName:M(),args:Pe()}),Ko=P({toolCallId:M(),toolName:M(),args:Pe(),result:Pe()}),Xo=Ge([cs.extend({state:pe("partial-call"),step:ye().optional()}),cs.extend({state:pe("call"),step:ye().optional()}),Ko.extend({state:pe("result"),step:ye().optional()})]),Qo=P({type:M(),content:M()}),er=P({type:pe("text"),text:M()}),tr=P({type:pe("reasoning"),reasoning:M(),details:He(Ge([P({type:pe("text"),text:M(),signature:M().optional()}),P({type:pe("redacted"),data:M()})])).optional()}),sr=P({name:pe("select"),props:P({options:He(P({label:M(),value:Ge([M(),ye()]),selected:xt().optional()}))})}),or=P({name:pe("placeholder"),props:P({})}),rr=Ge([sr,or]),nr=P({completed:xt(),component:rr}),ir=P({type:pe("tool-invocation"),toolInvocation:Xo,input:nr.optional(),jsx:M({description:"UI rendering"}).optional()}),ar=P({type:pe("source"),source:Qo}),pr=P({type:pe("file"),mimeType:M(),data:M()}),ur=P({type:pe("error"),text:M(),error:Pe().optional()}),_r=P({type:pe("step-start")}),zs=Ge([er,tr,ir,ar,pr,ur,_r]),ss=qt(["input","output","error","system"]),Ms=P({messageType:ss,parts:He(zs),metadata:bt(M(),Dt()).optional(),raw:Pe().optional()});P({id:M(),sessionId:M(),agentTypeId:M(),messageType:ss,contentSize:ye().nullable(),timestamp:Ot.date(),metadata:M().nullable(),raw:Pe().nullable().optional(),createdAt:Ot.date(),updatedAt:Ot.date()});const cr=P({messageType:qt(["output"]).default("output"),metadata:bt(M(),Dt()).optional()});P({id:M(),messageId:M()});const lr=P({parts:He(zs).optional(),metadata:bt(M(),Dt()).optional(),raw:Pe().optional()});P({messages:He(Ms)});function dr(n){return[mr(n)]}function ls(n){let e=n.parts;if(!e&&n.content&&(e=dr(n.content)),!e)throw new Error("Either content or parts is required for message creation");return{messageType:n.messageType,parts:e,metadata:n.metadata,raw:n.raw}}function mr(n){return{type:"text",text:n}}const Gt=10,ds=(n=0)=>e=>`\x1B[${e+n}m`,ms=(n=0)=>e=>`\x1B[${38+n};5;${e}m`,hs=(n=0)=>(e,t,s)=>`\x1B[${38+n};2;${e};${t};${s}m`,q={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(q.modifier);const hr=Object.keys(q.color),gr=Object.keys(q.bgColor);[...hr,...gr];function fr(){const n=new Map;for(const[e,t]of Object.entries(q)){for(const[s,o]of Object.entries(t))q[s]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},t[s]=q[s],n.set(o[0],o[1]);Object.defineProperty(q,e,{value:t,enumerable:!1})}return Object.defineProperty(q,"codes",{value:n,enumerable:!1}),q.color.close="\x1B[39m",q.bgColor.close="\x1B[49m",q.color.ansi=ds(),q.color.ansi256=ms(),q.color.ansi16m=hs(),q.bgColor.ansi=ds(Gt),q.bgColor.ansi256=ms(Gt),q.bgColor.ansi16m=hs(Gt),Object.defineProperties(q,{rgbToAnsi256:{value(e,t,s){return e===t&&t===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(s/255*5)},enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[s]=t;s.length===3&&(s=[...s].map(r=>r+r).join(""));const o=Number.parseInt(s,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:e=>q.rgbToAnsi256(...q.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,s,o;if(e>=232)t=((e-232)*10+8)/255,s=t,o=t;else{e-=16;const a=e%36;t=Math.floor(e/36)/5,s=Math.floor(a/6)/5,o=a%6/5}const r=Math.max(t,s,o)*2;if(r===0)return 30;let i=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(t));return r===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(e,t,s)=>q.ansi256ToAnsi(q.rgbToAnsi256(e,t,s)),enumerable:!1},hexToAnsi:{value:e=>q.ansi256ToAnsi(q.hexToAnsi256(e)),enumerable:!1}}),q}const ge=fr(),gs=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const n=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(n&&n.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),fs=gs!==0&&{level:gs},kr={stdout:fs,stderr:fs};function vr(n,e,t){let s=n.indexOf(e);if(s===-1)return n;const o=e.length;let r=0,i="";do i+=n.slice(r,s)+e+t,r=s+o,s=n.indexOf(e,r);while(s!==-1);return i+=n.slice(r),i}function yr(n,e,t,s){let o=0,r="";do{const i=n[s-1]==="\r";r+=n.slice(o,i?s-1:s)+e+(i?`\r
14
409
  `:`
15
- `)+t,o=s+1,s=r.indexOf(`
16
- `,o)}while(s!==-1);return n+=r.slice(o),n}const{stdout:gs,stderr:fs}=cr,Ht=Symbol("GENERATOR"),Ye=Symbol("STYLER"),gt=Symbol("IS_EMPTY"),ks=["ansi","ansi","ansi256","ansi16m"],Xe=Object.create(null),mr=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const t=gs?gs.level:0;r.level=e.level===void 0?t:e.level},hr=r=>{const e=(...t)=>t.join(" ");return mr(e,r),Object.setPrototypeOf(e,xt.prototype),e};function xt(r){return hr(r)}Object.setPrototypeOf(xt.prototype,Function.prototype);for(const[r,e]of Object.entries(me))Xe[r]={get(){const t=Lt(this,Wt(e.open,e.close,this[Ye]),this[gt]);return Object.defineProperty(this,r,{value:t}),t}};Xe.visible={get(){const r=Lt(this,this[Ye],!0);return Object.defineProperty(this,"visible",{value:r}),r}};const Jt=(r,e,t,...s)=>r==="rgb"?e==="ansi16m"?me[t].ansi16m(...s):e==="ansi256"?me[t].ansi256(me.rgbToAnsi256(...s)):me[t].ansi(me.rgbToAnsi(...s)):r==="hex"?Jt("rgb",e,t,...me.hexToRgb(...s)):me[t][r](...s),gr=["rgb","hex","ansi256"];for(const r of gr){Xe[r]={get(){const{level:t}=this;return function(...s){const o=Wt(Jt(r,ks[t],"color",...s),me.color.close,this[Ye]);return Lt(this,o,this[gt])}}};const e="bg"+r[0].toUpperCase()+r.slice(1);Xe[e]={get(){const{level:t}=this;return function(...s){const o=Wt(Jt(r,ks[t],"bgColor",...s),me.bgColor.close,this[Ye]);return Lt(this,o,this[gt])}}}}const fr=Object.defineProperties(()=>{},{...Xe,level:{enumerable:!0,get(){return this[Ht].level},set(r){this[Ht].level=r}}}),Wt=(r,e,t)=>{let s,o;return t===void 0?(s=r,o=e):(s=t.openAll+r,o=e+t.closeAll),{open:r,close:e,openAll:s,closeAll:o,parent:t}},Lt=(r,e,t)=>{const s=(...o)=>kr(s,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(s,fr),s[Ht]=r,s[Ye]=e,s[gt]=t,s},kr=(r,e)=>{if(r.level<=0||!e)return r[gt]?"":e;let t=r[Ye];if(t===void 0)return e;const{openAll:s,closeAll:o}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=lr(e,t.close,t.open),t=t.parent;const n=e.indexOf(`
17
- `);return n!==-1&&(e=dr(e,o,s,n)),s+e+o};Object.defineProperties(xt.prototype,Xe);const G=xt();xt({level:fs?fs.level:0});function vr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tt={exports:{}},qt,vs;function xr(){if(vs)return qt;vs=1;function r(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}qt=e;function e(t,s,o){var n=o&&o.stringify||r,i=1;if(typeof t=="object"&&t!==null){var a=s.length+i;if(a===1)return t;var p=new Array(a);p[0]=n(t);for(var _=1;_<a;_++)p[_]=n(s[_]);return p.join(" ")}if(typeof t!="string")return t;var l=s.length;if(l===0)return t;for(var v="",k=1-i,h=-1,y=t&&t.length||0,g=0;g<y;){if(t.charCodeAt(g)===37&&g+1<y){switch(h=h>-1?h:0,t.charCodeAt(g+1)){case 100:case 102:if(k>=l||s[k]==null)break;h<g&&(v+=t.slice(h,g)),v+=Number(s[k]),h=g+2,g++;break;case 105:if(k>=l||s[k]==null)break;h<g&&(v+=t.slice(h,g)),v+=Math.floor(Number(s[k])),h=g+2,g++;break;case 79:case 111:case 106:if(k>=l||s[k]===void 0)break;h<g&&(v+=t.slice(h,g));var w=typeof s[k];if(w==="string"){v+="'"+s[k]+"'",h=g+2,g++;break}if(w==="function"){v+=s[k].name||"<anonymous>",h=g+2,g++;break}v+=n(s[k]),h=g+2,g++;break;case 115:if(k>=l)break;h<g&&(v+=t.slice(h,g)),v+=String(s[k]),h=g+2,g++;break;case 37:h<g&&(v+=t.slice(h,g)),v+="%",h=g+2,g++,k--;break}++k}++g}return h===-1?t:(h<y&&(v+=t.slice(h)),v)}return qt}var xs;function yr(){if(xs)return tt.exports;xs=1;const r=xr();tt.exports=l;const e=Z().console||{},t={mapHttpRequest:C,mapHttpResponse:C,wrapRequestSerializer:Y,wrapResponseSerializer:Y,wrapErrorSerializer:Y,req:C,res:C,err:Te,errWithCause:Te};function s(u,d){return u==="silent"?1/0:d.levels.values[u]}const o=Symbol("pino.logFuncs"),n=Symbol("pino.hierarchy"),i={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function a(u,d){const x={logger:d,parent:u[n]};d[n]=x}function p(u,d,x){const O={};d.forEach(R=>{O[R]=x[R]?x[R]:e[R]||e[i[R]||"log"]||J}),u[o]=O}function _(u,d){return Array.isArray(u)?u.filter(function(O){return O!=="!stdSerializers.err"}):u===!0?Object.keys(d):!1}function l(u){u=u||{},u.browser=u.browser||{};const d=u.browser.transmit;if(d&&typeof d.send!="function")throw Error("pino: transmit option must have a send function");const x=u.browser.write||e;u.browser.write&&(u.browser.asObject=!0);const O=u.serializers||{},R=_(u.browser.serialize,O);let q=u.browser.serialize;Array.isArray(u.browser.serialize)&&u.browser.serialize.indexOf("!stdSerializers.err")>-1&&(q=!1);const V=Object.keys(u.customLevels||{}),F=["error","fatal","warn","info","debug","trace"].concat(V);typeof x=="function"&&F.forEach(function(_e){x[_e]=x}),(u.enabled===!1||u.browser.disabled)&&(u.level="silent");const H=u.level||"info",T=Object.create(x);T.log||(T.log=J),p(T,F,x),a({},T),Object.defineProperty(T,"levelVal",{get:yt}),Object.defineProperty(T,"level",{get:Le,set:bt});const B={transmit:d,serialize:R,asObject:u.browser.asObject,formatters:u.browser.formatters,levels:F,timestamp:pe(u),messageKey:u.messageKey||"msg",onChild:u.onChild||J};T.levels=v(u),T.level=H,T.setMaxListeners=T.getMaxListeners=T.emit=T.addListener=T.on=T.prependListener=T.once=T.prependOnceListener=T.removeListener=T.removeAllListeners=T.listeners=T.listenerCount=T.eventNames=T.write=T.flush=J,T.serializers=O,T._serialize=R,T._stdErrSerialize=q,T.child=function(..._e){return ts.call(this,B,..._e)},d&&(T._logEvent=ae());function yt(){return s(this.level,this)}function Le(){return this._level}function bt(_e){if(_e!=="silent"&&!this.levels.values[_e])throw Error("unknown level "+_e);this._level=_e,y(this,B,T,"error"),y(this,B,T,"fatal"),y(this,B,T,"warn"),y(this,B,T,"info"),y(this,B,T,"debug"),y(this,B,T,"trace"),V.forEach(ve=>{y(this,B,T,ve)})}function ts(_e,ve,Qe){if(!ve)throw new Error("missing bindings for child Pino");Qe=Qe||{},R&&ve.serializers&&(Qe.serializers=ve.serializers);const ss=Qe.serializers;if(R&&ss){var wt=Object.assign({},O,ss),os=u.browser.serialize===!0?Object.keys(wt):R;delete ve.serializers,U([ve],os,wt,this._stdErrSerialize)}function rs(Tt){this._childLevel=(Tt._childLevel|0)+1,this.bindings=ve,wt&&(this.serializers=wt,this._serialize=os),d&&(this._logEvent=ae([].concat(Tt._logEvent.bindings,ve)))}rs.prototype=this;const et=new rs(this);return a(this,et),et.child=function(...Tt){return ts.call(this,_e,...Tt)},et.level=Qe.level||this.level,_e.onChild(et),et}return T}function v(u){const d=u.customLevels||{},x=Object.assign({},l.levels.values,d),O=Object.assign({},l.levels.labels,k(d));return{values:x,labels:O}}function k(u){const d={};return Object.keys(u).forEach(function(x){d[u[x]]=x}),d}l.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},l.stdSerializers=t,l.stdTimeFunctions=Object.assign({},{nullTime:j,epochTime:W,unixTime:K,isoTime:te});function h(u){const d=[];u.bindings&&d.push(u.bindings);let x=u[n];for(;x.parent;)x=x.parent,x.logger.bindings&&d.push(x.logger.bindings);return d.reverse()}function y(u,d,x,O){if(Object.defineProperty(u,O,{value:s(u.level,x)>s(O,x)?J:x[o][O],writable:!0,enumerable:!0,configurable:!0}),u[O]===J){if(!d.transmit)return;const q=d.transmit.level||u.level,V=s(q,x);if(s(O,x)<V)return}u[O]=w(u,d,x,O);const R=h(u);R.length!==0&&(u[O]=g(R,u[O]))}function g(u,d){return function(){return d.apply(this,[...u,...arguments])}}function w(u,d,x,O){return function(R){return function(){const V=d.timestamp(),F=new Array(arguments.length),H=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var T=0;T<F.length;T++)F[T]=arguments[T];var B=!1;if(d.serialize&&(U(F,this._serialize,this.serializers,this._stdErrSerialize),B=!0),d.asObject||d.formatters?R.call(H,L(this,O,F,V,d)):R.apply(H,F),d.transmit){const yt=d.transmit.level||u._level,Le=s(yt,x),bt=s(O,x);if(bt<Le)return;ie(this,{ts:V,methodLevel:O,methodValue:bt,transmitValue:x.levels.values[d.transmit.level||u._level],send:d.transmit.send,val:s(u._level,x)},F,B)}}}(u[o][O])}function L(u,d,x,O,R){const{level:q,log:V=Le=>Le}=R.formatters||{},F=x.slice();let H=F[0];const T={};if(O&&(T.time=O),q){const Le=q(d,u.levels.values[d]);Object.assign(T,Le)}else T.level=u.levels.values[d];let B=(u._childLevel|0)+1;if(B<1&&(B=1),H!==null&&typeof H=="object"){for(;B--&&typeof F[0]=="object";)Object.assign(T,F.shift());H=F.length?r(F.shift(),F):void 0}else typeof H=="string"&&(H=r(F.shift(),F));return H!==void 0&&(T[R.messageKey]=H),V(T)}function U(u,d,x,O){for(const R in u)if(O&&u[R]instanceof Error)u[R]=l.stdSerializers.err(u[R]);else if(typeof u[R]=="object"&&!Array.isArray(u[R])&&d)for(const q in u[R])d.indexOf(q)>-1&&q in x&&(u[R][q]=x[q](u[R][q]))}function ie(u,d,x,O=!1){const R=d.send,q=d.ts,V=d.methodLevel,F=d.methodValue,H=d.val,T=u._logEvent.bindings;O||U(x,u._serialize||Object.keys(u.serializers),u.serializers,u._stdErrSerialize===void 0?!0:u._stdErrSerialize),u._logEvent.ts=q,u._logEvent.messages=x.filter(function(B){return T.indexOf(B)===-1}),u._logEvent.level.label=V,u._logEvent.level.value=F,R(V,u._logEvent,H),u._logEvent=ae(T)}function ae(u){return{ts:0,messages:[],bindings:u||[],level:{label:"",value:0}}}function Te(u){const d={type:u.constructor.name,msg:u.message,stack:u.stack};for(const x in u)d[x]===void 0&&(d[x]=u[x]);return d}function pe(u){return typeof u.timestamp=="function"?u.timestamp:u.timestamp===!1?j:W}function C(){return{}}function Y(u){return u}function J(){}function j(){return!1}function W(){return Date.now()}function K(){return Math.round(Date.now()/1e3)}function te(){return new Date(Date.now()).toISOString()}function Z(){function u(d){return typeof d<"u"&&d}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return u(self)||u(window)||u(this)||{}}}return tt.exports.default=l,tt.exports.pino=l,tt.exports}var br=yr();const Et=vr(br);class X{pino;useTerminalFormat;static instance;constructor(e={}){this.useTerminalFormat=e.useTerminalFormat??!0;const t=e.debug?"debug":e.verbose?"trace":"info";e.silent?this.pino=Et({level:"silent"}):e.logFile||e.logDir?this.pino=this.createMultiTransportLogger(t,e):this.useTerminalFormat&&process.stdout.isTTY?this.pino=Et({level:t,transport:{target:"pino-pretty",options:{colorize:!0,ignore:"pid,hostname",translateTime:"HH:MM:ss",messageFormat:"{msg}"}}}):this.pino=Et({level:t})}createMultiTransportLogger(e,t){let s;if(t.logFile)s=t.logFile;else if(t.logDir){Pe.existsSync(t.logDir)||Pe.mkdirSync(t.logDir,{recursive:!0});const n=new Date().toISOString().split("T")[0];s=be.join(t.logDir,`app-${n}.log`)}else{const n=be.join(Yt.tmpdir(),"agiflow-agents","logs",`session-${process.pid}`);Pe.existsSync(n)||Pe.mkdirSync(n,{recursive:!0});const i=new Date().toISOString().split("T")[0];s=be.join(n,`app-${i}.log`)}const o=[];return this.useTerminalFormat&&process.stdout.isTTY?o.push({level:e,target:"pino-pretty",options:{destination:1,colorize:!0,ignore:"pid,hostname",translateTime:"HH:MM:ss",messageFormat:"{msg}"}}):o.push({level:e,target:"pino/file",options:{destination:1}}),t.maxFileSize||t.maxFiles?o.push({level:e,target:"pino-roll",options:{file:s,frequency:"daily",size:t.maxFileSize||"10m",limit:{count:t.maxFiles||7},symlink:!0,mkdir:!0}}):o.push({level:e,target:"pino/file",options:{destination:s,mkdir:!0}}),Et({level:e,transport:{targets:o}})}static getInstance(){return X.instance||(X.instance=new X),X.instance}static configure(e){X.instance=new X(e)}getLogFilePath(){const e=this.pino.transports;if(e&&Array.isArray(e)){const t=e.find(s=>s.target==="pino/file"||s.target==="pino-roll");if(t&&t.options)return t.options.destination||t.options.file}}info(e,...t){this.useTerminalFormat&&process.stdout.isTTY?console.log(G.blue("ℹ"),e,...t):this.pino.info(e,...t)}static info(e,...t){X.getInstance().info(e,...t)}success(e,...t){this.useTerminalFormat&&process.stdout.isTTY?console.log(G.green("✓"),e,...t):this.pino.info({type:"success"},e,...t)}static success(e,...t){X.getInstance().success(e,...t)}warn(e,...t){this.useTerminalFormat&&process.stdout.isTTY?console.warn(G.yellow("⚠"),e,...t):this.pino.warn(e,...t)}static warn(e,...t){X.getInstance().warn(e,...t)}error(e,t,s){let o,n;t instanceof Error?(o=t,n=s):n=t,this.useTerminalFormat&&process.stdout.isTTY?console.error(G.red("✗"),e,o||""):o?this.pino.error(o,e):this.pino.error(e),n?.exit!==void 0&&process.exit(n.exit)}static error(e,t){X.getInstance().error(e,void 0,t)}debug(e,...t){this.useTerminalFormat&&process.stdout.isTTY?(ee.isDebugMode||this.pino.level==="debug"||this.pino.level==="trace")&&console.log(G.gray("🔍"),G.gray(e),...t):this.pino.debug(e,...t)}static debug(e,...t){X.getInstance().debug(e,...t)}trace(e,...t){this.useTerminalFormat&&process.stdout.isTTY?this.pino.level==="trace"&&console.log(G.gray("..."),G.gray(e),...t):this.pino.trace(e,...t)}title(e){this.useTerminalFormat&&process.stdout.isTTY?(console.log(),console.log(G.bold.cyan(e)),console.log(G.cyan("=".repeat(e.length)))):this.pino.info({type:"title"},e)}static title(e){X.getInstance().title(e)}code(e){this.useTerminalFormat&&process.stdout.isTTY?(console.log(),console.log(G.gray(" "+e)),console.log()):this.pino.info({type:"code",code:e},"Code example")}static code(e){X.getInstance().code(e)}newLine(){this.useTerminalFormat&&process.stdout.isTTY&&console.log()}static newLine(){X.getInstance().newLine()}terminal(e,t,...s){if(!process.stdout.isTTY){this.pino[e==="success"||e==="title"||e==="code"?"info":e](t,...s);return}switch(e){case"info":console.log(G.blue("ℹ"),t,...s);break;case"success":console.log(G.green("✓"),t,...s);break;case"warn":console.warn(G.yellow("⚠"),t,...s);break;case"error":console.error(G.red("✗"),t,...s);break;case"debug":console.log(G.gray("🔍"),G.gray(t),...s);break;case"title":console.log(),console.log(G.bold.cyan(t)),console.log(G.cyan("=".repeat(t.length)));break;case"code":console.log(),console.log(G.gray(" "+t)),console.log();break}}getPino(){return this.pino}child(e){const t=new X({useTerminalFormat:this.useTerminalFormat});return t.pino=this.pino.child(e),t}}class Ee{static AGIFLOW_DIR=je.join(Ft.homedir(),".agiflow");static async ensureDir(e){await Se.ensureDir(e)}static async exists(e){try{return await Se.access(e),!0}catch{return!1}}static async readJson(e){const t=await Se.readFile(e,"utf-8");return JSON.parse(t)}static async writeJson(e,t,s){await Se.ensureDir(je.dirname(e));const o=JSON.stringify(t,null,s?.spaces??2);await Se.writeFile(e,o,"utf-8")}static async copy(e,t){await Se.copy(e,t)}static async remove(e){await Se.remove(e)}static getCurrentDirectory(){return process.cwd()}static resolvePath(...e){return je.resolve(process.cwd(),...e)}static async getFiles(e,t){const s=await Se.readdir(e);return t?s.filter(o=>t.test(o)):s}static getAbsolutePath(e){return e?e.startsWith("~/")?je.join(Ft.homedir(),e.slice(2)):e==="~"?Ft.homedir():je.isAbsolute(e)?e:je.resolve(process.cwd(),e):process.cwd()}}class wr{filePath;cache=null;dirty=!1;constructor(e){this.filePath=e||je.join(Ee.AGIFLOW_DIR,"credentials.json")}async load(){if(this.cache)return this.cache;try{if(!await Ee.exists(this.filePath))return null;const t=await Ee.readJson(this.filePath);return this.cache=t,t}catch{return null}}async flush(){!this.dirty||!this.cache||(await Ee.ensureDir(Ee.AGIFLOW_DIR),await Ee.writeJson(this.filePath,this.cache),this.dirty=!1)}async setApiKey(e){this.cache={apiKey:e.apiKey,organizationId:e.organizationId,deviceId:e.deviceId||this.cache?.deviceId,expiresAt:e.expiresAt},this.dirty=!0,await this.flush()}async setDeviceId(e){const t=await this.load()||{apiKey:"",organizationId:""};t.deviceId=e,this.cache=t,this.dirty=!0,await this.flush()}async getApiKey(){return(await this.load())?.apiKey||null}async getAgentCreds(){const e=await this.load();if(!e)throw new Error("Cred not set");return{apiKey:e.apiKey,organizationId:e.organizationId,deviceId:e.deviceId}}async getOrganizationId(){return(await this.load())?.organizationId||null}async getDeviceId(){return(await this.load())?.deviceId||null}async isExpired(e=300*1e3){const t=await this.load();return t?.expiresAt?Date.now()>=t.expiresAt-e:!1}async clear(){this.cache=null,this.dirty=!1;try{await Ee.exists(this.filePath)&&await Ee.remove(this.filePath)}catch{}}async buildAuthHeaders(){const e=await this.load();return e?.apiKey?{"x-api-key":e.apiKey}:{}}async buildDeviceAuthHeaders(e){const t=await this.load();if(!t?.apiKey)return{};const s={"x-api-key":t.apiKey};return e&&(s["x-device-guid"]=e),t.deviceId&&(s["x-device-id"]=t.deviceId),t.organizationId&&(s["x-organization-id"]=t.organizationId),s}async buildAgentAuthHeaders(e){let t=e;if(t||(t=await this.getApiKey()||void 0),t||(t=ee.apiKey),!t)return{};const s={"x-api-key":t,"Content-Type":"application/json"},o=await this.getOrganizationId();o&&(s["x-organization-id"]=o);const n=await this.getDeviceId();return n&&(s["x-device-id"]=n),s}}M({limit:ge().min(1).max(100).optional(),offset:ge().min(0).optional(),messageType:es.optional(),sort:N().optional(),order:Pt(["asc","desc"]).optional()});class Tr{options;authService;credentials;logger;constructor(e){this.options=e,this.authService=e.authService,this.credentials=e.credentials??new wr,this.logger=e.logger??new X({verbose:!1})}async getAuthHeaders(){let e=await this.credentials.getApiKey(),t=await this.credentials.getOrganizationId();if((!e||!t)&&this.authService){const o=await this.authService.getValidApiKey();e=o.api_key,t=o.organization_id,await this.credentials.setApiKey({apiKey:e,organizationId:t,expiresAt:o.expires_at})}if(!e&&this.options.apiKey&&(e=this.options.apiKey),!t&&this.options.organizationId&&(t=this.options.organizationId),e&&t)return this.options.organizationId=t,{"Content-Type":"application/json","x-api-key":e};const s=this.options.authToken;if(!s)throw new Error("Authentication token is required for agent message operations");if(!this.options.organizationId)throw new Error("Organization ID is required for agent message operations");return{"Content-Type":"application/json",Authorization:`Bearer ${s}`}}async makeAuthenticatedRequest(e,t,s=!0){const o=await fetch(e,t);if(o.status===401&&s&&this.authService){const n=await o.text();if(n.includes("Invalid API key")){this.logger.info("= API key expired or invalid, clearing tokens and retrying authentication..."),await this.authService.clearTokens();try{await this.credentials.clear()}catch{}this.logger.info("= Retrying authentication...");const i=await this.getAuthHeaders(),a={...t,headers:{...t.headers,...i}};return await this.makeAuthenticatedRequest(e,a,!1)}if(n.includes("Invalid or expired session")){const i=ee.isContainerMode;if(this.logger.error("🚫 Session validation failed:",new Error(`Session validation failed for ${e}. Docker mode: ${i}, Method: ${t.method||"GET"}, Timestamp: ${new Date().toISOString()}`)),i)return this.logger.warn("🐳 Docker session timing issue detected, waiting and retrying..."),await new Promise(a=>setTimeout(a,2e3)),await this.makeAuthenticatedRequest(e,t,!1)}}return o.status===429&&this.logger.warn("= Rate limit exceeded, keeping credentials but not retrying"),o}async sendMessage(e){const t=await this.getAuthHeaders(),s=this.options.organizationId;if(!s)throw new Error("Organization ID is required for sending agent messages");const o=us(e);try{Ls.parse(o)}catch(n){throw new Error(`Invalid message payload: ${n instanceof Error?n.message:n}`)}try{const n=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${s}/agent-sessions/${e.sessionId}/messages`,{method:"POST",headers:t,body:JSON.stringify(o)});if(!n.ok){const a=await n.text();throw new Error(`Failed to send agent message: ${n.status} ${a}`)}return await n.json()}catch(n){throw new Error(`Failed to send agent message: ${n instanceof Error?n.message:n}`)}}async sendMessageBatch(e,t){const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)throw new Error("Organization ID is required for sending agent messages");const n=t.map(i=>us(i));try{const i=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${o}/agent-sessions/${e}/messages/batch`,{method:"POST",headers:s,body:JSON.stringify({messages:n})});if(!i.ok){const p=await i.text();throw new Error(`Failed to send agent message batch: ${i.status} ${p}`)}return await i.json()}catch(i){throw new Error(`Failed to send agent message batch: ${i instanceof Error?i.message:i}`)}}async getSessionMessages(e,t){const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)throw new Error("Organization ID is required for fetching agent messages");const n=new URLSearchParams;t?.limit&&n.append("limit",t.limit.toString()),t?.offset&&n.append("offset",t.offset.toString()),t?.messageType&&n.append("messageType",t.messageType),t?.sort&&n.append("sort",t.sort),t?.order&&n.append("order",t.order);const i=`${this.options.apiUrl}/api/v1/organizations/${o}/agent-sessions/${e}/messages?${n.toString()}`;try{const a=await this.makeAuthenticatedRequest(i,{method:"GET",headers:s});if(!a.ok){const _=await a.text();throw new Error(`Failed to fetch session messages: ${a.status} ${_}`)}return await a.json()}catch(a){throw new Error(`Failed to fetch session messages: ${a instanceof Error?a.message:a}`)}}async uploadMessageContent(e,t,s,o){const n=await this.getAuthHeaders(),i=this.options.organizationId;if(!i)throw new Error("Organization ID is required for uploading message content");const a=typeof s=="string"?Buffer.from(s,"utf-8"):s,p=a.length;try{const _=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${i}/agent-sessions/${e}/messages/presign`,{method:"POST",headers:n,body:JSON.stringify({messageType:t,contentSize:p})});if(!_.ok){const h=await _.text();throw new Error(`Failed to get presigned URL: ${_.status} ${h}`)}const{uploadUrl:l}=await _.json(),v=await fetch(l,{method:"PUT",body:a,headers:{"Content-Type":"application/octet-stream","Content-Length":p.toString()}});if(!v.ok)throw new Error(`Failed to upload content to R2: ${v.status}`);const k={sessionId:e,messageType:t,contentSize:p,metadata:o};return await this.sendMessage(k)}catch(_){throw new Error(`Failed to upload message content: ${_ instanceof Error?_.message:_}`)}}async startMessage(e,t){const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)throw new Error("Organization ID is required for starting agent messages");try{rr.parse(t)}catch(n){throw new Error(`Invalid start message payload: ${n instanceof Error?n.message:n}`)}try{const n=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${o}/agent-sessions/${e}/messages/start`,{method:"POST",headers:s,body:JSON.stringify(t)});if(!n.ok){const a=await n.text();throw new Error(`Failed to start agent message: ${n.status} ${a}`)}return await n.json()}catch(n){throw new Error(`Failed to start agent message: ${n instanceof Error?n.message:n}`)}}async updateMessage(e,t,s){const o=await this.getAuthHeaders(),n=this.options.organizationId;if(!n)throw new Error("Organization ID is required for updating agent messages");try{nr.parse(s)}catch(a){throw this.logger.error("=❌ Update message validation failed",new Error(`Update message validation failed: ${a instanceof Error?a.message:a}`)),new Error(`Invalid update message payload: ${a instanceof Error?a.message:a}`)}const i=JSON.stringify(s);try{const a=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${n}/agent-sessions/${e}/messages/${t}`,{method:"PATCH",headers:o,body:i});if(!a.ok){const _=await a.text();throw new Error(`Failed to update agent message: ${a.status} ${_}`)}return await a.json()}catch(a){throw new Error(`Failed to update agent message: ${a instanceof Error?a.message:a}`)}}async deleteSessionMessages(e){const t=await this.getAuthHeaders(),s=this.options.organizationId;if(!s)throw new Error("Organization ID is required for deleting session messages");this.logger.info(`=� Deleting all messages for session ${e}...`);try{const o=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${s}/agent-sessions/${e}/messages`,{method:"DELETE",headers:t},!1);if(!o.ok){const i=await o.text().catch(()=>"Unknown error");return this.logger.warn(`� Failed to delete session messages: ${o.status} ${i}`),0}const{deletedCount:n}=await o.json();return this.logger.success(` Deleted ${n} messages for session ${e}`),n}catch(o){return this.logger.warn("� Failed to delete session messages:",o),0}}async getAgentSession(e){const t=await this.getAuthHeaders(),s=this.options.organizationId;if(!s)throw new Error("Organization ID is required for fetching agent session");try{const o=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${s}/agent-sessions/${e}`,{method:"GET",headers:t});if(!o.ok){const i=await o.text();throw new Error(`Failed to fetch agent session: ${o.status} ${i}`)}return await o.json()}catch(o){throw new Error(`Failed to fetch agent session: ${o instanceof Error?o.message:o}`)}}async createTaskComment(e,t,s,o){try{const n=await this.getAuthHeaders(),i=this.options.organizationId;if(!i)return this.logger.warn("Organization ID is required for creating task comment"),null;const a=t&&t.length>1e4?t.substring(0,1e4):t,p=await this.getAgentSession(e);if(!p)return this.logger.warn("Agent session not found for task comment creation"),null;if(!p.taskId)return this.logger.debug("Agent session has no associated task - skipping comment creation"),null;const _=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${i}/tasks/${p.taskId}/comments`,{method:"POST",headers:n,body:JSON.stringify({content:a,assigneeId:s,info:o})});if(!_.ok){const v=await _.text();return this.logger.warn(`Failed to create task comment: ${_.status} ${v}`),null}const l=await _.json();return this.logger.debug("Task comment created successfully"),l}catch(n){return this.logger.warn(`Failed to create task comment: ${n instanceof Error?n.message:n}`),null}}async updateTaskDevInfo(e,t){try{const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)return this.logger.warn("Organization ID is required for updating task devInfo"),null;const n=await this.getAgentSession(e);if(!n)return this.logger.warn("Agent session not found for task devInfo update"),null;if(!n.taskId)return this.logger.debug("Agent session has no associated task - skipping devInfo update"),null;const i=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${o}/tasks/${n.taskId}`,{method:"PATCH",headers:s,body:JSON.stringify({devInfo:t})});if(!i.ok){const p=await i.text();return this.logger.warn(`Failed to update task devInfo: ${i.status} ${p}`),null}const a=await i.json();return this.logger.debug("Task devInfo updated successfully"),a}catch(s){return this.logger.warn(`Failed to update task devInfo: ${s instanceof Error?s.message:s}`),null}}}class Sr{logger;agentHttpService=null;interceptor;llmProvider;maxBodyBytes;sessionId;constructor(){const e=ee.netlogMaxBody;this.maxBodyBytes=e||8192,this.sessionId=ee.sessionId||"",this.llmProvider=new Cs;const t=ee.netlogFile||be.join(Yt.tmpdir(),"agiflow-agents","network",`network-${process.pid}.log`);this.logger=new st(t);let s=ee.serverUrl||"";s.startsWith("wss://")?s="https://"+s.slice(6):s.startsWith("ws://")&&(s="http://"+s.slice(5));const o=ee.apiKey||"",n=ee.organizationId||"";if(ee.isNetlogRemoteEnabled&&!!(this.sessionId&&s)&&s)try{this.agentHttpService=new Tr({apiUrl:s,organizationId:n,apiKey:o,logger:this.logger})}catch(a){st.shouldDebug()&&this.logger.error("AgentHttpService initialization failed",a)}this.interceptor=Ze.getInstance({maxBodyBytes:this.maxBodyBytes,enableDebug:ee.isDebugMode||ee.isNetlogDebug,llmProvider:this.llmProvider,idGenerator:ys.ulid,agentHttpService:this.agentHttpService||void 0,sessionId:this.sessionId})}start(){this.interceptor.start()}}const Er=new Sr;Er.start();
410
+ `)+t,o=s+1,s=n.indexOf(`
411
+ `,o)}while(s!==-1);return r+=n.slice(o),r}const{stdout:ks,stderr:vs}=kr,Kt=Symbol("GENERATOR"),Qe=Symbol("STYLER"),vt=Symbol("IS_EMPTY"),ys=["ansi","ansi","ansi256","ansi16m"],et=Object.create(null),xr=(n,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const t=ks?ks.level:0;n.level=e.level===void 0?t:e.level},br=n=>{const e=(...t)=>t.join(" ");return xr(e,n),Object.setPrototypeOf(e,wt.prototype),e};function wt(n){return br(n)}Object.setPrototypeOf(wt.prototype,Function.prototype);for(const[n,e]of Object.entries(ge))et[n]={get(){const t=Pt(this,Qt(e.open,e.close,this[Qe]),this[vt]);return Object.defineProperty(this,n,{value:t}),t}};et.visible={get(){const n=Pt(this,this[Qe],!0);return Object.defineProperty(this,"visible",{value:n}),n}};const Xt=(n,e,t,...s)=>n==="rgb"?e==="ansi16m"?ge[t].ansi16m(...s):e==="ansi256"?ge[t].ansi256(ge.rgbToAnsi256(...s)):ge[t].ansi(ge.rgbToAnsi(...s)):n==="hex"?Xt("rgb",e,t,...ge.hexToRgb(...s)):ge[t][n](...s),wr=["rgb","hex","ansi256"];for(const n of wr){et[n]={get(){const{level:t}=this;return function(...s){const o=Qt(Xt(n,ys[t],"color",...s),ge.color.close,this[Qe]);return Pt(this,o,this[vt])}}};const e="bg"+n[0].toUpperCase()+n.slice(1);et[e]={get(){const{level:t}=this;return function(...s){const o=Qt(Xt(n,ys[t],"bgColor",...s),ge.bgColor.close,this[Qe]);return Pt(this,o,this[vt])}}}}const Sr=Object.defineProperties(()=>{},{...et,level:{enumerable:!0,get(){return this[Kt].level},set(n){this[Kt].level=n}}}),Qt=(n,e,t)=>{let s,o;return t===void 0?(s=n,o=e):(s=t.openAll+n,o=e+t.closeAll),{open:n,close:e,openAll:s,closeAll:o,parent:t}},Pt=(n,e,t)=>{const s=(...o)=>Tr(s,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(s,Sr),s[Kt]=n,s[Qe]=e,s[vt]=t,s},Tr=(n,e)=>{if(n.level<=0||!e)return n[vt]?"":e;let t=n[Qe];if(t===void 0)return e;const{openAll:s,closeAll:o}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=vr(e,t.close,t.open),t=t.parent;const r=e.indexOf(`
412
+ `);return r!==-1&&(e=yr(e,o,s,r)),s+e+o};Object.defineProperties(wt.prototype,et);const K=wt();wt({level:vs?vs.level:0});function Er(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ot={exports:{}},Vt,xs;function Ir(){if(xs)return Vt;xs=1;function n(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}Vt=e;function e(t,s,o){var r=o&&o.stringify||n,i=1;if(typeof t=="object"&&t!==null){var a=s.length+i;if(a===1)return t;var p=new Array(a);p[0]=r(t);for(var u=1;u<a;u++)p[u]=r(s[u]);return p.join(" ")}if(typeof t!="string")return t;var c=s.length;if(c===0)return t;for(var g="",v=1-i,d=-1,m=t&&t.length||0,h=0;h<m;){if(t.charCodeAt(h)===37&&h+1<m){switch(d=d>-1?d:0,t.charCodeAt(h+1)){case 100:case 102:if(v>=c||s[v]==null)break;d<h&&(g+=t.slice(d,h)),g+=Number(s[v]),d=h+2,h++;break;case 105:if(v>=c||s[v]==null)break;d<h&&(g+=t.slice(d,h)),g+=Math.floor(Number(s[v])),d=h+2,h++;break;case 79:case 111:case 106:if(v>=c||s[v]===void 0)break;d<h&&(g+=t.slice(d,h));var w=typeof s[v];if(w==="string"){g+="'"+s[v]+"'",d=h+2,h++;break}if(w==="function"){g+=s[v].name||"<anonymous>",d=h+2,h++;break}g+=r(s[v]),d=h+2,h++;break;case 115:if(v>=c)break;d<h&&(g+=t.slice(d,h)),g+=String(s[v]),d=h+2,h++;break;case 37:d<h&&(g+=t.slice(d,h)),g+="%",d=h+2,h++,v--;break}++v}++h}return d===-1?t:(d<m&&(g+=t.slice(d)),g)}return Vt}var bs;function Ar(){if(bs)return ot.exports;bs=1;const n=Ir();ot.exports=c;const e=ne().console||{},t={mapHttpRequest:I,mapHttpResponse:I,wrapRequestSerializer:G,wrapResponseSerializer:G,wrapErrorSerializer:G,req:I,res:I,err:F,errWithCause:F};function s(_,k){return _==="silent"?1/0:k.levels.values[_]}const o=Symbol("pino.logFuncs"),r=Symbol("pino.hierarchy"),i={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function a(_,k){const x={logger:k,parent:_[r]};k[r]=x}function p(_,k,x){const R={};k.forEach(N=>{R[N]=x[N]?x[N]:e[N]||e[i[N]||"log"]||se}),_[o]=R}function u(_,k){return Array.isArray(_)?_.filter(function(R){return R!=="!stdSerializers.err"}):_===!0?Object.keys(k):!1}function c(_){_=_||{},_.browser=_.browser||{};const k=_.browser.transmit;if(k&&typeof k.send!="function")throw Error("pino: transmit option must have a send function");const x=_.browser.write||e;_.browser.write&&(_.browser.asObject=!0);const R=_.serializers||{},N=u(_.browser.serialize,R);let W=_.browser.serialize;Array.isArray(_.browser.serialize)&&_.browser.serialize.indexOf("!stdSerializers.err")>-1&&(W=!1);const Y=Object.keys(_.customLevels||{}),B=["error","fatal","warn","info","debug","trace"].concat(Y);typeof x=="function"&&B.forEach(function(ce){x[ce]=x}),(_.enabled===!1||_.browser.disabled)&&(_.level="silent");const ee=_.level||"info",S=Object.create(x);S.log||(S.log=se),p(S,B,x),a({},S),Object.defineProperty(S,"levelVal",{get:St}),Object.defineProperty(S,"level",{get:je,set:Tt});const Z={transmit:k,serialize:N,asObject:_.browser.asObject,formatters:_.browser.formatters,levels:B,timestamp:H(_),messageKey:_.messageKey||"msg",onChild:_.onChild||se};S.levels=g(_),S.level=ee,S.setMaxListeners=S.getMaxListeners=S.emit=S.addListener=S.on=S.prependListener=S.once=S.prependOnceListener=S.removeListener=S.removeAllListeners=S.listeners=S.listenerCount=S.eventNames=S.write=S.flush=se,S.serializers=R,S._serialize=N,S._stdErrSerialize=W,S.child=function(...ce){return os.call(this,Z,...ce)},k&&(S._logEvent=j());function St(){return s(this.level,this)}function je(){return this._level}function Tt(ce){if(ce!=="silent"&&!this.levels.values[ce])throw Error("unknown level "+ce);this._level=ce,m(this,Z,S,"error"),m(this,Z,S,"fatal"),m(this,Z,S,"warn"),m(this,Z,S,"info"),m(this,Z,S,"debug"),m(this,Z,S,"trace"),Y.forEach(we=>{m(this,Z,S,we)})}function os(ce,we,tt){if(!we)throw new Error("missing bindings for child Pino");tt=tt||{},N&&we.serializers&&(tt.serializers=we.serializers);const rs=tt.serializers;if(N&&rs){var Et=Object.assign({},R,rs),ns=_.browser.serialize===!0?Object.keys(Et):N;delete we.serializers,C([we],ns,Et,this._stdErrSerialize)}function is(It){this._childLevel=(It._childLevel|0)+1,this.bindings=we,Et&&(this.serializers=Et,this._serialize=ns),k&&(this._logEvent=j([].concat(It._logEvent.bindings,we)))}is.prototype=this;const st=new is(this);return a(this,st),st.child=function(...It){return os.call(this,ce,...It)},st.level=tt.level||this.level,ce.onChild(st),st}return S}function g(_){const k=_.customLevels||{},x=Object.assign({},c.levels.values,k),R=Object.assign({},c.levels.labels,v(k));return{values:x,labels:R}}function v(_){const k={};return Object.keys(_).forEach(function(x){k[_[x]]=x}),k}c.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},c.stdSerializers=t,c.stdTimeFunctions=Object.assign({},{nullTime:$,epochTime:Q,unixTime:V,isoTime:ae});function d(_){const k=[];_.bindings&&k.push(_.bindings);let x=_[r];for(;x.parent;)x=x.parent,x.logger.bindings&&k.push(x.logger.bindings);return k.reverse()}function m(_,k,x,R){if(Object.defineProperty(_,R,{value:s(_.level,x)>s(R,x)?se:x[o][R],writable:!0,enumerable:!0,configurable:!0}),_[R]===se){if(!k.transmit)return;const W=k.transmit.level||_.level,Y=s(W,x);if(s(R,x)<Y)return}_[R]=w(_,k,x,R);const N=d(_);N.length!==0&&(_[R]=h(N,_[R]))}function h(_,k){return function(){return k.apply(this,[..._,...arguments])}}function w(_,k,x,R){return function(N){return function(){const Y=k.timestamp(),B=new Array(arguments.length),ee=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var S=0;S<B.length;S++)B[S]=arguments[S];var Z=!1;if(k.serialize&&(C(B,this._serialize,this.serializers,this._stdErrSerialize),Z=!0),k.asObject||k.formatters?N.call(ee,L(this,R,B,Y,k)):N.apply(ee,B),k.transmit){const St=k.transmit.level||_._level,je=s(St,x),Tt=s(R,x);if(Tt<je)return;J(this,{ts:Y,methodLevel:R,methodValue:Tt,transmitValue:x.levels.values[k.transmit.level||_._level],send:k.transmit.send,val:s(_._level,x)},B,Z)}}}(_[o][R])}function L(_,k,x,R,N){const{level:W,log:Y=je=>je}=N.formatters||{},B=x.slice();let ee=B[0];const S={};if(R&&(S.time=R),W){const je=W(k,_.levels.values[k]);Object.assign(S,je)}else S.level=_.levels.values[k];let Z=(_._childLevel|0)+1;if(Z<1&&(Z=1),ee!==null&&typeof ee=="object"){for(;Z--&&typeof B[0]=="object";)Object.assign(S,B.shift());ee=B.length?n(B.shift(),B):void 0}else typeof ee=="string"&&(ee=n(B.shift(),B));return ee!==void 0&&(S[N.messageKey]=ee),Y(S)}function C(_,k,x,R){for(const N in _)if(R&&_[N]instanceof Error)_[N]=c.stdSerializers.err(_[N]);else if(typeof _[N]=="object"&&!Array.isArray(_[N])&&k)for(const W in _[N])k.indexOf(W)>-1&&W in x&&(_[N][W]=x[W](_[N][W]))}function J(_,k,x,R=!1){const N=k.send,W=k.ts,Y=k.methodLevel,B=k.methodValue,ee=k.val,S=_._logEvent.bindings;R||C(x,_._serialize||Object.keys(_.serializers),_.serializers,_._stdErrSerialize===void 0?!0:_._stdErrSerialize),_._logEvent.ts=W,_._logEvent.messages=x.filter(function(Z){return S.indexOf(Z)===-1}),_._logEvent.level.label=Y,_._logEvent.level.value=B,N(Y,_._logEvent,ee),_._logEvent=j(S)}function j(_){return{ts:0,messages:[],bindings:_||[],level:{label:"",value:0}}}function F(_){const k={type:_.constructor.name,msg:_.message,stack:_.stack};for(const x in _)k[x]===void 0&&(k[x]=_[x]);return k}function H(_){return typeof _.timestamp=="function"?_.timestamp:_.timestamp===!1?$:Q}function I(){return{}}function G(_){return _}function se(){}function $(){return!1}function Q(){return Date.now()}function V(){return Math.round(Date.now()/1e3)}function ae(){return new Date(Date.now()).toISOString()}function ne(){function _(k){return typeof k<"u"&&k}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return _(self)||_(window)||_(this)||{}}}return ot.exports.default=c,ot.exports.pino=c,ot.exports}var Cr=Ar();const Ct=Er(Cr);class oe{pino;useTerminalFormat;static instance;constructor(e={}){this.useTerminalFormat=e.useTerminalFormat??!0;const t=e.debug?"debug":e.verbose?"trace":"info";e.silent?this.pino=Ct({level:"silent"}):e.logFile||e.logDir?this.pino=this.createMultiTransportLogger(t,e):this.useTerminalFormat&&process.stdout.isTTY?this.pino=Ct({level:t,transport:{target:"pino-pretty",options:{colorize:!0,ignore:"pid,hostname",translateTime:"HH:MM:ss",messageFormat:"{msg}"}}}):this.pino=Ct({level:t})}createMultiTransportLogger(e,t){let s;if(t.logFile)s=t.logFile;else if(t.logDir){ke.existsSync(t.logDir)||ke.mkdirSync(t.logDir,{recursive:!0});const r=new Date().toISOString().split("T")[0];s=fe.join(t.logDir,`app-${r}.log`)}else{const r=fe.join(jt.tmpdir(),"agiflow-agents","logs",`session-${process.pid}`);ke.existsSync(r)||ke.mkdirSync(r,{recursive:!0});const i=new Date().toISOString().split("T")[0];s=fe.join(r,`app-${i}.log`)}const o=[];return this.useTerminalFormat&&process.stdout.isTTY?o.push({level:e,target:"pino-pretty",options:{destination:1,colorize:!0,ignore:"pid,hostname",translateTime:"HH:MM:ss",messageFormat:"{msg}"}}):o.push({level:e,target:"pino/file",options:{destination:1}}),t.maxFileSize||t.maxFiles?o.push({level:e,target:"pino-roll",options:{file:s,frequency:"daily",size:t.maxFileSize||"10m",limit:{count:t.maxFiles||7},symlink:!0,mkdir:!0}}):o.push({level:e,target:"pino/file",options:{destination:s,mkdir:!0}}),Ct({level:e,transport:{targets:o}})}static getInstance(){return oe.instance||(oe.instance=new oe),oe.instance}static configure(e){oe.instance=new oe(e)}getLogFilePath(){const e=this.pino.transports;if(e&&Array.isArray(e)){const t=e.find(s=>s.target==="pino/file"||s.target==="pino-roll");if(t&&t.options)return t.options.destination||t.options.file}}info(e,...t){this.useTerminalFormat&&process.stdout.isTTY?console.log(K.blue("ℹ"),e,...t):this.pino.info(e,...t)}static info(e,...t){oe.getInstance().info(e,...t)}success(e,...t){this.useTerminalFormat&&process.stdout.isTTY?console.log(K.green("✓"),e,...t):this.pino.info({type:"success"},e,...t)}static success(e,...t){oe.getInstance().success(e,...t)}warn(e,...t){this.useTerminalFormat&&process.stdout.isTTY?console.warn(K.yellow("⚠"),e,...t):this.pino.warn(e,...t)}static warn(e,...t){oe.getInstance().warn(e,...t)}error(e,t,s){let o,r;t instanceof Error?(o=t,r=s):r=t,this.useTerminalFormat&&process.stdout.isTTY?console.error(K.red("✗"),e,o||""):o?this.pino.error(o,e):this.pino.error(e),r?.exit!==void 0&&process.exit(r.exit)}static error(e,t){oe.getInstance().error(e,void 0,t)}debug(e,...t){this.useTerminalFormat&&process.stdout.isTTY?(te.isDebugMode||this.pino.level==="debug"||this.pino.level==="trace")&&console.log(K.gray("🔍"),K.gray(e),...t):this.pino.debug(e,...t)}static debug(e,...t){oe.getInstance().debug(e,...t)}trace(e,...t){this.useTerminalFormat&&process.stdout.isTTY?this.pino.level==="trace"&&console.log(K.gray("..."),K.gray(e),...t):this.pino.trace(e,...t)}title(e){this.useTerminalFormat&&process.stdout.isTTY?(console.log(),console.log(K.bold.cyan(e)),console.log(K.cyan("=".repeat(e.length)))):this.pino.info({type:"title"},e)}static title(e){oe.getInstance().title(e)}code(e){this.useTerminalFormat&&process.stdout.isTTY?(console.log(),console.log(K.gray(" "+e)),console.log()):this.pino.info({type:"code",code:e},"Code example")}static code(e){oe.getInstance().code(e)}newLine(){this.useTerminalFormat&&process.stdout.isTTY&&console.log()}static newLine(){oe.getInstance().newLine()}terminal(e,t,...s){if(!process.stdout.isTTY){this.pino[e==="success"||e==="title"||e==="code"?"info":e](t,...s);return}switch(e){case"info":console.log(K.blue("ℹ"),t,...s);break;case"success":console.log(K.green("✓"),t,...s);break;case"warn":console.warn(K.yellow("⚠"),t,...s);break;case"error":console.error(K.red("✗"),t,...s);break;case"debug":console.log(K.gray("🔍"),K.gray(t),...s);break;case"title":console.log(),console.log(K.bold.cyan(t)),console.log(K.cyan("=".repeat(t.length)));break;case"code":console.log(),console.log(K.gray(" "+t)),console.log();break}}getPino(){return this.pino}child(e){const t=new oe({useTerminalFormat:this.useTerminalFormat});return t.pino=this.pino.child(e),t}}class Or{filePath;cache=null;dirty=!1;constructor(e){this.filePath=e||Oe.join(X.AGIFLOW_DIR,"credentials.json")}async load(){if(this.cache)return this.cache;try{if(!await X.exists(this.filePath))return null;const t=await X.readJson(this.filePath);return this.cache=t,t}catch{return null}}async flush(){!this.dirty||!this.cache||(await X.ensureDir(X.AGIFLOW_DIR),await X.writeJson(this.filePath,this.cache),this.dirty=!1)}async setApiKey(e){this.cache={apiKey:e.apiKey,organizationId:e.organizationId,deviceId:e.deviceId||this.cache?.deviceId,expiresAt:e.expiresAt},this.dirty=!0,await this.flush()}async setDeviceId(e){const t=await this.load()||{apiKey:"",organizationId:""};t.deviceId=e,this.cache=t,this.dirty=!0,await this.flush()}async getApiKey(){return(await this.load())?.apiKey||null}async getAgentCreds(){const e=await this.load();if(!e)throw new Error("Cred not set");return{apiKey:e.apiKey,organizationId:e.organizationId,deviceId:e.deviceId}}async getOrganizationId(){return(await this.load())?.organizationId||null}async getDeviceId(){return(await this.load())?.deviceId||null}async isExpired(e=300*1e3){const t=await this.load();return t?.expiresAt?Date.now()>=t.expiresAt-e:!1}async clear(){this.cache=null,this.dirty=!1;try{await X.exists(this.filePath)&&await X.remove(this.filePath)}catch{}}async buildAuthHeaders(){const e=await this.load();return e?.apiKey?{"x-api-key":e.apiKey}:{}}async buildDeviceAuthHeaders(e){const t=await this.load();if(!t?.apiKey)return{};const s={"x-api-key":t.apiKey};return e&&(s["x-device-guid"]=e),t.deviceId&&(s["x-device-id"]=t.deviceId),t.organizationId&&(s["x-organization-id"]=t.organizationId),s}async buildAgentAuthHeaders(e){let t=e;if(t||(t=await this.getApiKey()||void 0),t||(t=te.apiKey),!t)return{};const s={"x-api-key":t,"Content-Type":"application/json"},o=await this.getOrganizationId();o&&(s["x-organization-id"]=o);const r=await this.getDeviceId();return r&&(s["x-device-id"]=r),s}}P({limit:ye().min(1).max(100).optional(),offset:ye().min(0).optional(),messageType:ss.optional(),sort:M().optional(),order:qt(["asc","desc"]).optional()});class Rr{options;authService;credentials;logger;constructor(e){this.options=e,this.authService=e.authService,this.credentials=e.credentials??new Or,this.logger=e.logger??new oe({verbose:!1})}async getAuthHeaders(){let e=await this.credentials.getApiKey(),t=await this.credentials.getOrganizationId();if((!e||!t)&&this.authService){const o=await this.authService.getValidApiKey();e=o.api_key,t=o.organization_id,await this.credentials.setApiKey({apiKey:e,organizationId:t,expiresAt:o.expires_at})}if(!e&&this.options.apiKey&&(e=this.options.apiKey),!t&&this.options.organizationId&&(t=this.options.organizationId),e&&t)return this.options.organizationId=t,{"Content-Type":"application/json","x-api-key":e};const s=this.options.authToken;if(!s)throw new Error("Authentication token is required for agent message operations");if(!this.options.organizationId)throw new Error("Organization ID is required for agent message operations");return{"Content-Type":"application/json",Authorization:`Bearer ${s}`}}async makeAuthenticatedRequest(e,t,s=!0){const o=await fetch(e,t);if(o.status===401&&s&&this.authService){const r=await o.text();if(r.includes("Invalid API key")){this.logger.info("= API key expired or invalid, clearing tokens and retrying authentication..."),await this.authService.clearTokens();try{await this.credentials.clear()}catch{}this.logger.info("= Retrying authentication...");const i=await this.getAuthHeaders(),a={...t,headers:{...t.headers,...i}};return await this.makeAuthenticatedRequest(e,a,!1)}if(r.includes("Invalid or expired session")){const i=te.isContainerMode;if(this.logger.error("🚫 Session validation failed:",new Error(`Session validation failed for ${e}. Docker mode: ${i}, Method: ${t.method||"GET"}, Timestamp: ${new Date().toISOString()}`)),i)return this.logger.warn("🐳 Docker session timing issue detected, waiting and retrying..."),await new Promise(a=>setTimeout(a,2e3)),await this.makeAuthenticatedRequest(e,t,!1)}}return o.status===429&&this.logger.warn("= Rate limit exceeded, keeping credentials but not retrying"),o}async sendMessage(e){const t=await this.getAuthHeaders(),s=this.options.organizationId;if(!s)throw new Error("Organization ID is required for sending agent messages");const o=ls(e);try{Ms.parse(o)}catch(r){throw new Error(`Invalid message payload: ${r instanceof Error?r.message:r}`)}try{const r=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${s}/agent-sessions/${e.sessionId}/messages`,{method:"POST",headers:t,body:JSON.stringify(o)});if(!r.ok){const a=await r.text();throw new Error(`Failed to send agent message: ${r.status} ${a}`)}return await r.json()}catch(r){throw new Error(`Failed to send agent message: ${r instanceof Error?r.message:r}`)}}async sendMessageBatch(e,t){const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)throw new Error("Organization ID is required for sending agent messages");const r=(t||[]).map(i=>ls(i));try{const i=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${o}/agent-sessions/${e}/messages/batch`,{method:"POST",headers:s,body:JSON.stringify({messages:r})});if(!i.ok){const p=await i.text();throw new Error(`Failed to send agent message batch: ${i.status} ${p}`)}return await i.json()}catch(i){throw new Error(`Failed to send agent message batch: ${i instanceof Error?i.message:i}`)}}async getSessionMessages(e,t){const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)throw new Error("Organization ID is required for fetching agent messages");const r=new URLSearchParams;t?.limit&&r.append("limit",t.limit.toString()),t?.offset&&r.append("offset",t.offset.toString()),t?.messageType&&r.append("messageType",t.messageType),t?.sort&&r.append("sort",t.sort),t?.order&&r.append("order",t.order);const i=`${this.options.apiUrl}/api/v1/organizations/${o}/agent-sessions/${e}/messages?${r.toString()}`;try{const a=await this.makeAuthenticatedRequest(i,{method:"GET",headers:s});if(!a.ok){const u=await a.text();throw new Error(`Failed to fetch session messages: ${a.status} ${u}`)}return await a.json()}catch(a){throw new Error(`Failed to fetch session messages: ${a instanceof Error?a.message:a}`)}}async uploadMessageContent(e,t,s,o){const r=await this.getAuthHeaders(),i=this.options.organizationId;if(!i)throw new Error("Organization ID is required for uploading message content");const a=typeof s=="string"?Buffer.from(s,"utf-8"):s,p=a.length;try{const u=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${i}/agent-sessions/${e}/messages/presign`,{method:"POST",headers:r,body:JSON.stringify({messageType:t,contentSize:p})});if(!u.ok){const d=await u.text();throw new Error(`Failed to get presigned URL: ${u.status} ${d}`)}const{uploadUrl:c}=await u.json(),g=await fetch(c,{method:"PUT",body:a,headers:{"Content-Type":"application/octet-stream","Content-Length":p.toString()}});if(!g.ok)throw new Error(`Failed to upload content to R2: ${g.status}`);const v={sessionId:e,messageType:t,contentSize:p,metadata:o};return await this.sendMessage(v)}catch(u){throw new Error(`Failed to upload message content: ${u instanceof Error?u.message:u}`)}}async startMessage(e,t){const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)throw new Error("Organization ID is required for starting agent messages");try{cr.parse(t)}catch(r){throw new Error(`Invalid start message payload: ${r instanceof Error?r.message:r}`)}try{const r=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${o}/agent-sessions/${e}/messages/start`,{method:"POST",headers:s,body:JSON.stringify(t)});if(!r.ok){const a=await r.text();throw new Error(`Failed to start agent message: ${r.status} ${a}`)}return await r.json()}catch(r){throw new Error(`Failed to start agent message: ${r instanceof Error?r.message:r}`)}}async updateMessage(e,t,s){const o=await this.getAuthHeaders(),r=this.options.organizationId;if(!r)throw new Error("Organization ID is required for updating agent messages");try{lr.parse(s)}catch(a){throw this.logger.error("=❌ Update message validation failed",new Error(`Update message validation failed: ${a instanceof Error?a.message:a}`)),new Error(`Invalid update message payload: ${a instanceof Error?a.message:a}`)}const i=JSON.stringify(s);try{const a=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${r}/agent-sessions/${e}/messages/${t}`,{method:"PATCH",headers:o,body:i});if(!a.ok){const u=await a.text();throw new Error(`Failed to update agent message: ${a.status} ${u}`)}return await a.json()}catch(a){throw new Error(`Failed to update agent message: ${a instanceof Error?a.message:a}`)}}async deleteSessionMessages(e){const t=await this.getAuthHeaders(),s=this.options.organizationId;if(!s)throw new Error("Organization ID is required for deleting session messages");this.logger.info(`=� Deleting all messages for session ${e}...`);try{const o=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${s}/agent-sessions/${e}/messages`,{method:"DELETE",headers:t},!1);if(!o.ok){const i=await o.text().catch(()=>"Unknown error");return this.logger.warn(`� Failed to delete session messages: ${o.status} ${i}`),0}const{deletedCount:r}=await o.json();return this.logger.success(` Deleted ${r} messages for session ${e}`),r}catch(o){return this.logger.warn("� Failed to delete session messages:",o),0}}async getAgentSession(e){const t=await this.getAuthHeaders(),s=this.options.organizationId;if(!s)throw new Error("Organization ID is required for fetching agent session");try{const o=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${s}/agent-sessions/${e}`,{method:"GET",headers:t});if(!o.ok){const i=await o.text();throw new Error(`Failed to fetch agent session: ${o.status} ${i}`)}return await o.json()}catch(o){throw new Error(`Failed to fetch agent session: ${o instanceof Error?o.message:o}`)}}async createTaskComment(e,t,s,o){try{const r=await this.getAuthHeaders(),i=this.options.organizationId;if(!i)return this.logger.warn("Organization ID is required for creating task comment"),null;const a=t&&t.length>1e4?t.substring(0,1e4):t,p=await this.getAgentSession(e);if(!p)return this.logger.warn("Agent session not found for task comment creation"),null;if(!p.taskId)return this.logger.debug("Agent session has no associated task - skipping comment creation"),null;const u=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${i}/tasks/${p.taskId}/comments`,{method:"POST",headers:r,body:JSON.stringify({content:a,assigneeId:s,info:o})});if(!u.ok){const g=await u.text();return this.logger.warn(`Failed to create task comment: ${u.status} ${g}`),null}const c=await u.json();return this.logger.debug("Task comment created successfully"),c}catch(r){return this.logger.warn(`Failed to create task comment: ${r instanceof Error?r.message:r}`),null}}async updateTaskDevInfo(e,t){try{const s=await this.getAuthHeaders(),o=this.options.organizationId;if(!o)return this.logger.warn("Organization ID is required for updating task devInfo"),null;const r=await this.getAgentSession(e);if(!r)return this.logger.warn("Agent session not found for task devInfo update"),null;if(!r.taskId)return this.logger.debug("Agent session has no associated task - skipping devInfo update"),null;const i=await this.makeAuthenticatedRequest(`${this.options.apiUrl}/api/v1/organizations/${o}/tasks/${r.taskId}`,{method:"PATCH",headers:s,body:JSON.stringify({devInfo:t})});if(!i.ok){const p=await i.text();return this.logger.warn(`Failed to update task devInfo: ${i.status} ${p}`),null}const a=await i.json();return this.logger.debug("Task devInfo updated successfully"),a}catch(s){return this.logger.warn(`Failed to update task devInfo: ${s instanceof Error?s.message:s}`),null}}}class Nr{logger;agentHttpService=null;interceptor;llmProvider;maxBodyBytes;sessionId;router;constructor(){const e=te.netlogMaxBody;this.maxBodyBytes=e||8192,this.sessionId=te.sessionId||"",this.llmProvider=new Ls;const t=te.netlogFile||fe.join(jt.tmpdir(),"agiflow-agents","network",`network-${process.pid}.log`);if(this.logger=new rt(t),this.sessionId)try{this.logger.info("[NetworkLog] Creating LlmRouter instance for session",{sessionId:this.sessionId}),this.router=new Yo({toProvider:"openai",sessionId:this.sessionId,logger:this.logger}),this.logger.info("[NetworkLog] ✓ LLM Router initialized successfully",{sessionId:this.sessionId,routerExists:!!this.router})}catch(a){this.logger.error("[NetworkLog] ✗ Failed to initialize LLM Router",a)}else this.logger.info("[NetworkLog] No session ID, skipping router initialization");let s=te.serverUrl||"";s.startsWith("wss://")?s="https://"+s.slice(6):s.startsWith("ws://")&&(s="http://"+s.slice(5));const o=te.apiKey||"",r=te.organizationId||"";if(te.isNetlogRemoteEnabled&&!!(this.sessionId&&s)&&s)try{this.agentHttpService=new Rr({apiUrl:s,organizationId:r,apiKey:o,logger:this.logger})}catch(a){rt.shouldDebug()&&this.logger.error("AgentHttpService initialization failed",a)}this.logger.info("[NetworkLog] Initializing LlmInterceptor",{hasRouter:!!this.router,hasAgentHttpService:!!this.agentHttpService,hasSessionId:!!this.sessionId,enableDebug:te.isDebugMode||te.isNetlogDebug}),this.interceptor=Je.getInstance({maxBodyBytes:this.maxBodyBytes,enableDebug:te.isDebugMode||te.isNetlogDebug,llmProvider:this.llmProvider,idGenerator:Te.ulid,agentHttpService:this.agentHttpService||void 0,sessionId:this.sessionId,router:this.router,logger:this.logger,logFilePath:this.logger.getLogPath()}),this.logger.info("[NetworkLog] ✓ LlmInterceptor initialized",{interceptorExists:!!this.interceptor})}start(){this.interceptor.start()}}const Lr=new Nr;Lr.start();
18
413
  //# sourceMappingURL=networkLog.js.map