@sixb/cli 0.2.3 → 0.2.4
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/dist/commands/agent.d.ts +5 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/runner/local-runner.d.ts +1 -1
- package/dist/tui/app.d.ts.map +1 -1
- package/dist/tui/format.d.ts +20 -0
- package/dist/tui/format.d.ts.map +1 -1
- package/dist/tui/transcript.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/commands/agent.ts +54 -8
- package/src/runner/local-runner.ts +1 -1
- package/src/tui/app.tsx +2 -1
- package/src/tui/format.ts +182 -4
- package/src/tui/transcript.tsx +8 -1
package/dist/commands/agent.d.ts
CHANGED
|
@@ -16,4 +16,9 @@ export declare function runAgent(options: {
|
|
|
16
16
|
readonly apiUrl?: string;
|
|
17
17
|
readonly profile?: string;
|
|
18
18
|
}): Promise<void>;
|
|
19
|
+
/** The questions a turn ended on, each with its choices numbered, as plain text. */
|
|
20
|
+
export declare function questionsText(questions: readonly {
|
|
21
|
+
readonly question: string;
|
|
22
|
+
readonly choices: readonly string[];
|
|
23
|
+
}[]): string;
|
|
19
24
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/commands/agent.ts"],"names":[],"mappings":"AAsCA;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,oGAAoG;IACpG,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/commands/agent.ts"],"names":[],"mappings":"AAsCA;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,oGAAoG;IACpG,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAsHhB;AAoPD,oFAAoF;AACpF,wBAAgB,aAAa,CAC3B,SAAS,EAAE,SAAS;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,GACvF,MAAM,CAWR"}
|
|
@@ -69,7 +69,7 @@ export declare class LocalRunner {
|
|
|
69
69
|
/** Hear each background command start and end. Returns the unsubscribe. */
|
|
70
70
|
onBackground(listener: () => void): () => void;
|
|
71
71
|
/**
|
|
72
|
-
* Stop a background command, and everything it started, as the agent's `
|
|
72
|
+
* Stop a background command, and everything it started, as the agent's `stop` does. False
|
|
73
73
|
* when it ended already, or is not this `sixb`'s.
|
|
74
74
|
*/
|
|
75
75
|
stopBackground(ref: ComputerBackgroundCommandRef): Promise<boolean>;
|
package/dist/tui/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/tui/app.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiC,WAAW,EAAE,MAAM,eAAe,CAAA;AA0B/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,OAAO,EAAE,KAAK,WAAW,EAAQ,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/tui/app.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiC,WAAW,EAAE,MAAM,eAAe,CAAA;AA0B/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,OAAO,EAAE,KAAK,WAAW,EAAQ,MAAM,wBAAwB,CAAA;AAiB/D,OAAO,EASL,KAAK,QAAQ,EAEd,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAmC,KAAK,GAAG,EAAuB,MAAM,cAAc,CAAA;AAgB7F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED,+FAA+F;AAC/F,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,6BAqZ9C;AAkvBD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,GAAG,EAAE,EACpB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,KAAK,EAAE;IACL,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;CAC9B,GACA,MAAM,CAcR"}
|
package/dist/tui/format.d.ts
CHANGED
|
@@ -15,9 +15,29 @@ export interface ToolLine {
|
|
|
15
15
|
readonly held?: boolean;
|
|
16
16
|
/** A shell command, shown whole as the call's panel. */
|
|
17
17
|
readonly command?: string;
|
|
18
|
+
/** The preview is diff lines, `+` added and `-` removed, colored as such. */
|
|
19
|
+
readonly diff?: boolean;
|
|
18
20
|
}
|
|
19
21
|
/** `outcomes` says how the held calls ended, by approval id: a decided call is no longer held. */
|
|
20
22
|
export declare function toolLine(part: ToolPart, outcomes?: ReadonlyMap<string, ApprovalOutcome>): ToolLine;
|
|
23
|
+
export interface AskedQuestion {
|
|
24
|
+
readonly question: string;
|
|
25
|
+
readonly choices: readonly string[];
|
|
26
|
+
readonly multiple: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** What a reply asked the user with its last `ask`: its questions, or none. */
|
|
29
|
+
export declare function askedInReply(message: {
|
|
30
|
+
readonly role: string;
|
|
31
|
+
readonly parts: readonly Part[];
|
|
32
|
+
} | null | undefined): readonly AskedQuestion[];
|
|
33
|
+
/**
|
|
34
|
+
* A reply of a number to the Agent's question, its last reply's one question with choices, is the
|
|
35
|
+
* choice under that number: "2" answers "2026". Anything else is sent as typed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pickedAnswer(messages: readonly {
|
|
38
|
+
readonly role: string;
|
|
39
|
+
readonly parts: readonly Part[];
|
|
40
|
+
}[], text: string): string;
|
|
21
41
|
/** Why a run failed, in a line; a conversation too long for its model says how to go on. */
|
|
22
42
|
export declare function runFailureText(error: {
|
|
23
43
|
readonly code: string;
|
package/dist/tui/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/tui/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEpD,KAAK,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAExD,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/tui/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEpD,KAAK,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAExD,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,gFAAgF;IA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
|
|
2
2
|
"name": "@sixb/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Command-line interface for Sixb projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -31,31 +31,31 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@opentui/core": "0.6.6",
|
|
33
33
|
"@opentui/react": "0.6.6",
|
|
34
|
-
"@sixb/agent": "0.2.
|
|
35
|
-
"@sixb/agent-worker": "0.2.
|
|
36
|
-
"@sixb/app": "^0.2.
|
|
34
|
+
"@sixb/agent": "0.2.4",
|
|
35
|
+
"@sixb/agent-worker": "0.2.4",
|
|
36
|
+
"@sixb/app": "^0.2.4",
|
|
37
37
|
"@sixb/client": "^0.2.3",
|
|
38
|
-
"@sixb/core": "0.2.
|
|
38
|
+
"@sixb/core": "0.2.4",
|
|
39
39
|
"@sixb/cli-core": "^0.2.3",
|
|
40
|
-
"@sixb/lake-worker": "0.2.
|
|
41
|
-
"@sixb/orchestrator": "0.2.
|
|
42
|
-
"@sixb/pipeline-worker": "0.2.
|
|
43
|
-
"@sixb/projection-worker": "0.2.
|
|
44
|
-
"@sixb/rules-worker": "0.2.
|
|
40
|
+
"@sixb/lake-worker": "0.2.4",
|
|
41
|
+
"@sixb/orchestrator": "0.2.4",
|
|
42
|
+
"@sixb/pipeline-worker": "0.2.4",
|
|
43
|
+
"@sixb/projection-worker": "0.2.4",
|
|
44
|
+
"@sixb/rules-worker": "0.2.4",
|
|
45
45
|
"@sixb/sandboxes-local": "^0.2.0",
|
|
46
|
-
"@sixb/server": "0.2.
|
|
47
|
-
"@sixb/sync-worker": "0.2.
|
|
48
|
-
"@sixb/workflow-worker": "0.2.
|
|
46
|
+
"@sixb/server": "0.2.4",
|
|
47
|
+
"@sixb/sync-worker": "0.2.4",
|
|
48
|
+
"@sixb/workflow-worker": "0.2.4",
|
|
49
49
|
"create-sixb": "^0.2.0",
|
|
50
50
|
"react": "^19.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@sixb/deploy-ssh": "0.2.0",
|
|
54
54
|
"@sixb/desktop": "0.2.1",
|
|
55
|
-
"@sixb/ducklake": "0.2.
|
|
56
|
-
"@sixb/pg": "0.2.
|
|
55
|
+
"@sixb/ducklake": "0.2.4",
|
|
56
|
+
"@sixb/pg": "0.2.4",
|
|
57
57
|
"@sixb/queues-bullmq": "0.2.3",
|
|
58
|
-
"@sixb/sqlite": "0.2.
|
|
58
|
+
"@sixb/sqlite": "0.2.4",
|
|
59
59
|
"@types/bun": "latest",
|
|
60
60
|
"@types/react": "^19.0.0",
|
|
61
61
|
"typescript": "^5.7.0"
|
package/src/commands/agent.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { type Connection, connect } from "../lib/connection"
|
|
|
17
17
|
import { errorMessage } from "../lib/errors"
|
|
18
18
|
import { thisComputer, thisComputerId } from "../runner/computer"
|
|
19
19
|
import { LocalRunner } from "../runner/local-runner"
|
|
20
|
-
import { toolLine } from "../tui/format"
|
|
20
|
+
import { askedInReply, pickedAnswer, toolLine } from "../tui/format"
|
|
21
21
|
import { liveRun, reduceLive, shownMessage } from "../tui/parts"
|
|
22
22
|
import {
|
|
23
23
|
APPROVAL_MODES,
|
|
@@ -108,6 +108,10 @@ export async function runAgent(options: {
|
|
|
108
108
|
)
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// In a conversation that asked a question with choices, a number answers with that choice.
|
|
112
|
+
const last = options.thread ? await lastMessage(connection, threadId) : null
|
|
113
|
+
const sent = last ? pickedAnswer([last], text) : text
|
|
114
|
+
|
|
111
115
|
const stop = new AbortController()
|
|
112
116
|
process.once("SIGINT", () => stop.abort())
|
|
113
117
|
try {
|
|
@@ -115,7 +119,7 @@ export async function runAgent(options: {
|
|
|
115
119
|
client,
|
|
116
120
|
path: { threadId: thread.id },
|
|
117
121
|
body: {
|
|
118
|
-
text,
|
|
122
|
+
text: sent,
|
|
119
123
|
...(approvalMode ? { approvalMode } : {}),
|
|
120
124
|
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
121
125
|
locale: Intl.DateTimeFormat().resolvedOptions().locale,
|
|
@@ -281,6 +285,10 @@ async function follow(
|
|
|
281
285
|
step(
|
|
282
286
|
`${mark} ${tone.strong(line.verb)} ${tone.muted(line.detail)}${line.note ? tone.faint(` ${line.note}`) : ""}`
|
|
283
287
|
)
|
|
288
|
+
// A question's choices are what the person answers with: they read under its line.
|
|
289
|
+
if (part.name === "ask") {
|
|
290
|
+
for (const row of line.preview ?? []) step(tone.faint(` ${row}`))
|
|
291
|
+
}
|
|
284
292
|
}
|
|
285
293
|
}
|
|
286
294
|
if (event.type === "agent.run.finished") settle("finished")
|
|
@@ -356,15 +364,28 @@ async function afterTurn(
|
|
|
356
364
|
return null
|
|
357
365
|
}
|
|
358
366
|
|
|
359
|
-
/** The
|
|
367
|
+
/** The thread's last message, as the TUI shows it. */
|
|
368
|
+
async function lastMessage(connection: Connection, threadId: string) {
|
|
369
|
+
const { data } = await listAgentThreadMessages({
|
|
370
|
+
client: connection.client,
|
|
371
|
+
path: { threadId },
|
|
372
|
+
query: { order: "desc", limit: "1" },
|
|
373
|
+
})
|
|
374
|
+
const last = data?.messages[0]
|
|
375
|
+
return last ? shownMessage(last) : null
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* The turn's answer: its last message's text, or as JSON. A turn that ended on a question gives
|
|
380
|
+
* the questions, each with its choices, and how to answer.
|
|
381
|
+
*/
|
|
360
382
|
async function printAnswer(connection: Connection, threadId: string, json: boolean) {
|
|
361
383
|
const { client } = connection
|
|
362
|
-
const [
|
|
363
|
-
|
|
384
|
+
const [shown, { data: runs }] = await Promise.all([
|
|
385
|
+
lastMessage(connection, threadId),
|
|
364
386
|
listAgentThreadRuns({ client, path: { threadId }, query: { order: "desc", limit: "1" } }),
|
|
365
387
|
])
|
|
366
|
-
const
|
|
367
|
-
const shown = last ? shownMessage(last) : null
|
|
388
|
+
const questions = askedInReply(shown)
|
|
368
389
|
const answer =
|
|
369
390
|
shown?.role === "assistant"
|
|
370
391
|
? shown.parts.flatMap((part) => (part.kind === "text" ? [part.text.trim()] : [])).join("\n\n")
|
|
@@ -376,15 +397,40 @@ async function printAnswer(connection: Connection, threadId: string, json: boole
|
|
|
376
397
|
|
|
377
398
|
if (json) {
|
|
378
399
|
process.stdout.write(
|
|
379
|
-
`${JSON.stringify({ threadId, runId: run?.id, status: run?.status, finishReason: run?.finishReason, text: answer })}\n`
|
|
400
|
+
`${JSON.stringify({ threadId, runId: run?.id, status: run?.status, finishReason: run?.finishReason, text: answer, ...(questions.length > 0 ? { questions } : {}) })}\n`
|
|
380
401
|
)
|
|
381
402
|
return
|
|
382
403
|
}
|
|
383
404
|
if (answer) process.stdout.write(`\n${process.stdout.isTTY ? styled(answer) : answer}\n`)
|
|
405
|
+
if (questions.length > 0) {
|
|
406
|
+
process.stdout.write(`\n${questionsText(questions)}\n`)
|
|
407
|
+
const byNumber = questions.length === 1 && (questions[0]?.choices.length ?? 0) > 0
|
|
408
|
+
step(
|
|
409
|
+
tone.faint(
|
|
410
|
+
`Answer with: sixb agent --thread ${threadId} "<answer>"${byNumber ? ", or a choice's number" : ""}`
|
|
411
|
+
)
|
|
412
|
+
)
|
|
413
|
+
}
|
|
384
414
|
if (run?.status === "failed") step(tone.fail(run.error?.message ?? "The turn failed."))
|
|
385
415
|
if (run?.status === "cancelled") step(tone.fail("The turn was stopped."))
|
|
386
416
|
}
|
|
387
417
|
|
|
418
|
+
/** The questions a turn ended on, each with its choices numbered, as plain text. */
|
|
419
|
+
export function questionsText(
|
|
420
|
+
questions: readonly { readonly question: string; readonly choices: readonly string[] }[]
|
|
421
|
+
): string {
|
|
422
|
+
return questions
|
|
423
|
+
.map((question, index) =>
|
|
424
|
+
[
|
|
425
|
+
questions.length > 1 ? `${index + 1}. ${question.question}` : question.question,
|
|
426
|
+
...question.choices.map(
|
|
427
|
+
(choice, at) => `${questions.length > 1 ? " " : " "}${at + 1}. ${choice}`
|
|
428
|
+
),
|
|
429
|
+
].join("\n")
|
|
430
|
+
)
|
|
431
|
+
.join("\n\n")
|
|
432
|
+
}
|
|
433
|
+
|
|
388
434
|
function parseApprovalMode(value: string | undefined): ApprovalMode | undefined {
|
|
389
435
|
if (value === undefined) return undefined
|
|
390
436
|
|
|
@@ -219,7 +219,7 @@ export class LocalRunner {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
|
-
* Stop a background command, and everything it started, as the agent's `
|
|
222
|
+
* Stop a background command, and everything it started, as the agent's `stop` does. False
|
|
223
223
|
* when it ended already, or is not this `sixb`'s.
|
|
224
224
|
*/
|
|
225
225
|
async stopBackground(ref: ComputerBackgroundCommandRef): Promise<boolean> {
|
package/src/tui/app.tsx
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
contextStatus,
|
|
42
42
|
elapsed,
|
|
43
43
|
fittedContextText,
|
|
44
|
+
pickedAnswer,
|
|
44
45
|
shortPath,
|
|
45
46
|
} from "./format"
|
|
46
47
|
import { Palette, type PaletteItem } from "./palette"
|
|
@@ -1013,7 +1014,7 @@ function ThreadView(
|
|
|
1013
1014
|
client,
|
|
1014
1015
|
path: { threadId },
|
|
1015
1016
|
body: {
|
|
1016
|
-
text,
|
|
1017
|
+
text: pickedAnswer(messages, text),
|
|
1017
1018
|
// The thread's mode applies, unless one chosen here has not reached it yet.
|
|
1018
1019
|
...(props.approval?.chosen && props.approval.mode
|
|
1019
1020
|
? { approvalMode: props.approval.mode }
|
package/src/tui/format.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface ToolLine {
|
|
|
15
15
|
readonly held?: boolean
|
|
16
16
|
/** A shell command, shown whole as the call's panel. */
|
|
17
17
|
readonly command?: string
|
|
18
|
+
/** The preview is diff lines, `+` added and `-` removed, colored as such. */
|
|
19
|
+
readonly diff?: boolean
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
const PREVIEW_LINES = 4
|
|
@@ -70,6 +72,31 @@ export function toolLine(
|
|
|
70
72
|
...error,
|
|
71
73
|
}
|
|
72
74
|
}
|
|
75
|
+
case "wait":
|
|
76
|
+
case "stop": {
|
|
77
|
+
// Background commands by their id, sub-agents by their key; with a sub-agent, the result is
|
|
78
|
+
// rich, its JSON in its text.
|
|
79
|
+
const ids = Array.isArray(input?.ids) ? input.ids.map(text) : [text(input?.id)]
|
|
80
|
+
const value = record(richValue(output))
|
|
81
|
+
const commands = Array.isArray(value?.commands) ? value.commands.map(record) : []
|
|
82
|
+
const results = Array.isArray(value?.results) ? value.results.map(record) : []
|
|
83
|
+
const [command] = commands
|
|
84
|
+
const one = commands.length + results.length === 1
|
|
85
|
+
const written = one ? text(command?.output) : ""
|
|
86
|
+
const childStatus = one && !command ? text(results[0]?.status) : ""
|
|
87
|
+
return {
|
|
88
|
+
verb: part.name,
|
|
89
|
+
// One command reads as bash_output's did: its id, then what it runs.
|
|
90
|
+
detail: [...ids, one && command ? firstLine(text(command.command)) : ""]
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.join(" "),
|
|
93
|
+
...(written.trim() ? { preview: lines(written) } : {}),
|
|
94
|
+
...(one && command ? backgroundNote(text(command.status), command.exitCode) : {}),
|
|
95
|
+
...(childStatus ? childNote(childStatus) : {}),
|
|
96
|
+
...error,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// What `wait` and `stop` were called for a background command: earlier threads hold them.
|
|
73
100
|
case "bash_output":
|
|
74
101
|
case "bash_stop": {
|
|
75
102
|
const output_ = text(output?.output)
|
|
@@ -83,6 +110,19 @@ export function toolLine(
|
|
|
83
110
|
}
|
|
84
111
|
}
|
|
85
112
|
case "read": {
|
|
113
|
+
// A file shown as itself, an image or a PDF, reads as view_file did.
|
|
114
|
+
if (output?.kind === "agentToolResult") {
|
|
115
|
+
return { verb: "view", detail: text(input?.path), ...error }
|
|
116
|
+
}
|
|
117
|
+
if (Array.isArray(output?.entries)) {
|
|
118
|
+
const entries = `${output.entries.length} ${output.entries.length === 1 ? "entry" : "entries"}`
|
|
119
|
+
return {
|
|
120
|
+
verb: "list",
|
|
121
|
+
detail: text(input?.path),
|
|
122
|
+
note: output.truncated === true ? `${entries}+` : entries,
|
|
123
|
+
...error,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
86
126
|
const lineCount = typeof output?.endLine === "number" && typeof output.startLine === "number"
|
|
87
127
|
return {
|
|
88
128
|
verb: "read",
|
|
@@ -93,6 +133,41 @@ export function toolLine(
|
|
|
93
133
|
...error,
|
|
94
134
|
}
|
|
95
135
|
}
|
|
136
|
+
case "edit": {
|
|
137
|
+
const changed = text(output?.diff)
|
|
138
|
+
.split("\n")
|
|
139
|
+
.filter((line) => /^[+-]/.test(line))
|
|
140
|
+
|
|
141
|
+
// The diff is cut on a large edit, so the edit counts its lines; an output stored before it
|
|
142
|
+
// did carries only the diff.
|
|
143
|
+
const added =
|
|
144
|
+
typeof output?.added === "number"
|
|
145
|
+
? output.added
|
|
146
|
+
: changed.filter((line) => line.startsWith("+")).length
|
|
147
|
+
const removed =
|
|
148
|
+
typeof output?.removed === "number"
|
|
149
|
+
? output.removed
|
|
150
|
+
: changed.filter((line) => line.startsWith("-")).length
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
verb: "edit",
|
|
154
|
+
detail: text(input?.path),
|
|
155
|
+
...(output?.diff !== undefined
|
|
156
|
+
? { note: `+${added} −${removed}`, diff: true, preview: limited(changed) }
|
|
157
|
+
: {}),
|
|
158
|
+
...error,
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
case "write": {
|
|
162
|
+
const linesWritten = typeof output?.lines === "number" ? output.lines : undefined
|
|
163
|
+
return {
|
|
164
|
+
verb: output?.created === false ? "rewrite" : "write",
|
|
165
|
+
detail: text(input?.path),
|
|
166
|
+
...(linesWritten !== undefined ? { note: plural(linesWritten, "line") } : {}),
|
|
167
|
+
...error,
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Earlier threads hold calls to it.
|
|
96
171
|
case "view_file":
|
|
97
172
|
return { verb: "view", detail: text(input?.path), ...error }
|
|
98
173
|
case "web_search": {
|
|
@@ -112,11 +187,14 @@ export function toolLine(
|
|
|
112
187
|
...(failed ? fetchFailure(part.error) : {}),
|
|
113
188
|
}
|
|
114
189
|
case "publish_artifact":
|
|
190
|
+
// What `publish_artifact` with an id was called: earlier threads hold calls to them.
|
|
115
191
|
case "update_artifact":
|
|
116
|
-
// What `update_artifact` was called: earlier threads hold calls to it.
|
|
117
192
|
case "publish_artifact_version":
|
|
118
193
|
return {
|
|
119
|
-
verb:
|
|
194
|
+
verb:
|
|
195
|
+
part.name === "publish_artifact" && !text(input?.id).startsWith("art_")
|
|
196
|
+
? "publish"
|
|
197
|
+
: "update",
|
|
120
198
|
detail: text(input?.title) || text(input?.path) || text(input?.artifactId),
|
|
121
199
|
...(output?.artifactId ? { note: `artifact:${text(output.artifactId)}` } : {}),
|
|
122
200
|
...error,
|
|
@@ -134,6 +212,7 @@ export function toolLine(
|
|
|
134
212
|
detail: [text(input?.key), firstLine(text(input?.task))].filter(Boolean).join(" "),
|
|
135
213
|
...error,
|
|
136
214
|
}
|
|
215
|
+
// What `wait` was called for sub-agents: earlier threads hold calls to it.
|
|
137
216
|
case "wait_agent": {
|
|
138
217
|
const runIds = Array.isArray(input?.runIds) ? input.runIds.length : 0
|
|
139
218
|
return {
|
|
@@ -148,12 +227,32 @@ export function toolLine(
|
|
|
148
227
|
detail: [text(input?.key), firstLine(text(input?.text))].filter(Boolean).join(" "),
|
|
149
228
|
...error,
|
|
150
229
|
}
|
|
151
|
-
case "
|
|
230
|
+
case "ask":
|
|
231
|
+
// What `ask` was called for a sub-agent: earlier threads hold calls to it.
|
|
232
|
+
case "ask_parent": {
|
|
233
|
+
const questions = askedQuestions(input)
|
|
234
|
+
// One question reads on the line; several, each with its choices numbered, under it. A row's
|
|
235
|
+
// runs of spaces collapse to one, so the choices are kept apart by a dot.
|
|
236
|
+
const [first] = questions
|
|
152
237
|
return {
|
|
153
238
|
verb: "ask",
|
|
154
|
-
detail:
|
|
239
|
+
detail:
|
|
240
|
+
questions.length === 1 && first ? first.question : plural(questions.length, "question"),
|
|
241
|
+
...(questions.length > 1 || first?.choices.length
|
|
242
|
+
? {
|
|
243
|
+
preview: questions.map((question) =>
|
|
244
|
+
[
|
|
245
|
+
...(questions.length > 1 ? [question.question] : []),
|
|
246
|
+
question.choices.map((choice, index) => `${index + 1}. ${choice}`).join(" · "),
|
|
247
|
+
]
|
|
248
|
+
.filter(Boolean)
|
|
249
|
+
.join(" ")
|
|
250
|
+
),
|
|
251
|
+
}
|
|
252
|
+
: {}),
|
|
155
253
|
...error,
|
|
156
254
|
}
|
|
255
|
+
}
|
|
157
256
|
default:
|
|
158
257
|
return {
|
|
159
258
|
verb: part.name,
|
|
@@ -262,6 +361,14 @@ function backgroundNote(status: string, exitCode: unknown): Pick<ToolLine, "note
|
|
|
262
361
|
return exitCode === 0 ? { note: "exit 0" } : { note: `exit ${exitCode}`, failed: true }
|
|
263
362
|
}
|
|
264
363
|
|
|
364
|
+
/** How a sub-agent a `wait` or a `stop` named stands, beside its line. */
|
|
365
|
+
function childNote(status: string): Pick<ToolLine, "note" | "failed"> {
|
|
366
|
+
if (status === "succeeded") return { note: "done" }
|
|
367
|
+
if (status === "cancelled") return { note: "stopped" }
|
|
368
|
+
if (status === "failed") return { note: "failed", failed: true }
|
|
369
|
+
return { note: status.replaceAll("_", " ") }
|
|
370
|
+
}
|
|
371
|
+
|
|
265
372
|
/** How decided calls ended, as the web chat's approval card names it. */
|
|
266
373
|
function decidedLine(outcomes: readonly ApprovalOutcome[]): Pick<ToolLine, "note" | "failed"> {
|
|
267
374
|
const ended = outcomes.map(outcomeNote)
|
|
@@ -303,6 +410,19 @@ function parseJson(value: string): unknown {
|
|
|
303
410
|
}
|
|
304
411
|
}
|
|
305
412
|
|
|
413
|
+
/** A rich result's value, its JSON text parsed; any other output as it is. */
|
|
414
|
+
function richValue(output: Record<string, unknown> | undefined): unknown {
|
|
415
|
+
if (output?.kind !== "agentToolResult" || !Array.isArray(output.content)) return output
|
|
416
|
+
const [first] = output.content
|
|
417
|
+
const textPart = record(first)
|
|
418
|
+
if (typeof textPart?.text !== "string") return undefined
|
|
419
|
+
try {
|
|
420
|
+
return JSON.parse(textPart.text)
|
|
421
|
+
} catch {
|
|
422
|
+
return undefined
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
306
426
|
function record(value: unknown): Record<string, unknown> | undefined {
|
|
307
427
|
return value && typeof value === "object" && !Array.isArray(value)
|
|
308
428
|
? (value as Record<string, unknown>)
|
|
@@ -335,6 +455,64 @@ function firstLine(value: string): string {
|
|
|
335
455
|
return value.trim().split("\n")[0]?.trim() ?? ""
|
|
336
456
|
}
|
|
337
457
|
|
|
458
|
+
export interface AskedQuestion {
|
|
459
|
+
readonly question: string
|
|
460
|
+
readonly choices: readonly string[]
|
|
461
|
+
readonly multiple: boolean
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** The questions of an `ask` call, or of an earlier `ask_parent` call's one question. */
|
|
465
|
+
function askedQuestions(input: Record<string, unknown> | undefined): AskedQuestion[] {
|
|
466
|
+
if (typeof input?.question === "string") {
|
|
467
|
+
return [{ question: input.question.trim(), choices: [], multiple: false }]
|
|
468
|
+
}
|
|
469
|
+
if (!Array.isArray(input?.questions)) return []
|
|
470
|
+
return input.questions.flatMap((value) => {
|
|
471
|
+
const question = record(value)
|
|
472
|
+
if (typeof question?.question !== "string") return []
|
|
473
|
+
const choices = Array.isArray(question.choices)
|
|
474
|
+
? question.choices.filter((choice): choice is string => typeof choice === "string")
|
|
475
|
+
: []
|
|
476
|
+
return [{ question: question.question.trim(), choices, multiple: question.multiple === true }]
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** What a reply asked the user with its last `ask`: its questions, or none. */
|
|
481
|
+
export function askedInReply(
|
|
482
|
+
message: { readonly role: string; readonly parts: readonly Part[] } | null | undefined
|
|
483
|
+
): readonly AskedQuestion[] {
|
|
484
|
+
if (message?.role !== "assistant") return []
|
|
485
|
+
const asked = [...message.parts]
|
|
486
|
+
.reverse()
|
|
487
|
+
.find(
|
|
488
|
+
(part): part is ToolPart =>
|
|
489
|
+
part.kind === "tool" && part.name === "ask" && part.state === "done"
|
|
490
|
+
)
|
|
491
|
+
return askedQuestions(record(asked?.input))
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* A reply of a number to the Agent's question, its last reply's one question with choices, is the
|
|
496
|
+
* choice under that number: "2" answers "2026". Anything else is sent as typed.
|
|
497
|
+
*/
|
|
498
|
+
export function pickedAnswer(
|
|
499
|
+
messages: readonly { readonly role: string; readonly parts: readonly Part[] }[],
|
|
500
|
+
text: string
|
|
501
|
+
): string {
|
|
502
|
+
const number = text.trim()
|
|
503
|
+
if (!/^\d+$/.test(number)) return text
|
|
504
|
+
const questions = askedInReply(messages.at(-1))
|
|
505
|
+
if (questions.length !== 1) return text
|
|
506
|
+
return questions[0]?.choices[Number(number) - 1] ?? text
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** At most a few rows, with how many more there were. */
|
|
510
|
+
function limited(rows: readonly string[]): string[] {
|
|
511
|
+
return rows.length > PREVIEW_LINES
|
|
512
|
+
? [...rows.slice(0, PREVIEW_LINES), `… ${plural(rows.length - PREVIEW_LINES, "more line")}`]
|
|
513
|
+
: [...rows]
|
|
514
|
+
}
|
|
515
|
+
|
|
338
516
|
function lines(value: string): string[] {
|
|
339
517
|
const all = value.replace(/\s+$/, "").split("\n")
|
|
340
518
|
return all.length > PREVIEW_LINES
|
package/src/tui/transcript.tsx
CHANGED
|
@@ -387,7 +387,7 @@ function ToolRow({
|
|
|
387
387
|
{line.preview?.map((row, index) => (
|
|
388
388
|
<text key={`${index}-${row.slice(0, 12)}`}>
|
|
389
389
|
<span fg={colors.faint}>{index === 0 ? " ⎿ " : " "}</span>
|
|
390
|
-
<span fg={colors.faint}>{oneLine(row, room)}</span>
|
|
390
|
+
<span fg={line.diff ? diffColor(colors, row) : colors.faint}>{oneLine(row, room)}</span>
|
|
391
391
|
</text>
|
|
392
392
|
))}
|
|
393
393
|
</box>
|
|
@@ -455,6 +455,13 @@ function CommandPanel({
|
|
|
455
455
|
|
|
456
456
|
const COMMAND_LINES = 3
|
|
457
457
|
|
|
458
|
+
/** A diff row's color: added green, removed red, anything else faint. */
|
|
459
|
+
function diffColor(colors: TuiColors, row: string): string {
|
|
460
|
+
if (row.startsWith("+")) return colors.green
|
|
461
|
+
if (row.startsWith("-")) return colors.red
|
|
462
|
+
return colors.faint
|
|
463
|
+
}
|
|
464
|
+
|
|
458
465
|
/** Under a turn's answer: where it ran, on which model, and how long it took. */
|
|
459
466
|
function RunMeta({
|
|
460
467
|
colors,
|