@hallohuman/hightea 0.1.34 → 0.1.35

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,35 +1,35 @@
1
1
  #!/usr/bin/env node
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 D,userInfo as C}from"node:os";import{join as H}from"node:path";import{createInterface as L}from"node:readline/promises";var O="HAB_SESSION_LAUNCH_ID";function R(a=process.env){let s=a[O]?.trim()??"";return s===""?{kind:"person",id:`local:${C().username}`}:{kind:"agent",id:`hab-session:${s}`}}function f(a=process.env){let s=R(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(D(),".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-4gpw7vjp.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-ntj1fcak.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-axj8ef03.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",`
2
+ import{readFileSync as z}from"node:fs";import{fileURLToPath as K}from"node:url";import{Command as R,CommanderError as P,Option as j}from"@silvery/commander";import{homedir as J,userInfo as G}from"node:os";import{join as N}from"node:path";import{createInterface as W}from"node:readline/promises";var E="HAB_SESSION_LAUNCH_ID";function M(a=process.env){let s=a[E]?.trim()??"";return s===""?{kind:"person",id:`local:${G().username}`}:{kind:"agent",id:`hab-session:${s}`}}function y(a=process.env){let s=M(a);if(s.kind==="agent"){let n=a[E]?.trim()??"";console.error(`refused: this shell carries ${E}=${n}, so it acts as agent ${s.id}; grants and key trust are a person's act. Run it from your own terminal.`)}return s}function x(a,s){console.error(`deprecated: ${a} becomes ${s}; this spelling is removed in the release after this one`)}function H(a,s){if(typeof a.refresh==="string")x(`${s} --refresh`,`${s} --every`);let n=a.every??a.refresh;return typeof n==="string"?n:void 0}var D="https://hightea.ai";function U(){return N(process.env.XDG_CONFIG_HOME??N(J(),".config"),"hightea","owner.json")}function B(a){let s=a.split("/");if(s.length!==2)return null;let[n,r]=s;if(n===void 0||r===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(r))return null;return{slug:n,code:r}}async function C(a,s){let n=0,r=new R("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:t}=await import("./chunk-4gpw7vjp.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})}),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: ${D})`).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=B(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:l,describedApp:S,installLineOf:c,isShippedApp:T,noAgentAppsLine:L}=await import("./chunk-ntj1fcak.js"),w=await l();if(o.app===void 0){if(w.length===0){console.error(L()),n=1;return}let f=w.length===1?w[0]:await q(w);if(f===void 0){n=1;return}i=f.id}else if(!T(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 f=w.find((b)=>b.id===o.app);if(f===void 0){let b=S(o.app);console.error(`${b.name} is not on this computer: install it with \`${c(b)}\`, then run the same command again. Nothing was redeemed and nothing was written.`),n=1;return}i=f.id}}let{hostJoin:d}=await import("./chunk-fjskavhw.js"),m=o.ownerConfig===void 0;n=await d({origin:o.origin??D,workspace:t.slug,code:t.code,ownerConfig:o.ownerConfig??U(),ownerConfigIsDefault:m,...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-axj8ef03.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-ym5anbc7.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-ym5anbc7.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-axj8ef03.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",`
6
+ 4 an agent is already bound to another host; 1 any other failure.`).exitOverride().action(async(e)=>{let{hostJoin:o}=await import("./chunk-fjskavhw.js");n=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-ym5anbc7.js");n=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-ym5anbc7.js");n=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-fjskavhw.js");n=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-axj8ef03.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",`
11
+ Exit status: 0 updated or already current; 1 any refusal, named on stderr.`).exitOverride().action(async(e)=>{let{hostUpdate:o}=await import("./chunk-fjskavhw.js");n=await o({host:e.host},{directory:s.pluginDirectory,version:s.version})});let g=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
- 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,n)=>{let{hostTrust:i}=await import("./chunk-a1vwy98c.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-a1vwy98c.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-a1vwy98c.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-p1142ccr.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-a1vwy98c.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-a1vwy98c.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",`
14
+ running as this machine's user, which can edit trusted-keys.json as it can config.json.`).exitOverride();g.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("--local","Act on this machine (the only mode; --host picks which joined host)").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-nqmxwka8.js");n=await i({action:"add",caller:y(),name:e,publicKey:o,...t.host===void 0?{}:{host:t.host},...t.configDir===void 0?{}:{configDir:t.configDir}})}),g.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("--local","Act on this machine (the only mode; --host picks which joined host)").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-nqmxwka8.js");n=await t({action:"remove",caller:y(),name:e,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})}),g.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("--local","Act on this machine (the only mode; --host picks which joined host)").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-nqmxwka8.js");n=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("--local","Act on this machine (the only mode; --host picks which joined host)").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-m472zxhe.js");n=await t({code:e,caller:y(),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("--local","Act on this machine (the only mode; --host picks which joined host)").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-nqmxwka8.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("--local","Act on this machine (the only mode; --host picks which joined host)").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-nqmxwka8.js");n=await t({action:"remove",caller:y(),name:e,browsers:!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})});let A=r.command("member-ask").description("This computer's own member credential: make a key, then redeem the challenge a workspace hands it.").exitOverride();A.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
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-dw3tmpqv.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-dw3tmpqv.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-dw3tmpqv.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
+ 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:t}=await import("./chunk-3emak1d3.js");n=await t({label:e,configDir:o.configDir??""})}),A.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,t)=>{let{memberAskRedeem:i,MEMBER_ASK_DEFAULT_ORIGIN:d}=await import("./chunk-3emak1d3.js");n=await i({label:e,challenge:o,configDir:t.configDir??"",workspace:t.workspace??"",origin:t.origin??d})});let O=r.command("auth").description("Sign this machine in to a Hightea deployment for the owner commands.").exitOverride();O.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-dw3tmpqv.js");n=await o({origin:e.origin??"",noBrowser:e.browser===!1,json:e.json===!0})}),O.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-dw3tmpqv.js");n=await o({origin:e.origin??"",json:e.json===!0})}),O.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-dw3tmpqv.js");n=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("--every <every>","Refresh interval to declare at bind time: 5m, 1h, 2d (default: 5m)").addOption(new j("--refresh <every>","Deprecated; use --every").hideHelp()).option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
22
22
  Exit status: 0 bound; 3 your account is not this workspace's owner; 1 any other failure, including a
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-88mhcx5q.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-88mhcx5q.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",`
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-jcgfe3z4.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",team:e.team??"",refresh:H(e,"hightea source bind-linear"),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-jcgfe3z4.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("--every <every>","Refresh interval to declare at bind time: 1h, 30m, 2d (default: none)").addOption(new j("--refresh <every>","Deprecated; use --every").hideHelp()).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
24
  Exit status: 0 bound; 3 your account is not this workspace's owner; 4 that source is bound to another host;
