@agimon-ai/po-web-components 0.0.0-alpha.195 → 0.0.0-alpha.196
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/po-runtime-identity.json +1 -1
- package/dist/src/components/McpApp.cjs +1 -1
- package/dist/src/components/McpApp.cjs.map +1 -1
- package/dist/src/components/McpApp.d.mts.map +1 -1
- package/dist/src/components/McpApp.mjs +1 -1
- package/dist/src/components/McpApp.mjs.map +1 -1
- package/dist/src/components/McpToolWidget.cjs +2 -2
- package/dist/src/components/McpToolWidget.cjs.map +1 -1
- package/dist/src/components/McpToolWidget.d.mts.map +1 -1
- package/dist/src/components/McpToolWidget.mjs +2 -2
- package/dist/src/components/McpToolWidget.mjs.map +1 -1
- package/dist/src/components/MessageItem.cjs +1 -1
- package/dist/src/components/MessageItem.cjs.map +1 -1
- package/dist/src/components/MessageItem.d.mts.map +1 -1
- package/dist/src/components/MessageItem.mjs +1 -1
- package/dist/src/components/MessageItem.mjs.map +1 -1
- package/dist/src/components/Picker.cjs +1 -1
- package/dist/src/components/Picker.cjs.map +1 -1
- package/dist/src/components/Picker.d.mts.map +1 -1
- package/dist/src/components/Picker.mjs +1 -1
- package/dist/src/components/Picker.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","NOTICE","README.md","llms.txt","package.json","src/components/Accordion.stories.tsx","src/components/Accordion.tsx","src/components/AgentAvatar.stories.tsx","src/components/AgentAvatar.tsx","src/components/AnsiText.stories.tsx","src/components/AnsiText.tsx","src/components/Avatar.stories.tsx","src/components/Avatar.tsx","src/components/Badge.stories.tsx","src/components/Badge.tsx","src/components/BrandPalette.stories.tsx","src/components/Breadcrumb.stories.tsx","src/components/Breadcrumb.tsx","src/components/Button.stories.tsx","src/components/Button.tsx","src/components/Checkbox.stories.tsx","src/components/Checkbox.tsx","src/components/CodeBlock.stories.tsx","src/components/CodeBlock.tsx","src/components/CodeEditor.stories.tsx","src/components/CodeEditor.tsx","src/components/CodeEditorView.stories.tsx","src/components/CodeEditorView.tsx","src/components/Collapsible.stories.tsx","src/components/Collapsible.tsx","src/components/Command.stories.tsx","src/components/Command.tsx","src/components/CopyButton.stories.tsx","src/components/CopyButton.tsx","src/components/CtaCard.stories.tsx","src/components/CtaCard.tsx","src/components/Dialog.stories.tsx","src/components/Dialog.tsx","src/components/DiffView.stories.tsx","src/components/DiffView.tsx","src/components/Dot.stories.tsx","src/components/Dot.tsx","src/components/Drawer.stories.tsx","src/components/Drawer.tsx","src/components/DropdownMenu.stories.tsx","src/components/DropdownMenu.tsx","src/components/EmptyState.stories.tsx","src/components/EmptyState.tsx","src/components/FileBrowser.stories.tsx","src/components/FileBrowser.tsx","src/components/FilePreview.stories.tsx","src/components/FilePreview.tsx","src/components/FlowGraph.stories.tsx","src/components/FlowGraph.tsx","src/components/HashlineLines.stories.tsx","src/components/HashlineLines.tsx","src/components/Input.stories.tsx","src/components/Input.tsx","src/components/Kbd.stories.tsx","src/components/Kbd.tsx","src/components/Label.stories.tsx","src/components/Label.tsx","src/components/LiveDuration.tsx","src/components/LoadingState.stories.tsx","src/components/LoadingState.tsx","src/components/Markdown.stories.tsx","src/components/Markdown.tsx","src/components/McpApp.tsx","src/components/McpToolWidget.stories.tsx","src/components/McpToolWidget.tsx","src/components/MediaPreview.stories.tsx","src/components/MediaPreview.tsx","src/components/MediaViewerDialog.stories.tsx","src/components/MediaViewerDialog.tsx","src/components/MermaidDiagram.stories.tsx","src/components/MermaidDiagram.tsx","src/components/MessageItem.stories.tsx","src/components/MessageItem.tsx","src/components/MessageLines.stories.tsx","src/components/MessageLines.tsx","src/components/OptionList.stories.tsx","src/components/OptionList.tsx","src/components/Panel.stories.tsx","src/components/Panel.tsx","src/components/PathText.stories.tsx","src/components/PathText.tsx","src/components/PdfPreview.stories.tsx","src/components/PdfPreview.tsx","src/components/Picker.stories.tsx","src/components/Picker.tsx","src/components/Popover.stories.tsx","src/components/Popover.tsx","src/components/ProfilePicker.stories.tsx","src/components/ProfilePicker.tsx","src/components/Progress.stories.tsx","src/components/Progress.tsx","src/components/QrCode.stories.tsx","src/components/QrCode.tsx","src/components/RadioGroup.stories.tsx","src/components/RadioGroup.tsx","src/components/ReviewCommentDraft.stories.tsx","src/components/ReviewCommentDraft.tsx","src/components/ScrollArea.stories.tsx","src/components/ScrollArea.tsx","src/components/SectionLabel.stories.tsx","src/components/SectionLabel.tsx","src/components/Select.stories.tsx","src/components/Select.tsx","src/components/Separator.stories.tsx","src/components/Separator.tsx","src/components/Settings.tsx","src/components/SetupRow.stories.tsx","src/components/SetupRow.tsx","src/components/Sheet.stories.tsx","src/components/Sheet.tsx","src/components/Skeleton.stories.tsx","src/components/Skeleton.tsx","src/components/Spinner.stories.tsx","src/components/Spinner.tsx","src/components/StatusBadge.stories.tsx","src/components/StatusBadge.tsx","src/components/StreamCursor.stories.tsx","src/components/StreamCursor.tsx","src/components/Switch.stories.tsx","src/components/Switch.tsx","src/components/SyntaxText.stories.tsx","src/components/SyntaxText.tsx","src/components/Tabs.stories.tsx","src/components/Tabs.tsx","src/components/TerminalView.stories.tsx","src/components/TerminalView.tsx","src/components/Textarea.stories.tsx","src/components/Textarea.tsx","src/components/Toast.stories.tsx","src/components/Toast.tsx","src/components/ToolPathLink.stories.tsx","src/components/ToolPathLink.tsx","src/components/Tooltip.stories.tsx","src/components/Tooltip.tsx","src/components/ViewableImage.stories.tsx","src/components/ViewableImage.tsx","src/exports/index.ts","src/exports/markdownMediaSlot.ts","src/exports/mcpAppHost.ts","src/exports/mcpWidget.ts","src/exports/nativeTheme.ts","src/exports/text.ts","src/exports/theme.ts","src/icons/icons.ts","src/lib/ansiSpans.ts","src/lib/cn.ts","src/lib/collapse.ts","src/lib/editorController.ts","src/lib/editorLanguage.ts","src/lib/editorTheme.ts","src/lib/fenceGrammar.ts","src/lib/fileDownload.ts","src/lib/files.ts","src/lib/hashlineHighlight.ts","src/lib/hashlineView.ts","src/lib/markdownMedia.ts","src/lib/markdownMediaSlot.ts","src/lib/markdownReferences.ts","src/lib/mcpAppFrame.ts","src/lib/mcpAppSandbox.ts","src/lib/mcpOpenAiBootstrap.ts","src/lib/media.ts","src/lib/mediaPlayback.ts","src/lib/mermaidDiagram.ts","src/lib/optionList.ts","src/lib/pathGroups.ts","src/lib/picker.ts","src/lib/profilePicker.ts","src/lib/qrMatrix.ts","src/lib/review.ts","src/lib/runDuration.ts","src/lib/syntaxHighlight.ts","src/lib/tone.ts","src/theme/apply.ts","src/theme/builtinThemes.ts","src/theme/derive.ts","src/theme/nativeTheme.ts","src/theme/parse.ts","src/theme/piTheme.ts","src/theme/preference.ts","src/types/diff.ts","src/types/editor.ts","src/types/theme.ts","src/types/tone.ts","styles/mcp.css","styles/preview.css","styles/theme.css","styles/tokens.css","themes/po-nord-dark.json","themes/po-one-light.json","tsdown.config.ts"],"sourceRevision":"d10fbb0570a8f5ccc26042d9dff9bffa","manifestRevision":"cd6b56004e8885b5b8d28b3764b1405e","outputFiles":["LICENSE","NOTICE","README.md","dist/_virtual/_rolldown/runtime.cjs","dist/index.cjs","dist/index.mjs","dist/markdownMediaSlot.cjs","dist/markdownMediaSlot.mjs","dist/mcpAppHost.cjs","dist/mcpAppHost.mjs","dist/mcpWidget.cjs","dist/mcpWidget.mjs","dist/nativeTheme.cjs","dist/nativeTheme.mjs","dist/src/components/Accordion.cjs","dist/src/components/Accordion.mjs","dist/src/components/AgentAvatar.cjs","dist/src/components/AgentAvatar.mjs","dist/src/components/AnsiText.cjs","dist/src/components/AnsiText.mjs","dist/src/components/Avatar.cjs","dist/src/components/Avatar.mjs","dist/src/components/Badge.cjs","dist/src/components/Badge.mjs","dist/src/components/Breadcrumb.cjs","dist/src/components/Breadcrumb.mjs","dist/src/components/Button.cjs","dist/src/components/Button.mjs","dist/src/components/Checkbox.cjs","dist/src/components/Checkbox.mjs","dist/src/components/CodeBlock.cjs","dist/src/components/CodeBlock.mjs","dist/src/components/CodeEditor.cjs","dist/src/components/CodeEditor.mjs","dist/src/components/CodeEditorView.cjs","dist/src/components/CodeEditorView.mjs","dist/src/components/Collapsible.cjs","dist/src/components/Collapsible.mjs","dist/src/components/Command.cjs","dist/src/components/Command.mjs","dist/src/components/CopyButton.cjs","dist/src/components/CopyButton.mjs","dist/src/components/CtaCard.cjs","dist/src/components/CtaCard.mjs","dist/src/components/Dialog.cjs","dist/src/components/Dialog.mjs","dist/src/components/DiffView.cjs","dist/src/components/DiffView.mjs","dist/src/components/Dot.cjs","dist/src/components/Dot.mjs","dist/src/components/Drawer.cjs","dist/src/components/Drawer.mjs","dist/src/components/DropdownMenu.cjs","dist/src/components/DropdownMenu.mjs","dist/src/components/EmptyState.cjs","dist/src/components/EmptyState.mjs","dist/src/components/FileBrowser.cjs","dist/src/components/FileBrowser.mjs","dist/src/components/FilePreview.cjs","dist/src/components/FilePreview.mjs","dist/src/components/FlowGraph.cjs","dist/src/components/FlowGraph.mjs","dist/src/components/HashlineLines.cjs","dist/src/components/HashlineLines.mjs","dist/src/components/Input.cjs","dist/src/components/Input.mjs","dist/src/components/Kbd.cjs","dist/src/components/Kbd.mjs","dist/src/components/Label.cjs","dist/src/components/Label.mjs","dist/src/components/LiveDuration.cjs","dist/src/components/LiveDuration.mjs","dist/src/components/LoadingState.cjs","dist/src/components/LoadingState.mjs","dist/src/components/Markdown.cjs","dist/src/components/Markdown.mjs","dist/src/components/McpApp.cjs","dist/src/components/McpApp.mjs","dist/src/components/McpToolWidget.cjs","dist/src/components/McpToolWidget.mjs","dist/src/components/MediaPreview.cjs","dist/src/components/MediaPreview.mjs","dist/src/components/MediaViewerDialog.cjs","dist/src/components/MediaViewerDialog.mjs","dist/src/components/MermaidDiagram.cjs","dist/src/components/MermaidDiagram.mjs","dist/src/components/MessageItem.cjs","dist/src/components/MessageItem.mjs","dist/src/components/MessageLines.cjs","dist/src/components/MessageLines.mjs","dist/src/components/OptionList.cjs","dist/src/components/OptionList.mjs","dist/src/components/Panel.cjs","dist/src/components/Panel.mjs","dist/src/components/PathText.cjs","dist/src/components/PathText.mjs","dist/src/components/PdfPreview.cjs","dist/src/components/PdfPreview.mjs","dist/src/components/Picker.cjs","dist/src/components/Picker.mjs","dist/src/components/Popover.cjs","dist/src/components/Popover.mjs","dist/src/components/ProfilePicker.cjs","dist/src/components/ProfilePicker.mjs","dist/src/components/Progress.cjs","dist/src/components/Progress.mjs","dist/src/components/QrCode.cjs","dist/src/components/QrCode.mjs","dist/src/components/RadioGroup.cjs","dist/src/components/RadioGroup.mjs","dist/src/components/ReviewCommentDraft.cjs","dist/src/components/ReviewCommentDraft.mjs","dist/src/components/ScrollArea.cjs","dist/src/components/ScrollArea.mjs","dist/src/components/SectionLabel.cjs","dist/src/components/SectionLabel.mjs","dist/src/components/Select.cjs","dist/src/components/Select.mjs","dist/src/components/Separator.cjs","dist/src/components/Separator.mjs","dist/src/components/Settings.cjs","dist/src/components/Settings.mjs","dist/src/components/SetupRow.cjs","dist/src/components/SetupRow.mjs","dist/src/components/Sheet.cjs","dist/src/components/Sheet.mjs","dist/src/components/Skeleton.cjs","dist/src/components/Skeleton.mjs","dist/src/components/Spinner.cjs","dist/src/components/Spinner.mjs","dist/src/components/StatusBadge.cjs","dist/src/components/StatusBadge.mjs","dist/src/components/StreamCursor.cjs","dist/src/components/StreamCursor.mjs","dist/src/components/Switch.cjs","dist/src/components/Switch.mjs","dist/src/components/SyntaxText.cjs","dist/src/components/SyntaxText.mjs","dist/src/components/Tabs.cjs","dist/src/components/Tabs.mjs","dist/src/components/TerminalView.cjs","dist/src/components/TerminalView.mjs","dist/src/components/Textarea.cjs","dist/src/components/Textarea.mjs","dist/src/components/Toast.cjs","dist/src/components/Toast.mjs","dist/src/components/ToolPathLink.cjs","dist/src/components/ToolPathLink.mjs","dist/src/components/Tooltip.cjs","dist/src/components/Tooltip.mjs","dist/src/components/ViewableImage.cjs","dist/src/components/ViewableImage.mjs","dist/src/icons/icons.cjs","dist/src/icons/icons.mjs","dist/src/lib/ansiSpans.cjs","dist/src/lib/ansiSpans.mjs","dist/src/lib/cn.cjs","dist/src/lib/cn.mjs","dist/src/lib/collapse.cjs","dist/src/lib/collapse.mjs","dist/src/lib/editorController.cjs","dist/src/lib/editorController.mjs","dist/src/lib/editorLanguage.cjs","dist/src/lib/editorLanguage.mjs","dist/src/lib/editorTheme.cjs","dist/src/lib/editorTheme.mjs","dist/src/lib/fenceGrammar.cjs","dist/src/lib/fenceGrammar.mjs","dist/src/lib/fileDownload.cjs","dist/src/lib/fileDownload.mjs","dist/src/lib/files.cjs","dist/src/lib/files.mjs","dist/src/lib/hashlineHighlight.cjs","dist/src/lib/hashlineHighlight.mjs","dist/src/lib/hashlineView.cjs","dist/src/lib/hashlineView.mjs","dist/src/lib/markdownMedia.cjs","dist/src/lib/markdownMedia.mjs","dist/src/lib/markdownMediaSlot.cjs","dist/src/lib/markdownMediaSlot.mjs","dist/src/lib/markdownReferences.cjs","dist/src/lib/markdownReferences.mjs","dist/src/lib/mcpAppFrame.cjs","dist/src/lib/mcpAppFrame.mjs","dist/src/lib/mcpAppSandbox.cjs","dist/src/lib/mcpAppSandbox.mjs","dist/src/lib/mcpOpenAiBootstrap.cjs","dist/src/lib/mcpOpenAiBootstrap.mjs","dist/src/lib/media.cjs","dist/src/lib/media.mjs","dist/src/lib/mediaPlayback.cjs","dist/src/lib/mediaPlayback.mjs","dist/src/lib/mermaidDiagram.cjs","dist/src/lib/mermaidDiagram.mjs","dist/src/lib/optionList.cjs","dist/src/lib/optionList.mjs","dist/src/lib/pathGroups.cjs","dist/src/lib/pathGroups.mjs","dist/src/lib/picker.cjs","dist/src/lib/picker.mjs","dist/src/lib/profilePicker.cjs","dist/src/lib/profilePicker.mjs","dist/src/lib/qrMatrix.cjs","dist/src/lib/qrMatrix.mjs","dist/src/lib/review.cjs","dist/src/lib/review.mjs","dist/src/lib/runDuration.cjs","dist/src/lib/runDuration.mjs","dist/src/lib/syntaxHighlight.cjs","dist/src/lib/syntaxHighlight.mjs","dist/src/lib/tone.cjs","dist/src/lib/tone.mjs","dist/src/theme/apply.cjs","dist/src/theme/apply.mjs","dist/src/theme/builtinThemes.cjs","dist/src/theme/builtinThemes.mjs","dist/src/theme/derive.cjs","dist/src/theme/derive.mjs","dist/src/theme/nativeTheme.cjs","dist/src/theme/nativeTheme.mjs","dist/src/theme/parse.cjs","dist/src/theme/parse.mjs","dist/src/theme/piTheme.cjs","dist/src/theme/piTheme.mjs","dist/src/theme/preference.cjs","dist/src/theme/preference.mjs","dist/src/types/editor.cjs","dist/src/types/editor.mjs","dist/src/types/theme.cjs","dist/src/types/theme.mjs","dist/src/types/tone.cjs","dist/src/types/tone.mjs","dist/text.cjs","dist/text.mjs","dist/theme.cjs","dist/theme.mjs","dist/themes/po-nord-dark.cjs","dist/themes/po-nord-dark.mjs","dist/themes/po-one-light.cjs","dist/themes/po-one-light.mjs","llms.txt","styles/mcp.css","styles/preview.css","styles/theme.css","styles/tokens.css","themes/po-nord-dark.json","themes/po-one-light.json"],"outputRevision":"4c11b3104ef1e183105e2919654c2a16"}
|
|
1
|
+
{"version":1,"platformRequirements":{},"sourceFiles":["LICENSE","NOTICE","README.md","llms.txt","package.json","src/components/Accordion.stories.tsx","src/components/Accordion.tsx","src/components/AgentAvatar.stories.tsx","src/components/AgentAvatar.tsx","src/components/AnsiText.stories.tsx","src/components/AnsiText.tsx","src/components/Avatar.stories.tsx","src/components/Avatar.tsx","src/components/Badge.stories.tsx","src/components/Badge.tsx","src/components/BrandPalette.stories.tsx","src/components/Breadcrumb.stories.tsx","src/components/Breadcrumb.tsx","src/components/Button.stories.tsx","src/components/Button.tsx","src/components/Checkbox.stories.tsx","src/components/Checkbox.tsx","src/components/CodeBlock.stories.tsx","src/components/CodeBlock.tsx","src/components/CodeEditor.stories.tsx","src/components/CodeEditor.tsx","src/components/CodeEditorView.stories.tsx","src/components/CodeEditorView.tsx","src/components/Collapsible.stories.tsx","src/components/Collapsible.tsx","src/components/Command.stories.tsx","src/components/Command.tsx","src/components/CopyButton.stories.tsx","src/components/CopyButton.tsx","src/components/CtaCard.stories.tsx","src/components/CtaCard.tsx","src/components/Dialog.stories.tsx","src/components/Dialog.tsx","src/components/DiffView.stories.tsx","src/components/DiffView.tsx","src/components/Dot.stories.tsx","src/components/Dot.tsx","src/components/Drawer.stories.tsx","src/components/Drawer.tsx","src/components/DropdownMenu.stories.tsx","src/components/DropdownMenu.tsx","src/components/EmptyState.stories.tsx","src/components/EmptyState.tsx","src/components/FileBrowser.stories.tsx","src/components/FileBrowser.tsx","src/components/FilePreview.stories.tsx","src/components/FilePreview.tsx","src/components/FlowGraph.stories.tsx","src/components/FlowGraph.tsx","src/components/HashlineLines.stories.tsx","src/components/HashlineLines.tsx","src/components/Input.stories.tsx","src/components/Input.tsx","src/components/Kbd.stories.tsx","src/components/Kbd.tsx","src/components/Label.stories.tsx","src/components/Label.tsx","src/components/LiveDuration.tsx","src/components/LoadingState.stories.tsx","src/components/LoadingState.tsx","src/components/Markdown.stories.tsx","src/components/Markdown.tsx","src/components/McpApp.tsx","src/components/McpToolWidget.stories.tsx","src/components/McpToolWidget.tsx","src/components/MediaPreview.stories.tsx","src/components/MediaPreview.tsx","src/components/MediaViewerDialog.stories.tsx","src/components/MediaViewerDialog.tsx","src/components/MermaidDiagram.stories.tsx","src/components/MermaidDiagram.tsx","src/components/MessageItem.stories.tsx","src/components/MessageItem.tsx","src/components/MessageLines.stories.tsx","src/components/MessageLines.tsx","src/components/OptionList.stories.tsx","src/components/OptionList.tsx","src/components/Panel.stories.tsx","src/components/Panel.tsx","src/components/PathText.stories.tsx","src/components/PathText.tsx","src/components/PdfPreview.stories.tsx","src/components/PdfPreview.tsx","src/components/Picker.stories.tsx","src/components/Picker.tsx","src/components/Popover.stories.tsx","src/components/Popover.tsx","src/components/ProfilePicker.stories.tsx","src/components/ProfilePicker.tsx","src/components/Progress.stories.tsx","src/components/Progress.tsx","src/components/QrCode.stories.tsx","src/components/QrCode.tsx","src/components/RadioGroup.stories.tsx","src/components/RadioGroup.tsx","src/components/ReviewCommentDraft.stories.tsx","src/components/ReviewCommentDraft.tsx","src/components/ScrollArea.stories.tsx","src/components/ScrollArea.tsx","src/components/SectionLabel.stories.tsx","src/components/SectionLabel.tsx","src/components/Select.stories.tsx","src/components/Select.tsx","src/components/Separator.stories.tsx","src/components/Separator.tsx","src/components/Settings.tsx","src/components/SetupRow.stories.tsx","src/components/SetupRow.tsx","src/components/Sheet.stories.tsx","src/components/Sheet.tsx","src/components/Skeleton.stories.tsx","src/components/Skeleton.tsx","src/components/Spinner.stories.tsx","src/components/Spinner.tsx","src/components/StatusBadge.stories.tsx","src/components/StatusBadge.tsx","src/components/StreamCursor.stories.tsx","src/components/StreamCursor.tsx","src/components/Switch.stories.tsx","src/components/Switch.tsx","src/components/SyntaxText.stories.tsx","src/components/SyntaxText.tsx","src/components/Tabs.stories.tsx","src/components/Tabs.tsx","src/components/TerminalView.stories.tsx","src/components/TerminalView.tsx","src/components/Textarea.stories.tsx","src/components/Textarea.tsx","src/components/Toast.stories.tsx","src/components/Toast.tsx","src/components/ToolPathLink.stories.tsx","src/components/ToolPathLink.tsx","src/components/Tooltip.stories.tsx","src/components/Tooltip.tsx","src/components/ViewableImage.stories.tsx","src/components/ViewableImage.tsx","src/exports/index.ts","src/exports/markdownMediaSlot.ts","src/exports/mcpAppHost.ts","src/exports/mcpWidget.ts","src/exports/nativeTheme.ts","src/exports/text.ts","src/exports/theme.ts","src/icons/icons.ts","src/lib/ansiSpans.ts","src/lib/cn.ts","src/lib/collapse.ts","src/lib/editorController.ts","src/lib/editorLanguage.ts","src/lib/editorTheme.ts","src/lib/fenceGrammar.ts","src/lib/fileDownload.ts","src/lib/files.ts","src/lib/hashlineHighlight.ts","src/lib/hashlineView.ts","src/lib/markdownMedia.ts","src/lib/markdownMediaSlot.ts","src/lib/markdownReferences.ts","src/lib/mcpAppFrame.ts","src/lib/mcpAppSandbox.ts","src/lib/mcpOpenAiBootstrap.ts","src/lib/media.ts","src/lib/mediaPlayback.ts","src/lib/mermaidDiagram.ts","src/lib/optionList.ts","src/lib/pathGroups.ts","src/lib/picker.ts","src/lib/profilePicker.ts","src/lib/qrMatrix.ts","src/lib/review.ts","src/lib/runDuration.ts","src/lib/syntaxHighlight.ts","src/lib/tone.ts","src/theme/apply.ts","src/theme/builtinThemes.ts","src/theme/derive.ts","src/theme/nativeTheme.ts","src/theme/parse.ts","src/theme/piTheme.ts","src/theme/preference.ts","src/types/diff.ts","src/types/editor.ts","src/types/theme.ts","src/types/tone.ts","styles/mcp.css","styles/preview.css","styles/theme.css","styles/tokens.css","themes/po-nord-dark.json","themes/po-one-light.json","tsdown.config.ts"],"sourceRevision":"63379ad09fdadadfe0b76221b20652e9","manifestRevision":"95dd1d0bbdb2d7caf7b6d118bfab45a3","outputFiles":["LICENSE","NOTICE","README.md","dist/_virtual/_rolldown/runtime.cjs","dist/index.cjs","dist/index.mjs","dist/markdownMediaSlot.cjs","dist/markdownMediaSlot.mjs","dist/mcpAppHost.cjs","dist/mcpAppHost.mjs","dist/mcpWidget.cjs","dist/mcpWidget.mjs","dist/nativeTheme.cjs","dist/nativeTheme.mjs","dist/src/components/Accordion.cjs","dist/src/components/Accordion.mjs","dist/src/components/AgentAvatar.cjs","dist/src/components/AgentAvatar.mjs","dist/src/components/AnsiText.cjs","dist/src/components/AnsiText.mjs","dist/src/components/Avatar.cjs","dist/src/components/Avatar.mjs","dist/src/components/Badge.cjs","dist/src/components/Badge.mjs","dist/src/components/Breadcrumb.cjs","dist/src/components/Breadcrumb.mjs","dist/src/components/Button.cjs","dist/src/components/Button.mjs","dist/src/components/Checkbox.cjs","dist/src/components/Checkbox.mjs","dist/src/components/CodeBlock.cjs","dist/src/components/CodeBlock.mjs","dist/src/components/CodeEditor.cjs","dist/src/components/CodeEditor.mjs","dist/src/components/CodeEditorView.cjs","dist/src/components/CodeEditorView.mjs","dist/src/components/Collapsible.cjs","dist/src/components/Collapsible.mjs","dist/src/components/Command.cjs","dist/src/components/Command.mjs","dist/src/components/CopyButton.cjs","dist/src/components/CopyButton.mjs","dist/src/components/CtaCard.cjs","dist/src/components/CtaCard.mjs","dist/src/components/Dialog.cjs","dist/src/components/Dialog.mjs","dist/src/components/DiffView.cjs","dist/src/components/DiffView.mjs","dist/src/components/Dot.cjs","dist/src/components/Dot.mjs","dist/src/components/Drawer.cjs","dist/src/components/Drawer.mjs","dist/src/components/DropdownMenu.cjs","dist/src/components/DropdownMenu.mjs","dist/src/components/EmptyState.cjs","dist/src/components/EmptyState.mjs","dist/src/components/FileBrowser.cjs","dist/src/components/FileBrowser.mjs","dist/src/components/FilePreview.cjs","dist/src/components/FilePreview.mjs","dist/src/components/FlowGraph.cjs","dist/src/components/FlowGraph.mjs","dist/src/components/HashlineLines.cjs","dist/src/components/HashlineLines.mjs","dist/src/components/Input.cjs","dist/src/components/Input.mjs","dist/src/components/Kbd.cjs","dist/src/components/Kbd.mjs","dist/src/components/Label.cjs","dist/src/components/Label.mjs","dist/src/components/LiveDuration.cjs","dist/src/components/LiveDuration.mjs","dist/src/components/LoadingState.cjs","dist/src/components/LoadingState.mjs","dist/src/components/Markdown.cjs","dist/src/components/Markdown.mjs","dist/src/components/McpApp.cjs","dist/src/components/McpApp.mjs","dist/src/components/McpToolWidget.cjs","dist/src/components/McpToolWidget.mjs","dist/src/components/MediaPreview.cjs","dist/src/components/MediaPreview.mjs","dist/src/components/MediaViewerDialog.cjs","dist/src/components/MediaViewerDialog.mjs","dist/src/components/MermaidDiagram.cjs","dist/src/components/MermaidDiagram.mjs","dist/src/components/MessageItem.cjs","dist/src/components/MessageItem.mjs","dist/src/components/MessageLines.cjs","dist/src/components/MessageLines.mjs","dist/src/components/OptionList.cjs","dist/src/components/OptionList.mjs","dist/src/components/Panel.cjs","dist/src/components/Panel.mjs","dist/src/components/PathText.cjs","dist/src/components/PathText.mjs","dist/src/components/PdfPreview.cjs","dist/src/components/PdfPreview.mjs","dist/src/components/Picker.cjs","dist/src/components/Picker.mjs","dist/src/components/Popover.cjs","dist/src/components/Popover.mjs","dist/src/components/ProfilePicker.cjs","dist/src/components/ProfilePicker.mjs","dist/src/components/Progress.cjs","dist/src/components/Progress.mjs","dist/src/components/QrCode.cjs","dist/src/components/QrCode.mjs","dist/src/components/RadioGroup.cjs","dist/src/components/RadioGroup.mjs","dist/src/components/ReviewCommentDraft.cjs","dist/src/components/ReviewCommentDraft.mjs","dist/src/components/ScrollArea.cjs","dist/src/components/ScrollArea.mjs","dist/src/components/SectionLabel.cjs","dist/src/components/SectionLabel.mjs","dist/src/components/Select.cjs","dist/src/components/Select.mjs","dist/src/components/Separator.cjs","dist/src/components/Separator.mjs","dist/src/components/Settings.cjs","dist/src/components/Settings.mjs","dist/src/components/SetupRow.cjs","dist/src/components/SetupRow.mjs","dist/src/components/Sheet.cjs","dist/src/components/Sheet.mjs","dist/src/components/Skeleton.cjs","dist/src/components/Skeleton.mjs","dist/src/components/Spinner.cjs","dist/src/components/Spinner.mjs","dist/src/components/StatusBadge.cjs","dist/src/components/StatusBadge.mjs","dist/src/components/StreamCursor.cjs","dist/src/components/StreamCursor.mjs","dist/src/components/Switch.cjs","dist/src/components/Switch.mjs","dist/src/components/SyntaxText.cjs","dist/src/components/SyntaxText.mjs","dist/src/components/Tabs.cjs","dist/src/components/Tabs.mjs","dist/src/components/TerminalView.cjs","dist/src/components/TerminalView.mjs","dist/src/components/Textarea.cjs","dist/src/components/Textarea.mjs","dist/src/components/Toast.cjs","dist/src/components/Toast.mjs","dist/src/components/ToolPathLink.cjs","dist/src/components/ToolPathLink.mjs","dist/src/components/Tooltip.cjs","dist/src/components/Tooltip.mjs","dist/src/components/ViewableImage.cjs","dist/src/components/ViewableImage.mjs","dist/src/icons/icons.cjs","dist/src/icons/icons.mjs","dist/src/lib/ansiSpans.cjs","dist/src/lib/ansiSpans.mjs","dist/src/lib/cn.cjs","dist/src/lib/cn.mjs","dist/src/lib/collapse.cjs","dist/src/lib/collapse.mjs","dist/src/lib/editorController.cjs","dist/src/lib/editorController.mjs","dist/src/lib/editorLanguage.cjs","dist/src/lib/editorLanguage.mjs","dist/src/lib/editorTheme.cjs","dist/src/lib/editorTheme.mjs","dist/src/lib/fenceGrammar.cjs","dist/src/lib/fenceGrammar.mjs","dist/src/lib/fileDownload.cjs","dist/src/lib/fileDownload.mjs","dist/src/lib/files.cjs","dist/src/lib/files.mjs","dist/src/lib/hashlineHighlight.cjs","dist/src/lib/hashlineHighlight.mjs","dist/src/lib/hashlineView.cjs","dist/src/lib/hashlineView.mjs","dist/src/lib/markdownMedia.cjs","dist/src/lib/markdownMedia.mjs","dist/src/lib/markdownMediaSlot.cjs","dist/src/lib/markdownMediaSlot.mjs","dist/src/lib/markdownReferences.cjs","dist/src/lib/markdownReferences.mjs","dist/src/lib/mcpAppFrame.cjs","dist/src/lib/mcpAppFrame.mjs","dist/src/lib/mcpAppSandbox.cjs","dist/src/lib/mcpAppSandbox.mjs","dist/src/lib/mcpOpenAiBootstrap.cjs","dist/src/lib/mcpOpenAiBootstrap.mjs","dist/src/lib/media.cjs","dist/src/lib/media.mjs","dist/src/lib/mediaPlayback.cjs","dist/src/lib/mediaPlayback.mjs","dist/src/lib/mermaidDiagram.cjs","dist/src/lib/mermaidDiagram.mjs","dist/src/lib/optionList.cjs","dist/src/lib/optionList.mjs","dist/src/lib/pathGroups.cjs","dist/src/lib/pathGroups.mjs","dist/src/lib/picker.cjs","dist/src/lib/picker.mjs","dist/src/lib/profilePicker.cjs","dist/src/lib/profilePicker.mjs","dist/src/lib/qrMatrix.cjs","dist/src/lib/qrMatrix.mjs","dist/src/lib/review.cjs","dist/src/lib/review.mjs","dist/src/lib/runDuration.cjs","dist/src/lib/runDuration.mjs","dist/src/lib/syntaxHighlight.cjs","dist/src/lib/syntaxHighlight.mjs","dist/src/lib/tone.cjs","dist/src/lib/tone.mjs","dist/src/theme/apply.cjs","dist/src/theme/apply.mjs","dist/src/theme/builtinThemes.cjs","dist/src/theme/builtinThemes.mjs","dist/src/theme/derive.cjs","dist/src/theme/derive.mjs","dist/src/theme/nativeTheme.cjs","dist/src/theme/nativeTheme.mjs","dist/src/theme/parse.cjs","dist/src/theme/parse.mjs","dist/src/theme/piTheme.cjs","dist/src/theme/piTheme.mjs","dist/src/theme/preference.cjs","dist/src/theme/preference.mjs","dist/src/types/editor.cjs","dist/src/types/editor.mjs","dist/src/types/theme.cjs","dist/src/types/theme.mjs","dist/src/types/tone.cjs","dist/src/types/tone.mjs","dist/text.cjs","dist/text.mjs","dist/theme.cjs","dist/theme.mjs","dist/themes/po-nord-dark.cjs","dist/themes/po-nord-dark.mjs","dist/themes/po-one-light.cjs","dist/themes/po-one-light.mjs","llms.txt","styles/mcp.css","styles/preview.css","styles/theme.css","styles/tokens.css","themes/po-nord-dark.json","themes/po-one-light.json"],"outputRevision":"3b5c5d987bc451db260eda9eddfa08da"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react/jsx-runtime"),t=require("react"),n=require("@modelcontextprotocol/ext-apps"),
|
|
1
|
+
let e=require("react/jsx-runtime"),t=require("react"),n=require("@agimon-ai/po-core/web"),r=require("@modelcontextprotocol/ext-apps"),i=require("react-dom/client");var a=class extends t.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?/* @__PURE__ */ (0,e.jsx)(`p`,{role:`status`,children:this.props.failure}):this.props.children}};function o({widgets:t,view:r}){let i=(0,n.useT)(),o=r.widget!==void 0&&Object.hasOwn(t,r.widget)?t[r.widget]:void 0;return r.failure?/* @__PURE__ */ (0,e.jsx)(`p`,{role:`status`,children:r.failure}):o===void 0?/* @__PURE__ */ (0,e.jsx)(`p`,{role:`status`,children:r.widget===void 0?i(`webComponents.mcpApp.waiting`,`Waiting for tool information...`):i(`webComponents.mcpApp.unavailable`,`No widget is available for this tool.`)}):/* @__PURE__ */ (0,e.jsx)(a,{failure:i(`webComponents.mcpApp.renderFailed`,`The tool widget could not be rendered.`),children:/* @__PURE__ */ (0,e.jsx)(o,{...r.props})},r.widget)}async function s(t){let n=document.getElementById(`root`);if(n===null)throw Error(`Missing MCP app root`);let a=(0,i.createRoot)(n),s=new r.App({name:`po-tools`,version:`1.0.0`},{},{autoResize:!0}),c=!1,l=!1,u=!1,d=!1,f={props:{toolName:``,args:{},result:null,phase:`connecting`}},p=()=>{c||a.render(/* @__PURE__ */ (0,e.jsx)(o,{widgets:t,view:f}))},m=e=>{l=!0,f={...f,failure:e},p()},h=(e,t)=>{if(typeof e==`string`&&e.length>0){if(f.props.toolName&&f.props.toolName!==e)return m(`The tool changed. Reopen this widget from the conversation.`),!1;f={...f,props:{...f.props,toolName:e}}}if(typeof t==`string`){if(f.widget!==void 0&&f.widget!==t)return m(`The widget changed. Refresh the MCP connection.`),!1;f={...f,widget:t}}return!0},g=()=>{let e=f.props.toolName,t=u&&d&&!!s.getHostCapabilities()?.serverTools&&e.length>0;f={...f,props:{...f.props,refresh:t?async()=>{if(c||e!==f.props.toolName||!d)throw Error(`This widget is no longer active.`);return s.callServerTool({name:e,arguments:{...f.props.args}})}:void 0}}},_=e=>{if(c||e===void 0)return;e.theme&&((0,r.applyDocumentTheme)(e.theme),document.documentElement.classList.toggle(`dark`,e.theme===`dark`),document.documentElement.dataset.theme=e.theme),e.styles?.variables&&(0,r.applyHostStyleVariables)(e.styles.variables);let t=e.toolInfo?.tool;if(t){if(!h(t.name,t._meta?.[`po/widget`]))return;let e=t._meta?.ui;d=Array.isArray(e?.visibility)&&e.visibility.includes(`app`)}g(),p()};s.ontoolinputpartial=({arguments:e})=>{c||l||(f={...f,props:{...f.props,args:e??{},phase:`preparing`}},p())},s.ontoolinput=({arguments:e})=>{c||l||(f={...f,props:{...f.props,args:e??{},phase:`running`}},p())},s.ontoolresult=e=>{c||l||h(e._meta?.[`po/toolName`],e._meta?.[`po/widget`])&&(l=!0,f={...f,props:{...f.props,result:e,phase:`result`}},g(),p())},s.ontoolcancelled=()=>{c||l||(l=!0,f={...f,props:{...f.props,phase:`cancelled`,result:null}},p())},s.onhostcontextchanged=_;let v=()=>{c||(f={...f,failure:`Tool view closed.`},p(),c=!0,window.removeEventListener(`pagehide`,v),setTimeout(()=>{s.close().catch(()=>{})},0))};s.onteardown=()=>(v(),{}),window.addEventListener(`pagehide`,v,{once:!0}),p();try{if(await s.connect(),c)return;u=!0,_(s.getHostContext())}catch{c||m(`Could not connect to the app host. Reopen this widget in an MCP Apps-compatible client.`)}}exports.McpApp=o,exports.mountMcpApp=s;
|
|
2
2
|
//# sourceMappingURL=McpApp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpApp.cjs","names":["Component","createRoot","App","react_jsx_runtime","react","_modelcontextprotocol_ext_apps","react_dom_client","WidgetBoundary","McpApp","Widget","view","widgets","mountMcpApp","element","root","app","disposed","terminal","connected","appVisible","render","fail","message","identify","name","widget","updateRefresh","enabled","applyContext","context","tool","ui","args","result","dispose"],"sources":["../../../src/components/McpApp.tsx"],"sourcesContent":["import type { PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport {\n App,\n applyDocumentTheme,\n applyHostStyleVariables,\n type McpUiHostContext,\n} from '@modelcontextprotocol/ext-apps';\nimport { Component, type ComponentType, type ReactNode } from 'react';\nimport { createRoot } from 'react-dom/client';\n\ninterface View {\n readonly widget?: string;\n readonly props: PoMcpWidgetProps;\n readonly failure?: string;\n}\n\nclass WidgetBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError() {\n return { failed: true };\n }\n\n render() {\n return this.state.failed ? <p role=\"status\">The tool widget could not be rendered.</p> : this.props.children;\n }\n}\n\n/** The root only dispatches. Tool-specific presentation belongs to the contributing package. */\nexport function McpApp({\n widgets,\n view,\n}: {\n widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>;\n view: View;\n}) {\n const Widget = view.widget !== undefined && Object.hasOwn(widgets, view.widget) ? widgets[view.widget] : undefined;\n if (view.failure) return <p role=\"status\">{view.failure}</p>;\n if (Widget === undefined)\n return (\n <p role=\"status\">\n {view.widget === undefined ? 'Waiting for tool information...' : 'No widget is available for this tool.'}\n </p>\n );\n return (\n <WidgetBoundary key={view.widget}>\n <Widget {...view.props} />\n </WidgetBoundary>\n );\n}\n\n/** Mounts one independently sandboxed invocation of the sync-generated widget registry. */\nexport async function mountMcpApp(widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>): Promise<void> {\n const element = document.getElementById('root');\n if (element === null) throw new Error('Missing MCP app root');\n const root = createRoot(element);\n const app = new App({ name: 'po-tools', version: '1.0.0' }, {}, { autoResize: true });\n let disposed = false;\n let terminal = false;\n let connected = false;\n let appVisible = false;\n let view: View = { props: { toolName: '', args: {}, result: null, phase: 'connecting' } };\n\n const render = (): void => {\n if (!disposed) root.render(<McpApp widgets={widgets} view={view} />);\n };\n const fail = (message: string): void => {\n terminal = true;\n view = { ...view, failure: message };\n render();\n };\n const identify = (name: unknown, widget: unknown): boolean => {\n if (typeof name === 'string' && name.length > 0) {\n if (view.props.toolName && view.props.toolName !== name) {\n fail('The tool changed. Reopen this widget from the conversation.');\n return false;\n }\n view = { ...view, props: { ...view.props, toolName: name } };\n }\n if (typeof widget === 'string') {\n if (view.widget !== undefined && view.widget !== widget) {\n fail('The widget changed. Refresh the MCP connection.');\n return false;\n }\n view = { ...view, widget };\n }\n return true;\n };\n const updateRefresh = (): void => {\n const name = view.props.toolName;\n const enabled = connected && appVisible && !!app.getHostCapabilities()?.serverTools && name.length > 0;\n view = {\n ...view,\n props: {\n ...view.props,\n refresh: enabled\n ? async () => {\n if (disposed || name !== view.props.toolName || !appVisible)\n throw new Error('This widget is no longer active.');\n return app.callServerTool({ name, arguments: { ...view.props.args } });\n }\n : undefined,\n },\n };\n };\n const applyContext = (context: McpUiHostContext | undefined): void => {\n if (disposed || context === undefined) return;\n if (context.theme) {\n applyDocumentTheme(context.theme);\n document.documentElement.classList.toggle('dark', context.theme === 'dark');\n document.documentElement.dataset.theme = context.theme;\n }\n if (context.styles?.variables) applyHostStyleVariables(context.styles.variables);\n const tool = context.toolInfo?.tool;\n if (tool) {\n if (!identify(tool.name, tool._meta?.['po/widget'])) return;\n const ui = tool._meta?.ui as { visibility?: unknown } | undefined;\n appVisible = Array.isArray(ui?.visibility) && ui.visibility.includes('app');\n }\n updateRefresh();\n render();\n };\n\n app.ontoolinputpartial = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'preparing' } };\n render();\n };\n app.ontoolinput = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'running' } };\n render();\n };\n app.ontoolresult = (result) => {\n if (disposed || terminal) return;\n if (!identify(result._meta?.['po/toolName'], result._meta?.['po/widget'])) return;\n terminal = true;\n view = { ...view, props: { ...view.props, result, phase: 'result' } };\n updateRefresh();\n render();\n };\n app.ontoolcancelled = () => {\n if (disposed || terminal) return;\n terminal = true;\n view = { ...view, props: { ...view.props, phase: 'cancelled', result: null } };\n render();\n };\n app.onhostcontextchanged = applyContext;\n\n const dispose = (): void => {\n if (disposed) return;\n view = { ...view, failure: 'Tool view closed.' };\n render();\n disposed = true;\n window.removeEventListener('pagehide', dispose);\n setTimeout(() => {\n void app.close().catch(() => {});\n }, 0);\n };\n\n app.onteardown = () => {\n dispose();\n return {};\n };\n window.addEventListener('pagehide', dispose, { once: true });\n render();\n\n try {\n await app.connect();\n if (disposed) return;\n connected = true;\n applyContext(app.getHostContext());\n } catch {\n if (!disposed) fail('Could not connect to the app host. Reopen this widget in an MCP Apps-compatible client.');\n }\n}\n"],"mappings":"A,gIAgBA,IAAMO,EAAN,cAA6BP,EAAAA,SAAwD,CACnF,MAAQ,CAAE,OAAQ,EAAM,EAExB,OAAO,0BAA2B,CAChC,MAAO,CAAE,OAAQ,EAAK,CACxB,CAEA,QAAS,CACP,OAAO,KAAK,MAAM,OAAS,iBAAA,EAAAG,EAAA,IAAA,CAAC,IAAD,CAAG,KAAK,SAA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AK,CAAC,EAC3Dd,EAAO,EAEP,GAAI,CAEF,GADA,MAAML,EAAI,QAAQ,EACdC,EAAU,OACd,EAAY,GACZY,EAAab,EAAI,eAAe,CAAC,CACnC,MAAQ,CACDC,GAAUK,EAAK,yFAAyF,CAC/G,CACF,C"}
|
|
1
|
+
{"version":3,"file":"McpApp.cjs","names":["Component","useT","createRoot","App","react_jsx_runtime","react","_agimon_ai_po_core_web","_modelcontextprotocol_ext_apps","react_dom_client","WidgetBoundary","McpApp","t","Widget","view","widgets","mountMcpApp","element","root","app","disposed","terminal","connected","appVisible","render","fail","message","identify","name","widget","updateRefresh","enabled","applyContext","context","tool","ui","args","result","dispose"],"sources":["../../../src/components/McpApp.tsx"],"sourcesContent":["import { useT, type PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport {\n App,\n applyDocumentTheme,\n applyHostStyleVariables,\n type McpUiHostContext,\n} from '@modelcontextprotocol/ext-apps';\nimport { Component, type ComponentType, type ReactNode } from 'react';\nimport { createRoot } from 'react-dom/client';\n\ninterface View {\n readonly widget?: string;\n readonly props: PoMcpWidgetProps;\n readonly failure?: string;\n}\n\nclass WidgetBoundary extends Component<{ children: ReactNode; failure: string }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError() {\n return { failed: true };\n }\n\n render() {\n return this.state.failed ? <p role=\"status\">{this.props.failure}</p> : this.props.children;\n }\n}\n\n/** The root only dispatches. Tool-specific presentation belongs to the contributing package. */\nexport function McpApp({\n widgets,\n view,\n}: {\n widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>;\n view: View;\n}) {\n const t = useT();\n const Widget = view.widget !== undefined && Object.hasOwn(widgets, view.widget) ? widgets[view.widget] : undefined;\n if (view.failure) return <p role=\"status\">{view.failure}</p>;\n if (Widget === undefined)\n return (\n <p role=\"status\">\n {view.widget === undefined\n ? t('webComponents.mcpApp.waiting', 'Waiting for tool information...')\n : t('webComponents.mcpApp.unavailable', 'No widget is available for this tool.')}\n </p>\n );\n return (\n <WidgetBoundary\n key={view.widget}\n failure={t('webComponents.mcpApp.renderFailed', 'The tool widget could not be rendered.')}\n >\n <Widget {...view.props} />\n </WidgetBoundary>\n );\n}\n\n/** Mounts one independently sandboxed invocation of the sync-generated widget registry. */\nexport async function mountMcpApp(widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>): Promise<void> {\n const element = document.getElementById('root');\n if (element === null) throw new Error('Missing MCP app root');\n const root = createRoot(element);\n const app = new App({ name: 'po-tools', version: '1.0.0' }, {}, { autoResize: true });\n let disposed = false;\n let terminal = false;\n let connected = false;\n let appVisible = false;\n let view: View = { props: { toolName: '', args: {}, result: null, phase: 'connecting' } };\n\n const render = (): void => {\n if (!disposed) root.render(<McpApp widgets={widgets} view={view} />);\n };\n const fail = (message: string): void => {\n terminal = true;\n view = { ...view, failure: message };\n render();\n };\n const identify = (name: unknown, widget: unknown): boolean => {\n if (typeof name === 'string' && name.length > 0) {\n if (view.props.toolName && view.props.toolName !== name) {\n fail('The tool changed. Reopen this widget from the conversation.');\n return false;\n }\n view = { ...view, props: { ...view.props, toolName: name } };\n }\n if (typeof widget === 'string') {\n if (view.widget !== undefined && view.widget !== widget) {\n fail('The widget changed. Refresh the MCP connection.');\n return false;\n }\n view = { ...view, widget };\n }\n return true;\n };\n const updateRefresh = (): void => {\n const name = view.props.toolName;\n const enabled = connected && appVisible && !!app.getHostCapabilities()?.serverTools && name.length > 0;\n view = {\n ...view,\n props: {\n ...view.props,\n refresh: enabled\n ? async () => {\n if (disposed || name !== view.props.toolName || !appVisible)\n throw new Error('This widget is no longer active.');\n return app.callServerTool({ name, arguments: { ...view.props.args } });\n }\n : undefined,\n },\n };\n };\n const applyContext = (context: McpUiHostContext | undefined): void => {\n if (disposed || context === undefined) return;\n if (context.theme) {\n applyDocumentTheme(context.theme);\n document.documentElement.classList.toggle('dark', context.theme === 'dark');\n document.documentElement.dataset.theme = context.theme;\n }\n if (context.styles?.variables) applyHostStyleVariables(context.styles.variables);\n const tool = context.toolInfo?.tool;\n if (tool) {\n if (!identify(tool.name, tool._meta?.['po/widget'])) return;\n const ui = tool._meta?.ui as { visibility?: unknown } | undefined;\n appVisible = Array.isArray(ui?.visibility) && ui.visibility.includes('app');\n }\n updateRefresh();\n render();\n };\n\n app.ontoolinputpartial = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'preparing' } };\n render();\n };\n app.ontoolinput = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'running' } };\n render();\n };\n app.ontoolresult = (result) => {\n if (disposed || terminal) return;\n if (!identify(result._meta?.['po/toolName'], result._meta?.['po/widget'])) return;\n terminal = true;\n view = { ...view, props: { ...view.props, result, phase: 'result' } };\n updateRefresh();\n render();\n };\n app.ontoolcancelled = () => {\n if (disposed || terminal) return;\n terminal = true;\n view = { ...view, props: { ...view.props, phase: 'cancelled', result: null } };\n render();\n };\n app.onhostcontextchanged = applyContext;\n\n const dispose = (): void => {\n if (disposed) return;\n view = { ...view, failure: 'Tool view closed.' };\n render();\n disposed = true;\n window.removeEventListener('pagehide', dispose);\n setTimeout(() => {\n void app.close().catch(() => {});\n }, 0);\n };\n\n app.onteardown = () => {\n dispose();\n return {};\n };\n window.addEventListener('pagehide', dispose, { once: true });\n render();\n\n try {\n await app.connect();\n if (disposed) return;\n connected = true;\n applyContext(app.getHostContext());\n } catch {\n if (!disposed) fail('Could not connect to the app host. Reopen this widget in an MCP Apps-compatible client.');\n }\n}\n"],"mappings":"A,oKAgBA,IAAMS,EAAN,cAA6BT,EAAAA,SAAyE,CACpG,MAAQ,CAAE,OAAQ,EAAM,EAExB,OAAO,0BAA2B,CAChC,MAAO,CAAE,OAAQ,EAAK,CACxB,CAEA,QAAS,CACP,OAAO,KAAK,MAAM,OAAS,iBAAA,EAAAI,EAAA,IAAA,CAAC,IAAD,CAAG,KAAK,SAAU,SAAA,KAAK,MAAM,OAAW,CAAA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C,EACN,EAEA,EAAI,gBACFmB,EAAQ,EACD,CAAC,GAEV,OAAO,iBAAiB,WAAYA,EAAS,CAAE,KAAM,EAAK,CAAC,EAC3Dd,EAAO,EAEP,GAAI,CAEF,GADA,MAAML,EAAI,QAAQ,EACdC,EAAU,OACd,EAAY,GACZY,EAAab,EAAI,eAAe,CAAC,CACnC,MAAQ,CACDC,GAAUK,EAAK,yFAAyF,CAC/G,CACF,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpApp.d.mts","names":[],"sources":["../../../src/components/McpApp.tsx"],"mappings":";;;UAUU;WACC;WACA,OAAO;WACP;;;wBAgBK,SACd,SACA;EAEA,SAAS,SAAS,eAAe,cAAc;EAC/C,MAAM;oBACP,IAAA;;
|
|
1
|
+
{"version":3,"file":"McpApp.d.mts","names":[],"sources":["../../../src/components/McpApp.tsx"],"mappings":";;;UAUU;WACC;WACA,OAAO;WACP;;;wBAgBK,SACd,SACA;EAEA,SAAS,SAAS,eAAe,cAAc;EAC/C,MAAM;oBACP,IAAA;;wBAuBqB,YAAY,SAAS,SAAS,eAAe,cAAc,sBAAsB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{Component as t}from"react";import{App as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Component as t}from"react";import{useT as n}from"@agimon-ai/po-core/web";import{App as r,applyDocumentTheme as i,applyHostStyleVariables as a}from"@modelcontextprotocol/ext-apps";import{createRoot as o}from"react-dom/client";var s=class extends t{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?/* @__PURE__ */ e(`p`,{role:`status`,children:this.props.failure}):this.props.children}};function c({widgets:t,view:r}){let i=n(),a=r.widget!==void 0&&Object.hasOwn(t,r.widget)?t[r.widget]:void 0;return r.failure?/* @__PURE__ */ e(`p`,{role:`status`,children:r.failure}):a===void 0?/* @__PURE__ */ e(`p`,{role:`status`,children:r.widget===void 0?i(`webComponents.mcpApp.waiting`,`Waiting for tool information...`):i(`webComponents.mcpApp.unavailable`,`No widget is available for this tool.`)}):/* @__PURE__ */ e(s,{failure:i(`webComponents.mcpApp.renderFailed`,`The tool widget could not be rendered.`),children:/* @__PURE__ */ e(a,{...r.props})},r.widget)}async function l(t){let n=document.getElementById(`root`);if(n===null)throw Error(`Missing MCP app root`);let s=o(n),l=new r({name:`po-tools`,version:`1.0.0`},{},{autoResize:!0}),u=!1,d=!1,f=!1,p=!1,m={props:{toolName:``,args:{},result:null,phase:`connecting`}},h=()=>{u||s.render(/* @__PURE__ */ e(c,{widgets:t,view:m}))},g=e=>{d=!0,m={...m,failure:e},h()},_=(e,t)=>{if(typeof e==`string`&&e.length>0){if(m.props.toolName&&m.props.toolName!==e)return g(`The tool changed. Reopen this widget from the conversation.`),!1;m={...m,props:{...m.props,toolName:e}}}if(typeof t==`string`){if(m.widget!==void 0&&m.widget!==t)return g(`The widget changed. Refresh the MCP connection.`),!1;m={...m,widget:t}}return!0},v=()=>{let e=m.props.toolName,t=f&&p&&!!l.getHostCapabilities()?.serverTools&&e.length>0;m={...m,props:{...m.props,refresh:t?async()=>{if(u||e!==m.props.toolName||!p)throw Error(`This widget is no longer active.`);return l.callServerTool({name:e,arguments:{...m.props.args}})}:void 0}}},y=e=>{if(u||e===void 0)return;e.theme&&(i(e.theme),document.documentElement.classList.toggle(`dark`,e.theme===`dark`),document.documentElement.dataset.theme=e.theme),e.styles?.variables&&a(e.styles.variables);let t=e.toolInfo?.tool;if(t){if(!_(t.name,t._meta?.[`po/widget`]))return;let e=t._meta?.ui;p=Array.isArray(e?.visibility)&&e.visibility.includes(`app`)}v(),h()};l.ontoolinputpartial=({arguments:e})=>{u||d||(m={...m,props:{...m.props,args:e??{},phase:`preparing`}},h())},l.ontoolinput=({arguments:e})=>{u||d||(m={...m,props:{...m.props,args:e??{},phase:`running`}},h())},l.ontoolresult=e=>{u||d||_(e._meta?.[`po/toolName`],e._meta?.[`po/widget`])&&(d=!0,m={...m,props:{...m.props,result:e,phase:`result`}},v(),h())},l.ontoolcancelled=()=>{u||d||(d=!0,m={...m,props:{...m.props,phase:`cancelled`,result:null}},h())},l.onhostcontextchanged=y;let b=()=>{u||(m={...m,failure:`Tool view closed.`},h(),u=!0,window.removeEventListener(`pagehide`,b),setTimeout(()=>{l.close().catch(()=>{})},0))};l.onteardown=()=>(b(),{}),window.addEventListener(`pagehide`,b,{once:!0}),h();try{if(await l.connect(),u)return;f=!0,y(l.getHostContext())}catch{u||g(`Could not connect to the app host. Reopen this widget in an MCP Apps-compatible client.`)}}export{c as McpApp,l as mountMcpApp};
|
|
2
2
|
//# sourceMappingURL=McpApp.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpApp.mjs","names":["WidgetBoundary","Component","McpApp","Widget","view","widgets","mountMcpApp","element","root","createRoot","app","App","disposed","terminal","connected","appVisible","render","fail","message","identify","name","widget","updateRefresh","enabled","applyContext","context","applyDocumentTheme","applyHostStyleVariables","tool","ui","args","result","dispose"],"sources":["../../../src/components/McpApp.tsx"],"sourcesContent":["import type { PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport {\n App,\n applyDocumentTheme,\n applyHostStyleVariables,\n type McpUiHostContext,\n} from '@modelcontextprotocol/ext-apps';\nimport { Component, type ComponentType, type ReactNode } from 'react';\nimport { createRoot } from 'react-dom/client';\n\ninterface View {\n readonly widget?: string;\n readonly props: PoMcpWidgetProps;\n readonly failure?: string;\n}\n\nclass WidgetBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError() {\n return { failed: true };\n }\n\n render() {\n return this.state.failed ? <p role=\"status\">The tool widget could not be rendered.</p> : this.props.children;\n }\n}\n\n/** The root only dispatches. Tool-specific presentation belongs to the contributing package. */\nexport function McpApp({\n widgets,\n view,\n}: {\n widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>;\n view: View;\n}) {\n const Widget = view.widget !== undefined && Object.hasOwn(widgets, view.widget) ? widgets[view.widget] : undefined;\n if (view.failure) return <p role=\"status\">{view.failure}</p>;\n if (Widget === undefined)\n return (\n <p role=\"status\">\n {view.widget === undefined ? 'Waiting for tool information...' : 'No widget is available for this tool.'}\n </p>\n );\n return (\n <WidgetBoundary key={view.widget}>\n <Widget {...view.props} />\n </WidgetBoundary>\n );\n}\n\n/** Mounts one independently sandboxed invocation of the sync-generated widget registry. */\nexport async function mountMcpApp(widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>): Promise<void> {\n const element = document.getElementById('root');\n if (element === null) throw new Error('Missing MCP app root');\n const root = createRoot(element);\n const app = new App({ name: 'po-tools', version: '1.0.0' }, {}, { autoResize: true });\n let disposed = false;\n let terminal = false;\n let connected = false;\n let appVisible = false;\n let view: View = { props: { toolName: '', args: {}, result: null, phase: 'connecting' } };\n\n const render = (): void => {\n if (!disposed) root.render(<McpApp widgets={widgets} view={view} />);\n };\n const fail = (message: string): void => {\n terminal = true;\n view = { ...view, failure: message };\n render();\n };\n const identify = (name: unknown, widget: unknown): boolean => {\n if (typeof name === 'string' && name.length > 0) {\n if (view.props.toolName && view.props.toolName !== name) {\n fail('The tool changed. Reopen this widget from the conversation.');\n return false;\n }\n view = { ...view, props: { ...view.props, toolName: name } };\n }\n if (typeof widget === 'string') {\n if (view.widget !== undefined && view.widget !== widget) {\n fail('The widget changed. Refresh the MCP connection.');\n return false;\n }\n view = { ...view, widget };\n }\n return true;\n };\n const updateRefresh = (): void => {\n const name = view.props.toolName;\n const enabled = connected && appVisible && !!app.getHostCapabilities()?.serverTools && name.length > 0;\n view = {\n ...view,\n props: {\n ...view.props,\n refresh: enabled\n ? async () => {\n if (disposed || name !== view.props.toolName || !appVisible)\n throw new Error('This widget is no longer active.');\n return app.callServerTool({ name, arguments: { ...view.props.args } });\n }\n : undefined,\n },\n };\n };\n const applyContext = (context: McpUiHostContext | undefined): void => {\n if (disposed || context === undefined) return;\n if (context.theme) {\n applyDocumentTheme(context.theme);\n document.documentElement.classList.toggle('dark', context.theme === 'dark');\n document.documentElement.dataset.theme = context.theme;\n }\n if (context.styles?.variables) applyHostStyleVariables(context.styles.variables);\n const tool = context.toolInfo?.tool;\n if (tool) {\n if (!identify(tool.name, tool._meta?.['po/widget'])) return;\n const ui = tool._meta?.ui as { visibility?: unknown } | undefined;\n appVisible = Array.isArray(ui?.visibility) && ui.visibility.includes('app');\n }\n updateRefresh();\n render();\n };\n\n app.ontoolinputpartial = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'preparing' } };\n render();\n };\n app.ontoolinput = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'running' } };\n render();\n };\n app.ontoolresult = (result) => {\n if (disposed || terminal) return;\n if (!identify(result._meta?.['po/toolName'], result._meta?.['po/widget'])) return;\n terminal = true;\n view = { ...view, props: { ...view.props, result, phase: 'result' } };\n updateRefresh();\n render();\n };\n app.ontoolcancelled = () => {\n if (disposed || terminal) return;\n terminal = true;\n view = { ...view, props: { ...view.props, phase: 'cancelled', result: null } };\n render();\n };\n app.onhostcontextchanged = applyContext;\n\n const dispose = (): void => {\n if (disposed) return;\n view = { ...view, failure: 'Tool view closed.' };\n render();\n disposed = true;\n window.removeEventListener('pagehide', dispose);\n setTimeout(() => {\n void app.close().catch(() => {});\n }, 0);\n };\n\n app.onteardown = () => {\n dispose();\n return {};\n };\n window.addEventListener('pagehide', dispose, { once: true });\n render();\n\n try {\n await app.connect();\n if (disposed) return;\n connected = true;\n applyContext(app.getHostContext());\n } catch {\n if (!disposed) fail('Could not connect to the app host. Reopen this widget in an MCP Apps-compatible client.');\n }\n}\n"],"mappings":"A,kOAgBA,IAAMA,EAAN,cAA6BC,CAAwD,CACnF,MAAQ,CAAE,OAAQ,EAAM,EAExB,OAAO,0BAA2B,CAChC,MAAO,CAAE,OAAQ,EAAK,CACxB,CAEA,QAAS,CACP,OAAO,K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AAUK,EAAK,yFAAyF,CAC/G,CACF,C"}
|
|
1
|
+
{"version":3,"file":"McpApp.mjs","names":["WidgetBoundary","Component","McpApp","t","useT","Widget","view","widgets","mountMcpApp","element","root","createRoot","app","App","disposed","terminal","connected","appVisible","render","fail","message","identify","name","widget","updateRefresh","enabled","applyContext","context","applyDocumentTheme","applyHostStyleVariables","tool","ui","args","result","dispose"],"sources":["../../../src/components/McpApp.tsx"],"sourcesContent":["import { useT, type PoMcpWidgetProps } from '@agimon-ai/po-core/web';\nimport {\n App,\n applyDocumentTheme,\n applyHostStyleVariables,\n type McpUiHostContext,\n} from '@modelcontextprotocol/ext-apps';\nimport { Component, type ComponentType, type ReactNode } from 'react';\nimport { createRoot } from 'react-dom/client';\n\ninterface View {\n readonly widget?: string;\n readonly props: PoMcpWidgetProps;\n readonly failure?: string;\n}\n\nclass WidgetBoundary extends Component<{ children: ReactNode; failure: string }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError() {\n return { failed: true };\n }\n\n render() {\n return this.state.failed ? <p role=\"status\">{this.props.failure}</p> : this.props.children;\n }\n}\n\n/** The root only dispatches. Tool-specific presentation belongs to the contributing package. */\nexport function McpApp({\n widgets,\n view,\n}: {\n widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>;\n view: View;\n}) {\n const t = useT();\n const Widget = view.widget !== undefined && Object.hasOwn(widgets, view.widget) ? widgets[view.widget] : undefined;\n if (view.failure) return <p role=\"status\">{view.failure}</p>;\n if (Widget === undefined)\n return (\n <p role=\"status\">\n {view.widget === undefined\n ? t('webComponents.mcpApp.waiting', 'Waiting for tool information...')\n : t('webComponents.mcpApp.unavailable', 'No widget is available for this tool.')}\n </p>\n );\n return (\n <WidgetBoundary\n key={view.widget}\n failure={t('webComponents.mcpApp.renderFailed', 'The tool widget could not be rendered.')}\n >\n <Widget {...view.props} />\n </WidgetBoundary>\n );\n}\n\n/** Mounts one independently sandboxed invocation of the sync-generated widget registry. */\nexport async function mountMcpApp(widgets: Readonly<Record<string, ComponentType<PoMcpWidgetProps>>>): Promise<void> {\n const element = document.getElementById('root');\n if (element === null) throw new Error('Missing MCP app root');\n const root = createRoot(element);\n const app = new App({ name: 'po-tools', version: '1.0.0' }, {}, { autoResize: true });\n let disposed = false;\n let terminal = false;\n let connected = false;\n let appVisible = false;\n let view: View = { props: { toolName: '', args: {}, result: null, phase: 'connecting' } };\n\n const render = (): void => {\n if (!disposed) root.render(<McpApp widgets={widgets} view={view} />);\n };\n const fail = (message: string): void => {\n terminal = true;\n view = { ...view, failure: message };\n render();\n };\n const identify = (name: unknown, widget: unknown): boolean => {\n if (typeof name === 'string' && name.length > 0) {\n if (view.props.toolName && view.props.toolName !== name) {\n fail('The tool changed. Reopen this widget from the conversation.');\n return false;\n }\n view = { ...view, props: { ...view.props, toolName: name } };\n }\n if (typeof widget === 'string') {\n if (view.widget !== undefined && view.widget !== widget) {\n fail('The widget changed. Refresh the MCP connection.');\n return false;\n }\n view = { ...view, widget };\n }\n return true;\n };\n const updateRefresh = (): void => {\n const name = view.props.toolName;\n const enabled = connected && appVisible && !!app.getHostCapabilities()?.serverTools && name.length > 0;\n view = {\n ...view,\n props: {\n ...view.props,\n refresh: enabled\n ? async () => {\n if (disposed || name !== view.props.toolName || !appVisible)\n throw new Error('This widget is no longer active.');\n return app.callServerTool({ name, arguments: { ...view.props.args } });\n }\n : undefined,\n },\n };\n };\n const applyContext = (context: McpUiHostContext | undefined): void => {\n if (disposed || context === undefined) return;\n if (context.theme) {\n applyDocumentTheme(context.theme);\n document.documentElement.classList.toggle('dark', context.theme === 'dark');\n document.documentElement.dataset.theme = context.theme;\n }\n if (context.styles?.variables) applyHostStyleVariables(context.styles.variables);\n const tool = context.toolInfo?.tool;\n if (tool) {\n if (!identify(tool.name, tool._meta?.['po/widget'])) return;\n const ui = tool._meta?.ui as { visibility?: unknown } | undefined;\n appVisible = Array.isArray(ui?.visibility) && ui.visibility.includes('app');\n }\n updateRefresh();\n render();\n };\n\n app.ontoolinputpartial = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'preparing' } };\n render();\n };\n app.ontoolinput = ({ arguments: args }) => {\n if (disposed || terminal) return;\n view = { ...view, props: { ...view.props, args: args ?? {}, phase: 'running' } };\n render();\n };\n app.ontoolresult = (result) => {\n if (disposed || terminal) return;\n if (!identify(result._meta?.['po/toolName'], result._meta?.['po/widget'])) return;\n terminal = true;\n view = { ...view, props: { ...view.props, result, phase: 'result' } };\n updateRefresh();\n render();\n };\n app.ontoolcancelled = () => {\n if (disposed || terminal) return;\n terminal = true;\n view = { ...view, props: { ...view.props, phase: 'cancelled', result: null } };\n render();\n };\n app.onhostcontextchanged = applyContext;\n\n const dispose = (): void => {\n if (disposed) return;\n view = { ...view, failure: 'Tool view closed.' };\n render();\n disposed = true;\n window.removeEventListener('pagehide', dispose);\n setTimeout(() => {\n void app.close().catch(() => {});\n }, 0);\n };\n\n app.onteardown = () => {\n dispose();\n return {};\n };\n window.addEventListener('pagehide', dispose, { once: true });\n render();\n\n try {\n await app.connect();\n if (disposed) return;\n connected = true;\n applyContext(app.getHostContext());\n } catch {\n if (!disposed) fail('Could not connect to the app host. Reopen this widget in an MCP Apps-compatible client.');\n }\n}\n"],"mappings":"A,gRAgBA,IAAMA,EAAN,cAA6BC,CAAyE,CACpG,MAAQ,CAAE,OAAQ,EAAM,EAExB,OAAO,0BAA2B,CAChC,MAAO,CAAE,OAAQ,EAAK,CACxB,CAEA,QAAS,CACP,OAAO,KAAK,MAAM,OAAS,kBAAC,IAAD,CAAG,KAAK,SAAU,SAAA,KAAK,MAAM,OAAW,CAAA,EAAI,KAAK,MAAM,QACpF,CACF,EAGA,SAAgBC,EAAO,CACrB,UACA,QAIC,CACD,IAAMC,EAAIC,EAAK,EACTC,EAASC,EAAK,SAAW,IAAA,IAAa,OAAO,OAAOC,EAASD,EAAK,MAAM,EAAIC,EAAQD,EAAK,QAAU,IAAA,GAUzG,OATIA,EA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,EACjFd,EAAO,EACT,EACA,EAAI,aAAe,CAAE,UAAWc,KAAW,CACrClB,GAAYC,IAChB,EAAO,CAAE,GAAGT,EAAM,MAAO,CAAE,GAAGA,EAAK,MAAO,KAAM0B,GAAQ,CAAC,EAAG,MAAO,SAAU,CAAE,EAC/Ed,EAAO,EACT,EACA,EAAI,aAAgB,GAAW,CACzBJ,GAAYC,GACXM,EAASY,EAAO,QAAQ,eAAgBA,EAAO,QAAQ,YAAY,IACxE,EAAW,GACX,EAAO,CAAE,GAAG3B,EAAM,MAAO,CAAE,GAAGA,EAAK,MAAO,SAAQ,MAAO,QAAS,CAAE,EACpEkB,EAAc,EACdN,EAAO,EACT,EACA,EAAI,oBAAwB,CACtBJ,GAAYC,IAChB,EAAW,GACX,EAAO,CAAE,GAAGT,EAAM,MAAO,CAAE,GAAGA,EAAK,MAAO,MAAO,YAAa,OAAQ,IAAK,CAAE,EAC7EY,EAAO,EACT,EACA,EAAI,qBAAuBQ,EAE3B,IAAMQ,MAAsB,CACtBpB,IACJ,EAAO,CAAE,GAAGR,EAAM,QAAS,mBAAoB,EAC/CY,EAAO,EACP,EAAW,GACX,OAAO,oBAAoB,WAAYgB,CAAO,EAC9C,eAAiB,CACftB,EAAS,MAAM,CAAC,CAAC,UAAY,CAAC,CAAC,CACjC,EAAG,CAAC,EACN,EAEA,EAAI,gBACFsB,EAAQ,EACD,CAAC,GAEV,OAAO,iBAAiB,WAAYA,EAAS,CAAE,KAAM,EAAK,CAAC,EAC3DhB,EAAO,EAEP,GAAI,CAEF,GADA,MAAMN,EAAI,QAAQ,EACdE,EAAU,OACd,EAAY,GACZY,EAAad,EAAI,eAAe,CAAC,CACnC,MAAQ,CACDE,GAAUK,EAAK,yFAAyF,CAC/G,CACF,C"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
let e=require("react/jsx-runtime");function
|
|
2
|
-
`:``}${e.text}`,
|
|
1
|
+
let e=require("react/jsx-runtime"),t=require("@agimon-ai/po-core/web");function n({title:n,phase:r,result:i,error:a,children:o}){let s=(0,t.useT)(),c=r===`error`||i?.isError===!0,l=c?s(`webComponents.mcpWidget.failed`,`Tool failed`):r===`result`?s(`webComponents.mcpWidget.received`,`Result received`):r===`cancelled`?s(`webComponents.mcpWidget.cancelled`,`Tool cancelled`):r===`running`?s(`webComponents.mcpWidget.running`,`Running tool...`):r===`preparing`?s(`webComponents.mcpWidget.preparing`,`Preparing tool...`):s(`webComponents.mcpWidget.connecting`,`Connecting to host...`);return/* @__PURE__ */ (0,e.jsxs)(`section`,{className:`min-w-0 rounded-md border border-po-border bg-po-bg p-4 text-base text-po-text`,children:[/* @__PURE__ */ (0,e.jsx)(`h1`,{className:`m-0 break-words text-lg font-semibold`,children:n}),/* @__PURE__ */ (0,e.jsx)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:c?`my-2 text-po-red`:`my-2 text-po-dim`,children:a??l}),o]})}function r(e){if(typeof e==`string`)return e.length>500?`${e.slice(0,500)}...`:e;if(typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`)return String(e);if(Array.isArray(e)&&e.every(e=>typeof e==`string`))return r(e.join(`, `))}function i({fields:n}){let i=(0,t.useT)(),a=n.flatMap(([e,t])=>{let n=r(t);return n===void 0||n===``?[]:[{label:e,text:n}]});return a.length===0?null:/* @__PURE__ */ (0,e.jsx)(`dl`,{"aria-label":i(`webComponents.mcpWidget.details`,`Tool details`),className:`my-3 flex min-w-0 flex-col gap-2`,children:a.map(({label:t,text:n})=>/* @__PURE__ */ (0,e.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-x-3 gap-y-1`,children:[/* @__PURE__ */ (0,e.jsx)(`dt`,{className:`text-sm text-po-dim`,children:t}),/* @__PURE__ */ (0,e.jsx)(`dd`,{className:`m-0 min-w-0 whitespace-pre-wrap break-all text-sm`,children:n})]},t))})}function a({result:n}){let r=(0,t.useT)();if(n===null)return null;let i=8e3,a=``,o=!1,s=0;for(let e of n.content??[]){if(e.type!==`text`){s+=1;continue}let t=`${a?`
|
|
2
|
+
`:``}${e.text}`,n=Math.max(0,i-a.length);o||=t.length>n,a+=t.slice(0,n)}if(!a&&n.structuredContent){let e=JSON.stringify(n.structuredContent,null,2);a=e.slice(0,i),o=e.length>i}return/* @__PURE__ */ (0,e.jsxs)(`details`,{open:!0,className:`min-w-0 rounded-md border border-po-border-soft`,children:[/* @__PURE__ */ (0,e.jsx)(`summary`,{className:`cursor-pointer bg-po-panel p-3 text-sm focus-visible:outline`,children:r(`webComponents.mcpWidget.output`,`Tool output`)}),/* @__PURE__ */ (0,e.jsx)(`pre`,{tabIndex:0,"aria-label":r(`webComponents.mcpWidget.outputPreview`,`Tool output preview`),className:`m-0 max-h-72 overflow-auto whitespace-pre-wrap break-all p-3 font-mono text-sm`,children:a||(s?r(`webComponents.mcpWidget.nonText`,`Non-text result returned to the agent.`):r(`webComponents.mcpWidget.empty`,`No text output.`))}),o||s?/* @__PURE__ */ (0,e.jsxs)(`p`,{className:`m-0 border-t border-po-border-soft p-3 text-sm text-po-dim`,children:[o?r(`webComponents.mcpWidget.truncated`,`Preview truncated. Full output remains in the tool result. `):``,s?r(`webComponents.mcpWidget.nonTextCount`,`{count} non-text content item(s) returned to the agent.`,{count:s}):``]}):null]})}exports.McpToolFields=i,exports.McpToolFrame=n,exports.McpToolOutput=a;
|
|
3
3
|
//# sourceMappingURL=McpToolWidget.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpToolWidget.cjs","names":["react_jsx_runtime","McpToolFrame","failed","phase","result","title","error","children","fieldText","value","item","McpToolFields","values","fields","label","text","McpToolOutput","limit","truncated","nonText","block","part","remaining"],"sources":["../../../src/components/McpToolWidget.tsx"],"sourcesContent":["import type { PoMcpWidgetProps } from '@agimon-ai/po-core/mcpWidget';\nimport type { ReactNode } from 'react';\n\n/** Presentational primitives only. Each package chooses its own fields and result presentation. */\nexport function McpToolFrame({\n title,\n phase,\n result,\n error,\n children,\n}: Pick<PoMcpWidgetProps, 'phase' | 'result' | 'error'> & { title: string; children?: ReactNode }) {\n const failed = phase === 'error' || result?.isError === true;\n const status = failed\n ? 'Tool failed'\n : phase === 'result'\n ? 'Result received'\n : phase === 'cancelled'\n ? 'Tool cancelled'\n : phase === 'running'\n ? 'Running tool...'\n : phase === 'preparing'\n ? 'Preparing tool...'\n : 'Connecting to host...';\n return (\n <section className=\"min-w-0 rounded-md border border-po-border bg-po-bg p-4 text-base text-po-text\">\n <h1 className=\"m-0 break-words text-lg font-semibold\">{title}</h1>\n <p\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className={failed ? 'my-2 text-po-red' : 'my-2 text-po-dim'}\n >\n {error ?? status}\n </p>\n {children}\n </section>\n );\n}\n\nfunction fieldText(value: unknown): string | undefined {\n if (typeof value === 'string') return value.length > 500 ? `${value.slice(0, 500)}...` : value;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return String(value);\n if (Array.isArray(value) && value.every((item) => typeof item === 'string')) return fieldText(value.join(', '));\n return undefined;\n}\n\nexport function McpToolFields({ fields }: { fields: readonly (readonly [string, unknown])[] }) {\n const values = fields.flatMap(([label, value]) => {\n const text = fieldText(value);\n return text === undefined || text === '' ? [] : [{ label, text }];\n });\n if (values.length === 0) return null;\n return (\n <dl aria-label
|
|
1
|
+
{"version":3,"file":"McpToolWidget.cjs","names":["useT","react_jsx_runtime","_agimon_ai_po_core_web","McpToolFrame","t","failed","phase","result","status","title","error","children","fieldText","value","item","McpToolFields","values","fields","label","text","McpToolOutput","limit","truncated","nonText","block","part","remaining"],"sources":["../../../src/components/McpToolWidget.tsx"],"sourcesContent":["import type { PoMcpWidgetProps } from '@agimon-ai/po-core/mcpWidget';\nimport { useT } from '@agimon-ai/po-core/web';\nimport type { ReactNode } from 'react';\n\n/** Presentational primitives only. Each package chooses its own fields and result presentation. */\nexport function McpToolFrame({\n title,\n phase,\n result,\n error,\n children,\n}: Pick<PoMcpWidgetProps, 'phase' | 'result' | 'error'> & { title: string; children?: ReactNode }) {\n const t = useT();\n const failed = phase === 'error' || result?.isError === true;\n const status = failed\n ? t('webComponents.mcpWidget.failed', 'Tool failed')\n : phase === 'result'\n ? t('webComponents.mcpWidget.received', 'Result received')\n : phase === 'cancelled'\n ? t('webComponents.mcpWidget.cancelled', 'Tool cancelled')\n : phase === 'running'\n ? t('webComponents.mcpWidget.running', 'Running tool...')\n : phase === 'preparing'\n ? t('webComponents.mcpWidget.preparing', 'Preparing tool...')\n : t('webComponents.mcpWidget.connecting', 'Connecting to host...');\n return (\n <section className=\"min-w-0 rounded-md border border-po-border bg-po-bg p-4 text-base text-po-text\">\n <h1 className=\"m-0 break-words text-lg font-semibold\">{title}</h1>\n <p\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className={failed ? 'my-2 text-po-red' : 'my-2 text-po-dim'}\n >\n {error ?? status}\n </p>\n {children}\n </section>\n );\n}\n\nfunction fieldText(value: unknown): string | undefined {\n if (typeof value === 'string') return value.length > 500 ? `${value.slice(0, 500)}...` : value;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return String(value);\n if (Array.isArray(value) && value.every((item) => typeof item === 'string')) return fieldText(value.join(', '));\n return undefined;\n}\n\nexport function McpToolFields({ fields }: { fields: readonly (readonly [string, unknown])[] }) {\n const t = useT();\n const values = fields.flatMap(([label, value]) => {\n const text = fieldText(value);\n return text === undefined || text === '' ? [] : [{ label, text }];\n });\n if (values.length === 0) return null;\n return (\n <dl aria-label={t('webComponents.mcpWidget.details', 'Tool details')} className=\"my-3 flex min-w-0 flex-col gap-2\">\n {values.map(({ label, text }) => (\n <div key={label} className=\"flex min-w-0 flex-wrap gap-x-3 gap-y-1\">\n <dt className=\"text-sm text-po-dim\">{label}</dt>\n <dd className=\"m-0 min-w-0 whitespace-pre-wrap break-all text-sm\">{text}</dd>\n </div>\n ))}\n </dl>\n );\n}\n\nexport function McpToolOutput({ result }: Pick<PoMcpWidgetProps, 'result'>) {\n const t = useT();\n if (result === null) return null;\n const limit = 8000;\n let text = '';\n let truncated = false;\n let nonText = 0;\n for (const block of result.content ?? []) {\n if (block.type !== 'text') {\n nonText += 1;\n continue;\n }\n const part = `${text ? '\\n' : ''}${block.text}`;\n const remaining = Math.max(0, limit - text.length);\n truncated ||= part.length > remaining;\n text += part.slice(0, remaining);\n }\n if (!text && result.structuredContent) {\n const value = JSON.stringify(result.structuredContent, null, 2);\n text = value.slice(0, limit);\n truncated = value.length > limit;\n }\n return (\n <details open className=\"min-w-0 rounded-md border border-po-border-soft\">\n <summary className=\"cursor-pointer bg-po-panel p-3 text-sm focus-visible:outline\">\n {t('webComponents.mcpWidget.output', 'Tool output')}\n </summary>\n <pre\n tabIndex={0}\n aria-label={t('webComponents.mcpWidget.outputPreview', 'Tool output preview')}\n className=\"m-0 max-h-72 overflow-auto whitespace-pre-wrap break-all p-3 font-mono text-sm\"\n >\n {text ||\n (nonText\n ? t('webComponents.mcpWidget.nonText', 'Non-text result returned to the agent.')\n : t('webComponents.mcpWidget.empty', 'No text output.'))}\n </pre>\n {truncated || nonText ? (\n <p className=\"m-0 border-t border-po-border-soft p-3 text-sm text-po-dim\">\n {truncated\n ? t('webComponents.mcpWidget.truncated', 'Preview truncated. Full output remains in the tool result. ')\n : ''}\n {nonText\n ? t('webComponents.mcpWidget.nonTextCount', '{count} non-text content item(s) returned to the agent.', {\n count: nonText,\n })\n : ''}\n </p>\n ) : null}\n </details>\n );\n}\n"],"mappings":"A,uEAKA,SAAgBG,EAAa,CAC3B,QACA,QACA,SACA,QACA,YACiG,CACjG,IAAMC,GAAA,EAAIJ,EAAAA,KAAAA,CAAK,EACTK,EAASC,IAAU,SAAWC,GAAQ,UAAY,GAClDC,EAASH,EACXD,EAAE,iCAAkC,aAAa,EACjDE,IAAU,SACRF,EAAE,mCAAoC,iBAAiB,EACvDE,IAAU,YACRF,EAAE,oCAAqC,gBAAgB,EACvDE,IAAU,UACRF,EAAE,kCAA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D,CAAA,EACJkB,GAAaC,EACZ,iBAAA,EAAAtB,EAAA,KAAA,CAAC,IAAD,CAAG,UAAU,6DAAb,SAAA,CACGqB,EACGlB,EAAE,oCAAqC,6DAA6D,EACpG,GACHmB,EACGnB,EAAE,uCAAwC,0DAA2D,CACnG,MAAOmB,CACT,CAAC,EACD,EACH,CACD,CAAA,EAAA,IACG,C,EAEb,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpToolWidget.d.mts","names":[],"sources":["../../../src/components/McpToolWidget.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"McpToolWidget.d.mts","names":[],"sources":["../../../src/components/McpToolWidget.tsx"],"mappings":";;;;wBAKgB,eACd,OACA,OACA,QACA,OACA,YACC,KAAK;EAAoD;EAAe,WAAW;oBAAW,IAAA;wBAsCjF,gBAAgB;EAAY;oBAAiD,IAAA;wBAmB7E,gBAAgB,UAAU,KAAK,8CAA2B,IAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";function
|
|
2
|
-
`:``}${e.text}`,n=Math.max(0,
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useT as n}from"@agimon-ai/po-core/web";function r({title:r,phase:i,result:a,error:o,children:s}){let c=n(),l=i===`error`||a?.isError===!0,u=l?c(`webComponents.mcpWidget.failed`,`Tool failed`):i===`result`?c(`webComponents.mcpWidget.received`,`Result received`):i===`cancelled`?c(`webComponents.mcpWidget.cancelled`,`Tool cancelled`):i===`running`?c(`webComponents.mcpWidget.running`,`Running tool...`):i===`preparing`?c(`webComponents.mcpWidget.preparing`,`Preparing tool...`):c(`webComponents.mcpWidget.connecting`,`Connecting to host...`);return/* @__PURE__ */ t(`section`,{className:`min-w-0 rounded-md border border-po-border bg-po-bg p-4 text-base text-po-text`,children:[/* @__PURE__ */ e(`h1`,{className:`m-0 break-words text-lg font-semibold`,children:r}),/* @__PURE__ */ e(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:l?`my-2 text-po-red`:`my-2 text-po-dim`,children:o??u}),s]})}function i(e){if(typeof e==`string`)return e.length>500?`${e.slice(0,500)}...`:e;if(typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`)return String(e);if(Array.isArray(e)&&e.every(e=>typeof e==`string`))return i(e.join(`, `))}function a({fields:r}){let a=n(),o=r.flatMap(([e,t])=>{let n=i(t);return n===void 0||n===``?[]:[{label:e,text:n}]});return o.length===0?null:/* @__PURE__ */ e(`dl`,{"aria-label":a(`webComponents.mcpWidget.details`,`Tool details`),className:`my-3 flex min-w-0 flex-col gap-2`,children:o.map(({label:n,text:r})=>/* @__PURE__ */ t(`div`,{className:`flex min-w-0 flex-wrap gap-x-3 gap-y-1`,children:[/* @__PURE__ */ e(`dt`,{className:`text-sm text-po-dim`,children:n}),/* @__PURE__ */ e(`dd`,{className:`m-0 min-w-0 whitespace-pre-wrap break-all text-sm`,children:r})]},n))})}function o({result:r}){let i=n();if(r===null)return null;let a=8e3,o=``,s=!1,c=0;for(let e of r.content??[]){if(e.type!==`text`){c+=1;continue}let t=`${o?`
|
|
2
|
+
`:``}${e.text}`,n=Math.max(0,a-o.length);s||=t.length>n,o+=t.slice(0,n)}if(!o&&r.structuredContent){let e=JSON.stringify(r.structuredContent,null,2);o=e.slice(0,a),s=e.length>a}return/* @__PURE__ */ t(`details`,{open:!0,className:`min-w-0 rounded-md border border-po-border-soft`,children:[/* @__PURE__ */ e(`summary`,{className:`cursor-pointer bg-po-panel p-3 text-sm focus-visible:outline`,children:i(`webComponents.mcpWidget.output`,`Tool output`)}),/* @__PURE__ */ e(`pre`,{tabIndex:0,"aria-label":i(`webComponents.mcpWidget.outputPreview`,`Tool output preview`),className:`m-0 max-h-72 overflow-auto whitespace-pre-wrap break-all p-3 font-mono text-sm`,children:o||(c?i(`webComponents.mcpWidget.nonText`,`Non-text result returned to the agent.`):i(`webComponents.mcpWidget.empty`,`No text output.`))}),s||c?/* @__PURE__ */ t(`p`,{className:`m-0 border-t border-po-border-soft p-3 text-sm text-po-dim`,children:[s?i(`webComponents.mcpWidget.truncated`,`Preview truncated. Full output remains in the tool result. `):``,c?i(`webComponents.mcpWidget.nonTextCount`,`{count} non-text content item(s) returned to the agent.`,{count:c}):``]}):null]})}export{a as McpToolFields,r as McpToolFrame,o as McpToolOutput};
|
|
3
3
|
//# sourceMappingURL=McpToolWidget.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpToolWidget.mjs","names":["McpToolFrame","failed","phase","result","title","error","children","fieldText","value","item","McpToolFields","values","fields","label","text","McpToolOutput","limit","truncated","nonText","block","part","remaining"],"sources":["../../../src/components/McpToolWidget.tsx"],"sourcesContent":["import type { PoMcpWidgetProps } from '@agimon-ai/po-core/mcpWidget';\nimport type { ReactNode } from 'react';\n\n/** Presentational primitives only. Each package chooses its own fields and result presentation. */\nexport function McpToolFrame({\n title,\n phase,\n result,\n error,\n children,\n}: Pick<PoMcpWidgetProps, 'phase' | 'result' | 'error'> & { title: string; children?: ReactNode }) {\n const failed = phase === 'error' || result?.isError === true;\n const status = failed\n ? 'Tool failed'\n : phase === 'result'\n ? 'Result received'\n : phase === 'cancelled'\n ? 'Tool cancelled'\n : phase === 'running'\n ? 'Running tool...'\n : phase === 'preparing'\n ? 'Preparing tool...'\n : 'Connecting to host...';\n return (\n <section className=\"min-w-0 rounded-md border border-po-border bg-po-bg p-4 text-base text-po-text\">\n <h1 className=\"m-0 break-words text-lg font-semibold\">{title}</h1>\n <p\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className={failed ? 'my-2 text-po-red' : 'my-2 text-po-dim'}\n >\n {error ?? status}\n </p>\n {children}\n </section>\n );\n}\n\nfunction fieldText(value: unknown): string | undefined {\n if (typeof value === 'string') return value.length > 500 ? `${value.slice(0, 500)}...` : value;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return String(value);\n if (Array.isArray(value) && value.every((item) => typeof item === 'string')) return fieldText(value.join(', '));\n return undefined;\n}\n\nexport function McpToolFields({ fields }: { fields: readonly (readonly [string, unknown])[] }) {\n const values = fields.flatMap(([label, value]) => {\n const text = fieldText(value);\n return text === undefined || text === '' ? [] : [{ label, text }];\n });\n if (values.length === 0) return null;\n return (\n <dl aria-label
|
|
1
|
+
{"version":3,"file":"McpToolWidget.mjs","names":["McpToolFrame","t","useT","failed","phase","result","status","title","error","children","fieldText","value","item","McpToolFields","values","fields","label","text","McpToolOutput","limit","truncated","nonText","block","part","remaining"],"sources":["../../../src/components/McpToolWidget.tsx"],"sourcesContent":["import type { PoMcpWidgetProps } from '@agimon-ai/po-core/mcpWidget';\nimport { useT } from '@agimon-ai/po-core/web';\nimport type { ReactNode } from 'react';\n\n/** Presentational primitives only. Each package chooses its own fields and result presentation. */\nexport function McpToolFrame({\n title,\n phase,\n result,\n error,\n children,\n}: Pick<PoMcpWidgetProps, 'phase' | 'result' | 'error'> & { title: string; children?: ReactNode }) {\n const t = useT();\n const failed = phase === 'error' || result?.isError === true;\n const status = failed\n ? t('webComponents.mcpWidget.failed', 'Tool failed')\n : phase === 'result'\n ? t('webComponents.mcpWidget.received', 'Result received')\n : phase === 'cancelled'\n ? t('webComponents.mcpWidget.cancelled', 'Tool cancelled')\n : phase === 'running'\n ? t('webComponents.mcpWidget.running', 'Running tool...')\n : phase === 'preparing'\n ? t('webComponents.mcpWidget.preparing', 'Preparing tool...')\n : t('webComponents.mcpWidget.connecting', 'Connecting to host...');\n return (\n <section className=\"min-w-0 rounded-md border border-po-border bg-po-bg p-4 text-base text-po-text\">\n <h1 className=\"m-0 break-words text-lg font-semibold\">{title}</h1>\n <p\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className={failed ? 'my-2 text-po-red' : 'my-2 text-po-dim'}\n >\n {error ?? status}\n </p>\n {children}\n </section>\n );\n}\n\nfunction fieldText(value: unknown): string | undefined {\n if (typeof value === 'string') return value.length > 500 ? `${value.slice(0, 500)}...` : value;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return String(value);\n if (Array.isArray(value) && value.every((item) => typeof item === 'string')) return fieldText(value.join(', '));\n return undefined;\n}\n\nexport function McpToolFields({ fields }: { fields: readonly (readonly [string, unknown])[] }) {\n const t = useT();\n const values = fields.flatMap(([label, value]) => {\n const text = fieldText(value);\n return text === undefined || text === '' ? [] : [{ label, text }];\n });\n if (values.length === 0) return null;\n return (\n <dl aria-label={t('webComponents.mcpWidget.details', 'Tool details')} className=\"my-3 flex min-w-0 flex-col gap-2\">\n {values.map(({ label, text }) => (\n <div key={label} className=\"flex min-w-0 flex-wrap gap-x-3 gap-y-1\">\n <dt className=\"text-sm text-po-dim\">{label}</dt>\n <dd className=\"m-0 min-w-0 whitespace-pre-wrap break-all text-sm\">{text}</dd>\n </div>\n ))}\n </dl>\n );\n}\n\nexport function McpToolOutput({ result }: Pick<PoMcpWidgetProps, 'result'>) {\n const t = useT();\n if (result === null) return null;\n const limit = 8000;\n let text = '';\n let truncated = false;\n let nonText = 0;\n for (const block of result.content ?? []) {\n if (block.type !== 'text') {\n nonText += 1;\n continue;\n }\n const part = `${text ? '\\n' : ''}${block.text}`;\n const remaining = Math.max(0, limit - text.length);\n truncated ||= part.length > remaining;\n text += part.slice(0, remaining);\n }\n if (!text && result.structuredContent) {\n const value = JSON.stringify(result.structuredContent, null, 2);\n text = value.slice(0, limit);\n truncated = value.length > limit;\n }\n return (\n <details open className=\"min-w-0 rounded-md border border-po-border-soft\">\n <summary className=\"cursor-pointer bg-po-panel p-3 text-sm focus-visible:outline\">\n {t('webComponents.mcpWidget.output', 'Tool output')}\n </summary>\n <pre\n tabIndex={0}\n aria-label={t('webComponents.mcpWidget.outputPreview', 'Tool output preview')}\n className=\"m-0 max-h-72 overflow-auto whitespace-pre-wrap break-all p-3 font-mono text-sm\"\n >\n {text ||\n (nonText\n ? t('webComponents.mcpWidget.nonText', 'Non-text result returned to the agent.')\n : t('webComponents.mcpWidget.empty', 'No text output.'))}\n </pre>\n {truncated || nonText ? (\n <p className=\"m-0 border-t border-po-border-soft p-3 text-sm text-po-dim\">\n {truncated\n ? t('webComponents.mcpWidget.truncated', 'Preview truncated. Full output remains in the tool result. ')\n : ''}\n {nonText\n ? t('webComponents.mcpWidget.nonTextCount', '{count} non-text content item(s) returned to the agent.', {\n count: nonText,\n })\n : ''}\n </p>\n ) : null}\n </details>\n );\n}\n"],"mappings":"A,gGAKA,SAAgBA,EAAa,CAC3B,QACA,QACA,SACA,QACA,YACiG,CACjG,IAAMC,EAAIC,EAAK,EACTC,EAASC,IAAU,SAAWC,GAAQ,UAAY,GAClDC,EAASH,EACXF,EAAE,iCAAkC,aAAa,EACjDG,IAAU,SACRH,EAAE,mCAAoC,iBAAiB,EACvDG,IAAU,YACRH,EAAE,oCAAqC,gBAAgB,EACvDG,IAAU,UACRH,EAAE,kCAAmC,iBAAiB,EACtDG,IAAU,YACRH,EAAE,oCAAqC,mBAAmB,EAC1DA,EAAE,qCAAsC,uBAAuB,EAC3E,MACE,kBAAC,UAAD,CAAS,UAAU,iFAAnB,SAAA,CACE,kBAAC,KAAD,CAAI,UAAU,wCAAyC,SAAAM,CAAU,CAAA,EACjE,kBAAC,IAAD,CACE,KAAK,SACL,YAAU,SACV,cAAY,OACZ,UAAWJ,EAAS,mBAAqB,mBAExC,SAAAK,GAASF,CACT,CAAA,EACFG,CACM,C,EAEb,CAEA,SAASC,EAAU,EAAoC,CACrD,GAAI,OAAOC,GAAU,SAAU,OAAOA,EAAM,OAAS,IAAM,GAAGA,EAAM,MAAM,EAAG,GAAG,EAAE,KAAOA,EAEzF,GADI,OAAOA,GAAU,UAAY,OAAO,SAASA,CAAK,GAClD,OAAOA,GAAU,UAAW,OAAO,OAAOA,CAAK,EACnD,GAAI,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAO,GAAS,OAAOC,GAAS,QAAQ,EAAG,OAAOF,EAAUC,EAAM,KAA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,CAAS,KAAA,GAAK,UAAU,kDAAxB,SAAA,CACE,kBAAC,UAAD,CAAS,UAAU,+DAChB,SAAAlB,EAAE,iCAAkC,aAAa,CAC3C,CAAA,EACT,kBAAC,MAAD,CACE,SAAU,EACV,aAAYA,EAAE,wCAAyC,qBAAqB,EAC5E,UAAU,iFAET,SAAAgB,IACEI,EACGpB,EAAE,kCAAmC,wCAAwC,EAC7EA,EAAE,gCAAiC,iBAAiB,EACvD,CAAA,EACJmB,GAAaC,EACZ,kBAAC,IAAD,CAAG,UAAU,6DAAb,SAAA,CACGD,EACGnB,EAAE,oCAAqC,6DAA6D,EACpG,GACHoB,EACGpB,EAAE,uCAAwC,0DAA2D,CACnG,MAAOoB,CACT,CAAC,EACD,EACH,CACD,CAAA,EAAA,IACG,C,EAEb,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require("../icons/icons.cjs");const e=require("../lib/cn.cjs"),t=require("./Button.cjs"),n=require("./StatusBadge.cjs");let r=require("react/jsx-runtime"),i=require("react"),a=require("@agimon-ai/po-core/web"),o=require("class-variance-authority"),s=require("lucide-react");const c=(0,i.createContext)(null),l=(0,i.createContext)({tone:`neutral`,expandable:!1,expanded:!1,toggle:()=>void 0}),u=(0,i.createContext)(!1);function d(){return(0,i.useContext)(l)}const f=(0,i.createContext)(null),p=(0,o.cva)(`overflow-hidden rounded-lg border transition-colors`,{variants:{tone:{...n.STATUS_EDGE,ok:`border-po-border-soft`}},defaultVariants:{tone:`neutral`}}),m=(0,o.cva)(`overflow-hidden border-l-2 transition-colors`,{variants:{tone:{...n.STATUS_EDGE,ok:`border-transparent`,neutral:`border-transparent`}},defaultVariants:{tone:`neutral`}});function h({title:e,children:t}){return/* @__PURE__ */ (0,r.jsxs)(r.Fragment,{children:[/* @__PURE__ */ (0,r.jsx)(`span`,{"aria-hidden":!0,className:`grid size-9 shrink-0 place-items-center rounded-full bg-po-rail text-po-dim max-sm:hidden`,children:/* @__PURE__ */ (0,r.jsx)(s.Wrench,{className:`size-4`})}),/* @__PURE__ */ (0,r.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[/* @__PURE__ */ (0,r.jsx)(`span`,{className:`text-sm text-po-dim`,children
|
|
1
|
+
require("../icons/icons.cjs");const e=require("../lib/cn.cjs"),t=require("./Button.cjs"),n=require("./StatusBadge.cjs");let r=require("react/jsx-runtime"),i=require("react"),a=require("@agimon-ai/po-core/web"),o=require("class-variance-authority"),s=require("lucide-react");const c=(0,i.createContext)(null),l=(0,i.createContext)({tone:`neutral`,expandable:!1,expanded:!1,toggle:()=>void 0}),u=(0,i.createContext)(!1);function d(){return(0,i.useContext)(l)}const f=(0,i.createContext)(null),p=(0,o.cva)(`overflow-hidden rounded-lg border transition-colors`,{variants:{tone:{...n.STATUS_EDGE,ok:`border-po-border-soft`}},defaultVariants:{tone:`neutral`}}),m=(0,o.cva)(`overflow-hidden border-l-2 transition-colors`,{variants:{tone:{...n.STATUS_EDGE,ok:`border-transparent`,neutral:`border-transparent`}},defaultVariants:{tone:`neutral`}});function h({title:e,children:t}){let n=(0,a.useT)();return/* @__PURE__ */ (0,r.jsxs)(r.Fragment,{children:[/* @__PURE__ */ (0,r.jsx)(`span`,{"aria-hidden":!0,className:`grid size-9 shrink-0 place-items-center rounded-full bg-po-rail text-po-dim max-sm:hidden`,children:/* @__PURE__ */ (0,r.jsx)(s.Wrench,{className:`size-4`})}),/* @__PURE__ */ (0,r.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[/* @__PURE__ */ (0,r.jsx)(`span`,{className:`text-sm text-po-dim`,children:n(`webComponents.messageItem.toolCall`,`Tool call`)}),/* @__PURE__ */ (0,r.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-base`,children:[/* @__PURE__ */ (0,r.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-po-hi`,children:e}),/* @__PURE__ */ (0,r.jsx)(`div`,{"data-slot":`message-item-summary`,className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden`,children:t})]})]})]})}function g({className:t,tone:n,expandable:a=!1,defaultExpanded:o=!1,expanded:s,onExpandedChange:d,children:h,...g}){let[_,v]=(0,i.useState)(o),y=(0,i.useContext)(f),b=(0,i.useContext)(c),x=y!==null,S=(0,i.useContext)(u)&&!x,C=s??_,w={tone:n??`neutral`,headerAccessory:b,expandable:a,expanded:C,nested:S,toggle:()=>{let e=!C;s===void 0&&v(e),d?.(e)}};return/* @__PURE__ */ (0,r.jsx)(l.Provider,{value:w,children:/* @__PURE__ */ (0,r.jsx)(c,{value:null,children:/* @__PURE__ */ (0,r.jsx)(u,{value:!0,children:/* @__PURE__ */ (0,r.jsx)(`div`,{"data-slot":`message-item`,"data-expanded":C,"data-grouped":x,"data-nested":S,className:e.cn(x?m({tone:n}):S?`min-w-0`:p({tone:n}),t),...g,children:typeof h==`function`?h(w):h})})})})}function _({className:e,tone:t,title:n,summary:i,badge:a,children:o,defaultExpanded:s=!1,...c}){return/* @__PURE__ */ (0,r.jsx)(g,{tone:t,expandable:!0,defaultExpanded:s,className:e,"data-slot":`message-item-group`,...c,children:({expanded:e})=>/* @__PURE__ */ (0,r.jsxs)(r.Fragment,{children:[/* @__PURE__ */ (0,r.jsx)(w,{title:n,badge:a,children:/* @__PURE__ */ (0,r.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-po-faint`,children:i})}),e?/* @__PURE__ */ (0,r.jsx)(f.Provider,{value:{tone:t??`neutral`},children:/* @__PURE__ */ (0,r.jsx)(`div`,{className:`flex flex-col divide-y divide-po-border-soft border-t border-po-border-soft`,children:o})}):null]})})}function v(e){return e.running?`running`:e.isError?`error`:`ok`}const y={neutral:``,running:`Running`,ok:`Completed`,error:`Failed`,info:`Info`,accent:`Note`};function b(e,t){switch(t){case`running`:return e(`webComponents.messageItem.running`,`Running`);case`ok`:return e(`webComponents.messageItem.completed`,`Completed`);case`error`:return e(`webComponents.messageItem.failed`,`Failed`);case`info`:return e(`webComponents.messageItem.info`,`Info`);case`accent`:return e(`webComponents.messageItem.note`,`Note`);default:return y[t]}}const x={running:/* @__PURE__ */ (0,r.jsx)(s.Loader2,{"aria-hidden":!0,className:`size-3 animate-spin`}),ok:/* @__PURE__ */ (0,r.jsx)(s.Check,{"aria-hidden":!0,className:`size-3`}),error:/* @__PURE__ */ (0,r.jsx)(s.CircleAlert,{"aria-hidden":!0,className:`size-3`})};function S({tone:e,children:t,...i}){return/* @__PURE__ */ (0,r.jsxs)(n.StatusBadge,{tone:e,size:`md`,className:`gap-1 font-semibold`,...i,children:[x[e],/* @__PURE__ */ (0,r.jsx)(`span`,{className:x[e]?`@max-md:sr-only`:void 0,children:t})]})}const C=/* @__PURE__ */ new Set([`ok`,`neutral`]);function w({className:n,title:o,badge:c,children:l,...u}){let{headerAccessory:p,tone:m,expandable:g,expanded:_,toggle:v,nested:y}=d(),w=(0,i.useContext)(f),T=(0,a.useT)(),E=w!==null&&C.has(m)?null:b(T,m),O=c===void 0?E:c;return/* @__PURE__ */ (0,r.jsxs)(`div`,{"data-slot":`message-item-header`,className:e.cn(`@container flex min-h-11 items-center gap-3 px-4 py-3 text-sm text-po-dim`,y&&`min-h-9 px-0 py-0`,n),...u,children:[w===null?y?/* @__PURE__ */ (0,r.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 text-base`,children:[/* @__PURE__ */ (0,r.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-po-hi`,children:o}),/* @__PURE__ */ (0,r.jsx)(`div`,{"data-slot":`message-item-summary`,className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden`,children:l})]}):/* @__PURE__ */ (0,r.jsx)(h,{title:o,children:l}):/* @__PURE__ */ (0,r.jsx)(`div`,{"data-slot":`message-item-summary`,className:`flex min-w-0 flex-1 items-center gap-2`,children:l}),p,O===null||O===``?null:y&&x[m]?/* @__PURE__ */ (0,r.jsxs)(`span`,{"data-testid":`tool-status`,className:e.cn(D({tone:m}),`flex w-3 justify-center`),children:[x[m],/* @__PURE__ */ (0,r.jsx)(`span`,{className:`sr-only`,children:O})]}):/* @__PURE__ */ (0,r.jsx)(S,{tone:m,"data-testid":`tool-status`,children:O}),g?/* @__PURE__ */ (0,r.jsx)(t.Button,{variant:`ghost`,size:`icon`,"data-testid":`tool-expand`,"aria-expanded":_,"aria-label":_?T(`webComponents.messageItem.collapse`,`collapse`):T(`webComponents.messageItem.expand`,`expand`),onClick:v,className:`text-po-dim hover:text-po-blue`,children:_?/* @__PURE__ */ (0,r.jsx)(s.ChevronUp,{className:`size-4`}):/* @__PURE__ */ (0,r.jsx)(s.ChevronDown,{className:`size-4`})}):null]})}function T({className:t,...n}){let{nested:i}=d();return/* @__PURE__ */ (0,r.jsx)(`div`,{"data-slot":`message-item-body`,className:e.cn(`border-t border-po-border-soft px-4 py-3 text-base text-po-dim`,i&&`border-t-0 px-0 py-1`,t),...n})}const E={neutral:`…`,running:`◐`,ok:`✓`,error:`✗`,info:`●`,accent:`●`},D=(0,o.cva)(`shrink-0`,{variants:{tone:{neutral:`text-po-faint`,running:`text-po-yellow`,ok:`text-po-green`,error:`text-po-red`,info:`text-po-blue`,accent:`text-po-magenta`}},defaultVariants:{tone:`neutral`}});function O({className:t,tone:n,glyph:i,expands:a=!1,children:o,...s}){let{toggle:c}=d(),l=/* @__PURE__ */ (0,r.jsxs)(r.Fragment,{children:[/* @__PURE__ */ (0,r.jsx)(`span`,{className:D({tone:n}),children:i??E[n??`neutral`]}),/* @__PURE__ */ (0,r.jsx)(`span`,{children:o})]});return a?/* @__PURE__ */ (0,r.jsx)(`button`,{type:`button`,"data-slot":`message-item-status`,"data-testid":`tool-more`,onClick:c,className:e.cn(`flex min-h-6 min-w-6 cursor-pointer items-center gap-1.5 text-po-faint hover:text-po-blue`,t),children:l}):/* @__PURE__ */ (0,r.jsx)(`span`,{"data-slot":`message-item-status`,className:e.cn(`flex items-center gap-1.5 text-po-faint`,t),...s,children:l})}exports.MessageItem=g,exports.MessageItemBody=T,exports.MessageItemGroup=_,exports.MessageItemHeader=w,exports.MessageItemHeaderAccessoryContext=c,exports.MessageItemStatus=O,exports.STATUS_GLYPH=E,exports.STATUS_LABEL=y,exports.messageItemRowVariants=m,exports.messageItemStatusVariants=D,exports.messageItemVariants=p,exports.toolTone=v,exports.useMessageItem=d;
|
|
2
2
|
//# sourceMappingURL=MessageItem.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.cjs","names":["createContext","useContext","cva","STATUS_EDGE","WrenchIcon","useState","cn","LoaderIcon","CheckIcon","AlertIcon","StatusBadge","useT","Button","ChevronUpIcon","ChevronDownIcon","require_cn","require_Button","require_StatusBadge","react_jsx_runtime","react","_agimon_ai_po_core_web","class_variance_authority","lucide_react","MessageItemHeaderAccessoryContext","MessageItemContext","InsideMessageItemContext","useMessageItem","MessageItemGroupContext","messageItemVariants","messageItemRowVariants","ToolCallLead","title","MessageItem","props","own","setOwn","defaultExpanded","group","headerAccessory","grouped","nested","current","expanded","state","tone","next","onExpandedChange","className","children","MessageItemGroup","MessageItemHeader","summary","toolTone","STATUS_LABEL","statusLabel","t","OUTCOME_ICON","OutcomeBadge","SILENT_IN_GROUP","defaultLabel","label","badge","messageItemStatusVariants","expandable","toggle","MessageItemBody","STATUS_GLYPH","MessageItemStatus","content","glyph","expands"],"sources":["../../../src/components/MessageItem.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/web';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { type ComponentProps, createContext, type ReactNode, useContext, useState } from 'react';\n\nimport { AlertIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon, LoaderIcon, WrenchIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport { Button } from './Button';\nimport { STATUS_EDGE, StatusBadge, type StatusTone } from './StatusBadge';\n\n/**\n * The message item: the timeline card a tool call, a run, or a notice sits\n * in. The item owns its outcome tone and its expand state; the header, body,\n * and status parts read both from it, so a card composes the parts and never\n * threads `expanded` by hand. A tool message in a web plugin is built from\n * this, and so is the cockpit's own fallback item, which is what keeps them\n * looking alike.\n */\n\n/** The next item captures this accessory for its header, without passing it to nested items. */\nexport const MessageItemHeaderAccessoryContext = createContext<ReactNode>(null);\n\nexport interface MessageItemState {\n tone: StatusTone;\n headerAccessory?: ReactNode;\n /** Whether the header offers the toggle; an item that hides nothing offers none. */\n expandable: boolean;\n expanded: boolean;\n toggle: () => void;\n /** Whether this item sits inside another item's body, such as a call an exec script made. */\n nested?: boolean;\n}\n\nconst MessageItemContext = createContext<MessageItemState>({\n tone: 'neutral',\n expandable: false,\n expanded: false,\n toggle: () => undefined,\n});\n\n/** True under any item, so an item drawn inside another one drops its own frame. */\nconst InsideMessageItemContext = createContext(false);\n\n/** The enclosing item's state, for a part that lives deeper than the item's render prop. */\nexport function useMessageItem(): MessageItemState {\n return useContext(MessageItemContext);\n}\n\n/**\n * The group an item is a row of, or null for an item that is a card of its\n * own. A row drops the frame the group already draws and keeps its tone as an\n * edge down its left side, and it stops repeating what the group's header has\n * said once: the tool's name, and an outcome the whole run shares.\n */\nconst MessageItemGroupContext = createContext<{ tone: StatusTone } | null>(null);\n\n/**\n * The frame, wearing the edge STATUS_EDGE names for the tone, so the two never drift apart.\n * A settled OK is the calm default and keeps the soft border; only work in flight or a failure colours the edge.\n */\nexport const messageItemVariants = cva('overflow-hidden rounded-lg border transition-colors', {\n variants: { tone: { ...STATUS_EDGE, ok: 'border-po-border-soft' } },\n defaultVariants: { tone: 'neutral' },\n});\n\n/** The same tone as a row: no card, one coloured edge, and the group's separators between rows. A settled row keeps a quiet edge. */\nexport const messageItemRowVariants = cva('overflow-hidden border-l-2 transition-colors', {\n variants: { tone: { ...STATUS_EDGE, ok: 'border-transparent', neutral: 'border-transparent' } },\n defaultVariants: { tone: 'neutral' },\n});\n\n/** The card's lead: the tool chip, the \"Tool call\" caption, then the name and its summary on one line. */\nfunction ToolCallLead({ title, children }: { title: ReactNode; children?: ReactNode }) {\n return (\n <>\n <span\n aria-hidden\n className=\"grid size-9 shrink-0 place-items-center rounded-full bg-po-rail text-po-dim max-sm:hidden\"\n >\n <WrenchIcon className=\"size-4\" />\n </span>\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"text-sm text-po-dim\">Tool call</span>\n <div className=\"flex min-w-0 items-center gap-2 text-base\">\n <span className=\"min-w-0 truncate font-semibold text-po-hi\">{title}</span>\n <div data-slot=\"message-item-summary\" className=\"flex min-w-0 flex-1 items-center gap-2 overflow-hidden\">\n {children}\n </div>\n </div>\n </div>\n </>\n );\n}\n\nexport interface MessageItemProps\n extends Omit<ComponentProps<'div'>, 'children'>, VariantProps<typeof messageItemVariants> {\n /** Whether the header offers the expand toggle. A toggle that reveals nothing reads as broken, so the card decides. */\n expandable?: boolean;\n defaultExpanded?: boolean;\n /** Controlled mode; pair with onExpandedChange. Omit it and the item keeps its own state. */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Plain content, or a function of the item's state for a card that picks its lines by `expanded`. */\n children?: ReactNode | ((state: MessageItemState) => ReactNode);\n}\n\nexport function MessageItem({\n className,\n tone,\n expandable = false,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n children,\n ...props\n}: MessageItemProps) {\n const [own, setOwn] = useState(defaultExpanded);\n const group = useContext(MessageItemGroupContext);\n const headerAccessory = useContext(MessageItemHeaderAccessoryContext);\n const grouped = group !== null;\n // A grouped row is also inside an item; the row style already handles it.\n const nested = useContext(InsideMessageItemContext) && !grouped;\n const current = expanded ?? own;\n const state: MessageItemState = {\n tone: tone ?? 'neutral',\n headerAccessory,\n expandable,\n expanded: current,\n nested,\n toggle: () => {\n const next = !current;\n if (expanded === undefined) setOwn(next);\n onExpandedChange?.(next);\n },\n };\n return (\n <MessageItemContext.Provider value={state}>\n <MessageItemHeaderAccessoryContext value={null}>\n <InsideMessageItemContext value>\n <div\n data-slot=\"message-item\"\n data-expanded={current}\n data-grouped={grouped}\n data-nested={nested}\n className={cn(\n grouped ? messageItemRowVariants({ tone }) : nested ? 'min-w-0' : messageItemVariants({ tone }),\n className,\n )}\n {...props}\n >\n {typeof children === 'function' ? children(state) : children}\n </div>\n </InsideMessageItemContext>\n </MessageItemHeaderAccessoryContext>\n </MessageItemContext.Provider>\n );\n}\n\nexport interface MessageItemGroupProps\n extends Omit<ComponentProps<'div'>, 'title'>, VariantProps<typeof messageItemVariants> {\n /** The bold label at the left of the group header: the tool the run belongs to. */\n title: ReactNode;\n /** The line beside it, such as how many calls the group holds. */\n summary?: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n defaultExpanded?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One frame around a run of items that belong together.\n *\n * A transcript that calls the same tool five times in a row is five identical\n * frames, five gutter labels and five gaps, and the repetition reads louder\n * than the commands do. The group draws the frame once and each item inside it\n * becomes a row: same header, same expand, no card of its own. The tone still\n * belongs to the row, as an edge, so a failure in the middle of a run is not\n * flattened into the group's own outcome.\n */\nexport function MessageItemGroup({\n className,\n tone,\n title,\n summary,\n badge,\n children,\n defaultExpanded = false,\n ...props\n}: MessageItemGroupProps) {\n return (\n <MessageItem\n tone={tone}\n expandable\n defaultExpanded={defaultExpanded}\n className={className}\n data-slot=\"message-item-group\"\n {...props}\n >\n {({ expanded }) => (\n <>\n <MessageItemHeader title={title} badge={badge}>\n <span className=\"min-w-0 flex-1 truncate text-po-faint\">{summary}</span>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemGroupContext.Provider value={{ tone: tone ?? 'neutral' }}>\n <div className=\"flex flex-col divide-y divide-po-border-soft border-t border-po-border-soft\">\n {children}\n </div>\n </MessageItemGroupContext.Provider>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\n/** The tone a tool call's item wears: running while the tool runs, then its outcome. */\nexport function toolTone(state: { running: boolean; isError: boolean }): StatusTone {\n return state.running ? 'running' : state.isError ? 'error' : 'ok';\n}\n\n/** The badge text a tone reads as when the header is not told otherwise; empty hides the badge. */\nexport const STATUS_LABEL: Readonly<Record<StatusTone, string>> = {\n neutral: '',\n running: 'Running',\n ok: 'Completed',\n error: 'Failed',\n info: 'Info',\n accent: 'Note',\n};\n\n/** STATUS_LABEL, translated where it is rendered. */\nfunction statusLabel(t: ReturnType<typeof useT>, tone: StatusTone): string {\n switch (tone) {\n case 'running':\n return t('webComponents.messageItem.running', 'Running');\n case 'ok':\n return t('webComponents.messageItem.completed', 'Completed');\n case 'error':\n return t('webComponents.messageItem.failed', 'Failed');\n case 'info':\n return t('webComponents.messageItem.info', 'Info');\n case 'accent':\n return t('webComponents.messageItem.note', 'Note');\n default:\n return STATUS_LABEL[tone];\n }\n}\n\nconst OUTCOME_ICON: Partial<Record<StatusTone, ReactNode>> = {\n running: <LoaderIcon aria-hidden className=\"size-3 animate-spin\" />,\n ok: <CheckIcon aria-hidden className=\"size-3\" />,\n error: <AlertIcon aria-hidden className=\"size-3\" />,\n};\n\n/** The sentence-case outcome pill, led by the tone's icon. A narrow card (a phone, a side drawer) keeps the icon and leaves the words to screen readers. */\nfunction OutcomeBadge({ tone, children, ...props }: ComponentProps<typeof StatusBadge> & { tone: StatusTone }) {\n return (\n <StatusBadge tone={tone} size=\"md\" className=\"gap-1 font-semibold\" {...props}>\n {OUTCOME_ICON[tone]}\n <span className={OUTCOME_ICON[tone] ? '@max-md:sr-only' : undefined}>{children}</span>\n </StatusBadge>\n );\n}\n\nexport interface MessageItemHeaderProps extends Omit<ComponentProps<'div'>, 'title'> {\n /** The bold label at the left: the tool name. */\n title: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n /** The summary beside the title; it gets the remaining width. */\n children?: ReactNode;\n}\n\n/** Inside a group these two are the quiet outcome: the group's header has already said it. */\nconst SILENT_IN_GROUP: ReadonlySet<StatusTone> = new Set<StatusTone>(['ok', 'neutral']);\n\n/**\n * The title row: label, summary, the tone's badge, and the expand toggle when\n * the item is expandable.\n *\n * A row inside a group says less. The group's header has already named the\n * tool and stated the run's outcome, so the row drops its title and speaks up\n * only when something went wrong or is still going: five OK badges down a run\n * of five are noise, and the one ERROR among them is the point.\n *\n * A nested item keeps its title but drops the chip and the caption: the outer\n * item already said this is a tool call. Its outcome is a bare glyph, as the\n * outer item's own call rows show it; the word stays for screen readers.\n */\nexport function MessageItemHeader({ className, title, badge, children, ...props }: MessageItemHeaderProps) {\n const { headerAccessory, tone, expandable, expanded, toggle, nested } = useMessageItem();\n const group = useContext(MessageItemGroupContext);\n const t = useT();\n const defaultLabel = group !== null && SILENT_IN_GROUP.has(tone) ? null : statusLabel(t, tone);\n const label = badge === undefined ? defaultLabel : badge;\n return (\n <div\n data-slot=\"message-item-header\"\n className={cn(\n '@container flex min-h-11 items-center gap-3 px-4 py-3 text-sm text-po-dim',\n nested && 'min-h-9 px-0 py-0',\n className,\n )}\n {...props}\n >\n {group !== null ? (\n <div data-slot=\"message-item-summary\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n {children}\n </div>\n ) : nested ? (\n <div className=\"flex min-w-0 flex-1 items-center gap-2 text-base\">\n <span className=\"min-w-0 truncate font-semibold text-po-hi\">{title}</span>\n <div data-slot=\"message-item-summary\" className=\"flex min-w-0 flex-1 items-center gap-2 overflow-hidden\">\n {children}\n </div>\n </div>\n ) : (\n <ToolCallLead title={title}>{children}</ToolCallLead>\n )}\n {headerAccessory}\n {label === null || label === '' ? null : nested && OUTCOME_ICON[tone] ? (\n <span data-testid=\"tool-status\" className={cn(messageItemStatusVariants({ tone }), 'flex w-3 justify-center')}>\n {OUTCOME_ICON[tone]}\n <span className=\"sr-only\">{label}</span>\n </span>\n ) : (\n <OutcomeBadge tone={tone} data-testid=\"tool-status\">\n {label}\n </OutcomeBadge>\n )}\n {expandable ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n data-testid=\"tool-expand\"\n aria-expanded={expanded}\n aria-label={\n expanded\n ? t('webComponents.messageItem.collapse', 'collapse')\n : t('webComponents.messageItem.expand', 'expand')\n }\n onClick={toggle}\n className=\"text-po-dim hover:text-po-blue\"\n >\n {expanded ? <ChevronUpIcon className=\"size-4\" /> : <ChevronDownIcon className=\"size-4\" />}\n </Button>\n ) : null}\n </div>\n );\n}\n\n/** The body under the header, on the card's own surface; a nested item's body needs no rule or inset. */\nexport function MessageItemBody({ className, ...props }: ComponentProps<'div'>) {\n const { nested } = useMessageItem();\n return (\n <div\n data-slot=\"message-item-body\"\n className={cn(\n 'border-t border-po-border-soft px-4 py-3 text-base text-po-dim',\n nested && 'border-t-0 px-0 py-1',\n className,\n )}\n {...props}\n />\n );\n}\n\n/** The glyph a tone reads as in a status line. */\nexport const STATUS_GLYPH: Readonly<Record<StatusTone, string>> = {\n neutral: '…',\n running: '◐',\n ok: '✓',\n error: '✗',\n info: '●',\n accent: '●',\n};\n\nexport const messageItemStatusVariants = cva('shrink-0', {\n variants: {\n tone: {\n neutral: 'text-po-faint',\n running: 'text-po-yellow',\n ok: 'text-po-green',\n error: 'text-po-red',\n info: 'text-po-blue',\n accent: 'text-po-magenta',\n } satisfies Record<StatusTone, string>,\n },\n defaultVariants: { tone: 'neutral' },\n});\n\nexport interface MessageItemStatusProps extends ComponentProps<'span'>, VariantProps<typeof messageItemStatusVariants> {\n /** Replaces the tone's glyph. */\n glyph?: string;\n /** Renders as a button that expands the item: the \"N more line(s)\" hint. Only className carries over. */\n expands?: boolean;\n}\n\n/** The one-line status under a body: `◐ running`, `✗ failed`, `✓ done`, or the hint that more is hidden. */\nexport function MessageItemStatus({\n className,\n tone,\n glyph,\n expands = false,\n children,\n ...props\n}: MessageItemStatusProps) {\n const { toggle } = useMessageItem();\n const content = (\n <>\n <span className={messageItemStatusVariants({ tone })}>{glyph ?? STATUS_GLYPH[tone ?? 'neutral']}</span>\n <span>{children}</span>\n </>\n );\n if (expands) {\n return (\n <button\n type=\"button\"\n data-slot=\"message-item-status\"\n data-testid=\"tool-more\"\n onClick={toggle}\n className={cn(\n 'flex min-h-6 min-w-6 cursor-pointer items-center gap-1.5 text-po-faint hover:text-po-blue',\n className,\n )}\n >\n {content}\n </button>\n );\n }\n return (\n <span\n data-slot=\"message-item-status\"\n className={cn('flex items-center gap-1.5 text-po-faint', className)}\n {...props}\n >\n {content}\n </span>\n );\n}\n"],"mappings":"A,kRAmBA,MAAauB,GAAA,EAAoCvB,EAAAA,cAAAA,CAAyB,IAAI,EAaxEwB,GAAA,EAAqBxB,EAAAA,cAAAA,CAAgC,CACzD,KAAM,UACN,WAAY,GACZ,SAAU,GACV,WAAc,IAAA,EAChB,CAAC,EAGKyB,GAAA,EAA2BzB,EAAAA,cAAAA,CAAc,EAAK,EAGpD,SAAgB0B,GAAmC,CACjD,OAAA,EAAOzB,EAAAA,WAAAA,CAAWuB,CAAkB,CACtC,CAQA,MAAMG,GAAA,EAA0B3B,EAAAA,cAAAA,CAA2C,IAAI,EAMlE4B,GAAA,EAAsB1B,EAAAA,IAAAA,CAAI,sDAAuD,CAC5F,SAAU,CAAE,KAAM,CAAE,GAAGC,EAAAA,YAAa,GAAI,uBAAwB,CAAE,EAClE,gBAAiB,CAAE,KAAM,SAAU,CACrC,CAAC,EAGY0B,GAAA,EAAyB3B,EAAAA,IAAAA,CAAI,+CAAgD,CACxF,SAAU,CAAE,KAAM,CAAE,GAAGC,EAAAA,YAAa,GAAI,qBAAsB,QAAS,oBAAqB,CAAE,EAC9F,gBAAiB,CAAE,KAAM,SAAU,CACrC,CAAC,EAGD,SAAS2B,EAAa,CAAE,QAAO,YAAwD,CACrF,MACE,iBAAA,EAAAZ,EAAA,KAAA,CAAAA,EAAA,SAAA,CAAA,SAAA,CACE,iBAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,cAAA,GACA,UAAU,4FAEV,SAAA,iBAAA,EAAAA,EAAA,IAAA,CAACd,EAAAA,OAAD,CAAY,UAAU,QAAU,CAAA,CAC5B,CAAA,EACN,iBAAA,EAAAc,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,+BAAf,SAAA,CACE,iBAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,sBAA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,GAAG,0CAA2CyC,CAAS,EAClE,GAAId,EAEH,SAAAmC,CACG,CAAA,CAEV,C"}
|
|
1
|
+
{"version":3,"file":"MessageItem.cjs","names":["createContext","useContext","cva","STATUS_EDGE","useT","WrenchIcon","useState","cn","LoaderIcon","CheckIcon","AlertIcon","StatusBadge","Button","ChevronUpIcon","ChevronDownIcon","require_cn","require_Button","require_StatusBadge","react_jsx_runtime","react","_agimon_ai_po_core_web","class_variance_authority","lucide_react","MessageItemHeaderAccessoryContext","MessageItemContext","InsideMessageItemContext","useMessageItem","MessageItemGroupContext","messageItemVariants","messageItemRowVariants","ToolCallLead","t","title","MessageItem","props","own","setOwn","defaultExpanded","group","headerAccessory","grouped","nested","current","expanded","state","tone","next","onExpandedChange","className","children","MessageItemGroup","MessageItemHeader","summary","toolTone","STATUS_LABEL","statusLabel","OUTCOME_ICON","OutcomeBadge","SILENT_IN_GROUP","defaultLabel","label","badge","messageItemStatusVariants","expandable","toggle","MessageItemBody","STATUS_GLYPH","MessageItemStatus","content","glyph","expands"],"sources":["../../../src/components/MessageItem.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/web';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { type ComponentProps, createContext, type ReactNode, useContext, useState } from 'react';\n\nimport { AlertIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon, LoaderIcon, WrenchIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport { Button } from './Button';\nimport { STATUS_EDGE, StatusBadge, type StatusTone } from './StatusBadge';\n\n/**\n * The message item: the timeline card a tool call, a run, or a notice sits\n * in. The item owns its outcome tone and its expand state; the header, body,\n * and status parts read both from it, so a card composes the parts and never\n * threads `expanded` by hand. A tool message in a web plugin is built from\n * this, and so is the cockpit's own fallback item, which is what keeps them\n * looking alike.\n */\n\n/** The next item captures this accessory for its header, without passing it to nested items. */\nexport const MessageItemHeaderAccessoryContext = createContext<ReactNode>(null);\n\nexport interface MessageItemState {\n tone: StatusTone;\n headerAccessory?: ReactNode;\n /** Whether the header offers the toggle; an item that hides nothing offers none. */\n expandable: boolean;\n expanded: boolean;\n toggle: () => void;\n /** Whether this item sits inside another item's body, such as a call an exec script made. */\n nested?: boolean;\n}\n\nconst MessageItemContext = createContext<MessageItemState>({\n tone: 'neutral',\n expandable: false,\n expanded: false,\n toggle: () => undefined,\n});\n\n/** True under any item, so an item drawn inside another one drops its own frame. */\nconst InsideMessageItemContext = createContext(false);\n\n/** The enclosing item's state, for a part that lives deeper than the item's render prop. */\nexport function useMessageItem(): MessageItemState {\n return useContext(MessageItemContext);\n}\n\n/**\n * The group an item is a row of, or null for an item that is a card of its\n * own. A row drops the frame the group already draws and keeps its tone as an\n * edge down its left side, and it stops repeating what the group's header has\n * said once: the tool's name, and an outcome the whole run shares.\n */\nconst MessageItemGroupContext = createContext<{ tone: StatusTone } | null>(null);\n\n/**\n * The frame, wearing the edge STATUS_EDGE names for the tone, so the two never drift apart.\n * A settled OK is the calm default and keeps the soft border; only work in flight or a failure colours the edge.\n */\nexport const messageItemVariants = cva('overflow-hidden rounded-lg border transition-colors', {\n variants: { tone: { ...STATUS_EDGE, ok: 'border-po-border-soft' } },\n defaultVariants: { tone: 'neutral' },\n});\n\n/** The same tone as a row: no card, one coloured edge, and the group's separators between rows. A settled row keeps a quiet edge. */\nexport const messageItemRowVariants = cva('overflow-hidden border-l-2 transition-colors', {\n variants: { tone: { ...STATUS_EDGE, ok: 'border-transparent', neutral: 'border-transparent' } },\n defaultVariants: { tone: 'neutral' },\n});\n\n/** The card's lead: the tool chip, the \"Tool call\" caption, then the name and its summary on one line. */\nfunction ToolCallLead({ title, children }: { title: ReactNode; children?: ReactNode }) {\n const t = useT();\n return (\n <>\n <span\n aria-hidden\n className=\"grid size-9 shrink-0 place-items-center rounded-full bg-po-rail text-po-dim max-sm:hidden\"\n >\n <WrenchIcon className=\"size-4\" />\n </span>\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"text-sm text-po-dim\">{t('webComponents.messageItem.toolCall', 'Tool call')}</span>\n <div className=\"flex min-w-0 items-center gap-2 text-base\">\n <span className=\"min-w-0 truncate font-semibold text-po-hi\">{title}</span>\n <div data-slot=\"message-item-summary\" className=\"flex min-w-0 flex-1 items-center gap-2 overflow-hidden\">\n {children}\n </div>\n </div>\n </div>\n </>\n );\n}\n\nexport interface MessageItemProps\n extends Omit<ComponentProps<'div'>, 'children'>, VariantProps<typeof messageItemVariants> {\n /** Whether the header offers the expand toggle. A toggle that reveals nothing reads as broken, so the card decides. */\n expandable?: boolean;\n defaultExpanded?: boolean;\n /** Controlled mode; pair with onExpandedChange. Omit it and the item keeps its own state. */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Plain content, or a function of the item's state for a card that picks its lines by `expanded`. */\n children?: ReactNode | ((state: MessageItemState) => ReactNode);\n}\n\nexport function MessageItem({\n className,\n tone,\n expandable = false,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n children,\n ...props\n}: MessageItemProps) {\n const [own, setOwn] = useState(defaultExpanded);\n const group = useContext(MessageItemGroupContext);\n const headerAccessory = useContext(MessageItemHeaderAccessoryContext);\n const grouped = group !== null;\n // A grouped row is also inside an item; the row style already handles it.\n const nested = useContext(InsideMessageItemContext) && !grouped;\n const current = expanded ?? own;\n const state: MessageItemState = {\n tone: tone ?? 'neutral',\n headerAccessory,\n expandable,\n expanded: current,\n nested,\n toggle: () => {\n const next = !current;\n if (expanded === undefined) setOwn(next);\n onExpandedChange?.(next);\n },\n };\n return (\n <MessageItemContext.Provider value={state}>\n <MessageItemHeaderAccessoryContext value={null}>\n <InsideMessageItemContext value>\n <div\n data-slot=\"message-item\"\n data-expanded={current}\n data-grouped={grouped}\n data-nested={nested}\n className={cn(\n grouped ? messageItemRowVariants({ tone }) : nested ? 'min-w-0' : messageItemVariants({ tone }),\n className,\n )}\n {...props}\n >\n {typeof children === 'function' ? children(state) : children}\n </div>\n </InsideMessageItemContext>\n </MessageItemHeaderAccessoryContext>\n </MessageItemContext.Provider>\n );\n}\n\nexport interface MessageItemGroupProps\n extends Omit<ComponentProps<'div'>, 'title'>, VariantProps<typeof messageItemVariants> {\n /** The bold label at the left of the group header: the tool the run belongs to. */\n title: ReactNode;\n /** The line beside it, such as how many calls the group holds. */\n summary?: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n defaultExpanded?: boolean;\n children?: ReactNode;\n}\n\n/**\n * One frame around a run of items that belong together.\n *\n * A transcript that calls the same tool five times in a row is five identical\n * frames, five gutter labels and five gaps, and the repetition reads louder\n * than the commands do. The group draws the frame once and each item inside it\n * becomes a row: same header, same expand, no card of its own. The tone still\n * belongs to the row, as an edge, so a failure in the middle of a run is not\n * flattened into the group's own outcome.\n */\nexport function MessageItemGroup({\n className,\n tone,\n title,\n summary,\n badge,\n children,\n defaultExpanded = false,\n ...props\n}: MessageItemGroupProps) {\n return (\n <MessageItem\n tone={tone}\n expandable\n defaultExpanded={defaultExpanded}\n className={className}\n data-slot=\"message-item-group\"\n {...props}\n >\n {({ expanded }) => (\n <>\n <MessageItemHeader title={title} badge={badge}>\n <span className=\"min-w-0 flex-1 truncate text-po-faint\">{summary}</span>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemGroupContext.Provider value={{ tone: tone ?? 'neutral' }}>\n <div className=\"flex flex-col divide-y divide-po-border-soft border-t border-po-border-soft\">\n {children}\n </div>\n </MessageItemGroupContext.Provider>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\n/** The tone a tool call's item wears: running while the tool runs, then its outcome. */\nexport function toolTone(state: { running: boolean; isError: boolean }): StatusTone {\n return state.running ? 'running' : state.isError ? 'error' : 'ok';\n}\n\n/** The badge text a tone reads as when the header is not told otherwise; empty hides the badge. */\nexport const STATUS_LABEL: Readonly<Record<StatusTone, string>> = {\n neutral: '',\n running: 'Running',\n ok: 'Completed',\n error: 'Failed',\n info: 'Info',\n accent: 'Note',\n};\n\n/** STATUS_LABEL, translated where it is rendered. */\nfunction statusLabel(t: ReturnType<typeof useT>, tone: StatusTone): string {\n switch (tone) {\n case 'running':\n return t('webComponents.messageItem.running', 'Running');\n case 'ok':\n return t('webComponents.messageItem.completed', 'Completed');\n case 'error':\n return t('webComponents.messageItem.failed', 'Failed');\n case 'info':\n return t('webComponents.messageItem.info', 'Info');\n case 'accent':\n return t('webComponents.messageItem.note', 'Note');\n default:\n return STATUS_LABEL[tone];\n }\n}\n\nconst OUTCOME_ICON: Partial<Record<StatusTone, ReactNode>> = {\n running: <LoaderIcon aria-hidden className=\"size-3 animate-spin\" />,\n ok: <CheckIcon aria-hidden className=\"size-3\" />,\n error: <AlertIcon aria-hidden className=\"size-3\" />,\n};\n\n/** The sentence-case outcome pill, led by the tone's icon. A narrow card (a phone, a side drawer) keeps the icon and leaves the words to screen readers. */\nfunction OutcomeBadge({ tone, children, ...props }: ComponentProps<typeof StatusBadge> & { tone: StatusTone }) {\n return (\n <StatusBadge tone={tone} size=\"md\" className=\"gap-1 font-semibold\" {...props}>\n {OUTCOME_ICON[tone]}\n <span className={OUTCOME_ICON[tone] ? '@max-md:sr-only' : undefined}>{children}</span>\n </StatusBadge>\n );\n}\n\nexport interface MessageItemHeaderProps extends Omit<ComponentProps<'div'>, 'title'> {\n /** The bold label at the left: the tool name. */\n title: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n /** The summary beside the title; it gets the remaining width. */\n children?: ReactNode;\n}\n\n/** Inside a group these two are the quiet outcome: the group's header has already said it. */\nconst SILENT_IN_GROUP: ReadonlySet<StatusTone> = new Set<StatusTone>(['ok', 'neutral']);\n\n/**\n * The title row: label, summary, the tone's badge, and the expand toggle when\n * the item is expandable.\n *\n * A row inside a group says less. The group's header has already named the\n * tool and stated the run's outcome, so the row drops its title and speaks up\n * only when something went wrong or is still going: five OK badges down a run\n * of five are noise, and the one ERROR among them is the point.\n *\n * A nested item keeps its title but drops the chip and the caption: the outer\n * item already said this is a tool call. Its outcome is a bare glyph, as the\n * outer item's own call rows show it; the word stays for screen readers.\n */\nexport function MessageItemHeader({ className, title, badge, children, ...props }: MessageItemHeaderProps) {\n const { headerAccessory, tone, expandable, expanded, toggle, nested } = useMessageItem();\n const group = useContext(MessageItemGroupContext);\n const t = useT();\n const defaultLabel = group !== null && SILENT_IN_GROUP.has(tone) ? null : statusLabel(t, tone);\n const label = badge === undefined ? defaultLabel : badge;\n return (\n <div\n data-slot=\"message-item-header\"\n className={cn(\n '@container flex min-h-11 items-center gap-3 px-4 py-3 text-sm text-po-dim',\n nested && 'min-h-9 px-0 py-0',\n className,\n )}\n {...props}\n >\n {group !== null ? (\n <div data-slot=\"message-item-summary\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n {children}\n </div>\n ) : nested ? (\n <div className=\"flex min-w-0 flex-1 items-center gap-2 text-base\">\n <span className=\"min-w-0 truncate font-semibold text-po-hi\">{title}</span>\n <div data-slot=\"message-item-summary\" className=\"flex min-w-0 flex-1 items-center gap-2 overflow-hidden\">\n {children}\n </div>\n </div>\n ) : (\n <ToolCallLead title={title}>{children}</ToolCallLead>\n )}\n {headerAccessory}\n {label === null || label === '' ? null : nested && OUTCOME_ICON[tone] ? (\n <span data-testid=\"tool-status\" className={cn(messageItemStatusVariants({ tone }), 'flex w-3 justify-center')}>\n {OUTCOME_ICON[tone]}\n <span className=\"sr-only\">{label}</span>\n </span>\n ) : (\n <OutcomeBadge tone={tone} data-testid=\"tool-status\">\n {label}\n </OutcomeBadge>\n )}\n {expandable ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n data-testid=\"tool-expand\"\n aria-expanded={expanded}\n aria-label={\n expanded\n ? t('webComponents.messageItem.collapse', 'collapse')\n : t('webComponents.messageItem.expand', 'expand')\n }\n onClick={toggle}\n className=\"text-po-dim hover:text-po-blue\"\n >\n {expanded ? <ChevronUpIcon className=\"size-4\" /> : <ChevronDownIcon className=\"size-4\" />}\n </Button>\n ) : null}\n </div>\n );\n}\n\n/** The body under the header, on the card's own surface; a nested item's body needs no rule or inset. */\nexport function MessageItemBody({ className, ...props }: ComponentProps<'div'>) {\n const { nested } = useMessageItem();\n return (\n <div\n data-slot=\"message-item-body\"\n className={cn(\n 'border-t border-po-border-soft px-4 py-3 text-base text-po-dim',\n nested && 'border-t-0 px-0 py-1',\n className,\n )}\n {...props}\n />\n );\n}\n\n/** The glyph a tone reads as in a status line. */\nexport const STATUS_GLYPH: Readonly<Record<StatusTone, string>> = {\n neutral: '…',\n running: '◐',\n ok: '✓',\n error: '✗',\n info: '●',\n accent: '●',\n};\n\nexport const messageItemStatusVariants = cva('shrink-0', {\n variants: {\n tone: {\n neutral: 'text-po-faint',\n running: 'text-po-yellow',\n ok: 'text-po-green',\n error: 'text-po-red',\n info: 'text-po-blue',\n accent: 'text-po-magenta',\n } satisfies Record<StatusTone, string>,\n },\n defaultVariants: { tone: 'neutral' },\n});\n\nexport interface MessageItemStatusProps extends ComponentProps<'span'>, VariantProps<typeof messageItemStatusVariants> {\n /** Replaces the tone's glyph. */\n glyph?: string;\n /** Renders as a button that expands the item: the \"N more line(s)\" hint. Only className carries over. */\n expands?: boolean;\n}\n\n/** The one-line status under a body: `◐ running`, `✗ failed`, `✓ done`, or the hint that more is hidden. */\nexport function MessageItemStatus({\n className,\n tone,\n glyph,\n expands = false,\n children,\n ...props\n}: MessageItemStatusProps) {\n const { toggle } = useMessageItem();\n const content = (\n <>\n <span className={messageItemStatusVariants({ tone })}>{glyph ?? STATUS_GLYPH[tone ?? 'neutral']}</span>\n <span>{children}</span>\n </>\n );\n if (expands) {\n return (\n <button\n type=\"button\"\n data-slot=\"message-item-status\"\n data-testid=\"tool-more\"\n onClick={toggle}\n className={cn(\n 'flex min-h-6 min-w-6 cursor-pointer items-center gap-1.5 text-po-faint hover:text-po-blue',\n className,\n )}\n >\n {content}\n </button>\n );\n }\n return (\n <span\n data-slot=\"message-item-status\"\n className={cn('flex items-center gap-1.5 text-po-faint', className)}\n {...props}\n >\n {content}\n </span>\n );\n}\n"],"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