@stackone/cli 1.36.0 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -8
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{cliCore-Ddbomdjz.cjs → cliCore-DpN3eM90.cjs} +48 -46
- package/dist/cliCore-f0Q3wfWi.mjs +173 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +118 -120
- package/dist/cliCore-DQtsHPaO.mjs +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./fileNames-DzZBY06N.mjs";import{C as t,S as n,T as r,_ as i,a,b as o,c as s,d as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,u as ee,v,w as y,x as b,y as x}from"./agentConfig-BWQWMYKQ.mjs";import{r as S,t as te}from"./setupMigration-C1ShGzOu.mjs";import{r as ne}from"./agentApiKey-CWXxJgCO.mjs";import{createRequire as C}from"node:module";import w from"chalk";import{Argument as T,Command as re}from"commander";import{BuildOrchestrator as E,checkCommandSafety as ie,createAgentSession as ae,createDefaultVisualizationRegistry as oe,createSkillTracker as se,executeAgent as ce,extractBuildIntent as le,getAvailableSkillNames as D,getBundledSkillsPath as O,getSkillsForMode as k,initAgentTelemetry as ue}from"@stackone/agent-harness";import*as A from"node:fs";import{existsSync as j,mkdirSync as de,readFileSync as fe,readdirSync as pe,writeFileSync as M}from"node:fs";import*as N from"node:os";import{homedir as me,platform as he}from"node:os";import*as P from"node:path";import{dirname as F,join as I}from"node:path";import{Box as L,Text as R,render as ge,useApp as _e,useInput as ve}from"ink";import z,{useCallback as ye,useEffect as B,useMemo as be,useRef as V,useState as H}from"react";import{exec as xe,execFile as Se,execSync as Ce}from"node:child_process";import we from"ink-spinner";import U,{readFileSync as Te,readdirSync as Ee,statSync as De,writeFileSync as Oe}from"fs";import W,{basename as G,dirname as ke,join as K,resolve as q}from"path";import J from"ora";import{access as Ae}from"node:fs/promises";import je from"inquirer";import{stdin as Me,stdout as Ne}from"node:process";import{createInterface as Pe}from"node:readline";import{isMissing as Y,isObject as Fe,notMissing as X,z as Z}from"@stackone/utils";import{cancel as Ie,confirm as Le,intro as Re,isCancel as ze,outro as Be,password as Ve,select as He,text as Ue}from"@clack/prompts";import{loadConnector as We,runAction as Ge,validateYamlConnector as Ke}from"@stackone/connect-sdk";import{diffLines as qe}from"diff";import{createInterface as Je}from"readline";import Ye from"semver";import{HttpClient as Xe}from"@stackone/transport";import{promisify as Ze}from"node:util";import{fileURLToPath as Qe}from"url";import{readdir as $e,stat as et}from"fs/promises";var tt=C(import.meta.url);const Q={primary:`#00AF66`,success:`green`,warning:`yellow`,error:`red`,text:`white`,dim:`gray`},nt={defaultTerminalWidth:80,boxWidth:44,maxToolNameWidth:64,maxInputSummaryWidth:60,maxSeparatorWidth:60,maxConversationTitleLength:36,maxExampleLength:38,maxCollapsedTools:5,maxToolOutputLines:15},rt=e=>{let t=e.replace(/^claude-/,``).replace(/-\d{8,}$/,``),n=t.match(/^(\w+)-(\d+)(?:-(\d+))?$/);if(n){let e=n[3]?`.${n[3]}`:``;return`${n[1]}-${n[2]}${e}`}return t||e},it={cellsPerFrame:3,pixelFrameMs:18,holdFrames:25,fadeSteps:5,fadeStepMs:80,timerIntervalMs:1e3};function at(e){return e.replace(/\*\*\*(.+?)\*\*\*/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/```([\s\S]*?)```/g,`$1`).replace(/`(.+?)`/g,`$1`).replace(/!\[([^\]]{0,500})\]\([^)]{1,2000}\)/g,`$1`).replace(/\[([^\]]{1,500})\]\([^)]{1,2000}\)/g,`$1`).replace(/^(?!_+$)[-*_]{3,}$/gm,``).replace(/^>\s+/gm,``).trim()}const ot=e=>{let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`},st=e=>{let t=(e.status===`complete`||e.status===`warning`||e.status===`error`)&&e.durationMs!=null?` ${ot(e.durationMs)}`:``,n=e.model?z.createElement(R,{dimColor:!0},` (`,rt(e.model),`)`):null;switch(e.status){case`complete`:return z.createElement(R,{color:`green`},e.name,n,` ✓`,t);case`warning`:return z.createElement(R,{color:`yellow`},e.name,n,` ⚠`,t);case`running`:return z.createElement(R,{color:`cyan`},e.name,n,` `,z.createElement(we,{type:`dots`}));case`error`:return z.createElement(R,{color:`red`},e.name,n,` ✗`,t);case`skipped`:return z.createElement(R,{dimColor:!0},e.name,` ⊘`);case`pending`:default:return z.createElement(R,{dimColor:!0},e.name,` ○`)}},ct=({phases:e})=>e.length===0?null:z.createElement(L,{marginBottom:1},z.createElement(R,{bold:!0},`Build: `),e.map((t,n)=>z.createElement(L,{key:t.name},z.createElement(R,null,`[`),st(t),z.createElement(R,null,`]`),n<e.length-1&&z.createElement(R,null,` `)))),lt=[`\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;14;147;94m▀\x1B[0m\x1B[38;2;8;125;77m\x1B[48;2;29;115;84m▀\x1B[0m\x1B[38;2;16;108;72m\x1B[48;2;23;128;88m▀\x1B[0m\x1B[38;2;14;112;73m\x1B[48;2;17;140;91m▀\x1B[0m\x1B[38;2;9;122;76m\x1B[48;2;11;152;95m▀\x1B[0m\x1B[38;2;4;132;79m\x1B[48;2;5;165;99m▀\x1B[0m\x1B[38;2;0;55;33m\x1B[48;2;0;69;41m▀\x1B[0m`,`\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;2;170;100m\x1B[48;2;11;153;95m▀\x1B[0m\x1B[38;2;34;106;81m\x1B[48;2;35;103;80m▀\x1B[0m\x1B[38;2;29;115;84m\x1B[48;2;29;115;84m▀\x1B[0m\x1B[38;2;23;127;88m\x1B[48;2;23;127;88m▀\x1B[0m\x1B[38;2;17;140;92m\x1B[48;2;17;140;92m▀\x1B[0m\x1B[38;2;11;152;95m\x1B[48;2;11;152;95m▀\x1B[0m\x1B[38;2;5;165;99m\x1B[48;2;5;165;99m▀\x1B[0m\x1B[38;2;0;69;41m\x1B[48;2;0;69;41m▀\x1B[0m`,`\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;1;125;74m\x1B[48;2;0;123;71m▀\x1B[0m \x1B[38;2;0;128;75m\x1B[48;2;0;123;71m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m`,`\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;123;71m\x1B[48;2;0;128;75m▀\x1B[0m \x1B[38;2;0;123;71m\x1B[48;2;1;125;74m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m`,` \x1B[38;2;0;69;41m\x1B[48;2;0;69;41m▀\x1B[0m\x1B[38;2;5;165;99m\x1B[48;2;5;165;99m▀\x1B[0m\x1B[38;2;11;152;95m\x1B[48;2;11;152;95m▀\x1B[0m\x1B[38;2;17;140;91m\x1B[48;2;17;140;91m▀\x1B[0m\x1B[38;2;23;127;88m\x1B[48;2;23;127;88m▀\x1B[0m\x1B[38;2;29;115;84m\x1B[48;2;29;115;84m▀\x1B[0m\x1B[38;2;35;102;80m\x1B[48;2;34;105;81m▀\x1B[0m\x1B[38;2;11;152;95m\x1B[48;2;3;169;100m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m`,` \x1B[38;2;0;69;40m\x1B[48;2;0;62;37m▀\x1B[0m\x1B[38;2;5;165;99m\x1B[48;2;5;148;89m▀\x1B[0m\x1B[38;2;11;152;95m\x1B[48;2;10;137;86m▀\x1B[0m\x1B[38;2;17;140;91m\x1B[48;2;15;126;82m▀\x1B[0m\x1B[38;2;23;127;88m\x1B[48;2;17;122;81m▀\x1B[0m\x1B[38;2;29;115;84m\x1B[48;2;9;139;86m▀\x1B[0m\x1B[38;2;16;143;92m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;158;92m▀\x1B[0m`].map(e=>{let t=[],n=0;for(;n<e.length;)if(e[n]===`\x1B`){let r=``;for(;n<e.length;)if(e[n]===`\x1B`){let t=e.indexOf(`m`,n);if(r+=e.substring(n,t+1),n=t+1,r.endsWith(`\x1B[0m`)&&/[▀▄█]/.test(r))break}else r+=e[n],n++;t.push(r)}else e[n]===` `&&t.push(null),n++;return t}),ut=[];for(let e=0;e<lt.length;e++)for(let t=0;t<lt[e].length;t++){let n=lt[e][t];n&&ut.push({row:e,col:t,cell:n})}const dt=Math.max(...lt.map(e=>e.length)),ft=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},pt=({ready:e,onComplete:t})=>{let[n,r]=H(0),i=V(ft(ut.map((e,t)=>t))),a=V(ft(ut.map((e,t)=>t))),o=V(!1),s=Math.ceil(ut.length/it.cellsPerFrame),c=s;B(()=>{let e=setInterval(()=>{r(e=>{let t=e+1;return t>=s+it.holdFrames+s+it.holdFrames?(i.current=ft(ut.map((e,t)=>t)),a.current=ft(ut.map((e,t)=>t)),0):t})},it.pixelFrameMs);return()=>clearInterval(e)},[s]),B(()=>{e&&n>=c&&!o.current&&(o.current=!0,t?.())},[e,n,c,t]);let l=new Set;if(n<s){let e=Math.min((n+1)*it.cellsPerFrame,ut.length);for(let t=0;t<e;t++)l.add(i.current[t])}else if(n<s+it.holdFrames)for(let e=0;e<ut.length;e++)l.add(e);else if(e)for(let e=0;e<ut.length;e++)l.add(e);else if(n<s*2+it.holdFrames){let e=n-s-it.holdFrames,t=Math.min((e+1)*it.cellsPerFrame,ut.length);for(let e=0;e<ut.length;e++)l.add(e);for(let e=0;e<t;e++)l.delete(a.current[e])}let u=new Map;for(let e of l){let t=ut[e];u.set(`${t.row},${t.col}`,t.cell)}let d=[];for(let e=0;e<lt.length;e++){let t=``;for(let n=0;n<dt;n++){let r=u.get(`${e},${n}`);t+=r??` `}d.push(t)}return z.createElement(R,null,d.join(`
|
|
2
|
-
`))},mt=(e,t)=>{if(t)return t;let n=nt.maxToolNameWidth;return(e.length>n?`${e.slice(0,n-1)}…`:e).padEnd(n)},ht=(e,t)=>{let n=e.split(`
|
|
3
|
-
`);return n.length<=t?{text:e,truncated:!1}:{text:n.slice(0,t).join(`
|
|
4
|
-
`),truncated:!0}},gt=({tools:e,expanded:t=!1,maxCollapsed:n=nt.maxCollapsedTools,title:r})=>{if(e.length===0)return null;let i=e.some(e=>e.status===`running`),a=r||(i?`Working...`:`Tools (${e.length})`),o=t?e:e.slice(0,n),s=e.length-o.length;return z.createElement(L,{flexDirection:`column`,borderStyle:`round`,borderColor:Q.primary,borderDimColor:!0,paddingX:1},z.createElement(R,{dimColor:!0,bold:!0},a),o.map((e,n)=>z.createElement(L,{key:`tool-${n}`,flexDirection:`column`},z.createElement(L,null,e.status===`running`?z.createElement(R,{color:Q.primary},z.createElement(we,{type:`dots`})):e.status===`failed`?z.createElement(R,{color:Q.error},`✗`):z.createElement(R,{color:Q.primary},`✓`),z.createElement(R,{bold:!0},` `,mt(e.name,e.skillName)),e.inputSummary&&z.createElement(R,{dimColor:!0,italic:!0},` `,e.inputSummary.length>nt.maxInputSummaryWidth?`${e.inputSummary.slice(0,nt.maxInputSummaryWidth-1)}…`:e.inputSummary)),t&&e.output&&z.createElement(L,{paddingLeft:2,flexDirection:`column`},(()=>{let{text:t,truncated:n}=ht(e.output,nt.maxToolOutputLines);return z.createElement(z.Fragment,null,z.createElement(R,{dimColor:!0,italic:!0,wrap:`wrap`},t),n&&z.createElement(R,{dimColor:!0,italic:!0},`... (truncated)`))})()))),s>0&&z.createElement(R,{dimColor:!0},`... and `,s,` more (Ctrl+O to show all)`))};let _t=``;try{let e=tt.resolve(`@stackone/agent-harness`),t=P.dirname(e);for(;t!==P.dirname(t);){let e=P.join(t,`package.json`);if(A.existsSync(e)){let t=JSON.parse(A.readFileSync(e,`utf-8`));if(t.name===`@stackone/agent-harness`){_t=t.version||``;break}}t=P.dirname(t)}}catch{}const vt=({startTime:e})=>{let[,t]=H(0);B(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]);let n=Date.now()-e.getTime(),r=Math.floor(n/1e3),i=r>=60?`${Math.floor(r/60)}m${r%60}s`:`${r}s`;return z.createElement(R,{dimColor:!0},i)},yt=({children:e})=>{let[t,n]=H(0);return B(()=>{if(t>=it.fadeSteps)return;let e=setTimeout(()=>n(e=>e+1),it.fadeStepMs);return()=>clearTimeout(e)},[t]),z.createElement(z.Fragment,null,e(Math.min(t/it.fadeSteps,1)))},bt=e=>{try{return Ce(process.platform===`darwin`?`pbcopy`:process.platform===`win32`?`clip`:`xclip -selection clipboard`,{input:e,stdio:[`pipe`,`ignore`,`ignore`]}),!0}catch{return!1}};function xt(e){return e===` `||e===` `||e===`
|
|
5
|
-
`||e===`\r`}function St(e,t){let n=t-1;for(;n>=0&&xt(e[n]);)n--;for(;n>=0&&!xt(e[n]);)n--;return n+1}function Ct(e,t){let n=t;for(;n<e.length&&xt(e[n]);)n++;for(;n<e.length&&!xt(e[n]);)n++;return n}function wt(e){return e.filter(e=>!(e.role===`system`&&e.content.startsWith(`TOOL_START:`)))}const Tt=e=>{let t=[],n={userMessage:null,toolMessages:[],assistantMessages:[],systemMessages:[]};for(let r of e)r.role===`user`?((n.userMessage||n.toolMessages.length>0||n.assistantMessages.length>0||n.systemMessages.length>0)&&t.push(n),n={userMessage:r,toolMessages:[],assistantMessages:[],systemMessages:[]}):r.role===`system`&&r.content.startsWith(`TOOL:`)?n.toolMessages.push(r):r.role===`assistant`?n.assistantMessages.push(r):n.systemMessages.push(r);return(n.userMessage||n.toolMessages.length>0||n.assistantMessages.length>0||n.systemMessages.length>0)&&t.push(n),t},Et=e=>{let t=e.split(`|||`);return{name:t[0].replace(`TOOL:`,``),inputSummary:t.length>=3&&t[1]||``,output:t.length>=3?t.slice(2).join(`|||`):t[1]||``}},Dt=({title:e,mode:t,connector:n,action:r,onSubmit:i,onExit:a,onStop:o,messages:s,currentToolCalls:c=[],isThinking:l=!1,isComplete:u=!1,error:d,isInterrupted:f=!1,commandHistory:p=[],streamingText:m=``,usage:h,detailViewData:g=null,onCloseDetailView:_,onResumeConversation:ee,onToggleTrust:v,onRewindTo:y,spawnedSubagentActive:b=!1,spawnedSubagentName:x=`Subagent`,spawnedSubagentComplete:S=!1,queuedMessages:te=[],isProcessingQueue:ne=!1,initInfo:C,pendingDeleteConfirmation:w=null,onConfirmDelete:T,slashCommands:re=[],welcomeContext:E,buildPhases:ie,currentBuildPhase:ae})=>{let{exit:oe}=_e(),[se,ce]=H(null),[le,D]=H(``),[,O]=H(0),k=V(0),[ue,A]=H(!0),j=V(s),[de,fe]=H(-1),pe=V(p),M=V(``),[N,me]=H([]),[he,P]=H(0),[F,I]=H(0),[ge,xe]=H(!1),[Se,Ce]=H(!1),[U,Te]=H(!1),[Ee,De]=H(!1),Oe=V(``),[W,G]=H(1),[ke,K]=H(null),[q,J]=H(1),Ae=be(()=>re.map(e=>`/${e.name}`),[re]);B(()=>{j.current=s},[s]),B(()=>{pe.current=p},[p]),B(()=>{le.startsWith(`/`)?(me(Ae.filter(e=>e.startsWith(le.toLowerCase()))),P(0)):(me([]),P(0))},[le]),B(()=>{if(g?.items){let e=Math.max(0,g.items.length-1);I(t=>Math.min(t,e))}},[g?.items?.length]),ve(ye((e,t)=>{let n=M.current,r=de;if(t.escape&&(l||m||c.length>0)&&!g){o?.(),D(``),M.current=``,k.current=0,O(0),fe(-1);return}if(t.escape&&b&&Se&&!g){Ce(!1);return}if(t.escape&&U&&!b&&!g){Te(!1);return}if(w&&T){if(t.escape||e.toLowerCase()===`n`){G(1),T(!1);return}if(e.toLowerCase()===`y`){G(0),T(!0);return}if(t.upArrow||t.downArrow){G(e=>e===0?1:0);return}if(t.return){T(W===0);return}return}if(g){if(ke){if(t.escape||t.ctrl&&e===`c`){K(null);return}if(t.leftArrow||t.rightArrow){J(e=>e===0?1:0);return}if(e.toLowerCase()===`y`){v&&v(ke.path),K(null);return}if(e.toLowerCase()===`n`){K(null);return}if(t.return){q===0&&v&&v(ke.path),K(null);return}return}if(t.escape||t.ctrl&&e===`c`)if(ge){xe(!1);return}else{_?.(),I(0);return}if(t.upArrow&&!ge){I(e=>e>0?e-1:g.items.length-1);return}if(t.downArrow&&!ge){I(e=>e<g.items.length-1?e+1:0);return}if(t.ctrl&&e===`o`&&g.type===`trust`&&!ke&&!ge){let e=g.items[F];e?.path&&(K({path:e.path,name:e.name}),J(1));return}if(t.return){if(ge)return;if(g.type===`resume`){let e=g.items[F];e.messages&&ee&&(ee(e.messages),_?.(),I(0));return}if(g.type===`rewind`){let e=g.items[F];e.index!==void 0&&y&&(y(e.index),_?.(),I(0));return}xe(!0);return}return}if(t.ctrl&&e===`o`){b?Ce(e=>!e):Te(e=>!e);return}if(t.ctrl&&e===`u`){D(``),M.current=``,k.current=0,O(0),fe(-1);return}if(t.ctrl&&e===`y`){let e=[...s].reverse().find(e=>e.role===`assistant`);e&&bt(e.content)&&(De(!0),setTimeout(()=>De(!1),2e3));return}if(t.ctrl&&e===`c`||e===``)if(n.trim()){D(``),M.current=``,k.current=0,O(0),fe(-1);return}else{a(),oe();return}if(t.shift&&t.return){let e=k.current,t=M.current,n=t.slice(0,e)+`
|
|
6
|
-
`+t.slice(e);M.current=n,D(n);let r=e+1;k.current=r,O(r);return}if(t.ctrl&&e===`a`){k.current=0,O(0);return}if(t.ctrl&&e===`e`){k.current=n.length,O(n.length);return}let u=e===`\x1Bb`||e===`b`&&t.meta||e===`\x1B\x1B[D`||e===`\x1B[1;3D`||e===`\x1B[1;9D`||t.meta&&t.leftArrow&&!t.ctrl&&!t.shift,d=e===`\x1Bf`||e===`f`&&t.meta||e===`\x1B\x1B[C`||e===`\x1B[1;3C`||e===`\x1B[1;9C`||t.meta&&t.rightArrow&&!t.ctrl&&!t.shift;if(u){let e=St(n,k.current);k.current=e,O(e);return}if(d){let e=Ct(n,k.current);k.current=e,O(e);return}if(t.home||e===`\x1B[H`||e===`\x1BOH`){k.current=0,O(0);return}if(t.end||e===`\x1B[F`||e===`\x1BOF`){k.current=n.length,O(n.length);return}if(process.platform===`darwin`&&t.meta&&t.leftArrow){k.current=0,O(0);return}if(process.platform===`darwin`&&t.meta&&t.rightArrow){k.current=n.length,O(n.length);return}if(process.platform===`darwin`&&t.meta&&t.upArrow){k.current=0,O(0);return}if(process.platform===`darwin`&&t.meta&&t.downArrow){k.current=n.length,O(n.length);return}if(t.ctrl&&t.leftArrow&&process.platform!==`darwin`){let e=St(n,k.current);k.current=e,O(e);return}if(t.ctrl&&t.rightArrow&&process.platform!==`darwin`){let e=Ct(n,k.current);k.current=e,O(e);return}let f=()=>{let e=process.stdout?.columns||80,t=Math.max(20,e-6),r=[],i=0;n.split(`
|
|
7
|
-
`).forEach((e,n)=>{let a=i,o=n===0?t-2:t;if(e.length===0)r.push({start:a,end:a});else{let n=0;for(;n<e.length;){let i=n===0?o:t;r.push({start:a+n,end:a+Math.min(n+i,e.length)}),n+=i}}i=a+e.length+1});let a=k.current,o=r.findIndex(e=>a>=e.start&&a<e.end);return o===-1&&r.length>0&&(o=r.findIndex(e=>a===e.end)),{rows:r,currentRow:Math.max(0,o)}};if(t.upArrow){if(N.length>0){P(e=>e>0?e-1:N.length-1);return}let e=pe.current;if(r>=0&&e.length>0){fe(t=>{let n=Math.max(0,t-1),r=e[n]||``;return D(r),M.current=r,k.current=r.length,O(r.length),n});return}let{rows:t,currentRow:n}=f();if(n>0){let e=k.current-t[n].start,r=t[n-1],i=r.start+Math.min(e,r.end-r.start);k.current=i,O(i);return}if(e.length>0){fe(t=>{let n=t<0?e.length-1:Math.max(0,t-1),r=e[n]||``;return D(r),M.current=r,k.current=r.length,O(r.length),n});return}return}if(t.downArrow){if(N.length>0){P(e=>e<N.length-1?e+1:0);return}let e=pe.current;if(r>=0&&e.length>0){fe(t=>{let n=t>=e.length-1?-1:t+1,r=n<0?``:e[n]||``;return D(r),M.current=r,k.current=r.length,O(r.length),n});return}let{rows:t,currentRow:n}=f();if(n<t.length-1){let e=k.current-t[n].start,r=t[n+1],i=r.start+Math.min(e,r.end-r.start);k.current=i,O(i);return}return}if(t.return){if(N.length>0){let e=N[he];me([]),P(0),D(``),M.current=``,k.current=0,O(0),Oe.current=e,i(e);return}if(n.trim()){let e=n.trim();Oe.current=e,i(e),D(``),M.current=``,k.current=0,O(0),fe(-1)}return}if((t.backspace||t.delete)&&k.current>0){let e=k.current,t=M.current,n=t.slice(0,e-1)+t.slice(e);M.current=n,D(n);let r=Math.max(0,e-1);k.current=r,O(r),fe(-1);return}if(t.leftArrow&&!t.meta&&!t.ctrl){let e=Math.max(0,k.current-1);k.current=e,O(e);return}if(t.rightArrow&&!t.meta&&!t.ctrl){let e=Math.min(n.length,k.current+1);k.current=e,O(e);return}if(t.tab&&n.startsWith(`/`)){let e=Ae.filter(e=>e.startsWith(n.toLowerCase()));if(e.length===1){let t=e[0].length;D(e[0]),M.current=e[0],k.current=t,O(t)}return}if(e){if(t.meta||t.ctrl||!e.split(``).every(e=>{let t=e.charCodeAt(0);return t>=32&&t!==127||t===10||t===9}))return;let n=k.current,r=M.current,i=r.slice(0,n)+e+r.slice(n);M.current=i,D(i);let a=n+e.length;k.current=a,O(a),fe(-1)}},[i,a,oe,de,Ae,N,he,g,ge,_,b,Se,ee,F,l,m,c,o,y,w,T,W,U,s])),B(()=>{u&&A(!1)},[u]);let je=l||m!==``||c.length>0;B(()=>{je&&!se?ce(new Date):!je&&se&&ce(null)},[je,se]);let Me=`\x1B[2m`,Ne=`\x1B[0m`,Pe=[`\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;140;82m\x1B[48;2;14;147;94m▀\x1B[0m\x1B[38;2;8;125;77m\x1B[48;2;29;115;84m▀\x1B[0m\x1B[38;2;16;108;72m\x1B[48;2;23;128;88m▀\x1B[0m\x1B[38;2;14;112;73m\x1B[48;2;17;140;91m▀\x1B[0m\x1B[38;2;9;122;76m\x1B[48;2;11;152;95m▀\x1B[0m\x1B[38;2;4;132;79m\x1B[48;2;5;165;99m▀\x1B[0m\x1B[38;2;0;55;33m\x1B[48;2;0;69;41m▀\x1B[0m ▄▖▗ ▌ ▄▖`,`\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;2;170;100m\x1B[48;2;11;153;95m▀\x1B[0m\x1B[38;2;34;106;81m\x1B[48;2;35;103;80m▀\x1B[0m\x1B[38;2;29;115;84m\x1B[48;2;29;115;84m▀\x1B[0m\x1B[38;2;23;127;88m\x1B[48;2;23;127;88m▀\x1B[0m\x1B[38;2;17;140;92m\x1B[48;2;17;140;92m▀\x1B[0m\x1B[38;2;11;152;95m\x1B[48;2;11;152;95m▀\x1B[0m\x1B[38;2;5;165;99m\x1B[48;2;5;165;99m▀\x1B[0m\x1B[38;2;0;69;41m\x1B[48;2;0;69;41m▀\x1B[0m ▚ ▜▘▀▌▛▘▙▘▌▌▛▌█▌`,`\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;1;125;74m\x1B[48;2;0;123;71m▀\x1B[0m \x1B[38;2;0;128;75m\x1B[48;2;0;123;71m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m ▄▌▐▖█▌▙▖▛▖▙▌▌▌▙▖`,`\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;123;71m\x1B[48;2;0;128;75m▀\x1B[0m \x1B[38;2;0;123;71m\x1B[48;2;1;125;74m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m\x1B[38;2;0;175;102m\x1B[48;2;0;175;102m▀\x1B[0m`,` \x1b[38;2;0;69;41m\x1b[48;2;0;69;41m▀\x1b[0m\x1b[38;2;5;165;99m\x1b[48;2;5;165;99m▀\x1b[0m\x1b[38;2;11;152;95m\x1b[48;2;11;152;95m▀\x1b[0m\x1b[38;2;17;140;91m\x1b[48;2;17;140;91m▀\x1b[0m\x1b[38;2;23;127;88m\x1b[48;2;23;127;88m▀\x1b[0m\x1b[38;2;29;115;84m\x1b[48;2;29;115;84m▀\x1b[0m\x1b[38;2;35;102;80m\x1b[48;2;34;105;81m▀\x1b[0m\x1b[38;2;11;152;95m\x1b[48;2;3;169;100m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;175;102m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;175;102m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;175;102m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;175;102m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;175;102m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;175;102m▀\x1b[0m ${Me}sessions monitored${Ne}`,` \x1b[38;2;0;69;40m\x1b[48;2;0;62;37m▀\x1b[0m\x1b[38;2;5;165;99m\x1b[48;2;5;148;89m▀\x1b[0m\x1b[38;2;11;152;95m\x1b[48;2;10;137;86m▀\x1b[0m\x1b[38;2;17;140;91m\x1b[48;2;15;126;82m▀\x1b[0m\x1b[38;2;23;127;88m\x1b[48;2;17;122;81m▀\x1b[0m\x1b[38;2;29;115;84m\x1b[48;2;9;139;86m▀\x1b[0m\x1b[38;2;16;143;92m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m\x1b[38;2;0;175;102m\x1b[48;2;0;158;92m▀\x1b[0m ${Me}preview${_t?` v${_t}`:``}${Ne}`].join(`
|
|
8
|
-
`),Y=wt(s),Fe=be(()=>Tt(Y),[Y]),X=!!C,Z=be(()=>{let e=[`${t.charAt(0).toUpperCase()+t.slice(1)} mode`];if(E?.credentialEmail){let t=E.credentialTimeRemaining?` (${E.credentialTimeRemaining.days}d ${E.credentialTimeRemaining.hours}h)`:``;e.push(`${E.credentialEmail}${t}`)}C&&C.mcpServers.length>0&&e.push(`${C.mcpServers.reduce((e,t)=>e+t.count,0)} tools`),C&&C.claudeSkills.count>0&&e.push(`${C.claudeSkills.count} skills`);let r=[{text:`✓ ${e.join(` · `)}`,color:Q.primary}],i=n||E?.detectedConnector;if(i&&r.push({text:`📂 Detected connector: ${i}`}),C)for(let e of C.errors)r.push({text:`⚠ ${e}`,color:`yellow`});return r},[C,E,t,n]),Ie=be(()=>{let e=[],t=E?.recentConversations;if(t&&t.length>0){e.push({text:`Recent sessions:`});for(let n of t){let t=n.trim(),r=t.length>36?`${t.slice(0,35)}…`:t;e.push({text:` "${r}"`})}e.push({text:``}),e.push({text:`/resume to continue`})}return e},[n,E]),Le=be(()=>{let e=n||E?.detectedConnector,r={build:[e?`"Add a new action to ${e}"`:`"Add a new action to Slack"`,e?`"Show current actions for ${e}"`:`"Show actions for Datadog"`,`"Create a connector for a new provider"`,`"Validate and fix connector issues"`,`"Add OAuth authentication support"`,`"Map response fields to StackOne schema"`,`"Add pagination to the list endpoint"`,`"Generate test credentials for sandbox"`,`"Add rate limiting configuration"`,`"Improve descriptions for all actions"`],test:[e?`"Test all actions for ${e}"`:`"Test all actions for Slack"`,`"Run a specific action and show response"`,`"Debug why list_users is returning errors"`,`"Test with a different account"`,`"Compare response against StackOne schema"`,`"Test pagination across all list actions"`,`"Validate error handling for 401 responses"`,`"Run actions with verbose output"`,`"Test the OAuth flow end to end"`,`"Check rate limiting behavior"`],research:[e?`"${e} API endpoints?"`:`"Workday API endpoints?"`,`"Compare pagination for Greenhouse vs Lever"`,`"Auth methods for this provider?"`,`"What versioning strategy does the API use?"`,`"Find the rate limits documentation"`,`"What webhook events are available?"`,`"How does the provider handle deleted records?"`,`"What scopes are needed for user data?"`,`"Does the API support filtering or search?"`,`"What date format does the API use?"`]},i=[...r[t]||r.build];for(let e=i.length-1;e>0;e--){let t=Math.floor(Math.random()*(e+1));[i[e],i[t]]=[i[t],i[e]]}let a=i.slice(0,3),o=[{text:`Try:`}];for(let e of a){let t=e.length>38?`${e.slice(0,36)}…"`:e;o.push({text:` ${t}`})}return o},[t,n]),[Re,ze]=H(!1),Be=ye(()=>ze(!0),[]),Ve=X&&Re,He=ye((e,t)=>{if(!e||t>=1)return e;let n=e.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(!n)return e;let r=Math.round(Number.parseInt(n[1],16)*t),i=Math.round(Number.parseInt(n[2],16)*t),a=Math.round(Number.parseInt(n[3],16)*t);return`#${r.toString(16).padStart(2,`0`)}${i.toString(16).padStart(2,`0`)}${a.toString(16).padStart(2,`0`)}`},[]);return z.createElement(L,{flexDirection:`column`,padding:1},!Ve&&z.createElement(pt,{ready:!!X,onComplete:Be}),Ve&&z.createElement(L,{flexDirection:`row`,marginBottom:1},z.createElement(L,{flexDirection:`column`,flexShrink:0},z.createElement(R,null,Pe)),z.createElement(L,{flexDirection:`column`,marginLeft:3,marginTop:1},z.createElement(yt,null,e=>z.createElement(z.Fragment,null,Z.map((t,n)=>z.createElement(R,{key:`hero-${n}`,color:He(t.color,e),dimColor:!t.color},t.text)),z.createElement(L,{flexDirection:`row`,marginTop:1},Ie.length>0&&z.createElement(L,{flexDirection:`column`,marginRight:2,borderStyle:`round`,borderColor:Q.primary,borderDimColor:!0,paddingX:1,width:44},Ie.map((e,t)=>z.createElement(R,{key:`ctx-${t}`,dimColor:!0},e.text))),z.createElement(L,{flexDirection:`column`,borderStyle:`round`,borderColor:Q.primary,borderDimColor:!0,paddingX:1,width:44},Le.map((e,t)=>z.createElement(R,{key:`ex-${t}`,dimColor:!0},e.text)))))))),z.createElement(L,{flexDirection:`column`,marginBottom:1},Fe.map((e,t)=>{let n=process.stdout?.columns||80,r=Math.max(0,Math.min(n-4,60)),i=[...e.assistantMessages,...e.toolMessages,...e.systemMessages],a=i.length>0?i.reduce((e,t)=>t.timestamp>e.timestamp?t:e):null,o=e.userMessage&&a?a.timestamp.getTime()-e.userMessage.timestamp.getTime():0,s=o>0?o>=6e4?`${Math.floor(o/6e4)}m${Math.round(o%6e4/1e3)}s`:`${Math.round(o/1e3)}s`:``,c=e.toolMessages.map(e=>{let t=Et(e.content);return{name:t.name,inputSummary:t.inputSummary,output:t.output,status:`completed`}});return z.createElement(L,{key:`turn-${t}`,flexDirection:`column`},t>0&&z.createElement(L,{marginBottom:1},z.createElement(R,{dimColor:!0},`─`.repeat(r))),e.userMessage&&z.createElement(L,{marginBottom:1,flexDirection:`column`},z.createElement(R,{bold:!0,color:`white`},`❯ You`,z.createElement(R,{color:`gray`},` `,`• `,e.userMessage.timestamp.toLocaleTimeString())),z.createElement(L,{paddingLeft:2},z.createElement(R,{color:`white`,wrap:`wrap`},e.userMessage.content))),(c.length>0||e.assistantMessages.length>0)&&z.createElement(L,{flexDirection:`column`,marginBottom:1},z.createElement(R,{bold:!0,color:Q.primary},`◆ StackOne Agent`),c.length>0&&z.createElement(L,{paddingLeft:2,marginTop:0,marginBottom:1},z.createElement(gt,{tools:c,expanded:U})),e.assistantMessages.map((n,r)=>{let i=r===e.assistantMessages.length-1;return z.createElement(L,{key:`asst-${t}-${r}`,paddingLeft:2,flexDirection:`column`,marginBottom:i?0:1},n.isSubagent&&z.createElement(R,{color:Q.primary,dimColor:!0},`⚡ Subagent`),z.createElement(R,{wrap:`wrap`,dimColor:!i},at(n.content)))}),s&&z.createElement(L,{paddingLeft:2,marginTop:1},z.createElement(R,{dimColor:!0},`✓ `,s))),e.systemMessages.map((e,n)=>z.createElement(L,{key:`sys-${t}-${n}`,marginBottom:1},z.createElement(R,{color:`gray`},`ℹ System • `,e.timestamp.toLocaleTimeString()),z.createElement(L,{paddingLeft:2},z.createElement(R,{dimColor:!0,wrap:`wrap`},e.content)))))})),z.createElement(L,{flexDirection:`column`,marginBottom:1},z.createElement(z.Fragment,null,(b||S)&&z.createElement(L,{marginBottom:0,marginTop:0,borderStyle:`single`,borderColor:Q.primary,paddingX:2,paddingY:1,flexDirection:`column`,height:Se?`100%`:void 0},z.createElement(R,{bold:!0,color:Q.primary},S?`✓`:`⚡`,` Subprocess:`,` `,x,` `,S?`(Complete)`:``,` `,Se?`(Expanded)`:``),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},S?Se?`Press Ctrl+O or ESC to collapse`:`Press Ctrl+O to expand`:Se?`Running... Press Ctrl+O or ESC to collapse`:`Running... Press Ctrl+O to expand`)),Se?z.createElement(z.Fragment,null,s.filter(e=>e.isSubagent&&!e.content.startsWith(`TOOL_START:`)).map((e,t)=>{let n=e.role===`system`&&e.content.startsWith(`TOOL:`),r=e.role===`assistant`?`⚡ Subagent`:`ℹ System`,i=e.content;if(n){let t=Et(e.content);r=`🔧 Tool • ${t.name}`,i=t.output.slice(0,500),t.output.length>500&&(i+=`
|
|
9
|
-
... (truncated)`)}return z.createElement(L,{key:`${e.timestamp.getTime()}-${t}-${e.role}-subagent`,marginTop:1,flexDirection:`column`},z.createElement(R,{bold:!0,color:Q.primary},r,z.createElement(R,{color:`gray`},` `,`•`,` `,e.timestamp.toLocaleTimeString())),z.createElement(L,{paddingLeft:2},z.createElement(R,{color:n?`gray`:Q.primary,dimColor:n,wrap:`wrap`},at(i))))}),!S&&!f&&l&&c.length===0&&z.createElement(L,{marginTop:1},z.createElement(R,{color:Q.primary},z.createElement(we,{type:`dots`})),z.createElement(R,{dimColor:!0},` Thinking...`)),!S&&!f&&c.length>0&&z.createElement(L,{flexDirection:`column`,marginTop:1},c.map((e,t)=>z.createElement(L,{key:t,marginBottom:1},e.status===`running`&&z.createElement(R,{color:Q.primary},z.createElement(we,{type:`dots`})),z.createElement(R,{color:Q.primary},` `,e.skillName?z.createElement(z.Fragment,null,`✨ Skill •`,` `,e.skillName):z.createElement(z.Fragment,null,`🔧 `,e.name),e.status===`running`&&`...`,e.status===`completed`&&` ✓`)))),!S&&m&&!f&&z.createElement(L,{marginTop:1},z.createElement(R,{color:Q.primary},at(m)))):z.createElement(z.Fragment,null,s.filter(e=>e.isSubagent&&!e.content.startsWith(`TOOL_START:`)&&e.role!==`system`||e.content.startsWith(`TOOL:`)).slice(-2).map((e,t)=>{let n=e.role===`system`&&e.content.startsWith(`TOOL:`),r=e.content;if(n){let t=Et(e.content);r=`🔧 ${t.name}: ${t.output.slice(0,100)}${t.output.length>100?`...`:``}`}let i=r.split(`
|
|
10
|
-
`).slice(0,2).join(`
|
|
11
|
-
`);return z.createElement(L,{key:t,marginTop:1},z.createElement(R,{color:Q.primary,dimColor:n},at(i),r.split(`
|
|
12
|
-
`).length>2&&`...`))}),!S&&!f&&l&&c.length===0&&z.createElement(L,{marginTop:1},z.createElement(R,{color:Q.primary},z.createElement(we,{type:`dots`})),z.createElement(R,{dimColor:!0},` Thinking...`)),!S&&!f&&c.length>0&&z.createElement(L,{flexDirection:`column`,marginTop:1},c.slice(-2).map((e,t)=>z.createElement(L,{key:t,marginBottom:1},e.status===`running`&&z.createElement(R,{color:Q.primary},z.createElement(we,{type:`dots`})),z.createElement(R,{color:Q.primary},` `,e.skillName?z.createElement(z.Fragment,null,`✨ Skill •`,` `,e.skillName):z.createElement(z.Fragment,null,`🔧 `,e.name),e.status===`running`&&`...`,e.status===`completed`&&` ✓`))),c.length>2&&z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`... and`,` `,c.length-2,` `,`more (Ctrl+O to expand)`))),!S&&m&&z.createElement(L,{marginTop:1},z.createElement(R,{color:Q.primary},at(m).split(`
|
|
13
|
-
`).slice(0,2).join(`
|
|
14
|
-
`),at(m).split(`
|
|
15
|
-
`).length>2&&`
|
|
16
|
-
...`))))),m&&!b&&!f&&z.createElement(L,{marginBottom:1,flexDirection:`column`},z.createElement(R,{bold:!0,color:Q.primary},`◆ StackOne Agent`,z.createElement(R,{color:`gray`},` • `,new Date().toLocaleTimeString())),z.createElement(L,{paddingLeft:2},z.createElement(R,{wrap:`wrap`},at(m)))),!b&&!f&&c.length>0&&z.createElement(L,{marginBottom:1,paddingLeft:2},z.createElement(gt,{tools:c.map(e=>({name:e.name,inputSummary:e.inputSummary||``,output:``,status:e.status===`failed`?`failed`:e.status,skillName:e.skillName}))}))),ie&&ie.length>0&&z.createElement(ct,{phases:ie,currentPhase:ae}),!b&&!f&&l&&c.length===0&&z.createElement(L,{marginBottom:1},z.createElement(R,{color:Q.primary},z.createElement(we,{type:`dots`})),z.createElement(R,{dimColor:!0},` Thinking...`),se&&z.createElement(R,{dimColor:!0},` `,z.createElement(vt,{startTime:se}))),f&&z.createElement(L,{marginTop:1},z.createElement(R,{color:`red`},`⏺ Interrupted · What should the StackOne Agent do instead?`)),d&&z.createElement(L,{marginBottom:1,borderStyle:`single`,borderColor:`red`,paddingX:2,paddingY:1,flexDirection:`column`},z.createElement(R,{color:`red`},`✗ `,d),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`Press Enter to try again or Ctrl+C to exit`))),u&&z.createElement(L,{marginBottom:1,borderStyle:`single`,borderColor:Q.primary,paddingX:2},z.createElement(R,{color:Q.primary},`✓ Complete`)),g&&z.createElement(L,{marginBottom:1,borderStyle:`single`,borderColor:Q.primary,paddingX:2,paddingY:1,flexDirection:`column`},ge?z.createElement(z.Fragment,null,z.createElement(R,{bold:!0,color:Q.primary},g.items[F].name),g.type!==`trust`&&z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},g.items[F].description)),g.type===`skills`&&z.createElement(L,{flexDirection:`column`},g.items[F].version?z.createElement(R,{dimColor:!0},`Version:`,` `,String(g.items[F].version)):null,g.items[F].author?z.createElement(R,{dimColor:!0},`Author:`,` `,String(g.items[F].author)):null,g.items[F].tags&&Array.isArray(g.items[F].tags)?z.createElement(R,{dimColor:!0},`Tags:`,` `,g.items[F].tags.join(`, `)):null,g.items[F].content?z.createElement(L,{marginTop:1,flexDirection:`column`},z.createElement(R,{bold:!0},`Skill Content:`),z.createElement(L,{marginTop:1},z.createElement(R,{wrap:`wrap`},String(g.items[F].content).slice(0,2e3),String(g.items[F].content).length>2e3?`
|
|
17
|
-
|
|
18
|
-
... (content truncated)`:``))):z.createElement(R,{dimColor:!0},`No content available`)),g.type===`tools`&&z.createElement(L,{flexDirection:`column`},z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`Category:`,` `,String(g.items[F].category))),z.createElement(L,{marginTop:1},z.createElement(R,{bold:!0},`Input Parameters:`)),g.items[F].inputSchema?z.createElement(L,{marginTop:1,paddingLeft:2,flexDirection:`column`},(()=>{let e=g.items[F].inputSchema,t=e.properties||{},n=e.required||[];return Object.entries(t).map(([e,t])=>z.createElement(L,{key:e,flexDirection:`column`,marginBottom:1},z.createElement(R,null,e,n.includes(e)?` *`:``,z.createElement(R,{dimColor:!0},` `,`(`,t.type?String(t.type):`any`,`)`)),t.description?z.createElement(L,{paddingLeft:2},z.createElement(R,{dimColor:!0},String(t.description))):null))})(),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`* = required parameter`))):z.createElement(L,{marginTop:1,paddingLeft:2},z.createElement(R,{dimColor:!0},`No parameters`)),z.createElement(L,{marginTop:1},z.createElement(R,{bold:!0},`Output:`)),z.createElement(L,{marginTop:1,paddingLeft:2},z.createElement(R,{dimColor:!0},`Returns JSON with tool execution results`))),g.type===`trust`&&z.createElement(L,{flexDirection:`column`,marginTop:1},z.createElement(R,null,z.createElement(R,{dimColor:!0},`Path: `),z.createElement(R,null,String(g.items[F].path))),z.createElement(R,null,z.createElement(R,{dimColor:!0},`Trusted at: `),z.createElement(R,null,g.items[F].trustedAt?new Date(g.items[F].trustedAt).toLocaleString():`N/A`))),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`Press Esc to go back`))):ke?z.createElement(z.Fragment,null,z.createElement(R,{bold:!0,color:`yellow`},`⚠️ Remove Trust`),z.createElement(L,{flexDirection:`column`,marginTop:1},z.createElement(R,{color:`white`},`Are you sure you want to remove trust from:`),z.createElement(R,{color:`cyan`,bold:!0},ke.path)),z.createElement(L,{flexDirection:`column`,marginTop:1},z.createElement(R,{color:`yellow`},`⚠️ This action is permanent. To trust this folder again,`),z.createElement(R,{color:`yellow`},`you must open a new chat session in that directory.`)),z.createElement(L,{marginTop:1},z.createElement(R,{color:q===0?`green`:`gray`,bold:q===0},q===0?`❯ [Y]es`:` Yes`),z.createElement(R,null,` `),z.createElement(R,{color:q===1?`green`:`gray`,bold:q===1},q===1?`❯ [N]o`:` No`)),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`←→ to select • Enter to confirm • Esc to cancel`))):z.createElement(z.Fragment,null,z.createElement(R,{bold:!0,color:Q.primary},g.type===`skills`?`📚 Skills (${g.items.length})`:g.type===`tools`?`🔧 Tools (${g.items.length})`:g.type===`mcp`?`📡 MCP Servers (${g.items.filter(e=>e.connected).length}/${g.items.length} connected)`:g.type===`trust`?`📁 Trusted Folders (${g.items.length})`:g.type===`rewind`?`⏮️ Command History (${g.items.length})`:`💬 Recent Conversations (${g.items.length})`),z.createElement(L,{flexDirection:`column`,marginTop:1},g.items.map((e,t)=>{let n=t===F?`❯ `:` `,r=process.stdout.columns||80,i=Math.min(r-10,120),a=(e.name||``).replace(/\n/g,` ⏎ `),o=``;if(g.type===`mcp`?o=e.connected?`● `:`○ `:g.type===`trust`&&(o=e.trusted?`● `:`○ `),g.type===`skills`)return z.createElement(R,{key:t,color:t===F?Q.primary:`gray`},n,a);let s=e.tokens?` (~${e.tokens.toLocaleString()} tokens)`:``,c=i-(n.length+o.length+a.length+s.length)-5,l=``;if(e.description&&c>10){let t=String(e.description).replace(/\n/g,` ⏎ `);l=t.length>c?` - ${t.slice(0,c)}...`:` - ${t}`}let u=`${n}${o}${a}${s}${l}`,d=u.slice(0,i);return z.createElement(R,{key:t,color:t===F?Q.primary:`gray`},d,u.length>i?`...`:``)})),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},g.type===`skills`?`↑↓ Navigate • Enter for details • Esc to close`:g.type===`trust`?`↑↓ Navigate • Ctrl+O to remove trust • Enter for details • Esc to close`:g.type===`resume`?`↑↓ Navigate • Enter to resume • Esc to close`:g.type===`rewind`?`↑↓ Navigate • Enter to rewind to • Esc to close`:`↑↓ Navigate • Enter for details • Esc to close`)))),te.length>0&&z.createElement(L,{flexDirection:`column`,marginBottom:1},te.map((e,t)=>z.createElement(L,{key:t,marginBottom:t<te.length-1?1:0},z.createElement(R,{dimColor:!0},`📬 `),z.createElement(R,null,e.content))),ne&&z.createElement(R,{dimColor:!0,italic:!0},`Processing...`)),w&&z.createElement(L,{marginBottom:1},z.createElement(R,{color:`yellow`},`Delete `),z.createElement(R,{color:`red`},w.isDirectory&&w.directoryContents?`${w.files.map(e=>e.split(`/`).pop()).join(`, `)}/ (${w.directoryContents.length} files)`:w.files.map(e=>e.split(`/`).pop()).join(`, `)),z.createElement(R,{color:`yellow`},`? `),z.createElement(R,{color:W===0?`green`:`gray`},W===0?`[Y]es`:`y`),z.createElement(R,null,`/`),z.createElement(R,{color:W===1?`green`:`gray`},W===1?`[N]o`:`n`)),ue&&!u&&!g&&!w&&z.createElement(z.Fragment,null,z.createElement(L,{borderStyle:`round`,borderColor:Q.primary,borderDimColor:!0,paddingX:2,flexDirection:`column`},(()=>{let e=process.stdout.columns||80,t=Math.max(20,e-6),n=M.current.split(`
|
|
19
|
-
`),r=k.current,i=0,a=[];return n.forEach((e,o)=>{let s=i,c=s+e.length;i=c+1;let l=o===0,u=l?t-2:t,d=[];if(e.length===0)d.push(``);else{let n=e,r=!0;for(;n.length>0;){let e=r?u:t;d.push(n.slice(0,e)),n=n.slice(e),r=!1}}let f=0;d.forEach((e,t)=>{let i=s+f,u=i+e.length,p=l&&t===0,m=r>=i&&r<u,h=r===c&&o<n.length-1&&t===d.length-1,g=r===u&&t===d.length-1&&o===n.length-1,_=`${o}-${t}`;if(m||h||g){let t=r-i,n=e.slice(0,t),o=h?` `:e.charAt(t)||` `,s=h?``:e.slice(t+1);a.push(z.createElement(L,{key:_},p&&z.createElement(R,{color:Q.primary},`❯ `),z.createElement(R,{color:`white`},n),z.createElement(R,{backgroundColor:`white`,color:`black`,bold:!0},o),z.createElement(R,{color:`white`},s)))}else a.push(z.createElement(L,{key:_},p&&z.createElement(R,{color:Q.primary},`❯ `),z.createElement(R,{color:`white`},e||` `)));f+=e.length})}),a})()),N.length>0&&z.createElement(L,{marginTop:1,paddingLeft:2,flexDirection:`column`},N.map((e,t)=>z.createElement(L,{key:e},z.createElement(R,{color:t===he?Q.primary:`gray`},t===he?`❯ `:` `,e))))),h&&(()=>{let e=100-(h.input_tokens+h.output_tokens)/1e6*100,t=e>50?`green`:e>20?`yellow`:`red`,n=e<10;return z.createElement(L,{marginTop:1,flexDirection:`column`},z.createElement(R,{dimColor:!0},`📊 Model: Sonnet 4.5 • 🧠 Context left:`,` `,z.createElement(R,{color:t},e.toFixed(1),`%`)),n&&z.createElement(R,{color:`red`},`⚠️ Context low (`,e.toFixed(1),`% remaining)`))})(),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},ue?`Type message and press Enter • Shift+Enter for new line • `:``,(l||m||c.length>0)&&`ESC to stop • `,Ee?`Copied to clipboard! • `:`Ctrl+Y to copy last response • `,b?`Ctrl+O to expand subprocess • `:`Ctrl+O to show/hide full tool results • `,`Ctrl+C to clear/exit`)))},Ot=({timeRemaining:e,onRunSetup:t,onIgnore:n})=>{let{exit:r}=_e(),[i,a]=H(0);ve((e,o)=>{if(e===`1`){t(),r();return}if(e===`2`){n(),r();return}o.upArrow?a(0):o.downArrow?a(1):o.return?i===0?(t(),r()):(n(),r()):o.escape&&(n(),r())});let o=`\x1B[38;2;0;175;102m`,{hours:s,minutes:c}=e,l=s>0?`${s} hour${s===1?``:`s`} and ${c} minute${c===1?``:`s`}`:`${c} minute${c===1?``:`s`}`;return z.createElement(L,{flexDirection:`column`,padding:2},z.createElement(L,{borderStyle:`round`,borderColor:`yellow`,flexDirection:`column`,paddingX:2,paddingY:1},z.createElement(R,{bold:!0,color:`yellow`},`⚠️ Credential Warning`),z.createElement(R,null),z.createElement(R,null,`Your StackOne credentials expire in `,l,` (last day of 7-day validity).`),z.createElement(R,null),z.createElement(R,null,"To avoid interruption, run `stackone agent setup` to reauthenticate."),z.createElement(R,null),z.createElement(R,{color:i===0?o:`white`},i===0?`❯ `:` `,`1. Run stackone agent setup`),z.createElement(R,{color:i===1?o:`white`},i===1?`❯ `:` `,`2. Ignore and continue`)),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`↑↓ to navigate • Enter to confirm • Esc to continue`)))},kt=({directory:e,onConfirm:t,onCancel:n})=>{let{exit:r}=_e(),[i,a]=H(0);ve((e,o)=>{o.upArrow?a(0):o.downArrow?a(1):o.return?i===0?(t(),r()):(n(),r()):o.escape&&(n(),r())});let o=`\x1B[38;2;0;175;102m`;return z.createElement(L,{flexDirection:`column`,padding:2},z.createElement(L,{borderStyle:`round`,borderColor:`#00AF66`,flexDirection:`column`,paddingX:2,paddingY:1},z.createElement(R,{bold:!0},`Do you trust the files in this folder?`),z.createElement(R,null),z.createElement(R,{dimColor:!0},e),z.createElement(R,null),z.createElement(R,null,`StackOne Agent may read, write, or execute files contained in this directory.`),z.createElement(R,null,`This can pose security risks, so only use files and commands from trusted sources.`),z.createElement(R,null),z.createElement(R,{color:i===0?o:`white`},i===0?`❯ `:` `,`1. Yes, proceed`),z.createElement(R,{color:i===1?o:`white`},i===1?`❯ `:` `,`2. No, exit`)),z.createElement(L,{marginTop:1},z.createElement(R,{dimColor:!0},`↑↓ to navigate • Enter to confirm • Esc to exit`)))},At=`claude-sonnet-4-6`;async function*jt(e){let{provider:t,category:n,apiKey:r,mcpServers:i,verbose:a,workDir:o=`./connectors/${t}`,abortSignal:s}=e,c=new E({provider:t,category:n,workDir:o,baseOptions:{mode:`build`,model:At,apiKey:r,mcpServers:i,verbose:a,origin:`cli`,abortSignal:s,mcpCache:{enabled:!0},contextPreservation:{enabled:!0,provider:t,workDir:o}}});for await(let e of c.run())yield e}const Mt=()=>{try{let e=I(F(C(import.meta.url).resolve(`@stackone/agent-harness`)),`mcp-servers`),t=pe(e).filter(e=>e.endsWith(`.json`)),n=[];for(let r of t){let t=fe(I(e,r),`utf-8`),i=JSON.parse(t);for(let[e,t]of Object.entries(i.mcpServers)){let r=`stdio`;if(t.type)r=t.type;else if(t.transport?.type){let n=t.transport.type;if(n!==`http`&&n!==`stdio`&&n!==`sse`){y.warn(`⚠️ Skipping MCP server "${e}": Invalid transport type "${n}". Must be "http", "stdio", or "sse"`);continue}r=n===`sse`?`http`:n}else t.url&&(r=`http`);let i={},a=t.transport?.headers||t.headers;if(a)for(let[t,n]of Object.entries(a))i[t]=n.replace(/\$\{([^}]+)\}/g,(n,r)=>{let i=process.env[r];return i===void 0?(y.warn(`[MCP] Warning: Environment variable '${r}' referenced in header '${t}' for server '${e}' is not set. Substituting empty string.`),``):i});if(t.auth?.type===`bearer`&&(i.Authorization=`Bearer ${t.auth.token.replace(/\$\{([^}]+)\}/g,(t,n)=>{let r=process.env[n];return r===void 0?(y.warn(`[MCP] Warning: Environment variable '${n}' for auth token in server '${e}' is not set`),``):r})}`),r===`http`&&!t.url){y.warn(`⚠️ Skipping MCP server "${e}": HTTP transport requires a URL`);continue}if(r===`stdio`){y.debug(`Skipping MCP server "${e}": stdio transport is not supported for bundled servers`);continue}n.push({name:e,transport:r,url:t?.url??``,headers:i})}}return n}catch(e){if(e.code===`ENOENT`)return y.log(`[MCP] No bundled MCP server configurations found in agent-harness package`),[];throw e}},Nt=(e,t)=>{try{if(t.existed&&t.content!==null){let n=P.dirname(e);return A.existsSync(n)||A.mkdirSync(n,{recursive:!0}),A.writeFileSync(e,t.content,`utf-8`),{success:!0,action:`restored`}}else return A.existsSync(e)?(A.unlinkSync(e),{success:!0,action:`deleted`}):{success:!0,action:`restored`}}catch(e){return{success:!1,action:`error`,error:e instanceof Error?e.message:String(e)}}},Pt=/<![^>]*>[\s\S]*<\/HTML>/gi,Ft=/API Error:\s*\d{3}.*?(?=API Error:|$)/gi,It=e=>e.replace(Pt,``).replace(Ft,``).trim(),Lt=e=>{let t=/<TITLE>([^<]*)<\/TITLE>/i.exec(e),n=/<H1>\s*(\d{3}[^<]*)<\/H1>/i.exec(e);if(t||n)return`HTTP ${n?.[1]?.trim()||``} from ${/cloudfront/i.test(e)?`CloudFront`:/nginx/i.test(e)?`Nginx`:`upstream`}`.trim();let r=/API Error:\s*\d{3}.*?(?=API Error:|$)/i.exec(e);return r?r[0].trim():/Failed to authenticate/i.test(e)?`Authentication failed`:null},Rt=(e,t,n)=>{let r=[...new Set(e)],i=t.length,a=n.length,o=[];i>0?o.push(`Build failed — ${i}/${a} phases errored\n`):o.push(`Build failed
|
|
20
|
-
`);for(let e of r)o.push(` ${e}`);let s=r.join(` `);return/400|Bad Request/i.test(s)?o.push(`
|
|
21
|
-
This usually means the model is not supported or the request was malformed.`,`Check that your STACKONE_AGENT_TOKEN is valid and the model is available.`):/401|Unauthorized|403|Forbidden/i.test(s)?o.push(`
|
|
22
|
-
Your API key may be invalid or expired.`,`Check your STACKONE_AGENT_TOKEN configuration.`):/429|rate limit/i.test(s)?o.push(`
|
|
23
|
-
Rate limit hit. Wait a moment and try again.`):/5\d{2}|Internal Server Error|Service Unavailable/i.test(s)&&o.push(`
|
|
24
|
-
The API is experiencing issues. Try again shortly.`),o.join(`
|
|
25
|
-
`)},zt=[{name:`commands`,description:`Show all available commands`,argumentHint:``,source:`cli`},{name:`skills`,description:`View and toggle skills (max 8)`,argumentHint:``,source:`cli`},{name:`tools`,description:`View available tools`,argumentHint:``,source:`cli`},{name:`mcp`,description:`List configured MCP servers`,argumentHint:``,source:`cli`},{name:`trust`,description:`View and manage trusted folders`,argumentHint:``,source:`cli`},{name:`compact`,description:`Summarize conversation to free up context`,argumentHint:``,source:`cli`},{name:`exit`,description:`Exit the agent (or use Ctrl+C)`,argumentHint:``,source:`cli`}],Bt=new Set([`heapdump`]);function Vt(e,t){let n=new Map(t.map(e=>[e.name,e]));for(let t of e)!n.has(t.name)&&!Bt.has(t.name)&&n.set(t.name,{...t,source:`harness`});return Array.from(n.values())}const Ht=({mode:e,connector:t,action:n,goal:r,verbose:i,temperature:a,apiKey:o})=>{let[s,l]=H([]),d=V([]);d.current=s;let[f,p]=H(new Map),[m,h]=H(!1),[g,_]=H(),[ee,v]=H(!1),[b,x]=H(!0),[S,te]=H([]),[ne,C]=H([]),[w,T]=H(``),[re]=H(),[E,k]=H(!1),[ue,j]=H(null),de=V(oe()),fe=V(se()),[pe]=H(new Date),[M,me]=H(0),[he,F]=H(!1),I=V(!1),[L,R]=H(``),[ge,_e]=H(!1),[ve,xe]=H([]),[Se,Ce]=H(!1),[we,U]=H(!1),Te=V(!1),[Ee,De]=H(),[Oe,W]=H(),G=V({shouldStop:!1,requestId:0,controller:null}),[ke,K]=H([]),q=V(null),[J,Ae]=H([]),je=V(null),Me=V([]),Ne=V(0),[Pe,Y]=H({claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]}),[Fe,X]=H(zt),Z=V(new Map),Ie=V(-1),[Le,Re]=H(null),ze=V(null),Be=V({operation:``,phase:`idle`}),Ve=(e,t=!1)=>{let n=Be.current,r=e;n.operation&&(r=`${r}\n\nContext: ${n.operation}`);let i={idle:`Agent was idle`,thinking:`Agent was processing your request`,tool_execution:n.toolName?`Agent was executing tool: ${n.toolName}`:`Agent was executing a tool`,streaming:`Agent was generating a response`};if(n.phase!==`idle`&&(r=`${r}\nPhase: ${i[n.phase]}`),t&&n.toolName&&n.toolInput)try{let e=typeof n.toolInput==`string`?n.toolInput:JSON.stringify(n.toolInput,null,2),t=e.length>500?e.slice(0,500)+`...`:e;r=`${r}\nTool input: ${t}`}catch{}return r},He=be(()=>{let e={};try{let t=c();t?.email&&(e.credentialEmail=t.email);let n=u(t);n.status===`valid`&&(e.credentialTimeRemaining=n.timeRemaining)}catch{}if(!t)try{let t=process.cwd(),n=A.readdirSync(t).find(e=>e.endsWith(`.connector.s1.yaml`));if(n)e.detectedConnector=n.replace(`.connector.s1.yaml`,``);else{let n=P.join(t,`src`,`configs`);if(A.existsSync(n)&&A.statSync(n).isDirectory()){let t=A.readdirSync(n);if(t.length===1){let r=P.join(n,t[0],`${t[0]}.connector.s1.yaml`);A.existsSync(r)&&(e.detectedConnector=t[0])}}}}catch{}try{let t=P.join(N.homedir(),`.stackone`,`conversations`);if(A.existsSync(t)){let n=A.readdirSync(t).filter(e=>e.endsWith(`.json`)).sort().reverse(),r=[];for(let e of n.slice(0,3)){let t=e.match(/^\d+-(.+)\.json$/);t&&r.push(t[1].replace(/-/g,` `))}r.length>0&&(e.recentConversations=r)}}catch{}return e},[t]);B(()=>{let e=P.join(N.homedir(),`.stackone`,`agent_history`);try{if(A.existsSync(e)){let t=A.readFileSync(e,`utf-8`),n;try{let e=JSON.parse(t);n=Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()):t.split(`
|
|
26
|
-
`).filter(e=>e.trim())}catch{n=t.split(`
|
|
27
|
-
`).filter(e=>e.trim())}C(n)}}catch(e){i&&y.error(`[History] Failed to load command history:`,e)}},[i]);let Ue=V([]);B(()=>{(async()=>{let t={claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]};try{try{let e=D(),n=O();te(e.map(e=>{let t=P.join(n,e,`SKILL.md`),r,i;try{if(A.existsSync(t)){let e=A.readFileSync(t,`utf-8`);i=e;let n=e.match(/^---\n([\s\S]*?)\n---/);if(n){let e=n[1].match(/description:\s*\|?\s*\n?([\s\S]*?)(?=\n\w+:|$)/);e&&(r=e[1].trim().split(`
|
|
28
|
-
`)[0].trim())}}}catch{}return{name:e,description:r,content:i}})),t.claudeSkills={count:e.length,names:e,totalSize:0}}catch(e){y.error(`[Skills] Failed to load skills:`,e),t.errors.push(`Failed to load skills`)}try{let e=Mt();Ue.current=e;for(let n of e)t.mcpServers.push({name:n.name,count:0});let n=`fetch.extract_html_text.web_search.vector_search.get_external_integrations.analyze_external_integration.analyze_external_integrations.get_external_repos.scan_external_repo.search_external_repo.get_provider_coverage.get_providers.map_provider_key.get_stackone_actions.meta_feedback.get_stackone_categories.get_docs.get_stackone_expressions.extract_oas_actions.get_provider_actions.scramble_credentials.improve_descriptions.discover_actions.get_improve_descriptions_task_status.get_discover_actions_task_status.test_actions.get_test_actions_task_status.analyze_versioning.get_analyze_versioning_task_status.falcon_workflow.falcon_research.falcon_build.falcon_oauth.falcon_test.falcon_security`.split(`.`);t.mcpServers.push({name:`stackone`,count:n.length}),t.toolCounts.mcpByServer.stackone=n}catch(e){t.errors.push(`MCP: ${e instanceof Error?e.message:String(e)}`)}t.toolCounts.builtin=[`Read`,`Write`,`Edit`,`Glob`,`Grep`,`Bash`,`WebSearch`,`WebFetch`],t.toolCounts.total=t.toolCounts.builtin.length;try{X(Vt(await(await ae({prompt:``,mode:e,apiKey:o})).supportedCommands(),zt))}catch(e){i&&y.warn(`[Commands] Failed to fetch harness commands:`,e)}Y(t)}catch(e){y.error(`[Init] Failed to initialize runtime:`,e)}finally{x(!1)}})()},[o,e,i]),B(()=>{Te.current=we},[we]),B(()=>{if(re&&!E){let e=re.input_tokens+re.output_tokens,t=(1e6-e)/1e6*100;if(t<10){let n={role:`system`,content:`⚠️ Context Warning\n\nYou have ${t.toFixed(1)}% context remaining (${(1e6-e).toLocaleString()} tokens).\n\nConsider using /compact to summarize the conversation and free up context.`,timestamp:new Date};l(e=>[...e,n]),k(!0)}}},[re,E]);let We=ye(async r=>{try{let i=d.current,a=i.filter(e=>e.role===`user`||e.role===`assistant`);if(a.length<2)return;let o=r.trim().slice(0,50)||a.find(e=>e.role===`user`)?.content?.slice(0,50)||`conversation`;await A.promises.mkdir(P.join(N.homedir(),`.stackone`,`conversations`),{recursive:!0});let s=Date.now(),c=`${s}-${o.replace(/[^a-zA-Z0-9]/g,`-`).toLowerCase().slice(0,50)}.json`,l=P.join(N.homedir(),`.stackone`,`conversations`,c);await A.promises.writeFile(l,JSON.stringify({title:o,timestamp:s,goal:r,messages:i.filter(e=>e.role!==`system`),mode:e,connector:t,action:n},null,2))}catch(e){y.error(`Failed to save conversation:`,e)}},[e,t,n]),Ge=async(e,t,n,r)=>{let a=[`research`,`discover-actions`,`build-and-validate`];De(a.map(e=>({name:e,status:`pending`})));let s=new Map,c=P.join(N.homedir(),`.stackone`),u=P.join(c,`build-debug.log`);A.existsSync(c)||A.mkdirSync(c,{recursive:!0});let d=A.createWriteStream(u,{flags:`w`}),f=e=>{d.write(`${JSON.stringify({ts:new Date().toISOString(),...e})}\n`)};d.on(`error`,()=>{f=()=>{}}),f({event:`build_start`,provider:e,category:t,model:At,mcpServerCount:Ue.current.length});let m=console.log,g=console.error;console.log=(...e)=>{f({event:`console_log`,args:e.map(String)})},console.error=(...e)=>{f({event:`console_error`,args:e.map(String)})};try{for await(let c of jt({provider:e,category:t,apiKey:o,mcpServers:Ue.current,verbose:i||!1,abortSignal:r})){if(!n())return;if(c.type===`agent_message`){let e=c.message;f({event:`agent_message`,phase:c.phase,msgType:e.type,...e.type===`text`&&{content:e.content},...e.type===`error`&&{error:e.error},...e.type===`tool_call`&&{toolName:e.toolName}})}else f({...c,timestamp:void 0});switch(c.type){case`phase_start`:W(c.phase),De(e=>(e||[]).map(e=>e.name===c.phase?{...e,status:`running`,model:c.model}:e));break;case`phase_complete`:{let e=c.result.warnings&&c.result.warnings.length>0,t=s.get(c.phase),n=t&&t.length>0,r=!c.result.success||n,i=r?`error`:e?`warning`:`complete`;De(e=>(e||[]).map(e=>e.name===c.phase?{...e,status:i,durationMs:c.result.durationMs}:e)),r?_(Rt(t&&t.length>0?t:[c.result.error||`Unknown error`],[c.phase],a)):e&&l(e=>[...e,{role:`system`,content:`⚠️ Phase "${c.phase}" completed with warnings:\n${c.result.warnings?.join(`
|
|
29
|
-
`)}`,timestamp:new Date}]);break}case`phase_error`:De(e=>(e||[]).map(e=>e.name===c.phase?{...e,status:`error`,durationMs:c.result?.durationMs}:e)),_(Rt([c.error||`Unknown error`],[c.phase],a));break;case`phase_skipped`:De(e=>(e||[]).map(e=>e.name===c.phase?{...e,status:`skipped`}:e));break;case`agent_message`:{let e=c.message;if(e.type===`text`){let t=e.content??``,n=Lt(t);if(n){let e=s.get(c.phase)??[];e.includes(n)||e.push(n),s.set(c.phase,e)}let r=It(t);T(e=>e+(r||``))}else if(e.type===`tool_call`){let t=`tc-${++Ne.current}`;Me.current.push(t),T(e=>(e&&l(t=>[...t,{role:`assistant`,content:e,timestamp:new Date}]),``)),p(n=>{let r=new Map(n);return r.set(t,{name:e.toolName??``,status:`running`}),r})}else if(e.type===`tool_result`){let e=Me.current.shift();e&&p(t=>{let n=new Map(t);return n.delete(e),n})}else e.type===`error`&&_(e.error??`Unknown error`);break}}}if(T(e=>{if(e){let t=Lt(e);if(t){let e=s.get(`_unattributed`)??[];e.includes(t)||e.push(t),s.set(`_unattributed`,e)}let n=It(e);n&&l(e=>[...e,{role:`assistant`,content:n,timestamp:new Date}])}return``}),s.size>0){let e=[...new Set([...s.values()].flat())],t=[...s.keys()].filter(e=>e!==`_unattributed`);De(e=>(e||[]).map(e=>s.has(e.name)&&e.status===`complete`?{...e,status:`error`}:e)),_(Rt(e,t,a))}W(void 0)}catch(e){let t=e instanceof Error?e.message:String(e);f({event:`build_error`,error:t}),_(t)}finally{f({event:`build_end`,phaseErrors:Object.fromEntries(s)}),console.log=m,console.error=g,d.end(),De(e=>(e||[]).map(e=>e.status===`pending`||e.status===`running`?{...e,status:`skipped`}:e)),h(!1),U(!1),Te.current=!1,p(new Map)}},Ke=ye(async(r,a=!1)=>{if((b||Te.current)&&!a){xe(e=>[...e,{content:r,timestamp:new Date}]),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{Je()},3e4);return}if(_(void 0),v(!1),r===`/skills`){if(S.length===0){let e={role:`system`,content:`📚 No skills loaded. Skills will be loaded on startup.`,timestamp:new Date};l(t=>[...t,e]);return}j({type:`skills`,items:S.map(e=>({name:e.name,description:e.description,content:e.content}))});return}if(r===`/tools`){let e=[];for(let t of Pe.mcpServers){let n=Pe.toolCounts.mcpByServer[t.name]||[];for(let r of n)e.push({name:r,description:`MCP tool (${t.name})`,category:`MCP:${t.name}`})}let t=[...Pe.toolCounts.builtin.map(e=>({name:e,description:`Built-in (from agent harness)`,category:`Built-in`})),...e,...Pe.mcpServers.filter(e=>!Pe.toolCounts.mcpByServer[e.name]?.length).map(e=>({name:e.name,description:e.name===`stackone`?`MCP server (${e.count} tools) - from agent harness`:`MCP server (${e.count} tools)`,category:`MCP`}))];j({type:`tools`,items:t.length>0?t:[{name:`—`,description:`Tools provided by harness (built-in + skills + MCP)`,category:``}]});return}if(r===`/commands`){let e=`📋 Available Commands:
|
|
30
|
-
|
|
31
|
-
`;for(let t of Fe){let n=t.argumentHint?` ${t.argumentHint}`:``;e+=` /${t.name}${n} - ${t.description}\n`}let t={role:`system`,content:e,timestamp:new Date};l(e=>[...e,t]);return}if(r===`/exit`&&process.exit(0),r===`/instructions`){let r=[`📜 Active Instructions
|
|
32
|
-
`];if(S.length>0){r.push(`Skills Loaded (${S.length}):`);for(let e of S)r.push(` • ${e.name}${e.description?` - ${e.description}`:``}`);r.push(``)}r.push(`Session Context:`),r.push(` • Mode: ${e}`),t&&r.push(` • Connector: ${t}`),n&&r.push(` • Action: ${n}`),r.push(` • Turn Count: ${M}`),r.push(``);let i={instructions:`Mode: ${e}\nSkills: ${S.map(e=>e.name).join(`, `)||`none`}\nConnector: ${t||`none`}`,skills:S.map(e=>({name:e.name,description:e.description,enabled:!0})),session:{id:`current`,startedAt:pe,mode:e,turnCount:M}},a=de.current.render(`instructions`,i);a?.content&&r.push(a.content);let o={role:`system`,content:r.join(`
|
|
33
|
-
`),timestamp:new Date};l(e=>[...e,o]);return}if(r===`/safety`){let e=`🛡️ Safety Rules
|
|
34
|
-
|
|
35
|
-
`;e+=`Command execution is protected by safety checks implemented in the agent harness.
|
|
36
|
-
`,e+=`These checks may block or require confirmation for potentially dangerous operations,
|
|
37
|
-
`,e+=`such as destructive filesystem commands or writing directly to devices.
|
|
38
|
-
|
|
39
|
-
`,e+=`The exact safety rules and heuristics are maintained by the runtime and may change over time.
|
|
40
|
-
`;try{ie(`ls -la`),e+=`
|
|
41
|
-
✓ Safety hook is active and working`}catch{e+=`
|
|
42
|
-
⚠ Safety hook check failed`}let t={role:`system`,content:e,timestamp:new Date};l(e=>[...e,t]);return}if(r===`/mcp`){if(Pe.mcpServers.length===0){let e={role:`system`,content:`📡 No MCP servers configured`,timestamp:new Date};l(t=>[...t,e]);return}j({type:`mcp`,items:Pe.mcpServers.map(e=>{let t=Pe.toolCounts.mcpByServer[e.name]||[];return{name:e.name,description:`${t.length} tools`,tools:t,connected:t.length>0}})});return}if(r===`/trust`){let{getTrustedFoldersForDisplay:e}=await import(`./trustedFolders-6UfkywNe.mjs`),t=e();if(t.length===0){let e={role:`system`,content:`📁 No trusted folders found.
|
|
43
|
-
|
|
44
|
-
Folders are automatically trusted when you open a chat session in them.`,timestamp:new Date};l(t=>[...t,e]);return}j({type:`trust`,items:t.map(e=>({name:e.name,description:e.path,path:e.path,trusted:e.trusted,trustedAt:e.trustedAt}))});return}if(r===`/rewind`){try{let e=P.join(N.homedir(),`.stackone`,`agent_history`);if(!A.existsSync(e)){let e={role:`system`,content:`⏮️ No command history found.`,timestamp:new Date};l(t=>[...t,e]);return}let t=A.readFileSync(e,`utf-8`).split(`
|
|
45
|
-
`).filter(e=>e.trim());if(t.length===0){let e={role:`system`,content:`⏮️ Command history is empty.`,timestamp:new Date};l(t=>[...t,e]);return}j({type:`rewind`,items:t.reverse().slice(0,10).map((e,n)=>({name:e,description:`${t.length-n} messages ago`,index:t.length-n-1}))})}catch(e){let t={role:`system`,content:`❌ Error loading history: ${e instanceof Error?e.message:String(e)}`,timestamp:new Date};l(e=>[...e,t])}return}if(r===`/resume`){try{let e=P.join(N.homedir(),`.stackone`,`conversations`);if(!A.existsSync(e)){let e={role:`system`,content:`▶️ No conversation history found. Start a new conversation first!`,timestamp:new Date};l(t=>[...t,e]);return}let t=A.readdirSync(e).filter(e=>e.endsWith(`.json`)).sort((e,t)=>{let n=parseInt(e.split(`-`)[0])||0;return(parseInt(t.split(`-`)[0])||0)-n}).slice(0,10);if(t.length===0){let e={role:`system`,content:`▶️ No conversations found.`,timestamp:new Date};l(t=>[...t,e]);return}let n=t.map(t=>{try{let n=A.readFileSync(P.join(e,t),`utf-8`),r=JSON.parse(n);return{file:t,title:r.title||`Untitled conversation`,timestamp:r.timestamp,messages:r.messages,goal:r.goal}}catch{return null}}).filter(Boolean);if(n.length===0){let e={role:`system`,content:`▶️ No valid conversations found.`,timestamp:new Date};l(t=>[...t,e]);return}j({type:`resume`,items:n.map(e=>({name:e?.title,description:new Date(e?.timestamp).toLocaleString(),goal:e?.goal,file:e?.file,messages:e?.messages}))})}catch(e){let t={role:`system`,content:`❌ Error loading conversations: ${e instanceof Error?e.message:String(e)}`,timestamp:new Date};l(e=>[...e,t])}return}let c=Fe.map(e=>`/${e.name}`),u=r.split(` `)[0];if(r.startsWith(`/`)&&u!==`/`&&!c.includes(u)){let e={role:`system`,content:`❌ Unknown command: ${r}\n\nType /commands to see available commands.`,timestamp:new Date};l(t=>[...t,e]);return}if(r===`/compact`){let e={role:`user`,content:r,timestamp:new Date};l(t=>[...t,e]),h(!0);try{let e=s.filter(e=>e.role===`user`||e.role===`assistant`).map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`).join(`
|
|
46
|
-
|
|
47
|
-
`),t=e.length>2e3?e.slice(0,2e3)+`
|
|
48
|
-
|
|
49
|
-
[... truncated for context]`:e;h(!1);let n={role:`system`,content:`🗜️ Compact mode activated - recent context:\n\n${t}`,timestamp:new Date};l(e=>[e[e.length-1],n])}catch(e){h(!1),_(e instanceof Error?e.message:`Failed to summarize conversation`)}return}C(e=>{let t=r.trim();if(!t)return e;let n=[...e,t],a=n.length-1;Ie.current=a,Z.current.has(a)||Z.current.set(a,{commandIndex:a,command:t,timestamp:Date.now(),files:new Map});let o=P.join(N.homedir(),`.stackone`,`agent_history`);try{let e=P.dirname(o);A.existsSync(e)||A.mkdirSync(e,{recursive:!0});let t=n.slice(-1e3);A.writeFileSync(o,JSON.stringify(t),`utf-8`)}catch(e){i&&y.error(`[History] Failed to save command history:`,e)}return n});let d={role:`user`,content:r,timestamp:new Date};l(e=>[...e,d]),h(!0),U(!0),me(e=>e+1),G.current.requestId+=1,G.current.shouldStop=!1,G.current.controller=new AbortController;let f=G.current.requestId,m=G.current.controller.signal;je.current&&=(clearTimeout(je.current),null),Ae([]);let g=()=>!G.current.shouldStop&&G.current.requestId===f;try{let a=s.filter(e=>(e.role===`user`||e.role===`assistant`)&&!e.isSubagent).map(e=>({role:e.role,content:e.content})).slice(-20).map(e=>`${e.role}: ${e.content.slice(0,500)}`).join(`
|
|
50
|
-
`);Me.current=[],Ne.current=0;let c=le(r);if(e===`build`&&c.isConnectorBuild&&c.provider){await Ge(c.provider,c.category,g,m);return}try{i&&(y.log(`
|
|
51
|
-
[AGENT:CONFIG] ═══════════════════════════════════════`),y.log(`[AGENT:CONFIG] Prompt: "${r.slice(0,100)}..."`),y.log(`[AGENT:CONFIG] Mode: ${e}`),y.log(`[AGENT:CONFIG] MCP Servers: ${Ue.current.map(e=>e.name).join(`, `)||`none`}`),y.log(`[AGENT:CONFIG] API Key: ${o?`${o.slice(0,15)}...`:`MISSING`}`),y.log(`[AGENT:CONFIG] Context keys: ${Object.keys({connector:t,action:n}).filter(e=>({connector:t,action:n})[e]).join(`, `)||`none`}`),y.log(`[AGENT:CONFIG] Max turns: 1000`),y.log(`[AGENT:CONFIG] ═══════════════════════════════════════
|
|
52
|
-
`));let s=0,c=Date.now();for await(let u of ce({prompt:r,mode:e,mcpServers:Ue.current,apiKey:o,context:{connector:t,action:n,conversationSummary:a||void 0},maxTurns:1e3,verbose:i||!1,streaming:!1,origin:`cli`,abortSignal:m})){s++;let e=Date.now()-c;if(i){let t=u.type===`text`?` content="${(u.content||``).slice(0,30)}..."`:u.type===`error`?` error="${u.error}"`:u.type===`tool_call`?` tool="${u.toolName}"`:``;y.log(`[AGENT:MSG #${s}] type=${u.type}${t} (${e}ms)`)}if(!g())return;if(u.type===`text`){Be.current.phase=`streaming`,T(e=>e+(u.content??``)),qe();continue}if(u.type===`skill_invocation`){let e=`skill-${++Ne.current}`;p(t=>{let n=new Map(t);return n.set(e,{name:`Skill`,status:`running`,skillName:u.skillName,inputSummary:u.skillArgs}),n}),setTimeout(()=>{p(t=>{let n=new Map(t);return n.delete(e),n})},2e3);continue}if(u.type===`tool_call`){Be.current={operation:`Processing: "${r.slice(0,100)}${r.length>100?`...`:``}"`,phase:`tool_execution`,toolName:u.toolName,toolInput:u.toolInput};let e=`tc-${++Ne.current}`;if(Me.current.push(e),K(t=>[...t,{id:e,name:u.toolName??``,input:u.toolInput,output:void 0}]),u.toolName===`spawn_subagent`&&u.toolInput){let e=u.toolInput,t=e.description??e.goal??e.name??`Subagent`;if(typeof t==`string`&&t.length>50){let e=String(t).split(/[.!?]/)[0];t=e.length>50?e.slice(0,47)+`...`:e}R(String(t)),I.current=!0,setTimeout(()=>F(!0),10)}let t=u.toolInput,n=``;t&&typeof t==`object`&&(t.command?n=String(t.command).slice(0,100):t.file_path?n=String(t.file_path):t.pattern?n=String(t.pattern):t.url?n=String(t.url):t.query&&(n=String(t.query))),T(e=>(e&&l(t=>[...t,{role:`assistant`,content:e,timestamp:new Date,isSubagent:I.current}]),``)),p(t=>{let r=new Map(t);return r.set(e,{name:u.toolName??``,status:`running`,inputSummary:n}),r});continue}if(u.type===`tool_result`){Be.current={...Be.current,phase:`streaming`,toolName:void 0,toolInput:void 0};let e=Me.current.shift();if(e){K(t=>t.map(t=>t.id===e?{...t,output:u.toolResult}:t));let t=``;p(n=>{let r=n.get(e);r?.inputSummary&&(t=r.inputSummary);let i=new Map(n);return i.delete(e),i});let n=typeof u.toolResult==`string`?u.toolResult:JSON.stringify(u.toolResult,null,2),r={role:`system`,content:`TOOL:${u.toolName}|||${t}|||${n}`,timestamp:new Date,isSubagent:I.current};l(e=>[...e,r])}continue}if(u.type===`tool_progress`){let e=u.progress;u.toolName&&p(t=>{let n=new Map(t);for(let[t,r]of n)if(r.name===u.toolName){n.set(t,{...r,inputSummary:e?.operation||r.inputSummary});break}return n});continue}if(u.type===`tool_error`){Be.current={...Be.current,phase:`streaming`,toolName:void 0,toolInput:void 0};let e=Me.current.shift();e&&(K(t=>t.map(t=>t.id===e?{...t,output:`Error: ${u.error}`}:t)),p(t=>{let n=new Map(t);return n.delete(e),n}));continue}if(u.type===`error`){let e=u.error??`Unknown error`,t=e;if(i){y.log(`
|
|
53
|
-
[AGENT:ERROR] ═══════════════════════════════════════`),y.log(`[AGENT:ERROR] Message: ${e}`),y.log(`[AGENT:ERROR] Full message object:`);try{y.log(JSON.stringify(u,null,2))}catch{y.log(`[AGENT:ERROR] (could not stringify message)`)}y.log(`[AGENT:ERROR] Messages received before error: ${s}`),y.log(`[AGENT:ERROR] Time elapsed: ${Date.now()-c}ms`),y.log(`[AGENT:ERROR] ═══════════════════════════════════════
|
|
54
|
-
`)}e.includes(`exited with code 1`)?t=`Agent subprocess failed (exit code 1).
|
|
55
|
-
|
|
56
|
-
Possible causes:
|
|
57
|
-
• Authentication issue with StackOne API
|
|
58
|
-
• Network connectivity problem
|
|
59
|
-
• Invalid agent configuration
|
|
60
|
-
|
|
61
|
-
Run 'stackone agent setup' to refresh credentials.
|
|
62
|
-
|
|
63
|
-
Original error: ${e}`:e.includes(`401`)||e.includes(`unauthorized`)||e.includes(`Unauthorized`)?t=`Authentication failed.
|
|
64
|
-
|
|
65
|
-
Run 'stackone agent setup' to refresh your credentials.
|
|
66
|
-
|
|
67
|
-
Original error: ${e}`:e.includes(`403`)||e.includes(`forbidden`)||e.includes(`Forbidden`)?t=`Access denied. Your credentials may not have permission for this operation.
|
|
68
|
-
|
|
69
|
-
Run 'stackone agent setup' to refresh your credentials.
|
|
70
|
-
|
|
71
|
-
Original error: ${e}`:(e.includes(`ENOTFOUND`)||e.includes(`ECONNREFUSED`)||e.includes(`network`))&&(t=`Network error. Check your internet connection.
|
|
72
|
-
|
|
73
|
-
Original error: ${e}`),_(t),Be.current={operation:``,phase:`idle`};continue}if(u.type===`done`){if(i){let e=Date.now()-c;y.log(`
|
|
74
|
-
[AGENT:DONE] ═══════════════════════════════════════`),y.log(`[AGENT:DONE] Total messages received: ${s}`),y.log(`[AGENT:DONE] Total time: ${e}ms`),y.log(`[AGENT:DONE] Status: ${u.status||`unknown`}`),s<=2&&y.log(`[AGENT:DONE] ⚠️ WARNING: Very few messages - agent may have failed early`),y.log(`[AGENT:DONE] ═══════════════════════════════════════
|
|
75
|
-
`)}Be.current={operation:``,phase:`idle`},h(!1),p(new Map),K([]);let e=I.current;T(t=>(t&&l(n=>[...n,{role:`assistant`,content:t,timestamp:new Date,isSubagent:e}]),``)),e?(I.current=!1,setTimeout(()=>{l(e=>{let t=e.filter(e=>e.isSubagent&&e.role===`assistant`).map(e=>e.content).join(`
|
|
76
|
-
|
|
77
|
-
`);return t?.trim()?setTimeout(()=>{_e(!1),F(!1),setTimeout(()=>{try{Ke(t,!0)}catch(e){y.error(`[SUBAGENT] Error:`,e),U(!1)}},100)},300):(_e(!1),F(!1),U(!1)),e})},100)):U(!1),await We(r)}}}catch(e){if(!g())return;h(!1),p(new Map),_(Ve(e instanceof Error?e.message:String(e),i||!1)),Be.current={operation:``,phase:`idle`}}g()&&(h(!1),p(new Map),U(!1),K([]),Be.current={operation:``,phase:`idle`})}catch(e){if(!g()){i&&y.log(`[STREAM] Ignoring error from interrupted request:`,e instanceof Error?e.message:String(e));return}h(!1),p(new Map),U(!1),K([]);let t=e instanceof Error?e.message:String(e);t.toLowerCase().includes(`cloudfront`)||t.includes(`403`)&&t.includes(`Request blocked`)?_(`⚠️ Request temporarily blocked by CloudFront
|
|
78
|
-
|
|
79
|
-
The API server's firewall blocked this request. This usually happens due to:
|
|
80
|
-
• Rate limiting (too many requests in a short time)
|
|
81
|
-
• Request size limits being exceeded
|
|
82
|
-
• Temporary server-side issues
|
|
83
|
-
|
|
84
|
-
What to try:
|
|
85
|
-
1. Wait a few seconds and try again
|
|
86
|
-
2. Start a fresh conversation with /compact
|
|
87
|
-
3. If this persists, contact the StackOne team
|
|
88
|
-
|
|
89
|
-
Press Enter to retry.`):t.includes(`403`)||t.includes(`Invalid authentication token`)||t.includes(`authentication`)?_(`Authentication failed. Your token may be invalid or expired.
|
|
90
|
-
|
|
91
|
-
To fix this:
|
|
92
|
-
1. Run: stackone agent setup
|
|
93
|
-
2. Follow the prompts to authenticate
|
|
94
|
-
3. Try again
|
|
95
|
-
|
|
96
|
-
Original error: ${t}`):t.includes(`API key`)||t.includes(`Invalid API Key`)?(y.error(`
|
|
97
|
-
❌ Critical error:`,t),y.error(`Please check your configuration and try again.
|
|
98
|
-
`),process.exit(1)):_(Ve(t,i||!1)),Be.current={operation:``,phase:`idle`},U(!1),h(!1),p(new Map)}},[b,s,r,e,t,n,re,E,o,he,We]);B(()=>{b||r&&Ke(r)},[b,r,e,Pe]);let qe=()=>{xe(e=>(e.length===0||p(e=>(!(e.size>0)&&Te.current&&(q.current&&=(clearTimeout(q.current),null),setTimeout(()=>Je(),100)),e)),e))},Je=()=>{xe(e=>{if(e.length===0)return e;Ce(!0),T(e=>{if(e){let t={role:`assistant`,content:e,timestamp:new Date,isSubagent:I.current};l(e=>[...e,t])}return``});let t=e.map(e=>({role:`user`,content:e.content,timestamp:new Date}));l(e=>[...e,...t]);let n=e.map(e=>e.content).join(`
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
`);return Ce(!1),U(!1),K([]),q.current&&=(clearTimeout(q.current),null),setTimeout(()=>{Ke(n,!0)},100),[]})},Ye=ye(async e=>{let{removeTrustedFolder:t,getTrustedFoldersForDisplay:n}=await import(`./trustedFolders-6UfkywNe.mjs`);t(e);let r=n();r.length===0?j(null):j({type:`trust`,items:r.map(e=>({name:e.name,description:e.path,path:e.path,trusted:e.trusted,trustedAt:e.trustedAt}))})},[j]);B(()=>{let e=S.map(e=>e.name);fe.current.setActiveSkills(e)},[S]),B(()=>{if(!b&&ve.length>0){let e=setTimeout(()=>{qe()},100);return()=>clearTimeout(e)}},[b,ve.length]);let Xe=()=>{},Ze=ye(()=>{G.current.shouldStop=!0,G.current.controller?.abort(),v(!0),T(e=>{if(e){let t=I.current,n={role:`assistant`,content:e,timestamp:new Date,isSubagent:t};l(e=>[...e,n])}return``}),h(!1),U(!1),Te.current=!1,p(new Map),K([]),l(e=>e.map(e=>{if(e.content.startsWith(`TOOL_START:`)){let t=e.content.split(`|||`)[1]||`unknown`;return{...e,content:`TOOL:${t}|||[Interrupted]|||`}}return e})),xe([]),Ae([]),Ce(!1),je.current&&=(clearTimeout(je.current),null)},[]),Qe=ye(e=>{ze.current&&=(ze.current.resolve(e),null),Re(null)},[]);return b?z.createElement(Dt,{title:`Agent ${e.charAt(0).toUpperCase()+e.slice(1)} Mode`,mode:e,connector:t,action:n,messages:[],currentToolCalls:[],isThinking:!1,isComplete:!1,error:void 0,isInterrupted:!1,onSubmit:()=>{},onExit:Xe,onStop:Ze,slashCommands:Fe,welcomeContext:He}):z.createElement(Dt,{title:`Agent ${e.charAt(0).toUpperCase()+e.slice(1)} Mode`,mode:e,connector:t,action:n,messages:s,currentToolCalls:Array.from(f.values()),isThinking:m,isComplete:!1,error:g,isInterrupted:ee,onSubmit:Ke,onExit:Xe,onStop:Ze,commandHistory:ne,streamingText:w,usage:re,detailViewData:ue,onCloseDetailView:()=>j(null),onToggleTrust:Ye,slashCommands:Fe,buildPhases:Ee,currentBuildPhase:Oe,onRewindTo:e=>{try{let t=P.join(N.homedir(),`.stackone`,`agent_history`),n=A.readFileSync(t,`utf-8`),r;try{let e=JSON.parse(n);r=Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()):n.split(`
|
|
103
|
-
`).filter(e=>e.trim())}catch{r=n.split(`
|
|
104
|
-
`).filter(e=>e.trim())}let i=new Map,a=[],o=[],s=[],c=Array.from(Z.current.keys()).filter(t=>t>e).sort((e,t)=>e-t);for(let e of c){let t=Z.current.get(e);if(t)for(let[e,n]of t.files)i.has(e)||i.set(e,n)}for(let[e,t]of i){let n=Nt(e,t);n.success?n.action===`deleted`?o.push(e):a.push(e):s.push(`${e}: ${n.error}`)}for(let e of c)Z.current.delete(e);Ie.current=e;let u=r.slice(0,e+1);A.writeFileSync(t,JSON.stringify(u),`utf-8`);let d=`⏮️ Rewound to command: "${r[e]}"`;if(a.length>0||o.length>0){if(d+=`
|
|
105
|
-
|
|
106
|
-
📁 File changes:`,a.length>0){d+=`\n Restored (${a.length}):`;for(let e of a.slice(0,10))d+=`\n • ${P.basename(e)}`;a.length>10&&(d+=`\n ... and ${a.length-10} more`)}if(o.length>0){d+=`\n Deleted (${o.length}):`;for(let e of o.slice(0,10))d+=`\n • ${P.basename(e)}`;o.length>10&&(d+=`\n ... and ${o.length-10} more`)}}else d+=`
|
|
107
|
-
|
|
108
|
-
📁 No file changes to restore.`;if(s.length>0){d+=`\n\n⚠️ Errors (${s.length}):`;for(let e of s.slice(0,5))d+=`\n • ${e}`}let f={role:`system`,content:d,timestamp:new Date};l(e=>[...e,f]),C(u)}catch(e){let t={role:`system`,content:`❌ Error rewinding: ${e instanceof Error?e.message:String(e)}`,timestamp:new Date};l(e=>[...e,t])}},onResumeConversation:e=>{l(e.map(e=>({...e,timestamp:new Date(e.timestamp)})))},spawnedSubagentActive:he,spawnedSubagentName:L,spawnedSubagentComplete:ge,queuedMessages:ve,isProcessingQueue:Se,initInfo:Pe,welcomeContext:He,pendingDeleteConfirmation:Le,onConfirmDelete:Qe})};var Ut=class{async execute(e){if(!process.execArgv.some(e=>e.startsWith(`--max-old-space-size`))){let{spawn:e}=await import(`child_process`);e(process.execPath,[`--max-old-space-size=8192`,...process.argv.slice(1)],{stdio:`inherit`,env:process.env}).on(`exit`,e=>{process.exit(e||0)});return}process.stdout.write(`\x1Bc`);let{getAgentApiKey:t,getAgentCredentialStatus:n,CredentialExpiredError:r,CredentialMissingError:i}=await import(`./agentApiKey-BoYyBKnD.mjs`),{hasOldSetupFiles:a,migrateFromLocalSetup:o,displayMigrationMessage:s}=await import(`./setupMigration-D_zUtD_W.mjs`);try{let r=process.cwd(),i=t();a(r)&&s(await o(r,i));let c=n(),l=c.status===`expiring_soon`?c.timeRemaining:void 0;process.env.STACKONE_AGENT_TOKEN||(process.env.STACKONE_AGENT_TOKEN=i);let u=P.join(N.homedir(),`.stackone`,`trusted_directories`),d=[];try{A.existsSync(u)&&(d=A.readFileSync(u,`utf-8`).split(`
|
|
109
|
-
`).filter(e=>e.trim()))}catch(e){y.error(`[Trust] Failed to load trusted directories:`,e)}if(!d.includes(r)){let e=!1,{addTrustedFolder:t}=await import(`./trustedFolders-6UfkywNe.mjs`),{waitUntilExit:n}=ge(z.createElement(kt,{directory:r,onConfirm:()=>{e=!0,t(r)},onCancel:()=>{e=!1}}));await n(),e||(y.log(`
|
|
110
|
-
Exiting...`),process.exit(0)),process.stdout.write(`\x1Bc`)}let f=i;if(l){let e={current:`ignore`},{waitUntilExit:n}=ge(z.createElement(Ot,{timeRemaining:l,onRunSetup:()=>{e.current=`setup`},onIgnore:()=>{e.current=`ignore`}}));if(await n(),e.current===`setup`){process.stdout.write(`\x1Bc`);let{spawnSync:e}=await import(`node:child_process`),n=e(process.execPath,[process.argv[1],`agent`,`setup`],{stdio:`inherit`});n.status!==0&&process.exit(n.status??1);let r=t();process.env.STACKONE_AGENT_TOKEN=r,f=r}process.stdout.write(`\x1Bc`)}let{waitUntilExit:p}=ge(z.createElement(Ht,{...e,apiKey:f}),{exitOnCtrlC:!1});await p()}catch(e){e instanceof r&&(y.error(`
|
|
111
|
-
❌ Credentials Expired
|
|
112
|
-
`),y.log(w.white(`Your StackOne credentials have expired.
|
|
113
|
-
`)),y.log(w.white("To continue using the agent, run `stackone agent setup` to reauthenticate.\n")),y.log(w.dim(`Credentials are valid for 7 days after authentication.
|
|
114
|
-
`)),process.exit(1)),e instanceof i&&(y.error(`
|
|
115
|
-
❌ Authentication Required
|
|
116
|
-
`),y.log(w.white(`You need to authenticate before using the agent.
|
|
117
|
-
`)),y.log(w.white("To get started, run `stackone agent setup` to authenticate.\n")),y.log(w.dim(`This will:`)),y.log(w.dim(` • Authenticate with your StackOne credentials`)),y.log(w.dim(` • Save your token securely to ~/.stackone/agent-config.json`)),y.log(w.dim(` • Enable access to StackOne Agent and MCP tools
|
|
118
|
-
`)),y.log(w.white(`If you already ran setup, your local configuration may be missing or unreadable.`)),y.log(w.white(`Run setup again to create or repair your authentication configuration.
|
|
119
|
-
`)),process.exit(1));let t=e instanceof Error?e.message:String(e);y.error(`
|
|
120
|
-
❌ Error:`,t),y.log(w.dim(`
|
|
121
|
-
If you continue to see this error, try running:`)),y.log(w.cyan(` stackone agent setup
|
|
122
|
-
`)),process.exit(1)}}},Wt=class{async execute(){y.log(w.blue.bold(`🧹 StackOne Agent Cleanup
|
|
123
|
-
`));try{let e=J(`Removing stored configuration...`).start();await p(),e.succeed(`Removed ~/.stackone/agent-config.json`);let t=J(`Removing MCP servers from Claude...`).start(),n=0;h(a(),_())&&n++,h(m(process.cwd()),s())&&n++,n>0?t.succeed(`Removed ${n} MCP server(s) from Claude`):t.warn(`No MCP servers found in Claude (already removed or not configured)`),y.success(`Cleanup complete!`),y.log(w.white(`
|
|
124
|
-
What was removed:`)),y.log(w.cyan(` • ~/.stackone/agent-config.json`)),n>0&&y.log(w.cyan(` • MCP server entries from Claude configuration`)),y.log(w.dim(`
|
|
125
|
-
To authenticate again:`)),y.log(w.cyan(` stackone agent setup`),w.dim(`(for global setup)`)),y.log(w.cyan(` stackone agent setup --local`),w.dim(`(for local project setup)`)),y.log(``),process.exit(0)}catch(e){e instanceof Error?y.error(e.message):y.error(`Unknown error occurred`),process.exit(1)}}};const Gt=(e,t)=>e?!!(t?.email||t?.password||t?.passwordFromStdin||process.env.STACKONE_EMAIL?.trim()||process.env.STACKONE_PASSWORD?.trim()):!1,Kt=`stackone-cli`,qt=async e=>{let t=`HTTP ${e.status}: ${e.statusText}`;try{let n=await e.text(),r=JSON.parse(n);return r.error_description||r.error||t}catch{return t}};var Jt=class{constructor(e){this.baseUrl=e||process.env.AUTH_SERVER_URL||`https://idp-api.stackone.com`}async login(e,t){try{let n=await fetch(`${this.baseUrl}/auth/sign-in/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})});if(!n.ok)return{success:!1,error:await qt(n)};let r=await n.json();return r.apiKey?{success:!0,apiKey:r.apiKey}:{success:!1,error:`Invalid response format`}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Network error occurred`}}}async validateKey(e){try{let t=await fetch(`${this.baseUrl}/api-key/verify`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});return t.ok?await t.json():{valid:!1,error:await qt(t)}}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Network error occurred`}}}async requestDeviceCode(){let e=await fetch(`${this.baseUrl}/api/auth/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({client_id:Kt})});if(!e.ok)throw Error(await qt(e));return await e.json()}async pollDeviceToken(e){try{let t=await fetch(`${this.baseUrl}/api/auth/device/token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:e,client_id:Kt})});if(t.ok)return{token:await t.json()};try{let e=await t.json();if(e.error)return{error:e}}catch{}return{error:{error:`server_error`,error_description:`HTTP ${t.status}: ${t.statusText}`}}}catch(e){return{error:{error:`network_error`,error_description:e instanceof Error?e.message:`Network error`}}}}async createApiKey(e){let t=10080*60,n=await fetch(`${this.baseUrl}/api/auth/api-key/create`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e}`},body:JSON.stringify({prefix:`falcon_key_`,expiresIn:t,name:`CLI Auth Key`})});if(!n.ok)throw Error(await qt(n));let r=await n.json(),i=new Date(Date.now()+t*1e3).toISOString();return{key:r.key,expiresAt:i}}};const Yt=e=>new Promise(t=>{let n=he(),r,i;n===`darwin`?(r=`open`,i=[e]):n===`win32`?(r=`rundll32`,i=[`url.dll,FileProtocolHandler`,e]):(r=`xdg-open`,i=[e]),Se(r,i,e=>{t(!e)})}),Xt=async(e,t)=>{let n=await e.requestDeviceCode(),r=await Yt(n.verification_uri_complete),i=`Confirmation code: ${n.user_code}`;t(r?`Browser opened. ${i}\nWaiting for authentication...`:`Could not open browser. Please visit:\n ${n.verification_uri_complete}\n\n${i}`);let a=n.interval*1e3,o=0,s=Date.now()+n.expires_in*1e3;for(;Date.now()<s;){await new Promise(e=>setTimeout(e,a));let r=await e.pollDeviceToken(n.device_code);if(`token`in r){t(`Authenticated. Creating API key...`);let n=await e.createApiKey(r.token.access_token),i=await e.validateKey(n.key);return{success:!0,apiKey:n.key,email:i.email,userId:i.userId,expiresAt:n.expiresAt}}let i=r.error.error;if(i===`authorization_pending`){o=0;continue}if(i===`slow_down`){o=0,await new Promise(e=>setTimeout(e,a));continue}if(i===`expired_token`)return{success:!1,error:`Authentication session expired`};if(i===`access_denied`)return{success:!1,error:`Access denied by user`};if(o++,o>=5)return{success:!1,error:`Polling failed: ${r.error.error_description??`unknown error`}`}}return{success:!1,error:`Authentication timed out`}},Zt=new Jt,Qt=async()=>{let e=Pe({input:Me,output:Ne}),t=await new Promise(t=>{e.question(w.white(`Email: `),e=>{t(e.trim())})});return e.close(),t||(y.error(`Email is required`),process.exit(1)),t},$t=async()=>{process.stdin.isTTY&&(y.error(`--password-stdin was set but no input was piped to stdin`),process.exit(1));let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`).replace(/[\r\n]+$/,``)},en=async e=>{let t=e.email?.trim()||process.env.STACKONE_EMAIL?.trim()||void 0,n;return e.passwordFromStdin?n=await $t():e.password?n=e.password:process.env.STACKONE_PASSWORD&&(n=process.env.STACKONE_PASSWORD),{email:t,password:n||void 0}},tn=async e=>{let t=await en(e),n=t.email;if(!n){let e=await ee();if(e?.email){y.log(w.dim(`Last used email: ${e.email}\n`));let{useExisting:t}=await je.prompt([{type:`confirm`,name:`useExisting`,message:`Sign in with this email?`,default:!0}]);n=t?e.email:await Qt()}else n=await Qt()}let r=t.password;r||=(e.passwordFromStdin&&(y.error(`Password is required`),process.exit(1)),(await je.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}])).password),r||(y.error(`Password is required`),process.exit(1)),y.log(``);let i=J(`Authenticating...`).start(),a=await Zt.login(n,r);(!a.success||!a.apiKey)&&(i.fail(`Authentication failed`),y.error(`${a.error||`Invalid credentials`}`),y.log(w.dim(`Please check your email and password and try again.
|
|
126
|
-
`)),process.exit(1)),i.succeed(`Login successful!`);let o=new Date(Date.now()+10080*60*1e3).toISOString();return{apiKey:a.apiKey,email:n,expiresAt:o}},nn=async()=>{let e=J(`Starting browser authentication...`).start(),t;try{t=await Xt(Zt,t=>{e.text=t})}catch(t){e.fail(`Authentication failed`),y.error(t instanceof Error?t.message:`Unknown error`),process.exit(1)}(!t.success||!t.apiKey)&&(e.fail(`Authentication failed`),y.error(t.error||`Unknown error`),process.exit(1)),e.succeed(`Login successful!`);let n=t.expiresAt||new Date(Date.now()+10080*60*1e3).toISOString();return{apiKey:t.apiKey,email:t.email??``,userId:t.userId,expiresAt:n}},rn=async(e,t={})=>{let{apiKey:n,email:r,userId:i,expiresAt:a}=e?await tn(t):await nn(),o={apiKey:n,userId:i??r,email:r,expiresAt:a,serverUrl:g()};return await f(o),o},an=e=>{let t=new Date(e),n=new Date,r=t.getTime()-n.getTime(),i=Math.floor(r/(1440*60*1e3)),a=Math.floor(r%(1440*60*1e3)/(3600*1e3)),o=t.toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0});return`${t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`})} at ${o} (${i>0?`${i} days, ${a} hours`:`${a} hours`} from now)`};var on=class{async execute(e){y.log(w.blue.bold(`🤖 StackOne Agent Setup - Global Configuration
|
|
127
|
-
`));try{let t=process.cwd(),n=await Ae(`${t}/CLAUDE.md`).then(()=>!0).catch(()=>!1),r=await Ae(`${t}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||r)if(y.warn(`Existing local setup detected:`),n&&y.log(w.dim(` • CLAUDE.md found in current directory`)),r&&y.log(w.dim(` • .mcp.json found in current directory`)),y.log(``),Gt(!!e?.legacy,e?.credentials))y.log(w.dim(`Non-interactive credentials detected; proceeding without confirmation.
|
|
128
|
-
`));else{let{proceed:e}=await je.prompt([{type:`confirm`,name:`proceed`,message:`Re-authenticate globally despite existing local setup?`,default:!0}]);e||(y.log(w.dim(`
|
|
129
|
-
Setup cancelled.`)),process.exit(0)),y.log(``)}let i=await rn(!!e?.legacy,e?.credentials);y.success(`API key saved to ~/.stackone/agent-config.json`),y.log(w.white(`✓ Key expires at`),w.cyan(an(i.expiresAt))),te(await S(process.cwd(),i.apiKey));let o=J(`Setting up global MCP configuration...`).start();try{l(a(),_(),i.apiKey),o.succeed(`Installed to Claude (global)`),y.success(`Global setup complete!`),y.log(w.white(`Config location:`),w.cyan(`~/.claude.json`)),y.log(w.dim(`Token stored securely in Claude MCP server config.`)),y.log(w.blue(`
|
|
130
|
-
Verify:`),w.cyan(`claude mcp list`)),y.log(w.dim(`
|
|
131
|
-
💡 Tip: Run Claude without permission prompts:`),w.cyan(`claude --dangerously-skip-permissions`)),y.log(w.dim(`
|
|
132
|
-
To setup for a specific project, run:`),w.cyan(`stackone agent setup --local`)),y.log(``)}catch(e){o.fail(`Installation to Claude failed`),e instanceof Error&&y.error(e.message)}process.exit(0)}catch(e){e instanceof Error?y.error(e.message):y.error(`Unknown error occurred`),process.exit(1)}}};const sn={research:`Researching API...`,"discover-actions":`Discovering available actions...`,"build-and-validate":`Building and validating connector...`};var cn=class{async execute(e){let{prompt:t,mode:n=`build`,maxTurns:r=25,verbose:i=!1}=e;t.trim()||(y.error(`A prompt is required.`),process.exit(1));let a;try{a=ne()}catch(e){e instanceof Error&&e.name===`CredentialMissingError`?(y.error(`
|
|
133
|
-
❌ Authentication Required
|
|
134
|
-
`),y.log(w.white("Run `stackone agent setup` to authenticate, then try again.\n"))):y.error(e instanceof Error?e.message:String(e)),process.exit(1)}let o=Mt(),s=le(t.trim());if(n===`build`&&s.isConnectorBuild&&s.provider)return this.executeOrchestratedBuild({provider:s.provider,category:s.category,apiKey:a,mcpServers:o,verbose:i});i&&(y.log(w.dim(`Mode: ${n}\n`)),o.length>0&&y.log(w.dim(`MCP Servers: ${o.map(e=>e.name).join(`, `)}\n`)));let c=null;try{for await(let e of ce({prompt:t.trim(),mode:n,apiKey:a,maxTurns:r,verbose:i,mcpServers:o,origin:`cli`}))un(e,e=>{c&&c.stop(),c=e})}catch(e){c?.fail(),y.error(w.red(`
|
|
135
|
-
Error: `+(e instanceof Error?e.message:String(e)))),process.exit(1)}c?.stop(),y.log(w.green(`
|
|
136
|
-
✓ Done
|
|
137
|
-
`))}async executeOrchestratedBuild(e){let{provider:t,category:n,verbose:r}=e,i=n?` (${n})`:``;y.log(w.bold(`\nOrchestrated build: ${t}${i}\n`));let a=null,o=new Map;try{for await(let t of jt(e))switch(t.type){case`phase_start`:{let e=sn[t.phase]||`${t.phase}...`,n=t.model?w.dim(` (${rt(t.model)})`):``;a?.stop(),a=J(w.cyan(`[${t.phase}]${n} ${e}`)).start(),o.set(t.phase,Date.now());break}case`phase_complete`:{let e=o.get(t.phase),n=e===void 0?0:Math.round((Date.now()-e)/1e3);a?.succeed(w.green(`[${t.phase}] Done (${n}s)`)),a=null;break}case`phase_error`:a?.fail(w.red(`[${t.phase}] ${t.error}`)),a=null;break;case`agent_message`:ln(t,a,r);break}}catch(e){a?.fail(),y.error(w.red(`
|
|
138
|
-
Error: `+(e instanceof Error?e.message:String(e)))),process.exit(1)}a?.stop(),y.log(w.green(`
|
|
139
|
-
✓ Build complete
|
|
140
|
-
`))}};const ln=(e,t,n)=>{let r=e.message;switch(r.type){case`text`:n&&process.stdout.write(r.content??``);break;case`tool_call`:{let n=r.toolName??`unknown tool`;t&&(t.text=w.cyan(`[${e.phase}] Tool: ${n}`));break}case`tool_error`:y.error(w.red(`\n[${e.phase}] Tool error (${r.toolName}): ${r.error??`Unknown error`}`));break;case`error`:y.error(w.red(`\n[${e.phase}] ${r.error??`Unknown error`}`));break;default:break}};function un(e,t){switch(e.type){case`text`:t(null),process.stdout.write(e.content??``);break;case`tool_call`:{let n=e.toolName??`unknown tool`;t(J(w.cyan(`Tool: ${n}`)).start());break}case`tool_result`:t(null);break;case`tool_progress`:{let n=e.progress?.operation||e.toolName||`Working...`;t(J(w.cyan(`Tool: ${n}`)).start());break}case`tool_error`:t(null),y.error(w.red(`\nTool error (${e.toolName}): ${e.error??`Unknown error`}`));break;case`error`:t(null),y.error(w.red(`\n${e.error??`Unknown error`}`));break;case`done`:t(null);break;default:process.env.VERBOSE&&console.warn(`[AgentRun] Unknown message type:`,e.type);break}}var dn=class{async execute(e){y.log(w.blue.bold(`🤖 StackOne Agent Setup - Local Project
|
|
141
|
-
`));try{let t=process.cwd(),n=await Ae(`${t}/CLAUDE.md`).then(()=>!0).catch(()=>!1),r=await Ae(`${t}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||r)if(y.warn(`Existing local setup detected:`),n&&y.log(w.dim(` • CLAUDE.md found`)),r&&y.log(w.dim(` • .mcp.json found`)),y.log(``),Gt(!!e?.legacy,e?.credentials))y.log(w.dim(`Non-interactive credentials detected; proceeding without confirmation.
|
|
142
|
-
`));else{let{proceed:e}=await je.prompt([{type:`confirm`,name:`proceed`,message:`Overwrite existing local configuration?`,default:!1}]);e||(y.log(w.dim(`
|
|
143
|
-
Setup cancelled.`)),process.exit(0)),y.log(``)}let i=await ee();(!i||!d(i))&&(y.warn(`Not authenticated globally.`),y.log(w.white(`Let's authenticate now...
|
|
144
|
-
`)),i=await rn(!!e?.legacy,e?.credentials),y.log(``)),te(await S(t,i.apiKey));let a=J(`Creating .mcp.json...`).start();try{l(m(t),s(),i.apiKey),a.succeed(`Created .mcp.json`),y.success(`Local setup complete!`),y.log(w.white(`Files created:`)),y.log(w.cyan(` • .mcp.json`)),y.log(w.dim(`Token stored securely in Claude MCP server config.`)),y.log(w.dim(`
|
|
145
|
-
💡 The stackone-agent-local MCP server is now available in this project`)),y.log(w.dim(`
|
|
146
|
-
💡 Tip: Run Claude without permission prompts:`),w.cyan(`claude --dangerously-skip-permissions`)),y.log(w.blue(`
|
|
147
|
-
Verify:`),w.cyan(`claude mcp list`)),y.log(``)}catch(e){a.fail(`Failed to create .mcp.json`),e instanceof Error&&y.error(e.message)}process.exit(0)}catch(e){e instanceof Error?y.error(e.message):y.error(`Unknown error occurred`),process.exit(1)}}},fn=class{async execute(e){let t=D(),n=e?.mode;if(y.log(w.bold(`
|
|
148
|
-
Available skills
|
|
149
|
-
`)),t.length===0){y.log(w.dim(` No bundled skills found.
|
|
150
|
-
`));return}for(let e of t)y.log(` • ${e}`);if(n){let e=k(n);if(e.length>0){y.log(w.bold(`\nRecommended for mode "${n}":\n`));for(let n of e){let e=t.includes(n);y.log(` • ${n}${e?``:w.dim(` (not found)`)}`)}}}y.log(``)}};const pn={profiles:{}},mn=()=>{let t=i.readConfigFile(e);if(!t)return pn;try{return JSON.parse(t)}catch{return pn}},hn=e=>mn().profiles[e],gn=e=>!!mn().profiles[e],_n=(t,n)=>{let r=mn();r.profiles[t]=n,i.writeConfigFile(e,JSON.stringify(r,null,2))},vn=()=>{let e=mn();return Object.keys(e.profiles)},yn=`https://api.stackone.com`;var bn=class{async execute({profile:e,connector:r,apiUrl:i,apiKey:a}={}){if(!e&&!a&&(y.error(`Profile or API key is required`),y.log(`Please provide a profile using the ${t(`--profile`)} option or an API key using the ${t(`--api-key`)} option.`),y.log(`To create a profile, run ${t(`stackone init`)}.`),process.exit(1)),e&&a&&(y.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&i&&y.warn(`Specifying ${t(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!gn(e)){y.error(`Configuration profile ${t(e)} not found`),y.log(`Run ${t(`stackone init`)} to create a new configuration profile.\n`);let n=vn();n.length>0&&(y.info(`Available configuration profiles:`),n.forEach(e=>{y.log(` - ${w.blue(e)}`)})),process.exit(1)}let o=e?hn(e):{apiUrl:i??yn,apiKey:a};o?.apiKey||(y.error(`API key is missing`),y.log(`Please provide a valid API key in the profile or via the ${t(`--api-key`)} option.`),process.exit(1)),r||(y.error(`Connector identifier is required in the format provider_key@version.`),process.exit(1));let s=r.split(`@`);(s.length!==2||!s[0]||!s[1])&&(y.error(`Invalid connector format ${n(r)}. Expected format: ${t(`provider_key@version`)}`),process.exit(1));let c=o.apiUrl??yn,l=await this.dropConnector(r,c,o.apiKey);process.exit(l?0:1)}async dropConnector(e,n,i){let a=J(`🗑️ Dropping connector ${t(e)}...`).start();try{let r=Buffer.from(i).toString(`base64`),o=await fetch(`${n}/registry/connectors/${e}`,{method:`DELETE`,headers:{Authorization:`Basic ${r}`}});return a.stop(),o.status===204?(y.success(`Successfully dropped connector ${t(e)} from the registry`),!0):o.status===404?(y.error(`Connector ${t(e)} not found in the registry`),!1):o.status===401||o.status===403?(y.error(`You do not have permission to drop this connector`),!1):o.status===409?(y.error(`Connector ${t(e)} has associated configs and cannot be dropped`),y.log(`Please delete all associated integration configurations before dropping the connector.`),!1):(o.ok||await b(o,`Failed to drop connector ${t(e)} from the registry`),!1)}catch(i){return a.stop(),y.error(`Failed to drop connector ${t(e)} from registry: ${i.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),!1}}};const xn=`stackone`;async function Sn(e,n){n.length===0&&(y.error(`Multiple versions of connector ${t(e)} were found but no owner information was returned`),process.exit(1));let r=n.map(e=>({value:e,label:e===xn?`StackOne`:`Custom`,hint:e===xn?`Official StackOne connector`:`Custom connector version created by your organization`}));y.warn(`Multiple versions of connector ${t(e)} were found. Please select which version to use.`);let i=await He({message:`Which version would you like to use?`,options:r});return ze(i)&&(y.error(`Operation cancelled.`),process.exit(1)),i}const Cn=`https://api.stackone.com`;var wn=class{async execute({profile:e,connector:r,accountId:i,format:a,outputFile:s,apiUrl:c,apiKey:l,owner:u}={}){if(!e&&!l&&(y.error(`Profile or API key is required`),y.log(`Please provide a profile using the ${t(`--profile`)} option or an API key using the ${t(`--api-key`)} option.`),y.log(`To create a profile, run ${t(`stackone init`)}.`),process.exit(1)),e&&l&&(y.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&c&&y.warn(`Specifying ${t(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!gn(e)){y.error(`Configuration profile ${t(e)} not found`),y.log(`Run ${t(`stackone init`)} to create a new configuration profile.\n`);let n=vn();n.length>0&&(y.info(`Available configuration profiles:`),n.forEach(e=>{y.log(` - ${w.blue(e)}`)})),process.exit(1)}let d=e?hn(e):{apiUrl:c??Cn,apiKey:l};d?.apiKey||(y.error(`API key is missing`),y.log(`Please provide a valid API key in the profile or via the ${t(`--api-key`)} option.`),process.exit(1)),Y(r)&&Y(i)&&(y.error(`Either ${t(`--connector`)} or ${t(`--account-id`)} must be provided`),process.exit(1)),X(r)&&X(i)&&(y.error(`Please provide either ${t(`--connector`)} or ${t(`--account-id`)}, not both.`),process.exit(1)),X(a)&&a!==`yaml`&&a!==`json`&&(y.error(`Format must be either ${t(`yaml`)} or ${t(`json`)}.`),process.exit(1));let f=d.apiUrl??Cn,p;if(X(r)){this.#t(r)||(y.error(`Invalid connector format ${n(r)}. Expected format: ${t(`provider_key@version`)} or ${t(`provider_key`)}`),process.exit(1));let e=this.#n(r);p=await this.#r(e,f,d.apiKey,a,u)}else X(i)?p=await this.#i(i,f,d.apiKey,a):(y.error(`Either ${t(`--connector`)} or ${t(`--account-id`)} must be provided`),process.exit(1));if(X(s))try{U.writeFileSync(s,p,`utf-8`),y.success(`Connector written to file: ${t(s)}`)}catch(e){y.error(`Failed to write connector to file ${t(s)}: ${e.message}`),process.exit(1)}else if(y.log(`\n${w.blue.inverse(` CONNECTOR CONTENT `)}\n`),!a||a===`yaml`)y.log(this.#e(p));else if(a===`json`)try{o(JSON.parse(p))}catch{y.log(p)}else y.log(p);process.exit(0)}#e(e){return e.split(`
|
|
151
|
-
`).map(e=>{if(e.trim().startsWith(`#`))return w.gray(e);if(e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t+1),r=e.substring(t+1),i=r,a=r.trim();return a===`true`||a===`false`?i=r.replace(a,w.cyan(a)):a===`null`||a===`~`?i=r.replace(a,w.gray(a)):/^-?\d+(\.\d+)?$/.test(a)?i=r.replace(a,w.green(a)):(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`)||a&&!a.startsWith(`-`))&&(i=r.replace(a,w.yellow(a))),w.red(n)+i}return e.trim().startsWith(`-`)?e.replace(`-`,w.gray(`-`)):e}).join(`
|
|
152
|
-
`)}#t=e=>!e.includes(`/`)&&!e.includes(`\\`)&&!e.endsWith(`.yaml`)&&!e.endsWith(`.yml`)?e.includes(`@`)?e.split(`@`).length===2:!0:!1;#n=e=>e.includes(`@`)?e:`${e}@latest`;async#r(e,n,i,a,o){let s=J(`Getting connector ${t(e)} from registry...`).start();try{let r=Buffer.from(i).toString(`base64`),c=a?`?format=${a}`:``,l=o?`${c?`&`:`?`}owner=${encodeURIComponent(o)}`:``,u=await fetch(`${n}/registry/connectors/${e}${c}${l}`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});if(s.stop(),u.status===409){o&&(await b(u,`Failed to get connector ${t(e)} from the registry`),process.exit(1));let i=await Sn(e,(await u.json()).availableOwners??[]),a=`${n}/registry/connectors/${e}${c}${c?`&`:`?`}owner=${encodeURIComponent(i)}`;s.text=`Getting connector ${t(e)} from registry...`,s.start();let l=await fetch(a,{method:`GET`,headers:{Authorization:`Basic ${r}`}});return s.stop(),l.ok||(await b(l,`Failed to get connector ${t(e)} from the registry`),process.exit(1)),await l.text()}return u.ok||(await b(u,`Failed to get connector ${t(e)} from the registry`),process.exit(1)),await u.text()}catch(i){s.stop(),y.error(`Failed to get connector ${t(e)} from the registry: ${i.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),process.exit(1)}}async#i(e,n,i,a){let o=J(`Getting connector from account ${t(e)}...`).start();try{let r=Buffer.from(i).toString(`base64`),s=a?`?format=${a}`:``,c=await fetch(`${n}/accounts/${e}/connector${s}`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});return o.stop(),c.ok||(await b(c,`Failed to get connector from account ${t(e)}`),process.exit(1)),await c.text()}catch(i){o.stop(),y.error(`Failed to get connector from account ${t(e)}: ${i.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),process.exit(1)}}};const Tn=`http://localhost:4000`;var En=class{async execute({environment:e}={}){let n=e?.toLowerCase()??`production`;try{Re(`${w.inverse(` Initialize profile `)}`);let e=await Ue({message:`Profile label`,validate:e=>{if(!e||e.trim().length===0)return`The profile label is required`;if(e.includes(` `))return`The profile label cannot contain spaces`}});if(ze(e))return Ie(`Configuration profile initialization cancelled`),process.exit(0);if(gn(e)){let n=await Le({message:`Configuration profile with name ${t(e)} already exists. Do you want to overwrite it?`});if(ze(n)||!n)return Ie(`Configuration profile initialization cancelled`),process.exit(0)}let r;if(n===`production`)r=`https://api.stackone.com`;else if(n===`staging`)r=`https://api.stackone-dev.com`;else{let e=await Ue({message:`API URL`,placeholder:Tn,initialValue:Tn,validate:e=>{if(!e||e.trim().length===0)return`API URL is required`;try{new URL(e)}catch{return`Please enter a valid URL`}}});if(ze(e))return Ie(`Configuration profile initialization cancelled`),process.exit(0);r=e}let i=await Ve({message:`API Key`,validate:e=>{if(!e||e.trim().length===0)return`API Key is required`}});if(ze(i))return Ie(`Configuration profile initialization cancelled`),process.exit(0);_n(e,{label:e,environment:n,apiUrl:r,apiKey:i}),Be(`${w.green(`✔`)} Configuration profile ${t(e)} initialized successfully!`),process.exit(0)}catch(e){e?.isTtyError?y.error(`Prompt couldn't be rendered in the current environment`):y.error(`Failed to initialize configuration profile: ${e}`),process.exit(1)}}};const $={pending:`○`,acceptRemote:`●`,acceptLocal:`◐`,acceptBoth:`◑`,current:`◉`,arrow:`→`,check:`✓`,cross:`✗`,warning:`⚠`};var Dn=class{constructor(e,t,n,r){this.conflicts=[],this.currentIndex=0,this.totalConflicts=0,this.currentCleanup=null,this.connectorId=t,this.localVersion=n,this.remoteVersion=r,this.conflicts=e.map(e=>({conflict:e,choice:e.type===`unchanged`?`remote`:`pending`})),this.totalConflicts=e.filter(e=>e.type===`conflict`).length}resetForReResolution(){this.currentIndex=0}async resolve(){return this.totalConflicts===0?{cancelled:!1,states:this.conflicts}:(this.moveToNextConflict(),new Promise(e=>{let t=Je({input:process.stdin,output:process.stdout});process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),this.render();let n=n=>{let r=n.toString();if(r===``){this.cleanup(t),this.renderCancelled(),e({cancelled:!0,states:this.conflicts});return}if(r===`\x1B`&&n.length===1){this.cleanup(t),this.renderCancelled(),e({cancelled:!0,states:this.conflicts});return}if(r.startsWith(`\x1B[`)){switch(r.slice(2)){case`D`:this.moveToPrevConflict(),this.render();break;case`C`:this.moveToNextConflict(),this.render();break}return}switch(r){case`r`:case`R`:this.setCurrentChoice(`remote`),this.advanceAfterChoice(t);break;case`l`:case`L`:this.setCurrentChoice(`local`),this.advanceAfterChoice(t);break;case`b`:case`B`:this.setCurrentChoice(`both`),this.advanceAfterChoice(t);break;case`\r`:case`
|
|
153
|
-
`:this.allResolved()?(this.cleanup(t),e({cancelled:!1,states:this.conflicts})):(this.moveToNextUnresolved(),this.render());break;case`q`:case`Q`:this.cleanup(t),this.renderCancelled(),e({cancelled:!0,states:this.conflicts});break;case`a`:case`A`:this.acceptAllRemaining(`remote`),this.render();break;case`u`:case`U`:this.setCurrentChoice(`pending`),this.render();break}};process.stdin.on(`data`,n),this.currentCleanup=()=>{process.stdin.removeListener(`data`,n),process.stdin.isTTY&&process.stdin.setRawMode(!1),t.close()}}))}cleanup(e){this.currentCleanup?(this.currentCleanup(),this.currentCleanup=null):(process.stdin.isTTY&&process.stdin.setRawMode(!1),e.close())}advanceAfterChoice(e){this.allResolved()||this.moveToNextUnresolved(),this.render()}render(){v();let e=process.stdout.columns||80;this.renderHeader(e),this.renderProgressBar(e),this.renderCurrentConflict(e),this.renderControls(e)}renderHeader(e){let t=this.connectorId,n=`${this.localVersion} ${$.arrow} ${this.remoteVersion}`,r=Math.max(0,e-17),i=Math.floor(r/2),a=r-i,o=` `.repeat(i)+`CONFLICT RESOLVER`+` `.repeat(a);y.log(``),y.log(w.bgBlue.white.bold(o)),y.log(w.gray(this.centerText(t,e))),y.log(w.gray(this.centerText(n,e))),y.log(``)}renderProgressBar(e){let t=this.conflicts.filter(e=>e.conflict.type===`conflict`),n=this.getCurrentConflictIndex(),r=t.map((e,t)=>{let r=t===n,i,a;switch(e.choice){case`remote`:i=r?$.current:$.acceptRemote,a=w.green;break;case`local`:i=r?$.current:$.acceptLocal,a=w.yellow;break;case`both`:i=r?$.current:$.acceptBoth,a=w.cyan;break;default:i=r?$.current:$.pending,a=r?w.white:w.gray}return a(i)}),i=t.filter(e=>e.choice!==`pending`).length,a=` Conflict ${n+1} of ${this.totalConflicts} • ${i}/${this.totalConflicts} resolved `;y.log(w.gray(this.centerText(a,e))),y.log(this.centerText(r.join(` `),e)),y.log(``)}renderCurrentConflict(e){let t=this.conflicts[this.currentIndex];if(!t||t.conflict.type!==`conflict`)return;let n=t.conflict;if(y.log(w.gray(`_`.repeat(e))),y.log(`
|
|
154
|
-
|
|
155
|
-
`),n.local){let e=t.choice===`local`||t.choice===`both`?w.yellow.bold(`${$.check} LOCAL (keeping)`):w.red.bold(`${$.cross} LOCAL (removing)`),r=n.local.split(`
|
|
156
|
-
`).filter(e=>e!==``),i=r.slice(0,20),a=t.choice===`local`||t.choice===`both`?w.yellow:w.red,o=i.map(e=>a(`- ${e}`)).join(`
|
|
157
|
-
`),s=r.length>20?`\n${w.gray(`... and ${r.length-20} more lines`)}`:``;y.log(`${e}\n\n${o}${s}`)}if(y.log(`
|
|
158
|
-
|
|
159
|
-
`),y.log(w.gray(`_`.repeat(e))),y.log(`
|
|
160
|
-
|
|
161
|
-
`),n.remote){let e=t.choice===`remote`||t.choice===`both`?w.green.bold(`${$.check} REMOTE (accepting)`):w.gray.bold(`${$.pending} REMOTE (skipping)`),r=n.remote.split(`
|
|
162
|
-
`).filter(e=>e!==``),i=r.slice(0,20),a=t.choice===`remote`||t.choice===`both`?w.green:w.gray,o=i.map(e=>a(`+ ${e}`)).join(`
|
|
163
|
-
`),s=r.length>20?`\n${w.gray(`... and ${r.length-20} more lines`)}`:``;y.log(`${e}\n\n${o}${s}`)}y.log(`
|
|
164
|
-
|
|
165
|
-
`),y.log(w.gray(`_`.repeat(e))),y.log(``)}renderControls(e){let t=[w.green(`[R] Accept Remote`),w.yellow(`[L] Keep Local`),w.cyan(`[B] Keep Both`),w.gray(`[U] Undo`)],n=[w.gray(`[←/→] Navigate`),w.gray(`[A] Accept all remaining`)],r=this.allResolved()?[w.green.bold(`[Enter] Apply Changes`),w.gray(`[Esc] Cancel`)]:[w.gray(`[Enter] Next Unresolved`),w.gray(`[Esc] Cancel`)];y.log(this.centerText(t.join(` `),e)),y.log(``),y.log(this.centerText(n.join(` `),e)),y.log(``),y.log(this.centerText(r.join(` `),e)),this.allResolved()&&(y.log(``),y.log(w.green.bold(this.centerText(`✓ All conflicts resolved!`,e))))}renderFinalSummary(){v();let e=this.conflicts.filter(e=>e.conflict.type===`conflict`),t=0,n=0,r=0;for(let i of e)switch(i.choice){case`remote`:t++;break;case`local`:n++;break;case`both`:r++;break}let i=[w.green.bold(`Conflict resolution complete`),``,`${w.bold(this.totalConflicts)} conflicts resolved:`,``,`${w.green($.acceptRemote)} Accepted remote: ${t}`,`${w.yellow($.acceptLocal)} Kept local: ${n}`,`${w.cyan($.acceptBoth)} Kept both: ${r}`];y.box(i.join(`
|
|
166
|
-
`))}renderCancelled(){v(),y.log(w.yellow(`Conflict resolution cancelled`)),y.log(``),y.log(`No changes were made to your local connector file.`)}getCurrentConflictIndex(){let e=-1;for(let t=0;t<=this.currentIndex&&t<this.conflicts.length;t++)this.conflicts[t].conflict.type===`conflict`&&e++;return e}moveToNextConflict(){for(let e=this.currentIndex+1;e<this.conflicts.length;e++)if(this.conflicts[e].conflict.type===`conflict`){this.currentIndex=e;return}for(let e=0;e<this.currentIndex;e++)if(this.conflicts[e].conflict.type===`conflict`){this.currentIndex=e;return}}moveToPrevConflict(){for(let e=this.currentIndex-1;e>=0;e--)if(this.conflicts[e].conflict.type===`conflict`){this.currentIndex=e;return}for(let e=this.conflicts.length-1;e>this.currentIndex;e--)if(this.conflicts[e].conflict.type===`conflict`){this.currentIndex=e;return}}moveToNextUnresolved(){for(let e=this.currentIndex+1;e<this.conflicts.length;e++)if(this.conflicts[e].conflict.type===`conflict`&&this.conflicts[e].choice===`pending`){this.currentIndex=e;return}for(let e=0;e<this.currentIndex;e++)if(this.conflicts[e].conflict.type===`conflict`&&this.conflicts[e].choice===`pending`){this.currentIndex=e;return}}setCurrentChoice(e){this.conflicts[this.currentIndex]?.conflict.type===`conflict`&&(this.conflicts[this.currentIndex].choice=e)}allResolved(){return this.conflicts.filter(e=>e.conflict.type===`conflict`).every(e=>e.choice!==`pending`)}acceptAllRemaining(e){for(let t of this.conflicts)t.conflict.type===`conflict`&&t.choice===`pending`&&(t.choice=e)}centerText(e,t){let n=this.stripAnsi(e),r=Math.max(0,Math.floor((t-n.length)/2));return` `.repeat(r)+e}stripAnsi(e){return e.replace(/\x1b\[[0-9;]*m/g,``)}getResolvedContent(){let e=[];for(let t of this.conflicts)if(t.conflict.type===`unchanged`)e.push(t.conflict.content||``);else if(t.conflict.type===`conflict`)switch(t.choice){case`remote`:t.conflict.remote&&e.push(t.conflict.remote);break;case`local`:t.conflict.local&&e.push(t.conflict.local);break;case`both`:t.conflict.local&&e.push(t.conflict.local),t.conflict.remote&&e.push(t.conflict.remote);break;case`pending`:t.conflict.remote&&e.push(t.conflict.remote);break}return e.join(``)}};const On=`https://api.stackone.com`;var kn=class{async execute({profile:e,connector:n,outputPath:r,apiUrl:i,apiKey:a,owner:o}={}){if(Y(n)&&(y.error(`Connector identifier is required`),y.log(`Please provide a connector identifier using the ${t(`--connector`)} option in the format: ${t(`provider_key@version`)} or ${t(`provider_key`)}`),y.log(`If no version is specified, the latest version will be pulled.`),process.exit(1)),!e&&!a&&(y.error(`Profile or API key is required`),y.log(`Please provide a profile using the ${t(`--profile`)} option or an API key using the ${t(`--api-key`)} option.`),y.log(`To create a profile, run ${t(`stackone init`)}.`),process.exit(1)),e&&a&&(y.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&i&&y.warn(`Specifying ${t(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!gn(e)){y.error(`Configuration profile ${t(e)} not found`),y.log(`Run ${t(`stackone init`)} to create a new configuration profile.\n`);let n=vn();n.length>0&&(y.info(`Available configuration profiles:`),n.forEach(e=>{y.log(` - ${w.blue(e)}`)})),process.exit(1)}let s=e?hn(e):{apiUrl:i??On,apiKey:a};s?.apiKey||(y.error(`API key is missing`),y.log(`Please provide a valid API key in the profile or via the ${t(`--api-key`)} option.`),process.exit(1));let c=s.apiUrl??On,[l,u]=n.split(`@`),d=await this.#f(l,c,s.apiKey,u??`latest`,o),f=this.#e(d),p=f.version??`unknown`,m=this.#t(r,f.key,p),h=this.#r(m),g=h===null,_=d;if(!g){let e=this.#i(h,m);e&&(y.warn(e.message),e.errors.length>0&&x(e.errors,!1),y.log(``));let t=e?void 0:this.#e(h);if(this.#o(h,d)){this.#a(h,d,m);let e=t?.version??`unknown`,r=await this.#s(h,d,n,e,p);r.action===`cancel`&&(Ie(`Pull cancelled`),process.exit(0)),r.action===`keep-local`&&(y.log(``),y.info(`Keeping local version. No changes made.`),process.exit(0)),r.action===`interactive-cancel`&&process.exit(0),r.action===`interactive`&&(_=r.resolvedContent)}else y.info(`No changes detected in connector configuration.`),process.exit(0)}let ee=Ke(_).connector,v=ee?.key??f.key,b=ee?.version??p,S=this.#t(r,v,b),te=S;if(S!==m){let e=await this.#n(S);y.log(``),e!==void 0&&(te=e)}await this.#d(te,_),g?y.success(`Connector ${t(v)}@${t(b)} pulled successfully (new connector)`):y.success(`Connector ${t(v)}@${t(b)} updated successfully`);let ne=v===f.key?t(v):`${t(f.key)} ${w.whiteBright(`→`)} ${t(v)}`,C=b===p?t(b):`${t(p)} ${w.whiteBright(`→`)} ${t(b)}`,T=te===m?t(te):`${t(m)}\n ${w.whiteBright(`→`)} ${t(te)}`;y.log(`\n${w.blue.inverse(` CONNECTOR DETAILS `)}\n`),y.log(` Provider: ${ne}`),y.log(` Version: ${C}`),y.log(` Output file: ${T}`),process.exit(0)}#e(e){let n=Ke(e),r=n?.errors??[];if(n.success)return n.connector;y.error(`Connector pulled from the registry is not valid`),y.log(`Please make sure you are using the latest version of the StackOne CLI by running ${t(`stackone update`)}`),r.length>0&&x(r,!0),process.exit(1)}#t(e,n,r){let i=`${n}_v${r.replaceAll(`.`,`-`)}.s1.yaml`;return e?(U.existsSync(e)&&(U.statSync(e).isDirectory()||(y.error(`Output path ${t(e)} is not a directory`),y.log(`Please provide a valid directory path to store connectors or use the default path.`),process.exit(1))),W.resolve(e,n,i)):W.resolve(process.cwd(),`connectors`,n,i)}async#n(e){if(!U.existsSync(e))return;let n=W.basename(e),r=W.dirname(e);y.warn(`File ${t(n)} already exists at ${t(r)}`);let i=await He({message:`How would you like to proceed?`,options:[{value:`override`,label:`Override existing file`,hint:`Replace the existing file with the new content`},{value:`rename`,label:`Save with a different name`,hint:`Provide a new filename for the connector`},{value:`cancel`,label:`Cancel`,hint:`Abort the pull operation`}]});if((ze(i)||i===`cancel`)&&(Ie(`Operation cancelled. No local changes were made.`),process.exit(0)),i===`override`)return;let a=await Ue({message:`Enter the new filename:`,placeholder:n,validate:e=>{if(!e||e.trim()===``)return`Filename cannot be empty`;if(!e.endsWith(`.s1.yaml`))return`Filename must end with .s1.yaml`;let t=W.join(r,e.trim());if(U.existsSync(t))return`File ${e} already exists`}});return ze(a)&&(Ie(`Operation cancelled. No local changes were made.`),process.exit(0)),W.join(r,a.trim())}#r(e){if(!U.existsSync(e))return null;try{return U.readFileSync(e,`utf-8`)}catch{return null}}#i(e,n){try{let r=Ke(e);if(!r.success){let e=r.errors??[];return{message:`Local connector ${t(W.basename(n))} has validation errors:`,errors:e}}}catch(e){return{message:`Local connector ${t(W.basename(n))} could not be validated: ${e.message}`,errors:[]}}return null}#a(e,t,n){let r=qe(e,t);if(!r.some(e=>e.added||e.removed)){y.info(`No changes detected in connector configuration.`);return}y.log(`${w.blue.inverse(` CHANGES `)}\n`),y.log(w.gray(`--- local: ${n}`)),y.log(w.gray(`+++ remote: StackOne Registry`)),y.log(``);let i=0,a=0;for(let e of r){let t=e.value.split(`
|
|
167
|
-
`).filter(e=>e!==``);if(e.added){i+=t.length;for(let e of t)y.log(w.green(`+ ${e}`))}else if(e.removed){a+=t.length;for(let e of t)y.log(w.red(`- ${e}`))}else if(t.length<=6)for(let e of t)y.log(w.gray(` ${e}`));else{for(let e=0;e<3;e++)y.log(w.gray(` ${t[e]}`));y.log(w.gray(` ... (${t.length-6} unchanged lines)`));for(let e=t.length-3;e<t.length;e++)y.log(w.gray(` ${t[e]}`))}}y.log(``),y.log(w.gray(`Summary: ${w.green(`+${i}`)} additions, ${w.red(`-${a}`)} deletions`))}#o(e,t){return qe(e,t).some(e=>e.added||e.removed)}async#s(e,t,n,r,i){y.log(``);let a=await He({message:`How would you like to resolve the differences?`,options:[{value:`override`,label:`Override local with remote`,hint:`Replace your local file with the StackOne version`},{value:`keep-local`,label:`Keep local version`,hint:`Cancel the pull and keep your current file`},{value:`interactive`,label:`Resolve conflicts interactively`,hint:`Choose which changes to accept one by one`},{value:`cancel`,label:`Cancel`,hint:`Abort the pull operation`}]});if(ze(a))return{action:`cancel`};if(a===`override`)return{action:`override`};if(a===`keep-local`)return{action:`keep-local`};if(a===`interactive`){let a=await this.#c(e,t,n,r,i);return a===null?{action:`interactive-cancel`}:{action:`interactive`,resolvedContent:a}}return{action:`cancel`}}async#c(e,t,n,r,i){let a=qe(e,t),o=this.#u(a);if(o.length===0)return y.info(`No conflicts to resolve.`),t;let s=new Dn(o,n,r,i);for(;;){if((await s.resolve()).cancelled)return null;let e=s.getResolvedContent(),t=Ke(e);if(t.success)return s.renderFinalSummary(),e;let n=await this.#l(t.errors);if(n===`cancel`)return v(),y.info(`Operation cancelled. No changes were made to the local connector.`),null;if(n===`save`)return v(),y.warn(`The connector was saved but it is invalid`),e;s.resetForReResolution()}}async#l(e){let{createInterface:t}=await import(`readline`);return new Promise(n=>{v();let r=(e||[{message:`Unknown validation error`}]).map(e=>` • ${e.message}`).join(`
|
|
168
|
-
`);y.box({title:`⚠️ Validation Failed`,message:`The resolved connector configuration is invalid:\n\n${r}`,style:{borderColor:`yellow`,padding:1}}),y.log(``),y.log(w.bold(` Choose an action:`)),y.log(``),y.log(w.cyan(` [B]`)+` ← Go back to conflict resolution`),y.log(w.dim(` Modify your choices to fix the validation errors`)),y.log(``),y.log(w.yellow(` [S]`)+` 💾 Save anyway`),y.log(w.dim(` Save the invalid configuration (not recommended)`)),y.log(``),y.log(w.red(` [C]`)+` ✖ Cancel`),y.log(w.dim(` Discard all changes`)),y.log(``);let i=t({input:process.stdin,output:process.stdout});process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume();let a=e=>{let t=e.toString().toLowerCase(),r=()=>{process.stdin.removeListener(`data`,a),process.stdin.isTTY&&process.stdin.setRawMode(!1),i.close()};if(t===``||t===`\x1B`){r(),n(`cancel`);return}switch(t){case`b`:r(),n(`back`);break;case`s`:r(),n(`save`);break;case`c`:case`q`:r(),n(`cancel`);break}};process.stdin.on(`data`,a)})}#u(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!r.added&&!r.removed)t.push({type:`unchanged`,content:r.value}),n++;else if(r.removed){let i=e[n+1];i?.added?(t.push({type:`conflict`,local:r.value,remote:i.value}),n+=2):(t.push({type:`conflict`,local:r.value,remote:void 0}),n++)}else r.added&&t.push({type:`conflict`,local:void 0,remote:r.value}),n++}return t}async#d(e,n){let r=W.dirname(e);U.existsSync(r)||U.mkdirSync(r,{recursive:!0});try{U.writeFileSync(e,n,`utf-8`)}catch(n){y.error(`Failed to write connector to file ${t(e)}: ${n.message}`),process.exit(1)}}async#f(e,n,i,a,o){let s=J(`Pulling connector ${t(e)}@${t(a)} from registry...`).start();try{let r=Buffer.from(i).toString(`base64`),c=`${n}/registry/connectors/${e}@${a}${o?`?owner=${encodeURIComponent(o)}`:``}`,l=await fetch(c,{method:`GET`,headers:{Authorization:`Basic ${r}`}});if(s.stop(),l.status===409){o&&(await this.#p(l,e,a),process.exit(1));let i=(await l.json()).availableOwners??[],c=await Sn(`${e}@${a}`,i);s.text=`Pulling connector ${t(e)}@${t(a)} from registry...`,s.start();let u=`${n}/registry/connectors/${e}@${a}`,d=await fetch(`${u}?owner=${encodeURIComponent(c)}`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});return s.stop(),d.ok||(await this.#p(d,e,a),process.exit(1)),await d.text()}return l.ok||(await this.#p(l,e,a),process.exit(1)),await l.text()}catch(i){s.stop(),y.error(`Failed to pull connector ${t(e)}@${t(a)} from the registry: ${i.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid.`),process.exit(1)}}async#p(e,n,r){switch(e.status){case 401:case 403:y.error(`Access denied`),y.log(`Please ensure that your API key is valid and has the ${t(`connectors:read`)} scope required to pull connectors.`);break;case 404:y.error(`Connector ${t(n)}@${t(r)} was not found in the registry`),await this.#m(n);break;case 429:y.error(`Rate limit exceeded`),y.log(`Too many requests. Please wait a moment before trying again.`);break;default:await b(e,`Failed to pull connector ${t(n)}`)}}async#m(e){y.info(`To see available versions, check the connector documentation or contact support.`)}};const An=`https://api.stackone.com`;var jn=class{async execute({profile:e,fileOrDir:n,apiUrl:r,apiKey:i,force:a}={}){if(!e&&!i&&(y.error(`Profile or API key is required`),y.log(`Please provide a profile using the ${t(`--profile`)} option or an API key using the ${t(`--api-key`)} option.`),y.log(`To create a profile, run ${t(`stackone init`)}.`),process.exit(1)),e&&i&&(y.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&r&&y.warn(`Specifying ${t(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!gn(e)){y.error(`Configuration profile ${t(e)} not found`),y.log(`Run ${t(`stackone init`)} to create a new configuration profile.\n`);let n=vn();n.length>0&&(y.info(`Available configuration profiles:`),n.forEach(e=>{y.log(` - ${w.blue(e)}`)})),process.exit(1)}let o=e?hn(e):{apiUrl:r??An,apiKey:i};o?.apiKey||(y.error(`API key is missing`),y.log(`Please provide a valid API key in the profile or via the ${t(`--api-key`)} option.`),process.exit(1)),n||(y.error(`File or directory is required.`),process.exit(1));try{De(n)}catch{y.error(`File or directory not found: ${w.red(n)}`),process.exit(1)}let s=De(n),c=o.apiUrl??An;if(s.isDirectory()){let e=Fn(n),t=0;e.length===0?(y.error(`No .s1.yaml connector files found in the directory: ${n}.`),process.exit(1)):(y.start(`Found ${e.length} connector(s) file(s). Pushing to registry...`),y.log(``));for(let n of e)await this.uploadFile(n,c,o.apiKey,a)&&t++;t===0?y.error(`Error while pushing connectors: no files were uploaded`):(y.log(``),y.info(`Upload completed: ${w.green(t)} of ${w.blue(e.length)} file(s) uploaded successfully.`)),process.exit(t>0?0:1)}else n.endsWith(`.s1.yaml`)||(y.error(`Only ${t(`.s1.yaml`)} files are supported for upload`),process.exit(1));let l=await this.uploadFile(n,c,o.apiKey,a);process.exit(l?0:1)}async uploadFile(e,n,i,a){let o=J(`📤 Pushing connector in ${G(e)}...`).start();try{let r=Pn(e);if(!r)return!1;let s=G(e),c=new FormData,l=new Blob([r],{type:`application/x-yaml`});c.append(`file`,l,s),a&&c.append(`force`,`true`);let u=Buffer.from(i).toString(`base64`),d=await fetch(`${n}/registry/connectors`,{method:`POST`,headers:{Authorization:`Basic ${u}`},body:c});if(o.stop(),!d.ok)return d.status===409||d.status===422?await this.handleVersionConflict(d,e,n,i,a):(await b(d,`Failed to push connector in ${t(s)} to the registry`),!1);let f=await d.json();return y.success(`Successfully uploaded ${t(s)} with connector ${t(f.provider)}@${t(f.version)}`),!0}catch(i){return o.stop(),y.error(`Failed to upload file ${t(e)}: ${i}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),!1}}async handleVersionConflict(e,n,r,i,a){let o=await e.text(),s;try{s=JSON.parse(o)}catch{}let c=Ye.valid(s?.latestVersion);if(!c)return await b(new Response(o,{status:e.status,statusText:e.statusText}),`Failed to push connector in ${t(G(n))} to the registry`),!1;let l=Te(n,`utf-8`),u=Mn(l),d=u?`${t(u)}`:``,f=e.status===409?`Version ${d} already exists in the registry. Latest version: ${t(c)}`:`Version ${d} is lower than the latest version in the registry. Latest version: ${t(c)}`;y.error(f);let p=Ye.inc(c,`patch`)??c,m=Ye.inc(c,`minor`)??c,h=Ye.inc(c,`major`)??c,g=await He({message:`How would you like to proceed?`,options:[{value:p,label:`Bump patch version (${p})`},{value:m,label:`Bump minor version (${m})`},{value:h,label:`Bump major version (${h})`},{value:`cancel`,label:`Cancel push`}]});return ze(g)||g===`cancel`?(Ie(`Push cancelled`),!1):(Oe(n,Nn(l,g),`utf-8`),y.info(`Updated version to ${t(g)} in ${G(n)}`),this.uploadFile(n,r,i,a))}};const Mn=e=>e.match(/^\s*version: (\S+)/m)?.[1],Nn=(e,t)=>e.replace(/^(\s*version: )\S+/m,`$1${t}`),Pn=e=>{let t=We(e),r=Ke(t),i=r?.errors??[];if(r.success)return t;i.length>0?(y.error(`Connector in ${n(e)} is not valid`),x(i,!0)):y.error(`Connector in ${n(e)} is not valid. Please check the file for errors.`)},Fn=e=>{let t=[],n=Ee(e,{withFileTypes:!0});for(let r of n){let n=K(e,r.name);r.isDirectory()?t.push(...Fn(n)):r.name.endsWith(`.s1.yaml`)&&t.push(n)}return t},In=Z.object({provider_key:Z.string().optional(),provider_version:Z.string().optional(),auth_config_key:Z.string(),environment:Z.string().default(`production`),organization_id:Z.string().default(`cli-organization-id`),account_id:Z.string().default(`cli-account-secure-id`),project_id:Z.string().default(`cli-project-secure-id`),credentials:Z.record(Z.string(),Z.any()).default({})}),Ln=Z.record(Z.string(),Z.any()),Rn=Z.object({path:Z.record(Z.string(),Z.any()).default({}),queryParams:Z.record(Z.string(),Z.any()).default({}),header:Z.record(Z.string(),Z.any()).default({}),body:Z.record(Z.string(),Z.any()).default({})}),zn=`https://api.stackone.com`;var Bn=class{async execute({connector:e,action:n,actionId:r,account:i,accountId:a,params:s,credentials:c,profile:l,outputFile:u,debug:d,apiUrl:f,apiKey:p,owner:m}={}){if(!l&&!p&&a&&(y.error(`Profile or API key is required when providing an account ID`),y.log(`Please provide a profile using the ${t(`--profile`)} option or an API key using the ${t(`--api-key`)} option.`),y.log(`To create a profile, run ${t(`stackone init`)}.`),process.exit(1)),l&&p&&(y.error(`Please provide either a profile or an API key, not both`),process.exit(1)),l&&f&&y.warn(`Specifying --api-url with a profile won't have any effect. Using API url from profile.`),l&&!gn(l)){y.error(`Configuration profile ${t(l)} not found`),y.log(`Run ${t(`stackone init`)} to create a new configuration profile.\n`);let e=vn();e.length>0&&(y.info(`Available configuration profiles:`),e.forEach(e=>{y.log(` - ${w.blue(e)}`)})),process.exit(1)}let h=l?hn(l):{apiUrl:f??zn,apiKey:p};Y(i)&&Y(a)&&(y.error(`A valid account or account ID is required to run an action`),process.exit(1));let g;if(X(e))if(this.#a(e)){!l&&!p&&(y.error(`Profile or API key is required when using a connector identifier`),y.log(`Please provide a profile using the ${t(`--profile`)} option or an API key using the ${t(`--api-key`)} option.`),y.log(`Run ${t(`stackone init`)} to create a new configuration profile.`),process.exit(1));let n=this.#o(e);g=await this.#s(n,h?.apiUrl??zn,h?.apiKey,m)}else g=this.#e(e);else X(a)&&(g=await this.#c(a,h?.apiUrl??zn,h?.apiKey));let _=X(n)?this.#r(n,e):g;Y(_)&&(y.error(`A valid connector is required to run an action.`),process.exit(1));let ee=X(_?.actions)?Object.keys(_?.actions).length:0,v=X(_?.actions)?Object.keys(_.actions)[ee-1]:void 0,b=X(v)?_?.actions?.[v]?.id:void 0,x=(X(r)&&!r?.startsWith(`${_.key}_`)?`${_.key}_${r}`:r)??b;Y(x)&&(y.error(`A valid action ID is required to run an action`),process.exit(1));let S=X(a)?await this.#l(a,h?.apiUrl??zn,h?.apiKey):{},te=X(i)?this.#i(i,_.key??`unknown`,_.version??`unknown`):void 0,ne=X(c)?this.#u(c):{},C={...S,...te,credentials:{...S.credentials??{},...ne}};Y(C)&&(y.error(`A valid account data is required to run an action.`),process.exit(1));let T=_.actions?.[x];Y(T)&&(y.error(`Action ID ${t(x)} not found in the connector ${t(_.key)}@${t(_.version)}.`),process.exit(1));let re=X(s)?this.#d(s,x):{path:{},queryParams:{},header:{},body:{}},E=Date.now(),ie=await this.#f({connector:_,actionId:x,account:C,queryParams:{...re.queryParams,...d?{debug:`true`}:{}},pathParams:re.path,body:re.body,headers:re.header}),ae=Date.now()-E;if(X(u))try{U.writeFileSync(u,JSON.stringify(ie.output,null,2),`utf-8`),y.info(`Output written to file: ${u}`)}catch(e){y.error(`Failed to write output to file ${u}: ${e.message}`),process.exit(1)}else y.log(`\n${w.blue.inverse(` ACTION OUTPUT `)}`),o(ie.output);y.log(``),y.info(`Action ${t(x)} from connector ${t(_?.key)}@${t(_?.version)} finished in ${w.yellowBright((ae/1e3).toFixed(2))} seconds.`),process.exit(0)}#e=e=>{let t=e;try{t=We(e)}catch{}return t?this.#n(t):void 0};#t=e=>{try{return We(e)}catch(n){y.error(`Failed to load connector file from ${t(e)}: ${n.message}`),process.exit(1)}};#n=e=>{let t=Ke(e),n=t?.errors??[];if(t.success)return t.connector||(y.error(`Failed to load connector.`),process.exit(1)),t.connector;n.length>0?(y.error(`Connector is not valid`),x(n,!0),process.exit(1)):(y.error(`Connector is not valid. Please check the file for errors.`),process.exit(1))};#r=(e,t)=>{let n=e;try{n=U.readFileSync(e,`utf-8`)}catch{}Y(t)&&(y.error(`A valid connector is required to load an action.`),process.exit(1));let r=`${this.#t(t)} - ${n.split(`
|
|
169
|
-
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
170
|
-
`)}`;return this.#n(r)};#i=(e,t,n)=>{let r=e;try{r=U.readFileSync(e,`utf-8`)}catch{}try{let e=In.parse(JSON.parse(r));return{providerKey:t,providerVersion:n,authConfigKey:e.auth_config_key,environment:e.environment,organizationId:e.organization_id,secureId:e.account_id,projectSecureId:e.project_id}}catch(e){let t=[];try{t=JSON.parse(e.message)}catch{}y.error(`Failed to parse account information`),x(t,!1),t.length===0&&y.log(e.message),process.exit(1)}};#a=e=>!e.includes(`/`)&&!e.includes(`\\`)&&!e.endsWith(`.yaml`)&&!e.endsWith(`.yml`)?e.includes(`@`)?e.split(`@`).length===2:!0:!1;#o=e=>e.includes(`@`)?e:`${e}@latest`;#s=async(e,n,i,a)=>{(Y(e)||Y(n)||Y(i))&&(y.error(`Connector identifier, API URL, and API key are required to fetch connector from registry.`),process.exit(1));let o=J();try{o.text=`Fetching connector ${t(e)} from registry...`,o.start();let r=Buffer.from(i).toString(`base64`),s=a?`?owner=${encodeURIComponent(a)}`:``,c=await fetch(`${n}/registry/connectors/${e}${s}`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});if(o.stop(),c.status===409){a&&(await b(c,`Failed to fetch connector ${t(e)} from registry`),process.exit(1));let i=await Sn(e,(await c.json()).availableOwners??[]);o.text=`Fetching connector ${t(e)} from registry...`,o.start();let s=await fetch(`${n}/registry/connectors/${e}?owner=${encodeURIComponent(i)}`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});o.stop(),s.ok||(await b(s,`Failed to fetch connector ${t(e)} from registry`),process.exit(1));let l=await s.text(),u=this.#n(l);return y.success(`Fetched connector ${t(u.key)}@${t(u.version)} from registry`),u}c.ok||(await b(c,`Failed to fetch connector ${t(e)} from registry`),process.exit(1));let l=await c.text(),u=this.#n(l);return y.success(`Fetched connector ${t(u.key)}@${t(u.version)} from registry`),u}catch(i){o.stop(),y.error(`Failed to fetch connector ${t(e)} from registry: ${i.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),process.exit(1)}};#c=async(e,n,i)=>{(Y(e)||Y(n)||Y(i))&&(y.error(`Account ID, API URL, and API key are required to fetch connector`),process.exit(1));let a=J();try{a.text=`Fetching connector for account ${t(e)} from API...`,a.start();let r=Buffer.from(i).toString(`base64`),o=await fetch(`${n}/accounts/${e}/connector`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});a.stop(),o.ok||(await b(o,`Failed to fetch connector`),process.exit(1));let s=await o.text(),c=this.#n(s);return y.success(`Fetched connector ${t(c.key)}@${t(c.version)} for account ${t(e)}`),c}catch(e){a.stop(),y.error(`Failed to fetch connector: ${e.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),process.exit(1)}};#l=async(e,n,i)=>{(Y(e)||Y(n)||Y(i))&&(y.error(`Account ID, API URL, and API key are required to fetch account information.`),process.exit(1));let a=J();try{a.text=`Fetching account ${t(e)} information from API...`,a.start();let r=Buffer.from(i).toString(`base64`),o=await fetch(`${n}/accounts/${e}/credentials`,{method:`GET`,headers:{Authorization:`Basic ${r}`}});a.stop(),o.ok||(await b(o,`Failed to fetch account ${t(e)} information`),process.exit(1));let s=await o.json();return y.success(`Fetched account ${t(e)} information from project ${t(s.project_id)}`),{providerKey:s.provider_key,providerVersion:s.provider_version,authConfigKey:s.auth_config_key,environment:s.environment,organizationId:s.organization_id,secureId:s.account_id,projectSecureId:s.project_id,credentials:s.credentials}}catch(i){a.stop(),y.error(`Failed to fetch account ${t(e)} information: ${i.message}`),y.log(`Please ensure that the API at ${r(n)} is reachable and the API key is valid`),process.exit(1)}};#u=e=>{let t=e;try{t=U.readFileSync(e,`utf-8`)}catch{}try{return Ln.parse(JSON.parse(t))}catch(e){let t=[];try{t=JSON.parse(e.message)}catch{}y.error(`Failed to parse credentials`),x(t,!1),t.length===0&&y.log(e.message),process.exit(1)}};#d=(e,n)=>{let r=e;try{r=U.readFileSync(e,`utf-8`)}catch{}try{return Rn.parse(JSON.parse(r))}catch(e){let r=[];try{r=JSON.parse(e.message)}catch{}y.error(`Invalid parameters for action ${t(n)}.`),x(r,!1),r.length===0&&y.log(e.message),process.exit(1)}};async#f({connector:e,actionId:n,account:r,pathParams:i={},queryParams:a={},body:s={},headers:c={}}){try{let l=await Ge({mode:`action_id`,actionId:n,account:r,connector:e,pathParams:i,queryParams:a,body:s,headers:c,getHttpClient:async()=>new Xe});if(l.response?.successful){let e={...this.#p(a,l.steps),...Fe(l.outputs)?l.outputs:{data:l.outputs}};return{statusCode:l.response?.statusCode,output:e}}else{let r=l.response?.message??`An error occurred while processing the request`;y.error(`Action ID ${t(n)} from connector ${t(e.key)}@${t(e.version)} failed with status ${l.response?.statusCode}: ${r}`);let i={...this.#p(a,l.steps)};Object.keys(i).length>0&&(y.log(`${w.yellow.inverse(` EXECUTION DETAILS `)}`),o(i)),process.exit(1)}}catch(e){this.#m(e)}}#p(e,t){return e?.debug===`true`?{debug:{steps:t}}:{}}#m(e){let t=e;switch(Y(t.errorType)&&(y.error(`An unknown error occurred`),y.log(`${e instanceof Error?e.message:String(e)}`),process.exit(1)),t.errorType){case`MISSING_ACTION_ERROR`:y.error(`The specified action was not found: ${t.message}`);break;case`INVALID_ACTION_INPUTS_ERROR`:let e=t;y.error(`Invalid action inputs`),x(e.validationErrors,!1);break;case`INVALID_CURSOR_ERROR`:y.error(`Invalid cursor: ${t.message}`);break;default:y.error(`An error occurred: ${t.message}`)}process.exit(1)}};const Vn=()=>{try{let e=K(ke(Qe(import.meta.url)),`..`,`package.json`);return JSON.parse(Te(e,`utf8`)).version}catch{return`unknown`}},Hn=Ze(xe);var Un=class{constructor(){this.packageName=`@stackone/cli`,this.spinner=J(),this.currentVersion=Vn()}async execute(e={}){this.spinner.text=`Checking for updates...`,this.spinner.start();try{let t=await this.getLatestVersion();this.spinner.stop(),t||(y.error(`Failed to check for updates`),process.exit(1)),this.isNewerVersion(t,this.currentVersion)?(y.box(`New version available: ${w.yellow(this.currentVersion)} → ${w.green(t)}`),await this.performUpdate(t)):e.force?(y.warn(`No updates available, but forcing reinstall...`),await this.performUpdate(t)):y.success(`You are already on the latest version (${this.currentVersion})`),process.exit(0)}catch(e){this.spinner.stop(),y.error(`Error while trying to update StackOne CLI: ${e?.message??`Unknown error`}`),process.exit(1)}}async getLatestVersion(){try{let{stdout:e}=await Hn(`npm view ${this.packageName} version`,{encoding:`utf-8`});return e.trim()}catch{return null}}isNewerVersion(e,t){return Ye.gt(e,t)}isUsingVolta(){if(typeof process.env.VOLTA_HOME!=`string`||process.env.VOLTA_HOME.length===0)return!1;let e=I(process.env.VOLTA_HOME,`bin`),t=I(e,`stackone`),n=I(e,`stackone.exe`);return j(t)||j(n)}async performUpdate(e){let n=this.isUsingVolta();this.spinner.text=`Updating to latest version (${t(e)})...`,this.spinner.start();try{await Hn(n?`volta install ${this.packageName}@latest`:`npm install -g ${this.packageName}@latest`,{encoding:`utf-8`}),this.spinner.stop(),y.success(`StackOne CLI updated successfully to latest version (${t(e)})`)}catch{this.spinner.stop();let e=n?`volta install ${this.packageName}@latest`:`npm install -g ${this.packageName}@latest`;throw Error(`Failed to install update. Please try manually: ${e}`)}}};const Wn=()=>{y.log(`${w.gray.inverse(` CONNECTORS VALIDATION `)} ${w.yellow.inverse(` WATCH MODE `)}\n`)};var Gn=class{async execute(e){let{watchMode:t,fileOrDir:n}=e,r=J(`Watching for file changes... ${w.gray(`(press "q" to quit)`)}`);if(!n)return;let i=q(n);try{await et(i)}catch{y.error(`The specified path does not exist: ${i}\n`),process.exit(1)}if(t){v();let e={},{watch:t}=await import(`chokidar`),n=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding(`utf8`);let a=()=>{s.close(),r.stop(),n.close(),y.log(w.grey(`
|
|
171
|
-
Exiting watch mode...`)),process.exit(0)};Wn(),y.start(`Validating connectors...`);let o=await Yn(i);e=Kn(e,o||{}),qn(e,i),r.start();let s=t(i,{persistent:!0,ignoreInitial:!0}),c=async t=>{if(!t.endsWith(`.s1.yaml`)&&!t.endsWith(`s1.partial.yaml`))return;let n=t.endsWith(`s1.partial.yaml`)?await Zn(t):[t];if(!(!n||n.length===0)){v(),r.stop(),Wn(),y.log(w.gray(`File change detected: ${t}`)),y.start(`Validating connectors...`);for(let t of n){let n=await Yn(t);e=Kn(e,n||{})}qn(e,i),r.start()}};s.on(`change`,async e=>await c(e)),process.stdin.on(`data`,e=>{e.toString()===`q`&&a()}),process.on(`SIGINT`,()=>{a()})}else await Yn(i,y),process.exit(0)}};const Kn=(e,t)=>{for(let[n,r]of Object.entries(t))e[n]=r;return e},qn=(e,n)=>{v(),Wn();let r=0,i=0;for(let[n,a]of Object.entries(e))a===null?r++:(y?.error(`Connector ${t(n)} is not valid`),x(a,!0),i++);y.log(``),y.log(w.blue.inverse(` Validation Summary `)),y.log(`Connectors path: ${t(n)}`),y.log(`${r===0?w.red(`0`):w.green(r)} valid, ${i===0?w.green(`0`):w.red(i)} invalid connectors\n`)},Jn=async e=>{let t=[],n=await $e(e);for(let r of n){let n=K(e,r),i=await et(n);i.isDirectory()?t.push(...await Jn(n)):i.isFile()&&r.endsWith(`.s1.yaml`)&&t.push(n)}return t},Yn=async(e,r)=>{let i=await et(e),a={};if(i.isDirectory()){let i=await Jn(e);if(i.length===0)return r?.error(`No StackOne connector found in ${n(e)}`),r?.log(`Connector files need to have the extension ${t(`*.s1.yaml`)}`),null;let o=0,s=0;for(let e of i){let t=await Xn(e,r);t===null?o++:(r?.log(``),s++),a[e]=t}return r?.log(``),r?.log(w.blue.inverse(` Validation Summary `)),r?.log(`${o===0?w.red(`0`):w.green(o)} valid, ${s===0?w.green(`0`):w.red(s)} invalid connectors`),a}else if(i.isFile()&&e.endsWith(`s1.yaml`))return a[e]=await Xn(e,r),a;else if(i.isFile()&&e.endsWith(`partial.yaml`)){r?.error(`Partial connector files cannot be validated directly`),r?.log(`The file ${n(e)} is a partial connector file.`);let i=await Zn(e);return i&&i?.length>0&&r?.log(`Did you mean ${t(i[0])}?`),null}else return r?.error(`No StackOne connector found in ${n(e)}`),r?.log(`Connector files need to have the extension ${t(`*.s1.yaml`)}`),null},Xn=async(e,n)=>{let r=Ke(We(e)),i=r?.errors??[];if(r.success){let r=e.split(`/`).pop()||e;return n?.success(`Connector ${t(r)} is valid!`),null}else if(i.length>0)return n?.error(`Connector ${t(e)} is not valid`),n&&x(i,!0),i;else return n?.error(`Connector ${t(e)} is not valid. Please check the file for errors`),[]},Zn=async e=>{let t=ke(e);try{return(await $e(t)).filter(e=>e.endsWith(`.s1.yaml`))?.map(e=>K(t,e))}catch{}};function Qn(e){if(!e)return!1;try{let{hostname:t}=new URL(e);return t===`stackone-dev.com`||t.endsWith(`.stackone-dev.com`)}catch{return!1}}function $n(){return process.env.AI_TELEMETRY_URL?process.env.AI_TELEMETRY_URL:[process.env.AUTH_SERVER_URL,process.env.STACKONE_API_URL].some(Qn)?`https://ai-telemetry.stackone-dev.com`:`https://ai-telemetry.stackone.com`}function er(){let e=process.env.STACKONE_AGENT_TOKEN,t=process.env.LANGSMITH_PROJECT||`stackone-agent-cli`;if(process.env.AI_TELEMETRY_URL=$n(),e)try{ue({apiKey:e,projectName:t}),process.env.VERBOSE&&console.log(`[Telemetry] Initialized for project:`,t)}catch(e){process.env.VERBOSE&&console.error(`[Telemetry] Failed to initialize:`,e)}}const tr=I(me(),`.stackone`),nr=I(tr,`version-check.json`),rr=(e=!1)=>{let t=sr(),n=Date.now();if(e||!t||n-t.lastCheckTime>1728e5){let e=ir();e&&ar(e)&&or(e),cr({lastCheckTime:n})}},ir=()=>{try{return Ce(`npm view @stackone/cli version`,{encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`],timeout:15e3}).trim()}catch{return null}},ar=e=>{try{let t=Vn();return Ye.gt(e,t)}catch{return!1}},or=e=>{let t=Vn(),n=`Update available: ${w.dim(t)} → ${w.green(e)}`,r=`\n\nRun ${w.cyan(`stackone update`)} to update`;y.box(n,r)},sr=()=>{try{if(!j(nr))return null;let e=fe(nr,`utf-8`);return JSON.parse(e)}catch{return null}},cr=e=>{try{j(tr)||de(tr,{recursive:!0}),M(nr,JSON.stringify(e,null,2),`utf-8`)}catch{}};var lr=class{constructor(e=new re,t=Vn()){this.program=e,this.version=t,er(),this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne CLI`).version(this.version,`-v, --version`)}registerCommands(){let e=new En,t=new jn,n=new kn,r=new bn,i=new wn,a=new Gn,o=new on,s=new dn,c=new Wt,l=new Ut,u=new cn,d=new fn,f=new Bn,p=new Un;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(e,t)=>{t(w.red(e))}}),this.program.command(`init`).option(`-e, --env <environment>`,`Specify the environment for the configuration profile`).description(`Initialize & create a StackOne CLI configuration profile`).action(t=>{e.execute({environment:t.env})}),this.program.command(`push`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).option(`--force`,`Force push the connector, bypassing version conflict checks`).addArgument(new T(`<path>`,`Connector file or directory to push`)).description(`Push a connector to the StackOne registry`).action((e,n)=>{t.execute({profile:n.profile,fileOrDir:e,apiUrl:n.apiUrl,apiKey:n.apiKey,force:n.force})}),this.program.command(`drop`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).addArgument(new T(`<connector>`,`Connector identifier in format provider_key@version`)).description(`Drop a connector from the StackOne registry`).action((e,t)=>{r.execute({profile:t.profile,connector:e,apiUrl:t.apiUrl,apiKey:t.apiKey})}),this.program.command(`get`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).option(`-c, --connector <connector>`,`Connector identifier in format provider_key@version or provider_key (defaults to latest)`).option(`--account-id <account-id>`,`Account ID to fetch connector from`).option(`-f, --format <format>`,`Output format: yaml or json (default: yaml)`,`yaml`).option(`-o, --output-file <output-file>`,`File to write the output to`).option(`--builtin`,`Use the builtin (StackOne) version of the connector`).option(`--custom`,`Use the custom (organization) version of the connector`).option(`--owner <owner>`,`Owner to use for disambiguating connector versions`).description(`Get a connector from the StackOne registry`).action(e=>{[e.builtin,e.custom,e.owner].filter(Boolean).length>1&&(y.error(`--builtin, --custom, and --owner are mutually exclusive. Please provide only one.`),process.exit(1)),i.execute({profile:e.profile,connector:e.connector,accountId:e.accountId,format:e.format,outputFile:e.outputFile,apiUrl:e.apiUrl,apiKey:e.apiKey,owner:e.builtin?`builtin`:e.custom?`custom`:e.owner})}),this.program.command(`pull`).option(`-c, --connector <connector>`,`Connector identifier in format provider_key@version or provider_key`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).option(`-o, --output <path>`,`Output directory for the connectors files (default: ./connectors)`).option(`--builtin`,`Use the builtin (StackOne) version of the connector`).option(`--custom`,`Use the custom (organization) version of the connector`).option(`--owner <owner>`,`Owner to use for disambiguating connector versions`).description(`Pull a connector configuration from StackOne registry to local filesystem`).action(e=>{[e.builtin,e.custom,e.owner].filter(Boolean).length>1&&(y.error(`--builtin, --custom, and --owner are mutually exclusive. Please provide only one.`),process.exit(1)),n.execute({profile:e.profile,connector:e.connector,outputPath:e.output,apiUrl:e.apiUrl,apiKey:e.apiKey,owner:e.builtin?`builtin`:e.custom?`custom`:e.owner})}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new T(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{a.execute({watchMode:t.watch,fileOrDir:e})}),this.program.command(`run`).option(`--connector <connector>`,`Connector file, inline YAML, or identifier (provider_key@version or provider_key for latest)`).option(`--action <action>`,`Action to execute on the connector (path to file or inline string action code)`).option(`--action-id <action-id>`,`Action ID to execute on the connector`).option(`--account <account>`,`Account details to use for running the connector (path to file or inline string account data)`).option(`--account-id <account-id>`,`Account ID to use for running the connector against (fetches connector from API if --connector not provided)`).option(`--params <params>`,`Action parameters (path to file or inline string with JSON parameters)`).option(`--credentials <credentials>`,`Credentials to use (path to file or inline string with JSON credentials)`).option(`-p, --profile <label>`,`Configuration profile to use`).option(`--api-url <api url>`,`API URL`).option(`--api-key <api key>`,`API Key`).option(`-o, --output-file <output-file>`,`File to write the output to`).option(`-d, --debug`,`Enables debug mode to include more details in the action execution output`).option(`--builtin`,`Use the builtin (StackOne) version of the connector`).option(`--custom`,`Use the custom (organization) version of the connector`).option(`--owner <owner>`,`Owner to use for disambiguating connector versions`).description(`Run a connector action`).action(e=>{[e.builtin,e.custom,e.owner].filter(Boolean).length>1&&(y.error(`--builtin, --custom, and --owner are mutually exclusive. Please provide only one.`),process.exit(1)),f.execute({connector:e.connector,action:e.action,actionId:e.actionId,account:e.account,accountId:e.accountId,params:e.params,credentials:e.credentials,profile:e.profile,outputFile:e.outputFile,debug:e.debug,apiUrl:e.apiUrl,apiKey:e.apiKey,owner:e.builtin?`builtin`:e.custom?`custom`:e.owner})});let m=this.program.command(`agent`).description(`StackOne agent commands`);m.command(`setup`).option(`-g, --global`,`Setup global configuration (default)`).option(`-l, --local`,`Setup local project configuration`).option(`--legacy`,`Use email/password login instead of browser-based auth`).option(`--email <email>`,`Email for legacy login (or set STACKONE_EMAIL); requires --legacy`).option(`--password <password>`,`Password for legacy login (or set STACKONE_PASSWORD); requires --legacy. Prefer --password-stdin`).option(`--password-stdin`,`Read password for legacy login from stdin; requires --legacy`).description(`Setup StackOne agent (global or local)`).action(e=>{e.global&&e.local&&(y.error(`--global and --local are mutually exclusive. Please provide only one.`),process.exit(1));let t=e.email!==void 0,n=e.password!==void 0,r=e.passwordStdin===!0;n&&r&&(y.error(`--password and --password-stdin are mutually exclusive. Please provide only one.`),process.exit(1)),(t||n||r)&&!e.legacy&&(y.error(`--email, --password, and --password-stdin require --legacy.`),process.exit(1)),t&&e.email.trim()===``&&(y.error(`--email cannot be empty.`),process.exit(1)),n&&e.password===``&&(y.error(`--password cannot be empty.`),process.exit(1)),r&&(t||process.env.STACKONE_EMAIL?.trim()||(y.error(`--password-stdin requires --email or STACKONE_EMAIL (stdin is consumed for the password, so email cannot be prompted).`),process.exit(1)));let i={email:e.email,password:e.password,passwordFromStdin:r};e.local?s.execute({legacy:!!e.legacy,credentials:i}):o.execute({legacy:!!e.legacy,credentials:i})}),m.command(`cleanup`).description(`Remove all API keys and credentials from configurations`).action(()=>{c.execute()}),m.command(`run`).description(`Run the agent once with a prompt (non-interactive)`).argument(`<prompt>`,`What to do`).option(`-m, --mode <mode>`,`Mode: build, test, or research`,`build`).option(`--max-turns <n>`,`Max agent turns`,`25`).option(`-v, --verbose`,`Verbose output`).action(async(e,t)=>{let n=[`build`,`test`,`research`],r=t.mode??`build`;n.includes(r)||(y.error(`${w.red(`Invalid mode:`)} ${w.white(r)}. Valid modes are: ${n.join(`, `)}.`),process.exit(1));let i=t.maxTurns?parseInt(String(t.maxTurns),10):void 0;await u.execute({prompt:String(e),mode:r,maxTurns:i!==void 0&&!isNaN(i)?i:void 0,verbose:t.verbose})}),m.command(`skills`).description(`List available agent skills and optional recommendations by mode`).option(`-m, --mode <mode>`,`Show skills recommended for this mode`).action(async e=>{await d.execute({mode:e.mode})}),m.command(`chat`).option(`-m, --mode <mode>`,`Mode: build, test, or research`,`build`).option(`-c, --connector <name>`,`Connector name`).option(`-a, --action <name>`,`Action name`).option(`-g, --goal <goal>`,`Initial goal/message`).option(`-t, --temperature <number>`,`Temperature (0-1, default: 0.5)`,parseFloat).option(`-v, --verbose`,`Enable verbose logging`).description(`Start an interactive chat session with the agent (use /commands in chat)`).action(async e=>{let t=[`build`,`test`,`research`];e.mode&&!t.includes(e.mode)&&(y.error(`❌ Error: Invalid mode "${e.mode}". Must be one of: ${t.join(`, `)}`),process.exit(1)),e.temperature!==void 0&&(isNaN(e.temperature)&&(y.error(`❌ Error: Temperature must be a valid number`),process.exit(1)),(e.temperature<0||e.temperature>1)&&(y.error(`❌ Error: Temperature must be between 0 and 1`),process.exit(1))),l.execute({mode:e.mode,connector:e.connector,action:e.action,goal:e.goal,temperature:e.temperature,verbose:e.verbose})}),this.program.command(`update`).option(`-f, --force`,`Force reinstall even if already on latest version`).description(`Update the CLI to the latest version`).action(e=>{p.execute({force:e.force})}),this.program.command(`version`).description(`Show version information`).action(async()=>{y.log(`${w.inverse.greenBright(`StackOne`)} ${w.grey(`CLI`)} ${w.whiteBright(this.version)}`),rr(!0),process.exit(0)})}run(){process.argv.includes(`version`)||rr(),this.program.parse(process.argv)}};export{lr as t};
|