2 import { Info, Loader2 } from '@lucide/svelte';
3 import { AgenticSectionType } from '$lib/enums';
4 import { toolsStore } from '$lib/stores/tools.svelte';
5 import type { AgenticSection } from '$lib/types';
6 import { abbreviateHome } from '$lib/utils';
9 section: AgenticSection;
10 isStreaming?: boolean;
13 let { isStreaming = false, section }: Props = $props();
15 const isPending = $derived(section.type === AgenticSectionType.TOOL_CALL_PENDING);
16 const isStreamingCall = $derived(section.type === AgenticSectionType.TOOL_CALL_STREAMING);
17 const showSpinner = $derived(isPending || (isStreamingCall && isStreaming));
22 errorMessage?: string;
25 function parseGetInfoMeta(toolResultString: string | undefined): GetInfoMeta {
26 if (!toolResultString) return {};
29 const parsed: unknown = JSON.parse(toolResultString);
31 if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
32 const obj = parsed as Record<string, unknown>;
34 if (typeof obj.error === 'string') return { errorMessage: obj.error };
37 cwd: typeof obj.cwd === 'string' ? obj.cwd : undefined,
38 os: typeof obj.os === 'string' ? obj.os : undefined
42 // not JSON - nothing to show
48 const infoMeta = $derived(parseGetInfoMeta(section.toolResult));
49 const home = $derived(toolsStore.serverHome);
50 const cwdDisplay = $derived(abbreviateHome(infoMeta.cwd ?? '', home));
53 <div class="text-muted-foreground flex items-center gap-2 py-1.5">
54 <Info class="text-muted-foreground/60 h-3.5 w-3.5 shrink-0" />
56 <span class="text-foreground/80 text-sm font-medium">Runtime info</span>
57 <Loader2 class="text-muted-foreground/70 h-3 w-3 animate-spin" />
58 {:else if infoMeta.errorMessage}
59 <span class="text-foreground/80 text-sm font-medium">Runtime info </span>
60 <span class="text-red-600 text-xs italic dark:text-red-400">- {infoMeta.errorMessage}</span
62 {:else if infoMeta.os || infoMeta.cwd}
63 <span class="text-foreground/80 text-sm font-medium">Runtime info </span>
65 <span class="font-mono text-foreground/90 text-sm">{infoMeta.os}</span>
68 <span class="font-mono text-foreground/90 text-sm" title={infoMeta.cwd}>{cwdDisplay}</span>
71 <span class="text-foreground/80 text-sm font-medium">Runtime info</span>