@stackone/cli 1.24.1 → 1.24.2
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/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cliCore-Bd0YUFKF.cjs +160 -0
- package/dist/cliCore-C8PH3YeQ.mjs +160 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +7 -2
- package/dist/cliCore-BY4hchrt.cjs +0 -160
- package/dist/cliCore-CnBmVgQy.mjs +0 -160
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,p as u,s as d,t as f,u as p}from"./agentConfig-D_NqqTkf.mjs";import{n as m}from"./fileNames-CsjGtN4o.mjs";import{r as h}from"./agentApiKey-XBjE_ul4.mjs";import{n as g,r as _,t as v}from"./setupMigration-DsLJUF0a.mjs";import y from"chalk";import{Argument as b,Command as x}from"commander";import{checkCommandSafety as ee,createAgentSession as S,createDefaultVisualizationRegistry as te,createSkillTracker as ne,executeAgent as re,getAvailableSkillNames as C,getBundledSkillsPath as ie,getSkillsForMode as ae,initUnifiedApiTelemetry as oe}from"@stackone/agent-harness";import*as w from"node:fs";import{existsSync as se,mkdirSync as ce,readFileSync as T,writeFileSync as E}from"node:fs";import*as D from"node:os";import{homedir as le}from"node:os";import*as O from"node:path";import{join as ue}from"node:path";import{Box as k,Static as de,Text as A,render as fe,useApp as pe,useInput as me}from"ink";import j,{useCallback as he,useEffect as M,useMemo as ge,useRef as N,useState as P}from"react";import _e from"ink-spinner";import F from"ora";import I,{readFileSync as L,readdirSync as ve,statSync as ye,writeFileSync as be}from"fs";import R,{basename as z,dirname as xe,join as B,resolve as Se}from"path";import{stdin as V,stdout as H}from"node:process";import{createInterface as Ce}from"node:readline";import U from"inquirer";import{isMissing as W,isObject as we,notMissing as G,z as K}from"@stackone/utils";import{cancel as q,confirm as Te,intro as J,isCancel as Y,outro as Ee,password as De,select as X,text as Z}from"@clack/prompts";import{loadConnector as Oe,runAction as ke,validateYamlConnector as Ae}from"@stackone/connect-sdk";import{diffLines as Q}from"diff";import{createInterface as je}from"readline";import Me from"semver";import{HttpClient as Ne}from"@stackone/transport";import{exec as Pe,execSync as Fe}from"node:child_process";import{promisify as Ie}from"node:util";import{fileURLToPath as Le}from"url";import{readdir as Re,stat as ze}from"fs/promises";function Be(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()}function Ve(e){return e===` `||e===` `||e===`
|
|
2
|
+
`||e===`\r`}function He(e,t){let n=t-1;for(;n>=0&&Ve(e[n]);)n--;for(;n>=0&&!Ve(e[n]);)n--;return n+1}function Ue(e,t){let n=t;for(;n<e.length&&Ve(e[n]);)n++;for(;n<e.length&&!Ve(e[n]);)n++;return n}const We={type:`header`};function Ge(e){return e.filter(e=>!(e.role===`system`&&e.content.startsWith(`TOOL_START:`)))}const Ke=({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:v,onToggleTrust:y,onRewindTo:b,spawnedSubagentActive:x=!1,spawnedSubagentName:ee=`Subagent`,spawnedSubagentComplete:S=!1,queuedMessages:te=[],isProcessingQueue:ne=!1,initInfo:re,pendingDeleteConfirmation:C=null,onConfirmDelete:ie,lastSubmittedUserContent:ae,lastSubmittedUserTimestamp:oe,slashCommands:w=[]})=>{let{exit:se}=pe(),[ce,T]=P(``),[,E]=P(0),D=N(0),[le,O]=P(!0),ue=N(s),[fe,F]=P(-1),I=N(p),L=N(``),[ve,ye]=P([]),[be,R]=P(0),[z,xe]=P(0),[B,Se]=P(!1),[V,H]=P(!1),[Ce,U]=P(!1),W=N(``),[we,G]=P(1),[K,q]=P(null),[Te,J]=P(1),[Y,Ee]=P(s.length===0);M(()=>{s.length>0&&Y&&Ee(!1)},[s.length,Y]);let De=ge(()=>w.map(e=>`/${e.name}`),[w]);M(()=>{ue.current=s},[s]),M(()=>{I.current=p},[p]),M(()=>{ce.startsWith(`/`)?(ye(De.filter(e=>e.startsWith(ce.toLowerCase()))),R(0)):(ye([]),R(0))},[ce]),M(()=>{if(g?.items){let e=Math.max(0,g.items.length-1);xe(t=>Math.min(t,e))}},[g?.items?.length]),me(he((e,t)=>{let n=L.current,r=fe;if(t.escape&&(l||m||c.length>0)&&!g){o?.(),T(``),L.current=``,D.current=0,E(0),F(-1);return}if(t.escape&&x&&V&&!g){H(!1);return}if(t.escape&&Ce&&!x&&!g){U(!1);return}if(C&&ie){if(t.escape||e.toLowerCase()===`n`){G(1),ie(!1);return}if(e.toLowerCase()===`y`){G(0),ie(!0);return}if(t.upArrow||t.downArrow){G(e=>e===0?1:0);return}if(t.return){ie(we===0);return}return}if(g){if(K){if(t.escape||t.ctrl&&e===`c`){q(null);return}if(t.leftArrow||t.rightArrow){J(e=>e===0?1:0);return}if(e.toLowerCase()===`y`){y&&y(K.path),q(null);return}if(e.toLowerCase()===`n`){q(null);return}if(t.return){Te===0&&y&&y(K.path),q(null);return}return}if(t.escape||t.ctrl&&e===`c`)if(B){Se(!1);return}else{_?.(),xe(0);return}if(t.upArrow&&!B){xe(e=>e>0?e-1:g.items.length-1);return}if(t.downArrow&&!B){xe(e=>e<g.items.length-1?e+1:0);return}if(t.ctrl&&e===`o`&&g.type===`trust`&&!K&&!B){let e=g.items[z];e?.path&&(q({path:e.path,name:e.name}),J(1));return}if(t.return){if(B)return;if(g.type===`resume`){let e=g.items[z];e.messages&&v&&(v(e.messages),_?.(),xe(0));return}if(g.type===`rewind`){let e=g.items[z];e.index!==void 0&&b&&(b(e.index),_?.(),xe(0));return}Se(!0);return}return}if(t.ctrl&&e===`o`){x?H(e=>!e):U(e=>!e);return}if(t.ctrl&&e===`u`){T(``),L.current=``,D.current=0,E(0),F(-1);return}if(t.ctrl&&e===`c`||e===``)if(n.trim()){T(``),L.current=``,D.current=0,E(0),F(-1);return}else{a(),se();return}if(t.shift&&t.return){let e=D.current,t=L.current,n=t.slice(0,e)+`
|
|
3
|
+
`+t.slice(e);L.current=n,T(n);let r=e+1;D.current=r,E(r);return}if(t.ctrl&&e===`a`){D.current=0,E(0);return}if(t.ctrl&&e===`e`){D.current=n.length,E(n.length);return}let s=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,u=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(s){let e=He(n,D.current);D.current=e,E(e);return}if(u){let e=Ue(n,D.current);D.current=e,E(e);return}if(t.home||e===`\x1B[H`||e===`\x1BOH`){D.current=0,E(0);return}if(t.end||e===`\x1B[F`||e===`\x1BOF`){D.current=n.length,E(n.length);return}if(process.platform===`darwin`&&t.meta&&t.leftArrow){D.current=0,E(0);return}if(process.platform===`darwin`&&t.meta&&t.rightArrow){D.current=n.length,E(n.length);return}if(process.platform===`darwin`&&t.meta&&t.upArrow){D.current=0,E(0);return}if(process.platform===`darwin`&&t.meta&&t.downArrow){D.current=n.length,E(n.length);return}if(t.ctrl&&t.leftArrow&&process.platform!==`darwin`){let e=He(n,D.current);D.current=e,E(e);return}if(t.ctrl&&t.rightArrow&&process.platform!==`darwin`){let e=Ue(n,D.current);D.current=e,E(e);return}let d=()=>{let e=process.stdout?.columns||80,t=Math.max(20,e-6),r=[],i=0;n.split(`
|
|
4
|
+
`).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=D.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(ve.length>0){R(e=>e>0?e-1:ve.length-1);return}let e=I.current;if(r>=0&&e.length>0){F(t=>{let n=Math.max(0,t-1),r=e[n]||``;return T(r),L.current=r,D.current=r.length,E(r.length),n});return}let{rows:t,currentRow:n}=d();if(n>0){let e=D.current-t[n].start,r=t[n-1],i=r.start+Math.min(e,r.end-r.start);D.current=i,E(i);return}if(e.length>0){F(t=>{let n=t<0?e.length-1:Math.max(0,t-1),r=e[n]||``;return T(r),L.current=r,D.current=r.length,E(r.length),n});return}return}if(t.downArrow){if(ve.length>0){R(e=>e<ve.length-1?e+1:0);return}let e=I.current;if(r>=0&&e.length>0){F(t=>{let n=t>=e.length-1?-1:t+1,r=n<0?``:e[n]||``;return T(r),L.current=r,D.current=r.length,E(r.length),n});return}let{rows:t,currentRow:n}=d();if(n<t.length-1){let e=D.current-t[n].start,r=t[n+1],i=r.start+Math.min(e,r.end-r.start);D.current=i,E(i);return}return}if(t.return){if(ve.length>0){let e=ve[be];ye([]),R(0),T(``),L.current=``,D.current=0,E(0),W.current=e,i(e);return}if(n.trim()){let e=n.trim();W.current=e,i(e),T(``),L.current=``,D.current=0,E(0),F(-1)}return}if((t.backspace||t.delete)&&D.current>0){let e=D.current,t=L.current,n=t.slice(0,e-1)+t.slice(e);L.current=n,T(n);let r=Math.max(0,e-1);D.current=r,E(r),F(-1);return}if(t.leftArrow&&!t.meta&&!t.ctrl){let e=Math.max(0,D.current-1);D.current=e,E(e);return}if(t.rightArrow&&!t.meta&&!t.ctrl){let e=Math.min(n.length,D.current+1);D.current=e,E(e);return}if(t.tab&&n.startsWith(`/`)){let e=De.filter(e=>e.startsWith(n.toLowerCase()));if(e.length===1){let t=e[0].length;T(e[0]),L.current=e[0],D.current=t,E(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=D.current,r=L.current,i=r.slice(0,n)+e+r.slice(n);L.current=i,T(i);let a=n+e.length;D.current=a,E(a),F(-1)}},[i,a,se,fe,De,ve,be,g,B,_,x,V,v,z,l,m,c,o,b,C,ie,we,Ce])),M(()=>{u&&O(!1)},[u]);let X=`\x1B[38;2;0;175;102m`,Z=`\x1B[0m`,Oe=`${X} ╔═════════╗${Z} ▄▖▗ ▌ ▄▖ ▄▖ ▗ ${X}╔═════════╗${Z}
|
|
5
|
+
${X} ║ ┌────╚════╗${Z} ▚ ▜▘▀▌▛▘▙▘▌▌▛▌█▌ ▌▌▛▌█▌▛▌▜▘ ${X}║ ┌────╚════╗${Z}
|
|
6
|
+
${X} ╚════╗────┘ ║${Z} ▄▌▐▖█▌▙▖▛▖▙▌▌▌▙▖ ▛▌▙▌▙▖▌▌▐▖ ${X}╚════╗────┘ ║${Z}
|
|
7
|
+
${X} ╚═════════╝${Z} ▄▌ ${X}╚═════════╝${Z}`,ke=Ge(s),Ae=ke.reduce((e,t,n)=>t.role===`user`?n:e,-1),Q=(e,t)=>{let n=e.role===`system`&&e.content.startsWith(`TOOL:`),r=e.role===`system`&&e.content.startsWith(`TOOL_START:`),i=e.role===`user`?`white`:e.role===`assistant`||n||r?`#00AF66`:`gray`,a=e.role===`user`?`❯ You`:e.role===`assistant`?e.isSubagent?`⚡ Subagent`:`◆ StackOne Agent`:`ℹ System`,o=e.content;r&&(a=`🔧 Tool • ${e.content.split(`|||`)[1]||``}`,o=``);let s=!1;if(n){let t=e.content.split(`|||`),n=t[0].replace(`TOOL:`,``),r=t.length>=3&&t[1]||``,i=t.length>=3?t.slice(2).join(`|||`):t[1]||``;a=r?`🔧 Tool • ${n} • ${r}`:`🔧 Tool • ${n}`,Ce?o=i:i.length>200?(s=!0,o=i.slice(0,200)):o=i}let c=e.role===`user`,l=Ae>=0&&t===Ae,u=e.content||(l?W.current:``)||(l&&p?.length?p[p.length-1]:``)||`(no content)`,d=c?u:Be(o??``);return c?j.createElement(k,{key:`msg-${e.timestamp.getTime()}-${t}`,marginBottom:1,flexDirection:`column`},j.createElement(A,{bold:!0,color:i},`❯ You`,j.createElement(A,{color:`gray`},` • `,e.timestamp.toLocaleTimeString())),j.createElement(k,{paddingLeft:2},j.createElement(A,{color:`white`,wrap:`wrap`},d))):j.createElement(k,{key:`msg-${e.timestamp.getTime()}-${t}`,marginBottom:1,flexDirection:`column`},j.createElement(A,{bold:!0,color:i},a,j.createElement(A,{color:`gray`},` • `,e.timestamp.toLocaleTimeString())),o!==void 0&&o!==``&&j.createElement(k,{paddingLeft:2,flexDirection:`column`},j.createElement(A,{color:n?`gray`:void 0,italic:n,wrap:`wrap`},d),s&&j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0,italic:!0},`... (truncated, press Ctrl+O to expand)`))))};return j.createElement(k,{flexDirection:`column`,padding:2},j.createElement(de,{items:[We]},()=>j.createElement(k,{key:`static-header`,flexDirection:`column`,marginBottom:1},j.createElement(A,null,Oe,`
|
|
8
|
+
`),j.createElement(A,{dimColor:!0},`⚠️ Preview Feature: experimental; sessions monitored. Review outputs carefully.`),j.createElement(A,null,`
|
|
9
|
+
`))),j.createElement(k,{flexDirection:`column`,marginBottom:1},Y&&j.createElement(k,{flexDirection:`column`,marginBottom:1},j.createElement(A,{bold:!0},`StackOne Builder - AI agent for connector development`),j.createElement(A,{dimColor:!0},`
|
|
10
|
+
`,`I can help you build connectors, add actions, test integrations, and answer questions about provider capabilities.`),j.createElement(A,null,`
|
|
11
|
+
`,`What would you like to work on?`),j.createElement(A,{dimColor:!0},`
|
|
12
|
+
`,`Examples:`),j.createElement(A,{dimColor:!0},`
|
|
13
|
+
`,` • "Create a new connector for Datadog"`),j.createElement(A,{dimColor:!0},` `,`• "Add a get_user action to the Slack connector"`),j.createElement(A,{dimColor:!0},` `,`• "Test the list_events action using account acc_xyz123"`)),ke.map((e,t)=>Q(e,t))),j.createElement(k,{flexDirection:`column`,marginBottom:1},j.createElement(j.Fragment,null,(x||S)&&j.createElement(k,{marginBottom:0,marginTop:0,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2,paddingY:1,flexDirection:`column`,height:V?`100%`:void 0},j.createElement(A,{bold:!0,color:`#00AF66`},S?`✓`:`⚡`,` Subprocess:`,` `,ee,` `,S?`(Complete)`:``,` `,V?`(Expanded)`:``),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},S?V?`Press Ctrl+O or ESC to collapse`:`Press Ctrl+O to expand`:V?`Running... Press Ctrl+O or ESC to collapse`:`Running... Press Ctrl+O to expand`)),V?j.createElement(j.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=e.content.split(`|||`),n=t[0].replace(`TOOL:`,``),a=t.length>=3?t.slice(2).join(`|||`):t[1]||``;r=`🔧 Tool • ${n}`,i=a.slice(0,500),a.length>500&&(i+=`
|
|
14
|
+
... (truncated)`)}return j.createElement(k,{key:`${e.timestamp.getTime()}-${t}-${e.role}-subagent`,marginTop:1,flexDirection:`column`},j.createElement(A,{bold:!0,color:`#00AF66`},r,j.createElement(A,{color:`gray`},` `,`•`,` `,e.timestamp.toLocaleTimeString())),j.createElement(k,{paddingLeft:2},j.createElement(A,{color:n?`gray`:`#00AF66`,dimColor:n,wrap:`wrap`},Be(i))))}),!S&&!f&&l&&c.length===0&&j.createElement(k,{marginTop:1},j.createElement(A,{color:`#00AF66`},j.createElement(_e,{type:`dots`})),j.createElement(A,{dimColor:!0},` Thinking...`)),!S&&!f&&c.length>0&&j.createElement(k,{flexDirection:`column`,marginTop:1},c.map((e,t)=>j.createElement(k,{key:t,marginBottom:1},e.status===`running`&&j.createElement(A,{color:`#00AF66`},j.createElement(_e,{type:`dots`})),j.createElement(A,{color:`#00AF66`},` `,e.skillName?j.createElement(j.Fragment,null,`✨ Skill •`,` `,e.skillName):j.createElement(j.Fragment,null,`🔧 `,e.name),e.status===`running`&&`...`,e.status===`completed`&&` ✓`)))),!S&&m&&!f&&j.createElement(k,{marginTop:1},j.createElement(A,{color:`#00AF66`},Be(m)))):j.createElement(j.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=e.content.split(`|||`),n=t[0].replace(`TOOL:`,``),i=t.length>=3?t.slice(2).join(`|||`):t[1]||``;r=`🔧 ${n}: ${i.slice(0,100)}${i.length>100?`...`:``}`}let i=r.split(`
|
|
15
|
+
`).slice(0,2).join(`
|
|
16
|
+
`);return j.createElement(k,{key:t,marginTop:1},j.createElement(A,{color:`#00AF66`,dimColor:n},Be(i),r.split(`
|
|
17
|
+
`).length>2&&`...`))}),!S&&!f&&l&&c.length===0&&j.createElement(k,{marginTop:1},j.createElement(A,{color:`#00AF66`},j.createElement(_e,{type:`dots`})),j.createElement(A,{dimColor:!0},` Thinking...`)),!S&&!f&&c.length>0&&j.createElement(k,{flexDirection:`column`,marginTop:1},c.slice(-2).map((e,t)=>j.createElement(k,{key:t,marginBottom:1},e.status===`running`&&j.createElement(A,{color:`#00AF66`},j.createElement(_e,{type:`dots`})),j.createElement(A,{color:`#00AF66`},` `,e.skillName?j.createElement(j.Fragment,null,`✨ Skill •`,` `,e.skillName):j.createElement(j.Fragment,null,`🔧 `,e.name),e.status===`running`&&`...`,e.status===`completed`&&` ✓`))),c.length>2&&j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`... and`,` `,c.length-2,` `,`more (Ctrl+O to expand)`))),!S&&m&&j.createElement(k,{marginTop:1},j.createElement(A,{color:`#00AF66`},Be(m).split(`
|
|
18
|
+
`).slice(0,2).join(`
|
|
19
|
+
`),Be(m).split(`
|
|
20
|
+
`).length>2&&`
|
|
21
|
+
...`))))),m&&!x&&!f&&j.createElement(k,{marginBottom:1,flexDirection:`column`},j.createElement(A,{bold:!0,color:`#00AF66`},`◆ StackOne Agent`,j.createElement(A,{color:`gray`},` • `,new Date().toLocaleTimeString())),j.createElement(k,{paddingLeft:2},j.createElement(A,{wrap:`wrap`},Be(m)))),!x&&!f&&c.length>0&&j.createElement(k,{marginBottom:1,flexDirection:`column`},c.map((e,t)=>j.createElement(k,{key:t,marginBottom:1},e.status===`running`&&j.createElement(A,{color:`#00AF66`},j.createElement(_e,{type:`dots`})),j.createElement(A,{color:`#00AF66`},` `,e.skillName?j.createElement(j.Fragment,null,`✨ Skill • `,e.skillName):j.createElement(j.Fragment,null,`🔧 `,e.name),e.status===`running`&&`...`,e.status===`completed`&&` ✓`))))),!x&&!f&&l&&c.length===0&&j.createElement(k,{marginBottom:1},j.createElement(A,{color:`#00AF66`},j.createElement(_e,{type:`dots`})),j.createElement(A,{dimColor:!0},` Thinking...`)),f&&j.createElement(k,{marginTop:1},j.createElement(A,{color:`red`},`⏺ Interrupted · What should the StackOne Agent do instead?`)),d&&j.createElement(k,{marginBottom:1,borderStyle:`single`,borderColor:`red`,paddingX:2,paddingY:1,flexDirection:`column`},j.createElement(A,{color:`red`},`✗ `,d),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`Press Enter to try again or Ctrl+C to exit`))),u&&j.createElement(k,{marginBottom:1,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2},j.createElement(A,{color:`#00AF66`},`✓ Complete`)),g&&j.createElement(k,{marginBottom:1,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2,paddingY:1,flexDirection:`column`},B?j.createElement(j.Fragment,null,j.createElement(A,{bold:!0,color:`#00AF66`},g.items[z].name),g.type!==`trust`&&j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},g.items[z].description)),g.type===`skills`&&j.createElement(k,{flexDirection:`column`},g.items[z].version?j.createElement(A,{dimColor:!0},`Version:`,` `,String(g.items[z].version)):null,g.items[z].author?j.createElement(A,{dimColor:!0},`Author:`,` `,String(g.items[z].author)):null,g.items[z].tags&&Array.isArray(g.items[z].tags)?j.createElement(A,{dimColor:!0},`Tags:`,` `,g.items[z].tags.join(`, `)):null,g.items[z].content?j.createElement(k,{marginTop:1,flexDirection:`column`},j.createElement(A,{bold:!0},`Skill Content:`),j.createElement(k,{marginTop:1},j.createElement(A,{wrap:`wrap`},String(g.items[z].content).slice(0,2e3),String(g.items[z].content).length>2e3?`
|
|
22
|
+
|
|
23
|
+
... (content truncated)`:``))):j.createElement(A,{dimColor:!0},`No content available`)),g.type===`tools`&&j.createElement(k,{flexDirection:`column`},j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`Category:`,` `,String(g.items[z].category))),j.createElement(k,{marginTop:1},j.createElement(A,{bold:!0},`Input Parameters:`)),g.items[z].inputSchema?j.createElement(k,{marginTop:1,paddingLeft:2,flexDirection:`column`},(()=>{let e=g.items[z].inputSchema,t=e.properties||{},n=e.required||[];return Object.entries(t).map(([e,t])=>j.createElement(k,{key:e,flexDirection:`column`,marginBottom:1},j.createElement(A,null,e,n.includes(e)?` *`:``,j.createElement(A,{dimColor:!0},` `,`(`,t.type?String(t.type):`any`,`)`)),t.description?j.createElement(k,{paddingLeft:2},j.createElement(A,{dimColor:!0},String(t.description))):null))})(),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`* = required parameter`))):j.createElement(k,{marginTop:1,paddingLeft:2},j.createElement(A,{dimColor:!0},`No parameters`)),j.createElement(k,{marginTop:1},j.createElement(A,{bold:!0},`Output:`)),j.createElement(k,{marginTop:1,paddingLeft:2},j.createElement(A,{dimColor:!0},`Returns JSON with tool execution results`))),g.type===`trust`&&j.createElement(k,{flexDirection:`column`,marginTop:1},j.createElement(A,null,j.createElement(A,{dimColor:!0},`Path: `),j.createElement(A,null,String(g.items[z].path))),j.createElement(A,null,j.createElement(A,{dimColor:!0},`Trusted at: `),j.createElement(A,null,g.items[z].trustedAt?new Date(g.items[z].trustedAt).toLocaleString():`N/A`))),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`Press Esc to go back`))):K?j.createElement(j.Fragment,null,j.createElement(A,{bold:!0,color:`yellow`},`⚠️ Remove Trust`),j.createElement(k,{flexDirection:`column`,marginTop:1},j.createElement(A,{color:`white`},`Are you sure you want to remove trust from:`),j.createElement(A,{color:`cyan`,bold:!0},K.path)),j.createElement(k,{flexDirection:`column`,marginTop:1},j.createElement(A,{color:`yellow`},`⚠️ This action is permanent. To trust this folder again,`),j.createElement(A,{color:`yellow`},`you must open a new chat session in that directory.`)),j.createElement(k,{marginTop:1},j.createElement(A,{color:Te===0?`green`:`gray`,bold:Te===0},Te===0?`❯ [Y]es`:` Yes`),j.createElement(A,null,` `),j.createElement(A,{color:Te===1?`green`:`gray`,bold:Te===1},Te===1?`❯ [N]o`:` No`)),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`←→ to select • Enter to confirm • Esc to cancel`))):j.createElement(j.Fragment,null,j.createElement(A,{bold:!0,color:`#00AF66`},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})`),j.createElement(k,{flexDirection:`column`,marginTop:1},g.items.map((e,t)=>{let n=t===z?`❯ `:` `,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 j.createElement(A,{key:t,color:t===z?`#00AF66`:`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 j.createElement(A,{key:t,color:t===z?`#00AF66`:`gray`},d,u.length>i?`...`:``)})),j.createElement(k,{marginTop:1},j.createElement(A,{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&&j.createElement(k,{flexDirection:`column`,marginBottom:1},te.map((e,t)=>j.createElement(k,{key:t,marginBottom:t<te.length-1?1:0},j.createElement(A,{dimColor:!0},`📬 `),j.createElement(A,null,e.content))),ne&&j.createElement(A,{dimColor:!0,italic:!0},`Processing...`)),C&&j.createElement(k,{marginBottom:1},j.createElement(A,{color:`yellow`},`Delete `),j.createElement(A,{color:`red`},C.isDirectory&&C.directoryContents?`${C.files.map(e=>e.split(`/`).pop()).join(`, `)}/ (${C.directoryContents.length} files)`:C.files.map(e=>e.split(`/`).pop()).join(`, `)),j.createElement(A,{color:`yellow`},`? `),j.createElement(A,{color:we===0?`green`:`gray`},we===0?`[Y]es`:`y`),j.createElement(A,null,`/`),j.createElement(A,{color:we===1?`green`:`gray`},we===1?`[N]o`:`n`)),le&&!u&&!g&&!C&&j.createElement(j.Fragment,null,j.createElement(k,{borderStyle:`double`,borderColor:`white`,paddingX:2,flexDirection:`column`},(()=>{let e=process.stdout.columns||80,t=Math.max(20,e-6),n=L.current.split(`
|
|
24
|
+
`),r=D.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(j.createElement(k,{key:_},p&&j.createElement(A,{color:`#00AF66`},`❯ `),j.createElement(A,{color:`white`},n),j.createElement(A,{backgroundColor:`white`,color:`black`,bold:!0},o),j.createElement(A,{color:`white`},s)))}else a.push(j.createElement(k,{key:_},p&&j.createElement(A,{color:`#00AF66`},`❯ `),j.createElement(A,{color:`white`},e||` `)));f+=e.length})}),a})()),ve.length>0&&j.createElement(k,{marginTop:1,paddingLeft:2,flexDirection:`column`},ve.map((e,t)=>j.createElement(k,{key:e},j.createElement(A,{color:t===be?`#00AF66`:`gray`},t===be?`❯ `:` `,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 j.createElement(k,{marginTop:1,flexDirection:`column`},j.createElement(A,{dimColor:!0},`📊 Model: Sonnet 4.5 • 🧠 Context left:`,` `,j.createElement(A,{color:t},e.toFixed(1),`%`)),n&&j.createElement(A,{color:`red`},`⚠️ Context low (`,e.toFixed(1),`% remaining)`))})(),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},le?`Type message and press Enter • Shift+Enter for new line • `:``,(l||m||c.length>0)&&`ESC to stop • `,x?`Ctrl+O to expand subprocess • `:`Ctrl+O to show/hide full tool results • `,`Ctrl+C to clear/exit`)))},qe=({timeRemaining:e,onRunSetup:t,onIgnore:n})=>{let{exit:r}=pe(),[i,a]=P(0);me((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 j.createElement(k,{flexDirection:`column`,padding:2},j.createElement(k,{borderStyle:`round`,borderColor:`yellow`,flexDirection:`column`,paddingX:2,paddingY:1},j.createElement(A,{bold:!0,color:`yellow`},`⚠️ Credential Warning`),j.createElement(A,null),j.createElement(A,null,`Your StackOne credentials expire in `,l,` (last day of 7-day validity).`),j.createElement(A,null),j.createElement(A,null,"To avoid interruption, run `stackone agent setup` to reauthenticate."),j.createElement(A,null),j.createElement(A,{color:i===0?o:`white`},i===0?`❯ `:` `,`1. Run stackone agent setup`),j.createElement(A,{color:i===1?o:`white`},i===1?`❯ `:` `,`2. Ignore and continue`)),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`↑↓ to navigate • Enter to confirm • Esc to continue`)))},Je=({directory:e,onConfirm:t,onCancel:n})=>{let{exit:r}=pe(),[i,a]=P(0);me((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 j.createElement(k,{flexDirection:`column`,padding:2},j.createElement(k,{borderStyle:`round`,borderColor:`#00AF66`,flexDirection:`column`,paddingX:2,paddingY:1},j.createElement(A,{bold:!0},`Do you trust the files in this folder?`),j.createElement(A,null),j.createElement(A,{dimColor:!0},e),j.createElement(A,null),j.createElement(A,null,`StackOne Agent may read, write, or execute files contained in this directory.`),j.createElement(A,null,`This can pose security risks, so only use files and commands from trusted sources.`),j.createElement(A,null),j.createElement(A,{color:i===0?o:`white`},i===0?`❯ `:` `,`1. Yes, proceed`),j.createElement(A,{color:i===1?o:`white`},i===1?`❯ `:` `,`2. No, exit`)),j.createElement(k,{marginTop:1},j.createElement(A,{dimColor:!0},`↑↓ to navigate • Enter to confirm • Esc to exit`)))};function Ye(){return[]}const Xe=(e,t)=>{try{if(t.existed&&t.content!==null){let n=O.dirname(e);return w.existsSync(n)||w.mkdirSync(n,{recursive:!0}),w.writeFileSync(e,t.content,`utf-8`),{success:!0,action:`restored`}}else return w.existsSync(e)?(w.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)}}},Ze=[{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`}],Qe=new Set([`heapdump`]);function $e(e,t){let n=new Map(t.map(e=>[e.name,e]));for(let t of e)!n.has(t.name)&&!Qe.has(t.name)&&n.set(t.name,{...t,source:`harness`});return Array.from(n.values())}const et=({mode:e,connector:t,action:n,goal:r,verbose:i,temperature:o,apiKey:s})=>{let[c,l]=P([]),[u,d]=P(new Map),[f,p]=P(!1),[m,h]=P(),[g,_]=P(!1),[v,y]=P(!0),[b,x]=P([]),[ae,oe]=P([]),[se,ce]=P(``),[T]=P(),[E,le]=P(!1),[ue,k]=P(null),de=N(te()),A=N(ne()),[fe]=P(new Date),[pe,me]=P(0),[ge,_e]=P(!1),F=N(!1),[I,L]=P(``),[ve,ye]=P(!1),[be,R]=P([]),[z,xe]=P(!1),[B,Se]=P(!1),V=N(!1),H=N({shouldStop:!1,requestId:0,controller:null}),[Ce,U]=P([]),W=N(null),[we,G]=P([]),K=N(null),q=N([]),Te=N(0),[J,Y]=P({claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]}),[Ee,De]=P(Ze),X=N(new Map),Z=N(-1),[Oe,ke]=P(null),Ae=N(null),Q=N({operation:``,phase:`idle`}),je=(e,t=!1)=>{let n=Q.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};M(()=>{let e=O.join(D.homedir(),`.stackone`,`agent_history`);try{if(w.existsSync(e)){let t=w.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(`
|
|
25
|
+
`).filter(e=>e.trim())}catch{n=t.split(`
|
|
26
|
+
`).filter(e=>e.trim())}oe(n)}}catch(e){i&&a.error(`[History] Failed to load command history:`,e)}},[i]);let Me=N([]);M(()=>{(async()=>{let t={claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]};try{try{let e=C(),n=ie();x(e.map(e=>{let t=O.join(n,e,`SKILL.md`),r,i;try{if(w.existsSync(t)){let e=w.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(`
|
|
27
|
+
`)[0].trim())}}}catch{}return{name:e,description:r,content:i}})),t.claudeSkills={count:e.length,names:e,totalSize:0}}catch(e){a.error(`[Skills] Failed to load skills:`,e),t.errors.push(`Failed to load skills`)}try{let e=Ye();Me.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{De($e(await(await S({prompt:``,mode:e,apiKey:s})).supportedCommands(),Ze))}catch(e){i&&a.warn(`[Commands] Failed to fetch harness commands:`,e)}Y(t)}catch(e){a.error(`[Init] Failed to initialize runtime:`,e)}finally{y(!1)}})()},[s,e,i]),M(()=>{V.current=B},[B]),M(()=>{if(T&&!E){let e=T.input_tokens+T.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]),le(!0)}}},[T,E]);let Ne=he(async r=>{try{let i=c.filter(e=>e.role===`user`||e.role===`assistant`);if(i.length<2)return;let a=r.trim().slice(0,50)||i.find(e=>e.role===`user`)?.content?.slice(0,50)||`conversation`;await w.promises.mkdir(O.join(D.homedir(),`.stackone`,`conversations`),{recursive:!0});let o=Date.now(),s=`${o}-${a.replace(/[^a-zA-Z0-9]/g,`-`).toLowerCase().slice(0,50)}.json`,l=O.join(D.homedir(),`.stackone`,`conversations`,s);await w.promises.writeFile(l,JSON.stringify({title:a,timestamp:o,goal:r,messages:c.filter(e=>e.role!==`system`),mode:e,connector:t,action:n},null,2))}catch(e){a.error(`Failed to save conversation:`,e)}},[c,e,t,n]),Pe=he(async(r,o=!1)=>{if((v||V.current)&&!o){R(e=>[...e,{content:r,timestamp:new Date}]),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{Ie()},3e4);return}if(h(void 0),_(!1),r===`/skills`){if(b.length===0){let e={role:`system`,content:`📚 No skills loaded. Skills will be loaded on startup.`,timestamp:new Date};l(t=>[...t,e]);return}k({type:`skills`,items:b.map(e=>({name:e.name,description:e.description,content:e.content}))});return}if(r===`/tools`){let e=[];for(let t of J.mcpServers){let n=J.toolCounts.mcpByServer[t.name]||[];for(let r of n)e.push({name:r,description:`MCP tool (${t.name})`,category:`MCP:${t.name}`})}let t=[...J.toolCounts.builtin.map(e=>({name:e,description:`Built-in (from agent harness)`,category:`Built-in`})),...e,...J.mcpServers.filter(e=>!J.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`}))];k({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:
|
|
28
|
+
|
|
29
|
+
`;for(let t of Ee){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
|
|
30
|
+
`];if(b.length>0){r.push(`Skills Loaded (${b.length}):`);for(let e of b)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: ${pe}`),r.push(``);let i={instructions:`Mode: ${e}\nSkills: ${b.map(e=>e.name).join(`, `)||`none`}\nConnector: ${t||`none`}`,skills:b.map(e=>({name:e.name,description:e.description,enabled:!0})),session:{id:`current`,startedAt:fe,mode:e,turnCount:pe}},a=de.current.render(`instructions`,i);a?.content&&r.push(a.content);let o={role:`system`,content:r.join(`
|
|
31
|
+
`),timestamp:new Date};l(e=>[...e,o]);return}if(r===`/safety`){let e=`🛡️ Safety Rules
|
|
32
|
+
|
|
33
|
+
`;e+=`Command execution is protected by safety checks implemented in the agent harness.
|
|
34
|
+
`,e+=`These checks may block or require confirmation for potentially dangerous operations,
|
|
35
|
+
`,e+=`such as destructive filesystem commands or writing directly to devices.
|
|
36
|
+
|
|
37
|
+
`,e+=`The exact safety rules and heuristics are maintained by the runtime and may change over time.
|
|
38
|
+
`;try{ee(`ls -la`),e+=`
|
|
39
|
+
✓ Safety hook is active and working`}catch{e+=`
|
|
40
|
+
⚠ Safety hook check failed`}let t={role:`system`,content:e,timestamp:new Date};l(e=>[...e,t]);return}if(r===`/mcp`){if(J.mcpServers.length===0){let e={role:`system`,content:`📡 No MCP servers configured`,timestamp:new Date};l(t=>[...t,e]);return}k({type:`mcp`,items:J.mcpServers.map(e=>{let t=J.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-IXmvFiFL.mjs`),t=e();if(t.length===0){let e={role:`system`,content:`📁 No trusted folders found.
|
|
41
|
+
|
|
42
|
+
Folders are automatically trusted when you open a chat session in them.`,timestamp:new Date};l(t=>[...t,e]);return}k({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=O.join(D.homedir(),`.stackone`,`agent_history`);if(!w.existsSync(e)){let e={role:`system`,content:`⏮️ No command history found.`,timestamp:new Date};l(t=>[...t,e]);return}let t=w.readFileSync(e,`utf-8`).split(`
|
|
43
|
+
`).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}k({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=O.join(D.homedir(),`.stackone`,`conversations`);if(!w.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=w.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=w.readFileSync(O.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}k({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 u=Ee.map(e=>`/${e.name}`),f=r.split(` `)[0];if(r.startsWith(`/`)&&f!==`/`&&!u.includes(f)){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]),p(!0);try{let e=c.filter(e=>e.role===`user`||e.role===`assistant`).map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`).join(`
|
|
44
|
+
|
|
45
|
+
`),t=e.length>2e3?e.slice(0,2e3)+`
|
|
46
|
+
|
|
47
|
+
[... truncated for context]`:e;p(!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){p(!1),h(e instanceof Error?e.message:`Failed to summarize conversation`)}return}oe(e=>{let t=r.trim();if(!t)return e;let n=[...e,t],o=n.length-1;Z.current=o,X.current.has(o)||X.current.set(o,{commandIndex:o,command:t,timestamp:Date.now(),files:new Map});let s=O.join(D.homedir(),`.stackone`,`agent_history`);try{let e=O.dirname(s);w.existsSync(e)||w.mkdirSync(e,{recursive:!0});let t=n.slice(-1e3);w.writeFileSync(s,JSON.stringify(t),`utf-8`)}catch(e){i&&a.error(`[History] Failed to save command history:`,e)}return n});let m={role:`user`,content:r,timestamp:new Date};l(e=>[...e,m]),p(!0),Se(!0),me(e=>e+1),H.current.requestId+=1,H.current.shouldStop=!1,H.current.controller=new AbortController;let g=H.current.requestId,y=H.current.controller.signal;K.current&&=(clearTimeout(K.current),null),G([]);let x=()=>!H.current.shouldStop&&H.current.requestId===g;try{let o=c.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(`
|
|
48
|
+
`);q.current=[],Te.current=0;try{i&&(a.log(`
|
|
49
|
+
[AGENT:CONFIG] ═══════════════════════════════════════`),a.log(`[AGENT:CONFIG] Prompt: "${r.slice(0,100)}..."`),a.log(`[AGENT:CONFIG] Mode: ${e}`),a.log(`[AGENT:CONFIG] MCP Servers: ${Me.current.map(e=>e.name).join(`, `)||`none`}`),a.log(`[AGENT:CONFIG] API Key: ${s?`${s.slice(0,15)}...`:`MISSING`}`),a.log(`[AGENT:CONFIG] Context keys: ${Object.keys({connector:t,action:n}).filter(e=>({connector:t,action:n})[e]).join(`, `)||`none`}`),a.log(`[AGENT:CONFIG] Max turns: 1000`),a.log(`[AGENT:CONFIG] ═══════════════════════════════════════
|
|
50
|
+
`));let c=0,u=Date.now();for await(let f of re({prompt:r,mode:e,mcpServers:Me.current,apiKey:s,context:{connector:t,action:n,conversationSummary:o||void 0},maxTurns:1e3,verbose:i||!1,streaming:!1,origin:`cli`,abortSignal:y})){c++;let e=Date.now()-u;if(i){let t=f.type===`text`?` content="${(f.content||``).slice(0,30)}..."`:f.type===`error`?` error="${f.error}"`:f.type===`tool_call`?` tool="${f.toolName}"`:``;a.log(`[AGENT:MSG #${c}] type=${f.type}${t} (${e}ms)`)}if(!x())return;if(f.type===`text`){Q.current.phase=`streaming`,ce(e=>e+(f.content??``)),Fe();continue}if(f.type===`skill_invocation`){let e=`skill-${++Te.current}`;d(t=>{let n=new Map(t);return n.set(e,{name:`Skill`,status:`running`,skillName:f.skillName,inputSummary:f.skillArgs}),n}),setTimeout(()=>{d(t=>{let n=new Map(t);return n.delete(e),n})},2e3);continue}if(f.type===`tool_call`){Q.current={operation:`Processing: "${r.slice(0,100)}${r.length>100?`...`:``}"`,phase:`tool_execution`,toolName:f.toolName,toolInput:f.toolInput};let e=`tc-${++Te.current}`;if(q.current.push(e),U(t=>[...t,{id:e,name:f.toolName??``,input:f.toolInput,output:void 0}]),f.toolName===`spawn_subagent`&&f.toolInput){let e=f.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}L(String(t)),F.current=!0,setTimeout(()=>_e(!0),10)}let t=f.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))),ce(e=>(e&&l(t=>[...t,{role:`assistant`,content:e,timestamp:new Date,isSubagent:F.current}]),``)),d(t=>{let r=new Map(t);return r.set(e,{name:f.toolName??``,status:`running`,inputSummary:n}),r});continue}if(f.type===`tool_result`){Q.current={...Q.current,phase:`streaming`,toolName:void 0,toolInput:void 0};let e=q.current.shift();if(e){U(t=>t.map(t=>t.id===e?{...t,output:f.toolResult}:t));let t=``;d(n=>{let r=n.get(e);r?.inputSummary&&(t=r.inputSummary);let i=new Map(n);return i.delete(e),i});let n=typeof f.toolResult==`string`?f.toolResult:JSON.stringify(f.toolResult,null,2),r={role:`system`,content:`TOOL:${f.toolName}|||${t}|||${n}`,timestamp:new Date,isSubagent:F.current};l(e=>[...e,r])}continue}if(f.type===`tool_progress`){let e=f.progress;f.toolName&&d(t=>{let n=new Map(t);for(let[t,r]of n)if(r.name===f.toolName){n.set(t,{...r,inputSummary:e?.operation||r.inputSummary});break}return n});continue}if(f.type===`tool_error`){Q.current={...Q.current,phase:`streaming`,toolName:void 0,toolInput:void 0};let e=q.current.shift();e&&(U(t=>t.map(t=>t.id===e?{...t,output:`Error: ${f.error}`}:t)),d(t=>{let n=new Map(t);return n.delete(e),n}));continue}if(f.type===`error`){let e=f.error??`Unknown error`,t=e;if(i){a.log(`
|
|
51
|
+
[AGENT:ERROR] ═══════════════════════════════════════`),a.log(`[AGENT:ERROR] Message: ${e}`),a.log(`[AGENT:ERROR] Full message object:`);try{a.log(JSON.stringify(f,null,2))}catch{a.log(`[AGENT:ERROR] (could not stringify message)`)}a.log(`[AGENT:ERROR] Messages received before error: ${c}`),a.log(`[AGENT:ERROR] Time elapsed: ${Date.now()-u}ms`),a.log(`[AGENT:ERROR] ═══════════════════════════════════════
|
|
52
|
+
`)}e.includes(`exited with code 1`)?t=`Agent subprocess failed (exit code 1).
|
|
53
|
+
|
|
54
|
+
Possible causes:
|
|
55
|
+
• Authentication issue with StackOne API
|
|
56
|
+
• Network connectivity problem
|
|
57
|
+
• Invalid agent configuration
|
|
58
|
+
|
|
59
|
+
Run 'stackone agent setup' to refresh credentials.
|
|
60
|
+
|
|
61
|
+
Original error: ${e}`:e.includes(`401`)||e.includes(`unauthorized`)||e.includes(`Unauthorized`)?t=`Authentication failed.
|
|
62
|
+
|
|
63
|
+
Run 'stackone agent setup' to refresh your credentials.
|
|
64
|
+
|
|
65
|
+
Original error: ${e}`:e.includes(`403`)||e.includes(`forbidden`)||e.includes(`Forbidden`)?t=`Access denied. Your credentials may not have permission for this operation.
|
|
66
|
+
|
|
67
|
+
Run 'stackone agent setup' to refresh your credentials.
|
|
68
|
+
|
|
69
|
+
Original error: ${e}`:(e.includes(`ENOTFOUND`)||e.includes(`ECONNREFUSED`)||e.includes(`network`))&&(t=`Network error. Check your internet connection.
|
|
70
|
+
|
|
71
|
+
Original error: ${e}`),h(t),Q.current={operation:``,phase:`idle`};continue}if(f.type===`done`){if(i){let e=Date.now()-u;a.log(`
|
|
72
|
+
[AGENT:DONE] ═══════════════════════════════════════`),a.log(`[AGENT:DONE] Total messages received: ${c}`),a.log(`[AGENT:DONE] Total time: ${e}ms`),a.log(`[AGENT:DONE] Status: ${f.status||`unknown`}`),c<=2&&a.log(`[AGENT:DONE] ⚠️ WARNING: Very few messages - agent may have failed early`),a.log(`[AGENT:DONE] ═══════════════════════════════════════
|
|
73
|
+
`)}Q.current={operation:``,phase:`idle`},p(!1),d(new Map),U([]);let e=F.current;ce(t=>(t&&l(n=>[...n,{role:`assistant`,content:t,timestamp:new Date,isSubagent:e}]),``)),e?(F.current=!1,setTimeout(()=>{l(e=>{let t=e.filter(e=>e.isSubagent&&e.role===`assistant`).map(e=>e.content).join(`
|
|
74
|
+
|
|
75
|
+
`);return t?.trim()?setTimeout(()=>{ye(!1),_e(!1),setTimeout(()=>{try{Pe(t,!0)}catch(e){a.error(`[SUBAGENT] Error:`,e),Se(!1)}},100)},300):(ye(!1),_e(!1),Se(!1)),e})},100)):Se(!1),await Ne(r)}}}catch(e){if(!x())return;p(!1),d(new Map),h(je(e instanceof Error?e.message:String(e),i||!1)),Q.current={operation:``,phase:`idle`}}x()&&(p(!1),d(new Map),Se(!1),U([]),Q.current={operation:``,phase:`idle`})}catch(e){if(!x()){i&&a.log(`[STREAM] Ignoring error from interrupted request:`,e instanceof Error?e.message:String(e));return}p(!1),d(new Map),Se(!1),U([]);let t=e instanceof Error?e.message:String(e);t.toLowerCase().includes(`cloudfront`)||t.includes(`403`)&&t.includes(`Request blocked`)?h(`⚠️ Request temporarily blocked by CloudFront
|
|
76
|
+
|
|
77
|
+
The API server's firewall blocked this request. This usually happens due to:
|
|
78
|
+
• Rate limiting (too many requests in a short time)
|
|
79
|
+
• Request size limits being exceeded
|
|
80
|
+
• Temporary server-side issues
|
|
81
|
+
|
|
82
|
+
What to try:
|
|
83
|
+
1. Wait a few seconds and try again
|
|
84
|
+
2. Start a fresh conversation with /compact
|
|
85
|
+
3. If this persists, contact the StackOne team
|
|
86
|
+
|
|
87
|
+
Press Enter to retry.`):t.includes(`403`)||t.includes(`Invalid authentication token`)||t.includes(`authentication`)?h(`Authentication failed. Your token may be invalid or expired.
|
|
88
|
+
|
|
89
|
+
To fix this:
|
|
90
|
+
1. Run: stackone agent setup
|
|
91
|
+
2. Follow the prompts to authenticate
|
|
92
|
+
3. Try again
|
|
93
|
+
|
|
94
|
+
Original error: ${t}`):t.includes(`API key`)||t.includes(`Invalid API Key`)?(a.error(`
|
|
95
|
+
❌ Critical error:`,t),a.error(`Please check your configuration and try again.
|
|
96
|
+
`),process.exit(1)):h(je(t,i||!1)),Q.current={operation:``,phase:`idle`},Se(!1),p(!1),d(new Map)}},[v,c,r,e,t,n,T,E,s,ge,Ne]);M(()=>{v||r&&Pe(r)},[v,r,e,J]);let Fe=()=>{R(e=>(e.length===0||d(e=>(!(e.size>0)&&V.current&&(W.current&&=(clearTimeout(W.current),null),setTimeout(()=>Ie(),100)),e)),e))},Ie=()=>{R(e=>{if(e.length===0)return e;xe(!0),ce(e=>{if(e){let t={role:`assistant`,content:e,timestamp:new Date,isSubagent:F.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(`
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
`);return xe(!1),Se(!1),U([]),W.current&&=(clearTimeout(W.current),null),setTimeout(()=>{Pe(n,!0)},100),[]})},Le=he(async e=>{let{removeTrustedFolder:t,getTrustedFoldersForDisplay:n}=await import(`./trustedFolders-IXmvFiFL.mjs`);t(e);let r=n();r.length===0?k(null):k({type:`trust`,items:r.map(e=>({name:e.name,description:e.path,path:e.path,trusted:e.trusted,trustedAt:e.trustedAt}))})},[k]);M(()=>{let e=b.map(e=>e.name);A.current.setActiveSkills(e)},[b]),M(()=>{if(!v&&be.length>0){let e=setTimeout(()=>{Fe()},100);return()=>clearTimeout(e)}},[v,be.length]);let Re=()=>{},ze=he(()=>{H.current.shouldStop=!0,H.current.controller?.abort(),_(!0),ce(e=>{if(e){let t=F.current,n={role:`assistant`,content:e,timestamp:new Date,isSubagent:t};l(e=>[...e,n])}return``}),p(!1),Se(!1),V.current=!1,d(new Map),U([]),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})),R([]),G([]),xe(!1),K.current&&=(clearTimeout(K.current),null)},[]),Be=he(e=>{Ae.current&&=(Ae.current.resolve(e),null),ke(null)},[]);return v?j.createElement(Ke,{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:Re,onStop:ze,slashCommands:Ee}):j.createElement(Ke,{title:`Agent ${e.charAt(0).toUpperCase()+e.slice(1)} Mode`,mode:e,connector:t,action:n,messages:c,currentToolCalls:Array.from(u.values()),isThinking:f,isComplete:!1,error:m,isInterrupted:g,onSubmit:Pe,onExit:Re,onStop:ze,commandHistory:ae,streamingText:se,usage:T,detailViewData:ue,onCloseDetailView:()=>k(null),onToggleTrust:Le,slashCommands:Ee,onRewindTo:e=>{try{let t=O.join(D.homedir(),`.stackone`,`agent_history`),n=w.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(`
|
|
101
|
+
`).filter(e=>e.trim())}catch{r=n.split(`
|
|
102
|
+
`).filter(e=>e.trim())}let i=new Map,a=[],o=[],s=[],c=Array.from(X.current.keys()).filter(t=>t>e).sort((e,t)=>e-t);for(let e of c){let t=X.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=Xe(e,t);n.success?n.action===`deleted`?o.push(e):a.push(e):s.push(`${e}: ${n.error}`)}for(let e of c)X.current.delete(e);Z.current=e;let u=r.slice(0,e+1);w.writeFileSync(t,JSON.stringify(u),`utf-8`);let d=`⏮️ Rewound to command: "${r[e]}"`;if(a.length>0||o.length>0){if(d+=`
|
|
103
|
+
|
|
104
|
+
📁 File changes:`,a.length>0){d+=`\n Restored (${a.length}):`;for(let e of a.slice(0,10))d+=`\n • ${O.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 • ${O.basename(e)}`;o.length>10&&(d+=`\n ... and ${o.length-10} more`)}}else d+=`
|
|
105
|
+
|
|
106
|
+
📁 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]),oe(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:ge,spawnedSubagentName:I,spawnedSubagentComplete:ve,queuedMessages:be,isProcessingQueue:z,initInfo:J,pendingDeleteConfirmation:Oe,onConfirmDelete:Be})};var tt=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-C2ZAnP7J.mjs`),{hasOldSetupFiles:o,migrateFromLocalSetup:s,displayMigrationMessage:c}=await import(`./setupMigration-BBDtXjPG.mjs`);try{let r=process.cwd();o(r)&&c(await s(r));let i=t(),l=n(),u=l.status===`expiring_soon`?l.timeRemaining:void 0;process.env.STACKONE_AGENT_TOKEN||(process.env.STACKONE_AGENT_TOKEN=i);let d=O.join(D.homedir(),`.stackone`,`trusted_directories`),f=[];try{w.existsSync(d)&&(f=w.readFileSync(d,`utf-8`).split(`
|
|
107
|
+
`).filter(e=>e.trim()))}catch(e){a.error(`[Trust] Failed to load trusted directories:`,e)}if(!f.includes(r)){let e=!1,{addTrustedFolder:t}=await import(`./trustedFolders-IXmvFiFL.mjs`),{waitUntilExit:n}=fe(j.createElement(Je,{directory:r,onConfirm:()=>{e=!0,t(r)},onCancel:()=>{e=!1}}));await n(),e||(a.log(`
|
|
108
|
+
Exiting...`),process.exit(0)),process.stdout.write(`\x1Bc`)}let p=i;if(u){let e={current:`ignore`},{waitUntilExit:n}=fe(j.createElement(qe,{timeRemaining:u,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,p=r}process.stdout.write(`\x1Bc`)}let{waitUntilExit:m}=fe(j.createElement(et,{...e,apiKey:p}),{exitOnCtrlC:!1});await m()}catch(e){e instanceof r&&(a.error(`
|
|
109
|
+
❌ Credentials Expired
|
|
110
|
+
`),a.log(y.white(`Your StackOne credentials have expired.
|
|
111
|
+
`)),a.log(y.white("To continue using the agent, run `stackone agent setup` to reauthenticate.\n")),a.log(y.dim(`Credentials are valid for 7 days after authentication.
|
|
112
|
+
`)),process.exit(1)),e instanceof i&&(a.error(`
|
|
113
|
+
❌ Authentication Required
|
|
114
|
+
`),a.log(y.white(`You need to authenticate before using the agent.
|
|
115
|
+
`)),a.log(y.white("To get started, run `stackone agent setup` to authenticate.\n")),a.log(y.dim(`This will:`)),a.log(y.dim(` • Authenticate with your StackOne credentials`)),a.log(y.dim(` • Save your token securely to ~/.stackone/agent-config.json`)),a.log(y.dim(` • Enable access to StackOne Agent and MCP tools
|
|
116
|
+
`)),a.log(y.white(`If you already ran setup, your local configuration may be missing or unreadable.`)),a.log(y.white(`Run setup again to create or repair your authentication configuration.
|
|
117
|
+
`)),process.exit(1));let t=e instanceof Error?e.message:String(e);a.error(`
|
|
118
|
+
❌ Error:`,t),a.log(y.dim(`
|
|
119
|
+
If you continue to see this error, try running:`)),a.log(y.cyan(` stackone agent setup
|
|
120
|
+
`)),process.exit(1)}}},nt=class{async execute(){a.log(y.blue.bold(`🧹 StackOne Agent Cleanup
|
|
121
|
+
`));try{let e=F(`Removing stored configuration...`).start();await f(),e.succeed(`Removed ~/.stackone/agent-config.json`),a.success(`Cleanup complete!`),a.log(y.white(`
|
|
122
|
+
What was removed:`)),a.log(y.cyan(` • ~/.stackone/agent-config.json`)),a.log(y.dim(`
|
|
123
|
+
To authenticate again:`)),a.log(y.cyan(` stackone agent setup`)),a.log(``),process.exit(0)}catch(e){e instanceof Error?a.error(e.message):a.error(`Unknown error occurred`),process.exit(1)}}};const rt=new class{constructor(e){this.baseUrl=e||process.env.AUTH_SERVER_URL||`https://idp-api.stackone.com`}async login(e,t){try{let n=`${this.baseUrl}/auth/sign-in/mcp`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})});if(!r.ok){let e=await r.text(),t={};try{t=JSON.parse(e)}catch{}return{success:!1,error:t.error||`HTTP ${r.status}: ${r.statusText}`}}let i=await r.text(),a=JSON.parse(i);return a.apiKey?{success:!0,apiKey:a.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=`${this.baseUrl}/api-key/verify`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!n.ok){let e=await n.text(),t={};try{t=JSON.parse(e)}catch{}return{valid:!1,error:t.error||`HTTP ${n.status}: ${n.statusText}`}}let r=await n.text();return JSON.parse(r)}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Network error occurred`}}}};function it(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 at=class{async execute(){a.log(y.blue.bold(`🤖 StackOne Agent Setup - Global Configuration
|
|
124
|
+
`));try{let t=await e(),n;if(t?.email){a.log(y.dim(`Last used email: ${t.email}\n`));let{useExisting:e}=await U.prompt([{type:`confirm`,name:`useExisting`,message:`Sign in with this email?`,default:!0}]);if(e)n=t.email;else{let e=Ce({input:V,output:H});n=await new Promise(t=>{e.question(y.white(`Email: `),e=>{t(e.trim())})}),e.close(),n||(a.error(`Email is required`),process.exit(1))}}else{let e=Ce({input:V,output:H});n=await new Promise(t=>{e.question(y.white(`Email: `),e=>{t(e.trim())})}),e.close(),n||(a.error(`Email is required`),process.exit(1))}let r=await U.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);r.password||(a.error(`Password is required`),process.exit(1)),a.log(``);let i=F(`Authenticating...`).start(),o=await rt.login(n,r.password);(!o.success||!o.apiKey)&&(i.fail(`Authentication failed`),a.error(`${o.error||`Invalid credentials`}`),a.log(y.dim(`Please check your email and password and try again.
|
|
125
|
+
`)),process.exit(1)),i.succeed(`Login successful!`);let s=new Date(Date.now()+10080*60*1e3).toISOString();await d({apiKey:o.apiKey,userId:n,email:n,expiresAt:s,serverUrl:l()}),a.success(`API key saved to ~/.stackone/agent-config.json`),a.log(y.white(`✓ Key expires at`),y.cyan(it(s))),a.success(`
|
|
126
|
+
Setup complete!`),a.log(y.dim(`
|
|
127
|
+
💡 Start the StackOne Agent Chat:`),y.cyan(`stackone agent chat`)),a.log(``),process.exit(0)}catch(e){e instanceof Error?a.error(e.message):a.error(`Unknown error occurred`),process.exit(1)}}},ot=class{async execute(e){let{prompt:t,mode:n=`build`,maxTurns:r=25,verbose:i=!1}=e;t.trim()||(a.error(`A prompt is required.`),process.exit(1));let o;try{o=h()}catch(e){e instanceof Error&&e.name===`CredentialMissingError`?(a.error(`
|
|
128
|
+
❌ Authentication Required
|
|
129
|
+
`),a.log(y.white("Run `stackone agent setup` to authenticate, then try again.\n"))):a.error(e instanceof Error?e.message:String(e)),process.exit(1)}let s=Ye();i&&(a.log(y.dim(`Mode: ${n}\n`)),s.length>0&&a.log(y.dim(`MCP Servers: ${s.map(e=>e.name).join(`, `)}\n`)));let c=null;try{for await(let e of re({prompt:t.trim(),mode:n,apiKey:o,maxTurns:r,verbose:i,mcpServers:s,origin:`cli`}))st(e,e=>{c&&c.stop(),c=e})}catch(e){c?.fail(),a.error(y.red(`
|
|
130
|
+
Error: `+(e instanceof Error?e.message:String(e)))),process.exit(1)}c?.stop(),a.log(y.green(`
|
|
131
|
+
✓ Done
|
|
132
|
+
`))}};function st(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(F(y.cyan(`Tool: ${n}`)).start());break}case`tool_result`:t(null);break;case`tool_progress`:{let n=e.progress?.operation||e.toolName||`Working...`;t(F(y.cyan(`Tool: ${n}`)).start());break}case`tool_error`:t(null),a.error(y.red(`\nTool error (${e.toolName}): ${e.error??`Unknown error`}`));break;case`error`:t(null),a.error(y.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 ct=class{async execute(){a.log(y.blue.bold(`🤖 StackOne Agent Setup - Local Project
|
|
133
|
+
`));try{let t=process.cwd();g(t)&&v(await _(t));let n=await e();if(!n||!o(n)){a.warn(`Not authenticated globally.`),a.log(y.white(`Let's authenticate now...
|
|
134
|
+
`));let e=Ce({input:V,output:H}),t=await new Promise(t=>{e.question(y.white(`Email: `),e=>{t(e.trim())})});e.close(),t||(a.error(`Email is required`),process.exit(1));let r=await U.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);r.password||(a.error(`Password is required`),process.exit(1)),a.log(``);let i=F(`Authenticating...`).start(),o=await rt.login(t,r.password);(!o.success||!o.apiKey)&&(i.fail(`Authentication failed`),a.error(`${o.error||`Invalid credentials`}`),a.log(y.dim(`Please check your email and password and try again.
|
|
135
|
+
`)),process.exit(1)),i.succeed(`Login successful!`);let s=new Date(Date.now()+10080*60*1e3).toISOString();await d({apiKey:o.apiKey,userId:t,email:t,expiresAt:s,serverUrl:l()}),n={apiKey:o.apiKey,userId:t,email:t,expiresAt:s,serverUrl:l()},a.log(``)}a.success(`Setup complete!`),a.log(y.white(`
|
|
136
|
+
Token saved to:`)),a.log(y.cyan(` ~/.stackone/agent-config.json`)),a.log(``),process.exit(0)}catch(e){e instanceof Error?a.error(e.message):a.error(`Unknown error occurred`),process.exit(1)}}},lt=class{async execute(e){let t=C(),n=e?.mode;if(a.log(y.bold(`
|
|
137
|
+
Available skills
|
|
138
|
+
`)),t.length===0){a.log(y.dim(` No bundled skills found.
|
|
139
|
+
`));return}for(let e of t)a.log(` • ${e}`);if(n){let e=ae(n);if(e.length>0){a.log(y.bold(`\nRecommended for mode "${n}":\n`));for(let n of e){let e=t.includes(n);a.log(` • ${n}${e?``:y.dim(` (not found)`)}`)}}}a.log(``)}};const ut={profiles:{}},dt=()=>{let e=t.readConfigFile(m);if(!e)return ut;try{return JSON.parse(e)}catch{return ut}},ft=e=>dt().profiles[e],pt=e=>!!dt().profiles[e],mt=(e,n)=>{let r=dt();r.profiles[e]=n,t.writeConfigFile(m,JSON.stringify(r,null,2))},ht=()=>{let e=dt();return Object.keys(e.profiles)},gt=`https://api.stackone.com`;var _t=class{async execute({profile:e,connector:t,apiUrl:n,apiKey:r}={}){if(!e&&!r&&(a.error(`Profile or API key is required`),a.log(`Please provide a profile using the ${c(`--profile`)} option or an API key using the ${c(`--api-key`)} option.`),a.log(`To create a profile, run ${c(`stackone init`)}.`),process.exit(1)),e&&r&&(a.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&n&&a.warn(`Specifying ${c(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!pt(e)){a.error(`Configuration profile ${c(e)} not found`),a.log(`Run ${c(`stackone init`)} to create a new configuration profile.\n`);let t=ht();t.length>0&&(a.info(`Available configuration profiles:`),t.forEach(e=>{a.log(` - ${y.blue(e)}`)})),process.exit(1)}let i=e?ft(e):{apiUrl:n??gt,apiKey:r};i?.apiKey||(a.error(`API key is missing`),a.log(`Please provide a valid API key in the profile or via the ${c(`--api-key`)} option.`),process.exit(1)),t||(a.error(`Connector identifier is required in the format provider_key@version.`),process.exit(1));let o=t.split(`@`);(o.length!==2||!o[0]||!o[1])&&(a.error(`Invalid connector format ${u(t)}. Expected format: ${c(`provider_key@version`)}`),process.exit(1));let s=i.apiUrl??gt,l=await this.dropConnector(t,s,i.apiKey);process.exit(l?0:1)}async dropConnector(e,t,n){let o=F(`🗑️ Dropping connector ${c(e)}...`).start();try{let i=Buffer.from(n).toString(`base64`),s=await fetch(`${t}/registry/connectors/${e}`,{method:`DELETE`,headers:{Authorization:`Basic ${i}`}});return o.stop(),s.status===204?(a.success(`Successfully dropped connector ${c(e)} from the registry`),!0):s.status===404?(a.error(`Connector ${c(e)} not found in the registry`),!1):s.status===401||s.status===403?(a.error(`You do not have permission to drop this connector`),!1):s.status===409?(a.error(`Connector ${c(e)} has associated configs and cannot be dropped`),a.log(`Please delete all associated integration configurations before dropping the connector.`),!1):(s.ok||await r(s,`Failed to drop connector ${c(e)} from the registry`),!1)}catch(n){return o.stop(),a.error(`Failed to drop connector ${c(e)} from registry: ${n.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),!1}}};const vt=`stackone`;async function yt(e,t){t.length===0&&(a.error(`Multiple versions of connector ${c(e)} were found but no owner information was returned`),process.exit(1));let n=t.map(e=>({value:e,label:e===vt?`StackOne`:`Custom`,hint:e===vt?`Official StackOne connector`:`Custom connector version created by your organization`}));a.warn(`Multiple versions of connector ${c(e)} were found. Please select which version to use.`);let r=await X({message:`Which version would you like to use?`,options:n});return Y(r)&&(a.error(`Operation cancelled.`),process.exit(1)),r}const bt=`https://api.stackone.com`;var xt=class{async execute({profile:e,connector:t,accountId:r,format:i,outputFile:o,apiUrl:s,apiKey:l,owner:d}={}){if(!e&&!l&&(a.error(`Profile or API key is required`),a.log(`Please provide a profile using the ${c(`--profile`)} option or an API key using the ${c(`--api-key`)} option.`),a.log(`To create a profile, run ${c(`stackone init`)}.`),process.exit(1)),e&&l&&(a.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&s&&a.warn(`Specifying ${c(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!pt(e)){a.error(`Configuration profile ${c(e)} not found`),a.log(`Run ${c(`stackone init`)} to create a new configuration profile.\n`);let t=ht();t.length>0&&(a.info(`Available configuration profiles:`),t.forEach(e=>{a.log(` - ${y.blue(e)}`)})),process.exit(1)}let f=e?ft(e):{apiUrl:s??bt,apiKey:l};f?.apiKey||(a.error(`API key is missing`),a.log(`Please provide a valid API key in the profile or via the ${c(`--api-key`)} option.`),process.exit(1)),W(t)&&W(r)&&(a.error(`Either ${c(`--connector`)} or ${c(`--account-id`)} must be provided`),process.exit(1)),G(t)&&G(r)&&(a.error(`Please provide either ${c(`--connector`)} or ${c(`--account-id`)}, not both.`),process.exit(1)),G(i)&&i!==`yaml`&&i!==`json`&&(a.error(`Format must be either ${c(`yaml`)} or ${c(`json`)}.`),process.exit(1));let p=f.apiUrl??bt,m;if(G(t)){this.#t(t)||(a.error(`Invalid connector format ${u(t)}. Expected format: ${c(`provider_key@version`)} or ${c(`provider_key`)}`),process.exit(1));let e=this.#n(t);m=await this.#r(e,p,f.apiKey,i,d)}else G(r)?m=await this.#i(r,p,f.apiKey,i):(a.error(`Either ${c(`--connector`)} or ${c(`--account-id`)} must be provided`),process.exit(1));if(G(o))try{I.writeFileSync(o,m,`utf-8`),a.success(`Connector written to file: ${c(o)}`)}catch(e){a.error(`Failed to write connector to file ${c(o)}: ${e.message}`),process.exit(1)}else if(a.log(`\n${y.blue.inverse(` CONNECTOR CONTENT `)}\n`),!i||i===`yaml`)a.log(this.#e(m));else if(i===`json`)try{n(JSON.parse(m))}catch{a.log(m)}else a.log(m);process.exit(0)}#e(e){return e.split(`
|
|
140
|
+
`).map(e=>{if(e.trim().startsWith(`#`))return y.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,y.cyan(a)):a===`null`||a===`~`?i=r.replace(a,y.gray(a)):/^-?\d+(\.\d+)?$/.test(a)?i=r.replace(a,y.green(a)):(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`)||a&&!a.startsWith(`-`))&&(i=r.replace(a,y.yellow(a))),y.red(n)+i}return e.trim().startsWith(`-`)?e.replace(`-`,y.gray(`-`)):e}).join(`
|
|
141
|
+
`)}#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,t,n,o,s){let l=F(`Getting connector ${c(e)} from registry...`).start();try{let i=Buffer.from(n).toString(`base64`),a=o?`?format=${o}`:``,u=s?`${a?`&`:`?`}owner=${encodeURIComponent(s)}`:``,d=await fetch(`${t}/registry/connectors/${e}${a}${u}`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});if(l.stop(),d.status===409){s&&(await r(d,`Failed to get connector ${c(e)} from the registry`),process.exit(1));let n=await yt(e,(await d.json()).availableOwners??[]),o=`${t}/registry/connectors/${e}${a}${a?`&`:`?`}owner=${encodeURIComponent(n)}`;l.text=`Getting connector ${c(e)} from registry...`,l.start();let u=await fetch(o,{method:`GET`,headers:{Authorization:`Basic ${i}`}});return l.stop(),u.ok||(await r(u,`Failed to get connector ${c(e)} from the registry`),process.exit(1)),await u.text()}return d.ok||(await r(d,`Failed to get connector ${c(e)} from the registry`),process.exit(1)),await d.text()}catch(n){l.stop(),a.error(`Failed to get connector ${c(e)} from the registry: ${n.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),process.exit(1)}}async#i(e,t,n,o){let s=F(`Getting connector from account ${c(e)}...`).start();try{let i=Buffer.from(n).toString(`base64`),a=o?`?format=${o}`:``,l=await fetch(`${t}/accounts/${e}/connector${a}`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});return s.stop(),l.ok||(await r(l,`Failed to get connector from account ${c(e)}`),process.exit(1)),await l.text()}catch(n){s.stop(),a.error(`Failed to get connector from account ${c(e)}: ${n.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),process.exit(1)}}};const St=`http://localhost:4000`;var Ct=class{async execute({environment:e}={}){let t=e?.toLowerCase()??`production`;try{J(`${y.inverse(` Initialize profile `)}`);let e=await Z({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(Y(e))return q(`Configuration profile initialization cancelled`),process.exit(0);if(pt(e)){let t=await Te({message:`Configuration profile with name ${c(e)} already exists. Do you want to overwrite it?`});if(Y(t)||!t)return q(`Configuration profile initialization cancelled`),process.exit(0)}let n;if(t===`production`)n=`https://api.stackone.com`;else if(t===`staging`)n=`https://api.stackone-dev.com`;else{let e=await Z({message:`API URL`,placeholder:St,initialValue:St,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(Y(e))return q(`Configuration profile initialization cancelled`),process.exit(0);n=e}let r=await De({message:`API Key`,validate:e=>{if(!e||e.trim().length===0)return`API Key is required`}});if(Y(r))return q(`Configuration profile initialization cancelled`),process.exit(0);mt(e,{label:e,environment:t,apiUrl:n,apiKey:r}),Ee(`${y.green(`✔`)} Configuration profile ${c(e)} initialized successfully!`),process.exit(0)}catch(e){e?.isTtyError?a.error(`Prompt couldn't be rendered in the current environment`):a.error(`Failed to initialize configuration profile: ${e}`),process.exit(1)}}};const $={pending:`○`,acceptRemote:`●`,acceptLocal:`◐`,acceptBoth:`◑`,current:`◉`,arrow:`→`,check:`✓`,cross:`✗`,warning:`⚠`};var wt=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`
|
|
142
|
+
`: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(){s();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),o=r-i,s=` `.repeat(i)+`CONFLICT RESOLVER`+` `.repeat(o);a.log(``),a.log(y.bgBlue.white.bold(s)),a.log(y.gray(this.centerText(t,e))),a.log(y.gray(this.centerText(n,e))),a.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=y.green;break;case`local`:i=r?$.current:$.acceptLocal,a=y.yellow;break;case`both`:i=r?$.current:$.acceptBoth,a=y.cyan;break;default:i=r?$.current:$.pending,a=r?y.white:y.gray}return a(i)}),i=t.filter(e=>e.choice!==`pending`).length,o=` Conflict ${n+1} of ${this.totalConflicts} • ${i}/${this.totalConflicts} resolved `;a.log(y.gray(this.centerText(o,e))),a.log(this.centerText(r.join(` `),e)),a.log(``)}renderCurrentConflict(e){let t=this.conflicts[this.currentIndex];if(!t||t.conflict.type!==`conflict`)return;let n=t.conflict;if(a.log(y.gray(`_`.repeat(e))),a.log(`
|
|
143
|
+
|
|
144
|
+
`),n.local){let e=t.choice===`local`||t.choice===`both`?y.yellow.bold(`${$.check} LOCAL (keeping)`):y.red.bold(`${$.cross} LOCAL (removing)`),r=n.local.split(`
|
|
145
|
+
`).filter(e=>e!==``),i=r.slice(0,20),o=t.choice===`local`||t.choice===`both`?y.yellow:y.red,s=i.map(e=>o(`- ${e}`)).join(`
|
|
146
|
+
`),c=r.length>20?`\n${y.gray(`... and ${r.length-20} more lines`)}`:``;a.log(`${e}\n\n${s}${c}`)}if(a.log(`
|
|
147
|
+
|
|
148
|
+
`),a.log(y.gray(`_`.repeat(e))),a.log(`
|
|
149
|
+
|
|
150
|
+
`),n.remote){let e=t.choice===`remote`||t.choice===`both`?y.green.bold(`${$.check} REMOTE (accepting)`):y.gray.bold(`${$.pending} REMOTE (skipping)`),r=n.remote.split(`
|
|
151
|
+
`).filter(e=>e!==``),i=r.slice(0,20),o=t.choice===`remote`||t.choice===`both`?y.green:y.gray,s=i.map(e=>o(`+ ${e}`)).join(`
|
|
152
|
+
`),c=r.length>20?`\n${y.gray(`... and ${r.length-20} more lines`)}`:``;a.log(`${e}\n\n${s}${c}`)}a.log(`
|
|
153
|
+
|
|
154
|
+
`),a.log(y.gray(`_`.repeat(e))),a.log(``)}renderControls(e){let t=[y.green(`[R] Accept Remote`),y.yellow(`[L] Keep Local`),y.cyan(`[B] Keep Both`),y.gray(`[U] Undo`)],n=[y.gray(`[←/→] Navigate`),y.gray(`[A] Accept all remaining`)],r=this.allResolved()?[y.green.bold(`[Enter] Apply Changes`),y.gray(`[Esc] Cancel`)]:[y.gray(`[Enter] Next Unresolved`),y.gray(`[Esc] Cancel`)];a.log(this.centerText(t.join(` `),e)),a.log(``),a.log(this.centerText(n.join(` `),e)),a.log(``),a.log(this.centerText(r.join(` `),e)),this.allResolved()&&(a.log(``),a.log(y.green.bold(this.centerText(`✓ All conflicts resolved!`,e))))}renderFinalSummary(){s();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=[y.green.bold(`Conflict resolution complete`),``,`${y.bold(this.totalConflicts)} conflicts resolved:`,``,`${y.green($.acceptRemote)} Accepted remote: ${t}`,`${y.yellow($.acceptLocal)} Kept local: ${n}`,`${y.cyan($.acceptBoth)} Kept both: ${r}`];a.box(i.join(`
|
|
155
|
+
`))}renderCancelled(){s(),a.log(y.yellow(`Conflict resolution cancelled`)),a.log(``),a.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 Tt=`https://api.stackone.com`;var Et=class{async execute({profile:e,connector:t,outputPath:n,apiUrl:r,apiKey:i,owner:o}={}){if(W(t)&&(a.error(`Connector identifier is required`),a.log(`Please provide a connector identifier using the ${c(`--connector`)} option in the format: ${c(`provider_key@version`)} or ${c(`provider_key`)}`),a.log(`If no version is specified, the latest version will be pulled.`),process.exit(1)),!e&&!i&&(a.error(`Profile or API key is required`),a.log(`Please provide a profile using the ${c(`--profile`)} option or an API key using the ${c(`--api-key`)} option.`),a.log(`To create a profile, run ${c(`stackone init`)}.`),process.exit(1)),e&&i&&(a.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&r&&a.warn(`Specifying ${c(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!pt(e)){a.error(`Configuration profile ${c(e)} not found`),a.log(`Run ${c(`stackone init`)} to create a new configuration profile.\n`);let t=ht();t.length>0&&(a.info(`Available configuration profiles:`),t.forEach(e=>{a.log(` - ${y.blue(e)}`)})),process.exit(1)}let s=e?ft(e):{apiUrl:r??Tt,apiKey:i};s?.apiKey||(a.error(`API key is missing`),a.log(`Please provide a valid API key in the profile or via the ${c(`--api-key`)} option.`),process.exit(1));let l=s.apiUrl??Tt,[u,d]=t.split(`@`),f=await this.#f(u,l,s.apiKey,d??`latest`,o),m=this.#e(f),h=m.version??`unknown`,g=this.#t(n,m.key,h),_=this.#r(g),v=_===null,b=f;if(!v){let e=this.#i(_,g);e&&(a.warn(e.message),e.errors.length>0&&p(e.errors,!1),a.log(``));let n=e?void 0:this.#e(_);if(this.#o(_,f)){this.#a(_,f,g);let e=n?.version??`unknown`,r=await this.#s(_,f,t,e,h);r.action===`cancel`&&(q(`Pull cancelled`),process.exit(0)),r.action===`keep-local`&&(a.log(``),a.info(`Keeping local version. No changes made.`),process.exit(0)),r.action===`interactive-cancel`&&process.exit(0),r.action===`interactive`&&(b=r.resolvedContent)}else a.info(`No changes detected in connector configuration.`),process.exit(0)}let x=Ae(b).connector,ee=x?.key??m.key,S=x?.version??h,te=this.#t(n,ee,S),ne=te;if(te!==g){let e=await this.#n(te);a.log(``),e!==void 0&&(ne=e)}await this.#d(ne,b),v?a.success(`Connector ${c(ee)}@${c(S)} pulled successfully (new connector)`):a.success(`Connector ${c(ee)}@${c(S)} updated successfully`);let re=ee===m.key?c(ee):`${c(m.key)} ${y.whiteBright(`→`)} ${c(ee)}`,C=S===h?c(S):`${c(h)} ${y.whiteBright(`→`)} ${c(S)}`,ie=ne===g?c(ne):`${c(g)}\n ${y.whiteBright(`→`)} ${c(ne)}`;a.log(`\n${y.blue.inverse(` CONNECTOR DETAILS `)}\n`),a.log(` Provider: ${re}`),a.log(` Version: ${C}`),a.log(` Output file: ${ie}`),process.exit(0)}#e(e){let t=Ae(e),n=t?.errors??[];if(t.success)return t.connector;a.error(`Connector pulled from the registry is not valid`),a.log(`Please make sure you are using the latest version of the StackOne CLI by running ${c(`stackone update`)}`),n.length>0&&p(n,!0),process.exit(1)}#t(e,t,n){let r=`${t}_v${n.replaceAll(`.`,`-`)}.s1.yaml`;return e?(I.existsSync(e)&&(I.statSync(e).isDirectory()||(a.error(`Output path ${c(e)} is not a directory`),a.log(`Please provide a valid directory path to store connectors or use the default path.`),process.exit(1))),R.resolve(e,t,r)):R.resolve(process.cwd(),`connectors`,t,r)}async#n(e){if(!I.existsSync(e))return;let t=R.basename(e),n=R.dirname(e);a.warn(`File ${c(t)} already exists at ${c(n)}`);let r=await X({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((Y(r)||r===`cancel`)&&(q(`Operation cancelled. No local changes were made.`),process.exit(0)),r===`override`)return;let i=await Z({message:`Enter the new filename:`,placeholder:t,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=R.join(n,e.trim());if(I.existsSync(t))return`File ${e} already exists`}});return Y(i)&&(q(`Operation cancelled. No local changes were made.`),process.exit(0)),R.join(n,i.trim())}#r(e){if(!I.existsSync(e))return null;try{return I.readFileSync(e,`utf-8`)}catch{return null}}#i(e,t){try{let n=Ae(e);if(!n.success){let e=n.errors??[];return{message:`Local connector ${c(R.basename(t))} has validation errors:`,errors:e}}}catch(e){return{message:`Local connector ${c(R.basename(t))} could not be validated: ${e.message}`,errors:[]}}return null}#a(e,t,n){let r=Q(e,t);if(!r.some(e=>e.added||e.removed)){a.info(`No changes detected in connector configuration.`);return}a.log(`${y.blue.inverse(` CHANGES `)}\n`),a.log(y.gray(`--- local: ${n}`)),a.log(y.gray(`+++ remote: StackOne Registry`)),a.log(``);let i=0,o=0;for(let e of r){let t=e.value.split(`
|
|
156
|
+
`).filter(e=>e!==``);if(e.added){i+=t.length;for(let e of t)a.log(y.green(`+ ${e}`))}else if(e.removed){o+=t.length;for(let e of t)a.log(y.red(`- ${e}`))}else if(t.length<=6)for(let e of t)a.log(y.gray(` ${e}`));else{for(let e=0;e<3;e++)a.log(y.gray(` ${t[e]}`));a.log(y.gray(` ... (${t.length-6} unchanged lines)`));for(let e=t.length-3;e<t.length;e++)a.log(y.gray(` ${t[e]}`))}}a.log(``),a.log(y.gray(`Summary: ${y.green(`+${i}`)} additions, ${y.red(`-${o}`)} deletions`))}#o(e,t){return Q(e,t).some(e=>e.added||e.removed)}async#s(e,t,n,r,i){a.log(``);let o=await X({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(Y(o))return{action:`cancel`};if(o===`override`)return{action:`override`};if(o===`keep-local`)return{action:`keep-local`};if(o===`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 o=Q(e,t),c=this.#u(o);if(c.length===0)return a.info(`No conflicts to resolve.`),t;let l=new wt(c,n,r,i);for(;;){if((await l.resolve()).cancelled)return null;let e=l.getResolvedContent(),t=Ae(e);if(t.success)return l.renderFinalSummary(),e;let n=await this.#l(t.errors);if(n===`cancel`)return s(),a.info(`Operation cancelled. No changes were made to the local connector.`),null;if(n===`save`)return s(),a.warn(`The connector was saved but it is invalid`),e;l.resetForReResolution()}}async#l(e){let{createInterface:t}=await import(`readline`);return new Promise(n=>{s();let r=(e||[{message:`Unknown validation error`}]).map(e=>` • ${e.message}`).join(`
|
|
157
|
+
`);a.box({title:`⚠️ Validation Failed`,message:`The resolved connector configuration is invalid:\n\n${r}`,style:{borderColor:`yellow`,padding:1}}),a.log(``),a.log(y.bold(` Choose an action:`)),a.log(``),a.log(y.cyan(` [B]`)+` ← Go back to conflict resolution`),a.log(y.dim(` Modify your choices to fix the validation errors`)),a.log(``),a.log(y.yellow(` [S]`)+` 💾 Save anyway`),a.log(y.dim(` Save the invalid configuration (not recommended)`)),a.log(``),a.log(y.red(` [C]`)+` ✖ Cancel`),a.log(y.dim(` Discard all changes`)),a.log(``);let i=t({input:process.stdin,output:process.stdout});process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume();let o=e=>{let t=e.toString().toLowerCase(),r=()=>{process.stdin.removeListener(`data`,o),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`,o)})}#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,t){let n=R.dirname(e);I.existsSync(n)||I.mkdirSync(n,{recursive:!0});try{I.writeFileSync(e,t,`utf-8`)}catch(t){a.error(`Failed to write connector to file ${c(e)}: ${t.message}`),process.exit(1)}}async#f(e,t,n,r,o){let s=F(`Pulling connector ${c(e)}@${c(r)} from registry...`).start();try{let i=Buffer.from(n).toString(`base64`),a=`${t}/registry/connectors/${e}@${r}${o?`?owner=${encodeURIComponent(o)}`:``}`,l=await fetch(a,{method:`GET`,headers:{Authorization:`Basic ${i}`}});if(s.stop(),l.status===409){o&&(await this.#p(l,e,r),process.exit(1));let n=(await l.json()).availableOwners??[],a=await yt(`${e}@${r}`,n);s.text=`Pulling connector ${c(e)}@${c(r)} from registry...`,s.start();let u=`${t}/registry/connectors/${e}@${r}`,d=await fetch(`${u}?owner=${encodeURIComponent(a)}`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});return s.stop(),d.ok||(await this.#p(d,e,r),process.exit(1)),await d.text()}return l.ok||(await this.#p(l,e,r),process.exit(1)),await l.text()}catch(n){s.stop(),a.error(`Failed to pull connector ${c(e)}@${c(r)} from the registry: ${n.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid.`),process.exit(1)}}async#p(e,t,n){switch(e.status){case 401:case 403:a.error(`Access denied`),a.log(`Please ensure that your API key is valid and has the ${c(`connectors:read`)} scope required to pull connectors.`);break;case 404:a.error(`Connector ${c(t)}@${c(n)} was not found in the registry`),await this.#m(t);break;case 429:a.error(`Rate limit exceeded`),a.log(`Too many requests. Please wait a moment before trying again.`);break;default:await r(e,`Failed to pull connector ${c(t)}`)}}async#m(e){a.info(`To see available versions, check the connector documentation or contact support.`)}};const Dt=`https://api.stackone.com`;var Ot=class{async execute({profile:e,fileOrDir:t,apiUrl:n,apiKey:r}={}){if(!e&&!r&&(a.error(`Profile or API key is required`),a.log(`Please provide a profile using the ${c(`--profile`)} option or an API key using the ${c(`--api-key`)} option.`),a.log(`To create a profile, run ${c(`stackone init`)}.`),process.exit(1)),e&&r&&(a.error(`Please provide either a profile or an API key, not both`),process.exit(1)),e&&n&&a.warn(`Specifying ${c(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),e&&!pt(e)){a.error(`Configuration profile ${c(e)} not found`),a.log(`Run ${c(`stackone init`)} to create a new configuration profile.\n`);let t=ht();t.length>0&&(a.info(`Available configuration profiles:`),t.forEach(e=>{a.log(` - ${y.blue(e)}`)})),process.exit(1)}let i=e?ft(e):{apiUrl:n??Dt,apiKey:r};i?.apiKey||(a.error(`API key is missing`),a.log(`Please provide a valid API key in the profile or via the ${c(`--api-key`)} option.`),process.exit(1)),t||(a.error(`File or directory is required.`),process.exit(1));try{ye(t)}catch{a.error(`File or directory not found: ${y.red(t)}`),process.exit(1)}let o=ye(t),s=i.apiUrl??Dt;if(o.isDirectory()){let e=Mt(t),n=0;e.length===0?(a.error(`No .s1.yaml connector files found in the directory: ${t}.`),process.exit(1)):(a.start(`Found ${e.length} connector(s) file(s). Pushing to registry...`),a.log(``));for(let t of e)await this.uploadFile(t,s,i.apiKey)&&n++;n===0?a.error(`Error while pushing connectors: no files were uploaded`):(a.log(``),a.info(`Upload completed: ${y.green(n)} of ${y.blue(e.length)} file(s) uploaded successfully.`)),process.exit(n>0?0:1)}else t.endsWith(`.s1.yaml`)||(a.error(`Only ${c(`.s1.yaml`)} files are supported for upload`),process.exit(1));let l=await this.uploadFile(t,s,i.apiKey);process.exit(l?0:1)}async uploadFile(e,t,n){let o=F(`📤 Pushing connector in ${z(e)}...`).start();try{let i=jt(e);if(!i)return!1;let s=z(e),l=new FormData,u=new Blob([i],{type:`application/x-yaml`});l.append(`file`,u,s);let d=Buffer.from(n).toString(`base64`),f=await fetch(`${t}/registry/connectors`,{method:`POST`,headers:{Authorization:`Basic ${d}`},body:l});if(o.stop(),!f.ok)return f.status===409||f.status===422?await this.handleVersionConflict(f,e,t,n):(await r(f,`Failed to push connector in ${c(s)} to the registry`),!1);let p=await f.json();return a.success(`Successfully uploaded ${c(s)} with connector ${c(p.provider)}@${c(p.version)}`),!0}catch(n){return o.stop(),a.error(`Failed to upload file ${c(e)}: ${n}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),!1}}async handleVersionConflict(e,t,n,i){let o=await e.text(),s;try{s=JSON.parse(o)}catch{}let l=Me.valid(s?.latestVersion);if(!l)return await r(new Response(o,{status:e.status,statusText:e.statusText}),`Failed to push connector in ${c(z(t))} to the registry`),!1;let u=L(t,`utf-8`),d=kt(u),f=d?`${c(d)}`:``,p=e.status===409?`Version ${f} already exists in the registry. Latest version: ${c(l)}`:`Version ${f} is lower than the latest version in the registry. Latest version: ${c(l)}`;a.error(p);let m=Me.inc(l,`patch`)??l,h=Me.inc(l,`minor`)??l,g=Me.inc(l,`major`)??l,_=await X({message:`How would you like to proceed?`,options:[{value:m,label:`Bump patch version (${m})`},{value:h,label:`Bump minor version (${h})`},{value:g,label:`Bump major version (${g})`},{value:`cancel`,label:`Cancel push`}]});return Y(_)||_===`cancel`?(q(`Push cancelled`),!1):(be(t,At(u,_),`utf-8`),a.info(`Updated version to ${c(_)} in ${z(t)}`),this.uploadFile(t,n,i))}};const kt=e=>e.match(/^\s*version: (\S+)/m)?.[1],At=(e,t)=>e.replace(/^(\s*version: )\S+/m,`$1${t}`),jt=e=>{let t=Oe(e),n=Ae(t),r=n?.errors??[];if(n.success)return t;r.length>0?(a.error(`Connector in ${u(e)} is not valid`),p(r,!0)):a.error(`Connector in ${u(e)} is not valid. Please check the file for errors.`)},Mt=e=>{let t=[],n=ve(e,{withFileTypes:!0});for(let r of n){let n=B(e,r.name);r.isDirectory()?t.push(...Mt(n)):r.name.endsWith(`.s1.yaml`)&&t.push(n)}return t},Nt=K.object({provider_key:K.string().optional(),provider_version:K.string().optional(),auth_config_key:K.string(),environment:K.string().default(`production`),organization_id:K.string().default(`cli-organization-id`),account_id:K.string().default(`cli-account-secure-id`),project_id:K.string().default(`cli-project-secure-id`),credentials:K.record(K.string(),K.any()).default({})}),Pt=K.record(K.string(),K.any()),Ft=K.object({path:K.record(K.string(),K.any()).default({}),queryParams:K.record(K.string(),K.any()).default({}),header:K.record(K.string(),K.any()).default({}),body:K.record(K.string(),K.any()).default({})}),It=`https://api.stackone.com`;var Lt=class{async execute({connector:e,action:t,actionId:r,account:i,accountId:o,params:s,credentials:l,profile:u,outputFile:d,debug:f,apiUrl:p,apiKey:m,owner:h}={}){if(!u&&!m&&o&&(a.error(`Profile or API key is required when providing an account ID`),a.log(`Please provide a profile using the ${c(`--profile`)} option or an API key using the ${c(`--api-key`)} option.`),a.log(`To create a profile, run ${c(`stackone init`)}.`),process.exit(1)),u&&m&&(a.error(`Please provide either a profile or an API key, not both`),process.exit(1)),u&&p&&a.warn(`Specifying --api-url with a profile won't have any effect. Using API url from profile.`),u&&!pt(u)){a.error(`Configuration profile ${c(u)} not found`),a.log(`Run ${c(`stackone init`)} to create a new configuration profile.\n`);let e=ht();e.length>0&&(a.info(`Available configuration profiles:`),e.forEach(e=>{a.log(` - ${y.blue(e)}`)})),process.exit(1)}let g=u?ft(u):{apiUrl:p??It,apiKey:m};W(i)&&W(o)&&(a.error(`A valid account or account ID is required to run an action`),process.exit(1));let _;if(G(e))if(this.#a(e)){!u&&!m&&(a.error(`Profile or API key is required when using a connector identifier`),a.log(`Please provide a profile using the ${c(`--profile`)} option or an API key using the ${c(`--api-key`)} option.`),a.log(`Run ${c(`stackone init`)} to create a new configuration profile.`),process.exit(1));let t=this.#o(e);_=await this.#s(t,g?.apiUrl??It,g?.apiKey,h)}else _=this.#e(e);else G(o)&&(_=await this.#c(o,g?.apiUrl??It,g?.apiKey));let v=G(t)?this.#r(t,e):_;W(v)&&(a.error(`A valid connector is required to run an action.`),process.exit(1));let b=G(v?.actions)?Object.keys(v?.actions).length:0,x=G(v?.actions)?Object.keys(v.actions)[b-1]:void 0,ee=G(x)?v?.actions?.[x]?.id:void 0,S=(G(r)&&!r?.startsWith(`${v.key}_`)?`${v.key}_${r}`:r)??ee;W(S)&&(a.error(`A valid action ID is required to run an action`),process.exit(1));let te=G(o)?await this.#l(o,g?.apiUrl??It,g?.apiKey):{},ne=G(i)?this.#i(i,v.key??`unknown`,v.version??`unknown`):void 0,re=G(l)?this.#u(l):{},C={...te,...ne,credentials:{...te.credentials??{},...re}};W(C)&&(a.error(`A valid account data is required to run an action.`),process.exit(1));let ie=v.actions?.[S];W(ie)&&(a.error(`Action ID ${c(S)} not found in the connector ${c(v.key)}@${c(v.version)}.`),process.exit(1));let ae=G(s)?this.#d(s,S):{path:{},queryParams:{},header:{},body:{}},oe=Date.now(),w=await this.#f({connector:v,actionId:S,account:C,queryParams:{...ae.queryParams,...f?{debug:`true`}:{}},pathParams:ae.path,body:ae.body,headers:ae.header}),se=Date.now()-oe;if(G(d))try{I.writeFileSync(d,JSON.stringify(w.output,null,2),`utf-8`),a.info(`Output written to file: ${d}`)}catch(e){a.error(`Failed to write output to file ${d}: ${e.message}`),process.exit(1)}else a.log(`\n${y.blue.inverse(` ACTION OUTPUT `)}`),n(w.output);a.log(``),a.info(`Action ${c(S)} from connector ${c(v?.key)}@${c(v?.version)} finished in ${y.yellowBright((se/1e3).toFixed(2))} seconds.`),process.exit(0)}#e=e=>{let t=e;try{t=Oe(e)}catch{}return t?this.#n(t):void 0};#t=e=>{try{return Oe(e)}catch(t){a.error(`Failed to load connector file from ${c(e)}: ${t.message}`),process.exit(1)}};#n=e=>{let t=Ae(e),n=t?.errors??[];if(t.success)return t.connector||(a.error(`Failed to load connector.`),process.exit(1)),t.connector;n.length>0?(a.error(`Connector is not valid`),p(n,!0),process.exit(1)):(a.error(`Connector is not valid. Please check the file for errors.`),process.exit(1))};#r=(e,t)=>{let n=e;try{n=I.readFileSync(e,`utf-8`)}catch{}W(t)&&(a.error(`A valid connector is required to load an action.`),process.exit(1));let r=`${this.#t(t)} - ${n.split(`
|
|
158
|
+
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
159
|
+
`)}`;return this.#n(r)};#i=(e,t,n)=>{let r=e;try{r=I.readFileSync(e,`utf-8`)}catch{}try{let e=Nt.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{}a.error(`Failed to parse account information`),p(t,!1),t.length===0&&a.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,t,n,o)=>{(W(e)||W(t)||W(n))&&(a.error(`Connector identifier, API URL, and API key are required to fetch connector from registry.`),process.exit(1));let s=F();try{s.text=`Fetching connector ${c(e)} from registry...`,s.start();let i=Buffer.from(n).toString(`base64`),l=o?`?owner=${encodeURIComponent(o)}`:``,u=await fetch(`${t}/registry/connectors/${e}${l}`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});if(s.stop(),u.status===409){o&&(await r(u,`Failed to fetch connector ${c(e)} from registry`),process.exit(1));let n=await yt(e,(await u.json()).availableOwners??[]);s.text=`Fetching connector ${c(e)} from registry...`,s.start();let l=await fetch(`${t}/registry/connectors/${e}?owner=${encodeURIComponent(n)}`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});s.stop(),l.ok||(await r(l,`Failed to fetch connector ${c(e)} from registry`),process.exit(1));let d=await l.text(),f=this.#n(d);return a.success(`Fetched connector ${c(f.key)}@${c(f.version)} from registry`),f}u.ok||(await r(u,`Failed to fetch connector ${c(e)} from registry`),process.exit(1));let d=await u.text(),f=this.#n(d);return a.success(`Fetched connector ${c(f.key)}@${c(f.version)} from registry`),f}catch(n){s.stop(),a.error(`Failed to fetch connector ${c(e)} from registry: ${n.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),process.exit(1)}};#c=async(e,t,n)=>{(W(e)||W(t)||W(n))&&(a.error(`Account ID, API URL, and API key are required to fetch connector`),process.exit(1));let o=F();try{o.text=`Fetching connector for account ${c(e)} from API...`,o.start();let i=Buffer.from(n).toString(`base64`),s=await fetch(`${t}/accounts/${e}/connector`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});o.stop(),s.ok||(await r(s,`Failed to fetch connector`),process.exit(1));let l=await s.text(),u=this.#n(l);return a.success(`Fetched connector ${c(u.key)}@${c(u.version)} for account ${c(e)}`),u}catch(e){o.stop(),a.error(`Failed to fetch connector: ${e.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),process.exit(1)}};#l=async(e,t,n)=>{(W(e)||W(t)||W(n))&&(a.error(`Account ID, API URL, and API key are required to fetch account information.`),process.exit(1));let o=F();try{o.text=`Fetching account ${c(e)} information from API...`,o.start();let i=Buffer.from(n).toString(`base64`),s=await fetch(`${t}/accounts/${e}/credentials`,{method:`GET`,headers:{Authorization:`Basic ${i}`}});o.stop(),s.ok||(await r(s,`Failed to fetch account ${c(e)} information`),process.exit(1));let l=await s.json();return a.success(`Fetched account ${c(e)} information from project ${c(l.project_id)}`),{providerKey:l.provider_key,providerVersion:l.provider_version,authConfigKey:l.auth_config_key,environment:l.environment,organizationId:l.organization_id,secureId:l.account_id,projectSecureId:l.project_id,credentials:l.credentials}}catch(n){o.stop(),a.error(`Failed to fetch account ${c(e)} information: ${n.message}`),a.log(`Please ensure that the API at ${i(t)} is reachable and the API key is valid`),process.exit(1)}};#u=e=>{let t=e;try{t=I.readFileSync(e,`utf-8`)}catch{}try{return Pt.parse(JSON.parse(t))}catch(e){let t=[];try{t=JSON.parse(e.message)}catch{}a.error(`Failed to parse credentials`),p(t,!1),t.length===0&&a.log(e.message),process.exit(1)}};#d=(e,t)=>{let n=e;try{n=I.readFileSync(e,`utf-8`)}catch{}try{return Ft.parse(JSON.parse(n))}catch(e){let n=[];try{n=JSON.parse(e.message)}catch{}a.error(`Invalid parameters for action ${c(t)}.`),p(n,!1),n.length===0&&a.log(e.message),process.exit(1)}};async#f({connector:e,actionId:t,account:r,pathParams:i={},queryParams:o={},body:s={},headers:l={}}){try{let u=await ke({mode:`action_id`,actionId:t,account:r,connector:e,pathParams:i,queryParams:o,body:s,headers:l,getHttpClient:async()=>new Ne});if(u.response?.successful){let e={...this.#p(o,u.steps),...we(u.outputs)?u.outputs:{data:u.outputs}};return{statusCode:u.response?.statusCode,output:e}}else{let r=u.response?.message??`An error occurred while processing the request`;a.error(`Action ID ${c(t)} from connector ${c(e.key)}@${c(e.version)} failed with status ${u.response?.statusCode}: ${r}`);let i={...this.#p(o,u.steps)};Object.keys(i).length>0&&(a.log(`${y.yellow.inverse(` EXECUTION DETAILS `)}`),n(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(W(t.errorType)&&(a.error(`An unknown error occurred`),a.log(`${e instanceof Error?e.message:String(e)}`),process.exit(1)),t.errorType){case`MISSING_ACTION_ERROR`:a.error(`The specified action was not found: ${t.message}`);break;case`INVALID_ACTION_INPUTS_ERROR`:let e=t;a.error(`Invalid action inputs`),p(e.validationErrors,!1);break;case`INVALID_CURSOR_ERROR`:a.error(`Invalid cursor: ${t.message}`);break;default:a.error(`An error occurred: ${t.message}`)}process.exit(1)}};const Rt=()=>{try{let e=B(xe(Le(import.meta.url)),`..`,`package.json`);return JSON.parse(L(e,`utf8`)).version}catch{return`unknown`}},zt=Ie(Pe);var Bt=class{constructor(){this.packageName=`@stackone/cli`,this.spinner=F(),this.currentVersion=Rt()}async execute(e={}){this.spinner.text=`Checking for updates...`,this.spinner.start();try{let t=await this.getLatestVersion();this.spinner.stop(),t||(a.error(`Failed to check for updates`),process.exit(1)),this.isNewerVersion(t,this.currentVersion)?(a.box(`New version available: ${y.yellow(this.currentVersion)} → ${y.green(t)}`),await this.performUpdate(t)):e.force?(a.warn(`No updates available, but forcing reinstall...`),await this.performUpdate(t)):a.success(`You are already on the latest version (${this.currentVersion})`),process.exit(0)}catch(e){this.spinner.stop(),a.error(`Error while trying to update StackOne CLI: ${e?.message??`Unknown error`}`),process.exit(1)}}async getLatestVersion(){try{let{stdout:e}=await zt(`npm view ${this.packageName} version`,{encoding:`utf-8`});return e.trim()}catch{return null}}isNewerVersion(e,t){return Me.gt(e,t)}isUsingVolta(){if(typeof process.env.VOLTA_HOME!=`string`||process.env.VOLTA_HOME.length===0)return!1;let e=ue(process.env.VOLTA_HOME,`bin`),t=ue(e,`stackone`),n=ue(e,`stackone.exe`);return se(t)||se(n)}async performUpdate(e){let t=this.isUsingVolta();this.spinner.text=`Updating to latest version (${c(e)})...`,this.spinner.start();try{await zt(t?`volta install ${this.packageName}@latest`:`npm install -g ${this.packageName}@latest`,{encoding:`utf-8`}),this.spinner.stop(),a.success(`StackOne CLI updated successfully to latest version (${c(e)})`)}catch{this.spinner.stop();let e=t?`volta install ${this.packageName}@latest`:`npm install -g ${this.packageName}@latest`;throw Error(`Failed to install update. Please try manually: ${e}`)}}};const Vt=()=>{a.log(`${y.gray.inverse(` CONNECTORS VALIDATION `)} ${y.yellow.inverse(` WATCH MODE `)}\n`)};var Ht=class{async execute(e){let{watchMode:t,fileOrDir:n}=e,r=F(`Watching for file changes... ${y.gray(`(press "q" to quit)`)}`);if(!n)return;let i=Se(n);try{await ze(i)}catch{a.error(`The specified path does not exist: ${i}\n`),process.exit(1)}if(t){s();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 o=()=>{l.close(),r.stop(),n.close(),a.log(y.grey(`
|
|
160
|
+
Exiting watch mode...`)),process.exit(0)};Vt(),a.start(`Validating connectors...`);let c=await Kt(i);e=Ut(e,c||{}),Wt(e,i),r.start();let l=t(i,{persistent:!0,ignoreInitial:!0}),u=async t=>{if(!t.endsWith(`.s1.yaml`)&&!t.endsWith(`s1.partial.yaml`))return;let n=t.endsWith(`s1.partial.yaml`)?await Jt(t):[t];if(!(!n||n.length===0)){s(),r.stop(),Vt(),a.log(y.gray(`File change detected: ${t}`)),a.start(`Validating connectors...`);for(let t of n){let n=await Kt(t);e=Ut(e,n||{})}Wt(e,i),r.start()}};l.on(`change`,async e=>await u(e)),process.stdin.on(`data`,e=>{e.toString()===`q`&&o()}),process.on(`SIGINT`,()=>{o()})}else await Kt(i,a),process.exit(0)}};const Ut=(e,t)=>{for(let[n,r]of Object.entries(t))e[n]=r;return e},Wt=(e,t)=>{s(),Vt();let n=0,r=0;for(let[t,i]of Object.entries(e))i===null?n++:(a?.error(`Connector ${c(t)} is not valid`),p(i,!0),r++);a.log(``),a.log(y.blue.inverse(` Validation Summary `)),a.log(`Connectors path: ${c(t)}`),a.log(`${n===0?y.red(`0`):y.green(n)} valid, ${r===0?y.green(`0`):y.red(r)} invalid connectors\n`)},Gt=async e=>{let t=[],n=await Re(e);for(let r of n){let n=B(e,r),i=await ze(n);i.isDirectory()?t.push(...await Gt(n)):i.isFile()&&r.endsWith(`.s1.yaml`)&&t.push(n)}return t},Kt=async(e,t)=>{let n=await ze(e),r={};if(n.isDirectory()){let n=await Gt(e);if(n.length===0)return t?.error(`No StackOne connector found in ${u(e)}`),t?.log(`Connector files need to have the extension ${c(`*.s1.yaml`)}`),null;let i=0,a=0;for(let e of n){let n=await qt(e,t);n===null?i++:(t?.log(``),a++),r[e]=n}return t?.log(``),t?.log(y.blue.inverse(` Validation Summary `)),t?.log(`${i===0?y.red(`0`):y.green(i)} valid, ${a===0?y.green(`0`):y.red(a)} invalid connectors`),r}else if(n.isFile()&&e.endsWith(`s1.yaml`))return r[e]=await qt(e,t),r;else if(n.isFile()&&e.endsWith(`partial.yaml`)){t?.error(`Partial connector files cannot be validated directly`),t?.log(`The file ${u(e)} is a partial connector file.`);let n=await Jt(e);return n&&n?.length>0&&t?.log(`Did you mean ${c(n[0])}?`),null}else return t?.error(`No StackOne connector found in ${u(e)}`),t?.log(`Connector files need to have the extension ${c(`*.s1.yaml`)}`),null},qt=async(e,t)=>{let n=Ae(Oe(e)),r=n?.errors??[];if(n.success){let n=e.split(`/`).pop()||e;return t?.success(`Connector ${c(n)} is valid!`),null}else if(r.length>0)return t?.error(`Connector ${c(e)} is not valid`),t&&p(r,!0),r;else return t?.error(`Connector ${c(e)} is not valid. Please check the file for errors`),[]},Jt=async e=>{let t=xe(e);try{return(await Re(t)).filter(e=>e.endsWith(`.s1.yaml`))?.map(e=>B(t,e))}catch{}};function Yt(){let e=process.env.STACKONE_AGENT_TOKEN,t=process.env.LANGSMITH_PROJECT||`stackone-agent-cli`;if(e)try{oe({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 Xt=ue(le(),`.stackone`),Zt=ue(Xt,`version-check.json`),Qt=(e=!1)=>{let t=nn(),n=Date.now();if(e||!t||n-t.lastCheckTime>1728e5){let e=$t();e&&en(e)&&tn(e),rn({lastCheckTime:n})}},$t=()=>{try{return Fe(`npm view @stackone/cli version`,{encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`],timeout:15e3}).trim()}catch{return null}},en=e=>{try{let t=Rt();return Me.gt(e,t)}catch{return!1}},tn=e=>{let t=Rt(),n=`Update available: ${y.dim(t)} → ${y.green(e)}`,r=`\n\nRun ${y.cyan(`stackone update`)} to update`;a.box(n,r)},nn=()=>{try{if(!se(Zt))return null;let e=T(Zt,`utf-8`);return JSON.parse(e)}catch{return null}},rn=e=>{try{se(Xt)||ce(Xt,{recursive:!0}),E(Zt,JSON.stringify(e,null,2),`utf-8`)}catch{}};var an=class{constructor(e=new x,t=Rt()){this.program=e,this.version=t,Yt(),this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne CLI`).version(this.version,`-v, --version`)}registerCommands(){let e=new Ct,t=new Ot,n=new Et,r=new _t,i=new xt,o=new Ht,s=new at,c=new ct,l=new nt,u=new tt,d=new ot,f=new lt,p=new Lt,m=new Bt;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(e,t)=>{t(y.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`).addArgument(new b(`<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})}),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 b(`<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&&(a.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&&(a.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 b(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{o.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&&(a.error(`--builtin, --custom, and --owner are mutually exclusive. Please provide only one.`),process.exit(1)),p.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 h=this.program.command(`agent`).description(`StackOne agent commands`);h.command(`setup`).option(`-g, --global`,`Setup global configuration`).option(`-l, --local`,`Setup local project configuration`).description(`Setup StackOne agent (global or local)`).action(e=>{e.global?s.execute():c.execute()}),h.command(`cleanup`).description(`Remove all API keys and credentials from configurations`).action(()=>{l.execute()}),h.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)||(a.error(`${y.red(`Invalid mode:`)} ${y.white(r)}. Valid modes are: ${n.join(`, `)}.`),process.exit(1));let i=t.maxTurns?parseInt(String(t.maxTurns),10):void 0;await d.execute({prompt:String(e),mode:r,maxTurns:i!==void 0&&!isNaN(i)?i:void 0,verbose:t.verbose})}),h.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 f.execute({mode:e.mode})}),h.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)&&(a.error(`❌ Error: Invalid mode "${e.mode}". Must be one of: ${t.join(`, `)}`),process.exit(1)),e.temperature!==void 0&&(isNaN(e.temperature)&&(a.error(`❌ Error: Temperature must be a valid number`),process.exit(1)),(e.temperature<0||e.temperature>1)&&(a.error(`❌ Error: Temperature must be between 0 and 1`),process.exit(1))),u.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=>{m.execute({force:e.force})}),this.program.command(`version`).description(`Show version information`).action(async()=>{a.log(`${y.inverse.greenBright(`StackOne`)} ${y.grey(`CLI`)} ${y.whiteBright(this.version)}`),Qt(!0),process.exit(0)})}run(){process.argv.includes(`version`)||Qt(),this.program.parse(process.argv)}};export{an as t};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./agentConfig-BTZi_eTF.cjs`);const e=require(`./cliCore-
|
|
1
|
+
require(`./agentConfig-BTZi_eTF.cjs`);const e=require(`./cliCore-Bd0YUFKF.cjs`);require(`./agentApiKey-D0XnbpYf.cjs`),require(`./setupMigration-CbFy6i_l.cjs`),exports.CLI=e.t;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./agentConfig-D_NqqTkf.mjs";import{t as e}from"./cliCore-
|
|
1
|
+
import"./agentConfig-D_NqqTkf.mjs";import{t as e}from"./cliCore-C8PH3YeQ.mjs";import"./agentApiKey-XBjE_ul4.mjs";import"./setupMigration-DsLJUF0a.mjs";export{e as CLI};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/cli",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.2",
|
|
4
4
|
"description": "StackOne Connect CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@stackone/connect-sdk": "2.34.4",
|
|
51
51
|
"@stackone/core": "2.27.4",
|
|
52
52
|
"@stackone/defender": "0.4.5",
|
|
53
|
-
"@stackone/transport": "2.14.
|
|
53
|
+
"@stackone/transport": "2.14.2",
|
|
54
54
|
"@stackone/utils": "0.19.0",
|
|
55
55
|
"chalk": "5.6.2",
|
|
56
56
|
"chokidar": "5.0.0",
|
|
@@ -107,5 +107,10 @@
|
|
|
107
107
|
"volta": {
|
|
108
108
|
"node": "22.14.0",
|
|
109
109
|
"npm": "11.6.4"
|
|
110
|
+
},
|
|
111
|
+
"overrides": {
|
|
112
|
+
"@aws-sdk/xml-builder": {
|
|
113
|
+
"fast-xml-parser": "5.4.2"
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
}
|