@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,232 @@
|
|
|
1
|
+
import { randomUUID, getModalityFromMimeType, exceedsMaxSize, readFileAsBase64, generateVideoThumbnail, matchesAcceptFilter, formatFileSize, } from "@copilotkit/shared";
|
|
2
|
+
function resolveInput(input) {
|
|
3
|
+
if (typeof input === "function") {
|
|
4
|
+
return input();
|
|
5
|
+
}
|
|
6
|
+
return input;
|
|
7
|
+
}
|
|
8
|
+
export function createAttachments(props) {
|
|
9
|
+
let attachments = $state([]);
|
|
10
|
+
let dragOver = $state(false);
|
|
11
|
+
let fileInputEl = $state(null);
|
|
12
|
+
let containerEl = $state(null);
|
|
13
|
+
let attachmentsRef = [];
|
|
14
|
+
const resolvedConfig = $derived(resolveInput(props.config));
|
|
15
|
+
const enabled = $derived(resolvedConfig?.enabled ?? false);
|
|
16
|
+
function setFileInputRef(el) {
|
|
17
|
+
fileInputEl = el;
|
|
18
|
+
}
|
|
19
|
+
function setContainerRef(el) {
|
|
20
|
+
containerEl = el;
|
|
21
|
+
}
|
|
22
|
+
function fileInputAction(node) {
|
|
23
|
+
fileInputEl = node;
|
|
24
|
+
return {
|
|
25
|
+
destroy() {
|
|
26
|
+
if (fileInputEl === node)
|
|
27
|
+
fileInputEl = null;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function containerAction(node) {
|
|
32
|
+
containerEl = node;
|
|
33
|
+
return {
|
|
34
|
+
destroy() {
|
|
35
|
+
if (containerEl === node)
|
|
36
|
+
containerEl = null;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const setAttachments = (next) => {
|
|
41
|
+
attachments = next;
|
|
42
|
+
attachmentsRef = next;
|
|
43
|
+
};
|
|
44
|
+
const updateAttachments = (updater) => {
|
|
45
|
+
setAttachments(updater(attachmentsRef));
|
|
46
|
+
};
|
|
47
|
+
async function processFiles(files) {
|
|
48
|
+
// Read the live config on every call so reactive getter updates apply
|
|
49
|
+
// to in-flight UI without re-creating the hook.
|
|
50
|
+
const config = resolveInput(props.config);
|
|
51
|
+
const accept = config?.accept ?? "*/*";
|
|
52
|
+
const maxSize = config?.maxSize ?? 20 * 1024 * 1024;
|
|
53
|
+
const rejectedFiles = files.filter((file) => !matchesAcceptFilter(file, accept));
|
|
54
|
+
for (const file of rejectedFiles) {
|
|
55
|
+
config?.onUploadFailed?.({
|
|
56
|
+
reason: "invalid-type",
|
|
57
|
+
file,
|
|
58
|
+
message: `File "${file.name}" is not accepted. Supported types: ${accept}`,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const validFiles = files.filter((file) => matchesAcceptFilter(file, accept));
|
|
62
|
+
for (const file of validFiles) {
|
|
63
|
+
if (exceedsMaxSize(file, maxSize)) {
|
|
64
|
+
config?.onUploadFailed?.({
|
|
65
|
+
reason: "file-too-large",
|
|
66
|
+
file,
|
|
67
|
+
message: `File "${file.name}" exceeds the maximum size of ${formatFileSize(maxSize)}`,
|
|
68
|
+
});
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const modality = getModalityFromMimeType(file.type);
|
|
72
|
+
const placeholderId = randomUUID();
|
|
73
|
+
updateAttachments((previous) => [
|
|
74
|
+
...previous,
|
|
75
|
+
{
|
|
76
|
+
id: placeholderId,
|
|
77
|
+
type: modality,
|
|
78
|
+
source: { type: "data", value: "", mimeType: file.type },
|
|
79
|
+
filename: file.name,
|
|
80
|
+
size: file.size,
|
|
81
|
+
status: "uploading",
|
|
82
|
+
},
|
|
83
|
+
]);
|
|
84
|
+
try {
|
|
85
|
+
let source;
|
|
86
|
+
let uploadMetadata;
|
|
87
|
+
if (config?.onUpload) {
|
|
88
|
+
const uploadResult = await config.onUpload(file);
|
|
89
|
+
const { metadata, ...uploadSource } = uploadResult;
|
|
90
|
+
source = uploadSource;
|
|
91
|
+
uploadMetadata = metadata;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const base64 = await readFileAsBase64(file);
|
|
95
|
+
source = { type: "data", value: base64, mimeType: file.type };
|
|
96
|
+
}
|
|
97
|
+
let thumbnail;
|
|
98
|
+
if (modality === "video") {
|
|
99
|
+
thumbnail = await generateVideoThumbnail(file);
|
|
100
|
+
}
|
|
101
|
+
updateAttachments((previous) => previous.map((attachment) => attachment.id === placeholderId
|
|
102
|
+
? {
|
|
103
|
+
...attachment,
|
|
104
|
+
source,
|
|
105
|
+
status: "ready",
|
|
106
|
+
thumbnail,
|
|
107
|
+
metadata: uploadMetadata,
|
|
108
|
+
}
|
|
109
|
+
: attachment));
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
updateAttachments((previous) => previous.filter((a) => a.id !== placeholderId));
|
|
113
|
+
console.error(`[CopilotKit] Failed to upload "${file.name}":`, error);
|
|
114
|
+
config?.onUploadFailed?.({
|
|
115
|
+
reason: "upload-failed",
|
|
116
|
+
file,
|
|
117
|
+
message: error instanceof Error
|
|
118
|
+
? error.message
|
|
119
|
+
: `Failed to upload "${file.name}"`,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function handleFileUpload(event) {
|
|
125
|
+
const target = event.target;
|
|
126
|
+
if (!target?.files?.length)
|
|
127
|
+
return;
|
|
128
|
+
await processFiles(Array.from(target.files));
|
|
129
|
+
if (target)
|
|
130
|
+
target.value = "";
|
|
131
|
+
}
|
|
132
|
+
function handleDragOver(event) {
|
|
133
|
+
if (!enabled)
|
|
134
|
+
return;
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
event.stopPropagation();
|
|
137
|
+
dragOver = true;
|
|
138
|
+
}
|
|
139
|
+
function handleDragLeave(event) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
event.stopPropagation();
|
|
142
|
+
dragOver = false;
|
|
143
|
+
}
|
|
144
|
+
async function handleDrop(event) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
event.stopPropagation();
|
|
147
|
+
dragOver = false;
|
|
148
|
+
if (!enabled)
|
|
149
|
+
return;
|
|
150
|
+
const files = Array.from(event.dataTransfer?.files ?? []);
|
|
151
|
+
if (files.length > 0) {
|
|
152
|
+
await processFiles(files);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function removeAttachment(id) {
|
|
156
|
+
updateAttachments((previous) => previous.filter((attachment) => attachment.id !== id));
|
|
157
|
+
}
|
|
158
|
+
function consumeAttachments() {
|
|
159
|
+
const ready = attachmentsRef.filter((attachment) => attachment.status === "ready");
|
|
160
|
+
if (ready.length === 0)
|
|
161
|
+
return ready;
|
|
162
|
+
updateAttachments((previous) => previous.filter((attachment) => attachment.status !== "ready"));
|
|
163
|
+
if (fileInputEl) {
|
|
164
|
+
fileInputEl.value = "";
|
|
165
|
+
}
|
|
166
|
+
return ready;
|
|
167
|
+
}
|
|
168
|
+
async function handlePaste(event) {
|
|
169
|
+
const liveConfig = resolveInput(props.config);
|
|
170
|
+
if (!(liveConfig?.enabled ?? false))
|
|
171
|
+
return;
|
|
172
|
+
const target = event.target;
|
|
173
|
+
const scope = containerEl;
|
|
174
|
+
// Paste is scoped to the composer/container: ignore pastes outside it so
|
|
175
|
+
// unrelated page pastes never enqueue uploads.
|
|
176
|
+
if (!target || !scope?.contains(target))
|
|
177
|
+
return;
|
|
178
|
+
const accept = liveConfig?.accept ?? "*/*";
|
|
179
|
+
const items = Array.from(event.clipboardData?.items ?? []);
|
|
180
|
+
const fileItems = items.filter((item) => {
|
|
181
|
+
if (item.kind !== "file")
|
|
182
|
+
return false;
|
|
183
|
+
const file = item.getAsFile();
|
|
184
|
+
return file !== null && matchesAcceptFilter(file, accept);
|
|
185
|
+
});
|
|
186
|
+
if (fileItems.length === 0)
|
|
187
|
+
return;
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
const files = fileItems
|
|
190
|
+
.map((item) => item.getAsFile())
|
|
191
|
+
.filter((file) => file !== null);
|
|
192
|
+
await processFiles(files);
|
|
193
|
+
}
|
|
194
|
+
$effect(() => {
|
|
195
|
+
if (typeof document === "undefined")
|
|
196
|
+
return;
|
|
197
|
+
// Always attached; enabled + container scoping is checked at event time
|
|
198
|
+
// so reactive config updates apply without re-subscribing.
|
|
199
|
+
document.addEventListener("paste", handlePaste);
|
|
200
|
+
return () => {
|
|
201
|
+
document.removeEventListener("paste", handlePaste);
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
get attachments() {
|
|
206
|
+
return attachments;
|
|
207
|
+
},
|
|
208
|
+
get enabled() {
|
|
209
|
+
return enabled;
|
|
210
|
+
},
|
|
211
|
+
get dragOver() {
|
|
212
|
+
return dragOver;
|
|
213
|
+
},
|
|
214
|
+
get fileInputRef() {
|
|
215
|
+
return fileInputEl;
|
|
216
|
+
},
|
|
217
|
+
get containerRef() {
|
|
218
|
+
return containerEl;
|
|
219
|
+
},
|
|
220
|
+
setFileInputRef,
|
|
221
|
+
setContainerRef,
|
|
222
|
+
fileInputAction,
|
|
223
|
+
containerAction,
|
|
224
|
+
processFiles,
|
|
225
|
+
handleFileUpload,
|
|
226
|
+
handleDragOver,
|
|
227
|
+
handleDragLeave,
|
|
228
|
+
handleDrop,
|
|
229
|
+
removeAttachment,
|
|
230
|
+
consumeAttachments,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentCapabilities } from "@ag-ui/core";
|
|
2
|
+
export interface CreateCapabilitiesResult {
|
|
3
|
+
capabilities: AgentCapabilities | undefined;
|
|
4
|
+
}
|
|
5
|
+
export declare function createCapabilities(agentId?: string | (() => string | undefined)): CreateCapabilitiesResult;
|
|
6
|
+
//# sourceMappingURL=create-capabilities.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-capabilities.svelte.d.ts","sourceRoot":"","sources":["../../src/hooks/create-capabilities.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC7C;AAED,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAC5C,wBAAwB,CAgB1B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createAgent } from "./create-agent.svelte";
|
|
2
|
+
export function createCapabilities(agentId) {
|
|
3
|
+
const agentHandle = createAgent({
|
|
4
|
+
get agentId() {
|
|
5
|
+
return typeof agentId === "function" ? agentId() : agentId;
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
return {
|
|
9
|
+
get capabilities() {
|
|
10
|
+
const a = agentHandle.agent;
|
|
11
|
+
if (a && "capabilities" in a) {
|
|
12
|
+
return a.capabilities;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Interrupt } from "@ag-ui/client";
|
|
2
|
+
import type { InterruptEvent, InterruptHandlerProps, InterruptRenderProps, InterruptResolveFn, InterruptCancelFn } from "../types/interrupt";
|
|
3
|
+
export type { InterruptEvent, InterruptHandlerProps, InterruptRenderProps, Interrupt, };
|
|
4
|
+
type InterruptHandlerFn<TValue, TResult> = (props: InterruptHandlerProps<TValue>) => TResult | PromiseLike<TResult>;
|
|
5
|
+
type InterruptResultFromHandler<THandler> = THandler extends (...args: never[]) => infer TResult ? TResult extends PromiseLike<infer TResolved> ? TResolved | null : TResult | null : null;
|
|
6
|
+
type InterruptResult<TValue, TResult> = InterruptResultFromHandler<InterruptHandlerFn<TValue, TResult>>;
|
|
7
|
+
export interface CreateInterruptConfig<TValue = unknown, TResult = never> {
|
|
8
|
+
handler?: InterruptHandlerFn<TValue, TResult>;
|
|
9
|
+
enabled?: (event: InterruptEvent<TValue>) => boolean;
|
|
10
|
+
agentId?: string | (() => string | undefined);
|
|
11
|
+
renderInChat?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateInterruptResult<TValue = unknown, TResult = never> {
|
|
14
|
+
interrupt: InterruptEvent<TValue> | null;
|
|
15
|
+
result: InterruptResult<TValue, TResult>;
|
|
16
|
+
hasInterrupt: boolean;
|
|
17
|
+
resolve: InterruptResolveFn;
|
|
18
|
+
resolveInterrupt: InterruptResolveFn;
|
|
19
|
+
cancel: InterruptCancelFn;
|
|
20
|
+
cancelInterrupt: InterruptCancelFn;
|
|
21
|
+
slotProps: InterruptRenderProps<TValue, InterruptResult<TValue, TResult>> | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function createInterrupt<TValue = unknown, TResult = never>(config?: CreateInterruptConfig<TValue, TResult>): CreateInterruptResult<TValue, TResult>;
|
|
24
|
+
//# sourceMappingURL=create-interrupt.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-interrupt.svelte.d.ts","sourceRoot":"","sources":["../../src/hooks/create-interrupt.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,eAAe,CAAC;AAI/D,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,SAAS,GACV,CAAC;AAsBF,KAAK,kBAAkB,CAAC,MAAM,EAAE,OAAO,IAAI,CACzC,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC,KACjC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAEpC,KAAK,0BAA0B,CAAC,QAAQ,IAAI,QAAQ,SAAS,CAC3D,GAAG,IAAI,EAAE,KAAK,EAAE,KACb,MAAM,OAAO,GACd,OAAO,SAAS,WAAW,CAAC,MAAM,SAAS,CAAC,GAC1C,SAAS,GAAG,IAAI,GAChB,OAAO,GAAG,IAAI,GAChB,IAAI,CAAC;AAET,KAAK,eAAe,CAAC,MAAM,EAAE,OAAO,IAAI,0BAA0B,CAChE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CACpC,CAAC;AAEF,MAAM,WAAW,qBAAqB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,KAAK;IACtE,OAAO,CAAC,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,KAAK;IACtE,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACzC,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,gBAAgB,EAAE,kBAAkB,CAAC;IACrC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,eAAe,EAAE,iBAAiB,CAAC;IACnC,SAAS,EAAE,oBAAoB,CAC7B,MAAM,EACN,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CACjC,GAAG,IAAI,CAAC;CACV;AA8BD,wBAAgB,eAAe,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,KAAK,EAC/D,MAAM,GAAE,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAM,GAClD,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAqWxC"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { getContext, untrack } from "svelte";
|
|
2
|
+
import { buildResumeArray, isInterruptExpired } from "@ag-ui/client";
|
|
3
|
+
import { COPILOT_KIT_KEY } from "../providers/context";
|
|
4
|
+
import { createAgent } from "./create-agent.svelte";
|
|
5
|
+
const INTERRUPT_EVENT_NAME = "on_interrupt";
|
|
6
|
+
function isPromiseLike(value) {
|
|
7
|
+
return ((typeof value === "object" || typeof value === "function") &&
|
|
8
|
+
value !== null &&
|
|
9
|
+
typeof Reflect.get(value, "then") === "function");
|
|
10
|
+
}
|
|
11
|
+
function normalizeAsyncResult(value) {
|
|
12
|
+
if (value instanceof Promise)
|
|
13
|
+
return value;
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
try {
|
|
16
|
+
value.then(resolve, reject);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
reject(error);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function toLegacyEvent(pending) {
|
|
24
|
+
if (pending.kind === "legacy")
|
|
25
|
+
return pending.event;
|
|
26
|
+
return { name: INTERRUPT_EVENT_NAME, value: pending.interrupts[0] };
|
|
27
|
+
}
|
|
28
|
+
export function createInterrupt(config = {}) {
|
|
29
|
+
const context = getContext(COPILOT_KIT_KEY);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("createInterrupt must be used within CopilotKitProvider");
|
|
32
|
+
}
|
|
33
|
+
const agentHandle = createAgent({
|
|
34
|
+
get agentId() {
|
|
35
|
+
return typeof config.agentId === "function"
|
|
36
|
+
? config.agentId()
|
|
37
|
+
: config.agentId;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
let pending = $state.raw(null);
|
|
41
|
+
let result = $state(null);
|
|
42
|
+
const responses = {};
|
|
43
|
+
let pendingAgentVersion = null;
|
|
44
|
+
function clearResponses() {
|
|
45
|
+
for (const key of Object.keys(responses))
|
|
46
|
+
delete responses[key];
|
|
47
|
+
}
|
|
48
|
+
$effect(() => {
|
|
49
|
+
const ownerVersion = agentHandle.agentInstanceVersion;
|
|
50
|
+
const resolvedAgent = untrack(() => agentHandle.agent);
|
|
51
|
+
if (pendingAgentVersion !== ownerVersion) {
|
|
52
|
+
pending = null;
|
|
53
|
+
result = null;
|
|
54
|
+
clearResponses();
|
|
55
|
+
pendingAgentVersion = ownerVersion;
|
|
56
|
+
}
|
|
57
|
+
if (!resolvedAgent) {
|
|
58
|
+
pending = null;
|
|
59
|
+
result = null;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let localLegacy = null;
|
|
63
|
+
let localStandard = null;
|
|
64
|
+
const subscription = resolvedAgent.subscribe({
|
|
65
|
+
onCustomEvent: ({ event }) => {
|
|
66
|
+
if (agentHandle.agentInstanceVersion !== ownerVersion)
|
|
67
|
+
return;
|
|
68
|
+
if (event.name === INTERRUPT_EVENT_NAME) {
|
|
69
|
+
localLegacy = {
|
|
70
|
+
name: event.name,
|
|
71
|
+
value: event.value,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onRunFinishedEvent: (params) => {
|
|
76
|
+
if (agentHandle.agentInstanceVersion !== ownerVersion)
|
|
77
|
+
return;
|
|
78
|
+
if (params.outcome === "interrupt") {
|
|
79
|
+
localStandard = params.interrupts;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
onRunStartedEvent: () => {
|
|
83
|
+
if (agentHandle.agentInstanceVersion !== ownerVersion)
|
|
84
|
+
return;
|
|
85
|
+
localLegacy = null;
|
|
86
|
+
localStandard = null;
|
|
87
|
+
clearResponses();
|
|
88
|
+
if (pending?.ownerVersion === ownerVersion)
|
|
89
|
+
pending = null;
|
|
90
|
+
},
|
|
91
|
+
onRunFinalized: () => {
|
|
92
|
+
if (agentHandle.agentInstanceVersion !== ownerVersion)
|
|
93
|
+
return;
|
|
94
|
+
if (localStandard && localStandard.length > 0) {
|
|
95
|
+
pending = {
|
|
96
|
+
kind: "standard",
|
|
97
|
+
interrupts: localStandard,
|
|
98
|
+
owner: resolvedAgent,
|
|
99
|
+
ownerVersion,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
else if (localLegacy) {
|
|
103
|
+
pending = {
|
|
104
|
+
kind: "legacy",
|
|
105
|
+
event: localLegacy,
|
|
106
|
+
owner: resolvedAgent,
|
|
107
|
+
ownerVersion,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
localLegacy = null;
|
|
111
|
+
localStandard = null;
|
|
112
|
+
},
|
|
113
|
+
onRunFailed: () => {
|
|
114
|
+
if (agentHandle.agentInstanceVersion !== ownerVersion)
|
|
115
|
+
return;
|
|
116
|
+
localLegacy = null;
|
|
117
|
+
localStandard = null;
|
|
118
|
+
clearResponses();
|
|
119
|
+
if (pending?.ownerVersion === ownerVersion)
|
|
120
|
+
pending = null;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
return () => subscription.unsubscribe();
|
|
124
|
+
});
|
|
125
|
+
const submitStandardIfComplete = async (interrupts, owner, ownerVersion) => {
|
|
126
|
+
if (pending?.ownerVersion !== ownerVersion ||
|
|
127
|
+
agentHandle.agentInstanceVersion !== ownerVersion) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const allAddressed = interrupts.every((i) => responses[i.id]);
|
|
131
|
+
if (!allAddressed)
|
|
132
|
+
return;
|
|
133
|
+
const expired = interrupts.find((i) => isInterruptExpired(i));
|
|
134
|
+
if (expired) {
|
|
135
|
+
console.error(`[CopilotKit] createInterrupt: interrupt ${expired.id} expired at ${expired.expiresAt}; not resuming.`);
|
|
136
|
+
clearResponses();
|
|
137
|
+
if (pending?.ownerVersion === ownerVersion)
|
|
138
|
+
pending = null;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const resume = buildResumeArray(interrupts, responses);
|
|
142
|
+
clearResponses();
|
|
143
|
+
if (agentHandle.agentInstanceVersion !== ownerVersion)
|
|
144
|
+
return;
|
|
145
|
+
try {
|
|
146
|
+
return await context.copilotkit.runAgent({
|
|
147
|
+
agent: owner,
|
|
148
|
+
resume,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
console.error("[CopilotKit] createInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
153
|
+
if (pending?.ownerVersion === ownerVersion)
|
|
154
|
+
pending = null;
|
|
155
|
+
throw err;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const resolve = async (payload, interruptId) => {
|
|
159
|
+
const current = pending;
|
|
160
|
+
if (!current)
|
|
161
|
+
return;
|
|
162
|
+
if (agentHandle.agentInstanceVersion !== current.ownerVersion)
|
|
163
|
+
return;
|
|
164
|
+
if (current.kind === "legacy") {
|
|
165
|
+
try {
|
|
166
|
+
return await context.copilotkit.runAgent({
|
|
167
|
+
agent: current.owner,
|
|
168
|
+
forwardedProps: {
|
|
169
|
+
command: {
|
|
170
|
+
resume: payload,
|
|
171
|
+
interruptEvent: current.event.value,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
console.error("[CopilotKit] createInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
178
|
+
if (pending?.ownerVersion === current.ownerVersion)
|
|
179
|
+
pending = null;
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (current.interrupts.length > 1 && interruptId === undefined) {
|
|
184
|
+
console.warn(`[CopilotKit] createInterrupt: resolve() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first.`);
|
|
185
|
+
}
|
|
186
|
+
const id = interruptId ?? current.interrupts[0]?.id;
|
|
187
|
+
if (!id)
|
|
188
|
+
return;
|
|
189
|
+
responses[id] = { status: "resolved", payload };
|
|
190
|
+
return submitStandardIfComplete(current.interrupts, current.owner, current.ownerVersion);
|
|
191
|
+
};
|
|
192
|
+
const cancel = async (interruptId) => {
|
|
193
|
+
const current = pending;
|
|
194
|
+
if (!current)
|
|
195
|
+
return;
|
|
196
|
+
if (agentHandle.agentInstanceVersion !== current.ownerVersion)
|
|
197
|
+
return;
|
|
198
|
+
if (current.kind === "legacy") {
|
|
199
|
+
console.warn("[CopilotKit] createInterrupt: cancel() is not supported for legacy on_interrupt interrupts; dismissing.");
|
|
200
|
+
pending = null;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (current.interrupts.length > 1 && interruptId === undefined) {
|
|
204
|
+
console.warn(`[CopilotKit] createInterrupt: cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first.`);
|
|
205
|
+
}
|
|
206
|
+
const id = interruptId ?? current.interrupts[0]?.id;
|
|
207
|
+
if (!id)
|
|
208
|
+
return;
|
|
209
|
+
responses[id] = { status: "cancelled" };
|
|
210
|
+
return submitStandardIfComplete(current.interrupts, current.owner, current.ownerVersion);
|
|
211
|
+
};
|
|
212
|
+
const resolveInterrupt = resolve;
|
|
213
|
+
const cancelInterrupt = cancel;
|
|
214
|
+
$effect(() => {
|
|
215
|
+
const currentPending = pending;
|
|
216
|
+
if (!currentPending) {
|
|
217
|
+
result = null;
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const legacyEvent = toLegacyEvent(currentPending);
|
|
221
|
+
if (config.enabled && !config.enabled(legacyEvent)) {
|
|
222
|
+
result = null;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const handler = config.handler;
|
|
226
|
+
if (!handler) {
|
|
227
|
+
result = null;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
let cancelled = false;
|
|
231
|
+
const ownerVersion = currentPending.ownerVersion;
|
|
232
|
+
const maybePromise = handler({
|
|
233
|
+
event: legacyEvent,
|
|
234
|
+
interrupt: currentPending.kind === "standard"
|
|
235
|
+
? (currentPending.interrupts[0] ?? null)
|
|
236
|
+
: null,
|
|
237
|
+
interrupts: currentPending.kind === "standard" ? currentPending.interrupts : [],
|
|
238
|
+
resolve,
|
|
239
|
+
cancel,
|
|
240
|
+
});
|
|
241
|
+
if (isPromiseLike(maybePromise)) {
|
|
242
|
+
normalizeAsyncResult(maybePromise)
|
|
243
|
+
.then((resolved) => {
|
|
244
|
+
if (!cancelled &&
|
|
245
|
+
agentHandle.agentInstanceVersion === ownerVersion &&
|
|
246
|
+
pending?.ownerVersion === ownerVersion) {
|
|
247
|
+
result = resolved;
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
.catch((err) => {
|
|
251
|
+
if (!cancelled &&
|
|
252
|
+
agentHandle.agentInstanceVersion === ownerVersion &&
|
|
253
|
+
pending?.ownerVersion === ownerVersion) {
|
|
254
|
+
console.error("[CopilotKit] createInterrupt handler failed:", err);
|
|
255
|
+
result = null;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
result = maybePromise;
|
|
261
|
+
}
|
|
262
|
+
return () => {
|
|
263
|
+
cancelled = true;
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
$effect(() => {
|
|
267
|
+
const core = context.copilotkit;
|
|
268
|
+
const currentPending = pending;
|
|
269
|
+
if (!currentPending) {
|
|
270
|
+
core.setInterruptState(null);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const legacyEvent = toLegacyEvent(currentPending);
|
|
274
|
+
if (config.enabled && !config.enabled(legacyEvent)) {
|
|
275
|
+
core.setInterruptState(null);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const slotProps = {
|
|
279
|
+
event: legacyEvent,
|
|
280
|
+
interrupt: currentPending.kind === "standard"
|
|
281
|
+
? (currentPending.interrupts[0] ?? null)
|
|
282
|
+
: null,
|
|
283
|
+
interrupts: currentPending.kind === "standard" ? currentPending.interrupts : [],
|
|
284
|
+
result: result,
|
|
285
|
+
resolve,
|
|
286
|
+
cancel,
|
|
287
|
+
};
|
|
288
|
+
core.setInterruptState(slotProps);
|
|
289
|
+
return () => {
|
|
290
|
+
if (core.interruptState === slotProps) {
|
|
291
|
+
core.setInterruptState(null);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
const interrupt = $derived(pending ? toLegacyEvent(pending) : null);
|
|
296
|
+
const hasInterrupt = $derived(pending !== null);
|
|
297
|
+
const slotProps = $derived.by(() => {
|
|
298
|
+
const currentPending = pending;
|
|
299
|
+
if (!currentPending)
|
|
300
|
+
return null;
|
|
301
|
+
const legacyEvent = toLegacyEvent(currentPending);
|
|
302
|
+
if (config.enabled && !config.enabled(legacyEvent))
|
|
303
|
+
return null;
|
|
304
|
+
return {
|
|
305
|
+
event: legacyEvent,
|
|
306
|
+
interrupt: currentPending.kind === "standard"
|
|
307
|
+
? (currentPending.interrupts[0] ?? null)
|
|
308
|
+
: null,
|
|
309
|
+
interrupts: currentPending.kind === "standard" ? currentPending.interrupts : [],
|
|
310
|
+
result: result,
|
|
311
|
+
resolve,
|
|
312
|
+
cancel,
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
return {
|
|
316
|
+
get interrupt() {
|
|
317
|
+
return interrupt;
|
|
318
|
+
},
|
|
319
|
+
get result() {
|
|
320
|
+
return result;
|
|
321
|
+
},
|
|
322
|
+
get hasInterrupt() {
|
|
323
|
+
return hasInterrupt;
|
|
324
|
+
},
|
|
325
|
+
resolve,
|
|
326
|
+
resolveInterrupt,
|
|
327
|
+
cancel,
|
|
328
|
+
cancelInterrupt,
|
|
329
|
+
get slotProps() {
|
|
330
|
+
return slotProps;
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Suggestion } from "@copilotkit/core";
|
|
2
|
+
export interface CreateSuggestionsOptions {
|
|
3
|
+
agentId?: string | (() => string | undefined);
|
|
4
|
+
}
|
|
5
|
+
export interface CreateSuggestionsResult {
|
|
6
|
+
suggestions: Suggestion[];
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
reloadSuggestions: () => void;
|
|
9
|
+
clearSuggestions: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createSuggestions(options?: CreateSuggestionsOptions): CreateSuggestionsResult;
|
|
12
|
+
//# sourceMappingURL=create-suggestions.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-suggestions.svelte.d.ts","sourceRoot":"","sources":["../../src/hooks/create-suggestions.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CAgEzB"}
|