@svadmin/ai-elements 0.5.1 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -51
- package/dist/ai.css +153 -2740
- package/dist/components/AICommandBar.svelte +6 -4
- package/dist/components/ChatDialog.svelte +102 -125
- package/dist/components/ChatDialog.svelte.d.ts +3 -9
- package/dist/components/Conversation.svelte +34 -10
- package/dist/components/ConversationContent.svelte +1 -1
- package/dist/components/ConversationScrollButton.svelte +0 -1
- package/dist/components/CopilotPanel.svelte +8 -6
- package/dist/components/Message.svelte +1 -1
- package/dist/components/MessageActions.svelte +1 -1
- package/dist/components/MessageContent.svelte +1 -1
- package/dist/components/MessageToolbar.svelte +1 -1
- package/dist/components/Response.svelte +31 -11
- package/dist/components/Response.svelte.d.ts +2 -2
- package/dist/components/Tool.svelte +13 -13
- package/dist/components/Tool.svelte.d.ts +1 -1
- package/dist/components/action/Action.svelte +3 -1
- package/dist/components/artifact/ArtifactAction.svelte +3 -1
- package/dist/components/attachments/Attachment.svelte +4 -2
- package/dist/components/attachments/Attachments.svelte +3 -1
- package/dist/components/attachments/types.js +3 -2
- package/dist/components/audio-player/AudioPlayer.svelte.d.ts +1 -1
- package/dist/components/canvas/Canvas.svelte +1 -1
- package/dist/components/checkpoint/index.d.ts +2 -2
- package/dist/components/code/index.d.ts +18 -1
- package/dist/components/code/index.js +11 -1
- package/dist/components/code-block/CodeBlockLanguageSelector.svelte.d.ts +1 -1
- package/dist/components/code-block/highlight.js +10 -9
- package/dist/components/commit/Commit.svelte +23 -2
- package/dist/components/commit/CommitActions.svelte +2 -11
- package/dist/components/commit/CommitCopyButton.svelte +1 -1
- package/dist/components/commit/CommitHeader.svelte +12 -2
- package/dist/components/commit/context.svelte.d.ts +6 -0
- package/dist/components/commit/context.svelte.js +14 -0
- package/dist/components/context/Context.svelte +6 -4
- package/dist/components/context/TokensWithCost.svelte +2 -1
- package/dist/components/edge/Animated.svelte +6 -6
- package/dist/components/edge/Temporary.svelte +6 -5
- package/dist/components/file-tree/FileTree.svelte +7 -5
- package/dist/components/jsx-preview/parser.js +10 -10
- package/dist/components/message/MessageAction.svelte +3 -1
- package/dist/components/mic-selector/MicSelector.svelte.d.ts +1 -1
- package/dist/components/model-selector/ModelSelectorDialog.svelte +3 -1
- package/dist/components/open-in-chat/OpenInChatGPT.svelte +3 -1
- package/dist/components/open-in-chat/OpenInClaude.svelte +3 -1
- package/dist/components/open-in-chat/OpenInCursor.svelte +3 -1
- package/dist/components/open-in-chat/OpenInGitHub.svelte +3 -1
- package/dist/components/open-in-chat/OpenInScira.svelte +3 -1
- package/dist/components/open-in-chat/OpenInT3.svelte +3 -1
- package/dist/components/open-in-chat/OpenInv0.svelte +3 -1
- package/dist/components/package-info/PackageInfo.svelte +3 -1
- package/dist/components/prompt-input/PromptInput.svelte +8 -18
- package/dist/components/prompt-input/PromptInputCommand.svelte +2 -1
- package/dist/components/prompt-input/PromptInputSelect.svelte.d.ts +1 -1
- package/dist/components/prompt-input/PromptInputSubmit.svelte +5 -18
- package/dist/components/prompt-input/PromptInputTextarea.svelte +6 -11
- package/dist/components/prompt-input/context.svelte.d.ts +1 -8
- package/dist/components/prompt-input/files.js +3 -2
- package/dist/components/question/Question.svelte +3 -1
- package/dist/components/schema-display/SchemaDisplay.svelte +4 -2
- package/dist/components/schema-display/SchemaDisplayParameter.svelte +14 -1
- package/dist/components/schema-display/SchemaDisplayProperty.svelte +16 -1
- package/dist/components/snippet/index.d.ts +3 -3
- package/dist/components/stack-trace/StackTrace.svelte +7 -5
- package/dist/components/suggestion/index.d.ts +1 -1
- package/dist/components/terminal/Terminal.svelte +4 -2
- package/dist/components/terminal/ansi.js +9 -6
- package/dist/components/test-results/Test.svelte +1 -1
- package/dist/components/test-results/TestResults.svelte +1 -1
- package/dist/components/test-results/context.svelte.d.ts +1 -1
- package/dist/components/tool/ToolContent.svelte +1 -1
- package/dist/components/tool/ToolHeader.svelte +5 -5
- package/dist/components/tool/ToolInput.svelte +2 -4
- package/dist/components/tool/ToolOutput.svelte +2 -4
- package/dist/components/tool/ToolStatusBadge.svelte +2 -3
- package/dist/components/voice-selector/VoiceSelector.svelte +2 -1
- package/dist/components/voice-selector/VoiceSelector.svelte.d.ts +2 -2
- package/dist/components/voice-selector/context.svelte.d.ts +2 -1
- package/dist/components/web-preview/WebPreview.svelte +4 -3
- package/dist/contracts.d.ts +2 -2
- package/dist/generated-components.d.ts +15 -1
- package/dist/generated-components.js +20 -1
- package/dist/internal/Tooltip.svelte +2 -1
- package/dist/parity-manifest.d.ts +0 -1
- package/dist/parity-manifest.js +0 -97
- package/package.json +9 -19
- package/UPSTREAM_PARITY.md +0 -69
- package/dist/ai-theme.css +0 -28
- package/dist/ai.theme.css +0 -2771
- package/dist/components/code/code-variants.d.ts +0 -25
- package/dist/components/code/code-variants.js +0 -20
- package/dist/components/conversation/scroll.d.ts +0 -4
- package/dist/components/conversation/scroll.js +0 -85
- package/dist/components/message/content-polish-html.d.ts +0 -5
- package/dist/components/message/content-polish-html.js +0 -75
- package/dist/components/tool/content-polish-scroll-region.d.ts +0 -3
- package/dist/components/tool/content-polish-scroll-region.js +0 -22
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
19
|
<script lang="ts">
|
|
20
|
+
import { definedOptions, definedReactiveOptions } from '@svadmin/core/options';
|
|
21
|
+
|
|
20
22
|
import type { Snippet } from 'svelte';
|
|
21
23
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
22
24
|
import { ChevronDown, Copy, ExternalLink } from '@lucide/svelte';
|
|
@@ -68,26 +70,26 @@
|
|
|
68
70
|
const resolvedFrames = $derived(frames?.length ? frames : parseStack(stackText));
|
|
69
71
|
const selectedFrame = $derived(resolvedFrames.find((frame) => frame.id === selectedId));
|
|
70
72
|
const compoundTrace = $derived(parseCompoundStackTrace(stackText));
|
|
71
|
-
provideStackTraceContext({
|
|
73
|
+
provideStackTraceContext(definedReactiveOptions({
|
|
72
74
|
get trace() { return compoundTrace; },
|
|
73
75
|
get raw() { return stackText; },
|
|
74
76
|
get open() { return open; },
|
|
75
|
-
setOpen(nextOpen) { open = nextOpen; onopenchange?.(nextOpen); if (onOpenChange !== onopenchange) onOpenChange?.(nextOpen); },
|
|
77
|
+
setOpen(nextOpen: boolean) { open = nextOpen; onopenchange?.(nextOpen); if (onOpenChange !== onopenchange) onOpenChange?.(nextOpen); },
|
|
76
78
|
get onFilePathClick() { return onfilepathclick ?? onFilePathClick; },
|
|
77
|
-
});
|
|
79
|
+
}));
|
|
78
80
|
|
|
79
81
|
function parseStack(value: string): StackTraceFrame[] {
|
|
80
82
|
return value.split('\n').map((line) => line.trim()).filter(Boolean).map((line, index) => {
|
|
81
83
|
const match = line.match(/^(?:at\s+)?(?:(.*?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
|
|
82
84
|
if (!match) return { id: `frame-${index}`, source: line };
|
|
83
|
-
return {
|
|
85
|
+
return definedOptions({
|
|
84
86
|
id: `frame-${index}`,
|
|
85
87
|
functionName: match[1] || undefined,
|
|
86
88
|
file: match[2],
|
|
87
89
|
line: Number(match[3]),
|
|
88
90
|
column: Number(match[4]),
|
|
89
91
|
source: line,
|
|
90
|
-
};
|
|
92
|
+
});
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Suggestion from './Suggestion.svelte';
|
|
2
2
|
import Suggestions from './Suggestions.svelte';
|
|
3
3
|
export { Suggestion, Suggestions };
|
|
4
|
-
export declare const Root: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "
|
|
4
|
+
export declare const Root: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "children" | "class"> & {
|
|
5
5
|
class?: string;
|
|
6
6
|
children?: import("svelte").Snippet;
|
|
7
7
|
ariaLabel?: string;
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<script lang="ts">
|
|
13
|
+
import { definedReactiveOptions } from '@svadmin/core/options';
|
|
14
|
+
|
|
13
15
|
import type { Snippet } from 'svelte';
|
|
14
16
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
15
17
|
import { cn, isPromiseLike } from '../../utils.js';
|
|
@@ -67,13 +69,13 @@
|
|
|
67
69
|
const hasClearCallback = $derived(Boolean(onclear || onClear));
|
|
68
70
|
|
|
69
71
|
import { provideTerminalContext } from './context.svelte.js';
|
|
70
|
-
provideTerminalContext({
|
|
72
|
+
provideTerminalContext(definedReactiveOptions({
|
|
71
73
|
get output() { return outputText; },
|
|
72
74
|
get lines() { return renderedLines; },
|
|
73
75
|
get isStreaming() { return effectiveStreaming; },
|
|
74
76
|
get autoScroll() { return autoScroll; },
|
|
75
77
|
get onClear() { return hasClearCallback ? clearTerminal : undefined; },
|
|
76
|
-
});
|
|
78
|
+
}));
|
|
77
79
|
|
|
78
80
|
$effect(() => {
|
|
79
81
|
void outputText;
|
|
@@ -3,17 +3,20 @@ const ANSI_SGR_PATTERN = new RegExp(`${ANSI_ESCAPE}\\[([0-9;]*)m`, 'g');
|
|
|
3
3
|
const ANSI_COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
|
|
4
4
|
function resetStyle(style) {
|
|
5
5
|
for (const key of Object.keys(style))
|
|
6
|
-
style
|
|
6
|
+
Reflect.deleteProperty(style, key);
|
|
7
7
|
}
|
|
8
8
|
function setColor(style, target, code) {
|
|
9
9
|
const offset = target === 'foreground' ? (code >= 90 ? 90 : 30) : (code >= 100 ? 100 : 40);
|
|
10
|
-
|
|
10
|
+
const color = ANSI_COLORS[code - offset];
|
|
11
|
+
if (color !== undefined)
|
|
12
|
+
style[target] = color;
|
|
11
13
|
}
|
|
12
14
|
function applyExtendedColor(style, target, codes, index) {
|
|
13
15
|
if (codes[index + 1] === 5) {
|
|
14
16
|
const colorIndex = codes[index + 2];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
const color = colorIndex === undefined ? undefined : ANSI_COLORS[colorIndex];
|
|
18
|
+
if (color !== undefined)
|
|
19
|
+
style[target] = color;
|
|
17
20
|
return index + 2;
|
|
18
21
|
}
|
|
19
22
|
return codes[index + 1] === 2 ? index + 4 : index;
|
|
@@ -45,11 +48,11 @@ function applyCode(style, codes, index) {
|
|
|
45
48
|
else if ((code >= 30 && code <= 37) || (code >= 90 && code <= 97))
|
|
46
49
|
setColor(style, 'foreground', code);
|
|
47
50
|
else if (code === 39)
|
|
48
|
-
style.foreground
|
|
51
|
+
delete style.foreground;
|
|
49
52
|
else if ((code >= 40 && code <= 47) || (code >= 100 && code <= 107))
|
|
50
53
|
setColor(style, 'background', code);
|
|
51
54
|
else if (code === 49)
|
|
52
|
-
style.background
|
|
55
|
+
delete style.background;
|
|
53
56
|
else if (code === 38)
|
|
54
57
|
return applyExtendedColor(style, 'foreground', codes, index);
|
|
55
58
|
else if (code === 48)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<script lang="ts">import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import { cn } from '../../utils.js'; import TestDuration from './TestDuration.svelte'; import TestName from './TestName.svelte'; import type { TestResultStatus } from './TestResults.svelte'; import TestStatus from './TestStatus.svelte'; import { provideTestContext } from './context.svelte.js'; interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { name: string; status: TestResultStatus; duration?: number; class?: string; children?: Snippet; } let { name, status, duration, class: className = '', children, ...rest }: Props = $props();
|
|
1
|
+
<script lang="ts">import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import { cn } from '../../utils.js'; import TestDuration from './TestDuration.svelte'; import TestName from './TestName.svelte'; import type { TestResultStatus } from './TestResults.svelte'; import TestStatus from './TestStatus.svelte'; import { provideTestContext } from './context.svelte.js'; interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { name: string; status: TestResultStatus; duration?: number; class?: string; children?: Snippet; } let { name, status, duration, class: className = '', children, ...rest }: Props = $props(); const testContext = { get name() { return name; }, get status() { return status; }, get duration() { return duration; } }; provideTestContext(testContext);</script>
|
|
2
2
|
<div {...rest} class={cn('svadmin-ai-tests-part__test', className)} data-slot="test">{#if children}{@render children()}{:else}<TestStatus /><TestName />{#if duration !== undefined}<TestDuration />{/if}{/if}</div>
|
|
3
3
|
<style>.svadmin-ai-tests-part__test { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .55rem .75rem; font-size: .75rem; }</style>
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
provideTestResultsContext({ get summary() { return resolvedSummary; } });
|
|
58
58
|
|
|
59
59
|
function statusLabel(status: TestResultStatus): string {
|
|
60
|
-
return status === 'todo' ? 'To do' : status
|
|
60
|
+
return status === 'todo' ? 'To do' : status.charAt(0).toUpperCase() + status.slice(1);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function formatDuration(value?: number): string {
|
|
@@ -18,7 +18,7 @@ export interface TestSuiteContextValue {
|
|
|
18
18
|
export interface TestContextValue {
|
|
19
19
|
readonly name: string;
|
|
20
20
|
readonly status: TestResultStatus;
|
|
21
|
-
readonly duration?: number;
|
|
21
|
+
readonly duration?: number | undefined;
|
|
22
22
|
}
|
|
23
23
|
export declare function provideTestResultsContext(value: TestResultsContextValue): TestResultsContextValue;
|
|
24
24
|
export declare function useTestResultsContext(component?: string): TestResultsContextValue;
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
{/if}
|
|
17
17
|
|
|
18
18
|
<style>
|
|
19
|
-
.svadmin-ai-tool-content { display: grid;
|
|
19
|
+
.svadmin-ai-tool-content { display: grid; gap: 1rem; border-top: 1px solid var(--border, currentColor); padding: 1rem; color: var(--foreground, currentColor); }
|
|
20
20
|
</style>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
{:else}
|
|
32
32
|
<span class="svadmin-ai-tool-header__summary">
|
|
33
33
|
<Wrench size={16} aria-hidden="true" />
|
|
34
|
-
<strong
|
|
34
|
+
<strong>{derivedName}</strong>
|
|
35
35
|
<ToolStatusBadge state={resolvedState} />
|
|
36
36
|
</span>
|
|
37
37
|
<ChevronDown class={cn(tool.open && 'svadmin-ai-tool-header__chevron--open')} size={16} aria-hidden="true" />
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
</summary>
|
|
40
40
|
|
|
41
41
|
<style>
|
|
42
|
-
.svadmin-ai-tool-header { display: flex;
|
|
42
|
+
.svadmin-ai-tool-header { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem; cursor: pointer; list-style: none; }
|
|
43
43
|
.svadmin-ai-tool-header::-webkit-details-marker { display: none; }
|
|
44
|
-
.svadmin-ai-tool-header__summary { display: flex;
|
|
45
|
-
.svadmin-ai-tool-header__summary strong {
|
|
46
|
-
.svadmin-ai-tool-header__summary > :global(svg) {
|
|
44
|
+
.svadmin-ai-tool-header__summary { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }
|
|
45
|
+
.svadmin-ai-tool-header__summary strong { overflow: hidden; font-size: 0.875rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
46
|
+
.svadmin-ai-tool-header__summary > :global(svg) { color: var(--muted-foreground, currentColor); }
|
|
47
47
|
.svadmin-ai-tool-header > :global(svg:last-child) { flex: none; color: var(--muted-foreground, currentColor); transition: transform 150ms ease; }
|
|
48
48
|
.svadmin-ai-tool-header > :global(.svadmin-ai-tool-header__chevron--open) { transform: rotate(180deg); }
|
|
49
49
|
.svadmin-ai-tool-header:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import { cn } from '../../utils.js';
|
|
9
9
|
import { useToolContext } from './context.svelte.js';
|
|
10
10
|
import { formatToolValue } from './status.js';
|
|
11
|
-
import { focusScrollableContent } from './content-polish-scroll-region.js';
|
|
12
11
|
|
|
13
12
|
let { input, class: className = '', ...rest }: ToolInputProps = $props();
|
|
14
13
|
const tool = useToolContext('ToolInput');
|
|
@@ -18,13 +17,12 @@
|
|
|
18
17
|
{#if resolvedInput !== undefined}
|
|
19
18
|
<div {...rest} class={cn('svadmin-ai-tool-input', className)} data-slot="tool-input">
|
|
20
19
|
<h4>Parameters</h4>
|
|
21
|
-
<pre
|
|
20
|
+
<pre>{formatToolValue(resolvedInput)}</pre>
|
|
22
21
|
</div>
|
|
23
22
|
{/if}
|
|
24
23
|
|
|
25
24
|
<style>
|
|
26
|
-
.svadmin-ai-tool-input { display: grid;
|
|
25
|
+
.svadmin-ai-tool-input { display: grid; gap: 0.5rem; overflow: hidden; }
|
|
27
26
|
h4 { margin: 0; color: var(--muted-foreground, currentColor); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; }
|
|
28
27
|
pre { max-height: 12rem; overflow: auto; margin: 0; border-radius: min(var(--radius, 0.5rem), 0.375rem); padding: 0.625rem; background: var(--muted, transparent); font-size: 0.75rem; white-space: pre-wrap; }
|
|
29
|
-
pre:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
30
28
|
</style>
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import { cn } from '../../utils.js';
|
|
9
9
|
import { useToolContext } from './context.svelte.js';
|
|
10
10
|
import { formatToolValue } from './status.js';
|
|
11
|
-
import { focusScrollableContent } from './content-polish-scroll-region.js';
|
|
12
11
|
|
|
13
12
|
let { output, errorText, class: className = '', ...rest }: ToolOutputProps = $props();
|
|
14
13
|
const tool = useToolContext('ToolOutput');
|
|
@@ -19,14 +18,13 @@
|
|
|
19
18
|
{#if resolvedOutput !== undefined || resolvedError}
|
|
20
19
|
<div {...rest} class={cn('svadmin-ai-tool-output', className)} data-slot="tool-output" data-error={resolvedError ? 'true' : undefined}>
|
|
21
20
|
<h4>{resolvedError ? 'Error' : 'Result'}</h4>
|
|
22
|
-
<pre
|
|
21
|
+
<pre>{resolvedError ?? formatToolValue(resolvedOutput)}</pre>
|
|
23
22
|
</div>
|
|
24
23
|
{/if}
|
|
25
24
|
|
|
26
25
|
<style>
|
|
27
|
-
.svadmin-ai-tool-output { display: grid;
|
|
26
|
+
.svadmin-ai-tool-output { display: grid; gap: 0.5rem; }
|
|
28
27
|
h4 { margin: 0; color: var(--muted-foreground, currentColor); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; }
|
|
29
28
|
pre { max-height: 12rem; overflow: auto; margin: 0; border-radius: min(var(--radius, 0.5rem), 0.375rem); padding: 0.625rem; background: var(--muted, transparent); color: var(--foreground, currentColor); font-size: 0.75rem; white-space: pre-wrap; }
|
|
30
29
|
.svadmin-ai-tool-output[data-error='true'] pre { background: color-mix(in oklch, var(--destructive, currentColor) 10%, transparent); color: var(--destructive, currentColor); }
|
|
31
|
-
pre:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
32
30
|
</style>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
const badge = $derived(getStatusBadge(state));
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
|
-
<span
|
|
22
|
+
<span {...rest} class={cn('svadmin-ai-tool-status', className)} data-tone={badge.tone} data-slot="tool-status-badge">
|
|
23
23
|
{#if children}
|
|
24
24
|
{@render children({ label: badge.label })}
|
|
25
25
|
{:else}
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
</span>
|
|
33
33
|
|
|
34
34
|
<style>
|
|
35
|
-
.svadmin-ai-tool-status { display: inline-flex;
|
|
36
|
-
.svadmin-ai-tool-status > :global(svg) { flex: none; }
|
|
35
|
+
.svadmin-ai-tool-status { display: inline-flex; align-items: center; gap: .375rem; border-radius: 999px; padding: .2rem .5rem; background: var(--muted, transparent); color: var(--muted-foreground, currentColor); font-size: .6875rem; }
|
|
37
36
|
.svadmin-ai-tool-status[data-tone='success'] { color: var(--success, currentColor); }
|
|
38
37
|
.svadmin-ai-tool-status[data-tone='info'] { color: var(--info, currentColor); }
|
|
39
38
|
.svadmin-ai-tool-status[data-tone='warning'] { color: var(--warning, currentColor); }
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
export interface VoiceSelectorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { value?: string; defaultValue?: string; open?: boolean; defaultOpen?: boolean; class?: string; children?: Snippet; onvaluechange?: (value: string | undefined) => void; onopenchange?: (open: boolean) => void; }
|
|
3
|
+
export interface VoiceSelectorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { value?: string | undefined; defaultValue?: string; open?: boolean; defaultOpen?: boolean; class?: string; children?: Snippet; onvaluechange?: (value: string | undefined) => void; onopenchange?: (open: boolean) => void; }
|
|
4
4
|
</script>
|
|
5
5
|
<script lang="ts">
|
|
6
|
+
|
|
6
7
|
import { cn } from '../../utils.js'; import { provideVoiceSelector, type VoiceSelectorItemRegistration } from './context.svelte.js';
|
|
7
8
|
let { value = $bindable<string | undefined>(), defaultValue, open = $bindable(false), defaultOpen = false, class: className = '', children, onvaluechange, onopenchange, onkeydown, ...rest }: VoiceSelectorProps = $props();
|
|
8
9
|
let initialized = false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
export interface VoiceSelectorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> {
|
|
4
|
-
value?: string;
|
|
4
|
+
value?: string | undefined;
|
|
5
5
|
defaultValue?: string;
|
|
6
6
|
open?: boolean;
|
|
7
7
|
defaultOpen?: boolean;
|
|
@@ -10,6 +10,6 @@ export interface VoiceSelectorProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
10
10
|
onvaluechange?: (value: string | undefined) => void;
|
|
11
11
|
onopenchange?: (open: boolean) => void;
|
|
12
12
|
}
|
|
13
|
-
declare const VoiceSelector: import("svelte").Component<VoiceSelectorProps, {}, "
|
|
13
|
+
declare const VoiceSelector: import("svelte").Component<VoiceSelectorProps, {}, "open" | "value">;
|
|
14
14
|
type VoiceSelector = ReturnType<typeof VoiceSelector>;
|
|
15
15
|
export default VoiceSelector;
|
|
@@ -9,7 +9,8 @@ export interface VoiceSelectorContextValue {
|
|
|
9
9
|
readonly value: string | undefined;
|
|
10
10
|
readonly open: boolean;
|
|
11
11
|
readonly query: string;
|
|
12
|
-
|
|
12
|
+
/** The getter remains present when filtering leaves no active item. */
|
|
13
|
+
readonly activeId: string | undefined;
|
|
13
14
|
readonly visibleCount: number;
|
|
14
15
|
setValue(value: string | undefined): void;
|
|
15
16
|
setOpen(open: boolean): void;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
+
import { definedReactiveOptions } from '@svadmin/core/options';
|
|
6
7
|
import type { Snippet } from 'svelte';
|
|
7
8
|
import { ExternalLink, Globe, Monitor, RefreshCw, Smartphone, Tablet } from '@lucide/svelte';
|
|
8
9
|
import { cn } from '../../utils.js';
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
onload?.();
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
provideWebPreviewContext({
|
|
91
|
+
provideWebPreviewContext(definedReactiveOptions({
|
|
91
92
|
get url() { return url; },
|
|
92
93
|
get safeUrl() { return safeUrl; },
|
|
93
94
|
get srcdoc() { return srcdoc; },
|
|
@@ -102,9 +103,9 @@
|
|
|
102
103
|
back,
|
|
103
104
|
forward,
|
|
104
105
|
reload,
|
|
105
|
-
setConsoleOpen(nextOpen) { consoleOpen = nextOpen; },
|
|
106
|
+
setConsoleOpen(nextOpen: boolean) { consoleOpen = nextOpen; },
|
|
106
107
|
frameLoaded: handleLoad,
|
|
107
|
-
});
|
|
108
|
+
}));
|
|
108
109
|
</script>
|
|
109
110
|
|
|
110
111
|
<section class={cn('svadmin-ai-web-preview', children && 'svadmin-ai-web-preview--compound', className)} aria-labelledby={children ? undefined : `${previewId}-title`} data-slot="web-preview">
|
package/dist/contracts.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ export declare function normalizeMessageParts(parts: ChatMessagePart[] | string)
|
|
|
9
9
|
export declare function partsToText(parts: ChatMessagePart[]): string;
|
|
10
10
|
export declare function isChatProviderStream(response: ChatProviderResponse): response is ChatProviderStream;
|
|
11
11
|
export interface ConsumeTextResponseOptions {
|
|
12
|
-
/**
|
|
12
|
+
/** Stops applying subsequent chunks after the provider request is cancelled. */
|
|
13
13
|
signal?: AbortSignal;
|
|
14
|
-
/**
|
|
14
|
+
/** Rejects stale results with an identity check when the component scope or input changes. */
|
|
15
15
|
isCurrent?: () => boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare function consumeTextResponse(response: ChatProviderResponse, onText?: (text: string) => void, options?: ConsumeTextResponseOptions): Promise<string>;
|
|
@@ -5,13 +5,27 @@ export type GeneratedComponentSchemaProps<Schema extends TObject> = StaticDecode
|
|
|
5
5
|
export interface GeneratedComponentDefinition<Schema extends TObject = TObject> {
|
|
6
6
|
readonly component: Component<GeneratedComponentSchemaProps<Schema>>;
|
|
7
7
|
readonly schema: Schema;
|
|
8
|
+
readonly description?: string;
|
|
8
9
|
}
|
|
9
10
|
export interface RuntimeGeneratedComponentDefinition {
|
|
10
11
|
readonly component: Component<never>;
|
|
11
12
|
readonly schema: TObject;
|
|
13
|
+
readonly description?: string;
|
|
12
14
|
}
|
|
13
15
|
export type GeneratedComponentRegistry = Record<string, RuntimeGeneratedComponentDefinition>;
|
|
14
|
-
|
|
16
|
+
export interface GeneratedComponentPromptOptions {
|
|
17
|
+
/** Adds a caller-owned instruction before the generated catalog. */
|
|
18
|
+
readonly preamble?: string;
|
|
19
|
+
/** Includes the JSON Schema for each component's props. */
|
|
20
|
+
readonly includeSchemas?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Defines Agent-rendered components with a TypeBox schema as the runtime props boundary. */
|
|
15
23
|
export declare function defineGeneratedComponent<const Schema extends TObject>(definition: GeneratedComponentDefinition<Schema>): GeneratedComponentDefinition<Schema>;
|
|
16
24
|
export declare function decodeGeneratedObjectProps(schema: TObject, input: unknown): GeneratedComponentProps;
|
|
17
25
|
export declare function decodeGeneratedComponentProps(definition: RuntimeGeneratedComponentDefinition, input: unknown): GeneratedComponentProps;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a deterministic model-facing catalog from the allow-listed registry.
|
|
28
|
+
* The catalog describes data and component names only; visual styling remains
|
|
29
|
+
* owned by the registered Svelte components.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createGeneratedComponentPrompt(registry: GeneratedComponentRegistry, options?: GeneratedComponentPromptOptions): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Value } from '@sinclair/typebox/value';
|
|
2
|
-
/**
|
|
2
|
+
/** Defines Agent-rendered components with a TypeBox schema as the runtime props boundary. */
|
|
3
3
|
export function defineGeneratedComponent(definition) {
|
|
4
4
|
return {
|
|
5
5
|
...definition,
|
|
@@ -16,6 +16,25 @@ export function decodeGeneratedObjectProps(schema, input) {
|
|
|
16
16
|
export function decodeGeneratedComponentProps(definition, input) {
|
|
17
17
|
return decodeGeneratedObjectProps(definition.schema, input);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a deterministic model-facing catalog from the allow-listed registry.
|
|
21
|
+
* The catalog describes data and component names only; visual styling remains
|
|
22
|
+
* owned by the registered Svelte components.
|
|
23
|
+
*/
|
|
24
|
+
export function createGeneratedComponentPrompt(registry, options = {}) {
|
|
25
|
+
const entries = Object.entries(registry)
|
|
26
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
27
|
+
.map(([name, definition]) => {
|
|
28
|
+
const description = definition.description ? ` - ${definition.description}` : '';
|
|
29
|
+
const schema = options.includeSchemas === false
|
|
30
|
+
? ''
|
|
31
|
+
: `\n propsSchema: ${JSON.stringify(definition.schema)}`;
|
|
32
|
+
return `- ${name}${description}${schema}`;
|
|
33
|
+
});
|
|
34
|
+
const preamble = options.preamble?.trim();
|
|
35
|
+
const header = preamble ? `${preamble}\n\n` : '';
|
|
36
|
+
return `${header}You may render only registered components from this catalog. Do not emit HTML, CSS, class names, or unregistered component names. Validate every prop against the component propsSchema.\n\nComponents:\n${entries.join('\n')}`;
|
|
37
|
+
}
|
|
19
38
|
function strictGeneratedObjectSchema(schema) {
|
|
20
39
|
if (schema.additionalProperties === false)
|
|
21
40
|
return schema;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
16
|
+
import { definedOptions } from '@svadmin/core/options';
|
|
16
17
|
import { onMount, tick } from 'svelte';
|
|
17
18
|
|
|
18
19
|
let { content, children, delay = 250 }: TooltipProps = $props();
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
onfocusin={() => show(true)}
|
|
102
103
|
onfocusout={handleFocusOut}
|
|
103
104
|
>
|
|
104
|
-
{@render children({ describedBy: content ? tooltipId : undefined })}
|
|
105
|
+
{@render children(definedOptions({ describedBy: content ? tooltipId : undefined }))}
|
|
105
106
|
</span>
|
|
106
107
|
|
|
107
108
|
{#if content && open}
|
|
@@ -18,7 +18,6 @@ export interface AIElementParityEntry {
|
|
|
18
18
|
surfaceStatus: AIElementParityStatus;
|
|
19
19
|
componentSurfaceStatus: AIElementParityStatus;
|
|
20
20
|
behaviorStatus: AIElementParityVerificationStatus;
|
|
21
|
-
behaviorEvidence: readonly string[];
|
|
22
21
|
visualStatus: AIElementParityVerificationStatus;
|
|
23
22
|
exactExports: readonly string[];
|
|
24
23
|
fallbackExports: readonly string[];
|