@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
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type InterruptResolveFn = (
|
|
9
|
-
payload?: unknown,
|
|
10
|
-
interruptId?: string,
|
|
11
|
-
) => Promise<RunAgentResult | void>;
|
|
12
|
-
export type InterruptCancelFn = (
|
|
13
|
-
interruptId?: string,
|
|
14
|
-
) => Promise<RunAgentResult | void>;
|
|
15
|
-
|
|
16
|
-
export interface InterruptHandlerProps<TValue = unknown> {
|
|
17
|
-
event: InterruptEvent<TValue>;
|
|
18
|
-
interrupt: Interrupt | null;
|
|
19
|
-
interrupts: Interrupt[];
|
|
20
|
-
resolve: InterruptResolveFn;
|
|
21
|
-
cancel: InterruptCancelFn;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
|
|
25
|
-
event: InterruptEvent<TValue>;
|
|
26
|
-
interrupt: Interrupt | null;
|
|
27
|
-
interrupts: Interrupt[];
|
|
28
|
-
result: TResult;
|
|
29
|
-
resolve: InterruptResolveFn;
|
|
30
|
-
cancel: InterruptCancelFn;
|
|
31
|
-
}
|
|
1
|
+
export type {
|
|
2
|
+
InterruptEvent,
|
|
3
|
+
InterruptResolveFn,
|
|
4
|
+
InterruptCancelFn,
|
|
5
|
+
InterruptHandlerProps,
|
|
6
|
+
InterruptRenderProps,
|
|
7
|
+
} from "@copilotkit/core";
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ActivityMessageRenderProps,
|
|
3
|
+
ActivityMessageRendererDef,
|
|
4
|
+
} from "@copilotkit/core";
|
|
4
5
|
import type { Component, VNodeChild } from "vue";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Props a Vue activity message renderer receives. Same as core's
|
|
9
|
+
* `ActivityMessageRenderProps`.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam TActivityContent - The shape of the activity content.
|
|
12
|
+
*/
|
|
13
|
+
export type VueActivityMessageRendererProps<TActivityContent> =
|
|
14
|
+
ActivityMessageRenderProps<TActivityContent>;
|
|
12
15
|
|
|
13
16
|
export type VueActivityMessageRendererRenderFn<TActivityContent> =
|
|
14
17
|
| ((props: VueActivityMessageRendererProps<TActivityContent>) => VNodeChild)
|
|
15
18
|
| Component<VueActivityMessageRendererProps<TActivityContent>>;
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A Vue activity message renderer registration. `content` takes any
|
|
22
|
+
* Standard Schema (zod, valibot, arktype, and so on). The chat validates the
|
|
23
|
+
* activity content with it and passes the result to `render`.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TActivityContent - The shape of the activity content.
|
|
26
|
+
*/
|
|
27
|
+
export type VueActivityMessageRenderer<TActivityContent> =
|
|
28
|
+
ActivityMessageRendererDef<
|
|
29
|
+
TActivityContent,
|
|
30
|
+
VueActivityMessageRendererRenderFn<TActivityContent>
|
|
31
|
+
>;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
CustomMessageRendererDef,
|
|
3
|
+
CustomMessageRendererPosition,
|
|
4
|
+
CustomMessageRenderProps,
|
|
5
|
+
} from "@copilotkit/core";
|
|
2
6
|
import type { Component, VNodeChild } from "vue";
|
|
3
7
|
|
|
4
|
-
|
|
8
|
+
/** Where a custom message renderer draws. Same as core's type. */
|
|
9
|
+
export type VueCustomMessageRendererPosition = CustomMessageRendererPosition;
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
position: VueCustomMessageRendererPosition;
|
|
9
|
-
runId: string;
|
|
10
|
-
messageIndex: number;
|
|
11
|
-
messageIndexInRun: number;
|
|
12
|
-
numberOfMessagesInRun: number;
|
|
13
|
-
agentId: string;
|
|
14
|
-
stateSnapshot: unknown;
|
|
15
|
-
}
|
|
11
|
+
/** Props a Vue custom message renderer receives. Same as core's type. */
|
|
12
|
+
export type VueCustomMessageRendererProps = CustomMessageRenderProps;
|
|
16
13
|
|
|
17
14
|
export type VueCustomMessageRendererRenderFn =
|
|
18
15
|
| ((props: VueCustomMessageRendererProps) => VNodeChild)
|
|
19
16
|
| Component<VueCustomMessageRendererProps>;
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
/** A Vue custom message renderer registration. */
|
|
19
|
+
export type VueCustomMessageRenderer =
|
|
20
|
+
CustomMessageRendererDef<VueCustomMessageRendererRenderFn>;
|
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ToolCallRenderProps,
|
|
3
|
+
ToolCallRendererDef,
|
|
4
|
+
} from "@copilotkit/core";
|
|
3
5
|
import type { Component, VNodeChild } from "vue";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
* Props passed to a Vue tool call render function.
|
|
8
|
+
* Props passed to a Vue tool call render function. Same as core's
|
|
9
|
+
* `ToolCallRenderProps`.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam T - The shape of the tool arguments.
|
|
7
12
|
*/
|
|
8
|
-
export type VueToolCallRendererRenderProps<T> =
|
|
9
|
-
| {
|
|
10
|
-
name: string;
|
|
11
|
-
toolCallId: string;
|
|
12
|
-
args: Partial<T>;
|
|
13
|
-
status: ToolCallStatus.InProgress;
|
|
14
|
-
result: undefined;
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
name: string;
|
|
18
|
-
toolCallId: string;
|
|
19
|
-
args: T;
|
|
20
|
-
status: ToolCallStatus.Executing;
|
|
21
|
-
result: undefined;
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
name: string;
|
|
25
|
-
toolCallId: string;
|
|
26
|
-
args: T;
|
|
27
|
-
status: ToolCallStatus.Complete;
|
|
28
|
-
result: string;
|
|
29
|
-
};
|
|
13
|
+
export type VueToolCallRendererRenderProps<T> = ToolCallRenderProps<T>;
|
|
30
14
|
|
|
31
15
|
/**
|
|
32
16
|
* Vue component or render function for tool call rendering.
|
|
@@ -36,16 +20,17 @@ export type VueToolCallRendererRenderFn<T> =
|
|
|
36
20
|
| ((props: VueToolCallRendererRenderProps<T>) => VNodeChild)
|
|
37
21
|
| Component<VueToolCallRendererRenderProps<T>>;
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
23
|
+
type VueToolCallRendererDef<T> = ToolCallRendererDef<
|
|
24
|
+
T,
|
|
25
|
+
VueToolCallRendererRenderFn<T>
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A Vue tool call renderer registration: core's `ToolCallRendererDef` with a
|
|
30
|
+
* Vue render function. `args` is required here. Use `defineToolCallRenderer`
|
|
31
|
+
* to build one; it fills in `args` for a `"*"` renderer that has no schema.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The shape of the tool arguments.
|
|
34
|
+
*/
|
|
35
|
+
export type VueToolCallRenderer<T = unknown> = VueToolCallRendererDef<T> &
|
|
36
|
+
Required<Pick<VueToolCallRendererDef<T>, "args">>;
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -13,7 +13,7 @@ export default defineConfig({
|
|
|
13
13
|
lib: {
|
|
14
14
|
entry: {
|
|
15
15
|
index: resolve(__dirname, "src/index.ts"),
|
|
16
|
-
"v2/index": resolve(__dirname, "src/index.ts"),
|
|
16
|
+
"v2/index": resolve(__dirname, "src/v2/index.ts"),
|
|
17
17
|
},
|
|
18
18
|
name: "CopilotKitVue",
|
|
19
19
|
formats: ["es", "cjs"],
|
|
@@ -28,6 +28,8 @@ export default defineConfig({
|
|
|
28
28
|
"@a2ui/web_core/v0_9/basic_catalog",
|
|
29
29
|
"@ag-ui/client",
|
|
30
30
|
"@ag-ui/core",
|
|
31
|
+
// The framework-neutral A2UI catalog description subpath (no React).
|
|
32
|
+
"@copilotkit/a2ui-renderer/catalog-schema",
|
|
31
33
|
// Core and its `/styles` subpath, so the stylesheet isn't bundled here.
|
|
32
34
|
/^@copilotkit\/core(\/.*)?$/,
|
|
33
35
|
// Keep the shared MCP Apps host + its subpaths external. The root entry
|
|
@@ -46,10 +48,7 @@ export default defineConfig({
|
|
|
46
48
|
// (duplicate top-level lit binding → "Identifier 'h' has already been
|
|
47
49
|
// declared") and risks double custom-element registration.
|
|
48
50
|
/^@copilotkit\/web-components(\/.*)?$/,
|
|
49
|
-
"@jetbrains/websandbox",
|
|
50
|
-
"lucide-vue-next",
|
|
51
51
|
"zod",
|
|
52
|
-
"zod-to-json-schema",
|
|
53
52
|
],
|
|
54
53
|
output: {
|
|
55
54
|
globals: { vue: "Vue" },
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type __VLS_Props = {
|
|
2
|
-
content: string;
|
|
3
|
-
isStreaming?: boolean;
|
|
4
|
-
};
|
|
5
|
-
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
|
-
isStreaming: boolean;
|
|
7
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
-
export default _default;
|
|
9
|
-
//# sourceMappingURL=BasicMarkdown.vue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BasicMarkdown.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/chat/BasicMarkdown.vue"],"names":[],"mappings":"AAuKA,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;;iBAAV,OAAO;;AAiM3D,wBAOG"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import type { Message, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
2
|
-
/**
|
|
3
|
-
* How the chat shows tool calls.
|
|
4
|
-
*
|
|
5
|
-
* - `"grouped"` (default): calls made in a row share one card, collapsed to a
|
|
6
|
-
* summary ("Used 3 tools") that opens to a row per call.
|
|
7
|
-
* - `"line"`: the same grouping as a quiet line of text, like the reasoning
|
|
8
|
-
* message's "Thought for 4 seconds".
|
|
9
|
-
* - `"stacked"`: the latest call on top of a stack of the earlier ones; click
|
|
10
|
-
* to fan the stack out into its cards.
|
|
11
|
-
* - `"turn"`: the agent works in the open (narration, then a row per call),
|
|
12
|
-
* and when the reply is done everything before it folds into "Worked for 9s".
|
|
13
|
-
* - `"separate"`: every call gets its own card, as before grouping existed.
|
|
14
|
-
*
|
|
15
|
-
* Only calls drawn by a renderer that opts into grouping (`group: true`) are
|
|
16
|
-
* grouped; CopilotKit's built-in card from `useDefaultRenderTool()` does. Any
|
|
17
|
-
* other call always shows on its own and splits the group around it.
|
|
18
|
-
*/
|
|
19
|
-
export type CopilotChatToolCallDisplay = "grouped" | "line" | "stacked" | "turn" | "separate";
|
|
20
|
-
/** One tool call and, once it has finished, the message carrying its result. */
|
|
21
|
-
export interface ToolCallEntry {
|
|
22
|
-
toolCall: ToolCall;
|
|
23
|
-
toolMessage?: ToolMessage;
|
|
24
|
-
}
|
|
25
|
-
export type ToolCallSegment =
|
|
26
|
-
/** Consecutive calls drawn by renderers that opted into grouping. */
|
|
27
|
-
{
|
|
28
|
-
kind: "group";
|
|
29
|
-
id: string;
|
|
30
|
-
calls: ToolCallEntry[];
|
|
31
|
-
/** Nothing renders after this group yet, so a running agent may add to it. */
|
|
32
|
-
trailing: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A call drawn by a renderer that didn't opt into grouping, or with no
|
|
36
|
-
* renderer at all. The latter renders nothing (and warns in development)
|
|
37
|
-
* without breaking a group.
|
|
38
|
-
*/
|
|
39
|
-
| {
|
|
40
|
-
kind: "call";
|
|
41
|
-
id: string;
|
|
42
|
-
call: ToolCallEntry;
|
|
43
|
-
rendered: boolean;
|
|
44
|
-
};
|
|
45
|
-
/** What one assistant message's tool-call area renders. */
|
|
46
|
-
export interface ToolCallLayout {
|
|
47
|
-
segments: ToolCallSegment[];
|
|
48
|
-
/** Changes whenever anything this layout renders changes; for memoization. */
|
|
49
|
-
signature: string;
|
|
50
|
-
}
|
|
51
|
-
/** Which tool-call renderers are registered. */
|
|
52
|
-
export interface ToolCallRendererNames {
|
|
53
|
-
/** Tool names with a renderer of their own. */
|
|
54
|
-
named: ReadonlySet<string>;
|
|
55
|
-
/** Of those, the ones whose renderer opted into grouping. */
|
|
56
|
-
groupedNames: ReadonlySet<string>;
|
|
57
|
-
/** A wildcard (`"*"`) renderer is registered. */
|
|
58
|
-
wildcard: boolean;
|
|
59
|
-
/** The wildcard renderer opted into grouping (the built-in card does). */
|
|
60
|
-
wildcardGroups: boolean;
|
|
61
|
-
}
|
|
62
|
-
/** Index of tool results by the call they answer. */
|
|
63
|
-
export declare function getToolResults(messages: Message[]): Map<string, ToolMessage>;
|
|
64
|
-
/**
|
|
65
|
-
* Lays out the tool calls of every assistant message in `rendered`.
|
|
66
|
-
*
|
|
67
|
-
* Calls drawn by a renderer that opted into grouping join the group that's
|
|
68
|
-
* open; anything else that shows between them closes it: assistant text, a
|
|
69
|
-
* user, reasoning or activity message, or a call drawn by any other renderer. A group belongs to
|
|
70
|
-
* the message where it starts, so later messages whose calls joined it render
|
|
71
|
-
* no tool calls themselves.
|
|
72
|
-
*
|
|
73
|
-
* @param rendered - The messages as the chat renders them, in order.
|
|
74
|
-
* @param all - Every message, for finding tool results (a transform may hide them).
|
|
75
|
-
* @param renderers - The registered renderers.
|
|
76
|
-
*/
|
|
77
|
-
export declare function getToolCallLayouts(rendered: Message[], all: Message[], renderers: ToolCallRendererNames): Map<string, ToolCallLayout>;
|
|
78
|
-
/**
|
|
79
|
-
* Which renderers draw tool calls, from the registered renderers and the
|
|
80
|
-
* view's tool-call slots. A slot wins over a registered renderer and never
|
|
81
|
-
* groups, since the chat can't tell what it draws: `#tool-call-<name>` takes
|
|
82
|
-
* that tool, and `#tool-call` takes every tool.
|
|
83
|
-
*
|
|
84
|
-
* @param renderers - The registered renderers (`copilotkit.renderToolCalls`).
|
|
85
|
-
* @param slotNames - The names of the slots the view was given.
|
|
86
|
-
*/
|
|
87
|
-
export declare function getToolCallRendererNames(renderers: readonly {
|
|
88
|
-
name: string;
|
|
89
|
-
group?: boolean;
|
|
90
|
-
}[], slotNames?: readonly string[]): ToolCallRendererNames;
|
|
91
|
-
/** A reply's working phase, for the `"turn"` display. */
|
|
92
|
-
export interface TurnWork {
|
|
93
|
-
/** Stable across the turn's life: the id of the user message it answers. */
|
|
94
|
-
key: string;
|
|
95
|
-
/** The first assistant-side message, where the "Worked for" line goes. */
|
|
96
|
-
firstMessageId: string;
|
|
97
|
-
/** Everything up to and including the last message with a tool call. */
|
|
98
|
-
workMessageIds: ReadonlySet<string>;
|
|
99
|
-
/**
|
|
100
|
-
* The reply's last assistant message, when it has text and is part of the
|
|
101
|
-
* work (it also calls a tool). Its text is the answer, so it stays out.
|
|
102
|
-
*/
|
|
103
|
-
replyTextMessageId?: string;
|
|
104
|
-
calls: ToolCallEntry[];
|
|
105
|
-
/** No user message follows, so the agent may still be working on it. */
|
|
106
|
-
isLatest: boolean;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Finds the working phase of every reply in `rendered`: its messages up to the
|
|
110
|
-
* last one that calls a tool. Text in there was narration; what follows is the
|
|
111
|
-
* reply itself. Replies that called no tools are omitted, except the latest,
|
|
112
|
-
* which may be about to.
|
|
113
|
-
*/
|
|
114
|
-
export declare function getTurnWork(rendered: Message[], layouts: ReadonlyMap<string, ToolCallLayout>): Map<string, TurnWork>;
|
|
115
|
-
//# sourceMappingURL=tool-call-layout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-layout.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/chat/tool-call-layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,0BAA0B,GAClC,SAAS,GACT,MAAM,GACN,SAAS,GACT,MAAM,GACN,UAAU,CAAC;AAEf,gFAAgF;AAChF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,MAAM,eAAe;AACzB,qEAAqE;AACnE;IACE,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,EAAE,OAAO,CAAC;CACnB;AACH;;;;GAIG;GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzE,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,gDAAgD;AAChD,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,6DAA6D;IAC7D,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,cAAc,EAAE,OAAO,CAAC;CACzB;AA4BD,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAM5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,OAAO,EAAE,EACnB,GAAG,EAAE,OAAO,EAAE,EACd,SAAS,EAAE,qBAAqB,GAC/B,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAuD7B;AAID;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,EACvD,SAAS,GAAE,SAAS,MAAM,EAAO,GAChC,qBAAqB,CAuBvB;AAED,yDAAyD;AACzD,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,cAAc,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,wEAAwE;IACxE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAC3C,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CA6DvB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { AssistantMessage } from "@ag-ui/core";
|
|
2
|
-
import type { CopilotKitCore } from "@copilotkit/core";
|
|
3
|
-
/** Trajectory event name for a rating of one assistant message. */
|
|
4
|
-
export declare const MESSAGE_FEEDBACK_EVENT_NAME = "message.feedback";
|
|
5
|
-
/** Longest comment kept, in characters; the rest is cut so the event stays small. */
|
|
6
|
-
export declare const MESSAGE_FEEDBACK_MAX_COMMENT_LENGTH = 1000;
|
|
7
|
-
export type MessageFeedbackRating = "up" | "down";
|
|
8
|
-
/** The rating this page gave one assistant message. */
|
|
9
|
-
export interface MessageFeedback {
|
|
10
|
-
readonly rating: MessageFeedbackRating;
|
|
11
|
-
readonly comment?: string;
|
|
12
|
-
}
|
|
13
|
-
/** The rating this page gave one message, if any. */
|
|
14
|
-
export declare function getMessageFeedback(agentId: string, threadId: string, messageId: string): MessageFeedback | undefined;
|
|
15
|
-
/** Calls `listener` whenever a rating in this Thread changes. */
|
|
16
|
-
export declare function subscribeToMessageFeedback(agentId: string, threadId: string, listener: () => void): () => void;
|
|
17
|
-
/**
|
|
18
|
-
* Sets (or, with `null`, clears) this page's rating of one message and sends
|
|
19
|
-
* it to the active Trajectory. Every change is a new event; the newest event
|
|
20
|
-
* for a `feedbackId` is the current one. Like any Trajectory event, a change
|
|
21
|
-
* made while no Trajectory captures, for example during a reconnect, is not
|
|
22
|
-
* sent; the page still shows it.
|
|
23
|
-
*/
|
|
24
|
-
export declare function setMessageFeedback(params: {
|
|
25
|
-
copilotkit: CopilotKitCore;
|
|
26
|
-
agentId: string;
|
|
27
|
-
threadId: string;
|
|
28
|
-
message: AssistantMessage;
|
|
29
|
-
feedback: MessageFeedback | null;
|
|
30
|
-
}): void;
|
|
31
|
-
/** @internal Forgets every rating, so each test starts empty. */
|
|
32
|
-
export declare function ɵresetMessageFeedbackCache(): void;
|
|
33
|
-
//# sourceMappingURL=message-feedback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-feedback.d.ts","sourceRoot":"","sources":["../../../src/v2/lib/message-feedback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAE9D,qFAAqF;AACrF,eAAO,MAAM,mCAAmC,OAAO,CAAC;AAKxD,MAAM,MAAM,qBAAqB,GAAG,IAAI,GAAG,MAAM,CAAC;AAElD,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AA2BD,qDAAqD;AACrD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,eAAe,GAAG,SAAS,CAE7B;AAED,iEAAiE;AACjE,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,IAAI,GACnB,MAAM,IAAI,CAYZ;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CAClC,GAAG,IAAI,CA4BP;AAED,iEAAiE;AACjE,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CopilotKitCoreVue } from "./vue-core";
|
|
2
|
-
import { TranscriptionErrorCode } from "@copilotkit/shared";
|
|
3
|
-
export interface TranscriptionResult {
|
|
4
|
-
text: string;
|
|
5
|
-
size: number;
|
|
6
|
-
type: string;
|
|
7
|
-
}
|
|
8
|
-
export interface TranscriptionErrorInfo {
|
|
9
|
-
code: TranscriptionErrorCode;
|
|
10
|
-
message: string;
|
|
11
|
-
retryable: boolean;
|
|
12
|
-
}
|
|
13
|
-
export { TranscriptionErrorCode };
|
|
14
|
-
export declare class TranscriptionError extends Error {
|
|
15
|
-
readonly info: TranscriptionErrorInfo;
|
|
16
|
-
constructor(info: TranscriptionErrorInfo);
|
|
17
|
-
}
|
|
18
|
-
export declare function transcribeAudio(core: CopilotKitCoreVue, audioBlob: Blob, filename?: string): Promise<TranscriptionResult>;
|
|
19
|
-
//# sourceMappingURL=transcription-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transcription-client.d.ts","sourceRoot":"","sources":["../../../src/v2/lib/transcription-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAuClC,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAgB,IAAI,EAAE,sBAAsB,CAAC;gBAEjC,IAAI,EAAE,sBAAsB;CAKzC;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,IAAI,EACf,QAAQ,GAAE,MAAyB,GAClC,OAAO,CAAC,mBAAmB,CAAC,CAiF9B"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, h } from "vue";
|
|
3
|
-
import type { VNode } from "vue";
|
|
4
|
-
import { parseMarkdown } from "@copilotkit/core";
|
|
5
|
-
import type { MarkdownToken } from "@copilotkit/core";
|
|
6
|
-
|
|
7
|
-
const props = withDefaults(
|
|
8
|
-
defineProps<{ content: string; isStreaming?: boolean }>(),
|
|
9
|
-
{ isStreaming: false },
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const tokens = computed(() => parseMarkdown(props.content ?? ""));
|
|
13
|
-
|
|
14
|
-
// Allowlist URL schemes to prevent XSS via javascript:/data:/vbscript: URIs.
|
|
15
|
-
const SAFE_HREF = /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i;
|
|
16
|
-
const SAFE_IMG_SRC = /^(https?:|data:image\/(?!svg)|\/|\.\/|\.\.\/)/i;
|
|
17
|
-
|
|
18
|
-
function sanitizeHref(href: string | undefined): string | undefined {
|
|
19
|
-
if (!href) return undefined;
|
|
20
|
-
return SAFE_HREF.test(href.trim()) ? href : undefined;
|
|
21
|
-
}
|
|
22
|
-
function sanitizeImgSrc(src: string | undefined): string | undefined {
|
|
23
|
-
if (!src) return undefined;
|
|
24
|
-
return SAFE_IMG_SRC.test(src.trim()) ? src : undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function inline(toks: MarkdownToken[] | undefined): (VNode | string)[] {
|
|
28
|
-
if (!toks) return [];
|
|
29
|
-
return toks.map((t) => {
|
|
30
|
-
switch (t.type) {
|
|
31
|
-
case "text":
|
|
32
|
-
return "tokens" in t && (t as any).tokens
|
|
33
|
-
? h("span", inline((t as any).tokens))
|
|
34
|
-
: (t as any).text;
|
|
35
|
-
case "strong":
|
|
36
|
-
return h("strong", inline((t as any).tokens));
|
|
37
|
-
case "em":
|
|
38
|
-
return h("em", inline((t as any).tokens));
|
|
39
|
-
case "del":
|
|
40
|
-
return h("del", inline((t as any).tokens));
|
|
41
|
-
case "codespan":
|
|
42
|
-
return h(
|
|
43
|
-
"code",
|
|
44
|
-
{ class: "cpk-markdown-inline-code" },
|
|
45
|
-
(t as any).text,
|
|
46
|
-
);
|
|
47
|
-
case "br":
|
|
48
|
-
return h("br");
|
|
49
|
-
case "link":
|
|
50
|
-
return h(
|
|
51
|
-
"a",
|
|
52
|
-
{
|
|
53
|
-
href: sanitizeHref((t as any).href),
|
|
54
|
-
target: "_blank",
|
|
55
|
-
rel: "noopener noreferrer",
|
|
56
|
-
},
|
|
57
|
-
(t as any).tokens ? inline((t as any).tokens) : (t as any).text,
|
|
58
|
-
);
|
|
59
|
-
case "image":
|
|
60
|
-
return h("img", {
|
|
61
|
-
src: sanitizeImgSrc((t as any).href),
|
|
62
|
-
alt: (t as any).text,
|
|
63
|
-
class: "cpk-markdown-image",
|
|
64
|
-
});
|
|
65
|
-
case "escape":
|
|
66
|
-
return (t as any).text;
|
|
67
|
-
default:
|
|
68
|
-
return "text" in t ? (t as any).text : "";
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function block(t: MarkdownToken): VNode | null {
|
|
74
|
-
switch (t.type) {
|
|
75
|
-
case "space":
|
|
76
|
-
return null;
|
|
77
|
-
case "heading": {
|
|
78
|
-
const depth = Math.min(Math.max((t as any).depth, 1), 6);
|
|
79
|
-
return h(`h${depth}`, inline((t as any).tokens));
|
|
80
|
-
}
|
|
81
|
-
case "paragraph":
|
|
82
|
-
return h("p", inline((t as any).tokens));
|
|
83
|
-
case "blockquote":
|
|
84
|
-
return h(
|
|
85
|
-
"blockquote",
|
|
86
|
-
(((t as any).tokens as MarkdownToken[] | undefined) ?? [])
|
|
87
|
-
.map(block)
|
|
88
|
-
.filter(Boolean),
|
|
89
|
-
);
|
|
90
|
-
case "code":
|
|
91
|
-
return h("pre", { class: "cpk-markdown-code-block" }, [
|
|
92
|
-
h(
|
|
93
|
-
"code",
|
|
94
|
-
{ "data-language": (t as any).lang || undefined },
|
|
95
|
-
(t as any).text,
|
|
96
|
-
),
|
|
97
|
-
]);
|
|
98
|
-
case "hr":
|
|
99
|
-
return h("hr");
|
|
100
|
-
case "list": {
|
|
101
|
-
const list = t as any;
|
|
102
|
-
const items = list.items.map((it: any) =>
|
|
103
|
-
h(
|
|
104
|
-
"li",
|
|
105
|
-
((it.tokens as MarkdownToken[] | undefined) ?? [])
|
|
106
|
-
.map(block)
|
|
107
|
-
.filter(Boolean),
|
|
108
|
-
),
|
|
109
|
-
);
|
|
110
|
-
return list.ordered
|
|
111
|
-
? h(
|
|
112
|
-
"ol",
|
|
113
|
-
{ start: typeof list.start === "number" ? list.start : undefined },
|
|
114
|
-
items,
|
|
115
|
-
)
|
|
116
|
-
: h("ul", items);
|
|
117
|
-
}
|
|
118
|
-
case "table": {
|
|
119
|
-
const tbl = t as any;
|
|
120
|
-
return h("div", { class: "cpk-markdown-table-container" }, [
|
|
121
|
-
h("table", [
|
|
122
|
-
h("thead", [
|
|
123
|
-
h(
|
|
124
|
-
"tr",
|
|
125
|
-
tbl.header.map((c: any) => h("th", inline(c.tokens))),
|
|
126
|
-
),
|
|
127
|
-
]),
|
|
128
|
-
h(
|
|
129
|
-
"tbody",
|
|
130
|
-
tbl.rows.map((row: any) =>
|
|
131
|
-
h(
|
|
132
|
-
"tr",
|
|
133
|
-
row.map((c: any) => h("td", inline(c.tokens))),
|
|
134
|
-
),
|
|
135
|
-
),
|
|
136
|
-
),
|
|
137
|
-
]),
|
|
138
|
-
]);
|
|
139
|
-
}
|
|
140
|
-
case "text":
|
|
141
|
-
return h(
|
|
142
|
-
"p",
|
|
143
|
-
(t as any).tokens ? inline((t as any).tokens) : (t as any).text,
|
|
144
|
-
);
|
|
145
|
-
default:
|
|
146
|
-
return "text" in t ? h("span", (t as any).text) : null;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const Rendered = () =>
|
|
151
|
-
h(
|
|
152
|
-
"div",
|
|
153
|
-
{ class: "copilot-chat-assistant-markdown" },
|
|
154
|
-
tokens.value.map(block).filter(Boolean),
|
|
155
|
-
);
|
|
156
|
-
</script>
|
|
157
|
-
|
|
158
|
-
<template>
|
|
159
|
-
<Rendered v-if="tokens.length" />
|
|
160
|
-
</template>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { mount } from "@vue/test-utils";
|
|
3
|
-
import BasicMarkdown from "../BasicMarkdown.vue";
|
|
4
|
-
|
|
5
|
-
describe("BasicMarkdown.vue", () => {
|
|
6
|
-
it("renders headings", () => {
|
|
7
|
-
const w = mount(BasicMarkdown, { props: { content: "# Title" } });
|
|
8
|
-
expect(w.find("h1").text()).toBe("Title");
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("renders bold/italic", () => {
|
|
12
|
-
const w = mount(BasicMarkdown, { props: { content: "**b** *i*" } });
|
|
13
|
-
expect(w.find("strong").text()).toBe("b");
|
|
14
|
-
expect(w.find("em").text()).toBe("i");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("renders code blocks", () => {
|
|
18
|
-
const w = mount(BasicMarkdown, { props: { content: "```\nx\n```" } });
|
|
19
|
-
expect(w.find("pre code").text()).toContain("x");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("renders tables", () => {
|
|
23
|
-
const w = mount(BasicMarkdown, {
|
|
24
|
-
props: { content: "| a | b |\n| --- | --- |\n| 1 | 2 |" },
|
|
25
|
-
});
|
|
26
|
-
expect(w.findAll("th")).toHaveLength(2);
|
|
27
|
-
expect(w.findAll("tbody td")).toHaveLength(2);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("renders links with safe href", () => {
|
|
31
|
-
const w = mount(BasicMarkdown, {
|
|
32
|
-
props: { content: "[CK](https://copilotkit.ai)" },
|
|
33
|
-
});
|
|
34
|
-
expect(w.find("a").attributes("href")).toBe("https://copilotkit.ai");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("neutralizes javascript: URIs in links (no XSS)", () => {
|
|
38
|
-
const w = mount(BasicMarkdown, {
|
|
39
|
-
props: { content: "[x](javascript:alert(1))" },
|
|
40
|
-
});
|
|
41
|
-
expect(w.find("a").attributes("href")).toBeUndefined();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("neutralizes javascript: image src", () => {
|
|
45
|
-
const w = mount(BasicMarkdown, {
|
|
46
|
-
props: { content: ")" },
|
|
47
|
-
});
|
|
48
|
-
expect(w.find("img").attributes("src")).toBeUndefined();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("renders nothing for empty content", () => {
|
|
52
|
-
const w = mount(BasicMarkdown, { props: { content: "" } });
|
|
53
|
-
expect(w.text()).toBe("");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("rejects data:image/svg+xml image src (SVG script vector)", () => {
|
|
57
|
-
const w = mount(BasicMarkdown, {
|
|
58
|
-
props: { content: "" },
|
|
59
|
-
});
|
|
60
|
-
expect(w.find("img").attributes("src")).toBeUndefined();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("still allows data:image/png image src", () => {
|
|
64
|
-
const w = mount(BasicMarkdown, {
|
|
65
|
-
props: { content: "" },
|
|
66
|
-
});
|
|
67
|
-
expect(w.find("img").attributes("src")).toContain("data:image/png");
|
|
68
|
-
});
|
|
69
|
-
});
|