@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) 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/bootstrap/run.js +5 -2
  28. package/dist/cli/cli.d.ts +2 -1
  29. package/dist/cli/cli.js +81 -16
  30. package/dist/command-line/context.d.ts +14 -4
  31. package/dist/command-line/context.js +1 -1
  32. package/dist/command-line/index.d.ts +6 -6
  33. package/dist/command-line/index.js +6 -5
  34. package/dist/command-line/input/arguments.d.ts +7 -0
  35. package/dist/command-line/input/arguments.js +22 -10
  36. package/dist/command-line/input/index.d.ts +2 -2
  37. package/dist/command-line/input/index.js +2 -2
  38. package/dist/command-line/input/stdin.d.ts +1 -0
  39. package/dist/command-line/input/stdin.js +1 -0
  40. package/dist/command-line/json.d.ts +1 -0
  41. package/dist/command-line/json.js +23 -0
  42. package/dist/command-line/output.d.ts +8 -1
  43. package/dist/command-line/output.js +33 -14
  44. package/dist/command-line/rows.d.ts +2 -0
  45. package/dist/command-line/rows.js +10 -1
  46. package/dist/command-line/two-phase.d.ts +5 -0
  47. package/dist/command-line/two-phase.js +33 -8
  48. package/dist/command-tree/help.d.ts +1 -1
  49. package/dist/command-tree/help.js +1 -0
  50. package/dist/command-tree/index.d.ts +2 -2
  51. package/dist/command-tree/index.js +1 -1
  52. package/dist/command-tree/local.js +12 -0
  53. package/dist/command-tree/placeholder.d.ts +1 -0
  54. package/dist/command-tree/placeholder.js +1 -0
  55. package/dist/command-tree/row.d.ts +2 -0
  56. package/dist/command-tree/tree.d.ts +3 -2
  57. package/dist/command-tree/tree.js +18 -2
  58. package/dist/connection/access/client.d.ts +13 -0
  59. package/dist/connection/access/client.js +19 -0
  60. package/dist/connection/access/commands.d.ts +6 -0
  61. package/dist/connection/access/commands.js +60 -0
  62. package/dist/connection/access/format.d.ts +8 -0
  63. package/dist/connection/access/format.js +61 -0
  64. package/dist/connection/access/index.d.ts +3 -0
  65. package/dist/connection/access/index.js +3 -0
  66. package/dist/connection/access/input.d.ts +53 -0
  67. package/dist/connection/access/input.js +83 -0
  68. package/dist/connection/client.d.ts +99 -1
  69. package/dist/connection/client.js +9 -1
  70. package/dist/connection/index.d.ts +2 -1
  71. package/dist/connection/index.js +2 -1
  72. package/dist/connection/system.d.ts +1 -0
  73. package/dist/connection/system.js +109 -5
  74. package/dist/connection/tree/tree.js +59 -8
  75. package/dist/container/output/format.js +1 -2
  76. package/dist/dashboard/cockpit-client.d.ts +6 -0
  77. package/dist/dashboard/cockpit-client.js +27 -0
  78. package/dist/dashboard/cockpits.d.ts +29 -0
  79. package/dist/dashboard/cockpits.js +65 -0
  80. package/dist/dashboard/dashboard.d.ts +7 -0
  81. package/dist/dashboard/dashboard.js +47 -0
  82. package/dist/dashboard/draw.d.ts +15 -0
  83. package/dist/dashboard/draw.js +30 -0
  84. package/dist/dashboard/frame.d.ts +4 -0
  85. package/dist/dashboard/frame.js +15 -0
  86. package/dist/dashboard/index.d.ts +2 -0
  87. package/dist/dashboard/index.js +2 -0
  88. package/dist/dashboard/modes.d.ts +5 -0
  89. package/dist/dashboard/modes.js +16 -0
  90. package/dist/dashboard/node-connection.d.ts +15 -0
  91. package/dist/dashboard/node-connection.js +51 -0
  92. package/dist/dashboard/pi-tui.d.ts +6 -0
  93. package/dist/dashboard/pi-tui.js +35 -0
  94. package/dist/dashboard/status-bar.d.ts +4 -0
  95. package/dist/dashboard/status-bar.js +60 -0
  96. package/dist/dashboard/terminal.d.ts +53 -0
  97. package/dist/dashboard/terminal.js +165 -0
  98. package/dist/dashboard/tree-model.d.ts +28 -0
  99. package/dist/dashboard/tree-model.js +97 -0
  100. package/dist/dashboard/tree.d.ts +10 -0
  101. package/dist/dashboard/tree.js +76 -0
  102. package/dist/fleet/fleet.d.ts +70 -0
  103. package/dist/fleet/fleet.js +91 -0
  104. package/dist/fleet/index.d.ts +2 -0
  105. package/dist/fleet/index.js +2 -0
  106. package/dist/hold/output/format.js +1 -5
  107. package/dist/hold/tree/tree.js +1 -0
  108. package/dist/import/commands.js +3 -4
  109. package/dist/import/output.js +1 -4
  110. package/dist/local-node/client.d.ts +9 -4
  111. package/dist/local-node/client.js +21 -9
  112. package/dist/local-node/index.d.ts +2 -1
  113. package/dist/local-node/index.js +2 -1
  114. package/dist/local-node/wait.d.ts +10 -0
  115. package/dist/local-node/wait.js +17 -0
  116. package/dist/login/commands.js +2 -1
  117. package/dist/mcp/calls.d.ts +1 -0
  118. package/dist/mcp/calls.js +37 -3
  119. package/dist/mcp/commands.d.ts +5 -2
  120. package/dist/mcp/commands.js +30 -4
  121. package/dist/mcp/routing.d.ts +24 -0
  122. package/dist/mcp/routing.js +188 -0
  123. package/dist/mcp/server.d.ts +13 -4
  124. package/dist/mcp/server.js +35 -12
  125. package/dist/presentation/output/format.js +4 -3
  126. package/dist/project-guard/commands.js +11 -2
  127. package/dist/project-workspace/commands.js +16 -6
  128. package/dist/project-workspace/output/human.d.ts +13 -0
  129. package/dist/project-workspace/output/human.js +17 -5
  130. package/dist/project-workspace/output/index.d.ts +1 -1
  131. package/dist/project-workspace/output/index.js +1 -1
  132. package/dist/project-workspace/output/metadata.js +1 -1
  133. package/dist/project-workspace/tree/tree.js +27 -12
  134. package/dist/reference/commands.js +4 -2
  135. package/dist/reference/index.d.ts +1 -1
  136. package/dist/reference/index.js +1 -1
  137. package/dist/reference/resolve.d.ts +2 -0
  138. package/dist/reference/resolve.js +28 -18
  139. package/dist/remote-node/client.d.ts +89 -9
  140. package/dist/remote-node/client.js +6 -1
  141. package/dist/remote-node/commands.d.ts +9 -0
  142. package/dist/remote-node/commands.js +96 -18
  143. package/dist/remote-node/connector.d.ts +12 -4
  144. package/dist/remote-node/connector.js +54 -26
  145. package/dist/remote-node/index.d.ts +2 -2
  146. package/dist/remote-node/index.js +2 -2
  147. package/dist/remote-node/reachability.d.ts +43 -1
  148. package/dist/remote-node/reachability.js +13 -3
  149. package/dist/remote-node/text.d.ts +2 -1
  150. package/dist/remote-node/text.js +74 -27
  151. package/dist/remote-node/tree/tree.js +21 -1
  152. package/dist/routine/client.d.ts +398 -0
  153. package/dist/routine/client.js +28 -0
  154. package/dist/routine/commands.d.ts +9 -0
  155. package/dist/routine/commands.js +109 -0
  156. package/dist/routine/index.d.ts +3 -0
  157. package/dist/routine/index.js +3 -0
  158. package/dist/routine/input.d.ts +28 -0
  159. package/dist/routine/input.js +44 -0
  160. package/dist/routine/output/format.d.ts +23 -0
  161. package/dist/routine/output/format.js +83 -0
  162. package/dist/routine/output/index.d.ts +2 -0
  163. package/dist/routine/output/index.js +2 -0
  164. package/dist/routine/tree/index.d.ts +2 -0
  165. package/dist/routine/tree/index.js +2 -0
  166. package/dist/routine/tree/tree.d.ts +3 -0
  167. package/dist/routine/tree/tree.js +70 -0
  168. package/dist/session/agent-permission.d.ts +2 -2
  169. package/dist/session/approval/commands.js +31 -9
  170. package/dist/session/approval/output/format.d.ts +11 -0
  171. package/dist/session/approval/output/format.js +8 -0
  172. package/dist/session/approval/output/index.d.ts +1 -1
  173. package/dist/session/approval/output/index.js +1 -1
  174. package/dist/session/attach-client.d.ts +1 -1
  175. package/dist/session/attach-client.js +12 -3
  176. package/dist/session/attach-render.js +15 -7
  177. package/dist/session/attach.js +17 -3
  178. package/dist/session/client.d.ts +12 -3
  179. package/dist/session/client.js +18 -17
  180. package/dist/session/commands.d.ts +1 -0
  181. package/dist/session/commands.js +120 -13
  182. package/dist/session/create-tasks.js +29 -11
  183. package/dist/session/index.d.ts +2 -2
  184. package/dist/session/index.js +2 -1
  185. package/dist/session/interaction/output/format.js +2 -1
  186. package/dist/session/output/diff.js +3 -10
  187. package/dist/session/output/failure.js +3 -10
  188. package/dist/session/output/human.d.ts +1 -0
  189. package/dist/session/output/human.js +21 -10
  190. package/dist/session/output/index.d.ts +2 -2
  191. package/dist/session/output/index.js +2 -2
  192. package/dist/session/output/tasks.d.ts +16 -1
  193. package/dist/session/output/tasks.js +41 -27
  194. package/dist/session/tree/tree.js +67 -8
  195. package/dist/session/turn/client.d.ts +4 -1
  196. package/dist/session/turn/client.js +22 -11
  197. package/dist/session/turn/commands.d.ts +2 -0
  198. package/dist/session/turn/commands.js +39 -11
  199. package/dist/session/turn/index.d.ts +3 -3
  200. package/dist/session/turn/index.js +1 -1
  201. package/dist/session/turn/output.d.ts +7 -2
  202. package/dist/session/turn/output.js +36 -13
  203. package/dist/status/client.d.ts +7 -2
  204. package/dist/status/command.js +3 -1
  205. package/dist/status/doctor.d.ts +5 -1
  206. package/dist/status/doctor.js +10 -4
  207. package/dist/status/output/compact.d.ts +1 -0
  208. package/dist/status/output/compact.js +3 -0
  209. package/dist/status/output/human.d.ts +1 -1
  210. package/dist/status/output/human.js +71 -14
  211. package/dist/team-workspace/ceremony.d.ts +19 -0
  212. package/dist/team-workspace/ceremony.js +141 -0
  213. package/dist/team-workspace/client.d.ts +58 -0
  214. package/dist/team-workspace/client.js +6 -0
  215. package/dist/team-workspace/commands.d.ts +3 -0
  216. package/dist/team-workspace/commands.js +85 -0
  217. package/dist/team-workspace/confirmation.d.ts +4 -0
  218. package/dist/team-workspace/confirmation.js +8 -0
  219. package/dist/team-workspace/dependencies.d.ts +8 -0
  220. package/dist/team-workspace/dependencies.js +2 -0
  221. package/dist/team-workspace/index.d.ts +6 -0
  222. package/dist/team-workspace/index.js +5 -0
  223. package/dist/team-workspace/launcher.d.ts +17 -0
  224. package/dist/team-workspace/launcher.js +30 -0
  225. package/dist/team-workspace/output.d.ts +15 -0
  226. package/dist/team-workspace/output.js +28 -0
  227. package/dist/team-workspace/terminal.d.ts +9 -0
  228. package/dist/team-workspace/terminal.js +46 -0
  229. package/dist/terminal/client.d.ts +4 -0
  230. package/dist/terminal/client.js +3 -0
  231. package/dist/terminal/commands.js +37 -25
  232. package/dist/terminal/control-commands.js +26 -9
  233. package/dist/terminal/keys.d.ts +12 -0
  234. package/dist/terminal/keys.js +62 -0
  235. package/dist/terminal/output/compact-list.d.ts +1 -0
  236. package/dist/terminal/output/compact-list.js +1 -0
  237. package/dist/terminal/output/human.d.ts +2 -19
  238. package/dist/terminal/output/human.js +6 -6
  239. package/dist/terminal/tree/tree.js +16 -16
  240. package/package.json +10 -8
