@agimon-ai/po-web-components 0.0.0-alpha.21 → 0.0.0-alpha.211
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/LICENSE +1 -192
- package/NOTICE +61 -0
- package/README.md +7 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +90 -70
- package/dist/index.mjs +1 -1
- package/dist/markdownMediaSlot.cjs +1 -0
- package/dist/markdownMediaSlot.d.mts +2 -0
- package/dist/markdownMediaSlot.mjs +1 -0
- package/dist/mcpAppHost.cjs +1 -0
- package/dist/mcpAppHost.d.mts +4 -0
- package/dist/mcpAppHost.mjs +1 -0
- package/dist/mcpWidget.d.mts +2 -2
- package/dist/mcpWidget.mjs +1 -1
- package/dist/nativeTheme.d.mts +2 -2
- package/dist/nativeTheme.mjs +1 -1
- package/dist/po-runtime-identity.json +1 -0
- package/dist/src/components/Accordion.cjs.map +1 -1
- package/dist/src/components/Accordion.d.mts.map +1 -0
- package/dist/src/components/Accordion.mjs.map +1 -0
- package/dist/src/components/AgentAvatar.cjs +1 -1
- package/dist/src/components/AgentAvatar.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/AgentAvatar.d.mts +6 -2
- package/dist/src/components/AgentAvatar.d.mts.map +1 -0
- package/dist/src/components/AgentAvatar.mjs +2 -0
- package/dist/src/components/AgentAvatar.mjs.map +1 -0
- package/dist/src/components/AnsiText.cjs.map +1 -1
- package/dist/src/components/AnsiText.d.mts.map +1 -0
- package/dist/src/components/AnsiText.mjs.map +1 -0
- package/dist/src/components/Avatar.cjs.map +1 -1
- package/dist/src/components/Avatar.d.mts.map +1 -0
- package/dist/src/components/Avatar.mjs.map +1 -0
- package/dist/src/components/Badge.cjs.map +1 -1
- package/dist/src/components/Badge.d.mts.map +1 -0
- package/dist/src/components/Badge.mjs.map +1 -0
- package/dist/src/components/Breadcrumb.cjs.map +1 -1
- package/dist/src/components/Breadcrumb.d.mts.map +1 -0
- package/dist/src/components/Breadcrumb.mjs.map +1 -0
- package/dist/src/components/Button.cjs.map +1 -1
- package/dist/src/components/Button.d.mts.map +1 -0
- package/dist/src/components/Button.mjs.map +1 -0
- package/dist/src/components/Checkbox.cjs.map +1 -1
- package/dist/src/components/Checkbox.d.mts.map +1 -0
- package/dist/src/components/Checkbox.mjs.map +1 -0
- package/dist/src/components/CodeBlock.cjs.map +1 -1
- package/dist/src/components/CodeBlock.d.mts.map +1 -0
- package/dist/src/components/CodeBlock.mjs.map +1 -0
- package/dist/src/components/CodeEditor.cjs.map +1 -1
- package/dist/src/components/CodeEditor.d.mts.map +1 -0
- package/dist/src/components/CodeEditor.mjs.map +1 -0
- package/dist/src/components/CodeEditorView.cjs.map +1 -1
- package/dist/src/components/CodeEditorView.mjs.map +1 -0
- package/dist/src/components/Collapsible.cjs.map +1 -1
- package/dist/src/components/Collapsible.d.mts.map +1 -0
- package/dist/src/components/Collapsible.mjs.map +1 -0
- package/dist/src/components/Command.cjs.map +1 -1
- package/dist/src/components/Command.d.mts.map +1 -0
- package/dist/src/components/Command.mjs.map +1 -0
- package/dist/src/components/CopyButton.cjs +1 -1
- package/dist/src/components/CopyButton.cjs.map +1 -1
- package/dist/src/components/CopyButton.mjs +2 -0
- package/dist/src/components/CopyButton.mjs.map +1 -0
- package/dist/src/components/CtaCard.cjs +2 -0
- package/dist/src/components/CtaCard.cjs.map +1 -0
- package/dist/src/components/CtaCard.d.mts +16 -0
- package/dist/src/components/CtaCard.d.mts.map +1 -0
- package/dist/src/components/CtaCard.mjs +2 -0
- package/dist/src/components/CtaCard.mjs.map +1 -0
- package/dist/src/components/Dialog.cjs +1 -1
- package/dist/src/components/Dialog.cjs.map +1 -1
- package/dist/src/components/Dialog.d.mts.map +1 -0
- package/dist/src/components/Dialog.mjs +2 -0
- package/dist/src/components/Dialog.mjs.map +1 -0
- package/dist/src/components/DiffView.cjs +1 -1
- package/dist/src/components/DiffView.cjs.map +1 -1
- package/dist/src/components/DiffView.d.mts.map +1 -0
- package/dist/src/components/DiffView.mjs +2 -0
- package/dist/src/components/DiffView.mjs.map +1 -0
- package/dist/src/components/Dot.cjs.map +1 -1
- package/dist/src/components/Dot.d.mts.map +1 -0
- package/dist/src/components/Dot.mjs.map +1 -0
- package/dist/src/components/Drawer.cjs.map +1 -1
- package/dist/src/components/Drawer.d.mts.map +1 -0
- package/dist/src/components/Drawer.mjs.map +1 -0
- package/dist/src/components/DropdownMenu.cjs +1 -1
- package/dist/src/components/DropdownMenu.cjs.map +1 -1
- package/dist/src/components/DropdownMenu.d.mts.map +1 -0
- package/dist/{packages/core/po-web-components/src → src}/components/DropdownMenu.mjs +1 -1
- package/dist/src/components/DropdownMenu.mjs.map +1 -0
- package/dist/src/components/EmptyState.cjs +1 -1
- package/dist/src/components/EmptyState.cjs.map +1 -1
- package/dist/src/components/EmptyState.d.mts +41 -0
- package/dist/src/components/EmptyState.d.mts.map +1 -0
- package/dist/src/components/EmptyState.mjs +2 -0
- package/dist/src/components/EmptyState.mjs.map +1 -0
- package/dist/src/components/FileBrowser.cjs +2 -0
- package/dist/src/components/FileBrowser.cjs.map +1 -0
- package/dist/src/components/FileBrowser.d.mts +62 -0
- package/dist/src/components/FileBrowser.d.mts.map +1 -0
- package/dist/src/components/FileBrowser.mjs +2 -0
- package/dist/src/components/FileBrowser.mjs.map +1 -0
- package/dist/src/components/FilePreview.cjs +2 -0
- package/dist/src/components/FilePreview.cjs.map +1 -0
- package/dist/src/components/FilePreview.d.mts +32 -0
- package/dist/src/components/FilePreview.d.mts.map +1 -0
- package/dist/src/components/FilePreview.mjs +2 -0
- package/dist/src/components/FilePreview.mjs.map +1 -0
- package/dist/src/components/FlowGraph.cjs +2 -0
- package/dist/src/components/FlowGraph.cjs.map +1 -0
- package/dist/src/components/FlowGraph.d.mts +119 -0
- package/dist/src/components/FlowGraph.d.mts.map +1 -0
- package/dist/src/components/FlowGraph.mjs +2 -0
- package/dist/src/components/FlowGraph.mjs.map +1 -0
- package/dist/src/components/HashlineLines.cjs +1 -1
- package/dist/src/components/HashlineLines.cjs.map +1 -1
- package/dist/src/components/HashlineLines.d.mts.map +1 -0
- package/dist/src/components/HashlineLines.mjs +2 -0
- package/dist/src/components/HashlineLines.mjs.map +1 -0
- package/dist/src/components/Input.cjs +1 -1
- package/dist/src/components/Input.cjs.map +1 -1
- package/dist/src/components/Input.d.mts.map +1 -0
- package/dist/src/components/Input.mjs +2 -0
- package/dist/src/components/Input.mjs.map +1 -0
- package/dist/src/components/Kbd.cjs.map +1 -1
- package/dist/src/components/Kbd.d.mts.map +1 -0
- package/dist/src/components/Kbd.mjs.map +1 -0
- package/dist/src/components/Label.cjs.map +1 -1
- package/dist/src/components/Label.d.mts.map +1 -0
- package/dist/src/components/Label.mjs.map +1 -0
- package/dist/src/components/LiveDuration.cjs +2 -0
- package/dist/src/components/LiveDuration.cjs.map +1 -0
- package/dist/src/components/LiveDuration.d.mts +15 -0
- package/dist/src/components/LiveDuration.d.mts.map +1 -0
- package/dist/src/components/LiveDuration.mjs +2 -0
- package/dist/src/components/LiveDuration.mjs.map +1 -0
- package/dist/src/components/LoadingState.cjs +2 -0
- package/dist/src/components/LoadingState.cjs.map +1 -0
- package/dist/src/components/LoadingState.d.mts +17 -0
- package/dist/src/components/LoadingState.d.mts.map +1 -0
- package/dist/src/components/LoadingState.mjs +2 -0
- package/dist/src/components/LoadingState.mjs.map +1 -0
- package/dist/src/components/Markdown.cjs +2 -2
- package/dist/src/components/Markdown.cjs.map +1 -1
- package/dist/src/components/Markdown.d.mts +38 -0
- package/dist/src/components/Markdown.d.mts.map +1 -0
- package/dist/src/components/Markdown.mjs +3 -0
- package/dist/src/components/Markdown.mjs.map +1 -0
- package/dist/src/components/McpApp.cjs +1 -1
- package/dist/src/components/McpApp.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/McpApp.d.mts +1 -2
- package/dist/src/components/McpApp.d.mts.map +1 -0
- package/dist/src/components/McpApp.mjs +2 -0
- package/dist/src/components/McpApp.mjs.map +1 -0
- package/dist/src/components/McpToolWidget.cjs +2 -2
- package/dist/src/components/McpToolWidget.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/McpToolWidget.d.mts +1 -2
- package/dist/src/components/McpToolWidget.d.mts.map +1 -0
- package/dist/src/components/McpToolWidget.mjs +3 -0
- package/dist/src/components/McpToolWidget.mjs.map +1 -0
- package/dist/src/components/MediaPreview.cjs +1 -1
- package/dist/src/components/MediaPreview.cjs.map +1 -1
- package/dist/src/components/MediaPreview.d.mts.map +1 -0
- package/dist/src/components/MediaPreview.mjs +2 -0
- package/dist/src/components/MediaPreview.mjs.map +1 -0
- package/dist/src/components/MediaViewerDialog.cjs +2 -0
- package/dist/src/components/MediaViewerDialog.cjs.map +1 -0
- package/dist/src/components/MediaViewerDialog.d.mts +20 -0
- package/dist/src/components/MediaViewerDialog.d.mts.map +1 -0
- package/dist/src/components/MediaViewerDialog.mjs +2 -0
- package/dist/src/components/MediaViewerDialog.mjs.map +1 -0
- package/dist/src/components/MermaidDiagram.cjs +1 -1
- package/dist/src/components/MermaidDiagram.cjs.map +1 -1
- package/dist/src/components/MermaidDiagram.mjs +2 -0
- package/dist/src/components/MermaidDiagram.mjs.map +1 -0
- package/dist/src/components/MessageItem.cjs +1 -1
- package/dist/src/components/MessageItem.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/MessageItem.d.mts +9 -2
- package/dist/src/components/MessageItem.d.mts.map +1 -0
- package/dist/src/components/MessageItem.mjs +2 -0
- package/dist/src/components/MessageItem.mjs.map +1 -0
- package/dist/src/components/MessageLines.cjs.map +1 -1
- package/dist/src/components/MessageLines.d.mts.map +1 -0
- package/dist/src/components/MessageLines.mjs.map +1 -0
- package/dist/src/components/OptionList.cjs +1 -1
- package/dist/src/components/OptionList.cjs.map +1 -1
- package/dist/src/components/OptionList.d.mts.map +1 -0
- package/dist/src/components/OptionList.mjs +2 -0
- package/dist/src/components/OptionList.mjs.map +1 -0
- package/dist/src/components/Panel.cjs.map +1 -1
- package/dist/src/components/Panel.d.mts.map +1 -0
- package/dist/src/components/Panel.mjs.map +1 -0
- package/dist/src/components/PathText.cjs +2 -0
- package/dist/src/components/PathText.cjs.map +1 -0
- package/dist/src/components/PathText.d.mts +15 -0
- package/dist/src/components/PathText.d.mts.map +1 -0
- package/dist/src/components/PathText.mjs +2 -0
- package/dist/src/components/PathText.mjs.map +1 -0
- package/dist/src/components/PdfPreview.cjs +1 -1
- package/dist/src/components/PdfPreview.cjs.map +1 -1
- package/dist/src/components/PdfPreview.d.mts.map +1 -0
- package/dist/src/components/PdfPreview.mjs +2 -0
- package/dist/src/components/PdfPreview.mjs.map +1 -0
- package/dist/src/components/Picker.cjs +1 -1
- package/dist/src/components/Picker.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/Picker.d.mts +19 -6
- package/dist/src/components/Picker.d.mts.map +1 -0
- package/dist/src/components/Picker.mjs +2 -0
- package/dist/src/components/Picker.mjs.map +1 -0
- package/dist/src/components/Popover.cjs.map +1 -1
- package/dist/src/components/Popover.d.mts.map +1 -0
- package/dist/src/components/Popover.mjs.map +1 -0
- package/dist/src/components/ProfilePicker.cjs +2 -0
- package/dist/src/components/ProfilePicker.cjs.map +1 -0
- package/dist/src/components/ProfilePicker.d.mts +34 -0
- package/dist/src/components/ProfilePicker.d.mts.map +1 -0
- package/dist/src/components/ProfilePicker.mjs +2 -0
- package/dist/src/components/ProfilePicker.mjs.map +1 -0
- package/dist/src/components/Progress.cjs.map +1 -1
- package/dist/src/components/Progress.d.mts.map +1 -0
- package/dist/src/components/Progress.mjs.map +1 -0
- package/dist/src/components/QrCode.cjs +2 -0
- package/dist/src/components/QrCode.cjs.map +1 -0
- package/dist/src/components/QrCode.d.mts +22 -0
- package/dist/src/components/QrCode.d.mts.map +1 -0
- package/dist/src/components/QrCode.mjs +2 -0
- package/dist/src/components/QrCode.mjs.map +1 -0
- package/dist/src/components/RadioGroup.cjs.map +1 -1
- package/dist/src/components/RadioGroup.d.mts.map +1 -0
- package/dist/src/components/RadioGroup.mjs.map +1 -0
- package/dist/src/components/ReferenceChip.cjs +2 -0
- package/dist/src/components/ReferenceChip.cjs.map +1 -0
- package/dist/src/components/ReferenceChip.d.mts +17 -0
- package/dist/src/components/ReferenceChip.d.mts.map +1 -0
- package/dist/src/components/ReferenceChip.mjs +2 -0
- package/dist/src/components/ReferenceChip.mjs.map +1 -0
- package/dist/src/components/ReviewCommentDraft.cjs +1 -1
- package/dist/src/components/ReviewCommentDraft.cjs.map +1 -1
- package/dist/src/components/ReviewCommentDraft.d.mts.map +1 -0
- package/dist/src/components/ReviewCommentDraft.mjs +2 -0
- package/dist/src/components/ReviewCommentDraft.mjs.map +1 -0
- package/dist/src/components/ScrollArea.cjs.map +1 -1
- package/dist/src/components/ScrollArea.d.mts.map +1 -0
- package/dist/src/components/ScrollArea.mjs.map +1 -0
- package/dist/src/components/SectionLabel.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/SectionLabel.d.mts +1 -1
- package/dist/src/components/SectionLabel.d.mts.map +1 -0
- package/dist/src/components/SectionLabel.mjs.map +1 -0
- package/dist/src/components/Select.cjs.map +1 -1
- package/dist/src/components/Select.d.mts.map +1 -0
- package/dist/src/components/Select.mjs.map +1 -0
- package/dist/src/components/Separator.cjs.map +1 -1
- package/dist/src/components/Separator.d.mts.map +1 -0
- package/dist/src/components/Separator.mjs.map +1 -0
- package/dist/src/components/Settings.cjs.map +1 -1
- package/dist/src/components/Settings.d.mts.map +1 -0
- package/dist/src/components/Settings.mjs.map +1 -0
- package/dist/src/components/SetupRow.cjs +2 -0
- package/dist/src/components/SetupRow.cjs.map +1 -0
- package/dist/src/components/SetupRow.d.mts +17 -0
- package/dist/src/components/SetupRow.d.mts.map +1 -0
- package/dist/src/components/SetupRow.mjs +2 -0
- package/dist/src/components/SetupRow.mjs.map +1 -0
- package/dist/src/components/Sheet.cjs +1 -1
- package/dist/src/components/Sheet.cjs.map +1 -1
- package/dist/src/components/Sheet.d.mts.map +1 -0
- package/dist/src/components/Sheet.mjs +2 -0
- package/dist/src/components/Sheet.mjs.map +1 -0
- package/dist/src/components/Skeleton.cjs.map +1 -1
- package/dist/src/components/Skeleton.d.mts.map +1 -0
- package/dist/src/components/Skeleton.mjs.map +1 -0
- package/dist/src/components/Spinner.cjs.map +1 -1
- package/dist/src/components/Spinner.d.mts.map +1 -0
- package/dist/src/components/Spinner.mjs.map +1 -0
- package/dist/src/components/StatusBadge.cjs.map +1 -1
- package/dist/src/components/StatusBadge.d.mts.map +1 -0
- package/dist/src/components/StatusBadge.mjs.map +1 -0
- package/dist/src/components/StreamCursor.cjs.map +1 -1
- package/dist/src/components/StreamCursor.d.mts.map +1 -0
- package/dist/src/components/StreamCursor.mjs.map +1 -0
- package/dist/src/components/Switch.cjs.map +1 -1
- package/dist/src/components/Switch.d.mts.map +1 -0
- package/dist/src/components/Switch.mjs.map +1 -0
- package/dist/src/components/SyntaxText.cjs +1 -1
- package/dist/src/components/SyntaxText.cjs.map +1 -1
- package/dist/src/components/SyntaxText.d.mts.map +1 -0
- package/dist/{packages/core/po-web-components/src → src}/components/SyntaxText.mjs +1 -1
- package/dist/src/components/SyntaxText.mjs.map +1 -0
- package/dist/src/components/Tabs.cjs +1 -1
- package/dist/src/components/Tabs.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/components/Tabs.d.mts +7 -3
- package/dist/src/components/Tabs.d.mts.map +1 -0
- package/dist/src/components/Tabs.mjs +2 -0
- package/dist/src/components/Tabs.mjs.map +1 -0
- package/dist/src/components/TerminalView.cjs.map +1 -1
- package/dist/src/components/TerminalView.d.mts.map +1 -0
- package/dist/src/components/TerminalView.mjs.map +1 -0
- package/dist/src/components/Textarea.cjs.map +1 -1
- package/dist/src/components/Textarea.d.mts.map +1 -0
- package/dist/src/components/Textarea.mjs.map +1 -0
- package/dist/src/components/Toast.cjs +1 -1
- package/dist/src/components/Toast.cjs.map +1 -1
- package/dist/src/components/Toast.d.mts.map +1 -0
- package/dist/src/components/Toast.mjs +2 -0
- package/dist/src/components/Toast.mjs.map +1 -0
- package/dist/src/components/ToolPathLink.cjs +1 -1
- package/dist/src/components/ToolPathLink.cjs.map +1 -1
- package/dist/src/components/ToolPathLink.d.mts.map +1 -0
- package/dist/src/components/ToolPathLink.mjs +2 -0
- package/dist/src/components/ToolPathLink.mjs.map +1 -0
- package/dist/src/components/Tooltip.cjs.map +1 -1
- package/dist/src/components/Tooltip.d.mts.map +1 -0
- package/dist/src/components/Tooltip.mjs.map +1 -0
- package/dist/src/components/ViewableImage.cjs +2 -0
- package/dist/src/components/ViewableImage.cjs.map +1 -0
- package/dist/src/components/ViewableImage.d.mts +19 -0
- package/dist/src/components/ViewableImage.d.mts.map +1 -0
- package/dist/src/components/ViewableImage.mjs +2 -0
- package/dist/src/components/ViewableImage.mjs.map +1 -0
- package/dist/src/icons/icons.cjs +1 -1
- package/dist/src/icons/icons.d.mts +2 -0
- package/dist/src/icons/icons.mjs +1 -0
- package/dist/src/lib/ansiSpans.cjs.map +1 -1
- package/dist/src/lib/ansiSpans.d.mts.map +1 -0
- package/dist/src/lib/ansiSpans.mjs.map +1 -0
- package/dist/src/lib/cn.cjs.map +1 -1
- package/dist/src/lib/cn.d.mts.map +1 -0
- package/dist/src/lib/cn.mjs.map +1 -0
- package/dist/src/lib/collapse.cjs.map +1 -1
- package/dist/src/lib/collapse.d.mts.map +1 -0
- package/dist/src/lib/collapse.mjs.map +1 -0
- package/dist/src/lib/editorController.cjs.map +1 -1
- package/dist/src/lib/editorController.mjs.map +1 -0
- package/dist/src/lib/editorLanguage.cjs.map +1 -1
- package/dist/src/lib/editorLanguage.d.mts.map +1 -0
- package/dist/src/lib/editorLanguage.mjs.map +1 -0
- package/dist/src/lib/editorTheme.cjs.map +1 -1
- package/dist/src/lib/editorTheme.d.mts.map +1 -0
- package/dist/src/lib/editorTheme.mjs.map +1 -0
- package/dist/src/lib/fenceGrammar.cjs.map +1 -1
- package/dist/src/lib/fenceGrammar.mjs.map +1 -0
- package/dist/src/lib/fileDownload.cjs +2 -0
- package/dist/src/lib/fileDownload.cjs.map +1 -0
- package/dist/src/lib/fileDownload.d.mts +25 -0
- package/dist/src/lib/fileDownload.d.mts.map +1 -0
- package/dist/src/lib/fileDownload.mjs +2 -0
- package/dist/src/lib/fileDownload.mjs.map +1 -0
- package/dist/src/lib/files.cjs +2 -0
- package/dist/src/lib/files.cjs.map +1 -0
- package/dist/src/lib/files.d.mts +61 -0
- package/dist/src/lib/files.d.mts.map +1 -0
- package/dist/src/lib/files.mjs +2 -0
- package/dist/src/lib/files.mjs.map +1 -0
- package/dist/src/lib/hashlineHighlight.cjs +1 -1
- package/dist/src/lib/hashlineHighlight.cjs.map +1 -1
- package/dist/src/lib/hashlineHighlight.d.mts.map +1 -0
- package/dist/{packages/core/po-web-components/src → src}/lib/hashlineHighlight.mjs +1 -1
- package/dist/src/lib/hashlineHighlight.mjs.map +1 -0
- package/dist/src/lib/hashlineView.cjs.map +1 -1
- package/dist/src/lib/hashlineView.d.mts.map +1 -0
- package/dist/src/lib/hashlineView.mjs.map +1 -0
- package/dist/src/lib/markdownMedia.cjs +2 -0
- package/dist/src/lib/markdownMedia.cjs.map +1 -0
- package/dist/src/lib/markdownMedia.d.mts +56 -0
- package/dist/src/lib/markdownMedia.d.mts.map +1 -0
- package/dist/src/lib/markdownMedia.mjs +2 -0
- package/dist/src/lib/markdownMedia.mjs.map +1 -0
- package/dist/src/lib/markdownMediaSlot.cjs +2 -0
- package/dist/src/lib/markdownMediaSlot.cjs.map +1 -0
- package/dist/src/lib/markdownMediaSlot.d.mts +10 -0
- package/dist/src/lib/markdownMediaSlot.d.mts.map +1 -0
- package/dist/src/lib/markdownMediaSlot.mjs +2 -0
- package/dist/src/lib/markdownMediaSlot.mjs.map +1 -0
- package/dist/src/lib/markdownReferences.cjs +2 -0
- package/dist/src/lib/markdownReferences.cjs.map +1 -0
- package/dist/src/lib/markdownReferences.mjs +2 -0
- package/dist/src/lib/markdownReferences.mjs.map +1 -0
- package/dist/src/lib/mcpAppFrame.cjs +3 -0
- package/dist/src/lib/mcpAppFrame.cjs.map +1 -0
- package/dist/src/lib/mcpAppFrame.d.mts +47 -0
- package/dist/src/lib/mcpAppFrame.d.mts.map +1 -0
- package/dist/src/lib/mcpAppFrame.mjs +3 -0
- package/dist/src/lib/mcpAppFrame.mjs.map +1 -0
- package/dist/src/lib/mcpAppSandbox.cjs +2 -0
- package/dist/src/lib/mcpAppSandbox.cjs.map +1 -0
- package/dist/src/lib/mcpAppSandbox.d.mts +19 -0
- package/dist/src/lib/mcpAppSandbox.d.mts.map +1 -0
- package/dist/src/lib/mcpAppSandbox.mjs +2 -0
- package/dist/src/lib/mcpAppSandbox.mjs.map +1 -0
- package/dist/src/lib/mcpOpenAiBootstrap.cjs +2 -0
- package/dist/src/lib/mcpOpenAiBootstrap.cjs.map +1 -0
- package/dist/src/lib/mcpOpenAiBootstrap.d.mts +32 -0
- package/dist/src/lib/mcpOpenAiBootstrap.d.mts.map +1 -0
- package/dist/src/lib/mcpOpenAiBootstrap.mjs +2 -0
- package/dist/src/lib/mcpOpenAiBootstrap.mjs.map +1 -0
- package/dist/src/lib/media.cjs.map +1 -1
- package/dist/src/lib/media.d.mts.map +1 -0
- package/dist/src/lib/media.mjs.map +1 -0
- package/dist/src/lib/mediaPlayback.cjs.map +1 -1
- package/dist/src/lib/mediaPlayback.mjs.map +1 -0
- package/dist/src/lib/mermaidDiagram.cjs +1 -1
- package/dist/src/lib/mermaidDiagram.cjs.map +1 -1
- package/dist/src/lib/mermaidDiagram.mjs +2 -0
- package/dist/src/lib/mermaidDiagram.mjs.map +1 -0
- package/dist/src/lib/optionList.cjs.map +1 -1
- package/dist/src/lib/optionList.d.mts.map +1 -0
- package/dist/src/lib/optionList.mjs.map +1 -0
- package/dist/src/lib/pathGroups.cjs.map +1 -1
- package/dist/src/lib/pathGroups.d.mts.map +1 -0
- package/dist/src/lib/pathGroups.mjs.map +1 -0
- package/dist/src/lib/picker.cjs +1 -1
- package/dist/src/lib/picker.cjs.map +1 -1
- package/dist/src/lib/picker.d.mts.map +1 -0
- package/dist/src/lib/picker.mjs +2 -0
- package/dist/src/lib/picker.mjs.map +1 -0
- package/dist/src/lib/profilePicker.cjs +2 -0
- package/dist/src/lib/profilePicker.cjs.map +1 -0
- package/dist/src/lib/profilePicker.d.mts +43 -0
- package/dist/src/lib/profilePicker.d.mts.map +1 -0
- package/dist/src/lib/profilePicker.mjs +2 -0
- package/dist/src/lib/profilePicker.mjs.map +1 -0
- package/dist/src/lib/qrMatrix.cjs +2 -0
- package/dist/src/lib/qrMatrix.cjs.map +1 -0
- package/dist/src/lib/qrMatrix.d.mts +5 -0
- package/dist/src/lib/qrMatrix.d.mts.map +1 -0
- package/dist/src/lib/qrMatrix.mjs +2 -0
- package/dist/src/lib/qrMatrix.mjs.map +1 -0
- package/dist/src/lib/review.cjs.map +1 -1
- package/dist/src/lib/review.d.mts.map +1 -0
- package/dist/src/lib/review.mjs.map +1 -0
- package/dist/src/lib/runDuration.cjs +2 -0
- package/dist/src/lib/runDuration.cjs.map +1 -0
- package/dist/src/lib/runDuration.d.mts +12 -0
- package/dist/src/lib/runDuration.d.mts.map +1 -0
- package/dist/src/lib/runDuration.mjs +2 -0
- package/dist/src/lib/runDuration.mjs.map +1 -0
- package/dist/src/lib/syntaxHighlight.cjs +1 -1
- package/dist/src/lib/syntaxHighlight.cjs.map +1 -1
- package/dist/{packages/core/po-web-components/src → src}/lib/syntaxHighlight.d.mts +6 -8
- package/dist/src/lib/syntaxHighlight.d.mts.map +1 -0
- package/dist/{packages/core/po-web-components/src → src}/lib/syntaxHighlight.mjs +1 -1
- package/dist/src/lib/syntaxHighlight.mjs.map +1 -0
- package/dist/src/lib/tone.cjs.map +1 -1
- package/dist/src/lib/tone.d.mts.map +1 -0
- package/dist/src/lib/tone.mjs.map +1 -0
- package/dist/src/theme/apply.cjs.map +1 -1
- package/dist/src/theme/apply.d.mts.map +1 -0
- package/dist/src/theme/apply.mjs.map +1 -0
- package/dist/src/theme/builtinThemes.cjs.map +1 -1
- package/dist/src/theme/builtinThemes.d.mts.map +1 -0
- package/dist/src/theme/builtinThemes.mjs.map +1 -0
- package/dist/src/theme/derive.cjs.map +1 -1
- package/dist/src/theme/derive.d.mts.map +1 -0
- package/dist/src/theme/derive.mjs.map +1 -0
- package/dist/src/theme/nativeTheme.cjs.map +1 -1
- package/dist/src/theme/nativeTheme.d.mts.map +1 -0
- package/dist/src/theme/nativeTheme.mjs.map +1 -0
- package/dist/src/theme/parse.cjs.map +1 -1
- package/dist/src/theme/parse.d.mts.map +1 -0
- package/dist/src/theme/parse.mjs.map +1 -0
- package/dist/src/theme/piTheme.cjs.map +1 -1
- package/dist/src/theme/piTheme.d.mts.map +1 -0
- package/dist/src/theme/piTheme.mjs.map +1 -0
- package/dist/src/theme/preference.cjs.map +1 -1
- package/dist/src/theme/preference.d.mts.map +1 -0
- package/dist/src/theme/preference.mjs.map +1 -0
- package/dist/src/types/diff.d.mts.map +1 -0
- package/dist/src/types/editor.cjs.map +1 -1
- package/dist/src/types/editor.d.mts.map +1 -0
- package/dist/src/types/editor.mjs.map +1 -0
- package/dist/src/types/theme.cjs.map +1 -1
- package/dist/src/types/theme.d.mts.map +1 -0
- package/dist/src/types/theme.mjs.map +1 -0
- package/dist/src/types/tone.cjs.map +1 -1
- package/dist/src/types/tone.d.mts.map +1 -0
- package/dist/src/types/tone.mjs.map +1 -0
- package/dist/text.cjs +1 -1
- package/dist/text.d.mts +13 -4
- package/dist/text.mjs +1 -1
- package/dist/theme.d.mts +7 -7
- package/dist/theme.mjs +1 -1
- package/dist/themes/po-nord-dark.cjs +1 -1
- package/dist/{packages/core/po-web-components/themes → themes}/po-nord-dark.mjs +1 -1
- package/dist/{packages/core/po-web-components/themes → themes}/po-nord-dark.mjs.map +1 -1
- package/dist/{packages/core/po-web-components/themes → themes}/po-one-light.mjs.map +1 -1
- package/locales/vi.json +168 -0
- package/locales/zh-CN.json +168 -0
- package/package.json +30 -11
- package/styles/theme.css +23 -0
- package/themes/po-nord-dark.json +1 -1
- package/dist/node_modules/.pnpm/@modelcontextprotocol_server@2.3.1/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-D4NN8WsG.d.mts +0 -26
- package/dist/node_modules/.pnpm/@modelcontextprotocol_server@2.3.1/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-D4NN8WsG.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/@modelcontextprotocol_server@2.3.1/node_modules/@modelcontextprotocol/server/dist/index.d.mts +0 -2
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/compat.d.mts +0 -8
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/compat.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/errors.d.mts +0 -21
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/errors.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/parse.d.mts +0 -15
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/parse.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/schemas.d.mts +0 -169
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/schemas.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/api.d.mts +0 -38
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/api.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/checks.d.mts +0 -63
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/checks.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/core.d.mts +0 -50
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/core.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/errors.d.mts +0 -135
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/errors.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/json-schema.d.mts +0 -70
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/json-schema.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/registries.d.mts +0 -31
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/registries.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/schemas.d.mts +0 -806
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/schemas.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/standard-schema.d.mts +0 -120
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/standard-schema.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/to-json-schema.d.mts +0 -128
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/to-json-schema.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/util.d.mts +0 -38
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/util.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/versions.d.mts +0 -8
- package/dist/node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/versions.d.mts.map +0 -1
- package/dist/packages/core/po-core/dist/mcpWidget.d.mts +0 -2
- package/dist/packages/core/po-core/dist/src/extensions/webPlugin.d.mts +0 -2
- package/dist/packages/core/po-core/dist/src/web/models/globalStore.d.mts +0 -1
- package/dist/packages/core/po-core/dist/src/web/models/sessionStore.d.mts +0 -1
- package/dist/packages/core/po-core/dist/src/web/models/workspaceStore.d.mts +0 -1
- package/dist/packages/core/po-core/dist/src/web/schemas/template.d.mts +0 -2
- package/dist/packages/core/po-core/dist/src/web/services/mcpWidget.d.mts +0 -1
- package/dist/packages/core/po-core/dist/src/web/types/extensionFile.d.mts +0 -3
- package/dist/packages/core/po-core/dist/src/web/types/mcpWidget.d.mts +0 -17
- package/dist/packages/core/po-core/dist/src/web/types/mcpWidget.d.mts.map +0 -1
- package/dist/packages/core/po-core/dist/src/web/types/nativeTemplate.d.mts +0 -2
- package/dist/packages/core/po-core/dist/src/web/types/template.d.mts +0 -1
- package/dist/packages/core/po-core/dist/src/web/types/webPlugin.d.mts +0 -3
- package/dist/packages/core/po-core/dist/web.d.mts +0 -12
- package/dist/packages/core/po-web-components/src/components/Accordion.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Accordion.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/AgentAvatar.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/AgentAvatar.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/AgentAvatar.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/AnsiText.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/AnsiText.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Avatar.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Avatar.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Badge.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Badge.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Breadcrumb.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Breadcrumb.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Button.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Button.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Checkbox.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Checkbox.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/CodeBlock.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/CodeBlock.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/CodeEditor.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/CodeEditor.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/CodeEditorView.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Collapsible.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Collapsible.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Command.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Command.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/CopyButton.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/CopyButton.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Dialog.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Dialog.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/Dialog.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/DiffView.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/DiffView.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/DiffView.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Dot.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Dot.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Drawer.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Drawer.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/DropdownMenu.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/DropdownMenu.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/EmptyState.d.mts +0 -17
- package/dist/packages/core/po-web-components/src/components/EmptyState.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/EmptyState.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/EmptyState.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/HashlineLines.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/HashlineLines.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/HashlineLines.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Input.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Input.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/Input.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Kbd.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Kbd.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Label.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Label.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Markdown.d.mts +0 -23
- package/dist/packages/core/po-web-components/src/components/Markdown.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Markdown.mjs +0 -3
- package/dist/packages/core/po-web-components/src/components/Markdown.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/McpApp.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/McpApp.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/McpApp.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/McpToolWidget.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/McpToolWidget.mjs +0 -3
- package/dist/packages/core/po-web-components/src/components/McpToolWidget.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MediaPreview.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MediaPreview.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/MediaPreview.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MermaidDiagram.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/MermaidDiagram.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MessageItem.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MessageItem.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/MessageItem.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MessageLines.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/MessageLines.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/OptionList.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/OptionList.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/OptionList.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Panel.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Panel.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/PdfPreview.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/PdfPreview.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/PdfPreview.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Picker.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Picker.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/Picker.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Popover.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Popover.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Progress.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Progress.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/RadioGroup.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/RadioGroup.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/ReviewCommentDraft.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/ReviewCommentDraft.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/ReviewCommentDraft.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/ScrollArea.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/ScrollArea.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/SectionLabel.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/SectionLabel.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Select.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Select.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Separator.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Separator.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Settings.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Settings.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Sheet.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Sheet.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/Sheet.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Skeleton.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Skeleton.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Spinner.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Spinner.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/StatusBadge.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/StatusBadge.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/StreamCursor.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/StreamCursor.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Switch.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Switch.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/SyntaxText.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/SyntaxText.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Tabs.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Tabs.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/Tabs.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/TerminalView.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/TerminalView.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Textarea.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Textarea.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Toast.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Toast.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/Toast.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/ToolPathLink.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/ToolPathLink.mjs +0 -2
- package/dist/packages/core/po-web-components/src/components/ToolPathLink.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Tooltip.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/components/Tooltip.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/icons/icons.d.mts +0 -2
- package/dist/packages/core/po-web-components/src/icons/icons.mjs +0 -1
- package/dist/packages/core/po-web-components/src/lib/ansiSpans.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/ansiSpans.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/cn.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/cn.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/collapse.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/collapse.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/editorController.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/editorLanguage.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/editorLanguage.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/editorTheme.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/editorTheme.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/fenceGrammar.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/hashlineHighlight.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/hashlineHighlight.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/hashlineView.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/hashlineView.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/media.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/media.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/mediaPlayback.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/mermaidDiagram.mjs +0 -2
- package/dist/packages/core/po-web-components/src/lib/mermaidDiagram.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/optionList.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/optionList.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/pathGroups.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/pathGroups.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/picker.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/picker.mjs +0 -2
- package/dist/packages/core/po-web-components/src/lib/picker.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/review.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/review.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/syntaxHighlight.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/syntaxHighlight.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/tone.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/lib/tone.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/apply.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/apply.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/builtinThemes.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/builtinThemes.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/derive.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/derive.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/nativeTheme.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/nativeTheme.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/parse.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/parse.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/piTheme.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/piTheme.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/preference.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/theme/preference.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/types/diff.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/types/editor.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/types/editor.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/types/theme.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/types/theme.mjs.map +0 -1
- package/dist/packages/core/po-web-components/src/types/tone.d.mts.map +0 -1
- package/dist/packages/core/po-web-components/src/types/tone.mjs.map +0 -1
- /package/dist/{packages/core/po-web-components/src → src}/components/Accordion.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Accordion.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/AnsiText.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/AnsiText.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Avatar.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Avatar.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Badge.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Badge.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Breadcrumb.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Breadcrumb.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Button.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Button.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Checkbox.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Checkbox.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/CodeBlock.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/CodeBlock.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/CodeEditor.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/CodeEditor.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/CodeEditorView.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Collapsible.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Collapsible.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Command.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Command.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Dialog.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/DiffView.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Dot.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Dot.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Drawer.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Drawer.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/DropdownMenu.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/HashlineLines.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Input.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Kbd.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Kbd.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Label.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Label.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/MediaPreview.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/MessageLines.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/MessageLines.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/OptionList.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Panel.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Panel.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/PdfPreview.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Popover.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Popover.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Progress.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Progress.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/RadioGroup.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/RadioGroup.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/ReviewCommentDraft.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/ScrollArea.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/ScrollArea.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/SectionLabel.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Select.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Select.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Separator.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Separator.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Settings.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Settings.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Sheet.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Skeleton.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Skeleton.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Spinner.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Spinner.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/StatusBadge.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/StatusBadge.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/StreamCursor.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/StreamCursor.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Switch.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Switch.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/SyntaxText.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/TerminalView.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/TerminalView.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Textarea.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Textarea.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Toast.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/ToolPathLink.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Tooltip.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/components/Tooltip.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/ansiSpans.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/ansiSpans.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/cn.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/cn.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/collapse.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/collapse.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/editorController.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/editorLanguage.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/editorLanguage.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/editorTheme.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/editorTheme.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/fenceGrammar.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/hashlineHighlight.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/hashlineView.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/hashlineView.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/media.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/media.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/mediaPlayback.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/optionList.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/optionList.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/pathGroups.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/pathGroups.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/picker.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/review.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/review.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/tone.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/lib/tone.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/apply.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/apply.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/builtinThemes.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/builtinThemes.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/derive.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/derive.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/nativeTheme.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/nativeTheme.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/parse.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/parse.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/piTheme.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/piTheme.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/preference.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/theme/preference.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/diff.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/editor.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/editor.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/theme.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/theme.mjs +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/tone.d.mts +0 -0
- /package/dist/{packages/core/po-web-components/src → src}/types/tone.mjs +0 -0
- /package/dist/{packages/core/po-web-components/themes → themes}/po-one-light.mjs +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpAppSandbox.mjs","names":["LOOPBACK_HOSTNAME","record","value","origins","domain","parsed","hostname","wildcard","host","hostOrigin","loopback","includesHost","mcpAppCsp","meta","metadata","ui","standard","raw","csp","resource","connect","frame","escapeAttribute","mcpAppHostTheme","message","data","theme","widgetThemeBootstrap","root","initial","changed","settle","follow","current","next","event","hostTheme","relayBootstrap","configured","config","port","inner","loaded","revoked","revoke","messageWindow","messageCount","childEvent","encoded","now","openai","hostEvent","mcpAppRelayHtml","policy","sources","kind","mcpAppDocument","themeScript","bootstrap","html","supportsMcpAppSandbox"],"sources":["../../../src/lib/mcpAppSandbox.ts"],"sourcesContent":["const MAX_CSP_DOMAINS = 64;\nconst MAX_DOMAIN_LENGTH = 2048;\nconst LOOPBACK_HOSTNAME = /^(localhost|127(\\.\\d{1,3}){3}|\\[::1\\])$/u;\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\n/** Accept origins only, never CSP tokens, URL paths, credentials, or the host origin. */\nfunction origins(value: unknown, hostOrigin: string): string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > MAX_CSP_DOMAINS) throw new Error('Invalid widget CSP domains');\n return value.map((domain: unknown) => {\n if (typeof domain !== 'string' || domain.length > MAX_DOMAIN_LENGTH) throw new Error('Invalid widget CSP domain');\n const parsed = new URL(domain);\n // Browsers percent-encode a wildcard label (`*.` becomes `%2A.`), which CSP ignores as an invalid source.\n const hostname = parsed.hostname.replace(/^%2a\\./iu, '*.');\n const wildcard = hostname.startsWith('*.');\n const host = new URL(hostOrigin);\n // Local dev servers serve widgets over plain HTTP on loopback; Po's own loopback origin stays excluded.\n const loopback = LOOPBACK_HOSTNAME.test(parsed.hostname);\n const includesHost = loopback\n ? LOOPBACK_HOSTNAME.test(host.hostname) && parsed.port === host.port\n : hostname === host.hostname || (wildcard && host.hostname.endsWith(hostname.slice(1)));\n if (\n !(loopback ? ['http:', 'https:', 'ws:', 'wss:'] : ['https:', 'wss:']).includes(parsed.protocol) ||\n parsed.username ||\n parsed.password ||\n parsed.pathname !== '/' ||\n parsed.search ||\n parsed.hash ||\n includesHost ||\n parsed.hostname.startsWith('0.') ||\n /[\\s;'\"<>]/u.test(domain)\n )\n throw new Error('Unsafe widget CSP domain');\n return `${parsed.protocol}//${hostname}${parsed.port ? `:${parsed.port}` : ''}`;\n });\n}\n\nexport function mcpAppCsp(metadata: unknown, hostOrigin: string): string {\n const meta = record(metadata);\n const ui = record(meta?.ui);\n if (meta?.ui !== undefined && ui === undefined) throw new Error('Invalid widget UI metadata');\n // A present standard field always wins, including malformed values (fail closed).\n const standard = ui !== undefined && 'csp' in ui;\n const raw = standard ? ui.csp : meta?.['openai/widgetCSP'];\n const csp = raw === undefined ? {} : record(raw);\n if (csp === undefined) throw new Error('Invalid widget CSP');\n const resource = origins(csp[standard ? 'resourceDomains' : 'resource_domains'], hostOrigin).join(' ');\n const connect = origins(csp[standard ? 'connectDomains' : 'connect_domains'], hostOrigin).join(' ');\n const frame = origins(csp[standard ? 'frameDomains' : 'frame_domains'], hostOrigin).join(' ');\n // Nested frames load only from declared frame domains; forms, base URLs, workers and navigation privileges are not admitted.\n return [\n \"default-src 'none'\",\n `script-src 'unsafe-inline' ${resource}`,\n `style-src 'unsafe-inline' ${resource}`,\n `img-src data: blob: ${resource}`,\n `font-src data: ${resource}`,\n `media-src blob: ${resource}`,\n `connect-src ${connect || \"'none'\"}`,\n `frame-src ${frame || \"'none'\"}`,\n `child-src ${frame || \"'none'\"}`,\n \"worker-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n ].join('; ');\n}\n\nfunction escapeAttribute(value: string): string {\n return value.replaceAll('&', '&').replaceAll('\"', '"').replaceAll('<', '<');\n}\n\ntype HostTheme = 'light' | 'dark';\n\n/** The theme a host message carries, from either bridge. Serialized into frames, so it stays self-contained. */\nexport function mcpAppHostTheme(data: unknown): HostTheme | undefined {\n const message = data as {\n channel?: unknown;\n globals?: { theme?: unknown } | null;\n jsonrpc?: unknown;\n method?: unknown;\n params?: { theme?: unknown } | null;\n } | null;\n const theme =\n message?.channel === 'po.openai'\n ? message.globals?.theme\n : message?.jsonrpc === '2.0' && message.method === 'ui/notifications/host-context-changed'\n ? message.params?.theme\n : undefined;\n return theme === 'light' || theme === 'dark' ? theme : undefined;\n}\n\n/**\n * Bundled trusted code, runs inside the App document. Waits for the App's own\n * <html> attributes, which the parser merges only where the root has none, so\n * an App-chosen class or data-theme wins until the host theme changes.\n */\nexport function widgetThemeBootstrap(hostTheme: (data: unknown) => HostTheme | undefined, initial: HostTheme): void {\n const root = document.documentElement;\n let theme = initial;\n let changed = false;\n const settle = (): void => {\n if (!root.classList.contains('light') && !root.classList.contains('dark')) root.classList.add(theme);\n if (root.getAttribute('data-theme') === null) root.setAttribute('data-theme', theme);\n };\n const follow = (): void => {\n root.classList.remove('light', 'dark');\n root.classList.add(theme);\n const current = root.getAttribute('data-theme');\n if (current === null || current === 'light' || current === 'dark') root.setAttribute('data-theme', theme);\n root.style.colorScheme = theme;\n };\n window.addEventListener('message', (event: MessageEvent<unknown>) => {\n const next = event.source === parent ? hostTheme(event.data) : undefined;\n if (next === undefined) return;\n theme = next;\n changed = true;\n if (document.readyState !== 'loading') follow();\n });\n if (document.readyState !== 'loading') settle();\n else\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'interactive') {\n if (changed) follow();\n else settle();\n }\n });\n}\n\n/** Bundled trusted code, runs in an opaque relay separate from the untrusted App. */\nexport function relayBootstrap(hostTheme: (data: unknown) => HostTheme | undefined): void {\n let configured = false;\n // The relay canvas must match the App's color scheme or the browser paints it opaque.\n const follow = (data: unknown): void => {\n const theme = hostTheme(data);\n if (theme !== undefined) document.documentElement.style.colorScheme = theme;\n };\n window.addEventListener('message', (event: MessageEvent<unknown>) => {\n if (event.source !== parent || configured || event.ports.length !== 1) return;\n const config = event.data as { html: string; policy: string; protocol: string };\n if (typeof config?.html !== 'string' || typeof config.policy !== 'string') return;\n configured = true;\n const port = event.ports[0]!;\n const inner = document.createElement('iframe');\n inner.title = 'MCP App content';\n inner.setAttribute('sandbox', 'allow-scripts');\n // Required CSP also binds nested frames, so an App with declared frame domains relies on the inherited relay\n // policy instead: MCP Apps let those frames keep their own CSP, and the relay revokes any second document.\n if (config.policy.includes(\"frame-src 'none'\")) inner.setAttribute('csp', config.policy);\n inner.setAttribute(\n 'allow',\n \"camera 'none'; microphone 'none'; geolocation 'none'; clipboard-read 'none'; clipboard-write 'none'\",\n );\n inner.style.cssText = 'width:100%;height:100%;border:0;display:block';\n let loaded = false;\n let revoked = false;\n const revoke = (): void => {\n if (revoked) return;\n revoked = true;\n inner.remove();\n port.postMessage({ type: 'revoked' });\n port.close();\n };\n inner.addEventListener('load', () => {\n if (loaded) revoke();\n loaded = true;\n });\n let messageWindow = Date.now();\n let messageCount = 0;\n window.addEventListener('message', (childEvent: MessageEvent<unknown>) => {\n if (revoked || childEvent.source !== inner.contentWindow) return;\n try {\n const encoded = JSON.stringify(childEvent.data);\n if (encoded === undefined || new TextEncoder().encode(encoded).byteLength > 65536) return revoke();\n const now = Date.now();\n if (now - messageWindow >= 1000) {\n messageWindow = now;\n messageCount = 0;\n }\n if (++messageCount > 128) return revoke();\n } catch {\n return revoke();\n }\n // window.openai is in every App, so its channel reaches the host port whatever the protocol.\n const openai = (childEvent.data as { channel?: unknown } | null)?.channel === 'po.openai';\n if (config.protocol === 'mcp' && !openai) parent.postMessage(childEvent.data, '*');\n else port.postMessage({ type: 'legacy', data: childEvent.data });\n });\n // The parent alone owns the other end of this channel. No origin-based trust.\n port.onmessage = (hostEvent: MessageEvent<unknown>) => {\n if (revoked) return;\n follow(hostEvent.data);\n inner.contentWindow?.postMessage(hostEvent.data, '*');\n };\n window.addEventListener('message', (hostEvent: MessageEvent<unknown>) => {\n if (!revoked && hostEvent.source === parent && config.protocol === 'mcp') {\n const data = hostEvent.data as { jsonrpc?: string } | null;\n if (data?.jsonrpc !== '2.0') return;\n follow(data);\n inner.contentWindow?.postMessage(data, '*');\n }\n });\n port.start();\n inner.srcdoc = config.html;\n document.body.append(inner);\n port.postMessage({ type: 'ready' });\n });\n}\n\nexport function mcpAppRelayHtml(policy: string, theme: HostTheme = 'light'): string {\n // frame-src adds srcdoc/about for the App frame, never a host route or a remote sandbox URL. The App's\n // declared frame domains stay, because the srcdoc App inherits this policy for its own nested frames.\n const relayPolicy = policy.replace(/\\b(frame|child)-src ([^;]*)/gu, (_, kind: string, sources: string) =>\n sources === \"'none'\" ? `${kind}-src about:` : `${kind}-src about: ${sources}`,\n );\n return `<!doctype html><html style=\"color-scheme:${theme}\"><meta http-equiv=\"Content-Security-Policy\" content=\"${escapeAttribute(relayPolicy)}\"><style>html,body{margin:0;height:100%;overflow:hidden}</style><script>(${relayBootstrap.toString()})(${mcpAppHostTheme.toString()})</script>`;\n}\n\n/** No host <html> is injected, so the App's own root attributes survive parsing. */\nexport function mcpAppDocument(html: string, policy: string, bootstrap = '', theme: HostTheme = 'light'): string {\n const themeScript = `<script>(${widgetThemeBootstrap.toString()})(${mcpAppHostTheme.toString()}, ${JSON.stringify(theme)})</script>`;\n return `<!doctype html><meta http-equiv=\"Content-Security-Policy\" content=\"${escapeAttribute(policy)}\"><meta name=\"color-scheme\" content=\"${theme}\">${themeScript}${bootstrap}${html}`;\n}\n\n/** Required CSP enforcement must survive self-navigation, not only initial srcdoc. */\nexport function supportsMcpAppSandbox(host: Document | HTMLIFrameElement): boolean {\n const frame = 'createElement' in host ? host.createElement('iframe') : host;\n return 'csp' in frame;\n}\n"],"mappings":"AAAA,MAEMA,EAAoB,2CAE1B,SAASC,EAAO,EAAqD,CACnE,OAAyB,OAAOC,GAAU,UAAnCA,GAA+C,CAAC,MAAM,QAAQA,CAAK,EACrEA,EACD,IAAA,EACN,CAGA,SAASC,EAAQ,EAAgB,EAA8B,CAC7D,GAAID,IAAU,IAAA,GAAW,MAAO,CAAC,EACjC,GAAI,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,OAAS,GAAiB,MAAU,MAAM,4BAA4B,EACzG,OAAOA,EAAM,IAAK,GAAoB,CACpC,GAAI,OAAOE,GAAW,UAAYA,EAAO,OAAS,KAAmB,MAAU,MAAM,2BAA2B,EAChH,IAAMC,EAAS,IAAI,IAAID,CAAM,EAEvBE,EAAWD,EAAO,SAAS,QAAQ,WAAY,IAAI,EACnDE,EAAWD,EAAS,WAAW,IAAI,EACnCE,EAAO,IAAI,IAAIC,CAAU,EAEzBC,EAAWV,EAAkB,KAAKK,EAAO,QAAQ,EACjDM,EAAeD,EACjBV,EAAkB,KAAKQ,EAAK,QAAQ,GAAKH,EAAO,OAASG,EAAK,KAC9DF,IAAaE,EAAK,UAAaD,GAAYC,E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,CAGA,SAAgBC,EAAsB,EAA6C,CAEjF,MAAO,QADO,kBAAmBpD,EAAOA,EAAK,cAAc,QAAQ,EAAIA,EAEzE,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=`po.openai`,n=/* @__PURE__ */ new Map,r=0,i=e,a=e=>{i={...i,...e},window.dispatchEvent(new CustomEvent(`openai:set_globals`,{detail:{globals:e}}))},o=(e,i)=>{if(n.size>=32)return Promise.reject(/* @__PURE__ */ Error(`Too many pending widget requests`));let a=++r;return new Promise((r,o)=>{let s=window.setTimeout(()=>{n.delete(a),o(/* @__PURE__ */ Error(`Widget request timed out`))},6e4);n.set(a,{resolve:r,reject:o,timer:s}),parent.postMessage({channel:t,id:a,method:e,input:i},`*`)})};Object.defineProperty(window,"openai",{value:Object.freeze({get toolInput(){return i.toolInput},get toolOutput(){return i.toolOutput},get toolResponseMetadata(){return i.toolResponseMetadata},get widgetState(){return i.widgetState},get theme(){return i.theme},get locale(){return i.locale},get displayMode(){return i.displayMode},get maxHeight(){return i.maxHeight},get safeArea(){return i.safeArea},get userAgent(){return i.userAgent},callTool:(e,t={})=>o(`callTool`,{name:e,arguments:t}),setWidgetState:e=>(a({widgetState:e}),o(`setState`,{state:e})),sendFollowUpMessage:e=>o(`followUp`,e),requestDisplayMode:()=>Promise.resolve({mode:`inline`}),openExternal:e=>o(`openLink`,{url:e.href}),requestClose:()=>o(`close`,{}),notifyIntrinsicHeight:e=>o(`height`,{height:e})}),configurable:!1,writable:!1}),window.addEventListener(`message`,e=>{if(e.source!==parent)return;let r=e.data;if(r?.channel!==t||(r.globals!==void 0&&a(r.globals),r.id===void 0))return;let i=n.get(r.id);i!==void 0&&(n.delete(r.id),clearTimeout(i.timer),typeof r.error==`string`?i.reject(Error(r.error)):i.resolve(r.result))}),parent.postMessage({channel:t,method:`initialized`,input:{}},`*`),document.addEventListener(`DOMContentLoaded`,()=>{a(i);let e=new ResizeObserver(()=>{let e=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);parent.postMessage({channel:t,method:`height`,input:{height:e}},`*`)});e.observe(document.body),window.addEventListener(`pagehide`,()=>e.disconnect(),{once:!0})},{once:!0})}function t(t){let n=JSON.stringify(t).replaceAll(`<`,`\\u003c`).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`);return`<script>(${e.toString()})(${n})<\/script>`}exports.bootstrap=e,exports.mcpOpenAiScript=t;
|
|
2
|
+
//# sourceMappingURL=mcpOpenAiBootstrap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpOpenAiBootstrap.cjs","names":["bootstrap","channel","pending","sequence","globals","initial","update","patch","request","id","timer","reject","args","state","input","event","message","callback","observer","height","mcpOpenAiScript","encoded"],"sources":["../../../src/lib/mcpOpenAiBootstrap.ts"],"sourcesContent":["interface LegacyGlobals {\n toolInput: Record<string, unknown>;\n toolOutput: unknown;\n toolResponseMetadata: Record<string, unknown>;\n widgetState: unknown;\n theme: 'light' | 'dark';\n locale: string;\n displayMode: 'inline';\n maxHeight: number;\n userAgent: { device: { type: 'desktop' | 'mobile' }; capabilities: { hover: boolean; touch: boolean } };\n safeArea: { insets: { top: number; right: number; bottom: number; left: number } };\n}\n\nexport function bootstrap(initial: LegacyGlobals): void {\n const channel = 'po.openai';\n const requestTimeout = 60_000;\n const pending = new Map<number, { resolve(value: unknown): void; reject(error: Error): void; timer: number }>();\n let sequence = 0;\n let globals = initial;\n const update = (patch: Partial<LegacyGlobals>): void => {\n globals = { ...globals, ...patch };\n window.dispatchEvent(new CustomEvent('openai:set_globals', { detail: { globals: patch } }));\n };\n const request = (method: string, input: unknown): Promise<unknown> => {\n if (pending.size >= 32) return Promise.reject(new Error('Too many pending widget requests'));\n const id = ++sequence;\n return new Promise((resolve, reject) => {\n const timer = window.setTimeout(() => {\n pending.delete(id);\n reject(new Error('Widget request timed out'));\n }, requestTimeout);\n pending.set(id, { resolve, reject, timer });\n parent.postMessage({ channel, id, method, input }, '*');\n });\n };\n const api = {\n get toolInput() {\n return globals.toolInput;\n },\n get toolOutput() {\n return globals.toolOutput;\n },\n get toolResponseMetadata() {\n return globals.toolResponseMetadata;\n },\n get widgetState() {\n return globals.widgetState;\n },\n get theme() {\n return globals.theme;\n },\n get locale() {\n return globals.locale;\n },\n get displayMode() {\n return globals.displayMode;\n },\n get maxHeight() {\n return globals.maxHeight;\n },\n get safeArea() {\n return globals.safeArea;\n },\n get userAgent() {\n return globals.userAgent;\n },\n callTool: (name: string, args: Record<string, unknown> = {}) => request('callTool', { name, arguments: args }),\n setWidgetState: (state: unknown) => {\n // Immediate local state, with await-compatible durable persistence.\n update({ widgetState: state });\n return request('setState', { state });\n },\n sendFollowUpMessage: (input: { prompt: string }) => request('followUp', input),\n requestDisplayMode: () => Promise.resolve({ mode: 'inline' }),\n openExternal: (input: { href: string }) => request('openLink', { url: input.href }),\n requestClose: () => request('close', {}),\n notifyIntrinsicHeight: (height: number) => request('height', { height }),\n };\n Object.defineProperty(window, 'openai', { value: Object.freeze(api), configurable: false, writable: false });\n window.addEventListener('message', (event: MessageEvent<unknown>) => {\n if (event.source !== parent) return;\n const message = event.data as {\n channel?: string;\n id?: number;\n error?: string;\n result?: unknown;\n globals?: Partial<LegacyGlobals>;\n };\n if (message?.channel !== channel) return;\n if (message.globals !== undefined) update(message.globals);\n if (message.id === undefined) return;\n const callback = pending.get(message.id);\n if (callback === undefined) return;\n pending.delete(message.id);\n clearTimeout(callback.timer);\n if (typeof message.error === 'string') callback.reject(new Error(message.error));\n else callback.resolve(message.result);\n });\n parent.postMessage({ channel, method: 'initialized', input: {} }, '*');\n document.addEventListener(\n 'DOMContentLoaded',\n () => {\n update(globals);\n const observer = new ResizeObserver(() => {\n const height = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);\n parent.postMessage({ channel, method: 'height', input: { height } }, '*');\n });\n observer.observe(document.body);\n window.addEventListener('pagehide', () => observer.disconnect(), { once: true });\n },\n { once: true },\n );\n}\n\nexport function mcpOpenAiScript(globals: LegacyGlobals): string {\n const encoded = JSON.stringify(globals)\n .replaceAll('<', '\\\\u003c')\n .replaceAll('\\u2028', '\\\\u2028')\n .replaceAll('\\u2029', '\\\\u2029');\n return `<script>(${bootstrap.toString()})(${encoded})</script>`;\n}\n"],"mappings":"AAaA,SAAgBA,EAAU,EAA8B,CACtD,IAAMC,EAAU,YAEVC,kBAAU,IAAI,IAChBC,EAAW,EACXC,EAAUC,EACRC,EAAU,GAAwC,CACtD,EAAU,CAAE,GAAGF,EAAS,GAAGG,CAAM,EACjC,OAAO,cAAc,IAAI,YAAY,qBAAsB,CAAE,OAAQ,CAAE,QAASA,CAAM,CAAE,CAAC,CAAC,CAC5F,EACMC,GAAW,EAAgB,IAAqC,CACpE,GAAIN,EAAQ,MAAQ,GAAI,OAAO,QAAQ,OAAO,gBAAI,MAAM,kCAAkC,CAAC,EAC3F,IAAMO,EAAK,EAAEN,EACb,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAMO,EAAQ,OAAO,eAAiB,CACpCR,EAAQ,OAAOO,CAAE,EACjBE,EAAO,gBAAI,MAAM,0BAA0B,CAAC,CAC9C,EAAG,GAAc,EACjBT,EAAQ,IAAIO,EAAI,CAAE,UAAS,SAAQ,OAAM,CAAC,EAC1C,OAAO,YAAY,CAAE,UAAS,KAAI,SAAQ,OAAM,EAAG,GAAG,CACxD,CAAC,CACH,EA4CA,OAAO,eAAe,OAAQ,SAAU,CAAE,MAAO,OAAO,OAAO,CA1C7D,IAAI,WAAY,CACd,OAAOL,EAAQ,SACjB,EACA,IAAI,YAAa,CACf,OAAOA,EAAQ,UACjB,EACA,IAAI,sBAAuB,CACzB,OAAOA,EAAQ,oBACjB,EACA,IAAI,aAAc,CAChB,OAAOA,EAAQ,WACjB,EACA,IAAI,OAAQ,CACV,OAAOA,EAAQ,KACjB,EACA,IAAI,QAAS,CACX,OAAOA,EAAQ,MACjB,EACA,IAAI,aAAc,CAChB,OAAOA,EAAQ,WACjB,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AK,IAAI,SAAS,KAAK,aAAc,SAAS,gBAAgB,YAAY,EACzF,OAAO,YAAY,CAAE,UAAS,OAAQ,SAAU,MAAO,CAAE,QAAO,CAAE,EAAG,GAAG,CAC1E,CAAC,EACDD,EAAS,QAAQ,SAAS,IAAI,EAC9B,OAAO,iBAAiB,eAAkBA,EAAS,WAAW,EAAG,CAAE,KAAM,EAAK,CAAC,CACjF,EACA,CAAE,KAAM,EAAK,CACf,CACF,CAEA,SAAgBE,EAAgB,EAAgC,CAC9D,IAAMC,EAAU,KAAK,UAAUjB,CAAO,CAAC,CACpC,WAAW,IAAK,SAAS,CAAC,CAC1B,WAAW,SAAU,SAAS,CAAC,CAC/B,WAAW,SAAU,SAAS,EACjC,MAAO,YAAYJ,EAAU,SAAS,EAAE,IAAIqB,EAAQ,YACtD,C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/lib/mcpOpenAiBootstrap.d.ts
|
|
2
|
+
interface LegacyGlobals {
|
|
3
|
+
toolInput: Record<string, unknown>;
|
|
4
|
+
toolOutput: unknown;
|
|
5
|
+
toolResponseMetadata: Record<string, unknown>;
|
|
6
|
+
widgetState: unknown;
|
|
7
|
+
theme: 'light' | 'dark';
|
|
8
|
+
locale: string;
|
|
9
|
+
displayMode: 'inline';
|
|
10
|
+
maxHeight: number;
|
|
11
|
+
userAgent: {
|
|
12
|
+
device: {
|
|
13
|
+
type: 'desktop' | 'mobile';
|
|
14
|
+
};
|
|
15
|
+
capabilities: {
|
|
16
|
+
hover: boolean;
|
|
17
|
+
touch: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
safeArea: {
|
|
21
|
+
insets: {
|
|
22
|
+
top: number;
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
left: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function mcpOpenAiScript(globals: LegacyGlobals): string;
|
|
30
|
+
//#endregion
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=mcpOpenAiBootstrap.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpOpenAiBootstrap.d.mts","names":[],"sources":["../../../src/lib/mcpOpenAiBootstrap.ts"],"mappings":";UAAU;EACR,WAAW;EACX;EACA,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;IAAa;MAAU;;IAA8B;MAAgB;MAAgB;;;EACrF;IAAY;MAAU;MAAa;MAAe;MAAgB;;;;wBAwGpD,gBAAgB,SAAS"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=`po.openai`,n=/* @__PURE__ */ new Map,r=0,i=e,a=e=>{i={...i,...e},window.dispatchEvent(new CustomEvent(`openai:set_globals`,{detail:{globals:e}}))},o=(e,i)=>{if(n.size>=32)return Promise.reject(/* @__PURE__ */ Error(`Too many pending widget requests`));let a=++r;return new Promise((r,o)=>{let s=window.setTimeout(()=>{n.delete(a),o(/* @__PURE__ */ Error(`Widget request timed out`))},6e4);n.set(a,{resolve:r,reject:o,timer:s}),parent.postMessage({channel:t,id:a,method:e,input:i},`*`)})};Object.defineProperty(window,"openai",{value:Object.freeze({get toolInput(){return i.toolInput},get toolOutput(){return i.toolOutput},get toolResponseMetadata(){return i.toolResponseMetadata},get widgetState(){return i.widgetState},get theme(){return i.theme},get locale(){return i.locale},get displayMode(){return i.displayMode},get maxHeight(){return i.maxHeight},get safeArea(){return i.safeArea},get userAgent(){return i.userAgent},callTool:(e,t={})=>o(`callTool`,{name:e,arguments:t}),setWidgetState:e=>(a({widgetState:e}),o(`setState`,{state:e})),sendFollowUpMessage:e=>o(`followUp`,e),requestDisplayMode:()=>Promise.resolve({mode:`inline`}),openExternal:e=>o(`openLink`,{url:e.href}),requestClose:()=>o(`close`,{}),notifyIntrinsicHeight:e=>o(`height`,{height:e})}),configurable:!1,writable:!1}),window.addEventListener(`message`,e=>{if(e.source!==parent)return;let r=e.data;if(r?.channel!==t||(r.globals!==void 0&&a(r.globals),r.id===void 0))return;let i=n.get(r.id);i!==void 0&&(n.delete(r.id),clearTimeout(i.timer),typeof r.error==`string`?i.reject(Error(r.error)):i.resolve(r.result))}),parent.postMessage({channel:t,method:`initialized`,input:{}},`*`),document.addEventListener(`DOMContentLoaded`,()=>{a(i);let e=new ResizeObserver(()=>{let e=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);parent.postMessage({channel:t,method:`height`,input:{height:e}},`*`)});e.observe(document.body),window.addEventListener(`pagehide`,()=>e.disconnect(),{once:!0})},{once:!0})}function t(t){let n=JSON.stringify(t).replaceAll(`<`,`\\u003c`).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`);return`<script>(${e.toString()})(${n})<\/script>`}export{e as bootstrap,t as mcpOpenAiScript};
|
|
2
|
+
//# sourceMappingURL=mcpOpenAiBootstrap.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpOpenAiBootstrap.mjs","names":["bootstrap","channel","pending","sequence","globals","initial","update","patch","request","id","timer","reject","args","state","input","event","message","callback","observer","height","mcpOpenAiScript","encoded"],"sources":["../../../src/lib/mcpOpenAiBootstrap.ts"],"sourcesContent":["interface LegacyGlobals {\n toolInput: Record<string, unknown>;\n toolOutput: unknown;\n toolResponseMetadata: Record<string, unknown>;\n widgetState: unknown;\n theme: 'light' | 'dark';\n locale: string;\n displayMode: 'inline';\n maxHeight: number;\n userAgent: { device: { type: 'desktop' | 'mobile' }; capabilities: { hover: boolean; touch: boolean } };\n safeArea: { insets: { top: number; right: number; bottom: number; left: number } };\n}\n\nexport function bootstrap(initial: LegacyGlobals): void {\n const channel = 'po.openai';\n const requestTimeout = 60_000;\n const pending = new Map<number, { resolve(value: unknown): void; reject(error: Error): void; timer: number }>();\n let sequence = 0;\n let globals = initial;\n const update = (patch: Partial<LegacyGlobals>): void => {\n globals = { ...globals, ...patch };\n window.dispatchEvent(new CustomEvent('openai:set_globals', { detail: { globals: patch } }));\n };\n const request = (method: string, input: unknown): Promise<unknown> => {\n if (pending.size >= 32) return Promise.reject(new Error('Too many pending widget requests'));\n const id = ++sequence;\n return new Promise((resolve, reject) => {\n const timer = window.setTimeout(() => {\n pending.delete(id);\n reject(new Error('Widget request timed out'));\n }, requestTimeout);\n pending.set(id, { resolve, reject, timer });\n parent.postMessage({ channel, id, method, input }, '*');\n });\n };\n const api = {\n get toolInput() {\n return globals.toolInput;\n },\n get toolOutput() {\n return globals.toolOutput;\n },\n get toolResponseMetadata() {\n return globals.toolResponseMetadata;\n },\n get widgetState() {\n return globals.widgetState;\n },\n get theme() {\n return globals.theme;\n },\n get locale() {\n return globals.locale;\n },\n get displayMode() {\n return globals.displayMode;\n },\n get maxHeight() {\n return globals.maxHeight;\n },\n get safeArea() {\n return globals.safeArea;\n },\n get userAgent() {\n return globals.userAgent;\n },\n callTool: (name: string, args: Record<string, unknown> = {}) => request('callTool', { name, arguments: args }),\n setWidgetState: (state: unknown) => {\n // Immediate local state, with await-compatible durable persistence.\n update({ widgetState: state });\n return request('setState', { state });\n },\n sendFollowUpMessage: (input: { prompt: string }) => request('followUp', input),\n requestDisplayMode: () => Promise.resolve({ mode: 'inline' }),\n openExternal: (input: { href: string }) => request('openLink', { url: input.href }),\n requestClose: () => request('close', {}),\n notifyIntrinsicHeight: (height: number) => request('height', { height }),\n };\n Object.defineProperty(window, 'openai', { value: Object.freeze(api), configurable: false, writable: false });\n window.addEventListener('message', (event: MessageEvent<unknown>) => {\n if (event.source !== parent) return;\n const message = event.data as {\n channel?: string;\n id?: number;\n error?: string;\n result?: unknown;\n globals?: Partial<LegacyGlobals>;\n };\n if (message?.channel !== channel) return;\n if (message.globals !== undefined) update(message.globals);\n if (message.id === undefined) return;\n const callback = pending.get(message.id);\n if (callback === undefined) return;\n pending.delete(message.id);\n clearTimeout(callback.timer);\n if (typeof message.error === 'string') callback.reject(new Error(message.error));\n else callback.resolve(message.result);\n });\n parent.postMessage({ channel, method: 'initialized', input: {} }, '*');\n document.addEventListener(\n 'DOMContentLoaded',\n () => {\n update(globals);\n const observer = new ResizeObserver(() => {\n const height = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);\n parent.postMessage({ channel, method: 'height', input: { height } }, '*');\n });\n observer.observe(document.body);\n window.addEventListener('pagehide', () => observer.disconnect(), { once: true });\n },\n { once: true },\n );\n}\n\nexport function mcpOpenAiScript(globals: LegacyGlobals): string {\n const encoded = JSON.stringify(globals)\n .replaceAll('<', '\\\\u003c')\n .replaceAll('\\u2028', '\\\\u2028')\n .replaceAll('\\u2029', '\\\\u2029');\n return `<script>(${bootstrap.toString()})(${encoded})</script>`;\n}\n"],"mappings":"AAaA,SAAgBA,EAAU,EAA8B,CACtD,IAAMC,EAAU,YAEVC,kBAAU,IAAI,IAChBC,EAAW,EACXC,EAAUC,EACRC,EAAU,GAAwC,CACtD,EAAU,CAAE,GAAGF,EAAS,GAAGG,CAAM,EACjC,OAAO,cAAc,IAAI,YAAY,qBAAsB,CAAE,OAAQ,CAAE,QAASA,CAAM,CAAE,CAAC,CAAC,CAC5F,EACMC,GAAW,EAAgB,IAAqC,CACpE,GAAIN,EAAQ,MAAQ,GAAI,OAAO,QAAQ,OAAO,gBAAI,MAAM,kCAAkC,CAAC,EAC3F,IAAMO,EAAK,EAAEN,EACb,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAMO,EAAQ,OAAO,eAAiB,CACpCR,EAAQ,OAAOO,CAAE,EACjBE,EAAO,gBAAI,MAAM,0BAA0B,CAAC,CAC9C,EAAG,GAAc,EACjBT,EAAQ,IAAIO,EAAI,CAAE,UAAS,SAAQ,OAAM,CAAC,EAC1C,OAAO,YAAY,CAAE,UAAS,KAAI,SAAQ,OAAM,EAAG,GAAG,CACxD,CAAC,CACH,EA4CA,OAAO,eAAe,OAAQ,SAAU,CAAE,MAAO,OAAO,OAAO,CA1C7D,IAAI,WAAY,CACd,OAAOL,EAAQ,SACjB,EACA,IAAI,YAAa,CACf,OA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,EAAQ,KAAK,CAAC,EAC1EC,EAAS,QAAQD,EAAQ,MAAM,EACtC,CAAC,EACD,OAAO,YAAY,CAAE,UAAS,OAAQ,cAAe,MAAO,CAAC,CAAE,EAAG,GAAG,EACrE,SAAS,iBACP,uBACM,CACJV,EAAOF,CAAO,EACd,IAAMc,EAAW,IAAI,mBAAqB,CACxC,IAAMC,EAAS,KAAK,IAAI,SAAS,KAAK,aAAc,SAAS,gBAAgB,YAAY,EACzF,OAAO,YAAY,CAAE,UAAS,OAAQ,SAAU,MAAO,CAAE,QAAO,CAAE,EAAG,GAAG,CAC1E,CAAC,EACDD,EAAS,QAAQ,SAAS,IAAI,EAC9B,OAAO,iBAAiB,eAAkBA,EAAS,WAAW,EAAG,CAAE,KAAM,EAAK,CAAC,CACjF,EACA,CAAE,KAAM,EAAK,CACf,CACF,CAEA,SAAgBE,EAAgB,EAAgC,CAC9D,IAAMC,EAAU,KAAK,UAAUjB,CAAO,CAAC,CACpC,WAAW,IAAK,SAAS,CAAC,CAC1B,WAAW,SAAU,SAAS,CAAC,CAC/B,WAAW,SAAU,SAAS,EACjC,MAAO,YAAYJ,EAAU,SAAS,EAAE,IAAIqB,EAAQ,YACtD,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.cjs","names":["MEDIA_KIND_BY_EXTENSION","extensionOf","name","filePath","dot","mediaKindOf"],"sources":["../../../src/lib/media.ts"],"sourcesContent":["import type { MediaKind } from '../types/editor';\n\n/**\n * Which files a browser can show without help.\n *\n * Keyed by lower-case extension without the dot, and deliberately short: an\n * entry here is a promise that the element named by its kind will render the\n * bytes, so a format the browser only sometimes handles belongs in the\n * download fallback instead of on this list.\n */\nconst MEDIA_KIND_BY_EXTENSION: Readonly<Record<string, MediaKind>> = {\n avif: 'image',\n bmp: 'image',\n gif: 'image',\n ico: 'image',\n jpeg: 'image',\n jpg: 'image',\n png: 'image',\n svg: 'image',\n webp: 'image',\n m4v: 'video',\n mov: 'video',\n mp4: 'video',\n webm: 'video',\n pdf: 'pdf',\n};\n\n/** The extension of a path, lower-cased and without the dot; empty when it has none. */\nfunction extensionOf(filePath: string): string {\n const name = filePath.split('/').at(-1) ?? '';\n const dot = name.lastIndexOf('.');\n // A leading dot is the whole name of a dotfile, not the start of a suffix.\n return dot < 1 ? '' : name.slice(dot + 1).toLowerCase();\n}\n\n/**\n * How to show the file at this path. Anything unrecognised is a download,\n * which is the honest answer for a `.docx` or a `.zip`: a browser cannot\n * render it, and pretending otherwise costs a converter that loses the\n * formatting it converted.\n */\nexport function mediaKindOf(filePath: string): MediaKind {\n return MEDIA_KIND_BY_EXTENSION[extensionOf(filePath)] ?? 'download';\n}\n"],"mappings":"AAUA,MAAMA,EAA+D,CACnE,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,KACP,EAGA,SAASC,EAAY,EAA0B,CAC7C,IAAMC,EAAOC,EAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAK,GACrCC,EAAMF,EAAK,YAAY,GAAG,EAEhC,OAAOE,EAAM,EAAI,GAAKF,EAAK,MAAME,EAAM,CAAC,CAAC,CAAC,YAAY,CACxD,CAQA,SAAgBC,EAAY,EAA6B,CACvD,OAAOL,EAAwBC,EAAYE,CAAQ,IAAM,UAC3D"}
|
|
1
|
+
{"version":3,"file":"media.cjs","names":["MEDIA_KIND_BY_EXTENSION","extensionOf","name","filePath","dot","mediaKindOf"],"sources":["../../../src/lib/media.ts"],"sourcesContent":["import type { MediaKind } from '../types/editor';\n\n/**\n * Which files a browser can show without help.\n *\n * Keyed by lower-case extension without the dot, and deliberately short: an\n * entry here is a promise that the element named by its kind will render the\n * bytes, so a format the browser only sometimes handles belongs in the\n * download fallback instead of on this list.\n */\nconst MEDIA_KIND_BY_EXTENSION: Readonly<Record<string, MediaKind>> = {\n avif: 'image',\n bmp: 'image',\n gif: 'image',\n ico: 'image',\n jpeg: 'image',\n jpg: 'image',\n png: 'image',\n svg: 'image',\n webp: 'image',\n m4v: 'video',\n mov: 'video',\n mp4: 'video',\n webm: 'video',\n pdf: 'pdf',\n};\n\n/** The extension of a path, lower-cased and without the dot; empty when it has none. */\nfunction extensionOf(filePath: string): string {\n const name = filePath.split('/').at(-1) ?? '';\n const dot = name.lastIndexOf('.');\n // A leading dot is the whole name of a dotfile, not the start of a suffix.\n return dot < 1 ? '' : name.slice(dot + 1).toLowerCase();\n}\n\n/**\n * How to show the file at this path. Anything unrecognised is a download,\n * which is the honest answer for a `.docx` or a `.zip`: a browser cannot\n * render it, and pretending otherwise costs a converter that loses the\n * formatting it converted.\n */\nexport function mediaKindOf(filePath: string): MediaKind {\n return MEDIA_KIND_BY_EXTENSION[extensionOf(filePath)] ?? 'download';\n}\n"],"mappings":"AAUA,MAAMA,EAA+D,CACnE,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,KACP,EAGA,SAASC,EAAY,EAA0B,CAC7C,IAAMC,EAAOC,EAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAK,GACrCC,EAAMF,EAAK,YAAY,GAAG,EAEhC,OAAOE,EAAM,EAAI,GAAKF,EAAK,MAAME,EAAM,CAAC,CAAC,CAAC,YAAY,CACxD,CAQA,SAAgBC,EAAY,EAA6B,CACvD,OAAOL,EAAwBC,EAAYE,CAAQ,IAAM,UAC3D,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.mts","names":[],"sources":["../../../src/lib/media.ts"],"mappings":";;;;;;;;wBAyCgB,YAAY,mBAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.mjs","names":["MEDIA_KIND_BY_EXTENSION","extensionOf","name","filePath","dot","mediaKindOf"],"sources":["../../../src/lib/media.ts"],"sourcesContent":["import type { MediaKind } from '../types/editor';\n\n/**\n * Which files a browser can show without help.\n *\n * Keyed by lower-case extension without the dot, and deliberately short: an\n * entry here is a promise that the element named by its kind will render the\n * bytes, so a format the browser only sometimes handles belongs in the\n * download fallback instead of on this list.\n */\nconst MEDIA_KIND_BY_EXTENSION: Readonly<Record<string, MediaKind>> = {\n avif: 'image',\n bmp: 'image',\n gif: 'image',\n ico: 'image',\n jpeg: 'image',\n jpg: 'image',\n png: 'image',\n svg: 'image',\n webp: 'image',\n m4v: 'video',\n mov: 'video',\n mp4: 'video',\n webm: 'video',\n pdf: 'pdf',\n};\n\n/** The extension of a path, lower-cased and without the dot; empty when it has none. */\nfunction extensionOf(filePath: string): string {\n const name = filePath.split('/').at(-1) ?? '';\n const dot = name.lastIndexOf('.');\n // A leading dot is the whole name of a dotfile, not the start of a suffix.\n return dot < 1 ? '' : name.slice(dot + 1).toLowerCase();\n}\n\n/**\n * How to show the file at this path. Anything unrecognised is a download,\n * which is the honest answer for a `.docx` or a `.zip`: a browser cannot\n * render it, and pretending otherwise costs a converter that loses the\n * formatting it converted.\n */\nexport function mediaKindOf(filePath: string): MediaKind {\n return MEDIA_KIND_BY_EXTENSION[extensionOf(filePath)] ?? 'download';\n}\n"],"mappings":"AAUA,MAAMA,EAA+D,CACnE,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,QACL,IAAK,QACL,IAAK,QACL,KAAM,QACN,IAAK,KACP,EAGA,SAASC,EAAY,EAA0B,CAC7C,IAAMC,EAAOC,EAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAK,GACrCC,EAAMF,EAAK,YAAY,GAAG,EAEhC,OAAOE,EAAM,EAAI,GAAKF,EAAK,MAAME,EAAM,CAAC,CAAC,CAAC,YAAY,CACxD,CAQA,SAAgBC,EAAY,EAA6B,CACvD,OAAOL,EAAwBC,EAAYE,CAAQ,IAAM,UAC3D,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaPlayback.cjs","names":["boundedMediaTime","seconds","duration"],"sources":["../../../src/lib/mediaPlayback.ts"],"sourcesContent":["/** Keep an imperative seek inside the playable part of the current video. */\nexport function boundedMediaTime(seconds: number, duration: number): number {\n if (!Number.isFinite(seconds)) throw new RangeError('Media seek time must be finite');\n const end = Number.isFinite(duration) && duration >= 0 ? duration : Number.POSITIVE_INFINITY;\n return Math.min(Math.max(seconds, 0), end);\n}\n"],"mappings":"AACA,SAAgBA,EAAiB,EAAiB,EAA0B,CAC1E,GAAI,CAAC,OAAO,SAASC,CAAO,EAAG,MAAU,WAAW,gCAAgC,EAEpF,OAAO,KAAK,IAAI,KAAK,IAAIA,EAAS,CAAC,EADvB,OAAO,SAASC,CAAQ,GAAKA,GAAY,EAAIA,EAAW,GAC3B,CAC3C"}
|
|
1
|
+
{"version":3,"file":"mediaPlayback.cjs","names":["boundedMediaTime","seconds","duration"],"sources":["../../../src/lib/mediaPlayback.ts"],"sourcesContent":["/** Keep an imperative seek inside the playable part of the current video. */\nexport function boundedMediaTime(seconds: number, duration: number): number {\n if (!Number.isFinite(seconds)) throw new RangeError('Media seek time must be finite');\n const end = Number.isFinite(duration) && duration >= 0 ? duration : Number.POSITIVE_INFINITY;\n return Math.min(Math.max(seconds, 0), end);\n}\n"],"mappings":"AACA,SAAgBA,EAAiB,EAAiB,EAA0B,CAC1E,GAAI,CAAC,OAAO,SAASC,CAAO,EAAG,MAAU,WAAW,gCAAgC,EAEpF,OAAO,KAAK,IAAI,KAAK,IAAIA,EAAS,CAAC,EADvB,OAAO,SAASC,CAAQ,GAAKA,GAAY,EAAIA,EAAW,GAC3B,CAC3C,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediaPlayback.mjs","names":["boundedMediaTime","seconds","duration"],"sources":["../../../src/lib/mediaPlayback.ts"],"sourcesContent":["/** Keep an imperative seek inside the playable part of the current video. */\nexport function boundedMediaTime(seconds: number, duration: number): number {\n if (!Number.isFinite(seconds)) throw new RangeError('Media seek time must be finite');\n const end = Number.isFinite(duration) && duration >= 0 ? duration : Number.POSITIVE_INFINITY;\n return Math.min(Math.max(seconds, 0), end);\n}\n"],"mappings":"AACA,SAAgBA,EAAiB,EAAiB,EAA0B,CAC1E,GAAI,CAAC,OAAO,SAASC,CAAO,EAAG,MAAU,WAAW,gCAAgC,EAEpF,OAAO,KAAK,IAAI,KAAK,IAAIA,EAAS,CAAC,EADvB,OAAO,SAASC,CAAQ,GAAKA,GAAY,EAAIA,EAAW,GAC3B,CAC3C,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e;async function t(){return e??=import(`mermaid`).then(({default:e})=>(e.initialize({startOnLoad:!1,fontFamily:`inherit`,theme:`dark`,securityLevel:`strict
|
|
1
|
+
let e;async function t(){return e??=import(`mermaid`).then(({default:e})=>(e.initialize({startOnLoad:!1,fontFamily:`inherit`,theme:`dark`,securityLevel:`strict`,suppressErrorRendering:!0}),e)),e}async function n(e,n){let{svg:r}=await(await t()).render(e,n);return r}exports.renderMermaid=n;
|
|
2
2
|
//# sourceMappingURL=mermaidDiagram.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaidDiagram.cjs","names":["loading","mermaidApi","mermaid","renderMermaid","id","code","svg"],"sources":["../../../src/lib/mermaidDiagram.ts"],"sourcesContent":["/**\n * Mermaid, loaded only for a message that actually draws one.\n *\n * Mermaid is the largest thing this library can pull in, so nothing imports it\n * at module scope: the dynamic import below is its own chunk, fetched the\n * first time a `mermaid` fence renders and reused after that. The renderer\n * needs a document to measure text, so this module is browser-only by nature\n * and every caller is inside an effect.\n */\n\nlet loading: Promise<typeof import('mermaid').default> | undefined;\n\n/** Loads and configures mermaid once per page. */\nasync function mermaidApi(): Promise<typeof import('mermaid').default> {\n loading ??= import('mermaid').then(({ default: mermaid }) => {\n mermaid.initialize({\n startOnLoad: false,\n // Diagram text follows the surface it sits on rather than mermaid's own\n // font stack, and the dark base is the only preset close to the cockpit.\n fontFamily: 'inherit',\n theme: 'dark',\n // Strict is mermaid's default and its sanitiser: labels are escaped and\n // script-carrying markup is stripped before the SVG is handed back,\n // which is what makes rendering diagram text from a model safe.\n securityLevel: 'strict',\n });\n return mermaid;\n });\n return loading;\n}\n\n/**\n * The SVG for one diagram.\n *\n * Rejects on invalid syntax, which for a streaming message is the normal case\n * until the fence closes; the caller shows the source until it resolves.\n */\nexport async function renderMermaid(id: string, code: string): Promise<string> {\n const mermaid = await mermaidApi();\n const { svg } = await mermaid.render(id, code);\n return svg;\n}\n"],"mappings":"AAUA,IAAIA,EAGJ,eAAeC,GAAwD,
|
|
1
|
+
{"version":3,"file":"mermaidDiagram.cjs","names":["loading","mermaidApi","mermaid","renderMermaid","id","code","svg"],"sources":["../../../src/lib/mermaidDiagram.ts"],"sourcesContent":["/**\n * Mermaid, loaded only for a message that actually draws one.\n *\n * Mermaid is the largest thing this library can pull in, so nothing imports it\n * at module scope: the dynamic import below is its own chunk, fetched the\n * first time a `mermaid` fence renders and reused after that. The renderer\n * needs a document to measure text, so this module is browser-only by nature\n * and every caller is inside an effect.\n */\n\nlet loading: Promise<typeof import('mermaid').default> | undefined;\n\n/** Loads and configures mermaid once per page. */\nasync function mermaidApi(): Promise<typeof import('mermaid').default> {\n loading ??= import('mermaid').then(({ default: mermaid }) => {\n mermaid.initialize({\n startOnLoad: false,\n // Diagram text follows the surface it sits on rather than mermaid's own\n // font stack, and the dark base is the only preset close to the cockpit.\n fontFamily: 'inherit',\n theme: 'dark',\n // Strict is mermaid's default and its sanitiser: labels are escaped and\n // script-carrying markup is stripped before the SVG is handed back,\n // which is what makes rendering diagram text from a model safe.\n securityLevel: 'strict',\n // Without this, a failed render leaves mermaid's bomb error diagram\n // appended to <body>, outside the conversation. The caller already\n // falls back to the source on rejection, so just throw.\n suppressErrorRendering: true,\n });\n return mermaid;\n });\n return loading;\n}\n\n/**\n * The SVG for one diagram.\n *\n * Rejects on invalid syntax, which for a streaming message is the normal case\n * until the fence closes; the caller shows the source until it resolves.\n */\nexport async function renderMermaid(id: string, code: string): Promise<string> {\n const mermaid = await mermaidApi();\n const { svg } = await mermaid.render(id, code);\n return svg;\n}\n"],"mappings":"AAUA,IAAIA,EAGJ,eAAeC,GAAwD,CAmBrE,MAlBA,KAAY,OAAO,UAAU,CAAC,MAAM,CAAE,QAASC,MAC7CA,EAAQ,WAAW,CACjB,YAAa,GAGb,WAAY,UACZ,MAAO,OAIP,cAAe,SAIf,uBAAwB,EAC1B,CAAC,EACMA,EACR,EACMF,CACT,CAQA,eAAsBG,EAAc,EAAY,EAA+B,CAE7E,GAAM,CAAE,OAAQ,MAAM,MADAF,EAAW,EAAA,CACH,OAAOG,EAAIC,CAAI,EAC7C,OAAOC,CACT,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e;async function t(){return e??=import(`mermaid`).then(({default:e})=>(e.initialize({startOnLoad:!1,fontFamily:`inherit`,theme:`dark`,securityLevel:`strict`,suppressErrorRendering:!0}),e)),e}async function n(e,n){let{svg:r}=await(await t()).render(e,n);return r}export{n as renderMermaid};
|
|
2
|
+
//# sourceMappingURL=mermaidDiagram.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaidDiagram.mjs","names":["loading","mermaidApi","mermaid","renderMermaid","id","code","svg"],"sources":["../../../src/lib/mermaidDiagram.ts"],"sourcesContent":["/**\n * Mermaid, loaded only for a message that actually draws one.\n *\n * Mermaid is the largest thing this library can pull in, so nothing imports it\n * at module scope: the dynamic import below is its own chunk, fetched the\n * first time a `mermaid` fence renders and reused after that. The renderer\n * needs a document to measure text, so this module is browser-only by nature\n * and every caller is inside an effect.\n */\n\nlet loading: Promise<typeof import('mermaid').default> | undefined;\n\n/** Loads and configures mermaid once per page. */\nasync function mermaidApi(): Promise<typeof import('mermaid').default> {\n loading ??= import('mermaid').then(({ default: mermaid }) => {\n mermaid.initialize({\n startOnLoad: false,\n // Diagram text follows the surface it sits on rather than mermaid's own\n // font stack, and the dark base is the only preset close to the cockpit.\n fontFamily: 'inherit',\n theme: 'dark',\n // Strict is mermaid's default and its sanitiser: labels are escaped and\n // script-carrying markup is stripped before the SVG is handed back,\n // which is what makes rendering diagram text from a model safe.\n securityLevel: 'strict',\n // Without this, a failed render leaves mermaid's bomb error diagram\n // appended to <body>, outside the conversation. The caller already\n // falls back to the source on rejection, so just throw.\n suppressErrorRendering: true,\n });\n return mermaid;\n });\n return loading;\n}\n\n/**\n * The SVG for one diagram.\n *\n * Rejects on invalid syntax, which for a streaming message is the normal case\n * until the fence closes; the caller shows the source until it resolves.\n */\nexport async function renderMermaid(id: string, code: string): Promise<string> {\n const mermaid = await mermaidApi();\n const { svg } = await mermaid.render(id, code);\n return svg;\n}\n"],"mappings":"AAUA,IAAIA,EAGJ,eAAeC,GAAwD,CAmBrE,MAlBA,KAAY,OAAO,UAAU,CAAC,MAAM,CAAE,QAASC,MAC7CA,EAAQ,WAAW,CACjB,YAAa,GAGb,WAAY,UACZ,MAAO,OAIP,cAAe,SAIf,uBAAwB,EAC1B,CAAC,EACMA,EACR,EACMF,CACT,CAQA,eAAsBG,EAAc,EAAY,EAA+B,CAE7E,GAAM,CAAE,OAAQ,MAAM,MADAF,EAAW,EAAA,CACH,OAAOG,EAAIC,CAAI,EAC7C,OAAOC,CACT,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionList.cjs","names":["handleOptionListKey","input","count","options","event","onCursorChange","cursor","option","onSelect","index","optionListHint","optionMarker"],"sources":["../../../src/lib/optionList.ts"],"sourcesContent":["import type { KeyboardEvent } from 'react';\n\n/** Digits are a shortcut, not the only way in: only the first nine can have one. */\nexport const MAX_DIGIT_SHORTCUT = 9;\n\n/**\n * The keyboard an option list answers to, handled on whichever element the\n * surrounding overlay focuses. Every key it claims is consumed, so a digit\n * that answers the agent never also reaches the rail's session shortcuts.\n */\nexport function handleOptionListKey(\n event: KeyboardEvent,\n input: {\n options: readonly string[];\n cursor: number;\n onCursorChange: (cursor: number) => void;\n onSelect: (option: string) => void;\n },\n): void {\n const { options, cursor, onCursorChange, onSelect } = input;\n const count = options.length;\n if (count === 0) return;\n\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n onCursorChange((cursor + (event.key === 'ArrowDown' ? 1 : -1) + count) % count);\n return;\n }\n if (event.key === 'Enter') {\n const option = options[cursor];\n if (option === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n onSelect(option);\n return;\n }\n const index = Number.parseInt(event.key, 10) - 1;\n const option = Number.isInteger(index) && index < MAX_DIGIT_SHORTCUT ? options[index] : undefined;\n if (option === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n onSelect(option);\n}\n\n/** What the footer should promise, given how many options there are. */\nexport function optionListHint(count: number): string {\n return count > MAX_DIGIT_SHORTCUT ? 'up/down move · enter select · 1-9 jump' : '1-9 select · enter confirm';\n}\n\n/** The digit a row answers to, or the bullet that says it has none. */\nexport function optionMarker(index: number): string {\n return index < MAX_DIGIT_SHORTCUT ? String(index + 1) : '·';\n}\n"],"mappings":"AAUA,SAAgBA,EACd,EACA,EAMM,CACN,GAAM,CAAE,UAAS,SAAQ,iBAAgB,YAAaC,EAChDC,EAAQC,EAAQ,OACtB,GAAID,IAAU,EAAG,OAEjB,GAAIE,EAAM,MAAQ,aAAeA,EAAM,MAAQ,UAAW,CACxDA,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBC,GAAgBC,GAAUF,EAAM,MAAQ,YAAc,EAAI,IAAMF,GAASA,CAAK,EAC9E,MACF,CACA,GAAIE,EAAM,MAAQ,QAAS,CACzB,IAAMG,EAASJ,EAAQG,GACvB,GAAIC,IAAW,IAAA,GAAW,OAC1BH,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBI,EAASD,CAAM,EACf,MACF,CACA,IAAME,EAAQ,OAAO,SAASL,EAAM,IAAK,EAAE,EAAI,EACzCG,EAAS,OAAO,UAAUE,CAAK,GAAKA,EAAA,EAA6BN,EAAQM,GAAS,IAAA,GACpFF,IAAW,IAAA,KACfH,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBI,EAASD,CAAM,EACjB,CAGA,SAAgBG,EAAe,EAAuB,CACpD,OAAOR,EAAA,EAA6B,yCAA2C,4BACjF,CAGA,SAAgBS,EAAa,EAAuB,CAClD,OAAOF,EAAA,EAA6B,OAAOA,EAAQ,CAAC,EAAI,GAC1D"}
|
|
1
|
+
{"version":3,"file":"optionList.cjs","names":["handleOptionListKey","input","count","options","event","onCursorChange","cursor","option","onSelect","index","optionListHint","optionMarker"],"sources":["../../../src/lib/optionList.ts"],"sourcesContent":["import type { KeyboardEvent } from 'react';\n\n/** Digits are a shortcut, not the only way in: only the first nine can have one. */\nexport const MAX_DIGIT_SHORTCUT = 9;\n\n/**\n * The keyboard an option list answers to, handled on whichever element the\n * surrounding overlay focuses. Every key it claims is consumed, so a digit\n * that answers the agent never also reaches the rail's session shortcuts.\n */\nexport function handleOptionListKey(\n event: KeyboardEvent,\n input: {\n options: readonly string[];\n cursor: number;\n onCursorChange: (cursor: number) => void;\n onSelect: (option: string) => void;\n },\n): void {\n const { options, cursor, onCursorChange, onSelect } = input;\n const count = options.length;\n if (count === 0) return;\n\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n onCursorChange((cursor + (event.key === 'ArrowDown' ? 1 : -1) + count) % count);\n return;\n }\n if (event.key === 'Enter') {\n const option = options[cursor];\n if (option === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n onSelect(option);\n return;\n }\n const index = Number.parseInt(event.key, 10) - 1;\n const option = Number.isInteger(index) && index < MAX_DIGIT_SHORTCUT ? options[index] : undefined;\n if (option === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n onSelect(option);\n}\n\n/** What the footer should promise, given how many options there are. */\nexport function optionListHint(count: number): string {\n return count > MAX_DIGIT_SHORTCUT ? 'up/down move · enter select · 1-9 jump' : '1-9 select · enter confirm';\n}\n\n/** The digit a row answers to, or the bullet that says it has none. */\nexport function optionMarker(index: number): string {\n return index < MAX_DIGIT_SHORTCUT ? String(index + 1) : '·';\n}\n"],"mappings":"AAUA,SAAgBA,EACd,EACA,EAMM,CACN,GAAM,CAAE,UAAS,SAAQ,iBAAgB,YAAaC,EAChDC,EAAQC,EAAQ,OACtB,GAAID,IAAU,EAAG,OAEjB,GAAIE,EAAM,MAAQ,aAAeA,EAAM,MAAQ,UAAW,CACxDA,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBC,GAAgBC,GAAUF,EAAM,MAAQ,YAAc,EAAI,IAAMF,GAASA,CAAK,EAC9E,MACF,CACA,GAAIE,EAAM,MAAQ,QAAS,CACzB,IAAMG,EAASJ,EAAQG,GACvB,GAAIC,IAAW,IAAA,GAAW,OAC1BH,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBI,EAASD,CAAM,EACf,MACF,CACA,IAAME,EAAQ,OAAO,SAASL,EAAM,IAAK,EAAE,EAAI,EACzCG,EAAS,OAAO,UAAUE,CAAK,GAAKA,EAAA,EAA6BN,EAAQM,GAAS,IAAA,GACpFF,IAAW,IAAA,KACfH,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBI,EAASD,CAAM,EACjB,CAGA,SAAgBG,EAAe,EAAuB,CACpD,OAAOR,EAAA,EAA6B,yCAA2C,4BACjF,CAGA,SAAgBS,EAAa,EAAuB,CAClD,OAAOF,EAAA,EAA6B,OAAOA,EAAQ,CAAC,EAAI,GAC1D,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionList.d.mts","names":[],"sources":["../../../src/lib/optionList.ts"],"mappings":";;;qBAGa;;;;;;wBAOG,oBACd,OAAO,eACP;EACE;EACA;EACA,iBAAiB;EACjB,WAAW;;;wBA8BC,eAAe;;wBAKf,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionList.mjs","names":["MAX_DIGIT_SHORTCUT","handleOptionListKey","input","count","options","event","onCursorChange","cursor","option","onSelect","index","optionListHint","optionMarker"],"sources":["../../../src/lib/optionList.ts"],"sourcesContent":["import type { KeyboardEvent } from 'react';\n\n/** Digits are a shortcut, not the only way in: only the first nine can have one. */\nexport const MAX_DIGIT_SHORTCUT = 9;\n\n/**\n * The keyboard an option list answers to, handled on whichever element the\n * surrounding overlay focuses. Every key it claims is consumed, so a digit\n * that answers the agent never also reaches the rail's session shortcuts.\n */\nexport function handleOptionListKey(\n event: KeyboardEvent,\n input: {\n options: readonly string[];\n cursor: number;\n onCursorChange: (cursor: number) => void;\n onSelect: (option: string) => void;\n },\n): void {\n const { options, cursor, onCursorChange, onSelect } = input;\n const count = options.length;\n if (count === 0) return;\n\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n onCursorChange((cursor + (event.key === 'ArrowDown' ? 1 : -1) + count) % count);\n return;\n }\n if (event.key === 'Enter') {\n const option = options[cursor];\n if (option === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n onSelect(option);\n return;\n }\n const index = Number.parseInt(event.key, 10) - 1;\n const option = Number.isInteger(index) && index < MAX_DIGIT_SHORTCUT ? options[index] : undefined;\n if (option === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n onSelect(option);\n}\n\n/** What the footer should promise, given how many options there are. */\nexport function optionListHint(count: number): string {\n return count > MAX_DIGIT_SHORTCUT ? 'up/down move · enter select · 1-9 jump' : '1-9 select · enter confirm';\n}\n\n/** The digit a row answers to, or the bullet that says it has none. */\nexport function optionMarker(index: number): string {\n return index < MAX_DIGIT_SHORTCUT ? String(index + 1) : '·';\n}\n"],"mappings":"AAGA,MAAaA,EAAqB,EAOlC,SAAgBC,EACd,EACA,EAMM,CACN,GAAM,CAAE,UAAS,SAAQ,iBAAgB,YAAaC,EAChDC,EAAQC,EAAQ,OACtB,GAAID,IAAU,EAAG,OAEjB,GAAIE,EAAM,MAAQ,aAAeA,EAAM,MAAQ,UAAW,CACxDA,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBC,GAAgBC,GAAUF,EAAM,MAAQ,YAAc,EAAI,IAAMF,GAASA,CAAK,EAC9E,MACF,CACA,GAAIE,EAAM,MAAQ,QAAS,CACzB,IAAMG,EAASJ,EAAQG,GACvB,GAAIC,IAAW,IAAA,GAAW,OAC1BH,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBI,EAASD,CAAM,EACf,MACF,CACA,IAAME,EAAQ,OAAO,SAASL,EAAM,IAAK,EAAE,EAAI,EACzCG,EAAS,OAAO,UAAUE,CAAK,GAAKA,EAAA,EAA6BN,EAAQM,GAAS,IAAA,GACpFF,IAAW,IAAA,KACfH,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtBI,EAASD,CAAM,EACjB,CAGA,SAAgBG,EAAe,EAAuB,CACpD,OAAOR,EAAA,EAA6B,yCAA2C,4BACjF,CAGA,SAAgBS,EAAa,EAAuB,CAClD,OAAOF,EAAA,EAA6B,OAAOA,EAAQ,CAAC,EAAI,GAC1D,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathGroups.cjs","names":["parentDir","cut","relPath","commonDir","leftParts","left","rightParts","right","shared","index","groupByDirectory","buckets","item","items","pathOf","key","bucket","groups","sorted","prefix","groupRowLabel"],"sources":["../../../src/lib/pathGroups.ts"],"sourcesContent":["/**\n * The two-level grouping a changed-file list uses: one header per top-level\n * segment, each naming the deepest directory its files share.\n *\n * Two levels rather than a full tree: paths here run five and six segments\n * deep, so a node per segment spends more rows on directories than on the files\n * someone came to find. The header carries the shared run of directories and\n * each row carries what is left, so a file stays one row and the part that\n * distinguishes it stays readable.\n */\n\n/** One header row and the items under it. */\nexport interface PathGroup<T> {\n /** The shared directory the header names, or empty for files at the root. */\n prefix: string;\n items: T[];\n}\n\n/** The directory part of a relative path, or empty for a file at the root. */\nfunction parentDir(relPath: string): string {\n const cut = relPath.lastIndexOf('/');\n return cut === -1 ? '' : relPath.slice(0, cut);\n}\n\n/** The longest directory two paths share, compared segment by segment rather than character by character. */\nfunction commonDir(left: string, right: string): string {\n const leftParts = left.split('/');\n const rightParts = right.split('/');\n const shared: string[] = [];\n for (let index = 0; index < Math.min(leftParts.length, rightParts.length); index += 1) {\n if (leftParts[index] !== rightParts[index]) break;\n shared.push(leftParts[index]);\n }\n return shared.join('/');\n}\n\n/** Groups by top-level segment, ordered by path so a header's files sit together under it. */\nexport function groupByDirectory<T>(items: readonly T[], pathOf: (item: T) => string): PathGroup<T>[] {\n const buckets = new Map<string, T[]>();\n for (const item of items) {\n const relPath = pathOf(item);\n const cut = relPath.indexOf('/');\n const key = cut === -1 ? '' : relPath.slice(0, cut);\n const bucket = buckets.get(key);\n if (bucket === undefined) buckets.set(key, [item]);\n else bucket.push(item);\n }\n const groups: PathGroup<T>[] = [];\n for (const [key, bucket] of buckets) {\n const sorted = [...bucket].sort((left, right) => pathOf(left).localeCompare(pathOf(right)));\n // Root files have no directory to name, so they keep an empty header and\n // render their own paths in full.\n const prefix = key === '' ? '' : sorted.map((item) => parentDir(pathOf(item))).reduce(commonDir);\n groups.push({ prefix, items: sorted });\n }\n return groups.sort((left, right) => left.prefix.localeCompare(right.prefix));\n}\n\n/** What one row shows once its group's header has already said the shared part. */\nexport function groupRowLabel(prefix: string, relPath: string): string {\n return prefix === '' ? relPath : relPath.slice(prefix.length + 1);\n}\n"],"mappings":"AAmBA,SAASA,EAAU,EAAyB,CAC1C,IAAMC,EAAMC,EAAQ,YAAY,GAAG,EACnC,OAAOD,IAAQ,GAAK,GAAKC,EAAQ,MAAM,EAAGD,CAAG,CAC/C,CAGA,SAASE,EAAU,EAAc,EAAuB,CACtD,IAAMC,EAAYC,EAAK,MAAM,GAAG,EAC1BC,EAAaC,EAA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","shared","index","groupByDirectory","buckets","item","items","pathOf","key","bucket","groups","sorted","prefix","groupRowLabel"],"sources":["../../../src/lib/pathGroups.ts"],"sourcesContent":["/**\n * The two-level grouping a changed-file list uses: one header per top-level\n * segment, each naming the deepest directory its files share.\n *\n * Two levels rather than a full tree: paths here run five and six segments\n * deep, so a node per segment spends more rows on directories than on the files\n * someone came to find. The header carries the shared run of directories and\n * each row carries what is left, so a file stays one row and the part that\n * distinguishes it stays readable.\n */\n\n/** One header row and the items under it. */\nexport interface PathGroup<T> {\n /** The shared directory the header names, or empty for files at the root. */\n prefix: string;\n items: T[];\n}\n\n/** The directory part of a relative path, or empty for a file at the root. */\nfunction parentDir(relPath: string): string {\n const cut = relPath.lastIndexOf('/');\n return cut === -1 ? '' : relPath.slice(0, cut);\n}\n\n/** The longest directory two paths share, compared segment by segment rather than character by character. */\nfunction commonDir(left: string, right: string): string {\n const leftParts = left.split('/');\n const rightParts = right.split('/');\n const shared: string[] = [];\n for (let index = 0; index < Math.min(leftParts.length, rightParts.length); index += 1) {\n if (leftParts[index] !== rightParts[index]) break;\n shared.push(leftParts[index]);\n }\n return shared.join('/');\n}\n\n/** Groups by top-level segment, ordered by path so a header's files sit together under it. */\nexport function groupByDirectory<T>(items: readonly T[], pathOf: (item: T) => string): PathGroup<T>[] {\n const buckets = new Map<string, T[]>();\n for (const item of items) {\n const relPath = pathOf(item);\n const cut = relPath.indexOf('/');\n const key = cut === -1 ? '' : relPath.slice(0, cut);\n const bucket = buckets.get(key);\n if (bucket === undefined) buckets.set(key, [item]);\n else bucket.push(item);\n }\n const groups: PathGroup<T>[] = [];\n for (const [key, bucket] of buckets) {\n const sorted = [...bucket].sort((left, right) => pathOf(left).localeCompare(pathOf(right)));\n // Root files have no directory to name, so they keep an empty header and\n // render their own paths in full.\n const prefix = key === '' ? '' : sorted.map((item) => parentDir(pathOf(item))).reduce(commonDir);\n groups.push({ prefix, items: sorted });\n }\n return groups.sort((left, right) => left.prefix.localeCompare(right.prefix));\n}\n\n/** What one row shows once its group's header has already said the shared part. */\nexport function groupRowLabel(prefix: string, relPath: string): string {\n return prefix === '' ? relPath : relPath.slice(prefix.length + 1);\n}\n"],"mappings":"AAmBA,SAASA,EAAU,EAAyB,CAC1C,IAAMC,EAAMC,EAAQ,YAAY,GAAG,EACnC,OAAOD,IAAQ,GAAK,GAAKC,EAAQ,MAAM,EAAGD,CAAG,CAC/C,CAGA,SAASE,EAAU,EAAc,EAAuB,CACtD,IAAMC,EAAYC,EAAK,MAAM,GAAG,EAC1BC,EAAaC,EAAM,MAAM,GAAG,EAC5BC,EAAmB,CAAC,EAC1B,IAAK,IAAIC,EAAQ,EAAGA,EAAQ,KAAK,IAAIL,EAAU,OAAQE,EAAW,MAAM,GAClEF,EAAUK,KAAWH,EAAWG,GADqC,GAAS,EAElFD,EAAO,KAAKJ,EAAUK,EAAM,EAE9B,OAAOD,EAAO,KAAK,GAAG,CACxB,CAGA,SAAgBE,EAAoB,EAAqB,EAA6C,CACpG,IAAMC,kBAAU,IAAI,IACpB,IAAK,IAAMC,KAAQC,EAAO,CACxB,IAAMX,EAAUY,EAAOF,CAAI,EACrBX,EAAMC,EAAQ,QAAQ,GAAG,EACzBa,EAAMd,IAAQ,GAAK,GAAKC,EAAQ,MAAM,EAAGD,CAAG,EAC5Ce,EAASL,EAAQ,IAAII,CAAG,EAC1BC,IAAW,IAAA,GAAWL,EAAQ,IAAII,EAAK,CAACH,CAAI,CAAC,EAC5CI,EAAO,KAAKJ,CAAI,CACvB,CACA,IAAMK,EAAyB,CAAC,EAChC,IAAK,GAAM,CAACF,EAAKC,KAAWL,EAAS,CACnC,IAAMO,EAAS,CAAC,GAAGF,CAAM,CAAC,CAAC,MAAM,EAAM,IAAUF,EAAOT,CAAI,CAAC,CAAC,cAAcS,EAAOP,CAAK,CAAC,CAAC,EAGpFY,EAASJ,IAAQ,GAAK,GAAKG,EAAO,IAAK,GAASlB,EAAUc,EAAOF,CAAI,CAAC,CAAC,CAAC,CAAC,OAAOT,CAAS,EAC/Fc,EAAO,KAAK,CAAE,SAAQ,MAAOC,CAAO,CAAC,CACvC,CACA,OAAOD,EAAO,MAAM,EAAM,IAAUZ,EAAK,OAAO,cAAcE,EAAM,MAAM,CAAC,CAC7E,CAGA,SAAgBa,EAAc,EAAgB,EAAyB,CACrE,OAAOD,IAAW,GAAKjB,EAAUA,EAAQ,MAAMiB,EAAO,OAAS,CAAC,CAClE,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathGroups.d.mts","names":[],"sources":["../../../src/lib/pathGroups.ts"],"mappings":";;;;;;;;;;;;iBAYiB,UAAU;;EAEzB;EACA,OAAO;;;wBAsBO,iBAAiB,GAAG,gBAAgB,KAAK,SAAS,MAAM,eAAe,UAAU;;wBAsBjF,cAAc,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathGroups.mjs","names":["parentDir","cut","relPath","commonDir","leftParts","left","rightParts","right","shared","index","groupByDirectory","buckets","item","items","pathOf","key","bucket","groups","sorted","prefix","groupRowLabel"],"sources":["../../../src/lib/pathGroups.ts"],"sourcesContent":["/**\n * The two-level grouping a changed-file list uses: one header per top-level\n * segment, each naming the deepest directory its files share.\n *\n * Two levels rather than a full tree: paths here run five and six segments\n * deep, so a node per segment spends more rows on directories than on the files\n * someone came to find. The header carries the shared run of directories and\n * each row carries what is left, so a file stays one row and the part that\n * distinguishes it stays readable.\n */\n\n/** One header row and the items under it. */\nexport interface PathGroup<T> {\n /** The shared directory the header names, or empty for files at the root. */\n prefix: string;\n items: T[];\n}\n\n/** The directory part of a relative path, or empty for a file at the root. */\nfunction parentDir(relPath: string): string {\n const cut = relPath.lastIndexOf('/');\n return cut === -1 ? '' : relPath.slice(0, cut);\n}\n\n/** The longest directory two paths share, compared segment by segment rather than character by character. */\nfunction commonDir(left: string, right: string): string {\n const leftParts = left.split('/');\n const rightParts = right.split('/');\n const shared: string[] = [];\n for (let index = 0; index < Math.min(leftParts.length, rightParts.length); index += 1) {\n if (leftParts[index] !== rightParts[index]) break;\n shared.push(leftParts[index]);\n }\n return shared.join('/');\n}\n\n/** Groups by top-level segment, ordered by path so a header's files sit together under it. */\nexport function groupByDirectory<T>(items: readonly T[], pathOf: (item: T) => string): PathGroup<T>[] {\n const buckets = new Map<string, T[]>();\n for (const item of items) {\n const relPath = pathOf(item);\n const cut = relPath.indexOf('/');\n const key = cut === -1 ? '' : relPath.slice(0, cut);\n const bucket = buckets.get(key);\n if (bucket === undefined) buckets.set(key, [item]);\n else bucket.push(item);\n }\n const groups: PathGroup<T>[] = [];\n for (const [key, bucket] of buckets) {\n const sorted = [...bucket].sort((left, right) => pathOf(left).localeCompare(pathOf(right)));\n // Root files have no directory to name, so they keep an empty header and\n // render their own paths in full.\n const prefix = key === '' ? '' : sorted.map((item) => parentDir(pathOf(item))).reduce(commonDir);\n groups.push({ prefix, items: sorted });\n }\n return groups.sort((left, right) => left.prefix.localeCompare(right.prefix));\n}\n\n/** What one row shows once its group's header has already said the shared part. */\nexport function groupRowLabel(prefix: string, relPath: string): string {\n return prefix === '' ? relPath : relPath.slice(prefix.length + 1);\n}\n"],"mappings":"AAmBA,SAASA,EAAU,EAAyB,CAC1C,IAAMC,EAAMC,EAAQ,YAAY,GAAG,EACnC,OAAOD,IAAQ,GAAK,GAAKC,EAAQ,MAAM,EAAGD,CAAG,CAC/C,CAGA,SAASE,EAAU,EAAc,EAAuB,CACtD,IAAMC,EAAYC,EAAK,MAAM,GAAG,EAC1BC,EAAaC,EAAM,MAAM,GAAG,EAC5BC,EAAmB,CAAC,EAC1B,IAAK,IAAIC,EAAQ,EAAGA,EAAQ,KAAK,IAAIL,EAAU,OAAQE,EAAW,MAAM,GAClEF,EAAUK,KAAWH,EAAWG,GADqC,GAAS,EAElFD,EAAO,KAAKJ,EAAUK,EAAM,EAE9B,OAAOD,EAAO,KAAK,GAAG,CACxB,CAGA,SAAgBE,EAAoB,EAAqB,EAA6C,CACpG,IAAMC,kBAAU,IAAI,IACpB,IAAK,IAAMC,KAAQC,EAAO,CACxB,IAAMX,EAAUY,EAAOF,CAAI,EACrBX,EAAMC,EAAQ,QAAQ,GAAG,EACzBa,EAAMd,IAAQ,GAAK,GAAKC,EAAQ,MAAM,EAAGD,CAAG,EAC5Ce,EAASL,EAAQ,IAAII,CAAG,EAC1BC,IAAW,IAAA,GAAWL,EAAQ,IAAII,EAAK,CAACH,CAAI,CAAC,EAC5CI,EAAO,KAAKJ,CAAI,CACvB,CACA,IAAMK,EAAyB,CAAC,EAChC,IAAK,GAAM,CAACF,EAAKC,KAAWL,EAAS,CACnC,IAAMO,EAAS,CAAC,GAAGF,CAAM,CAAC,CAAC,MAAM,EAAM,IAAUF,EAAOT,CAAI,CAAC,CAAC,cAAcS,EAAOP,CAAK,CAAC,CAAC,EAGpFY,EAASJ,IAAQ,GAAK,GAAKG,EAAO,IAAK,GAASlB,EAAUc,EAAOF,CAAI,CAAC,CAAC,CAAC,CAAC,OAAOT,CAAS,EAC/Fc,EAAO,KAAK,CAAE,SAAQ,MAAOC,CAAO,CAAC,CACvC,CACA,OAAOD,EAAO,MAAM,EAAM,IAAUZ,EAAK,OAAO,cAAcE,EAAM,MAAM,CAAC,CAC7E,CAGA,SAAgBa,EAAc,EAAgB,EAAyB,CACrE,OAAOD,IAAW,GAAKjB,EAAUA,EAAQ,MAAMiB,EAAO,OAAS,CAAC,CAClE,C"}
|
package/dist/src/lib/picker.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require("./optionList.cjs");
|
|
1
|
+
require("./optionList.cjs");let e=require("@agimon-ai/po-core/web");function t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>`${e.title} ${e.subtitle??``} ${e.value}`.toLowerCase().includes(n))}function n(e,t){return Math.max(0,e.findIndex(e=>t.includes(e.value)))}function r(e,t){let n=new Set(e);return n.delete(t)||n.add(t),n}function i(e,t){return e.size!==t.length||t.some(t=>!e.has(t))}function a(e,t){return e.filter(e=>t.has(e.value)).map(e=>e.value)}function o(t,n){return t?n?(0,e.t)(`webComponents.picker.hintToggleFiltered`,`enter toggles · tab to Apply`):(0,e.t)(`webComponents.picker.hintToggle`,`1-9, space or enter toggles · tab to Apply`):n?(0,e.t)(`webComponents.picker.hintPickFiltered`,`type to filter · enter picks`):(0,e.t)(`webComponents.picker.hintPick`,`1-9 or enter picks`)}function s(e,t){let{count:n,cursor:r,multiple:i,filterable:a}=t;if(e===`ArrowDown`||e===`ArrowUp`)return n===0?null:{kind:`move`,cursor:(r+(e===`ArrowDown`?1:-1)+n)%n};if(e===`Enter`)return n===0?null:{kind:`pick`,index:r};if(a)return null;if(e===` `&&i)return n===0?null:{kind:`pick`,index:r};let o=Number.parseInt(e,10)-1;return!Number.isInteger(o)||o<0||o>=Math.min(n,9)?null:{kind:`pick`,index:o}}exports.appliedValues=a,exports.draftChanged=i,exports.filterPickerItems=t,exports.initialPickerCursor=n,exports.pickerHint=o,exports.pickerKeyAction=s,exports.toggleDraft=r;
|
|
2
2
|
//# sourceMappingURL=picker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker.cjs","names":["filterPickerItems","needle","filter","items","item","initialPickerCursor","value","toggleDraft","next","draft","draftChanged","appliedValues","pickerHint","multiple","filterable","pickerKeyAction","state","key","count","cursor","index"],"sources":["../../../src/lib/picker.ts"],"sourcesContent":["import { MAX_DIGIT_SHORTCUT } from './optionList';\n\n/** What a picker row needs for matching and ordering; the view adds its own presentation. */\nexport interface PickerChoice {\n value: string;\n title: string;\n subtitle?: string;\n disabledReason?: string;\n}\n\n/** What a key does to a picker, decided apart from the DOM so it can be tested. */\nexport type PickerKeyAction = { kind: 'move'; cursor: number } | { kind: 'pick'; index: number };\n\n/** Rows whose title, subtitle or value contain the filter, case-insensitively. */\nexport function filterPickerItems<T extends PickerChoice>(items: readonly T[], filter: string): readonly T[] {\n const needle = filter.trim().toLowerCase();\n if (needle === '') return items;\n return items.filter((item) => `${item.title} ${item.subtitle ?? ''} ${item.value}`.toLowerCase().includes(needle));\n}\n\n/** Open on what is in effect, so Enter on a single choice keeps it. */\nexport function initialPickerCursor(items: readonly PickerChoice[], value: readonly string[]): number {\n return Math.max(\n 0,\n items.findIndex((item) => value.includes(item.value)),\n );\n}\n\n/** The draft with one value flipped. */\nexport function toggleDraft(draft: ReadonlySet<string>, value: string): Set<string> {\n const next = new Set(draft);\n if (!next.delete(value)) next.add(value);\n return next;\n}\n\n/** Whether the draft differs from what is in effect, which is what makes Apply worth pressing. */\nexport function draftChanged(draft: ReadonlySet<string>, value: readonly string[]): boolean {\n return draft.size !== value.length || value.some((item) => !draft.has(item));\n}\n\n/** The drafted values in the order they were offered, not the order they were clicked. */\nexport function appliedValues(items: readonly PickerChoice[], draft: ReadonlySet<string>): string[] {\n return items.filter((item) => draft.has(item.value)).map((item) => item.value);\n}\n\n/** The keys the footer promises, given the mode and whether a filter takes typing. */\nexport function pickerHint(multiple: boolean, filterable: boolean): string {\n if (multiple)
|
|
1
|
+
{"version":3,"file":"picker.cjs","names":["t","_agimon_ai_po_core_web","filterPickerItems","needle","filter","items","item","initialPickerCursor","value","toggleDraft","next","draft","draftChanged","appliedValues","pickerHint","multiple","filterable","pickerKeyAction","state","key","count","cursor","index"],"sources":["../../../src/lib/picker.ts"],"sourcesContent":["import { t } from '@agimon-ai/po-core/web';\n\nimport { MAX_DIGIT_SHORTCUT } from './optionList';\n\n/** What a picker row needs for matching and ordering; the view adds its own presentation. */\nexport interface PickerChoice {\n value: string;\n title: string;\n subtitle?: string;\n disabledReason?: string;\n}\n\n/** What a key does to a picker, decided apart from the DOM so it can be tested. */\nexport type PickerKeyAction = { kind: 'move'; cursor: number } | { kind: 'pick'; index: number };\n\n/** Rows whose title, subtitle or value contain the filter, case-insensitively. */\nexport function filterPickerItems<T extends PickerChoice>(items: readonly T[], filter: string): readonly T[] {\n const needle = filter.trim().toLowerCase();\n if (needle === '') return items;\n return items.filter((item) => `${item.title} ${item.subtitle ?? ''} ${item.value}`.toLowerCase().includes(needle));\n}\n\n/** Open on what is in effect, so Enter on a single choice keeps it. */\nexport function initialPickerCursor(items: readonly PickerChoice[], value: readonly string[]): number {\n return Math.max(\n 0,\n items.findIndex((item) => value.includes(item.value)),\n );\n}\n\n/** The draft with one value flipped. */\nexport function toggleDraft(draft: ReadonlySet<string>, value: string): Set<string> {\n const next = new Set(draft);\n if (!next.delete(value)) next.add(value);\n return next;\n}\n\n/** Whether the draft differs from what is in effect, which is what makes Apply worth pressing. */\nexport function draftChanged(draft: ReadonlySet<string>, value: readonly string[]): boolean {\n return draft.size !== value.length || value.some((item) => !draft.has(item));\n}\n\n/** The drafted values in the order they were offered, not the order they were clicked. */\nexport function appliedValues(items: readonly PickerChoice[], draft: ReadonlySet<string>): string[] {\n return items.filter((item) => draft.has(item.value)).map((item) => item.value);\n}\n\n/** The keys the footer promises, given the mode and whether a filter takes typing. */\nexport function pickerHint(multiple: boolean, filterable: boolean): string {\n if (multiple)\n return filterable\n ? t('webComponents.picker.hintToggleFiltered', 'enter toggles · tab to Apply')\n : t('webComponents.picker.hintToggle', '1-9, space or enter toggles · tab to Apply');\n return filterable\n ? t('webComponents.picker.hintPickFiltered', 'type to filter · enter picks')\n : t('webComponents.picker.hintPick', '1-9 or enter picks');\n}\n\n/**\n * The action a key asks for, or null to leave it alone. Digits jump to a row\n * only without a filter, which would otherwise take them as typing; space\n * toggles a multiple choice for the same reason.\n */\nexport function pickerKeyAction(\n key: string,\n state: { count: number; cursor: number; multiple: boolean; filterable: boolean },\n): PickerKeyAction | null {\n const { count, cursor, multiple, filterable } = state;\n if (key === 'ArrowDown' || key === 'ArrowUp') {\n if (count === 0) return null;\n return { kind: 'move', cursor: (cursor + (key === 'ArrowDown' ? 1 : -1) + count) % count };\n }\n if (key === 'Enter') return count === 0 ? null : { kind: 'pick', index: cursor };\n if (filterable) return null;\n if (key === ' ' && multiple) return count === 0 ? null : { kind: 'pick', index: cursor };\n const index = Number.parseInt(key, 10) - 1;\n if (!Number.isInteger(index) || index < 0 || index >= Math.min(count, MAX_DIGIT_SHORTCUT)) return null;\n return { kind: 'pick', index };\n}\n"],"mappings":"A,oEAgBA,SAAgBE,EAA0C,EAAqB,EAA8B,CAC3G,IAAMC,EAASC,EAAO,KAAK,CAAC,CAAC,YAAY,EAEzC,OADID,IAAW,GAAWE,EACnBA,EAAM,OAAQ,GAAS,GAAGC,EAAK,MAAM,GAAGA,EAAK,UAAY,GAAG,GAAGA,EAAK,QAAQ,YAAY,CAAC,CAAC,SAASH,CAAM,CAAC,CACnH,CAGA,SAAgBI,EAAoB,EAAgC,EAAkC,CACpG,OAAO,KAAK,IACV,EACAF,EAAM,UAAW,GAASG,EAAM,SAASF,EAAK,KAAK,CAAC,CACtD,CACF,CAGA,SAAgBG,EAAY,EAA4B,EAA4B,CAClF,IAAMC,EAAO,IAAI,IAAIC,CAAK,EAE1B,OADKD,EAAK,OAAOF,CAAK,GAAGE,EAAK,IAAIF,CAAK,EAChCE,CACT,CAGA,SAAgBE,EAAa,EAA4B,EAAmC,CAC1F,OAAOD,EAAM,OAASH,EAAM,QAAUA,EAAM,KAAM,GAAS,CAACG,EAAM,IAAIL,CAAI,CAAC,CAC7E,CAGA,SAAgBO,EAAc,EAAgC,EAAsC,CAClG,OAAOR,EAAM,OAAQ,GAASM,EAAM,IAAIL,EAAK,KAAK,CAAC,CAAC,CAAC,IAAK,GAASA,EAAK,KAAK,CAC/E,CAGA,SAAgBQ,EAAW,EAAmB,EAA6B,CAKzE,OAJIC,EACKC,GAAA,EACHhB,EAAAA,EAAAA,CAAE,0CAA2C,8BAA8B,GAAA,EAC3EA,EAAAA,EAAAA,CAAE,kCAAmC,4CAA4C,EAChFgB,GAAA,EACHhB,EAAAA,EAAAA,CAAE,wCAAyC,8BAA8B,GAAA,EACzEA,EAAAA,EAAAA,CAAE,gCAAiC,oBAAoB,CAC7D,CAOA,SAAgBiB,EACd,EACA,EACwB,CACxB,GAAM,CAAE,QAAO,SAAQ,WAAU,cAAeC,EAChD,GAAIC,IAAQ,aAAeA,IAAQ,UAEjC,OADIC,IAAU,EAAU,KACjB,CAAE,KAAM,OAAQ,QAASC,GAAUF,IAAQ,YAAc,EAAI,IAAMC,GAASA,CAAM,EAE3F,GAAID,IAAQ,QAAS,OAAOC,IAAU,EAAI,KAAO,CAAE,KAAM,OAAQ,MAAOC,CAAO,EAC/E,GAAIL,EAAY,OAAO,KACvB,GAAIG,IAAQ,KAAOJ,EAAU,OAAOK,IAAU,EAAI,KAAO,CAAE,KAAM,OAAQ,MAAOC,CAAO,EACvF,IAAMC,EAAQ,OAAO,SAASH,EAAK,EAAE,EAAI,EAEzC,MADI,CAAC,OAAO,UAAUG,CAAK,GAAKA,EAAQ,GAAKA,GAAS,KAAK,IAAIF,EAAA,CAAyB,EAAU,KAC3F,CAAE,KAAM,OAAQ,OAAM,CAC/B,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.d.mts","names":[],"sources":["../../../src/lib/picker.ts"],"mappings":";;iBAKiB;EACf;EACA;EACA;EACA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./optionList.mjs";import{t as e}from"@agimon-ai/po-core/web";function t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>`${e.title} ${e.subtitle??``} ${e.value}`.toLowerCase().includes(n))}function n(e,t){return Math.max(0,e.findIndex(e=>t.includes(e.value)))}function r(e,t){let n=new Set(e);return n.delete(t)||n.add(t),n}function i(e,t){return e.size!==t.length||t.some(t=>!e.has(t))}function a(e,t){return e.filter(e=>t.has(e.value)).map(e=>e.value)}function o(t,n){return t?n?e(`webComponents.picker.hintToggleFiltered`,`enter toggles · tab to Apply`):e(`webComponents.picker.hintToggle`,`1-9, space or enter toggles · tab to Apply`):n?e(`webComponents.picker.hintPickFiltered`,`type to filter · enter picks`):e(`webComponents.picker.hintPick`,`1-9 or enter picks`)}function s(e,t){let{count:n,cursor:r,multiple:i,filterable:a}=t;if(e===`ArrowDown`||e===`ArrowUp`)return n===0?null:{kind:`move`,cursor:(r+(e===`ArrowDown`?1:-1)+n)%n};if(e===`Enter`)return n===0?null:{kind:`pick`,index:r};if(a)return null;if(e===` `&&i)return n===0?null:{kind:`pick`,index:r};let o=Number.parseInt(e,10)-1;return!Number.isInteger(o)||o<0||o>=Math.min(n,9)?null:{kind:`pick`,index:o}}export{a as appliedValues,i as draftChanged,t as filterPickerItems,n as initialPickerCursor,o as pickerHint,s as pickerKeyAction,r as toggleDraft};
|
|
2
|
+
//# sourceMappingURL=picker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.mjs","names":["filterPickerItems","needle","filter","items","item","initialPickerCursor","value","toggleDraft","next","draft","draftChanged","appliedValues","pickerHint","multiple","filterable","t","pickerKeyAction","state","key","count","cursor","index"],"sources":["../../../src/lib/picker.ts"],"sourcesContent":["import { t } from '@agimon-ai/po-core/web';\n\nimport { MAX_DIGIT_SHORTCUT } from './optionList';\n\n/** What a picker row needs for matching and ordering; the view adds its own presentation. */\nexport interface PickerChoice {\n value: string;\n title: string;\n subtitle?: string;\n disabledReason?: string;\n}\n\n/** What a key does to a picker, decided apart from the DOM so it can be tested. */\nexport type PickerKeyAction = { kind: 'move'; cursor: number } | { kind: 'pick'; index: number };\n\n/** Rows whose title, subtitle or value contain the filter, case-insensitively. */\nexport function filterPickerItems<T extends PickerChoice>(items: readonly T[], filter: string): readonly T[] {\n const needle = filter.trim().toLowerCase();\n if (needle === '') return items;\n return items.filter((item) => `${item.title} ${item.subtitle ?? ''} ${item.value}`.toLowerCase().includes(needle));\n}\n\n/** Open on what is in effect, so Enter on a single choice keeps it. */\nexport function initialPickerCursor(items: readonly PickerChoice[], value: readonly string[]): number {\n return Math.max(\n 0,\n items.findIndex((item) => value.includes(item.value)),\n );\n}\n\n/** The draft with one value flipped. */\nexport function toggleDraft(draft: ReadonlySet<string>, value: string): Set<string> {\n const next = new Set(draft);\n if (!next.delete(value)) next.add(value);\n return next;\n}\n\n/** Whether the draft differs from what is in effect, which is what makes Apply worth pressing. */\nexport function draftChanged(draft: ReadonlySet<string>, value: readonly string[]): boolean {\n return draft.size !== value.length || value.some((item) => !draft.has(item));\n}\n\n/** The drafted values in the order they were offered, not the order they were clicked. */\nexport function appliedValues(items: readonly PickerChoice[], draft: ReadonlySet<string>): string[] {\n return items.filter((item) => draft.has(item.value)).map((item) => item.value);\n}\n\n/** The keys the footer promises, given the mode and whether a filter takes typing. */\nexport function pickerHint(multiple: boolean, filterable: boolean): string {\n if (multiple)\n return filterable\n ? t('webComponents.picker.hintToggleFiltered', 'enter toggles · tab to Apply')\n : t('webComponents.picker.hintToggle', '1-9, space or enter toggles · tab to Apply');\n return filterable\n ? t('webComponents.picker.hintPickFiltered', 'type to filter · enter picks')\n : t('webComponents.picker.hintPick', '1-9 or enter picks');\n}\n\n/**\n * The action a key asks for, or null to leave it alone. Digits jump to a row\n * only without a filter, which would otherwise take them as typing; space\n * toggles a multiple choice for the same reason.\n */\nexport function pickerKeyAction(\n key: string,\n state: { count: number; cursor: number; multiple: boolean; filterable: boolean },\n): PickerKeyAction | null {\n const { count, cursor, multiple, filterable } = state;\n if (key === 'ArrowDown' || key === 'ArrowUp') {\n if (count === 0) return null;\n return { kind: 'move', cursor: (cursor + (key === 'ArrowDown' ? 1 : -1) + count) % count };\n }\n if (key === 'Enter') return count === 0 ? null : { kind: 'pick', index: cursor };\n if (filterable) return null;\n if (key === ' ' && multiple) return count === 0 ? null : { kind: 'pick', index: cursor };\n const index = Number.parseInt(key, 10) - 1;\n if (!Number.isInteger(index) || index < 0 || index >= Math.min(count, MAX_DIGIT_SHORTCUT)) return null;\n return { kind: 'pick', index };\n}\n"],"mappings":"A,oEAgBA,SAAgBA,EAA0C,EAAqB,EAA8B,CAC3G,IAAMC,EAASC,EAAO,KAAK,CAAC,CAAC,YAAY,EAEzC,OADID,IAAW,GAAWE,EACnBA,EAAM,OAAQ,GAAS,GAAGC,EAAK,MAAM,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EACvF,IAAMC,EAAQ,OAAO,SAASH,EAAK,EAAE,EAAI,EAEzC,MADI,CAAC,OAAO,UAAUG,CAAK,GAAKA,EAAQ,GAAKA,GAAS,KAAK,IAAIF,EAAA,CAAyB,EAAU,KAC3F,CAAE,KAAM,OAAQ,OAAM,CAC/B,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("@agimon-ai/po-core/web");const t=`default`,n=`none`,r=`profile:`;function i(e){return e===void 0?t:e===null?n:`${r}${e}`}function a(e){if(e===`none`)return null;if(e.startsWith(r))return e.slice(8)}function o(e){return e.identity?.name||e.name}function s(e){return[e.identity?.role,e.identity?.contact].filter(Boolean).join(` · `)||(o(e)===e.name?void 0:e.name)}function c(r){return[{value:t,title:(0,e.t)(`webComponents.profilePicker.default`,`Workspace default`),subtitle:(0,e.t)(`webComponents.profilePicker.defaultSubtitle`,`Use what this workspace sets, if anything`)},{value:n,title:(0,e.t)(`webComponents.profilePicker.none`,`No profile`),subtitle:(0,e.t)(`webComponents.profilePicker.noneSubtitle`,`Start without a profile`)},...r.map(e=>{let t=s(e);return{value:i(e.name),title:o(e),...t===void 0?{}:{subtitle:t}}})]}function l(t,n){if(t===void 0)return(0,e.t)(`webComponents.profilePicker.default`,`Workspace default`);if(t===null)return(0,e.t)(`webComponents.profilePicker.none`,`No profile`);let r=n.find(e=>e.name===t);return r===void 0?t:o(r)}const u=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/;function d(e){return typeof e==`string`&&e.length<=262144&&u.test(e)?e:void 0}function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){if(!f(e)||typeof e.name!=`string`||e.name===``||typeof e.sourceId!=`string`||e.sourceId===``)return;let t=f(e.identity)?e.identity:void 0,n={};for(let e of[`name`,`icon`,`role`,`contact`]){let r=t?.[e];if(e===`icon`){let e=d(r);e&&(n.icon=e)}else typeof r==`string`&&r!==``&&(n[e]=r)}return{name:e.name,sourceId:e.sourceId,...Object.keys(n).length===0?{}:{identity:n}}}function m(e){if(!f(e)||!Array.isArray(e.profiles)||e.readiness!==`ready`&&e.readiness!==`unavailable`)return;let t=/* @__PURE__ */ new Set,n=[];for(let r of e.profiles){let e=p(r);e===void 0||t.has(e.name)||(t.add(e.name),n.push(e))}return{profiles:n,readiness:e.readiness}}const h={status:`unavailable`,profiles:[]};async function g(e,t){let n;try{n=await e(t)}catch{n=void 0}if(t.aborted)return;let r=m(n);return r===void 0?h:{status:r.readiness,profiles:r.profiles}}exports.DEFAULT_PROFILE_VALUE=t,exports.NO_PROFILE_VALUE=n,exports.inlineProfileIcon=d,exports.loadProfileCatalog=g,exports.parseProfileCatalog=m,exports.profileChoiceLabel=l,exports.profileChoiceOf=a,exports.profilePickerItems=c,exports.profileValueOf=i;
|
|
2
|
+
//# sourceMappingURL=profilePicker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profilePicker.cjs","names":["t","_agimon_ai_po_core_web","DEFAULT_PROFILE_VALUE","NO_PROFILE_VALUE","PROFILE_PREFIX","profileValueOf","choice","profileChoiceOf","value","titleOf","profile","subtitleOf","profilePickerItems","profiles","subtitle","profileChoiceLabel","candidate","INLINE_ICON","inlineProfileIcon","isRecord","profileOf","identity","presented","key","field","icon","parseProfileCatalog","seen","entry","UNAVAILABLE","loadProfileCatalog","answer","load","signal","catalog"],"sources":["../../../src/lib/profilePicker.ts"],"sourcesContent":["import { t } from '@agimon-ai/po-core/web';\n\nimport type { PickerChoice } from './picker';\n\n/**\n * The launch-time profile choice a person makes before a session exists.\n *\n * `undefined` is \"not chosen\": the workspace default may apply. `null` is an\n * explicit \"No profile\", which no default may override. A string names a profile.\n */\nexport type ProfileChoice = string | null | undefined;\n\n/** What the picker may know about a profile. Never its environment, persona, bindings or secrets. */\nexport interface ProfilePickerProfile {\n readonly name: string;\n /** Presentation only: `role` is what the persona does, `contact` a display-only address its source supplies. */\n readonly identity?: {\n readonly name?: string;\n readonly icon?: string;\n readonly role?: string;\n readonly contact?: string;\n };\n /** `files` for a profile file, otherwise the id of the plugin that contributed it. */\n readonly sourceId: string;\n}\n\nexport interface ProfilePickerCatalog {\n readonly profiles: readonly ProfilePickerProfile[];\n /** `unavailable`: a source did not become ready in time or failed. `profiles` lists what loaded. */\n readonly readiness: 'ready' | 'unavailable';\n}\n\nexport type ProfilePickerStatus = 'loading' | ProfilePickerCatalog['readiness'];\n\nexport interface ProfilePickerState {\n readonly status: Exclude<ProfilePickerStatus, 'loading'>;\n readonly profiles: readonly ProfilePickerProfile[];\n}\n\n/** Row values carry a prefix, so a profile named \"none\" or \"default\" cannot pass for a choice. */\nexport const DEFAULT_PROFILE_VALUE = 'default';\nexport const NO_PROFILE_VALUE = 'none';\nconst PROFILE_PREFIX = 'profile:';\n\nexport const DEFAULT_PROFILE_LABEL = 'Workspace default';\nexport const NO_PROFILE_LABEL = 'No profile';\n\nexport function profileValueOf(choice: ProfileChoice): string {\n if (choice === undefined) return DEFAULT_PROFILE_VALUE;\n if (choice === null) return NO_PROFILE_VALUE;\n return `${PROFILE_PREFIX}${choice}`;\n}\n\nexport function profileChoiceOf(value: string): ProfileChoice {\n if (value === NO_PROFILE_VALUE) return null;\n if (value.startsWith(PROFILE_PREFIX)) return value.slice(PROFILE_PREFIX.length);\n return undefined;\n}\n\nfunction titleOf(profile: ProfilePickerProfile): string {\n return profile.identity?.name || profile.name;\n}\n\n/** Role and contact under the name, otherwise the profile name when the title hides it. */\nfunction subtitleOf(profile: ProfilePickerProfile): string | undefined {\n const presented = [profile.identity?.role, profile.identity?.contact].filter(Boolean).join(' · ');\n if (presented) return presented;\n return titleOf(profile) === profile.name ? undefined : profile.name;\n}\n\n/** The workspace default and No profile first, then every profile in the order given. Nothing is preselected. */\nexport function profilePickerItems(profiles: readonly ProfilePickerProfile[]): PickerChoice[] {\n return [\n {\n value: DEFAULT_PROFILE_VALUE,\n title: t('webComponents.profilePicker.default', 'Workspace default'),\n subtitle: t('webComponents.profilePicker.defaultSubtitle', 'Use what this workspace sets, if anything'),\n },\n {\n value: NO_PROFILE_VALUE,\n title: t('webComponents.profilePicker.none', 'No profile'),\n subtitle: t('webComponents.profilePicker.noneSubtitle', 'Start without a profile'),\n },\n ...profiles.map((profile) => {\n const subtitle = subtitleOf(profile);\n return {\n value: profileValueOf(profile.name),\n title: titleOf(profile),\n ...(subtitle === undefined ? {} : { subtitle }),\n };\n }),\n ];\n}\n\nexport function profileChoiceLabel(choice: ProfileChoice, profiles: readonly ProfilePickerProfile[]): string {\n if (choice === undefined) return t('webComponents.profilePicker.default', 'Workspace default');\n if (choice === null) return t('webComponents.profilePicker.none', 'No profile');\n const profile = profiles.find((candidate) => candidate.name === choice);\n return profile === undefined ? choice : titleOf(profile);\n}\n\nconst INLINE_ICON = /^data:image\\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/;\n/** po-core's `PROFILE_ICON_MAX_DATA_URL_LENGTH`. */\nconst MAX_INLINE_ICON_LENGTH = 262_144;\n\n/**\n * A profile avatar the page may draw: an inline PNG, JPEG, GIF or WebP `data:` URL within po-core's\n * bound, so rendering never contacts a host and never runs an SVG. Anything else is undefined.\n */\nexport function inlineProfileIcon(value: unknown): string | undefined {\n return typeof value === 'string' && value.length <= MAX_INLINE_ICON_LENGTH && INLINE_ICON.test(value)\n ? value\n : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction profileOf(value: unknown): ProfilePickerProfile | undefined {\n if (!isRecord(value) || typeof value.name !== 'string' || value.name === '') return undefined;\n if (typeof value.sourceId !== 'string' || value.sourceId === '') return undefined;\n const identity = isRecord(value.identity) ? value.identity : undefined;\n const presented: Record<string, string> = {};\n for (const key of ['name', 'icon', 'role', 'contact'] as const) {\n const field = identity?.[key];\n if (key === 'icon') {\n const icon = inlineProfileIcon(field);\n if (icon) presented.icon = icon;\n } else if (typeof field === 'string' && field !== '') presented[key] = field;\n }\n return {\n name: value.name,\n sourceId: value.sourceId,\n ...(Object.keys(presented).length === 0 ? {} : { identity: presented }),\n };\n}\n\n/**\n * A server answer reduced to the fields the picker may show, or undefined when it is not a catalog.\n * Any other field is dropped here, so nothing sensitive a server mistakenly adds can reach the page.\n */\nexport function parseProfileCatalog(value: unknown): ProfilePickerCatalog | undefined {\n if (!isRecord(value) || !Array.isArray(value.profiles)) return undefined;\n if (value.readiness !== 'ready' && value.readiness !== 'unavailable') return undefined;\n const seen = new Set<string>();\n const profiles: ProfilePickerProfile[] = [];\n for (const entry of value.profiles) {\n const profile = profileOf(entry);\n if (profile === undefined || seen.has(profile.name)) continue;\n seen.add(profile.name);\n profiles.push(profile);\n }\n return { profiles, readiness: value.readiness };\n}\n\nconst UNAVAILABLE: ProfilePickerState = { status: 'unavailable', profiles: [] };\n\n/**\n * Runs one catalog request. A failed or malformed answer is \"unavailable\" with nothing listed, so a\n * session can still start without a profile. Undefined means the caller gave up on this request.\n */\nexport async function loadProfileCatalog(\n load: (signal: AbortSignal) => Promise<unknown>,\n signal: AbortSignal,\n): Promise<ProfilePickerState | undefined> {\n let answer: unknown;\n try {\n answer = await load(signal);\n } catch {\n answer = undefined;\n }\n if (signal.aborted) return undefined;\n const catalog = parseProfileCatalog(answer);\n return catalog === undefined ? UNAVAILABLE : { status: catalog.readiness, profiles: catalog.profiles };\n}\n"],"mappings":"A,wCAwCA,MAAaE,EAAwB,UACxBC,EAAmB,OAC1BC,EAAiB,WAKvB,SAAgBC,EAAe,EAA+B,CAG5D,OAFIC,IAAW,IAAA,GAAkBJ,EAC7BI,IAAW,KAAaH,EACrB,GAAGC,IAAiBE,GAC7B,CAEA,SAAgBC,EAAgB,EAA8B,CAC5D,GAAIC,IAAA,OAA4B,OAAO,KACvC,GAAIA,EAAM,WAAWJ,CAAc,EAAG,OAAOI,EAAM,MAAM,CAAqB,CAEhF,CAEA,SAASC,EAAQ,EAAuC,CACtD,OAAOC,EAAQ,UAAU,MAAQA,EAAQ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J,GAAI,CACF,EAAS,MAAMC,EAAKC,CAAM,CAC5B,MAAQ,CACN,EAAS,IAAA,EACX,CACA,GAAIA,EAAO,QAAS,OACpB,IAAMC,EAAUR,EAAoBK,CAAM,EAC1C,OAAOG,IAAY,IAAA,GAAYL,EAAc,CAAE,OAAQK,EAAQ,UAAW,SAAUA,EAAQ,QAAS,CACvG,C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/lib/profilePicker.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The launch-time profile choice a person makes before a session exists.
|
|
4
|
+
*
|
|
5
|
+
* `undefined` is "not chosen": the workspace default may apply. `null` is an
|
|
6
|
+
* explicit "No profile", which no default may override. A string names a profile.
|
|
7
|
+
*/
|
|
8
|
+
export type ProfileChoice = string | null | undefined;
|
|
9
|
+
/** What the picker may know about a profile. Never its environment, persona, bindings or secrets. */
|
|
10
|
+
export interface ProfilePickerProfile {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/** Presentation only: `role` is what the persona does, `contact` a display-only address its source supplies. */
|
|
13
|
+
readonly identity?: {
|
|
14
|
+
readonly name?: string;
|
|
15
|
+
readonly icon?: string;
|
|
16
|
+
readonly role?: string;
|
|
17
|
+
readonly contact?: string;
|
|
18
|
+
};
|
|
19
|
+
/** `files` for a profile file, otherwise the id of the plugin that contributed it. */
|
|
20
|
+
readonly sourceId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ProfilePickerCatalog {
|
|
23
|
+
readonly profiles: readonly ProfilePickerProfile[];
|
|
24
|
+
/** `unavailable`: a source did not become ready in time or failed. `profiles` lists what loaded. */
|
|
25
|
+
readonly readiness: 'ready' | 'unavailable';
|
|
26
|
+
}
|
|
27
|
+
export type ProfilePickerStatus = 'loading' | ProfilePickerCatalog['readiness'];
|
|
28
|
+
export interface ProfilePickerState {
|
|
29
|
+
readonly status: Exclude<ProfilePickerStatus, 'loading'>;
|
|
30
|
+
readonly profiles: readonly ProfilePickerProfile[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A profile avatar the page may draw: an inline PNG, JPEG, GIF or WebP `data:` URL within po-core's
|
|
34
|
+
* bound, so rendering never contacts a host and never runs an SVG. Anything else is undefined.
|
|
35
|
+
*/
|
|
36
|
+
export declare function inlineProfileIcon(value: unknown): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* A server answer reduced to the fields the picker may show, or undefined when it is not a catalog.
|
|
39
|
+
* Any other field is dropped here, so nothing sensitive a server mistakenly adds can reach the page.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseProfileCatalog(value: unknown): ProfilePickerCatalog | undefined;
|
|
42
|
+
//#endregion
|
|
43
|
+
//# sourceMappingURL=profilePicker.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profilePicker.d.mts","names":[],"sources":["../../../src/lib/profilePicker.ts"],"mappings":";;;;;;;YAUY;;iBAGK;WACN;;WAEA;aACE;aACA;aACA;aACA;;;WAGF;;iBAGM;WACN,mBAAmB;;WAEnB;;YAGC,kCAAkC;iBAE7B;WACN,QAAQ,QAAQ;WAChB,mBAAmB;;;;;;wBAyEd,kBAAkB;;;;;wBAiClB,oBAAoB,iBAAiB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"@agimon-ai/po-core/web";const t=`default`,n=`none`,r=`profile:`;function i(e){return e===void 0?t:e===null?n:`${r}${e}`}function a(e){if(e===`none`)return null;if(e.startsWith(r))return e.slice(8)}function o(e){return e.identity?.name||e.name}function s(e){return[e.identity?.role,e.identity?.contact].filter(Boolean).join(` · `)||(o(e)===e.name?void 0:e.name)}function c(r){return[{value:t,title:e(`webComponents.profilePicker.default`,`Workspace default`),subtitle:e(`webComponents.profilePicker.defaultSubtitle`,`Use what this workspace sets, if anything`)},{value:n,title:e(`webComponents.profilePicker.none`,`No profile`),subtitle:e(`webComponents.profilePicker.noneSubtitle`,`Start without a profile`)},...r.map(e=>{let t=s(e);return{value:i(e.name),title:o(e),...t===void 0?{}:{subtitle:t}}})]}function l(t,n){if(t===void 0)return e(`webComponents.profilePicker.default`,`Workspace default`);if(t===null)return e(`webComponents.profilePicker.none`,`No profile`);let r=n.find(e=>e.name===t);return r===void 0?t:o(r)}const u=/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/;function d(e){return typeof e==`string`&&e.length<=262144&&u.test(e)?e:void 0}function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){if(!f(e)||typeof e.name!=`string`||e.name===``||typeof e.sourceId!=`string`||e.sourceId===``)return;let t=f(e.identity)?e.identity:void 0,n={};for(let e of[`name`,`icon`,`role`,`contact`]){let r=t?.[e];if(e===`icon`){let e=d(r);e&&(n.icon=e)}else typeof r==`string`&&r!==``&&(n[e]=r)}return{name:e.name,sourceId:e.sourceId,...Object.keys(n).length===0?{}:{identity:n}}}function m(e){if(!f(e)||!Array.isArray(e.profiles)||e.readiness!==`ready`&&e.readiness!==`unavailable`)return;let t=/* @__PURE__ */ new Set,n=[];for(let r of e.profiles){let e=p(r);e===void 0||t.has(e.name)||(t.add(e.name),n.push(e))}return{profiles:n,readiness:e.readiness}}const h={status:`unavailable`,profiles:[]};async function g(e,t){let n;try{n=await e(t)}catch{n=void 0}if(t.aborted)return;let r=m(n);return r===void 0?h:{status:r.readiness,profiles:r.profiles}}export{t as DEFAULT_PROFILE_VALUE,n as NO_PROFILE_VALUE,d as inlineProfileIcon,g as loadProfileCatalog,m as parseProfileCatalog,l as profileChoiceLabel,a as profileChoiceOf,c as profilePickerItems,i as profileValueOf};
|
|
2
|
+
//# sourceMappingURL=profilePicker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profilePicker.mjs","names":["DEFAULT_PROFILE_VALUE","NO_PROFILE_VALUE","PROFILE_PREFIX","profileValueOf","choice","profileChoiceOf","value","titleOf","profile","subtitleOf","profilePickerItems","t","profiles","subtitle","profileChoiceLabel","candidate","INLINE_ICON","inlineProfileIcon","isRecord","profileOf","identity","presented","key","field","icon","parseProfileCatalog","seen","entry","UNAVAILABLE","loadProfileCatalog","answer","load","signal","catalog"],"sources":["../../../src/lib/profilePicker.ts"],"sourcesContent":["import { t } from '@agimon-ai/po-core/web';\n\nimport type { PickerChoice } from './picker';\n\n/**\n * The launch-time profile choice a person makes before a session exists.\n *\n * `undefined` is \"not chosen\": the workspace default may apply. `null` is an\n * explicit \"No profile\", which no default may override. A string names a profile.\n */\nexport type ProfileChoice = string | null | undefined;\n\n/** What the picker may know about a profile. Never its environment, persona, bindings or secrets. */\nexport interface ProfilePickerProfile {\n readonly name: string;\n /** Presentation only: `role` is what the persona does, `contact` a display-only address its source supplies. */\n readonly identity?: {\n readonly name?: string;\n readonly icon?: string;\n readonly role?: string;\n readonly contact?: string;\n };\n /** `files` for a profile file, otherwise the id of the plugin that contributed it. */\n readonly sourceId: string;\n}\n\nexport interface ProfilePickerCatalog {\n readonly profiles: readonly ProfilePickerProfile[];\n /** `unavailable`: a source did not become ready in time or failed. `profiles` lists what loaded. */\n readonly readiness: 'ready' | 'unavailable';\n}\n\nexport type ProfilePickerStatus = 'loading' | ProfilePickerCatalog['readiness'];\n\nexport interface ProfilePickerState {\n readonly status: Exclude<ProfilePickerStatus, 'loading'>;\n readonly profiles: readonly ProfilePickerProfile[];\n}\n\n/** Row values carry a prefix, so a profile named \"none\" or \"default\" cannot pass for a choice. */\nexport const DEFAULT_PROFILE_VALUE = 'default';\nexport const NO_PROFILE_VALUE = 'none';\nconst PROFILE_PREFIX = 'profile:';\n\nexport const DEFAULT_PROFILE_LABEL = 'Workspace default';\nexport const NO_PROFILE_LABEL = 'No profile';\n\nexport function profileValueOf(choice: ProfileChoice): string {\n if (choice === undefined) return DEFAULT_PROFILE_VALUE;\n if (choice === null) return NO_PROFILE_VALUE;\n return `${PROFILE_PREFIX}${choice}`;\n}\n\nexport function profileChoiceOf(value: string): ProfileChoice {\n if (value === NO_PROFILE_VALUE) return null;\n if (value.startsWith(PROFILE_PREFIX)) return value.slice(PROFILE_PREFIX.length);\n return undefined;\n}\n\nfunction titleOf(profile: ProfilePickerProfile): string {\n return profile.identity?.name || profile.name;\n}\n\n/** Role and contact under the name, otherwise the profile name when the title hides it. */\nfunction subtitleOf(profile: ProfilePickerProfile): string | undefined {\n const presented = [profile.identity?.role, profile.identity?.contact].filter(Boolean).join(' · ');\n if (presented) return presented;\n return titleOf(profile) === profile.name ? undefined : profile.name;\n}\n\n/** The workspace default and No profile first, then every profile in the order given. Nothing is preselected. */\nexport function profilePickerItems(profiles: readonly ProfilePickerProfile[]): PickerChoice[] {\n return [\n {\n value: DEFAULT_PROFILE_VALUE,\n title: t('webComponents.profilePicker.default', 'Workspace default'),\n subtitle: t('webComponents.profilePicker.defaultSubtitle', 'Use what this workspace sets, if anything'),\n },\n {\n value: NO_PROFILE_VALUE,\n title: t('webComponents.profilePicker.none', 'No profile'),\n subtitle: t('webComponents.profilePicker.noneSubtitle', 'Start without a profile'),\n },\n ...profiles.map((profile) => {\n const subtitle = subtitleOf(profile);\n return {\n value: profileValueOf(profile.name),\n title: titleOf(profile),\n ...(subtitle === undefined ? {} : { subtitle }),\n };\n }),\n ];\n}\n\nexport function profileChoiceLabel(choice: ProfileChoice, profiles: readonly ProfilePickerProfile[]): string {\n if (choice === undefined) return t('webComponents.profilePicker.default', 'Workspace default');\n if (choice === null) return t('webComponents.profilePicker.none', 'No profile');\n const profile = profiles.find((candidate) => candidate.name === choice);\n return profile === undefined ? choice : titleOf(profile);\n}\n\nconst INLINE_ICON = /^data:image\\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/;\n/** po-core's `PROFILE_ICON_MAX_DATA_URL_LENGTH`. */\nconst MAX_INLINE_ICON_LENGTH = 262_144;\n\n/**\n * A profile avatar the page may draw: an inline PNG, JPEG, GIF or WebP `data:` URL within po-core's\n * bound, so rendering never contacts a host and never runs an SVG. Anything else is undefined.\n */\nexport function inlineProfileIcon(value: unknown): string | undefined {\n return typeof value === 'string' && value.length <= MAX_INLINE_ICON_LENGTH && INLINE_ICON.test(value)\n ? value\n : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction profileOf(value: unknown): ProfilePickerProfile | undefined {\n if (!isRecord(value) || typeof value.name !== 'string' || value.name === '') return undefined;\n if (typeof value.sourceId !== 'string' || value.sourceId === '') return undefined;\n const identity = isRecord(value.identity) ? value.identity : undefined;\n const presented: Record<string, string> = {};\n for (const key of ['name', 'icon', 'role', 'contact'] as const) {\n const field = identity?.[key];\n if (key === 'icon') {\n const icon = inlineProfileIcon(field);\n if (icon) presented.icon = icon;\n } else if (typeof field === 'string' && field !== '') presented[key] = field;\n }\n return {\n name: value.name,\n sourceId: value.sourceId,\n ...(Object.keys(presented).length === 0 ? {} : { identity: presented }),\n };\n}\n\n/**\n * A server answer reduced to the fields the picker may show, or undefined when it is not a catalog.\n * Any other field is dropped here, so nothing sensitive a server mistakenly adds can reach the page.\n */\nexport function parseProfileCatalog(value: unknown): ProfilePickerCatalog | undefined {\n if (!isRecord(value) || !Array.isArray(value.profiles)) return undefined;\n if (value.readiness !== 'ready' && value.readiness !== 'unavailable') return undefined;\n const seen = new Set<string>();\n const profiles: ProfilePickerProfile[] = [];\n for (const entry of value.profiles) {\n const profile = profileOf(entry);\n if (profile === undefined || seen.has(profile.name)) continue;\n seen.add(profile.name);\n profiles.push(profile);\n }\n return { profiles, readiness: value.readiness };\n}\n\nconst UNAVAILABLE: ProfilePickerState = { status: 'unavailable', profiles: [] };\n\n/**\n * Runs one catalog request. A failed or malformed answer is \"unavailable\" with nothing listed, so a\n * session can still start without a profile. Undefined means the caller gave up on this request.\n */\nexport async function loadProfileCatalog(\n load: (signal: AbortSignal) => Promise<unknown>,\n signal: AbortSignal,\n): Promise<ProfilePickerState | undefined> {\n let answer: unknown;\n try {\n answer = await load(signal);\n } catch {\n answer = undefined;\n }\n if (signal.aborted) return undefined;\n const catalog = parseProfileCatalog(answer);\n return catalog === undefined ? UNAVAILABLE : { status: catalog.readiness, profiles: catalog.profiles };\n}\n"],"mappings":"A,2CAwCA,MAAaA,EAAwB,UACxBC,EAAmB,OAC1BC,EAAiB,WAKvB,SAAgBC,EAAe,EAA+B,CAG5D,OAFIC,IAAW,IAAA,GAAkBJ,EAC7BI,IAAW,KAAaH,EACrB,GAAGC,IAAiBE,GAC7B,CAEA,SAAgBC,EAAgB,EAA8B,CAC5D,GAAIC,IAAA,OAA4B,OAAO,KACvC,GAAIA,EAAM,WAAWJ,CAAc,EAAG,OAAOI,EAAM,MAAM,CAAqB,CAEhF,CAEA,SAASC,EAAQ,EAAuC,CACtD,OAAOC,EAAQ,UAAU,MAAQA,EAAQ,IAC3C,CAGA,SAASC,EAAW,EAAmD,CAGrE,MAFkB,CAACD,EAAQ,UAAU,KAAMA,EAAQ,UAAU,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,KACvF,IACGD,EAAQC,CAAO,IAAMA,EAAQ,KAAO,IAAA,GAAYA,EAAQ,KACjE,CAGA,SAAgBE,EAAmB,EAA2D,CAC5F,MAAO,CACL,CACE,MAAOV,EACP,MAAOW,EAAE,sCAAuC,mBAAmB,EACnE,SAAUA,EAAE,8CAA+C,2CAA2C,CACxG,EACA,CACE,MAAOV,EACP,MAAOU,EAAE,mCAAoC,YAAY,EACzD,SAAUA,EAAE,2CAA4C,yBAAyB,CACnF,EACA,GAAGC,EAAS,IAAK,GAAY,CAC3B,IAAMC,EAAWJ,EAAWD,CAAO,EACnC,MAAO,CACL,MAAOL,EAAeK,EAAQ,IAAI,EAClC,MAAOD,EAAQC,CAAO,EACtB,GAAIK,IAAa,IAAA,GAAY,CAAC,EAAI,CAAE,UAAS,CAC/C,CACF,CAAC,CACH,CACF,CAEA,SAAgBC,EAAmB,EAAuB,EAAmD,CAC3G,GAAIV,IAAW,IAAA,GAAW,OAAOO,EAAE,sCAAuC,mBAAmB,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mC,CAAC,EAC1C,IAAK,IAAMe,KAASrB,EAAM,SAAU,CAClC,IAAME,EAAUW,EAAUQ,CAAK,EAC3BnB,IAAY,IAAA,IAAakB,EAAK,IAAIlB,EAAQ,IAAI,IAClDkB,EAAK,IAAIlB,EAAQ,IAAI,EACrBI,EAAS,KAAKJ,CAAO,EACvB,CACA,MAAO,CAAE,WAAU,UAAWF,EAAM,SAAU,CAChD,CAEA,MAAMsB,EAAkC,CAAE,OAAQ,cAAe,SAAU,CAAC,CAAE,EAM9E,eAAsBC,EACpB,EACA,EACyC,CACzC,IAAIC,EACJ,GAAI,CACF,EAAS,MAAMC,EAAKC,CAAM,CAC5B,MAAQ,CACN,EAAS,IAAA,EACX,CACA,GAAIA,EAAO,QAAS,OACpB,IAAMC,EAAUR,EAAoBK,CAAM,EAC1C,OAAOG,IAAY,IAAA,GAAYL,EAAc,CAAE,OAAQK,EAAQ,UAAW,SAAUA,EAAQ,QAAS,CACvG,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("qrcode-generator");t=e.__toESM(t,1);function n(e){let n=(0,t.default)(0,`M`);n.addData(e),n.make();let r=n.getModuleCount(),i=[];for(let e=0;e<r;e+=1){let t=[];for(let i=0;i<r;i+=1)t.push(n.isDark(e,i));i.push(t)}return i}exports.qrMatrix=n;
|
|
2
|
+
//# sourceMappingURL=qrMatrix.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qrMatrix.cjs","names":["qrcode","require_runtime","qrcode_generator","qrMatrix","code","text","size","rows","row","cells","column"],"sources":["../../../src/lib/qrMatrix.ts"],"sourcesContent":["import qrcode from 'qrcode-generator';\n\n/**\n * The one place the QR encoder is touched.\n *\n * Wrapping it keeps the dependency to a single import and hands the renderer a\n * plain boolean grid, so the component stays a pure drawing of data and needs\n * no knowledge of error-correction levels or type numbers.\n */\n\n/**\n * Medium correction: the pairing URL is short, and a phone camera reading a\n * screen has no print noise to recover from, so the extra redundancy of a\n * higher level would only make the modules smaller for no gain.\n */\nconst ERROR_CORRECTION = 'M';\n/** 0 asks the encoder to pick the smallest type number the payload fits in. */\nconst AUTO_TYPE_NUMBER = 0;\n\n/** Row-major grid of dark modules, including the encoder's own quiet zone handling. */\nexport function qrMatrix(text: string): boolean[][] {\n const code = qrcode(AUTO_TYPE_NUMBER, ERROR_CORRECTION);\n code.addData(text);\n code.make();\n const size = code.getModuleCount();\n const rows: boolean[][] = [];\n for (let row = 0; row < size; row += 1) {\n const cells: boolean[] = [];\n for (let column = 0; column < size; column += 1) cells.push(code.isDark(row, column));\n rows.push(cells);\n }\n return rows;\n}\n"],"mappings":"A,2GAoBA,SAAgBG,EAAS,EAA2B,CAClD,IAAMC,GAAA,EAAOJ,EAAAA,QAAAA,CAAO,EAAkB,GAAgB,EACtDI,EAAK,QAAQC,CAAI,EACjBD,EAAK,KAAK,EACV,IAAME,EAAOF,EAAK,eAAe,EAC3BG,EAAoB,CAAC,EAC3B,IAAK,IAAIC,EAAM,EAAGA,EAAMF,EAAM,GAAO,EAAG,CACtC,IAAMG,EAAmB,CAAC,EAC1B,IAAK,IAAIC,EAAS,EAAGA,EAASJ,EAAM,GAAU,EAAGG,EAAM,KAAKL,EAAK,OAAOI,EAAKE,CAAM,CAAC,EACpFH,EAAK,KAAKE,CAAK,CACjB,CACA,OAAOF,CACT,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qrMatrix.d.mts","names":[],"sources":["../../../src/lib/qrMatrix.ts"],"mappings":";;wBAoBgB,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qrMatrix.mjs","names":["qrcode","qrMatrix","code","text","size","rows","row","cells","column"],"sources":["../../../src/lib/qrMatrix.ts"],"sourcesContent":["import qrcode from 'qrcode-generator';\n\n/**\n * The one place the QR encoder is touched.\n *\n * Wrapping it keeps the dependency to a single import and hands the renderer a\n * plain boolean grid, so the component stays a pure drawing of data and needs\n * no knowledge of error-correction levels or type numbers.\n */\n\n/**\n * Medium correction: the pairing URL is short, and a phone camera reading a\n * screen has no print noise to recover from, so the extra redundancy of a\n * higher level would only make the modules smaller for no gain.\n */\nconst ERROR_CORRECTION = 'M';\n/** 0 asks the encoder to pick the smallest type number the payload fits in. */\nconst AUTO_TYPE_NUMBER = 0;\n\n/** Row-major grid of dark modules, including the encoder's own quiet zone handling. */\nexport function qrMatrix(text: string): boolean[][] {\n const code = qrcode(AUTO_TYPE_NUMBER, ERROR_CORRECTION);\n code.addData(text);\n code.make();\n const size = code.getModuleCount();\n const rows: boolean[][] = [];\n for (let row = 0; row < size; row += 1) {\n const cells: boolean[] = [];\n for (let column = 0; column < size; column += 1) cells.push(code.isDark(row, column));\n rows.push(cells);\n }\n return rows;\n}\n"],"mappings":"A,gCAoBA,SAAgBC,EAAS,EAA2B,CAClD,IAAMC,EAAOF,EAAO,EAAkB,GAAgB,EACtDE,EAAK,QAAQC,CAAI,EACjBD,EAAK,KAAK,EACV,IAAME,EAAOF,EAAK,eAAe,EAC3BG,EAAoB,CAAC,EAC3B,IAAK,IAAIC,EAAM,EAAGA,EAAMF,EAAM,GAAO,EAAG,CACtC,IAAMG,EAAmB,CAAC,EAC1B,IAAK,IAAIC,EAAS,EAAGA,EAASJ,EAAM,GAAU,EAAGG,EAAM,KAAKL,EAAK,OAAOI,EAAKE,CAAM,CAAC,EACpFH,EAAK,KAAKE,CAAK,CACjB,CACA,OAAOF,CACT,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review.cjs","names":["diffGutterWidth","widest","hunk","hunks","row","diffRangeOf","numbered","rows","kept","side","lines","trimSnippet","snippet","text","maxLines","maxChars","reviewCommentAnchor","comment","single","defaultReviewHeading","count","buildReviewPrompt","comments","body","quoted","line","heading"],"sources":["../../../src/lib/review.ts"],"sourcesContent":["import type { DiffHunk, DiffMarker, DiffSide, ReviewComment } from '../types/diff';\n\n/**\n * Pure review logic shared by every surface that comments on a diff: sizing a\n * gutter, deciding which side a selection is on, naming an anchor, and folding\n * a set of notes into one message.\n */\n\n/** The widest line number in a diff, in characters, which sizes the gutter. */\nexport function diffGutterWidth(hunks: readonly DiffHunk[]): number {\n let widest = 1;\n for (const hunk of hunks) {\n for (const row of hunk.rows) widest = Math.max(widest, String(row.line).length);\n }\n return widest;\n}\n\n/**\n * The line range a set of touched rows covers, and the side it is on.\n *\n * Any context or added row puts the selection on the new side, and then the\n * removed rows in it are ignored: their numbers belong to the other file and\n * would stretch the range over lines that have nothing to do with it. Only a\n * selection made entirely of removed rows lands on the old side.\n */\nexport function diffRangeOf(\n rows: readonly { marker: DiffMarker; line: number }[],\n): { side: DiffSide; startLine: number; endLine: number } | undefined {\n const numbered = rows.filter((row) => Number.isFinite(row.line) && row.line > 0);\n const kept = numbered.filter((row) => row.marker !== '-');\n const side: DiffSide = kept.length > 0 ? 'new' : 'old';\n const lines = (kept.length > 0 ? kept : numbered).map((row) => row.line);\n if (lines.length === 0) return undefined;\n return { side, startLine: Math.min(...lines), endLine: Math.max(...lines) };\n}\n\n/** Trims a quoted snippet to something a prompt can carry without drowning it. */\nexport function trimSnippet(snippet: string, maxLines = 20, maxChars = 2000): string {\n const lines = snippet.split('\\n');\n const clipped = lines.length > maxLines ? [...lines.slice(0, maxLines), '…'] : lines;\n const text = clipped.join('\\n');\n return text.length > maxChars ? `${text.slice(0, maxChars)}…` : text;\n}\n\n/** How a comment names the place it is about. New-side anchors keep the `path:line` form. */\nexport function reviewCommentAnchor(comment: ReviewComment): string {\n if (comment.startLine === undefined) return comment.relPath;\n const single = comment.endLine === undefined || comment.endLine === comment.startLine;\n if (comment.side === 'old') {\n return single\n ? `${comment.relPath} (removed line ${comment.startLine})`\n : `${comment.relPath} (removed lines ${comment.startLine}-${comment.endLine})`;\n }\n return single\n ? `${comment.relPath}:${comment.startLine}`\n : `${comment.relPath}:${comment.startLine}-${comment.endLine}`;\n}\n\n/** The opening line of a review when the caller names no context of its own. */\nexport function defaultReviewHeading(count: number): string {\n return count === 1\n ? 'I left one review comment on a file you changed. Please address it.'\n : `I left ${count} review comments on files you changed. Please address them.`;\n}\n\n/**\n * The one message a review sends.\n *\n * Every note goes in a single message rather than one each: N notes then cost\n * one turn, and the agent sees the whole review before it changes anything.\n */\nexport function buildReviewPrompt(comments: readonly ReviewComment[], heading?: string): string {\n if (comments.length === 0) return '';\n const body = comments\n .map((comment) => {\n const quoted = trimSnippet(comment.snippet)\n .split('\\n')\n .map((line) => `> ${line}`)\n .join('\\n');\n return `### ${reviewCommentAnchor(comment)}\\n\\n${quoted}\\n\\n${comment.body.trim()}`;\n })\n .join('\\n\\n');\n return `${heading ?? defaultReviewHeading(comments.length)}\\n\\n${body}`;\n}\n"],"mappings":"AASA,SAAgBA,EAAgB,EAAoC,CAClE,IAAIC,EAAS,EACb,IAAK,IAAMC,KAAQC,EACjB,IAAK,IAAMC,KAAOF,EAAK,KAAM,EAAS,KAAK,IAAID,EAAQ,OAAOG,EAAI,IAAI,CAAC,CAAC,MAAM,EAEhF,OAAOH,CACT,CAUA,SAAgBI,EACd,EACoE,CACpE,IAAMC,EAAWC,EAAK,OAAQ,GAAQ,OAAO,SAASH,EAAI,IAAI,GAAKA,EAAI,KAAO,CAAC,EACzEI,EAAOF,EAAS,OAAQ,GAAQF,EAAI,SAAW,GAAG,EAClDK,EAAiBD,EAAK,OAAS,EAAI,MAAQ,MAC3CE,GAASF,EAAK,OAAS,EAAIA,EAAOF,EAAA,CAAU,IAAK,GAAQF,EAAI,IAAI,EACvE,GAAIM,EAAM,SAAW,EACrB,MAAO,CAAE,OAAM,UAAW,KAAK,IAAI,GAAGA,CAAK,EAAG,QAAS,KAAK,IAAI,GAAGA,CAAK,CAAE,CAC5E,CAGA,SAAgBC,EAAY,EAAiB,EAAW,GAAI,EAAW,IAAc,CACnF,IAAMD,EAAQE,EAAQ,MAAM;CAAI,EAE1BC,GADUH,EAAM,OAASI,EAAW,CAAC,GAAGJ,EAAM,MAAM,EAAGI,CAAQ,EAAG,GAAG,EAAIJ,EAAA,CAC1D,KAAK;CAAI,EAC9B,OAAOG,EAAK,OAASE,EAAW,GAAGF,EAAK,MAAM,EAAGE,CAAQ,EAAE,GAAKF,CAClE,CAGA,SAAgBG,EAAoB,EAAgC,CAClE,GAAIC,EAAQ,YAAc,IAAA,GAAW,OAAOA,EAAQ,QACpD,IAAMC,EAASD,EAAQ,UAAY,IAAA,IAAaA,EAAQ,UAAYA,EAAQ,UAM5E,OALIA,EAAQ,OAAS,MACZC,EACH,GAAGD,EAAQ,QAAQ,iBAAiBA,EAAQ,UAAU,GACtD,GAAGA,EAAQ,QAAQ,kBAAkBA,EAAQ,UAAU,GAAGA,EAAQ,QAAQ,GAEzEC,EACH,GAAGD,EAAQ,QAAQ,GAAGA,EAAQ,YAC9B,GAAGA,EAAQ,QAAQ,GAAGA,EAAQ,UAAU,GAAGA,EAAQ,SACzD,CAGA,SAAgBE,EAAqB,EAAuB,CAC1D,OAAOC,IAAU,EACb,sEACA,UAAUA,EAAM,4DACtB,CAQA,SAAgBC,EAAkB,EAAoC,EAA0B,CAC9F,GAAIC,EAAS,SAAW,EAAG,MAAO,GAClC,IAAMC,EAAOD,EACV,IAAK,GAAY,CAChB,IAAME,EAASb,EAAYM,EAAQ,OAAO,CAAC,CACxC,MAAM;CAAI,CAAC,CACX,IAAK,GAAS,KAAKQ,GAAM,CAAC,CAC1B,KAAK;CAAI,EACZ,MAAO,OAAOT,EAAoBC,CAAO,EAAE,MAAMO,EAAO,MAAMP,EAAQ,KAAK,KAAK,GAClF,CAAC,CAAC,CACD,KAAK;;CAAM,EACd,MAAO,GAAGS,GAAWP,EAAqBG,EAAS,MAAM,EAAE,MAAMC,GACnE"}
|
|
1
|
+
{"version":3,"file":"review.cjs","names":["diffGutterWidth","widest","hunk","hunks","row","diffRangeOf","numbered","rows","kept","side","lines","trimSnippet","snippet","text","maxLines","maxChars","reviewCommentAnchor","comment","single","defaultReviewHeading","count","buildReviewPrompt","comments","body","quoted","line","heading"],"sources":["../../../src/lib/review.ts"],"sourcesContent":["import type { DiffHunk, DiffMarker, DiffSide, ReviewComment } from '../types/diff';\n\n/**\n * Pure review logic shared by every surface that comments on a diff: sizing a\n * gutter, deciding which side a selection is on, naming an anchor, and folding\n * a set of notes into one message.\n */\n\n/** The widest line number in a diff, in characters, which sizes the gutter. */\nexport function diffGutterWidth(hunks: readonly DiffHunk[]): number {\n let widest = 1;\n for (const hunk of hunks) {\n for (const row of hunk.rows) widest = Math.max(widest, String(row.line).length);\n }\n return widest;\n}\n\n/**\n * The line range a set of touched rows covers, and the side it is on.\n *\n * Any context or added row puts the selection on the new side, and then the\n * removed rows in it are ignored: their numbers belong to the other file and\n * would stretch the range over lines that have nothing to do with it. Only a\n * selection made entirely of removed rows lands on the old side.\n */\nexport function diffRangeOf(\n rows: readonly { marker: DiffMarker; line: number }[],\n): { side: DiffSide; startLine: number; endLine: number } | undefined {\n const numbered = rows.filter((row) => Number.isFinite(row.line) && row.line > 0);\n const kept = numbered.filter((row) => row.marker !== '-');\n const side: DiffSide = kept.length > 0 ? 'new' : 'old';\n const lines = (kept.length > 0 ? kept : numbered).map((row) => row.line);\n if (lines.length === 0) return undefined;\n return { side, startLine: Math.min(...lines), endLine: Math.max(...lines) };\n}\n\n/** Trims a quoted snippet to something a prompt can carry without drowning it. */\nexport function trimSnippet(snippet: string, maxLines = 20, maxChars = 2000): string {\n const lines = snippet.split('\\n');\n const clipped = lines.length > maxLines ? [...lines.slice(0, maxLines), '…'] : lines;\n const text = clipped.join('\\n');\n return text.length > maxChars ? `${text.slice(0, maxChars)}…` : text;\n}\n\n/** How a comment names the place it is about. New-side anchors keep the `path:line` form. */\nexport function reviewCommentAnchor(comment: ReviewComment): string {\n if (comment.startLine === undefined) return comment.relPath;\n const single = comment.endLine === undefined || comment.endLine === comment.startLine;\n if (comment.side === 'old') {\n return single\n ? `${comment.relPath} (removed line ${comment.startLine})`\n : `${comment.relPath} (removed lines ${comment.startLine}-${comment.endLine})`;\n }\n return single\n ? `${comment.relPath}:${comment.startLine}`\n : `${comment.relPath}:${comment.startLine}-${comment.endLine}`;\n}\n\n/** The opening line of a review when the caller names no context of its own. */\nexport function defaultReviewHeading(count: number): string {\n return count === 1\n ? 'I left one review comment on a file you changed. Please address it.'\n : `I left ${count} review comments on files you changed. Please address them.`;\n}\n\n/**\n * The one message a review sends.\n *\n * Every note goes in a single message rather than one each: N notes then cost\n * one turn, and the agent sees the whole review before it changes anything.\n */\nexport function buildReviewPrompt(comments: readonly ReviewComment[], heading?: string): string {\n if (comments.length === 0) return '';\n const body = comments\n .map((comment) => {\n const quoted = trimSnippet(comment.snippet)\n .split('\\n')\n .map((line) => `> ${line}`)\n .join('\\n');\n return `### ${reviewCommentAnchor(comment)}\\n\\n${quoted}\\n\\n${comment.body.trim()}`;\n })\n .join('\\n\\n');\n return `${heading ?? defaultReviewHeading(comments.length)}\\n\\n${body}`;\n}\n"],"mappings":"AASA,SAAgBA,EAAgB,EAAoC,CAClE,IAAIC,EAAS,EACb,IAAK,IAAMC,KAAQC,EACjB,IAAK,IAAMC,KAAOF,EAAK,KAAM,EAAS,KAAK,IAAID,EAAQ,OAAOG,EAAI,IAAI,CAAC,CAAC,MAAM,EAEhF,OAAOH,CACT,CAUA,SAAgBI,EACd,EACoE,CACpE,IAAMC,EAAWC,EAAK,OAAQ,GAAQ,OAAO,SAASH,EAAI,IAAI,GAAKA,EAAI,KAAO,CAAC,EACzEI,EAAOF,EAAS,OAAQ,GAAQF,EAAI,SAAW,GAAG,EAClDK,EAAiBD,EAAK,OAAS,EAAI,MAAQ,MAC3CE,GAASF,EAAK,OAAS,EAAIA,EAAOF,EAAA,CAAU,IAAK,GAAQF,EAAI,IAAI,EACvE,GAAIM,EAAM,SAAW,EACrB,MAAO,CAAE,OAAM,UAAW,KAAK,IAAI,GAAGA,CAAK,EAAG,QAAS,KAAK,IAAI,GAAGA,CAAK,CAAE,CAC5E,CAGA,SAAgBC,EAAY,EAA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
{"version":3,"file":"review.d.mts","names":[],"sources":["../../../src/lib/review.ts"],"mappings":";;;;;;;;wBASgB,gBAAgB,gBAAgB;;;;;;;;;wBAgBhC,YACd;EAAiB,QAAQ;EAAY;;EAClC,MAAM;EAAU;EAAmB;;;wBAUxB,YAAY,iBAAiB,mBAAe;;wBAQ5C,oBAAoB,SAAS;;wBAc7B,qBAAqB;;;;;;;wBAYrB,kBAAkB,mBAAmB,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.mjs","names":["diffGutterWidth","widest","hunk","hunks","row","diffRangeOf","numbered","rows","kept","side","lines","trimSnippet","snippet","text","maxLines","maxChars","reviewCommentAnchor","comment","single","defaultReviewHeading","count","buildReviewPrompt","comments","body","quoted","line","heading"],"sources":["../../../src/lib/review.ts"],"sourcesContent":["import type { DiffHunk, DiffMarker, DiffSide, ReviewComment } from '../types/diff';\n\n/**\n * Pure review logic shared by every surface that comments on a diff: sizing a\n * gutter, deciding which side a selection is on, naming an anchor, and folding\n * a set of notes into one message.\n */\n\n/** The widest line number in a diff, in characters, which sizes the gutter. */\nexport function diffGutterWidth(hunks: readonly DiffHunk[]): number {\n let widest = 1;\n for (const hunk of hunks) {\n for (const row of hunk.rows) widest = Math.max(widest, String(row.line).length);\n }\n return widest;\n}\n\n/**\n * The line range a set of touched rows covers, and the side it is on.\n *\n * Any context or added row puts the selection on the new side, and then the\n * removed rows in it are ignored: their numbers belong to the other file and\n * would stretch the range over lines that have nothing to do with it. Only a\n * selection made entirely of removed rows lands on the old side.\n */\nexport function diffRangeOf(\n rows: readonly { marker: DiffMarker; line: number }[],\n): { side: DiffSide; startLine: number; endLine: number } | undefined {\n const numbered = rows.filter((row) => Number.isFinite(row.line) && row.line > 0);\n const kept = numbered.filter((row) => row.marker !== '-');\n const side: DiffSide = kept.length > 0 ? 'new' : 'old';\n const lines = (kept.length > 0 ? kept : numbered).map((row) => row.line);\n if (lines.length === 0) return undefined;\n return { side, startLine: Math.min(...lines), endLine: Math.max(...lines) };\n}\n\n/** Trims a quoted snippet to something a prompt can carry without drowning it. */\nexport function trimSnippet(snippet: string, maxLines = 20, maxChars = 2000): string {\n const lines = snippet.split('\\n');\n const clipped = lines.length > maxLines ? [...lines.slice(0, maxLines), '…'] : lines;\n const text = clipped.join('\\n');\n return text.length > maxChars ? `${text.slice(0, maxChars)}…` : text;\n}\n\n/** How a comment names the place it is about. New-side anchors keep the `path:line` form. */\nexport function reviewCommentAnchor(comment: ReviewComment): string {\n if (comment.startLine === undefined) return comment.relPath;\n const single = comment.endLine === undefined || comment.endLine === comment.startLine;\n if (comment.side === 'old') {\n return single\n ? `${comment.relPath} (removed line ${comment.startLine})`\n : `${comment.relPath} (removed lines ${comment.startLine}-${comment.endLine})`;\n }\n return single\n ? `${comment.relPath}:${comment.startLine}`\n : `${comment.relPath}:${comment.startLine}-${comment.endLine}`;\n}\n\n/** The opening line of a review when the caller names no context of its own. */\nexport function defaultReviewHeading(count: number): string {\n return count === 1\n ? 'I left one review comment on a file you changed. Please address it.'\n : `I left ${count} review comments on files you changed. Please address them.`;\n}\n\n/**\n * The one message a review sends.\n *\n * Every note goes in a single message rather than one each: N notes then cost\n * one turn, and the agent sees the whole review before it changes anything.\n */\nexport function buildReviewPrompt(comments: readonly ReviewComment[], heading?: string): string {\n if (comments.length === 0) return '';\n const body = comments\n .map((comment) => {\n const quoted = trimSnippet(comment.snippet)\n .split('\\n')\n .map((line) => `> ${line}`)\n .join('\\n');\n return `### ${reviewCommentAnchor(comment)}\\n\\n${quoted}\\n\\n${comment.body.trim()}`;\n })\n .join('\\n\\n');\n return `${heading ?? defaultReviewHeading(comments.length)}\\n\\n${body}`;\n}\n"],"mappings":"AASA,SAAgBA,EAAgB,EAAoC,CAClE,IAAIC,EAAS,EACb,IAAK,IAAMC,KAAQC,EACjB,IAAK,IAAMC,KAAOF,EAAK,KAAM,EAAS,KAAK,IAAID,EAAQ,OAAOG,EAAI,IAAI,CAAC,CAAC,MAAM,E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tB,CAQA,SAAgBC,EAAkB,EAAoC,EAA0B,CAC9F,GAAIC,EAAS,SAAW,EAAG,MAAO,GAClC,IAAMC,EAAOD,EACV,IAAK,GAAY,CAChB,IAAME,EAASb,EAAYM,EAAQ,OAAO,CAAC,CACxC,MAAM;CAAI,CAAC,CACX,IAAK,GAAS,KAAKQ,GAAM,CAAC,CAC1B,KAAK;CAAI,EACZ,MAAO,OAAOT,EAAoBC,CAAO,EAAE,MAAMO,EAAO,MAAMP,EAAQ,KAAK,KAAK,GAClF,CAAC,CAAC,CACD,KAAK;;CAAM,EACd,MAAO,GAAGS,GAAWP,EAAqBG,EAAS,MAAM,EAAE,MAAMC,GACnE,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=6e4,t=36e5;function n(n){if(n<e)return`<1m`;if(n<t)return`${Math.floor(n/e)}m`;let r=Math.floor(n/t),i=Math.floor(n%t/e);return`${r}h ${String(i).padStart(2,`0`)}m`}function r(e,t){return`${e.label} · ${n(Math.max(0,t-e.since))}`}function i(t,n){let r=Math.max(0,n-t);return e-r%e}exports.clockRefreshMs=i,exports.clockText=r,exports.formatRunDuration=n;
|
|
2
|
+
//# sourceMappingURL=runDuration.cjs.map
|