@agenticwork/setup 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +7 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import{useState as Vt}from"react";import{render as nr,Box as Kt,Text as Ge}from"ink";import{Text as B,Box as W}from"ink";import{Text as j}from"ink";import{jsx as Y}from"react/jsx-runtime";function Gt(e,t,n){let i=[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)],o=[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)];return"#"+i.map((l,m)=>Math.round(l+(o[m]-l)*Math.max(0,Math.min(1,n)))).map(l=>l.toString(16).padStart(2,"0")).join("")}function Te(e,t){if(e.length===1)return e[0];let n=Math.max(0,Math.min(1,t))*(e.length-1),i=Math.min(e.length-2,Math.floor(n));return Gt(e[i],e[i+1],n-i)}var ze=({text:e,stops:t,bold:n,dim:i})=>{let o=[...e],s=Math.max(1,o.length-1);return Y(j,{children:o.map((l,m)=>Y(j,{color:Te(t,m/s),bold:n,dimColor:i,children:l},m))})},$e=({width:e,stops:t,char:n="\u2500"})=>{let i=Math.max(1,e-1);return Y(j,{children:Array.from({length:e},(o,s)=>Y(j,{color:Te(t,s/i),children:n},s))})},je=({value:e,total:t,width:n,stops:i,track:o="#2C3A31"})=>{let s=Math.max(0,Math.min(n,Math.round(e/Math.max(1,t)*n))),l=Math.max(1,n-1);return Y(j,{children:Array.from({length:n},(m,r)=>r<s?Y(j,{color:Te(i,r/l),children:"\u2501"},r):Y(j,{color:o,children:"\u2500"},r))})};import{jsx as k,jsxs as F}from"react/jsx-runtime";var a={accent:"#88CCA0",accentDeep:"#5FA877",ink:"#E3EBE0",muted:"#8C9C8C",faint:"#5E6E5E",ok:"#88CCA0",warn:"#D9AE52",err:"#E0663A",signal:"#DB8240",teal:"#9FD8C4"},Ce=["#6FB3A8","#9FD8C4","#88CCA0","#D9AE52","#DB8240"],Ye=()=>Math.max(44,Math.min((process.stdout.columns||80)-6,88)),ae=()=>{let e=Ye();return F(W,{flexDirection:"column",paddingY:1,children:[F(W,{width:e,justifyContent:"space-between",children:[F(W,{children:[F(B,{color:a.signal,bold:!0,children:["\u2325"," "]}),k(ze,{text:"openagentic",stops:Ce,bold:!0})]}),k(B,{color:a.faint,children:"self-hosted \xB7 docker / k8s \xB7 v1.0"})]}),k($e,{width:e,stops:Ce}),k(B,{color:a.muted,children:"the open agentic platform for IT operations"})]})},zt=({step:e,total:t,title:n})=>F(W,{flexDirection:"column",marginBottom:1,children:[F(W,{children:[k(B,{color:a.accent,bold:!0,children:String(e).padStart(2,"0")}),F(B,{color:a.faint,children:[" / ",String(t).padStart(2,"0")]}),k(B,{color:a.faint,children:" "}),k(B,{color:a.ink,bold:!0,children:n})]}),k(W,{marginTop:0,children:k(je,{value:e,total:t,width:Math.min(36,Ye()),stops:Ce})})]}),b=({children:e})=>k(B,{color:a.muted,children:e}),$t=({hints:e})=>k(W,{marginTop:1,children:(e??["\u2191\u2193 move","\u23CE select","esc back","^C quit"]).map((n,i)=>F(B,{color:a.faint,children:[i>0?k(B,{color:a.faint,children:" \xB7 "}):null,n]},i))}),S=({step:e,total:t,title:n,children:i,hints:o,footer:s=!0})=>F(W,{flexDirection:"column",paddingX:2,paddingY:1,children:[k(ae,{}),k(zt,{step:e,total:t,title:n}),k(W,{flexDirection:"column",borderStyle:"round",borderColor:a.accentDeep,paddingX:2,paddingY:1,children:i}),s?k($t,{hints:o}):null]});import jt from"react";import{Box as U,Text as R}from"ink";import{jsx as I,jsxs as P}from"react/jsx-runtime";var Yt="https://openagentics.io/docs/troubleshooting",Jt="https://github.com/agentic-work/openagentic/issues",Xt="support@agenticwork.io",qt={docker:[{label:"Check the API logs",cmd:"docker logs openagentic-api-1 --tail=100"},{label:"See what is running",cmd:"docker compose ps"},{label:"Diagnose your environment",cmd:"curl -fsSL https://install.openagentics.io | bash -s -- --doctor"}],helm:[{label:"See which pods are unhealthy",cmd:"kubectl -n openagentic get pods"},{label:"Describe a stuck pod",cmd:"kubectl -n openagentic describe pod <name>"},{label:"Tail the API",cmd:"kubectl -n openagentic logs deploy/api --tail=100"}],wizard:[{label:"Diagnose your environment",cmd:"curl -fsSL https://install.openagentics.io | bash -s -- --doctor"},{label:"Re-run the wizard",cmd:"curl -fsSL https://install.openagentics.io | bash"}]},_e=({title:e,detail:t,actions:n,target:i="wizard",bare:o=!1})=>{let s=n&&n.length?n:qt[i];return P(U,{flexDirection:"column",paddingX:o?0:2,children:[o?null:I(ae,{}),P(U,{marginTop:1,flexDirection:"column",children:[P(U,{children:[I(R,{color:a.err,bold:!0,children:"\u2717 "}),I(R,{color:a.err,bold:!0,children:e})]}),t?I(U,{marginTop:1,marginLeft:2,children:I(R,{color:a.muted,children:t.slice(0,400)})}):null,P(U,{marginTop:1,flexDirection:"column",children:[I(R,{color:a.ink,bold:!0,children:"First, try these:"}),s.map((l,m)=>P(U,{flexDirection:"column",marginLeft:2,marginTop:m===0?1:0,children:[P(R,{color:a.muted,children:[m+1,". ",l.label]}),l.cmd?P(R,{color:a.accent,children:[" ",l.cmd]}):null]},m))]}),P(U,{marginTop:1,flexDirection:"column",children:[I(R,{color:a.ink,bold:!0,children:"Still stuck?"}),P(U,{marginLeft:2,flexDirection:"column",children:[P(R,{color:a.muted,children:["Troubleshooting: ",I(R,{color:a.teal,children:Yt})]}),P(R,{color:a.muted,children:["Open an issue: ",I(R,{color:a.teal,children:Jt})]}),P(R,{color:a.muted,children:["Email: ",I(R,{color:a.teal,children:Xt})]})]})]})]})]})},pe=class extends jt.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){process.stderr.write(`
2
+ import{useState as Vt}from"react";import{realpathSync as ir}from"fs";import{fileURLToPath as sr}from"url";import{render as ar,Box as Kt,Text as Ge}from"ink";import{Text as B,Box as W}from"ink";import{Text as j}from"ink";import{jsx as Y}from"react/jsx-runtime";function zt(e,t,n){let i=[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)],o=[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)];return"#"+i.map((l,m)=>Math.round(l+(o[m]-l)*Math.max(0,Math.min(1,n)))).map(l=>l.toString(16).padStart(2,"0")).join("")}function Te(e,t){if(e.length===1)return e[0];let n=Math.max(0,Math.min(1,t))*(e.length-1),i=Math.min(e.length-2,Math.floor(n));return zt(e[i],e[i+1],n-i)}var ze=({text:e,stops:t,bold:n,dim:i})=>{let o=[...e],s=Math.max(1,o.length-1);return Y(j,{children:o.map((l,m)=>Y(j,{color:Te(t,m/s),bold:n,dimColor:i,children:l},m))})},$e=({width:e,stops:t,char:n="\u2500"})=>{let i=Math.max(1,e-1);return Y(j,{children:Array.from({length:e},(o,s)=>Y(j,{color:Te(t,s/i),children:n},s))})},je=({value:e,total:t,width:n,stops:i,track:o="#2C3A31"})=>{let s=Math.max(0,Math.min(n,Math.round(e/Math.max(1,t)*n))),l=Math.max(1,n-1);return Y(j,{children:Array.from({length:n},(m,r)=>r<s?Y(j,{color:Te(i,r/l),children:"\u2501"},r):Y(j,{color:o,children:"\u2500"},r))})};import{jsx as k,jsxs as F}from"react/jsx-runtime";var a={accent:"#88CCA0",accentDeep:"#5FA877",ink:"#E3EBE0",muted:"#8C9C8C",faint:"#5E6E5E",ok:"#88CCA0",warn:"#D9AE52",err:"#E0663A",signal:"#DB8240",teal:"#9FD8C4"},Ce=["#6FB3A8","#9FD8C4","#88CCA0","#D9AE52","#DB8240"],Ye=()=>Math.max(44,Math.min((process.stdout.columns||80)-6,88)),ae=()=>{let e=Ye();return F(W,{flexDirection:"column",paddingY:1,children:[F(W,{width:e,justifyContent:"space-between",children:[F(W,{children:[F(B,{color:a.signal,bold:!0,children:["\u2325"," "]}),k(ze,{text:"openagentic",stops:Ce,bold:!0})]}),k(B,{color:a.faint,children:"self-hosted \xB7 docker / k8s \xB7 v1.0"})]}),k($e,{width:e,stops:Ce}),k(B,{color:a.muted,children:"the open agentic platform for IT operations"})]})},$t=({step:e,total:t,title:n})=>F(W,{flexDirection:"column",marginBottom:1,children:[F(W,{children:[k(B,{color:a.accent,bold:!0,children:String(e).padStart(2,"0")}),F(B,{color:a.faint,children:[" / ",String(t).padStart(2,"0")]}),k(B,{color:a.faint,children:" "}),k(B,{color:a.ink,bold:!0,children:n})]}),k(W,{marginTop:0,children:k(je,{value:e,total:t,width:Math.min(36,Ye()),stops:Ce})})]}),b=({children:e})=>k(B,{color:a.muted,children:e}),jt=({hints:e})=>k(W,{marginTop:1,children:(e??["\u2191\u2193 move","\u23CE select","esc back","^C quit"]).map((n,i)=>F(B,{color:a.faint,children:[i>0?k(B,{color:a.faint,children:" \xB7 "}):null,n]},i))}),S=({step:e,total:t,title:n,children:i,hints:o,footer:s=!0})=>F(W,{flexDirection:"column",paddingX:2,paddingY:1,children:[k(ae,{}),k($t,{step:e,total:t,title:n}),k(W,{flexDirection:"column",borderStyle:"round",borderColor:a.accentDeep,paddingX:2,paddingY:1,children:i}),s?k(jt,{hints:o}):null]});import Yt from"react";import{Box as U,Text as R}from"ink";import{jsx as I,jsxs as P}from"react/jsx-runtime";var Jt="https://openagentics.io/docs/troubleshooting",Xt="https://github.com/agentic-work/openagentic/issues",qt="support@agenticwork.io",Zt={docker:[{label:"Check the API logs",cmd:"docker logs openagentic-api-1 --tail=100"},{label:"See what is running",cmd:"docker compose ps"},{label:"Diagnose your environment",cmd:"curl -fsSL https://install.openagentics.io | bash -s -- --doctor"}],helm:[{label:"See which pods are unhealthy",cmd:"kubectl -n openagentic get pods"},{label:"Describe a stuck pod",cmd:"kubectl -n openagentic describe pod <name>"},{label:"Tail the API",cmd:"kubectl -n openagentic logs deploy/api --tail=100"}],wizard:[{label:"Diagnose your environment",cmd:"curl -fsSL https://install.openagentics.io | bash -s -- --doctor"},{label:"Re-run the wizard",cmd:"curl -fsSL https://install.openagentics.io | bash"}]},_e=({title:e,detail:t,actions:n,target:i="wizard",bare:o=!1})=>{let s=n&&n.length?n:Zt[i];return P(U,{flexDirection:"column",paddingX:o?0:2,children:[o?null:I(ae,{}),P(U,{marginTop:1,flexDirection:"column",children:[P(U,{children:[I(R,{color:a.err,bold:!0,children:"\u2717 "}),I(R,{color:a.err,bold:!0,children:e})]}),t?I(U,{marginTop:1,marginLeft:2,children:I(R,{color:a.muted,children:t.slice(0,400)})}):null,P(U,{marginTop:1,flexDirection:"column",children:[I(R,{color:a.ink,bold:!0,children:"First, try these:"}),s.map((l,m)=>P(U,{flexDirection:"column",marginLeft:2,marginTop:m===0?1:0,children:[P(R,{color:a.muted,children:[m+1,". ",l.label]}),l.cmd?P(R,{color:a.accent,children:[" ",l.cmd]}):null]},m))]}),P(U,{marginTop:1,flexDirection:"column",children:[I(R,{color:a.ink,bold:!0,children:"Still stuck?"}),P(U,{marginLeft:2,flexDirection:"column",children:[P(R,{color:a.muted,children:["Troubleshooting: ",I(R,{color:a.teal,children:Jt})]}),P(R,{color:a.muted,children:["Open an issue: ",I(R,{color:a.teal,children:Xt})]}),P(R,{color:a.muted,children:["Email: ",I(R,{color:a.teal,children:qt})]})]})]})]})]})},pe=class extends Yt.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){process.stderr.write(`
3
3
  [wizard] crashed: ${t?.stack||t?.message||String(t)}
4
- `)}render(){return this.state.error?I(_e,{title:"The setup wizard hit an unexpected error.",detail:this.state.error.message,target:"wizard"}):this.props.children}};import{Box as Qt,Text as Qe}from"ink";import{useEffect as Xe,useState as re}from"react";import{Box as J,Text as v,useInput as Re}from"ink";import{jsx as y,jsxs as L}from"react/jsx-runtime";var Zt=()=>{let[e,t]=re(!0);return Xe(()=>{let n=setInterval(()=>t(i=>!i),530);return()=>clearInterval(n)},[]),y(v,{color:a.accent,children:e?"\u258C":" "})},Oe=({value:e,onChange:t,onSubmit:n,isActive:i=!0,mask:o,placeholder:s})=>{Re((m,r)=>{if(r.return){n?.(e);return}if(r.backspace||r.delete){t(e.slice(0,-1));return}r.ctrl||r.meta||r.upArrow||r.downArrow||r.leftArrow||r.rightArrow||r.tab||r.escape||m&&t(e+m)},{isActive:i});let l=o&&e?o.repeat(e.length):e;return L(v,{children:[l?y(v,{color:a.ink,children:l}):s&&!i?y(v,{color:a.faint,children:s}):null,i?y(Zt,{}):null]})},D=({fields:e,values:t,onChange:n,onComplete:i,isActive:o=!0})=>{let[s,l]=re(0),[m,r]=re(null),c=e[s],d=u=>{let g=u.trim(),h=c.validate?c.validate(u):null;if(h){r(h);return}if(!c.optional&&!g){r(`${c.label.trim()} is required`);return}r(null),s+1<e.length?l(s+1):i(t)};return L(J,{flexDirection:"column",children:[e.map((u,g)=>L(J,{children:[L(v,{color:g===s?a.accent:a.muted,children:[g===s?"\u276F ":" ",u.label]}),y(v,{children:" "}),g===s?y(Oe,{value:t[u.key]??"",onChange:h=>n(u.key,h),onSubmit:d,mask:u.mask?"\u2022":void 0,isActive:o}):y(v,{color:a.muted,children:u.mask?t[u.key]?"\u2022".repeat(Math.min(t[u.key].length,24)):"":t[u.key]??""})]},u.key)),m?y(J,{marginTop:1,children:L(v,{color:a.err,children:["\u25CF ",m]})}):null]})};function O({items:e,onSelect:t,isActive:n=!0,initialIndex:i=0}){let[o,s]=re(i);return Re((l,m)=>{m.upArrow||l==="k"?s(r=>(r-1+e.length)%e.length):m.downArrow||l==="j"?s(r=>(r+1)%e.length):m.return&&t(e[o].value)},{isActive:n}),y(J,{flexDirection:"column",children:e.map((l,m)=>{let r=m===o;return L(J,{children:[y(v,{color:r?a.accent:a.faint,children:r?"\u276F ":" "}),y(v,{color:r?a.ink:a.muted,bold:r,children:l.label})]},l.value)})})}var qe=({items:e,selected:t,onChange:n,onSubmit:i,isActive:o=!0})=>{let[s,l]=re(0),m=new Set(t);return Re((r,c)=>{if(c.upArrow||r==="k")l(d=>(d-1+e.length)%e.length);else if(c.downArrow||r==="j")l(d=>(d+1)%e.length);else if(r===" "){let d=e[s].value,u=new Set(m);u.has(d)?u.delete(d):u.add(d),n(e.filter(g=>u.has(g.value)).map(g=>g.value))}else r==="a"?n(e.map(d=>d.value)):r==="n"?n([]):c.return&&i(e.filter(d=>m.has(d.value)).map(d=>d.value))},{isActive:o}),y(J,{flexDirection:"column",children:e.map((r,c)=>{let d=c===s,u=m.has(r.value);return L(J,{children:[y(v,{color:d?a.accent:a.faint,children:d?"\u276F ":" "}),L(v,{color:u?a.ok:a.faint,children:[u?"\u25C9":"\u25CB"," "]}),y(v,{color:d?a.ink:a.muted,bold:d,children:r.label})]},r.value)})})},Je=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Ze=({label:e})=>{let[t,n]=re(0);return Xe(()=>{let i=setInterval(()=>n(o=>(o+1)%Je.length),80);return()=>clearInterval(i)},[]),L(v,{children:[y(v,{color:a.accent,children:Je[t]}),e?L(v,{color:a.muted,children:[" ",e]}):null]})};import{jsx as le,jsxs as et}from"react/jsx-runtime";var tt=({onPick:e})=>et(S,{step:1,total:9,title:"Where do you want to run openagentic?",hints:["\u2191\u2193 / jk move","\u23CE select","esc back","^C quit"],children:[le(O,{items:[{label:"Docker \xB7 local / single machine",value:"docker",hint:"local / single machine"},{label:"Helm \xB7 production / kubernetes",value:"helm",hint:"production / kubernetes"}],onSelect:n=>e(n)}),et(Qt,{marginTop:1,children:[le(Qe,{color:a.faint,children:"\xB7 "}),le(b,{children:"Both paths land at "}),le(Qe,{color:a.teal,children:"http://localhost:8080"}),le(b,{children:" with the same UI."})]})]});import{useEffect as no,useState as io}from"react";import{Box as C,Text as _,useInput as so}from"ink";import{execa as eo}from"execa";import{existsSync as ot,statSync as to}from"node:fs";import{homedir as rt}from"node:os";import{join as nt}from"node:path";var oo=8e3;function ro(e){return e.startsWith("~/")||e==="~"?nt(rt(),e.slice(1)):e}function it(){let e=process.env.KUBECONFIG?.trim();if(e)return e;let t=nt(rt(),".kube","config");return ot(t)?t:null}function st(e){let t=ro(e.trim());if(!t)return{ok:!1,reason:"path is empty"};if(!ot(t))return{ok:!1,reason:`not found: ${t}`};try{if(!to(t).isFile())return{ok:!1,reason:`${t} is not a regular file`}}catch{return{ok:!1,reason:`cannot read ${t}`}}return{ok:!0,path:t}}async function X(e,t,n){try{let i=await eo(e,t,{timeout:oo,env:n,reject:!1});return{ok:i.exitCode===0,stdout:i.stdout||"",stderr:i.stderr||""}}catch(i){return{ok:!1,stdout:"",stderr:String(i)}}}async function at(e){let t={...process.env,KUBECONFIG:e},n={kubeconfigPath:e,kubectlVersion:null,helmVersion:null,context:null,reachable:!1,serverVersion:null,nodeCount:null,namespaceExists:!1,existingRelease:null},i=await X("kubectl",["version","--client=true","--output=json"],t);if(i.ok)try{let d=JSON.parse(i.stdout);n.kubectlVersion=d?.clientVersion?.gitVersion||null}catch{n.kubectlVersion=null}let o=await X("helm",["version","--template={{.Version}}"],t);if(o.ok&&(n.helmVersion=o.stdout.trim()),!n.kubectlVersion||!n.helmVersion)return n;let s=await X("kubectl",["config","current-context"],t);if(s.ok&&(n.context=s.stdout.trim()),!n.context)return n;let l=await X("kubectl",["version","--output=json"],t);if(l.ok)try{let d=JSON.parse(l.stdout);n.serverVersion=d?.serverVersion?.gitVersion||null,n.reachable=!!n.serverVersion}catch{n.reachable=!1}if(!n.reachable)return n;let m=await X("kubectl",["get","nodes","-o","name"],t);m.ok&&(n.nodeCount=m.stdout.split(`
5
- `).filter(Boolean).length);let r=await X("kubectl",["get","namespace","openagentic","-o","name"],t);n.namespaceExists=r.ok&&r.stdout.trim().length>0;let c=await X("helm",["list","-n","openagentic","-o","json"],t);if(c.ok)try{let d=JSON.parse(c.stdout);if(Array.isArray(d)&&d.length>0){let u=d.find(g=>g.name==="openagentic")??d[0];u&&(n.existingRelease={name:u.name,revision:Number(u.revision)||0,status:u.status||"unknown"})}}catch{}return n}import{jsx as x,jsxs as M}from"react/jsx-runtime";var lt=e=>{let t=e.trim();return!t||t.startsWith("~/")||t==="~"||t.startsWith("/")?null:"enter a leading-tilde (~/\u2026) or absolute (/\u2026) path"},ct=({onContinue:e,onBackToDocker:t})=>{let n=it(),[i,o]=io(n?{stage:"probing",kubeconfigPath:n}:{stage:"picking-kubeconfig",input:"",error:null});if(no(()=>{if(i.stage!=="probing")return;let c=!1;return at(i.kubeconfigPath).then(d=>{c||o({stage:"ready",probe:d})}),()=>{c=!0}},[i.stage==="probing"?i.kubeconfigPath:null]),so((c,d)=>{i.stage==="picking-kubeconfig"&&d.escape&&t()}),i.stage==="picking-kubeconfig"){let c=lt(i.input);return M(S,{step:2,total:10,title:"Checking your cluster",hints:["type path","\u23CE probe","esc back to Docker","^C quit"],children:[M(C,{flexDirection:"column",marginBottom:1,children:[M(_,{children:["No kubeconfig found at ",x(_,{color:a.accent,children:"$KUBECONFIG"})," or ",x(_,{color:a.accent,children:"~/.kube/config"}),"."]}),M(_,{children:["Paste a path to your kubeconfig, or press ",x(_,{color:a.accent,children:"Esc"})," to go back to Docker."]})]}),M(C,{children:[x(_,{color:a.accent,children:"\u276F "}),x(_,{color:a.muted,children:"kubeconfig "}),x(Oe,{value:i.input,placeholder:"~/.kube/config",onChange:d=>o({...i,input:d,error:null}),onSubmit:d=>{let u=lt(d);if(u){o({...i,error:u});return}let g=st(d);if(!g.ok){o({...i,error:g.reason});return}o({stage:"probing",kubeconfigPath:g.path})}})]}),(i.error??c)&&x(C,{marginTop:1,children:M(_,{color:a.err,children:["\u25CF ",i.error??c]})})]})}if(i.stage==="probing")return x(S,{step:2,total:10,title:"Checking your cluster",footer:!1,children:x(Ze,{label:`probing cluster via ${i.kubeconfigPath}\u2026`})});let{probe:s}=i,l=[{label:"kubeconfig",value:s.kubeconfigPath},{label:"kubectl",value:s.kubectlVersion??"not found on PATH",colour:s.kubectlVersion?void 0:a.err},{label:"helm",value:s.helmVersion??"not found on PATH",colour:s.helmVersion?void 0:a.err},{label:"context",value:s.context??"no current context set",colour:s.context?void 0:a.err},{label:"cluster",value:s.reachable?`${s.serverVersion??"unknown"} (${s.nodeCount??"?"} nodes)`:"unreachable",colour:s.reachable?a.ok:a.err},{label:"namespace",value:s.namespaceExists?"openagentic \u2014 exists":"openagentic \u2014 does not exist",colour:s.namespaceExists?a.warn:void 0},{label:"existing release",value:s.existingRelease?`${s.existingRelease.name} rev ${s.existingRelease.revision} (${s.existingRelease.status})`:"none",colour:s.existingRelease?a.warn:void 0}],m=s.kubectlVersion?s.helmVersion?s.context?s.reachable?null:"cluster is unreachable. Check VPN / kubeconfig / network.":"no current kubectl context is set. Run: kubectl config use-context <name>":"helm is not installed or not on PATH.":"kubectl is not installed or not on PATH.";if(m)return M(S,{step:2,total:10,title:"Checking your cluster",hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:[x(C,{flexDirection:"column",children:l.map(c=>M(C,{children:[x(C,{width:18,children:x(_,{color:a.muted,children:c.label})}),x(_,{color:c.colour,children:c.value})]},c.label))}),x(C,{marginTop:1,children:M(_,{color:a.err,children:["\u25CF ",m]})}),x(C,{marginTop:1,children:x(O,{items:[{label:"Back to Docker deploy",value:"docker"},{label:"Quit",value:"quit"}],onSelect:c=>{c==="docker"?t():process.exit(0)}})})]});let r=s.existingRelease?`Existing release 'openagentic' (rev ${s.existingRelease.revision}). Continuing will run helm upgrade.`:s.namespaceExists?"Namespace 'openagentic' exists but no Helm release. Continuing will adopt it.":null;return M(S,{step:2,total:10,title:"Checking your cluster",hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:[x(C,{flexDirection:"column",children:l.map(c=>M(C,{children:[x(C,{width:18,children:x(_,{color:a.muted,children:c.label})}),x(_,{color:c.colour,children:c.value})]},c.label))}),r&&x(C,{marginTop:1,children:M(_,{color:a.warn,children:["\u26A0 ",r]})}),x(C,{marginTop:1,children:x(O,{items:[{label:s.existingRelease?"Upgrade existing release":"Continue",value:"continue"},{label:"Back to Docker deploy",value:"docker"}],onSelect:c=>{c==="continue"?e(s.kubeconfigPath):t()}})}),x(C,{marginTop:1,children:x(b,{children:"Helm backend implementation is still in progress \u2014 the preflight above will run, but the final install step may not complete. See CLAUDE.md."})})]})};import{useState as ao}from"react";import{Box as dt}from"ink";import{jsx as ge,jsxs as co}from"react/jsx-runtime";var lo=[{key:"email",label:"email :",placeholder:"you@example.com",validate:e=>e.includes("@")?null:"enter a valid email address (must contain @)"},{key:"password",label:"password :",mask:!0,placeholder:"min 8 characters",validate:e=>e.length>=8?null:"password must be at least 8 characters"}],ut=({initial:e,step:t,total:n,onDone:i})=>{let[o,s]=ao({email:e.email,password:e.password});return ge(S,{step:t,total:n,title:"Create your admin account",hints:["type","\u23CE next","esc back"],children:co(dt,{flexDirection:"column",children:[ge(D,{fields:lo,values:o,onChange:(l,m)=>s(r=>({...r,[l]:m})),onComplete:l=>i({...e,email:l.email,password:l.password})}),ge(dt,{marginTop:1,children:ge(b,{children:"Minimum 8 characters. You can change this later from the admin panel."})})]})})};import{Box as Pe,Text as mt}from"ink";import{jsx as q,jsxs as gt}from"react/jsx-runtime";var pt=[{label:"Local only \u2014 Ollama on this machine",value:"ollama",hint:"Zero API costs, fully offline. Need an Ollama install (https://ollama.com)."},{label:"AWS Bedrock (Claude via IAM)",value:"cloud",hint:"Authenticate with AWS IAM creds \u2014 no raw API keys. Seeds Claude Sonnet 4.6 as the default chat + flows model."},{label:"Google Vertex AI (Gemini via service account)",value:"vertex",hint:"Authenticate with a GCP service account / workload identity \u2014 no API keys. Seeds gemini-2.5-pro chat + text-embedding-005 embeddings + Imagen, all on Vertex."},{label:"Both \u2014 gpt-oss:20b (local) + AWS Bedrock Claude Sonnet 4.6 (default), Ollama embeddings",value:"both",hint:"Richest demo: TWO selectable chat models \u2014 local gpt-oss:20b + frontier Claude Sonnet 4.6 (the default), free Ollama embeddings, all via AWS IAM (no raw keys)."},{label:"Skip for now \u2014 configure later from the admin panel",value:"skip",hint:"Stack will boot, but chat/embedding calls will fail until you wire a provider."}],ht=({step:e,total:t,onPick:n})=>q(S,{step:e,total:t,title:"How should the platform call LLMs?",hints:["\u2191\u2193 / jk move","\u23CE select","esc back","^C quit"],children:gt(Pe,{flexDirection:"column",children:[q(b,{children:"This decides where chat completions and embeddings get made."}),q(b,{children:"Cloud-management creds (Azure / AWS / GCP) are a separate step further down."}),q(Pe,{marginTop:1,children:q(O,{items:pt.map(i=>({label:i.label,value:i.value,hint:i.hint})),onSelect:i=>n(i)})}),q(Pe,{marginTop:1,flexDirection:"column",children:pt.map(i=>gt(mt,{color:a.faint,children:[" ",q(mt,{color:a.muted,bold:!0,children:i.label.split(" \u2014 ")[0]})," \u2014 ",i.hint]},i.value))})]})});import{useState as uo}from"react";import{Box as De,Text as Me}from"ink";import{jsx as Z,jsxs as Ie}from"react/jsx-runtime";var Be="nomic-embed-text",mo=[{key:"host",label:"host: ",placeholder:"http://ollama:11434",validate:e=>e.trim().startsWith("http")?null:"Host must start with http (e.g. http://ollama:11434)"},{key:"embedModel",label:"embed: ",optional:!0,placeholder:Be}],ft=({initial:e,step:t,total:n,onDone:i})=>{let[o,s]=uo({host:e.host,embedModel:e.embedModel});return Z(S,{step:t,total:n,title:"Where is your Ollama?",hints:["type","\u23CE next","esc back","^C quit"],children:Ie(De,{flexDirection:"column",children:[Z(D,{fields:mo,values:o,onChange:(r,c)=>s(d=>({...d,[r]:c})),onComplete:r=>i({...e,host:r.host.trim(),embedModel:r.embedModel.trim()||Be})}),Z(De,{marginTop:1,children:Ie(b,{children:["Default ",Z(Me,{color:a.teal,children:"http://ollama:11434"})," = the bundled container (recommended). Use ",Z(Me,{color:a.teal,children:"http://host.docker.internal:11434"})," to reach Ollama on your host."]})}),Z(De,{children:Ie(b,{children:["Ollama provides embeddings (semantic tool routing). The bundled container pre-pulls the embed model (",Z(Me,{color:a.muted,children:Be}),") on first boot."]})})]})})};import{useState as bt}from"react";import{Box as G}from"ink";import po from"node:fs";import go from"node:os";import ho from"node:path";import{jsx as E,jsxs as he}from"react/jsx-runtime";var fo=go.homedir(),St=e=>{try{return po.existsSync(ho.join(fo,e))}catch{return!1}},bo=()=>St(".aws/credentials")||St(".aws/config"),ce="us-east-1",xt=({initial:e,step:t,total:n,onDone:i})=>{let o=bo(),s=e.awsBedrock,[l,m]=bt("mode"),[r,c]=bt({region:s?.region||ce,accessKeyId:s?.accessKeyId||"",secretAccessKey:s?.secretAccessKey||"",profile:s?.profile||"default"}),d=(f,p)=>c(H=>({...H,[f]:p})),u=(f,p)=>{let V={region:(p.region||"").trim()||ce};f==="host"?V.useHostCreds=!0:f==="inline"?(V.accessKeyId=(p.accessKeyId||"").trim(),V.secretAccessKey=p.secretAccessKey||""):f==="profile"&&(V.profile=(p.profile||"").trim()||"default"),i({awsBedrock:V})},g=f=>f.trim()&&!/^[a-z]{2}-[a-z]+-\d+$/.test(f.trim())?"looks off \u2014 AWS regions are like us-east-1 (left blank uses us-east-1)":null,h=f=>{let p=f.trim();return p?p.startsWith("AKIA")?null:"IAM access key id must start with AKIA":"IAM access key id is required"};if(l==="mode"){let f=[];return o&&f.push({label:"Use my host AWS creds (~/.aws \u2014 mounted read-only)",value:"host",hint:"easy path"}),f.push({label:"Enter IAM access key / secret inline",value:"inline"}),f.push({label:"Use a named AWS profile",value:"profile"}),E(S,{step:t,total:n,title:"AWS Bedrock (Claude via IAM)",hints:["\u2191\u2193/jk move","\u23CE select","esc back"],children:he(G,{flexDirection:"column",children:[E(b,{children:"Cloud LLMs authenticate with AWS IAM \u2014 no raw provider API keys."}),E(b,{children:"Claude Sonnet 4.6 becomes the default chat + flows model."}),o?E(b,{children:"Detected AWS credentials in ~/.aws \u2014 host creds are the easy path."}):E(b,{children:"No ~/.aws found on this machine \u2014 paste IAM keys or name a profile."}),E(G,{marginTop:1,children:E(O,{items:f,onSelect:p=>m(p)})})]})})}return l==="host"?E(S,{step:t,total:n,title:"AWS Bedrock \u2014 region",hints:["type","\u23CE next","esc back"],children:he(G,{flexDirection:"column",children:[E(D,{fields:[{key:"region",label:"AWS region",placeholder:ce,validate:g}],values:r,onChange:d,onComplete:p=>u("host",p)}),E(G,{marginTop:1,children:E(b,{children:"Default us-east-1. Your host ~/.aws creds will be mounted read-only into the api."})})]})}):l==="inline"?E(S,{step:t,total:n,title:"AWS Bedrock \u2014 IAM access key",hints:["type","\u23CE next","esc back"],children:he(G,{flexDirection:"column",children:[E(D,{fields:[{key:"region",label:"AWS region ",placeholder:ce,validate:g},{key:"accessKeyId",label:"AWS access key id ",validate:h},{key:"secretAccessKey",label:"AWS secret access key",mask:!0}],values:r,onChange:d,onComplete:p=>u("inline",p)}),E(G,{marginTop:1,children:E(b,{children:"Inline IAM keys are written to .env as AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY."})})]})}):E(S,{step:t,total:n,title:"AWS Bedrock \u2014 named profile",hints:["type","\u23CE next","esc back"],children:he(G,{flexDirection:"column",children:[E(D,{fields:[{key:"region",label:"AWS region ",placeholder:ce,validate:g},{key:"profile",label:"AWS profile",placeholder:"default"}],values:r,onChange:d,onComplete:f=>u("profile",f)}),E(G,{marginTop:1,children:E(b,{children:"The named profile resolves from your host ~/.aws (mounted read-only into the api)."})})]})})};import{useState as So}from"react";import{Box as Le,Text as xo}from"ink";import Eo from"node:fs";import Ao from"node:os";import we from"node:path";import{jsx as ne,jsxs as yo}from"react/jsx-runtime";var ko=Ao.homedir(),vo=()=>{let e=we.join(ko,".config","gcloud","keys");try{let t=Eo.readdirSync(e).find(n=>n.endsWith(".json"));if(t)return we.join(e,t)}catch{}return""},z={region:"us-central1",chatModel:"gemini-2.5-pro",embedModel:"text-embedding-005",imageModel:"imagen-4.0-generate-001"},Et=({initial:e,step:t,total:n,onDone:i})=>{let o=e.vertex,s=vo(),[l,m]=So({project:o?.project||"",region:o?.region||"",chatModel:o?.chatModel||"",embedModel:o?.embedModel||"",imageModel:o?.imageModel||"",saKeyPath:o?.saKeyPath||""}),r=(h,A)=>m(f=>({...f,[h]:A})),c=h=>{let A=h.trim();return A?/^[a-z][a-z0-9-]*$/.test(A)?null:"project id must be lowercase letters, digits, and dashes":"GCP project id is required"},d=h=>{let A=h.trim();return A?!A.startsWith("~")&&!we.isAbsolute(A)?"path must be absolute or start with ~":null:"service-account key path is required"},u=[{key:"project",label:"GCP project id ",placeholder:"my-gcp-project",validate:c},{key:"region",label:"Region ",placeholder:z.region,optional:!0},{key:"chatModel",label:"Chat model ",placeholder:z.chatModel,optional:!0},{key:"embedModel",label:"Embedding model ",placeholder:z.embedModel,optional:!0},{key:"imageModel",label:"Image model ",placeholder:z.imageModel,optional:!0},{key:"saKeyPath",label:"Service-account key ",placeholder:s||"~/.config/gcloud/keys/sa.json",validate:d}];return ne(S,{step:t,total:n,title:"Google Vertex AI (service account / ADC)",hints:["type","\u23CE next","esc back"],children:yo(Le,{flexDirection:"column",children:[ne(D,{fields:u,values:l,onChange:r,onComplete:h=>i({vertex:{project:(h.project||"").trim(),region:(h.region||"").trim()||z.region,chatModel:(h.chatModel||"").trim()||z.chatModel,embedModel:(h.embedModel||"").trim()||z.embedModel,imageModel:(h.imageModel||"").trim()||z.imageModel,saKeyPath:(h.saKeyPath||"").trim()}})}),ne(Le,{marginTop:1,children:ne(b,{children:"No API keys \u2014 the api calls Vertex with the mounted service-account (ADC). Enter accepts each default."})}),ne(Le,{children:ne(xo,{color:a.faint,children:"Project + key are required; region and model ids fall back to the Vertex defaults."})})]})})};import{useState as Oo}from"react";import{Box as Fe,Text as be}from"ink";import To from"node:fs";import Co from"node:os";import _o from"node:path";var Ro=Co.homedir(),Q=e=>{try{return To.existsSync(_o.join(Ro,e))}catch{return!1}},ee=[{id:"web",label:"Web",blurb:"Search + page fetch (DuckDuckGo, no auth).",disabledEnv:"OpenAgentic_WEB_MCP_DISABLED",needsAuth:!1,authType:"none",defaultOn:!0},{id:"admin",label:"Admin",blurb:"Platform admin helpers \u2014 Postgres/Redis/Milvus/health.",disabledEnv:"OpenAgentic_ADMIN_MCP_DISABLED",needsAuth:!1,authType:"none",defaultOn:!0},{id:"aws",label:"AWS",blurb:"EC2 / S3 / IAM / Cost Explorer \u2014 AWS read-only.",disabledEnv:"OpenAgentic_AWS_MCP_DISABLED",needsAuth:!0,authType:"env-file",envFile:"aws.env",envVars:[{env:"AWS_ACCESS_KEY_ID",label:"AWS access key id"},{env:"AWS_SECRET_ACCESS_KEY",label:"AWS secret access key",mask:!0},{env:"AWS_REGION",label:"AWS default region",hint:"e.g. us-east-1"}],hostCreds:{description:"Use my host AWS CLI creds (~/.aws \u2014 mounted read-only)",detect:()=>Q(".aws/credentials")||Q(".aws/config")},defaultOn:!0},{id:"azure",label:"Azure",blurb:"ARM / Graph / Key Vault / Monitor / Cost \u2014 Azure read-only.",disabledEnv:"OpenAgentic_AZURE_MCP_DISABLED",needsAuth:!0,authType:"env-file",envFile:"azure.env",envVars:[{env:"AZURE_TENANT_ID",label:"Azure tenant id"},{env:"AZURE_CLIENT_ID",label:"Azure client id (App Registration)"},{env:"AZURE_CLIENT_SECRET",label:"Azure client secret",mask:!0},{env:"AZURE_SUBSCRIPTION_ID",label:"Default subscription id"}],hostCreds:{description:"Use my host Azure CLI creds (~/.azure \u2014 mounted read-only)",detect:()=>Q(".azure/azureProfile.json")||Q(".azure/TokenCache")},defaultOn:!0},{id:"gcp",label:"GCP",blurb:"Projects / Compute / Storage / Logging / Monitoring.",disabledEnv:"OpenAgentic_GCP_MCP_DISABLED",needsAuth:!0,authType:"env-file",envFile:"gcp.env",envVars:[{env:"GCP_PROJECT_ID",label:"GCP project id"},{env:"GCP_REGION",label:"Default region",hint:"e.g. us-central1"},{env:"GCP_CREDENTIALS_FILE",label:"Service-account JSON path",hint:"inside the mcp-proxy container"}],hostCreds:{description:"Use my host gcloud creds (~/.config/gcloud \u2014 mounted read-only)",detect:()=>Q(".config/gcloud/application_default_credentials.json")||Q(".config/gcloud/credentials.db")},defaultOn:!0},{id:"kubernetes",label:"Kubernetes",blurb:"Pods / deployments / logs (your local kubeconfig).",disabledEnv:"OpenAgentic_KUBERNETES_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"KUBECONFIG",label:"Path to kubeconfig",hint:"~/.kube/config on most machines"}],hostCreds:{description:"Use my host kubeconfig (~/.kube/config \u2014 mounted read-only)",detect:()=>Q(".kube/config")},defaultOn:!0},{id:"github",label:"GitHub",blurb:"Repos / issues / PRs via a PAT.",disabledEnv:"OpenAgentic_GITHUB_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"GITHUB_TOKEN",label:"GitHub personal access token",mask:!0}],defaultOn:!1},{id:"prometheus",label:"Prometheus",blurb:"Metric queries against a Prometheus server.",disabledEnv:"OpenAgentic_PROMETHEUS_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"PROMETHEUS_URL",label:"Prometheus URL",hint:"https://prom.example.com"},{env:"PROMETHEUS_USERNAME",label:"Basic auth user (optional)"},{env:"PROMETHEUS_PASSWORD",label:"Basic auth pass (optional)",mask:!0}],defaultOn:!1},{id:"loki",label:"Loki",blurb:"Log queries against a Loki instance.",disabledEnv:"OpenAgentic_LOKI_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"LOKI_URL",label:"Loki URL",hint:"https://loki.example.com"},{env:"LOKI_USERNAME",label:"Basic auth user (optional)"},{env:"LOKI_PASSWORD",label:"Basic auth pass (optional)",mask:!0}],defaultOn:!1}];function fe(e){return ee.filter(t=>e.includes(t.id)&&t.needsAuth)}function At(){return ee.filter(e=>e.defaultOn).map(e=>e.id)}function kt(){return ee.map(e=>e.id)}import{jsx as Se,jsxs as de}from"react/jsx-runtime";var vt=ee.map(e=>({label:e.label,value:e.id,hint:e.blurb})),yt=({initial:e,step:t,total:n,onDone:i})=>{let[o,s]=Oo(e);return Se(S,{step:t,total:n,title:"Which MCPs do you want enabled?",hints:["\u2191\u2193 move","\u2423 toggle","a all \xB7 n none","\u23CE continue"],children:de(Fe,{flexDirection:"column",children:[de(Fe,{marginBottom:1,children:[de(be,{color:a.muted,children:["Pick the tool servers to wire into the proxy."," "]}),Se(be,{color:a.faint,children:"You can re-run setup to change this later."})]}),Se(qe,{items:vt,selected:o,onChange:s,onSubmit:i,isActive:!0}),de(Fe,{marginTop:1,children:[Se(be,{color:a.accentDeep,children:"\u25CF "}),de(be,{color:a.muted,children:[o.length," of ",vt.length," selected"]})]})]})})};import{useState as xe,useEffect as Ot}from"react";import{Box as ue,Text as Tt}from"ink";import Po from"node:fs";import Do from"node:os";import We from"node:path";import{jsx as w,jsxs as Rt}from"react/jsx-runtime";var Mo=We.join(Do.homedir(),".openagentic","cloud-secrets"),Io=32,Ct=e=>/^https?:\/\//i.test(e.trim()),_t=e=>{let t=e.trim();return t.startsWith("~")||We.isAbsolute(t)},Bo={AWS_ACCESS_KEY_ID:e=>e.trim().startsWith("AKIA")?null:"access key id must start with AKIA",AWS_SECRET_ACCESS_KEY:e=>e.length>=8?null:"secret access key looks too short",AWS_REGION:e=>(/^[a-z]{2}-[a-z]+-\d$/.test(e.trim()),null),AZURE_CLIENT_SECRET:e=>e.length>=8?null:"client secret looks too short",GCP_PROJECT_ID:e=>/^[a-z][a-z0-9-]*$/.test(e.trim())?null:"project id must be lowercase letters, digits, dashes",GCP_CREDENTIALS_FILE:e=>_t(e)?null:"use an absolute path or one starting with ~",KUBECONFIG:e=>_t(e)?null:"use an absolute path or one starting with ~",GITHUB_TOKEN:e=>e.length>=8?null:"token looks too short",PROMETHEUS_URL:e=>Ct(e)?null:"must start with http:// or https://",LOKI_URL:e=>Ct(e)?null:"must start with http:// or https://"},Lo=new Set(["PROMETHEUS_USERNAME","PROMETHEUS_PASSWORD","LOKI_USERNAME","LOKI_PASSWORD"]),wo=e=>e.map(t=>({key:t.env,label:t.label.padEnd(Io),mask:t.mask,placeholder:t.hint,optional:Lo.has(t.env),validate:Bo[t.env]})),Pt=({enabledIds:e,initialAuth:t,step:n,total:i,onDone:o})=>{let s=fe(e),[l,m]=xe(0),[r,c]=xe({...t}),d=s.length===0;if(Ot(()=>{d&&o(r)},[d]),d)return null;let u=s[l],g=h=>{let A={...r,...h};c(A),l+1<s.length?m(l+1):o(A)};return w(S,{step:n,total:i,title:`${u.label}: credentials (${l+1} of ${s.length})`,hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:w(Fo,{mcp:u,auth:r,onDone:g},u.id)})},Fo=({mcp:e,auth:t,onDone:n})=>{let i=e.envFile?We.join(Mo,e.envFile):void 0,o=!!i&&Po.existsSync(i),s=e.authType==="fields"&&(e.hostCreds?.detect()??!1),[l,m]=xe(e.authType==="env-file"||s?"choose-source":"fields"),[r,c]=xe(e.envVars?Object.fromEntries(e.envVars.map(h=>[h.env,t[h.env]??""])):{}),d=!!e.envVars&&e.envVars.length>0,u=l==="fields"&&!d;if(Ot(()=>{u&&n(r)},[u]),l==="choose-source"){let A=[...e.hostCreds?.detect()??!1?[{label:`${e.hostCreds.description} (detected \u2014 recommended)`,value:"host-creds",hint:"zero paste"}]:[],...e.authType==="env-file"?o?[{label:`Use ${i} (detected)`,value:"use-file",hint:"on disk"}]:[{label:`Create empty ${i} stub`,value:"stub",hint:"fill in later"}]:[],{label:e.authType==="env-file"?"Paste credentials inline now":"Enter credentials inline",value:"paste"},{label:"Skip \u2014 this MCP stays disabled",value:"skip"}];return Rt(ue,{flexDirection:"column",children:[w(Tt,{color:a.muted,children:e.blurb}),w(ue,{marginTop:1,children:w(O,{items:A,onSelect:f=>{f==="host-creds"||f==="use-file"||f==="stub"?n({}):f==="skip"?n({[`__skip_${e.id}`]:"1"}):m("fields")}})})]})}if(!d)return null;let g=wo(e.envVars);return Rt(ue,{flexDirection:"column",children:[w(Tt,{color:a.muted,children:e.blurb}),w(ue,{marginTop:1,children:w(D,{fields:g,values:r,onChange:(h,A)=>c(f=>({...f,[h]:A})),onComplete:h=>n(h)})}),w(ue,{marginTop:1,children:w(b,{children:"type to fill \xB7 \u23CE next field \xB7 leave optional fields blank to skip"})})]})};import{Box as ie,Text as Ne}from"ink";import{jsx as $,jsxs as Ee}from"react/jsx-runtime";var Wo=e=>{switch(e){case"ollama":return"local Ollama only";case"cloud":return"AWS Bedrock (Claude via IAM)";case"vertex":return"Google Vertex AI (Gemini via service account)";case"both":return"Ollama embeddings + AWS Bedrock (Claude) chat";case"skip":return"skipped \u2014 configure in admin panel"}},No=e=>e?e.useHostCreds?`host ~/.aws creds, region ${e.region}`:e.profile?`profile ${e.profile}, region ${e.region}`:e.accessKeyId?`inline IAM key, region ${e.region}`:`region ${e.region}`:"none \u2014 chat will fail until set",Ho=e=>{if(!e||!e.project)return"none \u2014 chat will fail until set";let t=e.saKeyPath?`SA key ${e.saKeyPath}`:"host gcloud ADC";return`${e.project} (${e.region}), ${t}`},Dt=({config:e,step:t,total:n,onLaunch:i,onCancel:o})=>{let l=fe(e.mcps).filter(c=>c.authType==="fields"&&c.envVars?!c.envVars.some(d=>e.mcpAuth[d.env]):!1),m=e.mcps.length===0?"none selected":`${e.mcps.length} enabled (${e.mcps.slice(0,4).join(", ")}${e.mcps.length>4?"\u2026":""})`,r=(c,d,u=a.ink)=>Ee(ie,{children:[$(ie,{width:18,children:$(Ne,{color:a.muted,children:c})}),$(Ne,{color:u,children:d})]},c);return Ee(S,{step:t,total:n,title:"Review & launch",hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:[Ee(ie,{flexDirection:"column",children:[r("deploy target",e.target,a.teal),e.target==="helm"&&e.kubeconfigPath&&r("kubeconfig",e.kubeconfigPath),r("admin email",e.admin.email),r("LLM strategy",Wo(e.llmStrategy),a.signal),(e.llmStrategy==="ollama"||e.llmStrategy==="both")&&r("ollama host",e.ollama.host),(e.llmStrategy==="ollama"||e.llmStrategy==="both")&&r("embedding model",e.ollama.embedModel),(e.llmStrategy==="cloud"||e.llmStrategy==="both")&&r("AWS Bedrock",No(e.providers.awsBedrock)),(e.llmStrategy==="cloud"||e.llmStrategy==="both")&&r("chat model","claude-sonnet-4-6 (default)"),e.llmStrategy==="vertex"&&r("Vertex AI",Ho(e.providers.vertex),e.providers.vertex?.project?a.ink:a.err),e.llmStrategy==="vertex"&&r("chat / embed",`${e.providers.vertex?.chatModel||"gemini-2.5-pro"} \xB7 ${e.providers.vertex?.embedModel||"text-embedding-005"}`),r("MCPs",m),r("UI port",String(e.uiPort)),l.length>0&&$(ie,{marginTop:1,children:Ee(Ne,{color:a.err,children:["\u26A0 missing creds: ",l.map(c=>c.label).join(", ")]})})]}),$(ie,{marginTop:1,children:$(O,{items:[{label:`Launch ${e.target}`,value:"go",hint:"write .env and bring the stack up"},{label:"Cancel",value:"no",hint:"discard and exit"}],onSelect:c=>c==="go"?i():o()})}),$(ie,{marginTop:1,children:$(b,{children:"Nothing has been written to disk yet. Launch will write .env and bring the stack up."})})]})};import{useEffect as $o,useState as jo}from"react";import{Box as Ke,Text as ke}from"ink";import Yo from"open";import me from"node:fs";import Uo from"node:crypto";import{fileURLToPath as Vo}from"node:url";import se from"node:path";var Ko=se.dirname(Vo(import.meta.url)),te=se.resolve(Ko,"..","..","..",".."),Ae=se.join(te,".env"),He=se.join(te,".env.example"),li=se.join(te,"docker-compose.yml"),ci=se.join(te,"helm","openagentic");var Mt="REPLACE_ME_AT_INSTALL_TIME",Go=(e=24)=>Uo.randomBytes(e).toString("base64url");function Ve(){return me.existsSync(Ae)?zo(me.readFileSync(Ae,"utf8")):{}}function It(e){let t=me.existsSync(He)?me.readFileSync(He,"utf8"):"",n=Ve(),i=t.split(`
6
- `).map(l=>{let m=/^(\s*)([A-Z0-9_]+)\s*=(.*)$/.exec(l);if(m){let r=m[2],c=m[3];if(r in e)return`${m[1]}${r}=${e[r]}`;if(c.trim()===Mt)return`${m[1]}${r}=${n[r]&&n[r]!==Mt?n[r]:Go()}`}return l}),o=new Set(t.split(`
4
+ `)}render(){return this.state.error?I(_e,{title:"The setup wizard hit an unexpected error.",detail:this.state.error.message,target:"wizard"}):this.props.children}};import{Box as eo,Text as Qe}from"ink";import{useEffect as Xe,useState as re}from"react";import{Box as J,Text as v,useInput as Re}from"ink";import{jsx as y,jsxs as L}from"react/jsx-runtime";var Qt=()=>{let[e,t]=re(!0);return Xe(()=>{let n=setInterval(()=>t(i=>!i),530);return()=>clearInterval(n)},[]),y(v,{color:a.accent,children:e?"\u258C":" "})},Oe=({value:e,onChange:t,onSubmit:n,isActive:i=!0,mask:o,placeholder:s})=>{Re((m,r)=>{if(r.return){n?.(e);return}if(r.backspace||r.delete){t(e.slice(0,-1));return}r.ctrl||r.meta||r.upArrow||r.downArrow||r.leftArrow||r.rightArrow||r.tab||r.escape||m&&t(e+m)},{isActive:i});let l=o&&e?o.repeat(e.length):e;return L(v,{children:[l?y(v,{color:a.ink,children:l}):s&&!i?y(v,{color:a.faint,children:s}):null,i?y(Qt,{}):null]})},D=({fields:e,values:t,onChange:n,onComplete:i,isActive:o=!0})=>{let[s,l]=re(0),[m,r]=re(null),c=e[s],d=u=>{let g=u.trim(),h=c.validate?c.validate(u):null;if(h){r(h);return}if(!c.optional&&!g){r(`${c.label.trim()} is required`);return}r(null),s+1<e.length?l(s+1):i(t)};return L(J,{flexDirection:"column",children:[e.map((u,g)=>L(J,{children:[L(v,{color:g===s?a.accent:a.muted,children:[g===s?"\u276F ":" ",u.label]}),y(v,{children:" "}),g===s?y(Oe,{value:t[u.key]??"",onChange:h=>n(u.key,h),onSubmit:d,mask:u.mask?"\u2022":void 0,isActive:o}):y(v,{color:a.muted,children:u.mask?t[u.key]?"\u2022".repeat(Math.min(t[u.key].length,24)):"":t[u.key]??""})]},u.key)),m?y(J,{marginTop:1,children:L(v,{color:a.err,children:["\u25CF ",m]})}):null]})};function O({items:e,onSelect:t,isActive:n=!0,initialIndex:i=0}){let[o,s]=re(i);return Re((l,m)=>{m.upArrow||l==="k"?s(r=>(r-1+e.length)%e.length):m.downArrow||l==="j"?s(r=>(r+1)%e.length):m.return&&t(e[o].value)},{isActive:n}),y(J,{flexDirection:"column",children:e.map((l,m)=>{let r=m===o;return L(J,{children:[y(v,{color:r?a.accent:a.faint,children:r?"\u276F ":" "}),y(v,{color:r?a.ink:a.muted,bold:r,children:l.label})]},l.value)})})}var qe=({items:e,selected:t,onChange:n,onSubmit:i,isActive:o=!0})=>{let[s,l]=re(0),m=new Set(t);return Re((r,c)=>{if(c.upArrow||r==="k")l(d=>(d-1+e.length)%e.length);else if(c.downArrow||r==="j")l(d=>(d+1)%e.length);else if(r===" "){let d=e[s].value,u=new Set(m);u.has(d)?u.delete(d):u.add(d),n(e.filter(g=>u.has(g.value)).map(g=>g.value))}else r==="a"?n(e.map(d=>d.value)):r==="n"?n([]):c.return&&i(e.filter(d=>m.has(d.value)).map(d=>d.value))},{isActive:o}),y(J,{flexDirection:"column",children:e.map((r,c)=>{let d=c===s,u=m.has(r.value);return L(J,{children:[y(v,{color:d?a.accent:a.faint,children:d?"\u276F ":" "}),L(v,{color:u?a.ok:a.faint,children:[u?"\u25C9":"\u25CB"," "]}),y(v,{color:d?a.ink:a.muted,bold:d,children:r.label})]},r.value)})})},Je=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Ze=({label:e})=>{let[t,n]=re(0);return Xe(()=>{let i=setInterval(()=>n(o=>(o+1)%Je.length),80);return()=>clearInterval(i)},[]),L(v,{children:[y(v,{color:a.accent,children:Je[t]}),e?L(v,{color:a.muted,children:[" ",e]}):null]})};import{jsx as le,jsxs as et}from"react/jsx-runtime";var tt=({onPick:e})=>et(S,{step:1,total:9,title:"Where do you want to run openagentic?",hints:["\u2191\u2193 / jk move","\u23CE select","esc back","^C quit"],children:[le(O,{items:[{label:"Docker \xB7 local / single machine",value:"docker",hint:"local / single machine"},{label:"Helm \xB7 production / kubernetes",value:"helm",hint:"production / kubernetes"}],onSelect:n=>e(n)}),et(eo,{marginTop:1,children:[le(Qe,{color:a.faint,children:"\xB7 "}),le(b,{children:"Both paths land at "}),le(Qe,{color:a.teal,children:"http://localhost:8080"}),le(b,{children:" with the same UI."})]})]});import{useEffect as io,useState as so}from"react";import{Box as C,Text as _,useInput as ao}from"ink";import{execa as to}from"execa";import{existsSync as ot,statSync as oo}from"node:fs";import{homedir as rt}from"node:os";import{join as nt}from"node:path";var ro=8e3;function no(e){return e.startsWith("~/")||e==="~"?nt(rt(),e.slice(1)):e}function it(){let e=process.env.KUBECONFIG?.trim();if(e)return e;let t=nt(rt(),".kube","config");return ot(t)?t:null}function st(e){let t=no(e.trim());if(!t)return{ok:!1,reason:"path is empty"};if(!ot(t))return{ok:!1,reason:`not found: ${t}`};try{if(!oo(t).isFile())return{ok:!1,reason:`${t} is not a regular file`}}catch{return{ok:!1,reason:`cannot read ${t}`}}return{ok:!0,path:t}}async function X(e,t,n){try{let i=await to(e,t,{timeout:ro,env:n,reject:!1});return{ok:i.exitCode===0,stdout:i.stdout||"",stderr:i.stderr||""}}catch(i){return{ok:!1,stdout:"",stderr:String(i)}}}async function at(e){let t={...process.env,KUBECONFIG:e},n={kubeconfigPath:e,kubectlVersion:null,helmVersion:null,context:null,reachable:!1,serverVersion:null,nodeCount:null,namespaceExists:!1,existingRelease:null},i=await X("kubectl",["version","--client=true","--output=json"],t);if(i.ok)try{let d=JSON.parse(i.stdout);n.kubectlVersion=d?.clientVersion?.gitVersion||null}catch{n.kubectlVersion=null}let o=await X("helm",["version","--template={{.Version}}"],t);if(o.ok&&(n.helmVersion=o.stdout.trim()),!n.kubectlVersion||!n.helmVersion)return n;let s=await X("kubectl",["config","current-context"],t);if(s.ok&&(n.context=s.stdout.trim()),!n.context)return n;let l=await X("kubectl",["version","--output=json"],t);if(l.ok)try{let d=JSON.parse(l.stdout);n.serverVersion=d?.serverVersion?.gitVersion||null,n.reachable=!!n.serverVersion}catch{n.reachable=!1}if(!n.reachable)return n;let m=await X("kubectl",["get","nodes","-o","name"],t);m.ok&&(n.nodeCount=m.stdout.split(`
5
+ `).filter(Boolean).length);let r=await X("kubectl",["get","namespace","openagentic","-o","name"],t);n.namespaceExists=r.ok&&r.stdout.trim().length>0;let c=await X("helm",["list","-n","openagentic","-o","json"],t);if(c.ok)try{let d=JSON.parse(c.stdout);if(Array.isArray(d)&&d.length>0){let u=d.find(g=>g.name==="openagentic")??d[0];u&&(n.existingRelease={name:u.name,revision:Number(u.revision)||0,status:u.status||"unknown"})}}catch{}return n}import{jsx as x,jsxs as M}from"react/jsx-runtime";var lt=e=>{let t=e.trim();return!t||t.startsWith("~/")||t==="~"||t.startsWith("/")?null:"enter a leading-tilde (~/\u2026) or absolute (/\u2026) path"},ct=({onContinue:e,onBackToDocker:t})=>{let n=it(),[i,o]=so(n?{stage:"probing",kubeconfigPath:n}:{stage:"picking-kubeconfig",input:"",error:null});if(io(()=>{if(i.stage!=="probing")return;let c=!1;return at(i.kubeconfigPath).then(d=>{c||o({stage:"ready",probe:d})}),()=>{c=!0}},[i.stage==="probing"?i.kubeconfigPath:null]),ao((c,d)=>{i.stage==="picking-kubeconfig"&&d.escape&&t()}),i.stage==="picking-kubeconfig"){let c=lt(i.input);return M(S,{step:2,total:10,title:"Checking your cluster",hints:["type path","\u23CE probe","esc back to Docker","^C quit"],children:[M(C,{flexDirection:"column",marginBottom:1,children:[M(_,{children:["No kubeconfig found at ",x(_,{color:a.accent,children:"$KUBECONFIG"})," or ",x(_,{color:a.accent,children:"~/.kube/config"}),"."]}),M(_,{children:["Paste a path to your kubeconfig, or press ",x(_,{color:a.accent,children:"Esc"})," to go back to Docker."]})]}),M(C,{children:[x(_,{color:a.accent,children:"\u276F "}),x(_,{color:a.muted,children:"kubeconfig "}),x(Oe,{value:i.input,placeholder:"~/.kube/config",onChange:d=>o({...i,input:d,error:null}),onSubmit:d=>{let u=lt(d);if(u){o({...i,error:u});return}let g=st(d);if(!g.ok){o({...i,error:g.reason});return}o({stage:"probing",kubeconfigPath:g.path})}})]}),(i.error??c)&&x(C,{marginTop:1,children:M(_,{color:a.err,children:["\u25CF ",i.error??c]})})]})}if(i.stage==="probing")return x(S,{step:2,total:10,title:"Checking your cluster",footer:!1,children:x(Ze,{label:`probing cluster via ${i.kubeconfigPath}\u2026`})});let{probe:s}=i,l=[{label:"kubeconfig",value:s.kubeconfigPath},{label:"kubectl",value:s.kubectlVersion??"not found on PATH",colour:s.kubectlVersion?void 0:a.err},{label:"helm",value:s.helmVersion??"not found on PATH",colour:s.helmVersion?void 0:a.err},{label:"context",value:s.context??"no current context set",colour:s.context?void 0:a.err},{label:"cluster",value:s.reachable?`${s.serverVersion??"unknown"} (${s.nodeCount??"?"} nodes)`:"unreachable",colour:s.reachable?a.ok:a.err},{label:"namespace",value:s.namespaceExists?"openagentic \u2014 exists":"openagentic \u2014 does not exist",colour:s.namespaceExists?a.warn:void 0},{label:"existing release",value:s.existingRelease?`${s.existingRelease.name} rev ${s.existingRelease.revision} (${s.existingRelease.status})`:"none",colour:s.existingRelease?a.warn:void 0}],m=s.kubectlVersion?s.helmVersion?s.context?s.reachable?null:"cluster is unreachable. Check VPN / kubeconfig / network.":"no current kubectl context is set. Run: kubectl config use-context <name>":"helm is not installed or not on PATH.":"kubectl is not installed or not on PATH.";if(m)return M(S,{step:2,total:10,title:"Checking your cluster",hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:[x(C,{flexDirection:"column",children:l.map(c=>M(C,{children:[x(C,{width:18,children:x(_,{color:a.muted,children:c.label})}),x(_,{color:c.colour,children:c.value})]},c.label))}),x(C,{marginTop:1,children:M(_,{color:a.err,children:["\u25CF ",m]})}),x(C,{marginTop:1,children:x(O,{items:[{label:"Back to Docker deploy",value:"docker"},{label:"Quit",value:"quit"}],onSelect:c=>{c==="docker"?t():process.exit(0)}})})]});let r=s.existingRelease?`Existing release 'openagentic' (rev ${s.existingRelease.revision}). Continuing will run helm upgrade.`:s.namespaceExists?"Namespace 'openagentic' exists but no Helm release. Continuing will adopt it.":null;return M(S,{step:2,total:10,title:"Checking your cluster",hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:[x(C,{flexDirection:"column",children:l.map(c=>M(C,{children:[x(C,{width:18,children:x(_,{color:a.muted,children:c.label})}),x(_,{color:c.colour,children:c.value})]},c.label))}),r&&x(C,{marginTop:1,children:M(_,{color:a.warn,children:["\u26A0 ",r]})}),x(C,{marginTop:1,children:x(O,{items:[{label:s.existingRelease?"Upgrade existing release":"Continue",value:"continue"},{label:"Back to Docker deploy",value:"docker"}],onSelect:c=>{c==="continue"?e(s.kubeconfigPath):t()}})}),x(C,{marginTop:1,children:x(b,{children:"Helm backend implementation is still in progress \u2014 the preflight above will run, but the final install step may not complete. See CLAUDE.md."})})]})};import{useState as lo}from"react";import{Box as dt}from"ink";import{jsx as ge,jsxs as uo}from"react/jsx-runtime";var co=[{key:"email",label:"email :",placeholder:"you@example.com",validate:e=>e.includes("@")?null:"enter a valid email address (must contain @)"},{key:"password",label:"password :",mask:!0,placeholder:"min 8 characters",validate:e=>e.length>=8?null:"password must be at least 8 characters"}],ut=({initial:e,step:t,total:n,onDone:i})=>{let[o,s]=lo({email:e.email,password:e.password});return ge(S,{step:t,total:n,title:"Create your admin account",hints:["type","\u23CE next","esc back"],children:uo(dt,{flexDirection:"column",children:[ge(D,{fields:co,values:o,onChange:(l,m)=>s(r=>({...r,[l]:m})),onComplete:l=>i({...e,email:l.email,password:l.password})}),ge(dt,{marginTop:1,children:ge(b,{children:"Minimum 8 characters. You can change this later from the admin panel."})})]})})};import{Box as Pe,Text as mt}from"ink";import{jsx as q,jsxs as gt}from"react/jsx-runtime";var pt=[{label:"Local only \u2014 Ollama on this machine",value:"ollama",hint:"Zero API costs, fully offline. Need an Ollama install (https://ollama.com)."},{label:"AWS Bedrock (Claude via IAM)",value:"cloud",hint:"Authenticate with AWS IAM creds \u2014 no raw API keys. Seeds Claude Sonnet 4.6 as the default chat + flows model."},{label:"Google Vertex AI (Gemini via service account)",value:"vertex",hint:"Authenticate with a GCP service account / workload identity \u2014 no API keys. Seeds gemini-2.5-pro chat + text-embedding-005 embeddings + Imagen, all on Vertex."},{label:"Both \u2014 gpt-oss:20b (local) + AWS Bedrock Claude Sonnet 4.6 (default), Ollama embeddings",value:"both",hint:"Richest demo: TWO selectable chat models \u2014 local gpt-oss:20b + frontier Claude Sonnet 4.6 (the default), free Ollama embeddings, all via AWS IAM (no raw keys)."},{label:"Skip for now \u2014 configure later from the admin panel",value:"skip",hint:"Stack will boot, but chat/embedding calls will fail until you wire a provider."}],ht=({step:e,total:t,onPick:n})=>q(S,{step:e,total:t,title:"How should the platform call LLMs?",hints:["\u2191\u2193 / jk move","\u23CE select","esc back","^C quit"],children:gt(Pe,{flexDirection:"column",children:[q(b,{children:"This decides where chat completions and embeddings get made."}),q(b,{children:"Cloud-management creds (Azure / AWS / GCP) are a separate step further down."}),q(Pe,{marginTop:1,children:q(O,{items:pt.map(i=>({label:i.label,value:i.value,hint:i.hint})),onSelect:i=>n(i)})}),q(Pe,{marginTop:1,flexDirection:"column",children:pt.map(i=>gt(mt,{color:a.faint,children:[" ",q(mt,{color:a.muted,bold:!0,children:i.label.split(" \u2014 ")[0]})," \u2014 ",i.hint]},i.value))})]})});import{useState as mo}from"react";import{Box as De,Text as Me}from"ink";import{jsx as Z,jsxs as Ie}from"react/jsx-runtime";var Be="nomic-embed-text",po=[{key:"host",label:"host: ",placeholder:"http://ollama:11434",validate:e=>e.trim().startsWith("http")?null:"Host must start with http (e.g. http://ollama:11434)"},{key:"embedModel",label:"embed: ",optional:!0,placeholder:Be}],ft=({initial:e,step:t,total:n,onDone:i})=>{let[o,s]=mo({host:e.host,embedModel:e.embedModel});return Z(S,{step:t,total:n,title:"Where is your Ollama?",hints:["type","\u23CE next","esc back","^C quit"],children:Ie(De,{flexDirection:"column",children:[Z(D,{fields:po,values:o,onChange:(r,c)=>s(d=>({...d,[r]:c})),onComplete:r=>i({...e,host:r.host.trim(),embedModel:r.embedModel.trim()||Be})}),Z(De,{marginTop:1,children:Ie(b,{children:["Default ",Z(Me,{color:a.teal,children:"http://ollama:11434"})," = the bundled container (recommended). Use ",Z(Me,{color:a.teal,children:"http://host.docker.internal:11434"})," to reach Ollama on your host."]})}),Z(De,{children:Ie(b,{children:["Ollama provides embeddings (semantic tool routing). The bundled container pre-pulls the embed model (",Z(Me,{color:a.muted,children:Be}),") on first boot."]})})]})})};import{useState as bt}from"react";import{Box as G}from"ink";import go from"node:fs";import ho from"node:os";import fo from"node:path";import{jsx as E,jsxs as he}from"react/jsx-runtime";var bo=ho.homedir(),St=e=>{try{return go.existsSync(fo.join(bo,e))}catch{return!1}},So=()=>St(".aws/credentials")||St(".aws/config"),ce="us-east-1",xt=({initial:e,step:t,total:n,onDone:i})=>{let o=So(),s=e.awsBedrock,[l,m]=bt("mode"),[r,c]=bt({region:s?.region||ce,accessKeyId:s?.accessKeyId||"",secretAccessKey:s?.secretAccessKey||"",profile:s?.profile||"default"}),d=(f,p)=>c(H=>({...H,[f]:p})),u=(f,p)=>{let V={region:(p.region||"").trim()||ce};f==="host"?V.useHostCreds=!0:f==="inline"?(V.accessKeyId=(p.accessKeyId||"").trim(),V.secretAccessKey=p.secretAccessKey||""):f==="profile"&&(V.profile=(p.profile||"").trim()||"default"),i({awsBedrock:V})},g=f=>f.trim()&&!/^[a-z]{2}-[a-z]+-\d+$/.test(f.trim())?"looks off \u2014 AWS regions are like us-east-1 (left blank uses us-east-1)":null,h=f=>{let p=f.trim();return p?p.startsWith("AKIA")?null:"IAM access key id must start with AKIA":"IAM access key id is required"};if(l==="mode"){let f=[];return o&&f.push({label:"Use my host AWS creds (~/.aws \u2014 mounted read-only)",value:"host",hint:"easy path"}),f.push({label:"Enter IAM access key / secret inline",value:"inline"}),f.push({label:"Use a named AWS profile",value:"profile"}),E(S,{step:t,total:n,title:"AWS Bedrock (Claude via IAM)",hints:["\u2191\u2193/jk move","\u23CE select","esc back"],children:he(G,{flexDirection:"column",children:[E(b,{children:"Cloud LLMs authenticate with AWS IAM \u2014 no raw provider API keys."}),E(b,{children:"Claude Sonnet 4.6 becomes the default chat + flows model."}),o?E(b,{children:"Detected AWS credentials in ~/.aws \u2014 host creds are the easy path."}):E(b,{children:"No ~/.aws found on this machine \u2014 paste IAM keys or name a profile."}),E(G,{marginTop:1,children:E(O,{items:f,onSelect:p=>m(p)})})]})})}return l==="host"?E(S,{step:t,total:n,title:"AWS Bedrock \u2014 region",hints:["type","\u23CE next","esc back"],children:he(G,{flexDirection:"column",children:[E(D,{fields:[{key:"region",label:"AWS region",placeholder:ce,validate:g}],values:r,onChange:d,onComplete:p=>u("host",p)}),E(G,{marginTop:1,children:E(b,{children:"Default us-east-1. Your host ~/.aws creds will be mounted read-only into the api."})})]})}):l==="inline"?E(S,{step:t,total:n,title:"AWS Bedrock \u2014 IAM access key",hints:["type","\u23CE next","esc back"],children:he(G,{flexDirection:"column",children:[E(D,{fields:[{key:"region",label:"AWS region ",placeholder:ce,validate:g},{key:"accessKeyId",label:"AWS access key id ",validate:h},{key:"secretAccessKey",label:"AWS secret access key",mask:!0}],values:r,onChange:d,onComplete:p=>u("inline",p)}),E(G,{marginTop:1,children:E(b,{children:"Inline IAM keys are written to .env as AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY."})})]})}):E(S,{step:t,total:n,title:"AWS Bedrock \u2014 named profile",hints:["type","\u23CE next","esc back"],children:he(G,{flexDirection:"column",children:[E(D,{fields:[{key:"region",label:"AWS region ",placeholder:ce,validate:g},{key:"profile",label:"AWS profile",placeholder:"default"}],values:r,onChange:d,onComplete:f=>u("profile",f)}),E(G,{marginTop:1,children:E(b,{children:"The named profile resolves from your host ~/.aws (mounted read-only into the api)."})})]})})};import{useState as xo}from"react";import{Box as Le,Text as Eo}from"ink";import Ao from"node:fs";import ko from"node:os";import we from"node:path";import{jsx as ne,jsxs as To}from"react/jsx-runtime";var vo=ko.homedir(),yo=()=>{let e=we.join(vo,".config","gcloud","keys");try{let t=Ao.readdirSync(e).find(n=>n.endsWith(".json"));if(t)return we.join(e,t)}catch{}return""},z={region:"us-central1",chatModel:"gemini-2.5-pro",embedModel:"text-embedding-005",imageModel:"imagen-4.0-generate-001"},Et=({initial:e,step:t,total:n,onDone:i})=>{let o=e.vertex,s=yo(),[l,m]=xo({project:o?.project||"",region:o?.region||"",chatModel:o?.chatModel||"",embedModel:o?.embedModel||"",imageModel:o?.imageModel||"",saKeyPath:o?.saKeyPath||""}),r=(h,A)=>m(f=>({...f,[h]:A})),c=h=>{let A=h.trim();return A?/^[a-z][a-z0-9-]*$/.test(A)?null:"project id must be lowercase letters, digits, and dashes":"GCP project id is required"},d=h=>{let A=h.trim();return A?!A.startsWith("~")&&!we.isAbsolute(A)?"path must be absolute or start with ~":null:"service-account key path is required"},u=[{key:"project",label:"GCP project id ",placeholder:"my-gcp-project",validate:c},{key:"region",label:"Region ",placeholder:z.region,optional:!0},{key:"chatModel",label:"Chat model ",placeholder:z.chatModel,optional:!0},{key:"embedModel",label:"Embedding model ",placeholder:z.embedModel,optional:!0},{key:"imageModel",label:"Image model ",placeholder:z.imageModel,optional:!0},{key:"saKeyPath",label:"Service-account key ",placeholder:s||"~/.config/gcloud/keys/sa.json",validate:d}];return ne(S,{step:t,total:n,title:"Google Vertex AI (service account / ADC)",hints:["type","\u23CE next","esc back"],children:To(Le,{flexDirection:"column",children:[ne(D,{fields:u,values:l,onChange:r,onComplete:h=>i({vertex:{project:(h.project||"").trim(),region:(h.region||"").trim()||z.region,chatModel:(h.chatModel||"").trim()||z.chatModel,embedModel:(h.embedModel||"").trim()||z.embedModel,imageModel:(h.imageModel||"").trim()||z.imageModel,saKeyPath:(h.saKeyPath||"").trim()}})}),ne(Le,{marginTop:1,children:ne(b,{children:"No API keys \u2014 the api calls Vertex with the mounted service-account (ADC). Enter accepts each default."})}),ne(Le,{children:ne(Eo,{color:a.faint,children:"Project + key are required; region and model ids fall back to the Vertex defaults."})})]})})};import{useState as Po}from"react";import{Box as Fe,Text as be}from"ink";import Co from"node:fs";import _o from"node:os";import Ro from"node:path";var Oo=_o.homedir(),Q=e=>{try{return Co.existsSync(Ro.join(Oo,e))}catch{return!1}},ee=[{id:"web",label:"Web",blurb:"Search + page fetch (DuckDuckGo, no auth).",disabledEnv:"OpenAgentic_WEB_MCP_DISABLED",needsAuth:!1,authType:"none",defaultOn:!0},{id:"admin",label:"Admin",blurb:"Platform admin helpers \u2014 Postgres/Redis/Milvus/health.",disabledEnv:"OpenAgentic_ADMIN_MCP_DISABLED",needsAuth:!1,authType:"none",defaultOn:!0},{id:"aws",label:"AWS",blurb:"EC2 / S3 / IAM / Cost Explorer \u2014 AWS read-only.",disabledEnv:"OpenAgentic_AWS_MCP_DISABLED",needsAuth:!0,authType:"env-file",envFile:"aws.env",envVars:[{env:"AWS_ACCESS_KEY_ID",label:"AWS access key id"},{env:"AWS_SECRET_ACCESS_KEY",label:"AWS secret access key",mask:!0},{env:"AWS_REGION",label:"AWS default region",hint:"e.g. us-east-1"}],hostCreds:{description:"Use my host AWS CLI creds (~/.aws \u2014 mounted read-only)",detect:()=>Q(".aws/credentials")||Q(".aws/config")},defaultOn:!0},{id:"azure",label:"Azure",blurb:"ARM / Graph / Key Vault / Monitor / Cost \u2014 Azure read-only.",disabledEnv:"OpenAgentic_AZURE_MCP_DISABLED",needsAuth:!0,authType:"env-file",envFile:"azure.env",envVars:[{env:"AZURE_TENANT_ID",label:"Azure tenant id"},{env:"AZURE_CLIENT_ID",label:"Azure client id (App Registration)"},{env:"AZURE_CLIENT_SECRET",label:"Azure client secret",mask:!0},{env:"AZURE_SUBSCRIPTION_ID",label:"Default subscription id"}],hostCreds:{description:"Use my host Azure CLI creds (~/.azure \u2014 mounted read-only)",detect:()=>Q(".azure/azureProfile.json")||Q(".azure/TokenCache")},defaultOn:!0},{id:"gcp",label:"GCP",blurb:"Projects / Compute / Storage / Logging / Monitoring.",disabledEnv:"OpenAgentic_GCP_MCP_DISABLED",needsAuth:!0,authType:"env-file",envFile:"gcp.env",envVars:[{env:"GCP_PROJECT_ID",label:"GCP project id"},{env:"GCP_REGION",label:"Default region",hint:"e.g. us-central1"},{env:"GCP_CREDENTIALS_FILE",label:"Service-account JSON path",hint:"inside the mcp-proxy container"}],hostCreds:{description:"Use my host gcloud creds (~/.config/gcloud \u2014 mounted read-only)",detect:()=>Q(".config/gcloud/application_default_credentials.json")||Q(".config/gcloud/credentials.db")},defaultOn:!0},{id:"kubernetes",label:"Kubernetes",blurb:"Pods / deployments / logs (your local kubeconfig).",disabledEnv:"OpenAgentic_KUBERNETES_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"KUBECONFIG",label:"Path to kubeconfig",hint:"~/.kube/config on most machines"}],hostCreds:{description:"Use my host kubeconfig (~/.kube/config \u2014 mounted read-only)",detect:()=>Q(".kube/config")},defaultOn:!0},{id:"github",label:"GitHub",blurb:"Repos / issues / PRs via a PAT.",disabledEnv:"OpenAgentic_GITHUB_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"GITHUB_TOKEN",label:"GitHub personal access token",mask:!0}],defaultOn:!1},{id:"prometheus",label:"Prometheus",blurb:"Metric queries against a Prometheus server.",disabledEnv:"OpenAgentic_PROMETHEUS_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"PROMETHEUS_URL",label:"Prometheus URL",hint:"https://prom.example.com"},{env:"PROMETHEUS_USERNAME",label:"Basic auth user (optional)"},{env:"PROMETHEUS_PASSWORD",label:"Basic auth pass (optional)",mask:!0}],defaultOn:!1},{id:"loki",label:"Loki",blurb:"Log queries against a Loki instance.",disabledEnv:"OpenAgentic_LOKI_MCP_DISABLED",needsAuth:!0,authType:"fields",envVars:[{env:"LOKI_URL",label:"Loki URL",hint:"https://loki.example.com"},{env:"LOKI_USERNAME",label:"Basic auth user (optional)"},{env:"LOKI_PASSWORD",label:"Basic auth pass (optional)",mask:!0}],defaultOn:!1}];function fe(e){return ee.filter(t=>e.includes(t.id)&&t.needsAuth)}function At(){return ee.filter(e=>e.defaultOn).map(e=>e.id)}function kt(){return ee.map(e=>e.id)}import{jsx as Se,jsxs as de}from"react/jsx-runtime";var vt=ee.map(e=>({label:e.label,value:e.id,hint:e.blurb})),yt=({initial:e,step:t,total:n,onDone:i})=>{let[o,s]=Po(e);return Se(S,{step:t,total:n,title:"Which MCPs do you want enabled?",hints:["\u2191\u2193 move","\u2423 toggle","a all \xB7 n none","\u23CE continue"],children:de(Fe,{flexDirection:"column",children:[de(Fe,{marginBottom:1,children:[de(be,{color:a.muted,children:["Pick the tool servers to wire into the proxy."," "]}),Se(be,{color:a.faint,children:"You can re-run setup to change this later."})]}),Se(qe,{items:vt,selected:o,onChange:s,onSubmit:i,isActive:!0}),de(Fe,{marginTop:1,children:[Se(be,{color:a.accentDeep,children:"\u25CF "}),de(be,{color:a.muted,children:[o.length," of ",vt.length," selected"]})]})]})})};import{useState as xe,useEffect as Ot}from"react";import{Box as ue,Text as Tt}from"ink";import Do from"node:fs";import Mo from"node:os";import We from"node:path";import{jsx as w,jsxs as Rt}from"react/jsx-runtime";var Io=We.join(Mo.homedir(),".openagentic","cloud-secrets"),Bo=32,Ct=e=>/^https?:\/\//i.test(e.trim()),_t=e=>{let t=e.trim();return t.startsWith("~")||We.isAbsolute(t)},Lo={AWS_ACCESS_KEY_ID:e=>e.trim().startsWith("AKIA")?null:"access key id must start with AKIA",AWS_SECRET_ACCESS_KEY:e=>e.length>=8?null:"secret access key looks too short",AWS_REGION:e=>(/^[a-z]{2}-[a-z]+-\d$/.test(e.trim()),null),AZURE_CLIENT_SECRET:e=>e.length>=8?null:"client secret looks too short",GCP_PROJECT_ID:e=>/^[a-z][a-z0-9-]*$/.test(e.trim())?null:"project id must be lowercase letters, digits, dashes",GCP_CREDENTIALS_FILE:e=>_t(e)?null:"use an absolute path or one starting with ~",KUBECONFIG:e=>_t(e)?null:"use an absolute path or one starting with ~",GITHUB_TOKEN:e=>e.length>=8?null:"token looks too short",PROMETHEUS_URL:e=>Ct(e)?null:"must start with http:// or https://",LOKI_URL:e=>Ct(e)?null:"must start with http:// or https://"},wo=new Set(["PROMETHEUS_USERNAME","PROMETHEUS_PASSWORD","LOKI_USERNAME","LOKI_PASSWORD"]),Fo=e=>e.map(t=>({key:t.env,label:t.label.padEnd(Bo),mask:t.mask,placeholder:t.hint,optional:wo.has(t.env),validate:Lo[t.env]})),Pt=({enabledIds:e,initialAuth:t,step:n,total:i,onDone:o})=>{let s=fe(e),[l,m]=xe(0),[r,c]=xe({...t}),d=s.length===0;if(Ot(()=>{d&&o(r)},[d]),d)return null;let u=s[l],g=h=>{let A={...r,...h};c(A),l+1<s.length?m(l+1):o(A)};return w(S,{step:n,total:i,title:`${u.label}: credentials (${l+1} of ${s.length})`,hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:w(Wo,{mcp:u,auth:r,onDone:g},u.id)})},Wo=({mcp:e,auth:t,onDone:n})=>{let i=e.envFile?We.join(Io,e.envFile):void 0,o=!!i&&Do.existsSync(i),s=e.authType==="fields"&&(e.hostCreds?.detect()??!1),[l,m]=xe(e.authType==="env-file"||s?"choose-source":"fields"),[r,c]=xe(e.envVars?Object.fromEntries(e.envVars.map(h=>[h.env,t[h.env]??""])):{}),d=!!e.envVars&&e.envVars.length>0,u=l==="fields"&&!d;if(Ot(()=>{u&&n(r)},[u]),l==="choose-source"){let A=[...e.hostCreds?.detect()??!1?[{label:`${e.hostCreds.description} (detected \u2014 recommended)`,value:"host-creds",hint:"zero paste"}]:[],...e.authType==="env-file"?o?[{label:`Use ${i} (detected)`,value:"use-file",hint:"on disk"}]:[{label:`Create empty ${i} stub`,value:"stub",hint:"fill in later"}]:[],{label:e.authType==="env-file"?"Paste credentials inline now":"Enter credentials inline",value:"paste"},{label:"Skip \u2014 this MCP stays disabled",value:"skip"}];return Rt(ue,{flexDirection:"column",children:[w(Tt,{color:a.muted,children:e.blurb}),w(ue,{marginTop:1,children:w(O,{items:A,onSelect:f=>{f==="host-creds"||f==="use-file"||f==="stub"?n({}):f==="skip"?n({[`__skip_${e.id}`]:"1"}):m("fields")}})})]})}if(!d)return null;let g=Fo(e.envVars);return Rt(ue,{flexDirection:"column",children:[w(Tt,{color:a.muted,children:e.blurb}),w(ue,{marginTop:1,children:w(D,{fields:g,values:r,onChange:(h,A)=>c(f=>({...f,[h]:A})),onComplete:h=>n(h)})}),w(ue,{marginTop:1,children:w(b,{children:"type to fill \xB7 \u23CE next field \xB7 leave optional fields blank to skip"})})]})};import{Box as ie,Text as Ne}from"ink";import{jsx as $,jsxs as Ee}from"react/jsx-runtime";var No=e=>{switch(e){case"ollama":return"local Ollama only";case"cloud":return"AWS Bedrock (Claude via IAM)";case"vertex":return"Google Vertex AI (Gemini via service account)";case"both":return"Ollama embeddings + AWS Bedrock (Claude) chat";case"skip":return"skipped \u2014 configure in admin panel"}},Ho=e=>e?e.useHostCreds?`host ~/.aws creds, region ${e.region}`:e.profile?`profile ${e.profile}, region ${e.region}`:e.accessKeyId?`inline IAM key, region ${e.region}`:`region ${e.region}`:"none \u2014 chat will fail until set",Vo=e=>{if(!e||!e.project)return"none \u2014 chat will fail until set";let t=e.saKeyPath?`SA key ${e.saKeyPath}`:"host gcloud ADC";return`${e.project} (${e.region}), ${t}`},Dt=({config:e,step:t,total:n,onLaunch:i,onCancel:o})=>{let l=fe(e.mcps).filter(c=>c.authType==="fields"&&c.envVars?!c.envVars.some(d=>e.mcpAuth[d.env]):!1),m=e.mcps.length===0?"none selected":`${e.mcps.length} enabled (${e.mcps.slice(0,4).join(", ")}${e.mcps.length>4?"\u2026":""})`,r=(c,d,u=a.ink)=>Ee(ie,{children:[$(ie,{width:18,children:$(Ne,{color:a.muted,children:c})}),$(Ne,{color:u,children:d})]},c);return Ee(S,{step:t,total:n,title:"Review & launch",hints:["\u2191\u2193 move","\u23CE select","esc back","^C quit"],children:[Ee(ie,{flexDirection:"column",children:[r("deploy target",e.target,a.teal),e.target==="helm"&&e.kubeconfigPath&&r("kubeconfig",e.kubeconfigPath),r("admin email",e.admin.email),r("LLM strategy",No(e.llmStrategy),a.signal),(e.llmStrategy==="ollama"||e.llmStrategy==="both")&&r("ollama host",e.ollama.host),(e.llmStrategy==="ollama"||e.llmStrategy==="both")&&r("embedding model",e.ollama.embedModel),(e.llmStrategy==="cloud"||e.llmStrategy==="both")&&r("AWS Bedrock",Ho(e.providers.awsBedrock)),(e.llmStrategy==="cloud"||e.llmStrategy==="both")&&r("chat model","claude-sonnet-4-6 (default)"),e.llmStrategy==="vertex"&&r("Vertex AI",Vo(e.providers.vertex),e.providers.vertex?.project?a.ink:a.err),e.llmStrategy==="vertex"&&r("chat / embed",`${e.providers.vertex?.chatModel||"gemini-2.5-pro"} \xB7 ${e.providers.vertex?.embedModel||"text-embedding-005"}`),r("MCPs",m),r("UI port",String(e.uiPort)),l.length>0&&$(ie,{marginTop:1,children:Ee(Ne,{color:a.err,children:["\u26A0 missing creds: ",l.map(c=>c.label).join(", ")]})})]}),$(ie,{marginTop:1,children:$(O,{items:[{label:`Launch ${e.target}`,value:"go",hint:"write .env and bring the stack up"},{label:"Cancel",value:"no",hint:"discard and exit"}],onSelect:c=>c==="go"?i():o()})}),$(ie,{marginTop:1,children:$(b,{children:"Nothing has been written to disk yet. Launch will write .env and bring the stack up."})})]})};import{useEffect as jo,useState as Yo}from"react";import{Box as Ke,Text as ke}from"ink";import Jo from"open";import me from"node:fs";import Go from"node:crypto";import{fileURLToPath as Ko}from"node:url";import se from"node:path";var Uo=se.dirname(Ko(import.meta.url)),te=se.resolve(Uo,"..","..","..",".."),Ae=se.join(te,".env"),He=se.join(te,".env.example"),di=se.join(te,"docker-compose.yml"),ui=se.join(te,"helm","openagentic");var Mt="REPLACE_ME_AT_INSTALL_TIME",zo=(e=24)=>Go.randomBytes(e).toString("base64url");function Ve(){return me.existsSync(Ae)?$o(me.readFileSync(Ae,"utf8")):{}}function It(e){let t=me.existsSync(He)?me.readFileSync(He,"utf8"):"",n=Ve(),i=t.split(`
6
+ `).map(l=>{let m=/^(\s*)([A-Z0-9_]+)\s*=(.*)$/.exec(l);if(m){let r=m[2],c=m[3];if(r in e)return`${m[1]}${r}=${e[r]}`;if(c.trim()===Mt)return`${m[1]}${r}=${n[r]&&n[r]!==Mt?n[r]:zo()}`}return l}),o=new Set(t.split(`
7
7
  `).flatMap(l=>{let m=/^\s*([A-Z0-9_]+)\s*=/.exec(l);return m?[m[1]]:[]})),s=Object.entries(e).filter(([l])=>!o.has(l));if(s.length>0){i.push("","# \u2500\u2500\u2500 Added by setup wizard \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");for(let[l,m]of s)i.push(`${l}=${m}`)}me.writeFileSync(Ae,i.join(`
8
- `),"utf8")}function zo(e){let t={};for(let n of e.split(`
9
- `)){let i=/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/.exec(n);if(!i)continue;let o=i[2];(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),t[i[1]]=o}return t}import{execa as Bt}from"execa";async function Lt(e,t){t.onBuild?.("docker compose --profile milvus build (first run may take several minutes)"),await Bt("docker",["compose","--profile","milvus","build"],{cwd:te}),t.onBuildDone?.(),t.onStart?.("docker compose --profile milvus up -d"),await Bt("docker",["compose","--profile","milvus","up","-d"],{cwd:te}),t.onStartDone?.();let n=`http://localhost:${e.uiPort}`;t.onHealth?.(`waiting for ${n}/api/health`);let i=Date.now();for(;Date.now()-i<10*6e4;){try{if((await fetch(`${n}/api/health`)).ok)return t.onHealthDone?.(),n}catch{}await new Promise(o=>setTimeout(o,3e3))}throw new Error("API did not become healthy within 10 minutes. Run 'docker compose logs api' to investigate.")}async function wt(e,t){throw new Error("Helm deploy is not wired up yet \u2014 the chart at helm/openagentic needs a cleanup pass before the wizard can drive it. Use the Docker path for now.")}import{jsx as oe,jsxs as Ue}from"react/jsx-runtime";var ve=process.env.WIZARD_DRY_RUN==="1",Jo="anthropic.claude-sonnet-4-6",Xo="nomic-embed-text",qo=768,Zo="gpt-oss:20b",Ft="6",Qo="gemini-2.5-pro",er="text-embedding-005",Wt=768,tr="imagen-4.0-generate-001",or="/var/secrets/gcp/key.json",Ht=({config:e,step:t,total:n,onDone:i})=>{let[o,s]=jo(()=>(ve?["Write .env (dry-run)","Skip build (dry-run)","Skip start (dry-run)","Skip health (dry-run)","Skip browser (dry-run)"]:["Write .env",e.target==="docker"?"Build images":"Render chart",e.target==="docker"?"Start containers":"Apply release","Wait for health","Open browser"]).map(c=>({label:c,state:"pending"}))),l=(r,c)=>s(d=>d.map((u,g)=>g===r?{...u,...c}:u));$o(()=>{let r=!1;return(async()=>{try{if(l(0,{state:"running"}),It(rr(e)),l(0,{state:"ok"}),ve){l(1,{state:"ok",detail:"skipped"}),l(2,{state:"ok",detail:"skipped"}),l(3,{state:"ok",detail:"skipped"}),l(4,{state:"ok",detail:"skipped"}),setTimeout(i,50);return}let d=await(e.target==="docker"?Lt:wt)(e,{onBuild:u=>!r&&l(1,{state:"running",detail:u}),onBuildDone:()=>!r&&l(1,{state:"ok"}),onStart:u=>!r&&l(2,{state:"running",detail:u}),onStartDone:()=>!r&&l(2,{state:"ok"}),onHealth:u=>!r&&l(3,{state:"running",detail:u}),onHealthDone:()=>!r&&l(3,{state:"ok"})});if(r)return;l(4,{state:"running",detail:d});try{await Yo(d)}catch{}l(4,{state:"ok",detail:d}),setTimeout(i,1200)}catch(c){if(r)return;let d=c instanceof Error?c.message:String(c);s(u=>u.map(g=>g.state==="running"?{...g,state:"fail",detail:d}:g))}})(),()=>{r=!0}},[e]);let m=o.find(r=>r.state==="fail");return Ue(S,{step:t,total:n,title:ve?"Bringing up openagentic (dry-run)":"Bringing up openagentic",children:[oe(Ke,{flexDirection:"column",children:o.map((r,c)=>Ue(Ke,{children:[oe(ke,{color:Nt(r.state).color,children:Nt(r.state).char}),oe(ke,{children:" "}),oe(ke,{children:r.label}),r.detail?Ue(ke,{color:a.muted,children:[" ",r.detail.slice(0,80)]}):null]},c))}),m?oe(_e,{title:`${m.label} failed.`,detail:m.detail,target:e.target==="helm"?"helm":"docker"}):oe(Ke,{marginTop:1,children:oe(b,{children:ve?"WIZARD_DRY_RUN=1 \u2014 only .env is written; no containers are touched.":"First boot pulls the embedding model and seeds Milvus \u2014 give it a couple minutes."})})]})};function Nt(e){switch(e){case"ok":return{char:"\u2713",color:a.ok};case"fail":return{char:"\u2717",color:a.err};case"running":return{char:"\u25E6",color:a.accent};default:return{char:"\xB7",color:a.muted}}}function rr(e){let t=e.llmStrategy==="ollama"||e.llmStrategy==="both",n=e.llmStrategy==="cloud"||e.llmStrategy==="both",i=e.llmStrategy==="vertex",o={ADMIN_USER_EMAIL:e.admin.email,ADMIN_SEED_PASSWORD:e.admin.password,LOCAL_ADMIN_USERNAME:e.admin.name,UI_HOST_PORT:String(e.uiPort),MCPS_ENABLED:e.mcps.join(",")};t?(o.OLLAMA_HOST=e.ollama.host,o.OLLAMA_EMBED_MODEL=e.ollama.embedModel,o.OLLAMA_ENABLED="true",e.llmStrategy==="both"&&(o.OLLAMA_CHAT_MODEL=Zo)):o.OLLAMA_ENABLED="false";let s=e.providers.awsBedrock;if(n&&s){let r=(s.region||"us-east-1").trim()||"us-east-1";o.AWS_REGION=r,s.accessKeyId&&s.secretAccessKey?(o.AWS_ACCESS_KEY_ID=s.accessKeyId,o.AWS_SECRET_ACCESS_KEY=s.secretAccessKey):s.profile&&(o.AWS_PROFILE=s.profile),o.BOOTSTRAP_PROVIDER_NAME="aws-bedrock",o.BOOTSTRAP_PROVIDER_DISPLAY_NAME="AWS Bedrock",o.BOOTSTRAP_PROVIDER_TYPE="aws-bedrock",o.BOOTSTRAP_PROVIDER_CONFIG=JSON.stringify({region:r}),o.BOOTSTRAP_PROVIDER_DEFAULTS=JSON.stringify({chat:Jo,embedding:Xo,embeddingDimension:qo}),o.SEEDER_VERSION=Ft}let l=e.providers.vertex;if(i&&l){let r=(l.project||"").trim(),c=(l.region||"us-central1").trim()||"us-central1",d=l.chatModel||Qo,u=l.embedModel||er,g=l.imageModel||tr;o.GOOGLE_CLOUD_PROJECT=r,o.GOOGLE_CLOUD_LOCATION=c,o.VERTEX_PROJECT=r,o.VERTEX_LOCATION=c,o.EMBEDDING_PROVIDER="vertex-ai",o.GCP_PROJECT_ID=r,o.GCP_LOCATION=c,o.GCP_EMBEDDING_MODEL=u,o.EMBEDDING_DIMENSIONS=String(Wt),o.SKIP_TOOL_SEMANTIC_CACHE="false",o.DEFAULT_IMAGE_MODEL=g,l.saKeyPath&&(o.GCP_SA_KEY_FILE=l.saKeyPath.startsWith("~")?(process.env.HOME||"")+l.saKeyPath.slice(1):l.saKeyPath,o.GOOGLE_APPLICATION_CREDENTIALS=or),o.VERTEX_AI_API_KEY="",o.GEMINI_API_KEY="",o.BOOTSTRAP_PROVIDER_NAME="google-vertex",o.BOOTSTRAP_PROVIDER_DISPLAY_NAME="Google Vertex AI",o.BOOTSTRAP_PROVIDER_TYPE="vertex-ai",o.BOOTSTRAP_PROVIDER_CONFIG=JSON.stringify({projectId:r,location:c}),o.BOOTSTRAP_PROVIDER_DEFAULTS=JSON.stringify({chat:d,embedding:u,embeddingDimension:Wt}),o.SEEDER_VERSION=Ft}let m=new Set(e.mcps);for(let r of ee)o[r.disabledEnv]=m.has(r.id)?"false":"true";for(let[r,c]of Object.entries(e.mcpAuth))r.startsWith("__skip_")||c&&(o[r]=c);return o}var N={target:"docker",llmStrategy:"both",admin:{email:"admin@openagentic.local",password:"",name:"Admin"},ollama:{host:"http://ollama:11434",embedModel:"nomic-embed-text"},providers:{},mcps:[],mcpAuth:{},uiPort:8080};import{jsx as T,jsxs as ye}from"react/jsx-runtime";var ir=()=>{let e=Ve(),[t,n]=Vt(()=>({...N,admin:{...N.admin,email:e.ADMIN_USER_EMAIL||N.admin.email,name:e.LOCAL_ADMIN_USERNAME||N.admin.name},ollama:{...N.ollama,host:e.OLLAMA_HOST||N.ollama.host,embedModel:e.OLLAMA_EMBED_MODEL||N.ollama.embedModel},providers:e.AWS_REGION||e.AWS_ACCESS_KEY_ID||e.AWS_PROFILE?{awsBedrock:{region:e.AWS_REGION||"us-east-1",accessKeyId:e.AWS_ACCESS_KEY_ID||void 0,secretAccessKey:e.AWS_SECRET_ACCESS_KEY||void 0,profile:e.AWS_PROFILE||void 0,useHostCreds:!e.AWS_ACCESS_KEY_ID&&!e.AWS_PROFILE?!0:void 0}}:e.VERTEX_PROJECT||e.GOOGLE_CLOUD_PROJECT?{vertex:{project:e.VERTEX_PROJECT||e.GOOGLE_CLOUD_PROJECT||"",region:e.VERTEX_LOCATION||e.GOOGLE_CLOUD_LOCATION||"us-central1",chatModel:e.VERTEX_CHAT_MODEL||"gemini-2.5-pro",embedModel:e.GCP_EMBEDDING_MODEL||"text-embedding-005",imageModel:e.DEFAULT_IMAGE_MODEL||"imagen-4.0-generate-001",saKeyPath:e.GCP_SA_KEY_FILE||""}}:{},mcps:e.MCPS_ENABLED?e.MCPS_ENABLED.split(",").map(p=>p.trim()).filter(Boolean):At(),mcpAuth:{},uiPort:e.UI_HOST_PORT?Number(e.UI_HOST_PORT):N.uiPort})),[i,o]=Vt("target"),s=t.llmStrategy,l=p=>n(H=>({...H,llmStrategy:p})),m=t.target==="helm"?1:0,r=s==="ollama"||s==="both"?1:0,c=s==="cloud"||s==="both"?1:0,d=s==="vertex"?1:0,u=1+m+1+1+r+c+d+1+1+1+1,g=1,h={target:g++,helmPreflight:t.target==="helm"?g++:0,admin:g++,llmStrategy:g++,ollama:r?g++:0,providers:c?g++:0,vertex:d?g++:0,mcps:g++,mcpAuth:g++,review:g++,launch:g++},A=p=>p==="ollama"||p==="both"?"ollama":p==="cloud"?"providers":p==="vertex"?"vertex":"mcps",f=p=>p==="both"?"providers":"mcps";return i==="target"?T(tt,{onPick:p=>{n({...t,target:p}),o(p==="helm"?"helm-preflight":"admin")}}):i==="helm-preflight"?T(ct,{onContinue:p=>{n({...t,kubeconfigPath:p}),o("admin")},onBackToDocker:()=>{n({...t,target:"docker",kubeconfigPath:void 0}),o("admin")}}):i==="admin"?T(ut,{initial:t.admin,step:h.admin,total:u,onDone:p=>{n({...t,admin:p}),o("llm-strategy")}}):i==="llm-strategy"?T(ht,{step:h.llmStrategy,total:u,onPick:p=>{p==="both"?n(H=>({...H,llmStrategy:p,mcps:kt()})):l(p),o(A(p))}}):i==="ollama"?T(ft,{initial:t.ollama,step:h.ollama,total:u,onDone:p=>{n({...t,ollama:p}),o(f(s))}}):i==="providers"?T(xt,{initial:t.providers,step:h.providers,total:u,onDone:p=>{n({...t,providers:p}),o("mcps")}}):i==="vertex"?T(Et,{initial:t.providers,step:h.vertex,total:u,onDone:p=>{n({...t,providers:p}),o("mcps")}}):i==="mcps"?T(yt,{initial:t.mcps,step:h.mcps,total:u,onDone:p=>{n({...t,mcps:p}),o("mcp-auth")}}):i==="mcp-auth"?T(Pt,{enabledIds:t.mcps,initialAuth:t.mcpAuth,step:h.mcpAuth,total:u,onDone:p=>{let H=Object.keys(p).filter(K=>K.startsWith("__skip_")).map(K=>K.slice(7)),V={};for(let[K,Ut]of Object.entries(p))K.startsWith("__skip_")||(V[K]=Ut);n({...t,mcps:t.mcps.filter(K=>!H.includes(K)),mcpAuth:V}),o("review")}}):i==="review"?T(Dt,{config:t,step:h.review,total:u,onLaunch:()=>o("launch"),onCancel:()=>process.exit(0)}):i==="launch"?T(Ht,{config:t,step:h.launch,total:u,onDone:()=>o("done")}):ye(Kt,{flexDirection:"column",children:[T(ae,{}),ye(Kt,{marginLeft:2,flexDirection:"column",children:[T(Ge,{color:a.ok,bold:!0,children:"openagentic is running"}),ye(Ge,{color:a.muted,children:["open http://localhost:",t.uiPort," in your browser"]}),ye(Ge,{color:a.muted,children:["sign in with ",t.admin.email]})]})]})},sr=!!process.argv[1]&&/(^|\/)index\.tsx$/.test(process.argv[1]);if(sr){process.stdout.isTTY&&process.stdout.write("\x1B[2J\x1B[3J\x1B[H");let e=t=>{let n=t instanceof Error?t.stack||t.message:String(t);process.stderr.write(`
8
+ `),"utf8")}function $o(e){let t={};for(let n of e.split(`
9
+ `)){let i=/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/.exec(n);if(!i)continue;let o=i[2];(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),t[i[1]]=o}return t}import{execa as Bt}from"execa";async function Lt(e,t){t.onBuild?.("docker compose --profile milvus build (first run may take several minutes)"),await Bt("docker",["compose","--profile","milvus","build"],{cwd:te}),t.onBuildDone?.(),t.onStart?.("docker compose --profile milvus up -d"),await Bt("docker",["compose","--profile","milvus","up","-d"],{cwd:te}),t.onStartDone?.();let n=`http://localhost:${e.uiPort}`;t.onHealth?.(`waiting for ${n}/api/health`);let i=Date.now();for(;Date.now()-i<10*6e4;){try{if((await fetch(`${n}/api/health`)).ok)return t.onHealthDone?.(),n}catch{}await new Promise(o=>setTimeout(o,3e3))}throw new Error("API did not become healthy within 10 minutes. Run 'docker compose logs api' to investigate.")}async function wt(e,t){throw new Error("Helm deploy is not wired up yet \u2014 the chart at helm/openagentic needs a cleanup pass before the wizard can drive it. Use the Docker path for now.")}import{jsx as oe,jsxs as Ue}from"react/jsx-runtime";var ve=process.env.WIZARD_DRY_RUN==="1",Xo="anthropic.claude-sonnet-4-6",qo="nomic-embed-text",Zo=768,Qo="gpt-oss:20b",Ft="6",er="gemini-2.5-pro",tr="text-embedding-005",Wt=768,or="imagen-4.0-generate-001",rr="/var/secrets/gcp/key.json",Ht=({config:e,step:t,total:n,onDone:i})=>{let[o,s]=Yo(()=>(ve?["Write .env (dry-run)","Skip build (dry-run)","Skip start (dry-run)","Skip health (dry-run)","Skip browser (dry-run)"]:["Write .env",e.target==="docker"?"Build images":"Render chart",e.target==="docker"?"Start containers":"Apply release","Wait for health","Open browser"]).map(c=>({label:c,state:"pending"}))),l=(r,c)=>s(d=>d.map((u,g)=>g===r?{...u,...c}:u));jo(()=>{let r=!1;return(async()=>{try{if(l(0,{state:"running"}),It(nr(e)),l(0,{state:"ok"}),ve){l(1,{state:"ok",detail:"skipped"}),l(2,{state:"ok",detail:"skipped"}),l(3,{state:"ok",detail:"skipped"}),l(4,{state:"ok",detail:"skipped"}),setTimeout(i,50);return}let d=await(e.target==="docker"?Lt:wt)(e,{onBuild:u=>!r&&l(1,{state:"running",detail:u}),onBuildDone:()=>!r&&l(1,{state:"ok"}),onStart:u=>!r&&l(2,{state:"running",detail:u}),onStartDone:()=>!r&&l(2,{state:"ok"}),onHealth:u=>!r&&l(3,{state:"running",detail:u}),onHealthDone:()=>!r&&l(3,{state:"ok"})});if(r)return;l(4,{state:"running",detail:d});try{await Jo(d)}catch{}l(4,{state:"ok",detail:d}),setTimeout(i,1200)}catch(c){if(r)return;let d=c instanceof Error?c.message:String(c);s(u=>u.map(g=>g.state==="running"?{...g,state:"fail",detail:d}:g))}})(),()=>{r=!0}},[e]);let m=o.find(r=>r.state==="fail");return Ue(S,{step:t,total:n,title:ve?"Bringing up openagentic (dry-run)":"Bringing up openagentic",children:[oe(Ke,{flexDirection:"column",children:o.map((r,c)=>Ue(Ke,{children:[oe(ke,{color:Nt(r.state).color,children:Nt(r.state).char}),oe(ke,{children:" "}),oe(ke,{children:r.label}),r.detail?Ue(ke,{color:a.muted,children:[" ",r.detail.slice(0,80)]}):null]},c))}),m?oe(_e,{title:`${m.label} failed.`,detail:m.detail,target:e.target==="helm"?"helm":"docker"}):oe(Ke,{marginTop:1,children:oe(b,{children:ve?"WIZARD_DRY_RUN=1 \u2014 only .env is written; no containers are touched.":"First boot pulls the embedding model and seeds Milvus \u2014 give it a couple minutes."})})]})};function Nt(e){switch(e){case"ok":return{char:"\u2713",color:a.ok};case"fail":return{char:"\u2717",color:a.err};case"running":return{char:"\u25E6",color:a.accent};default:return{char:"\xB7",color:a.muted}}}function nr(e){let t=e.llmStrategy==="ollama"||e.llmStrategy==="both",n=e.llmStrategy==="cloud"||e.llmStrategy==="both",i=e.llmStrategy==="vertex",o={ADMIN_USER_EMAIL:e.admin.email,ADMIN_SEED_PASSWORD:e.admin.password,LOCAL_ADMIN_USERNAME:e.admin.name,UI_HOST_PORT:String(e.uiPort),MCPS_ENABLED:e.mcps.join(",")};t?(o.OLLAMA_HOST=e.ollama.host,o.OLLAMA_EMBED_MODEL=e.ollama.embedModel,o.OLLAMA_ENABLED="true",e.llmStrategy==="both"&&(o.OLLAMA_CHAT_MODEL=Qo)):o.OLLAMA_ENABLED="false";let s=e.providers.awsBedrock;if(n&&s){let r=(s.region||"us-east-1").trim()||"us-east-1";o.AWS_REGION=r,s.accessKeyId&&s.secretAccessKey?(o.AWS_ACCESS_KEY_ID=s.accessKeyId,o.AWS_SECRET_ACCESS_KEY=s.secretAccessKey):s.profile&&(o.AWS_PROFILE=s.profile),o.BOOTSTRAP_PROVIDER_NAME="aws-bedrock",o.BOOTSTRAP_PROVIDER_DISPLAY_NAME="AWS Bedrock",o.BOOTSTRAP_PROVIDER_TYPE="aws-bedrock",o.BOOTSTRAP_PROVIDER_CONFIG=JSON.stringify({region:r}),o.BOOTSTRAP_PROVIDER_DEFAULTS=JSON.stringify({chat:Xo,embedding:qo,embeddingDimension:Zo}),o.SEEDER_VERSION=Ft}let l=e.providers.vertex;if(i&&l){let r=(l.project||"").trim(),c=(l.region||"us-central1").trim()||"us-central1",d=l.chatModel||er,u=l.embedModel||tr,g=l.imageModel||or;o.GOOGLE_CLOUD_PROJECT=r,o.GOOGLE_CLOUD_LOCATION=c,o.VERTEX_PROJECT=r,o.VERTEX_LOCATION=c,o.EMBEDDING_PROVIDER="vertex-ai",o.GCP_PROJECT_ID=r,o.GCP_LOCATION=c,o.GCP_EMBEDDING_MODEL=u,o.EMBEDDING_DIMENSIONS=String(Wt),o.SKIP_TOOL_SEMANTIC_CACHE="false",o.DEFAULT_IMAGE_MODEL=g,l.saKeyPath&&(o.GCP_SA_KEY_FILE=l.saKeyPath.startsWith("~")?(process.env.HOME||"")+l.saKeyPath.slice(1):l.saKeyPath,o.GOOGLE_APPLICATION_CREDENTIALS=rr),o.VERTEX_AI_API_KEY="",o.GEMINI_API_KEY="",o.BOOTSTRAP_PROVIDER_NAME="google-vertex",o.BOOTSTRAP_PROVIDER_DISPLAY_NAME="Google Vertex AI",o.BOOTSTRAP_PROVIDER_TYPE="vertex-ai",o.BOOTSTRAP_PROVIDER_CONFIG=JSON.stringify({projectId:r,location:c}),o.BOOTSTRAP_PROVIDER_DEFAULTS=JSON.stringify({chat:d,embedding:u,embeddingDimension:Wt}),o.SEEDER_VERSION=Ft}let m=new Set(e.mcps);for(let r of ee)o[r.disabledEnv]=m.has(r.id)?"false":"true";for(let[r,c]of Object.entries(e.mcpAuth))r.startsWith("__skip_")||c&&(o[r]=c);return o}var N={target:"docker",llmStrategy:"both",admin:{email:"admin@openagentic.local",password:"",name:"Admin"},ollama:{host:"http://ollama:11434",embedModel:"nomic-embed-text"},providers:{},mcps:[],mcpAuth:{},uiPort:8080};import{jsx as T,jsxs as ye}from"react/jsx-runtime";var lr=()=>{let e=Ve(),[t,n]=Vt(()=>({...N,admin:{...N.admin,email:e.ADMIN_USER_EMAIL||N.admin.email,name:e.LOCAL_ADMIN_USERNAME||N.admin.name},ollama:{...N.ollama,host:e.OLLAMA_HOST||N.ollama.host,embedModel:e.OLLAMA_EMBED_MODEL||N.ollama.embedModel},providers:e.AWS_REGION||e.AWS_ACCESS_KEY_ID||e.AWS_PROFILE?{awsBedrock:{region:e.AWS_REGION||"us-east-1",accessKeyId:e.AWS_ACCESS_KEY_ID||void 0,secretAccessKey:e.AWS_SECRET_ACCESS_KEY||void 0,profile:e.AWS_PROFILE||void 0,useHostCreds:!e.AWS_ACCESS_KEY_ID&&!e.AWS_PROFILE?!0:void 0}}:e.VERTEX_PROJECT||e.GOOGLE_CLOUD_PROJECT?{vertex:{project:e.VERTEX_PROJECT||e.GOOGLE_CLOUD_PROJECT||"",region:e.VERTEX_LOCATION||e.GOOGLE_CLOUD_LOCATION||"us-central1",chatModel:e.VERTEX_CHAT_MODEL||"gemini-2.5-pro",embedModel:e.GCP_EMBEDDING_MODEL||"text-embedding-005",imageModel:e.DEFAULT_IMAGE_MODEL||"imagen-4.0-generate-001",saKeyPath:e.GCP_SA_KEY_FILE||""}}:{},mcps:e.MCPS_ENABLED?e.MCPS_ENABLED.split(",").map(p=>p.trim()).filter(Boolean):At(),mcpAuth:{},uiPort:e.UI_HOST_PORT?Number(e.UI_HOST_PORT):N.uiPort})),[i,o]=Vt("target"),s=t.llmStrategy,l=p=>n(H=>({...H,llmStrategy:p})),m=t.target==="helm"?1:0,r=s==="ollama"||s==="both"?1:0,c=s==="cloud"||s==="both"?1:0,d=s==="vertex"?1:0,u=1+m+1+1+r+c+d+1+1+1+1,g=1,h={target:g++,helmPreflight:t.target==="helm"?g++:0,admin:g++,llmStrategy:g++,ollama:r?g++:0,providers:c?g++:0,vertex:d?g++:0,mcps:g++,mcpAuth:g++,review:g++,launch:g++},A=p=>p==="ollama"||p==="both"?"ollama":p==="cloud"?"providers":p==="vertex"?"vertex":"mcps",f=p=>p==="both"?"providers":"mcps";return i==="target"?T(tt,{onPick:p=>{n({...t,target:p}),o(p==="helm"?"helm-preflight":"admin")}}):i==="helm-preflight"?T(ct,{onContinue:p=>{n({...t,kubeconfigPath:p}),o("admin")},onBackToDocker:()=>{n({...t,target:"docker",kubeconfigPath:void 0}),o("admin")}}):i==="admin"?T(ut,{initial:t.admin,step:h.admin,total:u,onDone:p=>{n({...t,admin:p}),o("llm-strategy")}}):i==="llm-strategy"?T(ht,{step:h.llmStrategy,total:u,onPick:p=>{p==="both"?n(H=>({...H,llmStrategy:p,mcps:kt()})):l(p),o(A(p))}}):i==="ollama"?T(ft,{initial:t.ollama,step:h.ollama,total:u,onDone:p=>{n({...t,ollama:p}),o(f(s))}}):i==="providers"?T(xt,{initial:t.providers,step:h.providers,total:u,onDone:p=>{n({...t,providers:p}),o("mcps")}}):i==="vertex"?T(Et,{initial:t.providers,step:h.vertex,total:u,onDone:p=>{n({...t,providers:p}),o("mcps")}}):i==="mcps"?T(yt,{initial:t.mcps,step:h.mcps,total:u,onDone:p=>{n({...t,mcps:p}),o("mcp-auth")}}):i==="mcp-auth"?T(Pt,{enabledIds:t.mcps,initialAuth:t.mcpAuth,step:h.mcpAuth,total:u,onDone:p=>{let H=Object.keys(p).filter(K=>K.startsWith("__skip_")).map(K=>K.slice(7)),V={};for(let[K,Gt]of Object.entries(p))K.startsWith("__skip_")||(V[K]=Gt);n({...t,mcps:t.mcps.filter(K=>!H.includes(K)),mcpAuth:V}),o("review")}}):i==="review"?T(Dt,{config:t,step:h.review,total:u,onLaunch:()=>o("launch"),onCancel:()=>process.exit(0)}):i==="launch"?T(Ht,{config:t,step:h.launch,total:u,onDone:()=>o("done")}):ye(Kt,{flexDirection:"column",children:[T(ae,{}),ye(Kt,{marginLeft:2,flexDirection:"column",children:[T(Ge,{color:a.ok,bold:!0,children:"openagentic is running"}),ye(Ge,{color:a.muted,children:["open http://localhost:",t.uiPort," in your browser"]}),ye(Ge,{color:a.muted,children:["sign in with ",t.admin.email]})]})]})},Ut=!1;try{Ut=!!process.argv[1]&&ir(process.argv[1])===sr(import.meta.url)}catch{}if(Ut){process.stdout.isTTY&&process.stdout.write("\x1B[2J\x1B[3J\x1B[H");let e=t=>{let n=t instanceof Error?t.stack||t.message:String(t);process.stderr.write(`
10
10
  \u2717 The setup wizard hit an unexpected error.
11
11
  ${n}
12
12
 
@@ -14,4 +14,4 @@ import{useState as Vt}from"react";import{render as nr,Box as Kt,Text as Ge}from"
14
14
  Help: https://openagentics.io/docs/troubleshooting
15
15
  Issues: https://github.com/agentic-work/openagentic/issues
16
16
 
17
- `),process.exit(1)};process.on("uncaughtException",e),process.on("unhandledRejection",e),nr(T(pe,{children:T(ir,{})}))}export{ir as App};
17
+ `),process.exit(1)};process.on("uncaughtException",e),process.on("unhandledRejection",e),ar(T(pe,{children:T(lr,{})}))}export{lr as App};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticwork/setup",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "openagentic-setup": "dist/index.js"