@stackone/cli 1.22.0 → 1.22.1
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-DYqmD_Xk.cjs → cliCore-B2FdSol-.cjs} +38 -38
- package/dist/cliCore-hs89zWPz.mjs +120 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/cliCore-BlRDois6.mjs +0 -120
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const e=require(`./agentConfig-BvRdgehY.cjs`),t=require(`./fileNames-Booqk8P6.cjs`),n=require(`./setupMigration-DqOL4hdx.cjs`);let r=require(`chalk`);r=e.y(r);let i=require(`commander`),a=require(`@stackone/agent-harness`),o=require(`node:fs`);o=e.y(o);let s=require(`node:os`);s=e.y(s);let c=require(`node:path`);c=e.y(c);let l=require(`ink`),u=require(`react`);u=e.y(u);let d=require(`ink-spinner`);d=e.y(d);let f=require(`fs`);f=e.y(f);let p=require(`path`);p=e.y(p);let m=require(`url`),h=require(`node:child_process`),g=require(`node:fs/promises`),_=require(`node:util`),v=require(`ora`);v=e.y(v);let y=require(`node:process`),b=require(`node:readline`),x=require(`inquirer`);x=e.y(x);let S=require(`@stackone/utils`),C=require(`@clack/prompts`),w=require(`@stackone/connect-sdk`),T=require(`diff`),ee=require(`readline`),E=require(`@stackone/transport`),D=require(`semver`);D=e.y(D);let O=require(`fs/promises`);function k(e){return e.replace(/\*\*\*(.+?)\*\*\*/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(
|
|
2
|
-
`||e===`\r`}function
|
|
3
|
-
`+
|
|
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=r.findIndex(e=>
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
${
|
|
1
|
+
const e=require(`./agentConfig-BvRdgehY.cjs`),t=require(`./fileNames-Booqk8P6.cjs`),n=require(`./setupMigration-DqOL4hdx.cjs`);let r=require(`chalk`);r=e.y(r);let i=require(`commander`),a=require(`@stackone/agent-harness`),o=require(`node:fs`);o=e.y(o);let s=require(`node:os`);s=e.y(s);let c=require(`node:path`);c=e.y(c);let l=require(`ink`),u=require(`react`);u=e.y(u);let d=require(`ink-spinner`);d=e.y(d);let f=require(`fs`);f=e.y(f);let p=require(`path`);p=e.y(p);let m=require(`url`),h=require(`node:child_process`),g=require(`node:fs/promises`),_=require(`node:util`),v=require(`ora`);v=e.y(v);let y=require(`node:process`),b=require(`node:readline`),x=require(`inquirer`);x=e.y(x);let S=require(`@stackone/utils`),C=require(`@clack/prompts`),w=require(`@stackone/connect-sdk`),T=require(`diff`),ee=require(`readline`),E=require(`@stackone/transport`),D=require(`semver`);D=e.y(D);let O=require(`fs/promises`);function k(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 A(e){return e===` `||e===` `||e===`
|
|
2
|
+
`||e===`\r`}function te(e,t){let n=t-1;for(;n>=0&&A(e[n]);)n--;for(;n>=0&&!A(e[n]);)n--;return n+1}function ne(e,t){let n=t;for(;n<e.length&&A(e[n]);)n++;for(;n<e.length&&!A(e[n]);)n++;return n}const re={type:`header`};function ie(e){return e.filter(e=>!(e.role===`system`&&e.content.startsWith(`TOOL_START:`)))}const ae=({title:e,mode:t,connector:n,action:r,onSubmit:i,onExit:a,onStop:o,messages:s,currentToolCalls:c=[],isThinking:f=!1,isComplete:p=!1,error:m,isInterrupted:h=!1,commandHistory:g=[],streamingText:_=``,usage:v,detailViewData:y=null,onCloseDetailView:b,onResumeConversation:x,onToggleSkill:S,onToggleTrust:C,onRewindTo:w,spawnedSubagentActive:T=!1,spawnedSubagentName:ee=`Subagent`,spawnedSubagentComplete:E=!1,queuedMessages:D=[],isProcessingQueue:O=!1,enabledSkills:A=[],initInfo:ae,pendingDeleteConfirmation:j=null,onConfirmDelete:M,lastSubmittedUserContent:oe,lastSubmittedUserTimestamp:se})=>{let{exit:ce}=(0,l.useApp)(),[N,P]=(0,u.useState)(``),[F,I]=(0,u.useState)(0),L=(0,u.useRef)(0),[le,R]=(0,u.useState)(!0),ue=(0,u.useRef)(s),[de,z]=(0,u.useState)(-1),fe=(0,u.useRef)(g),pe=(0,u.useRef)(``),[B,me]=(0,u.useState)([]),[V,he]=(0,u.useState)(0),[H,U]=(0,u.useState)(0),[W,ge]=(0,u.useState)(!1),[G,K]=(0,u.useState)(!1),[_e,ve]=(0,u.useState)(!1),[q,ye]=(0,u.useState)(!1),J=(0,u.useRef)(``),[Y,X]=(0,u.useState)(1),[be,xe]=(0,u.useState)(null),[Z,Q]=(0,u.useState)(1),Se=[`/commands`,`/skills`,`/tools`,`/mcp`,`/trust`,`/compact`,`/rewind`,`/resume`,`/exit`];(0,u.useEffect)(()=>{ue.current=s},[s]),(0,u.useEffect)(()=>{fe.current=g},[g]),(0,u.useEffect)(()=>{pe.current=N,N.startsWith(`/`)?(me(Se.filter(e=>e.startsWith(N.toLowerCase()))),he(0)):(me([]),he(0))},[N]),(0,u.useEffect)(()=>{L.current=F},[F]),(0,u.useEffect)(()=>{if(y?.items){let e=Math.max(0,y.items.length-1);U(t=>Math.min(t,e))}},[y?.items?.length]),(0,l.useInput)((0,u.useCallback)((e,t)=>{let n=pe.current,r=de;if(t.escape&&(f||_||c.length>0)){o?.(),P(``),pe.current=``,L.current=0,I(0),z(-1);return}if(t.escape&&T&&_e){ve(!1);return}if(t.escape&&q&&!T){ye(!1);return}if(j&&M){if(t.escape||e.toLowerCase()===`n`){X(1),M(!1);return}if(e.toLowerCase()===`y`){X(0),M(!0);return}if(t.upArrow||t.downArrow){X(e=>e===0?1:0);return}if(t.return){M(Y===0);return}return}if(y){if(be){if(t.escape||t.ctrl&&e===`c`){xe(null);return}if(t.leftArrow||t.rightArrow){Q(e=>e===0?1:0);return}if(e.toLowerCase()===`y`){C&&C(be.path),xe(null);return}if(e.toLowerCase()===`n`){xe(null);return}if(t.return){Z===0&&C&&C(be.path),xe(null);return}return}if(t.escape||t.ctrl&&e===`c`)if(W){ge(!1);return}else{b?.(),U(0);return}if(t.upArrow&&!W){U(e=>e>0?e-1:y.items.length-1);return}if(t.downArrow&&!W){U(e=>e<y.items.length-1?e+1:0);return}if(t.ctrl&&e===`o`){if(y.type===`skills`){let e=y.items[H];S&&S(e.name);return}if(y.type===`trust`&&!be&&!W){let e=y.items[H];e?.path&&(xe({path:e.path,name:e.name}),Q(1));return}}if(t.return){if(W)return;if(y.type===`resume`){let e=y.items[H];e.messages&&x&&(x(e.messages),b?.(),U(0));return}if(y.type===`rewind`){let e=y.items[H];e.index!==void 0&&w&&(w(e.index),b?.(),U(0));return}ge(!0);return}return}if(t.ctrl&&e===`o`){T?ve(e=>!e):ye(e=>!e);return}if(t.ctrl&&e===`u`){P(``),L.current=0,I(0),z(-1),K(!1);return}if(t.ctrl&&e===`c`||e===``)if(n.trim()){P(``),L.current=0,I(0),z(-1),K(!1);return}else if(G){a(),ce();return}else{K(!0);return}if(t.shift&&t.return){let e=L.current;P(t=>t.slice(0,e)+`
|
|
3
|
+
`+t.slice(e));let t=e+1;L.current=t,I(t);return}if(t.ctrl&&e===`a`){L.current=0,I(0);return}if(t.ctrl&&e===`e`){L.current=n.length,I(n.length);return}let s=e===`\x1Bb`||e===`b`&&(t.alt||t.meta)||e===`\x1B\x1B[D`||e===`\x1B[1;3D`||e===`\x1B[1;9D`||(t.alt||t.meta)&&t.leftArrow&&!t.ctrl&&!t.shift,l=e===`\x1Bf`||e===`f`&&(t.alt||t.meta)||e===`\x1B\x1B[C`||e===`\x1B[1;3C`||e===`\x1B[1;9C`||(t.alt||t.meta)&&t.rightArrow&&!t.ctrl&&!t.shift;if(s){let e=te(n,L.current);L.current=e,I(e);return}if(l){let e=ne(n,L.current);L.current=e,I(e);return}if(t.home||e===`\x1B[H`||e===`\x1BOH`){L.current=0,I(0);return}if(t.end||e===`\x1B[F`||e===`\x1BOF`){L.current=n.length,I(n.length);return}if(process.platform===`darwin`&&t.meta&&t.leftArrow&&!t.alt){L.current=0,I(0);return}if(process.platform===`darwin`&&t.meta&&t.rightArrow&&!t.alt){L.current=n.length,I(n.length);return}if(process.platform===`darwin`&&t.meta&&t.upArrow){L.current=0,I(0);return}if(process.platform===`darwin`&&t.meta&&t.downArrow){L.current=n.length,I(n.length);return}if(t.ctrl&&t.leftArrow&&process.platform!==`darwin`){let e=te(n,L.current);L.current=e,I(e);return}if(t.ctrl&&t.rightArrow&&process.platform!==`darwin`){let e=ne(n,L.current);L.current=e,I(e);return}let u=()=>{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=L.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(B.length>0){he(e=>e>0?e-1:B.length-1);return}let{rows:e,currentRow:t}=u();if(t>0){let n=L.current-e[t].start,r=e[t-1],i=r.start+Math.min(n,r.end-r.start);L.current=i,I(i);return}let n=fe.current;if(n.length>0){z(e=>{let t=e<0?n.length-1:Math.max(0,e-1),r=n[t]||``;return P(r),L.current=r.length,I(r.length),t});return}return}if(t.downArrow){if(B.length>0){he(e=>e<B.length-1?e+1:0);return}let{rows:e,currentRow:t}=u();if(t<e.length-1){let n=L.current-e[t].start,r=e[t+1],i=r.start+Math.min(n,r.end-r.start);L.current=i,I(i);return}let n=fe.current;if(n.length>0&&r>=0){z(e=>{let t=e>=n.length-1?-1:e+1,r=t<0?``:n[t]||``;return P(r),L.current=r.length,I(r.length),t});return}return}if(t.return){if(B.length>0){let e=B[V];me([]),he(0),P(``),L.current=0,I(0),J.current=e,i(e);return}if(n.trim()){let e=n.trim();J.current=e,i(e),P(``),pe.current=``,L.current=0,I(0),z(-1)}return}if((t.backspace||t.delete)&&L.current>0){let e=L.current;P(t=>t.slice(0,e-1)+t.slice(e));let t=Math.max(0,e-1);L.current=t,I(t),z(-1);return}if(t.leftArrow&&!t.meta&&!t.alt&&!t.ctrl){let e=Math.max(0,L.current-1);L.current=e,I(e);return}if(t.rightArrow&&!t.meta&&!t.alt&&!t.ctrl){let e=Math.min(n.length,L.current+1);L.current=e,I(e);return}if(t.tab&&n.startsWith(`/`)){let e=Se.filter(e=>e.startsWith(N.toLowerCase()));if(e.length===1){let t=e[0].length;P(e[0]),L.current=t,I(t)}return}if(e){if(t.meta||t.alt||t.ctrl||!e.split(``).every(e=>{let t=e.charCodeAt(0);return t>=32&&t!==127||t===10||t===9}))return;let n=L.current;P(t=>t.slice(0,n)+e+t.slice(n));let r=n+e.length;L.current=r,I(r),z(-1),K(!1)}},[i,a,ce,N,F,de,Se,B,V,y,W,b,G,T,E,_e,x,H,f,_,c,o,S,w,j,M,Y,s,q])),(0,u.useEffect)(()=>{p&&R(!1)},[p]);let $=`\x1B[38;2;0;175;102m`,Ce=`\x1B[0m`,we=`${$} ╔═════════╗${Ce} ▄▖▗ ▌ ▄▖ ▄▖ ▗ ${$}╔═════════╗${Ce}
|
|
5
|
+
${$} ║ ┌────╚════╗${Ce} ▚ ▜▘▀▌▛▘▙▘▌▌▛▌█▌ ▌▌▛▌█▌▛▌▜▘ ${$}║ ┌────╚════╗${Ce}
|
|
6
|
+
${$} ╚════╗────┘ ║${Ce} ▄▌▐▖█▌▙▖▛▖▙▌▌▌▙▖ ▛▌▙▌▙▖▌▌▐▖ ${$}╚════╗────┘ ║${Ce}
|
|
7
|
+
${$} ╚═════════╝${Ce} ▄▌ ${$}╚═════════╝${Ce}`,Te=ie(s),Ee=Te.reduce((e,t,n)=>t.role===`user`?n:e,-1),De=(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[1]||``;a=`🔧 Tool • ${t[0].replace(`TOOL:`,``)}`,q?o=n:n.length>200?(s=!0,o=n.slice(0,200)):o=n}let c=e.role===`user`,d=Ee>=0&&t===Ee,f=e.content||(d&&g?.length?g[g.length-1]:``)||`(no content)`,p=c?f:k(o??``);return c?u.default.createElement(l.Box,{key:`msg-${e.timestamp.getTime()}-${t}`,marginBottom:1,flexDirection:`column`},u.default.createElement(l.Text,{bold:!0,color:i},`❯ You`,u.default.createElement(l.Text,{color:`gray`},` • `,e.timestamp.toLocaleTimeString())),u.default.createElement(l.Box,{paddingLeft:2},u.default.createElement(l.Text,{color:`white`,wrap:`wrap`},p))):u.default.createElement(l.Box,{key:`msg-${e.timestamp.getTime()}-${t}`,marginBottom:1,flexDirection:`column`},u.default.createElement(l.Text,{bold:!0,color:i},a,u.default.createElement(l.Text,{color:`gray`},` • `,e.timestamp.toLocaleTimeString())),o!==void 0&&o!==``&&u.default.createElement(l.Box,{paddingLeft:2,flexDirection:`column`},u.default.createElement(l.Text,{color:n?`gray`:void 0,italic:n,wrap:`wrap`},p),s&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0,italic:!0},`... (truncated, press Ctrl+O to expand)`))))};return u.default.createElement(l.Box,{flexDirection:`column`,padding:2},u.default.createElement(l.Static,{items:[re]},()=>u.default.createElement(l.Box,{key:`static-header`,flexDirection:`column`,marginBottom:1},u.default.createElement(l.Text,null,we,`
|
|
8
8
|
`))),u.default.createElement(l.Box,{flexDirection:`column`,marginBottom:1},u.default.createElement(l.Text,{dimColor:!0},`⚠️ Preview Feature: experimental; sessions monitored. Review outputs carefully.`),u.default.createElement(l.Text,null,`
|
|
9
9
|
`),s.length===0&&u.default.createElement(l.Box,{flexDirection:`column`,marginBottom:1},u.default.createElement(l.Text,{bold:!0},`StackOne Builder - AI agent for connector development`),u.default.createElement(l.Text,{dimColor:!0},`
|
|
10
10
|
`,`I can help you build connectors, add actions, test integrations, and answer questions about provider capabilities.`),u.default.createElement(l.Text,null,`
|
|
11
11
|
`,`What would you like to work on?`),u.default.createElement(l.Text,{dimColor:!0},`
|
|
12
12
|
`,`Examples:`),u.default.createElement(l.Text,{dimColor:!0},`
|
|
13
|
-
`,` • "Create a new connector for Datadog"`),u.default.createElement(l.Text,{dimColor:!0},` `,`• "Add a get_user action to the Slack connector"`),u.default.createElement(l.Text,{dimColor:!0},` `,`• "Test the list_events action using account acc_xyz123"`)),
|
|
13
|
+
`,` • "Create a new connector for Datadog"`),u.default.createElement(l.Text,{dimColor:!0},` `,`• "Add a get_user action to the Slack connector"`),u.default.createElement(l.Text,{dimColor:!0},` `,`• "Test the list_events action using account acc_xyz123"`)),Te.map((e,t)=>De(e,t))),u.default.createElement(l.Box,{flexDirection:`column`,marginBottom:1},u.default.createElement(u.default.Fragment,null,(T||E)&&u.default.createElement(l.Box,{marginBottom:0,marginTop:0,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2,paddingY:1,flexDirection:`column`,height:_e?`100%`:void 0},u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},E?`✓`:`⚡`,` Subprocess:`,` `,ee,` `,E?`(Complete)`:``,` `,_e?`(Expanded)`:``),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},E?_e?`Press Ctrl+O or ESC to collapse`:`Press Ctrl+O to expand`:_e?`Running... Press Ctrl+O or ESC to collapse`:`Running... Press Ctrl+O to expand`)),_e?u.default.createElement(u.default.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[1]||``;r=`🔧 Tool • ${n}`,i=a.slice(0,500),a.length>500&&(i+=`
|
|
14
14
|
... (truncated)`)}return u.default.createElement(l.Box,{key:`${e.timestamp.getTime()}-${t}-${e.role}-subagent`,marginTop:1,flexDirection:`column`},u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},r,u.default.createElement(l.Text,{color:`gray`},` `,`•`,` `,e.timestamp.toLocaleTimeString())),u.default.createElement(l.Box,{paddingLeft:2},u.default.createElement(l.Text,{color:n?`gray`:`#00AF66`,dimColor:n,wrap:`wrap`},k(i))))}),!E&&!h&&f&&c.length===0&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{color:`#00AF66`},u.default.createElement(d.default,{type:`dots`})),u.default.createElement(l.Text,{dimColor:!0},` Thinking...`)),!E&&!h&&c.length>0&&u.default.createElement(l.Box,{flexDirection:`column`,marginTop:1},c.map((e,t)=>u.default.createElement(l.Box,{key:t,marginBottom:1},e.status===`running`&&u.default.createElement(l.Text,{color:`#00AF66`},u.default.createElement(d.default,{type:`dots`})),u.default.createElement(l.Text,{color:`#00AF66`},` `,`🔧 `,e.name,e.status===`running`&&`...`,e.status===`completed`&&` ✓`)))),!E&&_&&!h&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{color:`#00AF66`},k(_)))):u.default.createElement(u.default.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[1]||``;r=`🔧 ${n}: ${i.slice(0,100)}${i.length>100?`...`:``}`}let i=r.split(`
|
|
15
15
|
`).slice(0,2).join(`
|
|
16
16
|
`);return u.default.createElement(l.Box,{key:t,marginTop:1},u.default.createElement(l.Text,{color:`#00AF66`,dimColor:n},k(i),r.split(`
|
|
@@ -18,12 +18,12 @@ ${Q} ╚═════════╝${$} ▄
|
|
|
18
18
|
`).slice(0,2).join(`
|
|
19
19
|
`),k(_).split(`
|
|
20
20
|
`).length>2&&`
|
|
21
|
-
...`))))),_&&!T&&!h&&u.default.createElement(l.Box,{marginBottom:1,flexDirection:`column`},u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},`◆ StackOne Agent`,u.default.createElement(l.Text,{color:`gray`},` • `,new Date().toLocaleTimeString())),u.default.createElement(l.Box,{paddingLeft:2},u.default.createElement(l.Text,{wrap:`wrap`},k(_)))),!T&&!h&&c.length>0&&u.default.createElement(l.Box,{marginBottom:1,flexDirection:`column`},c.map((e,t)=>u.default.createElement(l.Box,{key:t,marginBottom:1},e.status===`running`&&u.default.createElement(l.Text,{color:`#00AF66`},u.default.createElement(d.default,{type:`dots`})),u.default.createElement(l.Text,{color:`#00AF66`},` `,`🔧 `,e.name,e.status===`running`&&`...`,e.status===`completed`&&` ✓`))))),!T&&!h&&f&&c.length===0&&u.default.createElement(l.Box,{marginBottom:1},u.default.createElement(l.Text,{color:`#00AF66`},u.default.createElement(d.default,{type:`dots`})),u.default.createElement(l.Text,{dimColor:!0},` Thinking...`)),h&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{color:`red`},`⏺ Interrupted · What should the StackOne Agent do instead?`)),m&&u.default.createElement(l.Box,{marginBottom:1,borderStyle:`single`,borderColor:`red`,paddingX:2,paddingY:1,flexDirection:`column`},u.default.createElement(l.Text,{color:`red`},`✗ `,m),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`Press Enter to try again or Ctrl+C to exit`))),p&&u.default.createElement(l.Box,{marginBottom:1,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2},u.default.createElement(l.Text,{color:`#00AF66`},`✓ Complete`)),y&&u.default.createElement(l.Box,{marginBottom:1,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2,paddingY:1,flexDirection:`column`},W?u.default.createElement(u.default.Fragment,null,u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},y.items[H].name),y.type!==`trust`&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},y.items[H].description)),y.type===`skills`&&u.default.createElement(l.Box,{flexDirection:`column`},y.items[H].version?u.default.createElement(l.Text,{dimColor:!0},`Version:`,` `,String(y.items[H].version)):null,y.items[H].author?u.default.createElement(l.Text,{dimColor:!0},`Author:`,` `,String(y.items[H].author)):null,y.items[H].tags&&Array.isArray(y.items[H].tags)?u.default.createElement(l.Text,{dimColor:!0},`Tags:`,` `,y.items[H].tags.join(`, `)):null,u.default.createElement(l.Text,{dimColor:!0},`Size:`,` `,String(y.items[H].size)),y.items[H].tokens?u.default.createElement(l.Text,{dimColor:!0},`Tokens: ~`,y.items[H].tokens.toLocaleString()):null,u.default.createElement(l.Text,{dimColor:!0},`Resources:`,` `,String(y.items[H].resources),` `,`files`),u.default.createElement(l.Text,{dimColor:!0},`Path:`,` `,String(y.items[H].path))),y.type===`tools`&&u.default.createElement(l.Box,{flexDirection:`column`},u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`Category:`,` `,String(y.items[H].category))),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{bold:!0},`Input Parameters:`)),y.items[H].inputSchema?u.default.createElement(l.Box,{marginTop:1,paddingLeft:2,flexDirection:`column`},(()=>{let e=y.items[H].inputSchema,t=e.properties||{},n=e.required||[];return Object.entries(t).map(([e,t])=>u.default.createElement(l.Box,{key:e,flexDirection:`column`,marginBottom:1},u.default.createElement(l.Text,null,e,n.includes(e)?` *`:``,u.default.createElement(l.Text,{dimColor:!0},` `,`(`,t.type?String(t.type):`any`,`)`)),t.description?u.default.createElement(l.Box,{paddingLeft:2},u.default.createElement(l.Text,{dimColor:!0},String(t.description))):null))})(),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`* = required parameter`))):u.default.createElement(l.Box,{marginTop:1,paddingLeft:2},u.default.createElement(l.Text,{dimColor:!0},`No parameters`)),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{bold:!0},`Output:`)),u.default.createElement(l.Box,{marginTop:1,paddingLeft:2},u.default.createElement(l.Text,{dimColor:!0},`Returns JSON with tool execution results`))),y.type===`trust`&&u.default.createElement(l.Box,{flexDirection:`column`,marginTop:1},u.default.createElement(l.Text,null,u.default.createElement(l.Text,{dimColor:!0},`Path: `),u.default.createElement(l.Text,null,String(y.items[H].path))),u.default.createElement(l.Text,null,u.default.createElement(l.Text,{dimColor:!0},`Trusted at: `),u.default.createElement(l.Text,null,y.items[H].trustedAt?new Date(y.items[H].trustedAt).toLocaleString():`N/A`))),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`Press Esc to go back`))):
|
|
22
|
-
`),r=0,i=[];return n.forEach((e,a)=>{let o=r,s=o+e.length;r=s+1;let c=a===0,d=c?t-2:t,f=[];if(e.length===0)f.push(``);else{let n=e,r=!0;for(;n.length>0;){let e=r?d:t;f.push(n.slice(0,e)),n=n.slice(e),r=!1}}let p=0;f.forEach((e,t)=>{let r=o+p,d=r+e.length,m=c&&t===0,h=
|
|
23
|
-
`).filter(e=>e.trim()))}catch(t){l&&e._.error(`[History] Failed to load command history:`,t)}},[l]),(0,u.useEffect)(()=>{(async()=>{let t={claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]};a.skillLoader.registerSkills(a.builtinSkills),a.skillLoader.registerSkills(a.customSkills);try{let e=await(0,a.loadBundledSkills)();
|
|
24
|
-
`),l=await T?.generateConversationTitle(a);if(!l)return;await o.promises.mkdir(c.join(s.homedir(),`.stackone`,`conversations`),{recursive:!0});let u=Date.now(),d=`${u}-${l.replace(/[^a-zA-Z0-9]/g,`-`).toLowerCase().slice(0,50)}.json`,f=c.join(s.homedir(),`.stackone`,`conversations`,d);await o.promises.writeFile(f,JSON.stringify({title:l,timestamp:u,goal:i,messages:p.filter(e=>e.role!==`system`),mode:t,connector:n,action:r},null,2))}catch(t){e._.error(`Failed to save conversation:`,t)}},[p,T,t,n,r]),Te=(0,u.useCallback)(async(i,u=!1)=>{if(!T){b(`Runtime not initialized`);return}if(
|
|
21
|
+
...`))))),_&&!T&&!h&&u.default.createElement(l.Box,{marginBottom:1,flexDirection:`column`},u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},`◆ StackOne Agent`,u.default.createElement(l.Text,{color:`gray`},` • `,new Date().toLocaleTimeString())),u.default.createElement(l.Box,{paddingLeft:2},u.default.createElement(l.Text,{wrap:`wrap`},k(_)))),!T&&!h&&c.length>0&&u.default.createElement(l.Box,{marginBottom:1,flexDirection:`column`},c.map((e,t)=>u.default.createElement(l.Box,{key:t,marginBottom:1},e.status===`running`&&u.default.createElement(l.Text,{color:`#00AF66`},u.default.createElement(d.default,{type:`dots`})),u.default.createElement(l.Text,{color:`#00AF66`},` `,`🔧 `,e.name,e.status===`running`&&`...`,e.status===`completed`&&` ✓`))))),!T&&!h&&f&&c.length===0&&u.default.createElement(l.Box,{marginBottom:1},u.default.createElement(l.Text,{color:`#00AF66`},u.default.createElement(d.default,{type:`dots`})),u.default.createElement(l.Text,{dimColor:!0},` Thinking...`)),h&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{color:`red`},`⏺ Interrupted · What should the StackOne Agent do instead?`)),m&&u.default.createElement(l.Box,{marginBottom:1,borderStyle:`single`,borderColor:`red`,paddingX:2,paddingY:1,flexDirection:`column`},u.default.createElement(l.Text,{color:`red`},`✗ `,m),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`Press Enter to try again or Ctrl+C to exit`))),p&&u.default.createElement(l.Box,{marginBottom:1,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2},u.default.createElement(l.Text,{color:`#00AF66`},`✓ Complete`)),y&&u.default.createElement(l.Box,{marginBottom:1,borderStyle:`single`,borderColor:`#00AF66`,paddingX:2,paddingY:1,flexDirection:`column`},W?u.default.createElement(u.default.Fragment,null,u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},y.items[H].name),y.type!==`trust`&&u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},y.items[H].description)),y.type===`skills`&&u.default.createElement(l.Box,{flexDirection:`column`},y.items[H].version?u.default.createElement(l.Text,{dimColor:!0},`Version:`,` `,String(y.items[H].version)):null,y.items[H].author?u.default.createElement(l.Text,{dimColor:!0},`Author:`,` `,String(y.items[H].author)):null,y.items[H].tags&&Array.isArray(y.items[H].tags)?u.default.createElement(l.Text,{dimColor:!0},`Tags:`,` `,y.items[H].tags.join(`, `)):null,u.default.createElement(l.Text,{dimColor:!0},`Size:`,` `,String(y.items[H].size)),y.items[H].tokens?u.default.createElement(l.Text,{dimColor:!0},`Tokens: ~`,y.items[H].tokens.toLocaleString()):null,u.default.createElement(l.Text,{dimColor:!0},`Resources:`,` `,String(y.items[H].resources),` `,`files`),u.default.createElement(l.Text,{dimColor:!0},`Path:`,` `,String(y.items[H].path))),y.type===`tools`&&u.default.createElement(l.Box,{flexDirection:`column`},u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`Category:`,` `,String(y.items[H].category))),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{bold:!0},`Input Parameters:`)),y.items[H].inputSchema?u.default.createElement(l.Box,{marginTop:1,paddingLeft:2,flexDirection:`column`},(()=>{let e=y.items[H].inputSchema,t=e.properties||{},n=e.required||[];return Object.entries(t).map(([e,t])=>u.default.createElement(l.Box,{key:e,flexDirection:`column`,marginBottom:1},u.default.createElement(l.Text,null,e,n.includes(e)?` *`:``,u.default.createElement(l.Text,{dimColor:!0},` `,`(`,t.type?String(t.type):`any`,`)`)),t.description?u.default.createElement(l.Box,{paddingLeft:2},u.default.createElement(l.Text,{dimColor:!0},String(t.description))):null))})(),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`* = required parameter`))):u.default.createElement(l.Box,{marginTop:1,paddingLeft:2},u.default.createElement(l.Text,{dimColor:!0},`No parameters`)),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{bold:!0},`Output:`)),u.default.createElement(l.Box,{marginTop:1,paddingLeft:2},u.default.createElement(l.Text,{dimColor:!0},`Returns JSON with tool execution results`))),y.type===`trust`&&u.default.createElement(l.Box,{flexDirection:`column`,marginTop:1},u.default.createElement(l.Text,null,u.default.createElement(l.Text,{dimColor:!0},`Path: `),u.default.createElement(l.Text,null,String(y.items[H].path))),u.default.createElement(l.Text,null,u.default.createElement(l.Text,{dimColor:!0},`Trusted at: `),u.default.createElement(l.Text,null,y.items[H].trustedAt?new Date(y.items[H].trustedAt).toLocaleString():`N/A`))),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`Press Esc to go back`))):be?u.default.createElement(u.default.Fragment,null,u.default.createElement(l.Text,{bold:!0,color:`yellow`},`⚠️ Remove Trust`),u.default.createElement(l.Box,{flexDirection:`column`,marginTop:1},u.default.createElement(l.Text,{color:`white`},`Are you sure you want to remove trust from:`),u.default.createElement(l.Text,{color:`cyan`,bold:!0},be.path)),u.default.createElement(l.Box,{flexDirection:`column`,marginTop:1},u.default.createElement(l.Text,{color:`yellow`},`⚠️ This action is permanent. To trust this folder again,`),u.default.createElement(l.Text,{color:`yellow`},`you must open a new chat session in that directory.`)),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{color:Z===0?`green`:`gray`,bold:Z===0},Z===0?`❯ [Y]es`:` Yes`),u.default.createElement(l.Text,null,` `),u.default.createElement(l.Text,{color:Z===1?`green`:`gray`,bold:Z===1},Z===1?`❯ [N]o`:` No`)),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`←→ to select • Enter to confirm • Esc to cancel`))):u.default.createElement(u.default.Fragment,null,u.default.createElement(l.Text,{bold:!0,color:`#00AF66`},y.type===`skills`?`📚 Skills (${y.items.filter(e=>e.enabled).length}/8 connected, max 8 skills)`:y.type===`tools`?`🔧 Tools (${y.items.length})`:y.type===`mcp`?`📡 MCP Servers (${y.items.filter(e=>e.connected).length}/${y.items.length} connected)`:y.type===`trust`?`📁 Trusted Folders (${y.items.length})`:y.type===`rewind`?`⏮️ Command History (${y.items.length})`:`💬 Recent Conversations (${y.items.length})`),u.default.createElement(l.Box,{flexDirection:`column`,marginTop:1},y.items.map((e,t)=>{let n=t===H?`❯ `:` `,r=process.stdout.columns||80,i=Math.min(r-10,120),a=(e.name||``).replace(/\n/g,` ⏎ `),o=``;y.type===`skills`?o=e.enabled?`● `:`○ `:y.type===`mcp`?o=e.connected?`● `:`○ `:y.type===`trust`&&(o=e.trusted?`● `:`○ `);let s=y.type===`skills`&&e.tokens?` (~${e.tokens.toLocaleString()} tokens)`:``,c=i-(n.length+o.length+a.length+s.length)-5,d=``;if(e.description&&c>10){let t=String(e.description).replace(/\n/g,` ⏎ `);d=t.length>c?` - ${t.slice(0,c)}...`:` - ${t}`}let f=`${n}${o}${a}${s}${d}`,p=f.slice(0,i);return u.default.createElement(l.Text,{key:t,color:t===H?`#00AF66`:`gray`},p,f.length>i?`...`:``)})),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},y.type===`skills`?`↑↓ Navigate • Ctrl+O to toggle • Enter for details • Esc to close`:y.type===`trust`?`↑↓ Navigate • Ctrl+O to remove trust • Enter for details • Esc to close`:y.type===`resume`?`↑↓ Navigate • Enter to resume • Esc to close`:y.type===`rewind`?`↑↓ Navigate • Enter to rewind to • Esc to close`:`↑↓ Navigate • Enter for details • Esc to close`)))),D.length>0&&u.default.createElement(l.Box,{flexDirection:`column`,marginBottom:1},D.map((e,t)=>u.default.createElement(l.Box,{key:t,marginBottom:t<D.length-1?1:0},u.default.createElement(l.Text,{dimColor:!0},`📬 `),u.default.createElement(l.Text,null,e.content))),O&&u.default.createElement(l.Text,{dimColor:!0,italic:!0},`Processing...`)),j&&u.default.createElement(l.Box,{marginBottom:1},u.default.createElement(l.Text,{color:`yellow`},`Delete `),u.default.createElement(l.Text,{color:`red`},j.isDirectory&&j.directoryContents?`${j.files.map(e=>e.split(`/`).pop()).join(`, `)}/ (${j.directoryContents.length} files)`:j.files.map(e=>e.split(`/`).pop()).join(`, `)),u.default.createElement(l.Text,{color:`yellow`},`? `),u.default.createElement(l.Text,{color:Y===0?`green`:`gray`},Y===0?`[Y]es`:`y`),u.default.createElement(l.Text,null,`/`),u.default.createElement(l.Text,{color:Y===1?`green`:`gray`},Y===1?`[N]o`:`n`)),le&&!p&&!y&&!j&&u.default.createElement(u.default.Fragment,null,u.default.createElement(l.Box,{borderStyle:`double`,borderColor:`white`,paddingX:2,flexDirection:`column`},(()=>{let e=process.stdout.columns||80,t=Math.max(20,e-6),n=N.split(`
|
|
22
|
+
`),r=0,i=[];return n.forEach((e,a)=>{let o=r,s=o+e.length;r=s+1;let c=a===0,d=c?t-2:t,f=[];if(e.length===0)f.push(``);else{let n=e,r=!0;for(;n.length>0;){let e=r?d:t;f.push(n.slice(0,e)),n=n.slice(e),r=!1}}let p=0;f.forEach((e,t)=>{let r=o+p,d=r+e.length,m=c&&t===0,h=F>=r&&F<d,g=F===s&&a<n.length-1&&t===f.length-1,_=F===d&&t===f.length-1&&a===n.length-1,v=`${a}-${t}`;if(h||g||_){let t=F-r,n=e.slice(0,t),a=g?` `:e.charAt(t)||` `,o=g?``:e.slice(t+1);i.push(u.default.createElement(l.Box,{key:v},m&&u.default.createElement(l.Text,{color:`#00AF66`},`❯ `),u.default.createElement(l.Text,{color:`white`},n),u.default.createElement(l.Text,{backgroundColor:`white`,color:`black`,bold:!0},a),u.default.createElement(l.Text,{color:`white`},o)))}else i.push(u.default.createElement(l.Box,{key:v},m&&u.default.createElement(l.Text,{color:`#00AF66`},`❯ `),u.default.createElement(l.Text,{color:`white`},e||` `)));p+=e.length})}),i})()),G&&u.default.createElement(l.Box,{marginTop:1,paddingLeft:2},u.default.createElement(l.Text,{color:`yellow`},`Press Ctrl+C again to exit`)),B.length>0&&u.default.createElement(l.Box,{marginTop:1,paddingLeft:2,flexDirection:`column`},B.map((e,t)=>u.default.createElement(l.Box,{key:e},u.default.createElement(l.Text,{color:t===V?`#00AF66`:`gray`},t===V?`❯ `:` `,e))))),v&&(()=>{let e=100-(v.input_tokens+v.output_tokens)/1e6*100,t=e>50?`green`:e>20?`yellow`:`red`,n=e<10;return u.default.createElement(l.Box,{marginTop:1,flexDirection:`column`},u.default.createElement(l.Text,{dimColor:!0},`📊 Model: Sonnet 4.5 • 🧠 Context left:`,` `,u.default.createElement(l.Text,{color:t},e.toFixed(1),`%`)),n&&u.default.createElement(l.Text,{color:`red`},`⚠️ Context low (`,e.toFixed(1),`% remaining)`))})(),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},le?`Type message and press Enter • Shift+Enter for new line • `:``,(f||_||c.length>0)&&`ESC to stop • `,T?`Ctrl+O to expand subprocess • `:`Ctrl+O to show/hide full tool results • `,`Ctrl+C to clear/exit`)))},j=({timeRemaining:e,onRunSetup:t,onIgnore:n})=>{let{exit:r}=(0,l.useApp)(),[i,a]=(0,u.useState)(0);(0,l.useInput)((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,d=s>0?`${s} hour${s===1?``:`s`} and ${c} minute${c===1?``:`s`}`:`${c} minute${c===1?``:`s`}`;return u.default.createElement(l.Box,{flexDirection:`column`,padding:2},u.default.createElement(l.Box,{borderStyle:`round`,borderColor:`yellow`,flexDirection:`column`,paddingX:2,paddingY:1},u.default.createElement(l.Text,{bold:!0,color:`yellow`},`⚠️ Credential Warning`),u.default.createElement(l.Text,null),u.default.createElement(l.Text,null,`Your StackOne credentials expire in `,d,` (last day of 7-day validity).`),u.default.createElement(l.Text,null),u.default.createElement(l.Text,null,"To avoid interruption, run `stackone agent setup` to reauthenticate."),u.default.createElement(l.Text,null),u.default.createElement(l.Text,{color:i===0?o:`white`},i===0?`❯ `:` `,`1. Run stackone agent setup`),u.default.createElement(l.Text,{color:i===1?o:`white`},i===1?`❯ `:` `,`2. Ignore and continue`)),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`↑↓ to navigate • Enter to confirm • Esc to continue`)))},M=({directory:e,onConfirm:t,onCancel:n})=>{let{exit:r}=(0,l.useApp)(),[i,a]=(0,u.useState)(0);(0,l.useInput)((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 u.default.createElement(l.Box,{flexDirection:`column`,padding:2},u.default.createElement(l.Box,{borderStyle:`round`,borderColor:`#00AF66`,flexDirection:`column`,paddingX:2,paddingY:1},u.default.createElement(l.Text,{bold:!0},`Do you trust the files in this folder?`),u.default.createElement(l.Text,null),u.default.createElement(l.Text,{dimColor:!0},e),u.default.createElement(l.Text,null),u.default.createElement(l.Text,null,`StackOne Agent may read, write, or execute files contained in this directory.`),u.default.createElement(l.Text,null,`This can pose security risks, so only use files and commands from trusted sources.`),u.default.createElement(l.Text,null),u.default.createElement(l.Text,{color:i===0?o:`white`},i===0?`❯ `:` `,`1. Yes, proceed`),u.default.createElement(l.Text,{color:i===1?o:`white`},i===1?`❯ `:` `,`2. No, exit`)),u.default.createElement(l.Box,{marginTop:1},u.default.createElement(l.Text,{dimColor:!0},`↑↓ to navigate • Enter to confirm • Esc to exit`)))},oe=()=>{try{let e=(0,p.join)((0,p.dirname)((0,m.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)),`..`,`package.json`);return JSON.parse((0,f.readFileSync)(e,`utf8`)).version}catch{return`unknown`}};oe();const se=e=>{try{return o.existsSync(e)?{existed:!0,content:o.readFileSync(e,`utf-8`)}:{existed:!1,content:null}}catch{return{existed:!1,content:null}}},ce=(e,t)=>{try{if(t.existed&&t.content!==null){let n=c.dirname(e);return o.existsSync(n)||o.mkdirSync(n,{recursive:!0}),o.writeFileSync(e,t.content,`utf-8`),{success:!0,action:`restored`}}else return o.existsSync(e)?(o.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)}}},N=({mode:t,connector:n,action:r,goal:i,verbose:l,temperature:d,apiKey:f})=>{let[p,m]=(0,u.useState)([]),[h,g]=(0,u.useState)(new Map),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(),[x,S]=(0,u.useState)(!1),[C,w]=(0,u.useState)(!0),[T,ee]=(0,u.useState)(),[E,D]=(0,u.useState)([]),[O,k]=(0,u.useState)([]),[A,te]=(0,u.useState)([]),[ne,re]=(0,u.useState)([]),[ie,j]=(0,u.useState)(``),[M,oe]=(0,u.useState)(),[N,P]=(0,u.useState)(!1),[F,I]=(0,u.useState)(null),[L,le]=(0,u.useState)(!1),R=(0,u.useRef)(!1),[ue,de]=(0,u.useState)(``),[z,fe]=(0,u.useState)(!1),[pe,B]=(0,u.useState)([]),[me,V]=(0,u.useState)(!1),[he,H]=(0,u.useState)(!1),U=(0,u.useRef)(!1),W=(0,u.useRef)({shouldStop:!1,requestId:0}),[ge,G]=(0,u.useState)([]),K=(0,u.useRef)(null),[_e,ve]=(0,u.useState)([]),q=(0,u.useRef)(null),[ye,J]=(0,u.useState)({claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]}),Y=(0,u.useRef)(new Map),X=(0,u.useRef)(-1),[be,xe]=(0,u.useState)(null),Z=(0,u.useRef)(null),Q=(0,u.useRef)({operation:``,phase:`idle`}),Se=(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},$=e=>{let t=e.replace(/^\s*(rm|unlink|rmdir)\s+/,``).replace(/-[rRfiv]+\s*/g,``),n=[],r=/"([^"]+)"|'([^']+)'|(\S+)/g,i;for(;(i=r.exec(t))!==null;)n.push(i[1]||i[2]||i[3]);return n.filter(e=>e&&!e.startsWith(`-`))},Ce=e=>{try{let t=c.isAbsolute(e)?e:c.resolve(process.cwd(),e);if(o.existsSync(t)&&o.statSync(t).isDirectory())return o.readdirSync(t).slice(0,20)}catch{}return[]};(0,u.useEffect)(()=>{let t=c.join(s.homedir(),`.stackone`,`agent_history`);try{o.existsSync(t)&&re(o.readFileSync(t,`utf-8`).split(`
|
|
23
|
+
`).filter(e=>e.trim()))}catch(t){l&&e._.error(`[History] Failed to load command history:`,t)}},[l]),(0,u.useEffect)(()=>{(async()=>{let t={claudeSkills:{count:0,names:[],totalSize:0},mcpServers:[],toolCounts:{total:0,builtin:[],mcpByServer:{}},errors:[]};a.skillLoader.registerSkills(a.builtinSkills),a.skillLoader.registerSkills(a.customSkills);try{let e=await(0,a.loadBundledSkills)();te(e);let n=e.map(e=>e.name);D(n),k(n.slice(0,8)),t.claudeSkills={count:e.length,names:n,totalSize:0}}catch(n){e._.error(`[Skills] Failed to load bundled skills:`,n),t.errors.push(`Failed to load Claude Skills`)}try{let{loadBundledMCPConfigs:e,loadMultipleMCPServers:n}=await import(`@stackone/agent-harness`),r=e();if(r.length>0){let e=await n(r);for(let[n,r]of e.entries())r.length>0&&(a.skillLoader.registerSkills(r),t.mcpServers.push({name:n,count:r.length}))}}catch(e){t.errors.push(`MCP: ${e instanceof Error?e.message:String(e)}`)}let n=a.skillLoader.toToolAdapters(),r=[/(?:^|[;&|]\s*)rm\b(?!\s+--help(?:\s|$))/i,/(?:^|[;&|]\s*)unlink\s/i,/(?:^|[;&|]\s*)rmdir\s/i,/(?:^|[;&|]\s*)find\b[^;|&]*-delete/i,/(?:^|[;&|]\s*)shred\s/i,/fs\.unlink|fs\.rm|fs\.rmdir/i,/os\.remove|os\.unlink|shutil\.rmtree/i,/File\.delete|FileUtils\.rm/i],i=n.map(e=>{let t=e.execute.bind(e);return e.name===`write_file`?{...e,execute:async e=>{let n=e.path||e.file_path;if(n&&X.current>=0){let e=Y.current.get(X.current);e||(e={commandIndex:X.current,command:``,timestamp:Date.now(),files:new Map},Y.current.set(X.current,e));let t=c.isAbsolute(n)?n:c.resolve(process.cwd(),n);if(!e.files.has(t)){let n=se(t);e.files.set(t,n)}}return t(e)}}:e.name===`execute_command`?{...e,execute:async e=>{let n=e.command;if(typeof n!=`string`)return t(e);if(r.some(e=>e.test(n))){let e=$(n),t=!1,r=[];for(let n of e){let e=c.isAbsolute(n)?n:c.resolve(process.cwd(),n);try{if(o.existsSync(e)&&o.statSync(e).isDirectory()){t=!0,r=Ce(e);break}}catch{}}if(!await new Promise(n=>{Z.current={resolve:n},xe({files:e,isDirectory:t,directoryContents:t?r:void 0})}))return`User refused to delete: ${e.join(`, `)}`}return t(e)}}:e}),s=i.filter(e=>!e.name.includes(`__`)),u=i.filter(e=>e.name.includes(`__`));t.toolCounts.total=i.length,t.toolCounts.builtin=s.map(e=>e.name),u.length>0&&(t.toolCounts.mcpByServer=u.reduce((e,t)=>{let[n]=t.name.split(`__`);return e[n]||(e[n]=[]),e[n].push(t.name.split(`__`)[1]),e},{})),J(t),ee(new a.AgentRuntime({apiKey:f,tools:i,temperature:d,verbose:l||!1,projectName:`stackone-agent-cli-chat`})),w(!1)})()},[f,d,l]),(0,u.useEffect)(()=>{U.current=he},[he]),(0,u.useEffect)(()=>{if(M&&!N){let e=M.input_tokens+M.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};m(e=>[...e,n]),P(!0)}}},[M,N]);let we=(0,u.useCallback)(async i=>{try{let e=p.filter(e=>e.role===`user`||e.role===`assistant`);if(e.length<2)return;let a=e.slice(0,6).map(e=>`${e.role}: ${e.content.slice(0,200)}`).join(`
|
|
24
|
+
`),l=await T?.generateConversationTitle(a);if(!l)return;await o.promises.mkdir(c.join(s.homedir(),`.stackone`,`conversations`),{recursive:!0});let u=Date.now(),d=`${u}-${l.replace(/[^a-zA-Z0-9]/g,`-`).toLowerCase().slice(0,50)}.json`,f=c.join(s.homedir(),`.stackone`,`conversations`,d);await o.promises.writeFile(f,JSON.stringify({title:l,timestamp:u,goal:i,messages:p.filter(e=>e.role!==`system`),mode:t,connector:n,action:r},null,2))}catch(t){e._.error(`Failed to save conversation:`,t)}},[p,T,t,n,r]),Te=(0,u.useCallback)(async(i,u=!1)=>{if(!T){b(`Runtime not initialized`);return}if(U.current&&!u){B(e=>[...e,{content:i,timestamp:new Date}]),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{De()},3e4);return}if(b(void 0),S(!1),i===`/skills`){if(A.length===0){let e={role:`system`,content:`📚 No skills loaded. Skills will be loaded on startup.`,timestamp:new Date};m(t=>[...t,e]);return}I({type:`skills`,items:A.map(e=>({name:e.name,description:e.description,version:e.version,author:e.author,tags:e.tags,enabled:O.includes(e.name)}))});return}if(i===`/tools`){try{let e=a.skillLoader.toToolAdapters();if(e.length===0){let e={role:`system`,content:`🔧 No tools found
|
|
25
25
|
|
|
26
|
-
Tools are loaded automatically from built-in, custom, and MCP sources.`,timestamp:new Date};m(t=>[...t,e]);return}
|
|
26
|
+
Tools are loaded automatically from built-in, custom, and MCP sources.`,timestamp:new Date};m(t=>[...t,e]);return}I({type:`tools`,items:e.map(e=>({name:e.name,description:e.description||`No description`,category:e.name.includes(`__`)?`MCP (${e.name.split(`__`)[0]})`:[`read_file`,`write_file`,`list_files`,`execute_command`].includes(e.name)?`Built-in`:`Custom`,inputSchema:e.inputSchema||e.input_schema}))})}catch(e){let t={role:`system`,content:`🔧 Error loading tools\n\n${e instanceof Error?e.message:String(e)}`,timestamp:new Date};m(e=>[...e,t])}return}if(i===`/commands`){let e={role:`system`,content:`📋 Available Commands:
|
|
27
27
|
|
|
28
28
|
• /commands - Show this help message
|
|
29
29
|
• /skills - View and toggle skills (max 8)
|
|
@@ -33,15 +33,15 @@ Tools are loaded automatically from built-in, custom, and MCP sources.`,timestam
|
|
|
33
33
|
• /compact - Summarize conversation to free up context
|
|
34
34
|
• /rewind - Remove last message from history
|
|
35
35
|
• /resume - Resume with last command
|
|
36
|
-
• /exit - Exit the agent (or use Ctrl+C)`,timestamp:new Date};m(t=>[...t,e]);return}if(i===`/exit`&&process.exit(0),i===`/mcp`){try{let{loadBundledMCPConfigs:e}=await import(`@stackone/agent-harness`),t=e();if(t.length===0){let e={role:`system`,content:`📡 No bundled MCP servers available`,timestamp:new Date};m(t=>[...t,e]);return}let n=new Set(ye.mcpServers.map(e=>e.name));
|
|
36
|
+
• /exit - Exit the agent (or use Ctrl+C)`,timestamp:new Date};m(t=>[...t,e]);return}if(i===`/exit`&&process.exit(0),i===`/mcp`){try{let{loadBundledMCPConfigs:e}=await import(`@stackone/agent-harness`),t=e();if(t.length===0){let e={role:`system`,content:`📡 No bundled MCP servers available`,timestamp:new Date};m(t=>[...t,e]);return}let n=new Set(ye.mcpServers.map(e=>e.name));I({type:`mcp`,items:t.map(e=>{let t=n.has(e.name),r=ye.toolCounts.mcpByServer[e.name]?.length||0,i=e.type===`http`?e.url:void 0;return{name:e.name,description:`${r} tools${i?` • ${i}`:``}`,connected:t,toolCount:r,url:i}})})}catch(e){let t={role:`system`,content:`❌ Error loading MCP servers: ${e instanceof Error?e.message:String(e)}`,timestamp:new Date};m(e=>[...e,t])}return}if(i===`/trust`){let{getTrustedFoldersForDisplay:e}=await Promise.resolve().then(()=>require(`./trustedFolders-BDzrQ06w.cjs`)),t=e();if(t.length===0){let e={role:`system`,content:`📁 No trusted folders found.
|
|
37
37
|
|
|
38
|
-
Folders are automatically trusted when you open a chat session in them.`,timestamp:new Date};m(t=>[...t,e]);return}
|
|
39
|
-
`).filter(e=>e.trim());if(t.length===0){let e={role:`system`,content:`⏮️ Command history is empty.`,timestamp:new Date};m(t=>[...t,e]);return}
|
|
38
|
+
Folders are automatically trusted when you open a chat session in them.`,timestamp:new Date};m(t=>[...t,e]);return}I({type:`trust`,items:t.map(e=>({name:e.name,description:e.path,path:e.path,trusted:e.trusted,trustedAt:e.trustedAt}))});return}if(i===`/rewind`){try{let e=c.join(s.homedir(),`.stackone`,`agent_history`);if(!o.existsSync(e)){let e={role:`system`,content:`⏮️ No command history found.`,timestamp:new Date};m(t=>[...t,e]);return}let t=o.readFileSync(e,`utf-8`).split(`
|
|
39
|
+
`).filter(e=>e.trim());if(t.length===0){let e={role:`system`,content:`⏮️ Command history is empty.`,timestamp:new Date};m(t=>[...t,e]);return}I({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};m(e=>[...e,t])}return}if(i===`/resume`){try{let e=c.join(s.homedir(),`.stackone`,`conversations`);if(!o.existsSync(e)){let e={role:`system`,content:`▶️ No conversation history found. Start a new conversation first!`,timestamp:new Date};m(t=>[...t,e]);return}let t=o.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};m(t=>[...t,e]);return}let n=t.map(t=>{try{let n=o.readFileSync(c.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};m(t=>[...t,e]);return}I({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};m(e=>[...e,t])}return}if(i.startsWith(`/`)&&![`/`,`/ /commands`,`/skills`,`/tools`,`/mcp`,`/trust`,`/compact`,`/rewind`,`/resume`,`/exit`].includes(i)){let e={role:`system`,content:`❌ Unknown command: ${i}\n\nType /commands to see available commands.`,timestamp:new Date};m(t=>[...t,e]);return}if(i===`/compact`){let e={role:`user`,content:i,timestamp:new Date};m(t=>[...t,e]),v(!0);try{let e=p.filter(e=>e.role===`user`||e.role===`assistant`).map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`).join(`
|
|
40
40
|
|
|
41
|
-
`),t=await T?.generateConversationSummary(e);v(!1);let n={role:`system`,content:`🗜️ Compact mode activated - conversation summarized:\n\n${t}`,timestamp:new Date};m(e=>[e[e.length-1],n])}catch(e){v(!1),b(e instanceof Error?e.message:`Failed to summarize conversation`)}return}
|
|
42
|
-
`),`utf-8`)}catch(t){l&&e._.error(`[History] Failed to save command history:`,t)}return n});let d={role:`user`,content:i,timestamp:new Date};m(e=>[...e,d]),v(!0),
|
|
41
|
+
`),t=await T?.generateConversationSummary(e);v(!1);let n={role:`system`,content:`🗜️ Compact mode activated - conversation summarized:\n\n${t}`,timestamp:new Date};m(e=>[e[e.length-1],n])}catch(e){v(!1),b(e instanceof Error?e.message:`Failed to summarize conversation`)}return}re(t=>{let n=[...t,i],r=n.length-1;X.current=r,Y.current.has(r)||Y.current.set(r,{commandIndex:r,command:i,timestamp:Date.now(),files:new Map});let a=c.join(s.homedir(),`.stackone`,`agent_history`);try{let e=c.dirname(a);o.existsSync(e)||o.mkdirSync(e,{recursive:!0});let t=n.slice(-1e3);o.writeFileSync(a,t.join(`
|
|
42
|
+
`),`utf-8`)}catch(t){l&&e._.error(`[History] Failed to save command history:`,t)}return n});let d={role:`user`,content:i,timestamp:new Date};m(e=>[...e,d]),v(!0),H(!0),W.current.requestId+=1,W.current.shouldStop=!1;let h=W.current.requestId;q.current&&=(clearTimeout(q.current),null),ve([]);let _=()=>!W.current.shouldStop&&W.current.requestId===h;try{let a=p.filter(e=>(e.role===`user`||e.role===`assistant`)&&!e.isSubagent).map(e=>({role:e.role,content:e.content})),o=O.length>0?O.slice(0,8):void 0;O.length>8&&l&&e._.warn(`[Skills] Warning: ${O.length} skills enabled, but Claude API limit is 8. Using first 8 skills.`);let s=()=>{ve(e=>e.length===0?e:(j(t=>{let n=[];t&&n.push({role:`assistant`,content:t,timestamp:new Date,isSubagent:R.current});for(let t of e)n.push({role:`system`,content:`TOOL_START:${t.id}|||${t.name}`,timestamp:new Date,isSubagent:t.isSubagent}),g(e=>{let n=new Map(e);return n.set(t.id,{name:t.name,status:`running`}),n});return n.length>0&&m(e=>[...e,...n]),``}),[]))},c=await T.executeStream({mode:t,goal:i,connector:n,action:r,conversationHistory:a,skills:o},{onThinking:()=>{_()&&(Q.current={operation:`Processing: "${i.slice(0,100)}${i.length>100?`...`:``}"`,phase:`thinking`},v(!0),g(new Map),j(``),Ee())},onToolCall:t=>{if(!_())return;Q.current={operation:`Processing: "${i.slice(0,100)}${i.length>100?`...`:``}"`,phase:`tool_execution`,toolName:t.name,toolInput:t.input},v(!1),G(e=>e.find(e=>e.id===t.id)?e.map(e=>e.id===t.id?{...e,input:t.input}:e):[...e,{id:t.id,name:t.name,input:t.input,output:void 0}]);let n=t.name===`spawn_subagent`;if(n&&t.input){let n=t.input;l&&e._.log(`spawn_subagent input:`,JSON.stringify(n,null,2));let r=n.description||n.goal||n.name||`Subagent`;if(typeof r==`string`&&r.length>50){let e=r.split(/[.!?]/)[0];r=e.length>50?e.slice(0,47)+`...`:e}l&&e._.log(`Extracted agent name:`,r),de(String(r)),R.current=!0,setTimeout(()=>{le(!0)},10)}ve(e=>[...e,{id:t.id,name:t.name,input:t.input,isSubagent:n?!0:R.current}]),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{s()},150)},onToolResult:e=>{if(!_())return;Q.current={...Q.current,phase:`streaming`,toolName:void 0,toolInput:void 0},G(t=>t.map(t=>t.id===e.id?{...t,output:e.output}:t)),g(t=>{let n=new Map(t);return n.set(e.id,{name:e.name,status:`completed`}),n});let t=typeof e.output==`string`?e.output:JSON.stringify(e.output,null,2);m(n=>n.map(n=>n.content.startsWith(`TOOL_START:${e.id}|||`)?{...n,content:`TOOL:${e.name}|||${t}`}:n)),setTimeout(()=>{g(t=>{let n=new Map(t);return n.delete(e.id),n})},500)},onToken:e=>{_()&&(Q.current.phase!==`tool_execution`&&(Q.current.phase=`streaming`),j(t=>t+e),q.current&&=(clearTimeout(q.current),setTimeout(()=>{s()},150)),Ee())},onUsage:e=>{_()&&oe(e)},onComplete:async t=>{if(!_())return;Q.current={operation:``,phase:`idle`},q.current&&=(clearTimeout(q.current),null),s(),v(!1),g(new Map),G([]);let n=R.current;j(e=>{if(e){let t={role:`assistant`,content:e,timestamp:new Date,isSubagent:n};m(e=>[...e,t])}return``}),n?(l&&e._.log(`[SUBAGENT] Subprocess completed, collecting output...`),R.current=!1,setTimeout(()=>{m(t=>{l&&(e._.log(`[SUBAGENT] Total messages:`,t.length),e._.log(`[SUBAGENT] Messages with isSubagent=true:`,t.filter(e=>e.isSubagent).length));let n=t.filter(t=>{let n=t.isSubagent&&t.role===`assistant`;return n&&l&&e._.log(`[SUBAGENT] Found message:`,t.content.slice(0,50)),n}).map(e=>e.content).join(`
|
|
43
43
|
|
|
44
|
-
`);return l&&e._.log(`[SUBAGENT] Collected output length:`,n.length),n&&n.trim()?setTimeout(()=>{l&&e._.log(`[SUBAGENT] Hiding subprocess UI...`),
|
|
44
|
+
`);return l&&e._.log(`[SUBAGENT] Collected output length:`,n.length),n&&n.trim()?setTimeout(()=>{l&&e._.log(`[SUBAGENT] Hiding subprocess UI...`),fe(!1),le(!1),setTimeout(()=>{l&&e._.log(`[SUBAGENT] Sending output to main agent`);try{Te(n,!0)}catch(t){e._.error(`[SUBAGENT] Error submitting to main agent:`,t),H(!1)}},100)},300):(l&&e._.log(`[SUBAGENT] No output found, closing subprocess`),fe(!1),le(!1),H(!1)),t})},100)):H(!1),await we(i)},onError:t=>{if(!_()){l&&e._.log(`[STREAM] Ignoring error from interrupted request:`,t.message);return}v(!1),g(new Map),b(Se(t.message,l||!1)),Q.current={operation:``,phase:`idle`}}});_()&&(v(!1),g(new Map),H(!1),G([]),c.status===`failed`&&c.error&&b(Se(c.error,l||!1)),Q.current={operation:``,phase:`idle`})}catch(t){if(!_()){l&&e._.log(`[STREAM] Ignoring error from interrupted request:`,t instanceof Error?t.message:String(t));return}v(!1),g(new Map),H(!1),G([]);let n=t instanceof Error?t.message:String(t);n.includes(`403`)||n.includes(`Invalid authentication token`)||n.includes(`authentication`)?b(f?.startsWith(`falcon_key_`)?`Authentication failed. The token in your .env is a Falcon MCP token, which is not authorized for the Claude proxy endpoint.
|
|
45
45
|
|
|
46
46
|
⚠️ Known Issue: The authentication system currently returns MCP-only tokens that don't work with the Claude proxy.
|
|
47
47
|
|
|
@@ -59,19 +59,19 @@ To fix this:
|
|
|
59
59
|
|
|
60
60
|
Original error: ${n}`):n.includes(`API key`)||n.includes(`Invalid API Key`)?(e._.error(`
|
|
61
61
|
❌ Critical error:`,n),e._.error(`Please check your configuration and try again.
|
|
62
|
-
`),process.exit(1)):b(
|
|
62
|
+
`),process.exit(1)):b(Se(n,l||!1)),Q.current={operation:``,phase:`idle`},H(!1),v(!1),g(new Map)}},[T,p,i,t,n,r,E,O,M,N,f,L,we]);(0,u.useEffect)(()=>{!T||C||i&&Te(i)},[T,C,i,t,ye]);let Ee=()=>{B(e=>(e.length===0||g(e=>(!(e.size>0)&&U.current&&(K.current&&=(clearTimeout(K.current),null),setTimeout(()=>De(),100)),e)),e))},De=()=>{B(e=>{if(e.length===0)return e;V(!0),j(e=>{if(e){let t={role:`assistant`,content:e,timestamp:new Date,isSubagent:R.current};m(e=>[...e,t])}return``});let t=e.map(e=>({role:`user`,content:e.content,timestamp:new Date}));m(e=>[...e,...t]);let n=e.map(e=>e.content).join(`
|
|
63
63
|
|
|
64
64
|
---
|
|
65
65
|
|
|
66
|
-
`);return V(!1),
|
|
67
|
-
`).filter(e=>e.trim()),r=new Map,i=[],a=[],l=[],u=Array.from(Y.current.keys()).filter(t=>t>e).sort((e,t)=>e-t);for(let e of u){let t=Y.current.get(e);if(t)for(let[e,n]of t.files)r.has(e)||r.set(e,n)}for(let[e,t]of r){let n=
|
|
66
|
+
`);return V(!1),H(!1),G([]),K.current&&=(clearTimeout(K.current),null),setTimeout(()=>{Te(n,!0)},100),[]})},Oe=(0,u.useCallback)(e=>{k(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=8?t:[...t,e])},[]),ke=(0,u.useCallback)(async e=>{let{removeTrustedFolder:t,getTrustedFoldersForDisplay:n}=await Promise.resolve().then(()=>require(`./trustedFolders-BDzrQ06w.cjs`));t(e);let r=n();r.length===0?I(null):I({type:`trust`,items:r.map(e=>({name:e.name,description:e.path,path:e.path,trusted:e.trusted,trustedAt:e.trustedAt}))})},[I]);(0,u.useEffect)(()=>{F?.type===`skills`&&A.length>0&&I({type:`skills`,items:A.map(e=>({name:e.name,description:e.description,version:e.version,author:e.author,tags:e.tags,enabled:O.includes(e.name)}))})},[O,A,F?.type]);let Ae=()=>{},je=(0,u.useCallback)(()=>{W.current.shouldStop=!0,S(!0),j(e=>{if(e){let t=R.current,n={role:`assistant`,content:e,timestamp:new Date,isSubagent:t};m(e=>[...e,n])}return``}),v(!1),H(!1),U.current=!1,g(new Map),G([]),m(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})),B([]),ve([]),V(!1),q.current&&=(clearTimeout(q.current),null)},[]),Me=(0,u.useCallback)(e=>{Z.current&&=(Z.current.resolve(e),null),xe(null)},[]);return C?u.default.createElement(ae,{title:`Agent ${t.charAt(0).toUpperCase()+t.slice(1)} Mode`,mode:t,connector:n,action:r,messages:[],currentToolCalls:[],isThinking:!1,isComplete:!1,error:void 0,isInterrupted:!1,onSubmit:()=>{},onExit:Ae,onStop:je}):u.default.createElement(ae,{title:`Agent ${t.charAt(0).toUpperCase()+t.slice(1)} Mode`,mode:t,connector:n,action:r,messages:p,currentToolCalls:Array.from(h.values()),isThinking:_,isComplete:!1,error:y,isInterrupted:x,onSubmit:Te,onExit:Ae,onStop:je,commandHistory:ne,streamingText:ie,usage:M,detailViewData:F,onCloseDetailView:()=>I(null),onToggleSkill:Oe,onToggleTrust:ke,onRewindTo:e=>{try{let t=c.join(s.homedir(),`.stackone`,`agent_history`),n=o.readFileSync(t,`utf-8`).split(`
|
|
67
|
+
`).filter(e=>e.trim()),r=new Map,i=[],a=[],l=[],u=Array.from(Y.current.keys()).filter(t=>t>e).sort((e,t)=>e-t);for(let e of u){let t=Y.current.get(e);if(t)for(let[e,n]of t.files)r.has(e)||r.set(e,n)}for(let[e,t]of r){let n=ce(e,t);n.success?n.action===`deleted`?a.push(e):i.push(e):l.push(`${e}: ${n.error}`)}for(let e of u)Y.current.delete(e);X.current=e;let d=n.slice(0,e+1);o.writeFileSync(t,d.join(`
|
|
68
68
|
`),`utf-8`);let f=`⏮️ Rewound to command: "${n[e]}"`;if(i.length>0||a.length>0){if(f+=`
|
|
69
69
|
|
|
70
70
|
📁 File changes:`,i.length>0){f+=`\n Restored (${i.length}):`;for(let e of i.slice(0,10))f+=`\n • ${c.basename(e)}`;i.length>10&&(f+=`\n ... and ${i.length-10} more`)}if(a.length>0){f+=`\n Deleted (${a.length}):`;for(let e of a.slice(0,10))f+=`\n • ${c.basename(e)}`;a.length>10&&(f+=`\n ... and ${a.length-10} more`)}}else f+=`
|
|
71
71
|
|
|
72
|
-
📁 No file changes to restore.`;if(l.length>0){f+=`\n\n⚠️ Errors (${l.length}):`;for(let e of l.slice(0,5))f+=`\n • ${e}`}let p={role:`system`,content:f,timestamp:new Date};m(e=>[...e,p]),
|
|
73
|
-
`).filter(e=>e.trim()))}catch(t){e._.error(`[Trust] Failed to load trusted directories:`,t)}if(!_.includes(r)){let t=!1,{addTrustedFolder:n}=await Promise.resolve().then(()=>require(`./trustedFolders-BDzrQ06w.cjs`)),{waitUntilExit:i}=(0,l.render)(u.default.createElement(
|
|
74
|
-
Exiting...`),process.exit(0)),process.stdout.write(`\x1Bc`)}let v=a;if(h){let e={current:`ignore`},{waitUntilExit:t}=(0,l.render)(u.default.createElement(
|
|
72
|
+
📁 No file changes to restore.`;if(l.length>0){f+=`\n\n⚠️ Errors (${l.length}):`;for(let e of l.slice(0,5))f+=`\n • ${e}`}let p={role:`system`,content:f,timestamp:new Date};m(e=>[...e,p]),re(d)}catch(e){let t={role:`system`,content:`❌ Error rewinding: ${e instanceof Error?e.message:String(e)}`,timestamp:new Date};m(e=>[...e,t])}},onResumeConversation:e=>{m(e.map(e=>({...e,timestamp:new Date(e.timestamp)})))},spawnedSubagentActive:L,spawnedSubagentName:ue,spawnedSubagentComplete:z,queuedMessages:pe,isProcessingQueue:me,enabledSkills:O,initInfo:ye,pendingDeleteConfirmation:be,onConfirmDelete:Me})};var P=class{async execute(t){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:n,getAgentCredentialStatus:i,CredentialExpiredError:a,CredentialMissingError:d}=await Promise.resolve().then(()=>require(`./agentApiKey-D_nB16-v.cjs`)),{hasOldSetupFiles:f,migrateFromLocalSetup:p,displayMigrationMessage:m}=await Promise.resolve().then(()=>require(`./setupMigration-CcE0WHEr.cjs`));try{let r=process.cwd();f(r)&&m(await p(r));let a=n(),d=i(),h=d.status===`expiring_soon`?d.timeRemaining:void 0;process.env.STACKONE_AGENT_TOKEN||(process.env.STACKONE_AGENT_TOKEN=a);let g=c.join(s.homedir(),`.stackone`,`trusted_directories`),_=[];try{o.existsSync(g)&&(_=o.readFileSync(g,`utf-8`).split(`
|
|
73
|
+
`).filter(e=>e.trim()))}catch(t){e._.error(`[Trust] Failed to load trusted directories:`,t)}if(!_.includes(r)){let t=!1,{addTrustedFolder:n}=await Promise.resolve().then(()=>require(`./trustedFolders-BDzrQ06w.cjs`)),{waitUntilExit:i}=(0,l.render)(u.default.createElement(M,{directory:r,onConfirm:()=>{t=!0,n(r)},onCancel:()=>{t=!1}}));await i(),t||(e._.log(`
|
|
74
|
+
Exiting...`),process.exit(0)),process.stdout.write(`\x1Bc`)}let v=a;if(h){let e={current:`ignore`},{waitUntilExit:t}=(0,l.render)(u.default.createElement(j,{timeRemaining:h,onRunSetup:()=>{e.current=`setup`},onIgnore:()=>{e.current=`ignore`}}));if(await t(),e.current===`setup`){process.stdout.write(`\x1Bc`);let{spawnSync:e}=await import(`node:child_process`),t=e(process.execPath,[process.argv[1],`agent`,`setup`],{stdio:`inherit`});t.status!==0&&process.exit(t.status??1);let r=n();process.env.STACKONE_AGENT_TOKEN=r,v=r}process.stdout.write(`\x1Bc`)}(0,l.render)(u.default.createElement(N,{...t,apiKey:v}),{exitOnCtrlC:!1})}catch(t){t instanceof a&&(e._.error(`
|
|
75
75
|
❌ Credentials Expired
|
|
76
76
|
`),e._.log(r.default.white(`Your StackOne credentials have expired.
|
|
77
77
|
`)),e._.log(r.default.white("To continue using the agent, run `stackone agent setup` to reauthenticate.\n")),e._.log(r.default.dim(`Credentials are valid for 7 days after authentication.
|
|
@@ -83,22 +83,22 @@ Exiting...`),process.exit(0)),process.stdout.write(`\x1Bc`)}let v=a;if(h){let e=
|
|
|
83
83
|
`)),process.exit(1));let n=t instanceof Error?t.message:String(t);e._.error(`
|
|
84
84
|
❌ Error:`,n),e._.log(r.default.dim(`
|
|
85
85
|
If you continue to see this error, try running:`)),e._.log(r.default.cyan(` stackone agent setup
|
|
86
|
-
`)),process.exit(1)}}};const
|
|
87
|
-
`));let t={configsCleaned:0};try{let n=(0,v.default)(`Removing stored configuration...`).start();await e.t(),n.succeed(`Removed ~/.stackone/agent-config.json`);let i=(0,v.default)(`Removing MCP servers from Claude...`).start(),a=0;try{await
|
|
86
|
+
`)),process.exit(1)}}};const F=(0,_.promisify)(h.exec);async function I(e){try{let t=await(0,g.readFile)(e,`utf-8`),n=JSON.parse(t),r=!1;if(n.mcpServers&&typeof n.mcpServers==`object`){for(let[e,t]of Object.entries(n.mcpServers))if(t&&typeof t==`object`&&`transport`in t){let e=t.transport;if(e&&typeof e==`object`&&`headers`in e){let t=e.headers;if(t&&typeof t==`object`&&`Authorization`in t){let e=t.Authorization;typeof e==`string`&&e.startsWith(`Bearer `)&&!e.includes("${")&&(t.Authorization="Bearer ${STACKONE_AGENT_TOKEN}",r=!0)}}}}return r&&await(0,g.writeFile)(e,JSON.stringify(n,null,2)),r}catch{return!1}}var L=class{async execute(){e._.log(r.default.blue.bold(`🧹 StackOne Agent Cleanup
|
|
87
|
+
`));let t={configsCleaned:0};try{let n=(0,v.default)(`Removing stored configuration...`).start();await e.t(),n.succeed(`Removed ~/.stackone/agent-config.json`);let i=(0,v.default)(`Removing MCP servers from Claude...`).start(),a=0;try{await F(`claude mcp remove ${e.i()} 2>/dev/null`),a++}catch{}try{await F(`claude mcp remove ${e.a()} 2>/dev/null`),a++}catch{}a>0?i.succeed(`Removed ${a} MCP server(s) from Claude`):i.warn(`No MCP servers found in Claude (already removed or not configured)`);let o=(0,v.default)(`Checking for .mcp.json file...`).start(),s=(0,c.join)(process.cwd(),`.mcp.json`);try{await I(s)?(t.configsCleaned=1,o.succeed(`Cleaned .mcp.json (replaced tokens with environment variables)`)):o.info(`.mcp.json already uses environment variables or not found`)}catch{o.info(`.mcp.json not found (already cleaned or not created)`)}e._.success(`Cleanup complete!`),e._.log(r.default.white(`
|
|
88
88
|
What was removed:`)),e._.log(r.default.cyan(` • ~/.stackone/agent-config.json`)),e._.log(r.default.cyan(` • MCP server from Claude configuration`)),t.configsCleaned>0&&e._.log(r.default.cyan(` • Hardcoded credentials from .mcp.json`)),e._.log(r.default.dim(`
|
|
89
|
-
To authenticate again:`)),e._.log(r.default.cyan(` stackone agent setup --global`),r.default.dim(`(for global setup)`)),e._.log(r.default.cyan(` stackone agent setup --local`),r.default.dim(`(for local project setup)`)),e._.log(``),process.exit(0)}catch(t){t instanceof Error?e._.error(t.message):e._.error(`Unknown error occurred`),process.exit(1)}}},
|
|
89
|
+
To authenticate again:`)),e._.log(r.default.cyan(` stackone agent setup --global`),r.default.dim(`(for global setup)`)),e._.log(r.default.cyan(` stackone agent setup --local`),r.default.dim(`(for local project setup)`)),e._.log(``),process.exit(0)}catch(t){t instanceof Error?e._.error(t.message):e._.error(`Unknown error occurred`),process.exit(1)}}},le=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`}}}};const R=new le,ue=(0,_.promisify)(h.exec);function de(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 z=class{async execute(){e._.log(r.default.blue.bold(`🤖 StackOne Agent Setup - Global Configuration
|
|
90
90
|
`));try{let t=process.cwd(),n=await(0,g.access)(`${t}/CLAUDE.md`).then(()=>!0).catch(()=>!1),i=await(0,g.access)(`${t}/.mcp.json`).then(()=>!0).catch(()=>!1);if(n||i){e._.warn(`Existing local setup detected:`),n&&e._.log(r.default.dim(` • CLAUDE.md found in current directory`)),i&&e._.log(r.default.dim(` • .mcp.json found in current directory`)),e._.log(``);let{proceed:t}=await x.default.prompt([{type:`confirm`,name:`proceed`,message:`Re-authenticate globally despite existing local setup?`,default:!0}]);t||(e._.log(r.default.dim(`
|
|
91
|
-
Setup cancelled.`)),process.exit(0)),e._.log(``)}let a=await e.s(),o;if(a?.email){e._.log(r.default.dim(`Last used email: ${a.email}\n`));let{useExisting:t}=await x.default.prompt([{type:`confirm`,name:`useExisting`,message:`Sign in with this email?`,default:!0}]);if(t)o=a.email;else{let t=(0,b.createInterface)({input:y.stdin,output:y.stdout});o=await new Promise(e=>{t.question(r.default.white(`Email: `),t=>{e(t.trim())})}),t.close(),o||(e._.error(`Email is required`),process.exit(1))}}else{let t=(0,b.createInterface)({input:y.stdin,output:y.stdout});o=await new Promise(e=>{t.question(r.default.white(`Email: `),t=>{e(t.trim())})}),t.close(),o||(e._.error(`Email is required`),process.exit(1))}let s=await x.default.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);s.password||(e._.error(`Password is required`),process.exit(1)),e._.log(``);let c=(0,v.default)(`Authenticating...`).start(),l=await
|
|
92
|
-
`)),process.exit(1)),c.succeed(`Login successful!`);let u=new Date(Date.now()+10080*60*1e3).toISOString();await e.l({apiKey:l.apiKey,userId:o,email:o,expiresAt:u,serverUrl:e.n()}),e._.success(`API key saved to ~/.stackone/agent-config.json`),e._.log(r.default.white(`✓ Key expires at`),r.default.cyan(
|
|
91
|
+
Setup cancelled.`)),process.exit(0)),e._.log(``)}let a=await e.s(),o;if(a?.email){e._.log(r.default.dim(`Last used email: ${a.email}\n`));let{useExisting:t}=await x.default.prompt([{type:`confirm`,name:`useExisting`,message:`Sign in with this email?`,default:!0}]);if(t)o=a.email;else{let t=(0,b.createInterface)({input:y.stdin,output:y.stdout});o=await new Promise(e=>{t.question(r.default.white(`Email: `),t=>{e(t.trim())})}),t.close(),o||(e._.error(`Email is required`),process.exit(1))}}else{let t=(0,b.createInterface)({input:y.stdin,output:y.stdout});o=await new Promise(e=>{t.question(r.default.white(`Email: `),t=>{e(t.trim())})}),t.close(),o||(e._.error(`Email is required`),process.exit(1))}let s=await x.default.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);s.password||(e._.error(`Password is required`),process.exit(1)),e._.log(``);let c=(0,v.default)(`Authenticating...`).start(),l=await R.login(o,s.password);(!l.success||!l.apiKey)&&(c.fail(`Authentication failed`),e._.error(`${l.error||`Invalid credentials`}`),e._.log(r.default.dim(`Please check your email and password and try again.
|
|
92
|
+
`)),process.exit(1)),c.succeed(`Login successful!`);let u=new Date(Date.now()+10080*60*1e3).toISOString();await e.l({apiKey:l.apiKey,userId:o,email:o,expiresAt:u,serverUrl:e.n()}),e._.success(`API key saved to ~/.stackone/agent-config.json`),e._.log(r.default.white(`✓ Key expires at`),r.default.cyan(de(u)));let d=(0,v.default)(`Setting up global MCP configuration...`).start();try{let t=e.i(),n=e.n();try{await ue(`claude mcp remove ${t} 2>/dev/null`)}catch{}await ue(`claude mcp add ${t} ${n} --scope user --transport http --header "Authorization: Bearer ${l.apiKey}"`),d.succeed(`Installed to Claude (global)`),e._.success(`Global setup complete!`),e._.log(r.default.white(`Config location:`),r.default.cyan(`~/.claude.json`)),e._.log(r.default.blue(`
|
|
93
93
|
Verify:`),r.default.cyan(`claude mcp list`)),e._.log(r.default.dim(`
|
|
94
94
|
💡 Tip: Run Claude without permission prompts:`),r.default.cyan(`claude --dangerously-skip-permissions`)),e._.log(r.default.dim(`
|
|
95
|
-
To setup for a specific project, run:`),r.default.cyan(`stackone agent setup --local`)),e._.log(``)}catch(t){d.fail(`Installation to Claude failed`),t instanceof Error&&(e._.error(t.message),e._.log(r.default.dim(`You can manually add the server later with:`)),e._.log(r.default.cyan(` claude mcp add ${e.i()} ${e.n()} --scope user --transport http --header "Authorization: Bearer ${l.apiKey}"`)))}process.exit(0)}catch(t){t instanceof Error?e._.error(t.message):e._.error(`Unknown error occurred`),process.exit(1)}}},
|
|
95
|
+
To setup for a specific project, run:`),r.default.cyan(`stackone agent setup --local`)),e._.log(``)}catch(t){d.fail(`Installation to Claude failed`),t instanceof Error&&(e._.error(t.message),e._.log(r.default.dim(`You can manually add the server later with:`)),e._.log(r.default.cyan(` claude mcp add ${e.i()} ${e.n()} --scope user --transport http --header "Authorization: Bearer ${l.apiKey}"`)))}process.exit(0)}catch(t){t instanceof Error?e._.error(t.message):e._.error(`Unknown error occurred`),process.exit(1)}}},fe=class{async execute(){e._.log(r.default.blue.bold(`🤖 StackOne Agent Setup - Local Project
|
|
96
96
|
`));try{let t=process.cwd();n.n(t)&&n.t(await n.r(t));let i=await e.s();if(!i||!e.o(i)){e._.warn(`Not authenticated globally.`),e._.log(r.default.white(`Let's authenticate now...
|
|
97
|
-
`));let t=(0,b.createInterface)({input:y.stdin,output:y.stdout}),n=await new Promise(e=>{t.question(r.default.white(`Email: `),t=>{e(t.trim())})});t.close(),n||(e._.error(`Email is required`),process.exit(1));let a=await x.default.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);a.password||(e._.error(`Password is required`),process.exit(1)),e._.log(``);let o=(0,v.default)(`Authenticating...`).start(),s=await
|
|
97
|
+
`));let t=(0,b.createInterface)({input:y.stdin,output:y.stdout}),n=await new Promise(e=>{t.question(r.default.white(`Email: `),t=>{e(t.trim())})});t.close(),n||(e._.error(`Email is required`),process.exit(1));let a=await x.default.prompt([{type:`password`,name:`password`,message:`Password:`,mask:`*`}]);a.password||(e._.error(`Password is required`),process.exit(1)),e._.log(``);let o=(0,v.default)(`Authenticating...`).start(),s=await R.login(n,a.password);(!s.success||!s.apiKey)&&(o.fail(`Authentication failed`),e._.error(`${s.error||`Invalid credentials`}`),e._.log(r.default.dim(`Please check your email and password and try again.
|
|
98
98
|
`)),process.exit(1)),o.succeed(`Login successful!`);let c=new Date(Date.now()+10080*60*1e3).toISOString();await e.l({apiKey:s.apiKey,userId:n,email:n,expiresAt:c,serverUrl:e.n()}),i={apiKey:s.apiKey,userId:n,email:n,expiresAt:c,serverUrl:e.n()},e._.log(``)}e._.success(`Setup complete!`),e._.log(r.default.white(`
|
|
99
|
-
Token saved to:`)),e._.log(r.default.cyan(` ~/.stackone/agent-config.json`)),e._.log(``),process.exit(0)}catch(t){t instanceof Error?e._.error(t.message):e._.error(`Unknown error occurred`),process.exit(1)}}};const
|
|
99
|
+
Token saved to:`)),e._.log(r.default.cyan(` ~/.stackone/agent-config.json`)),e._.log(``),process.exit(0)}catch(t){t instanceof Error?e._.error(t.message):e._.error(`Unknown error occurred`),process.exit(1)}}};const pe={profiles:{}},B=()=>{let n=e.u.readConfigFile(t.n);if(!n)return pe;try{return JSON.parse(n)}catch{return pe}},me=e=>B().profiles[e],V=e=>!!B().profiles[e],he=(n,r)=>{let i=B();i.profiles[n]=r,e.u.writeConfigFile(t.n,JSON.stringify(i,null,2))},H=()=>{let e=B();return Object.keys(e.profiles)},U=`https://api.stackone.com`;var W=class{async execute({profile:t,connector:n,apiUrl:i,apiKey:a}={}){if(!t&&!a&&(e._.error(`Profile or API key is required`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),t&&a&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),t&&i&&e._.warn(`Specifying ${e.g(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),t&&!V(t)){e._.error(`Configuration profile ${e.g(t)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let n=H();n.length>0&&(e._.info(`Available configuration profiles:`),n.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let o=t?me(t):{apiUrl:i??U,apiKey:a};o?.apiKey||(e._.error(`API key is missing`),e._.log(`Please provide a valid API key in the profile or via the ${e.g(`--api-key`)} option.`),process.exit(1)),n||(e._.error(`Connector identifier is required in the format provider_key@version.`),process.exit(1));let s=n.split(`@`);(s.length!==2||!s[0]||!s[1])&&(e._.error(`Invalid connector format ${e.h(n)}. Expected format: ${e.g(`provider_key@version`)}`),process.exit(1));let c=o.apiUrl??U,l=await this.dropConnector(n,c,o.apiKey);process.exit(l?0:1)}async dropConnector(t,n,r){let i=(0,v.default)(`🗑️ Dropping connector ${e.g(t)}...`).start();try{let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/registry/connectors/${t}`,{method:`DELETE`,headers:{Authorization:`Basic ${a}`}});return i.stop(),o.status===204?(e._.success(`Successfully dropped connector ${e.g(t)} from the registry`),!0):o.status===404?(e._.error(`Connector ${e.g(t)} not found in the registry`),!1):o.status===401||o.status===403?(e._.error(`You do not have permission to drop this connector`),!1):o.status===409?(e._.error(`Connector ${e.g(t)} has associated configs and cannot be dropped`),e._.log(`Please delete all associated integration configurations before dropping the connector.`),!1):(o.ok||await e.m(o,`Failed to drop connector ${e.g(t)} from the registry`),!1)}catch(r){return i.stop(),e._.error(`Failed to drop connector ${e.g(t)} from registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),!1}}};const ge=`https://api.stackone.com`;var G=class{async execute({profile:t,connector:n,accountId:i,format:a,outputFile:o,apiUrl:s,apiKey:c}={}){if(!t&&!c&&(e._.error(`Profile or API key is required`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),t&&c&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),t&&s&&e._.warn(`Specifying ${e.g(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),t&&!V(t)){e._.error(`Configuration profile ${e.g(t)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let n=H();n.length>0&&(e._.info(`Available configuration profiles:`),n.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let l=t?me(t):{apiUrl:s??ge,apiKey:c};l?.apiKey||(e._.error(`API key is missing`),e._.log(`Please provide a valid API key in the profile or via the ${e.g(`--api-key`)} option.`),process.exit(1)),(0,S.isMissing)(n)&&(0,S.isMissing)(i)&&(e._.error(`Either ${e.g(`--connector`)} or ${e.g(`--account-id`)} must be provided`),process.exit(1)),(0,S.notMissing)(n)&&(0,S.notMissing)(i)&&(e._.error(`Please provide either ${e.g(`--connector`)} or ${e.g(`--account-id`)}, not both.`),process.exit(1)),(0,S.notMissing)(a)&&a!==`yaml`&&a!==`json`&&(e._.error(`Format must be either ${e.g(`yaml`)} or ${e.g(`json`)}.`),process.exit(1));let u=l.apiUrl??ge,d;if((0,S.notMissing)(n)){this.#t(n)||(e._.error(`Invalid connector format ${e.h(n)}. Expected format: ${e.g(`provider_key@version`)} or ${e.g(`provider_key`)}`),process.exit(1));let t=this.#n(n);d=await this.#r(t,u,l.apiKey,a)}else (0,S.notMissing)(i)?d=await this.#i(i,u,l.apiKey,a):(e._.error(`Either ${e.g(`--connector`)} or ${e.g(`--account-id`)} must be provided`),process.exit(1));if((0,S.notMissing)(o))try{f.default.writeFileSync(o,d,`utf-8`),e._.success(`Connector written to file: ${e.g(o)}`)}catch(t){e._.error(`Failed to write connector to file ${e.g(o)}: ${t.message}`),process.exit(1)}else if(e._.log(`\n${r.default.blue.inverse(` CONNECTOR CONTENT `)}\n`),!a||a===`yaml`)e._.log(this.#e(d));else if(a===`json`)try{e.p(JSON.parse(d))}catch{e._.log(d)}else e._.log(d);process.exit(0)}#e(e){return e.split(`
|
|
100
100
|
`).map(e=>{if(e.trim().startsWith(`#`))return r.default.gray(e);if(e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t+1),i=e.substring(t+1),a=i,o=i.trim();return o===`true`||o===`false`?a=i.replace(o,r.default.cyan(o)):o===`null`||o===`~`?a=i.replace(o,r.default.gray(o)):/^-?\d+(\.\d+)?$/.test(o)?a=i.replace(o,r.default.green(o)):(o.startsWith(`"`)&&o.endsWith(`"`)||o.startsWith(`'`)&&o.endsWith(`'`)||o&&!o.startsWith(`-`))&&(a=i.replace(o,r.default.yellow(o))),r.default.red(n)+a}return e.trim().startsWith(`-`)?e.replace(`-`,r.default.gray(`-`)):e}).join(`
|
|
101
|
-
`)}#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(t,n,r,i){let a=(0,v.default)(`Getting connector ${e.g(t)} from registry...`).start();try{let o=Buffer.from(r).toString(`base64`),s=i?`?format=${i}`:``,c=await fetch(`${n}/registry/connectors/${t}${s}`,{method:`GET`,headers:{Authorization:`Basic ${o}`}});return a.stop(),c.ok||(await e.m(c,`Failed to get connector ${e.g(t)} from the registry`),process.exit(1)),await c.text()}catch(r){a.stop(),e._.error(`Failed to get connector ${e.g(t)} from the registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}}async#i(t,n,r,i){let a=(0,v.default)(`Getting connector from account ${e.g(t)}...`).start();try{let o=Buffer.from(r).toString(`base64`),s=i?`?format=${i}`:``,c=await fetch(`${n}/accounts/${t}/connector${s}`,{method:`GET`,headers:{Authorization:`Basic ${o}`}});return a.stop(),c.ok||(await e.m(c,`Failed to get connector from account ${e.g(t)}`),process.exit(1)),await c.text()}catch(r){a.stop(),e._.error(`Failed to get connector from account ${e.g(t)}: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}}};const K=`https://api.stackone.com`,_e=`https://api.stackone-dev.com`,ve=`http://localhost:4000`;var q=class{async execute({environment:t}={}){let n=t?.toLowerCase()??`production`;try{(0,C.intro)(`${r.default.inverse(` Initialize profile `)}`);let t=await(0,C.text)({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((0,C.isCancel)(t))return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0);if(V(t)){let n=await(0,C.confirm)({message:`Configuration profile with name ${e.g(t)} already exists. Do you want to overwrite it?`});if((0,C.isCancel)(n)||!n)return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0)}let i;if(n===`production`)i=`https://api.stackone.com`;else if(n===`staging`)i=`https://api.stackone-dev.com`;else{let e=await(0,C.text)({message:`API URL`,placeholder:ve,initialValue:ve,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((0,C.isCancel)(e))return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0);i=e}let a=await(0,C.password)({message:`API Key`,validate:e=>{if(!e||e.trim().length===0)return`API Key is required`}});if((0,C.isCancel)(a))return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0);
|
|
101
|
+
`)}#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(t,n,r,i){let a=(0,v.default)(`Getting connector ${e.g(t)} from registry...`).start();try{let o=Buffer.from(r).toString(`base64`),s=i?`?format=${i}`:``,c=await fetch(`${n}/registry/connectors/${t}${s}`,{method:`GET`,headers:{Authorization:`Basic ${o}`}});return a.stop(),c.ok||(await e.m(c,`Failed to get connector ${e.g(t)} from the registry`),process.exit(1)),await c.text()}catch(r){a.stop(),e._.error(`Failed to get connector ${e.g(t)} from the registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}}async#i(t,n,r,i){let a=(0,v.default)(`Getting connector from account ${e.g(t)}...`).start();try{let o=Buffer.from(r).toString(`base64`),s=i?`?format=${i}`:``,c=await fetch(`${n}/accounts/${t}/connector${s}`,{method:`GET`,headers:{Authorization:`Basic ${o}`}});return a.stop(),c.ok||(await e.m(c,`Failed to get connector from account ${e.g(t)}`),process.exit(1)),await c.text()}catch(r){a.stop(),e._.error(`Failed to get connector from account ${e.g(t)}: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}}};const K=`https://api.stackone.com`,_e=`https://api.stackone-dev.com`,ve=`http://localhost:4000`;var q=class{async execute({environment:t}={}){let n=t?.toLowerCase()??`production`;try{(0,C.intro)(`${r.default.inverse(` Initialize profile `)}`);let t=await(0,C.text)({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((0,C.isCancel)(t))return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0);if(V(t)){let n=await(0,C.confirm)({message:`Configuration profile with name ${e.g(t)} already exists. Do you want to overwrite it?`});if((0,C.isCancel)(n)||!n)return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0)}let i;if(n===`production`)i=`https://api.stackone.com`;else if(n===`staging`)i=`https://api.stackone-dev.com`;else{let e=await(0,C.text)({message:`API URL`,placeholder:ve,initialValue:ve,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((0,C.isCancel)(e))return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0);i=e}let a=await(0,C.password)({message:`API Key`,validate:e=>{if(!e||e.trim().length===0)return`API Key is required`}});if((0,C.isCancel)(a))return(0,C.cancel)(`Configuration profile initialization cancelled`),process.exit(0);he(t,{label:t,environment:n,apiUrl:i,apiKey:a}),(0,C.outro)(`${r.default.green(`✔`)} Configuration profile ${e.g(t)} initialized successfully!`),process.exit(0)}catch(t){t?.isTtyError?e._.error(`Prompt couldn't be rendered in the current environment`):e._.error(`Failed to initialize configuration profile: ${t}`),process.exit(1)}}};const ye=20,J={pending:`○`,acceptRemote:`●`,acceptLocal:`◐`,acceptBoth:`◑`,current:`◉`,arrow:`→`,check:`✓`,cross:`✗`,warning:`⚠`};var Y=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=(0,ee.createInterface)({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`
|
|
102
102
|
`: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(){e.d();let t=process.stdout.columns||80;this.renderHeader(t),this.renderProgressBar(t),this.renderCurrentConflict(t),this.renderControls(t)}renderHeader(t){let n=this.connectorId,i=`${this.localVersion} ${J.arrow} ${this.remoteVersion}`,a=Math.max(0,t-17),o=Math.floor(a/2),s=a-o,c=` `.repeat(o)+`CONFLICT RESOLVER`+` `.repeat(s);e._.log(``),e._.log(r.default.bgBlue.white.bold(c)),e._.log(r.default.gray(this.centerText(n,t))),e._.log(r.default.gray(this.centerText(i,t))),e._.log(``)}renderProgressBar(t){let n=this.conflicts.filter(e=>e.conflict.type===`conflict`),i=this.getCurrentConflictIndex(),a=n.map((e,t)=>{let n=t===i,a,o;switch(e.choice){case`remote`:a=n?J.current:J.acceptRemote,o=r.default.green;break;case`local`:a=n?J.current:J.acceptLocal,o=r.default.yellow;break;case`both`:a=n?J.current:J.acceptBoth,o=r.default.cyan;break;default:a=n?J.current:J.pending,o=n?r.default.white:r.default.gray}return o(a)}),o=n.filter(e=>e.choice!==`pending`).length,s=` Conflict ${i+1} of ${this.totalConflicts} • ${o}/${this.totalConflicts} resolved `;e._.log(r.default.gray(this.centerText(s,t))),e._.log(this.centerText(a.join(` `),t)),e._.log(``)}renderCurrentConflict(t){let n=this.conflicts[this.currentIndex];if(!n||n.conflict.type!==`conflict`)return;let i=n.conflict;if(e._.log(r.default.gray(`_`.repeat(t))),e._.log(`
|
|
103
103
|
|
|
104
104
|
`),i.local){let t=n.choice===`local`||n.choice===`both`?r.default.yellow.bold(`${J.check} LOCAL (keeping)`):r.default.red.bold(`${J.cross} LOCAL (removing)`),a=i.local.split(`
|
|
@@ -112,9 +112,9 @@ Token saved to:`)),e._.log(r.default.cyan(` ~/.stackone/agent-config.json`)),e.
|
|
|
112
112
|
`),l=a.length>20?`\n${r.default.gray(`... and ${a.length-20} more lines`)}`:``;e._.log(`${t}\n\n${c}${l}`)}e._.log(`
|
|
113
113
|
|
|
114
114
|
`),e._.log(r.default.gray(`_`.repeat(t))),e._.log(``)}renderControls(t){let n=[r.default.green(`[R] Accept Remote`),r.default.yellow(`[L] Keep Local`),r.default.cyan(`[B] Keep Both`),r.default.gray(`[U] Undo`)],i=[r.default.gray(`[←/→] Navigate`),r.default.gray(`[A] Accept all remaining`)],a=this.allResolved()?[r.default.green.bold(`[Enter] Apply Changes`),r.default.gray(`[Esc] Cancel`)]:[r.default.gray(`[Enter] Next Unresolved`),r.default.gray(`[Esc] Cancel`)];e._.log(this.centerText(n.join(` `),t)),e._.log(``),e._.log(this.centerText(i.join(` `),t)),e._.log(``),e._.log(this.centerText(a.join(` `),t)),this.allResolved()&&(e._.log(``),e._.log(r.default.green.bold(this.centerText(`✓ All conflicts resolved!`,t))))}renderFinalSummary(){e.d();let t=this.conflicts.filter(e=>e.conflict.type===`conflict`),n=0,i=0,a=0;for(let e of t)switch(e.choice){case`remote`:n++;break;case`local`:i++;break;case`both`:a++;break}let o=[r.default.green.bold(`Conflict resolution complete`),``,`${r.default.bold(this.totalConflicts)} conflicts resolved:`,``,`${r.default.green(J.acceptRemote)} Accepted remote: ${n}`,`${r.default.yellow(J.acceptLocal)} Kept local: ${i}`,`${r.default.cyan(J.acceptBoth)} Kept both: ${a}`];e._.box(o.join(`
|
|
115
|
-
`))}renderCancelled(){e.d(),e._.log(r.default.yellow(`Conflict resolution cancelled`)),e._.log(``),e._.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 X=`https://api.stackone.com`,be=3;var xe=class{async execute({profile:t,connector:n,outputPath:i,apiUrl:a,apiKey:o}={}){if((0,S.isMissing)(n)&&(e._.error(`Connector identifier is required`),e._.log(`Please provide a connector identifier using the ${e.g(`--connector`)} option in the format: ${e.g(`provider_key@version`)} or ${e.g(`provider_key`)}`),e._.log(`If no version is specified, the latest version will be pulled.`),process.exit(1)),!t&&!o&&(e._.error(`Profile or API key is required`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),t&&o&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),t&&a&&e._.warn(`Specifying ${e.g(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),t&&!V(t)){e._.error(`Configuration profile ${e.g(t)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let n=
|
|
115
|
+
`))}renderCancelled(){e.d(),e._.log(r.default.yellow(`Conflict resolution cancelled`)),e._.log(``),e._.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 X=`https://api.stackone.com`,be=3;var xe=class{async execute({profile:t,connector:n,outputPath:i,apiUrl:a,apiKey:o}={}){if((0,S.isMissing)(n)&&(e._.error(`Connector identifier is required`),e._.log(`Please provide a connector identifier using the ${e.g(`--connector`)} option in the format: ${e.g(`provider_key@version`)} or ${e.g(`provider_key`)}`),e._.log(`If no version is specified, the latest version will be pulled.`),process.exit(1)),!t&&!o&&(e._.error(`Profile or API key is required`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),t&&o&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),t&&a&&e._.warn(`Specifying ${e.g(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),t&&!V(t)){e._.error(`Configuration profile ${e.g(t)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let n=H();n.length>0&&(e._.info(`Available configuration profiles:`),n.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let s=t?me(t):{apiUrl:a??X,apiKey:o};s?.apiKey||(e._.error(`API key is missing`),e._.log(`Please provide a valid API key in the profile or via the ${e.g(`--api-key`)} option.`),process.exit(1));let c=s.apiUrl??X,[l,u]=n.split(`@`),d=await this.#f(l,c,s.apiKey,u??`latest`),f=this.#e(d),p=f.version??`unknown`,m=this.#t(i,f.key,p),h=this.#r(m),g=h===null,_=d;if(!g){let t=this.#i(h,m);t&&(e._.warn(t.message),t.errors.length>0&&e.f(t.errors,!1),e._.log(``));let r=t?void 0:this.#e(h);if(this.#o(h,d)){this.#a(h,d,m);let t=r?.version??`unknown`,i=await this.#s(h,d,n,t,p);i.action===`cancel`&&((0,C.cancel)(`Pull cancelled`),process.exit(0)),i.action===`keep-local`&&(e._.log(``),e._.info(`Keeping local version. No changes made.`),process.exit(0)),i.action===`interactive-cancel`&&process.exit(0),i.action===`interactive`&&(_=i.resolvedContent)}else e._.info(`No changes detected in connector configuration.`),process.exit(0)}let v=(0,w.validateYamlConnector)(_).connector,y=v?.key??f.key,b=v?.version??p,x=this.#t(i,y,b),T=x;if(x!==m){let t=await this.#n(x);e._.log(``),t!==void 0&&(T=t)}await this.#d(T,_),g?e._.success(`Connector ${e.g(y)}@${e.g(b)} pulled successfully (new connector)`):e._.success(`Connector ${e.g(y)}@${e.g(b)} updated successfully`);let ee=y===f.key?e.g(y):`${e.g(f.key)} ${r.default.whiteBright(`→`)} ${e.g(y)}`,E=b===p?e.g(b):`${e.g(p)} ${r.default.whiteBright(`→`)} ${e.g(b)}`,D=T===m?e.g(T):`${e.g(m)}\n ${r.default.whiteBright(`→`)} ${e.g(T)}`;e._.log(`\n${r.default.blue.inverse(` CONNECTOR DETAILS `)}\n`),e._.log(` Provider: ${ee}`),e._.log(` Version: ${E}`),e._.log(` Output file: ${D}`),process.exit(0)}#e(t){let n=(0,w.validateYamlConnector)(t),r=n?.errors??[];if(n.success)return n.connector;e._.error(`Connector pulled from the registry is not valid`),e._.log(`Please make sure you are using the latest version of the StackOne CLI by running ${e.g(`stackone update`)}`),r.length>0&&e.f(r,!0),process.exit(1)}#t(t,n,r){let i=`${n}_v${r.replaceAll(`.`,`-`)}.s1.yaml`;return t?(f.default.existsSync(t)&&(f.default.statSync(t).isDirectory()||(e._.error(`Output path ${e.g(t)} is not a directory`),e._.log(`Please provide a valid directory path to store connectors or use the default path.`),process.exit(1))),p.default.resolve(t,n,i)):p.default.resolve(process.cwd(),`connectors`,n,i)}async#n(t){if(!f.default.existsSync(t))return;let n=p.default.basename(t),r=p.default.dirname(t);e._.warn(`File ${e.g(n)} already exists at ${e.g(r)}`);let i=await(0,C.select)({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(((0,C.isCancel)(i)||i===`cancel`)&&((0,C.cancel)(`Operation cancelled. No local changes were made.`),process.exit(0)),i===`override`)return;let a=await(0,C.text)({message:`Enter the new filename:`,placeholder:n,validate:e=>{if(!e||e.trim()===``)return`Filename cannot be empty`;if(!e.endsWith(`.s1.yaml`))return`Filename must end with .s1.yaml`;let t=p.default.join(r,e.trim());if(f.default.existsSync(t))return`File ${e} already exists`}});return(0,C.isCancel)(a)&&((0,C.cancel)(`Operation cancelled. No local changes were made.`),process.exit(0)),p.default.join(r,a.trim())}#r(e){if(!f.default.existsSync(e))return null;try{return f.default.readFileSync(e,`utf-8`)}catch{return null}}#i(t,n){try{let r=(0,w.validateYamlConnector)(t);if(!r.success){let t=r.errors??[];return{message:`Local connector ${e.g(p.default.basename(n))} has validation errors:`,errors:t}}}catch(t){return{message:`Local connector ${e.g(p.default.basename(n))} could not be validated: ${t.message}`,errors:[]}}return null}#a(t,n,i){let a=(0,T.diffLines)(t,n);if(!a.some(e=>e.added||e.removed)){e._.info(`No changes detected in connector configuration.`);return}e._.log(`${r.default.blue.inverse(` CHANGES `)}\n`),e._.log(r.default.gray(`--- local: ${i}`)),e._.log(r.default.gray(`+++ remote: StackOne Registry`)),e._.log(``);let o=0,s=0;for(let t of a){let n=t.value.split(`
|
|
116
116
|
`).filter(e=>e!==``);if(t.added){o+=n.length;for(let t of n)e._.log(r.default.green(`+ ${t}`))}else if(t.removed){s+=n.length;for(let t of n)e._.log(r.default.red(`- ${t}`))}else if(n.length<=6)for(let t of n)e._.log(r.default.gray(` ${t}`));else{for(let t=0;t<3;t++)e._.log(r.default.gray(` ${n[t]}`));e._.log(r.default.gray(` ... (${n.length-6} unchanged lines)`));for(let t=n.length-3;t<n.length;t++)e._.log(r.default.gray(` ${n[t]}`))}}e._.log(``),e._.log(r.default.gray(`Summary: ${r.default.green(`+${o}`)} additions, ${r.default.red(`-${s}`)} deletions`))}#o(e,t){return(0,T.diffLines)(e,t).some(e=>e.added||e.removed)}async#s(t,n,r,i,a){e._.log(``);let o=await(0,C.select)({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((0,C.isCancel)(o))return{action:`cancel`};if(o===`override`)return{action:`override`};if(o===`keep-local`)return{action:`keep-local`};if(o===`interactive`){let e=await this.#c(t,n,r,i,a);return e===null?{action:`interactive-cancel`}:{action:`interactive`,resolvedContent:e}}return{action:`cancel`}}async#c(t,n,r,i,a){let o=(0,T.diffLines)(t,n),s=this.#u(o);if(s.length===0)return e._.info(`No conflicts to resolve.`),n;let c=new Y(s,r,i,a);for(;;){if((await c.resolve()).cancelled)return null;let t=c.getResolvedContent(),n=(0,w.validateYamlConnector)(t);if(n.success)return c.renderFinalSummary(),t;let r=await this.#l(n.errors);if(r===`cancel`)return e.d(),e._.info(`Operation cancelled. No changes were made to the local connector.`),null;if(r===`save`)return e.d(),e._.warn(`The connector was saved but it is invalid`),t;c.resetForReResolution()}}async#l(t){let{createInterface:n}=await import(`readline`);return new Promise(i=>{e.d();let a=(t||[{message:`Unknown validation error`}]).map(e=>` • ${e.message}`).join(`
|
|
117
|
-
`);e._.box({title:`⚠️ Validation Failed`,message:`The resolved connector configuration is invalid:\n\n${a}`,style:{borderColor:`yellow`,padding:1}}),e._.log(``),e._.log(r.default.bold(` Choose an action:`)),e._.log(``),e._.log(r.default.cyan(` [B]`)+` ← Go back to conflict resolution`),e._.log(r.default.dim(` Modify your choices to fix the validation errors`)),e._.log(``),e._.log(r.default.yellow(` [S]`)+` 💾 Save anyway`),e._.log(r.default.dim(` Save the invalid configuration (not recommended)`)),e._.log(``),e._.log(r.default.red(` [C]`)+` ✖ Cancel`),e._.log(r.default.dim(` Discard all changes`)),e._.log(``);let o=n({input:process.stdin,output:process.stdout});process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume();let s=e=>{let t=e.toString().toLowerCase(),n=()=>{process.stdin.removeListener(`data`,s),process.stdin.isTTY&&process.stdin.setRawMode(!1),o.close()};if(t===``||t===`\x1B`){n(),i(`cancel`);return}switch(t){case`b`:n(),i(`back`);break;case`s`:n(),i(`save`);break;case`c`:case`q`:n(),i(`cancel`);break}};process.stdin.on(`data`,s)})}#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(t,n){let r=p.default.dirname(t);f.default.existsSync(r)||f.default.mkdirSync(r,{recursive:!0});try{f.default.writeFileSync(t,n,`utf-8`)}catch(n){e._.error(`Failed to write connector to file ${e.g(t)}: ${n.message}`),process.exit(1)}}async#f(t,n,r,i){let a=(0,v.default)(`Pulling connector ${e.g(t)}@${e.g(i)} from registry...`).start();try{let e=Buffer.from(r).toString(`base64`),o=`${n}/registry/connectors/${t}@${i}`,s=await fetch(o,{method:`GET`,headers:{Authorization:`Basic ${e}`}});return a.stop(),s.ok||(await this.#p(s,t,i),process.exit(1)),await s.text()}catch(r){a.stop(),e._.error(`Failed to pull connector ${e.g(t)}@${e.g(i)} from the registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid.`),process.exit(1)}}async#p(t,n,r){switch(t.status){case 401:case 403:e._.error(`Access denied`),e._.log(`Please ensure that your API key is valid and has the ${e.g(`connectors:read`)} scope required to pull connectors.`);break;case 404:e._.error(`Connector ${e.g(n)}@${e.g(r)} was not found in the registry`),await this.#m(n);break;case 429:e._.error(`Rate limit exceeded`),e._.log(`Too many requests. Please wait a moment before trying again.`);break;default:await e.m(t,`Failed to pull connector ${e.g(n)}`)}}async#m(t){e._.info(`To see available versions, check the connector documentation or contact support.`)}};const Se=`https://api.stackone.com`;var Z=class{async execute({profile:t,fileOrDir:n,apiUrl:i,apiKey:a}={}){if(!t&&!a&&(e._.error(`Profile or API key is required`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),t&&a&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),t&&i&&e._.warn(`Specifying ${e.g(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),t&&!V(t)){e._.error(`Configuration profile ${e.g(t)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let n=U();n.length>0&&(e._.info(`Available configuration profiles:`),n.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let o=t?B(t):{apiUrl:i??Se,apiKey:a};o?.apiKey||(e._.error(`API key is missing`),e._.log(`Please provide a valid API key in the profile or via the ${e.g(`--api-key`)} option.`),process.exit(1)),n||(e._.error(`File or directory is required.`),process.exit(1));try{(0,f.statSync)(n)}catch{e._.error(`File or directory not found: ${r.default.red(n)}`),process.exit(1)}let s=(0,f.statSync)(n),c=o.apiUrl??Se;if(s.isDirectory()){let t=$(n),i=0;t.length===0?(e._.error(`No .s1.yaml connector files found in the directory: ${n}.`),process.exit(1)):(e._.start(`Found ${t.length} connector(s) file(s). Pushing to registry...`),e._.log(``));for(let e of t)await this.uploadFile(e,c,o.apiKey)&&i++;i===0?e._.error(`Error while pushing connectors: no files were uploaded`):(e._.log(``),e._.info(`Upload completed: ${r.default.green(i)} of ${r.default.blue(t.length)} file(s) uploaded successfully.`)),process.exit(i>0?0:1)}else n.endsWith(`.s1.yaml`)||(e._.error(`Only ${e.g(`.s1.yaml`)} files are supported for upload`),process.exit(1));let l=await this.uploadFile(n,c,o.apiKey);process.exit(l?0:1)}async uploadFile(t,n,r){let i=(0,v.default)(`📤 Pushing connector in ${(0,p.basename)(t)}...`).start();try{let a=Q(t);if(!a)return!1;let o=(0,p.basename)(t),s=new FormData,c=new Blob([a],{type:`application/x-yaml`});s.append(`file`,c,o);let l=Buffer.from(r).toString(`base64`),u=await fetch(`${n}/registry/connectors`,{method:`POST`,headers:{Authorization:`Basic ${l}`},body:s});if(i.stop(),!u.ok)return await e.m(u,`Failed to push connector in ${e.g(o)} to the registry`),!1;let d=await u.json();return e._.success(`Successfully uploaded ${e.g(o)} with connector ${e.g(d.provider)}@${e.g(d.version)}`),!0}catch(r){return i.stop(),e._.error(`Failed to upload file ${e.g(t)}: ${r}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),!1}}};const Q=t=>{let n=(0,w.loadConnector)(t),r=(0,w.validateYamlConnector)(n),i=r?.errors??[];if(r.success)return n;i.length>0?(e._.error(`Connector in ${e.h(t)} is not valid`),e.f(i,!0)):e._.error(`Connector in ${e.h(t)} is not valid. Please check the file for errors.`)},$=e=>{let t=[],n=(0,f.readdirSync)(e,{withFileTypes:!0});for(let r of n){let n=(0,p.join)(e,r.name);r.isDirectory()?t.push(...$(n)):r.name.endsWith(`.s1.yaml`)&&t.push(n)}return t},Ce=S.z.object({provider_key:S.z.string().optional(),provider_version:S.z.string().optional(),auth_config_key:S.z.string(),environment:S.z.string().default(`production`),organization_id:S.z.string().default(`cli-organization-id`),account_id:S.z.string().default(`cli-account-secure-id`),project_id:S.z.string().default(`cli-project-secure-id`),credentials:S.z.record(S.z.string(),S.z.any()).default({})}),we=S.z.record(S.z.string(),S.z.any()),Te=S.z.object({path:S.z.record(S.z.string(),S.z.any()).default({}),queryParams:S.z.record(S.z.string(),S.z.any()).default({}),header:S.z.record(S.z.string(),S.z.any()).default({}),body:S.z.record(S.z.string(),S.z.any()).default({})}),Ee=`https://api.stackone.com`;var De=class{async execute({connector:t,action:n,actionId:i,account:a,accountId:o,params:s,credentials:c,profile:l,outputFile:u,debug:d,apiUrl:p,apiKey:m}={}){if(!l&&!m&&o&&(e._.error(`Profile or API key is required when providing an account ID`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),l&&m&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),l&&p&&e._.warn(`Specifying --api-url with a profile won't have any effect. Using API url from profile.`),l&&!V(l)){e._.error(`Configuration profile ${e.g(l)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let t=U();t.length>0&&(e._.info(`Available configuration profiles:`),t.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let h=l?B(l):{apiUrl:p??Ee,apiKey:m};(0,S.isMissing)(a)&&(0,S.isMissing)(o)&&(e._.error(`A valid account or account ID is required to run an action`),process.exit(1));let g;if((0,S.notMissing)(t))if(this.#a(t)){!l&&!m&&(e._.error(`Profile or API key is required when using a connector identifier`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.`),process.exit(1));let n=this.#o(t);g=await this.#s(n,h?.apiUrl??Ee,h?.apiKey)}else g=this.#e(t);else (0,S.notMissing)(o)&&(g=await this.#c(o,h?.apiUrl??Ee,h?.apiKey));let _=(0,S.notMissing)(n)?this.#r(n,t):g;(0,S.isMissing)(_)&&(e._.error(`A valid connector is required to run an action.`),process.exit(1));let v=(0,S.notMissing)(_?.actions)?Object.keys(_?.actions).length:0,y=(0,S.notMissing)(_?.actions)?Object.keys(_.actions)[v-1]:void 0,b=(0,S.notMissing)(y)?_?.actions?.[y]?.id:void 0,x=((0,S.notMissing)(i)&&!i?.startsWith(`${_.key}_`)?`${_.key}_${i}`:i)??b;(0,S.isMissing)(x)&&(e._.error(`A valid action ID is required to run an action`),process.exit(1));let C=(0,S.notMissing)(o)?await this.#l(o,h?.apiUrl??Ee,h?.apiKey):{},w=(0,S.notMissing)(a)?this.#i(a,_.key??`unknown`,_.version??`unknown`):void 0,T=(0,S.notMissing)(c)?this.#u(c):{},ee={...C,...w,credentials:{...C.credentials??{},...T}};(0,S.isMissing)(ee)&&(e._.error(`A valid account data is required to run an action.`),process.exit(1));let E=_.actions?.[x];(0,S.isMissing)(E)&&(e._.error(`Action ID ${e.g(x)} not found in the connector ${e.g(_.key)}@${e.g(_.version)}.`),process.exit(1));let D=(0,S.notMissing)(s)?this.#d(s,x):{path:{},queryParams:{},header:{},body:{}},O=Date.now(),k=await this.#f({connector:_,actionId:x,account:ee,queryParams:{...D.queryParams,...d?{debug:`true`}:{}},pathParams:D.path,body:D.body,headers:D.header}),te=Date.now()-O;if((0,S.notMissing)(u))try{f.default.writeFileSync(u,JSON.stringify(k.output,null,2),`utf-8`),e._.info(`Output written to file: ${u}`)}catch(t){e._.error(`Failed to write output to file ${u}: ${t.message}`),process.exit(1)}else e._.log(`\n${r.default.blue.inverse(` ACTION OUTPUT `)}`),e.p(k.output);e._.log(``),e._.info(`Action ${e.g(x)} from connector ${e.g(_?.key)}@${e.g(_?.version)} finished in ${r.default.yellowBright((te/1e3).toFixed(2))} seconds.`),process.exit(0)}#e=e=>{let t=e;try{t=(0,w.loadConnector)(e)}catch{}return t?this.#n(t):void 0};#t=t=>{try{return(0,w.loadConnector)(t)}catch(n){e._.error(`Failed to load connector file from ${e.g(t)}: ${n.message}`),process.exit(1)}};#n=t=>{let n=(0,w.validateYamlConnector)(t),r=n?.errors??[];if(n.success)return n.connector||(e._.error(`Failed to load connector.`),process.exit(1)),n.connector;r.length>0?(e._.error(`Connector is not valid`),e.f(r,!0),process.exit(1)):(e._.error(`Connector is not valid. Please check the file for errors.`),process.exit(1))};#r=(t,n)=>{let r=t;try{r=f.default.readFileSync(t,`utf-8`)}catch{}(0,S.isMissing)(n)&&(e._.error(`A valid connector is required to load an action.`),process.exit(1));let i=`${this.#t(n)} - ${r.split(`
|
|
117
|
+
`);e._.box({title:`⚠️ Validation Failed`,message:`The resolved connector configuration is invalid:\n\n${a}`,style:{borderColor:`yellow`,padding:1}}),e._.log(``),e._.log(r.default.bold(` Choose an action:`)),e._.log(``),e._.log(r.default.cyan(` [B]`)+` ← Go back to conflict resolution`),e._.log(r.default.dim(` Modify your choices to fix the validation errors`)),e._.log(``),e._.log(r.default.yellow(` [S]`)+` 💾 Save anyway`),e._.log(r.default.dim(` Save the invalid configuration (not recommended)`)),e._.log(``),e._.log(r.default.red(` [C]`)+` ✖ Cancel`),e._.log(r.default.dim(` Discard all changes`)),e._.log(``);let o=n({input:process.stdin,output:process.stdout});process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume();let s=e=>{let t=e.toString().toLowerCase(),n=()=>{process.stdin.removeListener(`data`,s),process.stdin.isTTY&&process.stdin.setRawMode(!1),o.close()};if(t===``||t===`\x1B`){n(),i(`cancel`);return}switch(t){case`b`:n(),i(`back`);break;case`s`:n(),i(`save`);break;case`c`:case`q`:n(),i(`cancel`);break}};process.stdin.on(`data`,s)})}#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(t,n){let r=p.default.dirname(t);f.default.existsSync(r)||f.default.mkdirSync(r,{recursive:!0});try{f.default.writeFileSync(t,n,`utf-8`)}catch(n){e._.error(`Failed to write connector to file ${e.g(t)}: ${n.message}`),process.exit(1)}}async#f(t,n,r,i){let a=(0,v.default)(`Pulling connector ${e.g(t)}@${e.g(i)} from registry...`).start();try{let e=Buffer.from(r).toString(`base64`),o=`${n}/registry/connectors/${t}@${i}`,s=await fetch(o,{method:`GET`,headers:{Authorization:`Basic ${e}`}});return a.stop(),s.ok||(await this.#p(s,t,i),process.exit(1)),await s.text()}catch(r){a.stop(),e._.error(`Failed to pull connector ${e.g(t)}@${e.g(i)} from the registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid.`),process.exit(1)}}async#p(t,n,r){switch(t.status){case 401:case 403:e._.error(`Access denied`),e._.log(`Please ensure that your API key is valid and has the ${e.g(`connectors:read`)} scope required to pull connectors.`);break;case 404:e._.error(`Connector ${e.g(n)}@${e.g(r)} was not found in the registry`),await this.#m(n);break;case 429:e._.error(`Rate limit exceeded`),e._.log(`Too many requests. Please wait a moment before trying again.`);break;default:await e.m(t,`Failed to pull connector ${e.g(n)}`)}}async#m(t){e._.info(`To see available versions, check the connector documentation or contact support.`)}};const Z=`https://api.stackone.com`;var Q=class{async execute({profile:t,fileOrDir:n,apiUrl:i,apiKey:a}={}){if(!t&&!a&&(e._.error(`Profile or API key is required`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),t&&a&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),t&&i&&e._.warn(`Specifying ${e.g(`--api-url`)} with a profile won't have any effect. Using API url from profile.`),t&&!V(t)){e._.error(`Configuration profile ${e.g(t)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let n=H();n.length>0&&(e._.info(`Available configuration profiles:`),n.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let o=t?me(t):{apiUrl:i??Z,apiKey:a};o?.apiKey||(e._.error(`API key is missing`),e._.log(`Please provide a valid API key in the profile or via the ${e.g(`--api-key`)} option.`),process.exit(1)),n||(e._.error(`File or directory is required.`),process.exit(1));try{(0,f.statSync)(n)}catch{e._.error(`File or directory not found: ${r.default.red(n)}`),process.exit(1)}let s=(0,f.statSync)(n),c=o.apiUrl??Z;if(s.isDirectory()){let t=$(n),i=0;t.length===0?(e._.error(`No .s1.yaml connector files found in the directory: ${n}.`),process.exit(1)):(e._.start(`Found ${t.length} connector(s) file(s). Pushing to registry...`),e._.log(``));for(let e of t)await this.uploadFile(e,c,o.apiKey)&&i++;i===0?e._.error(`Error while pushing connectors: no files were uploaded`):(e._.log(``),e._.info(`Upload completed: ${r.default.green(i)} of ${r.default.blue(t.length)} file(s) uploaded successfully.`)),process.exit(i>0?0:1)}else n.endsWith(`.s1.yaml`)||(e._.error(`Only ${e.g(`.s1.yaml`)} files are supported for upload`),process.exit(1));let l=await this.uploadFile(n,c,o.apiKey);process.exit(l?0:1)}async uploadFile(t,n,r){let i=(0,v.default)(`📤 Pushing connector in ${(0,p.basename)(t)}...`).start();try{let a=Se(t);if(!a)return!1;let o=(0,p.basename)(t),s=new FormData,c=new Blob([a],{type:`application/x-yaml`});s.append(`file`,c,o);let l=Buffer.from(r).toString(`base64`),u=await fetch(`${n}/registry/connectors`,{method:`POST`,headers:{Authorization:`Basic ${l}`},body:s});if(i.stop(),!u.ok)return await e.m(u,`Failed to push connector in ${e.g(o)} to the registry`),!1;let d=await u.json();return e._.success(`Successfully uploaded ${e.g(o)} with connector ${e.g(d.provider)}@${e.g(d.version)}`),!0}catch(r){return i.stop(),e._.error(`Failed to upload file ${e.g(t)}: ${r}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),!1}}};const Se=t=>{let n=(0,w.loadConnector)(t),r=(0,w.validateYamlConnector)(n),i=r?.errors??[];if(r.success)return n;i.length>0?(e._.error(`Connector in ${e.h(t)} is not valid`),e.f(i,!0)):e._.error(`Connector in ${e.h(t)} is not valid. Please check the file for errors.`)},$=e=>{let t=[],n=(0,f.readdirSync)(e,{withFileTypes:!0});for(let r of n){let n=(0,p.join)(e,r.name);r.isDirectory()?t.push(...$(n)):r.name.endsWith(`.s1.yaml`)&&t.push(n)}return t},Ce=S.z.object({provider_key:S.z.string().optional(),provider_version:S.z.string().optional(),auth_config_key:S.z.string(),environment:S.z.string().default(`production`),organization_id:S.z.string().default(`cli-organization-id`),account_id:S.z.string().default(`cli-account-secure-id`),project_id:S.z.string().default(`cli-project-secure-id`),credentials:S.z.record(S.z.string(),S.z.any()).default({})}),we=S.z.record(S.z.string(),S.z.any()),Te=S.z.object({path:S.z.record(S.z.string(),S.z.any()).default({}),queryParams:S.z.record(S.z.string(),S.z.any()).default({}),header:S.z.record(S.z.string(),S.z.any()).default({}),body:S.z.record(S.z.string(),S.z.any()).default({})}),Ee=`https://api.stackone.com`;var De=class{async execute({connector:t,action:n,actionId:i,account:a,accountId:o,params:s,credentials:c,profile:l,outputFile:u,debug:d,apiUrl:p,apiKey:m}={}){if(!l&&!m&&o&&(e._.error(`Profile or API key is required when providing an account ID`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`To create a profile, run ${e.g(`stackone init`)}.`),process.exit(1)),l&&m&&(e._.error(`Please provide either a profile or an API key, not both`),process.exit(1)),l&&p&&e._.warn(`Specifying --api-url with a profile won't have any effect. Using API url from profile.`),l&&!V(l)){e._.error(`Configuration profile ${e.g(l)} not found`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.\n`);let t=H();t.length>0&&(e._.info(`Available configuration profiles:`),t.forEach(t=>{e._.log(` - ${r.default.blue(t)}`)})),process.exit(1)}let h=l?me(l):{apiUrl:p??Ee,apiKey:m};(0,S.isMissing)(a)&&(0,S.isMissing)(o)&&(e._.error(`A valid account or account ID is required to run an action`),process.exit(1));let g;if((0,S.notMissing)(t))if(this.#a(t)){!l&&!m&&(e._.error(`Profile or API key is required when using a connector identifier`),e._.log(`Please provide a profile using the ${e.g(`--profile`)} option or an API key using the ${e.g(`--api-key`)} option.`),e._.log(`Run ${e.g(`stackone init`)} to create a new configuration profile.`),process.exit(1));let n=this.#o(t);g=await this.#s(n,h?.apiUrl??Ee,h?.apiKey)}else g=this.#e(t);else (0,S.notMissing)(o)&&(g=await this.#c(o,h?.apiUrl??Ee,h?.apiKey));let _=(0,S.notMissing)(n)?this.#r(n,t):g;(0,S.isMissing)(_)&&(e._.error(`A valid connector is required to run an action.`),process.exit(1));let v=(0,S.notMissing)(_?.actions)?Object.keys(_?.actions).length:0,y=(0,S.notMissing)(_?.actions)?Object.keys(_.actions)[v-1]:void 0,b=(0,S.notMissing)(y)?_?.actions?.[y]?.id:void 0,x=((0,S.notMissing)(i)&&!i?.startsWith(`${_.key}_`)?`${_.key}_${i}`:i)??b;(0,S.isMissing)(x)&&(e._.error(`A valid action ID is required to run an action`),process.exit(1));let C=(0,S.notMissing)(o)?await this.#l(o,h?.apiUrl??Ee,h?.apiKey):{},w=(0,S.notMissing)(a)?this.#i(a,_.key??`unknown`,_.version??`unknown`):void 0,T=(0,S.notMissing)(c)?this.#u(c):{},ee={...C,...w,credentials:{...C.credentials??{},...T}};(0,S.isMissing)(ee)&&(e._.error(`A valid account data is required to run an action.`),process.exit(1));let E=_.actions?.[x];(0,S.isMissing)(E)&&(e._.error(`Action ID ${e.g(x)} not found in the connector ${e.g(_.key)}@${e.g(_.version)}.`),process.exit(1));let D=(0,S.notMissing)(s)?this.#d(s,x):{path:{},queryParams:{},header:{},body:{}},O=Date.now(),k=await this.#f({connector:_,actionId:x,account:ee,queryParams:{...D.queryParams,...d?{debug:`true`}:{}},pathParams:D.path,body:D.body,headers:D.header}),A=Date.now()-O;if((0,S.notMissing)(u))try{f.default.writeFileSync(u,JSON.stringify(k.output,null,2),`utf-8`),e._.info(`Output written to file: ${u}`)}catch(t){e._.error(`Failed to write output to file ${u}: ${t.message}`),process.exit(1)}else e._.log(`\n${r.default.blue.inverse(` ACTION OUTPUT `)}`),e.p(k.output);e._.log(``),e._.info(`Action ${e.g(x)} from connector ${e.g(_?.key)}@${e.g(_?.version)} finished in ${r.default.yellowBright((A/1e3).toFixed(2))} seconds.`),process.exit(0)}#e=e=>{let t=e;try{t=(0,w.loadConnector)(e)}catch{}return t?this.#n(t):void 0};#t=t=>{try{return(0,w.loadConnector)(t)}catch(n){e._.error(`Failed to load connector file from ${e.g(t)}: ${n.message}`),process.exit(1)}};#n=t=>{let n=(0,w.validateYamlConnector)(t),r=n?.errors??[];if(n.success)return n.connector||(e._.error(`Failed to load connector.`),process.exit(1)),n.connector;r.length>0?(e._.error(`Connector is not valid`),e.f(r,!0),process.exit(1)):(e._.error(`Connector is not valid. Please check the file for errors.`),process.exit(1))};#r=(t,n)=>{let r=t;try{r=f.default.readFileSync(t,`utf-8`)}catch{}(0,S.isMissing)(n)&&(e._.error(`A valid connector is required to load an action.`),process.exit(1));let i=`${this.#t(n)} - ${r.split(`
|
|
118
118
|
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
119
|
-
`)}`;return this.#n(i)};#i=(t,n,r)=>{let i=t;try{i=f.default.readFileSync(t,`utf-8`)}catch{}try{let e=Ce.parse(JSON.parse(i));return{providerKey:n,providerVersion:r,authConfigKey:e.auth_config_key,environment:e.environment,organizationId:e.organization_id,secureId:e.account_id,projectSecureId:e.project_id}}catch(t){let n=[];try{n=JSON.parse(t.message)}catch{}e._.error(`Failed to parse account information`),e.f(n,!1),n.length===0&&e._.log(t.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(t,n,r)=>{((0,S.isMissing)(t)||(0,S.isMissing)(n)||(0,S.isMissing)(r))&&(e._.error(`Connector identifier, API URL, and API key are required to fetch connector from registry.`),process.exit(1));let i=(0,v.default)();try{i.text=`Fetching connector ${e.g(t)} from registry...`,i.start();let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/registry/connectors/${t}`,{method:`GET`,headers:{Authorization:`Basic ${a}`}});i.stop(),o.ok||(await e.m(o,`Failed to fetch connector ${e.g(t)} from registry`),process.exit(1));let s=await o.text(),c=this.#n(s);return e._.success(`Fetched connector ${e.g(c.key)}@${e.g(c.version)} from registry`),c}catch(r){i.stop(),e._.error(`Failed to fetch connector ${e.g(t)} from registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}};#c=async(t,n,r)=>{((0,S.isMissing)(t)||(0,S.isMissing)(n)||(0,S.isMissing)(r))&&(e._.error(`Account ID, API URL, and API key are required to fetch connector`),process.exit(1));let i=(0,v.default)();try{i.text=`Fetching connector for account ${e.g(t)} from API...`,i.start();let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/accounts/${t}/connector`,{method:`GET`,headers:{Authorization:`Basic ${a}`}});i.stop(),o.ok||(await e.m(o,`Failed to fetch connector`),process.exit(1));let s=await o.text(),c=this.#n(s);return e._.success(`Fetched connector ${e.g(c.key)}@${e.g(c.version)} for account ${e.g(t)}`),c}catch(t){i.stop(),e._.error(`Failed to fetch connector: ${t.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}};#l=async(t,n,r)=>{((0,S.isMissing)(t)||(0,S.isMissing)(n)||(0,S.isMissing)(r))&&(e._.error(`Account ID, API URL, and API key are required to fetch account information.`),process.exit(1));let i=(0,v.default)();try{i.text=`Fetching account ${e.g(t)} information from API...`,i.start();let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/accounts/${t}/credentials`,{method:`GET`,headers:{Authorization:`Basic ${a}`}});i.stop(),o.ok||(await e.m(o,`Failed to fetch account ${e.g(t)} information`),process.exit(1));let s=await o.json();return e._.success(`Fetched account ${e.g(t)} information from project ${e.g(s.project_id)}`),{providerKey:s.provider_key,providerVersion:s.provider_version,authConfigKey:s.auth_config_key,environment:s.environment,organizationId:s.organization_id,secureId:s.account_id,projectSecureId:s.project_id,credentials:s.credentials}}catch(r){i.stop(),e._.error(`Failed to fetch account ${e.g(t)} information: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}};#u=t=>{let n=t;try{n=f.default.readFileSync(t,`utf-8`)}catch{}try{return we.parse(JSON.parse(n))}catch(t){let n=[];try{n=JSON.parse(t.message)}catch{}e._.error(`Failed to parse credentials`),e.f(n,!1),n.length===0&&e._.log(t.message),process.exit(1)}};#d=(t,n)=>{let r=t;try{r=f.default.readFileSync(t,`utf-8`)}catch{}try{return Te.parse(JSON.parse(r))}catch(t){let r=[];try{r=JSON.parse(t.message)}catch{}e._.error(`Invalid parameters for action ${e.g(n)}.`),e.f(r,!1),r.length===0&&e._.log(t.message),process.exit(1)}};async#f({connector:t,actionId:n,account:i,pathParams:a={},queryParams:o={},body:s={},headers:c={}}){try{let l=await(0,w.runAction)({mode:`action_id`,actionId:n,account:i,connector:t,pathParams:a,queryParams:o,body:s,headers:c,getHttpClient:async()=>new E.HttpClient});if(l.response?.successful){let e={...this.#p(o,l.steps),...(0,S.isObject)(l.outputs)?l.outputs:{data:l.outputs}};return{statusCode:l.response?.statusCode,output:e}}else{let i=l.response?.message??`An error occurred while processing the request`;e._.error(`Action ID ${e.g(n)} from connector ${e.g(t.key)}@${e.g(t.version)} failed with status ${l.response?.statusCode}: ${i}`);let a={...this.#p(o,l.steps)};Object.keys(a).length>0&&(e._.log(`${r.default.yellow.inverse(` EXECUTION DETAILS `)}`),e.p(a)),process.exit(1)}}catch(e){this.#m(e)}}#p(e,t){return e?.debug===`true`?{debug:{steps:t}}:{}}#m(t){let n=t;switch((0,S.isMissing)(n.errorType)&&(e._.error(`An unknown error occurred`),e._.log(`${t instanceof Error?t.message:String(t)}`),process.exit(1)),n.errorType){case`MISSING_ACTION_ERROR`:e._.error(`The specified action was not found: ${n.message}`);break;case`INVALID_ACTION_INPUTS_ERROR`:let t=n;e._.error(`Invalid action inputs`),e.f(t.validationErrors,!1);break;case`INVALID_CURSOR_ERROR`:e._.error(`Invalid cursor: ${n.message}`);break;default:e._.error(`An error occurred: ${n.message}`)}process.exit(1)}};const Oe=(0,_.promisify)(h.exec);var ke=class{constructor(){this.packageName=`@stackone/cli`,this.spinner=(0,v.default)(),this.currentVersion=
|
|
120
|
-
Exiting watch mode...`)),process.exit(0)};Ae(),e._.start(`Validating connectors...`);let c=await Fe(o);t=Me(t,c||{}),Ne(t,o),a.start();let l=n(o,{persistent:!0,ignoreInitial:!0}),u=async n=>{if(!n.endsWith(`.s1.yaml`)&&!n.endsWith(`s1.partial.yaml`))return;let i=n.endsWith(`s1.partial.yaml`)?await Le(n):[n];if(!(!i||i.length===0)){e.d(),a.stop(),Ae(),e._.log(r.default.gray(`File change detected: ${n}`)),e._.start(`Validating connectors...`);for(let e of i){let n=await Fe(e);t=Me(t,n||{})}Ne(t,o),a.start()}};l.on(`change`,async e=>await u(e)),process.stdin.on(`data`,e=>{e.toString()===`q`&&s()}),process.on(`SIGINT`,()=>{s()})}else await Fe(o,e._),process.exit(0)}};const Me=(e,t)=>{for(let[n,r]of Object.entries(t))e[n]=r;return e},Ne=(t,n)=>{e.d(),Ae();let i=0,a=0;for(let[n,r]of Object.entries(t))r===null?i++:(e._?.error(`Connector ${e.g(n)} is not valid`),e.f(r,!0),a++);e._.log(``),e._.log(r.default.blue.inverse(` Validation Summary `)),e._.log(`Connectors path: ${e.g(n)}`),e._.log(`${i===0?r.default.red(`0`):r.default.green(i)} valid, ${a===0?r.default.green(`0`):r.default.red(a)} invalid connectors\n`)},Pe=async e=>{let t=[],n=await(0,O.readdir)(e);for(let r of n){let n=(0,p.join)(e,r),i=await(0,O.stat)(n);i.isDirectory()?t.push(...await Pe(n)):i.isFile()&&r.endsWith(`.s1.yaml`)&&t.push(n)}return t},Fe=async(t,n)=>{let i=await(0,O.stat)(t),a={};if(i.isDirectory()){let i=await Pe(t);if(i.length===0)return n?.error(`No StackOne connector found in ${e.h(t)}`),n?.log(`Connector files need to have the extension ${e.g(`*.s1.yaml`)}`),null;let o=0,s=0;for(let e of i){let t=await Ie(e,n);t===null?o++:(n?.log(``),s++),a[e]=t}return n?.log(``),n?.log(r.default.blue.inverse(` Validation Summary `)),n?.log(`${o===0?r.default.red(`0`):r.default.green(o)} valid, ${s===0?r.default.green(`0`):r.default.red(s)} invalid connectors`),a}else if(i.isFile()&&t.endsWith(`s1.yaml`))return a[t]=await Ie(t,n),a;else if(i.isFile()&&t.endsWith(`partial.yaml`)){n?.error(`Partial connector files cannot be validated directly`),n?.log(`The file ${e.h(t)} is a partial connector file.`);let r=await Le(t);return r&&r?.length>0&&n?.log(`Did you mean ${e.g(r[0])}?`),null}else return n?.error(`No StackOne connector found in ${e.h(t)}`),n?.log(`Connector files need to have the extension ${e.g(`*.s1.yaml`)}`),null},Ie=async(t,n)=>{let r=(0,w.validateYamlConnector)((0,w.loadConnector)(t)),i=r?.errors??[];if(r.success){let r=t.split(`/`).pop()||t;return n?.success(`Connector ${e.g(r)} is valid!`),null}else if(i.length>0)return n?.error(`Connector ${e.g(t)} is not valid`),n&&e.f(i,!0),i;else return n?.error(`Connector ${e.g(t)} is not valid. Please check the file for errors`),[]},Le=async e=>{let t=(0,p.dirname)(e);try{return(await(0,O.readdir)(t)).filter(e=>e.endsWith(`.s1.yaml`))?.map(e=>(0,p.join)(t,e))}catch{}};function Re(){let e=process.env.LANGSMITH_API_KEY,t=process.env.LANGSMITH_PROJECT||`stackone-agent-cli`;e&&((0,a.initLangSmith)({apiKey:e,projectName:t,enabled:!0,metadata:{source:`cli`,version:process.env.npm_package_version||`unknown`}}),process.env.VERBOSE&&console.log(`[Telemetry] LangSmith initialized for project:`,t))}const ze=`@stackone/cli`,Be=2880*60*1e3,Ve=(0,c.join)((0,s.homedir)(),`.stackone`),He=(0,c.join)(Ve,`version-check.json`),Ue=(e=!1)=>{let t=qe(),n=Date.now();if(e||!t||n-t.lastCheckTime>1728e5){let e=We();e&&Ge(e)&&Ke(e),Je({lastCheckTime:n})}},We=()=>{try{return(0,h.execSync)(`npm view @stackone/cli version`,{encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`],timeout:15e3}).trim()}catch{return null}},Ge=e=>{try{let t=se();return D.default.gt(e,t)}catch{return!1}},Ke=t=>{let n=se(),i=`Update available: ${r.default.dim(n)} → ${r.default.green(t)}`,a=`\n\nRun ${r.default.cyan(`stackone update`)} to update`;e._.box(i,a)},qe=()=>{try{if(!(0,o.existsSync)(He))return null;let e=(0,o.readFileSync)(He,`utf-8`);return JSON.parse(e)}catch{return null}},Je=e=>{try{(0,o.existsSync)(Ve)||(0,o.mkdirSync)(Ve,{recursive:!0}),(0,o.writeFileSync)(He,JSON.stringify(e,null,2),`utf-8`)}catch{}};var Ye=class{constructor(e=new i.Command,t=se()){this.program=e,this.version=t,Re(),this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne CLI`).version(this.version,`-v, --version`)}registerCommands(){let t=new q,n=new Z,a=new xe,o=new he,s=new G,c=new je,l=new pe,u=new me,d=new ue,f=new N,p=new De,m=new ke;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(e,t)=>{t(r.default.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(e=>{t.execute({environment:e.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 i.Argument(`<path>`,`Connector file or directory to push`)).description(`Push a connector to the StackOne registry`).action((e,t)=>{n.execute({profile:t.profile,fileOrDir:e,apiUrl:t.apiUrl,apiKey:t.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 i.Argument(`<connector>`,`Connector identifier in format provider_key@version`)).description(`Drop a connector from the StackOne registry`).action((e,t)=>{o.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`).description(`Get a connector from the StackOne registry`).action(e=>{s.execute({profile:e.profile,connector:e.connector,accountId:e.accountId,format:e.format,outputFile:e.outputFile,apiUrl:e.apiUrl,apiKey:e.apiKey})}),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)`).description(`Pull a connector configuration from StackOne registry to local filesystem`).action(e=>{a.execute({profile:e.profile,connector:e.connector,outputPath:e.output,apiUrl:e.apiUrl,apiKey:e.apiKey})}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new i.Argument(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{c.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`).description(`Run a connector action`).action(e=>{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})});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?l.execute():u.execute()}),h.command(`cleanup`).description(`Remove all API keys and credentials from configurations`).action(()=>{d.execute()}),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 t=>{let n=[`build`,`test`,`research`];t.mode&&!n.includes(t.mode)&&(e._.error(`❌ Error: Invalid mode "${t.mode}". Must be one of: ${n.join(`, `)}`),process.exit(1)),t.temperature!==void 0&&(isNaN(t.temperature)&&(e._.error(`❌ Error: Temperature must be a valid number`),process.exit(1)),(t.temperature<0||t.temperature>1)&&(e._.error(`❌ Error: Temperature must be between 0 and 1`),process.exit(1))),f.execute({mode:t.mode,connector:t.connector,action:t.action,goal:t.goal,temperature:t.temperature,verbose:t.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()=>{e._.log(`${r.default.inverse.greenBright(`StackOne`)} ${r.default.grey(`CLI`)} ${r.default.whiteBright(this.version)}`),Ue(!0),process.exit(0)})}run(){process.argv.includes(`version`)||Ue(),this.program.parse(process.argv)}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Ye}});
|
|
119
|
+
`)}`;return this.#n(i)};#i=(t,n,r)=>{let i=t;try{i=f.default.readFileSync(t,`utf-8`)}catch{}try{let e=Ce.parse(JSON.parse(i));return{providerKey:n,providerVersion:r,authConfigKey:e.auth_config_key,environment:e.environment,organizationId:e.organization_id,secureId:e.account_id,projectSecureId:e.project_id}}catch(t){let n=[];try{n=JSON.parse(t.message)}catch{}e._.error(`Failed to parse account information`),e.f(n,!1),n.length===0&&e._.log(t.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(t,n,r)=>{((0,S.isMissing)(t)||(0,S.isMissing)(n)||(0,S.isMissing)(r))&&(e._.error(`Connector identifier, API URL, and API key are required to fetch connector from registry.`),process.exit(1));let i=(0,v.default)();try{i.text=`Fetching connector ${e.g(t)} from registry...`,i.start();let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/registry/connectors/${t}`,{method:`GET`,headers:{Authorization:`Basic ${a}`}});i.stop(),o.ok||(await e.m(o,`Failed to fetch connector ${e.g(t)} from registry`),process.exit(1));let s=await o.text(),c=this.#n(s);return e._.success(`Fetched connector ${e.g(c.key)}@${e.g(c.version)} from registry`),c}catch(r){i.stop(),e._.error(`Failed to fetch connector ${e.g(t)} from registry: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}};#c=async(t,n,r)=>{((0,S.isMissing)(t)||(0,S.isMissing)(n)||(0,S.isMissing)(r))&&(e._.error(`Account ID, API URL, and API key are required to fetch connector`),process.exit(1));let i=(0,v.default)();try{i.text=`Fetching connector for account ${e.g(t)} from API...`,i.start();let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/accounts/${t}/connector`,{method:`GET`,headers:{Authorization:`Basic ${a}`}});i.stop(),o.ok||(await e.m(o,`Failed to fetch connector`),process.exit(1));let s=await o.text(),c=this.#n(s);return e._.success(`Fetched connector ${e.g(c.key)}@${e.g(c.version)} for account ${e.g(t)}`),c}catch(t){i.stop(),e._.error(`Failed to fetch connector: ${t.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}};#l=async(t,n,r)=>{((0,S.isMissing)(t)||(0,S.isMissing)(n)||(0,S.isMissing)(r))&&(e._.error(`Account ID, API URL, and API key are required to fetch account information.`),process.exit(1));let i=(0,v.default)();try{i.text=`Fetching account ${e.g(t)} information from API...`,i.start();let a=Buffer.from(r).toString(`base64`),o=await fetch(`${n}/accounts/${t}/credentials`,{method:`GET`,headers:{Authorization:`Basic ${a}`}});i.stop(),o.ok||(await e.m(o,`Failed to fetch account ${e.g(t)} information`),process.exit(1));let s=await o.json();return e._.success(`Fetched account ${e.g(t)} information from project ${e.g(s.project_id)}`),{providerKey:s.provider_key,providerVersion:s.provider_version,authConfigKey:s.auth_config_key,environment:s.environment,organizationId:s.organization_id,secureId:s.account_id,projectSecureId:s.project_id,credentials:s.credentials}}catch(r){i.stop(),e._.error(`Failed to fetch account ${e.g(t)} information: ${r.message}`),e._.log(`Please ensure that the API at ${e.v(n)} is reachable and the API key is valid`),process.exit(1)}};#u=t=>{let n=t;try{n=f.default.readFileSync(t,`utf-8`)}catch{}try{return we.parse(JSON.parse(n))}catch(t){let n=[];try{n=JSON.parse(t.message)}catch{}e._.error(`Failed to parse credentials`),e.f(n,!1),n.length===0&&e._.log(t.message),process.exit(1)}};#d=(t,n)=>{let r=t;try{r=f.default.readFileSync(t,`utf-8`)}catch{}try{return Te.parse(JSON.parse(r))}catch(t){let r=[];try{r=JSON.parse(t.message)}catch{}e._.error(`Invalid parameters for action ${e.g(n)}.`),e.f(r,!1),r.length===0&&e._.log(t.message),process.exit(1)}};async#f({connector:t,actionId:n,account:i,pathParams:a={},queryParams:o={},body:s={},headers:c={}}){try{let l=await(0,w.runAction)({mode:`action_id`,actionId:n,account:i,connector:t,pathParams:a,queryParams:o,body:s,headers:c,getHttpClient:async()=>new E.HttpClient});if(l.response?.successful){let e={...this.#p(o,l.steps),...(0,S.isObject)(l.outputs)?l.outputs:{data:l.outputs}};return{statusCode:l.response?.statusCode,output:e}}else{let i=l.response?.message??`An error occurred while processing the request`;e._.error(`Action ID ${e.g(n)} from connector ${e.g(t.key)}@${e.g(t.version)} failed with status ${l.response?.statusCode}: ${i}`);let a={...this.#p(o,l.steps)};Object.keys(a).length>0&&(e._.log(`${r.default.yellow.inverse(` EXECUTION DETAILS `)}`),e.p(a)),process.exit(1)}}catch(e){this.#m(e)}}#p(e,t){return e?.debug===`true`?{debug:{steps:t}}:{}}#m(t){let n=t;switch((0,S.isMissing)(n.errorType)&&(e._.error(`An unknown error occurred`),e._.log(`${t instanceof Error?t.message:String(t)}`),process.exit(1)),n.errorType){case`MISSING_ACTION_ERROR`:e._.error(`The specified action was not found: ${n.message}`);break;case`INVALID_ACTION_INPUTS_ERROR`:let t=n;e._.error(`Invalid action inputs`),e.f(t.validationErrors,!1);break;case`INVALID_CURSOR_ERROR`:e._.error(`Invalid cursor: ${n.message}`);break;default:e._.error(`An error occurred: ${n.message}`)}process.exit(1)}};const Oe=(0,_.promisify)(h.exec);var ke=class{constructor(){this.packageName=`@stackone/cli`,this.spinner=(0,v.default)(),this.currentVersion=oe()}async execute(t={}){this.spinner.text=`Checking for updates...`,this.spinner.start();try{let n=await this.getLatestVersion();this.spinner.stop(),n||(e._.error(`Failed to check for updates`),process.exit(1)),this.isNewerVersion(n,this.currentVersion)?(e._.box(`New version available: ${r.default.yellow(this.currentVersion)} → ${r.default.green(n)}`),await this.performUpdate(n)):t.force?(e._.warn(`No updates available, but forcing reinstall...`),await this.performUpdate(n)):e._.success(`You are already on the latest version (${this.currentVersion})`),process.exit(0)}catch(t){this.spinner.stop(),e._.error(`Error while trying to update StackOne CLI: ${t?.message??`Unknown error`}`),process.exit(1)}}async getLatestVersion(){try{let{stdout:e}=await Oe(`npm view ${this.packageName} version`,{encoding:`utf-8`});return e.trim()}catch{return null}}isNewerVersion(e,t){return D.default.gt(e,t)}isUsingVolta(){if(typeof process.env.VOLTA_HOME!=`string`||process.env.VOLTA_HOME.length===0)return!1;let e=(0,c.join)(process.env.VOLTA_HOME,`bin`),t=(0,c.join)(e,`stackone`),n=(0,c.join)(e,`stackone.exe`);return(0,o.existsSync)(t)||(0,o.existsSync)(n)}async performUpdate(t){let n=this.isUsingVolta();this.spinner.text=`Updating to latest version (${e.g(t)})...`,this.spinner.start();try{await Oe(n?`volta install ${this.packageName}@latest`:`npm install -g ${this.packageName}@latest`,{encoding:`utf-8`}),this.spinner.stop(),e._.success(`StackOne CLI updated successfully to latest version (${e.g(t)})`)}catch{this.spinner.stop();let e=n?`volta install ${this.packageName}@latest`:`npm install -g ${this.packageName}@latest`;throw Error(`Failed to install update. Please try manually: ${e}`)}}};const Ae=()=>{e._.log(`${r.default.gray.inverse(` CONNECTORS VALIDATION `)} ${r.default.yellow.inverse(` WATCH MODE `)}\n`)};var je=class{async execute(t){let{watchMode:n,fileOrDir:i}=t,a=(0,v.default)(`Watching for file changes... ${r.default.gray(`(press "q" to quit)`)}`);if(!i)return;let o=(0,p.resolve)(i);try{await(0,O.stat)(o)}catch{e._.error(`The specified path does not exist: ${o}\n`),process.exit(1)}if(n){e.d();let t={},{watch:n}=await import(`chokidar`),i=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding(`utf8`);let s=()=>{l.close(),a.stop(),i.close(),e._.log(r.default.grey(`
|
|
120
|
+
Exiting watch mode...`)),process.exit(0)};Ae(),e._.start(`Validating connectors...`);let c=await Fe(o);t=Me(t,c||{}),Ne(t,o),a.start();let l=n(o,{persistent:!0,ignoreInitial:!0}),u=async n=>{if(!n.endsWith(`.s1.yaml`)&&!n.endsWith(`s1.partial.yaml`))return;let i=n.endsWith(`s1.partial.yaml`)?await Le(n):[n];if(!(!i||i.length===0)){e.d(),a.stop(),Ae(),e._.log(r.default.gray(`File change detected: ${n}`)),e._.start(`Validating connectors...`);for(let e of i){let n=await Fe(e);t=Me(t,n||{})}Ne(t,o),a.start()}};l.on(`change`,async e=>await u(e)),process.stdin.on(`data`,e=>{e.toString()===`q`&&s()}),process.on(`SIGINT`,()=>{s()})}else await Fe(o,e._),process.exit(0)}};const Me=(e,t)=>{for(let[n,r]of Object.entries(t))e[n]=r;return e},Ne=(t,n)=>{e.d(),Ae();let i=0,a=0;for(let[n,r]of Object.entries(t))r===null?i++:(e._?.error(`Connector ${e.g(n)} is not valid`),e.f(r,!0),a++);e._.log(``),e._.log(r.default.blue.inverse(` Validation Summary `)),e._.log(`Connectors path: ${e.g(n)}`),e._.log(`${i===0?r.default.red(`0`):r.default.green(i)} valid, ${a===0?r.default.green(`0`):r.default.red(a)} invalid connectors\n`)},Pe=async e=>{let t=[],n=await(0,O.readdir)(e);for(let r of n){let n=(0,p.join)(e,r),i=await(0,O.stat)(n);i.isDirectory()?t.push(...await Pe(n)):i.isFile()&&r.endsWith(`.s1.yaml`)&&t.push(n)}return t},Fe=async(t,n)=>{let i=await(0,O.stat)(t),a={};if(i.isDirectory()){let i=await Pe(t);if(i.length===0)return n?.error(`No StackOne connector found in ${e.h(t)}`),n?.log(`Connector files need to have the extension ${e.g(`*.s1.yaml`)}`),null;let o=0,s=0;for(let e of i){let t=await Ie(e,n);t===null?o++:(n?.log(``),s++),a[e]=t}return n?.log(``),n?.log(r.default.blue.inverse(` Validation Summary `)),n?.log(`${o===0?r.default.red(`0`):r.default.green(o)} valid, ${s===0?r.default.green(`0`):r.default.red(s)} invalid connectors`),a}else if(i.isFile()&&t.endsWith(`s1.yaml`))return a[t]=await Ie(t,n),a;else if(i.isFile()&&t.endsWith(`partial.yaml`)){n?.error(`Partial connector files cannot be validated directly`),n?.log(`The file ${e.h(t)} is a partial connector file.`);let r=await Le(t);return r&&r?.length>0&&n?.log(`Did you mean ${e.g(r[0])}?`),null}else return n?.error(`No StackOne connector found in ${e.h(t)}`),n?.log(`Connector files need to have the extension ${e.g(`*.s1.yaml`)}`),null},Ie=async(t,n)=>{let r=(0,w.validateYamlConnector)((0,w.loadConnector)(t)),i=r?.errors??[];if(r.success){let r=t.split(`/`).pop()||t;return n?.success(`Connector ${e.g(r)} is valid!`),null}else if(i.length>0)return n?.error(`Connector ${e.g(t)} is not valid`),n&&e.f(i,!0),i;else return n?.error(`Connector ${e.g(t)} is not valid. Please check the file for errors`),[]},Le=async e=>{let t=(0,p.dirname)(e);try{return(await(0,O.readdir)(t)).filter(e=>e.endsWith(`.s1.yaml`))?.map(e=>(0,p.join)(t,e))}catch{}};function Re(){let e=process.env.LANGSMITH_API_KEY,t=process.env.LANGSMITH_PROJECT||`stackone-agent-cli`;e&&((0,a.initLangSmith)({apiKey:e,projectName:t,enabled:!0,metadata:{source:`cli`,version:process.env.npm_package_version||`unknown`}}),process.env.VERBOSE&&console.log(`[Telemetry] LangSmith initialized for project:`,t))}const ze=`@stackone/cli`,Be=2880*60*1e3,Ve=(0,c.join)((0,s.homedir)(),`.stackone`),He=(0,c.join)(Ve,`version-check.json`),Ue=(e=!1)=>{let t=qe(),n=Date.now();if(e||!t||n-t.lastCheckTime>1728e5){let e=We();e&&Ge(e)&&Ke(e),Je({lastCheckTime:n})}},We=()=>{try{return(0,h.execSync)(`npm view @stackone/cli version`,{encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`],timeout:15e3}).trim()}catch{return null}},Ge=e=>{try{let t=oe();return D.default.gt(e,t)}catch{return!1}},Ke=t=>{let n=oe(),i=`Update available: ${r.default.dim(n)} → ${r.default.green(t)}`,a=`\n\nRun ${r.default.cyan(`stackone update`)} to update`;e._.box(i,a)},qe=()=>{try{if(!(0,o.existsSync)(He))return null;let e=(0,o.readFileSync)(He,`utf-8`);return JSON.parse(e)}catch{return null}},Je=e=>{try{(0,o.existsSync)(Ve)||(0,o.mkdirSync)(Ve,{recursive:!0}),(0,o.writeFileSync)(He,JSON.stringify(e,null,2),`utf-8`)}catch{}};var Ye=class{constructor(e=new i.Command,t=oe()){this.program=e,this.version=t,Re(),this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne CLI`).version(this.version,`-v, --version`)}registerCommands(){let t=new q,n=new Q,a=new xe,o=new W,s=new G,c=new je,l=new z,u=new fe,d=new L,f=new P,p=new De,m=new ke;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(e,t)=>{t(r.default.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(e=>{t.execute({environment:e.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 i.Argument(`<path>`,`Connector file or directory to push`)).description(`Push a connector to the StackOne registry`).action((e,t)=>{n.execute({profile:t.profile,fileOrDir:e,apiUrl:t.apiUrl,apiKey:t.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 i.Argument(`<connector>`,`Connector identifier in format provider_key@version`)).description(`Drop a connector from the StackOne registry`).action((e,t)=>{o.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`).description(`Get a connector from the StackOne registry`).action(e=>{s.execute({profile:e.profile,connector:e.connector,accountId:e.accountId,format:e.format,outputFile:e.outputFile,apiUrl:e.apiUrl,apiKey:e.apiKey})}),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)`).description(`Pull a connector configuration from StackOne registry to local filesystem`).action(e=>{a.execute({profile:e.profile,connector:e.connector,outputPath:e.output,apiUrl:e.apiUrl,apiKey:e.apiKey})}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new i.Argument(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{c.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`).description(`Run a connector action`).action(e=>{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})});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?l.execute():u.execute()}),h.command(`cleanup`).description(`Remove all API keys and credentials from configurations`).action(()=>{d.execute()}),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 t=>{let n=[`build`,`test`,`research`];t.mode&&!n.includes(t.mode)&&(e._.error(`❌ Error: Invalid mode "${t.mode}". Must be one of: ${n.join(`, `)}`),process.exit(1)),t.temperature!==void 0&&(isNaN(t.temperature)&&(e._.error(`❌ Error: Temperature must be a valid number`),process.exit(1)),(t.temperature<0||t.temperature>1)&&(e._.error(`❌ Error: Temperature must be between 0 and 1`),process.exit(1))),f.execute({mode:t.mode,connector:t.connector,action:t.action,goal:t.goal,temperature:t.temperature,verbose:t.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()=>{e._.log(`${r.default.inverse.greenBright(`StackOne`)} ${r.default.grey(`CLI`)} ${r.default.whiteBright(this.version)}`),Ue(!0),process.exit(0)})}run(){process.argv.includes(`version`)||Ue(),this.program.parse(process.argv)}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Ye}});
|