@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.20
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/bootstrap/run.js +5 -2
- package/dist/cli/cli.d.ts +2 -1
- package/dist/cli/cli.js +81 -16
- package/dist/command-line/context.d.ts +14 -4
- package/dist/command-line/context.js +1 -1
- package/dist/command-line/index.d.ts +6 -6
- package/dist/command-line/index.js +6 -5
- package/dist/command-line/input/arguments.d.ts +7 -0
- package/dist/command-line/input/arguments.js +22 -10
- package/dist/command-line/input/index.d.ts +2 -2
- package/dist/command-line/input/index.js +2 -2
- 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/access/client.d.ts +13 -0
- package/dist/connection/access/client.js +19 -0
- package/dist/connection/access/commands.d.ts +6 -0
- package/dist/connection/access/commands.js +60 -0
- package/dist/connection/access/format.d.ts +8 -0
- package/dist/connection/access/format.js +61 -0
- package/dist/connection/access/index.d.ts +3 -0
- package/dist/connection/access/index.js +3 -0
- package/dist/connection/access/input.d.ts +53 -0
- package/dist/connection/access/input.js +83 -0
- package/dist/connection/client.d.ts +99 -1
- package/dist/connection/client.js +9 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.js +2 -1
- package/dist/connection/system.d.ts +1 -0
- package/dist/connection/system.js +109 -5
- package/dist/connection/tree/tree.js +59 -8
- 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 +9 -4
- package/dist/local-node/client.js +21 -9
- package/dist/local-node/index.d.ts +2 -1
- package/dist/local-node/index.js +2 -1
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/commands.js +2 -1
- package/dist/mcp/calls.d.ts +1 -0
- package/dist/mcp/calls.js +37 -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 +28 -18
- 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 +54 -26
- 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 +31 -9
- 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 +12 -3
- package/dist/session/client.js +18 -17
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +120 -13
- package/dist/session/create-tasks.js +29 -11
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.js +2 -1
- 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.d.ts +1 -0
- package/dist/session/output/human.js +21 -10
- package/dist/session/output/index.d.ts +2 -2
- package/dist/session/output/index.js +2 -2
- package/dist/session/output/tasks.d.ts +16 -1
- package/dist/session/output/tasks.js +41 -27
- package/dist/session/tree/tree.js +67 -8
- package/dist/session/turn/client.d.ts +4 -1
- package/dist/session/turn/client.js +22 -11
- package/dist/session/turn/commands.d.ts +2 -0
- package/dist/session/turn/commands.js +39 -11
- 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/command.js +3 -1
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +10 -4
- 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/control-commands.js +26 -9
- package/dist/terminal/keys.d.ts +12 -0
- package/dist/terminal/keys.js +62 -0
- 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 +16 -16
- package/package.json +10 -8
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { KeyId } from "@earendil-works/pi-tui";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
export type ScreenSize = {
|
|
6
|
+
readonly columns: number;
|
|
7
|
+
readonly rows: number;
|
|
8
|
+
};
|
|
9
|
+
export type Screen = {
|
|
10
|
+
readonly quitKeys: readonly KeyId[];
|
|
11
|
+
readonly render: (size: ScreenSize) => readonly string[];
|
|
12
|
+
};
|
|
13
|
+
export type Surface = {
|
|
14
|
+
readonly drain: () => Promise<void>;
|
|
15
|
+
readonly matches: (input: string, key: KeyId) => boolean;
|
|
16
|
+
readonly show: (paint: () => string[], onInput: (input: string) => void) => void;
|
|
17
|
+
readonly size: () => ScreenSize;
|
|
18
|
+
readonly start: () => void;
|
|
19
|
+
readonly stop: () => void;
|
|
20
|
+
};
|
|
21
|
+
type Write = (chunk: string, callback?: () => void) => unknown;
|
|
22
|
+
export type TerminalHost = {
|
|
23
|
+
readonly env: Readonly<NodeJS.ProcessEnv>;
|
|
24
|
+
readonly kill: (pid: number, signal: "SIGTSTP") => unknown;
|
|
25
|
+
readonly off: (event: string, listener: () => void) => unknown;
|
|
26
|
+
readonly on: (event: string, listener: () => void) => unknown;
|
|
27
|
+
readonly platform: NodeJS.Platform;
|
|
28
|
+
readonly stdin: {
|
|
29
|
+
readonly isTTY?: boolean;
|
|
30
|
+
readonly setRawMode?: (mode: boolean) => unknown;
|
|
31
|
+
};
|
|
32
|
+
readonly stdout: {
|
|
33
|
+
readonly isTTY?: boolean;
|
|
34
|
+
write: Write;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
declare const TerminalFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
38
|
+
readonly _tag: "TerminalFailure";
|
|
39
|
+
} & Readonly<A>;
|
|
40
|
+
export declare class TerminalFailure extends TerminalFailure_base<{
|
|
41
|
+
readonly cause?: unknown;
|
|
42
|
+
readonly reason: "callback" | "missing" | "no-terminal";
|
|
43
|
+
}> {
|
|
44
|
+
}
|
|
45
|
+
declare const DashboardTerminal_base: Context.ServiceClass<DashboardTerminal, "maia/cli/DashboardTerminal", {
|
|
46
|
+
readonly run: (screen: Screen) => Effect.Effect<number, TerminalFailure>;
|
|
47
|
+
}>;
|
|
48
|
+
export declare class DashboardTerminal extends DashboardTerminal_base {
|
|
49
|
+
}
|
|
50
|
+
export type LoadSurface = Effect.Effect<Surface, TerminalFailure>;
|
|
51
|
+
export declare const terminalLayer: (host: TerminalHost, load: LoadSurface) => Layer.Layer<DashboardTerminal, never, never>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Data from "effect/Data";
|
|
3
|
+
import * as Deferred from "effect/Deferred";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import { NO_MODES, observe, resetBytes } from "./modes.js";
|
|
7
|
+
const EXIT_SIGNALLED = 130;
|
|
8
|
+
const SHUTDOWN_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM"];
|
|
9
|
+
const SUSPEND_KEY = "ctrl+z";
|
|
10
|
+
const PROCESS_GROUP = 0;
|
|
11
|
+
const WITHOUT_JOB_CONTROL = "win32";
|
|
12
|
+
const TERMINAL_PANE = "MAIA_TERMINAL_PANE";
|
|
13
|
+
const TERMINAL_GONE = "EIO";
|
|
14
|
+
export class TerminalFailure extends Data.TaggedError("TerminalFailure") {
|
|
15
|
+
}
|
|
16
|
+
export class DashboardTerminal extends Context.Service()("maia/cli/DashboardTerminal") {
|
|
17
|
+
}
|
|
18
|
+
const ignoringGoneTerminal = (action) => {
|
|
19
|
+
try {
|
|
20
|
+
action();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const code = error instanceof Error ? Reflect.get(error, "code") : undefined;
|
|
24
|
+
if (code !== TERMINAL_GONE)
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const restore = (session) => {
|
|
29
|
+
const bytes = resetBytes(session.ledger);
|
|
30
|
+
session.ledger = NO_MODES;
|
|
31
|
+
if (bytes !== "")
|
|
32
|
+
session.host.stdout.write(bytes);
|
|
33
|
+
ignoringGoneTerminal(() => {
|
|
34
|
+
session.host.stdin.setRawMode?.(false);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const leave = (session) => {
|
|
38
|
+
try {
|
|
39
|
+
ignoringGoneTerminal(session.surface.stop);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
restore(session);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const listen = (session) => {
|
|
46
|
+
const { stdout } = session.host;
|
|
47
|
+
const original = stdout.write;
|
|
48
|
+
stdout.write = (chunk, callback) => {
|
|
49
|
+
session.ledger = observe(session.ledger, chunk);
|
|
50
|
+
return original.call(stdout, chunk, callback);
|
|
51
|
+
};
|
|
52
|
+
return () => {
|
|
53
|
+
stdout.write = original;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const end = (session, code) => {
|
|
57
|
+
Deferred.doneUnsafe(session.outcome, Effect.succeed(code));
|
|
58
|
+
};
|
|
59
|
+
const attempt = (session, fallback, action) => {
|
|
60
|
+
try {
|
|
61
|
+
return action();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
Deferred.doneUnsafe(session.outcome, Effect.fail(new TerminalFailure({ cause: error, reason: "callback" })));
|
|
65
|
+
return fallback;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const suspend = (session) => {
|
|
69
|
+
const { host, onStop, surface } = session;
|
|
70
|
+
if (host.platform === WITHOUT_JOB_CONTROL || host.env[TERMINAL_PANE] === "1")
|
|
71
|
+
return;
|
|
72
|
+
attempt(session, undefined, () => {
|
|
73
|
+
leave(session);
|
|
74
|
+
host.off("SIGTSTP", onStop);
|
|
75
|
+
host.kill(PROCESS_GROUP, "SIGTSTP");
|
|
76
|
+
host.on("SIGTSTP", onStop);
|
|
77
|
+
surface.start();
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const present = (session) => {
|
|
81
|
+
const { screen, surface } = session;
|
|
82
|
+
surface.show(() => attempt(session, [], () => [...screen.render(surface.size())]), (input) => {
|
|
83
|
+
attempt(session, undefined, () => {
|
|
84
|
+
if (surface.matches(input, SUSPEND_KEY))
|
|
85
|
+
suspend(session);
|
|
86
|
+
else if (screen.quitKeys.some((key) => surface.matches(input, key)))
|
|
87
|
+
end(session, 0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
attempt(session, undefined, surface.start);
|
|
91
|
+
};
|
|
92
|
+
const onExit = (session) => () => {
|
|
93
|
+
restore(session);
|
|
94
|
+
};
|
|
95
|
+
const take = (session) => {
|
|
96
|
+
const unlisten = listen(session);
|
|
97
|
+
const shutdown = () => {
|
|
98
|
+
end(session, EXIT_SIGNALLED);
|
|
99
|
+
};
|
|
100
|
+
const handlers = [
|
|
101
|
+
...SHUTDOWN_SIGNALS.map((signal) => [signal, shutdown]),
|
|
102
|
+
["SIGTSTP", session.onStop],
|
|
103
|
+
["exit", onExit(session)],
|
|
104
|
+
];
|
|
105
|
+
handlers.forEach(([event, handler]) => session.host.on(event, handler));
|
|
106
|
+
return () => {
|
|
107
|
+
unlisten();
|
|
108
|
+
handlers.forEach(([event, handler]) => session.host.off(event, handler));
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const keep = (session, cause) => {
|
|
112
|
+
session.failure ??= { cause };
|
|
113
|
+
};
|
|
114
|
+
const release = (session, detach) => {
|
|
115
|
+
const drain = Effect.tryPromise({
|
|
116
|
+
catch: (error) => error,
|
|
117
|
+
try: () => session.surface.drain(),
|
|
118
|
+
}).pipe(Effect.catch((error) => Effect.sync(() => {
|
|
119
|
+
keep(session, error);
|
|
120
|
+
})));
|
|
121
|
+
const finish = Effect.sync(() => {
|
|
122
|
+
try {
|
|
123
|
+
leave(session);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
keep(session, error);
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
detach();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return Effect.ensuring(drain, finish);
|
|
133
|
+
};
|
|
134
|
+
const hold = (session) => Effect.gen(function* () {
|
|
135
|
+
yield* Effect.acquireRelease(Effect.sync(() => take(session)), (detach) => release(session, detach));
|
|
136
|
+
yield* Effect.sync(() => {
|
|
137
|
+
present(session);
|
|
138
|
+
});
|
|
139
|
+
return yield* Deferred.await(session.outcome);
|
|
140
|
+
}).pipe(Effect.scoped);
|
|
141
|
+
const run = (host, load, screen) => Effect.gen(function* () {
|
|
142
|
+
if (host.stdin.isTTY !== true || host.stdout.isTTY !== true)
|
|
143
|
+
return yield* new TerminalFailure({ reason: "no-terminal" });
|
|
144
|
+
const session = {
|
|
145
|
+
host,
|
|
146
|
+
ledger: NO_MODES,
|
|
147
|
+
onStop: () => {
|
|
148
|
+
suspend(session);
|
|
149
|
+
},
|
|
150
|
+
outcome: yield* Deferred.make(),
|
|
151
|
+
screen,
|
|
152
|
+
surface: yield* load,
|
|
153
|
+
};
|
|
154
|
+
const code = yield* hold(session);
|
|
155
|
+
return session.failure === undefined
|
|
156
|
+
? code
|
|
157
|
+
: yield* new TerminalFailure({
|
|
158
|
+
cause: session.failure.cause,
|
|
159
|
+
reason: "callback",
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
export const terminalLayer = (host, load) => Layer.succeed(DashboardTerminal, {
|
|
163
|
+
run: (screen) => run(host, load, screen),
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AttentionReason, type CockpitState } from "@maiaos/client-core/cockpit";
|
|
2
|
+
import type { NodeView } from "@maiaos/client-core/node-registry";
|
|
3
|
+
import type { Routine } from "@maiaos/sdk";
|
|
4
|
+
export type TreeNode = NodeView & Pick<CockpitState, "partial" | "stale">;
|
|
5
|
+
export type TreeInput = {
|
|
6
|
+
readonly accounts?: ReadonlyMap<string, string>;
|
|
7
|
+
readonly nodes: readonly TreeNode[];
|
|
8
|
+
readonly now: number;
|
|
9
|
+
readonly profile: string;
|
|
10
|
+
readonly routines?: readonly Routine[];
|
|
11
|
+
readonly state: CockpitState;
|
|
12
|
+
};
|
|
13
|
+
export type Row = {
|
|
14
|
+
readonly at: string;
|
|
15
|
+
readonly cells: readonly string[];
|
|
16
|
+
readonly children: readonly Row[];
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly depth: number;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly marker: boolean;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const ALARM = "1;31";
|
|
24
|
+
export declare const WARNING = "33";
|
|
25
|
+
export declare const codeStyle: (code: string) => string | undefined;
|
|
26
|
+
export declare const attentionStyle: (reason: AttentionReason) => string | undefined;
|
|
27
|
+
export declare const treeRows: (input: TreeInput) => readonly Row[];
|
|
28
|
+
//# sourceMappingURL=tree-model.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { isWorking, runtimeStatus, } from "@maiaos/client-core/cockpit";
|
|
2
|
+
export const ALARM = "1;31";
|
|
3
|
+
export const WARNING = "33";
|
|
4
|
+
const CODES = [..."APPR ASK FAIL STAL DONE RUN IDLE HOLD OFF".split(" "), ""];
|
|
5
|
+
const ATTENTION_CODES = new Map([
|
|
6
|
+
["approval_pending", "APPR"],
|
|
7
|
+
["failed", "FAIL"],
|
|
8
|
+
["question", "ASK"],
|
|
9
|
+
["settled_unreviewed", "DONE"],
|
|
10
|
+
["stalled", "STAL"],
|
|
11
|
+
["turn_failed", "FAIL"],
|
|
12
|
+
]);
|
|
13
|
+
const ROUTINE_CODES = {
|
|
14
|
+
active: "IDLE",
|
|
15
|
+
disabled: "OFF",
|
|
16
|
+
paused: "HOLD",
|
|
17
|
+
};
|
|
18
|
+
export const codeStyle = (code) => [ALARM, ALARM, WARNING, WARNING][CODES.indexOf(code)];
|
|
19
|
+
export const attentionStyle = (reason) => codeStyle(ATTENTION_CODES.get(reason) ?? "");
|
|
20
|
+
const order = (left, right) => Number(left > right) - Number(left < right);
|
|
21
|
+
const byUrgency = (left, right) => CODES.indexOf(left.code) - CODES.indexOf(right.code) ||
|
|
22
|
+
order(right.at, left.at) ||
|
|
23
|
+
order(left.id, right.id);
|
|
24
|
+
const group = (head, ...blocks) => {
|
|
25
|
+
const children = blocks.flatMap((block) => block.toSorted(byUrgency));
|
|
26
|
+
const { at, code, marker } = children.toSorted(byUrgency)[0] ?? {
|
|
27
|
+
at: "",
|
|
28
|
+
code: "",
|
|
29
|
+
marker: false,
|
|
30
|
+
};
|
|
31
|
+
return { ...head, at, cells: [], children, code, marker };
|
|
32
|
+
};
|
|
33
|
+
const marked = (lookup, holder) => holder === undefined || !lookup.fresh.has(holder.nodeId);
|
|
34
|
+
const sessionCode = ({ state }, session) => {
|
|
35
|
+
const reason = state.index.attention.get(session.id);
|
|
36
|
+
if (reason !== undefined)
|
|
37
|
+
return ATTENTION_CODES.get(reason) ?? "";
|
|
38
|
+
if (session.state === "waiting-approval")
|
|
39
|
+
return "APPR";
|
|
40
|
+
if (session.state === "failed")
|
|
41
|
+
return "FAIL";
|
|
42
|
+
const runtime = runtimeStatus(state.runtimes.get(session.id));
|
|
43
|
+
return isWorking({ ...runtime, state: session.state }) ? "RUN" : "IDLE";
|
|
44
|
+
};
|
|
45
|
+
const sessionRow = (lookup, session) => {
|
|
46
|
+
const { executor, id, title, updatedAt } = session;
|
|
47
|
+
const holder = lookup.state.index.sessionNodes?.get(id);
|
|
48
|
+
const [harness = "", model = "", effort = "", account = ""] = executor === undefined
|
|
49
|
+
? []
|
|
50
|
+
: [
|
|
51
|
+
executor.kind.split("-")[0],
|
|
52
|
+
executor.model ?? "default",
|
|
53
|
+
executor.effort ?? "default",
|
|
54
|
+
lookup.accounts?.get(executor.connectionId) ?? executor.connectionId,
|
|
55
|
+
];
|
|
56
|
+
return {
|
|
57
|
+
at: updatedAt,
|
|
58
|
+
cells: [harness, model, effort, holder?.hostLabel ?? "", account],
|
|
59
|
+
children: [],
|
|
60
|
+
code: sessionCode(lookup, session),
|
|
61
|
+
depth: 2,
|
|
62
|
+
id,
|
|
63
|
+
marker: marked(lookup, holder),
|
|
64
|
+
name: title ?? id,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const routineRow = (lookup, routine) => {
|
|
68
|
+
const { id, name, state, template, updatedAt } = routine;
|
|
69
|
+
const holder = lookup.state.index.projectNodes?.get(template.projectId);
|
|
70
|
+
return {
|
|
71
|
+
at: updatedAt,
|
|
72
|
+
cells: ["", "", "", holder?.hostLabel ?? ""],
|
|
73
|
+
children: [],
|
|
74
|
+
code: ROUTINE_CODES[state],
|
|
75
|
+
depth: 2,
|
|
76
|
+
id,
|
|
77
|
+
marker: marked(lookup, holder),
|
|
78
|
+
name,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const flatten = (row) => [
|
|
82
|
+
row,
|
|
83
|
+
...row.children.flatMap(flatten),
|
|
84
|
+
];
|
|
85
|
+
export const treeRows = (input) => {
|
|
86
|
+
const { nodes, routines = [], state } = input;
|
|
87
|
+
const fresh = nodes.filter(({ health, stale }) => health === "ready" && !stale);
|
|
88
|
+
const lookup = { ...input, fresh: new Set(fresh.map((node) => node.nodeId)) };
|
|
89
|
+
const sessionsOf = Map.groupBy(state.index.sessions.values(), (s) => s.projectId);
|
|
90
|
+
const routinesOf = Map.groupBy(routines, (r) => r.template.projectId);
|
|
91
|
+
const projectRow = (id) => group({ depth: 1, id, name: state.index.projects.get(id)?.name ?? id }, (routinesOf.get(id) ?? []).map((r) => routineRow(lookup, r)), (sessionsOf.get(id) ?? []).map((s) => sessionRow(lookup, s)));
|
|
92
|
+
return [...state.index.workspaces.values()]
|
|
93
|
+
.map(({ id, name, projectIds }) => group({ depth: 0, id, name }, projectIds.map(projectRow)))
|
|
94
|
+
.toSorted(byUrgency)
|
|
95
|
+
.flatMap(flatten);
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=tree-model.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Width } from "./draw.js";
|
|
2
|
+
import type { ScreenSize } from "./terminal.js";
|
|
3
|
+
import { type TreeInput } from "./tree-model.js";
|
|
4
|
+
export type TreeOptions = {
|
|
5
|
+
readonly color: boolean;
|
|
6
|
+
readonly width: Width;
|
|
7
|
+
};
|
|
8
|
+
export declare const tooSmall: ({ columns, rows }: ScreenSize) => string | undefined;
|
|
9
|
+
export declare const renderTree: (input: TreeInput, size: ScreenSize, { color, width }: TreeOptions) => readonly string[];
|
|
10
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { makeDraw } from "./draw.js";
|
|
2
|
+
import { statusBar } from "./status-bar.js";
|
|
3
|
+
import { codeStyle, treeRows } from "./tree-model.js";
|
|
4
|
+
const MINIMUM = { columns: 80, rows: 24 };
|
|
5
|
+
const COLUMNS = [
|
|
6
|
+
["HARN", 7],
|
|
7
|
+
["MODEL", 16],
|
|
8
|
+
["EFF", 8],
|
|
9
|
+
["NODE", 6],
|
|
10
|
+
["ACCT", 9],
|
|
11
|
+
];
|
|
12
|
+
const GRID_WIDTH = 55;
|
|
13
|
+
const AGE_COLUMNS = 3;
|
|
14
|
+
const BAND_ROWS = 2;
|
|
15
|
+
export const tooSmall = ({ columns, rows }) => columns < MINIMUM.columns || rows < MINIMUM.rows
|
|
16
|
+
? `Maia dashboard needs ${String(MINIMUM.columns)}x${String(MINIMUM.rows)} or more; this one is ${String(columns)}x${String(rows)}.`
|
|
17
|
+
: undefined;
|
|
18
|
+
const ageOf = (at, now) => {
|
|
19
|
+
const minutes = Math.max(0, Math.floor((now - Date.parse(at)) / 60_000));
|
|
20
|
+
if (Number.isNaN(minutes))
|
|
21
|
+
return "-";
|
|
22
|
+
const hours = Math.floor(minutes / 60);
|
|
23
|
+
const days = Math.floor(hours / 24);
|
|
24
|
+
if (minutes < 1)
|
|
25
|
+
return "<1m";
|
|
26
|
+
if (hours < 1)
|
|
27
|
+
return `${String(minutes)}m`;
|
|
28
|
+
if (days < 1)
|
|
29
|
+
return `${String(hours)}h`;
|
|
30
|
+
if (days < 100)
|
|
31
|
+
return `${String(days)}d`;
|
|
32
|
+
if (days < 365)
|
|
33
|
+
return `${String(Math.floor(days / 7))}w`;
|
|
34
|
+
return `${String(Math.min(99, Math.floor(days / 365)))}y`;
|
|
35
|
+
};
|
|
36
|
+
const grid = (draw, texts) => COLUMNS.map(([, size], index) => draw.column(texts[index] ?? "", size)).join("");
|
|
37
|
+
const rowLine = (draw, now, row) => draw.line([
|
|
38
|
+
[
|
|
39
|
+
draw.column(`${" ".repeat(row.depth)}${row.name}`, draw.columns - GRID_WIDTH),
|
|
40
|
+
],
|
|
41
|
+
[row.code.padEnd(4), codeStyle(row.code)],
|
|
42
|
+
[`${row.marker ? "?" : " "} `],
|
|
43
|
+
[grid(draw, row.cells)],
|
|
44
|
+
[ageOf(row.at, now).padStart(AGE_COLUMNS)],
|
|
45
|
+
]);
|
|
46
|
+
const headerLine = (draw) => draw.line([
|
|
47
|
+
[draw.column("NAME", draw.columns - GRID_WIDTH)],
|
|
48
|
+
["STATE "],
|
|
49
|
+
[
|
|
50
|
+
grid(draw, COLUMNS.map(([label]) => label)),
|
|
51
|
+
],
|
|
52
|
+
["AGE".padStart(AGE_COLUMNS)],
|
|
53
|
+
]);
|
|
54
|
+
export const renderTree = (input, size, { color, width }) => {
|
|
55
|
+
const draw = makeDraw({ color, columns: size.columns, width });
|
|
56
|
+
const small = tooSmall(size);
|
|
57
|
+
if (small !== undefined)
|
|
58
|
+
return [draw.line([[small]])];
|
|
59
|
+
const rows = treeRows(input);
|
|
60
|
+
const room = size.rows - BAND_ROWS;
|
|
61
|
+
const shown = rows.slice(0, rows.length > room ? room - 1 : room);
|
|
62
|
+
const empty = input.state.partial
|
|
63
|
+
? "No Workspace read yet."
|
|
64
|
+
: "No Workspace yet. Add one: maia container create --input-stdin --dry-run";
|
|
65
|
+
return [
|
|
66
|
+
draw.line(statusBar(input, rows, draw)),
|
|
67
|
+
headerLine(draw),
|
|
68
|
+
...(rows.length === 0
|
|
69
|
+
? [draw.line([[empty]])]
|
|
70
|
+
: shown.map((row) => rowLine(draw, input.now, row))),
|
|
71
|
+
...(shown.length < rows.length
|
|
72
|
+
? [draw.line([[`... ${String(rows.length - shown.length)} more rows`]])]
|
|
73
|
+
: []),
|
|
74
|
+
];
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type NodeHolding, type PagedNode, type RouteKind } from "@maiaos/client-core/cockpit";
|
|
2
|
+
import { type ProtocolError } from "@maiaos/sdk";
|
|
3
|
+
import type * as Crypto from "effect/Crypto";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Result from "effect/Result";
|
|
6
|
+
import type { CliNodeEffect, CliNodeResult } from "../local-node/index.js";
|
|
7
|
+
export type FleetNode<TReach> = {
|
|
8
|
+
readonly node: string;
|
|
9
|
+
readonly reach: TReach;
|
|
10
|
+
};
|
|
11
|
+
export type NodeAnswer<TValue> = {
|
|
12
|
+
readonly node: string;
|
|
13
|
+
readonly result: CliNodeResult<TValue>;
|
|
14
|
+
};
|
|
15
|
+
export type ListedNode = PagedNode<ProtocolError>;
|
|
16
|
+
export type HeldId = {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly kind: RouteKind;
|
|
19
|
+
};
|
|
20
|
+
export type NoHolder = {
|
|
21
|
+
readonly error: ProtocolError;
|
|
22
|
+
readonly holdings: readonly NodeHolding[];
|
|
23
|
+
};
|
|
24
|
+
export declare const refused: (code: string, message: string, retryable?: boolean) => {
|
|
25
|
+
error: {
|
|
26
|
+
code: string;
|
|
27
|
+
message: string;
|
|
28
|
+
retryable: boolean;
|
|
29
|
+
};
|
|
30
|
+
ok: false;
|
|
31
|
+
};
|
|
32
|
+
export type Fleet<TReach> = {
|
|
33
|
+
readonly bind?: (name: string) => TReach;
|
|
34
|
+
readonly chosen: boolean;
|
|
35
|
+
readonly listRemoteNodes?: (input: Record<string, never>) => CliNodeEffect<{
|
|
36
|
+
readonly nodes: readonly {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
}[];
|
|
39
|
+
}>;
|
|
40
|
+
readonly local: FleetNode<TReach>;
|
|
41
|
+
};
|
|
42
|
+
export declare const fleetNodes: <TReach>({ bind, chosen, listRemoteNodes, local, }: Fleet<TReach>) => CliNodeEffect<readonly FleetNode<TReach>[]>;
|
|
43
|
+
export declare const askEach: <TReach, TValue>(nodes: readonly FleetNode<TReach>[], ask: (reach: TReach) => CliNodeEffect<TValue>) => Effect.Effect<NodeAnswer<TValue>[], never, Crypto.Crypto>;
|
|
44
|
+
export declare const routes: ({ id, kind }: HeldId) => boolean;
|
|
45
|
+
export type HolderSearch<TReach> = {
|
|
46
|
+
readonly choose: string;
|
|
47
|
+
readonly probe: (reach: TReach) => CliNodeEffect<unknown>;
|
|
48
|
+
};
|
|
49
|
+
export declare const holderIn: <TReach>(nodes: readonly FleetNode<TReach>[], { id, kind }: HeldId, { choose, probe }: HolderSearch<TReach>) => Effect.Effect<Result.Result<FleetNode<TReach>, NoHolder>, never, Crypto.Crypto>;
|
|
50
|
+
export declare const mergeLists: <TItem extends object>(answers: readonly NodeAnswer<{
|
|
51
|
+
readonly items: readonly TItem[];
|
|
52
|
+
readonly nextCursor?: string;
|
|
53
|
+
}>[]) => {
|
|
54
|
+
items: (TItem & {
|
|
55
|
+
node: string;
|
|
56
|
+
})[];
|
|
57
|
+
nodes: PagedNode<{
|
|
58
|
+
readonly code: string;
|
|
59
|
+
readonly message: string;
|
|
60
|
+
readonly retryable: boolean;
|
|
61
|
+
readonly saturation?: "account" | "admission" | undefined;
|
|
62
|
+
}>[];
|
|
63
|
+
};
|
|
64
|
+
export declare const failureOf: (nodes: readonly ListedNode[]) => {
|
|
65
|
+
readonly code: string;
|
|
66
|
+
readonly message: string;
|
|
67
|
+
readonly retryable: boolean;
|
|
68
|
+
readonly saturation?: "account" | "admission" | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
//# sourceMappingURL=fleet.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { combinePages, holderAmong, } from "@maiaos/client-core/cockpit";
|
|
2
|
+
import { receiptGetParametersSchema } from "@maiaos/sdk";
|
|
3
|
+
import * as Config from "effect/Config";
|
|
4
|
+
import * as Duration from "effect/Duration";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Result from "effect/Result";
|
|
8
|
+
import { cell, LOCAL_NODE } from "../command-line/index.js";
|
|
9
|
+
import { isExactId } from "../reference/index.js";
|
|
10
|
+
const ASK_DEADLINE = Duration.seconds(12);
|
|
11
|
+
const ASK_CONCURRENCY = 4;
|
|
12
|
+
export const refused = (code, message, retryable = false) => ({
|
|
13
|
+
error: { code, message, retryable },
|
|
14
|
+
ok: false,
|
|
15
|
+
});
|
|
16
|
+
const actsAsSession = Effect.map(Effect.orElseSucceed(Config.option(Config.String("MAIA_SESSION_CREDENTIAL")), Option.none), Option.isSome);
|
|
17
|
+
const NO_REGISTRY = new Set([
|
|
18
|
+
"command_not_implemented",
|
|
19
|
+
"unsupported_method",
|
|
20
|
+
]);
|
|
21
|
+
const withRemotes = (local, names, bind) => names.includes(LOCAL_NODE)
|
|
22
|
+
? refused("invalid_argument", "A remote Node is registered as 'local', the name of this machine's Node: remove it with 'maia node remove local' and install it under another name.")
|
|
23
|
+
: {
|
|
24
|
+
ok: true,
|
|
25
|
+
value: [local, ...names.map((node) => ({ node, reach: bind(node) }))],
|
|
26
|
+
};
|
|
27
|
+
export const fleetNodes = ({ bind, chosen, listRemoteNodes, local, }) => Effect.gen(function* () {
|
|
28
|
+
if (chosen ||
|
|
29
|
+
bind === undefined ||
|
|
30
|
+
listRemoteNodes === undefined ||
|
|
31
|
+
(yield* actsAsSession))
|
|
32
|
+
return { ok: true, value: [local] };
|
|
33
|
+
const listed = yield* listRemoteNodes({});
|
|
34
|
+
if (listed.ok)
|
|
35
|
+
return withRemotes(local, listed.value.nodes.map(({ name }) => name), bind);
|
|
36
|
+
return NO_REGISTRY.has(listed.error.code)
|
|
37
|
+
? { ok: true, value: [local] }
|
|
38
|
+
: listed;
|
|
39
|
+
});
|
|
40
|
+
export const askEach = (nodes, ask) => Effect.forEach(nodes, ({ node, reach }) => ask(reach).pipe(nodes.length === 1
|
|
41
|
+
? (asked) => asked
|
|
42
|
+
: Effect.timeoutOrElse({
|
|
43
|
+
duration: ASK_DEADLINE,
|
|
44
|
+
orElse: () => Effect.succeed(refused("node_unavailable", `Node ${node} did not answer within ${Duration.format(ASK_DEADLINE)}.`, true)),
|
|
45
|
+
}), Effect.map((result) => ({ node, result }))), { concurrency: ASK_CONCURRENCY });
|
|
46
|
+
export const routes = ({ id, kind }) => kind === "command"
|
|
47
|
+
? receiptGetParametersSchema.safeParse({ commandId: id }).success
|
|
48
|
+
: isExactId(kind, id);
|
|
49
|
+
const holdingOf = ({ node, result }) => {
|
|
50
|
+
if (result.ok)
|
|
51
|
+
return { node, state: "holds" };
|
|
52
|
+
return {
|
|
53
|
+
node,
|
|
54
|
+
state: result.error.code === "resource_not_found" ? "absent" : "unavailable",
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const refusalOf = ({ id, nodes = [], reason }, answers, choose) => {
|
|
58
|
+
switch (reason) {
|
|
59
|
+
case "ambiguous":
|
|
60
|
+
return refused("node_ambiguous", `${id} is on ${String(nodes.length)} Nodes: ${nodes.join(", ")}. ${choose.charAt(0).toUpperCase()}${choose.slice(1)} to choose one.`).error;
|
|
61
|
+
case "unavailable": {
|
|
62
|
+
const why = answers.flatMap(({ node, result }) => nodes.includes(node) && !result.ok
|
|
63
|
+
? [`${node} (${cell(result.error.message)})`]
|
|
64
|
+
: []);
|
|
65
|
+
return refused("node_unavailable", `${id} could be on a Node that did not answer: ${why.join(", ")}. Retry, or ${choose}.`, true).error;
|
|
66
|
+
}
|
|
67
|
+
case "unknown":
|
|
68
|
+
return refused("resource_not_found", `No Node holds ${id}.`).error;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export const holderIn = (nodes, { id, kind }, { choose, probe }) => Effect.map(askEach(nodes, probe), (answers) => {
|
|
72
|
+
const holdings = answers.map(holdingOf);
|
|
73
|
+
const holder = holderAmong(kind, id, holdings);
|
|
74
|
+
const found = Result.isSuccess(holder)
|
|
75
|
+
? nodes.find(({ node }) => node === holder.success)
|
|
76
|
+
: undefined;
|
|
77
|
+
if (found !== undefined)
|
|
78
|
+
return Result.succeed(found);
|
|
79
|
+
const error = Result.isFailure(holder)
|
|
80
|
+
? refusalOf(holder.failure, answers, choose)
|
|
81
|
+
: refused("resource_not_found", `No Node holds ${id}.`).error;
|
|
82
|
+
return Result.fail({ error, holdings });
|
|
83
|
+
});
|
|
84
|
+
export const mergeLists = (answers) => combinePages(answers.map(({ node, result }) => ({
|
|
85
|
+
node,
|
|
86
|
+
page: result.ok
|
|
87
|
+
? Result.succeed(result.value)
|
|
88
|
+
: Result.fail(result.error),
|
|
89
|
+
})));
|
|
90
|
+
export const failureOf = (nodes) => nodes.find(({ error }) => error !== undefined)?.error;
|
|
91
|
+
//# sourceMappingURL=fleet.js.map
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { formatRows } from "../../command-line/index.js";
|
|
1
|
+
import { cell, formatRows } from "../../command-line/index.js";
|
|
2
2
|
export const isHoldResult = (result) => result.command.startsWith("hold.");
|
|
3
|
-
const cell = (value) => Array.from(value, (character) => {
|
|
4
|
-
const point = character.codePointAt(0) ?? 0;
|
|
5
|
-
return point < 32 || (point >= 127 && point <= 159) ? " " : character;
|
|
6
|
-
}).join("");
|
|
7
3
|
const targetList = (targets) => targets.map((target) => `${target.kind}:${target.id}`).join(",");
|
|
8
4
|
export const formatHoldResult = ({ result }) => {
|
|
9
5
|
switch (result.method) {
|
package/dist/hold/tree/tree.js
CHANGED
package/dist/import/commands.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { CliArgumentError, parseOptions, readTwoPhaseMode, reportError, requirePositionals, runTwoPhase, TWO_PHASE_FLAGS, } from "../command-line/index.js";
|
|
2
|
+
import { CliArgumentError, parseOptions, readTwoPhaseMode, reportError, requirePositionals, runTwoPhase, TWO_PHASE_FLAGS, writeSuccess, } from "../command-line/index.js";
|
|
3
3
|
import { readAdopt, readHistory, readScan } from "./input.js";
|
|
4
4
|
import { formatAdoptConfirm, formatAdoptPreview, formatHistory, formatScan, } from "./output.js";
|
|
5
5
|
const missingClient = () => Effect.fail(new CliArgumentError("Session discovery is unavailable."));
|
|
6
6
|
const write = (response, context, output) => {
|
|
7
7
|
if (!response.ok)
|
|
8
8
|
return reportError(response.error, context);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
: output.format(response.value));
|
|
9
|
+
const { value } = response;
|
|
10
|
+
writeSuccess({ command: output.command, result: value }, context, () => output.format(value));
|
|
12
11
|
return 0;
|
|
13
12
|
};
|
|
14
13
|
const required = (context, name) => {
|
package/dist/import/output.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const point = character.codePointAt(0) ?? 0;
|
|
3
|
-
return point < 32 || (point >= 127 && point <= 159) ? " " : character;
|
|
4
|
-
}).join("");
|
|
1
|
+
import { cell } from "../command-line/index.js";
|
|
5
2
|
const line = (...cells) => `${cells.map(cell).join("\t")}\n`;
|
|
6
3
|
const nativeName = (session) => `${session.executor === "claude-code" ? "claude" : "codex"}:${session.nativeId}`;
|
|
7
4
|
const groupLine = (group) => line(group.kind, group.repository?.rootPath ?? group.cwd ?? "", `${String(group.sessionCount)} sessions`, group.registeredProjectId ?? "unregistered");
|