@copilotkit/vue 1.82.0 → 1.84.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.
Files changed (43) hide show
  1. package/PARITY.md +2 -2
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.mjs +2 -2
  4. package/dist/use-render-activity-message--gNfCK8I.cjs +70 -0
  5. package/dist/use-render-activity-message--gNfCK8I.cjs.map +1 -0
  6. package/dist/{use-render-activity-message-CrBnMluO.js → use-render-activity-message-BQ_UwNGb.js} +5125 -5407
  7. package/dist/use-render-activity-message-BQ_UwNGb.js.map +1 -0
  8. package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -1
  9. package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -1
  10. package/dist/v2/components/chat/CopilotPopup.vue.d.ts +7 -2
  11. package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
  12. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +4 -2
  13. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
  14. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +4 -2
  15. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
  16. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +7 -2
  17. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
  18. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +4 -2
  19. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
  20. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +4 -2
  21. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
  22. package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
  23. package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
  24. package/dist/v2/components/chat/index.d.ts +16 -12
  25. package/dist/v2/components/chat/index.d.ts.map +1 -1
  26. package/dist/v2/components/chat/types.d.ts +7 -1
  27. package/dist/v2/components/chat/types.d.ts.map +1 -1
  28. package/dist/v2/index.cjs +1 -1
  29. package/dist/v2/index.mjs +1 -1
  30. package/package.json +6 -6
  31. package/src/v2/components/chat/CopilotPopup.vue +23 -25
  32. package/src/v2/components/chat/CopilotPopupView.vue +10 -39
  33. package/src/v2/components/chat/CopilotPopupViewInternal.vue +14 -34
  34. package/src/v2/components/chat/CopilotSidebar.vue +23 -25
  35. package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
  36. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +14 -34
  37. package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
  38. package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
  39. package/src/v2/components/chat/forwarded-slots.ts +17 -0
  40. package/src/v2/components/chat/types.ts +8 -0
  41. package/dist/use-render-activity-message-CrBnMluO.js.map +0 -1
  42. package/dist/use-render-activity-message-DuOFLc23.cjs +0 -70
  43. package/dist/use-render-activity-message-DuOFLc23.cjs.map +0 -1
@@ -1,8 +1,9 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { h } from "vue";
2
+ import { h, nextTick } from "vue";
3
3
  import { mount } from "@vue/test-utils";
4
4
  import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
5
5
  import { StateCapturingAgent } from "../../../__tests__/utils/agents";
6
+ import { mountWithProvider } from "../../../__tests__/utils/mount";
6
7
  import CopilotPopup from "../CopilotPopup.vue";
7
8
 
8
9
  function mountPopup(
@@ -55,4 +56,92 @@ describe("CopilotPopup", () => {
55
56
  ).toBe(true);
56
57
  expect(wrapper.find("[data-copilot-popup]").exists()).toBe(false);
57
58
  });
59
+
60
+ it("forwards the scroll-view slot to the chat view", () => {
61
+ const wrapper = mountPopup(
62
+ { welcomeScreen: false },
63
+ {
64
+ "scroll-view": ({ messages }: { messages: unknown[] }) =>
65
+ h(
66
+ "div",
67
+ { "data-testid": "custom-popup-scroll-view" },
68
+ String(messages.length),
69
+ ),
70
+ },
71
+ );
72
+
73
+ expect(wrapper.get("[data-testid='custom-popup-scroll-view']").text()).toBe(
74
+ "0",
75
+ );
76
+ expect(
77
+ wrapper.find("[data-testid='copilot-chat-view-scroll']").exists(),
78
+ ).toBe(false);
79
+ });
80
+
81
+ it("forwards the interrupt slot to the chat view", async () => {
82
+ const { wrapper, getCore } = mountWithProvider(
83
+ () =>
84
+ h(
85
+ CopilotPopup,
86
+ { welcomeScreen: false },
87
+ {
88
+ interrupt: ({ event }: { event: { value: string } }) =>
89
+ h("div", { "data-testid": "popup-interrupt" }, event.value),
90
+ },
91
+ ),
92
+ {
93
+ runtimeUrl: undefined,
94
+ agents__unsafe_dev_only: { default: new StateCapturingAgent() },
95
+ },
96
+ );
97
+
98
+ getCore().setInterruptState({
99
+ event: { name: "on_interrupt", value: "slot-forwarded" },
100
+ result: null,
101
+ resolve: () => undefined,
102
+ });
103
+ await nextTick();
104
+
105
+ expect(wrapper.get("[data-testid='popup-interrupt']").text()).toBe(
106
+ "slot-forwarded",
107
+ );
108
+ });
109
+
110
+ it("forwards the assistant-message slot to the message view", () => {
111
+ const agent = new StateCapturingAgent();
112
+ agent.setMessages([
113
+ { id: "assistant-1", role: "assistant", content: "Hello from the agent" },
114
+ ]);
115
+
116
+ const { wrapper } = mountWithProvider(
117
+ () =>
118
+ h(
119
+ CopilotPopup,
120
+ { welcomeScreen: false },
121
+ {
122
+ "assistant-message": ({
123
+ message,
124
+ }: {
125
+ message: { content: string };
126
+ }) =>
127
+ h(
128
+ "div",
129
+ { "data-testid": "popup-assistant-message" },
130
+ message.content,
131
+ ),
132
+ },
133
+ ),
134
+ {
135
+ runtimeUrl: undefined,
136
+ agents__unsafe_dev_only: { default: agent },
137
+ },
138
+ );
139
+
140
+ expect(wrapper.get("[data-testid='popup-assistant-message']").text()).toBe(
141
+ "Hello from the agent",
142
+ );
143
+ expect(
144
+ wrapper.find("[data-testid='copilot-assistant-message']").exists(),
145
+ ).toBe(false);
146
+ });
58
147
  });
