@hallohuman/hightea 0.1.30 → 0.1.31

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/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) 2026 Beorn. All rights reserved.
2
+
3
+ This software is proprietary. You may install and run it unmodified only to connect your own machines to a Hightea workspace (hightea.ai). No other right to use, copy, modify, distribute, sublicense or create derivative works is granted.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE SOFTWARE OR ITS USE.
package/dist/bin.js CHANGED
@@ -1,367 +1,29 @@
1
1
  #!/usr/bin/env node
2
-
3
- // src/bin.ts
4
- import { readFileSync } from "node:fs";
5
- import { fileURLToPath } from "node:url";
6
-
7
- // src/cli.ts
8
- import { Command, CommanderError } from "@silvery/commander";
9
- import { homedir } from "node:os";
10
- import { join } from "node:path";
11
- import { createInterface } from "node:readline/promises";
12
- var DEFAULT_ORIGIN = "https://hightea.ai";
13
- function defaultOwnerConfig() {
14
- return join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "hightea", "owner.json");
15
- }
16
- function parseConnectTarget(target) {
17
- const parts = target.split("/");
18
- if (parts.length !== 2)
19
- return null;
20
- const [slug, code] = parts;
21
- if (slug === undefined || code === undefined)
22
- return null;
23
- if (!/^[a-z0-9][a-z0-9-]{0,62}$/u.test(slug))
24
- return null;
25
- if (!/^[A-Za-z0-9_-]{4,128}$/u.test(code))
26
- return null;
27
- return { slug, code };
28
- }
29
- async function runCli(argv, options) {
30
- let code = 0;
31
- const program = new Command("hightea").description("Hightea: join this machine to a Hightea workspace as a host for your own agents.").version(options.version, "-v, --version").exitOverride();
32
- program.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", `
33
- Exit status: 0 previewed or applied; 1 the machine or the workspace refused the plan, or could not be reached.`).exitOverride().action(async (file, flags) => {
34
- const { applyFile } = await import("./chunk-cx3yvvkz.js");
35
- code = await applyFile(file, {
36
- machine: flags.machine ?? "",
37
- token: flags.token ?? process.env.AHP_TKN,
38
- yes: flags.yes === true,
39
- prune: flags.prune === true,
40
- stop: flags.stop === true,
41
- keep: flags.keep === true,
42
- origin: flags.origin ?? "",
43
- workspace: flags.workspace ?? "",
44
- sessionFile: flags.sessionFile,
45
- json: flags.json === true
46
- });
47
- });
48
- program.command("connect <target>").description("Connect this computer to a workspace: run the one command the Hightea page shows.").option("--origin <url>", `The deployment (default: ${DEFAULT_ORIGIN})`).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", `
49
- 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 (target, flags) => {
50
- const parsed = parseConnectTarget(target);
51
- if (parsed === null) {
52
- console.error(`connect: '${target}' is not <workspace>/<code>. Copy the whole command from the workspace's Add a computer step.`);
53
- code = 1;
54
- return;
55
- }
56
- let app;
57
- if (flags.ownerConfig === undefined || flags.app !== undefined) {
58
- const { agentAppsOnPath, describedApp, installLineOf, isShippedApp, noAgentAppsLine } = await import("./chunk-3rgfnt23.js");
59
- const found = await agentAppsOnPath();
60
- if (flags.app === undefined) {
61
- if (found.length === 0) {
62
- console.error(noAgentAppsLine());
63
- code = 1;
64
- return;
65
- }
66
- const chosen = found.length === 1 ? found[0] : await chooseAgentApp(found);
67
- if (chosen === undefined) {
68
- code = 1;
69
- return;
70
- }
71
- app = chosen.id;
72
- } else if (!isShippedApp(flags.app)) {
73
- console.error(`connect: '${flags.app}' is not an agent app this command can add. Run connect without --app to see the ones this computer can run.`);
74
- code = 1;
75
- return;
76
- } else {
77
- const chosen = found.find((candidate) => candidate.id === flags.app);
78
- if (chosen === undefined) {
79
- const row = describedApp(flags.app);
80
- console.error(`${row.name} is not on this computer: install it with \`${installLineOf(row)}\`, then run the same command again. Nothing was redeemed and nothing was written.`);
81
- code = 1;
82
- return;
83
- }
84
- app = chosen.id;
85
- }
86
- }
87
- const { hostJoin } = await import("./chunk-ph04jess.js");
88
- const ownerConfigIsDefault = flags.ownerConfig === undefined;
89
- code = await hostJoin({
90
- origin: flags.origin ?? DEFAULT_ORIGIN,
91
- workspace: parsed.slug,
92
- code: parsed.code,
93
- ownerConfig: flags.ownerConfig ?? defaultOwnerConfig(),
94
- ownerConfigIsDefault,
95
- ...app === undefined ? {} : { app, workingDirectory: process.cwd() }
96
- }, { directory: options.pluginDirectory, version: options.version });
97
- });
98
- const host = program.command("host").description("Hosts: this machine joining a workspace, and the workspace's registered hosts.").exitOverride();
99
- host.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 D}from"node:fs";import{fileURLToPath as C}from"node:url";import{Command as E,CommanderError as F}from"@silvery/commander";import{homedir as _}from"node:os";import{join as b}from"node:path";import{createInterface as A}from"node:readline/promises";var O="https://hightea.ai";function N(){return b(process.env.XDG_CONFIG_HOME??b(_(),".config"),"hightea","owner.json")}function I(c){let r=c.split("/");if(r.length!==2)return null;let[n,s]=r;if(n===void 0||s===void 0)return null;if(!/^[a-z0-9][a-z0-9-]{0,62}$/u.test(n))return null;if(!/^[A-Za-z0-9_-]{4,128}$/u.test(s))return null;return{slug:n,code:s}}async function S(c,r){let n=0,s=new E("hightea").description("Hightea: join this machine to a Hightea workspace as a host for your own agents.").version(r.version,"-v, --version").exitOverride();s.command("apply <file>").description("Apply a native process-compose file, or a TypeScript program that returns a plan: to one machine's ahpd, and a plan's hosts as join links the machines consume. Preview first, write only with --yes.").option("--machine <url>","The machine's ahpd WebSocket endpoint, e.g. ws://127.0.0.1:7777; required unless the plan names only hosts").option("--token <token>","The machine's token for this client (default: AHP_TKN)").option("--yes","Send the previewed changes; without it nothing is sent").option("--prune","After the preview lists them, remove entries this same source created that the plan no longer carries").option("--stop","With --prune: stop each program, then remove its entry").option("--keep","With --prune: leave each program running here and clear its source, so it is no longer pruned").option("--origin <url>","The deployment, for host entries: the workspace mints their join links as you").option("--workspace <slug>","The workspace slug, with --origin, for host entries").option("--session-file <file>","The ht_session cookie file for the person routes (default: your stored sign-in)").option("--json","Print one JSON document").addHelpText("after",`
3
+ Exit status: 0 previewed or applied; 1 the machine or the workspace refused the plan, or could not be reached.`).exitOverride().action(async(e,o)=>{let{applyFile:t}=await import("./chunk-8rbp82rh.js");n=await t(e,{machine:o.machine??"",token:o.token??process.env.AHP_TKN,yes:o.yes===!0,prune:o.prune===!0,stop:o.stop===!0,keep:o.keep===!0,origin:o.origin??"",workspace:o.workspace??"",sessionFile:o.sessionFile,json:o.json===!0})}),s.command("connect <target>").description("Connect this computer to a workspace: run the one command the Hightea page shows.").option("--origin <url>",`The deployment (default: ${O})`).option("--owner-config <file>","This computer's agent apps, provider plugins and credentials (default: your Hightea config directory)").option("--app <app>","The agent app to run here, when this computer can run more than one (skips the question)").addHelpText("after",`
4
+ Exit status: 0 connected; 2 pending, rerun the same command; 3 not authorised for that workspace; 1 any other failure, named on stderr.`).exitOverride().action(async(e,o)=>{let t=I(e);if(t===null){console.error(`connect: '${e}' is not <workspace>/<code>. Copy the whole command from the workspace's Add a computer step.`),n=1;return}let i;if(o.ownerConfig===void 0||o.app!==void 0){let{agentAppsOnPath:m,describedApp:j,installLineOf:a,isShippedApp:y,noAgentAppsLine:H}=await import("./chunk-db8mr7mp.js"),g=await m();if(o.app===void 0){if(g.length===0){console.error(H()),n=1;return}let w=g.length===1?g[0]:await L(g);if(w===void 0){n=1;return}i=w.id}else if(!y(o.app)){console.error(`connect: '${o.app}' is not an agent app this command can add. Run connect without --app to see the ones this computer can run.`),n=1;return}else{let w=g.find((v)=>v.id===o.app);if(w===void 0){let v=j(o.app);console.error(`${v.name} is not on this computer: install it with \`${a(v)}\`, then run the same command again. Nothing was redeemed and nothing was written.`),n=1;return}i=w.id}}let{hostJoin:p}=await import("./chunk-xy8j3npr.js"),T=o.ownerConfig===void 0;n=await p({origin:o.origin??O,workspace:t.slug,code:t.code,ownerConfig:o.ownerConfig??N(),ownerConfigIsDefault:T,...i===void 0?{}:{app:i,workingDirectory:process.cwd()}},{directory:r.pluginDirectory,version:r.version})});let d=s.command("host").description("Hosts: this machine joining a workspace, and the workspace's registered hosts.").exitOverride();d.command("join").description("Join this machine to a workspace with a one-use host join code from the workspace owner (the long form of connect).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--code <code>","The one-use join code").option("--owner-config <file>","Your owner configuration: agents, provider plugins and their credentials").option("--host <id>","The host this machine already is: add this code's agents to it instead of registering another computer").addHelpText("after",`
100
5
  Exit status: 0 registered; 2 pending, rerun the same command; 3 not authorised for that workspace or agent;
101
- 4 an agent is already bound to another host; 1 any other failure.`).exitOverride().action(async (flags) => {
102
- const { hostJoin } = await import("./chunk-ph04jess.js");
103
- code = await hostJoin({
104
- origin: flags.origin ?? "",
105
- workspace: flags.workspace ?? "",
106
- code: flags.code ?? "",
107
- ownerConfig: flags.ownerConfig ?? "",
108
- ...flags.host === undefined ? {} : { hostId: flags.host }
109
- }, { directory: options.pluginDirectory, version: options.version });
110
- });
111
- host.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", `
112
- Exit status: 0 listed; 3 your account is not a person of this workspace; 1 any other failure.`).exitOverride().action(async (flags) => {
113
- const { hostList } = await import("./chunk-9e325ntw.js");
114
- code = await hostList({
115
- origin: flags.origin ?? "",
116
- workspace: flags.workspace ?? "",
117
- sessionFile: flags.sessionFile,
118
- json: flags.json === true
119
- });
120
- });
121
- host.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", `
122
- 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 (flags) => {
123
- const { hostRemove } = await import("./chunk-9e325ntw.js");
124
- code = await hostRemove({
125
- origin: flags.origin ?? "",
126
- workspace: flags.workspace ?? "",
127
- host: flags.host ?? "",
128
- removeAgents: flags.removeAgents === true,
129
- sessionFile: flags.sessionFile,
130
- json: flags.json === true
131
- });
132
- });
133
- host.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 (flags) => {
134
- const { hostStatus } = await import("./chunk-ph04jess.js");
135
- code = await hostStatus({ version: options.version, json: flags.json === true });
136
- });
137
- host.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-xy8j3npr.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",code:e.code??"",ownerConfig:e.ownerConfig??"",...e.host===void 0?{}:{hostId:e.host}},{directory:r.pluginDirectory,version:r.version})}),d.command("list").description("List the workspace's registered hosts and which agents each runs; a workspace owner sees every host.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
7
+ Exit status: 0 listed; 3 your account is not a person of this workspace; 1 any other failure.`).exitOverride().action(async(e)=>{let{hostList:o}=await import("./chunk-19pwmgzg.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",sessionFile:e.sessionFile,json:e.json===!0})}),d.command("remove").description("Remove a registered host from a workspace, as the workspace owner; its agents need a new join code.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--host <id>","The registered host's id, e.g. host_01").option("--remove-agents","Also delete the agents this computer ran; without it they stay members and can join again").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
8
+ Exit status: 0 removed or already removed; 3 your account is not this workspace's owner; 1 any other failure, including an unknown host id.`).exitOverride().action(async(e)=>{let{hostRemove:o}=await import("./chunk-19pwmgzg.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",host:e.host??"",removeAgents:e.removeAgents===!0,sessionFile:e.sessionFile,json:e.json===!0})}),d.command("status").description("Show every joined host on this machine and whether its plugin bundle is intact. Changes nothing.").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostStatus:o}=await import("./chunk-xy8j3npr.js");n=await o({version:r.version,json:e.json===!0})}),d.command("update").description("Move a joined host on this machine to this CLI's plugin bundle; same host id and credentials. Restart the host after.").option("--host <id>","The joined host's id, when this machine holds more than one").addHelpText("after",`
138
9
  The old bundle is kept until the host has connected once on the new one; a later update removes it.
139
- ` + `A bundle newer than this CLI's is refused (HOST_UPDATE_DOWNGRADE).
140
- Exit status: 0 updated or already current; 1 any refusal, named on stderr.`).exitOverride().action(async (flags) => {
141
- const { hostUpdate } = await import("./chunk-ph04jess.js");
142
- code = await hostUpdate({ host: flags.host }, { directory: options.pluginDirectory, version: options.version });
143
- });
144
- const trust = host.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", `
10
+ A bundle newer than this CLI's is refused (HOST_UPDATE_DOWNGRADE).
11
+ Exit status: 0 updated or already current; 1 any refusal, named on stderr.`).exitOverride().action(async(e)=>{let{hostUpdate:o}=await import("./chunk-xy8j3npr.js");n=await o({host:e.host},{directory:r.pluginDirectory,version:r.version})});let l=d.command("trust").description("The older spelling of `hightea browsers`; the same file backs both, and the key commands also serve computer-to-computer asks.").addHelpText("after",`
145
12
  What it protects against: an ask forged by a compromised Hightea server or database.
