@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
@@ -0,0 +1,61 @@
1
+ import { formatRows, tab, withNextPage } from "../../command-line/index.js";
2
+ const scopeCell = (scope) => `${scope.kind === "project" ? "project" : "container"}:${scope.id}`;
3
+ const grantLine = (grant) => tab([
4
+ grant.grantId,
5
+ grant.connectionId,
6
+ scopeCell(grant.scope),
7
+ grant.state,
8
+ `revision=${grant.revision}`,
9
+ ]);
10
+ const poolLine = (pool) => tab([
11
+ pool.poolId,
12
+ scopeCell(pool.scope),
13
+ pool.mode,
14
+ pool.members.length === 0 ? "-" : pool.members.join(","),
15
+ `revision=${pool.revision}`,
16
+ ]);
17
+ const grantPreviewLines = (result) => [
18
+ result.current === undefined
19
+ ? tab([result.connectionId, scopeCell(result.scope), "none", "current"])
20
+ : `${grantLine(result.current)}\tcurrent`,
21
+ tab([
22
+ result.connectionId,
23
+ scopeCell(result.scope),
24
+ result.granted ? "grant" : "revoke",
25
+ "proposed",
26
+ `command=${result.commandId}`,
27
+ `expires=${result.expiresAt}`,
28
+ ]),
29
+ ].join("\n");
30
+ const poolPreviewLines = (result) => [
31
+ result.current === undefined
32
+ ? tab([scopeCell(result.scope), "none", "current"])
33
+ : `${poolLine(result.current)}\tcurrent`,
34
+ tab([
35
+ scopeCell(result.scope),
36
+ result.mode,
37
+ result.members.length === 0 ? "-" : result.members.join(","),
38
+ "proposed",
39
+ `command=${result.commandId}`,
40
+ `expires=${result.expiresAt}`,
41
+ ]),
42
+ ].join("\n");
43
+ const confirmed = (line, result) => tab([line, result.receipt.receiptId, result.delivery]);
44
+ const formatLines = (result) => {
45
+ switch (result.method) {
46
+ case "connection.grant.list":
47
+ return withNextPage(formatRows(result.items, grantLine, "No grants."), result.nextCursor).trimEnd();
48
+ case "connection.pool.list":
49
+ return withNextPage(formatRows(result.items, poolLine, "No pools."), result.nextCursor).trimEnd();
50
+ case "connection.grant.set.preview":
51
+ return grantPreviewLines(result);
52
+ case "connection.pool.set.preview":
53
+ return poolPreviewLines(result);
54
+ case "connection.grant.set.confirm":
55
+ return confirmed(grantLine(result.grant), result);
56
+ case "connection.pool.set.confirm":
57
+ return confirmed(poolLine(result.pool), result);
58
+ }
59
+ };
60
+ export const formatConnectionAccessResult = ({ result, }) => `${formatLines(result)}\n`;
61
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,3 @@
1
+ export { makeConnectionAccessClient } from "./client.js";
2
+ export { runConnectionGrantList, runConnectionGrantSet, runConnectionPoolList, runConnectionPoolSet, } from "./commands.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { makeConnectionAccessClient } from "./client.js";
2
+ export { runConnectionGrantList, runConnectionGrantSet, runConnectionPoolList, runConnectionPoolSet, } from "./commands.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,53 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { type ParsedOptions } from "../../command-line/index.js";
3
+ type PoolMode = "off" | "rotate" | "single";
4
+ export declare const readGrantList: (tokens: readonly string[]) => {
5
+ afterCursor?: string | undefined;
6
+ limit: number;
7
+ scope?: undefined;
8
+ connectionId?: string | undefined;
9
+ state?: "active" | "revoked" | undefined;
10
+ } | {
11
+ afterCursor?: string | undefined;
12
+ limit: number;
13
+ scope: {
14
+ readonly id: string;
15
+ readonly kind: "project" | "workspace";
16
+ };
17
+ connectionId?: string | undefined;
18
+ state?: "active" | "revoked" | undefined;
19
+ };
20
+ export declare const readPoolList: (tokens: readonly string[]) => {
21
+ afterCursor?: string | undefined;
22
+ limit: number;
23
+ scope?: undefined;
24
+ } | {
25
+ afterCursor?: string | undefined;
26
+ limit: number;
27
+ scope: {
28
+ readonly id: string;
29
+ readonly kind: "project" | "workspace";
30
+ };
31
+ };
32
+ export declare const GRANT_SET_OPTIONS: ReadonlySet<string>;
33
+ export declare const readGrantPreview: (parsed: ParsedOptions) => Effect.Effect<{
34
+ commandId: string;
35
+ connectionId: string;
36
+ granted: boolean;
37
+ scope: {
38
+ readonly id: string;
39
+ readonly kind: "project" | "workspace";
40
+ };
41
+ }, never, import("effect/Crypto").Crypto>;
42
+ export declare const POOL_SET_OPTIONS: ReadonlySet<string>;
43
+ export declare const readPoolPreview: (parsed: ParsedOptions) => Effect.Effect<{
44
+ commandId: string;
45
+ members: readonly string[];
46
+ mode: PoolMode;
47
+ scope: {
48
+ readonly id: string;
49
+ readonly kind: "project" | "workspace";
50
+ };
51
+ }, never, import("effect/Crypto").Crypto>;
52
+ export {};
53
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1,83 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { CliArgumentError, parseOptions, readPageSize, requirePositionals, } from "../../command-line/index.js";
3
+ import { commandIdentifier } from "../../local-node/index.js";
4
+ const SCOPE_OPTIONS = ["--container", "--project"];
5
+ const isMode = (value) => value === "off" || value === "rotate" || value === "single";
6
+ const isState = (value) => value === "active" || value === "revoked";
7
+ const readScope = (options) => {
8
+ const project = options.get("--project");
9
+ const container = options.get("--container");
10
+ if (project !== undefined && container !== undefined)
11
+ throw new CliArgumentError("Use one of '--project' or '--container'.");
12
+ if (project !== undefined)
13
+ return { id: project, kind: "project" };
14
+ return container === undefined
15
+ ? undefined
16
+ : { id: container, kind: "workspace" };
17
+ };
18
+ const requireScope = (options) => {
19
+ const scope = readScope(options);
20
+ if (scope === undefined)
21
+ throw new CliArgumentError("Use one of '--project' or '--container'.");
22
+ return scope;
23
+ };
24
+ const readPage = (options) => {
25
+ const afterCursor = options.get("--after");
26
+ return {
27
+ ...(afterCursor === undefined ? {} : { afterCursor }),
28
+ limit: readPageSize(options.get("--limit")),
29
+ };
30
+ };
31
+ const withScope = (scope) => scope === undefined ? {} : { scope };
32
+ export const readGrantList = (tokens) => {
33
+ const parsed = parseOptions(tokens, new Set([
34
+ ...SCOPE_OPTIONS,
35
+ "--after",
36
+ "--connection",
37
+ "--limit",
38
+ "--state",
39
+ ]));
40
+ requirePositionals(parsed.positionals, 0);
41
+ const connectionId = parsed.options.get("--connection");
42
+ const state = parsed.options.get("--state");
43
+ if (state !== undefined && !isState(state))
44
+ throw new CliArgumentError("Option '--state' must be 'active' or 'revoked'.");
45
+ return {
46
+ ...readPage(parsed.options),
47
+ ...(connectionId === undefined ? {} : { connectionId }),
48
+ ...withScope(readScope(parsed.options)),
49
+ ...(state === undefined ? {} : { state }),
50
+ };
51
+ };
52
+ export const readPoolList = (tokens) => {
53
+ const parsed = parseOptions(tokens, new Set([...SCOPE_OPTIONS, "--after", "--limit"]));
54
+ requirePositionals(parsed.positionals, 0);
55
+ return {
56
+ ...readPage(parsed.options),
57
+ ...withScope(readScope(parsed.options)),
58
+ };
59
+ };
60
+ export const GRANT_SET_OPTIONS = new Set([
61
+ ...SCOPE_OPTIONS,
62
+ "--command-id",
63
+ ]);
64
+ export const readGrantPreview = (parsed) => {
65
+ requirePositionals(parsed.positionals, 1);
66
+ const scope = requireScope(parsed.options);
67
+ const connectionId = parsed.positionals[0] ?? "";
68
+ const granted = !parsed.flags.has("--revoke");
69
+ return Effect.map(commandIdentifier(parsed.options.get("--command-id")), (commandId) => ({ commandId, connectionId, granted, scope }));
70
+ };
71
+ export const POOL_SET_OPTIONS = new Set([
72
+ ...SCOPE_OPTIONS,
73
+ "--command-id",
74
+ "--mode",
75
+ ]);
76
+ export const readPoolPreview = (parsed) => {
77
+ const scope = requireScope(parsed.options);
78
+ const mode = parsed.options.get("--mode") ?? "";
79
+ if (!isMode(mode))
80
+ throw new CliArgumentError("Option '--mode' must be 'off', 'rotate' or 'single'.");
81
+ return Effect.map(commandIdentifier(parsed.options.get("--command-id")), (commandId) => ({ commandId, members: parsed.positionals, mode, scope }));
82
+ };
83
+ //# sourceMappingURL=input.js.map
@@ -1,6 +1,12 @@
1
- import { type ConnectionCapacitySetParameters, type ConnectionCreateParameters, type ConnectionDetectParameters, type ConnectionGatewayCreateParameters, type ConnectionListParameters, type ConnectionLoginStartParameters, type ConnectionModelsListParameters, type ConnectionShowParameters, type ConnectionStateSetParameters, type ConnectionSystemConfirmParameters, type ConnectionSystemPreviewParameters, type ConnectionUsageShowParameters } from "@maiaos/sdk";
1
+ import { type ConnectionCapacitySetParameters, type ConnectionCreateParameters, type ConnectionDetectParameters, type ConnectionGatewayCreateParameters, type ConnectionListParameters, type ConnectionLoginStartParameters, type ConnectionModelsListParameters, type ConnectionShowParameters, type ConnectionStateSetParameters, type ConnectionSystemConfirmParameters, type ConnectionSystemPreviewParameters, type ConnectionUpkeepConfirmParameters, type ConnectionUpkeepPreviewParameters, type ConnectionUpkeepRefreshParameters, type ConnectionUsageShowParameters } from "@maiaos/sdk";
2
2
  import type { CliNodeOperations } from "../local-node/index.js";