@@ -1,8 +1,9 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { h } from "vue";
2
+ import { h, nextTick } from "vue";
3
3
  import { mount } from "@vue/test-utils";
4
4
  import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
5
5
  import { StateCapturingAgent } from "../../../__tests__/utils/agents";
6
+ import { mountWithProvider } from "../../../__tests__/utils/mount";
6
7
  import CopilotSidebar from "../CopilotSidebar.vue";
7
8
 
8
9
  function mountSidebar(
@@ -55,4 +56,92 @@ describe("CopilotSidebar", () => {
55
56
  ).toBe(true);
56
57
  expect(wrapper.find("[data-copilot-sidebar]").exists()).toBe(false);
57
58
  });
59
+
60
+ it("forwards the scroll-view slot to the chat view", () => {
61
+ const wrapper = mountSidebar(
62
+ { welcomeScreen: false },
63
+ {
64
+ "scroll-view": ({ messages }: { messages: unknown[] }) =>
65
+ h(
66
+ "div",
67
+ { "data-testid": "custom-sidebar-scroll-view" },
68
+ String(messages.length),
69
+ ),
70
+ },
71
+ );
72
+
73
+ expect(
74
+ wrapper.get("[data-testid='custom-sidebar-scroll-view']").text(),
75
+ ).toBe("0");
76
+ expect(
77
+ wrapper.find("[data-testid='copilot-chat-view-scroll']").exists(),
78
+ ).toBe(false);
79
+ });
80
+
81
+ it("forwards the interrupt slot to the chat view", async () => {
82
+ const { wrapper, getCore } = mountWithProvider(
83
+ () =>
84
+ h(
85
+ CopilotSidebar,
86
+ { welcomeScreen: false },
87
+ {
88
+ interrupt: ({ event }: { event: { value: string } }) =>
89
+ h("div", { "data-testid": "sidebar-interrupt" }, event.value),
90
+ },
91
+ ),
92
+ {
93
+ runtimeUrl: undefined,
94
+ agents__unsafe_dev_only: { default: new StateCapturingAgent() },
95
+ },
96
+ );
97
+
98
+ getCore().setInterruptState({
99
+ event: { name: "on_interrupt", value: "slot-forwarded" },
100
+ result: null,
101
+ resolve: () => undefined,
102
+ });
103
+ await nextTick();
104
+
105
+ expect(wrapper.get("[data-testid='sidebar-interrupt']").text()).toBe(
106
+ "slot-forwarded",
107
+ );
108
+ });
109
+
110
+ it("forwards the assistant-message slot to the message view", () => {
111
+ const agent = new StateCapturingAgent();
112
+ agent.setMessages([
113
+ { id: "assistant-1", role: "assistant", content: "Hello from the agent" },
114
+ ]);
115
+
116
+ const { wrapper } = mountWithProvider(
117
+ () =>
118
+ h(
119
+ CopilotSidebar,
120
+ { welcomeScreen: false },
121
+ {
122
+ "assistant-message": ({
123
+ message,
124
+ }: {
125
+ message: { content: string };
126
+ }) =>
127
+ h(
128
+ "div",
129
+ { "data-testid": "sidebar-assistant-message" },
130
+ message.content,
131
+ ),
132
+ },
133
+ ),
134
+ {
135
+ runtimeUrl: undefined,
136
+ agents__unsafe_dev_only: { default: agent },
137
+ },
138
+ );
139
+
140
+ expect(
141
+ wrapper.get("[data-testid='sidebar-assistant-message']").text(),
142
+ ).toBe("Hello from the agent");
143
+ expect(
144
+ wrapper.find("[data-testid='copilot-assistant-message']").exists(),
145
+ ).toBe(false);
146
+ });
58
147
  });
@@ -0,0 +1,17 @@
1
+ import type { Slots } from "vue";
2
+
3
+ /**
4
+ * Returns the names of the slots that a wrapper passes on to the component it
5
+ * wraps: every slot in `slots` except the ones in `ownSlots`, which the
6
+ * wrapper renders itself.
7
+ *
8
+ * CopilotChat passes every slot except `chat-view` to CopilotChatView.
9
+ * CopilotSidebar, CopilotPopup, and their view components use this rule at
10
+ * each layer, so a slot that works on CopilotChat also works on them.
11
+ */
12
+ export function forwardedSlotNames(
13
+ slots: Slots,
14
+ ownSlots: readonly string[] = [],
15
+ ): string[] {
16
+ return Object.keys(slots).filter((name) => !ownSlots.includes(name));
17
+ }
@@ -116,7 +116,15 @@ export interface CopilotChatProps extends Omit<
116
116
  | "onStartTranscribe"
117
117
  | "onCancelTranscribe"
118
118
  | "onFinishTranscribe"
119
+ // Redeclared below, deprecated: the chat sets it from its own state
120
+ | "inputMode"
119
121
  > {
122
+ /**
123
+ * @deprecated Has no effect. `CopilotChat` sets the input mode from its own
124
+ * transcription state. To set it yourself, render `CopilotChatView` and pass
125
+ * `inputMode` there.
126
+ */
127
+ inputMode?: CopilotChatInputMode;
120
128
  agentId?: string;
121
129
  threadId?: string;
122
130
  throttleMs?: number;