@copilotkit/vue 2.0.0-rc.2 → 2.0.0-rc.20
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/PARITY.md +3 -3
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +353 -16908
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-CsWYyd6r.cjs +91 -0
- package/dist/use-render-activity-message-CsWYyd6r.cjs.map +1 -0
- package/dist/use-render-activity-message-DntKKNdd.js +17418 -0
- package/dist/use-render-activity-message-DntKKNdd.js.map +1 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +2 -2
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -45
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +13 -5
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
- package/dist/v2/components/a2ui.d.ts +3 -7
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +2 -2
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +6 -270
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +2 -2
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +8 -3
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +5 -3
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +0 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
- package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +28 -25
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +2 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -1
- package/dist/v2/components/chat/message-feedback.d.ts +18 -49
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -1
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +2 -2
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-display-context.d.ts +2 -19
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +7 -20
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
- package/dist/v2/components/chat/turn-work.d.ts +0 -2
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -1
- package/dist/v2/components/chat/types.d.ts +8 -3
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts +11 -0
- package/dist/v2/components/chat/use-copy-feedback.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts +1 -1
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -1
- package/dist/v2/hooks/use-pin-to-send.d.ts +4 -12
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +197 -200
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/is-mobile-viewport.d.ts +1 -14
- package/dist/v2/lib/is-mobile-viewport.d.ts.map +1 -1
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +0 -1
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +0 -5
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/markdown-renderer.d.ts +2 -2
- package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -46
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -35
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/components/A2UIMessageRenderer.ts +3 -3
- package/src/v2/components/InlineFeatureWarning.vue +20 -21
- package/src/v2/components/LicenseWarningBanner.vue +27 -135
- package/src/v2/components/OpenGenerativeUIRenderer.ts +51 -373
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +1 -1
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +60 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +55 -6
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +1 -1
- package/src/v2/components/a2ui/A2UICatalogContext.ts +10 -102
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +1 -1
- package/src/v2/components/a2ui/catalog.ts +1 -0
- package/src/v2/components/a2ui/utils.ts +2 -0
- package/src/v2/components/a2ui.ts +1 -1
- package/src/v2/components/chat/CopilotChat.vue +19 -40
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +19 -43
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +14 -10
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +2 -2
- package/src/v2/components/chat/CopilotChatInput.vue +40 -30
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +45 -108
- package/src/v2/components/chat/CopilotChatMessageView.vue +72 -140
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +7 -15
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +60 -37
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +3 -3
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +15 -13
- package/src/v2/components/chat/CopilotChatUserMessage.vue +24 -112
- package/src/v2/components/chat/CopilotChatView.vue +5 -5
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +26 -36
- package/src/v2/components/chat/CopilotModalHeader.vue +11 -23
- package/src/v2/components/chat/CopilotPopup.vue +23 -25
- package/src/v2/components/chat/CopilotPopupView.vue +10 -39
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +14 -34
- package/src/v2/components/chat/CopilotSidebar.vue +23 -25
- package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +14 -34
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +4 -4
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +5 -5
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +33 -1
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +1 -99
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +3 -19
- package/src/v2/components/chat/forwarded-slots.ts +17 -0
- package/src/v2/components/chat/index.ts +0 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +10 -16
- package/src/v2/components/chat/message-feedback.ts +62 -197
- package/src/v2/components/chat/normalize-auto-scroll.ts +3 -17
- package/src/v2/components/chat/tool-call-display-context.ts +2 -23
- package/src/v2/components/chat/tool-call-group-parts.ts +44 -85
- package/src/v2/components/chat/turn-work.ts +0 -9
- package/src/v2/components/chat/types.ts +12 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-copy-feedback.ts +21 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -27
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +62 -1
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +105 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-attachments.ts +6 -2
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-keyboard-height.ts +17 -40
- package/src/v2/hooks/use-pin-to-send.ts +15 -99
- package/src/v2/hooks/use-render-activity-message.ts +27 -48
- package/src/v2/hooks/use-render-custom-messages.ts +14 -35
- package/src/v2/lib/__tests__/shallow-stable.test.ts +54 -0
- package/src/v2/lib/is-mobile-viewport.ts +5 -23
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/shallow-stable.ts +2 -16
- package/src/v2/lib/vue-core.ts +9 -13
- package/src/v2/providers/CopilotKitProvider.types.ts +0 -5
- package/src/v2/providers/CopilotKitProvider.vue +53 -112
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +1 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +3 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +17 -33
- package/src/v2/providers/markdown-renderer.ts +2 -2
- package/src/v2/providers/types.ts +3 -49
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +5 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -38
- package/tsconfig.json +0 -1
- package/vite.config.ts +3 -4
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/components/chat/tool-call-layout.d.ts +0 -115
- package/dist/v2/components/chat/tool-call-layout.d.ts.map +0 -1
- package/dist/v2/lib/message-feedback.d.ts +0 -33
- package/dist/v2/lib/message-feedback.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/src/v2/components/chat/BasicMarkdown.vue +0 -160
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -39
- package/src/v2/components/chat/tool-call-layout.ts +0 -304
- package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +0 -48
- package/src/v2/lib/__tests__/message-feedback.test.ts +0 -152
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/message-feedback.ts +0 -120
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -11,12 +11,7 @@ import type { VueToolCallRenderer } from "../../../types";
|
|
|
11
11
|
import { useDefaultRenderTool } from "../../../hooks/use-default-render-tool";
|
|
12
12
|
import CopilotChatMessageView from "../CopilotChatMessageView.vue";
|
|
13
13
|
import CopilotChatToolCallsView from "../CopilotChatToolCallsView.vue";
|
|
14
|
-
import {
|
|
15
|
-
getToolCallLayouts,
|
|
16
|
-
getToolCallRendererNames,
|
|
17
|
-
getTurnWork,
|
|
18
|
-
} from "../tool-call-layout";
|
|
19
|
-
import type { CopilotChatToolCallDisplay } from "../tool-call-layout";
|
|
14
|
+
import type { CopilotChatToolCallDisplay } from "@copilotkit/core";
|
|
20
15
|
|
|
21
16
|
// Ported from React's CopilotChatMessageView.toolCallDisplay tests.
|
|
22
17
|
|
|
@@ -55,13 +50,6 @@ const weather = defineToolCallRenderer({
|
|
|
55
50
|
render: () => h("div", { "data-testid": "weather-card" }, "Weather"),
|
|
56
51
|
});
|
|
57
52
|
|
|
58
|
-
const names = {
|
|
59
|
-
named: new Set(["weather"]),
|
|
60
|
-
groupedNames: new Set<string>(),
|
|
61
|
-
wildcard: true,
|
|
62
|
-
wildcardGroups: true,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
53
|
interface ViewState {
|
|
66
54
|
messages: Ref<Message[]>;
|
|
67
55
|
isRunning: Ref<boolean>;
|
|
@@ -118,92 +106,6 @@ function renderView(
|
|
|
118
106
|
const firstButton = (element: HTMLElement) =>
|
|
119
107
|
within(element).getAllByRole("button")[0]!;
|
|
120
108
|
|
|
121
|
-
describe("getToolCallLayouts", () => {
|
|
122
|
-
it("groups calls made in a row across messages, owned by the first", () => {
|
|
123
|
-
const messages = [
|
|
124
|
-
question,
|
|
125
|
-
callMessage("a"),
|
|
126
|
-
result("a"),
|
|
127
|
-
callMessage("b"),
|
|
128
|
-
result("b"),
|
|
129
|
-
];
|
|
130
|
-
const layouts = getToolCallLayouts(messages, messages, names);
|
|
131
|
-
|
|
132
|
-
const first = layouts.get("m-a")!.segments;
|
|
133
|
-
expect(first).toHaveLength(1);
|
|
134
|
-
expect(first[0]).toMatchObject({ kind: "group", trailing: true });
|
|
135
|
-
expect(
|
|
136
|
-
first[0]!.kind === "group" && first[0]!.calls.map((c) => c.toolCall.id),
|
|
137
|
-
).toEqual(["a", "b"]);
|
|
138
|
-
expect(layouts.get("m-b")!.segments).toEqual([]);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("starts a new group after text or a call with its own renderer", () => {
|
|
142
|
-
const messages = [
|
|
143
|
-
question,
|
|
144
|
-
callMessage("a"),
|
|
145
|
-
say("t", "Checking more."),
|
|
146
|
-
callMessage("b"),
|
|
147
|
-
callMessage("w", "weather"),
|
|
148
|
-
callMessage("c"),
|
|
149
|
-
];
|
|
150
|
-
const layouts = getToolCallLayouts(messages, messages, names);
|
|
151
|
-
const kinds = ["m-a", "m-b", "m-w", "m-c"].map((id) =>
|
|
152
|
-
layouts.get(id)!.segments.map((segment) => segment.kind),
|
|
153
|
-
);
|
|
154
|
-
expect(kinds).toEqual([["group"], ["group"], ["call"], ["group"]]);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("changes its signature when a result arrives for a call it holds", () => {
|
|
158
|
-
const before = [question, callMessage("a"), callMessage("b")];
|
|
159
|
-
const after = [...before, result("b")];
|
|
160
|
-
const signature = (messages: Message[]) =>
|
|
161
|
-
getToolCallLayouts(messages, messages, names).get("m-a")!.signature;
|
|
162
|
-
expect(signature(after)).not.toBe(signature(before));
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe("getTurnWork", () => {
|
|
167
|
-
it("treats everything up to the last call as work, and the rest as the reply", () => {
|
|
168
|
-
const messages = [
|
|
169
|
-
question,
|
|
170
|
-
say("t1", "Looking."),
|
|
171
|
-
callMessage("a"),
|
|
172
|
-
result("a"),
|
|
173
|
-
say("t2", "The answer."),
|
|
174
|
-
];
|
|
175
|
-
const layouts = getToolCallLayouts(messages, messages, names);
|
|
176
|
-
const turn = getTurnWork(messages, layouts).get("u1")!;
|
|
177
|
-
expect([...turn.workMessageIds]).toEqual(["t1", "m-a"]);
|
|
178
|
-
expect(turn.firstMessageId).toBe("t1");
|
|
179
|
-
expect(turn.calls).toHaveLength(1);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe("getToolCallRendererNames", () => {
|
|
184
|
-
const renderers = [
|
|
185
|
-
{ name: "*", group: true },
|
|
186
|
-
{ name: "search", group: true },
|
|
187
|
-
];
|
|
188
|
-
|
|
189
|
-
it("reads the renderers' group opt-in", () => {
|
|
190
|
-
const result = getToolCallRendererNames(renderers);
|
|
191
|
-
expect([...result.groupedNames]).toEqual(["search"]);
|
|
192
|
-
expect(result.wildcardGroups).toBe(true);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("never groups calls a tool-call slot draws", () => {
|
|
196
|
-
const named = getToolCallRendererNames(renderers, ["tool-call-search"]);
|
|
197
|
-
expect(named.named.has("search")).toBe(true);
|
|
198
|
-
expect(named.groupedNames.has("search")).toBe(false);
|
|
199
|
-
expect(named.wildcardGroups).toBe(true);
|
|
200
|
-
|
|
201
|
-
const wildcard = getToolCallRendererNames(renderers, ["tool-call"]);
|
|
202
|
-
expect(wildcard.groupedNames.size).toBe(0);
|
|
203
|
-
expect(wildcard.wildcardGroups).toBe(false);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
109
|
describe("CopilotChatMessageView toolCallDisplay", () => {
|
|
208
110
|
const burst = [
|
|
209
111
|
question,
|
|
@@ -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
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Message, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
2
2
|
import { contentToText } from "@ag-ui/core";
|
|
3
3
|
import { DEFAULT_AGENT_ID } from "@copilotkit/shared";
|
|
4
|
-
import { ToolCallStatus } from "@copilotkit/core";
|
|
4
|
+
import { ToolCallStatus, ɵresolveToolCallRenderer } from "@copilotkit/core";
|
|
5
5
|
import { partialJSONParse } from "@copilotkit/shared";
|
|
6
6
|
import type { CopilotChatToolCallRenderSlotProps } from "./types";
|
|
7
7
|
import type {
|
|
@@ -24,23 +24,6 @@ export function getToolCallSlotName(toolName: string): `tool-call-${string}` {
|
|
|
24
24
|
return `tool-call-${toolName}`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function getCoreRenderConfig(
|
|
28
|
-
toolCall: ToolCall,
|
|
29
|
-
renderToolCalls: readonly VueToolCallRenderer<unknown>[],
|
|
30
|
-
agentId: string,
|
|
31
|
-
): VueToolCallRenderer<unknown> | undefined {
|
|
32
|
-
const exactMatches = renderToolCalls.filter(
|
|
33
|
-
(renderConfig) => renderConfig.name === toolCall.function.name,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
exactMatches.find((renderConfig) => renderConfig.agentId === agentId) ??
|
|
38
|
-
exactMatches.find((renderConfig) => !renderConfig.agentId) ??
|
|
39
|
-
exactMatches[0] ??
|
|
40
|
-
renderToolCalls.find((renderConfig) => renderConfig.name === "*")
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
27
|
export function getToolCallRenderProps(
|
|
45
28
|
toolCall: ToolCall,
|
|
46
29
|
messages: Message[],
|
|
@@ -122,6 +105,7 @@ export function getToolCallMemoDeps(
|
|
|
122
105
|
toolCall.function.arguments,
|
|
123
106
|
findToolMessage(messages, toolCall.id)?.content,
|
|
124
107
|
executingToolCallIds.has(toolCall.id),
|
|
125
|
-
|
|
108
|
+
ɵresolveToolCallRenderer(renderToolCalls, toolCall.function.name, agentId)
|
|
109
|
+
?.render,
|
|
126
110
|
];
|
|
127
111
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
|
-
export { default as BasicMarkdown } from "./BasicMarkdown.vue";
|
|
3
2
|
export { default as StreamingMarkdownDefault } from "./StreamingMarkdownDefault.vue";
|
|
4
3
|
export { default as CopilotChatAssistantMessage } from "./CopilotChatAssistantMessage.vue";
|
|
5
4
|
export { default as CopilotChatAudioRecorder } from "./CopilotChatAudioRecorder.vue";
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
+
import { ɵinspectorShortcuts } from "@copilotkit/core";
|
|
1
2
|
import { onBeforeUnmount, readonly, ref } from "vue";
|
|
2
3
|
import type { Ref } from "vue";
|
|
3
4
|
|
|
4
|
-
// Page-lifetime preference, shared by every message and chat. Deliberately
|
|
5
|
-
// avoid sessionStorage: it survives reloads, while this preference must not.
|
|
6
|
-
let shortcutsHidden = false;
|
|
7
|
-
const listeners = new Set<() => void>();
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* Whether the user hid the Inspector buttons in the message toolbars ("Hide
|
|
11
|
-
* this icon"), until the page reloads.
|
|
7
|
+
* this icon"), until the page reloads. Core's `ɵinspectorShortcuts` holds
|
|
8
|
+
* the page-lifetime preference.
|
|
12
9
|
* @internal
|
|
13
10
|
*/
|
|
14
11
|
export function useInspectorShortcutsHidden(): Readonly<Ref<boolean>> {
|
|
15
|
-
const hidden = ref(
|
|
16
|
-
const
|
|
17
|
-
hidden.value =
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
onBeforeUnmount(() => listeners.delete(listener));
|
|
12
|
+
const hidden = ref(ɵinspectorShortcuts.hidden);
|
|
13
|
+
const unsubscribe = ɵinspectorShortcuts.subscribe(() => {
|
|
14
|
+
hidden.value = ɵinspectorShortcuts.hidden;
|
|
15
|
+
});
|
|
16
|
+
onBeforeUnmount(unsubscribe);
|
|
21
17
|
return readonly(hidden);
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
/** Hides the Inspector buttons of every message until the page reloads. */
|
|
25
21
|
export function hideInspectorShortcuts(): void {
|
|
26
|
-
|
|
27
|
-
listeners.forEach((listener) => listener());
|
|
22
|
+
ɵinspectorShortcuts.hide();
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
/** @internal Shows the buttons again, so each test starts fresh. */
|
|
31
26
|
export function ɵresetInspectorShortcuts(): void {
|
|
32
|
-
|
|
33
|
-
listeners.forEach((listener) => listener());
|
|
27
|
+
ɵinspectorShortcuts.reset();
|
|
34
28
|
}
|