@parallelworks/ui 0.44.0 → 0.46.0
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 +348 -25
- package/dist/ai/agent/diff.d.ts +2 -1
- package/dist/ai/agent/diff.js +4 -12
- package/dist/ai/agent/diffHighlight.d.ts +1 -1
- package/dist/ai/agent/diffHighlight.js +4 -3
- package/dist/ai/agent/index.d.ts +2 -1
- package/dist/ai/agent/permissions.d.ts +1 -1
- package/dist/ai/agent/permissions.js +1 -1
- package/dist/ai/agent/toolStrings.d.ts +37 -0
- package/dist/ai/agent/toolStrings.js +35 -0
- package/dist/ai/agent/toolfmt.d.ts +8 -3
- package/dist/ai/agent/toolfmt.js +50 -65
- package/dist/ai/ai.css +22 -35
- package/dist/ai/components/AllocationSelector.js +2 -2
- package/dist/ai/components/AttachmentManager.js +28 -29
- package/dist/ai/components/AttachmentUpload.js +25 -30
- package/dist/ai/components/BlockedGroupBanner.js +2 -2
- package/dist/ai/components/BranchNavigator.js +3 -4
- package/dist/ai/components/ChatEmptyState.js +8 -7
- package/dist/ai/components/ChatInput.js +10 -12
- package/dist/ai/components/ChatLayout.js +3 -3
- package/dist/ai/components/ChatMessage.js +49 -61
- package/dist/ai/components/ChatMessageList.js +46 -42
- package/dist/ai/components/ChatSidebar.js +26 -34
- package/dist/ai/components/ChatStage.d.ts +1 -1
- package/dist/ai/components/ChatStage.js +2 -2
- package/dist/ai/components/ComposerChrome.js +3 -4
- package/dist/ai/components/DragOverlay.js +6 -4
- package/dist/ai/components/ModelSelector.js +14 -15
- package/dist/ai/components/PastedText.js +18 -14
- package/dist/ai/components/ProviderIssueBanner.js +3 -4
- package/dist/ai/components/Reasoning.d.ts +12 -6
- package/dist/ai/components/Reasoning.js +31 -18
- package/dist/ai/components/ShareDialog.js +25 -28
- package/dist/ai/components/SlashMenu.js +3 -3
- package/dist/ai/components/agent/ActivityLine.d.ts +0 -5
- package/dist/ai/components/agent/ActivityLine.js +17 -54
- package/dist/ai/components/agent/AgentMessageParts.js +139 -149
- package/dist/ai/components/conversationActions.js +16 -16
- package/dist/ai/core/ChatProvider.d.ts +2 -4
- package/dist/ai/core/ChatProvider.js +25 -38
- package/dist/ai/core/exportConversation.js +4 -4
- package/dist/ai/core/pasteLanguage.d.ts +1 -1
- package/dist/ai/core/pasteLanguage.js +1 -1
- package/dist/ai/core/sidebarState.d.ts +8 -6
- package/dist/ai/core/sidebarState.js +21 -28
- package/dist/ai/core/useKeyboardShortcuts.js +14 -5
- package/dist/ai/index.d.ts +4 -5
- package/dist/ai/index.js +7 -7
- package/dist/ai/strings.d.ts +14 -31
- package/dist/ai/strings.js +19 -39
- package/dist/ai/types.d.ts +0 -5
- package/dist/ai/ui/ConversationSidebar.d.ts +12 -9
- package/dist/ai/ui/ConversationSidebar.js +43 -87
- package/dist/ai/ui/Markdown.d.ts +3 -6
- package/dist/ai/ui/Markdown.js +6 -73
- package/dist/ai/ui/Notice.js +10 -12
- package/dist/ai/ui/chip.d.ts +2 -2
- package/dist/ai/ui/chip.js +1 -1
- package/dist/ai/ui/sidebar.d.ts +4 -20
- package/dist/ai/ui/sidebar.js +30 -67
- package/dist/ai/utils.d.ts +0 -1
- package/dist/ai/utils.js +1 -14
- package/dist/brandIcons.d.ts +51 -0
- package/dist/brandIcons.js +75 -0
- package/dist/components/Avatar.d.ts +3 -1
- package/dist/components/Avatar.js +34 -28
- package/dist/components/Button.d.ts +12 -7
- package/dist/components/Button.js +39 -44
- package/dist/components/Callout.js +18 -12
- package/dist/components/Card.d.ts +18 -8
- package/dist/components/Card.js +17 -6
- package/dist/components/Checkbox.d.ts +9 -0
- package/dist/components/Checkbox.js +30 -0
- package/dist/components/Combobox.d.ts +9 -1
- package/dist/components/Combobox.js +71 -44
- package/dist/components/ConfirmModal.js +11 -11
- package/dist/components/ContextMenu.d.ts +2 -8
- package/dist/components/ContextMenu.js +2 -29
- package/dist/components/CopyToClipboard.js +17 -36
- package/dist/components/CreateModal.d.ts +3 -24
- package/dist/components/CreateModal.js +46 -113
- package/dist/components/DatePicker.d.ts +31 -0
- package/dist/components/DatePicker.js +191 -0
- package/dist/components/DescriptionList.js +4 -4
- package/dist/components/Disclosure.d.ts +34 -0
- package/dist/components/Disclosure.js +46 -0
- package/dist/components/Drawer.d.ts +47 -0
- package/dist/components/Drawer.js +120 -0
- package/dist/components/EmptyState.d.ts +15 -10
- package/dist/components/EmptyState.js +13 -8
- package/dist/components/ExternalLink.d.ts +8 -0
- package/dist/components/ExternalLink.js +29 -0
- package/dist/components/Field.d.ts +70 -0
- package/dist/components/Field.js +159 -0
- package/dist/components/HoverCard.js +11 -14
- package/dist/components/IconButton.d.ts +16 -13
- package/dist/components/IconButton.js +27 -18
- package/dist/components/InfoTip.js +16 -23
- package/dist/components/Input.d.ts +10 -9
- package/dist/components/Input.js +54 -96
- package/dist/components/LetterBadge.js +2 -2
- package/dist/components/Loader.d.ts +15 -8
- package/dist/components/Loader.js +29 -19
- package/dist/components/Markdown.d.ts +7 -1
- package/dist/components/Markdown.js +2 -0
- package/dist/components/MarkdownImpl.d.ts +1 -1
- package/dist/components/MarkdownImpl.js +55 -14
- package/dist/components/Menu.js +13 -15
- package/dist/components/MenuEntries.js +11 -16
- package/dist/components/Meter.d.ts +48 -0
- package/dist/components/Meter.js +94 -0
- package/dist/components/Modal.js +11 -14
- package/dist/components/NumberInput.d.ts +25 -0
- package/dist/components/NumberInput.js +55 -0
- package/dist/components/Overview.js +12 -10
- package/dist/components/PageHeader.d.ts +2 -3
- package/dist/components/PageHeader.js +30 -21
- package/dist/components/Pagination.d.ts +27 -14
- package/dist/components/Pagination.js +86 -25
- package/dist/components/Popover.d.ts +47 -0
- package/dist/components/Popover.js +63 -0
- package/dist/components/Provider.d.ts +200 -83
- package/dist/components/Provider.js +203 -121
- package/dist/components/Radio.d.ts +1 -1
- package/dist/components/Radio.js +4 -4
- package/dist/components/RefreshButton.d.ts +15 -0
- package/dist/components/RefreshButton.js +53 -0
- package/dist/components/RunStatusIcon.d.ts +12 -0
- package/dist/components/RunStatusIcon.js +84 -0
- package/dist/components/SearchInput.d.ts +16 -0
- package/dist/components/SearchInput.js +52 -0
- package/dist/components/Section.d.ts +28 -0
- package/dist/components/Section.js +76 -0
- package/dist/components/SegmentedControl.d.ts +7 -11
- package/dist/components/SegmentedControl.js +25 -56
- package/dist/components/Select.d.ts +5 -1
- package/dist/components/Select.js +43 -44
- package/dist/components/SettingModeOption.d.ts +3 -5
- package/dist/components/SettingModeOption.js +5 -6
- package/dist/components/SettingsCard.d.ts +32 -19
- package/dist/components/SettingsCard.js +40 -13
- package/dist/components/Skeleton.d.ts +22 -0
- package/dist/components/Skeleton.js +34 -0
- package/dist/components/Slider.d.ts +16 -0
- package/dist/components/Slider.js +30 -0
- package/dist/components/Sort.js +4 -6
- package/dist/components/StatusBadge.d.ts +5 -3
- package/dist/components/StatusBadge.js +10 -33
- package/dist/components/StatusIcons.d.ts +0 -4
- package/dist/components/StatusIcons.js +5 -13
- package/dist/components/Switch.d.ts +5 -1
- package/dist/components/Switch.js +23 -6
- package/dist/components/Table.js +13 -20
- package/dist/components/Tabs.d.ts +52 -0
- package/dist/components/Tabs.js +75 -0
- package/dist/components/ThemeEditor.d.ts +29 -0
- package/dist/components/ThemeEditor.js +397 -0
- package/dist/components/Toast.d.ts +57 -0
- package/dist/components/Toast.js +203 -0
- package/dist/components/Tooltip.js +12 -15
- package/dist/components/buttonClasses.d.ts +18 -0
- package/dist/components/buttonClasses.js +31 -0
- package/dist/components/codeTheme.d.ts +5 -0
- package/dist/components/codeTheme.js +93 -0
- package/dist/components/comboboxItems.d.ts +1 -1
- package/dist/components/fieldBox.d.ts +14 -0
- package/dist/components/fieldBox.js +29 -0
- package/dist/components/floating.d.ts +26 -5
- package/dist/components/floating.js +31 -9
- package/dist/{ai/ui/codeBreaks.js → components/markdownCodeBreaks.js} +1 -1
- package/dist/components/persistedState.d.ts +2 -0
- package/dist/components/persistedState.js +63 -0
- package/dist/components/relativeTime.d.ts +36 -8
- package/dist/components/relativeTime.js +106 -23
- package/dist/components/segmented.d.ts +17 -0
- package/dist/components/segmented.js +27 -0
- package/dist/components/shortcutKey.d.ts +4 -0
- package/dist/components/shortcutKey.js +27 -0
- package/dist/components/splitter.d.ts +26 -0
- package/dist/components/splitter.js +69 -0
- package/dist/components/tone.d.ts +9 -0
- package/dist/components/tone.js +30 -0
- package/dist/components/useCopy.d.ts +14 -0
- package/dist/components/useCopy.js +31 -0
- package/dist/components/useCssIsDark.d.ts +2 -0
- package/dist/components/useCssIsDark.js +2 -1
- package/dist/components/useTheme.d.ts +10 -0
- package/dist/components/useTheme.js +40 -0
- package/dist/cx.d.ts +5 -0
- package/dist/cx.js +11 -0
- package/dist/editing.d.ts +1 -1
- package/dist/editor/Editor.js +2 -2
- package/dist/editor/EditorField.js +7 -10
- package/dist/editor/FormCodePanel.js +10 -23
- package/dist/editor/Monaco.js +7 -4
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +2 -2
- package/dist/editor/themes.d.ts +4 -0
- package/dist/editor/themes.js +75 -76
- package/dist/file-explorer/FileExplorer.js +180 -187
- package/dist/file-explorer/FileExplorerContext.js +45 -67
- package/dist/file-explorer/FilePreview/CodePreviewEditor.js +2 -1
- package/dist/file-explorer/FilePreview/Inline.js +9 -7
- package/dist/file-explorer/FilePreview/StreamedBadge.js +2 -2
- package/dist/file-explorer/FilePreview/Viewer.js +32 -34
- package/dist/file-explorer/FilePreview/index.js +60 -92
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +4 -4
- package/dist/file-explorer/FilePreview/useObjectText.js +4 -4
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +4 -4
- package/dist/file-explorer/FileRow.js +10 -15
- package/dist/file-explorer/FileRowsWindow.js +2 -6
- package/dist/file-explorer/FileTable.js +2 -2
- package/dist/file-explorer/FileTableHeaders.js +8 -11
- package/dist/file-explorer/LoadMoreRow.js +8 -9
- package/dist/file-explorer/TreeView.js +16 -16
- package/dist/file-explorer/helpers.d.ts +1 -4
- package/dist/file-explorer/helpers.js +101 -114
- package/dist/file-explorer/lib/types.d.ts +2 -2
- package/dist/file-explorer/lib/utils.d.ts +0 -2
- package/dist/file-explorer/lib/utils.js +1 -25
- package/dist/file-explorer/toasts.js +109 -190
- package/dist/form/Fields/BooleanField.js +12 -14
- package/dist/form/Fields/CheckboxGroupField.d.ts +1 -1
- package/dist/form/Fields/CheckboxGroupField.js +16 -18
- package/dist/form/Fields/ColorField.js +11 -11
- package/dist/form/Fields/DropdownField.d.ts +1 -1
- package/dist/form/Fields/DropdownField.js +20 -36
- package/dist/form/Fields/DurationField.d.ts +1 -1
- package/dist/form/Fields/DurationField.js +36 -50
- package/dist/form/Fields/LabelField.js +2 -2
- package/dist/form/Fields/MultiDropdownField.d.ts +1 -1
- package/dist/form/Fields/MultiDropdownField.js +9 -14
- package/dist/form/Fields/NumberField.d.ts +1 -1
- package/dist/form/Fields/NumberField.js +13 -48
- package/dist/form/Fields/ObjectField.js +3 -3
- package/dist/form/Fields/RadioField.d.ts +1 -1
- package/dist/form/Fields/RadioField.js +15 -18
- package/dist/form/Fields/RangeField.js +34 -35
- package/dist/form/Fields/StringField.d.ts +1 -1
- package/dist/form/Fields/StringField.js +15 -25
- package/dist/form/Fields/TextAreaField.js +10 -15
- package/dist/form/Form.d.ts +7 -2
- package/dist/form/Form.js +144 -49
- package/dist/form/FormLayout.js +18 -12
- package/dist/form/Wizard/WizardContainer.js +44 -18
- package/dist/form/Wizard/WizardNavigation.d.ts +1 -1
- package/dist/form/Wizard/WizardNavigation.js +31 -56
- package/dist/form/Wizard/WizardStepIndicator.d.ts +3 -0
- package/dist/form/Wizard/WizardStepIndicator.js +98 -114
- package/dist/form/Wizard/types.d.ts +2 -2
- package/dist/form/fieldFrame.d.ts +7 -0
- package/dist/form/fieldFrame.js +19 -0
- package/dist/form/index.d.ts +5 -5
- package/dist/form/index.js +4 -6
- package/dist/form/layoutCSS.js +5 -4
- package/dist/form/types/fieldComponentTypes.d.ts +5 -3
- package/dist/form/useChoiceField.js +2 -3
- package/dist/form/useFieldValue.d.ts +3 -0
- package/dist/form/useFieldValue.js +24 -7
- package/dist/form/utils/duration.d.ts +2 -2
- package/dist/form/utils/duration.js +3 -3
- package/dist/form/utils/fieldItems.d.ts +1 -1
- package/dist/form/utils/fieldPath.d.ts +5 -3
- package/dist/form/utils/fieldPath.js +18 -3
- package/dist/form/utils/secondaryField.d.ts +0 -7
- package/dist/form/utils/secondaryField.js +1 -12
- package/dist/form/validation.d.ts +29 -0
- package/dist/form/validation.js +14 -0
- package/dist/format.d.ts +28 -0
- package/dist/format.js +64 -0
- package/dist/graph/AnnotationBanner.js +20 -31
- package/dist/graph/Connectors.js +1 -1
- package/dist/graph/DependencyGraph.js +51 -65
- package/dist/graph/GraphEditor.js +24 -28
- package/dist/graph/GraphEditorDialogs.js +239 -245
- package/dist/graph/InputDialog.js +93 -112
- package/dist/graph/InputsEditor.js +83 -84
- package/dist/graph/JobSummary.js +10 -11
- package/dist/graph/MatrixGroup.js +3 -3
- package/dist/graph/ProblemsButton.js +9 -10
- package/dist/graph/ShortcutsButton.js +12 -17
- package/dist/graph/SuggestionInput.d.ts +2 -3
- package/dist/graph/SuggestionInput.js +2 -4
- package/dist/graph/TreeView.js +47 -45
- package/dist/graph/WorkflowSettingsDialog.js +97 -102
- package/dist/graph/editorChrome.js +10 -12
- package/dist/graph/editorFields.d.ts +19 -16
- package/dist/graph/editorFields.js +97 -135
- package/dist/graph/editorPrimitives.d.ts +2 -2
- package/dist/graph/editorPrimitives.js +3 -3
- package/dist/graph/editorRows.js +22 -25
- package/dist/graph/editorStrings.d.ts +18 -21
- package/dist/graph/editorStrings.js +15 -27
- package/dist/graph/fieldProblems.js +2 -2
- package/dist/graph/graphEditorState.d.ts +4 -4
- package/dist/graph/inputRefs.d.ts +0 -13
- package/dist/graph/inputRefs.js +122 -160
- package/dist/graph/settingsViews.js +5 -3
- package/dist/graph/stepWith.js +100 -100
- package/dist/graph/toolbarPanel.d.ts +8 -0
- package/dist/graph/toolbarPanel.js +11 -0
- package/dist/icons.d.ts +234 -23
- package/dist/icons.js +249 -264
- package/dist/index.d.ts +38 -21
- package/dist/index.js +42 -21
- package/dist/list/ActionToolbar.d.ts +1 -5
- package/dist/list/ActionToolbar.js +21 -20
- package/dist/list/ListPage.js +7 -7
- package/dist/list/ListTable.d.ts +3 -2
- package/dist/list/ListTable.js +33 -29
- package/dist/list/ListViewControls.d.ts +0 -17
- package/dist/list/ListViewControls.js +50 -118
- package/dist/list/UserHoverCard.js +24 -32
- package/dist/list/index.d.ts +2 -4
- package/dist/list/index.js +3 -5
- package/dist/list/listSearch.d.ts +1 -1
- package/dist/list/listSearch.js +19 -14
- package/dist/list/rowMenu.js +20 -26
- package/dist/logviewer/LogViewer.js +268 -382
- package/dist/logviewer/logviewer.css +53 -41
- package/dist/logviewer/segments.d.ts +1 -1
- package/dist/logviewer/segments.js +1 -1
- package/dist/styles/base.css +16 -40
- package/dist/styles/theme.css +75 -106
- package/dist/styles.css +1 -1
- package/dist/theme/color.d.ts +40 -0
- package/dist/theme/color.js +228 -0
- package/dist/theme/contrast.d.ts +42 -0
- package/dist/theme/contrast.js +145 -0
- package/dist/theme/derive.d.ts +25 -0
- package/dist/theme/derive.js +475 -0
- package/dist/theme/fit.d.ts +35 -0
- package/dist/theme/fit.js +185 -0
- package/dist/theme/index.d.ts +14 -29
- package/dist/theme/index.js +20 -279
- package/dist/theme/model.d.ts +64 -0
- package/dist/theme/model.js +219 -0
- package/package.json +9 -5
- package/dist/ai/ui/Avatar.d.ts +0 -7
- package/dist/ai/ui/Avatar.js +0 -24
- package/dist/components/Filter.d.ts +0 -15
- package/dist/components/Filter.js +0 -32
- package/dist/components/FilterPill.d.ts +0 -7
- package/dist/components/FilterPill.js +0 -14
- package/dist/components/Indicator.d.ts +0 -4
- package/dist/components/Indicator.js +0 -44
- package/dist/components/SectionHeader.d.ts +0 -8
- package/dist/components/SectionHeader.js +0 -11
- package/dist/components/SettingRow.d.ts +0 -18
- package/dist/components/SettingRow.js +0 -35
- package/dist/components/SettingsGroup.d.ts +0 -8
- package/dist/components/SettingsGroup.js +0 -17
- package/dist/components/ghostButton.d.ts +0 -4
- package/dist/components/ghostButton.js +0 -7
- package/dist/components/inputClasses.d.ts +0 -1
- package/dist/components/inputClasses.js +0 -4
- package/dist/duration.d.ts +0 -3
- package/dist/duration.js +0 -17
- package/dist/form/FieldGroup.d.ts +0 -11
- package/dist/form/FieldGroup.js +0 -36
- package/dist/form/FieldWrapper.d.ts +0 -16
- package/dist/form/FieldWrapper.js +0 -55
- package/dist/form/fieldContext.d.ts +0 -19
- package/dist/form/fieldContext.js +0 -26
- package/dist/graph/Collapse.d.ts +0 -7
- package/dist/graph/Collapse.js +0 -15
- package/dist/graph/ToolbarPopover.d.ts +0 -13
- package/dist/graph/ToolbarPopover.js +0 -39
- package/dist/icons/ai/AiOutlineRollback.js +0 -16
- package/dist/icons/bi/BiBell.js +0 -16
- package/dist/icons/bi/BiBellOff.js +0 -16
- package/dist/icons/bi/BiBuildings.js +0 -20
- package/dist/icons/bi/BiError.js +0 -20
- package/dist/icons/bi/BiExpandVertical.js +0 -16
- package/dist/icons/bi/BiPause.js +0 -16
- package/dist/icons/bi/BiPlay.js +0 -16
- package/dist/icons/bi/BiRedo.js +0 -16
- package/dist/icons/bi/BiSolidCheckShield.js +0 -16
- package/dist/icons/bi/BiSolidTrashAlt.js +0 -16
- package/dist/icons/bi/BiStop.js +0 -16
- package/dist/icons/bi/BiUndo.js +0 -16
- package/dist/icons/bs/BsArrowsCollapse.js +0 -22
- package/dist/icons/bs/BsBank2.js +0 -19
- package/dist/icons/bs/BsBriefcase.js +0 -19
- package/dist/icons/bs/BsBucket.js +0 -19
- package/dist/icons/bs/BsCalendarX.js +0 -23
- package/dist/icons/bs/BsChatLeft.js +0 -19
- package/dist/icons/bs/BsChevronDoubleDown.js +0 -29
- package/dist/icons/bs/BsChevronDoubleUp.js +0 -29
- package/dist/icons/bs/BsClipboardCheck.js +0 -34
- package/dist/icons/bs/BsCurrencyDollar.js +0 -19
- package/dist/icons/bs/BsDash.js +0 -19
- package/dist/icons/bs/BsFileEarmarkZip.js +0 -23
- package/dist/icons/bs/BsFiles.js +0 -19
- package/dist/icons/bs/BsGeoAlt.js +0 -23
- package/dist/icons/bs/BsGrid.js +0 -19
- package/dist/icons/bs/BsLayers.js +0 -19
- package/dist/icons/bs/BsLayoutThreeColumns.js +0 -19
- package/dist/icons/bs/BsListUl.js +0 -22
- package/dist/icons/bs/BsMortarboard.js +0 -23
- package/dist/icons/bs/BsMusicNoteBeamed.js +0 -34
- package/dist/icons/bs/BsOpenai.js +0 -19
- package/dist/icons/bs/BsPersonPlus.js +0 -26
- package/dist/icons/bs/BsSearch.js +0 -19
- package/dist/icons/bs/BsSend.js +0 -19
- package/dist/icons/bs/BsShieldSlash.js +0 -22
- package/dist/icons/bs/BsStar.js +0 -19
- package/dist/icons/bs/BsStarFill.js +0 -19
- package/dist/icons/bs/BsStopCircle.js +0 -23
- package/dist/icons/bs/BsTag.js +0 -23
- package/dist/icons/bs/BsTelephone.js +0 -19
- package/dist/icons/bs/BsTerminal.js +0 -23
- package/dist/icons/bs/BsTerminalFill.js +0 -19
- package/dist/icons/bs/BsThreeDots.js +0 -19
- package/dist/icons/bs/BsThreeDotsVertical.js +0 -19
- package/dist/icons/bs/BsZoomIn.js +0 -37
- package/dist/icons/fa/FaAmazon.js +0 -16
- package/dist/icons/fa/FaAngleDown.js +0 -16
- package/dist/icons/fa/FaAngleLeft.js +0 -16
- package/dist/icons/fa/FaAngleRight.js +0 -16
- package/dist/icons/fa/FaAngleUp.js +0 -16
- package/dist/icons/fa/FaArrowDown.js +0 -16
- package/dist/icons/fa/FaArrowLeft.js +0 -16
- package/dist/icons/fa/FaArrowRight.js +0 -16
- package/dist/icons/fa/FaArrowUp.js +0 -16
- package/dist/icons/fa/FaBalanceScale.js +0 -16
- package/dist/icons/fa/FaCaretDown.js +0 -16
- package/dist/icons/fa/FaCentos.js +0 -16
- package/dist/icons/fa/FaChartLine.js +0 -16
- package/dist/icons/fa/FaChartPie.js +0 -16
- package/dist/icons/fa/FaCheck.js +0 -16
- package/dist/icons/fa/FaChevronDown.js +0 -16
- package/dist/icons/fa/FaChevronUp.js +0 -16
- package/dist/icons/fa/FaChrome.js +0 -16
- package/dist/icons/fa/FaCircleNotch.js +0 -16
- package/dist/icons/fa/FaCloud.js +0 -16
- package/dist/icons/fa/FaCloudDownloadAlt.js +0 -16
- package/dist/icons/fa/FaCog.js +0 -16
- package/dist/icons/fa/FaCogs.js +0 -16
- package/dist/icons/fa/FaComments.js +0 -16
- package/dist/icons/fa/FaCompress.js +0 -16
- package/dist/icons/fa/FaDesktop.js +0 -16
- package/dist/icons/fa/FaDocker.js +0 -16
- package/dist/icons/fa/FaDollarSign.js +0 -16
- package/dist/icons/fa/FaEdge.js +0 -16
- package/dist/icons/fa/FaEdit.js +0 -16
- package/dist/icons/fa/FaExclamationTriangle.js +0 -16
- package/dist/icons/fa/FaExpand.js +0 -16
- package/dist/icons/fa/FaEye.js +0 -16
- package/dist/icons/fa/FaEyeSlash.js +0 -16
- package/dist/icons/fa/FaFile.js +0 -16
- package/dist/icons/fa/FaFilePdf.js +0 -16
- package/dist/icons/fa/FaFilter.js +0 -16
- package/dist/icons/fa/FaFirefoxBrowser.js +0 -16
- package/dist/icons/fa/FaFlask.js +0 -16
- package/dist/icons/fa/FaFolder.js +0 -16
- package/dist/icons/fa/FaGithub.js +0 -16
- package/dist/icons/fa/FaGitlab.js +0 -16
- package/dist/icons/fa/FaGlobe.js +0 -16
- package/dist/icons/fa/FaGlobeAmericas.js +0 -16
- package/dist/icons/fa/FaImage.js +0 -16
- package/dist/icons/fa/FaInfoCircle.js +0 -16
- package/dist/icons/fa/FaKey.js +0 -16
- package/dist/icons/fa/FaLayerGroup.js +0 -16
- package/dist/icons/fa/FaLink.js +0 -16
- package/dist/icons/fa/FaLinkedin.js +0 -16
- package/dist/icons/fa/FaLinux.js +0 -16
- package/dist/icons/fa/FaList.js +0 -16
- package/dist/icons/fa/FaLock.js +0 -16
- package/dist/icons/fa/FaOpenid.js +0 -16
- package/dist/icons/fa/FaOpera.js +0 -16
- package/dist/icons/fa/FaPaperclip.js +0 -16
- package/dist/icons/fa/FaPlus.js +0 -16
- package/dist/icons/fa/FaPowerOff.js +0 -16
- package/dist/icons/fa/FaPrint.js +0 -16
- package/dist/icons/fa/FaQrcode.js +0 -16
- package/dist/icons/fa/FaQuestionCircle.js +0 -16
- package/dist/icons/fa/FaRedhat.js +0 -16
- package/dist/icons/fa/FaRegCircle.js +0 -16
- package/dist/icons/fa/FaRegFileImage.js +0 -16
- package/dist/icons/fa/FaRegFolder.js +0 -16
- package/dist/icons/fa/FaRobot.js +0 -16
- package/dist/icons/fa/FaRocket.js +0 -16
- package/dist/icons/fa/FaRunning.js +0 -16
- package/dist/icons/fa/FaSafari.js +0 -16
- package/dist/icons/fa/FaSave.js +0 -16
- package/dist/icons/fa/FaSearch.js +0 -16
- package/dist/icons/fa/FaShieldAlt.js +0 -16
- package/dist/icons/fa/FaSlack.js +0 -16
- package/dist/icons/fa/FaStar.js +0 -16
- package/dist/icons/fa/FaStop.js +0 -16
- package/dist/icons/fa/FaSuse.js +0 -16
- package/dist/icons/fa/FaTerminal.js +0 -16
- package/dist/icons/fa/FaTimes.js +0 -16
- package/dist/icons/fa/FaUbuntu.js +0 -16
- package/dist/icons/fa/FaUndoAlt.js +0 -16
- package/dist/icons/fa/FaUnlink.js +0 -16
- package/dist/icons/fa/FaUser.js +0 -16
- package/dist/icons/fa/FaUsers.js +0 -16
- package/dist/icons/fa/FaWindows.js +0 -16
- package/dist/icons/fa6/FaApple.js +0 -16
- package/dist/icons/fa6/FaArrowsRotate.js +0 -16
- package/dist/icons/fa6/FaDebian.js +0 -16
- package/dist/icons/fa6/FaFilterCircleXmark.js +0 -16
- package/dist/icons/fa6/FaInbox.js +0 -16
- package/dist/icons/fa6/FaLocationDot.js +0 -16
- package/dist/icons/fa6/FaRegFilePdf.js +0 -16
- package/dist/icons/fa6/FaRegFolderOpen.js +0 -16
- package/dist/icons/fa6/FaUpRightFromSquare.js +0 -16
- package/dist/icons/fa6/FaWandMagicSparkles.js +0 -16
- package/dist/icons/fa6/FaXTwitter.js +0 -16
- package/dist/icons/fi/FiActivity.js +0 -23
- package/dist/icons/fi/FiAlertCircle.js +0 -49
- package/dist/icons/fi/FiChevronDown.js +0 -23
- package/dist/icons/fi/FiClock.js +0 -31
- package/dist/icons/fi/FiCopy.js +0 -34
- package/dist/icons/fi/FiDownload.js +0 -40
- package/dist/icons/fi/FiFile.js +0 -27
- package/dist/icons/fi/FiFileText.js +0 -55
- package/dist/icons/fi/FiHardDrive.js +0 -55
- package/dist/icons/fi/FiRotateCcw.js +0 -27
- package/dist/icons/fi/FiUpload.js +0 -40
- package/dist/icons/fi/FiX.js +0 -37
- package/dist/icons/fi/FiZap.js +0 -23
- package/dist/icons/gi/GiSpy.js +0 -16
- package/dist/icons/go/GoGitCommit.js +0 -16
- package/dist/icons/go/GoGitPullRequest.js +0 -20
- package/dist/icons/go/GoIssueOpened.js +0 -16
- package/dist/icons/go/GoPlus.js +0 -16
- package/dist/icons/go/GoRepoForked.js +0 -28
- package/dist/icons/go/GoSignOut.js +0 -16
- package/dist/icons/go/GoSkip.js +0 -20
- package/dist/icons/go/GoVideo.js +0 -20
- package/dist/icons/gr/GrCloudComputer.js +0 -20
- package/dist/icons/gr/GrInbox.js +0 -20
- package/dist/icons/gr/GrServerCluster.js +0 -20
- package/dist/icons/gr/GrStorage.js +0 -20
- package/dist/icons/gr/GrTasks.js +0 -20
- package/dist/icons/hi/HiCog.js +0 -24
- package/dist/icons/hi/HiDuplicate.js +0 -24
- package/dist/icons/hi/HiOutlineArchive.js +0 -26
- package/dist/icons/hi/HiOutlineClipboardCopy.js +0 -26
- package/dist/icons/hi/HiOutlineHome.js +0 -26
- package/dist/icons/hi/HiQuestionMarkCircle.js +0 -24
- package/dist/icons/hi/HiServer.js +0 -24
- package/dist/icons/hi2/HiMiniCheckCircle.js +0 -24
- package/dist/icons/hi2/HiMiniLanguage.js +0 -28
- package/dist/icons/hi2/HiMiniMinusCircle.js +0 -24
- package/dist/icons/hi2/HiMiniXCircle.js +0 -24
- package/dist/icons/hi2/HiSparkles.js +0 -24
- package/dist/icons/im/ImSpinner5.js +0 -19
- package/dist/icons/io/IoIosNotifications.js +0 -16
- package/dist/icons/io/IoMdBuild.js +0 -16
- package/dist/icons/io/IoMdClose.js +0 -16
- package/dist/icons/io5/IoCloudUploadOutline.js +0 -32
- package/dist/icons/io5/IoDocumentTextOutline.js +0 -31
- package/dist/icons/io5/IoFileTrayFullOutline.js +0 -31
- package/dist/icons/io5/IoHeart.js +0 -16
- package/dist/icons/io5/IoHeartDislike.js +0 -16
- package/dist/icons/io5/IoHeartOutline.js +0 -22
- package/dist/icons/io5/IoInformationCircleOutline.js +0 -50
- package/dist/icons/io5/IoSettingsOutline.js +0 -22
- package/dist/icons/io5/IoWarningOutline.js +0 -40
- package/dist/icons/lu/LuArrowRight.js +0 -27
- package/dist/icons/lu/LuBadgeCheck.js +0 -27
- package/dist/icons/lu/LuBraces.js +0 -27
- package/dist/icons/lu/LuBrainCircuit.js +0 -101
- package/dist/icons/lu/LuCalendar.js +0 -46
- package/dist/icons/lu/LuCheck.js +0 -23
- package/dist/icons/lu/LuChevronLeft.js +0 -23
- package/dist/icons/lu/LuChevronRight.js +0 -23
- package/dist/icons/lu/LuCode.js +0 -27
- package/dist/icons/lu/LuExternalLink.js +0 -35
- package/dist/icons/lu/LuEye.js +0 -31
- package/dist/icons/lu/LuEyeOff.js +0 -40
- package/dist/icons/lu/LuFolderTree.js +0 -40
- package/dist/icons/lu/LuIdCard.js +0 -55
- package/dist/icons/lu/LuKeyboard.js +0 -71
- package/dist/icons/lu/LuLogs.js +0 -65
- package/dist/icons/lu/LuMail.js +0 -33
- package/dist/icons/lu/LuMegaphone.js +0 -27
- package/dist/icons/lu/LuMoon.js +0 -23
- package/dist/icons/lu/LuNetwork.js +0 -63
- package/dist/icons/lu/LuPartyPopper.js +0 -65
- package/dist/icons/lu/LuSettings2.js +0 -48
- package/dist/icons/lu/LuSheet.js +0 -72
- package/dist/icons/lu/LuShield.js +0 -23
- package/dist/icons/lu/LuSun.js +0 -69
- package/dist/icons/lu/LuTextCursorInput.js +0 -45
- package/dist/icons/lu/LuX.js +0 -27
- package/dist/icons/lu/LuZoomIn.js +0 -59
- package/dist/icons/lu/LuZoomOut.js +0 -49
- package/dist/icons/md/MdClear.js +0 -23
- package/dist/icons/md/MdDragHandle.js +0 -23
- package/dist/icons/md/MdInstallDesktop.js +0 -31
- package/dist/icons/md/MdOutlineAttachMoney.js +0 -23
- package/dist/icons/md/MdOutlineMoneyOff.js +0 -23
- package/dist/icons/md/MdPieChart.js +0 -23
- package/dist/icons/md/MdRefresh.js +0 -23
- package/dist/icons/md/MdReplay.js +0 -23
- package/dist/icons/md/MdSmartphone.js +0 -23
- package/dist/icons/pi/PiArrowBendUpRightBold.js +0 -19
- package/dist/icons/pi/PiPlugsConnectedFill.js +0 -19
- package/dist/icons/pi/PiRectangleDashed.js +0 -19
- package/dist/icons/pi/PiShareBold.js +0 -19
- package/dist/icons/si/SiAnthropic.js +0 -19
- package/dist/icons/si/SiHelm.js +0 -19
- package/dist/icons/si/SiKubernetes.js +0 -19
- package/dist/icons/tb/TbAlertTriangle.js +0 -35
- package/dist/icons/tb/TbAlertTriangleFilled.js +0 -19
- package/dist/icons/tb/TbApi.js +0 -40
- package/dist/icons/tb/TbBrain.js +0 -50
- package/dist/icons/tb/TbBuildingTunnel.js +0 -65
- package/dist/icons/tb/TbEdit.js +0 -35
- package/dist/icons/tb/TbLayoutSidebar.js +0 -27
- package/dist/icons/tb/TbLayoutSidebarLeftCollapse.js +0 -35
- package/dist/icons/tb/TbLayoutSidebarRightCollapse.js +0 -35
- package/dist/icons/tb/TbUser.js +0 -27
- package/dist/icons/tb/TbUserOff.js +0 -35
- package/dist/icons/tb/TbWorldShare.js +0 -55
- package/dist/icons/tb/TbWorldWww.js +0 -65
- package/dist/icons/ti/TiArrowSortedDown.js +0 -20
- package/dist/icons/ti/TiArrowSortedUp.js +0 -20
- package/dist/icons/ti/TiArrowUnsorted.js +0 -20
- package/dist/icons/ti/TiCancel.js +0 -20
- package/dist/icons/vsc/VscChromeMinimize.js +0 -19
- package/dist/icons/vsc/VscJson.js +0 -19
- package/dist/icons/vsc/VscLayoutSidebarLeft.js +0 -19
- package/dist/icons/vsc/VscPass.js +0 -27
- package/dist/icons/vsc/VscSplitHorizontal.js +0 -19
- package/dist/icons/vsc/VscTerminalPowershell.js +0 -19
- package/dist/list/ListPager.d.ts +0 -14
- package/dist/list/ListPager.js +0 -62
- package/dist/list/textEntry.d.ts +0 -2
- package/dist/list/textEntry.js +0 -10
- /package/dist/{ai/ui/codeBreaks.d.ts → components/markdownCodeBreaks.d.ts} +0 -0
package/dist/ai/agent/toolfmt.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultToolStrings } from "./toolStrings.js";
|
|
1
2
|
//#region src/ai/agent/toolfmt.ts
|
|
2
3
|
var TOOL_HEADERS = {
|
|
3
4
|
Bash: {
|
|
@@ -141,27 +142,17 @@ function fullToolArgs(primary, argsJSON) {
|
|
|
141
142
|
totalClip: 0
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
|
-
function plural(n, noun) {
|
|
145
|
-
return `${n} ${pluralNoun(n, noun)}`;
|
|
146
|
-
}
|
|
147
|
-
function pluralNoun(n, noun) {
|
|
148
|
-
if (n === 1) return noun;
|
|
149
|
-
if (/(?:s|x|ch|sh)$/.test(noun)) return `${noun}es`;
|
|
150
|
-
return `${noun}s`;
|
|
151
|
-
}
|
|
152
145
|
var TOOL_OUTPUT_TRUNCATION_MARKER = "\n\n... output truncated to ";
|
|
153
146
|
function trimToolOutputNotice(body) {
|
|
154
147
|
const i = body.lastIndexOf(TOOL_OUTPUT_TRUNCATION_MARKER);
|
|
155
148
|
if (i >= 0) return [body.slice(0, i).replace(/\n+$/, ""), true];
|
|
156
149
|
return [body, false];
|
|
157
150
|
}
|
|
158
|
-
function summarizeToolResult(result) {
|
|
151
|
+
function summarizeToolResult(result, t) {
|
|
159
152
|
const trimmed = result.replace(/\n+$/, "");
|
|
160
|
-
if (trimmed.trim() === "") return
|
|
153
|
+
if (trimmed.trim() === "") return t.noOutput;
|
|
161
154
|
const lines = trimmed.split("\n");
|
|
162
|
-
|
|
163
|
-
if (lines.length > 1) return `${first} (+${lines.length - 1} lines)`;
|
|
164
|
-
return first;
|
|
155
|
+
return t.firstLine(clip((lines[0] ?? "").trim(), 100), lines.length - 1);
|
|
165
156
|
}
|
|
166
157
|
function isErrorResult(text) {
|
|
167
158
|
return text.trim().startsWith("Error:");
|
|
@@ -195,15 +186,14 @@ function contentLines(body) {
|
|
|
195
186
|
if (rest === "") return [[], note];
|
|
196
187
|
return [rest.split("\n"), note];
|
|
197
188
|
}
|
|
198
|
-
function readFileSummary(body) {
|
|
199
|
-
if (body === "(empty file)") return
|
|
200
|
-
if (body.startsWith("Read image ")) return
|
|
189
|
+
function readFileSummary(body, t) {
|
|
190
|
+
if (body === "(empty file)") return t.emptyFile;
|
|
191
|
+
if (body.startsWith("Read image ")) return t.readImage;
|
|
201
192
|
const [lines, note] = contentLines(body);
|
|
202
193
|
let more = 0;
|
|
203
194
|
const m = note.match(/^\.\.\. \(truncated, (\d+) more lines\)/);
|
|
204
195
|
if (m) more = Number(m[1]);
|
|
205
|
-
|
|
206
|
-
return `Read ${plural(lines.length, "line")}`;
|
|
196
|
+
return t.readLines(lines.length, more);
|
|
207
197
|
}
|
|
208
198
|
var GREP_CONTENT_PATH = /^(.+?):\d+:/;
|
|
209
199
|
function grepMatchPath(line, lineNums) {
|
|
@@ -213,9 +203,9 @@ function grepMatchPath(line, lineNums) {
|
|
|
213
203
|
}
|
|
214
204
|
return GREP_CONTENT_PATH.exec(line)?.[1] ?? null;
|
|
215
205
|
}
|
|
216
|
-
function grepSearchSummary(argsJSON, body) {
|
|
217
|
-
if (body === "No matches found." || body === "No results after applying offset.") return
|
|
218
|
-
if (body.startsWith(RIPGREP_ERROR_PREFIX)) return summarizeToolResult(body);
|
|
206
|
+
function grepSearchSummary(argsJSON, body, t) {
|
|
207
|
+
if (body === "No matches found." || body === "No results after applying offset.") return t.noMatches;
|
|
208
|
+
if (body.startsWith(RIPGREP_ERROR_PREFIX)) return summarizeToolResult(body, t);
|
|
219
209
|
const [lines, note] = contentLines(body);
|
|
220
210
|
let outputMode = "";
|
|
221
211
|
let lineNums = true;
|
|
@@ -234,7 +224,7 @@ function grepSearchSummary(argsJSON, body) {
|
|
|
234
224
|
matches++;
|
|
235
225
|
files.add(path);
|
|
236
226
|
}
|
|
237
|
-
s =
|
|
227
|
+
s = t.foundMatches(matches, files.size);
|
|
238
228
|
} else if (outputMode === "count") {
|
|
239
229
|
let total = 0;
|
|
240
230
|
for (const l of lines) {
|
|
@@ -243,17 +233,15 @@ function grepSearchSummary(argsJSON, body) {
|
|
|
243
233
|
const n = Number.parseInt(tail, 10);
|
|
244
234
|
if (!Number.isNaN(n)) total += n;
|
|
245
235
|
}
|
|
246
|
-
s =
|
|
247
|
-
} else s =
|
|
248
|
-
|
|
249
|
-
return s;
|
|
236
|
+
s = t.foundMatches(total, lines.length);
|
|
237
|
+
} else s = t.foundFiles(lines.length);
|
|
238
|
+
return note === "" ? s : t.truncated(s);
|
|
250
239
|
}
|
|
251
|
-
function globSearchSummary(body) {
|
|
252
|
-
if (body === "No files matched the pattern.") return
|
|
240
|
+
function globSearchSummary(body, t) {
|
|
241
|
+
if (body === "No files matched the pattern.") return t.noFilesMatched;
|
|
253
242
|
const [lines, note] = contentLines(body);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return s;
|
|
243
|
+
const s = t.foundFiles(lines.length);
|
|
244
|
+
return note === "" ? s : t.truncated(s);
|
|
257
245
|
}
|
|
258
246
|
function bashExitCode(body) {
|
|
259
247
|
let i = body.lastIndexOf("\nExit code: ");
|
|
@@ -273,60 +261,59 @@ function bashExitCode(body) {
|
|
|
273
261
|
true
|
|
274
262
|
];
|
|
275
263
|
}
|
|
276
|
-
function bashSummary(body) {
|
|
277
|
-
if (body === "(no output)") return
|
|
264
|
+
function bashSummary(body, t) {
|
|
265
|
+
if (body === "(no output)") return t.noOutput;
|
|
278
266
|
const [out, code, ok] = bashExitCode(body);
|
|
279
|
-
if (!ok) return summarizeToolResult(body);
|
|
280
|
-
|
|
281
|
-
return `Exit ${code} · ${plural(out.split("\n").length, "line")}`;
|
|
267
|
+
if (!ok) return summarizeToolResult(body, t);
|
|
268
|
+
return t.exitCode(code, out === "" ? 0 : out.split("\n").length);
|
|
282
269
|
}
|
|
283
|
-
function webFetchSummary(body) {
|
|
270
|
+
function webFetchSummary(body, t) {
|
|
284
271
|
const m = body.match(/^HTTP (\d+)/);
|
|
285
|
-
if (!m) return summarizeToolResult(body);
|
|
272
|
+
if (!m) return summarizeToolResult(body, t);
|
|
286
273
|
const status = Number(m[1]);
|
|
287
274
|
const sep = body.indexOf("\n\n");
|
|
288
275
|
if (sep < 0) return clip(body.split("\n")[0] ?? "", 100);
|
|
289
|
-
|
|
276
|
+
const rest = body.slice(sep + 2);
|
|
277
|
+
return t.httpStatus(status, rest.split("\n").length);
|
|
290
278
|
}
|
|
291
|
-
function toolSummary(name, args, result, isError,
|
|
279
|
+
function toolSummary(name, args, result, isError, { editSummary, strings: t = defaultToolStrings } = {}) {
|
|
292
280
|
const [body, spilled] = trimToolOutputNotice(result.replace(/\n+$/, ""));
|
|
293
|
-
if (isError || body.trim() === "" || isErrorResult(body)) return summarizeToolResult(result);
|
|
281
|
+
if (isError || body.trim() === "" || isErrorResult(body)) return summarizeToolResult(result, t);
|
|
294
282
|
let s;
|
|
295
283
|
switch (name) {
|
|
296
284
|
case "EditFile":
|
|
297
285
|
case "WriteFile": {
|
|
298
|
-
const e =
|
|
299
|
-
return e !== "" ? e : summarizeToolResult(result);
|
|
286
|
+
const e = editSummary?.(name, args, t) ?? "";
|
|
287
|
+
return e !== "" ? e : summarizeToolResult(result, t);
|
|
300
288
|
}
|
|
301
289
|
case "ReadFile":
|
|
302
|
-
s = readFileSummary(body);
|
|
290
|
+
s = readFileSummary(body, t);
|
|
303
291
|
break;
|
|
304
292
|
case "GrepSearch":
|
|
305
|
-
s = grepSearchSummary(args, body);
|
|
293
|
+
s = grepSearchSummary(args, body, t);
|
|
306
294
|
break;
|
|
307
295
|
case "GlobSearch":
|
|
308
|
-
s = globSearchSummary(body);
|
|
296
|
+
s = globSearchSummary(body, t);
|
|
309
297
|
break;
|
|
310
298
|
case "Bash":
|
|
311
|
-
s = bashSummary(body);
|
|
299
|
+
s = bashSummary(body, t);
|
|
312
300
|
break;
|
|
313
301
|
case "WebFetch":
|
|
314
|
-
s = webFetchSummary(body);
|
|
302
|
+
s = webFetchSummary(body, t);
|
|
315
303
|
break;
|
|
316
|
-
default: return summarizeToolResult(result);
|
|
304
|
+
default: return summarizeToolResult(result, t);
|
|
317
305
|
}
|
|
318
|
-
|
|
319
|
-
return s;
|
|
306
|
+
return spilled ? t.outputTruncated(s) : s;
|
|
320
307
|
}
|
|
321
308
|
var ROLLUP_CATEGORIES = [
|
|
322
|
-
[(n) => n === "GrepSearch" || n === "GlobSearch",
|
|
323
|
-
[(n) => n === "ReadFile",
|
|
324
|
-
[(n) => n === "Bash",
|
|
325
|
-
[(n) => n === "WebFetch",
|
|
326
|
-
[(n) => n === "Skill",
|
|
327
|
-
[(n) => n === "SendMessage",
|
|
328
|
-
[(n) => n.startsWith("mcp__"),
|
|
329
|
-
[() => true,
|
|
309
|
+
[(n) => n === "GrepSearch" || n === "GlobSearch", "searched"],
|
|
310
|
+
[(n) => n === "ReadFile", "read"],
|
|
311
|
+
[(n) => n === "Bash", "ranCommands"],
|
|
312
|
+
[(n) => n === "WebFetch", "fetched"],
|
|
313
|
+
[(n) => n === "Skill", "loadedSkills"],
|
|
314
|
+
[(n) => n === "SendMessage", "sentMessages"],
|
|
315
|
+
[(n) => n.startsWith("mcp__"), "calledMcpTools"],
|
|
316
|
+
[() => true, "ranTools"]
|
|
330
317
|
];
|
|
331
318
|
var NON_GROUPABLE_TOOLS = /* @__PURE__ */ new Set([
|
|
332
319
|
"EditFile",
|
|
@@ -337,7 +324,7 @@ var NON_GROUPABLE_TOOLS = /* @__PURE__ */ new Set([
|
|
|
337
324
|
function isGroupableTool(name) {
|
|
338
325
|
return !NON_GROUPABLE_TOOLS.has(name);
|
|
339
326
|
}
|
|
340
|
-
function rollupSentence(names) {
|
|
327
|
+
function rollupSentence(names, t = defaultToolStrings) {
|
|
341
328
|
const counts = ROLLUP_CATEGORIES.map(() => 0);
|
|
342
329
|
for (const name of names) for (let i = 0; i < ROLLUP_CATEGORIES.length; i++) if (ROLLUP_CATEGORIES[i]?.[0](name)) {
|
|
343
330
|
counts[i] = (counts[i] ?? 0) + 1;
|
|
@@ -348,12 +335,10 @@ function rollupSentence(names) {
|
|
|
348
335
|
const n = counts[i] ?? 0;
|
|
349
336
|
if (n > 0) {
|
|
350
337
|
const cat = ROLLUP_CATEGORIES[i];
|
|
351
|
-
if (cat) parts.push(cat[1](n));
|
|
338
|
+
if (cat) parts.push(t.rollup[cat[1]](n));
|
|
352
339
|
}
|
|
353
340
|
}
|
|
354
|
-
|
|
355
|
-
const s = parts.join(", ");
|
|
356
|
-
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
341
|
+
return parts.length === 0 ? "" : t.rollup.sentence(parts);
|
|
357
342
|
}
|
|
358
343
|
var AGENT_COLOR_NAMES = [
|
|
359
344
|
"blue",
|
|
@@ -379,4 +364,4 @@ function agentColorHex(name) {
|
|
|
379
364
|
return name ? AGENT_COLOR_HEX[name] ?? null : null;
|
|
380
365
|
}
|
|
381
366
|
//#endregion
|
|
382
|
-
export { AGENT_COLOR_NAMES, agentColorHex, bashExitCode, clip, fullToolArgs, isGroupableTool,
|
|
367
|
+
export { AGENT_COLOR_NAMES, agentColorHex, bashExitCode, clip, fullToolArgs, isGroupableTool, resultFailed, rollupSentence, sanitizeLabel, sanitizePanelText, summarizeToolArgs, toolHeaderFor, toolSummary };
|
package/dist/ai/ai.css
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* on a dark one, from whatever ink the theme (or an org palette) supplies. */
|
|
7
7
|
.chat-ink {
|
|
8
8
|
--chat-ink: light-dark(
|
|
9
|
-
color-mix(in oklab, var(--theme-
|
|
10
|
-
color-mix(in oklab, var(--theme-
|
|
9
|
+
color-mix(in oklab, var(--theme-app, #000) 60%, black),
|
|
10
|
+
color-mix(in oklab, var(--theme-app, #fff) 75%, white)
|
|
11
11
|
);
|
|
12
12
|
color: var(--chat-ink);
|
|
13
13
|
--tw-prose-body: var(--chat-ink);
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
font-size: 0.875rem;
|
|
54
54
|
font-family: var(--font-mono, ui-monospace, monospace);
|
|
55
55
|
padding: 0.125em 0.375em;
|
|
56
|
-
background-color: color-mix(in oklab, var(--theme-
|
|
56
|
+
background-color: color-mix(in oklab, var(--theme-app, #000) 8%, transparent);
|
|
57
57
|
border-radius: 0.25rem;
|
|
58
|
-
/* Identifiers carry a
|
|
58
|
+
/* Identifiers carry a color of their own so they read as code at a glance
|
|
59
59
|
* without the weight the plugin gives them: the theme's link blue, which
|
|
60
60
|
* every palette already keeps legible on its surfaces. */
|
|
61
61
|
color: var(--theme-link, #2f6fa8);
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
* table reads as part of the answer rather than a widget dropped into it),
|
|
111
111
|
* and the copy/download controls only while the pointer is over the table. */
|
|
112
112
|
.markdown [data-streamdown="table-wrapper"] {
|
|
113
|
-
--table-line: color-mix(in oklab, var(--theme-
|
|
113
|
+
--table-line: color-mix(in oklab, var(--theme-app, #000) 10%, transparent);
|
|
114
114
|
position: relative;
|
|
115
115
|
display: block;
|
|
116
116
|
background: transparent;
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
font-weight: 600;
|
|
153
153
|
color: inherit;
|
|
154
154
|
background: transparent;
|
|
155
|
-
border-bottom: 1px solid color-mix(in oklab, var(--theme-
|
|
155
|
+
border-bottom: 1px solid color-mix(in oklab, var(--theme-app, #000) 28%, transparent);
|
|
156
156
|
}
|
|
157
157
|
.markdown [data-streamdown="table"] td {
|
|
158
158
|
padding: 0.4375rem 0.75rem;
|
|
@@ -187,7 +187,8 @@
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/* Streamdown code blocks: one surface, not a frame around an inset panel.
|
|
190
|
-
*
|
|
190
|
+
* The theme's code surface, which the syntax colors are solved against, with a
|
|
191
|
+
* hairline edge holds the language on its top edge,
|
|
191
192
|
* the copy and download controls quiet beside it, and the code on the same
|
|
192
193
|
* ground, so the block reads as part of the answer. */
|
|
193
194
|
.markdown [data-streamdown="code-block"] {
|
|
@@ -197,8 +198,8 @@
|
|
|
197
198
|
border: 0;
|
|
198
199
|
border-radius: 0.75rem;
|
|
199
200
|
overflow: hidden;
|
|
200
|
-
background:
|
|
201
|
-
box-shadow: 0 0 0 1px color-mix(in oklab, var(--theme-
|
|
201
|
+
background: var(--theme-code-bg, #f3f4f6);
|
|
202
|
+
box-shadow: 0 0 0 1px color-mix(in oklab, var(--theme-app, #000) 8%, transparent);
|
|
202
203
|
}
|
|
203
204
|
.markdown [data-streamdown="code-block-header"] {
|
|
204
205
|
height: 2.25rem;
|
|
@@ -222,8 +223,8 @@
|
|
|
222
223
|
color 150ms ease-out;
|
|
223
224
|
}
|
|
224
225
|
.markdown [data-streamdown="code-block-actions"] button:hover {
|
|
225
|
-
color: var(--theme-
|
|
226
|
-
background: color-mix(in oklab, var(--theme-
|
|
226
|
+
color: var(--theme-app, #000);
|
|
227
|
+
background: color-mix(in oklab, var(--theme-app, #000) 7%, transparent);
|
|
227
228
|
}
|
|
228
229
|
.markdown [data-streamdown="code-block-body"] {
|
|
229
230
|
border: 0;
|
|
@@ -247,7 +248,7 @@
|
|
|
247
248
|
explicitly to ensure correct colors in all modes.
|
|
248
249
|
See: https://shiki.style/guide/dual-themes#class-based-dark-mode */
|
|
249
250
|
|
|
250
|
-
/* Light mode: the primary Shiki theme's
|
|
251
|
+
/* Light mode: the primary Shiki theme's colors (--sdm-c) on the block's own
|
|
251
252
|
surface, which stands in for the theme's background. */
|
|
252
253
|
.markdown [data-streamdown="code-block-body"] pre {
|
|
253
254
|
/* biome-ignore lint/complexity/noImportantStyles: the highlighter sets the background as an inline style */
|
|
@@ -258,7 +259,7 @@
|
|
|
258
259
|
color: var(--sdm-c, inherit);
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
/* Dark mode: the --shiki-dark
|
|
262
|
+
/* Dark mode: the --shiki-dark colors, again on the block's surface. */
|
|
262
263
|
.dark .markdown [data-streamdown="code-block-body"] pre {
|
|
263
264
|
/* biome-ignore lint/complexity/noImportantStyles: the highlighter sets the background as an inline style */
|
|
264
265
|
background-color: transparent !important;
|
|
@@ -311,20 +312,6 @@
|
|
|
311
312
|
-webkit-mask-image: linear-gradient(to bottom, black calc(100% - 96px), transparent);
|
|
312
313
|
}
|
|
313
314
|
|
|
314
|
-
/* Theme-aware input styling (matches the host app's .theme-input; defined
|
|
315
|
-
* here too so the edit textarea is styled in standalone use) */
|
|
316
|
-
.theme-input {
|
|
317
|
-
background-color: var(--theme-input-bg, #f9fafb);
|
|
318
|
-
border-color: var(--theme-border, #d1d5db);
|
|
319
|
-
color: var(--theme-app, #374151);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
.theme-input:focus {
|
|
323
|
-
border-color: var(--theme-element, #3b82f6);
|
|
324
|
-
outline: none;
|
|
325
|
-
box-shadow: 0 0 0 1px var(--theme-element, #3b82f6);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
315
|
@keyframes shimmer {
|
|
329
316
|
0% {
|
|
330
317
|
background-position: 200% 0;
|
|
@@ -374,25 +361,25 @@
|
|
|
374
361
|
/* Tints of the ink for controls that sit on the panel: the theme's hover is a
|
|
375
362
|
* shade off another surface and would not read as a highlight here. */
|
|
376
363
|
@utility chat-tint {
|
|
377
|
-
background-color: color-mix(in oklab, var(--theme-
|
|
364
|
+
background-color: color-mix(in oklab, var(--theme-app, #000) 6%, transparent);
|
|
378
365
|
}
|
|
379
366
|
@utility chat-tint-strong {
|
|
380
|
-
background-color: color-mix(in oklab, var(--theme-
|
|
367
|
+
background-color: color-mix(in oklab, var(--theme-app, #000) 10%, transparent);
|
|
381
368
|
}
|
|
382
369
|
|
|
383
370
|
/* The composer is one surface lifted off the page: a hairline of the ink for
|
|
384
371
|
* its edge, and a short, soft shadow that deepens while it has focus. The
|
|
385
|
-
* shadow is black on every scheme; an ink-
|
|
372
|
+
* shadow is black on every scheme; an ink-colored one would glow on dark. */
|
|
386
373
|
.chat-composer {
|
|
387
374
|
box-shadow:
|
|
388
|
-
0 0 0 1px color-mix(in oklab, var(--theme-
|
|
375
|
+
0 0 0 1px color-mix(in oklab, var(--theme-app, #000) 12%, transparent),
|
|
389
376
|
0 1px 2px rgb(0 0 0 / 0.04),
|
|
390
377
|
0 6px 16px -8px rgb(0 0 0 / 0.12);
|
|
391
378
|
transition: box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
392
379
|
}
|
|
393
380
|
.chat-composer:focus-within {
|
|
394
381
|
box-shadow:
|
|
395
|
-
0 0 0 1px color-mix(in oklab, var(--theme-
|
|
382
|
+
0 0 0 1px color-mix(in oklab, var(--theme-app, #000) 22%, transparent),
|
|
396
383
|
0 1px 2px rgb(0 0 0 / 0.05),
|
|
397
384
|
0 10px 24px -10px rgb(0 0 0 / 0.18);
|
|
398
385
|
}
|
|
@@ -425,7 +412,7 @@
|
|
|
425
412
|
/* An edge drawn from the ink rather than the theme's border, so a card reads
|
|
426
413
|
* the same on the panel and on a tinted bubble. */
|
|
427
414
|
.chat-hairline {
|
|
428
|
-
box-shadow: 0 0 0 1px color-mix(in oklab, var(--theme-
|
|
415
|
+
box-shadow: 0 0 0 1px color-mix(in oklab, var(--theme-app, #000) 10%, transparent);
|
|
429
416
|
}
|
|
430
417
|
|
|
431
418
|
/* A bubble carrying pastes would shrink to its shortest line and squeeze
|
|
@@ -442,7 +429,7 @@
|
|
|
442
429
|
.chat-composer,
|
|
443
430
|
.chat-empty,
|
|
444
431
|
.chat-reasoning-body {
|
|
445
|
-
--chat-accent: var(--theme-accent, var(--theme-
|
|
432
|
+
--chat-accent: var(--theme-accent, var(--theme-accent, #06354f));
|
|
446
433
|
}
|
|
447
434
|
|
|
448
435
|
/* What the reader wrote carries a wash of the accent: theirs, not the
|
|
@@ -503,6 +490,6 @@
|
|
|
503
490
|
* losing contrast. */
|
|
504
491
|
.chat-queued .chat-bubble-user {
|
|
505
492
|
background: transparent;
|
|
506
|
-
outline: 1px dashed color-mix(in oklab, var(--theme-
|
|
493
|
+
outline: 1px dashed color-mix(in oklab, var(--theme-app, #000) 30%, transparent);
|
|
507
494
|
outline-offset: -1px;
|
|
508
495
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChevronDownIcon } from "../../icons.js";
|
|
2
2
|
import { Select } from "../../components/Select.js";
|
|
3
3
|
import { useChatConfig } from "../core/config.js";
|
|
4
4
|
import { useChat } from "../core/ChatProvider.js";
|
|
@@ -46,7 +46,7 @@ function AllocationSelector() {
|
|
|
46
46
|
children: [/* @__PURE__ */ jsx("span", {
|
|
47
47
|
className: "truncate",
|
|
48
48
|
children: selected?.name ?? t.placeholder
|
|
49
|
-
}), /* @__PURE__ */ jsx(
|
|
49
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
50
50
|
className: "h-3 w-3 shrink-0",
|
|
51
51
|
"aria-hidden": "true"
|
|
52
52
|
})]
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FiFile } from "../../icons/fi/FiFile.js";
|
|
1
|
+
import { cx } from "../../cx.js";
|
|
2
|
+
import { DownloadIcon, FileIcon, TrashIcon } from "../../icons.js";
|
|
4
3
|
import { safeUrl } from "../../safeUrl.js";
|
|
4
|
+
import { EmptyState } from "../../components/EmptyState.js";
|
|
5
|
+
import { Loader } from "../../components/Loader.js";
|
|
6
|
+
import { toast } from "../../components/Toast.js";
|
|
7
|
+
import { useStrings } from "../../components/Provider.js";
|
|
8
|
+
import { formatBytes } from "../../format.js";
|
|
9
|
+
import { RelativeTime } from "../../components/relativeTime.js";
|
|
5
10
|
import { useChatConfig } from "../core/config.js";
|
|
6
11
|
import { useChat } from "../core/ChatProvider.js";
|
|
7
|
-
import { formatFileSize } from "../utils.js";
|
|
8
12
|
import { attachmentsPageKey } from "./attachmentKeys.js";
|
|
9
|
-
import { clsx } from "clsx";
|
|
10
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
14
|
import { useCallback, useMemo, useState } from "react";
|
|
12
|
-
import { DateTime } from "luxon";
|
|
13
15
|
import useSWRInfinite from "swr/infinite";
|
|
14
16
|
//#region src/ai/components/AttachmentManager.tsx
|
|
15
17
|
function triggerDownload(url, filename) {
|
|
@@ -23,8 +25,9 @@ function triggerDownload(url, filename) {
|
|
|
23
25
|
document.body.removeChild(a);
|
|
24
26
|
}
|
|
25
27
|
function AttachmentManager() {
|
|
26
|
-
const { adapter
|
|
28
|
+
const { adapter } = useChat();
|
|
27
29
|
const t = useChatConfig().strings.attachmentManager;
|
|
30
|
+
const { common } = useStrings();
|
|
28
31
|
const attachmentsAdapter = adapter.attachments;
|
|
29
32
|
const [deleting, setDeleting] = useState(null);
|
|
30
33
|
const [thumbnails, setThumbnails] = useState({});
|
|
@@ -46,15 +49,11 @@ function AttachmentManager() {
|
|
|
46
49
|
await attachmentsAdapter.remove(attachmentId);
|
|
47
50
|
await mutate();
|
|
48
51
|
} catch (error) {
|
|
49
|
-
|
|
52
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
50
53
|
} finally {
|
|
51
54
|
setDeleting(null);
|
|
52
55
|
}
|
|
53
|
-
}, [
|
|
54
|
-
attachmentsAdapter,
|
|
55
|
-
mutate,
|
|
56
|
-
notify
|
|
57
|
-
]);
|
|
56
|
+
}, [attachmentsAdapter, mutate]);
|
|
58
57
|
if (!attachmentsAdapter) return null;
|
|
59
58
|
const hasMore = pages?.[pages.length - 1]?.hasMore ?? false;
|
|
60
59
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -66,14 +65,14 @@ function AttachmentManager() {
|
|
|
66
65
|
children: /* @__PURE__ */ jsxs("div", {
|
|
67
66
|
className: "max-w-4xl mx-auto",
|
|
68
67
|
children: [/* @__PURE__ */ jsx("h1", {
|
|
69
|
-
className: "text-2xl font-semibold mb-6 text-(--theme-
|
|
68
|
+
className: "text-2xl font-semibold mb-6 text-(--theme-app)",
|
|
70
69
|
children: t.title
|
|
71
70
|
}), isLoading && attachments.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
72
|
-
className: "
|
|
73
|
-
children: /* @__PURE__ */ jsx(
|
|
74
|
-
}) : attachments.length === 0 ? /* @__PURE__ */ jsx(
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
className: "py-12",
|
|
72
|
+
children: /* @__PURE__ */ jsx(Loader, { size: 32 })
|
|
73
|
+
}) : attachments.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
74
|
+
variant: "bare",
|
|
75
|
+
title: t.empty
|
|
77
76
|
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
78
77
|
className: "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",
|
|
79
78
|
children: attachments.map((att) => {
|
|
@@ -87,14 +86,14 @@ function AttachmentManager() {
|
|
|
87
86
|
style: { cursor: "pointer" }
|
|
88
87
|
} : {};
|
|
89
88
|
return /* @__PURE__ */ jsxs("div", {
|
|
90
|
-
className:
|
|
89
|
+
className: cx("rounded-lg border theme-border overflow-hidden", isDeleting && "opacity-50 pointer-events-none"),
|
|
91
90
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
92
91
|
className: "relative aspect-square bg-(--theme-muted-panel-bg) flex items-center justify-center",
|
|
93
92
|
...openProps,
|
|
94
|
-
children: [/* @__PURE__ */ jsx(
|
|
93
|
+
children: [/* @__PURE__ */ jsx(FileIcon, { className: "w-8 h-8 theme-muted-text" }), showThumbnail && /* @__PURE__ */ jsx("img", {
|
|
95
94
|
src: downloadUrl,
|
|
96
95
|
alt: att.filename || "Image",
|
|
97
|
-
className:
|
|
96
|
+
className: cx("absolute inset-0 w-full h-full object-cover", thumbnail !== "loaded" && "opacity-0"),
|
|
98
97
|
loading: "lazy",
|
|
99
98
|
onLoad: () => markThumbnail(att.id, "loaded"),
|
|
100
99
|
onError: () => markThumbnail(att.id, "broken")
|
|
@@ -104,11 +103,11 @@ function AttachmentManager() {
|
|
|
104
103
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
105
104
|
className: "min-w-0 flex-1",
|
|
106
105
|
children: [/* @__PURE__ */ jsx("p", {
|
|
107
|
-
className: "truncate font-medium text-(--theme-
|
|
106
|
+
className: "truncate font-medium text-(--theme-app)",
|
|
108
107
|
children: att.filename || "File"
|
|
109
108
|
}), /* @__PURE__ */ jsxs("p", {
|
|
110
109
|
className: "truncate theme-muted-text",
|
|
111
|
-
children: [att.size ?
|
|
110
|
+
children: [att.size ? formatBytes(att.size) : "", att.uploadedAt && /* @__PURE__ */ jsxs(Fragment, { children: [att.size ? " · " : "", /* @__PURE__ */ jsx(RelativeTime, { value: att.uploadedAt })] })]
|
|
112
111
|
})]
|
|
113
112
|
}), /* @__PURE__ */ jsxs("div", {
|
|
114
113
|
className: "flex items-center gap-0.5 flex-shrink-0",
|
|
@@ -116,15 +115,15 @@ function AttachmentManager() {
|
|
|
116
115
|
type: "button",
|
|
117
116
|
onClick: () => triggerDownload(downloadUrl, att.filename || "File"),
|
|
118
117
|
className: "p-1.5 rounded-lg hover:theme-hover theme-muted-text transition-colors",
|
|
119
|
-
title:
|
|
120
|
-
children: /* @__PURE__ */ jsx(
|
|
118
|
+
title: common.download,
|
|
119
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, { className: "w-4 h-4" })
|
|
121
120
|
}), /* @__PURE__ */ jsx("button", {
|
|
122
121
|
type: "button",
|
|
123
122
|
onClick: () => handleDelete(att.id),
|
|
124
123
|
disabled: isDeleting,
|
|
125
124
|
className: "p-1.5 rounded-lg hover:bg-red-500/15 theme-muted-text hover:text-red-600 transition-colors",
|
|
126
|
-
title:
|
|
127
|
-
children: /* @__PURE__ */ jsx(
|
|
125
|
+
title: common.delete,
|
|
126
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "w-4 h-4" })
|
|
128
127
|
})]
|
|
129
128
|
})]
|
|
130
129
|
})]
|
|
@@ -137,7 +136,7 @@ function AttachmentManager() {
|
|
|
137
136
|
onClick: () => setSize(size + 1),
|
|
138
137
|
disabled: isValidating,
|
|
139
138
|
className: "px-6 py-3 text-sm rounded-lg theme-muted-panel hover:theme-hover transition-colors disabled:opacity-50",
|
|
140
|
-
children: isValidating ?
|
|
139
|
+
children: isValidating ? common.loading : common.loadMore
|
|
141
140
|
})
|
|
142
141
|
})] })]
|
|
143
142
|
})
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { cx } from "../../cx.js";
|
|
2
|
+
import { AddIcon, FileIcon, ImageIcon, PdfIcon, TrashIcon, WarningIcon } from "../../icons.js";
|
|
3
|
+
import { toast } from "../../components/Toast.js";
|
|
4
|
+
import { useStrings } from "../../components/Provider.js";
|
|
5
|
+
import { formatBytes } from "../../format.js";
|
|
6
6
|
import { useChatConfig } from "../core/config.js";
|
|
7
7
|
import { useChat } from "../core/ChatProvider.js";
|
|
8
|
-
import { formatFileSize } from "../utils.js";
|
|
9
8
|
import { ATTACHMENTS_INFINITE_KEY } from "./attachmentKeys.js";
|
|
10
|
-
import { clsx } from "clsx";
|
|
11
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
10
|
import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from "react";
|
|
13
11
|
import { mutate } from "swr";
|
|
@@ -15,18 +13,19 @@ import { mutate } from "swr";
|
|
|
15
13
|
var DEFAULT_MAX_FILE_SIZE = 26214400;
|
|
16
14
|
var DEFAULT_MAX_FILES = 10;
|
|
17
15
|
function getFileIcon(mimeType) {
|
|
18
|
-
if (!mimeType) return
|
|
19
|
-
if (mimeType.startsWith("image/")) return
|
|
20
|
-
if (mimeType === "application/pdf") return
|
|
21
|
-
return
|
|
16
|
+
if (!mimeType) return FileIcon;
|
|
17
|
+
if (mimeType.startsWith("image/")) return ImageIcon;
|
|
18
|
+
if (mimeType === "application/pdf") return PdfIcon;
|
|
19
|
+
return FileIcon;
|
|
22
20
|
}
|
|
23
21
|
var AttachmentUpload = forwardRef(function AttachmentUpload({ conversationId, attachments, onAttachmentsChange, disabled = false, maxFiles = DEFAULT_MAX_FILES, maxFileSize = DEFAULT_MAX_FILE_SIZE }, ref) {
|
|
24
|
-
const { adapter
|
|
22
|
+
const { adapter } = useChat();
|
|
25
23
|
const t = useChatConfig().strings.attachmentUpload;
|
|
24
|
+
const { common } = useStrings();
|
|
26
25
|
const [isDragging, setIsDragging] = useState(false);
|
|
27
26
|
const fileInputRef = useRef(null);
|
|
28
27
|
const validateFile = useCallback((file) => {
|
|
29
|
-
if (file.size > maxFileSize) return t.fileTooLarge(
|
|
28
|
+
if (file.size > maxFileSize) return t.fileTooLarge(formatBytes(maxFileSize));
|
|
30
29
|
if (attachments.length >= maxFiles) return t.maxFilesAllowed(maxFiles);
|
|
31
30
|
return null;
|
|
32
31
|
}, [
|
|
@@ -63,7 +62,7 @@ var AttachmentUpload = forwardRef(function AttachmentUpload({ conversationId, at
|
|
|
63
62
|
for (const file of fileArray) {
|
|
64
63
|
const error = validateFile(file);
|
|
65
64
|
if (error) {
|
|
66
|
-
|
|
65
|
+
toast.error(error);
|
|
67
66
|
continue;
|
|
68
67
|
}
|
|
69
68
|
const pendingAttachment = {
|
|
@@ -83,7 +82,6 @@ var AttachmentUpload = forwardRef(function AttachmentUpload({ conversationId, at
|
|
|
83
82
|
onAttachmentsChange(attachments.concat(uploaded.filter((a) => a !== null)));
|
|
84
83
|
}, [
|
|
85
84
|
attachments,
|
|
86
|
-
notify,
|
|
87
85
|
onAttachmentsChange,
|
|
88
86
|
uploadFile,
|
|
89
87
|
validateFile
|
|
@@ -127,7 +125,7 @@ var AttachmentUpload = forwardRef(function AttachmentUpload({ conversationId, at
|
|
|
127
125
|
children: attachments.map((attachment, index) => {
|
|
128
126
|
const Icon = getFileIcon(attachment.mimeType);
|
|
129
127
|
return /* @__PURE__ */ jsxs("div", {
|
|
130
|
-
className:
|
|
128
|
+
className: cx("flex items-center gap-2 px-2 py-1 rounded border theme-border theme-muted-panel", attachment.error && "border-red-500"),
|
|
131
129
|
children: [
|
|
132
130
|
/* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 theme-muted-text" }),
|
|
133
131
|
/* @__PURE__ */ jsx("span", {
|
|
@@ -136,24 +134,25 @@ var AttachmentUpload = forwardRef(function AttachmentUpload({ conversationId, at
|
|
|
136
134
|
}),
|
|
137
135
|
/* @__PURE__ */ jsx("span", {
|
|
138
136
|
className: "text-xs theme-muted-text",
|
|
139
|
-
children:
|
|
137
|
+
children: formatBytes(attachment.size)
|
|
140
138
|
}),
|
|
141
139
|
attachment.uploading && /* @__PURE__ */ jsx("span", {
|
|
142
140
|
className: "text-xs text-blue-500 animate-pulse",
|
|
143
|
-
children:
|
|
141
|
+
children: t.uploading
|
|
144
142
|
}),
|
|
145
143
|
attachment.error && /* @__PURE__ */ jsx("span", {
|
|
146
|
-
|
|
144
|
+
role: "img",
|
|
145
|
+
"aria-label": attachment.error,
|
|
147
146
|
title: attachment.error,
|
|
148
|
-
children: "
|
|
147
|
+
children: /* @__PURE__ */ jsx(WarningIcon, { className: "h-3.5 w-3.5 text-red-500" })
|
|
149
148
|
}),
|
|
150
149
|
/* @__PURE__ */ jsx("button", {
|
|
151
150
|
type: "button",
|
|
152
151
|
onClick: () => handleRemove(index),
|
|
153
152
|
className: "p-0.5 rounded hover:bg-red-500/10",
|
|
154
|
-
title:
|
|
153
|
+
title: common.remove,
|
|
155
154
|
disabled,
|
|
156
|
-
children: /* @__PURE__ */ jsx(
|
|
155
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "w-3 h-3 text-red-500" })
|
|
157
156
|
})
|
|
158
157
|
]
|
|
159
158
|
}, attachment.id || index);
|
|
@@ -163,18 +162,14 @@ var AttachmentUpload = forwardRef(function AttachmentUpload({ conversationId, at
|
|
|
163
162
|
onDragOver: handleDragOver,
|
|
164
163
|
onDragLeave: handleDragLeave,
|
|
165
164
|
onDrop: handleDrop,
|
|
166
|
-
className:
|
|
165
|
+
className: cx("relative block w-full border-2 border-dashed rounded-lg p-3 text-center transition-colors", isDragging ? "border-blue-500 bg-blue-500/10" : "theme-border hover:theme-border", disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"),
|
|
167
166
|
onClick: disabled ? void 0 : handleClick,
|
|
168
167
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
169
168
|
className: "flex items-center justify-center gap-2 text-sm theme-muted-text",
|
|
170
|
-
children: [/* @__PURE__ */ jsx(
|
|
171
|
-
}), /* @__PURE__ */
|
|
169
|
+
children: [/* @__PURE__ */ jsx(AddIcon, { className: "w-4 h-4" }), /* @__PURE__ */ jsx("span", { children: isDragging ? t.dropFilesHere : t.addFiles })]
|
|
170
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
172
171
|
className: "block text-xs theme-muted-text mt-1",
|
|
173
|
-
children:
|
|
174
|
-
"Max ",
|
|
175
|
-
formatFileSize(maxFileSize),
|
|
176
|
-
" per file"
|
|
177
|
-
]
|
|
172
|
+
children: t.maxSizePerFile(formatBytes(maxFileSize))
|
|
178
173
|
})]
|
|
179
174
|
})]
|
|
180
175
|
})] });
|