@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -265
- package/dist/address-space/address-space.d.ts +38 -0
- package/dist/address-space/address-space.js +130 -0
- package/dist/address-space/index.d.ts +2 -0
- package/dist/address-space/index.js +2 -0
- package/dist/agents/client.d.ts +171 -0
- package/dist/agents/client.js +8 -0
- package/dist/agents/commands.d.ts +7 -0
- package/dist/agents/commands.js +65 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/input.d.ts +130 -0
- package/dist/agents/input.js +99 -0
- package/dist/agents/output/format.d.ts +8 -0
- package/dist/agents/output/format.js +47 -0
- package/dist/agents/output/index.d.ts +2 -0
- package/dist/agents/output/index.js +2 -0
- package/dist/agents/tree/index.d.ts +2 -0
- package/dist/agents/tree/index.js +2 -0
- package/dist/agents/tree/tree.d.ts +3 -0
- package/dist/agents/tree/tree.js +43 -0
- package/dist/bin/maia.cdx.json +37 -14
- package/dist/bin/maia.mjs +1 -1
- package/dist/bootstrap/exit.d.ts +14 -0
- package/dist/bootstrap/exit.js +42 -0
- package/dist/bootstrap/process.js +4 -26
- package/dist/bootstrap/run.js +5 -2
- package/dist/cli/cli.d.ts +2 -1
- package/dist/cli/cli.js +81 -16
- package/dist/command-line/context.d.ts +14 -4
- package/dist/command-line/context.js +1 -1
- package/dist/command-line/index.d.ts +6 -6
- package/dist/command-line/index.js +6 -5
- package/dist/command-line/input/arguments.d.ts +7 -0
- package/dist/command-line/input/arguments.js +22 -10
- package/dist/command-line/input/index.d.ts +2 -2
- package/dist/command-line/input/index.js +2 -2
- package/dist/command-line/input/stdin.d.ts +1 -0
- package/dist/command-line/input/stdin.js +1 -0
- package/dist/command-line/json.d.ts +1 -0
- package/dist/command-line/json.js +23 -0
- package/dist/command-line/output.d.ts +8 -1
- package/dist/command-line/output.js +33 -14
- package/dist/command-line/rows.d.ts +2 -0
- package/dist/command-line/rows.js +10 -1
- package/dist/command-line/two-phase.d.ts +5 -0
- package/dist/command-line/two-phase.js +33 -8
- package/dist/command-tree/help.d.ts +1 -1
- package/dist/command-tree/help.js +1 -0
- package/dist/command-tree/index.d.ts +2 -2
- package/dist/command-tree/index.js +1 -1
- package/dist/command-tree/local.js +12 -0
- package/dist/command-tree/placeholder.d.ts +1 -0
- package/dist/command-tree/placeholder.js +1 -0
- package/dist/command-tree/row.d.ts +2 -0
- package/dist/command-tree/tree.d.ts +3 -2
- package/dist/command-tree/tree.js +18 -2
- package/dist/connection/access/client.d.ts +13 -0
- package/dist/connection/access/client.js +19 -0
- package/dist/connection/access/commands.d.ts +6 -0
- package/dist/connection/access/commands.js +60 -0
- package/dist/connection/access/format.d.ts +8 -0
- package/dist/connection/access/format.js +61 -0
- package/dist/connection/access/index.d.ts +3 -0
- package/dist/connection/access/index.js +3 -0
- package/dist/connection/access/input.d.ts +53 -0
- package/dist/connection/access/input.js +83 -0
- package/dist/connection/client.d.ts +99 -1
- package/dist/connection/client.js +9 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.js +2 -1
- package/dist/connection/system.d.ts +1 -0
- package/dist/connection/system.js +109 -5
- package/dist/connection/tree/tree.js +59 -8
- package/dist/container/output/format.js +1 -2
- package/dist/dashboard/cockpit-client.d.ts +6 -0
- package/dist/dashboard/cockpit-client.js +27 -0
- package/dist/dashboard/cockpits.d.ts +29 -0
- package/dist/dashboard/cockpits.js +65 -0
- package/dist/dashboard/dashboard.d.ts +7 -0
- package/dist/dashboard/dashboard.js +47 -0
- package/dist/dashboard/draw.d.ts +15 -0
- package/dist/dashboard/draw.js +30 -0
- package/dist/dashboard/frame.d.ts +4 -0
- package/dist/dashboard/frame.js +15 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/modes.d.ts +5 -0
- package/dist/dashboard/modes.js +16 -0
- package/dist/dashboard/node-connection.d.ts +15 -0
- package/dist/dashboard/node-connection.js +51 -0
- package/dist/dashboard/pi-tui.d.ts +6 -0
- package/dist/dashboard/pi-tui.js +35 -0
- package/dist/dashboard/status-bar.d.ts +4 -0
- package/dist/dashboard/status-bar.js +60 -0
- package/dist/dashboard/terminal.d.ts +53 -0
- package/dist/dashboard/terminal.js +165 -0
- package/dist/dashboard/tree-model.d.ts +28 -0
- package/dist/dashboard/tree-model.js +97 -0
- package/dist/dashboard/tree.d.ts +10 -0
- package/dist/dashboard/tree.js +76 -0
- package/dist/fleet/fleet.d.ts +70 -0
- package/dist/fleet/fleet.js +91 -0
- package/dist/fleet/index.d.ts +2 -0
- package/dist/fleet/index.js +2 -0
- package/dist/hold/output/format.js +1 -5
- package/dist/hold/tree/tree.js +1 -0
- package/dist/import/commands.js +3 -4
- package/dist/import/output.js +1 -4
- package/dist/local-node/client.d.ts +9 -4
- package/dist/local-node/client.js +21 -9
- package/dist/local-node/index.d.ts +2 -1
- package/dist/local-node/index.js +2 -1
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/commands.js +2 -1
- package/dist/mcp/calls.d.ts +1 -0
- package/dist/mcp/calls.js +37 -3
- package/dist/mcp/commands.d.ts +5 -2
- package/dist/mcp/commands.js +30 -4
- package/dist/mcp/routing.d.ts +24 -0
- package/dist/mcp/routing.js +188 -0
- package/dist/mcp/server.d.ts +13 -4
- package/dist/mcp/server.js +35 -12
- package/dist/presentation/output/format.js +4 -3
- package/dist/project-guard/commands.js +11 -2
- package/dist/project-workspace/commands.js +16 -6
- package/dist/project-workspace/output/human.d.ts +13 -0
- package/dist/project-workspace/output/human.js +17 -5
- package/dist/project-workspace/output/index.d.ts +1 -1
- package/dist/project-workspace/output/index.js +1 -1
- package/dist/project-workspace/output/metadata.js +1 -1
- package/dist/project-workspace/tree/tree.js +27 -12
- package/dist/reference/commands.js +4 -2
- package/dist/reference/index.d.ts +1 -1
- package/dist/reference/index.js +1 -1
- package/dist/reference/resolve.d.ts +2 -0
- package/dist/reference/resolve.js +28 -18
- package/dist/remote-node/client.d.ts +89 -9
- package/dist/remote-node/client.js +6 -1
- package/dist/remote-node/commands.d.ts +9 -0
- package/dist/remote-node/commands.js +96 -18
- package/dist/remote-node/connector.d.ts +12 -4
- package/dist/remote-node/connector.js +54 -26
- package/dist/remote-node/index.d.ts +2 -2
- package/dist/remote-node/index.js +2 -2
- package/dist/remote-node/reachability.d.ts +43 -1
- package/dist/remote-node/reachability.js +13 -3
- package/dist/remote-node/text.d.ts +2 -1
- package/dist/remote-node/text.js +74 -27
- package/dist/remote-node/tree/tree.js +21 -1
- package/dist/routine/client.d.ts +398 -0
- package/dist/routine/client.js +28 -0
- package/dist/routine/commands.d.ts +9 -0
- package/dist/routine/commands.js +109 -0
- package/dist/routine/index.d.ts +3 -0
- package/dist/routine/index.js +3 -0
- package/dist/routine/input.d.ts +28 -0
- package/dist/routine/input.js +44 -0
- package/dist/routine/output/format.d.ts +23 -0
- package/dist/routine/output/format.js +83 -0
- package/dist/routine/output/index.d.ts +2 -0
- package/dist/routine/output/index.js +2 -0
- package/dist/routine/tree/index.d.ts +2 -0
- package/dist/routine/tree/index.js +2 -0
- package/dist/routine/tree/tree.d.ts +3 -0
- package/dist/routine/tree/tree.js +70 -0
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/commands.js +31 -9
- package/dist/session/approval/output/format.d.ts +11 -0
- package/dist/session/approval/output/format.js +8 -0
- package/dist/session/approval/output/index.d.ts +1 -1
- package/dist/session/approval/output/index.js +1 -1
- package/dist/session/attach-client.d.ts +1 -1
- package/dist/session/attach-client.js +12 -3
- package/dist/session/attach-render.js +15 -7
- package/dist/session/attach.js +17 -3
- package/dist/session/client.d.ts +12 -3
- package/dist/session/client.js +18 -17
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +120 -13
- package/dist/session/create-tasks.js +29 -11
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.js +2 -1
- package/dist/session/interaction/output/format.js +2 -1
- package/dist/session/output/diff.js +3 -10
- package/dist/session/output/failure.js +3 -10
- package/dist/session/output/human.d.ts +1 -0
- package/dist/session/output/human.js +21 -10
- package/dist/session/output/index.d.ts +2 -2
- package/dist/session/output/index.js +2 -2
- package/dist/session/output/tasks.d.ts +16 -1
- package/dist/session/output/tasks.js +41 -27
- package/dist/session/tree/tree.js +67 -8
- package/dist/session/turn/client.d.ts +4 -1
- package/dist/session/turn/client.js +22 -11
- package/dist/session/turn/commands.d.ts +2 -0
- package/dist/session/turn/commands.js +39 -11
- package/dist/session/turn/index.d.ts +3 -3
- package/dist/session/turn/index.js +1 -1
- package/dist/session/turn/output.d.ts +7 -2
- package/dist/session/turn/output.js +36 -13
- package/dist/status/client.d.ts +7 -2
- package/dist/status/command.js +3 -1
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +10 -4
- package/dist/status/output/compact.d.ts +1 -0
- package/dist/status/output/compact.js +3 -0
- package/dist/status/output/human.d.ts +1 -1
- package/dist/status/output/human.js +71 -14
- package/dist/team-workspace/ceremony.d.ts +19 -0
- package/dist/team-workspace/ceremony.js +141 -0
- package/dist/team-workspace/client.d.ts +58 -0
- package/dist/team-workspace/client.js +6 -0
- package/dist/team-workspace/commands.d.ts +3 -0
- package/dist/team-workspace/commands.js +85 -0
- package/dist/team-workspace/confirmation.d.ts +4 -0
- package/dist/team-workspace/confirmation.js +8 -0
- package/dist/team-workspace/dependencies.d.ts +8 -0
- package/dist/team-workspace/dependencies.js +2 -0
- package/dist/team-workspace/index.d.ts +6 -0
- package/dist/team-workspace/index.js +5 -0
- package/dist/team-workspace/launcher.d.ts +17 -0
- package/dist/team-workspace/launcher.js +30 -0
- package/dist/team-workspace/output.d.ts +15 -0
- package/dist/team-workspace/output.js +28 -0
- package/dist/team-workspace/terminal.d.ts +9 -0
- package/dist/team-workspace/terminal.js +46 -0
- package/dist/terminal/client.d.ts +4 -0
- package/dist/terminal/client.js +3 -0
- package/dist/terminal/commands.js +37 -25
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.d.ts +12 -0
- package/dist/terminal/keys.js +62 -0
- package/dist/terminal/output/compact-list.d.ts +1 -0
- package/dist/terminal/output/compact-list.js +1 -0
- package/dist/terminal/output/human.d.ts +2 -19
- package/dist/terminal/output/human.js +6 -6
- package/dist/terminal/tree/tree.js +16 -16
- package/guidance/maia-orchestration/SKILL.md +1 -2
- package/package.json +10 -8
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import { isTerminalControl } from "./rows.js";
|
|
2
3
|
const loadDecoder = () => import("./json-decoder.js");
|
|
4
|
+
const DEL = 127;
|
|
5
|
+
const ASTRAL = 65_536;
|
|
6
|
+
const HIGH_SURROGATE = 55_296;
|
|
7
|
+
const LOW_SURROGATE = 56_320;
|
|
8
|
+
const SURROGATE_SPAN = 1024;
|
|
9
|
+
const unitEscape = (unit) => `\\u${unit.toString(16).padStart(4, "0")}`;
|
|
10
|
+
const escapeCharacter = (point) => {
|
|
11
|
+
if (point < ASTRAL)
|
|
12
|
+
return unitEscape(point);
|
|
13
|
+
const offset = point - ASTRAL;
|
|
14
|
+
return (unitEscape(HIGH_SURROGATE + Math.floor(offset / SURROGATE_SPAN)) +
|
|
15
|
+
unitEscape(LOW_SURROGATE + (offset % SURROGATE_SPAN)));
|
|
16
|
+
};
|
|
17
|
+
export const jsonLine = (value) => {
|
|
18
|
+
const escaped = Array.from(JSON.stringify(value), (character) => {
|
|
19
|
+
const point = character.codePointAt(0) ?? 0;
|
|
20
|
+
return point >= DEL && isTerminalControl(character)
|
|
21
|
+
? escapeCharacter(point)
|
|
22
|
+
: character;
|
|
23
|
+
}).join("");
|
|
24
|
+
return `${escaped}\n`;
|
|
25
|
+
};
|
|
3
26
|
export const decodeJsonText = (text, failure) => Effect.promise(loadDecoder).pipe(Effect.flatMap((decoder) => decoder.decodeJson(text)), Effect.mapError(failure));
|
|
4
27
|
//# sourceMappingURL=json.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NodeHolding } from "@maiaos/client-core/cockpit";
|
|
1
2
|
import type { ProtocolError } from "@maiaos/sdk";
|
|
2
3
|
import type * as Effect from "effect/Effect";
|
|
3
4
|
import type { CliMutationRecovery, CliNodeResult } from "../local-node/index.js";
|
|
@@ -22,6 +23,7 @@ export type CliResolution = {
|
|
|
22
23
|
readonly reference?: string;
|
|
23
24
|
};
|
|
24
25
|
export type CliSuccessOutput = {
|
|
26
|
+
readonly error?: ProtocolError;
|
|
25
27
|
readonly ok: boolean;
|
|
26
28
|
readonly resolved?: readonly CliResolution[];
|
|
27
29
|
readonly result: CliSuccessResult;
|
|
@@ -32,22 +34,27 @@ export type CliUsageHint = {
|
|
|
32
34
|
};
|
|
33
35
|
export type CliErrorOutput = Partial<CliUsageHint> & {
|
|
34
36
|
readonly error: ProtocolError;
|
|
37
|
+
readonly nodes?: readonly NodeHolding[];
|
|
35
38
|
readonly ok: false;
|
|
36
39
|
readonly recovery?: CliMutationRecovery;
|
|
37
40
|
};
|
|
38
41
|
export type OutputContext = {
|
|
42
|
+
readonly error?: ProtocolError;
|
|
39
43
|
readonly io: CliIo;
|
|
40
44
|
readonly json: boolean;
|
|
41
45
|
readonly ok?: boolean;
|
|
42
46
|
readonly resolved?: readonly CliResolution[];
|
|
43
47
|
};
|
|
44
48
|
type ErrorContext = OutputContext & {
|
|
49
|
+
readonly nodes?: readonly NodeHolding[];
|
|
50
|
+
readonly notFoundHint?: string;
|
|
45
51
|
readonly recovery?: CliMutationRecovery;
|
|
46
52
|
readonly usage?: CliUsageHint;
|
|
47
53
|
};
|
|
48
54
|
export type CliCommandOutput = CliSuccessResult;
|
|
49
|
-
export declare const writeSuccess: <TResult extends CliCommandOutput>(result: TResult, { io, json, ok, resolved }: OutputContext, human: (result: TResult) => string) => void;
|
|
55
|
+
export declare const writeSuccess: <TResult extends CliCommandOutput>(result: TResult, { error, io, json, ok, resolved }: OutputContext, human: (result: TResult) => string) => void;
|
|
50
56
|
export declare const reportError: (error: ProtocolError, context: ErrorContext) => number;
|
|
57
|
+
export declare const exitCodeOf: (error: ProtocolError) => number;
|
|
51
58
|
export type NodeResultPresenter<TValue, TResult extends CliCommandOutput> = {
|
|
52
59
|
readonly toResult: (value: TValue) => TResult;
|
|
53
60
|
readonly toText: (result: TResult) => string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { jsonLine } from "./json.js";
|
|
2
|
+
import { cell } from "./rows.js";
|
|
1
3
|
const EXIT_DATA_NOT_FOUND = 66;
|
|
2
4
|
const EXIT_USAGE = 64;
|
|
3
5
|
const EXIT_UNAVAILABLE = 69;
|
|
@@ -6,14 +8,15 @@ const EXIT_DEADLINE = 74;
|
|
|
6
8
|
const EXIT_TEMPORARY = 75;
|
|
7
9
|
const EXIT_OUTCOME_UNKNOWN = 76;
|
|
8
10
|
const EXIT_PERMISSION = 77;
|
|
9
|
-
export const writeSuccess = (result, { io, json, ok = true, resolved = [] }, human) => {
|
|
11
|
+
export const writeSuccess = (result, { error, io, json, ok = true, resolved = [] }, human) => {
|
|
10
12
|
if (json) {
|
|
11
13
|
const output = {
|
|
14
|
+
...(ok || error === undefined ? {} : { error }),
|
|
12
15
|
ok,
|
|
13
16
|
...(resolved.length === 0 ? {} : { resolved }),
|
|
14
17
|
result,
|
|
15
18
|
};
|
|
16
|
-
io.stdout(
|
|
19
|
+
io.stdout(jsonLine(output));
|
|
17
20
|
return;
|
|
18
21
|
}
|
|
19
22
|
io.stdout(human(result));
|
|
@@ -26,23 +29,28 @@ const formatUsageHint = (error, hint) => {
|
|
|
26
29
|
? "Run 'maia --help' for usage.\n"
|
|
27
30
|
: "";
|
|
28
31
|
};
|
|
32
|
+
const formatRecovery = ({ commandId, profile }) => profile === undefined
|
|
33
|
+
? `Outcome unknown. Recover with:\n maia receipt show ${commandId}\n`
|
|
34
|
+
: `Outcome unknown. Start the Node of profile ${profile}, then read the receipt:\n maia-node --desktop --profile ${profile}\n maia --profile ${profile} receipt show ${commandId}\n`;
|
|
29
35
|
const writeError = (error, context) => {
|
|
30
|
-
const { io, json, recovery, usage: hint } = context;
|
|
36
|
+
const { io, json, nodes, notFoundHint, recovery, usage: hint } = context;
|
|
37
|
+
const notFound = error.code === "resource_not_found" ? notFoundHint : undefined;
|
|
31
38
|
if (json) {
|
|
32
39
|
const output = {
|
|
33
40
|
error,
|
|
34
41
|
ok: false,
|
|
42
|
+
...(nodes === undefined ? {} : { nodes }),
|
|
35
43
|
...(recovery === undefined ? {} : { recovery }),
|
|
44
|
+
...(notFound === undefined ? {} : { hint: notFound }),
|
|
36
45
|
...hint,
|
|
37
46
|
};
|
|
38
|
-
io.stderr(
|
|
47
|
+
io.stderr(jsonLine(output));
|
|
39
48
|
return;
|
|
40
49
|
}
|
|
41
50
|
const usage = formatUsageHint(error, hint);
|
|
42
|
-
const recoveryHint = recovery === undefined
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
io.stderr(`maia: ${error.message}\n${recoveryHint}${usage}`);
|
|
51
|
+
const recoveryHint = recovery === undefined ? "" : formatRecovery(recovery);
|
|
52
|
+
const notFoundLine = notFound === undefined ? "" : `${notFound}\n`;
|
|
53
|
+
io.stderr(`maia: ${cell(error.message)}\n${notFoundLine}${recoveryHint}${usage}`);
|
|
46
54
|
};
|
|
47
55
|
const TEMPORARY_ERROR_CODES = new Set([
|
|
48
56
|
"guard_leases_per_session_exceeded",
|
|
@@ -55,22 +63,33 @@ const PERMISSION_ERROR_CODES = new Set([
|
|
|
55
63
|
"authentication_failed",
|
|
56
64
|
"context_override_forbidden",
|
|
57
65
|
"role_denied",
|
|
66
|
+
"terminal_program_not_admitted",
|
|
67
|
+
]);
|
|
68
|
+
const USAGE_ERROR_CODES = new Set([
|
|
69
|
+
"command_not_implemented",
|
|
70
|
+
"invalid_argument",
|
|
71
|
+
"node_ambiguous",
|
|
72
|
+
]);
|
|
73
|
+
const UNAVAILABLE_ERROR_CODES = new Set([
|
|
74
|
+
"node_context_unavailable",
|
|
75
|
+
"node_unavailable",
|
|
76
|
+
"platform_unsupported",
|
|
77
|
+
"terminal_containment_unsupported",
|
|
58
78
|
]);
|
|
59
79
|
export const reportError = (error, context) => {
|
|
60
80
|
writeError(error, context);
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
return exitCodeOf(error);
|
|
82
|
+
};
|
|
83
|
+
export const exitCodeOf = (error) => {
|
|
84
|
+
if (USAGE_ERROR_CODES.has(error.code))
|
|
63
85
|
return EXIT_USAGE;
|
|
64
|
-
}
|
|
65
86
|
if (error.code === "resource_not_found" ||
|
|
66
87
|
error.code === "port_lease_not_found")
|
|
67
88
|
return EXIT_DATA_NOT_FOUND;
|
|
68
89
|
if (PERMISSION_ERROR_CODES.has(error.code))
|
|
69
90
|
return EXIT_PERMISSION;
|
|
70
|
-
if (error.code
|
|
71
|
-
error.code === "node_context_unavailable") {
|
|
91
|
+
if (UNAVAILABLE_ERROR_CODES.has(error.code))
|
|
72
92
|
return EXIT_UNAVAILABLE;
|
|
73
|
-
}
|
|
74
93
|
if (error.code === "deadline_exceeded")
|
|
75
94
|
return EXIT_DEADLINE;
|
|
76
95
|
if (error.code === "outcome_unknown")
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const isTerminalControl: (character: string) => boolean;
|
|
2
2
|
export declare const cell: (value: string) => string;
|
|
3
|
+
export declare const block: (value: string) => string;
|
|
3
4
|
export declare const tab: (values: readonly unknown[]) => string;
|
|
5
|
+
export declare const fields: (entries: readonly (readonly [label: string, value: string | undefined])[]) => string;
|
|
4
6
|
export type CliTable = {
|
|
5
7
|
readonly empty: string;
|
|
6
8
|
readonly headers: readonly string[];
|
|
@@ -8,7 +8,9 @@ export const isTerminalControl = (character) => {
|
|
|
8
8
|
point === 8233 ||
|
|
9
9
|
(FORMAT_CHARACTER.test(character) && !JOINERS.has(point)));
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const replaceControls = (value, kept) => Array.from(value, (character) => !kept.includes(character) && isTerminalControl(character) ? "�" : character).join("");
|
|
12
|
+
export const cell = (value) => replaceControls(value, "");
|
|
13
|
+
export const block = (value) => replaceControls(value, "\t\n");
|
|
12
14
|
export const tab = (values) => values.join("\t");
|
|
13
15
|
const align = (rows) => {
|
|
14
16
|
const widths = rows.reduce((sizes, row) => row.map((value, index) => Math.max(sizes[index] ?? 0, value.length)), []);
|
|
@@ -19,6 +21,13 @@ const align = (rows) => {
|
|
|
19
21
|
.trimEnd())
|
|
20
22
|
.join("\n")}\n`;
|
|
21
23
|
};
|
|
24
|
+
export const fields = (entries) => {
|
|
25
|
+
const shown = entries.flatMap(([label, value]) => value === undefined ? [] : [[`${label}:`, cell(value)]]);
|
|
26
|
+
const width = Math.max(...shown.map(([label]) => label.length)) + 1;
|
|
27
|
+
return shown
|
|
28
|
+
.map(([label, value]) => `${label.padEnd(width)}${value}\n`)
|
|
29
|
+
.join("");
|
|
30
|
+
};
|
|
22
31
|
export const formatRows = (items, format, text) => {
|
|
23
32
|
const empty = typeof text === "object" ? text.empty : text;
|
|
24
33
|
if (items.length === 0)
|
|
@@ -9,6 +9,10 @@ export declare const requestedTwoPhaseMode: (flags: ReadonlySet<string>, offersY
|
|
|
9
9
|
export declare const promptOrRefuse: (context: CommandContext, offersYes?: boolean) => "prompt";
|
|
10
10
|
export declare const readTwoPhaseMode: (flags: ReadonlySet<string>, context: CommandContext, offersYes?: boolean) => TwoPhaseMode;
|
|
11
11
|
export declare const readPipedPreview: (context: CommandContext) => Effect.Effect<object, CliArgumentError>;
|
|
12
|
+
export declare const peekStdin: (context: CommandContext) => Effect.Effect<{
|
|
13
|
+
readonly context: CommandContext;
|
|
14
|
+
readonly input: unknown;
|
|
15
|
+
}>;
|
|
12
16
|
export declare const confirmParameters: <TParameters>(schema: {
|
|
13
17
|
readonly safeParse: (input: unknown) => {
|
|
14
18
|
readonly data: TParameters;
|
|
@@ -52,6 +56,7 @@ export type InputTwoPhaseSpec<TPreviewParameters, TPreview extends object, TConf
|
|
|
52
56
|
readonly tokens: readonly string[];
|
|
53
57
|
readonly write: (result: CliNodeResult<TConfirm | TPreview>) => number;
|
|
54
58
|
};
|
|
59
|
+
export declare const readInputMode: (tokens: readonly string[]) => "confirm-stdin" | "dry-run";
|
|
55
60
|
export declare const runInputTwoPhase: <TPreviewParameters, TPreview extends object, TConfirmParameters, TConfirm, TRequirements>(spec: InputTwoPhaseSpec<TPreviewParameters, TPreview, TConfirmParameters, TConfirm, TRequirements>) => Effect.Effect<number, CliArgumentError, TRequirements>;
|
|
56
61
|
export {};
|
|
57
62
|
//# sourceMappingURL=two-phase.d.ts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import
|
|
3
|
+
import * as Exit from "effect/Exit";
|
|
4
|
+
import { CliArgumentError, parseOptions, recoverStdin, replayStdin, requirePositionals, } from "./input/index.js";
|
|
3
5
|
import { decodeJsonText } from "./json.js";
|
|
4
6
|
export const TWO_PHASE_FLAGS = [
|
|
5
7
|
"--confirm-stdin",
|
|
@@ -26,7 +28,11 @@ export const promptOrRefuse = (context, offersYes = false) => {
|
|
|
26
28
|
throw new CliArgumentError(`No person can confirm here: preview with '--dry-run', then pipe that preview to '--confirm-stdin'${offersYes ? ", or confirm at once with '--yes'" : ""}.`);
|
|
27
29
|
};
|
|
28
30
|
export const readTwoPhaseMode = (flags, context, offersYes = false) => requestedTwoPhaseMode(flags, offersYes) ?? promptOrRefuse(context, offersYes);
|
|
29
|
-
const
|
|
31
|
+
const PIPED_PREVIEW = {
|
|
32
|
+
label: "preview",
|
|
33
|
+
maxBytes: 64 * 1024,
|
|
34
|
+
maxChunks: 256,
|
|
35
|
+
};
|
|
30
36
|
const invalidPreview = () => new CliArgumentError("The piped preview is invalid; pipe the output of the same command with '--json --dry-run'.");
|
|
31
37
|
const unwrapPreview = (value) => {
|
|
32
38
|
const envelope = typeof value === "object" && value !== null && "ok" in value
|
|
@@ -43,16 +49,35 @@ export const readPipedPreview = (context) => Effect.gen(function* () {
|
|
|
43
49
|
const stdin = context.io.stdin;
|
|
44
50
|
if (stdin === undefined)
|
|
45
51
|
return yield* new CliArgumentError("Standard input is unavailable.");
|
|
46
|
-
const text = yield* stdin(
|
|
47
|
-
label: "preview",
|
|
48
|
-
maxBytes: MAX_PREVIEW_BYTES,
|
|
49
|
-
maxChunks: 256,
|
|
50
|
-
});
|
|
52
|
+
const text = yield* stdin(PIPED_PREVIEW);
|
|
51
53
|
const preview = unwrapPreview(yield* decodeJsonText(text, invalidPreview));
|
|
52
54
|
return typeof preview === "object" && preview !== null
|
|
53
55
|
? preview
|
|
54
56
|
: yield* invalidPreview();
|
|
55
57
|
});
|
|
58
|
+
export const peekStdin = (context) => Effect.gen(function* () {
|
|
59
|
+
const { io } = context;
|
|
60
|
+
if (io.stdin === undefined)
|
|
61
|
+
return { context, input: undefined };
|
|
62
|
+
const read = yield* Effect.exit(io.stdin(PIPED_PREVIEW));
|
|
63
|
+
if (Exit.isFailure(read)) {
|
|
64
|
+
if (Cause.hasInterruptsOnly(read.cause))
|
|
65
|
+
return yield* Effect.interrupt;
|
|
66
|
+
const { cause } = read;
|
|
67
|
+
return {
|
|
68
|
+
context: {
|
|
69
|
+
...context,
|
|
70
|
+
io: { ...io, stdin: () => Effect.failCause(cause) },
|
|
71
|
+
},
|
|
72
|
+
input: undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const input = yield* Effect.orElseSucceed(decodeJsonText(read.value, invalidPreview), () => ({}));
|
|
76
|
+
return {
|
|
77
|
+
context: { ...context, io: { ...io, stdin: replayStdin(read.value) } },
|
|
78
|
+
input: unwrapPreview(input),
|
|
79
|
+
};
|
|
80
|
+
});
|
|
56
81
|
export const confirmParameters = (schema, preview, previewOnly = []) => {
|
|
57
82
|
const parsed = schema.safeParse(confirmationOf(preview, previewOnly));
|
|
58
83
|
return parsed.success
|
|
@@ -124,7 +149,7 @@ const previewFromStdin = (context, spec) => Effect.gen(function* () {
|
|
|
124
149
|
const confirmPreview = (spec, previewed) => Effect.flatMap(confirmParameters(spec.confirmSchema, previewed, spec.previewOnly), (parameters) => spec.confirm === undefined
|
|
125
150
|
? Effect.fail(unavailableOperation(spec.label))
|
|
126
151
|
: Effect.map(spec.confirm(parameters), (result) => withRecovery(result, parameters)));
|
|
127
|
-
const readInputMode = (tokens) => {
|
|
152
|
+
export const readInputMode = (tokens) => {
|
|
128
153
|
const parsed = parseOptions(tokens, new Set(), new Set(["--input-stdin", ...TWO_PHASE_FLAGS]));
|
|
129
154
|
requirePositionals(parsed.positionals, 0);
|
|
130
155
|
const mode = requestedTwoPhaseMode(parsed.flags);
|
|
@@ -6,7 +6,7 @@ export declare const CLI_CONTRACT: {
|
|
|
6
6
|
readonly failure: '{"ok":false,"error":{"code","message","retryable"},"usage"?,"hint"?,"recovery"?} on stderr';
|
|
7
7
|
readonly success: '{"ok":true,"resolved"?,"result":{"command","result"}} on stdout';
|
|
8
8
|
};
|
|
9
|
-
readonly exitCodes: readonly [readonly [0, "done"], readonly [64, "invalid usage"], readonly [66, "unknown ID"], readonly [69, "Node unavailable"], readonly [70, "other failure: read the message"], readonly [74, "deadline reached"], readonly [75, "retry later: revision changed, full, limited or held"], readonly [76, "outcome unknown: run maia receipt show <command-id>"], readonly [77, "not permitted"]];
|
|
9
|
+
readonly exitCodes: readonly [readonly [0, "done"], readonly [64, "invalid usage"], readonly [66, "unknown ID"], readonly [69, "Node unavailable"], readonly [70, "other failure: read the message"], readonly [74, "deadline reached"], readonly [75, "retry later: revision changed, full, limited or held"], readonly [76, "outcome unknown: run maia receipt show <command-id>"], readonly [77, "not permitted"], readonly [130, "interrupted by a signal"]];
|
|
10
10
|
readonly grammar: "<x> is a value, [x] optional, (a | b) one of, <a|b> a choice, <1..100> an integer range, <duration> 30s, 10m or 1h, x... repeats; 'maia <command> --help --json' lists typed arguments.";
|
|
11
11
|
readonly idempotency: "A mutation that guards a revision takes the current --expected-revision (or a named --expected-*-revision); --command-id <id> names the mutation, and a retry with the same command ID replays the first result.";
|
|
12
12
|
readonly input: "Prompts appear only when stdin and stderr are terminals and --json and --no-input (MAIA_NO_INPUT=1) are absent; otherwise a command that confirms fails (exit 64) and names its flags. A two-phase command previews with --dry-run and confirms that preview from stdin with --confirm-stdin.";
|
|
@@ -15,6 +15,7 @@ export const CLI_CONTRACT = {
|
|
|
15
15
|
[75, "retry later: revision changed, full, limited or held"],
|
|
16
16
|
[76, "outcome unknown: run maia receipt show <command-id>"],
|
|
17
17
|
[77, "not permitted"],
|
|
18
|
+
[130, "interrupted by a signal"],
|
|
18
19
|
],
|
|
19
20
|
grammar: "<x> is a value, [x] optional, (a | b) one of, <a|b> a choice, <1..100> an integer range, <duration> 30s, 10m or 1h, x... repeats; 'maia <command> --help --json' lists typed arguments.",
|
|
20
21
|
idempotency: "A mutation that guards a revision takes the current --expected-revision (or a named --expected-*-revision); --command-id <id> names the mutation, and a retry with the same command ID replays the first result.",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { CliVersionResult } from "./commands.js";
|
|
2
2
|
export { exampleFor, parseUsage, type TreeArgument, type TreeForm, } from "./grammar.js";
|
|
3
3
|
export { CLI_CONTRACT, type CliHelpNode, type CliHelpNodeResult, type CliHelpResult, type CliHelpTreeResult, createHelpTree, createNodeHelp, formatNodeHelp, formatRootHelp, leafExample, usageHint, } from "./help.js";
|
|
4
|
-
export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE } from "./placeholder.js";
|
|
5
|
-
export type { GroupRow, LeafRow, LeafRunner, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation, } from "./row.js";
|
|
4
|
+
export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE, ROUTE_ARGUMENT, } from "./placeholder.js";
|
|
5
|
+
export type { GroupRow, LeafRoute, LeafRow, LeafRunner, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation, } from "./row.js";
|
|
6
6
|
export { suggestPaths, unknownPathMessage } from "./suggest.js";
|
|
7
7
|
export { commandTree, createTreeDigest, findNode, isNodeBacked, TREE_FRAGMENTS, TREE_SECTIONS, type TreeAvailability, type TreeLeafForm, type TreeNode, treeNodes, treeUsages, usagePath, } from "./tree.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { exampleFor, parseUsage, } from "./grammar.js";
|
|
2
2
|
export { CLI_CONTRACT, createHelpTree, createNodeHelp, formatNodeHelp, formatRootHelp, leafExample, usageHint, } from "./help.js";
|
|
3
|
-
export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE } from "./placeholder.js";
|
|
3
|
+
export { REFERENCE_PLACEHOLDER, REFERENCE_USAGE, ROUTE_ARGUMENT, } from "./placeholder.js";
|
|
4
4
|
export { suggestPaths, unknownPathMessage } from "./suggest.js";
|
|
5
5
|
export { commandTree, createTreeDigest, findNode, isNodeBacked, TREE_FRAGMENTS, TREE_SECTIONS, treeNodes, treeUsages, usagePath, } from "./tree.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,7 @@ const local = () => import("./commands.js");
|
|
|
2
2
|
const doctor = () => import("../status/index.js");
|
|
3
3
|
const mcp = () => import("../mcp/index.js");
|
|
4
4
|
const presentation = () => import("../presentation/index.js");
|
|
5
|
+
const dashboard = () => import("../dashboard/index.js");
|
|
5
6
|
const agent = [local, "runAgent"];
|
|
6
7
|
export const LOCAL_TREE = {
|
|
7
8
|
groups: [
|
|
@@ -121,6 +122,17 @@ export const LOCAL_TREE = {
|
|
|
121
122
|
"Serve coordinator or worker tools over MCP stdio.",
|
|
122
123
|
{ kind: "local", node: true, run: [mcp, "runMcpCommand"] },
|
|
123
124
|
],
|
|
125
|
+
[
|
|
126
|
+
"dashboard [--plain]",
|
|
127
|
+
1,
|
|
128
|
+
"",
|
|
129
|
+
"Open the terminal dashboard; --plain prints its text once.",
|
|
130
|
+
{
|
|
131
|
+
example: "maia dashboard --plain",
|
|
132
|
+
kind: "composite",
|
|
133
|
+
run: [dashboard, "runDashboard"],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
124
136
|
],
|
|
125
137
|
};
|
|
126
138
|
//# sourceMappingURL=local.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const KINDS = "connection|container|project|session|workspace";
|
|
2
2
|
export const REFERENCE_PLACEHOLDER = new RegExp(`^<(?:[a-z]+-)*?(${KINDS})(?:-id)?>$`, "u");
|
|
3
3
|
export const REFERENCE_USAGE = new RegExp(`<(?:[a-z]+-)*?(?:${KINDS})(?:-id)?>`, "u");
|
|
4
|
+
export const ROUTE_ARGUMENT = /^(?:--|<(?:[a-z]+-)*?)(approval|command|project|routine|session|terminal|turn|workspace)(?:-id(?:\|.+)?>)?$/u;
|
|
4
5
|
//# sourceMappingURL=placeholder.js.map
|
|
@@ -2,6 +2,7 @@ import type { localNodeRequestPayloadSchema, SessionAttachFrame } from "@maiaos/
|
|
|
2
2
|
import type { CommandContext, CommandEffect } from "../command-line/index.js";
|
|
3
3
|
export type TreeOperation = ReturnType<typeof localNodeRequestPayloadSchema.parse>["method"] | SessionAttachFrame["operationId"];
|
|
4
4
|
export type TreeLeafKind = "composite" | "discriminant" | "local" | "operation" | "shortcut" | "two-phase";
|
|
5
|
+
export type LeafRoute = readonly [string, string] | string;
|
|
5
6
|
export type LeafRunner = (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
7
|
export type RunnerReference = readonly [
|
|
7
8
|
load: () => Promise<object>,
|
|
@@ -12,6 +13,7 @@ export type LeafExtra = {
|
|
|
12
13
|
readonly kind?: Exclude<TreeLeafKind, "operation">;
|
|
13
14
|
readonly node?: true;
|
|
14
15
|
readonly remote?: false;
|
|
16
|
+
readonly route?: LeafRoute;
|
|
15
17
|
readonly run: RunnerReference;
|
|
16
18
|
};
|
|
17
19
|
export type LeafRow = readonly [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RunnerReference, TreeFragment, TreeLeafKind, TreeOperation } from "./row.js";
|
|
1
|
+
import type { LeafRoute, RunnerReference, TreeFragment, TreeLeafKind, TreeOperation } from "./row.js";
|
|
2
2
|
export type TreeAvailability = "implemented" | "source_implemented_candidate";
|
|
3
3
|
export type TreeLeafForm = {
|
|
4
4
|
readonly availability: TreeAvailability;
|
|
@@ -15,11 +15,12 @@ export type TreeNode = {
|
|
|
15
15
|
readonly operations: readonly TreeOperation[];
|
|
16
16
|
readonly path: readonly string[];
|
|
17
17
|
readonly remote?: false;
|
|
18
|
+
readonly route?: LeafRoute;
|
|
18
19
|
readonly run?: RunnerReference;
|
|
19
20
|
readonly summary: string;
|
|
20
21
|
};
|
|
21
22
|
export declare const TREE_FRAGMENTS: readonly TreeFragment[];
|
|
22
|
-
export declare const TREE_SECTIONS: readonly [readonly ["Start and sign in", readonly ["setup", "login", "status"]], readonly ["Work", readonly ["session", "run", "import"]], readonly ["Resources", readonly ["project", "workspace", "container", "terminal", "execution", "port", "reference"]], readonly ["Accounts and Nodes", readonly ["connection", "integration", "provider", "node"]], readonly ["Safety and audit", readonly ["hold", "receipt", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "agent", "help", "version", "doctor", "completion"]]];
|
|
23
|
+
export declare const TREE_SECTIONS: readonly [readonly ["Start and sign in", readonly ["setup", "login", "status"]], readonly ["Work", readonly ["session", "run", "routine", "import"]], readonly ["Resources", readonly ["project", "workspace", "container", "terminal", "execution", "port", "reference", "agents"]], readonly ["Accounts and Nodes", readonly ["connection", "integration", "provider", "node"]], readonly ["Safety and audit", readonly ["hold", "receipt", "context"]], readonly ["Clients and local", readonly ["presentation", "mcp", "dashboard", "agent", "help", "version", "doctor", "completion"]]];
|
|
23
24
|
export declare const usagePath: (usage: string) => readonly string[];
|
|
24
25
|
export declare const COMMAND_TREE: TreeNode;
|
|
25
26
|
export declare const commandTree: () => TreeNode;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { AGENTS_TREE } from "../agents/tree/index.js";
|
|
2
3
|
import { CONNECTION_TREE } from "../connection/tree/index.js";
|
|
3
4
|
import { EXECUTION_TREE } from "../execution/tree/index.js";
|
|
4
5
|
import { SAFETY_TREE } from "../hold/tree/index.js";
|
|
@@ -6,6 +7,7 @@ import { RUN_TREE } from "../orchestration/tree/index.js";
|
|
|
6
7
|
import { PROJECT_TREE } from "../project-workspace/tree/index.js";
|
|
7
8
|
import { REFERENCE_TREE } from "../reference/tree/index.js";
|
|
8
9
|
import { NODE_TREE } from "../remote-node/tree/index.js";
|
|
10
|
+
import { ROUTINE_TREE } from "../routine/tree/index.js";
|
|
9
11
|
import { SESSION_TREE } from "../session/tree/index.js";
|
|
10
12
|
import { TERMINAL_TREE } from "../terminal/tree/index.js";
|
|
11
13
|
import { LOCAL_TREE } from "./local.js";
|
|
@@ -14,16 +16,18 @@ export const TREE_FRAGMENTS = [
|
|
|
14
16
|
CONNECTION_TREE,
|
|
15
17
|
SESSION_TREE,
|
|
16
18
|
RUN_TREE,
|
|
19
|
+
ROUTINE_TREE,
|
|
17
20
|
PROJECT_TREE,
|
|
18
21
|
REFERENCE_TREE,
|
|
19
22
|
TERMINAL_TREE,
|
|
20
23
|
EXECUTION_TREE,
|
|
21
24
|
SAFETY_TREE,
|
|
25
|
+
AGENTS_TREE,
|
|
22
26
|
LOCAL_TREE,
|
|
23
27
|
];
|
|
24
28
|
export const TREE_SECTIONS = [
|
|
25
29
|
["Start and sign in", ["setup", "login", "status"]],
|
|
26
|
-
["Work", ["session", "run", "import"]],
|
|
30
|
+
["Work", ["session", "run", "routine", "import"]],
|
|
27
31
|
[
|
|
28
32
|
"Resources",
|
|
29
33
|
[
|
|
@@ -34,13 +38,23 @@ export const TREE_SECTIONS = [
|
|
|
34
38
|
"execution",
|
|
35
39
|
"port",
|
|
36
40
|
"reference",
|
|
41
|
+
"agents",
|
|
37
42
|
],
|
|
38
43
|
],
|
|
39
44
|
["Accounts and Nodes", ["connection", "integration", "provider", "node"]],
|
|
40
45
|
["Safety and audit", ["hold", "receipt", "context"]],
|
|
41
46
|
[
|
|
42
47
|
"Clients and local",
|
|
43
|
-
[
|
|
48
|
+
[
|
|
49
|
+
"presentation",
|
|
50
|
+
"mcp",
|
|
51
|
+
"dashboard",
|
|
52
|
+
"agent",
|
|
53
|
+
"help",
|
|
54
|
+
"version",
|
|
55
|
+
"doctor",
|
|
56
|
+
"completion",
|
|
57
|
+
],
|
|
44
58
|
],
|
|
45
59
|
];
|
|
46
60
|
const PATH_WORD = /^[a-z][a-z0-9-]*$/u;
|
|
@@ -82,6 +96,8 @@ const addLeaf = (root, row) => {
|
|
|
82
96
|
node.node = extra.node;
|
|
83
97
|
if (extra.remote !== undefined)
|
|
84
98
|
node.remote = extra.remote;
|
|
99
|
+
if (extra.route !== undefined)
|
|
100
|
+
node.route = extra.route;
|
|
85
101
|
if (extra.example !== undefined)
|
|
86
102
|
node.example = extra.example;
|
|
87
103
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ConnectionGrantListParameters, type ConnectionGrantListResult, type ConnectionGrantSetConfirmParameters, type ConnectionGrantSetConfirmResult, type ConnectionGrantSetPreviewParameters, type ConnectionGrantSetPreviewResult, type ConnectionPoolListParameters, type ConnectionPoolListResult, type ConnectionPoolSetConfirmParameters, type ConnectionPoolSetConfirmResult, type ConnectionPoolSetPreviewParameters, type ConnectionPoolSetPreviewResult } from "@maiaos/sdk";
|
|
2
|
+
import type { CliNodeEffect, CliNodeOperations } from "../../local-node/index.js";
|
|
3
|
+
export type Operation<TInput, TResult> = (input: TInput) => CliNodeEffect<TResult>;
|
|
4
|
+
export type ConnectionAccessClient = {
|
|
5
|
+
readonly confirmConnectionGrant: Operation<ConnectionGrantSetConfirmParameters, ConnectionGrantSetConfirmResult>;
|
|
6
|
+
readonly confirmConnectionPool: Operation<ConnectionPoolSetConfirmParameters, ConnectionPoolSetConfirmResult>;
|
|
7
|
+
readonly listConnectionGrants: Operation<ConnectionGrantListParameters, ConnectionGrantListResult>;
|
|
8
|
+
readonly listConnectionPools: Operation<ConnectionPoolListParameters, ConnectionPoolListResult>;
|
|
9
|
+
readonly previewConnectionGrant: Operation<ConnectionGrantSetPreviewParameters, ConnectionGrantSetPreviewResult>;
|
|
10
|
+
readonly previewConnectionPool: Operation<ConnectionPoolSetPreviewParameters, ConnectionPoolSetPreviewResult>;
|
|
11
|
+
};
|
|
12
|
+
export declare const makeConnectionAccessClient: (node: CliNodeOperations) => ConnectionAccessClient;
|
|
13
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { connectionGrantListParametersSchema, connectionGrantSetConfirmParametersSchema, connectionGrantSetPreviewParametersSchema, connectionPoolListParametersSchema, connectionPoolSetConfirmParametersSchema, connectionPoolSetPreviewParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
const reads = (node) => ({
|
|
3
|
+
listConnectionGrants: (input) => node.runValidatedNodeOperation(input, connectionGrantListParametersSchema, (client, parameters, options) => client.listConnectionGrants(parameters, options)),
|
|
4
|
+
listConnectionPools: (input) => node.runValidatedNodeOperation(input, connectionPoolListParametersSchema, (client, parameters, options) => client.listConnectionPools(parameters, options)),
|
|
5
|
+
});
|
|
6
|
+
const previews = (node) => ({
|
|
7
|
+
previewConnectionGrant: (input) => node.runValidatedNodeOperation(input, connectionGrantSetPreviewParametersSchema, (client, parameters, options) => client.previewConnectionGrant(parameters, options)),
|
|
8
|
+
previewConnectionPool: (input) => node.runValidatedNodeOperation(input, connectionPoolSetPreviewParametersSchema, (client, parameters, options) => client.previewConnectionPool(parameters, options)),
|
|
9
|
+
});
|
|
10
|
+
const confirmations = (node) => ({
|
|
11
|
+
confirmConnectionGrant: (input) => node.runValidatedNodeOperation(input, connectionGrantSetConfirmParametersSchema, (client, parameters, options) => client.confirmConnectionGrant(parameters, options), { commandId: input.commandId }),
|
|
12
|
+
confirmConnectionPool: (input) => node.runValidatedNodeOperation(input, connectionPoolSetConfirmParametersSchema, (client, parameters, options) => client.confirmConnectionPool(parameters, options), { commandId: input.commandId }),
|
|
13
|
+
});
|
|
14
|
+
export const makeConnectionAccessClient = (node) => ({
|
|
15
|
+
...confirmations(node),
|
|
16
|
+
...previews(node),
|
|
17
|
+
...reads(node),
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type CommandContext, type CommandEffect } from "../../command-line/index.js";
|
|
2
|
+
export declare const runConnectionGrantList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
|
+
export declare const runConnectionPoolList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
|
+
export declare const runConnectionGrantSet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
|
+
export declare const runConnectionPoolSet: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { connectionGrantSetConfirmParametersSchema, connectionPoolSetConfirmParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { CliArgumentError, confirmParameters, parseOptions, readTwoPhaseMode, runTwoPhase, TWO_PHASE_FLAGS, writeNodeResult, } from "../../command-line/index.js";
|
|
4
|
+
import { formatConnectionAccessResult, } from "./format.js";
|
|
5
|
+
import { GRANT_SET_OPTIONS, POOL_SET_OPTIONS, readGrantList, readGrantPreview, readPoolList, readPoolPreview, } from "./input.js";
|
|
6
|
+
const write = (context) => (result) => writeNodeResult(result, context, {
|
|
7
|
+
toResult: (value) => ({
|
|
8
|
+
command: value.method,
|
|
9
|
+
result: value,
|
|
10
|
+
}),
|
|
11
|
+
toText: formatConnectionAccessResult,
|
|
12
|
+
});
|
|
13
|
+
const unavailable = () => new CliArgumentError("Connection grants and pools are unavailable.");
|
|
14
|
+
const list = (step, read) => (tokens, context) => Effect.gen(function* () {
|
|
15
|
+
const operation = step(context.dependencies);
|
|
16
|
+
if (operation === undefined)
|
|
17
|
+
return yield* unavailable();
|
|
18
|
+
return write(context)(yield* operation(read(tokens)));
|
|
19
|
+
});
|
|
20
|
+
export const runConnectionGrantList = list((dependencies) => dependencies.listConnectionGrants, readGrantList);
|
|
21
|
+
export const runConnectionPoolList = list((dependencies) => dependencies.listConnectionPools, readPoolList);
|
|
22
|
+
const PROMPT = {
|
|
23
|
+
describe: (preview) => formatConnectionAccessResult({ command: preview.method, result: preview }),
|
|
24
|
+
question: "Apply this change?",
|
|
25
|
+
};
|
|
26
|
+
const runSet = (spec, tokens, context) => Effect.gen(function* () {
|
|
27
|
+
const parsed = parseOptions(tokens, spec.options, new Set(spec.flags));
|
|
28
|
+
const mode = readTwoPhaseMode(parsed.flags, context);
|
|
29
|
+
const send = spec.confirm(context.dependencies);
|
|
30
|
+
const preview = spec.preview(context.dependencies);
|
|
31
|
+
if (send === undefined || preview === undefined)
|
|
32
|
+
return yield* unavailable();
|
|
33
|
+
return yield* runTwoPhase({
|
|
34
|
+
confirm: (previewed) => Effect.flatMap(confirmParameters(spec.confirmSchema, previewed, ["current"]), send),
|
|
35
|
+
context,
|
|
36
|
+
mode,
|
|
37
|
+
preview: () => Effect.flatMap(spec.read(parsed), preview),
|
|
38
|
+
prompt: PROMPT,
|
|
39
|
+
writeConfirm: write(context),
|
|
40
|
+
writePreview: write(context),
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
const set = (spec) => (tokens, context) => runSet(spec, tokens, context);
|
|
44
|
+
export const runConnectionGrantSet = set({
|
|
45
|
+
confirm: (dependencies) => dependencies.confirmConnectionGrant,
|
|
46
|
+
confirmSchema: connectionGrantSetConfirmParametersSchema,
|
|
47
|
+
flags: ["--revoke", ...TWO_PHASE_FLAGS],
|
|
48
|
+
options: GRANT_SET_OPTIONS,
|
|
49
|
+
preview: (dependencies) => dependencies.previewConnectionGrant,
|
|
50
|
+
read: readGrantPreview,
|
|
51
|
+
});
|
|
52
|
+
export const runConnectionPoolSet = set({
|
|
53
|
+
confirm: (dependencies) => dependencies.confirmConnectionPool,
|
|
54
|
+
confirmSchema: connectionPoolSetConfirmParametersSchema,
|
|
55
|
+
flags: TWO_PHASE_FLAGS,
|
|
56
|
+
options: POOL_SET_OPTIONS,
|
|
57
|
+
preview: (dependencies) => dependencies.previewConnectionPool,
|
|
58
|
+
read: readPoolPreview,
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConnectionGrantListResult, ConnectionGrantSetConfirmResult, ConnectionGrantSetPreviewResult, ConnectionPoolListResult, ConnectionPoolSetConfirmResult, ConnectionPoolSetPreviewResult } from "@maiaos/sdk";
|
|
2
|
+
export type ConnectionAccessResult = ConnectionGrantListResult | ConnectionGrantSetConfirmResult | ConnectionGrantSetPreviewResult | ConnectionPoolListResult | ConnectionPoolSetConfirmResult | ConnectionPoolSetPreviewResult;
|
|
3
|
+
export type CliConnectionAccessResult = {
|
|
4
|
+
readonly command: ConnectionAccessResult["method"];
|
|
5
|
+
readonly result: ConnectionAccessResult;
|
|
6
|
+
};
|
|
7
|
+
export declare const formatConnectionAccessResult: ({ result, }: CliConnectionAccessResult) => string;
|
|
8
|
+
//# sourceMappingURL=format.d.ts.map
|