@maiaos/cli 0.1.0-canary.2 → 0.1.0-canary.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -265
- package/dist/address-space/address-space.d.ts +38 -0
- package/dist/address-space/address-space.js +130 -0
- package/dist/address-space/index.d.ts +2 -0
- package/dist/address-space/index.js +2 -0
- package/dist/agents/client.d.ts +171 -0
- package/dist/agents/client.js +8 -0
- package/dist/agents/commands.d.ts +7 -0
- package/dist/agents/commands.js +65 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/input.d.ts +130 -0
- package/dist/agents/input.js +99 -0
- package/dist/agents/output/format.d.ts +8 -0
- package/dist/agents/output/format.js +47 -0
- package/dist/agents/output/index.d.ts +2 -0
- package/dist/agents/output/index.js +2 -0
- package/dist/agents/tree/index.d.ts +2 -0
- package/dist/agents/tree/index.js +2 -0
- package/dist/agents/tree/tree.d.ts +3 -0
- package/dist/agents/tree/tree.js +43 -0
- package/dist/bin/maia.cdx.json +37 -14
- package/dist/bin/maia.mjs +1 -1
- package/dist/bootstrap/exit.d.ts +14 -0
- package/dist/bootstrap/exit.js +42 -0
- package/dist/bootstrap/process.js +4 -26
- package/dist/bootstrap/run.js +5 -2
- package/dist/cli/cli.d.ts +2 -1
- package/dist/cli/cli.js +81 -16
- package/dist/command-line/context.d.ts +14 -4
- package/dist/command-line/context.js +1 -1
- package/dist/command-line/index.d.ts +6 -6
- package/dist/command-line/index.js +6 -5
- package/dist/command-line/input/arguments.d.ts +7 -0
- package/dist/command-line/input/arguments.js +22 -10
- package/dist/command-line/input/index.d.ts +2 -2
- package/dist/command-line/input/index.js +2 -2
- package/dist/command-line/input/stdin.d.ts +1 -0
- package/dist/command-line/input/stdin.js +1 -0
- package/dist/command-line/json.d.ts +1 -0
- package/dist/command-line/json.js +23 -0
- package/dist/command-line/output.d.ts +8 -1
- package/dist/command-line/output.js +33 -14
- package/dist/command-line/rows.d.ts +2 -0
- package/dist/command-line/rows.js +10 -1
- package/dist/command-line/two-phase.d.ts +5 -0
- package/dist/command-line/two-phase.js +33 -8
- package/dist/command-tree/help.d.ts +1 -1
- package/dist/command-tree/help.js +1 -0
- package/dist/command-tree/index.d.ts +2 -2
- package/dist/command-tree/index.js +1 -1
- package/dist/command-tree/local.js +12 -0
- package/dist/command-tree/placeholder.d.ts +1 -0
- package/dist/command-tree/placeholder.js +1 -0
- package/dist/command-tree/row.d.ts +2 -0
- package/dist/command-tree/tree.d.ts +3 -2
- package/dist/command-tree/tree.js +18 -2
- package/dist/connection/access/client.d.ts +13 -0
- package/dist/connection/access/client.js +19 -0
- package/dist/connection/access/commands.d.ts +6 -0
- package/dist/connection/access/commands.js +60 -0
- package/dist/connection/access/format.d.ts +8 -0
- package/dist/connection/access/format.js +61 -0
- package/dist/connection/access/index.d.ts +3 -0
- package/dist/connection/access/index.js +3 -0
- package/dist/connection/access/input.d.ts +53 -0
- package/dist/connection/access/input.js +83 -0
- package/dist/connection/client.d.ts +99 -1
- package/dist/connection/client.js +9 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.js +2 -1
- package/dist/connection/system.d.ts +1 -0
- package/dist/connection/system.js +109 -5
- package/dist/connection/tree/tree.js +59 -8
- package/dist/container/output/format.js +1 -2
- package/dist/dashboard/cockpit-client.d.ts +6 -0
- package/dist/dashboard/cockpit-client.js +27 -0
- package/dist/dashboard/cockpits.d.ts +29 -0
- package/dist/dashboard/cockpits.js +65 -0
- package/dist/dashboard/dashboard.d.ts +7 -0
- package/dist/dashboard/dashboard.js +47 -0
- package/dist/dashboard/draw.d.ts +15 -0
- package/dist/dashboard/draw.js +30 -0
- package/dist/dashboard/frame.d.ts +4 -0
- package/dist/dashboard/frame.js +15 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/modes.d.ts +5 -0
- package/dist/dashboard/modes.js +16 -0
- package/dist/dashboard/node-connection.d.ts +15 -0
- package/dist/dashboard/node-connection.js +51 -0
- package/dist/dashboard/pi-tui.d.ts +6 -0
- package/dist/dashboard/pi-tui.js +35 -0
- package/dist/dashboard/status-bar.d.ts +4 -0
- package/dist/dashboard/status-bar.js +60 -0
- package/dist/dashboard/terminal.d.ts +53 -0
- package/dist/dashboard/terminal.js +165 -0
- package/dist/dashboard/tree-model.d.ts +28 -0
- package/dist/dashboard/tree-model.js +97 -0
- package/dist/dashboard/tree.d.ts +10 -0
- package/dist/dashboard/tree.js +76 -0
- package/dist/fleet/fleet.d.ts +70 -0
- package/dist/fleet/fleet.js +91 -0
- package/dist/fleet/index.d.ts +2 -0
- package/dist/fleet/index.js +2 -0
- package/dist/hold/output/format.js +1 -5
- package/dist/hold/tree/tree.js +1 -0
- package/dist/import/commands.js +3 -4
- package/dist/import/output.js +1 -4
- package/dist/local-node/client.d.ts +9 -4
- package/dist/local-node/client.js +21 -9
- package/dist/local-node/index.d.ts +2 -1
- package/dist/local-node/index.js +2 -1
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/commands.js +2 -1
- package/dist/mcp/calls.d.ts +1 -0
- package/dist/mcp/calls.js +37 -3
- package/dist/mcp/commands.d.ts +5 -2
- package/dist/mcp/commands.js +30 -4
- package/dist/mcp/routing.d.ts +24 -0
- package/dist/mcp/routing.js +188 -0
- package/dist/mcp/server.d.ts +13 -4
- package/dist/mcp/server.js +35 -12
- package/dist/presentation/output/format.js +4 -3
- package/dist/project-guard/commands.js +11 -2
- package/dist/project-workspace/commands.js +16 -6
- package/dist/project-workspace/output/human.d.ts +13 -0
- package/dist/project-workspace/output/human.js +17 -5
- package/dist/project-workspace/output/index.d.ts +1 -1
- package/dist/project-workspace/output/index.js +1 -1
- package/dist/project-workspace/output/metadata.js +1 -1
- package/dist/project-workspace/tree/tree.js +27 -12
- package/dist/reference/commands.js +4 -2
- package/dist/reference/index.d.ts +1 -1
- package/dist/reference/index.js +1 -1
- package/dist/reference/resolve.d.ts +2 -0
- package/dist/reference/resolve.js +28 -18
- package/dist/remote-node/client.d.ts +89 -9
- package/dist/remote-node/client.js +6 -1
- package/dist/remote-node/commands.d.ts +9 -0
- package/dist/remote-node/commands.js +96 -18
- package/dist/remote-node/connector.d.ts +12 -4
- package/dist/remote-node/connector.js +54 -26
- package/dist/remote-node/index.d.ts +2 -2
- package/dist/remote-node/index.js +2 -2
- package/dist/remote-node/reachability.d.ts +43 -1
- package/dist/remote-node/reachability.js +13 -3
- package/dist/remote-node/text.d.ts +2 -1
- package/dist/remote-node/text.js +74 -27
- package/dist/remote-node/tree/tree.js +21 -1
- package/dist/routine/client.d.ts +398 -0
- package/dist/routine/client.js +28 -0
- package/dist/routine/commands.d.ts +9 -0
- package/dist/routine/commands.js +109 -0
- package/dist/routine/index.d.ts +3 -0
- package/dist/routine/index.js +3 -0
- package/dist/routine/input.d.ts +28 -0
- package/dist/routine/input.js +44 -0
- package/dist/routine/output/format.d.ts +23 -0
- package/dist/routine/output/format.js +83 -0
- package/dist/routine/output/index.d.ts +2 -0
- package/dist/routine/output/index.js +2 -0
- package/dist/routine/tree/index.d.ts +2 -0
- package/dist/routine/tree/index.js +2 -0
- package/dist/routine/tree/tree.d.ts +3 -0
- package/dist/routine/tree/tree.js +70 -0
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/commands.js +31 -9
- package/dist/session/approval/output/format.d.ts +11 -0
- package/dist/session/approval/output/format.js +8 -0
- package/dist/session/approval/output/index.d.ts +1 -1
- package/dist/session/approval/output/index.js +1 -1
- package/dist/session/attach-client.d.ts +1 -1
- package/dist/session/attach-client.js +12 -3
- package/dist/session/attach-render.js +15 -7
- package/dist/session/attach.js +17 -3
- package/dist/session/client.d.ts +12 -3
- package/dist/session/client.js +18 -17
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +120 -13
- package/dist/session/create-tasks.js +29 -11
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.js +2 -1
- package/dist/session/interaction/output/format.js +2 -1
- package/dist/session/output/diff.js +3 -10
- package/dist/session/output/failure.js +3 -10
- package/dist/session/output/human.d.ts +1 -0
- package/dist/session/output/human.js +21 -10
- package/dist/session/output/index.d.ts +2 -2
- package/dist/session/output/index.js +2 -2
- package/dist/session/output/tasks.d.ts +16 -1
- package/dist/session/output/tasks.js +41 -27
- package/dist/session/tree/tree.js +67 -8
- package/dist/session/turn/client.d.ts +4 -1
- package/dist/session/turn/client.js +22 -11
- package/dist/session/turn/commands.d.ts +2 -0
- package/dist/session/turn/commands.js +39 -11
- package/dist/session/turn/index.d.ts +3 -3
- package/dist/session/turn/index.js +1 -1
- package/dist/session/turn/output.d.ts +7 -2
- package/dist/session/turn/output.js +36 -13
- package/dist/status/client.d.ts +7 -2
- package/dist/status/command.js +3 -1
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +10 -4
- package/dist/status/output/compact.d.ts +1 -0
- package/dist/status/output/compact.js +3 -0
- package/dist/status/output/human.d.ts +1 -1
- package/dist/status/output/human.js +71 -14
- package/dist/team-workspace/ceremony.d.ts +19 -0
- package/dist/team-workspace/ceremony.js +141 -0
- package/dist/team-workspace/client.d.ts +58 -0
- package/dist/team-workspace/client.js +6 -0
- package/dist/team-workspace/commands.d.ts +3 -0
- package/dist/team-workspace/commands.js +85 -0
- package/dist/team-workspace/confirmation.d.ts +4 -0
- package/dist/team-workspace/confirmation.js +8 -0
- package/dist/team-workspace/dependencies.d.ts +8 -0
- package/dist/team-workspace/dependencies.js +2 -0
- package/dist/team-workspace/index.d.ts +6 -0
- package/dist/team-workspace/index.js +5 -0
- package/dist/team-workspace/launcher.d.ts +17 -0
- package/dist/team-workspace/launcher.js +30 -0
- package/dist/team-workspace/output.d.ts +15 -0
- package/dist/team-workspace/output.js +28 -0
- package/dist/team-workspace/terminal.d.ts +9 -0
- package/dist/team-workspace/terminal.js +46 -0
- package/dist/terminal/client.d.ts +4 -0
- package/dist/terminal/client.js +3 -0
- package/dist/terminal/commands.js +37 -25
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.d.ts +12 -0
- package/dist/terminal/keys.js +62 -0
- package/dist/terminal/output/compact-list.d.ts +1 -0
- package/dist/terminal/output/compact-list.js +1 -0
- package/dist/terminal/output/human.d.ts +2 -19
- package/dist/terminal/output/human.js +6 -6
- package/dist/terminal/tree/tree.js +16 -16
- package/package.json +10 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNewSessionRecord, reduceSessionAttach, sessionItemText, } from "@maiaos/sdk";
|
|
2
|
+
import { block, cell } from "../command-line/index.js";
|
|
2
3
|
import { formatFailureCell } from "./output/index.js";
|
|
3
4
|
const MAX_ARGUMENTS_SHOWN = 200;
|
|
4
5
|
const header = (item) => {
|
|
@@ -8,9 +9,9 @@ const header = (item) => {
|
|
|
8
9
|
case "reasoning":
|
|
9
10
|
return "thinking> ";
|
|
10
11
|
case "command":
|
|
11
|
-
return `$ ${item.command}\n`;
|
|
12
|
+
return `$ ${cell(item.command)}\n`;
|
|
12
13
|
case "tool_call":
|
|
13
|
-
return `tool ${item.name} ${(item.arguments ?? "").slice(0, MAX_ARGUMENTS_SHOWN)}\n`;
|
|
14
|
+
return `tool ${cell(`${item.name} ${(item.arguments ?? "").slice(0, MAX_ARGUMENTS_SHOWN)}`)}\n`;
|
|
14
15
|
case "approval_request":
|
|
15
16
|
return item.approvalId === undefined
|
|
16
17
|
? "approval? "
|
|
@@ -28,7 +29,7 @@ const footer = (record) => {
|
|
|
28
29
|
if (item.kind === "command" && item.exitCode !== undefined)
|
|
29
30
|
return `[exit ${String(item.exitCode)}]\n${status}`;
|
|
30
31
|
if (item.kind === "file_change")
|
|
31
|
-
return `${item.changes.map((change) => `${change.change} ${change.path}\n`).join("")}${status}`;
|
|
32
|
+
return `${item.changes.map((change) => `${change.change} ${cell(change.path)}\n`).join("")}${status}`;
|
|
32
33
|
if (item.kind === "usage")
|
|
33
34
|
return `tokens: ${String(item.inputTokens)} in (${String(item.cachedInputTokens)} cached), ${String(item.outputTokens)} out${item.modelCallCount === undefined ? "" : `, ${String(item.modelCallCount)} model call${item.modelCallCount === 1 ? "" : "s"}`}\n`;
|
|
34
35
|
return status;
|
|
@@ -39,6 +40,13 @@ const emit = (rendered, text) => text.length === 0
|
|
|
39
40
|
state: { ...rendered.state, lineOpen: !text.endsWith("\n") },
|
|
40
41
|
text: `${rendered.text}${text}`,
|
|
41
42
|
};
|
|
43
|
+
const INDENT = " ";
|
|
44
|
+
const emitBody = (rendered, text) => emit(rendered, text
|
|
45
|
+
.split("\n")
|
|
46
|
+
.map((line, index) => line.length > 0 && (index > 0 || !rendered.state.lineOpen)
|
|
47
|
+
? `${INDENT}${line}`
|
|
48
|
+
: line)
|
|
49
|
+
.join("\n"));
|
|
42
50
|
const closeLine = (rendered) => {
|
|
43
51
|
const closed = rendered.state.lineOpen ? emit(rendered, "\n") : rendered;
|
|
44
52
|
return { ...closed, state: { ...closed.state, openItem: undefined } };
|
|
@@ -64,11 +72,11 @@ const writeItemText = (rendered, itemId, { cut = false, text }) => {
|
|
|
64
72
|
if (cut && !extendsShown) {
|
|
65
73
|
const positioned = onItemLine(rendered, itemId);
|
|
66
74
|
const separator = positioned.state.lineOpen ? "\n" : "";
|
|
67
|
-
return withShown(emit(positioned, `${separator}
|
|
75
|
+
return withShown(emitBody(emit(positioned, `${separator}…`), text), itemId, text);
|
|
68
76
|
}
|
|
69
77
|
if (!extendsShown || text.length === shown.length)
|
|
70
78
|
return rendered;
|
|
71
|
-
return withShown(
|
|
79
|
+
return withShown(emitBody(onItemLine(rendered, itemId), text.slice(shown.length)), itemId, text);
|
|
72
80
|
};
|
|
73
81
|
const renderStarted = (rendered, record) => {
|
|
74
82
|
const opened = emit(closeLine(rendered), header(record.item));
|
|
@@ -85,7 +93,7 @@ const renderDelta = (rendered, record) => {
|
|
|
85
93
|
const shown = rendered.state.written.get(record.itemId);
|
|
86
94
|
if (shown === undefined)
|
|
87
95
|
return rendered;
|
|
88
|
-
const appended =
|
|
96
|
+
const appended = emitBody(onItemLine(rendered, record.itemId), record.delta);
|
|
89
97
|
return {
|
|
90
98
|
...appended,
|
|
91
99
|
state: {
|
|
@@ -147,7 +155,7 @@ export const renderSessionAttachFrame = (state, frame) => {
|
|
|
147
155
|
const rendered = renderFrameText(state, frame);
|
|
148
156
|
return {
|
|
149
157
|
state: { ...rendered.state, view: reduceSessionAttach(state.view, frame) },
|
|
150
|
-
text: rendered.text,
|
|
158
|
+
text: block(rendered.text),
|
|
151
159
|
};
|
|
152
160
|
};
|
|
153
161
|
export const finishSessionAttachRender = (state) => state.lineOpen ? "\n" : "";
|
package/dist/session/attach.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { initialSessionAttachView, sessionAttachCursor, } from "@maiaos/sdk";
|
|
1
|
+
import { initialSessionAttachView, protocolErrorSchema, sessionAttachCursor, } from "@maiaos/sdk";
|
|
2
2
|
import * as Duration from "effect/Duration";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Ref from "effect/Ref";
|
|
5
5
|
import * as Stream from "effect/Stream";
|
|
6
|
-
import { CliArgumentError, parseOptions, reportError, requirePositionals, } from "../command-line/index.js";
|
|
6
|
+
import { CliArgumentError, jsonLine, parseOptions, reportError, requirePositionals, } from "../command-line/index.js";
|
|
7
7
|
import { finishSessionAttachRender, initialAttachRenderState, renderSessionAttachFrame, } from "./attach-render.js";
|
|
8
8
|
const MAX_IDLE_REATTACHES = 5;
|
|
9
9
|
const REATTACH_BACKOFF = Duration.millis(100);
|
|
@@ -31,10 +31,21 @@ const writeFrame = (attachment, frame) => Ref.modify(attachment.state, (state) =
|
|
|
31
31
|
}).pipe(Effect.map((text) => {
|
|
32
32
|
const { io, json } = attachment.context;
|
|
33
33
|
if (json)
|
|
34
|
-
io.stdout(
|
|
34
|
+
io.stdout(jsonLine(frame));
|
|
35
35
|
else if (text.length > 0)
|
|
36
36
|
io.stdout(text);
|
|
37
37
|
}));
|
|
38
|
+
const finalFailure = (failure) => {
|
|
39
|
+
if (!(failure instanceof Error) || !("code" in failure))
|
|
40
|
+
return undefined;
|
|
41
|
+
const remote = protocolErrorSchema.safeParse("remoteError" in failure ? failure.remoteError : undefined);
|
|
42
|
+
if (remote.success)
|
|
43
|
+
return remote.data;
|
|
44
|
+
return failure.code === "transport_failure" ||
|
|
45
|
+
typeof failure.code !== "string"
|
|
46
|
+
? undefined
|
|
47
|
+
: { code: failure.code, message: failure.message, retryable: false };
|
|
48
|
+
};
|
|
38
49
|
const framesOf = (attachment, stream) => attachment.follow
|
|
39
50
|
? stream
|
|
40
51
|
: stream.pipe(Stream.takeUntil((frame) => frame.kind === "synchronized"));
|
|
@@ -64,6 +75,9 @@ const attachOnce = (attachment) => Effect.gen(function* () {
|
|
|
64
75
|
if (!opened.ok)
|
|
65
76
|
return { error: opened.error, kind: "failed" };
|
|
66
77
|
const ran = yield* Effect.result(Stream.runForEach(framesOf(attachment, opened.value), (frame) => writeFrame(attachment, frame)));
|
|
78
|
+
const refusal = ran._tag === "Failure" ? finalFailure(ran.failure) : undefined;
|
|
79
|
+
if (refusal !== undefined)
|
|
80
|
+
return { error: refusal, kind: "failed" };
|
|
67
81
|
return yield* outcomeOf(attachment, ran._tag === "Success");
|
|
68
82
|
});
|
|
69
83
|
const finish = (attachment, outcome) => Ref.get(attachment.state).pipe(Effect.map((state) => {
|
package/dist/session/client.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import type { Session, SessionCreateParameters, SessionCreateResult, SessionCreationInput, SessionCreationOutcome, SessionCreationPlan, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListParameters, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionSpawnResult, SessionStartResult, SessionStopResult } from "@maiaos/sdk";
|
|
1
|
+
import type { Session, SessionCreateParameters, SessionCreateResult, SessionCreationInput, SessionCreationOutcome, SessionCreationPlan, SessionEventsListResult, SessionInboxAckResult, SessionInboxCheckResult, SessionListParameters, SessionListResult, SessionMessageSendResult, SessionObserveResult, SessionResumeResult, SessionShowResult, SessionSpawnResult, SessionStartResult, SessionStopResult, SessionWaitResult } from "@maiaos/sdk";
|
|
2
2
|
import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
|
|
3
|
+
export type WaitSessionInput = {
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
readonly states: readonly string[];
|
|
6
|
+
readonly timeoutMilliseconds: number;
|
|
7
|
+
};
|
|
3
8
|
export type CreateSessionInput = {
|
|
9
|
+
readonly agentId?: SessionCreateParameters["agentId"];
|
|
4
10
|
readonly baseRef?: string;
|
|
5
11
|
readonly commandId?: string;
|
|
6
12
|
readonly connectionId?: string;
|
|
13
|
+
readonly cwd?: string;
|
|
7
14
|
readonly definitionRef?: SessionCreateParameters["definitionRef"];
|
|
15
|
+
readonly effort?: SessionCreateParameters["effort"];
|
|
8
16
|
readonly executor?: SessionCreateParameters["executor"];
|
|
9
17
|
readonly model?: string;
|
|
10
18
|
readonly role?: SessionCreateParameters["role"];
|
|
@@ -57,7 +65,7 @@ export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
|
57
65
|
readonly commandId: string;
|
|
58
66
|
readonly grantedAt: string;
|
|
59
67
|
readonly inputDigest: string;
|
|
60
|
-
readonly operationIds: readonly ("approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.interrupt" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
68
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "events.read" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.register.confirm" | "node.remote.register.preview" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "session.wait" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.cancel" | "turn.interrupt" | "turn.queue.list" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
61
69
|
readonly revision: "1";
|
|
62
70
|
};
|
|
63
71
|
readonly method: "session.agent-permission.confirm";
|
|
@@ -94,7 +102,7 @@ export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
|
94
102
|
readonly inputDigest: string;
|
|
95
103
|
readonly issuedAt: string;
|
|
96
104
|
readonly method: "session.agent-permission.preview";
|
|
97
|
-
readonly operationIds: readonly ("approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.interrupt" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
105
|
+
readonly operationIds: readonly ("agents.change.confirm" | "agents.change.preview" | "agents.list" | "agents.show" | "approval.list" | "approval.respond" | "approval.show" | "connection.capacity.set" | "connection.create" | "connection.detect" | "connection.gateway.create" | "connection.grant.list" | "connection.grant.set.confirm" | "connection.grant.set.preview" | "connection.list" | "connection.login.start" | "connection.models.list" | "connection.pool.list" | "connection.pool.set.confirm" | "connection.pool.set.preview" | "connection.show" | "connection.state.set" | "connection.system.confirm" | "connection.system.preview" | "connection.upkeep.confirm" | "connection.upkeep.preview" | "connection.upkeep.refresh" | "connection.usage.show" | "container.create.confirm" | "container.create.preview" | "container.index.list" | "container.list" | "container.rename.confirm" | "container.rename.preview" | "container.show" | "context.show" | "discovery.sessions.list" | "events.read" | "execution.catalog.get" | "execution.checkpoint.create" | "execution.checkpoint.show" | "execution.command.run" | "execution.file.read" | "execution.placement.create" | "execution.placement.show" | "execution.relocation.apply" | "execution.relocation.plan" | "execution.relocation.reconcile" | "execution.relocation.show" | "execution.worktree.create" | "execution.worktree.import" | "execution.worktree.reconcile" | "execution.worktree.remove.apply" | "execution.worktree.remove.plan" | "execution.worktree.status" | "harness.installed.list" | "hold.list" | "hold.place.confirm" | "hold.place.preview" | "hold.release.confirm" | "hold.release.preview" | "integration.apply.claude-code" | "integration.apply.codex" | "integration.apply.pi-rpc" | "integration.plan.claude-code" | "integration.plan.codex" | "integration.plan.pi-rpc" | "integration.remove.claude-code" | "integration.remove.codex" | "integration.remove.pi-rpc" | "integration.status.claude-code" | "integration.status.codex" | "integration.status.pi-rpc" | "interaction.cancel" | "interaction.create" | "interaction.list" | "interaction.respond" | "interaction.show" | "monitor.bootstrap.create" | "node.remote.install.confirm" | "node.remote.install.preview" | "node.remote.list" | "node.remote.register.confirm" | "node.remote.register.preview" | "node.remote.remove.confirm" | "node.remote.remove.preview" | "node.shutdown" | "node.status" | "port.lease.acquire" | "port.lease.list" | "port.lease.release" | "port.lease.renew" | "presentation.catalog.show" | "presentation.project-list.show" | "presentation.session-list.show" | "presentation.workspace-directory.show" | "project.context.list" | "project.context.record" | "project.context.show" | "project.create.confirm" | "project.create.preview" | "project.guard.confirm" | "project.guard.preview" | "project.guard.show" | "project.list" | "project.register" | "project.rename.confirm" | "project.rename.preview" | "project.show" | "provider.pool.list" | "receipt.get" | "receipt.list" | "reference.resolve" | "routine.create.confirm" | "routine.create.preview" | "routine.disable.confirm" | "routine.disable.preview" | "routine.list" | "routine.pause" | "routine.resume" | "routine.run.confirm" | "routine.run.preview" | "routine.show" | "run.create" | "run.dispatch.settle-terminal" | "run.dispatch.show" | "run.inbox.ack" | "run.inbox.check" | "run.ledger.create" | "run.ledger.list" | "run.ledger.task.dispatch" | "run.ledger.task.list" | "run.ledger.task.settle" | "run.ledger.task.show" | "run.list" | "run.question.cancel" | "run.question.open" | "run.question.reply" | "run.show" | "run.task.list" | "run.task.show" | "runtime.probe" | "session.adopt.confirm" | "session.adopt.preview" | "session.agent-permission.confirm" | "session.agent-permission.preview" | "session.archive" | "session.create" | "session.diff" | "session.events.list" | "session.history.read" | "session.inbox.ack" | "session.inbox.check" | "session.list" | "session.message.send" | "session.observe" | "session.rename" | "session.resume" | "session.show" | "session.spawn" | "session.start" | "session.stop" | "session.wait" | "team-workspace.bootstrap.apply" | "team-workspace.bootstrap.preview" | "terminal.controller.acquire" | "terminal.controller.release" | "terminal.controller.renew" | "terminal.controller.request" | "terminal.controller.request.show" | "terminal.create" | "terminal.events.list" | "terminal.input.write" | "terminal.list" | "terminal.mutation.reconcile" | "terminal.observer.attach" | "terminal.observer.check" | "terminal.observer.detach" | "terminal.observer.resync" | "terminal.read" | "terminal.session.close" | "terminal.session.delete" | "terminal.session.resize" | "terminal.session.restart" | "terminal.session.signal" | "terminal.show" | "turn.cancel" | "turn.interrupt" | "turn.queue.list" | "turn.send" | "turn.show" | "turn.wait" | "voice.managed-turn.confirm" | "voice.managed-turn.preview" | "voice.orchestrator.context.show" | "voice.orchestrator.tool.call" | "voice.pi.relay" | "voice.pi.relay.preview" | "voice.pi.relay.reconcile" | "workspace.context.show" | "workspace.execution.configure" | "workspace.execution.show" | "workspace.list" | "workspace.membership.attach" | "workspace.repository.attach" | "workspace.select" | "workspace.show")[];
|
|
98
106
|
readonly proof: string;
|
|
99
107
|
}>;
|
|
100
108
|
attachSession: (input: import("./attach-client.js").AttachSessionInput) => CliNodeEffect<import("./attach-client.js").SessionAttachStream>;
|
|
@@ -127,6 +135,7 @@ export declare const makeSessionClient: (node: CliNodeOperations) => {
|
|
|
127
135
|
spawnSession: (input: SpawnSessionInput) => CliNodeEffect<SessionSpawnResult>;
|
|
128
136
|
startSession: (input: StartSessionInput) => CliNodeEffect<SessionStartResult>;
|
|
129
137
|
stopSession: (input: StartSessionInput) => CliNodeEffect<SessionStopResult>;
|
|
138
|
+
waitSession: (input: WaitSessionInput) => CliNodeEffect<SessionWaitResult>;
|
|
130
139
|
};
|
|
131
140
|
export {};
|
|
132
141
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/session/client.js
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
import { sessionCreateParametersSchema, sessionEventsListParametersSchema, sessionInboxAckParametersSchema, sessionInboxCheckParametersSchema, sessionListParametersSchema, sessionMessageSendParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionSpawnParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, } from "@maiaos/sdk";
|
|
1
|
+
import { MAX_SESSION_WAIT_MILLISECONDS, sessionCreateParametersSchema, sessionEventsListParametersSchema, sessionInboxAckParametersSchema, sessionInboxCheckParametersSchema, sessionListParametersSchema, sessionMessageSendParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionSpawnParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, sessionWaitParametersSchema, } from "@maiaos/sdk";
|
|
2
2
|
import * as Crypto from "effect/Crypto";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import { makeRelocateClient } from "../execution/index.js";
|
|
5
|
-
import { commandIdentifier, } from "../local-node/index.js";
|
|
5
|
+
import { commandIdentifier, repeatBoundedWait, } from "../local-node/index.js";
|
|
6
6
|
import { makeAgentPermissionCliClient } from "./agent-permission.js";
|
|
7
7
|
import { makeAttachClient } from "./attach-client.js";
|
|
8
8
|
import { makeCodingSessionClient } from "./coding-client.js";
|
|
9
9
|
export const makeSessionClient = (node) => {
|
|
10
10
|
const createSession = (input) => {
|
|
11
|
-
|
|
11
|
+
const { baseRef, commandId: requestedCommandId, ...selection } = input;
|
|
12
|
+
return Effect.flatMap(commandIdentifier(requestedCommandId), (commandId) => {
|
|
12
13
|
return node.runValidatedNodeOperation({
|
|
14
|
+
...selection,
|
|
13
15
|
commandId,
|
|
14
|
-
...(input.connectionId === undefined
|
|
15
|
-
? {}
|
|
16
|
-
: { connectionId: input.connectionId }),
|
|
17
16
|
expectedRevision: "0",
|
|
18
|
-
...(
|
|
19
|
-
? {}
|
|
20
|
-
: { definitionRef: input.definitionRef }),
|
|
21
|
-
...(input.executor === undefined ? {} : { executor: input.executor }),
|
|
22
|
-
...(input.model === undefined ? {} : { model: input.model }),
|
|
23
|
-
...(input.role === undefined ? {} : { role: input.role }),
|
|
24
|
-
...(input.title === undefined ? {} : { title: input.title }),
|
|
25
|
-
workspaceId: input.workspaceId,
|
|
26
|
-
...(input.baseRef === undefined
|
|
27
|
-
? {}
|
|
28
|
-
: { worktree: { baseRef: input.baseRef } }),
|
|
17
|
+
...(baseRef === undefined ? {} : { worktree: { baseRef } }),
|
|
29
18
|
}, sessionCreateParametersSchema, (client, parameters, options) => client.createSession(parameters, options), { commandId });
|
|
30
19
|
});
|
|
31
20
|
};
|
|
@@ -35,6 +24,17 @@ export const makeSessionClient = (node) => {
|
|
|
35
24
|
const showSession = (sessionId) => {
|
|
36
25
|
return node.runValidatedNodeOperation({ sessionId }, sessionShowParametersSchema, (client, parameters, options) => client.showSession(parameters, options));
|
|
37
26
|
};
|
|
27
|
+
const waitSessionOnce = (parameters) => node.runValidatedNodeOperation(parameters, sessionWaitParametersSchema, (client, validated, options) => client.waitSession(validated, options));
|
|
28
|
+
const waitSession = (input) => repeatBoundedWait({
|
|
29
|
+
maxRequestMilliseconds: MAX_SESSION_WAIT_MILLISECONDS,
|
|
30
|
+
once: (waitMilliseconds) => waitSessionOnce({
|
|
31
|
+
sessionId: input.sessionId,
|
|
32
|
+
states: input.states,
|
|
33
|
+
waitMilliseconds,
|
|
34
|
+
}),
|
|
35
|
+
satisfied: (value) => value.satisfied,
|
|
36
|
+
timeoutMilliseconds: input.timeoutMilliseconds,
|
|
37
|
+
});
|
|
38
38
|
const observeSessions = (input) => node.runValidatedNodeOperation(input, sessionObserveParametersSchema, (client, parameters, options) => client.observeSessions(parameters, options));
|
|
39
39
|
const listSessionEvents = (input) => {
|
|
40
40
|
return node.runValidatedNodeOperation(input, sessionEventsListParametersSchema, (client, parameters, options) => client.listSessionEvents(parameters, options));
|
|
@@ -119,6 +119,7 @@ export const makeSessionClient = (node) => {
|
|
|
119
119
|
spawnSession,
|
|
120
120
|
startSession,
|
|
121
121
|
stopSession,
|
|
122
|
+
waitSession,
|
|
122
123
|
...makeRelocateClient(node),
|
|
123
124
|
...makeAgentPermissionCliClient(node),
|
|
124
125
|
...makeCodingSessionClient(node),
|
|
@@ -2,6 +2,7 @@ import { type CommandContext, type CommandEffect } from "../command-line/index.j
|
|
|
2
2
|
export declare const runSessionCreate: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
3
3
|
export declare const runSessionList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
4
4
|
export declare const runSessionShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
|
+
export declare const runSessionWait: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
5
6
|
export declare const runSessionStart: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
6
7
|
export declare const runSessionStop: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
|
7
8
|
export declare const runSessionResume: (tokens: readonly string[], context: CommandContext) => CommandEffect;
|
package/dist/session/commands.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
1
|
+
import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import {
|
|
3
|
+
import { listEach, writeMerged } from "../address-space/index.js";
|
|
4
|
+
import { CliArgumentError, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readPageSize, readWaitTimeoutSeconds, requirePositionals, writeNodeResult, } from "../command-line/index.js";
|
|
5
|
+
import { mergeLists } from "../fleet/index.js";
|
|
4
6
|
import { runSessionTasks, } from "./create-tasks.js";
|
|
5
|
-
import { writeSessionResult } from "./output/index.js";
|
|
7
|
+
import { formatMergedSessions, formatSessionShow, writeSessionResult, } from "./output/index.js";
|
|
8
|
+
const EXIT_DEADLINE = 74;
|
|
6
9
|
const SESSION_CREATE_OPTIONS = new Set([
|
|
10
|
+
"--agent",
|
|
7
11
|
"--base",
|
|
8
12
|
"--command-id",
|
|
9
13
|
"--connection",
|
|
14
|
+
"--cwd",
|
|
15
|
+
"--effort",
|
|
10
16
|
"--executor",
|
|
11
17
|
"--model",
|
|
18
|
+
"--name",
|
|
12
19
|
"--agent-definition",
|
|
13
20
|
"--agent-definition-version",
|
|
14
21
|
"--agent-definition-digest",
|
|
@@ -69,6 +76,24 @@ const requireOneSelection = (input) => {
|
|
|
69
76
|
throw new CliArgumentError("Use one of '--connection', '--executor' or '--agent-definition'.");
|
|
70
77
|
if (input.model !== undefined && input.connectionId === undefined)
|
|
71
78
|
throw new CliArgumentError("Option '--model' needs '--connection' with a gateway connection.");
|
|
79
|
+
requireSupportedEffort(input);
|
|
80
|
+
};
|
|
81
|
+
const requireSupportedEffort = ({ connectionId, effort, executor, }) => {
|
|
82
|
+
if (effort === undefined)
|
|
83
|
+
return;
|
|
84
|
+
if (connectionId === undefined && executor === undefined)
|
|
85
|
+
throw new CliArgumentError("Option '--effort' needs '--connection' or '--executor'.");
|
|
86
|
+
const levels = executor === undefined ? [] : SESSION_EFFORT_LEVELS[executor];
|
|
87
|
+
if (executor !== undefined && !levels.includes(effort))
|
|
88
|
+
throw new CliArgumentError(`Executor ${executor} supports effort ${levels.join(", ")}.`);
|
|
89
|
+
};
|
|
90
|
+
const readEffort = (value) => {
|
|
91
|
+
if (value === undefined)
|
|
92
|
+
return;
|
|
93
|
+
const level = SESSION_EFFORT_LEVELS["codex-cli"].find((candidate) => candidate === value);
|
|
94
|
+
if (level !== undefined)
|
|
95
|
+
return level;
|
|
96
|
+
throw new CliArgumentError(`Option '--effort' must be ${SESSION_EFFORT_LEVELS["codex-cli"].slice(0, -1).join(", ")} or ${SESSION_EFFORT_LEVELS["codex-cli"].at(-1) ?? "ultra"}.`);
|
|
72
97
|
};
|
|
73
98
|
const readSessionRole = (value) => {
|
|
74
99
|
if (value === undefined)
|
|
@@ -77,15 +102,44 @@ const readSessionRole = (value) => {
|
|
|
77
102
|
return { role: value };
|
|
78
103
|
throw new CliArgumentError("Option '--role' must be worker or orchestrator.");
|
|
79
104
|
};
|
|
105
|
+
const AGENT_FIXED_OPTIONS = [
|
|
106
|
+
"--agent-definition",
|
|
107
|
+
"--agent-definition-digest",
|
|
108
|
+
"--agent-definition-version",
|
|
109
|
+
"--connection",
|
|
110
|
+
"--effort",
|
|
111
|
+
"--executor",
|
|
112
|
+
"--model",
|
|
113
|
+
];
|
|
114
|
+
const readAgentId = (options) => {
|
|
115
|
+
const agentId = options.get("--agent");
|
|
116
|
+
if (agentId === undefined)
|
|
117
|
+
return {};
|
|
118
|
+
const clash = AGENT_FIXED_OPTIONS.find((option) => options.has(option));
|
|
119
|
+
if (clash !== undefined)
|
|
120
|
+
throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
|
|
121
|
+
return { agentId };
|
|
122
|
+
};
|
|
123
|
+
const readSessionTitle = (options) => {
|
|
124
|
+
if (options.has("--name") && options.has("--title"))
|
|
125
|
+
throw new CliArgumentError("Use one of '--name' or '--title'.");
|
|
126
|
+
return options.get("--title") ?? options.get("--name");
|
|
127
|
+
};
|
|
80
128
|
const readSessionSelection = (options, workspaceId) => {
|
|
129
|
+
const agent = readAgentId(options);
|
|
81
130
|
const commandId = options.get("--command-id");
|
|
82
131
|
const connectionId = options.get("--connection");
|
|
83
132
|
const executor = readExecutorKind(options.get("--executor"));
|
|
133
|
+
const effort = readEffort(options.get("--effort"));
|
|
134
|
+
const cwd = options.get("--cwd");
|
|
84
135
|
const model = options.get("--model");
|
|
85
|
-
const title = options
|
|
136
|
+
const title = readSessionTitle(options);
|
|
86
137
|
const selection = {
|
|
138
|
+
...agent,
|
|
87
139
|
...(commandId === undefined ? {} : { commandId }),
|
|
88
140
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
141
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
142
|
+
...(effort === undefined ? {} : { effort }),
|
|
89
143
|
...(executor === undefined ? {} : { executor }),
|
|
90
144
|
...(model === undefined ? {} : { model }),
|
|
91
145
|
...readSessionRole(options.get("--role")),
|
|
@@ -98,8 +152,10 @@ const readSessionSelection = (options, workspaceId) => {
|
|
|
98
152
|
const readBaseRef = (value, selection) => {
|
|
99
153
|
if (value === undefined)
|
|
100
154
|
return;
|
|
101
|
-
if (selection.
|
|
102
|
-
|
|
155
|
+
if (selection.agentId === undefined &&
|
|
156
|
+
selection.connectionId === undefined &&
|
|
157
|
+
selection.executor === undefined)
|
|
158
|
+
throw new CliArgumentError("Option '--base' needs '--agent', '--connection' or '--executor'.");
|
|
103
159
|
if (sessionBaseRefSchema.safeParse(value).success)
|
|
104
160
|
return value;
|
|
105
161
|
throw new CliArgumentError("Option '--base' must name a branch, tag or commit without ranges, revision suffixes or a leading dash.");
|
|
@@ -142,8 +198,9 @@ const taskSource = (parsed) => {
|
|
|
142
198
|
const stdin = parsed.flags.has("--prompt-stdin");
|
|
143
199
|
if ([file, message, stdin ? "" : undefined].filter((value) => value !== undefined).length > 1)
|
|
144
200
|
throw new CliArgumentError("Use one of '--message', '--prompt-stdin' or '--from-file'.");
|
|
145
|
-
if (file !== undefined &&
|
|
146
|
-
|
|
201
|
+
if (file !== undefined &&
|
|
202
|
+
(parsed.options.has("--title") || parsed.options.has("--name")))
|
|
203
|
+
throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
|
|
147
204
|
if (file !== undefined)
|
|
148
205
|
return { kind: "file", path: file };
|
|
149
206
|
if (message !== undefined)
|
|
@@ -200,13 +257,34 @@ const readSessionList = (tokens) => {
|
|
|
200
257
|
...(states === undefined ? {} : { states }),
|
|
201
258
|
};
|
|
202
259
|
};
|
|
260
|
+
const writeSessionList = (result, context) => writeSessionResult(result, context, (value) => ({
|
|
261
|
+
command: "session.list",
|
|
262
|
+
result: value,
|
|
263
|
+
}));
|
|
203
264
|
export const runSessionList = (tokens, context) => Effect.gen(function* () {
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
265
|
+
const input = readSessionList(tokens);
|
|
266
|
+
if (input.projectId !== undefined)
|
|
267
|
+
return writeSessionList(yield* context.dependencies.listSessions(input), context);
|
|
268
|
+
return yield* listEach(context, {
|
|
269
|
+
merged: (answers) => writeMergedSessions(context, answers),
|
|
270
|
+
paged: input.afterCursor !== "0",
|
|
271
|
+
read: (dependencies) => dependencies.listSessions(input),
|
|
272
|
+
sole: (result) => writeSessionList(result, context),
|
|
273
|
+
});
|
|
209
274
|
});
|
|
275
|
+
const writeMergedSessions = (context, answers) => {
|
|
276
|
+
const { items, nodes } = mergeLists(answers);
|
|
277
|
+
const attention = answers.flatMap(({ node, result }) => result.ok
|
|
278
|
+
? (result.value.attention ?? []).map((item) => ({ ...item, node }))
|
|
279
|
+
: []);
|
|
280
|
+
const result = {
|
|
281
|
+
...(attention.length === 0 ? {} : { attention }),
|
|
282
|
+
items,
|
|
283
|
+
method: "session.list",
|
|
284
|
+
nodes,
|
|
285
|
+
};
|
|
286
|
+
return writeMerged(context, { command: "session.list", result }, formatMergedSessions);
|
|
287
|
+
};
|
|
210
288
|
export const runSessionShow = (tokens, context) => Effect.gen(function* () {
|
|
211
289
|
const parsed = parseOptions(tokens, new Set());
|
|
212
290
|
requirePositionals(parsed.positionals, 1);
|
|
@@ -220,6 +298,35 @@ export const runSessionShow = (tokens, context) => Effect.gen(function* () {
|
|
|
220
298
|
result: value,
|
|
221
299
|
}));
|
|
222
300
|
});
|
|
301
|
+
const readWaitInput = (tokens) => {
|
|
302
|
+
const parsed = parseOptionsWith(tokens, {
|
|
303
|
+
allowed: new Set(["--timeout", "--until"]),
|
|
304
|
+
allowedFlags: new Set(),
|
|
305
|
+
repeatable: new Set(["--until"]),
|
|
306
|
+
});
|
|
307
|
+
requirePositionals(parsed.positionals, 1);
|
|
308
|
+
const [sessionId] = parsed.positionals;
|
|
309
|
+
const states = parsed.options.get("--until")?.split(",");
|
|
310
|
+
if (sessionId === undefined || states === undefined)
|
|
311
|
+
throw new CliArgumentError("Name the Session and the state or states to wait for with '--until'.");
|
|
312
|
+
return {
|
|
313
|
+
sessionId,
|
|
314
|
+
states,
|
|
315
|
+
timeoutMilliseconds: readWaitTimeoutSeconds(parsed.options.get("--timeout")) * 1000,
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
export const runSessionWait = (tokens, context) => Effect.gen(function* () {
|
|
319
|
+
const input = readWaitInput(tokens);
|
|
320
|
+
const { waitSession } = context.dependencies;
|
|
321
|
+
if (waitSession === undefined)
|
|
322
|
+
throw new CliArgumentError("Session wait is unavailable.");
|
|
323
|
+
const result = yield* waitSession(input);
|
|
324
|
+
const code = writeNodeResult(result, context, {
|
|
325
|
+
toResult: (value) => ({ command: "session.wait", result: value }),
|
|
326
|
+
toText: ({ result: waited }) => formatSessionShow(waited),
|
|
327
|
+
});
|
|
328
|
+
return result.ok && !result.value.satisfied ? EXIT_DEADLINE : code;
|
|
329
|
+
});
|
|
223
330
|
const readLifecycleInput = (parsed) => {
|
|
224
331
|
const sessionId = parsed.positionals[0];
|
|
225
332
|
if (sessionId === undefined) {
|
|
@@ -21,19 +21,24 @@ const readText = (source, context) => {
|
|
|
21
21
|
const refusalMessage = (refusal) => refusal.reason === "too_long"
|
|
22
22
|
? `Task line ${String(refusal.line)} exceeds ${String(MAX_TURN_INPUT_BYTES)} bytes.`
|
|
23
23
|
: `A batch holds at most ${String(MAX_SESSION_CREATION_TASKS)} tasks; line ${String(refusal.line)} is beyond it.`;
|
|
24
|
+
const toTemplate = (selection) => {
|
|
25
|
+
const { agentId, baseRef, connectionId, effort, executor, model, role, title, } = selection;
|
|
26
|
+
return {
|
|
27
|
+
...(agentId === undefined ? {} : { agentId }),
|
|
28
|
+
...(connectionId === undefined ? {} : { connectionId }),
|
|
29
|
+
...(effort === undefined ? {} : { effort }),
|
|
30
|
+
...(executor === undefined ? {} : { executor }),
|
|
31
|
+
...(model === undefined ? {} : { model }),
|
|
32
|
+
...(role === undefined ? {} : { role }),
|
|
33
|
+
...(title === undefined ? {} : { title }),
|
|
34
|
+
...(baseRef === undefined ? {} : { worktree: { baseRef } }),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
24
37
|
const toInput = (request, text) => {
|
|
25
|
-
const {
|
|
26
|
-
const { projectId, source, workspaceId } = request;
|
|
38
|
+
const { projectId, selection, source, workspaceId } = request;
|
|
27
39
|
return {
|
|
28
40
|
...(projectId === undefined ? {} : { projectId }),
|
|
29
|
-
session:
|
|
30
|
-
...(connectionId === undefined ? {} : { connectionId }),
|
|
31
|
-
...(executor === undefined ? {} : { executor }),
|
|
32
|
-
...(model === undefined ? {} : { model }),
|
|
33
|
-
...(role === undefined ? {} : { role }),
|
|
34
|
-
...(title === undefined ? {} : { title }),
|
|
35
|
-
...(baseRef === undefined ? {} : { worktree: { baseRef } }),
|
|
36
|
-
},
|
|
41
|
+
session: toTemplate(selection),
|
|
37
42
|
split: source.kind === "file" ? "lines" : "whole",
|
|
38
43
|
text,
|
|
39
44
|
...(workspaceId === undefined ? {} : { workspaceId }),
|
|
@@ -79,13 +84,26 @@ const exitCode = (items) => {
|
|
|
79
84
|
? 0
|
|
80
85
|
: EXIT_REFUSED;
|
|
81
86
|
};
|
|
87
|
+
const batchError = (items) => {
|
|
88
|
+
const failed = items.find((item) => item.error !== undefined);
|
|
89
|
+
if (failed?.error === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
const { code, failure, kind, operationId, retryable } = failed.error;
|
|
92
|
+
return {
|
|
93
|
+
code: failure?.code ?? code ?? kind,
|
|
94
|
+
message: failure?.message ??
|
|
95
|
+
`Line ${String(failed.line)} stopped at ${operationId}: ${code ?? kind}.`,
|
|
96
|
+
retryable,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
82
99
|
const writeBatch = (plan, outcomes, context) => {
|
|
83
100
|
const items = outcomes.map((outcome) => reportItem(plan, outcome));
|
|
84
101
|
const code = exitCode(items);
|
|
102
|
+
const error = batchError(items);
|
|
85
103
|
writeSuccess({
|
|
86
104
|
command: "session.create.tasks",
|
|
87
105
|
result: { items, workspaceId: plan.workspaceId },
|
|
88
|
-
}, { ...context, ok: code === 0 }, ({ result }) => formatSessionTasks(result));
|
|
106
|
+
}, { ...context, ...(error === undefined ? {} : { error }), ok: code === 0 }, ({ result }) => formatSessionTasks(result));
|
|
89
107
|
return code;
|
|
90
108
|
};
|
|
91
109
|
export const runSessionTasks = (request, context) => Effect.gen(function* () {
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { runAgentPermissionSet } from "./agent-permission.js";
|
|
2
2
|
export { runSessionAttach } from "./attach.js";
|
|
3
|
-
export type
|
|
3
|
+
export { type AttachSessionInput, makeAttachClient, type SessionAttachStream, } from "./attach-client.js";
|
|
4
4
|
export { type CreateSessionInput, type ListSessionsInput, makeSessionClient, type StartSessionInput, } from "./client.js";
|
|
5
5
|
export { type ArchiveSessionInput, type DiffSessionInput, } from "./coding-client.js";
|
|
6
6
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
|
7
|
-
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
|
|
7
|
+
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
|
|
8
8
|
export { runSessionRename } from "./rename.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/session/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { runAgentPermissionSet } from "./agent-permission.js";
|
|
2
2
|
export { runSessionAttach } from "./attach.js";
|
|
3
|
+
export { makeAttachClient, } from "./attach-client.js";
|
|
3
4
|
export { makeSessionClient, } from "./client.js";
|
|
4
5
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
|
5
|
-
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
|
|
6
|
+
export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
|
|
6
7
|
export { runSessionRename } from "./rename.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsonLine } from "../../../command-line/index.js";
|
|
1
2
|
export const isInteractionResult = (result) => result.command.startsWith("interaction.");
|
|
2
|
-
export const formatInteractionResult = ({ result, }) => `Recorded only; does not authorize any operation.\n${
|
|
3
|
+
export const formatInteractionResult = ({ result, }) => `Recorded only; does not authorize any operation.\n${jsonLine(result)}`;
|
|
3
4
|
//# sourceMappingURL=format.js.map
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const point = character.codePointAt(0) ?? 0;
|
|
3
|
-
return ((point <= 31 && point !== 9 && point !== 10) ||
|
|
4
|
-
(point >= 127 && point <= 159) ||
|
|
5
|
-
point === 8232 ||
|
|
6
|
-
point === 8233);
|
|
7
|
-
};
|
|
8
|
-
const safeText = (value) => Array.from(value, (character) => isUnsafeControl(character) ? "�" : character).join("");
|
|
1
|
+
import { block, cell } from "../../command-line/index.js";
|
|
9
2
|
const counts = (file) => file.insertions === undefined || file.deletions === undefined
|
|
10
3
|
? "binary"
|
|
11
4
|
: `+${String(file.insertions)}\t-${String(file.deletions)}`;
|
|
12
5
|
const fileLine = (file) => [
|
|
13
6
|
file.status,
|
|
14
7
|
counts(file),
|
|
15
|
-
|
|
8
|
+
cell(file.previousPath === undefined
|
|
16
9
|
? file.path
|
|
17
10
|
: `${file.previousPath} -> ${file.path}`),
|
|
18
11
|
].join("\t");
|
|
@@ -24,7 +17,7 @@ export const formatSessionDiff = (result) => {
|
|
|
24
17
|
];
|
|
25
18
|
const patch = result.patch === undefined
|
|
26
19
|
? ""
|
|
27
|
-
: `${
|
|
20
|
+
: `${block(result.patch)}${result.patchTruncated === true ? "[patch truncated]\n" : ""}`;
|
|
28
21
|
return `${lines.join("\n")}\n${patch}`;
|
|
29
22
|
};
|
|
30
23
|
//# sourceMappingURL=diff.js.map
|