3
3
  export declare const makeConnectionClient: (node: CliNodeOperations) => {
4
+ confirmConnectionGrant: import("./access/client.js").Operation<import("@maiaos/sdk").ConnectionGrantSetConfirmParameters, import("@maiaos/sdk").ConnectionGrantSetConfirmResult>;
5
+ confirmConnectionPool: import("./access/client.js").Operation<import("@maiaos/sdk").ConnectionPoolSetConfirmParameters, import("@maiaos/sdk").ConnectionPoolSetConfirmResult>;
6
+ listConnectionGrants: import("./access/client.js").Operation<import("@maiaos/sdk").ConnectionGrantListParameters, import("@maiaos/sdk").ConnectionGrantListResult>;
7
+ listConnectionPools: import("./access/client.js").Operation<import("@maiaos/sdk").ConnectionPoolListParameters, import("@maiaos/sdk").ConnectionPoolListResult>;
8
+ previewConnectionGrant: import("./access/client.js").Operation<import("@maiaos/sdk").ConnectionGrantSetPreviewParameters, import("@maiaos/sdk").ConnectionGrantSetPreviewResult>;
9
+ previewConnectionPool: import("./access/client.js").Operation<import("@maiaos/sdk").ConnectionPoolSetPreviewParameters, import("@maiaos/sdk").ConnectionPoolSetPreviewResult>;
4
10
  listConnectionModels: (input: ConnectionModelsListParameters) => import("../local-node/client.js").CliNodeEffect<{
5
11
  readonly connectionId: string;
6
12
  readonly format: "anthropic" | "openai";
@@ -600,6 +606,22 @@ export declare const makeConnectionClient: (node: CliNodeOperations) => {
600
606
  } | undefined;
601
607
  readonly executableApproved: boolean;
602
608
  readonly executor: "claude-code" | "codex-cli";
609
+ readonly upkeep?: {
610
+ readonly approved?: {
611
+ readonly launchable: "unknown" | "yes";
612
+ readonly version?: string | undefined;
613
+ } | undefined;
614
+ readonly available?: {
615
+ readonly checkedAt: string;
616
+ readonly source: "npm-registry";
617
+ readonly version: string;
618
+ } | undefined;
619
+ readonly policy: "notify" | "off";
620
+ readonly proposal?: {
621
+ readonly command: string;
622
+ readonly kind: "approve-installed" | "update-available";
623
+ } | undefined;
624
+ } | undefined;
603
625
  readonly workerPrompt?: "failed" | "inconclusive" | "ok" | undefined;
604
626
  }, {
605
627
  readonly accountKind?: string | undefined;
@@ -624,6 +646,22 @@ export declare const makeConnectionClient: (node: CliNodeOperations) => {
624
646
  } | undefined;
625
647
  readonly executableApproved: boolean;
626
648
  readonly executor: "claude-code" | "codex-cli";
649
+ readonly upkeep?: {
650
+ readonly approved?: {
651
+ readonly launchable: "unknown" | "yes";
652
+ readonly version?: string | undefined;
653
+ } | undefined;
654
+ readonly available?: {
655
+ readonly checkedAt: string;
656
+ readonly source: "npm-registry";
657
+ readonly version: string;
658
+ } | undefined;
659
+ readonly policy: "notify" | "off";
660
+ readonly proposal?: {
661
+ readonly command: string;
662
+ readonly kind: "approve-installed" | "update-available";
663
+ } | undefined;
664
+ } | undefined;
627
665
  readonly workerPrompt?: "failed" | "inconclusive" | "ok" | undefined;
628
666
  }];
