tempest.games 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/app/assets/index-3KvDLshg.js +109 -0
- package/app/assets/index-B2F2ZwG-.css +1 -0
- package/app/index.html +2 -2
- package/bin/backend.bun.js +211 -211
- package/bin/backend.worker.tribunal.bun.js +1 -1
- package/bin/frontend.bun.js +8 -8
- package/bin/setup-db.bun.js +50 -50
- package/package.json +11 -10
- package/app/assets/index-C6lk2a-1.css +0 -1
- package/app/assets/index-D9sd7NK-.js +0 -109
|
@@ -11,7 +11,7 @@ ${H.trace}`:"No previous disposal trace was found."),Y.type){case"atom_family":c
|
|
|
11
11
|
`,JSON.stringify(T,null,"\t"),`
|
|
12
12
|
`,`Here are the issues returned from our validation:
|
|
13
13
|
`,JSON.stringify(M.issues,null,"\t")),U.push({response:T,error:M})}return $?.error(`safegen was unable to generate well-formed data after ${F} failed attempts.`),J}}}function R3(W){return["Please generate a response in JSON that conforms to the following JSON Schema:",JSON.stringify(W,null,2)].join(`
|
|
14
|
-
`)}var VX="RFC3986",KX={RFC1738:(W)=>String(W).replace(/%20/g,"+"),RFC3986:(W)=>String(W)},B3="RFC1738";var UD=Array.isArray,xW=(()=>{let W=[];for(let $=0;$<256;++$)W.push("%"+(($<16?"0":"")+$.toString(16)).toUpperCase());return W})();var m9=1024,Z3=(W,$,X,Y,J)=>{if(W.length===0)return W;let G=W;if(typeof W==="symbol")G=Symbol.prototype.toString.call(W);else if(typeof W!=="string")G=String(W);if(X==="iso-8859-1")return escape(G).replace(/%u[0-9a-f]{4}/gi,function(Q){return"%26%23"+parseInt(Q.slice(2),16)+"%3B"});let H="";for(let Q=0;Q<G.length;Q+=m9){let z=G.length>=m9?G.slice(Q,Q+m9):G,F=[];for(let T=0;T<z.length;++T){let U=z.charCodeAt(T);if(U===45||U===46||U===95||U===126||U>=48&&U<=57||U>=65&&U<=90||U>=97&&U<=122||J===B3&&(U===40||U===41)){F[F.length]=z.charAt(T);continue}if(U<128){F[F.length]=xW[U];continue}if(U<2048){F[F.length]=xW[192|U>>6]+xW[128|U&63];continue}if(U<55296||U>=57344){F[F.length]=xW[224|U>>12]+xW[128|U>>6&63]+xW[128|U&63];continue}T+=1,U=65536+((U&1023)<<10|z.charCodeAt(T)&1023),F[F.length]=xW[240|U>>18]+xW[128|U>>12&63]+xW[128|U>>6&63]+xW[128|U&63]}H+=F.join("")}return H};function S3(W){if(!W||typeof W!=="object")return!1;return!!(W.constructor&&W.constructor.isBuffer&&W.constructor.isBuffer(W))}function p9(W,$){if(UD(W)){let X=[];for(let Y=0;Y<W.length;Y+=1)X.push($(W[Y]));return X}return $(W)}var wD=Object.prototype.hasOwnProperty,q3={brackets(W){return String(W)+"[]"},comma:"comma",indices(W,$){return String(W)+"["+$+"]"},repeat(W){return String(W)}},vW=Array.isArray,MD=Array.prototype.push,C3=function(W,$){MD.apply(W,vW($)?$:[$])},_D=Date.prototype.toISOString,$1={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Z3,encodeValuesOnly:!1,format:VX,formatter:KX[VX],indices:!1,serializeDate(W){return _D.call(W)},skipNulls:!1,strictNullHandling:!1};function DD(W){return typeof W==="string"||typeof W==="number"||typeof W==="boolean"||typeof W==="symbol"||typeof W==="bigint"}var u9={};function k3(W,$,X,Y,J,G,H,Q,z,F,T,U,M,O,K,N,I,C){let R=W,q=C,m=0,c=!1;while((q=q.get(u9))!==void 0&&!c){let E=q.get(W);if(m+=1,typeof E!=="undefined")if(E===m)throw new RangeError("Cyclic object value");else c=!0;if(typeof q.get(u9)==="undefined")m=0}if(typeof F==="function")R=F($,R);else if(R instanceof Date)R=M?.(R);else if(X==="comma"&&vW(R))R=p9(R,function(E){if(E instanceof Date)return M?.(E);return E});if(R===null){if(G)return z&&!N?z($,$1.encoder,I,"key",O):$;R=""}if(DD(R)||S3(R)){if(z){let E=N?$:z($,$1.encoder,I,"key",O);return[K?.(E)+"="+K?.(z(R,$1.encoder,I,"value",O))]}return[K?.($)+"="+K?.(String(R))]}let v=[];if(typeof R==="undefined")return v;let h;if(X==="comma"&&vW(R)){if(N&&z)R=p9(R,z);h=[{value:R.length>0?R.join(",")||null:void 0}]}else if(vW(F))h=F;else{let E=Object.keys(R);h=T?E.sort(T):E}let U0=Q?String($).replace(/\./g,"%2E"):String($),m0=Y&&vW(R)&&R.length===1?U0+"[]":U0;if(J&&vW(R)&&R.length===0)return m0+"[]";for(let E=0;E<h.length;++E){let _0=h[E],e=typeof _0==="object"&&typeof _0.value!=="undefined"?_0.value:R[_0];if(H&&e===null)continue;let w0=U&&Q?_0.replace(/\./g,"%2E"):_0,s0=vW(R)?typeof X==="function"?X(m0,w0):m0:m0+(U?"."+w0:"["+w0+"]");C.set(W,m);let D1=new WeakMap;D1.set(u9,C),C3(v,k3(e,s0,X,Y,J,G,H,Q,X==="comma"&&N&&vW(R)?null:z,F,T,U,M,O,K,N,I,D1))}return v}function OD(W=$1){if(typeof W.allowEmptyArrays!=="undefined"&&typeof W.allowEmptyArrays!=="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof W.encodeDotInKeys!=="undefined"&&typeof W.encodeDotInKeys!=="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(W.encoder!==null&&typeof W.encoder!=="undefined"&&typeof W.encoder!=="function")throw new TypeError("Encoder has to be a function.");let $=W.charset||$1.charset;if(typeof W.charset!=="undefined"&&W.charset!=="utf-8"&&W.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let X=VX;if(typeof W.format!=="undefined"){if(!wD.call(KX,W.format))throw new TypeError("Unknown format option provided.");X=W.format}let Y=KX[X],J=$1.filter;if(typeof W.filter==="function"||vW(W.filter))J=W.filter;let G;if(W.arrayFormat&&W.arrayFormat in q3)G=W.arrayFormat;else if("indices"in W)G=W.indices?"indices":"repeat";else G=$1.arrayFormat;if("commaRoundTrip"in W&&typeof W.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let H=typeof W.allowDots==="undefined"?!!W.encodeDotInKeys===!0?!0:$1.allowDots:!!W.allowDots;return{addQueryPrefix:typeof W.addQueryPrefix==="boolean"?W.addQueryPrefix:$1.addQueryPrefix,allowDots:H,allowEmptyArrays:typeof W.allowEmptyArrays==="boolean"?!!W.allowEmptyArrays:$1.allowEmptyArrays,arrayFormat:G,charset:$,charsetSentinel:typeof W.charsetSentinel==="boolean"?W.charsetSentinel:$1.charsetSentinel,commaRoundTrip:!!W.commaRoundTrip,delimiter:typeof W.delimiter==="undefined"?$1.delimiter:W.delimiter,encode:typeof W.encode==="boolean"?W.encode:$1.encode,encodeDotInKeys:typeof W.encodeDotInKeys==="boolean"?W.encodeDotInKeys:$1.encodeDotInKeys,encoder:typeof W.encoder==="function"?W.encoder:$1.encoder,encodeValuesOnly:typeof W.encodeValuesOnly==="boolean"?W.encodeValuesOnly:$1.encodeValuesOnly,filter:J,format:X,formatter:Y,serializeDate:typeof W.serializeDate==="function"?W.serializeDate:$1.serializeDate,skipNulls:typeof W.skipNulls==="boolean"?W.skipNulls:$1.skipNulls,sort:typeof W.sort==="function"?W.sort:null,strictNullHandling:typeof W.strictNullHandling==="boolean"?W.strictNullHandling:$1.strictNullHandling}}function c9(W,$={}){let X=W,Y=OD($),J,G;if(typeof Y.filter==="function")G=Y.filter,X=G("",X);else if(vW(Y.filter))G=Y.filter,J=G;let H=[];if(typeof X!=="object"||X===null)return"";let Q=q3[Y.arrayFormat],z=Q==="comma"&&Y.commaRoundTrip;if(!J)J=Object.keys(X);if(Y.sort)J.sort(Y.sort);let F=new WeakMap;for(let M=0;M<J.length;++M){let O=J[M];if(Y.skipNulls&&X[O]===null)continue;C3(H,k3(X[O],O,Q,z,Y.allowEmptyArrays,Y.strictNullHandling,Y.skipNulls,Y.encodeDotInKeys,Y.encode?Y.encoder:null,Y.filter,Y.sort,Y.allowDots,Y.serializeDate,Y.format,Y.formatter,Y.encodeValuesOnly,Y.charset,F))}let T=H.join(Y.delimiter),U=Y.addQueryPrefix===!0?"?":"";if(Y.charsetSentinel)if(Y.charset==="iso-8859-1")U+="utf8=%26%2310003%3B&";else U+="utf8=%E2%9C%93&";return T.length>0?U+T:""}var o2="4.96.2";var I3=!1,i2=void 0,d9=void 0,KD=void 0,LD=void 0,AD=void 0,l9=void 0,ED=void 0,LX=void 0,o9=void 0,i9=void 0,n9=void 0,AX=void 0,r9=void 0;function j3(W,$={auto:!1}){if(I3)throw new Error(`you must \`import 'openai/shims/${W.kind}'\` before importing anything else from openai`);if(i2)throw new Error(`can't \`import 'openai/shims/${W.kind}'\` after \`import 'openai/shims/${i2}'\``);I3=$.auto,i2=W.kind,d9=W.fetch,KD=W.Request,LD=W.Response,AD=W.Headers,l9=W.FormData,ED=W.Blob,LX=W.File,o9=W.ReadableStream,i9=W.getMultipartRequestOptions,n9=W.getDefaultAgent,AX=W.fileFromPath,r9=W.isFsReadStream}class t9{constructor(W){this.body=W}get[Symbol.toStringTag](){return"MultipartBody"}}function f3({manuallyImported:W}={}){let $=W?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n",X,Y,J,G;try{X=fetch,Y=Request,J=Response,G=Headers}catch(H){throw new Error(`this environment is missing the following Web Fetch API type: ${H.message}. ${$}`)}return{kind:"web",fetch:X,Request:Y,Response:J,Headers:G,FormData:typeof FormData!=="undefined"?FormData:class H{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${$}`)}},Blob:typeof Blob!=="undefined"?Blob:class H{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${$}`)}},File:typeof File!=="undefined"?File:class H{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${$}`)}},ReadableStream:typeof ReadableStream!=="undefined"?ReadableStream:class H{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${$}`)}},getMultipartRequestOptions:async(H,Q)=>({...Q,body:new t9(H)}),getDefaultAgent:(H)=>{return},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:(H)=>!1}}import{ReadStream as RD}from"fs";function P3(){let W=f3();function $(X){return X instanceof RD}return{...W,isFsReadStream:$}}var a9=()=>{if(!i2)j3(P3(),{auto:!0})};a9();class o extends Error{}class r0 extends o{constructor(W,$,X,Y){super(`${r0.makeMessage(W,$,X)}`);this.status=W,this.headers=Y,this.request_id=Y?.["x-request-id"],this.error=$;let J=$;this.code=J?.code,this.param=J?.param,this.type=J?.type}static makeMessage(W,$,X){let Y=$?.message?typeof $.message==="string"?$.message:JSON.stringify($.message):$?JSON.stringify($):X;if(W&&Y)return`${W} ${Y}`;if(W)return`${W} status code (no body)`;if(Y)return Y;return"(no status code or body)"}static generate(W,$,X,Y){if(!W||!Y)return new n2({message:X,cause:kX($)});let J=$?.error;if(W===400)return new EX(W,J,X,Y);if(W===401)return new NX(W,J,X,Y);if(W===403)return new RX(W,J,X,Y);if(W===404)return new BX(W,J,X,Y);if(W===409)return new ZX(W,J,X,Y);if(W===422)return new SX(W,J,X,Y);if(W===429)return new qX(W,J,X,Y);if(W>=500)return new CX(W,J,X,Y);return new r0(W,J,X,Y)}}class X1 extends r0{constructor({message:W}={}){super(void 0,void 0,W||"Request was aborted.",void 0)}}class n2 extends r0{constructor({message:W,cause:$}){super(void 0,void 0,W||"Connection error.",void 0);if($)this.cause=$}}class r2 extends n2{constructor({message:W}={}){super({message:W??"Request timed out."})}}class EX extends r0{}class NX extends r0{}class RX extends r0{}class BX extends r0{}class ZX extends r0{}class SX extends r0{}class qX extends r0{}class CX extends r0{}class U4 extends o{constructor(){super("Could not parse response content as the length limit was reached")}}class w4 extends o{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var IX=function(W,$,X,Y,J){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!J)throw new TypeError("Private accessor was defined without a setter");if(typeof $==="function"?W!==$||!J:!$.has(W))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?J.call(W,X):J?J.value=X:$.set(W,X),X},t2=function(W,$,X,Y){if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof $==="function"?W!==$||!Y:!$.has(W))throw new TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call(W):Y?Y.value:$.get(W)},o1;class m8{constructor(){o1.set(this,void 0),this.buffer=new Uint8Array,IX(this,o1,null,"f")}decode(W){if(W==null)return[];let $=W instanceof ArrayBuffer?new Uint8Array(W):typeof W==="string"?new TextEncoder().encode(W):W,X=new Uint8Array(this.buffer.length+$.length);X.set(this.buffer),X.set($,this.buffer.length),this.buffer=X;let Y=[],J;while((J=ZD(this.buffer,t2(this,o1,"f")))!=null){if(J.carriage&&t2(this,o1,"f")==null){IX(this,o1,J.index,"f");continue}if(t2(this,o1,"f")!=null&&(J.index!==t2(this,o1,"f")+1||J.carriage)){Y.push(this.decodeText(this.buffer.slice(0,t2(this,o1,"f")-1))),this.buffer=this.buffer.slice(t2(this,o1,"f")),IX(this,o1,null,"f");continue}let G=t2(this,o1,"f")!==null?J.preceding-1:J.preceding,H=this.decodeText(this.buffer.slice(0,G));Y.push(H),this.buffer=this.buffer.slice(J.index),IX(this,o1,null,"f")}return Y}decodeText(W){if(W==null)return"";if(typeof W==="string")return W;if(typeof Buffer!=="undefined"){if(W instanceof Buffer)return W.toString();if(W instanceof Uint8Array)return Buffer.from(W).toString();throw new o(`Unexpected: received non-Uint8Array (${W.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder!=="undefined"){if(W instanceof Uint8Array||W instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(W);throw new o(`Unexpected: received non-Uint8Array/ArrayBuffer (${W.constructor.name}) in a web platform. Please report this error.`)}throw new o("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
14
|
+
`)}var VX="RFC3986",KX={RFC1738:(W)=>String(W).replace(/%20/g,"+"),RFC3986:(W)=>String(W)},B3="RFC1738";var UD=Array.isArray,xW=(()=>{let W=[];for(let $=0;$<256;++$)W.push("%"+(($<16?"0":"")+$.toString(16)).toUpperCase());return W})();var m9=1024,Z3=(W,$,X,Y,J)=>{if(W.length===0)return W;let G=W;if(typeof W==="symbol")G=Symbol.prototype.toString.call(W);else if(typeof W!=="string")G=String(W);if(X==="iso-8859-1")return escape(G).replace(/%u[0-9a-f]{4}/gi,function(Q){return"%26%23"+parseInt(Q.slice(2),16)+"%3B"});let H="";for(let Q=0;Q<G.length;Q+=m9){let z=G.length>=m9?G.slice(Q,Q+m9):G,F=[];for(let T=0;T<z.length;++T){let U=z.charCodeAt(T);if(U===45||U===46||U===95||U===126||U>=48&&U<=57||U>=65&&U<=90||U>=97&&U<=122||J===B3&&(U===40||U===41)){F[F.length]=z.charAt(T);continue}if(U<128){F[F.length]=xW[U];continue}if(U<2048){F[F.length]=xW[192|U>>6]+xW[128|U&63];continue}if(U<55296||U>=57344){F[F.length]=xW[224|U>>12]+xW[128|U>>6&63]+xW[128|U&63];continue}T+=1,U=65536+((U&1023)<<10|z.charCodeAt(T)&1023),F[F.length]=xW[240|U>>18]+xW[128|U>>12&63]+xW[128|U>>6&63]+xW[128|U&63]}H+=F.join("")}return H};function S3(W){if(!W||typeof W!=="object")return!1;return!!(W.constructor&&W.constructor.isBuffer&&W.constructor.isBuffer(W))}function p9(W,$){if(UD(W)){let X=[];for(let Y=0;Y<W.length;Y+=1)X.push($(W[Y]));return X}return $(W)}var wD=Object.prototype.hasOwnProperty,q3={brackets(W){return String(W)+"[]"},comma:"comma",indices(W,$){return String(W)+"["+$+"]"},repeat(W){return String(W)}},vW=Array.isArray,MD=Array.prototype.push,C3=function(W,$){MD.apply(W,vW($)?$:[$])},_D=Date.prototype.toISOString,$1={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Z3,encodeValuesOnly:!1,format:VX,formatter:KX[VX],indices:!1,serializeDate(W){return _D.call(W)},skipNulls:!1,strictNullHandling:!1};function DD(W){return typeof W==="string"||typeof W==="number"||typeof W==="boolean"||typeof W==="symbol"||typeof W==="bigint"}var u9={};function k3(W,$,X,Y,J,G,H,Q,z,F,T,U,M,O,K,N,I,C){let R=W,q=C,m=0,c=!1;while((q=q.get(u9))!==void 0&&!c){let E=q.get(W);if(m+=1,typeof E!=="undefined")if(E===m)throw new RangeError("Cyclic object value");else c=!0;if(typeof q.get(u9)==="undefined")m=0}if(typeof F==="function")R=F($,R);else if(R instanceof Date)R=M?.(R);else if(X==="comma"&&vW(R))R=p9(R,function(E){if(E instanceof Date)return M?.(E);return E});if(R===null){if(G)return z&&!N?z($,$1.encoder,I,"key",O):$;R=""}if(DD(R)||S3(R)){if(z){let E=N?$:z($,$1.encoder,I,"key",O);return[K?.(E)+"="+K?.(z(R,$1.encoder,I,"value",O))]}return[K?.($)+"="+K?.(String(R))]}let v=[];if(typeof R==="undefined")return v;let h;if(X==="comma"&&vW(R)){if(N&&z)R=p9(R,z);h=[{value:R.length>0?R.join(",")||null:void 0}]}else if(vW(F))h=F;else{let E=Object.keys(R);h=T?E.sort(T):E}let U0=Q?String($).replace(/\./g,"%2E"):String($),m0=Y&&vW(R)&&R.length===1?U0+"[]":U0;if(J&&vW(R)&&R.length===0)return m0+"[]";for(let E=0;E<h.length;++E){let _0=h[E],e=typeof _0==="object"&&typeof _0.value!=="undefined"?_0.value:R[_0];if(H&&e===null)continue;let w0=U&&Q?_0.replace(/\./g,"%2E"):_0,s0=vW(R)?typeof X==="function"?X(m0,w0):m0:m0+(U?"."+w0:"["+w0+"]");C.set(W,m);let D1=new WeakMap;D1.set(u9,C),C3(v,k3(e,s0,X,Y,J,G,H,Q,X==="comma"&&N&&vW(R)?null:z,F,T,U,M,O,K,N,I,D1))}return v}function OD(W=$1){if(typeof W.allowEmptyArrays!=="undefined"&&typeof W.allowEmptyArrays!=="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof W.encodeDotInKeys!=="undefined"&&typeof W.encodeDotInKeys!=="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(W.encoder!==null&&typeof W.encoder!=="undefined"&&typeof W.encoder!=="function")throw new TypeError("Encoder has to be a function.");let $=W.charset||$1.charset;if(typeof W.charset!=="undefined"&&W.charset!=="utf-8"&&W.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let X=VX;if(typeof W.format!=="undefined"){if(!wD.call(KX,W.format))throw new TypeError("Unknown format option provided.");X=W.format}let Y=KX[X],J=$1.filter;if(typeof W.filter==="function"||vW(W.filter))J=W.filter;let G;if(W.arrayFormat&&W.arrayFormat in q3)G=W.arrayFormat;else if("indices"in W)G=W.indices?"indices":"repeat";else G=$1.arrayFormat;if("commaRoundTrip"in W&&typeof W.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let H=typeof W.allowDots==="undefined"?!!W.encodeDotInKeys===!0?!0:$1.allowDots:!!W.allowDots;return{addQueryPrefix:typeof W.addQueryPrefix==="boolean"?W.addQueryPrefix:$1.addQueryPrefix,allowDots:H,allowEmptyArrays:typeof W.allowEmptyArrays==="boolean"?!!W.allowEmptyArrays:$1.allowEmptyArrays,arrayFormat:G,charset:$,charsetSentinel:typeof W.charsetSentinel==="boolean"?W.charsetSentinel:$1.charsetSentinel,commaRoundTrip:!!W.commaRoundTrip,delimiter:typeof W.delimiter==="undefined"?$1.delimiter:W.delimiter,encode:typeof W.encode==="boolean"?W.encode:$1.encode,encodeDotInKeys:typeof W.encodeDotInKeys==="boolean"?W.encodeDotInKeys:$1.encodeDotInKeys,encoder:typeof W.encoder==="function"?W.encoder:$1.encoder,encodeValuesOnly:typeof W.encodeValuesOnly==="boolean"?W.encodeValuesOnly:$1.encodeValuesOnly,filter:J,format:X,formatter:Y,serializeDate:typeof W.serializeDate==="function"?W.serializeDate:$1.serializeDate,skipNulls:typeof W.skipNulls==="boolean"?W.skipNulls:$1.skipNulls,sort:typeof W.sort==="function"?W.sort:null,strictNullHandling:typeof W.strictNullHandling==="boolean"?W.strictNullHandling:$1.strictNullHandling}}function c9(W,$={}){let X=W,Y=OD($),J,G;if(typeof Y.filter==="function")G=Y.filter,X=G("",X);else if(vW(Y.filter))G=Y.filter,J=G;let H=[];if(typeof X!=="object"||X===null)return"";let Q=q3[Y.arrayFormat],z=Q==="comma"&&Y.commaRoundTrip;if(!J)J=Object.keys(X);if(Y.sort)J.sort(Y.sort);let F=new WeakMap;for(let M=0;M<J.length;++M){let O=J[M];if(Y.skipNulls&&X[O]===null)continue;C3(H,k3(X[O],O,Q,z,Y.allowEmptyArrays,Y.strictNullHandling,Y.skipNulls,Y.encodeDotInKeys,Y.encode?Y.encoder:null,Y.filter,Y.sort,Y.allowDots,Y.serializeDate,Y.format,Y.formatter,Y.encodeValuesOnly,Y.charset,F))}let T=H.join(Y.delimiter),U=Y.addQueryPrefix===!0?"?":"";if(Y.charsetSentinel)if(Y.charset==="iso-8859-1")U+="utf8=%26%2310003%3B&";else U+="utf8=%E2%9C%93&";return T.length>0?U+T:""}var o2="4.97.0";var I3=!1,i2=void 0,d9=void 0,KD=void 0,LD=void 0,AD=void 0,l9=void 0,ED=void 0,LX=void 0,o9=void 0,i9=void 0,n9=void 0,AX=void 0,r9=void 0;function j3(W,$={auto:!1}){if(I3)throw new Error(`you must \`import 'openai/shims/${W.kind}'\` before importing anything else from openai`);if(i2)throw new Error(`can't \`import 'openai/shims/${W.kind}'\` after \`import 'openai/shims/${i2}'\``);I3=$.auto,i2=W.kind,d9=W.fetch,KD=W.Request,LD=W.Response,AD=W.Headers,l9=W.FormData,ED=W.Blob,LX=W.File,o9=W.ReadableStream,i9=W.getMultipartRequestOptions,n9=W.getDefaultAgent,AX=W.fileFromPath,r9=W.isFsReadStream}class t9{constructor(W){this.body=W}get[Symbol.toStringTag](){return"MultipartBody"}}function f3({manuallyImported:W}={}){let $=W?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n",X,Y,J,G;try{X=fetch,Y=Request,J=Response,G=Headers}catch(H){throw new Error(`this environment is missing the following Web Fetch API type: ${H.message}. ${$}`)}return{kind:"web",fetch:X,Request:Y,Response:J,Headers:G,FormData:typeof FormData!=="undefined"?FormData:class H{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${$}`)}},Blob:typeof Blob!=="undefined"?Blob:class H{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${$}`)}},File:typeof File!=="undefined"?File:class H{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${$}`)}},ReadableStream:typeof ReadableStream!=="undefined"?ReadableStream:class H{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${$}`)}},getMultipartRequestOptions:async(H,Q)=>({...Q,body:new t9(H)}),getDefaultAgent:(H)=>{return},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:(H)=>!1}}import{ReadStream as RD}from"fs";function P3(){let W=f3();function $(X){return X instanceof RD}return{...W,isFsReadStream:$}}var a9=()=>{if(!i2)j3(P3(),{auto:!0})};a9();class o extends Error{}class r0 extends o{constructor(W,$,X,Y){super(`${r0.makeMessage(W,$,X)}`);this.status=W,this.headers=Y,this.request_id=Y?.["x-request-id"],this.error=$;let J=$;this.code=J?.code,this.param=J?.param,this.type=J?.type}static makeMessage(W,$,X){let Y=$?.message?typeof $.message==="string"?$.message:JSON.stringify($.message):$?JSON.stringify($):X;if(W&&Y)return`${W} ${Y}`;if(W)return`${W} status code (no body)`;if(Y)return Y;return"(no status code or body)"}static generate(W,$,X,Y){if(!W||!Y)return new n2({message:X,cause:kX($)});let J=$?.error;if(W===400)return new EX(W,J,X,Y);if(W===401)return new NX(W,J,X,Y);if(W===403)return new RX(W,J,X,Y);if(W===404)return new BX(W,J,X,Y);if(W===409)return new ZX(W,J,X,Y);if(W===422)return new SX(W,J,X,Y);if(W===429)return new qX(W,J,X,Y);if(W>=500)return new CX(W,J,X,Y);return new r0(W,J,X,Y)}}class X1 extends r0{constructor({message:W}={}){super(void 0,void 0,W||"Request was aborted.",void 0)}}class n2 extends r0{constructor({message:W,cause:$}){super(void 0,void 0,W||"Connection error.",void 0);if($)this.cause=$}}class r2 extends n2{constructor({message:W}={}){super({message:W??"Request timed out."})}}class EX extends r0{}class NX extends r0{}class RX extends r0{}class BX extends r0{}class ZX extends r0{}class SX extends r0{}class qX extends r0{}class CX extends r0{}class U4 extends o{constructor(){super("Could not parse response content as the length limit was reached")}}class w4 extends o{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var IX=function(W,$,X,Y,J){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!J)throw new TypeError("Private accessor was defined without a setter");if(typeof $==="function"?W!==$||!J:!$.has(W))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?J.call(W,X):J?J.value=X:$.set(W,X),X},t2=function(W,$,X,Y){if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof $==="function"?W!==$||!Y:!$.has(W))throw new TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call(W):Y?Y.value:$.get(W)},o1;class m8{constructor(){o1.set(this,void 0),this.buffer=new Uint8Array,IX(this,o1,null,"f")}decode(W){if(W==null)return[];let $=W instanceof ArrayBuffer?new Uint8Array(W):typeof W==="string"?new TextEncoder().encode(W):W,X=new Uint8Array(this.buffer.length+$.length);X.set(this.buffer),X.set($,this.buffer.length),this.buffer=X;let Y=[],J;while((J=ZD(this.buffer,t2(this,o1,"f")))!=null){if(J.carriage&&t2(this,o1,"f")==null){IX(this,o1,J.index,"f");continue}if(t2(this,o1,"f")!=null&&(J.index!==t2(this,o1,"f")+1||J.carriage)){Y.push(this.decodeText(this.buffer.slice(0,t2(this,o1,"f")-1))),this.buffer=this.buffer.slice(t2(this,o1,"f")),IX(this,o1,null,"f");continue}let G=t2(this,o1,"f")!==null?J.preceding-1:J.preceding,H=this.decodeText(this.buffer.slice(0,G));Y.push(H),this.buffer=this.buffer.slice(J.index),IX(this,o1,null,"f")}return Y}decodeText(W){if(W==null)return"";if(typeof W==="string")return W;if(typeof Buffer!=="undefined"){if(W instanceof Buffer)return W.toString();if(W instanceof Uint8Array)return Buffer.from(W).toString();throw new o(`Unexpected: received non-Uint8Array (${W.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder!=="undefined"){if(W instanceof Uint8Array||W instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(W);throw new o(`Unexpected: received non-Uint8Array/ArrayBuffer (${W.constructor.name}) in a web platform. Please report this error.`)}throw new o("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
15
15
|
`)}}o1=new WeakMap;m8.NEWLINE_CHARS=new Set([`
|
|
16
16
|
`,"\r"]);m8.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function ZD(W,$){for(let J=$??0;J<W.length;J++){if(W[J]===10)return{preceding:J,index:J+1,carriage:!1};if(W[J]===13)return{preceding:J,index:J+1,carriage:!0}}return null}function x3(W){for(let Y=0;Y<W.length-1;Y++){if(W[Y]===10&&W[Y+1]===10)return Y+2;if(W[Y]===13&&W[Y+1]===13)return Y+2;if(W[Y]===13&&W[Y+1]===10&&Y+3<W.length&&W[Y+2]===13&&W[Y+3]===10)return Y+4}return-1}function s9(W){if(W[Symbol.asyncIterator])return W;let $=W.getReader();return{async next(){try{let X=await $.read();if(X?.done)$.releaseLock();return X}catch(X){throw $.releaseLock(),X}},async return(){let X=$.cancel();return $.releaseLock(),await X,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class i1{constructor(W,$){this.iterator=W,this.controller=$}static fromSSEResponse(W,$){let X=!1;async function*Y(){if(X)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let J=!1;try{for await(let G of SD(W,$)){if(J)continue;if(G.data.startsWith("[DONE]")){J=!0;continue}if(G.event===null||G.event.startsWith("response.")||G.event.startsWith("transcript.")){let H;try{H=JSON.parse(G.data)}catch(Q){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),Q}if(H&&H.error)throw new r0(void 0,H.error,void 0,e9(W.headers));yield H}else{let H;try{H=JSON.parse(G.data)}catch(Q){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),Q}if(G.event=="error")throw new r0(void 0,H.error,H.message,void 0);yield{event:G.event,data:H}}}J=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{if(!J)$.abort()}}return new i1(Y,$)}static fromReadableStream(W,$){let X=!1;async function*Y(){let G=new m8,H=s9(W);for await(let Q of H)for(let z of G.decode(Q))yield z;for(let Q of G.flush())yield Q}async function*J(){if(X)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let G=!1;try{for await(let H of Y()){if(G)continue;if(H)yield JSON.parse(H)}G=!0}catch(H){if(H instanceof Error&&H.name==="AbortError")return;throw H}finally{if(!G)$.abort()}}return new i1(J,$)}[Symbol.asyncIterator](){return this.iterator()}tee(){let W=[],$=[],X=this.iterator(),Y=(J)=>{return{next:()=>{if(J.length===0){let G=X.next();W.push(G),$.push(G)}return J.shift()}}};return[new i1(()=>Y(W),this.controller),new i1(()=>Y($),this.controller)]}toReadableStream(){let W=this,$,X=new TextEncoder;return new o9({async start(){$=W[Symbol.asyncIterator]()},async pull(Y){try{let{value:J,done:G}=await $.next();if(G)return Y.close();let H=X.encode(JSON.stringify(J)+`
|
|
17
17
|
`);Y.enqueue(H)}catch(J){Y.error(J)}},async cancel(){await $.return?.()}})}}async function*SD(W,$){if(!W.body)throw $.abort(),new o("Attempted to iterate over a response with no body");let X=new v3,Y=new m8,J=s9(W.body);for await(let G of qD(J))for(let H of Y.decode(G)){let Q=X.decode(H);if(Q)yield Q}for(let G of Y.flush()){let H=X.decode(G);if(H)yield H}}async function*qD(W){let $=new Uint8Array;for await(let X of W){if(X==null)continue;let Y=X instanceof ArrayBuffer?new Uint8Array(X):typeof X==="string"?new TextEncoder().encode(X):X,J=new Uint8Array($.length+Y.length);J.set($),J.set(Y,$.length),$=J;let G;while((G=x3($))!==-1)yield $.slice(0,G),$=$.slice(G)}if($.length>0)yield $}class v3{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(W){if(W.endsWith("\r"))W=W.substring(0,W.length-1);if(!W){if(!this.event&&!this.data.length)return null;let J={event:this.event,data:this.data.join(`
|