@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.4
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 +76 -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/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 +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 +10 -8
|
@@ -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");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LocalNodeRequestOptions, LocalNodeStatusResult, ProtocolError } from "@maiaos/sdk";
|
|
2
|
-
import type { DiscoveredNodeApiEffectConnection, LocalNodeEffectClient, NodeApiEffectDiscoveryOptions } from "@maiaos/sdk/node/effect";
|
|
2
|
+
import type { DiscoveredNodeApiEffectConnection, LocalNodeEffectClient, NodeApiEffectDiscoveryOptions, NodeBridge } from "@maiaos/sdk/node/effect";
|
|
3
3
|
import * as Crypto from "effect/Crypto";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as Schedule from "effect/Schedule";
|
|
6
5
|
export type CliMutationRecovery = {
|
|
7
6
|
readonly commandId: string;
|
|
7
|
+
readonly profile?: string;
|
|
8
8
|
};
|
|
9
9
|
export type CliNodeResult<TValue> = {
|
|
10
10
|
readonly error: ProtocolError;
|
|
@@ -14,7 +14,9 @@ export type CliNodeResult<TValue> = {
|
|
|
14
14
|
readonly ok: true;
|
|
15
15
|
readonly value: TValue;
|
|
16
16
|
};
|
|
17
|
-
export type CliNodeConnection = Pick<DiscoveredNodeApiEffectConnection, "client" | "status"
|
|
17
|
+
export type CliNodeConnection = Pick<DiscoveredNodeApiEffectConnection, "client" | "status"> & {
|
|
18
|
+
readonly attachSession?: NodeBridge["attachSession"];
|
|
19
|
+
};
|
|
18
20
|
export type CliNodeConnector = (options: NodeApiEffectDiscoveryOptions) => Effect.Effect<CliNodeConnection, unknown, Crypto.Crypto>;
|
|
19
21
|
export declare const newCliIdentifier: (prefix: "command" | "request") => Effect.Effect<string, never, Crypto.Crypto>;
|
|
20
22
|
export declare const commandIdentifier: (commandId: string | undefined) => Effect.Effect<string, never, Crypto.Crypto>;
|
|
@@ -36,6 +38,8 @@ export type CliNodeOperations = {
|
|
|
36
38
|
readonly asCoordinator: () => CliNodeOperations;
|
|
37
39
|
readonly asSession: () => CliNodeOperations;
|
|
38
40
|
readonly readStatus: Effect.Effect<LocalNodeStatusResult, unknown, Crypto.Crypto>;
|
|
41
|
+
readonly remote: boolean;
|
|
42
|
+
readonly runConnectionOperation: <TValue>(operation: (connection: CliNodeConnection) => Effect.Effect<TValue, unknown, Crypto.Crypto>) => CliNodeEffect<TValue>;
|
|
39
43
|
readonly runDiscoveryOperation: <TValue>(operation: (options: NodeApiEffectDiscoveryOptions) => Effect.Effect<TValue, unknown, Crypto.Crypto>, recovery?: CliMutationRecovery) => CliNodeEffect<TValue>;
|
|
40
44
|
readonly runNodeClientOperation: <TValue>(operation: (client: LocalNodeEffectClient, options: LocalNodeRequestOptions) => Effect.Effect<TValue, unknown>, recovery?: CliMutationRecovery) => CliNodeEffect<TValue>;
|
|
41
45
|
readonly runValidatedNodeOperation: <TParameters, TValue>(input: unknown, schema: ParameterSchema<TParameters>, operation: (client: LocalNodeEffectClient, parameters: TParameters, options: LocalNodeRequestOptions) => Effect.Effect<TValue, unknown>, recovery?: CliMutationRecovery) => CliNodeEffect<TValue>;
|
|
@@ -59,7 +63,7 @@ type LazyNodeDependencyInput<TModule, TClient> = {
|
|
|
59
63
|
readonly name: keyof TClient;
|
|
60
64
|
};
|
|
61
65
|
export declare const isBriefSaturation: (error: unknown) => boolean;
|
|
62
|
-
export declare const
|
|
66
|
+
export declare const retryBriefSaturation: <TValue, TError, TServices>(attempt: Effect.Effect<TValue, TError, TServices>, deadlineAt?: bigint) => Effect.Effect<TValue, TError, TServices>;
|
|
63
67
|
export declare const makeCliNodeOperations: (options?: CliNodeOperationsOptions) => CliNodeOperations;
|
|
64
68
|
export declare const discoveryOptionsFor: (profile: string | undefined) => Effect.Effect<NodeApiEffectDiscoveryOptions, unknown>;
|
|
65
69
|
export declare const runLazyNodeDependency: <TModule, TClient>(input: LazyNodeDependencyInput<TModule, TClient>) => Effect.Effect<unknown, unknown, Crypto.Crypto>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { protocolErrorSchema } from "@maiaos/sdk";
|
|
2
2
|
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Clock from "effect/Clock";
|
|
3
4
|
import * as Config from "effect/Config";
|
|
4
5
|
import * as Crypto from "effect/Crypto";
|
|
5
6
|
import * as Data from "effect/Data";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
6
8
|
import * as Effect from "effect/Effect";
|
|
7
9
|
import * as Option from "effect/Option";
|
|
8
10
|
import * as Predicate from "effect/Predicate";
|
|
@@ -181,15 +183,21 @@ export const isBriefSaturation = (error) => {
|
|
|
181
183
|
return (parsed.data.code === "saturated" && parsed.data.saturation === "admission");
|
|
182
184
|
return maiaClientErrorCode(error) === "saturated";
|
|
183
185
|
};
|
|
184
|
-
|
|
186
|
+
const SATURATION_RETRY = Schedule.exponential("100 millis").pipe(Schedule.jittered);
|
|
185
187
|
const SATURATION_RETRIES = 4;
|
|
188
|
+
const DEADLINE_MARGIN_NANOS = 500000000n;
|
|
189
|
+
const endingBefore = (deadlineAt) => Schedule.fromStep(Effect.map(Schedule.toStep(SATURATION_RETRY), (step) => (now, input) => Effect.flatMap(step(now, input), ([output, backoff]) => Effect.flatMap(Clock.monotonicTimeNanos, (current) => current + Duration.toNanosUnsafe(backoff) + DEADLINE_MARGIN_NANOS >=
|
|
190
|
+
deadlineAt
|
|
191
|
+
? Cause.done(output)
|
|
192
|
+
: Effect.succeed([output, backoff])))));
|
|
193
|
+
export const retryBriefSaturation = (attempt, deadlineAt) => Effect.retry(attempt, {
|
|
194
|
+
schedule: deadlineAt === undefined ? SATURATION_RETRY : endingBefore(deadlineAt),
|
|
195
|
+
times: SATURATION_RETRIES,
|
|
196
|
+
while: isBriefSaturation,
|
|
197
|
+
});
|
|
186
198
|
const nodeClientOperation = (connect) => (operation, recovery) => completeOperation(Effect.gen(function* () {
|
|
187
199
|
const connection = yield* connect;
|
|
188
|
-
return yield* newCliIdentifier("request").pipe(Effect.flatMap((messageId) => operation(connection.client, { messageId }))
|
|
189
|
-
schedule: SATURATION_RETRY,
|
|
190
|
-
times: SATURATION_RETRIES,
|
|
191
|
-
while: isBriefSaturation,
|
|
192
|
-
}));
|
|
200
|
+
return yield* retryBriefSaturation(newCliIdentifier("request").pipe(Effect.flatMap((messageId) => operation(connection.client, { messageId }))));
|
|
193
201
|
}), recovery);
|
|
194
202
|
const validatedNodeOperation = (runNodeClientOperation) => (input, schema, operation, recovery) => {
|
|
195
203
|
const parameters = schema.safeParse(input);
|
|
@@ -208,6 +216,9 @@ const coordinatorOptions = (options) => ({
|
|
|
208
216
|
const boundSession = (options) => options.remote === true
|
|
209
217
|
? () => Effect.fail(sessionRemoteDenied())
|
|
210
218
|
: connectSession;
|
|
219
|
+
const discoveryOperation = (options, discoveryOptions, operation) => options.remote === true
|
|
220
|
+
? Effect.fail(remoteDiscoveryDenied())
|
|
221
|
+
: asSessionOr(Effect.flatMap(discoveryOptions, operation), () => Effect.fail(sessionAttachmentDenied()));
|
|
211
222
|
export const makeCliNodeOperations = (options = {}) => {
|
|
212
223
|
const discoveryOptions = discoveryOptionsOf(options.discoveryOptions);
|
|
213
224
|
const connector = options.connector ?? connectLocalNode;
|
|
@@ -217,9 +228,9 @@ export const makeCliNodeOperations = (options = {}) => {
|
|
|
217
228
|
asCoordinator: () => makeCliNodeOperations(coordinatorOptions(options)),
|
|
218
229
|
asSession: () => makeCliNodeOperations({ ...options, requireSession: true }),
|
|
219
230
|
readStatus: Effect.map(connect, (connection) => connection.status),
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
231
|
+
remote: options.remote === true,
|
|
232
|
+
runConnectionOperation: (operation) => completeOperation(Effect.flatMap(connect, operation)),
|
|
233
|
+
runDiscoveryOperation: (operation, recovery) => completeOperation(discoveryOperation(options, discoveryOptions, operation), recovery),
|
|
223
234
|
runNodeClientOperation,
|
|
224
235
|
runValidatedNodeOperation: validatedNodeOperation(runNodeClientOperation),
|
|
225
236
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { type CliNodeCall, makeCallClient } from "./call.js";
|
|
2
|
-
export { type CliMutationRecovery, type CliNodeBinding, type CliNodeConnection, type CliNodeConnector, type CliNodeEffect, type CliNodeOperations, type CliNodeOperationsOptions, type CliNodeResult, commandIdentifier, connectLocalNode, discoveryOptionsFor, fillCommandIdentifier, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, outcomeCanBeAmbiguous, type ParameterSchema, runLazyNodeDependency, } from "./client.js";
|
|
2
|
+
export { type CliMutationRecovery, type CliNodeBinding, type CliNodeConnection, type CliNodeConnector, type CliNodeEffect, type CliNodeOperations, type CliNodeOperationsOptions, type CliNodeResult, commandIdentifier, connectLocalNode, discoveryOptionsFor, fillCommandIdentifier, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, outcomeCanBeAmbiguous, type ParameterSchema, retryBriefSaturation, runLazyNodeDependency, } from "./client.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/local-node/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { makeCallClient } from "./call.js";
|
|
2
|
-
export { commandIdentifier, connectLocalNode, discoveryOptionsFor, fillCommandIdentifier, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, outcomeCanBeAmbiguous, runLazyNodeDependency, } from "./client.js";
|
|
2
|
+
export { commandIdentifier, connectLocalNode, discoveryOptionsFor, fillCommandIdentifier, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, outcomeCanBeAmbiguous, retryBriefSaturation, runLazyNodeDependency, } from "./client.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/login/commands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { CliArgumentError, parseOptions, reportError, requirePositionals, unknownCommand, writeSuccess, } from "../command-line/index.js";
|
|
2
|
+
import { CliArgumentError, LOCAL_NODE, parseOptions, reportError, requirePositionals, unknownCommand, writeSuccess, } from "../command-line/index.js";
|
|
3
3
|
import { callNode, ConnectionNodeError, redactConnection, } from "../connection/index.js";
|
|
4
4
|
import { listAgentProviders, signInAgentProvider } from "./agent-provider.js";
|
|
5
5
|
import { loginFailureMessage } from "./failure.js";
|
|
@@ -57,6 +57,7 @@ const providerLogin = (tokens, context) => parsed(() => readProviderLogin(tokens
|
|
|
57
57
|
}));
|
|
58
58
|
const loginTarget = (tokens) => parseOptions(tokens, new Set(["--base-url", "--command-id", "--max-sessions", "--name"]), new Set(["--api-key-stdin", "--device-code"])).positionals[0];
|
|
59
59
|
const remoteLoginRefusal = (target, context) => context.node === undefined ||
|
|
60
|
+
context.node === LOCAL_NODE ||
|
|
60
61
|
target === "claude" ||
|
|
61
62
|
target === "codex" ||
|
|
62
63
|
target === "gateway"
|
package/dist/mcp/calls.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ import { type LocalNodeRequestMethod } from "@maiaos/sdk";
|
|
|
3
3
|
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
4
4
|
export type CoordinatorCall = (node: CliNodeOperations, input: unknown) => CliNodeEffect<unknown>;
|
|
5
5
|
export declare const COORDINATOR_CALLS: ReadonlyMap<CoordinatorToolOperation, CoordinatorCall>;
|
|
6
|
+
export declare const callCoordinator: (node: CliNodeOperations) => (operation: CoordinatorToolOperation, input: unknown) => CliNodeEffect<unknown>;
|
|
6
7
|
export declare const WORKER_CALLS: ReadonlyMap<LocalNodeRequestMethod, CoordinatorCall>;
|
|
7
8
|
//# sourceMappingURL=calls.d.ts.map
|
package/dist/mcp/calls.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { approvalListParametersSchema, approvalShowParametersSchema, connectionDetectParametersSchema, connectionListParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionUsageShowParametersSchema, containerIndexListParametersSchema, COORDINATOR_TOOL_OPERATIONS, discoverySessionsListParametersSchema, invocationContextShowParametersSchema, LOCAL_NODE_CALL_METHODS, localNodeRequestPayloadSchema, portLeaseAcquireParametersSchema, portLeaseListParametersSchema, portLeaseReleaseParametersSchema, portLeaseRenewParametersSchema, projectGuardShowParametersSchema, projectListParametersSchema, projectShowParametersSchema, receiptGetParametersSchema, runLedgerCreateParametersSchema, runLedgerListParametersSchema, runLedgerTaskDispatchParametersSchema, runLedgerTaskListParametersSchema, runLedgerTaskSettleParametersSchema, runLedgerTaskShowParametersSchema, sessionArchiveParametersSchema, sessionCreateParametersSchema, sessionDiffParametersSchema, sessionEventsListParametersSchema, sessionHistoryReadParametersSchema, sessionListParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, turnInterruptParametersSchema, turnSendParametersSchema, turnShowParametersSchema, turnWaitParametersSchema, workerToolDefinitions, workspaceListParametersSchema, workspaceShowParametersSchema, } from "@maiaos/sdk";
|
|
2
|
-
import { Predicate } from "effect";
|
|
1
|
+
import { agentsListParametersSchema, agentsShowParametersSchema, approvalListParametersSchema, approvalShowParametersSchema, connectionDetectParametersSchema, connectionListParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionUsageShowParametersSchema, containerIndexListParametersSchema, COORDINATOR_TOOL_OPERATIONS, discoverySessionsListParametersSchema, invocationContextShowParametersSchema, LOCAL_NODE_CALL_METHODS, localNodeRequestPayloadSchema, portLeaseAcquireParametersSchema, portLeaseListParametersSchema, portLeaseReleaseParametersSchema, portLeaseRenewParametersSchema, projectGuardShowParametersSchema, projectListParametersSchema, projectShowParametersSchema, receiptGetParametersSchema, routineListParametersSchema, routineShowParametersSchema, runLedgerCreateParametersSchema, runLedgerListParametersSchema, runLedgerTaskDispatchParametersSchema, runLedgerTaskListParametersSchema, runLedgerTaskSettleParametersSchema, runLedgerTaskShowParametersSchema, sessionArchiveParametersSchema, sessionCreateParametersSchema, sessionDiffParametersSchema, sessionEventsListParametersSchema, sessionHistoryReadParametersSchema, sessionInboxAckParametersSchema, sessionInboxCheckParametersSchema, sessionListParametersSchema, sessionMessageSendParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, turnCancelParametersSchema, turnInterruptParametersSchema, turnQueueListParametersSchema, turnSendParametersSchema, turnShowParametersSchema, turnWaitParametersSchema, workerToolDefinitions, workspaceListParametersSchema, workspaceShowParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import { Effect, Predicate } from "effect";
|
|
3
3
|
import { invalidNodeInput, } from "../local-node/index.js";
|
|
4
4
|
const recoveryOf = (input) => Predicate.hasProperty(input, "commandId") &&
|
|
5
5
|
Predicate.isString(input.commandId)
|
|
@@ -27,6 +27,14 @@ const typedCall = (method) => (node, input) => {
|
|
|
27
27
|
};
|
|
28
28
|
export const COORDINATOR_CALLS = new Map([
|
|
29
29
|
...COORDINATOR_TOOL_OPERATIONS.filter(isCallBound).map((operation) => [operation, typedCall(operation)]),
|
|
30
|
+
[
|
|
31
|
+
"agents.list",
|
|
32
|
+
validated(agentsListParametersSchema, (client, parameters, options) => client.listAgents(parameters, options)),
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"agents.show",
|
|
36
|
+
validated(agentsShowParametersSchema, (client, parameters, options) => client.showAgent(parameters, options)),
|
|
37
|
+
],
|
|
30
38
|
[
|
|
31
39
|
"approval.list",
|
|
32
40
|
validated(approvalListParametersSchema, (client, parameters, options) => client.listApprovals(parameters, options)),
|
|
@@ -96,6 +104,14 @@ export const COORDINATOR_CALLS = new Map([
|
|
|
96
104
|
"receipt.get",
|
|
97
105
|
validated(receiptGetParametersSchema, (client, parameters, options) => client.getReceipt(parameters, options)),
|
|
98
106
|
],
|
|
107
|
+
[
|
|
108
|
+
"routine.list",
|
|
109
|
+
validated(routineListParametersSchema, (client, parameters, options) => client.listRoutines(parameters, options)),
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"routine.show",
|
|
113
|
+
validated(routineShowParametersSchema, (client, parameters, options) => client.showRoutine(parameters, options)),
|
|
114
|
+
],
|
|
99
115
|
[
|
|
100
116
|
"run.ledger.create",
|
|
101
117
|
validated(runLedgerCreateParametersSchema, (client, parameters, options) => client.createRunLedger(parameters, options)),
|
|
@@ -164,10 +180,18 @@ export const COORDINATOR_CALLS = new Map([
|
|
|
164
180
|
"session.stop",
|
|
165
181
|
validated(sessionStopParametersSchema, (client, parameters, options) => client.stopSession(parameters, options)),
|
|
166
182
|
],
|
|
183
|
+
[
|
|
184
|
+
"turn.cancel",
|
|
185
|
+
validated(turnCancelParametersSchema, (client, parameters, options) => client.cancelTurn(parameters, options)),
|
|
186
|
+
],
|
|
167
187
|
[
|
|
168
188
|
"turn.interrupt",
|
|
169
189
|
validated(turnInterruptParametersSchema, (client, parameters, options) => client.interruptTurn(parameters, options)),
|
|
170
190
|
],
|
|
191
|
+
[
|
|
192
|
+
"turn.queue.list",
|
|
193
|
+
validated(turnQueueListParametersSchema, (client, parameters, options) => client.listTurnQueue(parameters, options)),
|
|
194
|
+
],
|
|
171
195
|
[
|
|
172
196
|
"turn.send",
|
|
173
197
|
validated(turnSendParametersSchema, (client, parameters, options) => client.sendTurn(parameters, options)),
|
|
@@ -189,10 +213,19 @@ export const COORDINATOR_CALLS = new Map([
|
|
|
189
213
|
validated(workspaceShowParametersSchema, (client, parameters, options) => client.showWorkspace(parameters, options)),
|
|
190
214
|
],
|
|
191
215
|
]);
|
|
216
|
+
export const callCoordinator = (node) => (operation, input) => {
|
|
217
|
+
const call = COORDINATOR_CALLS.get(operation);
|
|
218
|
+
return call === undefined
|
|
219
|
+
? Effect.die(new Error(`No SDK call for ${operation}.`))
|
|
220
|
+
: call(node, input);
|
|
221
|
+
};
|
|
192
222
|
export const WORKER_CALLS = (() => {
|
|
193
223
|
const available = new Map(COORDINATOR_CALLS);
|
|
194
224
|
available.set("context.show", validated(invocationContextShowParametersSchema, (client, parameters, options) => client.showCurrentContext(parameters, options)));
|
|
195
|
-
|
|
225
|
+
available.set("session.inbox.ack", validated(sessionInboxAckParametersSchema, (client, parameters, options) => client.acknowledgeSessionDelivery(parameters, options)));
|
|
226
|
+
available.set("session.inbox.check", validated(sessionInboxCheckParametersSchema, (client, parameters, options) => client.checkSessionInbox(parameters, options)));
|
|
227
|
+
available.set("session.message.send", validated(sessionMessageSendParametersSchema, (client, parameters, options) => client.sendSessionMessage(parameters, options)));
|
|
228
|
+
return new Map(workerToolDefinitions("orchestrator").map(({ operation }) => {
|
|
196
229
|
const call = available.get(operation);
|
|
197
230
|
if (call === undefined)
|
|
198
231
|
throw new Error(`No worker SDK call for ${operation}.`);
|
package/dist/mcp/commands.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { CoordinatorToolOperation } from "@maiaos/sdk";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import { type CliServices, type CommandContext, type CommandEffect } from "../command-line/index.js";
|
|
3
|
-
import type { CliNodeOperations } from "../local-node/index.js";
|
|
4
|
+
import type { CliNodeEffect, CliNodeOperations } from "../local-node/index.js";
|
|
5
|
+
import type { ToolFleet } from "./server.js";
|
|
4
6
|
export type McpCliDependencies = {
|
|
5
|
-
readonly
|
|
7
|
+
readonly callCoordinatorTool: (operation: CoordinatorToolOperation, input: unknown) => CliNodeEffect<unknown>;
|
|
8
|
+
readonly serveMcp: (version: string, worker?: boolean, fleet?: ToolFleet) => Effect.Effect<number, unknown, CliServices>;
|
|
6
9
|
};
|
|
7
10
|
export declare const makeMcpClient: (node: CliNodeOperations) => McpCliDependencies;
|
|
8
11
|
export declare const runMcpCommand: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|