@sixb/app 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -8
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +9 -8
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts +5 -8
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/agents-page.d.ts +4 -0
- package/dist/agent/agents-page.d.ts.map +1 -0
- package/dist/agent/artifact-card.d.ts +9 -0
- package/dist/agent/artifact-card.d.ts.map +1 -0
- package/dist/agent/artifact-panel-state.d.ts +16 -0
- package/dist/agent/artifact-panel-state.d.ts.map +1 -0
- package/dist/agent/artifact-panel.d.ts +38 -0
- package/dist/agent/artifact-panel.d.ts.map +1 -0
- package/dist/agent/components/file-attachment-card.d.ts +3 -3
- package/dist/agent/components/file-attachment-card.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 +3 -3
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/thread-artifacts-menu.d.ts +8 -0
- package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +3 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +10 -49
- 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 +16 -98
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/parts.d.ts +4 -4
- package/dist/agent/parts.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +32 -0
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -0
- package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +9 -0
- package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -0
- package/dist/agent/publish-artifact/use-live-publishes.d.ts +10 -0
- package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -0
- package/dist/agent/react-router.d.ts +1 -2
- package/dist/agent/react-router.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/artifacts/artifact-page.d.ts +7 -0
- package/dist/artifacts/artifact-page.d.ts.map +1 -0
- package/dist/artifacts/card-details.d.ts +15 -0
- package/dist/artifacts/card-details.d.ts.map +1 -0
- package/dist/artifacts/card-preview.d.ts +59 -0
- package/dist/artifacts/card-preview.d.ts.map +1 -0
- package/dist/artifacts/copy-feedback.d.ts +6 -0
- package/dist/artifacts/copy-feedback.d.ts.map +1 -0
- package/dist/artifacts/file-size.d.ts +11 -0
- package/dist/artifacts/file-size.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +45 -0
- package/dist/artifacts/file-source.d.ts.map +1 -0
- package/dist/artifacts/file-view.d.ts +9 -0
- package/dist/artifacts/file-view.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +45 -0
- package/dist/artifacts/frame.d.ts.map +1 -0
- package/dist/artifacts/gallery.d.ts +6 -0
- package/dist/artifacts/gallery.d.ts.map +1 -0
- package/dist/artifacts/kind-icon.d.ts +8 -0
- package/dist/artifacts/kind-icon.d.ts.map +1 -0
- package/dist/artifacts/markdown-tree.d.ts +22 -0
- package/dist/artifacts/markdown-tree.d.ts.map +1 -0
- package/dist/artifacts/messages.d.ts +301 -0
- package/dist/artifacts/messages.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +21 -0
- package/dist/artifacts/queries.d.ts.map +1 -0
- package/dist/artifacts/references/embed-tree.d.ts +17 -0
- package/dist/artifacts/references/embed-tree.d.ts.map +1 -0
- package/dist/artifacts/references/references.d.ts +50 -0
- package/dist/artifacts/references/references.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +11 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -0
- package/dist/artifacts/renderers/document.d.ts +17 -0
- package/dist/artifacts/renderers/document.d.ts.map +1 -0
- package/dist/artifacts/renderers/file.d.ts +10 -0
- package/dist/artifacts/renderers/file.d.ts.map +1 -0
- package/dist/artifacts/renderers/notice.d.ts +12 -0
- package/dist/artifacts/renderers/notice.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/chart-data.d.ts +33 -0
- package/dist/artifacts/renderers/sheet/chart-data.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/chart.d.ts +15 -0
- package/dist/artifacts/renderers/sheet/chart.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/format.d.ts +35 -0
- package/dist/artifacts/renderers/sheet/format.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/grid.d.ts +25 -0
- package/dist/artifacts/renderers/sheet/grid.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/mini-chart.d.ts +7 -0
- package/dist/artifacts/renderers/sheet/mini-chart.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/model.d.ts +29 -0
- package/dist/artifacts/renderers/sheet/model.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/selection.d.ts +42 -0
- package/dist/artifacts/renderers/sheet/selection.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/sheet.d.ts +17 -0
- package/dist/artifacts/renderers/sheet/sheet.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/virtual.d.ts +13 -0
- package/dist/artifacts/renderers/sheet/virtual.d.ts.map +1 -0
- package/dist/artifacts/renderers/sheet/workbook.d.ts +24 -0
- package/dist/artifacts/renderers/sheet/workbook.d.ts.map +1 -0
- package/dist/artifacts/renderers/slides/navigation.d.ts +17 -0
- package/dist/artifacts/renderers/slides/navigation.d.ts.map +1 -0
- package/dist/artifacts/renderers/slides/slides.d.ts +14 -0
- package/dist/artifacts/renderers/slides/slides.d.ts.map +1 -0
- package/dist/artifacts/target.d.ts +29 -0
- package/dist/artifacts/target.d.ts.map +1 -0
- package/dist/artifacts/theme.d.ts +18 -0
- package/dist/artifacts/theme.d.ts.map +1 -0
- package/dist/artifacts/viewer.d.ts +19 -0
- package/dist/artifacts/viewer.d.ts.map +1 -0
- package/dist/{chunk-shmw3f8t.js → chunk-3schcf10.js} +1 -1
- package/dist/chunk-c7gy61rx.js +276 -0
- package/dist/chunk-c7gy61rx.js.map +10 -0
- package/dist/{chunk-48pkffj6.js → chunk-g3f4cm8x.js} +1 -1
- package/dist/{chunk-zcxrt24m.js → chunk-gn3k23q5.js} +3 -2
- package/dist/{chunk-zcxrt24m.js.map → chunk-gn3k23q5.js.map} +3 -3
- package/dist/{chunk-3a99tmwg.js → chunk-ng0hdnrq.js} +10 -3
- package/dist/chunk-ng0hdnrq.js.map +10 -0
- package/dist/{chunk-j97e06rg.js → chunk-xxpdn63v.js} +7224 -2874
- package/dist/chunk-xxpdn63v.js.map +105 -0
- package/dist/codegen.d.ts +2 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -31
- package/dist/index.js.map +7 -7
- package/dist/locale-messages.d.ts +2 -0
- package/dist/locale-messages.d.ts.map +1 -1
- package/dist/locale.d.ts +2 -0
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +1 -1
- package/dist/pages/observability/activity/calendar.d.ts +9 -0
- package/dist/pages/observability/activity/calendar.d.ts.map +1 -0
- package/dist/pages/observability/activity/connections.d.ts +7 -0
- package/dist/pages/observability/activity/connections.d.ts.map +1 -0
- package/dist/pages/observability/activity/format.d.ts +11 -0
- package/dist/pages/observability/activity/format.d.ts.map +1 -0
- package/dist/pages/observability/activity/messages.d.ts +231 -0
- package/dist/pages/observability/activity/messages.d.ts.map +1 -0
- package/dist/pages/observability/activity/meta-items.d.ts +10 -0
- package/dist/pages/observability/activity/meta-items.d.ts.map +1 -0
- package/dist/pages/observability/activity/page.d.ts +6 -0
- package/dist/pages/observability/activity/page.d.ts.map +1 -0
- package/dist/pages/observability/activity/period.d.ts +31 -0
- package/dist/pages/observability/activity/period.d.ts.map +1 -0
- package/dist/pages/observability/activity/steps.d.ts +44 -0
- package/dist/pages/observability/activity/steps.d.ts.map +1 -0
- package/dist/pages/observability/activity/timeline.d.ts +36 -0
- package/dist/pages/observability/activity/timeline.d.ts.map +1 -0
- package/dist/pages/observability/activity/users.d.ts +18 -0
- package/dist/pages/observability/activity/users.d.ts.map +1 -0
- package/dist/pages/routes.d.ts +7 -0
- package/dist/pages/routes.d.ts.map +1 -1
- package/dist/pages/section-ui.d.ts +2 -1
- package/dist/pages/section-ui.d.ts.map +1 -1
- package/dist/pages.d.ts +4 -1
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +5852 -3754
- package/dist/pages.js.map +20 -7
- package/dist/sections/catalog.d.ts.map +1 -1
- package/dist/sections/sections.d.ts.map +1 -1
- package/dist/server.js +63 -10
- package/dist/server.js.map +5 -5
- package/dist/shell/search-command.d.ts.map +1 -1
- package/dist/shell/user-menu.d.ts +3 -3
- package/dist/shell/user-menu.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/agent/activity-label.ts +7 -0
- package/src/agent/agent-chat.tsx +29 -18
- package/src/agent/agent-execution-trace.tsx +1 -1
- package/src/agent/agent-panel.tsx +8 -13
- package/src/agent/agent-surface.tsx +4 -4
- package/src/agent/agents-page.ts +7 -0
- package/src/agent/artifact-card.tsx +190 -0
- package/src/agent/artifact-panel-state.ts +38 -0
- package/src/agent/artifact-panel.tsx +320 -0
- package/src/agent/components/file-attachment-card.tsx +13 -14
- package/src/agent/components/message-parts.tsx +30 -5
- package/src/agent/components/message-view.tsx +13 -19
- package/src/agent/components/thread-artifacts-menu.tsx +77 -0
- package/src/agent/i18n/en.ts +16 -58
- package/src/agent/i18n/fr.ts +15 -59
- package/src/agent/parts.ts +6 -6
- package/src/agent/publish-artifact/interpret.ts +110 -0
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +62 -0
- package/src/agent/publish-artifact/use-live-publishes.ts +45 -0
- package/src/agent/react-router.tsx +26 -7
- package/src/agent/view-file/view-file-tool-view.tsx +21 -18
- package/src/artifacts/artifact-page.tsx +61 -0
- package/src/artifacts/artifacts.css +172 -0
- package/src/artifacts/card-details.ts +92 -0
- package/src/artifacts/card-preview.tsx +612 -0
- package/src/artifacts/copy-feedback.ts +25 -0
- package/src/artifacts/file-size.ts +24 -0
- package/src/artifacts/file-source.ts +109 -0
- package/src/artifacts/file-view.ts +57 -0
- package/src/artifacts/frame.tsx +288 -0
- package/src/artifacts/gallery.tsx +405 -0
- package/src/artifacts/kind-icon.tsx +23 -0
- package/src/artifacts/markdown-tree.ts +32 -0
- package/src/artifacts/messages.ts +317 -0
- package/src/artifacts/queries.ts +85 -0
- package/src/artifacts/references/embed-tree.ts +86 -0
- package/src/artifacts/references/references.tsx +739 -0
- package/src/artifacts/renderers/document-tree.ts +157 -0
- package/src/artifacts/renderers/document.tsx +334 -0
- package/src/artifacts/renderers/file.tsx +160 -0
- package/src/artifacts/renderers/notice.tsx +38 -0
- package/src/artifacts/renderers/sheet/chart-data.ts +73 -0
- package/src/artifacts/renderers/sheet/chart.tsx +288 -0
- package/src/artifacts/renderers/sheet/format.ts +142 -0
- package/src/artifacts/renderers/sheet/grid.tsx +709 -0
- package/src/artifacts/renderers/sheet/mini-chart.tsx +241 -0
- package/src/artifacts/renderers/sheet/model.ts +136 -0
- package/src/artifacts/renderers/sheet/selection.ts +152 -0
- package/src/artifacts/renderers/sheet/sheet.tsx +471 -0
- package/src/artifacts/renderers/sheet/virtual.ts +49 -0
- package/src/artifacts/renderers/sheet/workbook.ts +57 -0
- package/src/artifacts/renderers/slides/navigation.ts +38 -0
- package/src/artifacts/renderers/slides/slides.tsx +441 -0
- package/src/artifacts/target.ts +76 -0
- package/src/artifacts/theme.ts +29 -0
- package/src/artifacts/viewer.tsx +476 -0
- package/src/build.ts +13 -2
- package/src/codegen.ts +38 -2
- package/src/createCustomApp.ts +21 -1
- package/src/index.ts +0 -5
- package/src/locale-messages.ts +9 -2
- package/src/pages/observability/activity/calendar.tsx +239 -0
- package/src/pages/observability/activity/connections.tsx +144 -0
- package/src/pages/observability/activity/format.ts +49 -0
- package/src/pages/observability/activity/messages.ts +255 -0
- package/src/pages/observability/activity/meta-items.tsx +23 -0
- package/src/pages/observability/activity/page.tsx +605 -0
- package/src/pages/observability/activity/period.ts +63 -0
- package/src/pages/observability/activity/steps.ts +102 -0
- package/src/pages/observability/activity/timeline.tsx +411 -0
- package/src/pages/observability/activity/users.tsx +133 -0
- package/src/pages/observability/messages.ts +2 -2
- package/src/pages/routes.ts +15 -0
- package/src/pages/section-ui.tsx +3 -1
- package/src/pages.ts +4 -1
- package/src/sections/catalog.ts +1 -0
- package/src/sections/sections.tsx +2 -0
- package/src/shell/search-command.tsx +8 -6
- package/src/shell/user-menu.tsx +22 -22
- package/dist/agent/document-preview/classify.d.ts +0 -4
- package/dist/agent/document-preview/classify.d.ts.map +0 -1
- package/dist/agent/document-preview/content-policy.d.ts +0 -10
- package/dist/agent/document-preview/content-policy.d.ts.map +0 -1
- package/dist/agent/document-preview/content.d.ts +0 -26
- package/dist/agent/document-preview/content.d.ts.map +0 -1
- package/dist/agent/document-preview/delimited.d.ts +0 -19
- package/dist/agent/document-preview/delimited.d.ts.map +0 -1
- package/dist/agent/document-preview/document-preview-root.d.ts +0 -24
- package/dist/agent/document-preview/document-preview-root.d.ts.map +0 -1
- package/dist/agent/document-preview/file-size.d.ts +0 -3
- package/dist/agent/document-preview/file-size.d.ts.map +0 -1
- package/dist/agent/document-preview/html.d.ts +0 -9
- package/dist/agent/document-preview/html.d.ts.map +0 -1
- package/dist/agent/document-preview/persistence.d.ts +0 -6
- package/dist/agent/document-preview/persistence.d.ts.map +0 -1
- package/dist/agent/document-preview/presentation.d.ts +0 -3
- package/dist/agent/document-preview/presentation.d.ts.map +0 -1
- package/dist/agent/document-preview/rendering.d.ts +0 -14
- package/dist/agent/document-preview/rendering.d.ts.map +0 -1
- package/dist/agent/document-preview/source.d.ts +0 -13
- package/dist/agent/document-preview/source.d.ts.map +0 -1
- package/dist/agent/document-preview/state.d.ts +0 -27
- package/dist/agent/document-preview/state.d.ts.map +0 -1
- package/dist/agent/document-preview/types.d.ts +0 -33
- package/dist/agent/document-preview/types.d.ts.map +0 -1
- package/dist/agent/workspace.d.ts +0 -11
- package/dist/agent/workspace.d.ts.map +0 -1
- package/dist/chunk-3a99tmwg.js.map +0 -10
- package/dist/chunk-j97e06rg.js.map +0 -80
- package/src/agent/document-preview/classify.ts +0 -55
- package/src/agent/document-preview/content-policy.ts +0 -37
- package/src/agent/document-preview/content.ts +0 -82
- package/src/agent/document-preview/delimited.ts +0 -118
- package/src/agent/document-preview/document-preview-root.tsx +0 -1017
- package/src/agent/document-preview/file-size.ts +0 -26
- package/src/agent/document-preview/html.ts +0 -67
- package/src/agent/document-preview/persistence.ts +0 -115
- package/src/agent/document-preview/presentation.ts +0 -13
- package/src/agent/document-preview/rendering.ts +0 -48
- package/src/agent/document-preview/source.ts +0 -48
- package/src/agent/document-preview/state.ts +0 -77
- package/src/agent/document-preview/types.ts +0 -36
- package/src/agent/workspace.ts +0 -33
- /package/dist/{chunk-shmw3f8t.js.map → chunk-3schcf10.js.map} +0 -0
- /package/dist/{chunk-48pkffj6.js.map → chunk-g3f4cm8x.js.map} +0 -0
package/src/agent/i18n/en.ts
CHANGED
|
@@ -203,14 +203,6 @@ export const en = {
|
|
|
203
203
|
},
|
|
204
204
|
/** Platform diagnostics, by their stable `code`; `unknown` covers codes added later. */
|
|
205
205
|
diagnostics: {
|
|
206
|
-
output_file_limit_exceeded:
|
|
207
|
-
"Some generated files were not attached because the file limit was reached.",
|
|
208
|
-
output_file_too_large: "A generated file exceeds the attachment size limit and was skipped.",
|
|
209
|
-
output_budget_exhausted:
|
|
210
|
-
"A generated file exceeds the remaining attachment budget and was skipped.",
|
|
211
|
-
output_collection_failed: "Generated files could not be collected.",
|
|
212
|
-
output_file_changed: "A generated file changed while it was being attached and was skipped.",
|
|
213
|
-
output_storage_failed: "A generated file could not be stored as an attachment.",
|
|
214
206
|
step_limit_reached:
|
|
215
207
|
"I reached the step limit before producing a final answer. Ask me to continue and I can use the work above as context.",
|
|
216
208
|
unknown: "Something went wrong during this response.",
|
|
@@ -473,56 +465,22 @@ export const en = {
|
|
|
473
465
|
hideRaw: "Hide raw",
|
|
474
466
|
commandFailed: "The command failed.",
|
|
475
467
|
},
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
tooLarge: "Document is too large to preview",
|
|
493
|
-
tooLargeFor: (size: string) =>
|
|
494
|
-
`This viewer accepts files up to ${size}. Download the file to view it elsewhere.`,
|
|
495
|
-
downloadToView: "Download the file to view the complete document.",
|
|
496
|
-
failed: "Could not preview document",
|
|
497
|
-
contentUnavailable: "The document content was unavailable.",
|
|
498
|
-
rendererFailed: "The configured document viewer could not render this file.",
|
|
499
|
-
noHtml: "The document did not contain readable HTML.",
|
|
500
|
-
noText: "The document did not contain readable text.",
|
|
501
|
-
tableFailed: "Could not preview table",
|
|
502
|
-
notParsed: "The file could not be parsed.",
|
|
503
|
-
noRows: "The file did not contain readable rows.",
|
|
504
|
-
notDelimited: "The file is not CSV or TSV data.",
|
|
505
|
-
malformed: "The file contains malformed delimited text.",
|
|
506
|
-
malformedNear: (row: number) => `The file contains malformed delimited text near row ${row}.`,
|
|
507
|
-
emptyFile: "The file is empty.",
|
|
508
|
-
noHeader: "The file does not contain a header row.",
|
|
509
|
-
column: (index: number) => `Column ${index}`,
|
|
510
|
-
firstRows: (shown: number, total: number) =>
|
|
511
|
-
`the first ${number(shown)} of ${number(total)} rows`,
|
|
512
|
-
firstColumns: (shown: number, total: number) =>
|
|
513
|
-
`the first ${number(shown)} of ${number(total)} columns`,
|
|
514
|
-
showing: (limits: string) => `Showing ${limits}.`,
|
|
515
|
-
and: "and",
|
|
516
|
-
downloadAll: "Download the file to view all data.",
|
|
517
|
-
dataPreview: (name: string) => `${name} data preview`,
|
|
518
|
-
noDataRows: "No data rows.",
|
|
519
|
-
pdfUnavailable: "PDF preview unavailable",
|
|
520
|
-
pdfDescription: "Open the PDF in your browser or download it to view the document.",
|
|
521
|
-
openPdf: "Open PDF",
|
|
522
|
-
loading: "Loading document…",
|
|
523
|
-
gone: "This document is no longer available.",
|
|
524
|
-
storageUnavailable: "Document storage is not available.",
|
|
525
|
-
loadFailed: "Could not load this document.",
|
|
468
|
+
artifacts: {
|
|
469
|
+
dialogTitle: "Artifact",
|
|
470
|
+
dialogDescription: "View an artifact or file from this conversation.",
|
|
471
|
+
canvasDescription: "View an artifact or file while you keep using the assistant.",
|
|
472
|
+
list: (total: number) =>
|
|
473
|
+
total === 1
|
|
474
|
+
? "1 artifact in this conversation"
|
|
475
|
+
: `${number(total)} artifacts in this conversation`,
|
|
476
|
+
all: "All artifacts",
|
|
477
|
+
/** A `publish_artifact` call, by the title it names (`title` may be empty). */
|
|
478
|
+
publishing: (title: string) => `Publishing ${title || "an artifact"}`,
|
|
479
|
+
published: (title: string) => `Published ${title || "an artifact"}`,
|
|
480
|
+
publishFailed: (title: string) => `Couldn't publish ${title || "an artifact"}`,
|
|
481
|
+
open: (title: string) => `Open ${title}`,
|
|
482
|
+
/** Labels the cards of what one response published. */
|
|
483
|
+
cards: "Published in this response",
|
|
526
484
|
},
|
|
527
485
|
sandbox: {
|
|
528
486
|
title: "Sandbox recovery required",
|
package/src/agent/i18n/fr.ts
CHANGED
|
@@ -193,16 +193,6 @@ export const fr: Translation<AgentMessages> = {
|
|
|
193
193
|
reconnectingLabel: "Reconnexion au flux de l’agent",
|
|
194
194
|
},
|
|
195
195
|
diagnostics: {
|
|
196
|
-
output_file_limit_exceeded:
|
|
197
|
-
"Certains fichiers générés n’ont pas été joints : le nombre maximal de fichiers a été atteint.",
|
|
198
|
-
output_file_too_large:
|
|
199
|
-
"Un fichier généré dépasse la taille maximale d’une pièce jointe et a été ignoré.",
|
|
200
|
-
output_budget_exhausted:
|
|
201
|
-
"Un fichier généré dépasse l’espace restant pour les pièces jointes et a été ignoré.",
|
|
202
|
-
output_collection_failed: "Les fichiers générés n’ont pas pu être récupérés.",
|
|
203
|
-
output_file_changed:
|
|
204
|
-
"Un fichier généré a été modifié pendant son ajout en pièce jointe et a été ignoré.",
|
|
205
|
-
output_storage_failed: "Un fichier généré n’a pas pu être enregistré en pièce jointe.",
|
|
206
196
|
step_limit_reached:
|
|
207
197
|
"J’ai atteint la limite d’étapes avant de produire une réponse finale. Il suffit de me demander de continuer pour reprendre ce travail.",
|
|
208
198
|
unknown: "Un problème est survenu pendant cette réponse.",
|
|
@@ -507,56 +497,22 @@ export const fr: Translation<AgentMessages> = {
|
|
|
507
497
|
hideRaw: "Masquer la sortie brute",
|
|
508
498
|
commandFailed: "La commande a échoué.",
|
|
509
499
|
},
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
dialogDescription:
|
|
514
|
-
"Prévisualiser, parcourir et télécharger les documents de cette conversation.",
|
|
500
|
+
artifacts: {
|
|
501
|
+
dialogTitle: "Artefact",
|
|
502
|
+
dialogDescription: "Afficher un artefact ou un fichier de cette conversation.",
|
|
515
503
|
canvasDescription:
|
|
516
|
-
"
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
tooLargeFor: (size) =>
|
|
529
|
-
`Cette visionneuse accepte les fichiers jusqu’à ${size}. Téléchargez le fichier pour le consulter.`,
|
|
530
|
-
downloadToView: "Téléchargez le fichier pour consulter le document complet.",
|
|
531
|
-
failed: "Impossible d’afficher le document",
|
|
532
|
-
contentUnavailable: "Le contenu du document est indisponible.",
|
|
533
|
-
rendererFailed: "La visionneuse configurée n’a pas pu afficher ce fichier.",
|
|
534
|
-
noHtml: "Le document ne contient pas de HTML lisible.",
|
|
535
|
-
noText: "Le document ne contient pas de texte lisible.",
|
|
536
|
-
tableFailed: "Impossible d’afficher le tableau",
|
|
537
|
-
notParsed: "Le fichier n’a pas pu être analysé.",
|
|
538
|
-
noRows: "Le fichier ne contient aucune ligne lisible.",
|
|
539
|
-
notDelimited: "Le fichier n’est pas au format CSV ou TSV.",
|
|
540
|
-
malformed: "Le fichier contient du texte délimité mal formé.",
|
|
541
|
-
malformedNear: (row) =>
|
|
542
|
-
`Le fichier contient du texte délimité mal formé vers la ligne ${number(row)}.`,
|
|
543
|
-
emptyFile: "Le fichier est vide.",
|
|
544
|
-
noHeader: "Le fichier ne contient pas de ligne d’en-tête.",
|
|
545
|
-
column: (index) => `Colonne ${index}`,
|
|
546
|
-
firstRows: (shown, total) => `les ${number(shown)} premières lignes sur ${number(total)}`,
|
|
547
|
-
firstColumns: (shown, total) => `les ${number(shown)} premières colonnes sur ${number(total)}`,
|
|
548
|
-
showing: (limits) => `Seules ${limits} sont affichées.`,
|
|
549
|
-
and: "et",
|
|
550
|
-
downloadAll: "Téléchargez le fichier pour consulter toutes les données.",
|
|
551
|
-
dataPreview: (name) => `Aperçu des données de ${name}`,
|
|
552
|
-
noDataRows: "Aucune ligne de données.",
|
|
553
|
-
pdfUnavailable: "Aperçu du PDF indisponible",
|
|
554
|
-
pdfDescription: "Ouvrez le PDF dans le navigateur ou téléchargez-le pour le consulter.",
|
|
555
|
-
openPdf: "Ouvrir le PDF",
|
|
556
|
-
loading: "Chargement du document…",
|
|
557
|
-
gone: "Ce document n’est plus disponible.",
|
|
558
|
-
storageUnavailable: "Le stockage des documents n’est pas disponible.",
|
|
559
|
-
loadFailed: "Impossible de charger ce document.",
|
|
504
|
+
"Afficher un artefact ou un fichier tout en continuant d’utiliser l’assistant.",
|
|
505
|
+
list: (total) =>
|
|
506
|
+
total === 1
|
|
507
|
+
? "1 artefact dans cette conversation"
|
|
508
|
+
: `${number(total)} artefacts dans cette conversation`,
|
|
509
|
+
all: "Tous les artefacts",
|
|
510
|
+
publishing: (title) => (title ? `Publication de ${title}` : "Publication d’un artefact"),
|
|
511
|
+
published: (title) => (title ? `${title} publié` : "Artefact publié"),
|
|
512
|
+
publishFailed: (title) =>
|
|
513
|
+
title ? `Impossible de publier ${title}` : "Impossible de publier l’artefact",
|
|
514
|
+
open: (title) => `Ouvrir ${title}`,
|
|
515
|
+
cards: "Publié dans cette réponse",
|
|
560
516
|
},
|
|
561
517
|
sandbox: {
|
|
562
518
|
title: "Récupération de l’environnement requise",
|
package/src/agent/parts.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FileSource } from "../artifacts/file-source"
|
|
2
2
|
import type { AgentFileRef, AgentMessagePart } from "./types"
|
|
3
3
|
|
|
4
4
|
// The render-ready vocabulary shared by the durable transcript and the live streaming row.
|
|
@@ -15,10 +15,10 @@ export type NormalizedTool = {
|
|
|
15
15
|
readonly files?: readonly NormalizedFile[]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/** A file shown in a message.
|
|
18
|
+
/** A file shown in a message. Its source, which reads the bytes, exists once the message is saved. */
|
|
19
19
|
export type NormalizedFile = {
|
|
20
20
|
readonly fileRef: AgentFileRef
|
|
21
|
-
readonly
|
|
21
|
+
readonly source?: FileSource
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export type NormalizedPart =
|
|
@@ -32,12 +32,12 @@ export function normalizeDurableParts(
|
|
|
32
32
|
parts: readonly AgentMessagePart[],
|
|
33
33
|
options: {
|
|
34
34
|
/** Resolve a file of the message from its JSON pointer, such as `/parts/2/fileRef`. */
|
|
35
|
-
readonly fileSource?: (fileRef: AgentFileRef, path: string) =>
|
|
35
|
+
readonly fileSource?: (fileRef: AgentFileRef, path: string) => FileSource | undefined
|
|
36
36
|
} = {}
|
|
37
37
|
): NormalizedPart[] {
|
|
38
38
|
const file = (fileRef: AgentFileRef, path: string): NormalizedFile => {
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const source = options.fileSource?.(fileRef, path)
|
|
40
|
+
return source === undefined ? { fileRef } : { fileRef, source }
|
|
41
41
|
}
|
|
42
42
|
const toolFiles = (output: unknown, partIndex: number): { files?: NormalizedFile[] } => {
|
|
43
43
|
const files = toolResultFiles(output).map(({ fileRef, contentIndex }) =>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ARTIFACT_KINDS } from "@sixb/core/artifacts"
|
|
2
|
+
import type { ArtifactKindName } from "../../artifacts/kind-icon"
|
|
3
|
+
import type { NormalizedPart, NormalizedTool } from "../parts"
|
|
4
|
+
|
|
5
|
+
/** Creating an artifact, and publishing the next version of one. */
|
|
6
|
+
const PUBLISH_TOOLS = new Set(["publish_artifact", "publish_artifact_version"])
|
|
7
|
+
|
|
8
|
+
export function isPublishTool(toolName: string): boolean {
|
|
9
|
+
return PUBLISH_TOOLS.has(toolName)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** What one publish call published, read from its result. */
|
|
13
|
+
export interface PublishedArtifact {
|
|
14
|
+
readonly artifactId: string
|
|
15
|
+
readonly version: number
|
|
16
|
+
readonly kind: ArtifactKindName
|
|
17
|
+
readonly title: string
|
|
18
|
+
readonly warnings: readonly { readonly message: string; readonly part?: string }[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function publishedArtifact(tool: NormalizedTool): PublishedArtifact | null {
|
|
22
|
+
if (!isPublishTool(tool.toolName) || tool.state !== "output-available") return null
|
|
23
|
+
const output = tool.output
|
|
24
|
+
if (
|
|
25
|
+
!isRecord(output) ||
|
|
26
|
+
typeof output.artifactId !== "string" ||
|
|
27
|
+
typeof output.version !== "number" ||
|
|
28
|
+
typeof output.title !== "string" ||
|
|
29
|
+
!(ARTIFACT_KINDS as readonly string[]).includes(String(output.kind))
|
|
30
|
+
) {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
const warnings = Array.isArray(output.warnings) ? output.warnings : []
|
|
34
|
+
return {
|
|
35
|
+
artifactId: output.artifactId,
|
|
36
|
+
version: output.version,
|
|
37
|
+
kind: output.kind as ArtifactKindName,
|
|
38
|
+
title: output.title,
|
|
39
|
+
warnings: warnings.flatMap((warning) =>
|
|
40
|
+
isRecord(warning) && typeof warning.message === "string"
|
|
41
|
+
? [
|
|
42
|
+
{
|
|
43
|
+
message: warning.message,
|
|
44
|
+
...(typeof warning.part === "string" ? { part: warning.part } : {}),
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
: []
|
|
48
|
+
),
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The title a publish call names, from its result or, until then, its input. */
|
|
53
|
+
export function publishTitle(tool: NormalizedTool): string {
|
|
54
|
+
const published = publishedArtifact(tool)
|
|
55
|
+
if (published) return published.title
|
|
56
|
+
return isRecord(tool.input) && typeof tool.input.title === "string" ? tool.input.title : ""
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** An artifact as a turn left it, and whether the turn created it or revised an earlier one. */
|
|
60
|
+
export interface TurnArtifact extends PublishedArtifact {
|
|
61
|
+
readonly created: boolean
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Each artifact a turn published, once, at the last version the turn published, in the order the
|
|
66
|
+
* turn first published them.
|
|
67
|
+
*/
|
|
68
|
+
export function turnArtifacts(parts: readonly NormalizedPart[]): TurnArtifact[] {
|
|
69
|
+
const byId = new Map<string, TurnArtifact>()
|
|
70
|
+
for (const part of parts) {
|
|
71
|
+
if (part.kind !== "tool") continue
|
|
72
|
+
const published = publishedArtifact(part.tool)
|
|
73
|
+
if (!published) continue
|
|
74
|
+
const earlier = byId.get(published.artifactId)
|
|
75
|
+
const created = earlier?.created === true || part.tool.toolName === "publish_artifact"
|
|
76
|
+
if (!earlier || published.version > earlier.version) {
|
|
77
|
+
byId.set(published.artifactId, { ...published, created })
|
|
78
|
+
} else if (created !== earlier.created) {
|
|
79
|
+
byId.set(published.artifactId, { ...earlier, created })
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return [...byId.values()]
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The titles of what a finished turn last tried to publish and could not: a refused attempt that no
|
|
87
|
+
* later publish of the same artifact (a version, by its id) or the same title (a new one) replaced.
|
|
88
|
+
*/
|
|
89
|
+
export function unpublishedTitles(parts: readonly NormalizedPart[]): string[] {
|
|
90
|
+
const refused = new Map<string, string>()
|
|
91
|
+
for (const part of parts) {
|
|
92
|
+
if (part.kind !== "tool" || !isPublishTool(part.tool.toolName)) continue
|
|
93
|
+
const result = publishedArtifact(part.tool)
|
|
94
|
+
if (result) {
|
|
95
|
+
refused.delete(`id:${result.artifactId}`)
|
|
96
|
+
refused.delete(`title:${result.title}`)
|
|
97
|
+
continue
|
|
98
|
+
}
|
|
99
|
+
if (part.tool.state !== "output-error") continue
|
|
100
|
+
const input = isRecord(part.tool.input) ? part.tool.input : {}
|
|
101
|
+
const key =
|
|
102
|
+
typeof input.id === "string" ? `id:${input.id.trim()}` : `title:${publishTitle(part.tool)}`
|
|
103
|
+
refused.set(key, publishTitle(part.tool))
|
|
104
|
+
}
|
|
105
|
+
return [...new Set(refused.values())]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
109
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
110
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FileUp } from "lucide-react"
|
|
2
|
+
import { useArtifactMessages } from "../../artifacts/messages"
|
|
3
|
+
import { ActivityStatusText } from "../components/activity-status"
|
|
4
|
+
import { useAgentMessages } from "../i18n"
|
|
5
|
+
import type { NormalizedTool } from "../parts"
|
|
6
|
+
import { publishedArtifact, publishTitle } from "./interpret"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A publish in the work trace: what it published and at which version, with any warnings, or why
|
|
10
|
+
* it was refused. The answer's cards show the result; this row keeps each attempt.
|
|
11
|
+
*/
|
|
12
|
+
export function PublishArtifactToolView({ tool }: { tool: NormalizedTool }) {
|
|
13
|
+
const messages = useAgentMessages().artifacts
|
|
14
|
+
const versionLabel = useArtifactMessages().viewer.version
|
|
15
|
+
const title = publishTitle(tool)
|
|
16
|
+
const published = publishedArtifact(tool)
|
|
17
|
+
const running = tool.state === "input-streaming" || tool.state === "input-available"
|
|
18
|
+
const failed = tool.state === "output-error"
|
|
19
|
+
const label = failed
|
|
20
|
+
? messages.publishFailed(title)
|
|
21
|
+
: running
|
|
22
|
+
? messages.publishing(title)
|
|
23
|
+
: messages.published(title)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="min-w-0 space-y-1">
|
|
27
|
+
<div className="flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground">
|
|
28
|
+
<FileUp className="size-3.5 shrink-0" />
|
|
29
|
+
{running ? (
|
|
30
|
+
<ActivityStatusText label={label} className="font-medium shimmer" />
|
|
31
|
+
) : (
|
|
32
|
+
<span className="min-w-0 truncate font-medium">{label}</span>
|
|
33
|
+
)}
|
|
34
|
+
{published ? (
|
|
35
|
+
<span className="shrink-0 text-muted-foreground/60 tabular-nums">
|
|
36
|
+
· {versionLabel(published.version)}
|
|
37
|
+
</span>
|
|
38
|
+
) : null}
|
|
39
|
+
</div>
|
|
40
|
+
{failed && tool.errorText ? (
|
|
41
|
+
<p className="pl-5 text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground/80">
|
|
42
|
+
{refusal(tool.errorText)}
|
|
43
|
+
</p>
|
|
44
|
+
) : null}
|
|
45
|
+
{published && published.warnings.length > 0 ? (
|
|
46
|
+
<ul className="space-y-0.5 pl-5 text-xs leading-relaxed text-muted-foreground/80">
|
|
47
|
+
{published.warnings.map((warning, index) => (
|
|
48
|
+
<li key={index}>
|
|
49
|
+
{warning.part ? `${warning.part}: ` : ""}
|
|
50
|
+
{warning.message}
|
|
51
|
+
</li>
|
|
52
|
+
))}
|
|
53
|
+
</ul>
|
|
54
|
+
) : null}
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The refusal the Agent received, without the worker's prefix. */
|
|
60
|
+
function refusal(errorText: string): string {
|
|
61
|
+
return errorText.replace(/^\[SixbAgentWorker\] publish_artifact(_version)? refused: /, "")
|
|
62
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getArtifactQueryKey } from "@sixb/client/hooks"
|
|
2
|
+
import { isMobileViewport } from "@sixb/ui/hooks"
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query"
|
|
4
|
+
import { useEffect, useRef } from "react"
|
|
5
|
+
import { useArtifactPanel } from "../artifact-panel"
|
|
6
|
+
import type { LiveRunState } from "../live-run"
|
|
7
|
+
import { turnArtifacts } from "./interpret"
|
|
8
|
+
|
|
9
|
+
/** Runs that already opened an artifact in this tab, so a remount does not open it again. */
|
|
10
|
+
const openedRuns = new Set<string>()
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Follows what a live turn publishes: each new version refreshes the artifact and every list of
|
|
14
|
+
* artifacts, and the turn's first publish opens the panel on it, at its latest version so later
|
|
15
|
+
* versions of the turn replace it in place. It opens only beside the conversation or over the app:
|
|
16
|
+
* a dialog would take the reader's focus, and the composer's, while the Agent is still working,
|
|
17
|
+
* so there the card waits to be opened.
|
|
18
|
+
*/
|
|
19
|
+
export function useLivePublishes(live: LiveRunState): void {
|
|
20
|
+
const panel = useArtifactPanel()
|
|
21
|
+
const queryClient = useQueryClient()
|
|
22
|
+
const seen = useRef(new Set<string>())
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const published = turnArtifacts(live.parts)
|
|
26
|
+
let changed = false
|
|
27
|
+
for (const artifact of published) {
|
|
28
|
+
const key = `${artifact.artifactId}@${artifact.version}`
|
|
29
|
+
if (seen.current.has(key)) continue
|
|
30
|
+
seen.current.add(key)
|
|
31
|
+
changed = true
|
|
32
|
+
void queryClient.invalidateQueries({
|
|
33
|
+
queryKey: getArtifactQueryKey({ path: { artifactId: artifact.artifactId } }),
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
if (changed) void queryClient.invalidateQueries({ queryKey: [{ _id: "listArtifacts" }] })
|
|
37
|
+
|
|
38
|
+
const first = published[0]
|
|
39
|
+
if (!first || !panel || !live.runId || openedRuns.has(live.runId)) return
|
|
40
|
+
openedRuns.add(live.runId)
|
|
41
|
+
// On a phone's first render the panel has not learned the width yet, so the width is asked.
|
|
42
|
+
if (panel.presentation === "dialog" || isMobileViewport()) return
|
|
43
|
+
panel.open({ type: "artifact", artifactId: first.artifactId })
|
|
44
|
+
}, [live.parts, live.runId, panel, queryClient])
|
|
45
|
+
}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { Button } from "@sixb/ui/components"
|
|
2
2
|
import { cn } from "@sixb/ui/lib/utils"
|
|
3
3
|
import { ArrowLeft } from "lucide-react"
|
|
4
|
-
import { useCallback } from "react"
|
|
5
|
-
import { useNavigate, useParams } from "react-router-dom"
|
|
4
|
+
import { useCallback, useMemo } from "react"
|
|
5
|
+
import { useNavigate, useParams, useSearchParams } from "react-router-dom"
|
|
6
|
+
import {
|
|
7
|
+
type ArtifactTarget,
|
|
8
|
+
artifactTargetFromSearch,
|
|
9
|
+
withArtifactTarget,
|
|
10
|
+
} from "../artifacts/target"
|
|
6
11
|
import { AgentChat, type AgentChatProps } from "./agent-chat"
|
|
7
12
|
import { useRegisteredAgentContext } from "./agent-context-provider"
|
|
8
13
|
import { useAgentMessages } from "./i18n"
|
|
9
14
|
|
|
10
|
-
export type {
|
|
11
|
-
AgentDocumentPreviewRenderer,
|
|
12
|
-
AgentDocumentPreviewRendererProps,
|
|
13
|
-
} from "./document-preview/types"
|
|
14
15
|
export type { AgentFileRef } from "./types"
|
|
15
16
|
|
|
16
17
|
export interface AgentChatPageProps
|
|
17
|
-
extends Omit<
|
|
18
|
+
extends Omit<
|
|
19
|
+
AgentChatProps,
|
|
20
|
+
"threadId" | "onNavigateHome" | "onNavigateThread" | "artifactTarget" | "onArtifactTargetChange"
|
|
21
|
+
> {
|
|
18
22
|
readonly routeBase?: string
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -29,7 +33,20 @@ export function AgentChatPage({
|
|
|
29
33
|
const navigate = useNavigate()
|
|
30
34
|
const registeredContext = useRegisteredAgentContext()
|
|
31
35
|
const { threadId: routeThreadId } = useParams()
|
|
36
|
+
const [searchParams, setSearchParams] = useSearchParams()
|
|
32
37
|
const normalizedRouteBase = normalizeRouteBase(routeBase)
|
|
38
|
+
// The open artifact lives in `?artifact=&v=&part=`, so a reload or a shared link lands on it.
|
|
39
|
+
const searchKey = searchParams.toString()
|
|
40
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the key stands for the parameters.
|
|
41
|
+
const artifactTarget = useMemo(() => artifactTargetFromSearch(searchParams), [searchKey])
|
|
42
|
+
const onArtifactTargetChange = useCallback(
|
|
43
|
+
(target: ArtifactTarget | null) => {
|
|
44
|
+
setSearchParams((current) => withArtifactTarget(current, target), {
|
|
45
|
+
replace: target === null,
|
|
46
|
+
})
|
|
47
|
+
},
|
|
48
|
+
[setSearchParams]
|
|
49
|
+
)
|
|
33
50
|
|
|
34
51
|
const onNavigateHome = useCallback(() => {
|
|
35
52
|
navigate(normalizedRouteBase)
|
|
@@ -50,6 +67,8 @@ export function AgentChatPage({
|
|
|
50
67
|
threadId={routeThreadId ?? null}
|
|
51
68
|
onNavigateHome={onNavigateHome}
|
|
52
69
|
onNavigateThread={onNavigateThread}
|
|
70
|
+
artifactTarget={artifactTarget}
|
|
71
|
+
onArtifactTargetChange={onArtifactTargetChange}
|
|
53
72
|
conversationHeaderActions={
|
|
54
73
|
<>
|
|
55
74
|
<Button
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { useLocale } from "@sixb/ui/lib/i18n"
|
|
1
2
|
import { cn } from "@sixb/ui/lib/utils"
|
|
2
3
|
import { Eye, File as FileIcon } from "lucide-react"
|
|
3
4
|
import type { ReactNode } from "react"
|
|
5
|
+
import { formatFileSize } from "../../artifacts/file-size"
|
|
6
|
+
import { fileView } from "../../artifacts/file-view"
|
|
7
|
+
import { useArtifactPanel } from "../artifact-panel"
|
|
4
8
|
import { ActivityStatusText } from "../components/activity-status"
|
|
5
|
-
import { useDocumentPreview } from "../document-preview/document-preview-root"
|
|
6
|
-
import { formatFileSize } from "../document-preview/file-size"
|
|
7
9
|
import { useAgentMessages } from "../i18n"
|
|
8
10
|
import type { NormalizedFile, NormalizedTool } from "../parts"
|
|
9
11
|
import { describeViewFile } from "./interpret"
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* A file the agent viewed. It belongs to the work, not to the answer, so it stays in the trace: an
|
|
13
|
-
* image as a small preview, any other file as a compact chip, each opening the
|
|
15
|
+
* image as a small preview, any other file as a compact chip, each opening in the artifact panel.
|
|
14
16
|
*/
|
|
15
17
|
export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
|
|
16
18
|
const messages = useAgentMessages().viewFile
|
|
@@ -43,15 +45,16 @@ export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
function ViewedFile({ file }: { file: NormalizedFile }) {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
48
|
+
const messages = useAgentMessages().files
|
|
49
|
+
const locale = useLocale()
|
|
50
|
+
const { fileRef, source } = file
|
|
51
|
+
const name = fileRef.fileName?.trim() || messages.file
|
|
49
52
|
|
|
50
|
-
if (
|
|
53
|
+
if (source && fileView(fileRef) === "image") {
|
|
51
54
|
return (
|
|
52
55
|
<OpenFile file={file} name={name}>
|
|
53
56
|
<img
|
|
54
|
-
src={
|
|
57
|
+
src={source.inlineUrl}
|
|
55
58
|
alt={name}
|
|
56
59
|
loading="lazy"
|
|
57
60
|
className="block h-auto max-h-28 w-auto max-w-[min(10rem,100%)] rounded-md border border-border/70 bg-muted/40 object-contain"
|
|
@@ -66,14 +69,14 @@ function ViewedFile({ file }: { file: NormalizedFile }) {
|
|
|
66
69
|
<FileIcon className="size-3.5 shrink-0" />
|
|
67
70
|
<span className="min-w-0 truncate font-medium text-foreground/80">{name}</span>
|
|
68
71
|
<span className="shrink-0 text-muted-foreground/60">
|
|
69
|
-
{formatFileSize(fileRef.sizeBytes)}
|
|
72
|
+
{formatFileSize(fileRef.sizeBytes, locale, messages)}
|
|
70
73
|
</span>
|
|
71
74
|
</span>
|
|
72
75
|
</OpenFile>
|
|
73
76
|
)
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
/** Open a saved file in the
|
|
79
|
+
/** Open a saved file in the artifact panel, or in a new tab outside a conversation. */
|
|
77
80
|
function OpenFile({
|
|
78
81
|
file,
|
|
79
82
|
name,
|
|
@@ -83,30 +86,30 @@ function OpenFile({
|
|
|
83
86
|
name: string
|
|
84
87
|
children: ReactNode
|
|
85
88
|
}) {
|
|
86
|
-
const
|
|
89
|
+
const panel = useArtifactPanel()
|
|
87
90
|
const messages = useAgentMessages()
|
|
88
|
-
const {
|
|
91
|
+
const { source } = file
|
|
89
92
|
const className = cn(
|
|
90
93
|
"block w-fit max-w-full rounded-md outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring",
|
|
91
|
-
|
|
94
|
+
source && "hover:opacity-80"
|
|
92
95
|
)
|
|
93
96
|
|
|
94
|
-
if (
|
|
97
|
+
if (source && panel) {
|
|
95
98
|
return (
|
|
96
99
|
<button
|
|
97
100
|
type="button"
|
|
98
101
|
className={className}
|
|
99
|
-
onClick={() =>
|
|
100
|
-
aria-label={messages.
|
|
102
|
+
onClick={() => panel.open({ type: "file", source })}
|
|
103
|
+
aria-label={messages.files.preview(name)}
|
|
101
104
|
>
|
|
102
105
|
{children}
|
|
103
106
|
</button>
|
|
104
107
|
)
|
|
105
108
|
}
|
|
106
|
-
if (
|
|
109
|
+
if (source) {
|
|
107
110
|
return (
|
|
108
111
|
<a
|
|
109
|
-
href={
|
|
112
|
+
href={source.inlineUrl}
|
|
110
113
|
target="_blank"
|
|
111
114
|
rel="noreferrer"
|
|
112
115
|
className={className}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useNavigate, useParams, useSearchParams } from "react-router-dom"
|
|
2
|
+
import {
|
|
3
|
+
type ArtifactTarget,
|
|
4
|
+
artifactTargetFromSearch,
|
|
5
|
+
artifactTargetHref,
|
|
6
|
+
withArtifactTarget,
|
|
7
|
+
} from "./target"
|
|
8
|
+
import { Viewer } from "./viewer"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An artifact on its own page, at `/artifacts/:artifactId` with `?v=` and `?part=`: the whole
|
|
12
|
+
* window, over whatever shell the app draws, so a shared link opens just the artifact. It belongs
|
|
13
|
+
* to no section: whoever may read the artifact can open it, and a link to it works anywhere.
|
|
14
|
+
*/
|
|
15
|
+
export function ArtifactPage() {
|
|
16
|
+
const { artifactId } = useParams()
|
|
17
|
+
const [searchParams, setSearchParams] = useSearchParams()
|
|
18
|
+
const navigate = useNavigate()
|
|
19
|
+
if (!artifactId) return null
|
|
20
|
+
|
|
21
|
+
// The artifact is the path; the version and part are parameters.
|
|
22
|
+
const params = new URLSearchParams(searchParams)
|
|
23
|
+
params.set("artifact", artifactId)
|
|
24
|
+
const target: ArtifactTarget = artifactTargetFromSearch(params) ?? {
|
|
25
|
+
type: "artifact",
|
|
26
|
+
artifactId,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="fixed inset-0 z-50 flex flex-col bg-background text-foreground">
|
|
31
|
+
<Viewer
|
|
32
|
+
target={target}
|
|
33
|
+
chrome={{
|
|
34
|
+
// Back to where the link was followed from, or into the app for a link opened cold.
|
|
35
|
+
onBack: () => (canGoBack() ? navigate(-1) : navigate("/")),
|
|
36
|
+
}}
|
|
37
|
+
// A version or part of this artifact replaces the address; it is the same page.
|
|
38
|
+
onTargetChange={(next) => {
|
|
39
|
+
if (next.type !== "artifact") return
|
|
40
|
+
const nextParams = withArtifactTarget(searchParams, next)
|
|
41
|
+
nextParams.delete("artifact")
|
|
42
|
+
setSearchParams(nextParams, { replace: true })
|
|
43
|
+
}}
|
|
44
|
+
// Another artifact is another page, so back returns to this one.
|
|
45
|
+
onOpenReference={(next) => navigate(artifactTargetHref(next))}
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** React Router numbers the entries it pushed; the first one has nowhere in the app to go back to. */
|
|
52
|
+
function canGoBack(): boolean {
|
|
53
|
+
const state: unknown = window.history.state
|
|
54
|
+
return (
|
|
55
|
+
typeof state === "object" &&
|
|
56
|
+
state !== null &&
|
|
57
|
+
"idx" in state &&
|
|
58
|
+
typeof state.idx === "number" &&
|
|
59
|
+
state.idx > 0
|
|
60
|
+
)
|
|
61
|
+
}
|