@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,7 +1,9 @@
1
1
  import { MAX_PROJECT_CONTEXT_NOTE_BODY_BYTES, } from "@maiaos/sdk";
2
2
  import * as Effect from "effect/Effect";
3
+ import { listEach, writeMerged } from "../address-space/index.js";
3
4
  import { CliArgumentError, missingArgument, parseOptions, readCursor, readExpectedRevision, readPageSize, readRevisionOption, requirePositionals, } from "../command-line/index.js";
4
- import { writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./output/index.js";
5
+ import { mergeLists } from "../fleet/index.js";
6
+ import { formatProjectLists, writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./output/index.js";
5
7
  const summarizeProjectRegistration = (result) => ({
6
8
  checkoutId: result.checkout.id,
7
9
  delivery: result.delivery,
@@ -40,14 +42,22 @@ export const runProjectRegister = (tokens, context) => Effect.gen(function* () {
40
42
  export const runProjectList = (tokens, context) => Effect.gen(function* () {
41
43
  const parsed = parseOptions(tokens, new Set(["--after", "--limit"]));
42
44
  requirePositionals(parsed.positionals, 0);
43
- const result = yield* context.dependencies.listProjects({
45
+ const input = {
44
46
  afterCursor: readCursor(parsed.options.get("--after")),
45
47
  limit: readPageSize(parsed.options.get("--limit")),
48
+ };
49
+ return yield* listEach(context, {
50
+ merged: (answers) => writeMerged(context, {
51
+ command: "project.list",
52
+ result: { ...mergeLists(answers), method: "project.list" },
53
+ }, formatProjectLists),
54
+ paged: input.afterCursor !== "0",
55
+ read: (dependencies) => dependencies.listProjects(input),
56
+ sole: (result) => writeProjectResult(result, context, (value) => ({
57
+ command: "project.list",
58
+ result: value,
59
+ })),
46
60
  });
47
- return writeProjectResult(result, context, (value) => ({
48
- command: "project.list",
49
- result: value,
50
- }));
51
61
  });
52
62
  export const runProjectShow = (tokens, context) => Effect.gen(function* () {
53
63
  const parsed = parseOptions(tokens, new Set());
@@ -1,5 +1,6 @@
1
1
  import type { ExecutionCatalogGetResult, ExecutionCommandRunResult, ExecutionFileReadResult, ExecutionPlacementCreateResult, ExecutionPlacementShowResult, ExecutionWorktreeCheckpointCreateResult, ExecutionWorktreeCheckpointShowResult, ExecutionWorktreeCreateResult, ExecutionWorktreeImportResult, ExecutionWorktreeReconcileResult, ExecutionWorktreeRemoveApplyResult, ExecutionWorktreeRemovePlanResult, ExecutionWorktreeStatusResult, ProjectContextListResult, ProjectContextRecordResult, ProjectContextShowResult, ProjectListResult, ProjectRegisterResult, ProjectShowResult, WorkspaceContextShowResult, WorkspaceExecutionConfigureResult, WorkspaceExecutionShowResult, WorkspaceListResult, WorkspaceMembershipAttachResult, WorkspaceRepositoryAttachResult, WorkspaceSelectResult, WorkspaceShowResult } from "@maiaos/sdk";
2
2
  import { type CliIo } from "../../command-line/index.js";
3
+ import type { ListedNode } from "../../fleet/index.js";
3
4
  import type { CliNodeResult } from "../../local-node/index.js";
4
5
  export type CliExecutionResult = {
5
6
  readonly command: "execution.catalog";
@@ -112,6 +113,18 @@ export type CliWorkspaceResult = {
112
113
  readonly command: "workspace.show";
113
114
  readonly result: WorkspaceShowResult;
114
115
  };
116
+ type ListedProject = ProjectListResult["items"][number];
117
+ export type CliProjectList = {
118
+ readonly command: "project.list";
119
+ readonly result: {
120
+ readonly items: readonly (ListedProject & {
121
+ readonly node: string;
122
+ })[];
123
+ readonly method: "project.list";
124
+ readonly nodes: readonly ListedNode[];
125
+ };
126
+ };
127
+ export declare const formatProjectLists: ({ result }: CliProjectList) => string;
115
128
  export declare const formatWorkspaceResult: (result: CliWorkspaceResult) => string;
116
129
  export declare const formatProjectResult: (result: CliProjectResult) => string;
117
130
  export declare const formatExecutionResult: (result: CliExecutionResult) => string;
@@ -1,8 +1,12 @@
1
- import { cell, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
2
- const formatProjectList = (result) => formatRows(result.items, (project) => `${project.id}\t${cell(project.name)}\t${project.revision}`, {
1
+ import { formatMerged } from "../../address-space/index.js";
2
+ import { cell, fields, formatRows, writeNodeResult, } from "../../command-line/index.js";
3
+ const projectRow = (project) => `${project.id}\t${cell(project.name)}\t${project.revision}`;
4
+ const PROJECT_TABLE = {
3
5
  empty: "No Projects. Register one with: maia project register <path>",
4
6
  headers: ["PROJECT", "NAME", "REVISION"],
5
- });
7
+ };
8
+ const formatProjectList = (result) => formatRows(result.items, projectRow, PROJECT_TABLE);
9
+ export const formatProjectLists = ({ result }) => formatMerged(result, projectRow, PROJECT_TABLE);
6
10
  const formatProjectContextList = (result) => formatRows(result.items, (note) => `${note.id}\t${note.sequence}\t${cell(note.body)}`, { empty: "No context notes.", headers: ["NOTE", "SEQUENCE", "BODY"] });
7
11
  const formatWorkspaceList = (result) => formatRows(result.items, (workspace) => `${workspace.id}\t${cell(workspace.name)}\t${workspace.kind}\t${workspace.revision}`, {
8
12
  empty: "No Workspaces.",
@@ -31,11 +35,19 @@ export const formatWorkspaceResult = (result) => {
31
35
  export const formatProjectResult = (result) => {
32
36
  switch (result.command) {
33
37
  case "project.register":
34
- return `${tab([result.result.projectId, result.result.workspaceId, result.result.repositoryId])}\nnext: maia session create --workspace ${result.result.workspaceId} --executor codex-cli --message '<task>'\n`;
38
+ return `${fields([
39
+ ["project", result.result.projectId],
40
+ ["workspace", result.result.workspaceId],
41
+ ["repository", result.result.repositoryId],
42
+ ])}next: maia session create --project ${result.result.projectId} --base <branch> --executor codex-cli --message '<task>'\n`;
35
43
  case "project.list":
36
44
  return formatProjectList(result.result);
37
45
  case "project.show":
38
- return `${result.result.project.id}\t${cell(result.result.project.name)}\t${result.result.project.revision}\n`;
46
+ return fields([
47
+ ["project", result.result.project.id],
48
+ ["name", result.result.project.name],
49
+ ["revision", result.result.project.revision],
50
+ ]);
39
51
  case "project.context.record":
40
52
  return `${result.result.noteId}\n`;
41
53
  case "project.context.list":
@@ -1,3 +1,3 @@
1
- export { type CliExecutionResult, type CliProjectResult, type CliWorkspaceResult, formatExecutionResult, formatProjectResult, formatWorkspaceResult, writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./human.js";
1
+ export { type CliExecutionResult, type CliProjectList, type CliProjectResult, type CliWorkspaceResult, formatExecutionResult, formatProjectLists, formatProjectResult, formatWorkspaceResult, writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./human.js";
2
2
  export { type CliProjectMetadataResult, formatProjectMetadataResult, isProjectMetadataResult, type ProjectMetadataResult, } from "./metadata.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- export { formatExecutionResult, formatProjectResult, formatWorkspaceResult, writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./human.js";
1
+ export { formatExecutionResult, formatProjectLists, formatProjectResult, formatWorkspaceResult, writeExecutionResult, writeProjectResult, writeWorkspaceResult, } from "./human.js";
2
2
  export { formatProjectMetadataResult, isProjectMetadataResult, } from "./metadata.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
+ import { cell } from "../../command-line/index.js";
1
2
  export const isProjectMetadataResult = (result) => result.command === "project.create.preview" ||
2
3
  result.command === "project.create.confirm" ||
3
4
  result.command === "project.rename.preview" ||
4
5
  result.command === "project.rename.confirm";
5
- const cell = (value) => value.replaceAll(/[\u0000-\u001F\u007F-\u009F]/gu, " ");
6
6
  export const formatProjectMetadataResult = ({ result, }) => {
7
7
  switch (result.method) {
8
8
  case "project.create.preview":
@@ -40,7 +40,7 @@ export const PROJECT_TREE = {
40
40
  0,
41
41
  "project.show",
42
42
  "Show one Project.",
43
- { run: [project, "runProjectShow"] },
43
+ { route: "<project-id>", run: [project, "runProjectShow"] },
44
44
  ],
45
45
  [
46
46
  "project create (--input-stdin --dry-run | --confirm-stdin)",
@@ -61,28 +61,32 @@ export const PROJECT_TREE = {
61
61
  1,
62
62
  "project.guard.show",
63
63
  "Show a Project's guards.",
64
- { run: [guard, "runProjectGuardShow"] },
64
+ { route: "<project-id>", run: [guard, "runProjectGuardShow"] },
65
65
  ],
66
66
  [
67
67
  "project guard set (<project-id> --expected-revision <revision> --max-depth <1..4> --max-live-children <1..64> --max-messages-per-minute <1..600> --max-leases-per-session <1..64> [--command-id <id>] [--dry-run] | --confirm-stdin)",
68
68
  1,
69
69
  ["project.guard.preview", "project.guard.confirm"],
70
70
  "Set a Project's guards after a preview.",
71
- { kind: "two-phase", run: [guard, "runProjectGuardSet"] },
71
+ {
72
+ kind: "two-phase",
73
+ route: "<project-id>",
74
+ run: [guard, "runProjectGuardSet"],
75
+ },
72
76
  ],
73
77
  [
74
78
  "project context record --project <project-id> --body-stdin [--command-id <id>]",
75
79
  0,
76
80
  "project.context.record",
77
81
  "Record a context note for a Project.",
78
- { run: [project, "runProjectContextRecord"] },
82
+ { route: "--project", run: [project, "runProjectContextRecord"] },
79
83
  ],
80
84
  [
81
85
  "project context list --project <project-id> [--limit <1..100>] [--after <cursor>]",
82
86
  0,
83
87
  "project.context.list",
84
88
  "List a Project's context notes.",
85
- { run: [project, "runProjectContextList"] },
89
+ { route: "--project", run: [project, "runProjectContextList"] },
86
90
  ],
87
91
  [
88
92
  "project context show <note-id>",
@@ -96,21 +100,21 @@ export const PROJECT_TREE = {
96
100
  0,
97
101
  "workspace.list",
98
102
  "List a Project's Workspaces.",
99
- { run: [project, "runWorkspaceList"] },
103
+ { route: "--project", run: [project, "runWorkspaceList"] },
100
104
  ],
101
105
  [
102
106
  "workspace show <workspace-id>",
103
107
  0,
104
108
  "workspace.show",
105
109
  "Show one Workspace.",
106
- { run: [project, "runWorkspaceShow"] },
110
+ { route: "<workspace-id>", run: [project, "runWorkspaceShow"] },
107
111
  ],
108
112
  [
109
113
  "workspace select <workspace-id> --project <project-id> --repository <repository-id> --expected-active-workspace-id <workspace-id> --expected-active-context-revision <revision> --expected-workspace-revision <revision> --expected-context-revision <revision> [--command-id <id>]",
110
114
  1,
111
115
  "workspace.select",
112
116
  "Select the active Workspace.",
113
- { run: [project, "runWorkspaceSelect"] },
117
+ { route: "<workspace-id>", run: [project, "runWorkspaceSelect"] },
114
118
  ],
115
119
  [
116
120
  "workspace context show",
@@ -124,28 +128,39 @@ export const PROJECT_TREE = {
124
128
  1,
125
129
  "workspace.execution.show",
126
130
  "Show a Workspace's execution settings.",
127
- { run: [project, "runWorkspaceExecutionShow"] },
131
+ { route: "<workspace-id>", run: [project, "runWorkspaceExecutionShow"] },
128
132
  ],
129
133
  [
130
134
  "workspace execution set <workspace-id> (--execution-profile <profile-id> | --policy <policy-id>) --expected-revision <revision> [--command-id <id>]",
131
135
  1,
132
136
  "workspace.execution.configure",
133
137
  "Set a Workspace's execution profile or policy.",
134
- { kind: "discriminant", run: [project, "runWorkspaceExecutionSet"] },
138
+ {
139
+ kind: "discriminant",
140
+ route: "<workspace-id>",
141
+ run: [project, "runWorkspaceExecutionSet"],
142
+ },
135
143
  ],
136
144
  [
137
145
  "workspace execution clear <workspace-id> --expected-revision <revision> [--command-id <id>]",
138
146
  1,
139
147
  "workspace.execution.configure",
140
148
  "Clear a Workspace's execution settings.",
141
- { kind: "discriminant", run: [project, "runWorkspaceExecutionClear"] },
149
+ {
150
+ kind: "discriminant",
151
+ route: "<workspace-id>",
152
+ run: [project, "runWorkspaceExecutionClear"],
153
+ },
142
154
  ],
143
155
  [
144
156
  "workspace membership attach <workspace-id> --project <project-id> --repository <repository-id> --expected-workspace-revision <revision> --expected-context-revision <revision> [--command-id <id>]",
145
157
  1,
146
158
  "workspace.membership.attach",
147
159
  "Attach a Project repository to a Workspace.",
148
- { run: [project, "runWorkspaceMembershipAttach"] },
160
+ {
161
+ route: "<workspace-id>",
162
+ run: [project, "runWorkspaceMembershipAttach"],
163
+ },
149
164
  ],
150
165
  [
151
166
  "workspace repository attach <path> --workspace <workspace-id> --expected-revision <revision> [--name <name>] [--command-id <id>]",
@@ -1,5 +1,5 @@
1
1
  import * as Effect from "effect/Effect";
2
- import { cell, CliArgumentError, parseOptions, writeNodeResult, } from "../command-line/index.js";
2
+ import { cell, CliArgumentError, LOCAL_NODE, parseOptions, writeNodeResult, } from "../command-line/index.js";
3
3
  import { workingFolder } from "./resolve.js";
4
4
  const KINDS = new Set([
5
5
  "connection",
@@ -15,7 +15,9 @@ const readParameters = (tokens, context) => {
15
15
  if (!isKind(kind) || extra.length > 0)
16
16
  throw new CliArgumentError("Name one kind (connection, container, project, session or workspace) and at most one reference.");
17
17
  const projectId = parsed.options.get("--project");
18
- const path = context.node === undefined ? workingFolder(context.io.cwd) : undefined;
18
+ const path = context.node === undefined || context.node === LOCAL_NODE
19
+ ? workingFolder(context.io.cwd)
20
+ : undefined;
19
21
  if (reference === undefined)
20
22
  return { kind, ...(path === undefined ? {} : { path }) };
21
23
  return { kind, reference, ...(projectId === undefined ? {} : { projectId }) };
@@ -1,3 +1,3 @@
1
1
  export { runReferenceResolve } from "./commands.js";
2
- export { describeResolution, type LeafArguments, type PreparedLeaf, prepareLeaf, type ResolvedArguments, resolveLeafArguments, workingFolder, } from "./resolve.js";
2
+ export { argumentValue, describeResolution, isExactId, type LeafArguments, type PreparedLeaf, prepareLeaf, type ResolvedArguments, resolveLeafArguments, workingFolder, } from "./resolve.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
1
  export { runReferenceResolve } from "./commands.js";
2
- export { describeResolution, prepareLeaf, resolveLeafArguments, workingFolder, } from "./resolve.js";
2
+ export { argumentValue, describeResolution, isExactId, prepareLeaf, resolveLeafArguments, workingFolder, } from "./resolve.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -8,6 +8,8 @@ export type ResolvedArguments = {
8
8
  readonly resolutions: readonly CliResolution[];
9
9
  readonly tokens: readonly string[];
10
10
  };
11
+ export declare const isExactId: (kind: string, value: string) => boolean;
12
+ export declare const argumentValue: (usage: string, tokens: readonly string[], argument: string) => Effect.Effect<string | undefined, CliArgumentError>;
11
13
  export declare const describeResolution: (item: CliResolution) => string;
12
14
  export type LeafArguments = {
13
15
  readonly context: CommandContext;
@@ -1,6 +1,6 @@
1
1
  import * as Data from "effect/Data";
2
2
  import * as Effect from "effect/Effect";
3
- import { cell, CliArgumentError, parseOptions, reportError, tokenizeArguments, } from "../command-line/index.js";
3
+ import { cell, CliArgumentError, LOCAL_NODE, parseOptions, reportError, tokenizeArguments, } from "../command-line/index.js";
4
4
  import { parseUsage, REFERENCE_PLACEHOLDER, } from "../command-tree/index.js";
5
5
  class ReferenceRefused extends Data.TaggedError("ReferenceRefused") {
6
6
  }
@@ -22,7 +22,7 @@ const kindOf = (placeholder) => {
22
22
  const word = REFERENCE_PLACEHOLDER.exec(placeholder ?? "")?.[1] ?? "";
23
23
  return isKind(word) ? word : undefined;
24
24
  };
25
- const isExactId = (kind, value) => new RegExp(`^${kind}_[0-9a-f]{32}$`, "u").test(value);
25
+ export const isExactId = (kind, value) => new RegExp(`^${kind}_[0-9a-f]{32}$`, "u").test(value);
26
26
  const grammarOf = (arguments_) => ({
27
27
  options: new Map(arguments_.flatMap((argument) => argument.name.startsWith("--") && argument.value !== undefined
28
28
  ? [
@@ -61,23 +61,21 @@ const placeOf = (grammar, role, position) => {
61
61
  ...(kind === undefined ? {} : { kind }),
62
62
  };
63
63
  };
64
- const targetsOf = (grammar, tokens, roles) => {
64
+ const placementsOf = (grammar, tokens, roles) => {
65
65
  const kept = roles.filter((role) => role.kind !== "flag");
66
66
  const positionals = kept.filter((role) => role.kind === "positional");
67
- return kept.flatMap((role) => {
67
+ return kept.map((role) => {
68
68
  const place = placeOf(grammar, role, positionals.indexOf(role));
69
- const { inline, kind } = place;
70
- return kind === undefined
71
- ? []
72
- : [
73
- {
74
- ...place,
75
- kind,
76
- reference: valueOf(tokens[role.index] ?? "", inline),
77
- },
78
- ];
69
+ return {
70
+ ...place,
71
+ reference: valueOf(tokens[role.index] ?? "", place.inline),
72
+ };
79
73
  });
80
74
  };
75
+ const targetsOf = (placements) => placements.flatMap((place) => {
76
+ const { kind } = place;
77
+ return kind === undefined ? [] : [{ ...place, kind }];
78
+ });
81
79
  const flagsOf = (arguments_) => new Set(arguments_.flatMap((argument) => argument.name.startsWith("--") && argument.value === undefined
82
80
  ? [argument.name]
83
81
  : []));
@@ -91,12 +89,15 @@ const locate = (arguments_, tokens) => Effect.try({
91
89
  const end = tokens.indexOf("--");
92
90
  parseOptions(end === -1 ? tokens : tokens.slice(0, end), valueOptions, flagsOf(arguments_));
93
91
  const roles = tokenizeArguments(tokens, valueOptions);
92
+ const placements = placementsOf(grammar, tokens, roles);
94
93
  return {
95
94
  given: new Set(roles.flatMap((role) => ("name" in role ? [role.name] : []))),
96
- targets: targetsOf(grammar, tokens, roles),
95
+ placements,
96
+ targets: targetsOf(placements),
97
97
  };
98
98
  },
99
99
  });
100
+ export const argumentValue = (usage, tokens, argument) => Effect.map(locate(parseUsage(usage).args, tokens), ({ placements }) => placements.find((place) => place.argument === argument)?.reference);
100
101
  const missingScope = (arguments_, given) => {
101
102
  const scope = arguments_.find((argument) => argument.required === true &&
102
103
  (argument.name === "--workspace" || argument.name === "--project"));
@@ -259,7 +260,7 @@ export const resolveLeafArguments = ({ context, cwd, tokens, usage, }) => {
259
260
  if (call === undefined)
260
261
  return Effect.succeed(settled(unresolved(tokens)));
261
262
  const { args } = parseUsage(usage);
262
- const path = context.node === undefined ? cwd : undefined;
263
+ const path = context.node === undefined || context.node === LOCAL_NODE ? cwd : undefined;
263
264
  return locate(args, tokens).pipe(Effect.flatMap(({ given, targets }) => given.has("--attached")
264
265
  ? Effect.succeed(unresolved(tokens))
265
266
  : resolveAll(call, tokens, plan(missingScope(args, given), path, targets))), Effect.map(settled), Effect.catchTag("ReferenceRefused", reported(context)));
@@ -274,7 +275,9 @@ export const prepareLeaf = (input) => Effect.map(resolveLeafArguments(input), (o
274
275
  context.io.stderr(describeResolution(item));
275
276
  });
276
277
  return {
277
- context: changed.length === 0 ? context : { ...context, resolved: changed },
278
+ context: changed.length === 0
279
+ ? context
280
+ : { ...context, resolved: [...(context.resolved ?? []), ...changed] },
278
281
  ok: true,
279
282
  tokens: outcome.tokens,
280
283
  };
@@ -1,6 +1,82 @@
1
- import { type RemoteNodeInstallConfirmParameters, type RemoteNodeInstallPreviewParameters, type RemoteNodeListParameters, type RemoteNodeRemoveConfirmParameters, type RemoteNodeRemovePreviewParameters } from "@maiaos/sdk";
1
+ import { type RemoteNodeInstallConfirmParameters, type RemoteNodeInstallPreviewParameters, type RemoteNodeListParameters, type RemoteNodeRegisterConfirmParameters, type RemoteNodeRegisterPreviewParameters, type RemoteNodeRemoveConfirmParameters, type RemoteNodeRemovePreviewParameters } from "@maiaos/sdk";
2
2
  import type { CliNodeOperations } from "../local-node/index.js";
3
3
  export declare const makeRemoteNodeClient: (node: CliNodeOperations) => {
4
+ confirmRemoteNodeRegister: (input: RemoteNodeRegisterConfirmParameters) => import("../local-node/client.js").CliNodeEffect<{
5
+ readonly actorId: string;
6
+ readonly commandId: string;
7
+ readonly delivery: "duplicate" | "new";
8
+ readonly inputDigest: string;
9
+ readonly node: {
10
+ readonly createdAt: string;
11
+ readonly error?: {
12
+ readonly code: string;
13
+ readonly message: string;
14
+ } | undefined;
15
+ readonly executors: readonly {
16
+ readonly executor: "claude-code" | "codex-cli";
17
+ readonly interpreter?: {
18
+ readonly path: string;
19
+ readonly sha256: string;
20
+ } | undefined;
21
+ readonly path?: string | undefined;
22
+ readonly realPath?: string | undefined;
23
+ readonly reason?: string | undefined;
24
+ readonly sha256?: string | undefined;
25
+ readonly source: "discovered" | "override";
26
+ readonly state: "available" | "unavailable";
27
+ }[];
28
+ readonly host: string;
29
+ readonly installedAt?: string | undefined;
30
+ readonly launcherPath: string;
31
+ readonly maiaVersion?: string | undefined;
32
+ readonly name: string;
33
+ readonly origin?: "registered" | undefined;
34
+ readonly profile: string;
35
+ readonly releaseId?: string | undefined;
36
+ readonly remaining?: readonly string[] | undefined;
37
+ readonly revision: string;
38
+ readonly root?: string | undefined;
39
+ readonly schemaVersion: "maia.remote-node/v1";
40
+ readonly state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
41
+ readonly unitName?: string | undefined;
42
+ readonly updatedAt: string;
43
+ };
44
+ readonly receipt: {
45
+ readonly actorId: string;
46
+ readonly aggregateRevision: string;
47
+ readonly commandId: string;
48
+ readonly createdAt: string;
49
+ readonly eventCursor: string;
50
+ readonly method: string;
51
+ readonly receiptId: string;
52
+ readonly schemaVersion: 1;
53
+ readonly state: "succeeded";
54
+ readonly target: {
55
+ readonly id: string;
56
+ readonly type: string;
57
+ };
58
+ readonly updatedAt: string;
59
+ };
60
+ readonly method: "node.remote.register.confirm";
61
+ }>;
62
+ previewRemoteNodeRegister: (input: RemoteNodeRegisterPreviewParameters) => import("../local-node/client.js").CliNodeEffect<{
63
+ readonly actorId: string;
64
+ readonly expiresAt: string;
65
+ readonly inputDigest: string;
66
+ readonly issuedAt: string;
67
+ readonly proof: string;
68
+ readonly commandId: string;
69
+ readonly method: "node.remote.register.preview";
70
+ readonly name: string;
71
+ readonly plan: {
72
+ readonly host: string;
73
+ readonly instanceId: string;
74
+ readonly launcherPath: string;
75
+ readonly maiaVersion: string;
76
+ readonly profile: string;
77
+ };
78
+ readonly planDigest: string;
79
+ }>;
4
80
  confirmRemoteNodeInstall: (input: RemoteNodeInstallConfirmParameters) => import("../local-node/client.js").CliNodeEffect<{
5
81
  readonly actorId: string;
6
82
  readonly commandId: string;
@@ -30,14 +106,15 @@ export declare const makeRemoteNodeClient: (node: CliNodeOperations) => {
30
106
  readonly launcherPath: string;
31
107
  readonly maiaVersion?: string | undefined;
32
108
  readonly name: string;
109
+ readonly origin?: "registered" | undefined;
33
110
  readonly profile: string;
34
111
  readonly releaseId?: string | undefined;
35
112
  readonly remaining?: readonly string[] | undefined;
36
113
  readonly revision: string;
37
- readonly root: string;
114
+ readonly root?: string | undefined;
38
115
  readonly schemaVersion: "maia.remote-node/v1";
39
116
  readonly state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
40
- readonly unitName: string;
117
+ readonly unitName?: string | undefined;
41
118
  readonly updatedAt: string;
42
119
  };
43
120
  readonly receipt: {
@@ -172,14 +249,15 @@ export declare const makeRemoteNodeClient: (node: CliNodeOperations) => {
172
249
  readonly launcherPath: string;
173
250
  readonly maiaVersion?: string | undefined;
174
251
  readonly name: string;
252
+ readonly origin?: "registered" | undefined;
175
253
  readonly profile: string;
176
254
  readonly releaseId?: string | undefined;
177
255
  readonly remaining?: readonly string[] | undefined;
178
256
  readonly revision: string;
179
- readonly root: string;
257
+ readonly root?: string | undefined;
180
258
  readonly schemaVersion: "maia.remote-node/v1";
181
259
  readonly state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
182
- readonly unitName: string;
260
+ readonly unitName?: string | undefined;
183
261
  readonly updatedAt: string;
184
262
  };
185
263
  readonly receipt: {
@@ -226,14 +304,15 @@ export declare const makeRemoteNodeClient: (node: CliNodeOperations) => {
226
304
  readonly launcherPath: string;
227
305
  readonly maiaVersion?: string | undefined;
228
306
  readonly name: string;
307
+ readonly origin?: "registered" | undefined;
229
308
  readonly profile: string;
230
309
  readonly releaseId?: string | undefined;
231
310
  readonly remaining?: readonly string[] | undefined;
232
311
  readonly revision: string;
233
- readonly root: string;
312
+ readonly root?: string | undefined;
234
313
  readonly schemaVersion: "maia.remote-node/v1";
235
314
  readonly state: "install_failed" | "installing" | "ready" | "remove_failed" | "removed" | "removing";
236
- readonly unitName: string;
315
+ readonly unitName?: string | undefined;
237
316
  readonly updatedAt: string;
238
317
  }[];
239
318
  }>;
@@ -249,9 +328,10 @@ export declare const makeRemoteNodeClient: (node: CliNodeOperations) => {
249
328
  readonly expectedRevision: string;
250
329
  readonly method: "node.remote.remove.preview";
251
330
  readonly name: string;
331
+ readonly origin?: "registered" | undefined;
252
332
  readonly purge: boolean;
253
- readonly root: string;
254
- readonly unitName: string;
333
+ readonly root?: string | undefined;
334
+ readonly unitName?: string | undefined;
255
335
  }>;
256
336
  };
257
337
  export type RemoteNodeCliDependencies = ReturnType<typeof makeRemoteNodeClient>;
@@ -1,10 +1,15 @@
1
- import { remoteNodeInstallConfirmParametersSchema, remoteNodeInstallPreviewParametersSchema, remoteNodeListParametersSchema, remoteNodeRemoveConfirmParametersSchema, remoteNodeRemovePreviewParametersSchema, } from "@maiaos/sdk";
1
+ import { remoteNodeInstallConfirmParametersSchema, remoteNodeInstallPreviewParametersSchema, remoteNodeListParametersSchema, remoteNodeRegisterConfirmParametersSchema, remoteNodeRegisterPreviewParametersSchema, remoteNodeRemoveConfirmParametersSchema, remoteNodeRemovePreviewParametersSchema, } from "@maiaos/sdk";
2
+ const registerOperations = (node) => ({
3
+ confirmRemoteNodeRegister: (input) => node.runValidatedNodeOperation(input, remoteNodeRegisterConfirmParametersSchema, (client, parameters, options) => client.confirmRemoteNodeRegister(parameters, options), { commandId: input.commandId }),
4
+ previewRemoteNodeRegister: (input) => node.runValidatedNodeOperation(input, remoteNodeRegisterPreviewParametersSchema, (client, parameters, options) => client.previewRemoteNodeRegister(parameters, options)),
5
+ });
2
6
  const installOperations = (node) => ({
3
7
  confirmRemoteNodeInstall: (input) => node.runValidatedNodeOperation(input, remoteNodeInstallConfirmParametersSchema, (client, parameters, options) => client.confirmRemoteNodeInstall(parameters, options), { commandId: input.commandId }),
4
8
  previewRemoteNodeInstall: (input) => node.runValidatedNodeOperation(input, remoteNodeInstallPreviewParametersSchema, (client, parameters, options) => client.previewRemoteNodeInstall(parameters, options)),
5
9
  });
6
10
  export const makeRemoteNodeClient = (node) => ({
7
11
  ...installOperations(node),
12
+ ...registerOperations(node),
8
13
  confirmRemoteNodeRemove: (input) => node.runValidatedNodeOperation(input, remoteNodeRemoveConfirmParametersSchema, (client, parameters, options) => client.confirmRemoteNodeRemove(parameters, options), { commandId: input.commandId }),
9
14
  listRemoteNodes: (input) => node.runValidatedNodeOperation(input, remoteNodeListParametersSchema, (client, parameters, options) => client.listRemoteNodes(parameters, options)),
10
15
  previewRemoteNodeRemove: (input) => node.runValidatedNodeOperation(input, remoteNodeRemovePreviewParametersSchema, (client, parameters, options) => client.previewRemoteNodeRemove(parameters, options)),
@@ -1,6 +1,15 @@
1
1
  import { type CommandContext, type CommandEffect } from "../command-line/index.js";
2
2
  export declare const nameFromHost: (host: string) => string;
3
+ type Interpreter = {
4
+ readonly arch: string;
5
+ readonly execPath: string;
6
+ readonly platform: string;
7
+ readonly version: string;
8
+ };
9
+ export declare const nodeRuntimeOf: (flag: string | undefined, interpreter: Interpreter) => string;
3
10
  export declare const runNodeInstall: (tokens: readonly string[], context: CommandContext) => CommandEffect;
11
+ export declare const runNodeRegister: (tokens: readonly string[], context: CommandContext) => CommandEffect;
4
12
  export declare const runNodeList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
5
13
  export declare const runNodeRemove: (tokens: readonly string[], context: CommandContext) => CommandEffect;
14
+ export {};
6
15
  //# sourceMappingURL=commands.d.ts.map