@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -265
- package/dist/address-space/address-space.d.ts +38 -0
- package/dist/address-space/address-space.js +130 -0
- package/dist/address-space/index.d.ts +2 -0
- package/dist/address-space/index.js +2 -0
- package/dist/agents/client.d.ts +171 -0
- package/dist/agents/client.js +8 -0
- package/dist/agents/commands.d.ts +7 -0
- package/dist/agents/commands.js +65 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/input.d.ts +130 -0
- package/dist/agents/input.js +99 -0
- package/dist/agents/output/format.d.ts +8 -0
- package/dist/agents/output/format.js +47 -0
- package/dist/agents/output/index.d.ts +2 -0
- package/dist/agents/output/index.js +2 -0
- package/dist/agents/tree/index.d.ts +2 -0
- package/dist/agents/tree/index.js +2 -0
- package/dist/agents/tree/tree.d.ts +3 -0
- package/dist/agents/tree/tree.js +43 -0
- package/dist/bin/maia.cdx.json +37 -14
- package/dist/bin/maia.mjs +1 -1
- package/dist/bootstrap/exit.d.ts +14 -0
- package/dist/bootstrap/exit.js +42 -0
- package/dist/bootstrap/process.js +4 -26
- package/dist/bootstrap/run.js +5 -2
- package/dist/cli/cli.d.ts +2 -1
- package/dist/cli/cli.js +81 -16
- package/dist/command-line/context.d.ts +14 -4
- package/dist/command-line/context.js +1 -1
- package/dist/command-line/index.d.ts +6 -6
- package/dist/command-line/index.js +6 -5
- package/dist/command-line/input/arguments.d.ts +7 -0
- package/dist/command-line/input/arguments.js +22 -10
- package/dist/command-line/input/index.d.ts +2 -2
- package/dist/command-line/input/index.js +2 -2
- package/dist/command-line/input/stdin.d.ts +1 -0
- package/dist/command-line/input/stdin.js +1 -0
- package/dist/command-line/json.d.ts +1 -0
- package/dist/command-line/json.js +23 -0
- package/dist/command-line/output.d.ts +8 -1
- package/dist/command-line/output.js +33 -14
- package/dist/command-line/rows.d.ts +2 -0
- package/dist/command-line/rows.js +10 -1
- package/dist/command-line/two-phase.d.ts +5 -0
- package/dist/command-line/two-phase.js +33 -8
- package/dist/command-tree/help.d.ts +1 -1
- package/dist/command-tree/help.js +1 -0
- package/dist/command-tree/index.d.ts +2 -2
- package/dist/command-tree/index.js +1 -1
- package/dist/command-tree/local.js +12 -0
- package/dist/command-tree/placeholder.d.ts +1 -0
- package/dist/command-tree/placeholder.js +1 -0
- package/dist/command-tree/row.d.ts +2 -0
- package/dist/command-tree/tree.d.ts +3 -2
- package/dist/command-tree/tree.js +18 -2
- package/dist/connection/access/client.d.ts +13 -0
- package/dist/connection/access/client.js +19 -0
- package/dist/connection/access/commands.d.ts +6 -0
- package/dist/connection/access/commands.js +60 -0
- package/dist/connection/access/format.d.ts +8 -0
- package/dist/connection/access/format.js +61 -0
- package/dist/connection/access/index.d.ts +3 -0
- package/dist/connection/access/index.js +3 -0
- package/dist/connection/access/input.d.ts +53 -0
- package/dist/connection/access/input.js +83 -0
- package/dist/connection/client.d.ts +99 -1
- package/dist/connection/client.js +9 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.js +2 -1
- package/dist/connection/system.d.ts +1 -0
- package/dist/connection/system.js +109 -5
- package/dist/connection/tree/tree.js +59 -8
- package/dist/container/output/format.js +1 -2
- package/dist/dashboard/cockpit-client.d.ts +6 -0
- package/dist/dashboard/cockpit-client.js +27 -0
- package/dist/dashboard/cockpits.d.ts +29 -0
- package/dist/dashboard/cockpits.js +65 -0
- package/dist/dashboard/dashboard.d.ts +7 -0
- package/dist/dashboard/dashboard.js +47 -0
- package/dist/dashboard/draw.d.ts +15 -0
- package/dist/dashboard/draw.js +30 -0
- package/dist/dashboard/frame.d.ts +4 -0
- package/dist/dashboard/frame.js +15 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/modes.d.ts +5 -0
- package/dist/dashboard/modes.js +16 -0
- package/dist/dashboard/node-connection.d.ts +15 -0
- package/dist/dashboard/node-connection.js +51 -0
- package/dist/dashboard/pi-tui.d.ts +6 -0
- package/dist/dashboard/pi-tui.js +35 -0
- package/dist/dashboard/status-bar.d.ts +4 -0
- package/dist/dashboard/status-bar.js +60 -0
- package/dist/dashboard/terminal.d.ts +53 -0
- package/dist/dashboard/terminal.js +165 -0
- package/dist/dashboard/tree-model.d.ts +28 -0
- package/dist/dashboard/tree-model.js +97 -0
- package/dist/dashboard/tree.d.ts +10 -0
- package/dist/dashboard/tree.js +76 -0
- package/dist/fleet/fleet.d.ts +70 -0
- package/dist/fleet/fleet.js +91 -0
- package/dist/fleet/index.d.ts +2 -0
- package/dist/fleet/index.js +2 -0
- package/dist/hold/output/format.js +1 -5
- package/dist/hold/tree/tree.js +1 -0
- package/dist/import/commands.js +3 -4
- package/dist/import/output.js +1 -4
- package/dist/local-node/client.d.ts +9 -4
- package/dist/local-node/client.js +21 -9
- package/dist/local-node/index.d.ts +2 -1
- package/dist/local-node/index.js +2 -1
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/commands.js +2 -1
- package/dist/mcp/calls.d.ts +1 -0
- package/dist/mcp/calls.js +37 -3
- package/dist/mcp/commands.d.ts +5 -2
- package/dist/mcp/commands.js +30 -4
- package/dist/mcp/routing.d.ts +24 -0
- package/dist/mcp/routing.js +188 -0
- package/dist/mcp/server.d.ts +13 -4
- package/dist/mcp/server.js +35 -12
- package/dist/presentation/output/format.js +4 -3
- package/dist/project-guard/commands.js +11 -2
- package/dist/project-workspace/commands.js +16 -6
- package/dist/project-workspace/output/human.d.ts +13 -0
- package/dist/project-workspace/output/human.js +17 -5
- package/dist/project-workspace/output/index.d.ts +1 -1
- package/dist/project-workspace/output/index.js +1 -1
- package/dist/project-workspace/output/metadata.js +1 -1
- package/dist/project-workspace/tree/tree.js +27 -12
- package/dist/reference/commands.js +4 -2
- package/dist/reference/index.d.ts +1 -1
- package/dist/reference/index.js +1 -1
- package/dist/reference/resolve.d.ts +2 -0
- package/dist/reference/resolve.js +28 -18
- package/dist/remote-node/client.d.ts +89 -9
- package/dist/remote-node/client.js +6 -1
- package/dist/remote-node/commands.d.ts +9 -0
- package/dist/remote-node/commands.js +96 -18
- package/dist/remote-node/connector.d.ts +12 -4
- package/dist/remote-node/connector.js +54 -26
- package/dist/remote-node/index.d.ts +2 -2
- package/dist/remote-node/index.js +2 -2
- package/dist/remote-node/reachability.d.ts +43 -1
- package/dist/remote-node/reachability.js +13 -3
- package/dist/remote-node/text.d.ts +2 -1
- package/dist/remote-node/text.js +74 -27
- package/dist/remote-node/tree/tree.js +21 -1
- package/dist/routine/client.d.ts +398 -0
- package/dist/routine/client.js +28 -0
- package/dist/routine/commands.d.ts +9 -0
- package/dist/routine/commands.js +109 -0
- package/dist/routine/index.d.ts +3 -0
- package/dist/routine/index.js +3 -0
- package/dist/routine/input.d.ts +28 -0
- package/dist/routine/input.js +44 -0
- package/dist/routine/output/format.d.ts +23 -0
- package/dist/routine/output/format.js +83 -0
- package/dist/routine/output/index.d.ts +2 -0
- package/dist/routine/output/index.js +2 -0
- package/dist/routine/tree/index.d.ts +2 -0
- package/dist/routine/tree/index.js +2 -0
- package/dist/routine/tree/tree.d.ts +3 -0
- package/dist/routine/tree/tree.js +70 -0
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/commands.js +31 -9
- package/dist/session/approval/output/format.d.ts +11 -0
- package/dist/session/approval/output/format.js +8 -0
- package/dist/session/approval/output/index.d.ts +1 -1
- package/dist/session/approval/output/index.js +1 -1
- package/dist/session/attach-client.d.ts +1 -1
- package/dist/session/attach-client.js +12 -3
- package/dist/session/attach-render.js +15 -7
- package/dist/session/attach.js +17 -3
- package/dist/session/client.d.ts +12 -3
- package/dist/session/client.js +18 -17
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +120 -13
- package/dist/session/create-tasks.js +29 -11
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.js +2 -1
- package/dist/session/interaction/output/format.js +2 -1
- package/dist/session/output/diff.js +3 -10
- package/dist/session/output/failure.js +3 -10
- package/dist/session/output/human.d.ts +1 -0
- package/dist/session/output/human.js +21 -10
- package/dist/session/output/index.d.ts +2 -2
- package/dist/session/output/index.js +2 -2
- package/dist/session/output/tasks.d.ts +16 -1
- package/dist/session/output/tasks.js +41 -27
- package/dist/session/tree/tree.js +67 -8
- package/dist/session/turn/client.d.ts +4 -1
- package/dist/session/turn/client.js +22 -11
- package/dist/session/turn/commands.d.ts +2 -0
- package/dist/session/turn/commands.js +39 -11
- package/dist/session/turn/index.d.ts +3 -3
- package/dist/session/turn/index.js +1 -1
- package/dist/session/turn/output.d.ts +7 -2
- package/dist/session/turn/output.js +36 -13
- package/dist/status/client.d.ts +7 -2
- package/dist/status/command.js +3 -1
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +10 -4
- package/dist/status/output/compact.d.ts +1 -0
- package/dist/status/output/compact.js +3 -0
- package/dist/status/output/human.d.ts +1 -1
- package/dist/status/output/human.js +71 -14
- package/dist/team-workspace/ceremony.d.ts +19 -0
- package/dist/team-workspace/ceremony.js +141 -0
- package/dist/team-workspace/client.d.ts +58 -0
- package/dist/team-workspace/client.js +6 -0
- package/dist/team-workspace/commands.d.ts +3 -0
- package/dist/team-workspace/commands.js +85 -0
- package/dist/team-workspace/confirmation.d.ts +4 -0
- package/dist/team-workspace/confirmation.js +8 -0
- package/dist/team-workspace/dependencies.d.ts +8 -0
- package/dist/team-workspace/dependencies.js +2 -0
- package/dist/team-workspace/index.d.ts +6 -0
- package/dist/team-workspace/index.js +5 -0
- package/dist/team-workspace/launcher.d.ts +17 -0
- package/dist/team-workspace/launcher.js +30 -0
- package/dist/team-workspace/output.d.ts +15 -0
- package/dist/team-workspace/output.js +28 -0
- package/dist/team-workspace/terminal.d.ts +9 -0
- package/dist/team-workspace/terminal.js +46 -0
- package/dist/terminal/client.d.ts +4 -0
- package/dist/terminal/client.js +3 -0
- package/dist/terminal/commands.js +37 -25
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.d.ts +12 -0
- package/dist/terminal/keys.js +62 -0
- package/dist/terminal/output/compact-list.d.ts +1 -0
- package/dist/terminal/output/compact-list.js +1 -0
- package/dist/terminal/output/human.d.ts +2 -19
- package/dist/terminal/output/human.js +6 -6
- package/dist/terminal/tree/tree.js +16 -16
- package/guidance/maia-orchestration/SKILL.md +1 -2
- package/package.json +10 -8
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { routineCreateConfirmParametersSchema, routineCreatePreviewParametersSchema, routineDisableConfirmParametersSchema, routineRunConfirmParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { listEach, onHolder, onInputHolder, writeMerged, } from "../address-space/index.js";
|
|
4
|
+
import { CliArgumentError, confirmParameters, parseOptions, readInputMode, readPipedPreview, readTwoPhaseMode, requirePositionals, runInputTwoPhase, runTwoPhase, TWO_PHASE_FLAGS, writeNodeResult, } from "../command-line/index.js";
|
|
5
|
+
import { mergeLists } from "../fleet/index.js";
|
|
6
|
+
import { readRoutineList, readRoutineShow, readRoutineTransition, readRoutineTransitionInput, ROUTINE_TRANSITION_OPTIONS, } from "./input.js";
|
|
7
|
+
import { formatRoutineList, formatRoutineResult, } from "./output/index.js";
|
|
8
|
+
const write = (result, context) => writeNodeResult(result, context, {
|
|
9
|
+
toResult: (value) => ({ command: value.method, result: value }),
|
|
10
|
+
toText: formatRoutineResult,
|
|
11
|
+
});
|
|
12
|
+
const run = (operation, input, context) => {
|
|
13
|
+
if (operation === undefined)
|
|
14
|
+
return Effect.die(new Error("Missing routine client."));
|
|
15
|
+
return input.pipe(Effect.flatMap(operation), Effect.map((result) => write(result, context)));
|
|
16
|
+
};
|
|
17
|
+
const missing = () => Effect.die(new Error("Missing routine client."));
|
|
18
|
+
export const runRoutineList = (tokens, context) => Effect.gen(function* () {
|
|
19
|
+
const input = readRoutineList(tokens);
|
|
20
|
+
if (input.projectId !== undefined)
|
|
21
|
+
return yield* run(context.dependencies.listRoutines, Effect.succeed(input), context);
|
|
22
|
+
return yield* listEach(context, {
|
|
23
|
+
merged: (answers) => writeMerged(context, {
|
|
24
|
+
command: "routine.list",
|
|
25
|
+
result: { ...mergeLists(answers), method: "routine.list" },
|
|
26
|
+
}, formatRoutineList),
|
|
27
|
+
paged: input.afterCursor !== undefined,
|
|
28
|
+
read: (dependencies) => dependencies.listRoutines?.(input) ?? missing(),
|
|
29
|
+
sole: (result) => write(result, context),
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
export const runRoutineShow = (tokens, context) => Effect.suspend(() => run(context.dependencies.showRoutine, Effect.succeed(readRoutineShow(tokens)), context));
|
|
33
|
+
export const runRoutinePause = (tokens, context) => Effect.suspend(() => run(context.dependencies.pauseRoutine, readRoutineTransition(tokens), context));
|
|
34
|
+
export const runRoutineResume = (tokens, context) => Effect.suspend(() => run(context.dependencies.resumeRoutine, readRoutineTransition(tokens), context));
|
|
35
|
+
const readPreviewed = (tokens, context) => {
|
|
36
|
+
const parsed = parseOptions(tokens, ROUTINE_TRANSITION_OPTIONS, new Set(TWO_PHASE_FLAGS));
|
|
37
|
+
const mode = readTwoPhaseMode(parsed.flags, context);
|
|
38
|
+
if (mode === "confirm-stdin")
|
|
39
|
+
requirePositionals(parsed.positionals, 0);
|
|
40
|
+
return { mode, parsed };
|
|
41
|
+
};
|
|
42
|
+
const confirmPiped = (context, change) => Effect.flatMap(Effect.flatMap(readPipedPreview(context), (value) => confirmParameters(change.schema, value, ["name"])), (confirmation) => onHolder(context, { id: confirmation.routineId, kind: "routine" }, (bound) => {
|
|
43
|
+
const { confirm } = change.phases(bound);
|
|
44
|
+
if (confirm === undefined)
|
|
45
|
+
return Effect.fail(new CliArgumentError(`Routine ${change.verb} is unavailable.`));
|
|
46
|
+
return Effect.map(confirm(confirmation), (result) => write(result, bound));
|
|
47
|
+
}));
|
|
48
|
+
const runPreviewed = (tokens, context, change) => Effect.gen(function* () {
|
|
49
|
+
const { mode, parsed } = readPreviewed(tokens, context);
|
|
50
|
+
if (mode === "confirm-stdin")
|
|
51
|
+
return yield* confirmPiped(context, change);
|
|
52
|
+
const { schema, verb } = change;
|
|
53
|
+
const { confirm, preview } = change.phases(context);
|
|
54
|
+
if (confirm === undefined || preview === undefined)
|
|
55
|
+
return yield* new CliArgumentError(`Routine ${verb} is unavailable.`);
|
|
56
|
+
return yield* runTwoPhase({
|
|
57
|
+
confirm: (value) => Effect.flatMap(confirmParameters(schema, value, ["name"]), confirm),
|
|
58
|
+
context,
|
|
59
|
+
mode,
|
|
60
|
+
preview: () => Effect.flatMap(readRoutineTransitionInput(parsed), preview),
|
|
61
|
+
prompt: change,
|
|
62
|
+
writeConfirm: (result) => write(result, context),
|
|
63
|
+
writePreview: (result) => write(result, context),
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
export const runRoutineDisable = (tokens, context) => runPreviewed(tokens, context, {
|
|
67
|
+
describe: (preview) => `Disable routine ${preview.routineId} "${preview.name}" at revision ${preview.expectedRevision}. It fires no more Sessions and cannot be resumed.\n`,
|
|
68
|
+
phases: ({ dependencies }) => ({
|
|
69
|
+
confirm: dependencies.confirmRoutineDisable,
|
|
70
|
+
preview: dependencies.previewRoutineDisable,
|
|
71
|
+
}),
|
|
72
|
+
question: "Disable this routine for good?",
|
|
73
|
+
schema: routineDisableConfirmParametersSchema,
|
|
74
|
+
verb: "disable",
|
|
75
|
+
});
|
|
76
|
+
export const runRoutineRun = (tokens, context) => runPreviewed(tokens, context, {
|
|
77
|
+
describe: (preview) => `Run routine ${preview.routineId} "${preview.name}" at revision ${preview.expectedRevision} now; it starts one Session.\n`,
|
|
78
|
+
phases: ({ dependencies }) => ({
|
|
79
|
+
confirm: dependencies.confirmRoutineRun,
|
|
80
|
+
preview: dependencies.previewRoutineRun,
|
|
81
|
+
}),
|
|
82
|
+
question: "Run this routine now?",
|
|
83
|
+
schema: routineRunConfirmParametersSchema,
|
|
84
|
+
verb: "run",
|
|
85
|
+
});
|
|
86
|
+
const ROUTINE_INPUT_ROUTE = {
|
|
87
|
+
idOf: (input) => {
|
|
88
|
+
const template = Reflect.get(input, "template");
|
|
89
|
+
return typeof template === "object" && template !== null
|
|
90
|
+
? Reflect.get(template, "projectId")
|
|
91
|
+
: undefined;
|
|
92
|
+
},
|
|
93
|
+
kind: "project",
|
|
94
|
+
};
|
|
95
|
+
export const runRoutineCreate = (tokens, context) => Effect.suspend(() => {
|
|
96
|
+
readInputMode(tokens);
|
|
97
|
+
return onInputHolder(context, ROUTINE_INPUT_ROUTE, (bound) => runInputTwoPhase({
|
|
98
|
+
confirm: bound.dependencies.confirmRoutineCreate,
|
|
99
|
+
confirmSchema: routineCreateConfirmParametersSchema,
|
|
100
|
+
context: bound,
|
|
101
|
+
label: "routine input",
|
|
102
|
+
preview: bound.dependencies.previewRoutineCreate,
|
|
103
|
+
previewOnly: ["nextFires", "routineId"],
|
|
104
|
+
previewSchema: routineCreatePreviewParametersSchema,
|
|
105
|
+
tokens,
|
|
106
|
+
write: (result) => write(result, bound),
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { type ParsedOptions } from "../command-line/index.js";
|
|
3
|
+
export declare const readRoutineList: (tokens: readonly string[]) => {
|
|
4
|
+
state?: undefined;
|
|
5
|
+
limit: number;
|
|
6
|
+
afterCursor?: string | undefined;
|
|
7
|
+
projectId?: string | undefined;
|
|
8
|
+
} | {
|
|
9
|
+
state: "active" | "disabled" | "paused";
|
|
10
|
+
limit: number;
|
|
11
|
+
afterCursor?: string | undefined;
|
|
12
|
+
projectId?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare const readRoutineShow: (tokens: readonly string[]) => {
|
|
15
|
+
routineId: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const ROUTINE_TRANSITION_OPTIONS: ReadonlySet<string>;
|
|
18
|
+
export declare const readRoutineTransitionInput: (parsed: ParsedOptions) => Effect.Effect<{
|
|
19
|
+
commandId: string;
|
|
20
|
+
expectedRevision: string;
|
|
21
|
+
routineId: string;
|
|
22
|
+
}, never, import("effect/Crypto").Crypto>;
|
|
23
|
+
export declare const readRoutineTransition: (tokens: readonly string[]) => Effect.Effect<{
|
|
24
|
+
commandId: string;
|
|
25
|
+
expectedRevision: string;
|
|
26
|
+
routineId: string;
|
|
27
|
+
}, never, import("effect/Crypto").Crypto>;
|
|
28
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { CliArgumentError, parseOptions, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
|
|
3
|
+
import { commandIdentifier } from "../local-node/index.js";
|
|
4
|
+
const STATES = ["active", "disabled", "paused"];
|
|
5
|
+
const readState = (value) => {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return {};
|
|
8
|
+
const state = STATES.find((candidate) => candidate === value);
|
|
9
|
+
if (state === undefined)
|
|
10
|
+
throw new CliArgumentError("Option '--state' must be 'active', 'paused' or 'disabled'.");
|
|
11
|
+
return { state };
|
|
12
|
+
};
|
|
13
|
+
export const readRoutineList = (tokens) => {
|
|
14
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--project", "--state"]));
|
|
15
|
+
requirePositionals(parsed.positionals, 0);
|
|
16
|
+
const afterCursor = parsed.options.get("--after");
|
|
17
|
+
const projectId = parsed.options.get("--project");
|
|
18
|
+
return {
|
|
19
|
+
limit: readPageSize(parsed.options.get("--limit")),
|
|
20
|
+
...(afterCursor === undefined ? {} : { afterCursor }),
|
|
21
|
+
...(projectId === undefined ? {} : { projectId }),
|
|
22
|
+
...readState(parsed.options.get("--state")),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const readRoutineShow = (tokens) => {
|
|
26
|
+
const parsed = parseOptions(tokens, new Set());
|
|
27
|
+
requirePositionals(parsed.positionals, 1);
|
|
28
|
+
return { routineId: parsed.positionals[0] ?? "" };
|
|
29
|
+
};
|
|
30
|
+
export const ROUTINE_TRANSITION_OPTIONS = new Set([
|
|
31
|
+
"--command-id",
|
|
32
|
+
"--expected-revision",
|
|
33
|
+
]);
|
|
34
|
+
export const readRoutineTransitionInput = (parsed) => {
|
|
35
|
+
requirePositionals(parsed.positionals, 1);
|
|
36
|
+
const expectedRevision = readExpectedRevision(parsed.options.get("--expected-revision"));
|
|
37
|
+
return Effect.map(commandIdentifier(parsed.options.get("--command-id")), (commandId) => ({
|
|
38
|
+
commandId,
|
|
39
|
+
expectedRevision,
|
|
40
|
+
routineId: parsed.positionals[0] ?? "",
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
export const readRoutineTransition = (tokens) => readRoutineTransitionInput(parseOptions(tokens, ROUTINE_TRANSITION_OPTIONS));
|
|
44
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Routine, RoutineCreateConfirmResult, RoutineCreatePreviewResult, RoutineDisableConfirmResult, RoutineDisablePreviewResult, RoutineListResult, RoutinePauseResult, RoutineResumeResult, RoutineRunConfirmResult, RoutineRunPreviewResult, RoutineShowResult } from "@maiaos/sdk";
|
|
2
|
+
import type { ListedNode } from "../../fleet/index.js";
|
|
3
|
+
export type RoutineResult = RoutineCreateConfirmResult | RoutineCreatePreviewResult | RoutineDisableConfirmResult | RoutineDisablePreviewResult | RoutineListResult | RoutinePauseResult | RoutineResumeResult | RoutineRunConfirmResult | RoutineRunPreviewResult | RoutineShowResult;
|
|
4
|
+
export type CliRoutineResult = {
|
|
5
|
+
readonly command: RoutineResult["method"];
|
|
6
|
+
readonly result: RoutineResult;
|
|
7
|
+
};
|
|
8
|
+
export declare const isRoutineResult: (result: {
|
|
9
|
+
readonly command: string;
|
|
10
|
+
}) => result is CliRoutineResult;
|
|
11
|
+
export type CliRoutineList = {
|
|
12
|
+
readonly command: "routine.list";
|
|
13
|
+
readonly result: {
|
|
14
|
+
readonly items: readonly (Routine & {
|
|
15
|
+
readonly node: string;
|
|
16
|
+
})[];
|
|
17
|
+
readonly method: "routine.list";
|
|
18
|
+
readonly nodes: readonly ListedNode[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const formatRoutineList: ({ result }: CliRoutineList) => string;
|
|
22
|
+
export declare const formatRoutineResult: ({ result }: CliRoutineResult) => string;
|
|
23
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { formatMerged } from "../../address-space/index.js";
|
|
2
|
+
import { cell, formatRows, withNextPage } from "../../command-line/index.js";
|
|
3
|
+
export const isRoutineResult = (result) => result.command.startsWith("routine.");
|
|
4
|
+
const scheduleText = (routine) => `${routine.schedule.expression} ${routine.schedule.timezone}`;
|
|
5
|
+
const routineRow = (routine) => [
|
|
6
|
+
routine.id,
|
|
7
|
+
routine.state,
|
|
8
|
+
routine.nextFireAt ?? "-",
|
|
9
|
+
scheduleText(routine),
|
|
10
|
+
cell(routine.name),
|
|
11
|
+
].join("\t");
|
|
12
|
+
const causeText = ({ failure, failureReason }) => {
|
|
13
|
+
if (failure === undefined)
|
|
14
|
+
return failureReason ?? "-";
|
|
15
|
+
return failureReason === undefined
|
|
16
|
+
? `${failure.code}: ${cell(failure.message)}`
|
|
17
|
+
: `${failureReason} (${failure.code}): ${cell(failure.message)}`;
|
|
18
|
+
};
|
|
19
|
+
const fireRow = (fire) => [
|
|
20
|
+
fire.scheduledAt,
|
|
21
|
+
fire.triggerKind,
|
|
22
|
+
fire.outcome,
|
|
23
|
+
fire.reason ?? "-",
|
|
24
|
+
fire.sessionId ?? "-",
|
|
25
|
+
fire.turnState ?? "-",
|
|
26
|
+
String(fire.missed ?? 0),
|
|
27
|
+
causeText(fire),
|
|
28
|
+
].join("\t");
|
|
29
|
+
const formatShow = ({ fires, routine }) => [
|
|
30
|
+
`${routine.id}\t${routine.state}\trevision=${routine.revision}\t${cell(routine.name)}`,
|
|
31
|
+
`schedule\t${scheduleText(routine)}`,
|
|
32
|
+
`next\t${routine.nextFireAt ?? "-"}`,
|
|
33
|
+
`project\t${routine.template.projectId}`,
|
|
34
|
+
`prompt\t${cell(routine.template.prompt)}`,
|
|
35
|
+
formatRows(fires, fireRow, {
|
|
36
|
+
empty: "No fires yet.",
|
|
37
|
+
headers: [
|
|
38
|
+
"SCHEDULED",
|
|
39
|
+
"TRIGGER",
|
|
40
|
+
"OUTCOME",
|
|
41
|
+
"REASON",
|
|
42
|
+
"SESSION",
|
|
43
|
+
"TURN",
|
|
44
|
+
"MISSED",
|
|
45
|
+
"CAUSE",
|
|
46
|
+
],
|
|
47
|
+
}),
|
|
48
|
+
].join("\n");
|
|
49
|
+
const formatPreview = (result) => `${result.routineId}\t${result.expiresAt}\n${result.nextFires
|
|
50
|
+
.map((fire) => `next\t${fire}\n`)
|
|
51
|
+
.join("")}`;
|
|
52
|
+
const formatChangePreview = (result) => `${result.routineId}\t${result.expiresAt}\t${cell(result.name)}\n`;
|
|
53
|
+
const formatChanged = ({ delivery, receipt, routine }) => `${routine.id}\t${routine.state}\t${routine.revision}\t${receipt.receiptId}\t${delivery}\t${routine.nextFireAt ?? "-"}\n`;
|
|
54
|
+
const ROUTINE_HEADERS = ["ROUTINE", "STATE", "NEXT FIRE", "SCHEDULE", "NAME"];
|
|
55
|
+
export const formatRoutineList = ({ result }) => formatMerged(result, routineRow, {
|
|
56
|
+
empty: "No routines.",
|
|
57
|
+
headers: ROUTINE_HEADERS,
|
|
58
|
+
});
|
|
59
|
+
const formatRun = ({ delivery, fire, receipt, }) => `${fire.id}\t${fire.outcome}\t${fire.routineId}\t${receipt.receiptId}\t${delivery}\n`;
|
|
60
|
+
export const formatRoutineResult = ({ result }) => {
|
|
61
|
+
switch (result.method) {
|
|
62
|
+
case "routine.list":
|
|
63
|
+
return withNextPage(formatRows(result.items, routineRow, {
|
|
64
|
+
empty: "No routines.",
|
|
65
|
+
headers: ROUTINE_HEADERS,
|
|
66
|
+
}), result.nextCursor);
|
|
67
|
+
case "routine.show":
|
|
68
|
+
return formatShow(result);
|
|
69
|
+
case "routine.create.preview":
|
|
70
|
+
return formatPreview(result);
|
|
71
|
+
case "routine.disable.preview":
|
|
72
|
+
case "routine.run.preview":
|
|
73
|
+
return formatChangePreview(result);
|
|
74
|
+
case "routine.create.confirm":
|
|
75
|
+
case "routine.pause":
|
|
76
|
+
case "routine.resume":
|
|
77
|
+
case "routine.disable.confirm":
|
|
78
|
+
return formatChanged(result);
|
|
79
|
+
case "routine.run.confirm":
|
|
80
|
+
return formatRun(result);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const routine = () => import("../index.js");
|
|
2
|
+
export const ROUTINE_TREE = {
|
|
3
|
+
groups: [["routine", "Cron-scheduled Sessions on exact Projects."]],
|
|
4
|
+
leaves: [
|
|
5
|
+
[
|
|
6
|
+
"routine create (--input-stdin --dry-run | --confirm-stdin)",
|
|
7
|
+
1,
|
|
8
|
+
["routine.create.preview", "routine.create.confirm"],
|
|
9
|
+
"Create a routine after a preview.",
|
|
10
|
+
{
|
|
11
|
+
example: "maia --json routine create --input-stdin --dry-run",
|
|
12
|
+
kind: "two-phase",
|
|
13
|
+
run: [routine, "runRoutineCreate"],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
"routine list [--project <project-id>] [--state <active|paused|disabled>] [--limit <1..100>] [--after <cursor>]",
|
|
18
|
+
1,
|
|
19
|
+
"routine.list",
|
|
20
|
+
"List routines.",
|
|
21
|
+
{ route: "--project", run: [routine, "runRoutineList"] },
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"routine show <routine-id>",
|
|
25
|
+
1,
|
|
26
|
+
"routine.show",
|
|
27
|
+
"Show a routine and its latest fires.",
|
|
28
|
+
{ route: "<routine-id>", run: [routine, "runRoutineShow"] },
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"routine run <routine-id> --expected-revision <revision> [--command-id <id>] [--dry-run | --confirm-stdin]",
|
|
32
|
+
1,
|
|
33
|
+
["routine.run.preview", "routine.run.confirm"],
|
|
34
|
+
"Run a routine now, after a preview.",
|
|
35
|
+
{
|
|
36
|
+
example: "maia --json routine run <routine-id> --expected-revision 1 --dry-run",
|
|
37
|
+
kind: "two-phase",
|
|
38
|
+
route: "<routine-id>",
|
|
39
|
+
run: [routine, "runRoutineRun"],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
"routine pause <routine-id> --expected-revision <revision> [--command-id <id>]",
|
|
44
|
+
1,
|
|
45
|
+
"routine.pause",
|
|
46
|
+
"Pause a routine; it fires no Session until resumed.",
|
|
47
|
+
{ route: "<routine-id>", run: [routine, "runRoutinePause"] },
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"routine resume <routine-id> --expected-revision <revision> [--command-id <id>]",
|
|
51
|
+
1,
|
|
52
|
+
"routine.resume",
|
|
53
|
+
"Resume a paused routine from its next slot.",
|
|
54
|
+
{ route: "<routine-id>", run: [routine, "runRoutineResume"] },
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
"routine disable <routine-id> --expected-revision <revision> [--command-id <id>] [--dry-run | --confirm-stdin]",
|
|
58
|
+
1,
|
|
59
|
+
["routine.disable.preview", "routine.disable.confirm"],
|
|
60
|
+
"Disable a routine for good, after a preview.",
|
|
61
|
+
{
|
|
62
|
+
example: "maia --json routine disable <routine-id> --expected-revision 1 --dry-run",
|
|
63
|
+
kind: "two-phase",
|
|
64
|
+
route: "<routine-id>",
|
|
65
|
+
run: [routine, "runRoutineDisable"],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -18,7 +18,7 @@ export declare const makeAgentPermissionCliClient: (node: CliNodeOperations) =>
|
|
|
18
18
|
readonly commandId: string;
|
|
19
19
|
readonly grantedAt: string;
|
|
20
20
|
readonly inputDigest: string;
|
|
21
|
-
readonly operationIds: readonly ("approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.interrupt" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
21
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "events.read" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.register.confirm" | "node.remote.register.preview" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "session.wait" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.cancel" | "turn.interrupt" | "turn.queue.list" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
22
22
|
readonly revision: "1";
|
|
23
23
|
};
|
|
24
24
|
readonly method: "session.agent-permission.confirm";
|
|
@@ -55,7 +55,7 @@ export declare const makeAgentPermissionCliClient: (node: CliNodeOperations) =>
|
|
|
55
55
|
readonly inputDigest: string;
|
|
56
56
|
readonly issuedAt: string;
|
|
57
57
|
readonly method: "session.agent-permission.preview";
|
|
58
|
-
readonly operationIds: readonly ("approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.interrupt" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
58
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "events.read" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.register.confirm" | "node.remote.register.preview" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "session.wait" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.cancel" | "turn.interrupt" | "turn.queue.list" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
59
59
|
readonly proof: string;
|
|
60
60
|
}>;
|
|
61
61
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import { listEach, writeMerged } from "../../address-space/index.js";
|
|
2
3
|
import { CliArgumentError, parseOptions, reportError, requirePositionals, writeNodeResult, } from "../../command-line/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { mergeLists } from "../../fleet/index.js";
|
|
5
|
+
import { commandIdentifier, holdsSessionCredential, } from "../../local-node/index.js";
|
|
6
|
+
import { describeApproval, formatApprovalResult, formatMergedApprovals, } from "./output/index.js";
|
|
5
7
|
const missing = (name) => Effect.die(new Error(`Missing approval client: ${name}.`));
|
|
6
8
|
const write = (context) => (result) => writeNodeResult(result, context, {
|
|
7
9
|
toResult: (value) => ({ command: value.method, result: value }),
|
|
@@ -14,18 +16,34 @@ const readLimit = (value) => {
|
|
|
14
16
|
throw new CliArgumentError("Option '--limit' must be an integer from 1 to 50.");
|
|
15
17
|
return Number(value);
|
|
16
18
|
};
|
|
19
|
+
const writeMergedApprovals = (context, answers) => {
|
|
20
|
+
const { items, nodes } = mergeLists(answers);
|
|
21
|
+
const pending = items.filter((item) => item.status === "pending");
|
|
22
|
+
const result = {
|
|
23
|
+
items: [...pending, ...items.filter((item) => item.status !== "pending")],
|
|
24
|
+
method: "approval.list",
|
|
25
|
+
nodes,
|
|
26
|
+
};
|
|
27
|
+
return writeMerged(context, { command: "approval.list", result }, formatMergedApprovals);
|
|
28
|
+
};
|
|
17
29
|
export const runApprovalList = (tokens, context) => {
|
|
18
30
|
const parsed = parseOptions(tokens, new Set(["--limit", "--session"]), new Set(["--all"]));
|
|
19
31
|
requirePositionals(parsed.positionals, 0);
|
|
20
32
|
const session = parsed.options.get("--session");
|
|
21
|
-
const
|
|
22
|
-
if (listApprovals === undefined)
|
|
23
|
-
return missing("list");
|
|
24
|
-
return Effect.map(listApprovals({
|
|
33
|
+
const input = {
|
|
25
34
|
limit: readLimit(parsed.options.get("--limit")),
|
|
26
35
|
...(parsed.flags.has("--all") ? { pendingOnly: false } : {}),
|
|
27
36
|
...(session === undefined ? {} : { sessionId: session }),
|
|
28
|
-
}
|
|
37
|
+
};
|
|
38
|
+
const read = (dependencies) => dependencies.listApprovals?.(input) ?? missing("list");
|
|
39
|
+
if (session !== undefined)
|
|
40
|
+
return Effect.map(read(context.dependencies), write(context));
|
|
41
|
+
return listEach(context, {
|
|
42
|
+
merged: (answers) => writeMergedApprovals(context, answers),
|
|
43
|
+
paged: false,
|
|
44
|
+
read,
|
|
45
|
+
sole: write(context),
|
|
46
|
+
});
|
|
29
47
|
};
|
|
30
48
|
export const runApprovalShow = (tokens, context) => {
|
|
31
49
|
const rest = tokens;
|
|
@@ -106,8 +124,12 @@ const decide = (context, input) => {
|
|
|
106
124
|
}));
|
|
107
125
|
});
|
|
108
126
|
};
|
|
109
|
-
const runDecision = (verb, tokens, context) => {
|
|
110
|
-
|
|
127
|
+
const runDecision = (verb, tokens, context) => Effect.gen(function* () {
|
|
128
|
+
if (verb !== "answer" || !(yield* holdsSessionCredential))
|
|
129
|
+
requirePerson(context, verb);
|
|
130
|
+
return yield* parseDecision(verb, tokens, context);
|
|
131
|
+
});
|
|
132
|
+
const parseDecision = (verb, tokens, context) => {
|
|
111
133
|
const parsed = parseOptions(tokens, OPTIONS[verb], verb === "approve" ? new Set(["--for-session"]) : new Set());
|
|
112
134
|
requirePositionals(parsed.positionals, 1);
|
|
113
135
|
const commandId = parsed.options.get("--command-id");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Approval, ApprovalListResult, ApprovalRespondResult, ApprovalShowResult } from "@maiaos/sdk";
|
|
2
|
+
import type { ListedNode } from "../../../fleet/index.js";
|
|
2
3
|
export type ApprovalCliResult = ApprovalListResult | ApprovalRespondResult | ApprovalShowResult;
|
|
3
4
|
export type CliApprovalResult = {
|
|
4
5
|
readonly command: ApprovalCliResult["method"];
|
|
@@ -8,5 +9,15 @@ export declare const isApprovalResult: (result: {
|
|
|
8
9
|
readonly command: string;
|
|
9
10
|
}) => result is CliApprovalResult;
|
|
10
11
|
export declare const describeApproval: (approval: Approval) => string;
|
|
12
|
+
export type CliMergedApprovals = {
|
|
13
|
+
readonly items: readonly (Approval & {
|
|
14
|
+
readonly node: string;
|
|
15
|
+
})[];
|
|
16
|
+
readonly method: "approval.list";
|
|
17
|
+
readonly nodes: readonly ListedNode[];
|
|
18
|
+
};
|
|
19
|
+
export declare const formatMergedApprovals: ({ result, }: {
|
|
20
|
+
readonly result: CliMergedApprovals;
|
|
21
|
+
}) => string;
|
|
11
22
|
export declare const formatApprovalResult: ({ result }: CliApprovalResult) => string;
|
|
12
23
|
//# sourceMappingURL=format.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nodeLines } from "../../../address-space/index.js";
|
|
1
2
|
export const isApprovalResult = (result) => result.command.startsWith("approval.");
|
|
2
3
|
const indent = (text) => text
|
|
3
4
|
.split("\n")
|
|
@@ -17,6 +18,13 @@ export const describeApproval = (approval) => [
|
|
|
17
18
|
const formatList = (result) => result.items.length === 0
|
|
18
19
|
? "No worker waits on a person.\n"
|
|
19
20
|
: `${result.items.map(describeApproval).join("\n")}\n`;
|
|
21
|
+
export const formatMergedApprovals = ({ result, }) => `${formatList({
|
|
22
|
+
items: result.items.map((item) => ({
|
|
23
|
+
...item,
|
|
24
|
+
approvalId: `${item.node}\t${item.approvalId}`,
|
|
25
|
+
})),
|
|
26
|
+
method: "approval.list",
|
|
27
|
+
})}${nodeLines(result.nodes)}`;
|
|
20
28
|
export const formatApprovalResult = ({ result }) => {
|
|
21
29
|
if (result.method === "approval.list")
|
|
22
30
|
return formatList(result);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type ApprovalCliResult, type CliApprovalResult, describeApproval, formatApprovalResult, isApprovalResult, } from "./format.js";
|
|
1
|
+
export { type ApprovalCliResult, type CliApprovalResult, type CliMergedApprovals, describeApproval, formatApprovalResult, formatMergedApprovals, isApprovalResult, } from "./format.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { describeApproval, formatApprovalResult, isApprovalResult, } from "./format.js";
|
|
1
|
+
export { describeApproval, formatApprovalResult, formatMergedApprovals, isApprovalResult, } from "./format.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SessionAttachFrame } from "@maiaos/sdk";
|
|
2
2
|
import type * as Crypto from "effect/Crypto";
|
|
3
3
|
import type * as Stream from "effect/Stream";
|
|
4
|
-
import type
|
|
4
|
+
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
5
5
|
export type AttachSessionInput = {
|
|
6
6
|
readonly after?: {
|
|
7
7
|
readonly epoch: string;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { newCliIdentifier, } from "../local-node/index.js";
|
|
3
|
+
const attachOverBridge = ({ attachSession }, input) => attachSession === undefined
|
|
4
|
+
? Effect.fail(new Error("This Node connection carries no Session stream."))
|
|
5
|
+
: Effect.map(newCliIdentifier("request"), (messageId) => attachSession({
|
|
4
6
|
...(input.after === undefined ? {} : { after: input.after }),
|
|
5
7
|
sessionId: input.sessionId,
|
|
6
|
-
},
|
|
8
|
+
}, { messageId }));
|
|
9
|
+
export const makeAttachClient = (node) => ({
|
|
10
|
+
attachSession: (input) => node.remote
|
|
11
|
+
? node.runConnectionOperation((connection) => attachOverBridge(connection, input))
|
|
12
|
+
: node.runDiscoveryOperation((options) => Effect.promise(() => import("@maiaos/sdk/node/effect")).pipe(Effect.map((sdk) => sdk.attachSessionEffect({
|
|
13
|
+
...(input.after === undefined ? {} : { after: input.after }),
|
|
14
|
+
sessionId: input.sessionId,
|
|
15
|
+
}, options)))),
|
|
7
16
|
});
|
|
8
17
|
//# sourceMappingURL=attach-client.js.map
|