@maiaos/cli 0.1.0-canary.6 → 0.1.0-canary.61
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 +8 -7
- package/dist/agents/client.d.ts +47 -27
- package/dist/agents/client.js +10 -3
- package/dist/agents/commands.d.ts +1 -0
- package/dist/agents/commands.js +24 -2
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/agents/input.js +6 -0
- package/dist/agents/output/format.js +11 -0
- package/dist/agents/tree/tree.js +13 -1
- package/dist/bin/maia.cdx.json +19 -19
- package/dist/bin/maia.mjs +1 -1
- package/dist/cli/cli.d.ts +8 -2
- package/dist/cli/cli.js +29 -6
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/command-line/context.d.ts +4 -2
- package/dist/command-line/emit/index.d.ts +4 -0
- package/dist/command-line/emit/index.js +4 -0
- package/dist/command-line/{output.d.ts → emit/output.d.ts} +2 -2
- package/dist/command-line/{rows.d.ts → emit/rows.d.ts} +2 -0
- package/dist/command-line/{rows.js → emit/rows.js} +8 -0
- package/dist/command-line/index.d.ts +5 -5
- package/dist/command-line/index.js +5 -5
- package/dist/command-line/input/arguments.d.ts +10 -0
- package/dist/command-line/input/arguments.js +30 -10
- package/dist/command-line/input/index.d.ts +2 -1
- package/dist/command-line/input/index.js +2 -1
- package/dist/command-line/input/manager-options.d.ts +10 -0
- package/dist/command-line/input/manager-options.js +38 -0
- package/dist/command-line/two-phase/index.d.ts +2 -0
- package/dist/command-line/two-phase/index.js +2 -0
- package/dist/command-line/{two-phase.d.ts → two-phase/two-phase.d.ts} +12 -12
- package/dist/command-line/{two-phase.js → two-phase/two-phase.js} +2 -2
- package/dist/command-receipt/command.js +1 -1
- package/dist/command-tree/tree.d.ts +1 -1
- package/dist/command-tree/tree.js +6 -1
- package/dist/connection/input.js +2 -2
- package/dist/connection/system.js +3 -2
- package/dist/connection/tree/tree.js +5 -5
- package/dist/events/commands.js +65 -0
- package/dist/events/index.js +2 -0
- package/dist/events/tree/index.js +2 -0
- package/dist/events/tree/tree.js +17 -0
- package/dist/import/batch.js +196 -0
- package/dist/import/client.d.ts +3 -3
- package/dist/import/client.js +1 -1
- package/dist/import/commands.d.ts +1 -0
- package/dist/import/commands.js +82 -8
- package/dist/import/index.d.ts +1 -1
- package/dist/import/index.js +1 -1
- package/dist/import/input.js +38 -3
- package/dist/import/manifest.js +107 -0
- package/dist/import/output.js +46 -2
- package/dist/local-node/client.d.ts +1 -0
- package/dist/local-node/client.js +1 -0
- 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/gateway.js +2 -2
- package/dist/login/vendor-input.js +2 -2
- package/dist/mcp/calls.js +6 -1
- package/dist/mcp/routing.js +1 -0
- package/dist/project-guard/client.d.ts +12 -0
- package/dist/project-guard/input.js +15 -1
- package/dist/project-guard/output/format.js +5 -0
- package/dist/project-workspace/tree/tree.js +1 -1
- package/dist/reference/resolve.js +9 -2
- package/dist/remote-node/connector.js +8 -1
- package/dist/run-ledger/client.d.ts +2 -0
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/client.d.ts +5 -2
- package/dist/session/approval/client.js +2 -2
- package/dist/session/approval/commands.d.ts +1 -0
- package/dist/session/approval/commands.js +97 -17
- package/dist/session/approval/index.d.ts +1 -1
- package/dist/session/approval/index.js +1 -1
- package/dist/session/client.d.ts +14 -3
- package/dist/session/client.js +17 -2
- package/dist/session/coding-client.d.ts +2 -0
- package/dist/session/coding-client.js +1 -2
- package/dist/session/coding-commands.js +24 -7
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +131 -18
- package/dist/session/create-tasks.js +10 -2
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/output/human.js +32 -5
- package/dist/session/output/index.js +1 -1
- package/dist/session/output/tasks.js +51 -7
- package/dist/session/tree/tree.js +52 -19
- package/dist/session/turn/client.js +7 -9
- package/dist/session/turn/commands.js +67 -20
- package/dist/session/turn/output.d.ts +6 -0
- package/dist/session/turn/output.js +12 -2
- package/dist/status/client.d.ts +14 -3
- 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 +3 -0
- package/dist/status/output/compact.js +17 -7
- package/dist/status/output/human.js +15 -0
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.js +62 -0
- package/dist/terminal/output/compact-list.js +3 -0
- package/dist/terminal/output/human.js +2 -2
- package/dist/terminal/tree/tree.js +1 -1
- package/dist/webhooks/client.d.ts +156 -0
- package/dist/webhooks/client.js +8 -0
- package/dist/webhooks/commands.d.ts +17 -0
- package/dist/webhooks/commands.js +76 -0
- package/dist/webhooks/index.d.ts +3 -0
- package/dist/webhooks/index.js +3 -0
- package/dist/webhooks/input.js +125 -0
- package/dist/webhooks/output/format.js +75 -0
- package/dist/webhooks/output/index.js +2 -0
- package/dist/webhooks/tree/index.js +2 -0
- package/dist/webhooks/tree/tree.js +49 -0
- package/guidance/maia-cli/SKILL.md +1 -1
- package/guidance/maia-node/SKILL.md +54 -0
- package/guidance/maia-orchestration/SKILL.md +1 -2
- package/guidance/maia-sessions/SKILL.md +69 -0
- package/package.json +5 -5
- package/dist/address-space/address-space.d.ts +0 -38
- package/dist/address-space/index.d.ts +0 -2
- package/dist/agents/input.d.ts +0 -130
- package/dist/agents/output/format.d.ts +0 -8
- package/dist/agents/output/index.d.ts +0 -2
- package/dist/agents/tree/index.d.ts +0 -2
- package/dist/agents/tree/tree.d.ts +0 -3
- package/dist/bootstrap/exit.d.ts +0 -14
- package/dist/bootstrap/exit.js +0 -42
- package/dist/bootstrap/index.d.ts +0 -3
- package/dist/bootstrap/index.js +0 -3
- package/dist/bootstrap/process.d.ts +0 -5
- package/dist/bootstrap/process.js +0 -23
- package/dist/bootstrap/run.d.ts +0 -25
- package/dist/bootstrap/run.js +0 -95
- package/dist/bootstrap/stdio.d.ts +0 -4
- package/dist/bootstrap/stdio.js +0 -9
- package/dist/cli/environment.d.ts +0 -8
- package/dist/cli/services.d.ts +0 -4
- package/dist/command-line/input/stdin-stream.d.ts +0 -4
- package/dist/command-line/json-decoder.d.ts +0 -3
- package/dist/command-receipt/command.d.ts +0 -4
- package/dist/command-receipt/compact-list.d.ts +0 -20
- package/dist/command-receipt/index.d.ts +0 -3
- package/dist/command-tree/completion.d.ts +0 -6
- package/dist/command-tree/local.d.ts +0 -3
- package/dist/command-tree/row.js +0 -2
- package/dist/connection/access/format.d.ts +0 -8
- package/dist/connection/access/input.d.ts +0 -53
- package/dist/connection/input.d.ts +0 -50
- package/dist/connection/signin.d.ts +0 -4
- package/dist/connection/tree/index.d.ts +0 -2
- package/dist/connection/tree/tree.d.ts +0 -3
- package/dist/container/output/format.d.ts +0 -11
- package/dist/container/output/index.d.ts +0 -2
- package/dist/context/client.d.ts +0 -7
- package/dist/context/commands.d.ts +0 -3
- package/dist/context/index.d.ts +0 -3
- package/dist/dashboard/cockpit-client.d.ts +0 -6
- package/dist/dashboard/cockpit-client.js +0 -27
- package/dist/dashboard/cockpits.d.ts +0 -29
- package/dist/dashboard/cockpits.js +0 -65
- package/dist/dashboard/dashboard.d.ts +0 -7
- package/dist/dashboard/draw.d.ts +0 -15
- package/dist/dashboard/frame.d.ts +0 -4
- package/dist/dashboard/index.d.ts +0 -2
- package/dist/dashboard/modes.d.ts +0 -5
- package/dist/dashboard/node-connection.d.ts +0 -15
- package/dist/dashboard/node-connection.js +0 -51
- package/dist/dashboard/pi-tui.d.ts +0 -6
- package/dist/dashboard/status-bar.d.ts +0 -4
- package/dist/dashboard/terminal.d.ts +0 -53
- package/dist/dashboard/tree-model.d.ts +0 -28
- package/dist/dashboard/tree.d.ts +0 -10
- package/dist/development/cli.d.ts +0 -3
- package/dist/development/cli.js +0 -44
- package/dist/execution/tree/index.d.ts +0 -2
- package/dist/execution/tree/tree.d.ts +0 -3
- package/dist/hold/output/format.d.ts +0 -11
- package/dist/hold/output/index.d.ts +0 -2
- package/dist/hold/tree/index.d.ts +0 -2
- package/dist/hold/tree/tree.d.ts +0 -3
- package/dist/import/input.d.ts +0 -16
- package/dist/import/output.d.ts +0 -6
- package/dist/integration/output.d.ts +0 -22
- package/dist/login/failure.d.ts +0 -3
- package/dist/login/gateway.d.ts +0 -12
- package/dist/login/menu.d.ts +0 -4
- package/dist/login/output/format.d.ts +0 -16
- package/dist/login/output/index.d.ts +0 -2
- package/dist/login/vendor-account.d.ts +0 -95
- package/dist/login/vendor-input.d.ts +0 -14
- package/dist/mcp/calls.d.ts +0 -8
- package/dist/orchestration/output/compact-aggregate.d.ts +0 -121
- package/dist/orchestration/output/compact-run-list.d.ts +0 -20
- package/dist/orchestration/output/human.d.ts +0 -80
- package/dist/orchestration/output/index.d.ts +0 -4
- package/dist/orchestration/tree/index.d.ts +0 -2
- package/dist/orchestration/tree/tree.d.ts +0 -3
- package/dist/port-lease/input.d.ts +0 -65
- package/dist/port-lease/output/format.d.ts +0 -11
- package/dist/port-lease/output/index.d.ts +0 -2
- package/dist/presentation/output/format.d.ts +0 -11
- package/dist/presentation/output/index.d.ts +0 -3
- package/dist/project-guard/input.d.ts +0 -18
- package/dist/project-guard/output/format.d.ts +0 -11
- package/dist/project-guard/output/index.d.ts +0 -2
- package/dist/project-workspace/output/human.d.ts +0 -139
- package/dist/project-workspace/output/index.d.ts +0 -3
- package/dist/project-workspace/output/metadata.d.ts +0 -11
- package/dist/project-workspace/tree/index.d.ts +0 -2
- package/dist/project-workspace/tree/tree.d.ts +0 -3
- package/dist/provider/client.d.ts +0 -6
- package/dist/provider/commands.d.ts +0 -3
- package/dist/provider/index.d.ts +0 -3
- package/dist/reference/commands.d.ts +0 -3
- package/dist/reference/index.d.ts +0 -3
- package/dist/reference/resolve.d.ts +0 -31
- package/dist/reference/tree/index.d.ts +0 -2
- package/dist/reference/tree/tree.d.ts +0 -3
- package/dist/remote-node/reachability.d.ts +0 -64
- package/dist/remote-node/text.d.ts +0 -10
- package/dist/remote-node/tree/index.d.ts +0 -2
- package/dist/remote-node/tree/tree.d.ts +0 -3
- package/dist/routine/input.d.ts +0 -28
- package/dist/routine/output/format.d.ts +0 -23
- package/dist/routine/output/index.d.ts +0 -2
- package/dist/routine/tree/index.d.ts +0 -2
- package/dist/routine/tree/tree.d.ts +0 -3
- package/dist/run-ledger/input.d.ts +0 -42
- package/dist/run-ledger/output/format.d.ts +0 -11
- package/dist/run-ledger/output/index.d.ts +0 -2
- package/dist/session/approval/output/format.d.ts +0 -23
- package/dist/session/approval/output/index.d.ts +0 -2
- package/dist/session/attach-render.d.ts +0 -16
- package/dist/session/create-tasks.d.ts +0 -20
- package/dist/session/interaction/input.d.ts +0 -15
- package/dist/session/interaction/output/format.d.ts +0 -11
- package/dist/session/interaction/output/index.d.ts +0 -2
- package/dist/session/output/diff.d.ts +0 -3
- package/dist/session/output/failure.d.ts +0 -11
- package/dist/session/output/human.d.ts +0 -112
- package/dist/session/output/index.d.ts +0 -6
- package/dist/session/output/observe.d.ts +0 -4
- package/dist/session/output/tasks.d.ts +0 -34
- package/dist/session/task-file.d.ts +0 -5
- package/dist/session/tree/index.d.ts +0 -2
- package/dist/session/tree/tree.d.ts +0 -3
- package/dist/team-workspace/ceremony.d.ts +0 -19
- package/dist/team-workspace/confirmation.d.ts +0 -4
- package/dist/team-workspace/dependencies.js +0 -2
- package/dist/team-workspace/output.d.ts +0 -15
- package/dist/terminal/arguments.d.ts +0 -13
- package/dist/terminal/output/compact-list.d.ts +0 -148
- package/dist/terminal/output/human.d.ts +0 -42
- package/dist/terminal/output/index.d.ts +0 -3
- package/dist/terminal/tree/index.d.ts +0 -2
- package/dist/terminal/tree/tree.d.ts +0 -3
- /package/dist/command-line/{json-decoder.js → emit/json-decoder.js} +0 -0
- /package/dist/command-line/{json.d.ts → emit/json.d.ts} +0 -0
- /package/dist/command-line/{json.js → emit/json.js} +0 -0
- /package/dist/command-line/{output.js → emit/output.js} +0 -0
|
@@ -23,7 +23,7 @@ export const CONNECTION_TREE = {
|
|
|
23
23
|
],
|
|
24
24
|
leaves: [
|
|
25
25
|
[
|
|
26
|
-
"setup [--max-sessions <1..
|
|
26
|
+
"setup [--max-sessions <1..64>] [--command-id <id>] [--dry-run | --confirm-stdin | --yes]",
|
|
27
27
|
1,
|
|
28
28
|
["connection.system.preview", "connection.system.confirm"],
|
|
29
29
|
"Use installed vendor CLIs as system-default accounts.",
|
|
@@ -41,7 +41,7 @@ export const CONNECTION_TREE = {
|
|
|
41
41
|
{ kind: "composite", run: loginRunner },
|
|
42
42
|
],
|
|
43
43
|
[
|
|
44
|
-
"login <claude|codex> [--name <name>] [--device-code] [--max-sessions <1..
|
|
44
|
+
"login <claude|codex> [--name <name>] [--device-code] [--max-sessions <1..64>]",
|
|
45
45
|
1,
|
|
46
46
|
"",
|
|
47
47
|
"Add or re-sign a Claude Code or Codex account.",
|
|
@@ -59,14 +59,14 @@ export const CONNECTION_TREE = {
|
|
|
59
59
|
{ kind: "composite", run: loginRunner },
|
|
60
60
|
],
|
|
61
61
|
[
|
|
62
|
-
"login gateway --name <name> --base-url <url> --api-key-stdin [--max-sessions <1..
|
|
62
|
+
"login gateway --name <name> --base-url <url> --api-key-stdin [--max-sessions <1..64>] [--command-id <id>]",
|
|
63
63
|
1,
|
|
64
64
|
"connection.gateway.create",
|
|
65
65
|
"Add a gateway Connection with its API key.",
|
|
66
66
|
{ run: [login, "runLoginGateway"] },
|
|
67
67
|
],
|
|
68
68
|
[
|
|
69
|
-
"connection create --name <name> --executor <codex-cli|claude-code> --root <maia-managed|system-default> [--max-sessions <1..
|
|
69
|
+
"connection create --name <name> --executor <codex-cli|claude-code> --root <maia-managed|system-default> [--max-sessions <1..64>] [--command-id <id>]",
|
|
70
70
|
1,
|
|
71
71
|
"connection.create",
|
|
72
72
|
"Create a worker account Connection.",
|
|
@@ -133,7 +133,7 @@ export const CONNECTION_TREE = {
|
|
|
133
133
|
{ run: [connection, "runConnectionModelsList"] },
|
|
134
134
|
],
|
|
135
135
|
[
|
|
136
|
-
"connection capacity set <connection> --max-sessions <1..
|
|
136
|
+
"connection capacity set <connection> --max-sessions <1..64> --expected-revision <revision> [--command-id <id>]",
|
|
137
137
|
1,
|
|
138
138
|
"connection.capacity.set",
|
|
139
139
|
"Set a Connection's Session limit.",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { findEventKind, localNodeRequestPayloadSchema, SESSION_ACTIVITY_SUBJECT_TYPE, SESSION_STATUS_SUBJECT_TYPE, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { cell, writeNodeResult, } from "../command-line/emit/index.js";
|
|
4
|
+
import { CliArgumentError, parseOptionsWith, readPageSize, requirePositionals, } from "../command-line/input/index.js";
|
|
5
|
+
const MAX_LIMIT = 100;
|
|
6
|
+
const readSubject = (value) => {
|
|
7
|
+
const split = value.indexOf(":");
|
|
8
|
+
if (split < 1 || split === value.length - 1)
|
|
9
|
+
throw new CliArgumentError("Option '--subject' must be <type>:<id>.");
|
|
10
|
+
const type = value.slice(0, split);
|
|
11
|
+
if (type !== SESSION_ACTIVITY_SUBJECT_TYPE &&
|
|
12
|
+
type !== SESSION_STATUS_SUBJECT_TYPE)
|
|
13
|
+
throw new CliArgumentError(`Option '--subject' type must be ${SESSION_ACTIVITY_SUBJECT_TYPE} or ${SESSION_STATUS_SUBJECT_TYPE}.`);
|
|
14
|
+
return { id: value.slice(split + 1), type };
|
|
15
|
+
};
|
|
16
|
+
const readKinds = (value) => {
|
|
17
|
+
const kinds = value.split(",");
|
|
18
|
+
const unknown = kinds.find((kind) => findEventKind(kind) === undefined);
|
|
19
|
+
if (unknown !== undefined)
|
|
20
|
+
throw new CliArgumentError(`Unknown event kind '${unknown}'.`);
|
|
21
|
+
return kinds;
|
|
22
|
+
};
|
|
23
|
+
const readParameters = (tokens) => {
|
|
24
|
+
const parsed = parseOptionsWith(tokens, {
|
|
25
|
+
allowed: new Set(["--kind", "--limit", "--since", "--subject"]),
|
|
26
|
+
allowedFlags: new Set(),
|
|
27
|
+
repeatable: new Set(["--kind"]),
|
|
28
|
+
});
|
|
29
|
+
requirePositionals(parsed.positionals, 0);
|
|
30
|
+
const kind = parsed.options.get("--kind");
|
|
31
|
+
const limit = parsed.options.get("--limit");
|
|
32
|
+
const since = parsed.options.get("--since");
|
|
33
|
+
const subject = parsed.options.get("--subject");
|
|
34
|
+
const parameters = {
|
|
35
|
+
...(kind === undefined ? {} : { kinds: readKinds(kind) }),
|
|
36
|
+
...(limit === undefined ? {} : { limit: readPageSize(limit, MAX_LIMIT) }),
|
|
37
|
+
...(since === undefined ? {} : { since }),
|
|
38
|
+
...(subject === undefined ? {} : { subject: readSubject(subject) }),
|
|
39
|
+
};
|
|
40
|
+
if (!localNodeRequestPayloadSchema.safeParse({
|
|
41
|
+
method: "events.read",
|
|
42
|
+
parameters,
|
|
43
|
+
}).success)
|
|
44
|
+
throw new CliArgumentError("Options '--kind', '--since' and '--subject' must be valid event filters.");
|
|
45
|
+
return parameters;
|
|
46
|
+
};
|
|
47
|
+
const formatResult = (value) => {
|
|
48
|
+
if (value.status === "invalid_cursor")
|
|
49
|
+
return "invalid cursor; read again without --since\n";
|
|
50
|
+
if (value.status === "cursor_reset_required")
|
|
51
|
+
return `cursor reset (${value.reason}); resume with --since ${value.next}\n`;
|
|
52
|
+
const lines = value.events.map((event) => `${event.seq}\t${event.kind}\t${cell(event.subject.id)}\t${event.ts}\n`);
|
|
53
|
+
return `${lines.join("")}next ${value.next}\n`;
|
|
54
|
+
};
|
|
55
|
+
export const runEventsRead = (tokens, context) => {
|
|
56
|
+
const parameters = readParameters(tokens);
|
|
57
|
+
const { call } = context.dependencies;
|
|
58
|
+
if (call === undefined)
|
|
59
|
+
return Effect.die(new Error("Missing the typed Node call."));
|
|
60
|
+
return Effect.map(call("events.read", parameters), (result) => writeNodeResult(result, context, {
|
|
61
|
+
toResult: (value) => ({ command: "events.read", result: value }),
|
|
62
|
+
toText: ({ result: value }) => formatResult(value),
|
|
63
|
+
}));
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const events = () => import("../index.js");
|
|
2
|
+
export const EVENTS_TREE = {
|
|
3
|
+
groups: [["events", "The Node's public events, read by cursor."]],
|
|
4
|
+
leaves: [
|
|
5
|
+
[
|
|
6
|
+
"events read [--kind <kind>]... [--since <cursor>] [--subject <type>:<id>] [--limit <1..100>]",
|
|
7
|
+
1,
|
|
8
|
+
"events.read",
|
|
9
|
+
"Read one page of public events after a cursor.",
|
|
10
|
+
{
|
|
11
|
+
example: "maia --json events read --since <cursor> --limit 50",
|
|
12
|
+
run: [events, "runEventsRead"],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ADOPTION_REFUSED_ERROR_CODE, } from "@maiaos/sdk";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { jsonLine } from "../command-line/emit/index.js";
|
|
5
|
+
import { CliArgumentError } from "../command-line/input/index.js";
|
|
6
|
+
import { newCliIdentifier, } from "../local-node/index.js";
|
|
7
|
+
import { MAX_IMPORT_BYTES, MAX_IMPORT_ENTRIES, } from "./manifest.js";
|
|
8
|
+
const MAX_REASON_CHARACTERS = 300;
|
|
9
|
+
const harness = Schema.Literals(["claude-code", "codex-cli"]);
|
|
10
|
+
const nativeId = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.:-]{1,200}$/u));
|
|
11
|
+
const base = { harness, index: Schema.Int, nativeId };
|
|
12
|
+
const reason = Schema.String.check(Schema.isMaxLength(MAX_REASON_CHARACTERS));
|
|
13
|
+
const sessionId = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.:-]{1,200}$/u));
|
|
14
|
+
const plannedEntry = Schema.Union([
|
|
15
|
+
Schema.Struct({
|
|
16
|
+
...base,
|
|
17
|
+
commandId: sessionId,
|
|
18
|
+
connectionId: sessionId,
|
|
19
|
+
expiresAt: Schema.String,
|
|
20
|
+
hostAuthority: Schema.optional(Schema.Literal(true)),
|
|
21
|
+
inputDigest: Schema.String,
|
|
22
|
+
labels: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
23
|
+
outcome: Schema.Literal("adopt"),
|
|
24
|
+
permission: Schema.optional(Schema.String.check(Schema.isMaxLength(64))),
|
|
25
|
+
previewId: Schema.String.check(Schema.isPattern(/^adopt_[A-Za-z0-9_-]{43}$/u)),
|
|
26
|
+
role: Schema.optional(Schema.Literals(["orchestrator", "worker"])),
|
|
27
|
+
title: Schema.optional(Schema.String.check(Schema.isMaxLength(80))),
|
|
28
|
+
workingDirectory: Schema.String.check(Schema.isMaxLength(4096)),
|
|
29
|
+
workspaceId: sessionId,
|
|
30
|
+
}),
|
|
31
|
+
Schema.Struct({ ...base, outcome: Schema.Literal("skipped"), sessionId }),
|
|
32
|
+
Schema.Struct({ ...base, outcome: Schema.Literal("refused"), reason }),
|
|
33
|
+
]);
|
|
34
|
+
const importPlan = Schema.Struct({
|
|
35
|
+
entries: Schema.Array(plannedEntry).check(Schema.isMinLength(1), Schema.isMaxLength(MAX_IMPORT_ENTRIES)),
|
|
36
|
+
method: Schema.Literal("session.import.preview"),
|
|
37
|
+
});
|
|
38
|
+
const cut = (text) => text.length > MAX_REASON_CHARACTERS
|
|
39
|
+
? `${text.slice(0, MAX_REASON_CHARACTERS - 1)}…`
|
|
40
|
+
: text;
|
|
41
|
+
const identityOf = ({ harness, index, nativeId }) => ({
|
|
42
|
+
harness,
|
|
43
|
+
index,
|
|
44
|
+
nativeId,
|
|
45
|
+
});
|
|
46
|
+
const refusedBy = (identity, error) => ({
|
|
47
|
+
...identity,
|
|
48
|
+
outcome: "refused",
|
|
49
|
+
reason: cut(`${error.code}: ${error.message}`),
|
|
50
|
+
});
|
|
51
|
+
const managerFields = ({ labels, role, title }) => ({
|
|
52
|
+
...(labels === undefined ? {} : { labels }),
|
|
53
|
+
...(role === undefined ? {} : { role }),
|
|
54
|
+
...(title === undefined ? {} : { title }),
|
|
55
|
+
});
|
|
56
|
+
const plannedFrom = (identity, commandId, value) => "alreadyAdopted" in value
|
|
57
|
+
? {
|
|
58
|
+
...identity,
|
|
59
|
+
outcome: "skipped",
|
|
60
|
+
sessionId: value.alreadyAdopted.sessionId,
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
...identity,
|
|
64
|
+
commandId,
|
|
65
|
+
connectionId: value.connectionId,
|
|
66
|
+
expiresAt: value.expiresAt,
|
|
67
|
+
...(value.hostAuthority === true
|
|
68
|
+
? { hostAuthority: true }
|
|
69
|
+
: {}),
|
|
70
|
+
inputDigest: value.inputDigest,
|
|
71
|
+
outcome: "adopt",
|
|
72
|
+
...(value.permission === undefined
|
|
73
|
+
? {}
|
|
74
|
+
: { permission: value.permission }),
|
|
75
|
+
...managerFields(value),
|
|
76
|
+
previewId: value.previewId,
|
|
77
|
+
workingDirectory: value.workingDirectory,
|
|
78
|
+
workspaceId: value.workspaceId,
|
|
79
|
+
};
|
|
80
|
+
const previewEntry = (entry, previewAdopt) => {
|
|
81
|
+
const identity = identityOf(entry);
|
|
82
|
+
return Effect.gen(function* () {
|
|
83
|
+
const commandId = yield* newCliIdentifier("command");
|
|
84
|
+
const answer = yield* previewAdopt({ ...entry.request, commandId });
|
|
85
|
+
return answer.ok
|
|
86
|
+
? plannedFrom(identity, commandId, answer.value)
|
|
87
|
+
: refusedBy(identity, answer.error);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
export const previewOutputBytes = (plan) => new TextEncoder().encode(jsonLine({ ok: true, result: { command: "session.import", result: plan } })).length;
|
|
91
|
+
export const previewImport = (entries, previewAdopt) => Effect.forEach(entries, (entry) => previewEntry(entry, previewAdopt)).pipe(Effect.map((planned) => ({
|
|
92
|
+
entries: planned,
|
|
93
|
+
method: "session.import.preview",
|
|
94
|
+
})), Effect.filterOrFail((plan) => previewOutputBytes(plan) <= MAX_IMPORT_BYTES, () => new CliArgumentError(`The preview artifact exceeds ${String(MAX_IMPORT_BYTES)} bytes, the most '--confirm-stdin' reads; split the import file.`)));
|
|
95
|
+
export const readImportPlan = (value) => {
|
|
96
|
+
try {
|
|
97
|
+
return Schema.decodeUnknownSync(importPlan, { onExcessProperty: "error" })(value);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
throw new CliArgumentError("The piped preview is invalid; pipe the output of 'maia --json session import --from <file> --dry-run'.");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const AMBIGUOUS_CODES = new Set([
|
|
104
|
+
"deadline_exceeded",
|
|
105
|
+
"outcome_unknown",
|
|
106
|
+
"transport_failed",
|
|
107
|
+
]);
|
|
108
|
+
const failedConfirm = (entry, error) => {
|
|
109
|
+
const identity = identityOf(entry);
|
|
110
|
+
if (error.code === "already_adopted")
|
|
111
|
+
return { ...identity, outcome: "skipped" };
|
|
112
|
+
return AMBIGUOUS_CODES.has(error.code)
|
|
113
|
+
? {
|
|
114
|
+
...identity,
|
|
115
|
+
commandId: entry.commandId,
|
|
116
|
+
outcome: "unknown",
|
|
117
|
+
reason: cut(`${error.message} Check 'maia receipt show ${entry.commandId}' before importing again.`),
|
|
118
|
+
}
|
|
119
|
+
: refusedBy(identity, error);
|
|
120
|
+
};
|
|
121
|
+
const mismatch = (entry, value) => {
|
|
122
|
+
const differs = [
|
|
123
|
+
["command ID", value.commandId, entry.commandId],
|
|
124
|
+
["input digest", value.inputDigest, entry.inputDigest],
|
|
125
|
+
["executor", value.adoption.executor, entry.harness],
|
|
126
|
+
["native ID", value.adoption.nativeId, entry.nativeId],
|
|
127
|
+
["connection", value.adoption.connectionId, entry.connectionId],
|
|
128
|
+
].filter(([, got, wanted]) => got !== wanted);
|
|
129
|
+
return differs.length === 0
|
|
130
|
+
? undefined
|
|
131
|
+
: differs.map(([name]) => name).join(", ");
|
|
132
|
+
};
|
|
133
|
+
const confirmed = (entry, value) => {
|
|
134
|
+
const differs = mismatch(entry, value);
|
|
135
|
+
return differs === undefined
|
|
136
|
+
? {
|
|
137
|
+
...identityOf(entry),
|
|
138
|
+
commandId: entry.commandId,
|
|
139
|
+
delivery: value.delivery,
|
|
140
|
+
outcome: "adopted",
|
|
141
|
+
receiptId: value.receipt.receiptId,
|
|
142
|
+
sessionId: value.session.id,
|
|
143
|
+
}
|
|
144
|
+
: {
|
|
145
|
+
...identityOf(entry),
|
|
146
|
+
commandId: entry.commandId,
|
|
147
|
+
outcome: "unknown",
|
|
148
|
+
reason: cut(`The Node confirmed a different adoption than the preview (${differs}). Check 'maia receipt show ${entry.commandId}' before importing again.`),
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
const settled = (entry, answer) => answer.ok
|
|
152
|
+
? confirmed(entry, answer.value)
|
|
153
|
+
: failedConfirm(entry, answer.error);
|
|
154
|
+
const carried = (entry) => entry.outcome === "skipped"
|
|
155
|
+
? { ...identityOf(entry), outcome: "skipped", sessionId: entry.sessionId }
|
|
156
|
+
: { ...identityOf(entry), outcome: "refused", reason: entry.reason };
|
|
157
|
+
const confirmEntry = (entry, stopped, confirmAdopt) => {
|
|
158
|
+
if (entry.outcome !== "adopt")
|
|
159
|
+
return Effect.succeed(carried(entry));
|
|
160
|
+
if (stopped)
|
|
161
|
+
return Effect.succeed({
|
|
162
|
+
...identityOf(entry),
|
|
163
|
+
commandId: entry.commandId,
|
|
164
|
+
outcome: "not-attempted",
|
|
165
|
+
});
|
|
166
|
+
return confirmAdopt({
|
|
167
|
+
inputDigest: entry.inputDigest,
|
|
168
|
+
previewId: entry.previewId,
|
|
169
|
+
}).pipe(Effect.map((answer) => settled(entry, answer)));
|
|
170
|
+
};
|
|
171
|
+
export const confirmImport = (plan, confirmAdopt) => Effect.reduce(plan.entries, () => ({ entries: [], stopped: false }), (state, entry) => confirmEntry(entry, state.stopped, confirmAdopt).pipe(Effect.map((result) => ({
|
|
172
|
+
entries: [...state.entries, result],
|
|
173
|
+
stopped: state.stopped || result.outcome === "unknown",
|
|
174
|
+
})))).pipe(Effect.map(({ entries }) => ({
|
|
175
|
+
entries,
|
|
176
|
+
method: "session.import.confirm",
|
|
177
|
+
})));
|
|
178
|
+
export const firstFailure = (result) => {
|
|
179
|
+
const failed = result.entries.find((entry) => entry.outcome !== "adopted" && entry.outcome !== "skipped");
|
|
180
|
+
if (failed === undefined)
|
|
181
|
+
return undefined;
|
|
182
|
+
if (failed.outcome === "refused")
|
|
183
|
+
return {
|
|
184
|
+
code: ADOPTION_REFUSED_ERROR_CODE,
|
|
185
|
+
message: failed.reason,
|
|
186
|
+
retryable: false,
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
code: "outcome_unknown",
|
|
190
|
+
message: failed.outcome === "unknown"
|
|
191
|
+
? failed.reason
|
|
192
|
+
: `Entry ${String(failed.index)} was not attempted.`,
|
|
193
|
+
retryable: false,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=batch.js.map
|
package/dist/import/client.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type DiscoverySessionsListParameters, type DiscoverySessionsListResult, type SessionAdoptConfirmResult, type
|
|
1
|
+
import { type DiscoverySessionsListParameters, type DiscoverySessionsListResult, type SessionAdoptConfirmParameters, type SessionAdoptConfirmResult, type SessionAdoptPreviewOutcome, type SessionAdoptPreviewParameters, type SessionHistoryReadParameters, type SessionHistoryReadResult } from "@maiaos/sdk";
|
|
2
2
|
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
3
3
|
type AdoptInput = Omit<SessionAdoptPreviewParameters, "commandId"> & {
|
|
4
4
|
readonly commandId?: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const makeDiscoveryClient: (node: CliNodeOperations) => {
|
|
7
|
-
previewSessionAdopt: (input: AdoptInput) => CliNodeEffect<
|
|
8
|
-
confirmSessionAdopt: (
|
|
7
|
+
previewSessionAdopt: (input: AdoptInput) => CliNodeEffect<SessionAdoptPreviewOutcome>;
|
|
8
|
+
confirmSessionAdopt: (input: SessionAdoptConfirmParameters) => CliNodeEffect<SessionAdoptConfirmResult>;
|
|
9
9
|
listDiscoveredSessions: (input: DiscoverySessionsListParameters) => CliNodeEffect<DiscoverySessionsListResult>;
|
|
10
10
|
readSessionHistory: (input: SessionHistoryReadParameters) => CliNodeEffect<SessionHistoryReadResult>;
|
|
11
11
|
};
|
package/dist/import/client.js
CHANGED
|
@@ -5,7 +5,7 @@ const makePreviewClient = (node) => ({
|
|
|
5
5
|
previewSessionAdopt: (input) => Effect.flatMap(commandIdentifier(input.commandId), (commandId) => node.runValidatedNodeOperation({ ...input, commandId }, sessionAdoptPreviewParametersSchema, (client, parameters, options) => client.previewSessionAdopt(parameters, options))),
|
|
6
6
|
});
|
|
7
7
|
const makeConfirmClient = (node) => ({
|
|
8
|
-
confirmSessionAdopt: (
|
|
8
|
+
confirmSessionAdopt: (input) => node.runValidatedNodeOperation(input, sessionAdoptConfirmParametersSchema, (client, parameters, options) => client.confirmSessionAdopt(parameters, options)),
|
|
9
9
|
});
|
|
10
10
|
export const makeDiscoveryClient = (node) => ({
|
|
11
11
|
...makePreviewClient(node),
|
|
@@ -2,4 +2,5 @@ import { type CommandContext, type CommandEffect } from "../command-line/index.j
|
|
|
2
2
|
export declare const runScan: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
3
|
export declare const runHistoryRead: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
4
|
export declare const runAdopt: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
|
+
export declare const runImport: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
6
|
//# sourceMappingURL=commands.d.ts.map
|
package/dist/import/commands.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ADOPTION_REFUSED_ERROR_CODE, } from "@maiaos/sdk";
|
|
1
2
|
import { Effect } from "effect";
|
|
2
|
-
import { CliArgumentError, parseOptions, readTwoPhaseMode, reportError, requirePositionals, runTwoPhase, TWO_PHASE_FLAGS, writeSuccess, } from "../command-line/index.js";
|
|
3
|
+
import { CliArgumentError, LABEL_OPTION, parseOptions, parseOptionsWith, readTwoPhaseMode, reportError, requireOneLabelPerOption, requirePositionals, runTwoPhase, TWO_PHASE_FLAGS, writeSuccess, } from "../command-line/index.js";
|
|
4
|
+
import { confirmImport, firstFailure, previewImport, readImportPlan, } from "./batch.js";
|
|
3
5
|
import { readAdopt, readHistory, readScan } from "./input.js";
|
|
4
|
-
import {
|
|
6
|
+
import { parseManifest, readManifestFile } from "./manifest.js";
|
|
7
|
+
import { formatAdoptConfirm, formatAdoptPreview, formatHistory, formatImportPreview, formatImportResult, formatScan, } from "./output.js";
|
|
5
8
|
const missingClient = () => Effect.fail(new CliArgumentError("Session discovery is unavailable."));
|
|
6
9
|
const write = (response, context, output) => {
|
|
7
10
|
if (!response.ok)
|
|
@@ -39,14 +42,34 @@ export const runHistoryRead = (tokens, context) => Effect.gen(function* () {
|
|
|
39
42
|
format: formatHistory,
|
|
40
43
|
});
|
|
41
44
|
}).pipe(Effect.catch(failed(context)));
|
|
42
|
-
const
|
|
45
|
+
const confirmationOf = (preview) => {
|
|
43
46
|
const previewId = Reflect.get(preview, "previewId");
|
|
44
|
-
|
|
47
|
+
const inputDigest = Reflect.get(preview, "inputDigest");
|
|
48
|
+
if (typeof previewId !== "string" ||
|
|
49
|
+
!previewId.startsWith("adopt_") ||
|
|
50
|
+
typeof inputDigest !== "string")
|
|
45
51
|
throw new CliArgumentError("The piped preview is invalid; pipe the output of 'maia --json session adopt … --dry-run'.");
|
|
46
|
-
return previewId;
|
|
52
|
+
return { inputDigest, previewId };
|
|
47
53
|
};
|
|
48
54
|
const readAdoptMode = (tokens, context) => {
|
|
49
|
-
|
|
55
|
+
requireOneLabelPerOption(tokens);
|
|
56
|
+
const parsed = parseOptionsWith(tokens, {
|
|
57
|
+
allowed: new Set([
|
|
58
|
+
"--command-id",
|
|
59
|
+
"--label",
|
|
60
|
+
"--name",
|
|
61
|
+
"--permission",
|
|
62
|
+
"--role",
|
|
63
|
+
"--title",
|
|
64
|
+
"--workspace",
|
|
65
|
+
]),
|
|
66
|
+
allowedFlags: new Set([
|
|
67
|
+
"--attest-ended",
|
|
68
|
+
"--host-authority",
|
|
69
|
+
...TWO_PHASE_FLAGS,
|
|
70
|
+
]),
|
|
71
|
+
repeatable: LABEL_OPTION,
|
|
72
|
+
});
|
|
50
73
|
const mode = readTwoPhaseMode(parsed.flags, context);
|
|
51
74
|
if (mode === "confirm-stdin")
|
|
52
75
|
requirePositionals(parsed.positionals, 0);
|
|
@@ -57,10 +80,10 @@ export const runAdopt = (tokens, context) => Effect.gen(function* () {
|
|
|
57
80
|
const previewSessionAdopt = yield* required(context, "previewSessionAdopt");
|
|
58
81
|
const confirmSessionAdopt = yield* required(context, "confirmSessionAdopt");
|
|
59
82
|
return yield* runTwoPhase({
|
|
60
|
-
confirm: (preview) => Effect.suspend(() => confirmSessionAdopt(
|
|
83
|
+
confirm: (preview) => Effect.suspend(() => confirmSessionAdopt(confirmationOf(preview))),
|
|
61
84
|
context,
|
|
62
85
|
mode,
|
|
63
|
-
preview: () => Effect.suspend(() => previewSessionAdopt(readAdopt(parsed))),
|
|
86
|
+
preview: () => Effect.suspend(() => previewSessionAdopt(readAdopt(parsed))).pipe(Effect.map(refuseAlreadyAdopted)),
|
|
64
87
|
prompt: { describe: formatAdoptPreview, question: "Adopt this session?" },
|
|
65
88
|
writeConfirm: (result) => write(result, context, {
|
|
66
89
|
command: "session.adopt.confirm",
|
|
@@ -72,4 +95,55 @@ export const runAdopt = (tokens, context) => Effect.gen(function* () {
|
|
|
72
95
|
}),
|
|
73
96
|
});
|
|
74
97
|
}).pipe(Effect.catch(failed(context)));
|
|
98
|
+
const refuseAlreadyAdopted = (response) => response.ok && "alreadyAdopted" in response.value
|
|
99
|
+
? {
|
|
100
|
+
error: {
|
|
101
|
+
code: ADOPTION_REFUSED_ERROR_CODE,
|
|
102
|
+
message: `Maia Session ${response.value.alreadyAdopted.sessionId} already adopted this session.`,
|
|
103
|
+
retryable: false,
|
|
104
|
+
},
|
|
105
|
+
ok: false,
|
|
106
|
+
}
|
|
107
|
+
: response;
|
|
108
|
+
const IMPORT_INCOMPLETE = 1;
|
|
109
|
+
const readImportSource = (parsed, mode) => {
|
|
110
|
+
const from = parsed.options.get("--from");
|
|
111
|
+
if (mode === "confirm-stdin" && from !== undefined)
|
|
112
|
+
throw new CliArgumentError("Option '--from' belongs to the preview; '--confirm-stdin' takes the piped preview.");
|
|
113
|
+
if (mode !== "confirm-stdin" && from === undefined)
|
|
114
|
+
throw new CliArgumentError("Option '--from' is required.");
|
|
115
|
+
return from ?? "";
|
|
116
|
+
};
|
|
117
|
+
const importWriter = (context, format, failure) => (result) => {
|
|
118
|
+
if (!result.ok)
|
|
119
|
+
return reportError(result.error, context);
|
|
120
|
+
const error = failure?.(result.value);
|
|
121
|
+
writeSuccess({ command: "session.import", result: result.value }, error === undefined ? context : { ...context, error, ok: false }, () => format(result.value));
|
|
122
|
+
return error === undefined ? 0 : IMPORT_INCOMPLETE;
|
|
123
|
+
};
|
|
124
|
+
const ok = (value) => ({ ok: true, value });
|
|
125
|
+
const IMPORT_PROMPT = {
|
|
126
|
+
describe: formatImportPreview,
|
|
127
|
+
question: "Adopt these sessions?",
|
|
128
|
+
};
|
|
129
|
+
const readImportArguments = (tokens, context) => {
|
|
130
|
+
const parsed = parseOptions(tokens, new Set(["--from"]), new Set(TWO_PHASE_FLAGS));
|
|
131
|
+
requirePositionals(parsed.positionals, 0);
|
|
132
|
+
const mode = readTwoPhaseMode(parsed.flags, context);
|
|
133
|
+
return { from: readImportSource(parsed, mode), mode };
|
|
134
|
+
};
|
|
135
|
+
export const runImport = (tokens, context) => Effect.gen(function* () {
|
|
136
|
+
const { from, mode } = readImportArguments(tokens, context);
|
|
137
|
+
const previewAdopt = yield* required(context, "previewSessionAdopt");
|
|
138
|
+
const confirmAdopt = yield* required(context, "confirmSessionAdopt");
|
|
139
|
+
return yield* runTwoPhase({
|
|
140
|
+
confirm: (piped) => Effect.suspend(() => confirmImport(readImportPlan(piped), confirmAdopt)).pipe(Effect.map(ok)),
|
|
141
|
+
context,
|
|
142
|
+
mode,
|
|
143
|
+
preview: () => readManifestFile(from).pipe(Effect.flatMap(parseManifest), Effect.flatMap((entries) => previewImport(entries, previewAdopt)), Effect.map(ok)),
|
|
144
|
+
prompt: IMPORT_PROMPT,
|
|
145
|
+
writeConfirm: importWriter(context, formatImportResult, firstFailure),
|
|
146
|
+
writePreview: importWriter(context, formatImportPreview),
|
|
147
|
+
});
|
|
148
|
+
}).pipe(Effect.catch(failed(context)));
|
|
75
149
|
//# sourceMappingURL=commands.js.map
|
package/dist/import/index.d.ts
CHANGED
package/dist/import/index.js
CHANGED
package/dist/import/input.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
2
|
+
import { CliArgumentError, parseOptions, readLabels, readPageSize, readPermission, readSessionRole, readSessionTitle, requirePositionals, } from "../command-line/index.js";
|
|
3
|
+
export const validPermission = (permission, executor) => {
|
|
4
|
+
const valid = sessionCreateParametersSchema.safeParse({
|
|
5
|
+
commandId: "command_validate",
|
|
6
|
+
...(executor === undefined
|
|
7
|
+
? { connectionId: "connection_validate" }
|
|
8
|
+
: { executor }),
|
|
9
|
+
expectedRevision: "0",
|
|
10
|
+
hostAuthority: true,
|
|
11
|
+
permission,
|
|
12
|
+
workspaceId: "workspace_validate",
|
|
13
|
+
});
|
|
14
|
+
return valid.success ? valid.data.permission : undefined;
|
|
15
|
+
};
|
|
2
16
|
const SOURCES = ["claude", "codex"];
|
|
3
17
|
const readSources = (value) => {
|
|
4
18
|
if (value === undefined)
|
|
@@ -19,18 +33,28 @@ const readDays = (value) => {
|
|
|
19
33
|
return days;
|
|
20
34
|
};
|
|
21
35
|
const readScanLimit = (value) => value === undefined ? 50 : readPageSize(value);
|
|
36
|
+
const readAdoptedFilter = (flags) => {
|
|
37
|
+
if (flags.has("--adopted") && flags.has("--not-adopted"))
|
|
38
|
+
throw new CliArgumentError("Options '--adopted' and '--not-adopted' cannot be used together.");
|
|
39
|
+
if (flags.has("--adopted"))
|
|
40
|
+
return "only";
|
|
41
|
+
return flags.has("--not-adopted") ? "none" : undefined;
|
|
42
|
+
};
|
|
22
43
|
export const readScan = (tokens) => {
|
|
23
|
-
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--root", "--since", "--source"]), new Set(["--include-content"]));
|
|
44
|
+
const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--root", "--since", "--source"]), new Set(["--adopted", "--include-content", "--not-adopted", "--running"]));
|
|
24
45
|
requirePositionals(parsed.positionals, 0);
|
|
46
|
+
const adopted = readAdoptedFilter(parsed.flags);
|
|
25
47
|
const cursor = parsed.options.get("--after");
|
|
26
48
|
const root = parsed.options.get("--root");
|
|
27
49
|
const sinceDays = readDays(parsed.options.get("--since"));
|
|
28
50
|
return {
|
|
51
|
+
...(adopted === undefined ? {} : { adopted }),
|
|
29
52
|
...(cursor === undefined ? {} : { cursor }),
|
|
30
53
|
...(parsed.flags.has("--include-content")
|
|
31
54
|
? { includeContentFields: true }
|
|
32
55
|
: {}),
|
|
33
56
|
limit: readScanLimit(parsed.options.get("--limit")),
|
|
57
|
+
...(parsed.flags.has("--running") ? { observed: "running" } : {}),
|
|
34
58
|
...(root === undefined ? {} : { roots: [root] }),
|
|
35
59
|
...(sinceDays === undefined ? {} : { sinceDays }),
|
|
36
60
|
sources: readSources(parsed.options.get("--source")),
|
|
@@ -80,12 +104,23 @@ export const readAdopt = (parsed) => {
|
|
|
80
104
|
if (workspaceId === undefined)
|
|
81
105
|
throw new CliArgumentError("Option '--workspace' is required.");
|
|
82
106
|
const commandId = parsed.options.get("--command-id");
|
|
107
|
+
const permission = parsed.options.get("--permission");
|
|
108
|
+
const hostAuthority = parsed.flags.has("--host-authority");
|
|
109
|
+
if (permission !== undefined && !hostAuthority)
|
|
110
|
+
throw new CliArgumentError("Option '--permission' needs '--host-authority'.");
|
|
111
|
+
const target = readNativeTarget(parsed.positionals[0] ?? "");
|
|
112
|
+
const title = readSessionTitle(parsed.options);
|
|
83
113
|
return {
|
|
84
114
|
...(parsed.flags.has("--attest-ended")
|
|
85
115
|
? { attestEnded: true }
|
|
86
116
|
: {}),
|
|
87
117
|
...(commandId === undefined ? {} : { commandId }),
|
|
88
|
-
...
|
|
118
|
+
...(hostAuthority ? { hostAuthority: true } : {}),
|
|
119
|
+
...readPermission(permission, (value) => validPermission(value, target.executor)),
|
|
120
|
+
...readLabels(parsed.options.get("--label")),
|
|
121
|
+
...readSessionRole(parsed.options.get("--role")),
|
|
122
|
+
...(title === undefined ? {} : { title }),
|
|
123
|
+
...target,
|
|
89
124
|
workspaceId,
|
|
90
125
|
};
|
|
91
126
|
};
|