@copilotkit/svelte 0.1.0 → 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/{src → dist}/components/chat/CopilotChat.svelte +26 -1
- package/dist/components/chat/CopilotChat.svelte.d.ts +5 -1
- package/dist/components/chat/CopilotChat.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts +80 -1
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts +9 -1
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatInput.svelte.d.ts +20 -1
- package/dist/components/chat/CopilotChatInput.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts +10 -1
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts +14 -1
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts +40 -1
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts +10 -1
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts +10 -1
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts +8 -1
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts +12 -1
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts +62 -1
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatView.svelte.d.ts +32 -1
- package/dist/components/chat/CopilotChatView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotPopup.svelte.d.ts +5 -1
- package/dist/components/chat/CopilotPopup.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotSidebar.svelte.d.ts +5 -1
- package/dist/components/chat/CopilotSidebar.svelte.d.ts.map +1 -0
- package/dist/components/chat/StreamMarkdown.svelte.d.ts +7 -1
- package/dist/components/chat/StreamMarkdown.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 +1 -1
- package/dist/components/chat/dispatch-after-active-run.js +31 -0
- package/dist/components/chat/markdown/CodeBlock.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/CodeBlock.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts +9 -1
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/Table.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/Table.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableBody.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/TableBody.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableCell.svelte.d.ts +10 -1
- package/dist/components/chat/markdown/TableCell.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableHead.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/TableHead.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableRow.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/TableRow.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/highlight.js +91 -0
- package/dist/components/chat/media-parts.d.ts +2 -2
- package/dist/components/chat/media-parts.js +17 -0
- package/dist/components/chat/types.d.ts +5 -3
- package/dist/components/chat/types.js +7 -0
- package/dist/components/icons/index.d.ts +1 -1
- package/dist/components/icons/index.js +1 -0
- package/dist/components/index.d.ts +17 -17
- package/dist/hooks/connect-agent-context.svelte.js +25 -0
- package/dist/hooks/create-agent.svelte.d.ts +3 -3
- package/dist/hooks/create-agent.svelte.js +341 -0
- package/dist/hooks/create-attachments.svelte.d.ts +1 -1
- package/dist/hooks/create-attachments.svelte.js +232 -0
- package/dist/hooks/create-capabilities.svelte.d.ts +1 -1
- package/dist/hooks/create-capabilities.svelte.js +17 -0
- package/dist/hooks/create-interrupt.svelte.d.ts +2 -2
- package/dist/hooks/create-interrupt.svelte.js +333 -0
- package/dist/hooks/create-suggestions.svelte.d.ts +1 -1
- package/dist/hooks/create-suggestions.svelte.js +61 -0
- package/dist/hooks/create-threads.svelte.js +230 -0
- package/dist/hooks/index.d.ts +19 -19
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/load-katex-styles.svelte.js +11 -0
- package/dist/hooks/register-frontend-tool.svelte.d.ts +1 -1
- package/dist/hooks/register-frontend-tool.svelte.js +32 -0
- package/dist/hooks/register-human-in-the-loop.svelte.d.ts +1 -1
- package/dist/hooks/register-human-in-the-loop.svelte.js +84 -0
- package/dist/hooks/register-render-tool-call.svelte.d.ts +1 -1
- package/dist/hooks/register-render-tool-call.svelte.js +26 -0
- package/dist/index.d.ts +5 -5
- package/dist/lib/svelte-core.d.ts +4 -3
- package/dist/lib/svelte-core.js +145 -0
- package/dist/providers/CopilotKitProvider.svelte.d.ts +9 -1
- package/dist/providers/CopilotKitProvider.svelte.d.ts.map +1 -0
- package/dist/providers/CopilotKitProvider.types.d.ts +4 -4
- package/dist/providers/CopilotKitProvider.types.js +1 -0
- package/dist/providers/context.d.ts +3 -3
- package/dist/providers/context.js +2 -0
- package/dist/providers/index.d.ts +5 -5
- package/dist/providers/index.js +2 -0
- package/dist/providers/useCopilotKit.d.ts +1 -1
- package/dist/providers/useCopilotKit.js +9 -0
- package/dist/styles.css +1 -2
- package/dist/types/a2ui.js +1 -0
- package/dist/types/activity-message-renderer.d.ts +3 -3
- package/dist/types/activity-message-renderer.js +1 -0
- package/dist/types/custom-message-renderer.d.ts +1 -1
- package/dist/types/custom-message-renderer.js +1 -0
- package/dist/types/frontend-tool.d.ts +2 -2
- package/dist/types/frontend-tool.js +1 -0
- package/dist/types/human-in-the-loop.d.ts +1 -1
- package/dist/types/human-in-the-loop.js +1 -0
- package/dist/types/index.d.ts +8 -8
- package/dist/types/interrupt.d.ts +1 -1
- package/dist/types/interrupt.js +1 -0
- package/dist/types/sandbox-function.d.ts +1 -1
- package/dist/types/sandbox-function.js +1 -0
- package/dist/types/tool-call-renderer.d.ts +2 -2
- package/dist/types/tool-call-renderer.js +1 -0
- package/package.json +14 -22
- package/dist/components/chat/CopilotChat.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatAssistantMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatAttachmentQueue.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatInput.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatMessageView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatReasoningMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatSuggestionPill.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatToggleButton.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatToolCallsView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatUserMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotPopup.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotSidebar.d.svelte.ts +0 -1
- package/dist/components/chat/StreamMarkdown.d.svelte.ts +0 -1
- package/dist/components/chat/chat-config-context.d.svelte.ts +0 -10
- package/dist/index.cjs +0 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -6
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -3037
- package/dist/index.mjs.map +0 -1
- package/src/components/chat/chat-config-context.svelte.ts +0 -28
- package/src/components/chat/dispatch-after-active-run.ts +0 -40
- package/src/components/chat/markdown/highlight.ts +0 -96
- package/src/components/chat/media-parts.ts +0 -34
- package/src/components/chat/types.ts +0 -176
- package/src/components/icons/index.ts +0 -23
- package/src/hooks/connect-agent-context.svelte.ts +0 -46
- package/src/hooks/create-agent.svelte.ts +0 -420
- package/src/hooks/create-attachments.svelte.ts +0 -311
- package/src/hooks/create-capabilities.svelte.ts +0 -26
- package/src/hooks/create-interrupt.svelte.ts +0 -467
- package/src/hooks/create-suggestions.svelte.ts +0 -84
- package/src/hooks/create-threads.svelte.ts +0 -337
- package/src/hooks/index.ts +0 -45
- package/src/hooks/load-katex-styles.svelte.ts +0 -13
- package/src/hooks/register-frontend-tool.svelte.ts +0 -45
- package/src/hooks/register-human-in-the-loop.svelte.ts +0 -118
- package/src/hooks/register-render-tool-call.svelte.ts +0 -75
- package/src/lib/svelte-core.ts +0 -230
- package/src/providers/CopilotKitProvider.types.ts +0 -55
- package/src/providers/context.ts +0 -26
- package/src/providers/index.ts +0 -5
- package/src/providers/useCopilotKit.ts +0 -11
- package/src/types/a2ui.ts +0 -5
- package/src/types/activity-message-renderer.ts +0 -21
- package/src/types/custom-message-renderer.ts +0 -23
- package/src/types/frontend-tool.ts +0 -8
- package/src/types/human-in-the-loop.ts +0 -40
- package/src/types/interrupt.ts +0 -32
- package/src/types/sandbox-function.ts +0 -8
- package/src/types/tool-call-renderer.ts +0 -36
- /package/{src → dist}/app.d.ts +0 -0
- /package/{src → dist}/components/chat/CopilotChatAssistantMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatAttachmentQueue.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatInput.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatMessageView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatReasoningMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatSuggestionPill.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatSuggestionView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatToggleButton.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatToolCallsView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatUserMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotPopup.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotSidebar.svelte +0 -0
- /package/{src → dist}/components/chat/StreamMarkdown.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/CodeBlock.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/CodeSpan.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/Table.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableBody.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableCell.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableHead.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableRow.svelte +0 -0
- /package/{src/components/index.ts → dist/components/index.js} +0 -0
- /package/{src/index.ts → dist/index.js} +0 -0
- /package/{src → dist}/providers/CopilotKitProvider.svelte +0 -0
- /package/{src → dist}/styles/globals.css +0 -0
- /package/{src → dist}/styles.d.ts +0 -0
- /package/{src/types/index.ts → dist/types/index.js} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { getContext } from "svelte";
|
|
2
|
+
import { CopilotKitCoreRuntimeConnectionStatus, ɵcreateThreadStore, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectFetchMoreError, ɵselectThreadsIsLoading, } from "@copilotkit/core";
|
|
3
|
+
import { COPILOT_KIT_KEY } from "../providers/context";
|
|
4
|
+
export function createThreads(input) {
|
|
5
|
+
const context = getContext(COPILOT_KIT_KEY);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("createThreads must be used within CopilotKitProvider");
|
|
8
|
+
}
|
|
9
|
+
// The core object is kept for operations (register/unregister) and the
|
|
10
|
+
// instrumented transport. All reactive runtime state below is read through
|
|
11
|
+
// the provider getters (context.runtimeUrl, context.headers, ...), never
|
|
12
|
+
// through the non-reactive fields on the core object — mirroring
|
|
13
|
+
// react-core's useThreads, which reads useCopilotKit() state.
|
|
14
|
+
const core = context.copilotkit;
|
|
15
|
+
const store = ɵcreateThreadStore({
|
|
16
|
+
fetch: core.ɵruntimeFetch,
|
|
17
|
+
});
|
|
18
|
+
let threads = $state([]);
|
|
19
|
+
let storeIsLoading = $state(false);
|
|
20
|
+
let storeError = $state(null);
|
|
21
|
+
let fetchMoreError = $state(null);
|
|
22
|
+
let hasMoreThreads = $state(false);
|
|
23
|
+
let isFetchingMoreThreads = $state(false);
|
|
24
|
+
let isMutating = $state(false);
|
|
25
|
+
let hasDispatchedContext = $state(false);
|
|
26
|
+
function bindSelector(selector) {
|
|
27
|
+
const val = selector(store.getState());
|
|
28
|
+
const subscription = store.select(selector).subscribe((next) => {
|
|
29
|
+
if (selector === ɵselectThreads)
|
|
30
|
+
threads = next;
|
|
31
|
+
else if (selector === ɵselectThreadsIsLoading)
|
|
32
|
+
storeIsLoading = next;
|
|
33
|
+
else if (selector === ɵselectThreadsError)
|
|
34
|
+
storeError = next;
|
|
35
|
+
else if (selector === ɵselectFetchMoreError)
|
|
36
|
+
fetchMoreError = next;
|
|
37
|
+
else if (selector === ɵselectHasNextPage)
|
|
38
|
+
hasMoreThreads = next;
|
|
39
|
+
else if (selector === ɵselectIsFetchingNextPage)
|
|
40
|
+
isFetchingMoreThreads = next;
|
|
41
|
+
else if (selector === ɵselectIsMutating)
|
|
42
|
+
isMutating = next;
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
initialValue: val,
|
|
46
|
+
unsubscribe: () => subscription.unsubscribe(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
$effect(() => {
|
|
50
|
+
const threadsBinding = bindSelector(ɵselectThreads);
|
|
51
|
+
const storeIsLoadingBinding = bindSelector(ɵselectThreadsIsLoading);
|
|
52
|
+
const storeErrorBinding = bindSelector(ɵselectThreadsError);
|
|
53
|
+
const fetchMoreErrorBinding = bindSelector(ɵselectFetchMoreError);
|
|
54
|
+
const hasMoreThreadsBinding = bindSelector(ɵselectHasNextPage);
|
|
55
|
+
const isFetchingMoreThreadsBinding = bindSelector(ɵselectIsFetchingNextPage);
|
|
56
|
+
const isMutatingBinding = bindSelector(ɵselectIsMutating);
|
|
57
|
+
threads = threadsBinding.initialValue;
|
|
58
|
+
storeIsLoading = storeIsLoadingBinding.initialValue;
|
|
59
|
+
storeError = storeErrorBinding.initialValue;
|
|
60
|
+
fetchMoreError = fetchMoreErrorBinding.initialValue;
|
|
61
|
+
hasMoreThreads = hasMoreThreadsBinding.initialValue;
|
|
62
|
+
isFetchingMoreThreads =
|
|
63
|
+
isFetchingMoreThreadsBinding.initialValue;
|
|
64
|
+
isMutating = isMutatingBinding.initialValue;
|
|
65
|
+
return () => {
|
|
66
|
+
threadsBinding.unsubscribe();
|
|
67
|
+
storeIsLoadingBinding.unsubscribe();
|
|
68
|
+
storeErrorBinding.unsubscribe();
|
|
69
|
+
fetchMoreErrorBinding.unsubscribe();
|
|
70
|
+
hasMoreThreadsBinding.unsubscribe();
|
|
71
|
+
isFetchingMoreThreadsBinding.unsubscribe();
|
|
72
|
+
isMutatingBinding.unsubscribe();
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
$effect(() => {
|
|
76
|
+
store.start();
|
|
77
|
+
return () => {
|
|
78
|
+
store.setContext(null);
|
|
79
|
+
store.stop();
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
// Reactive input getters (agentId/enabled/includeArchived/limit) and
|
|
83
|
+
// provider getters are read inside $derived/$effect so updates rerun them.
|
|
84
|
+
const resolvedEnabled = $derived(input.enabled ?? true);
|
|
85
|
+
const threadListEndpointSupported = $derived(context.threadEndpoints?.list !== false);
|
|
86
|
+
const threadMutationsSupported = $derived(context.threadEndpoints?.mutations !== false);
|
|
87
|
+
const threadEndpointsUnavailable = $derived(!!context.runtimeUrl &&
|
|
88
|
+
context.runtimeConnectionStatus ===
|
|
89
|
+
CopilotKitCoreRuntimeConnectionStatus.Connected &&
|
|
90
|
+
!threadListEndpointSupported);
|
|
91
|
+
const threadMutationsError = $derived(threadMutationsSupported
|
|
92
|
+
? null
|
|
93
|
+
: new Error("Thread mutations are not available on this CopilotKit runtime"));
|
|
94
|
+
const threadEndpointsError = $derived(threadEndpointsUnavailable
|
|
95
|
+
? new Error("Thread endpoints are not available on this CopilotKit runtime")
|
|
96
|
+
: null);
|
|
97
|
+
$effect(() => {
|
|
98
|
+
const enabled = input.enabled ?? true;
|
|
99
|
+
const runtimeUrl = context.runtimeUrl;
|
|
100
|
+
const runtimeStatus = context.runtimeConnectionStatus;
|
|
101
|
+
const headers = context.headers;
|
|
102
|
+
const endpoints = context.threadEndpoints;
|
|
103
|
+
const intelligence = context.intelligence;
|
|
104
|
+
const agentId = input.agentId;
|
|
105
|
+
const includeArchived = input.includeArchived;
|
|
106
|
+
const limit = input.limit;
|
|
107
|
+
const listSupported = endpoints?.list !== false;
|
|
108
|
+
const clearContext = () => {
|
|
109
|
+
if (hasDispatchedContext) {
|
|
110
|
+
store.setContext(null);
|
|
111
|
+
}
|
|
112
|
+
hasDispatchedContext = false;
|
|
113
|
+
};
|
|
114
|
+
// Disabled: stay inert and tear down any previously-dispatched context
|
|
115
|
+
// so an in-flight subscription is closed and no further fetch is issued.
|
|
116
|
+
if (!enabled) {
|
|
117
|
+
clearContext();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!runtimeUrl) {
|
|
121
|
+
clearContext();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// Defer setting the context until the runtime reports Connected. Before
|
|
125
|
+
// `/info` resolves we don't know `intelligence.wsUrl`, so dispatching
|
|
126
|
+
// early would issue a list fetch without it, then a second one once it
|
|
127
|
+
// lands. For transient states (Disconnected/Connecting/Error with a URL
|
|
128
|
+
// still set) the previously-dispatched context stays in place.
|
|
129
|
+
if (runtimeStatus !== CopilotKitCoreRuntimeConnectionStatus.Connected) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!listSupported) {
|
|
133
|
+
clearContext();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const threadContext = {
|
|
137
|
+
runtimeUrl,
|
|
138
|
+
headers: { ...headers },
|
|
139
|
+
wsUrl: intelligence?.wsUrl,
|
|
140
|
+
agentId,
|
|
141
|
+
includeArchived,
|
|
142
|
+
limit,
|
|
143
|
+
};
|
|
144
|
+
store.setContext(threadContext);
|
|
145
|
+
hasDispatchedContext = true;
|
|
146
|
+
});
|
|
147
|
+
$effect(() => {
|
|
148
|
+
const enabled = input.enabled ?? true;
|
|
149
|
+
const nextAgentId = input.agentId;
|
|
150
|
+
// A disabled (e.g. unlicensed) surface must not claim the agentId slot.
|
|
151
|
+
// The registry is single-slot/last-writer-wins, so registering an inert
|
|
152
|
+
// store would evict — and on unmount tear down — a co-mounted live store
|
|
153
|
+
// for the same agent. Staying unregistered while disabled leaves the live
|
|
154
|
+
// store's registration intact. Mirrors react-core's use-threads gate.
|
|
155
|
+
//
|
|
156
|
+
// The cleanup unregisters exactly the id this run registered: on an
|
|
157
|
+
// agentId change it releases the previous id before the next run
|
|
158
|
+
// registers the new one; on an enabled true→false flip it releases the
|
|
159
|
+
// active id and the re-run registers nothing; on unmount it releases the
|
|
160
|
+
// active id only (an initially-disabled hook never registers, so its
|
|
161
|
+
// unmount unregisters nothing).
|
|
162
|
+
if (!enabled) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
core.registerThreadStore(nextAgentId, store);
|
|
166
|
+
return () => {
|
|
167
|
+
if (core.getThreadStore(nextAgentId) === store) {
|
|
168
|
+
core.unregisterThreadStore(nextAgentId);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
const runtimeError = $derived(context.runtimeUrl ? null : new Error("Runtime URL is not configured"));
|
|
173
|
+
const preConnectLoading = $derived(!!context.runtimeUrl &&
|
|
174
|
+
resolvedEnabled &&
|
|
175
|
+
!threadEndpointsUnavailable &&
|
|
176
|
+
!hasDispatchedContext);
|
|
177
|
+
const isLoading = $derived(runtimeError || threadEndpointsError
|
|
178
|
+
? false
|
|
179
|
+
: preConnectLoading || storeIsLoading);
|
|
180
|
+
const error = $derived(runtimeError ?? threadEndpointsError ?? storeError);
|
|
181
|
+
const listError = $derived(storeError);
|
|
182
|
+
function guardMutation(mutation) {
|
|
183
|
+
return (...args) => {
|
|
184
|
+
if (threadMutationsError) {
|
|
185
|
+
return Promise.reject(threadMutationsError);
|
|
186
|
+
}
|
|
187
|
+
return mutation(...args);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
get threads() {
|
|
192
|
+
return threads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
|
|
193
|
+
id,
|
|
194
|
+
agentId,
|
|
195
|
+
name,
|
|
196
|
+
archived,
|
|
197
|
+
createdAt,
|
|
198
|
+
updatedAt,
|
|
199
|
+
...(lastRunAt !== undefined ? { lastRunAt } : {}),
|
|
200
|
+
}));
|
|
201
|
+
},
|
|
202
|
+
get isLoading() {
|
|
203
|
+
return isLoading;
|
|
204
|
+
},
|
|
205
|
+
get error() {
|
|
206
|
+
return error;
|
|
207
|
+
},
|
|
208
|
+
get listError() {
|
|
209
|
+
return listError;
|
|
210
|
+
},
|
|
211
|
+
get fetchMoreError() {
|
|
212
|
+
return fetchMoreError;
|
|
213
|
+
},
|
|
214
|
+
get hasMoreThreads() {
|
|
215
|
+
return hasMoreThreads;
|
|
216
|
+
},
|
|
217
|
+
get isFetchingMoreThreads() {
|
|
218
|
+
return isFetchingMoreThreads;
|
|
219
|
+
},
|
|
220
|
+
get isMutating() {
|
|
221
|
+
return isMutating;
|
|
222
|
+
},
|
|
223
|
+
fetchMoreThreads: () => store.fetchNextPage(),
|
|
224
|
+
refetchThreads: () => store.refetchThreads(),
|
|
225
|
+
renameThread: guardMutation((threadId, name) => store.renameThread(threadId, name)),
|
|
226
|
+
archiveThread: guardMutation((threadId) => store.archiveThread(threadId)),
|
|
227
|
+
unarchiveThread: guardMutation((threadId) => store.unarchiveThread(threadId)),
|
|
228
|
+
deleteThread: guardMutation((threadId) => store.deleteThread(threadId)),
|
|
229
|
+
};
|
|
230
|
+
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { createAgent, CreateAgentUpdate, getThreadClone, } from
|
|
2
|
-
export type { CreateAgentProps } from
|
|
3
|
-
export { connectAgentContext } from
|
|
4
|
-
export type { AgentContextInput, JsonSerializable, } from
|
|
5
|
-
export { registerFrontendTool } from
|
|
6
|
-
export { registerRenderToolCall } from
|
|
7
|
-
export type { RenderToolProps, RenderToolInProgressProps, RenderToolExecutingProps, RenderToolCompleteProps, } from
|
|
8
|
-
export { registerHumanInTheLoop } from
|
|
9
|
-
export { createSuggestions } from
|
|
10
|
-
export type { CreateSuggestionsOptions, CreateSuggestionsResult, } from
|
|
11
|
-
export { createInterrupt } from
|
|
12
|
-
export type { CreateInterruptConfig, CreateInterruptResult, } from
|
|
13
|
-
export { createThreads } from
|
|
14
|
-
export type { Thread, CreateThreadsInput, CreateThreadsResult, } from
|
|
15
|
-
export { createAttachments } from
|
|
16
|
-
export type { CreateAttachmentsProps, CreateAttachmentsReturn, AttachmentsConfigInput, } from
|
|
17
|
-
export { loadKatexStyles } from
|
|
18
|
-
export { createCapabilities } from
|
|
19
|
-
export type { CreateCapabilitiesResult } from
|
|
1
|
+
export { createAgent, CreateAgentUpdate, getThreadClone, } from "./create-agent.svelte";
|
|
2
|
+
export type { CreateAgentProps } from "./create-agent.svelte";
|
|
3
|
+
export { connectAgentContext } from "./connect-agent-context.svelte";
|
|
4
|
+
export type { AgentContextInput, JsonSerializable, } from "./connect-agent-context.svelte";
|
|
5
|
+
export { registerFrontendTool } from "./register-frontend-tool.svelte";
|
|
6
|
+
export { registerRenderToolCall } from "./register-render-tool-call.svelte";
|
|
7
|
+
export type { RenderToolProps, RenderToolInProgressProps, RenderToolExecutingProps, RenderToolCompleteProps, } from "./register-render-tool-call.svelte";
|
|
8
|
+
export { registerHumanInTheLoop } from "./register-human-in-the-loop.svelte";
|
|
9
|
+
export { createSuggestions } from "./create-suggestions.svelte";
|
|
10
|
+
export type { CreateSuggestionsOptions, CreateSuggestionsResult, } from "./create-suggestions.svelte";
|
|
11
|
+
export { createInterrupt } from "./create-interrupt.svelte";
|
|
12
|
+
export type { CreateInterruptConfig, CreateInterruptResult, } from "./create-interrupt.svelte";
|
|
13
|
+
export { createThreads } from "./create-threads.svelte";
|
|
14
|
+
export type { Thread, CreateThreadsInput, CreateThreadsResult, } from "./create-threads.svelte";
|
|
15
|
+
export { createAttachments } from "./create-attachments.svelte";
|
|
16
|
+
export type { CreateAttachmentsProps, CreateAttachmentsReturn, AttachmentsConfigInput, } from "./create-attachments.svelte";
|
|
17
|
+
export { loadKatexStyles } from "./load-katex-styles.svelte";
|
|
18
|
+
export { createCapabilities } from "./create-capabilities.svelte";
|
|
19
|
+
export type { CreateCapabilitiesResult } from "./create-capabilities.svelte";
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createAgent, CreateAgentUpdate, getThreadClone, } from "./create-agent.svelte";
|
|
2
|
+
export { connectAgentContext } from "./connect-agent-context.svelte";
|
|
3
|
+
export { registerFrontendTool } from "./register-frontend-tool.svelte";
|
|
4
|
+
export { registerRenderToolCall } from "./register-render-tool-call.svelte";
|
|
5
|
+
export { registerHumanInTheLoop } from "./register-human-in-the-loop.svelte";
|
|
6
|
+
export { createSuggestions } from "./create-suggestions.svelte";
|
|
7
|
+
export { createInterrupt } from "./create-interrupt.svelte";
|
|
8
|
+
export { createThreads } from "./create-threads.svelte";
|
|
9
|
+
export { createAttachments } from "./create-attachments.svelte";
|
|
10
|
+
export { loadKatexStyles } from "./load-katex-styles.svelte";
|
|
11
|
+
export { createCapabilities } from "./create-capabilities.svelte";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let injected = false;
|
|
2
|
+
export function loadKatexStyles() {
|
|
3
|
+
$effect(() => {
|
|
4
|
+
if (injected || typeof document === "undefined")
|
|
5
|
+
return;
|
|
6
|
+
injected = true;
|
|
7
|
+
void import("katex/dist/katex.min.css").catch(() => {
|
|
8
|
+
console.warn("[CopilotKit] Failed to load katex styles — math content may render without formatting");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SvelteFrontendTool } from
|
|
1
|
+
import type { SvelteFrontendTool } from "../types";
|
|
2
2
|
export declare function registerFrontendTool<T extends Record<string, unknown>>(tool: SvelteFrontendTool<T>): void;
|
|
3
3
|
//# sourceMappingURL=register-frontend-tool.svelte.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getContext } from "svelte";
|
|
2
|
+
import { COPILOT_KIT_KEY } from "../providers/context";
|
|
3
|
+
export function registerFrontendTool(tool) {
|
|
4
|
+
const context = getContext(COPILOT_KIT_KEY);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("registerFrontendTool must be used within CopilotKitProvider");
|
|
7
|
+
}
|
|
8
|
+
$effect(() => {
|
|
9
|
+
const core = context.copilotkit;
|
|
10
|
+
const name = tool.name;
|
|
11
|
+
if (core.getTool({ toolName: name, agentId: tool.agentId })) {
|
|
12
|
+
console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
|
|
13
|
+
}
|
|
14
|
+
core.addHookFrontendTool(tool);
|
|
15
|
+
const renderer = tool.render
|
|
16
|
+
? {
|
|
17
|
+
name,
|
|
18
|
+
args: tool.parameters,
|
|
19
|
+
agentId: tool.agentId,
|
|
20
|
+
render: tool.render,
|
|
21
|
+
}
|
|
22
|
+
: undefined;
|
|
23
|
+
if (renderer)
|
|
24
|
+
core.addHookRenderToolCall(renderer);
|
|
25
|
+
return () => {
|
|
26
|
+
core.removeHookFrontendTool(name, tool.agentId, tool);
|
|
27
|
+
if (renderer) {
|
|
28
|
+
core.removeHookRenderToolCall(name, tool.agentId, renderer);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SvelteHumanInTheLoop } from
|
|
1
|
+
import type { SvelteHumanInTheLoop } from "../types";
|
|
2
2
|
export declare function registerHumanInTheLoop<T extends Record<string, unknown>>(tool: SvelteHumanInTheLoop<T>): void;
|
|
3
3
|
//# sourceMappingURL=register-human-in-the-loop.svelte.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getContext } from "svelte";
|
|
2
|
+
import { COPILOT_KIT_KEY } from "../providers/context";
|
|
3
|
+
export function registerHumanInTheLoop(tool) {
|
|
4
|
+
const context = getContext(COPILOT_KIT_KEY);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("registerHumanInTheLoop must be used within CopilotKitProvider");
|
|
7
|
+
}
|
|
8
|
+
const pendingResponses = {};
|
|
9
|
+
const respond = async (toolCallId, result) => {
|
|
10
|
+
const pending = pendingResponses[toolCallId];
|
|
11
|
+
if (!pending)
|
|
12
|
+
return;
|
|
13
|
+
pending.cleanupAbort?.();
|
|
14
|
+
delete pendingResponses[toolCallId];
|
|
15
|
+
pending.resolve(result);
|
|
16
|
+
};
|
|
17
|
+
const handler = async (_args, { toolCall, signal }) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
if (signal?.aborted) {
|
|
20
|
+
reject(new Error("Human-in-the-loop interaction aborted"));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const pending = {
|
|
24
|
+
resolve,
|
|
25
|
+
reject,
|
|
26
|
+
cleanupAbort: undefined,
|
|
27
|
+
};
|
|
28
|
+
pendingResponses[toolCall.id] = pending;
|
|
29
|
+
if (signal) {
|
|
30
|
+
const onAbort = () => {
|
|
31
|
+
delete pendingResponses[toolCall.id];
|
|
32
|
+
reject(new Error("Human-in-the-loop interaction aborted"));
|
|
33
|
+
};
|
|
34
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
35
|
+
pending.cleanupAbort = () => signal.removeEventListener("abort", onAbort);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
$effect(() => {
|
|
40
|
+
const core = context.copilotkit;
|
|
41
|
+
const { name, agentId, parameters, description, render } = tool;
|
|
42
|
+
const RenderComponent = (props) => {
|
|
43
|
+
const extendedProps = {
|
|
44
|
+
...props,
|
|
45
|
+
name,
|
|
46
|
+
description: description || "",
|
|
47
|
+
respond: props.status === "executing"
|
|
48
|
+
? (result) => respond(props.toolCallId, result)
|
|
49
|
+
: undefined,
|
|
50
|
+
};
|
|
51
|
+
return render(extendedProps);
|
|
52
|
+
};
|
|
53
|
+
const frontendTool = {
|
|
54
|
+
...tool,
|
|
55
|
+
name,
|
|
56
|
+
agentId,
|
|
57
|
+
parameters,
|
|
58
|
+
type: "human-in-the-loop",
|
|
59
|
+
handler,
|
|
60
|
+
render: RenderComponent,
|
|
61
|
+
};
|
|
62
|
+
const renderer = {
|
|
63
|
+
name,
|
|
64
|
+
args: parameters,
|
|
65
|
+
agentId,
|
|
66
|
+
render: RenderComponent,
|
|
67
|
+
};
|
|
68
|
+
core.addHookFrontendTool(frontendTool);
|
|
69
|
+
core.addHookRenderToolCall(renderer);
|
|
70
|
+
return () => {
|
|
71
|
+
for (const pending of Object.values(pendingResponses)) {
|
|
72
|
+
if (!pending)
|
|
73
|
+
continue;
|
|
74
|
+
pending.cleanupAbort?.();
|
|
75
|
+
pending.reject(new Error("Human-in-the-loop interaction aborted"));
|
|
76
|
+
}
|
|
77
|
+
for (const toolCallId of Object.keys(pendingResponses)) {
|
|
78
|
+
delete pendingResponses[toolCallId];
|
|
79
|
+
}
|
|
80
|
+
core.removeHookFrontendTool(name, agentId, frontendTool);
|
|
81
|
+
core.removeHookRenderToolCall(name, agentId, renderer);
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getContext } from "svelte";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { COPILOT_KIT_KEY } from "../providers/context";
|
|
4
|
+
export function registerRenderToolCall(config) {
|
|
5
|
+
const context = getContext(COPILOT_KIT_KEY);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("registerRenderToolCall must be used within CopilotKitProvider");
|
|
8
|
+
}
|
|
9
|
+
$effect(() => {
|
|
10
|
+
const { name, agentId, parameters, render } = config;
|
|
11
|
+
const schema = name === "*" && !parameters ? z.any() : (parameters ?? z.any());
|
|
12
|
+
const renderer = {
|
|
13
|
+
name,
|
|
14
|
+
args: schema,
|
|
15
|
+
render: (props) => render({
|
|
16
|
+
...props,
|
|
17
|
+
parameters: props.args,
|
|
18
|
+
}),
|
|
19
|
+
...(agentId ? { agentId } : {}),
|
|
20
|
+
};
|
|
21
|
+
context.copilotkit.addHookRenderToolCall(renderer);
|
|
22
|
+
return () => {
|
|
23
|
+
context.copilotkit.removeHookRenderToolCall(name, agentId, renderer);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./components";
|
|
2
|
+
export * from "./hooks";
|
|
3
|
+
export * from "./providers";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./lib/svelte-core";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CopilotKitCore
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CopilotKitCore } from "@copilotkit/core";
|
|
2
|
+
import type { CopilotKitCoreConfig, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, FrontendTool } from "@copilotkit/core";
|
|
3
|
+
import type { SvelteActivityMessageRenderer, SvelteToolCallRenderer, SvelteCustomMessageRenderer } from "../types";
|
|
4
|
+
import type { InterruptRenderProps } from "../types/interrupt";
|
|
4
5
|
export interface CopilotKitCoreSvelteConfig extends CopilotKitCoreConfig {
|
|
5
6
|
renderToolCalls?: SvelteToolCallRenderer<unknown>[];
|
|
6
7
|
renderActivityMessages?: SvelteActivityMessageRenderer<unknown>[];
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { tick } from "svelte";
|
|
2
|
+
import { CopilotKitCore } from "@copilotkit/core";
|
|
3
|
+
export class CopilotKitCoreSvelte extends CopilotKitCore {
|
|
4
|
+
_propFrontendTools = [];
|
|
5
|
+
_hookFrontendTools = new Map();
|
|
6
|
+
_renderToolCalls = [];
|
|
7
|
+
_hookRenderToolCalls = new Map();
|
|
8
|
+
_cachedMergedRenderToolCalls = null;
|
|
9
|
+
_renderCustomMessages = [];
|
|
10
|
+
_renderActivityMessages = [];
|
|
11
|
+
_interruptState = null;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
super(config);
|
|
14
|
+
this._propFrontendTools = [...(config.tools ?? [])];
|
|
15
|
+
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
16
|
+
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
17
|
+
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
18
|
+
}
|
|
19
|
+
get renderCustomMessages() {
|
|
20
|
+
return this._renderCustomMessages;
|
|
21
|
+
}
|
|
22
|
+
get renderActivityMessages() {
|
|
23
|
+
return this._renderActivityMessages;
|
|
24
|
+
}
|
|
25
|
+
setTools(tools) {
|
|
26
|
+
this._propFrontendTools = [...tools];
|
|
27
|
+
this._syncFrontendTools();
|
|
28
|
+
}
|
|
29
|
+
removeTool(name, agentId) {
|
|
30
|
+
this._propFrontendTools = this._propFrontendTools.filter((tool) => !(tool.name === name &&
|
|
31
|
+
(agentId !== undefined ? tool.agentId === agentId : !tool.agentId)));
|
|
32
|
+
this._hookFrontendTools.delete(`${agentId ?? ""}:${name}`);
|
|
33
|
+
super.removeTool(name, agentId);
|
|
34
|
+
this._syncFrontendTools();
|
|
35
|
+
}
|
|
36
|
+
addHookFrontendTool(tool) {
|
|
37
|
+
this._hookFrontendTools.set(`${tool.agentId ?? ""}:${tool.name}`, tool);
|
|
38
|
+
this._syncFrontendTools();
|
|
39
|
+
}
|
|
40
|
+
removeHookFrontendTool(name, agentId, expectedTool) {
|
|
41
|
+
const key = `${agentId ?? ""}:${name}`;
|
|
42
|
+
if (expectedTool !== undefined &&
|
|
43
|
+
this._hookFrontendTools.get(key) !== expectedTool) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (this._hookFrontendTools.delete(key)) {
|
|
47
|
+
this._syncFrontendTools();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
_syncFrontendTools() {
|
|
51
|
+
const merged = new Map();
|
|
52
|
+
for (const tool of this._propFrontendTools) {
|
|
53
|
+
merged.set(`${tool.agentId ?? ""}:${tool.name}`, tool);
|
|
54
|
+
}
|
|
55
|
+
for (const [key, tool] of this._hookFrontendTools) {
|
|
56
|
+
merged.set(key, tool);
|
|
57
|
+
}
|
|
58
|
+
super.setTools([...merged.values()]);
|
|
59
|
+
}
|
|
60
|
+
setRenderActivityMessages(renderers) {
|
|
61
|
+
this._renderActivityMessages = [...renderers];
|
|
62
|
+
}
|
|
63
|
+
setRenderCustomMessages(renderers) {
|
|
64
|
+
this._renderCustomMessages = [...renderers];
|
|
65
|
+
void this.notifySubscribers((subscriber) => {
|
|
66
|
+
const svelteSubscriber = subscriber;
|
|
67
|
+
return svelteSubscriber.onRenderCustomMessagesChanged?.({
|
|
68
|
+
copilotkit: this,
|
|
69
|
+
renderCustomMessages: [...this.renderCustomMessages],
|
|
70
|
+
});
|
|
71
|
+
}, "Subscriber onRenderCustomMessagesChanged error:");
|
|
72
|
+
}
|
|
73
|
+
get propRenderToolCalls() {
|
|
74
|
+
return this._renderToolCalls;
|
|
75
|
+
}
|
|
76
|
+
get renderToolCalls() {
|
|
77
|
+
if (this._hookRenderToolCalls.size === 0) {
|
|
78
|
+
return this._renderToolCalls;
|
|
79
|
+
}
|
|
80
|
+
if (this._cachedMergedRenderToolCalls) {
|
|
81
|
+
return this._cachedMergedRenderToolCalls;
|
|
82
|
+
}
|
|
83
|
+
const merged = new Map();
|
|
84
|
+
for (const rc of this._renderToolCalls) {
|
|
85
|
+
merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
|
|
86
|
+
}
|
|
87
|
+
for (const [key, rc] of this._hookRenderToolCalls) {
|
|
88
|
+
merged.set(key, rc);
|
|
89
|
+
}
|
|
90
|
+
this._cachedMergedRenderToolCalls = Array.from(merged.values());
|
|
91
|
+
return this._cachedMergedRenderToolCalls;
|
|
92
|
+
}
|
|
93
|
+
get interruptState() {
|
|
94
|
+
return this._interruptState;
|
|
95
|
+
}
|
|
96
|
+
setRenderToolCalls(renderToolCalls) {
|
|
97
|
+
this._renderToolCalls = [...renderToolCalls];
|
|
98
|
+
this._cachedMergedRenderToolCalls = null;
|
|
99
|
+
this._notifyRenderToolCallsChanged();
|
|
100
|
+
}
|
|
101
|
+
addHookRenderToolCall(entry) {
|
|
102
|
+
const key = `${entry.agentId ?? ""}:${entry.name}`;
|
|
103
|
+
this._hookRenderToolCalls.set(key, entry);
|
|
104
|
+
this._cachedMergedRenderToolCalls = null;
|
|
105
|
+
this._notifyRenderToolCallsChanged();
|
|
106
|
+
}
|
|
107
|
+
removeHookRenderToolCall(name, agentId, expectedRenderer) {
|
|
108
|
+
const key = `${agentId ?? ""}:${name}`;
|
|
109
|
+
if (expectedRenderer !== undefined &&
|
|
110
|
+
this._hookRenderToolCalls.get(key) !== expectedRenderer) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (this._hookRenderToolCalls.delete(key)) {
|
|
114
|
+
this._cachedMergedRenderToolCalls = null;
|
|
115
|
+
this._notifyRenderToolCallsChanged();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_notifyRenderToolCallsChanged() {
|
|
119
|
+
void this.notifySubscribers((subscriber) => {
|
|
120
|
+
const svelteSubscriber = subscriber;
|
|
121
|
+
if (svelteSubscriber.onRenderToolCallsChanged) {
|
|
122
|
+
return svelteSubscriber.onRenderToolCallsChanged?.({
|
|
123
|
+
copilotkit: this,
|
|
124
|
+
renderToolCalls: [...this.renderToolCalls],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}, "Subscriber onRenderToolCallsChanged error:");
|
|
128
|
+
}
|
|
129
|
+
setInterruptState(interruptState) {
|
|
130
|
+
this._interruptState = interruptState;
|
|
131
|
+
void this.notifySubscribers((subscriber) => {
|
|
132
|
+
const svelteSubscriber = subscriber;
|
|
133
|
+
return svelteSubscriber.onInterruptStateChanged?.({
|
|
134
|
+
copilotkit: this,
|
|
135
|
+
interruptState: this._interruptState,
|
|
136
|
+
});
|
|
137
|
+
}, "Subscriber onInterruptStateChanged error:");
|
|
138
|
+
}
|
|
139
|
+
subscribe(subscriber) {
|
|
140
|
+
return super.subscribe(subscriber);
|
|
141
|
+
}
|
|
142
|
+
async waitForPendingFrameworkUpdates() {
|
|
143
|
+
await tick();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
import type { CopilotKitProviderProps } from "./CopilotKitProvider.types";
|
|
3
|
+
type $$ComponentProps = CopilotKitProviderProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CopilotKitProvider: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CopilotKitProvider = ReturnType<typeof CopilotKitProvider>;
|
|
8
|
+
export default CopilotKitProvider;
|
|
9
|
+
//# sourceMappingURL=CopilotKitProvider.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotKitProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/providers/CopilotKitProvider.svelte"],"names":[],"mappings":"AAcE,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAI3E,KAAK,gBAAgB,GAAI,uBAAuB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAsR3E,QAAA,MAAM,kBAAkB,sDAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AbstractAgent } from
|
|
2
|
-
import { CopilotKitCoreErrorCode } from
|
|
3
|
-
import { DebugConfig } from
|
|
4
|
-
import { A2UITheme, SandboxFunction, SvelteActivityMessageRenderer, SvelteCustomMessageRenderer, SvelteFrontendTool, SvelteHumanInTheLoop, SvelteToolCallRenderer } from
|
|
1
|
+
import type { AbstractAgent } from "@ag-ui/client";
|
|
2
|
+
import type { CopilotKitCoreErrorCode } from "@copilotkit/core";
|
|
3
|
+
import type { DebugConfig } from "@copilotkit/shared";
|
|
4
|
+
import type { A2UITheme, SandboxFunction, SvelteActivityMessageRenderer, SvelteCustomMessageRenderer, SvelteFrontendTool, SvelteHumanInTheLoop, SvelteToolCallRenderer } from "../types";
|
|
5
5
|
export interface CopilotKitProviderProps {
|
|
6
6
|
runtimeUrl?: string;
|
|
7
7
|
headers?: Record<string, string> | (() => Record<string, string>);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|