@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.3
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/README.md +38 -265
- package/dist/address-space/address-space.d.ts +38 -0
- package/dist/address-space/address-space.js +130 -0
- package/dist/address-space/index.d.ts +2 -0
- package/dist/address-space/index.js +2 -0
- package/dist/agents/client.d.ts +171 -0
- package/dist/agents/client.js +8 -0
- package/dist/agents/commands.d.ts +7 -0
- package/dist/agents/commands.js +65 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/input.d.ts +130 -0
- package/dist/agents/input.js +99 -0
- package/dist/agents/output/format.d.ts +8 -0
- package/dist/agents/output/format.js +47 -0
- package/dist/agents/output/index.d.ts +2 -0
- package/dist/agents/output/index.js +2 -0
- package/dist/agents/tree/index.d.ts +2 -0
- package/dist/agents/tree/index.js +2 -0
- package/dist/agents/tree/tree.d.ts +3 -0
- package/dist/agents/tree/tree.js +43 -0
- package/dist/bin/maia.cdx.json +37 -14
- package/dist/bin/maia.mjs +1 -1
- package/dist/bootstrap/exit.d.ts +14 -0
- package/dist/bootstrap/exit.js +42 -0
- package/dist/bootstrap/process.js +4 -26
- package/dist/cli/cli.js +70 -13
- package/dist/command-line/context.d.ts +13 -4
- package/dist/command-line/context.js +1 -1
- package/dist/command-line/index.d.ts +5 -5
- package/dist/command-line/index.js +5 -4
- package/dist/command-line/input/index.d.ts +1 -1
- package/dist/command-line/input/index.js +1 -1
- package/dist/command-line/input/stdin.d.ts +1 -0
- package/dist/command-line/input/stdin.js +1 -0
- package/dist/command-line/json.d.ts +1 -0
- package/dist/command-line/json.js +23 -0
- package/dist/command-line/output.d.ts +8 -1
- package/dist/command-line/output.js +33 -14
- package/dist/command-line/rows.d.ts +2 -0
- package/dist/command-line/rows.js +10 -1
- package/dist/command-line/two-phase.d.ts +5 -0
- package/dist/command-line/two-phase.js +33 -8
- package/dist/command-tree/help.d.ts +1 -1
- package/dist/command-tree/help.js +1 -0
- package/dist/command-tree/index.d.ts +2 -2
- package/dist/command-tree/index.js +1 -1
- package/dist/command-tree/local.js +12 -0
- package/dist/command-tree/placeholder.d.ts +1 -0
- package/dist/command-tree/placeholder.js +1 -0
- package/dist/command-tree/row.d.ts +2 -0
- package/dist/command-tree/tree.d.ts +3 -2
- package/dist/command-tree/tree.js +18 -2
- package/dist/connection/client.d.ts +93 -1
- package/dist/connection/client.js +7 -1
- package/dist/connection/index.d.ts +1 -1
- package/dist/connection/index.js +1 -1
- package/dist/connection/system.d.ts +1 -0
- package/dist/connection/system.js +109 -5
- package/dist/connection/tree/tree.js +17 -4
- package/dist/container/output/format.js +1 -2
- package/dist/dashboard/cockpit-client.d.ts +6 -0
- package/dist/dashboard/cockpit-client.js +27 -0
- package/dist/dashboard/cockpits.d.ts +29 -0
- package/dist/dashboard/cockpits.js +65 -0
- package/dist/dashboard/dashboard.d.ts +7 -0
- package/dist/dashboard/dashboard.js +47 -0
- package/dist/dashboard/draw.d.ts +15 -0
- package/dist/dashboard/draw.js +30 -0
- package/dist/dashboard/frame.d.ts +4 -0
- package/dist/dashboard/frame.js +15 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/modes.d.ts +5 -0
- package/dist/dashboard/modes.js +16 -0
- package/dist/dashboard/node-connection.d.ts +15 -0
- package/dist/dashboard/node-connection.js +51 -0
- package/dist/dashboard/pi-tui.d.ts +6 -0
- package/dist/dashboard/pi-tui.js +35 -0
- package/dist/dashboard/status-bar.d.ts +4 -0
- package/dist/dashboard/status-bar.js +60 -0
- package/dist/dashboard/terminal.d.ts +53 -0
- package/dist/dashboard/terminal.js +165 -0
- package/dist/dashboard/tree-model.d.ts +28 -0
- package/dist/dashboard/tree-model.js +97 -0
- package/dist/dashboard/tree.d.ts +10 -0
- package/dist/dashboard/tree.js +76 -0
- package/dist/fleet/fleet.d.ts +70 -0
- package/dist/fleet/fleet.js +91 -0
- package/dist/fleet/index.d.ts +2 -0
- package/dist/fleet/index.js +2 -0
- package/dist/hold/output/format.js +1 -5
- package/dist/hold/tree/tree.js +1 -0
- package/dist/import/commands.js +3 -4
- package/dist/import/output.js +1 -4
- package/dist/local-node/client.d.ts +8 -4
- package/dist/local-node/client.js +20 -9
- package/dist/local-node/index.d.ts +1 -1
- package/dist/local-node/index.js +1 -1
- package/dist/login/commands.js +2 -1
- package/dist/mcp/calls.d.ts +1 -0
- package/dist/mcp/calls.js +36 -3
- package/dist/mcp/commands.d.ts +5 -2
- package/dist/mcp/commands.js +30 -4
- package/dist/mcp/routing.d.ts +24 -0
- package/dist/mcp/routing.js +188 -0
- package/dist/mcp/server.d.ts +13 -4
- package/dist/mcp/server.js +35 -12
- package/dist/presentation/output/format.js +4 -3
- package/dist/project-guard/commands.js +11 -2
- package/dist/project-workspace/commands.js +16 -6
- package/dist/project-workspace/output/human.d.ts +13 -0
- package/dist/project-workspace/output/human.js +17 -5
- package/dist/project-workspace/output/index.d.ts +1 -1
- package/dist/project-workspace/output/index.js +1 -1
- package/dist/project-workspace/output/metadata.js +1 -1
- package/dist/project-workspace/tree/tree.js +27 -12
- package/dist/reference/commands.js +4 -2
- package/dist/reference/index.d.ts +1 -1
- package/dist/reference/index.js +1 -1
- package/dist/reference/resolve.d.ts +2 -0
- package/dist/reference/resolve.js +20 -17
- package/dist/remote-node/client.d.ts +89 -9
- package/dist/remote-node/client.js +6 -1
- package/dist/remote-node/commands.d.ts +9 -0
- package/dist/remote-node/commands.js +96 -18
- package/dist/remote-node/connector.d.ts +12 -4
- package/dist/remote-node/connector.js +46 -25
- package/dist/remote-node/index.d.ts +2 -2
- package/dist/remote-node/index.js +2 -2
- package/dist/remote-node/reachability.d.ts +43 -1
- package/dist/remote-node/reachability.js +13 -3
- package/dist/remote-node/text.d.ts +2 -1
- package/dist/remote-node/text.js +74 -27
- package/dist/remote-node/tree/tree.js +21 -1
- package/dist/routine/client.d.ts +398 -0
- package/dist/routine/client.js +28 -0
- package/dist/routine/commands.d.ts +9 -0
- package/dist/routine/commands.js +109 -0
- package/dist/routine/index.d.ts +3 -0
- package/dist/routine/index.js +3 -0
- package/dist/routine/input.d.ts +28 -0
- package/dist/routine/input.js +44 -0
- package/dist/routine/output/format.d.ts +23 -0
- package/dist/routine/output/format.js +83 -0
- package/dist/routine/output/index.d.ts +2 -0
- package/dist/routine/output/index.js +2 -0
- package/dist/routine/tree/index.d.ts +2 -0
- package/dist/routine/tree/index.js +2 -0
- package/dist/routine/tree/tree.d.ts +3 -0
- package/dist/routine/tree/tree.js +70 -0
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/commands.js +24 -6
- package/dist/session/approval/output/format.d.ts +11 -0
- package/dist/session/approval/output/format.js +8 -0
- package/dist/session/approval/output/index.d.ts +1 -1
- package/dist/session/approval/output/index.js +1 -1
- package/dist/session/attach-client.d.ts +1 -1
- package/dist/session/attach-client.js +12 -3
- package/dist/session/attach-render.js +15 -7
- package/dist/session/attach.js +17 -3
- package/dist/session/client.d.ts +4 -2
- package/dist/session/client.js +4 -15
- package/dist/session/commands.js +76 -9
- package/dist/session/create-tasks.js +29 -11
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -0
- package/dist/session/interaction/output/format.js +2 -1
- package/dist/session/output/diff.js +3 -10
- package/dist/session/output/failure.js +3 -10
- package/dist/session/output/human.js +21 -10
- package/dist/session/output/index.d.ts +1 -1
- package/dist/session/output/index.js +1 -1
- package/dist/session/output/tasks.d.ts +16 -1
- package/dist/session/output/tasks.js +41 -27
- package/dist/session/tree/tree.js +56 -8
- package/dist/session/turn/client.d.ts +4 -1
- package/dist/session/turn/client.js +15 -2
- package/dist/session/turn/commands.d.ts +2 -0
- package/dist/session/turn/commands.js +38 -5
- package/dist/session/turn/index.d.ts +3 -3
- package/dist/session/turn/index.js +1 -1
- package/dist/session/turn/output.d.ts +7 -2
- package/dist/session/turn/output.js +36 -13
- package/dist/status/client.d.ts +7 -2
- package/dist/status/output/compact.d.ts +1 -0
- package/dist/status/output/compact.js +3 -0
- package/dist/status/output/human.d.ts +1 -1
- package/dist/status/output/human.js +71 -14
- package/dist/team-workspace/ceremony.d.ts +19 -0
- package/dist/team-workspace/ceremony.js +141 -0
- package/dist/team-workspace/client.d.ts +58 -0
- package/dist/team-workspace/client.js +6 -0
- package/dist/team-workspace/commands.d.ts +3 -0
- package/dist/team-workspace/commands.js +85 -0
- package/dist/team-workspace/confirmation.d.ts +4 -0
- package/dist/team-workspace/confirmation.js +8 -0
- package/dist/team-workspace/dependencies.d.ts +8 -0
- package/dist/team-workspace/dependencies.js +2 -0
- package/dist/team-workspace/index.d.ts +6 -0
- package/dist/team-workspace/index.js +5 -0
- package/dist/team-workspace/launcher.d.ts +17 -0
- package/dist/team-workspace/launcher.js +30 -0
- package/dist/team-workspace/output.d.ts +15 -0
- package/dist/team-workspace/output.js +28 -0
- package/dist/team-workspace/terminal.d.ts +9 -0
- package/dist/team-workspace/terminal.js +46 -0
- package/dist/terminal/client.d.ts +4 -0
- package/dist/terminal/client.js +3 -0
- package/dist/terminal/commands.js +37 -25
- package/dist/terminal/output/compact-list.d.ts +1 -0
- package/dist/terminal/output/compact-list.js +1 -0
- package/dist/terminal/output/human.d.ts +2 -19
- package/dist/terminal/output/human.js +6 -6
- package/dist/terminal/tree/tree.js +15 -15
- package/package.json +8 -6
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import { remoteNodeInstallConfirmParametersSchema, remoteNodeRemoveConfirmParametersSchema, } from "@maiaos/sdk";
|
|
3
|
+
import { remoteNodeInstallConfirmParametersSchema, remoteNodeRegisterConfirmParametersSchema, remoteNodeRemoveConfirmParametersSchema, } from "@maiaos/sdk";
|
|
4
4
|
import * as Data from "effect/Data";
|
|
5
5
|
import * as Duration from "effect/Duration";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Schedule from "effect/Schedule";
|
|
8
|
-
import { askToConfirm, CliArgumentError, confirmParameters, missingArgument, parseOptions, promptOrRefuse, readPipedPreview, reportError, requestedTwoPhaseMode, requirePositionals, TWO_PHASE_FLAGS, } from "../command-line/index.js";
|
|
8
|
+
import { askToConfirm, CliArgumentError, confirmParameters, jsonLine, LOCAL_NODE, missingArgument, parseOptions, promptOrRefuse, readPipedPreview, reportError, requestedTwoPhaseMode, requirePositionals, TWO_PHASE_FLAGS, } from "../command-line/index.js";
|
|
9
9
|
import { commandIdentifier, } from "../local-node/index.js";
|
|
10
|
-
import {
|
|
11
|
-
import { installedText, listText, planText, removedText } from "./text.js";
|
|
10
|
+
import { withReachability } from "./reachability.js";
|
|
11
|
+
import { installedText, listText, planText, registerPlanText, removedText, } from "./text.js";
|
|
12
12
|
const WAIT_MS = 3500;
|
|
13
13
|
const PROBE_DEADLINE = Duration.minutes(3);
|
|
14
14
|
const JOB_DEADLINE = Duration.minutes(20);
|
|
@@ -64,20 +64,41 @@ const optionalBinaries = (options) => {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
const CONFIRM_FLAGS = new Set(["--yes", ...TWO_PHASE_FLAGS]);
|
|
67
|
+
const readName = (name) => {
|
|
68
|
+
if (name === LOCAL_NODE)
|
|
69
|
+
throw new CliArgumentError("The name 'local' is this machine's Node: name the Node with --name <name>.");
|
|
70
|
+
return name;
|
|
71
|
+
};
|
|
72
|
+
const PINNED_NODE_VERSION = "24.22.1";
|
|
73
|
+
const thisNode = {
|
|
74
|
+
arch: process.arch,
|
|
75
|
+
execPath: process.execPath,
|
|
76
|
+
platform: process.platform,
|
|
77
|
+
version: process.versions.node,
|
|
78
|
+
};
|
|
79
|
+
export const nodeRuntimeOf = (flag, interpreter) => {
|
|
80
|
+
if (flag !== undefined)
|
|
81
|
+
return flag;
|
|
82
|
+
if (interpreter.platform === "linux" &&
|
|
83
|
+
interpreter.arch === "x64" &&
|
|
84
|
+
interpreter.version === PINNED_NODE_VERSION)
|
|
85
|
+
return interpreter.execPath;
|
|
86
|
+
throw new CliArgumentError(`--node-runtime is required: this Node.js is ${interpreter.platform}-${interpreter.arch} ${interpreter.version}, and a remote host needs a linux-x64 ${PINNED_NODE_VERSION} build.`);
|
|
87
|
+
};
|
|
67
88
|
const readAdd = ({ options, positionals }) => {
|
|
68
89
|
requirePositionals(positionals, 1);
|
|
69
90
|
const host = positionals[0] ?? "";
|
|
70
91
|
const release = options.get("--release");
|
|
71
|
-
|
|
72
|
-
if (release === undefined || runtime === undefined)
|
|
92
|
+
if (release === undefined)
|
|
73
93
|
throw missingArgument();
|
|
94
|
+
const runtime = nodeRuntimeOf(options.get("--node-runtime"), thisNode);
|
|
74
95
|
return {
|
|
75
96
|
commandId: options.get("--command-id"),
|
|
76
97
|
parameters: {
|
|
77
98
|
...optionalBinaries(options),
|
|
78
99
|
host,
|
|
79
100
|
keep: readKeep(options.get("--keep")),
|
|
80
|
-
name: options.get("--name") ?? nameFromHost(host),
|
|
101
|
+
name: readName(options.get("--name") ?? nameFromHost(host)),
|
|
81
102
|
nodeRuntime: resolve(process.cwd(), runtime),
|
|
82
103
|
profile: options.get("--remote-profile") ?? "default",
|
|
83
104
|
release: resolve(process.cwd(), release),
|
|
@@ -86,7 +107,7 @@ const readAdd = ({ options, positionals }) => {
|
|
|
86
107
|
};
|
|
87
108
|
};
|
|
88
109
|
const confirmed = (context, question, mode) => mode === "prompt" ? askToConfirm(context, question) : Effect.succeed(true);
|
|
89
|
-
const pipedPlan = (piped) => {
|
|
110
|
+
const pipedPlan = (piped, longPolled = true) => {
|
|
90
111
|
const parameters = Reflect.get(piped, "parameters");
|
|
91
112
|
const preview = Reflect.get(piped, "preview");
|
|
92
113
|
if (typeof parameters !== "object" ||
|
|
@@ -100,7 +121,7 @@ const pipedPlan = (piped) => {
|
|
|
100
121
|
inputDigest: Reflect.get(preview, "inputDigest"),
|
|
101
122
|
...(planDigest === undefined ? {} : { planDigest }),
|
|
102
123
|
proof: Reflect.get(preview, "proof"),
|
|
103
|
-
waitMs: WAIT_MS,
|
|
124
|
+
...(longPolled ? { waitMs: WAIT_MS } : {}),
|
|
104
125
|
};
|
|
105
126
|
};
|
|
106
127
|
const notSettled = () => new NodeCommandError({
|
|
@@ -118,7 +139,7 @@ const repeatUntil = (effect, settled, deadline) => effect.pipe(Effect.repeat({
|
|
|
118
139
|
orElse: () => Effect.fail(notSettled()),
|
|
119
140
|
}));
|
|
120
141
|
const write = (context, output, text) => {
|
|
121
|
-
context.io.stdout(context.json ?
|
|
142
|
+
context.io.stdout(context.json ? jsonLine({ ok: true, result: output }) : text);
|
|
122
143
|
};
|
|
123
144
|
const exitFor = (node) => {
|
|
124
145
|
if (node.state === "ready" || node.state === "removed")
|
|
@@ -175,17 +196,70 @@ export const runNodeInstall = (tokens, context) => guarded(Effect.gen(function*
|
|
|
175
196
|
const proven = { inputDigest, planDigest, proof, waitMs: WAIT_MS };
|
|
176
197
|
return yield* finishInstall(context, { ...parameters, ...proven });
|
|
177
198
|
}), context);
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
199
|
+
const REGISTER_OPTIONS = new Set([
|
|
200
|
+
"--command-id",
|
|
201
|
+
"--launcher",
|
|
202
|
+
"--name",
|
|
203
|
+
"--remote-profile",
|
|
204
|
+
]);
|
|
205
|
+
const readRegister = ({ options, positionals }) => {
|
|
206
|
+
requirePositionals(positionals, 1);
|
|
207
|
+
const host = positionals[0] ?? "";
|
|
208
|
+
const launcherPath = options.get("--launcher");
|
|
209
|
+
const profile = options.get("--remote-profile");
|
|
210
|
+
return {
|
|
211
|
+
commandId: options.get("--command-id"),
|
|
212
|
+
parameters: {
|
|
213
|
+
host,
|
|
214
|
+
...(launcherPath === undefined ? {} : { launcherPath }),
|
|
215
|
+
name: readName(options.get("--name") ?? nameFromHost(host)),
|
|
216
|
+
...(profile === undefined ? {} : { profile }),
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
const finishRegister = (context, confirmation) => Effect.gen(function* () {
|
|
221
|
+
const result = yield* required(operation(context.dependencies.confirmRemoteNodeRegister)(confirmation));
|
|
222
|
+
write(context, { command: "node.remote.register.confirm", result }, installedText(result.node));
|
|
223
|
+
return exitFor(result.node);
|
|
224
|
+
});
|
|
225
|
+
const confirmPipedRegister = (context) => Effect.gen(function* () {
|
|
226
|
+
const piped = yield* readPipedPreview(context);
|
|
227
|
+
return yield* finishRegister(context, yield* confirmParameters(remoteNodeRegisterConfirmParametersSchema, pipedPlan(piped, false)));
|
|
228
|
+
});
|
|
229
|
+
const planRegister = (context, parsed) => Effect.gen(function* () {
|
|
230
|
+
const input = readRegister(parsed);
|
|
231
|
+
const commandId = yield* commandIdentifier(input.commandId);
|
|
232
|
+
const parameters = { ...input.parameters, commandId };
|
|
233
|
+
const preview = yield* required(operation(context.dependencies.previewRemoteNodeRegister)(parameters));
|
|
234
|
+
write(context, {
|
|
235
|
+
command: "node.remote.register.preview",
|
|
236
|
+
result: { parameters, preview },
|
|
237
|
+
}, registerPlanText(preview));
|
|
238
|
+
return { parameters, preview };
|
|
239
|
+
});
|
|
240
|
+
export const runNodeRegister = (tokens, context) => guarded(Effect.gen(function* () {
|
|
241
|
+
const parsed = parseOptions(tokens, REGISTER_OPTIONS, new Set(TWO_PHASE_FLAGS));
|
|
242
|
+
const requested = requestedTwoPhaseMode(parsed.flags);
|
|
243
|
+
if (requested === "confirm-stdin")
|
|
244
|
+
return yield* confirmPipedRegister(context);
|
|
245
|
+
const mode = requested ?? promptOrRefuse(context);
|
|
246
|
+
const { parameters, preview } = yield* planRegister(context, parsed);
|
|
247
|
+
if (mode === "dry-run")
|
|
248
|
+
return 0;
|
|
249
|
+
const question = `Register the Node on ${parameters.host} as ${parameters.name}?`;
|
|
250
|
+
if (!(yield* confirmed(context, question, mode)))
|
|
251
|
+
return cancelled(context);
|
|
252
|
+
const { inputDigest, planDigest, proof } = preview;
|
|
253
|
+
const proven = { inputDigest, planDigest, proof };
|
|
254
|
+
return yield* finishRegister(context, { ...parameters, ...proven });
|
|
255
|
+
}), context);
|
|
182
256
|
export const runNodeList = (tokens, context) => guarded(Effect.gen(function* () {
|
|
183
257
|
const { flags, positionals } = parseOptions(tokens, new Set(), new Set(["--all"]));
|
|
184
258
|
requirePositionals(positionals, 0);
|
|
185
259
|
const listed = yield* required(operation(context.dependencies.listRemoteNodes)({
|
|
186
260
|
includeRemoved: flags.has("--all"),
|
|
187
261
|
}));
|
|
188
|
-
const nodes = yield* withReachability(listed.nodes);
|
|
262
|
+
const nodes = yield* withReachability(listed.nodes, context.dependencies.sshLayer);
|
|
189
263
|
write(context, { command: "node.remote.list", result: { nodes } }, listText(nodes));
|
|
190
264
|
return 0;
|
|
191
265
|
}), context);
|
|
@@ -197,9 +271,13 @@ const readRemove = ({ flags, options, positionals }) => {
|
|
|
197
271
|
purge: flags.has("--purge"),
|
|
198
272
|
};
|
|
199
273
|
};
|
|
200
|
-
const removeQuestion = (node, purge) =>
|
|
201
|
-
|
|
202
|
-
|
|
274
|
+
const removeQuestion = (node, purge) => {
|
|
275
|
+
if (node.root === undefined)
|
|
276
|
+
return `Forget ${node.name}? The Node on ${node.host} keeps running.`;
|
|
277
|
+
return purge
|
|
278
|
+
? `Uninstall ${node.name} from ${node.host}:${node.root} and DELETE profile ${node.profile}'s state (its database)? Sign-ins there stay.`
|
|
279
|
+
: `Uninstall ${node.name} from ${node.host}:${node.root}? Profile ${node.profile}'s state stays for a later add.`;
|
|
280
|
+
};
|
|
203
281
|
const registered = (context, name) => Effect.flatMap(required(operation(context.dependencies.listRemoteNodes)({})), (listed) => {
|
|
204
282
|
const node = listed.nodes.find((candidate) => candidate.name === name);
|
|
205
283
|
return node === undefined
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type Connection, type LocalNodeStatusResult, MaiaClientError, type RemoteNodeRecord } from "@maiaos/sdk";
|
|
2
|
-
import { type LocalNodeEffectClient, type NodeApiEffectDiscoveryOptions } from "@maiaos/sdk/node/effect";
|
|
2
|
+
import { type LocalNodeEffectClient, type NodeApiEffectDiscoveryOptions, type NodeBridge } from "@maiaos/sdk/node/effect";
|
|
3
3
|
import type * as Crypto from "effect/Crypto";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import type { ChildProcessSpawner } from "effect/process/ChildProcessSpawner";
|
|
5
7
|
import * as Scope from "effect/Scope";
|
|
6
8
|
import { type CliNodeConnector } from "../local-node/index.js";
|
|
9
|
+
export type SshLayer = Layer.Layer<ChildProcessSpawner>;
|
|
7
10
|
export declare const readRemoteNode: (connector: CliNodeConnector, options: NodeApiEffectDiscoveryOptions, name: string) => Effect.Effect<{
|
|
8
11
|
readonly createdAt: string;
|
|
9
12
|
readonly error?: {
|
|
@@ -28,27 +31,32 @@ export declare const readRemoteNode: (connector: CliNodeConnector, options: Node
|
|
|
28
31
|
readonly launcherPath: string;
|
|
29
32
|
readonly maiaVersion?: string | undefined;
|
|
30
33
|
readonly name: string;
|
|
34
|
+
readonly origin?: "registered" | undefined;
|
|
31
35
|
readonly profile: string;
|
|
32
36
|
readonly releaseId?: string | undefined;
|
|
33
37
|
readonly remaining?: readonly string[] | undefined;
|
|
34
38
|
readonly revision: string;
|
|
35
|
-
readonly root
|
|
39
|
+
readonly root?: string | undefined;
|
|
36
40
|
readonly schemaVersion: "maia.remote-node/v1";
|
|
37
41
|
readonly state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
|
|
38
|
-
readonly unitName
|
|
42
|
+
readonly unitName?: string | undefined;
|
|
39
43
|
readonly updatedAt: string;
|
|
40
44
|
}, unknown, Crypto.Crypto>;
|
|
41
45
|
export type RemoteBridge = {
|
|
46
|
+
readonly attachSession: NodeBridge["attachSession"];
|
|
42
47
|
readonly client: LocalNodeEffectClient;
|
|
43
48
|
readonly closed: Effect.Effect<boolean>;
|
|
49
|
+
readonly coordinator: LocalNodeEffectClient;
|
|
50
|
+
readonly coordinatorAttachSession: NodeBridge["attachSession"];
|
|
44
51
|
readonly status: LocalNodeStatusResult;
|
|
45
52
|
readonly version: string;
|
|
46
53
|
};
|
|
47
|
-
export declare const openRemoteBridge: (node: RemoteNodeRecord, scope: Scope.Scope) => Effect.Effect<RemoteBridge, MaiaClientError>;
|
|
54
|
+
export declare const openRemoteBridge: (node: RemoteNodeRecord, scope: Scope.Scope, ssh?: SshLayer) => Effect.Effect<RemoteBridge, MaiaClientError>;
|
|
48
55
|
export declare const makeRemoteNodeConnector: (input: {
|
|
49
56
|
readonly local?: CliNodeConnector;
|
|
50
57
|
readonly name: string;
|
|
51
58
|
readonly scope: Scope.Scope;
|
|
59
|
+
readonly ssh?: SshLayer;
|
|
52
60
|
}) => CliNodeConnector;
|
|
53
61
|
export declare const remoteSignInScript: (node: RemoteNodeRecord, connection: Connection) => string | undefined;
|
|
54
62
|
export declare const remoteVendorLogin: (input: {
|
|
@@ -3,12 +3,15 @@ import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto";
|
|
|
3
3
|
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
4
4
|
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
5
5
|
import { MaiaClientError, } from "@maiaos/sdk";
|
|
6
|
-
import { bridgeScript, openNodeBridge, shellQuote, sshCommandArguments, } from "@maiaos/sdk/node/effect";
|
|
6
|
+
import { bridgeScript, NO_SSH_STDERR, openNodeBridge, readSshStderr, shellQuote, sshCommandArguments, } from "@maiaos/sdk/node/effect";
|
|
7
7
|
import * as Duration from "effect/Duration";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
9
10
|
import * as Layer from "effect/Layer";
|
|
11
|
+
import { isPlatformError } from "effect/PlatformError";
|
|
10
12
|
import * as ChildProcess from "effect/process/ChildProcess";
|
|
11
13
|
import * as Scope from "effect/Scope";
|
|
14
|
+
import * as Semaphore from "effect/Semaphore";
|
|
12
15
|
import * as Stream from "effect/Stream";
|
|
13
16
|
import { connectLocalNode, discoveryOptionsFor, newCliIdentifier, } from "../local-node/index.js";
|
|
14
17
|
const spawner = NodeChildProcessSpawner.layer.pipe(Layer.provide(Layer.merge(NodeFileSystem.layer, NodePath.layer)));
|
|
@@ -29,60 +32,78 @@ export const readRemoteNode = (connector, options, name) => Effect.gen(function*
|
|
|
29
32
|
return yield* Effect.fail(unreachable(name, "no Node has this name; see maia node list."));
|
|
30
33
|
return node;
|
|
31
34
|
});
|
|
32
|
-
const STDERR_TAIL_BYTES = 512;
|
|
33
35
|
const spawnBridge = (node) => ChildProcess.make("ssh", sshCommandArguments({
|
|
34
36
|
host: node.host,
|
|
35
37
|
script: bridgeScript(node.launcherPath),
|
|
36
38
|
}), { stderr: "pipe", stdin: "pipe", stdout: "pipe" });
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
+
const readStderr = (stderr, read) => stderr.pipe(Stream.decodeText(), Stream.runForEach((chunk) => Effect.sync(() => {
|
|
40
|
+
read.reader = readSshStderr(read.reader, chunk);
|
|
39
41
|
})), Effect.ignore, Effect.forkScoped);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const SSH_NOT_STARTED = "ssh could not be started.";
|
|
43
|
+
const reasonOf = (error, failure) => {
|
|
44
|
+
const own = isPlatformError(error) ? SSH_NOT_STARTED : error.message;
|
|
45
|
+
const failed = own.endsWith(".") ? own : `${own}.`;
|
|
46
|
+
return failure === undefined ? failed : `${failed} ${failure.message}`;
|
|
43
47
|
};
|
|
44
48
|
const asRecorded = (node, bridge) => {
|
|
45
|
-
const { client, closed, hello } = bridge;
|
|
49
|
+
const { attachSession, client, closed, coordinator, coordinatorAttachSession, hello, } = bridge;
|
|
46
50
|
return hello.status.profile === node.profile
|
|
47
51
|
? Effect.succeed({
|
|
52
|
+
attachSession,
|
|
48
53
|
client,
|
|
49
54
|
closed,
|
|
55
|
+
coordinator,
|
|
56
|
+
coordinatorAttachSession,
|
|
50
57
|
status: hello.status,
|
|
51
58
|
version: hello.version,
|
|
52
59
|
})
|
|
53
60
|
: Effect.fail(unreachable(node.name, "the bridge answers for another profile."));
|
|
54
61
|
};
|
|
55
|
-
|
|
62
|
+
const notReady = ({ name, state }) => state === "install_failed" || state === "remove_failed"
|
|
63
|
+
? `it is ${state}, not ready: remove it with 'maia node remove ${name}'.`
|
|
64
|
+
: `it is ${state}, not ready.`;
|
|
65
|
+
export const openRemoteBridge = (node, scope, ssh = spawner) => {
|
|
56
66
|
if (node.state !== "ready")
|
|
57
|
-
return Effect.fail(unreachable(node.name,
|
|
58
|
-
const
|
|
67
|
+
return Effect.fail(unreachable(node.name, notReady(node)));
|
|
68
|
+
const read = { reader: NO_SSH_STDERR };
|
|
59
69
|
return Effect.gen(function* () {
|
|
60
70
|
const handle = yield* spawnBridge(node);
|
|
61
|
-
yield*
|
|
71
|
+
yield* readStderr(handle.stderr, read);
|
|
62
72
|
const bridge = yield* openNodeBridge(handle, {
|
|
63
73
|
helloDeadline: BRIDGE_DEADLINE,
|
|
64
74
|
});
|
|
65
75
|
return yield* asRecorded(node, bridge);
|
|
66
|
-
}).pipe(Effect.provide(
|
|
76
|
+
}).pipe(Effect.provide(ssh), Effect.provideService(Scope.Scope, scope), Effect.mapError((error) => error instanceof MaiaClientError
|
|
67
77
|
? error
|
|
68
|
-
: unreachable(node.name, reasonOf(error,
|
|
78
|
+
: unreachable(node.name, reasonOf(error, read.reader.failure))));
|
|
69
79
|
};
|
|
80
|
+
const connectionOf = (bridge, principal) => ({
|
|
81
|
+
attachSession: principal === undefined
|
|
82
|
+
? bridge.attachSession
|
|
83
|
+
: bridge.coordinatorAttachSession,
|
|
84
|
+
client: principal === undefined ? bridge.client : bridge.coordinator,
|
|
85
|
+
status: bridge.status,
|
|
86
|
+
});
|
|
87
|
+
const openIntoCache = (node, { scope, ssh }, cache) => Effect.uninterruptibleMask((restore) => Effect.flatMap(Scope.fork(scope), (attempt) => restore(openRemoteBridge(node, attempt, ssh)).pipe(Effect.onExit((exit) => {
|
|
88
|
+
const closed = cache.entry?.scope;
|
|
89
|
+
if (Exit.isSuccess(exit))
|
|
90
|
+
cache.entry = { bridge: exit.value, scope: attempt };
|
|
91
|
+
else
|
|
92
|
+
delete cache.entry;
|
|
93
|
+
return Effect.andThen(closed === undefined ? Effect.void : Scope.close(closed, Exit.void), Exit.isSuccess(exit) ? Effect.void : Scope.close(attempt, exit));
|
|
94
|
+
}))));
|
|
70
95
|
export const makeRemoteNodeConnector = (input) => {
|
|
71
96
|
const local = input.local ?? connectLocalNode;
|
|
72
97
|
const cache = {};
|
|
73
|
-
const
|
|
74
|
-
|
|
98
|
+
const opening = Semaphore.makeUnsafe(1);
|
|
99
|
+
const open = ({ principal: _mark, ...operator }) => Effect.gen(function* () {
|
|
100
|
+
const cached = cache.entry?.bridge;
|
|
75
101
|
if (cached !== undefined && !(yield* cached.closed))
|
|
76
102
|
return cached;
|
|
77
|
-
const node = yield* readRemoteNode(local,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
return (options) => open(options).pipe(Effect.map((bridge) => ({
|
|
83
|
-
client: bridge.client,
|
|
84
|
-
status: bridge.status,
|
|
85
|
-
})));
|
|
103
|
+
const node = yield* readRemoteNode(local, operator, input.name);
|
|
104
|
+
return yield* openIntoCache(node, input, cache);
|
|
105
|
+
}).pipe(Semaphore.withPermit(opening));
|
|
106
|
+
return (options) => open(options).pipe(Effect.map((bridge) => connectionOf(bridge, options.principal)));
|
|
86
107
|
};
|
|
87
108
|
const vendorCommand = (executor) => executor === "codex-cli"
|
|
88
109
|
? { arguments_: "login --device-auth", variable: "CODEX_HOME" }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { makeRemoteNodeClient, type RemoteNodeCliDependencies, } from "./client.js";
|
|
2
|
-
export { runNodeInstall, runNodeList, runNodeRemove } from "./commands.js";
|
|
3
|
-
export { makeRemoteNodeConnector, remoteVendorLogin } from "./connector.js";
|
|
2
|
+
export { runNodeInstall, runNodeList, runNodeRegister, runNodeRemove, } from "./commands.js";
|
|
3
|
+
export { makeRemoteNodeConnector, remoteVendorLogin, type SshLayer, } from "./connector.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { makeRemoteNodeClient, } from "./client.js";
|
|
2
|
-
export { runNodeInstall, runNodeList, runNodeRemove } from "./commands.js";
|
|
3
|
-
export { makeRemoteNodeConnector, remoteVendorLogin } from "./connector.js";
|
|
2
|
+
export { runNodeInstall, runNodeList, runNodeRegister, runNodeRemove, } from "./commands.js";
|
|
3
|
+
export { makeRemoteNodeConnector, remoteVendorLogin, } from "./connector.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { RemoteNodeRecord } from "@maiaos/sdk";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import { type SshLayer } from "./connector.js";
|
|
3
4
|
export type Reachability = {
|
|
4
5
|
readonly latencyMs: number;
|
|
6
|
+
readonly lifecycle: string;
|
|
5
7
|
readonly pid: number;
|
|
8
|
+
readonly pressure: string;
|
|
6
9
|
readonly state: "reachable";
|
|
10
|
+
readonly trees: {
|
|
11
|
+
readonly capacity: number;
|
|
12
|
+
readonly used: number;
|
|
13
|
+
};
|
|
7
14
|
readonly version: string;
|
|
8
15
|
} | {
|
|
9
16
|
readonly reason: string;
|
|
@@ -18,5 +25,40 @@ export type Reachability = {
|
|
|
18
25
|
readonly reason: string;
|
|
19
26
|
readonly state: "unreachable";
|
|
20
27
|
};
|
|
21
|
-
export declare const
|
|
28
|
+
export declare const withReachability: (nodes: readonly RemoteNodeRecord[], ssh?: SshLayer) => Effect.Effect<{
|
|
29
|
+
createdAt: string;
|
|
30
|
+
error?: {
|
|
31
|
+
readonly code: string;
|
|
32
|
+
readonly message: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
executors: readonly {
|
|
35
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
36
|
+
readonly interpreter?: {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
readonly sha256: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
readonly path?: string | undefined;
|
|
41
|
+
readonly realPath?: string | undefined;
|
|
42
|
+
readonly reason?: string | undefined;
|
|
43
|
+
readonly sha256?: string | undefined;
|
|
44
|
+
readonly source: "discovered" | "override";
|
|
45
|
+
readonly state: "available" | "unavailable";
|
|
46
|
+
}[];
|
|
47
|
+
host: string;
|
|
48
|
+
installedAt?: string | undefined;
|
|
49
|
+
launcherPath: string;
|
|
50
|
+
maiaVersion?: string | undefined;
|
|
51
|
+
name: string;
|
|
52
|
+
origin?: "registered" | undefined;
|
|
53
|
+
profile: string;
|
|
54
|
+
releaseId?: string | undefined;
|
|
55
|
+
remaining?: readonly string[] | undefined;
|
|
56
|
+
revision: string;
|
|
57
|
+
root?: string | undefined;
|
|
58
|
+
schemaVersion: "maia.remote-node/v1";
|
|
59
|
+
state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
|
|
60
|
+
unitName?: string | undefined;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
reachability: Reachability;
|
|
63
|
+
}[], never, never>;
|
|
22
64
|
//# sourceMappingURL=reachability.d.ts.map
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import * as Clock from "effect/Clock";
|
|
2
2
|
import * as Duration from "effect/Duration";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
-
import { openRemoteBridge } from "./connector.js";
|
|
4
|
+
import { openRemoteBridge, } from "./connector.js";
|
|
5
5
|
const CHECK_DEADLINE = Duration.seconds(12);
|
|
6
6
|
const greeted = (node, bridge, latencyMs) => node.maiaVersion === undefined || bridge.version === node.maiaVersion
|
|
7
7
|
? {
|
|
8
8
|
latencyMs,
|
|
9
|
+
lifecycle: bridge.status.lifecycle,
|
|
9
10
|
pid: bridge.status.pid,
|
|
11
|
+
pressure: bridge.status.processResources.pressure,
|
|
10
12
|
state: "reachable",
|
|
13
|
+
trees: {
|
|
14
|
+
capacity: bridge.status.processResources.admission.capacity,
|
|
15
|
+
used: bridge.status.processResources.admission.usedTrees,
|
|
16
|
+
},
|
|
11
17
|
version: bridge.version,
|
|
12
18
|
}
|
|
13
19
|
: {
|
|
14
20
|
reason: `it answers as maia-node ${bridge.version}, recorded ${node.maiaVersion}`,
|
|
15
21
|
state: "stale",
|
|
16
22
|
};
|
|
17
|
-
|
|
23
|
+
const checkReachability = (node, ssh) => node.state === "ready"
|
|
18
24
|
? Effect.gen(function* () {
|
|
19
25
|
const started = yield* Clock.currentTimeMillis;
|
|
20
|
-
const bridge = yield* Effect.flatMap(Effect.scope, (scope) => openRemoteBridge(node, scope));
|
|
26
|
+
const bridge = yield* Effect.flatMap(Effect.scope, (scope) => openRemoteBridge(node, scope, ssh));
|
|
21
27
|
const finished = yield* Clock.currentTimeMillis;
|
|
22
28
|
return greeted(node, bridge, finished - started);
|
|
23
29
|
}).pipe(Effect.scoped, Effect.timeoutOrElse({
|
|
@@ -31,4 +37,8 @@ export const checkReachability = (node) => node.state === "ready"
|
|
|
31
37
|
state: "unreachable",
|
|
32
38
|
})))
|
|
33
39
|
: Effect.succeed({ reason: `it is ${node.state}`, state: "not_checked" });
|
|
40
|
+
export const withReachability = (nodes, ssh) => Effect.forEach(nodes, (node) => Effect.map(checkReachability(node, ssh), (reachability) => ({
|
|
41
|
+
...node,
|
|
42
|
+
reachability,
|
|
43
|
+
})), { concurrency: 4 });
|
|
34
44
|
//# sourceMappingURL=reachability.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { RemoteNodeInstallPreviewResult, RemoteNodeRecord } from "@maiaos/sdk";
|
|
1
|
+
import type { RemoteNodeInstallPreviewResult, RemoteNodeRecord, RemoteNodeRegisterPreviewResult } from "@maiaos/sdk";
|
|
2
2
|
import type { Reachability } from "./reachability.js";
|
|
3
3
|
export declare const planText: (preview: RemoteNodeInstallPreviewResult) => string;
|
|
4
|
+
export declare const registerPlanText: ({ name, plan, }: RemoteNodeRegisterPreviewResult) => string;
|
|
4
5
|
export declare const installedText: (node: RemoteNodeRecord) => string;
|
|
5
6
|
export declare const removedText: (node: RemoteNodeRecord) => string;
|
|
6
7
|
export declare const listText: (nodes: readonly (RemoteNodeRecord & {
|
package/dist/remote-node/text.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { formatRows } from "../command-line/index.js";
|
|
2
|
-
const
|
|
3
|
-
const printable = (text) => text.replaceAll(CONTROL, "?");
|
|
1
|
+
import { cell, formatRows } from "../command-line/index.js";
|
|
2
|
+
const textLines = (lines) => `${lines.map(cell).join("\n")}\n`;
|
|
4
3
|
const mebibytes = (bytes) => `${(bytes / 1_048_576).toFixed(1)} MiB`;
|
|
5
4
|
const executorLine = (executor) => {
|
|
6
5
|
const name = executor.executor === "codex-cli" ? "codex " : "claude";
|
|
@@ -14,7 +13,7 @@ const executorLine = (executor) => {
|
|
|
14
13
|
const changeLines = (plan) => plan.executorChanges.map((change) => ` changed ${change.executor}: ${change.from?.path ?? "none"} -> ${change.to?.path ?? "none"}`);
|
|
15
14
|
const readyPlan = (preview) => {
|
|
16
15
|
const { name, plan } = preview;
|
|
17
|
-
return [
|
|
16
|
+
return textLines([
|
|
18
17
|
`Plan (${plan.mode}) for ${name}: maia-node ${plan.maiaVersion}, release ${plan.releaseId}, upload ${mebibytes(plan.uploadBytes)}`,
|
|
19
18
|
` root ${plan.root} profile ${plan.profile} unit ${plan.unitName}`,
|
|
20
19
|
` bridge ${plan.launcherPath}`,
|
|
@@ -25,40 +24,88 @@ const readyPlan = (preview) => {
|
|
|
25
24
|
...(plan.prune.releases.length === 0
|
|
26
25
|
? []
|
|
27
26
|
: [` prune ${plan.prune.releases.join(", ")}`]),
|
|
28
|
-
|
|
29
|
-
].join("\n");
|
|
27
|
+
]);
|
|
30
28
|
};
|
|
29
|
+
const blockerLines = ({ code, message, remedy, }) => [
|
|
30
|
+
` - ${code}: ${message}`,
|
|
31
|
+
...(remedy === undefined ? [] : [` ${remedy}`]),
|
|
32
|
+
];
|
|
31
33
|
export const planText = (preview) => {
|
|
32
34
|
if (preview.state === "ready")
|
|
33
|
-
return
|
|
35
|
+
return readyPlan(preview);
|
|
34
36
|
if (preview.state === "probing")
|
|
35
37
|
return "Still probing.\n";
|
|
36
|
-
return
|
|
38
|
+
return textLines([
|
|
37
39
|
`The host cannot run a contained Maia Node (${preview.facts.distro || preview.facts.os}, Linux ${preview.facts.kernel}):`,
|
|
38
|
-
...preview.blockers.
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
...preview.blockers.flatMap(blockerLines),
|
|
41
|
+
]);
|
|
42
|
+
};
|
|
43
|
+
export const registerPlanText = ({ name, plan, }) => textLines([
|
|
44
|
+
`Register ${name}: maia-node ${plan.maiaVersion} running on ${plan.host}, profile ${plan.profile}`,
|
|
45
|
+
` bridge ${plan.launcherPath}`,
|
|
46
|
+
` instance ${plan.instanceId}`,
|
|
47
|
+
]);
|
|
48
|
+
const stateLines = (node) => [
|
|
49
|
+
`${node.name} is ${node.state}.`,
|
|
50
|
+
...(node.error === undefined
|
|
51
|
+
? []
|
|
52
|
+
: [` ${node.error.code}: ${node.error.message}`]),
|
|
53
|
+
];
|
|
54
|
+
export const installedText = (node) => textLines(node.state === "ready"
|
|
55
|
+
? [
|
|
56
|
+
`${node.name} is ready: maia-node ${node.maiaVersion ?? "?"} on ${node.host}.`,
|
|
57
|
+
`Next: maia --node ${node.name} status`,
|
|
58
|
+
]
|
|
59
|
+
: stateLines(node));
|
|
60
|
+
export const removedText = (node) => {
|
|
61
|
+
if (node.state === "removed" && node.origin === "registered")
|
|
62
|
+
return textLines([
|
|
63
|
+
`${node.name} is forgotten; the Node on ${node.host} keeps running.`,
|
|
64
|
+
]);
|
|
65
|
+
return textLines(node.state === "removed"
|
|
66
|
+
? [
|
|
67
|
+
`${node.name} is removed from ${node.host}.`,
|
|
68
|
+
...(node.remaining === undefined || node.remaining.length === 0
|
|
69
|
+
? []
|
|
70
|
+
: [` Kept on the host: ${node.remaining.join(", ")}`]),
|
|
71
|
+
]
|
|
72
|
+
: stateLines(node));
|
|
41
73
|
};
|
|
42
|
-
const errorLine = (node) => node.error === undefined
|
|
43
|
-
? ""
|
|
44
|
-
: `\n ${node.error.code}: ${node.error.message}`;
|
|
45
|
-
export const installedText = (node) => printable(node.state === "ready"
|
|
46
|
-
? `${node.name} is ready: maia-node ${node.maiaVersion ?? "?"} on ${node.host}.\nNext: maia --node ${node.name} status\n`
|
|
47
|
-
: `${node.name} is ${node.state}.${errorLine(node)}\n`);
|
|
48
|
-
export const removedText = (node) => printable(node.state === "removed"
|
|
49
|
-
? `${node.name} is removed from ${node.host}.${node.remaining === undefined || node.remaining.length === 0 ? "" : `\n Kept on the host: ${node.remaining.join(", ")}`}\n`
|
|
50
|
-
: `${node.name} is ${node.state}.${errorLine(node)}\n`);
|
|
51
74
|
const reachabilityText = (reachability) => reachability.state === "reachable"
|
|
52
75
|
? `reachable pid ${String(reachability.pid)} ${String(reachability.latencyMs)} ms`
|
|
53
76
|
: `${reachability.state}: ${reachability.reason}`;
|
|
54
|
-
|
|
77
|
+
const loadCells = (reachability) => reachability.state === "reachable"
|
|
78
|
+
? [
|
|
79
|
+
`${reachability.lifecycle} ${reachability.pressure}`,
|
|
80
|
+
`${String(reachability.trees.used)}/${String(reachability.trees.capacity)}`,
|
|
81
|
+
]
|
|
82
|
+
: ["-", "-"];
|
|
83
|
+
const LIST_HEADERS = [
|
|
84
|
+
"NODE",
|
|
85
|
+
"HOST",
|
|
86
|
+
"STATE",
|
|
87
|
+
"VERSION",
|
|
88
|
+
"HEALTH",
|
|
89
|
+
"TREES",
|
|
90
|
+
"REACHABLE",
|
|
91
|
+
];
|
|
92
|
+
const observedState = ({ reachability, state, }) => {
|
|
93
|
+
if (state !== "ready" || reachability.state === "reachable")
|
|
94
|
+
return state;
|
|
95
|
+
return reachability.state === "stale" ? "stale" : "unreachable";
|
|
96
|
+
};
|
|
97
|
+
const listRow = (node) => [
|
|
55
98
|
node.name,
|
|
56
99
|
node.host,
|
|
57
|
-
node
|
|
58
|
-
node.maiaVersion ?? "-",
|
|
100
|
+
observedState(node),
|
|
101
|
+
node.maiaVersion === "0.0.0" ? "-" : (node.maiaVersion ?? "-"),
|
|
102
|
+
...loadCells(node.reachability),
|
|
59
103
|
reachabilityText(node.reachability),
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
104
|
+
]
|
|
105
|
+
.map(cell)
|
|
106
|
+
.join("\t");
|
|
107
|
+
export const listText = (nodes) => formatRows(nodes, listRow, {
|
|
108
|
+
empty: "No remote Nodes. Add one with: maia node install <host> --release <file> [--node-runtime <file>]",
|
|
109
|
+
headers: LIST_HEADERS,
|
|
110
|
+
});
|
|
64
111
|
//# sourceMappingURL=text.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const remote = () => import("../index.js");
|
|
2
2
|
const status = () => import("../../status/index.js");
|
|
3
|
+
const bootstrap = () => import("../../team-workspace/index.js");
|
|
3
4
|
const nodeStatus = [status, "runNodeStatus"];
|
|
4
5
|
export const NODE_TREE = {
|
|
5
6
|
groups: [["node", "This Node, and remote Nodes over SSH (--node <name>)."]],
|
|
@@ -26,12 +27,31 @@ export const NODE_TREE = {
|
|
|
26
27
|
{ run: [status, "runNodeMonitor"] },
|
|
27
28
|
],
|
|
28
29
|
[
|
|
29
|
-
"node
|
|
30
|
+
"node bootstrap --owner-name <display-name> --workspace-name <name> [--command-id <id>]",
|
|
31
|
+
1,
|
|
32
|
+
["team-workspace.bootstrap.preview", "team-workspace.bootstrap.apply"],
|
|
33
|
+
"Create the first owner of an empty Node after a terminal confirmation.",
|
|
34
|
+
{
|
|
35
|
+
example: 'maia --profile work node bootstrap --owner-name Ada --workspace-name "Ada\'s Workspace"',
|
|
36
|
+
kind: "composite",
|
|
37
|
+
remote: false,
|
|
38
|
+
run: [bootstrap, "runNodeBootstrap"],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"node install <host> --release <maia-node.release.json> [--node-runtime <node>] [--name <name>] [--root <dir>] [--remote-profile <name>] [--keep <2..8>] [--codex-bin <path>] [--claude-bin <path>] [--command-id <id>] [--dry-run | --confirm-stdin | --yes]",
|
|
30
43
|
1,
|
|
31
44
|
["node.remote.install.preview", "node.remote.install.confirm"],
|
|
32
45
|
"Install Maia Node on a remote host over SSH.",
|
|
33
46
|
{ kind: "two-phase", remote: false, run: [remote, "runNodeInstall"] },
|
|
34
47
|
],
|
|
48
|
+
[
|
|
49
|
+
"node register <host> [--launcher <path>] [--name <name>] [--remote-profile <name>] [--command-id <id>] [--dry-run | --confirm-stdin]",
|
|
50
|
+
1,
|
|
51
|
+
["node.remote.register.preview", "node.remote.register.confirm"],
|
|
52
|
+
"Register a Maia Node already running on a host.",
|
|
53
|
+
{ kind: "two-phase", remote: false, run: [remote, "runNodeRegister"] },
|
|
54
|
+
],
|
|
35
55
|
[
|
|
36
56
|
"node list [--all]",
|
|
37
57
|
1,
|