@hallohuman/hightea 0.1.31 → 0.1.32

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/bin.js CHANGED
@@ -1,29 +1,35 @@
1
1
  #!/usr/bin/env node
2
- import{readFileSync as D}from"node:fs";import{fileURLToPath as C}from"node:url";import{Command as E,CommanderError as F}from"@silvery/commander";import{homedir as _}from"node:os";import{join as b}from"node:path";import{createInterface as A}from"node:readline/promises";var O="https://hightea.ai";function N(){return b(process.env.XDG_CONFIG_HOME??b(_(),".config"),"hightea","owner.json")}function I(c){let r=c.split("/");if(r.length!==2)return null;let[n,s]=r;if(n===void 0||s===void 0)return null;if(!/^[a-z0-9][a-z0-9-]{0,62}$/u.test(n))return null;if(!/^[A-Za-z0-9_-]{4,128}$/u.test(s))return null;return{slug:n,code:s}}async function S(c,r){let n=0,s=new E("hightea").description("Hightea: join this machine to a Hightea workspace as a host for your own agents.").version(r.version,"-v, --version").exitOverride();s.command("apply <file>").description("Apply a native process-compose file, or a TypeScript program that returns a plan: to one machine's ahpd, and a plan's hosts as join links the machines consume. Preview first, write only with --yes.").option("--machine <url>","The machine's ahpd WebSocket endpoint, e.g. ws://127.0.0.1:7777; required unless the plan names only hosts").option("--token <token>","The machine's token for this client (default: AHP_TKN)").option("--yes","Send the previewed changes; without it nothing is sent").option("--prune","After the preview lists them, remove entries this same source created that the plan no longer carries").option("--stop","With --prune: stop each program, then remove its entry").option("--keep","With --prune: leave each program running here and clear its source, so it is no longer pruned").option("--origin <url>","The deployment, for host entries: the workspace mints their join links as you").option("--workspace <slug>","The workspace slug, with --origin, for host entries").option("--session-file <file>","The ht_session cookie file for the person routes (default: your stored sign-in)").option("--json","Print one JSON document").addHelpText("after",`
3
- Exit status: 0 previewed or applied; 1 the machine or the workspace refused the plan, or could not be reached.`).exitOverride().action(async(e,o)=>{let{applyFile:t}=await import("./chunk-8rbp82rh.js");n=await t(e,{machine:o.machine??"",token:o.token??process.env.AHP_TKN,yes:o.yes===!0,prune:o.prune===!0,stop:o.stop===!0,keep:o.keep===!0,origin:o.origin??"",workspace:o.workspace??"",sessionFile:o.sessionFile,json:o.json===!0})}),s.command("connect <target>").description("Connect this computer to a workspace: run the one command the Hightea page shows.").option("--origin <url>",`The deployment (default: ${O})`).option("--owner-config <file>","This computer's agent apps, provider plugins and credentials (default: your Hightea config directory)").option("--app <app>","The agent app to run here, when this computer can run more than one (skips the question)").addHelpText("after",`
4
- Exit status: 0 connected; 2 pending, rerun the same command; 3 not authorised for that workspace; 1 any other failure, named on stderr.`).exitOverride().action(async(e,o)=>{let t=I(e);if(t===null){console.error(`connect: '${e}' is not <workspace>/<code>. Copy the whole command from the workspace's Add a computer step.`),n=1;return}let i;if(o.ownerConfig===void 0||o.app!==void 0){let{agentAppsOnPath:m,describedApp:j,installLineOf:a,isShippedApp:y,noAgentAppsLine:H}=await import("./chunk-db8mr7mp.js"),g=await m();if(o.app===void 0){if(g.length===0){console.error(H()),n=1;return}let w=g.length===1?g[0]:await L(g);if(w===void 0){n=1;return}i=w.id}else if(!y(o.app)){console.error(`connect: '${o.app}' is not an agent app this command can add. Run connect without --app to see the ones this computer can run.`),n=1;return}else{let w=g.find((v)=>v.id===o.app);if(w===void 0){let v=j(o.app);console.error(`${v.name} is not on this computer: install it with \`${a(v)}\`, then run the same command again. Nothing was redeemed and nothing was written.`),n=1;return}i=w.id}}let{hostJoin:p}=await import("./chunk-xy8j3npr.js"),T=o.ownerConfig===void 0;n=await p({origin:o.origin??O,workspace:t.slug,code:t.code,ownerConfig:o.ownerConfig??N(),ownerConfigIsDefault:T,...i===void 0?{}:{app:i,workingDirectory:process.cwd()}},{directory:r.pluginDirectory,version:r.version})});let d=s.command("host").description("Hosts: this machine joining a workspace, and the workspace's registered hosts.").exitOverride();d.command("join").description("Join this machine to a workspace with a one-use host join code from the workspace owner (the long form of connect).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--code <code>","The one-use join code").option("--owner-config <file>","Your owner configuration: agents, provider plugins and their credentials").option("--host <id>","The host this machine already is: add this code's agents to it instead of registering another computer").addHelpText("after",`
2
+ import{readFileSync as W}from"node:fs";import{fileURLToPath as M}from"node:url";import{Command as I,CommanderError as N}from"@silvery/commander";import{homedir as C,userInfo as L}from"node:os";import{join as H}from"node:path";import{createInterface as R}from"node:readline/promises";var O="HAB_SESSION_LAUNCH_ID";function D(a=process.env){let s=a[O]?.trim()??"";return s===""?{kind:"person",id:`local:${L().username}`}:{kind:"agent",id:`hab-session:${s}`}}function f(a=process.env){let s=D(a);if(s.kind==="agent"){let t=a[O]?.trim()??"";console.error(`refused: this shell carries ${O}=${t}, so it acts as agent ${s.id}; grants and key trust are a person's act. Run it from your own terminal.`)}return s}var _="https://hightea.ai";function P(){return H(process.env.XDG_CONFIG_HOME??H(C(),".config"),"hightea","owner.json")}function J(a){let s=a.split("/");if(s.length!==2)return null;let[t,r]=s;if(t===void 0||r===void 0)return null;if(!/^[a-z0-9][a-z0-9-]{0,62}$/u.test(t))return null;if(!/^[A-Za-z0-9_-]{4,128}$/u.test(r))return null;return{slug:t,code:r}}async function F(a,s){let t=0,r=new I("hightea").description("Hightea: join this machine to a Hightea workspace as a host for your own agents.").version(s.version,"-v, --version").exitOverride();r.command("apply <file>").description("Apply a native process-compose file, or a TypeScript program that returns a plan: to one machine's ahpd, and a plan's hosts as join links the machines consume. Preview first, write only with --yes.").option("--machine <url>","The machine's ahpd WebSocket endpoint, e.g. ws://127.0.0.1:7777; required unless the plan names only hosts").option("--token <token>","The machine's token for this client (default: AHP_TKN)").option("--yes","Send the previewed changes; without it nothing is sent").option("--prune","After the preview lists them, remove entries this same source created that the plan no longer carries").option("--stop","With --prune: stop each program, then remove its entry").option("--keep","With --prune: leave each program running here and clear its source, so it is no longer pruned").option("--origin <url>","The deployment, for host entries: the workspace mints their join links as you").option("--workspace <slug>","The workspace slug, with --origin, for host entries").option("--session-file <file>","The ht_session cookie file for the person routes (default: your stored sign-in)").option("--json","Print one JSON document").addHelpText("after",`
3
+ Exit status: 0 previewed or applied; 1 the machine or the workspace refused the plan, or could not be reached.`).exitOverride().action(async(e,o)=>{let{applyFile:n}=await import("./chunk-749gsvce.js");t=await n(e,{machine:o.machine??"",token:o.token??process.env.AHP_TKN,yes:o.yes===!0,prune:o.prune===!0,stop:o.stop===!0,keep:o.keep===!0,origin:o.origin??"",workspace:o.workspace??"",sessionFile:o.sessionFile,json:o.json===!0})}),r.command("connect <target>").description("Connect this computer to a workspace: run the one command the Hightea page shows.").option("--origin <url>",`The deployment (default: ${_})`).option("--owner-config <file>","This computer's agent apps, provider plugins and credentials (default: your Hightea config directory)").option("--app <app>","The agent app to run here, when this computer can run more than one (skips the question)").addHelpText("after",`
4
+ Exit status: 0 connected; 2 pending, rerun the same command; 3 not authorised for that workspace; 1 any other failure, named on stderr.`).exitOverride().action(async(e,o)=>{let n=J(e);if(n===null){console.error(`connect: '${e}' is not <workspace>/<code>. Copy the whole command from the workspace's Add a computer step.`),t=1;return}let i;if(o.ownerConfig===void 0||o.app!==void 0){let{agentAppsOnPath:m,describedApp:j,installLineOf:c,isShippedApp:v,noAgentAppsLine:A}=await import("./chunk-hrtxeg8j.js"),g=await m();if(o.app===void 0){if(g.length===0){console.error(A()),t=1;return}let w=g.length===1?g[0]:await G(g);if(w===void 0){t=1;return}i=w.id}else if(!v(o.app)){console.error(`connect: '${o.app}' is not an agent app this command can add. Run connect without --app to see the ones this computer can run.`),t=1;return}else{let w=g.find((T)=>T.id===o.app);if(w===void 0){let T=j(o.app);console.error(`${T.name} is not on this computer: install it with \`${c(T)}\`, then run the same command again. Nothing was redeemed and nothing was written.`),t=1;return}i=w.id}}let{hostJoin:d}=await import("./chunk-gbwfgq6g.js"),x=o.ownerConfig===void 0;t=await d({origin:o.origin??_,workspace:n.slug,code:n.code,ownerConfig:o.ownerConfig??P(),ownerConfigIsDefault:x,...i===void 0?{}:{app:i,workingDirectory:process.cwd()}},{directory:s.pluginDirectory,version:s.version})});let h=r.command("host").description("Hosts: this machine joining a workspace, and the workspace's registered hosts.").exitOverride();h.command("join").description("Join this machine to a workspace with a one-use host join code from the workspace owner (the long form of connect).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--code <code>","The one-use join code").option("--owner-config <file>","Your owner configuration: agents, provider plugins and their credentials").option("--host <id>","The host this machine already is: add this code's agents to it instead of registering another computer").addHelpText("after",`
5
5
  Exit status: 0 registered; 2 pending, rerun the same command; 3 not authorised for that workspace or agent;
6
- 4 an agent is already bound to another host; 1 any other failure.`).exitOverride().action(async(e)=>{let{hostJoin:o}=await import("./chunk-xy8j3npr.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",code:e.code??"",ownerConfig:e.ownerConfig??"",...e.host===void 0?{}:{hostId:e.host}},{directory:r.pluginDirectory,version:r.version})}),d.command("list").description("List the workspace's registered hosts and which agents each runs; a workspace owner sees every host.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
7
- Exit status: 0 listed; 3 your account is not a person of this workspace; 1 any other failure.`).exitOverride().action(async(e)=>{let{hostList:o}=await import("./chunk-19pwmgzg.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",sessionFile:e.sessionFile,json:e.json===!0})}),d.command("remove").description("Remove a registered host from a workspace, as the workspace owner; its agents need a new join code.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--host <id>","The registered host's id, e.g. host_01").option("--remove-agents","Also delete the agents this computer ran; without it they stay members and can join again").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
8
- Exit status: 0 removed or already removed; 3 your account is not this workspace's owner; 1 any other failure, including an unknown host id.`).exitOverride().action(async(e)=>{let{hostRemove:o}=await import("./chunk-19pwmgzg.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",host:e.host??"",removeAgents:e.removeAgents===!0,sessionFile:e.sessionFile,json:e.json===!0})}),d.command("status").description("Show every joined host on this machine and whether its plugin bundle is intact. Changes nothing.").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostStatus:o}=await import("./chunk-xy8j3npr.js");n=await o({version:r.version,json:e.json===!0})}),d.command("update").description("Move a joined host on this machine to this CLI's plugin bundle; same host id and credentials. Restart the host after.").option("--host <id>","The joined host's id, when this machine holds more than one").addHelpText("after",`
6
+ 4 an agent is already bound to another host; 1 any other failure.`).exitOverride().action(async(e)=>{let{hostJoin:o}=await import("./chunk-gbwfgq6g.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",code:e.code??"",ownerConfig:e.ownerConfig??"",...e.host===void 0?{}:{hostId:e.host}},{directory:s.pluginDirectory,version:s.version})}),h.command("list").description("List the workspace's registered hosts and which agents each runs; a workspace owner sees every host.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
7
+ Exit status: 0 listed; 3 your account is not a person of this workspace; 1 any other failure.`).exitOverride().action(async(e)=>{let{hostList:o}=await import("./chunk-7mgx0krk.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",sessionFile:e.sessionFile,json:e.json===!0})}),h.command("remove").description("Remove a registered host from a workspace, as the workspace owner; its agents need a new join code.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--host <id>","The registered host's id, e.g. host_01").option("--remove-agents","Also delete the agents this computer ran; without it they stay members and can join again").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
8
+ Exit status: 0 removed or already removed; 3 your account is not this workspace's owner; 1 any other failure, including an unknown host id.`).exitOverride().action(async(e)=>{let{hostRemove:o}=await import("./chunk-7mgx0krk.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",host:e.host??"",removeAgents:e.removeAgents===!0,sessionFile:e.sessionFile,json:e.json===!0})}),h.command("status").description("Show every joined host on this machine and whether its plugin bundle is intact. Changes nothing.").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostStatus:o}=await import("./chunk-gbwfgq6g.js");t=await o({version:s.version,json:e.json===!0})}),h.command("update").description("Move a joined host on this machine to this CLI's plugin bundle; same host id and credentials. Restart the host after.").option("--host <id>","The joined host's id, when this machine holds more than one").addHelpText("after",`
9
9
  The old bundle is kept until the host has connected once on the new one; a later update removes it.