@@ -1,6 +1,6 @@
1
- import type { FailureDetail, TurnInterruptResult, TurnShowResult, TurnTokenUsage, TurnWaitResult } from "@maiaos/sdk";
1
+ import type { FailureDetail, TurnInterruptResult, TurnQueueListResult, TurnShowResult, TurnTokenUsage, TurnWaitResult } from "@maiaos/sdk";
2
2
  export type CliTurnMutation = {
3
- readonly command: "turn.interrupt" | "turn.send";
3
+ readonly command: "turn.cancel" | "turn.interrupt" | "turn.send";
4
4
  readonly result: {
5
5
  readonly delivery: TurnInterruptResult["delivery"];
6
6
  readonly receipt: TurnInterruptResult["receipt"];
@@ -35,7 +35,12 @@ export type CliTurnWait = {
35
35
  readonly command: "turn.wait";
36
36
  readonly result: TurnWaitResult;
37
37
  };
38
+ export type CliTurnQueue = {
39
+ readonly command: "turn.queue.list";
40
+ readonly result: TurnQueueListResult;
41
+ };
38
42
  export declare const formatTurnMutation: ({ result }: CliTurnMutation) => string;
43
+ export declare const formatTurnQueue: ({ result }: CliTurnQueue) => string;
39
44
  export declare const formatTurnShow: ({ result }: CliTurnShow) => string;
40
45
  export declare const formatTurnWait: ({ result }: CliTurnWait) => string;
41
46
  export declare const turnWaitExitCode: (result: TurnWaitResult) => number;
@@ -1,17 +1,40 @@
1
+ import { block, cell, fields, formatRows, tab, } from "../../command-line/index.js";
1
2
  import { formatFailure } from "../output/index.js";
2
- const tab = (values) => values.join("\t");
3
- const printable = (text) => Array.from(text, (character) => {
4
- const point = character.codePointAt(0) ?? 0;
5
- return (point < 32 && character !== "\n" && character !== "\t") ||
6
- (point >= 127 && point <= 159)
7
- ? "�"
8
- : character;
9
- }).join("");
10
- export const formatTurnMutation = ({ result }) => `${result.turnId}\t${result.state}\t${result.revision}\n`;
3
+ export const formatTurnMutation = ({ result }) => fields([
4
+ ["turn", result.turnId],
5
+ ["state", result.state],
6
+ ["revision", result.revision],
7
+ ]);
8
+ const turnFields = (turn, reason) => fields([
9
+ ["turn", turn.id],
10
+ ["state", turn.state],
11
+ ["revision", turn.revision],
12
+ ["session", turn.sessionId],
13
+ ["reason", reason],
14
+ ]);
15
+ export const formatTurnQueue = ({ result }) => {
16
+ const { activeTurn, queue } = result;
17
+ const rows = [
18
+ ...(activeTurn === undefined
19
+ ? []
20
+ : [["-", activeTurn.state, activeTurn.id, activeTurn.revision, ""]]),
21
+ ...queue.map((entry) => [
22
+ String(entry.position),
23
+ "queued",
24
+ entry.id,
25
+ entry.revision,
26
+ cell(entry.inputPreview.replaceAll(/\s+/gu, " ")),
27
+ ]),
28
+ ];
29
+ return formatRows(rows, tab, {
30
+ empty: "no running or queued turn",
31
+ headers: ["POSITION", "STATE", "TURN", "REVISION", "INPUT"],
32
+ });
33
+ };
11
34
  const formatUsage = (usage) => usage === undefined
12
35
  ? ""
13
36
  : `tokens: input ${String(usage.inputTokens)} (cached ${String(usage.cachedInputTokens)}), output ${String(usage.outputTokens)} (reasoning ${String(usage.reasoningOutputTokens)}), total ${String(usage.totalTokens)}${usage.modelCallCount === undefined ? "" : `, model calls ${String(usage.modelCallCount)}`}\n`;
14
- const formatContent = (turn) => `input:\n${printable(turn.input.text)}\n${turn.state === "completed" ? `response:\n${printable(turn.responseText)}\n` : ""}`;
37
+ const formatContent = (turn) => `input:\n${block(turn.input.text)}\n${turn.state === "completed" ? `response:\n${block(turn.responseText)}\n` : ""}`;
15
38
  const shownContent = (result) => result.contentIncluded ? formatContent(result.turn) : "";
16
39
  export const formatTurnShow = ({ result }) => {
17
40
  const { turn } = result;
@@ -20,11 +43,11 @@ export const formatTurnShow = ({ result }) => {
20
43
  ? formatFailure(turn.failure, turn.state)
21
44
  : "";
22
45
  const usage = "tokenUsage" in turn ? formatUsage(turn.tokenUsage) : "";
23
- return `${tab([turn.id, turn.state, turn.revision, turn.sessionId])}\n${failure}${usage}${shownContent(result)}`;
46
+ return `${turnFields(turn)}${failure}${usage}${shownContent(result)}`;
24
47
  };
25
48
  export const formatTurnWait = ({ result }) => result.turns
26
- .map((turn) => `${tab([turn.id, turn.state, turn.revision, turn.sessionId, ...(turn.failureReason === undefined ? [] : [turn.failureReason])])}\n${turn.state === "failed" || turn.state === "outcome-unknown" ? formatFailure(turn.failure, turn.state) : ""}`)
27
- .join("");
49
+ .map((turn) => `${turnFields(turn, turn.failureReason)}${turn.state === "failed" || turn.state === "outcome-unknown" ? formatFailure(turn.failure, turn.state) : ""}`)
50
+ .join("\n");
28
51
  const EXIT_FAILED = 70;
29
52
  const EXIT_DEADLINE = 74;
30
53
  const EXIT_OUTCOME_UNKNOWN = 76;
@@ -8,6 +8,11 @@ export declare const makeStatusClient: (node: CliNodeOperations) => {
8
8
  readonly pid: number;
9
9
  readonly profile: string;
10
10
  readonly startedAt: string;
11
+ readonly executorHost?: {
12
+ readonly bubblewrap: "found" | "missing";
13
+ readonly socat: "found" | "missing";
14
+ readonly userNamespaces: "allowed" | "no_nesting" | "restricted";
15
+ } | undefined;
11
16
  readonly method: "node.status";
12
17
  readonly processResources: {
13
18
  readonly activeTrees: number;
@@ -42,7 +47,7 @@ export declare const makeStatusClient: (node: CliNodeOperations) => {
42
47
  };
43
48
  readonly cleanupUnknownTrees: number;
44
49
  readonly fencedTrees: number;
45
- readonly nextStep: "close_idle_terminal" | "inspect_cleanup_unknown" | "inspect_observed_pressure" | "none" | "verify_native_host";
50
+ readonly nextStep: "close_idle_terminal" | "inspect_cleanup_unknown" | "inspect_observed_pressure" | "none" | "run_node_in_delegated_cgroup" | "verify_native_host";
46
51
  readonly observations: {
47
52
  readonly cpuTimeMilliseconds: {
48
53
  readonly availableTrees: number;
@@ -102,7 +107,7 @@ export declare const makeStatusClient: (node: CliNodeOperations) => {
102
107
  };
103
108
  readonly treeCount: number;
104
109
  };
105
- readonly pressure: "admission_degraded" | "cleanup_unknown" | "healthy" | "observed_pressure" | "warning";
110
+ readonly pressure: "admission_degraded" | "cgroup_delegation_unavailable" | "cleanup_unknown" | "healthy" | "observed_pressure" | "warning";
106
111
  readonly supervision: {
107
112
  readonly trackedTrees: number;
108
113
  readonly watcherFibers: number;
@@ -14,7 +14,9 @@ const unavailableError = (cause) => {
14
14
  const remote = Predicate.hasProperty(error, "remoteError")
15
15
  ? protocolErrorSchema.safeParse(error.remoteError)
16
16
  : undefined;
17
- return remote?.success === true && remote.data.code === "node_unavailable"
17
+ return remote?.success === true &&
18
+ (remote.data.code === "node_unavailable" ||
19
+ remote.data.code === "invalid_argument")
18
20
  ? remote.data
19
21
  : createUnavailableError();
20
22
  };
@@ -5,9 +5,13 @@ export type DoctorCheck = {
5
5
  readonly next?: string;
6
6
  readonly ok: boolean;
7
7
  };
8
+ export type DoctorScope = "machine" | "node";
8
9
  export type CliDoctorResult = {
9
- readonly checks: readonly DoctorCheck[];
10
+ readonly checks: readonly (DoctorCheck & {
11
+ readonly scope: DoctorScope;
12
+ })[];
10
13
  readonly command: "doctor";
14
+ readonly node?: string;
11
15
  readonly ok: boolean;
12
16
  readonly version: string;
13
17
  };
@@ -1,6 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Option from "effect/Option";
3
- import { requireNoArguments, writeSuccess, } from "../command-line/index.js";
3
+ import { LOCAL_NODE, requireNoArguments, writeSuccess, } from "../command-line/index.js";
4
4
  const EXIT_FAILED = 70;
5
5
  const vendorWords = (executor) => executor === "codex-cli"
6
6
  ? { integration: "codex", login: "codex" }
@@ -71,8 +71,8 @@ const nodeChecks = (detected, connections) => {
71
71
  ]),
72
72
  ];
73
73
  };
74
- const formatDoctor = (result) => `Maia doctor ${result.ok ? "ok" : "failed"}\n${result.checks
75
- .map((check) => ` ${check.code}: ${check.ok ? "ok" : "failed"}${check.detail === undefined ? "" : ` (${check.detail})`}${check.ok || check.next === undefined ? "" : `; next: ${check.next}`}\n`)
74
+ const formatDoctor = (result) => `Maia doctor ${result.ok ? "ok" : "failed"}${result.node === undefined ? "" : ` (Node ${result.node})`}\n${result.checks
75
+ .map((check) => ` ${check.code}${check.scope === "machine" ? " (this machine)" : ""}: ${check.ok ? "ok" : "failed"}${check.detail === undefined ? "" : ` (${check.detail})`}${check.ok || check.next === undefined ? "" : `; next: ${check.next}`}\n`)
76
76
  .join("")}`;
77
77
  const readLifecycle = (dependencies) => Effect.map(Effect.option(Effect.map(Effect.suspend(() => dependencies.readStatus()), (node) => node.lifecycle)), Option.getOrUndefined);
78
78
  const nodeCheck = (lifecycle) => lifecycle === undefined
@@ -100,8 +100,14 @@ export const runDoctor = (tokens, context) => Effect.gen(function* () {
100
100
  const checks = yield* readChecks(context);
101
101
  const ok = checks.every((check) => check.ok);
102
102
  const result = {
103
- checks,
103
+ checks: checks.map((check) => ({
104
+ ...check,
105
+ scope: check.code === "cli" ? "machine" : "node",
106
+ })),
104
107
  command: "doctor",
108
+ ...(context.node === undefined || context.node === LOCAL_NODE
109
+ ? {}
110
+ : { node: context.node }),
105
111
  ok,
106
112
  version: context.version,
107
113
  };
@@ -2,6 +2,7 @@ import type { LocalNodeStatusResult } from "@maiaos/sdk";
2
2
  export declare const sumObservationWarningTrees: (observations: LocalNodeStatusResult["processResources"]["observations"]) => number;
3
3
  export type CliCompactStatusResult = {
4
4
  readonly command: "status";
5
+ readonly executorHost?: LocalNodeStatusResult["executorHost"];
5
6
  readonly instanceId: LocalNodeStatusResult["instanceId"];
6
7
  readonly lifecycle: LocalNodeStatusResult["lifecycle"];
7
8
  readonly pid: LocalNodeStatusResult["pid"];
@@ -26,6 +26,9 @@ const projectStatusCapability = (capability) => ({
26
26
  });
27
27
  export const projectStatusResult = (node) => ({
28
28
  command: "status",
29
+ ...(node.executorHost === undefined
30
+ ? {}
31
+ : { executorHost: node.executorHost }),
29
32
  instanceId: node.instanceId,
30
33
  lifecycle: node.lifecycle,
31
34
  pid: node.pid,
@@ -3,5 +3,5 @@ export type CliStatusResult = {
3
3
  readonly command: "status";
4
4
  readonly node: LocalNodeStatusResult;
5
5
  };
6
- export declare const formatHumanStatus: (result: CliStatusResult) => string;
6
+ export declare const formatHumanStatus: ({ node }: CliStatusResult) => string;
7
7
  //# sourceMappingURL=human.d.ts.map
@@ -8,23 +8,80 @@ const processResourceNextStep = (nextStep) => {
8
8
  return "inspect per-tree pressure warnings; termination stays disabled";
9
9
  case "none":
10
10
  return "none";
11
+ case "run_node_in_delegated_cgroup":
12
+ return "restart the Node in a cgroup delegated to its user: a systemd user unit with Delegate=yes and DelegateSubgroup=node, or systemd-run --user -p Delegate=yes -p DelegateSubgroup=node";
11
13
  case "verify_native_host":
12
14
  return "verify the native process host";
13
15
  }
14
16
  };
15
- const formatObservedMetric = (label, metric) => `${label} ${metric.state}${metric.maximumValue === undefined ? "" : ` max ${String(metric.maximumValue)}`}; budget ${metric.budget}; ${String(metric.warningTrees)} warning`;
16
- export const formatHumanStatus = (result) => {
17
- const { node } = result;
18
- const resources = node.processResources;
19
- const observed = resources.observations;
20
- return `Maia node ${node.lifecycle}\n profile: ${node.profile}\n pid: ${String(node.pid)}\n instance: ${node.instanceId}\n storage: ${node.storage.integrity} (${node.storage.journalMode})\n process resources: ${resources.pressure} (${resources.capability.mode}; hard limits ${resources.capability.hardLimitEnforcement}; release qualified ${String(resources.capability.releaseQualified)})\n admission: ${resources.admission.state}; ${String(resources.admission.usedTrees)}/${String(resources.admission.capacity)} used; ${String(resources.admission.availableTrees)} available; ${String(resources.admission.queuedSpawns)} queued\n ownership: ${String(resources.activeTrees)} active; ${String(resources.fencedTrees)} fenced; ${String(resources.cleanupUnknownTrees)} cleanup unknown; ${String(resources.supervision.watcherFibers)} watcher fibers\n latest target observations: ${[
21
- formatObservedMetric("cpu-ms", observed.cpuTimeMilliseconds),
22
- formatObservedMetric("rss-bytes", observed.rssBytes),
23
- formatObservedMetric("peak-rss-bytes", observed.observedPeakRssBytes),
24
- formatObservedMetric("processes", observed.processCount),
25
- formatObservedMetric("fds", observed.fileDescriptorCount),
26
- formatObservedMetric("io-read-bytes", observed.ioReadBytes),
27
- formatObservedMetric("io-write-bytes", observed.ioWriteBytes),
28
- ].join("; ")}\n observed-pressure termination: ${resources.capability.observedPressureTermination}; samples are advisory, not hard enforcement or automatic kill\n inspect: --json compact; SDK lossless\n next step: ${processResourceNextStep(resources.nextStep)}\n get started: maia doctor checks accounts and integrations; maia setup uses the installed CLIs\n`;
17
+ const OBSERVED_METRICS = [
18
+ ["cpu-ms", "cpuTimeMilliseconds"],
19
+ ["rss-bytes", "rssBytes"],
20
+ ["peak-rss-bytes", "observedPeakRssBytes"],
21
+ ["processes", "processCount"],
22
+ ["fds", "fileDescriptorCount"],
23
+ ["io-read-bytes", "ioReadBytes"],
24
+ ["io-write-bytes", "ioWriteBytes"],
25
+ ];
26
+ const formatMetric = (label, metric, trees) => {
27
+ const parts = [
28
+ metric.maximumValue === undefined
29
+ ? ""
30
+ : `max ${String(metric.maximumValue)}`,
31
+ metric.unavailableTrees === 0
32
+ ? ""
33
+ : `${String(metric.unavailableTrees)} of ${String(trees)} unmeasured`,
34
+ metric.warningTrees === 0 ? "" : `${String(metric.warningTrees)} warning`,
35
+ ].filter(Boolean);
36
+ return metric.budget === "declared_per_tree_limit" && parts.length > 0
37
+ ? [`${label} ${parts.join(", ")}`]
38
+ : [];
39
+ };
40
+ const processResourceLines = ({ admission, capability, cleanupUnknownTrees, fencedTrees, nextStep, observations, pressure, }) => {
41
+ const measured = OBSERVED_METRICS.flatMap(([label, key]) => formatMetric(label, observations[key], observations.treeCount));
42
+ return [
43
+ `process resources: ${pressure} (${capability.mode}; hard limits ${capability.hardLimitEnforcement})`,
44
+ `capacity: ${String(admission.usedTrees)}/${String(admission.capacity)} process trees in use${admission.state === "available" ? "" : `; ${admission.state}`}`,
45
+ ...(cleanupUnknownTrees === 0
46
+ ? []
47
+ : [
48
+ `ownership: ${String(fencedTrees)} fenced; ${String(cleanupUnknownTrees)} cleanup unknown`,
49
+ ]),
50
+ `observations: ${measured.length === 0 ? "none yet" : measured.join("; ")}`,
51
+ ...(nextStep === "none"
52
+ ? []
53
+ : [`next step: ${processResourceNextStep(nextStep)}`]),
54
+ ];
55
+ };
56
+ const BOTH = "refuses Codex and coding Claude Code Sessions";
57
+ const CODING_CLAUDE = "refuses coding Claude Code Sessions";
58
+ const executorHostLines = (host) => {
59
+ if (host === undefined)
60
+ return [];
61
+ const userNamespaces = {
62
+ allowed: "user namespaces: allowed",
63
+ ["no_nesting"]: `user namespaces: no_nesting (${CODING_CLAUDE}); next step: the owner sets kernel.apparmor_restrict_unprivileged_userns=0 and stops enforcing the unpriv_bwrap AppArmor profile`,
64
+ restricted: `user namespaces: restricted (${BOTH}); next step: the owner sets kernel.apparmor_restrict_unprivileged_userns=0`,
65
+ };
66
+ return [
67
+ host.bubblewrap === "found"
68
+ ? "bubblewrap: found"
69
+ : `bubblewrap: missing (${BOTH}); next step: the owner installs the bubblewrap package`,
70
+ host.socat === "found"
71
+ ? "socat: found"
72
+ : `socat: missing (${CODING_CLAUDE}); next step: the owner installs the socat package`,
73
+ userNamespaces[host.userNamespaces],
74
+ ];
75
+ };
76
+ export const formatHumanStatus = ({ node }) => {
77
+ const lines = [
78
+ `profile: ${node.profile}`,
79
+ `pid: ${String(node.pid)}`,
80
+ `instance: ${node.instanceId}`,
81
+ `storage: ${node.storage.integrity} (${node.storage.journalMode})`,
82
+ ...processResourceLines(node.processResources),
83
+ ...executorHostLines(node.executorHost),
84
+ ];
85
+ return `Maia node ${node.lifecycle}\n${lines.map((line) => ` ${line}\n`).join("")}`;
29
86
  };
30
87
  //# sourceMappingURL=human.js.map
@@ -0,0 +1,19 @@
1
+ import { type ProtocolError, type TeamWorkspaceBootstrapPreviewParameters } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Ref from "effect/Ref";
4
+ import { CliArgumentError, type CliDependencies, type CommandContext } from "../command-line/index.js";
5
+ import type { CliMutationRecovery } from "../local-node/index.js";
6
+ import type { BootstrapNode } from "./launcher.js";
7
+ export type BootstrapDependencies = Required<Pick<CliDependencies, "applyBootstrap" | "confirmOnTerminal" | "getReceipt" | "previewBootstrap" | "startBootstrapNode">>;
8
+ export type Ceremony = {
9
+ readonly context: CommandContext;
10
+ readonly dependencies: BootstrapDependencies;
11
+ readonly node: BootstrapNode;
12
+ readonly parameters: TeamWorkspaceBootstrapPreviewParameters;
13
+ readonly profile: string;
14
+ readonly sent: Ref.Ref<boolean>;
15
+ };
16
+ export declare const nodeUnavailable: (message: string) => ProtocolError;
17
+ export declare const recoveryFor: ({ parameters, profile, }: Pick<Ceremony, "parameters" | "profile">) => CliMutationRecovery;
18
+ export declare const runCeremony: (ceremony: Ceremony) => Effect.Effect<number, CliArgumentError, import("effect/Crypto").Crypto>;
19
+ //# sourceMappingURL=ceremony.d.ts.map
@@ -0,0 +1,141 @@
1
+ import { TEAM_WORKSPACE_BOOTSTRAP_PREVIEW_TTL_MILLISECONDS, teamWorkspaceBootstrapApplyResultSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Predicate from "effect/Predicate";
4
+ import * as Ref from "effect/Ref";
5
+ import * as Schedule from "effect/Schedule";
6
+ import { CliArgumentError, EXIT_CANCELLED, reportError, writeNodeResult, } from "../command-line/index.js";
7
+ import { confirmationFrame, confirmationPhrase } from "./confirmation.js";
8
+ import { describePreview, formatBootstrapOutput, toBootstrapOutput, } from "./output.js";
9
+ const READY_DEADLINE = "30 seconds";
10
+ const READY_INTERVAL = "100 millis";
11
+ const DEFINITE_REFUSALS = new Set([
12
+ "bootstrap_authority_unavailable",
13
+ "bootstrap_binding_mismatch",
14
+ "bootstrap_confirmation_required",
15
+ "bootstrap_preview_expired",
16
+ ]);
17
+ const RESERVED_IDENTIFIERS = [
18
+ "clientId",
19
+ "deviceId",
20
+ "nodeId",
21
+ "teamWorkspaceId",
22
+ "userId",
23
+ ];
24
+ export const nodeUnavailable = (message) => ({
25
+ code: "node_unavailable",
26
+ message,
27
+ retryable: true,
28
+ });
29
+ const failed = (error) => ({
30
+ error,
31
+ ok: false,
32
+ });
33
+ const integrityFailed = (message) => failed({ code: "bootstrap_integrity_failed", message, retryable: false });
34
+ const previewWhenReady = (ceremony) => Effect.suspend(() => ceremony.dependencies.previewBootstrap(ceremony.parameters)).pipe(Effect.repeat({
35
+ schedule: Schedule.spaced(READY_INTERVAL),
36
+ until: (result) => result.ok || result.error.code !== "node_unavailable",
37
+ }), Effect.timeoutOrElse({
38
+ duration: READY_DEADLINE,
39
+ orElse: () => Effect.succeed(failed(nodeUnavailable("The Node did not become ready in 30 seconds."))),
40
+ }));
41
+ const askPerson = (ceremony, preview) => ceremony.dependencies
42
+ .confirmOnTerminal({
43
+ description: describePreview({
44
+ ownerDisplayName: ceremony.parameters.ownerDisplayName,
45
+ preview,
46
+ profile: ceremony.profile,
47
+ workspaceName: ceremony.parameters.workspaceName,
48
+ }),
49
+ expected: confirmationPhrase(preview),
50
+ })
51
+ .pipe(Effect.timeoutOrElse({
52
+ duration: TEAM_WORKSPACE_BOOTSTRAP_PREVIEW_TTL_MILLISECONDS,
53
+ orElse: () => Effect.succeed("expired"),
54
+ }));
55
+ const withoutApproval = (ceremony, answer) => {
56
+ const { context } = ceremony;
57
+ if (answer === "unavailable")
58
+ return Effect.fail(new CliArgumentError("No controlling terminal: run this command in a terminal. A pipe or redirect cannot confirm."));
59
+ if (answer === "expired")
60
+ return Effect.succeed(reportError({
61
+ code: "bootstrap_preview_expired",
62
+ message: "The preview expired before it was confirmed; run the command again.",
63
+ retryable: false,
64
+ }, context));
65
+ return Effect.sync(() => {
66
+ context.io.stderr("Cancelled; nothing changed.\n");
67
+ return EXIT_CANCELLED;
68
+ });
69
+ };
70
+ const matchesPreview = (result, preview) => result.commandId === preview.commandId &&
71
+ result.inputDigest === preview.inputDigest &&
72
+ result.previewId === preview.previewId &&
73
+ RESERVED_IDENTIFIERS.every((key) => result[key] === preview[key]);
74
+ const settle = (result, preview) => result.ok && !matchesPreview(result.value, preview)
75
+ ? integrityFailed("The Node's result does not match the confirmed preview.")
76
+ : result;
77
+ const recovered = (receipt, preview) => {
78
+ const parsed = Predicate.isObject(receipt.result)
79
+ ? teamWorkspaceBootstrapApplyResultSchema.safeParse({
80
+ ...receipt.result,
81
+ receipt: receipt.receipt,
82
+ })
83
+ : { success: false };
84
+ return parsed.success
85
+ ? settle({ ok: true, value: parsed.data }, preview)
86
+ : integrityFailed("The stored receipt is not this bootstrap's result.");
87
+ };
88
+ const afterRetry = (result, unknown) => {
89
+ if (result.ok)
90
+ return result;
91
+ const { code } = result.error;
92
+ if (code === "bootstrap_already_completed")
93
+ return integrityFailed("The Node is owned but holds no receipt for this command; bootstrap is not repeated.");
94
+ return DEFINITE_REFUSALS.has(code) ? result : unknown;
95
+ };
96
+ const applyParametersFor = (parameters, preview) => ({
97
+ ...parameters,
98
+ inputDigest: preview.inputDigest,
99
+ previewId: preview.previewId,
100
+ });
101
+ const reconcile = (ceremony, preview, unknown) => Effect.gen(function* () {
102
+ const { dependencies, parameters } = ceremony;
103
+ const receipt = yield* Effect.suspend(() => dependencies.getReceipt(parameters.commandId));
104
+ if (receipt.ok)
105
+ return recovered(receipt.value, preview);
106
+ if (receipt.error.code !== "resource_not_found")
107
+ return unknown;
108
+ const retried = yield* Effect.suspend(() => dependencies.applyBootstrap(applyParametersFor(parameters, preview)));
109
+ return settle(afterRetry(retried, unknown), preview);
110
+ });
111
+ const applyOnce = (ceremony, preview) => Effect.suspend(() => ceremony.dependencies.applyBootstrap(applyParametersFor(ceremony.parameters, preview))).pipe(Effect.flatMap((result) => !result.ok && result.error.code === "outcome_unknown"
112
+ ? reconcile(ceremony, preview, result)
113
+ : Effect.succeed(settle(result, preview))));
114
+ export const recoveryFor = ({ parameters, profile, }) => ({
115
+ commandId: parameters.commandId,
116
+ profile,
117
+ });
118
+ const withRecovery = (result, ceremony) => !result.ok && result.recovery !== undefined
119
+ ? { ...result, recovery: recoveryFor(ceremony) }
120
+ : result;
121
+ const confirmAndApply = (ceremony, preview) => ceremony.node.sendConfirmation(confirmationFrame(preview)).pipe(Effect.matchEffect({
122
+ onFailure: (error) => Effect.succeed(reportError({
123
+ code: "bootstrap_channel_invalid",
124
+ message: error.message,
125
+ retryable: false,
126
+ }, ceremony.context)),
127
+ onSuccess: () => Ref.set(ceremony.sent, true).pipe(Effect.andThen(applyOnce(ceremony, preview)), Effect.map((result) => writeNodeResult(withRecovery(result, ceremony), ceremony.context, {
128
+ toResult: toBootstrapOutput,
129
+ toText: formatBootstrapOutput,
130
+ }))),
131
+ }));
132
+ export const runCeremony = (ceremony) => Effect.gen(function* () {
133
+ const previewed = yield* previewWhenReady(ceremony);
134
+ if (!previewed.ok)
135
+ return reportError(previewed.error, ceremony.context);
136
+ const answer = yield* askPerson(ceremony, previewed.value);
137
+ return answer === "confirmed"
138
+ ? yield* confirmAndApply(ceremony, previewed.value)
139
+ : yield* withoutApproval(ceremony, answer);
140
+ });
141
+ //# sourceMappingURL=ceremony.js.map
@@ -0,0 +1,58 @@
1
+ import { type TeamWorkspaceBootstrapApplyParameters, type TeamWorkspaceBootstrapPreviewParameters } from "@maiaos/sdk";
2
+ import type { CliNodeOperations } from "../local-node/index.js";
3
+ export declare const makeBootstrapClient: (node: CliNodeOperations) => {
4
+ applyBootstrap: (input: TeamWorkspaceBootstrapApplyParameters) => import("../local-node/client.js").CliNodeEffect<{
5
+ readonly clientId: string;
6
+ readonly deviceId: string;
7
+ readonly nodeId: string;
8
+ readonly teamWorkspaceId: string;
9
+ readonly userId: string;
10
+ readonly authoritySource: "local-os-profile-owner";
11
+ readonly bootstrapRevision: "1";
12
+ readonly commandId: string;
13
+ readonly delivery: "duplicate" | "new";
14
+ readonly inputDigest: string;
15
+ readonly method: "team-workspace.bootstrap.apply";
16
+ readonly previewId: string;
17
+ readonly receipt: {
18
+ readonly actorId: string;
19
+ readonly aggregateRevision: string;
20
+ readonly commandId: string;
21
+ readonly createdAt: string;
22
+ readonly eventCursor: string;
23
+ readonly method: string;
24
+ readonly receiptId: string;
25
+ readonly schemaVersion: 1;
26
+ readonly state: "succeeded";
27
+ readonly target: {
28
+ readonly id: string;
29
+ readonly type: string;
30
+ };
31
+ readonly updatedAt: string;
32
+ };
33
+ readonly releaseQualified: false;
34
+ readonly role: "owner";
35
+ readonly schemaVersion: 1;
36
+ }>;
37
+ previewBootstrap: (input: TeamWorkspaceBootstrapPreviewParameters) => import("../local-node/client.js").CliNodeEffect<{
38
+ readonly clientId: string;
39
+ readonly deviceId: string;
40
+ readonly nodeId: string;
41
+ readonly teamWorkspaceId: string;
42
+ readonly userId: string;
43
+ readonly authoritySource: "local-os-profile-owner";
44
+ readonly commandId: string;
45
+ readonly expectedBootstrapRevision: "0";
46
+ readonly expiresAt: string;
47
+ readonly inputDigest: string;
48
+ readonly issuedAt: string;
49
+ readonly method: "team-workspace.bootstrap.preview";
50
+ readonly nodeEpoch: string;
51
+ readonly previewId: string;
52
+ readonly releaseQualified: false;
53
+ readonly role: "owner";
54
+ readonly schemaVersion: 1;
55
+ }>;
56
+ };
57
+ export type BootstrapClientDependencies = ReturnType<typeof makeBootstrapClient>;
58
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { teamWorkspaceBootstrapApplyParametersSchema, teamWorkspaceBootstrapPreviewParametersSchema, } from "@maiaos/sdk";
2
+ export const makeBootstrapClient = (node) => ({
3
+ applyBootstrap: (input) => node.runValidatedNodeOperation(input, teamWorkspaceBootstrapApplyParametersSchema, (client, parameters, options) => client.applyTeamWorkspaceBootstrap(parameters, options), { commandId: input.commandId }),
4
+ previewBootstrap: (input) => node.runValidatedNodeOperation(input, teamWorkspaceBootstrapPreviewParametersSchema, (client, parameters, options) => client.previewTeamWorkspaceBootstrap(parameters, options)),
5
+ });
6
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,3 @@
1
+ import { type CommandContext, type CommandEffect } from "../command-line/index.js";
2
+ export declare const runNodeBootstrap: (tokens: readonly string[], context: CommandContext) => CommandEffect;
3
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,85 @@
1
+ import { TEAM_WORKSPACE_BOOTSTRAP_SCHEMA_VERSION, teamWorkspaceBootstrapPreviewParametersSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Ref from "effect/Ref";
4
+ import { CliArgumentError, parseOptions, reportError, requirePositionals, } from "../command-line/index.js";
5
+ import { commandIdentifier } from "../local-node/index.js";
6
+ import { nodeUnavailable, recoveryFor, runCeremony, } from "./ceremony.js";
7
+ const OPTIONS = new Set(["--command-id", "--owner-name", "--workspace-name"]);
8
+ const requiredOption = (options, name) => {
9
+ const value = options.get(name);
10
+ if (value === undefined)
11
+ throw new CliArgumentError(`Option '${name}' is required.`);
12
+ return value;
13
+ };
14
+ const requiredProfile = (context) => {
15
+ if (context.profile === undefined)
16
+ throw new CliArgumentError("Option '--profile' is required: it names the profile whose Node this command starts.");
17
+ return context.profile;
18
+ };
19
+ const requireTerminalSession = (context) => {
20
+ if (context.io.interactive !== true)
21
+ throw new CliArgumentError("A person must confirm at a terminal: run this with standard input and error attached to a terminal and without '--no-input'.");
22
+ };
23
+ const readRequest = (tokens, context) => {
24
+ const parsed = parseOptions(tokens, OPTIONS);
25
+ requirePositionals(parsed.positionals, 0);
26
+ const profile = requiredProfile(context);
27
+ requireTerminalSession(context);
28
+ const commandId = parsed.options.get("--command-id");
29
+ return {
30
+ ...(commandId === undefined ? {} : { commandId }),
31
+ ownerDisplayName: requiredOption(parsed.options, "--owner-name"),
32
+ profile,
33
+ workspaceName: requiredOption(parsed.options, "--workspace-name"),
34
+ };
35
+ };
36
+ const requireDependencies = (context) => {
37
+ const { applyBootstrap, confirmOnTerminal, getReceipt, previewBootstrap, startBootstrapNode, } = context.dependencies;
38
+ if (applyBootstrap === undefined ||
39
+ confirmOnTerminal === undefined ||
40
+ previewBootstrap === undefined ||
41
+ startBootstrapNode === undefined)
42
+ throw new CliArgumentError("This CLI cannot bootstrap a Node.");
43
+ return {
44
+ applyBootstrap,
45
+ confirmOnTerminal,
46
+ getReceipt,
47
+ previewBootstrap,
48
+ startBootstrapNode,
49
+ };
50
+ };
51
+ const previewParametersFor = (request) => Effect.gen(function* () {
52
+ const parsed = teamWorkspaceBootstrapPreviewParametersSchema.safeParse({
53
+ commandId: yield* commandIdentifier(request.commandId),
54
+ expectedBootstrapRevision: "0",
55
+ ownerDisplayName: request.ownerDisplayName,
56
+ schemaVersion: TEAM_WORKSPACE_BOOTSTRAP_SCHEMA_VERSION,
57
+ workspaceName: request.workspaceName,
58
+ });
59
+ return parsed.success
60
+ ? parsed.data
61
+ : yield* new CliArgumentError("The bootstrap input is invalid: a name is 1 to 160 UTF-8 bytes of NFC text without control characters or edge whitespace, and '--command-id' is a protocol identifier.");
62
+ });
63
+ const reportExit = (node, ceremony) => node.exited.pipe(Effect.catch((error) => Effect.map(Ref.get(ceremony.sent), (confirmed) => reportError(nodeUnavailable(error.message), {
64
+ ...ceremony.context,
65
+ ...(confirmed ? { recovery: recoveryFor(ceremony) } : {}),
66
+ }))));
67
+ const supervise = (plan) => plan.dependencies.startBootstrapNode(plan.profile).pipe(Effect.matchEffect({
68
+ onFailure: (error) => Effect.succeed(reportError(nodeUnavailable(error.message), plan.context)),
69
+ onSuccess: (node) => Effect.flatMap(Ref.make(false), (sent) => {
70
+ const ceremony = { ...plan, node, sent };
71
+ return Effect.raceFirst(runCeremony(ceremony), reportExit(node, ceremony));
72
+ }),
73
+ }));
74
+ const plan = (request, context, parameters) => ({
75
+ context,
76
+ dependencies: requireDependencies(context),
77
+ parameters,
78
+ profile: request.profile,
79
+ });
80
+ export const runNodeBootstrap = (tokens, context) => Effect.gen(function* () {
81
+ const request = readRequest(tokens, context);
82
+ const parameters = yield* previewParametersFor(request);
83
+ return yield* Effect.scoped(supervise(plan(request, context, parameters)));
84
+ });
85
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,4 @@
1
+ import type { TeamWorkspaceBootstrapPreviewResult } from "@maiaos/sdk";
2
+ export declare const confirmationFrame: (preview: Pick<TeamWorkspaceBootstrapPreviewResult, "commandId" | "inputDigest" | "nodeEpoch" | "previewId">) => string;
3
+ export declare const confirmationPhrase: (preview: Pick<TeamWorkspaceBootstrapPreviewResult, "previewId">) => string;
4
+ //# sourceMappingURL=confirmation.d.ts.map
@@ -0,0 +1,8 @@
1
+ export const confirmationFrame = (preview) => JSON.stringify({
2
+ commandId: preview.commandId,
3
+ inputDigest: preview.inputDigest,
4
+ nodeEpoch: preview.nodeEpoch,
5
+ previewId: preview.previewId,
6
+ });
7
+ export const confirmationPhrase = (preview) => `YES ${preview.previewId}`;
8
+ //# sourceMappingURL=confirmation.js.map