@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/cli/cli.js +70 -13
- package/dist/command-line/context.d.ts +13 -4
- package/dist/command-line/context.js +1 -1
- package/dist/command-line/index.d.ts +5 -5
- package/dist/command-line/index.js +5 -4
- package/dist/command-line/input/index.d.ts +1 -1
- package/dist/command-line/input/index.js +1 -1
- 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/client.d.ts +93 -1
- package/dist/connection/client.js +7 -1
- package/dist/connection/index.d.ts +1 -1
- package/dist/connection/index.js +1 -1
- package/dist/connection/system.d.ts +1 -0
- package/dist/connection/system.js +109 -5
- package/dist/connection/tree/tree.js +17 -4
- 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 +8 -4
- package/dist/local-node/client.js +20 -9
- package/dist/local-node/index.d.ts +1 -1
- package/dist/local-node/index.js +1 -1
- package/dist/login/commands.js +2 -1
- package/dist/mcp/calls.d.ts +1 -0
- package/dist/mcp/calls.js +36 -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 +20 -17
- 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 +46 -25
- 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 +24 -6
- 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 +4 -2
- package/dist/session/client.js +4 -15
- package/dist/session/commands.js +76 -9
- package/dist/session/create-tasks.js +29 -11
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -0
- 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.js +21 -10
- package/dist/session/output/index.d.ts +1 -1
- package/dist/session/output/index.js +1 -1
- package/dist/session/output/tasks.d.ts +16 -1
- package/dist/session/output/tasks.js +41 -27
- package/dist/session/tree/tree.js +56 -8
- package/dist/session/turn/client.d.ts +4 -1
- package/dist/session/turn/client.js +15 -2
- package/dist/session/turn/commands.d.ts +2 -0
- package/dist/session/turn/commands.js +38 -5
- 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/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/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 +15 -15
- package/package.json +8 -6
|
@@ -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
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
listConnectionModels: (input: ConnectionModelsListParameters) => import("../local-node/client.js").CliNodeEffect<{
|
|
@@ -600,6 +600,22 @@ export declare const makeConnectionClient: (node: CliNodeOperations) => {
|
|
|
600
600
|
} | undefined;
|
|
601
601
|
readonly executableApproved: boolean;
|
|
602
602
|
readonly executor: "claude-code" | "codex-cli";
|
|
603
|
+
readonly upkeep?: {
|
|
604
|
+
readonly approved?: {
|
|
605
|
+
readonly launchable: "unknown" | "yes";
|
|
606
|
+
readonly version?: string | undefined;
|
|
607
|
+
} | undefined;
|
|
608
|
+
readonly available?: {
|
|
609
|
+
readonly checkedAt: string;
|
|
610
|
+
readonly source: "npm-registry";
|
|
611
|
+
readonly version: string;
|
|
612
|
+
} | undefined;
|
|
613
|
+
readonly policy: "notify" | "off";
|
|
614
|
+
readonly proposal?: {
|
|
615
|
+
readonly command: string;
|
|
616
|
+
readonly kind: "approve-installed" | "update-available";
|
|
617
|
+
} | undefined;
|
|
618
|
+
} | undefined;
|
|
603
619
|
readonly workerPrompt?: "failed" | "inconclusive" | "ok" | undefined;
|
|
604
620
|
}, {
|
|
605
621
|
readonly accountKind?: string | undefined;
|
|
@@ -624,6 +640,22 @@ export declare const makeConnectionClient: (node: CliNodeOperations) => {
|
|
|
624
640
|
} | undefined;
|
|
625
641
|
readonly executableApproved: boolean;
|
|
626
642
|
readonly executor: "claude-code" | "codex-cli";
|
|
643
|
+
readonly upkeep?: {
|
|
644
|
+
readonly approved?: {
|
|
645
|
+
readonly launchable: "unknown" | "yes";
|
|
646
|
+
readonly version?: string | undefined;
|
|
647
|
+
} | undefined;
|
|
648
|
+
readonly available?: {
|
|
649
|
+
readonly checkedAt: string;
|
|
650
|
+
readonly source: "npm-registry";
|
|
651
|
+
readonly version: string;
|
|
652
|
+
} | undefined;
|
|
653
|
+
readonly policy: "notify" | "off";
|
|
654
|
+
readonly proposal?: {
|
|
655
|
+
readonly command: string;
|
|
656
|
+
readonly kind: "approve-installed" | "update-available";
|
|
657
|
+
} | undefined;
|
|
658
|
+
} | undefined;
|
|
627
659
|
readonly workerPrompt?: "failed" | "inconclusive" | "ok" | undefined;
|
|
628
660
|
}];
|
|
629
661
|
readonly method: "connection.detect";
|
|
@@ -687,6 +719,66 @@ export declare const makeConnectionClient: (node: CliNodeOperations) => {
|
|
|
687
719
|
readonly method: "connection.system.preview";
|
|
688
720
|
readonly proof: string;
|
|
689
721
|
}>;
|
|
722
|
+
confirmConnectionUpkeep: (input: ConnectionUpkeepConfirmParameters) => import("../local-node/client.js").CliNodeEffect<{
|
|
723
|
+
readonly actorId: string;
|
|
724
|
+
readonly commandId: string;
|
|
725
|
+
readonly delivery: "duplicate" | "new";
|
|
726
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
727
|
+
readonly inputDigest: string;
|
|
728
|
+
readonly method: "connection.upkeep.confirm";
|
|
729
|
+
readonly policy: "notify" | "off";
|
|
730
|
+
readonly policyRevision: number;
|
|
731
|
+
readonly receipt: {
|
|
732
|
+
readonly actorId: string;
|
|
733
|
+
readonly aggregateRevision: string;
|
|
734
|
+
readonly commandId: string;
|
|
735
|
+
readonly createdAt: string;
|
|
736
|
+
readonly eventCursor: string;
|
|
737
|
+
readonly method: string;
|
|
738
|
+
readonly receiptId: string;
|
|
739
|
+
readonly schemaVersion: 1;
|
|
740
|
+
readonly state: "succeeded";
|
|
741
|
+
readonly target: {
|
|
742
|
+
readonly id: string;
|
|
743
|
+
readonly type: string;
|
|
744
|
+
};
|
|
745
|
+
readonly updatedAt: string;
|
|
746
|
+
};
|
|
747
|
+
}>;
|
|
748
|
+
previewConnectionUpkeep: (input: ConnectionUpkeepPreviewParameters) => import("../local-node/client.js").CliNodeEffect<{
|
|
749
|
+
readonly actorId: string;
|
|
750
|
+
readonly authorizationRevision: number;
|
|
751
|
+
readonly commandId: string;
|
|
752
|
+
readonly current: "notify" | "off";
|
|
753
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
754
|
+
readonly expiresAt: string;
|
|
755
|
+
readonly inputDigest: string;
|
|
756
|
+
readonly issuedAt: string;
|
|
757
|
+
readonly method: "connection.upkeep.preview";
|
|
758
|
+
readonly policy: "notify" | "off";
|
|
759
|
+
readonly policyRevision: number;
|
|
760
|
+
readonly proof: string;
|
|
761
|
+
}>;
|
|
762
|
+
refreshConnectionUpkeep: (input: ConnectionUpkeepRefreshParameters) => import("../local-node/client.js").CliNodeEffect<{
|
|
763
|
+
readonly executors: readonly [{
|
|
764
|
+
readonly available?: {
|
|
765
|
+
readonly checkedAt: string;
|
|
766
|
+
readonly source: "npm-registry";
|
|
767
|
+
readonly version: string;
|
|
768
|
+
} | undefined;
|
|
769
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
770
|
+
readonly refreshed: boolean;
|
|
771
|
+
}, {
|
|
772
|
+
readonly available?: {
|
|
773
|
+
readonly checkedAt: string;
|
|
774
|
+
readonly source: "npm-registry";
|
|
775
|
+
readonly version: string;
|
|
776
|
+
} | undefined;
|
|
777
|
+
readonly executor: "claude-code" | "codex-cli";
|
|
778
|
+
readonly refreshed: boolean;
|
|
779
|
+
}];
|
|
780
|
+
readonly method: "connection.upkeep.refresh";
|
|
781
|
+
}>;
|
|
690
782
|
};
|
|
691
783
|
export type ConnectionCliDependencies = ReturnType<typeof makeConnectionClient>;
|
|
692
784
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
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
2
|
const readClient = (node) => ({
|
|
3
3
|
listConnectionModels: (input) => node.runValidatedNodeOperation(input, connectionModelsListParametersSchema, (client, parameters, options) => client.listConnectionModels(parameters, options)),
|
|
4
4
|
listConnections: (input) => node.runValidatedNodeOperation(input, connectionListParametersSchema, (client, parameters, options) => client.listConnections(parameters, options)),
|
|
@@ -19,10 +19,16 @@ const systemClient = (node) => ({
|
|
|
19
19
|
detectConnections: (input) => node.runValidatedNodeOperation(input, connectionDetectParametersSchema, (client, parameters, options) => client.detectConnections(parameters, options)),
|
|
20
20
|
previewSystemConnections: (input) => node.runValidatedNodeOperation(input, connectionSystemPreviewParametersSchema, (client, parameters, options) => client.previewSystemConnections(parameters, options)),
|
|
21
21
|
});
|
|
22
|
+
const upkeepClient = (node) => ({
|
|
23
|
+
confirmConnectionUpkeep: (input) => node.runValidatedNodeOperation(input, connectionUpkeepConfirmParametersSchema, (client, parameters, options) => client.confirmConnectionUpkeep(parameters, options), { commandId: input.commandId }),
|
|
24
|
+
previewConnectionUpkeep: (input) => node.runValidatedNodeOperation(input, connectionUpkeepPreviewParametersSchema, (client, parameters, options) => client.previewConnectionUpkeep(parameters, options)),
|
|
25
|
+
refreshConnectionUpkeep: (input) => node.runValidatedNodeOperation(input, connectionUpkeepRefreshParametersSchema, (client, parameters, options) => client.refreshConnectionUpkeep(parameters, options)),
|
|
26
|
+
});
|
|
22
27
|
export const makeConnectionClient = (node) => ({
|
|
23
28
|
...readClient(node),
|
|
24
29
|
...mutationClient(node),
|
|
25
30
|
...signInClient(node),
|
|
26
31
|
...systemClient(node),
|
|
32
|
+
...upkeepClient(node),
|
|
27
33
|
});
|
|
28
34
|
//# sourceMappingURL=client.js.map
|
|
@@ -3,5 +3,5 @@ export { runConnectionCapacitySet, runConnectionCreate, runConnectionDisable, ru
|
|
|
3
3
|
export { runVendorLogin } from "./login.js";
|
|
4
4
|
export { describeConnection, formatConnectionResult, redactConnection, redactConnectionResult, } from "./output/index.js";
|
|
5
5
|
export { callNode, ConnectionNodeError, findConnectionByName, } from "./resolve.js";
|
|
6
|
-
export { runConnectionDetect, runSetup } from "./system.js";
|
|
6
|
+
export { runConnectionDetect, runConnectionUpdatePolicySet, runSetup, } from "./system.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/connection/index.js
CHANGED
|
@@ -3,5 +3,5 @@ export { runConnectionCapacitySet, runConnectionCreate, runConnectionDisable, ru
|
|
|
3
3
|
export { runVendorLogin } from "./login.js";
|
|
4
4
|
export { describeConnection, formatConnectionResult, redactConnection, redactConnectionResult, } from "./output/index.js";
|
|
5
5
|
export { callNode, ConnectionNodeError, findConnectionByName, } from "./resolve.js";
|
|
6
|
-
export { runConnectionDetect, runSetup } from "./system.js";
|
|
6
|
+
export { runConnectionDetect, runConnectionUpdatePolicySet, runSetup, } from "./system.js";
|
|
7
7
|
//# 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 ?
|
|
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
|
-
|
|
54
|
-
|
|
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
|
: {
|