@redocly/openapi-docs 3.24.0-next.12 → 3.24.0-next.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{redocly-openapi-docs.min.AiChatProvider-Df0bddw5.js → redocly-openapi-docs.min.AiChatProvider-Yov31DEU.js} +3 -3
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-fsf5yS84.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-B_dB-lOJ.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-aiEGENkd.js → redocly-openapi-docs.min.AiPanel-CtKN6hFm.js} +103 -103
- package/dist/redocly-openapi-docs.min.FileWatcher-BwK7sE0m.js +1 -0
- package/dist/redocly-openapi-docs.min.Observable-D6wKbFwB.js +1 -0
- package/dist/redocly-openapi-docs.min.SemanticSearchService-DjseXm_c.js +1 -0
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-D1Xkf-XX.js → redocly-openapi-docs.min.SqliteDBStorage-Bx9UaSKL.js} +1 -1
- package/dist/redocly-openapi-docs.min.TauriFileSystemAdapter-yrGOe3h5.js +1 -0
- package/dist/redocly-openapi-docs.min.TauriRootStorage-ClZi76Q1.js +1 -0
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-CWZZ9F5q.js +1 -0
- package/dist/redocly-openapi-docs.min.core-BYyFOtMX.js +1 -0
- package/dist/redocly-openapi-docs.min.external-resolver-CbvAhf_l.js +2 -0
- package/dist/redocly-openapi-docs.min.index--MWWlmDA.js +1 -0
- package/dist/redocly-openapi-docs.min.index-DcsZXkNR.js +1 -0
- package/dist/{redocly-openapi-docs.min.index-Zp6s2A4z.js → redocly-openapi-docs.min.index-DtttP3cc.js} +2688 -2688
- package/dist/redocly-openapi-docs.min.index-WycsPyMc.js +1 -0
- package/dist/redocly-openapi-docs.min.index-YnvLQkG_.js +1 -0
- package/dist/redocly-openapi-docs.min.index-xl_tBaHD.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-BPYH3T43.js → redocly-openapi-docs.min.lint-CEV6icUl.js} +2 -2
- package/dist/{redocly-openapi-docs.min.lint-graphql-Cq7DgC7n.js → redocly-openapi-docs.min.lint-graphql-CiN1693v.js} +1 -1
- package/dist/redocly-openapi-docs.min.periodic-revalidation-Dsp-n7ui.js +1 -0
- package/dist/redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js +1 -0
- package/dist/{redocly-openapi-docs.min.respect-run-ztu6EOq2.js → redocly-openapi-docs.min.respect-run-ChOfDjwj.js} +1 -1
- package/dist/{redocly-openapi-docs.min.standalone-D8BmO4OO.js → redocly-openapi-docs.min.standalone-B1SVJ6KL.js} +958 -937
- package/dist/redocly-openapi-docs.min.tauri-path-MSCTrFm2.js +1 -0
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-Dj8qddY3.js → redocly-openapi-docs.min.useAiChatQueries-DbOWonop.js} +6 -6
- package/package.json +3 -3
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-C7hnSHO0.js +0 -1
- package/dist/redocly-openapi-docs.min.external-resolver-3wjREuy_.js +0 -2
- package/dist/redocly-openapi-docs.min.index-BM1O0fdX.js +0 -1
- package/dist/redocly-openapi-docs.min.index-I_lfTVFA.js +0 -1
- package/dist/redocly-openapi-docs.min.index-qqKTpI_q.js +0 -1
- package/dist/redocly-openapi-docs.min.tauri-path-laqHaTpn.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bg as g,bh as l,aZ as u}from"./redocly-openapi-docs.min.index-DtttP3cc.js";import{bi as b,bj as h,aT as w}from"./redocly-openapi-docs.min.index-DtttP3cc.js";async function j(s,e){const a=u(),r=await l(s),c=await l(e),n=r.replace(new RegExp(`^${a}+`),"").split(a).filter(Boolean),i=c.replace(new RegExp(`^${a}+`),"").split(a).filter(Boolean),p=Math.min(n.length,i.length);let o=0;for(let t=0;t<p&&n[t]===i[t];t++)o++;const m=n.slice(o).map(()=>".."),f=i.slice(o);return[...m,...f].join(a)}async function x(s){const e=await g(s);return e?`.${e}`:""}export{b as dirname,x as extname,h as isAbsolute,w as join,j as relative,l as resolve};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Ql}from"./redocly-openapi-docs.min.standalone-
|
|
1
|
+
import{r as Ql}from"./redocly-openapi-docs.min.standalone-B1SVJ6KL.js";import{ad as gv,ae as eu,af as yv,ag as vv,ah as _v,R as Ds,ai as wv,a4 as la,Y as Le,aj as fn,ak as Er,al as bv,am as xv,an as Iv,e as no,$ as ua,ao as tu,ap as js,_ as Us,aq as ou,ar as zs,as as Ls,at as kv,au as Pa,av as Mr,aw as nu,ax as au,C as Fs,ay as Tv,az as Cv,aA as Sv,I as Ev,aB as Mv,aC as ru,aD as Ov,aE as su,N as Or,aF as Rv,f as iu,M as lu,aG as Av,aH as uu,aI as Nv,aJ as cu,aK as $v,aL as Pv,aM as qv,aN as Dv,A as du,d as pu}from"./redocly-openapi-docs.min.index-DtttP3cc.js";import{g as jv,c as mu,d as Uv,f as zv,h as hu,i as Lv,j as Fv}from"./redocly-openapi-docs.min.SemanticSearchService-DjseXm_c.js";var Zv=class extends gv{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions({...e,behavior:eu()},t)}getOptimisticResult(e){return e.behavior=eu(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:o}=e,n=super.createResult(e,t),{isFetching:a,isRefetching:r,isError:s,isRefetchError:l}=n,u=o.fetchMeta?.fetchMore?.direction,d=s&&u==="forward",c=a&&u==="forward",m=s&&u==="backward",g=a&&u==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:vv(t,o.data),hasPreviousPage:yv(t,o.data),isFetchNextPageError:d,isFetchingNextPage:c,isFetchPreviousPageError:m,isFetchingPreviousPage:g,isRefetchError:l&&!d&&!m,isRefetching:r&&!c&&!g}}};function Bv(e,t){return _v(e,Zv)}const qa={path:"pathParameters",query:"queryParameters",header:"headers",cookie:"cookies"},Vv={run_request:{approveLabel:"Run",denyLabel:"Skip"},update_step:{approveLabel:"Apply",denyLabel:"Dismiss"},update_security:{approveLabel:"Apply",denyLabel:"Dismiss"}},Hv={set_active_environment:{approveLabel:"Switch",denyLabel:"Cancel"},add_environment:{approveLabel:"Add",denyLabel:"Cancel"},upsert_input:{approveLabel:"Set",denyLabel:"Cancel"},upsert_server:{approveLabel:"Set",denyLabel:"Cancel"},remove_input:{approveLabel:"Remove",denyLabel:"Cancel"},remove_server:{approveLabel:"Remove",denyLabel:"Cancel"},create_collection:{approveLabel:"Create",denyLabel:"Cancel"},create_workflow:{approveLabel:"Create",denyLabel:"Cancel"},create_step:{approveLabel:"Create",denyLabel:"Cancel"},move_step:{approveLabel:"Move",denyLabel:"Cancel"},delete_collection:{approveLabel:"Delete",denyLabel:"Cancel"},delete_workflow:{approveLabel:"Delete",denyLabel:"Cancel"},delete_step:{approveLabel:"Delete",denyLabel:"Cancel"},save_tab_to_collection:{approveLabel:"Save",denyLabel:"Cancel"}},Wv={CHAT:"chat",HISTORY:"history"},Gv="report_status",Jv="run_workflow";var fu="vercel.ai.error",Kv=Symbol.for(fu),gu,yu,_e=class Vy extends(yu=Error,gu=Kv,yu){constructor({name:t,message:o,cause:n}){super(o),this[gu]=!0,this.name=t,this.cause=n}static isInstance(t){return Vy.hasMarker(t,fu)}static hasMarker(t,o){const n=Symbol.for(o);return t!=null&&typeof t=="object"&&n in t&&typeof t[n]=="boolean"&&t[n]===!0}},vu="AI_APICallError",_u=`vercel.ai.error.${vu}`,Yv=Symbol.for(_u),wu,bu,ut=class extends(bu=_e,wu=Yv,bu){constructor({message:e,url:t,requestBodyValues:o,statusCode:n,responseHeaders:a,responseBody:r,cause:s,isRetryable:l=n!=null&&(n===408||n===409||n===429||n>=500),data:u}){super({name:vu,message:e,cause:s}),this[wu]=!0,this.url=t,this.requestBodyValues=o,this.statusCode=n,this.responseHeaders=a,this.responseBody=r,this.isRetryable=l,this.data=u}static isInstance(e){return _e.hasMarker(e,_u)}},xu="AI_EmptyResponseBodyError",Iu=`vercel.ai.error.${xu}`,Xv=Symbol.for(Iu),ku,Tu,Qv=class extends(Tu=_e,ku=Xv,Tu){constructor({message:e="Empty response body"}={}){super({name:xu,message:e}),this[ku]=!0}static isInstance(e){return _e.hasMarker(e,Iu)}};function Xo(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.toString():JSON.stringify(e)}var Cu="AI_InvalidArgumentError",Su=`vercel.ai.error.${Cu}`,e_=Symbol.for(Su),Eu,Mu,Zs=class extends(Mu=_e,Eu=e_,Mu){constructor({message:e,cause:t,argument:o}){super({name:Cu,message:e,cause:t}),this[Eu]=!0,this.argument=o}static isInstance(e){return _e.hasMarker(e,Su)}},Ou="AI_InvalidPromptError",Ru=`vercel.ai.error.${Ou}`,t_=Symbol.for(Ru),Au,Nu,gn=class extends(Nu=_e,Au=t_,Nu){constructor({prompt:e,message:t,cause:o}){super({name:Ou,message:`Invalid prompt: ${t}`,cause:o}),this[Au]=!0,this.prompt=e}static isInstance(e){return _e.hasMarker(e,Ru)}},$u="AI_InvalidResponseDataError",Pu=`vercel.ai.error.${$u}`,o_=Symbol.for(Pu),qu,Du,Rr=class extends(Du=_e,qu=o_,Du){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:$u,message:t}),this[qu]=!0,this.data=e}static isInstance(e){return _e.hasMarker(e,Pu)}},ju="AI_JSONParseError",Uu=`vercel.ai.error.${ju}`,n_=Symbol.for(Uu),zu,Lu,Ar=class extends(Lu=_e,zu=n_,Lu){constructor({text:e,cause:t}){super({name:ju,message:`JSON parsing failed: Text: ${e}.
|
|
2
2
|
Error message: ${Xo(t)}`,cause:t}),this[zu]=!0,this.text=e}static isInstance(e){return _e.hasMarker(e,Uu)}},Fu="AI_LoadAPIKeyError",Zu=`vercel.ai.error.${Fu}`,a_=Symbol.for(Zu),Bu,Vu,Nr=class extends(Vu=_e,Bu=a_,Vu){constructor({message:e}){super({name:Fu,message:e}),this[Bu]=!0}static isInstance(e){return _e.hasMarker(e,Zu)}},Hu="AI_NoSuchModelError",Wu=`vercel.ai.error.${Hu}`,r_=Symbol.for(Wu),Gu,Ju,Ku=class extends(Ju=_e,Gu=r_,Ju){constructor({errorName:e=Hu,modelId:t,modelType:o,message:n=`No such ${o}: ${t}`}){super({name:e,message:n}),this[Gu]=!0,this.modelId=t,this.modelType=o}static isInstance(e){return _e.hasMarker(e,Wu)}},Yu="AI_NoSuchProviderReferenceError",Xu=`vercel.ai.error.${Yu}`,s_=Symbol.for(Xu),Qu,ec,i_=class extends(ec=_e,Qu=s_,ec){constructor({provider:e,reference:t,message:o=`No provider reference found for provider '${e}'. Available providers: ${Object.keys(t).join(", ")}`}){super({name:Yu,message:o}),this[Qu]=!0,this.provider=e,this.reference=t}static isInstance(e){return _e.hasMarker(e,Xu)}},tc="AI_TooManyEmbeddingValuesForCallError",oc=`vercel.ai.error.${tc}`,l_=Symbol.for(oc),nc,ac,rc=class extends(ac=_e,nc=l_,ac){constructor(e){super({name:tc,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[nc]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return _e.hasMarker(e,oc)}},sc="AI_TypeValidationError",ic=`vercel.ai.error.${sc}`,u_=Symbol.for(ic),lc,uc,Qo=class Bl extends(uc=_e,lc=u_,uc){constructor({value:t,cause:o,context:n}){let a="Type validation failed";if(n?.field&&(a+=` for ${n.field}`),n?.entityName||n?.entityId){a+=" (";const r=[];n.entityName&&r.push(n.entityName),n.entityId&&r.push(`id: "${n.entityId}"`),a+=r.join(", "),a+=")"}super({name:sc,message:`${a}: Value: ${JSON.stringify(t)}.
|
|
3
3
|
Error message: ${Xo(o)}`,cause:o}),this[lc]=!0,this.value=t,this.context=n}static isInstance(t){return _e.hasMarker(t,ic)}static wrap({value:t,cause:o,context:n}){var a,r,s;return Bl.isInstance(o)&&o.value===t&&((a=o.context)==null?void 0:a.field)===n?.field&&((r=o.context)==null?void 0:r.entityName)===n?.entityName&&((s=o.context)==null?void 0:s.entityId)===n?.entityId?o:new Bl({value:t,cause:o,context:n})}},cc="AI_UnsupportedFunctionalityError",dc=`vercel.ai.error.${cc}`,c_=Symbol.for(dc),pc,mc,wt=class extends(mc=_e,pc=c_,mc){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:cc,message:t}),this[pc]=!0,this.functionality=e}static isInstance(e){return _e.hasMarker(e,dc)}};function Bs(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:Array.isArray(e)?e.every(Bs):typeof e=="object"?Object.entries(e).every(([t,o])=>typeof t=="string"&&(o===void 0||Bs(o))):!1}function Da(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,o])=>typeof t=="string"&&(o===void 0||Bs(o)))}function K(e,t,o){function n(l,u){var d;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(d=l._zod).traits??(d.traits=new Set),l._zod.traits.add(e),t(l,u);for(const c in s.prototype)c in l||Object.defineProperty(l,c,{value:s.prototype[c].bind(l)});l._zod.constr=s,l._zod.def=u}const a=o?.Parent??Object;class r extends a{}Object.defineProperty(r,"name",{value:e});function s(l){var u;const d=o?.Parent?new r:this;n(d,l),(u=d._zod).deferred??(u.deferred=[]);for(const c of d._zod.deferred)c();return d}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>o?.Parent&&l instanceof o.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class ja extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const hc={};function yn(e){return hc}function fc(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function d_(e,t){return typeof t=="bigint"?t.toString():t}function Vs(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Hs(e){return e==null}function Ws(e){const t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function p_(e,t){const o=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=o>n?o:n,r=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return r%s/10**a}function tt(e,t,o){Object.defineProperty(e,t,{get(){{const n=o();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ua(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function za(e){return JSON.stringify(e)}const gc=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const m_=Vs(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Pr(e){if($r(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const o=t.prototype;return!($r(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}const h_=new Set(["string","number","symbol"]);function La(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $n(e,t,o){const n=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(n._zod.parent=e),n}function Ie(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function f_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const g_={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function y_(e,t){const o={},n=e._zod.def;for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=n.shape[a])}return $n(e,{...e._zod.def,shape:o,checks:[]})}function v_(e,t){const o={...e._zod.def.shape},n=e._zod.def;for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return $n(e,{...e._zod.def,shape:o,checks:[]})}function __(e,t){if(!Pr(t))throw new Error("Invalid input to extend: expected a plain object");const o={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return Ua(this,"shape",n),n},checks:[]};return $n(e,o)}function w_(e,t){return $n(e,{...e._zod.def,get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return Ua(this,"shape",o),o},catchall:t._zod.def.catchall,checks:[]})}function b_(e,t,o){const n=t._zod.def.shape,a={...n};if(o)for(const r in o){if(!(r in n))throw new Error(`Unrecognized key: "${r}"`);o[r]&&(a[r]=e?new e({type:"optional",innerType:n[r]}):n[r])}else for(const r in n)a[r]=e?new e({type:"optional",innerType:n[r]}):n[r];return $n(t,{...t._zod.def,shape:a,checks:[]})}function x_(e,t,o){const n=t._zod.def.shape,a={...n};if(o)for(const r in o){if(!(r in a))throw new Error(`Unrecognized key: "${r}"`);o[r]&&(a[r]=new e({type:"nonoptional",innerType:n[r]}))}else for(const r in n)a[r]=new e({type:"nonoptional",innerType:n[r]});return $n(t,{...t._zod.def,shape:a,checks:[]})}function Fa(e,t=0){for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function vn(e,t){return t.map(o=>{var n;return(n=o).path??(n.path=[]),o.path.unshift(e),o})}function qr(e){return typeof e=="string"?e:e?.message}function _n(e,t,o){const n={...e,path:e.path??[]};if(!e.message){const a=qr(e.inst?._zod.def?.error?.(e))??qr(t?.error?.(e))??qr(o.customError?.(e))??qr(o.localeError?.(e))??"Invalid input";n.message=a}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Gs(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Za(...e){const[t,o,n]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:n}:{...t}}const yc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,d_,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vc=K("$ZodError",yc),_c=K("$ZodError",yc,{Parent:Error});function I_(e,t=o=>o.message){const o={},n=[];for(const a of e.issues)a.path.length>0?(o[a.path[0]]=o[a.path[0]]||[],o[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:o}}function k_(e,t){const o=t||function(r){return r.message},n={_errors:[]},a=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(l=>a({issues:l}));else if(s.code==="invalid_key")a({issues:s.issues});else if(s.code==="invalid_element")a({issues:s.issues});else if(s.path.length===0)n._errors.push(o(s));else{let l=n,u=0;for(;u<s.path.length;){const d=s.path[u];u===s.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(o(s))):l[d]=l[d]||{_errors:[]},l=l[d],u++}}};return a(e),n}const T_=e=>(t,o,n,a)=>{const r=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw new ja;if(s.issues.length){const l=new(a?.Err??e)(s.issues.map(u=>_n(u,r,yn())));throw gc(l,a?.callee),l}return s.value},C_=e=>async(t,o,n,a)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:o,issues:[]},r);if(s instanceof Promise&&(s=await s),s.issues.length){const l=new(a?.Err??e)(s.issues.map(u=>_n(u,r,yn())));throw gc(l,a?.callee),l}return s.value},wc=e=>(t,o,n)=>{const a=n?{...n,async:!1}:{async:!1},r=t._zod.run({value:o,issues:[]},a);if(r instanceof Promise)throw new ja;return r.issues.length?{success:!1,error:new(e??vc)(r.issues.map(s=>_n(s,a,yn())))}:{success:!0,data:r.value}},S_=wc(_c),bc=e=>async(t,o,n)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let r=t._zod.run({value:o,issues:[]},a);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(s=>_n(s,a,yn())))}:{success:!0,data:r.value}},E_=bc(_c),M_=/^[cC][^\s-]{8,}$/,O_=/^[0-9a-z]+$/,R_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,A_=/^[0-9a-vA-V]{20}$/,N_=/^[A-Za-z0-9]{27}$/,$_=/^[a-zA-Z0-9_-]{21}$/,P_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,q_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,xc=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,D_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,j_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function U_(){return new RegExp(j_,"u")}const z_=/^(?:(?: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])$/,L_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,F_=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Z_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,B_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ic=/^[A-Za-z0-9_-]*$/,V_=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,H_=/^\+(?:[0-9]){6,14}[0-9]$/,kc="(?:(?:\\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])))",W_=new RegExp(`^${kc}$`);function Tc(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function G_(e){return new RegExp(`^${Tc(e)}$`)}function J_(e){const t=Tc({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${o.join("|")})`;return new RegExp(`^${kc}T(?:${n})$`)}const K_=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Y_=/^\d+$/,X_=/^-?\d+(?:\.\d+)?/i,Q_=/true|false/i,ew=/null/i,tw=/^[^A-Z]*$/,ow=/^[^a-z]*$/,ao=K("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),Cc={number:"number",bigint:"bigint",object:"date"},Sc=K("$ZodCheckLessThan",(e,t)=>{ao.init(e,t);const o=Cc[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,r=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:o,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ec=K("$ZodCheckGreaterThan",(e,t)=>{ao.init(e,t);const o=Cc[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,r=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:o,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nw=K("$ZodCheckMultipleOf",(e,t)=>{ao.init(e,t),e._zod.onattach.push(o=>{var n;(n=o._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=o=>{if(typeof o.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):p_(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),aw=K("$ZodCheckNumberFormat",(e,t)=>{ao.init(e,t),t.format=t.format||"float64";const o=t.format?.includes("int"),n=o?"int":"number",[a,r]=g_[t.format];e._zod.onattach.push(s=>{const l=s._zod.bag;l.format=t.format,l.minimum=a,l.maximum=r,o&&(l.pattern=Y_)}),e._zod.check=s=>{const l=s.value;if(o){if(!Number.isInteger(l)){s.issues.push({expected:n,format:t.format,code:"invalid_type",input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}l<a&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),l>r&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:r,inst:e})}}),rw=K("$ZodCheckMaxLength",(e,t)=>{var o;ao.init(e,t),(o=e._zod.def).when??(o.when=n=>{const a=n.value;return!Hs(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const r=Gs(a);n.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),sw=K("$ZodCheckMinLength",(e,t)=>{var o;ao.init(e,t),(o=e._zod.def).when??(o.when=n=>{const a=n.value;return!Hs(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const r=Gs(a);n.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),iw=K("$ZodCheckLengthEquals",(e,t)=>{var o;ao.init(e,t),(o=e._zod.def).when??(o.when=n=>{const a=n.value;return!Hs(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,r=a.length;if(r===t.length)return;const s=Gs(a),l=r>t.length;n.issues.push({origin:s,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Dr=K("$ZodCheckStringFormat",(e,t)=>{var o,n;ao.init(e,t),e._zod.onattach.push(a=>{const r=a._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(o=e._zod).check??(o.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),lw=K("$ZodCheckRegex",(e,t)=>{Dr.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),uw=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=tw),Dr.init(e,t)}),cw=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ow),Dr.init(e,t)}),dw=K("$ZodCheckIncludes",(e,t)=>{ao.init(e,t);const o=La(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${o}`:o);t.pattern=n,e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),pw=K("$ZodCheckStartsWith",(e,t)=>{ao.init(e,t);const o=new RegExp(`^${La(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(o)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),mw=K("$ZodCheckEndsWith",(e,t)=>{ao.init(e,t);const o=new RegExp(`.*${La(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(o)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),hw=K("$ZodCheckOverwrite",(e,t)=>{ao.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}});class fw{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
4
4
|
`).filter(r=>r),n=Math.min(...o.map(r=>r.length-r.trimStart().length)),a=o.map(r=>r.slice(n)).map(r=>" ".repeat(this.indent*2)+r);for(const r of a)this.content.push(r)}compile(){const t=Function,o=this?.args,n=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...o,n.join(`
|
|
@@ -69,7 +69,7 @@ Alternatively, you can use a provider module instead of the AI Gateway.
|
|
|
69
69
|
|
|
70
70
|
Learn more: \x1B[34m${o}\x1B[0m
|
|
71
71
|
|
|
72
|
-
`),{name:"GatewayAuthenticationError"})}function yh(e){return{inputTokens:e.inputTokens.total,inputTokenDetails:{noCacheTokens:e.inputTokens.noCache,cacheReadTokens:e.inputTokens.cacheRead,cacheWriteTokens:e.inputTokens.cacheWrite},outputTokens:e.outputTokens.total,outputTokenDetails:{textTokens:e.outputTokens.text,reasoningTokens:e.outputTokens.reasoning},totalTokens:an(e.inputTokens.total,e.outputTokens.total),raw:e.raw}}function Bi(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function vh(e,t){var o,n,a,r,s,l,u,d,c,m;return{inputTokens:an(e.inputTokens,t.inputTokens),inputTokenDetails:{noCacheTokens:an((o=e.inputTokenDetails)==null?void 0:o.noCacheTokens,(n=t.inputTokenDetails)==null?void 0:n.noCacheTokens),cacheReadTokens:an((a=e.inputTokenDetails)==null?void 0:a.cacheReadTokens,(r=t.inputTokenDetails)==null?void 0:r.cacheReadTokens),cacheWriteTokens:an((s=e.inputTokenDetails)==null?void 0:s.cacheWriteTokens,(l=t.inputTokenDetails)==null?void 0:l.cacheWriteTokens)},outputTokens:an(e.outputTokens,t.outputTokens),outputTokenDetails:{textTokens:an((u=e.outputTokenDetails)==null?void 0:u.textTokens,(d=t.outputTokenDetails)==null?void 0:d.textTokens),reasoningTokens:an((c=e.outputTokenDetails)==null?void 0:c.reasoningTokens,(m=t.outputTokenDetails)==null?void 0:m.reasoningTokens)},totalTokens:an(e.totalTokens,t.totalTokens)}}function an(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function Vi(...e){const t=Ln(...e).map(o=>o instanceof AbortSignal?o:AbortSignal.timeout(o));return t.length===0?void 0:t.length===1?t[0]:AbortSignal.any(t)}function cs(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const o={...e};for(const n in t)if(!(n==="__proto__"||n==="constructor"||n==="prototype")&&Object.prototype.hasOwnProperty.call(t,n)){const a=t[n];if(a===void 0)continue;const r=n in e?e[n]:void 0,s=a!==null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp),l=r!=null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp);s&&l?o[n]=cs(r,a):o[n]=a}return o}function Qa(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}async function kt(e){await Promise.all(Un(e.callbacks).map(async t=>{try{await t?.(e.event)}catch{}}))}function GC({error:e,exponentialBackoffDelay:t}){const o=ut.isInstance(e)?e.responseHeaders:ut.isInstance(e.cause)?e.cause.responseHeaders:void 0;if(!o)return t;let n;const a=o["retry-after-ms"];if(a){const s=parseFloat(a);Number.isNaN(s)||(n=s)}const r=o["retry-after"];if(r&&n===void 0){const s=parseFloat(r);Number.isNaN(s)?n=Date.parse(r)-Date.now():n=s*1e3}return n!=null&&!Number.isNaN(n)&&0<=n&&(n<60*1e3||n<t)?n:t}var JC=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:o=2,abortSignal:n}={})=>async a=>_h(a,{maxRetries:e,delayInMs:t,backoffFactor:o,abortSignal:n});async function _h(e,{maxRetries:t,delayInMs:o,backoffFactor:n,abortSignal:a},r=[]){try{return await e()}catch(s){if(Fo(s)||t===0)throw s;const l=Xo(s),u=[...r,s],d=u.length;if(d>t)throw new Hm({message:`Failed after ${d} attempts. Last error: ${l}`,reason:"maxRetriesExceeded",errors:u});if(s instanceof Error&&(ut.isInstance(s)&&s.isRetryable===!0||Nt.isInstance(s)&&s.isRetryable===!0)&&d<=t)return await zn(GC({error:s,exponentialBackoffDelay:o}),{abortSignal:a}),_h(e,{maxRetries:t,delayInMs:n*o,backoffFactor:n,abortSignal:a},u);throw d===1?s:new Hm({message:`Failed after ${d} attempts with non-retryable error: '${l}'`,reason:"errorNotRetryable",errors:u})}}function Hi({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new No({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new No({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}const o=e??2;return{maxRetries:o,retry:JC({maxRetries:o,abortSignal:t})}}function Wi({abortController:e,label:t,timeoutMs:o}){if(!(e==null||o==null))return setTimeout(()=>e.abort(new DOMException(`${t} timeout of ${o}ms exceeded`,"TimeoutError")),o)}function Cn({tokens:e,durationMs:t}){const o=1e3*(e??0)/(t??0);return Number.isFinite(o)?o:0}function wh({messages:e}){const t=e.at(-1);if(t?.role!="tool")return{approvedToolApprovals:[],deniedToolApprovals:[]};const o={};for(const u of e)if(u.role==="assistant"&&typeof u.content!="string"){const d=u.content;for(const c of d)c.type==="tool-call"&&(o[c.toolCallId]=c)}const n={};for(const u of e)if(u.role==="assistant"&&typeof u.content!="string"){const d=u.content;for(const c of d)c.type==="tool-approval-request"&&(n[c.approvalId]=c)}const a={};for(const u of t.content)u.type==="tool-result"&&(a[u.toolCallId]=u);const r=[],s=[],l=t.content.filter(u=>u.type==="tool-approval-response");for(const u of l){const d=n[u.approvalId];if(d==null)throw new WT({approvalId:u.approvalId});if(a[d.toolCallId]!=null)continue;const c=o[d.toolCallId];if(c==null)throw new $i({toolCallId:d.toolCallId,approvalId:d.approvalId});const m={approvalRequest:d,approvalResponse:u,toolCall:c};u.approved?r.push(m):s.push(m)}return{approvedToolApprovals:r,deniedToolApprovals:s}}async function Gi({toolName:e,context:t,contextSchema:o}){return o==null?t:await $e({value:t,schema:o,context:{field:"tool context",entityName:e}})}async function Ji({toolCall:e,tools:t,toolsContext:o,callId:n,messages:a,abortSignal:r,timeout:s,experimental_sandbox:l,onPreliminaryToolResult:u,onToolExecutionStart:d,onToolExecutionEnd:c,executeToolInTelemetryContext:m=async({execute:f})=>await f(),runInTracingChannelSpan:g=async({execute:f})=>await f()}){const{toolName:f,toolCallId:v,input:b}=e,x=t?.[f];if(!ep(x))return;const _=await Gi({toolName:f,context:o?.[f],contextSchema:x.contextSchema}),w={toolCall:e,messages:a,toolContext:_},T={callId:n,...w};return await g({type:"executeTool",event:T,execute:async()=>{let y;await kt({event:T,callbacks:d});const C=NC(s,f),S=Vi(r,C);let R=0;try{await m({callId:n,toolCallId:v,...w,execute:async()=>{const E=Qa();try{const P=mk({tool:x,input:b,options:{toolCallId:v,messages:a,abortSignal:S,context:_,experimental_sandbox:l}});for await(const W of P)W.type==="preliminary"?u?.({...e,type:"tool-result",output:W.output,preliminary:!0}):y=W.output}finally{R=Qa()-E}}})}catch(E){const P={type:"tool-error",toolCallId:v,toolName:f,input:b,error:E,dynamic:x.type==="dynamic",...e.providerMetadata!=null?{providerMetadata:e.providerMetadata}:{},...e.toolMetadata!=null?{toolMetadata:e.toolMetadata}:{}};return await kt({event:{...T,toolOutput:P,toolExecutionMs:R},callbacks:c}),{output:P,toolExecutionMs:R}}const O={type:"tool-result",toolCallId:v,toolName:f,input:b,output:y,dynamic:x.type==="dynamic",...e.providerMetadata!=null?{providerMetadata:e.providerMetadata}:{},...e.toolMetadata!=null?{toolMetadata:e.toolMetadata}:{}};return await kt({event:{...T,toolOutput:O,toolExecutionMs:R},callbacks:c}),{output:O,toolExecutionMs:R}}})}function bh({tools:e,activeTools:t}){return e==null||t==null?e:Object.fromEntries(Object.entries(e).filter(([o])=>t.includes(o)))}var Ki=class{constructor({data:e,mediaType:t}){const o=e instanceof Uint8Array;this.base64Data=o?void 0:e,this.uint8ArrayData=o?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=en(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Lo(this.base64Data)),this.uint8ArrayData}},KC=class extends Ki{constructor(e){super(e),this.type="file"}},YC={};BT(YC,{array:()=>eS,choice:()=>tS,json:()=>oS,object:()=>QC,text:()=>ds});function XC(e){const t=["ROOT"];let o=-1,n=null,a=0;function r(c){return c>="0"&&c<="9"||c>="A"&&c<="F"||c>="a"&&c<="f"}function s(c,m,g){switch(c){case'"':{o=m,t.pop(),t.push(g),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{o=m,n=m,t.pop(),t.push(g),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=m,t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"{":{o=m,t.pop(),t.push(g),t.push("INSIDE_OBJECT_START");break}case"[":{o=m,t.pop(),t.push(g),t.push("INSIDE_ARRAY_START");break}}}function l(c,m){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{o=m,t.pop();break}}}function u(c,m){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=m,t.pop();break}}}for(let c=0;c<e.length;c++){const m=e[c];switch(t[t.length-1]){case"ROOT":s(m,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(m){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{o=c,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{m==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{m==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{m===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{s(m,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{l(m,c);break}case"INSIDE_STRING":{switch(m){case'"':{t.pop(),o=c;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:o=c}break}case"INSIDE_ARRAY_START":{m==="]"?(o=c,t.pop()):(o=c,s(m,c,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(m){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=c,t.pop();break}default:{o=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{s(m,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),m==="u"?(a=0,t.push("INSIDE_STRING_UNICODE_ESCAPE")):o=c;break}case"INSIDE_STRING_UNICODE_ESCAPE":{r(m)&&(a++,a===4&&(t.pop(),o=c));break}case"INSIDE_NUMBER":{switch(m){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(m,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(m,c);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(m,c);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(m,c);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const g=e.substring(n,c+1);!"false".startsWith(g)&&!"true".startsWith(g)&&!"null".startsWith(g)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(m,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(m,c)):o=c;break}}}let d=e.slice(0,o+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{d+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{d+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{d+="]";break}case"INSIDE_LITERAL":{const m=e.substring(n,e.length);"true".startsWith(m)?d+="true".slice(m.length):"false".startsWith(m)?d+="false".slice(m.length):"null".startsWith(m)&&(d+="null".slice(m.length))}}return d}async function er(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await So({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await So({text:XC(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var ds=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),QC=({schema:e,name:t,description:o})=>{const n=Vn(e);return{name:"object",responseFormat:je(n.jsonSchema).then(a=>({type:"json",schema:a,...t!=null&&{name:t},...o!=null&&{description:o}})),async parseCompleteOutput({text:a},r){const s=await So({text:a});if(!s.success)throw new Tn({message:"No object generated: could not parse the response.",cause:s.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const l=await Co({value:s.value,schema:n});if(!l.success)throw new Tn({message:"No object generated: response did not match schema.",cause:l.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});return l.value},async parsePartialOutput({text:a}){const r=await er(a);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:r.value}}},createElementStreamTransform(){}}},eS=({element:e,name:t,description:o})=>{const n=Vn(e);return{name:"array",responseFormat:je(n.jsonSchema).then(a=>{const{$schema:r,...s}=a;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:s}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...o!=null&&{description:o}}}),async parseCompleteOutput({text:a},r){const s=await So({text:a});if(!s.success)throw new Tn({message:"No object generated: could not parse the response.",cause:s.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const l=s.value;if(l==null||typeof l!="object"||!("elements"in l)||!Array.isArray(l.elements))throw new Tn({message:"No object generated: response did not match schema.",cause:new Qo({value:l,cause:"response must be an object with an elements array"}),text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const u=[];for(const d of l.elements){const c=await Co({value:d,schema:n});if(!c.success)throw new Tn({message:"No object generated: response did not match schema.",cause:c.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});u.push(c.value)}return u},async parsePartialOutput({text:a}){const r=await er(a);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=r.value;if(s==null||typeof s!="object"||!("elements"in s)||!Array.isArray(s.elements))return;const l=r.state==="repaired-parse"&&s.elements.length>0?s.elements.slice(0,-1):s.elements,u=[];for(const d of l){const c=await Co({value:d,schema:n});c.success&&u.push(c.value)}return{partial:u}}}},createElementStreamTransform(){let a=0;return new TransformStream({transform({partialOutput:r},s){if(r!=null)for(;a<r.length;a++)s.enqueue(r[a])}})}}},tS=({options:e,name:t,description:o})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...o!=null&&{description:o}}),async parseCompleteOutput({text:n},a){const r=await So({text:n});if(!r.success)throw new Tn({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});const s=r.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string"||!e.includes(s.result))throw new Tn({message:"No object generated: response did not match schema.",cause:new Qo({value:s,cause:"response must be an object that contains a choice value."}),text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});return s.result},async parsePartialOutput({text:n}){const a=await er(n);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const r=a.value;if(r==null||typeof r!="object"||!("result"in r)||typeof r.result!="string")return;const s=e.filter(l=>l.startsWith(r.result));return a.state==="successful-parse"?s.includes(r.result)?{partial:r.result}:void 0:s.length===1?{partial:s[0]}:void 0}}},createElementStreamTransform(){}}),oS=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:o},n){const a=await So({text:o});if(!a.success)throw new Tn({message:"No object generated: could not parse the response.",cause:a.error,text:o,response:n.response,usage:n.usage,finishReason:n.finishReason});return a.value},async parsePartialOutput({text:o}){const n=await er(o);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return n.value===void 0?void 0:{partial:n.value}}},createElementStreamTransform(){}});async function xh({toolCall:e,tools:t,repairToolCall:o,refineToolInput:n,messages:a,instructions:r}){try{if(t==null){if(e.providerExecuted&&e.dynamic)return await Yi({toolCall:await Ih(e),refineToolInput:n});throw new Pi({toolName:e.toolName})}try{return await Yi({toolCall:await kh({toolCall:e,tools:t}),refineToolInput:n})}catch(s){if(o==null||!(Pi.isInstance(s)||is.isInstance(s)))throw s;let l=null;try{l=await o({toolCall:e,tools:t,inputSchema:async({toolName:u})=>{const{inputSchema:d}=t[u];return await Vn(d).jsonSchema},instructions:r,system:r,messages:a,error:s})}catch(u){throw new oC({cause:u,originalError:s})}if(l==null)throw s;return await Yi({toolCall:await kh({toolCall:l,tools:t}),refineToolInput:n})}}catch(s){const l=await So({text:e.input}),u=l.success?l.value:e.input,d=t?.[e.toolName];return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:u,dynamic:!0,invalid:!0,error:s,title:d?.title,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...d?.metadata!=null?{toolMetadata:d.metadata}:{}}}}async function Yi({toolCall:e,refineToolInput:t}){const o=t?.[e.toolName];return o==null?e:{...e,input:await o(e.input)}}async function Ih(e){const t=e.input.trim()===""?{success:!0,value:{}}:await So({text:e.input});if(t.success===!1)throw new is({toolName:e.toolName,toolInput:e.input,cause:t.error});return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:t.value,providerExecuted:!0,dynamic:!0,providerMetadata:e.providerMetadata}}async function kh({toolCall:e,tools:t}){const o=e.toolName,n=t[o];if(n==null){if(e.providerExecuted&&e.dynamic)return await Ih(e);throw new Pi({toolName:e.toolName,availableTools:Object.keys(t)})}const a=Vn(n.inputSchema),r=e.input.trim()===""?await Co({value:{},schema:a}):await So({text:e.input,schema:a});if(r.success===!1)throw new is({toolName:o,toolInput:e.input,cause:r.error});return n.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:r.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...n.metadata!=null?{toolMetadata:n.metadata}:{},dynamic:!0,title:n.title}:{type:"tool-call",toolCallId:e.toolCallId,toolName:o,input:r.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...n.metadata!=null?{toolMetadata:n.metadata}:{},title:n.title}}function nS(e){return typeof e=="object"&&e!==null&&"type"in e?e.type==="data"?e.data:e.url:e}function aS(e){return e.map(t=>t.type==="reasoning"?{type:"reasoning",text:t.text,...t.providerMetadata!=null?{providerOptions:t.providerMetadata}:{}}:{type:"reasoning-file",data:t.file.base64,mediaType:t.file.mediaType,...t.providerMetadata!=null?{providerOptions:t.providerMetadata}:{}})}function Th(e){return e.map(t=>{if(t.type==="reasoning")return{type:"reasoning",text:t.text,...t.providerOptions!=null?{providerMetadata:t.providerOptions}:{}};const o=nS(t.data),n=o instanceof ArrayBuffer?new Uint8Array(o):o instanceof URL?o.toString():o;return{type:"reasoning-file",file:new Ki({data:n,mediaType:t.mediaType}),...t.providerOptions!=null?{providerMetadata:t.providerOptions}:{}}})}async function Xi({tools:e,toolCall:t,toolApproval:o,messages:n,toolsContext:a,runtimeContext:r}){if(o!=null&&typeof o=="function")return Ch(await o({toolCall:t,tools:e,toolsContext:a,messages:n,runtimeContext:r}));const s=t.toolName,l=e?.[s],u=t.input,d=o?.[s];if(d!=null){const c=typeof d=="function"?await d(u,{toolCallId:t.toolCallId,messages:n,toolContext:await Gi({toolName:s,context:a?.[s],contextSchema:l?.contextSchema}),runtimeContext:r}):d;return Ch(c)}return l?.needsApproval==null?{type:"not-applicable"}:(typeof l.needsApproval=="function"?await l.needsApproval(u,{toolCallId:t.toolCallId,messages:n,context:await Gi({toolName:s,context:a?.[s],contextSchema:l?.contextSchema})}):l.needsApproval)?{type:"user-approval"}:{type:"not-applicable"}}function Ch(e){return e===void 0?{type:"not-applicable"}:typeof e=="string"?{type:e}:e}function ro(...e){return async t=>{await Promise.allSettled(e.map(async o=>{await o?.(t)}))}}var Sh="ai:telemetry";function Eh(){var e;return typeof process<"u"&&((e=process.release)==null?void 0:e.name)==="node"}var Qi;async function rS(){if(Eh())return Qi==null&&(Qi=import("./redocly-openapi-docs.min.standalone-D8BmO4OO.js").then(e=>e.bz).catch(()=>{})),Qi}function Mh(e){var t;const o=globalThis.process;try{return(t=o?.getBuiltinModule)==null?void 0:t.call(o,e)}catch{return}}async function Oh(e,t){var o;const n=await rS(),a=(o=n?.tracingChannel)==null?void 0:o.call(n,Sh);if(a==null||a.hasSubscribers===!1)return await t();let r,s,l,u=!1,d=!1;const c=()=>{try{r=Promise.resolve(t())}catch(m){r=Promise.reject(m)}return r=r.then(m=>(s=m,u=!0,m),m=>{throw l=m,d=!0,m}),r};try{return await a.tracePromise(c,e)}catch{if(d)throw l;return u?s:r!=null?await r:await t()}}function sS({message:e,completion:t}){var o;if(!Eh())return;const n=Mh("node:diagnostics_channel"),a=Mh("node:async_hooks"),r=(o=n?.tracingChannel)==null?void 0:o.call(n,Sh);if(r==null||r.hasSubscribers===!1||a==null){Promise.resolve(t).catch(()=>{});return}const s=e;let l,u=!1;const d=m=>{try{m()}catch{}},c=({result:m,error:g})=>{u||(u=!0,g!==void 0&&(s.error=g,d(()=>r.error.publish(s))),m!==void 0&&(s.result=m),d(()=>r.asyncEnd.publish(s)))};return d(()=>{r.start.runStores(s,()=>{l=new a.AsyncResource("ai.telemetry")})}),d(()=>r.end.publish(s)),Promise.resolve(t).then(m=>c({result:m}),m=>c({error:m})),{run:m=>l==null?m():l.runInAsyncScope(m)}}function iS(){var e;return(e=globalThis.AI_SDK_TELEMETRY_INTEGRATIONS)!=null?e:[]}function tr(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function lS({telemetry:e}){if(e?.isEnabled===!1)return{};const t=e?.integrations,o=t!=null?Un(t):iS(),n={recordInputs:e?.recordInputs,recordOutputs:e?.recordOutputs,functionId:e?.functionId},a=l=>{const u=o.map(c=>{var m;return(m=c[l])==null?void 0:m.bind(c)}).filter(Boolean).map(c=>m=>c(tr(m,n))),d=ro(...u);return async c=>{await d(c)}},r=o.map(l=>{var u;return(u=l.executeLanguageModelCall)==null?void 0:u.bind(l)}).filter(Boolean),s=o.map(l=>{var u;return(u=l.executeTool)==null?void 0:u.bind(l)}).filter(Boolean);return{runInTracingChannelSpan:async({type:l,event:u,execute:d})=>await Oh({type:l,event:tr(u,n)},d),startTracingChannelContext:({type:l,event:u,completion:d})=>sS({message:{type:l,event:tr(u,n)},completion:d}),onStart:a("onStart"),onStepStart:a("onStepStart"),onLanguageModelCallStart:a("onLanguageModelCallStart"),onLanguageModelCallEnd:a("onLanguageModelCallEnd"),onToolExecutionStart:a("onToolExecutionStart"),onToolExecutionEnd:a("onToolExecutionEnd"),onStepEnd:ro(a("onStepEnd"),a("onStepFinish")),onObjectStepStart:a("onObjectStepStart"),onObjectStepEnd:a("onObjectStepEnd"),onEmbedStart:a("onEmbedStart"),onEmbedEnd:a("onEmbedEnd"),onRerankStart:a("onRerankStart"),onRerankEnd:a("onRerankEnd"),onEnd:a("onEnd"),onAbort:a("onAbort"),onError:a("onError"),executeLanguageModelCall:async({execute:l,...u})=>{const d=tr(u,n);let c=l;for(const m of r){const g=c;c=()=>m({...d,execute:g})}return await Oh({type:"languageModelCall",event:d},c)},executeTool:async({execute:l,...u})=>{const d=tr(u,n);let c=l;for(const m of s){const g=c;c=()=>m({...d,execute:g})}return await c()}}}function uS(e){const t=e.map(o=>"text"in o?o.text:"").join("");return t.length>0?t:void 0}var el=class{constructor({callId:e,stepNumber:t,provider:o,modelId:n,runtimeContext:a,toolsContext:r,content:s,finishReason:l,rawFinishReason:u,usage:d,performance:c,warnings:m,request:g,response:f,providerMetadata:v}){this.callId=e,this.stepNumber=t,this.model={provider:o,modelId:n},this.runtimeContext=a,this.toolsContext=r,this.content=s,this.finishReason=l,this.rawFinishReason=u,this.usage=d,this.performance=c,this.warnings=m,this.request=g,this.response=f,this.providerMetadata=v}get text(){return this.content.filter(e=>e.type==="text").map(e=>e.text).join("")}get reasoning(){return aS(this.content.filter(e=>e.type==="reasoning"||e.type==="reasoning-file"))}get reasoningText(){return uS(this.reasoning)}get files(){return this.content.filter(e=>e.type==="file").map(e=>e.file)}get sources(){return this.content.filter(e=>e.type==="source")}get toolCalls(){return this.content.filter(e=>e.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function or({context:e,includeContext:t}){return e==null?{}:Object.fromEntries(Object.entries(e).filter(([o])=>t?.[o]===!0))}function nr({step:e,includeRuntimeContext:t,includeToolsContext:o}){return new el({callId:e.callId,stepNumber:e.stepNumber,provider:e.model.provider,modelId:e.model.modelId,runtimeContext:or({context:e.runtimeContext,includeContext:t}),toolsContext:ps({toolsContext:e.toolsContext,includeToolsContext:o}),content:e.content,finishReason:e.finishReason,rawFinishReason:e.rawFinishReason,usage:e.usage,performance:e.performance,warnings:e.warnings,request:e.request,response:e.response,providerMetadata:e.providerMetadata})}function ps({toolsContext:e,includeToolsContext:t}){return t==null?{}:Object.fromEntries(Object.entries(e).map(([o,n])=>[o,tl({toolName:o,toolContext:n,includeToolsContext:t})]))}function tl({toolName:e,toolContext:t,includeToolsContext:o}){const n=o?.[e];return or({context:t,includeContext:n})}function Rh({telemetry:e,includeRuntimeContext:t,includeToolsContext:o}){const n=lS({telemetry:e});return{...n,onStart:a=>{var r;return(r=n.onStart)==null?void 0:r.call(n,{...a,runtimeContext:or({context:a.runtimeContext,includeContext:t}),toolsContext:ps({toolsContext:a.toolsContext,includeToolsContext:o})})},onStepStart:a=>{var r;return(r=n.onStepStart)==null?void 0:r.call(n,{...a,runtimeContext:or({context:a.runtimeContext,includeContext:t}),steps:a.steps.map(s=>nr({step:s,includeRuntimeContext:t,includeToolsContext:o})),toolsContext:ps({toolsContext:a.toolsContext,includeToolsContext:o})})},onStepEnd:a=>{var r;return(r=n.onStepEnd)==null?void 0:r.call(n,nr({step:a,includeRuntimeContext:t,includeToolsContext:o}))},onStepFinish:a=>{var r;return(r=n.onStepEnd)==null?void 0:r.call(n,nr({step:a,includeRuntimeContext:t,includeToolsContext:o}))},onEnd:a=>{var r;return(r=n.onEnd)==null?void 0:r.call(n,(s=>({...a,runtimeContext:or({context:a.runtimeContext,includeContext:t}),steps:s,finalStep:s.at(-1),toolsContext:ps({toolsContext:a.toolsContext,includeToolsContext:o})}))(a.steps.map(s=>nr({step:s,includeRuntimeContext:t,includeToolsContext:o}))))},onAbort:a=>{var r;return(r=n.onAbort)==null?void 0:r.call(n,{...a,steps:a.steps.map(s=>nr({step:s,includeRuntimeContext:t,includeToolsContext:o}))})},onToolExecutionStart:a=>{var r;return(r=n.onToolExecutionStart)==null?void 0:r.call(n,{...a,toolContext:tl({toolName:a.toolCall.toolName,toolContext:a.toolContext,includeToolsContext:o})})},onToolExecutionEnd:a=>{var r;return(r=n.onToolExecutionEnd)==null?void 0:r.call(n,{...a,toolContext:tl({toolName:a.toolCall.toolName,toolContext:a.toolContext,includeToolsContext:o})})}}}function ms(e){return({steps:t})=>t.length===e}function cS(...e){return({steps:t})=>{var o,n,a;return(a=(n=(o=t[t.length-1])==null?void 0:o.toolCalls)==null?void 0:n.some(r=>e.includes(r.toolName)))!=null?a:!1}}async function Ah({stopConditions:e,steps:t}){return(await Promise.all(e.map(o=>o({steps:t})))).some(o=>o)}function ol(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}async function Nh({content:e,tools:t}){const o=[],n=[];for(const r of e)if(r.type!=="source"&&!((r.type==="tool-result"||r.type==="tool-error")&&!r.providerExecuted)&&!(r.type==="text"&&r.text.length===0))switch(r.type){case"text":n.push({type:"text",text:r.text,providerOptions:r.providerMetadata});break;case"custom":n.push({type:"custom",kind:r.kind,providerOptions:r.providerMetadata});break;case"reasoning":n.push({type:"reasoning",text:r.text,providerOptions:r.providerMetadata});break;case"file":n.push({type:"file",data:r.file.base64,mediaType:r.file.mediaType,providerOptions:r.providerMetadata});break;case"reasoning-file":n.push({type:"reasoning-file",data:r.file.base64,mediaType:r.file.mediaType,providerOptions:r.providerMetadata});break;case"tool-call":n.push({type:"tool-call",toolCallId:r.toolCallId,toolName:r.toolName,input:r.invalid&&typeof r.input!="object"?{}:r.input,providerExecuted:r.providerExecuted,providerOptions:r.providerMetadata});break;case"tool-result":{const s=await Wn({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.output,errorMode:"none"});n.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:s,providerOptions:r.providerMetadata});break}case"tool-error":{const s=await Wn({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.error,errorMode:"json"});n.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:s,providerOptions:r.providerMetadata});break}case"tool-approval-request":n.push({type:"tool-approval-request",approvalId:r.approvalId,toolCallId:r.toolCall.toolCallId,isAutomatic:r.isAutomatic,...r.signature!=null?{signature:r.signature}:{}});break}n.length>0&&o.push({role:"assistant",content:n});const a=[];for(const r of e){if(r.type!=="tool-approval-response"&&r.type!=="tool-result"&&r.type!=="tool-error")continue;if(r.type==="tool-approval-response"){a.push({type:"tool-approval-response",approvalId:r.approvalId,approved:r.approved,reason:r.reason,providerExecuted:r.providerExecuted}),r.approved===!1&&a.push({type:"tool-result",toolCallId:r.toolCall.toolCallId,toolName:r.toolCall.toolName,output:{type:"execution-denied",reason:r.reason}});continue}if(r.providerExecuted)continue;const s=await Wn({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.type==="tool-result"?r.output:r.error,errorMode:r.type==="tool-error"?"text":"none"});a.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:s,...r.providerMetadata!=null?{providerOptions:r.providerMetadata}:{}})}return a.length>0&&o.push({role:"tool",content:a}),o}var nl=new TextEncoder;function al(e){return e==null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(al).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${al(e[t])}`).join(",")}}`}function $h(e){return en(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function dS(e){return Lo(e)}async function Ph(e){const t=typeof e=="string"?nl.encode(e):e;return crypto.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}async function qh(e){const t=al(e),o=await crypto.subtle.digest("SHA-256",nl.encode(t));return $h(new Uint8Array(o))}function Dh(e,t,o,n){return nl.encode(`${e}
|
|
72
|
+
`),{name:"GatewayAuthenticationError"})}function yh(e){return{inputTokens:e.inputTokens.total,inputTokenDetails:{noCacheTokens:e.inputTokens.noCache,cacheReadTokens:e.inputTokens.cacheRead,cacheWriteTokens:e.inputTokens.cacheWrite},outputTokens:e.outputTokens.total,outputTokenDetails:{textTokens:e.outputTokens.text,reasoningTokens:e.outputTokens.reasoning},totalTokens:an(e.inputTokens.total,e.outputTokens.total),raw:e.raw}}function Bi(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function vh(e,t){var o,n,a,r,s,l,u,d,c,m;return{inputTokens:an(e.inputTokens,t.inputTokens),inputTokenDetails:{noCacheTokens:an((o=e.inputTokenDetails)==null?void 0:o.noCacheTokens,(n=t.inputTokenDetails)==null?void 0:n.noCacheTokens),cacheReadTokens:an((a=e.inputTokenDetails)==null?void 0:a.cacheReadTokens,(r=t.inputTokenDetails)==null?void 0:r.cacheReadTokens),cacheWriteTokens:an((s=e.inputTokenDetails)==null?void 0:s.cacheWriteTokens,(l=t.inputTokenDetails)==null?void 0:l.cacheWriteTokens)},outputTokens:an(e.outputTokens,t.outputTokens),outputTokenDetails:{textTokens:an((u=e.outputTokenDetails)==null?void 0:u.textTokens,(d=t.outputTokenDetails)==null?void 0:d.textTokens),reasoningTokens:an((c=e.outputTokenDetails)==null?void 0:c.reasoningTokens,(m=t.outputTokenDetails)==null?void 0:m.reasoningTokens)},totalTokens:an(e.totalTokens,t.totalTokens)}}function an(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function Vi(...e){const t=Ln(...e).map(o=>o instanceof AbortSignal?o:AbortSignal.timeout(o));return t.length===0?void 0:t.length===1?t[0]:AbortSignal.any(t)}function cs(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const o={...e};for(const n in t)if(!(n==="__proto__"||n==="constructor"||n==="prototype")&&Object.prototype.hasOwnProperty.call(t,n)){const a=t[n];if(a===void 0)continue;const r=n in e?e[n]:void 0,s=a!==null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp),l=r!=null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp);s&&l?o[n]=cs(r,a):o[n]=a}return o}function Qa(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}async function kt(e){await Promise.all(Un(e.callbacks).map(async t=>{try{await t?.(e.event)}catch{}}))}function GC({error:e,exponentialBackoffDelay:t}){const o=ut.isInstance(e)?e.responseHeaders:ut.isInstance(e.cause)?e.cause.responseHeaders:void 0;if(!o)return t;let n;const a=o["retry-after-ms"];if(a){const s=parseFloat(a);Number.isNaN(s)||(n=s)}const r=o["retry-after"];if(r&&n===void 0){const s=parseFloat(r);Number.isNaN(s)?n=Date.parse(r)-Date.now():n=s*1e3}return n!=null&&!Number.isNaN(n)&&0<=n&&(n<60*1e3||n<t)?n:t}var JC=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:o=2,abortSignal:n}={})=>async a=>_h(a,{maxRetries:e,delayInMs:t,backoffFactor:o,abortSignal:n});async function _h(e,{maxRetries:t,delayInMs:o,backoffFactor:n,abortSignal:a},r=[]){try{return await e()}catch(s){if(Fo(s)||t===0)throw s;const l=Xo(s),u=[...r,s],d=u.length;if(d>t)throw new Hm({message:`Failed after ${d} attempts. Last error: ${l}`,reason:"maxRetriesExceeded",errors:u});if(s instanceof Error&&(ut.isInstance(s)&&s.isRetryable===!0||Nt.isInstance(s)&&s.isRetryable===!0)&&d<=t)return await zn(GC({error:s,exponentialBackoffDelay:o}),{abortSignal:a}),_h(e,{maxRetries:t,delayInMs:n*o,backoffFactor:n,abortSignal:a},u);throw d===1?s:new Hm({message:`Failed after ${d} attempts with non-retryable error: '${l}'`,reason:"errorNotRetryable",errors:u})}}function Hi({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new No({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new No({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}const o=e??2;return{maxRetries:o,retry:JC({maxRetries:o,abortSignal:t})}}function Wi({abortController:e,label:t,timeoutMs:o}){if(!(e==null||o==null))return setTimeout(()=>e.abort(new DOMException(`${t} timeout of ${o}ms exceeded`,"TimeoutError")),o)}function Cn({tokens:e,durationMs:t}){const o=1e3*(e??0)/(t??0);return Number.isFinite(o)?o:0}function wh({messages:e}){const t=e.at(-1);if(t?.role!="tool")return{approvedToolApprovals:[],deniedToolApprovals:[]};const o={};for(const u of e)if(u.role==="assistant"&&typeof u.content!="string"){const d=u.content;for(const c of d)c.type==="tool-call"&&(o[c.toolCallId]=c)}const n={};for(const u of e)if(u.role==="assistant"&&typeof u.content!="string"){const d=u.content;for(const c of d)c.type==="tool-approval-request"&&(n[c.approvalId]=c)}const a={};for(const u of t.content)u.type==="tool-result"&&(a[u.toolCallId]=u);const r=[],s=[],l=t.content.filter(u=>u.type==="tool-approval-response");for(const u of l){const d=n[u.approvalId];if(d==null)throw new WT({approvalId:u.approvalId});if(a[d.toolCallId]!=null)continue;const c=o[d.toolCallId];if(c==null)throw new $i({toolCallId:d.toolCallId,approvalId:d.approvalId});const m={approvalRequest:d,approvalResponse:u,toolCall:c};u.approved?r.push(m):s.push(m)}return{approvedToolApprovals:r,deniedToolApprovals:s}}async function Gi({toolName:e,context:t,contextSchema:o}){return o==null?t:await $e({value:t,schema:o,context:{field:"tool context",entityName:e}})}async function Ji({toolCall:e,tools:t,toolsContext:o,callId:n,messages:a,abortSignal:r,timeout:s,experimental_sandbox:l,onPreliminaryToolResult:u,onToolExecutionStart:d,onToolExecutionEnd:c,executeToolInTelemetryContext:m=async({execute:f})=>await f(),runInTracingChannelSpan:g=async({execute:f})=>await f()}){const{toolName:f,toolCallId:v,input:b}=e,x=t?.[f];if(!ep(x))return;const _=await Gi({toolName:f,context:o?.[f],contextSchema:x.contextSchema}),w={toolCall:e,messages:a,toolContext:_},T={callId:n,...w};return await g({type:"executeTool",event:T,execute:async()=>{let y;await kt({event:T,callbacks:d});const C=NC(s,f),S=Vi(r,C);let R=0;try{await m({callId:n,toolCallId:v,...w,execute:async()=>{const E=Qa();try{const P=mk({tool:x,input:b,options:{toolCallId:v,messages:a,abortSignal:S,context:_,experimental_sandbox:l}});for await(const W of P)W.type==="preliminary"?u?.({...e,type:"tool-result",output:W.output,preliminary:!0}):y=W.output}finally{R=Qa()-E}}})}catch(E){const P={type:"tool-error",toolCallId:v,toolName:f,input:b,error:E,dynamic:x.type==="dynamic",...e.providerMetadata!=null?{providerMetadata:e.providerMetadata}:{},...e.toolMetadata!=null?{toolMetadata:e.toolMetadata}:{}};return await kt({event:{...T,toolOutput:P,toolExecutionMs:R},callbacks:c}),{output:P,toolExecutionMs:R}}const O={type:"tool-result",toolCallId:v,toolName:f,input:b,output:y,dynamic:x.type==="dynamic",...e.providerMetadata!=null?{providerMetadata:e.providerMetadata}:{},...e.toolMetadata!=null?{toolMetadata:e.toolMetadata}:{}};return await kt({event:{...T,toolOutput:O,toolExecutionMs:R},callbacks:c}),{output:O,toolExecutionMs:R}}})}function bh({tools:e,activeTools:t}){return e==null||t==null?e:Object.fromEntries(Object.entries(e).filter(([o])=>t.includes(o)))}var Ki=class{constructor({data:e,mediaType:t}){const o=e instanceof Uint8Array;this.base64Data=o?void 0:e,this.uint8ArrayData=o?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=en(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Lo(this.base64Data)),this.uint8ArrayData}},KC=class extends Ki{constructor(e){super(e),this.type="file"}},YC={};BT(YC,{array:()=>eS,choice:()=>tS,json:()=>oS,object:()=>QC,text:()=>ds});function XC(e){const t=["ROOT"];let o=-1,n=null,a=0;function r(c){return c>="0"&&c<="9"||c>="A"&&c<="F"||c>="a"&&c<="f"}function s(c,m,g){switch(c){case'"':{o=m,t.pop(),t.push(g),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{o=m,n=m,t.pop(),t.push(g),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=m,t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"{":{o=m,t.pop(),t.push(g),t.push("INSIDE_OBJECT_START");break}case"[":{o=m,t.pop(),t.push(g),t.push("INSIDE_ARRAY_START");break}}}function l(c,m){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{o=m,t.pop();break}}}function u(c,m){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=m,t.pop();break}}}for(let c=0;c<e.length;c++){const m=e[c];switch(t[t.length-1]){case"ROOT":s(m,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(m){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{o=c,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{m==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{m==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{m===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{s(m,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{l(m,c);break}case"INSIDE_STRING":{switch(m){case'"':{t.pop(),o=c;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:o=c}break}case"INSIDE_ARRAY_START":{m==="]"?(o=c,t.pop()):(o=c,s(m,c,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(m){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=c,t.pop();break}default:{o=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{s(m,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),m==="u"?(a=0,t.push("INSIDE_STRING_UNICODE_ESCAPE")):o=c;break}case"INSIDE_STRING_UNICODE_ESCAPE":{r(m)&&(a++,a===4&&(t.pop(),o=c));break}case"INSIDE_NUMBER":{switch(m){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(m,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(m,c);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(m,c);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(m,c);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const g=e.substring(n,c+1);!"false".startsWith(g)&&!"true".startsWith(g)&&!"null".startsWith(g)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(m,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(m,c)):o=c;break}}}let d=e.slice(0,o+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{d+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{d+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{d+="]";break}case"INSIDE_LITERAL":{const m=e.substring(n,e.length);"true".startsWith(m)?d+="true".slice(m.length):"false".startsWith(m)?d+="false".slice(m.length):"null".startsWith(m)&&(d+="null".slice(m.length))}}return d}async function er(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await So({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await So({text:XC(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var ds=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),QC=({schema:e,name:t,description:o})=>{const n=Vn(e);return{name:"object",responseFormat:je(n.jsonSchema).then(a=>({type:"json",schema:a,...t!=null&&{name:t},...o!=null&&{description:o}})),async parseCompleteOutput({text:a},r){const s=await So({text:a});if(!s.success)throw new Tn({message:"No object generated: could not parse the response.",cause:s.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const l=await Co({value:s.value,schema:n});if(!l.success)throw new Tn({message:"No object generated: response did not match schema.",cause:l.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});return l.value},async parsePartialOutput({text:a}){const r=await er(a);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:r.value}}},createElementStreamTransform(){}}},eS=({element:e,name:t,description:o})=>{const n=Vn(e);return{name:"array",responseFormat:je(n.jsonSchema).then(a=>{const{$schema:r,...s}=a;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:s}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...o!=null&&{description:o}}}),async parseCompleteOutput({text:a},r){const s=await So({text:a});if(!s.success)throw new Tn({message:"No object generated: could not parse the response.",cause:s.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const l=s.value;if(l==null||typeof l!="object"||!("elements"in l)||!Array.isArray(l.elements))throw new Tn({message:"No object generated: response did not match schema.",cause:new Qo({value:l,cause:"response must be an object with an elements array"}),text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const u=[];for(const d of l.elements){const c=await Co({value:d,schema:n});if(!c.success)throw new Tn({message:"No object generated: response did not match schema.",cause:c.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});u.push(c.value)}return u},async parsePartialOutput({text:a}){const r=await er(a);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=r.value;if(s==null||typeof s!="object"||!("elements"in s)||!Array.isArray(s.elements))return;const l=r.state==="repaired-parse"&&s.elements.length>0?s.elements.slice(0,-1):s.elements,u=[];for(const d of l){const c=await Co({value:d,schema:n});c.success&&u.push(c.value)}return{partial:u}}}},createElementStreamTransform(){let a=0;return new TransformStream({transform({partialOutput:r},s){if(r!=null)for(;a<r.length;a++)s.enqueue(r[a])}})}}},tS=({options:e,name:t,description:o})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...o!=null&&{description:o}}),async parseCompleteOutput({text:n},a){const r=await So({text:n});if(!r.success)throw new Tn({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});const s=r.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string"||!e.includes(s.result))throw new Tn({message:"No object generated: response did not match schema.",cause:new Qo({value:s,cause:"response must be an object that contains a choice value."}),text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});return s.result},async parsePartialOutput({text:n}){const a=await er(n);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const r=a.value;if(r==null||typeof r!="object"||!("result"in r)||typeof r.result!="string")return;const s=e.filter(l=>l.startsWith(r.result));return a.state==="successful-parse"?s.includes(r.result)?{partial:r.result}:void 0:s.length===1?{partial:s[0]}:void 0}}},createElementStreamTransform(){}}),oS=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:o},n){const a=await So({text:o});if(!a.success)throw new Tn({message:"No object generated: could not parse the response.",cause:a.error,text:o,response:n.response,usage:n.usage,finishReason:n.finishReason});return a.value},async parsePartialOutput({text:o}){const n=await er(o);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return n.value===void 0?void 0:{partial:n.value}}},createElementStreamTransform(){}});async function xh({toolCall:e,tools:t,repairToolCall:o,refineToolInput:n,messages:a,instructions:r}){try{if(t==null){if(e.providerExecuted&&e.dynamic)return await Yi({toolCall:await Ih(e),refineToolInput:n});throw new Pi({toolName:e.toolName})}try{return await Yi({toolCall:await kh({toolCall:e,tools:t}),refineToolInput:n})}catch(s){if(o==null||!(Pi.isInstance(s)||is.isInstance(s)))throw s;let l=null;try{l=await o({toolCall:e,tools:t,inputSchema:async({toolName:u})=>{const{inputSchema:d}=t[u];return await Vn(d).jsonSchema},instructions:r,system:r,messages:a,error:s})}catch(u){throw new oC({cause:u,originalError:s})}if(l==null)throw s;return await Yi({toolCall:await kh({toolCall:l,tools:t}),refineToolInput:n})}}catch(s){const l=await So({text:e.input}),u=l.success?l.value:e.input,d=t?.[e.toolName];return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:u,dynamic:!0,invalid:!0,error:s,title:d?.title,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...d?.metadata!=null?{toolMetadata:d.metadata}:{}}}}async function Yi({toolCall:e,refineToolInput:t}){const o=t?.[e.toolName];return o==null?e:{...e,input:await o(e.input)}}async function Ih(e){const t=e.input.trim()===""?{success:!0,value:{}}:await So({text:e.input});if(t.success===!1)throw new is({toolName:e.toolName,toolInput:e.input,cause:t.error});return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:t.value,providerExecuted:!0,dynamic:!0,providerMetadata:e.providerMetadata}}async function kh({toolCall:e,tools:t}){const o=e.toolName,n=t[o];if(n==null){if(e.providerExecuted&&e.dynamic)return await Ih(e);throw new Pi({toolName:e.toolName,availableTools:Object.keys(t)})}const a=Vn(n.inputSchema),r=e.input.trim()===""?await Co({value:{},schema:a}):await So({text:e.input,schema:a});if(r.success===!1)throw new is({toolName:o,toolInput:e.input,cause:r.error});return n.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:r.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...n.metadata!=null?{toolMetadata:n.metadata}:{},dynamic:!0,title:n.title}:{type:"tool-call",toolCallId:e.toolCallId,toolName:o,input:r.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...n.metadata!=null?{toolMetadata:n.metadata}:{},title:n.title}}function nS(e){return typeof e=="object"&&e!==null&&"type"in e?e.type==="data"?e.data:e.url:e}function aS(e){return e.map(t=>t.type==="reasoning"?{type:"reasoning",text:t.text,...t.providerMetadata!=null?{providerOptions:t.providerMetadata}:{}}:{type:"reasoning-file",data:t.file.base64,mediaType:t.file.mediaType,...t.providerMetadata!=null?{providerOptions:t.providerMetadata}:{}})}function Th(e){return e.map(t=>{if(t.type==="reasoning")return{type:"reasoning",text:t.text,...t.providerOptions!=null?{providerMetadata:t.providerOptions}:{}};const o=nS(t.data),n=o instanceof ArrayBuffer?new Uint8Array(o):o instanceof URL?o.toString():o;return{type:"reasoning-file",file:new Ki({data:n,mediaType:t.mediaType}),...t.providerOptions!=null?{providerMetadata:t.providerOptions}:{}}})}async function Xi({tools:e,toolCall:t,toolApproval:o,messages:n,toolsContext:a,runtimeContext:r}){if(o!=null&&typeof o=="function")return Ch(await o({toolCall:t,tools:e,toolsContext:a,messages:n,runtimeContext:r}));const s=t.toolName,l=e?.[s],u=t.input,d=o?.[s];if(d!=null){const c=typeof d=="function"?await d(u,{toolCallId:t.toolCallId,messages:n,toolContext:await Gi({toolName:s,context:a?.[s],contextSchema:l?.contextSchema}),runtimeContext:r}):d;return Ch(c)}return l?.needsApproval==null?{type:"not-applicable"}:(typeof l.needsApproval=="function"?await l.needsApproval(u,{toolCallId:t.toolCallId,messages:n,context:await Gi({toolName:s,context:a?.[s],contextSchema:l?.contextSchema})}):l.needsApproval)?{type:"user-approval"}:{type:"not-applicable"}}function Ch(e){return e===void 0?{type:"not-applicable"}:typeof e=="string"?{type:e}:e}function ro(...e){return async t=>{await Promise.allSettled(e.map(async o=>{await o?.(t)}))}}var Sh="ai:telemetry";function Eh(){var e;return typeof process<"u"&&((e=process.release)==null?void 0:e.name)==="node"}var Qi;async function rS(){if(Eh())return Qi==null&&(Qi=import("./redocly-openapi-docs.min.standalone-B1SVJ6KL.js").then(e=>e.bx).catch(()=>{})),Qi}function Mh(e){var t;const o=globalThis.process;try{return(t=o?.getBuiltinModule)==null?void 0:t.call(o,e)}catch{return}}async function Oh(e,t){var o;const n=await rS(),a=(o=n?.tracingChannel)==null?void 0:o.call(n,Sh);if(a==null||a.hasSubscribers===!1)return await t();let r,s,l,u=!1,d=!1;const c=()=>{try{r=Promise.resolve(t())}catch(m){r=Promise.reject(m)}return r=r.then(m=>(s=m,u=!0,m),m=>{throw l=m,d=!0,m}),r};try{return await a.tracePromise(c,e)}catch{if(d)throw l;return u?s:r!=null?await r:await t()}}function sS({message:e,completion:t}){var o;if(!Eh())return;const n=Mh("node:diagnostics_channel"),a=Mh("node:async_hooks"),r=(o=n?.tracingChannel)==null?void 0:o.call(n,Sh);if(r==null||r.hasSubscribers===!1||a==null){Promise.resolve(t).catch(()=>{});return}const s=e;let l,u=!1;const d=m=>{try{m()}catch{}},c=({result:m,error:g})=>{u||(u=!0,g!==void 0&&(s.error=g,d(()=>r.error.publish(s))),m!==void 0&&(s.result=m),d(()=>r.asyncEnd.publish(s)))};return d(()=>{r.start.runStores(s,()=>{l=new a.AsyncResource("ai.telemetry")})}),d(()=>r.end.publish(s)),Promise.resolve(t).then(m=>c({result:m}),m=>c({error:m})),{run:m=>l==null?m():l.runInAsyncScope(m)}}function iS(){var e;return(e=globalThis.AI_SDK_TELEMETRY_INTEGRATIONS)!=null?e:[]}function tr(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function lS({telemetry:e}){if(e?.isEnabled===!1)return{};const t=e?.integrations,o=t!=null?Un(t):iS(),n={recordInputs:e?.recordInputs,recordOutputs:e?.recordOutputs,functionId:e?.functionId},a=l=>{const u=o.map(c=>{var m;return(m=c[l])==null?void 0:m.bind(c)}).filter(Boolean).map(c=>m=>c(tr(m,n))),d=ro(...u);return async c=>{await d(c)}},r=o.map(l=>{var u;return(u=l.executeLanguageModelCall)==null?void 0:u.bind(l)}).filter(Boolean),s=o.map(l=>{var u;return(u=l.executeTool)==null?void 0:u.bind(l)}).filter(Boolean);return{runInTracingChannelSpan:async({type:l,event:u,execute:d})=>await Oh({type:l,event:tr(u,n)},d),startTracingChannelContext:({type:l,event:u,completion:d})=>sS({message:{type:l,event:tr(u,n)},completion:d}),onStart:a("onStart"),onStepStart:a("onStepStart"),onLanguageModelCallStart:a("onLanguageModelCallStart"),onLanguageModelCallEnd:a("onLanguageModelCallEnd"),onToolExecutionStart:a("onToolExecutionStart"),onToolExecutionEnd:a("onToolExecutionEnd"),onStepEnd:ro(a("onStepEnd"),a("onStepFinish")),onObjectStepStart:a("onObjectStepStart"),onObjectStepEnd:a("onObjectStepEnd"),onEmbedStart:a("onEmbedStart"),onEmbedEnd:a("onEmbedEnd"),onRerankStart:a("onRerankStart"),onRerankEnd:a("onRerankEnd"),onEnd:a("onEnd"),onAbort:a("onAbort"),onError:a("onError"),executeLanguageModelCall:async({execute:l,...u})=>{const d=tr(u,n);let c=l;for(const m of r){const g=c;c=()=>m({...d,execute:g})}return await Oh({type:"languageModelCall",event:d},c)},executeTool:async({execute:l,...u})=>{const d=tr(u,n);let c=l;for(const m of s){const g=c;c=()=>m({...d,execute:g})}return await c()}}}function uS(e){const t=e.map(o=>"text"in o?o.text:"").join("");return t.length>0?t:void 0}var el=class{constructor({callId:e,stepNumber:t,provider:o,modelId:n,runtimeContext:a,toolsContext:r,content:s,finishReason:l,rawFinishReason:u,usage:d,performance:c,warnings:m,request:g,response:f,providerMetadata:v}){this.callId=e,this.stepNumber=t,this.model={provider:o,modelId:n},this.runtimeContext=a,this.toolsContext=r,this.content=s,this.finishReason=l,this.rawFinishReason=u,this.usage=d,this.performance=c,this.warnings=m,this.request=g,this.response=f,this.providerMetadata=v}get text(){return this.content.filter(e=>e.type==="text").map(e=>e.text).join("")}get reasoning(){return aS(this.content.filter(e=>e.type==="reasoning"||e.type==="reasoning-file"))}get reasoningText(){return uS(this.reasoning)}get files(){return this.content.filter(e=>e.type==="file").map(e=>e.file)}get sources(){return this.content.filter(e=>e.type==="source")}get toolCalls(){return this.content.filter(e=>e.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function or({context:e,includeContext:t}){return e==null?{}:Object.fromEntries(Object.entries(e).filter(([o])=>t?.[o]===!0))}function nr({step:e,includeRuntimeContext:t,includeToolsContext:o}){return new el({callId:e.callId,stepNumber:e.stepNumber,provider:e.model.provider,modelId:e.model.modelId,runtimeContext:or({context:e.runtimeContext,includeContext:t}),toolsContext:ps({toolsContext:e.toolsContext,includeToolsContext:o}),content:e.content,finishReason:e.finishReason,rawFinishReason:e.rawFinishReason,usage:e.usage,performance:e.performance,warnings:e.warnings,request:e.request,response:e.response,providerMetadata:e.providerMetadata})}function ps({toolsContext:e,includeToolsContext:t}){return t==null?{}:Object.fromEntries(Object.entries(e).map(([o,n])=>[o,tl({toolName:o,toolContext:n,includeToolsContext:t})]))}function tl({toolName:e,toolContext:t,includeToolsContext:o}){const n=o?.[e];return or({context:t,includeContext:n})}function Rh({telemetry:e,includeRuntimeContext:t,includeToolsContext:o}){const n=lS({telemetry:e});return{...n,onStart:a=>{var r;return(r=n.onStart)==null?void 0:r.call(n,{...a,runtimeContext:or({context:a.runtimeContext,includeContext:t}),toolsContext:ps({toolsContext:a.toolsContext,includeToolsContext:o})})},onStepStart:a=>{var r;return(r=n.onStepStart)==null?void 0:r.call(n,{...a,runtimeContext:or({context:a.runtimeContext,includeContext:t}),steps:a.steps.map(s=>nr({step:s,includeRuntimeContext:t,includeToolsContext:o})),toolsContext:ps({toolsContext:a.toolsContext,includeToolsContext:o})})},onStepEnd:a=>{var r;return(r=n.onStepEnd)==null?void 0:r.call(n,nr({step:a,includeRuntimeContext:t,includeToolsContext:o}))},onStepFinish:a=>{var r;return(r=n.onStepEnd)==null?void 0:r.call(n,nr({step:a,includeRuntimeContext:t,includeToolsContext:o}))},onEnd:a=>{var r;return(r=n.onEnd)==null?void 0:r.call(n,(s=>({...a,runtimeContext:or({context:a.runtimeContext,includeContext:t}),steps:s,finalStep:s.at(-1),toolsContext:ps({toolsContext:a.toolsContext,includeToolsContext:o})}))(a.steps.map(s=>nr({step:s,includeRuntimeContext:t,includeToolsContext:o}))))},onAbort:a=>{var r;return(r=n.onAbort)==null?void 0:r.call(n,{...a,steps:a.steps.map(s=>nr({step:s,includeRuntimeContext:t,includeToolsContext:o}))})},onToolExecutionStart:a=>{var r;return(r=n.onToolExecutionStart)==null?void 0:r.call(n,{...a,toolContext:tl({toolName:a.toolCall.toolName,toolContext:a.toolContext,includeToolsContext:o})})},onToolExecutionEnd:a=>{var r;return(r=n.onToolExecutionEnd)==null?void 0:r.call(n,{...a,toolContext:tl({toolName:a.toolCall.toolName,toolContext:a.toolContext,includeToolsContext:o})})}}}function ms(e){return({steps:t})=>t.length===e}function cS(...e){return({steps:t})=>{var o,n,a;return(a=(n=(o=t[t.length-1])==null?void 0:o.toolCalls)==null?void 0:n.some(r=>e.includes(r.toolName)))!=null?a:!1}}async function Ah({stopConditions:e,steps:t}){return(await Promise.all(e.map(o=>o({steps:t})))).some(o=>o)}function ol(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}async function Nh({content:e,tools:t}){const o=[],n=[];for(const r of e)if(r.type!=="source"&&!((r.type==="tool-result"||r.type==="tool-error")&&!r.providerExecuted)&&!(r.type==="text"&&r.text.length===0))switch(r.type){case"text":n.push({type:"text",text:r.text,providerOptions:r.providerMetadata});break;case"custom":n.push({type:"custom",kind:r.kind,providerOptions:r.providerMetadata});break;case"reasoning":n.push({type:"reasoning",text:r.text,providerOptions:r.providerMetadata});break;case"file":n.push({type:"file",data:r.file.base64,mediaType:r.file.mediaType,providerOptions:r.providerMetadata});break;case"reasoning-file":n.push({type:"reasoning-file",data:r.file.base64,mediaType:r.file.mediaType,providerOptions:r.providerMetadata});break;case"tool-call":n.push({type:"tool-call",toolCallId:r.toolCallId,toolName:r.toolName,input:r.invalid&&typeof r.input!="object"?{}:r.input,providerExecuted:r.providerExecuted,providerOptions:r.providerMetadata});break;case"tool-result":{const s=await Wn({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.output,errorMode:"none"});n.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:s,providerOptions:r.providerMetadata});break}case"tool-error":{const s=await Wn({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.error,errorMode:"json"});n.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:s,providerOptions:r.providerMetadata});break}case"tool-approval-request":n.push({type:"tool-approval-request",approvalId:r.approvalId,toolCallId:r.toolCall.toolCallId,isAutomatic:r.isAutomatic,...r.signature!=null?{signature:r.signature}:{}});break}n.length>0&&o.push({role:"assistant",content:n});const a=[];for(const r of e){if(r.type!=="tool-approval-response"&&r.type!=="tool-result"&&r.type!=="tool-error")continue;if(r.type==="tool-approval-response"){a.push({type:"tool-approval-response",approvalId:r.approvalId,approved:r.approved,reason:r.reason,providerExecuted:r.providerExecuted}),r.approved===!1&&a.push({type:"tool-result",toolCallId:r.toolCall.toolCallId,toolName:r.toolCall.toolName,output:{type:"execution-denied",reason:r.reason}});continue}if(r.providerExecuted)continue;const s=await Wn({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.type==="tool-result"?r.output:r.error,errorMode:r.type==="tool-error"?"text":"none"});a.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:s,...r.providerMetadata!=null?{providerOptions:r.providerMetadata}:{}})}return a.length>0&&o.push({role:"tool",content:a}),o}var nl=new TextEncoder;function al(e){return e==null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(al).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${al(e[t])}`).join(",")}}`}function $h(e){return en(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function dS(e){return Lo(e)}async function Ph(e){const t=typeof e=="string"?nl.encode(e):e;return crypto.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}async function qh(e){const t=al(e),o=await crypto.subtle.digest("SHA-256",nl.encode(t));return $h(new Uint8Array(o))}function Dh(e,t,o,n){return nl.encode(`${e}
|
|
73
73
|
${t}
|
|
74
74
|
${o}
|
|
75
75
|
${n}`)}async function pS({secret:e,approvalId:t,toolCallId:o,toolName:n,input:a}){const r=await Ph(e),s=await qh(a),l=Dh(t,o,n,s),u=await crypto.subtle.sign("HMAC",r,l);return $h(new Uint8Array(u))}async function mS({secret:e,signature:t,approvalId:o,toolCallId:n,toolName:a,input:r}){const s=await Ph(e),l=await qh(r),u=Dh(o,n,a,l),d=dS(t);return crypto.subtle.verify("HMAC",s,d,u)}async function jh({secret:e,approvalId:t,toolCallId:o,toolName:n,input:a}){if(e!=null)return pS({secret:e,approvalId:t,toolCallId:o,toolName:n,input:a})}async function Uh({approvedToolApprovals:e,tools:t,toolApproval:o,messages:n,toolsContext:a,runtimeContext:r,toolApprovalSecret:s}){var l;const u=[],d=[];for(const c of e){const{toolCall:m,approvalRequest:g}=c,f=t?.[m.toolName];if(s!=null){if(g.signature==null)throw new im({approvalId:g.approvalId,toolCallId:m.toolCallId,reason:"missing signature"});if(!await mS({secret:s,signature:g.signature,approvalId:g.approvalId,toolCallId:m.toolCallId,toolName:m.toolName,input:m.input}))throw new im({approvalId:g.approvalId,toolCallId:m.toolCallId,reason:"invalid signature"})}if(ep(f)&&f.inputSchema!=null){const b=await Co({value:m.input,schema:Vn(f.inputSchema)});if(!b.success)throw new is({toolName:m.toolName,toolInput:JSON.stringify(m.input),cause:b.error})}const v=await Xi({tools:t,toolApproval:o,toolCall:m,messages:n,toolsContext:a,runtimeContext:r});v.type==="denied"?d.push({...c,approvalResponse:{...c.approvalResponse,approved:!1,reason:(l=v.reason)!=null?l:c.approvalResponse.reason}}):u.push(c)}return{approvedToolApprovals:u,deniedToolApprovals:d}}var hS=To({prefix:"aitxt",size:24}),fS=To({prefix:"call",size:24});async function gS({model:e,tools:t,toolChoice:o,instructions:n,system:a,prompt:r,messages:s,allowSystemInMessages:l,maxRetries:u,abortSignal:d,timeout:c,headers:m,stopWhen:g=ms(1),experimental_sandbox:f,output:v,toolApproval:b,experimental_toolApprovalSecret:x,experimental_telemetry:_,telemetry:w=_,providerOptions:T,activeTools:y,toolOrder:C,prepareStep:S,experimental_repairToolCall:R,experimental_refineToolInput:O,experimental_download:E,runtimeContext:P={},toolsContext:W={},experimental_include:Q,include:B=Q,_internal:{generateId:F=hS,generateCallId:V=fS,now:ie=Qa}={},onStart:X,experimental_onStart:H,onStepStart:z,experimental_onStepStart:Z,onLanguageModelCallStart:L,experimental_onLanguageModelCallStart:re,onLanguageModelCallEnd:ae,experimental_onLanguageModelCallEnd:he,onToolExecutionStart:be,onToolExecutionEnd:le,experimental_onToolCallStart:U,experimental_onToolCallFinish:Y,onStepEnd:oe,onStepFinish:q,onFinish:pe,onEnd:j=pe,...k}){var N,D,me,Je;B={requestBody:(N=B?.requestBody)!=null?N:!1,requestMessages:(D=B?.requestMessages)!=null?D:!1,responseBody:(me=B?.responseBody)!=null?me:!1};const Ct=Ka(e),et=Un(g),Be=X??H,Re=z??Z,St=L??re,lo=ae??he,uo=be??U,to=le??Y,Ft=oe??q,xe=ch(c),oo=dh(c),Go=oo!=null?new AbortController:void 0,Zt=Vi(d,xe,Go?.signal),{maxRetries:dn,retry:_o}=Hi({maxRetries:u,abortSignal:Zt}),Dt=Ui(k),M=Zo(m??{},`ai/${oh}`),te=await Zi({instructions:n,system:a,prompt:r,messages:s,allowSystemInMessages:l}),Se=V(),Me=Rh({telemetry:w,includeRuntimeContext:w?.includeRuntimeContext,includeToolsContext:w?.includeToolsContext}),Ke=(Je=Me.runInTracingChannelSpan)!=null?Je:async({execute:xt})=>await xt(),ht={callId:Se,operationId:"ai.generateText",provider:Ct.provider,modelId:Ct.modelId,instructions:te.instructions,messages:te.messages,tools:t,toolChoice:o,activeTools:y,toolOrder:C,maxOutputTokens:Dt.maxOutputTokens,temperature:Dt.temperature,topP:Dt.topP,topK:Dt.topK,presencePenalty:Dt.presencePenalty,frequencyPenalty:Dt.frequencyPenalty,stopSequences:Dt.stopSequences,seed:Dt.seed,reasoning:Dt.reasoning,maxRetries:dn,timeout:c,headers:M,providerOptions:T,output:v,runtimeContext:P,toolsContext:W};return await Ke({type:"generateText",event:ht,execute:async()=>{var xt;await kt({event:ht,callbacks:[Be,Me.onStart]});try{const at=te.messages,co=[],{approvedToolApprovals:wo,deniedToolApprovals:ve}=wh({messages:at}),{approvedToolApprovals:Qe,deniedToolApprovals:$o}=await Uh({approvedToolApprovals:wo.filter(Ye=>!Ye.toolCall.providerExecuted),tools:t,toolApproval:b,messages:at,toolsContext:W,runtimeContext:P,toolApprovalSecret:x}),Mn=[...ve,...$o];if(Mn.length>0||Qe.length>0){const Ye=await zh({toolCalls:Qe.map(Mt=>Mt.toolCall),tools:t,callId:Se,messages:at,abortSignal:Zt,timeout:c,experimental_sandbox:f,toolsContext:W,onToolExecutionStart:Mt=>kt({event:Mt,callbacks:[uo,Me.onToolExecutionStart]}),onToolExecutionEnd:Mt=>kt({event:Mt,callbacks:[to,Me.onToolExecutionEnd]}),executeToolInTelemetryContext:Me.executeTool,runInTracingChannelSpan:Ke}),lt=[];for(const Mt of Ye){const Yt=Mt.output,On=await Wn({toolCallId:Yt.toolCallId,input:Yt.input,tool:t?.[Yt.toolName],output:Yt.type==="tool-result"?Yt.output:Yt.error,errorMode:Yt.type==="tool-error"?"text":"none"});lt.push({type:"tool-result",toolCallId:Yt.toolCallId,toolName:Yt.toolName,output:On})}for(const Mt of Mn)lt.push({type:"tool-result",toolCallId:Mt.toolCall.toolCallId,toolName:Mt.toolCall.toolName,output:{type:"execution-denied",reason:Mt.approvalResponse.reason,...Mt.toolCall.providerExecuted&&{providerOptions:{openai:{approvalId:Mt.approvalResponse.approvalId}}}}});co.push({role:"tool",content:lt})}const bo=Ui(k);let pt,po=[],xo=[],Fe=[],Po=[];const ze=[];let Kt=te.instructions,_t=[...at,...co];const pn=new Map;do{const Ye=Wi({abortController:Go,label:"Step",timeoutMs:oo}),lt=ze.length;try{await Ke({type:"step",event:{callId:Se,stepNumber:lt},execute:async()=>{var Mt,Yt,On,aa,gr,yr,Jo,ra,Sa,vr,_r,wr,Ea,br,xr,Ir,kr;const Tr=[...co,...ze.flatMap(Ce=>Ce.response.messages)],Rn=_t,Ot=await S?.({model:Ct,steps:ze,stepNumber:ze.length,instructions:Kt,initialInstructions:te.instructions,messages:Rn,initialMessages:at,responseMessages:Tr,runtimeContext:P,toolsContext:W,experimental_sandbox:f}),Ma=(Mt=Ot?.experimental_sandbox)!=null?Mt:f,jt=Ka((Yt=Ot?.model)!=null?Yt:Ct),qo=(aa=(On=Ot?.instructions)!=null?On:Ot?.system)!=null?aa:Kt,sa=await nh({prompt:{instructions:qo,messages:(gr=Ot?.messages)!=null?gr:Rn},supportedUrls:await jt.supportedUrls,download:E,provider:jt.provider.split(".")[0]});P=(yr=Ot?.runtimeContext)!=null?yr:P,W=(Jo=Ot?.toolsContext)!=null?Jo:W;const Oa=bh({tools:t,activeTools:(ra=Ot?.activeTools)!=null?ra:y}),Ra=(Sa=Ot?.toolOrder)!=null?Sa:C,An=await Li({tools:Oa,toolOrder:Ra,toolsContext:W,experimental_sandbox:Ma}),Aa=zi({toolChoice:(vr=Ot?.toolChoice)!=null?vr:o}),Mo=(_r=Ot?.messages)!=null?_r:Rn,Na=cs(T,Ot?.providerOptions);await kt({event:{callId:Se,provider:jt.provider,modelId:jt.modelId,stepNumber:lt,instructions:qo,messages:Mo,tools:t,toolChoice:(wr=Ot?.toolChoice)!=null?wr:o,activeTools:(Ea=Ot?.activeTools)!=null?Ea:y,toolOrder:Ra,steps:[...ze],providerOptions:Na,output:v,runtimeContext:P,promptMessages:sa,stepTools:An,stepToolChoice:Aa,toolsContext:W},callbacks:[Re,Me.onStepStart]});const Cr={provider:jt.provider,modelId:jt.modelId,instructions:qo,messages:Mo,tools:An,...bo},hn={callId:Se,...Cr},Ae=ie();await kt({event:hn,callbacks:[St,Me.onLanguageModelCallStart]});const $t=(br=Me.executeLanguageModelCall)!=null?br:async({execute:Ce})=>await Ce();pt=await _o(async()=>{var Ce,Rt,jo,Ko,Yo,Kl,Yl,Xl;const ia=await $t({...hn,execute:async()=>await jt.doGenerate({...bo,tools:An,toolChoice:Aa,responseFormat:await v?.responseFormat,prompt:sa,providerOptions:Na,abortSignal:Zt,headers:M})}),fv={id:(Rt=(Ce=ia.response)==null?void 0:Ce.id)!=null?Rt:F(),timestamp:(Ko=(jo=ia.response)==null?void 0:jo.timestamp)!=null?Ko:new Date,modelId:(Kl=(Yo=ia.response)==null?void 0:Yo.modelId)!=null?Kl:jt.modelId,headers:(Yl=ia.response)==null?void 0:Yl.headers,body:(Xl=ia.response)==null?void 0:Xl.body};return{...ia,response:fv}});const mo=ie()-Ae,Ut=yh(pt.usage),Xt=await Promise.all(pt.content.filter(Ce=>Ce.type==="tool-call").map(Ce=>xh({toolCall:Ce,tools:t,repairToolCall:R,refineToolInput:O,instructions:qo,messages:Mo}))),Do={},Nn={},It=new Set,Sr=Lh({content:pt.content,toolCalls:Xt,toolOutputs:[],toolApprovalRequests:[],toolApprovalResponses:[],tools:t});await kt({event:{callId:Se,provider:jt.provider,modelId:jt.modelId,finishReason:pt.finishReason.unified,usage:Ut,content:Sr,responseId:pt.response.id,performance:{responseTimeMs:mo,effectiveOutputTokensPerSecond:Cn({tokens:Ut.outputTokens,durationMs:mo}),outputTokensPerSecond:void 0,inputTokensPerSecond:void 0,effectiveTotalTokensPerSecond:Cn({tokens:ol(Ut.inputTokens,Ut.outputTokens),durationMs:mo}),timeToFirstOutputMs:void 0}},callbacks:[lo,Me.onLanguageModelCallEnd]});for(const Ce of Xt){if(Ce.invalid)continue;const Rt=t?.[Ce.toolName];if(Rt==null)continue;Rt?.onInputAvailable!=null&&await Rt.onInputAvailable({input:Ce.input,toolCallId:Ce.toolCallId,messages:Mo,abortSignal:Zt,context:P});const jo=await Xi({tools:t,toolApproval:b,toolCall:Ce,messages:Mo,toolsContext:W,runtimeContext:P});if(jo.type==="not-applicable")continue;const Ko=F(),Yo=await jh({secret:x,approvalId:Ko,toolCallId:Ce.toolCallId,toolName:Ce.toolName,input:Ce.input});switch(jo.type){case"user-approval":{Do[Ce.toolCallId]={type:"tool-approval-request",approvalId:Ko,toolCall:Ce,...Yo!=null?{signature:Yo}:{}},It.add(Ce.toolCallId);break}case"approved":{Do[Ce.toolCallId]={type:"tool-approval-request",approvalId:Ko,toolCall:Ce,isAutomatic:!0,...Yo!=null?{signature:Yo}:{}},Nn[Ce.toolCallId]={type:"tool-approval-response",approvalId:Ko,toolCall:Ce,approved:!0,reason:jo.reason,providerExecuted:Ce.providerExecuted};break}case"denied":{Do[Ce.toolCallId]={type:"tool-approval-request",approvalId:Ko,toolCall:Ce,isAutomatic:!0,...Yo!=null?{signature:Yo}:{}},Nn[Ce.toolCallId]={type:"tool-approval-response",approvalId:Ko,toolCall:Ce,approved:!1,reason:jo.reason,providerExecuted:Ce.providerExecuted},It.add(Ce.toolCallId);break}}}const $a=Xt.filter(Ce=>Ce.invalid&&Ce.dynamic);xo=[];for(const Ce of $a)xo.push({type:"tool-error",toolCallId:Ce.toolCallId,toolName:Ce.toolName,input:Ce.input,error:Xo(Ce.error),dynamic:!0});po=Xt.filter(Ce=>!Ce.providerExecuted),Fe=Object.values(Nn),Po=Fe.filter(Ce=>Ce.approved===!1);const Wl={};if(t!=null){const Ce=await zh({toolCalls:po.filter(Rt=>!Rt.invalid&&!It.has(Rt.toolCallId)),tools:t,callId:Se,messages:Mo,abortSignal:Zt,timeout:c,experimental_sandbox:Ma,toolsContext:W,onToolExecutionStart:Rt=>kt({event:Rt,callbacks:[uo,Me.onToolExecutionStart]}),onToolExecutionEnd:Rt=>kt({event:Rt,callbacks:[to,Me.onToolExecutionEnd]}),executeToolInTelemetryContext:Me.executeTool,runInTracingChannelSpan:Ke});for(const Rt of Ce)Wl[Rt.output.toolCallId]=Rt.toolExecutionMs,xo.push(Rt.output)}const dv=ie()-Ae,pv={effectiveOutputTokensPerSecond:Cn({tokens:Ut.outputTokens,durationMs:mo}),outputTokensPerSecond:void 0,inputTokensPerSecond:void 0,effectiveTotalTokensPerSecond:Cn({tokens:ol(Ut.inputTokens,Ut.outputTokens),durationMs:mo}),stepTimeMs:dv,responseTimeMs:mo,toolExecutionMs:Wl,timeToFirstOutputMs:void 0};for(const Ce of Xt){if(!Ce.providerExecuted)continue;const Rt=t?.[Ce.toolName];Rt?.type==="provider"&&Rt.supportsDeferredResults&&(pt.content.some(jo=>jo.type==="tool-result"&&jo.toolCallId===Ce.toolCallId)||pn.set(Ce.toolCallId,{toolName:Ce.toolName}))}for(const Ce of pt.content)Ce.type==="tool-result"&&pn.delete(Ce.toolCallId);const Gl=Lh({content:pt.content,toolCalls:Xt,toolOutputs:xo,toolApprovalRequests:Object.values(Do),toolApprovalResponses:Fe,tools:t}),Jl=await Nh({content:Gl,tools:t}),mv={...pt.request,body:B.requestBody?(xr=pt.request)==null?void 0:xr.body:void 0,messages:B.requestMessages?Ya(Mo):void 0},hv={...pt.response,messages:Ya(Jl),body:B.responseBody?(Ir=pt.response)==null?void 0:Ir.body:void 0},qs=new el({callId:Se,stepNumber:lt,provider:jt.provider,modelId:jt.modelId,runtimeContext:P,content:Gl,finishReason:pt.finishReason.unified,rawFinishReason:pt.finishReason.raw,usage:Ut,performance:pv,warnings:pt.warnings,providerMetadata:pt.providerMetadata,request:mv,response:hv,toolsContext:W});return va({warnings:(kr=pt.warnings)!=null?kr:[],provider:jt.provider,model:jt.modelId}),ze.push(qs),Kt=qo,_t=[...Mo,...Jl],await kt({event:qs,callbacks:[Ft,Me.onStepEnd]}),qs}})}finally{Ye!=null&&clearTimeout(Ye)}}while((po.length>0&&xo.length+Po.length===po.length||pn.size>0)&&!await Ah({stopConditions:et,steps:ze}));const Et=ze[ze.length-1],ta=ze.reduce((Ye,lt)=>vh(Ye,lt.usage),{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0}),dr=ze.flatMap(Ye=>Ye.files),pr=ze.flatMap(Ye=>Ye.sources),mr=ze.flatMap(Ye=>Ye.toolCalls),mn=ze.flatMap(Ye=>Ye.staticToolCalls),$s=ze.flatMap(Ye=>Ye.dynamicToolCalls),oa=ze.flatMap(Ye=>Ye.toolResults),na=ze.flatMap(Ye=>Ye.staticToolResults),Ca=ze.flatMap(Ye=>Ye.dynamicToolResults),hr=ze.flatMap(Ye=>{var lt;return(lt=Ye.warnings)!=null?lt:[]}),Ps={callId:Se,stepNumber:Et.stepNumber,model:Et.model,runtimeContext:Et.runtimeContext,finishReason:Et.finishReason,rawFinishReason:Et.rawFinishReason,usage:ta,totalUsage:ta,content:ze.flatMap(Ye=>Ye.content),text:Et.text,reasoning:Et.reasoning,reasoningText:Et.reasoningText,files:dr,sources:pr,toolCalls:mr,staticToolCalls:mn,dynamicToolCalls:$s,toolResults:oa,staticToolResults:na,dynamicToolResults:Ca,responseMessages:[...co,...ze.flatMap(Ye=>Ye.response.messages)],warnings:hr,request:Et.request,response:Et.response,providerMetadata:Et.providerMetadata,steps:ze,finalStep:Et,toolsContext:W};await kt({event:Ps,callbacks:[j,Me.onEnd]});let fr;return Et.finishReason==="stop"&&(fr=await(v??ds()).parseCompleteOutput({text:Et.text},{response:Et.response,usage:Et.usage,finishReason:Et.finishReason})),new yS({initialResponseMessages:co,steps:ze,totalUsage:ta,output:fr})}catch(at){throw await((xt=Me.onError)==null?void 0:xt.call(Me,{callId:Se,error:at})),gh(at)}}})}async function zh({toolCalls:e,tools:t,callId:o,messages:n,abortSignal:a,timeout:r,experimental_sandbox:s,toolsContext:l,onToolExecutionStart:u,onToolExecutionEnd:d,executeToolInTelemetryContext:c,runInTracingChannelSpan:m}){return(await Promise.all(e.map(async g=>await Ji({toolCall:g,tools:t,callId:o,messages:n,abortSignal:a,timeout:r,experimental_sandbox:s,toolsContext:l,onToolExecutionStart:u,onToolExecutionEnd:d,executeToolInTelemetryContext:c,runInTracingChannelSpan:m})))).filter(g=>g!=null)}var yS=class{constructor(e){this.initialResponseMessages=e.initialResponseMessages,this.steps=e.steps,this._output=e.output,this.totalUsage=e.totalUsage}get finalStep(){return this.steps.at(-1)}get content(){return this.steps.flatMap(e=>e.content)}get text(){return this.finalStep.text}get files(){return this.steps.flatMap(e=>e.files)}get reasoningText(){return this.finalStep.reasoningText}get reasoning(){return Th(this.finalStep.reasoning)}get toolCalls(){return this.steps.flatMap(e=>e.toolCalls)}get staticToolCalls(){return this.steps.flatMap(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.steps.flatMap(e=>e.dynamicToolCalls)}get toolResults(){return this.steps.flatMap(e=>e.toolResults)}get staticToolResults(){return this.steps.flatMap(e=>e.staticToolResults)}get dynamicToolResults(){return this.steps.flatMap(e=>e.dynamicToolResults)}get sources(){return this.steps.flatMap(e=>e.sources)}get finishReason(){return this.finalStep.finishReason}get rawFinishReason(){return this.finalStep.rawFinishReason}get warnings(){return this.steps.flatMap(e=>{var t;return(t=e.warnings)!=null?t:[]})}get providerMetadata(){return this.finalStep.providerMetadata}get response(){return this.finalStep.response}get responseMessages(){return[...this.initialResponseMessages,...this.steps.flatMap(e=>e.response.messages)]}get request(){return this.finalStep.request}get usage(){return this.totalUsage}get output(){if(this._output==null)throw new ls;return this._output}};function Lh({content:e,toolCalls:t,toolOutputs:o,toolApprovalRequests:n,toolApprovalResponses:a,tools:r}){const s=[],l=[],u=[],d=new Set(a.map(c=>c.toolCall.toolCallId));for(const c of e)switch(c.type){case"text":case"reasoning":case"custom":case"source":s.push(c);break;case"file":case"reasoning-file":{s.push({type:c.type,file:new Ki({data:c.data.type==="data"?c.data.data:c.data.url.toString(),mediaType:c.mediaType}),...c.providerMetadata!=null?{providerMetadata:c.providerMetadata}:{}});break}case"tool-call":{s.push(t.find(m=>m.toolCallId===c.toolCallId));break}case"tool-result":{const m=t.find(g=>g.toolCallId===c.toolCallId);if(m==null){const g=r?.[c.toolName];if(!(g?.type==="provider"&&g.supportsDeferredResults))throw new Error(`Tool call ${c.toolCallId} not found.`);c.isError?s.push({type:"tool-error",toolCallId:c.toolCallId,toolName:c.toolName,input:void 0,error:c.result,providerExecuted:!0,dynamic:c.dynamic,...c.providerMetadata!=null?{providerMetadata:c.providerMetadata}:{},...g?.metadata!=null?{toolMetadata:g.metadata}:{}}):s.push({type:"tool-result",toolCallId:c.toolCallId,toolName:c.toolName,input:void 0,output:c.result,providerExecuted:!0,dynamic:c.dynamic,...c.providerMetadata!=null?{providerMetadata:c.providerMetadata}:{},...g?.metadata!=null?{toolMetadata:g.metadata}:{}});break}c.isError?s.push({type:"tool-error",toolCallId:c.toolCallId,toolName:c.toolName,input:m.input,error:c.result,providerExecuted:!0,dynamic:m.dynamic,...c.providerMetadata!=null?{providerMetadata:c.providerMetadata}:{},...m.toolMetadata!=null?{toolMetadata:m.toolMetadata}:{}}):s.push({type:"tool-result",toolCallId:c.toolCallId,toolName:c.toolName,input:m.input,output:c.result,providerExecuted:!0,dynamic:m.dynamic,...c.providerMetadata!=null?{providerMetadata:c.providerMetadata}:{},...m.toolMetadata!=null?{toolMetadata:m.toolMetadata}:{}});break}case"tool-approval-request":{const m=t.find(g=>g.toolCallId===c.toolCallId);if(m==null)throw new $i({toolCallId:c.toolCallId,approvalId:c.approvalId});s.push({type:"tool-approval-request",approvalId:c.approvalId,toolCall:m});break}}for(const c of o)d.has(c.toolCallId)?l.push(c):u.push(c);return[...s,...u,...n,...a,...l]}function hs(e,t){const o=new Headers(e??{});for(const[n,a]of Object.entries(t))o.has(n)||o.set(n,a);return o}function vS({status:e,statusText:t,headers:o,stream:n}){return new Response(n.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:hs(o,{"content-type":"text/plain; charset=utf-8"})})}function Fh({response:e,status:t,statusText:o,headers:n,stream:a}){const r=t??200;o!==void 0?e.writeHead(r,o,n):e.writeHead(r,n);const s=a.getReader();(async()=>{try{for(;;){const{done:l,value:u}=await s.read();if(l)break;e.write(u)||await new Promise(d=>{e.once("drain",d)})}}catch(l){throw l}finally{e.end()}})()}function _S({response:e,status:t,statusText:o,headers:n,stream:a}){Fh({response:e,status:t,statusText:o,headers:Object.fromEntries(hs(n,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function wS({stream:e}){return e.pipeThrough(new TransformStream({transform(t,o){t.type==="text-delta"&&o.enqueue(t.text)}}))}var Zh=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
@@ -305,11 +305,11 @@ Duplicates of earlier statuses and statuses reported back-to-back with no action
|
|
|
305
305
|
**After the run**
|
|
306
306
|
- Report the outcome from this tool's result; do not re-read it with other tools.
|
|
307
307
|
- When \`historyId\` is non-null, link to the run: \`[label](replay://workflow-run?collectionId=...&workflowId=...&historyId=...)\`. That link reopens this exact run; it never starts a new one. When it is null, say the run was not saved instead of building a link; never put the literal text null in the url.
|
|
308
|
-
- Each call starts a NEW run. Call it again only when the user wants another run.`,Uq=Ha({collectionId:$().describe("Id of the collection that holds the workflow."),workflowId:$().describe("Id of the workflow to run.")}),zq=ue({stepId:$(),statusCode:Ne().int().nullable(),passed:ho()}),Lq=ue({collectionId:$().describe("Resolved id of the collection that was run."),workflowId:$().describe("Resolved id of the workflow that was run."),historyId:$().nullable().describe("Id of this saved run. Put it in the workflow-run link as &historyId=... so the user can reopen this exact run. Null when history is not persisted."),success:ho().describe("Overall verdict from the execution engine. False when a step failed a non-warn check or the run hit the global timeout. Can be false even when passedSteps equals totalSteps: a step that failed and then passed on retry is not counted as failed here."),timedOut:ho().describe("True when the run hit the global execution timeout. Then success is false even if every listed step passed; report that the run timed out rather than blaming a step."),durationMs:Ne().describe("Total run time in milliseconds."),totalSteps:Ne().int().nonnegative(),passedSteps:Ne().int().nonnegative(),steps:De(zq).describe("Per-step outcome, in execution order: stepId, HTTP statusCode, and pass/fail only \u2014 no check name or failure message.")}),Fq=ln(Lq),Zq={description:jq,inputSchema:Uq,outputSchema:Fq,needsApproval:!1};function Bq(e,t){return async(o,n)=>{const a=o.collectionId.trim(),r=o.workflowId.trim();if(!a)return Pe("collectionId is required.");if(!r)return Pe("workflowId is required.");const s=ql(e,a,r);if(!s.ok)return Pe(s.message,s.details);try{const{workflowResult:l,historyId:u,verdict:d}=await t({collectionId:s.value.collectionId,workflowId:s.value.workflowId});return{isError:!1,data:{collectionId:s.value.collectionId,workflowId:s.value.workflowId,historyId:u,success:d.succeeded,timedOut:d.timedOut,durationMs:l.totalTimeMs,totalSteps:d.totalSteps,passedSteps:d.passedSteps,steps:d.steps.map(({step:c,passed:m})=>({stepId:c.stepId,statusCode:c.response?.statusCode??null,passed:m}))}}}catch(l){return Pe(l instanceof Error?l.message:"Workflow execution failed.")}}}const Ty={name:"run_workflow",definition:Zq,createExecutor:e=>Bq(e.store,e.runWorkflow)},Vq=25,Hq='RAG semantic search over OpenAPI specs and Arazzo assets in the current Replay project.\n\n**What it does**\n- Finds OpenAPI and Arazzo entities via natural-language query (scoped by `type`), returning up to `count` matches with detail via `include`.\n\n**Use when**\n- You need **initial schema/context** or request schema details from project assets.\n- You need canonical IDs/coordinates for an API, collection, workflow, or step.\n- You need to find operations/workflows/steps by natural language when IDs are unknown.\n\n**Never use when**\n- You are only verifying post-action UI changes in the active tab.\n- You already have exact IDs and only need active-tab state.\n- You are about to repeat an identical no-result query.\n\n**Input guidance**\n- Rewording the same query rarely helps; change `type`, `query`, or intent instead.\n- "Collection" is ambiguous (Arazzo entity vs API requests by tags/path/criteria). For request lists, use `type: api_operation` with query/filters\u2014not Arazzo `collection`.\n- Pass all known filters (`apiId`, `path`, `method`, `operationId`, `collectionId`, `workflowId`, `stepId`); `query + filters` is most precise.\n- If semantic search returns no matches, ID filters enable direct lookup (see pairing on each filter field).\n- Phrase `query` like indexed text: titles/descriptions for collections/workflows; `step: \u2026`; `operationId: \u2026`; path/method/tags for endpoints.\n- If results are empty and lookup needs missing IDs, the tool may ask for them.\n',Wq=ue({query:$().optional().describe("Natural language search query."),count:Ne().positive().max(Vq).optional().default(10),type:st(["api_operation","api","collection","workflow","step"]).describe("Scope results to this item type. api = OpenAPI spec; api_operation = API endpoint; collection = Arazzo collection; workflow = Arazzo workflow; step = Arazzo workflow step."),include:De(st(["description","path","method","operationId","requestBody","parameters","security","responses","tags","successCriteria","title"])).describe("Fields to include in the response."),apiId:$().optional().describe("OpenAPI API ID (from loaded spec). For one endpoint, pair with operationId or path+method."),path:$().optional().describe("Filter by API path (e.g. /users). Use with method for precise operation matching."),method:$().optional().describe("Filter by HTTP method (GET, POST, PUT, DELETE, etc). Use with path for precise operation matching."),operationId:$().optional().describe("OpenAPI operationId. Requires apiId."),collectionId:$().optional().describe("Arazzo collection ID."),workflowId:$().optional().describe("Workflow ID within the collection. Requires collectionId."),stepId:$().optional().describe("Step ID within a workflow. Requires collectionId and workflowId.")}).strict(),Gq=Yr(),Jq={description:Hq,inputSchema:Wq,outputSchema:Gq,needsApproval:!1},Kq=["get","put","post","delete","options","head","patch","trace"],Yq=["query","x-query"];function Xq(e){return async(t,o)=>{const n=
|
|
308
|
+
- Each call starts a NEW run. Call it again only when the user wants another run.`,Uq=Ha({collectionId:$().describe("Id of the collection that holds the workflow."),workflowId:$().describe("Id of the workflow to run.")}),zq=ue({stepId:$(),statusCode:Ne().int().nullable(),passed:ho()}),Lq=ue({collectionId:$().describe("Resolved id of the collection that was run."),workflowId:$().describe("Resolved id of the workflow that was run."),historyId:$().nullable().describe("Id of this saved run. Put it in the workflow-run link as &historyId=... so the user can reopen this exact run. Null when history is not persisted."),success:ho().describe("Overall verdict from the execution engine. False when a step failed a non-warn check or the run hit the global timeout. Can be false even when passedSteps equals totalSteps: a step that failed and then passed on retry is not counted as failed here."),timedOut:ho().describe("True when the run hit the global execution timeout. Then success is false even if every listed step passed; report that the run timed out rather than blaming a step."),durationMs:Ne().describe("Total run time in milliseconds."),totalSteps:Ne().int().nonnegative(),passedSteps:Ne().int().nonnegative(),steps:De(zq).describe("Per-step outcome, in execution order: stepId, HTTP statusCode, and pass/fail only \u2014 no check name or failure message.")}),Fq=ln(Lq),Zq={description:jq,inputSchema:Uq,outputSchema:Fq,needsApproval:!1};function Bq(e,t){return async(o,n)=>{const a=o.collectionId.trim(),r=o.workflowId.trim();if(!a)return Pe("collectionId is required.");if(!r)return Pe("workflowId is required.");const s=ql(e,a,r);if(!s.ok)return Pe(s.message,s.details);try{const{workflowResult:l,historyId:u,verdict:d}=await t({collectionId:s.value.collectionId,workflowId:s.value.workflowId});return{isError:!1,data:{collectionId:s.value.collectionId,workflowId:s.value.workflowId,historyId:u,success:d.succeeded,timedOut:d.timedOut,durationMs:l.totalTimeMs,totalSteps:d.totalSteps,passedSteps:d.passedSteps,steps:d.steps.map(({step:c,passed:m})=>({stepId:c.stepId,statusCode:c.response?.statusCode??null,passed:m}))}}}catch(l){return Pe(l instanceof Error?l.message:"Workflow execution failed.")}}}const Ty={name:"run_workflow",definition:Zq,createExecutor:e=>Bq(e.store,e.runWorkflow)},Vq=25,Hq='RAG semantic search over OpenAPI specs and Arazzo assets in the current Replay project.\n\n**What it does**\n- Finds OpenAPI and Arazzo entities via natural-language query (scoped by `type`), returning up to `count` matches with detail via `include`.\n\n**Use when**\n- You need **initial schema/context** or request schema details from project assets.\n- You need canonical IDs/coordinates for an API, collection, workflow, or step.\n- You need to find operations/workflows/steps by natural language when IDs are unknown.\n\n**Never use when**\n- You are only verifying post-action UI changes in the active tab.\n- You already have exact IDs and only need active-tab state.\n- You are about to repeat an identical no-result query.\n\n**Input guidance**\n- Rewording the same query rarely helps; change `type`, `query`, or intent instead.\n- "Collection" is ambiguous (Arazzo entity vs API requests by tags/path/criteria). For request lists, use `type: api_operation` with query/filters\u2014not Arazzo `collection`.\n- Pass all known filters (`apiId`, `path`, `method`, `operationId`, `collectionId`, `workflowId`, `stepId`); `query + filters` is most precise.\n- If semantic search returns no matches, ID filters enable direct lookup (see pairing on each filter field).\n- Phrase `query` like indexed text: titles/descriptions for collections/workflows; `step: \u2026`; `operationId: \u2026`; path/method/tags for endpoints.\n- If results are empty and lookup needs missing IDs, the tool may ask for them.\n',Wq=ue({query:$().optional().describe("Natural language search query."),count:Ne().positive().max(Vq).optional().default(10),type:st(["api_operation","api","collection","workflow","step"]).describe("Scope results to this item type. api = OpenAPI spec; api_operation = API endpoint; collection = Arazzo collection; workflow = Arazzo workflow; step = Arazzo workflow step."),include:De(st(["description","path","method","operationId","requestBody","parameters","security","responses","tags","successCriteria","title"])).describe("Fields to include in the response."),apiId:$().optional().describe("OpenAPI API ID (from loaded spec). For one endpoint, pair with operationId or path+method."),path:$().optional().describe("Filter by API path (e.g. /users). Use with method for precise operation matching."),method:$().optional().describe("Filter by HTTP method (GET, POST, PUT, DELETE, etc). Use with path for precise operation matching."),operationId:$().optional().describe("OpenAPI operationId. Requires apiId."),collectionId:$().optional().describe("Arazzo collection ID."),workflowId:$().optional().describe("Workflow ID within the collection. Requires collectionId."),stepId:$().optional().describe("Step ID within a workflow. Requires collectionId and workflowId.")}).strict(),Gq=Yr(),Jq={description:Hq,inputSchema:Wq,outputSchema:Gq,needsApproval:!1},Kq=["get","put","post","delete","options","head","patch","trace"],Yq=["query","x-query"];function Xq(e){return async(t,o)=>{const n=jv(),a={type:t.type,apiId:t.apiId,operationId:t.operationId,path:t.path,method:t.method,collectionId:t.collectionId,workflowId:t.workflowId,stepId:t.stepId},r=t.query??"";let s=await n.search(r,t.count,a);return s.length===0&&(s=n2(e,a)),s.length===0?{isError:!1,data:{message:`No results found. ${Qq(t)}`}}:{isError:!1,data:{message:a2(s,t.include)}}}}function Qq(e){const t=[],{type:o,apiId:n,path:a,method:r,operationId:s,collectionId:l,workflowId:u,stepId:d,query:c}=e;switch(o){case"api":n||t.push("apiId");break;case"api_operation":{if(!n){t.push("apiId");break}const f=s!=null&&s!=="",v=a!=null&&a!==""&&r!=null&&r!=="";!f&&!v&&t.push("operationId","path","method");break}case"collection":l||t.push("collectionId");break;case"workflow":l?u||t.push("workflowId"):t.push("collectionId");break;case"step":l?u?d||t.push("stepId"):t.push("workflowId"):t.push("collectionId");break;default:if(l!=null&&l!==""&&(u?d||t.push("stepId"):t.push("workflowId")),n!=null&&n!==""){const f=s!=null&&s!=="",v=a!=null&&a!==""&&r!=null&&r!=="";!f&&!v&&t.push("operationId","path","method")}}c!=null&&c.trim()!==""||t.push("query");const m=[...new Set(t)];let g;return m.length===0?g="You already pass strong filters. Try a more specific natural-language query, or confirm IDs and paths match the project.":g=`To improve results, prefer adding (in order): ${m.slice(0,5).join(", ")}. When names are known but IDs are not, phrase query like indexed text: collection/workflow titles and descriptions; step: \u2026; operationId: \u2026; path/method/summary/tags for endpoints.`,g}function e2(e,t){const o=e.paths??{};for(const[n,a]of Object.entries(o)){if(!a||typeof a!="object")continue;const r=a,s=[...Kq.filter(u=>u in a),...Yq.filter(u=>u in a)];for(const u of s){const d=a[u];if(!d||typeof d!="object")continue;const c=d;if(!(t.operationId&&(c.operationId??"")!==t.operationId)&&!(t.path&&n!==t.path)&&!(t.method&&u.toUpperCase()!==t.method.toUpperCase()))return{path:n,method:u,op:c,pathItem:r}}const l=r.additionalOperations;if(l&&typeof l=="object")for(const[u,d]of Object.entries(l)){if(!d||typeof d!="object")continue;const c=d;if(!(t.operationId&&(c.operationId??"")!==t.operationId)&&!(t.path&&n!==t.path)&&!(t.method&&u.toUpperCase()!==t.method.toUpperCase()))return{path:n,method:u,op:c,pathItem:r}}}return null}function t2(e,t){const{type:o,apiId:n,operationId:a,path:r,method:s}=t;if(!n)return[];const l=e.find(m=>m.id===n);if(!l)return[];if(o==="api")return[{...mu(l).payload,score:1}];const u=a!=null&&a!=="",d=r!=null&&r!==""&&s!=null&&s!=="";if(!(o==="api_operation"||u||d||o==null&&(u||d)))return o==null?[{...mu(l).payload,score:1}]:[];const c=e2(l,{operationId:a,path:r,method:s});return c?[{...Uv({apiId:l.id,apiTitle:l.info?.title??"Untitled API",path:c.path,method:c.method,op:c.op,pathItem:c.pathItem,globalSchemes:zv(l),apiSecurity:l.security}).payload,score:1}]:[]}function o2(e,t){const{type:o,collectionId:n,workflowId:a,stepId:r}=t;if(!n)return[];const s=e.find(c=>c.id===n);if(!s)return[];const l=s.info?.title??"Untitled Collection";if(o==="collection")return[{...hu(s).payload,score:1}];const u=()=>{if(!a||!r)return[];const c=s.workflows?.find(g=>(g.workflowId??"")===a);if(!c)return[];const m=c.steps?.find(g=>(g.stepId??"")===r);return m?[{...Lv({collectionId:n,collectionTitle:l,workflowId:a,workflowTitle:c.summary??a,step:m}).payload,score:1}]:[]},d=()=>{if(!a)return[];const c=s.workflows?.find(m=>(m.workflowId??"")===a);return c?[{...Fv({collectionId:n,collectionTitle:l,workflow:c}).payload,score:1}]:[]};return o==="step"?u():o==="workflow"?d():o==null?r&&a?u():a?d():[{...hu(s).payload,score:1}]:[]}function n2(e,t){const o=e.apis.get(),n=e.collections.get(),{type:a}=t;return a==="api"||a==="api_operation"?t2(o,t):a==="collection"||a==="workflow"||a==="step"?o2(n,t):[]}function a2(e,t){return[KN(e,t).join(`
|
|
309
309
|
|
|
310
310
|
`)].filter(o=>o!=null&&o.length>0).join(`
|
|
311
311
|
|
|
312
|
-
`)}const r2="You already ran this exact search earlier in this conversation. If nothing has changed since then, reuse those results instead of repeating. If you expect different results (for example after an edit), do not just repeat the same search - change the query, the type, or the filters, or read the current state another way.",s2=10;function i2(e){const t=[e.type,En(e.query),En(e.apiId),En(e.operationId),En(e.path),En(e.method)?.toLowerCase(),En(e.collectionId),En(e.workflowId),En(e.stepId)];return t.every(o=>o==null)?null:JSON.stringify([...t,l2(e),u2(e)])}function l2(e){return typeof e?.count=="number"?e.count:s2}function u2(e){return Array.isArray(e?.include)?[...new Set(e.include)].sort():[]}function En(e){if(typeof e!="string")return null;const t=Jg(e);return t===""?null:t}const c2=[Kg({key:i2,warn:r2})],Cy={name:"search",definition:Jq,guards:c2,createExecutor:e=>Xq(e.store)},d2="Update security (x-security) for one or more Replay steps.\n\n**What it does**\n- Applies atomic add/update/remove changes to step security entries.\n- `add` UPSERTS by scheme identity: an existing entry with the same `schemeId` (or same `type` when `schemeId` is omitted) - including the auto-seeded entry created when the step was linked to its operation - is updated in place, never duplicated. Repeated identical wiring converges.\n- The result echoes each affected step's resulting security in `resultingState`; confirm from it, do NOT re-read tabs after mutation.\n- Empty security list falls back to No Auth.\n\n**Targeting**\n- Saved step: `collectionId` + `workflowId` + `stepId`.\n- Multi-step batch: set `changes[].stepId` per change (top-level `stepId` is the default and may be empty); wire a whole chain in ONE call.\n- Unsaved draft tab on focus: all three ids empty strings, no per-change stepId.\n\n**Choosing the type (match the OpenAPI scheme)**\n- http bearer -> `JWT` (`data.token`). A plain bearer token is NOT OAuth 2.0.\n- http basic -> `Basic Auth`, http digest -> `Digest Auth` (`data.username`, `data.password`).\n- apiKey -> `API key` (`data.name`, `data.key`, `data.location`); keep `data.key`'s `$inputs.<name>` segment identical to `data.name`.\n- oauth2 (grant-based flows only) -> `OAuth 2.0`; `data.grantType` is REQUIRED with flow values (`accessToken`, `clientId`, ...): `clientCredentials`, `clientCredentialsWithJwtAssertion`, `authorizationCode`, `authorizationCodeWithPkce`, `implicit`, `password`.\n- openIdConnect -> `OpenID Connect` (`data.openIdConnectUrl` plus OAuth2 fields).\n- `add` with a `schemeId` existing under a different type is rejected; use `update` at that index only to intentionally change a type.\n\n**Change shapes**\n- add/update: `{ action, stepId?, index?, type, schemeId?, data? }`; pass `schemeId` whenever known (it is the upsert identity), `index` is required for update.\n- remove: `{ action: \"remove\", stepId?, index }`.",p2=["clientCredentials","clientCredentialsWithJwtAssertion","authorizationCode","authorizationCodeWithPkce","implicit","password"],m2={grantType:st(p2).optional().describe("OAuth2 grant type."),clientId:$().optional(),clientSecret:$().optional(),tokenUrl:$().optional(),authorizationUrl:$().optional(),callbackUrl:$().optional(),accessToken:$().optional(),username:$().optional().describe("For password grant type."),password:$().optional().describe("For password grant type.")},h2=ue({username:$().optional(),password:$().optional()}).strict(),f2=ue({username:$().optional(),password:$().optional()}).strict(),g2=ue({token:$().optional()}).strict(),y2=ue({location:st(["header","query","cookie"]).optional(),name:$().optional().describe("Must match the OpenAPI security scheme `name` (header/query/cookie parameter name). Not the scheme component ref id (e.g. UserCookie)."),key:$().optional().describe("Secret value or `$inputs.<name>` / `{$inputs.<name>}`. The `<name>` segment must be identical to `data.name` (OpenAPI apiKey `name`, e.g. accessToken). Wrong example: `data.name` accessToken but key `$inputs.UserCookie` (UserCookie is the securitySchemes ref, not the cookie name).")}).strict(),Sy=ue({...m2}).strict(),v2=Sy.extend({openIdConnectUrl:$().optional(),userInfoUrl:$().optional()}).strict(),Ey=$().optional().describe("Target step id for this change. Overrides the top-level stepId; use to batch changes for several steps of the same workflow in one call."),ka=_$.extend({action:st(["add","update"]),schemeId:$().optional(),stepId:Ey}),_2=Xr("type",[ka.extend({type:Ue(Le.BasicAuth),data:h2.optional()}).strict(),ka.extend({type:Ue(Le.DigestAuth),data:f2.optional()}).strict(),ka.extend({type:Ue(Le.JWT),data:g2.optional()}).strict(),ka.extend({type:Ue(Le.APIKey),data:y2.optional()}).strict(),ka.extend({type:Ue(Le.OAuth2),data:Sy.optional()}).strict(),ka.extend({type:Ue(Le.OpenIDConnect),data:v2.optional()}).strict()]),w2=$l.extend({action:Ue("remove"),index:Ne().int().min(0).describe("0-based position of the entry in the step's current security list; every index in one call refers to that same list. Position, not schemeId, identifies the entry - a step can list the same scheme more than once."),stepId:Ey}).strict(),b2=zo([_2,w2]),x2=ue({collectionId:$().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:$().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:$().describe("Saved step: step id (default target for changes without their own stepId; may be empty when every change sets one). Unsaved draft tab: empty string (with empty collectionId and workflowId)."),changes:De(b2).min(1).describe("List of security changes to apply.")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),n=e.workflowId.trim(),a=e.stepId.trim(),r=e.changes.map(u=>u.stepId?.trim()),s=r.every(Boolean),l=r.some(Boolean);!(o&&n&&(a||s))&&!(!o&&!n&&!a&&!l)&&t.addIssue({code:se.custom,message:"Provide collectionId and workflowId plus a stepId for every change (top-level or per-change), or all empty ids for the focused unsaved request tab.",path:["collectionId"]})}),I2=ey,k2={description:d2,inputSchema:x2,outputSchema:I2,needsApproval:()=>!0},vo={ADD:"add",UPDATE:"update",REMOVE:"remove"};function We(e,t){return{status:e,...t!==void 0&&{summary:t}}}function My(e){if(!e||typeof e!="object"||!("meta"in e))return{};const{meta:t}=e;if(!t||typeof t!="object")return{};const o="totalChanges"in t&&typeof t.totalChanges=="number"?t.totalChanges:void 0,n="approvedChanges"in t&&typeof t.approvedChanges=="number"?t.approvedChanges:void 0;return{totalChanges:o,approvedChanges:n}}function Oy(e,t){return!Number.isInteger(t.index)||t.index<0||t.index>=e.length?{ok:!1,message:`Index ${t.index} out of bounds. Step has ${e.length} security entries.`}:{ok:!0,entry:e[t.index]}}const T2=new Set(["grantType","openIdConnectUrl","userInfoUrl"]);function C2(e){return e.type===Le.OAuth2||e.type===Le.OpenIDConnect}function Ry(e,t){const o=e;for(const[n,a]of Object.entries(t))a!==void 0&&n in o&&(o[n]=a)}function Ay(e,t){const o=Object.entries(t);for(const[r,s]of o)r==="grantType"&&typeof s=="string"&&pu[s]&&(e.grantType=pu[s]);const n=e[e.grantType],a=new Set(Object.keys(Uv[e.grantType]));for(const[r,s]of o)r!=="grantType"&&s!==void 0&&a.has(r)&&(n[r]=s)}function Ny(e){return e.securityType===Le.NoAuth?null:e[e.securityType]?.schemeName??null}function S2(e,t){!t||e.securityType===Le.NoAuth||(e.securitySchemeId=t,e[e.securityType].schemeName=t)}function jl(e,t){if(e.securityType=t.type,S2(e,t.schemeId),!t.data)return e;switch(t.type){case Le.BasicAuth:case Le.DigestAuth:case Le.JWT:Ry(e[t.type],t.data);break;case Le.APIKey:{const{location:o,...n}=t.data;Ry(e[Le.APIKey],n),o&&(e[Le.APIKey].location=jv(o));break}case Le.OAuth2:Ay(e[Le.OAuth2],t.data);break;case Le.OpenIDConnect:{const{openIdConnectUrl:o,userInfoUrl:n,...a}=t.data;Ay(e[Le.OpenIDConnect],a),o!==void 0&&(e[Le.OpenIDConnect].openIdConnectUrl=o),n!==void 0&&(e[Le.OpenIDConnect].userInfoUrl=n);break}}return e}function E2(e,t){return t.schemeId?e.findIndex(o=>o.securitySchemeId===t.schemeId||Ny(o)===t.schemeId):e.findIndex(o=>o.securityType===t.type)}function M2(e){return e.data?Object.entries(e.data).some(([t,o])=>o!==void 0&&!T2.has(t)):!1}function O2(e){return e.schemeId?`${e.type} (scheme '${e.schemeId}')`:e.type}function $y(e,t,o,n){return e.has(t)?{ok:!1,message:`The security entry at index ${o} is targeted by both a mutation and a remove${n}; issue only one action for it.`}:null}function R2(e,t,o){let n=e;const a=[],r=t.filter(u=>u.action!==vo.REMOVE),s=t.filter(u=>u.action===vo.REMOVE),l=new Set;for(const u of s){const d=Oy(e,u);if(!d.ok)return{ok:!1,message:d.message};l.add(d.entry)}for(const u of r){if(u.action===vo.ADD){const m=n.length===1&&n[0].securityType===Le.NoAuth,g=m?-1:E2(n,u);if(g>=0){const v=n[g],b=$y(l,v,g,o);if(b)return b;if(v.securityType!==u.type)return{ok:!1,message:`Scheme '${u.schemeId}' already exists${o} as ${v.securityType}, not ${u.type}. Match the documented scheme type (plain http/bearer -> JWT with data.token; OAuth 2.0 only for grant-based flows), or use action "update" at index ${g} to intentionally change the type.`};n=[...n],n[g]=jl(structuredClone(v),u),a.push(We("applied",`Updated existing ${O2(u)} in place (index: ${g})${o}`));continue}if(C2(u)&&M2(u)&&!u.data?.grantType)return{ok:!1,message:`grantType is required when adding ${u.type} security with flow values${o}. For a plain http/bearer token use type "${Le.JWT}" with data.token instead.`};const f=jl(du(),u);n=m?[f]:[...n,f],a.push(We("applied",`Added ${u.type} security (index: ${n.length-1})${o}`));continue}if(u.index===void 0)return{ok:!1,message:"index is required for update action."};if(u.index>=n.length)return{ok:!1,message:`Index ${u.index} out of bounds. Step has ${n.length} security entries.`};const d=n[u.index],c=$y(l,d,u.index,o);if(c)return c;if(d.securitySchemeId){const m=Ny(d);if(u.schemeId&&m!==u.schemeId)return{ok:!1,message:`schemeId mismatch at index ${u.index}. Expected ${m??"none"}.`}}n=[...n],n[u.index]=jl(structuredClone(d),u),a.push(We("applied",`Updated ${u.type} at index ${u.index}${o}`))}if(l.size>0){const u=n.filter(c=>!l.has(c)),d=n.length-u.length;n=u;for(let c=0;c<d;c++)a.push(We("applied"))}return n.length===0&&(n=[du()]),{ok:!0,security:n,applied:a}}function A2(e){return async t=>{const{changes:o,collectionId:n,workflowId:a,stepId:r}=t,s=My(t),l=r.trim(),u=new Map;for(const g of o){const f=g.stepId?.trim()||l,v=u.get(f);v?v.push(g):u.set(f,[g])}const d=[],c=[];for(const[g,f]of u){const v=Dl(e,n,a,g);if(!v.ok)return Pe(v.message,v.details);const b=v.value,x=g||b.stepId.get(),_=u.size>1?` for step '${x}'`:"",w=Array.from(b.security.get({noproxy:!0})),T=R2(w,f,_);if(!T.ok)return Pe(T.message);d.push(...T.applied),c.push({step:b,security:T.security,label:x})}for(const g of c)g.step.security.set(g.security);const m=c.map(g=>`stepId=${g.label}
|
|
312
|
+
`)}const r2="You already ran this exact search earlier in this conversation. If nothing has changed since then, reuse those results instead of repeating. If you expect different results (for example after an edit), do not just repeat the same search - change the query, the type, or the filters, or read the current state another way.",s2=10;function i2(e){const t=[e.type,En(e.query),En(e.apiId),En(e.operationId),En(e.path),En(e.method)?.toLowerCase(),En(e.collectionId),En(e.workflowId),En(e.stepId)];return t.every(o=>o==null)?null:JSON.stringify([...t,l2(e),u2(e)])}function l2(e){return typeof e?.count=="number"?e.count:s2}function u2(e){return Array.isArray(e?.include)?[...new Set(e.include)].sort():[]}function En(e){if(typeof e!="string")return null;const t=Jg(e);return t===""?null:t}const c2=[Kg({key:i2,warn:r2})],Cy={name:"search",definition:Jq,guards:c2,createExecutor:e=>Xq(e.store)},d2="Update security (x-security) for one or more Replay steps.\n\n**What it does**\n- Applies atomic add/update/remove changes to step security entries.\n- `add` UPSERTS by scheme identity: an existing entry with the same `schemeId` (or same `type` when `schemeId` is omitted) - including the auto-seeded entry created when the step was linked to its operation - is updated in place, never duplicated. Repeated identical wiring converges.\n- The result echoes each affected step's resulting security in `resultingState`; confirm from it, do NOT re-read tabs after mutation.\n- Empty security list falls back to No Auth.\n\n**Targeting**\n- Saved step: `collectionId` + `workflowId` + `stepId`.\n- Multi-step batch: set `changes[].stepId` per change (top-level `stepId` is the default and may be empty); wire a whole chain in ONE call.\n- Unsaved draft tab on focus: all three ids empty strings, no per-change stepId.\n\n**Choosing the type (match the OpenAPI scheme)**\n- http bearer -> `JWT` (`data.token`). A plain bearer token is NOT OAuth 2.0.\n- http basic -> `Basic Auth`, http digest -> `Digest Auth` (`data.username`, `data.password`).\n- apiKey -> `API key` (`data.name`, `data.key`, `data.location`); keep `data.key`'s `$inputs.<name>` segment identical to `data.name`.\n- oauth2 (grant-based flows only) -> `OAuth 2.0`; `data.grantType` is REQUIRED with flow values (`accessToken`, `clientId`, ...): `clientCredentials`, `clientCredentialsWithJwtAssertion`, `authorizationCode`, `authorizationCodeWithPkce`, `implicit`, `password`.\n- openIdConnect -> `OpenID Connect` (`data.openIdConnectUrl` plus OAuth2 fields).\n- `add` with a `schemeId` existing under a different type is rejected; use `update` at that index only to intentionally change a type.\n\n**Change shapes**\n- add/update: `{ action, stepId?, index?, type, schemeId?, data? }`; pass `schemeId` whenever known (it is the upsert identity), `index` is required for update.\n- remove: `{ action: \"remove\", stepId?, index }`.",p2=["clientCredentials","clientCredentialsWithJwtAssertion","authorizationCode","authorizationCodeWithPkce","implicit","password"],m2={grantType:st(p2).optional().describe("OAuth2 grant type."),clientId:$().optional(),clientSecret:$().optional(),tokenUrl:$().optional(),authorizationUrl:$().optional(),callbackUrl:$().optional(),accessToken:$().optional(),username:$().optional().describe("For password grant type."),password:$().optional().describe("For password grant type.")},h2=ue({username:$().optional(),password:$().optional()}).strict(),f2=ue({username:$().optional(),password:$().optional()}).strict(),g2=ue({token:$().optional()}).strict(),y2=ue({location:st(["header","query","cookie"]).optional(),name:$().optional().describe("Must match the OpenAPI security scheme `name` (header/query/cookie parameter name). Not the scheme component ref id (e.g. UserCookie)."),key:$().optional().describe("Secret value or `$inputs.<name>` / `{$inputs.<name>}`. The `<name>` segment must be identical to `data.name` (OpenAPI apiKey `name`, e.g. accessToken). Wrong example: `data.name` accessToken but key `$inputs.UserCookie` (UserCookie is the securitySchemes ref, not the cookie name).")}).strict(),Sy=ue({...m2}).strict(),v2=Sy.extend({openIdConnectUrl:$().optional(),userInfoUrl:$().optional()}).strict(),Ey=$().optional().describe("Target step id for this change. Overrides the top-level stepId; use to batch changes for several steps of the same workflow in one call."),ka=_$.extend({action:st(["add","update"]),schemeId:$().optional(),stepId:Ey}),_2=Xr("type",[ka.extend({type:Ue(Le.BasicAuth),data:h2.optional()}).strict(),ka.extend({type:Ue(Le.DigestAuth),data:f2.optional()}).strict(),ka.extend({type:Ue(Le.JWT),data:g2.optional()}).strict(),ka.extend({type:Ue(Le.APIKey),data:y2.optional()}).strict(),ka.extend({type:Ue(Le.OAuth2),data:Sy.optional()}).strict(),ka.extend({type:Ue(Le.OpenIDConnect),data:v2.optional()}).strict()]),w2=$l.extend({action:Ue("remove"),index:Ne().int().min(0).describe("0-based position of the entry in the step's current security list; every index in one call refers to that same list. Position, not schemeId, identifies the entry - a step can list the same scheme more than once."),stepId:Ey}).strict(),b2=zo([_2,w2]),x2=ue({collectionId:$().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:$().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:$().describe("Saved step: step id (default target for changes without their own stepId; may be empty when every change sets one). Unsaved draft tab: empty string (with empty collectionId and workflowId)."),changes:De(b2).min(1).describe("List of security changes to apply.")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),n=e.workflowId.trim(),a=e.stepId.trim(),r=e.changes.map(u=>u.stepId?.trim()),s=r.every(Boolean),l=r.some(Boolean);!(o&&n&&(a||s))&&!(!o&&!n&&!a&&!l)&&t.addIssue({code:se.custom,message:"Provide collectionId and workflowId plus a stepId for every change (top-level or per-change), or all empty ids for the focused unsaved request tab.",path:["collectionId"]})}),I2=ey,k2={description:d2,inputSchema:x2,outputSchema:I2,needsApproval:()=>!0},vo={ADD:"add",UPDATE:"update",REMOVE:"remove"};function We(e,t){return{status:e,...t!==void 0&&{summary:t}}}function My(e){if(!e||typeof e!="object"||!("meta"in e))return{};const{meta:t}=e;if(!t||typeof t!="object")return{};const o="totalChanges"in t&&typeof t.totalChanges=="number"?t.totalChanges:void 0,n="approvedChanges"in t&&typeof t.approvedChanges=="number"?t.approvedChanges:void 0;return{totalChanges:o,approvedChanges:n}}function Oy(e,t){return!Number.isInteger(t.index)||t.index<0||t.index>=e.length?{ok:!1,message:`Index ${t.index} out of bounds. Step has ${e.length} security entries.`}:{ok:!0,entry:e[t.index]}}const T2=new Set(["grantType","openIdConnectUrl","userInfoUrl"]);function C2(e){return e.type===Le.OAuth2||e.type===Le.OpenIDConnect}function Ry(e,t){const o=e;for(const[n,a]of Object.entries(t))a!==void 0&&n in o&&(o[n]=a)}function Ay(e,t){const o=Object.entries(t);for(const[r,s]of o)r==="grantType"&&typeof s=="string"&&cu[s]&&(e.grantType=cu[s]);const n=e[e.grantType],a=new Set(Object.keys($v[e.grantType]));for(const[r,s]of o)r!=="grantType"&&s!==void 0&&a.has(r)&&(n[r]=s)}function Ny(e){return e.securityType===Le.NoAuth?null:e[e.securityType]?.schemeName??null}function S2(e,t){!t||e.securityType===Le.NoAuth||(e.securitySchemeId=t,e[e.securityType].schemeName=t)}function jl(e,t){if(e.securityType=t.type,S2(e,t.schemeId),!t.data)return e;switch(t.type){case Le.BasicAuth:case Le.DigestAuth:case Le.JWT:Ry(e[t.type],t.data);break;case Le.APIKey:{const{location:o,...n}=t.data;Ry(e[Le.APIKey],n),o&&(e[Le.APIKey].location=Nv(o));break}case Le.OAuth2:Ay(e[Le.OAuth2],t.data);break;case Le.OpenIDConnect:{const{openIdConnectUrl:o,userInfoUrl:n,...a}=t.data;Ay(e[Le.OpenIDConnect],a),o!==void 0&&(e[Le.OpenIDConnect].openIdConnectUrl=o),n!==void 0&&(e[Le.OpenIDConnect].userInfoUrl=n);break}}return e}function E2(e,t){return t.schemeId?e.findIndex(o=>o.securitySchemeId===t.schemeId||Ny(o)===t.schemeId):e.findIndex(o=>o.securityType===t.type)}function M2(e){return e.data?Object.entries(e.data).some(([t,o])=>o!==void 0&&!T2.has(t)):!1}function O2(e){return e.schemeId?`${e.type} (scheme '${e.schemeId}')`:e.type}function $y(e,t,o,n){return e.has(t)?{ok:!1,message:`The security entry at index ${o} is targeted by both a mutation and a remove${n}; issue only one action for it.`}:null}function R2(e,t,o){let n=e;const a=[],r=t.filter(u=>u.action!==vo.REMOVE),s=t.filter(u=>u.action===vo.REMOVE),l=new Set;for(const u of s){const d=Oy(e,u);if(!d.ok)return{ok:!1,message:d.message};l.add(d.entry)}for(const u of r){if(u.action===vo.ADD){const m=n.length===1&&n[0].securityType===Le.NoAuth,g=m?-1:E2(n,u);if(g>=0){const v=n[g],b=$y(l,v,g,o);if(b)return b;if(v.securityType!==u.type)return{ok:!1,message:`Scheme '${u.schemeId}' already exists${o} as ${v.securityType}, not ${u.type}. Match the documented scheme type (plain http/bearer -> JWT with data.token; OAuth 2.0 only for grant-based flows), or use action "update" at index ${g} to intentionally change the type.`};n=[...n],n[g]=jl(structuredClone(v),u),a.push(We("applied",`Updated existing ${O2(u)} in place (index: ${g})${o}`));continue}if(C2(u)&&M2(u)&&!u.data?.grantType)return{ok:!1,message:`grantType is required when adding ${u.type} security with flow values${o}. For a plain http/bearer token use type "${Le.JWT}" with data.token instead.`};const f=jl(uu(),u);n=m?[f]:[...n,f],a.push(We("applied",`Added ${u.type} security (index: ${n.length-1})${o}`));continue}if(u.index===void 0)return{ok:!1,message:"index is required for update action."};if(u.index>=n.length)return{ok:!1,message:`Index ${u.index} out of bounds. Step has ${n.length} security entries.`};const d=n[u.index],c=$y(l,d,u.index,o);if(c)return c;if(d.securitySchemeId){const m=Ny(d);if(u.schemeId&&m!==u.schemeId)return{ok:!1,message:`schemeId mismatch at index ${u.index}. Expected ${m??"none"}.`}}n=[...n],n[u.index]=jl(structuredClone(d),u),a.push(We("applied",`Updated ${u.type} at index ${u.index}${o}`))}if(l.size>0){const u=n.filter(c=>!l.has(c)),d=n.length-u.length;n=u;for(let c=0;c<d;c++)a.push(We("applied"))}return n.length===0&&(n=[uu()]),{ok:!0,security:n,applied:a}}function A2(e){return async t=>{const{changes:o,collectionId:n,workflowId:a,stepId:r}=t,s=My(t),l=r.trim(),u=new Map;for(const g of o){const f=g.stepId?.trim()||l,v=u.get(f);v?v.push(g):u.set(f,[g])}const d=[],c=[];for(const[g,f]of u){const v=Dl(e,n,a,g);if(!v.ok)return Pe(v.message,v.details);const b=v.value,x=g||b.stepId.get(),_=u.size>1?` for step '${x}'`:"",w=Array.from(b.security.get({noproxy:!0})),T=R2(w,f,_);if(!T.ok)return Pe(T.message);d.push(...T.applied),c.push({step:b,security:T.security,label:x})}for(const g of c)g.step.security.set(g.security);const m=c.map(g=>`stepId=${g.label}
|
|
313
313
|
${xs(g.security)}`).join(`
|
|
314
314
|
|
|
315
315
|
`);return{isError:!1,data:{totalChanges:s.totalChanges??o.length,approvedChanges:s.approvedChanges??o.length,applied:d,resultingState:m}}}}const Py={name:"update_security",definition:k2,createExecutor:e=>A2(e.store)},N2=`Update an existing Replay step with atomic changes.
|
|
@@ -346,7 +346,7 @@ ${xs(g.security)}`).join(`
|
|
|
346
346
|
- Batch related edits in one call; include all known edits up front.
|
|
347
347
|
- For OpenAPI-linked steps, avoid method/url changes.
|
|
348
348
|
- After changing path/query parameters, decide whether to add a separate URL change.
|
|
349
|
-
`,$2=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P2=[ua.Text,ua.JSON,ua.XML],q2=ue({name:$().min(1),in:st(["path","query","header","cookie"]),value:$()}).strict(),D2=ue({condition:$().min(1),context:$().optional().describe("Context for the expression."),type:st(["simple","regex","jsonpath","xpath"]).optional()}).strict(),j2=Kn.extend({field:Ue("url"),data:$().min(1).describe("New request URL for step.")}).strict(),U2=Kn.extend({field:Ue("description"),data:$().describe("New step description text.")}).strict(),z2=Kn.extend({field:Ue("method"),data:st($2).describe("New HTTP method for x-operation step.")}).strict(),L2=Kn.extend({field:Ue("parameters"),data:q2.optional().describe("Parameter data. Required for add/update actions.")}).strict(),F2=Kn.extend({field:Ue("outputs"),data:ue({name:$().min(1).describe("Output name."),expression:$().min(1).describe("Output expression.")}).strict().optional().describe("Output mapping. Required for add/update actions.")}).strict(),Z2=Kn.extend({field:Ue("successCriteria"),data:D2.optional().describe("Success criterion. Required for add/update actions.")}).strict(),B2=Kn.extend({field:Ue("body"),data:ue({contentType:st(P2).optional().describe("Request body content type. Allowed: text/plain, application/json, application/xml."),content:$().describe("Request body content as string.")}).strict().describe("Request body content and optional content type.")}).strict(),V2=Xr("field",[j2,U2,z2,L2,F2,Z2,B2]),H2=ue({collectionId:$().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:$().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:$().describe("Saved step: step id. Unsaved draft tab: empty string (with empty collectionId and workflowId)."),changes:De(V2).min(1).describe("List of individual changes to apply to the step.")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),n=e.workflowId.trim(),a=e.stepId.trim();!(o&&n&&a)&&!(!o&&!n&&!a)&&t.addIssue({code:se.custom,message:"Provide all three ids for a saved step, or three empty strings for the focused unsaved request tab.",path:["collectionId"]})}),W2=ey,G2={description:N2,inputSchema:H2,outputSchema:W2,needsApproval:()=>!0};function J2(e){return e.replace(/\{\{([^{}\s]+)\}\}/g,"{$1}")}function Ul(e){return qa[e]}function zl(e,t){return e.id===t}function qy(e,t){return e.condition===t}function Ll(e,t){return Us(e)&&e.id===t}function Dy(e,t,o){return{...ou(e),key:t,value:o,active:!0}}function Fl(e,t){e.set(o=>[...o,...t])}function Ms(e,t,o){let n=!1;return e.set(a=>{const r=a.findIndex(l=>o.find(l,t));if(r<0)return a;const s=[...a];return s[r]=o.produce(a[r]),n=!0,s}),n}function Zl(e,t,o){let n=!1;return e.set(a=>{const r=a.filter(s=>!o(s,t));return n=r.length<a.length,r}),n}function K2(e,t){switch(e.action){case vo.ADD:{if(!e.data)return We("failed","Failed parameter add because data is missing.");const{in:o,name:n,value:a}=e.data,r=Ul(o),s=Dy(o,n,a);return Fl(t.parameters[r],[s]),We("applied",`Added ${o} parameter '${n}' (id: ${s.id})`)}case vo.UPDATE:{if(!e.id)return We("failed","Failed parameter update because id is missing.");if(!e.data)return We("failed","Failed parameter update because data is missing.");const{in:o,name:n,value:a}=e.data,r=Ul(o);return Ms(t.parameters[r],e.id,{find:Ll,produce:s=>Us(s)?{...Dy(o,n,a),id:s.id,...s.allowReserved!==void 0&&{allowReserved:s.allowReserved}}:s})?We("applied"):We("failed",`Parameter with id '${e.id}' not found.`)}case vo.REMOVE:{if(!e.id)return We("failed","Failed parameter remove because id is missing.");const o=e.id,n=e.data?.in,a=n?[Ul(n)]:Object.values(qa);let r=!1;for(const s of a)if(t.parameters[s].get({noproxy:!0}).some(l=>Ll(l,o))){r=Zl(t.parameters[s],o,Ll);break}return r?We("applied"):We("failed",`Parameter with id '${o}' not found.`)}}}function Y2(e,t){switch(e.action){case vo.ADD:{if(!e.data)return We("failed","Failed output add because data is missing.");const{name:o,expression:n}=e.data,a=t.outputs.get({noproxy:!0}).find(s=>s.key===o);if(a)return Ms(t.outputs,a.id,{find:zl,produce:s=>({...s,key:o,value:n,active:!0})}),We("applied",`Updated existing output '${o}' in place (id: ${a.id})`);const r=crypto.randomUUID();return Fl(t.outputs,[{id:r,key:o,value:n,active:!0}]),We("applied",`Added output '${o}' (id: ${r})`)}case vo.UPDATE:{if(!e.id)return We("failed","Failed output update because id is missing.");if(!e.data)return We("failed","Failed output update because data is missing.");const{name:o,expression:n}=e.data;return Ms(t.outputs,e.id,{find:zl,produce:a=>({...a,key:o,value:n,active:!0})})?We("applied"):We("failed",`Output with id '${e.id}' not found.`)}case vo.REMOVE:return e.id?Zl(t.outputs,e.id,zl)?We("applied"):We("failed",`Output with id '${e.id}' not found.`):We("failed","Failed output remove because id is missing.")}}function X2(e,t){switch(e.action){case vo.ADD:{if(!e.data)return We("failed","Failed success criteria add because data is missing.");const{condition:o,context:n,type:a}=e.data,r=tu(a??js.SIMPLE);return Fl(t.successCriteria,[{...r,condition:o,...n!==void 0&&{context:n}}]),We("applied")}case vo.UPDATE:{if(typeof e.id!="string")return We("failed","Failed success criteria update because id is missing.");if(!e.data)return We("failed","Failed success criteria update because data is missing.");const{condition:o,context:n,type:a}=e.data;return Ms(t.successCriteria,e.id,{find:qy,produce:r=>({...r,id:r.id||crypto.randomUUID(),condition:o,context:n??r.context,type:a??r.type??js.SIMPLE})})?We("applied"):We("failed",`Success criterion with condition '${e.id}' not found.`)}case vo.REMOVE:return typeof e.id!="string"?We("failed","Failed success criteria remove because id is missing."):Zl(t.successCriteria,e.id,qy)?We("applied"):We("failed",`Success criterion with condition '${e.id}' not found.`)}}function Q2(e){return async t=>{const{changes:o,collectionId:n,workflowId:a,stepId:r}=t,s=My(t),l=Dl(e,n,a,r);if(!l.ok)return Pe(l.message,l.details);const u=l.value;if(o.some(m=>m.field==="method"||m.field==="url")&&u.operation.ornull!==null)return Pe("Cannot update method or url for a step linked to an OpenAPI operation.");const d=[];for(const m of o)switch(m.field){case"method":case"url":{u.xOperation.ornull===null&&u.xOperation.set({method:"GET",url:""});const g=u.xOperation.ornull;if(!g)return Pe("Step xOperation state is unavailable.");if(m.field==="method")g.method.set(m.data);else{const f=J2(m.data);g.url.set(f);const v=u.parameters.queryParameters.get({noproxy:!0});u.parameters.queryParameters.set(
|
|
349
|
+
`,$2=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P2=[ua.Text,ua.JSON,ua.XML],q2=ue({name:$().min(1),in:st(["path","query","header","cookie"]),value:$()}).strict(),D2=ue({condition:$().min(1),context:$().optional().describe("Context for the expression."),type:st(["simple","regex","jsonpath","xpath"]).optional()}).strict(),j2=Kn.extend({field:Ue("url"),data:$().min(1).describe("New request URL for step.")}).strict(),U2=Kn.extend({field:Ue("description"),data:$().describe("New step description text.")}).strict(),z2=Kn.extend({field:Ue("method"),data:st($2).describe("New HTTP method for x-operation step.")}).strict(),L2=Kn.extend({field:Ue("parameters"),data:q2.optional().describe("Parameter data. Required for add/update actions.")}).strict(),F2=Kn.extend({field:Ue("outputs"),data:ue({name:$().min(1).describe("Output name."),expression:$().min(1).describe("Output expression.")}).strict().optional().describe("Output mapping. Required for add/update actions.")}).strict(),Z2=Kn.extend({field:Ue("successCriteria"),data:D2.optional().describe("Success criterion. Required for add/update actions.")}).strict(),B2=Kn.extend({field:Ue("body"),data:ue({contentType:st(P2).optional().describe("Request body content type. Allowed: text/plain, application/json, application/xml."),content:$().describe("Request body content as string.")}).strict().describe("Request body content and optional content type.")}).strict(),V2=Xr("field",[j2,U2,z2,L2,F2,Z2,B2]),H2=ue({collectionId:$().describe("Saved step: collection id. Unsaved draft tab on focus: empty string (with empty workflowId and stepId)."),workflowId:$().describe("Saved step: workflow id. Unsaved draft tab: empty string (with empty collectionId and stepId)."),stepId:$().describe("Saved step: step id. Unsaved draft tab: empty string (with empty collectionId and workflowId)."),changes:De(V2).min(1).describe("List of individual changes to apply to the step.")}).strict().superRefine((e,t)=>{const o=e.collectionId.trim(),n=e.workflowId.trim(),a=e.stepId.trim();!(o&&n&&a)&&!(!o&&!n&&!a)&&t.addIssue({code:se.custom,message:"Provide all three ids for a saved step, or three empty strings for the focused unsaved request tab.",path:["collectionId"]})}),W2=ey,G2={description:N2,inputSchema:H2,outputSchema:W2,needsApproval:()=>!0};function J2(e){return e.replace(/\{\{([^{}\s]+)\}\}/g,"{$1}")}function Ul(e){return qa[e]}function zl(e,t){return e.id===t}function qy(e,t){return e.condition===t}function Ll(e,t){return Us(e)&&e.id===t}function Dy(e,t,o){return{...ou(e),key:t,value:o,active:!0}}function Fl(e,t){e.set(o=>[...o,...t])}function Ms(e,t,o){let n=!1;return e.set(a=>{const r=a.findIndex(l=>o.find(l,t));if(r<0)return a;const s=[...a];return s[r]=o.produce(a[r]),n=!0,s}),n}function Zl(e,t,o){let n=!1;return e.set(a=>{const r=a.filter(s=>!o(s,t));return n=r.length<a.length,r}),n}function K2(e,t){switch(e.action){case vo.ADD:{if(!e.data)return We("failed","Failed parameter add because data is missing.");const{in:o,name:n,value:a}=e.data,r=Ul(o),s=Dy(o,n,a);return Fl(t.parameters[r],[s]),We("applied",`Added ${o} parameter '${n}' (id: ${s.id})`)}case vo.UPDATE:{if(!e.id)return We("failed","Failed parameter update because id is missing.");if(!e.data)return We("failed","Failed parameter update because data is missing.");const{in:o,name:n,value:a}=e.data,r=Ul(o);return Ms(t.parameters[r],e.id,{find:Ll,produce:s=>Us(s)?{...Dy(o,n,a),id:s.id,...s.allowReserved!==void 0&&{allowReserved:s.allowReserved}}:s})?We("applied"):We("failed",`Parameter with id '${e.id}' not found.`)}case vo.REMOVE:{if(!e.id)return We("failed","Failed parameter remove because id is missing.");const o=e.id,n=e.data?.in,a=n?[Ul(n)]:Object.values(qa);let r=!1;for(const s of a)if(t.parameters[s].get({noproxy:!0}).some(l=>Ll(l,o))){r=Zl(t.parameters[s],o,Ll);break}return r?We("applied"):We("failed",`Parameter with id '${o}' not found.`)}}}function Y2(e,t){switch(e.action){case vo.ADD:{if(!e.data)return We("failed","Failed output add because data is missing.");const{name:o,expression:n}=e.data,a=t.outputs.get({noproxy:!0}).find(s=>s.key===o);if(a)return Ms(t.outputs,a.id,{find:zl,produce:s=>({...s,key:o,value:n,active:!0})}),We("applied",`Updated existing output '${o}' in place (id: ${a.id})`);const r=crypto.randomUUID();return Fl(t.outputs,[{id:r,key:o,value:n,active:!0}]),We("applied",`Added output '${o}' (id: ${r})`)}case vo.UPDATE:{if(!e.id)return We("failed","Failed output update because id is missing.");if(!e.data)return We("failed","Failed output update because data is missing.");const{name:o,expression:n}=e.data;return Ms(t.outputs,e.id,{find:zl,produce:a=>({...a,key:o,value:n,active:!0})})?We("applied"):We("failed",`Output with id '${e.id}' not found.`)}case vo.REMOVE:return e.id?Zl(t.outputs,e.id,zl)?We("applied"):We("failed",`Output with id '${e.id}' not found.`):We("failed","Failed output remove because id is missing.")}}function X2(e,t){switch(e.action){case vo.ADD:{if(!e.data)return We("failed","Failed success criteria add because data is missing.");const{condition:o,context:n,type:a}=e.data,r=tu(a??js.SIMPLE);return Fl(t.successCriteria,[{...r,condition:o,...n!==void 0&&{context:n}}]),We("applied")}case vo.UPDATE:{if(typeof e.id!="string")return We("failed","Failed success criteria update because id is missing.");if(!e.data)return We("failed","Failed success criteria update because data is missing.");const{condition:o,context:n,type:a}=e.data;return Ms(t.successCriteria,e.id,{find:qy,produce:r=>({...r,id:r.id||crypto.randomUUID(),condition:o,context:n??r.context,type:a??r.type??js.SIMPLE})})?We("applied"):We("failed",`Success criterion with condition '${e.id}' not found.`)}case vo.REMOVE:return typeof e.id!="string"?We("failed","Failed success criteria remove because id is missing."):Zl(t.successCriteria,e.id,qy)?We("applied"):We("failed",`Success criterion with condition '${e.id}' not found.`)}}function Q2(e){return async t=>{const{changes:o,collectionId:n,workflowId:a,stepId:r}=t,s=My(t),l=Dl(e,n,a,r);if(!l.ok)return Pe(l.message,l.details);const u=l.value;if(o.some(m=>m.field==="method"||m.field==="url")&&u.operation.ornull!==null)return Pe("Cannot update method or url for a step linked to an OpenAPI operation.");const d=[];for(const m of o)switch(m.field){case"method":case"url":{u.xOperation.ornull===null&&u.xOperation.set({method:"GET",url:""});const g=u.xOperation.ornull;if(!g)return Pe("Step xOperation state is unavailable.");if(m.field==="method")g.method.set(m.data);else{const f=J2(m.data);g.url.set(f);const v=u.parameters.queryParameters.get({noproxy:!0});u.parameters.queryParameters.set(Pv(qv(f),v))}d.push(We("applied"));break}case"description":u.description.set(m.data),d.push(We("applied"));break;case"body":u.requestBody.merge({content:m.data.content,...m.data.contentType!==void 0&&{type:m.data.contentType}}),d.push(We("applied"));break;case"parameters":d.push(K2(m,u));break;case"outputs":d.push(Y2(m,u));break;case"successCriteria":d.push(X2(m,u));break}const c=o.some(m=>m.field==="outputs");return{isError:!1,data:{totalChanges:s.totalChanges??o.length,approvedChanges:s.approvedChanges??o.length,applied:d,...c&&{resultingState:Nl(u.outputs.get({noproxy:!0}))||"Outputs: (none)"}}}}}const jy={name:"update_step",definition:G2,createExecutor:e=>Q2(e.store)},eD=`Search the public web via a nested agent and return a consolidated summary.
|
|
350
350
|
|
|
351
351
|
**What it does**
|
|
352
352
|
- Runs provider web search (results depend on the active model provider) and synthesizes findings for the parent agent.
|
|
@@ -378,4 +378,4 @@ You must use the provider web search tool to gather information. You cannot acce
|
|
|
378
378
|
- Include source URLs for all claims that are material to the parent agent's next steps.
|
|
379
379
|
- Clearly distinguish between verified findings, inferred conclusions, and information that could not be verified.
|
|
380
380
|
- When sources conflict, report the conflict and cite the competing sources rather than selecting a winner without evidence.
|
|
381
|
-
`,sD=Zg(Ho("role",aD),Ho("output",rD));function iD(){return[Vg(sD)]}function lD(e){const t=sN(e),o=Pg(e);return async(n,a)=>{try{return{isError:!1,data:{message:await dl({model:o,system:iD(),prompt:uD(n),tools:t,toolChoice:"required",stopWhen:cS("web_search"),temperature:0,abortSignal:a.abortSignal}).text}}}catch(r){return{isError:!0,error:{message:r.message}}}}}function uD(e){return nt(["[URL]",e.url," ","[TASK]",e.task])}const Uy={name:"web_search",definition:nD,createExecutor:e=>lD(e.model)},zy=[by,xy,ky,Ty,Cy,Py,jy,ty,my,fy,Uy,cy];function cD(e){return zy.some(t=>t.name===e)}function dD(e,t){for(const o of zy)e.register(f$(o,t[o.name]))}function Ly(e){const t=e.startsWith("tool-")?e.slice(5):e;return cD(t)?t:void 0}function Fy(e,t){return`${e}::${t}`}function Os(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&e.type.startsWith("tool-")&&"toolCallId"in e}function Rs(e){return e.state==="approval-requested"&&e.approval?.id!=null}function Zy(e){return e.state==="output-denied"?!0:e.state==="output-available"&&e.approval!=null}function By(e){return e.parts.some(t=>Os(t)&&Rs(t))}function pD(e){return e.some(By)}function mD(e){return e.map(t=>By(t)?{...t,parts:t.parts.map(hD)}:t)}function hD(e){return!Os(e)||!Rs(e)?e:{...e,state:"output-denied",approval:{id:e.approval.id,approved:!1}}}function fD(e){const t=[],o=[];let n=0;const a={},r=()=>{o.length!==0&&(t.push({kind:"reasoning-block",key:`reasoning-${n++}`,items:[...o]}),o.length=0)},s=l=>{const u=l.trim();if(u.length===0)return;const d=o[o.length-1];d?.kind==="action"&&d.text===u||o.push({kind:"action",text:u})};for(let l=0;l<e.length;l++){const u=e[l];if(u.type==="step-start")continue;if(u.type==="text"){r();const c=u.text??"";c.length>0&&t.push({kind:"text",text:c,key:`text-${l}`,workflowRunHistoryIds:Object.fromEntries(Object.entries(a).map(([m,g])=>[m,[...g]]))});continue}if(!Os(u))continue;const d=Ly(u.type);if(d===Jv){const c=yD(u);if(c){const m=Fy(c.collectionId,c.workflowId),g=a[m]??=[];g.includes(c.historyId)||g.push(c.historyId)}}if(d===Gv){const c=vD(u.input);c&&s(c);continue}if(Rs(u)||Zy(u)){r(),t.push({kind:"tool",part:u,key:`tool-${l}`});continue}}return r(),t}const gD=ue({isError:Ue(!1),data:ue({collectionId:$().min(1),workflowId:$().min(1),historyId:$().min(1)})});function yD(e){if(e.state!=="output-available")return;const t=gD.safeParse(e.output);return t.success?t.data.data:void 0}function vD(e){if(e==null||typeof e!="object")return;const t=e.message;if(typeof t!="string")return;const o=t.trim();return o.length>0?o:void 0}function _D(e){return e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function wD(e){return
|
|
381
|
+
`,sD=Zg(Ho("role",aD),Ho("output",rD));function iD(){return[Vg(sD)]}function lD(e){const t=sN(e),o=Pg(e);return async(n,a)=>{try{return{isError:!1,data:{message:await dl({model:o,system:iD(),prompt:uD(n),tools:t,toolChoice:"required",stopWhen:cS("web_search"),temperature:0,abortSignal:a.abortSignal}).text}}}catch(r){return{isError:!0,error:{message:r.message}}}}}function uD(e){return nt(["[URL]",e.url," ","[TASK]",e.task])}const Uy={name:"web_search",definition:nD,createExecutor:e=>lD(e.model)},zy=[by,xy,ky,Ty,Cy,Py,jy,ty,my,fy,Uy,cy];function cD(e){return zy.some(t=>t.name===e)}function dD(e,t){for(const o of zy)e.register(f$(o,t[o.name]))}function Ly(e){const t=e.startsWith("tool-")?e.slice(5):e;return cD(t)?t:void 0}function Fy(e,t){return`${e}::${t}`}function Os(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&e.type.startsWith("tool-")&&"toolCallId"in e}function Rs(e){return e.state==="approval-requested"&&e.approval?.id!=null}function Zy(e){return e.state==="output-denied"?!0:e.state==="output-available"&&e.approval!=null}function By(e){return e.parts.some(t=>Os(t)&&Rs(t))}function pD(e){return e.some(By)}function mD(e){return e.map(t=>By(t)?{...t,parts:t.parts.map(hD)}:t)}function hD(e){return!Os(e)||!Rs(e)?e:{...e,state:"output-denied",approval:{id:e.approval.id,approved:!1}}}function fD(e){const t=[],o=[];let n=0;const a={},r=()=>{o.length!==0&&(t.push({kind:"reasoning-block",key:`reasoning-${n++}`,items:[...o]}),o.length=0)},s=l=>{const u=l.trim();if(u.length===0)return;const d=o[o.length-1];d?.kind==="action"&&d.text===u||o.push({kind:"action",text:u})};for(let l=0;l<e.length;l++){const u=e[l];if(u.type==="step-start")continue;if(u.type==="text"){r();const c=u.text??"";c.length>0&&t.push({kind:"text",text:c,key:`text-${l}`,workflowRunHistoryIds:Object.fromEntries(Object.entries(a).map(([m,g])=>[m,[...g]]))});continue}if(!Os(u))continue;const d=Ly(u.type);if(d===Jv){const c=yD(u);if(c){const m=Fy(c.collectionId,c.workflowId),g=a[m]??=[];g.includes(c.historyId)||g.push(c.historyId)}}if(d===Gv){const c=vD(u.input);c&&s(c);continue}if(Rs(u)||Zy(u)){r(),t.push({kind:"tool",part:u,key:`tool-${l}`});continue}}return r(),t}const gD=ue({isError:Ue(!1),data:ue({collectionId:$().min(1),workflowId:$().min(1),historyId:$().min(1)})});function yD(e){if(e.state!=="output-available")return;const t=gD.safeParse(e.output);return t.success?t.data.data:void 0}function vD(e){if(e==null||typeof e!="object")return;const t=e.message;if(typeof t!="string")return;const o=t.trim();return o.length>0?o:void 0}function _D(e){return e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function wD(e){return Dv({queryKey:pu.detail(e??""),queryFn:async()=>e?await du.getInstance().findOne(e)??null:null,enabled:!!e})}function bD(e){return Bv({queryKey:pu.infiniteHistory(e),initialPageParam:0,queryFn:async({pageParam:t})=>du.getInstance().findRecentChatsPage({offset:t,limit:e}),getNextPageParam:t=>t.hasMore?t.nextOffset:void 0})}export{eE as A,vy as B,wy as C,tE as D,_y as E,Fy as F,Hv as G,Vv as H,Os as I,Rs as J,vo as K,Dl as L,Oy as M,qa as N,y$ as O,Ly as P,Zy as Q,fD as R,Bg as S,FS as T,bD as U,Wv as V,Pg as a,Ho as b,GS as c,cy as d,ty as e,Cy as f,bN as g,my as h,ms as i,Py as j,Ty as k,ky as l,fy as m,xy as n,by as o,KS as p,pD as q,dD as r,dl as s,mD as t,jy as u,Qg as v,Uy as w,oE as x,_D as y,wD as z};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.24.0-next.
|
|
3
|
+
"version": "3.24.0-next.13",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"web-vitals": "3.3.1",
|
|
42
42
|
"@redocly/config": "0.53.1",
|
|
43
43
|
"@redocly/redoc-opentelemetry": "0.2.2",
|
|
44
|
-
"@redocly/replay": "0.27.0-next.
|
|
44
|
+
"@redocly/replay": "0.27.0-next.12"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@shikijs/transformers": "3.21.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"url": "~0.11.0",
|
|
72
72
|
"vite": "7.3.6",
|
|
73
73
|
"vitest": "4.1.10",
|
|
74
|
-
"@redocly/theme": "0.68.0-next.
|
|
74
|
+
"@redocly/theme": "0.68.0-next.9"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"start": "pnpm run copy-highlight-hook && vite",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as i}from"./redocly-openapi-docs.min.standalone-D8BmO4OO.js";import{R as u,U as n}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";function m(){return`aichat_${i()}`}function l(){return`aimsg_${i()}`}function c(){return`aimpt_${i()}`}function f(t){return{id:t.id,title:t.title??void 0,modelConfig:t.modelConfig,messages:t.messages.map(p),createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}}function p(t){return{id:t.uiId,role:t.role,metadata:t.metadata,parts:t.parts.map(g)}}function g(t){return t.self}function I(t){const a=t.id;return{id:a,title:t.title,modelConfig:t.modelConfig,messages:t.messages.map((e,r)=>d(a,r,e))}}function d(t,a,e,r=l()){return{id:r,uiId:e.id,role:e.role,metadata:e.metadata,aiChatId:t,indexWithinInsertBatch:a,parts:e.parts.map((o,s)=>C(r,s,o))}}function C(t,a,e){return{id:c(),text:e.type==="text"?e.text:null,index:a,self:e,aiMessageId:t}}function h(t){return{id:t.id,title:t.title,modelConfig:v(t.model),messages:t.messages.map(x)}}function v(t){switch(t.provider){case n.OPENAI:case n.ANTHROPIC:case n.GEMINI:return{provider:t.provider,modelId:t.modelId};case u:return{provider:t.provider,baseUrl:t.baseUrl};default:throw new Error("Cannot create model config")}}function x(t){return{...t,parts:t.parts.filter(a=>a.type!=="file")}}export{I as a,h as b,f as c,d,m as g};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aL as r,a7 as n,aM as i,aN as c,aO as l}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";import{aI as f,ap as s,bl as d,b3 as o}from"./redocly-openapi-docs.min.standalone-D8BmO4OO.js";class w extends f{constructor(){super()}resolveExternalRef(e,a){return r(a)?a:e&&r(e)?new URL(a,e).href:e?s.resolve(s.dirname(e),a):a}async loadExternalRef(e){if(r(e)){const{body:a,mimeType:t}=await d(e,{...this.config.http,customFetch:n});return new o(e,a,t)}else{if(!await i(e))throw new Error(`File not found at ${e}.`);try{throw await c(e),new Error(`Expected a file but received a folder at ${e}.`)}catch(t){if(t instanceof Error&&t.message.includes("Expected a file but received a folder"))throw t}const a=await l(e);return new o(e,a.replace(/\r\n/g,`
|
|
2
|
-
`))}}}export{w as ExternalResolver};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aK as t}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";async function a(o={}){return typeof o=="object"&&Object.freeze(o),await t("plugin:dialog|open",{options:o})}export{a as open};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aC as T,x as m,aD as v,aE as O,aF as I,aG as w,aH as A,aI as h,aJ as C,aK as b,aL as V}from"./redocly-openapi-docs.min.standalone-D8BmO4OO.js";import{aM as M,aN as B,aO as q,aP as J,aQ as Y,aR as W,aS as H,aT as K,aU as Q,aV as X,aW as Z,aX as ee,aY as se,aZ as ae,a_ as te,a$ as re,b0 as ne,b1 as oe,b2 as ie,b3 as le,b4 as ce,b5 as me,b6 as ue,b7 as pe,b8 as ye,b9 as fe,ba as de,bb as ge,bc as he,bd as ve,be,bf as Ee,bg as Re,bh as Se,bi as Te,bj as Oe,bk as Ie,bl as we,bm as Ae,bn as Ce,bo as xe,bp as De,bq as Pe}from"./redocly-openapi-docs.min.standalone-D8BmO4OO.js";import{g as x,t as D,A as je,c as E,l as R,S as ke,R as Ne,C as Fe}from"./redocly-openapi-docs.min.lint-BPYH3T43.js";import{a as ze,b as _e,d as $e,e as Le,f as Ge,h as Ue,i as Ve,j as Me,k as Be,m as qe,n as Je,o as Ye,p as We,q as He,r as Ke,s as Qe,u as Xe,v as Ze,w as es,x as ss,y as as,z as ts,B as rs,s as ns,D as os}from"./redocly-openapi-docs.min.lint-BPYH3T43.js";function is(e){return(T.extname(e)===".yaml"||T.extname(e)===".yml")&&!1}function ls(e){return m(e)&&!v(e)}async function cs(e){return new Promise(s=>setTimeout(s,e))}const S="type",P=["api-description","api-operation","data-schema"];function j(e,s){const{ctx:a}=x("EntityFileDefault",s),{ctx:t,discriminatorResolver:r}=x("EntityFile",e);return{entityTypes:{...a,...t,EntityFileArray:{properties:{},items:n=>{if(m(n)){const i=n[S];if(!i)return"Entity";const o=r?.(n,i);if(o&&typeof o=="string")return o}return"Entity"}}},discriminatorResolver:r}}const ms=e=>({ExternalDocs:{leave(){e.externalDocs.total++}},ref:{enter(s){e.refs.items.add(s.$ref)}},Tag:{leave(s){e.tags.items.add(s.name)}},Link:{leave(s){e.links.items.add(s.operationId)}},WebhooksMap:{Operation:{leave(s){if(e.webhooks.total++,s.tags)for(const a of s.tags)e.tags.items.add(a)}}},Paths:{PathItem:{leave(){e.pathItems.total++},Operation:{leave(s){if(e.operations.total++,s.tags)for(const a of s.tags)e.tags.items.add(a)}},Parameter:{leave(s){e.parameters.items.add(s.name)}}}},NamedSchemas:{Schema:{leave(){e.schemas.total++}}},Root:{leave(){e.parameters.total=e.parameters.items.size,e.refs.total=e.refs.items.size,e.links.total=e.links.items.size,e.tags.total=e.tags.items.size}}}),us=e=>({ExternalDocs:{leave(){e.externalDocs.total++}},ref:{enter(s){e.refs.items.add(s.$ref)}},Tag:{leave(s){e.tags.items.add(s.name)}},ChannelMap:{Channel:{leave(){e.channels.total++},Operation:{leave(s){if(e.operations.total++,s.tags)for(const a of s.tags)e.tags.items.add(a)}},Parameter:{leave(s){s.name&&e.parameters.items.add(s.name)}}}},NamedSchemas:{Schema:{leave(){e.schemas.total++}}},Root:{leave(){e.parameters.total=e.parameters.items.size,e.refs.total=e.refs.items.size,e.tags.total=e.tags.items.size}}}),ps=e=>({ExternalDocs:{leave(){e.externalDocs.total++}},ref:{enter(s){e.refs.items.add(s.$ref)}},Tag:{leave(s){e.tags.items.add(s.name)}},NamedChannels:{Channel:{leave(){e.channels.total++},Parameter:{leave(s){s.name&&e.parameters.items.add(s.name)}}}},NamedOperations:{Operation:{leave(s){if(e.operations.total++,s.tags)for(const a of s.tags)e.tags.items.add(a)}}},NamedSchemas:{Schema:{leave(){e.schemas.total++}}},Root:{leave(){e.parameters.total=e.parameters.items.size,e.refs.total=e.refs.items.size,e.tags.total=e.tags.items.size}}}),ys=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,k=2,N=150,fs=()=>({any(e,{report:s,location:a}){if(m(e)&&"key"in e){const t=e.key;if(typeof t!="string"){s({message:"Entity `key` must be a string.",location:a.child(["key"])});return}t.length<k&&s({message:`Entity 'key' must be at least ${k} characters long.`,location:a.child(["key"])}),t.length>N&&s({message:`Entity 'key' must not exceed ${N} characters.`,location:a.child(["key"])}),ys.test(t)||s({message:"Entity `key` must contain only lowercase letters, numbers, and hyphens, and cannot start or end with a hyphen.",location:a.child(["key"])})}}});function F(e,s){const a=s.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")+e;return Object.values(D).includes(a)?a:e}function ds(e,s){const a={};for(const[t,r]of Object.entries(s))if(z(t,r)){if(r.severity==="off")continue;a[t]={...bs(e,t,r)}}else a[t]=r;return a}function gs(e){const s={},a={};for(const[t,r]of Object.entries(e))if(z(t,r)){const n=r;vs(n)?s[t]=n:a[t]=n}else a[t]=r;return{entityRules:s,apiRules:a}}function hs(e,s,a){if(!m(a.parsed)||!m(a.parsed.components))return null;const t=a.parsed.components,r="schemas"in t?t.schemas:void 0;if(!r||!(e in r))return null;const n=r[e];try{const i=JSON.parse(s);if(O(n,i))return n}catch{return null}return null}function z(e,s){return e.startsWith("rule/")&&m(s)}function vs(e){return Object.values(D).some(s=>e.subject.type===s)}function bs(e,s,a){const t=F(a.subject.type,e),r=a.where?.map(n=>({...n,subject:{...n.subject,type:F(n.subject.type,e)}}));return{assertionId:s,subject:{...a.subject,type:t},assertions:a.assertions,...r&&{where:r},...a.message&&{message:a.message},...a.severity&&{severity:a.severity}}}async function _(e){const{document:s,entitySchema:a,entityDefaultSchema:t,severity:r,externalRefResolver:n=new h,assertionConfig:i={}}=e,o={problems:[],specVersion:"entity",visitorsData:{}},{entityTypes:u,discriminatorResolver:p}=j(a,t),l=I(u);let c=l.Entity;if(Array.isArray(s.parsed))c=l.EntityFileArray;else if(m(s.parsed)){const d=s.parsed[S];if(!d)c=l.Entity;else{const g=p?.(s.parsed,d);g&&typeof g=="string"&&l[g]&&(c=l[g])}}const y=je(i),f=Array.isArray(y)?y.map(d=>({severity:r||"error",ruleId:"entity assertions",visitor:d})):[{severity:r||"error",ruleId:"entity assertions",visitor:y}],L=[{severity:r||"error",ruleId:"entity struct",visitor:ke()},{severity:r||"error",ruleId:"entity no-unresolved-refs",visitor:V()},{severity:r||"error",ruleId:"entity key-valid",visitor:fs()},...f],G=w(L,l),U=await A({rootDocument:s,rootType:c,externalRefResolver:n});return C({document:s,rootType:c,normalizedVisitors:G,resolvedRefMap:U,ctx:o}),o.problems}async function Es(e,s,a){if(!s.rules)throw new Error(`Scorecard level "${s.name}" has no rules defined.`);const t=new h,r=b(JSON.stringify(e,null,2),"entity"),n=r.parsed[S],i=ds(n||"unknown",s.rules),{entityRules:o,apiRules:u}=gs(i),p=await _({document:r,entitySchema:Fe,entityDefaultSchema:Ne,externalRefResolver:t,assertionConfig:o});if(P.includes(e.type)){if(Object.keys(u).length===0)return p;if(!a)throw new Error(`Document is required for entity type "${e.type}". Provide the source API document to lint API rules.`);if(e.type==="data-schema"&&e.metadata?.schema){Object.values(u).forEach(f=>{if(m(f)&&m(f.subject)&&f.subject.type!=="Schema")throw new Error(`API rules for "data-schema" entity must target Schema subject, but found "${f.subject.type}".`)});const c=hs(e.title,e.metadata.schema,a);if(!c)throw new Error(`Schema "${e.title}" not found in the document. Ensure the schema exists in components.schemas.`);const y=await $({schema:c,schemaKey:e.title,config:await E({rules:u}),specType:e.metadata.specType,sourceDocument:a,externalRefResolver:t});return[...p,...y]}const l=await R({document:a,externalRefResolver:t,config:await E({rules:u})});return[...p,...l]}else if(!v(u))throw new Error(`API rules are not supported for entity type "${e.type}". Only ${P.join(", ")} support API rules.`);return p}async function $(e){const{schema:s,schemaKey:a,config:t,sourceDocument:r,specType:n,externalRefResolver:i=new h(t.resolve)}=e,o=r.parsed,u=o[n],p=o.info,l=b(JSON.stringify({[n]:u,info:p,components:{schemas:{[a]:s}}},null,2),r?.source.absoluteRef||`schema:${a}`);return(await R({document:l,config:t,externalRefResolver:i})).filter(c=>c.location.some(y=>y.pointer?.includes(`/components/schemas/${a}`)))}class Rs extends Error{}export{M as Arazzo1Types,B as Arazzo1_1Types,q as AsyncApi2Types,J as AsyncApi3Types,h as BaseResolver,Y as CONFIG_BUNDLER_VISITOR_ID,W as CONFIG_FILE_NAME,H as Config,ze as ConfigTypes,_e as ConfigValidationError,K as DEFAULT_CONFIG,Q as DEFAULT_PROJECT_PLUGIN_PATHS,Rs as HandledError,X as IGNORE_BANNER,Z as IGNORE_FILE,ee as Oas2Types,se as Oas3Types,ae as Oas3_1Types,te as Oas3_2Types,re as OpenRpcTypes,ne as Overlay1Types,oe as PLUGINS_COLLECTOR_VISITOR_ID,ie as ResolveError,le as Source,us as StatsAsync2,ps as StatsAsync3,ms as StatsOAS,ce as YamlParseError,$e as bundle,me as bundleDocument,Le as bundleFromString,Ge as clearPluginsCache,E as createConfig,Ue as createConfigTypes,j as createEntityTypes,O as dequal,ue as detectSpec,is as doesYamlFileExist,pe as escapePointerFragment,Ve as findConfig,Me as formatProblems,Be as getAstNodeByPointer,qe as getCodeframe,ye as getDir,Je as getLineColLocation,fe as getMajorSpecVersion,Ye as getPluginCacheVersion,We as getTotals,de as getTypes,ge as isAbsoluteUrl,he as isBrowser,v as isEmptyObject,ve as isGraphqlRef,be as isMappingRef,He as isNotEmptyArray,ls as isNotEmptyObject,m as isPlainObject,Ee as isRef,Re as isString,Se as isSupportedExtension,Te as isTruthy,Ke as keysOf,Qe as lint,Xe as lintConfig,R as lintDocument,_ as lintEntityFile,Es as lintEntityWithScorecardLevel,Ze as lintFromString,$ as lintSchema,es as loadConfig,ss as loadIgnoreConfig,as as logger,b as makeDocumentFromString,Oe as mapTypeToComponent,I as normalizeTypes,w as normalizeVisitors,Ie as parseYaml,cs as pause,ts as pluralize,we as readFileFromUrl,Ae as regexFromString,A as resolveDocument,Ce as resolvePath,rs as resolvePlugins,xe as slash,De as stringifyYaml,Pe as unescapePointerFragment,ns as validate,C as walkDocument,os as xmlEscape};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
async function i(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}async function a(n,e){await i("plugin:opener|open_url",{url:n,with:e})}async function r(n,e){await i("plugin:opener|open_path",{path:n,with:e})}async function o(n){return i("plugin:opener|reveal_item_in_dir",{paths:typeof n=="string"?[n]:n})}export{r as openPath,a as openUrl,o as revealItemInDir};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b6 as f,b7 as l,b8 as u}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";import{b9 as w,ba as g,bb as h}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";async function x(s,e){const a=u(),r=await l(s),c=await l(e),n=r.replace(new RegExp(`^${a}+`),"").split(a).filter(Boolean),i=c.replace(new RegExp(`^${a}+`),"").split(a).filter(Boolean),p=Math.min(n.length,i.length);let o=0;for(let t=0;t<p&&n[t]===i[t];t++)o++;const b=n.slice(o).map(()=>".."),m=i.slice(o);return[...b,...m].join(a)}async function $(s){const e=await f(s);return e?`.${e}`:""}export{w as dirname,$ as extname,g as isAbsolute,h as join,x as relative,l as resolve};
|