rantera 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/dist/index.js +6 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import{createRequire}from"node:module";const require=createRequire(import.meta.url);
2
3
  var fi=Object.create;var be=Object.defineProperty;var di=Object.getOwnPropertyDescriptor;var mi=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,gi=Object.prototype.hasOwnProperty;var J=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var S=(i,t)=>()=>{try{return t||i((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}};var Fi=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mi(t))!gi.call(i,r)&&r!==e&&be(i,r,{get:()=>t[r],enumerable:!(n=di(t,r))||n.enumerable});return i};var st=(i,t,e)=>(e=i!=null?fi(pi(i)):{},Fi(t||!i||!i.__esModule?be(e,"default",{value:i,enumerable:!0}):e,i));var X=S(bt=>{var ut=class extends Error{constructor(t,e,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},At=class extends ut{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};bt.CommanderError=ut;bt.InvalidArgumentError=At});var at=S(wt=>{var{InvalidArgumentError:Ci}=X(),yt=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new Ci(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ei(i){let t=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+t+">":"["+t+"]"}wt.Argument=yt;wt.humanReadableArgName=Ei});var Bt=S(ye=>{var{humanReadableArgName:_i}=at(),Ot=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){let e=t.commands.filter(r=>!r._hidden),n=t._getHelpCommand();return n&&!n._hidden&&e.push(n),this.sortSubcommands&&e.sort((r,o)=>r.name().localeCompare(o.name())),e}compareOptions(t,e){let n=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return n(t).localeCompare(n(e))}visibleOptions(t){let e=t.options.filter(r=>!r.hidden),n=t._getHelpOption();if(n&&!n.hidden){let r=n.short&&t._findOption(n.short),o=n.long&&t._findOption(n.long);!r&&!o?e.push(n):n.long&&!o?e.push(t.createOption(n.long,n.description)):n.short&&!r&&e.push(t.createOption(n.short,n.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let n=t.parent;n;n=n.parent){let r=n.options.filter(o=>!o.hidden);e.push(...r)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(n=>_i(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((n,r)=>Math.max(n,e.subcommandTerm(r).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((n,r)=>Math.max(n,e.optionTerm(r).length),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((n,r)=>Math.max(n,e.optionTerm(r).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((n,r)=>Math.max(n,e.argumentTerm(r).length),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let n="";for(let r=t.parent;r;r=r.parent)n=r.name()+" "+n;return n+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let n=`(${e.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatHelp(t,e){let n=e.padWidth(t,e),r=e.helpWidth||80,o=2,s=2;function a(d,m){if(m){let E=`${d.padEnd(n+s)}${m}`;return e.wrap(E,r-o,n+s)}return d}function l(d){return d.join(`
3
4
  `).replace(/^/gm," ".repeat(o))}let D=[`Usage: ${e.commandUsage(t)}`,""],h=e.commandDescription(t);h.length>0&&(D=D.concat([e.wrap(h,r,0),""]));let c=e.visibleArguments(t).map(d=>a(e.argumentTerm(d),e.argumentDescription(d)));c.length>0&&(D=D.concat(["Arguments:",l(c),""]));let f=e.visibleOptions(t).map(d=>a(e.optionTerm(d),e.optionDescription(d)));if(f.length>0&&(D=D.concat(["Options:",l(f),""])),this.showGlobalOptions){let d=e.visibleGlobalOptions(t).map(m=>a(e.optionTerm(m),e.optionDescription(m)));d.length>0&&(D=D.concat(["Global Options:",l(d),""]))}let p=e.visibleCommands(t).map(d=>a(e.subcommandTerm(d),e.subcommandDescription(d)));return p.length>0&&(D=D.concat(["Commands:",l(p),""])),D.join(`
4
5
  `)}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,n,r=40){let o=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",s=new RegExp(`[\\n][${o}]+`);if(t.match(s))return t;let a=e-n;if(a<r)return t;let l=t.slice(0,n),D=t.slice(n).replace(`\r
@@ -25,7 +26,7 @@ Expecting one of '${n.join("', '")}'`);let r=`${t}Help`;return this.on(r,o=>{let
25
26
  ${f}`}}else yield{type:"error",text:`Could not reach Rantera API: ${D}`};return}if(!o.ok){let D=await o.text().catch(()=>"");yield{type:"error",text:`API error ${o.status}: ${D}`};return}if(!o.body){yield{type:"error",text:"No response body from API."};return}let s=o.body.getReader(),a=new TextDecoder,l="";for(;;){let{done:D,value:h}=await s.read();if(D)break;for(l+=a.decode(h,{stream:!0});;){let c=l.indexOf(`
26
27
  __WAKANDA_TOOL__:`),f=l.indexOf(`
27
28
  __WAKANDA_TOOL_RESULT__:`);if(c===-1&&f===-1){l.length>32&&(yield{type:"text",text:l.slice(0,l.length-32)},l=l.slice(l.length-32));break}let p=c!==-1&&(f===-1||c<f)?c:f,d=p===c;p>0&&(yield{type:"text",text:l.slice(0,p)});let m=p+1,E=l.indexOf(`
28
- `,m);if(E===-1){l=l.slice(p);break}let _=l.slice(m,E);l=l.slice(E+1);let A=d?"__WAKANDA_TOOL__:":"__WAKANDA_TOOL_RESULT__:",b=_.slice(A.length);try{let W=JSON.parse(b);d?yield{type:"tool_call",tool:{name:W.name,args:W.args}}:yield{type:"tool_result_inline",tool_name:W.name,result:W.result}}catch{yield{type:"text",text:_}}}}l.trim()&&(yield{type:"text",text:l})}import{existsSync as k,mkdirSync as Vt,readdirSync as He,readFileSync as Ut,renameSync as Ni,rmSync as Li,statSync as V,unlinkSync as Wi,writeFileSync as je}from"fs";import{dirname as Ve,join as w,relative as Ue}from"path";var Hi=5e5,lt=200,Dt=200,jt=500,qe=new Set(["node_modules",".git",".next","dist","__pycache__",".venv","venv"]);function Ge(i){let t=i.replace(/\\/g,"/"),e="",n=0;for(;n<t.length;){let r=t[n];r==="*"?t[n+1]==="*"?(e+=".*",n+=2,t[n]==="/"&&n++):(e+="[^/]*",n++):r==="?"?(e+="[^/]",n++):/[.+^${}()|[\]\\]/.test(r)?(e+="\\"+r,n++):(e+=r,n++)}return new RegExp("^"+e+"$")}function qt(i,t,e,n=1e4){if(e.length>=n)return;let r;try{r=He(i).sort()}catch{return}for(let o of r){if(e.length>=n)break;if(qe.has(o))continue;let s=w(i,o);try{V(s).isDirectory()?qt(s,t,e,n):e.push(Ue(t,s).replace(/\\/g,"/"))}catch{}}}function Ke(i,t){let e=w(t,i);if(!k(e))return`ERROR: path '${i}' does not exist.`;if(!V(e).isDirectory())return`ERROR: '${i}' is not a directory.`;let n=[];function r(s,a,l){if(n.length>=lt)return;let D;try{D=He(s).sort()}catch{return}for(let h of D){if(n.length>=lt)break;if(qe.has(h)){n.push(`${l}${h}/ (skipped)`);continue}let c=w(s,h);V(c).isDirectory()?(n.push(`${l}${h}/`),a<3&&r(c,a+1,l+" ")):n.push(`${l}${h}`)}}r(e,0,"");let o=Ue(t,e)||".";return n.length>=lt&&n.push(`... (truncated at ${lt} entries)`),o+`/
29
+ `,m);if(E===-1){l=l.slice(p);break}let _=l.slice(m,E);l=l.slice(E+1);let A=d?"__WAKANDA_TOOL__:":"__WAKANDA_TOOL_RESULT__:",b=_.slice(A.length);try{let L=JSON.parse(b);d?yield{type:"tool_call",tool:{name:L.name,args:L.args,rawPart:L._rawPart}}:yield{type:"tool_result_inline",tool_name:L.name,result:L.result}}catch{yield{type:"text",text:_}}}}l.trim()&&(yield{type:"text",text:l})}import{existsSync as k,mkdirSync as Vt,readdirSync as He,readFileSync as Ut,renameSync as Ni,rmSync as Li,statSync as V,unlinkSync as Wi,writeFileSync as je}from"fs";import{dirname as Ve,join as w,relative as Ue}from"path";var Hi=5e5,lt=200,Dt=200,jt=500,qe=new Set(["node_modules",".git",".next","dist","__pycache__",".venv","venv"]);function Ge(i){let t=i.replace(/\\/g,"/"),e="",n=0;for(;n<t.length;){let r=t[n];r==="*"?t[n+1]==="*"?(e+=".*",n+=2,t[n]==="/"&&n++):(e+="[^/]*",n++):r==="?"?(e+="[^/]",n++):/[.+^${}()|[\]\\]/.test(r)?(e+="\\"+r,n++):(e+=r,n++)}return new RegExp("^"+e+"$")}function qt(i,t,e,n=1e4){if(e.length>=n)return;let r;try{r=He(i).sort()}catch{return}for(let o of r){if(e.length>=n)break;if(qe.has(o))continue;let s=w(i,o);try{V(s).isDirectory()?qt(s,t,e,n):e.push(Ue(t,s).replace(/\\/g,"/"))}catch{}}}function Ke(i,t){let e=w(t,i);if(!k(e))return`ERROR: path '${i}' does not exist.`;if(!V(e).isDirectory())return`ERROR: '${i}' is not a directory.`;let n=[];function r(s,a,l){if(n.length>=lt)return;let D;try{D=He(s).sort()}catch{return}for(let h of D){if(n.length>=lt)break;if(qe.has(h)){n.push(`${l}${h}/ (skipped)`);continue}let c=w(s,h);V(c).isDirectory()?(n.push(`${l}${h}/`),a<3&&r(c,a+1,l+" ")):n.push(`${l}${h}`)}}r(e,0,"");let o=Ue(t,e)||".";return n.length>=lt&&n.push(`... (truncated at ${lt} entries)`),o+`/
29
30
  `+n.join(`
30
31
  `)}function Ye(i,t,e="."){let n=w(t,e);if(!k(n))return`ERROR: path '${e}' does not exist.`;let r=[];qt(n,n,r);let o=Ge(i),s=r.filter(D=>o.test(D));if(s.length===0)return`No files match '${i}'.`;let a=s.slice(0,jt),l=s.length>jt?`
31
32
  ... (${s.length} total, showing ${jt})`:"";return a.join(`
@@ -45,11 +46,11 @@ ${o}`:"")).trim();e(n&&!r&&!o?`ERROR: ${n.message}`:s||"(no output)")})})}functi
45
46
  ${t}`,ar=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),lr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Dr=(i,t,e)=>{let n=e===""?"":`with ${e.trim()}() `,r=ur.bind(null,n,t.toString());Object.defineProperty(r,"name",lr);let{writable:o,enumerable:s,configurable:a}=ar;Object.defineProperty(i,"toString",{value:r,writable:o,enumerable:s,configurable:a})};function Jt(i,t,{ignoreNonConfigurable:e=!1}={}){let{name:n}=i;for(let r of Reflect.ownKeys(t))rr(i,t,r,e);return sr(i,t),Dr(i,t,n),i}var ft=new WeakMap,xn=(i,t={})=>{if(typeof i!="function")throw new TypeError("Expected a function");let e,n=0,r=i.displayName||i.name||"<anonymous>",o=function(...s){if(ft.set(o,++n),n===1)e=i.apply(this,s),i=void 0;else if(t.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return e};return Jt(o,i),ft.set(o,n),o};xn.callCount=i=>{if(!ft.has(i))throw new Error(`The given function \`${i.name}\` is not wrapped by the \`onetime\` package`);return ft.get(i)};var An=xn;var U=[];U.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&U.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&U.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var dt=i=>!!i&&typeof i=="object"&&typeof i.removeListener=="function"&&typeof i.emit=="function"&&typeof i.reallyExit=="function"&&typeof i.listeners=="function"&&typeof i.kill=="function"&&typeof i.pid=="number"&&typeof i.on=="function",Xt=Symbol.for("signal-exit emitter"),Zt=globalThis,cr=Object.defineProperty.bind(Object),Qt=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Zt[Xt])return Zt[Xt];cr(Zt,Xt,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,e){this.listeners[t].push(e)}removeListener(t,e){let n=this.listeners[t],r=n.indexOf(e);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(t,e,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let r=!1;for(let o of this.listeners[t])r=o(e,n)===!0||r;return t==="exit"&&(r=this.emit("afterExit",e,n)||r),r}},mt=class{},hr=i=>({onExit(t,e){return i.onExit(t,e)},load(){return i.load()},unload(){return i.unload()}}),te=class extends mt{onExit(){return()=>{}}load(){}unload(){}},ee=class extends mt{#s=ne.platform==="win32"?"SIGINT":"SIGHUP";#n=new Qt;#t;#r;#h;#e={};#o=!1;constructor(t){super(),this.#t=t,this.#e={};for(let e of U)this.#e[e]=()=>{let n=this.#t.listeners(e),{count:r}=this.#n,o=t;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(r+=o.__signal_exit_emitter__.count),n.length===r){this.unload();let s=this.#n.emit("exit",null,e),a=e==="SIGHUP"?this.#s:e;s||t.kill(t.pid,a)}};this.#h=t.reallyExit,this.#r=t.emit}onExit(t,e){if(!dt(this.#t))return()=>{};this.#o===!1&&this.load();let n=e?.alwaysLast?"afterExit":"exit";return this.#n.on(n,t),()=>{this.#n.removeListener(n,t),this.#n.listeners.exit.length===0&&this.#n.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#n.count+=1;for(let t of U)try{let e=this.#e[t];e&&this.#t.on(t,e)}catch{}this.#t.emit=(t,...e)=>this.#f(t,...e),this.#t.reallyExit=t=>this.#i(t)}}unload(){this.#o&&(this.#o=!1,U.forEach(t=>{let e=this.#e[t];if(!e)throw new Error("Listener not defined for signal: "+t);try{this.#t.removeListener(t,e)}catch{}}),this.#t.emit=this.#r,this.#t.reallyExit=this.#h,this.#n.count-=1)}#i(t){return dt(this.#t)?(this.#t.exitCode=t||0,this.#n.emit("exit",this.#t.exitCode,null),this.#h.call(this.#t,this.#t.exitCode)):0}#f(t,...e){let n=this.#r;if(t==="exit"&&dt(this.#t)){typeof e[0]=="number"&&(this.#t.exitCode=e[0]);let r=n.call(this.#t,t,...e);return this.#n.emit("exit",this.#t.exitCode,null),r}else return n.call(this.#t,t,...e)}},ne=globalThis.process,{onExit:bn,load:Ko,unload:Yo}=hr(dt(ne)?new ee(ne):new te);var yn=pt.stderr.isTTY?pt.stderr:pt.stdout.isTTY?pt.stdout:void 0,fr=yn?An(()=>{bn(()=>{yn.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},wn=fr;var gt=!1,z={};z.show=(i=On.stderr)=>{i.isTTY&&(gt=!1,i.write("\x1B[?25h"))};z.hide=(i=On.stderr)=>{i.isTTY&&(wn(),gt=!0,i.write("\x1B[?25l"))};z.toggle=(i,t)=>{i!==void 0&&(gt=i),gt?z.show(t):z.hide(t)};var ie=z;var rt=st(re(),1);import R from"node:process";function oe(){return R.platform!=="win32"?R.env.TERM!=="linux":!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask==="{cmd::Cmder}"||R.env.TERM_PROGRAM==="Terminus-Sublime"||R.env.TERM_PROGRAM==="vscode"||R.env.TERM==="xterm-256color"||R.env.TERM==="alacritty"||R.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var mr={info:u.blue("\u2139"),success:u.green("\u2714"),warning:u.yellow("\u26A0"),error:u.red("\u2716")},pr={info:u.blue("i"),success:u.green("\u221A"),warning:u.yellow("\u203C"),error:u.red("\xD7")},gr=oe()?mr:pr,nt=gr;function se({onlyFirst:i=!1}={}){let t=String.raw`(?:\u0007|\u001B\u005C|\u009C)`,e=String.raw`(?:(?:\u001B\]|\u009D)[^\u0007\u001B\u009C\u009D]*${t})`,n=String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[A-PR-TZcf-nq-uy=><~]`,r=String.raw`(?:\u001B\[|\u009B)[<=>][0-9;:]*[A-PR-TZcf-nq-uy~]`,o=`${e}|${r}|${n}`;return new RegExp(o,i?void 0:"g")}var Fr=se();function it(i){if(typeof i!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof i}\``);return!i.includes("\x1B")&&!i.includes("\x9B")?i:i.replace(Fr,"")}var Tn=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Sn=12288,kn=65510,$n=[12288,12288,65281,65376,65504,65510];var In=4352,Pn=262141,ue=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101594,101631,101664,101760,101874,101888,102801,102816,102866,110576,110579,110581,110587,110589,110590,110592,110888,110898,110898,110928,110930,110933,110933,110948,110952,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127406,127406,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128729,128732,128735,128747,128748,128756,128764,128986,128986,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129734,129736,129736,129740,129757,129759,129771,129775,129786,131072,196605,196608,262141];var Ct=(i,t)=>{let e=0,n=Math.floor(i.length/2)-1;for(;e<=n;){let r=Math.floor((e+n)/2),o=r*2;if(t<i[o])n=r-1;else if(t>i[o+1])e=r+1;else return!0}return!1};var Mn=19968,[_r,xr]=Ar(ue);function Ar(i){let t=i[0],e=i[1];for(let n=0;n<i.length;n+=2){let r=i[n],o=i[n+1];if(Mn>=r&&Mn<=o)return[r,o];o-r>e-t&&(t=r,e=o)}return[t,e]}var Nn=i=>i<161||i>1114109?!1:Ct(Tn,i),Ln=i=>i<Sn||i>kn?!1:Ct($n,i);var Wn=i=>i>=_r&&i<=xr?!0:i<In||i>Pn?!1:Ct(ue,i);function br(i){if(!Number.isSafeInteger(i))throw new TypeError(`Expected a code point, got \`${typeof i}\`.`)}function Hn(i,{ambiguousAsWide:t=!1}={}){return br(i),Ln(i)||Wn(i)||t&&Nn(i)?2:1}var Un=st(Vn(),1),yr=new Intl.Segmenter,wr=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function ae(i,t={}){if(typeof i!="string"||i.length===0)return 0;let{ambiguousIsNarrow:e=!0,countAnsiEscapeCodes:n=!1}=t;if(n||(i=it(i)),i.length===0)return 0;let r=0,o={ambiguousAsWide:!e};for(let{segment:s}of yr.segment(i)){let a=s.codePointAt(0);if(!(a<=31||a>=127&&a<=159)&&!(a>=8203&&a<=8207||a===65279)&&!(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)&&!(a>=55296&&a<=57343)&&!(a>=65024&&a<=65039)&&!wr.test(s)){if((0,Un.default)().test(s)){r+=2;continue}r+=Hn(a,o)}}return r}function le({stream:i=process.stdout}={}){return!!(i&&i.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import qn from"node:process";function De(){let{env:i}=qn,{TERM:t,TERM_PROGRAM:e}=i;return qn.platform!=="win32"?t!=="linux":!!i.WT_SESSION||!!i.TERMINUS_SUBLIME||i.ConEmuTask==="{cmd::Cmder}"||e==="Terminus-Sublime"||e==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||i.TERMINAL_EMULATOR==="JetBrains-JediTerm"}import $ from"node:process";var Or=3,ce=class{#s=0;start(){this.#s++,this.#s===1&&this.#n()}stop(){if(this.#s<=0)throw new Error("`stop` called more times than `start`");this.#s--,this.#s===0&&this.#t()}#n(){$.platform==="win32"||!$.stdin.isTTY||($.stdin.setRawMode(!0),$.stdin.on("data",this.#r),$.stdin.resume())}#t(){$.stdin.isTTY&&($.stdin.off("data",this.#r),$.stdin.pause(),$.stdin.setRawMode(!1))}#r(t){t[0]===Or&&$.emit("SIGINT")}},Br=new ce,he=Br;var vr=st(re(),1),fe=class{#s=0;#n=!1;#t=0;#r=-1;#h=0;#e;#o;#i;#f;#m;#l;#D;#c;#p;#u;#a;color;constructor(t){typeof t=="string"&&(t={text:t}),this.#e={color:"cyan",stream:Et.stderr,discardStdin:!0,hideCursor:!0,...t},this.color=this.#e.color,this.spinner=this.#e.spinner,this.#m=this.#e.interval,this.#i=this.#e.stream,this.#l=typeof this.#e.isEnabled=="boolean"?this.#e.isEnabled:le({stream:this.#i}),this.#D=typeof this.#e.isSilent=="boolean"?this.#e.isSilent:!1,this.text=this.#e.text,this.prefixText=this.#e.prefixText,this.suffixText=this.#e.suffixText,this.indent=this.#e.indent,Et.env.NODE_ENV==="test"&&(this._stream=this.#i,this._isEnabled=this.#l,Object.defineProperty(this,"_linesToClear",{get(){return this.#s},set(e){this.#s=e}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#r}}),Object.defineProperty(this,"_lineCount",{get(){return this.#t}}))}get indent(){return this.#c}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");this.#c=t,this.#d()}get interval(){return this.#m??this.#o.interval??100}get spinner(){return this.#o}set spinner(t){if(this.#r=-1,this.#m=void 0,typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#o=t}else if(!De())this.#o=rt.default.line;else if(t===void 0)this.#o=rt.default.dots;else if(t!=="default"&&rt.default[t])this.#o=rt.default[t];else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#p}set text(t=""){this.#p=t,this.#d()}get prefixText(){return this.#u}set prefixText(t=""){this.#u=t,this.#d()}get suffixText(){return this.#a}set suffixText(t=""){this.#a=t,this.#d()}get isSpinning(){return this.#f!==void 0}#g(t=this.#u,e=" "){return typeof t=="string"&&t!==""?t+e:typeof t=="function"?t()+e:""}#F(t=this.#a,e=" "){return typeof t=="string"&&t!==""?e+t:typeof t=="function"?e+t():""}#d(){let t=this.#i.columns??80,e=this.#g(this.#u,"-"),n=this.#F(this.#a,"-"),r=" ".repeat(this.#c)+e+"--"+this.#p+"--"+n;this.#t=0;for(let o of it(r).split(`
46
47
  `))this.#t+=Math.max(1,Math.ceil(ae(o,{countAnsiEscapeCodes:!0})/t))}get isEnabled(){return this.#l&&!this.#D}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#l=t}get isSilent(){return this.#D}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#D=t}frame(){let t=Date.now();(this.#r===-1||t-this.#h>=this.interval)&&(this.#r=++this.#r%this.#o.frames.length,this.#h=t);let{frames:e}=this.#o,n=e[this.#r];this.color&&(n=u[this.color](n));let r=typeof this.#u=="string"&&this.#u!==""?this.#u+" ":"",o=typeof this.text=="string"?" "+this.text:"",s=typeof this.#a=="string"&&this.#a!==""?" "+this.#a:"";return r+n+o+s}clear(){if(!this.#l||!this.#i.isTTY)return this;this.#i.cursorTo(0);for(let t=0;t<this.#s;t++)t>0&&this.#i.moveCursor(0,-1),this.#i.clearLine(1);return(this.#c||this.lastIndent!==this.#c)&&this.#i.cursorTo(this.#c),this.lastIndent=this.#c,this.#s=0,this}render(){return this.#D?this:(this.clear(),this.#i.write(this.frame()),this.#s=this.#t,this)}start(t){return t&&(this.text=t),this.#D?this:this.#l?this.isSpinning?this:(this.#e.hideCursor&&ie.hide(this.#i),this.#e.discardStdin&&Et.stdin.isTTY&&(this.#n=!0,he.start()),this.render(),this.#f=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#i.write(`- ${this.text}
47
48
  `),this)}stop(){return this.#l?(clearInterval(this.#f),this.#f=void 0,this.#r=0,this.clear(),this.#e.hideCursor&&ie.show(this.#i),this.#e.discardStdin&&Et.stdin.isTTY&&this.#n&&(he.stop(),this.#n=!1),this):this}succeed(t){return this.stopAndPersist({symbol:nt.success,text:t})}fail(t){return this.stopAndPersist({symbol:nt.error,text:t})}warn(t){return this.stopAndPersist({symbol:nt.warning,text:t})}info(t){return this.stopAndPersist({symbol:nt.info,text:t})}stopAndPersist(t={}){if(this.#D)return this;let e=t.prefixText??this.#u,n=this.#g(e," "),r=t.symbol??" ",o=t.text??this.text,a=typeof o=="string"?(r?" ":"")+o:"",l=t.suffixText??this.#a,D=this.#F(l," "),h=n+r+a+D+`
48
- `;return this.stop(),this.#i.write(h),this}};function de(i){return new fe(i)}var T="#006B3F",x="#FCD116",pe="#CE1126",Rr="0.1.2",L=null,I=[{id:"hira",display:"Hira",desc:"The motherland's voice",available:!0},{id:"tera",display:"Tera",desc:"Orchestrator \u2014 routes to best specialist",available:!1},{id:"akili",display:"Akili",desc:"Code intelligence",available:!1},{id:"ilimi",display:"Ilimi",desc:"Knowledge & research",available:!1}];function Tr(i){return i.replace(/\x1b\[[0-9;]*m/g,"").length}var ge=64;function Sr(i){let t=Math.max(0,ge-3-i.length);return u.hex(x).dim("\u256D\u2500 ")+u.white.bold(i)+u.hex(x).dim(" "+"\u2500".repeat(t)+"\u256E")}function kr(i){let t=Math.max(0,ge-2-Tr(i));return u.hex(x).dim("\u2502")+" "+i+" ".repeat(t)+" "+u.hex(x).dim("\u2502")}function $r(){return u.hex(x).dim("\u2570"+"\u2500".repeat(ge)+"\u256F")}var Ir=[["#CE1126","#FCD116","#078930"],["#006B3F","#FFFFFF","#006B3F"],["#000000","#CE1126","#006600"],["#078930","#FCD116","#CE1126"],["#DE3831","#FFB612","#007A4D"],["#CE1126","#FFFFFF","#000000"],["#3A75C4","#000000","#1EB53A"],["#FCDC04","#DE3108","#000000"],["#00853F","#FDEF42","#E31B23"],["#007FFF","#F7D618","#CE1126"],["#FAD201","#19B3EE","#20603D"],["#CC0000","#000000","#FCDD00"]];function Pr(){let i=" ",t=" ";for(let[e,n,r]of Ir)i+=u.bgHex(n).hex(e)("\u2580\u2580\u2580\u2580"),t+=u.bgHex(r).hex(n)("\u2580\u2580\u2580\u2580");return[i,t]}function q(i=28){let t=" ";for(let e=0;e<i;e++)switch(e%4){case 0:t+=u.hex(x)("\u25C6");break;case 1:t+=u.dim("\u2500");break;case 2:t+=u.hex(T)("\u25C7");break;case 3:t+=u.dim("\u2500");break}return t}function me(i){return i>=1e3?`${(i/1e3).toFixed(1)}k`:String(i)}function Mr(){let[i,t]=Pr();console.log(),console.log(i),console.log(t),console.log(),console.log(" "+u.hex(x).bold("RANTERA")+" "+u.dim("\xB7")+" "+u.hex(T).bold("Wakanda")+" "+u.dim(Rr)),console.log(" "+u.dim("African Intelligence. Global Tools.")),console.log(),console.log(q()),console.log()}function Gn(i,t,e){Mr();let n=i.replace(/\\/g,"/").split("/").filter(Boolean),r=n.length>=2?n.slice(-2).join("/"):i,o=I.find(a=>a.id===t)??I[0],s=[u.dim("Model ")+u.white(o.display)+u.dim(" (Rantera AI)"),u.dim("Dir ")+u.white(r),...e?[u.dim("Memory ")+u.hex(T)("\u2713 RANTERA.md")]:[],"",u.dim("Task, ")+u.hex(x)("/help")+u.dim(" for commands, ")+u.hex(x)("/model")+u.dim(" to switch.")];console.log(" "+Sr("Wakanda"));for(let a of s)console.log(" "+kr(a));console.log(" "+$r()),console.log()}function Kn(){let i=n=>" "+u.hex(x)(n.padEnd(20)),t=n=>" "+u.hex(T)("\u25C6")+" "+u.dim(n),e=()=>console.log(" "+q(26));console.log(),console.log(" "+u.white.bold("Slash Commands")),e(),console.log(i("/help")+u.dim("Show this message")),console.log(i("/model [name]")+u.dim("List models or switch (e.g. /model hira)")),console.log(i("/compact")+u.dim("Trim history \u2014 keep last 3 exchanges")),console.log(i("/cost")+u.dim("Show estimated token usage for this session")),console.log(i("/clear")+u.dim("Erase all conversation history")),console.log(i("/history")+u.dim("Show recent messages")),console.log(i("/status")+u.dim("Auth, model, context and config info")),console.log(i("/login")+u.dim("Log in (or switch to a different account)")),console.log(i("/logout")+u.dim("Log out of current account")),console.log(i("/exit")+u.dim("Exit Wakanda")),console.log(),console.log(" "+u.white.bold("Input")),e(),console.log(t("End a line with \\ to continue on the next line (multi-line)")),console.log(t("Press \u2191 / \u2193 to scroll through your input history")),console.log(t("Ctrl+C cancels a running task")),console.log(),console.log(" "+u.white.bold("Tips")),e(),console.log(t("Just type your task \u2014 Tera understands natural language")),console.log(t('Reference files directly: "fix the bug in auth.ts"')),console.log(t('Give feedback: "try again, make it simpler"')),console.log(t("Add RANTERA.md in your project root for persistent context")),console.log()}function Yn(i="hira"){let t=e=>" "+u.hex(x)(e.padEnd(10));console.log(),console.log(" "+u.white.bold("Models")),console.log(" "+q(26));for(let e of I){let n=e.id===i?u.hex(T)("\u25C6 "):" ",r=e.available?u.dim(e.desc):u.dim(e.desc)+" "+u.hex("#334155")("[coming soon]");console.log(n+t(e.display)+r)}console.log(),console.log(u.dim(" Current: ")+u.white(i)),console.log(u.dim(" Switch: ")+u.hex(x)("/model <name>")+u.dim(" e.g. /model hira")),console.log()}function zn(i,t){let n=Math.min(100,Math.round(i/2e5*1e3)/10),r=o=>" "+u.dim(o.padEnd(12));console.log(),console.log(" "+u.white.bold("Token Usage ")+u.dim("(estimated)")),console.log(" "+q(26)),console.log(r("Messages")+u.white(String(t))),console.log(r("Tokens")+u.white(`~${me(i)}`)),console.log(r("Context")+u.white(`${n}%`)+u.dim(` of 200k (~${me(i)} / 200k tokens)`)),n>80&&(console.log(),console.log(u.hex("#FCD116")(" \u26A0 Context is over 80%. Use /compact to trim history."))),console.log()}function Jn(i,t,e,n,r,o){let a=Math.min(100,Math.round(o/2e5*1e3)/10),l=f=>" "+u.dim(f.padEnd(10)),D=n.replace(/\\/g,"/").split("/").filter(Boolean),h=D.length>=2?D.slice(-2).join("/"):n,c=I.find(f=>f.id===r)??I[0];console.log(),console.log(" "+u.white.bold("Status")),console.log(" "+q(26)),console.log(l("Auth")+(i?u.hex(T).bold("\u2713 Logged in")+u.dim(` (${i.slice(0,16)}\u2026)`):u.hex(pe).bold("\u2717 Not logged in")+u.dim(" Run `rantera auth login`"))),console.log(l("API URL")+u.white(t??"https://rantera.ai")),console.log(l("Model")+u.white(c.display)+u.dim(` ${c.desc}`)),console.log(l("Dir")+u.white(h)),console.log(l("History")+u.dim(`${e} message${e!==1?"s":""}`)),console.log(l("Context")+u.white(`~${me(o)} tokens`)+u.dim(` (${a}% of 200k)`)),console.log()}function Xn(i){if(i.length===0){console.log(),console.log(u.dim(" No conversation history yet.")),console.log();return}console.log(),console.log(" "+u.white.bold("History")+" "+u.dim(`${i.length} message${i.length!==1?"s":""}`)),console.log(" "+q(26));for(let t of i){let n=t.role==="user"?" "+u.hex(x).bold("you "):" "+u.hex(T).bold("tera"),r=t.content?.replace(/\n/g," ")??"",o=r.length>80?r.slice(0,80)+u.dim("\u2026"):r;console.log(n+" "+u.dim(o))}console.log()}function Zn(i){L=de({text:u.hex(x)(i),color:"yellow",spinner:"dots"}).start()}function Fe(i=!0,t){L&&(i?L.succeed(t?u.hex(T)(t):void 0):L.fail(t?u.dim(t):void 0),L=null)}function ot(){L&&(L.stop(),L=null)}function Qn(i){process.stdout.write(i)}function ti(i,t){let e=Nr(t);console.log(`
49
+ `;return this.stop(),this.#i.write(h),this}};function de(i){return new fe(i)}var T="#006B3F",x="#FCD116",pe="#CE1126",Rr="0.1.2",W=null,I=[{id:"hira",display:"Hira",desc:"The motherland's voice",available:!0},{id:"tera",display:"Tera",desc:"Orchestrator \u2014 routes to best specialist",available:!1},{id:"akili",display:"Akili",desc:"Code intelligence",available:!1},{id:"ilimi",display:"Ilimi",desc:"Knowledge & research",available:!1}];function Tr(i){return i.replace(/\x1b\[[0-9;]*m/g,"").length}var ge=64;function Sr(i){let t=Math.max(0,ge-3-i.length);return u.hex(x).dim("\u256D\u2500 ")+u.white.bold(i)+u.hex(x).dim(" "+"\u2500".repeat(t)+"\u256E")}function kr(i){let t=Math.max(0,ge-2-Tr(i));return u.hex(x).dim("\u2502")+" "+i+" ".repeat(t)+" "+u.hex(x).dim("\u2502")}function $r(){return u.hex(x).dim("\u2570"+"\u2500".repeat(ge)+"\u256F")}var Ir=[["#CE1126","#FCD116","#078930"],["#006B3F","#FFFFFF","#006B3F"],["#000000","#CE1126","#006600"],["#078930","#FCD116","#CE1126"],["#DE3831","#FFB612","#007A4D"],["#CE1126","#FFFFFF","#000000"],["#3A75C4","#000000","#1EB53A"],["#FCDC04","#DE3108","#000000"],["#00853F","#FDEF42","#E31B23"],["#007FFF","#F7D618","#CE1126"],["#FAD201","#19B3EE","#20603D"],["#CC0000","#000000","#FCDD00"]];function Pr(){let i=" ",t=" ";for(let[e,n,r]of Ir)i+=u.bgHex(n).hex(e)("\u2580\u2580\u2580\u2580"),t+=u.bgHex(r).hex(n)("\u2580\u2580\u2580\u2580");return[i,t]}function q(i=28){let t=" ";for(let e=0;e<i;e++)switch(e%4){case 0:t+=u.hex(x)("\u25C6");break;case 1:t+=u.dim("\u2500");break;case 2:t+=u.hex(T)("\u25C7");break;case 3:t+=u.dim("\u2500");break}return t}function me(i){return i>=1e3?`${(i/1e3).toFixed(1)}k`:String(i)}function Mr(){let[i,t]=Pr();console.log(),console.log(i),console.log(t),console.log(),console.log(" "+u.hex(x).bold("RANTERA")+" "+u.dim("\xB7")+" "+u.hex(T).bold("Wakanda")+" "+u.dim(Rr)),console.log(" "+u.dim("African Intelligence. Global Tools.")),console.log(),console.log(q()),console.log()}function Gn(i,t,e){Mr();let n=i.replace(/\\/g,"/").split("/").filter(Boolean),r=n.length>=2?n.slice(-2).join("/"):i,o=I.find(a=>a.id===t)??I[0],s=[u.dim("Model ")+u.white(o.display)+u.dim(" (Rantera AI)"),u.dim("Dir ")+u.white(r),...e?[u.dim("Memory ")+u.hex(T)("\u2713 RANTERA.md")]:[],"",u.dim("Task, ")+u.hex(x)("/help")+u.dim(" for commands, ")+u.hex(x)("/model")+u.dim(" to switch.")];console.log(" "+Sr("Wakanda"));for(let a of s)console.log(" "+kr(a));console.log(" "+$r()),console.log()}function Kn(){let i=n=>" "+u.hex(x)(n.padEnd(20)),t=n=>" "+u.hex(T)("\u25C6")+" "+u.dim(n),e=()=>console.log(" "+q(26));console.log(),console.log(" "+u.white.bold("Slash Commands")),e(),console.log(i("/help")+u.dim("Show this message")),console.log(i("/model [name]")+u.dim("List models or switch (e.g. /model hira)")),console.log(i("/compact")+u.dim("Trim history \u2014 keep last 3 exchanges")),console.log(i("/cost")+u.dim("Show estimated token usage for this session")),console.log(i("/clear")+u.dim("Erase all conversation history")),console.log(i("/history")+u.dim("Show recent messages")),console.log(i("/status")+u.dim("Auth, model, context and config info")),console.log(i("/login")+u.dim("Log in (or switch to a different account)")),console.log(i("/logout")+u.dim("Log out of current account")),console.log(i("/exit")+u.dim("Exit Wakanda")),console.log(),console.log(" "+u.white.bold("Input")),e(),console.log(t("End a line with \\ to continue on the next line (multi-line)")),console.log(t("Press \u2191 / \u2193 to scroll through your input history")),console.log(t("Ctrl+C cancels a running task")),console.log(),console.log(" "+u.white.bold("Tips")),e(),console.log(t("Just type your task \u2014 Tera understands natural language")),console.log(t('Reference files directly: "fix the bug in auth.ts"')),console.log(t('Give feedback: "try again, make it simpler"')),console.log(t("Add RANTERA.md in your project root for persistent context")),console.log()}function Yn(i="hira"){let t=e=>" "+u.hex(x)(e.padEnd(10));console.log(),console.log(" "+u.white.bold("Models")),console.log(" "+q(26));for(let e of I){let n=e.id===i?u.hex(T)("\u25C6 "):" ",r=e.available?u.dim(e.desc):u.dim(e.desc)+" "+u.hex("#334155")("[coming soon]");console.log(n+t(e.display)+r)}console.log(),console.log(u.dim(" Current: ")+u.white(i)),console.log(u.dim(" Switch: ")+u.hex(x)("/model <name>")+u.dim(" e.g. /model hira")),console.log()}function zn(i,t){let n=Math.min(100,Math.round(i/2e5*1e3)/10),r=o=>" "+u.dim(o.padEnd(12));console.log(),console.log(" "+u.white.bold("Token Usage ")+u.dim("(estimated)")),console.log(" "+q(26)),console.log(r("Messages")+u.white(String(t))),console.log(r("Tokens")+u.white(`~${me(i)}`)),console.log(r("Context")+u.white(`${n}%`)+u.dim(` of 200k (~${me(i)} / 200k tokens)`)),n>80&&(console.log(),console.log(u.hex("#FCD116")(" \u26A0 Context is over 80%. Use /compact to trim history."))),console.log()}function Jn(i,t,e,n,r,o){let a=Math.min(100,Math.round(o/2e5*1e3)/10),l=f=>" "+u.dim(f.padEnd(10)),D=n.replace(/\\/g,"/").split("/").filter(Boolean),h=D.length>=2?D.slice(-2).join("/"):n,c=I.find(f=>f.id===r)??I[0];console.log(),console.log(" "+u.white.bold("Status")),console.log(" "+q(26)),console.log(l("Auth")+(i?u.hex(T).bold("\u2713 Logged in")+u.dim(` (${i.slice(0,16)}\u2026)`):u.hex(pe).bold("\u2717 Not logged in")+u.dim(" Run `rantera auth login`"))),console.log(l("API URL")+u.white(t??"https://rantera.ai")),console.log(l("Model")+u.white(c.display)+u.dim(` ${c.desc}`)),console.log(l("Dir")+u.white(h)),console.log(l("History")+u.dim(`${e} message${e!==1?"s":""}`)),console.log(l("Context")+u.white(`~${me(o)} tokens`)+u.dim(` (${a}% of 200k)`)),console.log()}function Xn(i){if(i.length===0){console.log(),console.log(u.dim(" No conversation history yet.")),console.log();return}console.log(),console.log(" "+u.white.bold("History")+" "+u.dim(`${i.length} message${i.length!==1?"s":""}`)),console.log(" "+q(26));for(let t of i){let n=t.role==="user"?" "+u.hex(x).bold("you "):" "+u.hex(T).bold("tera"),r=t.content?.replace(/\n/g," ")??"",o=r.length>80?r.slice(0,80)+u.dim("\u2026"):r;console.log(n+" "+u.dim(o))}console.log()}function Zn(i){W=de({text:u.hex(x)(i),color:"yellow",spinner:"dots"}).start()}function Fe(i=!0,t){W&&(i?W.succeed(t?u.hex(T)(t):void 0):W.fail(t?u.dim(t):void 0),W=null)}function ot(){W&&(W.stop(),W=null)}function Qn(i){process.stdout.write(i)}function ti(i,t){let e=Nr(t);console.log(`
49
50
  `+u.hex(x).bold(`\u25C6 ${i}`)+" "+u.dim(e))}function ei(i,t,e){let n=e?u.hex(T)("\u2713"):u.hex(pe)("\u2717"),r=t.length>240?t.slice(0,240).replace(/\n/g," ")+u.dim("\u2026"):t.replace(/\n/g," ");console.log(" "+n+" "+u.dim(r)+`
50
51
  `)}function M(i){console.error(`
51
52
  `+u.hex(pe).bold("\u2717")+" "+u.white.bold("Error:")+" "+i)}function N(i){console.log(" "+u.hex(T).bold("\u2713")+" "+i)}function ni(){console.log(q(28))}function ii(i="hira"){let t=I.find(e=>e.id===i)??I[0];process.stdout.write(`
52
- `+u.hex(T).bold(`${t.display} \u276F`)+" ")}function Nr(i){let t=[];for(let[e,n]of Object.entries(i)){let r=typeof n=="string"&&n.length>60?n.slice(0,60)+"\u2026":String(n);t.push(`${e}=${r}`)}return t.join(" ")}var ri=50;async function oi(i,t,e){let n=[...t,{role:"user",content:i}],r={model:e.model,system:e.system},o=0,s="";for(;o<ri;){let a=null,l="";for await(let c of Ht(n,r))if(c.type==="text"&&c.text)l+=c.text,e.onText?.(c.text);else if(c.type==="tool_call"&&c.tool)a=c.tool,e.onToolCall?.(c.tool.name,c.tool.args);else if(c.type==="tool_result_inline"){let f=c.result??"";e.onToolResult?.(c.tool_name,f,!0),n.push({role:"assistant",content:""}),n.push({role:"tool_result",tool_name:c.tool_name,content:f})}else if(c.type==="error")return M(c.text??"Unknown error"),s;if(l&&!a){s=l;break}if(!a)break;if(o++,a.name==="ask_user"){let c=String(a.args.question??""),f=e.onAskUser?await e.onAskUser(c):"";e.onToolResult?.(a.name,f,!0),n.push({role:"assistant",content:l||""}),n.push({role:"tool_result",tool_name:"ask_user",content:f});continue}let{output:D,ok:h}=await Dn(a.name,a.args,e.cwd);e.onToolResult?.(a.name,D,h),n.push({role:"assistant",content:l||""}),n.push({role:"tool_result",tool_name:a.name,content:D})}if(!s&&o>=ri){n.push({role:"user",content:"You've reached the step limit. Summarize what you found and give your final answer now."});for await(let a of Ht(n,r))a.type==="text"&&a.text&&(s+=a.text,e.onText?.(a.text))}return s}import{spawn as Ce}from"child_process";import{createServer as Lr}from"http";var Wr=`<!DOCTYPE html>
53
+ `+u.hex(T).bold(`${t.display} \u276F`)+" ")}function Nr(i){let t=[];for(let[e,n]of Object.entries(i)){let r=typeof n=="string"&&n.length>60?n.slice(0,60)+"\u2026":String(n);t.push(`${e}=${r}`)}return t.join(" ")}var ri=50;async function oi(i,t,e){let n=[...t,{role:"user",content:i}],r={model:e.model,system:e.system},o=0,s="";for(;o<ri;){let a=null,l="";for await(let c of Ht(n,r))if(c.type==="text"&&c.text)l+=c.text,e.onText?.(c.text);else if(c.type==="tool_call"&&c.tool)a=c.tool,e.onToolCall?.(c.tool.name,c.tool.args);else if(c.type==="tool_result_inline"){let f=c.result??"";e.onToolResult?.(c.tool_name,f,!0),n.push({role:"assistant",content:""}),n.push({role:"tool_result",tool_name:c.tool_name,content:f})}else if(c.type==="error")return M(c.text??"Unknown error"),s;if(l&&!a){s=l;break}if(!a)break;if(o++,a.name==="ask_user"){let c=String(a.args.question??""),f=e.onAskUser?await e.onAskUser(c):"";e.onToolResult?.(a.name,f,!0),n.push({role:"assistant",content:l||""}),n.push({role:"tool_result",tool_name:"ask_user",content:f});continue}let{output:D,ok:h}=await Dn(a.name,a.args,e.cwd);e.onToolResult?.(a.name,D,h),n.push({role:"assistant",content:l||""}),n.push({role:"tool_result",tool_name:a.name,content:D,rawModelPart:a.rawPart})}if(!s&&o>=ri){n.push({role:"user",content:"You've reached the step limit. Summarize what you found and give your final answer now."});for await(let a of Ht(n,r))a.type==="text"&&a.text&&(s+=a.text,e.onText?.(a.text))}return s}import{spawn as Ce}from"child_process";import{createServer as Lr}from"http";var Wr=`<!DOCTYPE html>
53
54
  <html lang="en">
54
55
  <head>
55
56
  <meta charset="UTF-8" />
@@ -154,8 +155,8 @@ ${t}`,ar=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),lr=Objec
154
155
  `:"")+p.slice(0,-1),h=!0,c();return}let d=D+(D?`
155
156
  `:"")+p;D="",h=!1;let m=d.trim();if(!m){c();return}if(m==="/help"){Kn(),c();return}if(m==="/clear"){o.length=0,console.log(u.dim(`
156
157
  Conversation cleared.
157
- `)),c();return}if(m==="/history"){let E=o.filter(_=>_.role==="user"||_.role==="assistant").map(_=>({role:_.role,content:_.content}));Xn(E),c();return}if(m==="/status"){let E=_e(o,a);Jn(j(),r.apiUrl,o.length,t,s,E),c();return}if(m==="/compact"){let _=o.length;if(o.length>6){o.splice(0,o.length-6);let A=o.length,b=_e(o,a),W=Math.round(b/Kr*100);console.log(u.dim(`
158
- Compacted \u2014 kept last ${A} of ${_} messages.`)+" "+u.dim(`(~${Yr(b)} tokens, ${W}% of 200k)
158
+ `)),c();return}if(m==="/history"){let E=o.filter(_=>_.role==="user"||_.role==="assistant").map(_=>({role:_.role,content:_.content}));Xn(E),c();return}if(m==="/status"){let E=_e(o,a);Jn(j(),r.apiUrl,o.length,t,s,E),c();return}if(m==="/compact"){let _=o.length;if(o.length>6){o.splice(0,o.length-6);let A=o.length,b=_e(o,a),L=Math.round(b/Kr*100);console.log(u.dim(`
159
+ Compacted \u2014 kept last ${A} of ${_} messages.`)+" "+u.dim(`(~${Yr(b)} tokens, ${L}% of 200k)
159
160
  `))}else console.log(u.dim(`
160
161
  Nothing to compact yet.
161
162
  `));c();return}if(m==="/cost"){let E=_e(o,a),_=o.filter(A=>A.role==="user"||A.role==="assistant").length;zn(E,_),c();return}if(m==="/model"||m.startsWith("/model ")){let E=m.split(/\s+/);if(E.length===1)Yn(s);else{let _=E[1].toLowerCase(),A=I.find(b=>b.id===_);if(!A)M(`Unknown model "${_}". Available: ${I.filter(b=>b.available).map(b=>b.id).join(", ")}`);else if(!A.available)console.log(u.dim(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rantera",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Rantera CLI — African-first AI platform for developers",
5
5
  "bin": {
6
6
  "rantera": "dist/index.js"