629
667
  readonly method: "connection.detect";
@@ -687,6 +725,66 @@ export declare const makeConnectionClient: (node: CliNodeOperations) => {
687
725
  readonly method: "connection.system.preview";
688
726
  readonly proof: string;
689
727
  }>;
728
+ confirmConnectionUpkeep: (input: ConnectionUpkeepConfirmParameters) => import("../local-node/client.js").CliNodeEffect<{
729
+ readonly actorId: string;
730
+ readonly commandId: string;
731
+ readonly delivery: "duplicate" | "new";
732
+ readonly executor: "claude-code" | "codex-cli";
733
+ readonly inputDigest: string;
734
+ readonly method: "connection.upkeep.confirm";
735
+ readonly policy: "notify" | "off";
736
+ readonly policyRevision: number;
737
+ readonly receipt: {
738
+ readonly actorId: string;
739
+ readonly aggregateRevision: string;
740
+ readonly commandId: string;
741
+ readonly createdAt: string;
742
+ readonly eventCursor: string;
743
+ readonly method: string;
744
+ readonly receiptId: string;
745
+ readonly schemaVersion: 1;
746
+ readonly state: "succeeded";
747
+ readonly target: {
748
+ readonly id: string;
749
+ readonly type: string;
750
+ };
751
+ readonly updatedAt: string;
752
+ };
753
+ }>;
754
+ previewConnectionUpkeep: (input: ConnectionUpkeepPreviewParameters) => import("../local-node/client.js").CliNodeEffect<{
755
+ readonly actorId: string;
756
+ readonly authorizationRevision: number;
757
+ readonly commandId: string;
758
+ readonly current: "notify" | "off";
759
+ readonly executor: "claude-code" | "codex-cli";
760
+ readonly expiresAt: string;
761
+ readonly inputDigest: string;
762
+ readonly issuedAt: string;
763
+ readonly method: "connection.upkeep.preview";
764
+ readonly policy: "notify" | "off";
765
+ readonly policyRevision: number;
766
+ readonly proof: string;
767
+ }>;
768
+ refreshConnectionUpkeep: (input: ConnectionUpkeepRefreshParameters) => import("../local-node/client.js").CliNodeEffect<{
769
+ readonly executors: readonly [{
770
+ readonly available?: {
771
+ readonly checkedAt: string;
772
+ readonly source: "npm-registry";
773
+ readonly version: string;
774
+ } | undefined;
775
+ readonly executor: "claude-code" | "codex-cli";
776
+ readonly refreshed: boolean;
777
+ }, {
778
+ readonly available?: {
779
+ readonly checkedAt: string;
780
+ readonly source: "npm-registry";
781
+ readonly version: string;
782
+ } | undefined;
783
+ readonly executor: "claude-code" | "codex-cli";
784
+ readonly refreshed: boolean;
785
+ }];
786
+ readonly method: "connection.upkeep.refresh";
787
+ }>;
690
788
  };
