@routecraft/cli 0.7.2 → 0.7.3-canary-20261004170320

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.
@@ -0,0 +1,2 @@
1
+ var s="0.7.3-canary-20261004170320";export{s as a};//# sourceMappingURL=chunk-NQY6EG6Q.js.map
2
+ //# sourceMappingURL=chunk-NQY6EG6Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json"],"names":["version"],"mappings":"AAEE,IAAAA,CAAAA,CAAW","file":"chunk-NQY6EG6Q.js","sourcesContent":["{\n \"name\": \"@routecraft/cli\",\n \"version\": \"0.7.3-canary-20261004170320\",\n \"description\": \"CLI for running Routecraft capabilities\",\n \"private\": false,\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/tui/app.tsx src/tui/db.ts --format esm --dts --external react --external ink --external bun:sqlite\",\n \"test\": \"vitest\",\n \"test:coverage\": \"vitest --coverage\",\n \"prepublishOnly\": \"bun run build\"\n },\n \"dependencies\": {\n \"@agentclientprotocol/sdk\": \"^1.4.0\",\n \"@routecraft/routecraft\": \"0.7.3-canary-20261004170320\",\n \"commander\": \"^14.0.3\",\n \"dotenv\": \"^17.4.2\",\n \"ink\": \"^7.1.1\",\n \"pino-pretty\": \"^13.1.3\",\n \"react\": \"^19.2.0\",\n \"yaml\": \"^2.9.1\"\n },\n \"devDependencies\": {\n \"@types/mailparser\": \"^3.4.6\",\n \"@types/react\": \"^19.2.18\",\n \"ink-testing-library\": \"^4.0.0\",\n \"jose\": \"^6.2.12\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": \"https://github.com/routecraftjs/routecraft\",\n \"bin\": {\n \"craft\": \"./dist/index.js\"\n },\n \"engines\": {\n \"bun\": \">=1.1.0\"\n },\n \"keywords\": [\n \"routecraft\",\n \"cli\",\n \"routes\",\n \"automation\",\n \"typescript\"\n ],\n \"author\": \"routecraftjs\",\n \"license\": \"Apache-2.0\",\n \"homepage\": \"https://routecraft.dev\"\n}\n"]}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- import {a as a$1}from'./chunk-WCEUG34O.js';import {b as b$1}from'./chunk-OKX5YME7.js';import {resolve}from'path';process.versions.bun||(console.error(b$1),process.exit(1));var{relaunchOutsideProject:O}=await import('./relaunch-7TTF2OEI.js'),y=O(import.meta.url);y&&process.exit(await y);var{Command:S}=await import('commander'),s=new S;f(s.name("craft").description("A modern routing framework for TypeScript").version(a$1).enablePositionalOptions()).showSuggestionAfterError().showHelpAfterError().exitOverride(t=>{t.code==="commander.unknownCommand"&&process.exit(0);});s.hook("preAction",async(t,e)=>{await E(e);});process.argv.length<=2&&s.help({error:false});async function E(t){let e=await P(t),n=R(t.opts()),{checkBunRuntime:o}=await import('./runtime-gate-NEYB2HPB.js'),r=o();r.ok||await l(1,r.message);let{logFileDiversion:c,logger:d}=await import('@routecraft/routecraft'),i=c();if(i!==void 0){let p=n===void 0?i.source:"--log-file";await l(2,`Cannot write logs to ${i.path} (from ${p}): ${i.reason}. Point it at a file this process can create or append to.`);}for(let p of e)d[p.level](p.message);}async function l(t,e){await C(process.stderr,e),process.exit(t);}function C(t,e){return new Promise(n=>{t.write(`${e}
2
+ import {a as a$1}from'./chunk-NQY6EG6Q.js';import {b as b$1}from'./chunk-OKX5YME7.js';import {resolve}from'path';process.versions.bun||(console.error(b$1),process.exit(1));var{relaunchOutsideProject:O}=await import('./relaunch-7TTF2OEI.js'),y=O(import.meta.url);y&&process.exit(await y);var{Command:S}=await import('commander'),s=new S;f(s.name("craft").description("A modern routing framework for TypeScript").version(a$1).enablePositionalOptions()).showSuggestionAfterError().showHelpAfterError().exitOverride(t=>{t.code==="commander.unknownCommand"&&process.exit(0);});s.hook("preAction",async(t,e)=>{await E(e);});process.argv.length<=2&&s.help({error:false});async function E(t){let e=await P(t),n=R(t.opts()),{checkBunRuntime:o}=await import('./runtime-gate-NEYB2HPB.js'),r=o();r.ok||await l(1,r.message);let{logFileDiversion:c,logger:d}=await import('@routecraft/routecraft'),i=c();if(i!==void 0){let p=n===void 0?i.source:"--log-file";await l(2,`Cannot write logs to ${i.path} (from ${p}): ${i.reason}. Point it at a file this process can create or append to.`);}for(let p of e)d[p.level](p.message);}async function l(t,e){await C(process.stderr,e),process.exit(t);}function C(t,e){return new Promise(n=>{t.write(`${e}
3
3
  `,()=>n());})}function R(t){let e=s.opts(),n=t.logLevel??e.logLevel,o=t.logFile??e.logFile;return n!==void 0&&(process.env.LOG_LEVEL=n,process.env.CRAFT_LOG_LEVEL=n),o!==void 0&&(process.env.LOG_FILE=o,process.env.CRAFT_LOG_FILE=o),o}function f(t){return t.option("--log-level <level>","Log level (e.g. info, warn, error, silent to disable)").option("--log-file <path>","Write logs to a file instead of stdout")}var b=new WeakMap,g="--project <dir>",h="Project whose .routecraft/settings.yaml is read (default: the working directory)";function L(t,e){return b.set(t,e),t.option("--env <path>","Load environment variables from a .env file (default: .env)").option("--profile <name>","Settings profile to select")}async function P(t){let e=b.get(t)?.(t.args);if(e===void 0)return [];let n=t.opts(),{EnvFileError:o,loadEnvironment:r}=await import('./util-CSBMQ2PQ.js'),{resolveSettings:c,SettingsError:d}=await import('./settings-XW6WNPDV.js');try{let i=c({cwd:e,...n.profile===void 0?{}:{profile:n.profile}});return r({explicit:n.env,profile:i.profile?.value,env:i.env?.value,defaultsFrom:e})}catch(i){if(i instanceof d||i instanceof o)return l(2,i.message);throw i}}f(L(s.command("run").description("Run routes from a single TypeScript/JavaScript file").argument("<file>","Path to a file containing routes").argument("[args...]","CLI command and flags to pass through to CLI adapter routes"),()=>process.cwd())).passThroughOptions().action(async(t,e)=>{let{runCommand:n}=await import('./run-BYR62OGM.js'),o=await n(t,e);if(!o.success){a({code:o.code??1,...o.message?{error:o.message}:{}});return}});f(L(s.command("start").description("Start a project from its folder convention (capabilities, plugins, agents, skills)").argument("[dir]","Project root (default: current directory)"),t=>resolve(process.cwd(),t[0]??".")).option("--once","Shut down after the first exchange reaches a terminal outcome").option("--timeout <duration>",'With --once, give up and exit non-zero after this long (milliseconds, or a duration string like "30s")')).action(async(t,e)=>{let{startCommand:n}=await import('./start-OFODWBWZ.js'),o;if(e.timeout!==void 0){let{parseDuration:c}=await import('@routecraft/routecraft'),d=/^\d+(\.\d+)?$/.test(e.timeout.trim())?Number(e.timeout):e.timeout;try{o=c(d,"--timeout");}catch{a({code:1,error:`--timeout must be a number of milliseconds (at least 1) or a duration string like "30s". Received "${String(e.timeout)}".`});return}}if(o!==void 0&&e.once!==true){a({code:1,error:"--timeout bounds the wait for the first exchange, which only --once waits for. Add --once, or drop --timeout."});return}let r=await n(t,{once:e.once===true,...o===void 0?{}:{timeoutMs:o}});if(!r.success){a({code:r.code??1,...r.message?{error:r.message}:{}});return}});function a(t){let e=[];t.output!==void 0&&e.push([process.stdout,t.output]),t.error!==void 0&&e.push([process.stderr,t.error]);let n=()=>{setImmediate(()=>process.exit(t.code));};if(e.length===0){n();return}process.exitCode=t.code,Promise.all(e.map(([o,r])=>C(o,r))).then(n);}async function x(){let{fstatSync:t}=await import('fs');try{let o=t(0);if(!o.isFIFO()&&!o.isFile())return}catch{return}let e=[];for await(let o of process.stdin)e.push(Buffer.from(o));let n=Buffer.concat(e).toString("utf8");return n.length===0?void 0:n}s.command("exec").description("Dispatch to a route on a running instance and print the result").argument("[route]","Route id to dispatch to; omit for the endpoint list").argument("[args...]","Route input as --field=value pairs").option("--profile <name>","Settings profile to select").option(g,h).option("--url <url>","Ops server base URL of the target instance").option("--token <token>","Bearer credential for the management door").option("--format <format>","pretty (default), json, or raw").passThroughOptions().allowUnknownOption().action(async(t,e,n)=>{let{execCommand:o}=await import('./exec-LJZY4IXV.js'),r=t===void 0||e.length>0?void 0:await x();a(await o(t,e,{...n,...r===void 0?{}:{stdin:r}}));});s.command("acp").description("Bridge an editor to an instance over the Agent Client Protocol").option("--profile <name>","Settings profile to select").option(g,h).option("--url <url>","Ops server base URL of the target instance").option("--token <token>","Bearer credential for the management door").option("--agent <name>","Agent to talk to; the instance's default otherwise").action(async t=>{let{acpCommand:e}=await import('./acp-JAOUSF3F.js');a(await e(t));});var m=s.command("ops").description("Inspect a running instance: health, readiness, routes, deferrals, indicators");function u(t){return t.option("--profile <name>","Settings profile to select").option(g,h).option("--url <url>","Ops server base URL of the target instance").option("--token <token>","Bearer credential for the management door").option("--format <format>","pretty (default), json, or raw")}u(m.command("health").description("Operational health: every component, whatever its domain")).action(async t=>{let{healthCommand:e}=await import('./ops-B6N4ATXZ.js');a(await e(t));});u(m.command("ready").description("Readiness: whether this replica should receive traffic")).action(async t=>{let{readyCommand:e}=await import('./ops-B6N4ATXZ.js');a(await e(t));});u(m.command("routes").description("List routes, or describe one").argument("[id]","Route id; omit to list").option("--dispatchable","Only routes that can be dispatched to").option("--source <kind>","Only routes carrying a source of this kind")).action(async(t,e)=>{let{routesCommand:n,routeCommand:o}=await import('./ops-B6N4ATXZ.js');a(t===void 0?await n(e):await o(t,e));});u(m.command("deferrals").description("List what is waiting, or describe one deferral").argument("[id]","Deferral id; omit to list").option("--state <state>","waiting (default), settled, or all").option("--route <id>","Only deferrals belonging to this route").option("--limit <n>","Rows in one page").option("--after <cursor>","Continue from a previous page's cursor")).action(async(t,e)=>{let{deferralsCommand:n,deferralCommand:o}=await import('./ops-B6N4ATXZ.js');a(t===void 0?await n(e):await o(t,e));});u(m.command("indicators").description("List indicators, or read one").argument("[name]","Indicator name; omit to list")).action(async(t,e)=>{let{indicatorsCommand:n,indicatorCommand:o}=await import('./ops-B6N4ATXZ.js');a(t===void 0?await n(e):await o(t,e));});s.command("tui").description("Launch the Terminal UI to monitor Routecraft execution history").option("--db <path>","Path to the telemetry SQLite database",".routecraft/telemetry.db").action(async t=>{let{resolve:e,isAbsolute:n}=await import('path'),o=n(t.db)?t.db:e(process.cwd(),t.db),{renderTui:r}=await import('./tui/app.js');await r(o);});await s.parseAsync();//# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/dist/tui/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import {a}from'../chunk-WCEUG34O.js';import {a as a$1}from'../chunk-2EEA43OX.js';import {useState,useCallback,useEffect,useMemo,Fragment as Fragment$1}from'react';import {useApp,useStdout,useInput,Box,Text,render}from'ink';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ut=[{items:[{key:"capabilities",label:"Capabilities",shortcut:"1"}]},{items:[{key:"agents",label:"Agents",shortcut:"2"},{key:"tools",label:"Tools",shortcut:"3"}]},{items:[{key:"exchanges",label:"Exchanges",shortcut:"4"},{key:"errors",label:"Errors",shortcut:"5"},{key:"events",label:"Events",shortcut:"6"}]}],Xt=Ut.flatMap(e=>e.items);function Re(e,t){return t<=0?"":e.length>t?e.slice(0,t-1)+"\u2026":e}function M(e){return e==null||!Number.isFinite(e)||e<0?"-":e===0?"<1ms":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Z(e){switch(e){case "completed":case "started":case "finished":case "running":return "green";case "failed":case "error":return "red";case "stopped":case "dropped":return "yellow";default:return "white"}}function vo(e){return e<1e5?ee(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}function Ye(e){switch(e){case "result":return "green";case "error":return "red";default:return "yellow"}}function R(e,t){return t===void 0?e:t<=0?"":e.length>t?e.slice(0,t-1)+"\u2026":e.padEnd(t)}function ln(e){try{let t=JSON.parse(e),o="exchangeId"in t?`${String(t.exchangeId).slice(0,8)}`:"",l="duration"in t?M(t.duration):"";if("operation"in t&&"routeId"in t){let s="adapter"in t?`(${t.adapter})`:"adapterId"in t?`(${t.adapterId})`:"",n="";if("metadata"in t&&typeof t.metadata=="object"&&t.metadata!==null){let f=t.metadata,m=Object.keys(f).slice(0,2);m.length>0&&(n=m.map(g=>`${g}=${f[g]}`).join(" "));}return {step:String(t.operation),adapter:s,exchange:o,duration:l,meta:n}}if("routeId"in t&&"exchangeId"in t){let s="error"in t?"(err)":"reason"in t?`(${String(t.reason).slice(0,8)})`:"";return {step:String(t.routeId),adapter:s,exchange:o,duration:l,meta:""}}if("route"in t&&typeof t.route=="object"&&t.route!==null){let s=t.route;return {step:s.routeId??s.definition?.id??"?",adapter:"",exchange:"",duration:"",meta:""}}if("pluginId"in t)return {step:`plugin=${t.pluginId}`,adapter:"",exchange:"",duration:"",meta:""};if("error"in t){let s=t.error;return {step:typeof s=="object"&&s!==null&&"message"in s?String(s.message):String(s),adapter:"",exchange:"",duration:"",meta:""}}return null}catch{return null}}function Io(e,t){let o=ln(t);return o||{step:t,adapter:"",exchange:"",duration:"",meta:""}}function ee(e){return e.toLocaleString("en-US")}function Wt(e,t,o){return o<=0?t:e<t?e:e>=t+o?e-o+1:t}function we(e=0){let[t,o]=useState(e),[l,s]=useState(0),n=useCallback((g,u,x)=>{let T=Math.max(0,Math.min(g,u-1));o(T),s(i=>Wt(T,i,x));},[]),f=useCallback((g,u,x)=>{o(T=>{let i=Math.max(0,Math.min(T+g,u-1));return s(h=>Wt(i,h,x)),i});},[]),m=useCallback(()=>{o(0),s(0);},[]);return {selectedIndex:t,scrollOffset:l,moveBy:f,moveTo:n,reset:m}}var c={accent:"#7482ff",accentSoft:"#9ea8fd",success:"green",error:"red",warn:"yellow",muted:"gray"};function _(e){return e?{color:c.accent,bold:true}:{}}function w({title:e,subtitle:t,color:o=c.muted,width:l,flexGrow:s,paddingX:n=1,children:f}){let m=l?l-2-n*2:20;return jsxs(Box,{flexDirection:"column",borderStyle:"single",borderColor:o,paddingX:n,width:l,flexGrow:s,children:[e&&jsxs(Fragment,{children:[jsxs(Text,{bold:true,dimColor:true,children:[e,t&&jsxs(Fragment,{children:[" ",t]})]}),jsx(Text,{dimColor:true,children:"\u2500".repeat(Math.max(m,1))})]}),f]})}var un=[192,36,18,9],dn=10240,ft=[{max:0,color:"gray"},{max:10,color:"green"},{max:20,color:"green"},{max:30,color:"yellow"},{max:40,color:"yellow"},{max:50,color:"red"}];function Dt({values:e,columns:t,steps:o=ft,label:l}){let s=o.length-1,n=e.length>=t?e.slice(e.length-t):[...new Array(t-e.length).fill(0),...e],f=n.map(u=>{if(u<=0)return 0;for(let x=1;x<o.length;x++)if(u<o[x].max)return x;return s}),m=Math.ceil(s/4),g=[];for(let u=m-1;u>=0;u--){let x=u*4,T=[];for(let i=0;i<n.length;i++){let h=f[i],p=0,y="";for(let D=0;D<4;D++){let ie=x+D+1;if(ie>s)break;(h>=ie||h===0&&ie===1)&&(p|=un[D],y=h===0?o[0].color:o[ie].color);}let H=String.fromCharCode(dn+p),F=T[T.length-1];F&&F.color===y?F.text+=H:T.push({text:H,color:y});}g.push(jsx(Text,{children:T.map((i,h)=>i.color?jsx(Text,{color:i.color,children:i.text},h):jsx(Text,{children:i.text},h))},u));}return jsxs(Fragment,{children:[g,l&&jsx(Text,{dimColor:true,wrap:"truncate",children:l})]})}function ko({route:e}){return jsxs(Fragment,{children:[jsxs(Text,{wrap:"truncate",children:["Capability:"," ",jsx(Text,{bold:true,color:c.accent,children:e.id})]}),jsxs(Text,{wrap:"truncate",children:["Status:"," ",jsx(Text,{bold:true,color:Z(e.status),children:e.status})," ","Exchanges: ",jsx(Text,{bold:true,children:ee(e.totalExchanges)})," ","Errors:"," ",jsx(Text,{bold:true,...e.failedExchanges>0?{color:"red"}:{},children:ee(e.failedExchanges)})," ","Dropped:"," ",jsx(Text,{bold:true,...e.droppedExchanges>0?{color:"yellow"}:{},children:ee(e.droppedExchanges)})," ","Avg: ",jsx(Text,{bold:true,children:M(e.avgDurationMs)})]})]})}function te({columns:e,data:t,rowKey:o,selectedIndex:l,scrollOffset:s,visibleRows:n,gap:f=2,emptyMessage:m="No data",renderFullRow:g}){let u=" ".repeat(f),x=jsx(Box,{children:e.map((h,p)=>{let H=p===e.length-1?"":u;if(h.width==="flex")return jsxs(Fragment$1,{children:[jsx(Box,{flexGrow:1,flexBasis:0,minWidth:0,children:jsx(Text,{bold:true,dimColor:true,wrap:"truncate",children:h.header})}),H&&jsx(Box,{flexShrink:0,children:jsx(Text,{children:H})})]},p);let F=h.align==="right"?h.header.padStart(h.width):R(h.header,h.width);return jsxs(Box,{flexShrink:0,children:[jsx(Text,{bold:true,dimColor:true,children:F}),H&&jsx(Text,{children:H})]},p)})});if(t.length===0)return jsxs(Fragment,{children:[x,jsx(Text,{dimColor:true,children:m})]});let T=t.slice(s,s+n),i=t.length-s-n;return jsxs(Fragment,{children:[x,T.map((h,p)=>{let y=s+p,H=y===l,F=g?.(h,y);return F!==void 0?jsx(Box,{children:F},o(h,y)):jsx(Box,{children:e.map((D,ie)=>{let v=ie===e.length-1?"":u,j=D.width==="flex"?void 0:D.width,rt=D.render(h,H,j);return D.width==="flex"?jsxs(Fragment$1,{children:[jsx(Box,{flexGrow:1,flexBasis:0,minWidth:0,children:jsx(Text,{wrap:"truncate",children:rt})}),v&&jsx(Box,{flexShrink:0,children:jsx(Text,{children:v})})]},ie):jsxs(Box,{flexShrink:0,children:[rt,v&&jsx(Text,{children:v})]},ie)})},o(h,y))}),jsx(Text,{dimColor:true,children:i>0?"\u2193 more":" "})]})}function kt(e,t={adapter:true,exchange:true}){let o=new WeakMap;function l(s){let n=e(s);if(!n)return;let f=o.get(n);return f||(f=Io(n.eventName,n.details),o.set(n,f)),f}return [{header:"Step",width:10,render:(s,n,f)=>{let m=l(s);return m?jsx(Text,{children:R(m.step,f)}):jsx(Text,{children:R("",f)})}},...t.adapter?[{header:"Adapter",width:10,render:(s,n,f)=>{let m=l(s);return m?jsx(Text,{children:R(m.adapter,f)}):jsx(Text,{children:R("",f)})}}]:[],...t.exchange?[{header:"Exchange",width:12,render:(s,n,f)=>{let m=l(s);return m?jsx(Text,{children:R(m.exchange,f)}):jsx(Text,{children:R("",f)})}}]:[],{header:"Duration",width:8,align:"right",render:s=>{let n=l(s);return n?jsx(Text,{children:n.duration.padStart(8)}):jsx(Text,{children:""})}}]}function oe(){return {header:"",width:2,render:(e,t)=>jsx(Text,{..._(t),children:t?"> ":" "})}}var pn=[oe(),{header:"ID",width:"flex",render:(e,t)=>jsx(Text,{..._(t),children:e.id})},{header:"Status",width:9,render:(e,t,o)=>jsx(Text,{color:Z(e.status),children:R(e.status,o)})},{header:"Duration",width:8,align:"right",render:e=>jsx(Text,{children:M(e.durationMs).padStart(8)})},{header:"Time",width:8,render:(e,t,o)=>jsx(Text,{dimColor:true,children:R(e.startedAt.replace("T"," ").slice(11,19),o)})}];function Lo({capabilityId:e,route:t,exchanges:o,selectedIndex:l,scrollOffset:s,width:n,height:f,color:m=c.muted,activity:g,title:u}){let x=Math.ceil((ft.length-1)/4),T=t?2+x+2:0,i=Math.max(f-6-T,3),h=u??(t?"EXCHANGES":`EXCHANGES: ${e}`);return jsxs(Box,{flexDirection:"column",width:n,flexGrow:1,children:[t&&jsxs(w,{width:n,children:[jsx(ko,{route:t}),jsx(Text,{children:" "}),jsx(Dt,{values:g?g.throughput:[],columns:n-4,label:"Exchanges per 5s bucket"})]}),jsx(w,{title:h,width:n,flexGrow:1,color:m,children:jsx(te,{columns:pn,data:o,rowKey:p=>`${p.id}:${p.contextId}`,selectedIndex:l,scrollOffset:s,visibleRows:i,emptyMessage:"No exchanges"})})]})}function gn(e){let t=[],o=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(\btrue\b|\bfalse\b)|(\bnull\b)|([{}[\],:])/g,l=0,s;for(;(s=o.exec(e))!==null;)s.index>l&&t.push({text:e.slice(l,s.index),type:"brace"}),s[1]!==void 0?(t.push({text:s[1],type:"key"}),t.push({text:":",type:"brace"})):s[2]!==void 0?t.push({text:s[2],type:"string"}):s[3]!==void 0?t.push({text:s[3],type:"number"}):s[4]!==void 0?t.push({text:s[4],type:"boolean"}):s[5]!==void 0?t.push({text:s[5],type:"null"}):s[6]!==void 0&&t.push({text:s[6],type:"brace"}),l=s.index+s[0].length;return l<e.length&&t.push({text:e.slice(l),type:"brace"}),t}var Tn={key:"white",string:c.accentSoft,number:c.warn,boolean:c.warn,null:c.error,brace:c.muted};function xe(e,t){try{let o=JSON.parse(e);return JSON.stringify(o,null,2).split(`
