@redocly/openapi-docs 3.24.0-next.11 → 3.24.0-next.12
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-B6qZxoKI.js → redocly-openapi-docs.min.AiChatProvider-Df0bddw5.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-Cy4k7pUw.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-fsf5yS84.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-Bwuv-ZH_.js → redocly-openapi-docs.min.AiPanel-aiEGENkd.js} +1 -1
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-DlCxvBqX.js → redocly-openapi-docs.min.SqliteDBStorage-D1Xkf-XX.js} +1 -1
- package/dist/{redocly-openapi-docs.min.ai-chat-mappers-C8DaS6ge.js → redocly-openapi-docs.min.ai-chat-mappers-C7hnSHO0.js} +1 -1
- package/dist/{redocly-openapi-docs.min.external-resolver-CKkEKWzQ.js → redocly-openapi-docs.min.external-resolver-3wjREuy_.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-bTUZhh-q.js → redocly-openapi-docs.min.index-BM1O0fdX.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-BsXv-Pjz.js → redocly-openapi-docs.min.index-I_lfTVFA.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-DWajc5Ac.js → redocly-openapi-docs.min.index-Zp6s2A4z.js} +1137 -1137
- package/dist/redocly-openapi-docs.min.index-qqKTpI_q.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-DMpx1vvZ.js → redocly-openapi-docs.min.lint-BPYH3T43.js} +2 -2
- package/dist/{redocly-openapi-docs.min.lint-graphql-DH0N_7pS.js → redocly-openapi-docs.min.lint-graphql-Cq7DgC7n.js} +1 -1
- package/dist/{redocly-openapi-docs.min.respect-run-JH1Xd21R.js → redocly-openapi-docs.min.respect-run-ztu6EOq2.js} +1 -1
- package/dist/redocly-openapi-docs.min.standalone-D8BmO4OO.js +11974 -0
- package/dist/{redocly-openapi-docs.min.tauri-path-TzmCcPBx.js → redocly-openapi-docs.min.tauri-path-laqHaTpn.js} +1 -1
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-RJxlmgfo.js → redocly-openapi-docs.min.useAiChatQueries-Dj8qddY3.js} +74 -74
- package/package.json +4 -4
- package/dist/redocly-openapi-docs.min.index-We3Hmt3m.js +0 -1
- package/dist/redocly-openapi-docs.min.standalone-DMeytWE9.js +0 -12112
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{U as v,V as T,az as x,M as _t,c as Qt,r as l,j as at}from"./redocly-openapi-docs.min.standalone-DMeytWE9.js";import{T as Gt,c as rt,D as Ht,a as Vt,u as mt,b as gt,d as A,A as ft,I as Yt,e as E,f as Xt,g as Zt,h as te,i as wt,j as ee,k as ne,l as oe,m as ae,n as Tt,o as st,p as ht,q as At,r as re,s as se,t as Mt,R as it,v as ie,w as yt,x as le,y as ue}from"./redocly-openapi-docs.min.index-DWajc5Ac.js";import{c as St,p as pe,g as ce,T as de,i as me,a as ge,s as fe,A as he,b as ye,r as Se,d as ve,e as be,o as Ie,f as ke,w as Ce,m as xe,h as _e,u as we,j as Te,k as Ae,l as Me,n as Oe,D as Ee,q as Re,t as je,v as qe,x as Ne,y as $e,z as Pe}from"./redocly-openapi-docs.min.useAiChatQueries-RJxlmgfo.js";import{b as Ot,g as Et}from"./redocly-openapi-docs.min.ai-chat-mappers-C8DaS6ge.js";function R(t){const e=t.toLowerCase(),n=[["google.vertex","gcp.vertex_ai"],["google.generative-ai","gcp.gemini"],["google-vertex","gcp.vertex_ai"],["amazon-bedrock","aws.bedrock"],["azure-openai","azure.ai.openai"],["anthropic","anthropic"],["openai","openai"],["azure","azure.ai.inference"],["google","gcp.gemini"],["mistral","mistral_ai"],["cohere","cohere"],["bedrock","aws.bedrock"],["groq","groq"],["deepseek","deepseek"],["perplexity","perplexity"],["xai","x_ai"]];for(const[o,r]of n)if(e===o||e.startsWith(o+".")||e.startsWith(o+"-"))return r;return t}function Rt(t){var e;return(e={"ai.generateText":"invoke_agent","ai.streamText":"invoke_agent","ai.generateObject":"invoke_agent","ai.streamObject":"invoke_agent","ai.embed":"embeddings","ai.embedMany":"embeddings","ai.rerank":"rerank"}[t])!=null?e:t}function jt(t){return typeof t=="string"?[{type:"text",content:t}]:Array.isArray(t)?t.map(e=>({type:"text",content:e.content})):[{type:"text",content:t.content}]}function De(t){var e,n,o,r,a;switch(t.type){case"text":return{type:"text",content:t.text};case"reasoning":return{type:"reasoning",content:t.text};case"tool-call":return{type:"tool_call",id:(e=t.toolCallId)!=null?e:null,name:t.toolName,arguments:t.input};case"tool-result":{const s=t.output;let i;return s&&(s.type==="text"||s.type==="error-text"||s.type==="json"||s.type==="error-json"?i=s.value:s.type==="execution-denied"?i={denied:!0,reason:s.reason}:i=s),{type:"tool_call_response",id:(n=t.toolCallId)!=null?n:null,response:i}}case"file":{const s=t.data,i=(()=>{if(typeof s=="object"&&s!==null&&!(s instanceof URL)&&!(s instanceof Uint8Array)&&!(s instanceof ArrayBuffer)&&"type"in s)switch(s.type){case"data":return s.data;case"url":return s.url;case"text":return s.text;default:return""}return s})();let u;if(i instanceof Uint8Array)u=St(i);else if(typeof i=="string"){if(i.startsWith("http://")||i.startsWith("https://"))return{type:"uri",modality:j(t.mediaType),mime_type:(o=t.mediaType)!=null?o:null,uri:i};u=i}else{if(i instanceof URL)return{type:"uri",modality:j(t.mediaType),mime_type:(r=t.mediaType)!=null?r:null,uri:i.toString()};u=String(i)}return{type:"blob",modality:j(t.mediaType),mime_type:(a=t.mediaType)!=null?a:null,content:u}}case"tool-approval-response":return{type:"tool_approval_response",approval_id:t.approvalId,approved:t.approved,reason:t.reason};case"custom":return{type:"custom",kind:t.kind};case"reasoning-file":return{type:String(t.type)};default:return{type:String(t.type)}}}function j(t){return!t||t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"image"}function We(t){return t.filter(e=>e.role!=="system").map(e=>{if(e.role==="system")return{role:"system",parts:[{type:"text",content:e.content}]};const n=e.content.map(De);return{role:e.role,parts:n}})}function vt({prompt:t,messages:e}){const n=[];if(typeof t=="string")n.push({role:"user",parts:[{type:"text",content:t}]});else if(Array.isArray(t))for(const o of t){const r=qt(o);r&&n.push(r)}if(e)for(const o of e){const r=qt(o);r&&n.push(r)}return n}function qt(t){if(t.role!=="system"){if(t.role==="user")return typeof t.content=="string"?{role:"user",parts:[{type:"text",content:t.content}]}:{role:"user",parts:t.content.map(e=>{var n,o,r,a,s,i,u,d;switch(e.type){case"text":return{type:"text",content:e.text};case"image":{const p=e.image;return p instanceof URL?{type:"uri",modality:"image",mime_type:(n=e.mediaType)!=null?n:null,uri:p.toString()}:typeof p=="string"?p.startsWith("http://")||p.startsWith("https://")?{type:"uri",modality:"image",mime_type:(o=e.mediaType)!=null?o:null,uri:p}:{type:"blob",modality:"image",mime_type:(r=e.mediaType)!=null?r:null,content:p}:{type:"blob",modality:"image",mime_type:(a=e.mediaType)!=null?a:null,content:St(p)}}case"file":{const p=e.data,c=(()=>{if(typeof p=="object"&&p!==null&&!(p instanceof URL)&&!(p instanceof Uint8Array)&&!(p instanceof ArrayBuffer)&&"type"in p)switch(p.type){case"data":return p.data;case"url":return p.url;case"text":return p.text;default:return""}return p})();return c instanceof URL?{type:"uri",modality:j(e.mediaType),mime_type:(s=e.mediaType)!=null?s:null,uri:c.toString()}:typeof c=="string"?c.startsWith("http://")||c.startsWith("https://")?{type:"uri",modality:j(e.mediaType),mime_type:(i=e.mediaType)!=null?i:null,uri:c}:{type:"blob",modality:j(e.mediaType),mime_type:(u=e.mediaType)!=null?u:null,content:c}:{type:"blob",modality:j(e.mediaType),mime_type:(d=e.mediaType)!=null?d:null,content:St(c)}}default:return{type:String(e.type)}}})};if(t.role==="assistant")return typeof t.content=="string"?{role:"assistant",parts:[{type:"text",content:t.content}]}:{role:"assistant",parts:t.content.map(e=>{var n,o;switch(e.type){case"text":return{type:"text",content:e.text};case"reasoning":return{type:"reasoning",content:e.text};case"tool-call":return{type:"tool_call",id:(n=e.toolCallId)!=null?n:null,name:e.toolName,arguments:e.input};case"tool-result":{const r=e.output;let a;return r&&(r.type==="text"||r.type==="error-text"||r.type==="json"||r.type==="error-json"?a=r.value:r.type==="execution-denied"?a={denied:!0,reason:r.reason}:a=r),{type:"tool_call_response",id:(o=e.toolCallId)!=null?o:null,response:a}}default:return{type:String(e.type)}}})};if(t.role==="tool")return{role:"tool",parts:t.content.map(e=>{var n;if(e.type==="tool-result"){const o=e.output;let r;return o&&(o.type==="text"||o.type==="error-text"||o.type==="json"||o.type==="error-json"?r=o.value:o.type==="execution-denied"?r={denied:!0,reason:o.reason}:r=o),{type:"tool_call_response",id:(n=e.toolCallId)!=null?n:null,response:r}}return{type:String(e.type)}})}}}function Nt({text:t,reasoning:e,toolCalls:n,files:o,finishReason:r}){const a=[];if(e)for(const s of e)"text"in s&&s.text&&a.push({type:"reasoning",content:s.text});if(t!=null&&t.length>0&&a.push({type:"text",content:t}),n)for(const s of n)a.push({type:"tool_call",id:s.toolCallId,name:s.toolName,arguments:s.input});if(o)for(const s of o)a.push({type:"blob",modality:j(s.mediaType),mime_type:s.mediaType,content:s.base64});return[{role:"assistant",parts:a,finish_reason:Pt(r)}]}function $t({objectText:t,finishReason:e}){return[{role:"assistant",parts:[{type:"text",content:t}],finish_reason:Pt(e)}]}function Pt(t){var e;return(e={stop:"stop",length:"length","content-filter":"content_filter","tool-calls":"tool_call",error:"error",other:"stop",unknown:"stop"}[t])!=null?e:t}function U(t,e){e instanceof Error?(t.recordException({name:e.name,message:e.message,stack:e.stack}),t.setStatus({code:_t.ERROR,message:e.message})):t.setStatus({code:_t.ERROR})}function Je(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function lt(t){if(!Array.isArray(t))return t;const e=new Set(t.filter(Je).map(o=>typeof o));if(e.size!==1)return;const[n]=e;return n==="string"?t.filter(o=>typeof o=="string"):n==="number"?t.filter(o=>typeof o=="number"):t.filter(o=>typeof o=="boolean")}function Le(t){const e={};for(const[n,o]of Object.entries(t??{})){if(o==null)continue;const r=lt(o);r!=null&&(e[n]=r)}return e}function Ue(t){return t?.isEnabled!==!1}function h(t,e){if(!Ue(t))return{};const n={};for(const[o,r]of Object.entries(e)){if(r==null)continue;if(typeof r=="object"&&"input"in r&&typeof r.input=="function"){if(t?.recordInputs===!1)continue;const s=r.input();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}if(typeof r=="object"&&"output"in r&&typeof r.output=="function"){if(t?.recordOutputs===!1)continue;const s=r.output();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}const a=lt(r);a!=null&&(n[o]=a)}return n}var Fe={usage:!1,providerMetadata:!1,embedding:!1,reranking:!1,runtimeContext:!1,headers:!1,toolChoice:!1,schema:!1};function Ke(t){var e,n,o,r,a,s,i,u;return{...Fe,usage:(e=t.usage)!=null?e:!1,providerMetadata:(n=t.providerMetadata)!=null?n:!1,embedding:(o=t.embedding)!=null?o:!1,reranking:(r=t.reranking)!=null?r:!1,runtimeContext:(a=t.runtimeContext)!=null?a:!1,headers:(s=t.headers)!=null?s:!1,toolChoice:(i=t.toolChoice)!=null?i:!1,schema:(u=t.schema)!=null?u:!1}}function Be(t){const e={};for(const[n,o]of Object.entries(t??{}))Dt(e,`ai.settings.context.${n}`,o);return e}function Dt(t,e,n){if(n!=null){if(Array.isArray(n)||typeof n!="object"){t[e]=n;return}for(const[o,r]of Object.entries(n))Dt(t,`${e}.${o}`,r)}}function ut(t){return Object.fromEntries(Object.entries(t??{}).filter(([,e])=>e!=null).map(([e,n])=>[`ai.request.headers.${e}`,n]))}function V(t){var e,n,o;return{"ai.usage.inputTokenDetails.noCacheTokens":(e=t.inputTokenDetails)==null?void 0:e.noCacheTokens,"ai.usage.outputTokenDetails.textTokens":(n=t.outputTokenDetails)==null?void 0:n.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(o=t.outputTokenDetails)==null?void 0:o.reasoningTokens}}function S(t,e,n){const o={};for(const[r,a]of Object.entries(n))!e[r]||a==null||Object.assign(o,h(t,a));return o}function pt(t){return t==null?void 0:t/1e3}function ze(t){var e;return{"gen_ai.client.operation.duration":pt(t.responseTimeMs),"gen_ai.client.operation.time_to_first_chunk":pt(t.timeToFirstOutputMs),"gen_ai.client.operation.time_per_output_chunk":pt((e=t.timeBetweenOutputChunksMs)==null?void 0:e.avg)}}var Qe=class{constructor(t={}){this.callStates=new Map;var e;this.tracer=(e=t.tracer)!=null?e:v.getTracer("gen_ai"),this.supplementalAttributes=Ke(t),this.enrichSpan=t.enrichSpan}getCallState(t){return this.callStates.get(t)}cleanupCallState(t){this.callStates.delete(t)}getSpanAttributes({attributes:t,spanType:e,operationId:n,callId:o,runtimeContext:r}){var a;let s;try{s=(a=this.enrichSpan)==null?void 0:a.call(this,{spanType:e,operationId:n,callId:o,runtimeContext:r})}catch{s=void 0}return{...Le(s),...t}}executeTool({callId:t,toolCallId:e,execute:n}){var o;const r=(o=this.getCallState(t))==null?void 0:o.toolSpans.get(e);return r==null?n():T.with(r.context,n)}executeLanguageModelCall({callId:t,execute:e}){var n;const o=this.getCallState(t),r=(n=o?.inferenceContext)!=null?n:o?.stepContext;return r==null?e():T.with(r,e)}onStart(t){if(t.operationId==="ai.embed"||t.operationId==="ai.embedMany"){this.onEmbedOperationStart(t);return}if(t.operationId==="ai.rerank"){this.onRerankOperationStart(t);return}if(t.operationId==="ai.generateObject"||t.operationId==="ai.streamObject"){this.onObjectOperationStart(t);return}this.onGenerateStart(t)}onGenerateStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,stopSequences:t.stopSequences,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=t.runtimeContext,i=S(n,this.supplementalAttributes,{runtimeContext:Be(s),headers:ut(t.headers)}),u=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.stop_sequences":t.stopSequences,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.instructions?{input:()=>JSON.stringify(jt(t.instructions))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:void 0,messages:t.messages}))},...i}),d=`${a} ${t.modelId}`,p=this.tracer.startSpan(d,{attributes:this.getSpanAttributes({attributes:u,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:s}),kind:x.INTERNAL}),c=v.setSpan(T.active(),p);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:p,rootContext:c,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:s,baseSupplementalAttributes:i})}onObjectOperationStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=S(n,this.supplementalAttributes,{headers:ut(t.headers)}),i=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.system?{input:()=>JSON.stringify(jt(t.system))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:t.prompt,messages:t.messages}))},...s,...S(n,this.supplementalAttributes,{schema:{"ai.schema":t.schema?{input:()=>JSON.stringify(t.schema)}:void 0,"ai.schema.name":t.schemaName,"ai.schema.description":t.schemaDescription,"ai.settings.output":t.output}})}),u=`${a} ${t.modelId}`,d=this.tracer.startSpan(u,{attributes:this.getSpanAttributes({attributes:i,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.INTERNAL}),p=v.setSpan(T.active(),d);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:d,rootContext:p,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:s})}onObjectStepStart(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan||!n.rootContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>t.promptMessages?JSON.stringify(We(t.promptMessages)):void 0},...n.baseSupplementalAttributes}),s=`chat ${t.modelId}`;n.inferenceSpan=this.tracer.startSpan(s,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.rootContext),n.inferenceContext=v.setSpan(n.rootContext,n.inferenceSpan)}onObjectStepEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.inferenceSpan)return;const{telemetry:o}=n;n.inferenceSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.response.id,"gen_ai.response.model":t.response.modelId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>{try{return JSON.stringify($t({objectText:t.objectText,finishReason:t.finishReason}))}catch{return t.objectText}}},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.inferenceSpan.end(),n.inferenceSpan=void 0,n.inferenceContext=void 0}onEmbedOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=t.value,a=t.operationId==="ai.embedMany",s=h(e,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{embedding:a?{"ai.values":{input:()=>r.map(p=>JSON.stringify(p))}}:{"ai.value":{input:()=>JSON.stringify(r)}}})}),i=`embeddings ${t.modelId}`,u=this.tracer.startSpan(i,{attributes:this.getSpanAttributes({attributes:s,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),d=v.setSpan(T.active(),u);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:u,rootContext:d,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onStepStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e;e.runtimeContext=t.runtimeContext;const o=h(n,{"gen_ai.operation.name":"agent_step",...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{toolChoice:{"ai.prompt.toolChoice":{input:()=>t.stepToolChoice!=null?JSON.stringify(t.stepToolChoice):void 0}}})});e.stepSpan=this.tracer.startSpan(`step ${t.steps.length+1}`,{attributes:this.getSpanAttributes({attributes:o,spanType:"step",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.rootContext),e.stepContext=v.setSpan(e.rootContext,e.stepSpan)}onLanguageModelCallStart(t){var e;const n=this.getCallState(t.callId);if(!n?.stepContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.stop_sequences":n.settings.stopSequences,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>{const s=vt({prompt:void 0,messages:t.messages});return s.length>0?JSON.stringify(s):void 0}},"gen_ai.tool.definitions":{input:()=>t.tools?JSON.stringify(t.tools):void 0}});n.inferenceSpan=this.tracer.startSpan(`chat ${t.modelId}`,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.stepContext),n.inferenceContext=v.setSpan(n.stepContext,n.inferenceSpan)}onLanguageModelCallEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.inferenceSpan)return;const{telemetry:r}=o;o.inferenceSpan.setAttributes(h(r,{...ze(t.performance),"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.responseId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>JSON.stringify(Nt({text:t.content.filter(a=>a.type==="text").map(a=>a.text).join("")||void 0,reasoning:t.content.filter(a=>a.type==="reasoning"),toolCalls:t.content.filter(a=>a.type==="tool-call"),files:t.content.filter(a=>a.type==="file").map(a=>a.file),finishReason:t.finishReason}))},...S(r,this.supplementalAttributes,{usage:V(t.usage)})})),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0}onToolExecutionStart(t){const e=this.getCallState(t.callId);if(!e?.stepContext)return;const{telemetry:n}=e,{toolCall:o}=t,r=h(n,{"gen_ai.operation.name":"execute_tool","gen_ai.tool.name":o.toolName,"gen_ai.tool.call.id":o.toolCallId,"gen_ai.tool.type":"function","gen_ai.tool.call.arguments":{input:()=>JSON.stringify(o.input)}}),a=`execute_tool ${o.toolName}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"tool",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.stepContext),i=v.setSpan(e.stepContext,s);e.toolSpans.set(o.toolCallId,{span:s,context:i})}onToolExecutionEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.toolSpans.get(t.toolCall.toolCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e,{toolOutput:a}=t;if(o.setAttributes(h(r,{"gen_ai.execute_tool.duration":pt(t.toolExecutionMs)})),a.type==="tool-result")try{o.setAttributes(h(r,{"gen_ai.tool.call.result":{output:()=>JSON.stringify(a.output)}}))}catch{}else U(o,a.error);o.end(),e.toolSpans.delete(t.toolCall.toolCallId)}onStepEnd(t){const e=this.getCallState(t.callId);if(!e?.stepSpan)return;const{telemetry:n}=e;e.stepSpan.setAttributes(S(n,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})),e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0}onStepFinish(t){this.onStepEnd(t)}onEnd(t){const e=this.getCallState(t.callId);if(e?.rootSpan){if(e.operationId==="ai.embed"||e.operationId==="ai.embedMany"){this.onEmbedOperationEnd(t);return}if(e.operationId==="ai.rerank"){this.onRerankOperationEnd(t);return}if(e.operationId==="ai.generateObject"||e.operationId==="ai.streamObject"){this.onObjectOperationEnd(t);return}this.onGenerateEnd(t)}}onGenerateEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.rootSpan)return;const{telemetry:r}=o;o.rootSpan.setAttributes(h(r,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>{var a;return JSON.stringify(Nt({text:(a=t.text)!=null?a:void 0,reasoning:t.finalStep.reasoning,toolCalls:t.toolCalls,files:t.files,finishReason:t.finishReason}))}},...S(r,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.finalStep.providerMetadata?JSON.stringify(t.finalStep.providerMetadata):void 0},usage:V(t.usage)})})),o.rootSpan.end(),this.cleanupCallState(t.callId)}onObjectOperationEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan)return;const{telemetry:o}=n;n.rootSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>t.object!=null?JSON.stringify($t({objectText:JSON.stringify(t.object),finishReason:t.finishReason})):void 0},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedOperationEnd(t){const e=this.getCallState(t.callId);if(!e?.rootSpan)return;const{telemetry:n}=e,o=e.operationId==="ai.embedMany";e.rootSpan.setAttributes(h(n,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(n,this.supplementalAttributes,{embedding:o?{"ai.embeddings":{output:()=>t.embedding.map(r=>JSON.stringify(r))}}:{"ai.embedding":{output:()=>JSON.stringify(t.embedding)}}})})),e.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{embedding:{"ai.values":{input:()=>t.values.map(u=>JSON.stringify(u))}}})}),a=`embeddings ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"embedding",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.embedSpans.set(t.embedCallId,{span:s,context:i})}onEmbedEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.embedSpans.get(t.embedCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e;o.setAttributes(h(r,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(r,this.supplementalAttributes,{embedding:{"ai.embeddings":{output:()=>t.embeddings.map(a=>JSON.stringify(a))}}})})),o.end(),e.embedSpans.delete(t.embedCallId)}onRerankOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=h(e,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${t.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),i=v.setSpan(T.active(),s);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:s,rootContext:i,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onRerankOperationEnd(t){const e=this.getCallState(t.callId);e?.rootSpan&&(e.rootSpan.end(),this.cleanupCallState(t.callId))}onRerankStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"reranking",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.rerankSpan={span:s,context:i}}onRerankEnd(t){const e=this.getCallState(t.callId);if(!e?.rerankSpan)return;const{span:n}=e.rerankSpan,{telemetry:o}=e;n.setAttributes(S(o,this.supplementalAttributes,{reranking:{"ai.ranking.type":t.documentsType,"ai.ranking":{output:()=>t.ranking.map(r=>JSON.stringify(r))}}})),n.end(),e.rerankSpan=void 0}onAbort(t){const e=this.getCallState(t.callId);if(e?.rootSpan){for(const{span:n}of e.toolSpans.values())n.end();e.toolSpans.clear(),e.inferenceSpan&&(e.inferenceSpan.end(),e.inferenceSpan=void 0,e.inferenceContext=void 0),e.stepSpan&&(e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0);for(const{span:n}of e.embedSpans.values())n.end();e.embedSpans.clear(),e.rerankSpan&&(e.rerankSpan.span.end(),e.rerankSpan=void 0),e.rootSpan.end(),this.cleanupCallState(t.callId)}}onError(t){var e;const n=t;if(!n?.callId)return;const o=this.getCallState(n.callId);if(!o?.rootSpan)return;const r=(e=n.error)!=null?e:t;for(const{span:a}of o.toolSpans.values())U(a,r),a.end();o.toolSpans.clear(),o.inferenceSpan&&(U(o.inferenceSpan,r),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0),o.stepSpan&&(U(o.stepSpan,r),o.stepSpan.end(),o.stepSpan=void 0,o.stepContext=void 0);for(const{span:a}of o.embedSpans.values())U(a,r),a.end();o.embedSpans.clear(),o.rerankSpan&&(U(o.rerankSpan.span,r),o.rerankSpan.span.end(),o.rerankSpan=void 0),U(o.rootSpan,r),o.rootSpan.end(),this.cleanupCallState(n.callId)}};function Ge(t){return pe({messages:t,emptyMessages:"remove",reasoning:"none",toolCalls:`before-last-${Gt}-messages`})}function He(t){return typeof t=="object"&&t!==null&&"role"in t&&"content"in t}function Ve(t){return Array.isArray(t)&&t.every(He)}function Ye(t,{conversationId:e,getModel:n}){let o=0;const r=()=>{const a=n?.();return a?{model_provider:a.provider,model_id:a.modelId}:{}};return{onStepStart:()=>{o+=1},onToolExecutionStart:a=>{t("com.redocly.aiChat.toolCallStarted",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,...r()}])},onToolExecutionEnd:a=>{const s=a.toolOutput.type==="tool-error";t("com.redocly.aiChat.toolCallFinished",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,success:!s,duration_ms:a.toolExecutionMs,...r(),...s&&{error:a.toolOutput.error instanceof Error?a.toolOutput.error.message:String(a.toolOutput.error)}}])},onStart:a=>{o=0,t("com.redocly.aiChat.conversationStarted",[{...rt("conversation",e,"ai"),model_provider:"provider"in a?a.provider:"unknown",model_id:"modelId"in a?a.modelId:"unknown"}])},onEnd:a=>{if(!("steps"in a))return;const s=a.usage;t("com.redocly.aiChat.conversationFinished",[{...rt("conversation",e,"ai"),model_provider:a.model.provider,model_id:a.model.modelId,success:!0,step_count:a.steps.length,finish_reason:a.finishReason,input_tokens:s.inputTokens,output_tokens:s.outputTokens,total_tokens:s.totalTokens}])}}}function Xe(t,e){const n=()=>v.getSpan(T.active())?T.active():e;return{startSpan:(o,r,a)=>t.startSpan(o,r,a??e),startActiveSpan:((o,r,a,s)=>{if(typeof r=="function")return t.startActiveSpan(o,{},n(),r);if(typeof a=="function")return t.startActiveSpan(o,r,n(),a);if(s)return t.startActiveSpan(o,r,a,s);throw new Error("withParentContext: invalid startActiveSpan invocation")})}}const Ze=`You are a helpful assistant that can generate titles for conversations.
|
|
1
|
+
import{U as v,V as T,az as x,M as _t,c as Qt,r as l,j as at}from"./redocly-openapi-docs.min.standalone-D8BmO4OO.js";import{T as Gt,c as rt,D as Ht,a as Vt,u as mt,b as gt,d as A,A as ft,I as Yt,e as E,f as Xt,g as Zt,h as te,i as wt,j as ee,k as ne,l as oe,m as ae,n as Tt,o as st,p as ht,q as At,r as re,s as se,t as Mt,R as it,v as ie,w as yt,x as le,y as ue}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";import{c as St,p as pe,g as ce,T as de,i as me,a as ge,s as fe,A as he,b as ye,r as Se,d as ve,e as be,o as Ie,f as ke,w as Ce,m as xe,h as _e,u as we,j as Te,k as Ae,l as Me,n as Oe,D as Ee,q as Re,t as je,v as qe,x as Ne,y as $e,z as Pe}from"./redocly-openapi-docs.min.useAiChatQueries-Dj8qddY3.js";import{b as Ot,g as Et}from"./redocly-openapi-docs.min.ai-chat-mappers-C7hnSHO0.js";function R(t){const e=t.toLowerCase(),n=[["google.vertex","gcp.vertex_ai"],["google.generative-ai","gcp.gemini"],["google-vertex","gcp.vertex_ai"],["amazon-bedrock","aws.bedrock"],["azure-openai","azure.ai.openai"],["anthropic","anthropic"],["openai","openai"],["azure","azure.ai.inference"],["google","gcp.gemini"],["mistral","mistral_ai"],["cohere","cohere"],["bedrock","aws.bedrock"],["groq","groq"],["deepseek","deepseek"],["perplexity","perplexity"],["xai","x_ai"]];for(const[o,r]of n)if(e===o||e.startsWith(o+".")||e.startsWith(o+"-"))return r;return t}function Rt(t){var e;return(e={"ai.generateText":"invoke_agent","ai.streamText":"invoke_agent","ai.generateObject":"invoke_agent","ai.streamObject":"invoke_agent","ai.embed":"embeddings","ai.embedMany":"embeddings","ai.rerank":"rerank"}[t])!=null?e:t}function jt(t){return typeof t=="string"?[{type:"text",content:t}]:Array.isArray(t)?t.map(e=>({type:"text",content:e.content})):[{type:"text",content:t.content}]}function De(t){var e,n,o,r,a;switch(t.type){case"text":return{type:"text",content:t.text};case"reasoning":return{type:"reasoning",content:t.text};case"tool-call":return{type:"tool_call",id:(e=t.toolCallId)!=null?e:null,name:t.toolName,arguments:t.input};case"tool-result":{const s=t.output;let i;return s&&(s.type==="text"||s.type==="error-text"||s.type==="json"||s.type==="error-json"?i=s.value:s.type==="execution-denied"?i={denied:!0,reason:s.reason}:i=s),{type:"tool_call_response",id:(n=t.toolCallId)!=null?n:null,response:i}}case"file":{const s=t.data,i=(()=>{if(typeof s=="object"&&s!==null&&!(s instanceof URL)&&!(s instanceof Uint8Array)&&!(s instanceof ArrayBuffer)&&"type"in s)switch(s.type){case"data":return s.data;case"url":return s.url;case"text":return s.text;default:return""}return s})();let u;if(i instanceof Uint8Array)u=St(i);else if(typeof i=="string"){if(i.startsWith("http://")||i.startsWith("https://"))return{type:"uri",modality:j(t.mediaType),mime_type:(o=t.mediaType)!=null?o:null,uri:i};u=i}else{if(i instanceof URL)return{type:"uri",modality:j(t.mediaType),mime_type:(r=t.mediaType)!=null?r:null,uri:i.toString()};u=String(i)}return{type:"blob",modality:j(t.mediaType),mime_type:(a=t.mediaType)!=null?a:null,content:u}}case"tool-approval-response":return{type:"tool_approval_response",approval_id:t.approvalId,approved:t.approved,reason:t.reason};case"custom":return{type:"custom",kind:t.kind};case"reasoning-file":return{type:String(t.type)};default:return{type:String(t.type)}}}function j(t){return!t||t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"image"}function We(t){return t.filter(e=>e.role!=="system").map(e=>{if(e.role==="system")return{role:"system",parts:[{type:"text",content:e.content}]};const n=e.content.map(De);return{role:e.role,parts:n}})}function vt({prompt:t,messages:e}){const n=[];if(typeof t=="string")n.push({role:"user",parts:[{type:"text",content:t}]});else if(Array.isArray(t))for(const o of t){const r=qt(o);r&&n.push(r)}if(e)for(const o of e){const r=qt(o);r&&n.push(r)}return n}function qt(t){if(t.role!=="system"){if(t.role==="user")return typeof t.content=="string"?{role:"user",parts:[{type:"text",content:t.content}]}:{role:"user",parts:t.content.map(e=>{var n,o,r,a,s,i,u,d;switch(e.type){case"text":return{type:"text",content:e.text};case"image":{const p=e.image;return p instanceof URL?{type:"uri",modality:"image",mime_type:(n=e.mediaType)!=null?n:null,uri:p.toString()}:typeof p=="string"?p.startsWith("http://")||p.startsWith("https://")?{type:"uri",modality:"image",mime_type:(o=e.mediaType)!=null?o:null,uri:p}:{type:"blob",modality:"image",mime_type:(r=e.mediaType)!=null?r:null,content:p}:{type:"blob",modality:"image",mime_type:(a=e.mediaType)!=null?a:null,content:St(p)}}case"file":{const p=e.data,c=(()=>{if(typeof p=="object"&&p!==null&&!(p instanceof URL)&&!(p instanceof Uint8Array)&&!(p instanceof ArrayBuffer)&&"type"in p)switch(p.type){case"data":return p.data;case"url":return p.url;case"text":return p.text;default:return""}return p})();return c instanceof URL?{type:"uri",modality:j(e.mediaType),mime_type:(s=e.mediaType)!=null?s:null,uri:c.toString()}:typeof c=="string"?c.startsWith("http://")||c.startsWith("https://")?{type:"uri",modality:j(e.mediaType),mime_type:(i=e.mediaType)!=null?i:null,uri:c}:{type:"blob",modality:j(e.mediaType),mime_type:(u=e.mediaType)!=null?u:null,content:c}:{type:"blob",modality:j(e.mediaType),mime_type:(d=e.mediaType)!=null?d:null,content:St(c)}}default:return{type:String(e.type)}}})};if(t.role==="assistant")return typeof t.content=="string"?{role:"assistant",parts:[{type:"text",content:t.content}]}:{role:"assistant",parts:t.content.map(e=>{var n,o;switch(e.type){case"text":return{type:"text",content:e.text};case"reasoning":return{type:"reasoning",content:e.text};case"tool-call":return{type:"tool_call",id:(n=e.toolCallId)!=null?n:null,name:e.toolName,arguments:e.input};case"tool-result":{const r=e.output;let a;return r&&(r.type==="text"||r.type==="error-text"||r.type==="json"||r.type==="error-json"?a=r.value:r.type==="execution-denied"?a={denied:!0,reason:r.reason}:a=r),{type:"tool_call_response",id:(o=e.toolCallId)!=null?o:null,response:a}}default:return{type:String(e.type)}}})};if(t.role==="tool")return{role:"tool",parts:t.content.map(e=>{var n;if(e.type==="tool-result"){const o=e.output;let r;return o&&(o.type==="text"||o.type==="error-text"||o.type==="json"||o.type==="error-json"?r=o.value:o.type==="execution-denied"?r={denied:!0,reason:o.reason}:r=o),{type:"tool_call_response",id:(n=e.toolCallId)!=null?n:null,response:r}}return{type:String(e.type)}})}}}function Nt({text:t,reasoning:e,toolCalls:n,files:o,finishReason:r}){const a=[];if(e)for(const s of e)"text"in s&&s.text&&a.push({type:"reasoning",content:s.text});if(t!=null&&t.length>0&&a.push({type:"text",content:t}),n)for(const s of n)a.push({type:"tool_call",id:s.toolCallId,name:s.toolName,arguments:s.input});if(o)for(const s of o)a.push({type:"blob",modality:j(s.mediaType),mime_type:s.mediaType,content:s.base64});return[{role:"assistant",parts:a,finish_reason:Pt(r)}]}function $t({objectText:t,finishReason:e}){return[{role:"assistant",parts:[{type:"text",content:t}],finish_reason:Pt(e)}]}function Pt(t){var e;return(e={stop:"stop",length:"length","content-filter":"content_filter","tool-calls":"tool_call",error:"error",other:"stop",unknown:"stop"}[t])!=null?e:t}function U(t,e){e instanceof Error?(t.recordException({name:e.name,message:e.message,stack:e.stack}),t.setStatus({code:_t.ERROR,message:e.message})):t.setStatus({code:_t.ERROR})}function Je(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function lt(t){if(!Array.isArray(t))return t;const e=new Set(t.filter(Je).map(o=>typeof o));if(e.size!==1)return;const[n]=e;return n==="string"?t.filter(o=>typeof o=="string"):n==="number"?t.filter(o=>typeof o=="number"):t.filter(o=>typeof o=="boolean")}function Le(t){const e={};for(const[n,o]of Object.entries(t??{})){if(o==null)continue;const r=lt(o);r!=null&&(e[n]=r)}return e}function Ue(t){return t?.isEnabled!==!1}function h(t,e){if(!Ue(t))return{};const n={};for(const[o,r]of Object.entries(e)){if(r==null)continue;if(typeof r=="object"&&"input"in r&&typeof r.input=="function"){if(t?.recordInputs===!1)continue;const s=r.input();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}if(typeof r=="object"&&"output"in r&&typeof r.output=="function"){if(t?.recordOutputs===!1)continue;const s=r.output();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}const a=lt(r);a!=null&&(n[o]=a)}return n}var Fe={usage:!1,providerMetadata:!1,embedding:!1,reranking:!1,runtimeContext:!1,headers:!1,toolChoice:!1,schema:!1};function Ke(t){var e,n,o,r,a,s,i,u;return{...Fe,usage:(e=t.usage)!=null?e:!1,providerMetadata:(n=t.providerMetadata)!=null?n:!1,embedding:(o=t.embedding)!=null?o:!1,reranking:(r=t.reranking)!=null?r:!1,runtimeContext:(a=t.runtimeContext)!=null?a:!1,headers:(s=t.headers)!=null?s:!1,toolChoice:(i=t.toolChoice)!=null?i:!1,schema:(u=t.schema)!=null?u:!1}}function Be(t){const e={};for(const[n,o]of Object.entries(t??{}))Dt(e,`ai.settings.context.${n}`,o);return e}function Dt(t,e,n){if(n!=null){if(Array.isArray(n)||typeof n!="object"){t[e]=n;return}for(const[o,r]of Object.entries(n))Dt(t,`${e}.${o}`,r)}}function ut(t){return Object.fromEntries(Object.entries(t??{}).filter(([,e])=>e!=null).map(([e,n])=>[`ai.request.headers.${e}`,n]))}function V(t){var e,n,o;return{"ai.usage.inputTokenDetails.noCacheTokens":(e=t.inputTokenDetails)==null?void 0:e.noCacheTokens,"ai.usage.outputTokenDetails.textTokens":(n=t.outputTokenDetails)==null?void 0:n.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(o=t.outputTokenDetails)==null?void 0:o.reasoningTokens}}function S(t,e,n){const o={};for(const[r,a]of Object.entries(n))!e[r]||a==null||Object.assign(o,h(t,a));return o}function pt(t){return t==null?void 0:t/1e3}function ze(t){var e;return{"gen_ai.client.operation.duration":pt(t.responseTimeMs),"gen_ai.client.operation.time_to_first_chunk":pt(t.timeToFirstOutputMs),"gen_ai.client.operation.time_per_output_chunk":pt((e=t.timeBetweenOutputChunksMs)==null?void 0:e.avg)}}var Qe=class{constructor(t={}){this.callStates=new Map;var e;this.tracer=(e=t.tracer)!=null?e:v.getTracer("gen_ai"),this.supplementalAttributes=Ke(t),this.enrichSpan=t.enrichSpan}getCallState(t){return this.callStates.get(t)}cleanupCallState(t){this.callStates.delete(t)}getSpanAttributes({attributes:t,spanType:e,operationId:n,callId:o,runtimeContext:r}){var a;let s;try{s=(a=this.enrichSpan)==null?void 0:a.call(this,{spanType:e,operationId:n,callId:o,runtimeContext:r})}catch{s=void 0}return{...Le(s),...t}}executeTool({callId:t,toolCallId:e,execute:n}){var o;const r=(o=this.getCallState(t))==null?void 0:o.toolSpans.get(e);return r==null?n():T.with(r.context,n)}executeLanguageModelCall({callId:t,execute:e}){var n;const o=this.getCallState(t),r=(n=o?.inferenceContext)!=null?n:o?.stepContext;return r==null?e():T.with(r,e)}onStart(t){if(t.operationId==="ai.embed"||t.operationId==="ai.embedMany"){this.onEmbedOperationStart(t);return}if(t.operationId==="ai.rerank"){this.onRerankOperationStart(t);return}if(t.operationId==="ai.generateObject"||t.operationId==="ai.streamObject"){this.onObjectOperationStart(t);return}this.onGenerateStart(t)}onGenerateStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,stopSequences:t.stopSequences,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=t.runtimeContext,i=S(n,this.supplementalAttributes,{runtimeContext:Be(s),headers:ut(t.headers)}),u=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.stop_sequences":t.stopSequences,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.instructions?{input:()=>JSON.stringify(jt(t.instructions))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:void 0,messages:t.messages}))},...i}),d=`${a} ${t.modelId}`,p=this.tracer.startSpan(d,{attributes:this.getSpanAttributes({attributes:u,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:s}),kind:x.INTERNAL}),c=v.setSpan(T.active(),p);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:p,rootContext:c,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:s,baseSupplementalAttributes:i})}onObjectOperationStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=S(n,this.supplementalAttributes,{headers:ut(t.headers)}),i=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.system?{input:()=>JSON.stringify(jt(t.system))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:t.prompt,messages:t.messages}))},...s,...S(n,this.supplementalAttributes,{schema:{"ai.schema":t.schema?{input:()=>JSON.stringify(t.schema)}:void 0,"ai.schema.name":t.schemaName,"ai.schema.description":t.schemaDescription,"ai.settings.output":t.output}})}),u=`${a} ${t.modelId}`,d=this.tracer.startSpan(u,{attributes:this.getSpanAttributes({attributes:i,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.INTERNAL}),p=v.setSpan(T.active(),d);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:d,rootContext:p,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:s})}onObjectStepStart(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan||!n.rootContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>t.promptMessages?JSON.stringify(We(t.promptMessages)):void 0},...n.baseSupplementalAttributes}),s=`chat ${t.modelId}`;n.inferenceSpan=this.tracer.startSpan(s,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.rootContext),n.inferenceContext=v.setSpan(n.rootContext,n.inferenceSpan)}onObjectStepEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.inferenceSpan)return;const{telemetry:o}=n;n.inferenceSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.response.id,"gen_ai.response.model":t.response.modelId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>{try{return JSON.stringify($t({objectText:t.objectText,finishReason:t.finishReason}))}catch{return t.objectText}}},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.inferenceSpan.end(),n.inferenceSpan=void 0,n.inferenceContext=void 0}onEmbedOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=t.value,a=t.operationId==="ai.embedMany",s=h(e,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{embedding:a?{"ai.values":{input:()=>r.map(p=>JSON.stringify(p))}}:{"ai.value":{input:()=>JSON.stringify(r)}}})}),i=`embeddings ${t.modelId}`,u=this.tracer.startSpan(i,{attributes:this.getSpanAttributes({attributes:s,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),d=v.setSpan(T.active(),u);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:u,rootContext:d,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onStepStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e;e.runtimeContext=t.runtimeContext;const o=h(n,{"gen_ai.operation.name":"agent_step",...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{toolChoice:{"ai.prompt.toolChoice":{input:()=>t.stepToolChoice!=null?JSON.stringify(t.stepToolChoice):void 0}}})});e.stepSpan=this.tracer.startSpan(`step ${t.steps.length+1}`,{attributes:this.getSpanAttributes({attributes:o,spanType:"step",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.rootContext),e.stepContext=v.setSpan(e.rootContext,e.stepSpan)}onLanguageModelCallStart(t){var e;const n=this.getCallState(t.callId);if(!n?.stepContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.stop_sequences":n.settings.stopSequences,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>{const s=vt({prompt:void 0,messages:t.messages});return s.length>0?JSON.stringify(s):void 0}},"gen_ai.tool.definitions":{input:()=>t.tools?JSON.stringify(t.tools):void 0}});n.inferenceSpan=this.tracer.startSpan(`chat ${t.modelId}`,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.stepContext),n.inferenceContext=v.setSpan(n.stepContext,n.inferenceSpan)}onLanguageModelCallEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.inferenceSpan)return;const{telemetry:r}=o;o.inferenceSpan.setAttributes(h(r,{...ze(t.performance),"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.responseId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>JSON.stringify(Nt({text:t.content.filter(a=>a.type==="text").map(a=>a.text).join("")||void 0,reasoning:t.content.filter(a=>a.type==="reasoning"),toolCalls:t.content.filter(a=>a.type==="tool-call"),files:t.content.filter(a=>a.type==="file").map(a=>a.file),finishReason:t.finishReason}))},...S(r,this.supplementalAttributes,{usage:V(t.usage)})})),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0}onToolExecutionStart(t){const e=this.getCallState(t.callId);if(!e?.stepContext)return;const{telemetry:n}=e,{toolCall:o}=t,r=h(n,{"gen_ai.operation.name":"execute_tool","gen_ai.tool.name":o.toolName,"gen_ai.tool.call.id":o.toolCallId,"gen_ai.tool.type":"function","gen_ai.tool.call.arguments":{input:()=>JSON.stringify(o.input)}}),a=`execute_tool ${o.toolName}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"tool",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.stepContext),i=v.setSpan(e.stepContext,s);e.toolSpans.set(o.toolCallId,{span:s,context:i})}onToolExecutionEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.toolSpans.get(t.toolCall.toolCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e,{toolOutput:a}=t;if(o.setAttributes(h(r,{"gen_ai.execute_tool.duration":pt(t.toolExecutionMs)})),a.type==="tool-result")try{o.setAttributes(h(r,{"gen_ai.tool.call.result":{output:()=>JSON.stringify(a.output)}}))}catch{}else U(o,a.error);o.end(),e.toolSpans.delete(t.toolCall.toolCallId)}onStepEnd(t){const e=this.getCallState(t.callId);if(!e?.stepSpan)return;const{telemetry:n}=e;e.stepSpan.setAttributes(S(n,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})),e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0}onStepFinish(t){this.onStepEnd(t)}onEnd(t){const e=this.getCallState(t.callId);if(e?.rootSpan){if(e.operationId==="ai.embed"||e.operationId==="ai.embedMany"){this.onEmbedOperationEnd(t);return}if(e.operationId==="ai.rerank"){this.onRerankOperationEnd(t);return}if(e.operationId==="ai.generateObject"||e.operationId==="ai.streamObject"){this.onObjectOperationEnd(t);return}this.onGenerateEnd(t)}}onGenerateEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.rootSpan)return;const{telemetry:r}=o;o.rootSpan.setAttributes(h(r,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>{var a;return JSON.stringify(Nt({text:(a=t.text)!=null?a:void 0,reasoning:t.finalStep.reasoning,toolCalls:t.toolCalls,files:t.files,finishReason:t.finishReason}))}},...S(r,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.finalStep.providerMetadata?JSON.stringify(t.finalStep.providerMetadata):void 0},usage:V(t.usage)})})),o.rootSpan.end(),this.cleanupCallState(t.callId)}onObjectOperationEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan)return;const{telemetry:o}=n;n.rootSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>t.object!=null?JSON.stringify($t({objectText:JSON.stringify(t.object),finishReason:t.finishReason})):void 0},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedOperationEnd(t){const e=this.getCallState(t.callId);if(!e?.rootSpan)return;const{telemetry:n}=e,o=e.operationId==="ai.embedMany";e.rootSpan.setAttributes(h(n,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(n,this.supplementalAttributes,{embedding:o?{"ai.embeddings":{output:()=>t.embedding.map(r=>JSON.stringify(r))}}:{"ai.embedding":{output:()=>JSON.stringify(t.embedding)}}})})),e.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{embedding:{"ai.values":{input:()=>t.values.map(u=>JSON.stringify(u))}}})}),a=`embeddings ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"embedding",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.embedSpans.set(t.embedCallId,{span:s,context:i})}onEmbedEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.embedSpans.get(t.embedCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e;o.setAttributes(h(r,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(r,this.supplementalAttributes,{embedding:{"ai.embeddings":{output:()=>t.embeddings.map(a=>JSON.stringify(a))}}})})),o.end(),e.embedSpans.delete(t.embedCallId)}onRerankOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=h(e,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${t.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),i=v.setSpan(T.active(),s);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:s,rootContext:i,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onRerankOperationEnd(t){const e=this.getCallState(t.callId);e?.rootSpan&&(e.rootSpan.end(),this.cleanupCallState(t.callId))}onRerankStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"reranking",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.rerankSpan={span:s,context:i}}onRerankEnd(t){const e=this.getCallState(t.callId);if(!e?.rerankSpan)return;const{span:n}=e.rerankSpan,{telemetry:o}=e;n.setAttributes(S(o,this.supplementalAttributes,{reranking:{"ai.ranking.type":t.documentsType,"ai.ranking":{output:()=>t.ranking.map(r=>JSON.stringify(r))}}})),n.end(),e.rerankSpan=void 0}onAbort(t){const e=this.getCallState(t.callId);if(e?.rootSpan){for(const{span:n}of e.toolSpans.values())n.end();e.toolSpans.clear(),e.inferenceSpan&&(e.inferenceSpan.end(),e.inferenceSpan=void 0,e.inferenceContext=void 0),e.stepSpan&&(e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0);for(const{span:n}of e.embedSpans.values())n.end();e.embedSpans.clear(),e.rerankSpan&&(e.rerankSpan.span.end(),e.rerankSpan=void 0),e.rootSpan.end(),this.cleanupCallState(t.callId)}}onError(t){var e;const n=t;if(!n?.callId)return;const o=this.getCallState(n.callId);if(!o?.rootSpan)return;const r=(e=n.error)!=null?e:t;for(const{span:a}of o.toolSpans.values())U(a,r),a.end();o.toolSpans.clear(),o.inferenceSpan&&(U(o.inferenceSpan,r),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0),o.stepSpan&&(U(o.stepSpan,r),o.stepSpan.end(),o.stepSpan=void 0,o.stepContext=void 0);for(const{span:a}of o.embedSpans.values())U(a,r),a.end();o.embedSpans.clear(),o.rerankSpan&&(U(o.rerankSpan.span,r),o.rerankSpan.span.end(),o.rerankSpan=void 0),U(o.rootSpan,r),o.rootSpan.end(),this.cleanupCallState(n.callId)}};function Ge(t){return pe({messages:t,emptyMessages:"remove",reasoning:"none",toolCalls:`before-last-${Gt}-messages`})}function He(t){return typeof t=="object"&&t!==null&&"role"in t&&"content"in t}function Ve(t){return Array.isArray(t)&&t.every(He)}function Ye(t,{conversationId:e,getModel:n}){let o=0;const r=()=>{const a=n?.();return a?{model_provider:a.provider,model_id:a.modelId}:{}};return{onStepStart:()=>{o+=1},onToolExecutionStart:a=>{t("com.redocly.aiChat.toolCallStarted",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,...r()}])},onToolExecutionEnd:a=>{const s=a.toolOutput.type==="tool-error";t("com.redocly.aiChat.toolCallFinished",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,success:!s,duration_ms:a.toolExecutionMs,...r(),...s&&{error:a.toolOutput.error instanceof Error?a.toolOutput.error.message:String(a.toolOutput.error)}}])},onStart:a=>{o=0,t("com.redocly.aiChat.conversationStarted",[{...rt("conversation",e,"ai"),model_provider:"provider"in a?a.provider:"unknown",model_id:"modelId"in a?a.modelId:"unknown"}])},onEnd:a=>{if(!("steps"in a))return;const s=a.usage;t("com.redocly.aiChat.conversationFinished",[{...rt("conversation",e,"ai"),model_provider:a.model.provider,model_id:a.model.modelId,success:!0,step_count:a.steps.length,finish_reason:a.finishReason,input_tokens:s.inputTokens,output_tokens:s.outputTokens,total_tokens:s.totalTokens}])}}}function Xe(t,e){const n=()=>v.getSpan(T.active())?T.active():e;return{startSpan:(o,r,a)=>t.startSpan(o,r,a??e),startActiveSpan:((o,r,a,s)=>{if(typeof r=="function")return t.startActiveSpan(o,{},n(),r);if(typeof a=="function")return t.startActiveSpan(o,r,n(),a);if(s)return t.startActiveSpan(o,r,a,s);throw new Error("withParentContext: invalid startActiveSpan invocation")})}}const Ze=`You are a helpful assistant that can generate titles for conversations.
|
|
2
2
|
|
|
3
3
|
## Rules
|
|
4
4
|
- Titles should be at most 30 characters.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o,a as m,d as y}from"./redocly-openapi-docs.min.ai-chat-mappers-
|
|
1
|
+
import{c as o,a as m,d as y}from"./redocly-openapi-docs.min.ai-chat-mappers-C7hnSHO0.js";import{a as h,b as r,c as d}from"./redocly-openapi-docs.min.ai-message-parts.schema-C7fjQhYX.js";import{a as c,e as a,b as g}from"./redocly-openapi-docs.min.indexes-Bp4ld5gB.js";const u={orderBy:[c(r.createdAt),c(r.indexWithinInsertBatch)],with:{parts:{orderBy:[c(h.index)]}}};class b{constructor(t){this.sqliteDB=t}sqliteDB;async findAll(){return await this.initialize(),(await this.db.query.aiChats.findMany({with:{messages:u}})).map(o)}async findRecentChatsPage(t){await this.initialize();const i=t.limit+1,s=await this.db.query.aiChats.findMany({orderBy:(l,{desc:w})=>w(l.updatedAt),limit:i,offset:t.offset}),e=s.slice(0,t.limit),n=s.length>t.limit,f=t.offset+e.length;return{items:e.map(l=>{const w={...l,messages:[]};return o(w)}),hasMore:n,nextOffset:f}}async findOne(t){await this.initialize();const i=await this.db.query.aiChats.findFirst({where:a(d.id,t),with:{messages:u}});return i&&o(i)}async upsert(t){await this.initialize();const i=m(t);await this.db.query.aiChats.findFirst({where:a(d.id,i.id),columns:{id:!0}})?await this.db.update(d).set(i).where(a(d.id,i.id)):await this.db.insert(d).values(i);for(let s=0;s<t.messages.length;s++)await this.upsertMessageRowAndParts(t.id,s,t.messages[s])}async remove(t){await this.initialize(),await this.db.delete(d).where(a(d.id,t))}async upsertMessageRowAndParts(t,i,s){const e=await this.db.query.aiMessages.findFirst({where:g(a(r.aiChatId,t),a(r.uiId,s.id))}),n=y(t,i,s,e?.id);e?await this.db.update(r).set({...n,indexWithinInsertBatch:e.indexWithinInsertBatch}).where(a(r.id,e.id)):await this.db.insert(r).values(n),await this.db.delete(h).where(a(h.aiMessageId,n.id)),n.parts.length>0&&await this.db.insert(h).values(n.parts)}get db(){return this.sqliteDB.db}async initialize(){await this.sqliteDB.initialize()}}export{b as AiChatSqliteDBStorage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as q,a as l,j as r,f as ae,B as _,r as h,e as ct,O as dt,af as ut,D as pt,h as ft,m as ye,n as ht,aA as xt,aB as gt,ae as E,ab as U,d as mt}from"./redocly-openapi-docs.min.standalone-
|
|
1
|
+
import{g as q,a as l,j as r,f as ae,B as _,r as h,e as ct,O as dt,af as ut,D as pt,h as ft,m as ye,n as ht,aA as xt,aB as gt,ae as E,ab as U,d as mt}from"./redocly-openapi-docs.min.standalone-D8BmO4OO.js";import{f as J,z as we,B as vt,e as yt,q as je,m as wt,n as jt,C as bt,E as Ct,F as se,G as le,H as kt,J as It,S as $,K as ce,L as Tt,M as _t,N as be,O as St,P as At,R as de,Q as Ot,U as ue,V as Ce,W as ke,t as Ie,X as pe,Y as L,Z as Bt,_ as Vt,$ as zt,a0 as Mt,a1 as Ft}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";import{B as $t,C as Rt,E as Et,F as Lt,G as Nt,H as Dt,I as Pt,J as Te,K as k,L as _e,M as Ut,N as Ht,O as H,P as Gt,Q as Kt,R as Wt,S as V,U as Zt,V as N}from"./redocly-openapi-docs.min.useAiChatQueries-Dj8qddY3.js";function Q(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Yt=45e3,qt=e=>r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M12 7.5H4V8.5H12V7.5Z"})}),Jt=l(qt).attrs({"data-component-name":"icons/SubtractIcon/SubtractIcon"})`
|
|
2
2
|
path {
|
|
3
3
|
fill: ${({color:e})=>q(e)};
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aK as ve}from"./redocly-openapi-docs.min.index-Zp6s2A4z.js";import{h as We}from"./redocly-openapi-docs.min.history.schema-DzAAX18S.js";import{s as Ve}from"./redocly-openapi-docs.min.step-context.schema-DEgzIgw0.js";import{b as z,c as G,a as H}from"./redocly-openapi-docs.min.ai-message-parts.schema-C7fjQhYX.js";import{c as f,T as m,i as h,g as W,s as n,o as Ue,n as Ye,f as Ge,h as He,j as Ze,k as Xe,m as et,p as tt,q as st,l as it,r as rt,t as nt,u as at,v as ot,w as lt,x as ct,y as ht,z as ut,e as qe,A as dt,b as ce,d as ft,a as mt,C as O,S as y,V as A,B as E,D as he,E as R,F as V,G as Z,H as ue,P as Ce,I as pt,J as de,K as fe,L as gt,W as Ne,M as Qe,N as yt,O as X,Q as Te}from"./redocly-openapi-docs.min.indexes-Bp4ld5gB.js";class bt{static[f]="ConsoleLogWriter";write(e){console.log(e)}}class wt{static[f]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new bt}logQuery(e,t){const s=t.map(r=>{try{return JSON.stringify(r)}catch{return String(r)}}),i=s.length?` -- params: [${s.join(", ")}]`:"";this.writer.write(`Query: ${e}${i}`)}}class St{static[f]="NoopLogger";logQuery(){}}const Le=Symbol.for("drizzle:PgInlineForeignKeys"),xe=Symbol.for("drizzle:EnableRLS");class $t extends m{static[f]="PgTable";static Symbol=Object.assign({},m.Symbol,{InlineForeignKeys:Le,EnableRLS:xe});[Le]=[];[xe]=!1;[m.Symbol.ExtraConfigBuilder]=void 0;[m.Symbol.ExtraConfigColumns]={}}class vt{static[f]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new qt(e,this.columns,this.name)}}class qt{constructor(e,t,s){this.table=e,this.columns=t,this.name=s}static[f]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[$t.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}class Oe{constructor(e,t,s){this.sourceTable=e,this.referencedTable=t,this.relationName=s,this.referencedTableName=t[m.Symbol.Name]}static[f]="Relation";referencedTableName;fieldName}class Be{constructor(e,t){this.table=e,this.config=t}static[f]="Relations"}class D extends Oe{constructor(e,t,s,i){super(e,t,s?.relationName),this.config=s,this.isNullable=i}static[f]="One";withFieldName(e){const t=new D(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class ne extends Oe{constructor(e,t,s){super(e,t,s?.relationName),this.config=s}static[f]="Many";withFieldName(e){const t=new ne(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function Ct(){return{and:ce,between:dt,eq:qe,exists:ut,gt:ht,gte:ct,ilike:lt,inArray:ot,isNull:at,isNotNull:nt,like:rt,lt:it,lte:st,ne:tt,not:et,notBetween:Xe,notExists:Ze,notLike:He,notIlike:Ge,notInArray:Ye,or:Ue,sql:n}}function Nt(){return{sql:n,asc:mt,desc:ft}}function Qt(l,e){Object.keys(l).length===1&&"default"in l&&!h(l.default,m)&&(l=l.default);const t={},s={},i={};for(const[r,a]of Object.entries(l))if(h(a,m)){const o=W(a),c=s[o];t[o]=r,i[r]={tsName:r,dbName:a[m.Symbol.Name],schema:a[m.Symbol.Schema],columns:a[m.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(const d of Object.values(a[m.Symbol.Columns]))d.primary&&i[r].primaryKey.push(d);const u=a[m.Symbol.ExtraConfigBuilder]?.(a[m.Symbol.ExtraConfigColumns]);if(u)for(const d of Object.values(u))h(d,vt)&&i[r].primaryKey.push(...d.columns)}else if(h(a,Be)){const o=W(a.table),c=t[o],u=a.config(e(a.table));let d;for(const[g,N]of Object.entries(u))if(c){const Q=i[c];Q.relations[g]=N}else o in s||(s[o]={relations:{},primaryKey:d}),s[o].relations[g]=N}return{tables:i,tableNamesMap:t}}function me(l,e){return new Be(l,t=>Object.fromEntries(Object.entries(e(t)).map(([s,i])=>[s,i.withFieldName(s)])))}function Tt(l){return function(e,t){return new D(l,e,t,t?.fields.reduce((s,i)=>s&&i.notNull,!0)??!1)}}function Lt(l){return function(e,t){return new ne(l,e,t)}}function xt(l,e,t){if(h(t,D)&&t.config)return{fields:t.config.fields,references:t.config.references};const s=e[W(t.referencedTable)];if(!s)throw new Error(`Table "${t.referencedTable[m.Symbol.Name]}" not found in schema`);const i=l[s];if(!i)throw new Error(`Table "${s}" not found in schema`);const r=t.sourceTable,a=e[W(r)];if(!a)throw new Error(`Table "${r[m.Symbol.Name]}" not found in schema`);const o=[];for(const c of Object.values(i.relations))(t.relationName&&t!==c&&c.relationName===t.relationName||!t.relationName&&c.referencedTable===t.sourceTable)&&o.push(c);if(o.length>1)throw t.relationName?new Error(`There are multiple relations with name "${t.relationName}" in table "${s}"`):new Error(`There are multiple relations between "${s}" and "${t.sourceTable[m.Symbol.Name]}". Please specify relation name`);if(o[0]&&h(o[0],D)&&o[0].config)return{fields:o[0].config.references,references:o[0].config.fields};throw new Error(`There is not enough information to infer relation "${a}.${t.fieldName}"`)}function Ot(l){return{one:Tt(l),many:Lt(l)}}function pe(l,e,t,s,i=r=>r){const r={};for(const[a,o]of s.entries())if(o.isJson){const c=e.relations[o.tsKey],u=t[a],d=typeof u=="string"?JSON.parse(u):u;r[o.tsKey]=h(c,D)?d&&pe(l,l[o.relationTableTsKey],d,o.selection,i):d.map(g=>pe(l,l[o.relationTableTsKey],g,o.selection,i))}else{const c=i(t[a]),u=o.field;let d;h(u,O)?d=u:h(u,y)?d=u.decoder:d=u.sql.decoder,r[o.tsKey]=c===null?null:d.mapFromDriverValue(c)}return r}class ee{constructor(e){this.table=e}static[f]="ColumnAliasProxyHandler";get(e,t){return t==="table"?this.table:e[t]}}class ge{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[f]="TableAliasProxyHandler";get(e,t){if(t===m.Symbol.IsAlias)return!0;if(t===m.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===m.Symbol.OriginalName)return this.alias;if(t===A)return{...e[A],name:this.alias,isAlias:!0};if(t===m.Symbol.Columns){const i=e[m.Symbol.Columns];if(!i)return i;const r={};return Object.keys(i).map(a=>{r[a]=new Proxy(i[a],new ee(new Proxy(e,this)))}),r}const s=e[t];return h(s,O)?new Proxy(s,new ee(new Proxy(e,this))):s}}function ye(l,e){return new Proxy(l,new ge(e,!1))}function P(l,e){return new Proxy(l,new ee(new Proxy(l.table,new ge(e,!1))))}function je(l,e){return new y.Aliased(te(l.sql,e),l.fieldAlias)}function te(l,e){return n.join(l.queryChunks.map(t=>h(t,O)?P(t,e):h(t,y)?te(t,e):h(t,y.Aliased)?je(t,e):t))}class T{static[f]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===A)return{...e[A],selectedFields:new Proxy(e[A].selectedFields,this)};if(typeof t=="symbol")return e[t];const s=(h(e,E)?e._.selectedFields:h(e,he)?e[A].selectedFields:e)[t];if(h(s,y.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!s.isSelectionField)return s.sql;const i=s.clone();return i.isSelectionField=!0,i}if(h(s,y)){if(this.config.sqlBehavior==="sql")return s;throw new Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return h(s,O)?this.config.alias?new Proxy(s,new ee(new Proxy(s.table,new ge(this.config.alias,this.config.replaceOriginalName??!1)))):s:typeof s!="object"||s===null?s:new Proxy(s,new T(this.config))}}class K{static[f]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}function k(l){return h(l,R)?[`${l[m.Symbol.BaseName]}`]:h(l,E)?l._.usedTables??[]:h(l,y)?l.usedTables??[]:[]}class Ae extends K{constructor(e,t,s,i){super(),this.table=e,this.session=t,this.dialect=s,this.config={table:e,withList:i}}static[f]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){const t=e[0](new Proxy(this.config.table[m.Symbol.Columns],new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),s=Array.isArray(t)?t:[t];this.config.orderBy=s}else{const t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[R.Symbol.Columns]){return this.config.returning=V(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:k(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}function Bt(l){return(l.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function jt(l){return(l.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,s)=>{const i=s===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`;return e+i},"")}function At(l){return l}class Rt{static[f]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Bt:e==="camelCase"?jt:At}getColumnCasing(e){if(!e.keyAsName)return e.name;const t=e.table[m.Symbol.Schema]??"public",s=e.table[m.Symbol.OriginalName],i=`${t}.${s}.${e.name}`;return this.cache[i]||this.cacheTable(e.table),this.cache[i]}cacheTable(e){const t=e[m.Symbol.Schema]??"public",s=e[m.Symbol.OriginalName],i=`${t}.${s}`;if(!this.cachedTables[i]){for(const r of Object.values(e[m.Symbol.Columns])){const a=`${i}.${r.name}`;this.cache[a]=this.convert(r.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class be extends Error{static[f]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class I extends Error{constructor(e,t,s){super(`Failed query: ${e}
|
|
2
2
|
params: ${t}`),this.query=e,this.params=t,this.cause=s,Error.captureStackTrace(this,I),s&&(this.cause=s)}}class Mt extends be{static[f]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class we extends he{static[f]="SQLiteViewBase"}class se{static[f]="SQLiteDialect";casing;constructor(e){this.casing=new Rt(e?.casing)}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;const t=[n`with `];for(const[s,i]of e.entries())t.push(n`${n.identifier(i._.alias)} as (${i._.sql})`),s<e.length-1&&t.push(n`, `);return t.push(n` `),n.join(t)}buildDeleteQuery({table:e,where:t,returning:s,withList:i,limit:r,orderBy:a}){const o=this.buildWithCTE(i),c=s?n` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,u=t?n` where ${t}`:void 0,d=this.buildOrderBy(a),g=this.buildLimit(r);return n`${o}delete from ${e}${u}${c}${d}${g}`}buildUpdateSet(e,t){const s=e[m.Symbol.Columns],i=Object.keys(s).filter(a=>t[a]!==void 0||s[a]?.onUpdateFn!==void 0),r=i.length;return n.join(i.flatMap((a,o)=>{const c=s[a],u=c.onUpdateFn?.(),d=t[a]??(h(u,y)?u:n.param(u,c)),g=n`${n.identifier(this.casing.getColumnCasing(c))} = ${d}`;return o<r-1?[g,n.raw(", ")]:[g]}))}buildUpdateQuery({table:e,set:t,where:s,returning:i,withList:r,joins:a,from:o,limit:c,orderBy:u}){const d=this.buildWithCTE(r),g=this.buildUpdateSet(e,t),N=o&&n.join([n.raw(" from "),this.buildFromTable(o)]),Q=this.buildJoins(a),q=i?n` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,w=s?n` where ${s}`:void 0,$=this.buildOrderBy(u),S=this.buildLimit(c);return n`${d}update ${e} set ${g}${N}${Q}${w}${q}${$}${S}`}buildSelection(e,{isSingleTable:t=!1}={}){const s=e.length,i=e.flatMap(({field:r},a)=>{const o=[];if(h(r,y.Aliased)&&r.isSelectionField)o.push(n.identifier(r.fieldAlias));else if(h(r,y.Aliased)||h(r,y)){const c=h(r,y.Aliased)?r.sql:r;t?o.push(new y(c.queryChunks.map(u=>h(u,O)?n.identifier(this.casing.getColumnCasing(u)):u))):o.push(c),h(r,y.Aliased)&&o.push(n` as ${n.identifier(r.fieldAlias)}`)}else if(h(r,O)){const c=r.table[m.Symbol.Name];r.columnType==="SQLiteNumericBigInt"?t?o.push(n`cast(${n.identifier(this.casing.getColumnCasing(r))} as text)`):o.push(n`cast(${n.identifier(c)}.${n.identifier(this.casing.getColumnCasing(r))} as text)`):t?o.push(n.identifier(this.casing.getColumnCasing(r))):o.push(n`${n.identifier(c)}.${n.identifier(this.casing.getColumnCasing(r))}`)}else if(h(r,E)){const c=Object.entries(r._.selectedFields);if(c.length===1){const u=c[0][1],d=h(u,y)?u.decoder:h(u,O)?{mapFromDriverValue:g=>u.mapFromDriverValue(g)}:u.sql.decoder;d&&(r._.sql.decoder=d)}o.push(r)}return a<s-1&&o.push(n`, `),o});return n.join(i)}buildJoins(e){if(!e||e.length===0)return;const t=[];if(e)for(const[s,i]of e.entries()){s===0&&t.push(n` `);const r=i.table,a=i.on?n` on ${i.on}`:void 0;if(h(r,R)){const o=r[R.Symbol.Name],c=r[R.Symbol.Schema],u=r[R.Symbol.OriginalName],d=o===u?void 0:i.alias;t.push(n`${n.raw(i.joinType)} join ${c?n`${n.identifier(c)}.`:void 0}${n.identifier(u)}${d&&n` ${n.identifier(d)}`}${a}`)}else t.push(n`${n.raw(i.joinType)} join ${r}${a}`);s<e.length-1&&t.push(n` `)}return n.join(t)}buildLimit(e){return typeof e=="object"||typeof e=="number"&&e>=0?n` limit ${e}`:void 0}buildOrderBy(e){const t=[];if(e)for(const[s,i]of e.entries())t.push(i),s<e.length-1&&t.push(n`, `);return t.length>0?n` order by ${n.join(t)}`:void 0}buildFromTable(e){return h(e,m)&&e[m.Symbol.IsAlias]?n`${n`${n.identifier(e[m.Symbol.Schema]??"")}.`.if(e[m.Symbol.Schema])}${n.identifier(e[m.Symbol.OriginalName])} ${n.identifier(e[m.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:s,where:i,having:r,table:a,joins:o,orderBy:c,groupBy:u,limit:d,offset:g,distinct:N,setOperators:Q}){const q=s??V(t);for(const B of q)if(h(B.field,O)&&Z(B.field.table)!==(h(a,E)?a._.alias:h(a,we)?a[A].name:h(a,y)?void 0:Z(a))&&!(j=>o?.some(({alias:Y})=>Y===(j[m.Symbol.IsAlias]?Z(j):j[m.Symbol.BaseName])))(B.field.table)){const j=Z(B.field.table);throw new Error(`Your "${B.path.join("->")}" field references a column "${j}"."${B.field.name}", but the table "${j}" is not part of the query! Did you forget to join it?`)}const w=!o||o.length===0,$=this.buildWithCTE(e),S=N?n` distinct`:void 0,L=this.buildSelection(q,{isSingleTable:w}),v=this.buildFromTable(a),C=this.buildJoins(o),M=i?n` where ${i}`:void 0,x=r?n` having ${r}`:void 0,p=[];if(u)for(const[B,j]of u.entries())p.push(j),B<u.length-1&&p.push(n`, `);const b=p.length>0?n` group by ${n.join(p)}`:void 0,_=this.buildOrderBy(c),U=this.buildLimit(d),le=g?n` offset ${g}`:void 0,J=n`${$}select${S} ${L} from ${v}${C}${M}${b}${x}${_}${U}${le}`;return Q.length>0?this.buildSetOperations(J,Q):J}buildSetOperations(e,t){const[s,...i]=t;if(!s)throw new Error("Cannot pass undefined values to any set operator");return i.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:s}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:s}),i)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:s,rightSelect:i,limit:r,orderBy:a,offset:o}}){const c=n`${e.getSQL()} `,u=n`${i.getSQL()}`;let d;if(a&&a.length>0){const q=[];for(const w of a)if(h(w,ue))q.push(n.identifier(w.name));else if(h(w,y)){for(let $=0;$<w.queryChunks.length;$++){const S=w.queryChunks[$];h(S,ue)&&(w.queryChunks[$]=n.identifier(this.casing.getColumnCasing(S)))}q.push(n`${w}`)}else q.push(n`${w}`);d=n` order by ${n.join(q,n`, `)}`}const g=typeof r=="object"||typeof r=="number"&&r>=0?n` limit ${r}`:void 0,N=n.raw(`${t} ${s?"all ":""}`),Q=o?n` offset ${o}`:void 0;return n`${c}${N}${u}${d}${g}${Q}`}buildInsertQuery({table:e,values:t,onConflict:s,returning:i,withList:r,select:a}){const o=[],c=e[m.Symbol.Columns],u=Object.entries(c).filter(([w,$])=>!$.shouldDisableInsert()),d=u.map(([,w])=>n.identifier(this.casing.getColumnCasing(w)));if(a){const w=t;h(w,y)?o.push(w):o.push(w.getSQL())}else{const w=t;o.push(n.raw("values "));for(const[$,S]of w.entries()){const L=[];for(const[v,C]of u){const M=S[v];if(M===void 0||h(M,Ce)&&M.value===void 0){let x;if(C.default!==null&&C.default!==void 0)x=h(C.default,y)?C.default:n.param(C.default,C);else if(C.defaultFn!==void 0){const p=C.defaultFn();x=h(p,y)?p:n.param(p,C)}else if(!C.default&&C.onUpdateFn!==void 0){const p=C.onUpdateFn();x=h(p,y)?p:n.param(p,C)}else x=n`null`;L.push(x)}else L.push(M)}o.push(L),$<w.length-1&&o.push(n`, `)}}const g=this.buildWithCTE(r),N=n.join(o),Q=i?n` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,q=s?.length?n.join(s):void 0;return n`${g}insert into ${e} ${d} ${N}${q}${Q}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:s,table:i,tableConfig:r,queryConfig:a,tableAlias:o,nestedQueryRelation:c,joinOn:u}){let d=[],g,N,Q=[],q;const w=[];if(a===!0)d=Object.entries(r.columns).map(([S,L])=>({dbKey:L.name,tsKey:S,field:P(L,o),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{const S=Object.fromEntries(Object.entries(r.columns).map(([p,b])=>[p,P(b,o)]));if(a.where){const p=typeof a.where=="function"?a.where(S,Ct()):a.where;q=p&&te(p,o)}const L=[];let v=[];if(a.columns){let p=!1;for(const[b,_]of Object.entries(a.columns))_!==void 0&&b in r.columns&&(!p&&_===!0&&(p=!0),v.push(b));v.length>0&&(v=p?v.filter(b=>a.columns?.[b]===!0):Object.keys(r.columns).filter(b=>!v.includes(b)))}else v=Object.keys(r.columns);for(const p of v){const b=r.columns[p];L.push({tsKey:p,value:b})}let C=[];a.with&&(C=Object.entries(a.with).filter(p=>!!p[1]).map(([p,b])=>({tsKey:p,queryConfig:b,relation:r.relations[p]})));let M;if(a.extras){M=typeof a.extras=="function"?a.extras(S,{sql:n}):a.extras;for(const[p,b]of Object.entries(M))L.push({tsKey:p,value:je(b,o)})}for(const{tsKey:p,value:b}of L)d.push({dbKey:h(b,y.Aliased)?b.fieldAlias:r.columns[p].name,tsKey:p,field:h(b,O)?P(b,o):b,relationTableTsKey:void 0,isJson:!1,selection:[]});let x=typeof a.orderBy=="function"?a.orderBy(S,Nt()):a.orderBy??[];Array.isArray(x)||(x=[x]),Q=x.map(p=>h(p,O)?P(p,o):te(p,o)),g=a.limit,N=a.offset;for(const{tsKey:p,queryConfig:b,relation:_}of C){const U=xt(t,s,_),le=W(_.referencedTable),J=s[le],B=`${o}_${p}`,j=ce(...U.fields.map((Je,ze)=>qe(P(U.references[ze],B),P(Je,o)))),Y=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:s,table:e[J],tableConfig:t[J],queryConfig:h(_,D)?b===!0?{limit:1}:{...b,limit:1}:b,tableAlias:B,joinOn:j,nestedQueryRelation:_}),De=n`(${Y.sql})`.as(p);d.push({dbKey:p,tsKey:p,field:De,relationTableTsKey:J,isJson:!0,selection:Y.selection})}}if(d.length===0)throw new be({message:`No fields selected for table "${r.tsName}" ("${o}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let $;if(q=ce(u,q),c){let S=n`json_array(${n.join(d.map(({field:v})=>h(v,ue)?n.identifier(this.casing.getColumnCasing(v)):h(v,y.Aliased)?v.sql:v),n`, `)})`;h(c,ne)&&(S=n`coalesce(json_group_array(${S}), json_array())`);const L=[{dbKey:"data",tsKey:"data",field:S.as("data"),isJson:!0,relationTableTsKey:r.tsName,selection:d}];g!==void 0||N!==void 0||Q.length>0?($=this.buildSelectQuery({table:ye(i,o),fields:{},fieldsFlat:[{path:[],field:n.raw("*")}],where:q,limit:g,offset:N,orderBy:Q,setOperators:[]}),q=void 0,g=void 0,N=void 0,Q=void 0):$=ye(i,o),$=this.buildSelectQuery({table:h($,R)?$:new E($,{},o),fields:{},fieldsFlat:L.map(({field:v})=>({path:[],field:h(v,O)?P(v,o):v})),joins:w,where:q,limit:g,offset:N,orderBy:Q,setOperators:[]})}else $=this.buildSelectQuery({table:ye(i,o),fields:{},fieldsFlat:d.map(({field:S})=>({path:[],field:h(S,O)?P(S,o):S})),joins:w,where:q,limit:g,offset:N,orderBy:Q,setOperators:[]});return{tableTsKey:r.tsName,sql:$,selection:d}}}class _t extends se{static[f]="SQLiteSyncDialect";migrate(e,t,s){const i=s===void 0||typeof s=="string"?"__drizzle_migrations":s.migrationsTable??"__drizzle_migrations",r=n`
|
|
3
3
|
CREATE TABLE IF NOT EXISTS ${n.identifier(i)} (
|
|
4
4
|
id SERIAL PRIMARY KEY,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as i}from"./redocly-openapi-docs.min.standalone-
|
|
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 +1,2 @@
|
|
|
1
|
-
import{
|
|
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
2
|
`))}}}export{w as ExternalResolver};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aK as t}from"./redocly-openapi-docs.min.index-
|
|
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 +1 @@
|
|
|
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-
|
|
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};
|