@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.
@@ -1,89 +0,0 @@
1
- import"./chunk-0ab6h39c.js";
2
- import {
3
- ownerIo,
4
- sendOwner
5
- } from "./chunk-sbqmqp8e.js";
6
-
7
- // src/host.ts
8
- var USAGE = `hightea host list --origin https://your-deployment --workspace SLUG [--session-file FILE] [--json]
9
- ` + "hightea host remove --origin https://your-deployment --workspace SLUG --host HOST [--remove-agents] [--session-file FILE] [--json]";
10
- async function hostRemove(target, io = ownerIo()) {
11
- if (target.workspace.trim().length === 0 || target.host.trim().length === 0) {
12
- io.err(`HOST_REMOVE_INPUT: --workspace and --host are required.
13
- ${USAGE}`);
14
- return 1;
15
- }
16
- const hostId = target.host.trim();
17
- const query = target.removeAgents === true ? "?removeAgents=1" : "";
18
- const sent = await sendOwner(target, io, {
19
- method: "DELETE",
20
- path: `/hosts/${encodeURIComponent(hostId)}${query}`,
21
- what: "remove",
22
- label: "HOST_REMOVE"
23
- });
24
- if ("error" in sent) {
25
- io.err(sent.error);
26
- return sent.exit;
27
- }
28
- if (target.json) {
29
- io.out(JSON.stringify(sent.answer));
30
- return 0;
31
- }
32
- const host = sent.answer.host ?? {};
33
- const ended = typeof host.endedDeliveries === "number" ? host.endedDeliveries : 0;
34
- const name = String(host.hostId ?? hostId);
35
- if (host.alreadyRevoked === true) {
36
- io.out(`host ${name} was already removed; nothing was left running`);
37
- return 0;
38
- }
39
- io.out(`removed host ${name}: revoked, ${ended} ${ended === 1 ? "delivery" : "deliveries"} ended`);
40
- const kept = Array.isArray(sent.answer.agentsKeptUnrouted) ? sent.answer.agentsKeptUnrouted.length : 0;
41
- io.out(kept === 0 ? "Its agents have no host until they join again with a new join code." : `Its ${kept === 1 ? "agent is" : `${String(kept)} agents are`} still a member, now with no computer; a new join code routes ${kept === 1 ? "it" : "them"} again. (--remove-agents deletes them with the computer.)`);
42
- return 0;
43
- }
44
- function hostLine(host) {
45
- const field = (name) => host[name] === null || host[name] === undefined ? "none" : String(host[name]);
46
- const agents = Array.isArray(host.agentMemberIds) && host.agentMemberIds.length > 0 ? host.agentMemberIds.join(",") : "none";
47
- const state = field("status") === "revoked" ? `revoked ${field("revokedAt")}` : `last seen ${field("lastSeenAt")}`;
48
- const note = typeof host.initializeNote === "string" ? ` ${host.initializeNote}` : "";
49
- return `${field("hostId")} ${field("status")} ${host.connected === true ? "connected" : "not connected"} ` + `plugin ${field("pluginVersion")} agents ${agents} owner ${field("ownerAccountId")} ${state}${note}`;
50
- }
51
- async function hostList(target, io = ownerIo()) {
52
- if (target.workspace.trim().length === 0) {
53
- io.err(`HOST_LIST_INPUT: --workspace is required.
54
- ${USAGE}`);
55
- return 1;
56
- }
57
- const sent = await sendOwner(target, io, { method: "GET", path: "/hosts", what: "list", label: "HOST_LIST" });
58
- if ("error" in sent) {
59
- io.err(sent.error);
60
- return sent.exit;
61
- }
62
- if (target.json) {
63
- io.out(JSON.stringify(sent.answer));
64
- return 0;
65
- }
66
- const hosts = Array.isArray(sent.answer.hosts) ? sent.answer.hosts : [];
67
- if (hosts.length === 0) {
68
- io.out(`no hosts in workspace ${target.workspace.trim()} that your account can see (a workspace owner sees every host)`);
69
- return 0;
70
- }
71
- io.out(hosts.map(hostLine).join(`
72
- `));
73
- if (hosts.some((host) => host.status === "active")) {
74
- io.out("A host you no longer use: `hightea host remove --workspace " + target.workspace.trim() + " --host <id>`.");
75
- }
76
- const carrier = sent.answer.wakeCarrier;
77
- if (typeof carrier?.active !== "number" || typeof carrier.unsigned !== "number") {
78
- io.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.");
79
- } else if (carrier.unsigned === 0) {
80
- io.out(`every active host advertises signed envelopes: the wake-bearer path can be deleted`);
81
- } else {
82
- io.out(`${carrier.unsigned} of ${carrier.active} active hosts lack signed envelopes and still get a wake bearer; ` + `the path can be deleted when this reads 0`);
83
- }
84
- return 0;
85
- }
86
- export {
87
- hostList,
88
- hostRemove
89
- };