25
- 1 any other failure.`).exitOverride().action(async(e)=>{let{sourceBind:o}=await import("./chunk-88mhcx5q.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-88mhcx5q.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-88mhcx5q.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-88mhcx5q.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-9fxpgay8.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-9fxpgay8.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-9fxpgay8.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-9fxpgay8.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("--config-dir <dir>","The ahpd configuration directory, when acting on a hab-run or stopped host with --local").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-q669464j.js"),c=(v)=>typeof m[v]==="string"?m[v]:void 0;t=await j({origin:c("origin")??"",workspace:c("workspace")??"",host:c("host"),configDir:c("configDir"),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-q669464j.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("--config-dir <dir>","The ahpd configuration directory, when acting on a hab-run or stopped host with --local").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-q669464j.js"),i=(d)=>typeof o[d]==="string"?o[d]:void 0;t=await n({origin:i("origin")??"",workspace:i("workspace")??"",host:i("host"),configDir:i("configDir"),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-axj8ef03.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-e9s05rg6.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-e9s05rg6.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=L({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});
25
+ 1 any other failure.`).exitOverride().action(async(e)=>{let{sourceBind:o}=await import("./chunk-jcgfe3z4.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",host:e.host??"",refresh:H(e,"hightea source bind"),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-jcgfe3z4.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})});let F=(e,o)=>{u.command(e,o===void 0?{}:{hidden:!0}).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(t)=>{if(o!==void 0)x(o,"hightea source status");let{sourceShow:i}=await import("./chunk-jcgfe3z4.js");n=await i({origin:t.origin??"",workspace:t.workspace??"",source:t.source??"",sessionFile:t.sessionFile,json:t.json===!0})})};F("status",void 0),F("show","hightea source show");let I=(e,o)=>{u.command(e,o===void 0?{}:{hidden:!0}).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").addOption(new j("--refresh <interval>","Deprecated; use --every").hideHelp()).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(t)=>{if(o!==void 0)x(o,"hightea source refresh");let{sourceSetRefresh:i}=await import("./chunk-jcgfe3z4.js");n=await i({origin:t.origin??"",workspace:t.workspace??"",source:t.source??"",every:H(t,"hightea source refresh")??"",sessionFile:t.sessionFile,json:t.json===!0})})};I("refresh",void 0),I("set-refresh","hightea source set-refresh");let k=r.command("admin").description("The Fleet admin seat: create a room, remove an agent, list members, read the activity log.").exitOverride();k.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-9fxpgay8.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",seat:e.seat,sessionFile:e.sessionFile,json:e.json===!0,slug:e.slug??"",title:e.title})}),k.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:t}=await import("./chunk-9fxpgay8.js");n=await t({origin:o.origin??"",workspace:o.workspace??"",seat:o.seat,sessionFile:o.sessionFile,json:o.json===!0,memberId:e})}),k.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-9fxpgay8.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",seat:e.seat,sessionFile:e.sessionFile,json:e.json===!0})}),k.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-9fxpgay8.js"),t=e.limit===void 0?void 0:Number(e.limit);n=await o({origin:e.origin??"",workspace:e.workspace??"",seat:e.seat,sessionFile:e.sessionFile,json:e.json===!0,limit:t})});let v=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,t={})=>{let i=v.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("--config-dir <dir>","The ahpd configuration directory, when acting on a hab-run or stopped host with --local").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",`
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 m=t.named?String(d[0]):void 0,l=t.named?d[1]:d[0],{serviceCommand:S}=await import("./chunk-76e2zy9j.js"),c=(T)=>typeof l[T]==="string"?l[T]:void 0;n=await S({origin:c("origin")??"",workspace:c("workspace")??"",host:c("host"),configDir:c("configDir"),local:l.local===!0,sessionFile:c("sessionFile"),json:l.json===!0},{command:e,name:m,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."),v.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-76e2zy9j.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})}),v.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").option("--from-host <id>","The old host whose backup is read").addOption(new j("--from <id>","Deprecated; use --from-host").hideHelp()).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("--config-dir <dir>","The ahpd configuration directory, when acting on a hab-run or stopped host with --local").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:t}=await import("./chunk-76e2zy9j.js"),i=(m)=>typeof o[m]==="string"?o[m]:void 0;if(typeof o.from==="string")x("hightea service restore --from","hightea service restore --from-host");let d=i("fromHost")??i("from");if(d===void 0||d===""){console.error("hightea service restore needs --from-host <id>, the old host whose backup is read; nothing was created"),n=1;return}n=await t({origin:i("origin")??"",workspace:i("workspace")??"",host:i("host"),configDir:i("configDir"),local:o.local===!0,sessionFile:i("sessionFile"),json:o.json===!0},{from:d,names:e,yes:o.yes===!0})});for(let[e,o]of[["enable",!0],["disable",!1]])v.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").option("--local","Act on this machine (the only mode; --host picks which joined host)").addHelpText("after",`
34
+ Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOverride().action(async(t)=>{let{hostServicesGrants:i}=await import("./chunk-fjskavhw.js");n=await i({enable:o,caller:y(),...typeof t.host==="string"?{host:t.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:t}=await import("./chunk-45fsefe1.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-45fsefe1.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 r.parseAsync([...a],{from:"user"})}catch(e){if(!(e instanceof P))throw e;return e.code==="commander.helpDisplayed"||e.code==="commander.version"||e.code==="commander.help"?0:1}return n}async function q(a){if(process.stdin.isTTY!==!0){console.error(`this computer can run more than one agent app: ${a.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 s=W({input:process.stdin,output:process.stdout});try{console.log("This computer can run:");for(let[g,_]of a.entries())console.log(` ${g+1}) ${_.name}`);let n=(await s.question(`Which app should this computer's agent be? [1-${a.length}] `)).trim(),r=Number(n),h=Number.isInteger(r)&&r>=1&&r<=a.length?a[r-1]:void 0;if(h===void 0)console.error(`connect: '${n}' is not one of the numbers above. Nothing was redeemed.`);return h}finally{s.close()}}var Y=K(new URL("./plugin/",import.meta.url)),{version:V}=JSON.parse(z(new URL("./plugin/plugin.json",import.meta.url),"utf8"));process.exitCode=await C(process.argv.slice(2),{version:V,pluginDirectory:Y});
@@ -1,2 +1,2 @@
1
- import{m,o,g,n,i}from"./chunk-kq5y08g7.js";import{r}from"./chunk-evg5apz3.js";import{writeJsonAtomic as k}from"@ahpd/sdk";import{existsSync as b}from"node:fs";import{isAbsolute as _,join as S,resolve as A}from"node:path";async function R(e,a,T){if(e.configDir!==void 0){let s=_(e.configDir)?A(e.configDir):void 0;if(s===void 0)return{error:`TRUST_CONFIG_DIR_INVALID: --config-dir needs an absolute path; ${JSON.stringify(e.configDir)} is not one`};if(!b(S(s,"config.json")))return{error:`TRUST_CONFIG_DIR_INVALID: ${s} holds no config.json; name the directory holding this host's ahpd configuration (in a hab-managed host that is its xdg-config/ahpd)`};return{configDir:s,...s===a.configDir?{}:{note:`Trusting in the configuration you named at ${s}; this machine's claim names ${a.configDir}.`}}}let c=(await T.runningAhpds()).filter((s)=>s.hostIds.includes(a.hostId));if(c.length>1)return{error:`TRUST_HOST_AMBIGUOUS: ${String(c.length)} running ahpd processes serve ${a.hostId} (${c.map((s)=>`${String(s.pid)} at ${s.configDir}`).join(", ")}); stop the extras or name one with --config-dir`};let d=c[0];if(d!==void 0)return d.configDir===a.configDir?{configDir:d.configDir}:{configDir:d.configDir,note:`Using the running host's configuration at ${d.configDir} (pid ${String(d.pid)}); this machine's claim names ${a.configDir}, which that host does not read.`};if(e.action==="list")return{configDir:a.configDir,note:`No ahpd process serving ${a.hostId} is running on this machine; reading the claim's copy at ${a.configDir}, which a hab-managed host would not read.`};return{error:`TRUST_NO_RUNNING_HOST: no ahpd process serving ${a.hostId} is running on this machine, so there is no configuration to change; start the host, or name its configuration with --config-dir <dir> (this machine's claim names ${a.configDir})`}}var D="A trusted browser key lets posts made in that browser ask this machine's agents; a trusted host key lets that machine's agents ask them too.";async function h(e,a=()=>new Date,T={runningAhpds:()=>i()}){if(e.action!=="list")try{r(e.caller,"key-trust")}catch(t){return console.error(`${t.message}; nothing was changed`),1}let c=await n(e.host);if("error"in c)return console.error(c.error.replace(/^SERVICE_/u,"TRUST_")),1;let d=await R(e,c,T);if("error"in d)return console.error(d.error),1;let s;try{s=g(d.configDir)}catch(t){return console.error(`${t.message}; it was left unchanged`),1}let l=s.state==="read"?s.keys:[],f=`host ${c.hostId} (${s.file})`;if(d.note!==void 0)console.error(d.note);if(e.action==="list"){if(e.json===!0)return console.log(JSON.stringify({hostId:c.hostId,file:s.file,keys:l})),0;if(e.browsers===!0){if(l.length===0)return console.log(`No browsers are approved on ${f}. A browser's own page shows the code when someone presses "Approve this browser"; approve it here with \`hightea approve <code>\`.`),0;console.log(`Browsers approved on ${f}:`);for(let t of l)console.log(` ${t.name.padEnd(22)} approved ${E(t.addedAt)}${t.personName===void 0?"":` ${t.personName}`}`);return 0}if(l.length===0)return console.log(`No trusted keys for ${f}: room asks to this machine's agents are refused until you add one with \`hightea host trust add <name> <public key>\`.`),0;console.log(`Trusted keys for ${f}:`);for(let t of l)console.log(` ${t.name} key ${t.keyId} added ${t.addedAt}`);return console.log(D),0}if(!m.test(e.name))return console.error("TRUST_NAME_INVALID: a name is 1 to 64 letters, digits, '.', '_' or '-' (single spaces are allowed between them), starting with a letter or digit; nothing was changed"),1;let u=l.find((t)=>t.name===e.name);if(e.action==="remove"){if(u===void 0)return console.error(`TRUST_NAME_UNKNOWN: ${f} trusts no key named ${e.name} (trusted: ${l.map((t)=>t.name).join(", ")||"none"}); nothing was changed`),1;if(!I(s.file,l.filter((t)=>t!==u)))return 1;if(e.browsers===!0)return console.log(`Removed. The next message from ${u.name} will ask again.`),0;return console.log(`Removed ${e.name} (key ${u.keyId}) from ${f}. Asks signed with it are refused from now on.`),0}let y=o(e.publicKey);if("error"in y)return console.error(`${y.error}; nothing was changed`),1;let p=(t)=>{if(e.quiet!==!0)console.log(t)};if(u!==void 0){if(u.publicKey===e.publicKey)return p(`${e.name} (key ${y.keyId}) is already trusted by ${f}; it was left unchanged.`),0;return console.error(`TRUST_NAME_TAKEN: ${f} already trusts another key as ${e.name}; remove it first or pick another name. Nothing was changed`),1}let w=l.find((t)=>t.keyId===y.keyId);if(w!==void 0)return console.error(`TRUST_KEY_TAKEN: ${f} already trusts this key as ${w.name}; nothing was changed`),1;let N={name:e.name,keyId:y.keyId,publicKey:e.publicKey,addedAt:a().toISOString(),...e.personName===void 0||e.personName===""?{}:{personName:e.personName}};if(!I(s.file,[...l,N]))return 1;return p(`Trusted ${e.name} (key ${y.keyId}) on ${f}. ${D}`),0}function E(e){let a=new Date(e);if(Number.isNaN(a.getTime()))return e;return new Intl.DateTimeFormat("sv-SE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(a)}function I(e,a){try{k(e,{v:1,keys:a},{mode:384})}catch(T){return console.error(`TRUST_FILE_UNWRITABLE: ${e}: ${T.message}`),!1}return!0}
1
+ import{m,o,g,n,i}from"./chunk-8td27k15.js";import{r}from"./chunk-evg5apz3.js";import{writeJsonAtomic as k}from"@ahpd/sdk";import{existsSync as b}from"node:fs";import{isAbsolute as _,join as S,resolve as A}from"node:path";async function R(e,a,T){if(e.configDir!==void 0){let s=_(e.configDir)?A(e.configDir):void 0;if(s===void 0)return{error:`TRUST_CONFIG_DIR_INVALID: --config-dir needs an absolute path; ${JSON.stringify(e.configDir)} is not one`};if(!b(S(s,"config.json")))return{error:`TRUST_CONFIG_DIR_INVALID: ${s} holds no config.json; name the directory holding this host's ahpd configuration (in a hab-managed host that is its xdg-config/ahpd)`};return{configDir:s,...s===a.configDir?{}:{note:`Trusting in the configuration you named at ${s}; this machine's claim names ${a.configDir}.`}}}let c=(await T.runningAhpds()).filter((s)=>s.hostIds.includes(a.hostId));if(c.length>1)return{error:`TRUST_HOST_AMBIGUOUS: ${String(c.length)} running ahpd processes serve ${a.hostId} (${c.map((s)=>`${String(s.pid)} at ${s.configDir}`).join(", ")}); stop the extras or name one with --config-dir`};let d=c[0];if(d!==void 0)return d.configDir===a.configDir?{configDir:d.configDir}:{configDir:d.configDir,note:`Using the running host's configuration at ${d.configDir} (pid ${String(d.pid)}); this machine's claim names ${a.configDir}, which that host does not read.`};if(e.action==="list")return{configDir:a.configDir,note:`No ahpd process serving ${a.hostId} is running on this machine; reading the claim's copy at ${a.configDir}, which a hab-managed host would not read.`};return{error:`TRUST_NO_RUNNING_HOST: no ahpd process serving ${a.hostId} is running on this machine, so there is no configuration to change; start the host, or name its configuration with --config-dir <dir> (this machine's claim names ${a.configDir})`}}var D="A trusted browser key lets posts made in that browser ask this machine's agents; a trusted host key lets that machine's agents ask them too.";async function h(e,a=()=>new Date,T={runningAhpds:()=>i()}){if(e.action!=="list")try{r(e.caller,"key-trust")}catch(t){return console.error(`${t.message}; nothing was changed`),1}let c=await n(e.host);if("error"in c)return console.error(c.error.replace(/^SERVICE_/u,"TRUST_")),1;let d=await R(e,c,T);if("error"in d)return console.error(d.error),1;let s;try{s=g(d.configDir)}catch(t){return console.error(`${t.message}; it was left unchanged`),1}let l=s.state==="read"?s.keys:[],f=`host ${c.hostId} (${s.file})`;if(d.note!==void 0)console.error(d.note);if(e.action==="list"){if(e.json===!0)return console.log(JSON.stringify({hostId:c.hostId,file:s.file,keys:l})),0;if(e.browsers===!0){if(l.length===0)return console.log(`No browsers are approved on ${f}. A browser's own page shows the code when someone presses "Approve this browser"; approve it here with \`hightea approve <code>\`.`),0;console.log(`Browsers approved on ${f}:`);for(let t of l)console.log(` ${t.name.padEnd(22)} approved ${E(t.addedAt)}${t.personName===void 0?"":` ${t.personName}`}`);return 0}if(l.length===0)return console.log(`No trusted keys for ${f}: room asks to this machine's agents are refused until you add one with \`hightea host trust add <name> <public key>\`.`),0;console.log(`Trusted keys for ${f}:`);for(let t of l)console.log(` ${t.name} key ${t.keyId} added ${t.addedAt}`);return console.log(D),0}if(!m.test(e.name))return console.error("TRUST_NAME_INVALID: a name is 1 to 64 letters, digits, '.', '_' or '-' (single spaces are allowed between them), starting with a letter or digit; nothing was changed"),1;let u=l.find((t)=>t.name===e.name);if(e.action==="remove"){if(u===void 0)return console.error(`TRUST_NAME_UNKNOWN: ${f} trusts no key named ${e.name} (trusted: ${l.map((t)=>t.name).join(", ")||"none"}); nothing was changed`),1;if(!I(s.file,l.filter((t)=>t!==u)))return 1;if(e.browsers===!0)return console.log(`Removed. The next message from ${u.name} will ask again.`),0;return console.log(`Removed ${e.name} (key ${u.keyId}) from ${f}. Asks signed with it are refused from now on.`),0}let y=o(e.publicKey);if("error"in y)return console.error(`${y.error}; nothing was changed`),1;let p=(t)=>{if(e.quiet!==!0)console.log(t)};if(u!==void 0){if(u.publicKey===e.publicKey)return p(`${e.name} (key ${y.keyId}) is already trusted by ${f}; it was left unchanged.`),0;return console.error(`TRUST_NAME_TAKEN: ${f} already trusts another key as ${e.name}; remove it first or pick another name. Nothing was changed`),1}let w=l.find((t)=>t.keyId===y.keyId);if(w!==void 0)return console.error(`TRUST_KEY_TAKEN: ${f} already trusts this key as ${w.name}; nothing was changed`),1;let N={name:e.name,keyId:y.keyId,publicKey:e.publicKey,addedAt:a().toISOString(),...e.personName===void 0||e.personName===""?{}:{personName:e.personName}};if(!I(s.file,[...l,N]))return 1;return p(`Trusted ${e.name} (key ${y.keyId}) on ${f}. ${D}`),0}function E(e){let a=new Date(e);if(Number.isNaN(a.getTime()))return e;return new Intl.DateTimeFormat("sv-SE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(a)}function I(e,a){try{k(e,{v:1,keys:a},{mode:384})}catch(T){return console.error(`TRUST_FILE_UNWRITABLE: ${e}: ${T.message}`),!1}return!0}
2
2
  export{h};
@@ -1,4 +1,4 @@
1
- import{c}from"./chunk-jaf9mk6s.js";import"./chunk-tay0pyz4.js";import{i}from"./chunk-kq5y08g7.js";import{S,E}from"./chunk-evg5apz3.js";import{readFile as D}from"node:fs/promises";import{join as O}from"node:path";var h=`hightea deploy <service> --pin <sha> [--host <id>] [--json]
1
+ import{c}from"./chunk-jaf9mk6s.js";import"./chunk-tay0pyz4.js";import{i}from"./chunk-8td27k15.js";import{S,E}from"./chunk-evg5apz3.js";import{readFile as D}from"node:fs/promises";import{join as O}from"node:path";var h=`hightea deploy <service> --pin <sha> [--host <id>] [--json]
2
2
  hightea deploy status <service> [--host <id>] [--json]`,P=/^[0-9a-fA-F]{40}$/u,y=()=>({out:(e)=>console.log(e),err:(e)=>console.error(e)}),_=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),u=(e)=>e.hostIds.length>0?`${e.hostIds.join(",")} (pid ${String(e.pid)})`:`pid ${String(e.pid)}`;async function N(e,n){if(e.port!==void 0)return e.port;try{let s=JSON.parse(await n(e.config));if(_(s)&&typeof s.port==="number"&&Number.isInteger(s.port))return s.port}catch{return}return}async function R(e,n){let s=e.connectionTokenFile??O(e.configDir,"connection.token");try{return(await n(s)).trim()||void 0}catch{return}}async function f(e,n={}){let s=n.readFile??((t)=>D(t,"utf8")),a;try{a=await(n.runningAhpds??i)()}catch(t){return{error:`DEPLOY_NO_AHPD: the process table could not be read: ${t.message}`}}let d=e?.trim(),r;if(d!==void 0&&d!==""){let t=a.filter((p)=>p.hostIds.includes(d));if(t.length===0)return{error:`DEPLOY_NO_AHPD: no running ahpd on this machine serves host ${d} (running: ${a.map(u).join("; ")||"none"})`};if(t.length>1)return{error:`DEPLOY_NO_AHPD: ${String(t.length)} running ahpds serve host ${d} (${t.map(u).join("; ")}); the process table cannot tell them apart`};r=t[0]}else{if(a.length===0)return{error:"DEPLOY_NO_AHPD: no running ahpd on this machine; start one with `hightea host join` first"};if(a.length>1)return{error:`DEPLOY_NO_AHPD: this machine runs ${String(a.length)} ahpds (${a.map(u).join("; ")}); name one with --host <id>`};r=a[0]}if(r===void 0)return{error:"DEPLOY_NO_AHPD: no running ahpd on this machine"};let l=await N(r,s);if(l===void 0)return{error:`DEPLOY_NO_AHPD: ${r.config} names no port and its command line has no --port; cannot reach this ahpd`};let o=await R(r,s);return{url:`ws://${r.host??"127.0.0.1"}:${String(l)}`,...o===void 0?{}:{token:o},label:r.hostIds[0]??`pid ${String(r.pid)}`}}async function g(e,n){try{return await(n.connect??c)(e.url,{token:e.token,clientId:"hightea-deploy"})}catch(s){return{error:`DEPLOY_NO_AHPD: ${e.url} did not answer: ${s.message}`}}}var I=(e,n)=>{if(e==="RUNNING")return`DEPLOY_RUNNING: ${n}`;if(e==="UNKNOWN_SERVICE")return`DEPLOY_UNKNOWN_SERVICE: ${n}`;return`DEPLOY_REFUSED ${e}: ${n}`},m=(e)=>/No channel at x-hh-deploys:\/\//u.test(e.message)?"DEPLOY_NO_DRIVER: this ahpd has no deploy driver loaded (x-hh-deploys://); its deploy plugin is not in its configuration":`DEPLOY_DRIVER_UNREADABLE: ${e.message}`;async function x(e,n=y(),s={}){let a=e.service.trim();if(a==="")return n.err(`DEPLOY_SERVICE_REQUIRED: name the service to deploy
3
3
  ${h}`),1;let d=e.pin.trim();if(!P.test(d))return n.err(`DEPLOY_PIN_NOT_SHA: --pin must be a full 40-character commit sha; '${d}' is not`),1;let r=await f(e.host,s);if("error"in r)return n.err(r.error),1;let l=await g(r,s);if("error"in l)return n.err(l.error),1;try{let o=await S(l,{service:a,version:d.toLowerCase()});if(!o.ok)return n.err(I(o.code,o.message)),1;if(e.json)n.out(JSON.stringify({machine:r.label,service:o.service,pin:o.sha,deployId:o.deployId,state:o.state}));else n.out(`started ${o.service} at ${o.sha}: deploy ${o.deployId} on ${r.label}`);return 0}catch(o){return n.err(m(o)),1}finally{l.close()}}var A=(e,n)=>({machine:n,service:e.service,state:e.state,pin:e.to??null,from:e.from??null,...e.step===void 0?{}:{step:e.step},...e.reason===void 0?{}:{reason:e.reason},...e.exit===void 0?{}:{exit:e.exit},deployId:e.deployId,...e.at===void 0?{}:{at:e.at}});async function j(e,n=y(),s={}){let a=e.service.trim();if(a==="")return n.err(`DEPLOY_SERVICE_REQUIRED: name the service to read
4
4
  ${h}`),1;let d=await f(e.host,s);if("error"in d)return n.err(d.error),1;let r=await g(d,s);if("error"in r)return n.err(r.error),1;try{let l=await E(r),o=l.runs.filter((p)=>p.service===a);if(o.length===0){let p=l.error===void 0?"":` (${l.error})`;return n.err(`DEPLOY_UNKNOWN_SERVICE: ${a} has no deploy on ${l.machine||d.label}${p}`),1}let t=A(o[0],l.machine||d.label);if(e.json)n.out(JSON.stringify(t));else n.out(`${t.state} ${t.service} pin ${t.pin??"?"} ${t.step===void 0?"":`${t.step} `}deploy ${t.deployId}${t.reason===void 0?"":` last error: ${t.reason}`}`);return 0}catch(l){return n.err(m(l)),1}finally{r.close()}}export{x as deployPlace,j as deployStatus};
@@ -5,7 +5,7 @@ import"./chunk-kjkww5cr.js";import{t,e}from"./chunk-vzkbknwq.js";import{existsSy
5
5
  `+`hightea service acknowledge (--host … | --local [--host HOST] [--config-dir DIR])
6
6
  `+`hightea service backup --host HOST --origin URL --workspace SLUG [--json]
7
7
  hightea service restore [NAME...] --from OLD_HOST (--host NEW_HOST | --local [--host HOST] [--config-dir DIR]) --origin URL --workspace SLUG [--yes] [--json]
8
- hightea service enable|disable [--host HOST] (run on the machine)`,_=(n)=>typeof n==="object"&&n!==null&&!Array.isArray(n)&&typeof n.ok==="boolean"?n:void 0;function U(n,o){let r=encodeURIComponent((n.host??"").trim()),l=async(c,i,s,f)=>{let u=await e(n,o,{method:c,path:`/hosts/${r}/services${i}`,what:s,label:"SERVICE",...f===void 0?{}:{body:f}});if("error"in u){let m=_(u.body?.answer);return m===void 0?u:{answer:m}}let h=_(u.answer.answer);return h===void 0?{exit:1,error:`SERVICE_ANSWER_INVALID: ${s} answered without the host's answer: ${JSON.stringify(u.answer).slice(0,300)}`}:{answer:h}},a=(c)=>`/${encodeURIComponent(c)}`;return{machine:(n.host??"").trim(),list:()=>l("GET","","list"),put:(c)=>l("PUT",a(String(c.service.name)),"put",c),remove:(c)=>l("DELETE",a(c.name),"remove",{ifVersion:c.ifVersion}),control:(c,i)=>l("POST",`${a(c)}/${i}`,i),logs:(c)=>{let i=new URLSearchParams;if(c.end!==void 0)i.set("end",String(c.end));if(c.limit!==void 0)i.set("limit",String(c.limit));let s=i.size===0?"":`?${i}`;return l("GET",`${a(c.name)}/logs${s}`,"logs")},acknowledge:(c)=>l("POST","/acknowledge","acknowledge",c)}}var W=/(^|[\\/])(@ahpd[\\/]deploy|packages[\\/]deploy|(services|deploy)[\\/]plugin)([\\/]|$)/u;function V(n){if(!P(n)||!n.endsWith("/plugin.json"))return;try{let o=JSON.parse(x(n,"utf8"));return typeof o?.id==="string"?o.id:void 0}catch{return}}async function X(n,o=B().username){let r=L(n,"config.json"),l;try{l=JSON.parse(x(r,"utf8"))}catch{return}let a=l?.plugins,c=(Array.isArray(a)?a:[]).filter((g)=>g!==null&&typeof g==="object"&&typeof g.source==="string"),i=c.filter((g)=>V(g.source)==="services"),s=c.filter((g)=>{if(V(g.source)!=="deploy"&&!W.test(g.source))return!1;let y=g.options;return y!==null&&typeof y==="object"&&(("files"in y)||("socket"in y))}),f=i.length>0?i:s;if(f.length===0)return;if(f.length>1)return`${r} has ${f.length} services plugin entries; keep one`;let{acknowledge:u,acknowledgeFiles:h,changesAt:m,controlService:v,listServices:w,machineOf:S,putService:d,removeService:k,serviceLogs:I}=await import("@hallohuman/hightea-services"),O=f[0].options,A=S(n,O!==null&&typeof O==="object"?O:{});if(typeof A==="string")return A;let{machine:p,stateFile:E}=A;try{C(D(E),{recursive:!0,mode:448}),C(D(p.changeLog),{recursive:!0,mode:448})}catch(g){return`cannot make the services directory for ${p.changeLog}: ${g.message}`}let R={principal:`local:${o}`,remote:!1},N=(g)=>{let y=g;if(y.ok&&(!("changed"in y)||y.changed===!0)&&typeof y.file==="string"&&typeof y.ifVersion==="string")u(E,y.file,y.ifVersion);return g};return{machine:p,caller:R,list:()=>w(p),put:async(g)=>N(await d(p,R,g)),remove:async(g)=>N(await k(p,R,g)),control:(g,y)=>v(p,R,{name:g,verb:y}),logs:(g)=>I(p,R,g),acknowledge:(g)=>h(p,R,g,(y,F)=>u(E,y,F)),changes:(g={},y)=>m(p,g,y)}}async function H(n,o={}){let r;if(n.configDir!==void 0&&n.configDir.trim()!==""){if(!P(n.configDir))return{error:`SERVICE_CONFIG_DIR_INVALID: --config-dir needs an absolute path; ${JSON.stringify(n.configDir)} is not one`};let s=q(n.configDir);if(!M(L(s,"config.json")))return{error:`SERVICE_CONFIG_DIR_INVALID: ${s} holds no config.json; name the directory holding this host's ahpd configuration (in a hab-managed host that is its xdg-config/ahpd)`};r=s}else{let{localHost:s,runningAhpds:f}=await import("./chunk-axj8ef03.js"),h=await(o.localHost??((m)=>s(m,{runningAhpds:o.runningAhpds??f})))(n.host);if("error"in h)return h;r=h.configDir}let{localServices:l,LOG_LINES_MAX:a}=await import("@hallohuman/hightea-services"),c=l(r);if(typeof c==="string"&&c.includes("has no services plugin entry")){let s=await X(r);if(s!==void 0)c=s}if(typeof c==="string")return{error:`SERVICE_NOT_CONFIGURED: ${c}`};let i=(s)=>({answer:s});return{machine:c.machine.name,list:async()=>i(c.list()),put:async(s)=>i(await c.put(s)),remove:async(s)=>i(await c.remove(s)),control:async(s,f)=>i(await c.control(s,f)),logs:async(s)=>i(await c.logs({name:s.name,endOffset:s.end??0,limit:Math.min(s.limit??100,a)})),acknowledge:async(s)=>i(await c.acknowledge(s))}}async function oe(n,o,r=t(),l={}){let a=!n.local;if(a&&((n.host??"").trim()===""||n.workspace.trim()===""))return r.err(`SERVICE_INPUT: name the host with --host and --workspace, or act on this machine with --local.
8
+ hightea service enable|disable [--host HOST] (run on the machine)`,_=(n)=>typeof n==="object"&&n!==null&&!Array.isArray(n)&&typeof n.ok==="boolean"?n:void 0;function U(n,o){let r=encodeURIComponent((n.host??"").trim()),l=async(c,i,s,f)=>{let u=await e(n,o,{method:c,path:`/hosts/${r}/services${i}`,what:s,label:"SERVICE",...f===void 0?{}:{body:f}});if("error"in u){let m=_(u.body?.answer);return m===void 0?u:{answer:m}}let h=_(u.answer.answer);return h===void 0?{exit:1,error:`SERVICE_ANSWER_INVALID: ${s} answered without the host's answer: ${JSON.stringify(u.answer).slice(0,300)}`}:{answer:h}},a=(c)=>`/${encodeURIComponent(c)}`;return{machine:(n.host??"").trim(),list:()=>l("GET","","list"),put:(c)=>l("PUT",a(String(c.service.name)),"put",c),remove:(c)=>l("DELETE",a(c.name),"remove",{ifVersion:c.ifVersion}),control:(c,i)=>l("POST",`${a(c)}/${i}`,i),logs:(c)=>{let i=new URLSearchParams;if(c.end!==void 0)i.set("end",String(c.end));if(c.limit!==void 0)i.set("limit",String(c.limit));let s=i.size===0?"":`?${i}`;return l("GET",`${a(c.name)}/logs${s}`,"logs")},acknowledge:(c)=>l("POST","/acknowledge","acknowledge",c)}}var W=/(^|[\\/])(@ahpd[\\/]deploy|packages[\\/]deploy|(services|deploy)[\\/]plugin)([\\/]|$)/u;function V(n){if(!P(n)||!n.endsWith("/plugin.json"))return;try{let o=JSON.parse(x(n,"utf8"));return typeof o?.id==="string"?o.id:void 0}catch{return}}async function X(n,o=B().username){let r=L(n,"config.json"),l;try{l=JSON.parse(x(r,"utf8"))}catch{return}let a=l?.plugins,c=(Array.isArray(a)?a:[]).filter((g)=>g!==null&&typeof g==="object"&&typeof g.source==="string"),i=c.filter((g)=>V(g.source)==="services"),s=c.filter((g)=>{if(V(g.source)!=="deploy"&&!W.test(g.source))return!1;let y=g.options;return y!==null&&typeof y==="object"&&(("files"in y)||("socket"in y))}),f=i.length>0?i:s;if(f.length===0)return;if(f.length>1)return`${r} has ${f.length} services plugin entries; keep one`;let{acknowledge:u,acknowledgeFiles:h,changesAt:m,controlService:v,listServices:w,machineOf:S,putService:d,removeService:k,serviceLogs:I}=await import("@hallohuman/hightea-services"),O=f[0].options,A=S(n,O!==null&&typeof O==="object"?O:{});if(typeof A==="string")return A;let{machine:p,stateFile:E}=A;try{C(D(E),{recursive:!0,mode:448}),C(D(p.changeLog),{recursive:!0,mode:448})}catch(g){return`cannot make the services directory for ${p.changeLog}: ${g.message}`}let R={principal:`local:${o}`,remote:!1},N=(g)=>{let y=g;if(y.ok&&(!("changed"in y)||y.changed===!0)&&typeof y.file==="string"&&typeof y.ifVersion==="string")u(E,y.file,y.ifVersion);return g};return{machine:p,caller:R,list:()=>w(p),put:async(g)=>N(await d(p,R,g)),remove:async(g)=>N(await k(p,R,g)),control:(g,y)=>v(p,R,{name:g,verb:y}),logs:(g)=>I(p,R,g),acknowledge:(g)=>h(p,R,g,(y,F)=>u(E,y,F)),changes:(g={},y)=>m(p,g,y)}}async function H(n,o={}){let r;if(n.configDir!==void 0&&n.configDir.trim()!==""){if(!P(n.configDir))return{error:`SERVICE_CONFIG_DIR_INVALID: --config-dir needs an absolute path; ${JSON.stringify(n.configDir)} is not one`};let s=q(n.configDir);if(!M(L(s,"config.json")))return{error:`SERVICE_CONFIG_DIR_INVALID: ${s} holds no config.json; name the directory holding this host's ahpd configuration (in a hab-managed host that is its xdg-config/ahpd)`};r=s}else{let{localHost:s,runningAhpds:f}=await import("./chunk-fjskavhw.js"),h=await(o.localHost??((m)=>s(m,{runningAhpds:o.runningAhpds??f})))(n.host);if("error"in h)return h;r=h.configDir}let{localServices:l,LOG_LINES_MAX:a}=await import("@hallohuman/hightea-services"),c=l(r);if(typeof c==="string"&&c.includes("has no services plugin entry")){let s=await X(r);if(s!==void 0)c=s}if(typeof c==="string")return{error:`SERVICE_NOT_CONFIGURED: ${c}`};let i=(s)=>({answer:s});return{machine:c.machine.name,list:async()=>i(c.list()),put:async(s)=>i(await c.put(s)),remove:async(s)=>i(await c.remove(s)),control:async(s,f)=>i(await c.control(s,f)),logs:async(s)=>i(await c.logs({name:s.name,endOffset:s.end??0,limit:Math.min(s.limit??100,a)})),acknowledge:async(s)=>i(await c.acknowledge(s))}}async function oe(n,o,r=t(),l={}){let a=!n.local;if(a&&((n.host??"").trim()===""||n.workspace.trim()===""))return r.err(`SERVICE_INPUT: name the host with --host and --workspace, or act on this machine with --local.
9
9
  ${T}`),1;let c=o.command!=="list"&&o.command!=="acknowledge",i=o.name?.trim()??"";if(c&&i==="")return r.err(`SERVICE_INPUT: ${o.command} names one service.
10
10
  ${T}`),1;let s=a?U(n,r):await(l.local??H)(n);if("error"in s)return r.err(s.error),1;let f=(u,h)=>{if("error"in u)return r.err(u.error),u.exit;let m=u.answer;if(!m.ok){if(r.err(`${String(m.code??"SERVICE_REFUSED")}: ${String(m.message??"the machine refused")}`),typeof m.diff==="string"&&m.diff!=="")r.err(m.diff);if(n.json)r.out(JSON.stringify(m));return 1}if(n.json)r.out(JSON.stringify(m));else h(m);return 0};switch(o.command){case"list":return f(await s.list(),(u)=>r.out(G(u,s.machine)));case"start":case"stop":case"restart":return f(await s.control(i,o.command),()=>r.out(`${o.command}: ${i} on ${s.machine}`));case"logs":{let u=j(o.end,0),h=j(o.limit,1);if(u===null||h===null)return r.err("SERVICE_INPUT: --end and --limit are whole numbers of lines; --limit is at least 1"),1;let m=await s.logs({name:i,...u===void 0?{}:{end:u},...h===void 0?{}:{limit:h}});return f(m,(v)=>{r.out(`raw output from ${i} on ${s.machine}:`);for(let w of Array.isArray(v.lines)?v.lines:[])r.out(String(w))})}case"acknowledge":case"add":case"change":case"remove":{let u=await s.list();if("error"in u)return r.err(u.error),u.exit;if(!u.answer.ok)return f(u,()=>{});let h=String(u.answer.ifVersion??""),v=(Array.isArray(u.answer.services)?u.answer.services:[]).some((d)=>d.name===i);if(o.command==="acknowledge"){let d=u.answer.hashes??{};return f(await s.acknowledge({hashes:d}),()=>r.out(`acknowledged ${Object.keys(d).join(", ")||"no files"} on ${s.machine} as they are now`))}if(o.command==="remove")return f(await s.remove({name:i,ifVersion:h}),()=>r.out(`removed ${i} on ${s.machine}`));if(o.command==="add"&&v)return r.err(`SERVICE_EXISTS: ${i} is already a service on ${s.machine}; use \`hightea service change\``),1;if(o.command==="change"&&!v)return r.err(`SERVICE_NOT_FOUND: ${i} is not a service on ${s.machine}; use \`hightea service add\``),1;let w=z(i,o.fields??{});if(typeof w==="string")return r.err(`SERVICE_INPUT: ${w}`),1;let S=K(u.answer.capabilities,w,s.machine);if(S!==void 0)return r.err(`SERVICE_UNSUPPORTED: ${S} Nothing was sent.`),1;if(o.command==="add"&&w.command===void 0)return r.err("SERVICE_INPUT: a new service needs --command"),1;return f(await s.put({service:w,ifVersion:h}),(d)=>r.out(d.changed===!1?`${i} on ${s.machine} already reads so; nothing was written`:`${o.command==="add"?"added":"changed"} ${i} on ${s.machine}`))}}}function z(n,o){let r={};if(o.patch!==void 0){try{r=JSON.parse(o.patch)}catch{return"--patch is a JSON object of service fields"}if(typeof r!=="object"||r===null||Array.isArray(r))return"--patch is a JSON object of service fields";if(r.name!==void 0&&r.name!==n)return"--patch names another service"}return{...r,name:n,...o.command===void 0?{}:{command:o.command},...o.cwd===void 0?{}:{cwd:o.cwd}}}function K(n,o,r){if(typeof n!=="object"||n===null)return;let{fields:l,schedule:a}=n;if(Array.isArray(l)){let i=Object.keys(o).filter((s)=>!l.includes(s));if(i.length>0)return`${r}'s driver does not take ${i.join(", ")}; it takes ${l.join(", ")}.`}let c=o.schedule;if(Array.isArray(a)&&typeof c==="object"&&c!==null){let s=Object.keys(c).filter((f)=>f==="cron"||f==="interval").filter((f)=>!a.includes(f));if(s.length>0)return`${r}'s driver does not take ${s.map((f)=>`schedule.${f}`).join(", ")}; it takes ${a.map((f)=>`schedule.${String(f)}`).join(", ")}.`}return}function j(n,o){if(n===void 0)return;return/^\d{1,7}$/u.test(n.trim())&&Number(n)>=o?Number(n):null}function G(n,o){let r=Array.isArray(n.services)?n.services:[],l=Array.isArray(n.readOnly)?n.readOnly:[],a=r.map((i)=>{let s=Array.isArray(i.plainEnv)&&i.plainEnv.length>0?` (plain env: ${i.plainEnv.join("; ")})`:"";return`${String(i.name)} ${String(i.command??"")}${s}`});for(let i of l)a.push(`${String(i.name)} read-only: ${String(i.reason)}`);if(a.length===0)a.push(`no services on ${o} (${String(n.file??"its file")})`);let c=Y(n);if(c.length>0){a.push(`drift on ${o} (${c.length}), shown only; nothing was repaired:`);for(let i of c)a.push(` ${i.level}: ${i.text}`)}return a.join(`
11
11
  `)}function Y(n){let o=(l)=>(Array.isArray(l)?l:[]).filter((a)=>b(a)&&typeof a.text==="string").map((a)=>({level:typeof a.level==="string"?a.level:"warning",text:String(a.text)})),r=Array.isArray(n.rows)?n.rows:[];return[...o(n.alerts),...r.flatMap((l)=>b(l)?o(l.alerts):[])]}var b=(n)=>typeof n==="object"&&n!==null&&!Array.isArray(n);async function J(n,o,r){let l=await e(n,o,{method:"GET",path:`/hosts/${encodeURIComponent(r)}/services/backup`,what:"backup",label:"SERVICE"});if("error"in l)return l;let a=l.answer.backup;if(!b(a)||typeof a.label!=="string"||!b(a.listing)||!Array.isArray(a.lines))return{exit:1,error:`SERVICE_ANSWER_INVALID: backup answered without a backup: ${JSON.stringify(l.answer).slice(0,300)}`};return{backup:a}}function Q(n){if(n.unreadable===!0)return`unreadable line at ${String(n.offset)} (${String(n.bytes)} bytes)`;if(n.boundary===!0)return`--- ${String(n.message)} ---`;let o=b(n.refused)?` refused ${String(n.refused.code)}`:"",r=typeof n.name==="string"&&n.name!==""?` ${n.name}`:"";return`${String(n.at??"")} ${String(n.principal??"")} ${String(n.op??"")}${r}${o}`}async function se(n,o=t()){let r=(n.host??"").trim();if(r===""||n.workspace.trim()===""||n.local)return o.err(`SERVICE_INPUT: name the host with --host and --workspace; a backup is read from Hightea, never --local.