@sixb/app 0.2.3 → 0.2.5
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.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/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +8 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.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/conversation.d.ts +3 -6
- package/dist/agent/conversation.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 +9 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.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 +16 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +114 -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 +190 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.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/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.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/card-preview.d.ts.map +1 -1
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +278 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.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/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.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/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/messages.d.ts +6 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages.js +12 -5
- package/dist/pages.js.map +6 -6
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +9 -1
- package/src/agent/agent-chat.tsx +57 -37
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +96 -37
- package/src/agent/components/message-parts.tsx +390 -64
- package/src/agent/components/message-view.tsx +12 -2
- package/src/agent/components/pending-messages.tsx +338 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +92 -45
- package/src/agent/conversation.ts +203 -54
- 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 +64 -61
- 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 +360 -92
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +134 -16
- package/src/agent/i18n/fr.ts +122 -16
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- 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/react-router.tsx +2 -2
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +33 -6
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +7 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +434 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +14 -5
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +4 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +192 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- 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/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +101 -41
- package/src/index.ts +8 -0
- package/src/pages/console/data/messages.ts +6 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-001c4gnk.js.map +0 -204
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { AgentConversationMessage, AgentConversationTurn } from "../conversation"
|
|
2
|
+
|
|
3
|
+
/** One question of an `ask` call, as the card shows it. */
|
|
4
|
+
export interface AskedQuestion {
|
|
5
|
+
readonly question: string
|
|
6
|
+
readonly choices: readonly string[]
|
|
7
|
+
/** Several of the choices may be picked. */
|
|
8
|
+
readonly multiple: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The tools an agent asks with: `ask`, and a sub-agent's `ask_parent` in earlier threads. */
|
|
12
|
+
export function isAskTool(toolName: string): boolean {
|
|
13
|
+
return toolName === "ask" || toolName === "ask_parent"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The questions of an `ask` call's input, or of an `ask_parent` call's `{ question }`. */
|
|
17
|
+
export function askedQuestions(input: unknown): readonly AskedQuestion[] {
|
|
18
|
+
if (!isRecord(input)) return []
|
|
19
|
+
if (typeof input.question === "string" && input.question.trim()) {
|
|
20
|
+
return [{ question: input.question.trim(), choices: [], multiple: false }]
|
|
21
|
+
}
|
|
22
|
+
if (!Array.isArray(input.questions)) return []
|
|
23
|
+
return input.questions.flatMap((value): AskedQuestion[] => {
|
|
24
|
+
if (!isRecord(value) || typeof value.question !== "string" || !value.question.trim()) return []
|
|
25
|
+
const choices = Array.isArray(value.choices)
|
|
26
|
+
? value.choices.filter((choice): choice is string => typeof choice === "string" && !!choice)
|
|
27
|
+
: []
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
question: value.question.trim(),
|
|
31
|
+
choices,
|
|
32
|
+
multiple: value.multiple === true && choices.length > 0,
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The questions as one line, for a row that names them: `Which year? · Which regions?`. */
|
|
39
|
+
export function askedText(input: unknown): string {
|
|
40
|
+
return askedQuestions(input)
|
|
41
|
+
.map((question) => question.question)
|
|
42
|
+
.join(" · ")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The user's answer as the message the card sends: the picked choices or the typed text, and with
|
|
47
|
+
* several questions each answer after its question. Unanswered questions are left out; empty when
|
|
48
|
+
* nothing was answered.
|
|
49
|
+
*/
|
|
50
|
+
export function answerText(
|
|
51
|
+
questions: readonly AskedQuestion[],
|
|
52
|
+
answers: readonly (readonly string[])[]
|
|
53
|
+
): string {
|
|
54
|
+
const answered = questions.flatMap((question, index) => {
|
|
55
|
+
const picked = (answers[index] ?? []).map((answer) => answer.trim()).filter(Boolean)
|
|
56
|
+
return picked.length > 0 ? [{ question: question.question, answer: picked.join(", ") }] : []
|
|
57
|
+
})
|
|
58
|
+
if (questions.length === 1) return answered[0]?.answer ?? ""
|
|
59
|
+
return answered.map(({ question, answer }) => `${question} ${answer}`).join("\n")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The questions the conversation's last word asks the user, and the reply that asked them. */
|
|
63
|
+
export interface OpenQuestion {
|
|
64
|
+
readonly messageKey: string
|
|
65
|
+
readonly questions: readonly AskedQuestion[]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* What still waits for the user: the questions of the conversation's last message, a reply that
|
|
70
|
+
* asked, once its turn ended. A later message answers it, and a running turn has not asked yet.
|
|
71
|
+
*/
|
|
72
|
+
export function openQuestion(
|
|
73
|
+
messages: readonly AgentConversationMessage[],
|
|
74
|
+
turn: AgentConversationTurn
|
|
75
|
+
): OpenQuestion | null {
|
|
76
|
+
if (turn.kind === "responding") return null
|
|
77
|
+
const last = messages.at(-1)
|
|
78
|
+
if (last?.role !== "assistant") return null
|
|
79
|
+
const asked = last.parts.filter(
|
|
80
|
+
(part) => part.type === "tool" && part.toolName === "ask" && part.state === "output-available"
|
|
81
|
+
)
|
|
82
|
+
const questions = asked.flatMap((part) =>
|
|
83
|
+
part.type === "tool" ? askedQuestions(part.input) : []
|
|
84
|
+
)
|
|
85
|
+
return questions.length > 0 ? { messageKey: last.key, questions } : null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
89
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
90
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { MessageCircleQuestion } from "lucide-react"
|
|
2
|
+
import { createContext, useContext } from "react"
|
|
3
|
+
import { ACTIVITY_STATUS_ROW_CLASS_NAME } from "../components/activity-status"
|
|
4
|
+
import { useAgentMessages } from "../i18n"
|
|
5
|
+
import type { NormalizedTool } from "../parts"
|
|
6
|
+
import { askedQuestions } from "./interpret"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether the reply a line is in asks the reader now: its question is the conversation's last word,
|
|
10
|
+
* answered in the composer, which becomes the question (`QuestionComposer`). `answering` when the
|
|
11
|
+
* reader may answer there; otherwise, as for an observer, someone else's answer is awaited.
|
|
12
|
+
*/
|
|
13
|
+
export interface QuestionTurn {
|
|
14
|
+
readonly open: boolean
|
|
15
|
+
readonly answering?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const QuestionTurnContext = createContext<QuestionTurn>({ open: false })
|
|
19
|
+
|
|
20
|
+
/** The Agent's questions in its reply: a quiet line each, the composer asks them. */
|
|
21
|
+
export function QuestionCards({ tools }: { readonly tools: readonly NormalizedTool[] }) {
|
|
22
|
+
if (tools.length === 0) return null
|
|
23
|
+
return (
|
|
24
|
+
<div className="flex flex-col gap-3">
|
|
25
|
+
{tools.map((tool, index) => (
|
|
26
|
+
// A reply's calls never reorder: their order is their identity.
|
|
27
|
+
<QuestionLine key={index} tool={tool} />
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function QuestionLine({ tool }: { readonly tool: NormalizedTool }) {
|
|
34
|
+
const turn = useContext(QuestionTurnContext)
|
|
35
|
+
const messages = useAgentMessages().questions
|
|
36
|
+
const questions = askedQuestions(tool.input)
|
|
37
|
+
if (questions.length === 0) return null
|
|
38
|
+
|
|
39
|
+
// While the reader may answer, the composer is the question: the reply leaves it to the composer.
|
|
40
|
+
if (turn.open && turn.answering) return null
|
|
41
|
+
const label = turn.open ? messages.waiting : messages.asked
|
|
42
|
+
return (
|
|
43
|
+
<div className="min-w-0">
|
|
44
|
+
<p className={ACTIVITY_STATUS_ROW_CLASS_NAME}>
|
|
45
|
+
<MessageCircleQuestion className="size-3.5 shrink-0" />
|
|
46
|
+
<span className="min-w-0 truncate font-medium">{label}</span>
|
|
47
|
+
</p>
|
|
48
|
+
<ul className="mt-1 space-y-0.5 pl-5 text-[13px] text-muted-foreground">
|
|
49
|
+
{questions.map((question) => (
|
|
50
|
+
<li key={question.question} className="break-words">
|
|
51
|
+
{question.question}
|
|
52
|
+
</li>
|
|
53
|
+
))}
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
2
|
+
import { ArrowUp, Check, ChevronLeft, X } from "lucide-react"
|
|
3
|
+
import { useEffect, useRef, useState } from "react"
|
|
4
|
+
import { useAgentMessages } from "../i18n"
|
|
5
|
+
import { type AskedQuestion, answerText } from "./interpret"
|
|
6
|
+
|
|
7
|
+
export interface QuestionComposerProps {
|
|
8
|
+
readonly questions: readonly AskedQuestion[]
|
|
9
|
+
readonly onAnswer: (text: string) => void
|
|
10
|
+
/** Back to the composer, to reply in words of one's own. */
|
|
11
|
+
readonly onDismiss: () => void
|
|
12
|
+
readonly className?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The composer, become the Agent's question: the same surface in the same place, its questions one
|
|
17
|
+
* at a time, each choice a row to pick and a last row to write something else. Picking the one
|
|
18
|
+
* answer of the last question sends; several questions send together from the last.
|
|
19
|
+
*/
|
|
20
|
+
export function QuestionComposer({
|
|
21
|
+
questions,
|
|
22
|
+
onAnswer,
|
|
23
|
+
onDismiss,
|
|
24
|
+
className,
|
|
25
|
+
}: QuestionComposerProps) {
|
|
26
|
+
const messages = useAgentMessages().questions
|
|
27
|
+
const [step, setStep] = useState(0)
|
|
28
|
+
const [answers, setAnswers] = useState<readonly (readonly string[])[]>(() =>
|
|
29
|
+
questions.map(() => [])
|
|
30
|
+
)
|
|
31
|
+
const [other, setOther] = useState("")
|
|
32
|
+
const [sent, setSent] = useState(false)
|
|
33
|
+
const rows = useRef<HTMLDivElement>(null)
|
|
34
|
+
|
|
35
|
+
const question = questions[step]
|
|
36
|
+
const last = step === questions.length - 1
|
|
37
|
+
const picked = answers[step] ?? []
|
|
38
|
+
|
|
39
|
+
// Each question starts on its first choice, ready for the keyboard.
|
|
40
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new step moves the focus
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
rows.current?.querySelector<HTMLButtonElement>("[data-choice]")?.focus({ preventScroll: true })
|
|
43
|
+
}, [step])
|
|
44
|
+
|
|
45
|
+
if (!question) return null
|
|
46
|
+
|
|
47
|
+
const finish = (next: readonly (readonly string[])[]) => {
|
|
48
|
+
const text = answerText(questions, next)
|
|
49
|
+
if (!text || sent) return
|
|
50
|
+
setSent(true)
|
|
51
|
+
onAnswer(text)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const commit = (answer: readonly string[]) => {
|
|
55
|
+
const next = answers.map((entry, index) => (index === step ? answer : entry))
|
|
56
|
+
setAnswers(next)
|
|
57
|
+
setOther("")
|
|
58
|
+
if (last) finish(next)
|
|
59
|
+
else setStep(step + 1)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const choose = (choice: string) => {
|
|
63
|
+
if (!question.multiple) return commit([choice])
|
|
64
|
+
setAnswers((current) =>
|
|
65
|
+
current.map((entry, index) =>
|
|
66
|
+
index !== step
|
|
67
|
+
? entry
|
|
68
|
+
: entry.includes(choice)
|
|
69
|
+
? entry.filter((value) => value !== choice)
|
|
70
|
+
: [...entry, choice]
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const writeOther = () => {
|
|
76
|
+
const text = other.trim()
|
|
77
|
+
if (!text) return
|
|
78
|
+
commit(question.multiple ? [...picked, text] : [text])
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className={cn("relative bg-background px-4 pt-2 pb-3", className)}>
|
|
83
|
+
<div className="mx-auto w-full max-w-[46rem]">
|
|
84
|
+
<section
|
|
85
|
+
aria-label={messages.card(questions.length)}
|
|
86
|
+
aria-busy={sent}
|
|
87
|
+
onKeyDown={(event) => {
|
|
88
|
+
if (event.key === "Escape") {
|
|
89
|
+
event.preventDefault()
|
|
90
|
+
onDismiss()
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
if (event.target instanceof HTMLInputElement) return
|
|
94
|
+
const number = Number(event.key)
|
|
95
|
+
const choice = Number.isInteger(number) ? question.choices[number - 1] : undefined
|
|
96
|
+
if (choice !== undefined) {
|
|
97
|
+
event.preventDefault()
|
|
98
|
+
choose(choice)
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
102
|
+
event.preventDefault()
|
|
103
|
+
const all = [...(rows.current?.querySelectorAll<HTMLElement>("[data-row]") ?? [])]
|
|
104
|
+
const at = all.indexOf(document.activeElement as HTMLElement)
|
|
105
|
+
const to =
|
|
106
|
+
event.key === "ArrowDown" ? Math.min(all.length - 1, at + 1) : Math.max(0, at - 1)
|
|
107
|
+
all[to]?.focus()
|
|
108
|
+
}
|
|
109
|
+
}}
|
|
110
|
+
className={cn(
|
|
111
|
+
"sixb-composer-surface relative rounded-[26px] p-2",
|
|
112
|
+
"motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-3 motion-safe:duration-300 motion-safe:ease-out"
|
|
113
|
+
)}
|
|
114
|
+
>
|
|
115
|
+
{/* The question, where it stands among the others, and the way back to the composer. */}
|
|
116
|
+
<div className="flex items-start gap-2 px-3 pt-2.5 pb-2">
|
|
117
|
+
{step > 0 ? (
|
|
118
|
+
<button
|
|
119
|
+
type="button"
|
|
120
|
+
onClick={() => setStep(step - 1)}
|
|
121
|
+
aria-label={messages.back}
|
|
122
|
+
className="-ml-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-black/[0.05] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 dark:hover:bg-white/[0.08]"
|
|
123
|
+
>
|
|
124
|
+
<ChevronLeft className="size-4" />
|
|
125
|
+
</button>
|
|
126
|
+
) : null}
|
|
127
|
+
<div className="min-w-0 flex-1">
|
|
128
|
+
<h3
|
|
129
|
+
key={step}
|
|
130
|
+
className="text-[15px] leading-snug font-medium tracking-[-0.01em] text-foreground motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200"
|
|
131
|
+
>
|
|
132
|
+
{question.question}
|
|
133
|
+
</h3>
|
|
134
|
+
{question.multiple ? (
|
|
135
|
+
<p className="mt-0.5 text-xs text-muted-foreground">{messages.pickAny}</p>
|
|
136
|
+
) : null}
|
|
137
|
+
</div>
|
|
138
|
+
{questions.length > 1 ? (
|
|
139
|
+
<span
|
|
140
|
+
className="mt-1.5 flex shrink-0 items-center gap-1"
|
|
141
|
+
aria-label={messages.step(step + 1, questions.length)}
|
|
142
|
+
>
|
|
143
|
+
{questions.map((entry, index) => (
|
|
144
|
+
<span
|
|
145
|
+
key={entry.question}
|
|
146
|
+
className={cn(
|
|
147
|
+
"size-1.5 rounded-full transition-colors duration-200",
|
|
148
|
+
index === step
|
|
149
|
+
? "bg-foreground"
|
|
150
|
+
: index < step
|
|
151
|
+
? "bg-foreground/40"
|
|
152
|
+
: "bg-foreground/15"
|
|
153
|
+
)}
|
|
154
|
+
/>
|
|
155
|
+
))}
|
|
156
|
+
</span>
|
|
157
|
+
) : null}
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
onClick={onDismiss}
|
|
161
|
+
aria-label={messages.dismiss}
|
|
162
|
+
title={messages.dismiss}
|
|
163
|
+
className="-mt-0.5 -mr-1 flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-black/[0.05] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 dark:hover:bg-white/[0.08]"
|
|
164
|
+
>
|
|
165
|
+
<X className="size-4" />
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div
|
|
170
|
+
ref={rows}
|
|
171
|
+
key={step}
|
|
172
|
+
className="flex flex-col gap-0.5 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200"
|
|
173
|
+
>
|
|
174
|
+
{question.choices.map((choice, index) => {
|
|
175
|
+
const selected = picked.includes(choice)
|
|
176
|
+
return (
|
|
177
|
+
<button
|
|
178
|
+
key={choice}
|
|
179
|
+
type="button"
|
|
180
|
+
data-row=""
|
|
181
|
+
data-choice=""
|
|
182
|
+
aria-pressed={question.multiple ? selected : undefined}
|
|
183
|
+
disabled={sent}
|
|
184
|
+
onClick={() => choose(choice)}
|
|
185
|
+
className={cn(
|
|
186
|
+
"group/choice flex min-h-11 w-full items-center gap-3 rounded-[18px] px-3 text-left text-[15px] text-foreground outline-none transition-colors",
|
|
187
|
+
"hover:bg-black/[0.04] focus-visible:bg-black/[0.05] dark:hover:bg-white/[0.06] dark:focus-visible:bg-white/[0.08]",
|
|
188
|
+
selected && "bg-black/[0.05] dark:bg-white/[0.08]"
|
|
189
|
+
)}
|
|
190
|
+
>
|
|
191
|
+
<span
|
|
192
|
+
aria-hidden="true"
|
|
193
|
+
className={cn(
|
|
194
|
+
"flex size-6 shrink-0 items-center justify-center rounded-[7px] text-xs font-medium tabular-nums transition-colors",
|
|
195
|
+
selected
|
|
196
|
+
? "bg-foreground text-background"
|
|
197
|
+
: "bg-black/[0.05] text-muted-foreground group-hover/choice:text-foreground dark:bg-white/[0.08]"
|
|
198
|
+
)}
|
|
199
|
+
>
|
|
200
|
+
{selected ? <Check className="size-3.5" strokeWidth={2.5} /> : index + 1}
|
|
201
|
+
</span>
|
|
202
|
+
<span className="min-w-0 flex-1 break-words">{choice}</span>
|
|
203
|
+
</button>
|
|
204
|
+
)
|
|
205
|
+
})}
|
|
206
|
+
|
|
207
|
+
{/* Something else, in words: the composer's own field and send button, in a row. */}
|
|
208
|
+
<div
|
|
209
|
+
className={cn(
|
|
210
|
+
"flex min-h-11 items-center gap-3 rounded-[18px] pr-1 pl-3",
|
|
211
|
+
question.choices.length > 0 && "mt-0.5"
|
|
212
|
+
)}
|
|
213
|
+
>
|
|
214
|
+
{question.choices.length > 0 ? (
|
|
215
|
+
<span aria-hidden="true" className="size-6 shrink-0" />
|
|
216
|
+
) : null}
|
|
217
|
+
<input
|
|
218
|
+
data-row=""
|
|
219
|
+
type="text"
|
|
220
|
+
value={other}
|
|
221
|
+
disabled={sent}
|
|
222
|
+
aria-label={messages.typeAnswer}
|
|
223
|
+
placeholder={
|
|
224
|
+
question.choices.length > 0 ? messages.somethingElse : messages.typeAnswer
|
|
225
|
+
}
|
|
226
|
+
onChange={(event) => setOther(event.target.value)}
|
|
227
|
+
onKeyDown={(event) => {
|
|
228
|
+
if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
229
|
+
event.preventDefault()
|
|
230
|
+
if (other.trim()) writeOther()
|
|
231
|
+
else if (question.multiple && picked.length > 0) commit(picked)
|
|
232
|
+
}
|
|
233
|
+
}}
|
|
234
|
+
className="h-10 min-w-0 flex-1 bg-transparent text-[15px] text-foreground outline-none placeholder:text-muted-foreground/70"
|
|
235
|
+
/>
|
|
236
|
+
{question.multiple || other.trim() || question.choices.length === 0 ? (
|
|
237
|
+
<button
|
|
238
|
+
type="button"
|
|
239
|
+
disabled={sent || (!other.trim() && picked.length === 0)}
|
|
240
|
+
onClick={() => (other.trim() ? writeOther() : commit(picked))}
|
|
241
|
+
aria-label={last ? messages.send : messages.next}
|
|
242
|
+
className={cn(
|
|
243
|
+
"sixb-composer-send flex size-9 shrink-0 items-center justify-center rounded-full outline-none transition-colors",
|
|
244
|
+
"bg-foreground text-background hover:bg-foreground/85 focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
245
|
+
"disabled:bg-foreground/25 dark:disabled:bg-white/20 dark:disabled:text-white/70"
|
|
246
|
+
)}
|
|
247
|
+
>
|
|
248
|
+
<ArrowUp className={cn("size-4", !last && "rotate-90")} strokeWidth={2.25} />
|
|
249
|
+
</button>
|
|
250
|
+
) : null}
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</section>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
@@ -46,9 +46,9 @@ export function AgentChatPage({
|
|
|
46
46
|
// biome-ignore lint/correctness/useExhaustiveDependencies: the key stands for the parameters.
|
|
47
47
|
const artifactTarget = useMemo(() => artifactTargetFromSearch(searchParams), [searchKey])
|
|
48
48
|
const onArtifactTargetChange = useCallback(
|
|
49
|
-
(target: ArtifactTarget | null) => {
|
|
49
|
+
(target: ArtifactTarget | null, options?: { readonly replace?: boolean }) => {
|
|
50
50
|
setSearchParams((current) => withArtifactTarget(current, target), {
|
|
51
|
-
replace: target === null,
|
|
51
|
+
replace: options?.replace ?? target === null,
|
|
52
52
|
})
|
|
53
53
|
},
|
|
54
54
|
[setSearchParams]
|
|
@@ -15,6 +15,13 @@ export interface ReadOutput {
|
|
|
15
15
|
readonly nextOffset?: number
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** A folder `read` listed: its entries, folders ending in `/`. */
|
|
19
|
+
export interface ReadDirectory {
|
|
20
|
+
readonly path: string
|
|
21
|
+
readonly entries: readonly string[]
|
|
22
|
+
readonly truncated: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
export interface ReadDescription {
|
|
19
26
|
readonly path: string
|
|
20
27
|
readonly title: string
|
|
@@ -55,12 +62,38 @@ export function coerceReadOutput(value: unknown): ReadOutput | null {
|
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
export function coerceReadDirectory(value: unknown): ReadDirectory | null {
|
|
66
|
+
if (
|
|
67
|
+
!isRecord(value) ||
|
|
68
|
+
typeof value.path !== "string" ||
|
|
69
|
+
!Array.isArray(value.entries) ||
|
|
70
|
+
!value.entries.every((entry) => typeof entry === "string")
|
|
71
|
+
) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
return { path: value.path, entries: value.entries, truncated: value.truncated === true }
|
|
75
|
+
}
|
|
76
|
+
|
|
58
77
|
export function describeRead(
|
|
59
78
|
input: ReadInput | null,
|
|
60
79
|
output: ReadOutput | null,
|
|
61
|
-
messages: AgentMessages = en
|
|
80
|
+
messages: AgentMessages = en,
|
|
81
|
+
directory: ReadDirectory | null = null
|
|
62
82
|
): ReadDescription {
|
|
63
83
|
const m = messages.read
|
|
84
|
+
if (directory) {
|
|
85
|
+
const name = fileName(directory.path)
|
|
86
|
+
const entries = m.entries(directory.entries.length)
|
|
87
|
+
return {
|
|
88
|
+
path: directory.path,
|
|
89
|
+
title: m.directory.title(name),
|
|
90
|
+
runningTitle: m.directory.running(name),
|
|
91
|
+
failedTitle: m.directory.failed(name),
|
|
92
|
+
detail: directory.truncated ? m.moreAvailable(entries) : entries,
|
|
93
|
+
skill: false,
|
|
94
|
+
memory: false,
|
|
95
|
+
}
|
|
96
|
+
}
|
|
64
97
|
const path = output?.path ?? input?.path ?? ""
|
|
65
98
|
const memory = memoryFile(path)
|
|
66
99
|
if (memory !== null) {
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@sixb/ui/components"
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Bookmark,
|
|
4
|
+
BookOpen,
|
|
5
|
+
ChevronRight,
|
|
6
|
+
FileText,
|
|
7
|
+
FolderOpen,
|
|
8
|
+
type LucideIcon,
|
|
9
|
+
} from "lucide-react"
|
|
3
10
|
import { ActivityStatusText } from "../components/activity-status"
|
|
4
11
|
import { useAgentMessages } from "../i18n"
|
|
5
12
|
import type { NormalizedTool } from "../parts"
|
|
6
|
-
import { coerceReadInput, coerceReadOutput, describeRead } from "./interpret"
|
|
13
|
+
import { coerceReadDirectory, coerceReadInput, coerceReadOutput, describeRead } from "./interpret"
|
|
7
14
|
|
|
8
15
|
export function ReadToolView({ tool }: { tool: NormalizedTool }) {
|
|
9
16
|
const messages = useAgentMessages()
|
|
10
17
|
const input = coerceReadInput(tool.input)
|
|
11
18
|
const output = coerceReadOutput(tool.output)
|
|
12
|
-
const
|
|
19
|
+
const directory = coerceReadDirectory(tool.output)
|
|
20
|
+
const description = describeRead(input, output, messages, directory)
|
|
13
21
|
const running = tool.state === "input-streaming" || tool.state === "input-available"
|
|
14
22
|
const error = tool.state === "output-error"
|
|
15
|
-
const Icon =
|
|
23
|
+
const Icon = directory
|
|
24
|
+
? FolderOpen
|
|
25
|
+
: description.memory
|
|
26
|
+
? Bookmark
|
|
27
|
+
: description.skill
|
|
28
|
+
? BookOpen
|
|
29
|
+
: FileText
|
|
16
30
|
const label = error
|
|
17
31
|
? description.failedTitle
|
|
18
32
|
: running
|
|
@@ -44,6 +58,8 @@ export function ReadToolView({ tool }: { tool: NormalizedTool }) {
|
|
|
44
58
|
) : null}
|
|
45
59
|
{error ? (
|
|
46
60
|
<ReadBlock value={tool.errorText?.trim() || messages.read.error} />
|
|
61
|
+
) : directory ? (
|
|
62
|
+
<ReadBlock value={directory.entries.join("\n")} />
|
|
47
63
|
) : output?.content ? (
|
|
48
64
|
<ReadBlock value={output.content} />
|
|
49
65
|
) : output ? (
|