691
789
  export type ConnectionCliDependencies = ReturnType<typeof makeConnectionClient>;
692
790
  //# sourceMappingURL=client.d.ts.map
@@ -1,4 +1,5 @@
1
- import { connectionCapacitySetParametersSchema, connectionCreateParametersSchema, connectionDetectParametersSchema, connectionGatewayCreateParametersSchema, connectionListParametersSchema, connectionLoginStartParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionStateSetParametersSchema, connectionSystemConfirmParametersSchema, connectionSystemPreviewParametersSchema, connectionUsageShowParametersSchema, } from "@maiaos/sdk";
1
+ import { connectionCapacitySetParametersSchema, connectionCreateParametersSchema, connectionDetectParametersSchema, connectionGatewayCreateParametersSchema, connectionListParametersSchema, connectionLoginStartParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionStateSetParametersSchema, connectionSystemConfirmParametersSchema, connectionSystemPreviewParametersSchema, connectionUpkeepConfirmParametersSchema, connectionUpkeepPreviewParametersSchema, connectionUpkeepRefreshParametersSchema, connectionUsageShowParametersSchema, } from "@maiaos/sdk";
2
+ import { makeConnectionAccessClient } from "./access/index.js";
2
3
  const readClient = (node) => ({
3
4
  listConnectionModels: (input) => node.runValidatedNodeOperation(input, connectionModelsListParametersSchema, (client, parameters, options) => client.listConnectionModels(parameters, options)),
4
5
  listConnections: (input) => node.runValidatedNodeOperation(input, connectionListParametersSchema, (client, parameters, options) => client.listConnections(parameters, options)),
@@ -19,10 +20,17 @@ const systemClient = (node) => ({
19
20
  detectConnections: (input) => node.runValidatedNodeOperation(input, connectionDetectParametersSchema, (client, parameters, options) => client.detectConnections(parameters, options)),
20
21
  previewSystemConnections: (input) => node.runValidatedNodeOperation(input, connectionSystemPreviewParametersSchema, (client, parameters, options) => client.previewSystemConnections(parameters, options)),
21
22
  });
23
+ const upkeepClient = (node) => ({
24
+ confirmConnectionUpkeep: (input) => node.runValidatedNodeOperation(input, connectionUpkeepConfirmParametersSchema, (client, parameters, options) => client.confirmConnectionUpkeep(parameters, options), { commandId: input.commandId }),
25
+ previewConnectionUpkeep: (input) => node.runValidatedNodeOperation(input, connectionUpkeepPreviewParametersSchema, (client, parameters, options) => client.previewConnectionUpkeep(parameters, options)),
26
+ refreshConnectionUpkeep: (input) => node.runValidatedNodeOperation(input, connectionUpkeepRefreshParametersSchema, (client, parameters, options) => client.refreshConnectionUpkeep(parameters, options)),
27
+ });
22
28
  export const makeConnectionClient = (node) => ({
29
+ ...makeConnectionAccessClient(node),
23
30
  ...readClient(node),
24
31
  ...mutationClient(node),
25
32
  ...signInClient(node),
26
33
  ...systemClient(node),
34
+ ...upkeepClient(node),
27
35
  });
28
36
  //# sourceMappingURL=client.js.map
@@ -1,7 +1,8 @@
1
+ export { runConnectionGrantList, runConnectionGrantSet, runConnectionPoolList, runConnectionPoolSet, } from "./access/index.js";
1
2
  export { type ConnectionCliDependencies, makeConnectionClient, } from "./client.js";
2
3
  export { runConnectionCapacitySet, runConnectionCreate, runConnectionDisable, runConnectionEnable, runConnectionList, runConnectionLoginStart, runConnectionModelsList, runConnectionShow, runConnectionUsageShow, type VendorLogin, } from "./commands.js";
3
4
  export { runVendorLogin } from "./login.js";
4
5
  export { describeConnection, formatConnectionResult, redactConnection, redactConnectionResult, } from "./output/index.js";
5
6
  export { callNode, ConnectionNodeError, findConnectionByName, } from "./resolve.js";
6
- export { runConnectionDetect, runSetup } from "./system.js";
7
+ export { runConnectionDetect, runConnectionUpdatePolicySet, runSetup, } from "./system.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,8 @@
1
+ export { runConnectionGrantList, runConnectionGrantSet, runConnectionPoolList, runConnectionPoolSet, } from "./access/index.js";
1
2
  export { makeConnectionClient, } from "./client.js";
2
3
  export { runConnectionCapacitySet, runConnectionCreate, runConnectionDisable, runConnectionEnable, runConnectionList, runConnectionLoginStart, runConnectionModelsList, runConnectionShow, runConnectionUsageShow, } from "./commands.js";
3
4
  export { runVendorLogin } from "./login.js";
4
5
  export { describeConnection, formatConnectionResult, redactConnection, redactConnectionResult, } from "./output/index.js";
5
6
  export { callNode, ConnectionNodeError, findConnectionByName, } from "./resolve.js";
6
- export { runConnectionDetect, runSetup } from "./system.js";
7
+ export { runConnectionDetect, runConnectionUpdatePolicySet, runSetup, } from "./system.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  import { type CommandContext, type CommandEffect } from "../command-line/index.js";
2
2
  export declare const runConnectionDetect: (tokens: readonly string[], context: CommandContext) => CommandEffect;
3
3
  export declare const runSetup: (tokens: readonly string[], context: CommandContext) => CommandEffect;
4
+ export declare const runConnectionUpdatePolicySet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
4
5
  //# sourceMappingURL=system.d.ts.map
@@ -1,7 +1,7 @@
1
- import { connectionSystemConfirmParametersSchema, } from "@maiaos/sdk";
1
+ import { connectionSystemConfirmParametersSchema, connectionUpkeepConfirmParametersSchema, } from "@maiaos/sdk";
2
2
  import * as Data from "effect/Data";
3
3
  import * as Effect from "effect/Effect";
4
- import { askToConfirm, CliArgumentError, confirmParameters, EXIT_CANCELLED, parseOptions, promptOrRefuse, readPipedPreview, reportError, requestedTwoPhaseMode, requirePositionals, TWO_PHASE_FLAGS, } from "../command-line/index.js";
4
+ import { askToConfirm, CliArgumentError, confirmParameters, EXIT_CANCELLED, jsonLine, parseOptions, promptOrRefuse, readPipedPreview, reportError, requestedTwoPhaseMode, requirePositionals, TWO_PHASE_FLAGS, } from "../command-line/index.js";
5
5
  import { commandIdentifier, } from "../local-node/index.js";
6
6
  class SetupNodeError extends Data.TaggedError("SetupNodeError") {
7
7
  }
@@ -11,7 +11,7 @@ const required = (effect) => effect === undefined
11
11
  ? Effect.succeed(result.value)
12
12
  : Effect.fail(new SetupNodeError({ error: result.error })));
13
13
  const write = (context, output, text) => {
14
- context.io.stdout(context.json ? `${JSON.stringify({ ok: true, result: output })}\n` : text);
14
+ context.io.stdout(context.json ? jsonLine({ ok: true, result: output }) : text);
15
15
  };
16
16
  const nodeLocal = (value) => ({
17
17
  ...value,
@@ -35,6 +35,33 @@ const signIn = (item) => {
35
35
  return `signed in${kind}`;
36
36
  return item.auth === "none" ? "signed out" : "sign-in unknown";
37
37
  };
38
+ const APPROVED_BUILD = {
39
+ unknown: "not checked",
40
+ yes: "launches",
41
+ };
42
+ const PROPOSALS = {
43
+ ["approve-installed"]: (command) => `the installed build is not the approved one; review it with '${command}'`,
44
+ ["update-available"]: (command) => `a newer version is out; update with '${command}' (Maia never runs the vendor's updater)`,
45
+ };
46
+ const newestText = (available) => available === undefined
47
+ ? "not checked; run 'maia connection detect --refresh'"
48
+ : `${available.version} on the npm registry, a proxy for the vendor's own channel (checked ${available.checkedAt})`;
49
+ const upkeepText = ({ upkeep }) => {
50
+ if (upkeep === undefined)
51
+ return [];
52
+ const { approved, available, policy, proposal } = upkeep;
53
+ return [
54
+ ` newest version: ${newestText(available)}; update policy: ${policy}`,
55
+ ...(approved === undefined
56
+ ? []
57
+ : [
58
+ ` approved build: ${approved.version === undefined ? "" : `${approved.version} `}${APPROVED_BUILD[approved.launchable]}`,
59
+ ]),
60
+ ...(proposal === undefined
61
+ ? []
62
+ : [` next: ${PROPOSALS[proposal.kind](proposal.command)}`]),
63
+ ];
64
+ };
38
65
  const detectedText = (item) => {
39
66
  if (!item.binary.found)
40
67
  return `${item.executor}: not installed\n`;
@@ -46,12 +73,24 @@ const detectedText = (item) => {
46
73
  `${item.executor} ${version ?? "(version unknown)"} ${path}${onNodePath ? "" : " (not on the Node's PATH)"}`,
47
74
  ` ${signIn(item)}; ${account}; executable ${item.executableApproved ? "approved" : "not approved"}`,
48
75
  ...(item.endpoint?.hint === undefined ? [] : [` ${item.endpoint.hint}`]),
76
+ ...upkeepText(item),
49
77
  "",
50
78
  ].join("\n");
51
79
  };
80
+ const refreshNewest = (context) => required(context.dependencies.refreshConnectionUpkeep?.({})).pipe(Effect.map(({ executors }) => executors
81
+ .filter((item) => !item.refreshed)
82
+ .map((item) => `a newer ${item.executor} version`)), Effect.catch(() => Effect.succeed(["newer versions"])), Effect.map((unchecked) => {
83
+ if (unchecked.length > 0)
84
+ context.io.stderr(unchecked
85
+ .map((what) => `Could not check for ${what}; showing the last answer.\n`)
86
+ .join(""));
87
+ }));
52
88
  export const runConnectionDetect = (tokens, context) => Effect.gen(function* () {
53
- requirePositionals(tokens, 0);
54
- const detected = yield* required(context.dependencies.detectConnections?.({}));
89
+ const parsed = parseOptions(tokens, new Set(), new Set(["--refresh"]));
90
+ requirePositionals(parsed.positionals, 0);
91
+ if (parsed.flags.has("--refresh"))
92
+ yield* refreshNewest(context);
93
+ const detected = yield* required(context.dependencies.detectConnections?.({ upkeep: true }));
55
94
  write(context, { command: "connection.detect", result: markDetected(detected) }, detected.executors.map(detectedText).join(""));
56
95
  return 0;
57
96
  }).pipe(Effect.catch(reportSetupFailure(context)));
@@ -176,6 +215,71 @@ export const runSetup = (tokens, context) => Effect.gen(function* () {
176
215
  }
177
216
  return writeConfirmed(context, yield* confirm(context, plan), plan);
178
217
  }).pipe(Effect.catch(reportSetupFailure(context)));
218
+ const readPolicyChange = (parsed) => {
219
+ const [executor, policy] = parsed.positionals;
220
+ if (executor !== "claude-code" && executor !== "codex-cli")
221
+ throw new CliArgumentError("The CLI must be claude-code or codex-cli.");
222
+ if (policy !== "off" && policy !== "notify")
223
+ throw new CliArgumentError("The update policy must be off or notify.");
224
+ return { executor, policy };
225
+ };
226
+ const POLICY_EFFECT = {
227
+ notify: "Maia proposes updates in 'maia connection detect'.",
228
+ off: "Maia stops proposing updates; detection still shows the facts.",
229
+ };
230
+ const policyText = (plan) => `${plan.executor}: update policy ${plan.current} -> ${plan.policy}. ${POLICY_EFFECT[plan.policy]}\n`;
231
+ const policyConfirmedText = (result) => `${result.executor}: update policy ${result.policy} (receipt ${result.receipt.receiptId})\n`;
232
+ const confirmPolicy = (context, preview) => Effect.gen(function* () {
233
+ const parameters = yield* confirmParameters(connectionUpkeepConfirmParametersSchema, preview, ["authorizationRevision", "current", "policyRevision"]);
234
+ return yield* required(context.dependencies.confirmConnectionUpkeep?.(parameters));
235
+ });
236
+ const previewPolicy = (context, parsed, change) => Effect.flatMap(commandIdentifier(parsed.options.get("--command-id")), (commandId) => required(context.dependencies.previewConnectionUpkeep?.({
237
+ commandId,
238
+ ...change,
239
+ })));
240
+ const writePolicySet = (context, result, plan) => {
241
+ write(context, {
242
+ command: "connection.update-policy.set",
243
+ result: { ...(plan === undefined ? {} : { preview: plan }), result },
244
+ }, policyConfirmedText(result));
245
+ return 0;
246
+ };
247
+ const writePolicyUnchanged = (context, plan) => {
248
+ write(context, { command: "connection.update-policy.set", result: { preview: plan } }, `${plan.executor}: update policy is already ${plan.policy}; nothing changed.\n`);
249
+ return 0;
250
+ };
251
+ const writePolicyDryRun = (context, plan) => {
252
+ write(context, { command: "connection.upkeep.preview", result: plan }, `${policyText(plan)}Confirm with: maia --json connection update-policy set ${plan.executor} ${plan.policy} --dry-run | maia connection update-policy set --confirm-stdin\n`);
253
+ return 0;
254
+ };
255
+ const readPolicyRequest = (tokens) => {
256
+ const parsed = parseOptions(tokens, new Set(["--command-id"]), new Set(["--yes", ...TWO_PHASE_FLAGS]));
257
+ const requested = requestedTwoPhaseMode(parsed.flags, true);
258
+ requirePositionals(parsed.positionals, requested === "confirm-stdin" ? 0 : 2);
259
+ return { parsed, requested };
260
+ };
261
+ const approvedByPerson = (context, requested, plan) => Effect.gen(function* () {
262
+ const mode = requested ?? promptOrRefuse(context, true);
263
+ if (!context.json)
264
+ context.io.stdout(policyText(plan));
265
+ if (mode !== "prompt" || (yield* askToConfirm(context, "Change it?")))
266
+ return true;
267
+ context.io.stderr("Cancelled; nothing changed.\n");
268
+ return false;
269
+ });
270
+ export const runConnectionUpdatePolicySet = (tokens, context) => Effect.gen(function* () {
271
+ const { parsed, requested } = readPolicyRequest(tokens);
272
+ if (requested === "confirm-stdin")
273
+ return writePolicySet(context, yield* confirmPolicy(context, yield* readPipedPreview(context)));
274
+ const plan = yield* previewPolicy(context, parsed, readPolicyChange(parsed));
275
+ if (requested === "dry-run")
276
+ return writePolicyDryRun(context, plan);
277
+ if (plan.current === plan.policy)
278
+ return writePolicyUnchanged(context, plan);
279
+ if (!(yield* approvedByPerson(context, requested, plan)))
280
+ return EXIT_CANCELLED;
281
+ return writePolicySet(context, yield* confirmPolicy(context, plan), plan);
282
+ }).pipe(Effect.catch(reportSetupFailure(context)));
179
283
  const reportSetupFailure = (context) => (error) => Effect.sync(() => reportError(error instanceof SetupNodeError
180
284
  ? error.error
181
285
  : {