]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
e466c84ee20f965fd0b48fbb2fb88e061588ccad
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { ChevronDown, ShieldQuestion } from '@lucide/svelte';
3 import { ChatMessageActionCard } from '$lib/components/app';
4 import { Button } from '$lib/components/ui/button';
5 import * as ButtonGroup from '$lib/components/ui/button-group';
6 import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
7 import { ToolSource, ToolPermissionDecision } from '$lib/enums';
8 import { TOOL_SERVER_LABELS } from '$lib/constants';
9 import { toolsStore } from '$lib/stores/tools.svelte';
10
11 interface Props {
12 toolName: string;
13 serverLabel: string;
14 onDecision: (decision: ToolPermissionDecision) => void;
15 }
16
17 let { toolName, serverLabel, onDecision }: Props = $props();
18 </script>
19
20 <ChatMessageActionCard icon={ShieldQuestion}>
21 {#snippet message()}
22 Allow use of
23
24 <span class="font-semibold">{toolName}</span>
25
26 {#if serverLabel}
27 from <span class="font-semibold">{serverLabel}</span>
28 {/if}
29
30 ?
31 {/snippet}
32
33 {#snippet actions()}
34 <DropdownMenu.Root>
35 <ButtonGroup.Root
36 class="overflow-hidden rounded-md bg-foreground text-white shadow-sm dark:bg-secondary dark:text-foreground"
37 >
38 <Button
39 class="rounded-none! shadow-none!"
40 size="sm"
41 onclick={() => onDecision(ToolPermissionDecision.ONCE)}
42 >
43 Allow once
44 </Button>
45
46 <ButtonGroup.Separator />
47
48 <DropdownMenu.Trigger>
49 <Button size="sm" class="rounded-none! !ps-2 shadow-none!">
50 <ChevronDown class="h-3.5 w-3.5" />
51 </Button>
52 </DropdownMenu.Trigger>
53 </ButtonGroup.Root>
54
55 <DropdownMenu.Content align="start" class="min-w-[8rem]">
56 <DropdownMenu.Item onclick={() => onDecision(ToolPermissionDecision.ALWAYS)}>
57 Always allow <pre>{toolName}</pre>
58 tool
59 </DropdownMenu.Item>
60 {#if serverLabel}
61 <DropdownMenu.Item onclick={() => onDecision(ToolPermissionDecision.ALWAYS_SERVER)}>
62 Always allow all tools from {serverLabel}
63 </DropdownMenu.Item>
64 {:else}
65 {@const source = toolsStore.getToolSource(toolName)}
66 {@const providerName =
67 source === ToolSource.BUILTIN
68 ? TOOL_SERVER_LABELS[ToolSource.BUILTIN]
69 : source === ToolSource.CUSTOM
70 ? TOOL_SERVER_LABELS[ToolSource.CUSTOM]
71 : 'MCP Tools'}
72 <DropdownMenu.Item onclick={() => onDecision(ToolPermissionDecision.ALWAYS_SERVER)}>
73 Approve all tools from {providerName}
74 </DropdownMenu.Item>
75 {/if}
76 </DropdownMenu.Content>
77 </DropdownMenu.Root>
78
79 <Button
80 variant="destructive"
81 size="sm"
82 class="text-destructive hover:text-destructive"
83 onclick={() => onDecision(ToolPermissionDecision.DENY)}
84 >
85 Deny
86 </Button>
87 {/snippet}
88 </ChatMessageActionCard>