10
10
  A bundle newer than this CLI's is refused (HOST_UPDATE_DOWNGRADE).
11
- Exit status: 0 updated or already current; 1 any refusal, named on stderr.`).exitOverride().action(async(e)=>{let{hostUpdate:o}=await import("./chunk-xy8j3npr.js");n=await o({host:e.host},{directory:r.pluginDirectory,version:r.version})});let l=d.command("trust").description("The older spelling of `hightea browsers`; the same file backs both, and the key commands also serve computer-to-computer asks.").addHelpText("after",`
11
+ Exit status: 0 updated or already current; 1 any refusal, named on stderr.`).exitOverride().action(async(e)=>{let{hostUpdate:o}=await import("./chunk-gbwfgq6g.js");t=await o({host:e.host},{directory:s.pluginDirectory,version:s.version})});let l=h.command("trust").description("The older spelling of `hightea browsers`; the same file backs both, and the key commands also serve computer-to-computer asks.").addHelpText("after",`
12
12
  What it protects against: an ask forged by a compromised Hightea server or database.
13
13
  What it does not: a compromised page script, since the script that signs comes from Hightea, or a process
14
14
  running as this machine's user, which can edit trusted-keys.json as it can config.json.`).exitOverride();l.command("add").description("Trust a browser's (or another host's) public key, under a name of your choosing.").argument("<name>","A name for the key, e.g. the browser it came from").argument("<public-key>","The raw Ed25519 public key, base64url, as the browser's Members page shows it").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").addHelpText("after",`
15
- Exit status: 0 trusted or already trusted; 1 any failure, with the file left unchanged.`).exitOverride().action(async(e,o,t)=>{let{hostTrust:i}=await import("./chunk-8x5daqht.js");n=await i({action:"add",name:e,publicKey:o,...t.host===void 0?{}:{host:t.host},...t.configDir===void 0?{}:{configDir:t.configDir}})}),l.command("remove").description("Stop trusting the key with this name; asks signed with it are refused from then on.").argument("<name>","The key's name, as `hightea host trust list` shows it").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").addHelpText("after",`
16
- Exit status: 0 removed; 1 any failure, including an unknown name, with the file left unchanged.`).exitOverride().action(async(e,o)=>{let{hostTrust:t}=await import("./chunk-8x5daqht.js");n=await t({action:"remove",name:e,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})}),l.command("list").description("List the keys this machine trusts. Changes nothing.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to read, when the running host is not found").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostTrust:o}=await import("./chunk-8x5daqht.js");n=await o({action:"list",json:e.json===!0,...e.host===void 0?{}:{host:e.host},...e.configDir===void 0?{}:{configDir:e.configDir}})}),s.command("approve <code>").description("Approve a browser to ask this computer's agents, using the code that browser shows.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").option("--origin <url>","The deployment, when this machine's claim does not record it").option("--workspace <slug>","The workspace slug, when this machine's claim does not record it").option("--json","Print one JSON document").addHelpText("after",`
17
- Then come back to the browser: the message that asked sends itself. Exit status: 0 approved; 1 anything else, named on stderr, with the trusted-keys file left unchanged.`).exitOverride().action(async(e,o)=>{let{hostApprove:t}=await import("./chunk-gcqhggbh.js");n=await t({code:e,json:o.json===!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir},...o.origin===void 0?{}:{origin:o.origin},...o.workspace===void 0?{}:{workspace:o.workspace}})}),s.command("browsers").description("The browsers approved to ask this computer's agents.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to read, when the running host is not found").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostTrust:o}=await import("./chunk-8x5daqht.js");n=await o({action:"list",browsers:!0,json:e.json===!0,...e.host===void 0?{}:{host:e.host},...e.configDir===void 0?{}:{configDir:e.configDir}})}).command("remove <name>").description("Stop trusting a browser; its next message asks again.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").exitOverride().action(async(e,o)=>{let{hostTrust:t}=await import("./chunk-8x5daqht.js");n=await t({action:"remove",name:e,browsers:!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})});let k=s.command("auth").description("Sign this machine in to a Hightea deployment for the owner commands.").exitOverride();k.command("login").description("Sign in with a short code confirmed in your browser, and store the session for this deployment.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--no-browser","Print the confirmation URL instead of opening it").option("--json","Print one JSON document with the account and expiry, never the tokens").addHelpText("after",`
18
- Exit status: 0 signed in; 1 any other failure, named on stderr.`).exitOverride().action(async(e)=>{let{authLogin:o}=await import("./chunk-jdzvh3gk.js");n=await o({origin:e.origin??"",noBrowser:e.browser===!1,json:e.json===!0})}),k.command("status").description("Show which account this machine is signed in as for a deployment. Changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--json","Print one JSON document with the account and expiry, never the tokens").exitOverride().action(async(e)=>{let{authStatus:o}=await import("./chunk-jdzvh3gk.js");n=await o({origin:e.origin??"",json:e.json===!0})}),k.command("logout").description("Revoke this machine's session at the deployment and forget its local credential.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{authLogout:o}=await import("./chunk-jdzvh3gk.js");n=await o({origin:e.origin??"",json:e.json===!0})});let u=s.command("source").description("A workspace's km sources: bind one to a host, unbind it, or read its state.").exitOverride();u.command("bind-linear").description("Bind one Linear team as a cloud dataset, as the workspace owner (#37446).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--team <id>","The Linear team id (`hightea source teams` lists them)").option("--refresh <every>","Refresh interval to declare at bind time: 5m, 1h, 2d (default: 5m)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
15
+ Exit status: 0 trusted or already trusted; 1 any failure, with the file left unchanged.`).exitOverride().action(async(e,o,n)=>{let{hostTrust:i}=await import("./chunk-pdnrwmme.js");t=await i({action:"add",caller:f(),name:e,publicKey:o,...n.host===void 0?{}:{host:n.host},...n.configDir===void 0?{}:{configDir:n.configDir}})}),l.command("remove").description("Stop trusting the key with this name; asks signed with it are refused from then on.").argument("<name>","The key's name, as `hightea host trust list` shows it").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").addHelpText("after",`
16
+ Exit status: 0 removed; 1 any failure, including an unknown name, with the file left unchanged.`).exitOverride().action(async(e,o)=>{let{hostTrust:n}=await import("./chunk-pdnrwmme.js");t=await n({action:"remove",caller:f(),name:e,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})}),l.command("list").description("List the keys this machine trusts. Changes nothing.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to read, when the running host is not found").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostTrust:o}=await import("./chunk-pdnrwmme.js");t=await o({action:"list",json:e.json===!0,...e.host===void 0?{}:{host:e.host},...e.configDir===void 0?{}:{configDir:e.configDir}})}),r.command("approve <code>").description("Approve a browser to ask this computer's agents, using the code that browser shows.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").option("--origin <url>","The deployment, when this machine's claim does not record it").option("--workspace <slug>","The workspace slug, when this machine's claim does not record it").option("--json","Print one JSON document").addHelpText("after",`
17
+ Then come back to the browser: the message that asked sends itself. Exit status: 0 approved; 1 anything else, named on stderr, with the trusted-keys file left unchanged.`).exitOverride().action(async(e,o)=>{let{hostApprove:n}=await import("./chunk-dzr0pvfa.js");t=await n({code:e,caller:f(),json:o.json===!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir},...o.origin===void 0?{}:{origin:o.origin},...o.workspace===void 0?{}:{workspace:o.workspace}})}),r.command("browsers").description("The browsers approved to ask this computer's agents.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to read, when the running host is not found").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostTrust:o}=await import("./chunk-pdnrwmme.js");t=await o({action:"list",browsers:!0,json:e.json===!0,...e.host===void 0?{}:{host:e.host},...e.configDir===void 0?{}:{configDir:e.configDir}})}).command("remove <name>").description("Stop trusting a browser; its next message asks again.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").exitOverride().action(async(e,o)=>{let{hostTrust:n}=await import("./chunk-pdnrwmme.js");t=await n({action:"remove",caller:f(),name:e,browsers:!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})});let E=r.command("member-ask").description("This computer's own member credential: make a key, then redeem the challenge a workspace hands it.").exitOverride();E.command("key").description("Make a member key at <config-dir>/member-ask/<label>.key (0600) and print its public half and fingerprint.").argument("<label>","The name to keep this key under, e.g. scout").option("--config-dir <dir>","This host's ahpd configuration directory (an absolute path)").addHelpText("after",`
18
+ The public key is what a person approves into a join request; the private half never leaves this machine.
19
+ An existing key is never replaced. Exit status: 0 made; 1 any refusal, named on stderr, with no file written.`).exitOverride().action(async(e,o)=>{let{memberAskKey:n}=await import("./chunk-3emak1d3.js");t=await n({label:e,configDir:o.configDir??""})}),E.command("redeem").description("Sign a one-time challenge with <label>'s key and store the member ask token it buys.").argument("<label>","The name the key was made under").argument("<challenge>","The askChallenge.challenge a workspace_join_status answer handed you").option("--config-dir <dir>","This host's ahpd configuration directory (an absolute path)").option("--workspace <slug>","The workspace slug the member belongs to").option("--origin <url>","The deployment, when it is not https://hightea.ai").addHelpText("after",`
20
+ The token is stored beside the key and never printed. Exit status: 0 stored; 1 any refusal, named on stderr.`).exitOverride().action(async(e,o,n)=>{let{memberAskRedeem:i,MEMBER_ASK_DEFAULT_ORIGIN:d}=await import("./chunk-3emak1d3.js");t=await i({label:e,challenge:o,configDir:n.configDir??"",workspace:n.workspace??"",origin:n.origin??d})});let b=r.command("auth").description("Sign this machine in to a Hightea deployment for the owner commands.").exitOverride();b.command("login").description("Sign in with a short code confirmed in your browser, and store the session for this deployment.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--no-browser","Print the confirmation URL instead of opening it").option("--json","Print one JSON document with the account and expiry, never the tokens").addHelpText("after",`
21
+ Exit status: 0 signed in; 1 any other failure, named on stderr.`).exitOverride().action(async(e)=>{let{authLogin:o}=await import("./chunk-w2f84aab.js");t=await o({origin:e.origin??"",noBrowser:e.browser===!1,json:e.json===!0})}),b.command("status").description("Show which account this machine is signed in as for a deployment. Changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--json","Print one JSON document with the account and expiry, never the tokens").exitOverride().action(async(e)=>{let{authStatus:o}=await import("./chunk-w2f84aab.js");t=await o({origin:e.origin??"",json:e.json===!0})}),b.command("logout").description("Revoke this machine's session at the deployment and forget its local credential.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{authLogout:o}=await import("./chunk-w2f84aab.js");t=await o({origin:e.origin??"",json:e.json===!0})});let u=r.command("source").description("A workspace's km sources: bind one to a host, unbind it, or read its state.").exitOverride();u.command("bind-linear").description("Bind one Linear team as a cloud dataset, as the workspace owner (#37446).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--team <id>","The Linear team id (`hightea source teams` lists them)").option("--refresh <every>","Refresh interval to declare at bind time: 5m, 1h, 2d (default: 5m)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
19
22
  Exit status: 0 bound; 3 your account is not this workspace's owner; 1 any other failure, including a
20
- workspace that has not authorized Linear, a team the token cannot see, or an interval under 5 minutes.`).exitOverride().action(async(e)=>{let{sourceBindLinear:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",team:e.team??"",refresh:e.refresh,sessionFile:e.sessionFile,json:e.json===!0})}),u.command("teams").description("List the Linear teams this workspace's token can see, as the workspace owner (#37446).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{sourceTeams:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("bind").description("Bind a km source to one of the workspace's hosts, as the workspace owner.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--host <id>","The host id that serves the source").option("--refresh <every>","Refresh interval to declare at bind time: 1h, 30m, 2d (default: none)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
23
+ workspace that has not authorized Linear, a team the token cannot see, or an interval under 5 minutes.`).exitOverride().action(async(e)=>{let{sourceBindLinear:o}=await import("./chunk-wyzpk81n.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",team:e.team??"",refresh:e.refresh,sessionFile:e.sessionFile,json:e.json===!0})}),u.command("teams").description("List the Linear teams this workspace's token can see, as the workspace owner (#37446).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{sourceTeams:o}=await import("./chunk-wyzpk81n.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("bind").description("Bind a km source to one of the workspace's hosts, as the workspace owner.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--host <id>","The host id that serves the source").option("--refresh <every>","Refresh interval to declare at bind time: 1h, 30m, 2d (default: none)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
21
24
  Exit status: 0 bound; 3 your account is not this workspace's owner; 4 that source is bound to another host;
22
- 1 any other failure.`).exitOverride().action(async(e)=>{let{sourceBind:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",host:e.host??"",refresh:e.refresh,sessionFile:e.sessionFile,json:e.json===!0})}),u.command("unbind").description("Take a km source out of service, as the workspace owner; its rows stay and read as unbound.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
23
- Exit status: 0 unbound; 3 your account is not this workspace's owner; 1 any other failure, including a source that is not bound.`).exitOverride().action(async(e)=>{let{sourceUnbind:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("show").description("Read one source's binding, freshness and position; changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{sourceShow:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("set-refresh").description("Give a bound source a refresh interval (1h, 30m, 2d) or clear it with none; as the workspace owner.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--every <interval>","45s, 30m, 1h, 2d, or none to clear; the shortest allowed is 5m").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
24
- Exit status: 0 set; 3 your account is not this workspace's owner; 1 any other failure, including an interval under 5 minutes.`).exitOverride().action(async(e)=>{let{sourceSetRefresh:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",every:e.every??"",sessionFile:e.sessionFile,json:e.json===!0})});let f=s.command("service").description("A machine's services under process-compose: list, change, start, stop, read logs; from Hightea or on the machine.").exitOverride(),h=(e,o,t={})=>{let i=f.command(e).description(o);if(t.named)i.argument("<name>","The service's name, as process-compose knows it");if(i.option("--host <id>","The registered host's id; with --local, which of this machine's joined hosts").option("--local","Act on this machine, in-process, as you").option("--origin <url>","The deployment, e.g. https://hightea.dev (with --host)").option("--workspace <slug>","The workspace slug (with --host)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print the machine's answer as one JSON document"),t.fields)i.option("--command <cmd>","The program's command line").option("--cwd <dir>","The directory it runs in").option("--patch <json>","Any other service fields, as a JSON object (env, schedule, restart, depends_on, health)");if(t.logs)i.option("--limit <lines>","How many lines (the machine caps it)").option("--end <lines>","Lines back from the newest the read ends at (default 0)");i.addHelpText("after",`
25
- Exit status: 0 done; 3 your account may not manage this host's services; 1 any other failure, named on stderr.`).exitOverride().action(async(...p)=>{let T=t.named?String(p[0]):void 0,m=t.named?p[1]:p[0],{serviceCommand:j}=await import("./chunk-dkzzzkex.js"),a=(y)=>typeof m[y]==="string"?m[y]:void 0;n=await j({origin:a("origin")??"",workspace:a("workspace")??"",host:a("host"),local:m.local===!0,sessionFile:a("sessionFile"),json:m.json===!0},{command:e,name:T,fields:{command:a("command"),cwd:a("cwd"),patch:a("patch")},end:a("end"),limit:a("limit")})})};h("list","List the machine's services, which are read-only and why. Shows commands and paths."),h("add","Add a service to the machine's own process-compose file.",{named:!0,fields:!0}),h("change","Change a service in the machine's own process-compose file.",{named:!0,fields:!0}),h("remove","Take a service out of the machine's own process-compose file.",{named:!0}),h("start","Start a service.",{named:!0}),h("stop","Stop a service.",{named:!0}),h("restart","Restart a service.",{named:!0}),h("logs","One bounded read of a service's raw output; nothing is kept.",{named:!0,logs:!0}),h("acknowledge","Accept the process-compose files as they are now, so drift stops alerting on a hand edit."),f.command("backup").description("Show Hightea's backup of a host's services and their change log, labelled with how far it reaches; works while the host is offline or revoked.").requiredOption("--host <id>","The registered host's id").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print the backup as one JSON document").addHelpText("after",`
26
- Exit status: 0 shown; 3 your account may not read this host's backup; 1 any other failure, named on stderr.`).exitOverride().action(async(e)=>{let{serviceBackupCommand:o}=await import("./chunk-dkzzzkex.js"),t=(i)=>typeof e[i]==="string"?e[i]:void 0;n=await o({origin:t("origin")??"",workspace:t("workspace")??"",host:t("host"),local:!1,sessionFile:t("sessionFile"),json:e.json===!0})}),f.command("restore").description("Create a host's backed-up services on a new host, create-only: shows what it will create and asks first.").argument("[names...]","Which services; every one in the backup when none is named").requiredOption("--from <id>","The old host whose backup is read").option("--host <id>","The new registered host's id; with --local, which of this machine's joined hosts").option("--local","Create them on this machine, in-process, as you").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--yes","Do not ask; for scripts").option("--json","Print each service's outcome as one JSON document").addHelpText("after",`
27
- Exit status: 0 every service created; 3 your account may not read the old host's backup; 1 anything else, each named.`).exitOverride().action(async(e,o)=>{let{serviceRestore:t}=await import("./chunk-dkzzzkex.js"),i=(p)=>typeof o[p]==="string"?o[p]:void 0;n=await t({origin:i("origin")??"",workspace:i("workspace")??"",host:i("host"),local:o.local===!0,sessionFile:i("sessionFile"),json:o.json===!0},{from:i("from")??"",names:e,yes:o.yes===!0})});for(let[e,o]of[["enable",!0],["disable",!1]])f.command(e).description(o?"On this machine: let Hightea list, read logs of, change, start and stop this machine's services (adds the services grants).":"On this machine: stop Hightea managing this machine's services (removes the services grants).").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").addHelpText("after",`
28
- Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOverride().action(async(t)=>{let{hostServicesGrants:i}=await import("./chunk-xy8j3npr.js");n=await i({enable:o,...typeof t.host==="string"?{host:t.host}:{}})});s.command("deploy <service>").description("Place one of this machine's services at a version through its deploy driver; `deploy status <service>` reads one back.").option("--pin <sha>","The full 40-character commit sha to deploy").option("--host <id>","The joined host's id, when this machine runs more than one ahpd").option("--json","Print one JSON document").addHelpText("after",`
29
- Exit status: 0 started; 1 any refusal or failure, named on stderr.`).exitOverride().action(async(e,o)=>{let{deployPlace:t}=await import("./chunk-p616vcdm.js");n=await t({service:e,pin:typeof o.pin==="string"?o.pin:"",host:typeof o.host==="string"?o.host:void 0,json:o.json===!0})}).command("status <service>").description("Read this service's newest deploy: its state, the pin it is at and the last error it recorded.").addHelpText("after","\nThe parent's --host and --json are accepted here too, before or after `status`.\nExit status: 0 read; 1 no ahpd or no such service on it, named on stderr.").exitOverride().action(async(...e)=>{let o=String(e[0]),{deployStatus:t}=await import("./chunk-p616vcdm.js"),i=e[2].optsWithGlobals();n=await t({service:o,host:typeof i.host==="string"?i.host:void 0,json:i.json===!0})});try{await s.parseAsync([...c],{from:"user"})}catch(e){if(!(e instanceof F))throw e;return e.code==="commander.helpDisplayed"||e.code==="commander.version"||e.code==="commander.help"?0:1}return n}async function L(c){if(process.stdin.isTTY!==!0){console.error(`this computer can run more than one agent app: ${c.map((n)=>`${n.name} (${n.id})`).join(", ")}. Run the same command in a terminal to choose, or add --app <id>. Nothing was redeemed.`);return}let r=A({input:process.stdin,output:process.stdout});try{console.log("This computer can run:");for(let[l,x]of c.entries())console.log(` ${l+1}) ${x.name}`);let n=(await r.question(`Which app should this computer's agent be? [1-${c.length}] `)).trim(),s=Number(n),d=Number.isInteger(s)&&s>=1&&s<=c.length?c[s-1]:void 0;if(d===void 0)console.error(`connect: '${n}' is not one of the numbers above. Nothing was redeemed.`);return d}finally{r.close()}}var P=C(new URL("./plugin/",import.meta.url)),{version:J}=JSON.parse(D(new URL("./plugin/plugin.json",import.meta.url),"utf8"));process.exitCode=await S(process.argv.slice(2),{version:J,pluginDirectory:P});
25
+ 1 any other failure.`).exitOverride().action(async(e)=>{let{sourceBind:o}=await import("./chunk-wyzpk81n.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",host:e.host??"",refresh:e.refresh,sessionFile:e.sessionFile,json:e.json===!0})}),u.command("unbind").description("Take a km source out of service, as the workspace owner; its rows stay and read as unbound.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
26
+ Exit status: 0 unbound; 3 your account is not this workspace's owner; 1 any other failure, including a source that is not bound.`).exitOverride().action(async(e)=>{let{sourceUnbind:o}=await import("./chunk-wyzpk81n.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("show").description("Read one source's binding, freshness and position; changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{sourceShow:o}=await import("./chunk-wyzpk81n.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("set-refresh").description("Give a bound source a refresh interval (1h, 30m, 2d) or clear it with none; as the workspace owner.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--every <interval>","45s, 30m, 1h, 2d, or none to clear; the shortest allowed is 5m").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
27
+ Exit status: 0 set; 3 your account is not this workspace's owner; 1 any other failure, including an interval under 5 minutes.`).exitOverride().action(async(e)=>{let{sourceSetRefresh:o}=await import("./chunk-wyzpk81n.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",every:e.every??"",sessionFile:e.sessionFile,json:e.json===!0})});let y=r.command("admin").description("The Fleet admin seat: create a room, remove an agent, list members, read the activity log.").exitOverride();y.command("room").description("Rooms the admin seat creates.").exitOverride().command("create").description("Create one open room; every active member is seated in it.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--slug <slug>","The room name: lowercase letters, digits and single hyphens").option("--title <title>","The room's display title (default: the slug)").option("--seat <seat>","Who asked, as @chief — required for every write the admin seat makes").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
28
+ Exit status: 0 created; 3 your session is not this workspace's owner or admin seat; 4 the call named no --seat; 1 any other failure.`).exitOverride().action(async(e)=>{let{adminRoomCreate:o}=await import("./chunk-5hvk5pvs.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",seat:e.seat,sessionFile:e.sessionFile,json:e.json===!0,slug:e.slug??"",title:e.title})}),y.command("member").description("Members the admin seat adds and removes.").exitOverride().command("remove <memberId>").description("Remove one member: an agent, or the admin seat itself.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--seat <seat>","Who asked, as @chief — required for every removal the admin seat makes").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
29
+ Exit status: 0 removed; 3 your session is not this workspace's owner or admin seat, or a person's removal was refused; 4 the call named no --seat; 1 any other failure.`).exitOverride().action(async(e,o)=>{let{adminMemberRemove:n}=await import("./chunk-5hvk5pvs.js");t=await n({origin:o.origin??"",workspace:o.workspace??"",seat:o.seat,sessionFile:o.sessionFile,json:o.json===!0,memberId:e})}),y.command("members").description("List this workspace's active people and agents; changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--seat <seat>","Who asked, as @chief — the admin seat names itself on every call").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{adminMembers:o}=await import("./chunk-5hvk5pvs.js");t=await o({origin:e.origin??"",workspace:e.workspace??"",seat:e.seat,sessionFile:e.sessionFile,json:e.json===!0})}),y.command("activity").description("Read the workspace's audit trail: actor, seat, action, target and time, newest first.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--limit <n>","How many rows, 1 to 1000 (default 100)").option("--seat <seat>","Who asked, as @chief — the admin seat names itself on every call").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
30
+ Exit status: 0 read; 3 your session is not this workspace's owner or admin seat; 1 any other failure.`).exitOverride().action(async(e)=>{let{adminActivity:o}=await import("./chunk-5hvk5pvs.js"),n=e.limit===void 0?void 0:Number(e.limit);t=await o({origin:e.origin??"",workspace:e.workspace??"",seat:e.seat,sessionFile:e.sessionFile,json:e.json===!0,limit:n})});let k=r.command("service").description("A machine's services under process-compose: list, change, start, stop, read logs; from Hightea or on the machine.").exitOverride(),p=(e,o,n={})=>{let i=k.command(e).description(o);if(n.named)i.argument("<name>","The service's name, as process-compose knows it");if(i.option("--host <id>","The registered host's id; with --local, which of this machine's joined hosts").option("--local","Act on this machine, in-process, as you").option("--origin <url>","The deployment, e.g. https://hightea.dev (with --host)").option("--workspace <slug>","The workspace slug (with --host)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print the machine's answer as one JSON document"),n.fields)i.option("--command <cmd>","The program's command line").option("--cwd <dir>","The directory it runs in").option("--patch <json>","Any other service fields, as a JSON object (env, schedule, restart, depends_on, health)");if(n.logs)i.option("--limit <lines>","How many lines (the machine caps it)").option("--end <lines>","Lines back from the newest the read ends at (default 0)");i.addHelpText("after",`
31
+ Exit status: 0 done; 3 your account may not manage this host's services; 1 any other failure, named on stderr.`).exitOverride().action(async(...d)=>{let x=n.named?String(d[0]):void 0,m=n.named?d[1]:d[0],{serviceCommand:j}=await import("./chunk-vr4rsfaf.js"),c=(v)=>typeof m[v]==="string"?m[v]:void 0;t=await j({origin:c("origin")??"",workspace:c("workspace")??"",host:c("host"),local:m.local===!0,sessionFile:c("sessionFile"),json:m.json===!0},{command:e,name:x,fields:{command:c("command"),cwd:c("cwd"),patch:c("patch")},end:c("end"),limit:c("limit")})})};p("list","List the machine's services, which are read-only and why. Shows commands and paths."),p("add","Add a service to the machine's own process-compose file.",{named:!0,fields:!0}),p("change","Change a service in the machine's own process-compose file.",{named:!0,fields:!0}),p("remove","Take a service out of the machine's own process-compose file.",{named:!0}),p("start","Start a service.",{named:!0}),p("stop","Stop a service.",{named:!0}),p("restart","Restart a service.",{named:!0}),p("logs","One bounded read of a service's raw output; nothing is kept.",{named:!0,logs:!0}),p("acknowledge","Accept the process-compose files as they are now, so drift stops alerting on a hand edit."),k.command("backup").description("Show Hightea's backup of a host's services and their change log, labelled with how far it reaches; works while the host is offline or revoked.").requiredOption("--host <id>","The registered host's id").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print the backup as one JSON document").addHelpText("after",`
32
+ Exit status: 0 shown; 3 your account may not read this host's backup; 1 any other failure, named on stderr.`).exitOverride().action(async(e)=>{let{serviceBackupCommand:o}=await import("./chunk-vr4rsfaf.js"),n=(i)=>typeof e[i]==="string"?e[i]:void 0;t=await o({origin:n("origin")??"",workspace:n("workspace")??"",host:n("host"),local:!1,sessionFile:n("sessionFile"),json:e.json===!0})}),k.command("restore").description("Create a host's backed-up services on a new host, create-only: shows what it will create and asks first.").argument("[names...]","Which services; every one in the backup when none is named").requiredOption("--from <id>","The old host whose backup is read").option("--host <id>","The new registered host's id; with --local, which of this machine's joined hosts").option("--local","Create them on this machine, in-process, as you").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--yes","Do not ask; for scripts").option("--json","Print each service's outcome as one JSON document").addHelpText("after",`
33
+ Exit status: 0 every service created; 3 your account may not read the old host's backup; 1 anything else, each named.`).exitOverride().action(async(e,o)=>{let{serviceRestore:n}=await import("./chunk-vr4rsfaf.js"),i=(d)=>typeof o[d]==="string"?o[d]:void 0;t=await n({origin:i("origin")??"",workspace:i("workspace")??"",host:i("host"),local:o.local===!0,sessionFile:i("sessionFile"),json:o.json===!0},{from:i("from")??"",names:e,yes:o.yes===!0})});for(let[e,o]of[["enable",!0],["disable",!1]])k.command(e).description(o?"On this machine: let Hightea list, read logs of, change, start and stop this machine's services (adds the services grants).":"On this machine: stop Hightea managing this machine's services (removes the services grants).").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").addHelpText("after",`
34
+ Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOverride().action(async(n)=>{let{hostServicesGrants:i}=await import("./chunk-gbwfgq6g.js");t=await i({enable:o,caller:f(),...typeof n.host==="string"?{host:n.host}:{}})});r.command("deploy <service>").description("Place one of this machine's services at a version through its deploy driver; `deploy status <service>` reads one back.").option("--pin <sha>","The full 40-character commit sha to deploy").option("--host <id>","The joined host's id, when this machine runs more than one ahpd").option("--json","Print one JSON document").addHelpText("after",`
35
+ Exit status: 0 started; 1 any refusal or failure, named on stderr.`).exitOverride().action(async(e,o)=>{let{deployPlace:n}=await import("./chunk-h9f45p57.js");t=await n({service:e,pin:typeof o.pin==="string"?o.pin:"",host:typeof o.host==="string"?o.host:void 0,json:o.json===!0})}).command("status <service>").description("Read this service's newest deploy: its state, the pin it is at and the last error it recorded.").addHelpText("after","\nThe parent's --host and --json are accepted here too, before or after `status`.\nExit status: 0 read; 1 no ahpd or no such service on it, named on stderr.").exitOverride().action(async(...e)=>{let o=String(e[0]),{deployStatus:n}=await import("./chunk-h9f45p57.js"),i=e[2].optsWithGlobals();t=await n({service:o,host:typeof i.host==="string"?i.host:void 0,json:i.json===!0})});try{await r.parseAsync([...a],{from:"user"})}catch(e){if(!(e instanceof N))throw e;return e.code==="commander.helpDisplayed"||e.code==="commander.version"||e.code==="commander.help"?0:1}return t}async function G(a){if(process.stdin.isTTY!==!0){console.error(`this computer can run more than one agent app: ${a.map((t)=>`${t.name} (${t.id})`).join(", ")}. Run the same command in a terminal to choose, or add --app <id>. Nothing was redeemed.`);return}let s=R({input:process.stdin,output:process.stdout});try{console.log("This computer can run:");for(let[l,S]of a.entries())console.log(` ${l+1}) ${S.name}`);let t=(await s.question(`Which app should this computer's agent be? [1-${a.length}] `)).trim(),r=Number(t),h=Number.isInteger(r)&&r>=1&&r<=a.length?a[r-1]:void 0;if(h===void 0)console.error(`connect: '${t}' is not one of the numbers above. Nothing was redeemed.`);return h}finally{s.close()}}var U=M(new URL("./plugin/",import.meta.url)),{version:B}=JSON.parse(W(new URL("./plugin/plugin.json",import.meta.url),"utf8"));process.exitCode=await F(process.argv.slice(2),{version:B,pluginDirectory:U});
@@ -0,0 +1,2 @@
1
+ import{createHash as R,createPrivateKey as I,createPublicKey as x,generateKeyPairSync as B,sign as N}from"node:crypto";import{mkdir as D,readFile as O,rename as T,stat as U,writeFile as h}from"node:fs/promises";import{isAbsolute as L,join as f,resolve as b}from"node:path";var y="member-ask",z="https://hightea.ai",k={out:(e)=>console.log(e),err:(e)=>console.error(e)},j=/^[A-Za-z0-9][A-Za-z0-9._-]{0,59}$/u,A=(e)=>R("sha256").update(e).digest("base64url"),v=(e)=>e.slice(0,12),M=(e,r)=>f(e,y,`${r}.key`),P=(e,r)=>f(e,y,`${r}.token`),F=(e,r)=>{if((r&63)===0)return null;let n=(r&511).toString(8).padStart(3,"0");return`MEMBER_ASK_DIR_INSECURE: ${e} is mode ${n}, so it is not this user's alone; make it 0700 by hand (chmod 700 ${e}) and run this again`},w=async(e)=>{try{return F(e,(await U(e)).mode)}catch(r){if(r.code==="ENOENT")return null;return`MEMBER_ASK_DIR_INSECURE: ${e} cannot be read (${String(r)})`}},K=(e)=>{if(!j.test(e.label))return`MEMBER_ASK_LABEL_INVALID: ${JSON.stringify(e.label)} is not a label; use letters, digits, '.', '_' or '-', up to 60 characters`;if(e.configDir.trim()==="")return"MEMBER_ASK_USAGE: --config-dir is required: the host's ahpd configuration directory, where member-ask/ lives";if(!L(e.configDir))return`MEMBER_ASK_USAGE: --config-dir needs an absolute path; ${JSON.stringify(e.configDir)} is not one`;return null};async function V(e,r=k){let n=K(e);if(n!==null)return r.err(n),1;let o=b(e.configDir),t=M(o,e.label),i=f(o,y),l=await w(i);if(l!==null)return r.err(l),1;let d=B("ed25519"),c=d.privateKey.export({format:"pem",type:"pkcs8"}).toString();try{await D(i,{recursive:!0,mode:448}),await h(t,c,{mode:384,flag:"wx"})}catch(a){if(a.code==="EEXIST")return r.err(`MEMBER_ASK_KEY_EXISTS: ${t} already exists, and a key a workspace may already trust is never replaced; pick another label, or remove that file by hand if you are sure nothing trusts it`),1;return r.err(`MEMBER_ASK_KEY_UNWRITABLE: ${t} could not be written (${String(a)})`),1}let s=d.publicKey.export({format:"jwk"}).x;if(s===void 0)return r.err(`MEMBER_ASK_KEY_UNWRITABLE: ${t} was written but its public half cannot be read`),1;return r.out(s),r.out(`fingerprint ${v(A(s))}`),0}var J=async(e,r)=>{let n=M(e,r),o;try{o=await O(n,"utf8")}catch(t){if(t.code==="ENOENT")return`MEMBER_ASK_NO_KEY: ${n} does not exist, so there is no private key to sign with; run \`hightea member-ask key ${r}\` first, or name the right --config-dir`;return`MEMBER_ASK_KEY_UNREADABLE: ${n} cannot be read (${String(t)})`}try{let t=I({key:o,format:"pem"});if(t.asymmetricKeyType!=="ed25519")throw Error(`a ${String(t.asymmetricKeyType)} key, not Ed25519`);let i=x(t).export({format:"jwk"}).x;if(i===void 0)throw Error("the public half is not an Ed25519 x coordinate");return{key:t,publicKey:i}}catch(t){return`MEMBER_ASK_KEY_UNREADABLE: ${n} is not an Ed25519 PKCS8 key (${String(t)}); it is never regenerated, fix or remove it by hand`}},Y=(e)=>{let r=e.split(".")[1];if(r===void 0)return;try{let n=JSON.parse(Buffer.from(r,"base64url").toString("utf8"));if(typeof n!=="object"||n===null)return;let o=n.exp;return typeof o==="number"&&Number.isFinite(o)&&o>0?o*1000:void 0}catch{return}};async function H(e,r=k){let n=K(e);if(n!==null)return r.err(n),1;if(e.challenge.trim()==="")return r.err("MEMBER_ASK_USAGE: <challenge> is required: the askChallenge.challenge a workspace_join_status answer handed you"),1;if(!/^[a-z0-9][a-z0-9-]{0,62}$/u.test(e.workspace))return r.err(`MEMBER_ASK_USAGE: --workspace needs the workspace slug; ${JSON.stringify(e.workspace)} is not one`),1;let o=b(e.configDir),t=await w(f(o,y));if(t!==null)return r.err(t),1;let i=await J(o,e.label);if(typeof i==="string")return r.err(i),1;let l=A(i.publicKey),d=N(null,Buffer.from(e.challenge,"utf8"),i.key).toString("base64url"),c=`${e.origin.replace(/\/+$/u,"")}/api/ws/${encodeURIComponent(e.workspace)}/member-ask/redeem`,s;try{s=await(r.fetch??fetch)(c,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({challenge:e.challenge,keyId:l,signature:d})})}catch(u){return r.err(`MEMBER_ASK_REFUSED: ${c} could not be reached (${String(u)})`),1}let a;try{a=await s.json()}catch{return r.err(`MEMBER_ASK_ANSWER_INVALID: ${c} answered ${String(s.status)} without JSON`),1}if(!s.ok){let u=typeof a==="object"&&a!==null?a.error:void 0,E=typeof u?.code==="string"?u.code:"HTTP_ERROR",_=typeof u?.message==="string"?u.message:"no message";if(E==="KEY_NOT_FOR_MEMBER"||E==="KEY_NOT_FOUND")return r.err(`MEMBER_ASK_KEY_MISMATCH: the challenge names another key than ${e.label}'s (${l}); ${String(s.status)} ${E}: ${_}`),1;return r.err(`MEMBER_ASK_REFUSED: ${c} answered ${String(s.status)} ${E}: ${_}`),1}let g=typeof a==="object"&&a!==null?a.token:void 0;if(typeof g!=="string"||g==="")return r.err(`MEMBER_ASK_ANSWER_INVALID: ${c} answered ${String(s.status)} without a token`),1;let p=Y(g);if(p===void 0)return r.err(`MEMBER_ASK_ANSWER_INVALID: ${c} answered a token carrying no readable exp, so nothing can say when it dies`),1;let m=P(o,e.label),S=`${m}.${String(process.pid)}.tmp`;try{await h(S,`${g}
2
+ `,{mode:384,flag:"wx"}),await T(S,m)}catch(u){return r.err(`MEMBER_ASK_STORE_FAILED: ${m} could not be written (${String(u)})`),1}return r.out(`token stored, expires ${new Date(p).toISOString()}`),0}export{z as MEMBER_ASK_DEFAULT_ORIGIN,V as memberAskKey,H as memberAskRedeem};
@@ -0,0 +1,5 @@
1
+ import{s,f}from"./chunk-dvsftn8z.js";import{chmod as p,mkdir as u,readFile as I,rm as O,stat as _,writeFile as N}from"node:fs/promises";import{homedir as x}from"node:os";import{join as h}from"node:path";var R=new Set(["FORBIDDEN","NOT_A_MEMBER","UNAUTHENTICATED"]);function t(){return{fetch:(r,o)=>globalThis.fetch(r,o),readFile:(r)=>I(r,"utf8"),stat:(r)=>_(r),writeFile:(r,o,n)=>N(r,o,n),mkdir:async(r,o)=>{await u(r,o)},chmod:(r,o)=>p(r,o),rm:(r,o)=>O(r,o),env:process.env,home:x(),nowMs:()=>Date.now(),out:(r)=>{process.stdout.write(`${r}
2
+ `)},err:(r)=>{process.stderr.write(`${r}
3
+ `)}}}async function T(r,o,n,c){let d=r.sessionFile?.trim()||o.env.HIGHTEA_SESSION_FILE?.trim();if(d===void 0||d===""){let i=await f(c,o);if("credential"in i)return{cookie:i.credential.sessionToken};if(i.error.startsWith("AUTH_NOT_SIGNED_IN")){let a=h(o.env.XDG_CONFIG_HOME?.trim()||h(o.home,".config"),"hightea","session"),m=await S(a,o,n);if(!("error"in m))return m;return{error:`${n}_SESSION_MISSING: ${i.error}`}}if(i.error.startsWith("AUTH_CREDENTIALS_EXPOSED"))return{error:`${n}_SESSION_EXPOSED: ${i.error}`};if(i.error.startsWith("AUTH_SESSION_EXPIRED")||i.error.startsWith("AUTH_REFRESH"))return{error:`${n}_SESSION_EXPIRED: ${i.error}`};return{error:`${n}_SESSION_INVALID: ${i.error}`}}return await S(d,o,n)}async function S(r,o,n){let c,d;try{c=await o.readFile(r),d=(await o.stat(r)).mode}catch(a){return{error:`${n}_SESSION_MISSING: no session in ${r} (${a.message}). Sign in to the deployment in a browser and write its ht_session cookie to that file, or pass --session-file.`}}if((d&63)!==0)return{error:`${n}_SESSION_EXPOSED: ${r} is mode 0${(d&511).toString(8).padStart(3,"0")}; run chmod 600 ${r}.`};let i=c.split(`
4
+ `).map((a)=>a.trim()).filter((a)=>a.length>0);if(i.length!==1)return{error:`${n}_SESSION_INVALID: ${r} must hold exactly one non-empty line (the ht_session cookie value); it holds ${i.length}.`};return{cookie:i[0]}}async function e(r,o,n){let c=s(r.origin,n.label);if("error"in c)return{exit:1,error:c.error};let d=await T(r,o,n.label,c.origin);if("error"in d)return{exit:1,error:d.error};let i=`${c.origin}/api/ws/${encodeURIComponent(r.workspace)}${n.path}`,a;try{a=await o.fetch(i,{method:n.method,headers:{cookie:`ht_session=${d.cookie}`,origin:c.origin,accept:"application/json","cache-control":"no-store",...n.headers,...n.body===void 0?{}:{"content-type":"application/json"}},...n.body===void 0?{}:{body:JSON.stringify(n.body)}})}catch(l){return{exit:1,error:`${n.label}_UNREACHABLE: ${n.what} ${n.method} ${i} did not answer: ${l.message}`}}let m=await a.text(),y={};if(m.length>0)try{let l=JSON.parse(m);if(typeof l!=="object"||l===null||Array.isArray(l))throw SyntaxError("not a JSON object");y=l}catch(l){if(!(l instanceof SyntaxError))throw l;return{exit:1,error:`${n.label}_ANSWER_INVALID: ${n.what} ${n.method} ${i} answered HTTP ${a.status} with non-JSON: ${m.slice(0,300)}`}}if(a.ok)return{answer:y};let g=y.error,w=typeof g?.code==="string"?g.code:`HTTP_${a.status}`,E=typeof g?.message==="string"?g.message:m.slice(0,300);return{exit:R.has(w)?3:n.extraExits?.[w]??1,error:`${w}: ${E}`,body:y}}
5
+ export{t,e};
@@ -0,0 +1,9 @@
1
+ import"./chunk-dvsftn8z.js";import{t,e}from"./chunk-55a0ndzw.js";var c={ADMIN_SEAT_REQUIRED:4},m=`hightea admin room create --origin https://your-deployment --workspace SLUG --slug ROOM --seat @chief [--title TITLE] [--session-file FILE] [--json]
2
+ hightea admin member remove --origin https://your-deployment --workspace SLUG MEMBER_ID --seat @chief [--session-file FILE] [--json]
3
+ hightea admin members --origin https://your-deployment --workspace SLUG [--session-file FILE] [--json]
4
+ hightea admin activity --origin https://your-deployment --workspace SLUG [--seat @chief] [--limit 100] [--session-file FILE] [--json]`;function d(){return t()}function f(r){if(r.seat===void 0||r.seat.trim().length===0)return{};let n=r.seat.trim();if(!/^@[A-Za-z0-9][A-Za-z0-9._/-]*$/u.test(n))return null;return{"x-hightea-seat":n}}async function u(r,n,i){if(r.workspace.trim().length===0)return{exit:1,error:`ADMIN_INPUT: --workspace is required.
5
+ ${m}`};let o=f(r);if(o===null)return{exit:1,error:`ADMIN_INPUT: --seat names the acting seat as @name, e.g. @chief.
6
+ ${m}`};return e(r,n,{...i,label:"ADMIN",headers:o,extraExits:c})}async function w(r,n=d()){let i=r.slug.trim();if(i.length===0)return n.err(`ADMIN_INPUT: --slug is required (lowercase letters, digits and single hyphens).
7
+ ${m}`),1;let o=await u(r,n,{method:"POST",what:"room create",path:"/rooms",body:r.title===void 0?{slug:i}:{slug:i,title:r.title}});if("error"in o)return n.err(o.error),o.exit;if(r.json)return n.out(JSON.stringify(o.answer)),0;let s=o.answer.room??{};return n.out(`created room ${String(s.slug??i)} (${String(s.roomId??"no id")})`),n.out("Every active member is seated in an open room; no separate join step."),0}async function h(r,n=d()){let i=r.memberId.trim();if(i.length===0)return n.err(`ADMIN_INPUT: a member id is required (hightea admin members lists them).
8
+ ${m}`),1;let o=await u(r,n,{method:"DELETE",what:"member remove",path:`/members/${encodeURIComponent(i)}`});if("error"in o)return n.err(o.error),o.exit;if(r.json)return n.out(JSON.stringify(o.answer)),0;let s=o.answer.member??{};return n.out(`removed ${String(s.kind??"member")} ${String(s.name??i)} (${String(s.id??i)}); its turns and join links are cancelled with it`),0}async function y(r,n=d()){let i=await u(r,n,{method:"GET",what:"members",path:"/members"});if("error"in i)return n.err(i.error),i.exit;if(r.json)return n.out(JSON.stringify(i.answer)),0;let o=Array.isArray(i.answer.members)?i.answer.members:[];for(let s of o)n.out(`${String(s.displayName??"(unnamed)")} — ${String(s.kind??"?")} ${String(s.role??"?")} (${String(s.id??"no id")})`);if(o.length===0)n.out("No active members. This workspace answered a member list with no rows.");return 0}async function p(r,n=d()){let i=r.limit===void 0?void 0:r.limit;if(i!==void 0&&(!Number.isSafeInteger(i)||i<1||i>1000))return n.err(`ADMIN_INPUT: --limit is a whole number from 1 to 1000.
9
+ ${m}`),1;let o=await u(r,n,{method:"GET",what:"activity",path:i===void 0?"/audit":`/audit?limit=${i}`});if("error"in o)return n.err(o.error),o.exit;if(r.json)return n.out(JSON.stringify(o.answer)),0;let s=Array.isArray(o.answer.entries)?o.answer.entries:[];for(let a of s){let l=a.detail===null||a.detail===void 0?"":` — ${String(a.detail)}`;n.out(`${String(a.at??"?")} ${String(a.action??"?")} ${String(a.target??"?")}${l}`)}if(s.length===0)n.out("No audit rows. This workspace answered an activity read with no entries.");return 0}export{p as adminActivity,h as adminMemberRemove,y as adminMembers,w as adminRoomCreate};