@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.
Files changed (216) hide show
  1. package/README.md +38 -265
  2. package/dist/address-space/address-space.d.ts +38 -0
  3. package/dist/address-space/address-space.js +130 -0
  4. package/dist/address-space/index.d.ts +2 -0
  5. package/dist/address-space/index.js +2 -0
  6. package/dist/agents/client.d.ts +171 -0
  7. package/dist/agents/client.js +8 -0
  8. package/dist/agents/commands.d.ts +7 -0
  9. package/dist/agents/commands.js +65 -0
  10. package/dist/agents/index.d.ts +3 -0
  11. package/dist/agents/index.js +3 -0
  12. package/dist/agents/input.d.ts +130 -0
  13. package/dist/agents/input.js +99 -0
  14. package/dist/agents/output/format.d.ts +8 -0
  15. package/dist/agents/output/format.js +47 -0
  16. package/dist/agents/output/index.d.ts +2 -0
  17. package/dist/agents/output/index.js +2 -0
  18. package/dist/agents/tree/index.d.ts +2 -0
  19. package/dist/agents/tree/index.js +2 -0
  20. package/dist/agents/tree/tree.d.ts +3 -0
  21. package/dist/agents/tree/tree.js +43 -0
  22. package/dist/bin/maia.cdx.json +37 -14
  23. package/dist/bin/maia.mjs +1 -1
  24. package/dist/bootstrap/exit.d.ts +14 -0
  25. package/dist/bootstrap/exit.js +42 -0
  26. package/dist/bootstrap/process.js +4 -26
  27. package/dist/cli/cli.js +70 -13
  28. package/dist/command-line/context.d.ts +13 -4
  29. package/dist/command-line/context.js +1 -1
  30. package/dist/command-line/index.d.ts +5 -5
  31. package/dist/command-line/index.js +5 -4
  32. package/dist/command-line/input/index.d.ts +1 -1
  33. package/dist/command-line/input/index.js +1 -1
  34. package/dist/command-line/input/stdin.d.ts +1 -0
  35. package/dist/command-line/input/stdin.js +1 -0
  36. package/dist/command-line/json.d.ts +1 -0
  37. package/dist/command-line/json.js +23 -0
  38. package/dist/command-line/output.d.ts +8 -1
  39. package/dist/command-line/output.js +33 -14
  40. package/dist/command-line/rows.d.ts +2 -0
  41. package/dist/command-line/rows.js +10 -1
  42. package/dist/command-line/two-phase.d.ts +5 -0
  43. package/dist/command-line/two-phase.js +33 -8
  44. package/dist/command-tree/help.d.ts +1 -1
  45. package/dist/command-tree/help.js +1 -0
  46. package/dist/command-tree/index.d.ts +2 -2
  47. package/dist/command-tree/index.js +1 -1
  48. package/dist/command-tree/local.js +12 -0
  49. package/dist/command-tree/placeholder.d.ts +1 -0
  50. package/dist/command-tree/placeholder.js +1 -0
  51. package/dist/command-tree/row.d.ts +2 -0
  52. package/dist/command-tree/tree.d.ts +3 -2
  53. package/dist/command-tree/tree.js +18 -2
  54. package/dist/connection/client.d.ts +93 -1
  55. package/dist/connection/client.js +7 -1
  56. package/dist/connection/index.d.ts +1 -1
  57. package/dist/connection/index.js +1 -1
  58. package/dist/connection/system.d.ts +1 -0
  59. package/dist/connection/system.js +109 -5
  60. package/dist/connection/tree/tree.js +17 -4
  61. package/dist/container/output/format.js +1 -2
  62. package/dist/dashboard/cockpit-client.d.ts +6 -0
  63. package/dist/dashboard/cockpit-client.js +27 -0
  64. package/dist/dashboard/cockpits.d.ts +29 -0
  65. package/dist/dashboard/cockpits.js +65 -0
  66. package/dist/dashboard/dashboard.d.ts +7 -0
  67. package/dist/dashboard/dashboard.js +47 -0
  68. package/dist/dashboard/draw.d.ts +15 -0
  69. package/dist/dashboard/draw.js +30 -0
  70. package/dist/dashboard/frame.d.ts +4 -0
  71. package/dist/dashboard/frame.js +15 -0
  72. package/dist/dashboard/index.d.ts +2 -0
  73. package/dist/dashboard/index.js +2 -0
  74. package/dist/dashboard/modes.d.ts +5 -0
  75. package/dist/dashboard/modes.js +16 -0
  76. package/dist/dashboard/node-connection.d.ts +15 -0
  77. package/dist/dashboard/node-connection.js +51 -0
  78. package/dist/dashboard/pi-tui.d.ts +6 -0
  79. package/dist/dashboard/pi-tui.js +35 -0
  80. package/dist/dashboard/status-bar.d.ts +4 -0
  81. package/dist/dashboard/status-bar.js +60 -0
  82. package/dist/dashboard/terminal.d.ts +53 -0
  83. package/dist/dashboard/terminal.js +165 -0
  84. package/dist/dashboard/tree-model.d.ts +28 -0
  85. package/dist/dashboard/tree-model.js +97 -0
  86. package/dist/dashboard/tree.d.ts +10 -0
  87. package/dist/dashboard/tree.js +76 -0
  88. package/dist/fleet/fleet.d.ts +70 -0
  89. package/dist/fleet/fleet.js +91 -0
  90. package/dist/fleet/index.d.ts +2 -0
  91. package/dist/fleet/index.js +2 -0
  92. package/dist/hold/output/format.js +1 -5
  93. package/dist/hold/tree/tree.js +1 -0
  94. package/dist/import/commands.js +3 -4
  95. package/dist/import/output.js +1 -4
  96. package/dist/local-node/client.d.ts +8 -4
  97. package/dist/local-node/client.js +20 -9
  98. package/dist/local-node/index.d.ts +1 -1
  99. package/dist/local-node/index.js +1 -1
  100. package/dist/login/commands.js +2 -1
  101. package/dist/mcp/calls.d.ts +1 -0
  102. package/dist/mcp/calls.js +36 -3
  103. package/dist/mcp/commands.d.ts +5 -2
  104. package/dist/mcp/commands.js +30 -4
  105. package/dist/mcp/routing.d.ts +24 -0
  106. package/dist/mcp/routing.js +188 -0
  107. package/dist/mcp/server.d.ts +13 -4
  108. package/dist/mcp/server.js +35 -12
  109. package/dist/presentation/output/format.js +4 -3
  110. package/dist/project-guard/commands.js +11 -2
  111. package/dist/project-workspace/commands.js +16 -6
  112. package/dist/project-workspace/output/human.d.ts +13 -0
  113. package/dist/project-workspace/output/human.js +17 -5
  114. package/dist/project-workspace/output/index.d.ts +1 -1
  115. package/dist/project-workspace/output/index.js +1 -1
  116. package/dist/project-workspace/output/metadata.js +1 -1
  117. package/dist/project-workspace/tree/tree.js +27 -12
  118. package/dist/reference/commands.js +4 -2
  119. package/dist/reference/index.d.ts +1 -1
  120. package/dist/reference/index.js +1 -1
  121. package/dist/reference/resolve.d.ts +2 -0
  122. package/dist/reference/resolve.js +20 -17
  123. package/dist/remote-node/client.d.ts +89 -9
  124. package/dist/remote-node/client.js +6 -1
  125. package/dist/remote-node/commands.d.ts +9 -0
  126. package/dist/remote-node/commands.js +96 -18
  127. package/dist/remote-node/connector.d.ts +12 -4
  128. package/dist/remote-node/connector.js +46 -25
  129. package/dist/remote-node/index.d.ts +2 -2
  130. package/dist/remote-node/index.js +2 -2
  131. package/dist/remote-node/reachability.d.ts +43 -1
  132. package/dist/remote-node/reachability.js +13 -3
  133. package/dist/remote-node/text.d.ts +2 -1
  134. package/dist/remote-node/text.js +74 -27
  135. package/dist/remote-node/tree/tree.js +21 -1
  136. package/dist/routine/client.d.ts +398 -0
  137. package/dist/routine/client.js +28 -0
  138. package/dist/routine/commands.d.ts +9 -0
  139. package/dist/routine/commands.js +109 -0
  140. package/dist/routine/index.d.ts +3 -0
  141. package/dist/routine/index.js +3 -0
  142. package/dist/routine/input.d.ts +28 -0
  143. package/dist/routine/input.js +44 -0
  144. package/dist/routine/output/format.d.ts +23 -0
  145. package/dist/routine/output/format.js +83 -0
  146. package/dist/routine/output/index.d.ts +2 -0
  147. package/dist/routine/output/index.js +2 -0
  148. package/dist/routine/tree/index.d.ts +2 -0
  149. package/dist/routine/tree/index.js +2 -0
  150. package/dist/routine/tree/tree.d.ts +3 -0
  151. package/dist/routine/tree/tree.js +70 -0
  152. package/dist/session/agent-permission.d.ts +2 -2
  153. package/dist/session/approval/commands.js +24 -6
  154. package/dist/session/approval/output/format.d.ts +11 -0
  155. package/dist/session/approval/output/format.js +8 -0
  156. package/dist/session/approval/output/index.d.ts +1 -1
  157. package/dist/session/approval/output/index.js +1 -1
  158. package/dist/session/attach-client.d.ts +1 -1
  159. package/dist/session/attach-client.js +12 -3
  160. package/dist/session/attach-render.js +15 -7
  161. package/dist/session/attach.js +17 -3
  162. package/dist/session/client.d.ts +4 -2
  163. package/dist/session/client.js +4 -15
  164. package/dist/session/commands.js +76 -9
  165. package/dist/session/create-tasks.js +29 -11
  166. package/dist/session/index.d.ts +1 -1
  167. package/dist/session/index.js +1 -0
  168. package/dist/session/interaction/output/format.js +2 -1
  169. package/dist/session/output/diff.js +3 -10
  170. package/dist/session/output/failure.js +3 -10
  171. package/dist/session/output/human.js +21 -10
  172. package/dist/session/output/index.d.ts +1 -1
  173. package/dist/session/output/index.js +1 -1
  174. package/dist/session/output/tasks.d.ts +16 -1
  175. package/dist/session/output/tasks.js +41 -27
  176. package/dist/session/tree/tree.js +56 -8
  177. package/dist/session/turn/client.d.ts +4 -1
  178. package/dist/session/turn/client.js +15 -2
  179. package/dist/session/turn/commands.d.ts +2 -0
  180. package/dist/session/turn/commands.js +38 -5
  181. package/dist/session/turn/index.d.ts +3 -3
  182. package/dist/session/turn/index.js +1 -1
  183. package/dist/session/turn/output.d.ts +7 -2
  184. package/dist/session/turn/output.js +36 -13
  185. package/dist/status/client.d.ts +7 -2
  186. package/dist/status/output/compact.d.ts +1 -0
  187. package/dist/status/output/compact.js +3 -0
  188. package/dist/status/output/human.d.ts +1 -1
  189. package/dist/status/output/human.js +71 -14
  190. package/dist/team-workspace/ceremony.d.ts +19 -0
  191. package/dist/team-workspace/ceremony.js +141 -0
  192. package/dist/team-workspace/client.d.ts +58 -0
  193. package/dist/team-workspace/client.js +6 -0
  194. package/dist/team-workspace/commands.d.ts +3 -0
  195. package/dist/team-workspace/commands.js +85 -0
  196. package/dist/team-workspace/confirmation.d.ts +4 -0
  197. package/dist/team-workspace/confirmation.js +8 -0
  198. package/dist/team-workspace/dependencies.d.ts +8 -0
  199. package/dist/team-workspace/dependencies.js +2 -0
  200. package/dist/team-workspace/index.d.ts +6 -0
  201. package/dist/team-workspace/index.js +5 -0
  202. package/dist/team-workspace/launcher.d.ts +17 -0
  203. package/dist/team-workspace/launcher.js +30 -0
  204. package/dist/team-workspace/output.d.ts +15 -0
  205. package/dist/team-workspace/output.js +28 -0
  206. package/dist/team-workspace/terminal.d.ts +9 -0
  207. package/dist/team-workspace/terminal.js +46 -0
  208. package/dist/terminal/client.d.ts +4 -0
  209. package/dist/terminal/client.js +3 -0
  210. package/dist/terminal/commands.js +37 -25
  211. package/dist/terminal/output/compact-list.d.ts +1 -0
  212. package/dist/terminal/output/compact-list.js +1 -0
  213. package/dist/terminal/output/human.d.ts +2 -19
  214. package/dist/terminal/output/human.js +6 -6
  215. package/dist/terminal/tree/tree.js +15 -15
  216. package/package.json +8 -6
