@yukino.js/yukino 0.0.3-dev → 0.0.3
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/README.md +5 -14
- package/dist/{acp-J6EPN6TP.js → acp-5YESBJ7N.js} +1 -1
- package/dist/{agent-LA65FOAB.js → agent-D6LSQHAD.js} +1 -1
- package/dist/{anthropic-YP6DY2F3.js → anthropic-CEUDAJL2.js} +1 -1
- package/dist/{chunk-675L7SRF.js → chunk-6GCU7CRK.js} +9 -9
- package/dist/chunk-7DLUKIPE.js +5 -0
- package/dist/{chunk-JEOQXHOX.js → chunk-OAFPGTZY.js} +2 -2
- package/dist/{chunk-7CVY4FXY.js → chunk-QG22QNQJ.js} +1 -1
- package/dist/{chunk-ZQP5DTJA.js → chunk-RCXKUD3Y.js} +1 -1
- package/dist/{chunk-P77AEADG.js → chunk-SAJCBGHL.js} +1 -1
- package/dist/{chunk-2UNWKNDU.js → chunk-UPNNYP7M.js} +1 -1
- package/dist/{chunk-Y6COQ5UY.js → chunk-XO7ITAWR.js} +1 -1
- package/dist/{chunk-CT773IEX.js → chunk-YBUSZS75.js} +3 -3
- package/dist/lib/{agent-KDWPLLAV.js → agent-KNGNHPSW.js} +3 -3
- package/dist/lib/{anthropic-OJALXK4E.js → anthropic-MSGL4VBM.js} +2 -2
- package/dist/lib/{chunk-77FSPN6Y.js → chunk-BDJLW7U2.js} +8 -8
- package/dist/lib/{chunk-SS7OJYHN.js → chunk-BMODZ6SU.js} +4 -4
- package/dist/lib/{chunk-2DEH6DOX.js → chunk-E6VFL5IO.js} +1 -1
- package/dist/lib/{chunk-7G4AI2PP.js → chunk-ENTAZT2J.js} +1 -1
- package/dist/lib/{chunk-WOMWIFSN.js → chunk-K4VUUC44.js} +2 -2
- package/dist/lib/{chunk-ZF52ER22.js → chunk-MDX24JQ5.js} +1 -1
- package/dist/lib/index.d.ts +42 -42
- package/dist/lib/index.js +43 -43
- package/dist/lib/{openai-FB7BBZVN.js → openai-DL5VBJR4.js} +2 -2
- package/dist/lib/{permissions-BZRN4RES.js → permissions-Q4FBU5VD.js} +1 -1
- package/dist/lib/{providers-7ZGRBCQ4.js → providers-VKVMAYIT.js} +1 -1
- package/dist/main.js +221 -225
- package/dist/{openai-2FE77NB2.js → openai-AQNX24XU.js} +1 -1
- package/dist/{permissions-R7P7RWZU.js → permissions-VCDMNX3L.js} +1 -1
- package/dist/{providers-EZFC2EPW.js → providers-SVAEL2RU.js} +1 -1
- package/dist/{server-54LNMGWU.js → server-UI2ZQVXG.js} +1 -1
- package/package.json +3 -11
- package/dist/chunk-M5H5EYXN.js +0 -5
- package/postinstall.mjs +0 -80
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
3
|
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{A as Rt,B as ws,C as so,D as Ps,E as xs,F as Rs,m as rn,o as sn,q as nn,r as on,t as an,u as un,z as ln}from"./chunk-M5H5EYXN.js";import{f as ro,k as Hr,l as ue,m as Is,n as cn,t as oe}from"./chunk-2UNWKNDU.js";import"./chunk-GYBJR2RB.js";import"./chunk-7MKA3SHV.js";function x(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}function c(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}var Je=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Je=r.randomUUID.bind(r),r.randomUUID();let e=new Uint8Array(1),t=r?()=>r.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^t()&15>>+s/4).toString(16))};function Wr(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var Jr=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{if(Object.prototype.toString.call(r)==="[object Error]"){let e=new Error(r.message,r.cause?{cause:r.cause}:{});return r.stack&&(e.stack=r.stack),r.cause&&!e.cause&&(e.cause=r.cause),r.name&&(e.name=r.name),e}}catch{}try{return new Error(JSON.stringify(r))}catch{}}return new Error(r)};var g=class extends Error{},F=class r extends g{constructor(e,t,s,n){super(`${r.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t;let o=t;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(e,t,s){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new ke({message:s,cause:Jr(t)});let o=t?.error;return e===400?new Ct(e,o,s,n):e===401?new St(e,o,s,n):e===403?new kt(e,o,s,n):e===404?new $t(e,o,s,n):e===409?new Et(e,o,s,n):e===422?new Ot(e,o,s,n):e===429?new vt(e,o,s,n):e>=500?new Tt(e,o,s,n):new r(e,o,s,n)}},M=class extends F{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},ke=class extends F{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},$e=class extends ke{constructor({message:e}={}){super({message:e??"Request timed out."})}},Ct=class extends F{},St=class extends F{},kt=class extends F{},$t=class extends F{},Et=class extends F{},Ot=class extends F{},vt=class extends F{},Tt=class extends F{},Lt=class extends g{constructor(){super("Could not parse response content as the length limit was reached")}},jt=class extends g{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},fe=class extends Error{constructor(e){super(e)}},Xe=class extends F{constructor(e,t,s){let n="OAuth2 authentication error",o;if(t&&typeof t=="object"){let a=t;o=a.error;let l=a.error_description;l&&typeof l=="string"?n=l:o&&(n=o)}super(e,t,n,s),this.error_code=o}},Xr=class extends g{constructor(e,t,s){super(e),this.provider=t,this.cause=s}};var xi=/^[a-z][a-z0-9+.-]*:/i,no=r=>xi.test(r),V=r=>(V=Array.isArray,V(r)),pn=V;function Cs(r){return typeof r!="object"?{}:r??{}}function dn(r){if(!r)return!0;for(let e in r)return!1;return!0}function oo(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Vr(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var io=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new g(`${r} must be an integer`);if(e<0)throw new g(`${r} must be a positive integer`);return e};var ao=r=>{try{return JSON.parse(r)}catch{return}};var he=r=>new Promise(e=>setTimeout(e,r));var Ee="6.49.0";var po=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ri(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var Ci=()=>{let r=Ri();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":co(Deno.build.os),"X-Stainless-Arch":uo(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(r==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":co(globalThis.process.platform??"unknown"),"X-Stainless-Arch":uo(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=Si();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Si(){if(typeof navigator>"u"||!navigator)return null;let r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of r){let s=t.exec(navigator.userAgent);if(s){let n=s[1]||0,o=s[2]||0,a=s[3]||0;return{browser:e,version:`${n}.${o}.${a}`}}}return null}var uo=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",co=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),lo,fo=()=>lo??(lo=Ci());function Ss(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function fn(...r){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...r)}function Gr(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return fn({start(){},async pull(t){let{done:s,value:n}=await e.next();s?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function ks(r){if(r[Symbol.asyncIterator])return r;let e=r.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function hn(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let e=r.getReader(),t=e.cancel();e.releaseLock(),await t}var mo=({headers:r,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var mn="RFC3986",_n=r=>String(r),yn={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:_n},_o="RFC1738";var $s=(r,e)=>($s=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),$s(r,e)),me=(()=>{let r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();var gn=1024,yo=(r,e,t,s,n)=>{if(r.length===0)return r;let o=r;if(typeof r=="symbol"?o=Symbol.prototype.toString.call(r):typeof r!="string"&&(o=String(r)),t==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<o.length;l+=gn){let f=o.length>=gn?o.slice(l,l+gn):o,p=[];for(let h=0;h<f.length;++h){let _=f.charCodeAt(h);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||n===_o&&(_===40||_===41)){p[p.length]=f.charAt(h);continue}if(_<128){p[p.length]=me[_];continue}if(_<2048){p[p.length]=me[192|_>>6]+me[128|_&63];continue}if(_<55296||_>=57344){p[p.length]=me[224|_>>12]+me[128|_>>6&63]+me[128|_&63];continue}h+=1,_=65536+((_&1023)<<10|f.charCodeAt(h)&1023),p[p.length]=me[240|_>>18]+me[128|_>>12&63]+me[128|_>>6&63]+me[128|_&63]}a+=p.join("")}return a};function go(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function An(r,e){if(V(r)){let t=[];for(let s=0;s<r.length;s+=1)t.push(e(r[s]));return t}return e(r)}var bo={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,e){return String(r)+"["+e+"]"},repeat(r){return String(r)}},Io=function(r,e){Array.prototype.push.apply(r,V(e)?e:[e])},Ao,z={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:yo,encodeValuesOnly:!1,format:mn,formatter:_n,indices:!1,serializeDate(r){return(Ao??(Ao=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function $i(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var bn={};function wo(r,e,t,s,n,o,a,l,f,p,h,_,m,I,P,b,w,$){let A=r,E=$,y=0,C=!1;for(;(E=E.get(bn))!==void 0&&!C;){let T=E.get(r);if(y+=1,typeof T<"u"){if(T===y)throw new RangeError("Cyclic object value");C=!0}typeof E.get(bn)>"u"&&(y=0)}if(typeof p=="function"?A=p(e,A):A instanceof Date?A=m?.(A):t==="comma"&&V(A)&&(A=An(A,function(T){return T instanceof Date?m?.(T):T})),A===null){if(o)return f&&!b?f(e,z.encoder,w,"key",I):e;A=""}if($i(A)||go(A)){if(f){let T=b?e:f(e,z.encoder,w,"key",I);return[P?.(T)+"="+P?.(f(A,z.encoder,w,"value",I))]}return[P?.(e)+"="+P?.(String(A))]}let k=[];if(typeof A>"u")return k;let L;if(t==="comma"&&V(A))b&&f&&(A=An(A,f)),L=[{value:A.length>0?A.join(",")||null:void 0}];else if(V(p))L=p;else{let T=Object.keys(A);L=h?T.sort(h):T}let j=l?String(e).replace(/\./g,"%2E"):String(e),N=s&&V(A)&&A.length===1?j+"[]":j;if(n&&V(A)&&A.length===0)return N+"[]";for(let T=0;T<L.length;++T){let W=L[T],xt=typeof W=="object"&&typeof W.value<"u"?W.value:A[W];if(a&&xt===null)continue;let J=_&&l?W.replace(/\./g,"%2E"):W,As=V(A)?typeof t=="function"?t(N,J):N:N+(_?"."+J:"["+J+"]");$.set(r,y);let bs=new WeakMap;bs.set(bn,$),Io(k,wo(xt,As,t,s,n,o,a,l,t==="comma"&&b&&V(A)?null:f,p,h,_,m,I,P,b,w,bs))}return k}function Ei(r=z){if(typeof r.allowEmptyArrays<"u"&&typeof r.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof r.encodeDotInKeys<"u"&&typeof r.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=r.charset||z.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=mn;if(typeof r.format<"u"){if(!$s(yn,r.format))throw new TypeError("Unknown format option provided.");t=r.format}let s=yn[t],n=z.filter;(typeof r.filter=="function"||V(r.filter))&&(n=r.filter);let o;if(r.arrayFormat&&r.arrayFormat in bo?o=r.arrayFormat:"indices"in r?o=r.indices?"indices":"repeat":o=z.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:z.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:z.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:z.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:z.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?z.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:z.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:z.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:z.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:z.encodeValuesOnly,filter:n,format:t,formatter:s,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:z.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:z.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:z.strictNullHandling}}function Po(r,e={}){let t=r,s=Ei(e),n,o;typeof s.filter=="function"?(o=s.filter,t=o("",t)):V(s.filter)&&(o=s.filter,n=o);let a=[];if(typeof t!="object"||t===null)return"";let l=bo[s.arrayFormat],f=l==="comma"&&s.commaRoundTrip;n||(n=Object.keys(t)),s.sort&&n.sort(s.sort);let p=new WeakMap;for(let m=0;m<n.length;++m){let I=n[m];s.skipNulls&&t[I]===null||Io(a,wo(t[I],I,l,f,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,p))}let h=a.join(s.delimiter),_=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?_+="utf8=%26%2310003%3B&":_+="utf8=%E2%9C%93&"),h.length>0?_+h:""}function xo(r){return Po(r,{arrayFormat:"brackets"})}function So(r){let e=0;for(let n of r)e+=n.length;let t=new Uint8Array(e),s=0;for(let n of r)t.set(n,s),s+=n.length;return t}var Ro;function ee(r){let e;return(Ro??(e=new globalThis.TextEncoder,Ro=e.encode.bind(e)))(r)}var Co;function In(r){let e;return(Co??(e=new globalThis.TextDecoder,Co=e.decode.bind(e)))(r)}var te,re,Ve=class{constructor(){te.set(this,void 0),re.set(this,void 0),x(this,te,new Uint8Array,"f"),x(this,re,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ee(e):e;x(this,te,So([c(this,te,"f"),t]),"f");let s=[],n;for(;(n=vi(c(this,te,"f"),c(this,re,"f")))!=null;){if(n.carriage&&c(this,re,"f")==null){x(this,re,n.index,"f");continue}if(c(this,re,"f")!=null&&(n.index!==c(this,re,"f")+1||n.carriage)){s.push(In(c(this,te,"f").subarray(0,c(this,re,"f")-1))),x(this,te,c(this,te,"f").subarray(c(this,re,"f")),"f"),x(this,re,null,"f");continue}let o=c(this,re,"f")!==null?n.preceding-1:n.preceding,a=In(c(this,te,"f").subarray(0,o));s.push(a),x(this,te,c(this,te,"f").subarray(n.index),"f"),x(this,re,null,"f")}return s}flush(){return c(this,te,"f").length?this.decode(`
|
|
4
|
+
import{A as Rt,B as ws,C as so,D as Ps,E as xs,F as Rs,m as rn,o as sn,q as nn,r as on,t as an,u as un,z as ln}from"./chunk-7DLUKIPE.js";import{f as ro,k as Hr,l as ue,m as Is,n as cn,s as oe}from"./chunk-UPNNYP7M.js";import"./chunk-GYBJR2RB.js";import"./chunk-7MKA3SHV.js";function x(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}function c(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}var Je=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Je=r.randomUUID.bind(r),r.randomUUID();let e=new Uint8Array(1),t=r?()=>r.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^t()&15>>+s/4).toString(16))};function Wr(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var Jr=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{if(Object.prototype.toString.call(r)==="[object Error]"){let e=new Error(r.message,r.cause?{cause:r.cause}:{});return r.stack&&(e.stack=r.stack),r.cause&&!e.cause&&(e.cause=r.cause),r.name&&(e.name=r.name),e}}catch{}try{return new Error(JSON.stringify(r))}catch{}}return new Error(r)};var g=class extends Error{},F=class r extends g{constructor(e,t,s,n){super(`${r.makeMessage(e,t,s)}`),this.status=e,this.headers=n,this.requestID=n?.get("x-request-id"),this.error=t;let o=t;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(e,t,s){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):s;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,s,n){if(!e||!n)return new ke({message:s,cause:Jr(t)});let o=t?.error;return e===400?new Ct(e,o,s,n):e===401?new St(e,o,s,n):e===403?new kt(e,o,s,n):e===404?new $t(e,o,s,n):e===409?new Et(e,o,s,n):e===422?new Ot(e,o,s,n):e===429?new vt(e,o,s,n):e>=500?new Tt(e,o,s,n):new r(e,o,s,n)}},M=class extends F{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},ke=class extends F{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},$e=class extends ke{constructor({message:e}={}){super({message:e??"Request timed out."})}},Ct=class extends F{},St=class extends F{},kt=class extends F{},$t=class extends F{},Et=class extends F{},Ot=class extends F{},vt=class extends F{},Tt=class extends F{},Lt=class extends g{constructor(){super("Could not parse response content as the length limit was reached")}},jt=class extends g{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},fe=class extends Error{constructor(e){super(e)}},Xe=class extends F{constructor(e,t,s){let n="OAuth2 authentication error",o;if(t&&typeof t=="object"){let a=t;o=a.error;let l=a.error_description;l&&typeof l=="string"?n=l:o&&(n=o)}super(e,t,n,s),this.error_code=o}},Xr=class extends g{constructor(e,t,s){super(e),this.provider=t,this.cause=s}};var xi=/^[a-z][a-z0-9+.-]*:/i,no=r=>xi.test(r),V=r=>(V=Array.isArray,V(r)),pn=V;function Cs(r){return typeof r!="object"?{}:r??{}}function dn(r){if(!r)return!0;for(let e in r)return!1;return!0}function oo(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Vr(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var io=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new g(`${r} must be an integer`);if(e<0)throw new g(`${r} must be a positive integer`);return e};var ao=r=>{try{return JSON.parse(r)}catch{return}};var he=r=>new Promise(e=>setTimeout(e,r));var Ee="6.49.0";var po=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ri(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var Ci=()=>{let r=Ri();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":co(Deno.build.os),"X-Stainless-Arch":uo(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(r==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":co(globalThis.process.platform??"unknown"),"X-Stainless-Arch":uo(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=Si();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ee,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Si(){if(typeof navigator>"u"||!navigator)return null;let r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of r){let s=t.exec(navigator.userAgent);if(s){let n=s[1]||0,o=s[2]||0,a=s[3]||0;return{browser:e,version:`${n}.${o}.${a}`}}}return null}var uo=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",co=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),lo,fo=()=>lo??(lo=Ci());function Ss(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function fn(...r){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...r)}function Gr(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return fn({start(){},async pull(t){let{done:s,value:n}=await e.next();s?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function ks(r){if(r[Symbol.asyncIterator])return r;let e=r.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function hn(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let e=r.getReader(),t=e.cancel();e.releaseLock(),await t}var mo=({headers:r,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var mn="RFC3986",_n=r=>String(r),yn={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:_n},_o="RFC1738";var $s=(r,e)=>($s=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),$s(r,e)),me=(()=>{let r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();var gn=1024,yo=(r,e,t,s,n)=>{if(r.length===0)return r;let o=r;if(typeof r=="symbol"?o=Symbol.prototype.toString.call(r):typeof r!="string"&&(o=String(r)),t==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<o.length;l+=gn){let f=o.length>=gn?o.slice(l,l+gn):o,p=[];for(let h=0;h<f.length;++h){let _=f.charCodeAt(h);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||n===_o&&(_===40||_===41)){p[p.length]=f.charAt(h);continue}if(_<128){p[p.length]=me[_];continue}if(_<2048){p[p.length]=me[192|_>>6]+me[128|_&63];continue}if(_<55296||_>=57344){p[p.length]=me[224|_>>12]+me[128|_>>6&63]+me[128|_&63];continue}h+=1,_=65536+((_&1023)<<10|f.charCodeAt(h)&1023),p[p.length]=me[240|_>>18]+me[128|_>>12&63]+me[128|_>>6&63]+me[128|_&63]}a+=p.join("")}return a};function go(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function An(r,e){if(V(r)){let t=[];for(let s=0;s<r.length;s+=1)t.push(e(r[s]));return t}return e(r)}var bo={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,e){return String(r)+"["+e+"]"},repeat(r){return String(r)}},Io=function(r,e){Array.prototype.push.apply(r,V(e)?e:[e])},Ao,z={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:yo,encodeValuesOnly:!1,format:mn,formatter:_n,indices:!1,serializeDate(r){return(Ao??(Ao=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function $i(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var bn={};function wo(r,e,t,s,n,o,a,l,f,p,h,_,m,I,P,b,w,$){let A=r,E=$,y=0,C=!1;for(;(E=E.get(bn))!==void 0&&!C;){let T=E.get(r);if(y+=1,typeof T<"u"){if(T===y)throw new RangeError("Cyclic object value");C=!0}typeof E.get(bn)>"u"&&(y=0)}if(typeof p=="function"?A=p(e,A):A instanceof Date?A=m?.(A):t==="comma"&&V(A)&&(A=An(A,function(T){return T instanceof Date?m?.(T):T})),A===null){if(o)return f&&!b?f(e,z.encoder,w,"key",I):e;A=""}if($i(A)||go(A)){if(f){let T=b?e:f(e,z.encoder,w,"key",I);return[P?.(T)+"="+P?.(f(A,z.encoder,w,"value",I))]}return[P?.(e)+"="+P?.(String(A))]}let k=[];if(typeof A>"u")return k;let L;if(t==="comma"&&V(A))b&&f&&(A=An(A,f)),L=[{value:A.length>0?A.join(",")||null:void 0}];else if(V(p))L=p;else{let T=Object.keys(A);L=h?T.sort(h):T}let j=l?String(e).replace(/\./g,"%2E"):String(e),N=s&&V(A)&&A.length===1?j+"[]":j;if(n&&V(A)&&A.length===0)return N+"[]";for(let T=0;T<L.length;++T){let W=L[T],xt=typeof W=="object"&&typeof W.value<"u"?W.value:A[W];if(a&&xt===null)continue;let J=_&&l?W.replace(/\./g,"%2E"):W,As=V(A)?typeof t=="function"?t(N,J):N:N+(_?"."+J:"["+J+"]");$.set(r,y);let bs=new WeakMap;bs.set(bn,$),Io(k,wo(xt,As,t,s,n,o,a,l,t==="comma"&&b&&V(A)?null:f,p,h,_,m,I,P,b,w,bs))}return k}function Ei(r=z){if(typeof r.allowEmptyArrays<"u"&&typeof r.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof r.encodeDotInKeys<"u"&&typeof r.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=r.charset||z.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=mn;if(typeof r.format<"u"){if(!$s(yn,r.format))throw new TypeError("Unknown format option provided.");t=r.format}let s=yn[t],n=z.filter;(typeof r.filter=="function"||V(r.filter))&&(n=r.filter);let o;if(r.arrayFormat&&r.arrayFormat in bo?o=r.arrayFormat:"indices"in r?o=r.indices?"indices":"repeat":o=z.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:z.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:z.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:z.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:z.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?z.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:z.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:z.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:z.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:z.encodeValuesOnly,filter:n,format:t,formatter:s,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:z.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:z.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:z.strictNullHandling}}function Po(r,e={}){let t=r,s=Ei(e),n,o;typeof s.filter=="function"?(o=s.filter,t=o("",t)):V(s.filter)&&(o=s.filter,n=o);let a=[];if(typeof t!="object"||t===null)return"";let l=bo[s.arrayFormat],f=l==="comma"&&s.commaRoundTrip;n||(n=Object.keys(t)),s.sort&&n.sort(s.sort);let p=new WeakMap;for(let m=0;m<n.length;++m){let I=n[m];s.skipNulls&&t[I]===null||Io(a,wo(t[I],I,l,f,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,p))}let h=a.join(s.delimiter),_=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?_+="utf8=%26%2310003%3B&":_+="utf8=%E2%9C%93&"),h.length>0?_+h:""}function xo(r){return Po(r,{arrayFormat:"brackets"})}function So(r){let e=0;for(let n of r)e+=n.length;let t=new Uint8Array(e),s=0;for(let n of r)t.set(n,s),s+=n.length;return t}var Ro;function ee(r){let e;return(Ro??(e=new globalThis.TextEncoder,Ro=e.encode.bind(e)))(r)}var Co;function In(r){let e;return(Co??(e=new globalThis.TextDecoder,Co=e.decode.bind(e)))(r)}var te,re,Ve=class{constructor(){te.set(this,void 0),re.set(this,void 0),x(this,te,new Uint8Array,"f"),x(this,re,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?ee(e):e;x(this,te,So([c(this,te,"f"),t]),"f");let s=[],n;for(;(n=vi(c(this,te,"f"),c(this,re,"f")))!=null;){if(n.carriage&&c(this,re,"f")==null){x(this,re,n.index,"f");continue}if(c(this,re,"f")!=null&&(n.index!==c(this,re,"f")+1||n.carriage)){s.push(In(c(this,te,"f").subarray(0,c(this,re,"f")-1))),x(this,te,c(this,te,"f").subarray(c(this,re,"f")),"f"),x(this,re,null,"f");continue}let o=c(this,re,"f")!==null?n.preceding-1:n.preceding,a=In(c(this,te,"f").subarray(0,o));s.push(a),x(this,te,c(this,te,"f").subarray(n.index),"f"),x(this,re,null,"f")}return s}flush(){return c(this,te,"f").length?this.decode(`
|
|
5
5
|
`):[]}};te=new WeakMap,re=new WeakMap;Ve.NEWLINE_CHARS=new Set([`
|
|
6
6
|
`,"\r"]);Ve.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function vi(r,e){for(let n=e??0;n<r.length;n++){if(r[n]===10)return{preceding:n,index:n+1,carriage:!1};if(r[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function ko(r){for(let s=0;s<r.length-1;s++){if(r[s]===10&&r[s+1]===10||r[s]===13&&r[s+1]===13)return s+2;if(r[s]===13&&r[s+1]===10&&s+3<r.length&&r[s+2]===13&&r[s+3]===10)return s+4}return-1}var Os={off:0,error:200,warn:300,info:400,debug:500},wn=(r,e,t)=>{if(r){if(oo(Os,r))return r;K(t).warn(`${e} was set to ${JSON.stringify(r)}, expected one of ${JSON.stringify(Object.keys(Os))}`)}};function Qr(){}function Es(r,e,t){return!e||Os[r]>Os[t]?Qr:e[r].bind(e)}var Ti={error:Qr,warn:Qr,info:Qr,debug:Qr},$o=new WeakMap;function K(r){let e=r.logger,t=r.logLevel??"off";if(!e)return Ti;let s=$o.get(e);if(s&&s[0]===t)return s[1];let n={error:Es("error",e,t),warn:Es("warn",e,t),info:Es("info",e,t),debug:Es("debug",e,t)};return $o.set(e,[t,n]),n}var Ae=r=>(r.options&&(r.options={...r.options},delete r.options.headers),r.headers&&(r.headers=Object.fromEntries((r.headers instanceof Headers?[...r.headers]:Object.entries(r.headers)).map(([e,t])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="api-key"||e.toLowerCase()==="x-api-key"||e.toLowerCase()==="x-amz-security-token"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in r&&(r.retryOfRequestLogID&&(r.retryOf=r.retryOfRequestLogID),delete r.retryOfRequestLogID),r);var Yr,Z=class r{constructor(e,t,s){this.iterator=e,Yr.set(this,void 0),this.controller=t,x(this,Yr,s,"f")}static fromSSEResponse(e,t,s,n){let o=!1,a=s?K(s):console;async function*l(){if(o)throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let f=!1;try{for await(let p of Li(e,t))if(!f){if(p.data.startsWith("[DONE]")){f=!0;continue}if(p.event===null||!p.event.startsWith("thread.")){let h;try{h=JSON.parse(p.data)}catch(_){throw a.error("Could not parse message into JSON:",p.data),a.error("From chunk:",p.raw),_}if(h&&h.error)throw new F(void 0,h.error,void 0,e.headers);yield n?{event:p.event,data:h}:h}else{let h;try{h=JSON.parse(p.data)}catch(_){throw console.error("Could not parse message into JSON:",p.data),console.error("From chunk:",p.raw),_}if(p.event=="error")throw new F(void 0,h.error,h.message,void 0);yield{event:p.event,data:h}}}f=!0}catch(p){if(Wr(p))return;throw p}finally{f||t.abort()}}return new r(l,t,s)}static fromReadableStream(e,t,s){let n=!1;async function*o(){let l=new Ve,f=e.getReader(),p=!1,h,_=()=>{h??(h=f.cancel()),h.catch(()=>{})};t.signal.addEventListener("abort",_,{once:!0});try{if(t.signal.aborted){_();return}for(;;){let{value:m,done:I}=await f.read();if(I){p=!0;break}if(t.signal.aborted)return;for(let P of l.decode(m)){if(t.signal.aborted)return;yield P}}if(t.signal.aborted)return;for(let m of l.flush()){if(t.signal.aborted)return;yield m}}finally{t.signal.removeEventListener("abort",_),p||_(),f.releaseLock()}}async function*a(){if(n)throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let l=!1;try{for await(let f of o())l||f&&(yield JSON.parse(f));l=!0}catch(f){if(t.signal.aborted||Wr(f))return;throw f}finally{l||t.abort()}}return new r(a,t,s)}[(Yr=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],s=this.iterator(),n=o=>({next:()=>{if(o.length===0){let a=s.next();e.push(a),t.push(a)}return o.shift()}});return[new r(()=>n(e),this.controller,c(this,Yr,"f")),new r(()=>n(t),this.controller,c(this,Yr,"f"))]}toReadableStream(){let e=this,t;return fn({async start(){t=e[Symbol.asyncIterator]()},async pull(s){try{let{value:n,done:o}=await t.next();if(o)return s.close();let a=ee(JSON.stringify(n)+`
|
|
7
7
|
`);s.enqueue(a)}catch(n){s.error(n)}},async cancel(){await t.return?.()}})}};async function*Li(r,e){if(!r.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new g("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new g("Attempted to iterate over a response with no body");let t=new Pn,s=new Ve,n=ks(r.body);for await(let o of ji(n))for(let a of s.decode(o)){let l=t.decode(a);l&&(yield l)}for(let o of s.flush()){let a=t.decode(o);a&&(yield a)}}async function*ji(r){let e=new Uint8Array;for await(let t of r){if(t==null)continue;let s=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?ee(t):t,n=new Uint8Array(e.length+s.length);n.set(e),n.set(s,e.length),e=n;let o;for(;(o=ko(e))!==-1;)yield e.slice(0,o),e=e.slice(o)}e.length>0&&(yield e)}var Pn=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
3
|
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{a,b,c,d,e,f}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f}from"./chunk-RCXKUD3Y.js";import"./chunk-XO7ITAWR.js";import"./chunk-UPNNYP7M.js";import"./chunk-GYBJR2RB.js";import"./chunk-7MKA3SHV.js";export{b as PathSandbox,f as PermissionChecker,d as RuleEngine,c as evaluateRules,a as extractContent,e as isSafeCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
3
|
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{b as a,c as b}from"./chunk-
|
|
4
|
+
import{b as a,c as b}from"./chunk-QG22QNQJ.js";import"./chunk-JFKC4VCA.js";import"./chunk-GYBJR2RB.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{b as createTelemetryRuntime,a as parseExporterTypes};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
3
|
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{b as a,c as b}from"./chunk-
|
|
4
|
+
import{b as a,c as b}from"./chunk-YBUSZS75.js";import"./chunk-6GCU7CRK.js";import"./chunk-HLE7243Q.js";import"./chunk-OAFPGTZY.js";import"./chunk-QG22QNQJ.js";import"./chunk-JFKC4VCA.js";import"./chunk-SAJCBGHL.js";import"./chunk-OFC2GD5K.js";import"./chunk-7DLUKIPE.js";import"./chunk-RCXKUD3Y.js";import"./chunk-XO7ITAWR.js";import"./chunk-UPNNYP7M.js";import"./chunk-GYBJR2RB.js";import"./chunk-L2BWSPCF.js";import"./chunk-HMZQYFYG.js";import"./chunk-3QL446GD.js";import"./chunk-AGSYLE4E.js";import"./chunk-CU3IISCC.js";import"./chunk-VCIRD267.js";import"./chunk-7MKA3SHV.js";export{b as RemoteServer,a as createRemoteAgent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yukino.js/yukino",
|
|
3
|
-
"version": "0.0.3
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Yukino is a terminal-based AI coding agent. It provides an interactive UI (terminal user interface) for conversing with large language models, executing code, manipulating files, and orchestrating multi-agent workflows, all from the command line.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
-
"postinstall.mjs",
|
|
28
27
|
"README.md"
|
|
29
28
|
],
|
|
30
29
|
"type": "module",
|
|
@@ -45,9 +44,6 @@
|
|
|
45
44
|
"@agentclientprotocol/sdk": "^1.5.0",
|
|
46
45
|
"@anthropic-ai/sandbox-runtime": "^0.0.76",
|
|
47
46
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
48
|
-
"@bufbuild/protobuf": "^2.15.0",
|
|
49
|
-
"@connectrpc/connect": "^2.2.0",
|
|
50
|
-
"@connectrpc/connect-node": "^2.2.0",
|
|
51
47
|
"@langfuse/otel": "^5.11.1",
|
|
52
48
|
"@langfuse/tracing": "^5.11.1",
|
|
53
49
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
@@ -99,8 +95,6 @@
|
|
|
99
95
|
},
|
|
100
96
|
"devDependencies": {
|
|
101
97
|
"@biomejs/biome": "2.4.15",
|
|
102
|
-
"@bufbuild/buf": "^1.73.0",
|
|
103
|
-
"@bufbuild/protoc-gen-es": "^2.15.0",
|
|
104
98
|
"@eslint/js": "^9.39.5",
|
|
105
99
|
"@tailwindcss/postcss": "^4.3.3",
|
|
106
100
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -135,7 +129,7 @@
|
|
|
135
129
|
"build:fe": "cd src/remote/fe && rm -rf ./dist && tsup",
|
|
136
130
|
"preview:fe": "pnpm dlx serve src/remote/fe/dist",
|
|
137
131
|
"dev": "tsx ./src/main.tsx",
|
|
138
|
-
"build": "rm -rf ./dist &&
|
|
132
|
+
"build": "rm -rf ./dist && tsup",
|
|
139
133
|
"lint": "eslint --cache --quiet ./src ./tests",
|
|
140
134
|
"lint:fix": "eslint --cache --fix --quiet ./src ./tests",
|
|
141
135
|
"test": "vitest run --maxWorkers=2",
|
|
@@ -146,8 +140,6 @@
|
|
|
146
140
|
"happy:fix": "pnpm typecheck && pnpm format && pnpm lint:fix && pnpm build && pnpm test",
|
|
147
141
|
"add:user": "pnpm adduser --registry=https://registry.npmjs.org/",
|
|
148
142
|
"publish:latest": "pnpm publish --access public --registry=https://registry.npmjs.org/",
|
|
149
|
-
"publish:nightly": "pnpm publish --access public --registry=https://registry.npmjs.org/ --tag nightly"
|
|
150
|
-
"gen:pb": "buf generate ../../yukino/pb --template ../../yukino/pb/buf.gen.yaml",
|
|
151
|
-
"postinstall": "node postinstall.mjs"
|
|
143
|
+
"publish:nightly": "pnpm publish --access public --registry=https://registry.npmjs.org/ --tag nightly"
|
|
152
144
|
}
|
|
153
145
|
}
|
package/dist/chunk-M5H5EYXN.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
-
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
-
import{a as P,f as E}from"./chunk-2UNWKNDU.js";import{D as t,b,c as x}from"./chunk-GYBJR2RB.js";import{existsSync as L,readFileSync as N}from"fs";import{homedir as W}from"os";import{join as I}from"path";function h(e){return!!e._zod}function p(e,n){return h(e)?b(e,n):e.safeParse(n)}async function Oe(e,n){return h(e)?await x(e,n):await e.safeParseAsync(n)}function Le(e){if(!e)return;let n;if(h(e)?n=e._zod?.def?.shape:n=e.shape,!!n){if(typeof n=="function")try{return n()}catch{return}return n}}function G(e){return e.length===0?"object root":e.reduce((n,o,r)=>r===0?String(o):typeof o=="number"?`${n}[${o}]`:`${n}.${o}`,"")}function v(e){if(e&&typeof e=="object"){if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0)return e.issues.map(n=>n.path?.length?`${n.message} at ${G(n.path)}`:n.message).join(`
|
|
5
|
-
`);if("message"in e&&typeof e.message=="string")return e.message;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function Ne(e){if(h(e)){let a=e._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}let o=e._def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}let r=e.value;if(r!==void 0)return r}var m=E({module:"config"}),$={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY","openai-compat":"OPENAI_API_KEY"};function Z(e){return y.has(e)}var y=new Set(Object.keys($)),c=class extends Error{constructor(n){super(n),this.name="ConfigError"}};function X(){return I(W(),".yukino","config.yaml")}var _=["off","minimal","low","medium","high","xhigh","max"],d=t.enum(["none","minimal","low","medium","high","xhigh","max"]),q=t.enum(["low","medium","high","xhigh","max"]),Q=t.strictObject({off:t.literal("none").nullable().optional(),minimal:d.nullable().optional(),low:d.nullable().optional(),medium:d.nullable().optional(),high:d.nullable().optional(),xhigh:d.nullable().optional(),max:d.nullable().optional()}),z=t.looseObject({name:t.string(),protocol:t.enum(["anthropic","openai","openai-compat"]),base_url:t.string(),model:t.string(),api_key:t.string().optional(),thinking:t.enum(_).optional(),reasoning:t.boolean().optional(),thinking_level_map:Q.optional(),thinking_mode:t.enum(["budget","adaptive"]).optional(),context_window:t.coerce.number().optional(),max_output_tokens:t.coerce.number().optional()}),ee="high",C=1e6,T=128e3,ne={minimal:1024,low:2048,medium:8192,high:16384,xhigh:32768,max:65536},oe=1024,te=1024;function Fe(e){return _.some(n=>n===e)}function re(e){return ae(e,e.thinking??ee)}function Be(e){return e==="off"?0:ne[e]}function R(e,n){if(n?.reasoning===!1)return null;if(e==="off")return"none";let o=n?.thinking_level_map?.[e];if(o!==void 0)return o;if(n?.protocol==="anthropic"&&n.thinking_mode==="adaptive"){if(e==="minimal")return"low";if(e==="xhigh")return"high"}return e}function ie(e,n){let o=q.safeParse(R(e,n));return o.success?o.data:null}function se(e){return e.reasoning===!1||e.protocol==="anthropic"&&e.thinking_mode!=="adaptive"&&K(e)<oe+te?["off"]:_.filter(n=>{if(n==="off")return!0;if(e.protocol==="anthropic"&&e.thinking_mode==="adaptive")return ie(n,e)!==null;let o=R(n,e);return o!==null&&o!=="none"})}function ae(e,n){let o=se(e),r="off";for(let i of _)if(o.includes(i)&&(r=i),i===n)break;return r}function A(e){return{...e,thinking:re(e),context_window:U(e),max_output_tokens:K(e)}}function U(e){return Number.isSafeInteger(e.context_window)&&(e.context_window??0)>0?e.context_window??C:C}function K(e){let n=e.max_output_tokens,o=Number.isSafeInteger(n)&&(n??0)>0?n??T:T;return Math.min(o,U(e))}function He(e){if(e.api_key)return e.api_key;let n=Z(e.protocol)?$[e.protocol]:"";return n?process.env[n]??"":""}var D=t.looseObject({name:t.string(),command:t.string().optional(),args:t.array(t.string()).optional(),url:t.string().optional(),transport:t.string().optional(),headers:t.record(t.string(),t.string()).optional(),env:t.record(t.string(),t.string()).optional()}),V=t.looseObject({id:t.string().optional(),event:t.string(),condition:t.string().optional(),action:t.looseObject({type:t.string(),command:t.string().optional(),url:t.string().optional(),method:t.string().optional(),prompt:t.string().optional()}),reject:t.boolean().optional(),once:t.boolean().optional(),async:t.boolean().optional(),on_error:t.string().optional()}),F=t.looseObject({enabled:t.boolean().optional(),backend:t.enum(["native","sandbox-runtime"]).optional(),auto_allow:t.boolean().optional(),network_enabled:t.boolean().optional()}),le=t.looseObject({default_provider:t.number().default(0),providers:t.array(z),permission_mode:t.string().optional(),mcp_servers:t.array(D).default([]),hooks:t.array(V).default([]),sandbox:F.optional(),enable_coordinator_mode:t.boolean().optional(),enable_fork:t.boolean().optional()});function Je(e){return e.enable_fork!==!1}function ce(e){return typeof e=="object"&&e!==null}function M(e){let n=N(e,"utf-8"),o=P.load(n);if(!ce(o))return m.error({path:e},"invalid yaml"),{default_provider:0,providers:[],mcp_servers:[],hooks:[]};let r=p(le,o);if(r.success){let l=r.data;return{...l,providers:l.providers.map(A)}}m.error({error:r.error},"config error");let i=0,a=[],f,s=[],u=[],S,w=!1,k=!0;if("default_provider"in o){let l=p(t.number(),o.default_provider);l.success&&(i=l.data)}if("providers"in o){let l=p(t.array(z),o.providers);if(l.success)a=l.data.map(A);else throw new c(`Invalid provider configuration in ${e}: ${v(l.error)}`)}if("permission_mode"in o&&typeof o.permission_mode=="string"&&(f=o.permission_mode),"mcp_servers"in o){let l=p(t.array(D),o.mcp_servers);if(l.success)s=l.data;else throw new c(`Invalid MCP server configuration in ${e}: ${v(l.error)}`)}if("hooks"in o){let l=p(t.array(V),o.hooks);l.success&&(u=l.data)}if("sandbox"in o){let l=p(F,o.sandbox);if(l.success)S=l.data;else throw new c(`Invalid sandbox configuration in ${e}: ${v(l.error)}`)}return"enable_coordinator_mode"in o&&(w=!!o.enable_coordinator_mode),"enable_fork"in o&&(k=!!o.enable_fork),{default_provider:i,providers:a,permission_mode:f,mcp_servers:s,hooks:u,sandbox:S,enable_coordinator_mode:w,enable_fork:k}}function j(e){if(e.providers.length===0)throw new c("At least one provider MUST be configured.");let n=["name","protocol","base_url","model"],o=new Map;for(let r=0;r<e.providers.length;r++){let i=e.providers[r],a={name:i.name,protocol:i.protocol,base_url:i.base_url,model:i.model},f=n.filter(u=>!a[u].trim());if(f.length>0)throw new c(`Provider #${String(r+1)}: missing fields: ${f.join(", ")}`);if(!y.has(i.protocol))throw new c(`Provider #${String(r+1)}: invalid protocol '${i.protocol}', MUST be one of: ${Array.from(y).join(", ")}`);let s=o.get(i.base_url);if(s!==void 0)throw new c(`Provider #${String(r+1)}: duplicate base_url '${i.base_url}' (already used by provider #${String(s+1)}).`);o.set(i.base_url,r)}}function O(e){let n=new Map;for(let o=0;o<e.mcp_servers.length;o++){let r=e.mcp_servers[o],i=`MCP server #${String(o+1)}`;if(!r.name.trim())throw new c(`${i}: name must not be empty.`);let a=n.get(r.name);if(a!==void 0)throw new c(`${i}: duplicate name '${r.name}' (already used by MCP server #${String(a+1)}).`);n.set(r.name,o);let f=!!r.command?.trim(),s=!!r.url?.trim();if(f===s)throw new c(`${i} '${r.name}': configure exactly one of command or url.`);if(f&&r.transport&&r.transport!=="stdio")throw new c(`${i} '${r.name}': command servers must use stdio.`);if(s&&r.transport&&!["http","sse"].includes(r.transport))throw new c(`${i} '${r.name}': URL transport must be http or sse.`)}}var fe=".mcp.json",ue=t.looseObject({command:t.string().optional(),args:t.array(t.string()).optional(),env:t.record(t.string(),t.string()).optional(),type:t.enum(["stdio","sse","http"]).optional(),url:t.string().optional(),headers:t.record(t.string(),t.string()).optional()}),pe=t.looseObject({mcpServers:t.record(t.string(),t.unknown()).default({})});function de(e,n){let o=n.type??(n.command!==void 0?"stdio":"http");return o==="stdio"?!n.command||n.url!==void 0?null:{name:e,command:n.command,args:n.args,env:n.env}:!n.url||n.command!==void 0?null:{name:e,url:n.url,transport:o,headers:n.headers}}function me(e){let n=I(e,fe);if(!L(n))return[];let o;try{o=JSON.parse(N(n,"utf-8"))}catch(a){return m.error({err:a,path:n},"invalid .mcp.json"),[]}let r=p(pe,o);if(!r.success)return m.error({error:r.error,path:n},"invalid .mcp.json"),[];let i=[];for(let[a,f]of Object.entries(r.data.mcpServers)){let s=p(ue,f);if(!a.trim()||!s.success){m.warn({name:a,path:n,error:s.success?void 0:s.error},"skipping invalid .mcp.json server entry");continue}let u=de(a,s.data);u?i.push(u):m.warn({name:a,path:n},"skipping invalid .mcp.json server entry")}return i}function Ye(e,n){let o=me(n);if(o.length===0)return e;let r=new Set(e.mcp_servers.map(i=>i.name));return{...e,mcp_servers:[...e.mcp_servers,...o.filter(i=>!r.has(i.name))]}}function Ge(e,n={}){if(e){let i=M(e);return O(i),(!n.allowEmptyProviders||i.providers.length>0)&&j(i),i}let o=X();if(!L(o)){if(n.allowEmptyProviders)return{default_provider:0,providers:[],mcp_servers:[],hooks:[]};throw new c(`No config file found, expected ${o}.`)}let r=M(o);return O(r),(!n.allowEmptyProviders||r.providers.length>0)&&j(r),r}var ge="Tool execution was interrupted. The tool may or may not have completed; verify before relying on its effects.",Ze="The user rejected this tool use. Nothing was changed (for file edits, the new content was NOT written).";function Xe(e){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.role==="assistant"&&r.toolUses?.length){n.push(r);let i=new Set(r.toolUses.map(s=>s.toolUseId)),a=[],f=[];for(;o+1<e.length;){let s=e[o+1];if(s.role!=="user"||!s.toolResults?.length||s.toolUses?.length)break;o++,f.push(s);for(let u of s.toolResults)i.delete(u.toolUseId)&&a.push(u)}for(let s of i)a.push({toolUseId:s,content:ge,isError:!0});n.push({...f[0]??{role:"user",content:""},toolResults:a});for(let s of f.slice(1))(s.content.length>0||s.thinkingBlocks?.length)&&n.push({...s,toolResults:[]});continue}if((r.toolResults?.length??0)>0){if(r.content.length===0&&!r.toolUses?.length&&!r.thinkingBlocks?.length)continue;n.push({...r,toolResults:[]})}else n.push(r)}return n}var g=class extends Error{constructor(n){super(n),this.name="LLMError"}},B=class extends g{constructor(n){super(n),this.name="AuthenticationError"}},H=class extends g{retryAfter;constructor(n,o){super(n),this.name="RateLimitError",this.retryAfter=o}},J=class extends g{constructor(n){super(n),this.name="NetworkError"}},Y=class extends g{constructor(n){super(n),this.name="ContextTooLongError"}};function Qe(e){return/context_length_exceeded/i.test(e)||/maximum\s+context\s+length/i.test(e)||/prompts?\s+(?:is\s+)?too\s+long/i.test(e)}export{p as a,Oe as b,Le as c,Ne as d,X as e,_ as f,z as g,ee as h,C as i,T as j,te as k,Fe as l,re as m,Be as n,R as o,ie as p,se as q,ae as r,U as s,K as t,He as u,Je as v,Ye as w,Ge as x,Ze as y,Xe as z,g as A,B,H as C,J as D,Y as E,Qe as F};
|
package/postinstall.mjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// Download yukino-code-${os}-${arch} from the fixed GitHub release into
|
|
2
|
-
// ~/.yukino/bin, the directory the CLI resolves the Go agent-bridge binary
|
|
3
|
-
// from. The single binary serves all three bridge transports, selected by its
|
|
4
|
-
// own --remote flag (stdio/rpc/ws).
|
|
5
|
-
//
|
|
6
|
-
// The release tag carries no version: every publish overwrites the same asset,
|
|
7
|
-
// so this always fetches the newest bridge build. Failures never block the
|
|
8
|
-
// install — the binary is only needed by the --remote=stdio/rpc/ws bridge
|
|
9
|
-
// transports, and a missing binary produces a targeted error at that point.
|
|
10
|
-
|
|
11
|
-
// @ts-check
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
chmodSync,
|
|
15
|
-
existsSync,
|
|
16
|
-
mkdirSync,
|
|
17
|
-
renameSync,
|
|
18
|
-
unlinkSync,
|
|
19
|
-
writeFileSync,
|
|
20
|
-
} from "node:fs";
|
|
21
|
-
import { homedir } from "node:os";
|
|
22
|
-
import path from "node:path";
|
|
23
|
-
import { fileURLToPath } from "node:url";
|
|
24
|
-
|
|
25
|
-
const RELEASE_BASE =
|
|
26
|
-
"https://github.com/hangtiancheng/yukino-code/releases/download/binaries";
|
|
27
|
-
const BIN_DIR = path.join(homedir(), ".yukino", "bin");
|
|
28
|
-
|
|
29
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
30
|
-
// Inside the monorepo the developer builds the binary locally instead
|
|
31
|
-
// (pnpm build:yukino); downloading would just overwrite that local build.
|
|
32
|
-
if (existsSync(path.join(here, "..", "..", "release.js"))) {
|
|
33
|
-
console.log(
|
|
34
|
-
"postinstall: inside the yukino-code repo — skipping bridge binary download (run `pnpm build:yukino` to build it into ~/.yukino/bin).",
|
|
35
|
-
);
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const { platform, arch } = process;
|
|
40
|
-
if (
|
|
41
|
-
!["linux", "darwin", "win32"].includes(platform) ||
|
|
42
|
-
!["x64", "arm64"].includes(arch)
|
|
43
|
-
) {
|
|
44
|
-
console.warn(
|
|
45
|
-
`postinstall: no prebuilt bridge binary for ${platform}-${arch} — skipping; the --remote=stdio/rpc/ws transports will not be available.`,
|
|
46
|
-
);
|
|
47
|
-
process.exit(0);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
mkdirSync(BIN_DIR, { recursive: true });
|
|
51
|
-
|
|
52
|
-
const name = `yukino-code-${platform}-${arch}`;
|
|
53
|
-
const dest = path.join(BIN_DIR, name);
|
|
54
|
-
const temporary = `${dest}.part`;
|
|
55
|
-
try {
|
|
56
|
-
const res = await fetch(`${RELEASE_BASE}/${name}`, { redirect: "follow" });
|
|
57
|
-
if (!res.ok) {
|
|
58
|
-
throw new Error(`HTTP ${res.status}`);
|
|
59
|
-
}
|
|
60
|
-
writeFileSync(temporary, Buffer.from(await res.arrayBuffer()));
|
|
61
|
-
if (platform !== "win32") {
|
|
62
|
-
chmodSync(temporary, 0o755);
|
|
63
|
-
}
|
|
64
|
-
renameSync(temporary, dest);
|
|
65
|
-
console.log(`postinstall: downloaded ${name} -> ${dest}`);
|
|
66
|
-
} catch (err) {
|
|
67
|
-
console.warn(
|
|
68
|
-
`postinstall: could not download ${name} (${err instanceof Error ? err.message : String(err)}); the --remote=stdio/rpc/ws bridge transports will not work until it is available.`,
|
|
69
|
-
);
|
|
70
|
-
} finally {
|
|
71
|
-
// The successful path already renamed the temp file away; only a failed
|
|
72
|
-
// download leaves it behind.
|
|
73
|
-
if (existsSync(temporary)) {
|
|
74
|
-
try {
|
|
75
|
-
unlinkSync(temporary);
|
|
76
|
-
} catch {
|
|
77
|
-
/* best effort */
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|