meowtail 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ASSISTANT.md +52 -0
- package/JSON.md +48 -0
- package/LICENSE +21 -0
- package/README.md +474 -2
- package/THIRD_PARTY_NOTICES.md +27 -0
- package/dist/src/chat/assistant-composer.d.ts +8 -0
- package/dist/src/chat/assistant-composer.js +246 -0
- package/dist/src/chat/assistant-content.d.ts +20 -0
- package/dist/src/chat/assistant-content.js +66 -0
- package/dist/src/chat/assistant-draft.d.ts +5 -0
- package/dist/src/chat/assistant-draft.js +23 -0
- package/dist/src/chat/assistant-markdown.d.ts +11 -0
- package/dist/src/chat/assistant-markdown.js +33 -0
- package/dist/src/chat/assistant-question.d.ts +12 -0
- package/dist/src/chat/assistant-question.js +95 -0
- package/dist/src/chat/assistant-scroll.d.ts +7 -0
- package/dist/src/chat/assistant-scroll.js +72 -0
- package/dist/src/chat/assistant-types.d.ts +174 -0
- package/dist/src/chat/assistant-types.js +40 -0
- package/dist/src/chat/assistant.d.ts +9 -0
- package/dist/src/chat/assistant.js +294 -0
- package/dist/src/chat/attachments.d.ts +23 -0
- package/dist/src/chat/attachments.js +81 -0
- package/dist/src/chat/bubble.d.ts +17 -0
- package/dist/src/chat/bubble.js +18 -0
- package/dist/src/chat/composer.d.ts +36 -0
- package/dist/src/chat/composer.js +31 -0
- package/dist/src/chat/conversation-scroll.d.ts +9 -0
- package/dist/src/chat/conversation-scroll.js +36 -0
- package/dist/src/chat/conversation.d.ts +16 -0
- package/dist/src/chat/conversation.js +62 -0
- package/dist/src/chat/frame.d.ts +9 -0
- package/dist/src/chat/frame.js +6 -0
- package/dist/src/chat/header.d.ts +14 -0
- package/dist/src/chat/header.js +15 -0
- package/dist/src/chat/index.d.ts +15 -0
- package/dist/src/chat/index.js +15 -0
- package/dist/src/chat/message-actions.d.ts +9 -0
- package/dist/src/chat/message-actions.js +6 -0
- package/dist/src/chat/message-context.d.ts +2 -0
- package/dist/src/chat/message-context.js +2 -0
- package/dist/src/chat/message-list.d.ts +25 -0
- package/dist/src/chat/message-list.js +23 -0
- package/dist/src/chat/message.d.ts +24 -0
- package/dist/src/chat/message.js +36 -0
- package/dist/src/chat/process.d.ts +11 -0
- package/dist/src/chat/process.js +9 -0
- package/dist/src/chat/question.d.ts +15 -0
- package/dist/src/chat/question.js +7 -0
- package/dist/src/chat/sources.d.ts +15 -0
- package/dist/src/chat/sources.js +19 -0
- package/dist/src/chat/status.d.ts +18 -0
- package/dist/src/chat/status.js +16 -0
- package/dist/src/chat/tool-call.d.ts +21 -0
- package/dist/src/chat/tool-call.js +40 -0
- package/dist/src/clipboard.d.ts +2 -0
- package/dist/src/clipboard.js +44 -0
- package/dist/src/components/add-button.d.ts +4 -0
- package/dist/src/components/add-button.js +8 -0
- package/dist/src/components/alert.d.ts +20 -0
- package/dist/src/components/alert.js +16 -0
- package/dist/src/components/aspect-ratio.d.ts +11 -0
- package/dist/src/components/aspect-ratio.js +19 -0
- package/dist/src/components/badge.d.ts +18 -0
- package/dist/src/components/badge.js +16 -0
- package/dist/src/components/breadcrumb.d.ts +15 -0
- package/dist/src/components/breadcrumb.js +10 -0
- package/dist/src/components/button.d.ts +31 -0
- package/dist/src/components/button.js +26 -0
- package/dist/src/components/card-action.d.ts +9 -0
- package/dist/src/components/card-action.js +6 -0
- package/dist/src/components/card-content.d.ts +9 -0
- package/dist/src/components/card-content.js +6 -0
- package/dist/src/components/card-description.d.ts +9 -0
- package/dist/src/components/card-description.js +6 -0
- package/dist/src/components/card-footer.d.ts +9 -0
- package/dist/src/components/card-footer.js +6 -0
- package/dist/src/components/card-header.d.ts +9 -0
- package/dist/src/components/card-header.js +6 -0
- package/dist/src/components/card-title.d.ts +10 -0
- package/dist/src/components/card-title.js +6 -0
- package/dist/src/components/card.d.ts +17 -0
- package/dist/src/components/card.js +19 -0
- package/dist/src/components/checkbox.d.ts +18 -0
- package/dist/src/components/checkbox.js +44 -0
- package/dist/src/components/choice-group.d.ts +27 -0
- package/dist/src/components/choice-group.js +85 -0
- package/dist/src/components/choice-select.d.ts +31 -0
- package/dist/src/components/choice-select.js +353 -0
- package/dist/src/components/code-block.d.ts +13 -0
- package/dist/src/components/code-block.js +71 -0
- package/dist/src/components/container.d.ts +17 -0
- package/dist/src/components/container.js +16 -0
- package/dist/src/components/credential-source.d.ts +22 -0
- package/dist/src/components/credential-source.js +34 -0
- package/dist/src/components/description-list.d.ts +20 -0
- package/dist/src/components/description-list.js +13 -0
- package/dist/src/components/detail-section.d.ts +16 -0
- package/dist/src/components/detail-section.js +12 -0
- package/dist/src/components/dialog.d.ts +43 -0
- package/dist/src/components/dialog.js +29 -0
- package/dist/src/components/diff-block.d.ts +21 -0
- package/dist/src/components/diff-block.js +24 -0
- package/dist/src/components/disclosure.d.ts +15 -0
- package/dist/src/components/disclosure.js +14 -0
- package/dist/src/components/drawer.d.ts +19 -0
- package/dist/src/components/drawer.js +56 -0
- package/dist/src/components/empty-state.d.ts +19 -0
- package/dist/src/components/empty-state.js +11 -0
- package/dist/src/components/field-group.d.ts +13 -0
- package/dist/src/components/field-group.js +20 -0
- package/dist/src/components/field.d.ts +16 -0
- package/dist/src/components/field.js +48 -0
- package/dist/src/components/grid.d.ts +27 -0
- package/dist/src/components/grid.js +29 -0
- package/dist/src/components/hover-card.d.ts +22 -0
- package/dist/src/components/hover-card.js +147 -0
- package/dist/src/components/icon-button.d.ts +17 -0
- package/dist/src/components/icon-button.js +17 -0
- package/dist/src/components/icon-rail.d.ts +20 -0
- package/dist/src/components/icon-rail.js +14 -0
- package/dist/src/components/image-lightbox.d.ts +14 -0
- package/dist/src/components/image-lightbox.js +51 -0
- package/dist/src/components/image-preview.d.ts +16 -0
- package/dist/src/components/image-preview.js +42 -0
- package/dist/src/components/index.d.ts +88 -0
- package/dist/src/components/index.js +87 -0
- package/dist/src/components/inline.d.ts +14 -0
- package/dist/src/components/inline.js +23 -0
- package/dist/src/components/input.d.ts +10 -0
- package/dist/src/components/input.js +6 -0
- package/dist/src/components/item.d.ts +26 -0
- package/dist/src/components/item.js +19 -0
- package/dist/src/components/json-block.d.ts +18 -0
- package/dist/src/components/json-block.js +49 -0
- package/dist/src/components/json-tree.d.ts +16 -0
- package/dist/src/components/json-tree.js +76 -0
- package/dist/src/components/layout-item.d.ts +15 -0
- package/dist/src/components/layout-item.js +16 -0
- package/dist/src/components/layout-types.d.ts +18 -0
- package/dist/src/components/layout-types.js +13 -0
- package/dist/src/components/list-group.d.ts +30 -0
- package/dist/src/components/list-group.js +32 -0
- package/dist/src/components/menu.d.ts +45 -0
- package/dist/src/components/menu.js +227 -0
- package/dist/src/components/nav-item.d.ts +13 -0
- package/dist/src/components/nav-item.js +19 -0
- package/dist/src/components/output-block.d.ts +20 -0
- package/dist/src/components/output-block.js +66 -0
- package/dist/src/components/page-frame.d.ts +21 -0
- package/dist/src/components/page-frame.js +16 -0
- package/dist/src/components/page-header.d.ts +15 -0
- package/dist/src/components/page-header.js +9 -0
- package/dist/src/components/path-label.d.ts +11 -0
- package/dist/src/components/path-label.js +37 -0
- package/dist/src/components/path-picker.d.ts +18 -0
- package/dist/src/components/path-picker.js +83 -0
- package/dist/src/components/pill.d.ts +11 -0
- package/dist/src/components/pill.js +14 -0
- package/dist/src/components/popover.d.ts +31 -0
- package/dist/src/components/popover.js +232 -0
- package/dist/src/components/process-group.d.ts +17 -0
- package/dist/src/components/process-group.js +8 -0
- package/dist/src/components/process-step.d.ts +13 -0
- package/dist/src/components/process-step.js +7 -0
- package/dist/src/components/rail-item.d.ts +25 -0
- package/dist/src/components/rail-item.js +16 -0
- package/dist/src/components/rail-section.d.ts +18 -0
- package/dist/src/components/rail-section.js +11 -0
- package/dist/src/components/read-block.d.ts +24 -0
- package/dist/src/components/read-block.js +82 -0
- package/dist/src/components/region-layout-types.d.ts +19 -0
- package/dist/src/components/region-layout-types.js +78 -0
- package/dist/src/components/region-layout.d.ts +19 -0
- package/dist/src/components/region-layout.js +254 -0
- package/dist/src/components/resource-card.d.ts +22 -0
- package/dist/src/components/resource-card.js +20 -0
- package/dist/src/components/resource-link.d.ts +18 -0
- package/dist/src/components/resource-link.js +14 -0
- package/dist/src/components/risk-confirmation.d.ts +22 -0
- package/dist/src/components/risk-confirmation.js +45 -0
- package/dist/src/components/search-block.d.ts +28 -0
- package/dist/src/components/search-block.js +40 -0
- package/dist/src/components/search-input.d.ts +18 -0
- package/dist/src/components/search-input.js +13 -0
- package/dist/src/components/segmented-control.d.ts +24 -0
- package/dist/src/components/segmented-control.js +63 -0
- package/dist/src/components/select.d.ts +17 -0
- package/dist/src/components/select.js +6 -0
- package/dist/src/components/separator.d.ts +10 -0
- package/dist/src/components/separator.js +11 -0
- package/dist/src/components/shortcut-keys.d.ts +12 -0
- package/dist/src/components/shortcut-keys.js +7 -0
- package/dist/src/components/skeleton-boundary.d.ts +12 -0
- package/dist/src/components/skeleton-boundary.js +73 -0
- package/dist/src/components/skeleton.d.ts +17 -0
- package/dist/src/components/skeleton.js +15 -0
- package/dist/src/components/spinner.d.ts +10 -0
- package/dist/src/components/spinner.js +7 -0
- package/dist/src/components/stack.d.ts +13 -0
- package/dist/src/components/stack.js +22 -0
- package/dist/src/components/state-dot.d.ts +14 -0
- package/dist/src/components/state-dot.js +28 -0
- package/dist/src/components/status-dot.d.ts +34 -0
- package/dist/src/components/status-dot.js +25 -0
- package/dist/src/components/switch.d.ts +9 -0
- package/dist/src/components/switch.js +8 -0
- package/dist/src/components/tabs.d.ts +24 -0
- package/dist/src/components/tabs.js +90 -0
- package/dist/src/components/tag.d.ts +23 -0
- package/dist/src/components/tag.js +16 -0
- package/dist/src/components/terminal-block.d.ts +24 -0
- package/dist/src/components/terminal-block.js +103 -0
- package/dist/src/components/text-shimmer.d.ts +15 -0
- package/dist/src/components/text-shimmer.js +17 -0
- package/dist/src/components/textarea.d.ts +9 -0
- package/dist/src/components/textarea.js +6 -0
- package/dist/src/components/timeline.d.ts +26 -0
- package/dist/src/components/timeline.js +17 -0
- package/dist/src/components/toast.d.ts +14 -0
- package/dist/src/components/toast.js +7 -0
- package/dist/src/components/toolbar.d.ts +12 -0
- package/dist/src/components/toolbar.js +155 -0
- package/dist/src/components/tooltip.d.ts +19 -0
- package/dist/src/components/tooltip.js +81 -0
- package/dist/src/components/web-block.d.ts +24 -0
- package/dist/src/components/web-block.js +40 -0
- package/dist/src/components/window-title-bar.d.ts +25 -0
- package/dist/src/components/window-title-bar.js +16 -0
- package/dist/src/components/work-card.d.ts +21 -0
- package/dist/src/components/work-card.js +11 -0
- package/dist/src/icons/LUCIDE-LICENSE +43 -0
- package/dist/src/icons/README.md +9 -0
- package/dist/src/icons/doodle-cat.d.ts +5 -0
- package/dist/src/icons/doodle-cat.js +8 -0
- package/dist/src/icons/external-arrow.d.ts +2 -0
- package/dist/src/icons/external-arrow.js +5 -0
- package/dist/src/icons/file-type-icon.d.ts +29 -0
- package/dist/src/icons/file-type-icon.js +211 -0
- package/dist/src/icons/github.d.ts +2 -0
- package/dist/src/icons/github.js +5 -0
- package/dist/src/icons/icon.d.ts +51 -0
- package/dist/src/icons/icon.js +135 -0
- package/dist/src/icons/index.d.ts +10 -0
- package/dist/src/icons/index.js +10 -0
- package/dist/src/icons/meowland-mark.d.ts +5 -0
- package/dist/src/icons/meowland-mark.js +5 -0
- package/dist/src/icons/notes.d.ts +2 -0
- package/dist/src/icons/notes.js +5 -0
- package/dist/src/icons/plus.d.ts +2 -0
- package/dist/src/icons/plus.js +5 -0
- package/dist/src/icons/search.d.ts +2 -0
- package/dist/src/icons/search.js +5 -0
- package/dist/src/icons/tasks.d.ts +2 -0
- package/dist/src/icons/tasks.js +5 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/json/catalog.d.ts +169 -0
- package/dist/src/json/catalog.js +164 -0
- package/dist/src/json/index.d.ts +1 -0
- package/dist/src/json/index.js +1 -0
- package/dist/src/registry/index.d.ts +833 -0
- package/dist/src/registry/index.js +235 -0
- package/dist/src/registry.d.ts +1 -0
- package/dist/src/registry.js +1 -0
- package/dist/src/shared/dom-root.d.ts +3 -0
- package/dist/src/shared/dom-root.js +8 -0
- package/dist/src/shared/layout-style.d.ts +4 -0
- package/dist/src/shared/layout-style.js +13 -0
- package/dist/src/syntax-highlight.d.ts +26 -0
- package/dist/src/syntax-highlight.js +116 -0
- package/dist/src/theme/base.styles.d.ts +2 -0
- package/dist/src/theme/base.styles.js +26 -0
- package/dist/src/theme/chat/assistant.styles.d.ts +2 -0
- package/dist/src/theme/chat/assistant.styles.js +289 -0
- package/dist/src/theme/chat/attachments.styles.d.ts +1 -0
- package/dist/src/theme/chat/attachments.styles.js +255 -0
- package/dist/src/theme/chat/composer.styles.d.ts +1 -0
- package/dist/src/theme/chat/composer.styles.js +519 -0
- package/dist/src/theme/chat/conversation.styles.d.ts +1 -0
- package/dist/src/theme/chat/conversation.styles.js +57 -0
- package/dist/src/theme/chat/frame.styles.d.ts +1 -0
- package/dist/src/theme/chat/frame.styles.js +107 -0
- package/dist/src/theme/chat/header.styles.d.ts +1 -0
- package/dist/src/theme/chat/header.styles.js +93 -0
- package/dist/src/theme/chat/message.styles.d.ts +1 -0
- package/dist/src/theme/chat/message.styles.js +423 -0
- package/dist/src/theme/chat/question.styles.d.ts +1 -0
- package/dist/src/theme/chat/question.styles.js +57 -0
- package/dist/src/theme/chat/records.styles.d.ts +1 -0
- package/dist/src/theme/chat/records.styles.js +546 -0
- package/dist/src/theme/chat/status.styles.d.ts +1 -0
- package/dist/src/theme/chat/status.styles.js +75 -0
- package/dist/src/theme/components/alert.styles.d.ts +1 -0
- package/dist/src/theme/components/alert.styles.js +28 -0
- package/dist/src/theme/components/badge.styles.d.ts +1 -0
- package/dist/src/theme/components/badge.styles.js +66 -0
- package/dist/src/theme/components/breadcrumb.styles.d.ts +1 -0
- package/dist/src/theme/components/breadcrumb.styles.js +44 -0
- package/dist/src/theme/components/button.styles.d.ts +1 -0
- package/dist/src/theme/components/button.styles.js +143 -0
- package/dist/src/theme/components/card.styles.d.ts +1 -0
- package/dist/src/theme/components/card.styles.js +108 -0
- package/dist/src/theme/components/choice-group.styles.d.ts +1 -0
- package/dist/src/theme/components/choice-group.styles.js +87 -0
- package/dist/src/theme/components/choice-select.styles.d.ts +1 -0
- package/dist/src/theme/components/choice-select.styles.js +182 -0
- package/dist/src/theme/components/code-block.styles.d.ts +1 -0
- package/dist/src/theme/components/code-block.styles.js +77 -0
- package/dist/src/theme/components/description-list.styles.d.ts +1 -0
- package/dist/src/theme/components/description-list.styles.js +39 -0
- package/dist/src/theme/components/detail-section.styles.d.ts +1 -0
- package/dist/src/theme/components/detail-section.styles.js +43 -0
- package/dist/src/theme/components/dialog.styles.d.ts +1 -0
- package/dist/src/theme/components/dialog.styles.js +91 -0
- package/dist/src/theme/components/disclosure.styles.d.ts +1 -0
- package/dist/src/theme/components/disclosure.styles.js +79 -0
- package/dist/src/theme/components/drawer.styles.d.ts +2 -0
- package/dist/src/theme/components/drawer.styles.js +67 -0
- package/dist/src/theme/components/empty-state.styles.d.ts +1 -0
- package/dist/src/theme/components/empty-state.styles.js +51 -0
- package/dist/src/theme/components/field-group.styles.d.ts +1 -0
- package/dist/src/theme/components/field-group.styles.js +31 -0
- package/dist/src/theme/components/field.styles.d.ts +1 -0
- package/dist/src/theme/components/field.styles.js +31 -0
- package/dist/src/theme/components/hover-card.styles.d.ts +1 -0
- package/dist/src/theme/components/hover-card.styles.js +59 -0
- package/dist/src/theme/components/icon-rail.styles.d.ts +1 -0
- package/dist/src/theme/components/icon-rail.styles.js +236 -0
- package/dist/src/theme/components/image-lightbox.styles.d.ts +1 -0
- package/dist/src/theme/components/image-lightbox.styles.js +67 -0
- package/dist/src/theme/components/image-preview.styles.d.ts +1 -0
- package/dist/src/theme/components/image-preview.styles.js +68 -0
- package/dist/src/theme/components/item.styles.d.ts +1 -0
- package/dist/src/theme/components/item.styles.js +101 -0
- package/dist/src/theme/components/json.styles.d.ts +1 -0
- package/dist/src/theme/components/json.styles.js +127 -0
- package/dist/src/theme/components/layout.styles.d.ts +1 -0
- package/dist/src/theme/components/layout.styles.js +103 -0
- package/dist/src/theme/components/list-group.styles.d.ts +1 -0
- package/dist/src/theme/components/list-group.styles.js +98 -0
- package/dist/src/theme/components/menu.styles.d.ts +1 -0
- package/dist/src/theme/components/menu.styles.js +77 -0
- package/dist/src/theme/components/native-input.styles.d.ts +1 -0
- package/dist/src/theme/components/native-input.styles.js +113 -0
- package/dist/src/theme/components/nav-item.styles.d.ts +1 -0
- package/dist/src/theme/components/nav-item.styles.js +68 -0
- package/dist/src/theme/components/output-block.styles.d.ts +1 -0
- package/dist/src/theme/components/output-block.styles.js +226 -0
- package/dist/src/theme/components/page-frame.styles.d.ts +1 -0
- package/dist/src/theme/components/page-frame.styles.js +57 -0
- package/dist/src/theme/components/page-header.styles.d.ts +1 -0
- package/dist/src/theme/components/page-header.styles.js +39 -0
- package/dist/src/theme/components/path-label.styles.d.ts +1 -0
- package/dist/src/theme/components/path-label.styles.js +27 -0
- package/dist/src/theme/components/path-picker.styles.d.ts +1 -0
- package/dist/src/theme/components/path-picker.styles.js +33 -0
- package/dist/src/theme/components/pill.styles.d.ts +1 -0
- package/dist/src/theme/components/pill.styles.js +39 -0
- package/dist/src/theme/components/popover.styles.d.ts +1 -0
- package/dist/src/theme/components/popover.styles.js +49 -0
- package/dist/src/theme/components/process-group.styles.d.ts +1 -0
- package/dist/src/theme/components/process-group.styles.js +141 -0
- package/dist/src/theme/components/region-layout.styles.d.ts +1 -0
- package/dist/src/theme/components/region-layout.styles.js +57 -0
- package/dist/src/theme/components/resource-card.styles.d.ts +1 -0
- package/dist/src/theme/components/resource-card.styles.js +105 -0
- package/dist/src/theme/components/resource-card.tokens.d.ts +5 -0
- package/dist/src/theme/components/resource-card.tokens.js +6 -0
- package/dist/src/theme/components/resource-link.styles.d.ts +1 -0
- package/dist/src/theme/components/resource-link.styles.js +78 -0
- package/dist/src/theme/components/risk-confirmation.styles.d.ts +1 -0
- package/dist/src/theme/components/risk-confirmation.styles.js +9 -0
- package/dist/src/theme/components/search-input.styles.d.ts +1 -0
- package/dist/src/theme/components/search-input.styles.js +63 -0
- package/dist/src/theme/components/segmented-control.styles.d.ts +1 -0
- package/dist/src/theme/components/segmented-control.styles.js +63 -0
- package/dist/src/theme/components/separator.styles.d.ts +1 -0
- package/dist/src/theme/components/separator.styles.js +15 -0
- package/dist/src/theme/components/shortcut-keys.styles.d.ts +1 -0
- package/dist/src/theme/components/shortcut-keys.styles.js +34 -0
- package/dist/src/theme/components/skeleton.styles.d.ts +1 -0
- package/dist/src/theme/components/skeleton.styles.js +43 -0
- package/dist/src/theme/components/spinner.styles.d.ts +1 -0
- package/dist/src/theme/components/spinner.styles.js +27 -0
- package/dist/src/theme/components/state-dot.styles.d.ts +1 -0
- package/dist/src/theme/components/state-dot.styles.js +68 -0
- package/dist/src/theme/components/status-dot.styles.d.ts +1 -0
- package/dist/src/theme/components/status-dot.styles.js +72 -0
- package/dist/src/theme/components/tabs.styles.d.ts +1 -0
- package/dist/src/theme/components/tabs.styles.js +93 -0
- package/dist/src/theme/components/tag.styles.d.ts +1 -0
- package/dist/src/theme/components/tag.styles.js +55 -0
- package/dist/src/theme/components/text-shimmer.styles.d.ts +1 -0
- package/dist/src/theme/components/text-shimmer.styles.js +59 -0
- package/dist/src/theme/components/timeline.styles.d.ts +1 -0
- package/dist/src/theme/components/timeline.styles.js +87 -0
- package/dist/src/theme/components/toast.styles.d.ts +1 -0
- package/dist/src/theme/components/toast.styles.js +48 -0
- package/dist/src/theme/components/toggle.styles.d.ts +1 -0
- package/dist/src/theme/components/toggle.styles.js +85 -0
- package/dist/src/theme/components/toolbar.styles.d.ts +1 -0
- package/dist/src/theme/components/toolbar.styles.js +22 -0
- package/dist/src/theme/components/tooltip.styles.d.ts +1 -0
- package/dist/src/theme/components/tooltip.styles.js +26 -0
- package/dist/src/theme/components/web-block.styles.d.ts +1 -0
- package/dist/src/theme/components/web-block.styles.js +48 -0
- package/dist/src/theme/components/window-title-bar.styles.d.ts +6 -0
- package/dist/src/theme/components/window-title-bar.styles.js +57 -0
- package/dist/src/theme/components/work-card.styles.d.ts +1 -0
- package/dist/src/theme/components/work-card.styles.js +78 -0
- package/dist/src/theme/icons/icons.styles.d.ts +1 -0
- package/dist/src/theme/icons/icons.styles.js +29 -0
- package/dist/src/theme/index.d.ts +3 -0
- package/dist/src/theme/index.js +168 -0
- package/dist/src/theme/palette.d.ts +55 -0
- package/dist/src/theme/palette.js +56 -0
- package/dist/src/theme/shared/code-highlight.styles.d.ts +1 -0
- package/dist/src/theme/shared/code-highlight.styles.js +20 -0
- package/dist/src/theme/shared/code-highlight.tokens.d.ts +12 -0
- package/dist/src/theme/shared/code-highlight.tokens.js +13 -0
- package/dist/src/theme/tokens.d.ts +111 -0
- package/dist/src/theme/tokens.js +128 -0
- package/package.json +62 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AssistantViewProps } from "./assistant-types.js";
|
|
2
|
+
export declare const assistantComposerContract: {
|
|
3
|
+
readonly name: "assistant-composer";
|
|
4
|
+
readonly parts: readonly ["root", "choices", "feedback", "file"];
|
|
5
|
+
};
|
|
6
|
+
export declare const AssistantComposer: import("meowjsx").Component<{
|
|
7
|
+
options: AssistantViewProps;
|
|
8
|
+
}, "assistant-composer", "choices" | "feedback" | "file" | "root">;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { defineComponent, h, unwrap } from "meowjsx";
|
|
2
|
+
import { ChatComposer } from "./composer.js";
|
|
3
|
+
import { ChatAttachments } from "./attachments.js";
|
|
4
|
+
import { Button } from "../components/button.js";
|
|
5
|
+
import { ChoiceSelect } from "../components/choice-select.js";
|
|
6
|
+
import { Icon } from "../icons/icon.js";
|
|
7
|
+
import { assistantDerived } from "./assistant-content.js";
|
|
8
|
+
import { consumeAssistantDraft, snapshotAssistantDraft } from "./assistant-draft.js";
|
|
9
|
+
import { assistantCopy as defaultAssistantCopy, } from "./assistant-types.js";
|
|
10
|
+
export const assistantComposerContract = {
|
|
11
|
+
name: "assistant-composer",
|
|
12
|
+
parts: ["root", "choices", "feedback", "file"],
|
|
13
|
+
};
|
|
14
|
+
export const AssistantComposer = defineComponent(assistantComposerContract, ({ options }, context) => {
|
|
15
|
+
const assistantCopy = { ...defaultAssistantCopy, ...options.labels };
|
|
16
|
+
const controlled = options.draft !== undefined;
|
|
17
|
+
if (controlled && !options.onDraftChange && !options.readOnly)
|
|
18
|
+
throw new Error("A controlled Assistant draft requires onDraftChange or readOnly");
|
|
19
|
+
const local = context.signal(options.defaultDraft ?? { text: "", attachments: [] });
|
|
20
|
+
const draft = assistantDerived(context, () => controlled ? unwrap(options.draft) : local.value);
|
|
21
|
+
const text = assistantDerived(context, () => draft.value.text);
|
|
22
|
+
const pending = context.signal(false);
|
|
23
|
+
const attaching = context.signal(false);
|
|
24
|
+
const feedback = context.signal("");
|
|
25
|
+
const disabled = assistantDerived(context, () => options.readOnly || unwrap(options.disabled ?? false));
|
|
26
|
+
const submitDisabled = assistantDerived(context, () => disabled.value ||
|
|
27
|
+
pending.value ||
|
|
28
|
+
!options.onSubmit ||
|
|
29
|
+
(!draft.value.text.trim() && !draft.value.attachments.length));
|
|
30
|
+
let textVersion = 0;
|
|
31
|
+
let previousText = draft.value.text;
|
|
32
|
+
let disposed = false;
|
|
33
|
+
let textarea;
|
|
34
|
+
let fileInput;
|
|
35
|
+
const urls = new Set();
|
|
36
|
+
context.effect(() => {
|
|
37
|
+
if (previousText !== draft.value.text) {
|
|
38
|
+
previousText = draft.value.text;
|
|
39
|
+
textVersion++;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const change = (next, accepted = false) => {
|
|
43
|
+
if (!accepted && disabled.value)
|
|
44
|
+
return;
|
|
45
|
+
if (!controlled)
|
|
46
|
+
local.value = next;
|
|
47
|
+
options.onDraftChange?.(next);
|
|
48
|
+
};
|
|
49
|
+
const resize = () => {
|
|
50
|
+
if (!textarea)
|
|
51
|
+
return;
|
|
52
|
+
textarea.style.height = "auto";
|
|
53
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
54
|
+
};
|
|
55
|
+
const send = async (event) => {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
if (pending.value || submitDisabled.value || !options.onSubmit)
|
|
58
|
+
return;
|
|
59
|
+
const snapshot = snapshotAssistantDraft(draft.value);
|
|
60
|
+
const version = textVersion;
|
|
61
|
+
pending.value = true;
|
|
62
|
+
feedback.value = "";
|
|
63
|
+
try {
|
|
64
|
+
const result = await options.onSubmit(snapshot);
|
|
65
|
+
if (disposed)
|
|
66
|
+
return;
|
|
67
|
+
if (result?.accepted === true) {
|
|
68
|
+
change(consumeAssistantDraft(draft.value, snapshot, version === textVersion), true);
|
|
69
|
+
}
|
|
70
|
+
else
|
|
71
|
+
feedback.value = assistantCopy.rejected;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
if (!disposed)
|
|
75
|
+
feedback.value = assistantCopy.submitError;
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
if (!disposed) {
|
|
79
|
+
pending.value = false;
|
|
80
|
+
resize();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const attach = async (event) => {
|
|
85
|
+
const files = [...(event.currentTarget.files ?? [])];
|
|
86
|
+
event.currentTarget.value = "";
|
|
87
|
+
if (!files.length || disabled.value || attaching.value)
|
|
88
|
+
return;
|
|
89
|
+
attaching.value = true;
|
|
90
|
+
feedback.value = "";
|
|
91
|
+
try {
|
|
92
|
+
const result = options.onAttach
|
|
93
|
+
? await options.onAttach(files)
|
|
94
|
+
: files.map((file) => {
|
|
95
|
+
const url = URL.createObjectURL(file);
|
|
96
|
+
urls.add(url);
|
|
97
|
+
return {
|
|
98
|
+
id: url,
|
|
99
|
+
name: file.name,
|
|
100
|
+
mediaType: file.type || "application/octet-stream",
|
|
101
|
+
sizeBytes: file.size,
|
|
102
|
+
url,
|
|
103
|
+
file,
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
if (!disposed && result)
|
|
107
|
+
change({ ...draft.value, attachments: [...draft.value.attachments, ...result] });
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
if (!disposed)
|
|
111
|
+
feedback.value = assistantCopy.attachError;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
if (!disposed)
|
|
115
|
+
attaching.value = false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
context.onCleanup(() => {
|
|
119
|
+
disposed = true;
|
|
120
|
+
for (const url of urls)
|
|
121
|
+
URL.revokeObjectURL(url);
|
|
122
|
+
});
|
|
123
|
+
const localModel = context.signal(unwrap(options.models ?? [])[0]?.value ?? "");
|
|
124
|
+
const localReasoning = context.signal(unwrap(options.reasoningOptions ?? [])[0]?.value ?? "");
|
|
125
|
+
const choices = context.part("choices", "div", null, assistantDerived(context, () => {
|
|
126
|
+
const models = unwrap(options.models ?? []);
|
|
127
|
+
return models.length
|
|
128
|
+
? h(ChoiceSelect, {
|
|
129
|
+
options: models,
|
|
130
|
+
value: options.model ?? localModel,
|
|
131
|
+
"aria-label": assistantCopy.model,
|
|
132
|
+
onValueChange: (value) => {
|
|
133
|
+
if (options.model === undefined)
|
|
134
|
+
localModel.value = value;
|
|
135
|
+
options.onModelChange?.(value);
|
|
136
|
+
},
|
|
137
|
+
placement: "top",
|
|
138
|
+
matchTriggerWidth: false,
|
|
139
|
+
})
|
|
140
|
+
: null;
|
|
141
|
+
}), assistantDerived(context, () => {
|
|
142
|
+
const reasoning = unwrap(options.reasoningOptions ?? []);
|
|
143
|
+
return reasoning.length
|
|
144
|
+
? h(ChoiceSelect, {
|
|
145
|
+
options: reasoning,
|
|
146
|
+
value: options.reasoning ?? localReasoning,
|
|
147
|
+
"aria-label": assistantCopy.reasoning,
|
|
148
|
+
onValueChange: (value) => {
|
|
149
|
+
if (options.reasoning === undefined)
|
|
150
|
+
localReasoning.value = value;
|
|
151
|
+
options.onReasoningChange?.(value);
|
|
152
|
+
},
|
|
153
|
+
placement: "top",
|
|
154
|
+
matchTriggerWidth: false,
|
|
155
|
+
})
|
|
156
|
+
: null;
|
|
157
|
+
}), options.composerTrailing);
|
|
158
|
+
return context.part("root", "div", null, h(ChatComposer, {
|
|
159
|
+
value: text,
|
|
160
|
+
placeholder: assistantCopy.placeholder,
|
|
161
|
+
inputLabel: assistantCopy.composer,
|
|
162
|
+
submitLabel: assistantCopy.send,
|
|
163
|
+
submitDisabled,
|
|
164
|
+
trailing: choices,
|
|
165
|
+
attachments: assistantDerived(context, () => draft.value.attachments.length
|
|
166
|
+
? h(ChatAttachments, {
|
|
167
|
+
items: draft.value.attachments.map((attachment) => ({
|
|
168
|
+
...attachment,
|
|
169
|
+
onRemove: disabled.value
|
|
170
|
+
? undefined
|
|
171
|
+
: () => change({
|
|
172
|
+
...draft.value,
|
|
173
|
+
attachments: draft.value.attachments.filter((item) => item !== attachment),
|
|
174
|
+
}),
|
|
175
|
+
})),
|
|
176
|
+
})
|
|
177
|
+
: null),
|
|
178
|
+
hint: assistantDerived(context, () => unwrap(options.disabledReason ?? "")),
|
|
179
|
+
onSubmit: send,
|
|
180
|
+
onInput: (event) => {
|
|
181
|
+
textVersion++;
|
|
182
|
+
change({ ...draft.value, text: event.target.value });
|
|
183
|
+
resize();
|
|
184
|
+
},
|
|
185
|
+
onKeyDown: (event) => {
|
|
186
|
+
if (event.target === textarea &&
|
|
187
|
+
event.key === "Enter" &&
|
|
188
|
+
!event.shiftKey &&
|
|
189
|
+
!event.isComposing &&
|
|
190
|
+
event.keyCode !== 229)
|
|
191
|
+
void send(event);
|
|
192
|
+
},
|
|
193
|
+
ref: (form) => {
|
|
194
|
+
let active = true;
|
|
195
|
+
let stop;
|
|
196
|
+
const observer = new ResizeObserver(resize);
|
|
197
|
+
observer.observe(form);
|
|
198
|
+
// Host refs run before children mount; find the native input after this tree is mounted.
|
|
199
|
+
queueMicrotask(() => {
|
|
200
|
+
if (!active || disposed || !form.isConnected)
|
|
201
|
+
return;
|
|
202
|
+
textarea = form.querySelector("textarea");
|
|
203
|
+
stop = context.effect(() => {
|
|
204
|
+
const value = text.value;
|
|
205
|
+
textarea.disabled = !!disabled.value;
|
|
206
|
+
textarea.readOnly = !!options.readOnly;
|
|
207
|
+
queueMicrotask(() => {
|
|
208
|
+
if (!disposed && textarea) {
|
|
209
|
+
if (textarea.value !== value)
|
|
210
|
+
textarea.value = value;
|
|
211
|
+
resize();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
resize();
|
|
216
|
+
});
|
|
217
|
+
return () => {
|
|
218
|
+
active = false;
|
|
219
|
+
stop?.();
|
|
220
|
+
observer.disconnect();
|
|
221
|
+
textarea = undefined;
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
children: options.allowAttachments === false
|
|
225
|
+
? []
|
|
226
|
+
: [
|
|
227
|
+
h(Button, {
|
|
228
|
+
variant: "quiet",
|
|
229
|
+
size: "small",
|
|
230
|
+
"aria-label": assistantCopy.attach,
|
|
231
|
+
disabled: assistantDerived(context, () => disabled.value || attaching.value),
|
|
232
|
+
onClick: () => fileInput?.click(),
|
|
233
|
+
children: h(Icon, { name: "paperclip" }),
|
|
234
|
+
}),
|
|
235
|
+
context.part("file", "input", {
|
|
236
|
+
type: "file",
|
|
237
|
+
multiple: true,
|
|
238
|
+
hidden: true,
|
|
239
|
+
onChange: attach,
|
|
240
|
+
ref: (element) => {
|
|
241
|
+
fileInput = element;
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
],
|
|
245
|
+
}), context.part("feedback", "p", { role: "status", hidden: assistantDerived(context, () => !feedback.value) }, feedback));
|
|
246
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LifecycleScope, type Signal } from "meowjsx";
|
|
2
|
+
import type { AssistantMessage, AssistantMessagePart, AssistantProcessStep, AssistantViewProps } from "./assistant-types.js";
|
|
3
|
+
/** All derived values live in their owning component lifecycle. */
|
|
4
|
+
export declare function assistantDerived<T>(context: Pick<LifecycleScope, "signal" | "effect">, read: () => T): import("meowjsx").WritableSignal<T>;
|
|
5
|
+
export declare const assistantStepsContract: {
|
|
6
|
+
readonly name: "assistant-steps";
|
|
7
|
+
readonly parts: readonly ["root", "step", "label", "description", "status"];
|
|
8
|
+
};
|
|
9
|
+
export declare const AssistantSteps: import("meowjsx").Component<{
|
|
10
|
+
steps: Signal<readonly AssistantProcessStep[]>;
|
|
11
|
+
}, "assistant-steps", "description" | "label" | "root" | "status" | "step">;
|
|
12
|
+
export declare const AssistantPartView: import("meowjsx").Component<{
|
|
13
|
+
value: Signal<AssistantMessagePart>;
|
|
14
|
+
message: Signal<AssistantMessage>;
|
|
15
|
+
renderPart?: AssistantViewProps["renderPart"];
|
|
16
|
+
}, "assistant-part", "root">;
|
|
17
|
+
export declare const AssistantMessageView: import("meowjsx").Component<{
|
|
18
|
+
value: Signal<AssistantMessage>;
|
|
19
|
+
renderPart?: AssistantViewProps["renderPart"];
|
|
20
|
+
}, "assistant-message", "root">;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { defineComponent, h, keyed, unwrap, } from "meowjsx";
|
|
2
|
+
import { ChatMessage } from "./message.js";
|
|
3
|
+
import { ChatAttachments } from "./attachments.js";
|
|
4
|
+
import { ProcessGroup } from "../components/process-group.js";
|
|
5
|
+
import { CodeBlock } from "../components/code-block.js";
|
|
6
|
+
import { StatusDot } from "../components/status-dot.js";
|
|
7
|
+
import { AssistantMarkdown } from "./assistant-markdown.js";
|
|
8
|
+
/** All derived values live in their owning component lifecycle. */
|
|
9
|
+
export function assistantDerived(context, read) {
|
|
10
|
+
const value = context.signal(read());
|
|
11
|
+
context.effect(() => {
|
|
12
|
+
value.value = read();
|
|
13
|
+
});
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
export const assistantStepsContract = {
|
|
17
|
+
name: "assistant-steps",
|
|
18
|
+
parts: ["root", "step", "label", "description", "status"],
|
|
19
|
+
};
|
|
20
|
+
const AssistantStep = defineComponent(assistantStepsContract, ({ value }, context) => context.part("step", "li", null, h(StatusDot, { state: assistantDerived(context, () => value.value.tone ?? "unknown") }), context.part("label", "div", null, h("strong", null, assistantDerived(context, () => value.value.title)), context.part("description", "p", { hidden: assistantDerived(context, () => !value.value.description) }, assistantDerived(context, () => value.value.description ?? ""))), context.part("status", "span", null, assistantDerived(context, () => value.value.statusText ?? ""))));
|
|
21
|
+
export const AssistantSteps = defineComponent(assistantStepsContract, ({ steps }, context) => context.part("root", "ol", null, keyed(steps, (step) => step.id, (value) => h(AssistantStep, { value }))));
|
|
22
|
+
export const AssistantPartView = defineComponent({ name: "assistant-part", parts: ["root"] }, ({ value, message, renderPart }, context) => {
|
|
23
|
+
// The keyed identity includes kind, so this component's structural variant is stable.
|
|
24
|
+
const initial = value.value;
|
|
25
|
+
const custom = renderPart
|
|
26
|
+
? assistantDerived(context, () => renderPart(value.value, message.value))
|
|
27
|
+
: undefined;
|
|
28
|
+
let fallback;
|
|
29
|
+
if (initial.kind === "text") {
|
|
30
|
+
fallback = h(AssistantMarkdown, {
|
|
31
|
+
text: assistantDerived(context, () => value.value.text),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else if (initial.kind === "process") {
|
|
35
|
+
fallback = h(ProcessGroup, {
|
|
36
|
+
title: assistantDerived(context, () => value.value.title),
|
|
37
|
+
status: assistantDerived(context, () => value.value.statusText),
|
|
38
|
+
open: initial.defaultOpen ?? false,
|
|
39
|
+
children: h(AssistantSteps, {
|
|
40
|
+
steps: assistantDerived(context, () => value.value.steps),
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (initial.kind === "code") {
|
|
45
|
+
// CodeBlock owns its copy/wrap/highlight lifecycle. Replace only this block on code changes.
|
|
46
|
+
fallback = assistantDerived(context, () => {
|
|
47
|
+
const part = value.value;
|
|
48
|
+
return h(CodeBlock, { code: part.code, language: part.language });
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
fallback = assistantDerived(context, () => h(ChatAttachments, { items: value.value.items }));
|
|
53
|
+
}
|
|
54
|
+
const content = custom ? assistantDerived(context, () => unwrap(custom) ?? fallback) : fallback;
|
|
55
|
+
return context.part("root", "div", { "data-assistant-part-id": initial.id, "data-kind": initial.kind }, content);
|
|
56
|
+
});
|
|
57
|
+
export const AssistantMessageView = defineComponent({ name: "assistant-message", parts: ["root"] }, ({ value, renderPart }, context) => {
|
|
58
|
+
const parts = assistantDerived(context, () => value.value.parts);
|
|
59
|
+
return context.part("root", "div", { "data-assistant-message-id": value.value.id }, h(ChatMessage, {
|
|
60
|
+
role: value.value.role,
|
|
61
|
+
author: "",
|
|
62
|
+
header: h("div", { "data-assistant-message-header": true }, h("strong", null, assistantDerived(context, () => value.value.author)), h("time", null, assistantDerived(context, () => value.value.timestamp ?? "")), h("span", { role: "status" }, assistantDerived(context, () => value.value.status && value.value.status !== "complete" ? value.value.status : ""))),
|
|
63
|
+
surface: "none",
|
|
64
|
+
children: keyed(parts, (part) => `${part.id}:${part.kind}`, (part) => h(AssistantPartView, { value: part, message: value, renderPart })),
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AssistantDraft } from "./assistant-types.js";
|
|
2
|
+
/** Isolate submitted metadata from later in-place host edits; keep File and action identities. */
|
|
3
|
+
export declare function snapshotAssistantDraft(draft: AssistantDraft): AssistantDraft;
|
|
4
|
+
/** Consume only the fields accepted by this submission, never a later edit or attachment. */
|
|
5
|
+
export declare function consumeAssistantDraft(current: AssistantDraft, submitted: AssistantDraft, textUnchanged: boolean): AssistantDraft;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Isolate submitted metadata from later in-place host edits; keep File and action identities. */
|
|
2
|
+
export function snapshotAssistantDraft(draft) {
|
|
3
|
+
return {
|
|
4
|
+
text: draft.text,
|
|
5
|
+
attachments: draft.attachments.map((attachment) => ({ ...attachment })),
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/** Consume only the fields accepted by this submission, never a later edit or attachment. */
|
|
9
|
+
export function consumeAssistantDraft(current, submitted, textUnchanged) {
|
|
10
|
+
const accepted = new Map(submitted.attachments.map((attachment) => [attachment.id, attachment]));
|
|
11
|
+
return {
|
|
12
|
+
text: textUnchanged && current.text === submitted.text ? "" : current.text,
|
|
13
|
+
attachments: current.attachments.filter((attachment) => {
|
|
14
|
+
const original = accepted.get(attachment.id);
|
|
15
|
+
return (!original ||
|
|
16
|
+
original.url !== attachment.url ||
|
|
17
|
+
original.file !== attachment.file ||
|
|
18
|
+
original.name !== attachment.name ||
|
|
19
|
+
original.mediaType !== attachment.mediaType ||
|
|
20
|
+
original.sizeBytes !== attachment.sizeBytes);
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Signal } from "meowjsx";
|
|
2
|
+
export declare function assistantSafeLink(href: string): string | undefined;
|
|
3
|
+
/** Raw HTML and images are text. Only explicit safe external links become navigation. */
|
|
4
|
+
export declare const assistantMarkdown: (text: string) => string;
|
|
5
|
+
export declare const assistantMarkdownContract: {
|
|
6
|
+
readonly name: "assistant-markdown";
|
|
7
|
+
readonly parts: readonly ["root"];
|
|
8
|
+
};
|
|
9
|
+
export declare const AssistantMarkdown: import("meowjsx").Component<{
|
|
10
|
+
text: Signal<string>;
|
|
11
|
+
}, "assistant-markdown", "root">;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineComponent } from "meowjsx";
|
|
2
|
+
import { Marked, Renderer } from "marked";
|
|
3
|
+
const escape = (text) => text.replace(/[&<>"']/g, (value) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[value]);
|
|
4
|
+
export function assistantSafeLink(href) {
|
|
5
|
+
try {
|
|
6
|
+
const url = new URL(href);
|
|
7
|
+
return ["http:", "https:", "mailto:"].includes(url.protocol) ? url.href : undefined;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const renderer = new Renderer();
|
|
14
|
+
renderer.html = ({ text }) => escape(text);
|
|
15
|
+
renderer.image = ({ text }) => escape(text);
|
|
16
|
+
renderer.link = function ({ href, title, tokens }) {
|
|
17
|
+
const label = this.parser.parseInline(tokens);
|
|
18
|
+
const link = assistantSafeLink(href);
|
|
19
|
+
return link
|
|
20
|
+
? `<a href="${escape(link)}" target="_blank" rel="noreferrer"${title ? ` title="${escape(title)}"` : ""}>${label}</a>`
|
|
21
|
+
: label;
|
|
22
|
+
};
|
|
23
|
+
const markdown = new Marked({ renderer, gfm: true, breaks: true });
|
|
24
|
+
/** Raw HTML and images are text. Only explicit safe external links become navigation. */
|
|
25
|
+
export const assistantMarkdown = (text) => markdown.parse(text, { async: false });
|
|
26
|
+
export const assistantMarkdownContract = { name: "assistant-markdown", parts: ["root"] };
|
|
27
|
+
export const AssistantMarkdown = defineComponent(assistantMarkdownContract, ({ text }, context) => {
|
|
28
|
+
const html = context.signal({ __html: assistantMarkdown(text.value) });
|
|
29
|
+
context.effect(() => {
|
|
30
|
+
html.value = { __html: assistantMarkdown(text.value) };
|
|
31
|
+
});
|
|
32
|
+
return context.part("root", "div", { dangerouslySetInnerHTML: html });
|
|
33
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Signal } from "meowjsx";
|
|
2
|
+
import { type AssistantLabels, type AssistantQuestion, type AssistantViewProps } from "./assistant-types.js";
|
|
3
|
+
export declare const assistantQuestionContract: {
|
|
4
|
+
readonly name: "assistant-question";
|
|
5
|
+
readonly parts: readonly ["root", "answer", "options"];
|
|
6
|
+
};
|
|
7
|
+
export declare const AssistantQuestionView: import("meowjsx").Component<{
|
|
8
|
+
value: Signal<AssistantQuestion>;
|
|
9
|
+
onAnswer?: AssistantViewProps["onAnswer"];
|
|
10
|
+
onDismiss?: AssistantViewProps["onDismissQuestion"];
|
|
11
|
+
labels?: Partial<AssistantLabels>;
|
|
12
|
+
}, "assistant-question", "answer" | "options" | "root">;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { defineComponent, h } from "meowjsx";
|
|
2
|
+
import { ChatQuestion } from "./question.js";
|
|
3
|
+
import { Button } from "../components/button.js";
|
|
4
|
+
import { Select } from "../components/select.js";
|
|
5
|
+
import { assistantDerived } from "./assistant-content.js";
|
|
6
|
+
import { assistantCopy as defaultAssistantCopy, } from "./assistant-types.js";
|
|
7
|
+
export const assistantQuestionContract = {
|
|
8
|
+
name: "assistant-question",
|
|
9
|
+
parts: ["root", "answer", "options"],
|
|
10
|
+
};
|
|
11
|
+
export const AssistantQuestionView = defineComponent(assistantQuestionContract, ({ value, onAnswer, onDismiss, labels }, context) => {
|
|
12
|
+
const assistantCopy = { ...defaultAssistantCopy, ...labels };
|
|
13
|
+
const answer = context.signal("");
|
|
14
|
+
const sending = context.signal(false);
|
|
15
|
+
const error = context.signal("");
|
|
16
|
+
const disabled = assistantDerived(context, () => sending.value || value.value.state !== "open" || !onAnswer);
|
|
17
|
+
let disposed = false;
|
|
18
|
+
context.onCleanup(() => {
|
|
19
|
+
disposed = true;
|
|
20
|
+
});
|
|
21
|
+
const submit = async (event) => {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
if (sending.value || disabled.value || !answer.value.trim() || !onAnswer)
|
|
24
|
+
return;
|
|
25
|
+
sending.value = true;
|
|
26
|
+
error.value = "";
|
|
27
|
+
try {
|
|
28
|
+
await onAnswer(value.value.id, answer.value);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
if (!disposed)
|
|
32
|
+
error.value = assistantCopy.answerError;
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
if (!disposed)
|
|
36
|
+
sending.value = false;
|
|
37
|
+
}
|
|
38
|
+
// Question state and answer acceptance remain facts supplied by the host.
|
|
39
|
+
};
|
|
40
|
+
return context.part("root", "form", { onSubmit: submit }, h(ChatQuestion, {
|
|
41
|
+
question: assistantDerived(context, () => value.value.title),
|
|
42
|
+
label: assistantCopy.questions,
|
|
43
|
+
description: assistantDerived(context, () => value.value.description),
|
|
44
|
+
feedback: assistantDerived(context, () => error.value ||
|
|
45
|
+
value.value.feedback ||
|
|
46
|
+
(value.value.state === "submitting"
|
|
47
|
+
? assistantCopy.questionSubmitting
|
|
48
|
+
: value.value.state === "answered"
|
|
49
|
+
? assistantCopy.questionAnswered
|
|
50
|
+
: value.value.state === "unavailable"
|
|
51
|
+
? assistantCopy.questionUnavailable
|
|
52
|
+
: "")),
|
|
53
|
+
children: [
|
|
54
|
+
context.part("options", "div", { hidden: assistantDerived(context, () => !value.value.options?.length) }, h(Select, {
|
|
55
|
+
value: answer,
|
|
56
|
+
disabled,
|
|
57
|
+
"aria-label": value.value.title,
|
|
58
|
+
onChange: (event) => {
|
|
59
|
+
answer.value = event.currentTarget.value;
|
|
60
|
+
},
|
|
61
|
+
children: assistantDerived(context, () => [
|
|
62
|
+
h("option", { value: "" }, assistantCopy.answerPlaceholder),
|
|
63
|
+
...(value.value.options ?? []).map((option) => h("option", { value: option.value }, option.label)),
|
|
64
|
+
]),
|
|
65
|
+
})),
|
|
66
|
+
context.part("answer", "textarea", {
|
|
67
|
+
value: answer,
|
|
68
|
+
rows: 2,
|
|
69
|
+
"aria-label": `${assistantCopy.answer}: ${value.value.title}`,
|
|
70
|
+
placeholder: assistantCopy.answerPlaceholder,
|
|
71
|
+
disabled,
|
|
72
|
+
onInput: (event) => {
|
|
73
|
+
answer.value = event.currentTarget.value;
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
actions: [
|
|
78
|
+
h(Button, {
|
|
79
|
+
type: "submit",
|
|
80
|
+
size: "small",
|
|
81
|
+
disabled: assistantDerived(context, () => disabled.value || !answer.value.trim()),
|
|
82
|
+
children: assistantCopy.answer,
|
|
83
|
+
}),
|
|
84
|
+
onDismiss
|
|
85
|
+
? h(Button, {
|
|
86
|
+
variant: "quiet",
|
|
87
|
+
size: "small",
|
|
88
|
+
disabled: assistantDerived(context, () => sending.value || value.value.state !== "open"),
|
|
89
|
+
onClick: () => onDismiss(value.value.id),
|
|
90
|
+
children: assistantCopy.dismiss,
|
|
91
|
+
})
|
|
92
|
+
: null,
|
|
93
|
+
],
|
|
94
|
+
}));
|
|
95
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The transcript has exactly one scroll owner. The latest control belongs to this viewport. */
|
|
2
|
+
export declare function assistantScroll(viewport: HTMLElement, content: HTMLElement, onLatest: (latest: boolean) => void): {
|
|
3
|
+
beforeUpdate: () => void;
|
|
4
|
+
afterUpdate: () => void;
|
|
5
|
+
latest(): void;
|
|
6
|
+
dispose(): void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** The transcript has exactly one scroll owner. The latest control belongs to this viewport. */
|
|
2
|
+
export function assistantScroll(viewport, content, onLatest) {
|
|
3
|
+
let following = true;
|
|
4
|
+
let anchor;
|
|
5
|
+
let top = viewport.scrollTop;
|
|
6
|
+
let restoring = false;
|
|
7
|
+
const rows = () => [...content.querySelectorAll("[data-assistant-message-id]")];
|
|
8
|
+
const atLatest = () => viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop <= 24;
|
|
9
|
+
const capture = () => {
|
|
10
|
+
top = viewport.scrollTop;
|
|
11
|
+
const origin = viewport.getBoundingClientRect().top;
|
|
12
|
+
const row = rows().find((item) => item.getBoundingClientRect().bottom > origin);
|
|
13
|
+
anchor = row
|
|
14
|
+
? { id: row.dataset.assistantMessageId, offset: row.getBoundingClientRect().top - origin }
|
|
15
|
+
: undefined;
|
|
16
|
+
};
|
|
17
|
+
const restore = () => {
|
|
18
|
+
if (!viewport.clientHeight)
|
|
19
|
+
return;
|
|
20
|
+
restoring = true;
|
|
21
|
+
if (following)
|
|
22
|
+
viewport.scrollTop = Math.max(0, viewport.scrollHeight - viewport.clientHeight);
|
|
23
|
+
else {
|
|
24
|
+
const row = anchor && rows().find((item) => item.dataset.assistantMessageId === anchor.id);
|
|
25
|
+
viewport.scrollTop =
|
|
26
|
+
row && anchor
|
|
27
|
+
? viewport.scrollTop +
|
|
28
|
+
row.getBoundingClientRect().top -
|
|
29
|
+
viewport.getBoundingClientRect().top -
|
|
30
|
+
anchor.offset
|
|
31
|
+
: top;
|
|
32
|
+
}
|
|
33
|
+
capture();
|
|
34
|
+
onLatest(atLatest());
|
|
35
|
+
restoring = false;
|
|
36
|
+
};
|
|
37
|
+
const scroll = () => {
|
|
38
|
+
if (restoring)
|
|
39
|
+
return;
|
|
40
|
+
following = atLatest();
|
|
41
|
+
capture();
|
|
42
|
+
onLatest(following);
|
|
43
|
+
};
|
|
44
|
+
const inspectDisclosure = (event) => {
|
|
45
|
+
const summary = event.target instanceof Element ? event.target.closest("summary") : null;
|
|
46
|
+
if (!summary || !content.contains(summary))
|
|
47
|
+
return;
|
|
48
|
+
// Expanding an earlier process is a reading action, not a request to follow its new height.
|
|
49
|
+
following = false;
|
|
50
|
+
capture();
|
|
51
|
+
};
|
|
52
|
+
viewport.addEventListener("scroll", scroll, { passive: true });
|
|
53
|
+
viewport.addEventListener("click", inspectDisclosure);
|
|
54
|
+
const observer = new ResizeObserver(restore);
|
|
55
|
+
observer.observe(viewport);
|
|
56
|
+
observer.observe(content);
|
|
57
|
+
restore();
|
|
58
|
+
return {
|
|
59
|
+
beforeUpdate: capture,
|
|
60
|
+
afterUpdate: restore,
|
|
61
|
+
latest() {
|
|
62
|
+
following = true;
|
|
63
|
+
restore();
|
|
64
|
+
viewport.focus({ preventScroll: true });
|
|
65
|
+
},
|
|
66
|
+
dispose() {
|
|
67
|
+
observer.disconnect();
|
|
68
|
+
viewport.removeEventListener("scroll", scroll);
|
|
69
|
+
viewport.removeEventListener("click", inspectDisclosure);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|