bostrat-node 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- var se=Object.defineProperty;var re=(e,t)=>()=>(e&&(t=e(e=0)),t);var ie=(e,t)=>{for(var n in t)se(e,n,{get:t[n],enumerable:!0})};var Z={};ie(Z,{commandPlan:()=>V,flyDockerfile:()=>X,flyToml:()=>z,flyWizard:()=>Se,parseFlyFlags:()=>J,stageBuild:()=>q});import _ from"node:fs";import p from"node:path";import me from"node:os";import ye from"node:readline/promises";import{execFile as he}from"node:child_process";import{randomUUID as we}from"node:crypto";import{fileURLToPath as ge}from"node:url";function z({app:e,region:t,nodeName:n=e,planeUrl:o=G}){return`# bostrat node on YOUR Fly org \u2014 written by \`bostrat-node fly\`.
1
+ var re=Object.defineProperty;var ie=(e,t)=>()=>(e&&(t=e(e=0)),t);var ae=(e,t)=>{for(var n in t)re(e,n,{get:t[n],enumerable:!0})};var ee={};ae(ee,{commandPlan:()=>q,flyDockerfile:()=>J,flyToml:()=>V,flyWizard:()=>Oe,parseFlyFlags:()=>Z,stageBuild:()=>Q});import S from"node:fs";import f from"node:path";import ye from"node:os";import he from"node:readline/promises";import{execFile as we}from"node:child_process";import{randomUUID as ge}from"node:crypto";import{fileURLToPath as Te}from"node:url";function V({app:e,region:t,nodeName:n=e,planeUrl:o=X}){return`# bostrat node on YOUR Fly org \u2014 written by \`bostrat-node fly\`.
2
2
  # Redeploy after edits: fly deploy <this dir> -c <this file> -a ${e} --ha=false
3
3
  # No [http_service] and none should be added: the node dials OUT to the plane;
4
4
  # nothing inbound, ever. The node token lives in \`fly secrets\`, not here.
@@ -31,7 +31,7 @@ primary_region = "${t}"
31
31
  # Scale later with: fly scale memory 4096 -a ${e}
32
32
  size = "shared-cpu-2x"
33
33
  memory = "2gb"
34
- `}function X({layout:e="src"}={}){return`# bostrat node image \u2014 written by \`bostrat-node fly\`; context = this directory.
34
+ `}function J({layout:e="src"}={}){return`# bostrat node image \u2014 written by \`bostrat-node fly\`; context = this directory.
35
35
  FROM node:24-slim AS deps
36
36
  RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \\
37
37
  && rm -rf /var/lib/apt/lists/*
@@ -54,62 +54,64 @@ RUN chmod +x /usr/local/bin/node-entrypoint.sh
54
54
  ENV NODE_ENV=production
55
55
  ENV HOME=/data/home
56
56
  CMD ["node-entrypoint.sh"]
57
- `}function V({app:e,org:t,region:n,sizeGb:o,token:r,owner:s,dir:i}){let a=[`BOSTRAT_PLANE_TOKEN=${r}`,...s?[`BOSTRAT_OWNER=${s}`]:[]];return[{argv:["apps","create",e,"-o",t],display:`fly apps create ${e} -o ${t}`,tolerate:/already|taken|exists/i},{argv:["volumes","create","node_data","-a",e,"-r",n,"-s",String(o),"-y"],display:`fly volumes create node_data -a ${e} -r ${n} -s ${o} -y`,tolerate:/already|exists/i},{argv:["secrets","import","-a",e,"--stage"],display:`fly secrets import -a ${e} --stage # BOSTRAT_PLANE_TOKEN=<redacted>${s?" BOSTRAT_OWNER=\u2026":""} via stdin`,stdin:a.join(`
57
+ `}function q({app:e,org:t,region:n,sizeGb:o,token:r,owner:s,dir:i}){let a=[`BOSTRAT_PLANE_TOKEN=${r}`,...s?[`BOSTRAT_OWNER=${s}`]:[]];return[{argv:["apps","create",e,"-o",t],display:`fly apps create ${e} -o ${t}`,tolerate:/already|taken|exists/i},{argv:["volumes","create","node_data","-a",e,"-r",n,"-s",String(o),"-y"],display:`fly volumes create node_data -a ${e} -r ${n} -s ${o} -y`,tolerate:/already|exists/i},{argv:["secrets","import","-a",e,"--stage"],display:`fly secrets import -a ${e} --stage # BOSTRAT_PLANE_TOKEN=<redacted>${s?" BOSTRAT_OWNER=\u2026":""} via stdin`,stdin:a.join(`
58
58
  `)+`
59
- `},{argv:["deploy",i,"-c",p.join(i,"fly.toml"),"-a",e,"--ha=false"],display:`fly deploy ${i} -c ${p.join(i,"fly.toml")} -a ${e} --ha=false`}]}function J(e=[]){let t={},n={"--app":"app","--org":"org","--region":"region","--size-gb":"sizeGb","--name":"name","--plane-url":"planeUrl","--token":"token","--owner":"owner"};for(let o=0;o<e.length;o++){let r=e[o];if(r==="--yes"||r==="-y")t.yes=!0;else if(n[r])t[n[r]]=e[++o]??"";else if(r.startsWith("--")&&r.includes("=")){let[s,...i]=r.split("=");n[s]?t[n[s]]=i.join("="):s==="--yes"&&(t.yes=!0)}}return t.sizeGb!=null&&(t.sizeGb=Number(t.sizeGb)||10),t}function q({app:e,agentDir:t=Te,dest:n,toml:o}){let r=n||p.join(me.homedir(),".bostrat","fly",e);_.mkdirSync(r,{recursive:!0});let s=[],i=(c,{optional:f=!1}={})=>{let d=p.join(t,c);if(!_.existsSync(d)){if(f)return;throw new Error(`staging: ${d} missing \u2014 is this a complete bostrat-agent install?`)}_.cpSync(d,p.join(r,c),{recursive:!0}),s.push(c)};i("package.json"),i("package-lock.json",{optional:!0});let a=_.existsSync(p.join(t,"src"))?"src":"dist";return i(a),i("bin"),i("node-entrypoint.sh"),_.writeFileSync(p.join(r,".dockerignore"),`node_modules
60
- `),_.writeFileSync(p.join(r,"Dockerfile"),X({layout:a})),_.writeFileSync(p.join(r,"fly.toml"),o),s.push(".dockerignore","Dockerfile","fly.toml"),{dir:r,manifest:s}}async function _e({ask:e,output:t,exec:n,flag:o}){if(o)return o;try{let{stdout:r}=await L(["orgs","list","--json"],{exec:n}),s=JSON.parse(r),i=Array.isArray(s)?s.map(a=>a.Slug||a.slug).filter(Boolean):Object.keys(s);if(i.length===1)return t.write(`Org: ${i[0]} (your only org)
61
- `),i[0];if(i.length>1)return await e(`Fly org (${i.join(" / ")})`,i[0])}catch{}return await e("Fly org slug (see `fly orgs list`)","personal")}async function Se({argv:e=[],input:t=process.stdin,output:n=process.stdout,exec:o,stageDest:r}={}){let s=J(e),i=ye.createInterface({input:t,output:n}),a=async(l,m)=>(await i.question(m?`${l} [${m}]: `:`${l}: `)).trim()||m||"",c=l=>(i.close(),l);n.write(`bostrat-node fly \u2014 a node on YOUR Fly org, on your bill.
59
+ `},{argv:["deploy",i,"-c",f.join(i,"fly.toml"),"-a",e,"--ha=false"],display:`fly deploy ${i} -c ${f.join(i,"fly.toml")} -a ${e} --ha=false`}]}function Z(e=[]){let t={},n={"--app":"app","--org":"org","--region":"region","--size-gb":"sizeGb","--name":"name","--plane-url":"planeUrl","--token":"token","--owner":"owner"};for(let o=0;o<e.length;o++){let r=e[o];if(r==="--yes"||r==="-y")t.yes=!0;else if(n[r])t[n[r]]=e[++o]??"";else if(r.startsWith("--")&&r.includes("=")){let[s,...i]=r.split("=");n[s]?t[n[s]]=i.join("="):s==="--yes"&&(t.yes=!0)}}return t.sizeGb!=null&&(t.sizeGb=Number(t.sizeGb)||10),t}function Q({app:e,agentDir:t=_e,dest:n,toml:o}){let r=n||f.join(ye.homedir(),".bostrat","fly",e);S.mkdirSync(r,{recursive:!0});let s=[],i=(l,{optional:p=!1}={})=>{let u=f.join(t,l);if(!S.existsSync(u)){if(p)return;throw new Error(`staging: ${u} missing \u2014 is this a complete bostrat-agent install?`)}S.cpSync(u,f.join(r,l),{recursive:!0}),s.push(l)};i("package.json"),i("package-lock.json",{optional:!0});let a=S.existsSync(f.join(t,"src"))?"src":"dist";return i(a),i("bin"),i("node-entrypoint.sh"),S.writeFileSync(f.join(r,".dockerignore"),`node_modules
60
+ `),S.writeFileSync(f.join(r,"Dockerfile"),J({layout:a})),S.writeFileSync(f.join(r,"fly.toml"),o),s.push(".dockerignore","Dockerfile","fly.toml"),{dir:r,manifest:s}}async function Se({ask:e,output:t,exec:n,flag:o}){if(o)return o;try{let{stdout:r}=await B(["orgs","list","--json"],{exec:n}),s=JSON.parse(r),i=Array.isArray(s)?s.map(a=>a.Slug||a.slug).filter(Boolean):Object.keys(s);if(i.length===1)return t.write(`Org: ${i[0]} (your only org)
61
+ `),i[0];if(i.length>1)return await e(`Fly org (${i.join(" / ")})`,i[0])}catch{}return await e("Fly org slug (see `fly orgs list`)","personal")}async function Oe({argv:e=[],input:t=process.stdin,output:n=process.stdout,exec:o,stageDest:r}={}){let s=Z(e),i=he.createInterface({input:t,output:n}),a=async(c,y)=>(await i.question(y?`${c} [${y}]: `:`${c}: `)).trim()||y||"",l=c=>(i.close(),c);n.write(`bostrat-node fly \u2014 a node on YOUR Fly org, on your bill.
62
62
  bostrat never sees your Fly account: this wizard only runs your own \`fly\` CLI.
63
63
 
64
- `);try{await L(["version"],{exec:o})}catch{return n.write("\u2717 `fly` (flyctl) is not installed or not on PATH.\n install: https://fly.io/docs/flyctl/install/ \u2014 then re-run `bostrat-node fly`\n"),c(1)}try{let{stdout:l}=await L(["auth","whoami"],{exec:o});n.write(`\u2713 signed in to Fly as ${l.trim()}
65
- `)}catch{return n.write("\u2717 not signed in to Fly. Run `fly auth login` (or `fly auth signup`) and re-run `bostrat-node fly`.\n"),c(1)}let f=await _e({ask:a,output:n,exec:o,flag:s.org}),d=s.app||await a("App name",`bostrat-node-${we().slice(0,4)}`),k=s.region||await a("Region (see `fly platform regions`)","iad"),g=s.sizeGb||Number(await a("Volume size GB (logins + repos live here)","10"))||10,v=s.name||d,N=s.planeUrl||G,P=s.token||await a("Node token (minted in the bostrat setup chat \u2014 shown once)");if(!P)return n.write(`\u2717 a node token is required \u2014 mint one in the bostrat setup chat (Connect a node \u2192 Fly), then re-run with it.
66
- `),c(1);let $=s.owner??await a("Owner userId (shown next to the token; empty = infer from token)",""),{dir:T,manifest:O}=q({app:d,dest:r,toml:z({app:d,region:k,nodeName:v,planeUrl:N})});n.write(`
67
- staged build context \u2192 ${T} (${O.join(", ")})
64
+ `);try{await B(["version"],{exec:o})}catch{return n.write("\u2717 `fly` (flyctl) is not installed or not on PATH.\n install: https://fly.io/docs/flyctl/install/ \u2014 then re-run `bostrat-node fly`\n"),l(1)}try{let{stdout:c}=await B(["auth","whoami"],{exec:o});n.write(`\u2713 signed in to Fly as ${c.trim()}
65
+ `)}catch{return n.write("\u2717 not signed in to Fly. Run `fly auth login` (or `fly auth signup`) and re-run `bostrat-node fly`.\n"),l(1)}let p=await Se({ask:a,output:n,exec:o,flag:s.org}),u=s.app||await a("App name",`bostrat-node-${ge().slice(0,4)}`),k=s.region||await a("Region (see `fly platform regions`)","iad"),C=s.sizeGb||Number(await a("Volume size GB (logins + repos live here)","10"))||10,g=s.name||u,v=s.planeUrl||X,E=s.token||await a("Node token (minted in the bostrat setup chat \u2014 shown once)");if(!E)return n.write(`\u2717 a node token is required \u2014 mint one in the bostrat setup chat (Connect a node \u2192 Fly), then re-run with it.
66
+ `),l(1);let j=s.owner??await a("Owner userId (shown next to the token; empty = infer from token)",""),{dir:T,manifest:N}=Q({app:u,dest:r,toml:V({app:u,region:k,nodeName:g,planeUrl:v})});n.write(`
67
+ staged build context \u2192 ${T} (${N.join(", ")})
68
68
 
69
69
  Plan (your flyctl, your org, your bill):
70
- `);let b=V({app:d,org:f,region:k,sizeGb:g,token:P,owner:$,dir:T});for(let l of b)n.write(` $ ${l.display}
70
+ `);let _=q({app:u,org:p,region:k,sizeGb:C,token:E,owner:j,dir:T});for(let c of _)n.write(` $ ${c.display}
71
71
  `);if(!s.yes&&(await a(`
72
72
  Run it? (Y/n)`,"Y")).toLowerCase().startsWith("n"))return n.write(`aborted \u2014 nothing was created. Re-run any time; the staged context is kept.
73
- `),c(1);for(let l of b){n.write(`
74
- \u2192 ${l.display}
75
- `);try{let{stdout:m,stderr:B}=await L(l.argv,{stdin:l.stdin,exec:o}),F=`${m||""}${B||""}`.trim();F&&n.write(F.split(`
76
- `).map(oe=>` ${oe}`).join(`
73
+ `),l(1);for(let c of _){n.write(`
74
+ \u2192 ${c.display}
75
+ `);try{let{stdout:y,stderr:P}=await B(c.argv,{stdin:c.stdin,exec:o}),K=`${y||""}${P||""}`.trim();K&&n.write(K.split(`
76
+ `).map(se=>` ${se}`).join(`
77
77
  `)+`
78
- `)}catch(m){let B=`${m?.stdout||""}${m?.stderr||""}${m?.message||""}`;if(l.tolerate&&l.tolerate.test(B)){n.write(` (already exists \u2014 continuing)
79
- `);continue}return n.write(`\u2717 failed: ${B.trim().split(`
78
+ `)}catch(y){let P=`${y?.stdout||""}${y?.stderr||""}${y?.message||""}`;if(c.tolerate&&c.tolerate.test(P)){n.write(` (already exists \u2014 continuing)
79
+ `);continue}return n.write(`\u2717 failed: ${P.trim().split(`
80
80
  `).slice(-4).join(`
81
81
  `)}
82
82
  fix and re-run \`bostrat-node fly\` \u2014 every step is safe to repeat.
83
- `),c(1)}}return n.write(`
83
+ `),l(1)}}return n.write(`
84
84
  \u2713 deployed. The node dials out to the plane by itself \u2014 watch the bostrat setup
85
85
  chat: the node step advances on its own within a minute.
86
- logs: fly logs -a ${d}
87
- redeploy: fly deploy ${T} -c ${p.join(T,"fly.toml")} -a ${d} --ha=false
86
+ logs: fly logs -a ${u}
87
+ redeploy: fly deploy ${T} -c ${f.join(T,"fly.toml")} -a ${u} --ha=false
88
88
  Vendor logins (Claude/Codex) are NOT set up here \u2014 you type those later, inside
89
89
  boxes, and they land on this machine's volume, never on bostrat (box-auth-policy).
90
- `),c(0)}var Te,G,L,Q=re(()=>{Te=p.resolve(p.dirname(ge(import.meta.url)),".."),G="wss://plane.bostrat.ai/v1/node";L=(e,{stdin:t,exec:n}={})=>new Promise((o,r)=>{if(n)return n(e,{stdin:t}).then(o,r);let s=he("fly",e,{timeout:6e5,maxBuffer:16*1024*1024},(i,a,c)=>i?r(Object.assign(i,{stdout:a,stderr:c})):o({stdout:a,stderr:c}));t!=null&&s.stdin?.end(t)})});import w from"node:fs";import u from"node:path";import R from"node:os";import{createRequire as ee}from"node:module";import{execFile as Oe,spawn as be}from"node:child_process";import{promisify as Ae}from"node:util";import Re from"node:readline/promises";import{randomUUID as xe}from"node:crypto";import{fileURLToPath as Ee}from"node:url";import I from"node:fs";import j from"node:path";import ae from"node:os";var ce=process.env.BOSTRAT_STATE_DIR||j.join(process.env.HOME||ae.tmpdir(),".bostrat"),A=()=>j.join(ce,"node.env");function C(e){let t;try{t=I.readFileSync(e,"utf8")}catch{return{}}let n={};for(let o of t.split(`
91
- `)){let r=o.trim();if(!r||r.startsWith("#"))continue;let s=/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(r);if(!s)continue;let i=s[2].trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),n[s[1]]=i}return n}function M(e,t=process.env){let n=C(e);for(let[o,r]of Object.entries(n))o in t||(t[o]=r);return n}function K(e,t,{header:n=""}={}){let o=[];n&&o.push(...n.split(`
92
- `).map(r=>r?`# ${r}`:"#"));for(let[r,s]of Object.entries(t))s==null||s===""||o.push(`${r}=${s}`);I.mkdirSync(j.dirname(e),{recursive:!0}),I.writeFileSync(e,o.join(`
90
+ `),l(0)}var _e,X,B,te=ie(()=>{_e=f.resolve(f.dirname(Te(import.meta.url)),".."),X="wss://plane.bostrat.ai/v1/node";B=(e,{stdin:t,exec:n}={})=>new Promise((o,r)=>{if(n)return n(e,{stdin:t}).then(o,r);let s=we("fly",e,{timeout:6e5,maxBuffer:16*1024*1024},(i,a,l)=>i?r(Object.assign(i,{stdout:a,stderr:l})):o({stdout:a,stderr:l}));t!=null&&s.stdin?.end(t)})});import m from"node:fs";import d from"node:path";import x from"node:os";import{createRequire as D}from"node:module";import{execFile as be,spawn as Ae}from"node:child_process";import{promisify as xe}from"node:util";import Re from"node:readline/promises";import{randomUUID as ve}from"node:crypto";import{fileURLToPath as Ee}from"node:url";import $ from"node:fs";import L from"node:path";import ce from"node:os";var le=process.env.BOSTRAT_STATE_DIR||L.join(process.env.HOME||ce.tmpdir(),".bostrat"),A=()=>L.join(le,"node.env");function U(e){let t=String(e||"").trim();if(!t)return"";let n=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`wss://${t}`,o;try{o=new URL(n)}catch{return t}let r={"https:":"wss:","http:":"ws:","wss:":"wss:","ws:":"ws:"}[o.protocol];return r?(o.protocol=r,(o.pathname===""||o.pathname==="/")&&(o.pathname="/v1/node"),o.toString()):t}function I(e){let t;try{t=$.readFileSync(e,"utf8")}catch{return{}}let n={};for(let o of t.split(`
91
+ `)){let r=o.trim();if(!r||r.startsWith("#"))continue;let s=/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(r);if(!s)continue;let i=s[2].trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),n[s[1]]=i}return n}function H(e,t=process.env){let n=I(e);for(let[o,r]of Object.entries(n))o in t||(t[o]=r);return n}function W(e,t,{header:n=""}={}){let o=[];n&&o.push(...n.split(`
92
+ `).map(r=>r?`# ${r}`:"#"));for(let[r,s]of Object.entries(t))s==null||s===""||o.push(`${r}=${s}`);$.mkdirSync(L.dirname(e),{recursive:!0}),$.writeFileSync(e,o.join(`
93
93
  `)+`
94
- `,{mode:384}),I.chmodSync(e,384)}function H(e=process.platform){return e==="darwin"?{BOSTRAT_TMUX_BIN:"/opt/homebrew/bin/tmux",BOSTRAT_TMUX_SOCKET:`/tmp/tmux-${process.getuid?.()??501}/bostrat`,BOSTRAT_CHROMIUM_BIN:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}:{}}import{execFile as de}from"node:child_process";import{promisify as pe}from"node:util";import le from"node:os";import W from"node:path";var ue=process.env.BOSTRAT_DEBUG_DIR||W.join(le.homedir(),".bostrat","debug"),ot=W.join(ue,"handoff.jsonl"),st=Number(process.env.BOSTRAT_HANDOFF_DEBUG_MAX)||500;var fe=pe(de);var gt=process.env.BOSTRAT_TMUX_BIN||"/usr/bin/tmux",Tt=process.env.BOSTRAT_TMUX_SOCKET||"/tmp/tmux-1000/default",_t=process.env.BOSTRAT_DEFAULT_CWD||process.env.HOME||"/",St=process.env.BOSTRAT_AGENT_CMD||"claude --dangerously-skip-permissions";async function Y(e,{loginShell:t=!1,failOpen:n=!1}={}){if(!e)return!1;let o=t?process.env.SHELL||"/bin/sh":"sh",r=t?"-lic":"-c";try{return await fe(o,[r,'command -v "$1" >/dev/null 2>&1',"_",e],{timeout:5e3}),!0}catch(s){return s?.code===1?!1:n}}var Ot=Number(process.env.BOSTRAT_PROMPT_CAPTURE_COLS)||100,bt=Number(process.env.BOSTRAT_PROMPT_CAPTURE_ROWS)||40,At=Number(process.env.BOSTRAT_PROMPT_CAPTURE_LINES)||80,Rt=Number(process.env.BOSTRAT_BOX_COLS)||120,xt=Number(process.env.BOSTRAT_BOX_ROWS)||40;var S=Ae(Oe),U=u.dirname(Ee(import.meta.url)),x=u.resolve(U,".."),ve=u.join(U,"index.js"),ke="wss://plane.bostrat.ai/v1/node",Ne=ee(import.meta.url)("../package.json").version,h=(e,t)=>({name:e,level:"pass",detail:t}),E=(e,t,n)=>({name:e,level:"warn",detail:t,fix:n}),y=(e,t,n)=>({name:e,level:"fail",detail:t,fix:n});async function Pe(){let[e,t]=process.versions.node.split(".").map(Number);return e>22||e===22&&t>=5?h("node runtime",`${process.version} at ${process.execPath}`):y("node runtime",`${process.version} < 22.5`,"install Node \u226522.5 via nvm and re-run under it")}function $e(e){let t;try{t=w.statSync(e)}catch{return E("node.env",`${e} missing`,"run `bostrat-node init`")}let n=t.mode&511;return n&63?E("node.env",`${e} mode ${n.toString(8)} \u2014 group/world readable and it can hold a key`,`chmod 600 ${e}`):h("node.env",`${e} (0600)`)}async function Be(e){let t=e.BOSTRAT_TMUX_BIN||"/usr/bin/tmux";try{let{stdout:n}=await S(t,["-V"],{timeout:5e3});return h("tmux",`${t} (${n.trim()})`)}catch{return y("tmux",`${t} not runnable`,process.platform==="darwin"?"brew install tmux (then BOSTRAT_TMUX_BIN=/opt/homebrew/bin/tmux)":"install tmux")}}async function D(e,{required:t=!1}={}){if(await Y(e,{loginShell:!0,failOpen:!1}))return h(e,"resolves on the login-shell PATH");let o="not on the login-shell PATH";return t?y(e,o,`install ${e} so \`$SHELL -lic 'command -v ${e}'\` finds it`):E(e,o)}async function Ie(){let e=await Promise.all(["claude","codex","cursor-agent"].map(t=>D(t)));return e.some(t=>t.level==="pass")||e.push(y("agent CLIs","no agent CLI found at all \u2014 a node with nothing to drive","install at least one of claude / codex / cursor-agent")),e}async function Ce(){try{let t=ee(u.join(x,"src","node-cli.js"))("node-pty");return await new Promise((n,o)=>{let r=t.spawn("/bin/echo",["ok"],{cols:20,rows:5}),s=setTimeout(()=>o(new Error("spawn timeout")),5e3);r.onExit(()=>{clearTimeout(s),n()})}),h("node-pty","loads and spawns under this runtime")}catch(e){return y("node-pty",`load/spawn failed: ${e?.message||e}`,`cd ${x} && npm rebuild node-pty # with THIS node first on PATH \u2014 never the system npm`)}}function Le(e){let t=e.BOSTRAT_CHROMIUM_BIN||"/usr/bin/chromium";return w.existsSync(t)?h("chromium (mocks)",t):E("chromium (mocks)",`${t} missing \u2014 mock rendering unavailable`,"install Chromium/Chrome and set BOSTRAT_CHROMIUM_BIN")}function je(e){let t=e.BOSTRAT_CLAUDE_USE_API_KEY==="1";return t&&!e.ANTHROPIC_API_KEY?y("claude lane","BOSTRAT_CLAUDE_USE_API_KEY=1 but ANTHROPIC_API_KEY is empty","add the key to node.env or set the flag to 0"):h("claude lane",t?"BYO API key (injected per new box)":"box-local login (subscription \u2014 you type `claude login` inside the box)")}async function De(e,{WebSocketImpl:t}={}){if(!e.BOSTRAT_PLANE_URL||!e.BOSTRAT_PLANE_TOKEN)return E("plane link","BOSTRAT_PLANE_URL/TOKEN unset \u2014 node runs pure M1 (local only)","run `bostrat-node init`");let n=t||(await import("ws")).default,o=Date.now();return await new Promise(r=>{let s=new n(e.BOSTRAT_PLANE_URL,{headers:{authorization:`Bearer ${e.BOSTRAT_PLANE_TOKEN}`}}),i=c=>{clearTimeout(a);try{s.close()}catch{}r(c)},a=setTimeout(()=>i(y("plane link",`no hello_ok within 5s from ${e.BOSTRAT_PLANE_URL}`,"check the URL, the token, and the plane's IP gate")),5e3);s.on("open",()=>s.send(JSON.stringify({v:1,ch:"ctl",type:"hello",nodeId:`doctor-${xe().slice(0,8)}`}))),s.on("message",c=>{try{let f=JSON.parse(c);f.type==="hello_ok"?i(h("plane link",`hello_ok in ${Date.now()-o}ms (${e.BOSTRAT_PLANE_URL})`)):f.type==="error"&&i(y("plane link",`plane said: ${f.code} ${f.message||""}`,"check the token"))}catch{}}),s.on("error",c=>i(y("plane link",`${c?.message||c}`,"check the URL, the token, and the plane's IP gate")))})}function Ue(e){return e.BOSTRAT_STATE_REMOTE?h("state remote",`${e.BOSTRAT_STATE_REMOTE} (this node's own \u2014 never another node's repo)`):E("state remote","unset \u2014 state syncs to a local repo only, no off-box durability","create a per-node private repo and set BOSTRAT_STATE_REMOTE")}async function te(e,t={}){let n=[];return n.push(await Pe()),n.push($e(t.envFile||A())),n.push(await Be(e)),n.push(...await Ie()),n.push(await D("git",{required:!0})),n.push(await D("gh")),n.push(await Ce()),n.push(Le(e)),n.push(je(e)),n.push(await De(e,t)),n.push(Ue(e)),n}function ne(e,t=console.log){let n={pass:"\u2713",warn:"!",fail:"\u2717"};for(let s of e)t(`${n[s.level]} ${s.name}: ${s.detail}`),s.fix&&s.level!=="pass"&&t(` fix: ${s.fix}`);let o=e.filter(s=>s.level==="fail").length,r=e.filter(s=>s.level==="warn").length;return t(o?`
94
+ `,{mode:384}),$.chmodSync(e,384)}function Y(e=process.platform){return e==="darwin"?{BOSTRAT_TMUX_BIN:"/opt/homebrew/bin/tmux",BOSTRAT_TMUX_SOCKET:`/tmp/tmux-${process.getuid?.()??501}/bostrat`,BOSTRAT_CHROMIUM_BIN:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}:{}}import{execFile as pe}from"node:child_process";import{promisify as fe}from"node:util";import ue from"node:os";import z from"node:path";var de=process.env.BOSTRAT_DEBUG_DIR||z.join(ue.homedir(),".bostrat","debug"),st=z.join(de,"handoff.jsonl"),rt=Number(process.env.BOSTRAT_HANDOFF_DEBUG_MAX)||500;var me=fe(pe);var Tt=process.env.BOSTRAT_TMUX_BIN||"/usr/bin/tmux",_t=process.env.BOSTRAT_TMUX_SOCKET||"/tmp/tmux-1000/default",St=process.env.BOSTRAT_DEFAULT_CWD||process.env.HOME||"/",Ot=process.env.BOSTRAT_AGENT_CMD||"claude --dangerously-skip-permissions";async function G(e,{loginShell:t=!1,failOpen:n=!1}={}){if(!e)return!1;let o=t?process.env.SHELL||"/bin/sh":"sh",r=t?"-lic":"-c";try{return await me(o,[r,'command -v "$1" >/dev/null 2>&1',"_",e],{timeout:5e3}),!0}catch(s){return s?.code===1?!1:n}}var bt=Number(process.env.BOSTRAT_PROMPT_CAPTURE_COLS)||100,At=Number(process.env.BOSTRAT_PROMPT_CAPTURE_ROWS)||40,xt=Number(process.env.BOSTRAT_PROMPT_CAPTURE_LINES)||80,Rt=Number(process.env.BOSTRAT_BOX_COLS)||120,vt=Number(process.env.BOSTRAT_BOX_ROWS)||40;var O=xe(be),M=d.dirname(Ee(import.meta.url)),b=d.resolve(M,".."),ke=d.join(M,"index.js"),Ne="wss://plane.bostrat.ai/v1/node",Pe=D(import.meta.url)("../package.json").version,w=(e,t)=>({name:e,level:"pass",detail:t}),R=(e,t,n)=>({name:e,level:"warn",detail:t,fix:n}),h=(e,t,n)=>({name:e,level:"fail",detail:t,fix:n});async function $e(){let[e,t]=process.versions.node.split(".").map(Number);return e>22||e===22&&t>=5?w("node runtime",`${process.version} at ${process.execPath}`):h("node runtime",`${process.version} < 22.5`,"install Node \u226522.5 via nvm and re-run under it")}function Ie(e){let t;try{t=m.statSync(e)}catch{return R("node.env",`${e} missing`,"run `bostrat-node init`")}let n=t.mode&511;return n&63?R("node.env",`${e} mode ${n.toString(8)} \u2014 group/world readable and it can hold a key`,`chmod 600 ${e}`):w("node.env",`${e} (0600)`)}async function Be(e){let t=e.BOSTRAT_TMUX_BIN||"/usr/bin/tmux";try{let{stdout:n}=await O(t,["-V"],{timeout:5e3});return w("tmux",`${t} (${n.trim()})`)}catch{return h("tmux",`${t} not runnable`,process.platform==="darwin"?"brew install tmux (then BOSTRAT_TMUX_BIN=/opt/homebrew/bin/tmux)":"install tmux")}}async function F(e,{required:t=!1}={}){if(await G(e,{loginShell:!0,failOpen:!1}))return w(e,"resolves on the login-shell PATH");let o="not on the login-shell PATH";return t?h(e,o,`install ${e} so \`$SHELL -lic 'command -v ${e}'\` finds it`):R(e,o)}async function Ce(){let e=await Promise.all(["claude","codex","cursor-agent"].map(t=>F(t)));return e.some(t=>t.level==="pass")||e.push(h("agent CLIs","no agent CLI found at all \u2014 a node with nothing to drive","install at least one of claude / codex / cursor-agent")),e}async function je(){try{let t=D(d.join(b,"src","node-cli.js"))("node-pty");return await new Promise((n,o)=>{let r=t.spawn("/bin/echo",["ok"],{cols:20,rows:5}),s=setTimeout(()=>o(new Error("spawn timeout")),5e3);r.onExit(()=>{clearTimeout(s),n()})}),w("node-pty","loads and spawns under this runtime")}catch(e){let t=`cd ${b} && npm rebuild node-pty # with THIS node first on PATH \u2014 never the system npm`;try{let n=D(d.join(b,"package.json")),o=d.join(d.dirname(n.resolve("node-pty/package.json")),"prebuilds",`${process.platform}-${process.arch}`,"spawn-helper");m.existsSync(o)&&!(m.statSync(o).mode&73)&&(t=`chmod +x ${o} # node-pty ships it non-executable`)}catch{}return h("node-pty",`load/spawn failed: ${e?.message||e}`,t)}}function Le(e){let t=e.BOSTRAT_CHROMIUM_BIN||"/usr/bin/chromium";return m.existsSync(t)?w("chromium (mocks)",t):R("chromium (mocks)",`${t} missing \u2014 mock rendering unavailable`,"install Chromium/Chrome and set BOSTRAT_CHROMIUM_BIN")}function Ue(e){let t=e.BOSTRAT_CLAUDE_USE_API_KEY==="1";return t&&!e.ANTHROPIC_API_KEY?h("claude lane","BOSTRAT_CLAUDE_USE_API_KEY=1 but ANTHROPIC_API_KEY is empty","add the key to node.env or set the flag to 0"):w("claude lane",t?"BYO API key (injected per new box)":"box-local login (subscription \u2014 you type `claude login` inside the box)")}async function De(e,{WebSocketImpl:t}={}){if(!e.BOSTRAT_PLANE_URL||!e.BOSTRAT_PLANE_TOKEN)return R("plane link","BOSTRAT_PLANE_URL/TOKEN unset \u2014 node runs pure M1 (local only)","run `bostrat-node init`");let n=t||(await import("ws")).default,o=Date.now(),r=U(e.BOSTRAT_PLANE_URL);return await new Promise(s=>{let i=new n(r,{headers:{authorization:`Bearer ${e.BOSTRAT_PLANE_TOKEN}`}}),a=p=>{clearTimeout(l);try{i.close()}catch{}s(p)},l=setTimeout(()=>a(h("plane link",`no hello_ok within 5s from ${r}`,"check the URL, the token, and the plane's IP gate")),5e3);i.on("open",()=>i.send(JSON.stringify({v:1,ch:"ctl",type:"hello",nodeId:`doctor-${ve().slice(0,8)}`}))),i.on("message",p=>{try{let u=JSON.parse(p);u.type==="hello_ok"?a(w("plane link",`hello_ok in ${Date.now()-o}ms (${r})`)):u.type==="error"&&a(h("plane link",`plane said: ${u.code} ${u.message||""}`,"check the token"))}catch{}}),i.on("error",p=>a(h("plane link",`${p?.message||p}`,"check the URL, the token, and the plane's IP gate")))})}function Fe(e){return e.BOSTRAT_STATE_REMOTE?w("state remote",`${e.BOSTRAT_STATE_REMOTE} (this node's own \u2014 never another node's repo)`):R("state remote","unset \u2014 state syncs to a local repo only, no off-box durability","create a per-node private repo and set BOSTRAT_STATE_REMOTE")}async function ne(e,t={}){let n=[];return n.push(await $e()),n.push(Ie(t.envFile||A())),n.push(await Be(e)),n.push(...await Ce()),n.push(await F("git",{required:!0})),n.push(await F("gh")),n.push(await je()),n.push(Le(e)),n.push(Ue(e)),n.push(await De(e,t)),n.push(Fe(e)),n}function oe(e,t=console.log){let n={pass:"\u2713",warn:"!",fail:"\u2717"};for(let s of e)t(`${n[s.level]} ${s.name}: ${s.detail}`),s.fix&&s.level!=="pass"&&t(` fix: ${s.fix}`);let o=e.filter(s=>s.level==="fail").length,r=e.filter(s=>s.level==="warn").length;return t(o?`
95
95
  FAIL \u2014 ${o} blocking, ${r} warnings`:`
96
- OK \u2014 0 blocking, ${r} warnings`),o===0}async function Fe({envFile:e=A(),input:t=process.stdin,output:n=process.stdout}={}){let o=C(e),r=Re.createInterface({input:t,output:n}),s=async(O,b)=>(await r.question(b?`${O} [${b}]: `:`${O}: `)).trim()||b||"";n.write(`bostrat-node init \u2014 plane link + machine config. No vendor logins here:
96
+ OK \u2014 0 blocking, ${r} warnings`),o===0}async function Me({envFile:e=A(),input:t=process.stdin,output:n=process.stdout}={}){let o=I(e),r=Re.createInterface({input:t,output:n}),s=async(_,c)=>(await r.question(c?`${_} [${c}]: `:`${_}: `)).trim()||c||"";n.write(`bostrat-node init \u2014 plane link + machine config. No vendor logins here:
97
97
  you type those inside each box, later (box-auth-policy).
98
98
 
99
- `);let i=await s("Plane URL",o.BOSTRAT_PLANE_URL||ke),a=await s("Node token (minted plane-side; stored 0600)",o.BOSTRAT_PLANE_TOKEN),c=await s("Owner userId (shown at mint; empty = infer from token)",o.BOSTRAT_OWNER||""),f=await s("Node name",o.BOSTRAT_NODE_NAME||R.hostname().split(".")[0]),d=await s("Repos root",o.BOSTRAT_REPOS_ROOT||u.join(R.homedir(),"Documents")),k=await s("State remote (per-node private repo; empty = local-only)",o.BOSTRAT_STATE_REMOTE||""),g=(await s("Route NEW claude boxes through a BYO API key? (y/N)",o.BOSTRAT_CLAUDE_USE_API_KEY==="1"?"y":"N")).toLowerCase().startsWith("y");g&&n.write(`
99
+ `);let i=await s("Plane URL",o.BOSTRAT_PLANE_URL||Ne),a=U(i);a!==i.trim()&&n.write(` \u2192 using ${a}
100
+ `);let l=await s("Node token (minted plane-side; stored 0600)",o.BOSTRAT_PLANE_TOKEN),p=await s("Owner userId (shown at mint; empty = infer from token)",o.BOSTRAT_OWNER||"");p&&!/^user_[A-Za-z0-9]+$/.test(p)&&n.write(` ! that doesn't look like a Clerk userId (user_\u2026) \u2014 leave it empty next time and the plane infers the owner from the token; saved as typed.
101
+ `);let u=await s("Node name",o.BOSTRAT_NODE_NAME||x.hostname().split(".")[0]),k=await s("Repos root",o.BOSTRAT_REPOS_ROOT||d.join(x.homedir(),"Documents")),C=await s("State remote (per-node private repo; empty = local-only)",o.BOSTRAT_STATE_REMOTE||""),g=(await s("Route NEW claude boxes through a BYO API key? (y/N)",o.BOSTRAT_CLAUDE_USE_API_KEY==="1"?"y":"N")).toLowerCase().startsWith("y");g&&n.write(`
100
102
  BYO API key (box-auth-policy rule 5): claude boxes on this node bill to YOUR key,
101
103
  injected per box, stored 0600 in node.env, never sent to the plane.
102
104
  \u2022 create/copy a key: https://console.anthropic.com/settings/keys
103
105
  \u2022 set a monthly spend limit while you're there \u2014 the key is live.
104
106
 
105
107
  `);let v=g?await s("ANTHROPIC_API_KEY (starts sk-ant-)",o.ANTHROPIC_API_KEY):"";g&&v&&!/^sk-ant-/.test(v)&&n.write(` ! that doesn't look like an Anthropic key (expected sk-ant-\u2026) \u2014 saved as-is; re-run init to correct.
106
- `),r.close();let N={...H(),...o,BOSTRAT_PLANE_URL:i,BOSTRAT_PLANE_TOKEN:a,BOSTRAT_OWNER:c,BOSTRAT_NODE_NAME:f,BOSTRAT_REPOS_ROOT:d,BOSTRAT_STATE_REMOTE:k,BOSTRAT_CLAUDE_USE_API_KEY:g?"1":"0",ANTHROPIC_API_KEY:g?v:o.ANTHROPIC_API_KEY};K(e,N,{header:`bostrat node config \u2014 written by \`bostrat-node init\` ${new Date().toISOString()}
108
+ `),r.close();let E={...Y(),...o,BOSTRAT_PLANE_URL:a,BOSTRAT_PLANE_TOKEN:l,BOSTRAT_OWNER:p,BOSTRAT_NODE_NAME:u,BOSTRAT_REPOS_ROOT:k,BOSTRAT_STATE_REMOTE:C,BOSTRAT_CLAUDE_USE_API_KEY:g?"1":"0",ANTHROPIC_API_KEY:g?v:o.ANTHROPIC_API_KEY};W(e,E,{header:`bostrat node config \u2014 written by \`bostrat-node init\` ${new Date().toISOString()}
107
109
  0600: BOSTRAT_PLANE_TOKEN always lives here, ANTHROPIC_API_KEY may. Never commit.
108
110
  Bind host: unset = loopback-only while plane-linked; BOSTRAT_HOST=all restores bind-all (LAN).`}),n.write(`
109
111
  wrote ${e}
110
112
 
111
- `);let P={...N,...process.env},$=await te(P,{envFile:e}),T=ne($,O=>n.write(O+`
112
- `));return T&&n.write("\nnext: `bostrat-node run` (foreground) or `bostrat-node install-service`\n"),{ok:T,results:$}}function Me({envFile:e=A()}={}){M(e);let t=process.env.BOSTRAT_NODE_BIN||process.execPath,n=be(t,[ve],{cwd:x,stdio:"inherit",env:process.env});for(let o of["SIGINT","SIGTERM"])process.on(o,()=>n.kill(o));return n.on("exit",(o,r)=>process.exit(r?1:o??1)),n}function Ke({agentDir:e=x,nodeBin:t=process.execPath,envFile:n=A(),home:o=R.homedir()}={}){let r=u.dirname(t),s=u.join(u.basename(U),"index.js");return`# bostrat node \u2014 written by \`bostrat-node install-service\`. Config lives in
113
+ `);let j={...E,...process.env},T=await ne(j,{envFile:e}),N=oe(T,_=>n.write(_+`
114
+ `));return N&&n.write("\nnext: `bostrat-node run` (foreground) or `bostrat-node install-service`\n"),{ok:N,results:T}}function Ke({envFile:e=A()}={}){H(e);let t=process.env.BOSTRAT_NODE_BIN||process.execPath,n=Ae(t,[ke],{cwd:b,stdio:"inherit",env:process.env});for(let o of["SIGINT","SIGTERM"])process.on(o,()=>n.kill(o));return n.on("exit",(o,r)=>process.exit(r?1:o??1)),n}function He({agentDir:e=b,nodeBin:t=process.execPath,envFile:n=A(),home:o=x.homedir()}={}){let r=d.dirname(t),s=d.join(d.basename(M),"index.js");return`# bostrat node \u2014 written by \`bostrat-node install-service\`. Config lives in
113
115
  # ${n} (edit + \`systemctl --user restart bostrat-node\`), not here.
114
116
  [Unit]
115
117
  Description=bostrat node \u2014 box runtime dialing out to the coordination plane (plane-p1-package-node-scope-2026-07-14.md)
@@ -129,7 +131,7 @@ RestartSec=2
129
131
 
130
132
  [Install]
131
133
  WantedBy=default.target
132
- `}function He({agentDir:e=x,nodeBin:t=process.execPath,home:n=R.homedir()}={}){let o=u.dirname(t),r=`${n}/Library/Logs/bostrat`;return`<?xml version="1.0" encoding="UTF-8"?>
134
+ `}function We({agentDir:e=b,nodeBin:t=process.execPath,home:n=x.homedir()}={}){let o=d.dirname(t),r=`${n}/Library/Logs/bostrat`;return`<?xml version="1.0" encoding="UTF-8"?>
133
135
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
134
136
  <plist version="1.0">
135
137
  <dict>
@@ -151,7 +153,7 @@ WantedBy=default.target
151
153
  <key>StandardErrorPath</key><string>${r}/node.err.log</string>
152
154
  </dict>
153
155
  </plist>
154
- `}function We(e=process.platform,t=R.homedir()){return e==="darwin"?{kind:"launchd",file:u.join(t,"Library","LaunchAgents","com.bostrat.node.plist")}:{kind:"systemd",file:u.join(t,".config","systemd","user","bostrat-node.service")}}async function Ye({uninstall:e=!1,start:t=!0,platform:n=process.platform,log:o=console.log,agentDir:r=x}={}){let{kind:s,file:i}=We(n);if(!e&&r.split(u.sep).includes("_npx"))return o("\u2717 running from the npx cache \u2014 a service must point at a durable install."),o(" fix: npm install -g bostrat-node && bostrat-node install-service"),1;if(e){s==="systemd"?(await S("systemctl",["--user","disable","--now","bostrat-node.service"]).catch(()=>{}),w.rmSync(i,{force:!0}),await S("systemctl",["--user","daemon-reload"])):(await S("launchctl",["unload","-w",i]).catch(()=>{}),w.rmSync(i,{force:!0})),o(`removed ${i}`);return}w.mkdirSync(u.dirname(i),{recursive:!0}),s==="systemd"?(w.writeFileSync(i,Ke()),await S("systemctl",["--user","daemon-reload"]),t&&await S("systemctl",["--user","enable","--now","bostrat-node.service"]),o(`installed ${i}${t?" (enabled + started)":""}`),o("logs: journalctl --user -u bostrat-node.service -f")):(w.mkdirSync(u.join(R.homedir(),"Library","Logs","bostrat"),{recursive:!0}),w.writeFileSync(i,He()),t&&await S("launchctl",["load","-w",i]),o(`installed ${i}${t?" (loaded)":""}`),o("logs: ~/Library/Logs/bostrat/node.{out,err}.log"))}async function Gt(e=process.argv.slice(2)){let t=e[0],n=A();if(t==="--version"||t==="-v"||t==="version")return console.log(Ne),0;if(t==="init")return(await Fe({envFile:n})).ok?0:1;if(t==="doctor"){let o={...C(n),...process.env};return ne(await te(o,{envFile:n}))?0:1}if(t==="run"||t==="start")return Me({envFile:n}),null;if(t==="install-service")return await Ye({uninstall:e.includes("--uninstall"),start:!e.includes("--no-start")})||0;if(t==="fly"){let{flyWizard:o}=await Promise.resolve().then(()=>(Q(),Z));return await o({argv:e.slice(1)})}return console.log(`bostrat-node \u2014 install and run a bostrat node (plane P1)
156
+ `}function Ye(e=process.platform,t=x.homedir()){return e==="darwin"?{kind:"launchd",file:d.join(t,"Library","LaunchAgents","com.bostrat.node.plist")}:{kind:"systemd",file:d.join(t,".config","systemd","user","bostrat-node.service")}}async function ze({uninstall:e=!1,start:t=!0,platform:n=process.platform,log:o=console.log,agentDir:r=b}={}){let{kind:s,file:i}=Ye(n);if(!e&&r.split(d.sep).includes("_npx"))return o("\u2717 running from the npx cache \u2014 a service must point at a durable install."),o(" fix: npm install -g bostrat-node && bostrat-node install-service"),1;if(e){s==="systemd"?(await O("systemctl",["--user","disable","--now","bostrat-node.service"]).catch(()=>{}),m.rmSync(i,{force:!0}),await O("systemctl",["--user","daemon-reload"])):(await O("launchctl",["unload","-w",i]).catch(()=>{}),m.rmSync(i,{force:!0})),o(`removed ${i}`);return}m.mkdirSync(d.dirname(i),{recursive:!0}),s==="systemd"?(m.writeFileSync(i,He()),await O("systemctl",["--user","daemon-reload"]),t&&await O("systemctl",["--user","enable","--now","bostrat-node.service"]),o(`installed ${i}${t?" (enabled + started)":""}`),o("logs: journalctl --user -u bostrat-node.service -f")):(m.mkdirSync(d.join(x.homedir(),"Library","Logs","bostrat"),{recursive:!0}),m.writeFileSync(i,We()),t&&await O("launchctl",["load","-w",i]),o(`installed ${i}${t?" (loaded)":""}`),o("logs: ~/Library/Logs/bostrat/node.{out,err}.log"))}async function Gt(e=process.argv.slice(2)){let t=e[0],n=A();if(t==="--version"||t==="-v"||t==="version")return console.log(Pe),0;if(t==="init")return(await Me({envFile:n})).ok?0:1;if(t==="doctor"){let o={...I(n),...process.env};return oe(await ne(o,{envFile:n}))?0:1}if(t==="run"||t==="start")return Ke({envFile:n}),null;if(t==="install-service")return await ze({uninstall:e.includes("--uninstall"),start:!e.includes("--no-start")})||0;if(t==="fly"){let{flyWizard:o}=await Promise.resolve().then(()=>(te(),ee));return await o({argv:e.slice(1)})}return console.log(`bostrat-node \u2014 install and run a bostrat node (plane P1)
155
157
 
156
158
  usage: bostrat-node <init | doctor | run | install-service [--uninstall] [--no-start] | fly | --version>
157
159
 
@@ -159,4 +161,4 @@ usage: bostrat-node <init | doctor | run | install-service [--uninstall] [--no-s
159
161
  doctor check this machine (CLIs, tmux, node-pty, plane reachability)
160
162
  run start the node in the foreground (sources node.env)
161
163
  install-service run at boot/login: systemd --user (Linux) / launchd (macOS)
162
- fly provision this node on YOUR OWN Fly.io org (uses your flyctl)`),t?1:0}export{Fe as init,Ye as installService,He as launchdPlist,Gt as main,ne as printDoctor,Me as runAgent,te as runDoctor,We as servicePaths,Ke as systemdUnit};
164
+ fly provision this node on YOUR OWN Fly.io org (uses your flyctl)`),t?1:0}export{Me as init,ze as installService,We as launchdPlist,Gt as main,oe as printDoctor,Ke as runAgent,ne as runDoctor,Ye as servicePaths,He as systemdUnit};