@aiquants/chat 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/README.md +218 -26
- package/dist/{ChatAnswerHtml-3K6G6UKC.js → ChatAnswerHtml-UNWOOMYK.js} +1 -1
- package/dist/{chunk-7CEL735H.js → chunk-44WLZMPZ.js} +1 -1
- package/dist/chunk-5MWD2PSY.js +1 -0
- package/dist/chunk-GSCTWGZT.js +1 -0
- package/dist/chunk-HC7HXC2K.js +1 -0
- package/dist/{chunk-PLNRET3Z.js → chunk-KNPMHSTQ.js} +1 -1
- package/dist/{chunk-7KWWXSGA.js → chunk-NWDLT2AZ.js} +1 -1
- package/dist/client.cjs +2 -2
- package/dist/client.d.cts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.js +1 -1
- package/dist/{httpTransport-BAaKwioS.d.ts → httpTransport-Cgj10OUn.d.ts} +1 -1
- package/dist/{httpTransport-D_JJABMq.d.cts → httpTransport-o7MkPUuY.d.cts} +1 -1
- package/dist/{index-iHWm67aF.d.cts → index-g-wjju1F.d.cts} +9518 -1785
- package/dist/{index-iHWm67aF.d.ts → index-g-wjju1F.d.ts} +9518 -1785
- package/dist/protocol.cjs +1 -1
- package/dist/protocol.d.cts +1 -1
- package/dist/protocol.d.ts +1 -1
- package/dist/protocol.js +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.d.cts +210 -24
- package/dist/react.d.ts +210 -24
- package/dist/react.js +2 -2
- package/dist/{runStream-DLhaMZSu.d.ts → runStream-Wn5F3RKe.d.ts} +3 -1
- package/dist/{runStream-Dd5YdJoh.d.cts → runStream-jp4rlkIw.d.cts} +3 -1
- package/dist/testing.cjs +6 -6
- package/dist/testing.d.cts +55 -4
- package/dist/testing.d.ts +55 -4
- package/dist/testing.js +6 -6
- package/dist/{transport-Clvkp7mW.d.ts → transport-CYd9hh42.d.cts} +23 -1
- package/dist/{transport-5ExGY_ti.d.cts → transport-DlhniH4C.d.ts} +23 -1
- package/package.json +5 -5
- package/dist/chunk-4NR4KSV6.js +0 -1
- package/dist/chunk-TQNSD6RJ.js +0 -1
- package/dist/chunk-WGNEBS4H.js +0 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { C as ChatFetch } from "./httpTransport-
|
|
3
|
-
import { d as ChatSingleEndpoint, b as ChatExchangeParams } from "./transport-
|
|
4
|
-
import {
|
|
2
|
+
import { C as ChatFetch } from "./httpTransport-Cgj10OUn.js";
|
|
3
|
+
import { d as ChatSingleEndpoint, b as ChatExchangeParams } from "./transport-DlhniH4C.js";
|
|
4
|
+
import { $ as ChatExchangeEndpointName, a0 as ChatExchangeShapeName, aV as chatExchangeShapeSchemas, k as CHAT_EXCHANGES, aT as chatErrorBodySchema, ad as ChatQueryName, bg as chatQuerySchemas, K as ChatBusinessCodeName, V as ChatEventName, as as RESYNC_REQUIRED_EVENT, U as ChatEventData } from "./index-g-wjju1F.js";
|
|
5
5
|
type ShapeInput<Name> = Name extends ChatExchangeShapeName ? z.input<(typeof chatExchangeShapeSchemas)[Name]> : null;
|
|
6
6
|
type ShapeOutput<Name> = Name extends ChatExchangeShapeName ? z.output<(typeof chatExchangeShapeSchemas)[Name]> : null;
|
|
7
7
|
type ChatScenarioAnswer<Endpoint extends ChatExchangeEndpointName> = ShapeInput<(typeof CHAT_EXCHANGES)[Endpoint]["answer"]>;
|
|
@@ -47,4 +47,55 @@ type ChatScenarioFetch = {
|
|
|
47
47
|
type ChatScenarioRefusalFields = Omit<z.input<typeof chatErrorBodySchema>, "error_code">;
|
|
48
48
|
declare const chatScenarioRefusal: (name: ChatBusinessCodeName, fields: ChatScenarioRefusalFields) => ChatScenarioRefusedReply;
|
|
49
49
|
declare const createChatScenarioFetch: (options: ChatScenarioFetchOptions) => ChatScenarioFetch;
|
|
50
|
-
|
|
50
|
+
declare const CHAT_SCENARIO_STREAM_MAX_WAIT_MS = 2147483647;
|
|
51
|
+
type ChatScenarioTimers = {
|
|
52
|
+
setTimer(handler: () => void, delayMs: number): unknown;
|
|
53
|
+
clearTimer(handle: unknown): void;
|
|
54
|
+
};
|
|
55
|
+
type ChatScenarioEventName = Exclude<ChatEventName, typeof RESYNC_REQUIRED_EVENT>;
|
|
56
|
+
type ChatScenarioStreamStep = {
|
|
57
|
+
[Name in ChatScenarioEventName]: {
|
|
58
|
+
readonly kind: "event";
|
|
59
|
+
readonly afterMs: number;
|
|
60
|
+
readonly event: Name;
|
|
61
|
+
readonly data: ChatEventData<Name>;
|
|
62
|
+
};
|
|
63
|
+
}[ChatScenarioEventName] | {
|
|
64
|
+
readonly kind: "resync";
|
|
65
|
+
readonly afterMs: number;
|
|
66
|
+
} | {
|
|
67
|
+
readonly kind: "drop";
|
|
68
|
+
readonly afterMs: number;
|
|
69
|
+
} | {
|
|
70
|
+
readonly kind: "gate";
|
|
71
|
+
readonly gate: string;
|
|
72
|
+
};
|
|
73
|
+
type ChatScenarioHeartbeat = {
|
|
74
|
+
readonly event: string;
|
|
75
|
+
readonly data: string;
|
|
76
|
+
readonly everyMs: number;
|
|
77
|
+
};
|
|
78
|
+
type ChatScenarioRunStreamsOptions = {
|
|
79
|
+
readonly baseUrl: string;
|
|
80
|
+
readonly cursorParam: string;
|
|
81
|
+
readonly idBaseMs: number;
|
|
82
|
+
readonly heartbeat: ChatScenarioHeartbeat;
|
|
83
|
+
readonly timers: ChatScenarioTimers;
|
|
84
|
+
readonly runs: Readonly<Record<string, readonly ChatScenarioStreamStep[]>>;
|
|
85
|
+
};
|
|
86
|
+
type ChatScenarioEventSource = {
|
|
87
|
+
readonly readyState: number;
|
|
88
|
+
readonly url: string;
|
|
89
|
+
addEventListener(type: string, listener: (event: Event) => void): void;
|
|
90
|
+
close(): void;
|
|
91
|
+
};
|
|
92
|
+
type ChatScenarioRunStreams = {
|
|
93
|
+
readonly createEventSource: (url: string, init: {
|
|
94
|
+
readonly withCredentials: boolean;
|
|
95
|
+
}) => ChatScenarioEventSource;
|
|
96
|
+
readonly release: (runUid: string, gate: string) => void;
|
|
97
|
+
readonly endOf: (runUid: string) => ChatEventName | null;
|
|
98
|
+
readonly breaches: () => readonly string[];
|
|
99
|
+
};
|
|
100
|
+
declare const createChatScenarioRunStreams: (options: ChatScenarioRunStreamsOptions) => ChatScenarioRunStreams;
|
|
101
|
+
export { CHAT_SCENARIO_STREAM_MAX_WAIT_MS, type ChatScenarioAnswer, type ChatScenarioEventSource, type ChatScenarioFetch, type ChatScenarioFetchOptions, type ChatScenarioHeartbeat, type ChatScenarioHold, type ChatScenarioRefusalFields, type ChatScenarioRefusedReply, type ChatScenarioReply, type ChatScenarioRequest, type ChatScenarioRunStreams, type ChatScenarioRunStreamsOptions, type ChatScenarioStep, type ChatScenarioStreamStep, type ChatScenarioTimers, type ChatUnstampWrite, chatScenarioRefusal, createChatScenarioFetch, createChatScenarioRunStreams };
|
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)
|
|
1
|
+
import{a as Oe,b as Ae,c as xe,d as Ne,e as Te,f as _e,g as je,h as Be}from"./chunk-HC7HXC2K.js";import{a as m,c as ke,d as F,f as G,h as ve}from"./chunk-NWDLT2AZ.js";import{a as c,c as J}from"./chunk-KNPMHSTQ.js";import{C as Q,D as ye,E as fe,J as ge,K as me,L as Ee,M as we,O as be,a as he,b as ne,cb as Z,db as Se,eb as Re,f as x,fb as Ce,gb as P,hb as $e,l as pe}from"./chunk-GSCTWGZT.js";import{z as oe}from"zod";var Pe="application/json",ae="multipart/form-data",Me=Object.freeze({body:void 0,filenames:Object.freeze([])}),dt=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+/,ct=/[\t ]*;[\t ]*(?:([!#$%&'*+.^_`|~0-9A-Za-z-]+)=([!#$%&'*+.^_`|~0-9A-Za-z-]+|"(?:[\t !#-\x5b\x5d-~\x80-\xff]|\\[\t -~\x80-\xff])*"))?/y,lt=/^[0-9A-Za-z'()+_,./:=? -]{0,69}[0-9A-Za-z'()+_,./:=?-]$/,ut=/^([!#$%&'*+.^_`|~0-9A-Za-z-]+):[\t ]*([^\r\n]*?)[\t ]*$/,ht=Object.freeze(["content-disposition","content-type"]),pt=/^form-data/i,yt=/[\t ]*;[\t ]*([!#$%&'*+.^_`|~0-9A-Za-z-]+)="([^"]*)"/y,ft=Object.freeze(["name","filename"]),Ue=Object.freeze(Object.keys(x.attachments.upload)),Y=new TextEncoder,W=Y.encode(`\r
|
|
2
|
+
`),Le=Y.encode(`\r
|
|
3
3
|
\r
|
|
4
|
-
`),
|
|
5
|
-
`)){let i=
|
|
6
|
-
`);if(!
|
|
7
|
-
--${t}`),a=[],i=r.length;for(;;){let s=xe(e,o,i);if(s===-1)throw n("whose part is not closed by a delimiter");a.push(st(e.subarray(i,s),n));let d=s+o.length;if(_(e,F,d)){i=d+F.length;continue}if(!_(e,X,d))throw n('whose delimiter is followed by neither CRLF nor "--"');if(e.length!==d+X.length+F.length||!_(e,F,d+X.length))throw n("that does not end with CRLF right after its close delimiter");return a}},dt=e=>{if(!et.test(e))return null;let t=new RegExp(tt.source,"y");t.lastIndex=9;let n=new Map;for(;t.lastIndex<e.length;){let o=t.exec(e);if(o===null)return null;let[,a,i]=o,s=a.toLowerCase();if(!nt.includes(s)||n.has(s))return null;n.set(s,i)}let r=n.get("name");return r===void 0?null:{name:r,filename:n.get("filename")??null}},ct=(e,t)=>{let n={},r=[],o=-1;for(let a of e){let i=a.headers.get("content-disposition");if(i===void 0)throw t("with a part without a Content-Disposition");let s=dt(i);if(s===null)throw t(`with the Content-Disposition ${c(i)}`);let d=ke.indexOf(s.name);if(d===-1)throw t(`with a part named ${c(s.name)}`);if(d<=o)throw t(d===o?`with the part ${c(s.name)} twice`:`with the part ${c(s.name)} after the part ${c(ke[o])}`);o=d;let l=a.headers.get("content-type");if(s.filename===null){if(l!==void 0)throw t(`with the text part ${c(s.name)} holding a Content-Type`);try{n[s.name]=Ae(a.content)}catch{throw t(`with the text part ${c(s.name)} that is not UTF-8`)}}else{if(l===void 0)throw t(`with the file part ${c(s.name)} without a Content-Type`);n[s.name]=new Blob([a.content],{type:l}),r.push(s.filename)}}return{body:n,filenames:r}},Ne=async(e,t,n,r)=>{if(N[e].body===null){if(n!=null)throw new TypeError(`${r}: init.body must be undefined or null (${e} takes no body), got ${c(n)}`);if(t!==null)throw new RangeError(`${r}: init.headers must hold no Content-Type (${e} takes no body), got ${c(t)}`);return Oe}let o=t===null?null:rt(t);if(!Object.hasOwn(R.paths.upload,e)){if(o?.essence!==Ce)throw new RangeError(`${r}: the Content-Type of init.headers must declare ${Ce} (${e} takes a JSON body), got ${c(t)}`);if(typeof n!="string")throw new TypeError(`${r}: init.body must be a JSON text (${e} takes a JSON body), got ${c(n)}`);try{return{body:JSON.parse(n),filenames:Oe.filenames}}catch{throw new RangeError(`${r}: init.body must be a JSON text (${e} takes a JSON body), got a text that is not JSON`)}}let a=ot(o);if(a===null)throw new RangeError(`${r}: the Content-Type of init.headers must declare ${K} with one boundary of RFC 2046 and no other parameter (${e} takes a multipart body), got ${c(t)}`);if(fe(n)===null)throw new TypeError(`${r}: init.body must be a Blob (${e} takes a multipart body), got ${c(n)}`);let i=s=>new RangeError(`${r}: init.body must be a ${K} body of the upload's fields (RFC 7578), got a body ${s}`);return ct(it(await at(n),a,i),i)};var lt=Object.freeze(Object.keys(N).map(e=>{let t=Object.hasOwn(R.paths.upload,e),{method:n,path:r}=t?R.paths.upload[e]:R.paths.json[e];return Object.freeze({endpoint:e,upload:t,method:n,segments:Object.freeze(`${R.paths.base}${r}`.split("/"))})})),ht=/^\{([a-z_]+)\}$/,je=e=>e instanceof V.ZodEffects?je(e.innerType()):e.shape,ut=new Map(Object.entries(le).map(([e,t])=>[e,Object.freeze(Object.entries(je(t)).filter(([,n])=>(n instanceof V.ZodOptional?n.unwrap():n)instanceof V.ZodBoolean).map(([n])=>n))])),Te=(e,t)=>{C("object",e,t,"init");let{method:n,headers:r,body:o,signal:a}=e;return Object.freeze({method:n,headers:r,body:o,signal:a})},pt=(e,t,n)=>{for(let r of lt){let o=r.upload?n.uploadBaseUrl:n.jsonBaseUrl;if(r.method!==e||!t.startsWith(o))continue;let a=t.slice(o.length),i=a.indexOf("?"),s=i===-1?a:a.slice(0,i),d=s.split("/");if(d.length!==r.segments.length)continue;let l={};if(r.segments.every((O,j)=>{let k=d[j],P=ht.exec(O);return P===null?k===O:(l[P[1]]=k,k!=="")}))return{route:r,written:l,path:s,search:i===-1?"":a.slice(i)}}return null},ft=(e,t,n,r)=>{let o=[n.jsonBaseUrl,n.uploadBaseUrl].filter(i=>t.startsWith(i)).sort((i,s)=>s.length-i.length)[0],a=o===void 0?"a URL under neither base":`the URL ${c(t.slice(o.length))} after a base`;return new RangeError(`${r}: url and init.method must name an endpoint of the exchanges' table under the base of its channel, got ${c(e)} and ${a}`)},yt=(e,t,n,r)=>{let o=()=>new RangeError(`${r}: url must hold the path of ${e.endpoint} as the contract writes it, each parameter one segment encoded by encodeURIComponent, got the path ${c(n)}`),a={};for(let[s,d]of Object.entries(t))try{a[s]=decodeURIComponent(d)}catch{throw o()}if((e.upload?de(e.endpoint,a).path:ie(e.endpoint,a).path)!==n)throw o();return a},gt=(e,t,n)=>{let r=ut.get(e);if(r===void 0){if(t!=="")throw new RangeError(`${n}: url must hold no query (${e} takes no query), got the query ${c(t)}`);return}let o=new Map;for(let[a,i]of new URLSearchParams(t.slice(1))){if(o.has(a))throw new RangeError(`${n}: url must hold each field of the query of ${e} once, got the field ${c(a)} twice`);o.set(a,r.includes(a)&&(i==="true"||i==="false")?i==="true":i)}return Object.fromEntries(o)},mt=(e,t,n,r)=>{if(!Ee(e))return t;let o=be(t),a=t.slice(o.length);return Re(a)?`${o}${Se(n,a,r,"unstampWrite")}`:t},_e=async(e,t,n,r,o)=>{C("string",e,o,"url");let a=t.method===void 0?"GET":t.method;if(typeof a!="string")throw new TypeError(`${o}: init.method must be undefined or a string, got ${c(a)}`);let i=mt(a,e,r,o),s=pt(a,i,n);if(s===null)throw ft(a,i,n,o);let{route:d,search:l}=s,g=yt(d,s.written,s.path,o),O;try{O=new Headers(t.headers)}catch(L){throw new TypeError(`${o}: init.headers must be headers the browser's Headers reads, got ${c(t.headers)}`,{cause:L})}let j=gt(d.endpoint,l,o),{body:k,filenames:P}=await Ne(d.endpoint,O.get("content-type"),t.body,o),q=ge(d.endpoint,{params:Object.keys(g).length===0?void 0:g,query:j,body:k,signal:t.signal===null?void 0:t.signal},o);if(q.query!==null&&he(d.endpoint,q.query)!==l)throw new RangeError(`${o}: url must hold the query of ${d.endpoint} as chatQueryString writes it of the query its schema read, got the query ${c(l)}`);if(d.upload){let L=P[0],Y=me(q.body.file_name);if(L!==Y)throw new RangeError(`${o}: init.body must carry the filename of its file part as the transport writes it of file_name (${c(Y)}), got ${c(L)}`)}return q};var v="createChatScenarioFetch",B="ChatScenarioFetch.fetch",ee="ChatScenarioFetch.plan",wt="ChatScenarioFetch.hold",ve="ChatScenarioHold.settle",Et="ChatScenarioFetch.assertDone",W="chatScenarioRefusal",Be=Object.freeze(Object.keys(N)),bt=Object.freeze(Object.keys(R.business_codes)),ze=se({answered:["kind","answer"],refused:["kind","status","body"],unreached:["kind"],response:["kind","response"]}),Rt=Object.freeze(Object.keys(ze)),te=Object.freeze(Object.keys(D.innerType().shape).filter(e=>e!=="error_code")),St="application/json",Pe=65536,Ct=1,qe=400,Le=599,Ot=Z({Blob:{attributes:["size","type"],operations:["slice"],statics:[]},AbortSignal:{attributes:["aborted","reason"],operations:["addEventListener","removeEventListener"],statics:["any"]}}),kt=Object.freeze({kind:"unreached"}),$t=Object.freeze({waiting:"has taken no request",answering:"awaits the answer its response function makes",settled:"has answered its request",stopped:"was stopped"}),Ie=e=>Object.getOwnPropertyDescriptor(AbortSignal.prototype,e).get,re=e=>Reflect.apply(Ie("aborted"),e,[])===!0,oe=e=>Reflect.apply(Ie("reason"),e,[]),Ue=e=>{let t=Function.prototype.bind(void 0);return Reflect.apply(AbortSignal.prototype.addEventListener,e,["abort",t]),Reflect.apply(AbortSignal.prototype.removeEventListener,e,["abort",t]),e},xt=e=>{let t=Ue(AbortSignal.any([Ue(e)]));if(re(t))throw new TypeError("the runtime's AbortSignal.any made an aborted signal from a signal that is not aborted");return t},Me=e=>typeof e=="object"&&e!==null||typeof e=="function",Fe=(e,t)=>{let n=!1,r=a=>{n||(n=!0,t.rejected(a))},o=a=>{if(n)return;n=!0;let i;try{i=Me(a)?Reflect.get(a,"then"):void 0}catch(d){t.rejected(d);return}if(typeof i!="function"){t.fulfilled(a);return}let s=i;Promise.resolve().then(()=>Fe((d,l)=>Reflect.apply(s,a,[d,l]),t))};try{e(o,r)}catch(a){r(a)}},He=(e,t,n)=>{let r=a=>new RangeError(`${t}: ${n} must be a value JSON.stringify writes as a JSON text, got ${c(e)}`,a===void 0?void 0:{cause:a}),o;try{o=JSON.stringify(e)}catch(a){throw r(a)}if(o===void 0)throw r();return o},At=(e,t,n,r)=>{let o=N[e];if(o.answer===null){if(t!==null)throw new TypeError(`${n}: ${r} must be null (${e} answers no body), got ${c(t)}`);return Object.freeze({kind:"json",status:o.status,text:null})}let a=He(t,n,r);return J(ue[o.answer],JSON.parse(a),n,r,`the answer of ${e} (${o.answer}) when written as a JSON text and read back`),Object.freeze({kind:"json",status:o.status,text:a})},Nt=(e,t,n,r)=>{let o=pe(e,n,`${r}.status`,`an integer from ${qe} to ${Le}`,s=>Number.isInteger(s)&&s>=qe&&s<=Le),a=He(t,n,`${r}.body`),i=ce(J(D,JSON.parse(a),n,`${r}.body`,"a failed answer's body when written as a JSON text and read back"));if(i!==null){let s=R.business_codes[i.name].http_status;if(o!==s)throw new RangeError(`${n}: ${r}.status must be ${s}, the status of the business code ${i.name} its body carries, got ${o}`)}return Object.freeze({kind:"json",status:o,text:a})},ne=(e,t,n,r)=>{C("object",t,n,r);let o=t,a=M(Rt,o.kind,n,`${r}.kind`),i=ze[a],s=Object.keys(o).find(d=>!i.includes(d));if(s!==void 0)throw new RangeError(`${n}: ${r} must hold only the fields of a reply of the kind ${a} (${i.join(", ")}), got the key ${c(s)}`);switch(a){case"answered":return At(e,o.answer,n,`${r}.answer`);case"refused":{let{status:d,body:l}=o;return Nt(d,l,n,r)}case"unreached":return kt;case"response":{let{response:d}=o;return C("function",d,n,`${r}.response`),Object.freeze({kind:"response",make:d})}}},jt=e=>{let t=new TextEncoder().encode(e),n=()=>{},r;return{stream:new ReadableStream({type:"bytes",start:i=>{r=i;for(let s=0;s<t.byteLength;s+=Pe)i.enqueue(t.slice(s,s+Pe))},pull:i=>{n(),i.close(),i.byobRequest?.respond(0)},cancel:()=>{n()}},{highWaterMark:Ct}),tie:i=>{let s=()=>{n(),r.error(oe(i))};n=()=>Reflect.apply(AbortSignal.prototype.removeEventListener,i,["abort",s]),Reflect.apply(AbortSignal.prototype.addEventListener,i,["abort",s])}}},Tt=e=>{if(e.text===null)return{response:new Response(null,{status:e.status}),tie:null};let t=jt(e.text);return{response:new Response(t.stream,{status:e.status,headers:{"Content-Type":St}}),tie:t.tie}},_t=e=>{let t=Reflect.get(Blob.prototype,"arrayBuffer"),n=Reflect.get(globalThis,"FileReader");if(typeof t!="function"&&typeof n!="function")throw new TypeError(`${e}: the runtime's Blob.prototype.arrayBuffer or its FileReader must be a function, as an upload's file is read by one of them, got ${c(t)} and ${c(n)}`)},vt=e=>e instanceof Error?`${e.name}: ${e.message}`:c(e),on=(e,t)=>{let n=M(bt,e,W,"name");C("object",t,W,"fields");let r=t,o=Object.keys(r).find(g=>!te.includes(g));if(o!==void 0)throw new RangeError(`${W}: fields must hold only the fields of a failed answer's body besides error_code (${te.join(", ")}), got the key ${c(o)}`);let{number:a,http_status:i}=R.business_codes[n],s=[["error_code",a],...te.map(g=>[g,r[g]])],d=Object.fromEntries(s.filter(([,g])=>g!==void 0)),l=J(D,d,W,"fields",`the fields of a failed answer's body of ${n}`);return Z({kind:"refused",status:i,body:l})},an=e=>{C("object",e,v,"options");let{jsonBaseUrl:t,uploadBaseUrl:n,unstampWrite:r}=e;G(t,v,"jsonBaseUrl"),G(n,v,"uploadBaseUrl"),C("function",r,v,"unstampWrite"),we(v,Ot),_t(v);let o=Object.freeze({jsonBaseUrl:t,uploadBaseUrl:n}),a=new Map,i=[],s=[],d=[],l=new Set,g=new Set,O=Promise.resolve(),j=()=>{for(let w of g)w()},k=w=>{let u=a.get(w);if(u!==void 0)return u;let y=[];return a.set(w,y),y};return Object.freeze({fetch:(w,u)=>{let y;try{y=Te(u,B)}catch(m){return d.push(m),Promise.reject(m)}let E=ye(y.signal)?y.signal:null;if(E!==null&&re(E))return Promise.reject(oe(E));let f=null;if(E!==null)try{f=xt(E)}catch(m){let x=new TypeError(`${B}: init.signal must be a signal the runtime's AbortSignal.any can make the request's own signal from, got ${c(E)}`,{cause:m});return d.push(x),Promise.reject(x)}return new Promise((m,x)=>{let b=!1,$=null,U={};l.add(U);let T=p=>{b||(b=!0,l.delete(U),$!==null&&$.phase.kind==="answering"&&($.phase={kind:"settled"}),f!==null&&(g.delete(S),Reflect.apply(AbortSignal.prototype.removeEventListener,f,["abort",Q])),p())},z=p=>{S(),d.push(p),T(()=>x(p))},Q=()=>{$!==null&&($.phase={kind:"stopped"}),T(()=>x(oe(E)))},S=()=>(!b&&E!==null&&re(E)&&Q(),b),De=p=>{let h;try{h=Tt(p)}catch(I){z(I);return}T(()=>{f!==null&&h.tie!==null&&h.tie(f),m(h.response)})},Je=p=>{let h,I;try{h=Reflect.apply(p,void 0,[]),I=Me(h)?Reflect.get(h,"then"):void 0}catch(A){z(A);return}if(typeof I!="function"){T(()=>m(h));return}let Ye=I;Fe((A,Qe)=>Reflect.apply(Ye,h,[A,Qe]),{fulfilled:A=>{S(),T(()=>m(A))},rejected:A=>{S()||z(A)}})},ae=p=>{if(!S())switch(p.kind){case"unreached":T(()=>x(new TypeError(`${B}: the request was not reached, as its step planned`)));return;case"json":De(p);return;case"response":Je(p.make)}},We=p=>{let h=a.get(p.endpoint)?.shift();if(h===void 0)throw new RangeError(`${B}: a request of ${p.endpoint} must find a step the scenario planned for it, got one when none is left`);if(s.push(p),h.kind==="hold"){$=h.state,l.delete(U),h.state.phase={kind:"arrived",answer:ae},h.state.arrive(p);return}ae(h.kind==="reply"?h.reply:ne(p.endpoint,Reflect.apply(h.step,void 0,[p]),B,h.field))};f!==null&&(g.add(S),Reflect.apply(AbortSignal.prototype.addEventListener,f,["abort",Q])),O=O.then(async()=>{if(S())return;let p;try{p=await _e(w,y,o,r,B)}catch(h){S()||z(h);return}if(!S())try{We(p)}catch(h){z(h)}})})},plan:(w,...u)=>{let y=M(Be,w,ee,"endpoint");if(u.length===0)throw new RangeError(`${ee}: steps must be one step or more, got none`);let E=u.map((f,m)=>Object.freeze(typeof f=="function"?{kind:"function",step:f,field:`steps[${m}](request)`}:{kind:"reply",reply:ne(y,f,ee,`steps[${m}]`)}));k(y).push(...E)},hold:w=>{let u=M(Be,w,wt,"endpoint"),y,E=new Promise(b=>{y=b}),f={endpoint:u,phase:{kind:"waiting"},arrive:y};i.push(f),k(u).push(Object.freeze({kind:"hold",state:f}));let m=()=>{j();let{phase:b}=f;if(b.kind!=="arrived")throw new TypeError(`${ve}: the held step of ${u} must hold a request it has neither answered nor stopped, got a step that ${$t[b.kind]}`);return b};return Object.freeze({arrived:E,settle:b=>{m();let $=ne(u,b,ve,"reply"),U=m();f.phase={kind:"answering"},U.answer($)}})},requests:()=>Object.freeze([...s]),assertDone:()=>{j();let w=[...l.size>0?[`requests still being read: ${l.size}`]:[],...d.map(u=>`the breach ${vt(u)}`),...[...a].filter(([,u])=>u.length>0).map(([u,y])=>`untaken steps of ${u}: ${y.length}`),...i.filter(u=>u.phase.kind==="arrived"||u.phase.kind==="answering").map(u=>`the held request of ${u.endpoint} neither answered nor stopped`)];if(w.length>0)throw new Error(`${Et}: the scenario must end with every request read, no breach, every step taken, and every held request answered or stopped, got ${w.join("; ")}`)}})};export{on as chatScenarioRefusal,an as createChatScenarioFetch};
|
|
4
|
+
`),re=Y.encode("--"),gt=e=>{let t=dt.exec(e);if(t===null)return null;let n=new RegExp(ct.source,"y");n.lastIndex=t[0].length;let r=[];for(;n.lastIndex<e.length;){let a=n.exec(e);if(a===null)return null;let[,o,i]=a;if(o!==void 0){let s=i;r.push([o.toLowerCase(),s.startsWith('"')?s.slice(1,-1).replace(/\\([\s\S])/g,"$1"):s])}}return{essence:t[0].toLowerCase(),parameters:r}},mt=e=>{if(e===null||e.essence!==ae||e.parameters.length!==1)return null;let[t,n]=e.parameters[0];return t==="boundary"&<.test(n)?n:null},Et=async e=>typeof Blob.prototype.arrayBuffer=="function"?new Uint8Array(await Reflect.apply(Blob.prototype.arrayBuffer,e,[])):await new Promise((t,n)=>{let r=new FileReader;r.addEventListener("load",()=>t(new Uint8Array(r.result))),r.addEventListener("error",()=>n(r.error)),r.readAsArrayBuffer(e)}),L=(e,t,n)=>n+t.length<=e.length&&t.every((r,a)=>e[n+a]===r),qe=(e,t,n)=>{let r=t[0];for(let a=e.indexOf(r,n);a!==-1;a=e.indexOf(r,a+1))if(L(e,t,a))return a;return-1},ze=e=>new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(e),wt=(e,t)=>{if(L(e,W,0))throw t("with a part without headers");let n=qe(e,Le,0);if(n===-1)throw t("with a part without a blank line after its headers");let r;try{r=ze(e.subarray(0,n))}catch{throw t("with headers that are not UTF-8")}let a=new Map;for(let o of r.split(`\r
|
|
5
|
+
`)){let i=ut.exec(o);if(i===null)throw t(`with the header line ${c(o)}`);let[,s,d]=i,p=s.toLowerCase();if(!ht.includes(p))throw t(`with the header ${c(s)} in a part`);if(a.has(p))throw t(`with the header ${c(s)} twice in a part`);a.set(p,d)}return{headers:a,content:e.subarray(n+Le.length)}},bt=(e,t,n)=>{let r=Y.encode(`--${t}\r
|
|
6
|
+
`);if(!L(e,r,0))throw n("that does not begin with the delimiter of its boundary and CRLF");let a=Y.encode(`\r
|
|
7
|
+
--${t}`),o=[],i=r.length;for(;;){let s=qe(e,a,i);if(s===-1)throw n("whose part is not closed by a delimiter");o.push(wt(e.subarray(i,s),n));let d=s+a.length;if(L(e,W,d)){i=d+W.length;continue}if(!L(e,re,d))throw n('whose delimiter is followed by neither CRLF nor "--"');if(e.length!==d+re.length+W.length||!L(e,W,d+re.length))throw n("that does not end with CRLF right after its close delimiter");return o}},St=e=>{if(!pt.test(e))return null;let t=new RegExp(yt.source,"y");t.lastIndex=9;let n=new Map;for(;t.lastIndex<e.length;){let a=t.exec(e);if(a===null)return null;let[,o,i]=a,s=o.toLowerCase();if(!ft.includes(s)||n.has(s))return null;n.set(s,i)}let r=n.get("name");return r===void 0?null:{name:r,filename:n.get("filename")??null}},Rt=(e,t)=>{let n={},r=[],a=-1;for(let o of e){let i=o.headers.get("content-disposition");if(i===void 0)throw t("with a part without a Content-Disposition");let s=St(i);if(s===null)throw t(`with the Content-Disposition ${c(i)}`);let d=Ue.indexOf(s.name);if(d===-1)throw t(`with a part named ${c(s.name)}`);if(d<=a)throw t(d===a?`with the part ${c(s.name)} twice`:`with the part ${c(s.name)} after the part ${c(Ue[a])}`);a=d;let p=o.headers.get("content-type");if(s.filename===null){if(p!==void 0)throw t(`with the text part ${c(s.name)} holding a Content-Type`);try{n[s.name]=ze(o.content)}catch{throw t(`with the text part ${c(s.name)} that is not UTF-8`)}}else{if(p===void 0)throw t(`with the file part ${c(s.name)} without a Content-Type`);n[s.name]=new Blob([o.content],{type:p}),r.push(s.filename)}}return{body:n,filenames:r}},Ie=async(e,t,n,r)=>{if(P[e].body===null){if(n!=null)throw new TypeError(`${r}: init.body must be undefined or null (${e} takes no body), got ${c(n)}`);if(t!==null)throw new RangeError(`${r}: init.headers must hold no Content-Type (${e} takes no body), got ${c(t)}`);return Me}let a=t===null?null:gt(t);if(!Object.hasOwn(x.paths.upload,e)){if(a?.essence!==Pe)throw new RangeError(`${r}: the Content-Type of init.headers must declare ${Pe} (${e} takes a JSON body), got ${c(t)}`);if(typeof n!="string")throw new TypeError(`${r}: init.body must be a JSON text (${e} takes a JSON body), got ${c(n)}`);try{return{body:JSON.parse(n),filenames:Me.filenames}}catch{throw new RangeError(`${r}: init.body must be a JSON text (${e} takes a JSON body), got a text that is not JSON`)}}let o=mt(a);if(o===null)throw new RangeError(`${r}: the Content-Type of init.headers must declare ${ae} with one boundary of RFC 2046 and no other parameter (${e} takes a multipart body), got ${c(t)}`);if(ve(n)===null)throw new TypeError(`${r}: init.body must be a Blob (${e} takes a multipart body), got ${c(n)}`);let i=s=>new RangeError(`${r}: init.body must be a ${ae} body of the upload's fields (RFC 7578), got a body ${s}`);return Rt(bt(await Et(n),o,i),i)};var Ct=Object.freeze(Object.keys(P).map(e=>{let t=Object.hasOwn(x.paths.upload,e),{method:n,path:r}=t?x.paths.upload[e]:x.paths.json[e];return Object.freeze({endpoint:e,upload:t,method:n,segments:Object.freeze(`${x.paths.base}${r}`.split("/"))})})),$t=/^\{([a-z_]+)\}$/,He=e=>e instanceof oe.ZodEffects?He(e.innerType()):e.shape,kt=new Map(Object.entries(Re).map(([e,t])=>[e,Object.freeze(Object.entries(He(t)).filter(([,n])=>(n instanceof oe.ZodOptional?n.unwrap():n)instanceof oe.ZodBoolean).map(([n])=>n))])),De=(e,t)=>{m("object",e,t,"init");let{method:n,headers:r,body:a,signal:o}=e;return Object.freeze({method:n,headers:r,body:a,signal:o})},vt=(e,t,n)=>{for(let r of Ct){let a=r.upload?n.uploadBaseUrl:n.jsonBaseUrl;if(r.method!==e||!t.startsWith(a))continue;let o=t.slice(a.length),i=o.indexOf("?"),s=i===-1?o:o.slice(0,i),d=s.split("/");if(d.length!==r.segments.length)continue;let p={};if(r.segments.every((k,O)=>{let N=d[O],$=$t.exec(k);return $===null?N===k:(p[$[1]]=N,N!=="")}))return{route:r,written:p,path:s,search:i===-1?"":o.slice(i)}}return null},Ot=(e,t,n,r)=>{let a=[n.jsonBaseUrl,n.uploadBaseUrl].filter(i=>t.startsWith(i)).sort((i,s)=>s.length-i.length)[0],o=a===void 0?"a URL under neither base":`the URL ${c(t.slice(a.length))} after a base`;return new RangeError(`${r}: url and init.method must name an endpoint of the exchanges' table under the base of its channel, got ${c(e)} and ${o}`)},At=(e,t,n,r)=>{let a=()=>new RangeError(`${r}: url must hold the path of ${e.endpoint} as the contract writes it, each parameter one segment encoded by encodeURIComponent, got the path ${c(n)}`),o={};for(let[s,d]of Object.entries(t))try{o[s]=decodeURIComponent(d)}catch{throw a()}if((e.upload?we(e.endpoint,o).path:Ee(e.endpoint,o).path)!==n)throw a();return o},xt=(e,t,n)=>{let r=kt.get(e);if(r===void 0){if(t!=="")throw new RangeError(`${n}: url must hold no query (${e} takes no query), got the query ${c(t)}`);return}let a=new Map;for(let[o,i]of new URLSearchParams(t.slice(1))){if(a.has(o))throw new RangeError(`${n}: url must hold each field of the query of ${e} once, got the field ${c(o)} twice`);a.set(o,r.includes(o)&&(i==="true"||i==="false")?i==="true":i)}return Object.fromEntries(a)},Nt=(e,t,n,r)=>{if(!Te(e))return t;let a=_e(t),o=t.slice(a.length);return je(o)?`${a}${Be(n,o,r,"unstampWrite")}`:t},Fe=async(e,t,n,r,a)=>{m("string",e,a,"url");let o=t.method===void 0?"GET":t.method;if(typeof o!="string")throw new TypeError(`${a}: init.method must be undefined or a string, got ${c(o)}`);let i=Nt(o,e,r,a),s=vt(o,i,n);if(s===null)throw Ot(o,i,n,a);let{route:d,search:p}=s,g=At(d,s.written,s.path,a),k;try{k=new Headers(t.headers)}catch(l){throw new TypeError(`${a}: init.headers must be headers the browser's Headers reads, got ${c(t.headers)}`,{cause:l})}let O=xt(d.endpoint,p,a),{body:N,filenames:$}=await Ie(d.endpoint,k.get("content-type"),t.body,a),M=Ae(d.endpoint,{params:Object.keys(g).length===0?void 0:g,query:O,body:N,signal:t.signal===null?void 0:t.signal},a);if(M.query!==null&&Ce(d.endpoint,M.query)!==p)throw new RangeError(`${a}: url must hold the query of ${d.endpoint} as chatQueryString writes it of the query its schema read, got the query ${c(p)}`);if(d.upload){let l=$[0],y=xe(M.body.file_name);if(l!==y)throw new RangeError(`${a}: init.body must carry the filename of its file part as the transport writes it of file_name (${c(y)}), got ${c(l)}`)}return M};var q="createChatScenarioFetch",z="ChatScenarioFetch.fetch",se="ChatScenarioFetch.plan",Tt="ChatScenarioFetch.hold",Je="ChatScenarioHold.settle",_t="ChatScenarioFetch.assertDone",X="chatScenarioRefusal",We=Object.freeze(Object.keys(P)),jt=Object.freeze(Object.keys(x.business_codes)),Xe=he({answered:["kind","answer"],refused:["kind","status","body"],unreached:["kind"],response:["kind","response"]}),Bt=Object.freeze(Object.keys(Xe)),ie=Object.freeze(Object.keys(Z.innerType().shape).filter(e=>e!=="error_code")),Pt="application/json",Ye=65536,Mt=1,Qe=400,Ze=599,Ut=ne({Blob:{attributes:["size","type"],operations:["slice"],statics:[]},AbortSignal:{attributes:["aborted","reason"],operations:["addEventListener","removeEventListener"],statics:["any"]}}),Lt=Object.freeze({kind:"unreached"}),qt=Object.freeze({waiting:"has taken no request",answering:"awaits the answer its response function makes",settled:"has answered its request",stopped:"was stopped"}),Ve=e=>Object.getOwnPropertyDescriptor(AbortSignal.prototype,e).get,ce=e=>Reflect.apply(Ve("aborted"),e,[])===!0,le=e=>Reflect.apply(Ve("reason"),e,[]),Ge=e=>{let t=Function.prototype.bind(void 0);return Reflect.apply(AbortSignal.prototype.addEventListener,e,["abort",t]),Reflect.apply(AbortSignal.prototype.removeEventListener,e,["abort",t]),e},zt=e=>{let t=Ge(AbortSignal.any([Ge(e)]));if(ce(t))throw new TypeError("the runtime's AbortSignal.any made an aborted signal from a signal that is not aborted");return t},Ke=e=>typeof e=="object"&&e!==null||typeof e=="function",et=(e,t)=>{let n=!1,r=o=>{n||(n=!0,t.rejected(o))},a=o=>{if(n)return;n=!0;let i;try{i=Ke(o)?Reflect.get(o,"then"):void 0}catch(d){t.rejected(d);return}if(typeof i!="function"){t.fulfilled(o);return}let s=i;Promise.resolve().then(()=>et((d,p)=>Reflect.apply(s,o,[d,p]),t))};try{e(a,r)}catch(o){r(o)}},tt=(e,t,n)=>{let r=o=>new RangeError(`${t}: ${n} must be a value JSON.stringify writes as a JSON text, got ${c(e)}`,o===void 0?void 0:{cause:o}),a;try{a=JSON.stringify(e)}catch(o){throw r(o)}if(a===void 0)throw r();return a},It=(e,t,n,r)=>{let a=P[e];if(a.answer===null){if(t!==null)throw new TypeError(`${n}: ${r} must be null (${e} answers no body), got ${c(t)}`);return Object.freeze({kind:"json",status:a.status,text:null})}let o=tt(t,n,r);return G($e[a.answer],JSON.parse(o),n,r,`the answer of ${e} (${a.answer}) when written as a JSON text and read back`),Object.freeze({kind:"json",status:a.status,text:o})},Ht=(e,t,n,r)=>{let a=ke(e,n,`${r}.status`,`an integer from ${Qe} to ${Ze}`,s=>Number.isInteger(s)&&s>=Qe&&s<=Ze),o=tt(t,n,`${r}.body`),i=Se(G(Z,JSON.parse(o),n,`${r}.body`,"a failed answer's body when written as a JSON text and read back"));if(i!==null){let s=x.business_codes[i.name].http_status;if(a!==s)throw new RangeError(`${n}: ${r}.status must be ${s}, the status of the business code ${i.name} its body carries, got ${a}`)}return Object.freeze({kind:"json",status:a,text:o})},de=(e,t,n,r)=>{m("object",t,n,r);let a=t,o=J(Bt,a.kind,n,`${r}.kind`),i=Xe[o],s=Object.keys(a).find(d=>!i.includes(d));if(s!==void 0)throw new RangeError(`${n}: ${r} must hold only the fields of a reply of the kind ${o} (${i.join(", ")}), got the key ${c(s)}`);switch(o){case"answered":return It(e,a.answer,n,`${r}.answer`);case"refused":{let{status:d,body:p}=a;return Ht(d,p,n,r)}case"unreached":return Lt;case"response":{let{response:d}=a;return m("function",d,n,`${r}.response`),Object.freeze({kind:"response",make:d})}}},Dt=e=>{let t=new TextEncoder().encode(e),n=()=>{},r;return{stream:new ReadableStream({type:"bytes",start:i=>{r=i;for(let s=0;s<t.byteLength;s+=Ye)i.enqueue(t.slice(s,s+Ye))},pull:i=>{n(),i.close(),i.byobRequest?.respond(0)},cancel:()=>{n()}},{highWaterMark:Mt}),tie:i=>{let s=()=>{n(),r.error(le(i))};n=()=>Reflect.apply(AbortSignal.prototype.removeEventListener,i,["abort",s]),Reflect.apply(AbortSignal.prototype.addEventListener,i,["abort",s])}}},Ft=e=>{if(e.text===null)return{response:new Response(null,{status:e.status}),tie:null};let t=Dt(e.text);return{response:new Response(t.stream,{status:e.status,headers:{"Content-Type":Pt}}),tie:t.tie}},Jt=e=>{let t=Reflect.get(Blob.prototype,"arrayBuffer"),n=Reflect.get(globalThis,"FileReader");if(typeof t!="function"&&typeof n!="function")throw new TypeError(`${e}: the runtime's Blob.prototype.arrayBuffer or its FileReader must be a function, as an upload's file is read by one of them, got ${c(t)} and ${c(n)}`)},Wt=e=>e instanceof Error?`${e.name}: ${e.message}`:c(e),wn=(e,t)=>{let n=J(jt,e,X,"name");m("object",t,X,"fields");let r=t,a=Object.keys(r).find(g=>!ie.includes(g));if(a!==void 0)throw new RangeError(`${X}: fields must hold only the fields of a failed answer's body besides error_code (${ie.join(", ")}), got the key ${c(a)}`);let{number:o,http_status:i}=x.business_codes[n],s=[["error_code",o],...ie.map(g=>[g,r[g]])],d=Object.fromEntries(s.filter(([,g])=>g!==void 0)),p=G(Z,d,X,"fields",`the fields of a failed answer's body of ${n}`);return ne({kind:"refused",status:i,body:p})},bn=e=>{m("object",e,q,"options");let{jsonBaseUrl:t,uploadBaseUrl:n,unstampWrite:r}=e;F(t,q,"jsonBaseUrl"),F(n,q,"uploadBaseUrl"),m("function",r,q,"unstampWrite"),Ne(q,Ut),Jt(q);let a=Object.freeze({jsonBaseUrl:t,uploadBaseUrl:n}),o=new Map,i=[],s=[],d=[],p=new Set,g=new Set,k=Promise.resolve(),O=()=>{for(let h of g)h()},N=h=>{let u=o.get(h);if(u!==void 0)return u;let R=[];return o.set(h,R),R};return Object.freeze({fetch:(h,u)=>{let R;try{R=De(u,z)}catch(C){return d.push(C),Promise.reject(C)}let v=Oe(R.signal)?R.signal:null;if(v!==null&&ce(v))return Promise.reject(le(v));let E=null;if(v!==null)try{E=zt(v)}catch(C){let j=new TypeError(`${z}: init.signal must be a signal the runtime's AbortSignal.any can make the request's own signal from, got ${c(v)}`,{cause:C});return d.push(j),Promise.reject(j)}return new Promise((C,j)=>{let A=!1,_=null,I={};p.add(I);let U=S=>{A||(A=!0,p.delete(I),_!==null&&_.phase.kind==="answering"&&(_.phase={kind:"settled"}),E!==null&&(g.delete(T),Reflect.apply(AbortSignal.prototype.removeEventListener,E,["abort",te])),S())},H=S=>{T(),d.push(S),U(()=>j(S))},te=()=>{_!==null&&(_.phase={kind:"stopped"}),U(()=>j(le(v)))},T=()=>(!A&&v!==null&&ce(v)&&te(),A),rt=S=>{let w;try{w=Ft(S)}catch(D){H(D);return}U(()=>{E!==null&&w.tie!==null&&w.tie(E),C(w.response)})},at=S=>{let w,D;try{w=Reflect.apply(S,void 0,[]),D=Ke(w)?Reflect.get(w,"then"):void 0}catch(B){H(B);return}if(typeof D!="function"){U(()=>C(w));return}let st=D;et((B,it)=>Reflect.apply(st,w,[B,it]),{fulfilled:B=>{T(),U(()=>C(B))},rejected:B=>{T()||H(B)}})},ue=S=>{if(!T())switch(S.kind){case"unreached":U(()=>j(new TypeError(`${z}: the request was not reached, as its step planned`)));return;case"json":rt(S);return;case"response":at(S.make)}},ot=S=>{let w=o.get(S.endpoint)?.shift();if(w===void 0)throw new RangeError(`${z}: a request of ${S.endpoint} must find a step the scenario planned for it, got one when none is left`);if(s.push(S),w.kind==="hold"){_=w.state,p.delete(I),w.state.phase={kind:"arrived",answer:ue},w.state.arrive(S);return}ue(w.kind==="reply"?w.reply:de(S.endpoint,Reflect.apply(w.step,void 0,[S]),z,w.field))};E!==null&&(g.add(T),Reflect.apply(AbortSignal.prototype.addEventListener,E,["abort",te])),k=k.then(async()=>{if(T())return;let S;try{S=await Fe(h,R,a,r,z)}catch(w){T()||H(w);return}if(!T())try{ot(S)}catch(w){H(w)}})})},plan:(h,...u)=>{let R=J(We,h,se,"endpoint");if(u.length===0)throw new RangeError(`${se}: steps must be one step or more, got none`);let v=u.map((E,C)=>Object.freeze(typeof E=="function"?{kind:"function",step:E,field:`steps[${C}](request)`}:{kind:"reply",reply:de(R,E,se,`steps[${C}]`)}));N(R).push(...v)},hold:h=>{let u=J(We,h,Tt,"endpoint"),R,v=new Promise(A=>{R=A}),E={endpoint:u,phase:{kind:"waiting"},arrive:R};i.push(E),N(u).push(Object.freeze({kind:"hold",state:E}));let C=()=>{O();let{phase:A}=E;if(A.kind!=="arrived")throw new TypeError(`${Je}: the held step of ${u} must hold a request it has neither answered nor stopped, got a step that ${qt[A.kind]}`);return A};return Object.freeze({arrived:v,settle:A=>{C();let _=de(u,A,Je,"reply"),I=C();E.phase={kind:"answering"},I.answer(_)}})},requests:()=>Object.freeze([...s]),assertDone:()=>{O();let h=[...p.size>0?[`requests still being read: ${p.size}`]:[],...d.map(u=>`the breach ${Wt(u)}`),...[...o].filter(([,u])=>u.length>0).map(([u,R])=>`untaken steps of ${u}: ${R.length}`),...i.filter(u=>u.phase.kind==="arrived"||u.phase.kind==="answering").map(u=>`the held request of ${u.endpoint} neither answered nor stopped`)];if(h.length>0)throw new Error(`${_t}: the scenario must end with every request read, no breach, every step taken, and every held request answered or stopped, got ${h.join("; ")}`)}})};var f="createChatScenarioRunStreams",V=Object.freeze({connecting:0,open:1,closed:2}),K=2147483647,ee=class extends EventTarget{url;#r=V.connecting;#e=null;#t=null;#n;#a=()=>{};constructor(t,n){super(),this.url=t,this.#n=n}get readyState(){return this.#r}isClosed(){return this.#r===V.closed}whenClosed(t){this.#a=t}after(t,n){this.#e=this.#n.setTimer(()=>{this.#e=null,n()},t)}beat(t){this.#t=this.#n.setTimer(()=>{this.#t=null,this.carry(t.event,t.data,""),this.isClosed()||this.beat(t)},t.everyMs)}stopBeating(){this.#t!==null&&(this.#n.clearTimer(this.#t),this.#t=null)}open(){this.#r=V.open,this.dispatchEvent(new Event("open"))}carry(t,n,r){this.dispatchEvent(new MessageEvent(t,{data:n,lastEventId:r}))}fail(){this.#o(),this.dispatchEvent(new Event("error"))}close(){this.#o()}#o(){this.isClosed()||(this.#r=V.closed,this.#e!==null&&(this.#n.clearTimer(this.#e),this.#e=null),this.stopBeating(),this.#a())}},nt=(e,t)=>{if(m("number",e,f,`${t}.afterMs`),!Number.isInteger(e)||e<0||e>K)throw new RangeError(`${f}: ${t}.afterMs must be an integer from 0 to ${K}, got ${c(e)}`)},Yt=e=>{m("object",e,f,"heartbeat");let{event:t,data:n,everyMs:r}=e;if(m("string",t,f,"heartbeat.event"),t===""||ye(t))throw new RangeError(`${f}: heartbeat.event must be a non-empty name that is not an event of the contract, got ${c(t)}`);if(m("string",n,f,"heartbeat.data"),m("number",r,f,"heartbeat.everyMs"),!Number.isInteger(r)||r<1||r>K)throw new RangeError(`${f}: heartbeat.everyMs must be an integer from 1 to ${K}, got ${c(r)}`);return Object.freeze({event:t,data:n,everyMs:r})},Qt=(e,t,n)=>{if(!Array.isArray(t))throw new TypeError(`${f}: runs[${JSON.stringify(e)}] must be an array of steps, got ${c(t)}`);let r=new Set,a=0;return t.map((o,i)=>{let s=`runs[${JSON.stringify(e)}][${i}]`;m("object",o,f,s);let{kind:d}=o;if(d==="gate"){let{gate:$}=o;if(m("string",$,f,`${s}.gate`),$===""||r.has($))throw new RangeError(`${f}: ${s}.gate must be a non-empty gate the script names once, got ${c($)}`);return r.add($),{kind:d,gate:$}}let{afterMs:p}=o;if(d==="resync"||d==="drop")return nt(p,s),{kind:d,afterMs:p};if(d!=="event")throw new RangeError(`${f}: ${s}.kind must be "event", "resync", "drop" or "gate", got ${c(d)}`);nt(p,s);let{event:g,data:k}=o;if(m("string",g,f,`${s}.event`),g===Q)throw new RangeError(`${f}: ${s}.event must not be ${Q}; a script places it as a step of kind "resync"`);let O=JSON.stringify(k)??"";try{me(g,O)}catch($){throw $ instanceof ge?new RangeError(`${f}: ${s} is not an event the contract reads: ${$.message}`,{cause:$}):$}let N=`${n}-${a}`;return a+=1,{kind:d,afterMs:p,event:g,data:O,id:N}})},vn=e=>{m("object",e,f,"options");let{baseUrl:t,cursorParam:n,idBaseMs:r,heartbeat:a,timers:o,runs:i}=e;if(F(t,f,"baseUrl"),m("string",n,f,"cursorParam"),n==="")throw new RangeError(`${f}: cursorParam must be a non-empty string, got ${c(n)}`);if(m("number",r,f,"idBaseMs"),!Number.isSafeInteger(r)||r<1)throw new RangeError(`${f}: idBaseMs must be a positive safe integer, got ${c(r)}`);let s=Yt(a);m("object",o,f,"timers"),m("function",o.setTimer,f,"timers.setTimer"),m("function",o.clearTimer,f,"timers.clearTimer"),m("object",i,f,"runs");let d=new Map;for(let[l,y]of Object.entries(i)){if(!pe.safeParse(l).success)throw new RangeError(`${f}: runs must be keyed by chat uids, got ${c(l)}`);let b=Qt(l,y,r),h=new Set(b.flatMap(u=>u.kind==="gate"?[u.gate]:[]));d.set(l,{runUid:l,path:`${t}${be("runEvents",{run_uid:l})}`,steps:b,gates:h,released:new Set,passed:new Set,open:null,end:null})}let p=[],g=new Map,k=(l,y,b)=>{let h=l.steps[b];if(!(h===void 0||y.isClosed())){if(h.kind==="gate"){if(l.released.has(h.gate)){k(l,y,b+1);return}let u=g.get(l.runUid)??new Map;u.set(h.gate,()=>k(l,y,b+1)),g.set(l.runUid,u);return}if((h.kind==="drop"||h.kind==="resync")&&l.passed.has(b)){k(l,y,b+1);return}y.after(h.afterMs,()=>{if(h.kind==="drop"){l.passed.add(b),y.fail();return}if(h.kind==="resync"){l.passed.add(b),y.stopBeating(),y.carry(Q,"","");return}if(fe(h.event)){l.end=h.event,y.stopBeating(),y.carry(h.event,h.data,h.id);return}y.carry(h.event,h.data,h.id),k(l,y,b+1)})}},O=(l,y)=>{p.push(y);let b=new ee(l,o);return b.after(0,()=>b.fail()),b};return Object.freeze({createEventSource:(l,y)=>{let[b,h=""]=l.split("?",2),u=[...d.values()].find(C=>C.path===b);if(u===void 0)return O(l,`a stream no script plans: ${l}`);if(u.open!==null&&!u.open.isClosed())return O(l,`a second stream of run ${u.runUid} while one is open: ${l}`);let R=new URLSearchParams(h).get(n),v=R===null?0:u.steps.findIndex(C=>C.kind==="event"&&C.id===R)+1;if(v===0&&R!==null)return O(l,`a stream of run ${u.runUid} from a stream ID its script does not hold: ${R}`);let E=new ee(l,o);return u.open=E,E.whenClosed(()=>{u.open=null,g.delete(u.runUid)}),E.after(0,()=>{E.open(),E.beat(s),k(u,E,v)}),E},release:(l,y)=>{let b=d.get(l);if(b===void 0||!b.gates.has(y)){p.push(`a release of gate ${JSON.stringify(y)} no script of run ${l} has`);return}b.released.add(y);let h=g.get(l)?.get(y);h!==void 0&&(g.get(l)?.delete(y),h())},endOf:l=>{let y=d.get(l);return y===void 0?(p.push(`an end of run ${l} no script plans`),null):y.end},breaches:()=>[...p]})};export{K as CHAT_SCENARIO_STREAM_MAX_WAIT_MS,wn as chatScenarioRefusal,bn as createChatScenarioFetch,vn as createChatScenarioRunStreams};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { K as ChatBusinessCodeName, $ as ChatExchangeEndpointName, Z as ChatExchangeAnswer, S as ChatErrorBody, ad as ChatQueryName, bg as chatQuerySchemas, _ as ChatExchangeBody } from "./index-g-wjju1F.cjs";
|
|
3
3
|
declare const EXCHANGE_PATH_PARAMS: {
|
|
4
4
|
readonly listConversations: readonly [
|
|
5
5
|
];
|
|
@@ -8,6 +8,12 @@ declare const EXCHANGE_PATH_PARAMS: {
|
|
|
8
8
|
readonly getConversation: readonly [
|
|
9
9
|
"conversation_uid"
|
|
10
10
|
];
|
|
11
|
+
readonly updateConversation: readonly [
|
|
12
|
+
"conversation_uid"
|
|
13
|
+
];
|
|
14
|
+
readonly deleteConversation: readonly [
|
|
15
|
+
"conversation_uid"
|
|
16
|
+
];
|
|
11
17
|
readonly listMessages: readonly [
|
|
12
18
|
"conversation_uid"
|
|
13
19
|
];
|
|
@@ -19,6 +25,18 @@ declare const EXCHANGE_PATH_PARAMS: {
|
|
|
19
25
|
"conversation_uid",
|
|
20
26
|
"message_uid"
|
|
21
27
|
];
|
|
28
|
+
readonly getConversationTree: readonly [
|
|
29
|
+
"conversation_uid"
|
|
30
|
+
];
|
|
31
|
+
readonly searchConversation: readonly [
|
|
32
|
+
"conversation_uid"
|
|
33
|
+
];
|
|
34
|
+
readonly setActiveRoot: readonly [
|
|
35
|
+
"conversation_uid"
|
|
36
|
+
];
|
|
37
|
+
readonly setActiveChild: readonly [
|
|
38
|
+
"message_uid"
|
|
39
|
+
];
|
|
22
40
|
readonly startRun: readonly [
|
|
23
41
|
"conversation_uid"
|
|
24
42
|
];
|
|
@@ -34,6 +52,10 @@ declare const EXCHANGE_PATH_PARAMS: {
|
|
|
34
52
|
];
|
|
35
53
|
readonly updateSettings: readonly [
|
|
36
54
|
];
|
|
55
|
+
readonly getPolicy: readonly [
|
|
56
|
+
];
|
|
57
|
+
readonly consentPolicy: readonly [
|
|
58
|
+
];
|
|
37
59
|
readonly getAttachment: readonly [
|
|
38
60
|
"attachment_uid"
|
|
39
61
|
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { K as ChatBusinessCodeName, $ as ChatExchangeEndpointName, Z as ChatExchangeAnswer, S as ChatErrorBody, ad as ChatQueryName, bg as chatQuerySchemas, _ as ChatExchangeBody } from "./index-g-wjju1F.js";
|
|
3
3
|
declare const EXCHANGE_PATH_PARAMS: {
|
|
4
4
|
readonly listConversations: readonly [
|
|
5
5
|
];
|
|
@@ -8,6 +8,12 @@ declare const EXCHANGE_PATH_PARAMS: {
|
|
|
8
8
|
readonly getConversation: readonly [
|
|
9
9
|
"conversation_uid"
|
|
10
10
|
];
|
|
11
|
+
readonly updateConversation: readonly [
|
|
12
|
+
"conversation_uid"
|
|
13
|
+
];
|
|
14
|
+
readonly deleteConversation: readonly [
|
|
15
|
+
"conversation_uid"
|
|
16
|
+
];
|
|
11
17
|
readonly listMessages: readonly [
|
|
12
18
|
"conversation_uid"
|
|
13
19
|
];
|
|
@@ -19,6 +25,18 @@ declare const EXCHANGE_PATH_PARAMS: {
|
|
|
19
25
|
"conversation_uid",
|
|
20
26
|
"message_uid"
|
|
21
27
|
];
|
|
28
|
+
readonly getConversationTree: readonly [
|
|
29
|
+
"conversation_uid"
|
|
30
|
+
];
|
|
31
|
+
readonly searchConversation: readonly [
|
|
32
|
+
"conversation_uid"
|
|
33
|
+
];
|
|
34
|
+
readonly setActiveRoot: readonly [
|
|
35
|
+
"conversation_uid"
|
|
36
|
+
];
|
|
37
|
+
readonly setActiveChild: readonly [
|
|
38
|
+
"message_uid"
|
|
39
|
+
];
|
|
22
40
|
readonly startRun: readonly [
|
|
23
41
|
"conversation_uid"
|
|
24
42
|
];
|
|
@@ -34,6 +52,10 @@ declare const EXCHANGE_PATH_PARAMS: {
|
|
|
34
52
|
];
|
|
35
53
|
readonly updateSettings: readonly [
|
|
36
54
|
];
|
|
55
|
+
readonly getPolicy: readonly [
|
|
56
|
+
];
|
|
57
|
+
readonly consentPolicy: readonly [
|
|
58
|
+
];
|
|
37
59
|
readonly getAttachment: readonly [
|
|
38
60
|
"attachment_uid"
|
|
39
61
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The chat of the AI Quants applications: the wire contract of its stream events, failure codes, business codes, endpoints (their paths, queries and exchanges), resources, attachments and vocabularies, with the marks of the characters a reader cannot see, the subscription to a run's stream and the notice of its connection, the fold of the stream into the view a window holds, the arithmetic, frame, composer (with its recording through the host's microphone) and attachment rules of the chat's screen, the reading of a refused answer, the names of the diagrams a window saves, and the authorization resources its endpoints guard with.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"license": "MIT",
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@aiquants/authz-core": "^0.6.2",
|
|
78
|
-
"@aiquants/console-ui": "^0.
|
|
78
|
+
"@aiquants/console-ui": "^0.11.0",
|
|
79
79
|
"@aiquants/input-method": "^0.1.2",
|
|
80
80
|
"@aiquants/markdown": "^14.0.0",
|
|
81
81
|
"@aiquants/sse": "^0.4.0",
|
|
@@ -113,12 +113,12 @@
|
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@aiquants/auth-core": "0.9.4",
|
|
115
115
|
"@aiquants/authz-core": "0.6.4",
|
|
116
|
-
"@aiquants/console-ui": "0.
|
|
116
|
+
"@aiquants/console-ui": "0.11.0",
|
|
117
117
|
"@aiquants/input-method": "0.1.2",
|
|
118
|
-
"@aiquants/markdown": "14.
|
|
118
|
+
"@aiquants/markdown": "14.1.0",
|
|
119
119
|
"@aiquants/spreadsheet": "0.21.2",
|
|
120
120
|
"@aiquants/sse": "0.4.0",
|
|
121
|
-
"@aiquants/virtualscroll": "3.
|
|
121
|
+
"@aiquants/virtualscroll": "3.31.1",
|
|
122
122
|
"@testing-library/jest-dom": "^6.9.1",
|
|
123
123
|
"@testing-library/react": "^16.3.2",
|
|
124
124
|
"@testing-library/user-event": "^14.6.1",
|
package/dist/chunk-4NR4KSV6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var H={protocol_version:1,events:{"run.started":{terminal:!1,start:!0,fields:{run_uid:"required",conversation_uid:"required",assistant_message_uid:"required",protocol:"required",model:"required",started_at:"required"}},"step.started":{terminal:!1,start:!1,fields:{step:"required",kind:"required"}},"step.retry":{terminal:!1,start:!1,fields:{step:"required",retry_no:"required",reason:"required",wait_ms:"required"}},"text.delta":{terminal:!1,start:!1,fields:{step:"required",text:"required"}},"reasoning.delta":{terminal:!1,start:!1,fields:{step:"required",text:"required"}},usage:{terminal:!1,start:!1,fields:{step:"required",input_tokens:"required",output_tokens:"required",cached_input_tokens:"required",reasoning_tokens:"required",cost_micros:"required"}},"step.finished":{terminal:!1,start:!1,fields:{step:"required",finish_reason:"required",reasoning_ms:"optional"}},"step.reset":{terminal:!1,start:!1,fields:{step:"required"}},"run.completed":{terminal:!0,start:!1,fields:{finish_reason:"required",usage_total:"required",cost_total_micros:"required"}},"run.failed":{terminal:!0,start:!1,fields:{error_code:"required",detail:"required",retryable:"required",calls:"required"}},"run.cancelled":{terminal:!0,start:!1,fields:{cancelled_by:"required",calls:"required"}},"resync-required":{terminal:!0,start:!1,fields:{}}},event_refusals:["unknown_event","reserved_data","too_deep","not_json","shape"],data_max_depth:8,failure_codes:{CHAT_PROVIDER_FAILED:{detail:[{reason:{presence:"required",values:["rate_limited","quota_exhausted","auth_failed","timeout","error"]},retry:{presence:"required",values:["exhausted","withheld","no_time","none"]},retry_after_seconds:{presence:"optional",type:"count"}}]},CHAT_PROVIDER_REFUSED:{detail:[{}]},CHAT_MODEL_UNAVAILABLE:{detail:[{reason:{presence:"required",values:["access_denied","classification","stopped","breaker_open","ledger_mismatch","config_invalid","credential_refused","reasoning_level_unavailable"]}}]},CHAT_ASSISTANT_UNAVAILABLE:{detail:[{}]},CHAT_CONTEXT_OVERFLOW:{detail:[{}]},CHAT_CONTEXT_CHANGED:{detail:[{}]},CHAT_KNOWLEDGE_UNAVAILABLE:{detail:[{}]},CHAT_KNOWLEDGE_BODY_HIDDEN:{detail:[{}]},CHAT_KNOWLEDGE_SCOPE_TOO_LARGE:{detail:[{}]},CHAT_RUN_LIMIT_REACHED:{detail:[{kind:{presence:"required",values:["steps","tool_calls","events","active_time"]}}]},CHAT_CONFIRM_LIMIT_REACHED:{detail:[{}]},CHAT_CONFIDENTIALITY_BLOCKED:{detail:[{}]},CHAT_BUDGET_EXCEEDED:{detail:[{scope:{presence:"required",values:["run"]}},{scope:{presence:"required",values:["user","tenant"]},resets_at:{presence:"required",type:"instant"}}]},CHAT_RUN_INTERRUPTED:{detail:[{}]},CHAT_STOPPED_BY_ADMIN:{detail:[{}]},CHAT_ACCESS_REVOKED:{detail:[{}]},CHAT_TOOL_ARGS_INVALID:{detail:[{}]},CHAT_TOOL_UNAVAILABLE:{detail:[{}]},CHAT_TOOL_TIMEOUT:{detail:[{}]},CHAT_SOURCE_BUSY:{detail:[{}]},CHAT_TOOL_CONTRACT_ERROR:{detail:[{}]},CHAT_TOOL_INTERRUPTED:{detail:[{}]},CHAT_TOOL_RESULT_SHAPE_CHANGED:{detail:[{}]},CHAT_EGRESS_DENIED:{detail:[{}]}},business_codes:{PERMISSION_DENIED:{http_status:403,number:4031,detail:[{}]},NOT_FOUND:{http_status:404,number:4040,detail:[{resource:{presence:"required",values:["conversation","message","run","approval","source","tool","assistant","citation","attachment"]}}]},REQUEST_INVALID:{http_status:422,number:4222,detail:[{errors:{presence:"required",type:"errors"}}]},UPSTREAM_UNAVAILABLE:{http_status:503,number:5039,detail:[{upstream:{presence:"required",values:["model","stream_store","attachment_store"]}}]},CONFIGURATION_ERROR:{http_status:503,number:5030,detail:[{},{errors:{presence:"required",type:"errors"}},{reading:{presence:"required",values:["transcription","ocr"]}}]},CHAT_POLICY_CONSENT_REQUIRED:{http_status:403,number:40310,detail:[{}]},CHAT_POLICY_NOT_PUBLISHED:{http_status:403,number:40311,detail:[{}]},CHAT_STATE_CONFLICT:{http_status:409,number:40910,detail:[{kind:{presence:"required",values:["approval","branch","edit"]}},{kind:{presence:"required",values:["attachment"]},reason:{presence:"required",values:["processing","failed","already_bound"]}}]},CHAT_RUN_ACTIVE:{http_status:423,number:4233,detail:[{}]},CHAT_ADMISSION_BUSY:{http_status:423,number:4234,detail:[{}]},CHAT_CONCURRENCY_LIMIT:{http_status:429,number:4290,detail:[{scope:{presence:"required",values:["user","tenant","model"]}}]},CHAT_RATE_LIMIT:{http_status:429,number:4291,detail:[{}]},CHAT_BUDGET_EXCEEDED:{http_status:429,number:4292,detail:[{scope:{presence:"required",values:["run"]}},{scope:{presence:"required",values:["user","tenant"]},resets_at:{presence:"required",type:"instant"}}]}},request_invalid_types:["egress_denied","sql_statement_rejected","secret_in_text","individual_number_in_text","idempotency_key_reused","message_role","toggle_unknown","secret_name_unknown","reasoning_shape_invalid","reasoning_summary_unsupported","reasoning_level_unsupported","approval_stale_unconfirmed","model_unavailable","assistant_unavailable","declared_level_below_default","attachment_type_refused","attachment_too_large","attachment_too_many_pixels","attachment_too_many_pages","attachment_too_long","attachment_count_exceeded","attachment_unsupported_by_model","attachment_exceeds_provider_limit","attachment_unread_for_external_model"],host_refusal_roles:["chat_disabled","knowledge_body_hidden"],paths:{base:"/ai/chat",json:{listConversations:{method:"GET",path:"/conversations"},createConversation:{method:"POST",path:"/conversations"},getConversation:{method:"GET",path:"/conversations/{conversation_uid}"},updateConversation:{method:"PATCH",path:"/conversations/{conversation_uid}"},deleteConversation:{method:"DELETE",path:"/conversations/{conversation_uid}"},listMessages:{method:"GET",path:"/conversations/{conversation_uid}/messages"},getMessage:{method:"GET",path:"/conversations/{conversation_uid}/messages/{message_uid}"},getMessagePath:{method:"GET",path:"/conversations/{conversation_uid}/messages/{message_uid}/path"},getConversationTree:{method:"GET",path:"/conversations/{conversation_uid}/tree"},searchConversation:{method:"GET",path:"/conversations/{conversation_uid}/search"},setActiveRoot:{method:"PUT",path:"/conversations/{conversation_uid}/active-root"},setActiveChild:{method:"PUT",path:"/messages/{message_uid}/active-child"},startRun:{method:"POST",path:"/conversations/{conversation_uid}/runs"},getRun:{method:"GET",path:"/runs/{run_uid}"},cancelRun:{method:"POST",path:"/runs/{run_uid}/cancel"},exportConversation:{method:"GET",path:"/conversations/{conversation_uid}/export"},putFeedback:{method:"PUT",path:"/messages/{message_uid}/feedback"},listModels:{method:"GET",path:"/models"},getSettings:{method:"GET",path:"/settings"},updateSettings:{method:"PATCH",path:"/settings"},getPolicy:{method:"GET",path:"/policy"},consentPolicy:{method:"POST",path:"/policy-consents"},listPolicyVersions:{method:"GET",path:"/admin/policy"},publishPolicy:{method:"POST",path:"/admin/policy"},getAttachment:{method:"GET",path:"/attachments/{attachment_uid}"},updateAttachment:{method:"PATCH",path:"/attachments/{attachment_uid}"},deleteAttachment:{method:"DELETE",path:"/attachments/{attachment_uid}"}},upload:{createAttachment:{method:"POST",path:"/attachments"}},content:{getAttachmentContent:{method:"GET",path:"/attachments/{attachment_uid}/content"},getAttachmentPreview:{method:"GET",path:"/attachments/{attachment_uid}/preview"}},stream:{runEvents:{method:"GET",path:"/runs/{run_uid}/events"}}},limits:["CHAT_USER_MESSAGE_MAX_CHARS","CHAT_RUN_POLL_INTERVAL_MS","CHAT_RENDER_DIAGRAM_MAX_CHARS","CHAT_RENDER_DIAGRAM_MAX_EDGES","CHAT_RENDER_MAX_DIAGRAMS_PER_MESSAGE","CHAT_RENDER_DIAGRAM_CACHE_MAX_CHARS","CHAT_RENDER_HTML_CACHE_MAX_CHARS","CHAT_RENDER_HTML_MAX_BYTES","CHAT_RENDER_CONVERT_TIMEOUT_MS","CHAT_RENDER_LOAD_TIMEOUT_MS","CHAT_RENDER_MATH_MAX_SIZE_EM","CHAT_RENDER_MATH_MAX_EXPAND","CHAT_RENDER_LIST_OVERSCAN_ROWS","CHAT_RENDER_SMOOTH_HALF_LIFE_MS","CHAT_CONVERSATION_PAGE_SIZE","CHAT_TITLE_SEARCH_PAUSE_MS","CHAT_ATTACHMENT_MAX_COUNT","CHAT_ATTACHMENT_IMAGE_MAX_BYTES","CHAT_ATTACHMENT_PDF_MAX_BYTES","CHAT_ATTACHMENT_AUDIO_MAX_BYTES","CHAT_ATTACHMENT_AUDIO_MAX_SECONDS","CHAT_ATTACHMENT_POLL_INTERVAL_MS"],attachments:{kinds:{image:{flag:"supports_images",accepted_types:["image/png","image/jpeg","image/webp","image/gif"],failure_tags:["secret_in_text","individual_number_in_text"],part:"image_text",fields:{width:"required",height:"required",text_unread:"required"}},document:{flag:"supports_pdf",accepted_types:["application/pdf"],failure_tags:["ocr_unavailable","secret_in_text","individual_number_in_text"],part:"page",fields:{page_count:"required",unread_pages:"required"}},audio:{flag:"supports_audio",accepted_types:["audio/webm","audio/mp4","audio/wav","audio/mpeg","audio/ogg","audio/flac"],failure_tags:["transcription_unavailable","secret_in_text","individual_number_in_text"],part:"segment",fields:{duration_ms:"required"}}},origins:["user","tool"],states:["processing","ready","failed"],failure_tags:["transcription_unavailable","ocr_unavailable","secret_in_text","individual_number_in_text"],parts:{page:{sources:["text_layer","ocr"],fields:{kind:"required",page:"required",source:"required",text:"required"}},segment:{sources:["transcription"],fields:{kind:"required",start_ms:"required",end_ms:"required",source:"required",text:"required"}},image_text:{sources:["ocr"],fields:{kind:"required",source:"required",text:"required"}}},pdf_deliveries:["document","page_text"],resource:{attachment_uid:"required",origin:"required",kind:"required",content_type:"required",byte_size:"required",sha256:"required",file_name:"required",alt_text:"required",state:"required",failure_tag:"required",expires_at:"required",parts:"required"},message_item:{attachment_uid:"required",origin:"required",kind:"required",content_type:"required",byte_size:"required",file_name:"required",alt_text:"required"},upload:{model_uid:"required",file_name:"required",alt_text:"optional",file:"required"},update:{alt_text:"required"},fragments:{message:{attachments:"required"},message_request:{attachment_ids:"required"},model:{supports_images:"required",supports_pdf:"required",supports_audio:"required",pdf_delivery:"required"}}},vocabularies:{run_states:["queued","running","awaiting_approval","completed","failed","cancelled"],active_run_states:["queued","running","awaiting_approval"],run_kinds:["send","edit","regenerate"],finish_reasons:["stop","length"],message_roles:["user","assistant"],reasoning_levels:["off","low","medium","high","max"],title_origins:["user","model"],confidentiality_levels:["PUBLIC","INTERNAL","DEPARTMENT","CONFIDENTIAL","RESTRICTED"],model_unavailable_reasons:["access_denied","classification","disabled","ledger_mismatch","config_invalid","credential_refused","stopped","breaker_open"],model_upstream_unavailable_reasons:["stopped","breaker_open"],processing_locations:["internal","external"],export_formats:["markdown","json"],language_codes:["ja","en"],notification_levels:["all","finish","none"],stream_displays:["smooth","immediate","on_finish"],message_actions_displays:["auto","always","hover"],send_keys:["enter","ctrl_enter"]},queries:{listConversations:{cursor:"optional",until:"optional",q:"optional",pinned:"optional"},listMessages:{cursor:"optional"},getMessagePath:{cursor:"optional"},searchConversation:{q:"required"},exportConversation:{format:"required"},listModels:{conversation_uid:"optional",declared_level:"optional"}},resources:{conversation:{conversation_uid:"required",title:"required",title_origin:"required",model_uid:"required",reasoning_level:"required",declared_level:"required",pinned:"required",last_activity_at:"required",purge_due_at:"required",active_root_message_uid:"required",active_run:"required",created_at:"required"},active_run:{run_uid:"required",state:"required"},page:{items:"required",next_cursor:"required"},message:{message_uid:"required",conversation_uid:"required",parent_message_uid:"required",role:"required",text:"required",created_at:"required",active_child_message_uid:"required",sibling_message_uids:"required",attachments:"required"},message_role_fields:{user:{},assistant:{context_cut_before:"required",run:"required"}},message_run:{run_uid:"required",model:"required",state:"required",segment_no:"required",finish_reason:"required",failure:"required",cancelled_by:"required",stream_open:"required",view:"required"},message_run_model:{model_uid:"required",display_name:"required"},run_failure:{error_code:"required",detail:"required"},run_seed:{mark:"required",started:"required",steps:"required"},run_seed_step:{step:"required",kind:"required",text:"required",reasoning:"required",usage:"required",finish:"required"},run_request:{send:{kind:"required",client_request_id:"required",parent_message_uid:"required",text:"required",attachment_ids:"required",model_uid:"required",reasoning_level:"required"},edit:{kind:"required",client_request_id:"required",target_message_uid:"required",text:"required",attachment_ids:"required",model_uid:"required",reasoning_level:"required"},regenerate:{kind:"required",client_request_id:"required",target_message_uid:"required",model_uid:"required",reasoning_level:"required"}},run_accepted:{run_uid:"required",user_message_uid:"required",assistant_message_uid:"required"},conversation_request:{client_request_id:"required",text:"required",attachment_ids:"required",model_uid:"required",reasoning_level:"required",declared_level:"required"},conversation_accepted:{conversation:"required",run:"required"},run:{run_uid:"required",conversation_uid:"required",assistant_message_uid:"required",state:"required",segment_no:"required"},settings:{user_settings:"required",conversation_defaults:"required",limits:"required"},user_settings:{language_code:"required",notification_level:"required",stream_display:"required",follow_scroll:"required",reduce_motion:"required",message_actions_display:"required",collapse_action_labels:"required",send_key:"required",default_model_uid:"required"},user_settings_update:{language_code:"optional",notification_level:"optional",stream_display:"optional",follow_scroll:"optional",reduce_motion:"optional",message_actions_display:"optional",collapse_action_labels:"optional",send_key:"optional",default_model_uid:"optional"},conversation_defaults:{model_uid:"required",declared_level:"required"},model_list:{items:"required"},model:{model_uid:"required",display_name:"required",unavailable_reason:"required",reasoning_levels:"required",default_reasoning_level:"required",reasoning_summary:"required",supports_tools:"required",supports_images:"required",supports_pdf:"required",supports_audio:"required",pdf_delivery:"required",context_window_tokens:"required",max_output_tokens:"required",processing_location:"required",processing_countries:"required",storage_countries:"required",used_for_training:"required",retention_days:"required",contract_terms:"required",recent_failures:"required"},model_hidden:{model_uid:"required",unavailable_reason:"required"},recent_failures:{calls:"required",failures:"required"},error_body:{error_code:"required",error_msg:"required",request_id:"required",detail:"optional",failed_stage:"optional"}},exchanges:{listConversations:{status:200,body:null,answer:"conversation_page"},createConversation:{status:201,body:"conversation_request",answer:"conversation_accepted"},getConversation:{status:200,body:null,answer:"conversation"},listMessages:{status:200,body:null,answer:"message_page"},getMessage:{status:200,body:null,answer:"message"},getMessagePath:{status:200,body:null,answer:"message_page"},startRun:{status:202,body:"run_request",answer:"run_accepted"},getRun:{status:200,body:null,answer:"run"},cancelRun:{status:200,body:null,answer:"run"},listModels:{status:200,body:null,answer:"model_list"},getSettings:{status:200,body:null,answer:"settings"},updateSettings:{status:200,body:"user_settings_update",answer:"settings"},getAttachment:{status:200,body:null,answer:"attachment"},updateAttachment:{status:200,body:"attachment_update",answer:"attachment"},deleteAttachment:{status:204,body:null,answer:null},createAttachment:{status:201,body:"attachment_upload",answer:"attachment"}},invisible:{set:{default_ignorable:["U+00AD","U+034F","U+061C","U+115F..U+1160","U+17B4..U+17B5","U+180B..U+180F","U+200B..U+200F","U+202A..U+202E","U+2060..U+206F","U+3164","U+FE00..U+FE0F","U+FEFF","U+FFA0","U+FFF0..U+FFF8","U+1BCA0..U+1BCA3","U+1D173..U+1D17A","U+E0000..U+E0FFF"],controls:["U+0000..U+0008","U+000B..U+000C","U+000E..U+001F","U+007F..U+009F"],separators:["U+2028..U+2029"],interlinear_annotations:["U+FFF9..U+FFFB"],noncharacters:["U+FDD0..U+FDEF","U+FFFE..U+FFFF","U+1FFFE..U+1FFFF","U+2FFFE..U+2FFFF","U+3FFFE..U+3FFFF","U+4FFFE..U+4FFFF","U+5FFFE..U+5FFFF","U+6FFFE..U+6FFFF","U+7FFFE..U+7FFFF","U+8FFFE..U+8FFFF","U+9FFFE..U+9FFFF","U+AFFFE..U+AFFFF","U+BFFFE..U+BFFFF","U+CFFFE..U+CFFFF","U+DFFFE..U+DFFFF","U+EFFFE..U+EFFFF","U+FFFFE..U+FFFFF","U+10FFFE..U+10FFFF"]},exceptions:{variation_selectors:["U+180B..U+180D","U+180F","U+FE00..U+FE0F","U+E0100..U+E01EF"],joiners:["U+200C..U+200D"],tag_flags:[["U+1F3F4","U+E0067","U+E0062","U+E0065","U+E006E","U+E0067","U+E007F"],["U+1F3F4","U+E0067","U+E0062","U+E0073","U+E0063","U+E0074","U+E007F"],["U+1F3F4","U+E0067","U+E0062","U+E0077","U+E006C","U+E0073","U+E007F"]]},white_space:["U+0009..U+000D","U+0020","U+0085","U+00A0","U+1680","U+2000..U+200A","U+2028..U+2029","U+202F","U+205F","U+3000"]},drawable_diagrams:[{type:"mindmap",header:"mindmap"},{type:"architecture",header:"architecture-beta"},{type:"c4",header:"C4Context"},{type:"kanban",header:"kanban"},{type:"classDiagram",header:"classDiagram-v2"},{type:"class",header:"classDiagram"},{type:"er",header:"erDiagram"},{type:"gantt",header:"gantt"},{type:"info",header:"info"},{type:"pie",header:"pie"},{type:"requirement",header:"requirementDiagram"},{type:"sequence",header:"sequenceDiagram"},{type:"swimlane",header:"swimlane-beta"},{type:"flowchart-v2",header:"flowchart"},{type:"timeline",header:"timeline"},{type:"gitGraph",header:"gitGraph"},{type:"stateDiagram",header:"stateDiagram-v2"},{type:"quadrantChart",header:"quadrantChart"},{type:"sankey",header:"sankey"},{type:"packet",header:"packet"},{type:"xychart",header:"xychart"},{type:"block",header:"block"},{type:"eventmodeling",header:"eventmodeling"},{type:"treeView",header:"treeView-beta"},{type:"ishikawa",header:"ishikawa-beta"},{type:"railroad",header:"railroad-beta"},{type:"railroadEbnf",header:"railroad-ebnf-beta"},{type:"railroadAbnf",header:"railroad-abnf-beta"},{type:"railroadPeg",header:"railroad-peg-beta"},{type:"venn",header:"venn-beta"},{type:"wardley",header:"wardley-beta"},{type:"cynefin",header:"cynefin-beta"}]};var I=e=>`U+${e.toString(16).toUpperCase().padStart(4,"0")}`,re=e=>{let a=/^U\+[0-9A-F]{4,6}$/.test(e)?Number.parseInt(e.slice(2),16):Number.NaN;if(!(a<=1114111)||a>=55296&&a<=57343||I(a)!==e)throw new Error(`not the contract's spelling of a code point: ${JSON.stringify(e)}`);return a},U=(e,a)=>{let n=[];for(let r of e){let s=r.split("..").map(re),o=s[0],d=s.at(-1);if(s.length>2||s.length===2&&!(o<d))throw new Error(`not the contract's spelling of a range of code points in ${a}: ${JSON.stringify(r)}`);let i=n.at(-1);if(i!==void 0&&!(o>i[1]+1))throw new Error(`not in order with a gap after every range in ${a}: ${JSON.stringify(r)}`);n.push([o,d])}return n},b=(e,a)=>e.some(([n,r])=>n<=a&&a<=r),De=e=>{let a=[],n=Object.entries(e.set).flatMap(([i,c])=>U(c,`the set's ${i}`)).sort((i,c)=>i[0]-c[0]);for(let[i,c]of n){let y=a.at(-1);if(y===void 0||i>y[1]+1)a.push([i,c]);else if(i===y[1]+1)a[a.length-1]=[y[0],c];else throw new Error(`two categories of the set share ${I(i)}`)}let r=U(e.exceptions.variation_selectors,"the variation selectors"),s=U(e.exceptions.joiners,"the joiners");for(let[i,c]of[...r,...s])if(!a.some(y=>y[0]<=i&&c<=y[1]))throw new Error(`an exception is outside the set: ${I(i)}`);let o=U(e.white_space,"the white space"),d=e.exceptions.tag_flags.map(i=>{let[c,...y]=i.map(re);if(c===void 0||b(a,c)||b(o,c)||y.length===0||!y.every(Ue=>b(a,Ue)))throw new Error(`a tag flag is not a visible character followed by characters of the set: ${JSON.stringify(i)}`);return[c,...y]});return{set:a,variationSelectors:r,joiners:s,tagFlags:d,whiteSpace:o}},A=De(H.invisible),D=e=>e.map(([a,n])=>a===n?`\\u{${a.toString(16)}}`:`\\u{${a.toString(16)}}-\\u{${n.toString(16)}}`).join(""),se=`[^${D(A.set)}${D(A.whiteSpace)}]`,ke=new RegExp(`(${A.tagFlags.map(e=>e.map(a=>`\\u{${a.toString(16)}}`).join("")).join("|")})|[${D(A.set)}]`,"gu"),oe=new RegExp(se,"uy"),we=new RegExp(`[${D(A.variationSelectors)}]`,"uy"),Me=new RegExp(se,"u"),Le=[...new Map(A.tagFlags.flatMap(([e,...a])=>a.slice(0,-1).map((n,r)=>{let s=String.fromCodePoint(...a.slice(0,r+1));return[String.fromCodePoint(e)+s,s.length]})))].map(([e,a])=>({ending:e,held:a})),w=(e,a)=>{let n=e.charCodeAt(a-1),r=e.charCodeAt(a-2);return n>=56320&&n<=57343&&r>=55296&&r<=56319?a-2:a-1},X=(e,a,n)=>(e.lastIndex=n,e.test(a)),k=(e,a)=>a>0&&X(oe,e,w(e,a)),ie=(e,a)=>{if(a===0)return!1;let n=w(e,a);return X(we,e,n)&&k(e,n)},je=(e,a,n)=>{let r=n.codePointAt(0);return b(A.variationSelectors,r)?k(e,a):b(A.joiners,r)&&X(oe,e,a+n.length)&&(k(e,a)||ie(e,a))},Pe=e=>{if(e.length===0)return 0;let a=w(e,e.length),n=e.codePointAt(a);if(b(A.joiners,n)&&(k(e,a)||ie(e,a)))return a;let r=Le.find(({ending:s})=>e.endsWith(s));return r===void 0?e.length:e.length-r.held},Be=(e,a)=>{let n=a.complete?e:e.slice(0,Pe(e)),r=[],s=0,o=0;for(let d of n.matchAll(ke)){let[i,c]=d;c!==void 0||je(n,d.index,i)||(r.push(n.slice(s,d.index),`\u27E6${I(i.codePointAt(0))}\u27E7`),s=d.index+i.length,o+=1)}return o===0?{text:n,marks:o}:(r.push(n.slice(s)),{text:r.join(""),marks:o})},Ge=e=>Me.test(e),$=e=>{let a=0;for(let r of e){if(!b(A.whiteSpace,r.codePointAt(0)))break;a+=r.length}let n=e.length;for(;n>a;){let r=w(e,n);if(!b(A.whiteSpace,e.codePointAt(r)))break;n=r}return a===n?null:e.slice(a,n)};import{z as t}from"zod";var M=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let a=Object.getPrototypeOf(e);return a===null||typeof a=="object"&&Object.getPrototypeOf(a)===null},u=e=>{if(Array.isArray(e)||M(e)){for(let a of Object.values(e))u(a);Object.freeze(e)}return e},de=e=>u(e);var le=e=>{if(!(Number.isInteger(e)&&e>=1))throw new RangeError(`the most members of one set of marks is not a positive integer: ${e}`);let a=[],n=new Set;return a.push(n),{has:r=>{for(let s of a)if(s.has(r))return!0;return!1},add:r=>{n.size===e&&(n=new Set,a.push(n)),n.add(r)}}};var g=de(H),ha=g.protocol_version,ga=u(["chat_disabled","knowledge_body_hidden"]),ze=u(["CHAT_USER_MESSAGE_MAX_CHARS","CHAT_RUN_POLL_INTERVAL_MS","CHAT_RENDER_DIAGRAM_MAX_CHARS","CHAT_RENDER_DIAGRAM_MAX_EDGES","CHAT_RENDER_MAX_DIAGRAMS_PER_MESSAGE","CHAT_RENDER_DIAGRAM_CACHE_MAX_CHARS","CHAT_RENDER_HTML_CACHE_MAX_CHARS","CHAT_RENDER_HTML_MAX_BYTES","CHAT_RENDER_CONVERT_TIMEOUT_MS","CHAT_RENDER_LOAD_TIMEOUT_MS","CHAT_RENDER_MATH_MAX_SIZE_EM","CHAT_RENDER_MATH_MAX_EXPAND","CHAT_RENDER_LIST_OVERSCAN_ROWS","CHAT_RENDER_SMOOTH_HALF_LIFE_MS","CHAT_CONVERSATION_PAGE_SIZE","CHAT_TITLE_SEARCH_PAUSE_MS","CHAT_ATTACHMENT_MAX_COUNT","CHAT_ATTACHMENT_IMAGE_MAX_BYTES","CHAT_ATTACHMENT_PDF_MAX_BYTES","CHAT_ATTACHMENT_AUDIO_MAX_BYTES","CHAT_ATTACHMENT_AUDIO_MAX_SECONDS","CHAT_ATTACHMENT_POLL_INTERVAL_MS"]),fa=g.drawable_diagrams,m=u({run_states:["queued","running","awaiting_approval","completed","failed","cancelled"],active_run_states:["queued","running","awaiting_approval"],run_kinds:["send","edit","regenerate"],finish_reasons:["stop","length"],message_roles:["user","assistant"],reasoning_levels:["off","low","medium","high","max"],title_origins:["user","model"],confidentiality_levels:["PUBLIC","INTERNAL","DEPARTMENT","CONFIDENTIAL","RESTRICTED"],model_unavailable_reasons:["access_denied","classification","disabled","ledger_mismatch","config_invalid","credential_refused","stopped","breaker_open"],model_upstream_unavailable_reasons:["stopped","breaker_open"],processing_locations:["internal","external"],export_formats:["markdown","json"],language_codes:["ja","en"],notification_levels:["all","finish","none"],stream_displays:["smooth","immediate","on_finish"],message_actions_displays:["auto","always","hover"],send_keys:["enter","ctrl_enter"]}),Xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,ye=/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\.[0-9]{7}Z$/,$e=/[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/,Ke=e=>{let a=ye.exec(e);if(a===null)return!1;let[n,r,s,o,d,i]=a.slice(1).map(Number),c=new Date(0);return c.setUTCFullYear(n,r-1,s),c.setUTCHours(o,d,i,0),n>=1&&c.getUTCFullYear()===n&&c.getUTCMonth()===r-1&&c.getUTCDate()===s&&c.getUTCHours()===o&&c.getUTCMinutes()===d&&c.getUTCSeconds()===i},l=t.string().regex(Xe),R=t.string().regex(ye).refine(Ke,{message:"not a real instant"}),h=t.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),T=t.number().int().positive().max(Number.MAX_SAFE_INTEGER),G=e=>!$e.test(e),p=t.string().min(1).refine(G,{message:"a lone surrogate"}),C=t.string().refine(G,{message:"a lone surrogate"}),ce=p.refine(e=>($(e)??"")===e,{message:"white space at an end"}),ee=u(Object.keys(g.failure_codes)),Ze=t.enum(ee),_=t.object({}).strict(),te=u({CHAT_PROVIDER_FAILED:t.object({reason:t.enum(["rate_limited","quota_exhausted","auth_failed","timeout","error"]),retry:t.enum(["exhausted","withheld","no_time","none"]),retry_after_seconds:h.optional()}).strict(),CHAT_PROVIDER_REFUSED:_,CHAT_MODEL_UNAVAILABLE:t.object({reason:t.enum(["access_denied","classification","stopped","breaker_open","ledger_mismatch","config_invalid","credential_refused","reasoning_level_unavailable"])}).strict(),CHAT_ASSISTANT_UNAVAILABLE:_,CHAT_CONTEXT_OVERFLOW:_,CHAT_CONTEXT_CHANGED:_,CHAT_KNOWLEDGE_UNAVAILABLE:_,CHAT_KNOWLEDGE_BODY_HIDDEN:_,CHAT_KNOWLEDGE_SCOPE_TOO_LARGE:_,CHAT_RUN_LIMIT_REACHED:t.object({kind:t.enum(["steps","tool_calls","events","active_time"])}).strict(),CHAT_CONFIRM_LIMIT_REACHED:_,CHAT_CONFIDENTIALITY_BLOCKED:_,CHAT_BUDGET_EXCEEDED:t.union([t.object({scope:t.enum(["run"])}).strict(),t.object({scope:t.enum(["user","tenant"]),resets_at:R}).strict()]),CHAT_RUN_INTERRUPTED:_,CHAT_STOPPED_BY_ADMIN:_,CHAT_ACCESS_REVOKED:_,CHAT_TOOL_ARGS_INVALID:_,CHAT_TOOL_UNAVAILABLE:_,CHAT_TOOL_TIMEOUT:_,CHAT_SOURCE_BUSY:_,CHAT_TOOL_CONTRACT_ERROR:_,CHAT_TOOL_INTERRUPTED:_,CHAT_TOOL_RESULT_SHAPE_CHANGED:_,CHAT_EGRESS_DENIED:_}),Ye=t.object({loc:t.array(t.union([C,h])),msg:p,type:p}).strict(),Je=t.array(Ye).min(1),ue=t.object({errors:Je}).strict(),Ee=u({PERMISSION_DENIED:_,NOT_FOUND:t.object({resource:t.enum(["conversation","message","run","approval","source","tool","assistant","citation","attachment"])}).strict(),REQUEST_INVALID:ue,UPSTREAM_UNAVAILABLE:t.object({upstream:t.enum(["model","stream_store","attachment_store"])}).strict(),CONFIGURATION_ERROR:t.union([_,ue,t.object({reading:t.enum(["transcription","ocr"])}).strict()]),CHAT_POLICY_CONSENT_REQUIRED:_,CHAT_POLICY_NOT_PUBLISHED:_,CHAT_STATE_CONFLICT:t.union([t.object({kind:t.enum(["approval","branch","edit"])}).strict(),t.object({kind:t.enum(["attachment"]),reason:t.enum(["processing","failed","already_bound"])}).strict()]),CHAT_RUN_ACTIVE:_,CHAT_ADMISSION_BUSY:_,CHAT_CONCURRENCY_LIMIT:t.object({scope:t.enum(["user","tenant","model"])}).strict(),CHAT_RATE_LIMIT:_,CHAT_BUDGET_EXCEEDED:te.CHAT_BUDGET_EXCEEDED}),ya=u(["egress_denied","sql_statement_rejected","secret_in_text","individual_number_in_text","idempotency_key_reused","message_role","toggle_unknown","secret_name_unknown","reasoning_shape_invalid","reasoning_summary_unsupported","reasoning_level_unsupported","approval_stale_unconfirmed","model_unavailable","assistant_unavailable","declared_level_below_default","attachment_type_refused","attachment_too_large","attachment_too_many_pixels","attachment_too_many_pages","attachment_too_long","attachment_count_exceeded","attachment_unsupported_by_model","attachment_exceeds_provider_limit","attachment_unread_for_external_model"]),Ae=t.object({call:l,status:t.enum(["succeeded","failed","denied","cancelled","interrupted"]),error_code:Ze.nullable()}).strict(),Qe=t.object({input_tokens:h,output_tokens:h,cached_input_tokens:h,reasoning_tokens:h}).strict(),We=e=>t.object({error_code:t.literal(e),detail:te[e],retryable:t.boolean(),calls:t.array(Ae)}).strict(),et=ee.map(e=>We(e)),v=u({"run.started":t.object({run_uid:l,conversation_uid:l,assistant_message_uid:l,protocol:t.number().int().positive().max(Number.MAX_SAFE_INTEGER),model:t.object({model_uid:l,display_name:p}).strict(),started_at:R}).strict(),"step.started":t.object({step:T,kind:t.enum(["llm"])}).strict(),"step.retry":t.object({step:T,retry_no:t.number().int().positive().max(Number.MAX_SAFE_INTEGER),reason:t.enum(["rate_limited","timeout","error"]),wait_ms:h}).strict(),"text.delta":t.object({step:T,text:p}).strict(),"reasoning.delta":t.object({step:T,text:p}).strict(),usage:t.object({step:T,input_tokens:h,output_tokens:h,cached_input_tokens:h,reasoning_tokens:h,cost_micros:h}).strict(),"step.finished":t.object({step:T,finish_reason:t.enum(m.finish_reasons),reasoning_ms:h.optional()}).strict(),"step.reset":t.object({step:T}).strict(),"run.completed":t.object({finish_reason:t.enum(m.finish_reasons),usage_total:Qe,cost_total_micros:h}).strict(),"run.failed":t.discriminatedUnion("error_code",et),"run.cancelled":t.object({cancelled_by:t.enum(["user","admin"]),calls:t.array(Ae)}).strict(),"resync-required":t.object({}).strict()}),tt="resync-required",at=e=>Object.hasOwn(g.events,e),Ea=e=>g.events[e].terminal,Aa=u(Object.keys(g.events).filter(e=>g.events[e].start)),Ca=u(Object.keys(g.events).filter(e=>g.events[e].terminal)),ba=u(["unknown_event","reserved_data","too_deep","not_json","shape"]),B=g.data_max_depth,S=class extends Error{eventName;refusal;constructor(a,n,r){super(`chat event ${JSON.stringify(a)} refused (${n}): ${r}`),this.name="ChatEventRefusedError",this.eventName=a,this.refusal=n}},_e=34,nt=92,rt=new Set([91,123]),st=new Set([93,125]),ot=(e,a)=>{let n=0,r=!1,s=!1;for(let o=0;o<e.length;o+=1){let d=e.charCodeAt(o);if(r)s?s=!1:d===nt?s=!0:d===_e&&(r=!1);else if(d===_e)r=!0;else if(rt.has(d)){if(n+=1,n>a)return!0}else st.has(d)&&(n-=1)}return!1},Ta=(e,a)=>{if(!at(e))throw new S(e,"unknown_event","the contract names no such event");if(e===tt){if(a!=="")throw new S(e,"reserved_data","the reserved event carries no data");return{event:e,data:{}}}if(ot(a,B))throw new S(e,"too_deep",`data nests more than ${B} arrays and objects`);let n;try{n=JSON.parse(a)}catch{throw new S(e,"not_json","data is not JSON")}let r=v[e].safeParse(n);if(!r.success)throw new S(e,"shape",r.error.issues.map(s=>`${s.path.join(".")||"(root)"}: ${s.code}`).join("; "));return{event:e,data:r.data}},it=(e,a)=>{let n=new Set,r=e.replace(/\{([a-z_]+)\}/g,(o,d)=>{n.add(d);let i=a[d];if(i===void 0||i==="")throw new RangeError(`path ${e} needs a value for {${d}}`);return encodeURIComponent(i)}),s=Object.keys(a).filter(o=>!n.has(o));if(s.length>0)throw new RangeError(`path ${e} names no ${s.map(o=>`{${o}}`).join(", ")}`);return r},V=(e,a)=>({method:e.method,path:`${g.paths.base}${it(e.path,a)}`}),Sa=(e,a={})=>V(g.paths.json[e],a),Ra=(e,a={})=>V(g.paths.upload[e],a),va=(e,a)=>V(g.paths.content[e],a).path,xa=(e,a)=>V(g.paths.stream[e],a).path,dt=u({image:"supports_images",document:"supports_pdf",audio:"supports_audio"}),Oa=u(Object.keys(dt)),x=u({image:["image/png","image/jpeg","image/webp","image/gif"],document:["application/pdf"],audio:["audio/webm","audio/mp4","audio/wav","audio/mpeg","audio/ogg","audio/flac"]}),lt=u(["user","tool"]),ct=u(["processing","ready","failed"]),ut=u(["transcription_unavailable","ocr_unavailable","secret_in_text","individual_number_in_text"]),_t=u({image:["secret_in_text","individual_number_in_text"],document:["ocr_unavailable","secret_in_text","individual_number_in_text"],audio:["transcription_unavailable","secret_in_text","individual_number_in_text"]}),pt=u(["document","page_text"]),mt=/^[0-9a-f]{64}$/,ht=t.string().regex(mt),E=h.positive(),Ce=t.object({kind:t.literal("page"),page:E,source:t.enum(["text_layer","ocr"]),text:p}).strict(),be=t.object({kind:t.literal("segment"),start_ms:h,end_ms:h,source:t.enum(["transcription"]),text:p}).strict(),Te=t.object({kind:t.literal("image_text"),source:t.enum(["ocr"]),text:p}).strict(),qa=u({page:Ce,segment:be,image_text:Te}),O={attachment_uid:l,origin:t.enum(lt)},K={byte_size:E,sha256:ht,file_name:p,alt_text:p.nullable(),state:t.enum(ct),failure_tag:t.enum(ut).nullable(),expires_at:R.nullable()},Z={byte_size:E,file_name:p,alt_text:p.nullable()},q={image:{width:E,height:E,text_unread:t.boolean()},document:{page_count:E,unread_pages:t.array(E)},audio:{duration_ms:E}},Y=u({image:t.object({...O,kind:t.literal("image"),content_type:t.enum(x.image),...K,parts:t.array(Te),...q.image}).strict(),document:t.object({...O,kind:t.literal("document"),content_type:t.enum(x.document),...K,parts:t.array(Ce),...q.document}).strict(),audio:t.object({...O,kind:t.literal("audio"),content_type:t.enum(x.audio),...K,parts:t.array(be),...q.audio}).strict()}),J=u({image:t.object({...O,kind:t.literal("image"),content_type:t.enum(x.image),...Z,...q.image}).strict(),document:t.object({...O,kind:t.literal("document"),content_type:t.enum(x.document),...Z,...q.document}).strict(),audio:t.object({...O,kind:t.literal("audio"),content_type:t.enum(x.audio),...Z,...q.audio}).strict()}),f=e=>(a,n)=>e.addIssue({code:t.ZodIssueCode.custom,path:[...a],message:n}),Se=(e,a,n)=>{let r=0;for(let[s,o]of e.entries())o>a?n(["unread_pages",s],"past the last page"):o<=r&&n(["unread_pages",s],"not after the page before it"),r=o},gt=(e,a,n,r)=>{let s=new Set(n),o=0;for(let[d,i]of e.entries())i.page>a?r(["parts",d,"page"],"past the last page"):i.page<o?r(["parts",d,"page"],"before the page of the part before it"):s.has(i.page)&&r(["parts",d,"page"],"a page named unread"),o=i.page},ft=(e,a,n)=>{let r=0;for(let[s,o]of e.entries())o.end_ms<o.start_ms?n(["parts",s,"end_ms"],"before its start"):o.end_ms>a&&n(["parts",s,"end_ms"],"past the end of the audio"),o.start_ms<r&&n(["parts",s,"start_ms"],"before the start of the segment before it"),r=o.start_ms},yt=(e,a)=>{let n=f(a);switch(e.state==="failed"!=(e.failure_tag!==null)&&n(["failure_tag"],"a failure tag goes with the failed state and with no other"),e.failure_tag!==null&&!_t[e.kind].includes(e.failure_tag)&&n(["failure_tag"],"a failure tag the kind does not fail with"),e.state!=="ready"&&e.parts.length>0&&n(["parts"],"only a ready attachment holds read text"),e.kind){case"image":e.parts.length>1&&n(["parts"],"an image holds one read text at most"),e.text_unread&&(e.state!=="ready"&&n(["text_unread"],"only a ready attachment marks its text unread"),e.parts.length>0&&n(["text_unread"],"an image marked unread holds no read text"));break;case"document":e.state!=="ready"&&e.unread_pages.length>0&&n(["unread_pages"],"only a ready attachment names unread pages"),Se(e.unread_pages,e.page_count,n),gt(e.parts,e.page_count,e.unread_pages,n);break;case"audio":ft(e.parts,e.duration_ms,n);break}},Et=t.discriminatedUnion("kind",[Y.image,Y.document,Y.audio]).superRefine(yt),At=t.discriminatedUnion("kind",[J.image,J.document,J.audio]).superRefine((e,a)=>{e.kind==="document"&&Se(e.unread_pages,e.page_count,f(a))}),z=(e,a,n)=>{let r=new Set;for(let[s,o]of e.entries())r.has(o)&&a(n(s),"given twice"),r.add(o)},Ct=t.array(l).superRefine((e,a)=>z(e,f(a),n=>[n])),bt=t.array(At).superRefine((e,a)=>z(e.map(n=>n.attachment_uid),f(a),n=>[n,"attachment_uid"])),F=u({message:{attachments:bt},message_request:{attachment_ids:Ct},model:{supports_images:t.boolean(),supports_pdf:t.boolean(),supports_audio:t.boolean(),pdf_delivery:t.enum(pt).nullable()}}),Tt=(e,a)=>{e.supports_pdf!==(e.pdf_delivery!==null)&&f(a)(["pdf_delivery"],"how a model takes a PDF goes with its flag for PDFs and with nothing else")},St=t.object({model_uid:l,file_name:p,alt_text:p.optional(),file:t.instanceof(Blob)}).strict(),Rt=t.object({alt_text:p.nullable()}).strict(),vt=/^[A-Za-z0-9_-]{1,1024}$/,xt=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,Re=/^(0|[1-9][0-9]{0,19})-(0|[1-9][0-9]{0,19})$/,Ot=(1n<<64n)-1n,N=t.string().regex(vt),L=t.string().regex(xt),qt=e=>{let a=Re.exec(e);return a===null?!1:a.slice(1).every(n=>BigInt(n)<=Ot)},Nt=t.string().regex(Re).refine(qt,{message:"a part above 64 bits"}).brand(),Ft=t.object({step:T,kind:v["step.started"].shape.kind,text:C,reasoning:C,usage:v.usage.omit({step:!0}).nullable(),finish:v["step.finished"].omit({step:!0}).nullable()}).strict(),ae=(e,a,n)=>{for(let[r,s]of e.steps.entries()){let o=e.steps[r-1];a.order&&o!==void 0&&o.step>=s.step&&n(["steps",r,"step"],"the seed's steps are not in increasing order of their numbers"),a.mark&&e.mark===null&&(s.text!==""||s.reasoning!=="")&&n(["steps",r],"a seed without a mark holds a step's text or reasoning")}},ve=t.object({mark:Nt.nullable(),started:v["run.started"].nullable(),steps:t.array(Ft)}).strict(),Ht=ve.superRefine((e,a)=>ae(e,{order:!0,mark:!1},f(a))),Na=ve.superRefine((e,a)=>ae(e,{order:!0,mark:!0},f(a))),Ut=t.object({run_uid:l,state:t.enum(m.active_run_states)}).strict(),ne=t.object({conversation_uid:l,title:p.nullable(),title_origin:t.enum(m.title_origins).nullable(),model_uid:l,reasoning_level:t.enum(m.reasoning_levels),declared_level:t.enum(m.confidentiality_levels),pinned:t.boolean(),last_activity_at:R,purge_due_at:R.nullable(),active_root_message_uid:l,active_run:Ut.nullable(),created_at:R}).strict().superRefine((e,a)=>{e.title===null!=(e.title_origin===null)&&f(a)(["title_origin"],"a title and its origin are null together")}),xe=e=>t.object({items:t.array(e),next_cursor:N.nullable()}).strict(),It=xe(ne),Dt=e=>t.object({error_code:t.literal(e),detail:te[e]}).strict(),kt=t.discriminatedUnion("error_code",ee.map(e=>Dt(e))),wt=t.object({model_uid:l,display_name:p.nullable()}).strict(),Mt=t.object({run_uid:l,model:wt,state:t.enum(m.run_states),segment_no:E,finish_reason:t.enum(m.finish_reasons).nullable(),failure:kt.nullable(),cancelled_by:v["run.cancelled"].shape.cancelled_by.nullable(),stream_open:t.boolean(),view:Ht}).strict().superRefine((e,a)=>{let n=f(a);e.state==="completed"!=(e.finish_reason!==null)&&n(["finish_reason"],"a run's finish reason goes with its completed state and with nothing else"),e.state==="failed"!=(e.failure!==null)&&n(["failure"],"a run's failure goes with its failed state and with nothing else"),e.state==="cancelled"!=(e.cancelled_by!==null)&&n(["cancelled_by"],"who cancelled a run goes with its cancelled state and with nothing else"),e.stream_open&&ae(e.view,{order:!1,mark:!0},(r,s)=>n(["view",...r],s))}),pe={message_uid:l,conversation_uid:l,parent_message_uid:l.nullable()},me={created_at:R,active_child_message_uid:l.nullable(),sibling_message_uids:t.array(l),...F.message},he=u({user:t.object({...pe,role:t.literal("user"),text:C,...me}).strict(),assistant:t.object({...pe,role:t.literal("assistant"),text:C,...me,context_cut_before:l.nullable(),run:Mt}).strict()}),Lt=(e,a)=>{let n=f(a);z(e.sibling_message_uids,n,r=>["sibling_message_uids",r]),e.sibling_message_uids.includes(e.message_uid)||n(["sibling_message_uids"],"a message is one of its siblings"),e.role==="user"&&e.text===""&&e.attachments.length===0&&n(["text"],"a message without text holds an attachment")},Oe=t.discriminatedUnion("role",[he.user,he.assistant]).superRefine(Lt),jt=xe(Oe),j={model_uid:l,reasoning_level:t.enum(m.reasoning_levels)},Q=u({send:t.object({kind:t.literal("send"),client_request_id:L,parent_message_uid:l,text:C,...F.message_request,...j}).strict(),edit:t.object({kind:t.literal("edit"),client_request_id:L,target_message_uid:l,text:C,...F.message_request,...j}).strict(),regenerate:t.object({kind:t.literal("regenerate"),client_request_id:L,target_message_uid:l,...j}).strict()}),qe=(e,a)=>{e.text===""&&e.attachment_ids.length===0&&a(["text"],"a message without text binds an attachment")},Pt=t.discriminatedUnion("kind",[Q.send,Q.edit,Q.regenerate]).superRefine((e,a)=>{e.kind!=="regenerate"&&qe(e,f(a))}),Ne=t.object({run_uid:l,user_message_uid:l.nullable(),assistant_message_uid:l}).strict(),Bt=t.object({client_request_id:L,text:C,...F.message_request,...j,declared_level:t.enum(m.confidentiality_levels)}).strict().superRefine((e,a)=>qe(e,f(a))),Gt=t.object({conversation:ne,run:Ne.extend({user_message_uid:l})}).strict(),Vt=t.object({run_uid:l,conversation_uid:l,assistant_message_uid:l,state:t.enum(m.run_states),segment_no:E}).strict(),Fe=t.object({language_code:t.enum(m.language_codes),notification_level:t.enum(m.notification_levels),stream_display:t.enum(m.stream_displays),follow_scroll:t.boolean(),reduce_motion:t.boolean(),message_actions_display:t.enum(m.message_actions_displays),collapse_action_labels:t.boolean(),send_key:t.enum(m.send_keys),default_model_uid:l.nullable()}).strict(),zt=Fe.partial().superRefine((e,a)=>{Object.values(e).every(n=>n===void 0)&&f(a)([],"no setting; an update names at least one setting it changes")}),Xt=t.object({model_uid:l.nullable(),declared_level:t.enum(m.confidentiality_levels)}).strict(),$t=t.object(Object.fromEntries(ze.map(e=>[e,E]))).strict(),Kt=t.object({user_settings:Fe,conversation_defaults:Xt,limits:$t}).strict(),Zt=t.object({calls:h,failures:h}).strict().superRefine((e,a)=>{e.failures>e.calls&&f(a)(["failures"],"more failures than calls")}),Yt=(e,a)=>{let n=-1;for(let[r,s]of e.reasoning_levels.entries()){let o=m.reasoning_levels.indexOf(s);o<=n&&a(["reasoning_levels",r],"not after the level before it in the vocabulary's order"),n=o}e.reasoning_levels.includes(e.default_reasoning_level)||a(["default_reasoning_level"],"not one of the model's reasoning levels")},Jt=t.object({model_uid:l,display_name:p,unavailable_reason:t.enum(m.model_unavailable_reasons).exclude(["access_denied"]).nullable(),reasoning_levels:t.array(t.enum(m.reasoning_levels)).min(1),default_reasoning_level:t.enum(m.reasoning_levels),reasoning_summary:t.boolean(),supports_tools:t.boolean(),...F.model,context_window_tokens:E,max_output_tokens:E,processing_location:t.enum(m.processing_locations),processing_countries:p,storage_countries:p,used_for_training:t.boolean(),retention_days:h,contract_terms:p,recent_failures:Zt.nullable()}).strict().superRefine((e,a)=>{Tt(e,a),Yt(e,f(a))}),Qt=t.object({model_uid:l,unavailable_reason:t.literal("access_denied")}).strict(),Wt=t.object({items:t.array(t.union([Jt,Qt]))}).strict().superRefine((e,a)=>{let n=f(a);for(let[r,s]of e.items.entries())r>0&&s.unavailable_reason==="access_denied"&&n(["items",r],"a hidden row comes first");z(e.items.map(r=>r.model_uid),n,r=>["items",r,"model_uid"])}),He=new Map(Object.keys(g.business_codes).map(e=>[g.business_codes[e].number,e])),P="a value no JSON text reads as",ea=(e,a)=>{let n=e.length,r=Reflect.ownKeys(e).length-1;return n!==r?{kind:"problem",message:P}:{kind:"array",source:e,length:r,depth:a,copy:[],next:0}},ge=(e,a)=>{let n=[];for(let r of Reflect.ownKeys(e)){if(typeof r=="symbol")return{kind:"problem",message:"a member name that is not a text"};if(!G(r))return{kind:"problem",message:"a lone surrogate"};n.push(r)}return{kind:"object",source:e,names:n,depth:a,copy:{},next:0}},ta=e=>{let a=e.kind==="array"?e.length:e.names.length;if(e.next===a)return;let n=e.next;return e.next+=1,e.kind==="array"?n:e.names[n]},fe=(e,a,n)=>{Object.defineProperty(e,a,{__proto__:null,value:n,writable:!0,enumerable:!0,configurable:!0})},aa=e=>{if(!M(e))return{kind:"problem",message:"not a JSON object"};let a=ge(e,1);if(a.kind==="problem")return a;let n=le(4194304);n.add(e);let r=[a];for(let s=r.at(-1);s!==void 0;s=r.at(-1)){let o=ta(s);if(o===void 0){r.pop();continue}let d=Object.getOwnPropertyDescriptor(s.source,o);if(d===void 0||d.enumerable!==!0||!Object.hasOwn(d,"value"))return{kind:"problem",message:P};let i=d.value;if(typeof i=="string"&&!G(i))return{kind:"problem",message:"a lone surrogate"};if(typeof i=="number"&&!(Math.abs(i)<=Number.MAX_SAFE_INTEGER))return{kind:"problem",message:`a number outside \xB1${Number.MAX_SAFE_INTEGER}`};if(i===null||typeof i=="string"||typeof i=="number"||typeof i=="boolean"){fe(s.copy,o,i);continue}if(typeof i!="object")return{kind:"problem",message:P};if(n.has(i))return{kind:"problem",message:"an array or object held twice"};if(!(Array.isArray(i)||M(i)))return{kind:"problem",message:P};n.add(i);let c=s.depth+1;if(c>B)return{kind:"problem",message:`nests more than ${B} arrays and objects`};let y=Array.isArray(i)?ea(i,c):ge(i,c);if(y.kind==="problem")return y;fe(s.copy,o,y.copy),r.push(y)}return{kind:"copy",copy:a.copy}},na=t.object({error_code:h,error_msg:p,request_id:p,detail:t.unknown(),failed_stage:p.optional()}).strict(),W=(e,a)=>{for(let n of a)e.addIssue({...n,path:n.path.slice(e.path.length),fatal:!0})},Fa=na.transform((e,a)=>{let{detail:n,...r}=e;if(n===void 0)return r;let s={path:[...a.path,"detail"]};if(typeof n=="string"){let i=C.safeParse(n,s);return i.success?{...e,detail:n}:(W(a,i.error.issues),t.NEVER)}let o=aa(n);if(o.kind==="problem")return W(a,[{code:t.ZodIssueCode.custom,path:s.path,message:o.message}]),t.NEVER;let d=He.get(e.error_code);if(d!==void 0){let c=Ee[d].safeParse(o.copy,s);if(!c.success)return W(a,c.error.issues),t.NEVER}return{...e,detail:o.copy}}),Ha=e=>{let a=He.get(e.error_code);if(a===void 0)return null;let n=Ee[a],r=typeof e.detail=="object"?n.parse(e.detail):null;return{name:a,detail:r}},ra=u({listConversations:t.object({cursor:N.optional(),until:N.optional(),q:ce.optional(),pinned:t.boolean().optional()}).strict().superRefine((e,a)=>{e.cursor!==void 0&&e.until!==void 0&&f(a)(["until"],"the rows after a cursor or the rows before one, not both")}),listMessages:t.object({cursor:N.optional()}).strict(),getMessagePath:t.object({cursor:N.optional()}).strict(),searchConversation:t.object({q:ce}).strict(),exportConversation:t.object({format:t.enum(m.export_formats)}).strict(),listModels:t.object({conversation_uid:l.optional(),declared_level:t.enum(m.confidentiality_levels).optional()}).strict().superRefine((e,a)=>{e.conversation_uid!==void 0&&e.declared_level!==void 0&&f(a)(["declared_level"],"a conversation's list or a new conversation's, not both")})}),Ua=(e,a)=>{let r=ra[e].parse(a),s=new URLSearchParams;for(let d of Object.keys(g.queries[e])){let i=r[d];i!==void 0&&s.append(d,String(i))}let o=s.toString();return o===""?"":`?${o}`},Ia=u({listConversations:{status:200,body:null,answer:"conversation_page"},createConversation:{status:201,body:"conversation_request",answer:"conversation_accepted"},getConversation:{status:200,body:null,answer:"conversation"},listMessages:{status:200,body:null,answer:"message_page"},getMessage:{status:200,body:null,answer:"message"},getMessagePath:{status:200,body:null,answer:"message_page"},startRun:{status:202,body:"run_request",answer:"run_accepted"},getRun:{status:200,body:null,answer:"run"},cancelRun:{status:200,body:null,answer:"run"},listModels:{status:200,body:null,answer:"model_list"},getSettings:{status:200,body:null,answer:"settings"},updateSettings:{status:200,body:"user_settings_update",answer:"settings"},getAttachment:{status:200,body:null,answer:"attachment"},updateAttachment:{status:200,body:"attachment_update",answer:"attachment"},deleteAttachment:{status:204,body:null,answer:null},createAttachment:{status:201,body:"attachment_upload",answer:"attachment"}}),Da=u({conversation_page:It,conversation_request:Bt,conversation_accepted:Gt,conversation:ne,message_page:jt,message:Oe,run_request:Pt,run_accepted:Ne,run:Vt,model_list:Wt,settings:Kt,user_settings_update:zt,attachment:Et,attachment_update:Rt,attachment_upload:St});export{u as a,de as b,Be as c,Ge as d,$ as e,g as f,ha as g,ga as h,ze as i,fa as j,m as k,l,R as m,h as n,T as o,p,C as q,ce as r,ee as s,Ze as t,te as u,Ye as v,Je as w,Ee as x,ya as y,Ae as z,v as A,tt as B,at as C,Ea as D,Aa as E,Ca as F,ba as G,B as H,S as I,Ta as J,Sa as K,Ra as L,va as M,xa as N,dt as O,Oa as P,x as Q,lt as R,ct as S,ut as T,_t as U,pt as V,ht as W,Ce as X,be as Y,Te as Z,qa as _,Y as $,J as aa,Et as ba,At as ca,Ct as da,bt as ea,F as fa,Tt as ga,St as ha,Rt as ia,N as ja,L as ka,Nt as la,Ft as ma,Ht as na,Na as oa,Ut as pa,ne as qa,It as ra,kt as sa,wt as ta,Mt as ua,he as va,Oe as wa,jt as xa,Q as ya,Pt as za,Ne as Aa,Bt as Ba,Gt as Ca,Vt as Da,Fe as Ea,zt as Fa,Xt as Ga,$t as Ha,Kt as Ia,Zt as Ja,Jt as Ka,Qt as La,Wt as Ma,Fa as Na,Ha as Oa,ra as Pa,Ua as Qa,Ia as Ra,Da as Sa};
|