1
+ import {a}from'../chunk-NQY6EG6Q.js';import {a as a$1}from'../chunk-2EEA43OX.js';import {useState,useCallback,useEffect,useMemo,Fragment as Fragment$1}from'react';import {useApp,useStdout,useInput,Box,Text,render}from'ink';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ut=[{items:[{key:"capabilities",label:"Capabilities",shortcut:"1"}]},{items:[{key:"agents",label:"Agents",shortcut:"2"},{key:"tools",label:"Tools",shortcut:"3"}]},{items:[{key:"exchanges",label:"Exchanges",shortcut:"4"},{key:"errors",label:"Errors",shortcut:"5"},{key:"events",label:"Events",shortcut:"6"}]}],Xt=Ut.flatMap(e=>e.items);function Re(e,t){return t<=0?"":e.length>t?e.slice(0,t-1)+"\u2026":e}function M(e){return e==null||!Number.isFinite(e)||e<0?"-":e===0?"<1ms":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Z(e){switch(e){case "completed":case "started":case "finished":case "running":return "green";case "failed":case "error":return "red";case "stopped":case "dropped":return "yellow";default:return "white"}}function vo(e){return e<1e5?ee(e):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}function Ye(e){switch(e){case "result":return "green";case "error":return "red";default:return "yellow"}}function R(e,t){return t===void 0?e:t<=0?"":e.length>t?e.slice(0,t-1)+"\u2026":e.padEnd(t)}function ln(e){try{let t=JSON.parse(e),o="exchangeId"in t?`${String(t.exchangeId).slice(0,8)}`:"",l="duration"in t?M(t.duration):"";if("operation"in t&&"routeId"in t){let s="adapter"in t?`(${t.adapter})`:"adapterId"in t?`(${t.adapterId})`:"",n="";if("metadata"in t&&typeof t.metadata=="object"&&t.metadata!==null){let f=t.metadata,m=Object.keys(f).slice(0,2);m.length>0&&(n=m.map(g=>`${g}=${f[g]}`).join(" "));}return {step:String(t.operation),adapter:s,exchange:o,duration:l,meta:n}}if("routeId"in t&&"exchangeId"in t){let s="error"in t?"(err)":"reason"in t?`(${String(t.reason).slice(0,8)})`:"";return {step:String(t.routeId),adapter:s,exchange:o,duration:l,meta:""}}if("route"in t&&typeof t.route=="object"&&t.route!==null){let s=t.route;return {step:s.routeId??s.definition?.id??"?",adapter:"",exchange:"",duration:"",meta:""}}if("pluginId"in t)return {step:`plugin=${t.pluginId}`,adapter:"",exchange:"",duration:"",meta:""};if("error"in t){let s=t.error;return {step:typeof s=="object"&&s!==null&&"message"in s?String(s.message):String(s),adapter:"",exchange:"",duration:"",meta:""}}return null}catch{return null}}function Io(e,t){let o=ln(t);return o||{step:t,adapter:"",exchange:"",duration:"",meta:""}}function ee(e){return e.toLocaleString("en-US")}function Wt(e,t,o){return o<=0?t:e<t?e:e>=t+o?e-o+1:t}function we(e=0){let[t,o]=useState(e),[l,s]=useState(0),n=useCallback((g,u,x)=>{let T=Math.max(0,Math.min(g,u-1));o(T),s(i=>Wt(T,i,x));},[]),f=useCallback((g,u,x)=>{o(T=>{let i=Math.max(0,Math.min(T+g,u-1));return s(h=>Wt(i,h,x)),i});},[]),m=useCallback(()=>{o(0),s(0);},[]);return {selectedIndex:t,scrollOffset:l,moveBy:f,moveTo:n,reset:m}}var c={accent:"#7482ff",accentSoft:"#9ea8fd",success:"green",error:"red",warn:"yellow",muted:"gray"};function _(e){return e?{color:c.accent,bold:true}:{}}function w({title:e,subtitle:t,color:o=c.muted,width:l,flexGrow:s,paddingX:n=1,children:f}){let m=l?l-2-n*2:20;return jsxs(Box,{flexDirection:"column",borderStyle:"single",borderColor:o,paddingX:n,width:l,flexGrow:s,children:[e&&jsxs(Fragment,{children:[jsxs(Text,{bold:true,dimColor:true,children:[e,t&&jsxs(Fragment,{children:[" ",t]})]}),jsx(Text,{dimColor:true,children:"\u2500".repeat(Math.max(m,1))})]}),f]})}var un=[192,36,18,9],dn=10240,ft=[{max:0,color:"gray"},{max:10,color:"green"},{max:20,color:"green"},{max:30,color:"yellow"},{max:40,color:"yellow"},{max:50,color:"red"}];function Dt({values:e,columns:t,steps:o=ft,label:l}){let s=o.length-1,n=e.length>=t?e.slice(e.length-t):[...new Array(t-e.length).fill(0),...e],f=n.map(u=>{if(u<=0)return 0;for(let x=1;x<o.length;x++)if(u<o[x].max)return x;return s}),m=Math.ceil(s/4),g=[];for(let u=m-1;u>=0;u--){let x=u*4,T=[];for(let i=0;i<n.length;i++){let h=f[i],p=0,y="";for(let D=0;D<4;D++){let ie=x+D+1;if(ie>s)break;(h>=ie||h===0&&ie===1)&&(p|=un[D],y=h===0?o[0].color:o[ie].color);}let H=String.fromCharCode(dn+p),F=T[T.length-1];F&&F.color===y?F.text+=H:T.push({text:H,color:y});}g.push(jsx(Text,{children:T.map((i,h)=>i.color?jsx(Text,{color:i.color,children:i.text},h):jsx(Text,{children:i.text},h))},u));}return jsxs(Fragment,{children:[g,l&&jsx(Text,{dimColor:true,wrap:"truncate",children:l})]})}function ko({route:e}){return jsxs(Fragment,{children:[jsxs(Text,{wrap:"truncate",children:["Capability:"," ",jsx(Text,{bold:true,color:c.accent,children:e.id})]}),jsxs(Text,{wrap:"truncate",children:["Status:"," ",jsx(Text,{bold:true,color:Z(e.status),children:e.status})," ","Exchanges: ",jsx(Text,{bold:true,children:ee(e.totalExchanges)})," ","Errors:"," ",jsx(Text,{bold:true,...e.failedExchanges>0?{color:"red"}:{},children:ee(e.failedExchanges)})," ","Dropped:"," ",jsx(Text,{bold:true,...e.droppedExchanges>0?{color:"yellow"}:{},children:ee(e.droppedExchanges)})," ","Avg: ",jsx(Text,{bold:true,children:M(e.avgDurationMs)})]})]})}function te({columns:e,data:t,rowKey:o,selectedIndex:l,scrollOffset:s,visibleRows:n,gap:f=2,emptyMessage:m="No data",renderFullRow:g}){let u=" ".repeat(f),x=jsx(Box,{children:e.map((h,p)=>{let H=p===e.length-1?"":u;if(h.width==="flex")return jsxs(Fragment$1,{children:[jsx(Box,{flexGrow:1,flexBasis:0,minWidth:0,children:jsx(Text,{bold:true,dimColor:true,wrap:"truncate",children:h.header})}),H&&jsx(Box,{flexShrink:0,children:jsx(Text,{children:H})})]},p);let F=h.align==="right"?h.header.padStart(h.width):R(h.header,h.width);return jsxs(Box,{flexShrink:0,children:[jsx(Text,{bold:true,dimColor:true,children:F}),H&&jsx(Text,{children:H})]},p)})});if(t.length===0)return jsxs(Fragment,{children:[x,jsx(Text,{dimColor:true,children:m})]});let T=t.slice(s,s+n),i=t.length-s-n;return jsxs(Fragment,{children:[x,T.map((h,p)=>{let y=s+p,H=y===l,F=g?.(h,y);return F!==void 0?jsx(Box,{children:F},o(h,y)):jsx(Box,{children:e.map((D,ie)=>{let v=ie===e.length-1?"":u,j=D.width==="flex"?void 0:D.width,rt=D.render(h,H,j);return D.width==="flex"?jsxs(Fragment$1,{children:[jsx(Box,{flexGrow:1,flexBasis:0,minWidth:0,children:jsx(Text,{wrap:"truncate",children:rt})}),v&&jsx(Box,{flexShrink:0,children:jsx(Text,{children:v})})]},ie):jsxs(Box,{flexShrink:0,children:[rt,v&&jsx(Text,{children:v})]},ie)})},o(h,y))}),jsx(Text,{dimColor:true,children:i>0?"\u2193 more":" "})]})}function kt(e,t={adapter:true,exchange:true}){let o=new WeakMap;function l(s){let n=e(s);if(!n)return;let f=o.get(n);return f||(f=Io(n.eventName,n.details),o.set(n,f)),f}return [{header:"Step",width:10,render:(s,n,f)=>{let m=l(s);return m?jsx(Text,{children:R(m.step,f)}):jsx(Text,{children:R("",f)})}},...t.adapter?[{header:"Adapter",width:10,render:(s,n,f)=>{let m=l(s);return m?jsx(Text,{children:R(m.adapter,f)}):jsx(Text,{children:R("",f)})}}]:[],...t.exchange?[{header:"Exchange",width:12,render:(s,n,f)=>{let m=l(s);return m?jsx(Text,{children:R(m.exchange,f)}):jsx(Text,{children:R("",f)})}}]:[],{header:"Duration",width:8,align:"right",render:s=>{let n=l(s);return n?jsx(Text,{children:n.duration.padStart(8)}):jsx(Text,{children:""})}}]}function oe(){return {header:"",width:2,render:(e,t)=>jsx(Text,{..._(t),children:t?"> ":" "})}}var pn=[oe(),{header:"ID",width:"flex",render:(e,t)=>jsx(Text,{..._(t),children:e.id})},{header:"Status",width:9,render:(e,t,o)=>jsx(Text,{color:Z(e.status),children:R(e.status,o)})},{header:"Duration",width:8,align:"right",render:e=>jsx(Text,{children:M(e.durationMs).padStart(8)})},{header:"Time",width:8,render:(e,t,o)=>jsx(Text,{dimColor:true,children:R(e.startedAt.replace("T"," ").slice(11,19),o)})}];function Lo({capabilityId:e,route:t,exchanges:o,selectedIndex:l,scrollOffset:s,width:n,height:f,color:m=c.muted,activity:g,title:u}){let x=Math.ceil((ft.length-1)/4),T=t?2+x+2:0,i=Math.max(f-6-T,3),h=u??(t?"EXCHANGES":`EXCHANGES: ${e}`);return jsxs(Box,{flexDirection:"column",width:n,flexGrow:1,children:[t&&jsxs(w,{width:n,children:[jsx(ko,{route:t}),jsx(Text,{children:" "}),jsx(Dt,{values:g?g.throughput:[],columns:n-4,label:"Exchanges per 5s bucket"})]}),jsx(w,{title:h,width:n,flexGrow:1,color:m,children:jsx(te,{columns:pn,data:o,rowKey:p=>`${p.id}:${p.contextId}`,selectedIndex:l,scrollOffset:s,visibleRows:i,emptyMessage:"No exchanges"})})]})}function gn(e){let t=[],o=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(\btrue\b|\bfalse\b)|(\bnull\b)|([{}[\],:])/g,l=0,s;for(;(s=o.exec(e))!==null;)s.index>l&&t.push({text:e.slice(l,s.index),type:"brace"}),s[1]!==void 0?(t.push({text:s[1],type:"key"}),t.push({text:":",type:"brace"})):s[2]!==void 0?t.push({text:s[2],type:"string"}):s[3]!==void 0?t.push({text:s[3],type:"number"}):s[4]!==void 0?t.push({text:s[4],type:"boolean"}):s[5]!==void 0?t.push({text:s[5],type:"null"}):s[6]!==void 0&&t.push({text:s[6],type:"brace"}),l=s.index+s[0].length;return l<e.length&&t.push({text:e.slice(l),type:"brace"}),t}var Tn={key:"white",string:c.accentSoft,number:c.warn,boolean:c.warn,null:c.error,brace:c.muted};function xe(e,t){try{let o=JSON.parse(e);return JSON.stringify(o,null,2).split(`
2
2
  `).map(s=>{let n=Math.max(1,t);return s.length>n?s.slice(0,Math.max(0,n-1))+"\u2026":s})}catch{let o=Math.max(1,t);return e.split(`
3
3
  `).map(l=>l.length>o?l.slice(0,Math.max(0,o-1))+"\u2026":l)}}function et({line:e}){let t=gn(e);return t.length===0?jsx(Text,{children:e}):jsx(Text,{children:t.map((o,l)=>jsx(Text,{color:Tn[o.type],children:o.text},l))})}function At(e){try{let t=JSON.parse(e);return typeof t!="object"||t===null||Array.isArray(t)?null:t}catch{return null}}function En(e,t){let o=new Map,l=0;o.set(t,{exchangeId:t,label:"parent",events:[]});for(let s of e){let n=At(s.details),f=n?String(n.exchangeId??""):"",m=!f||f===t?t:f;o.has(m)||(l++,o.set(m,{exchangeId:m,label:`child ${l}`,events:[]})),o.get(m).events.push(s);}return Array.from(o.values())}function Rn(e){return [oe(),{header:"Time",width:10,render:(t,o,l)=>{if(!t.event)return jsx(Text,{children:R("",l)});let s=" ".repeat(t.indent);return jsx(Text,{dimColor:true,children:R(s+t.event.timestamp.replace("T"," ").slice(11,19),l)})}},{header:"Event",width:"flex",render:t=>t.event?jsx(Text,{children:t.event.eventName}):jsx(Text,{})},...kt(t=>t.event,{adapter:e>=80,exchange:e>=68})]}function _o({exchange:e,events:t,width:o,height:l,scrollOffset:s,selectedIndex:n=-1,color:f=c.muted}){let m=e.error?2:0,g=Math.max(l-9-m,3),u=useMemo(()=>Rn(o-4),[o]),x=En(t,e.id),T=x.length>1,i=[];for(let p of x){T&&i.push({type:"header",text:`${p.label} (${p.exchangeId.slice(0,8)}) - ${p.events.length} events`,indent:0});for(let y of p.events)i.push({type:"event",event:y,indent:T?2:0});}let h=T?`EXCHANGE FLOW (${x.length} exchanges, ${t.length} events)`:`RELATED EVENTS (${t.length})`;return jsxs(Box,{flexDirection:"column",width:o,flexGrow:1,children:[jsxs(w,{width:o,children:[jsxs(Text,{children:["Capability:"," ",jsx(Text,{bold:true,color:c.accent,children:e.routeId})]}),jsxs(Text,{children:["Exchange:"," ",jsx(Text,{bold:true,color:c.accent,children:Re(e.id,o-14)})]}),jsxs(Text,{children:["Status:"," ",jsx(Text,{bold:true,color:Z(e.status),children:e.status}),e.durationMs!==null&&jsxs(Text,{children:[" ","Duration:"," ",jsx(Text,{bold:true,children:M(e.durationMs)})]})," ","Started: ",jsx(Text,{bold:true,children:e.startedAt}),e.completedAt&&jsxs(Text,{children:[" ","Completed: ",jsx(Text,{bold:true,children:e.completedAt})]})]}),e.error&&e.status==="failed"&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{color:"red",children:["Error: ",e.error]})]}),e.error&&e.status==="dropped"&&jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsxs(Text,{color:"yellow",children:["Reason: ",e.error]})]})]}),jsx(w,{title:h,width:o,flexGrow:1,color:f,children:jsx(te,{columns:u,data:i,rowKey:(p,y)=>p.type==="header"?`h-${y}`:`${p.event?.id??p.event?.timestamp}-${y}`,selectedIndex:n,scrollOffset:s,visibleRows:g,emptyMessage:"No related events found",renderFullRow:p=>p.type==="header"?jsx(Text,{bold:true,color:c.accent,children:p.text}):void 0})})]})}function Cn(e){return [oe(),{header:"Time",width:8,render:(t,o,l)=>jsx(Text,{..._(o),children:R(t.timestamp.replace("T"," ").slice(11,19),l)})},{header:"Event",width:"flex",render:t=>jsx(Text,{children:t.eventName})},...kt(t=>t,{adapter:e>=80,exchange:e>=68})]}function Po({events:e,selectedIndex:t,scrollOffset:o,width:l,height:s,color:n=c.muted}){let f=Math.max(s-6,5),m=useMemo(()=>Cn(l-4),[l]);return jsx(w,{title:"EVENTS",subtitle:jsxs(Text,{dimColor:true,children:["(",e.length," total)"]}),width:l,flexGrow:1,color:n,children:jsx(te,{columns:m,data:e,rowKey:(g,u)=>g.id!==void 0?String(g.id):`${g.timestamp}-${u}`,selectedIndex:t,scrollOffset:o,visibleRows:f,emptyMessage:"No events recorded yet."})})}function $o({event:e,width:t,height:o,scrollOffset:l,color:s=c.accent}){let n=At(e.details),f=n&&typeof n.routeId=="string"?n.routeId:void 0,m=n&&typeof n.exchangeId=="string"?n.exchangeId:void 0,u=2+(1+(f?1:0)+(m?1:0)+2),x=5,T=Math.max(t-6,20),i=xe(e.details,T),h=Math.max(o-u-x,3),p=Math.max(0,Math.min(l,Math.max(i.length-h,0))),y=i.slice(p,p+h);return jsxs(Box,{flexDirection:"column",width:t,flexGrow:1,children:[jsxs(w,{width:t,children:[jsxs(Text,{children:["Context:"," ",jsx(Text,{bold:true,color:c.accent,children:e.contextId})]}),f&&jsxs(Text,{children:["Capability:"," ",jsx(Text,{bold:true,color:c.accent,children:f})]}),m&&jsxs(Text,{children:["Exchange:"," ",jsx(Text,{bold:true,color:c.accent,children:m})]}),jsxs(Text,{children:["Event:"," ",jsx(Text,{bold:true,color:c.accent,children:e.eventName})]}),jsxs(Text,{children:["Time: ",jsx(Text,{bold:true,children:e.timestamp.replace("T"," ")})]})]}),jsxs(w,{title:"DETAILS",subtitle:jsxs(Text,{dimColor:true,children:["(",p+1,"-",Math.min(p+h,i.length),"/",i.length," lines)"]}),width:t,flexGrow:1,color:s,children:[y.map((H,F)=>jsx(et,{line:H},p+F)),y.length<h&&Array.from({length:h-y.length}).map((H,F)=>jsx(Text,{children:" "},`pad-${F}`))]})]})}function Mn(e,t){let o=[];return o.push("HEADERS"),o.push(...xe(e.headers,t)),o.push(""),o.push("BODY"),e.body!==null?(o.push(...xe(e.body,t)),e.truncated&&(o.push(""),o.push("[Body truncated to configured limit]"))):o.push("[null]"),o}function Go({exchange:e,snapshot:t,width:o,height:l,scrollOffset:s,color:n=c.accent}){let g=Math.max(o-6,20),u=Math.max(l-5-5,3),T=t!==null?Mn(t,g):["[Snapshots not captured]","","Enable with:"," telemetry({ sqlite: { captureSnapshots: true } })"],i=Math.max(0,Math.min(s,Math.max(T.length-u,0))),h=T.slice(i,i+u);return jsxs(Box,{flexDirection:"column",width:o,flexGrow:1,children:[jsxs(w,{width:o,children:[jsxs(Text,{children:["Capability:"," ",jsx(Text,{bold:true,color:c.accent,children:e.routeId})]}),jsxs(Text,{children:["Exchange:"," ",jsx(Text,{bold:true,color:c.accent,children:Re(e.id,o-14)})]}),jsxs(Text,{children:["Status:"," ",jsx(Text,{bold:true,color:Z(e.status),children:e.status}),e.durationMs!==null&&jsxs(Text,{children:[" ","Duration:"," ",jsx(Text,{bold:true,children:M(e.durationMs)})]})]})]}),jsxs(w,{title:"EXCHANGE SNAPSHOT",subtitle:jsxs(Text,{dimColor:true,children:["(",i+1,"-",Math.min(i+u,T.length),"/",T.length," lines)"]}),width:o,flexGrow:1,color:n,children:[h.map((p,y)=>p==="HEADERS"||p==="BODY"?jsx(Text,{bold:true,color:c.accent,children:p},i+y):p.startsWith("[")?jsx(Text,{dimColor:true,children:p},i+y):jsx(et,{line:p},i+y)),h.length<u&&Array.from({length:u-h.length}).map((p,y)=>jsx(Text,{children:" "},`pad-${y}`))]})]})}function Lt({items:e,itemKey:t,label:o,dotColor:l,emptyText:s,selectedIndex:n,listOffset:f,visibleRows:m,width:g}){let u=Math.max(0,Math.min(f,Math.max(e.length-m,0)));return jsxs(Fragment,{children:[jsx(Text,{children:" "}),jsx(Text,{bold:true,dimColor:true,children:"\u2500".repeat(g+2)}),e.length===0?jsx(Text,{dimColor:true,children:s}):e.slice(u,u+m).map((x,T)=>{let h=u+T===n;return jsxs(Text,{wrap:"truncate",children:[jsx(Text,{..._(h),children:h?"> ":" "}),jsx(Text,{color:l(x),children:"\u25CF "}),jsx(Text,{..._(h),children:Re(o(x),g-2)})]},t(x))}),e.length>m&&jsxs(Text,{dimColor:true,children:[n+1,"/",e.length]})]})}function Ho({agentKey:e,runs:t,infos:o,selectedIndex:l,scrollOffset:s,width:n,height:f,color:m}){let g=Math.max(f-6,3),u=e?`RUNS: ${e}`:"RUNS",x=n-4>=66,T=[oe(),{header:"Run",width:"flex",render:(i,h)=>jsx(Text,{..._(h),children:i.id})},{header:"Status",width:9,render:(i,h,p)=>{let y=o.get(i.id)?.status??i.status;return jsx(Text,{color:Z(y),children:R(y,p)})}},{header:"Model",width:"flex",render:i=>jsx(Text,{dimColor:true,children:o.get(i.id)?.model??"-"})},{header:"Tokens",width:6,align:"right",render:i=>{let h=o.get(i.id)?.totalTokens;return jsx(Text,{children:(h!=null?vo(h):"-").padStart(6)})}},{header:"Duration",width:8,align:"right",render:i=>jsx(Text,{children:M(i.durationMs).padStart(8)})},...x?[{header:"Time",width:8,render:(i,h,p)=>jsx(Text,{dimColor:true,children:R(i.startedAt.replace("T"," ").slice(11,19),p)})}]:[]];return jsx(Box,{flexDirection:"column",width:n,flexGrow:1,children:jsx(w,{title:u,width:n,flexGrow:1,...m?{color:m}:{},children:jsx(te,{columns:T,data:t,rowKey:i=>`${i.id}:${i.contextId}`,selectedIndex:l,scrollOffset:s,visibleRows:g,emptyMessage:"No runs"})})})}var Nn=[oe(),{header:"Tool",width:"flex",render:(e,t)=>jsx(Text,{..._(t),children:e.toolName})},{header:"Status",width:8,render:(e,t,o)=>jsx(Text,{color:Ye(e.status),children:R(e.status,o)})},{header:"I/O",width:3,render:e=>jsx(Text,{dimColor:true,children:(e.hasInput?"i":"-")+(e.hasOutput?"o":"-")})},{header:"Duration",width:8,align:"right",render:e=>jsx(Text,{children:M(e.durationMs).padStart(8)})}];function Fo({agentKey:e,run:t,info:o,toolCalls:l,selectedIndex:s,scrollOffset:n,width:f,height:m,color:g=c.accent}){let x=Math.max(m-6-6,3),T=o&&(o.inputTokens!==null||o.outputTokens!==null)?`${o.inputTokens??"?"} in / ${o.outputTokens??"?"} out`+(o.totalTokens!==null?` (${o.totalTokens} total)`:""):o&&o.totalTokens!==null?`${o.totalTokens} total`:"-";return jsxs(Box,{flexDirection:"column",width:f,flexGrow:1,children:[jsxs(w,{width:f,children:[jsxs(Text,{children:["Agent:"," ",jsx(Text,{bold:true,color:c.accent,children:e})]}),jsxs(Text,{children:["Model: ",jsx(Text,{bold:true,children:o?.model??"-"})]}),jsxs(Text,{children:["Status:"," ",jsx(Text,{bold:true,color:Z(o?.status??t.status),children:o?.status??t.status}),o?.finishReason&&jsxs(Text,{children:[" ","Finish: ",jsx(Text,{bold:true,children:o.finishReason})]})]}),jsxs(Text,{children:["Tokens: ",jsx(Text,{bold:true,children:T})]})]}),jsx(w,{title:"TOOL CALLS",width:f,flexGrow:1,color:g,children:jsx(te,{columns:Nn,data:l,rowKey:i=>i.toolCallId,selectedIndex:s,scrollOffset:n,visibleRows:x,emptyMessage:"No tool calls"})})]})}function Ln(e){return [oe(),{header:"Route",width:"flex",render:(t,o)=>jsx(Text,{..._(o),children:t.routeId||"-"})},...e>=68?[{header:"Agent",width:12,render:(t,o,l)=>jsx(Text,{dimColor:true,children:R(t.agentName??"-",l)})}]:[],{header:"Status",width:8,render:(t,o,l)=>jsx(Text,{color:Ye(t.status),children:R(t.status,l)})},{header:"Exchange",width:12,render:(t,o,l)=>jsx(Text,{dimColor:true,children:R(t.exchangeId.slice(0,8),l)})},{header:"Duration",width:8,align:"right",render:t=>jsx(Text,{children:M(t.durationMs).padStart(8)})},...e>=82?[{header:"Time",width:8,render:(t,o,l)=>jsx(Text,{dimColor:true,children:R(t.timestamp.slice(11,19),l)})}]:[]]}function jo({toolName:e,calls:t,selectedIndex:o,scrollOffset:l,width:s,height:n,color:f=c.muted}){let m=Math.max(n-6,3),g=e?`TOOL CALLS: ${e}`:"TOOL CALLS";return jsx(Box,{flexDirection:"column",width:s,flexGrow:1,children:jsx(w,{title:g,width:s,flexGrow:1,color:f,children:jsx(te,{columns:Ln(s-4),data:t,rowKey:u=>u.toolCallId,selectedIndex:o,scrollOffset:l,visibleRows:m,emptyMessage:"No tool calls"})})})}function _n(e,t){let o=[];return o.push("INPUT"),e.hasInput&&e.input!==null?o.push(...xe(e.input,t)):o.push("[Not captured - enable snapshots]"),o.push(""),o.push("OUTPUT"),e.status==="invoked"?o.push("[Pending - tool still running or not recorded]"):e.hasOutput&&e.output!==null?o.push(...xe(e.output,t)):e.status==="error"?o.push("[No output - call errored]"):o.push("[Not captured - enable snapshots]"),e.status==="error"?(o.push(""),o.push("ERROR"),e.error!==null?o.push(...xe(e.error,t)):o.push(`[${e.errorName??"Error"} - enable snapshots for details]`)):e.error!==null&&(o.push(""),o.push("ERROR"),o.push(...xe(e.error,t))),o}function Jo({call:e,width:t,height:o,scrollOffset:l,color:s=c.accent}){let m=Math.max(t-6,20),g=Math.max(o-5-5,3),u=_n(e,m),x=Math.max(0,Math.min(l,Math.max(u.length-g,0))),T=u.slice(x,x+g);return jsxs(Box,{flexDirection:"column",width:t,flexGrow:1,children:[jsxs(w,{width:t,children:[jsxs(Text,{children:["Tool:"," ",jsx(Text,{bold:true,color:c.accent,children:Re(e.toolName,t-10)})]}),jsxs(Text,{children:["Exchange:"," ",jsx(Text,{bold:true,color:c.accent,children:Re(e.exchangeId,t-14)})]}),jsxs(Text,{children:["Status:"," ",jsx(Text,{bold:true,color:Ye(e.status),children:e.status}),e.durationMs!==null&&jsxs(Text,{children:[" ","Duration:"," ",jsx(Text,{bold:true,children:M(e.durationMs)})]})]})]}),jsxs(w,{title:"TOOL CALL",subtitle:jsxs(Text,{dimColor:true,children:["(",x+1,"-",Math.min(x+g,u.length),"/",u.length," lines)"]}),width:t,flexGrow:1,color:s,children:[T.map((i,h)=>i==="INPUT"||i==="OUTPUT"||i==="ERROR"?jsx(Text,{bold:true,color:c.accent,children:i},x+h):i.startsWith("[")?jsx(Text,{dimColor:true,children:i},x+h):jsx(et,{line:i},x+h)),T.length<g&&Array.from({length:g-T.length}).map((i,h)=>jsx(Text,{children:" "},`pad-${h}`))]})]})}function Jn(e){return e.failedExchanges>0?c.error:e.totalExchanges>0?c.success:c.warn}function Kn(e){return e.errorCount>0?c.error:e.runCount>0?c.success:c.warn}function Vn(e){return e.errorCount>0?c.error:e.callCount>0?c.success:c.warn}var to=[...Array.from({length:7},(e,t)=>({max:(t+1)*5,color:"green"})),...Array.from({length:7},(e,t)=>({max:35+(t+1)*10,color:"yellow"})),...Array.from({length:6},(e,t)=>({max:105+(t+1)*25,color:"red"}))];function Un(e){let t=Array.from({length:e},(o,l)=>{let s=Math.min(Math.ceil((l+1)*to.length/e)-1,to.length-1);return to[s]});return [{max:0,color:"gray"},...t]}var Ko=new Set(["event","snapshot","tool-call"]);function Uo(e,t){let o=new Map;o.set(t,[]);for(let l of e)try{let s=JSON.parse(l.details),n=String(s.exchangeId??""),f=!n||n===t?t:n;o.has(f)||o.set(f,[]),o.get(f).push(l);}catch{o.get(t).push(l);}return o}function Vo(e,t){let o=Uo(e,t);return e.length+(o.size>1?o.size:0)}function Xn({db:e}){let{exit:t}=useApp(),{stdout:o}=useStdout(),l=o?.columns??80,s=o?.rows??24,[n,f]=useState("capabilities"),[m,g]=useState([]),u=m.at(-1)??"root",[x,T]=useState([]),[i,h]=useState({totalRoutes:0,totalExchanges:0,completedExchanges:0,failedExchanges:0,droppedExchanges:0,errorRate:0,avgDurationMs:null,p90DurationMs:null,p95DurationMs:null,p99DurationMs:null}),[p,y]=useState([]),[H,F]=useState(void 0),D=we(),[ie,U]=useState([]),v=we(),[j,rt]=useState(void 0),[Bt,oo]=useState([]),[no,ro]=useState([]),pe=we(),me=we(),[xt,so]=useState(void 0),[_t,st]=useState(0),[Xo,Wo]=useState(null),[ge,lo]=useState([]),J=we(),[je,io]=useState(void 0),[qo,ao]=useState(null),[zo,co]=useState(new Map),[pt,uo]=useState([]),Te=we(),[Pt,lt]=useState(""),[$t,gt]=useState(false),[Ne,z]=useState(false),[Oe,mo]=useState([]),X=we(),[fo,Tt]=useState([]),Y=we(),[Le,bt]=useState(void 0),be=50,Yo=10,W=useCallback(r=>{g(a=>[...a,r]),st(0);},[]),yt=useCallback(()=>{g(r=>r.slice(0,-1)),st(0);},[]),Xe=Math.max(Math.min(Math.floor(l*.18),26),16),We=Math.max(Math.min(Math.floor(l*.22),30),20),ae=Math.max(l-Xe-We,30),O=Math.max(s-4,10),ye=Math.max(O-10,3),Qo=Math.max(Math.min(O-19,5),1)*4,Et=Math.max(O-6-6,3),it=m.includes("exchange")?j?.id:void 0,ho=m.includes("exchange")?j?.correlationId:void 0,at=m.includes("agent-run")?je?.id:void 0,ct=u==="tool-call"?Le?.toolCallId:void 0,Gt=u==="tool-call"?Le?.toolName:void 0,Ht=ge[J.selectedIndex]?.key,Ft=ge[J.selectedIndex]?.source,xo=Oe[X.selectedIndex]?.name,Je=useCallback((r,a)=>{if(!r){U([]),co(new Map);return}let S=a!==void 0?e.getAgentRuns(r.key,r.source,a):e.getAgentRuns(r.key,r.source);U(S),co(e.getAgentRunInfos(S.map(N=>N.id)));},[e]),jt=useCallback(()=>{try{let r=e.getRouteSummary();T(r),h(e.getMetrics());let a=We-4;y(e.getLiveTrafficBuckets(a,5));let S=ae-4,N=r[D.selectedIndex];N&&F(e.getSingleRouteActivity(N.id,S,5));let L,B;m.length===0&&(n==="agents"?(L=e.getAgents(),lo(L)):n==="tools"&&(B=e.getTools(),mo(B)));let Be=m.at(-1);if(it){let d=e.getExchangeById(it);d&&rt(d);let $=e.getEventsByExchange(it,ho??"");if(oo($),Ne&&Be==="exchange"){let Ke=d?.error?2:0,ze=Math.max(O-9-Ke,3),he=Vo($,it);me.moveTo(he-1,he,ze);}}if(at){let d=e.getExchangeById(at);d&&io(d),ao(e.getAgentRunInfo(at));let $=e.getAgentRunToolCalls(at);if(uo($),Ne&&Be==="agent-run"&&Te.moveTo($.length-1,$.length,Et),ct){let Ke=$.find(ze=>ze.toolCallId===ct);Ke&&bt(Ke);}}else if(ct&&Gt){let d=e.getToolCalls(Gt).find($=>$.toolCallId===ct);d&&bt(d);}if(m.length>0&&!(Ne&&Be==="browse"))return;if(n==="capabilities"){let d=r[D.selectedIndex];d&&U(e.getExchangesByRoute(d.id,be));}else if(n==="agents"){let d=L?L[J.selectedIndex]:Ht&&Ft?{key:Ht,source:Ft}:void 0;Je(d,be);}else if(n==="tools"){let d=B?B[X.selectedIndex]?.name:xo;Tt(d?e.getToolCalls(d):[]);}else n==="exchanges"?U(e.getAllExchanges(be)):n==="errors"?U(e.getFailedExchanges(be)):n==="events"&&ro(e.getRecentEvents({limit:200}));}catch{}},[e,n,D.selectedIndex,J.selectedIndex,X.selectedIndex,We,ae,O,Et,m,Ne,Je,it,ho,at,ct,Gt,Ht,Ft,xo,me.moveTo,Te.moveTo]);useEffect(()=>{jt();let r=setInterval(jt,2e3);return ()=>{clearInterval(r);}},[jt]);let po=useCallback(r=>{D.moveTo(r,x.length,ye),v.reset();let a=x[r];a&&U(e.getExchangesByRoute(a.id,be));},[e,x,D,v,ye]),go=useCallback(r=>{J.moveTo(r,ge.length,ye),v.reset(),Je(ge[r],be);},[ge,J,v,ye,Je]),To=useCallback(r=>{X.moveTo(r,Oe.length,ye),Y.reset();let a=Oe[r];a&&Tt(e.getToolCalls(a.name));},[e,Oe,X,Y,ye]),Zo=useCallback(r=>{if(f(r),g([]),st(0),lt(""),gt(false),z(false),v.reset(),r==="agents"){J.reset();let a=e.getAgents();lo(a),Je(a[0],be);}else if(r==="tools"){X.reset(),Y.reset();let a=e.getTools();mo(a);let S=a[0];Tt(S?e.getToolCalls(S.name):[]);}else r==="exchanges"?U(e.getAllExchanges(be)):r==="errors"?U(e.getFailedExchanges(be)):r==="events"&&(pe.reset(),ro(e.getRecentEvents({limit:200})));},[e,v,pe,J,X,Y,Je]),ut=Pt.trim().toLowerCase(),Jt=(...r)=>ut===""||r.some(a=>a!==null&&a.toLowerCase().includes(ut)),Ee=ut?ie.filter(r=>Jt(r.id,r.routeId,r.status)):ie,dt=ut?fo.filter(r=>Jt(r.toolName,r.routeId,r.exchangeId,r.status)):fo,Rt=ut?no.filter(r=>Jt(r.eventName,r.details)):no,wt=useCallback(()=>{v.reset(),Y.reset(),pe.reset();},[v,Y,pe]),qe=x[D.selectedIndex],Ct=ge[J.selectedIndex],Kt=Oe[X.selectedIndex],en=Math.ceil((ft.length-1)/4),tn=qe?2+en+2:0,bo=Math.max(O-6-tn,3),yo=Math.max(O-6,5),vt=Math.max(O-6,3),mt=useCallback(r=>{rt(r),oo(e.getEventsByExchange(r.id,r.correlationId)),me.reset(),z(r.status==="started"),W("exchange");},[e,me,W]),Eo=useCallback(r=>{if(!r.exchangeId)return;let a=e.getExchangeById(r.exchangeId)??{id:r.exchangeId,routeId:r.routeId,contextId:"",correlationId:"",status:"started",startedAt:r.timestamp,completedAt:null,durationMs:null,error:null};mt(a);},[e,mt]);useInput((r,a)=>{if($t){a.return?gt(false):a.escape?(gt(false),lt(""),wt()):a.backspace||a.delete?(lt(d=>d.slice(0,-1)),wt()):r&&!a.ctrl&&!a.meta&&(lt(d=>d+r),wt());return}if(r==="q"){e.close(),t();return}let S=Xt.find(d=>d.shortcut===r);if(S){Zo(S.key);return}let N=a.ctrl?Yo:1,L=r==="j"||a.downArrow,B=r==="k"||a.upArrow,Be=a.escape||a.backspace||a.delete;if(u==="browse"){if(r==="/"){gt(true);return}if(r==="f"){z(d=>!d);return}if((L||B)&&Ne&&z(false),Be){yt(),lt(""),z(false),wt();return}}if(u!=="root"&&Ko.has(u)){if(r==="x"&&u==="tool-call"&&Le){Eo(Le);return}L?st(d=>d+N):B?st(d=>Math.max(d-N,0)):Be&&yt();return}if(u==="agent-run"){if(r==="f"){z(d=>!d);return}if(r==="x"&&je){mt(je);return}if((L||B)&&Ne&&z(false),L)Te.moveBy(N,pt.length,Et);else if(B)Te.moveBy(-N,pt.length,Et);else if(a.return){let d=pt[Te.selectedIndex];d&&(bt(d),W("tool-call"));}else Be&&(yt(),z(false),Te.reset());return}if(u==="exchange"){if(r==="f"){z(he=>!he);return}(L||B)&&Ne&&z(false);let d=j?.error?2:0,$=Math.max(O-9-d,3),Ke=j?.id??"",ze=Vo(Bt,Ke);if(L)me.moveBy(N,ze,$);else if(B)me.moveBy(-N,ze,$);else if(a.return){let he=0,Vt,Ro=Uo(Bt,Ke),nn=Ro.size>1;for(let[,rn]of Ro){nn&&he++;for(let sn of rn)he===me.selectedIndex&&(Vt=sn),he++;}Vt&&(so(Vt),W("event"));}else if(r==="e"&&j){let he=e.getExchangeSnapshot(j.id);Wo(he),W("snapshot");}else Be&&(me.reset(),z(false),yt());return}if(n==="events"){if(u==="root"){a.return&&W("browse");return}if(L)pe.moveBy(N,Rt.length,yo);else if(B)pe.moveBy(-N,Rt.length,yo);else if(a.return){let d=Rt[pe.selectedIndex];d&&(so(d),W("event"));}return}if(n==="agents"){if(u==="root"){L?go(Math.min(J.selectedIndex+1,ge.length-1)):B?go(Math.max(J.selectedIndex-1,0)):a.return&&(W("browse"),Je(ge[J.selectedIndex]));return}if(L)v.moveBy(N,Ee.length,vt);else if(B)v.moveBy(-N,Ee.length,vt);else if(a.return){let d=Ee[v.selectedIndex];if(d){io(d);let $=e.getAgentRunInfo(d.id);ao($),uo(e.getAgentRunToolCalls(d.id)),Te.reset(),z(d.status==="started"||$?.status==="running"),W("agent-run");}}else if(r==="x"){let d=Ee[v.selectedIndex];d&&mt(d);}return}if(n==="tools"){if(u==="root"){if(L)To(Math.min(X.selectedIndex+1,Oe.length-1));else if(B)To(Math.max(X.selectedIndex-1,0));else if(a.return){W("browse");let d=Oe[X.selectedIndex];d&&Tt(e.getToolCalls(d.name));}return}if(L)Y.moveBy(N,dt.length,vt);else if(B)Y.moveBy(-N,dt.length,vt);else if(a.return){let d=dt[Y.selectedIndex];d&&(bt(d),W("tool-call"));}else if(r==="x"){let d=dt[Y.selectedIndex];d&&Eo(d);}return}if(u==="root"){if(n==="capabilities"){if(L)po(Math.min(D.selectedIndex+1,x.length-1));else if(B)po(Math.max(D.selectedIndex-1,0));else if(a.return){W("browse");let d=x[D.selectedIndex];d&&U(e.getExchangesByRoute(d.id));}}else a.return&&(W("browse"),U(n==="exchanges"?e.getAllExchanges():e.getFailedExchanges()));return}if(L)v.moveBy(N,Ee.length,bo);else if(B)v.moveBy(-N,Ee.length,bo);else if(a.return){let d=Ee[v.selectedIndex];d&&mt(d);}});let on=(n==="capabilities"||n==="agents"||n==="tools")&&u==="root",q=u==="browse",E=[];u!=="root"&&Ko.has(u)?(E.push({key:"j/k",action:"Scroll"}),E.push({key:"C-j/k",action:"Jump"}),u==="tool-call"&&E.push({key:"x",action:"Exchange"}),E.push({key:"Esc",action:"Back"})):u==="agent-run"?(E.push({key:"j/k",action:"Navigate"}),E.push({key:"Enter",action:"Tool I/O"}),E.push({key:"x",action:"Exchange"}),E.push({key:"f",action:"Follow"}),E.push({key:"Esc",action:"Back"})):u==="exchange"?(E.push({key:"j/k",action:"Navigate"}),E.push({key:"Enter",action:"Event"}),E.push({key:"e",action:"Snapshot"}),E.push({key:"f",action:"Follow"}),E.push({key:"Esc",action:"Back"})):q?(E.push({key:"j/k",action:"Navigate"}),E.push({key:"C-j/k",action:"Jump"}),E.push({key:"Enter",action:"Detail"}),(n==="agents"||n==="tools")&&E.push({key:"x",action:"Exchange"}),E.push({key:"/",action:"Filter"}),E.push({key:"f",action:"Follow"}),E.push({key:"Esc",action:"Back"})):(E.push({key:"j/k",action:"Navigate"}),n==="capabilities"?E.push({key:"Enter",action:"Exchanges"}):n==="agents"?E.push({key:"Enter",action:"Runs"}):n==="tools"?E.push({key:"Enter",action:"Calls"}):E.push({key:"Enter",action:"Browse"})),E.push({key:"1-6",action:"View"}),E.push({key:"q",action:"Quit"});let Q=[];{let r=Xt.find(a=>a.key===n)?.label??n;Q.push(r),m.length>0&&(n==="capabilities"&&qe?Q.push(qe.id):n==="agents"&&Ct?Q.push(Ct.key):n==="tools"&&Kt&&Q.push(Kt.name));for(let a of m)a==="exchange"&&j?Q.push(j.id.slice(0,8)):a==="agent-run"&&je?Q.push(`run ${je.id.slice(0,8)}`):a==="tool-call"&&Le?Q.push(Le.toolName):a==="event"&&xt?Q.push(xt.eventName):a==="snapshot"&&Q.push("snapshot");}let fe;return u==="event"&&xt?fe=jsx($o,{event:xt,width:ae,height:O,scrollOffset:_t}):u==="snapshot"&&j?fe=jsx(Go,{exchange:j,snapshot:Xo,width:ae,height:O,scrollOffset:_t}):u==="tool-call"&&Le?fe=jsx(Jo,{call:Le,width:ae,height:O,scrollOffset:_t}):u==="agent-run"&&je?fe=jsx(Fo,{agentKey:Ct?.key??"",run:je,info:qo,toolCalls:pt,selectedIndex:Te.selectedIndex,scrollOffset:Te.scrollOffset,width:ae,height:O}):u==="exchange"&&j?fe=jsx(_o,{exchange:j,events:Bt,width:ae,height:O,selectedIndex:me.selectedIndex,scrollOffset:me.scrollOffset,color:c.accent}):n==="events"?fe=jsx(Po,{events:Rt,selectedIndex:q?pe.selectedIndex:-1,scrollOffset:q?pe.scrollOffset:0,width:ae,height:O,color:q?c.accent:c.muted}):n==="agents"?fe=jsx(Ho,{agentKey:Ct?.key??"",runs:Ee,infos:zo,selectedIndex:q?v.selectedIndex:-1,scrollOffset:q?v.scrollOffset:0,width:ae,height:O,color:q?c.accent:c.muted}):n==="tools"?fe=jsx(jo,{toolName:Kt?.name??"",calls:dt,selectedIndex:q?Y.selectedIndex:-1,scrollOffset:q?Y.scrollOffset:0,width:ae,height:O,color:q?c.accent:c.muted}):fe=jsx(Lo,{capabilityId:n==="capabilities"?qe?.id??"":n==="exchanges"?"All Capabilities":"Failed Exchanges",...n==="capabilities"&&qe?{route:qe}:{},activity:n==="capabilities"?H:void 0,exchanges:Ee,selectedIndex:q?v.selectedIndex:-1,scrollOffset:q?v.scrollOffset:0,width:ae,height:O,color:q?c.accent:c.muted}),jsxs(Box,{flexDirection:"column",width:l,height:s,children:[jsxs(Box,{paddingX:1,width:l,children:[jsx(Text,{bold:true,children:"Routecraft"}),jsxs(Text,{dimColor:true,children:[" ","craft tui"," ","v",a]}),jsx(Box,{flexGrow:1,justifyContent:"flex-end",children:jsx(Text,{wrap:"truncate",children:Q.map((r,a)=>jsxs(Text,{children:[a>0&&jsx(Text,{dimColor:true,children:" \u203A "}),jsx(Text,{...a===Q.length-1&&Q.length>1?{color:c.accent}:{dimColor:true},children:r})]},`${r}-${a}`))})})]}),jsxs(Box,{flexDirection:"row",width:l,flexGrow:1,children:[jsx(Box,{flexDirection:"column",width:Xe,children:jsxs(w,{title:"NAVIGATION",color:on?c.accent:c.muted,width:Xe,flexGrow:1,children:[Ut.map((r,a)=>jsxs(Box,{flexDirection:"column",children:[a>0&&jsx(Text,{children:" "}),r.label&&jsx(Text,{dimColor:true,bold:true,children:r.label}),r.items.map(S=>jsxs(Text,{wrap:"truncate",children:[jsxs(Text,{..._(n===S.key),children:[n===S.key?"> ":" ",S.label]}),jsxs(Text,{dimColor:true,children:[" (",S.shortcut,")"]}),S.key==="errors"&&i.failedExchanges>0&&jsxs(Text,{color:c.error,children:[" ",ee(i.failedExchanges)]})]},S.key))]},r.label??a)),n==="capabilities"&&jsx(Lt,{items:x,itemKey:r=>r.id,label:r=>r.id,dotColor:Jn,emptyText:"No capabilities",selectedIndex:D.selectedIndex,listOffset:D.scrollOffset,visibleRows:ye,width:Xe-6}),n==="agents"&&jsx(Lt,{items:ge,itemKey:r=>r.key,label:r=>r.key,dotColor:Kn,emptyText:"No agents",selectedIndex:J.selectedIndex,listOffset:J.scrollOffset,visibleRows:ye,width:Xe-6}),n==="tools"&&jsx(Lt,{items:Oe,itemKey:r=>r.name,label:r=>r.name,dotColor:Vn,emptyText:"No tools",selectedIndex:X.selectedIndex,listOffset:X.scrollOffset,visibleRows:ye,width:Xe-6})]})}),fe,jsx(Box,{flexDirection:"column",width:We,children:jsxs(w,{title:"METRICS",width:We,flexGrow:1,children:[jsx(Dt,{values:p,columns:We-4,steps:Un(Qo),label:"Exchanges per 5s bucket"}),jsx(Text,{children:" "}),jsx(Text,{bold:true,dimColor:true,children:"THROUGHPUT"}),[["Exchanges",ee(i.totalExchanges),c.accent],["Completed",ee(i.completedExchanges),"green"],["Errors",ee(i.failedExchanges),i.failedExchanges>0?"red":"green"],["Dropped",ee(i.droppedExchanges),i.droppedExchanges>0?"yellow":"green"],["Error Rate",`${(i.errorRate*100).toFixed(1)}%`,i.errorRate>.1?"red":"green"],["Capabilities",ee(i.totalRoutes),""]].map(([r,a,S])=>jsxs(Box,{children:[jsx(Box,{flexGrow:1,children:jsxs(Text,{wrap:"truncate",children:[r,":"]})}),jsx(Text,{bold:true,...S?{color:S}:{},children:a})]},r)),jsx(Text,{children:" "}),jsx(Text,{bold:true,dimColor:true,children:"LATENCY (5m)"}),[["Avg",M(i.avgDurationMs),""],["p90",M(i.p90DurationMs),""],["p95",M(i.p95DurationMs),""],["p99",M(i.p99DurationMs),""]].map(([r,a,S])=>jsxs(Box,{children:[jsx(Box,{flexGrow:1,children:jsxs(Text,{wrap:"truncate",children:[r,":"]})}),jsx(Text,{bold:true,...S?{color:S}:{},children:a})]},r))]})})]}),jsx(Box,{paddingX:1,width:l,children:jsxs(Text,{wrap:"truncate",children:[($t||Pt!=="")&&jsxs(Text,{color:c.accent,children:["/",Pt,$t?"\u258F":""," "]}),Ne&&jsxs(Text,{color:c.success,children:["\u25CF follow"," "]}),E.map((r,a)=>jsxs(Text,{children:[a>0&&jsx(Text,{children:" "}),jsx(Text,{color:c.accentSoft,children:r.key}),jsxs(Text,{dimColor:true,children:[" ",r.action]})]},r.key))]})})]})}async function vl(e){let t;try{t=await a$1.open(e);}catch(l){let s=l instanceof Error?l.message:String(l);process.stderr.write(`Failed to open telemetry database: ${s}
4
4
  `),process.stderr.write(`Path: ${e}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routecraft/cli",
3
- "version": "0.7.2",
3
+ "version": "0.7.3-canary-20261004170320",
4
4
  "description": "CLI for running Routecraft capabilities",
5
5
  "private": false,
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@agentclientprotocol/sdk": "^1.4.0",
26
- "@routecraft/routecraft": "^0.7.2",
26
+ "@routecraft/routecraft": "0.7.3-canary-20261004170320",
27
27
  "commander": "^14.0.3",
28
28
  "dotenv": "^17.4.2",
29
29
  "ink": "^7.1.1",
@@ -1,2 +0,0 @@
1
- var s="0.7.2";export{s as a};//# sourceMappingURL=chunk-WCEUG34O.js.map
2
- //# sourceMappingURL=chunk-WCEUG34O.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../package.json"],"names":["version"],"mappings":"AAEE,IAAAA,CAAAA,CAAW","file":"chunk-WCEUG34O.js","sourcesContent":["{\n \"name\": \"@routecraft/cli\",\n \"version\": \"0.7.2\",\n \"description\": \"CLI for running Routecraft capabilities\",\n \"private\": false,\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/tui/app.tsx src/tui/db.ts --format esm --dts --external react --external ink --external bun:sqlite\",\n \"test\": \"vitest\",\n \"test:coverage\": \"vitest --coverage\",\n \"prepublishOnly\": \"bun run build\"\n },\n \"dependencies\": {\n \"@agentclientprotocol/sdk\": \"^1.4.0\",\n \"@routecraft/routecraft\": \"^0.7.2\",\n \"commander\": \"^14.0.3\",\n \"dotenv\": \"^17.4.2\",\n \"ink\": \"^7.1.1\",\n \"pino-pretty\": \"^13.1.3\",\n \"react\": \"^19.2.0\",\n \"yaml\": \"^2.9.1\"\n },\n \"devDependencies\": {\n \"@types/mailparser\": \"^3.4.6\",\n \"@types/react\": \"^19.2.18\",\n \"ink-testing-library\": \"^4.0.0\",\n \"jose\": \"^6.2.12\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": \"https://github.com/routecraftjs/routecraft\",\n \"bin\": {\n \"craft\": \"./dist/index.js\"\n },\n \"engines\": {\n \"bun\": \">=1.1.0\"\n },\n \"keywords\": [\n \"routecraft\",\n \"cli\",\n \"routes\",\n \"automation\",\n \"typescript\"\n ],\n \"author\": \"routecraftjs\",\n \"license\": \"Apache-2.0\",\n \"homepage\": \"https://routecraft.dev\"\n}\n"]}