@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
package/dist/session/commands.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
1
|
+
import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { listEach, writeMerged } from "../address-space/index.js";
|
|
3
4
|
import { CliArgumentError, parseOptions, readCursor, readDuration, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
|
|
5
|
+
import { mergeLists } from "../fleet/index.js";
|
|
4
6
|
import { runSessionTasks, } from "./create-tasks.js";
|
|
5
|
-
import { writeSessionResult } from "./output/index.js";
|
|
7
|
+
import { formatMergedSessions, writeSessionResult } from "./output/index.js";
|
|
6
8
|
const SESSION_CREATE_OPTIONS = new Set([
|
|
9
|
+
"--agent",
|
|
7
10
|
"--base",
|
|
8
11
|
"--command-id",
|
|
9
12
|
"--connection",
|
|
13
|
+
"--effort",
|
|
10
14
|
"--executor",
|
|
11
15
|
"--model",
|
|
12
16
|
"--agent-definition",
|
|
@@ -69,6 +73,24 @@ const requireOneSelection = (input) => {
|
|
|
69
73
|
throw new CliArgumentError("Use one of '--connection', '--executor' or '--agent-definition'.");
|
|
70
74
|
if (input.model !== undefined && input.connectionId === undefined)
|
|
71
75
|
throw new CliArgumentError("Option '--model' needs '--connection' with a gateway connection.");
|
|
76
|
+
requireSupportedEffort(input);
|
|
77
|
+
};
|
|
78
|
+
const requireSupportedEffort = ({ connectionId, effort, executor, }) => {
|
|
79
|
+
if (effort === undefined)
|
|
80
|
+
return;
|
|
81
|
+
if (connectionId === undefined && executor === undefined)
|
|
82
|
+
throw new CliArgumentError("Option '--effort' needs '--connection' or '--executor'.");
|
|
83
|
+
const levels = executor === undefined ? [] : SESSION_EFFORT_LEVELS[executor];
|
|
84
|
+
if (executor !== undefined && !levels.includes(effort))
|
|
85
|
+
throw new CliArgumentError(`Executor ${executor} supports effort ${levels.join(", ")}.`);
|
|
86
|
+
};
|
|
87
|
+
const readEffort = (value) => {
|
|
88
|
+
if (value === undefined)
|
|
89
|
+
return;
|
|
90
|
+
const level = SESSION_EFFORT_LEVELS["codex-cli"].find((candidate) => candidate === value);
|
|
91
|
+
if (level !== undefined)
|
|
92
|
+
return level;
|
|
93
|
+
throw new CliArgumentError(`Option '--effort' must be ${SESSION_EFFORT_LEVELS["codex-cli"].slice(0, -1).join(", ")} or ${SESSION_EFFORT_LEVELS["codex-cli"].at(-1) ?? "ultra"}.`);
|
|
72
94
|
};
|
|
73
95
|
const readSessionRole = (value) => {
|
|
74
96
|
if (value === undefined)
|
|
@@ -77,15 +99,37 @@ const readSessionRole = (value) => {
|
|
|
77
99
|
return { role: value };
|
|
78
100
|
throw new CliArgumentError("Option '--role' must be worker or orchestrator.");
|
|
79
101
|
};
|
|
102
|
+
const AGENT_FIXED_OPTIONS = [
|
|
103
|
+
"--agent-definition",
|
|
104
|
+
"--agent-definition-digest",
|
|
105
|
+
"--agent-definition-version",
|
|
106
|
+
"--connection",
|
|
107
|
+
"--effort",
|
|
108
|
+
"--executor",
|
|
109
|
+
"--model",
|
|
110
|
+
];
|
|
111
|
+
const readAgentId = (options) => {
|
|
112
|
+
const agentId = options.get("--agent");
|
|
113
|
+
if (agentId === undefined)
|
|
114
|
+
return {};
|
|
115
|
+
const clash = AGENT_FIXED_OPTIONS.find((option) => options.has(option));
|
|
116
|
+
if (clash !== undefined)
|
|
117
|
+
throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
|
|
118
|
+
return { agentId };
|
|
119
|
+
};
|
|
80
120
|
const readSessionSelection = (options, workspaceId) => {
|
|
121
|
+
const agent = readAgentId(options);
|
|
81
122
|
const commandId = options.get("--command-id");
|
|
82
123
|
const connectionId = options.get("--connection");
|
|
83
124
|
const executor = readExecutorKind(options.get("--executor"));
|
|
125
|
+
const effort = readEffort(options.get("--effort"));
|
|
84
126
|
const model = options.get("--model");
|
|
85
127
|
const title = options.get("--title");
|
|
86
128
|
const selection = {
|
|
129
|
+
...agent,
|
|
87
130
|
...(commandId === undefined ? {} : { commandId }),
|
|
88
131
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
132
|
+
...(effort === undefined ? {} : { effort }),
|
|
89
133
|
...(executor === undefined ? {} : { executor }),
|
|
90
134
|
...(model === undefined ? {} : { model }),
|
|
91
135
|
...readSessionRole(options.get("--role")),
|
|
@@ -98,8 +142,10 @@ const readSessionSelection = (options, workspaceId) => {
|
|
|
98
142
|
const readBaseRef = (value, selection) => {
|
|
99
143
|
if (value === undefined)
|
|
100
144
|
return;
|
|
101
|
-
if (selection.
|
|
102
|
-
|
|
145
|
+
if (selection.agentId === undefined &&
|
|
146
|
+
selection.connectionId === undefined &&
|
|
147
|
+
selection.executor === undefined)
|
|
148
|
+
throw new CliArgumentError("Option '--base' needs '--agent', '--connection' or '--executor'.");
|
|
103
149
|
if (sessionBaseRefSchema.safeParse(value).success)
|
|
104
150
|
return value;
|
|
105
151
|
throw new CliArgumentError("Option '--base' must name a branch, tag or commit without ranges, revision suffixes or a leading dash.");
|
|
@@ -200,13 +246,34 @@ const readSessionList = (tokens) => {
|
|
|
200
246
|
...(states === undefined ? {} : { states }),
|
|
201
247
|
};
|
|
202
248
|
};
|
|
249
|
+
const writeSessionList = (result, context) => writeSessionResult(result, context, (value) => ({
|
|
250
|
+
command: "session.list",
|
|
251
|
+
result: value,
|
|
252
|
+
}));
|
|
203
253
|
export const runSessionList = (tokens, context) => Effect.gen(function* () {
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
254
|
+
const input = readSessionList(tokens);
|
|
255
|
+
if (input.projectId !== undefined)
|
|
256
|
+
return writeSessionList(yield* context.dependencies.listSessions(input), context);
|
|
257
|
+
return yield* listEach(context, {
|
|
258
|
+
merged: (answers) => writeMergedSessions(context, answers),
|
|
259
|
+
paged: input.afterCursor !== "0",
|
|
260
|
+
read: (dependencies) => dependencies.listSessions(input),
|
|
261
|
+
sole: (result) => writeSessionList(result, context),
|
|
262
|
+
});
|
|
209
263
|
});
|
|
264
|
+
const writeMergedSessions = (context, answers) => {
|
|
265
|
+
const { items, nodes } = mergeLists(answers);
|
|
266
|
+
const attention = answers.flatMap(({ node, result }) => result.ok
|
|
267
|
+
? (result.value.attention ?? []).map((item) => ({ ...item, node }))
|
|
268
|
+
: []);
|
|
269
|
+
const result = {
|
|
270
|
+
...(attention.length === 0 ? {} : { attention }),
|
|
271
|
+
items,
|
|
272
|
+
method: "session.list",
|
|
273
|
+
nodes,
|
|
274
|
+
};
|
|
275
|
+
return writeMerged(context, { command: "session.list", result }, formatMergedSessions);
|
|
276
|
+
};
|
|
210
277
|
export const runSessionShow = (tokens, context) => Effect.gen(function* () {
|
|
211
278
|
const parsed = parseOptions(tokens, new Set());
|
|
212
279
|
requirePositionals(parsed.positionals, 1);
|
|
@@ -21,19 +21,24 @@ const readText = (source, context) => {
|
|
|
21
21
|
const refusalMessage = (refusal) => refusal.reason === "too_long"
|
|
22
22
|
? `Task line ${String(refusal.line)} exceeds ${String(MAX_TURN_INPUT_BYTES)} bytes.`
|
|
23
23
|
: `A batch holds at most ${String(MAX_SESSION_CREATION_TASKS)} tasks; line ${String(refusal.line)} is beyond it.`;
|
|
24
|
+
const toTemplate = (selection) => {
|
|
25
|
+
const { agentId, baseRef, connectionId, effort, executor, model, role, title, } = selection;
|
|
26
|
+
return {
|
|
27
|
+
...(agentId === undefined ? {} : { agentId }),
|
|
28
|
+
...(connectionId === undefined ? {} : { connectionId }),
|
|
29
|
+
...(effort === undefined ? {} : { effort }),
|
|
30
|
+
...(executor === undefined ? {} : { executor }),
|
|
31
|
+
...(model === undefined ? {} : { model }),
|
|
32
|
+
...(role === undefined ? {} : { role }),
|
|
33
|
+
...(title === undefined ? {} : { title }),
|
|
34
|
+
...(baseRef === undefined ? {} : { worktree: { baseRef } }),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
24
37
|
const toInput = (request, text) => {
|
|
25
|
-
const {
|
|
26
|
-
const { projectId, source, workspaceId } = request;
|
|
38
|
+
const { projectId, selection, source, workspaceId } = request;
|
|
27
39
|
return {
|
|
28
40
|
...(projectId === undefined ? {} : { projectId }),
|
|
29
|
-
session:
|
|
30
|
-
...(connectionId === undefined ? {} : { connectionId }),
|
|
31
|
-
...(executor === undefined ? {} : { executor }),
|
|
32
|
-
...(model === undefined ? {} : { model }),
|
|
33
|
-
...(role === undefined ? {} : { role }),
|
|
34
|
-
...(title === undefined ? {} : { title }),
|
|
35
|
-
...(baseRef === undefined ? {} : { worktree: { baseRef } }),
|
|
36
|
-
},
|
|
41
|
+
session: toTemplate(selection),
|
|
37
42
|
split: source.kind === "file" ? "lines" : "whole",
|
|
38
43
|
text,
|
|
39
44
|
...(workspaceId === undefined ? {} : { workspaceId }),
|
|
@@ -79,13 +84,26 @@ const exitCode = (items) => {
|
|
|
79
84
|
? 0
|
|
80
85
|
: EXIT_REFUSED;
|
|
81
86
|
};
|
|
87
|
+
const batchError = (items) => {
|
|
88
|
+
const failed = items.find((item) => item.error !== undefined);
|
|
89
|
+
if (failed?.error === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
const { code, failure, kind, operationId, retryable } = failed.error;
|
|
92
|
+
return {
|
|
93
|
+
code: failure?.code ?? code ?? kind,
|
|
94
|
+
message: failure?.message ??
|
|
95
|
+
`Line ${String(failed.line)} stopped at ${operationId}: ${code ?? kind}.`,
|
|
96
|
+
retryable,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
82
99
|
const writeBatch = (plan, outcomes, context) => {
|
|
83
100
|
const items = outcomes.map((outcome) => reportItem(plan, outcome));
|
|
84
101
|
const code = exitCode(items);
|
|
102
|
+
const error = batchError(items);
|
|
85
103
|
writeSuccess({
|
|
86
104
|
command: "session.create.tasks",
|
|
87
105
|
result: { items, workspaceId: plan.workspaceId },
|
|
88
|
-
}, { ...context, ok: code === 0 }, ({ result }) => formatSessionTasks(result));
|
|
106
|
+
}, { ...context, ...(error === undefined ? {} : { error }), ok: code === 0 }, ({ result }) => formatSessionTasks(result));
|
|
89
107
|
return code;
|
|
90
108
|
};
|
|
91
109
|
export const runSessionTasks = (request, context) => Effect.gen(function* () {
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { runAgentPermissionSet } from "./agent-permission.js";
|
|
2
2
|
export { runSessionAttach } from "./attach.js";
|
|
3
|
-
export type
|
|
3
|
+
export { type AttachSessionInput, makeAttachClient, type SessionAttachStream, } from "./attach-client.js";
|
|
4
4
|
export { type CreateSessionInput, type ListSessionsInput, makeSessionClient, type StartSessionInput, } from "./client.js";
|
|
5
5
|
export { type ArchiveSessionInput, type DiffSessionInput, } from "./coding-client.js";
|
|
6
6
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
package/dist/session/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { runAgentPermissionSet } from "./agent-permission.js";
|
|
2
2
|
export { runSessionAttach } from "./attach.js";
|
|
3
|
+
export { makeAttachClient, } from "./attach-client.js";
|
|
3
4
|
export { makeSessionClient, } from "./client.js";
|
|
4
5
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
|
5
6
|
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsonLine } from "../../../command-line/index.js";
|
|
1
2
|
export const isInteractionResult = (result) => result.command.startsWith("interaction.");
|
|
2
|
-
export const formatInteractionResult = ({ result, }) => `Recorded only; does not authorize any operation.\n${
|
|
3
|
+
export const formatInteractionResult = ({ result, }) => `Recorded only; does not authorize any operation.\n${jsonLine(result)}`;
|
|
3
4
|
//# sourceMappingURL=format.js.map
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const point = character.codePointAt(0) ?? 0;
|
|
3
|
-
return ((point <= 31 && point !== 9 && point !== 10) ||
|
|
4
|
-
(point >= 127 && point <= 159) ||
|
|
5
|
-
point === 8232 ||
|
|
6
|
-
point === 8233);
|
|
7
|
-
};
|
|
8
|
-
const safeText = (value) => Array.from(value, (character) => isUnsafeControl(character) ? "�" : character).join("");
|
|
1
|
+
import { block, cell } from "../../command-line/index.js";
|
|
9
2
|
const counts = (file) => file.insertions === undefined || file.deletions === undefined
|
|
10
3
|
? "binary"
|
|
11
4
|
: `+${String(file.insertions)}\t-${String(file.deletions)}`;
|
|
12
5
|
const fileLine = (file) => [
|
|
13
6
|
file.status,
|
|
14
7
|
counts(file),
|
|
15
|
-
|
|
8
|
+
cell(file.previousPath === undefined
|
|
16
9
|
? file.path
|
|
17
10
|
: `${file.previousPath} -> ${file.path}`),
|
|
18
11
|
].join("\t");
|
|
@@ -24,7 +17,7 @@ export const formatSessionDiff = (result) => {
|
|
|
24
17
|
];
|
|
25
18
|
const patch = result.patch === undefined
|
|
26
19
|
? ""
|
|
27
|
-
: `${
|
|
20
|
+
: `${block(result.patch)}${result.patchTruncated === true ? "[patch truncated]\n" : ""}`;
|
|
28
21
|
return `${lines.join("\n")}\n${patch}`;
|
|
29
22
|
};
|
|
30
23
|
//# sourceMappingURL=diff.js.map
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { formatRows } from "../../command-line/index.js";
|
|
2
|
-
const
|
|
3
|
-
const point = character.codePointAt(0) ?? 0;
|
|
4
|
-
return (point <= 31 ||
|
|
5
|
-
(point >= 127 && point <= 159) ||
|
|
6
|
-
point === 8232 ||
|
|
7
|
-
point === 8233);
|
|
8
|
-
};
|
|
9
|
-
export const formatFailureCell = (failure) => `${failure.code}: ${Array.from(failure.message, (character) => isTerminalControl(character) ? "�" : character).join("")}`;
|
|
1
|
+
import { cell, formatRows } from "../../command-line/index.js";
|
|
2
|
+
export const formatFailureCell = (failure) => cell(`${failure.code}: ${failure.message}`);
|
|
10
3
|
export const formatFailure = (failure, state = "failed") => failure === undefined ? "" : `${state}: ${formatFailureCell(failure)}\n`;
|
|
11
4
|
const eventFailure = (event) => {
|
|
12
5
|
const { eventType, payload } = event;
|
|
@@ -15,7 +8,7 @@ const eventFailure = (event) => {
|
|
|
15
8
|
typeof payload.reason !== "string")
|
|
16
9
|
return "";
|
|
17
10
|
const failure = "failure" in payload ? payload.failure : undefined;
|
|
18
|
-
return `\t${payload.reason}${failure === undefined ? "" : `\t${formatFailureCell(failure)}`}`;
|
|
11
|
+
return `\t${cell(payload.reason)}${failure === undefined ? "" : `\t${formatFailureCell(failure)}`}`;
|
|
19
12
|
};
|
|
20
13
|
export const formatSessionEvents = (items) => formatRows(items, (event) => `${event.sessionCursor}\t${event.eventType}\t${event.globalCursor}${eventFailure(event)}`, {
|
|
21
14
|
empty: "No events.",
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { cell, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
|
|
1
|
+
import { cell, fields, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
|
|
2
2
|
import { formatSessionDiff } from "./diff.js";
|
|
3
3
|
import { formatFailure, formatSessionEvents } from "./failure.js";
|
|
4
4
|
import { formatSessionObservation } from "./observe.js";
|
|
5
5
|
import { formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
const formatSessionInbox = (deliveries) => formatRows(deliveries, (delivery) => `${delivery.deliveryId}\t${delivery.sequence}\t${cell(delivery.message.senderSessionId)}\t${cell(delivery.message.subject)}\t${cell(delivery.message.body)}`);
|
|
7
|
-
const formatSessionCreation = (result) => `${
|
|
8
|
-
result.sessionId,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:
|
|
13
|
-
]
|
|
7
|
+
const formatSessionCreation = (result) => `${fields([
|
|
8
|
+
["session", result.sessionId],
|
|
9
|
+
["account", result.executor?.connectionId],
|
|
10
|
+
[
|
|
11
|
+
"workspace",
|
|
12
|
+
result.worktree === undefined ? undefined : result.workspaceId,
|
|
13
|
+
],
|
|
14
|
+
["branch", result.worktree?.branch],
|
|
15
|
+
])}next: maia session start ${result.sessionId} --expected-revision ${result.revision} --wait\n`;
|
|
14
16
|
const formatArchive = ({ archive, revision, sessionId, state, }) => {
|
|
15
17
|
const kept = archive === undefined
|
|
16
18
|
? ["no worktree to keep"]
|
|
@@ -29,8 +31,17 @@ const formatCodingSession = (result) => {
|
|
|
29
31
|
const formatAgentPermission = (result) => result.command === "session.agent-permission.preview"
|
|
30
32
|
? `${result.result.sessionId}\t${result.result.expiresAt}\n`
|
|
31
33
|
: `${result.result.receipt.receiptId}\t${result.result.delivery}\n`;
|
|
32
|
-
const formatSessionShow = ({ session, }) => `${
|
|
33
|
-
|
|
34
|
+
const formatSessionShow = ({ session, }) => `${fields([
|
|
35
|
+
["session", session.id],
|
|
36
|
+
["state", session.state],
|
|
37
|
+
["revision", session.revision],
|
|
38
|
+
["workspace", session.workspaceId],
|
|
39
|
+
])}${formatFailure(session.failure)}`;
|
|
40
|
+
const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
|
|
41
|
+
["session", sessionId],
|
|
42
|
+
["state", state],
|
|
43
|
+
["revision", revision],
|
|
44
|
+
])}${state === "starting" ? `next: maia session start ${sessionId} --expected-revision ${revision} --wait returns once it runs; maia session show ${sessionId} shows it now\n` : ""}`;
|
|
34
45
|
const formatSessions = (result) => result.items.length === 0 ? "No Sessions.\n" : formatSessionList(result);
|
|
35
46
|
const formatInboxAck = ({ delivery, deliveryRecord, mailboxRevision, }) => `${tab([deliveryRecord.deliveryId, delivery, mailboxRevision])}\n`;
|
|
36
47
|
const formatMessageSend = ({ delivery, deliveryId, sequence, }) => `${tab([deliveryId, delivery, sequence])}\n`;
|
|
@@ -2,5 +2,5 @@ export { formatSessionDiff } from "./diff.js";
|
|
|
2
2
|
export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
|
|
3
3
|
export { type CliSessionResult, formatSessionResult, writeSessionResult, } from "./human.js";
|
|
4
4
|
export { formatSessionObservation } from "./observe.js";
|
|
5
|
-
export { type CliSessionTaskItem, type CliSessionTasksResult, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
5
|
+
export { type CliSessionList, type CliSessionTaskItem, type CliSessionTasksResult, formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,5 +2,5 @@ export { formatSessionDiff } from "./diff.js";
|
|
|
2
2
|
export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
|
|
3
3
|
export { formatSessionResult, writeSessionResult, } from "./human.js";
|
|
4
4
|
export { formatSessionObservation } from "./observe.js";
|
|
5
|
-
export { formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
5
|
+
export { formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SessionCreationOutcome, SessionListResult } from "@maiaos/sdk";
|
|
2
|
+
import type { ListedNode } from "../../fleet/index.js";
|
|
2
3
|
export type CliSessionTaskItem = {
|
|
3
4
|
readonly error?: SessionCreationOutcome["error"];
|
|
4
5
|
readonly line: number;
|
|
@@ -14,6 +15,20 @@ export type CliSessionTasksResult = {
|
|
|
14
15
|
readonly items: readonly CliSessionTaskItem[];
|
|
15
16
|
readonly workspaceId: string;
|
|
16
17
|
};
|
|
17
|
-
export declare const formatSessionTasks: (
|
|
18
|
+
export declare const formatSessionTasks: ({ items }: CliSessionTasksResult) => string;
|
|
19
|
+
type ListedSession = SessionListResult["items"][number];
|
|
18
20
|
export declare const formatSessionList: (result: SessionListResult) => string;
|
|
21
|
+
type Labeled<TValue> = TValue & {
|
|
22
|
+
readonly node: string;
|
|
23
|
+
};
|
|
24
|
+
export type CliSessionList = {
|
|
25
|
+
readonly attention?: readonly Labeled<NonNullable<SessionListResult["attention"]>[number]>[];
|
|
26
|
+
readonly items: readonly Labeled<ListedSession>[];
|
|
27
|
+
readonly method: "session.list";
|
|
28
|
+
readonly nodes: readonly ListedNode[];
|
|
29
|
+
};
|
|
30
|
+
export declare const formatMergedSessions: ({ result, }: {
|
|
31
|
+
readonly result: CliSessionList;
|
|
32
|
+
}) => string;
|
|
33
|
+
export {};
|
|
19
34
|
//# sourceMappingURL=tasks.d.ts.map
|
|
@@ -1,34 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatMerged } from "../../address-space/index.js";
|
|
2
|
+
import { cell, fields, formatRows, tab, withNextPage, } from "../../command-line/index.js";
|
|
2
3
|
import { formatFailureCell } from "./failure.js";
|
|
3
4
|
const failure = ({ error }) => error === undefined
|
|
4
|
-
?
|
|
5
|
+
? undefined
|
|
5
6
|
: `${error.operationId}:${error.code ?? error.kind}${error.failure === undefined ? "" : ` (${formatFailureCell(error.failure)})`}`;
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
export const formatSessionTasks = ({ items }) => items.length === 1
|
|
8
|
+
? items
|
|
9
|
+
.map((item) => fields([
|
|
10
|
+
["stage", item.stage],
|
|
11
|
+
["session", item.sessionId],
|
|
12
|
+
["turn", item.turnId],
|
|
13
|
+
["command", item.recovery?.commandId],
|
|
14
|
+
["error", failure(item)],
|
|
15
|
+
]))
|
|
16
|
+
.join("")
|
|
17
|
+
: formatRows(items, (item) => tab([
|
|
18
|
+
item.line,
|
|
19
|
+
item.stage,
|
|
20
|
+
item.sessionId ?? "-",
|
|
21
|
+
item.turnId ?? "-",
|
|
22
|
+
item.recovery?.commandId ?? "-",
|
|
23
|
+
failure(item) ?? "-",
|
|
24
|
+
]), {
|
|
25
|
+
empty: "",
|
|
26
|
+
headers: ["LINE", "STAGE", "SESSION", "TURN", "COMMAND", "ERROR"],
|
|
27
|
+
});
|
|
28
|
+
const SESSION_HEADERS = ["SESSION", "STATE", "WORKSPACE", "ATTENTION", "TITLE"];
|
|
29
|
+
const sessionCells = (session, attention) => [
|
|
30
|
+
session.id,
|
|
31
|
+
session.state,
|
|
32
|
+
session.workspaceId,
|
|
33
|
+
attention ?? "-",
|
|
34
|
+
cell(session.title ?? "-"),
|
|
35
|
+
];
|
|
21
36
|
export const formatSessionList = (result) => {
|
|
22
37
|
const attention = new Map((result.attention ?? []).map((item) => [item.sessionId, item.attention]));
|
|
23
|
-
return withNextPage(formatRows(result.items, (session) => tab(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}), result.nextCursor);
|
|
38
|
+
return withNextPage(formatRows(result.items, (session) => tab(sessionCells(session, attention.get(session.id))), { empty: "No Sessions.", headers: SESSION_HEADERS }), result.nextCursor);
|
|
39
|
+
};
|
|
40
|
+
const sessionKey = (node, id) => `${node} ${id}`;
|
|
41
|
+
export const formatMergedSessions = ({ result, }) => {
|
|
42
|
+
const attention = new Map((result.attention ?? []).map((item) => [
|
|
43
|
+
sessionKey(item.node, item.sessionId),
|
|
44
|
+
item.attention,
|
|
45
|
+
]));
|
|
46
|
+
return formatMerged(result, (session) => tab(sessionCells(session, attention.get(sessionKey(session.node, session.id)))), { empty: "No Sessions.", headers: SESSION_HEADERS });
|
|
33
47
|
};
|
|
34
48
|
//# sourceMappingURL=tasks.js.map
|