@copilotkit/svelte 0.0.1 → 0.1.1-canary.svelte-preview
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/LICENSE +21 -0
- package/README.md +324 -3
- package/dist/app.d.ts +7 -0
- package/dist/components/chat/CopilotChat.svelte +247 -0
- package/dist/components/chat/CopilotChat.svelte.d.ts +5 -0
- package/dist/components/chat/CopilotChat.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatAssistantMessage.svelte +295 -0
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts +80 -0
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte +241 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts +9 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatInput.svelte +192 -0
- package/dist/components/chat/CopilotChatInput.svelte.d.ts +20 -0
- package/dist/components/chat/CopilotChatInput.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatMessage.svelte +37 -0
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts +10 -0
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatMessageView.svelte +76 -0
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts +14 -0
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatReasoningMessage.svelte +210 -0
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts +40 -0
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatSuggestionPill.svelte +66 -0
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts +10 -0
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatSuggestionView.svelte +36 -0
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts +10 -0
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatToggleButton.svelte +47 -0
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts +8 -0
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatToolCallsView.svelte +187 -0
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts +12 -0
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatUserMessage.svelte +312 -0
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts +62 -0
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatView.svelte +177 -0
- package/dist/components/chat/CopilotChatView.svelte.d.ts +32 -0
- package/dist/components/chat/CopilotChatView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotPopup.svelte +187 -0
- package/dist/components/chat/CopilotPopup.svelte.d.ts +5 -0
- package/dist/components/chat/CopilotPopup.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotSidebar.svelte +138 -0
- package/dist/components/chat/CopilotSidebar.svelte.d.ts +5 -0
- package/dist/components/chat/CopilotSidebar.svelte.d.ts.map +1 -0
- package/dist/components/chat/StreamMarkdown.svelte +30 -0
- package/dist/components/chat/StreamMarkdown.svelte.d.ts +7 -0
- package/dist/components/chat/StreamMarkdown.svelte.d.ts.map +1 -0
- package/dist/components/chat/chat-config-context.svelte.d.ts +10 -0
- package/dist/components/chat/chat-config-context.svelte.d.ts.map +1 -0
- package/dist/components/chat/chat-config-context.svelte.js +20 -0
- package/dist/components/chat/dispatch-after-active-run.d.ts +3 -0
- package/dist/components/chat/dispatch-after-active-run.d.ts.map +1 -0
- package/dist/components/chat/dispatch-after-active-run.js +31 -0
- package/dist/components/chat/markdown/CodeBlock.svelte +78 -0
- package/dist/components/chat/markdown/CodeBlock.svelte.d.ts +8 -0
- package/dist/components/chat/markdown/CodeBlock.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/CodeSpan.svelte +29 -0
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts +9 -0
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/Table.svelte +15 -0
- package/dist/components/chat/markdown/Table.svelte.d.ts +8 -0
- package/dist/components/chat/markdown/Table.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableBody.svelte +11 -0
- package/dist/components/chat/markdown/TableBody.svelte.d.ts +8 -0
- package/dist/components/chat/markdown/TableBody.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableCell.svelte +29 -0
- package/dist/components/chat/markdown/TableCell.svelte.d.ts +10 -0
- package/dist/components/chat/markdown/TableCell.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableHead.svelte +11 -0
- package/dist/components/chat/markdown/TableHead.svelte.d.ts +8 -0
- package/dist/components/chat/markdown/TableHead.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableRow.svelte +11 -0
- package/dist/components/chat/markdown/TableRow.svelte.d.ts +8 -0
- package/dist/components/chat/markdown/TableRow.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/highlight.d.ts +8 -0
- package/dist/components/chat/markdown/highlight.d.ts.map +1 -0
- package/dist/components/chat/markdown/highlight.js +91 -0
- package/dist/components/chat/media-parts.d.ts +11 -0
- package/dist/components/chat/media-parts.d.ts.map +1 -0
- package/dist/components/chat/media-parts.js +17 -0
- package/dist/components/chat/types.d.ts +139 -0
- package/dist/components/chat/types.d.ts.map +1 -0
- package/dist/components/chat/types.js +7 -0
- package/dist/components/icons/index.d.ts +2 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/icons/index.js +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +17 -0
- package/dist/hooks/connect-agent-context.svelte.d.ts +9 -0
- package/dist/hooks/connect-agent-context.svelte.d.ts.map +1 -0
- package/dist/hooks/connect-agent-context.svelte.js +25 -0
- package/dist/hooks/create-agent.svelte.d.ts +23 -0
- package/dist/hooks/create-agent.svelte.d.ts.map +1 -0
- package/dist/hooks/create-agent.svelte.js +341 -0
- package/dist/hooks/create-attachments.svelte.d.ts +33 -0
- package/dist/hooks/create-attachments.svelte.d.ts.map +1 -0
- package/dist/hooks/create-attachments.svelte.js +232 -0
- package/dist/hooks/create-capabilities.svelte.d.ts +6 -0
- package/dist/hooks/create-capabilities.svelte.d.ts.map +1 -0
- package/dist/hooks/create-capabilities.svelte.js +17 -0
- package/dist/hooks/create-interrupt.svelte.d.ts +24 -0
- package/dist/hooks/create-interrupt.svelte.d.ts.map +1 -0
- package/dist/hooks/create-interrupt.svelte.js +333 -0
- package/dist/hooks/create-suggestions.svelte.d.ts +12 -0
- package/dist/hooks/create-suggestions.svelte.d.ts.map +1 -0
- package/dist/hooks/create-suggestions.svelte.js +61 -0
- package/dist/hooks/create-threads.svelte.d.ts +33 -0
- package/dist/hooks/create-threads.svelte.d.ts.map +1 -0
- package/dist/hooks/create-threads.svelte.js +230 -0
- package/dist/hooks/index.d.ts +20 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/load-katex-styles.svelte.d.ts +2 -0
- package/dist/hooks/load-katex-styles.svelte.d.ts.map +1 -0
- package/dist/hooks/load-katex-styles.svelte.js +11 -0
- package/dist/hooks/register-frontend-tool.svelte.d.ts +3 -0
- package/dist/hooks/register-frontend-tool.svelte.d.ts.map +1 -0
- package/dist/hooks/register-frontend-tool.svelte.js +32 -0
- package/dist/hooks/register-human-in-the-loop.svelte.d.ts +3 -0
- package/dist/hooks/register-human-in-the-loop.svelte.d.ts.map +1 -0
- package/dist/hooks/register-human-in-the-loop.svelte.js +84 -0
- package/dist/hooks/register-render-tool-call.svelte.d.ts +30 -0
- package/dist/hooks/register-render-tool-call.svelte.d.ts.map +1 -0
- package/dist/hooks/register-render-tool-call.svelte.js +26 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/lib/svelte-core.d.ts +54 -0
- package/dist/lib/svelte-core.d.ts.map +1 -0
- package/dist/lib/svelte-core.js +145 -0
- package/dist/providers/CopilotKitProvider.svelte +291 -0
- package/dist/providers/CopilotKitProvider.svelte.d.ts +9 -0
- package/dist/providers/CopilotKitProvider.svelte.d.ts.map +1 -0
- package/dist/providers/CopilotKitProvider.types.d.ts +47 -0
- package/dist/providers/CopilotKitProvider.types.d.ts.map +1 -0
- package/dist/providers/CopilotKitProvider.types.js +1 -0
- package/dist/providers/context.d.ts +19 -0
- package/dist/providers/context.d.ts.map +1 -0
- package/dist/providers/context.js +2 -0
- package/dist/providers/index.d.ts +6 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/useCopilotKit.d.ts +3 -0
- package/dist/providers/useCopilotKit.d.ts.map +1 -0
- package/dist/providers/useCopilotKit.js +9 -0
- package/dist/styles/globals.css +691 -0
- package/dist/styles.css +2 -0
- package/dist/styles.d.ts +1 -0
- package/dist/types/a2ui.d.ts +5 -0
- package/dist/types/a2ui.d.ts.map +1 -0
- package/dist/types/a2ui.js +1 -0
- package/dist/types/activity-message-renderer.d.ts +17 -0
- package/dist/types/activity-message-renderer.d.ts.map +1 -0
- package/dist/types/activity-message-renderer.js +1 -0
- package/dist/types/custom-message-renderer.d.ts +18 -0
- package/dist/types/custom-message-renderer.d.ts.map +1 -0
- package/dist/types/custom-message-renderer.js +1 -0
- package/dist/types/frontend-tool.d.ts +6 -0
- package/dist/types/frontend-tool.d.ts.map +1 -0
- package/dist/types/frontend-tool.js +1 -0
- package/dist/types/human-in-the-loop.d.ts +31 -0
- package/dist/types/human-in-the-loop.d.ts.map +1 -0
- package/dist/types/human-in-the-loop.js +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/interrupt.d.ts +23 -0
- package/dist/types/interrupt.d.ts.map +1 -0
- package/dist/types/interrupt.js +1 -0
- package/dist/types/sandbox-function.d.ts +8 -0
- package/dist/types/sandbox-function.d.ts.map +1 -0
- package/dist/types/sandbox-function.js +1 -0
- package/dist/types/tool-call-renderer.d.ts +29 -0
- package/dist/types/tool-call-renderer.d.ts.map +1 -0
- package/dist/types/tool-call-renderer.js +1 -0
- package/package.json +103 -8
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CopilotChatInputMode, ToolsMenuItem } from "./types";
|
|
3
|
+
import type { Attachment } from "@copilotkit/shared";
|
|
4
|
+
import CopilotChatAttachmentQueue from "./CopilotChatAttachmentQueue.svelte";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
value: initialValue = "",
|
|
8
|
+
isRunning = false,
|
|
9
|
+
onSubmit,
|
|
10
|
+
onStop,
|
|
11
|
+
onInputChange,
|
|
12
|
+
placeholder = "Type a message...",
|
|
13
|
+
attachments = [] as Attachment[],
|
|
14
|
+
canAddFile = false,
|
|
15
|
+
onAddFile,
|
|
16
|
+
onRemoveAttachment,
|
|
17
|
+
}: {
|
|
18
|
+
value?: string;
|
|
19
|
+
isRunning?: boolean;
|
|
20
|
+
inputMode?: CopilotChatInputMode;
|
|
21
|
+
toolsMenu?: (ToolsMenuItem | "-")[];
|
|
22
|
+
onSubmit: (value: string) => void;
|
|
23
|
+
onStop?: () => void;
|
|
24
|
+
onInputChange: (value: string) => void;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
attachments?: Attachment[];
|
|
27
|
+
canAddFile?: boolean;
|
|
28
|
+
onAddFile?: () => void;
|
|
29
|
+
onRemoveAttachment?: (id: string) => void;
|
|
30
|
+
} = $props();
|
|
31
|
+
|
|
32
|
+
let localValue = $derived(initialValue);
|
|
33
|
+
let hasUploading = $derived(attachments.some((a) => a.status === "uploading"));
|
|
34
|
+
let canSend = $derived(
|
|
35
|
+
isRunning ? true : hasUploading ? false : localValue.trim().length > 0 || attachments.length > 0,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
39
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
40
|
+
if (e.isComposing) return;
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
send();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function send() {
|
|
47
|
+
// Mirror React/Vue: block sends while uploads are in flight. Attachments
|
|
48
|
+
// alone (no text) are a valid send.
|
|
49
|
+
if (hasUploading || isRunning) return;
|
|
50
|
+
const trimmed = localValue.trim();
|
|
51
|
+
if (!trimmed && attachments.length === 0) return;
|
|
52
|
+
onSubmit(trimmed);
|
|
53
|
+
localValue = "";
|
|
54
|
+
onInputChange("");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleInput() {
|
|
58
|
+
onInputChange(localValue);
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div class="copilotkit-input">
|
|
63
|
+
{#if attachments.length > 0}
|
|
64
|
+
<CopilotChatAttachmentQueue {attachments} {onRemoveAttachment} />
|
|
65
|
+
{/if}
|
|
66
|
+
{#if hasUploading}
|
|
67
|
+
<div class="copilotkit-upload-hint" role="status">
|
|
68
|
+
Uploading attachments…
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
71
|
+
<div class="copilotkit-input-row">
|
|
72
|
+
{#if canAddFile}
|
|
73
|
+
<button
|
|
74
|
+
type="button"
|
|
75
|
+
class="copilotkit-attach-btn"
|
|
76
|
+
aria-label="Add file"
|
|
77
|
+
onclick={onAddFile}
|
|
78
|
+
>
|
|
79
|
+
+
|
|
80
|
+
</button>
|
|
81
|
+
{/if}
|
|
82
|
+
<textarea
|
|
83
|
+
class="copilotkit-textarea"
|
|
84
|
+
value={localValue}
|
|
85
|
+
oninput={(e) => { localValue = (e.target as HTMLTextAreaElement).value; handleInput(); }}
|
|
86
|
+
onkeydown={handleKeydown}
|
|
87
|
+
placeholder={placeholder}
|
|
88
|
+
rows="1"
|
|
89
|
+
disabled={isRunning}
|
|
90
|
+
></textarea>
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
class="copilotkit-send-btn"
|
|
94
|
+
onclick={isRunning && onStop ? onStop : send}
|
|
95
|
+
disabled={!isRunning && !canSend}
|
|
96
|
+
>
|
|
97
|
+
{#if isRunning}
|
|
98
|
+
■
|
|
99
|
+
{:else}
|
|
100
|
+
↑
|
|
101
|
+
{/if}
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<style>
|
|
107
|
+
.copilotkit-input {
|
|
108
|
+
border-top: 1px solid #e5e7eb;
|
|
109
|
+
padding: 12px 16px;
|
|
110
|
+
background: #fff;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.copilotkit-input-row {
|
|
114
|
+
display: flex;
|
|
115
|
+
gap: 8px;
|
|
116
|
+
align-items: flex-end;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.copilotkit-textarea {
|
|
120
|
+
flex: 1;
|
|
121
|
+
resize: none;
|
|
122
|
+
border: 1px solid #d1d5db;
|
|
123
|
+
border-radius: 8px;
|
|
124
|
+
padding: 10px 12px;
|
|
125
|
+
font-size: 14px;
|
|
126
|
+
line-height: 1.5;
|
|
127
|
+
font-family: inherit;
|
|
128
|
+
outline: none;
|
|
129
|
+
min-height: 40px;
|
|
130
|
+
max-height: 200px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.copilotkit-textarea:focus {
|
|
134
|
+
border-color: #3b82f6;
|
|
135
|
+
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.copilotkit-textarea:disabled {
|
|
139
|
+
opacity: 0.6;
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.copilotkit-send-btn {
|
|
144
|
+
width: 40px;
|
|
145
|
+
height: 40px;
|
|
146
|
+
border-radius: 8px;
|
|
147
|
+
border: none;
|
|
148
|
+
background: #3b82f6;
|
|
149
|
+
color: #fff;
|
|
150
|
+
font-size: 18px;
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
justify-content: center;
|
|
155
|
+
flex-shrink: 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.copilotkit-send-btn:disabled {
|
|
159
|
+
opacity: 0.4;
|
|
160
|
+
cursor: not-allowed;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.copilotkit-send-btn:hover:not(:disabled) {
|
|
164
|
+
background: #2563eb;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.copilotkit-attach-btn {
|
|
168
|
+
width: 40px;
|
|
169
|
+
height: 40px;
|
|
170
|
+
border-radius: 8px;
|
|
171
|
+
border: 1px solid #d1d5db;
|
|
172
|
+
background: #f9fafb;
|
|
173
|
+
color: #374151;
|
|
174
|
+
font-size: 20px;
|
|
175
|
+
line-height: 1;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
display: flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
flex-shrink: 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.copilotkit-attach-btn:hover {
|
|
184
|
+
background: #f3f4f6;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.copilotkit-upload-hint {
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
color: #6b7280;
|
|
190
|
+
padding: 0 2px 8px;
|
|
191
|
+
}
|
|
192
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CopilotChatInputMode, ToolsMenuItem } from "./types";
|
|
2
|
+
import type { Attachment } from "@copilotkit/shared";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
value?: string;
|
|
5
|
+
isRunning?: boolean;
|
|
6
|
+
inputMode?: CopilotChatInputMode;
|
|
7
|
+
toolsMenu?: (ToolsMenuItem | "-")[];
|
|
8
|
+
onSubmit: (value: string) => void;
|
|
9
|
+
onStop?: () => void;
|
|
10
|
+
onInputChange: (value: string) => void;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
attachments?: Attachment[];
|
|
13
|
+
canAddFile?: boolean;
|
|
14
|
+
onAddFile?: () => void;
|
|
15
|
+
onRemoveAttachment?: (id: string) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const CopilotChatInput: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
18
|
+
type CopilotChatInput = ReturnType<typeof CopilotChatInput>;
|
|
19
|
+
export default CopilotChatInput;
|
|
20
|
+
//# sourceMappingURL=CopilotChatInput.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotChatInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/chat/CopilotChatInput.svelte"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGtD,KAAK,gBAAgB,GAAI;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,aAAa,GAAG,GAAG,CAAC,EAAE,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAwEJ,QAAA,MAAM,gBAAgB,sDAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Message, AssistantMessage, UserMessage, ReasoningMessage } from "@ag-ui/core";
|
|
3
|
+
import CopilotChatAssistantMessage from "./CopilotChatAssistantMessage.svelte";
|
|
4
|
+
import CopilotChatUserMessage from "./CopilotChatUserMessage.svelte";
|
|
5
|
+
import CopilotChatReasoningMessage from "./CopilotChatReasoningMessage.svelte";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
message,
|
|
9
|
+
messages = [] as Message[],
|
|
10
|
+
isRunning = false,
|
|
11
|
+
}: {
|
|
12
|
+
message: Message;
|
|
13
|
+
messages?: Message[];
|
|
14
|
+
isRunning?: boolean;
|
|
15
|
+
} = $props();
|
|
16
|
+
|
|
17
|
+
function isAssistant(msg: Message): msg is AssistantMessage {
|
|
18
|
+
return msg.role === "assistant";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isUser(msg: Message): msg is UserMessage {
|
|
22
|
+
return msg.role === "user";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isReasoning(msg: Message): msg is ReasoningMessage {
|
|
26
|
+
return msg.role === "reasoning";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
{#if isReasoning(message)}
|
|
32
|
+
<CopilotChatReasoningMessage {message} {messages} {isRunning} />
|
|
33
|
+
{:else if isAssistant(message)}
|
|
34
|
+
<CopilotChatAssistantMessage {message} {messages} {isRunning} />
|
|
35
|
+
{:else if isUser(message)}
|
|
36
|
+
<CopilotChatUserMessage {message} />
|
|
37
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Message } from "@ag-ui/core";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
message: Message;
|
|
4
|
+
messages?: Message[];
|
|
5
|
+
isRunning?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const CopilotChatMessage: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type CopilotChatMessage = ReturnType<typeof CopilotChatMessage>;
|
|
9
|
+
export default CopilotChatMessage;
|
|
10
|
+
//# sourceMappingURL=CopilotChatMessage.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotChatMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/chat/CopilotChatMessage.svelte"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAmD,MAAM,aAAa,CAAC;AAK7F,KAAK,gBAAgB,GAAI;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAiCJ,QAAA,MAAM,kBAAkB,sDAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tick } from "svelte";
|
|
3
|
+
import type { Message } from "@ag-ui/core";
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import CopilotChatMessage from "./CopilotChatMessage.svelte";
|
|
6
|
+
import { normalizeAutoScroll, type AutoScrollMode } from "./types";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
messages = [] as Message[],
|
|
10
|
+
isRunning = false,
|
|
11
|
+
autoScroll = true as AutoScrollMode | boolean,
|
|
12
|
+
sentMessageId = null,
|
|
13
|
+
footer,
|
|
14
|
+
}: {
|
|
15
|
+
messages?: Message[];
|
|
16
|
+
isRunning?: boolean;
|
|
17
|
+
autoScroll?: AutoScrollMode | boolean;
|
|
18
|
+
sentMessageId?: string | null;
|
|
19
|
+
footer?: Snippet;
|
|
20
|
+
} = $props();
|
|
21
|
+
|
|
22
|
+
let container: HTMLDivElement | undefined = $state();
|
|
23
|
+
const autoScrollMode = $derived(normalizeAutoScroll(autoScroll));
|
|
24
|
+
let handledSentMessageId: string | null = null;
|
|
25
|
+
|
|
26
|
+
$effect(() => {
|
|
27
|
+
if (!container) return;
|
|
28
|
+
if (autoScrollMode === "pin-to-bottom") {
|
|
29
|
+
void messages;
|
|
30
|
+
void isRunning;
|
|
31
|
+
queueMicrotask(() => {
|
|
32
|
+
if (!container) return;
|
|
33
|
+
container.scrollTop = container.scrollHeight;
|
|
34
|
+
});
|
|
35
|
+
} else if (
|
|
36
|
+
autoScrollMode === "pin-to-send" &&
|
|
37
|
+
sentMessageId &&
|
|
38
|
+
sentMessageId !== handledSentMessageId
|
|
39
|
+
) {
|
|
40
|
+
handledSentMessageId = sentMessageId;
|
|
41
|
+
void tick().then(() => {
|
|
42
|
+
const sentMessage = [...(container?.querySelectorAll<HTMLElement>(
|
|
43
|
+
"[data-message-id]",
|
|
44
|
+
) ?? [])].find((element) => element.dataset.messageId === sentMessageId);
|
|
45
|
+
if (sentMessage && container) {
|
|
46
|
+
const containerTop = container.getBoundingClientRect().top;
|
|
47
|
+
const messageTop = sentMessage.getBoundingClientRect().top;
|
|
48
|
+
container.scrollTop += messageTop - containerTop;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<div bind:this={container} class="copilotkit-message-list">
|
|
56
|
+
<div class="copilotkit-message-list-padding cpk:px-4">
|
|
57
|
+
<div class="copilotkit-message-list-inner cpk:w-full cpk:max-w-3xl cpk:mx-auto">
|
|
58
|
+
{#each messages as msg (msg.id)}
|
|
59
|
+
<CopilotChatMessage message={msg} {messages} {isRunning} />
|
|
60
|
+
{/each}
|
|
61
|
+
{#if footer}
|
|
62
|
+
<div class="copilotkit-message-list-footer cpk:mt-4">
|
|
63
|
+
{@render footer()}
|
|
64
|
+
</div>
|
|
65
|
+
{/if}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
.copilotkit-message-list {
|
|
72
|
+
flex: 1;
|
|
73
|
+
overflow-y: auto;
|
|
74
|
+
padding: 8px 0;
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Message } from "@ag-ui/core";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { type AutoScrollMode } from "./types";
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
messages?: Message[];
|
|
6
|
+
isRunning?: boolean;
|
|
7
|
+
autoScroll?: AutoScrollMode | boolean;
|
|
8
|
+
sentMessageId?: string | null;
|
|
9
|
+
footer?: Snippet;
|
|
10
|
+
};
|
|
11
|
+
declare const CopilotChatMessageView: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
|
+
type CopilotChatMessageView = ReturnType<typeof CopilotChatMessageView>;
|
|
13
|
+
export default CopilotChatMessageView;
|
|
14
|
+
//# sourceMappingURL=CopilotChatMessageView.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotChatMessageView.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/chat/CopilotChatMessageView.svelte"],"names":[],"mappings":"AAIE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAEpE,KAAK,gBAAgB,GAAI;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AA+DJ,QAAA,MAAM,sBAAsB,sDAAwC,CAAC;AACrE,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Message, ReasoningMessage } from "@ag-ui/core";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import { IconChevronRight } from "../icons";
|
|
5
|
+
import StreamMarkdown from "./StreamMarkdown.svelte";
|
|
6
|
+
|
|
7
|
+
interface HeaderSlotProps {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
label: string;
|
|
10
|
+
hasContent: boolean;
|
|
11
|
+
isStreaming: boolean;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ContentViewSlotProps {
|
|
16
|
+
isStreaming: boolean;
|
|
17
|
+
hasContent: boolean;
|
|
18
|
+
content: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ToggleSlotProps {
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
contentView: ContentViewSlotProps;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LayoutSlotProps {
|
|
27
|
+
message: ReasoningMessage;
|
|
28
|
+
messages: Message[];
|
|
29
|
+
isRunning: boolean;
|
|
30
|
+
header: HeaderSlotProps;
|
|
31
|
+
contentView: ContentViewSlotProps;
|
|
32
|
+
toggle: ToggleSlotProps;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let {
|
|
36
|
+
message,
|
|
37
|
+
messages = [] as Message[],
|
|
38
|
+
isRunning = false,
|
|
39
|
+
header,
|
|
40
|
+
contentView,
|
|
41
|
+
toggle,
|
|
42
|
+
layout,
|
|
43
|
+
}: {
|
|
44
|
+
message: ReasoningMessage;
|
|
45
|
+
messages?: Message[];
|
|
46
|
+
isRunning?: boolean;
|
|
47
|
+
header?: Snippet<[HeaderSlotProps]>;
|
|
48
|
+
contentView?: Snippet<[ContentViewSlotProps]>;
|
|
49
|
+
toggle?: Snippet<[ToggleSlotProps]>;
|
|
50
|
+
layout?: Snippet<[LayoutSlotProps]>;
|
|
51
|
+
children?: Snippet<[]>;
|
|
52
|
+
} = $props();
|
|
53
|
+
|
|
54
|
+
function formatDuration(seconds: number): string {
|
|
55
|
+
if (seconds < 1) return "a few seconds";
|
|
56
|
+
if (seconds < 60) return `${Math.round(seconds)} seconds`;
|
|
57
|
+
const mins = Math.floor(seconds / 60);
|
|
58
|
+
const secs = Math.round(seconds % 60);
|
|
59
|
+
if (secs === 0) return `${mins} minute${mins > 1 ? "s" : ""}`;
|
|
60
|
+
return `${mins}m ${secs}s`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const normalizedContent = $derived(
|
|
64
|
+
typeof message.content === "string" ? message.content : "",
|
|
65
|
+
);
|
|
66
|
+
const hasContent = $derived(normalizedContent.length > 0);
|
|
67
|
+
const isLatest = $derived(
|
|
68
|
+
messages[messages.length - 1]?.id === message.id,
|
|
69
|
+
);
|
|
70
|
+
const isStreaming = $derived(!!(isRunning && isLatest));
|
|
71
|
+
|
|
72
|
+
let elapsed = $state(0);
|
|
73
|
+
let isOpen = $state(false);
|
|
74
|
+
let userToggledDuringStreaming = $state(false);
|
|
75
|
+
let startTimeMs: number | null = null;
|
|
76
|
+
let elapsedInterval: ReturnType<typeof setInterval> | null = null;
|
|
77
|
+
|
|
78
|
+
function clearElapsedInterval() {
|
|
79
|
+
if (elapsedInterval) {
|
|
80
|
+
clearInterval(elapsedInterval);
|
|
81
|
+
elapsedInterval = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function updateElapsedNow() {
|
|
86
|
+
if (startTimeMs !== null) {
|
|
87
|
+
elapsed = (Date.now() - startTimeMs) / 1000;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
$effect(() => {
|
|
92
|
+
if (isStreaming) {
|
|
93
|
+
if (startTimeMs === null) {
|
|
94
|
+
startTimeMs = Date.now();
|
|
95
|
+
}
|
|
96
|
+
clearElapsedInterval();
|
|
97
|
+
elapsedInterval = setInterval(updateElapsedNow, 1000);
|
|
98
|
+
userToggledDuringStreaming = false;
|
|
99
|
+
isOpen = true;
|
|
100
|
+
} else {
|
|
101
|
+
clearElapsedInterval();
|
|
102
|
+
updateElapsedNow();
|
|
103
|
+
if (!userToggledDuringStreaming) {
|
|
104
|
+
isOpen = false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return () => {
|
|
109
|
+
clearElapsedInterval();
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const label = $derived(
|
|
114
|
+
isStreaming
|
|
115
|
+
? "Thinking\u2026"
|
|
116
|
+
: `Thought for ${formatDuration(elapsed)}`,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
function toggleOpen() {
|
|
120
|
+
if (!hasContent) return;
|
|
121
|
+
userToggledDuringStreaming = true;
|
|
122
|
+
isOpen = !isOpen;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const headerProps = $derived<HeaderSlotProps>({
|
|
126
|
+
get isOpen() { return isOpen; },
|
|
127
|
+
get label() { return label; },
|
|
128
|
+
get hasContent() { return hasContent; },
|
|
129
|
+
get isStreaming() { return isStreaming; },
|
|
130
|
+
get onClick() { return hasContent ? toggleOpen : undefined; },
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const contentViewProps = $derived<ContentViewSlotProps>({
|
|
134
|
+
get isStreaming() { return isStreaming; },
|
|
135
|
+
get hasContent() { return hasContent; },
|
|
136
|
+
get content() { return normalizedContent; },
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const toggleProps = $derived<ToggleSlotProps>({
|
|
140
|
+
get isOpen() { return isOpen; },
|
|
141
|
+
get contentView() { return contentViewProps; },
|
|
142
|
+
});
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<div data-copilotkit class="cpk:my-1" data-message-id={message.id}>
|
|
146
|
+
{#if layout}
|
|
147
|
+
{@render layout({
|
|
148
|
+
message,
|
|
149
|
+
messages,
|
|
150
|
+
isRunning,
|
|
151
|
+
header: headerProps,
|
|
152
|
+
contentView: contentViewProps,
|
|
153
|
+
toggle: toggleProps,
|
|
154
|
+
})}
|
|
155
|
+
{:else}
|
|
156
|
+
{#if header}
|
|
157
|
+
{@render header(headerProps)}
|
|
158
|
+
{:else}
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
class="cpk:inline-flex cpk:items-center cpk:gap-1 cpk:py-1 cpk:text-sm cpk:text-muted-foreground cpk:transition-colors cpk:select-none"
|
|
162
|
+
class:cpk:hover:text-foreground={hasContent}
|
|
163
|
+
class:cpk:cursor-pointer={hasContent}
|
|
164
|
+
class:cpk:cursor-default={!hasContent}
|
|
165
|
+
aria-expanded={hasContent ? isOpen : undefined}
|
|
166
|
+
onclick={hasContent ? toggleOpen : undefined}
|
|
167
|
+
>
|
|
168
|
+
<span class="cpk:font-medium">{label}</span>
|
|
169
|
+
{#if isStreaming && !hasContent}
|
|
170
|
+
<span class="cpk:inline-flex cpk:items-center cpk:ml-1">
|
|
171
|
+
<span class="cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"></span>
|
|
172
|
+
</span>
|
|
173
|
+
{/if}
|
|
174
|
+
{#if hasContent}
|
|
175
|
+
<IconChevronRight
|
|
176
|
+
class={"cpk:size-3.5 cpk:shrink-0 cpk:transition-transform cpk:duration-200" + (isOpen ? " cpk:rotate-90" : "")}
|
|
177
|
+
/>
|
|
178
|
+
{/if}
|
|
179
|
+
</button>
|
|
180
|
+
{/if}
|
|
181
|
+
|
|
182
|
+
{#if toggle}
|
|
183
|
+
{@render toggle(toggleProps)}
|
|
184
|
+
{:else}
|
|
185
|
+
<div
|
|
186
|
+
class="cpk:grid cpk:transition-[grid-template-rows] cpk:duration-200 cpk:ease-in-out"
|
|
187
|
+
style="grid-template-rows: {isOpen ? '1fr' : '0fr'}"
|
|
188
|
+
>
|
|
189
|
+
<div class="cpk:overflow-hidden">
|
|
190
|
+
{#if contentView}
|
|
191
|
+
{@render contentView(contentViewProps)}
|
|
192
|
+
{:else}
|
|
193
|
+
{#if hasContent || isStreaming}
|
|
194
|
+
<div class="cpk:pb-2 cpk:pt-1">
|
|
195
|
+
<div class="cpk:text-sm cpk:text-muted-foreground">
|
|
196
|
+
<StreamMarkdown content={normalizedContent} />
|
|
197
|
+
{#if isStreaming && hasContent}
|
|
198
|
+
<span class="cpk:inline-flex cpk:items-center cpk:ml-1 cpk:align-middle">
|
|
199
|
+
<span class="cpk:w-2 cpk:h-2 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"></span>
|
|
200
|
+
</span>
|
|
201
|
+
{/if}
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
{/if}
|
|
205
|
+
{/if}
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
{/if}
|
|
209
|
+
{/if}
|
|
210
|
+
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Message, ReasoningMessage } from "@ag-ui/core";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
interface HeaderSlotProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
hasContent: boolean;
|
|
7
|
+
isStreaming: boolean;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
interface ContentViewSlotProps {
|
|
11
|
+
isStreaming: boolean;
|
|
12
|
+
hasContent: boolean;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
interface ToggleSlotProps {
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
contentView: ContentViewSlotProps;
|
|
18
|
+
}
|
|
19
|
+
interface LayoutSlotProps {
|
|
20
|
+
message: ReasoningMessage;
|
|
21
|
+
messages: Message[];
|
|
22
|
+
isRunning: boolean;
|
|
23
|
+
header: HeaderSlotProps;
|
|
24
|
+
contentView: ContentViewSlotProps;
|
|
25
|
+
toggle: ToggleSlotProps;
|
|
26
|
+
}
|
|
27
|
+
type $$ComponentProps = {
|
|
28
|
+
message: ReasoningMessage;
|
|
29
|
+
messages?: Message[];
|
|
30
|
+
isRunning?: boolean;
|
|
31
|
+
header?: Snippet<[HeaderSlotProps]>;
|
|
32
|
+
contentView?: Snippet<[ContentViewSlotProps]>;
|
|
33
|
+
toggle?: Snippet<[ToggleSlotProps]>;
|
|
34
|
+
layout?: Snippet<[LayoutSlotProps]>;
|
|
35
|
+
children?: Snippet<[]>;
|
|
36
|
+
};
|
|
37
|
+
declare const CopilotChatReasoningMessage: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
38
|
+
type CopilotChatReasoningMessage = ReturnType<typeof CopilotChatReasoningMessage>;
|
|
39
|
+
export default CopilotChatReasoningMessage;
|
|
40
|
+
//# sourceMappingURL=CopilotChatReasoningMessage.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotChatReasoningMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/chat/CopilotChatReasoningMessage.svelte"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAKtC,UAAU,eAAe;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,eAAe;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,oBAAoB,CAAC;CACnC;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,oBAAoB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB;AACF,KAAK,gBAAgB,GAAI;IACtB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;CACxB,CAAC;AAoKJ,QAAA,MAAM,2BAA2B,sDAAwC,CAAC;AAC1E,KAAK,2BAA2B,GAAG,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAClF,eAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Suggestion } from "@copilotkit/core";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
suggestion,
|
|
6
|
+
isLoading = false,
|
|
7
|
+
onSelect,
|
|
8
|
+
}: {
|
|
9
|
+
suggestion: Suggestion;
|
|
10
|
+
isLoading?: boolean;
|
|
11
|
+
onSelect: () => void;
|
|
12
|
+
} = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
class="copilotkit-suggestion-pill"
|
|
18
|
+
onclick={onSelect}
|
|
19
|
+
disabled={isLoading}
|
|
20
|
+
>
|
|
21
|
+
{#if isLoading}
|
|
22
|
+
<span class="copilotkit-spinner"></span>
|
|
23
|
+
{/if}
|
|
24
|
+
{suggestion.title}
|
|
25
|
+
</button>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.copilotkit-suggestion-pill {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 6px;
|
|
32
|
+
padding: 8px 14px;
|
|
33
|
+
border: 1px solid #d1d5db;
|
|
34
|
+
border-radius: 16px;
|
|
35
|
+
background: #fff;
|
|
36
|
+
font-size: 13px;
|
|
37
|
+
color: #374151;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
transition: all 0.15s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.copilotkit-suggestion-pill:hover:not(:disabled) {
|
|
44
|
+
border-color: #3b82f6;
|
|
45
|
+
color: #3b82f6;
|
|
46
|
+
background: #eff6ff;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.copilotkit-suggestion-pill:disabled {
|
|
50
|
+
opacity: 0.5;
|
|
51
|
+
cursor: not-allowed;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.copilotkit-spinner {
|
|
55
|
+
width: 12px;
|
|
56
|
+
height: 12px;
|
|
57
|
+
border: 2px solid #e5e7eb;
|
|
58
|
+
border-top-color: #3b82f6;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
animation: spin 0.6s linear infinite;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@keyframes spin {
|
|
64
|
+
to { transform: rotate(360deg); }
|
|
65
|
+
}
|
|
66
|
+
</style>
|