@sixb/app 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/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/background/background-tool-row.d.ts.map +1 -1
- package/dist/agent/background/interpret.d.ts +1 -1
- package/dist/agent/background/interpret.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +4 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +5 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/delegation/agent-exchange.d.ts +16 -0
- package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
- package/dist/agent/delegation/child-card.d.ts +3 -3
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +1 -10
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +4 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
- package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
- package/dist/agent/file-edits/interpret.d.ts +25 -0
- package/dist/agent/file-edits/interpret.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +6 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +46 -5
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +76 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/message-agent/interpret.d.ts +2 -2
- package/dist/agent/message-agent/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/questions/interpret.d.ts +31 -0
- package/dist/agent/questions/interpret.d.ts.map +1 -0
- package/dist/agent/questions/question-card.d.ts +16 -0
- package/dist/agent/questions/question-card.d.ts.map +1 -0
- package/dist/agent/questions/question-composer.d.ts +15 -0
- package/dist/agent/questions/question-composer.d.ts.map +1 -0
- package/dist/agent/read/interpret.d.ts +8 -1
- package/dist/agent/read/interpret.d.ts.map +1 -1
- package/dist/agent/read/read-tool-view.d.ts.map +1 -1
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/waits.d.ts +14 -0
- package/dist/agent/waits.d.ts.map +1 -0
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +52 -0
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
- package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
- package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
- package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
- package/dist/{chunk-kes4ygmz.js → chunk-970s5nkn.js} +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-kymx9y5e.js} +3117 -2363
- package/dist/{chunk-001c4gnk.js.map → chunk-kymx9y5e.js.map} +36 -29
- package/dist/{chunk-fwb9mxwm.js → chunk-pxd07kvx.js} +1 -1
- package/dist/{chunk-5crvhjp2.js → chunk-yrcm1pbg.js} +1504 -233
- package/dist/chunk-yrcm1pbg.js.map +34 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +3 -3
- package/dist/pages.js +2 -2
- package/package.json +2 -2
- package/src/agent/activity-label.ts +6 -1
- package/src/agent/agent-chat.tsx +1 -0
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/conversation-panel.tsx +27 -8
- package/src/agent/components/message-parts.tsx +23 -5
- package/src/agent/components/transcript.tsx +45 -27
- package/src/agent/delegation/agent-exchange.tsx +53 -0
- package/src/agent/delegation/child-card.tsx +6 -40
- package/src/agent/delegation/child-parts.tsx +1 -84
- package/src/agent/delegation/child-work.tsx +19 -5
- package/src/agent/delegation/interpret.ts +33 -54
- package/src/agent/delegation/model.ts +1 -1
- package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
- package/src/agent/file-edits/interpret.ts +120 -0
- package/src/agent/hooks/use-agent-conversation.ts +20 -0
- package/src/agent/i18n/en.ts +47 -5
- package/src/agent/i18n/fr.ts +39 -4
- package/src/agent/message-agent/interpret.ts +4 -3
- package/src/agent/publish-artifact/interpret.ts +14 -5
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
- package/src/agent/questions/interpret.ts +90 -0
- package/src/agent/questions/question-card.tsx +57 -0
- package/src/agent/questions/question-composer.tsx +257 -0
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/tool-views/built-in.tsx +19 -8
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +36 -0
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/frame.tsx +3 -2
- package/src/artifacts/messages.ts +54 -0
- package/src/artifacts/renderers/canvas/board-editor.tsx +37 -15
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/controls.tsx +64 -30
- package/src/artifacts/renderers/canvas/focus.tsx +200 -56
- package/src/artifacts/renderers/canvas/gestures.ts +265 -0
- package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
- package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
- package/src/artifacts/renderers/canvas/page-size.ts +218 -0
- package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
- package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
- package/src/artifacts/viewer.tsx +15 -1
- package/src/index.ts +2 -0
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-kes4ygmz.js.map → chunk-970s5nkn.js.map} +0 -0
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-pxd07kvx.js.map} +0 -0
|
@@ -2,6 +2,8 @@ import type { AgentChild } from "@sixb/client"
|
|
|
2
2
|
import { type AgentConversationMessage, normalizedTool } from "../conversation"
|
|
3
3
|
import type { AgentMessages } from "../i18n/en"
|
|
4
4
|
import { type NormalizedPart, type NormalizedTool, toolResultValue } from "../parts"
|
|
5
|
+
import { askedText, isAskTool } from "../questions/interpret"
|
|
6
|
+
import { isCommandId, isStop, namedIds, waitsForChildren } from "../waits"
|
|
5
7
|
|
|
6
8
|
// What the parent's own parts say about the sub-agents it delegated to: which it spawned, what it
|
|
7
9
|
// told or answered each, and what each asked. A reader of the thread always has them, even without
|
|
@@ -24,13 +26,7 @@ export interface SpawnedChild {
|
|
|
24
26
|
readonly pending: boolean
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
/**
|
|
28
|
-
export interface ChildExchange {
|
|
29
|
-
readonly kind: "told" | "asked" | "answered"
|
|
30
|
-
readonly text: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** What `wait_agent` last said about one of a child's runs. */
|
|
29
|
+
/** What `wait`, or a `stop`, last said about one of a child's runs. */
|
|
34
30
|
export interface WaitedChild {
|
|
35
31
|
readonly status: string
|
|
36
32
|
readonly text?: string
|
|
@@ -41,7 +37,6 @@ export interface WaitedChild {
|
|
|
41
37
|
export interface ThreadDelegation {
|
|
42
38
|
/** The turn that spawned each child. */
|
|
43
39
|
readonly spawnedBy: ReadonlyMap<string, string | null>
|
|
44
|
-
readonly exchanges: ReadonlyMap<string, readonly ChildExchange[]>
|
|
45
40
|
/** By the id of the run waited on: a child's first run, or one that continued it. */
|
|
46
41
|
readonly waited: ReadonlyMap<string, WaitedChild>
|
|
47
42
|
/**
|
|
@@ -93,7 +88,8 @@ export interface DelegationTurn {
|
|
|
93
88
|
readonly tools: readonly NormalizedTool[]
|
|
94
89
|
}
|
|
95
90
|
|
|
96
|
-
|
|
91
|
+
/** Earlier threads hold `wait_agent`; a `wait` or a `stop` for commands alone is left out. */
|
|
92
|
+
const DELEGATION_TOOLS = new Set(["spawn_agent", "message_agent", "wait", "stop", "wait_agent"])
|
|
97
93
|
|
|
98
94
|
/** The delegation calls of each reply, oldest first, the one streaming last. */
|
|
99
95
|
export function delegationTurns(
|
|
@@ -109,28 +105,15 @@ export function delegationTurns(
|
|
|
109
105
|
}
|
|
110
106
|
|
|
111
107
|
/**
|
|
112
|
-
* Read the thread's sub-agents from its turns, oldest first, the one streaming now last.
|
|
113
|
-
*
|
|
108
|
+
* Read the thread's sub-agents from its turns, oldest first, the one streaming now last. What
|
|
109
|
+
* passed between the Agent and a child reads in the child's panel, from its own thread.
|
|
114
110
|
*/
|
|
115
111
|
export function readThreadDelegation(turns: readonly DelegationTurn[]): ThreadDelegation {
|
|
116
112
|
const spawnedBy = new Map<string, string | null>()
|
|
117
|
-
const exchanges = new Map<string, ChildExchange[]>()
|
|
118
113
|
const waited = new Map<string, WaitedChild>()
|
|
119
114
|
const owners = new Map<string, string>()
|
|
120
115
|
const ownersByTurn = new Map<string, ReadonlyMap<string, string>>()
|
|
121
116
|
|
|
122
|
-
const add = (key: string, exchange: ChildExchange) => {
|
|
123
|
-
const owner = owners.get(key)
|
|
124
|
-
if (!owner) return
|
|
125
|
-
const list = exchanges.get(owner) ?? []
|
|
126
|
-
// A question is listed by every wait until it is answered: it reads once.
|
|
127
|
-
const repeated = list.some(
|
|
128
|
-
(earlier) => earlier.kind === exchange.kind && earlier.text === exchange.text
|
|
129
|
-
)
|
|
130
|
-
if (exchange.kind === "asked" && repeated) return
|
|
131
|
-
exchanges.set(owner, [...list, exchange])
|
|
132
|
-
}
|
|
133
|
-
|
|
134
117
|
const read = (runId: string | null, tool: NormalizedTool) => {
|
|
135
118
|
const child = spawnedChild(tool)
|
|
136
119
|
if (child && !child.pending) {
|
|
@@ -139,28 +122,15 @@ export function readThreadDelegation(turns: readonly DelegationTurn[]): ThreadDe
|
|
|
139
122
|
return
|
|
140
123
|
}
|
|
141
124
|
|
|
142
|
-
if (tool
|
|
143
|
-
const input = isRecord(tool.input) ? tool.input : {}
|
|
144
|
-
const output = toolResultValue(tool.output)
|
|
145
|
-
if (typeof input.key !== "string" || typeof input.text !== "string") return
|
|
146
|
-
const kind = isRecord(output) && output.delivery === "answer" ? "answered" : "told"
|
|
147
|
-
add(input.key.trim(), { kind, text: input.text.trim() })
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (tool.toolName !== "wait_agent" || tool.state !== "output-available") return
|
|
125
|
+
if (!waitsForChildren(tool) || tool.state !== "output-available") return
|
|
152
126
|
const output = toolResultValue(tool.output)
|
|
153
127
|
if (!isRecord(output)) return
|
|
154
128
|
|
|
155
|
-
for (const question of Array.isArray(output.questions) ? output.questions : []) {
|
|
156
|
-
if (!isRecord(question)) continue
|
|
157
|
-
if (typeof question.key !== "string" || typeof question.text !== "string") continue
|
|
158
|
-
add(question.key, { kind: "asked", text: question.text.trim() })
|
|
159
|
-
}
|
|
160
129
|
for (const result of Array.isArray(output.results) ? output.results : []) {
|
|
161
130
|
if (!isRecord(result) || typeof result.runId !== "string") continue
|
|
162
131
|
if (typeof result.status !== "string") continue
|
|
163
|
-
|
|
132
|
+
// Named by its key, as `wait` takes it, or by its run id, as `wait_agent` did.
|
|
133
|
+
waited.set(owners.get(result.runId) ?? result.runId, {
|
|
164
134
|
status: result.status,
|
|
165
135
|
...(typeof result.text === "string" ? { text: result.text } : {}),
|
|
166
136
|
...(isRecord(result.error) && typeof result.error.message === "string"
|
|
@@ -177,7 +147,6 @@ export function readThreadDelegation(turns: readonly DelegationTurn[]): ThreadDe
|
|
|
177
147
|
|
|
178
148
|
return {
|
|
179
149
|
spawnedBy,
|
|
180
|
-
exchanges,
|
|
181
150
|
waited,
|
|
182
151
|
ownerOf: (key, runId) =>
|
|
183
152
|
(runId ? ownersByTurn.get(runId) : undefined)?.get(key) ?? owners.get(key),
|
|
@@ -273,14 +242,13 @@ export function childTitle(key: string): string {
|
|
|
273
242
|
return words ? `${words.charAt(0).toUpperCase()}${words.slice(1)}` : key
|
|
274
243
|
}
|
|
275
244
|
|
|
276
|
-
/** The question a child at work waits on, from its live parts: its `
|
|
245
|
+
/** The question a child at work waits on, from its live parts: its `ask` call in flight. */
|
|
277
246
|
export function liveQuestion(parts: readonly NormalizedPart[]): string | null {
|
|
278
247
|
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
279
248
|
const part = parts[index]
|
|
280
|
-
if (part?.kind !== "tool" || part.tool.toolName
|
|
249
|
+
if (part?.kind !== "tool" || !isAskTool(part.tool.toolName)) continue
|
|
281
250
|
if (part.tool.state !== "input-available") return null
|
|
282
|
-
|
|
283
|
-
return typeof input.question === "string" ? input.question.trim() : null
|
|
251
|
+
return askedText(part.tool.input) || null
|
|
284
252
|
}
|
|
285
253
|
return null
|
|
286
254
|
}
|
|
@@ -294,11 +262,14 @@ export function formatWorked(ms: number, messages: AgentMessages["delegation"]):
|
|
|
294
262
|
return messages.hours(Math.floor(minutes / 60), minutes % 60)
|
|
295
263
|
}
|
|
296
264
|
|
|
297
|
-
/**
|
|
265
|
+
/**
|
|
266
|
+
* The children a `wait` or a `stop` names, by title: `wait` takes their keys, `wait_agent` took
|
|
267
|
+
* run ids, titled when the parts spawned them. Its background commands are not children.
|
|
268
|
+
*/
|
|
298
269
|
function waitedKeys(tool: NormalizedTool, keys: ReadonlyMap<string, string>): readonly string[] {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
270
|
+
return namedIds(tool)
|
|
271
|
+
.filter((id) => !isCommandId(id))
|
|
272
|
+
.map((id) => keys.get(id) ?? (tool.toolName === "wait_agent" ? "" : childTitle(id)))
|
|
302
273
|
}
|
|
303
274
|
|
|
304
275
|
/**
|
|
@@ -330,13 +301,11 @@ export function describeDelegationTool(
|
|
|
330
301
|
}
|
|
331
302
|
}
|
|
332
303
|
|
|
333
|
-
if (tool.toolName
|
|
334
|
-
|
|
335
|
-
const question = typeof input.question === "string" ? input.question.trim() : ""
|
|
336
|
-
return { title: labels.askedAgent(question), running: labels.states.asking }
|
|
304
|
+
if (isAskTool(tool.toolName)) {
|
|
305
|
+
return { title: labels.askedAgent(askedText(tool.input)), running: labels.states.asking }
|
|
337
306
|
}
|
|
338
307
|
|
|
339
|
-
if (tool
|
|
308
|
+
if (waitsForChildren(tool)) {
|
|
340
309
|
const keys = new Map<string, string>()
|
|
341
310
|
for (const part of parts) {
|
|
342
311
|
if (part.kind !== "tool") continue
|
|
@@ -345,6 +314,16 @@ export function describeDelegationTool(
|
|
|
345
314
|
}
|
|
346
315
|
const waitedFor = waitedKeys(tool, keys)
|
|
347
316
|
const named = waitedFor.every(Boolean) ? waitedFor : []
|
|
317
|
+
if (isStop(tool)) {
|
|
318
|
+
const name = named[0] ?? ""
|
|
319
|
+
if (tool.state === "output-error") {
|
|
320
|
+
const failed = labels.stopAgentFailed(name)
|
|
321
|
+
return { title: failed, running: failed }
|
|
322
|
+
}
|
|
323
|
+
return tool.state === "output-available"
|
|
324
|
+
? { title: labels.stoppedAgent(name), running: labels.stoppedAgent(name) }
|
|
325
|
+
: { title: labels.stoppingAgent(name), running: labels.stoppingAgent(name) }
|
|
326
|
+
}
|
|
348
327
|
const waiting =
|
|
349
328
|
named.length === 1
|
|
350
329
|
? labels.waitingFor(named[0] ?? "")
|
|
@@ -224,7 +224,7 @@ function shortName(name: string): string {
|
|
|
224
224
|
return `${(word > LINE_NAME_LENGTH / 2 ? cut.slice(0, word) : cut).replace(/[\s,.:;-]+$/, "")}…`
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
/** What `
|
|
227
|
+
/** What `wait`, or a `stop`, last said of any of the child's runs. */
|
|
228
228
|
function waitedFor(
|
|
229
229
|
waited: ReadonlyMap<string, WaitedChild>,
|
|
230
230
|
child: SpawnedChild,
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@sixb/ui/components"
|
|
2
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
3
|
+
import { ChevronRight, FilePen, FilePlus } from "lucide-react"
|
|
4
|
+
import { ActivityStatusText } from "../components/activity-status"
|
|
5
|
+
import { useAgentMessages } from "../i18n"
|
|
6
|
+
import type { NormalizedTool } from "../parts"
|
|
7
|
+
import { type DiffLine, describeEdit, describeWrite, type FileEditDescription } from "./interpret"
|
|
8
|
+
|
|
9
|
+
/** A change the agent made to part of a file: its name and `+3 −1`, opening to the diff. */
|
|
10
|
+
export function EditToolView({ tool }: { tool: NormalizedTool }) {
|
|
11
|
+
const messages = useAgentMessages()
|
|
12
|
+
return (
|
|
13
|
+
<FileEditRow tool={tool} description={describeEdit(tool, messages)} icon={FilePen} counts />
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A file the agent created or replaced whole: its name and lines, opening to what it wrote. */
|
|
18
|
+
export function WriteToolView({ tool }: { tool: NormalizedTool }) {
|
|
19
|
+
const messages = useAgentMessages()
|
|
20
|
+
return <FileEditRow tool={tool} description={describeWrite(tool, messages)} icon={FilePlus} />
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function FileEditRow({
|
|
24
|
+
tool,
|
|
25
|
+
description,
|
|
26
|
+
icon: Icon,
|
|
27
|
+
counts = false,
|
|
28
|
+
}: {
|
|
29
|
+
tool: NormalizedTool
|
|
30
|
+
description: FileEditDescription
|
|
31
|
+
icon: typeof FilePen
|
|
32
|
+
/** Show the lines added and removed, in the diff's colors, rather than the detail text. */
|
|
33
|
+
counts?: boolean
|
|
34
|
+
}) {
|
|
35
|
+
const running = tool.state === "input-streaming" || tool.state === "input-available"
|
|
36
|
+
const error = tool.state === "output-error"
|
|
37
|
+
const label = error
|
|
38
|
+
? description.failedTitle
|
|
39
|
+
: running
|
|
40
|
+
? description.runningTitle
|
|
41
|
+
: description.title
|
|
42
|
+
|
|
43
|
+
if (running) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground">
|
|
46
|
+
<Icon className="size-3.5 shrink-0" />
|
|
47
|
+
<ActivityStatusText label={label} className="font-medium shimmer" />
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Collapsible>
|
|
54
|
+
<CollapsibleTrigger className="group flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground transition-colors hover:text-foreground">
|
|
55
|
+
<Icon className="size-3.5 shrink-0" />
|
|
56
|
+
<span className="min-w-0 truncate font-medium">{label}</span>
|
|
57
|
+
{error || !description.detail ? null : counts ? (
|
|
58
|
+
<span className="shrink-0 font-mono text-[11px] tabular-nums">
|
|
59
|
+
<span className="text-emerald-600 dark:text-emerald-400">+{description.added}</span>{" "}
|
|
60
|
+
<span className="text-red-600 dark:text-red-400">−{description.removed}</span>
|
|
61
|
+
</span>
|
|
62
|
+
) : (
|
|
63
|
+
<span className="min-w-0 shrink truncate text-muted-foreground/60">
|
|
64
|
+
{description.detail}
|
|
65
|
+
</span>
|
|
66
|
+
)}
|
|
67
|
+
<ChevronRight className="size-3.5 shrink-0 opacity-0 transition-all group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-100" />
|
|
68
|
+
</CollapsibleTrigger>
|
|
69
|
+
<CollapsibleContent>
|
|
70
|
+
<div className="mt-3 min-w-0 space-y-2 text-xs">
|
|
71
|
+
{description.path ? (
|
|
72
|
+
<p className="truncate font-mono text-[10px] text-muted-foreground/60">
|
|
73
|
+
{description.path}
|
|
74
|
+
</p>
|
|
75
|
+
) : null}
|
|
76
|
+
{error ? (
|
|
77
|
+
<pre className="scrollbar-thin max-h-60 overflow-auto rounded bg-muted/50 p-2 text-[11px] leading-relaxed text-foreground">
|
|
78
|
+
{tool.errorText?.trim()}
|
|
79
|
+
</pre>
|
|
80
|
+
) : (
|
|
81
|
+
<DiffBlock lines={description.lines} />
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
</CollapsibleContent>
|
|
85
|
+
</Collapsible>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const LINE_CLASS: Record<DiffLine["kind"], string> = {
|
|
90
|
+
hunk: "text-muted-foreground/60",
|
|
91
|
+
added: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",
|
|
92
|
+
removed: "bg-red-500/10 text-red-700 dark:text-red-300",
|
|
93
|
+
context: "text-foreground/80",
|
|
94
|
+
note: "text-muted-foreground/60 italic",
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const LINE_MARK: Record<DiffLine["kind"], string> = {
|
|
98
|
+
hunk: "",
|
|
99
|
+
added: "+",
|
|
100
|
+
removed: "−",
|
|
101
|
+
context: " ",
|
|
102
|
+
note: "",
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function DiffBlock({ lines }: { lines: readonly DiffLine[] }) {
|
|
106
|
+
return (
|
|
107
|
+
<pre className="scrollbar-thin max-h-72 overflow-auto rounded bg-muted/50 py-1.5 text-[11px] leading-relaxed">
|
|
108
|
+
{lines.map((line, index) => (
|
|
109
|
+
<div
|
|
110
|
+
// Lines of one diff never reorder: the index is their identity.
|
|
111
|
+
key={index}
|
|
112
|
+
className={cn("flex min-w-max gap-2 px-2", LINE_CLASS[line.kind])}
|
|
113
|
+
>
|
|
114
|
+
{line.kind === "hunk" || line.kind === "note" ? (
|
|
115
|
+
<span>{line.text}</span>
|
|
116
|
+
) : (
|
|
117
|
+
<>
|
|
118
|
+
<span className="w-2 shrink-0 select-none opacity-70">{LINE_MARK[line.kind]}</span>
|
|
119
|
+
<span>{line.text || " "}</span>
|
|
120
|
+
</>
|
|
121
|
+
)}
|
|
122
|
+
</div>
|
|
123
|
+
))}
|
|
124
|
+
</pre>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type AgentMessages, en } from "../i18n/en"
|
|
2
|
+
import type { NormalizedTool } from "../parts"
|
|
3
|
+
|
|
4
|
+
/** One line of the unified diff `edit` returns. */
|
|
5
|
+
export interface DiffLine {
|
|
6
|
+
readonly kind: "hunk" | "added" | "removed" | "context" | "note"
|
|
7
|
+
readonly text: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface FileEditDescription {
|
|
11
|
+
/** The path the call named, or empty until it streams in. */
|
|
12
|
+
readonly path: string
|
|
13
|
+
readonly title: string
|
|
14
|
+
readonly runningTitle: string
|
|
15
|
+
readonly failedTitle: string
|
|
16
|
+
/** `+3 −1` for an edit, the line count for a write, once it has a result. */
|
|
17
|
+
readonly detail?: string
|
|
18
|
+
readonly added: number
|
|
19
|
+
readonly removed: number
|
|
20
|
+
/** The edit's diff, or the written file's contents as added lines. */
|
|
21
|
+
readonly lines: readonly DiffLine[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function describeEdit(
|
|
25
|
+
tool: Pick<NormalizedTool, "input" | "output">,
|
|
26
|
+
messages: AgentMessages = en
|
|
27
|
+
): FileEditDescription {
|
|
28
|
+
const m = messages.edit
|
|
29
|
+
const path = stringField(tool.input, "path") ?? stringField(tool.output, "path") ?? ""
|
|
30
|
+
const name = fileName(path)
|
|
31
|
+
const diff = stringField(tool.output, "diff")
|
|
32
|
+
const lines = diff === undefined ? [] : parseDiff(diff)
|
|
33
|
+
|
|
34
|
+
// The diff is cut on a large edit, so the edit counts its lines; an output stored before it
|
|
35
|
+
// did carries only the diff.
|
|
36
|
+
const added =
|
|
37
|
+
numberField(tool.output, "added") ?? lines.filter((line) => line.kind === "added").length
|
|
38
|
+
const removed =
|
|
39
|
+
numberField(tool.output, "removed") ?? lines.filter((line) => line.kind === "removed").length
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
path,
|
|
43
|
+
title: m.title(name),
|
|
44
|
+
runningTitle: m.running(name),
|
|
45
|
+
failedTitle: m.failed(name),
|
|
46
|
+
...(diff === undefined ? {} : { detail: `+${added} −${removed}` }),
|
|
47
|
+
added,
|
|
48
|
+
removed,
|
|
49
|
+
lines,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function describeWrite(
|
|
54
|
+
tool: Pick<NormalizedTool, "input" | "output">,
|
|
55
|
+
messages: AgentMessages = en
|
|
56
|
+
): FileEditDescription {
|
|
57
|
+
const m = messages.write
|
|
58
|
+
const path = stringField(tool.input, "path") ?? stringField(tool.output, "path") ?? ""
|
|
59
|
+
const name = fileName(path)
|
|
60
|
+
const content = stringField(tool.input, "content")
|
|
61
|
+
const created = booleanField(tool.output, "created")
|
|
62
|
+
const lineCount = numberField(tool.output, "lines")
|
|
63
|
+
const lines: DiffLine[] =
|
|
64
|
+
content === undefined
|
|
65
|
+
? []
|
|
66
|
+
: contentLines(content).map((text) => ({ kind: "added" as const, text }))
|
|
67
|
+
return {
|
|
68
|
+
path,
|
|
69
|
+
title: created === false ? m.replaced(name) : m.created(name),
|
|
70
|
+
runningTitle: m.running(name),
|
|
71
|
+
failedTitle: m.failed(name),
|
|
72
|
+
...(lineCount === undefined ? {} : { detail: m.lines(lineCount) }),
|
|
73
|
+
added: lines.length,
|
|
74
|
+
removed: 0,
|
|
75
|
+
lines,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A unified diff's lines by kind; `… 3 more hunks` and anything unexpected are notes. */
|
|
80
|
+
export function parseDiff(diff: string): DiffLine[] {
|
|
81
|
+
const lines = diff.endsWith("\n") ? diff.slice(0, -1).split("\n") : diff.split("\n")
|
|
82
|
+
return lines.map((line): DiffLine => {
|
|
83
|
+
if (line.startsWith("@@")) return { kind: "hunk", text: line }
|
|
84
|
+
if (line.startsWith("+")) return { kind: "added", text: line.slice(1) }
|
|
85
|
+
if (line.startsWith("-")) return { kind: "removed", text: line.slice(1) }
|
|
86
|
+
if (line.startsWith(" ")) return { kind: "context", text: line.slice(1) }
|
|
87
|
+
return { kind: "note", text: line }
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const MAX_CONTENT_LINES = 400
|
|
92
|
+
|
|
93
|
+
function contentLines(content: string): string[] {
|
|
94
|
+
if (content === "") return []
|
|
95
|
+
const lines = (content.endsWith("\n") ? content.slice(0, -1) : content).split("\n")
|
|
96
|
+
return lines.length > MAX_CONTENT_LINES ? lines.slice(0, MAX_CONTENT_LINES) : lines
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function fileName(path: string): string {
|
|
100
|
+
return path.split("/").filter(Boolean).at(-1) ?? ""
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function stringField(value: unknown, key: string): string | undefined {
|
|
104
|
+
const field = isRecord(value) ? value[key] : undefined
|
|
105
|
+
return typeof field === "string" ? field : undefined
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function numberField(value: unknown, key: string): number | undefined {
|
|
109
|
+
const field = isRecord(value) ? value[key] : undefined
|
|
110
|
+
return typeof field === "number" && Number.isInteger(field) ? field : undefined
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function booleanField(value: unknown, key: string): boolean | undefined {
|
|
114
|
+
const field = isRecord(value) ? value[key] : undefined
|
|
115
|
+
return typeof field === "boolean" ? field : undefined
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
119
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
120
|
+
}
|
|
@@ -62,6 +62,8 @@ import {
|
|
|
62
62
|
preferenceWithReasoning,
|
|
63
63
|
resolveModelSelection,
|
|
64
64
|
} from "../model-selection"
|
|
65
|
+
import { openQuestion } from "../questions/interpret"
|
|
66
|
+
import type { QuestionComposerProps } from "../questions/question-composer"
|
|
65
67
|
import { type RequesterSettings, sendWithRequesterSettings } from "../requester-settings"
|
|
66
68
|
import {
|
|
67
69
|
CONTEXT_LIMIT_EXCEEDED,
|
|
@@ -1098,6 +1100,19 @@ export function useAgentConversation({
|
|
|
1098
1100
|
}
|
|
1099
1101
|
}, [computer, backgroundCommands, runsOnComputer, threadId])
|
|
1100
1102
|
|
|
1103
|
+
// The Agent's open question takes the composer's place until it is answered or set aside, to
|
|
1104
|
+
// reply in words of one's own.
|
|
1105
|
+
const [questionSetAside, setQuestionSetAside] = useState<string | null>(null)
|
|
1106
|
+
const asked = threadId !== null ? openQuestion(messages, turn) : null
|
|
1107
|
+
const asking = asked !== null && questionSetAside !== asked.messageKey ? asked : null
|
|
1108
|
+
const questionProps: QuestionComposerProps | null = asking
|
|
1109
|
+
? {
|
|
1110
|
+
questions: asking.questions,
|
|
1111
|
+
onAnswer: (text) => void send(text, [], []),
|
|
1112
|
+
onDismiss: () => setQuestionSetAside(asking.messageKey),
|
|
1113
|
+
}
|
|
1114
|
+
: null
|
|
1115
|
+
|
|
1101
1116
|
const transcriptProps: TranscriptProps = {
|
|
1102
1117
|
threadId,
|
|
1103
1118
|
messages,
|
|
@@ -1261,6 +1276,11 @@ export function useAgentConversation({
|
|
|
1261
1276
|
transcriptProps,
|
|
1262
1277
|
/** Spread into `<Composer>`, then add the page's own props such as `placeholder`. */
|
|
1263
1278
|
composerProps,
|
|
1279
|
+
/**
|
|
1280
|
+
* Spread into `<QuestionComposer>` while set, in the composer's place: the Agent's question,
|
|
1281
|
+
* until the reader answers it or sets it aside.
|
|
1282
|
+
*/
|
|
1283
|
+
questionProps,
|
|
1264
1284
|
/** Spread into `<SandboxRecovery>` while set: the composer stays disabled until it is resolved. */
|
|
1265
1285
|
sandboxRecoveryProps,
|
|
1266
1286
|
/** Where the reader's own conversation runs on their computer, for its badge. */
|
package/src/agent/i18n/en.ts
CHANGED
|
@@ -351,10 +351,8 @@ export const en = {
|
|
|
351
351
|
timeout: "Ran out of time",
|
|
352
352
|
unknown: "Delegated",
|
|
353
353
|
},
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
answer: "Agent answered",
|
|
357
|
-
answerHint: "Your next message answers it.",
|
|
354
|
+
/** A sub-agent's question its turn ended on while it held a call: the decision continued it. */
|
|
355
|
+
noAnswer: "It went on without an answer, once the approval was decided.",
|
|
358
356
|
close: "Close",
|
|
359
357
|
viewRequest: "See its request below",
|
|
360
358
|
stepsLater: "At work. Its steps show here once it finishes.",
|
|
@@ -386,6 +384,9 @@ export const en = {
|
|
|
386
384
|
heardFrom: (key: string) => `Heard back from ${key}`,
|
|
387
385
|
heardFromCount: (agents: number) => `Heard back from ${count(agents, "sub-agent")}`,
|
|
388
386
|
waitFailed: "Couldn't wait for the sub-agents",
|
|
387
|
+
stoppingAgent: (key: string) => `Stopping ${key}`,
|
|
388
|
+
stoppedAgent: (key: string) => `Stopped ${key}`,
|
|
389
|
+
stopAgentFailed: (key: string) => `Couldn't stop ${key}`,
|
|
389
390
|
askedAgent: (question: string) => `Asked the agent: ${question}`,
|
|
390
391
|
/** The reply's line: the sub-agents by name, and how they stand. */
|
|
391
392
|
line: {
|
|
@@ -466,6 +467,40 @@ export const en = {
|
|
|
466
467
|
failed: (name: string) => `Couldn't view ${name || "a file"}`,
|
|
467
468
|
open: (name: string) => `Open ${name}`,
|
|
468
469
|
},
|
|
470
|
+
/** The Agent's questions to the user, from its `ask` tool. */
|
|
471
|
+
questions: {
|
|
472
|
+
card: (count: number): string =>
|
|
473
|
+
count === 1 ? "The agent's question" : "The agent's questions",
|
|
474
|
+
asked: "Asked you",
|
|
475
|
+
/** For someone who reads the conversation but cannot answer in it. */
|
|
476
|
+
waiting: "Waiting for an answer",
|
|
477
|
+
running: "Asking you",
|
|
478
|
+
send: "Send answer",
|
|
479
|
+
sending: "Sending…",
|
|
480
|
+
pickAny: "Pick any",
|
|
481
|
+
typeAnswer: "Type an answer",
|
|
482
|
+
typeOther: "Or type another answer",
|
|
483
|
+
somethingElse: "Something else…",
|
|
484
|
+
next: "Next question",
|
|
485
|
+
back: "Previous question",
|
|
486
|
+
step: (step: number, total: number): string => `Question ${step} of ${total}`,
|
|
487
|
+
/** Close the question, to reply in the composer instead. */
|
|
488
|
+
dismiss: "Reply in chat",
|
|
489
|
+
},
|
|
490
|
+
/** The edit tool, for a change to part of a file (`name` may be empty). */
|
|
491
|
+
edit: {
|
|
492
|
+
title: (name: string) => `Edited ${name || "a file"}`,
|
|
493
|
+
running: (name: string) => `Editing ${name || "a file"}`,
|
|
494
|
+
failed: (name: string) => `Couldn't edit ${name || "a file"}`,
|
|
495
|
+
},
|
|
496
|
+
/** The write tool, for a file created or replaced whole (`name` may be empty). */
|
|
497
|
+
write: {
|
|
498
|
+
created: (name: string) => `Created ${name || "a file"}`,
|
|
499
|
+
replaced: (name: string) => `Rewrote ${name || "a file"}`,
|
|
500
|
+
running: (name: string) => `Writing ${name || "a file"}`,
|
|
501
|
+
failed: (name: string) => `Couldn't write ${name || "a file"}`,
|
|
502
|
+
lines: (lines: number) => count(lines, "line"),
|
|
503
|
+
},
|
|
469
504
|
/** The read tool, for a file (`name` may be empty), a skill reference, or a skill guide. */
|
|
470
505
|
read: {
|
|
471
506
|
file: {
|
|
@@ -484,6 +519,13 @@ export const en = {
|
|
|
484
519
|
failed: (name: string) => `Couldn't read the ${name} guide`,
|
|
485
520
|
},
|
|
486
521
|
/** A file of the user's memory, or of the project's when `project`. */
|
|
522
|
+
/** A folder the agent listed. */
|
|
523
|
+
directory: {
|
|
524
|
+
title: (name: string) => `Listed ${name || "a folder"}`,
|
|
525
|
+
running: (name: string) => `Listing ${name || "a folder"}`,
|
|
526
|
+
failed: (name: string) => `Couldn't list ${name || "a folder"}`,
|
|
527
|
+
},
|
|
528
|
+
entries: (entries: number) => count(entries, "entry", "entries"),
|
|
487
529
|
memory: {
|
|
488
530
|
title: (project: boolean): string => (project ? "Read project memory" : "Read memory"),
|
|
489
531
|
running: (project: boolean): string =>
|
|
@@ -776,7 +818,7 @@ export const en = {
|
|
|
776
818
|
publishing: (title: string) => `Publishing ${title || "an artifact"}`,
|
|
777
819
|
published: (title: string) => `Published ${title || "an artifact"}`,
|
|
778
820
|
publishFailed: (title: string) => `Couldn't publish ${title || "an artifact"}`,
|
|
779
|
-
/**
|
|
821
|
+
/** A `publish_artifact` call with an id, which changes an artifact's current version. */
|
|
780
822
|
updating: (title: string) => `Updating ${title || "an artifact"}`,
|
|
781
823
|
updated: (title: string) => `Updated ${title || "an artifact"}`,
|
|
782
824
|
updateFailed: (title: string) => `Couldn't update ${title || "an artifact"}`,
|
package/src/agent/i18n/fr.ts
CHANGED
|
@@ -334,10 +334,7 @@ export const fr: Translation<AgentMessages> = {
|
|
|
334
334
|
timeout: "Temps écoulé",
|
|
335
335
|
unknown: "Délégué",
|
|
336
336
|
},
|
|
337
|
-
|
|
338
|
-
asks: "A demandé",
|
|
339
|
-
answer: "L’agent a répondu",
|
|
340
|
-
answerHint: "Votre prochain message lui répond.",
|
|
337
|
+
noAnswer: "Il a continué sans réponse, une fois l’approbation décidée.",
|
|
341
338
|
close: "Fermer",
|
|
342
339
|
viewRequest: "Voir sa demande plus bas",
|
|
343
340
|
stepsLater: "En cours. Ses étapes s’afficheront ici une fois terminé.",
|
|
@@ -369,6 +366,9 @@ export const fr: Translation<AgentMessages> = {
|
|
|
369
366
|
heardFrom: (key) => `Réponse de ${key}`,
|
|
370
367
|
heardFromCount: (agents) => `Réponses de ${count(agents, "sous-agent")}`,
|
|
371
368
|
waitFailed: "Impossible d’attendre les sous-agents",
|
|
369
|
+
stoppingAgent: (key) => `Arrêt de ${key}`,
|
|
370
|
+
stoppedAgent: (key) => `${key} arrêté`,
|
|
371
|
+
stopAgentFailed: (key) => `Impossible d’arrêter ${key}`,
|
|
372
372
|
line: {
|
|
373
373
|
names: (names) =>
|
|
374
374
|
names.length <= 1
|
|
@@ -443,6 +443,35 @@ export const fr: Translation<AgentMessages> = {
|
|
|
443
443
|
name ? `Impossible de consulter ${name}` : "Impossible de consulter le fichier",
|
|
444
444
|
open: (name) => `Ouvrir ${name}`,
|
|
445
445
|
},
|
|
446
|
+
questions: {
|
|
447
|
+
card: (count) => (count === 1 ? "La question de l’agent" : "Les questions de l’agent"),
|
|
448
|
+
asked: "Vous a demandé",
|
|
449
|
+
waiting: "En attente d’une réponse",
|
|
450
|
+
running: "Vous pose une question",
|
|
451
|
+
send: "Envoyer la réponse",
|
|
452
|
+
sending: "Envoi…",
|
|
453
|
+
pickAny: "Plusieurs choix possibles",
|
|
454
|
+
typeAnswer: "Saisir une réponse",
|
|
455
|
+
typeOther: "Ou saisir une autre réponse",
|
|
456
|
+
somethingElse: "Autre chose…",
|
|
457
|
+
next: "Question suivante",
|
|
458
|
+
back: "Question précédente",
|
|
459
|
+
step: (step, total) => `Question ${step} sur ${total}`,
|
|
460
|
+
dismiss: "Répondre dans la conversation",
|
|
461
|
+
},
|
|
462
|
+
edit: {
|
|
463
|
+
title: (name) => (name ? `${name} modifié` : "Fichier modifié"),
|
|
464
|
+
running: (name) => (name ? `Modification de ${name}` : "Modification d’un fichier"),
|
|
465
|
+
failed: (name) =>
|
|
466
|
+
name ? `Impossible de modifier ${name}` : "Impossible de modifier le fichier",
|
|
467
|
+
},
|
|
468
|
+
write: {
|
|
469
|
+
created: (name) => (name ? `${name} créé` : "Fichier créé"),
|
|
470
|
+
replaced: (name) => (name ? `${name} réécrit` : "Fichier réécrit"),
|
|
471
|
+
running: (name) => (name ? `Écriture de ${name}` : "Écriture d’un fichier"),
|
|
472
|
+
failed: (name) => (name ? `Impossible d’écrire ${name}` : "Impossible d’écrire le fichier"),
|
|
473
|
+
lines: (lines) => count(lines, "ligne"),
|
|
474
|
+
},
|
|
446
475
|
read: {
|
|
447
476
|
file: {
|
|
448
477
|
title: (name) => (name ? `${name} lu` : "Fichier lu"),
|
|
@@ -459,6 +488,12 @@ export const fr: Translation<AgentMessages> = {
|
|
|
459
488
|
running: (name) => `Consultation du guide ${quoted(name)}`,
|
|
460
489
|
failed: (name) => `Impossible de lire le guide ${quoted(name)}`,
|
|
461
490
|
},
|
|
491
|
+
directory: {
|
|
492
|
+
title: (name) => (name ? `Contenu de ${name} listé` : "Dossier listé"),
|
|
493
|
+
running: (name) => (name ? `Liste du contenu de ${name}` : "Liste d’un dossier"),
|
|
494
|
+
failed: (name) => (name ? `Impossible de lister ${name}` : "Impossible de lister le dossier"),
|
|
495
|
+
},
|
|
496
|
+
entries: (entries) => count(entries, "élément"),
|
|
462
497
|
memory: {
|
|
463
498
|
title: (project) => (project ? "Mémoire du projet consultée" : "Mémoire consultée"),
|
|
464
499
|
running: (project) =>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentMessages } from "../i18n/en"
|
|
2
2
|
import { type NormalizedTool, toolResultValue } from "../parts"
|
|
3
|
+
import { waitsForChildren } from "../waits"
|
|
3
4
|
|
|
4
5
|
export interface MessageAgentDescription {
|
|
5
6
|
/** The row's title: what the Agent told which child, or that it could not. */
|
|
@@ -8,7 +9,7 @@ export interface MessageAgentDescription {
|
|
|
8
9
|
readonly running: string
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
/** A question a child waits on, as `
|
|
12
|
+
/** A question a child waits on, as `wait` returned it. */
|
|
12
13
|
export interface ChildQuestion {
|
|
13
14
|
readonly key: string
|
|
14
15
|
readonly text: string
|
|
@@ -42,9 +43,9 @@ export function describeMessageAgent(
|
|
|
42
43
|
return { title: messaging, running: messaging }
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
/** The questions a `
|
|
46
|
+
/** The questions a `wait` call returned: the children that wait on the Agent's answer. */
|
|
46
47
|
export function childQuestions(tool: NormalizedTool): readonly ChildQuestion[] {
|
|
47
|
-
if (tool
|
|
48
|
+
if (!waitsForChildren(tool) || tool.state !== "output-available") return []
|
|
48
49
|
|
|
49
50
|
const output = toolResultValue(tool.output)
|
|
50
51
|
if (!isRecord(output) || !Array.isArray(output.questions)) return []
|