@plusonelabs/cue 0.0.62 → 0.0.63
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/cue-v0.0.63.tar.gz +0 -0
- package/dist/cli.mjs +2 -2
- package/package.json +1 -1
- package/cue-v0.0.62.tar.gz +0 -0
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url); global.__CUE_VERSION__ = '0.0.
|
|
2
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url); global.__CUE_VERSION__ = '0.0.63';
|
|
3
3
|
var ume=Object.create;var fT=Object.defineProperty;var dme=Object.getOwnPropertyDescriptor;var pme=Object.getOwnPropertyNames;var fme=Object.getPrototypeOf,mme=Object.prototype.hasOwnProperty;var Lt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var T=(t,e)=>()=>(t&&(e=t(t=0)),e);var Te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Un=(t,e)=>{for(var n in e)fT(t,n,{get:e[n],enumerable:!0})},mq=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pme(e))!mme.call(t,o)&&o!==n&&fT(t,o,{get:()=>e[o],enumerable:!(s=dme(e,o))||s.enumerable});return t};var ke=(t,e,n)=>(n=t!=null?ume(fme(t)):{},mq(e||!t||!t.__esModule?fT(n,"default",{value:t,enumerable:!0}):n,t)),Aq=t=>mq(fT({},"__esModule",{value:!0}),t);import mT from"fs";import rM from"path";function lm(){if(typeof global.__CUE_VERSION__<"u")return global.__CUE_VERSION__;try{let t=process.argv[1],e=rM.join(rM.dirname(t),"..","package.json");if(mT.existsSync(e)){let n=mT.readFileSync(e,"utf-8");return JSON.parse(n).version}}catch{}if(process.argv[1].includes("src/cli.tsx"))try{let t=rM.join(process.cwd(),"package.json");if(mT.existsSync(t)){let e=mT.readFileSync(t,"utf-8");return JSON.parse(e).version}}catch{}return"unknown"}var Ub=T(()=>{"use strict"});function rt(t,e,n,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(t,n):o?o.value=n:e.set(t,n),n}function de(t,e,n,s){if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?s:n==="a"?s.call(t):s?s.value:e.get(t)}var vp=T(()=>{});var aM,yq=T(()=>{aM=function(){let{crypto:t}=globalThis;if(t?.randomUUID)return aM=t.randomUUID.bind(t),t.randomUUID();let e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^n()&15>>+s/4).toString(16))}});function Cp(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}var Fb,yv=T(()=>{Fb=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){let e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)}});var yt,Ai,$i,um,Ev,vv,Cv,Sv,Iv,xv,bv,_v,Bv,jc=T(()=>{yv();yt=class extends Error{},Ai=class t extends yt{constructor(e,n,s,o){super(`${t.makeMessage(e,n,s)}`),this.status=e,this.headers=o,this.requestID=o?.get("request-id"),this.error=n}static makeMessage(e,n,s){let o=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,n,s,o){if(!e||!o)return new um({message:s,cause:Fb(n)});let i=n;return e===400?new vv(e,i,s,o):e===401?new Cv(e,i,s,o):e===403?new Sv(e,i,s,o):e===404?new Iv(e,i,s,o):e===409?new xv(e,i,s,o):e===422?new bv(e,i,s,o):e===429?new _v(e,i,s,o):e>=500?new Bv(e,i,s,o):new t(e,i,s,o)}},$i=class extends Ai{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},um=class extends Ai{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}},Ev=class extends um{constructor({message:e}={}){super({message:e??"Request timed out."})}},vv=class extends Ai{},Cv=class extends Ai{},Sv=class extends Ai{},Iv=class extends Ai{},xv=class extends Ai{},bv=class extends Ai{},_v=class extends Ai{},Bv=class extends Ai{}});function AT(t){return typeof t!="object"?{}:t??{}}function vq(t){if(!t)return!0;for(let e in t)return!1;return!0}function Cq(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var gme,Eq,cM,lM,Sq,gT,Lg=T(()=>{jc();gme=/^[a-z][a-z0-9+.-]*:/i,Eq=t=>gme.test(t),cM=t=>(cM=Array.isArray,cM(t)),lM=cM;Sq=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new yt(`${t} must be an integer`);if(e<0)throw new yt(`${t} must be a positive integer`);return e},gT=t=>{try{return JSON.parse(t)}catch{return}}});var Iq,xq=T(()=>{Iq=t=>new Promise(e=>setTimeout(e,t))});var dm,uM=T(()=>{dm="0.71.2"});function hme(){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"}function Eme(){if(typeof navigator>"u"||!navigator)return null;let t=[{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:n}of t){let s=n.exec(navigator.userAgent);if(s){let o=s[1]||0,i=s[2]||0,c=s[3]||0;return{browser:e,version:`${o}.${i}.${c}`}}}return null}var wq,yme,bq,_q,Bq,Dq,dM=T(()=>{uM();wq=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";yme=()=>{let t=hme();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":dm,"X-Stainless-OS":_q(Deno.build.os),"X-Stainless-Arch":bq(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":dm,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":dm,"X-Stainless-OS":_q(globalThis.process.platform??"unknown"),"X-Stainless-Arch":bq(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=Eme();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":dm,"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":dm,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};bq=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",_q=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown"),Dq=()=>Bq??(Bq=yme())});function Tq(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pM(...t){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(...t)}function hT(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return pM({start(){},async pull(n){let{done:s,value:o}=await e.next();s?n.close():n.enqueue(o)},async cancel(){await e.return?.()}})}function Pb(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let n=await e.read();return n?.done&&e.releaseLock(),n}catch(n){throw e.releaseLock(),n}},async return(){let n=e.cancel();return e.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Qq(t){if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await t[Symbol.asyncIterator]().return?.();return}let e=t.getReader(),n=e.cancel();e.releaseLock(),await n}var wv=T(()=>{});var Rq,kq=T(()=>{Rq=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)})});function Mq(t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),s=0;for(let o of t)n.set(o,s),s+=o.length;return n}function Lb(t){let e;return(Nq??(e=new globalThis.TextEncoder,Nq=e.encode.bind(e)))(t)}function fM(t){let e;return(Oq??(e=new globalThis.TextDecoder,Oq=e.decode.bind(e)))(t)}var Nq,Oq,mM=T(()=>{});function Sme(t,e){for(let o=e??0;o<t.length;o++){if(t[o]===10)return{preceding:o,index:o+1,carriage:!1};if(t[o]===13)return{preceding:o,index:o+1,carriage:!0}}return null}function Uq(t){for(let s=0;s<t.length-1;s++){if(t[s]===10&&t[s+1]===10||t[s]===13&&t[s+1]===13)return s+2;if(t[s]===13&&t[s+1]===10&&s+3<t.length&&t[s+2]===13&&t[s+3]===10)return s+4}return-1}var Ka,qa,Sp,AM=T(()=>{vp();mM();Sp=class{constructor(){Ka.set(this,void 0),qa.set(this,void 0),rt(this,Ka,new Uint8Array,"f"),rt(this,qa,null,"f")}decode(e){if(e==null)return[];let n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Lb(e):e;rt(this,Ka,Mq([de(this,Ka,"f"),n]),"f");let s=[],o;for(;(o=Sme(de(this,Ka,"f"),de(this,qa,"f")))!=null;){if(o.carriage&&de(this,qa,"f")==null){rt(this,qa,o.index,"f");continue}if(de(this,qa,"f")!=null&&(o.index!==de(this,qa,"f")+1||o.carriage)){s.push(fM(de(this,Ka,"f").subarray(0,de(this,qa,"f")-1))),rt(this,Ka,de(this,Ka,"f").subarray(de(this,qa,"f")),"f"),rt(this,qa,null,"f");continue}let i=de(this,qa,"f")!==null?o.preceding-1:o.preceding,c=fM(de(this,Ka,"f").subarray(0,i));s.push(c),rt(this,Ka,de(this,Ka,"f").subarray(o.index),"f"),rt(this,qa,null,"f")}return s}flush(){return de(this,Ka,"f").length?this.decode(`
|
|
4
4
|
`):[]}};Ka=new WeakMap,qa=new WeakMap;Sp.NEWLINE_CHARS=new Set([`
|
|
5
5
|
`,"\r"]);Sp.NEWLINE_REGEXP=/\r\n|[\n\r]/g});function $b(){}function yT(t,e,n){return!e||ET[t]>ET[n]?$b:e[t].bind(e)}function gi(t){let e=t.logger,n=t.logLevel??"off";if(!e)return Ime;let s=Fq.get(e);if(s&&s[0]===n)return s[1];let o={error:yT("error",e,n),warn:yT("warn",e,n),info:yT("info",e,n),debug:yT("debug",e,n)};return Fq.set(e,[n,o]),o}var ET,gM,Ime,Fq,Ip,vT=T(()=>{Lg();ET={off:0,error:200,warn:300,info:400,debug:500},gM=(t,e,n)=>{if(t){if(Cq(ET,t))return t;gi(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(ET))}`)}};Ime={error:$b,warn:$b,info:$b,debug:$b},Fq=new WeakMap;Ip=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="x-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t)});async function*xme(t,e){if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new yt("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 yt("Attempted to iterate over a response with no body");let n=new hM,s=new Sp,o=Pb(t.body);for await(let i of bme(o))for(let c of s.decode(i)){let d=n.decode(c);d&&(yield d)}for(let i of s.flush()){let c=n.decode(i);c&&(yield c)}}async function*bme(t){let e=new Uint8Array;for await(let n of t){if(n==null)continue;let s=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?Lb(n):n,o=new Uint8Array(e.length+s.length);o.set(e),o.set(s,e.length),e=o;let i;for(;(i=Uq(e))!==-1;)yield e.slice(0,i),e=e.slice(i)}e.length>0&&(yield e)}function _me(t,e){let n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}var zb,Wu,hM,yM=T(()=>{vp();jc();wv();AM();wv();yv();Lg();mM();vT();jc();Wu=class t{constructor(e,n,s){this.iterator=e,zb.set(this,void 0),this.controller=n,rt(this,zb,s,"f")}static fromSSEResponse(e,n,s){let o=!1,i=s?gi(s):console;async function*c(){if(o)throw new yt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let d=!1;try{for await(let f of xme(e,n)){if(f.event==="completion")try{yield JSON.parse(f.data)}catch(m){throw i.error("Could not parse message into JSON:",f.data),i.error("From chunk:",f.raw),m}if(f.event==="message_start"||f.event==="message_delta"||f.event==="message_stop"||f.event==="content_block_start"||f.event==="content_block_delta"||f.event==="content_block_stop")try{yield JSON.parse(f.data)}catch(m){throw i.error("Could not parse message into JSON:",f.data),i.error("From chunk:",f.raw),m}if(f.event!=="ping"&&f.event==="error")throw new Ai(void 0,gT(f.data)??f.data,void 0,e.headers)}d=!0}catch(f){if(Cp(f))return;throw f}finally{d||n.abort()}}return new t(c,n,s)}static fromReadableStream(e,n,s){let o=!1;async function*i(){let d=new Sp,f=Pb(e);for await(let m of f)for(let h of d.decode(m))yield h;for(let m of d.flush())yield m}async function*c(){if(o)throw new yt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let d=!1;try{for await(let f of i())d||f&&(yield JSON.parse(f));d=!0}catch(f){if(Cp(f))return;throw f}finally{d||n.abort()}}return new t(c,n,s)}[(zb=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],n=[],s=this.iterator(),o=i=>({next:()=>{if(i.length===0){let c=s.next();e.push(c),n.push(c)}return i.shift()}});return[new t(()=>o(e),this.controller,de(this,zb,"f")),new t(()=>o(n),this.controller,de(this,zb,"f"))]}toReadableStream(){let e=this,n;return pM({async start(){n=e[Symbol.asyncIterator]()},async pull(s){try{let{value:o,done:i}=await n.next();if(i)return s.close();let c=Lb(JSON.stringify(o)+`
|
|
@@ -46,7 +46,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
46
46
|
Output: ${e.totalOutputTokens.toLocaleString()}
|
|
47
47
|
Cached: ${e.totalCachedTokens.toLocaleString()}
|
|
48
48
|
${n?`Estimated Cost: $${n.total}`:""}
|
|
49
|
-
${s?`Cache Hit Rate: ${s.hitRate}% (${s.efficiency})`:""}`}reset(){this.sessionStats=null,this.interactions=[]}},Bp=new sU});function c0(t){return t instanceof zv?{name:t.name,message:t.message,timestamp:t.timestamp,context:t.context,stack:t.stack,...t instanceof wp&&{statusCode:t.statusCode,apiResponse:t.apiResponse},...t instanceof Dp&&{toolName:t.toolName,toolInput:t.toolInput},...t instanceof rU&&{operation:t.operation,filePath:t.filePath}}:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:{error:String(t),type:typeof t}}var zv,wp,Dp,rU,jv=T(()=>{zv=class extends Error{timestamp;context;constructor(e,n){super(e),this.name=this.constructor.name,this.timestamp=new Date().toISOString(),this.context=n}},wp=class extends zv{statusCode;apiResponse;constructor(e,n,s,o){super(e,o),this.statusCode=n,this.apiResponse=s}},Dp=class extends zv{toolName;toolInput;constructor(e,n,s,o){super(`Tool ${e} failed: ${n}`,o),this.toolName=e,this.toolInput=s}},rU=class extends zv{filePath;operation;constructor(e,n,s,o){super(`${e} failed for ${n}: ${s}`,o),this.operation=e,this.filePath=n}}});var yJ={};Un(yJ,{clearConfigCache:()=>lU,getConfigPath:()=>uU,getConfigValue:()=>cU,getCurrentEnvironment:()=>yi,getCurrentEnvironmentKeys:()=>Ya,getCurrentEnvironmentOnlyKeys:()=>Zc,getEnvironmentBaseUrl:()=>la,getMachineName:()=>ym,getProjectId:()=>Em,getSandboxId:()=>Hv,getSessionId:()=>p0,loadGlobalConfig:()=>hi,saveGlobalConfig:()=>l0,setCurrentEnvironment:()=>u0,setEnvironmentKeys:()=>Za,setGlobalApiKeys:()=>Yg,setMachineName:()=>d0,setProjectId:()=>dU,setSandboxId:()=>pU,setSessionId:()=>fU,updateGlobalConfig:()=>Yc});import{existsSync as mJ,readFileSync as Wme,writeFileSync as AJ,mkdirSync as Vme}from"fs";import{join as gJ}from"path";import{homedir as Xme}from"os";function hJ(){mJ(HT)||(Vme(HT,{recursive:!0,mode:448}),v.debug("Created config directory",{path:HT}))}function hi(){if(Vs)return Vs;if(hJ(),!mJ(ed))return v.info("Config file not found, using defaults",{path:ed}),Vs={...aU},Vs;try{let t=Wme(ed,"utf-8"),e=JSON.parse(t),n=!1;return e.currentEnvironment==="dev"&&(e.currentEnvironment="local",n=!0),e.environments?.dev&&(e.environments.local=e.environments.dev,delete e.environments.dev,n=!0),Vs={...aU,...e},n&&(v.info("Migrated config: renamed dev environment to local"),AJ(ed,JSON.stringify(Vs,null,2),{mode:384})),v.info("Loaded config from disk",{path:ed,currentEnvironment:Vs?.currentEnvironment,projectId:Vs?.projectId,sandboxId:Vs?.sandboxId,sessionId:Vs?.sessionId,hasProjectId:!!Vs?.projectId,hasSandboxId:!!Vs?.sandboxId,hasSessionId:!!Vs?.sessionId}),Vs}catch(t){return v.error("Failed to load config file",{path:ed,error:t instanceof Error?t.message:String(t)}),Vs={...aU},Vs}}function l0(t){hJ();try{Vs={...t,lastUpdated:new Date().toISOString()},AJ(ed,JSON.stringify(Vs,null,2),{mode:384}),v.info("Saved config to disk",{path:ed})}catch(e){throw v.error("Failed to save config file",{path:ed,error:e instanceof Error?e.message:String(e)}),e}}function Yc(t){let n={...hi(),...t};l0(n)}function cU(t){return hi()[t]}function lU(){Vs=null}function uU(){return ed}function la(t){if(process.env.CUE_BASE_URL)return process.env.CUE_BASE_URL;let e=hi(),n=t||yi(),s=e.environments?.[n];if(s?.apiUrl)return s.apiUrl;if(s?.baseUrl)return s.baseUrl;switch(n){case"production":return"https://
|
|
49
|
+
${s?`Cache Hit Rate: ${s.hitRate}% (${s.efficiency})`:""}`}reset(){this.sessionStats=null,this.interactions=[]}},Bp=new sU});function c0(t){return t instanceof zv?{name:t.name,message:t.message,timestamp:t.timestamp,context:t.context,stack:t.stack,...t instanceof wp&&{statusCode:t.statusCode,apiResponse:t.apiResponse},...t instanceof Dp&&{toolName:t.toolName,toolInput:t.toolInput},...t instanceof rU&&{operation:t.operation,filePath:t.filePath}}:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:{error:String(t),type:typeof t}}var zv,wp,Dp,rU,jv=T(()=>{zv=class extends Error{timestamp;context;constructor(e,n){super(e),this.name=this.constructor.name,this.timestamp=new Date().toISOString(),this.context=n}},wp=class extends zv{statusCode;apiResponse;constructor(e,n,s,o){super(e,o),this.statusCode=n,this.apiResponse=s}},Dp=class extends zv{toolName;toolInput;constructor(e,n,s,o){super(`Tool ${e} failed: ${n}`,o),this.toolName=e,this.toolInput=s}},rU=class extends zv{filePath;operation;constructor(e,n,s,o){super(`${e} failed for ${n}: ${s}`,o),this.operation=e,this.filePath=n}}});var yJ={};Un(yJ,{clearConfigCache:()=>lU,getConfigPath:()=>uU,getConfigValue:()=>cU,getCurrentEnvironment:()=>yi,getCurrentEnvironmentKeys:()=>Ya,getCurrentEnvironmentOnlyKeys:()=>Zc,getEnvironmentBaseUrl:()=>la,getMachineName:()=>ym,getProjectId:()=>Em,getSandboxId:()=>Hv,getSessionId:()=>p0,loadGlobalConfig:()=>hi,saveGlobalConfig:()=>l0,setCurrentEnvironment:()=>u0,setEnvironmentKeys:()=>Za,setGlobalApiKeys:()=>Yg,setMachineName:()=>d0,setProjectId:()=>dU,setSandboxId:()=>pU,setSessionId:()=>fU,updateGlobalConfig:()=>Yc});import{existsSync as mJ,readFileSync as Wme,writeFileSync as AJ,mkdirSync as Vme}from"fs";import{join as gJ}from"path";import{homedir as Xme}from"os";function hJ(){mJ(HT)||(Vme(HT,{recursive:!0,mode:448}),v.debug("Created config directory",{path:HT}))}function hi(){if(Vs)return Vs;if(hJ(),!mJ(ed))return v.info("Config file not found, using defaults",{path:ed}),Vs={...aU},Vs;try{let t=Wme(ed,"utf-8"),e=JSON.parse(t),n=!1;return e.currentEnvironment==="dev"&&(e.currentEnvironment="local",n=!0),e.environments?.dev&&(e.environments.local=e.environments.dev,delete e.environments.dev,n=!0),Vs={...aU,...e},n&&(v.info("Migrated config: renamed dev environment to local"),AJ(ed,JSON.stringify(Vs,null,2),{mode:384})),v.info("Loaded config from disk",{path:ed,currentEnvironment:Vs?.currentEnvironment,projectId:Vs?.projectId,sandboxId:Vs?.sandboxId,sessionId:Vs?.sessionId,hasProjectId:!!Vs?.projectId,hasSandboxId:!!Vs?.sandboxId,hasSessionId:!!Vs?.sessionId}),Vs}catch(t){return v.error("Failed to load config file",{path:ed,error:t instanceof Error?t.message:String(t)}),Vs={...aU},Vs}}function l0(t){hJ();try{Vs={...t,lastUpdated:new Date().toISOString()},AJ(ed,JSON.stringify(Vs,null,2),{mode:384}),v.info("Saved config to disk",{path:ed})}catch(e){throw v.error("Failed to save config file",{path:ed,error:e instanceof Error?e.message:String(e)}),e}}function Yc(t){let n={...hi(),...t};l0(n)}function cU(t){return hi()[t]}function lU(){Vs=null}function uU(){return ed}function la(t){if(process.env.CUE_BASE_URL)return process.env.CUE_BASE_URL;let e=hi(),n=t||yi(),s=e.environments?.[n];if(s?.apiUrl)return s.apiUrl;if(s?.baseUrl)return s.baseUrl;switch(n){case"production":return"https://api.cueos.ai";case"staging":return"https://api-staging.cueos.ai";default:return"http://localhost:8000"}}function yi(){let t=hi();return t.currentEnvironment?t.currentEnvironment:eAe()}function eAe(){let t=process.env.NODE_ENV,e=process.argv[1]||"",n=process.argv[0]||"";return t==="production"?"production":e.includes("dist/cli.mjs")||e.includes("bin/cue.mjs")||e.endsWith("/cue")?(v.debug("Environment detected as production from built bundle path",{currentPath:e}),"production"):e.includes("src/")||n.includes("tsx")?"local":(v.debug("Environment defaulted to production"),"production")}function u0(t){Yc({currentEnvironment:t})}function Ya(){let t=hi(),e=yi();v.debug("Getting environment keys",{currentEnvironment:e,hasEnvConfig:!!t.environments?.[e]});let n=t.environments?.[e],s={cueApiKey:n?.cueApiKey,accessToken:n?.accessToken,refreshToken:n?.refreshToken,anthropicApiKey:t.anthropicApiKey,openaiApiKey:t.openaiApiKey,geminiApiKey:t.geminiApiKey};return v.debug("Resolved keys",{environment:e,hasCueKey:!!s.cueApiKey,hasAnthropicKey:!!s.anthropicApiKey,hasOpenAIKey:!!s.openaiApiKey,hasGeminiKey:!!s.geminiApiKey,hasAccessToken:!!s.accessToken,hasRefreshToken:!!s.refreshToken}),s}function Zc(){let t=hi(),e=yi(),n=t.environments?.[e];return{cueApiKey:n?.cueApiKey,accessToken:n?.accessToken,refreshToken:n?.refreshToken}}function Za(t,e){let n=hi(),s={...n,environments:{...n.environments,[t]:{...n.environments?.[t],...e}}};l0(s)}function Yg(t){Yc(t)}function ym(){return hi().machineName}function d0(t){Yc({machineName:t})}function Em(){return hi().projectId}function dU(t){Yc({projectId:t})}function Hv(){return hi().sandboxId}function pU(t){Yc({sandboxId:t})}function p0(){return hi().sessionId}function fU(t){Yc({sessionId:t})}var HT,ed,aU,Vs,Zg=T(()=>{Qt();HT=process.env.CUE_CONFIG_DIR||gJ(Xme(),".cue"),ed=gJ(HT,"config.json"),aU={environments:{local:{},staging:{},production:{}},autoConnect:!0,theme:"dark"},Vs=null});import{existsSync as Gv,mkdirSync as mU,writeFileSync as GT}from"fs";import{join as Tp}from"path";import{homedir as EJ}from"os";import{randomUUID as tAe}from"crypto";function vJ(t){return(t.startsWith("/")?t:`/${t}`).replace(/\//g,"-").replace(/[^a-zA-Z0-9\-_.]/g,"_")}async function IJ(){try{let{loadGlobalConfig:t}=await Promise.resolve().then(()=>(Zg(),yJ)),e=t();if(e.logLevel&&!process.env.CUE_LOG_LEVEL){let n=vm[e.logLevel];n!==void 0&&v.setLogLevel(n)}e.consoleLogging&&!process.env.CUE_ENABLE_CONSOLE_LOG&&v.setConsoleLogging(!0)}catch{}}var Wc,Kv,Qp,CJ,vm,AU,v,SJ,Qt=T(()=>{iU();jv();Kv=global;Kv.__LOGGER_SESSION_ID?Wc=Kv.__LOGGER_SESSION_ID:(Wc=process.env.CLI_SESSION_ID||tAe(),Kv.__LOGGER_SESSION_ID=Wc);Qp=[],CJ=50,vm=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o))(vm||{}),AU=class{logPath;debugLogPath;sessionLogPath;currentLogLevel=0;initialized=!1;isDevelopment=!1;consoleLoggingEnabled=!1;ensureInitialized(){if(this.initialized)return;this.isDevelopment=process.env.NODE_ENV==="development"||process.cwd().includes("/cue/cli")&&Gv(Tp(process.cwd(),"src"))||process.cwd().includes("/cue/cli")&&Gv(Tp(process.cwd(),"package.json")),this.consoleLoggingEnabled=this.isDevelopment||process.env.CUE_ENABLE_CONSOLE_LOG==="true";let e=this.isDevelopment?Tp(process.cwd(),"logs"):Tp(EJ(),".cue","logs"),n=new Date,s=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),d=String(n.getMinutes()).padStart(2,"0"),f=`${s}-${o}-${i}-${c}-${d}`,m=Tp(e,"debug");Gv(m)||mU(m,{recursive:!0,mode:493}),this.logPath=Tp(m,`debug-${f}-${Wc}.log`),this.debugLogPath=Tp(e,"debug.log");let h=process.cwd(),C=vJ(h),I=Tp(EJ(),".cue","projects",C);this.sessionLogPath=Tp(I,`${Wc}-log.jsonl`),Gv(e)||mU(e,{recursive:!0}),Gv(I)||mU(I,{recursive:!0});try{Bp.initSession(Wc)}catch(x){console.warn("Token tracking initialization failed:",x)}this.initialized=!0}log(e,n,s){if(e<this.currentLogLevel)return;this.ensureInitialized();let o={level:e,message:n,timestamp:new Date().toISOString(),sessionId:Wc,cwd:process.cwd(),...s&&{data:s}};this.consoleLoggingEnabled&&e>0&&this.logToConsole(o),this.logToFile(o)}logToConsole(e){let n=vm[e.level],s=e.timestamp.split("T")[1]?.split(".")[0]||"",o="";switch(e.level){case 0:o="\x1B[90m";break;case 1:o="\x1B[34m";break;case 2:o="\x1B[33m";break;case 3:o="\x1B[31m";break}console.log(`${o}[${s}] ${n}:\x1B[0m ${e.message}`),e.data&&console.log(" Data:",e.data)}logToFile(e){try{let n=vm[e.level],s=new Date(e.timestamp).toLocaleTimeString(),o=e.data?`[${s}] ${n}: ${e.message} ${JSON.stringify(e.data,null,2)}
|
|
50
50
|
`:`[${s}] ${n}: ${e.message}
|
|
51
51
|
`;GT(this.logPath,o,{flag:"a",encoding:"utf8"}),GT(this.debugLogPath,o,{flag:"a",encoding:"utf8"})}catch(n){console.error("Failed to write to log file:",n)}}logSessionToFile(e){this.ensureInitialized();try{let n=JSON.stringify(e)+`
|
|
52
52
|
`;GT(this.sessionLogPath,n,{flag:"a",encoding:"utf8"})}catch(n){console.error("Failed to write to session log file:",n)}}setLogLevel(e){this.currentLogLevel=e}setConsoleLogging(e){this.consoleLoggingEnabled=e}isConsoleLoggingEnabled(){return this.ensureInitialized(),this.consoleLoggingEnabled}debug(e,n){this.log(0,e,n)}info(e,n){this.log(1,e,n)}warn(e,n){this.log(2,e,n)}error(e,n){this.log(3,e,n);let s={error:c0(n||new Error(e)),timestamp:new Date().toISOString(),level:3};Qp.length>=CJ&&Qp.shift(),Qp.push(s)}logError(e,n){try{process.env.NODE_ENV==="test"&&console.error(e);let s=c0(e),o={error:s,timestamp:new Date().toISOString(),level:3,context:n};Qp.length>=CJ&&Qp.shift(),Qp.push(o),this.log(3,s.message||"Unknown error",{error:s,context:n})}catch(s){console.error("Failed to log error:",s)}}toolStart(e,n){this.info(`Tool execution started: ${e}`,{input:n})}toolSuccess(e,n){this.info(`Tool execution succeeded: ${e}`,{output:n})}toolError(e,n){this.error(`Tool execution failed: ${e}`,{error:n.message||n})}cacheHit(e,n){this.debug(`Cache hit for ${e}`,{cacheReadTokens:n})}cacheMiss(e,n){this.debug(`Cache miss for ${e}`,{cacheCreationTokens:n})}logUserMessage(e){this.ensureInitialized();let n={sessionId:Wc,timestamp:new Date().toISOString(),type:"user",content:e};this.logSessionToFile(n)}logAssistantMessage(e,n){if(this.ensureInitialized(),n?.usage)try{Bp.addTokenUsage(n.usage,n.model)}catch(o){this.error("Failed to track tokens",{error:String(o)})}let s={sessionId:Wc,timestamp:new Date().toISOString(),type:"assistant",content:e,metadata:n};this.logSessionToFile(s)}logToolExecution(e,n,s,o){this.ensureInitialized();let i={sessionId:Wc,timestamp:new Date().toISOString(),type:"tool",content:o?`Tool ${e} executed successfully`:`Tool ${e} failed`,metadata:{toolName:e,toolInput:n,toolOutput:s}};this.logSessionToFile(i)}getSessionId(){return Wc}getSessionLogPath(){return this.ensureInitialized(),this.sessionLogPath}getTokenStats(){return Bp.getSessionStats()}getTokenSummary(){return Bp.formatSessionSummary()}getLatestTokenUsage(){return Bp.getLatestInteraction()}getInMemoryErrors(){return[...Qp]}getDebugLogPath(){return this.ensureInitialized(),this.debugLogPath}getSessionDebugLogPath(){return this.ensureInitialized(),this.logPath}getRecentErrors(e=10){return Qp.slice(-e)}clearErrorLog(){Qp.length=0}clearDebugLogs(){this.ensureInitialized(),Gv(this.debugLogPath)&>(this.debugLogPath,"")}dumpDebugInfo(){return this.ensureInitialized(),{sessionId:Wc,projectPath:process.cwd(),projectName:vJ(process.cwd()),logPaths:{main:this.logPath,debug:this.debugLogPath,session:this.sessionLogPath},currentLogLevel:vm[this.currentLogLevel],recentErrors:this.getRecentErrors(5),tokenStats:Bp.getSessionStats(),memoryUsage:process.memoryUsage()}}};Kv.__LOGGER_INSTANCE?v=Kv.__LOGGER_INSTANCE:(v=new AU,Kv.__LOGGER_INSTANCE=v);SJ=process.env.CUE_LOG_LEVEL;if(SJ){let t=vm[SJ.toUpperCase()];t!==void 0&&v.setLogLevel(t)}});var nAe,KT,gU,oAe,sAe,hU=T(()=>{nAe="Cue",KT="CUE.md",gU=".cue/CUE.md",oAe="cue",sAe=".cue"});import{existsSync as qv,readFileSync as qT,writeFileSync as iAe,mkdirSync as rAe}from"fs";import{join as Jv,dirname as xJ,parse as bJ}from"path";import{homedir as aAe}from"os";function cAe(){lAe();let t=[],e=process.cwd();for(;e!==bJ(e).root;){let o=Jv(e,KT);if(qv(o))try{let c=qT(o,"utf-8");t.push(`Project context from ${o}:
|
package/package.json
CHANGED
package/cue-v0.0.62.tar.gz
DELETED
|
Binary file
|