@yukino.js/yukino 0.0.6 → 0.0.7

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.
@@ -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 cn}from"./chunk-P6DHMU7R.js";import{a as on}from"./chunk-TPWRDFEX.js";import{$ as de,B as to,K as Wr,L as Ae,M as ro,N as an,T as oe,X as un,Y as Ct,Z as Is,_ as so,aa as Ps,ba as xs,o as en,q as tn,s as rn,t as sn,w as nn}from"./chunk-E7FXB7TA.js";import"./chunk-IW5L5276.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 Xe=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Xe=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 Jr(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var Xr=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 y=class extends Error{},N=class r extends y{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 $e({message:s,cause:Xr(t)});let o=t?.error;return e===400?new St(e,o,s,n):e===401?new kt(e,o,s,n):e===403?new $t(e,o,s,n):e===404?new Et(e,o,s,n):e===409?new vt(e,o,s,n):e===422?new Ot(e,o,s,n):e===429?new Tt(e,o,s,n):e>=500?new Lt(e,o,s,n):new r(e,o,s,n)}},M=class extends N{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},$e=class extends N{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},Ee=class extends $e{constructor({message:e}={}){super({message:e??"Request timed out."})}},St=class extends N{},kt=class extends N{},$t=class extends N{},Et=class extends N{},vt=class extends N{},Ot=class extends N{},Tt=class extends N{},Lt=class extends N{},jt=class extends y{constructor(){super("Could not parse response content as the length limit was reached")}},Ft=class extends y{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},fe=class extends Error{constructor(e){super(e)}},Ve=class extends N{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}},Vr=class extends y{constructor(e,t,s){super(e),this.provider=t,this.cause=s}};var Ri=/^[a-z][a-z0-9+.-]*:/i,no=r=>Ri.test(r),V=r=>(V=Array.isArray,V(r)),ln=V;function Rs(r){return typeof r!="object"?{}:r??{}}function pn(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 Gr(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var io=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new y(`${r} must be an integer`);if(e<0)throw new y(`${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 ve="6.49.0";var po=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ci(){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 Si=()=>{let r=Ci();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"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":ve,"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":ve,"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=ki();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"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":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ki(){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=Si());function Cs(){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 dn(...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 Qr(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return dn({start(){},async pull(t){let{done:s,value:n}=await e.next();s?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function Ss(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 fn(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 hn="RFC3986",mn=r=>String(r),_n={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:mn},_o="RFC1738";var ks=(r,e)=>(ks=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),ks(r,e)),me=(()=>{let r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();var yn=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+=yn){let f=o.length>=yn?o.slice(l,l+yn):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 gn(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)}},wo=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:hn,formatter:mn,indices:!1,serializeDate(r){return(Ao??(Ao=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function Ei(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var An={};function Io(r,e,t,s,n,o,a,l,f,p,h,_,m,w,P,b,I,$){let g=r,E=$,R=0,S=!1;for(;(E=E.get(An))!==void 0&&!S;){let L=E.get(r);if(R+=1,typeof L<"u"){if(L===R)throw new RangeError("Cyclic object value");S=!0}typeof E.get(An)>"u"&&(R=0)}if(typeof p=="function"?g=p(e,g):g instanceof Date?g=m?.(g):t==="comma"&&V(g)&&(g=gn(g,function(L){return L instanceof Date?m?.(L):L})),g===null){if(o)return f&&!b?f(e,z.encoder,I,"key",w):e;g=""}if(Ei(g)||go(g)){if(f){let L=b?e:f(e,z.encoder,I,"key",w);return[P?.(L)+"="+P?.(f(g,z.encoder,I,"value",w))]}return[P?.(e)+"="+P?.(String(g))]}let A=[];if(typeof g>"u")return A;let v;if(t==="comma"&&V(g))b&&f&&(g=gn(g,f)),v=[{value:g.length>0?g.join(",")||null:void 0}];else if(V(p))v=p;else{let L=Object.keys(g);v=h?L.sort(h):L}let j=l?String(e).replace(/\./g,"%2E"):String(e),F=s&&V(g)&&g.length===1?j+"[]":j;if(n&&V(g)&&g.length===0)return F+"[]";for(let L=0;L<v.length;++L){let W=v[L],Rt=typeof W=="object"&&typeof W.value<"u"?W.value:g[W];if(a&&Rt===null)continue;let J=_&&l?W.replace(/\./g,"%2E"):W,bs=V(g)?typeof t=="function"?t(F,J):F:F+(_?"."+J:"["+J+"]");$.set(r,R);let ws=new WeakMap;ws.set(An,$),wo(A,Io(Rt,bs,t,s,n,o,a,l,t==="comma"&&b&&V(g)?null:f,p,h,_,m,w,P,b,I,ws))}return A}function vi(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=hn;if(typeof r.format<"u"){if(!ks(_n,r.format))throw new TypeError("Unknown format option provided.");t=r.format}let s=_n[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=vi(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 w=n[m];s.skipNulls&&t[w]===null||wo(a,Io(t[w],w,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 bn(r){let e;return(Co??(e=new globalThis.TextDecoder,Co=e.decode.bind(e)))(r)}var te,re,Ge=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=Ti(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(bn(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=bn(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 cn}from"./chunk-P6DHMU7R.js";import{a as on}from"./chunk-7ZBAF7M4.js";import{$ as so,B as to,L as Wr,M as Ae,N as ro,O as an,U as oe,Y as un,Z as Ct,_ as Is,aa as de,ba as Ps,ca as xs,o as en,q as tn,s as rn,t as sn,w as nn}from"./chunk-NG62ISUV.js";import"./chunk-IW5L5276.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 Xe=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Xe=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 Jr(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var Xr=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 y=class extends Error{},N=class r extends y{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 $e({message:s,cause:Xr(t)});let o=t?.error;return e===400?new St(e,o,s,n):e===401?new kt(e,o,s,n):e===403?new $t(e,o,s,n):e===404?new Et(e,o,s,n):e===409?new vt(e,o,s,n):e===422?new Ot(e,o,s,n):e===429?new Tt(e,o,s,n):e>=500?new Lt(e,o,s,n):new r(e,o,s,n)}},M=class extends N{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},$e=class extends N{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},Ee=class extends $e{constructor({message:e}={}){super({message:e??"Request timed out."})}},St=class extends N{},kt=class extends N{},$t=class extends N{},Et=class extends N{},vt=class extends N{},Ot=class extends N{},Tt=class extends N{},Lt=class extends N{},jt=class extends y{constructor(){super("Could not parse response content as the length limit was reached")}},Ft=class extends y{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},fe=class extends Error{constructor(e){super(e)}},Ve=class extends N{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}},Vr=class extends y{constructor(e,t,s){super(e),this.provider=t,this.cause=s}};var Ri=/^[a-z][a-z0-9+.-]*:/i,no=r=>Ri.test(r),V=r=>(V=Array.isArray,V(r)),ln=V;function Rs(r){return typeof r!="object"?{}:r??{}}function pn(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 Gr(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var io=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new y(`${r} must be an integer`);if(e<0)throw new y(`${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 ve="6.49.0";var po=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Ci(){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 Si=()=>{let r=Ci();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"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":ve,"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":ve,"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=ki();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ve,"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":ve,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ki(){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=Si());function Cs(){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 dn(...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 Qr(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return dn({start(){},async pull(t){let{done:s,value:n}=await e.next();s?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function Ss(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 fn(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 hn="RFC3986",mn=r=>String(r),_n={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:mn},_o="RFC1738";var ks=(r,e)=>(ks=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),ks(r,e)),me=(()=>{let r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})();var yn=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+=yn){let f=o.length>=yn?o.slice(l,l+yn):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 gn(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)}},wo=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:hn,formatter:mn,indices:!1,serializeDate(r){return(Ao??(Ao=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function Ei(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var An={};function Io(r,e,t,s,n,o,a,l,f,p,h,_,m,w,P,b,I,$){let g=r,E=$,R=0,S=!1;for(;(E=E.get(An))!==void 0&&!S;){let L=E.get(r);if(R+=1,typeof L<"u"){if(L===R)throw new RangeError("Cyclic object value");S=!0}typeof E.get(An)>"u"&&(R=0)}if(typeof p=="function"?g=p(e,g):g instanceof Date?g=m?.(g):t==="comma"&&V(g)&&(g=gn(g,function(L){return L instanceof Date?m?.(L):L})),g===null){if(o)return f&&!b?f(e,z.encoder,I,"key",w):e;g=""}if(Ei(g)||go(g)){if(f){let L=b?e:f(e,z.encoder,I,"key",w);return[P?.(L)+"="+P?.(f(g,z.encoder,I,"value",w))]}return[P?.(e)+"="+P?.(String(g))]}let A=[];if(typeof g>"u")return A;let v;if(t==="comma"&&V(g))b&&f&&(g=gn(g,f)),v=[{value:g.length>0?g.join(",")||null:void 0}];else if(V(p))v=p;else{let L=Object.keys(g);v=h?L.sort(h):L}let j=l?String(e).replace(/\./g,"%2E"):String(e),F=s&&V(g)&&g.length===1?j+"[]":j;if(n&&V(g)&&g.length===0)return F+"[]";for(let L=0;L<v.length;++L){let W=v[L],Rt=typeof W=="object"&&typeof W.value<"u"?W.value:g[W];if(a&&Rt===null)continue;let J=_&&l?W.replace(/\./g,"%2E"):W,bs=V(g)?typeof t=="function"?t(F,J):F:F+(_?"."+J:"["+J+"]");$.set(r,R);let ws=new WeakMap;ws.set(An,$),wo(A,Io(Rt,bs,t,s,n,o,a,l,t==="comma"&&b&&V(g)?null:f,p,h,_,m,w,P,b,I,ws))}return A}function vi(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=hn;if(typeof r.format<"u"){if(!ks(_n,r.format))throw new TypeError("Unknown format option provided.");t=r.format}let s=_n[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=vi(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 w=n[m];s.skipNulls&&t[w]===null||wo(a,Io(t[w],w,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 bn(r){let e;return(Co??(e=new globalThis.TextDecoder,Co=e.decode.bind(e)))(r)}var te,re,Ge=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=Ti(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(bn(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=bn(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;Ge.NEWLINE_CHARS=new Set([`
6
6
  `,"\r"]);Ge.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ti(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 Es={off:0,error:200,warn:300,info:400,debug:500},wn=(r,e,t)=>{if(r){if(oo(Es,r))return r;K(t).warn(`${e} was set to ${JSON.stringify(r)}, expected one of ${JSON.stringify(Object.keys(Es))}`)}};function Yr(){}function $s(r,e,t){return!e||Es[r]>Es[t]?Yr:e[r].bind(e)}var Li={error:Yr,warn:Yr,info:Yr,debug:Yr},$o=new WeakMap;function K(r){let e=r.logger,t=r.logLevel??"off";if(!e)return Li;let s=$o.get(e);if(s&&s[0]===t)return s[1];let n={error:$s("error",e,t),warn:$s("warn",e,t),info:$s("info",e,t),debug:$s("debug",e,t)};return $o.set(e,[t,n]),n}var be=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 Zr,Z=class r{constructor(e,t,s){this.iterator=e,Zr.set(this,void 0),this.controller=t,x(this,Zr,s,"f")}static fromSSEResponse(e,t,s,n){let o=!1,a=s?K(s):console;async function*l(){if(o)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let f=!1;try{for await(let p of ji(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 N(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 N(void 0,h.error,h.message,void 0);yield{event:p.event,data:h}}}f=!0}catch(p){if(Jr(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 Ge,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:w}=await f.read();if(w){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 y("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||Jr(f))return;throw f}finally{l||t.abort()}}return new r(a,t,s)}[(Zr=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,Zr,"f")),new r(()=>n(t),this.controller,c(this,Zr,"f"))]}toReadableStream(){let e=this,t;return dn({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*ji(r,e){if(!r.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new y("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 y("Attempted to iterate over a response with no body");let t=new In,s=new Ge,n=Ss(r.body);for await(let o of Fi(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*Fi(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 In=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{b as a,c as b}from"./chunk-SYLHBECV.js";import"./chunk-JFKC4VCA.js";import"./chunk-IW5L5276.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};
4
+ import{b as a,c as b}from"./chunk-HWDSXNX4.js";import"./chunk-JFKC4VCA.js";import"./chunk-IW5L5276.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-XFVM5ZZL.js";import"./chunk-ME5UYXP4.js";import"./chunk-SYLHBECV.js";import"./chunk-JFKC4VCA.js";import"./chunk-WVT2D5AR.js";import"./chunk-E7FXB7TA.js";import"./chunk-IW5L5276.js";import"./chunk-NAQRFHUX.js";import"./chunk-VM4YKTHC.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};
4
+ import{b as a,c as b}from"./chunk-QQZCYWYI.js";import"./chunk-QRO6H32L.js";import"./chunk-HWDSXNX4.js";import"./chunk-JFKC4VCA.js";import"./chunk-7PPWFSIC.js";import"./chunk-NG62ISUV.js";import"./chunk-IW5L5276.js";import"./chunk-NAQRFHUX.js";import"./chunk-VM4YKTHC.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.6",
3
+ "version": "0.0.7",
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
  "acp",
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __yukinoCreateRequire } from "node:module";
3
- const require = __yukinoCreateRequire(import.meta.url);
4
- import{g as w}from"./chunk-MDPSQ6L7.js";import{a as W}from"./chunk-P6DHMU7R.js";import{a as V,g as D,h as J}from"./chunk-WVT2D5AR.js";import{a as j}from"./chunk-TPWRDFEX.js";import{$ as g,B as U,K,N as h,O as $,T as F,X as H,Y as q,Z as P,_ as z,aa as G,ba as Y,m as S,o as C,p as M,q as N,r as R,s as B,t as O,w as L}from"./chunk-E7FXB7TA.js";import"./chunk-IW5L5276.js";import"./chunk-7MKA3SHV.js";function Z(o){for(let t=o.length-1;t>=0;t--){let e=o[t];if(e.defer_loading!==!0){e.cache_control={type:"ephemeral"};return}}}function ee(o){return o.some(t=>"defer_loading"in t&&t.defer_loading===!0)}function te(o,t){if("input_schema"in o){let e=o,{cache_control:n,...i}=e;return t||delete i.type,{...i,...t?{type:"custom"}:{},...e.defer_loading!==!0&&n?{cache_control:n}:{}}}throw new Error("Anthropic received a tool schema serialized for another protocol.")}var oe=U({module:"llm"});function f(o){return typeof o=="string"?[{type:"text",text:o}]:o.map(t=>{let e=V(t);if(!e||e.type==="tool_reference")throw new Error(`Unsupported user content block: ${F(t,"type","unknown")}`);return e})}function ne(o){let t=[];for(let e of o)if(e.role==="assistant"){let n=[];if(e.thinkingBlocks)for(let l of e.thinkingBlocks)n.push({type:"thinking",thinking:l.thinking,signature:l.signature});let i=typeof e.content=="string"?e.content:K(e.content);if(i&&n.push({type:"text",text:i}),e.toolUses)for(let l of e.toolUses)n.push({type:"tool_use",id:l.toolUseId,name:l.toolName==="ComputerUse"?"computer":l.toolName,input:l.arguments});n.length===0&&n.push({type:"text",text:""}),t.push({role:"assistant",content:n})}else if(e.toolResults&&e.toolResults.length>0){let n=[];for(let i of e.toolResults)n.push({type:"tool_result",tool_use_id:i.toolUseId,is_error:i.isError,content:i.contentBlocks?.length?i.contentBlocks:i.content});e.content.length>0&&n.push(...f(e.content)),t.push({role:"user",content:n})}else{if(t.length===0){t.push({role:"user",content:f(e.content)});continue}let n=t[t.length-1],i=n.content;n.role==="user"?(typeof i=="string"&&(i=n.content=i.trim().length>0?[{type:"text",text:i}]:[]),i.push(...f(e.content))):t.push({role:"user",content:f(e.content)})}return t}var Q=class{protocol="anthropic";client;model;thinkingLevel;systemPrompt;maxOutputTokens;config;useExplicitCustomToolType;constructor(t,e){let n=j(t);if(!n)throw new P("Anthropic API key not found, set ANTHROPIC_API_KEY in ~/.yukino/config.yaml, or via ANTHROPIC_API_KEY env variable.");this.client=new w({apiKey:n,baseURL:t.base_url}),this.useExplicitCustomToolType=J(t.base_url),this.model=t.model,this.config={...t},this.thinkingLevel=C(t),this.systemPrompt=e,this.maxOutputTokens=L(t)}setSystemPrompt(t){this.systemPrompt=t}setMaxOutputTokens(t){this.config={...this.config,max_output_tokens:t},this.maxOutputTokens=L(this.config),this.setThinkingLevel(this.thinkingLevel)}setThinkingLevel(t){return this.thinkingLevel=O(this.config,t),this.thinkingLevel}getThinkingLevel(){return this.thinkingLevel}getSupportedThinkingLevels(){return B(this.config)}async*stream(t,e,n){let i=ne(H(t.getMessages())),l=ee(e),d=e.map(r=>te(r,this.useExplicitCustomToolType));Z(d),se(i);let p={model:this.model,max_tokens:this.maxOutputTokens,stream:!0,system:[{type:"text",text:this.systemPrompt,cache_control:{type:"ephemeral"}}],messages:i,...d.length>0?{tools:d}:{}},k=this.getThinkingLevel();if(this.config.reasoning!==!1)if(k==="off")p.thinking={type:"disabled"};else if(this.config.thinking_mode==="adaptive"){let r=R(k,this.config);r!==null&&(p.thinking={type:"adaptive"},p.output_config={effort:r})}else{let r=N(k,this.config);r!==null&&r!=="none"&&(p.thinking={type:"enabled",budget_tokens:Math.min(M(r),this.maxOutputTokens-S)})}let _=0,y=0,T=0,v=0,E="end_turn",A="",b="",x=!1,I=!1;try{let r=[...l?[D]:[]],X=this.client.messages.stream(p,{...n?{signal:n}:{},...r.length>0?{headers:{"anthropic-beta":r.join(",")}}:{}}),c="",u="",m="";for await(let a of X)switch(a.type){case"content_block_start":{let s=a.content_block;if(s.type==="thinking")x=!0,A="",b="";else if(s.type==="tool_use"){if(!s.id||!s.name)throw new g("Anthropic tool call started without a valid id or name");u=s.id,c=s.name==="computer"?"ComputerUse":s.name,m="",yield{type:"tool_call_start",toolName:c,toolId:u}}break}case"content_block_delta":{let s=a.delta;if(s.type==="thinking_delta")A+=s.thinking,yield{type:"thinking_delta",text:s.thinking};else if(s.type==="signature_delta")b+=s.signature;else if(s.type==="text_delta")yield{type:"text_delta",text:s.text};else if(s.type==="input_json_delta"){if(!u||!c)throw new g("Anthropic tool arguments arrived before a valid tool call");m+=s.partial_json,yield{type:"tool_call_delta",text:s.partial_json}}break}case"content_block_stop":{if(x&&(yield{type:"thinking_complete",thinking:A,signature:b},x=!1),c){let s=W(m);yield{type:"tool_call_complete",toolId:u,toolName:c,arguments:s.arguments,...s.parseError?{parseError:s.parseError}:{}},c="",u="",m=""}break}case"message_delta":{a.delta.stop_reason&&(E=a.delta.stop_reason);let s=a.usage;typeof s.output_tokens=="number"&&(y=s.output_tokens),typeof s.input_tokens=="number"&&(_=s.input_tokens),typeof s.cache_read_input_tokens=="number"&&(T=s.cache_read_input_tokens),typeof s.cache_creation_input_tokens=="number"&&(v=s.cache_creation_input_tokens);break}case"message_stop":{I=!0;break}case"message_start":{_=a.message.usage.input_tokens,y=a.message.usage.output_tokens,T=a.message.usage.cache_read_input_tokens??0,v=a.message.usage.cache_creation_input_tokens??0;break}}if(!I)throw new g("Anthropic stream ended without message_stop; response was truncated");yield{type:"stream_end",stopReason:E,usage:{inputTokens:_,outputTokens:y,cacheReadInputTokens:T,cacheCreationInputTokens:v}}}catch(r){throw oe.error({err:r},"llm operation failed"),ie(r)}}};function se(o){for(let t=o.length-1;t>=0;t--){if(o[t].role!=="user")continue;let e=o[t].content;if(typeof e=="string"&&e.length===0||Array.isArray(e)&&e.length===0)return;typeof e=="string"&&(e=o[t].content=[{type:"text",text:e}]);let n=e[e.length-1];for(let i=e.length-1;i>=0;i--)if(e[i].type!=="image"){n=e[i];break}Reflect.set(n,"cache_control",{type:"ephemeral"});return}}function ie(o){if(o instanceof w.APIError){if(o.status===413||o.status===400&&Y(o.message))return new G(`Prompt too long: ${o.message}`);if(o.status===401)return new P(`Invalid API key: ${o.message}`);if(o.status===429){let t=o.headers,e=t instanceof Headers?t.get("retry-after"):void 0,n="Rate Limited";if(e){let i=Number.parseInt(h(e));Number.isNaN(i)?n+=", please wait.":n+=`, retry after ${h(i)}s.`}else n+=", please wait.";return new z(n,e?h(e):void 0)}return new q(`Anthropic API error (${h(o.status)}): ${o.message}`)}return new g(`Network error: ${$(o)}`)}export{Q as AnthropicClient,ne as buildAnthropicMessages,se as markLastUserTailForCache,Z as markToolsForCache,ee as needsToolSearchBeta};