@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/package.json +10 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
type Output = {
|
|
3
|
+
readonly on: (event: "close" | "error", listener: () => void) => unknown;
|
|
4
|
+
readonly writableLength: number;
|
|
5
|
+
readonly write: (chunk: string, callback?: () => void) => unknown;
|
|
6
|
+
};
|
|
7
|
+
type ExitingProcess = {
|
|
8
|
+
readonly exit: (code: number) => void;
|
|
9
|
+
readonly stderr: Output;
|
|
10
|
+
readonly stdout: Output;
|
|
11
|
+
};
|
|
12
|
+
export declare const exitAfterOutput: (program: Effect.Effect<number>, host: ExitingProcess) => Effect.Effect<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=exit.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
2
|
+
import * as Deferred from "effect/Deferred";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Exit from "effect/Exit";
|
|
5
|
+
import * as Fiber from "effect/Fiber";
|
|
6
|
+
const EXIT_INTERRUPTED = 130;
|
|
7
|
+
const watch = (output) => Effect.gen(function* () {
|
|
8
|
+
const ended = yield* Deferred.make();
|
|
9
|
+
const end = () => {
|
|
10
|
+
Deferred.doneUnsafe(ended, Effect.succeed(true));
|
|
11
|
+
};
|
|
12
|
+
output.on("error", end);
|
|
13
|
+
output.on("close", end);
|
|
14
|
+
const flushed = Effect.callback((resume) => {
|
|
15
|
+
if (output.writableLength === 0) {
|
|
16
|
+
resume(Effect.succeed(true));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
output.write("", () => {
|
|
20
|
+
resume(Effect.succeed(true));
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return Effect.raceFirst(Deferred.await(ended), flushed);
|
|
24
|
+
});
|
|
25
|
+
const exitCode = (exit, stderr) => {
|
|
26
|
+
if (Exit.isSuccess(exit))
|
|
27
|
+
return exit.value;
|
|
28
|
+
if (Cause.hasInterruptsOnly(exit.cause))
|
|
29
|
+
return EXIT_INTERRUPTED;
|
|
30
|
+
stderr.write(`${Cause.pretty(exit.cause)}\n`);
|
|
31
|
+
return 1;
|
|
32
|
+
};
|
|
33
|
+
export const exitAfterOutput = (program, host) => Effect.gen(function* () {
|
|
34
|
+
const drains = [yield* watch(host.stdout), yield* watch(host.stderr)];
|
|
35
|
+
const running = yield* Effect.forkChild(program, {
|
|
36
|
+
startImmediately: true,
|
|
37
|
+
});
|
|
38
|
+
const code = exitCode(yield* Fiber.await(running), host.stderr);
|
|
39
|
+
yield* Effect.all(drains, { concurrency: "unbounded", discard: true });
|
|
40
|
+
host.exit(code);
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=exit.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import * as Cause from "effect/Cause";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
4
|
-
import
|
|
3
|
+
import { constVoid } from "effect/Function";
|
|
5
4
|
import * as Runtime from "effect/Runtime";
|
|
6
5
|
import { promptLine, terminalIsInteractive, } from "../command-line/input/index.js";
|
|
6
|
+
import { exitAfterOutput } from "./exit.js";
|
|
7
7
|
const readProcessStdin = (request) => Effect.promise(() => import("./stdio.js")).pipe(Effect.flatMap((stdio) => stdio.readStdin(request)));
|
|
8
8
|
export const processIo = () => ({
|
|
9
9
|
interactive: terminalIsInteractive(),
|
|
@@ -16,30 +16,8 @@ export const processIo = () => ({
|
|
|
16
16
|
process.stdout.write(text);
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
const runMain = Runtime.makeRunMain(({ fiber, teardown }) => {
|
|
21
|
-
fiber.addObserver((exit) => {
|
|
22
|
-
teardown(exit, (code) => {
|
|
23
|
-
process.exitCode = code;
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
19
|
+
const runMain = Runtime.makeRunMain(constVoid);
|
|
27
20
|
export const runProcessMain = (program) => {
|
|
28
|
-
runMain(program, {
|
|
29
|
-
disableErrorReporting: true,
|
|
30
|
-
teardown: (exit, onExit) => {
|
|
31
|
-
if (Exit.isSuccess(exit) && typeof exit.value === "number") {
|
|
32
|
-
onExit(exit.value);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause)) {
|
|
36
|
-
onExit(EXIT_INTERRUPTED);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (Exit.isFailure(exit))
|
|
40
|
-
process.stderr.write(`${Cause.pretty(exit.cause)}\n`);
|
|
41
|
-
onExit(1);
|
|
42
|
-
},
|
|
43
|
-
});
|
|
21
|
+
runMain(exitAfterOutput(program, process), { disableErrorReporting: true });
|
|
44
22
|
};
|
|
45
23
|
//# sourceMappingURL=process.js.map
|
package/dist/bootstrap/run.js
CHANGED
|
@@ -17,12 +17,15 @@ const probePayloads = (dependencies) => Effect.all([
|
|
|
17
17
|
probe(dependencies.loadAgent, (module) => typeof module.runMaiaAgent === "function"),
|
|
18
18
|
]).pipe(Effect.map(([cliPayload, agent]) => ({ agent, cliPayload })));
|
|
19
19
|
const formatInstallation = (checks) => `Maia doctor failed\n${checks
|
|
20
|
-
.map((check) => ` ${check.code}: ${check.ok ? "ok" : "failed; next: reinstall Maia"}`)
|
|
20
|
+
.map((check) => ` ${check.code} (this machine): ${check.ok ? "ok" : "failed; next: reinstall Maia"}`)
|
|
21
21
|
.join("\n")}\n`;
|
|
22
22
|
const writeInstallationFailure = (output) => {
|
|
23
23
|
const { arguments_, checks, input } = output;
|
|
24
24
|
const result = {
|
|
25
|
-
checks: checks.map((check) =>
|
|
25
|
+
checks: checks.map((check) => ({
|
|
26
|
+
...(check.ok ? check : { ...check, next: "reinstall Maia" }),
|
|
27
|
+
scope: "machine",
|
|
28
|
+
})),
|
|
26
29
|
command: "doctor",
|
|
27
30
|
ok: false,
|
|
28
31
|
version: input.version,
|
package/dist/cli/cli.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import type * as Scope from "effect/Scope";
|
|
3
3
|
import { type CliDependencies, type CliIo } from "../command-line/index.js";
|
|
4
4
|
import type { CliNodeConnector } from "../local-node/index.js";
|
|
5
|
+
import type { SshLayer } from "../remote-node/index.js";
|
|
5
6
|
export type { CliDependencies, CliErrorOutput, CliIo, CliSuccessOutput, CliSuccessResult, } from "../command-line/index.js";
|
|
6
7
|
export type { CliHelpResult, CliVersionResult } from "../command-tree/index.js";
|
|
7
8
|
export type { CliStatusResult } from "../status/index.js";
|
|
@@ -12,6 +13,6 @@ export type CliRemoteNode = {
|
|
|
12
13
|
export type CliDependencyResolver = (profile: string | undefined, remote?: CliRemoteNode) => CliDependencies;
|
|
13
14
|
type CliDependencySource = CliDependencies | CliDependencyResolver;
|
|
14
15
|
export declare const makeCli: (dependencies: CliDependencySource) => (arguments_: readonly string[], version: string, io: CliIo) => Effect.Effect<number>;
|
|
15
|
-
export declare const makeCliDependencies: (connector?: CliNodeConnector) => CliDependencyResolver;
|
|
16
|
+
export declare const makeCliDependencies: (connector?: CliNodeConnector, ssh?: SshLayer) => CliDependencyResolver;
|
|
16
17
|
export declare const runCli: (arguments_: readonly string[], version: string, io: CliIo) => Effect.Effect<number>;
|
|
17
18
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Cause from "effect/Cause";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import { argumentsAreBounded, CliArgumentError, parseArguments, readGlobalValue, reportError, writeSuccess, } from "../command-line/index.js";
|
|
3
|
+
import { argumentsAreBounded, CliArgumentError, LOCAL_NODE, parseArguments, readGlobalValue, reportError, writeSuccess, } from "../command-line/index.js";
|
|
4
4
|
import { createHelpTree, createNodeHelp, findNode, formatNodeHelp, formatRootHelp, isNodeBacked, REFERENCE_USAGE, unknownPathMessage, usageHint, } from "../command-tree/index.js";
|
|
5
5
|
const createArgumentError = (message) => ({
|
|
6
6
|
code: "invalid_argument",
|
|
@@ -64,17 +64,23 @@ const resolveOptions = (parsed, leaf, environment) => {
|
|
|
64
64
|
...(profile === undefined ? {} : { profile }),
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
+
const remoteName = (parsed) => parsed.node === LOCAL_NODE ? undefined : parsed.node;
|
|
67
68
|
const resolveInvocationDependencies = (source, parsed, scope) => {
|
|
69
|
+
const name = remoteName(parsed);
|
|
68
70
|
if (typeof source !== "function") {
|
|
69
|
-
if (parsed.profile !== undefined ||
|
|
71
|
+
if (parsed.profile !== undefined || name !== undefined)
|
|
70
72
|
throw new CliArgumentError("This CLI dependency binding does not support '--profile' or '--node'.");
|
|
71
73
|
return source;
|
|
72
74
|
}
|
|
73
|
-
return
|
|
75
|
+
return name === undefined || scope === undefined
|
|
74
76
|
? source(parsed.profile)
|
|
75
|
-
: source(parsed.profile, { name
|
|
77
|
+
: source(parsed.profile, { name, scope });
|
|
76
78
|
};
|
|
79
|
+
const nodeBinder = (source, profile, scope) => typeof source === "function" && scope !== undefined
|
|
80
|
+
? { bindNode: (name) => source(profile, { name, scope }) }
|
|
81
|
+
: {};
|
|
77
82
|
const commandContext = (input, parsed, scope) => ({
|
|
83
|
+
...nodeBinder(input.dependencies, parsed.profile, scope),
|
|
78
84
|
dependencies: resolveInvocationDependencies(input.dependencies, parsed, scope),
|
|
79
85
|
io: parsed.noInput ? { ...input.io, interactive: false } : input.io,
|
|
80
86
|
json: parsed.json,
|
|
@@ -132,11 +138,11 @@ const leafProgram = (leaf, rest, context) => {
|
|
|
132
138
|
});
|
|
133
139
|
};
|
|
134
140
|
const withCliServices = (program) => Effect.promise(() => import("./services.js")).pipe(Effect.flatMap((services) => services.provideCliServices(program)));
|
|
135
|
-
const
|
|
141
|
+
const runPrepared = (leaf, rest, context) => {
|
|
136
142
|
const usage = leaf.forms[0]?.usage ?? "";
|
|
137
143
|
if (!REFERENCE_USAGE.test(usage) || context.dependencies.call === undefined)
|
|
138
|
-
return
|
|
139
|
-
|
|
144
|
+
return leafProgram(leaf, rest, context);
|
|
145
|
+
return Effect.promise(() => import("../reference/index.js")).pipe(Effect.flatMap((module) => module.prepareLeaf({
|
|
140
146
|
context,
|
|
141
147
|
cwd: module.workingFolder(context.io.cwd),
|
|
142
148
|
tokens: rest,
|
|
@@ -144,7 +150,18 @@ const runResolved = (leaf, rest, context) => {
|
|
|
144
150
|
})), Effect.flatMap((prepared) => prepared.ok
|
|
145
151
|
? leafProgram(leaf, prepared.tokens, prepared.context)
|
|
146
152
|
: Effect.succeed(prepared.exitCode)));
|
|
147
|
-
|
|
153
|
+
};
|
|
154
|
+
const runResolved = (leaf, rest, context) => {
|
|
155
|
+
const { forms, route } = leaf;
|
|
156
|
+
const prepared = (bound) => runPrepared(leaf, rest, bound);
|
|
157
|
+
if (route === undefined)
|
|
158
|
+
return withCliServices(prepared(context));
|
|
159
|
+
const routed = {
|
|
160
|
+
argument: route,
|
|
161
|
+
tokens: rest,
|
|
162
|
+
usage: forms[0]?.usage ?? "",
|
|
163
|
+
};
|
|
164
|
+
return withCliServices(Effect.flatMap(Effect.promise(() => import("../address-space/index.js")), (module) => module.routeLeaf(context, routed, prepared)));
|
|
148
165
|
};
|
|
149
166
|
const runParsed = (input, parsed) => {
|
|
150
167
|
if (isHelpInvocation(parsed))
|
|
@@ -157,9 +174,7 @@ const runParsed = (input, parsed) => {
|
|
|
157
174
|
!parsed.json)
|
|
158
175
|
input.io.stderr(`node: ${resolved.node} (MAIA_NODE)\n`);
|
|
159
176
|
const run = (scope) => Effect.suspend(() => runResolved(leaf, rest, commandContext(input, resolved, scope)));
|
|
160
|
-
return yield*
|
|
161
|
-
? run()
|
|
162
|
-
: Effect.scoped(Effect.flatMap(Effect.scope, run));
|
|
177
|
+
return yield* Effect.scoped(Effect.flatMap(Effect.scope, run));
|
|
163
178
|
});
|
|
164
179
|
};
|
|
165
180
|
const executeCli = (input) => Effect.suspend(() => {
|
|
@@ -185,6 +200,7 @@ const loadStatus = () => import("../status/index.js");
|
|
|
185
200
|
const loadContext = () => import("../context/index.js");
|
|
186
201
|
const loadContainer = () => import("../container/index.js");
|
|
187
202
|
const loadHold = () => import("../hold/index.js");
|
|
203
|
+
const loadRoutine = () => import("../routine/index.js");
|
|
188
204
|
const loadImport = () => import("../import/index.js");
|
|
189
205
|
const loadInteraction = () => import("../session/interaction/index.js");
|
|
190
206
|
const loadConnection = () => import("../connection/index.js");
|
|
@@ -196,7 +212,9 @@ const loadApproval = () => import("../session/approval/index.js");
|
|
|
196
212
|
const loadRemoteNode = () => import("../remote-node/index.js");
|
|
197
213
|
const loadRunLedger = () => import("../run-ledger/index.js");
|
|
198
214
|
const loadProjectGuard = () => import("../project-guard/index.js");
|
|
215
|
+
const loadAgents = () => import("../agents/index.js");
|
|
199
216
|
const loadLocalNode = () => import("../local-node/index.js");
|
|
217
|
+
const loadBootstrap = () => import("../team-workspace/index.js");
|
|
200
218
|
const lazyDependencies = (load, makeClient, binding) => Object.fromEntries(binding.names.map((name) => [
|
|
201
219
|
name,
|
|
202
220
|
(...arguments_) => Effect.promise(() => import("../local-node/index.js")).pipe(Effect.flatMap((module) => module.runLazyNodeDependency({
|
|
@@ -237,9 +255,15 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
237
255
|
...lazyDependencies(loadConnection, (module, node) => module.makeConnectionClient(node), {
|
|
238
256
|
...binding,
|
|
239
257
|
names: [
|
|
258
|
+
"confirmConnectionGrant",
|
|
259
|
+
"confirmConnectionPool",
|
|
240
260
|
"createConnection",
|
|
241
261
|
"createGatewayConnection",
|
|
262
|
+
"listConnectionGrants",
|
|
263
|
+
"listConnectionPools",
|
|
242
264
|
"listConnections",
|
|
265
|
+
"previewConnectionGrant",
|
|
266
|
+
"previewConnectionPool",
|
|
243
267
|
"listConnectionModels",
|
|
244
268
|
"showConnection",
|
|
245
269
|
"showConnectionUsage",
|
|
@@ -249,6 +273,9 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
249
273
|
"detectConnections",
|
|
250
274
|
"previewSystemConnections",
|
|
251
275
|
"confirmSystemConnections",
|
|
276
|
+
"refreshConnectionUpkeep",
|
|
277
|
+
"previewConnectionUpkeep",
|
|
278
|
+
"confirmConnectionUpkeep",
|
|
252
279
|
],
|
|
253
280
|
}),
|
|
254
281
|
...lazyDependencies(loadInteraction, (module, node) => module.makeInteractionClient(node), {
|
|
@@ -292,6 +319,21 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
292
319
|
"confirmHoldRelease",
|
|
293
320
|
],
|
|
294
321
|
}),
|
|
322
|
+
...lazyDependencies(loadRoutine, (module, node) => module.makeRoutineCliClient(node), {
|
|
323
|
+
...binding,
|
|
324
|
+
names: [
|
|
325
|
+
"listRoutines",
|
|
326
|
+
"showRoutine",
|
|
327
|
+
"previewRoutineCreate",
|
|
328
|
+
"confirmRoutineCreate",
|
|
329
|
+
"pauseRoutine",
|
|
330
|
+
"resumeRoutine",
|
|
331
|
+
"previewRoutineDisable",
|
|
332
|
+
"confirmRoutineDisable",
|
|
333
|
+
"previewRoutineRun",
|
|
334
|
+
"confirmRoutineRun",
|
|
335
|
+
],
|
|
336
|
+
}),
|
|
295
337
|
...lazyDependencies(() => import("../project-workspace/index.js"), (module, node) => module.makeProjectMetadataClient(node), {
|
|
296
338
|
...binding,
|
|
297
339
|
names: [
|
|
@@ -377,6 +419,7 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
377
419
|
"sendAttachedSessionMessage",
|
|
378
420
|
"showExecutionRelocation",
|
|
379
421
|
"showSession",
|
|
422
|
+
"waitSession",
|
|
380
423
|
"startSession",
|
|
381
424
|
"stopSession",
|
|
382
425
|
],
|
|
@@ -401,7 +444,14 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
401
444
|
}),
|
|
402
445
|
...lazyDependencies(loadTurn, (module, node) => module.makeTurnClient(node), {
|
|
403
446
|
...binding,
|
|
404
|
-
names: [
|
|
447
|
+
names: [
|
|
448
|
+
"cancelTurn",
|
|
449
|
+
"interruptTurn",
|
|
450
|
+
"listTurnQueue",
|
|
451
|
+
"sendTurn",
|
|
452
|
+
"showTurn",
|
|
453
|
+
"waitTurns",
|
|
454
|
+
],
|
|
405
455
|
}),
|
|
406
456
|
...lazyDependencies(loadContext, (module, node) => module.makeContextClient(node), { ...binding, names: ["showAttachedCurrentContext", "showCurrentContext"] }),
|
|
407
457
|
...lazyDependencies(loadApproval, (module, node) => module.makeApprovalClient(node), {
|
|
@@ -432,36 +482,51 @@ const makeDefaultCliDependencies = (binding) => ({
|
|
|
432
482
|
...binding,
|
|
433
483
|
names: ["confirmProjectGuard", "previewProjectGuard", "showProjectGuard"],
|
|
434
484
|
}),
|
|
485
|
+
...lazyDependencies(loadAgents, (module, node) => module.makeAgentsClient(node), {
|
|
486
|
+
...binding,
|
|
487
|
+
names: [
|
|
488
|
+
"confirmAgentChange",
|
|
489
|
+
"listAgents",
|
|
490
|
+
"previewAgentChange",
|
|
491
|
+
"showAgent",
|
|
492
|
+
],
|
|
493
|
+
}),
|
|
435
494
|
...lazyDependencies(loadRemoteNode, (module, node) => module.makeRemoteNodeClient(node), {
|
|
436
495
|
...binding,
|
|
437
496
|
names: [
|
|
438
497
|
"confirmRemoteNodeInstall",
|
|
498
|
+
"confirmRemoteNodeRegister",
|
|
439
499
|
"confirmRemoteNodeRemove",
|
|
440
500
|
"listRemoteNodes",
|
|
441
501
|
"previewRemoteNodeInstall",
|
|
502
|
+
"previewRemoteNodeRegister",
|
|
442
503
|
"previewRemoteNodeRemove",
|
|
443
504
|
],
|
|
444
505
|
}),
|
|
445
506
|
...lazyDependencies(loadLocalNode, (module, node) => module.makeCallClient(node), { ...binding, names: ["call"] }),
|
|
507
|
+
...lazyDependencies(loadBootstrap, (module, node) => module.makeBootstrapClient(node), { ...binding, names: ["applyBootstrap", "previewBootstrap"] }),
|
|
508
|
+
confirmOnTerminal: (request) => Effect.promise(loadBootstrap).pipe(Effect.flatMap((module) => module.confirmOnControllingTerminal(request))),
|
|
509
|
+
startBootstrapNode: (profile) => Effect.promise(loadBootstrap).pipe(Effect.flatMap((module) => module.startBootstrapNode(profile))),
|
|
446
510
|
...lazyDependencies(loadMcp, (module, node) => module.makeMcpClient(node), {
|
|
447
511
|
...binding,
|
|
448
|
-
names: ["serveMcp"],
|
|
512
|
+
names: ["callCoordinatorTool", "serveMcp"],
|
|
449
513
|
}),
|
|
450
514
|
...lazyDependencies(loadStatus, (module, node) => module.makeStatusClient(node), { ...binding, names: ["createMonitorBootstrap", "readStatus"] }),
|
|
451
515
|
});
|
|
452
|
-
const remoteConnector = (remote, local) => {
|
|
516
|
+
const remoteConnector = (remote, local, ssh) => {
|
|
453
517
|
const cache = {};
|
|
454
518
|
return (options) => Effect.promise(loadRemoteNode).pipe(Effect.flatMap((module) => {
|
|
455
519
|
cache.connector ??= module.makeRemoteNodeConnector({
|
|
456
520
|
...(local === undefined ? {} : { local }),
|
|
457
521
|
name: remote.name,
|
|
458
522
|
scope: remote.scope,
|
|
523
|
+
...(ssh === undefined ? {} : { ssh }),
|
|
459
524
|
});
|
|
460
525
|
return cache.connector(options);
|
|
461
526
|
}));
|
|
462
527
|
};
|
|
463
528
|
const remoteSignIn = (remote, binding) => (connection) => Effect.promise(loadRemoteNode).pipe(Effect.flatMap((module) => module.remoteVendorLogin({ ...binding, name: remote.name })(connection)));
|
|
464
|
-
export const makeCliDependencies = (connector) => (profile, remote) => {
|
|
529
|
+
export const makeCliDependencies = (connector, ssh) => (profile, remote) => {
|
|
465
530
|
const binding = {
|
|
466
531
|
...(connector === undefined ? {} : { connector }),
|
|
467
532
|
...(profile === undefined ? {} : { profile }),
|
|
@@ -471,7 +536,7 @@ export const makeCliDependencies = (connector) => (profile, remote) => {
|
|
|
471
536
|
: {
|
|
472
537
|
...makeDefaultCliDependencies({
|
|
473
538
|
...binding,
|
|
474
|
-
connector: remoteConnector(remote, connector),
|
|
539
|
+
connector: remoteConnector(remote, connector, ssh),
|
|
475
540
|
remote: true,
|
|
476
541
|
}),
|
|
477
542
|
runVendorLogin: remoteSignIn(remote, binding),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AgentPermissionConfirmParameters, AgentPermissionConfirmResult, AgentPermissionPreviewParameters, AgentPermissionPreviewResult, ExecutionCatalogGetResult, ExecutionCommandRunResult, ExecutionFileReadResult, ExecutionPlacementCreateResult, ExecutionPlacementShowResult, ExecutionRelocationApplyResult, ExecutionRelocationPlanResult, ExecutionRelocationReconcileResult, ExecutionRelocationShowResult, ExecutionWorktreeCheckpointCreateResult, ExecutionWorktreeCheckpointShowResult, ExecutionWorktreeCreateResult, ExecutionWorktreeImportResult, ExecutionWorktreeReconcileResult, ExecutionWorktreeRemoveApplyResult, ExecutionWorktreeRemovePlanResult, ExecutionWorktreeStatusResult, InvocationContextShowResult, LiveTerminalCloseResult, LiveTerminalControllerAcquireResult, LiveTerminalControllerReleaseResult, LiveTerminalControllerRequestResult, LiveTerminalControllerRequestShowResult, LiveTerminalResizeResult, LiveTerminalSignalResult, LiveTerminalWriteResult, LocalNodeStatusResult, MonitorBootstrapCreateResult, OrchestrationDispatchSettleTerminalResult, OrchestrationDispatchShowResult, OrchestrationInboxAckResult, OrchestrationInboxCheckResult, OrchestrationQuestionCancelResult, OrchestrationQuestionOpenResult, OrchestrationQuestionReplyResult, OrchestrationRunCreateResult, OrchestrationRunListResult, OrchestrationRunShowResult, OrchestrationTaskListResult, OrchestrationTaskShowResult, ProjectContextListResult, ProjectContextRecordResult, ProjectContextShowResult, ProjectListResult, ProjectRegisterResult, ProjectShowResult, ProviderPoolListResult, ReceiptGetResult, ReceiptListParameters, ReceiptListResult, SessionArchiveResult, SessionCreateResult, SessionDiffResult, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionStartResult, SessionStopResult, TerminalCreateResult, TerminalEventsListResult, TerminalListResult, TerminalReadResult, TerminalShowResult, TurnInterruptResult, TurnSendResult, TurnShowResult, TurnWaitResult, WorkspaceContextShowResult, WorkspaceExecutionConfigureResult, WorkspaceExecutionShowResult, WorkspaceListResult, WorkspaceMembershipAttachResult, WorkspaceRepositoryAttachResult, WorkspaceSelectResult, WorkspaceShowResult } from "@maiaos/sdk";
|
|
1
|
+
import type { AgentPermissionConfirmParameters, AgentPermissionConfirmResult, AgentPermissionPreviewParameters, AgentPermissionPreviewResult, ExecutionCatalogGetResult, ExecutionCommandRunResult, ExecutionFileReadResult, ExecutionPlacementCreateResult, ExecutionPlacementShowResult, ExecutionRelocationApplyResult, ExecutionRelocationPlanResult, ExecutionRelocationReconcileResult, ExecutionRelocationShowResult, ExecutionWorktreeCheckpointCreateResult, ExecutionWorktreeCheckpointShowResult, ExecutionWorktreeCreateResult, ExecutionWorktreeImportResult, ExecutionWorktreeReconcileResult, ExecutionWorktreeRemoveApplyResult, ExecutionWorktreeRemovePlanResult, ExecutionWorktreeStatusResult, InvocationContextShowResult, LiveTerminalCloseResult, LiveTerminalControllerAcquireResult, LiveTerminalControllerReleaseResult, LiveTerminalControllerRequestResult, LiveTerminalControllerRequestShowResult, LiveTerminalResizeResult, LiveTerminalSignalResult, LiveTerminalWriteResult, LocalNodeStatusResult, MonitorBootstrapCreateResult, OrchestrationDispatchSettleTerminalResult, OrchestrationDispatchShowResult, OrchestrationInboxAckResult, OrchestrationInboxCheckResult, OrchestrationQuestionCancelResult, OrchestrationQuestionOpenResult, OrchestrationQuestionReplyResult, OrchestrationRunCreateResult, OrchestrationRunListResult, OrchestrationRunShowResult, OrchestrationTaskListResult, OrchestrationTaskShowResult, ProjectContextListResult, ProjectContextRecordResult, ProjectContextShowResult, ProjectListResult, ProjectRegisterResult, ProjectShowResult, ProviderPoolListResult, ReceiptGetResult, ReceiptListParameters, ReceiptListResult, SessionArchiveResult, SessionCreateResult, SessionDiffResult, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionStartResult, SessionStopResult, TerminalCreateResult, TerminalEventsListResult, TerminalListResult, TerminalReadResult, TerminalShowResult, TurnCancelResult, TurnInterruptResult, TurnQueueListResult, TurnSendResult, TurnShowResult, TurnWaitResult, WorkspaceContextShowResult, WorkspaceExecutionConfigureResult, WorkspaceExecutionShowResult, WorkspaceListResult, WorkspaceMembershipAttachResult, WorkspaceRepositoryAttachResult, WorkspaceSelectResult, WorkspaceShowResult } from "@maiaos/sdk";
|
|
2
2
|
import type * as Crypto from "effect/Crypto";
|
|
3
3
|
import type * as Effect from "effect/Effect";
|
|
4
|
+
import type { AgentsCliDependencies } from "../agents/index.js";
|
|
4
5
|
import type { ConnectionCliDependencies, VendorLogin } from "../connection/index.js";
|
|
5
6
|
import type { ContainerCliDependencies } from "../container/index.js";
|
|
6
7
|
import type { ApplyExecutionRelocationInput, PlanExecutionRelocationInput, ReconcileExecutionRelocationInput } from "../execution/index.js";
|
|
@@ -15,19 +16,21 @@ import type { PortLeaseCliDependencies } from "../port-lease/index.js";
|
|
|
15
16
|
import type { PresentationCliDependencies } from "../presentation/index.js";
|
|
16
17
|
import type { ProjectGuardCliDependencies } from "../project-guard/index.js";
|
|
17
18
|
import type { AttachRepositoryInput, AttachWorkspaceMembershipInput, ConfigureWorkspaceExecutionInput, CreateExecutionCheckpointInput, CreateExecutionPlacementInput, CreateExecutionWorktreeInput, ImportExecutionWorktreeInput, ProjectMetadataCliDependencies, ReadExecutionFileInput, ReconcileExecutionWorktreeInput, RecordProjectContextInput, RegisterProjectInput, RemoveExecutionWorktreeInput, RunExecutionCommandInput, SelectWorkspaceInput } from "../project-workspace/index.js";
|
|
18
|
-
import type { RemoteNodeCliDependencies } from "../remote-node/index.js";
|
|
19
|
+
import type { RemoteNodeCliDependencies, SshLayer } from "../remote-node/index.js";
|
|
20
|
+
import type { RoutineCliDependencies } from "../routine/index.js";
|
|
19
21
|
import type { RunLedgerCliDependencies } from "../run-ledger/index.js";
|
|
20
22
|
import type { ApprovalCliDependencies } from "../session/approval/index.js";
|
|
21
23
|
import type { ArchiveSessionInput, AttachSessionInput, CreateSessionInput, DiffSessionInput, ListSessionsInput, makeSessionClient, SessionAttachStream, StartSessionInput } from "../session/index.js";
|
|
22
24
|
import type { InteractionCliDependencies } from "../session/interaction/index.js";
|
|
23
|
-
import type { InterruptTurnInput, SendTurnInput, WaitTurnsInput } from "../session/turn/index.js";
|
|
25
|
+
import type { CancelTurnInput, InterruptTurnInput, SendTurnInput, WaitTurnsInput } from "../session/turn/index.js";
|
|
26
|
+
import type { BootstrapCliDependencies } from "../team-workspace/index.js";
|
|
24
27
|
import type { CreateTerminalInput, makeTerminalClient } from "../terminal/index.js";
|
|
25
28
|
import type { CliArgumentError } from "./input/index.js";
|
|
26
29
|
import type { CliIo, CliResolution } from "./output.js";
|
|
27
30
|
type OrchestrationClient = ReturnType<typeof makeOrchestrationClient>;
|
|
28
31
|
type SessionClient = ReturnType<typeof makeSessionClient>;
|
|
29
32
|
type TerminalClient = ReturnType<typeof makeTerminalClient>;
|
|
30
|
-
export type CliDependencies = Partial<ApprovalCliDependencies & ConnectionCliDependencies & ContainerCliDependencies & HoldCliDependencies & DiscoveryCliDependencies & IntegrationCliDependencies & PresentationCliDependencies & McpCliDependencies & InteractionCliDependencies & PortLeaseCliDependencies & ProjectGuardCliDependencies & ProjectMetadataCliDependencies & RemoteNodeCliDependencies & RunLedgerCliDependencies> & {
|
|
33
|
+
export type CliDependencies = Partial<AgentsCliDependencies & ApprovalCliDependencies & BootstrapCliDependencies & ConnectionCliDependencies & ContainerCliDependencies & HoldCliDependencies & DiscoveryCliDependencies & IntegrationCliDependencies & PresentationCliDependencies & McpCliDependencies & InteractionCliDependencies & PortLeaseCliDependencies & ProjectGuardCliDependencies & ProjectMetadataCliDependencies & RemoteNodeCliDependencies & RoutineCliDependencies & RunLedgerCliDependencies> & {
|
|
31
34
|
readonly acknowledgeAttachedSessionDelivery?: (input: Parameters<SessionClient["acknowledgeAttachedSessionDelivery"]>[0]) => CliNodeEffect<SessionInboxAckResult>;
|
|
32
35
|
readonly acknowledgeRunDelivery: (input: Parameters<OrchestrationClient["acknowledgeRunDelivery"]>[0]) => CliNodeEffect<OrchestrationInboxAckResult>;
|
|
33
36
|
readonly acquireTerminalController: (input: Parameters<TerminalClient["acquireTerminalController"]>[0]) => CliNodeEffect<LiveTerminalControllerAcquireResult>;
|
|
@@ -40,6 +43,7 @@ export type CliDependencies = Partial<ApprovalCliDependencies & ConnectionCliDep
|
|
|
40
43
|
readonly awaitSessionRunning?: SessionClient["awaitSessionRunning"];
|
|
41
44
|
readonly call?: CliNodeCall;
|
|
42
45
|
readonly cancelRunQuestion: (input: Parameters<OrchestrationClient["cancelRunQuestion"]>[0]) => CliNodeEffect<OrchestrationQuestionCancelResult>;
|
|
46
|
+
readonly cancelTurn?: (input: CancelTurnInput) => CliNodeEffect<TurnCancelResult>;
|
|
43
47
|
readonly checkAttachedSessionInbox?: (input: Parameters<SessionClient["checkAttachedSessionInbox"]>[0]) => CliNodeEffect<SessionInboxCheckResult>;
|
|
44
48
|
readonly checkRunInbox: (input: Parameters<OrchestrationClient["checkRunInbox"]>[0]) => CliNodeEffect<OrchestrationInboxCheckResult>;
|
|
45
49
|
readonly closeTerminal: (input: Parameters<TerminalClient["closeTerminal"]>[0]) => CliNodeEffect<LiveTerminalCloseResult>;
|
|
@@ -93,6 +97,7 @@ export type CliDependencies = Partial<ApprovalCliDependencies & ConnectionCliDep
|
|
|
93
97
|
readonly limit: number;
|
|
94
98
|
readonly workspaceId: string;
|
|
95
99
|
}) => CliNodeEffect<TerminalListResult>;
|
|
100
|
+
readonly listTurnQueue?: (sessionId: string) => CliNodeEffect<TurnQueueListResult>;
|
|
96
101
|
readonly listWorkspaces: (input: {
|
|
97
102
|
readonly afterCursor: string;
|
|
98
103
|
readonly limit: number;
|
|
@@ -158,18 +163,23 @@ export type CliDependencies = Partial<ApprovalCliDependencies & ConnectionCliDep
|
|
|
158
163
|
readonly showWorkspaceContext?: () => CliNodeEffect<WorkspaceContextShowResult>;
|
|
159
164
|
readonly showWorkspaceExecution?: (workspaceId: string) => CliNodeEffect<WorkspaceExecutionShowResult>;
|
|
160
165
|
readonly signalTerminal: (input: Parameters<TerminalClient["signalTerminal"]>[0]) => CliNodeEffect<LiveTerminalSignalResult>;
|
|
166
|
+
readonly sshLayer?: SshLayer;
|
|
161
167
|
readonly startSession: (input: StartSessionInput) => CliNodeEffect<SessionStartResult>;
|
|
162
168
|
readonly stopSession?: (input: StartSessionInput) => CliNodeEffect<SessionStopResult>;
|
|
169
|
+
readonly waitSession?: SessionClient["waitSession"];
|
|
163
170
|
readonly waitTurns?: (input: WaitTurnsInput) => CliNodeEffect<TurnWaitResult>;
|
|
164
171
|
readonly writeTerminalInput: (input: Parameters<TerminalClient["writeTerminalInput"]>[0]) => CliNodeEffect<LiveTerminalWriteResult>;
|
|
165
172
|
};
|
|
166
173
|
export type CliServices = Crypto.Crypto;
|
|
167
174
|
export type CommandEffect = Effect.Effect<number, CliArgumentError, CliServices>;
|
|
175
|
+
export declare const LOCAL_NODE = "local";
|
|
168
176
|
export type CommandContext = {
|
|
177
|
+
readonly bindNode?: (name: string) => CliDependencies;
|
|
169
178
|
readonly dependencies: CliDependencies;
|
|
170
179
|
readonly io: CliIo;
|
|
171
180
|
readonly json: boolean;
|
|
172
181
|
readonly node?: string;
|
|
182
|
+
readonly notFoundHint?: string;
|
|
173
183
|
readonly profile?: string;
|
|
174
184
|
readonly resolved?: readonly CliResolution[];
|
|
175
185
|
readonly version: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const LOCAL_NODE = "local";
|
|
2
2
|
//# sourceMappingURL=context.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { type CliDependencies, type CliServices, type CommandContext, type CommandEffect, } from "./context.js";
|
|
2
|
-
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
3
|
-
export { decodeJsonText } from "./json.js";
|
|
4
|
-
export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, type NodeResultPresenter, reportError, writeNodeResult, writeSuccess, } from "./output.js";
|
|
5
|
-
export { cell, formatRows, tab, withNextPage } from "./rows.js";
|
|
6
|
-
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, promptOrRefuse, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, type TwoPhaseMode, } from "./two-phase.js";
|
|
1
|
+
export { type CliDependencies, type CliServices, type CommandContext, type CommandEffect, LOCAL_NODE, } from "./context.js";
|
|
2
|
+
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
3
|
+
export { decodeJsonText, jsonLine } from "./json.js";
|
|
4
|
+
export { type CliCommandOutput, type CliErrorOutput, type CliIo, type CliResolution, type CliSuccessOutput, type CliSuccessResult, exitCodeOf, type NodeResultPresenter, reportError, writeNodeResult, writeSuccess, } from "./output.js";
|
|
5
|
+
export { block, cell, type CliTable, fields, formatRows, tab, withNextPage, } from "./rows.js";
|
|
6
|
+
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, type TwoPhaseMode, } from "./two-phase.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { LOCAL_NODE, } from "./context.js";
|
|
2
|
+
export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readBoundedStdin, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, recoverStdin, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./input/index.js";
|
|
3
|
+
export { decodeJsonText, jsonLine } from "./json.js";
|
|
4
|
+
export { exitCodeOf, reportError, writeNodeResult, writeSuccess, } from "./output.js";
|
|
5
|
+
export { block, cell, fields, formatRows, tab, withNextPage, } from "./rows.js";
|
|
6
|
+
export { askToConfirm, canPrompt, confirmationOf, confirmParameters, EXIT_CANCELLED, peekStdin, promptOrRefuse, readInputMode, readPipedPreview, readTwoPhaseMode, requestedTwoPhaseMode, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, } from "./two-phase.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -24,6 +24,12 @@ export declare const argumentsAreBounded: (arguments_: readonly string[]) => boo
|
|
|
24
24
|
type ValueOption = "--node" | "--profile";
|
|
25
25
|
export declare const readGlobalValue: (option: ValueOption, value: string | undefined) => string;
|
|
26
26
|
export declare const parseArguments: (arguments_: readonly string[]) => ParsedArguments;
|
|
27
|
+
export type OptionSpec = {
|
|
28
|
+
readonly allowed: ReadonlySet<string>;
|
|
29
|
+
readonly allowedFlags: ReadonlySet<string>;
|
|
30
|
+
readonly repeatable: ReadonlySet<string>;
|
|
31
|
+
};
|
|
32
|
+
export declare const parseOptionsWith: (tokens: readonly string[], spec: OptionSpec) => ParsedOptions;
|
|
27
33
|
export declare const parseOptions: (tokens: readonly string[], allowed: ReadonlySet<string>, allowedFlags?: ReadonlySet<string>) => ParsedOptions;
|
|
28
34
|
export declare const requirePositionals: (positionals: readonly string[], count: number) => void;
|
|
29
35
|
export declare const missingArgument: () => CliArgumentError;
|
|
@@ -37,6 +43,7 @@ export declare const readDuration: (value: string, option: `--${string}`, range:
|
|
|
37
43
|
readonly max: number;
|
|
38
44
|
readonly min: number;
|
|
39
45
|
}) => number;
|
|
46
|
+
export declare const readWaitTimeoutSeconds: (value: string | undefined) => number;
|
|
40
47
|
export type ArgumentToken = {
|
|
41
48
|
readonly index: number;
|
|
42
49
|
readonly inline: boolean;
|
|
@@ -77,13 +77,20 @@ export const parseArguments = (arguments_) => {
|
|
|
77
77
|
tokens: [...scan.tokens, ...(end === -1 ? [] : arguments_.slice(end))],
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
const takeOptionValue = (state, token) => {
|
|
81
|
+
const { options, pendingOption } = state;
|
|
82
|
+
if (pendingOption === undefined)
|
|
83
|
+
return;
|
|
84
|
+
if (token.startsWith("--")) {
|
|
85
|
+
throw new CliArgumentError(`Option '${pendingOption}' requires a value.`);
|
|
86
|
+
}
|
|
87
|
+
const earlier = options.get(pendingOption);
|
|
88
|
+
options.set(pendingOption, earlier === undefined ? token : `${earlier},${token}`);
|
|
89
|
+
delete state.pendingOption;
|
|
90
|
+
};
|
|
80
91
|
const parseOptionToken = (state, token) => {
|
|
81
92
|
if (state.pendingOption !== undefined) {
|
|
82
|
-
|
|
83
|
-
throw new CliArgumentError(`Option '${state.pendingOption}' requires a value.`);
|
|
84
|
-
}
|
|
85
|
-
state.options.set(state.pendingOption, token);
|
|
86
|
-
delete state.pendingOption;
|
|
93
|
+
takeOptionValue(state, token);
|
|
87
94
|
return;
|
|
88
95
|
}
|
|
89
96
|
if (!token.startsWith("--")) {
|
|
@@ -100,7 +107,7 @@ const parseOptionToken = (state, token) => {
|
|
|
100
107
|
if (!state.allowed.has(token)) {
|
|
101
108
|
throw new CliArgumentError("The command contains an unknown option.");
|
|
102
109
|
}
|
|
103
|
-
if (state.options.has(token)) {
|
|
110
|
+
if (state.options.has(token) && !state.repeatable.has(token)) {
|
|
104
111
|
throw new CliArgumentError(`Option '${token}' may be used only once.`);
|
|
105
112
|
}
|
|
106
113
|
state.pendingOption = token;
|
|
@@ -112,16 +119,15 @@ const splitInlineValue = (token, allowed) => {
|
|
|
112
119
|
const name = token.slice(0, separator);
|
|
113
120
|
return allowed.has(name) ? [name, token.slice(separator + 1)] : [token];
|
|
114
121
|
};
|
|
115
|
-
export const
|
|
122
|
+
export const parseOptionsWith = (tokens, spec) => {
|
|
116
123
|
const state = {
|
|
117
|
-
|
|
118
|
-
allowedFlags,
|
|
124
|
+
...spec,
|
|
119
125
|
flags: new Set(),
|
|
120
126
|
options: new Map(),
|
|
121
127
|
positionals: [],
|
|
122
128
|
};
|
|
123
129
|
tokens
|
|
124
|
-
.flatMap((token) => splitInlineValue(token, allowed))
|
|
130
|
+
.flatMap((token) => splitInlineValue(token, spec.allowed))
|
|
125
131
|
.forEach((token) => {
|
|
126
132
|
parseOptionToken(state, token);
|
|
127
133
|
});
|
|
@@ -134,6 +140,7 @@ export const parseOptions = (tokens, allowed, allowedFlags = new Set()) => {
|
|
|
134
140
|
positionals: state.positionals,
|
|
135
141
|
};
|
|
136
142
|
};
|
|
143
|
+
export const parseOptions = (tokens, allowed, allowedFlags = new Set()) => parseOptionsWith(tokens, { allowed, allowedFlags, repeatable: new Set() });
|
|
137
144
|
export const requirePositionals = (positionals, count) => {
|
|
138
145
|
if (positionals.length === count)
|
|
139
146
|
return;
|
|
@@ -191,6 +198,11 @@ export const readDuration = (value, option, range) => {
|
|
|
191
198
|
throw new CliArgumentError(`Option '${option}' must be a duration from ${describeSeconds(range.min)} to ${describeSeconds(range.max)}, such as 30s, 10m or 1h.`);
|
|
192
199
|
return seconds;
|
|
193
200
|
};
|
|
201
|
+
const DEFAULT_WAIT_SECONDS = 600;
|
|
202
|
+
const MAX_WAIT_SECONDS = 86_400;
|
|
203
|
+
export const readWaitTimeoutSeconds = (value) => value === undefined
|
|
204
|
+
? DEFAULT_WAIT_SECONDS
|
|
205
|
+
: readDuration(value, "--timeout", { max: MAX_WAIT_SECONDS, min: 1 });
|
|
194
206
|
const tokenRole = (token, index, valueOptions) => {
|
|
195
207
|
if (!token.startsWith("--"))
|
|
196
208
|
return { index, kind: "positional" };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
1
|
+
export { argumentsAreBounded, type ArgumentToken, CliArgumentError, missingArgument, parseArguments, type ParsedArguments, type ParsedOptions, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
2
2
|
export { promptLine, type PromptOptions, terminalIsInteractive, } from "./prompt.js";
|
|
3
|
-
export { type BoundedStdinRequest, readBoundedStdin, recoverStdin, } from "./stdin.js";
|
|
3
|
+
export { type BoundedStdinRequest, readBoundedStdin, recoverStdin, replayStdin, } from "./stdin.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
1
|
+
export { argumentsAreBounded, CliArgumentError, missingArgument, parseArguments, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readGlobalValue, readPageSize, readRevisionOption, readWaitTimeoutSeconds, requireNoArguments, requirePositionals, tokenizeArguments, unknownCommand, } from "./arguments.js";
|
|
2
2
|
export { promptLine, terminalIsInteractive, } from "./prompt.js";
|
|
3
|
-
export { readBoundedStdin, recoverStdin, } from "./stdin.js";
|
|
3
|
+
export { readBoundedStdin, recoverStdin, replayStdin, } from "./stdin.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,5 +7,6 @@ export type BoundedStdinRequest = {
|
|
|
7
7
|
readonly maxChunks: number;
|
|
8
8
|
};
|
|
9
9
|
export declare const readBoundedStdin: (input: Stream.Stream<string | Uint8Array, unknown>, request: BoundedStdinRequest) => Effect.Effect<string, CliArgumentError>;
|
|
10
|
+
export declare const replayStdin: (text: string) => (request: BoundedStdinRequest) => Effect.Effect<string, CliArgumentError>;
|
|
10
11
|
export declare const recoverStdin: <TError>(read: Effect.Effect<string, CliArgumentError>, recover: (error: unknown) => TError) => Effect.Effect<string, TError>;
|
|
11
12
|
//# sourceMappingURL=stdin.d.ts.map
|
|
@@ -17,6 +17,7 @@ const decodeUtf8 = (collected) => Effect.try({
|
|
|
17
17
|
});
|
|
18
18
|
const loadStreamFold = () => import("./stdin-stream.js");
|
|
19
19
|
export const readBoundedStdin = (input, request) => Effect.promise(loadStreamFold).pipe(Effect.flatMap(({ foldStream }) => foldStream(input, () => ({ bytes: 0, chunks: [] }), (collected, chunk) => collectChunk(request, collected, chunk))), Effect.flatMap(decodeUtf8));
|
|
20
|
+
export const replayStdin = (text) => (request) => Effect.as(collectChunk(request, { bytes: 0, chunks: [] }, text), text);
|
|
20
21
|
export const recoverStdin = (read, recover) => read.pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)
|
|
21
22
|
? Effect.interrupt
|
|
22
23
|
: Effect.fail(recover(Cause.squash(cause)))));
|