@copilotkit/svelte 0.0.0-stage → 0.1.0
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 +325 -2
- package/dist/components/chat/CopilotChat.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChat.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatAssistantMessage.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatInput.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatInput.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatMessage.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatMessageView.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatReasoningMessage.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatSuggestionPill.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatSuggestionView.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatToggleButton.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatToolCallsView.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatUserMessage.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotChatView.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotChatView.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotPopup.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotPopup.svelte.d.ts +1 -0
- package/dist/components/chat/CopilotSidebar.d.svelte.ts +1 -0
- package/dist/components/chat/CopilotSidebar.svelte.d.ts +1 -0
- package/dist/components/chat/StreamMarkdown.d.svelte.ts +1 -0
- package/dist/components/chat/StreamMarkdown.svelte.d.ts +1 -0
- package/dist/components/chat/chat-config-context.d.svelte.ts +10 -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/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/markdown/CodeBlock.svelte.d.ts +1 -0
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts +1 -0
- package/dist/components/chat/markdown/Table.svelte.d.ts +1 -0
- package/dist/components/chat/markdown/TableBody.svelte.d.ts +1 -0
- package/dist/components/chat/markdown/TableCell.svelte.d.ts +1 -0
- package/dist/components/chat/markdown/TableHead.svelte.d.ts +1 -0
- package/dist/components/chat/markdown/TableRow.svelte.d.ts +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/media-parts.d.ts +11 -0
- package/dist/components/chat/media-parts.d.ts.map +1 -0
- package/dist/components/chat/types.d.ts +137 -0
- package/dist/components/chat/types.d.ts.map +1 -0
- package/dist/components/icons/index.d.ts +2 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.d.ts.map +1 -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/create-agent.svelte.d.ts +23 -0
- package/dist/hooks/create-agent.svelte.d.ts.map +1 -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-capabilities.svelte.d.ts +6 -0
- package/dist/hooks/create-capabilities.svelte.d.ts.map +1 -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-suggestions.svelte.d.ts +12 -0
- package/dist/hooks/create-suggestions.svelte.d.ts.map +1 -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/index.d.ts +20 -0
- package/dist/hooks/index.d.ts.map +1 -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/register-frontend-tool.svelte.d.ts +3 -0
- package/dist/hooks/register-frontend-tool.svelte.d.ts.map +1 -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-render-tool-call.svelte.d.ts +30 -0
- package/dist/hooks/register-render-tool-call.svelte.d.ts.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +3037 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/svelte-core.d.ts +53 -0
- package/dist/lib/svelte-core.d.ts.map +1 -0
- package/dist/providers/CopilotKitProvider.svelte.d.ts +1 -0
- package/dist/providers/CopilotKitProvider.types.d.ts +47 -0
- package/dist/providers/CopilotKitProvider.types.d.ts.map +1 -0
- package/dist/providers/context.d.ts +19 -0
- package/dist/providers/context.d.ts.map +1 -0
- package/dist/providers/index.d.ts +6 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/useCopilotKit.d.ts +3 -0
- package/dist/providers/useCopilotKit.d.ts.map +1 -0
- package/dist/styles.css +3 -0
- package/dist/types/a2ui.d.ts +5 -0
- package/dist/types/a2ui.d.ts.map +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/custom-message-renderer.d.ts +18 -0
- package/dist/types/custom-message-renderer.d.ts.map +1 -0
- package/dist/types/frontend-tool.d.ts +6 -0
- package/dist/types/frontend-tool.d.ts.map +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/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interrupt.d.ts +23 -0
- package/dist/types/interrupt.d.ts.map +1 -0
- package/dist/types/sandbox-function.d.ts +8 -0
- package/dist/types/sandbox-function.d.ts.map +1 -0
- package/dist/types/tool-call-renderer.d.ts +29 -0
- package/dist/types/tool-call-renderer.d.ts.map +1 -0
- package/package.json +114 -3
- package/src/app.d.ts +7 -0
- package/src/components/chat/CopilotChat.svelte +222 -0
- package/src/components/chat/CopilotChatAssistantMessage.svelte +295 -0
- package/src/components/chat/CopilotChatAttachmentQueue.svelte +241 -0
- package/src/components/chat/CopilotChatInput.svelte +192 -0
- package/src/components/chat/CopilotChatMessage.svelte +37 -0
- package/src/components/chat/CopilotChatMessageView.svelte +76 -0
- package/src/components/chat/CopilotChatReasoningMessage.svelte +210 -0
- package/src/components/chat/CopilotChatSuggestionPill.svelte +66 -0
- package/src/components/chat/CopilotChatSuggestionView.svelte +36 -0
- package/src/components/chat/CopilotChatToggleButton.svelte +47 -0
- package/src/components/chat/CopilotChatToolCallsView.svelte +187 -0
- package/src/components/chat/CopilotChatUserMessage.svelte +312 -0
- package/src/components/chat/CopilotChatView.svelte +177 -0
- package/src/components/chat/CopilotPopup.svelte +187 -0
- package/src/components/chat/CopilotSidebar.svelte +138 -0
- package/src/components/chat/StreamMarkdown.svelte +30 -0
- package/src/components/chat/chat-config-context.svelte.ts +28 -0
- package/src/components/chat/dispatch-after-active-run.ts +40 -0
- package/src/components/chat/markdown/CodeBlock.svelte +78 -0
- package/src/components/chat/markdown/CodeSpan.svelte +29 -0
- package/src/components/chat/markdown/Table.svelte +15 -0
- package/src/components/chat/markdown/TableBody.svelte +11 -0
- package/src/components/chat/markdown/TableCell.svelte +29 -0
- package/src/components/chat/markdown/TableHead.svelte +11 -0
- package/src/components/chat/markdown/TableRow.svelte +11 -0
- package/src/components/chat/markdown/highlight.ts +96 -0
- package/src/components/chat/media-parts.ts +34 -0
- package/src/components/chat/types.ts +176 -0
- package/src/components/icons/index.ts +23 -0
- package/src/components/index.ts +17 -0
- package/src/hooks/connect-agent-context.svelte.ts +46 -0
- package/src/hooks/create-agent.svelte.ts +420 -0
- package/src/hooks/create-attachments.svelte.ts +311 -0
- package/src/hooks/create-capabilities.svelte.ts +26 -0
- package/src/hooks/create-interrupt.svelte.ts +467 -0
- package/src/hooks/create-suggestions.svelte.ts +84 -0
- package/src/hooks/create-threads.svelte.ts +337 -0
- package/src/hooks/index.ts +45 -0
- package/src/hooks/load-katex-styles.svelte.ts +13 -0
- package/src/hooks/register-frontend-tool.svelte.ts +45 -0
- package/src/hooks/register-human-in-the-loop.svelte.ts +118 -0
- package/src/hooks/register-render-tool-call.svelte.ts +75 -0
- package/src/index.ts +6 -0
- package/src/lib/svelte-core.ts +230 -0
- package/src/providers/CopilotKitProvider.svelte +291 -0
- package/src/providers/CopilotKitProvider.types.ts +55 -0
- package/src/providers/context.ts +26 -0
- package/src/providers/index.ts +5 -0
- package/src/providers/useCopilotKit.ts +11 -0
- package/src/styles/globals.css +691 -0
- package/src/styles.d.ts +1 -0
- package/src/types/a2ui.ts +5 -0
- package/src/types/activity-message-renderer.ts +21 -0
- package/src/types/custom-message-renderer.ts +23 -0
- package/src/types/frontend-tool.ts +8 -0
- package/src/types/human-in-the-loop.ts +40 -0
- package/src/types/index.ts +8 -0
- package/src/types/interrupt.ts +32 -0
- package/src/types/sandbox-function.ts +8 -0
- package/src/types/tool-call-renderer.ts +36 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3037 @@
|
|
|
1
|
+
var rt = Object.defineProperty;
|
|
2
|
+
var at = (a, t, n) => t in a ? rt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n;
|
|
3
|
+
var re = (a, t, n) => at(a, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { getContext as oe, untrack as st, setContext as Ge, tick as Ce } from "svelte";
|
|
5
|
+
import { CopilotKitCoreRuntimeConnectionStatus as ve, ProxiedCopilotRuntimeAgent as it, ɵcreateThreadStore as ot, ɵselectThreads as Oe, ɵselectThreadsIsLoading as Ue, ɵselectThreadsError as Ve, ɵselectFetchMoreError as De, ɵselectHasNextPage as ze, ɵselectIsFetchingNextPage as je, ɵselectIsMutating as Ke, ToolCallStatus as fe, isRunCompletionAware as lt, CopilotKitCore as dt } from "@copilotkit/core";
|
|
6
|
+
import "svelte/internal/disclose-version";
|
|
7
|
+
import * as e from "svelte/internal/client";
|
|
8
|
+
import { DEFAULT_AGENT_ID as me, matchesAcceptFilter as Te, exceedsMaxSize as ct, formatFileSize as We, getModalityFromMimeType as ut, randomUUID as Ie, readFileAsBase64 as gt, generateVideoThumbnail as pt, partialJSONParse as Be, getSourceUrl as pe, getDocumentIcon as Je, createAttachmentContent as ft } from "@copilotkit/shared";
|
|
9
|
+
import vt from "@humanspeak/svelte-markdown";
|
|
10
|
+
import we from "highlight.js";
|
|
11
|
+
import { Download as mt, Check as Re, Copy as Ae, LoaderCircle as ht, CircleCheck as _t, Circle as bt, ThumbsUp as kt, ThumbsDown as yt, Volume2 as Ct, RefreshCw as Tt, ChevronLeft as wt, ChevronRight as Xe } from "lucide-svelte";
|
|
12
|
+
import { HttpAgent as xt, isInterruptExpired as Mt, buildResumeArray as It } from "@ag-ui/client";
|
|
13
|
+
import { SvelteMap as Ee, SvelteSet as St } from "svelte/reactivity";
|
|
14
|
+
import { z as Se } from "zod";
|
|
15
|
+
function Rt(a) {
|
|
16
|
+
return a === void 0 || a === !0 ? "pin-to-bottom" : a === !1 ? "none" : a;
|
|
17
|
+
}
|
|
18
|
+
const le = Symbol("copilotkit"), Ye = Symbol("copilotChatConfig");
|
|
19
|
+
var At = ((a) => (a.OnMessagesChanged = "OnMessagesChanged", a.OnStateChanged = "OnStateChanged", a.OnRunStatusChanged = "OnRunStatusChanged", a))(At || {});
|
|
20
|
+
const Et = [
|
|
21
|
+
"OnMessagesChanged",
|
|
22
|
+
/* OnMessagesChanged */
|
|
23
|
+
"OnStateChanged",
|
|
24
|
+
/* OnStateChanged */
|
|
25
|
+
"OnRunStatusChanged"
|
|
26
|
+
/* OnRunStatusChanged */
|
|
27
|
+
], he = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Qe = 50;
|
|
28
|
+
function Fr(a, t) {
|
|
29
|
+
var n;
|
|
30
|
+
if (!(!a || !t))
|
|
31
|
+
return (n = he.get(a)) == null ? void 0 : n.get(t);
|
|
32
|
+
}
|
|
33
|
+
function Lt(a, t) {
|
|
34
|
+
const n = a.clone();
|
|
35
|
+
if (n === a)
|
|
36
|
+
throw new Error(`createAgent: ${a.constructor.name}.clone() returned the same instance. clone() must return a new, independent object.`);
|
|
37
|
+
return n.threadId = t, n.setMessages([]), n.setState({}), n;
|
|
38
|
+
}
|
|
39
|
+
function ce(a, t, n) {
|
|
40
|
+
t instanceof xt && (typeof a.applyHeadersToAgent == "function" ? a.applyHeadersToAgent(t) : t.headers = { ...t.headers, ...n });
|
|
41
|
+
}
|
|
42
|
+
function Ft(a, t, n, r) {
|
|
43
|
+
let s = he.get(t);
|
|
44
|
+
s || (s = new Ee(), he.set(t, s));
|
|
45
|
+
const o = s.get(n);
|
|
46
|
+
if (o)
|
|
47
|
+
return o.threadId = n, ce(a, o, r), o;
|
|
48
|
+
const g = Lt(t, n);
|
|
49
|
+
if (ce(a, g, r), s.size >= Qe) {
|
|
50
|
+
const c = ye.get(t), p = [...s.keys()].find((m) => !(c != null && c.get(m)));
|
|
51
|
+
p !== void 0 && s.delete(p);
|
|
52
|
+
}
|
|
53
|
+
return s.set(n, g), g;
|
|
54
|
+
}
|
|
55
|
+
function Pt(a, t) {
|
|
56
|
+
let n = ye.get(a);
|
|
57
|
+
n || (n = new Ee(), ye.set(a, n)), n.set(t, (n.get(t) ?? 0) + 1);
|
|
58
|
+
}
|
|
59
|
+
function Ot(a, t) {
|
|
60
|
+
const n = ye.get(a), r = n == null ? void 0 : n.get(t);
|
|
61
|
+
if (r === void 0) return;
|
|
62
|
+
r <= 1 ? n == null || n.delete(t) : n == null || n.set(t, r - 1);
|
|
63
|
+
const s = he.get(a);
|
|
64
|
+
for (; s && s.size > Qe; ) {
|
|
65
|
+
const o = [...s.keys()].find((g) => !(n != null && n.get(g)));
|
|
66
|
+
if (o === void 0) break;
|
|
67
|
+
s.delete(o);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function Le(a = {}) {
|
|
71
|
+
const t = oe(le);
|
|
72
|
+
if (!t)
|
|
73
|
+
throw new Error("createAgent must be used within CopilotKitProvider");
|
|
74
|
+
const n = e.derived(() => a.agentId ?? me), r = e.derived(() => a.threadId), s = e.derived(() => a.updates ?? Et), o = e.derived(() => a.throttleMs);
|
|
75
|
+
let g = e.state(null), c = null, p = e.state(0), m = e.state(0), _ = e.state(e.proxy([])), R = e.state(!1), L = e.state(null);
|
|
76
|
+
const E = new Ee();
|
|
77
|
+
let M = null;
|
|
78
|
+
function x() {
|
|
79
|
+
M && (Ot(M.source, M.threadId), M = null);
|
|
80
|
+
}
|
|
81
|
+
function k(h) {
|
|
82
|
+
c !== h && e.set(m, e.get(m) + 1), c = h, e.set(g, h, !0);
|
|
83
|
+
}
|
|
84
|
+
const A = () => {
|
|
85
|
+
const h = e.get(n), d = e.get(r), y = d ? `${h}:${d}` : h, b = t.copilotkit, i = t.runtimeUrl, f = t.runtimeConnectionStatus, P = t.runtimeTransport, v = t.headers, l = "credentials" in t ? t.credentials : b.credentials, w = t.agents ?? {}, F = b.getAgent(h), U = w[h] ?? F;
|
|
86
|
+
if (U) {
|
|
87
|
+
E.delete(y), E.delete(h), ce(b, U, v);
|
|
88
|
+
let C;
|
|
89
|
+
d ? (M && (M.source !== U || M.threadId !== d) && x(), C = Ft(b, U, d, v), (!M || M.source !== U || M.threadId !== d) && (Pt(U, d), M = { source: U, threadId: d })) : (x(), C = U), k(C), e.set(_, [...C.messages ?? []], !0), e.set(R, C.isRunning ?? !1, !0), e.set(L, C, !0);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const V = i !== void 0;
|
|
93
|
+
if (V && (f === ve.Disconnected || f === ve.Connecting || f === ve.Error)) {
|
|
94
|
+
x();
|
|
95
|
+
let C = E.get(y);
|
|
96
|
+
if (C && (C.runtimeUrl !== i || C.transport !== P) && (E.delete(y), C = void 0), C) {
|
|
97
|
+
C.agent.credentials = l, ce(b, C.agent, v), d && (C.agent.threadId = d), k(C.agent), e.set(_, [...C.agent.messages ?? []], !0), e.set(R, C.agent.isRunning ?? !1, !0), e.set(L, C.agent, !0);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const I = new it({
|
|
101
|
+
runtimeUrl: i,
|
|
102
|
+
agentId: h,
|
|
103
|
+
transport: P,
|
|
104
|
+
runtimeMode: "pending",
|
|
105
|
+
credentials: l
|
|
106
|
+
});
|
|
107
|
+
ce(b, I, v), d && (I.threadId = d), E.set(y, { agent: I, runtimeUrl: i, transport: P }), k(I), e.set(_, [...I.messages ?? []], !0), e.set(R, I.isRunning ?? !1, !0), e.set(L, I, !0);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
x();
|
|
111
|
+
const T = Object.keys(w), K = V ? `runtimeUrl=${i}` : "no runtimeUrl";
|
|
112
|
+
throw new Error(`createAgent: Agent '${h}' not found after runtime sync (${K}). ` + (T.length ? `Known agents: [${T.join(", ")}]` : "No agents registered."));
|
|
113
|
+
};
|
|
114
|
+
return e.user_effect(() => {
|
|
115
|
+
A();
|
|
116
|
+
}), e.user_effect(() => () => x()), e.user_effect(() => {
|
|
117
|
+
const h = t.headers, d = t.copilotkit;
|
|
118
|
+
ce(d, e.get(L), h);
|
|
119
|
+
for (const y of Object.values(t.agents ?? {})) {
|
|
120
|
+
ce(d, y, h);
|
|
121
|
+
const b = he.get(y);
|
|
122
|
+
if (b)
|
|
123
|
+
for (const i of b.values())
|
|
124
|
+
ce(d, i, h);
|
|
125
|
+
}
|
|
126
|
+
for (const y of E.values())
|
|
127
|
+
ce(d, y.agent, h);
|
|
128
|
+
}), e.user_effect(() => {
|
|
129
|
+
const h = e.get(L), d = e.get(s), y = t.copilotkit;
|
|
130
|
+
if (!h || d.length === 0) return;
|
|
131
|
+
let b = !0, i = !1;
|
|
132
|
+
const f = () => {
|
|
133
|
+
b && (i || (i = !0, queueMicrotask(() => {
|
|
134
|
+
i = !1, b && e.set(p, e.get(p) + 1);
|
|
135
|
+
})));
|
|
136
|
+
}, P = {};
|
|
137
|
+
d.includes(
|
|
138
|
+
"OnMessagesChanged"
|
|
139
|
+
/* OnMessagesChanged */
|
|
140
|
+
) && (P.onMessagesChanged = () => {
|
|
141
|
+
b && (e.set(_, (h.messages ?? []).map((l) => ({ ...l })), !0), e.set(R, h.isRunning ?? !1, !0), e.set(p, e.get(p) + 1));
|
|
142
|
+
}), d.includes(
|
|
143
|
+
"OnStateChanged"
|
|
144
|
+
/* OnStateChanged */
|
|
145
|
+
) && (P.onStateChanged = f), d.includes(
|
|
146
|
+
"OnRunStatusChanged"
|
|
147
|
+
/* OnRunStatusChanged */
|
|
148
|
+
) && (P.onRunInitialized = () => {
|
|
149
|
+
b && (e.set(R, !0), e.set(g, h, !0), e.set(p, e.get(p) + 1));
|
|
150
|
+
}, P.onRunFinalized = () => {
|
|
151
|
+
b && (e.set(R, !1), e.set(g, h, !0), e.set(_, (h.messages ?? []).map((l) => ({ ...l })), !0), e.set(p, e.get(p) + 1));
|
|
152
|
+
}, P.onRunFailed = () => {
|
|
153
|
+
b && (e.set(R, !1), e.set(g, h, !0), e.set(_, (h.messages ?? []).map((l) => ({ ...l })), !0), e.set(p, e.get(p) + 1));
|
|
154
|
+
}, P.onRunErrorEvent = () => {
|
|
155
|
+
b && (e.set(R, !1), e.set(g, h, !0), e.set(_, (h.messages ?? []).map((l) => ({ ...l })), !0), e.set(p, e.get(p) + 1));
|
|
156
|
+
});
|
|
157
|
+
const v = y.subscribeToAgentWithOptions(h, P, { throttleMs: e.get(o) });
|
|
158
|
+
return () => {
|
|
159
|
+
b = !1, v.unsubscribe();
|
|
160
|
+
};
|
|
161
|
+
}), {
|
|
162
|
+
get agent() {
|
|
163
|
+
return e.get(p), e.get(g);
|
|
164
|
+
},
|
|
165
|
+
get agentInstanceVersion() {
|
|
166
|
+
return e.get(m);
|
|
167
|
+
},
|
|
168
|
+
get messages() {
|
|
169
|
+
return e.get(_);
|
|
170
|
+
},
|
|
171
|
+
get isRunning() {
|
|
172
|
+
return e.get(R);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function Pr(a) {
|
|
177
|
+
const t = oe(le);
|
|
178
|
+
if (!t)
|
|
179
|
+
throw new Error("connectAgentContext must be used within CopilotKitProvider");
|
|
180
|
+
e.user_effect(() => {
|
|
181
|
+
const n = t.copilotkit, r = a.description, s = a.value, o = s === void 0 ? "" : typeof s == "string" ? s : JSON.stringify(s), g = n.addContext({ description: r, value: o });
|
|
182
|
+
return () => {
|
|
183
|
+
n.removeContext(g);
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function Or(a) {
|
|
188
|
+
const t = oe(le);
|
|
189
|
+
if (!t)
|
|
190
|
+
throw new Error("registerFrontendTool must be used within CopilotKitProvider");
|
|
191
|
+
e.user_effect(() => {
|
|
192
|
+
const n = t.copilotkit, r = a.name;
|
|
193
|
+
n.getTool({ toolName: r, agentId: a.agentId }) && console.warn(`Tool '${r}' already exists for agent '${a.agentId || "global"}'. Overriding with latest registration.`), n.addHookFrontendTool(a);
|
|
194
|
+
const s = a.render ? {
|
|
195
|
+
name: r,
|
|
196
|
+
args: a.parameters,
|
|
197
|
+
agentId: a.agentId,
|
|
198
|
+
render: a.render
|
|
199
|
+
} : void 0;
|
|
200
|
+
return s && n.addHookRenderToolCall(s), () => {
|
|
201
|
+
n.removeHookFrontendTool(r, a.agentId, a), s && n.removeHookRenderToolCall(r, a.agentId, s);
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function Ur(a) {
|
|
206
|
+
const t = oe(le);
|
|
207
|
+
if (!t)
|
|
208
|
+
throw new Error("registerRenderToolCall must be used within CopilotKitProvider");
|
|
209
|
+
e.user_effect(() => {
|
|
210
|
+
const { name: n, agentId: r, parameters: s, render: o } = a, g = n === "*" && !s ? Se.any() : s ?? Se.any(), c = {
|
|
211
|
+
name: n,
|
|
212
|
+
args: g,
|
|
213
|
+
render: (p) => o({ ...p, parameters: p.args }),
|
|
214
|
+
...r ? { agentId: r } : {}
|
|
215
|
+
};
|
|
216
|
+
return t.copilotkit.addHookRenderToolCall(c), () => {
|
|
217
|
+
t.copilotkit.removeHookRenderToolCall(n, r, c);
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function Vr(a) {
|
|
222
|
+
const t = oe(le);
|
|
223
|
+
if (!t)
|
|
224
|
+
throw new Error("registerHumanInTheLoop must be used within CopilotKitProvider");
|
|
225
|
+
const n = {}, r = async (o, g) => {
|
|
226
|
+
var p;
|
|
227
|
+
const c = n[o];
|
|
228
|
+
c && ((p = c.cleanupAbort) == null || p.call(c), delete n[o], c.resolve(g));
|
|
229
|
+
}, s = async (o, { toolCall: g, signal: c }) => new Promise((p, m) => {
|
|
230
|
+
if (c != null && c.aborted) {
|
|
231
|
+
m(new Error("Human-in-the-loop interaction aborted"));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const _ = { resolve: p, reject: m, cleanupAbort: void 0 };
|
|
235
|
+
if (n[g.id] = _, c) {
|
|
236
|
+
const R = () => {
|
|
237
|
+
delete n[g.id], m(new Error("Human-in-the-loop interaction aborted"));
|
|
238
|
+
};
|
|
239
|
+
c.addEventListener("abort", R, { once: !0 }), _.cleanupAbort = () => c.removeEventListener("abort", R);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
e.user_effect(() => {
|
|
243
|
+
const o = t.copilotkit, { name: g, agentId: c, parameters: p, description: m, render: _ } = a, R = (M) => {
|
|
244
|
+
const x = {
|
|
245
|
+
...M,
|
|
246
|
+
name: g,
|
|
247
|
+
description: m || "",
|
|
248
|
+
respond: M.status === "executing" ? (k) => r(M.toolCallId, k) : void 0
|
|
249
|
+
};
|
|
250
|
+
return _(x);
|
|
251
|
+
}, L = {
|
|
252
|
+
...a,
|
|
253
|
+
name: g,
|
|
254
|
+
agentId: c,
|
|
255
|
+
parameters: p,
|
|
256
|
+
type: "human-in-the-loop",
|
|
257
|
+
handler: s,
|
|
258
|
+
render: R
|
|
259
|
+
}, E = { name: g, args: p, agentId: c, render: R };
|
|
260
|
+
return o.addHookFrontendTool(L), o.addHookRenderToolCall(E), () => {
|
|
261
|
+
var M;
|
|
262
|
+
for (const x of Object.values(n))
|
|
263
|
+
x && ((M = x.cleanupAbort) == null || M.call(x), x.reject(new Error("Human-in-the-loop interaction aborted")));
|
|
264
|
+
for (const x of Object.keys(n))
|
|
265
|
+
delete n[x];
|
|
266
|
+
o.removeHookFrontendTool(g, c, L), o.removeHookRenderToolCall(g, c, E);
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function Ut(a = {}) {
|
|
271
|
+
const t = oe(le);
|
|
272
|
+
if (!t)
|
|
273
|
+
throw new Error("createSuggestions must be used within CopilotKitProvider");
|
|
274
|
+
const n = e.derived(() => (typeof a.agentId == "function" ? a.agentId() : a.agentId) ?? me);
|
|
275
|
+
let r = e.state(e.proxy([])), s = e.state(!1);
|
|
276
|
+
return e.user_effect(() => {
|
|
277
|
+
const c = t.copilotkit, p = c.getSuggestions(e.get(n));
|
|
278
|
+
e.set(r, p.suggestions, !0), e.set(s, p.isLoading, !0);
|
|
279
|
+
const m = c.subscribe({
|
|
280
|
+
onSuggestionsChanged: ({ agentId: _, suggestions: R }) => {
|
|
281
|
+
if (_ !== e.get(n)) return;
|
|
282
|
+
e.set(r, R, !0);
|
|
283
|
+
const L = c.getSuggestions(e.get(n));
|
|
284
|
+
e.set(s, L.isLoading, !0);
|
|
285
|
+
},
|
|
286
|
+
onSuggestionsStartedLoading: ({ agentId: _ }) => {
|
|
287
|
+
_ === e.get(n) && e.set(s, !0);
|
|
288
|
+
},
|
|
289
|
+
onSuggestionsFinishedLoading: ({ agentId: _ }) => {
|
|
290
|
+
_ === e.get(n) && e.set(s, !1);
|
|
291
|
+
},
|
|
292
|
+
onSuggestionsConfigChanged: () => {
|
|
293
|
+
const _ = c.getSuggestions(e.get(n));
|
|
294
|
+
e.set(r, _.suggestions, !0), e.set(s, _.isLoading, !0);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
return () => m.unsubscribe();
|
|
298
|
+
}), {
|
|
299
|
+
get suggestions() {
|
|
300
|
+
return e.get(r);
|
|
301
|
+
},
|
|
302
|
+
get isLoading() {
|
|
303
|
+
return e.get(s);
|
|
304
|
+
},
|
|
305
|
+
reloadSuggestions: () => {
|
|
306
|
+
t.copilotkit.reloadSuggestions(e.get(n));
|
|
307
|
+
},
|
|
308
|
+
clearSuggestions: () => {
|
|
309
|
+
t.copilotkit.clearSuggestions(e.get(n));
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const Ze = "on_interrupt";
|
|
314
|
+
function Vt(a) {
|
|
315
|
+
return (typeof a == "object" || typeof a == "function") && a !== null && typeof Reflect.get(a, "then") == "function";
|
|
316
|
+
}
|
|
317
|
+
function Dt(a) {
|
|
318
|
+
return a instanceof Promise ? a : new Promise((t, n) => {
|
|
319
|
+
try {
|
|
320
|
+
a.then(t, n);
|
|
321
|
+
} catch (r) {
|
|
322
|
+
n(r);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function _e(a) {
|
|
327
|
+
return a.kind === "legacy" ? a.event : { name: Ze, value: a.interrupts[0] };
|
|
328
|
+
}
|
|
329
|
+
function Dr(a = {}) {
|
|
330
|
+
const t = oe(le);
|
|
331
|
+
if (!t)
|
|
332
|
+
throw new Error("createInterrupt must be used within CopilotKitProvider");
|
|
333
|
+
const n = Le({
|
|
334
|
+
get agentId() {
|
|
335
|
+
return typeof a.agentId == "function" ? a.agentId() : a.agentId;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
let r = e.state(null), s = e.state(null);
|
|
339
|
+
const o = {};
|
|
340
|
+
let g = null;
|
|
341
|
+
function c() {
|
|
342
|
+
for (const k of Object.keys(o)) delete o[k];
|
|
343
|
+
}
|
|
344
|
+
e.user_effect(() => {
|
|
345
|
+
const k = n.agentInstanceVersion, A = st(() => n.agent);
|
|
346
|
+
if (g !== k && (e.set(r, null), e.set(s, null), c(), g = k), !A) {
|
|
347
|
+
e.set(r, null), e.set(s, null);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
let h = null, d = null;
|
|
351
|
+
const y = A.subscribe({
|
|
352
|
+
onCustomEvent: ({ event: b }) => {
|
|
353
|
+
n.agentInstanceVersion === k && b.name === Ze && (h = { name: b.name, value: b.value });
|
|
354
|
+
},
|
|
355
|
+
onRunFinishedEvent: (b) => {
|
|
356
|
+
n.agentInstanceVersion === k && b.outcome === "interrupt" && (d = b.interrupts);
|
|
357
|
+
},
|
|
358
|
+
onRunStartedEvent: () => {
|
|
359
|
+
var b;
|
|
360
|
+
n.agentInstanceVersion === k && (h = null, d = null, c(), ((b = e.get(r)) == null ? void 0 : b.ownerVersion) === k && e.set(r, null));
|
|
361
|
+
},
|
|
362
|
+
onRunFinalized: () => {
|
|
363
|
+
n.agentInstanceVersion === k && (d && d.length > 0 ? e.set(r, {
|
|
364
|
+
kind: "standard",
|
|
365
|
+
interrupts: d,
|
|
366
|
+
owner: A,
|
|
367
|
+
ownerVersion: k
|
|
368
|
+
}) : h && e.set(r, {
|
|
369
|
+
kind: "legacy",
|
|
370
|
+
event: h,
|
|
371
|
+
owner: A,
|
|
372
|
+
ownerVersion: k
|
|
373
|
+
}), h = null, d = null);
|
|
374
|
+
},
|
|
375
|
+
onRunFailed: () => {
|
|
376
|
+
var b;
|
|
377
|
+
n.agentInstanceVersion === k && (h = null, d = null, c(), ((b = e.get(r)) == null ? void 0 : b.ownerVersion) === k && e.set(r, null));
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
return () => y.unsubscribe();
|
|
381
|
+
});
|
|
382
|
+
const p = async (k, A, h) => {
|
|
383
|
+
var i, f, P;
|
|
384
|
+
if (((i = e.get(r)) == null ? void 0 : i.ownerVersion) !== h || n.agentInstanceVersion !== h || !k.every((v) => o[v.id])) return;
|
|
385
|
+
const y = k.find((v) => Mt(v));
|
|
386
|
+
if (y) {
|
|
387
|
+
console.error(`[CopilotKit] createInterrupt: interrupt ${y.id} expired at ${y.expiresAt}; not resuming.`), c(), ((f = e.get(r)) == null ? void 0 : f.ownerVersion) === h && e.set(r, null);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const b = It(k, o);
|
|
391
|
+
if (c(), n.agentInstanceVersion === h)
|
|
392
|
+
try {
|
|
393
|
+
return await t.copilotkit.runAgent({ agent: A, resume: b });
|
|
394
|
+
} catch (v) {
|
|
395
|
+
throw console.error("[CopilotKit] createInterrupt resolve: runAgent rejected; clearing pending + rethrowing", v), ((P = e.get(r)) == null ? void 0 : P.ownerVersion) === h && e.set(r, null), v;
|
|
396
|
+
}
|
|
397
|
+
}, m = async (k, A) => {
|
|
398
|
+
var y, b;
|
|
399
|
+
const h = e.get(r);
|
|
400
|
+
if (!h || n.agentInstanceVersion !== h.ownerVersion) return;
|
|
401
|
+
if (h.kind === "legacy")
|
|
402
|
+
try {
|
|
403
|
+
return await t.copilotkit.runAgent({
|
|
404
|
+
agent: h.owner,
|
|
405
|
+
forwardedProps: {
|
|
406
|
+
command: { resume: k, interruptEvent: h.event.value }
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
} catch (i) {
|
|
410
|
+
throw console.error("[CopilotKit] createInterrupt resolve: runAgent rejected; clearing pending + rethrowing", i), ((y = e.get(r)) == null ? void 0 : y.ownerVersion) === h.ownerVersion && e.set(r, null), i;
|
|
411
|
+
}
|
|
412
|
+
h.interrupts.length > 1 && A === void 0 && console.warn(`[CopilotKit] createInterrupt: resolve() called without an interruptId while ${h.interrupts.length} interrupts are open; defaulting to the first.`);
|
|
413
|
+
const d = A ?? ((b = h.interrupts[0]) == null ? void 0 : b.id);
|
|
414
|
+
if (d)
|
|
415
|
+
return o[d] = { status: "resolved", payload: k }, p(h.interrupts, h.owner, h.ownerVersion);
|
|
416
|
+
}, _ = async (k) => {
|
|
417
|
+
var d;
|
|
418
|
+
const A = e.get(r);
|
|
419
|
+
if (!A || n.agentInstanceVersion !== A.ownerVersion) return;
|
|
420
|
+
if (A.kind === "legacy") {
|
|
421
|
+
console.warn("[CopilotKit] createInterrupt: cancel() is not supported for legacy on_interrupt interrupts; dismissing."), e.set(r, null);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
A.interrupts.length > 1 && k === void 0 && console.warn(`[CopilotKit] createInterrupt: cancel() called without an interruptId while ${A.interrupts.length} interrupts are open; defaulting to the first.`);
|
|
425
|
+
const h = k ?? ((d = A.interrupts[0]) == null ? void 0 : d.id);
|
|
426
|
+
if (h)
|
|
427
|
+
return o[h] = { status: "cancelled" }, p(A.interrupts, A.owner, A.ownerVersion);
|
|
428
|
+
}, R = m, L = _;
|
|
429
|
+
e.user_effect(() => {
|
|
430
|
+
const k = e.get(r);
|
|
431
|
+
if (!k) {
|
|
432
|
+
e.set(s, null);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const A = _e(k);
|
|
436
|
+
if (a.enabled && !a.enabled(A)) {
|
|
437
|
+
e.set(s, null);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const h = a.handler;
|
|
441
|
+
if (!h) {
|
|
442
|
+
e.set(s, null);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
let d = !1;
|
|
446
|
+
const y = k.ownerVersion, b = h({
|
|
447
|
+
event: A,
|
|
448
|
+
interrupt: k.kind === "standard" ? k.interrupts[0] ?? null : null,
|
|
449
|
+
interrupts: k.kind === "standard" ? k.interrupts : [],
|
|
450
|
+
resolve: m,
|
|
451
|
+
cancel: _
|
|
452
|
+
});
|
|
453
|
+
return Vt(b) ? Dt(b).then((i) => {
|
|
454
|
+
var f;
|
|
455
|
+
!d && n.agentInstanceVersion === y && ((f = e.get(r)) == null ? void 0 : f.ownerVersion) === y && e.set(s, i, !0);
|
|
456
|
+
}).catch((i) => {
|
|
457
|
+
var f;
|
|
458
|
+
!d && n.agentInstanceVersion === y && ((f = e.get(r)) == null ? void 0 : f.ownerVersion) === y && (console.error("[CopilotKit] createInterrupt handler failed:", i), e.set(s, null));
|
|
459
|
+
}) : e.set(s, b, !0), () => {
|
|
460
|
+
d = !0;
|
|
461
|
+
};
|
|
462
|
+
}), e.user_effect(() => {
|
|
463
|
+
const k = t.copilotkit, A = e.get(r);
|
|
464
|
+
if (!A) {
|
|
465
|
+
k.setInterruptState(null);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const h = _e(A);
|
|
469
|
+
if (a.enabled && !a.enabled(h)) {
|
|
470
|
+
k.setInterruptState(null);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const d = {
|
|
474
|
+
event: h,
|
|
475
|
+
interrupt: A.kind === "standard" ? A.interrupts[0] ?? null : null,
|
|
476
|
+
interrupts: A.kind === "standard" ? A.interrupts : [],
|
|
477
|
+
result: e.get(s),
|
|
478
|
+
resolve: m,
|
|
479
|
+
cancel: _
|
|
480
|
+
};
|
|
481
|
+
return k.setInterruptState(d), () => {
|
|
482
|
+
k.interruptState === d && k.setInterruptState(null);
|
|
483
|
+
};
|
|
484
|
+
});
|
|
485
|
+
const E = e.derived(() => e.get(r) ? _e(e.get(r)) : null), M = e.derived(() => e.get(r) !== null), x = e.derived(() => {
|
|
486
|
+
const k = e.get(r);
|
|
487
|
+
if (!k) return null;
|
|
488
|
+
const A = _e(k);
|
|
489
|
+
return a.enabled && !a.enabled(A) ? null : {
|
|
490
|
+
event: A,
|
|
491
|
+
interrupt: k.kind === "standard" ? k.interrupts[0] ?? null : null,
|
|
492
|
+
interrupts: k.kind === "standard" ? k.interrupts : [],
|
|
493
|
+
result: e.get(s),
|
|
494
|
+
resolve: m,
|
|
495
|
+
cancel: _
|
|
496
|
+
};
|
|
497
|
+
});
|
|
498
|
+
return {
|
|
499
|
+
get interrupt() {
|
|
500
|
+
return e.get(E);
|
|
501
|
+
},
|
|
502
|
+
get result() {
|
|
503
|
+
return e.get(s);
|
|
504
|
+
},
|
|
505
|
+
get hasInterrupt() {
|
|
506
|
+
return e.get(M);
|
|
507
|
+
},
|
|
508
|
+
resolve: m,
|
|
509
|
+
resolveInterrupt: R,
|
|
510
|
+
cancel: _,
|
|
511
|
+
cancelInterrupt: L,
|
|
512
|
+
get slotProps() {
|
|
513
|
+
return e.get(x);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function zr(a) {
|
|
518
|
+
const t = oe(le);
|
|
519
|
+
if (!t)
|
|
520
|
+
throw new Error("createThreads must be used within CopilotKitProvider");
|
|
521
|
+
const n = t.copilotkit, r = ot({ fetch: n.ɵruntimeFetch });
|
|
522
|
+
let s = e.state(e.proxy([])), o = e.state(!1), g = e.state(null), c = e.state(null), p = e.state(!1), m = e.state(!1), _ = e.state(!1), R = e.state(!1);
|
|
523
|
+
function L(v) {
|
|
524
|
+
const l = v(r.getState()), w = r.select(v).subscribe((F) => {
|
|
525
|
+
v === Oe ? e.set(s, F, !0) : v === Ue ? e.set(o, F, !0) : v === Ve ? e.set(g, F, !0) : v === De ? e.set(c, F, !0) : v === ze ? e.set(p, F, !0) : v === je ? e.set(m, F, !0) : v === Ke && e.set(_, F, !0);
|
|
526
|
+
});
|
|
527
|
+
return {
|
|
528
|
+
initialValue: l,
|
|
529
|
+
unsubscribe: () => w.unsubscribe()
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
e.user_effect(() => {
|
|
533
|
+
const v = L(Oe), l = L(Ue), w = L(Ve), F = L(De), U = L(ze), V = L(je), T = L(Ke);
|
|
534
|
+
return e.set(s, v.initialValue, !0), e.set(o, l.initialValue, !0), e.set(g, w.initialValue, !0), e.set(c, F.initialValue, !0), e.set(p, U.initialValue, !0), e.set(m, V.initialValue, !0), e.set(_, T.initialValue, !0), () => {
|
|
535
|
+
v.unsubscribe(), l.unsubscribe(), w.unsubscribe(), F.unsubscribe(), U.unsubscribe(), V.unsubscribe(), T.unsubscribe();
|
|
536
|
+
};
|
|
537
|
+
}), e.user_effect(() => (r.start(), () => {
|
|
538
|
+
r.setContext(null), r.stop();
|
|
539
|
+
}));
|
|
540
|
+
const E = e.derived(() => a.enabled ?? !0), M = e.derived(() => {
|
|
541
|
+
var v;
|
|
542
|
+
return ((v = t.threadEndpoints) == null ? void 0 : v.list) !== !1;
|
|
543
|
+
}), x = e.derived(() => {
|
|
544
|
+
var v;
|
|
545
|
+
return ((v = t.threadEndpoints) == null ? void 0 : v.mutations) !== !1;
|
|
546
|
+
}), k = e.derived(() => !!t.runtimeUrl && t.runtimeConnectionStatus === ve.Connected && !e.get(M)), A = e.derived(() => e.get(x) ? null : new Error("Thread mutations are not available on this CopilotKit runtime")), h = e.derived(() => e.get(k) ? new Error("Thread endpoints are not available on this CopilotKit runtime") : null);
|
|
547
|
+
e.user_effect(() => {
|
|
548
|
+
const v = a.enabled ?? !0, l = t.runtimeUrl, w = t.runtimeConnectionStatus, F = t.headers, U = t.threadEndpoints, V = t.intelligence, T = a.agentId, K = a.includeArchived, C = a.limit, I = (U == null ? void 0 : U.list) !== !1, B = () => {
|
|
549
|
+
e.get(R) && r.setContext(null), e.set(R, !1);
|
|
550
|
+
};
|
|
551
|
+
if (!v) {
|
|
552
|
+
B();
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (!l) {
|
|
556
|
+
B();
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (w !== ve.Connected)
|
|
560
|
+
return;
|
|
561
|
+
if (!I) {
|
|
562
|
+
B();
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const Y = {
|
|
566
|
+
runtimeUrl: l,
|
|
567
|
+
headers: { ...F },
|
|
568
|
+
wsUrl: V == null ? void 0 : V.wsUrl,
|
|
569
|
+
agentId: T,
|
|
570
|
+
includeArchived: K,
|
|
571
|
+
limit: C
|
|
572
|
+
};
|
|
573
|
+
r.setContext(Y), e.set(R, !0);
|
|
574
|
+
}), e.user_effect(() => {
|
|
575
|
+
const v = a.enabled ?? !0, l = a.agentId;
|
|
576
|
+
if (v)
|
|
577
|
+
return n.registerThreadStore(l, r), () => {
|
|
578
|
+
n.getThreadStore(l) === r && n.unregisterThreadStore(l);
|
|
579
|
+
};
|
|
580
|
+
});
|
|
581
|
+
const d = e.derived(() => t.runtimeUrl ? null : new Error("Runtime URL is not configured")), y = e.derived(() => !!t.runtimeUrl && e.get(E) && !e.get(k) && !e.get(R)), b = e.derived(() => e.get(d) || e.get(h) ? !1 : e.get(y) || e.get(o)), i = e.derived(() => e.get(d) ?? e.get(h) ?? e.get(g)), f = e.derived(() => e.get(g));
|
|
582
|
+
function P(v) {
|
|
583
|
+
return (...l) => e.get(A) ? Promise.reject(e.get(A)) : v(...l);
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
get threads() {
|
|
587
|
+
return e.get(s).map(({ id: v, agentId: l, name: w, archived: F, createdAt: U, updatedAt: V, lastRunAt: T }) => ({
|
|
588
|
+
id: v,
|
|
589
|
+
agentId: l,
|
|
590
|
+
name: w,
|
|
591
|
+
archived: F,
|
|
592
|
+
createdAt: U,
|
|
593
|
+
updatedAt: V,
|
|
594
|
+
...T !== void 0 ? { lastRunAt: T } : {}
|
|
595
|
+
}));
|
|
596
|
+
},
|
|
597
|
+
get isLoading() {
|
|
598
|
+
return e.get(b);
|
|
599
|
+
},
|
|
600
|
+
get error() {
|
|
601
|
+
return e.get(i);
|
|
602
|
+
},
|
|
603
|
+
get listError() {
|
|
604
|
+
return e.get(f);
|
|
605
|
+
},
|
|
606
|
+
get fetchMoreError() {
|
|
607
|
+
return e.get(c);
|
|
608
|
+
},
|
|
609
|
+
get hasMoreThreads() {
|
|
610
|
+
return e.get(p);
|
|
611
|
+
},
|
|
612
|
+
get isFetchingMoreThreads() {
|
|
613
|
+
return e.get(m);
|
|
614
|
+
},
|
|
615
|
+
get isMutating() {
|
|
616
|
+
return e.get(_);
|
|
617
|
+
},
|
|
618
|
+
fetchMoreThreads: () => r.fetchNextPage(),
|
|
619
|
+
refetchThreads: () => r.refetchThreads(),
|
|
620
|
+
renameThread: P((v, l) => r.renameThread(v, l)),
|
|
621
|
+
archiveThread: P((v) => r.archiveThread(v)),
|
|
622
|
+
unarchiveThread: P((v) => r.unarchiveThread(v)),
|
|
623
|
+
deleteThread: P((v) => r.deleteThread(v))
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function xe(a) {
|
|
627
|
+
return typeof a == "function" ? a() : a;
|
|
628
|
+
}
|
|
629
|
+
function zt(a) {
|
|
630
|
+
let t = e.state(e.proxy([])), n = e.state(!1), r = e.state(null), s = e.state(null), o = [];
|
|
631
|
+
const g = e.derived(() => xe(a.config)), c = e.derived(() => {
|
|
632
|
+
var i;
|
|
633
|
+
return ((i = e.get(g)) == null ? void 0 : i.enabled) ?? !1;
|
|
634
|
+
});
|
|
635
|
+
function p(i) {
|
|
636
|
+
e.set(r, i, !0);
|
|
637
|
+
}
|
|
638
|
+
function m(i) {
|
|
639
|
+
e.set(s, i, !0);
|
|
640
|
+
}
|
|
641
|
+
function _(i) {
|
|
642
|
+
return e.set(r, i, !0), {
|
|
643
|
+
destroy() {
|
|
644
|
+
e.get(r) === i && e.set(r, null);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function R(i) {
|
|
649
|
+
return e.set(s, i, !0), {
|
|
650
|
+
destroy() {
|
|
651
|
+
e.get(s) === i && e.set(s, null);
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
const L = (i) => {
|
|
656
|
+
e.set(t, i, !0), o = i;
|
|
657
|
+
}, E = (i) => {
|
|
658
|
+
L(i(o));
|
|
659
|
+
};
|
|
660
|
+
async function M(i) {
|
|
661
|
+
var F, U, V;
|
|
662
|
+
const f = xe(a.config), P = (f == null ? void 0 : f.accept) ?? "*/*", v = (f == null ? void 0 : f.maxSize) ?? 20 * 1024 * 1024, l = i.filter((T) => !Te(T, P));
|
|
663
|
+
for (const T of l)
|
|
664
|
+
(F = f == null ? void 0 : f.onUploadFailed) == null || F.call(f, {
|
|
665
|
+
reason: "invalid-type",
|
|
666
|
+
file: T,
|
|
667
|
+
message: `File "${T.name}" is not accepted. Supported types: ${P}`
|
|
668
|
+
});
|
|
669
|
+
const w = i.filter((T) => Te(T, P));
|
|
670
|
+
for (const T of w) {
|
|
671
|
+
if (ct(T, v)) {
|
|
672
|
+
(U = f == null ? void 0 : f.onUploadFailed) == null || U.call(f, {
|
|
673
|
+
reason: "file-too-large",
|
|
674
|
+
file: T,
|
|
675
|
+
message: `File "${T.name}" exceeds the maximum size of ${We(v)}`
|
|
676
|
+
});
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
const K = ut(T.type), C = Ie();
|
|
680
|
+
E((I) => [
|
|
681
|
+
...I,
|
|
682
|
+
{
|
|
683
|
+
id: C,
|
|
684
|
+
type: K,
|
|
685
|
+
source: { type: "data", value: "", mimeType: T.type },
|
|
686
|
+
filename: T.name,
|
|
687
|
+
size: T.size,
|
|
688
|
+
status: "uploading"
|
|
689
|
+
}
|
|
690
|
+
]);
|
|
691
|
+
try {
|
|
692
|
+
let I, B;
|
|
693
|
+
if (f != null && f.onUpload) {
|
|
694
|
+
const z = await f.onUpload(T), { metadata: u, ...S } = z;
|
|
695
|
+
I = S, B = u;
|
|
696
|
+
} else
|
|
697
|
+
I = { type: "data", value: await gt(T), mimeType: T.type };
|
|
698
|
+
let Y;
|
|
699
|
+
K === "video" && (Y = await pt(T)), E((z) => z.map((u) => u.id === C ? {
|
|
700
|
+
...u,
|
|
701
|
+
source: I,
|
|
702
|
+
status: "ready",
|
|
703
|
+
thumbnail: Y,
|
|
704
|
+
metadata: B
|
|
705
|
+
} : u));
|
|
706
|
+
} catch (I) {
|
|
707
|
+
E((B) => B.filter((Y) => Y.id !== C)), console.error(`[CopilotKit] Failed to upload "${T.name}":`, I), (V = f == null ? void 0 : f.onUploadFailed) == null || V.call(f, {
|
|
708
|
+
reason: "upload-failed",
|
|
709
|
+
file: T,
|
|
710
|
+
message: I instanceof Error ? I.message : `Failed to upload "${T.name}"`
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
async function x(i) {
|
|
716
|
+
var P;
|
|
717
|
+
const f = i.target;
|
|
718
|
+
(P = f == null ? void 0 : f.files) != null && P.length && (await M(Array.from(f.files)), f && (f.value = ""));
|
|
719
|
+
}
|
|
720
|
+
function k(i) {
|
|
721
|
+
e.get(c) && (i.preventDefault(), i.stopPropagation(), e.set(n, !0));
|
|
722
|
+
}
|
|
723
|
+
function A(i) {
|
|
724
|
+
i.preventDefault(), i.stopPropagation(), e.set(n, !1);
|
|
725
|
+
}
|
|
726
|
+
async function h(i) {
|
|
727
|
+
var P;
|
|
728
|
+
if (i.preventDefault(), i.stopPropagation(), e.set(n, !1), !e.get(c)) return;
|
|
729
|
+
const f = Array.from(((P = i.dataTransfer) == null ? void 0 : P.files) ?? []);
|
|
730
|
+
f.length > 0 && await M(f);
|
|
731
|
+
}
|
|
732
|
+
function d(i) {
|
|
733
|
+
E((f) => f.filter((P) => P.id !== i));
|
|
734
|
+
}
|
|
735
|
+
function y() {
|
|
736
|
+
const i = o.filter((f) => f.status === "ready");
|
|
737
|
+
return i.length === 0 || (E((f) => f.filter((P) => P.status !== "ready")), e.get(r) && (e.get(r).value = "")), i;
|
|
738
|
+
}
|
|
739
|
+
async function b(i) {
|
|
740
|
+
var V;
|
|
741
|
+
const f = xe(a.config);
|
|
742
|
+
if (!((f == null ? void 0 : f.enabled) ?? !1)) return;
|
|
743
|
+
const P = i.target, v = e.get(s);
|
|
744
|
+
if (!P || !(v != null && v.contains(P))) return;
|
|
745
|
+
const l = (f == null ? void 0 : f.accept) ?? "*/*", F = Array.from(((V = i.clipboardData) == null ? void 0 : V.items) ?? []).filter((T) => {
|
|
746
|
+
if (T.kind !== "file") return !1;
|
|
747
|
+
const K = T.getAsFile();
|
|
748
|
+
return K !== null && Te(K, l);
|
|
749
|
+
});
|
|
750
|
+
if (F.length === 0) return;
|
|
751
|
+
i.preventDefault();
|
|
752
|
+
const U = F.map((T) => T.getAsFile()).filter((T) => T !== null);
|
|
753
|
+
await M(U);
|
|
754
|
+
}
|
|
755
|
+
return e.user_effect(() => {
|
|
756
|
+
if (!(typeof document > "u"))
|
|
757
|
+
return document.addEventListener("paste", b), () => {
|
|
758
|
+
document.removeEventListener("paste", b);
|
|
759
|
+
};
|
|
760
|
+
}), {
|
|
761
|
+
get attachments() {
|
|
762
|
+
return e.get(t);
|
|
763
|
+
},
|
|
764
|
+
get enabled() {
|
|
765
|
+
return e.get(c);
|
|
766
|
+
},
|
|
767
|
+
get dragOver() {
|
|
768
|
+
return e.get(n);
|
|
769
|
+
},
|
|
770
|
+
get fileInputRef() {
|
|
771
|
+
return e.get(r);
|
|
772
|
+
},
|
|
773
|
+
get containerRef() {
|
|
774
|
+
return e.get(s);
|
|
775
|
+
},
|
|
776
|
+
setFileInputRef: p,
|
|
777
|
+
setContainerRef: m,
|
|
778
|
+
fileInputAction: _,
|
|
779
|
+
containerAction: R,
|
|
780
|
+
processFiles: M,
|
|
781
|
+
handleFileUpload: x,
|
|
782
|
+
handleDragOver: k,
|
|
783
|
+
handleDragLeave: A,
|
|
784
|
+
handleDrop: h,
|
|
785
|
+
removeAttachment: d,
|
|
786
|
+
consumeAttachments: y
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
let He = !1;
|
|
790
|
+
function jr() {
|
|
791
|
+
e.user_effect(() => {
|
|
792
|
+
He || typeof document > "u" || (He = !0, import("katex/dist/katex.min.css").catch(() => {
|
|
793
|
+
console.warn("[CopilotKit] Failed to load katex styles — math content may render without formatting");
|
|
794
|
+
}));
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function Kr(a) {
|
|
798
|
+
const t = Le({
|
|
799
|
+
get agentId() {
|
|
800
|
+
return typeof a == "function" ? a() : a;
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
return {
|
|
804
|
+
get capabilities() {
|
|
805
|
+
const n = t.agent;
|
|
806
|
+
if (n && "capabilities" in n)
|
|
807
|
+
return n.capabilities;
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
function $e() {
|
|
812
|
+
const a = oe(le);
|
|
813
|
+
if (!a)
|
|
814
|
+
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
815
|
+
return a;
|
|
816
|
+
}
|
|
817
|
+
class jt {
|
|
818
|
+
constructor(t, n, r) {
|
|
819
|
+
re(this, "agentId");
|
|
820
|
+
re(this, "threadId");
|
|
821
|
+
re(this, "hasExplicitThreadId");
|
|
822
|
+
re(this, "labels");
|
|
823
|
+
this.agentId = t, this.threadId = n, this.hasExplicitThreadId = r ?? !1, this.labels = {};
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
function Kt(a) {
|
|
827
|
+
Ge(Ye, a);
|
|
828
|
+
}
|
|
829
|
+
function Fe() {
|
|
830
|
+
return oe(Ye);
|
|
831
|
+
}
|
|
832
|
+
const Bt = {
|
|
833
|
+
js: "javascript",
|
|
834
|
+
jsx: "javascript",
|
|
835
|
+
mjs: "javascript",
|
|
836
|
+
cjs: "javascript",
|
|
837
|
+
ts: "typescript",
|
|
838
|
+
tsx: "typescript",
|
|
839
|
+
sh: "bash",
|
|
840
|
+
shell: "bash",
|
|
841
|
+
zsh: "bash",
|
|
842
|
+
yml: "yaml",
|
|
843
|
+
md: "markdown",
|
|
844
|
+
py: "python",
|
|
845
|
+
rb: "ruby",
|
|
846
|
+
rs: "rust",
|
|
847
|
+
"c++": "cpp",
|
|
848
|
+
cs: "csharp",
|
|
849
|
+
"c#": "csharp",
|
|
850
|
+
html: "xml",
|
|
851
|
+
svg: "xml"
|
|
852
|
+
}, Ht = {
|
|
853
|
+
bash: "sh",
|
|
854
|
+
c: "c",
|
|
855
|
+
cpp: "cpp",
|
|
856
|
+
csharp: "cs",
|
|
857
|
+
css: "css",
|
|
858
|
+
diff: "diff",
|
|
859
|
+
go: "go",
|
|
860
|
+
graphql: "graphql",
|
|
861
|
+
java: "java",
|
|
862
|
+
javascript: "js",
|
|
863
|
+
json: "json",
|
|
864
|
+
kotlin: "kt",
|
|
865
|
+
less: "less",
|
|
866
|
+
lua: "lua",
|
|
867
|
+
markdown: "md",
|
|
868
|
+
php: "php",
|
|
869
|
+
plaintext: "txt",
|
|
870
|
+
python: "py",
|
|
871
|
+
ruby: "rb",
|
|
872
|
+
rust: "rs",
|
|
873
|
+
scss: "scss",
|
|
874
|
+
sql: "sql",
|
|
875
|
+
swift: "swift",
|
|
876
|
+
typescript: "ts",
|
|
877
|
+
xml: "xml",
|
|
878
|
+
yaml: "yml"
|
|
879
|
+
};
|
|
880
|
+
function Pe(a) {
|
|
881
|
+
const t = a == null ? void 0 : a.trim().toLowerCase().split(/\s+/)[0];
|
|
882
|
+
if (t)
|
|
883
|
+
return Bt[t] ?? t;
|
|
884
|
+
}
|
|
885
|
+
function Nt(a) {
|
|
886
|
+
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
887
|
+
}
|
|
888
|
+
function qt(a, t) {
|
|
889
|
+
const n = Pe(t);
|
|
890
|
+
try {
|
|
891
|
+
if (n && we.getLanguage(n))
|
|
892
|
+
return we.highlight(a, { language: n, ignoreIllegals: !0 }).value;
|
|
893
|
+
if (a.trim().length > 0)
|
|
894
|
+
return we.highlightAuto(a).value;
|
|
895
|
+
} catch {
|
|
896
|
+
}
|
|
897
|
+
return Nt(a);
|
|
898
|
+
}
|
|
899
|
+
function Gt(a) {
|
|
900
|
+
return Pe(a) ?? "text";
|
|
901
|
+
}
|
|
902
|
+
function Wt(a) {
|
|
903
|
+
const t = Pe(a);
|
|
904
|
+
return `code.${t && Ht[t] || "txt"}`;
|
|
905
|
+
}
|
|
906
|
+
var Jt = e.from_html('<div data-streamdown="code-block"><div data-streamdown="code-block-header"><span data-testid="copilot-code-block-language"> </span> <div class="cpk:flex cpk:items-center cpk:gap-1"><button type="button" data-streamdown="code-block-copy-button" data-testid="copilot-code-block-copy"><!></button> <button type="button" data-streamdown="code-block-download-button" data-testid="copilot-code-block-download" aria-label="Download code" title="Download code"><!></button></div></div> <pre data-streamdown="code-block-body"><code class="hljs"></code></pre></div>');
|
|
907
|
+
function Xt(a, t) {
|
|
908
|
+
e.push(t, !0);
|
|
909
|
+
let n = e.prop(t, "lang", 3, ""), r = e.prop(t, "text", 3, ""), s = e.state(!1), o = null;
|
|
910
|
+
const g = e.derived(() => Gt(n())), c = e.derived(() => qt(r(), n()));
|
|
911
|
+
async function p() {
|
|
912
|
+
try {
|
|
913
|
+
await navigator.clipboard.writeText(r()), e.set(s, !0), o && clearTimeout(o), o = setTimeout(
|
|
914
|
+
() => {
|
|
915
|
+
e.set(s, !1);
|
|
916
|
+
},
|
|
917
|
+
2e3
|
|
918
|
+
);
|
|
919
|
+
} catch {
|
|
920
|
+
e.set(s, !1);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
function m() {
|
|
924
|
+
if (typeof document > "u") return;
|
|
925
|
+
const f = new Blob([r()], { type: "text/plain;charset=utf-8" }), P = URL.createObjectURL(f), v = document.createElement("a");
|
|
926
|
+
v.href = P, v.download = Wt(n()), document.body.appendChild(v), v.click(), v.remove(), URL.revokeObjectURL(P);
|
|
927
|
+
}
|
|
928
|
+
var _ = Jt(), R = e.child(_), L = e.child(R), E = e.only_child(L, !0), M = e.sibling(L, 2), x = e.child(M), k = e.child(x);
|
|
929
|
+
{
|
|
930
|
+
var A = (f) => {
|
|
931
|
+
Re(f, { class: "cpk:size-4" });
|
|
932
|
+
}, h = (f) => {
|
|
933
|
+
Ae(f, { class: "cpk:size-4" });
|
|
934
|
+
};
|
|
935
|
+
e.if(k, (f) => {
|
|
936
|
+
e.get(s) ? f(A) : f(h, -1);
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
e.reset(x);
|
|
940
|
+
var d = e.sibling(x, 2), y = e.child(d);
|
|
941
|
+
mt(y, { class: "cpk:size-4" }), e.reset(d), e.reset(M), e.reset(R);
|
|
942
|
+
var b = e.sibling(R, 2), i = e.child(b);
|
|
943
|
+
e.html(i, () => e.get(c), !0), e.reset(i), e.reset(b), e.reset(_), e.template_effect(() => {
|
|
944
|
+
e.set_text(E, e.get(g)), e.set_attribute(x, "aria-label", e.get(s) ? "Copied" : "Copy code"), e.set_attribute(x, "title", e.get(s) ? "Copied" : "Copy code");
|
|
945
|
+
}), e.delegated("click", x, p), e.delegated("click", d, m), e.append(a, _), e.pop();
|
|
946
|
+
}
|
|
947
|
+
e.delegate(["click"]);
|
|
948
|
+
var Yt = e.from_html('<code data-streamdown="inline-code"><!></code>');
|
|
949
|
+
function Qt(a, t) {
|
|
950
|
+
e.push(t, !0);
|
|
951
|
+
function n(p) {
|
|
952
|
+
return p.replace(/^`+/, "").replace(/`+$/, "");
|
|
953
|
+
}
|
|
954
|
+
const r = e.derived(() => typeof t.text == "string" ? n(t.text) : n(t.raw ?? ""));
|
|
955
|
+
var s = Yt(), o = e.child(s);
|
|
956
|
+
{
|
|
957
|
+
var g = (p) => {
|
|
958
|
+
var m = e.text();
|
|
959
|
+
e.template_effect(() => e.set_text(m, e.get(r))), e.append(p, m);
|
|
960
|
+
}, c = (p) => {
|
|
961
|
+
var m = e.comment(), _ = e.first_child(m);
|
|
962
|
+
e.snippet(_, () => t.children), e.append(p, m);
|
|
963
|
+
};
|
|
964
|
+
e.if(o, (p) => {
|
|
965
|
+
typeof t.text == "string" || t.raw !== void 0 ? p(g) : t.children && p(c, 1);
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
e.reset(s), e.append(a, s), e.pop();
|
|
969
|
+
}
|
|
970
|
+
var Zt = e.from_html('<div data-streamdown="table-wrapper"><div class="cpk:overflow-x-auto"><table data-streamdown="table"><!></table></div></div>');
|
|
971
|
+
function $t(a, t) {
|
|
972
|
+
var n = Zt(), r = e.child(n), s = e.child(r), o = e.child(s);
|
|
973
|
+
{
|
|
974
|
+
var g = (c) => {
|
|
975
|
+
var p = e.comment(), m = e.first_child(p);
|
|
976
|
+
e.snippet(m, () => t.children), e.append(c, p);
|
|
977
|
+
};
|
|
978
|
+
e.if(o, (c) => {
|
|
979
|
+
t.children && c(g);
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
e.reset(s), e.reset(r), e.reset(n), e.append(a, n);
|
|
983
|
+
}
|
|
984
|
+
var en = e.from_html('<thead data-streamdown="table-header"><!></thead>');
|
|
985
|
+
function tn(a, t) {
|
|
986
|
+
var n = en(), r = e.child(n);
|
|
987
|
+
{
|
|
988
|
+
var s = (o) => {
|
|
989
|
+
var g = e.comment(), c = e.first_child(g);
|
|
990
|
+
e.snippet(c, () => t.children), e.append(o, g);
|
|
991
|
+
};
|
|
992
|
+
e.if(r, (o) => {
|
|
993
|
+
t.children && o(s);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
e.reset(n), e.append(a, n);
|
|
997
|
+
}
|
|
998
|
+
var nn = e.from_html('<tbody data-streamdown="table-body"><!></tbody>');
|
|
999
|
+
function rn(a, t) {
|
|
1000
|
+
var n = nn(), r = e.child(n);
|
|
1001
|
+
{
|
|
1002
|
+
var s = (o) => {
|
|
1003
|
+
var g = e.comment(), c = e.first_child(g);
|
|
1004
|
+
e.snippet(c, () => t.children), e.append(o, g);
|
|
1005
|
+
};
|
|
1006
|
+
e.if(r, (o) => {
|
|
1007
|
+
t.children && o(s);
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
e.reset(n), e.append(a, n);
|
|
1011
|
+
}
|
|
1012
|
+
var an = e.from_html('<tr data-streamdown="table-row"><!></tr>');
|
|
1013
|
+
function sn(a, t) {
|
|
1014
|
+
var n = an(), r = e.child(n);
|
|
1015
|
+
{
|
|
1016
|
+
var s = (o) => {
|
|
1017
|
+
var g = e.comment(), c = e.first_child(g);
|
|
1018
|
+
e.snippet(c, () => t.children), e.append(o, g);
|
|
1019
|
+
};
|
|
1020
|
+
e.if(r, (o) => {
|
|
1021
|
+
t.children && o(s);
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
e.reset(n), e.append(a, n);
|
|
1025
|
+
}
|
|
1026
|
+
var on = e.from_html('<th data-streamdown="table-header-cell"><!></th>'), ln = e.from_html('<td data-streamdown="table-cell"><!></td>');
|
|
1027
|
+
function dn(a, t) {
|
|
1028
|
+
let n = e.prop(t, "header", 3, !1), r = e.prop(t, "align", 3, null);
|
|
1029
|
+
const s = e.derived(() => r() ? `text-align: ${r()};` : void 0);
|
|
1030
|
+
var o = e.comment(), g = e.first_child(o);
|
|
1031
|
+
{
|
|
1032
|
+
var c = (m) => {
|
|
1033
|
+
var _ = on(), R = e.child(_);
|
|
1034
|
+
{
|
|
1035
|
+
var L = (E) => {
|
|
1036
|
+
var M = e.comment(), x = e.first_child(M);
|
|
1037
|
+
e.snippet(x, () => t.children), e.append(E, M);
|
|
1038
|
+
};
|
|
1039
|
+
e.if(R, (E) => {
|
|
1040
|
+
t.children && E(L);
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
e.reset(_), e.template_effect(() => e.set_style(_, e.get(s))), e.append(m, _);
|
|
1044
|
+
}, p = (m) => {
|
|
1045
|
+
var _ = ln(), R = e.child(_);
|
|
1046
|
+
{
|
|
1047
|
+
var L = (E) => {
|
|
1048
|
+
var M = e.comment(), x = e.first_child(M);
|
|
1049
|
+
e.snippet(x, () => t.children), e.append(E, M);
|
|
1050
|
+
};
|
|
1051
|
+
e.if(R, (E) => {
|
|
1052
|
+
t.children && E(L);
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
e.reset(_), e.template_effect(() => e.set_style(_, e.get(s))), e.append(m, _);
|
|
1056
|
+
};
|
|
1057
|
+
e.if(g, (m) => {
|
|
1058
|
+
n() ? m(c) : m(p, -1);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
e.append(a, o);
|
|
1062
|
+
}
|
|
1063
|
+
function et(a, t) {
|
|
1064
|
+
let n = e.prop(t, "content", 3, "");
|
|
1065
|
+
const r = {
|
|
1066
|
+
code: Xt,
|
|
1067
|
+
codespan: Qt,
|
|
1068
|
+
table: $t,
|
|
1069
|
+
tablehead: tn,
|
|
1070
|
+
tablebody: rn,
|
|
1071
|
+
tablerow: sn,
|
|
1072
|
+
tablecell: dn
|
|
1073
|
+
};
|
|
1074
|
+
vt(a, {
|
|
1075
|
+
get source() {
|
|
1076
|
+
return n();
|
|
1077
|
+
},
|
|
1078
|
+
streaming: !0,
|
|
1079
|
+
get renderers() {
|
|
1080
|
+
return r;
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
var Me = e.from_html("<!> <span> </span>", 1), cn = e.from_html('<div class="cpk:flex cpk:items-center cpk:gap-2 cpk:py-1 cpk:text-sm cpk:text-muted-foreground"><!></div>');
|
|
1085
|
+
function un(a, t) {
|
|
1086
|
+
e.push(t, !0);
|
|
1087
|
+
let n = e.prop(t, "messages", 19, () => []);
|
|
1088
|
+
const { copilotkit: r, executingToolCallIds: s } = $e(), o = Fe();
|
|
1089
|
+
let g = e.state(e.proxy([]));
|
|
1090
|
+
e.user_effect(() => {
|
|
1091
|
+
const d = r;
|
|
1092
|
+
e.set(g, [...d.renderToolCalls ?? []], !0);
|
|
1093
|
+
const y = d.subscribe({
|
|
1094
|
+
onRenderToolCallsChanged: (b) => {
|
|
1095
|
+
e.set(g, [...b.renderToolCalls ?? []], !0);
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
return () => y.unsubscribe();
|
|
1099
|
+
});
|
|
1100
|
+
function c(d) {
|
|
1101
|
+
return n().find((y) => y.role === "tool" && y.toolCallId === d);
|
|
1102
|
+
}
|
|
1103
|
+
function p(d) {
|
|
1104
|
+
return s.has(d);
|
|
1105
|
+
}
|
|
1106
|
+
function m(d) {
|
|
1107
|
+
var b;
|
|
1108
|
+
const y = (b = c(d)) == null ? void 0 : b.content;
|
|
1109
|
+
return y === void 0 ? void 0 : _(y);
|
|
1110
|
+
}
|
|
1111
|
+
function _(d) {
|
|
1112
|
+
return typeof d == "string" ? d : d.map((y) => "text" in y && typeof y.text == "string" ? y.text : JSON.stringify(y) ?? "").join("");
|
|
1113
|
+
}
|
|
1114
|
+
function R(d) {
|
|
1115
|
+
const y = Be(d);
|
|
1116
|
+
return y && typeof y == "object" && !Array.isArray(y) ? y : {};
|
|
1117
|
+
}
|
|
1118
|
+
function L(d, y) {
|
|
1119
|
+
const b = e.get(g).find((i) => i.name === d && i.agentId === y);
|
|
1120
|
+
return b || e.get(g).find((i) => i.name === d && !i.agentId);
|
|
1121
|
+
}
|
|
1122
|
+
function E(d) {
|
|
1123
|
+
const y = (o == null ? void 0 : o.agentId) || me;
|
|
1124
|
+
return L(d, y) ?? L("*", y);
|
|
1125
|
+
}
|
|
1126
|
+
function M(d) {
|
|
1127
|
+
const y = c(d.id), b = Be(d.function.arguments);
|
|
1128
|
+
return y ? {
|
|
1129
|
+
name: d.function.name,
|
|
1130
|
+
args: b,
|
|
1131
|
+
status: fe.Complete,
|
|
1132
|
+
result: _(y.content),
|
|
1133
|
+
toolCall: d,
|
|
1134
|
+
toolMessage: y
|
|
1135
|
+
} : {
|
|
1136
|
+
name: d.function.name,
|
|
1137
|
+
args: b,
|
|
1138
|
+
status: p(d.id) ? fe.Executing : fe.InProgress,
|
|
1139
|
+
result: void 0,
|
|
1140
|
+
toolCall: d,
|
|
1141
|
+
toolMessage: void 0
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
function x(d) {
|
|
1145
|
+
const y = c(d.id), b = R(d.function.arguments);
|
|
1146
|
+
return y ? {
|
|
1147
|
+
name: d.function.name,
|
|
1148
|
+
toolCallId: d.id,
|
|
1149
|
+
args: b,
|
|
1150
|
+
status: fe.Complete,
|
|
1151
|
+
result: _(y.content)
|
|
1152
|
+
} : p(d.id) ? {
|
|
1153
|
+
name: d.function.name,
|
|
1154
|
+
toolCallId: d.id,
|
|
1155
|
+
args: b,
|
|
1156
|
+
status: fe.Executing,
|
|
1157
|
+
result: void 0
|
|
1158
|
+
} : {
|
|
1159
|
+
name: d.function.name,
|
|
1160
|
+
toolCallId: d.id,
|
|
1161
|
+
args: b,
|
|
1162
|
+
status: fe.InProgress,
|
|
1163
|
+
result: void 0
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
function k(d) {
|
|
1167
|
+
return d;
|
|
1168
|
+
}
|
|
1169
|
+
var A = e.comment(), h = e.first_child(A);
|
|
1170
|
+
e.each(h, 17, () => t.message.toolCalls ?? [], (d) => d.id, (d, y) => {
|
|
1171
|
+
var b = e.comment(), i = e.first_child(b);
|
|
1172
|
+
{
|
|
1173
|
+
var f = (v) => {
|
|
1174
|
+
var l = e.comment(), w = e.first_child(l);
|
|
1175
|
+
{
|
|
1176
|
+
let F = e.derived(() => M(e.get(y)));
|
|
1177
|
+
e.snippet(w, () => t.toolCall, () => e.get(F));
|
|
1178
|
+
}
|
|
1179
|
+
e.append(v, l);
|
|
1180
|
+
}, P = (v) => {
|
|
1181
|
+
const l = e.derived(() => E(e.get(y).function.name));
|
|
1182
|
+
var w = e.comment(), F = e.first_child(w);
|
|
1183
|
+
{
|
|
1184
|
+
var U = (T) => {
|
|
1185
|
+
const K = e.derived(() => e.get(l).render(x(e.get(y))));
|
|
1186
|
+
var C = e.comment(), I = e.first_child(C);
|
|
1187
|
+
{
|
|
1188
|
+
var B = (z) => {
|
|
1189
|
+
var u = e.text();
|
|
1190
|
+
e.template_effect(() => e.set_text(u, e.get(K))), e.append(z, u);
|
|
1191
|
+
}, Y = (z) => {
|
|
1192
|
+
var u = e.comment(), S = e.first_child(u);
|
|
1193
|
+
e.snippet(S, () => e.get(K)), e.append(z, u);
|
|
1194
|
+
};
|
|
1195
|
+
e.if(I, (z) => {
|
|
1196
|
+
typeof e.get(K) == "string" || typeof e.get(K) == "number" ? z(B) : typeof e.get(K) == "function" && z(Y, 1);
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
e.append(T, C);
|
|
1200
|
+
}, V = (T) => {
|
|
1201
|
+
var K = cn(), C = e.child(K);
|
|
1202
|
+
{
|
|
1203
|
+
var I = (S) => {
|
|
1204
|
+
var O = Me(), N = e.first_child(O);
|
|
1205
|
+
ht(N, { class: "cpk:size-4 cpk:animate-spin" });
|
|
1206
|
+
var G = e.sibling(N, 2), J = e.only_child(G, !0);
|
|
1207
|
+
e.template_effect(() => e.set_text(J, e.get(y).function.name)), e.append(S, O);
|
|
1208
|
+
}, B = e.derived(() => p(e.get(y).id)), Y = (S) => {
|
|
1209
|
+
var O = Me(), N = e.first_child(O);
|
|
1210
|
+
_t(N, { class: "cpk:size-4 cpk:text-green-500" });
|
|
1211
|
+
var G = e.sibling(N, 2), J = e.only_child(G, !0);
|
|
1212
|
+
e.template_effect(() => e.set_text(J, e.get(y).function.name)), e.append(S, O);
|
|
1213
|
+
}, z = e.derived(() => m(e.get(y).id)), u = (S) => {
|
|
1214
|
+
var O = Me(), N = e.first_child(O);
|
|
1215
|
+
bt(N, { class: "cpk:size-4 cpk:text-muted-foreground" });
|
|
1216
|
+
var G = e.sibling(N, 2), J = e.only_child(G, !0);
|
|
1217
|
+
e.template_effect(() => e.set_text(J, e.get(y).function.name)), e.append(S, O);
|
|
1218
|
+
};
|
|
1219
|
+
e.if(C, (S) => {
|
|
1220
|
+
e.get(B) ? S(I) : e.get(z) ? S(Y, 1) : S(u, -1);
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
e.reset(K), e.append(T, K);
|
|
1224
|
+
};
|
|
1225
|
+
e.if(F, (T) => {
|
|
1226
|
+
e.get(l) ? T(U) : T(V, -1);
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
e.append(v, w);
|
|
1230
|
+
};
|
|
1231
|
+
e.if(i, (v) => {
|
|
1232
|
+
t.toolCall ? v(f) : v(P, -1);
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
e.append(d, b);
|
|
1236
|
+
}), e.append(a, A), e.pop();
|
|
1237
|
+
}
|
|
1238
|
+
var gn = e.from_html('<button data-testid="copilot-copy-button" type="button"><!></button>'), be = e.from_html('<button type="button"><!></button>'), pn = e.from_html('<div class="cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:-ml-[5px] cpk:-mt-[0px]"><div class="cpk:flex cpk:items-center cpk:gap-1"><!> <!> <!> <!> <!> <!></div></div>'), fn = e.from_html('<div data-copilotkit="" data-testid="copilot-assistant-message" class="cpk:w-full cpk:group cpk:pt-10"><div class="cpk:prose cpk:max-w-full cpk:break-words cpk:dark:prose-invert"><!></div> <div class="cpk:flex cpk:w-full cpk:flex-col cpk:items-stretch"><!></div> <!></div>');
|
|
1239
|
+
function vn(a, t) {
|
|
1240
|
+
e.push(t, !0);
|
|
1241
|
+
const n = {
|
|
1242
|
+
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
1243
|
+
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
1244
|
+
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
1245
|
+
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
1246
|
+
assistantMessageToolbarRegenerateLabel: "Regenerate"
|
|
1247
|
+
};
|
|
1248
|
+
let r = e.prop(t, "messages", 19, () => []), s = e.prop(t, "isRunning", 3, !1), o = e.prop(t, "toolbarVisible", 3, !0), g = e.state(!1), c = null;
|
|
1249
|
+
const p = Fe(), m = { ...n, ...p == null ? void 0 : p.labels };
|
|
1250
|
+
function _(C) {
|
|
1251
|
+
return C ? typeof C == "string" ? C : Array.isArray(C) ? C.map((I) => I && typeof I == "object" && "type" in I && I.type === "text" && typeof I.text == "string" ? I.text : "").filter((I) => I.length > 0).join(`
|
|
1252
|
+
`) : "" : "";
|
|
1253
|
+
}
|
|
1254
|
+
const R = e.derived(() => _(t.message.content)), L = e.derived(() => e.get(R).trim().length > 0), E = e.derived(() => {
|
|
1255
|
+
var C;
|
|
1256
|
+
return ((C = r().filter((I) => I.role === "assistant").at(-1)) == null ? void 0 : C.id) === t.message.id;
|
|
1257
|
+
}), M = e.derived(() => o() && e.get(L) && !(s() && e.get(E)));
|
|
1258
|
+
function x() {
|
|
1259
|
+
c && clearTimeout(c), e.set(g, !0), c = setTimeout(
|
|
1260
|
+
() => {
|
|
1261
|
+
e.set(g, !1), c = null;
|
|
1262
|
+
},
|
|
1263
|
+
2e3
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
async function k() {
|
|
1267
|
+
var C;
|
|
1268
|
+
if (e.get(R) && !(typeof navigator > "u" || typeof ((C = navigator.clipboard) == null ? void 0 : C.writeText) != "function"))
|
|
1269
|
+
try {
|
|
1270
|
+
await navigator.clipboard.writeText(e.get(R)), x();
|
|
1271
|
+
} catch (I) {
|
|
1272
|
+
console.error("Failed to copy to clipboard:", I);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
function A() {
|
|
1276
|
+
var C;
|
|
1277
|
+
(C = t.onThumbsUp) == null || C.call(t, t.message);
|
|
1278
|
+
}
|
|
1279
|
+
function h() {
|
|
1280
|
+
var C;
|
|
1281
|
+
(C = t.onThumbsDown) == null || C.call(t, t.message);
|
|
1282
|
+
}
|
|
1283
|
+
function d() {
|
|
1284
|
+
var C;
|
|
1285
|
+
(C = t.onReadAloud) == null || C.call(t, t.message);
|
|
1286
|
+
}
|
|
1287
|
+
function y() {
|
|
1288
|
+
var C;
|
|
1289
|
+
(C = t.onRegenerate) == null || C.call(t, t.message);
|
|
1290
|
+
}
|
|
1291
|
+
const b = "cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0 cpk:cursor-pointer cpk:text-[rgb(93,93,93)] cpk:transition-colors cpk:hover:bg-[#E8E8E8] cpk:hover:text-[rgb(93,93,93)] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030] cpk:dark:hover:text-[rgb(243,243,243)] cpk:disabled:pointer-events-none cpk:disabled:opacity-50";
|
|
1292
|
+
var i = fn(), f = e.child(i), P = e.child(f);
|
|
1293
|
+
{
|
|
1294
|
+
var v = (C) => {
|
|
1295
|
+
var I = e.comment(), B = e.first_child(I);
|
|
1296
|
+
e.snippet(B, () => t.messageRenderer, () => ({ message: t.message, content: e.get(R) })), e.append(C, I);
|
|
1297
|
+
}, l = (C) => {
|
|
1298
|
+
var I = e.comment(), B = e.first_child(I);
|
|
1299
|
+
{
|
|
1300
|
+
var Y = (z) => {
|
|
1301
|
+
et(z, {
|
|
1302
|
+
get content() {
|
|
1303
|
+
return e.get(R);
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
};
|
|
1307
|
+
e.if(B, (z) => {
|
|
1308
|
+
e.get(L) && z(Y);
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
e.append(C, I);
|
|
1312
|
+
};
|
|
1313
|
+
e.if(P, (C) => {
|
|
1314
|
+
t.messageRenderer ? C(v) : C(l, -1);
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
e.reset(f);
|
|
1318
|
+
var w = e.sibling(f, 2), F = e.child(w);
|
|
1319
|
+
{
|
|
1320
|
+
var U = (C) => {
|
|
1321
|
+
var I = e.comment(), B = e.first_child(I);
|
|
1322
|
+
e.snippet(B, () => t.toolCallsView, () => ({ message: t.message, messages: r() })), e.append(C, I);
|
|
1323
|
+
}, V = (C) => {
|
|
1324
|
+
un(C, {
|
|
1325
|
+
get message() {
|
|
1326
|
+
return t.message;
|
|
1327
|
+
},
|
|
1328
|
+
get messages() {
|
|
1329
|
+
return r();
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1333
|
+
e.if(F, (C) => {
|
|
1334
|
+
t.toolCallsView ? C(U) : C(V, -1);
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
e.reset(w);
|
|
1338
|
+
var T = e.sibling(w, 2);
|
|
1339
|
+
{
|
|
1340
|
+
var K = (C) => {
|
|
1341
|
+
var I = e.comment(), B = e.first_child(I);
|
|
1342
|
+
{
|
|
1343
|
+
var Y = (u) => {
|
|
1344
|
+
var S = e.comment(), O = e.first_child(S);
|
|
1345
|
+
e.snippet(O, () => t.toolbar, () => ({
|
|
1346
|
+
message: t.message,
|
|
1347
|
+
shouldShowToolbar: e.get(M)
|
|
1348
|
+
})), e.append(u, S);
|
|
1349
|
+
}, z = (u) => {
|
|
1350
|
+
var S = pn(), O = e.child(S), N = e.child(O);
|
|
1351
|
+
{
|
|
1352
|
+
var G = (j) => {
|
|
1353
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1354
|
+
e.snippet(Z, () => t.copyButton, () => ({
|
|
1355
|
+
onCopy: k,
|
|
1356
|
+
copied: e.get(g),
|
|
1357
|
+
label: m.assistantMessageToolbarCopyMessageLabel
|
|
1358
|
+
})), e.append(j, W);
|
|
1359
|
+
}, J = (j) => {
|
|
1360
|
+
var W = gn();
|
|
1361
|
+
e.set_class(W, 1, e.clsx(b));
|
|
1362
|
+
var Z = e.child(W);
|
|
1363
|
+
{
|
|
1364
|
+
var ie = (H) => {
|
|
1365
|
+
Re(H, { class: "cpk:size-[18px]" });
|
|
1366
|
+
}, se = (H) => {
|
|
1367
|
+
Ae(H, { class: "cpk:size-[18px]" });
|
|
1368
|
+
};
|
|
1369
|
+
e.if(Z, (H) => {
|
|
1370
|
+
e.get(g) ? H(ie) : H(se, -1);
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
e.reset(W), e.template_effect(() => {
|
|
1374
|
+
e.set_attribute(W, "aria-label", m.assistantMessageToolbarCopyMessageLabel), e.set_attribute(W, "title", m.assistantMessageToolbarCopyMessageLabel);
|
|
1375
|
+
}), e.delegated("click", W, k), e.append(j, W);
|
|
1376
|
+
};
|
|
1377
|
+
e.if(N, (j) => {
|
|
1378
|
+
t.copyButton ? j(G) : j(J, -1);
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
var Q = e.sibling(N, 2);
|
|
1382
|
+
{
|
|
1383
|
+
var ae = (j) => {
|
|
1384
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1385
|
+
{
|
|
1386
|
+
var ie = (H) => {
|
|
1387
|
+
var D = e.comment(), te = e.first_child(D);
|
|
1388
|
+
e.snippet(te, () => t.thumbsUpButton, () => ({
|
|
1389
|
+
onThumbsUp: A,
|
|
1390
|
+
label: m.assistantMessageToolbarThumbsUpLabel
|
|
1391
|
+
})), e.append(H, D);
|
|
1392
|
+
}, se = (H) => {
|
|
1393
|
+
var D = be();
|
|
1394
|
+
e.set_class(D, 1, e.clsx(b));
|
|
1395
|
+
var te = e.child(D);
|
|
1396
|
+
kt(te, { class: "cpk:size-[18px]" }), e.reset(D), e.template_effect(() => {
|
|
1397
|
+
e.set_attribute(D, "aria-label", m.assistantMessageToolbarThumbsUpLabel), e.set_attribute(D, "title", m.assistantMessageToolbarThumbsUpLabel);
|
|
1398
|
+
}), e.delegated("click", D, A), e.append(H, D);
|
|
1399
|
+
};
|
|
1400
|
+
e.if(Z, (H) => {
|
|
1401
|
+
t.thumbsUpButton ? H(ie) : H(se, -1);
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
e.append(j, W);
|
|
1405
|
+
};
|
|
1406
|
+
e.if(Q, (j) => {
|
|
1407
|
+
t.onThumbsUp && j(ae);
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
var de = e.sibling(Q, 2);
|
|
1411
|
+
{
|
|
1412
|
+
var ee = (j) => {
|
|
1413
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1414
|
+
{
|
|
1415
|
+
var ie = (H) => {
|
|
1416
|
+
var D = e.comment(), te = e.first_child(D);
|
|
1417
|
+
e.snippet(te, () => t.thumbsDownButton, () => ({
|
|
1418
|
+
onThumbsDown: h,
|
|
1419
|
+
label: m.assistantMessageToolbarThumbsDownLabel
|
|
1420
|
+
})), e.append(H, D);
|
|
1421
|
+
}, se = (H) => {
|
|
1422
|
+
var D = be();
|
|
1423
|
+
e.set_class(D, 1, e.clsx(b));
|
|
1424
|
+
var te = e.child(D);
|
|
1425
|
+
yt(te, { class: "cpk:size-[18px]" }), e.reset(D), e.template_effect(() => {
|
|
1426
|
+
e.set_attribute(D, "aria-label", m.assistantMessageToolbarThumbsDownLabel), e.set_attribute(D, "title", m.assistantMessageToolbarThumbsDownLabel);
|
|
1427
|
+
}), e.delegated("click", D, h), e.append(H, D);
|
|
1428
|
+
};
|
|
1429
|
+
e.if(Z, (H) => {
|
|
1430
|
+
t.thumbsDownButton ? H(ie) : H(se, -1);
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
e.append(j, W);
|
|
1434
|
+
};
|
|
1435
|
+
e.if(de, (j) => {
|
|
1436
|
+
t.onThumbsDown && j(ee);
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
var $ = e.sibling(de, 2);
|
|
1440
|
+
{
|
|
1441
|
+
var q = (j) => {
|
|
1442
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1443
|
+
{
|
|
1444
|
+
var ie = (H) => {
|
|
1445
|
+
var D = e.comment(), te = e.first_child(D);
|
|
1446
|
+
e.snippet(te, () => t.readAloudButton, () => ({
|
|
1447
|
+
onReadAloud: d,
|
|
1448
|
+
label: m.assistantMessageToolbarReadAloudLabel
|
|
1449
|
+
})), e.append(H, D);
|
|
1450
|
+
}, se = (H) => {
|
|
1451
|
+
var D = be();
|
|
1452
|
+
e.set_class(D, 1, e.clsx(b));
|
|
1453
|
+
var te = e.child(D);
|
|
1454
|
+
Ct(te, { class: "cpk:size-[20px]" }), e.reset(D), e.template_effect(() => {
|
|
1455
|
+
e.set_attribute(D, "aria-label", m.assistantMessageToolbarReadAloudLabel), e.set_attribute(D, "title", m.assistantMessageToolbarReadAloudLabel);
|
|
1456
|
+
}), e.delegated("click", D, d), e.append(H, D);
|
|
1457
|
+
};
|
|
1458
|
+
e.if(Z, (H) => {
|
|
1459
|
+
t.readAloudButton ? H(ie) : H(se, -1);
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
e.append(j, W);
|
|
1463
|
+
};
|
|
1464
|
+
e.if($, (j) => {
|
|
1465
|
+
t.onReadAloud && j(q);
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
var X = e.sibling($, 2);
|
|
1469
|
+
{
|
|
1470
|
+
var ne = (j) => {
|
|
1471
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1472
|
+
{
|
|
1473
|
+
var ie = (H) => {
|
|
1474
|
+
var D = e.comment(), te = e.first_child(D);
|
|
1475
|
+
e.snippet(te, () => t.regenerateButton, () => ({
|
|
1476
|
+
onRegenerate: y,
|
|
1477
|
+
label: m.assistantMessageToolbarRegenerateLabel
|
|
1478
|
+
})), e.append(H, D);
|
|
1479
|
+
}, se = (H) => {
|
|
1480
|
+
var D = be();
|
|
1481
|
+
e.set_class(D, 1, e.clsx(b));
|
|
1482
|
+
var te = e.child(D);
|
|
1483
|
+
Tt(te, { class: "cpk:size-[18px]" }), e.reset(D), e.template_effect(() => {
|
|
1484
|
+
e.set_attribute(D, "aria-label", m.assistantMessageToolbarRegenerateLabel), e.set_attribute(D, "title", m.assistantMessageToolbarRegenerateLabel);
|
|
1485
|
+
}), e.delegated("click", D, y), e.append(H, D);
|
|
1486
|
+
};
|
|
1487
|
+
e.if(Z, (H) => {
|
|
1488
|
+
t.regenerateButton ? H(ie) : H(se, -1);
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
e.append(j, W);
|
|
1492
|
+
};
|
|
1493
|
+
e.if(X, (j) => {
|
|
1494
|
+
t.onRegenerate && j(ne);
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
var ue = e.sibling(X, 2);
|
|
1498
|
+
{
|
|
1499
|
+
var ge = (j) => {
|
|
1500
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1501
|
+
e.snippet(Z, () => t.toolbarItems), e.append(j, W);
|
|
1502
|
+
};
|
|
1503
|
+
e.if(ue, (j) => {
|
|
1504
|
+
t.toolbarItems && j(ge);
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
e.reset(O), e.reset(S), e.append(u, S);
|
|
1508
|
+
};
|
|
1509
|
+
e.if(B, (u) => {
|
|
1510
|
+
t.toolbar ? u(Y) : u(z, -1);
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
e.append(C, I);
|
|
1514
|
+
};
|
|
1515
|
+
e.if(T, (C) => {
|
|
1516
|
+
e.get(M) && C(K);
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
e.reset(i), e.template_effect(() => e.set_attribute(i, "data-message-id", t.message.id)), e.append(a, i), e.pop();
|
|
1520
|
+
}
|
|
1521
|
+
e.delegate(["click"]);
|
|
1522
|
+
function mn(a) {
|
|
1523
|
+
return !a || typeof a == "string" ? [] : a.filter(
|
|
1524
|
+
(t) => t.type === "image" || t.type === "audio" || t.type === "video" || t.type === "document"
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
function Ne(a) {
|
|
1528
|
+
var n;
|
|
1529
|
+
const t = (n = a.metadata) == null ? void 0 : n.filename;
|
|
1530
|
+
return typeof t == "string" ? t : void 0;
|
|
1531
|
+
}
|
|
1532
|
+
var hn = e.from_html('<img class="cpk:max-h-[80px] cpk:max-w-[80px] cpk:h-auto cpk:w-auto cpk:rounded-xl cpk:object-cover cpk:bg-muted" data-testid="copilot-user-message-image"/>'), _n = e.from_html('<video preload="metadata" class="cpk:max-h-[120px] cpk:max-w-[240px] cpk:rounded-xl cpk:bg-muted" data-testid="copilot-user-message-video"></video>', 2), bn = e.from_html('<audio controls="" preload="metadata" class="cpk:max-w-[300px] cpk:w-full cpk:h-10" data-testid="copilot-user-message-audio"></audio>'), kn = e.from_html('<div class="cpk:flex cpk:items-center cpk:gap-2 cpk:rounded-lg cpk:border cpk:border-border cpk:bg-muted cpk:px-3 cpk:py-2 cpk:text-sm" data-testid="copilot-user-message-document"><span class="cpk:font-semibold cpk:text-muted-foreground"> </span> <span> </span></div>'), yn = e.from_html('<div class="cpk:flex cpk:flex-row cpk:flex-wrap cpk:max-w-full cpk:justify-end cpk:gap-2 cpk:mb-2" data-testid="copilot-user-attachments"></div>'), Cn = e.from_html("<div> </div>"), Tn = e.from_html('<button data-testid="copilot-user-copy-button" type="button"><!></button>');
|
|
1533
|
+
e.from_html('<button type="button"><!></button>');
|
|
1534
|
+
var wn = e.from_html('<div class="cpk:flex cpk:items-center cpk:gap-1"><button type="button" aria-label="Previous branch" title="Previous branch"><!></button> <span class="cpk:text-sm cpk:text-muted-foreground cpk:px-0 cpk:font-medium"> </span> <button type="button" aria-label="Next branch" title="Next branch"><!></button></div>'), xn = e.from_html('<div class="cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:justify-end cpk:-mr-[5px] cpk:mt-[4px] cpk:opacity-0 cpk:group-hover:opacity-100 cpk:group-focus-within:opacity-100"><div class="cpk:flex cpk:items-center cpk:gap-1 cpk:justify-end"><!> <!> <!> <!></div></div>'), Mn = e.from_html('<div data-copilotkit="" data-testid="copilot-user-message" class="cpk:flex cpk:flex-col cpk:items-end cpk:w-full cpk:group cpk:pt-10"><!> <!> <!></div>');
|
|
1535
|
+
function In(a, t) {
|
|
1536
|
+
e.push(t, !0);
|
|
1537
|
+
const n = {
|
|
1538
|
+
userMessageToolbarCopyMessageLabel: "Copy",
|
|
1539
|
+
userMessageToolbarEditMessageLabel: "Edit"
|
|
1540
|
+
};
|
|
1541
|
+
let r = e.prop(t, "branchIndex", 3, 0), s = e.prop(t, "numberOfBranches", 3, 1), o = e.state(!1), g = null;
|
|
1542
|
+
function c(w) {
|
|
1543
|
+
return w ? typeof w == "string" ? w : w.map((F) => F && typeof F == "object" && "type" in F && F.type === "text" && typeof F.text == "string" ? F.text : "").filter((F) => F.length > 0).join(`
|
|
1544
|
+
`) : "";
|
|
1545
|
+
}
|
|
1546
|
+
const p = e.derived(() => c(t.message.content)), m = e.derived(() => e.get(p).includes(`
|
|
1547
|
+
`)), _ = e.derived(() => mn(t.message.content).filter((w) => pe(w.source).length > 0)), R = !1, L = e.derived(() => s() > 1), E = e.derived(() => r() > 0), M = e.derived(() => r() < s() - 1);
|
|
1548
|
+
function x() {
|
|
1549
|
+
g && clearTimeout(g), e.set(o, !0), g = setTimeout(
|
|
1550
|
+
() => {
|
|
1551
|
+
e.set(o, !1), g = null;
|
|
1552
|
+
},
|
|
1553
|
+
2e3
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
async function k() {
|
|
1557
|
+
var w;
|
|
1558
|
+
if (e.get(p) && !(typeof navigator > "u" || typeof ((w = navigator.clipboard) == null ? void 0 : w.writeText) != "function"))
|
|
1559
|
+
try {
|
|
1560
|
+
await navigator.clipboard.writeText(e.get(p)), x();
|
|
1561
|
+
} catch (F) {
|
|
1562
|
+
console.error("Failed to copy to clipboard:", F);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
function A() {
|
|
1566
|
+
typeof document < "u" && document.dispatchEvent(new CustomEvent("copilotkit:edit-message", { detail: { message: t.message } }));
|
|
1567
|
+
}
|
|
1568
|
+
function h(w) {
|
|
1569
|
+
typeof document < "u" && document.dispatchEvent(new CustomEvent("copilotkit:switch-branch", {
|
|
1570
|
+
detail: {
|
|
1571
|
+
branchIndex: w,
|
|
1572
|
+
numberOfBranches: s(),
|
|
1573
|
+
message: t.message
|
|
1574
|
+
}
|
|
1575
|
+
}));
|
|
1576
|
+
}
|
|
1577
|
+
function d() {
|
|
1578
|
+
e.get(E) && h(r() - 1);
|
|
1579
|
+
}
|
|
1580
|
+
function y() {
|
|
1581
|
+
e.get(M) && h(r() + 1);
|
|
1582
|
+
}
|
|
1583
|
+
const b = "cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0 cpk:cursor-pointer cpk:text-[rgb(93,93,93)] cpk:transition-colors cpk:hover:bg-[#E8E8E8] cpk:hover:text-[rgb(93,93,93)] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030] cpk:dark:hover:text-[rgb(243,243,243)] cpk:disabled:pointer-events-none cpk:disabled:opacity-50", i = e.derived(() => ({
|
|
1584
|
+
message: t.message,
|
|
1585
|
+
get content() {
|
|
1586
|
+
return e.get(p);
|
|
1587
|
+
},
|
|
1588
|
+
get isMultiline() {
|
|
1589
|
+
return e.get(m);
|
|
1590
|
+
},
|
|
1591
|
+
get showBranchNavigation() {
|
|
1592
|
+
return e.get(L);
|
|
1593
|
+
},
|
|
1594
|
+
get hasEditAction() {
|
|
1595
|
+
return R;
|
|
1596
|
+
},
|
|
1597
|
+
branchIndex: r(),
|
|
1598
|
+
numberOfBranches: s(),
|
|
1599
|
+
get canGoPrev() {
|
|
1600
|
+
return e.get(E);
|
|
1601
|
+
},
|
|
1602
|
+
get canGoNext() {
|
|
1603
|
+
return e.get(M);
|
|
1604
|
+
},
|
|
1605
|
+
onCopy: k,
|
|
1606
|
+
onEdit: A,
|
|
1607
|
+
goPrev: d,
|
|
1608
|
+
goNext: y,
|
|
1609
|
+
get copied() {
|
|
1610
|
+
return e.get(o);
|
|
1611
|
+
}
|
|
1612
|
+
}));
|
|
1613
|
+
var f = e.comment(), P = e.first_child(f);
|
|
1614
|
+
{
|
|
1615
|
+
var v = (w) => {
|
|
1616
|
+
var F = e.comment(), U = e.first_child(F);
|
|
1617
|
+
e.snippet(U, () => t.layout, () => e.get(i)), e.append(w, F);
|
|
1618
|
+
}, l = (w) => {
|
|
1619
|
+
var F = Mn(), U = e.child(F);
|
|
1620
|
+
{
|
|
1621
|
+
var V = (z) => {
|
|
1622
|
+
var u = yn();
|
|
1623
|
+
e.each(u, 21, () => e.get(_), e.index, (S, O) => {
|
|
1624
|
+
var N = e.comment(), G = e.first_child(N);
|
|
1625
|
+
{
|
|
1626
|
+
var J = (ee) => {
|
|
1627
|
+
var $ = hn();
|
|
1628
|
+
e.template_effect(
|
|
1629
|
+
(q, X) => {
|
|
1630
|
+
e.set_attribute($, "src", q), e.set_attribute($, "alt", X);
|
|
1631
|
+
},
|
|
1632
|
+
[
|
|
1633
|
+
() => pe(e.get(O).source),
|
|
1634
|
+
() => Ne(e.get(O)) ?? "Image attachment"
|
|
1635
|
+
]
|
|
1636
|
+
), e.append(ee, $);
|
|
1637
|
+
}, Q = (ee) => {
|
|
1638
|
+
var $ = _n();
|
|
1639
|
+
$.muted = !0, e.template_effect((q) => e.set_attribute($, "src", q), [() => pe(e.get(O).source)]), e.append(ee, $);
|
|
1640
|
+
}, ae = (ee) => {
|
|
1641
|
+
var $ = bn();
|
|
1642
|
+
e.template_effect((q) => e.set_attribute($, "src", q), [() => pe(e.get(O).source)]), e.append(ee, $);
|
|
1643
|
+
}, de = (ee) => {
|
|
1644
|
+
var $ = kn(), q = e.child($), X = e.only_child(q, !0), ne = e.sibling(q, 2), ue = e.only_child(ne, !0);
|
|
1645
|
+
e.reset($), e.template_effect(
|
|
1646
|
+
(ge, j) => {
|
|
1647
|
+
e.set_text(X, ge), e.set_text(ue, j);
|
|
1648
|
+
},
|
|
1649
|
+
[
|
|
1650
|
+
() => Je(e.get(O).source.mimeType ?? ""),
|
|
1651
|
+
() => Ne(e.get(O)) ?? "Document"
|
|
1652
|
+
]
|
|
1653
|
+
), e.append(ee, $);
|
|
1654
|
+
};
|
|
1655
|
+
e.if(G, (ee) => {
|
|
1656
|
+
e.get(O).type === "image" ? ee(J) : e.get(O).type === "video" ? ee(Q, 1) : e.get(O).type === "audio" ? ee(ae, 2) : ee(de, -1);
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
e.append(S, N);
|
|
1660
|
+
}), e.reset(u), e.append(z, u);
|
|
1661
|
+
};
|
|
1662
|
+
e.if(U, (z) => {
|
|
1663
|
+
e.get(_).length > 0 && z(V);
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
var T = e.sibling(U, 2);
|
|
1667
|
+
{
|
|
1668
|
+
var K = (z) => {
|
|
1669
|
+
var u = e.comment(), S = e.first_child(u);
|
|
1670
|
+
e.snippet(S, () => t.messageRenderer, () => ({
|
|
1671
|
+
message: t.message,
|
|
1672
|
+
content: e.get(p),
|
|
1673
|
+
isMultiline: e.get(m)
|
|
1674
|
+
})), e.append(z, u);
|
|
1675
|
+
}, C = (z) => {
|
|
1676
|
+
var u = Cn();
|
|
1677
|
+
let S;
|
|
1678
|
+
var O = e.only_child(u, !0);
|
|
1679
|
+
e.template_effect(() => {
|
|
1680
|
+
S = e.set_class(u, 1, "cpk:prose cpk:dark:prose-invert cpk:bg-muted cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:inline-block cpk:whitespace-pre-wrap", null, S, { "cpk:py-3": e.get(m) }), e.set_attribute(u, "data-multiline", e.get(m) ? "true" : void 0), e.set_text(O, e.get(p));
|
|
1681
|
+
}), e.append(z, u);
|
|
1682
|
+
};
|
|
1683
|
+
e.if(T, (z) => {
|
|
1684
|
+
t.messageRenderer ? z(K) : z(C, -1);
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
var I = e.sibling(T, 2);
|
|
1688
|
+
{
|
|
1689
|
+
var B = (z) => {
|
|
1690
|
+
var u = e.comment(), S = e.first_child(u);
|
|
1691
|
+
e.snippet(S, () => t.toolbar, () => ({
|
|
1692
|
+
message: t.message,
|
|
1693
|
+
showBranchNavigation: e.get(L),
|
|
1694
|
+
hasEditAction: R
|
|
1695
|
+
})), e.append(z, u);
|
|
1696
|
+
}, Y = (z) => {
|
|
1697
|
+
var u = xn(), S = e.child(u), O = e.child(S);
|
|
1698
|
+
{
|
|
1699
|
+
var N = (q) => {
|
|
1700
|
+
var X = e.comment(), ne = e.first_child(X);
|
|
1701
|
+
e.snippet(ne, () => t.toolbarItems), e.append(q, X);
|
|
1702
|
+
};
|
|
1703
|
+
e.if(O, (q) => {
|
|
1704
|
+
t.toolbarItems && q(N);
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
var G = e.sibling(O, 2);
|
|
1708
|
+
{
|
|
1709
|
+
var J = (q) => {
|
|
1710
|
+
var X = e.comment(), ne = e.first_child(X);
|
|
1711
|
+
e.snippet(ne, () => t.copyButton, () => ({
|
|
1712
|
+
onCopy: k,
|
|
1713
|
+
copied: e.get(o),
|
|
1714
|
+
label: n.userMessageToolbarCopyMessageLabel
|
|
1715
|
+
})), e.append(q, X);
|
|
1716
|
+
}, Q = (q) => {
|
|
1717
|
+
var X = Tn();
|
|
1718
|
+
e.set_class(X, 1, e.clsx(b));
|
|
1719
|
+
var ne = e.child(X);
|
|
1720
|
+
{
|
|
1721
|
+
var ue = (j) => {
|
|
1722
|
+
Re(j, { class: "cpk:size-[18px]" });
|
|
1723
|
+
}, ge = (j) => {
|
|
1724
|
+
Ae(j, { class: "cpk:size-[18px]" });
|
|
1725
|
+
};
|
|
1726
|
+
e.if(ne, (j) => {
|
|
1727
|
+
e.get(o) ? j(ue) : j(ge, -1);
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
e.reset(X), e.template_effect(() => {
|
|
1731
|
+
e.set_attribute(X, "aria-label", n.userMessageToolbarCopyMessageLabel), e.set_attribute(X, "title", n.userMessageToolbarCopyMessageLabel);
|
|
1732
|
+
}), e.delegated("click", X, k), e.append(q, X);
|
|
1733
|
+
};
|
|
1734
|
+
e.if(G, (q) => {
|
|
1735
|
+
t.copyButton ? q(J) : q(Q, -1);
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
var ae = e.sibling(G, 2);
|
|
1739
|
+
{
|
|
1740
|
+
var de = (q) => {
|
|
1741
|
+
var X = e.comment(), ne = e.first_child(X);
|
|
1742
|
+
e.snippet(ne, () => t.editButton, () => ({
|
|
1743
|
+
onEdit: A,
|
|
1744
|
+
label: n.userMessageToolbarEditMessageLabel
|
|
1745
|
+
})), e.append(q, X);
|
|
1746
|
+
};
|
|
1747
|
+
e.if(ae, (q) => {
|
|
1748
|
+
t.editButton && q(de);
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
var ee = e.sibling(ae, 2);
|
|
1752
|
+
{
|
|
1753
|
+
var $ = (q) => {
|
|
1754
|
+
var X = e.comment(), ne = e.first_child(X);
|
|
1755
|
+
{
|
|
1756
|
+
var ue = (j) => {
|
|
1757
|
+
var W = e.comment(), Z = e.first_child(W);
|
|
1758
|
+
e.snippet(Z, () => t.branchNavigation, () => ({
|
|
1759
|
+
branchIndex: r(),
|
|
1760
|
+
numberOfBranches: s(),
|
|
1761
|
+
canGoPrev: e.get(E),
|
|
1762
|
+
canGoNext: e.get(M),
|
|
1763
|
+
goPrev: d,
|
|
1764
|
+
goNext: y
|
|
1765
|
+
})), e.append(j, W);
|
|
1766
|
+
}, ge = (j) => {
|
|
1767
|
+
var W = wn(), Z = e.child(W);
|
|
1768
|
+
e.set_class(Z, 1, "cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0 cpk:cursor-pointer cpk:text-[rgb(93,93,93)] cpk:transition-colors cpk:hover:bg-[#E8E8E8] cpk:hover:text-[rgb(93,93,93)] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030] cpk:dark:hover:text-[rgb(243,243,243)] cpk:disabled:pointer-events-none cpk:disabled:opacity-50 cpk:h-6 cpk:w-6 cpk:p-0");
|
|
1769
|
+
var ie = e.child(Z);
|
|
1770
|
+
wt(ie, { class: "cpk:size-[20px]" }), e.reset(Z);
|
|
1771
|
+
var se = e.sibling(Z, 2), H = e.only_child(se), D = e.sibling(se, 2);
|
|
1772
|
+
e.set_class(D, 1, "cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0 cpk:cursor-pointer cpk:text-[rgb(93,93,93)] cpk:transition-colors cpk:hover:bg-[#E8E8E8] cpk:hover:text-[rgb(93,93,93)] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030] cpk:dark:hover:text-[rgb(243,243,243)] cpk:disabled:pointer-events-none cpk:disabled:opacity-50 cpk:h-6 cpk:w-6 cpk:p-0");
|
|
1773
|
+
var te = e.child(D);
|
|
1774
|
+
Xe(te, { class: "cpk:size-[20px]" }), e.reset(D), e.reset(W), e.template_effect(() => {
|
|
1775
|
+
Z.disabled = !e.get(E), e.set_text(H, `${r() + 1}/${s() ?? ""}`), D.disabled = !e.get(M);
|
|
1776
|
+
}), e.delegated("click", Z, d), e.delegated("click", D, y), e.append(j, W);
|
|
1777
|
+
};
|
|
1778
|
+
e.if(ne, (j) => {
|
|
1779
|
+
t.branchNavigation ? j(ue) : j(ge, -1);
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
e.append(q, X);
|
|
1783
|
+
};
|
|
1784
|
+
e.if(ee, (q) => {
|
|
1785
|
+
e.get(L) && q($);
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
e.reset(S), e.reset(u), e.append(z, u);
|
|
1789
|
+
};
|
|
1790
|
+
e.if(I, (z) => {
|
|
1791
|
+
t.toolbar ? z(B) : z(Y, -1);
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
e.reset(F), e.template_effect(() => e.set_attribute(F, "data-message-id", t.message.id)), e.append(w, F);
|
|
1795
|
+
};
|
|
1796
|
+
e.if(P, (w) => {
|
|
1797
|
+
t.layout ? w(v) : w(l, -1);
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
e.append(a, f), e.pop();
|
|
1801
|
+
}
|
|
1802
|
+
e.delegate(["click"]);
|
|
1803
|
+
var Sn = e.from_html('<span class="cpk:inline-flex cpk:items-center cpk:ml-1"><span class="cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"></span></span>'), Rn = e.from_html('<button type="button"><span class="cpk:font-medium"> </span> <!> <!></button>'), An = e.from_html('<span class="cpk:inline-flex cpk:items-center cpk:ml-1 cpk:align-middle"><span class="cpk:w-2 cpk:h-2 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"></span></span>'), En = e.from_html('<div class="cpk:pb-2 cpk:pt-1"><div class="cpk:text-sm cpk:text-muted-foreground"><!> <!></div></div>'), Ln = e.from_html('<div class="cpk:grid cpk:transition-[grid-template-rows] cpk:duration-200 cpk:ease-in-out"><div class="cpk:overflow-hidden"><!></div></div>'), Fn = e.from_html("<!> <!>", 1), Pn = e.from_html('<div data-copilotkit="" class="cpk:my-1"><!></div>');
|
|
1804
|
+
function On(a, t) {
|
|
1805
|
+
e.push(t, !0);
|
|
1806
|
+
let n = e.prop(t, "messages", 19, () => []), r = e.prop(t, "isRunning", 3, !1);
|
|
1807
|
+
function s(v) {
|
|
1808
|
+
if (v < 1) return "a few seconds";
|
|
1809
|
+
if (v < 60) return `${Math.round(v)} seconds`;
|
|
1810
|
+
const l = Math.floor(v / 60), w = Math.round(v % 60);
|
|
1811
|
+
return w === 0 ? `${l} minute${l > 1 ? "s" : ""}` : `${l}m ${w}s`;
|
|
1812
|
+
}
|
|
1813
|
+
const o = e.derived(() => typeof t.message.content == "string" ? t.message.content : ""), g = e.derived(() => e.get(o).length > 0), c = e.derived(() => {
|
|
1814
|
+
var v;
|
|
1815
|
+
return ((v = n()[n().length - 1]) == null ? void 0 : v.id) === t.message.id;
|
|
1816
|
+
}), p = e.derived(() => !!(r() && e.get(c)));
|
|
1817
|
+
let m = e.state(0), _ = e.state(!1), R = e.state(!1), L = null, E = null;
|
|
1818
|
+
function M() {
|
|
1819
|
+
E && (clearInterval(E), E = null);
|
|
1820
|
+
}
|
|
1821
|
+
function x() {
|
|
1822
|
+
L !== null && e.set(m, (Date.now() - L) / 1e3);
|
|
1823
|
+
}
|
|
1824
|
+
e.user_effect(() => (e.get(p) ? (L === null && (L = Date.now()), M(), E = setInterval(x, 1e3), e.set(R, !1), e.set(_, !0)) : (M(), x(), e.get(R) || e.set(_, !1)), () => {
|
|
1825
|
+
M();
|
|
1826
|
+
}));
|
|
1827
|
+
const k = e.derived(() => e.get(p) ? "Thinking…" : `Thought for ${s(e.get(m))}`);
|
|
1828
|
+
function A() {
|
|
1829
|
+
e.get(g) && (e.set(R, !0), e.set(_, !e.get(_)));
|
|
1830
|
+
}
|
|
1831
|
+
const h = e.derived(() => ({
|
|
1832
|
+
get isOpen() {
|
|
1833
|
+
return e.get(_);
|
|
1834
|
+
},
|
|
1835
|
+
get label() {
|
|
1836
|
+
return e.get(k);
|
|
1837
|
+
},
|
|
1838
|
+
get hasContent() {
|
|
1839
|
+
return e.get(g);
|
|
1840
|
+
},
|
|
1841
|
+
get isStreaming() {
|
|
1842
|
+
return e.get(p);
|
|
1843
|
+
},
|
|
1844
|
+
get onClick() {
|
|
1845
|
+
return e.get(g) ? A : void 0;
|
|
1846
|
+
}
|
|
1847
|
+
})), d = e.derived(() => ({
|
|
1848
|
+
get isStreaming() {
|
|
1849
|
+
return e.get(p);
|
|
1850
|
+
},
|
|
1851
|
+
get hasContent() {
|
|
1852
|
+
return e.get(g);
|
|
1853
|
+
},
|
|
1854
|
+
get content() {
|
|
1855
|
+
return e.get(o);
|
|
1856
|
+
}
|
|
1857
|
+
})), y = e.derived(() => ({
|
|
1858
|
+
get isOpen() {
|
|
1859
|
+
return e.get(_);
|
|
1860
|
+
},
|
|
1861
|
+
get contentView() {
|
|
1862
|
+
return e.get(d);
|
|
1863
|
+
}
|
|
1864
|
+
}));
|
|
1865
|
+
var b = Pn(), i = e.child(b);
|
|
1866
|
+
{
|
|
1867
|
+
var f = (v) => {
|
|
1868
|
+
var l = e.comment(), w = e.first_child(l);
|
|
1869
|
+
e.snippet(w, () => t.layout, () => ({
|
|
1870
|
+
message: t.message,
|
|
1871
|
+
messages: n(),
|
|
1872
|
+
isRunning: r(),
|
|
1873
|
+
header: e.get(h),
|
|
1874
|
+
contentView: e.get(d),
|
|
1875
|
+
toggle: e.get(y)
|
|
1876
|
+
})), e.append(v, l);
|
|
1877
|
+
}, P = (v) => {
|
|
1878
|
+
var l = Fn(), w = e.first_child(l);
|
|
1879
|
+
{
|
|
1880
|
+
var F = (C) => {
|
|
1881
|
+
var I = e.comment(), B = e.first_child(I);
|
|
1882
|
+
e.snippet(B, () => t.header, () => e.get(h)), e.append(C, I);
|
|
1883
|
+
}, U = (C) => {
|
|
1884
|
+
var I = Rn();
|
|
1885
|
+
let B;
|
|
1886
|
+
var Y = e.child(I), z = e.only_child(Y, !0), u = e.sibling(Y, 2);
|
|
1887
|
+
{
|
|
1888
|
+
var S = (G) => {
|
|
1889
|
+
var J = Sn();
|
|
1890
|
+
e.append(G, J);
|
|
1891
|
+
};
|
|
1892
|
+
e.if(u, (G) => {
|
|
1893
|
+
e.get(p) && !e.get(g) && G(S);
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
var O = e.sibling(u, 2);
|
|
1897
|
+
{
|
|
1898
|
+
var N = (G) => {
|
|
1899
|
+
{
|
|
1900
|
+
let J = e.derived(() => "cpk:size-3.5 cpk:shrink-0 cpk:transition-transform cpk:duration-200" + (e.get(_) ? " cpk:rotate-90" : ""));
|
|
1901
|
+
Xe(G, {
|
|
1902
|
+
get class() {
|
|
1903
|
+
return e.get(J);
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
e.if(O, (G) => {
|
|
1909
|
+
e.get(g) && G(N);
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
e.reset(I), e.template_effect(() => {
|
|
1913
|
+
B = e.set_class(I, 1, "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", null, B, {
|
|
1914
|
+
"cpk:hover:text-foreground": e.get(g),
|
|
1915
|
+
"cpk:cursor-pointer": e.get(g),
|
|
1916
|
+
"cpk:cursor-default": !e.get(g)
|
|
1917
|
+
}), e.set_attribute(I, "aria-expanded", e.get(g) ? e.get(_) : void 0), e.set_text(z, e.get(k));
|
|
1918
|
+
}), e.delegated("click", I, function(...G) {
|
|
1919
|
+
var J;
|
|
1920
|
+
(J = e.get(g) ? A : void 0) == null || J.apply(this, G);
|
|
1921
|
+
}), e.append(C, I);
|
|
1922
|
+
};
|
|
1923
|
+
e.if(w, (C) => {
|
|
1924
|
+
t.header ? C(F) : C(U, -1);
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
var V = e.sibling(w, 2);
|
|
1928
|
+
{
|
|
1929
|
+
var T = (C) => {
|
|
1930
|
+
var I = e.comment(), B = e.first_child(I);
|
|
1931
|
+
e.snippet(B, () => t.toggle, () => e.get(y)), e.append(C, I);
|
|
1932
|
+
}, K = (C) => {
|
|
1933
|
+
var I = Ln(), B = e.child(I), Y = e.child(B);
|
|
1934
|
+
{
|
|
1935
|
+
var z = (S) => {
|
|
1936
|
+
var O = e.comment(), N = e.first_child(O);
|
|
1937
|
+
e.snippet(N, () => t.contentView, () => e.get(d)), e.append(S, O);
|
|
1938
|
+
}, u = (S) => {
|
|
1939
|
+
var O = e.comment(), N = e.first_child(O);
|
|
1940
|
+
{
|
|
1941
|
+
var G = (J) => {
|
|
1942
|
+
var Q = En(), ae = e.child(Q), de = e.child(ae);
|
|
1943
|
+
et(de, {
|
|
1944
|
+
get content() {
|
|
1945
|
+
return e.get(o);
|
|
1946
|
+
}
|
|
1947
|
+
});
|
|
1948
|
+
var ee = e.sibling(de, 2);
|
|
1949
|
+
{
|
|
1950
|
+
var $ = (q) => {
|
|
1951
|
+
var X = An();
|
|
1952
|
+
e.append(q, X);
|
|
1953
|
+
};
|
|
1954
|
+
e.if(ee, (q) => {
|
|
1955
|
+
e.get(p) && e.get(g) && q($);
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
e.reset(ae), e.reset(Q), e.append(J, Q);
|
|
1959
|
+
};
|
|
1960
|
+
e.if(N, (J) => {
|
|
1961
|
+
(e.get(g) || e.get(p)) && J(G);
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
e.append(S, O);
|
|
1965
|
+
};
|
|
1966
|
+
e.if(Y, (S) => {
|
|
1967
|
+
t.contentView ? S(z) : S(u, -1);
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
e.reset(B), e.reset(I), e.template_effect(() => e.set_style(I, `grid-template-rows: ${e.get(_) ? "1fr" : "0fr"}`)), e.append(C, I);
|
|
1971
|
+
};
|
|
1972
|
+
e.if(V, (C) => {
|
|
1973
|
+
t.toggle ? C(T) : C(K, -1);
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
e.append(v, l);
|
|
1977
|
+
};
|
|
1978
|
+
e.if(i, (v) => {
|
|
1979
|
+
t.layout ? v(f) : v(P, -1);
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
e.reset(b), e.template_effect(() => e.set_attribute(b, "data-message-id", t.message.id)), e.append(a, b), e.pop();
|
|
1983
|
+
}
|
|
1984
|
+
e.delegate(["click"]);
|
|
1985
|
+
function Un(a, t) {
|
|
1986
|
+
let n = e.prop(t, "messages", 19, () => []), r = e.prop(t, "isRunning", 3, !1);
|
|
1987
|
+
function s(x) {
|
|
1988
|
+
return x.role === "assistant";
|
|
1989
|
+
}
|
|
1990
|
+
function o(x) {
|
|
1991
|
+
return x.role === "user";
|
|
1992
|
+
}
|
|
1993
|
+
function g(x) {
|
|
1994
|
+
return x.role === "reasoning";
|
|
1995
|
+
}
|
|
1996
|
+
var c = e.comment(), p = e.first_child(c);
|
|
1997
|
+
{
|
|
1998
|
+
var m = (x) => {
|
|
1999
|
+
On(x, {
|
|
2000
|
+
get message() {
|
|
2001
|
+
return t.message;
|
|
2002
|
+
},
|
|
2003
|
+
get messages() {
|
|
2004
|
+
return n();
|
|
2005
|
+
},
|
|
2006
|
+
get isRunning() {
|
|
2007
|
+
return r();
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
}, _ = e.derived(() => g(t.message)), R = (x) => {
|
|
2011
|
+
vn(x, {
|
|
2012
|
+
get message() {
|
|
2013
|
+
return t.message;
|
|
2014
|
+
},
|
|
2015
|
+
get messages() {
|
|
2016
|
+
return n();
|
|
2017
|
+
},
|
|
2018
|
+
get isRunning() {
|
|
2019
|
+
return r();
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
}, L = e.derived(() => s(t.message)), E = (x) => {
|
|
2023
|
+
In(x, {
|
|
2024
|
+
get message() {
|
|
2025
|
+
return t.message;
|
|
2026
|
+
}
|
|
2027
|
+
});
|
|
2028
|
+
}, M = e.derived(() => o(t.message));
|
|
2029
|
+
e.if(p, (x) => {
|
|
2030
|
+
e.get(_) ? x(m) : e.get(L) ? x(R, 1) : e.get(M) && x(E, 2);
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
e.append(a, c);
|
|
2034
|
+
}
|
|
2035
|
+
var Vn = e.from_html('<div class="copilotkit-message-list-footer cpk:mt-4"><!></div>'), Dn = e.from_html('<div class="copilotkit-message-list svelte-1xx0xqn"><div class="copilotkit-message-list-padding cpk:px-4"><div class="copilotkit-message-list-inner cpk:w-full cpk:max-w-3xl cpk:mx-auto"><!> <!></div></div></div>');
|
|
2036
|
+
function zn(a, t) {
|
|
2037
|
+
e.push(t, !0);
|
|
2038
|
+
let n = e.prop(t, "messages", 19, () => []), r = e.prop(t, "isRunning", 3, !1), s = e.prop(t, "autoScroll", 3, !0), o = e.prop(t, "sentMessageId", 3, null), g = e.state(void 0);
|
|
2039
|
+
const c = e.derived(() => Rt(s()));
|
|
2040
|
+
let p = null;
|
|
2041
|
+
e.user_effect(() => {
|
|
2042
|
+
e.get(g) && (e.get(c) === "pin-to-bottom" ? (n(), r(), queueMicrotask(() => {
|
|
2043
|
+
e.get(g) && (e.get(g).scrollTop = e.get(g).scrollHeight);
|
|
2044
|
+
})) : e.get(c) === "pin-to-send" && o() && o() !== p && (p = o(), Ce().then(() => {
|
|
2045
|
+
var k;
|
|
2046
|
+
const x = [
|
|
2047
|
+
...((k = e.get(g)) == null ? void 0 : k.querySelectorAll("[data-message-id]")) ?? []
|
|
2048
|
+
].find((A) => A.dataset.messageId === o());
|
|
2049
|
+
if (x && e.get(g)) {
|
|
2050
|
+
const A = e.get(g).getBoundingClientRect().top, h = x.getBoundingClientRect().top;
|
|
2051
|
+
e.get(g).scrollTop += h - A;
|
|
2052
|
+
}
|
|
2053
|
+
})));
|
|
2054
|
+
});
|
|
2055
|
+
var m = Dn(), _ = e.child(m), R = e.child(_), L = e.child(R);
|
|
2056
|
+
e.each(L, 17, n, (x) => x.id, (x, k) => {
|
|
2057
|
+
Un(x, {
|
|
2058
|
+
get message() {
|
|
2059
|
+
return e.get(k);
|
|
2060
|
+
},
|
|
2061
|
+
get messages() {
|
|
2062
|
+
return n();
|
|
2063
|
+
},
|
|
2064
|
+
get isRunning() {
|
|
2065
|
+
return r();
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
});
|
|
2069
|
+
var E = e.sibling(L, 2);
|
|
2070
|
+
{
|
|
2071
|
+
var M = (x) => {
|
|
2072
|
+
var k = Vn(), A = e.child(k);
|
|
2073
|
+
e.snippet(A, () => t.footer), e.reset(k), e.append(x, k);
|
|
2074
|
+
};
|
|
2075
|
+
e.if(E, (x) => {
|
|
2076
|
+
t.footer && x(M);
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
e.reset(R), e.reset(_), e.reset(m), e.bind_this(m, (x) => e.set(g, x), () => e.get(g)), e.append(a, m), e.pop();
|
|
2080
|
+
}
|
|
2081
|
+
var jn = e.from_html('<div data-testid="copilot-chat-attachment-uploading-overlay" class="copilotkit-attachment-uploading svelte-1ss983l" aria-label="Uploading"><div class="copilotkit-attachment-spinner svelte-1ss983l"></div></div>'), Kn = e.from_html('<img class="copilotkit-attachment-image svelte-1ss983l" data-testid="copilot-chat-attachment-image-thumbnail"/>'), Bn = e.from_html('<img class="copilotkit-attachment-image svelte-1ss983l" data-testid="copilot-chat-attachment-video-thumbnail"/>'), Hn = e.from_html('<video preload="metadata" class="copilotkit-attachment-image svelte-1ss983l" data-testid="copilot-chat-attachment-video-fallback"></video>', 2), Nn = e.from_html('<span class="copilotkit-attachment-name svelte-1ss983l"> </span>'), qn = e.from_html('<div class="copilotkit-attachment-audio svelte-1ss983l"><audio controls="" preload="metadata" class="copilotkit-attachment-audio-player svelte-1ss983l" data-testid="copilot-chat-attachment-audio-player"></audio> <!></div>'), Gn = e.from_html('<span class="copilotkit-attachment-size svelte-1ss983l"> </span>'), Wn = e.from_html('<div class="copilotkit-attachment-doc svelte-1ss983l"><div class="copilotkit-attachment-doc-icon svelte-1ss983l"> </div> <div class="copilotkit-attachment-doc-meta svelte-1ss983l"><span class="copilotkit-attachment-name svelte-1ss983l" data-testid="copilot-chat-attachment-document-filename"> </span> <!></div></div>'), Jn = e.from_html('<div class="copilotkit-attachment-placeholder svelte-1ss983l" data-testid="copilot-chat-attachment-placeholder"></div>'), Xn = e.from_html('<div data-testid="copilot-chat-attachment-item"><!> <!> <button type="button" class="copilotkit-attachment-remove svelte-1ss983l" aria-label="Remove attachment">✕</button></div>'), Yn = e.from_html('<div data-testid="copilot-attachment-queue" class="copilotkit-attachment-queue svelte-1ss983l"></div>');
|
|
2082
|
+
function Qn(a, t) {
|
|
2083
|
+
e.push(t, !0);
|
|
2084
|
+
let n = e.prop(t, "attachments", 19, () => []);
|
|
2085
|
+
var r = e.comment(), s = e.first_child(r);
|
|
2086
|
+
{
|
|
2087
|
+
var o = (g) => {
|
|
2088
|
+
var c = Yn();
|
|
2089
|
+
e.each(c, 21, n, (p) => p.id, (p, m) => {
|
|
2090
|
+
var _ = Xn();
|
|
2091
|
+
let R;
|
|
2092
|
+
var L = e.child(_);
|
|
2093
|
+
{
|
|
2094
|
+
var E = (h) => {
|
|
2095
|
+
var d = jn();
|
|
2096
|
+
e.append(h, d);
|
|
2097
|
+
};
|
|
2098
|
+
e.if(L, (h) => {
|
|
2099
|
+
e.get(m).status === "uploading" && h(E);
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
var M = e.sibling(L, 2);
|
|
2103
|
+
{
|
|
2104
|
+
var x = (h) => {
|
|
2105
|
+
var d = e.comment(), y = e.first_child(d);
|
|
2106
|
+
{
|
|
2107
|
+
var b = (v) => {
|
|
2108
|
+
var l = Kn();
|
|
2109
|
+
e.template_effect(
|
|
2110
|
+
(w) => {
|
|
2111
|
+
e.set_attribute(l, "src", w), e.set_attribute(l, "alt", e.get(m).filename || "Image attachment");
|
|
2112
|
+
},
|
|
2113
|
+
[() => pe(e.get(m).source)]
|
|
2114
|
+
), e.append(v, l);
|
|
2115
|
+
}, i = (v) => {
|
|
2116
|
+
var l = e.comment(), w = e.first_child(l);
|
|
2117
|
+
{
|
|
2118
|
+
var F = (V) => {
|
|
2119
|
+
var T = Bn();
|
|
2120
|
+
e.template_effect(() => {
|
|
2121
|
+
e.set_attribute(T, "src", e.get(m).thumbnail), e.set_attribute(T, "alt", e.get(m).filename || "Video thumbnail");
|
|
2122
|
+
}), e.append(V, T);
|
|
2123
|
+
}, U = (V) => {
|
|
2124
|
+
var T = Hn();
|
|
2125
|
+
T.muted = !0, e.template_effect((K) => e.set_attribute(T, "src", K), [() => pe(e.get(m).source)]), e.append(V, T);
|
|
2126
|
+
};
|
|
2127
|
+
e.if(w, (V) => {
|
|
2128
|
+
e.get(m).thumbnail ? V(F) : V(U, -1);
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
e.append(v, l);
|
|
2132
|
+
}, f = (v) => {
|
|
2133
|
+
var l = qn(), w = e.child(l), F = e.sibling(w, 2);
|
|
2134
|
+
{
|
|
2135
|
+
var U = (V) => {
|
|
2136
|
+
var T = Nn(), K = e.only_child(T, !0);
|
|
2137
|
+
e.template_effect(() => e.set_text(K, e.get(m).filename)), e.append(V, T);
|
|
2138
|
+
};
|
|
2139
|
+
e.if(F, (V) => {
|
|
2140
|
+
e.get(m).filename && V(U);
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
e.reset(l), e.template_effect((V) => e.set_attribute(w, "src", V), [() => pe(e.get(m).source)]), e.append(v, l);
|
|
2144
|
+
}, P = (v) => {
|
|
2145
|
+
var l = Wn(), w = e.child(l), F = e.only_child(w, !0), U = e.sibling(w, 2), V = e.child(U), T = e.only_child(V, !0), K = e.sibling(V, 2);
|
|
2146
|
+
{
|
|
2147
|
+
var C = (I) => {
|
|
2148
|
+
var B = Gn(), Y = e.only_child(B, !0);
|
|
2149
|
+
e.template_effect((z) => e.set_text(Y, z), [() => We(e.get(m).size)]), e.append(I, B);
|
|
2150
|
+
};
|
|
2151
|
+
e.if(K, (I) => {
|
|
2152
|
+
e.get(m).size != null && I(C);
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
e.reset(U), e.reset(l), e.template_effect(
|
|
2156
|
+
(I) => {
|
|
2157
|
+
e.set_text(F, I), e.set_text(T, e.get(m).filename || "Document");
|
|
2158
|
+
},
|
|
2159
|
+
[
|
|
2160
|
+
() => Je(e.get(m).source.mimeType ?? "")
|
|
2161
|
+
]
|
|
2162
|
+
), e.append(v, l);
|
|
2163
|
+
};
|
|
2164
|
+
e.if(y, (v) => {
|
|
2165
|
+
e.get(m).type === "image" ? v(b) : e.get(m).type === "video" ? v(i, 1) : e.get(m).type === "audio" ? v(f, 2) : v(P, -1);
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
e.append(h, d);
|
|
2169
|
+
}, k = (h) => {
|
|
2170
|
+
var d = Jn();
|
|
2171
|
+
e.append(h, d);
|
|
2172
|
+
};
|
|
2173
|
+
e.if(M, (h) => {
|
|
2174
|
+
e.get(m).status === "ready" ? h(x) : h(k, -1);
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
var A = e.sibling(M, 2);
|
|
2178
|
+
e.reset(_), e.template_effect(() => {
|
|
2179
|
+
e.set_attribute(_, "data-card-type", e.get(m).type), R = e.set_class(_, 1, "copilotkit-attachment-card svelte-1ss983l", null, R, {
|
|
2180
|
+
"is-media": e.get(m).type === "image" || e.get(m).type === "video"
|
|
2181
|
+
});
|
|
2182
|
+
}), e.delegated("click", A, () => {
|
|
2183
|
+
var h;
|
|
2184
|
+
return (h = t.onRemoveAttachment) == null ? void 0 : h.call(t, e.get(m).id);
|
|
2185
|
+
}), e.append(p, _);
|
|
2186
|
+
}), e.reset(c), e.append(g, c);
|
|
2187
|
+
};
|
|
2188
|
+
e.if(s, (g) => {
|
|
2189
|
+
n().length > 0 && g(o);
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
e.append(a, r), e.pop();
|
|
2193
|
+
}
|
|
2194
|
+
e.delegate(["click"]);
|
|
2195
|
+
var Zn = e.from_html('<div class="copilotkit-upload-hint svelte-1roil49" role="status">Uploading attachments…</div>'), $n = e.from_html('<button type="button" class="copilotkit-attach-btn svelte-1roil49" aria-label="Add file">+</button>'), er = e.from_html('<div class="copilotkit-input svelte-1roil49"><!> <!> <div class="copilotkit-input-row svelte-1roil49"><!> <textarea class="copilotkit-textarea svelte-1roil49" rows="1"></textarea> <button type="button" class="copilotkit-send-btn svelte-1roil49"><!></button></div></div>');
|
|
2196
|
+
function tr(a, t) {
|
|
2197
|
+
e.push(t, !0);
|
|
2198
|
+
let n = e.prop(t, "value", 3, ""), r = e.prop(t, "isRunning", 3, !1), s = e.prop(t, "placeholder", 3, "Type a message..."), o = e.prop(t, "attachments", 19, () => []), g = e.prop(t, "canAddFile", 3, !1), c = e.derived(n), p = e.derived(() => o().some((l) => l.status === "uploading")), m = e.derived(() => r() ? !0 : e.get(p) ? !1 : e.get(c).trim().length > 0 || o().length > 0);
|
|
2199
|
+
function _(l) {
|
|
2200
|
+
if (l.key === "Enter" && !l.shiftKey) {
|
|
2201
|
+
if (l.isComposing) return;
|
|
2202
|
+
l.preventDefault(), R();
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
function R() {
|
|
2206
|
+
if (e.get(p) || r()) return;
|
|
2207
|
+
const l = e.get(c).trim();
|
|
2208
|
+
!l && o().length === 0 || (t.onSubmit(l), e.set(c, ""), t.onInputChange(""));
|
|
2209
|
+
}
|
|
2210
|
+
function L() {
|
|
2211
|
+
t.onInputChange(e.get(c));
|
|
2212
|
+
}
|
|
2213
|
+
var E = er(), M = e.child(E);
|
|
2214
|
+
{
|
|
2215
|
+
var x = (l) => {
|
|
2216
|
+
Qn(l, {
|
|
2217
|
+
get attachments() {
|
|
2218
|
+
return o();
|
|
2219
|
+
},
|
|
2220
|
+
get onRemoveAttachment() {
|
|
2221
|
+
return t.onRemoveAttachment;
|
|
2222
|
+
}
|
|
2223
|
+
});
|
|
2224
|
+
};
|
|
2225
|
+
e.if(M, (l) => {
|
|
2226
|
+
o().length > 0 && l(x);
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
var k = e.sibling(M, 2);
|
|
2230
|
+
{
|
|
2231
|
+
var A = (l) => {
|
|
2232
|
+
var w = Zn();
|
|
2233
|
+
e.append(l, w);
|
|
2234
|
+
};
|
|
2235
|
+
e.if(k, (l) => {
|
|
2236
|
+
e.get(p) && l(A);
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
var h = e.sibling(k, 2), d = e.child(h);
|
|
2240
|
+
{
|
|
2241
|
+
var y = (l) => {
|
|
2242
|
+
var w = $n();
|
|
2243
|
+
e.delegated("click", w, function(...F) {
|
|
2244
|
+
var U;
|
|
2245
|
+
(U = t.onAddFile) == null || U.apply(this, F);
|
|
2246
|
+
}), e.append(l, w);
|
|
2247
|
+
};
|
|
2248
|
+
e.if(d, (l) => {
|
|
2249
|
+
g() && l(y);
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
var b = e.sibling(d, 2);
|
|
2253
|
+
e.remove_textarea_child(b);
|
|
2254
|
+
var i = e.sibling(b, 2), f = e.child(i);
|
|
2255
|
+
{
|
|
2256
|
+
var P = (l) => {
|
|
2257
|
+
var w = e.text("■");
|
|
2258
|
+
e.append(l, w);
|
|
2259
|
+
}, v = (l) => {
|
|
2260
|
+
var w = e.text("↑");
|
|
2261
|
+
e.append(l, w);
|
|
2262
|
+
};
|
|
2263
|
+
e.if(f, (l) => {
|
|
2264
|
+
r() ? l(P) : l(v, -1);
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
e.reset(i), e.reset(h), e.reset(E), e.template_effect(() => {
|
|
2268
|
+
e.set_value(b, e.get(c)), e.set_attribute(b, "placeholder", s()), b.disabled = r(), i.disabled = !r() && !e.get(m);
|
|
2269
|
+
}), e.delegated("input", b, (l) => {
|
|
2270
|
+
e.set(c, l.target.value), L();
|
|
2271
|
+
}), e.delegated("keydown", b, _), e.delegated("click", i, function(...l) {
|
|
2272
|
+
var w;
|
|
2273
|
+
(w = r() && t.onStop ? t.onStop : R) == null || w.apply(this, l);
|
|
2274
|
+
}), e.append(a, E), e.pop();
|
|
2275
|
+
}
|
|
2276
|
+
e.delegate(["click", "input", "keydown"]);
|
|
2277
|
+
var nr = e.from_html('<span class="copilotkit-spinner svelte-1o1lyb4"></span>'), rr = e.from_html('<button type="button" class="copilotkit-suggestion-pill svelte-1o1lyb4"><!> </button>');
|
|
2278
|
+
function ar(a, t) {
|
|
2279
|
+
e.push(t, !0);
|
|
2280
|
+
let n = e.prop(t, "isLoading", 3, !1);
|
|
2281
|
+
var r = rr(), s = e.child(r);
|
|
2282
|
+
{
|
|
2283
|
+
var o = (c) => {
|
|
2284
|
+
var p = nr();
|
|
2285
|
+
e.append(c, p);
|
|
2286
|
+
};
|
|
2287
|
+
e.if(s, (c) => {
|
|
2288
|
+
n() && c(o);
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
var g = e.sibling(s);
|
|
2292
|
+
e.reset(r), e.template_effect(() => {
|
|
2293
|
+
r.disabled = n(), e.set_text(g, ` ${t.suggestion.title ?? ""}`);
|
|
2294
|
+
}), e.delegated("click", r, function(...c) {
|
|
2295
|
+
var p;
|
|
2296
|
+
(p = t.onSelect) == null || p.apply(this, c);
|
|
2297
|
+
}), e.append(a, r), e.pop();
|
|
2298
|
+
}
|
|
2299
|
+
e.delegate(["click"]);
|
|
2300
|
+
var sr = e.from_html('<div class="copilotkit-suggestions svelte-16oo4xi"></div>');
|
|
2301
|
+
function qe(a, t) {
|
|
2302
|
+
e.push(t, !0);
|
|
2303
|
+
let n = e.prop(t, "suggestions", 19, () => []), r = e.prop(t, "loadingIndexes", 19, () => []);
|
|
2304
|
+
var s = e.comment(), o = e.first_child(s);
|
|
2305
|
+
{
|
|
2306
|
+
var g = (c) => {
|
|
2307
|
+
var p = sr();
|
|
2308
|
+
e.each(p, 21, n, e.index, (m, _, R) => {
|
|
2309
|
+
{
|
|
2310
|
+
let L = e.derived(() => r().includes(R));
|
|
2311
|
+
ar(m, {
|
|
2312
|
+
get suggestion() {
|
|
2313
|
+
return e.get(_);
|
|
2314
|
+
},
|
|
2315
|
+
get isLoading() {
|
|
2316
|
+
return e.get(L);
|
|
2317
|
+
},
|
|
2318
|
+
onSelect: () => t.onSelectSuggestion(e.get(_), R)
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
}), e.reset(p), e.append(c, p);
|
|
2322
|
+
};
|
|
2323
|
+
e.if(o, (c) => {
|
|
2324
|
+
n().length > 0 && c(g);
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
e.append(a, s), e.pop();
|
|
2328
|
+
}
|
|
2329
|
+
var ir = e.from_html('<div class="copilotkit-welcome svelte-d1g2ha"><div class="copilotkit-welcome-content svelte-d1g2ha"><div class="copilotkit-welcome-icon svelte-d1g2ha">🤖</div> <h2 class="copilotkit-welcome-title svelte-d1g2ha">How can I help you?</h2> <p class="copilotkit-welcome-subtitle svelte-d1g2ha">Ask me anything to get started.</p></div> <!></div>'), or = e.from_html('<div class="copilotkit-drag-overlay svelte-d1g2ha" data-testid="copilot-drag-overlay">Drop files to attach</div>'), lr = e.from_html('<div role="presentation"><!> <!> <!></div>');
|
|
2330
|
+
function dr(a, t) {
|
|
2331
|
+
e.push(t, !0);
|
|
2332
|
+
let n = e.prop(t, "messages", 19, () => []), r = e.prop(t, "isRunning", 3, !1), s = e.prop(t, "welcomeScreen", 3, !1), o = e.prop(t, "suggestions", 19, () => []), g = e.prop(t, "attachments", 19, () => []), c = e.prop(t, "dragOver", 3, !1), p = e.prop(t, "inputValue", 3, ""), m = e.prop(t, "inputMode", 3, "input"), _ = e.prop(t, "inputToolsMenu", 19, () => []), R = e.prop(t, "autoScroll", 3, !0), L = e.prop(t, "sentMessageId", 3, null), E = e.derived(() => !!t.onAddFile);
|
|
2333
|
+
var M = lr();
|
|
2334
|
+
let x;
|
|
2335
|
+
var k = e.child(M);
|
|
2336
|
+
{
|
|
2337
|
+
var A = (i) => {
|
|
2338
|
+
var f = ir(), P = e.sibling(e.child(f), 2);
|
|
2339
|
+
{
|
|
2340
|
+
var v = (l) => {
|
|
2341
|
+
qe(l, {
|
|
2342
|
+
get suggestions() {
|
|
2343
|
+
return o();
|
|
2344
|
+
},
|
|
2345
|
+
get onSelectSuggestion() {
|
|
2346
|
+
return t.onSelectSuggestion;
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
};
|
|
2350
|
+
e.if(P, (l) => {
|
|
2351
|
+
o().length > 0 && l(v);
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
e.reset(f), e.append(i, f);
|
|
2355
|
+
}, h = (i) => {
|
|
2356
|
+
zn(i, {
|
|
2357
|
+
get messages() {
|
|
2358
|
+
return n();
|
|
2359
|
+
},
|
|
2360
|
+
get isRunning() {
|
|
2361
|
+
return r();
|
|
2362
|
+
},
|
|
2363
|
+
get autoScroll() {
|
|
2364
|
+
return R();
|
|
2365
|
+
},
|
|
2366
|
+
get sentMessageId() {
|
|
2367
|
+
return L();
|
|
2368
|
+
},
|
|
2369
|
+
footer: (P) => {
|
|
2370
|
+
var v = e.comment(), l = e.first_child(v);
|
|
2371
|
+
{
|
|
2372
|
+
var w = (F) => {
|
|
2373
|
+
qe(F, {
|
|
2374
|
+
get suggestions() {
|
|
2375
|
+
return o();
|
|
2376
|
+
},
|
|
2377
|
+
get onSelectSuggestion() {
|
|
2378
|
+
return t.onSelectSuggestion;
|
|
2379
|
+
}
|
|
2380
|
+
});
|
|
2381
|
+
};
|
|
2382
|
+
e.if(l, (F) => {
|
|
2383
|
+
!r() && o().length > 0 && F(w);
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
e.append(P, v);
|
|
2387
|
+
},
|
|
2388
|
+
$$slots: { footer: !0 }
|
|
2389
|
+
});
|
|
2390
|
+
};
|
|
2391
|
+
e.if(k, (i) => {
|
|
2392
|
+
s() && n().length === 0 ? i(A) : i(h, -1);
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
var d = e.sibling(k, 2);
|
|
2396
|
+
{
|
|
2397
|
+
let i = e.derived(() => s() && n().length === 0 ? "Type your message..." : "Type a message...");
|
|
2398
|
+
tr(d, {
|
|
2399
|
+
get value() {
|
|
2400
|
+
return p();
|
|
2401
|
+
},
|
|
2402
|
+
get isRunning() {
|
|
2403
|
+
return r();
|
|
2404
|
+
},
|
|
2405
|
+
get inputMode() {
|
|
2406
|
+
return m();
|
|
2407
|
+
},
|
|
2408
|
+
get toolsMenu() {
|
|
2409
|
+
return _();
|
|
2410
|
+
},
|
|
2411
|
+
get onSubmit() {
|
|
2412
|
+
return t.onSubmitMessage;
|
|
2413
|
+
},
|
|
2414
|
+
get onStop() {
|
|
2415
|
+
return t.onStop;
|
|
2416
|
+
},
|
|
2417
|
+
get onInputChange() {
|
|
2418
|
+
return t.onInputChange;
|
|
2419
|
+
},
|
|
2420
|
+
get attachments() {
|
|
2421
|
+
return g();
|
|
2422
|
+
},
|
|
2423
|
+
get canAddFile() {
|
|
2424
|
+
return e.get(E);
|
|
2425
|
+
},
|
|
2426
|
+
get onAddFile() {
|
|
2427
|
+
return t.onAddFile;
|
|
2428
|
+
},
|
|
2429
|
+
get onRemoveAttachment() {
|
|
2430
|
+
return t.onRemoveAttachment;
|
|
2431
|
+
},
|
|
2432
|
+
get placeholder() {
|
|
2433
|
+
return e.get(i);
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
var y = e.sibling(d, 2);
|
|
2438
|
+
{
|
|
2439
|
+
var b = (i) => {
|
|
2440
|
+
var f = or();
|
|
2441
|
+
e.append(i, f);
|
|
2442
|
+
};
|
|
2443
|
+
e.if(y, (i) => {
|
|
2444
|
+
c() && i(b);
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
e.reset(M), e.template_effect(() => x = e.set_class(M, 1, "copilotkit-chat-view svelte-d1g2ha", null, x, { "drag-over": c() })), e.event("dragover", M, function(...i) {
|
|
2448
|
+
var f;
|
|
2449
|
+
(f = t.onDragOver) == null || f.apply(this, i);
|
|
2450
|
+
}), e.event("dragleave", M, function(...i) {
|
|
2451
|
+
var f;
|
|
2452
|
+
(f = t.onDragLeave) == null || f.apply(this, i);
|
|
2453
|
+
}), e.event("drop", M, function(...i) {
|
|
2454
|
+
var f;
|
|
2455
|
+
(f = t.onDrop) == null || f.apply(this, i);
|
|
2456
|
+
}), e.append(a, M), e.pop();
|
|
2457
|
+
}
|
|
2458
|
+
const ke = /* @__PURE__ */ new WeakMap();
|
|
2459
|
+
async function cr(a, t) {
|
|
2460
|
+
const r = (ke.get(a) ?? Promise.resolve()).catch(() => {
|
|
2461
|
+
}).then(async () => {
|
|
2462
|
+
const s = a, o = lt(s) ? s.activeRunCompletionPromise : void 0;
|
|
2463
|
+
if (a.isRunning && o)
|
|
2464
|
+
try {
|
|
2465
|
+
await o;
|
|
2466
|
+
} catch (g) {
|
|
2467
|
+
console.error(
|
|
2468
|
+
"CopilotChat: in-flight run rejected while queuing send",
|
|
2469
|
+
g
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
await t();
|
|
2473
|
+
});
|
|
2474
|
+
ke.set(a, r);
|
|
2475
|
+
try {
|
|
2476
|
+
await r;
|
|
2477
|
+
} finally {
|
|
2478
|
+
ke.get(a) === r && ke.delete(a);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
var ur = e.from_html('<p class="copilotkit-chat-error svelte-2q2d9l" role="alert"> </p>'), gr = e.from_html('<input type="file" multiple="" style="display: none" data-testid="copilot-file-input"/>'), pr = e.from_html('<div data-copilotkit=""><!> <!> <!></div>');
|
|
2482
|
+
function tt(a, t) {
|
|
2483
|
+
e.push(t, !0);
|
|
2484
|
+
function n(u) {
|
|
2485
|
+
if (!(u === void 0 || u === !1))
|
|
2486
|
+
return u === !0 ? { enabled: !0 } : { ...u, enabled: u.enabled ?? !0 };
|
|
2487
|
+
}
|
|
2488
|
+
let r = e.prop(t, "autoScroll", 3, !0), s = e.prop(t, "welcomeScreen", 3, !0), o = e.prop(t, "inputMode", 3, "input"), g = e.prop(t, "inputToolsMenu", 19, () => []), c = e.prop(t, "className", 3, ""), p = e.proxy(Ie()), m = e.derived(() => t.threadId ?? p), _ = e.derived(() => !!t.threadId), R = e.derived(() => t.agentId ?? me), L = e.derived(() => n(t.attachments));
|
|
2489
|
+
Kt(new jt(t.agentId ?? me, e.get(m), e.get(_)));
|
|
2490
|
+
let E = e.state(null), M = e.state(null);
|
|
2491
|
+
e.user_pre_effect(() => {
|
|
2492
|
+
const u = e.get(R), S = e.get(m), O = Fe();
|
|
2493
|
+
O && (O.agentId = u, O.threadId = S), e.set(E, Le({ agentId: u, threadId: S, throttleMs: t.throttleMs }), !0), e.set(M, Ut({ agentId: u }), !0);
|
|
2494
|
+
});
|
|
2495
|
+
let { copilotkit: x } = $e(), k = e.derived(() => {
|
|
2496
|
+
var u;
|
|
2497
|
+
return ((u = e.get(E)) == null ? void 0 : u.agent) ?? null;
|
|
2498
|
+
}), A = e.derived(() => {
|
|
2499
|
+
var u;
|
|
2500
|
+
return ((u = e.get(E)) == null ? void 0 : u.messages) ?? [];
|
|
2501
|
+
}), h = e.derived(() => {
|
|
2502
|
+
var u;
|
|
2503
|
+
return ((u = e.get(E)) == null ? void 0 : u.isRunning) ?? !1;
|
|
2504
|
+
}), d = e.derived(() => {
|
|
2505
|
+
var u;
|
|
2506
|
+
return ((u = e.get(M)) == null ? void 0 : u.suggestions) ?? [];
|
|
2507
|
+
}), y = e.state(null), b = e.state(null);
|
|
2508
|
+
const i = zt({ config: () => e.get(L) });
|
|
2509
|
+
let f = e.derived(() => i.attachments), P = e.derived(() => i.enabled), v = e.derived(() => i.dragOver);
|
|
2510
|
+
function l() {
|
|
2511
|
+
e.get(P) && setTimeout(
|
|
2512
|
+
() => {
|
|
2513
|
+
var u;
|
|
2514
|
+
(u = i.fileInputRef) == null || u.click();
|
|
2515
|
+
},
|
|
2516
|
+
100
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
async function w(u, S = !1) {
|
|
2520
|
+
const O = e.get(k);
|
|
2521
|
+
if (O) {
|
|
2522
|
+
e.set(y, null);
|
|
2523
|
+
try {
|
|
2524
|
+
await cr(O, async () => {
|
|
2525
|
+
if (S && e.get(f).some((J) => J.status === "uploading")) {
|
|
2526
|
+
e.set(y, "Wait for attachments to finish uploading before sending.");
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
const N = S ? i.consumeAttachments() : [], G = Ie();
|
|
2530
|
+
if (N.length > 0) {
|
|
2531
|
+
const J = [];
|
|
2532
|
+
u.trim() && J.push({ type: "text", text: u });
|
|
2533
|
+
for (const Q of N)
|
|
2534
|
+
J.push(ft(Q));
|
|
2535
|
+
O.addMessage({ id: G, role: "user", content: J });
|
|
2536
|
+
} else
|
|
2537
|
+
O.addMessage({ id: G, role: "user", content: u });
|
|
2538
|
+
e.set(b, G, !0), await x.runAgent({ agent: O });
|
|
2539
|
+
});
|
|
2540
|
+
} catch (N) {
|
|
2541
|
+
console.error("CopilotChat: runAgent failed after sending a message", N), e.set(y, "The message could not be sent. Please try again.");
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
function F(u) {
|
|
2546
|
+
return w(u, !0);
|
|
2547
|
+
}
|
|
2548
|
+
function U() {
|
|
2549
|
+
e.get(k) && x.stopAgent({ agent: e.get(k) });
|
|
2550
|
+
}
|
|
2551
|
+
function V(u) {
|
|
2552
|
+
var S;
|
|
2553
|
+
(S = t.onInputChange) == null || S.call(t, u);
|
|
2554
|
+
}
|
|
2555
|
+
function T(u) {
|
|
2556
|
+
return w(u.message);
|
|
2557
|
+
}
|
|
2558
|
+
var K = pr(), C = e.child(K);
|
|
2559
|
+
{
|
|
2560
|
+
var I = (u) => {
|
|
2561
|
+
var S = ur(), O = e.only_child(S, !0);
|
|
2562
|
+
e.template_effect(() => e.set_text(O, e.get(y))), e.append(u, S);
|
|
2563
|
+
};
|
|
2564
|
+
e.if(C, (u) => {
|
|
2565
|
+
e.get(y) && u(I);
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
var B = e.sibling(C, 2);
|
|
2569
|
+
{
|
|
2570
|
+
var Y = (u) => {
|
|
2571
|
+
var S = gr();
|
|
2572
|
+
e.action(S, (O) => {
|
|
2573
|
+
var N;
|
|
2574
|
+
return (N = i.fileInputAction) == null ? void 0 : N.call(i, O);
|
|
2575
|
+
}), e.template_effect(() => {
|
|
2576
|
+
var O;
|
|
2577
|
+
return e.set_attribute(S, "accept", ((O = e.get(L)) == null ? void 0 : O.accept) ?? "*/*");
|
|
2578
|
+
}), e.delegated("change", S, (O) => void i.handleFileUpload(O)), e.append(u, S);
|
|
2579
|
+
};
|
|
2580
|
+
e.if(B, (u) => {
|
|
2581
|
+
e.get(P) && u(Y);
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
var z = e.sibling(B, 2);
|
|
2585
|
+
{
|
|
2586
|
+
let u = e.derived(() => e.get(P) ? i.removeAttachment : void 0), S = e.derived(() => e.get(P) ? l : void 0), O = e.derived(() => e.get(P) ? i.handleDragOver : void 0), N = e.derived(() => e.get(P) ? i.handleDragLeave : void 0), G = e.derived(() => e.get(P) ? i.handleDrop : void 0);
|
|
2587
|
+
dr(z, {
|
|
2588
|
+
get messages() {
|
|
2589
|
+
return e.get(A);
|
|
2590
|
+
},
|
|
2591
|
+
get isRunning() {
|
|
2592
|
+
return e.get(h);
|
|
2593
|
+
},
|
|
2594
|
+
get autoScroll() {
|
|
2595
|
+
return r();
|
|
2596
|
+
},
|
|
2597
|
+
get sentMessageId() {
|
|
2598
|
+
return e.get(b);
|
|
2599
|
+
},
|
|
2600
|
+
get welcomeScreen() {
|
|
2601
|
+
return s();
|
|
2602
|
+
},
|
|
2603
|
+
get suggestions() {
|
|
2604
|
+
return e.get(d);
|
|
2605
|
+
},
|
|
2606
|
+
get attachments() {
|
|
2607
|
+
return e.get(f);
|
|
2608
|
+
},
|
|
2609
|
+
get dragOver() {
|
|
2610
|
+
return e.get(v);
|
|
2611
|
+
},
|
|
2612
|
+
get inputValue() {
|
|
2613
|
+
return t.inputValue;
|
|
2614
|
+
},
|
|
2615
|
+
get inputMode() {
|
|
2616
|
+
return o();
|
|
2617
|
+
},
|
|
2618
|
+
get inputToolsMenu() {
|
|
2619
|
+
return g();
|
|
2620
|
+
},
|
|
2621
|
+
onSubmitMessage: F,
|
|
2622
|
+
onStop: U,
|
|
2623
|
+
onInputChange: V,
|
|
2624
|
+
onSelectSuggestion: T,
|
|
2625
|
+
get onRemoveAttachment() {
|
|
2626
|
+
return e.get(u);
|
|
2627
|
+
},
|
|
2628
|
+
get onAddFile() {
|
|
2629
|
+
return e.get(S);
|
|
2630
|
+
},
|
|
2631
|
+
get onDragOver() {
|
|
2632
|
+
return e.get(O);
|
|
2633
|
+
},
|
|
2634
|
+
get onDragLeave() {
|
|
2635
|
+
return e.get(N);
|
|
2636
|
+
},
|
|
2637
|
+
get onDrop() {
|
|
2638
|
+
return e.get(G);
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
e.reset(K), e.action(K, (u) => {
|
|
2643
|
+
var S;
|
|
2644
|
+
return (S = i.containerAction) == null ? void 0 : S.call(i, u);
|
|
2645
|
+
}), e.template_effect(() => e.set_class(K, 1, `copilotkit-chat ${c() ?? ""}`, "svelte-2q2d9l")), e.append(a, K), e.pop();
|
|
2646
|
+
}
|
|
2647
|
+
e.delegate(["change"]);
|
|
2648
|
+
var fr = e.from_svg('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"></path></svg>'), vr = e.from_svg('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"></path></svg>'), mr = e.from_html('<button type="button" class="copilotkit-toggle-btn svelte-1tg8ft"><!></button>');
|
|
2649
|
+
function nt(a, t) {
|
|
2650
|
+
let n = e.prop(t, "isOpen", 3, !1);
|
|
2651
|
+
var r = mr(), s = e.child(r);
|
|
2652
|
+
{
|
|
2653
|
+
var o = (c) => {
|
|
2654
|
+
var p = fr();
|
|
2655
|
+
e.append(c, p);
|
|
2656
|
+
}, g = (c) => {
|
|
2657
|
+
var p = vr();
|
|
2658
|
+
e.append(c, p);
|
|
2659
|
+
};
|
|
2660
|
+
e.if(s, (c) => {
|
|
2661
|
+
n() ? c(o) : c(g, -1);
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
e.reset(r), e.template_effect(() => e.set_attribute(r, "aria-label", n() ? "Close chat" : "Open chat")), e.delegated("click", r, function(...c) {
|
|
2665
|
+
var p;
|
|
2666
|
+
(p = t.onclick) == null || p.apply(this, c);
|
|
2667
|
+
}), e.append(a, r);
|
|
2668
|
+
}
|
|
2669
|
+
e.delegate(["click"]);
|
|
2670
|
+
var hr = /* @__PURE__ */ new Set(["$$slots", "$$events", "$$legacy", "width", "defaultOpen"]), _r = e.from_html('<div class="copilotkit-sidebar-wrapper svelte-z4qr0f"><!> <div role="presentation"></div> <div><div class="copilotkit-sidebar-header svelte-z4qr0f"><h3 class="copilotkit-sidebar-title svelte-z4qr0f">Copilot</h3> <button type="button" class="copilotkit-sidebar-close svelte-z4qr0f" aria-label="Close chat">✕</button></div> <div class="copilotkit-sidebar-body svelte-z4qr0f"><!></div></div></div>');
|
|
2671
|
+
function Br(a, t) {
|
|
2672
|
+
e.push(t, !0);
|
|
2673
|
+
let n = e.prop(t, "width", 3, "400px"), r = e.prop(t, "defaultOpen", 3, !1), s = e.rest_props(t, hr), o = e.state(e.proxy(r())), g = e.derived(() => typeof n() == "number" ? `${n()}px` : n()), c, p;
|
|
2674
|
+
function m() {
|
|
2675
|
+
e.set(o, !e.get(o));
|
|
2676
|
+
}
|
|
2677
|
+
function _() {
|
|
2678
|
+
const i = !!(p != null && p.contains(document.activeElement));
|
|
2679
|
+
e.set(o, !1), i && Ce().then(() => {
|
|
2680
|
+
var f;
|
|
2681
|
+
(f = c == null ? void 0 : c.querySelector(".copilotkit-toggle-btn")) == null || f.focus();
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
function R(i) {
|
|
2685
|
+
e.get(o) && i.key === "Escape" && _();
|
|
2686
|
+
}
|
|
2687
|
+
var L = _r();
|
|
2688
|
+
e.event("keydown", e.window, R);
|
|
2689
|
+
var E = e.child(L);
|
|
2690
|
+
nt(E, {
|
|
2691
|
+
get isOpen() {
|
|
2692
|
+
return e.get(o);
|
|
2693
|
+
},
|
|
2694
|
+
onclick: m
|
|
2695
|
+
});
|
|
2696
|
+
var M = e.sibling(E, 2);
|
|
2697
|
+
let x;
|
|
2698
|
+
var k = e.sibling(M, 2);
|
|
2699
|
+
let A;
|
|
2700
|
+
var h = e.child(k), d = e.sibling(e.child(h), 2);
|
|
2701
|
+
e.reset(h);
|
|
2702
|
+
var y = e.sibling(h, 2), b = e.child(y);
|
|
2703
|
+
tt(b, e.spread_props(() => s)), e.reset(y), e.reset(k), e.bind_this(k, (i) => p = i, () => p), e.reset(L), e.bind_this(L, (i) => c = i, () => c), e.template_effect(() => {
|
|
2704
|
+
x = e.set_class(M, 1, "copilotkit-sidebar-overlay svelte-z4qr0f", null, x, { "is-closed": !e.get(o) }), e.set_attribute(M, "aria-hidden", e.get(o) ? void 0 : !0), M.inert = !e.get(o), e.set_attribute(M, "hidden", !e.get(o)), A = e.set_class(k, 1, "copilotkit-sidebar svelte-z4qr0f", null, A, { "is-closed": !e.get(o) }), e.set_style(k, `width: ${e.get(g) ?? ""}`), e.set_attribute(k, "aria-hidden", e.get(o) ? void 0 : !0), k.inert = !e.get(o), e.set_attribute(k, "hidden", !e.get(o));
|
|
2705
|
+
}), e.delegated("click", M, _), e.delegated("keydown", M, (i) => i.key === "Escape" && _()), e.delegated("click", d, _), e.append(a, L), e.pop();
|
|
2706
|
+
}
|
|
2707
|
+
e.delegate(["click", "keydown"]);
|
|
2708
|
+
var br = /* @__PURE__ */ new Set([
|
|
2709
|
+
"$$slots",
|
|
2710
|
+
"$$events",
|
|
2711
|
+
"$$legacy",
|
|
2712
|
+
"width",
|
|
2713
|
+
"height",
|
|
2714
|
+
"clickOutsideToClose",
|
|
2715
|
+
"defaultOpen"
|
|
2716
|
+
]), kr = e.from_html('<div class="copilotkit-popup-wrapper svelte-1ik81yh"><!> <div role="presentation"><div class="copilotkit-popup svelte-1ik81yh" role="dialog" aria-modal="true" aria-labelledby="copilot-popup-title" tabindex="-1"><div class="copilotkit-popup-header svelte-1ik81yh"><h3 id="copilot-popup-title" class="copilotkit-popup-title svelte-1ik81yh">Copilot</h3> <button type="button" class="copilotkit-popup-close svelte-1ik81yh" aria-label="Close chat">✕</button></div> <div class="copilotkit-popup-body svelte-1ik81yh"><!></div></div></div></div>');
|
|
2717
|
+
function Hr(a, t) {
|
|
2718
|
+
e.push(t, !0);
|
|
2719
|
+
let n = e.prop(t, "width", 3, "400px"), r = e.prop(t, "height", 3, "600px"), s = e.prop(t, "clickOutsideToClose", 3, !0), o = e.prop(t, "defaultOpen", 3, !1), g = e.rest_props(t, br), c = e.state(e.proxy(o())), p = e.derived(() => typeof n() == "number" ? `${n()}px` : n()), m = e.derived(() => typeof r() == "number" ? `${r()}px` : r()), _, R;
|
|
2720
|
+
function L() {
|
|
2721
|
+
e.get(c) ? E() : e.set(c, !0);
|
|
2722
|
+
}
|
|
2723
|
+
function E() {
|
|
2724
|
+
var l;
|
|
2725
|
+
(l = R == null ? void 0 : R.querySelector(".copilotkit-toggle-btn")) == null || l.focus(), e.set(c, !1);
|
|
2726
|
+
}
|
|
2727
|
+
function M(l) {
|
|
2728
|
+
if (l.key === "Escape") {
|
|
2729
|
+
E();
|
|
2730
|
+
return;
|
|
2731
|
+
}
|
|
2732
|
+
if (l.key !== "Tab" || !_) return;
|
|
2733
|
+
const w = [
|
|
2734
|
+
..._.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')
|
|
2735
|
+
].filter((V) => !V.hasAttribute("hidden"));
|
|
2736
|
+
if (w.length === 0) {
|
|
2737
|
+
l.preventDefault(), _.focus();
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
const F = w[0], U = w[w.length - 1];
|
|
2741
|
+
_.contains(document.activeElement) ? l.shiftKey && document.activeElement === F ? (l.preventDefault(), U.focus()) : !l.shiftKey && document.activeElement === U && (l.preventDefault(), F.focus()) : (l.preventDefault(), (l.shiftKey ? U : F).focus());
|
|
2742
|
+
}
|
|
2743
|
+
e.user_effect(() => {
|
|
2744
|
+
e.get(c) && Ce().then(() => {
|
|
2745
|
+
var w;
|
|
2746
|
+
(w = (_ == null ? void 0 : _.querySelector('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')) ?? _) == null || w.focus();
|
|
2747
|
+
});
|
|
2748
|
+
});
|
|
2749
|
+
function x(l) {
|
|
2750
|
+
s() && l.target === l.currentTarget && E();
|
|
2751
|
+
}
|
|
2752
|
+
function k(l) {
|
|
2753
|
+
e.get(c) && l.key === "Escape" && E();
|
|
2754
|
+
}
|
|
2755
|
+
var A = kr();
|
|
2756
|
+
e.event("keydown", e.window, k);
|
|
2757
|
+
var h = e.child(A);
|
|
2758
|
+
nt(h, {
|
|
2759
|
+
get isOpen() {
|
|
2760
|
+
return e.get(c);
|
|
2761
|
+
},
|
|
2762
|
+
onclick: L
|
|
2763
|
+
});
|
|
2764
|
+
var d = e.sibling(h, 2);
|
|
2765
|
+
let y;
|
|
2766
|
+
var b = e.child(d), i = e.child(b), f = e.sibling(e.child(i), 2);
|
|
2767
|
+
e.reset(i);
|
|
2768
|
+
var P = e.sibling(i, 2), v = e.child(P);
|
|
2769
|
+
tt(v, e.spread_props(() => g)), e.reset(P), e.reset(b), e.bind_this(b, (l) => _ = l, () => _), e.reset(d), e.reset(A), e.bind_this(A, (l) => R = l, () => R), e.template_effect(() => {
|
|
2770
|
+
y = e.set_class(d, 1, "copilotkit-popup-overlay svelte-1ik81yh", null, y, { "is-closed": !e.get(c) }), e.set_attribute(d, "aria-hidden", e.get(c) ? void 0 : !0), d.inert = !e.get(c), e.set_attribute(d, "hidden", !e.get(c)), e.set_style(b, `width: ${e.get(p) ?? ""}; height: ${e.get(m) ?? ""}`);
|
|
2771
|
+
}), e.delegated("click", d, x), e.delegated("keydown", d, (l) => l.key === "Escape" && E()), e.delegated("keydown", b, M), e.delegated("click", f, E), e.append(a, A), e.pop();
|
|
2772
|
+
}
|
|
2773
|
+
e.delegate(["click", "keydown"]);
|
|
2774
|
+
class yr extends dt {
|
|
2775
|
+
constructor(n) {
|
|
2776
|
+
super(n);
|
|
2777
|
+
re(this, "_propFrontendTools", []);
|
|
2778
|
+
re(this, "_hookFrontendTools", /* @__PURE__ */ new Map());
|
|
2779
|
+
re(this, "_renderToolCalls", []);
|
|
2780
|
+
re(this, "_hookRenderToolCalls", /* @__PURE__ */ new Map());
|
|
2781
|
+
re(this, "_cachedMergedRenderToolCalls", null);
|
|
2782
|
+
re(this, "_renderCustomMessages", []);
|
|
2783
|
+
re(this, "_renderActivityMessages", []);
|
|
2784
|
+
re(this, "_interruptState", null);
|
|
2785
|
+
this._propFrontendTools = [...n.tools ?? []], this._renderToolCalls = n.renderToolCalls ?? [], this._renderCustomMessages = n.renderCustomMessages ?? [], this._renderActivityMessages = n.renderActivityMessages ?? [];
|
|
2786
|
+
}
|
|
2787
|
+
get renderCustomMessages() {
|
|
2788
|
+
return this._renderCustomMessages;
|
|
2789
|
+
}
|
|
2790
|
+
get renderActivityMessages() {
|
|
2791
|
+
return this._renderActivityMessages;
|
|
2792
|
+
}
|
|
2793
|
+
setTools(n) {
|
|
2794
|
+
this._propFrontendTools = [...n], this._syncFrontendTools();
|
|
2795
|
+
}
|
|
2796
|
+
removeTool(n, r) {
|
|
2797
|
+
this._propFrontendTools = this._propFrontendTools.filter(
|
|
2798
|
+
(s) => !(s.name === n && (r !== void 0 ? s.agentId === r : !s.agentId))
|
|
2799
|
+
), this._hookFrontendTools.delete(`${r ?? ""}:${n}`), super.removeTool(n, r), this._syncFrontendTools();
|
|
2800
|
+
}
|
|
2801
|
+
addHookFrontendTool(n) {
|
|
2802
|
+
this._hookFrontendTools.set(`${n.agentId ?? ""}:${n.name}`, n), this._syncFrontendTools();
|
|
2803
|
+
}
|
|
2804
|
+
removeHookFrontendTool(n, r, s) {
|
|
2805
|
+
const o = `${r ?? ""}:${n}`;
|
|
2806
|
+
s !== void 0 && this._hookFrontendTools.get(o) !== s || this._hookFrontendTools.delete(o) && this._syncFrontendTools();
|
|
2807
|
+
}
|
|
2808
|
+
_syncFrontendTools() {
|
|
2809
|
+
const n = /* @__PURE__ */ new Map();
|
|
2810
|
+
for (const r of this._propFrontendTools)
|
|
2811
|
+
n.set(`${r.agentId ?? ""}:${r.name}`, r);
|
|
2812
|
+
for (const [r, s] of this._hookFrontendTools)
|
|
2813
|
+
n.set(r, s);
|
|
2814
|
+
super.setTools([...n.values()]);
|
|
2815
|
+
}
|
|
2816
|
+
setRenderActivityMessages(n) {
|
|
2817
|
+
this._renderActivityMessages = [...n];
|
|
2818
|
+
}
|
|
2819
|
+
setRenderCustomMessages(n) {
|
|
2820
|
+
this._renderCustomMessages = [...n], this.notifySubscribers((r) => {
|
|
2821
|
+
var o;
|
|
2822
|
+
const s = r;
|
|
2823
|
+
return (o = s.onRenderCustomMessagesChanged) == null ? void 0 : o.call(s, {
|
|
2824
|
+
copilotkit: this,
|
|
2825
|
+
renderCustomMessages: [...this.renderCustomMessages]
|
|
2826
|
+
});
|
|
2827
|
+
}, "Subscriber onRenderCustomMessagesChanged error:");
|
|
2828
|
+
}
|
|
2829
|
+
get propRenderToolCalls() {
|
|
2830
|
+
return this._renderToolCalls;
|
|
2831
|
+
}
|
|
2832
|
+
get renderToolCalls() {
|
|
2833
|
+
if (this._hookRenderToolCalls.size === 0)
|
|
2834
|
+
return this._renderToolCalls;
|
|
2835
|
+
if (this._cachedMergedRenderToolCalls)
|
|
2836
|
+
return this._cachedMergedRenderToolCalls;
|
|
2837
|
+
const n = /* @__PURE__ */ new Map();
|
|
2838
|
+
for (const r of this._renderToolCalls)
|
|
2839
|
+
n.set(`${r.agentId ?? ""}:${r.name}`, r);
|
|
2840
|
+
for (const [r, s] of this._hookRenderToolCalls)
|
|
2841
|
+
n.set(r, s);
|
|
2842
|
+
return this._cachedMergedRenderToolCalls = Array.from(n.values()), this._cachedMergedRenderToolCalls;
|
|
2843
|
+
}
|
|
2844
|
+
get interruptState() {
|
|
2845
|
+
return this._interruptState;
|
|
2846
|
+
}
|
|
2847
|
+
setRenderToolCalls(n) {
|
|
2848
|
+
this._renderToolCalls = [...n], this._cachedMergedRenderToolCalls = null, this._notifyRenderToolCallsChanged();
|
|
2849
|
+
}
|
|
2850
|
+
addHookRenderToolCall(n) {
|
|
2851
|
+
const r = `${n.agentId ?? ""}:${n.name}`;
|
|
2852
|
+
this._hookRenderToolCalls.set(r, n), this._cachedMergedRenderToolCalls = null, this._notifyRenderToolCallsChanged();
|
|
2853
|
+
}
|
|
2854
|
+
removeHookRenderToolCall(n, r, s) {
|
|
2855
|
+
const o = `${r ?? ""}:${n}`;
|
|
2856
|
+
s !== void 0 && this._hookRenderToolCalls.get(o) !== s || this._hookRenderToolCalls.delete(o) && (this._cachedMergedRenderToolCalls = null, this._notifyRenderToolCallsChanged());
|
|
2857
|
+
}
|
|
2858
|
+
_notifyRenderToolCallsChanged() {
|
|
2859
|
+
this.notifySubscribers((n) => {
|
|
2860
|
+
var s;
|
|
2861
|
+
const r = n;
|
|
2862
|
+
if (r.onRenderToolCallsChanged)
|
|
2863
|
+
return (s = r.onRenderToolCallsChanged) == null ? void 0 : s.call(r, {
|
|
2864
|
+
copilotkit: this,
|
|
2865
|
+
renderToolCalls: [...this.renderToolCalls]
|
|
2866
|
+
});
|
|
2867
|
+
}, "Subscriber onRenderToolCallsChanged error:");
|
|
2868
|
+
}
|
|
2869
|
+
setInterruptState(n) {
|
|
2870
|
+
this._interruptState = n, this.notifySubscribers((r) => {
|
|
2871
|
+
var o;
|
|
2872
|
+
const s = r;
|
|
2873
|
+
return (o = s.onInterruptStateChanged) == null ? void 0 : o.call(s, {
|
|
2874
|
+
copilotkit: this,
|
|
2875
|
+
interruptState: this._interruptState
|
|
2876
|
+
});
|
|
2877
|
+
}, "Subscriber onInterruptStateChanged error:");
|
|
2878
|
+
}
|
|
2879
|
+
subscribe(n) {
|
|
2880
|
+
return super.subscribe(n);
|
|
2881
|
+
}
|
|
2882
|
+
async waitForPendingFrameworkUpdates() {
|
|
2883
|
+
await Ce();
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
function Nr(a, t) {
|
|
2887
|
+
e.push(t, !0);
|
|
2888
|
+
let n = e.prop(t, "headers", 19, () => ({})), r = e.prop(t, "properties", 19, () => ({})), s = e.prop(t, "agents__unsafe_dev_only", 19, () => ({})), o = e.prop(t, "selfManagedAgents", 19, () => ({})), g = e.prop(t, "renderToolCalls", 19, () => []), c = e.prop(t, "renderActivityMessages", 19, () => []), p = e.prop(t, "renderCustomMessages", 19, () => []), m = e.prop(t, "frontendTools", 19, () => []), _ = e.prop(t, "humanInTheLoop", 19, () => []);
|
|
2889
|
+
const R = "X-CopilotCloud-Public-Api-Key", L = "https://api.cloud.copilotkit.ai/copilotkit/v1", E = e.derived(() => t.publicApiKey ?? t.publicLicenseKey), M = e.derived(() => ({ ...s(), ...o() })), x = e.derived(() => typeof n() == "function" ? n()() : n()), k = e.derived(() => {
|
|
2890
|
+
const u = { ...e.get(x) };
|
|
2891
|
+
return e.get(E) && !u[R] && (u[R] = e.get(E)), u;
|
|
2892
|
+
}), A = e.derived(() => t.runtimeUrl ?? (e.get(E) ? L : void 0)), h = e.derived(() => {
|
|
2893
|
+
var u;
|
|
2894
|
+
return !!((u = t.a2ui) != null && u.catalog);
|
|
2895
|
+
}), d = e.derived(() => e.get(h) ? { ...r(), a2uiCatalogAvailable: !0 } : r());
|
|
2896
|
+
function y(u) {
|
|
2897
|
+
const S = (u ?? []).map((O) => O.name).join(", ");
|
|
2898
|
+
throw new Error(`CopilotKitProvider humanInTheLoop (${S}) cannot be registered. Use registerHumanInTheLoop so each invocation is resolved by tool call id.`);
|
|
2899
|
+
}
|
|
2900
|
+
const b = e.derived(() => [...m()]), i = e.derived(() => {
|
|
2901
|
+
const u = [...g()];
|
|
2902
|
+
for (const S of m())
|
|
2903
|
+
if (S.render) {
|
|
2904
|
+
const O = S.parameters ?? Se.any();
|
|
2905
|
+
u.push({
|
|
2906
|
+
name: S.name,
|
|
2907
|
+
args: O,
|
|
2908
|
+
agentId: S.agentId,
|
|
2909
|
+
render: S.render
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
return u;
|
|
2913
|
+
});
|
|
2914
|
+
let f = e.state(e.proxy({})), P = e.state(e.proxy(ve.Disconnected)), v = e.state(void 0), l = e.state("auto"), w = e.state(e.proxy({})), F = e.state(void 0), U = e.state(void 0), V = e.state(void 0), T = new yr({});
|
|
2915
|
+
const K = t.runtimeUrl ?? (e.get(E) ? L : void 0);
|
|
2916
|
+
K && (T.setRuntimeUrl(K), e.set(v, K, !0));
|
|
2917
|
+
const C = new St();
|
|
2918
|
+
Ge(le, {
|
|
2919
|
+
get copilotkit() {
|
|
2920
|
+
return T;
|
|
2921
|
+
},
|
|
2922
|
+
get executingToolCallIds() {
|
|
2923
|
+
return C;
|
|
2924
|
+
},
|
|
2925
|
+
get agents() {
|
|
2926
|
+
return e.get(f);
|
|
2927
|
+
},
|
|
2928
|
+
get runtimeConnectionStatus() {
|
|
2929
|
+
return e.get(P);
|
|
2930
|
+
},
|
|
2931
|
+
get runtimeUrl() {
|
|
2932
|
+
return e.get(v);
|
|
2933
|
+
},
|
|
2934
|
+
get runtimeTransport() {
|
|
2935
|
+
return e.get(l);
|
|
2936
|
+
},
|
|
2937
|
+
get headers() {
|
|
2938
|
+
return e.get(w);
|
|
2939
|
+
},
|
|
2940
|
+
get credentials() {
|
|
2941
|
+
return t.credentials;
|
|
2942
|
+
},
|
|
2943
|
+
get threadEndpoints() {
|
|
2944
|
+
return e.get(F);
|
|
2945
|
+
},
|
|
2946
|
+
get intelligence() {
|
|
2947
|
+
return e.get(U);
|
|
2948
|
+
},
|
|
2949
|
+
get licenseStatus() {
|
|
2950
|
+
return e.get(V);
|
|
2951
|
+
}
|
|
2952
|
+
}), e.user_effect(() => {
|
|
2953
|
+
const u = t.useSingleEndpoint === !0 ? "single" : t.useSingleEndpoint === !1 ? "rest" : "auto";
|
|
2954
|
+
T.setRuntimeUrl(e.get(A)), T.setRuntimeTransport(u), T.setHeaders(e.get(k)), T.setCredentials(t.credentials), T.setProperties(e.get(d)), T.setAgents__unsafe_dev_only(e.get(M)), T.setDebug(t.debug), T.setTools(e.get(b)), T.setRenderToolCalls(e.get(i)), T.setRenderCustomMessages(p()), T.setRenderActivityMessages(c()), t.defaultThrottleMs !== void 0 && T.setDefaultThrottleMs(t.defaultThrottleMs);
|
|
2955
|
+
}), e.user_effect(() => {
|
|
2956
|
+
e.set(f, T.agents, !0), e.set(P, T.runtimeConnectionStatus, !0), e.set(v, T.runtimeUrl, !0), e.set(l, T.runtimeTransport, !0), e.set(w, T.headers, !0), e.set(F, T.threadEndpoints, !0), e.set(U, T.intelligence, !0), e.set(V, T.licenseStatus, !0);
|
|
2957
|
+
}), e.user_effect(() => {
|
|
2958
|
+
const u = T, S = u.subscribe({
|
|
2959
|
+
onToolExecutionStart: ({ toolCallId: Q }) => {
|
|
2960
|
+
C.add(Q);
|
|
2961
|
+
},
|
|
2962
|
+
onToolExecutionEnd: ({ toolCallId: Q }) => {
|
|
2963
|
+
C.delete(Q);
|
|
2964
|
+
}
|
|
2965
|
+
}), O = u.subscribe({ onRenderToolCallsChanged: () => {
|
|
2966
|
+
} }), N = u.subscribe({ onRenderCustomMessagesChanged: () => {
|
|
2967
|
+
} }), G = u.subscribe({
|
|
2968
|
+
onRuntimeConnectionStatusChanged: ({ status: Q }) => {
|
|
2969
|
+
e.set(P, Q, !0), e.set(F, u.threadEndpoints, !0), e.set(U, u.intelligence, !0), e.set(V, u.licenseStatus, !0), e.set(v, u.runtimeUrl, !0), e.set(l, u.runtimeTransport, !0), e.set(w, u.headers, !0);
|
|
2970
|
+
},
|
|
2971
|
+
onAgentsChanged: ({ agents: Q }) => {
|
|
2972
|
+
e.set(f, { ...Q }, !0);
|
|
2973
|
+
},
|
|
2974
|
+
onHeadersChanged: ({ headers: Q }) => {
|
|
2975
|
+
e.set(w, Q, !0);
|
|
2976
|
+
}
|
|
2977
|
+
}), J = u.subscribe({
|
|
2978
|
+
onError: (Q) => {
|
|
2979
|
+
var ae;
|
|
2980
|
+
(ae = t.onError) == null || ae.call(t, Q);
|
|
2981
|
+
}
|
|
2982
|
+
});
|
|
2983
|
+
return () => {
|
|
2984
|
+
S.unsubscribe(), O.unsubscribe(), N.unsubscribe(), G.unsubscribe(), J.unsubscribe();
|
|
2985
|
+
};
|
|
2986
|
+
});
|
|
2987
|
+
var I = e.comment(), B = e.first_child(I);
|
|
2988
|
+
{
|
|
2989
|
+
var Y = (u) => {
|
|
2990
|
+
var S = e.text();
|
|
2991
|
+
e.template_effect((O) => e.set_text(S, O), [() => y(_())]), e.append(u, S);
|
|
2992
|
+
}, z = (u) => {
|
|
2993
|
+
var S = e.comment(), O = e.first_child(S);
|
|
2994
|
+
e.snippet(O, () => t.children), e.append(u, S);
|
|
2995
|
+
};
|
|
2996
|
+
e.if(B, (u) => {
|
|
2997
|
+
_().length > 0 ? u(Y) : t.children && u(z, 1);
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
e.append(a, I), e.pop();
|
|
3001
|
+
}
|
|
3002
|
+
export {
|
|
3003
|
+
tt as CopilotChat,
|
|
3004
|
+
vn as CopilotChatAssistantMessage,
|
|
3005
|
+
Qn as CopilotChatAttachmentQueue,
|
|
3006
|
+
tr as CopilotChatInput,
|
|
3007
|
+
Un as CopilotChatMessage,
|
|
3008
|
+
zn as CopilotChatMessageView,
|
|
3009
|
+
On as CopilotChatReasoningMessage,
|
|
3010
|
+
ar as CopilotChatSuggestionPill,
|
|
3011
|
+
qe as CopilotChatSuggestionView,
|
|
3012
|
+
nt as CopilotChatToggleButton,
|
|
3013
|
+
un as CopilotChatToolCallsView,
|
|
3014
|
+
In as CopilotChatUserMessage,
|
|
3015
|
+
dr as CopilotChatView,
|
|
3016
|
+
yr as CopilotKitCoreSvelte,
|
|
3017
|
+
Nr as CopilotKitProvider,
|
|
3018
|
+
Hr as CopilotPopup,
|
|
3019
|
+
Br as CopilotSidebar,
|
|
3020
|
+
At as CreateAgentUpdate,
|
|
3021
|
+
et as StreamMarkdown,
|
|
3022
|
+
Pr as connectAgentContext,
|
|
3023
|
+
Le as createAgent,
|
|
3024
|
+
zt as createAttachments,
|
|
3025
|
+
Kr as createCapabilities,
|
|
3026
|
+
Dr as createInterrupt,
|
|
3027
|
+
Ut as createSuggestions,
|
|
3028
|
+
zr as createThreads,
|
|
3029
|
+
Fr as getThreadClone,
|
|
3030
|
+
jr as loadKatexStyles,
|
|
3031
|
+
Rt as normalizeAutoScroll,
|
|
3032
|
+
Or as registerFrontendTool,
|
|
3033
|
+
Vr as registerHumanInTheLoop,
|
|
3034
|
+
Ur as registerRenderToolCall,
|
|
3035
|
+
$e as useCopilotKit
|
|
3036
|
+
};
|
|
3037
|
+
//# sourceMappingURL=index.mjs.map
|