146
- ` + `What it does not: a compromised page script, since the script that signs comes from Hightea, or a process
147
- ` + "running as this machine's user, which can edit trusted-keys.json as it can config.json.").exitOverride();
148
- trust.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", `
149
- Exit status: 0 trusted or already trusted; 1 any failure, with the file left unchanged.`).exitOverride().action(async (name, publicKey, flags) => {
150
- const { hostTrust } = await import("./chunk-0r70ekxd.js");
151
- code = await hostTrust({ action: "add", name, publicKey, ...flags.host === undefined ? {} : { host: flags.host }, ...flags.configDir === undefined ? {} : { configDir: flags.configDir } });
152
- });
153
- trust.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", `
154
- Exit status: 0 removed; 1 any failure, including an unknown name, with the file left unchanged.`).exitOverride().action(async (name, flags) => {
155
- const { hostTrust } = await import("./chunk-0r70ekxd.js");
156
- code = await hostTrust({ action: "remove", name, ...flags.host === undefined ? {} : { host: flags.host }, ...flags.configDir === undefined ? {} : { configDir: flags.configDir } });
157
- });
158
- trust.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 (flags) => {
159
- const { hostTrust } = await import("./chunk-0r70ekxd.js");
160
- code = await hostTrust({ action: "list", json: flags.json === true, ...flags.host === undefined ? {} : { host: flags.host }, ...flags.configDir === undefined ? {} : { configDir: flags.configDir } });
161
- });
162
- program.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", `
163
- 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 (given, flags) => {
164
- const { hostApprove } = await import("./chunk-h8pdqn31.js");
165
- code = await hostApprove({
166
- code: given,
167
- json: flags.json === true,
168
- ...flags.host === undefined ? {} : { host: flags.host },
169
- ...flags.configDir === undefined ? {} : { configDir: flags.configDir },
170
- ...flags.origin === undefined ? {} : { origin: flags.origin },
171
- ...flags.workspace === undefined ? {} : { workspace: flags.workspace }
172
- });
173
- });
174
- const browsers = program.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 (flags) => {
175
- const { hostTrust } = await import("./chunk-0r70ekxd.js");
176
- code = await hostTrust({ action: "list", browsers: true, json: flags.json === true, ...flags.host === undefined ? {} : { host: flags.host }, ...flags.configDir === undefined ? {} : { configDir: flags.configDir } });
177
- });
178
- browsers.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 (name, flags) => {
179
- const { hostTrust } = await import("./chunk-0r70ekxd.js");
180
- code = await hostTrust({ action: "remove", name, browsers: true, ...flags.host === undefined ? {} : { host: flags.host }, ...flags.configDir === undefined ? {} : { configDir: flags.configDir } });
181
- });
182
- const auth = program.command("auth").description("Sign this machine in to a Hightea deployment for the owner commands.").exitOverride();
183
- auth.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", `
184
- Exit status: 0 signed in; 1 any other failure, named on stderr.`).exitOverride().action(async (flags) => {
185
- const { authLogin } = await import("./chunk-d5h204vj.js");
186
- code = await authLogin({ origin: flags.origin ?? "", noBrowser: flags.browser === false, json: flags.json === true });
187
- });
188
- auth.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 (flags) => {
189
- const { authStatus } = await import("./chunk-d5h204vj.js");
190
- code = await authStatus({ origin: flags.origin ?? "", json: flags.json === true });
191
- });
192
- auth.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 (flags) => {
193
- const { authLogout } = await import("./chunk-d5h204vj.js");
194
- code = await authLogout({ origin: flags.origin ?? "", json: flags.json === true });
195
- });
196
- const source = program.command("source").description("A workspace's km sources: bind one to a host, unbind it, or read its state.").exitOverride();
197
- source.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", `
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,t)=>{let{hostTrust:i}=await import("./chunk-8x5daqht.js");n=await i({action:"add",name:e,publicKey:o,...t.host===void 0?{}:{host:t.host},...t.configDir===void 0?{}:{configDir:t.configDir}})}),l.command("remove").description("Stop trusting the key with this name; asks signed with it are refused from then on.").argument("<name>","The key's name, as `hightea host trust list` shows it").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").addHelpText("after",`
16
+ Exit status: 0 removed; 1 any failure, including an unknown name, with the file left unchanged.`).exitOverride().action(async(e,o)=>{let{hostTrust:t}=await import("./chunk-8x5daqht.js");n=await t({action:"remove",name:e,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})}),l.command("list").description("List the keys this machine trusts. Changes nothing.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to read, when the running host is not found").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostTrust:o}=await import("./chunk-8x5daqht.js");n=await o({action:"list",json:e.json===!0,...e.host===void 0?{}:{host:e.host},...e.configDir===void 0?{}:{configDir:e.configDir}})}),s.command("approve <code>").description("Approve a browser to ask this computer's agents, using the code that browser shows.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").option("--origin <url>","The deployment, when this machine's claim does not record it").option("--workspace <slug>","The workspace slug, when this machine's claim does not record it").option("--json","Print one JSON document").addHelpText("after",`
17
+ Then come back to the browser: the message that asked sends itself. Exit status: 0 approved; 1 anything else, named on stderr, with the trusted-keys file left unchanged.`).exitOverride().action(async(e,o)=>{let{hostApprove:t}=await import("./chunk-gcqhggbh.js");n=await t({code:e,json:o.json===!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir},...o.origin===void 0?{}:{origin:o.origin},...o.workspace===void 0?{}:{workspace:o.workspace}})}),s.command("browsers").description("The browsers approved to ask this computer's agents.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to read, when the running host is not found").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{hostTrust:o}=await import("./chunk-8x5daqht.js");n=await o({action:"list",browsers:!0,json:e.json===!0,...e.host===void 0?{}:{host:e.host},...e.configDir===void 0?{}:{configDir:e.configDir}})}).command("remove <name>").description("Stop trusting a browser; its next message asks again.").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").option("--config-dir <dir>","The ahpd configuration directory to change, when the running host is not found").exitOverride().action(async(e,o)=>{let{hostTrust:t}=await import("./chunk-8x5daqht.js");n=await t({action:"remove",name:e,browsers:!0,...o.host===void 0?{}:{host:o.host},...o.configDir===void 0?{}:{configDir:o.configDir}})});let k=s.command("auth").description("Sign this machine in to a Hightea deployment for the owner commands.").exitOverride();k.command("login").description("Sign in with a short code confirmed in your browser, and store the session for this deployment.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--no-browser","Print the confirmation URL instead of opening it").option("--json","Print one JSON document with the account and expiry, never the tokens").addHelpText("after",`
18
+ Exit status: 0 signed in; 1 any other failure, named on stderr.`).exitOverride().action(async(e)=>{let{authLogin:o}=await import("./chunk-jdzvh3gk.js");n=await o({origin:e.origin??"",noBrowser:e.browser===!1,json:e.json===!0})}),k.command("status").description("Show which account this machine is signed in as for a deployment. Changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--json","Print one JSON document with the account and expiry, never the tokens").exitOverride().action(async(e)=>{let{authStatus:o}=await import("./chunk-jdzvh3gk.js");n=await o({origin:e.origin??"",json:e.json===!0})}),k.command("logout").description("Revoke this machine's session at the deployment and forget its local credential.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{authLogout:o}=await import("./chunk-jdzvh3gk.js");n=await o({origin:e.origin??"",json:e.json===!0})});let u=s.command("source").description("A workspace's km sources: bind one to a host, unbind it, or read its state.").exitOverride();u.command("bind-linear").description("Bind one Linear team as a cloud dataset, as the workspace owner (#37446).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--team <id>","The Linear team id (`hightea source teams` lists them)").option("--refresh <every>","Refresh interval to declare at bind time: 5m, 1h, 2d (default: 5m)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
19
+ Exit status: 0 bound; 3 your account is not this workspace's owner; 1 any other failure, including a
20
+ workspace that has not authorized Linear, a team the token cannot see, or an interval under 5 minutes.`).exitOverride().action(async(e)=>{let{sourceBindLinear:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",team:e.team??"",refresh:e.refresh,sessionFile:e.sessionFile,json:e.json===!0})}),u.command("teams").description("List the Linear teams this workspace's token can see, as the workspace owner (#37446).").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{sourceTeams:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("bind").description("Bind a km source to one of the workspace's hosts, as the workspace owner.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--host <id>","The host id that serves the source").option("--refresh <every>","Refresh interval to declare at bind time: 1h, 30m, 2d (default: none)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
198
21
  Exit status: 0 bound; 3 your account is not this workspace's owner; 4 that source is bound to another host;
199
- 1 any other failure.`).exitOverride().action(async (flags) => {
200
- const { sourceBind } = await import("./chunk-5mezgvms.js");
201
- code = await sourceBind({
202
- origin: flags.origin ?? "",
203
- workspace: flags.workspace ?? "",
204
- source: flags.source ?? "",
205
- host: flags.host ?? "",
206
- refresh: flags.refresh,
207
- sessionFile: flags.sessionFile,
208
- json: flags.json === true
209
- });
210
- });
211
- source.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", `
212
- 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 (flags) => {
213
- const { sourceUnbind } = await import("./chunk-5mezgvms.js");
214
- code = await sourceUnbind({
215
- origin: flags.origin ?? "",
216
- workspace: flags.workspace ?? "",
217
- source: flags.source ?? "",
218
- sessionFile: flags.sessionFile,
219
- json: flags.json === true
220
- });
221
- });
222
- source.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 (flags) => {
223
- const { sourceShow } = await import("./chunk-5mezgvms.js");
224
- code = await sourceShow({
225
- origin: flags.origin ?? "",
226
- workspace: flags.workspace ?? "",
227
- source: flags.source ?? "",
228
- sessionFile: flags.sessionFile,
229
- json: flags.json === true
230
- });
231
- });
232
- source.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", `
233
- 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 (flags) => {
234
- const { sourceSetRefresh } = await import("./chunk-5mezgvms.js");
235
- code = await sourceSetRefresh({
236
- origin: flags.origin ?? "",
237
- workspace: flags.workspace ?? "",
238
- source: flags.source ?? "",
239
- every: flags.every ?? "",
240
- sessionFile: flags.sessionFile,
241
- json: flags.json === true
242
- });
243
- });
244
- const service = program.command("service").description("A machine's services under process-compose: list, change, start, stop, read logs; from Hightea or on the machine.").exitOverride();
245
- const serviceAction = (command, description, options = {}) => {
246
- const sub = service.command(command).description(description);
247
- if (options.named)
248
- sub.argument("<name>", "The service's name, as process-compose knows it");
249
- sub.option("--host <id>", "The registered host's id; with --local, which of this machine's joined hosts").option("--local", "Act on this machine, in-process, as you").option("--origin <url>", "The deployment, e.g. https://hightea.dev (with --host)").option("--workspace <slug>", "The workspace slug (with --host)").option("--session-file <file>", "File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json", "Print the machine's answer as one JSON document");
250
- if (options.fields) {
251
- sub.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)");
252
- }
253
- if (options.logs) {
254
- sub.option("--limit <lines>", "How many lines (the machine caps it)").option("--end <lines>", "Lines back from the newest the read ends at (default 0)");
255
- }
256
- sub.addHelpText("after", `
257
- Exit status: 0 done; 3 your account may not manage this host's services; 1 any other failure, named on stderr.`).exitOverride().action(async (...args) => {
258
- const name = options.named ? String(args[0]) : undefined;
259
- const flags = options.named ? args[1] : args[0];
260
- const { serviceCommand } = await import("./chunk-y5r2yxx1.js");
261
- const text = (key) => typeof flags[key] === "string" ? flags[key] : undefined;
262
- code = await serviceCommand({
263
- origin: text("origin") ?? "",
264
- workspace: text("workspace") ?? "",
265
- host: text("host"),
266
- local: flags.local === true,
267
- sessionFile: text("sessionFile"),
268
- json: flags.json === true
269
- }, { command, name, fields: { command: text("command"), cwd: text("cwd"), patch: text("patch") }, end: text("end"), limit: text("limit") });
270
- });
271
- };
272
- serviceAction("list", "List the machine's services, which are read-only and why. Shows commands and paths.");
273
- serviceAction("add", "Add a service to the machine's own process-compose file.", { named: true, fields: true });
274
- serviceAction("change", "Change a service in the machine's own process-compose file.", { named: true, fields: true });
275
- serviceAction("remove", "Take a service out of the machine's own process-compose file.", { named: true });
276
- serviceAction("start", "Start a service.", { named: true });
277
- serviceAction("stop", "Stop a service.", { named: true });
278
- serviceAction("restart", "Restart a service.", { named: true });
279
- serviceAction("logs", "One bounded read of a service's raw output; nothing is kept.", { named: true, logs: true });
280
- serviceAction("acknowledge", "Accept the process-compose files as they are now, so drift stops alerting on a hand edit.");
281
- service.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", `
282
- Exit status: 0 shown; 3 your account may not read this host's backup; 1 any other failure, named on stderr.`).exitOverride().action(async (flags) => {
283
- const { serviceBackupCommand } = await import("./chunk-y5r2yxx1.js");
284
- const text = (key) => typeof flags[key] === "string" ? flags[key] : undefined;
285
- code = await serviceBackupCommand({
286
- origin: text("origin") ?? "",
287
- workspace: text("workspace") ?? "",
288
- host: text("host"),
289
- local: false,
290
- sessionFile: text("sessionFile"),
291
- json: flags.json === true
292
- });
293
- });
294
- service.command("restore").description("Create a host's backed-up services on a new host, create-only: shows what it will create and asks first.").argument("[names...]", "Which services; every one in the backup when none is named").requiredOption("--from <id>", "The old host whose backup is read").option("--host <id>", "The new registered host's id; with --local, which of this machine's joined hosts").option("--local", "Create them on this machine, in-process, as you").option("--origin <url>", "The deployment, e.g. https://hightea.dev").option("--workspace <slug>", "The workspace slug").option("--session-file <file>", "File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--yes", "Do not ask; for scripts").option("--json", "Print each service's outcome as one JSON document").addHelpText("after", `
295
- 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 (names, flags) => {
296
- const { serviceRestore } = await import("./chunk-y5r2yxx1.js");
297
- const text = (key) => typeof flags[key] === "string" ? flags[key] : undefined;
298
- code = await serviceRestore({
299
- origin: text("origin") ?? "",
300
- workspace: text("workspace") ?? "",
301
- host: text("host"),
302
- local: flags.local === true,
303
- sessionFile: text("sessionFile"),
304
- json: flags.json === true
305
- }, { from: text("from") ?? "", names, yes: flags.yes === true });
306
- });
307
- for (const [verb, enable] of [["enable", true], ["disable", false]]) {
308
- service.command(verb).description(enable ? "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", `
309
- Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOverride().action(async (flags) => {
310
- const { hostServicesGrants } = await import("./chunk-ph04jess.js");
311
- code = await hostServicesGrants({ enable, ...typeof flags.host === "string" ? { host: flags.host } : {} });
312
- });
313
- }
314
- const deploy = program.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", `
315
- Exit status: 0 started; 1 any refusal or failure, named on stderr.`).exitOverride().action(async (serviceName, flags) => {
316
- const { deployPlace } = await import("./chunk-gk8tyqac.js");
317
- code = await deployPlace({
318
- service: serviceName,
319
- pin: typeof flags.pin === "string" ? flags.pin : "",
320
- host: typeof flags.host === "string" ? flags.host : undefined,
321
- json: flags.json === true
322
- });
323
- });
324
- deploy.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`.\n" + "Exit status: 0 read; 1 no ahpd or no such service on it, named on stderr.").exitOverride().action(async (...args) => {
325
- const serviceName = String(args[0]);
326
- const { deployStatus } = await import("./chunk-gk8tyqac.js");
327
- const flags = args[2].optsWithGlobals();
328
- code = await deployStatus({
329
- service: serviceName,
330
- host: typeof flags.host === "string" ? flags.host : undefined,
331
- json: flags.json === true
332
- });
333
- });
334
- try {
335
- await program.parseAsync([...argv], { from: "user" });
336
- } catch (error) {
337
- if (!(error instanceof CommanderError))
338
- throw error;
339
- return error.code === "commander.helpDisplayed" || error.code === "commander.version" || error.code === "commander.help" ? 0 : 1;
340
- }
341
- return code;
342
- }
343
- async function chooseAgentApp(found) {
344
- if (process.stdin.isTTY !== true) {
345
- console.error(`this computer can run more than one agent app: ${found.map((app) => `${app.name} (${app.id})`).join(", ")}. ` + "Run the same command in a terminal to choose, or add --app <id>. Nothing was redeemed.");
346
- return;
347
- }
348
- const ask = createInterface({ input: process.stdin, output: process.stdout });
349
- try {
350
- console.log("This computer can run:");
351
- for (const [index, app] of found.entries())
352
- console.log(` ${index + 1}) ${app.name}`);
353
- const answer = (await ask.question(`Which app should this computer's agent be? [1-${found.length}] `)).trim();
354
- const index = Number(answer);
355
- const chosen = Number.isInteger(index) && index >= 1 && index <= found.length ? found[index - 1] : undefined;
356
- if (chosen === undefined)
357
- console.error(`connect: '${answer}' is not one of the numbers above. Nothing was redeemed.`);
358
- return chosen;
359
- } finally {
360
- ask.close();
361
- }
362
- }
363
-
364
- // src/bin.ts
365
- var pluginDirectory = fileURLToPath(new URL("./plugin/", import.meta.url));
366
- var { version } = JSON.parse(readFileSync(new URL("./plugin/plugin.json", import.meta.url), "utf8"));
367
- process.exitCode = await runCli(process.argv.slice(2), { version, pluginDirectory });
22
+ 1 any other failure.`).exitOverride().action(async(e)=>{let{sourceBind:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",host:e.host??"",refresh:e.refresh,sessionFile:e.sessionFile,json:e.json===!0})}),u.command("unbind").description("Take a km source out of service, as the workspace owner; its rows stay and read as unbound.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
23
+ Exit status: 0 unbound; 3 your account is not this workspace's owner; 1 any other failure, including a source that is not bound.`).exitOverride().action(async(e)=>{let{sourceUnbind:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("show").description("Read one source's binding, freshness and position; changes nothing.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").exitOverride().action(async(e)=>{let{sourceShow:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",sessionFile:e.sessionFile,json:e.json===!0})}),u.command("set-refresh").description("Give a bound source a refresh interval (1h, 30m, 2d) or clear it with none; as the workspace owner.").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--source <id>","The source id, e.g. src_km").option("--every <interval>","45s, 30m, 1h, 2d, or none to clear; the shortest allowed is 5m").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print one JSON document").addHelpText("after",`
24
+ Exit status: 0 set; 3 your account is not this workspace's owner; 1 any other failure, including an interval under 5 minutes.`).exitOverride().action(async(e)=>{let{sourceSetRefresh:o}=await import("./chunk-5s85pw9m.js");n=await o({origin:e.origin??"",workspace:e.workspace??"",source:e.source??"",every:e.every??"",sessionFile:e.sessionFile,json:e.json===!0})});let f=s.command("service").description("A machine's services under process-compose: list, change, start, stop, read logs; from Hightea or on the machine.").exitOverride(),h=(e,o,t={})=>{let i=f.command(e).description(o);if(t.named)i.argument("<name>","The service's name, as process-compose knows it");if(i.option("--host <id>","The registered host's id; with --local, which of this machine's joined hosts").option("--local","Act on this machine, in-process, as you").option("--origin <url>","The deployment, e.g. https://hightea.dev (with --host)").option("--workspace <slug>","The workspace slug (with --host)").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print the machine's answer as one JSON document"),t.fields)i.option("--command <cmd>","The program's command line").option("--cwd <dir>","The directory it runs in").option("--patch <json>","Any other service fields, as a JSON object (env, schedule, restart, depends_on, health)");if(t.logs)i.option("--limit <lines>","How many lines (the machine caps it)").option("--end <lines>","Lines back from the newest the read ends at (default 0)");i.addHelpText("after",`
25
+ Exit status: 0 done; 3 your account may not manage this host's services; 1 any other failure, named on stderr.`).exitOverride().action(async(...p)=>{let T=t.named?String(p[0]):void 0,m=t.named?p[1]:p[0],{serviceCommand:j}=await import("./chunk-dkzzzkex.js"),a=(y)=>typeof m[y]==="string"?m[y]:void 0;n=await j({origin:a("origin")??"",workspace:a("workspace")??"",host:a("host"),local:m.local===!0,sessionFile:a("sessionFile"),json:m.json===!0},{command:e,name:T,fields:{command:a("command"),cwd:a("cwd"),patch:a("patch")},end:a("end"),limit:a("limit")})})};h("list","List the machine's services, which are read-only and why. Shows commands and paths."),h("add","Add a service to the machine's own process-compose file.",{named:!0,fields:!0}),h("change","Change a service in the machine's own process-compose file.",{named:!0,fields:!0}),h("remove","Take a service out of the machine's own process-compose file.",{named:!0}),h("start","Start a service.",{named:!0}),h("stop","Stop a service.",{named:!0}),h("restart","Restart a service.",{named:!0}),h("logs","One bounded read of a service's raw output; nothing is kept.",{named:!0,logs:!0}),h("acknowledge","Accept the process-compose files as they are now, so drift stops alerting on a hand edit."),f.command("backup").description("Show Hightea's backup of a host's services and their change log, labelled with how far it reaches; works while the host is offline or revoked.").requiredOption("--host <id>","The registered host's id").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json","Print the backup as one JSON document").addHelpText("after",`
26
+ Exit status: 0 shown; 3 your account may not read this host's backup; 1 any other failure, named on stderr.`).exitOverride().action(async(e)=>{let{serviceBackupCommand:o}=await import("./chunk-dkzzzkex.js"),t=(i)=>typeof e[i]==="string"?e[i]:void 0;n=await o({origin:t("origin")??"",workspace:t("workspace")??"",host:t("host"),local:!1,sessionFile:t("sessionFile"),json:e.json===!0})}),f.command("restore").description("Create a host's backed-up services on a new host, create-only: shows what it will create and asks first.").argument("[names...]","Which services; every one in the backup when none is named").requiredOption("--from <id>","The old host whose backup is read").option("--host <id>","The new registered host's id; with --local, which of this machine's joined hosts").option("--local","Create them on this machine, in-process, as you").option("--origin <url>","The deployment, e.g. https://hightea.dev").option("--workspace <slug>","The workspace slug").option("--session-file <file>","File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--yes","Do not ask; for scripts").option("--json","Print each service's outcome as one JSON document").addHelpText("after",`
27
+ Exit status: 0 every service created; 3 your account may not read the old host's backup; 1 anything else, each named.`).exitOverride().action(async(e,o)=>{let{serviceRestore:t}=await import("./chunk-dkzzzkex.js"),i=(p)=>typeof o[p]==="string"?o[p]:void 0;n=await t({origin:i("origin")??"",workspace:i("workspace")??"",host:i("host"),local:o.local===!0,sessionFile:i("sessionFile"),json:o.json===!0},{from:i("from")??"",names:e,yes:o.yes===!0})});for(let[e,o]of[["enable",!0],["disable",!1]])f.command(e).description(o?"On this machine: let Hightea list, read logs of, change, start and stop this machine's services (adds the services grants).":"On this machine: stop Hightea managing this machine's services (removes the services grants).").option("--host <id>","Which of this machine's joined hosts, when it holds more than one").addHelpText("after",`
28
+ Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOverride().action(async(t)=>{let{hostServicesGrants:i}=await import("./chunk-xy8j3npr.js");n=await i({enable:o,...typeof t.host==="string"?{host:t.host}:{}})});s.command("deploy <service>").description("Place one of this machine's services at a version through its deploy driver; `deploy status <service>` reads one back.").option("--pin <sha>","The full 40-character commit sha to deploy").option("--host <id>","The joined host's id, when this machine runs more than one ahpd").option("--json","Print one JSON document").addHelpText("after",`
29
+ Exit status: 0 started; 1 any refusal or failure, named on stderr.`).exitOverride().action(async(e,o)=>{let{deployPlace:t}=await import("./chunk-p616vcdm.js");n=await t({service:e,pin:typeof o.pin==="string"?o.pin:"",host:typeof o.host==="string"?o.host:void 0,json:o.json===!0})}).command("status <service>").description("Read this service's newest deploy: its state, the pin it is at and the last error it recorded.").addHelpText("after","\nThe parent's --host and --json are accepted here too, before or after `status`.\nExit status: 0 read; 1 no ahpd or no such service on it, named on stderr.").exitOverride().action(async(...e)=>{let o=String(e[0]),{deployStatus:t}=await import("./chunk-p616vcdm.js"),i=e[2].optsWithGlobals();n=await t({service:o,host:typeof i.host==="string"?i.host:void 0,json:i.json===!0})});try{await s.parseAsync([...c],{from:"user"})}catch(e){if(!(e instanceof F))throw e;return e.code==="commander.helpDisplayed"||e.code==="commander.version"||e.code==="commander.help"?0:1}return n}async function L(c){if(process.stdin.isTTY!==!0){console.error(`this computer can run more than one agent app: ${c.map((n)=>`${n.name} (${n.id})`).join(", ")}. Run the same command in a terminal to choose, or add --app <id>. Nothing was redeemed.`);return}let r=A({input:process.stdin,output:process.stdout});try{console.log("This computer can run:");for(let[l,x]of c.entries())console.log(` ${l+1}) ${x.name}`);let n=(await r.question(`Which app should this computer's agent be? [1-${c.length}] `)).trim(),s=Number(n),d=Number.isInteger(s)&&s>=1&&s<=c.length?c[s-1]:void 0;if(d===void 0)console.error(`connect: '${n}' is not one of the numbers above. Nothing was redeemed.`);return d}finally{r.close()}}var P=C(new URL("./plugin/",import.meta.url)),{version:J}=JSON.parse(D(new URL("./plugin/plugin.json",import.meta.url),"utf8"));process.exitCode=await S(process.argv.slice(2),{version:J,pluginDirectory:P});
@@ -0,0 +1,5 @@
1
+ import"./chunk-r9yjtfhp.js";import{t,e}from"./chunk-xj3c5jgm.js";var c=`hightea host list --origin https://your-deployment --workspace SLUG [--session-file FILE] [--json]
2
+ hightea host remove --origin https://your-deployment --workspace SLUG --host HOST [--remove-agents] [--session-file FILE] [--json]`;async function g(r,n=t()){if(r.workspace.trim().length===0||r.host.trim().length===0)return n.err(`HOST_REMOVE_INPUT: --workspace and --host are required.
3
+ ${c}`),1;let o=r.host.trim(),i=r.removeAgents===!0?"?removeAgents=1":"",s=await e(r,n,{method:"DELETE",path:`/hosts/${encodeURIComponent(o)}${i}`,what:"remove",label:"HOST_REMOVE"});if("error"in s)return n.err(s.error),s.exit;if(r.json)return n.out(JSON.stringify(s.answer)),0;let a=s.answer.host??{},u=typeof a.endedDeliveries==="number"?a.endedDeliveries:0,h=String(a.hostId??o);if(a.alreadyRevoked===!0)return n.out(`host ${h} was already removed; nothing was left running`),0;n.out(`removed host ${h}: revoked, ${u} ${u===1?"delivery":"deliveries"} ended`);let d=Array.isArray(s.answer.agentsKeptUnrouted)?s.answer.agentsKeptUnrouted.length:0;return n.out(d===0?"Its agents have no host until they join again with a new join code.":`Its ${d===1?"agent is":`${String(d)} agents are`} still a member, now with no computer; a new join code routes ${d===1?"it":"them"} again. (--remove-agents deletes them with the computer.)`),0}function w(r){let n=(a)=>r[a]===null||r[a]===void 0?"none":String(r[a]),o=Array.isArray(r.agentMemberIds)&&r.agentMemberIds.length>0?r.agentMemberIds.join(","):"none",i=n("status")==="revoked"?`revoked ${n("revokedAt")}`:`last seen ${n("lastSeenAt")}`,s=typeof r.initializeNote==="string"?` ${r.initializeNote}`:"";return`${n("hostId")} ${n("status")} ${r.connected===!0?"connected":"not connected"} plugin ${n("pluginVersion")} agents ${o} owner ${n("ownerAccountId")} ${i}${s}`}async function m(r,n=t()){if(r.workspace.trim().length===0)return n.err(`HOST_LIST_INPUT: --workspace is required.
4
+ ${c}`),1;let o=await e(r,n,{method:"GET",path:"/hosts",what:"list",label:"HOST_LIST"});if("error"in o)return n.err(o.error),o.exit;if(r.json)return n.out(JSON.stringify(o.answer)),0;let i=Array.isArray(o.answer.hosts)?o.answer.hosts:[];if(i.length===0)return n.out(`no hosts in workspace ${r.workspace.trim()} that your account can see (a workspace owner sees every host)`),0;if(n.out(i.map(w).join(`
5
+ `)),i.some((a)=>a.status==="active"))n.out("A host you no longer use: `hightea host remove --workspace "+r.workspace.trim()+" --host <id>`.");let s=o.answer.wakeCarrier;if(typeof s?.active!=="number"||typeof s.unsigned!=="number")n.err("WAKE_CARRIER_UNKNOWN: this workspace answered no wakeCarrier census (active, unsigned), so whether any host still gets a wake bearer is unknown. The workspace build and this CLI disagree; the list above is not evidence that the old wake path is unused.");else if(s.unsigned===0)n.out("every active host advertises signed envelopes: the wake-bearer path can be deleted");else n.out(`${s.unsigned} of ${s.active} active hosts lack signed envelopes and still get a wake bearer; the path can be deleted when this reads 0`);return 0}export{m as hostList,g as hostRemove};
@@ -0,0 +1,13 @@
1
+ import"./chunk-r9yjtfhp.js";import{t,e}from"./chunk-xj3c5jgm.js";var u=`hightea source bind --origin https://your-deployment --workspace SLUG --source SOURCE --host HOST [--refresh 1h] [--session-file FILE] [--json]
2
+ hightea source bind-linear --origin https://your-deployment --workspace SLUG --team TEAM [--refresh 5m] [--session-file FILE] [--json]
3
+ hightea source teams --origin https://your-deployment --workspace SLUG [--session-file FILE] [--json]
4
+ hightea source unbind --origin https://your-deployment --workspace SLUG --source SOURCE [--session-file FILE] [--json]
5
+ hightea source set-refresh --origin https://your-deployment --workspace SLUG --source SOURCE --every 1h [--session-file FILE] [--json]
6
+ hightea source show --origin https://your-deployment --workspace SLUG --source SOURCE [--session-file FILE] [--json]`;function l(n){let r=n.trim().toLowerCase();if(r==="")return"INVALID";if(r==="none"||r==="off")return null;let o=/^(\d+)(s|m|h|d)$/u.exec(r);if(o===null)return"INVALID";let s={s:1000,m:60000,h:3600000,d:86400000}[o[2]],i=Number(o[1])*s;return Number.isSafeInteger(i)&&i>0?i:"INVALID"}var f={SOURCE_BINDING_CONFLICT:4};function a(){return t()}async function h(n,r,o){if(n.workspace.trim().length===0||n.source.trim().length===0)return{exit:1,error:`SOURCE_INPUT: --workspace and --source are required.
7
+ ${u}`};return e(n,r,{...o,label:"SOURCE",extraExits:f,path:`/sources/${encodeURIComponent(n.source)}${o.path}`})}function d(n){let r=(s)=>n[s]===null||n[s]===void 0?"none":String(n[s]),o=n.listing===!0?", first list running":n.listing===!1?", no list running":"";return`${r("status")} on ${r("hostId")} as dataset ${r("dataset")} (freshness ${r("freshness")}${o})`}async function S(n,r=a()){if(n.host.trim().length===0)return r.err(`SOURCE_INPUT: --host is required (the host id that serves the source).
8
+ ${u}`),1;let o=n.refresh===void 0?void 0:l(n.refresh);if(o==="INVALID"||o===null)return r.err(`SOURCE_INPUT: --refresh takes a whole count and one unit — 30m, 1h, 2d — and a bind never clears a schedule.
9
+ ${u}`),1;let s=await h(n,r,{method:"POST",path:"/bind",body:o===void 0?{hostId:n.host.trim()}:{hostId:n.host.trim(),refreshMs:o},what:"bind"});if("error"in s)return r.err(s.error),s.exit;if(n.json)return r.out(JSON.stringify(s.answer)),0;let i=s.answer.source??{};return r.out(`bound ${String(i.sourceId??n.source)} to ${String(i.hostId??n.host)}: ${d(i)}`),r.out("The source's first list fills its dataset; run `hightea source show` to watch its freshness."),0}async function w(n,r=a()){let o=n.team.trim();if(n.workspace.trim().length===0||o.length===0)return r.err(`SOURCE_INPUT: --workspace and --team are required (the Linear team id; \`hightea source teams\` lists them).
10
+ ${u}`),1;let s=n.refresh===void 0?void 0:l(n.refresh);if(s==="INVALID"||s===null)return r.err(`SOURCE_INPUT: --refresh takes a whole count and one unit — 5m, 1h, 2d — and a bind never clears a schedule.
11
+ ${u}`),1;let i=await e(n,r,{method:"POST",label:"SOURCE",extraExits:f,path:`/linear/teams/${encodeURIComponent(o)}/bind`,body:s===void 0?{}:{refreshMs:s},what:"bind-linear"});if("error"in i)return r.err(i.error),i.exit;if(n.json)return r.out(JSON.stringify(i.answer)),0;let c=i.answer.source??{};return r.out(`bound Linear team ${o} as ${String(c.sourceId??`linear:${o}`)}: ${d(c)}`),r.out("The first sweep is queued with the binding; `hightea source show` watches its freshness."),0}async function p(n,r=a()){let o=await e(n,r,{method:"GET",label:"SOURCE",extraExits:f,path:"/linear/teams",what:"teams"});if("error"in o)return r.err(o.error),o.exit;if(n.json)return r.out(JSON.stringify(o.answer)),0;let s=o.answer.teams??[];if(s.length===0)return r.out("Linear sees no teams for this workspace's token; authorize Linear first."),0;for(let i of s)r.out(`${String(i.id)} ${String(i.key)} ${String(i.name)}`);return 0}async function g(n,r=a()){let o=await h(n,r,{method:"POST",path:"/unbind",what:"unbind"});if("error"in o)return r.err(o.error),o.exit;if(n.json)return r.out(JSON.stringify(o.answer)),0;let s=o.answer.source??{};return r.out(`unbound ${String(s.sourceId??n.source)} from ${String(s.hostId??"its host")}: ${d(s)}`),r.out("Rows kept; rebind refreshes them."),0}async function y(n,r=a()){let o=await h(n,r,{method:"GET",path:"",what:"read"});if("error"in o)return r.err(o.error),o.exit;if(n.json)return r.out(JSON.stringify(o.answer)),0;let s=o.answer.source??{},i=s.position;return r.out(`${String(s.sourceId??n.source)}: ${d(s)}`),r.out(`position ${i===null||i===void 0?"none":`${String(i.epoch)}/${String(i.ordinal)}`}, last error ${s.lastError===null||s.lastError===void 0?"none":String(s.lastError)}, dropped ${String(s.dropped??0)}, duplicates ${String(s.duplicates??0)}`),0}async function I(n,r=a()){if(n.every.trim().length===0)return r.err(`SOURCE_INPUT: --every is required (1h, 30m, 2d, or none).
12
+ ${u}`),1;let o=l(n.every);if(o==="INVALID")return r.err(`SOURCE_INPUT: --every takes a whole count and one unit — 45s, 30m, 1h, 2d — or none.
13
+ ${u}`),1;let s=await h(n,r,{method:"POST",path:"/schedule",body:{everyMs:o},what:"set its refresh interval"});if("error"in s)return r.err(s.error),s.exit;if(n.json)return r.out(JSON.stringify(s.answer)),0;let i=s.answer.source??{},c=i.reconcileMs===null||i.reconcileMs===void 0?"no schedule (refreshes only when the host reports a gap)":`refresh every ${Math.round(Number(i.reconcileMs)/60000)} min`;return r.out(`${String(i.sourceId??n.source)}: ${c}; ${d(i)}`),0}export{S as sourceBind,w as sourceBindLinear,I as sourceSetRefresh,y as sourceShow,p as sourceTeams,g as sourceUnbind};
@@ -0,0 +1,2 @@
1
+ import{h,r,m,n,o}from"./chunk-9pv1nvfv.js";import{writeJsonAtomic as N}from"@ahpd/sdk";import{existsSync as b}from"node:fs";import{isAbsolute as k,join as _,resolve as S}from"node:path";async function A(e,i,u){if(e.configDir!==void 0){let s=k(e.configDir)?S(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,"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===i.configDir?{}:{note:`Trusting in the configuration you named at ${s}; this machine's claim names ${i.configDir}.`}}}let d=(await u.runningAhpds()).filter((s)=>s.hostIds.includes(i.hostId));if(d.length>1)return{error:`TRUST_HOST_AMBIGUOUS: ${String(d.length)} running ahpd processes serve ${i.hostId} (${d.map((s)=>`${String(s.pid)} at ${s.configDir}`).join(", ")}); stop the extras or name one with --config-dir`};let a=d[0];if(a!==void 0)return a.configDir===i.configDir?{configDir:a.configDir}:{configDir:a.configDir,note:`Using the running host's configuration at ${a.configDir} (pid ${String(a.pid)}); this machine's claim names ${i.configDir}, which that host does not read.`};if(e.action==="list")return{configDir:i.configDir,note:`No ahpd process serving ${i.hostId} is running on this machine; reading the claim's copy at ${i.configDir}, which a hab-managed host would not read.`};return{error:`TRUST_NO_RUNNING_HOST: no ahpd process serving ${i.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 ${i.configDir})`}}var w="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 p(e,i=()=>new Date,u={runningAhpds:()=>o()}){let d=await n(e.host);if("error"in d)return console.error(d.error.replace(/^SERVICE_/u,"TRUST_")),1;let a=await A(e,d,u);if("error"in a)return console.error(a.error),1;let s;try{s=m(a.configDir)}catch(t){return console.error(`${t.message}; it was left unchanged`),1}let c=s.state==="read"?s.keys:[],g=`host ${d.hostId} (${s.file})`;if(a.note!==void 0)console.error(a.note);if(e.action==="list"){if(e.json===!0)return console.log(JSON.stringify({hostId:d.hostId,file:s.file,keys:c})),0;if(e.browsers===!0){if(c.length===0)return console.log(`No browsers are approved on ${g}. 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 ${g}:`);for(let t of c)console.log(` ${t.name.padEnd(22)} approved ${R(t.addedAt)}${t.personName===void 0?"":` ${t.personName}`}`);return 0}if(c.length===0)return console.log(`No trusted keys for ${g}: 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 ${g}:`);for(let t of c)console.log(` ${t.name} key ${t.keyId} added ${t.addedAt}`);return console.log(w),0}if(!h.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 l=c.find((t)=>t.name===e.name);if(e.action==="remove"){if(l===void 0)return console.error(`TRUST_NAME_UNKNOWN: ${g} trusts no key named ${e.name} (trusted: ${c.map((t)=>t.name).join(", ")||"none"}); nothing was changed`),1;if(!D(s.file,c.filter((t)=>t!==l)))return 1;if(e.browsers===!0)return console.log(`Removed. The next message from ${l.name} will ask again.`),0;return console.log(`Removed ${e.name} (key ${l.keyId}) from ${g}. Asks signed with it are refused from now on.`),0}let f=r(e.publicKey);if("error"in f)return console.error(`${f.error}; nothing was changed`),1;let y=(t)=>{if(e.quiet!==!0)console.log(t)};if(l!==void 0){if(l.publicKey===e.publicKey)return y(`${e.name} (key ${f.keyId}) is already trusted by ${g}; it was left unchanged.`),0;return console.error(`TRUST_NAME_TAKEN: ${g} already trusts another key as ${e.name}; remove it first or pick another name. Nothing was changed`),1}let T=c.find((t)=>t.keyId===f.keyId);if(T!==void 0)return console.error(`TRUST_KEY_TAKEN: ${g} already trusts this key as ${T.name}; nothing was changed`),1;let I={name:e.name,keyId:f.keyId,publicKey:e.publicKey,addedAt:i().toISOString(),...e.personName===void 0||e.personName===""?{}:{personName:e.personName}};if(!D(s.file,[...c,I]))return 1;return y(`Trusted ${e.name} (key ${f.keyId}) on ${g}. ${w}`),0}function R(e){let i=new Date(e);if(Number.isNaN(i.getTime()))return e;return new Intl.DateTimeFormat("sv-SE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(i)}function D(e,i){try{N(e,{v:1,keys:i},{mode:384})}catch(u){return console.error(`TRUST_FILE_UNWRITABLE: ${e}: ${u.message}`),!1}return!0}
2
+ export{p};