@docyrus/ui-pro-ai-assistant 0.0.1
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/index.js +26161 -0
- package/dist/index.js.map +1 -0
- package/package.json +155 -0
- package/src/components/assistant-animations.tsx +29 -0
- package/src/components/assistant-dialogs.tsx +235 -0
- package/src/components/code-view.tsx +278 -0
- package/src/components/create-agent-task.tsx +104 -0
- package/src/components/create-new-work-version.tsx +30 -0
- package/src/components/extract-web.tsx +160 -0
- package/src/components/forward-to-agent.tsx +90 -0
- package/src/components/generate-chart.tsx +101 -0
- package/src/components/generative-action-button.tsx +122 -0
- package/src/components/generative-tool.tsx +685 -0
- package/src/components/generative-ui-object.tsx +210 -0
- package/src/components/input-area.tsx +1209 -0
- package/src/components/json-schema-layout.tsx +326 -0
- package/src/components/list-item-card.tsx +92 -0
- package/src/components/mermaid-diagram.tsx +192 -0
- package/src/components/preview-image.tsx +47 -0
- package/src/components/request-approval.tsx +48 -0
- package/src/components/request-user-input.tsx +270 -0
- package/src/components/search-web.tsx +319 -0
- package/src/components/sheet-command.tsx +88 -0
- package/src/components/shell-canvas.tsx +122 -0
- package/src/components/show-advanced-data-table.tsx +352 -0
- package/src/components/show-generated-content-options.tsx +93 -0
- package/src/components/show-people-cards.tsx +180 -0
- package/src/components/subagent-tool.tsx +180 -0
- package/src/components/text-editor-tool.tsx +328 -0
- package/src/components/work-canvas.tsx +88 -0
- package/src/components/work-card.tsx +42 -0
- package/src/declarations.d.ts +1 -0
- package/src/docy-assistant.tsx +1962 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-assistant-api.ts +507 -0
- package/src/hooks/use-deployment-data.ts +162 -0
- package/src/hooks/use-project-state.ts +347 -0
- package/src/hooks/use-session-state.ts +207 -0
- package/src/hooks/use-speech-recognition.ts +137 -0
- package/src/hooks/use-ui-state.ts +185 -0
- package/src/hooks/use-works-state.ts +146 -0
- package/src/i18n/context.tsx +253 -0
- package/src/i18n/index.ts +19 -0
- package/src/i18n/locales/de.json +198 -0
- package/src/i18n/locales/el.json +198 -0
- package/src/i18n/locales/en.json +226 -0
- package/src/i18n/locales/es.json +198 -0
- package/src/i18n/locales/fr.json +198 -0
- package/src/i18n/locales/it.json +198 -0
- package/src/i18n/locales/pt.json +198 -0
- package/src/i18n/locales/sl.json +198 -0
- package/src/i18n/locales/tr.json +211 -0
- package/src/i18n/types.ts +23 -0
- package/src/i18n/use-translation.ts +17 -0
- package/src/index.ts +18 -0
- package/src/internal/plate-editor/editor/auth-context.ts +11 -0
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +39 -0
- package/src/internal/plate-editor/editor/editor-kit.tsx +89 -0
- package/src/internal/plate-editor/editor/plate-editor.tsx +75 -0
- package/src/internal/plate-editor/editor/plate-types.ts +126 -0
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +172 -0
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +211 -0
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +26 -0
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +51 -0
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +24 -0
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +38 -0
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +6 -0
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +14 -0
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +17 -0
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +31 -0
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +23 -0
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +26 -0
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +8 -0
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +174 -0
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +68 -0
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +13 -0
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +27 -0
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +43 -0
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +6 -0
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +15 -0
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +12 -0
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +19 -0
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +47 -0
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +19 -0
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +22 -0
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +35 -0
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +24 -0
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +27 -0
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +18 -0
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +8 -0
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +10 -0
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +37 -0
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +53 -0
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +17 -0
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +95 -0
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +20 -0
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +22 -0
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +14 -0
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +9 -0
- package/src/internal/plate-editor/editor/transforms.ts +165 -0
- package/src/internal/plate-editor/editor/use-chat.ts +152 -0
- package/src/internal/plate-editor/hooks/index.ts +3 -0
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +31 -0
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +26 -0
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +21 -0
- package/src/internal/plate-editor/hooks/use-media-query.ts +44 -0
- package/src/internal/plate-editor/hooks/use-mounted.ts +18 -0
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +114 -0
- package/src/internal/plate-editor/hooks/use-upload-file.ts +81 -0
- package/src/internal/plate-editor/i18n/context.tsx +58 -0
- package/src/internal/plate-editor/i18n/index.ts +3 -0
- package/src/internal/plate-editor/i18n/locales/de.json +57 -0
- package/src/internal/plate-editor/i18n/locales/el.json +57 -0
- package/src/internal/plate-editor/i18n/locales/en.json +57 -0
- package/src/internal/plate-editor/i18n/locales/es.json +57 -0
- package/src/internal/plate-editor/i18n/locales/fr.json +57 -0
- package/src/internal/plate-editor/i18n/locales/it.json +57 -0
- package/src/internal/plate-editor/i18n/locales/pt.json +57 -0
- package/src/internal/plate-editor/i18n/locales/sl.json +57 -0
- package/src/internal/plate-editor/i18n/locales/tr.json +57 -0
- package/src/internal/plate-editor/i18n/types.ts +59 -0
- package/src/internal/plate-editor/i18n/use-translation.ts +22 -0
- package/src/internal/plate-editor/index.ts +39 -0
- package/src/internal/plate-editor/lib/ai-output-converter.ts +153 -0
- package/src/internal/plate-editor/lib/download-file.ts +17 -0
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +828 -0
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +41 -0
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +27 -0
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +147 -0
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +90 -0
- package/src/internal/plate-editor/plate-ui/avatar.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +106 -0
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +364 -0
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +556 -0
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +78 -0
- package/src/internal/plate-editor/plate-ui/block-list.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +557 -0
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +47 -0
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +469 -0
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +10 -0
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/button.tsx +190 -0
- package/src/internal/plate-editor/plate-ui/calendar.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +76 -0
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +54 -0
- package/src/internal/plate-editor/plate-ui/caption.tsx +48 -0
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +172 -0
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +228 -0
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/code-node.tsx +12 -0
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +65 -0
- package/src/internal/plate-editor/plate-ui/column-node.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/command.tsx +204 -0
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +12 -0
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +45 -0
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/comment.tsx +619 -0
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +43 -0
- package/src/internal/plate-editor/plate-ui/date-node.tsx +56 -0
- package/src/internal/plate-editor/plate-ui/dialog.tsx +426 -0
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +266 -0
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +40 -0
- package/src/internal/plate-editor/plate-ui/editor.tsx +148 -0
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +48 -0
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +626 -0
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +155 -0
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +226 -0
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +208 -0
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +157 -0
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +27 -0
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +1129 -0
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +129 -0
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +99 -0
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +211 -0
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +154 -0
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +20 -0
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +56 -0
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +9 -0
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +7 -0
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +18 -0
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +28 -0
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +124 -0
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +34 -0
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +409 -0
- package/src/internal/plate-editor/plate-ui/input.tsx +39 -0
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +260 -0
- package/src/internal/plate-editor/plate-ui/label.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +71 -0
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +15 -0
- package/src/internal/plate-editor/plate-ui/link-node.tsx +33 -0
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +30 -0
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +149 -0
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +179 -0
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +36 -0
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +21 -0
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +32 -0
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +103 -0
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +30 -0
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +37 -0
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +183 -0
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +441 -0
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +127 -0
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +229 -0
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +216 -0
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +73 -0
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +35 -0
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +119 -0
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +46 -0
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +79 -0
- package/src/internal/plate-editor/plate-ui/menu.tsx +532 -0
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +126 -0
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +34 -0
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +15 -0
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +16 -0
- package/src/internal/plate-editor/plate-ui/popover.tsx +77 -0
- package/src/internal/plate-editor/plate-ui/progress.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +81 -0
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +88 -0
- package/src/internal/plate-editor/plate-ui/separator.tsx +43 -0
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +435 -0
- package/src/internal/plate-editor/plate-ui/spinner.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +35 -0
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +168 -0
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/table-node.tsx +285 -0
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +254 -0
- package/src/internal/plate-editor/plate-ui/tabs.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/textarea.tsx +58 -0
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +142 -0
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +57 -0
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +50 -0
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +18 -0
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +33 -0
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/toggle.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +380 -0
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +149 -0
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +177 -0
- package/src/internal/plate-editor/types/index.ts +22 -0
- package/src/internal/plate-editor/vite.ts +284 -0
- package/src/internal/sheets/components/univer-sheets.tsx +1104 -0
- package/src/internal/sheets/i18n/context.tsx +183 -0
- package/src/internal/sheets/i18n/index.ts +19 -0
- package/src/internal/sheets/i18n/locales/de.json +21 -0
- package/src/internal/sheets/i18n/locales/el.json +21 -0
- package/src/internal/sheets/i18n/locales/en.json +21 -0
- package/src/internal/sheets/i18n/locales/es.json +21 -0
- package/src/internal/sheets/i18n/locales/fr.json +21 -0
- package/src/internal/sheets/i18n/locales/it.json +21 -0
- package/src/internal/sheets/i18n/locales/pt.json +21 -0
- package/src/internal/sheets/i18n/locales/sl.json +21 -0
- package/src/internal/sheets/i18n/locales/tr.json +21 -0
- package/src/internal/sheets/i18n/types.ts +23 -0
- package/src/internal/sheets/i18n/use-translation.ts +17 -0
- package/src/internal/sheets/index.ts +14 -0
- package/src/internal/sheets/types/css.d.ts +11 -0
- package/src/internal/sheets/types/index.ts +260 -0
- package/src/internal/sheets/xlsx.ts +1169 -0
- package/src/lib/api-client.ts +77 -0
- package/src/lib/assistant-api-actions.ts +549 -0
- package/src/lib/assistant-config.tsx +71 -0
- package/src/lib/class-utils.ts +40 -0
- package/src/lib/index.ts +7 -0
- package/src/lib/message-utils.ts +131 -0
- package/src/tools/tools-schema.json +512 -0
- package/src/types/index.ts +235 -0
- package/src/views/assistant-view.tsx +1137 -0
- package/src/views/canvas-app.tsx +839 -0
- package/src/views/canvas-code.tsx +93 -0
- package/src/views/canvas-deep-research.tsx +44 -0
- package/src/views/canvas-image.tsx +25 -0
- package/src/views/canvas-record-view.tsx +285 -0
- package/src/views/canvas-spreadsheet.tsx +125 -0
- package/src/views/canvas-text.tsx +52 -0
- package/src/views/canvas.tsx +274 -0
- package/src/views/chat-panel.tsx +149 -0
- package/src/views/index.ts +20 -0
- package/src/views/memories-panel.tsx +365 -0
- package/src/views/message-list.tsx +370 -0
- package/src/views/project-detail.tsx +257 -0
- package/src/views/projects-panel.tsx +131 -0
- package/src/views/sessions-list.tsx +98 -0
- package/src/views/sidebar-content.tsx +256 -0
- package/src/views/work-detail.tsx +98 -0
- package/src/vite.ts +284 -0
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { CodeBlock, CodeBlockCopyButton } from '@docyrus/ui-pro-shared/ai';
|
|
4
|
+
import {
|
|
5
|
+
Source,
|
|
6
|
+
SourcesContent,
|
|
7
|
+
SourcesTrigger,
|
|
8
|
+
Sources
|
|
9
|
+
} from '@docyrus/ui-pro-shared/ai-elements/sources';
|
|
10
|
+
import { Card } from '@docyrus/ui-pro-shared/components/card';
|
|
11
|
+
|
|
12
|
+
import { useAssistantTranslation } from '../i18n';
|
|
13
|
+
import { type ToolActionEvent } from '../types';
|
|
14
|
+
|
|
15
|
+
import { CreateAgentTask } from './create-agent-task';
|
|
16
|
+
import { CreateNewWorkVersion } from './create-new-work-version';
|
|
17
|
+
import { ExtractWeb } from './extract-web';
|
|
18
|
+
import { ForwardToAgent } from './forward-to-agent';
|
|
19
|
+
import { GenerateChart } from './generate-chart';
|
|
20
|
+
import { GenerativeActionButton } from './generative-action-button';
|
|
21
|
+
import { MermaidDiagram } from './mermaid-diagram';
|
|
22
|
+
import PreviewImage from './preview-image';
|
|
23
|
+
import { RequestApproval } from './request-approval';
|
|
24
|
+
import { RequestUserInput } from './request-user-input';
|
|
25
|
+
import { SheetCommand } from './sheet-command';
|
|
26
|
+
import { ShowAdvancedDataTable } from './show-advanced-data-table';
|
|
27
|
+
import { SearchWeb } from './search-web';
|
|
28
|
+
import { ShowGeneratedContentOptions } from './show-generated-content-options';
|
|
29
|
+
import { ShowPeopleCards } from './show-people-cards';
|
|
30
|
+
import { SubagentTool } from './subagent-tool';
|
|
31
|
+
import { TextEditorTool } from './text-editor-tool';
|
|
32
|
+
import { WorkCanvas } from './work-canvas';
|
|
33
|
+
|
|
34
|
+
interface Part {
|
|
35
|
+
state:
|
|
36
|
+
| 'input-available'
|
|
37
|
+
| 'input-streaming'
|
|
38
|
+
| 'output-available'
|
|
39
|
+
| 'output-error'
|
|
40
|
+
| 'approval-requested'
|
|
41
|
+
| 'approval-responded'
|
|
42
|
+
| 'output-denied';
|
|
43
|
+
input?: Record<string, any>;
|
|
44
|
+
output?: any;
|
|
45
|
+
errorText?: string;
|
|
46
|
+
toolCallId: string;
|
|
47
|
+
approval?:
|
|
48
|
+
| { id: string; approved?: never; reason?: never }
|
|
49
|
+
| { id: string; approved: true; reason?: string }
|
|
50
|
+
| { id: string; approved: false; reason?: string };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface GenerativeUIToolProps {
|
|
54
|
+
part: Part;
|
|
55
|
+
toolName: string;
|
|
56
|
+
onToolAction: (event: ToolActionEvent) => void;
|
|
57
|
+
openCanvasView?: (options: {
|
|
58
|
+
type: string;
|
|
59
|
+
id: string;
|
|
60
|
+
versionId?: string;
|
|
61
|
+
title?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
images?: any[];
|
|
64
|
+
contentJson?: Record<string, any> | null;
|
|
65
|
+
loaded?: boolean;
|
|
66
|
+
workId?: string;
|
|
67
|
+
commands?: any[];
|
|
68
|
+
fetchLatestVersion?: boolean;
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
}) => void;
|
|
71
|
+
onUseWorkResult?: (data: {
|
|
72
|
+
workId?: string;
|
|
73
|
+
workVersionId?: string;
|
|
74
|
+
workType?: string;
|
|
75
|
+
data?: any;
|
|
76
|
+
}) => void;
|
|
77
|
+
onSendSpreadsheetCommands?: (commands: any[]) => void;
|
|
78
|
+
onForwardToAgent?: (options: { agentId: string; prompt?: string }) => void;
|
|
79
|
+
onInsertText?: (data: { text: string }) => void;
|
|
80
|
+
onReplaceText?: (data: { text: string }) => void;
|
|
81
|
+
workId?: string;
|
|
82
|
+
agent?: Record<string, any>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const stringify = (val: any): string => {
|
|
86
|
+
try {
|
|
87
|
+
return typeof val === 'string' ? val : JSON.stringify(val, null, 2);
|
|
88
|
+
} catch {
|
|
89
|
+
return String(val ?? '');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export function GenerativeUITool({
|
|
94
|
+
part, toolName, onToolAction, openCanvasView, onUseWorkResult, onSendSpreadsheetCommands, onForwardToAgent, onInsertText, onReplaceText, workId, agent
|
|
95
|
+
}: GenerativeUIToolProps) {
|
|
96
|
+
const { t } = useAssistantTranslation();
|
|
97
|
+
|
|
98
|
+
const emitToolAction = (decision: string) => {
|
|
99
|
+
onToolAction({
|
|
100
|
+
tool: toolName,
|
|
101
|
+
toolCallId: part.toolCallId,
|
|
102
|
+
decision,
|
|
103
|
+
input: part.input
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// requestApproval tool
|
|
108
|
+
if (toolName === 'requestApproval') {
|
|
109
|
+
return (
|
|
110
|
+
<div className="not-prose mb-4 w-full">
|
|
111
|
+
<RequestApproval
|
|
112
|
+
state={part.state}
|
|
113
|
+
action={part.input?.action}
|
|
114
|
+
details={part.input?.details}
|
|
115
|
+
onApprove={() => emitToolAction('approve')}
|
|
116
|
+
onReject={() => emitToolAction('continue')} />
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// previewCode tool
|
|
122
|
+
if (
|
|
123
|
+
toolName === 'previewCode'
|
|
124
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
125
|
+
) {
|
|
126
|
+
return (
|
|
127
|
+
<div className="not-prose mb-4 w-full">
|
|
128
|
+
<Card
|
|
129
|
+
className="p-4 cursor-pointer hover:bg-accent/50 transition-colors"
|
|
130
|
+
onClick={() => openCanvasView?.({
|
|
131
|
+
type: 'code',
|
|
132
|
+
id: part.output?.id || '',
|
|
133
|
+
title: part.input?.title,
|
|
134
|
+
description: part.input?.description
|
|
135
|
+
})}>
|
|
136
|
+
<h3 className="font-semibold text-sm mb-2">{part.input?.title || t('descriptions.code_preview')}</h3>
|
|
137
|
+
{part.input?.description && <p className="text-xs text-muted-foreground mb-2">{part.input?.description}</p>}
|
|
138
|
+
<div className="text-xs text-muted-foreground">{t('messages.click_to_view_code')} →</div>
|
|
139
|
+
</Card>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// generateImage/previewImage tool
|
|
145
|
+
if (
|
|
146
|
+
toolName === 'generateImage'
|
|
147
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
148
|
+
) {
|
|
149
|
+
// Handle completed state with images
|
|
150
|
+
if (part.state === 'output-available' && part.output?.status === 'success' && part.output?.result?.images) {
|
|
151
|
+
return (
|
|
152
|
+
<div className="not-prose mb-4 w-full">
|
|
153
|
+
<PreviewImage
|
|
154
|
+
title={part.input?.prompt}
|
|
155
|
+
images={part.output.result.images}
|
|
156
|
+
onOpen={() => openCanvasView?.({
|
|
157
|
+
type: 'image',
|
|
158
|
+
id: part.output.result.workId || part.output.result.id || '',
|
|
159
|
+
title: part.input?.prompt,
|
|
160
|
+
images: part.output.result.images
|
|
161
|
+
})} />
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Loading state (input-streaming, input-available, or output loading)
|
|
167
|
+
return (
|
|
168
|
+
<div className="not-prose mb-4 w-full">
|
|
169
|
+
<div className="rounded-lg border bg-card p-3">
|
|
170
|
+
<div className="text-xs font-medium text-muted-foreground mb-1">{t('messages.generating_image')}</div>
|
|
171
|
+
<div className="text-sm">{part.output?.text || t('messages.generating_image_message')}</div>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// showImage tool
|
|
178
|
+
if (
|
|
179
|
+
toolName === 'showImage'
|
|
180
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
181
|
+
) {
|
|
182
|
+
return (
|
|
183
|
+
<div className="not-prose mb-4 w-full">
|
|
184
|
+
<PreviewImage
|
|
185
|
+
title={part.input?.title}
|
|
186
|
+
images={part.input?.images} />
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// showAdvancedDataTable tool
|
|
192
|
+
if (toolName === 'showAdvancedDataTable') {
|
|
193
|
+
return (
|
|
194
|
+
<div className="not-prose mb-4 w-full">
|
|
195
|
+
<ShowAdvancedDataTable
|
|
196
|
+
state={part.state}
|
|
197
|
+
errorText={part.errorText}
|
|
198
|
+
title={part.input?.title}
|
|
199
|
+
description={part.input?.description}
|
|
200
|
+
additionalComments={part.input?.additionalComments}
|
|
201
|
+
data={part.input?.data}
|
|
202
|
+
columns={part.input?.columns}
|
|
203
|
+
enableTree={part.input?.enableTree}
|
|
204
|
+
treeChildrenField={part.input?.treeChildrenField} />
|
|
205
|
+
</div>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// record form tools
|
|
210
|
+
if (
|
|
211
|
+
toolName === 'showCreateRecordForm'
|
|
212
|
+
|| toolName === 'showUpdateRecordForm'
|
|
213
|
+
|| toolName === 'showRecordDetailsForm'
|
|
214
|
+
) {
|
|
215
|
+
const recordMode = toolName === 'showCreateRecordForm' ? 'add' : toolName === 'showUpdateRecordForm' ? 'edit' : 'view';
|
|
216
|
+
|
|
217
|
+
const dataSourceId = part.input?.dataSourceId
|
|
218
|
+
|| part.output?.result?.dataSourceId;
|
|
219
|
+
|
|
220
|
+
const recordDefaultValues = part.input?.defaultValues
|
|
221
|
+
|| part.output?.result?.defaultValues;
|
|
222
|
+
|
|
223
|
+
const recordId = part.input?.recordId || part.output?.result?.recordId;
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div className="not-prose mb-4 w-full">
|
|
227
|
+
<GenerativeActionButton
|
|
228
|
+
action={toolName}
|
|
229
|
+
data={part.input}
|
|
230
|
+
title={part.output?.text}
|
|
231
|
+
icon={part.output?.icon}
|
|
232
|
+
onAction={(action, data) => {
|
|
233
|
+
openCanvasView?.({
|
|
234
|
+
type: 'record',
|
|
235
|
+
id: `record-${Date.now()}`,
|
|
236
|
+
title: part.output?.text || action,
|
|
237
|
+
dataSourceId,
|
|
238
|
+
data: recordDefaultValues,
|
|
239
|
+
mode: recordMode,
|
|
240
|
+
recordId
|
|
241
|
+
} as any);
|
|
242
|
+
onToolAction({
|
|
243
|
+
tool: action,
|
|
244
|
+
toolCallId: part.toolCallId,
|
|
245
|
+
decision: 'open',
|
|
246
|
+
input: data
|
|
247
|
+
});
|
|
248
|
+
}} />
|
|
249
|
+
</div>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// previewMermaidDiagram tool
|
|
254
|
+
if (toolName === 'previewMermaidDiagram') {
|
|
255
|
+
return (
|
|
256
|
+
<div className="not-prose mb-4 w-full">
|
|
257
|
+
<MermaidDiagram
|
|
258
|
+
title={part.output?.text ?? part.input?.title}
|
|
259
|
+
description={part.input?.description}
|
|
260
|
+
mermaidNotation={part.input?.mermaidNotation ?? ''}
|
|
261
|
+
state={part.state} />
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// generateChart tool
|
|
267
|
+
if (toolName === 'generateChart') {
|
|
268
|
+
return (
|
|
269
|
+
<div className="not-prose mb-4 w-full">
|
|
270
|
+
<GenerateChart
|
|
271
|
+
spec={part.output?.result?.spec}
|
|
272
|
+
time={part.output?.result?.time}
|
|
273
|
+
state={part.state}
|
|
274
|
+
errorText={part.errorText}
|
|
275
|
+
title={part.output?.text ?? part.input?.title}
|
|
276
|
+
description={part.input?.description} />
|
|
277
|
+
</div>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// saveTextWork tool
|
|
282
|
+
if (
|
|
283
|
+
toolName === 'saveTextWork'
|
|
284
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
285
|
+
) {
|
|
286
|
+
return (
|
|
287
|
+
<div className="not-prose mb-4 w-full">
|
|
288
|
+
<WorkCanvas
|
|
289
|
+
title={part.output?.text || part.input?.title}
|
|
290
|
+
description={part.input?.description}
|
|
291
|
+
id={part.output?.result?.workId || ''}
|
|
292
|
+
content={part.input?.content || ''}
|
|
293
|
+
state={part.state}
|
|
294
|
+
onOpen={() => openCanvasView?.({
|
|
295
|
+
type: 'text',
|
|
296
|
+
id: part.output?.result?.workId || '',
|
|
297
|
+
versionId: part.output?.result?.workVersionId || '',
|
|
298
|
+
title: part.input?.title,
|
|
299
|
+
description: part.input?.description
|
|
300
|
+
})} />
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// showWorkCanvas tool
|
|
306
|
+
if (
|
|
307
|
+
toolName === 'showWorkCanvas'
|
|
308
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
309
|
+
) {
|
|
310
|
+
return (
|
|
311
|
+
<div className="not-prose mb-4 w-full">
|
|
312
|
+
<WorkCanvas
|
|
313
|
+
title={part.output?.text || part.input?.title}
|
|
314
|
+
description={part.input?.description}
|
|
315
|
+
id={part.input?.workId || ''}
|
|
316
|
+
state={part.state}
|
|
317
|
+
showUseButton={!!onUseWorkResult}
|
|
318
|
+
onOpen={() => openCanvasView?.({
|
|
319
|
+
type: part.input?.workType || 'code',
|
|
320
|
+
id: part.input?.workId || '',
|
|
321
|
+
versionId: part.input?.workVersionId || '',
|
|
322
|
+
title: part.input?.title,
|
|
323
|
+
description: part.input?.description
|
|
324
|
+
})}
|
|
325
|
+
onUseResult={() => onUseWorkResult?.({
|
|
326
|
+
workId: part.input?.workId,
|
|
327
|
+
workVersionId: part.input?.workVersionId,
|
|
328
|
+
workType: part.input?.workType || 'code',
|
|
329
|
+
data: part.input
|
|
330
|
+
})} />
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// searchWeb / web_search / google_search / browser_search tools
|
|
336
|
+
if (
|
|
337
|
+
toolName === 'searchWeb'
|
|
338
|
+
|| toolName === 'web_search'
|
|
339
|
+
|| toolName === 'google_search'
|
|
340
|
+
|| toolName === 'browser_search'
|
|
341
|
+
) {
|
|
342
|
+
if (part.state === 'input-available' || part.state === 'input-streaming') {
|
|
343
|
+
return (
|
|
344
|
+
<div className="not-prose mb-4 w-full">
|
|
345
|
+
<div className="rounded-lg border bg-card p-3 flex items-center gap-2">
|
|
346
|
+
<span className="text-xs font-medium text-slate-500">
|
|
347
|
+
{part.output?.text || 'Searching the web...'}
|
|
348
|
+
</span>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<div className="not-prose mb-4 w-full">
|
|
356
|
+
<SearchWeb
|
|
357
|
+
state={part.state}
|
|
358
|
+
output={part.output}
|
|
359
|
+
errorText={part.errorText}
|
|
360
|
+
title={part.output?.text} />
|
|
361
|
+
</div>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// extractFromWeb tool
|
|
366
|
+
if (
|
|
367
|
+
toolName === 'extractFromWeb'
|
|
368
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
369
|
+
) {
|
|
370
|
+
return (
|
|
371
|
+
<div className="not-prose mb-4 w-full">
|
|
372
|
+
<ExtractWeb
|
|
373
|
+
title={part.output?.text || part.output?.result?.title || part.input?.title}
|
|
374
|
+
status={part.output?.result?.status || part.output?.status}
|
|
375
|
+
state={part.state}
|
|
376
|
+
runId={part.output?.result?.runId || part.output?.result?.extractionId}
|
|
377
|
+
onOpen={() => openCanvasView?.({
|
|
378
|
+
type: 'data',
|
|
379
|
+
id: part.output?.result?.workId || 'streaming',
|
|
380
|
+
versionId: part.output?.result?.workVersionId || 'streaming',
|
|
381
|
+
contentJson: {
|
|
382
|
+
basis: part.output?.result?.data?.output?.basis,
|
|
383
|
+
content: part.output?.result?.data?.output?.content
|
|
384
|
+
},
|
|
385
|
+
loaded: true
|
|
386
|
+
} as any)} />
|
|
387
|
+
</div>
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// deepResearch tool
|
|
392
|
+
if (
|
|
393
|
+
toolName === 'deepResearch'
|
|
394
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
395
|
+
) {
|
|
396
|
+
if (part.state === 'input-available' || part.state === 'input-streaming') {
|
|
397
|
+
return (
|
|
398
|
+
<div className="not-prose mb-4 w-full">
|
|
399
|
+
<div className="rounded-lg border bg-card p-3 flex items-center gap-2">
|
|
400
|
+
<span className="text-xs font-medium text-slate-500">
|
|
401
|
+
{part.output?.text || `${t('tools.deep_research')}...`}
|
|
402
|
+
</span>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return (
|
|
409
|
+
<div className="not-prose mb-4 w-full">
|
|
410
|
+
<Card
|
|
411
|
+
className="p-4 cursor-pointer hover:bg-accent/50 transition-colors"
|
|
412
|
+
onClick={() => openCanvasView?.({
|
|
413
|
+
type: 'data',
|
|
414
|
+
id: part.output?.result?.data?.run?.run_id || part.output?.result?.workId || '',
|
|
415
|
+
title: part.input?.title || part.output?.text || t('tools.deep_research'),
|
|
416
|
+
contentJson: {
|
|
417
|
+
output_schema: part.output?.result?.data?.output?.output_schema || part.input?.output_schema,
|
|
418
|
+
content: part.output?.result?.data?.output?.content,
|
|
419
|
+
basis: part.output?.result?.data?.output?.basis
|
|
420
|
+
},
|
|
421
|
+
loaded: true
|
|
422
|
+
})}>
|
|
423
|
+
<h3 className="font-semibold text-sm mb-2">{part.input?.title || part.output?.text || t('tools.deep_research')}</h3>
|
|
424
|
+
{part.input?.description && <p className="text-xs text-muted-foreground mb-2">{part.input.description}</p>}
|
|
425
|
+
<div className="text-xs text-muted-foreground">{t('messages.click_to_view_code')} →</div>
|
|
426
|
+
</Card>
|
|
427
|
+
</div>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// requestUserInput tool
|
|
432
|
+
if (
|
|
433
|
+
toolName === 'requestUserInput'
|
|
434
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
435
|
+
) {
|
|
436
|
+
return (
|
|
437
|
+
<div className="not-prose mb-4 w-full">
|
|
438
|
+
<RequestUserInput
|
|
439
|
+
state={part.state}
|
|
440
|
+
schema={part.input?.jsonSchema || {}}
|
|
441
|
+
title={part.input?.title || 'User Input Required'}
|
|
442
|
+
description={part.input?.description || ''}
|
|
443
|
+
submitLabel={part.input?.submitLabel || 'Submit'}
|
|
444
|
+
output={part.output}
|
|
445
|
+
onSubmit={data => onToolAction({
|
|
446
|
+
tool: toolName,
|
|
447
|
+
toolCallId: part.toolCallId,
|
|
448
|
+
decision: 'submit',
|
|
449
|
+
input: data
|
|
450
|
+
})}
|
|
451
|
+
onCancel={() => emitToolAction('cancel')} />
|
|
452
|
+
</div>
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// call*Agent tools (orchestrator subagent calls)
|
|
457
|
+
if (
|
|
458
|
+
toolName.startsWith('call')
|
|
459
|
+
&& toolName.endsWith('Agent')
|
|
460
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
461
|
+
) {
|
|
462
|
+
const output = part.output as Record<string, any> | undefined;
|
|
463
|
+
|
|
464
|
+
return (
|
|
465
|
+
<div className="not-prose mb-4 w-full">
|
|
466
|
+
<SubagentTool
|
|
467
|
+
toolState={part.state}
|
|
468
|
+
input={part.input}
|
|
469
|
+
status={output?.status}
|
|
470
|
+
text={output?.text}
|
|
471
|
+
icon={output?.icon}
|
|
472
|
+
skillName={output?.skillName}
|
|
473
|
+
agentName={output?.agentName}
|
|
474
|
+
step={output?.step}
|
|
475
|
+
result={output?.result}
|
|
476
|
+
agent={agent}
|
|
477
|
+
openCanvasView={openCanvasView} />
|
|
478
|
+
</div>
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// forwardToAgentById tool
|
|
483
|
+
if (
|
|
484
|
+
toolName === 'forwardToAgentById'
|
|
485
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming')
|
|
486
|
+
) {
|
|
487
|
+
return (
|
|
488
|
+
<div className="not-prose mb-4 w-full">
|
|
489
|
+
<ForwardToAgent
|
|
490
|
+
agentId={part.input?.agentId}
|
|
491
|
+
prompt={part.input?.prompt}
|
|
492
|
+
state={part.state}
|
|
493
|
+
onForward={() => {
|
|
494
|
+
onForwardToAgent?.({ agentId: part.input?.agentId, prompt: part.input?.prompt });
|
|
495
|
+
emitToolAction('forward');
|
|
496
|
+
}} />
|
|
497
|
+
</div>
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// runSpreadsheetCommand tool
|
|
502
|
+
if (toolName === 'runSpreadsheetCommand') {
|
|
503
|
+
return (
|
|
504
|
+
<div className="not-prose mb-4 w-full">
|
|
505
|
+
<SheetCommand
|
|
506
|
+
commands={part.input?.commands}
|
|
507
|
+
state={part.state}
|
|
508
|
+
toolCallId={part.toolCallId}
|
|
509
|
+
workId={part.input?.id || workId}
|
|
510
|
+
openCanvasView={openCanvasView}
|
|
511
|
+
onSendSpreadsheetCommands={onSendSpreadsheetCommands}
|
|
512
|
+
onAutoRespond={() => onToolAction({
|
|
513
|
+
tool: toolName,
|
|
514
|
+
toolCallId: part.toolCallId,
|
|
515
|
+
decision: 'submit',
|
|
516
|
+
input: { success: true }
|
|
517
|
+
})} />
|
|
518
|
+
</div>
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// showPeopleCards tool
|
|
523
|
+
if (
|
|
524
|
+
toolName === 'showPeopleCards'
|
|
525
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
526
|
+
) {
|
|
527
|
+
return (
|
|
528
|
+
<div className="not-prose mb-4 w-full">
|
|
529
|
+
<ShowPeopleCards
|
|
530
|
+
state={part.state}
|
|
531
|
+
output={part.output}
|
|
532
|
+
errorText={part.errorText}
|
|
533
|
+
title={part.output?.text} />
|
|
534
|
+
</div>
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// createAgentTask tool
|
|
539
|
+
if (
|
|
540
|
+
toolName === 'createAgentTask'
|
|
541
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
542
|
+
) {
|
|
543
|
+
return (
|
|
544
|
+
<div className="not-prose mb-4 w-full">
|
|
545
|
+
<CreateAgentTask
|
|
546
|
+
taskPrompt={part.input?.taskPrompt}
|
|
547
|
+
taskDescription={part.input?.taskDescription}
|
|
548
|
+
scheduleType={part.input?.scheduleType}
|
|
549
|
+
state={part.state}
|
|
550
|
+
output={part.output} />
|
|
551
|
+
</div>
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// showGeneratedContentOptions tool
|
|
556
|
+
if (
|
|
557
|
+
toolName === 'showGeneratedContentOptions'
|
|
558
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available' || part.state === 'output-error')
|
|
559
|
+
) {
|
|
560
|
+
return (
|
|
561
|
+
<div className="not-prose mb-4 w-full">
|
|
562
|
+
<ShowGeneratedContentOptions
|
|
563
|
+
output={part.output?.result}
|
|
564
|
+
state={part.state}
|
|
565
|
+
onInsertText={onInsertText}
|
|
566
|
+
onReplaceText={onReplaceText} />
|
|
567
|
+
</div>
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// createNewWorkVersion tool
|
|
572
|
+
if (toolName === 'createNewWorkVersion') {
|
|
573
|
+
return (
|
|
574
|
+
<div className="not-prose mb-4 w-full">
|
|
575
|
+
<CreateNewWorkVersion
|
|
576
|
+
title={part.output?.text || part.input?.title}
|
|
577
|
+
description={part.input?.description}
|
|
578
|
+
state={part.state} />
|
|
579
|
+
</div>
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// searchDocuments tool
|
|
584
|
+
if (toolName === 'searchDocuments') {
|
|
585
|
+
if (part.state === 'input-available' || part.state === 'input-streaming') {
|
|
586
|
+
return (
|
|
587
|
+
<div className="not-prose mb-4 w-full">
|
|
588
|
+
<div className="rounded-lg border bg-card p-3 flex items-center gap-2">
|
|
589
|
+
<span className="text-xs font-medium text-slate-500">
|
|
590
|
+
{part.output?.text || t('tools.document_search')}
|
|
591
|
+
</span>
|
|
592
|
+
</div>
|
|
593
|
+
</div>
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (part.state === 'output-available') {
|
|
598
|
+
const sources: Array<{ url: string; title?: string }> = part.output?.result?.sources ?? [];
|
|
599
|
+
|
|
600
|
+
if (sources.length > 0) {
|
|
601
|
+
return (
|
|
602
|
+
<div className="not-prose mb-4 w-full">
|
|
603
|
+
<Sources>
|
|
604
|
+
<SourcesTrigger count={sources.length}>
|
|
605
|
+
<span className="font-medium">{part.output?.text || `${sources.length} sources`}</span>
|
|
606
|
+
</SourcesTrigger>
|
|
607
|
+
<SourcesContent>
|
|
608
|
+
{sources.map((src, idx) => (
|
|
609
|
+
<Source key={idx} href={src.url} title={src.title || src.url} />
|
|
610
|
+
))}
|
|
611
|
+
</SourcesContent>
|
|
612
|
+
</Sources>
|
|
613
|
+
</div>
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return (
|
|
618
|
+
<div className="not-prose mb-4 w-full">
|
|
619
|
+
<div className="rounded-lg border bg-card p-3">
|
|
620
|
+
<span className="text-xs font-medium text-slate-500">No documents found</span>
|
|
621
|
+
</div>
|
|
622
|
+
</div>
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// str_replace_based_edit_tool
|
|
628
|
+
if (
|
|
629
|
+
toolName === 'str_replace_based_edit_tool'
|
|
630
|
+
&& (part.state === 'input-available' || part.state === 'input-streaming' || part.state === 'output-available')
|
|
631
|
+
) {
|
|
632
|
+
const output = part.output as any;
|
|
633
|
+
|
|
634
|
+
return (
|
|
635
|
+
<div className="not-prose mb-4 w-full">
|
|
636
|
+
<TextEditorTool
|
|
637
|
+
command={part.input?.command || 'view'}
|
|
638
|
+
path={part.input?.path || ''}
|
|
639
|
+
fileText={part.input?.file_text || ''}
|
|
640
|
+
oldStr={part.input?.old_str || ''}
|
|
641
|
+
newStr={part.input?.new_str || ''}
|
|
642
|
+
insertLine={part.input?.insert_line || 0}
|
|
643
|
+
viewRange={part.input?.view_range || null}
|
|
644
|
+
query={part.input?.query || ''}
|
|
645
|
+
state={part.state}
|
|
646
|
+
result={output?.result ?? output ?? null}
|
|
647
|
+
errorText={part.errorText}
|
|
648
|
+
onOpen={() => openCanvasView?.({
|
|
649
|
+
type: output?.type || 'code',
|
|
650
|
+
id: output?.workId || '',
|
|
651
|
+
versionId: output?.workVersionId || '',
|
|
652
|
+
title: part.input?.path
|
|
653
|
+
})} />
|
|
654
|
+
</div>
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (part.state === 'output-available') {
|
|
659
|
+
return (
|
|
660
|
+
<div className="not-prose mb-4 w-full">
|
|
661
|
+
<div className="rounded-lg border bg-card p-3">
|
|
662
|
+
<div className="text-xs font-medium text-muted-foreground mb-1">{t('sections.output')}</div>
|
|
663
|
+
<CodeBlock code={stringify(part.output)} language="json">
|
|
664
|
+
<CodeBlockCopyButton />
|
|
665
|
+
</CodeBlock>
|
|
666
|
+
</div>
|
|
667
|
+
</div>
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (part.state === 'output-error') {
|
|
672
|
+
return (
|
|
673
|
+
<div className="not-prose mb-4 w-full">
|
|
674
|
+
<div className="rounded-lg border bg-card p-3">
|
|
675
|
+
<div className="text-xs font-medium text-destructive mb-1">{t('sections.error')}</div>
|
|
676
|
+
<CodeBlock code={part.errorText || ''} language={'txt' as any}>
|
|
677
|
+
<CodeBlockCopyButton />
|
|
678
|
+
</CodeBlock>
|
|
679
|
+
</div>
|
|
680
|
+
</div>
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return null;
|
|
685
|
+
}
|