]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
d45e361574875f40349f59a09570c5e34ad98196
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { Info, Loader2 } from '@lucide/svelte';
3 import { AgenticSectionType } from '$lib/enums';
4 import { abbreviateHome, type AgenticSection } from '$lib/utils';
5 import { toolsStore } from '$lib/stores/tools.svelte';
6
7 interface Props {
8 section: AgenticSection;
9 isStreaming?: boolean;
10 }
11
12 let { section, isStreaming = false }: Props = $props();
13
14 const isPending = $derived(section.type === AgenticSectionType.TOOL_CALL_PENDING);
15 const isStreamingCall = $derived(section.type === AgenticSectionType.TOOL_CALL_STREAMING);
16 const showSpinner = $derived(isPending || (isStreamingCall && isStreaming));
17
18 type GetInfoMeta = {
19 os?: string;
20 cwd?: string;
21 errorMessage?: string;
22 };
23
24 function parseGetInfoMeta(toolResultString: string | undefined): GetInfoMeta {
25 if (!toolResultString) return {};
26
27 try {
28 const parsed: unknown = JSON.parse(toolResultString);
29 if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
30 const obj = parsed as Record<string, unknown>;
31 if (typeof obj.error === 'string') return { errorMessage: obj.error };
32 return {
33 os: typeof obj.os === 'string' ? obj.os : undefined,
34 cwd: typeof obj.cwd === 'string' ? obj.cwd : undefined
35 };
36 }
37 } catch {
38 // not JSON - nothing to show
39 }
40
41 return {};
42 }
43
44 const infoMeta = $derived(parseGetInfoMeta(section.toolResult));
45 const home = $derived(toolsStore.serverHome);
46 const cwdDisplay = $derived(abbreviateHome(infoMeta.cwd ?? '', home));
47 </script>
48
49 <div class="text-muted-foreground flex items-center gap-2 py-1.5">
50 <Info class="text-muted-foreground/60 h-3.5 w-3.5 shrink-0" />
51 {#if showSpinner}
52 <span class="text-foreground/80 text-sm font-medium">Runtime info</span>
53 <Loader2 class="text-muted-foreground/70 h-3 w-3 animate-spin" />
54 {:else if infoMeta.errorMessage}
55 <span class="text-foreground/80 text-sm font-medium">Runtime info&nbsp;</span>
56 <span class="text-red-600 text-xs italic dark:text-red-400">-&nbsp;{infoMeta.errorMessage}</span
57 >
58 {:else if infoMeta.os || infoMeta.cwd}
59 <span class="text-foreground/80 text-sm font-medium">Runtime info&nbsp;</span>
60 {#if infoMeta.os}
61 <span class="font-mono text-foreground/90 text-sm">{infoMeta.os}</span>
62 {/if}
63 {#if infoMeta.cwd}
64 <span class="font-mono text-foreground/90 text-sm" title={infoMeta.cwd}>{cwdDisplay}</span>
65 {/if}
66 {:else}
67 <span class="text-foreground/80 text-sm font-medium">Runtime info</span>
68 {/if}
69 </div>