@kitn.ai/ui 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +394 -0
- package/dist/bash-InADTalH.js +1 -0
- package/dist/core-AYMC6_lb.js +12 -0
- package/dist/css-M7EaDHN_.js +1 -0
- package/dist/custom-elements.json +4739 -0
- package/dist/engine-javascript-vq0WuIJl.js +141 -0
- package/dist/github-dark-dimmed-DUshB20C.js +1 -0
- package/dist/github-light-JYsPkUQd.js +1 -0
- package/dist/host-embed.d.ts +33 -0
- package/dist/html-CPZ3oZQ7.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/javascript-C25yR2R2.js +1 -0
- package/dist/json-DxJze_jm.js +1 -0
- package/dist/kitn-chat-provider.d.ts +2 -0
- package/dist/kitn-chat-provider.es.js +240 -0
- package/dist/kitn-chat.es.js +77 -0
- package/dist/llms/llms-full.txt +1018 -0
- package/dist/llms/llms.txt +104 -0
- package/dist/origin.d.ts +5 -0
- package/dist/provider-runtime.d.ts +27 -0
- package/dist/schemas/card-envelope.schema.json +14 -0
- package/dist/schemas/card-event.schema.json +12 -0
- package/dist/schemas/choice.schema.json +70 -0
- package/dist/schemas/confirm.schema.json +65 -0
- package/dist/schemas/embed.schema.json +65 -0
- package/dist/schemas/form.result.schema.json +7 -0
- package/dist/schemas/form.schema.json +33 -0
- package/dist/schemas/link.schema.json +56 -0
- package/dist/schemas/tasks.result.schema.json +16 -0
- package/dist/schemas/tasks.schema.json +78 -0
- package/dist/svelte--5p79yCD.js +1 -0
- package/dist/theme.tokens.css +176 -0
- package/dist/tsx-B8rCNbgL.js +1 -0
- package/dist/typescript-RycA9KXf.js +1 -0
- package/dist/validate.d.ts +4 -0
- package/dist/version.d.ts +4 -0
- package/dist/vue-BmIZj4XD.js +1 -0
- package/dist/wire.d.ts +53 -0
- package/frameworks/react/index.tsx +948 -0
- package/frameworks/react/runtime.tsx +94 -0
- package/llms-full.txt +1018 -0
- package/llms.txt +104 -0
- package/package.json +141 -0
- package/src/components/artifact.stories.tsx +138 -0
- package/src/components/artifact.tsx +743 -0
- package/src/components/attachments.stories.tsx +303 -0
- package/src/components/attachments.test.tsx +64 -0
- package/src/components/attachments.tsx +399 -0
- package/src/components/card-fallback.tsx +28 -0
- package/src/components/card-renderer.tsx +52 -0
- package/src/components/card.tsx +110 -0
- package/src/components/chain-of-thought.stories.tsx +211 -0
- package/src/components/chain-of-thought.tsx +139 -0
- package/src/components/chat-container.stories.tsx +187 -0
- package/src/components/chat-container.tsx +82 -0
- package/src/components/chat-scope-picker.tsx +47 -0
- package/src/components/chat-thread.test.tsx +58 -0
- package/src/components/chat-thread.tsx +249 -0
- package/src/components/checkpoint.stories.tsx +102 -0
- package/src/components/checkpoint.tsx +88 -0
- package/src/components/choice-card.tsx +569 -0
- package/src/components/code-block.stories.tsx +150 -0
- package/src/components/code-block.tsx +105 -0
- package/src/components/component-meta.json +3735 -0
- package/src/components/confirm-card.stories.tsx +74 -0
- package/src/components/confirm-card.tsx +315 -0
- package/src/components/context.stories.tsx +229 -0
- package/src/components/context.test.tsx +133 -0
- package/src/components/context.tsx +363 -0
- package/src/components/conversation-item.stories.tsx +125 -0
- package/src/components/conversation-item.tsx +16 -0
- package/src/components/conversation-list.stories.tsx +133 -0
- package/src/components/conversation-list.tsx +101 -0
- package/src/components/default-input.test.tsx +111 -0
- package/src/components/embed.tsx +196 -0
- package/src/components/empty.stories.tsx +434 -0
- package/src/components/empty.tsx +166 -0
- package/src/components/feedback-bar.stories.tsx +138 -0
- package/src/components/feedback-bar.test.tsx +103 -0
- package/src/components/feedback-bar.tsx +166 -0
- package/src/components/file-tree.stories.tsx +73 -0
- package/src/components/file-tree.tsx +383 -0
- package/src/components/file-upload.stories.tsx +156 -0
- package/src/components/file-upload.tsx +161 -0
- package/src/components/form-widgets.tsx +461 -0
- package/src/components/form.tsx +873 -0
- package/src/components/image.stories.tsx +89 -0
- package/src/components/image.tsx +67 -0
- package/src/components/link-preview.tsx +194 -0
- package/src/components/loader.stories.tsx +181 -0
- package/src/components/loader.tsx +333 -0
- package/src/components/markdown.stories.tsx +180 -0
- package/src/components/markdown.tsx +81 -0
- package/src/components/message-action-bar.test.tsx +128 -0
- package/src/components/message-narrow.stories.tsx +329 -0
- package/src/components/message-skills.stories.tsx +211 -0
- package/src/components/message-skills.tsx +36 -0
- package/src/components/message.stories.tsx +281 -0
- package/src/components/message.tsx +227 -0
- package/src/components/model-switcher.stories.tsx +123 -0
- package/src/components/model-switcher.test.tsx +65 -0
- package/src/components/model-switcher.tsx +87 -0
- package/src/components/prompt-input.stories.tsx +222 -0
- package/src/components/prompt-input.tsx +211 -0
- package/src/components/prompt-suggestion.stories.tsx +142 -0
- package/src/components/prompt-suggestion.tsx +115 -0
- package/src/components/reasoning.stories.tsx +140 -0
- package/src/components/reasoning.tsx +156 -0
- package/src/components/resizable.test.tsx +226 -0
- package/src/components/response-stream.tsx +103 -0
- package/src/components/scroll-button.stories.tsx +100 -0
- package/src/components/scroll-button.tsx +34 -0
- package/src/components/slash-command.stories.tsx +163 -0
- package/src/components/slash-command.tsx +232 -0
- package/src/components/source-list.test.tsx +152 -0
- package/src/components/source.stories.tsx +124 -0
- package/src/components/source.tsx +129 -0
- package/src/components/tasks-card.stories.tsx +78 -0
- package/src/components/tasks-card.tsx +432 -0
- package/src/components/text-shimmer.stories.tsx +87 -0
- package/src/components/text-shimmer.tsx +37 -0
- package/src/components/thinking-bar.stories.tsx +87 -0
- package/src/components/thinking-bar.tsx +50 -0
- package/src/components/tool.stories.tsx +153 -0
- package/src/components/tool.tsx +184 -0
- package/src/components/use-card-resolution.ts +28 -0
- package/src/components/voice-input.stories.tsx +83 -0
- package/src/components/voice-input.tsx +107 -0
- package/src/elements/artifact.stories.tsx +506 -0
- package/src/elements/artifact.tsx +137 -0
- package/src/elements/attachments.stories.tsx +190 -0
- package/src/elements/attachments.tsx +136 -0
- package/src/elements/card.stories.tsx +113 -0
- package/src/elements/card.tsx +40 -0
- package/src/elements/cards.stories.tsx +59 -0
- package/src/elements/cards.tsx +97 -0
- package/src/elements/catalog.stories.tsx +491 -0
- package/src/elements/chain-of-thought.declarative.test.tsx +153 -0
- package/src/elements/chain-of-thought.stories.tsx +113 -0
- package/src/elements/chain-of-thought.tsx +92 -0
- package/src/elements/chat-scope-picker.stories.tsx +73 -0
- package/src/elements/chat-scope-picker.tsx +36 -0
- package/src/elements/chat-types.ts +42 -0
- package/src/elements/chat-workspace.stories.tsx +288 -0
- package/src/elements/chat-workspace.tsx +161 -0
- package/src/elements/chat.stories.tsx +151 -0
- package/src/elements/chat.tsx +80 -0
- package/src/elements/checkpoint.stories.tsx +72 -0
- package/src/elements/checkpoint.tsx +47 -0
- package/src/elements/choice.stories.tsx +240 -0
- package/src/elements/choice.tsx +48 -0
- package/src/elements/code-block.stories.tsx +83 -0
- package/src/elements/code-block.tsx +42 -0
- package/src/elements/compiled.css +2 -0
- package/src/elements/composed-shell.stories.tsx +316 -0
- package/src/elements/confirm-card.stories.tsx +227 -0
- package/src/elements/confirm-card.tsx +51 -0
- package/src/elements/context-meter.stories.tsx +151 -0
- package/src/elements/context-meter.tsx +121 -0
- package/src/elements/conversation-list.declarative.test.tsx +137 -0
- package/src/elements/conversation-list.stories.tsx +243 -0
- package/src/elements/conversation-list.tsx +80 -0
- package/src/elements/css.ts +5 -0
- package/src/elements/default-input.tsx +247 -0
- package/src/elements/define.tsx +171 -0
- package/src/elements/element-meta.json +3314 -0
- package/src/elements/element-types.d.ts +710 -0
- package/src/elements/embed.stories.tsx +213 -0
- package/src/elements/embed.tsx +35 -0
- package/src/elements/empty.stories.tsx +111 -0
- package/src/elements/empty.tsx +29 -0
- package/src/elements/feedback-bar.stories.tsx +114 -0
- package/src/elements/feedback-bar.tsx +61 -0
- package/src/elements/file-tree.stories.tsx +134 -0
- package/src/elements/file-tree.tsx +52 -0
- package/src/elements/file-upload.stories.tsx +82 -0
- package/src/elements/file-upload.tsx +44 -0
- package/src/elements/form.stories.tsx +248 -0
- package/src/elements/form.tsx +43 -0
- package/src/elements/framework-usage.json +563 -0
- package/src/elements/image.stories.tsx +71 -0
- package/src/elements/image.tsx +32 -0
- package/src/elements/link-preview.stories.tsx +209 -0
- package/src/elements/link-preview.tsx +34 -0
- package/src/elements/loader.stories.tsx +88 -0
- package/src/elements/loader.tsx +25 -0
- package/src/elements/markdown.stories.tsx +76 -0
- package/src/elements/markdown.tsx +38 -0
- package/src/elements/message-skills.declarative.test.tsx +104 -0
- package/src/elements/message-skills.stories.tsx +114 -0
- package/src/elements/message-skills.tsx +85 -0
- package/src/elements/message.stories.tsx +218 -0
- package/src/elements/message.tsx +162 -0
- package/src/elements/model-switcher.declarative.test.tsx +130 -0
- package/src/elements/model-switcher.stories.tsx +198 -0
- package/src/elements/model-switcher.tsx +93 -0
- package/src/elements/popover.stories.tsx +80 -0
- package/src/elements/popover.tsx +59 -0
- package/src/elements/prompt-input-slash-command.test.tsx +128 -0
- package/src/elements/prompt-input-stoppable.test.tsx +88 -0
- package/src/elements/prompt-input-toolbar-actions.test.tsx +120 -0
- package/src/elements/prompt-input.stories.tsx +331 -0
- package/src/elements/prompt-input.tsx +185 -0
- package/src/elements/prompt-suggestions.declarative.test.tsx +164 -0
- package/src/elements/prompt-suggestions.stories.tsx +213 -0
- package/src/elements/prompt-suggestions.tsx +94 -0
- package/src/elements/reasoning.stories.tsx +77 -0
- package/src/elements/reasoning.tsx +50 -0
- package/src/elements/register.ts +56 -0
- package/src/elements/remote.stories.tsx +314 -0
- package/src/elements/remote.tsx +221 -0
- package/src/elements/resizable.d.ts +27 -0
- package/src/elements/resizable.stories.tsx +426 -0
- package/src/elements/resizable.tsx +553 -0
- package/src/elements/response-stream.stories.tsx +79 -0
- package/src/elements/response-stream.tsx +40 -0
- package/src/elements/scroll-button.stories.tsx +202 -0
- package/src/elements/scroll-button.test.tsx +148 -0
- package/src/elements/scroll-button.tsx +126 -0
- package/src/elements/source-list.stories.tsx +143 -0
- package/src/elements/source.stories.tsx +88 -0
- package/src/elements/source.tsx +120 -0
- package/src/elements/styles.css +199 -0
- package/src/elements/switch.stories.tsx +56 -0
- package/src/elements/switch.tsx +43 -0
- package/src/elements/tasks.stories.tsx +237 -0
- package/src/elements/tasks.tsx +46 -0
- package/src/elements/text-shimmer.stories.tsx +64 -0
- package/src/elements/text-shimmer.tsx +28 -0
- package/src/elements/thinking-bar.stories.tsx +72 -0
- package/src/elements/thinking-bar.tsx +34 -0
- package/src/elements/tool.stories.tsx +89 -0
- package/src/elements/tool.tsx +23 -0
- package/src/elements/voice-input.stories.tsx +88 -0
- package/src/elements/voice-input.tsx +41 -0
- package/src/index.ts +253 -0
- package/src/primitives/card-contract.ts +71 -0
- package/src/primitives/card-host.tsx +35 -0
- package/src/primitives/card-registry.tsx +67 -0
- package/src/primitives/card-resolution.ts +36 -0
- package/src/primitives/card-routing.ts +79 -0
- package/src/primitives/card-schemas/card-envelope.schema.json +14 -0
- package/src/primitives/card-schemas/card-event.schema.json +12 -0
- package/src/primitives/card-schemas/choice.schema.json +70 -0
- package/src/primitives/card-schemas/confirm.schema.json +65 -0
- package/src/primitives/card-schemas/embed.schema.json +65 -0
- package/src/primitives/card-schemas/form.result.schema.json +7 -0
- package/src/primitives/card-schemas/form.schema.json +33 -0
- package/src/primitives/card-schemas/link.schema.json +56 -0
- package/src/primitives/card-schemas/tasks.result.schema.json +16 -0
- package/src/primitives/card-schemas/tasks.schema.json +78 -0
- package/src/primitives/card-validate.ts +95 -0
- package/src/primitives/chat-config.tsx +76 -0
- package/src/primitives/controllable.test.ts +47 -0
- package/src/primitives/controllable.ts +21 -0
- package/src/primitives/embed-providers.ts +254 -0
- package/src/primitives/highlighter.ts +157 -0
- package/src/primitives/link-preview.ts +87 -0
- package/src/primitives/pdf-preview.ts +121 -0
- package/src/primitives/use-auto-resize.ts +31 -0
- package/src/primitives/use-resize-observer.ts +12 -0
- package/src/primitives/use-stick-to-bottom.ts +43 -0
- package/src/primitives/use-text-stream.ts +112 -0
- package/src/primitives/use-voice-recorder.ts +50 -0
- package/src/remote/host-embed.ts +345 -0
- package/src/remote/index.ts +2 -0
- package/src/remote/origin.ts +30 -0
- package/src/remote/provider-runtime.ts +259 -0
- package/src/remote/provider.ts +2 -0
- package/src/remote/validate.ts +22 -0
- package/src/remote/version.ts +12 -0
- package/src/remote/wire.ts +48 -0
- package/src/stories/chat-panel-layout.stories.tsx +145 -0
- package/src/stories/chat-scene.tsx +571 -0
- package/src/stories/checkpoint-restore.stories.tsx +256 -0
- package/src/stories/context-usage.stories.tsx +212 -0
- package/src/stories/conversation-with-reasoning.stories.tsx +182 -0
- package/src/stories/conversation-with-sources.stories.tsx +471 -0
- package/src/stories/docs/Accessibility.mdx +119 -0
- package/src/stories/docs/ChildElements.mdx +269 -0
- package/src/stories/docs/ForAIAgents.mdx +162 -0
- package/src/stories/docs/GettingStarted.mdx +65 -0
- package/src/stories/docs/Installation.mdx +83 -0
- package/src/stories/docs/Introduction.mdx +50 -0
- package/src/stories/docs/SolidJsAdvanced.mdx +17 -0
- package/src/stories/docs/Theming.mdx +85 -0
- package/src/stories/docs/element-controls.ts +121 -0
- package/src/stories/docs/frameworks/Angular.mdx +245 -0
- package/src/stories/docs/frameworks/Html.mdx +227 -0
- package/src/stories/docs/frameworks/Overview.mdx +47 -0
- package/src/stories/docs/frameworks/React.mdx +227 -0
- package/src/stories/docs/frameworks/Solid.mdx +173 -0
- package/src/stories/docs/frameworks/Svelte.mdx +194 -0
- package/src/stories/docs/frameworks/Vue.mdx +238 -0
- package/src/stories/docs/generative-ui-overview.mdx +186 -0
- package/src/stories/docs/recipes/SpeechToText.mdx +7 -0
- package/src/stories/docs/recipes/Streaming.mdx +68 -0
- package/src/stories/docs/recipes/TextToSpeech.mdx +35 -0
- package/src/stories/docs/theme-editor/canvas.tsx +32 -0
- package/src/stories/docs/theme-editor/inspector.tsx +66 -0
- package/src/stories/docs/theme-editor/presets.test.ts +32 -0
- package/src/stories/docs/theme-editor/presets.ts +64 -0
- package/src/stories/docs/theme-editor/theme-css.test.ts +19 -0
- package/src/stories/docs/theme-editor/theme-css.ts +15 -0
- package/src/stories/docs/theme-editor/theme-editor.tsx +146 -0
- package/src/stories/docs/theme-tokens.tsx +174 -0
- package/src/stories/examples/ChoosingComponents.mdx +106 -0
- package/src/stories/examples/sample-data.ts +79 -0
- package/src/stories/examples/usage/checkpoint-restore.ts +156 -0
- package/src/stories/examples/usage/context-usage.ts +591 -0
- package/src/stories/examples/usage/conversation-with-reasoning.ts +224 -0
- package/src/stories/examples/usage/conversation-with-sources.ts +589 -0
- package/src/stories/examples/usage/empty-state.ts +144 -0
- package/src/stories/examples/usage/full-chat-app.ts +277 -0
- package/src/stories/examples/usage/index.ts +63 -0
- package/src/stories/examples/usage/message-actions.ts +704 -0
- package/src/stories/examples/usage/pattern-centered-conversation.ts +446 -0
- package/src/stories/examples/usage/pattern-chat-panel-layout.ts +442 -0
- package/src/stories/examples/usage/pattern-docked-widget.ts +479 -0
- package/src/stories/examples/usage/prompt-input-variants.ts +1356 -0
- package/src/stories/examples/usage/streaming-response.ts +687 -0
- package/src/stories/examples/usage/types.ts +33 -0
- package/src/stories/full-chat.stories.tsx +18 -0
- package/src/stories/message-actions.stories.tsx +230 -0
- package/src/stories/pattern-centered-conversation.stories.tsx +93 -0
- package/src/stories/pattern-docked-widget.stories.tsx +93 -0
- package/src/stories/pattern-empty-state.stories.tsx +76 -0
- package/src/stories/prompt-input-variants.stories.tsx +456 -0
- package/src/stories/streaming-response.stories.tsx +438 -0
- package/src/stories/theme-editor.stories.tsx +16 -0
- package/src/stories/token-reference.stories.tsx +18 -0
- package/src/stories/typography.stories.tsx +78 -0
- package/src/types.ts +47 -0
- package/src/ui/action-icons.ts +52 -0
- package/src/ui/avatar.stories.tsx +103 -0
- package/src/ui/avatar.tsx +23 -0
- package/src/ui/badge.stories.tsx +86 -0
- package/src/ui/badge.tsx +21 -0
- package/src/ui/button.stories.tsx +145 -0
- package/src/ui/button.tsx +38 -0
- package/src/ui/collapsible.stories.tsx +69 -0
- package/src/ui/collapsible.tsx +125 -0
- package/src/ui/dropdown.stories.tsx +59 -0
- package/src/ui/dropdown.tsx +196 -0
- package/src/ui/hover-card.stories.tsx +77 -0
- package/src/ui/hover-card.test.tsx +30 -0
- package/src/ui/hover-card.tsx +172 -0
- package/src/ui/overlay.stories.tsx +115 -0
- package/src/ui/overlay.tsx +158 -0
- package/src/ui/popover.stories.tsx +81 -0
- package/src/ui/popover.test.tsx +99 -0
- package/src/ui/popover.tsx +92 -0
- package/src/ui/resizable.stories.tsx +236 -0
- package/src/ui/resizable.tsx +576 -0
- package/src/ui/scroll-area.stories.tsx +50 -0
- package/src/ui/scroll-area.tsx +15 -0
- package/src/ui/separator.stories.tsx +81 -0
- package/src/ui/separator.tsx +10 -0
- package/src/ui/skeleton.stories.tsx +337 -0
- package/src/ui/skeleton.tsx +16 -0
- package/src/ui/switch.stories.tsx +51 -0
- package/src/ui/switch.test.tsx +59 -0
- package/src/ui/switch.tsx +62 -0
- package/src/ui/textarea.stories.tsx +76 -0
- package/src/ui/textarea.tsx +21 -0
- package/src/ui/tooltip.stories.tsx +74 -0
- package/src/ui/tooltip.tsx +68 -0
- package/src/utils/cn.ts +24 -0
- package/theme.css +187 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// src/remote/provider-runtime.ts
|
|
2
|
+
// The provider iframe-side bridge: handshake responder + CardHost impl + auto-height.
|
|
3
|
+
// Security-critical, stateful, vanilla DOM ONLY — NO SolidJS imports (ships in the
|
|
4
|
+
// SolidJS-free `@kitn.ai/ui/provider` bundle). See the iframe-transport design spec
|
|
5
|
+
// (Provider iframe runtime surface + addendum H-A/H-D/H-E/H-J/H-H).
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
type CardEnvelope,
|
|
9
|
+
type CardContext,
|
|
10
|
+
type CardEvent,
|
|
11
|
+
type CardHost,
|
|
12
|
+
} from '../primitives/card-contract';
|
|
13
|
+
import { createPacker, isCardWireFrame, type WireMessage } from './wire';
|
|
14
|
+
import { assertOrigin, redactFrame } from './origin';
|
|
15
|
+
import { negotiateVersion } from './version';
|
|
16
|
+
import { hasPollutionKey } from './validate';
|
|
17
|
+
import { observeContentHeight } from '../primitives/use-resize-observer';
|
|
18
|
+
import { validateAgainstSchema, type JsonSchema } from '../primitives/card-validate';
|
|
19
|
+
|
|
20
|
+
/** A provider-side renderer for one card `type`. Renamed (was CardRenderer) per H-K
|
|
21
|
+
* to avoid colliding with the exported Solid `<CardRenderer>` component. */
|
|
22
|
+
export interface RemoteCardRenderer {
|
|
23
|
+
/** The card `type` this renderer handles. */
|
|
24
|
+
type: string;
|
|
25
|
+
/** Optional JSON Schema for this type's `data`; validated best-effort before mount. */
|
|
26
|
+
schema?: JsonSchema;
|
|
27
|
+
/** Mount into `root`, given the envelope + a CardHost. Return a disposer. */
|
|
28
|
+
mount(root: HTMLElement, envelope: CardEnvelope, host: CardHost): () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CreateCardBridgeOptions {
|
|
32
|
+
/** Element the card mounts into + whose height is observed. */
|
|
33
|
+
root: HTMLElement;
|
|
34
|
+
/** Renderers by card type. Unknown type → inline "unsupported card" + event{error}. */
|
|
35
|
+
renderers: RemoteCardRenderer[];
|
|
36
|
+
/** Versions this runtime supports (default ['1']). */
|
|
37
|
+
supportedVersions?: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CardBridge {
|
|
41
|
+
/** Begin: listen for `hello`, complete handshake, render on `render`. */
|
|
42
|
+
start(): void;
|
|
43
|
+
/** Stop observers + listeners + dispose current card. */
|
|
44
|
+
stop(): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const DEFAULT_VERSIONS = ['1'];
|
|
48
|
+
|
|
49
|
+
/** A minimal complete-enough default so `CardHost.context()` never returns undefined
|
|
50
|
+
* (the contract's return is non-optional) before the first `context` frame. */
|
|
51
|
+
function defaultContext(): CardContext {
|
|
52
|
+
return { theme: { mode: 'light' }, locale: 'en' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createCardBridge(options: CreateCardBridgeOptions): CardBridge {
|
|
56
|
+
const { root, renderers } = options;
|
|
57
|
+
const hostVersions = options.supportedVersions ?? DEFAULT_VERSIONS;
|
|
58
|
+
const rendererByType = new Map(renderers.map((r) => [r.type, r] as const));
|
|
59
|
+
|
|
60
|
+
// ── Locked-after-hello bridge identity (H-A/H-C). null until the first valid hello. ──
|
|
61
|
+
let lockedSource: unknown = null;
|
|
62
|
+
let lockedOrigin: string | null = null;
|
|
63
|
+
let nonce: string | null = null;
|
|
64
|
+
let negotiated: string | null = null;
|
|
65
|
+
let packer: ReturnType<typeof createPacker> | null = null;
|
|
66
|
+
let stopped = false; // tombstone: rejects all inbound once the version is unsupported / stopped
|
|
67
|
+
|
|
68
|
+
// ── Render state (H-E). One card at a time in v1. ──
|
|
69
|
+
let context: CardContext | null = null;
|
|
70
|
+
let currentId: string | null = null;
|
|
71
|
+
let currentEnvelope: CardEnvelope | null = null;
|
|
72
|
+
let dispose: (() => void) | null = null;
|
|
73
|
+
let stopObserver: (() => void) | null = null;
|
|
74
|
+
// The theme key applied at the current mount. A `context` push only forces a
|
|
75
|
+
// dispose+remount when the theme actually changes (renderers apply theme
|
|
76
|
+
// imperatively at mount); token/locale/a11y refreshes are read on-demand via
|
|
77
|
+
// host.context() and must NOT wipe in-progress card state.
|
|
78
|
+
let appliedThemeKey: string | null = null;
|
|
79
|
+
const themeKey = (c: CardContext | null) => JSON.stringify(c?.theme ?? null);
|
|
80
|
+
|
|
81
|
+
function warnDrop(data: unknown): void {
|
|
82
|
+
try { console.warn('[kai-remote]', redactFrame(data)); } catch { /* best-effort */ }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function postUp(message: WireMessage): void {
|
|
86
|
+
if (!packer || !lockedOrigin) return;
|
|
87
|
+
try { (parent as Window).postMessage(packer(message), lockedOrigin); } catch { /* best-effort */ }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const cardHost: CardHost = {
|
|
91
|
+
context: () => context ?? defaultContext(),
|
|
92
|
+
// HOST CONTRACT: the host MUST validate inbound event.cardId against the active card,
|
|
93
|
+
// because the provider cannot fence a replaced/stale renderer's host.emit calls.
|
|
94
|
+
emit: (event: CardEvent) => postUp({ dir: 'up', kind: 'event', event }),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function disposeCurrent(): void {
|
|
98
|
+
if (dispose) {
|
|
99
|
+
try { dispose(); } catch { /* renderer disposer threw — best-effort */ }
|
|
100
|
+
}
|
|
101
|
+
dispose = null;
|
|
102
|
+
currentId = null;
|
|
103
|
+
currentEnvelope = null;
|
|
104
|
+
appliedThemeKey = null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function startObserver(): void {
|
|
108
|
+
// Tear down any existing observer so observeContentHeight's internal `last` baseline
|
|
109
|
+
// re-initializes to -1 and the newly-mounted card always emits its initial height.
|
|
110
|
+
stopObserver?.(); stopObserver = null;
|
|
111
|
+
stopObserver = observeContentHeight(root, (height) => {
|
|
112
|
+
if (!currentId) return;
|
|
113
|
+
cardHost.emit({ kind: 'resize', cardId: currentId, height });
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function renderUnsupported(envelope: CardEnvelope, message: string): void {
|
|
118
|
+
disposeCurrent();
|
|
119
|
+
root.replaceChildren();
|
|
120
|
+
const el = document.createElement('div');
|
|
121
|
+
el.setAttribute('role', 'alert');
|
|
122
|
+
el.textContent = `Unsupported card: ${envelope.type}`;
|
|
123
|
+
root.appendChild(el);
|
|
124
|
+
currentId = envelope.id;
|
|
125
|
+
startObserver(); // placeholder has a height the host must know about
|
|
126
|
+
cardHost.emit({ kind: 'error', cardId: envelope.id, message });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function handleRender(envelope: CardEnvelope): void {
|
|
130
|
+
// Prototype-pollution guard (H-D): nested data is forwarded to app handlers.
|
|
131
|
+
if (hasPollutionKey(envelope.data)) {
|
|
132
|
+
renderUnsupported(envelope, 'rejected: payload contains a prohibited key');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const renderer = rendererByType.get(envelope.type);
|
|
136
|
+
if (!renderer) {
|
|
137
|
+
renderUnsupported(envelope, `no renderer registered for type "${envelope.type}"`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Best-effort schema validation (H-D). On failure: placeholder + event{error}.
|
|
141
|
+
if (renderer.schema) {
|
|
142
|
+
const result = validateAgainstSchema(renderer.schema, envelope.data);
|
|
143
|
+
if (!result.valid) {
|
|
144
|
+
renderUnsupported(envelope, `invalid card data: ${result.errors.join('; ')}`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Re-render rules (H-E): same id OR different id → dispose current, clear, mount new
|
|
150
|
+
// (v1 has no in-place renderer update path).
|
|
151
|
+
disposeCurrent();
|
|
152
|
+
root.replaceChildren();
|
|
153
|
+
try {
|
|
154
|
+
dispose = renderer.mount(root, envelope, cardHost) ?? (() => {});
|
|
155
|
+
currentId = envelope.id;
|
|
156
|
+
currentEnvelope = envelope;
|
|
157
|
+
appliedThemeKey = themeKey(context);
|
|
158
|
+
} catch {
|
|
159
|
+
// NON-REFLECTIVE fault (H-H): never echo envelope/context content.
|
|
160
|
+
dispose = null;
|
|
161
|
+
currentId = envelope.id; // onError needs a cardId even on mount failure
|
|
162
|
+
postUp({ dir: 'up', kind: 'fault', code: 'render-failed', message: 'card failed to render' });
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
startObserver();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function onMessage(event: MessageEvent): void {
|
|
169
|
+
if (stopped) return;
|
|
170
|
+
const data = event.data;
|
|
171
|
+
|
|
172
|
+
// ── Pre-lock: only the FIRST valid down `hello` from window.parent locks the bridge. ──
|
|
173
|
+
if (lockedSource === null) {
|
|
174
|
+
if (!isCardWireFrame(data, 'down')) return;
|
|
175
|
+
if (data.message.kind !== 'hello') return;
|
|
176
|
+
if (event.source !== window.parent) return; // host source must be the parent window
|
|
177
|
+
const supported = (data.message as { supportedVersions: string[] }).supportedVersions;
|
|
178
|
+
const picked = negotiateVersion(supported, hostVersions);
|
|
179
|
+
const echoedNonce = data.nonce;
|
|
180
|
+
const origin = event.origin;
|
|
181
|
+
if (picked === null) {
|
|
182
|
+
// No common version → fault with the host's first supported version + received nonce.
|
|
183
|
+
try {
|
|
184
|
+
(parent as Window).postMessage(
|
|
185
|
+
createPacker(hostVersions[0], echoedNonce)({ dir: 'up', kind: 'fault', code: 'version-unsupported', message: 'no compatible protocol version' }),
|
|
186
|
+
origin,
|
|
187
|
+
);
|
|
188
|
+
} catch { /* best-effort */ }
|
|
189
|
+
stopped = true; // refuse further frames
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
// Lock identity.
|
|
193
|
+
lockedSource = event.source;
|
|
194
|
+
lockedOrigin = origin;
|
|
195
|
+
nonce = echoedNonce;
|
|
196
|
+
negotiated = picked;
|
|
197
|
+
packer = createPacker(negotiated, nonce);
|
|
198
|
+
postUp({ dir: 'up', kind: 'ready', acceptedVersion: negotiated, capabilities: { types: renderers.map((r) => r.type) } });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ── Post-lock: ALL gates must pass (H-A source + origin + H-D direction + nonce + version). ──
|
|
203
|
+
if (event.source !== lockedSource) { warnDrop(data); return; }
|
|
204
|
+
if (!assertOrigin(event.origin, lockedOrigin!)) { warnDrop(data); return; }
|
|
205
|
+
if (!isCardWireFrame(data, 'down')) { warnDrop(data); return; }
|
|
206
|
+
if (data.nonce !== nonce) { warnDrop(data); return; }
|
|
207
|
+
if (data.version !== negotiated) { warnDrop(data); return; }
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
const message = data.message;
|
|
211
|
+
switch (message.kind) {
|
|
212
|
+
case 'hello':
|
|
213
|
+
// Re-hello after lock is ignored (bridge identity is fixed for its generation).
|
|
214
|
+
return;
|
|
215
|
+
case 'context': {
|
|
216
|
+
const next = (message as { context: CardContext }).context;
|
|
217
|
+
context = next;
|
|
218
|
+
// Live context push. Renderers read host.context() on-demand, so silent
|
|
219
|
+
// token/locale/a11y refreshes need NO remount — storing the new context is
|
|
220
|
+
// enough. Only a THEME change requires a dispose+remount, since renderers
|
|
221
|
+
// apply theme imperatively at mount (v1 has no in-place update hook).
|
|
222
|
+
if (currentEnvelope && themeKey(next) !== appliedThemeKey) {
|
|
223
|
+
handleRender(currentEnvelope); // handleRender resets appliedThemeKey
|
|
224
|
+
}
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
case 'render':
|
|
228
|
+
handleRender((message as { envelope: CardEnvelope }).envelope);
|
|
229
|
+
return;
|
|
230
|
+
case 'teardown':
|
|
231
|
+
teardown();
|
|
232
|
+
return;
|
|
233
|
+
default:
|
|
234
|
+
warnDrop(data);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
// No throw may escape the message handler — the listener must survive.
|
|
239
|
+
warnDrop(data);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function teardown(): void {
|
|
244
|
+
disposeCurrent();
|
|
245
|
+
if (stopObserver) { stopObserver(); stopObserver = null; }
|
|
246
|
+
root.replaceChildren();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
start() {
|
|
251
|
+
window.addEventListener('message', onMessage);
|
|
252
|
+
},
|
|
253
|
+
stop() {
|
|
254
|
+
stopped = true;
|
|
255
|
+
window.removeEventListener('message', onMessage);
|
|
256
|
+
teardown();
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CardEventKind } from '../primitives/card-contract';
|
|
2
|
+
|
|
3
|
+
const POLLUTION = new Set(['__proto__', 'constructor', 'prototype']);
|
|
4
|
+
/** Recursive guard (H-D): nested data/patch/context are forwarded to app handlers. */
|
|
5
|
+
export function hasPollutionKey(value: unknown): boolean {
|
|
6
|
+
if (Array.isArray(value)) return value.some(hasPollutionKey);
|
|
7
|
+
if (value && typeof value === 'object') {
|
|
8
|
+
for (const k of Object.keys(value)) {
|
|
9
|
+
if (POLLUTION.has(k)) return true;
|
|
10
|
+
if (hasPollutionKey((value as Record<string, unknown>)[k])) return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Verbs MUST match CardEventKind in card-contract.ts (verify against source).
|
|
17
|
+
const KINDS: ReadonlySet<string> = new Set<CardEventKind>([
|
|
18
|
+
'ready', 'submit', 'action', 'send-prompt', 'open', 'resize', 'state', 'dismiss', 'error',
|
|
19
|
+
] as CardEventKind[]);
|
|
20
|
+
export function isKnownEventKind(k: unknown): k is CardEventKind {
|
|
21
|
+
return typeof k === 'string' && KINDS.has(k);
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Contract versions are decimal integer strings ('1','2',…). */
|
|
2
|
+
export function isValidVersion(s: string): boolean {
|
|
3
|
+
return /^[0-9]+$/.test(s);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** Highest version both sides support; null if disjoint or any candidate is malformed. */
|
|
7
|
+
export function negotiateVersion(hostVersions: string[], mine: string[]): string | null {
|
|
8
|
+
const set = new Set(mine.filter(isValidVersion));
|
|
9
|
+
const common = hostVersions.filter((v) => isValidVersion(v) && set.has(v));
|
|
10
|
+
if (common.length === 0) return null;
|
|
11
|
+
return common.sort((a, b) => Number(b) - Number(a))[0];
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type CardEnvelope, type CardContext, type CardEvent } from '../primitives/card-contract';
|
|
2
|
+
|
|
3
|
+
export const CARD_WIRE_PROTOCOL = 'kitn-card' as const;
|
|
4
|
+
|
|
5
|
+
export interface WireFrame<M extends WireMessage = WireMessage> {
|
|
6
|
+
protocol: typeof CARD_WIRE_PROTOCOL;
|
|
7
|
+
/** The NEGOTIATED contract version (set by the per-bridge packer). */
|
|
8
|
+
version: string;
|
|
9
|
+
/** Per-bridge instance nonce (host-minted, echoed on every up-frame). */
|
|
10
|
+
nonce: string;
|
|
11
|
+
message: M;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type DownMessage =
|
|
15
|
+
| { dir: 'down'; kind: 'hello'; supportedVersions: string[] }
|
|
16
|
+
| { dir: 'down'; kind: 'render'; envelope: CardEnvelope }
|
|
17
|
+
| { dir: 'down'; kind: 'context'; context: CardContext }
|
|
18
|
+
| { dir: 'down'; kind: 'teardown' };
|
|
19
|
+
|
|
20
|
+
export type UpMessage =
|
|
21
|
+
| { dir: 'up'; kind: 'ready'; acceptedVersion: string; capabilities?: { types?: string[] } }
|
|
22
|
+
| { dir: 'up'; kind: 'event'; event: CardEvent }
|
|
23
|
+
| { dir: 'up'; kind: 'focus-edge'; edge: 'start' | 'end' }
|
|
24
|
+
| { dir: 'up'; kind: 'fault'; code: WireFaultCode; message: string };
|
|
25
|
+
|
|
26
|
+
export type WireFaultCode = 'version-unsupported' | 'bad-frame' | 'render-failed' | 'origin-rejected';
|
|
27
|
+
export type WireMessage = DownMessage | UpMessage;
|
|
28
|
+
|
|
29
|
+
export function createPacker(version: string, nonce: string) {
|
|
30
|
+
return function pack<M extends WireMessage>(message: M): WireFrame<M> {
|
|
31
|
+
return { protocol: CARD_WIRE_PROTOCOL, version, nonce, message };
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Structural + direction guard. Host calls with 'up', runtime with 'down'.
|
|
36
|
+
* STRUCTURAL only — nonce/version equality + schema validation happen after. */
|
|
37
|
+
export function isCardWireFrame(data: unknown, expectedDir: 'up' | 'down'): data is WireFrame {
|
|
38
|
+
if (typeof data !== 'object' || data === null) return false;
|
|
39
|
+
const d = data as Record<string, unknown>;
|
|
40
|
+
const m = d.message as Record<string, unknown> | undefined;
|
|
41
|
+
return (
|
|
42
|
+
d.protocol === CARD_WIRE_PROTOCOL &&
|
|
43
|
+
typeof d.version === 'string' &&
|
|
44
|
+
typeof d.nonce === 'string' &&
|
|
45
|
+
typeof m === 'object' && m !== null &&
|
|
46
|
+
m.dir === expectedDir
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
+
import { createSignal } from 'solid-js';
|
|
3
|
+
import { Message, MessageAvatar, MessageContent, MessageActions } from '../components/message';
|
|
4
|
+
import { ChatContainer } from '../components/chat-container';
|
|
5
|
+
import { ChatConfig } from '../primitives/chat-config';
|
|
6
|
+
import { PromptInput, PromptInputTextarea, PromptInputActions } from '../components/prompt-input';
|
|
7
|
+
import { Button } from '../ui/button';
|
|
8
|
+
import { ScrollButton } from '../components/scroll-button';
|
|
9
|
+
import { Copy, ArrowUp } from 'lucide-solid';
|
|
10
|
+
|
|
11
|
+
const meta: Meta = {
|
|
12
|
+
title: 'Patterns/Chat Panel Layout',
|
|
13
|
+
parameters: { layout: 'centered' },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj;
|
|
18
|
+
|
|
19
|
+
const assistantMsg1 = `The document is a transcript of a YouTube video by Cole Medin, where he discusses building a self-evolving memory system for coding agents using Large Language Models (LLMs), inspired by Andre Karpathy's ideas on LLM knowledge bases.`;
|
|
20
|
+
|
|
21
|
+
const assistantMsg2 = `Short answer: **it has to be a separate browser window** (or tab/iframe), not just a normal component in your application.
|
|
22
|
+
|
|
23
|
+
Here's why:
|
|
24
|
+
|
|
25
|
+
- The OAuth flow requires redirecting to the provider's login page
|
|
26
|
+
- The callback URL needs to be a real URL the browser can navigate to
|
|
27
|
+
- Security policies prevent embedding auth pages in iframes`;
|
|
28
|
+
|
|
29
|
+
const userMsg1 = 'What is this video about?';
|
|
30
|
+
const userMsg2 = 'And from what I understand, does that need to be another browser window pop-up that happens, or can I just have a component that does that in my application?';
|
|
31
|
+
|
|
32
|
+
function CopyButton(props: { text: string }) {
|
|
33
|
+
return (
|
|
34
|
+
<button aria-label="Copy message" onClick={() => navigator.clipboard.writeText(props.text)}>
|
|
35
|
+
<Copy size={14} />
|
|
36
|
+
</button>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Reference layout — uses variant props, no custom class overrides.
|
|
42
|
+
*/
|
|
43
|
+
export const ChatGPTStyle: Story = {
|
|
44
|
+
render: () => {
|
|
45
|
+
const [input, setInput] = createSignal('');
|
|
46
|
+
return (
|
|
47
|
+
<ChatConfig proseSize="base">
|
|
48
|
+
<div
|
|
49
|
+
style={{ width: '420px', height: '700px' }}
|
|
50
|
+
class="flex flex-col overflow-hidden rounded-lg bg-card"
|
|
51
|
+
>
|
|
52
|
+
{/* Header */}
|
|
53
|
+
<div class="px-3 py-2.5 bg-muted/30 text-sm font-semibold text-foreground flex-shrink-0 flex items-center justify-between">
|
|
54
|
+
<span>Chat Panel</span>
|
|
55
|
+
<span class="text-xs text-muted-foreground">GPT-4o Mini</span>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
{/* Messages */}
|
|
59
|
+
<ChatContainer class="flex-1 min-w-0 px-4 py-3 space-y-4">
|
|
60
|
+
{/* Assistant message 1 — with avatar */}
|
|
61
|
+
<Message>
|
|
62
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
63
|
+
<div class="flex w-full flex-col min-w-0">
|
|
64
|
+
<MessageContent markdown class="bg-transparent p-0 pt-1.5">
|
|
65
|
+
{assistantMsg1}
|
|
66
|
+
</MessageContent>
|
|
67
|
+
<MessageActions>
|
|
68
|
+
<CopyButton text={assistantMsg1} />
|
|
69
|
+
</MessageActions>
|
|
70
|
+
</div>
|
|
71
|
+
</Message>
|
|
72
|
+
|
|
73
|
+
{/* User message 1 */}
|
|
74
|
+
<Message class="group flex-col items-end">
|
|
75
|
+
<MessageContent class="bg-muted text-primary max-w-[85%] rounded-xl px-4 py-2 mr-1">
|
|
76
|
+
{userMsg1}
|
|
77
|
+
</MessageContent>
|
|
78
|
+
<MessageActions class="opacity-0 group-hover:opacity-100 transition-opacity duration-150">
|
|
79
|
+
<CopyButton text={userMsg1} />
|
|
80
|
+
</MessageActions>
|
|
81
|
+
</Message>
|
|
82
|
+
|
|
83
|
+
{/* Assistant message 2 — with avatar, markdown */}
|
|
84
|
+
<Message>
|
|
85
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
86
|
+
<div class="flex w-full flex-col min-w-0">
|
|
87
|
+
<MessageContent markdown class="bg-transparent p-0 pt-1.5">
|
|
88
|
+
{assistantMsg2}
|
|
89
|
+
</MessageContent>
|
|
90
|
+
<MessageActions>
|
|
91
|
+
<CopyButton text={assistantMsg2} />
|
|
92
|
+
</MessageActions>
|
|
93
|
+
</div>
|
|
94
|
+
</Message>
|
|
95
|
+
|
|
96
|
+
{/* User message 2 — longer */}
|
|
97
|
+
<Message class="group flex-col items-end">
|
|
98
|
+
<MessageContent class="bg-muted text-primary max-w-[85%] rounded-xl px-4 py-2 mr-1">
|
|
99
|
+
{userMsg2}
|
|
100
|
+
</MessageContent>
|
|
101
|
+
<MessageActions class="opacity-0 group-hover:opacity-100 transition-opacity duration-150">
|
|
102
|
+
<CopyButton text={userMsg2} />
|
|
103
|
+
</MessageActions>
|
|
104
|
+
</Message>
|
|
105
|
+
|
|
106
|
+
{/* Assistant message 3 — with avatar, short */}
|
|
107
|
+
<Message>
|
|
108
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
109
|
+
<div class="flex w-full flex-col min-w-0">
|
|
110
|
+
<MessageContent markdown class="bg-transparent p-0 pt-1.5">
|
|
111
|
+
Got it — let me know if you have more questions!
|
|
112
|
+
</MessageContent>
|
|
113
|
+
<MessageActions>
|
|
114
|
+
<CopyButton text="Got it — let me know if you have more questions!" />
|
|
115
|
+
</MessageActions>
|
|
116
|
+
</div>
|
|
117
|
+
</Message>
|
|
118
|
+
<ScrollButton />
|
|
119
|
+
</ChatContainer>
|
|
120
|
+
|
|
121
|
+
{/* Input */}
|
|
122
|
+
<div class="px-3 pb-3 pt-1 flex-shrink-0">
|
|
123
|
+
<PromptInput
|
|
124
|
+
value={input()}
|
|
125
|
+
onValueChange={setInput}
|
|
126
|
+
onSubmit={() => setInput('')}
|
|
127
|
+
>
|
|
128
|
+
<PromptInputTextarea placeholder="Ask about this page..." class="min-h-[44px] pt-3 pl-4" />
|
|
129
|
+
<PromptInputActions class="mt-2 flex w-full items-center justify-end gap-2 px-3 pb-3">
|
|
130
|
+
<Button
|
|
131
|
+
size="icon-sm"
|
|
132
|
+
class="rounded-full"
|
|
133
|
+
aria-label="Send message"
|
|
134
|
+
disabled={!input().trim()}
|
|
135
|
+
>
|
|
136
|
+
<ArrowUp class="size-4" />
|
|
137
|
+
</Button>
|
|
138
|
+
</PromptInputActions>
|
|
139
|
+
</PromptInput>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</ChatConfig>
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
};
|