@maiaos/cli 0.1.0-canary.4 → 0.1.0-canary.40
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 +2 -2
- package/dist/agents/client.d.ts +47 -27
- package/dist/agents/client.js +10 -3
- package/dist/agents/commands.d.ts +1 -0
- package/dist/agents/commands.js +24 -2
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/agents/input.d.ts +3 -1
- package/dist/agents/input.js +6 -0
- package/dist/agents/output/format.d.ts +2 -2
- package/dist/agents/output/format.js +11 -0
- package/dist/agents/tree/tree.js +13 -1
- package/dist/bin/maia.cdx.json +19 -19
- package/dist/bin/maia.mjs +1 -1
- package/dist/bootstrap/run.js +5 -2
- package/dist/cli/cli.d.ts +8 -2
- package/dist/cli/cli.js +19 -6
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/command-line/context.d.ts +1 -0
- package/dist/command-line/index.d.ts +2 -2
- package/dist/command-line/index.js +2 -2
- 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 +1 -1
- package/dist/command-line/input/index.js +1 -1
- package/dist/command-line/rows.d.ts +1 -0
- package/dist/command-line/rows.js +3 -0
- package/dist/command-receipt/command.js +1 -1
- package/dist/connection/input.js +2 -2
- package/dist/connection/system.js +3 -2
- package/dist/connection/tree/tree.js +5 -5
- package/dist/local-node/client.d.ts +1 -0
- package/dist/local-node/client.js +1 -0
- package/dist/local-node/index.d.ts +2 -1
- package/dist/local-node/index.js +2 -1
- package/dist/local-node/wait.d.ts +10 -0
- package/dist/local-node/wait.js +17 -0
- package/dist/login/gateway.js +2 -2
- package/dist/login/vendor-input.js +2 -2
- package/dist/mcp/calls.js +6 -1
- package/dist/mcp/routing.js +1 -0
- package/dist/project-guard/client.d.ts +12 -0
- package/dist/project-guard/input.d.ts +3 -0
- package/dist/project-guard/input.js +15 -1
- package/dist/project-guard/output/format.js +5 -0
- package/dist/project-workspace/tree/tree.js +1 -1
- package/dist/reference/resolve.js +9 -2
- package/dist/remote-node/connector.js +8 -1
- package/dist/session/agent-permission.d.ts +2 -2
- package/dist/session/approval/client.d.ts +5 -2
- package/dist/session/approval/client.js +2 -2
- package/dist/session/approval/commands.js +29 -15
- package/dist/session/client.d.ts +12 -3
- package/dist/session/client.js +14 -2
- package/dist/session/commands.d.ts +1 -0
- package/dist/session/commands.js +87 -9
- package/dist/session/create-tasks.js +4 -1
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/output/human.d.ts +2 -0
- package/dist/session/output/human.js +6 -3
- package/dist/session/output/index.d.ts +1 -1
- package/dist/session/output/index.js +1 -1
- package/dist/session/output/tasks.js +9 -1
- package/dist/session/tree/tree.js +22 -11
- package/dist/session/turn/client.js +7 -9
- package/dist/session/turn/commands.js +67 -20
- package/dist/session/turn/output.d.ts +6 -0
- package/dist/session/turn/output.js +8 -1
- package/dist/status/client.d.ts +14 -3
- package/dist/status/command.js +3 -1
- package/dist/status/doctor.d.ts +5 -1
- package/dist/status/doctor.js +10 -4
- package/dist/status/output/compact.d.ts +3 -0
- package/dist/status/output/compact.js +17 -7
- package/dist/status/output/human.js +15 -0
- package/dist/terminal/control-commands.js +26 -9
- package/dist/terminal/keys.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 +3 -0
- package/dist/terminal/output/human.js +2 -2
- package/dist/terminal/tree/tree.js +1 -1
- package/guidance/maia-cli/SKILL.md +1 -1
- package/guidance/maia-node/SKILL.md +54 -0
- package/guidance/maia-orchestration/SKILL.md +1 -2
- package/guidance/maia-sessions/SKILL.md +69 -0
- package/package.json +4 -4
package/dist/session/commands.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
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
3
|
import { listEach, writeMerged } from "../address-space/index.js";
|
|
4
|
-
import { CliArgumentError, parseOptions, readCursor, readDuration, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
|
|
4
|
+
import { CliArgumentError, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readPageSize, readWaitTimeoutSeconds, requirePositionals, writeNodeResult, } from "../command-line/index.js";
|
|
5
5
|
import { mergeLists } from "../fleet/index.js";
|
|
6
6
|
import { runSessionTasks, } from "./create-tasks.js";
|
|
7
|
-
import { formatMergedSessions, writeSessionResult } from "./output/index.js";
|
|
7
|
+
import { formatMergedSessions, formatSessionShow, writeSessionResult, } from "./output/index.js";
|
|
8
|
+
const EXIT_DEADLINE = 74;
|
|
8
9
|
const SESSION_CREATE_OPTIONS = new Set([
|
|
9
10
|
"--agent",
|
|
10
11
|
"--base",
|
|
11
12
|
"--command-id",
|
|
12
13
|
"--connection",
|
|
14
|
+
"--cwd",
|
|
13
15
|
"--effort",
|
|
14
16
|
"--executor",
|
|
15
17
|
"--model",
|
|
18
|
+
"--name",
|
|
19
|
+
"--permission",
|
|
16
20
|
"--agent-definition",
|
|
17
21
|
"--agent-definition-version",
|
|
18
22
|
"--agent-definition-digest",
|
|
@@ -20,6 +24,9 @@ const SESSION_CREATE_OPTIONS = new Set([
|
|
|
20
24
|
"--title",
|
|
21
25
|
]);
|
|
22
26
|
const summarizeSessionCreation = (result) => ({
|
|
27
|
+
...(result.session.containment === undefined
|
|
28
|
+
? {}
|
|
29
|
+
: { containment: result.session.containment }),
|
|
23
30
|
...(result.session.agentDefinitionRef === undefined
|
|
24
31
|
? {}
|
|
25
32
|
: { agentDefinitionRef: result.session.agentDefinitionRef }),
|
|
@@ -62,7 +69,7 @@ const readSessionCreateOptions = (parsed) => {
|
|
|
62
69
|
throw new CliArgumentError(parsed.options.has("--project")
|
|
63
70
|
? "Option '--project' needs '--message', '--prompt-stdin' or '--from-file'; name a Workspace with '--workspace' otherwise."
|
|
64
71
|
: "Option '--workspace' is required.");
|
|
65
|
-
const input = readSessionSelection(parsed
|
|
72
|
+
const input = readSessionSelection(parsed, workspaceId);
|
|
66
73
|
const definition = readDefinitionSelection(parsed.options, input);
|
|
67
74
|
requireOneSelection({ ...input, ...definition });
|
|
68
75
|
return { ...input, ...definition };
|
|
@@ -117,28 +124,69 @@ const readAgentId = (options) => {
|
|
|
117
124
|
throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
|
|
118
125
|
return { agentId };
|
|
119
126
|
};
|
|
120
|
-
const
|
|
127
|
+
const readSessionTitle = (options) => {
|
|
128
|
+
if (options.has("--name") && options.has("--title"))
|
|
129
|
+
throw new CliArgumentError("Use one of '--name' or '--title'.");
|
|
130
|
+
return options.get("--title") ?? options.get("--name");
|
|
131
|
+
};
|
|
132
|
+
const readSessionSelection = ({ flags, options }, workspaceId) => {
|
|
121
133
|
const agent = readAgentId(options);
|
|
122
134
|
const commandId = options.get("--command-id");
|
|
123
135
|
const connectionId = options.get("--connection");
|
|
124
136
|
const executor = readExecutorKind(options.get("--executor"));
|
|
125
137
|
const effort = readEffort(options.get("--effort"));
|
|
138
|
+
const cwd = options.get("--cwd");
|
|
126
139
|
const model = options.get("--model");
|
|
127
|
-
const title = options
|
|
140
|
+
const title = readSessionTitle(options);
|
|
128
141
|
const selection = {
|
|
129
142
|
...agent,
|
|
130
143
|
...(commandId === undefined ? {} : { commandId }),
|
|
131
144
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
145
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
132
146
|
...(effort === undefined ? {} : { effort }),
|
|
133
147
|
...(executor === undefined ? {} : { executor }),
|
|
134
148
|
...(model === undefined ? {} : { model }),
|
|
135
149
|
...readSessionRole(options.get("--role")),
|
|
136
150
|
...(title === undefined ? {} : { title }),
|
|
151
|
+
...readHostAuthority({ flags, options }),
|
|
137
152
|
workspaceId,
|
|
138
153
|
};
|
|
139
154
|
const baseRef = readBaseRef(options.get("--base"), selection);
|
|
140
155
|
return { ...selection, ...(baseRef === undefined ? {} : { baseRef }) };
|
|
141
156
|
};
|
|
157
|
+
const readPermission = (permission, executor) => {
|
|
158
|
+
if (permission === undefined)
|
|
159
|
+
return {};
|
|
160
|
+
const valid = sessionCreateParametersSchema.safeParse({
|
|
161
|
+
commandId: "command_validate",
|
|
162
|
+
...(executor === undefined
|
|
163
|
+
? { connectionId: "connection_validate" }
|
|
164
|
+
: { executor }),
|
|
165
|
+
expectedRevision: "0",
|
|
166
|
+
hostAuthority: true,
|
|
167
|
+
permission,
|
|
168
|
+
workspaceId: "workspace_validate",
|
|
169
|
+
});
|
|
170
|
+
if (!valid.success || valid.data.permission === undefined)
|
|
171
|
+
throw new CliArgumentError("Option '--permission' must be a permission mode Claude Code or Codex defines.");
|
|
172
|
+
return { permission: valid.data.permission };
|
|
173
|
+
};
|
|
174
|
+
const readHostAuthority = ({ flags, options, }) => {
|
|
175
|
+
const permission = options.get("--permission");
|
|
176
|
+
if (!flags.has("--host-authority")) {
|
|
177
|
+
if (permission !== undefined)
|
|
178
|
+
throw new CliArgumentError("Option '--permission' needs '--host-authority'.");
|
|
179
|
+
return {};
|
|
180
|
+
}
|
|
181
|
+
if (options.has("--base"))
|
|
182
|
+
throw new CliArgumentError("Option '--host-authority' runs in an existing '--cwd', not a Maia worktree; drop '--base'.");
|
|
183
|
+
if (!options.has("--connection") && !options.has("--executor"))
|
|
184
|
+
throw new CliArgumentError("Option '--host-authority' needs '--connection' or '--executor'.");
|
|
185
|
+
return {
|
|
186
|
+
hostAuthority: true,
|
|
187
|
+
...readPermission(permission, readExecutorKind(options.get("--executor"))),
|
|
188
|
+
};
|
|
189
|
+
};
|
|
142
190
|
const readBaseRef = (value, selection) => {
|
|
143
191
|
if (value === undefined)
|
|
144
192
|
return;
|
|
@@ -188,8 +236,9 @@ const taskSource = (parsed) => {
|
|
|
188
236
|
const stdin = parsed.flags.has("--prompt-stdin");
|
|
189
237
|
if ([file, message, stdin ? "" : undefined].filter((value) => value !== undefined).length > 1)
|
|
190
238
|
throw new CliArgumentError("Use one of '--message', '--prompt-stdin' or '--from-file'.");
|
|
191
|
-
if (file !== undefined &&
|
|
192
|
-
|
|
239
|
+
if (file !== undefined &&
|
|
240
|
+
(parsed.options.has("--title") || parsed.options.has("--name")))
|
|
241
|
+
throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
|
|
193
242
|
if (file !== undefined)
|
|
194
243
|
return { kind: "file", path: file };
|
|
195
244
|
if (message !== undefined)
|
|
@@ -211,7 +260,7 @@ const readSessionTasks = (parsed, source) => {
|
|
|
211
260
|
const workspaceId = readTaskWorkspace(parsed, source);
|
|
212
261
|
const projectId = parsed.options.get("--project");
|
|
213
262
|
const commandId = parsed.options.get("--command-id");
|
|
214
|
-
const { workspaceId: _placeholder, ...selection } = readSessionSelection(parsed
|
|
263
|
+
const { workspaceId: _placeholder, ...selection } = readSessionSelection(parsed, workspaceId ?? "workspace_default");
|
|
215
264
|
requireOneSelection({ ...selection, workspaceId: _placeholder });
|
|
216
265
|
return {
|
|
217
266
|
...(commandId === undefined ? {} : { commandId }),
|
|
@@ -222,7 +271,7 @@ const readSessionTasks = (parsed, source) => {
|
|
|
222
271
|
};
|
|
223
272
|
};
|
|
224
273
|
export const runSessionCreate = (tokens, context) => {
|
|
225
|
-
const parsed = parseOptions(tokens, TASK_OPTIONS, new Set(["--prompt-stdin"]));
|
|
274
|
+
const parsed = parseOptions(tokens, TASK_OPTIONS, new Set(["--host-authority", "--prompt-stdin"]));
|
|
226
275
|
const source = taskSource(parsed);
|
|
227
276
|
if (source !== undefined)
|
|
228
277
|
return runSessionTasks(readSessionTasks(parsed, source), context);
|
|
@@ -287,6 +336,35 @@ export const runSessionShow = (tokens, context) => Effect.gen(function* () {
|
|
|
287
336
|
result: value,
|
|
288
337
|
}));
|
|
289
338
|
});
|
|
339
|
+
const readWaitInput = (tokens) => {
|
|
340
|
+
const parsed = parseOptionsWith(tokens, {
|
|
341
|
+
allowed: new Set(["--timeout", "--until"]),
|
|
342
|
+
allowedFlags: new Set(),
|
|
343
|
+
repeatable: new Set(["--until"]),
|
|
344
|
+
});
|
|
345
|
+
requirePositionals(parsed.positionals, 1);
|
|
346
|
+
const [sessionId] = parsed.positionals;
|
|
347
|
+
const states = parsed.options.get("--until")?.split(",");
|
|
348
|
+
if (sessionId === undefined || states === undefined)
|
|
349
|
+
throw new CliArgumentError("Name the Session and the state or states to wait for with '--until'.");
|
|
350
|
+
return {
|
|
351
|
+
sessionId,
|
|
352
|
+
states,
|
|
353
|
+
timeoutMilliseconds: readWaitTimeoutSeconds(parsed.options.get("--timeout")) * 1000,
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
export const runSessionWait = (tokens, context) => Effect.gen(function* () {
|
|
357
|
+
const input = readWaitInput(tokens);
|
|
358
|
+
const { waitSession } = context.dependencies;
|
|
359
|
+
if (waitSession === undefined)
|
|
360
|
+
throw new CliArgumentError("Session wait is unavailable.");
|
|
361
|
+
const result = yield* waitSession(input);
|
|
362
|
+
const code = writeNodeResult(result, context, {
|
|
363
|
+
toResult: (value) => ({ command: "session.wait", result: value }),
|
|
364
|
+
toText: ({ result: waited }) => formatSessionShow(waited),
|
|
365
|
+
});
|
|
366
|
+
return result.ok && !result.value.satisfied ? EXIT_DEADLINE : code;
|
|
367
|
+
});
|
|
290
368
|
const readLifecycleInput = (parsed) => {
|
|
291
369
|
const sessionId = parsed.positionals[0];
|
|
292
370
|
if (sessionId === undefined) {
|
|
@@ -22,13 +22,16 @@ 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
24
|
const toTemplate = (selection) => {
|
|
25
|
-
const { agentId, baseRef, connectionId, effort, executor, model, role, title, } = selection;
|
|
25
|
+
const { agentId, baseRef, connectionId, cwd, effort, executor, hostAuthority, model, permission, role, title, } = selection;
|
|
26
26
|
return {
|
|
27
27
|
...(agentId === undefined ? {} : { agentId }),
|
|
28
28
|
...(connectionId === undefined ? {} : { connectionId }),
|
|
29
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
29
30
|
...(effort === undefined ? {} : { effort }),
|
|
30
31
|
...(executor === undefined ? {} : { executor }),
|
|
32
|
+
...(hostAuthority === undefined ? {} : { hostAuthority }),
|
|
31
33
|
...(model === undefined ? {} : { model }),
|
|
34
|
+
...(permission === undefined ? {} : { permission }),
|
|
32
35
|
...(role === undefined ? {} : { role }),
|
|
33
36
|
...(title === undefined ? {} : { title }),
|
|
34
37
|
...(baseRef === undefined ? {} : { worktree: { baseRef } }),
|
package/dist/session/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { type AttachSessionInput, makeAttachClient, type SessionAttachStream, }
|
|
|
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
|
@@ -3,6 +3,6 @@ export { runSessionAttach } from "./attach.js";
|
|
|
3
3
|
export { makeAttachClient, } from "./attach-client.js";
|
|
4
4
|
export { makeSessionClient, } from "./client.js";
|
|
5
5
|
export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
|
|
6
|
-
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";
|
|
7
7
|
export { runSessionRename } from "./rename.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -30,6 +30,7 @@ export type CliSessionResult = {
|
|
|
30
30
|
} | {
|
|
31
31
|
readonly command: "session.create";
|
|
32
32
|
readonly result: {
|
|
33
|
+
readonly containment?: SessionCreateResult["session"]["containment"];
|
|
33
34
|
readonly delivery: SessionCreateResult["delivery"];
|
|
34
35
|
readonly executor?: SessionCreateResult["session"]["executor"];
|
|
35
36
|
readonly receipt: SessionCreateResult["receipt"];
|
|
@@ -103,6 +104,7 @@ export type CliSessionResult = {
|
|
|
103
104
|
readonly command: "session.show";
|
|
104
105
|
readonly result: SessionShowResult;
|
|
105
106
|
};
|
|
107
|
+
export declare const formatSessionShow: ({ session, }: Pick<SessionShowResult, "session">) => string;
|
|
106
108
|
export declare const formatSessionResult: (result: CliSessionResult) => string;
|
|
107
109
|
export declare const writeSessionResult: <TValue>(result: CliNodeResult<TValue>, context: {
|
|
108
110
|
readonly io: CliIo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cell, fields, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
|
|
1
|
+
import { cell, fields, formatRows, tab, withPrunedHistory, writeNodeResult, } from "../../command-line/index.js";
|
|
2
2
|
import { formatSessionDiff } from "./diff.js";
|
|
3
3
|
import { formatFailure, formatSessionEvents } from "./failure.js";
|
|
4
4
|
import { formatSessionObservation } from "./observe.js";
|
|
@@ -7,6 +7,7 @@ const formatSessionInbox = (deliveries) => formatRows(deliveries, (delivery) =>
|
|
|
7
7
|
const formatSessionCreation = (result) => `${fields([
|
|
8
8
|
["session", result.sessionId],
|
|
9
9
|
["account", result.executor?.connectionId],
|
|
10
|
+
["containment", result.containment],
|
|
10
11
|
[
|
|
11
12
|
"workspace",
|
|
12
13
|
result.worktree === undefined ? undefined : result.workspaceId,
|
|
@@ -31,11 +32,12 @@ const formatCodingSession = (result) => {
|
|
|
31
32
|
const formatAgentPermission = (result) => result.command === "session.agent-permission.preview"
|
|
32
33
|
? `${result.result.sessionId}\t${result.result.expiresAt}\n`
|
|
33
34
|
: `${result.result.receipt.receiptId}\t${result.result.delivery}\n`;
|
|
34
|
-
const formatSessionShow = ({ session, }) => `${fields([
|
|
35
|
+
export const formatSessionShow = ({ session, }) => `${fields([
|
|
35
36
|
["session", session.id],
|
|
36
37
|
["state", session.state],
|
|
37
38
|
["revision", session.revision],
|
|
38
39
|
["workspace", session.workspaceId],
|
|
40
|
+
["containment", session.containment],
|
|
39
41
|
])}${formatFailure(session.failure)}`;
|
|
40
42
|
const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
|
|
41
43
|
["session", sessionId],
|
|
@@ -45,6 +47,7 @@ const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
|
|
|
45
47
|
const formatSessions = (result) => result.items.length === 0 ? "No Sessions.\n" : formatSessionList(result);
|
|
46
48
|
const formatInboxAck = ({ delivery, deliveryRecord, mailboxRevision, }) => `${tab([deliveryRecord.deliveryId, delivery, mailboxRevision])}\n`;
|
|
47
49
|
const formatMessageSend = ({ delivery, deliveryId, sequence, }) => `${tab([deliveryId, delivery, sequence])}\n`;
|
|
50
|
+
const formatEventsPage = ({ items, oldestRetainedCursor, }) => withPrunedHistory(formatSessionEvents(items), oldestRetainedCursor);
|
|
48
51
|
export const formatSessionResult = (result) => {
|
|
49
52
|
switch (result.command) {
|
|
50
53
|
case "session.agent-permission.confirm":
|
|
@@ -56,7 +59,7 @@ export const formatSessionResult = (result) => {
|
|
|
56
59
|
case "session.diff":
|
|
57
60
|
return formatCodingSession(result);
|
|
58
61
|
case "session.events.list":
|
|
59
|
-
return
|
|
62
|
+
return formatEventsPage(result.result);
|
|
60
63
|
case "session.inbox.ack":
|
|
61
64
|
return formatInboxAck(result.result);
|
|
62
65
|
case "session.inbox.check":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { formatSessionDiff } from "./diff.js";
|
|
2
2
|
export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
|
|
3
|
-
export { type CliSessionResult, formatSessionResult, writeSessionResult, } from "./human.js";
|
|
3
|
+
export { type CliSessionResult, formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
|
|
4
4
|
export { formatSessionObservation } from "./observe.js";
|
|
5
5
|
export { type CliSessionList, type CliSessionTaskItem, type CliSessionTasksResult, formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { formatSessionDiff } from "./diff.js";
|
|
2
2
|
export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
|
|
3
|
-
export { formatSessionResult, writeSessionResult, } from "./human.js";
|
|
3
|
+
export { formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
|
|
4
4
|
export { formatSessionObservation } from "./observe.js";
|
|
5
5
|
export { formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -25,12 +25,20 @@ export const formatSessionTasks = ({ items }) => items.length === 1
|
|
|
25
25
|
empty: "",
|
|
26
26
|
headers: ["LINE", "STAGE", "SESSION", "TURN", "COMMAND", "ERROR"],
|
|
27
27
|
});
|
|
28
|
-
const SESSION_HEADERS = [
|
|
28
|
+
const SESSION_HEADERS = [
|
|
29
|
+
"SESSION",
|
|
30
|
+
"STATE",
|
|
31
|
+
"WORKSPACE",
|
|
32
|
+
"ATTENTION",
|
|
33
|
+
"CONTAINMENT",
|
|
34
|
+
"TITLE",
|
|
35
|
+
];
|
|
29
36
|
const sessionCells = (session, attention) => [
|
|
30
37
|
session.id,
|
|
31
38
|
session.state,
|
|
32
39
|
session.workspaceId,
|
|
33
40
|
attention ?? "-",
|
|
41
|
+
session.containment ?? "-",
|
|
34
42
|
cell(session.title ?? "-"),
|
|
35
43
|
];
|
|
36
44
|
export const formatSessionList = (result) => {
|
|
@@ -18,7 +18,7 @@ export const SESSION_TREE = {
|
|
|
18
18
|
],
|
|
19
19
|
leaves: [
|
|
20
20
|
[
|
|
21
|
-
"session create (--workspace <workspace-id> | --project <project-id>) [--command-id <id>] [--role <worker|orchestrator>] [--connection <connection-id> [--executor <codex-cli|claude-code>] [--model <id>] | --executor <codex-cli|claude-code> | --agent <agent-id> | --agent-definition <key> --agent-definition-version <version> --agent-definition-digest <sha256>] [--effort <low|medium|high|xhigh|max|ultra>] [--base <branch-tag-or-commit>] [--title <text>] [--message <text> | --prompt-stdin | --from-file <path>]",
|
|
21
|
+
"session create (--workspace <workspace-id> | --project <project-id>) [--command-id <id>] [--role <worker|orchestrator>] [--connection <connection-id> [--executor <codex-cli|claude-code>] [--model <id>] | --executor <codex-cli|claude-code> | --agent <agent-id> | --agent-definition <key> --agent-definition-version <version> --agent-definition-digest <sha256>] [--effort <low|medium|high|xhigh|max|ultra>] [--base <branch-tag-or-commit> | --host-authority [--permission <mode>]] [--cwd <path>] [--title <text> | --name <text>] [--message <text> | --prompt-stdin | --from-file <path>]",
|
|
22
22
|
0,
|
|
23
23
|
"session.create",
|
|
24
24
|
"Create a Session, optionally starting it with a first message.",
|
|
@@ -50,6 +50,17 @@ export const SESSION_TREE = {
|
|
|
50
50
|
run: [session, "runSessionShow"],
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
|
+
[
|
|
54
|
+
"session wait <session-id> --until <state>[,<state>...] [--timeout <duration>]",
|
|
55
|
+
1,
|
|
56
|
+
"session.wait",
|
|
57
|
+
"Wait until a Session reaches one of the states; exits 74 on timeout.",
|
|
58
|
+
{
|
|
59
|
+
example: "maia --json session wait session_1 --until idle --until failed --timeout 10m",
|
|
60
|
+
route: "<session-id>",
|
|
61
|
+
run: [session, "runSessionWait"],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
53
64
|
[
|
|
54
65
|
"session rename <session-id> --title <text> --expected-revision <revision> [--command-id <id>]",
|
|
55
66
|
1,
|
|
@@ -190,12 +201,12 @@ export const SESSION_TREE = {
|
|
|
190
201
|
{ run: [session, "runSessionInboxAck"] },
|
|
191
202
|
],
|
|
192
203
|
[
|
|
193
|
-
"session turn send --session <session-id> --prompt-stdin --expected-revision <revision> [--command-id <id>]",
|
|
204
|
+
"session turn send --session <session-id> --prompt-stdin --expected-revision <revision> [--wait] [--command-id <id>]",
|
|
194
205
|
1,
|
|
195
206
|
"turn.send",
|
|
196
|
-
"Send a turn from stdin; it queues
|
|
207
|
+
"Send a turn from stdin; it queues. --wait returns once it is done.",
|
|
197
208
|
{
|
|
198
|
-
example: "printf %s 'Explain the build' | maia --json session turn send --session session_1 --prompt-stdin --expected-revision 2 --command-id send-1",
|
|
209
|
+
example: "printf %s 'Explain the build' | maia --json session turn send --session session_1 --prompt-stdin --expected-revision 2 --wait --command-id send-1",
|
|
199
210
|
route: "--session",
|
|
200
211
|
run: [turn, "runTurnSend"],
|
|
201
212
|
},
|
|
@@ -223,13 +234,13 @@ export const SESSION_TREE = {
|
|
|
223
234
|
},
|
|
224
235
|
],
|
|
225
236
|
[
|
|
226
|
-
"session turn show <turn-id> [--include-content]",
|
|
237
|
+
"session turn show (<turn-id> | --session <session-id> --latest) [--include-content]",
|
|
227
238
|
1,
|
|
228
239
|
"turn.show",
|
|
229
|
-
"Show
|
|
240
|
+
"Show a turn or a Session's latest turn; --include-content adds its text.",
|
|
230
241
|
{
|
|
231
|
-
example: "maia --json session turn show
|
|
232
|
-
route: "<turn-id>",
|
|
242
|
+
example: "maia --json session turn show --session session_1 --latest --include-content",
|
|
243
|
+
route: ["<turn-id>", "--session"],
|
|
233
244
|
run: [turn, "runTurnShow"],
|
|
234
245
|
},
|
|
235
246
|
],
|
|
@@ -274,7 +285,7 @@ export const SESSION_TREE = {
|
|
|
274
285
|
{ route: "<approval-id>", run: [approval, "runApprovalShow"] },
|
|
275
286
|
],
|
|
276
287
|
[
|
|
277
|
-
"session approval approve <approval-id> [--for-session] [--command-id <id>]",
|
|
288
|
+
"session approval approve <approval-id> [--for-session] [--as-coordinator] [--command-id <id>]",
|
|
278
289
|
1,
|
|
279
290
|
"approval.respond",
|
|
280
291
|
"Approve a worker's request.",
|
|
@@ -286,7 +297,7 @@ export const SESSION_TREE = {
|
|
|
286
297
|
},
|
|
287
298
|
],
|
|
288
299
|
[
|
|
289
|
-
"session approval deny <approval-id> [--reason <text>] [--command-id <id>]",
|
|
300
|
+
"session approval deny <approval-id> [--reason <text>] [--as-coordinator] [--command-id <id>]",
|
|
290
301
|
1,
|
|
291
302
|
"approval.respond",
|
|
292
303
|
"Deny a worker's request.",
|
|
@@ -297,7 +308,7 @@ export const SESSION_TREE = {
|
|
|
297
308
|
},
|
|
298
309
|
],
|
|
299
310
|
[
|
|
300
|
-
"session approval answer <approval-id> (--text <answer> | --option <option-id>) [--command-id <id>]",
|
|
311
|
+
"session approval answer <approval-id> (--text <answer> | --option <option-id>) [--as-coordinator] [--command-id <id>]",
|
|
301
312
|
1,
|
|
302
313
|
"approval.respond",
|
|
303
314
|
"Answer a worker's question.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MAX_TURN_WAIT_MILLISECONDS, turnCancelParametersSchema, turnInterruptParametersSchema, turnQueueListParametersSchema, turnSendParametersSchema, turnShowParametersSchema, turnWaitParametersSchema, } from "@maiaos/sdk";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import { commandIdentifier, } from "../../local-node/index.js";
|
|
3
|
+
import { commandIdentifier, repeatBoundedWait, } from "../../local-node/index.js";
|
|
4
4
|
export const makeTurnClient = (node) => {
|
|
5
5
|
const interruptTurn = (input) => {
|
|
6
6
|
return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
|
|
@@ -29,17 +29,15 @@ export const makeTurnClient = (node) => {
|
|
|
29
29
|
};
|
|
30
30
|
const showTurn = (turnId) => node.runValidatedNodeOperation({ turnId }, turnShowParametersSchema, (client, parameters, options) => client.showTurn(parameters, options));
|
|
31
31
|
const waitTurnsOnce = (parameters) => node.runValidatedNodeOperation(parameters, turnWaitParametersSchema, (client, validated, options) => client.waitTurns(validated, options));
|
|
32
|
-
const waitWithin = (input) =>
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const waitWithin = (input) => repeatBoundedWait({
|
|
33
|
+
maxRequestMilliseconds: MAX_TURN_WAIT_MILLISECONDS,
|
|
34
|
+
once: (waitMilliseconds) => waitTurnsOnce({
|
|
35
35
|
mode: input.mode,
|
|
36
36
|
turnIds: input.turnIds,
|
|
37
37
|
waitMilliseconds,
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return result;
|
|
42
|
-
return yield* waitWithin({ ...input, timeoutMilliseconds: remaining });
|
|
38
|
+
}),
|
|
39
|
+
satisfied: (value) => value.satisfied,
|
|
40
|
+
timeoutMilliseconds: input.timeoutMilliseconds,
|
|
43
41
|
});
|
|
44
42
|
return {
|
|
45
43
|
cancelTurn,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_TURN_INPUT_BYTES, MAX_TURN_WAIT_IDS, } from "@maiaos/sdk";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import { CliArgumentError, parseOptions,
|
|
4
|
-
import { formatTurnMutation, formatTurnQueue, formatTurnShow, formatTurnWait, turnWaitExitCode, } from "./output.js";
|
|
3
|
+
import { CliArgumentError, parseOptions, readExpectedRevision, readRevisionOption, readWaitTimeoutSeconds, reportError, requirePositionals, writeNodeResult, writeSuccess, } from "../../command-line/index.js";
|
|
4
|
+
import { formatTurnMutation, formatTurnQueue, formatTurnSend, formatTurnShow, formatTurnWait, turnWaitExitCode, } from "./output.js";
|
|
5
5
|
const utf8 = new TextEncoder();
|
|
6
6
|
const summarizeTurnMutation = (result) => ({
|
|
7
7
|
delivery: result.delivery,
|
|
@@ -11,8 +11,9 @@ const summarizeTurnMutation = (result) => ({
|
|
|
11
11
|
state: result.turn.state,
|
|
12
12
|
turnId: result.turn.id,
|
|
13
13
|
});
|
|
14
|
+
const SEND_WAIT_MILLISECONDS = 24 * 60 * 60 * 1000;
|
|
14
15
|
const parseTurnSendArguments = (tokens) => {
|
|
15
|
-
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision", "--session"]), new Set(["--prompt-stdin"]));
|
|
16
|
+
const parsed = parseOptions(tokens, new Set(["--command-id", "--expected-revision", "--session"]), new Set(["--prompt-stdin", "--wait"]));
|
|
16
17
|
requirePositionals(parsed.positionals, 0);
|
|
17
18
|
const sessionId = parsed.options.get("--session");
|
|
18
19
|
if (sessionId === undefined) {
|
|
@@ -25,9 +26,31 @@ const parseTurnSendArguments = (tokens) => {
|
|
|
25
26
|
return {
|
|
26
27
|
expectedRevision: readExpectedRevision(parsed.options.get("--expected-revision")),
|
|
27
28
|
sessionId,
|
|
29
|
+
wait: parsed.flags.has("--wait"),
|
|
28
30
|
...(commandId === undefined ? {} : { commandId }),
|
|
29
31
|
};
|
|
30
32
|
};
|
|
33
|
+
const waitFailure = (turnId, error) => ({
|
|
34
|
+
...error,
|
|
35
|
+
message: `Turn ${turnId} was accepted, but waiting for it failed: ${error.message} Follow it with 'maia session turn wait ${turnId}'.`,
|
|
36
|
+
});
|
|
37
|
+
const waitForSentTurn = (context, sent) => Effect.gen(function* () {
|
|
38
|
+
const { waitTurns } = context.dependencies;
|
|
39
|
+
if (waitTurns === undefined)
|
|
40
|
+
throw new CliArgumentError("Turn wait is unavailable.");
|
|
41
|
+
const waited = yield* waitTurns({
|
|
42
|
+
mode: "all",
|
|
43
|
+
timeoutMilliseconds: SEND_WAIT_MILLISECONDS,
|
|
44
|
+
turnIds: [sent.turn.id],
|
|
45
|
+
});
|
|
46
|
+
if (!waited.ok)
|
|
47
|
+
return reportError(waitFailure(sent.turn.id, waited.error), context);
|
|
48
|
+
writeSuccess({
|
|
49
|
+
command: "turn.send",
|
|
50
|
+
result: { ...summarizeTurnMutation(sent), wait: waited.value },
|
|
51
|
+
}, context, formatTurnSend);
|
|
52
|
+
return turnWaitExitCode(waited.value);
|
|
53
|
+
});
|
|
31
54
|
export const runTurnSend = (tokens, context) => Effect.gen(function* () {
|
|
32
55
|
const input = parseTurnSendArguments(tokens);
|
|
33
56
|
if (context.io.stdin === undefined) {
|
|
@@ -38,14 +61,21 @@ export const runTurnSend = (tokens, context) => Effect.gen(function* () {
|
|
|
38
61
|
maxBytes: MAX_TURN_INPUT_BYTES,
|
|
39
62
|
maxChunks: 1024,
|
|
40
63
|
});
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
-
toText: formatTurnMutation,
|
|
64
|
+
const sent = yield* context.dependencies.sendTurn({
|
|
65
|
+
...(input.commandId === undefined ? {} : { commandId: input.commandId }),
|
|
66
|
+
expectedRevision: input.expectedRevision,
|
|
67
|
+
prompt,
|
|
68
|
+
sessionId: input.sessionId,
|
|
48
69
|
});
|
|
70
|
+
if (!sent.ok || !input.wait)
|
|
71
|
+
return writeNodeResult(sent, context, {
|
|
72
|
+
toResult: (value) => ({
|
|
73
|
+
command: "turn.send",
|
|
74
|
+
result: summarizeTurnMutation(value),
|
|
75
|
+
}),
|
|
76
|
+
toText: formatTurnSend,
|
|
77
|
+
});
|
|
78
|
+
return yield* waitForSentTurn(context, sent.value);
|
|
49
79
|
});
|
|
50
80
|
const parseTurnMutationArguments = (tokens, revisionOption) => {
|
|
51
81
|
const parsed = parseOptions(tokens, new Set(["--command-id", revisionOption]));
|
|
@@ -106,14 +136,21 @@ export const runTurnQueue = (tokens, context) => Effect.gen(function* () {
|
|
|
106
136
|
});
|
|
107
137
|
});
|
|
108
138
|
const parseTurnShowArguments = (tokens) => {
|
|
109
|
-
const parsed = parseOptions(tokens, new Set(), new Set(["--include-content"]));
|
|
110
|
-
requirePositionals(parsed.positionals, 1);
|
|
139
|
+
const parsed = parseOptions(tokens, new Set(["--session"]), new Set(["--include-content", "--latest"]));
|
|
111
140
|
const includeContent = parsed.flags.has("--include-content");
|
|
141
|
+
const sessionId = parsed.options.get("--session");
|
|
142
|
+
if (sessionId !== undefined || parsed.flags.has("--latest")) {
|
|
143
|
+
if (sessionId === undefined || !parsed.flags.has("--latest"))
|
|
144
|
+
throw new CliArgumentError("Use '--session' and '--latest' together.");
|
|
145
|
+
requirePositionals(parsed.positionals, 0);
|
|
146
|
+
return { includeContent, target: { sessionId, type: "latest" } };
|
|
147
|
+
}
|
|
148
|
+
requirePositionals(parsed.positionals, 1);
|
|
112
149
|
const turnId = parsed.positionals[0];
|
|
113
150
|
if (turnId === undefined) {
|
|
114
151
|
throw new CliArgumentError("The turn identifier is missing.");
|
|
115
152
|
}
|
|
116
|
-
return { includeContent, turnId };
|
|
153
|
+
return { includeContent, target: { turnId, type: "turn" } };
|
|
117
154
|
};
|
|
118
155
|
const turnTerminalProjection = (turn) => {
|
|
119
156
|
if (turn.state === "completed") {
|
|
@@ -145,22 +182,32 @@ const projectTurnWithoutContent = (value) => ({
|
|
|
145
182
|
const summarizeTurnShow = (value, includeContent) => includeContent
|
|
146
183
|
? { ...value, contentIncluded: true }
|
|
147
184
|
: projectTurnWithoutContent(value);
|
|
185
|
+
const turnToShow = (context, target) => {
|
|
186
|
+
const { showSession, showTurn } = context.dependencies;
|
|
187
|
+
if (target.type === "turn")
|
|
188
|
+
return showTurn(target.turnId);
|
|
189
|
+
return Effect.flatMap(showSession(target.sessionId), (shown) => {
|
|
190
|
+
if (!shown.ok)
|
|
191
|
+
return Effect.succeed({ error: shown.error, ok: false });
|
|
192
|
+
const { latestTurnId } = shown.value.session;
|
|
193
|
+
return latestTurnId === undefined
|
|
194
|
+
? Effect.succeed({ ok: true, value: undefined })
|
|
195
|
+
: showTurn(latestTurnId);
|
|
196
|
+
});
|
|
197
|
+
};
|
|
148
198
|
export const runTurnShow = (tokens, context) => Effect.gen(function* () {
|
|
149
199
|
const input = parseTurnShowArguments(tokens);
|
|
150
|
-
const result = yield* context
|
|
200
|
+
const result = yield* turnToShow(context, input.target);
|
|
151
201
|
return writeNodeResult(result, context, {
|
|
152
202
|
toResult: (value) => ({
|
|
153
203
|
command: "turn.show",
|
|
154
|
-
result:
|
|
204
|
+
result: value === undefined
|
|
205
|
+
? { contentIncluded: false, method: "turn.show" }
|
|
206
|
+
: summarizeTurnShow(value, input.includeContent),
|
|
155
207
|
}),
|
|
156
208
|
toText: formatTurnShow,
|
|
157
209
|
});
|
|
158
210
|
});
|
|
159
|
-
const DEFAULT_TURN_WAIT_SECONDS = 600;
|
|
160
|
-
const MAX_TURN_WAIT_SECONDS = 86_400;
|
|
161
|
-
const readWaitTimeoutSeconds = (value) => value === undefined
|
|
162
|
-
? DEFAULT_TURN_WAIT_SECONDS
|
|
163
|
-
: readDuration(value, "--timeout", { max: MAX_TURN_WAIT_SECONDS, min: 1 });
|
|
164
211
|
const parseTurnWaitArguments = (tokens) => {
|
|
165
212
|
const parsed = parseOptions(tokens, new Set(["--timeout"]), new Set(["--any"]));
|
|
166
213
|
if (parsed.positionals.length === 0 ||
|
|
@@ -8,6 +8,7 @@ export type CliTurnMutation = {
|
|
|
8
8
|
readonly sessionId: string;
|
|
9
9
|
readonly state: TurnInterruptResult["turn"]["state"];
|
|
10
10
|
readonly turnId: string;
|
|
11
|
+
readonly wait?: TurnWaitResult;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
export type CliTurnShow = {
|
|
@@ -29,6 +30,10 @@ export type CliTurnShow = {
|
|
|
29
30
|
readonly state: TurnShowResult["turn"]["state"];
|
|
30
31
|
readonly tokenUsage?: TurnTokenUsage;
|
|
31
32
|
};
|
|
33
|
+
} | {
|
|
34
|
+
readonly contentIncluded: false;
|
|
35
|
+
readonly method: "turn.show";
|
|
36
|
+
readonly turn?: undefined;
|
|
32
37
|
};
|
|
33
38
|
};
|
|
34
39
|
export type CliTurnWait = {
|
|
@@ -40,6 +45,7 @@ export type CliTurnQueue = {
|
|
|
40
45
|
readonly result: TurnQueueListResult;
|
|
41
46
|
};
|
|
42
47
|
export declare const formatTurnMutation: ({ result }: CliTurnMutation) => string;
|
|
48
|
+
export declare const formatTurnSend: (output: CliTurnMutation) => string;
|
|
43
49
|
export declare const formatTurnQueue: ({ result }: CliTurnQueue) => string;
|
|
44
50
|
export declare const formatTurnShow: ({ result }: CliTurnShow) => string;
|
|
45
51
|
export declare const formatTurnWait: ({ result }: CliTurnWait) => string;
|
|
@@ -5,6 +5,9 @@ export const formatTurnMutation = ({ result }) => fields([
|
|
|
5
5
|
["state", result.state],
|
|
6
6
|
["revision", result.revision],
|
|
7
7
|
]);
|
|
8
|
+
export const formatTurnSend = (output) => output.result.wait === undefined
|
|
9
|
+
? formatTurnMutation(output)
|
|
10
|
+
: formatTurnWait({ command: "turn.wait", result: output.result.wait });
|
|
8
11
|
const turnFields = (turn, reason) => fields([
|
|
9
12
|
["turn", turn.id],
|
|
10
13
|
["state", turn.state],
|
|
@@ -35,9 +38,13 @@ const formatUsage = (usage) => usage === undefined
|
|
|
35
38
|
? ""
|
|
36
39
|
: `tokens: input ${String(usage.inputTokens)} (cached ${String(usage.cachedInputTokens)}), output ${String(usage.outputTokens)} (reasoning ${String(usage.reasoningOutputTokens)}), total ${String(usage.totalTokens)}${usage.modelCallCount === undefined ? "" : `, model calls ${String(usage.modelCallCount)}`}\n`;
|
|
37
40
|
const formatContent = (turn) => `input:\n${block(turn.input.text)}\n${turn.state === "completed" ? `response:\n${block(turn.responseText)}\n` : ""}`;
|
|
38
|
-
const shownContent = (result) => result.contentIncluded
|
|
41
|
+
const shownContent = (result) => result.contentIncluded && result.turn !== undefined
|
|
42
|
+
? formatContent(result.turn)
|
|
43
|
+
: "";
|
|
39
44
|
export const formatTurnShow = ({ result }) => {
|
|
40
45
|
const { turn } = result;
|
|
46
|
+
if (turn === undefined)
|
|
47
|
+
return "no turn with output yet\n";
|
|
41
48
|
const failure = "failure" in turn &&
|
|
42
49
|
(turn.state === "failed" || turn.state === "outcome-unknown")
|
|
43
50
|
? formatFailure(turn.failure, turn.state)
|