@svadmin/ai-elements 0.1.0 → 0.3.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/README.md +45 -9
- package/dist/ai.css +35 -1
- package/dist/components/ChatDialog.svelte +93 -35
- package/dist/components/ChatDialog.svelte.d.ts +6 -0
- package/dist/components/Conversation.svelte +37 -17
- package/dist/components/Conversation.svelte.d.ts +3 -2
- package/dist/components/ConversationContent.svelte +29 -4
- package/dist/components/ConversationContent.svelte.d.ts +3 -2
- package/dist/components/ConversationEmptyState.svelte +33 -7
- package/dist/components/ConversationEmptyState.svelte.d.ts +4 -2
- package/dist/components/ConversationScrollButton.svelte +47 -2
- package/dist/components/ConversationScrollButton.svelte.d.ts +8 -2
- package/dist/components/Message.svelte +30 -16
- package/dist/components/Message.svelte.d.ts +5 -5
- package/dist/components/MessageContent.svelte +23 -4
- package/dist/components/MessageContent.svelte.d.ts +3 -2
- package/dist/components/Reasoning.svelte +51 -9
- package/dist/components/Reasoning.svelte.d.ts +4 -3
- package/dist/components/action/Action.svelte +48 -0
- package/dist/components/action/Action.svelte.d.ts +13 -0
- package/dist/components/action/Actions.svelte +12 -0
- package/dist/components/action/Actions.svelte.d.ts +9 -0
- package/dist/components/action/index.d.ts +4 -0
- package/dist/components/action/index.js +2 -0
- package/dist/components/artifact/ArtifactAction.svelte +43 -7
- package/dist/components/artifact/ArtifactAction.svelte.d.ts +5 -0
- package/dist/components/artifact/ArtifactClose.svelte +26 -6
- package/dist/components/artifact/ArtifactClose.svelte.d.ts +5 -2
- package/dist/components/artifact/index.d.ts +1 -0
- package/dist/components/audio-player/AudioPlayerControlBar.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerDurationDisplay.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerElement.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerMuteButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerPlayButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerSeekBackwardButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerSeekForwardButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerTimeDisplay.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerTimeRange.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerVolumeRange.svelte +0 -1
- package/dist/components/checkpoint/index.d.ts +2 -2
- package/dist/components/code/Code.svelte +16 -0
- package/dist/components/code/Code.svelte.d.ts +10 -0
- package/dist/components/code/index.d.ts +23 -0
- package/dist/components/code/index.js +14 -0
- package/dist/components/code-block/CodeBlock.svelte +23 -4
- package/dist/components/code-block/CodeBlock.svelte.d.ts +8 -4
- package/dist/components/code-block/CodeBlockContent.svelte +7 -1
- package/dist/components/code-block/CodeBlockContent.svelte.d.ts +1 -0
- package/dist/components/code-block/CodeBlockLine.svelte +3 -1
- package/dist/components/code-block/CodeBlockLine.svelte.d.ts +1 -0
- package/dist/components/code-block/CodeBlockOverflow.svelte +32 -0
- package/dist/components/code-block/CodeBlockOverflow.svelte.d.ts +13 -0
- package/dist/components/code-block/index.d.ts +3 -0
- package/dist/components/code-block/index.js +1 -0
- package/dist/components/context/Context.svelte +46 -5
- package/dist/components/context/Context.svelte.d.ts +5 -1
- package/dist/components/conversation/index.d.ts +4 -0
- package/dist/components/file-tree/FileTree.svelte +35 -16
- package/dist/components/file-tree/FileTree.svelte.d.ts +7 -1
- package/dist/components/file-tree/FileTreeFile.svelte +3 -3
- package/dist/components/file-tree/FileTreeFile.svelte.d.ts +1 -0
- package/dist/components/file-tree/context.svelte.d.ts +2 -0
- package/dist/components/inline-citation/InlineCitation.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCardBody.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselHeader.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselIndex.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselNext.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselPrev.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationQuote.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationText.svelte +0 -1
- package/dist/components/jsx-preview/JSXPreviewContent.svelte +43 -31
- package/dist/components/jsx-preview/index.d.ts +1 -1
- package/dist/components/jsx-preview/parser.d.ts +18 -8
- package/dist/components/jsx-preview/parser.js +1 -1
- package/dist/components/message/MessageAction.svelte +45 -9
- package/dist/components/message/MessageAction.svelte.d.ts +2 -2
- package/dist/components/message/MessageAttachment.svelte +64 -0
- package/dist/components/message/MessageAttachment.svelte.d.ts +18 -0
- package/dist/components/message/MessageAttachmentPreview.svelte +51 -0
- package/dist/components/message/MessageAttachmentPreview.svelte.d.ts +9 -0
- package/dist/components/message/MessageAttachments.svelte +25 -0
- package/dist/components/message/MessageAttachments.svelte.d.ts +9 -0
- package/dist/components/message/MessageResponse.svelte +26 -8
- package/dist/components/message/MessageResponse.svelte.d.ts +5 -5
- package/dist/components/message/index.d.ts +8 -0
- package/dist/components/message/index.js +3 -0
- package/dist/components/prompt-input/PromptInput.svelte +17 -4
- package/dist/components/prompt-input/PromptInput.svelte.d.ts +3 -1
- package/dist/components/prompt-input/PromptInputActionAddAttachments.svelte +0 -1
- package/dist/components/prompt-input/PromptInputActionMenuContent.svelte +0 -1
- package/dist/components/prompt-input/PromptInputActionMenuTrigger.svelte +0 -1
- package/dist/components/prompt-input/PromptInputAttachment.svelte +31 -0
- package/dist/components/prompt-input/PromptInputAttachment.svelte.d.ts +9 -0
- package/dist/components/prompt-input/PromptInputAttachmentImagePreview.svelte +34 -0
- package/dist/components/prompt-input/PromptInputAttachmentImagePreview.svelte.d.ts +9 -0
- package/dist/components/prompt-input/PromptInputAttachments.svelte +22 -0
- package/dist/components/prompt-input/PromptInputAttachments.svelte.d.ts +10 -0
- package/dist/components/prompt-input/PromptInputBody.svelte +0 -1
- package/dist/components/prompt-input/PromptInputButton.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommand.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandEmpty.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandGroup.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandInput.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandList.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandSeparator.svelte +0 -1
- package/dist/components/prompt-input/PromptInputFooter.svelte +0 -1
- package/dist/components/prompt-input/PromptInputHeader.svelte +0 -1
- package/dist/components/prompt-input/PromptInputHoverCardContent.svelte +0 -1
- package/dist/components/prompt-input/PromptInputHoverCardTrigger.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSelectContent.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSelectItem.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSelectTrigger.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSubmit.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTab.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabBody.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabItem.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabLabel.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabsList.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTextarea.svelte +3 -3
- package/dist/components/prompt-input/PromptInputToolbar.svelte +14 -0
- package/dist/components/prompt-input/PromptInputToolbar.svelte.d.ts +9 -0
- package/dist/components/prompt-input/PromptInputTools.svelte +0 -1
- package/dist/components/prompt-input/context.svelte.d.ts +1 -0
- package/dist/components/prompt-input/index.d.ts +8 -0
- package/dist/components/prompt-input/index.js +4 -0
- package/dist/components/reasoning/index.d.ts +1 -0
- package/dist/components/response/index.d.ts +2 -0
- package/dist/components/response/index.js +1 -0
- package/dist/components/sandbox/SandboxHeader.svelte +13 -4
- package/dist/components/sandbox/SandboxHeader.svelte.d.ts +6 -5
- package/dist/components/sandbox/SandboxTabContent.svelte +1 -1
- package/dist/components/sandbox/SandboxTabs.svelte +2 -2
- package/dist/components/sandbox/SandboxTabs.svelte.d.ts +1 -0
- package/dist/components/sandbox/SandboxTabsTrigger.svelte +12 -2
- package/dist/components/sandbox/SandboxTabsTrigger.svelte.d.ts +4 -5
- package/dist/components/sandbox/context.svelte.d.ts +2 -0
- package/dist/components/snippet/index.d.ts +2 -2
- package/dist/components/stack-trace/StackTrace.svelte +6 -4
- package/dist/components/stack-trace/StackTrace.svelte.d.ts +2 -1
- package/dist/components/stack-trace/StackTraceCopyButton.svelte +48 -2
- package/dist/components/stack-trace/StackTraceHeader.svelte +37 -2
- package/dist/components/stack-trace/StackTraceHeader.svelte.d.ts +2 -2
- package/dist/components/suggestion/index.d.ts +1 -1
- package/dist/components/terminal/AnsiText.svelte +42 -0
- package/dist/components/terminal/AnsiText.svelte.d.ts +6 -0
- package/dist/components/terminal/Terminal.svelte +20 -10
- package/dist/components/terminal/Terminal.svelte.d.ts +2 -1
- package/dist/components/terminal/TerminalContent.svelte +2 -2
- package/dist/components/terminal/ansi.d.ts +12 -0
- package/dist/components/terminal/ansi.js +76 -0
- package/dist/components/tool/ToolHeader.svelte +4 -16
- package/dist/components/tool/ToolStatusBadge.svelte +4 -3
- package/dist/components/tool/index.d.ts +1 -1
- package/dist/components/tool/status.d.ts +4 -1
- package/dist/components/tool/status.js +7 -7
- package/dist/components/transcription/Transcription.svelte +22 -14
- package/dist/components/transcription/Transcription.svelte.d.ts +2 -1
- package/dist/components/transcription/TranscriptionSegment.svelte +1 -1
- package/dist/components/transcription/context.svelte.d.ts +1 -0
- package/dist/components/voice-selector/VoiceSelectorAccent.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorAge.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorAttributes.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorBullet.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorContent.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorDescription.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorDialog.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorEmpty.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorGender.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorGroup.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorInput.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorList.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorName.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorPreview.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorRoot.svelte.d.ts +1 -1
- package/dist/components/voice-selector/VoiceSelectorSeparator.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorShortcut.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorTrigger.svelte +0 -1
- package/dist/components/workflow/index.d.ts +6 -0
- package/dist/components/workflow/index.js +3 -0
- package/dist/components/workflow/node/index.d.ts +1 -0
- package/dist/components/workflow/node/index.js +1 -0
- package/dist/components/workflow/panel/index.d.ts +1 -0
- package/dist/components/workflow/panel/index.js +1 -0
- package/dist/components/workflow/toolbar/index.d.ts +1 -0
- package/dist/components/workflow/toolbar/index.js +1 -0
- package/dist/context.svelte.d.ts +1 -0
- package/dist/contracts.d.ts +1 -1
- package/dist/generated-components.d.ts +2 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.js +8 -4
- package/dist/internal/Tooltip.svelte +124 -0
- package/dist/internal/Tooltip.svelte.d.ts +12 -0
- package/dist/parity-manifest.js +1 -0
- package/package.json +4 -3
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
type
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'value'> {
|
|
3
4
|
value: string;
|
|
4
5
|
class?: string;
|
|
5
6
|
children?: Snippet;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
declare const SandboxTabsTrigger: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
}
|
|
8
|
+
declare const SandboxTabsTrigger: import("svelte").Component<Props, {}, "">;
|
|
10
9
|
type SandboxTabsTrigger = ReturnType<typeof SandboxTabsTrigger>;
|
|
11
10
|
export default SandboxTabsTrigger;
|
|
@@ -5,6 +5,8 @@ export interface SandboxContextValue {
|
|
|
5
5
|
export interface SandboxTabsContextValue {
|
|
6
6
|
readonly value: string;
|
|
7
7
|
setValue(value: string): void;
|
|
8
|
+
tabId(value: string): string;
|
|
9
|
+
panelId(value: string): string;
|
|
8
10
|
}
|
|
9
11
|
export declare function provideSandboxContext(value: SandboxContextValue): void;
|
|
10
12
|
export declare function useSandboxContext(): SandboxContextValue;
|
|
@@ -5,7 +5,7 @@ import SnippetInput from './SnippetInput.svelte';
|
|
|
5
5
|
import SnippetText from './SnippetText.svelte';
|
|
6
6
|
export { Snippet, SnippetAddon, SnippetCopyButton, SnippetInput, SnippetText };
|
|
7
7
|
export declare const Root: import("svelte").Component<import("./Snippet.svelte").SnippetProps, {}, "">;
|
|
8
|
-
export declare const Addon: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "
|
|
8
|
+
export declare const Addon: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "children" | "class"> & {
|
|
9
9
|
align?: "inline-start" | "inline-end" | "block-start" | "block-end";
|
|
10
10
|
class?: string;
|
|
11
11
|
children?: import("svelte").Snippet;
|
|
@@ -16,7 +16,7 @@ export declare const Input: import("svelte").Component<Omit<import("svelte/eleme
|
|
|
16
16
|
} & {
|
|
17
17
|
ariaLabel?: string;
|
|
18
18
|
}, {}, "">;
|
|
19
|
-
export declare const Text: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLSpanElement>, "
|
|
19
|
+
export declare const Text: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLSpanElement>, "children" | "class"> & {
|
|
20
20
|
class?: string;
|
|
21
21
|
children?: import("svelte").Snippet;
|
|
22
22
|
}, {}, "">;
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
|
|
19
19
|
<script lang="ts">
|
|
20
20
|
import type { Snippet } from 'svelte';
|
|
21
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
21
22
|
import { ChevronDown, Copy, ExternalLink } from '@lucide/svelte';
|
|
22
23
|
import { cn } from '../../utils.js';
|
|
23
|
-
interface Props {
|
|
24
|
+
interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'class' | 'title'> {
|
|
24
25
|
trace?: string;
|
|
25
26
|
error?: StackTraceErrorData | Error | string;
|
|
26
27
|
message?: string;
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
stack,
|
|
46
47
|
frames,
|
|
47
48
|
title = 'Stack trace',
|
|
48
|
-
defaultOpen =
|
|
49
|
+
defaultOpen = false,
|
|
49
50
|
open = $bindable(defaultOpen),
|
|
50
51
|
class: className = '',
|
|
51
52
|
children,
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
onfilepathclick,
|
|
55
56
|
onOpenChange,
|
|
56
57
|
onFilePathClick,
|
|
58
|
+
...rest
|
|
57
59
|
}: Props = $props();
|
|
58
60
|
|
|
59
61
|
import { parseStackTrace as parseCompoundStackTrace, provideStackTraceContext } from './context.svelte.js';
|
|
@@ -102,11 +104,11 @@
|
|
|
102
104
|
</script>
|
|
103
105
|
|
|
104
106
|
{#if children}
|
|
105
|
-
<section class={cn('svadmin-ai-stack-trace', 'svadmin-ai-stack-trace--compound', className)} data-slot="stack-trace">
|
|
107
|
+
<section {...rest} class={cn('svadmin-ai-stack-trace', 'svadmin-ai-stack-trace--compound', className)} data-slot="stack-trace">
|
|
106
108
|
{@render children()}
|
|
107
109
|
</section>
|
|
108
110
|
{:else}
|
|
109
|
-
<details class={cn('svadmin-ai-stack-trace', className)} {open} ontoggle={(event) => { const next = (event.currentTarget as HTMLDetailsElement).open; open = next; onopenchange?.(next); if (onOpenChange !== onopenchange) onOpenChange?.(next); }}>
|
|
111
|
+
<details {...rest} class={cn('svadmin-ai-stack-trace', className)} {open} ontoggle={(event) => { const next = (event.currentTarget as HTMLDetailsElement).open; open = next; onopenchange?.(next); if (onOpenChange !== onopenchange) onOpenChange?.(next); }}>
|
|
110
112
|
<summary class="svadmin-ai-stack-trace__summary">
|
|
111
113
|
<span class="svadmin-ai-stack-trace__summary-main">
|
|
112
114
|
<span class="svadmin-ai-stack-trace__chevron" aria-hidden="true"><ChevronDown size={15} /></span>
|
|
@@ -13,7 +13,8 @@ export interface StackTraceErrorData {
|
|
|
13
13
|
stack?: string;
|
|
14
14
|
}
|
|
15
15
|
import type { Snippet } from 'svelte';
|
|
16
|
-
|
|
16
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
17
|
+
interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'class' | 'title'> {
|
|
17
18
|
trace?: string;
|
|
18
19
|
error?: StackTraceErrorData | Error | string;
|
|
19
20
|
message?: string;
|
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
import { Check, Copy } from '@lucide/svelte';
|
|
5
|
+
import { cn } from '../../utils.js';
|
|
6
|
+
import { useStackTraceContext } from './context.svelte.js';
|
|
7
|
+
|
|
8
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'onerror'> {
|
|
9
|
+
class?: string;
|
|
10
|
+
children?: Snippet<[boolean]>;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
oncopy?: () => void;
|
|
13
|
+
onerror?: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { class: className = '', children, timeout = 2000, oncopy, onerror, onclick, onkeydown, disabled = false, ...rest }: Props = $props();
|
|
17
|
+
const stack = useStackTraceContext('StackTraceCopyButton');
|
|
18
|
+
let copied = $state(false);
|
|
19
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
20
|
+
|
|
21
|
+
async function copyTrace(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): Promise<void> {
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
onclick?.(event);
|
|
24
|
+
if (disabled || event.defaultPrevented) return;
|
|
25
|
+
if (typeof navigator === 'undefined' || !navigator.clipboard?.writeText) {
|
|
26
|
+
onerror?.(new Error('Clipboard API not available'));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await navigator.clipboard.writeText(stack.raw);
|
|
31
|
+
copied = true;
|
|
32
|
+
oncopy?.();
|
|
33
|
+
if (timer) clearTimeout(timer);
|
|
34
|
+
timer = setTimeout(() => { copied = false; }, timeout);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
onerror?.(error instanceof Error ? error : new Error('Copy failed'));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function stopKeyboardPropagation(event: KeyboardEvent & { currentTarget: EventTarget & HTMLButtonElement }): void {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
onkeydown?.(event);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
$effect(() => () => { if (timer) clearTimeout(timer); });
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<button {...rest} type="button" class={cn('svadmin-ai-stack-part__button', className)} aria-label={copied ? 'Copied stack trace' : 'Copy stack trace'} title={copied ? 'Copied' : 'Copy stack trace'} {disabled} data-slot="stack-trace-copy-button" onclick={copyTrace} onkeydown={stopKeyboardPropagation}>{#if children}{@render children(copied)}{:else}{#if copied}<Check size={14} aria-hidden="true" />{:else}<Copy size={14} aria-hidden="true" />{/if}{/if}</button>
|
|
3
49
|
<style>.svadmin-ai-stack-part__button { display: inline-flex; width: 1.9rem; height: 1.9rem; align-items: center; justify-content: center; border: 0; border-radius: min(var(--radius, .5rem), .5rem); background: transparent; color: var(--muted-foreground, currentColor); cursor: pointer; }.svadmin-ai-stack-part__button:hover:not(:disabled) { background: var(--muted, transparent); color: var(--foreground, currentColor); }.svadmin-ai-stack-part__button:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }</style>
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { cn } from '../../utils.js';
|
|
5
|
+
import { useStackTraceContext } from './context.svelte.js';
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> {
|
|
8
|
+
class?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { class: className = '', children, onclick, onkeydown, tabindex = 0, ...rest }: Props = $props();
|
|
13
|
+
const stack = useStackTraceContext('StackTraceHeader');
|
|
14
|
+
|
|
15
|
+
function toggleFromClick(event: MouseEvent & { currentTarget: EventTarget & HTMLDivElement }): void {
|
|
16
|
+
onclick?.(event);
|
|
17
|
+
if (!event.defaultPrevented) stack.setOpen(!stack.open);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function toggleFromKeyboard(event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }): void {
|
|
21
|
+
onkeydown?.(event);
|
|
22
|
+
if (event.defaultPrevented || event.target !== event.currentTarget || (event.key !== 'Enter' && event.key !== ' ')) return;
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
stack.setOpen(!stack.open);
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div
|
|
29
|
+
{...rest}
|
|
30
|
+
role="button"
|
|
31
|
+
{tabindex}
|
|
32
|
+
class={cn('svadmin-ai-stack-part__header', className)}
|
|
33
|
+
aria-expanded={stack.open}
|
|
34
|
+
data-slot="stack-trace-header"
|
|
35
|
+
onclick={toggleFromClick}
|
|
36
|
+
onkeydown={toggleFromKeyboard}
|
|
37
|
+
>{@render children?.()}</div>
|
|
3
38
|
<style>.svadmin-ai-stack-part__header { display: flex; width: 100%; align-items: center; gap: .75rem; padding: .7rem .8rem; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }.svadmin-ai-stack-part__header:hover { background: var(--muted, transparent); }.svadmin-ai-stack-part__header:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: -2px; }</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type {
|
|
3
|
-
interface Props extends Omit<
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> {
|
|
4
4
|
class?: string;
|
|
5
5
|
children?: Snippet;
|
|
6
6
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { parseAnsi } from './ansi.js';
|
|
3
|
+
|
|
4
|
+
let { text }: { text: string } = $props();
|
|
5
|
+
const segments = $derived(parseAnsi(text));
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#each segments as segment, index (`${index}-${segment.text}`)}
|
|
9
|
+
<span
|
|
10
|
+
data-ansi-foreground={segment.foreground}
|
|
11
|
+
data-ansi-background={segment.background}
|
|
12
|
+
data-ansi-bold={segment.bold || undefined}
|
|
13
|
+
data-ansi-dim={segment.dim || undefined}
|
|
14
|
+
data-ansi-italic={segment.italic || undefined}
|
|
15
|
+
data-ansi-underline={segment.underline || undefined}
|
|
16
|
+
data-ansi-strikethrough={segment.strikethrough || undefined}
|
|
17
|
+
>{segment.text}</span>
|
|
18
|
+
{/each}
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
[data-ansi-bold='true'] { font-weight: 700; }
|
|
22
|
+
[data-ansi-dim='true'] { opacity: .65; }
|
|
23
|
+
[data-ansi-italic='true'] { font-style: italic; }
|
|
24
|
+
[data-ansi-underline='true'] { text-decoration: underline; }
|
|
25
|
+
[data-ansi-strikethrough='true'] { text-decoration: line-through; }
|
|
26
|
+
[data-ansi-foreground='black'] { color: var(--muted-foreground, currentColor); }
|
|
27
|
+
[data-ansi-foreground='red'] { color: var(--destructive, currentColor); }
|
|
28
|
+
[data-ansi-foreground='green'] { color: var(--success, currentColor); }
|
|
29
|
+
[data-ansi-foreground='yellow'] { color: var(--warning, currentColor); }
|
|
30
|
+
[data-ansi-foreground='blue'] { color: var(--info, var(--primary, currentColor)); }
|
|
31
|
+
[data-ansi-foreground='magenta'] { color: var(--chart-4, var(--primary, currentColor)); }
|
|
32
|
+
[data-ansi-foreground='cyan'] { color: var(--chart-5, var(--info, currentColor)); }
|
|
33
|
+
[data-ansi-foreground='white'] { color: var(--foreground, currentColor); }
|
|
34
|
+
[data-ansi-background='black'] { background: var(--muted, transparent); }
|
|
35
|
+
[data-ansi-background='red'] { background: color-mix(in srgb, var(--destructive, currentColor) 22%, transparent); }
|
|
36
|
+
[data-ansi-background='green'] { background: color-mix(in srgb, var(--success, currentColor) 22%, transparent); }
|
|
37
|
+
[data-ansi-background='yellow'] { background: color-mix(in srgb, var(--warning, currentColor) 22%, transparent); }
|
|
38
|
+
[data-ansi-background='blue'] { background: color-mix(in srgb, var(--info, var(--primary, currentColor)) 22%, transparent); }
|
|
39
|
+
[data-ansi-background='magenta'] { background: color-mix(in srgb, var(--chart-4, var(--primary, currentColor)) 22%, transparent); }
|
|
40
|
+
[data-ansi-background='cyan'] { background: color-mix(in srgb, var(--chart-5, var(--info, currentColor)) 22%, transparent); }
|
|
41
|
+
[data-ansi-background='white'] { background: color-mix(in srgb, var(--foreground, currentColor) 18%, transparent); }
|
|
42
|
+
</style>
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
<script lang="ts">
|
|
13
13
|
import type { Snippet } from 'svelte';
|
|
14
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
14
15
|
import { cn, isPromiseLike } from '../../utils.js';
|
|
16
|
+
import AnsiText from './AnsiText.svelte';
|
|
15
17
|
|
|
16
|
-
interface Props {
|
|
18
|
+
interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'class' | 'title'> {
|
|
17
19
|
lines?: TerminalLine[];
|
|
18
20
|
output?: string;
|
|
19
21
|
isStreaming?: boolean;
|
|
@@ -49,6 +51,7 @@
|
|
|
49
51
|
oncommanderror,
|
|
50
52
|
onclear,
|
|
51
53
|
onClear,
|
|
54
|
+
...rest
|
|
52
55
|
}: Props = $props();
|
|
53
56
|
|
|
54
57
|
let localLines = $state<TerminalLine[]>([]);
|
|
@@ -56,10 +59,12 @@
|
|
|
56
59
|
let historyIndex = $state(-1);
|
|
57
60
|
let submitting = $state(false);
|
|
58
61
|
let inputElement: HTMLInputElement | undefined = $state();
|
|
62
|
+
let bodyElement: HTMLDivElement | undefined = $state();
|
|
59
63
|
const renderedLines = $derived([...lines, ...localLines]);
|
|
60
64
|
const outputText = $derived(output ?? renderedLines.map((line) => line.text).join('\n'));
|
|
61
65
|
const effectiveStreaming = $derived(submitting || isStreaming);
|
|
62
66
|
const statusLabel = $derived(effectiveStreaming ? 'Running command' : readOnly ? 'Read only' : 'Ready');
|
|
67
|
+
const hasClearCallback = $derived(Boolean(onclear || onClear));
|
|
63
68
|
|
|
64
69
|
import { provideTerminalContext } from './context.svelte.js';
|
|
65
70
|
provideTerminalContext({
|
|
@@ -67,7 +72,12 @@
|
|
|
67
72
|
get lines() { return renderedLines; },
|
|
68
73
|
get isStreaming() { return effectiveStreaming; },
|
|
69
74
|
get autoScroll() { return autoScroll; },
|
|
70
|
-
onClear:
|
|
75
|
+
get onClear() { return hasClearCallback ? clearTerminal : undefined; },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
$effect(() => {
|
|
79
|
+
void outputText;
|
|
80
|
+
if (autoScroll && bodyElement) bodyElement.scrollTop = bodyElement.scrollHeight;
|
|
71
81
|
});
|
|
72
82
|
|
|
73
83
|
function submitCommand(): void {
|
|
@@ -128,7 +138,7 @@
|
|
|
128
138
|
}
|
|
129
139
|
</script>
|
|
130
140
|
|
|
131
|
-
<section class={cn('svadmin-ai-terminal', children && 'svadmin-ai-terminal--compound', className)}
|
|
141
|
+
<section aria-label={title} {...rest} class={cn('svadmin-ai-terminal', children && 'svadmin-ai-terminal--compound', className)} data-slot="terminal">
|
|
132
142
|
{#if children}
|
|
133
143
|
{@render children()}
|
|
134
144
|
{:else}
|
|
@@ -140,20 +150,20 @@
|
|
|
140
150
|
</div>
|
|
141
151
|
<div class="svadmin-ai-terminal__actions">
|
|
142
152
|
<span class="svadmin-ai-terminal__status" role="status" aria-live="polite">{statusLabel}</span>
|
|
143
|
-
|
|
144
|
-
Clear
|
|
145
|
-
|
|
153
|
+
{#if hasClearCallback}
|
|
154
|
+
<button type="button" class="svadmin-ai-terminal__clear" aria-label="Clear terminal" onclick={clearTerminal} disabled={disabled || submitting}>Clear</button>
|
|
155
|
+
{/if}
|
|
146
156
|
</div>
|
|
147
157
|
</header>
|
|
148
158
|
|
|
149
|
-
<div class="svadmin-ai-terminal__body" role="log" aria-live="polite" aria-busy={submitting}>
|
|
159
|
+
<div bind:this={bodyElement} class="svadmin-ai-terminal__body" role="log" aria-live="polite" aria-busy={submitting}>
|
|
150
160
|
{#if output !== undefined}
|
|
151
|
-
<div class="svadmin-ai-terminal__line"><code
|
|
161
|
+
<div class="svadmin-ai-terminal__line"><code><AnsiText text={output} /></code></div>
|
|
152
162
|
{:else}
|
|
153
163
|
{#each renderedLines as line, index (line.id ?? `${line.kind ?? 'output'}-${index}-${line.text}`)}
|
|
154
164
|
<div class={cn('svadmin-ai-terminal__line', `svadmin-ai-terminal__line--${line.kind ?? 'output'}`)}>
|
|
155
165
|
{#if line.kind === 'input'}<span class="svadmin-ai-terminal__prompt" aria-hidden="true">{prompt}</span>{/if}
|
|
156
|
-
<code
|
|
166
|
+
<code><AnsiText text={line.text} /></code>
|
|
157
167
|
{#if line.timestamp}<time datetime={line.timestamp}>{line.timestamp}</time>{/if}
|
|
158
168
|
</div>
|
|
159
169
|
{:else}
|
|
@@ -162,7 +172,7 @@
|
|
|
162
172
|
{/if}
|
|
163
173
|
</div>
|
|
164
174
|
|
|
165
|
-
{#if !readOnly}
|
|
175
|
+
{#if oncommand && !readOnly}
|
|
166
176
|
<form class="svadmin-ai-terminal__form" onsubmit={(event) => { event.preventDefault(); submitCommand(); }}>
|
|
167
177
|
<label class="svadmin-ai-terminal__input-label">
|
|
168
178
|
<span class="svadmin-ai-terminal__prompt" aria-hidden="true">{prompt}</span>
|
|
@@ -6,7 +6,8 @@ export interface TerminalLine {
|
|
|
6
6
|
timestamp?: string;
|
|
7
7
|
}
|
|
8
8
|
import type { Snippet } from 'svelte';
|
|
9
|
-
|
|
9
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
10
|
+
interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'class' | 'title'> {
|
|
10
11
|
lines?: TerminalLine[];
|
|
11
12
|
output?: string;
|
|
12
13
|
isStreaming?: boolean;
|
|
@@ -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 { useTerminalContext } from './context.svelte.js'; interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { class?: string; children?: Snippet; maxHeight?: string; } let { class: className = '', children, maxHeight, ...rest }: Props = $props(); const terminal = useTerminalContext('TerminalContent'); let element = $state<HTMLDivElement>(); $effect(() => { if (terminal.autoScroll && element) element.scrollTop = element.scrollHeight; });</script>
|
|
2
|
-
<div {...rest} bind:this={element} class={cn('svadmin-ai-terminal-part__content', className)} style:--terminal-max-height={maxHeight} data-slot="terminal-content" role="log" aria-live="polite" aria-busy={terminal.isStreaming}>{#if children}{@render children()}{:else}<pre
|
|
1
|
+
<script lang="ts">import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import { cn } from '../../utils.js'; import AnsiText from './AnsiText.svelte'; import { useTerminalContext } from './context.svelte.js'; interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { class?: string; children?: Snippet; maxHeight?: string; } let { class: className = '', children, maxHeight, ...rest }: Props = $props(); const terminal = useTerminalContext('TerminalContent'); let element = $state<HTMLDivElement>(); $effect(() => { if (terminal.autoScroll && element) element.scrollTop = element.scrollHeight; });</script>
|
|
2
|
+
<div {...rest} bind:this={element} class={cn('svadmin-ai-terminal-part__content', className)} style:--terminal-max-height={maxHeight} data-slot="terminal-content" role="log" aria-live="polite" aria-busy={terminal.isStreaming}>{#if children}{@render children()}{:else}<pre><AnsiText text={terminal.output} />{#if terminal.isStreaming}<span class="svadmin-ai-terminal-part__cursor" aria-hidden="true"></span>{/if}</pre>{/if}</div>
|
|
3
3
|
<style>.svadmin-ai-terminal-part__content { max-height: var(--terminal-max-height, 24rem); overflow: auto; padding: .8rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; line-height: 1.55; }.svadmin-ai-terminal-part__content pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }.svadmin-ai-terminal-part__cursor { display: inline-block; width: .45rem; height: 1em; margin-left: .25rem; vertical-align: -.15em; background: currentColor; animation: svadmin-ai-terminal-cursor 1s steps(2, jump-none) infinite; } @keyframes svadmin-ai-terminal-cursor { 50% { opacity: 0; } }</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AnsiColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
|
|
2
|
+
export interface AnsiSegment {
|
|
3
|
+
text: string;
|
|
4
|
+
foreground?: AnsiColor;
|
|
5
|
+
background?: AnsiColor;
|
|
6
|
+
bold?: boolean;
|
|
7
|
+
dim?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
underline?: boolean;
|
|
10
|
+
strikethrough?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseAnsi(text: string): AnsiSegment[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const ANSI_ESCAPE = String.fromCharCode(27);
|
|
2
|
+
const ANSI_SGR_PATTERN = new RegExp(`${ANSI_ESCAPE}\\[([0-9;]*)m`, 'g');
|
|
3
|
+
const ANSI_COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
|
|
4
|
+
function resetStyle(style) {
|
|
5
|
+
for (const key of Object.keys(style))
|
|
6
|
+
style[key] = undefined;
|
|
7
|
+
}
|
|
8
|
+
function setColor(style, target, code) {
|
|
9
|
+
const offset = target === 'foreground' ? (code >= 90 ? 90 : 30) : (code >= 100 ? 100 : 40);
|
|
10
|
+
style[target] = ANSI_COLORS[code - offset];
|
|
11
|
+
}
|
|
12
|
+
function applyExtendedColor(style, target, codes, index) {
|
|
13
|
+
if (codes[index + 1] === 5) {
|
|
14
|
+
const colorIndex = codes[index + 2];
|
|
15
|
+
if (colorIndex !== undefined && colorIndex < ANSI_COLORS.length)
|
|
16
|
+
style[target] = ANSI_COLORS[colorIndex];
|
|
17
|
+
return index + 2;
|
|
18
|
+
}
|
|
19
|
+
return codes[index + 1] === 2 ? index + 4 : index;
|
|
20
|
+
}
|
|
21
|
+
function applyCode(style, codes, index) {
|
|
22
|
+
const code = codes[index] ?? 0;
|
|
23
|
+
if (code === 0)
|
|
24
|
+
resetStyle(style);
|
|
25
|
+
else if (code === 1)
|
|
26
|
+
style.bold = true;
|
|
27
|
+
else if (code === 2)
|
|
28
|
+
style.dim = true;
|
|
29
|
+
else if (code === 3)
|
|
30
|
+
style.italic = true;
|
|
31
|
+
else if (code === 4)
|
|
32
|
+
style.underline = true;
|
|
33
|
+
else if (code === 9)
|
|
34
|
+
style.strikethrough = true;
|
|
35
|
+
else if (code === 22) {
|
|
36
|
+
style.bold = false;
|
|
37
|
+
style.dim = false;
|
|
38
|
+
}
|
|
39
|
+
else if (code === 23)
|
|
40
|
+
style.italic = false;
|
|
41
|
+
else if (code === 24)
|
|
42
|
+
style.underline = false;
|
|
43
|
+
else if (code === 29)
|
|
44
|
+
style.strikethrough = false;
|
|
45
|
+
else if ((code >= 30 && code <= 37) || (code >= 90 && code <= 97))
|
|
46
|
+
setColor(style, 'foreground', code);
|
|
47
|
+
else if (code === 39)
|
|
48
|
+
style.foreground = undefined;
|
|
49
|
+
else if ((code >= 40 && code <= 47) || (code >= 100 && code <= 107))
|
|
50
|
+
setColor(style, 'background', code);
|
|
51
|
+
else if (code === 49)
|
|
52
|
+
style.background = undefined;
|
|
53
|
+
else if (code === 38)
|
|
54
|
+
return applyExtendedColor(style, 'foreground', codes, index);
|
|
55
|
+
else if (code === 48)
|
|
56
|
+
return applyExtendedColor(style, 'background', codes, index);
|
|
57
|
+
return index;
|
|
58
|
+
}
|
|
59
|
+
export function parseAnsi(text) {
|
|
60
|
+
const segments = [];
|
|
61
|
+
const style = {};
|
|
62
|
+
let cursor = 0;
|
|
63
|
+
let match;
|
|
64
|
+
ANSI_SGR_PATTERN.lastIndex = 0;
|
|
65
|
+
while ((match = ANSI_SGR_PATTERN.exec(text))) {
|
|
66
|
+
if (match.index > cursor)
|
|
67
|
+
segments.push({ text: text.slice(cursor, match.index), ...style });
|
|
68
|
+
const codes = match[1] ? match[1].split(';').map(Number) : [0];
|
|
69
|
+
for (let index = 0; index < codes.length; index += 1)
|
|
70
|
+
index = applyCode(style, codes, index);
|
|
71
|
+
cursor = ANSI_SGR_PATTERN.lastIndex;
|
|
72
|
+
}
|
|
73
|
+
if (cursor < text.length)
|
|
74
|
+
segments.push({ text: text.slice(cursor), ...style });
|
|
75
|
+
return segments.length ? segments : [{ text: '' }];
|
|
76
|
+
}
|
|
@@ -14,15 +14,14 @@
|
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<script lang="ts">
|
|
17
|
-
import {
|
|
17
|
+
import { ChevronDown, Wrench } from '@lucide/svelte';
|
|
18
18
|
import { cn } from '../../utils.js';
|
|
19
19
|
import { useToolContext } from './context.svelte.js';
|
|
20
|
-
import
|
|
20
|
+
import ToolStatusBadge from './ToolStatusBadge.svelte';
|
|
21
21
|
|
|
22
22
|
let { title, type, state: stateProp, toolName, class: className = '', children, ...rest }: ToolHeaderProps = $props();
|
|
23
23
|
const tool = useToolContext('ToolHeader');
|
|
24
24
|
const resolvedState = $derived(stateProp ?? tool.state);
|
|
25
|
-
const badge = $derived(getStatusBadge(resolvedState));
|
|
26
25
|
const derivedName = $derived(title ?? toolName ?? (type === 'dynamic-tool' ? toolName : type?.split('-').slice(1).join('-')) ?? tool.name);
|
|
27
26
|
</script>
|
|
28
27
|
|
|
@@ -33,13 +32,7 @@
|
|
|
33
32
|
<span class="svadmin-ai-tool-header__summary">
|
|
34
33
|
<Wrench size={16} aria-hidden="true" />
|
|
35
34
|
<strong>{derivedName}</strong>
|
|
36
|
-
<
|
|
37
|
-
{#if badge.tone === 'success'}<CheckCircle2 size={14} aria-hidden="true" />
|
|
38
|
-
{:else if badge.tone === 'danger' || badge.tone === 'warning'}<CircleX size={14} aria-hidden="true" />
|
|
39
|
-
{:else if badge.tone === 'pending'}<Clock3 size={14} aria-hidden="true" />
|
|
40
|
-
{:else}<Circle size={12} aria-hidden="true" />{/if}
|
|
41
|
-
{badge.label}
|
|
42
|
-
</span>
|
|
35
|
+
<ToolStatusBadge state={resolvedState} />
|
|
43
36
|
</span>
|
|
44
37
|
<ChevronDown class={cn(tool.open && 'svadmin-ai-tool-header__chevron--open')} size={16} aria-hidden="true" />
|
|
45
38
|
{/if}
|
|
@@ -48,14 +41,9 @@
|
|
|
48
41
|
<style>
|
|
49
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; }
|
|
50
43
|
.svadmin-ai-tool-header::-webkit-details-marker { display: none; }
|
|
51
|
-
.svadmin-ai-tool-header__summary
|
|
44
|
+
.svadmin-ai-tool-header__summary { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }
|
|
52
45
|
.svadmin-ai-tool-header__summary strong { overflow: hidden; font-size: 0.875rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
53
46
|
.svadmin-ai-tool-header__summary > :global(svg) { color: var(--muted-foreground, currentColor); }
|
|
54
|
-
.svadmin-ai-tool-header__badge { flex: none; border-radius: 999px; padding: 0.2rem 0.5rem; background: var(--muted, transparent); color: var(--muted-foreground, currentColor); font-size: 0.6875rem; }
|
|
55
|
-
.svadmin-ai-tool-header__badge[data-tone='success'] { color: var(--success, currentColor); }
|
|
56
|
-
.svadmin-ai-tool-header__badge[data-tone='warning'] { color: var(--warning, currentColor); }
|
|
57
|
-
.svadmin-ai-tool-header__badge[data-tone='danger'] { color: var(--destructive, currentColor); }
|
|
58
|
-
.svadmin-ai-tool-header__badge[data-tone='pending'] { color: var(--primary, currentColor); }
|
|
59
47
|
.svadmin-ai-tool-header > :global(svg:last-child) { flex: none; color: var(--muted-foreground, currentColor); transition: transform 150ms ease; }
|
|
60
48
|
.svadmin-ai-tool-header > :global(.svadmin-ai-tool-header__chevron--open) { transform: rotate(180deg); }
|
|
61
49
|
.svadmin-ai-tool-header:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
{#if children}
|
|
24
24
|
{@render children({ label: badge.label })}
|
|
25
25
|
{:else}
|
|
26
|
-
{#if badge.
|
|
27
|
-
{:else if badge.
|
|
28
|
-
{:else if badge.
|
|
26
|
+
{#if badge.icon === 'check-circle'}<CheckCircle2 size={14} aria-hidden="true" />
|
|
27
|
+
{:else if badge.icon === 'x-circle'}<CircleX size={14} aria-hidden="true" />
|
|
28
|
+
{:else if badge.icon === 'clock'}<Clock3 class={badge.pulse ? 'animate-pulse' : ''} size={14} aria-hidden="true" />
|
|
29
29
|
{:else}<Circle size={12} aria-hidden="true" />{/if}
|
|
30
30
|
<span>{badge.label}</span>
|
|
31
31
|
{/if}
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
<style>
|
|
35
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; }
|
|
36
36
|
.svadmin-ai-tool-status[data-tone='success'] { color: var(--success, currentColor); }
|
|
37
|
+
.svadmin-ai-tool-status[data-tone='info'] { color: var(--info, currentColor); }
|
|
37
38
|
.svadmin-ai-tool-status[data-tone='warning'] { color: var(--warning, currentColor); }
|
|
38
39
|
.svadmin-ai-tool-status[data-tone='danger'] { color: var(--destructive, currentColor); }
|
|
39
40
|
.svadmin-ai-tool-status[data-tone='pending'] { color: var(--primary, currentColor); }
|
|
@@ -5,7 +5,7 @@ export { default as Input, default as ToolInput } from './ToolInput.svelte';
|
|
|
5
5
|
export { default as Output, default as ToolOutput } from './ToolOutput.svelte';
|
|
6
6
|
export { default as StatusBadge, default as ToolStatusBadge } from './ToolStatusBadge.svelte';
|
|
7
7
|
export { getStatusBadge } from './status.js';
|
|
8
|
-
export type { ToolDisplayState, ToolStatusBadge as ToolStatusBadgeDefinition, ToolStatusTone, } from './status.js';
|
|
8
|
+
export type { ToolDisplayState, ToolStatusIcon, ToolStatusBadge as ToolStatusBadgeDefinition, ToolStatusTone, } from './status.js';
|
|
9
9
|
export type { ToolHeaderProps } from './ToolHeader.svelte';
|
|
10
10
|
export type { ToolInputProps } from './ToolInput.svelte';
|
|
11
11
|
export type { ToolOutputProps } from './ToolOutput.svelte';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ToolState } from '../../contracts.js';
|
|
2
2
|
export type ToolDisplayState = ToolState;
|
|
3
|
-
export type ToolStatusTone = 'neutral' | 'pending' | 'success' | 'warning' | 'danger';
|
|
3
|
+
export type ToolStatusTone = 'neutral' | 'pending' | 'info' | 'success' | 'warning' | 'danger';
|
|
4
|
+
export type ToolStatusIcon = 'circle' | 'clock' | 'check-circle' | 'x-circle';
|
|
4
5
|
export interface ToolStatusBadge {
|
|
5
6
|
label: string;
|
|
6
7
|
tone: ToolStatusTone;
|
|
8
|
+
icon: ToolStatusIcon;
|
|
9
|
+
pulse?: boolean;
|
|
7
10
|
}
|
|
8
11
|
export declare function getStatusBadge(status: ToolDisplayState): ToolStatusBadge;
|
|
9
12
|
export declare function formatToolValue(value: unknown): string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const statuses = {
|
|
2
|
-
'approval-requested': { label: 'Awaiting Approval', tone: 'warning' },
|
|
3
|
-
'approval-responded': { label: 'Responded', tone: '
|
|
4
|
-
'input-available': { label: 'Running', tone: 'pending' },
|
|
5
|
-
'input-streaming': { label: 'Pending', tone: 'neutral' },
|
|
6
|
-
'output-available': { label: 'Completed', tone: 'success' },
|
|
7
|
-
'output-denied': { label: 'Denied', tone: 'warning' },
|
|
8
|
-
'output-error': { label: 'Error', tone: 'danger' },
|
|
2
|
+
'approval-requested': { label: 'Awaiting Approval', tone: 'warning', icon: 'clock' },
|
|
3
|
+
'approval-responded': { label: 'Responded', tone: 'info', icon: 'check-circle' },
|
|
4
|
+
'input-available': { label: 'Running', tone: 'pending', icon: 'clock', pulse: true },
|
|
5
|
+
'input-streaming': { label: 'Pending', tone: 'neutral', icon: 'circle' },
|
|
6
|
+
'output-available': { label: 'Completed', tone: 'success', icon: 'check-circle' },
|
|
7
|
+
'output-denied': { label: 'Denied', tone: 'warning', icon: 'x-circle' },
|
|
8
|
+
'output-error': { label: 'Error', tone: 'danger', icon: 'x-circle' },
|
|
9
9
|
};
|
|
10
10
|
export function getStatusBadge(status) {
|
|
11
11
|
return statuses[status];
|