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