@@ -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.connectionId === undefined && selection.executor === undefined)
102
- throw new CliArgumentError("Option '--base' needs '--connection' or '--executor'.");
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 result = yield* context.dependencies.listSessions(readSessionList(tokens));
205
- return writeSessionResult(result, context, (value) => ({
206
- command: "session.list",
207
- result: value,
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 { baseRef, connectionId, executor, model, role, title } = request.selection;
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* () {
@@ -1,6 +1,6 @@
1
1
  export { runAgentPermissionSet } from "./agent-permission.js";
2
2
  export { runSessionAttach } from "./attach.js";
3
- export type { AttachSessionInput, SessionAttachStream, } from "./attach-client.js";
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";
@@ -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${JSON.stringify(result)}\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
- const isUnsafeControl = (character) => {
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
- safeText(file.previousPath === undefined
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
- : `${safeText(result.patch)}${result.patchTruncated === true ? "[patch truncated]\n" : ""}`;
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 isTerminalControl = (character) => {
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) => `${tab([
8
- result.sessionId,
9
- ...(result.executor === undefined ? [] : [result.executor.connectionId]),
10
- ...(result.worktree === undefined
11
- ? []
12
- : [result.workspaceId, result.worktree.branch]),
13
- ])}\nnext: maia session start ${result.sessionId} --expected-revision ${result.revision} --wait\n`;
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, }) => `${session.id}\t${session.state}\t${session.workspaceId}\n${formatFailure(session.failure)}`;
33
- const formatLifecycle = ({ revision, sessionId, state, }) => `${sessionId}\t${state}\t${revision}\n${state === "starting" ? `next: maia session start ${sessionId} --expected-revision ${revision} --wait returns once it runs; maia session show ${sessionId} shows it now\n` : ""}`;
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: (result: CliSessionTasksResult) => string;
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 { cell, formatRows, tab, withNextPage, } from "../../command-line/index.js";
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 receiptIds = ({ receipts }) => {
7
- const ids = [receipts.create, receipts.start, receipts.send].flatMap((receipt) => (receipt === undefined ? [] : [receipt.receiptId]));
8
- return ids.length === 0 ? "-" : ids.join(",");
9
- };
10
- export const formatSessionTasks = (result) => result.items
11
- .map((item) => `${[
12
- String(item.line),
13
- item.stage,
14
- item.sessionId ?? "-",
15
- item.turnId ?? "-",
16
- failure(item),
17
- receiptIds(item),
18
- item.recovery?.commandId ?? "-",
19
- ].join("\t")}\n`)
20
- .join("");
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
- session.id,
25
- session.state,
26
- session.workspaceId,
27
- attention.get(session.id) ?? "-",
28
- cell(session.title ?? "-"),
29
- ]), {
30
- empty: "No Sessions.",
31
- headers: ["SESSION", "STATE", "WORKSPACE", "ATTENTION", "TITLE"],
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