@maiaos/cli 0.1.0-canary.55 → 0.1.0-canary.57
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 +4 -3
- package/dist/bin/maia.cdx.json +19 -19
- package/dist/bin/maia.mjs +1 -1
- package/dist/cli/cli.js +10 -0
- package/dist/command-line/context.d.ts +2 -1
- package/dist/command-line/emit/index.d.ts +1 -1
- package/dist/command-line/emit/index.js +1 -1
- package/dist/command-line/emit/rows.d.ts +1 -0
- package/dist/command-line/emit/rows.js +5 -0
- package/dist/command-line/index.d.ts +3 -3
- package/dist/command-line/index.js +3 -3
- package/dist/command-line/input/index.d.ts +2 -1
- package/dist/command-line/input/index.js +1 -0
- 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-tree/tree.d.ts +1 -1
- package/dist/command-tree/tree.js +3 -0
- package/dist/events/commands.js +4 -3
- 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 +16 -2
- package/dist/import/manifest.js +107 -0
- package/dist/import/output.js +44 -2
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/commands.d.ts +1 -0
- package/dist/session/approval/commands.js +75 -9
- package/dist/session/approval/index.d.ts +1 -1
- package/dist/session/approval/index.js +1 -1
- package/dist/session/client.d.ts +2 -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.js +36 -39
- package/dist/session/output/human.js +14 -3
- package/dist/session/output/tasks.js +25 -11
- package/dist/session/tree/tree.js +31 -9
- 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/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 -132
- 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 -98
- 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/emit/json-decoder.d.ts +0 -3
- package/dist/command-line/input/stdin-stream.d.ts +0 -4
- 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/events/commands.d.ts +0 -11
- package/dist/events/index.d.ts +0 -2
- package/dist/events/tree/index.d.ts +0 -2
- package/dist/events/tree/tree.d.ts +0 -10
- 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 -19
- 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 -21
- 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 -115
- 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 -36
- 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/keys.d.ts +0 -12
- package/dist/terminal/output/compact-list.d.ts +0 -149
- 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/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,5 +1,5 @@
|
|
|
1
1
|
import { sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
2
|
-
import { CliArgumentError, parseOptions, readPageSize, readPermission, requirePositionals, } from "../command-line/index.js";
|
|
2
|
+
import { CliArgumentError, parseOptions, readLabels, readPageSize, readPermission, readSessionRole, readSessionTitle, requirePositionals, } from "../command-line/index.js";
|
|
3
3
|
export const validPermission = (permission, executor) => {
|
|
4
4
|
const valid = sessionCreateParametersSchema.safeParse({
|
|
5
5
|
commandId: "command_validate",
|
|
@@ -33,18 +33,28 @@ const readDays = (value) => {
|
|
|
33
33
|
return days;
|
|
34
34
|
};
|
|
35
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
|
+
};
|
|
36
43
|
export const readScan = (tokens) => {
|
|
37
|
-
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"]));
|
|
38
45
|
requirePositionals(parsed.positionals, 0);
|
|
46
|
+
const adopted = readAdoptedFilter(parsed.flags);
|
|
39
47
|
const cursor = parsed.options.get("--after");
|
|
40
48
|
const root = parsed.options.get("--root");
|
|
41
49
|
const sinceDays = readDays(parsed.options.get("--since"));
|
|
42
50
|
return {
|
|
51
|
+
...(adopted === undefined ? {} : { adopted }),
|
|
43
52
|
...(cursor === undefined ? {} : { cursor }),
|
|
44
53
|
...(parsed.flags.has("--include-content")
|
|
45
54
|
? { includeContentFields: true }
|
|
46
55
|
: {}),
|
|
47
56
|
limit: readScanLimit(parsed.options.get("--limit")),
|
|
57
|
+
...(parsed.flags.has("--running") ? { observed: "running" } : {}),
|
|
48
58
|
...(root === undefined ? {} : { roots: [root] }),
|
|
49
59
|
...(sinceDays === undefined ? {} : { sinceDays }),
|
|
50
60
|
sources: readSources(parsed.options.get("--source")),
|
|
@@ -99,6 +109,7 @@ export const readAdopt = (parsed) => {
|
|
|
99
109
|
if (permission !== undefined && !hostAuthority)
|
|
100
110
|
throw new CliArgumentError("Option '--permission' needs '--host-authority'.");
|
|
101
111
|
const target = readNativeTarget(parsed.positionals[0] ?? "");
|
|
112
|
+
const title = readSessionTitle(parsed.options);
|
|
102
113
|
return {
|
|
103
114
|
...(parsed.flags.has("--attest-ended")
|
|
104
115
|
? { attestEnded: true }
|
|
@@ -106,6 +117,9 @@ export const readAdopt = (parsed) => {
|
|
|
106
117
|
...(commandId === undefined ? {} : { commandId }),
|
|
107
118
|
...(hostAuthority ? { hostAuthority: true } : {}),
|
|
108
119
|
...readPermission(permission, (value) => validPermission(value, target.executor)),
|
|
120
|
+
...readLabels(parsed.options.get("--label")),
|
|
121
|
+
...readSessionRole(parsed.options.get("--role")),
|
|
122
|
+
...(title === undefined ? {} : { title }),
|
|
109
123
|
...target,
|
|
110
124
|
workspaceId,
|
|
111
125
|
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
2
|
+
import { sessionAdoptPreviewParametersSchema } from "@maiaos/sdk";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as FileSystem from "effect/FileSystem";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import { CliArgumentError } from "../command-line/input/index.js";
|
|
7
|
+
export const MAX_IMPORT_ENTRIES = 64;
|
|
8
|
+
export const MAX_IMPORT_BYTES = 64 * 1024;
|
|
9
|
+
const ENTRY_KEYS = new Set([
|
|
10
|
+
"attestEnded",
|
|
11
|
+
"harness",
|
|
12
|
+
"hostAuthority",
|
|
13
|
+
"labels",
|
|
14
|
+
"nativeId",
|
|
15
|
+
"role",
|
|
16
|
+
"title",
|
|
17
|
+
"workspaceId",
|
|
18
|
+
]);
|
|
19
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
const invalid = (message) => new CliArgumentError(message);
|
|
21
|
+
const unreadable = () => invalid("Option '--from' must name a readable JSON file.");
|
|
22
|
+
export const readManifestFile = (path) => Effect.gen(function* () {
|
|
23
|
+
const fs = yield* FileSystem.FileSystem;
|
|
24
|
+
const info = yield* fs.stat(path);
|
|
25
|
+
if (info.type !== "File")
|
|
26
|
+
return yield* unreadable();
|
|
27
|
+
if (Number(info.size) > MAX_IMPORT_BYTES)
|
|
28
|
+
return yield* invalid(`The import file must be at most ${String(MAX_IMPORT_BYTES)} bytes.`);
|
|
29
|
+
const bytes = yield* fs.readFile(path);
|
|
30
|
+
return yield* Effect.try({
|
|
31
|
+
catch: () => invalid("The import file must be UTF-8 text."),
|
|
32
|
+
try: () => new TextDecoder("utf-8", { fatal: true }).decode(bytes),
|
|
33
|
+
});
|
|
34
|
+
}).pipe(Effect.catchTag("PlatformError", () => Effect.fail(unreadable())), Effect.provide(NodeFileSystem.layer));
|
|
35
|
+
const hostFields = (value, where) => {
|
|
36
|
+
if (value === undefined)
|
|
37
|
+
return {};
|
|
38
|
+
if (!isRecord(value) ||
|
|
39
|
+
Object.keys(value).some((key) => key !== "permission"))
|
|
40
|
+
throw invalid(`${where}: 'hostAuthority' must be an object with an optional 'permission'.`);
|
|
41
|
+
const { permission } = value;
|
|
42
|
+
return {
|
|
43
|
+
hostAuthority: true,
|
|
44
|
+
...(permission === undefined ? {} : { permission }),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const readHarness = (value, where) => {
|
|
48
|
+
const unknown = Object.keys(value).filter((key) => !ENTRY_KEYS.has(key));
|
|
49
|
+
if (unknown.length > 0)
|
|
50
|
+
throw invalid(`${where} has unknown fields: ${unknown.join(", ")}.`);
|
|
51
|
+
const { harness } = value;
|
|
52
|
+
if (harness !== "claude-code" && harness !== "codex-cli")
|
|
53
|
+
throw invalid(`${where}: 'harness' must be claude-code or codex-cli.`);
|
|
54
|
+
return harness;
|
|
55
|
+
};
|
|
56
|
+
const parseEntry = (value, index) => {
|
|
57
|
+
const where = `Entry ${String(index)}`;
|
|
58
|
+
if (!isRecord(value))
|
|
59
|
+
throw invalid(`${where} must be an object.`);
|
|
60
|
+
const harness = readHarness(value, where);
|
|
61
|
+
const { attestEnded, hostAuthority, labels, nativeId, role, title } = value;
|
|
62
|
+
const { workspaceId } = value;
|
|
63
|
+
const parsed = sessionAdoptPreviewParametersSchema.safeParse({
|
|
64
|
+
...(attestEnded === undefined ? {} : { attestEnded }),
|
|
65
|
+
commandId: "command_manifest_check",
|
|
66
|
+
executor: harness,
|
|
67
|
+
...hostFields(hostAuthority, where),
|
|
68
|
+
nativeId,
|
|
69
|
+
...(labels === undefined ? {} : { labels }),
|
|
70
|
+
...(role === undefined ? {} : { role }),
|
|
71
|
+
...(title === undefined ? {} : { title }),
|
|
72
|
+
workspaceId,
|
|
73
|
+
});
|
|
74
|
+
if (!parsed.success)
|
|
75
|
+
throw invalid(`${where}: 'nativeId', 'workspaceId', 'attestEnded', 'hostAuthority', 'title', 'labels' or 'role' is invalid.`);
|
|
76
|
+
const { commandId: _commandId, ...request } = parsed.data;
|
|
77
|
+
return { harness, index, nativeId: request.nativeId, request };
|
|
78
|
+
};
|
|
79
|
+
const requireEntries = (document) => {
|
|
80
|
+
const entries = isRecord(document) ? document.entries : undefined;
|
|
81
|
+
if (!Array.isArray(entries) || entries.length === 0)
|
|
82
|
+
throw invalid('The import file must be { "entries": [ ... ] } with at least one entry.');
|
|
83
|
+
if (entries.length > MAX_IMPORT_ENTRIES)
|
|
84
|
+
throw invalid(`An import takes at most ${String(MAX_IMPORT_ENTRIES)} entries; split the file.`);
|
|
85
|
+
return entries;
|
|
86
|
+
};
|
|
87
|
+
const requireDistinct = (entries) => {
|
|
88
|
+
const seen = new Set();
|
|
89
|
+
entries.forEach((entry) => {
|
|
90
|
+
const key = `${entry.harness}:${entry.nativeId}`;
|
|
91
|
+
if (seen.has(key))
|
|
92
|
+
throw invalid(`Entry ${String(entry.index)} repeats ${key}.`);
|
|
93
|
+
seen.add(key);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const decodeDocument = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
|
|
97
|
+
export const parseManifest = (text) => decodeDocument(text).pipe(Effect.mapError(() => invalid("The import file is not valid JSON.")), Effect.flatMap((document) => Effect.try({
|
|
98
|
+
catch: (error) => error instanceof CliArgumentError
|
|
99
|
+
? error
|
|
100
|
+
: invalid("The import file is invalid."),
|
|
101
|
+
try: () => {
|
|
102
|
+
const parsed = requireEntries(document).map(parseEntry);
|
|
103
|
+
requireDistinct(parsed);
|
|
104
|
+
return parsed;
|
|
105
|
+
},
|
|
106
|
+
})));
|
|
107
|
+
//# sourceMappingURL=manifest.js.map
|
package/dist/import/output.js
CHANGED
|
@@ -2,15 +2,17 @@ import { cell } from "../command-line/index.js";
|
|
|
2
2
|
const line = (...cells) => `${cells.map(cell).join("\t")}\n`;
|
|
3
3
|
const nativeName = (session) => `${session.executor === "claude-code" ? "claude" : "codex"}:${session.nativeId}`;
|
|
4
4
|
const groupLine = (group) => line(group.kind, group.repository?.rootPath ?? group.cwd ?? "", `${String(group.sessionCount)} sessions`, group.registeredProjectId ?? "unregistered");
|
|
5
|
-
const sessionLine = (session) => line(nativeName(session), `${session.liveness}/${session.livenessEvidence}`, session.lastActivityAt, session.cwd, session.sources.join(","), session.adoptedSessionId === undefined
|
|
5
|
+
const sessionLine = (session) => line(nativeName(session), `${session.liveness}/${session.livenessEvidence}`, session.observed ?? "", session.lastActivityAt, session.cwd, session.sources.join(","), session.adoptedSessionId === undefined
|
|
6
6
|
? ""
|
|
7
7
|
: `adopted:${session.adoptedSessionId}`, session.content?.title ?? session.content?.firstPrompt ?? "");
|
|
8
|
+
const truncatedLines = (result) => (result.truncatedSources ?? []).map((source) => line("truncated", source, "this page ends where the listing stopped; the next page continues from the cursor"));
|
|
8
9
|
export const formatScan = (result) => {
|
|
9
10
|
const { bySource, excluded, orphaned, total } = result.summary;
|
|
10
11
|
return [
|
|
11
12
|
line(`${String(total)} sessions since ${result.since}`, `claude ${String(bySource.claude)}, codex ${String(bySource.codex)}`, `orphaned ${String(orphaned)}`),
|
|
12
13
|
line("excluded", `maia ${String(excluded.maiaOwned)}`, `workers ${String(excluded.subagent)}`, `outside-roots ${String(excluded.outsideRoots)}`),
|
|
13
14
|
...result.sourceErrors.map((error) => line("source-error", error.source, error.code, error.message)),
|
|
15
|
+
...truncatedLines(result),
|
|
14
16
|
...result.groups.map(groupLine),
|
|
15
17
|
...result.items.map(sessionLine),
|
|
16
18
|
result.nextCursor === undefined
|
|
@@ -18,10 +20,21 @@ export const formatScan = (result) => {
|
|
|
18
20
|
: line("next", `--cursor ${result.nextCursor}`),
|
|
19
21
|
].join("");
|
|
20
22
|
};
|
|
23
|
+
const managerParts = ({ labels, role, title, }) => [
|
|
24
|
+
...(role === undefined ? [] : [`role ${role}`]),
|
|
25
|
+
...(labels === undefined
|
|
26
|
+
? []
|
|
27
|
+
: [
|
|
28
|
+
`labels ${Object.entries(labels)
|
|
29
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
30
|
+
.join(",")}`,
|
|
31
|
+
]),
|
|
32
|
+
...(title === undefined ? [] : [`title ${title}`]),
|
|
33
|
+
];
|
|
21
34
|
export const formatAdoptPreview = (preview) => [
|
|
22
35
|
line(`adopt ${nativeName(preview)}`, `workspace ${preview.workspaceId}`, `${preview.workingDirectory} (${preview.workingDirectoryOrigin})`, `account ${preview.connectionId}`, `${preview.liveness}/${preview.livenessEvidence}`, ...(preview.hostAuthority === true
|
|
23
36
|
? ["containment none (host authority)"]
|
|
24
|
-
: [])),
|
|
37
|
+
: []), ...managerParts(preview)),
|
|
25
38
|
line("confirm", `printf '{"previewId":"${preview.previewId}"}' | maia session adopt --confirm-stdin`, `expires ${preview.expiresAt}`),
|
|
26
39
|
].join("");
|
|
27
40
|
export const formatAdoptConfirm = (result) => [
|
|
@@ -36,4 +49,33 @@ export const formatHistory = (result) => [
|
|
|
36
49
|
? ""
|
|
37
50
|
: line("next", `--offset ${String(result.nextOffset)}`),
|
|
38
51
|
].join("");
|
|
52
|
+
const adoptDetail = (entry) => "workspaceId" in entry
|
|
53
|
+
? [
|
|
54
|
+
`workspace ${entry.workspaceId}`,
|
|
55
|
+
`account ${entry.connectionId}`,
|
|
56
|
+
entry.workingDirectory,
|
|
57
|
+
entry.hostAuthority === true
|
|
58
|
+
? `host authority${entry.permission === undefined ? "" : ` ${entry.permission}`}`
|
|
59
|
+
: "contained",
|
|
60
|
+
...managerParts(entry),
|
|
61
|
+
]
|
|
62
|
+
: [];
|
|
63
|
+
const importLine = (entry) => {
|
|
64
|
+
const name = `${entry.harness === "claude-code" ? "claude" : "codex"}:${entry.nativeId}`;
|
|
65
|
+
const detail = [
|
|
66
|
+
...adoptDetail(entry),
|
|
67
|
+
"sessionId" in entry ? entry.sessionId : undefined,
|
|
68
|
+
"reason" in entry ? entry.reason : undefined,
|
|
69
|
+
"previewId" in entry ? `preview ${entry.previewId}` : undefined,
|
|
70
|
+
"commandId" in entry && !("previewId" in entry)
|
|
71
|
+
? `command ${entry.commandId}`
|
|
72
|
+
: undefined,
|
|
73
|
+
].filter((part) => part !== undefined);
|
|
74
|
+
return line(`#${String(entry.index)}`, entry.outcome, name, ...detail);
|
|
75
|
+
};
|
|
76
|
+
export const formatImportPreview = (plan) => [
|
|
77
|
+
...plan.entries.map(importLine),
|
|
78
|
+
line("confirm", "maia --json session import --from <file> --dry-run | maia session import --confirm-stdin"),
|
|
79
|
+
].join("");
|
|
80
|
+
export const formatImportResult = (result) => result.entries.map(importLine).join("");
|
|
39
81
|
//# sourceMappingURL=output.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 ("agents.change.confirm" | "agents.change.preview" | "agents.detect" | "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")[];
|
|
21
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.detect" | "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" | "webhooks.change.confirm" | "webhooks.change.preview" | "webhooks.deliveries" | "webhooks.list" | "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 ("agents.change.confirm" | "agents.change.preview" | "agents.detect" | "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")[];
|
|
58
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.detect" | "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" | "webhooks.change.confirm" | "webhooks.change.preview" | "webhooks.deliveries" | "webhooks.list" | "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
|
};
|
|
@@ -4,4 +4,5 @@ export declare const runApprovalShow: (tokens: readonly string[], context: Comma
|
|
|
4
4
|
export declare const runApprovalApprove: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
5
|
export declare const runApprovalDeny: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
6
|
export declare const runApprovalAnswer: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
7
|
+
export declare const runSessionAnswer: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
7
8
|
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -109,7 +109,20 @@ const notConfirmed = (context) => reportError({
|
|
|
109
109
|
message: "Nothing approved; the worker still waits until the request expires.",
|
|
110
110
|
retryable: false,
|
|
111
111
|
}, context);
|
|
112
|
-
const
|
|
112
|
+
const respond = (context, { approvalId, asCoordinator, commandId }, { approval, decision }) => Effect.gen(function* () {
|
|
113
|
+
const { respondToApproval } = context.dependencies;
|
|
114
|
+
if (respondToApproval === undefined)
|
|
115
|
+
return yield* missing("decision");
|
|
116
|
+
const id = yield* commandIdentifier(commandId);
|
|
117
|
+
return write(context)(yield* respondToApproval({
|
|
118
|
+
...decision,
|
|
119
|
+
approvalId,
|
|
120
|
+
commandId: id,
|
|
121
|
+
requestDigest: approval.requestDigest,
|
|
122
|
+
}, asCoordinator));
|
|
123
|
+
});
|
|
124
|
+
const decide = (context, input) => {
|
|
125
|
+
const { approvalId, asCoordinator, requested } = input;
|
|
113
126
|
const { respondToApproval, showApproval } = context.dependencies;
|
|
114
127
|
if (respondToApproval === undefined || showApproval === undefined)
|
|
115
128
|
return missing("decision");
|
|
@@ -118,17 +131,11 @@ const decide = (context, { approvalId, asCoordinator, commandId, requested }) =>
|
|
|
118
131
|
if (!shown.ok)
|
|
119
132
|
return write(context)(shown);
|
|
120
133
|
const { approval } = shown.value;
|
|
121
|
-
const decision = resolveAnswer(approval, requested);
|
|
134
|
+
const decision = resolveAnswer(approval, typeof requested === "function" ? requested(approval) : requested);
|
|
122
135
|
const reading = { approval, asCoordinator, decision };
|
|
123
136
|
if (!(yield* confirmed(context, reading)))
|
|
124
137
|
return notConfirmed(context);
|
|
125
|
-
|
|
126
|
-
return write(context)(yield* respondToApproval({
|
|
127
|
-
...decision,
|
|
128
|
-
approvalId,
|
|
129
|
-
commandId: id,
|
|
130
|
-
requestDigest: approval.requestDigest,
|
|
131
|
-
}, asCoordinator));
|
|
138
|
+
return yield* respond(context, input, reading);
|
|
132
139
|
});
|
|
133
140
|
};
|
|
134
141
|
const runDecision = (verb, tokens, context) => Effect.gen(function* () {
|
|
@@ -152,4 +159,63 @@ const parseDecision = (verb, tokens, context) => {
|
|
|
152
159
|
export const runApprovalApprove = (tokens, context) => runDecision("approve", tokens, context);
|
|
153
160
|
export const runApprovalDeny = (tokens, context) => runDecision("deny", tokens, context);
|
|
154
161
|
export const runApprovalAnswer = (tokens, context) => runDecision("answer", tokens, context);
|
|
162
|
+
const answerDecision = (approval, text) => {
|
|
163
|
+
if (approval.kind === "question")
|
|
164
|
+
return { answer: text, decision: "answer" };
|
|
165
|
+
const word = text.trim().toLowerCase();
|
|
166
|
+
if (word === "approve" || word === "deny")
|
|
167
|
+
return { decision: word };
|
|
168
|
+
throw new CliArgumentError(`This ${approval.kind} request takes 'approve' or 'deny', not an answer.`);
|
|
169
|
+
};
|
|
170
|
+
const decisionFor = (context, approval, { asCoordinator, credential, sessionId, text }) => {
|
|
171
|
+
if (approval.sessionId !== sessionId)
|
|
172
|
+
throw new CliArgumentError(`Prompt '${approval.approvalId}' belongs to ${approval.sessionId}, not ${sessionId}.`);
|
|
173
|
+
const decision = answerDecision(approval, text);
|
|
174
|
+
const verb = decision.decision;
|
|
175
|
+
if (!asCoordinator && !(credential && verb === "answer"))
|
|
176
|
+
requirePerson(context, verb);
|
|
177
|
+
return decision;
|
|
178
|
+
};
|
|
179
|
+
const statusUnreadable = (context) => reportError({
|
|
180
|
+
code: "invalid_argument",
|
|
181
|
+
message: "The Session's status is unknown; no answer was sent.",
|
|
182
|
+
retryable: false,
|
|
183
|
+
}, context);
|
|
184
|
+
const parseAnswer = (tokens) => {
|
|
185
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--prompt"]), new Set(["--as-coordinator"]));
|
|
186
|
+
requirePositionals(parsed.positionals, 2);
|
|
187
|
+
const [sessionId = "", text = ""] = parsed.positionals;
|
|
188
|
+
const approvalId = parsed.options.get("--prompt");
|
|
189
|
+
if (approvalId === undefined)
|
|
190
|
+
throw new CliArgumentError("Option '--prompt' is required: name the prompt that 'session show' printed.");
|
|
191
|
+
const commandId = parsed.options.get("--command-id");
|
|
192
|
+
return {
|
|
193
|
+
approvalId,
|
|
194
|
+
asCoordinator: parsed.flags.has("--as-coordinator"),
|
|
195
|
+
...(commandId === undefined ? {} : { commandId }),
|
|
196
|
+
sessionId,
|
|
197
|
+
text,
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
export const runSessionAnswer = (tokens, context) => {
|
|
201
|
+
const { sessionId, text, ...input } = parseAnswer(tokens);
|
|
202
|
+
return Effect.gen(function* () {
|
|
203
|
+
const credential = yield* holdsSessionCredential;
|
|
204
|
+
const shown = yield* context.dependencies.showSession(sessionId);
|
|
205
|
+
if (!shown.ok)
|
|
206
|
+
return reportError(shown.error, context);
|
|
207
|
+
if (shown.value.session.status === "unknown")
|
|
208
|
+
return statusUnreadable(context);
|
|
209
|
+
const { asCoordinator } = input;
|
|
210
|
+
return yield* decide(context, {
|
|
211
|
+
...input,
|
|
212
|
+
requested: (approval) => decisionFor(context, approval, {
|
|
213
|
+
asCoordinator,
|
|
214
|
+
credential,
|
|
215
|
+
sessionId,
|
|
216
|
+
text,
|
|
217
|
+
}),
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
};
|
|
155
221
|
//# sourceMappingURL=commands.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { type ApprovalCliDependencies, makeApprovalClient } from "./client.js";
|
|
2
|
-
export { runApprovalAnswer, runApprovalApprove, runApprovalDeny, runApprovalList, runApprovalShow, } from "./commands.js";
|
|
2
|
+
export { runApprovalAnswer, runApprovalApprove, runApprovalDeny, runApprovalList, runApprovalShow, runSessionAnswer, } from "./commands.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { makeApprovalClient } from "./client.js";
|
|
2
|
-
export { runApprovalAnswer, runApprovalApprove, runApprovalDeny, runApprovalList, runApprovalShow, } from "./commands.js";
|
|
2
|
+
export { runApprovalAnswer, runApprovalApprove, runApprovalDeny, runApprovalList, runApprovalShow, runSessionAnswer, } from "./commands.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|