@copilotkit/svelte 0.1.0 → 0.1.1-canary.svelte-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src → dist}/components/chat/CopilotChat.svelte +26 -1
- package/dist/components/chat/CopilotChat.svelte.d.ts +5 -1
- package/dist/components/chat/CopilotChat.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts +80 -1
- package/dist/components/chat/CopilotChatAssistantMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts +9 -1
- package/dist/components/chat/CopilotChatAttachmentQueue.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatInput.svelte.d.ts +20 -1
- package/dist/components/chat/CopilotChatInput.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts +10 -1
- package/dist/components/chat/CopilotChatMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts +14 -1
- package/dist/components/chat/CopilotChatMessageView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts +40 -1
- package/dist/components/chat/CopilotChatReasoningMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts +10 -1
- package/dist/components/chat/CopilotChatSuggestionPill.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts +10 -1
- package/dist/components/chat/CopilotChatSuggestionView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts +8 -1
- package/dist/components/chat/CopilotChatToggleButton.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts +12 -1
- package/dist/components/chat/CopilotChatToolCallsView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts +62 -1
- package/dist/components/chat/CopilotChatUserMessage.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotChatView.svelte.d.ts +32 -1
- package/dist/components/chat/CopilotChatView.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotPopup.svelte.d.ts +5 -1
- package/dist/components/chat/CopilotPopup.svelte.d.ts.map +1 -0
- package/dist/components/chat/CopilotSidebar.svelte.d.ts +5 -1
- package/dist/components/chat/CopilotSidebar.svelte.d.ts.map +1 -0
- package/dist/components/chat/StreamMarkdown.svelte.d.ts +7 -1
- package/dist/components/chat/StreamMarkdown.svelte.d.ts.map +1 -0
- package/dist/components/chat/chat-config-context.svelte.js +20 -0
- package/dist/components/chat/dispatch-after-active-run.d.ts +1 -1
- package/dist/components/chat/dispatch-after-active-run.js +31 -0
- package/dist/components/chat/markdown/CodeBlock.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/CodeBlock.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts +9 -1
- package/dist/components/chat/markdown/CodeSpan.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/Table.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/Table.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableBody.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/TableBody.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableCell.svelte.d.ts +10 -1
- package/dist/components/chat/markdown/TableCell.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableHead.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/TableHead.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/TableRow.svelte.d.ts +8 -1
- package/dist/components/chat/markdown/TableRow.svelte.d.ts.map +1 -0
- package/dist/components/chat/markdown/highlight.js +91 -0
- package/dist/components/chat/media-parts.d.ts +2 -2
- package/dist/components/chat/media-parts.js +17 -0
- package/dist/components/chat/types.d.ts +5 -3
- package/dist/components/chat/types.js +7 -0
- package/dist/components/icons/index.d.ts +1 -1
- package/dist/components/icons/index.js +1 -0
- package/dist/components/index.d.ts +17 -17
- package/dist/hooks/connect-agent-context.svelte.js +25 -0
- package/dist/hooks/create-agent.svelte.d.ts +3 -3
- package/dist/hooks/create-agent.svelte.js +341 -0
- package/dist/hooks/create-attachments.svelte.d.ts +1 -1
- package/dist/hooks/create-attachments.svelte.js +232 -0
- package/dist/hooks/create-capabilities.svelte.d.ts +1 -1
- package/dist/hooks/create-capabilities.svelte.js +17 -0
- package/dist/hooks/create-interrupt.svelte.d.ts +2 -2
- package/dist/hooks/create-interrupt.svelte.js +333 -0
- package/dist/hooks/create-suggestions.svelte.d.ts +1 -1
- package/dist/hooks/create-suggestions.svelte.js +61 -0
- package/dist/hooks/create-threads.svelte.js +230 -0
- package/dist/hooks/index.d.ts +19 -19
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/load-katex-styles.svelte.js +11 -0
- package/dist/hooks/register-frontend-tool.svelte.d.ts +1 -1
- package/dist/hooks/register-frontend-tool.svelte.js +32 -0
- package/dist/hooks/register-human-in-the-loop.svelte.d.ts +1 -1
- package/dist/hooks/register-human-in-the-loop.svelte.js +84 -0
- package/dist/hooks/register-render-tool-call.svelte.d.ts +1 -1
- package/dist/hooks/register-render-tool-call.svelte.js +26 -0
- package/dist/index.d.ts +5 -5
- package/dist/lib/svelte-core.d.ts +4 -3
- package/dist/lib/svelte-core.js +145 -0
- package/dist/providers/CopilotKitProvider.svelte.d.ts +9 -1
- package/dist/providers/CopilotKitProvider.svelte.d.ts.map +1 -0
- package/dist/providers/CopilotKitProvider.types.d.ts +4 -4
- package/dist/providers/CopilotKitProvider.types.js +1 -0
- package/dist/providers/context.d.ts +3 -3
- package/dist/providers/context.js +2 -0
- package/dist/providers/index.d.ts +5 -5
- package/dist/providers/index.js +2 -0
- package/dist/providers/useCopilotKit.d.ts +1 -1
- package/dist/providers/useCopilotKit.js +9 -0
- package/dist/styles.css +1 -2
- package/dist/types/a2ui.js +1 -0
- package/dist/types/activity-message-renderer.d.ts +3 -3
- package/dist/types/activity-message-renderer.js +1 -0
- package/dist/types/custom-message-renderer.d.ts +1 -1
- package/dist/types/custom-message-renderer.js +1 -0
- package/dist/types/frontend-tool.d.ts +2 -2
- package/dist/types/frontend-tool.js +1 -0
- package/dist/types/human-in-the-loop.d.ts +1 -1
- package/dist/types/human-in-the-loop.js +1 -0
- package/dist/types/index.d.ts +8 -8
- package/dist/types/interrupt.d.ts +1 -1
- package/dist/types/interrupt.js +1 -0
- package/dist/types/sandbox-function.d.ts +1 -1
- package/dist/types/sandbox-function.js +1 -0
- package/dist/types/tool-call-renderer.d.ts +2 -2
- package/dist/types/tool-call-renderer.js +1 -0
- package/package.json +14 -22
- package/dist/components/chat/CopilotChat.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatAssistantMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatAttachmentQueue.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatInput.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatMessageView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatReasoningMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatSuggestionPill.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatSuggestionView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatToggleButton.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatToolCallsView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatUserMessage.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotChatView.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotPopup.d.svelte.ts +0 -1
- package/dist/components/chat/CopilotSidebar.d.svelte.ts +0 -1
- package/dist/components/chat/StreamMarkdown.d.svelte.ts +0 -1
- package/dist/components/chat/chat-config-context.d.svelte.ts +0 -10
- package/dist/index.cjs +0 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -6
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -3037
- package/dist/index.mjs.map +0 -1
- package/src/components/chat/chat-config-context.svelte.ts +0 -28
- package/src/components/chat/dispatch-after-active-run.ts +0 -40
- package/src/components/chat/markdown/highlight.ts +0 -96
- package/src/components/chat/media-parts.ts +0 -34
- package/src/components/chat/types.ts +0 -176
- package/src/components/icons/index.ts +0 -23
- package/src/hooks/connect-agent-context.svelte.ts +0 -46
- package/src/hooks/create-agent.svelte.ts +0 -420
- package/src/hooks/create-attachments.svelte.ts +0 -311
- package/src/hooks/create-capabilities.svelte.ts +0 -26
- package/src/hooks/create-interrupt.svelte.ts +0 -467
- package/src/hooks/create-suggestions.svelte.ts +0 -84
- package/src/hooks/create-threads.svelte.ts +0 -337
- package/src/hooks/index.ts +0 -45
- package/src/hooks/load-katex-styles.svelte.ts +0 -13
- package/src/hooks/register-frontend-tool.svelte.ts +0 -45
- package/src/hooks/register-human-in-the-loop.svelte.ts +0 -118
- package/src/hooks/register-render-tool-call.svelte.ts +0 -75
- package/src/lib/svelte-core.ts +0 -230
- package/src/providers/CopilotKitProvider.types.ts +0 -55
- package/src/providers/context.ts +0 -26
- package/src/providers/index.ts +0 -5
- package/src/providers/useCopilotKit.ts +0 -11
- package/src/types/a2ui.ts +0 -5
- package/src/types/activity-message-renderer.ts +0 -21
- package/src/types/custom-message-renderer.ts +0 -23
- package/src/types/frontend-tool.ts +0 -8
- package/src/types/human-in-the-loop.ts +0 -40
- package/src/types/interrupt.ts +0 -32
- package/src/types/sandbox-function.ts +0 -8
- package/src/types/tool-call-renderer.ts +0 -36
- /package/{src → dist}/app.d.ts +0 -0
- /package/{src → dist}/components/chat/CopilotChatAssistantMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatAttachmentQueue.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatInput.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatMessageView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatReasoningMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatSuggestionPill.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatSuggestionView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatToggleButton.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatToolCallsView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatUserMessage.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotChatView.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotPopup.svelte +0 -0
- /package/{src → dist}/components/chat/CopilotSidebar.svelte +0 -0
- /package/{src → dist}/components/chat/StreamMarkdown.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/CodeBlock.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/CodeSpan.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/Table.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableBody.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableCell.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableHead.svelte +0 -0
- /package/{src → dist}/components/chat/markdown/TableRow.svelte +0 -0
- /package/{src/components/index.ts → dist/components/index.js} +0 -0
- /package/{src/index.ts → dist/index.js} +0 -0
- /package/{src → dist}/providers/CopilotKitProvider.svelte +0 -0
- /package/{src → dist}/styles/globals.css +0 -0
- /package/{src → dist}/styles.d.ts +0 -0
- /package/{src/types/index.ts → dist/types/index.js} +0 -0
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { setContext, getContext } from "svelte";
|
|
2
|
-
import { COPILOT_CHAT_CONFIG_KEY } from "../../providers/context";
|
|
3
|
-
|
|
4
|
-
export class ChatConfig {
|
|
5
|
-
agentId: string;
|
|
6
|
-
threadId: string | undefined;
|
|
7
|
-
hasExplicitThreadId: boolean;
|
|
8
|
-
labels: Record<string, string>;
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
agentId: string,
|
|
12
|
-
threadId?: string,
|
|
13
|
-
hasExplicitThreadId?: boolean,
|
|
14
|
-
) {
|
|
15
|
-
this.agentId = agentId;
|
|
16
|
-
this.threadId = threadId;
|
|
17
|
-
this.hasExplicitThreadId = hasExplicitThreadId ?? false;
|
|
18
|
-
this.labels = {};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function setChatConfig(config: ChatConfig): void {
|
|
23
|
-
setContext(COPILOT_CHAT_CONFIG_KEY, config);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function getChatConfig(): ChatConfig | undefined {
|
|
27
|
-
return getContext<ChatConfig | undefined>(COPILOT_CHAT_CONFIG_KEY);
|
|
28
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { AbstractAgent } from "@ag-ui/client";
|
|
2
|
-
import { isRunCompletionAware } from "@copilotkit/core";
|
|
3
|
-
|
|
4
|
-
const dispatchQueues = new WeakMap<AbstractAgent, Promise<void>>();
|
|
5
|
-
|
|
6
|
-
export async function dispatchAfterActiveRunSettles(
|
|
7
|
-
agent: AbstractAgent,
|
|
8
|
-
dispatch: () => Promise<void>,
|
|
9
|
-
): Promise<void> {
|
|
10
|
-
const previous = dispatchQueues.get(agent) ?? Promise.resolve();
|
|
11
|
-
const current = previous
|
|
12
|
-
.catch(() => {})
|
|
13
|
-
.then(async () => {
|
|
14
|
-
const maybeAware: unknown = agent;
|
|
15
|
-
const activeRunCompletionPromise = isRunCompletionAware(maybeAware)
|
|
16
|
-
? maybeAware.activeRunCompletionPromise
|
|
17
|
-
: undefined;
|
|
18
|
-
|
|
19
|
-
if (agent.isRunning && activeRunCompletionPromise) {
|
|
20
|
-
try {
|
|
21
|
-
await activeRunCompletionPromise;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
// Let the queued message proceed, but make a failed run observable.
|
|
24
|
-
console.error(
|
|
25
|
-
"CopilotChat: in-flight run rejected while queuing send",
|
|
26
|
-
error,
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await dispatch();
|
|
32
|
-
});
|
|
33
|
-
dispatchQueues.set(agent, current);
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
await current;
|
|
37
|
-
} finally {
|
|
38
|
-
if (dispatchQueues.get(agent) === current) dispatchQueues.delete(agent);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import hljs from "highlight.js";
|
|
2
|
-
|
|
3
|
-
const LANGUAGE_ALIASES: Record<string, string> = {
|
|
4
|
-
js: "javascript",
|
|
5
|
-
jsx: "javascript",
|
|
6
|
-
mjs: "javascript",
|
|
7
|
-
cjs: "javascript",
|
|
8
|
-
ts: "typescript",
|
|
9
|
-
tsx: "typescript",
|
|
10
|
-
sh: "bash",
|
|
11
|
-
shell: "bash",
|
|
12
|
-
zsh: "bash",
|
|
13
|
-
yml: "yaml",
|
|
14
|
-
md: "markdown",
|
|
15
|
-
py: "python",
|
|
16
|
-
rb: "ruby",
|
|
17
|
-
rs: "rust",
|
|
18
|
-
"c++": "cpp",
|
|
19
|
-
cs: "csharp",
|
|
20
|
-
"c#": "csharp",
|
|
21
|
-
html: "xml",
|
|
22
|
-
svg: "xml",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const EXTENSION_BY_LANGUAGE: Record<string, string> = {
|
|
26
|
-
bash: "sh",
|
|
27
|
-
c: "c",
|
|
28
|
-
cpp: "cpp",
|
|
29
|
-
csharp: "cs",
|
|
30
|
-
css: "css",
|
|
31
|
-
diff: "diff",
|
|
32
|
-
go: "go",
|
|
33
|
-
graphql: "graphql",
|
|
34
|
-
java: "java",
|
|
35
|
-
javascript: "js",
|
|
36
|
-
json: "json",
|
|
37
|
-
kotlin: "kt",
|
|
38
|
-
less: "less",
|
|
39
|
-
lua: "lua",
|
|
40
|
-
markdown: "md",
|
|
41
|
-
php: "php",
|
|
42
|
-
plaintext: "txt",
|
|
43
|
-
python: "py",
|
|
44
|
-
ruby: "rb",
|
|
45
|
-
rust: "rs",
|
|
46
|
-
scss: "scss",
|
|
47
|
-
sql: "sql",
|
|
48
|
-
swift: "swift",
|
|
49
|
-
typescript: "ts",
|
|
50
|
-
xml: "xml",
|
|
51
|
-
yaml: "yml",
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function normalizeLanguage(lang: string | undefined): string | undefined {
|
|
55
|
-
const cleaned = lang?.trim().toLowerCase().split(/\s+/)[0];
|
|
56
|
-
if (!cleaned) return undefined;
|
|
57
|
-
return LANGUAGE_ALIASES[cleaned] ?? cleaned;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function escapeHtml(value: string): string {
|
|
61
|
-
return value
|
|
62
|
-
.replace(/&/g, "&")
|
|
63
|
-
.replace(/</g, "<")
|
|
64
|
-
.replace(/>/g, ">")
|
|
65
|
-
.replace(/"/g, """)
|
|
66
|
-
.replace(/'/g, "'");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Highlights a fenced code block. Unknown languages fall back to automatic
|
|
71
|
-
* detection so highlighting still works when the fence is missing a language.
|
|
72
|
-
*/
|
|
73
|
-
export function highlightCode(code: string, lang?: string): string {
|
|
74
|
-
const language = normalizeLanguage(lang);
|
|
75
|
-
try {
|
|
76
|
-
if (language && hljs.getLanguage(language)) {
|
|
77
|
-
return hljs.highlight(code, { language, ignoreIllegals: true }).value;
|
|
78
|
-
}
|
|
79
|
-
if (code.trim().length > 0) {
|
|
80
|
-
return hljs.highlightAuto(code).value;
|
|
81
|
-
}
|
|
82
|
-
} catch {
|
|
83
|
-
// Fall through to escaped plain text on any highlighter failure.
|
|
84
|
-
}
|
|
85
|
-
return escapeHtml(code);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function getLanguageLabel(lang?: string): string {
|
|
89
|
-
return normalizeLanguage(lang) ?? "text";
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function getDownloadFilename(lang?: string): string {
|
|
93
|
-
const language = normalizeLanguage(lang);
|
|
94
|
-
const extension = (language && EXTENSION_BY_LANGUAGE[language]) || "txt";
|
|
95
|
-
return `code.${extension}`;
|
|
96
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { UserMessage } from "@ag-ui/core";
|
|
2
|
-
import type {
|
|
3
|
-
AudioInputPart,
|
|
4
|
-
DocumentInputPart,
|
|
5
|
-
ImageInputPart,
|
|
6
|
-
VideoInputPart,
|
|
7
|
-
} from "@copilotkit/shared";
|
|
8
|
-
|
|
9
|
-
export type MediaPart =
|
|
10
|
-
| ImageInputPart
|
|
11
|
-
| AudioInputPart
|
|
12
|
-
| VideoInputPart
|
|
13
|
-
| DocumentInputPart;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Keeps only the non-text parts of a user message. Mirrors the React package so
|
|
17
|
-
* sent images, audio, video and documents render above the message bubble
|
|
18
|
-
* instead of being dropped.
|
|
19
|
-
*/
|
|
20
|
-
export function getMediaParts(content: UserMessage["content"]): MediaPart[] {
|
|
21
|
-
if (!content || typeof content === "string") return [];
|
|
22
|
-
return content.filter(
|
|
23
|
-
(part): part is MediaPart =>
|
|
24
|
-
part.type === "image" ||
|
|
25
|
-
part.type === "audio" ||
|
|
26
|
-
part.type === "video" ||
|
|
27
|
-
part.type === "document",
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getMediaPartFilename(part: MediaPart): string | undefined {
|
|
32
|
-
const filename = part.metadata?.filename;
|
|
33
|
-
return typeof filename === "string" ? filename : undefined;
|
|
34
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Message,
|
|
3
|
-
AssistantMessage,
|
|
4
|
-
UserMessage,
|
|
5
|
-
ToolCall,
|
|
6
|
-
ToolMessage,
|
|
7
|
-
} from "@ag-ui/core";
|
|
8
|
-
import type { ToolCallStatus } from "@copilotkit/core";
|
|
9
|
-
import type { Suggestion } from "@copilotkit/core";
|
|
10
|
-
import type {
|
|
11
|
-
Attachment,
|
|
12
|
-
AttachmentModality,
|
|
13
|
-
AttachmentsConfig,
|
|
14
|
-
InputContent,
|
|
15
|
-
} from "@copilotkit/shared";
|
|
16
|
-
import type { CopilotKitCoreErrorCode } from "@copilotkit/core";
|
|
17
|
-
|
|
18
|
-
export type { Attachment, AttachmentModality, AttachmentsConfig, InputContent };
|
|
19
|
-
|
|
20
|
-
export type AutoScrollMode = "pin-to-bottom" | "pin-to-send" | "none";
|
|
21
|
-
|
|
22
|
-
export function normalizeAutoScroll(
|
|
23
|
-
value: AutoScrollMode | boolean | undefined,
|
|
24
|
-
): AutoScrollMode {
|
|
25
|
-
if (value === undefined || value === true) return "pin-to-bottom";
|
|
26
|
-
if (value === false) return "none";
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type CopilotChatInputMode = "input" | "transcribe" | "processing";
|
|
31
|
-
|
|
32
|
-
export type ToolsMenuItem = {
|
|
33
|
-
label: string;
|
|
34
|
-
} & (
|
|
35
|
-
| { action: () => void; items?: never }
|
|
36
|
-
| { action?: never; items: (ToolsMenuItem | "-")[] }
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
export interface CopilotChatProps {
|
|
40
|
-
agentId?: string;
|
|
41
|
-
threadId?: string;
|
|
42
|
-
throttleMs?: number;
|
|
43
|
-
labels?: Record<string, string>;
|
|
44
|
-
className?: string;
|
|
45
|
-
autoScroll?: AutoScrollMode | boolean;
|
|
46
|
-
welcomeScreen?: boolean;
|
|
47
|
-
inputValue?: string;
|
|
48
|
-
onInputChange?: (value: string) => void;
|
|
49
|
-
inputMode?: CopilotChatInputMode;
|
|
50
|
-
inputToolsMenu?: (ToolsMenuItem | "-")[];
|
|
51
|
-
attachments?: boolean | AttachmentsConfig;
|
|
52
|
-
onError?: (event: {
|
|
53
|
-
error: Error;
|
|
54
|
-
code: CopilotKitCoreErrorCode;
|
|
55
|
-
context: Record<string, unknown>;
|
|
56
|
-
}) => void;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface CopilotChatViewProps {
|
|
60
|
-
messages: Message[];
|
|
61
|
-
isRunning: boolean;
|
|
62
|
-
autoScroll?: AutoScrollMode | boolean;
|
|
63
|
-
welcomeScreen?: boolean;
|
|
64
|
-
suggestions?: Suggestion[];
|
|
65
|
-
attachments?: Attachment[];
|
|
66
|
-
inputValue?: string;
|
|
67
|
-
inputMode?: CopilotChatInputMode;
|
|
68
|
-
inputToolsMenu?: (ToolsMenuItem | "-")[];
|
|
69
|
-
isConnecting?: boolean;
|
|
70
|
-
hasExplicitThreadId?: boolean;
|
|
71
|
-
onSubmitMessage: (value: string) => void;
|
|
72
|
-
onStop?: () => void;
|
|
73
|
-
onInputChange: (value: string) => void;
|
|
74
|
-
onSelectSuggestion: (suggestion: Suggestion, index: number) => void;
|
|
75
|
-
onRemoveAttachment?: (id: string) => void;
|
|
76
|
-
onAddFile?: () => void;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface CopilotSidebarProps extends CopilotChatProps {
|
|
80
|
-
width?: number | string;
|
|
81
|
-
defaultOpen?: boolean;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface CopilotPopupProps extends CopilotChatProps {
|
|
85
|
-
width?: number | string;
|
|
86
|
-
height?: number | string;
|
|
87
|
-
clickOutsideToClose?: boolean;
|
|
88
|
-
defaultOpen?: boolean;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface CopilotChatToggleButtonProps {
|
|
92
|
-
isOpen: boolean;
|
|
93
|
-
onclick?: () => void;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface CopilotChatToolCallRenderSlotProps {
|
|
97
|
-
name: string;
|
|
98
|
-
args: unknown;
|
|
99
|
-
status: ToolCallStatus;
|
|
100
|
-
result: string | undefined;
|
|
101
|
-
toolCall: ToolCall;
|
|
102
|
-
toolMessage: ToolMessage | undefined;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface CopilotChatAssistantMessageMessageRendererSlotProps {
|
|
106
|
-
message: AssistantMessage;
|
|
107
|
-
content: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface CopilotChatAssistantMessageToolbarSlotProps {
|
|
111
|
-
message: AssistantMessage;
|
|
112
|
-
shouldShowToolbar: boolean;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface CopilotChatAssistantMessageCopyButtonSlotProps {
|
|
116
|
-
onCopy: () => Promise<void>;
|
|
117
|
-
copied: boolean;
|
|
118
|
-
label: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface CopilotChatAssistantMessageThumbsUpButtonSlotProps {
|
|
122
|
-
onThumbsUp: () => void;
|
|
123
|
-
label: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface CopilotChatAssistantMessageThumbsDownButtonSlotProps {
|
|
127
|
-
onThumbsDown: () => void;
|
|
128
|
-
label: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface CopilotChatAssistantMessageReadAloudButtonSlotProps {
|
|
132
|
-
onReadAloud: () => void;
|
|
133
|
-
label: string;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface CopilotChatAssistantMessageRegenerateButtonSlotProps {
|
|
137
|
-
onRegenerate: () => void;
|
|
138
|
-
label: string;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface CopilotChatAssistantMessageToolCallsViewSlotProps {
|
|
142
|
-
message: AssistantMessage;
|
|
143
|
-
messages: Message[];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export interface CopilotChatUserMessageMessageRendererSlotProps {
|
|
147
|
-
message: UserMessage;
|
|
148
|
-
content: string;
|
|
149
|
-
isMultiline: boolean;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface CopilotChatUserMessageToolbarSlotProps {
|
|
153
|
-
message: UserMessage;
|
|
154
|
-
showBranchNavigation: boolean;
|
|
155
|
-
hasEditAction: boolean;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface CopilotChatUserMessageCopyButtonSlotProps {
|
|
159
|
-
onCopy: () => Promise<void>;
|
|
160
|
-
copied: boolean;
|
|
161
|
-
label: string;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface CopilotChatUserMessageEditButtonSlotProps {
|
|
165
|
-
onEdit: () => void;
|
|
166
|
-
label: string;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface CopilotChatUserMessageBranchNavigationSlotProps {
|
|
170
|
-
branchIndex: number;
|
|
171
|
-
numberOfBranches: number;
|
|
172
|
-
canGoPrev: boolean;
|
|
173
|
-
canGoNext: boolean;
|
|
174
|
-
goPrev: () => void;
|
|
175
|
-
goNext: () => void;
|
|
176
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
Check as IconCheck,
|
|
3
|
-
Copy as IconCopy,
|
|
4
|
-
Download as IconDownload,
|
|
5
|
-
SquarePen as IconEdit,
|
|
6
|
-
ChevronLeft as IconChevronLeft,
|
|
7
|
-
ChevronRight as IconChevronRight,
|
|
8
|
-
ChevronDown as IconChevronDown,
|
|
9
|
-
RefreshCw as IconRefreshCw,
|
|
10
|
-
Volume2 as IconVolume2,
|
|
11
|
-
ThumbsUp as IconThumbsUp,
|
|
12
|
-
ThumbsDown as IconThumbsDown,
|
|
13
|
-
CircleCheck as IconCheckCircle,
|
|
14
|
-
Circle as IconCircle,
|
|
15
|
-
MessageCircle as IconMessageCircle,
|
|
16
|
-
X as IconX,
|
|
17
|
-
Plus as IconPlus,
|
|
18
|
-
Mic as IconMic,
|
|
19
|
-
ArrowUp as IconArrowUp,
|
|
20
|
-
Square as IconSquare,
|
|
21
|
-
LoaderCircle as IconLoader2,
|
|
22
|
-
PanelLeftOpen as IconPanelLeftOpen,
|
|
23
|
-
} from "lucide-svelte";
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { getContext } from "svelte";
|
|
2
|
-
import { COPILOT_KIT_KEY } from "../providers/context";
|
|
3
|
-
import type { CopilotKitContextValue } from "../providers/context";
|
|
4
|
-
|
|
5
|
-
export type JsonSerializable =
|
|
6
|
-
| string
|
|
7
|
-
| number
|
|
8
|
-
| boolean
|
|
9
|
-
| null
|
|
10
|
-
| JsonSerializable[]
|
|
11
|
-
| { [key: string]: JsonSerializable };
|
|
12
|
-
|
|
13
|
-
export interface AgentContextInput {
|
|
14
|
-
description: string;
|
|
15
|
-
value: JsonSerializable;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function connectAgentContext(context: AgentContextInput): void {
|
|
19
|
-
const ctx = getContext<CopilotKitContextValue | null>(COPILOT_KIT_KEY);
|
|
20
|
-
if (!ctx) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
"connectAgentContext must be used within CopilotKitProvider",
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
$effect(() => {
|
|
27
|
-
const core = ctx.copilotkit;
|
|
28
|
-
const description = context.description;
|
|
29
|
-
const raw = context.value;
|
|
30
|
-
const stringValue =
|
|
31
|
-
raw === undefined
|
|
32
|
-
? ""
|
|
33
|
-
: typeof raw === "string"
|
|
34
|
-
? raw
|
|
35
|
-
: JSON.stringify(raw);
|
|
36
|
-
|
|
37
|
-
const id = core.addContext({
|
|
38
|
-
description,
|
|
39
|
-
value: stringValue,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return () => {
|
|
43
|
-
core.removeContext(id);
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
}
|