@hallohuman/hightea 0.1.17 → 0.1.30
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 +171 -64
- package/dist/chunk-0r70ekxd.js +8 -0
- package/dist/chunk-13tpn1g6.js +465 -0
- package/dist/chunk-3rgfnt23.js +16 -0
- package/dist/{chunk-rs0vvh3x.js → chunk-9e325ntw.js} +15 -4
- package/dist/{chunk-3ah56pdt.js → chunk-cx3yvvkz.js} +174 -207
- package/dist/{chunk-h5s3wwdz.js → chunk-dvnzt54t.js} +1126 -2001
- package/dist/chunk-dvt4hb8z.js +1491 -0
- package/dist/chunk-gk8tyqac.js +184 -0
- package/dist/chunk-h8pdqn31.js +157 -0
- package/dist/{chunk-1xykqbdm.js → chunk-ph04jess.js} +5 -2
- package/dist/chunk-w0ebwtch.js +161 -0
- package/dist/{chunk-6ae0ftqh.js → chunk-y5r2yxx1.js} +1 -1
- package/dist/plugin/plugin.json +8 -1
- package/dist/plugin/plugin.mjs +2179 -627
- package/package.json +8 -5
- package/dist/chunk-hxs6jv2m.js +0 -91
package/dist/bin.js
CHANGED
|
@@ -1,69 +1,116 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
// package.json
|
|
6
|
-
var package_default = {
|
|
7
|
-
name: "@hallohuman/hightea",
|
|
8
|
-
version: "0.1.17",
|
|
9
|
-
description: "The Hightea command line: join this machine to a Hightea workspace as a host.",
|
|
10
|
-
publishConfig: {
|
|
11
|
-
access: "public"
|
|
12
|
-
},
|
|
13
|
-
type: "module",
|
|
14
|
-
bin: {
|
|
15
|
-
hightea: "./dist/bin.js"
|
|
16
|
-
},
|
|
17
|
-
files: [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
engines: {
|
|
21
|
-
node: ">=26.13.1"
|
|
22
|
-
},
|
|
23
|
-
scripts: {
|
|
24
|
-
build: "bun build.ts",
|
|
25
|
-
prepack: "bun run build"
|
|
26
|
-
},
|
|
27
|
-
dependencies: {
|
|
28
|
-
"@ahpd/deploy": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/ahpd-deploy-0.15.0-beorn.3a159188.tgz",
|
|
29
|
-
"@ahpd/sdk": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/ahpd-sdk-0.15.0-beorn.3a159188.tgz",
|
|
30
|
-
"@ahpd/server": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/ahpd-server-0.15.0-beorn.3a159188.tgz",
|
|
31
|
-
"@hallohuman/hightea-services": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/hallohuman-hightea-services-0.16.0-beorn.3a159188.tgz",
|
|
32
|
-
"@silvery/commander": "0.29.3",
|
|
33
|
-
ws: "8.21.0"
|
|
34
|
-
},
|
|
35
|
-
devDependencies: {
|
|
36
|
-
"@hallohuman/hightea-ahp-host": "workspace:*",
|
|
37
|
-
"@hallohuman/hightea-client": "workspace:*"
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
6
|
|
|
41
7
|
// src/cli.ts
|
|
42
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
|
+
}
|
|
43
29
|
async function runCli(argv, options) {
|
|
44
30
|
let code = 0;
|
|
45
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();
|
|
46
|
-
program.command("apply <file>").description("Apply a native process-compose file, or a TypeScript program that returns a plan
|
|
47
|
-
Exit status: 0 previewed or applied; 1 the machine refused the plan or could not be reached.`).exitOverride().action(async (file, flags) => {
|
|
48
|
-
const { applyFile } = await import("./chunk-
|
|
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");
|
|
49
35
|
code = await applyFile(file, {
|
|
50
36
|
machine: flags.machine ?? "",
|
|
51
37
|
token: flags.token ?? process.env.AHP_TKN,
|
|
52
38
|
yes: flags.yes === true,
|
|
53
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,
|
|
54
45
|
json: flags.json === true
|
|
55
46
|
});
|
|
56
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
|
+
});
|
|
57
98
|
const host = program.command("host").description("Hosts: this machine joining a workspace, and the workspace's registered hosts.").exitOverride();
|
|
58
|
-
host.command("join").description("Join this machine to a workspace with a one-use host join code from the workspace owner.").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").addHelpText("after", `
|
|
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", `
|
|
59
100
|
Exit status: 0 registered; 2 pending, rerun the same command; 3 not authorised for that workspace or agent;
|
|
60
101
|
4 an agent is already bound to another host; 1 any other failure.`).exitOverride().action(async (flags) => {
|
|
61
|
-
const { hostJoin } = await import("./chunk-
|
|
62
|
-
code = await hostJoin({
|
|
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 });
|
|
63
110
|
});
|
|
64
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", `
|
|
65
112
|
Exit status: 0 listed; 3 your account is not a person of this workspace; 1 any other failure.`).exitOverride().action(async (flags) => {
|
|
66
|
-
const { hostList } = await import("./chunk-
|
|
113
|
+
const { hostList } = await import("./chunk-9e325ntw.js");
|
|
67
114
|
code = await hostList({
|
|
68
115
|
origin: flags.origin ?? "",
|
|
69
116
|
workspace: flags.workspace ?? "",
|
|
@@ -71,45 +118,66 @@ Exit status: 0 listed; 3 your account is not a person of this workspace; 1 any o
|
|
|
71
118
|
json: flags.json === true
|
|
72
119
|
});
|
|
73
120
|
});
|
|
74
|
-
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("--session-file <file>", "File holding your signed-in ht_session cookie (default: HIGHTEA_SESSION_FILE)").option("--json", "Print one JSON document").addHelpText("after", `
|
|
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", `
|
|
75
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) => {
|
|
76
|
-
const { hostRemove } = await import("./chunk-
|
|
123
|
+
const { hostRemove } = await import("./chunk-9e325ntw.js");
|
|
77
124
|
code = await hostRemove({
|
|
78
125
|
origin: flags.origin ?? "",
|
|
79
126
|
workspace: flags.workspace ?? "",
|
|
80
127
|
host: flags.host ?? "",
|
|
128
|
+
removeAgents: flags.removeAgents === true,
|
|
81
129
|
sessionFile: flags.sessionFile,
|
|
82
130
|
json: flags.json === true
|
|
83
131
|
});
|
|
84
132
|
});
|
|
85
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) => {
|
|
86
|
-
const { hostStatus } = await import("./chunk-
|
|
134
|
+
const { hostStatus } = await import("./chunk-ph04jess.js");
|
|
87
135
|
code = await hostStatus({ version: options.version, json: flags.json === true });
|
|
88
136
|
});
|
|
89
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", `
|
|
90
138
|
The old bundle is kept until the host has connected once on the new one; a later update removes it.
|
|
91
139
|
` + `A bundle newer than this CLI's is refused (HOST_UPDATE_DOWNGRADE).
|
|
92
140
|
Exit status: 0 updated or already current; 1 any refusal, named on stderr.`).exitOverride().action(async (flags) => {
|
|
93
|
-
const { hostUpdate } = await import("./chunk-
|
|
141
|
+
const { hostUpdate } = await import("./chunk-ph04jess.js");
|
|
94
142
|
code = await hostUpdate({ host: flags.host }, { directory: options.pluginDirectory, version: options.version });
|
|
95
143
|
});
|
|
96
|
-
const trust = host.command("trust").description("The
|
|
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", `
|
|
97
145
|
What it protects against: an ask forged by a compromised Hightea server or database.
|
|
98
146
|
` + `What it does not: a compromised page script, since the script that signs comes from Hightea, or a process
|
|
99
147
|
` + "running as this machine's user, which can edit trusted-keys.json as it can config.json.").exitOverride();
|
|
100
|
-
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").addHelpText("after", `
|
|
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", `
|
|
101
149
|
Exit status: 0 trusted or already trusted; 1 any failure, with the file left unchanged.`).exitOverride().action(async (name, publicKey, flags) => {
|
|
102
|
-
const { hostTrust } = await import("./chunk-
|
|
103
|
-
code = await hostTrust({ action: "add", name, publicKey, ...flags.host === undefined ? {} : { host: flags.host } });
|
|
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 } });
|
|
104
152
|
});
|
|
105
|
-
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").addHelpText("after", `
|
|
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", `
|
|
106
154
|
Exit status: 0 removed; 1 any failure, including an unknown name, with the file left unchanged.`).exitOverride().action(async (name, flags) => {
|
|
107
|
-
const { hostTrust } = await import("./chunk-
|
|
108
|
-
code = await hostTrust({ action: "remove", name, ...flags.host === undefined ? {} : { host: flags.host } });
|
|
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 } });
|
|
109
161
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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 } });
|
|
113
181
|
});
|
|
114
182
|
const auth = program.command("auth").description("Sign this machine in to a Hightea deployment for the owner commands.").exitOverride();
|
|
115
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", `
|
|
@@ -189,7 +257,7 @@ Exit status: 0 set; 3 your account is not this workspace's owner; 1 any other fa
|
|
|
189
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) => {
|
|
190
258
|
const name = options.named ? String(args[0]) : undefined;
|
|
191
259
|
const flags = options.named ? args[1] : args[0];
|
|
192
|
-
const { serviceCommand } = await import("./chunk-
|
|
260
|
+
const { serviceCommand } = await import("./chunk-y5r2yxx1.js");
|
|
193
261
|
const text = (key) => typeof flags[key] === "string" ? flags[key] : undefined;
|
|
194
262
|
code = await serviceCommand({
|
|
195
263
|
origin: text("origin") ?? "",
|
|
@@ -212,7 +280,7 @@ Exit status: 0 done; 3 your account may not manage this host's services; 1 any o
|
|
|
212
280
|
serviceAction("acknowledge", "Accept the process-compose files as they are now, so drift stops alerting on a hand edit.");
|
|
213
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", `
|
|
214
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) => {
|
|
215
|
-
const { serviceBackupCommand } = await import("./chunk-
|
|
283
|
+
const { serviceBackupCommand } = await import("./chunk-y5r2yxx1.js");
|
|
216
284
|
const text = (key) => typeof flags[key] === "string" ? flags[key] : undefined;
|
|
217
285
|
code = await serviceBackupCommand({
|
|
218
286
|
origin: text("origin") ?? "",
|
|
@@ -225,7 +293,7 @@ Exit status: 0 shown; 3 your account may not read this host's backup; 1 any othe
|
|
|
225
293
|
});
|
|
226
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", `
|
|
227
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) => {
|
|
228
|
-
const { serviceRestore } = await import("./chunk-
|
|
296
|
+
const { serviceRestore } = await import("./chunk-y5r2yxx1.js");
|
|
229
297
|
const text = (key) => typeof flags[key] === "string" ? flags[key] : undefined;
|
|
230
298
|
code = await serviceRestore({
|
|
231
299
|
origin: text("origin") ?? "",
|
|
@@ -239,10 +307,30 @@ Exit status: 0 every service created; 3 your account may not read the old host's
|
|
|
239
307
|
for (const [verb, enable] of [["enable", true], ["disable", false]]) {
|
|
240
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", `
|
|
241
309
|
Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOverride().action(async (flags) => {
|
|
242
|
-
const { hostServicesGrants } = await import("./chunk-
|
|
310
|
+
const { hostServicesGrants } = await import("./chunk-ph04jess.js");
|
|
243
311
|
code = await hostServicesGrants({ enable, ...typeof flags.host === "string" ? { host: flags.host } : {} });
|
|
244
312
|
});
|
|
245
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
|
+
});
|
|
246
334
|
try {
|
|
247
335
|
await program.parseAsync([...argv], { from: "user" });
|
|
248
336
|
} catch (error) {
|
|
@@ -252,9 +340,28 @@ Exit status: 0 changed or already so; 1 any failure, named on stderr.`).exitOver
|
|
|
252
340
|
}
|
|
253
341
|
return code;
|
|
254
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
|
+
}
|
|
255
363
|
|
|
256
364
|
// src/bin.ts
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
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 });
|