@copilotkit/vue 1.80.0 → 1.82.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/AGENTS.md +8 -7
- package/CONTRIBUTOR_GUIDE.md +120 -0
- package/PARITY.md +19 -10
- package/README.md +24 -373
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/styles.css +1 -1
- package/dist/{use-render-activity-message-BhgLK8XD.js → use-render-activity-message-CrBnMluO.js} +3190 -3148
- package/dist/use-render-activity-message-CrBnMluO.js.map +1 -0
- package/dist/use-render-activity-message-DuOFLc23.cjs +70 -0
- package/dist/use-render-activity-message-DuOFLc23.cjs.map +1 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
- package/dist/v2/components/a2ui/utils.d.ts +1 -1
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +54 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +3 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +4 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +15 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +9 -0
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/styles/globals.css +16 -0
- package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +188 -0
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +63 -0
- package/src/v2/components/a2ui/A2UICatalogContext.ts +14 -2
- package/src/v2/components/a2ui/catalog.ts +44 -15
- package/src/v2/components/a2ui/utils.ts +1 -1
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +8 -3
- package/src/v2/components/chat/CopilotChatInput.vue +2 -2
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +11 -1
- package/src/v2/components/chat/CopilotChatView.vue +1 -1
- package/src/v2/components/chat/CopilotModalHeader.vue +4 -1
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +11 -1
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +3 -1
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +198 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +2 -1
- package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +69 -0
- package/src/v2/providers/CopilotKitProvider.types.ts +15 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +50 -0
- package/src/v2/providers/types.ts +9 -0
- package/dist/use-render-activity-message-BhgLK8XD.js.map +0 -1
- package/dist/use-render-activity-message-DfvDG9VF.cjs +0 -70
- package/dist/use-render-activity-message-DfvDG9VF.cjs.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { h } from "vue";
|
|
6
|
+
import { mount } from "@vue/test-utils";
|
|
7
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
8
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
9
|
+
import CopilotChatView from "../CopilotChatView.vue";
|
|
10
|
+
|
|
11
|
+
const CHAT_ROOT_SELECTOR = ".copilotKitChat[data-copilotkit]";
|
|
12
|
+
|
|
13
|
+
// Resolve from this file, so the read does not depend on the working directory.
|
|
14
|
+
// (A `new URL(...)` object fails here: under jsdom it is not Node's URL.)
|
|
15
|
+
const globalsCss = readFileSync(
|
|
16
|
+
resolve(
|
|
17
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
18
|
+
"../../../../styles/globals.css",
|
|
19
|
+
),
|
|
20
|
+
{ encoding: "utf8" },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
/** Returns the body of the first `@layer <name> { ... }` block. */
|
|
24
|
+
function layerBody(css: string, name: string): string {
|
|
25
|
+
const start = css.indexOf(`@layer ${name} {`);
|
|
26
|
+
if (start === -1) return "";
|
|
27
|
+
let depth = 0;
|
|
28
|
+
for (let i = css.indexOf("{", start); i < css.length; i++) {
|
|
29
|
+
if (css[i] === "{") depth++;
|
|
30
|
+
if (css[i] === "}" && --depth === 0) {
|
|
31
|
+
return css.slice(css.indexOf("{", start) + 1, i);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function mountChatView(props: Record<string, unknown>) {
|
|
38
|
+
return mount(CopilotKitProvider, {
|
|
39
|
+
props: { runtimeUrl: "/api/copilotkit" },
|
|
40
|
+
slots: {
|
|
41
|
+
default: () =>
|
|
42
|
+
h(
|
|
43
|
+
CopilotChatConfigurationProvider,
|
|
44
|
+
{ threadId: "t1" },
|
|
45
|
+
{ default: () => h(CopilotChatView, props) },
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// PE-1053, the Vue side of PE-788: the chat root is an inline-size container
|
|
52
|
+
// (`cpk:@container`), so its content gives it no intrinsic width. As a flex
|
|
53
|
+
// item in a row its auto width collapsed to a narrow column. jsdom does no
|
|
54
|
+
// layout, so these tests pin the two halves of the fix: the base-layer width
|
|
55
|
+
// rule, and a chat root that the rule's selector matches.
|
|
56
|
+
describe("CopilotChatView root width (PE-1053)", () => {
|
|
57
|
+
it("fills its container from the base layer, so app widths still win", () => {
|
|
58
|
+
const base = layerBody(globalsCss, "base").replace(/\s+/g, " ");
|
|
59
|
+
expect(base).toContain(`${CHAT_ROOT_SELECTOR} { width: 100%; }`);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// The welcome screen and the message view share this one root element.
|
|
63
|
+
it("the chat root matches the width rule", () => {
|
|
64
|
+
const wrapper = mountChatView({ messages: [] });
|
|
65
|
+
const root = wrapper.find("[data-testid='copilot-chat-view']");
|
|
66
|
+
expect(root.exists()).toBe(true);
|
|
67
|
+
expect(root.element.matches(CHAT_ROOT_SELECTOR)).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -90,6 +90,21 @@ export interface CopilotKitProviderProps {
|
|
|
90
90
|
theme?: A2UITheme;
|
|
91
91
|
catalog?: any;
|
|
92
92
|
loadingComponent?: Component;
|
|
93
|
+
/**
|
|
94
|
+
* When true (the default), the full component schemas from the catalog are
|
|
95
|
+
* sent as agent context so the agent knows what components and props are
|
|
96
|
+
* available. The A2UI middleware can overwrite this with a server-side
|
|
97
|
+
* schema if configured.
|
|
98
|
+
*
|
|
99
|
+
* When false, the agent context still describes the catalog, but only by its
|
|
100
|
+
* catalog ID and the names of its custom components, without their JSON
|
|
101
|
+
* schemas. The component schema entry and the A2UI generation and design
|
|
102
|
+
* guidelines are not sent. With the CopilotKit LangGraph middleware's
|
|
103
|
+
* injected A2UI tool, the A2UI subagent then gets the component names only;
|
|
104
|
+
* a host can still give it a composition guide through the middleware's
|
|
105
|
+
* guidelines (`a2uiParams.guidelines.compositionGuide` in TypeScript,
|
|
106
|
+
* `a2ui_params["guidelines"]["composition_guide"]` in Python).
|
|
107
|
+
*/
|
|
93
108
|
includeSchema?: boolean;
|
|
94
109
|
};
|
|
95
110
|
/** Configuration for the built-in MCP Apps renderer. */
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { defineComponent, h, ref } from "vue";
|
|
3
3
|
import { mount } from "@vue/test-utils";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { Catalog } from "@a2ui/web_core/v0_9";
|
|
6
|
+
import type { ComponentApi } from "@a2ui/web_core/v0_9";
|
|
4
7
|
import CopilotKitProvider from "../CopilotKitProvider.vue";
|
|
5
8
|
import { useCopilotKit } from "../useCopilotKit";
|
|
6
9
|
|
|
@@ -76,3 +79,50 @@ describe("CopilotKitProvider a2ui catalog auto-enable", () => {
|
|
|
76
79
|
expect(a2uiRenderer).toBeUndefined();
|
|
77
80
|
});
|
|
78
81
|
});
|
|
82
|
+
|
|
83
|
+
const CAPABILITIES_DESCRIPTION =
|
|
84
|
+
"A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.";
|
|
85
|
+
|
|
86
|
+
function makeCustomCatalog(): Catalog<ComponentApi> {
|
|
87
|
+
return new Catalog<ComponentApi>(
|
|
88
|
+
"copilotkit://custom-catalog",
|
|
89
|
+
[{ name: "FlightCard", schema: z.object({ airline: z.string() }) }],
|
|
90
|
+
[],
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function capabilitiesValue(
|
|
95
|
+
core: ReturnType<typeof mountProvider>["observedCore"]["value"],
|
|
96
|
+
): string | undefined {
|
|
97
|
+
return Object.values(core?.context ?? {}).find(
|
|
98
|
+
(entry) => entry.description === CAPABILITIES_DESCRIPTION,
|
|
99
|
+
)?.value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
describe("CopilotKitProvider a2ui catalog context", () => {
|
|
103
|
+
it("lists custom components by name only when includeSchema is false", () => {
|
|
104
|
+
const { observedCore } = mountProvider({
|
|
105
|
+
a2ui: { catalog: makeCustomCatalog(), includeSchema: false },
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(capabilitiesValue(observedCore.value)).toBe(
|
|
109
|
+
[
|
|
110
|
+
"Available A2UI catalog:",
|
|
111
|
+
"- copilotkit://custom-catalog",
|
|
112
|
+
" Custom catalog (does NOT include all basic components).",
|
|
113
|
+
" Custom components:",
|
|
114
|
+
" - FlightCard",
|
|
115
|
+
].join("\n"),
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("includes custom component schemas by default", () => {
|
|
120
|
+
const { observedCore } = mountProvider({
|
|
121
|
+
a2ui: { catalog: makeCustomCatalog() },
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const value = capabilitiesValue(observedCore.value);
|
|
125
|
+
expect(value).toContain(" - FlightCard:\n {");
|
|
126
|
+
expect(value).toContain('"airline"');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -25,6 +25,15 @@ export const CopilotChatDefaultLabels = {
|
|
|
25
25
|
chatScrollToBottomLabel: "Scroll to bottom",
|
|
26
26
|
modalHeaderTitle: "CopilotKit Chat",
|
|
27
27
|
welcomeMessageText: "How can I help you today?",
|
|
28
|
+
reasoningMessageThinkingLabel: "Thinking…",
|
|
29
|
+
chatInputSlashMenuLabel: "Slash commands",
|
|
30
|
+
chatInputSlashMenuEmptyText: "No commands found",
|
|
31
|
+
attachmentRemoveButtonLabel: "Remove attachment",
|
|
32
|
+
attachmentPlayVideoButtonLabel: "Play video",
|
|
33
|
+
attachmentPreviewCloseButtonLabel: "Close preview",
|
|
34
|
+
modalHeaderCloseButtonLabel: "Close",
|
|
35
|
+
modalHeaderThreadsButtonLabel: "Open threads",
|
|
36
|
+
sidebarLabel: "Copilot chat sidebar",
|
|
28
37
|
} as const;
|
|
29
38
|
|
|
30
39
|
export type CopilotChatLabels = typeof CopilotChatDefaultLabels;
|