@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,23 +1,30 @@
|
|
|
1
1
|
import type { AssistantMessage } from "@ag-ui/core";
|
|
2
2
|
import type { CopilotKitCore } from "@copilotkit/core";
|
|
3
|
-
import { computed, inject, onBeforeUnmount, ref, shallowRef, watch } from "vue";
|
|
4
|
-
import type { ComputedRef, InjectionKey, Ref } from "vue";
|
|
5
3
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
ɵFeedbackCommentController,
|
|
5
|
+
ɵgetMessageFeedbackControls,
|
|
6
|
+
ɵisLearningFeedbackEnabled,
|
|
7
|
+
ɵsubscribeToLearningFeedbackEnabled,
|
|
8
|
+
ɵsubscribeToMessageFeedback,
|
|
9
|
+
} from "@copilotkit/core";
|
|
10
|
+
import type {
|
|
11
|
+
ɵMessageFeedbackControls,
|
|
12
|
+
ɵMessageFeedbackScope,
|
|
13
|
+
} from "@copilotkit/core";
|
|
14
|
+
import { computed, inject, onBeforeUnmount, ref, shallowRef, watch } from "vue";
|
|
10
15
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
ComputedRef,
|
|
17
|
+
InjectionKey,
|
|
18
|
+
Ref,
|
|
19
|
+
ShallowRef,
|
|
20
|
+
WritableComputedRef,
|
|
21
|
+
} from "vue";
|
|
14
22
|
|
|
15
23
|
/** The chat whose assistant messages collect feedback for Learning. */
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
24
|
+
export type MessageFeedbackScope = ɵMessageFeedbackScope;
|
|
25
|
+
|
|
26
|
+
/** Current feedback for one assistant message, and how to change it. */
|
|
27
|
+
export type MessageFeedbackControls = ɵMessageFeedbackControls;
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* Provided by the message view while Learning is on for this chat. Assistant
|
|
@@ -29,68 +36,27 @@ export const MessageFeedbackScopeKey: InjectionKey<
|
|
|
29
36
|
Ref<MessageFeedbackScope | null>
|
|
30
37
|
> = Symbol("CopilotMessageFeedbackScope");
|
|
31
38
|
|
|
32
|
-
// Cores that captured since Learning was configured, for chats that mount
|
|
33
|
-
// while capture reconnects or is stopped. A Core leaves when its config goes.
|
|
34
|
-
const capturedCores = new WeakSet<CopilotKitCore>();
|
|
35
|
-
|
|
36
|
-
const rememberCapture = (copilotkit: CopilotKitCore) => {
|
|
37
|
-
if (capturedCores.has(copilotkit)) return;
|
|
38
|
-
capturedCores.add(copilotkit);
|
|
39
|
-
const unsubscribe = copilotkit.ɵsubscribeToLearningConfigured(() => {
|
|
40
|
-
if (copilotkit.ɵlearningConfigured) return;
|
|
41
|
-
capturedCores.delete(copilotkit);
|
|
42
|
-
unsubscribe();
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
39
|
/**
|
|
47
|
-
* Whether the thumbs record feedback for Learning.
|
|
48
|
-
*
|
|
49
|
-
* capture reconnects or is stopped, so the buttons do not flicker. Ratings
|
|
50
|
-
* given meanwhile still show but, like any Trajectory event, are not sent.
|
|
40
|
+
* Whether the thumbs record feedback for Learning. See core's
|
|
41
|
+
* `ɵisLearningFeedbackEnabled` for the rules.
|
|
51
42
|
* @internal
|
|
52
43
|
*/
|
|
53
44
|
export function useLearningFeedbackEnabled(
|
|
54
45
|
copilotkit: Ref<CopilotKitCore>,
|
|
55
46
|
): ComputedRef<boolean> {
|
|
56
|
-
const
|
|
57
|
-
const capturing = ref(false);
|
|
58
|
-
|
|
47
|
+
const enabled = ref(false);
|
|
59
48
|
watch(
|
|
60
49
|
copilotkit,
|
|
61
50
|
(core, _previous, onCleanup) => {
|
|
62
51
|
const read = () => {
|
|
63
|
-
|
|
64
|
-
capturing.value = core.trajectoryId !== null;
|
|
65
|
-
if (capturing.value) rememberCapture(core);
|
|
52
|
+
enabled.value = ɵisLearningFeedbackEnabled(core);
|
|
66
53
|
};
|
|
67
54
|
read();
|
|
68
|
-
|
|
69
|
-
const subscription = core.subscribe({ onTrajectoryChanged: read });
|
|
70
|
-
onCleanup(() => {
|
|
71
|
-
unsubscribeConfigured();
|
|
72
|
-
subscription.unsubscribe();
|
|
73
|
-
});
|
|
55
|
+
onCleanup(ɵsubscribeToLearningFeedbackEnabled(core, read));
|
|
74
56
|
},
|
|
75
57
|
{ immediate: true },
|
|
76
58
|
);
|
|
77
|
-
|
|
78
|
-
return computed(
|
|
79
|
-
() =>
|
|
80
|
-
configured.value &&
|
|
81
|
-
(capturing.value || capturedCores.has(copilotkit.value)),
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Current feedback for one assistant message, and how to change it. */
|
|
86
|
-
export interface MessageFeedbackControls {
|
|
87
|
-
readonly feedback: MessageFeedback | undefined;
|
|
88
|
-
/** Gives `rating`; a different rating than before starts without a comment. */
|
|
89
|
-
readonly rate: (rating: MessageFeedbackRating) => void;
|
|
90
|
-
/** Removes the rating and its comment. */
|
|
91
|
-
readonly clear: () => void;
|
|
92
|
-
/** Sets the current rating's comment; an empty one removes it. */
|
|
93
|
-
readonly comment: (comment: string) => void;
|
|
59
|
+
return computed(() => enabled.value);
|
|
94
60
|
}
|
|
95
61
|
|
|
96
62
|
/** Feedback controls for `message`, or `null` when this chat collects none. */
|
|
@@ -106,7 +72,7 @@ export function useMessageFeedback(
|
|
|
106
72
|
(current, _previous, onCleanup) => {
|
|
107
73
|
if (!current) return;
|
|
108
74
|
onCleanup(
|
|
109
|
-
|
|
75
|
+
ɵsubscribeToMessageFeedback(current.agentId, current.threadId, () => {
|
|
110
76
|
version.value++;
|
|
111
77
|
}),
|
|
112
78
|
);
|
|
@@ -118,174 +84,73 @@ export function useMessageFeedback(
|
|
|
118
84
|
const current = scope.value;
|
|
119
85
|
if (!current) return null;
|
|
120
86
|
void version.value;
|
|
121
|
-
|
|
122
|
-
const feedback = getMessageFeedback(
|
|
123
|
-
current.agentId,
|
|
124
|
-
current.threadId,
|
|
125
|
-
target.id,
|
|
126
|
-
);
|
|
127
|
-
const save = (next: MessageFeedback | null) =>
|
|
128
|
-
setMessageFeedback({ ...current, message: target, feedback: next });
|
|
129
|
-
return {
|
|
130
|
-
feedback,
|
|
131
|
-
rate: (rating) => {
|
|
132
|
-
if (feedback?.rating !== rating) save({ rating });
|
|
133
|
-
},
|
|
134
|
-
clear: () => {
|
|
135
|
-
if (feedback) save(null);
|
|
136
|
-
},
|
|
137
|
-
comment: (comment) => {
|
|
138
|
-
if (feedback) save({ rating: feedback.rating, comment });
|
|
139
|
-
},
|
|
140
|
-
};
|
|
87
|
+
return ɵgetMessageFeedbackControls(current, message.value);
|
|
141
88
|
});
|
|
142
89
|
}
|
|
143
90
|
|
|
144
|
-
/**
|
|
145
|
-
* How long the pointer may be away from the rating and its comment before the
|
|
146
|
-
* comment closes: enough to cross the gap between them, short enough that
|
|
147
|
-
* passing over a rating does not leave it open.
|
|
148
|
-
*/
|
|
149
|
-
export const FEEDBACK_COMMENT_CLOSE_DELAY_MS = 150;
|
|
150
|
-
|
|
151
91
|
/** The comment popover of one rated message: when it shows and what it holds. */
|
|
152
92
|
export interface FeedbackComment {
|
|
153
|
-
readonly open:
|
|
93
|
+
readonly open: ComputedRef<boolean>;
|
|
154
94
|
/** The comment being edited. */
|
|
155
|
-
readonly draft:
|
|
95
|
+
readonly draft: WritableComputedRef<string>;
|
|
156
96
|
/** Grows each time the field should take focus: after a keyboard rating. */
|
|
157
|
-
readonly focusRequest:
|
|
97
|
+
readonly focusRequest: ComputedRef<number>;
|
|
158
98
|
/** Whether a focus request waits; reading it answers the request. */
|
|
159
99
|
readonly takeFocusRequest: () => boolean;
|
|
160
100
|
/** The comment field, for moving focus into it. */
|
|
161
|
-
readonly input:
|
|
101
|
+
readonly input: ShallowRef<HTMLInputElement | null>;
|
|
162
102
|
/** Opens with `comment` in the field. */
|
|
163
|
-
readonly show:
|
|
103
|
+
readonly show: ɵFeedbackCommentController["show"];
|
|
164
104
|
/** The pointer or focus reached the rating or the popover. */
|
|
165
|
-
readonly enter:
|
|
105
|
+
readonly enter: ɵFeedbackCommentController["enter"];
|
|
166
106
|
/**
|
|
167
107
|
* It left them: close soon, unless the user is editing the comment or, when
|
|
168
108
|
* focus left, the pointer is still on the rating or the popover.
|
|
169
109
|
*/
|
|
170
|
-
readonly leave:
|
|
110
|
+
readonly leave: ɵFeedbackCommentController["leave"];
|
|
171
111
|
/** Tracks whether focus is in the comment form. */
|
|
172
112
|
readonly setEditing: (editing: boolean) => void;
|
|
173
113
|
/** Closes, saving a changed comment unless `save` is false. */
|
|
174
|
-
readonly close:
|
|
114
|
+
readonly close: ɵFeedbackCommentController["close"];
|
|
175
115
|
/** Moves focus back to the thumb without opening the comment again. */
|
|
176
116
|
readonly returnFocus: (target: HTMLElement | null) => void;
|
|
177
117
|
}
|
|
178
118
|
|
|
179
119
|
/**
|
|
180
|
-
* Drives the comment popover of a rated message
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* It opens when a rating is given and whenever the pointer or keyboard focus
|
|
184
|
-
* reaches the chosen thumb, with the saved comment in the field. It closes by
|
|
185
|
-
* itself shortly after the pointer leaves the thumb and the popover, unless
|
|
186
|
-
* focus is in the field: then it stays until focus moves away, Enter, or
|
|
187
|
-
* Escape. Closing saves a changed comment; Escape, a click on a thumb, and
|
|
188
|
-
* removing the rating discard it.
|
|
120
|
+
* Drives the comment popover of a rated message with core's
|
|
121
|
+
* `ɵFeedbackCommentController`, which holds the open and close rules.
|
|
189
122
|
* @internal
|
|
190
123
|
*/
|
|
191
124
|
export function useFeedbackComment(
|
|
192
125
|
controls: Ref<MessageFeedbackControls | null>,
|
|
193
126
|
): FeedbackComment {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// Whether the pointer is on the chosen thumb or the popover. Browsers that
|
|
202
|
-
// do not focus a clicked button move focus to nothing while it stays there.
|
|
203
|
-
let pointerOver = false;
|
|
204
|
-
// Set while focus moves back to the thumb, whose focus would open it again.
|
|
205
|
-
let returning = false;
|
|
206
|
-
|
|
207
|
-
const takeFocusRequest = () => {
|
|
208
|
-
const waiting = focusWaiting;
|
|
209
|
-
focusWaiting = false;
|
|
210
|
-
return waiting;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const cancelClose = () => {
|
|
214
|
-
if (timer === undefined) return;
|
|
215
|
-
clearTimeout(timer);
|
|
216
|
-
timer = undefined;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const savedComment = () => controls.value?.feedback?.comment ?? "";
|
|
220
|
-
|
|
221
|
-
const close = ({ save = true }: { save?: boolean } = {}) => {
|
|
222
|
-
cancelClose();
|
|
223
|
-
focusWaiting = false;
|
|
224
|
-
pointerOver = false;
|
|
225
|
-
if (!open.value) return;
|
|
226
|
-
const current = controls.value;
|
|
227
|
-
if (save && current?.feedback && draft.value.trim() !== savedComment())
|
|
228
|
-
current.comment(draft.value);
|
|
229
|
-
editing = false;
|
|
230
|
-
open.value = false;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const show = ({ comment, focus }: { comment: string; focus: boolean }) => {
|
|
234
|
-
cancelClose();
|
|
235
|
-
draft.value = comment;
|
|
236
|
-
if (focus) {
|
|
237
|
-
focusWaiting = true;
|
|
238
|
-
focusRequest.value++;
|
|
239
|
-
}
|
|
240
|
-
open.value = true;
|
|
241
|
-
};
|
|
242
|
-
|
|
127
|
+
const controller = new ɵFeedbackCommentController({
|
|
128
|
+
getControls: () => controls.value,
|
|
129
|
+
});
|
|
130
|
+
const state = shallowRef(controller.getSnapshot());
|
|
131
|
+
const unsubscribe = controller.subscribe(() => {
|
|
132
|
+
state.value = controller.getSnapshot();
|
|
133
|
+
});
|
|
243
134
|
// A message that unmounts (scrolled out of a virtual list) keeps its edit.
|
|
244
135
|
onBeforeUnmount(() => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
open.value &&
|
|
249
|
-
current?.feedback &&
|
|
250
|
-
draft.value.trim() !== savedComment()
|
|
251
|
-
)
|
|
252
|
-
current.comment(draft.value);
|
|
136
|
+
controller.dispose();
|
|
137
|
+
unsubscribe();
|
|
253
138
|
});
|
|
254
139
|
|
|
255
140
|
return {
|
|
256
|
-
open,
|
|
257
|
-
draft
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (via === "pointer") pointerOver = false;
|
|
271
|
-
else if (pointerOver) return;
|
|
272
|
-
cancelClose();
|
|
273
|
-
timer = setTimeout(() => {
|
|
274
|
-
timer = undefined;
|
|
275
|
-
if (!editing) close();
|
|
276
|
-
}, FEEDBACK_COMMENT_CLOSE_DELAY_MS);
|
|
277
|
-
},
|
|
278
|
-
setEditing: (value) => {
|
|
279
|
-
editing = value;
|
|
280
|
-
},
|
|
281
|
-
close,
|
|
282
|
-
returnFocus: (target) => {
|
|
283
|
-
returning = true;
|
|
284
|
-
try {
|
|
285
|
-
target?.focus();
|
|
286
|
-
} finally {
|
|
287
|
-
returning = false;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
141
|
+
open: computed(() => state.value.open),
|
|
142
|
+
draft: computed({
|
|
143
|
+
get: () => state.value.draft,
|
|
144
|
+
set: controller.setDraft,
|
|
145
|
+
}),
|
|
146
|
+
focusRequest: computed(() => state.value.focusRequest),
|
|
147
|
+
takeFocusRequest: controller.takeFocusRequest,
|
|
148
|
+
input: shallowRef<HTMLInputElement | null>(null),
|
|
149
|
+
show: controller.show,
|
|
150
|
+
enter: controller.enter,
|
|
151
|
+
leave: controller.leave,
|
|
152
|
+
setEditing: controller.setEditing,
|
|
153
|
+
close: controller.close,
|
|
154
|
+
returnFocus: controller.returnFocus,
|
|
290
155
|
};
|
|
291
156
|
}
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"pin-to-bottom",
|
|
5
|
-
"pin-to-send",
|
|
6
|
-
"none",
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
export function normalizeAutoScroll(
|
|
10
|
-
value: AutoScrollMode | boolean | undefined,
|
|
11
|
-
): AutoScrollMode {
|
|
12
|
-
if (value === undefined) return "pin-to-bottom";
|
|
13
|
-
if (value === true) return "pin-to-bottom";
|
|
14
|
-
if (value === false) return "none";
|
|
15
|
-
if ((VALID as readonly string[]).includes(value)) return value;
|
|
16
|
-
return "pin-to-bottom";
|
|
17
|
-
}
|
|
1
|
+
// The rules live in core. This module keeps the import path stable.
|
|
2
|
+
export { ɵnormalizeAutoScroll as normalizeAutoScroll } from "@copilotkit/core";
|
|
3
|
+
export type { ɵAutoScrollMode as AutoScrollMode } from "@copilotkit/core";
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
import type { ComputedRef, InjectionKey } from "vue";
|
|
2
|
-
import type {
|
|
3
|
-
CopilotChatToolCallDisplay,
|
|
4
|
-
ToolCallLayout,
|
|
5
|
-
} from "./tool-call-layout";
|
|
2
|
+
import type { ɵToolCallDisplayContextValue } from "@copilotkit/core";
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* Provided by the message view so each message's tool calls follow the view's
|
|
9
6
|
* `toolCallDisplay` without every layer passing it along.
|
|
10
7
|
* @internal
|
|
11
8
|
*/
|
|
12
|
-
export interface ToolCallDisplayContextValue {
|
|
13
|
-
display: CopilotChatToolCallDisplay;
|
|
14
|
-
isRunning: boolean;
|
|
15
|
-
/** Each assistant message's tool calls, laid out across the whole list. */
|
|
16
|
-
layouts: ReadonlyMap<string, ToolCallLayout>;
|
|
17
|
-
/**
|
|
18
|
-
* `"turn"` display: for each message in a reply's working phase, whether
|
|
19
|
-
* that work is showing. Messages not in here are the reply itself.
|
|
20
|
-
*/
|
|
21
|
-
workOpen: ReadonlyMap<string, boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* Like `workOpen`, for the messages' text: text that ends the reply stays
|
|
24
|
-
* out of it even when its message also calls a tool.
|
|
25
|
-
*/
|
|
26
|
-
workTextOpen: ReadonlyMap<string, boolean>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** @internal */
|
|
30
9
|
export const ToolCallDisplayContextKey: InjectionKey<
|
|
31
|
-
ComputedRef
|
|
10
|
+
ComputedRef<ɵToolCallDisplayContextValue>
|
|
32
11
|
> = Symbol("CopilotChatToolCallDisplay");
|
|
33
12
|
|
|
34
13
|
/**
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { defineComponent, h, onMounted, ref, watch } from "vue";
|
|
2
2
|
import type { PropType } from "vue";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ɵcountFailedToolCalls,
|
|
5
|
+
ɵformatLabel,
|
|
6
|
+
ɵgetArgumentPreview,
|
|
7
|
+
ɵstringifyToolCallPayload,
|
|
8
|
+
} from "@copilotkit/core";
|
|
9
|
+
import type {
|
|
10
|
+
CopilotChatLabels,
|
|
11
|
+
ToolCallEntry,
|
|
12
|
+
ɵToolCallRowStatus,
|
|
13
|
+
} from "@copilotkit/core";
|
|
4
14
|
import {
|
|
5
15
|
IconCheck,
|
|
6
16
|
IconChevronRight,
|
|
@@ -9,83 +19,25 @@ import {
|
|
|
9
19
|
IconX,
|
|
10
20
|
} from "../icons";
|
|
11
21
|
import { useCopilotId } from "../ui/use-id";
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
/** A call that never got a result after the run ended (Stop, an error) is "stopped". */
|
|
15
|
-
export type ToolCallStatusName = "running" | "done" | "failed" | "stopped";
|
|
22
|
+
import { useChatLabels } from "./use-chat-labels";
|
|
16
23
|
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
19
|
-
* the run has moved on or ended, its result is never coming.
|
|
25
|
+
* The label for a tool call's status ("Running", "Done", ...).
|
|
20
26
|
* @internal
|
|
21
27
|
*/
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export const statusLabels: Record<ToolCallStatusName, string> = {
|
|
36
|
-
running: "Running",
|
|
37
|
-
done: "Done",
|
|
38
|
-
failed: "Failed",
|
|
39
|
-
stopped: "Stopped",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** The first non-empty string argument: usually a command, path or query. */
|
|
43
|
-
export function argumentPreview(parameters: unknown): string | undefined {
|
|
44
|
-
if (!parameters || typeof parameters !== "object") return undefined;
|
|
45
|
-
const value = Object.values(parameters).find(
|
|
46
|
-
(v): v is string => typeof v === "string" && v.trim().length > 0,
|
|
47
|
-
);
|
|
48
|
-
return value?.replace(/\s+/g, " ");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** @internal */
|
|
52
|
-
export const entryPreview = (entry: ToolCallEntry) =>
|
|
53
|
-
argumentPreview(partialJSONParse(entry.toolCall.function.arguments));
|
|
54
|
-
|
|
55
|
-
/** "run_command ×2, read_file" */
|
|
56
|
-
export function toolNames(calls: ToolCallEntry[]): string {
|
|
57
|
-
const counts = new Map<string, number>();
|
|
58
|
-
for (const { toolCall } of calls) {
|
|
59
|
-
const name = toolCall.function.name;
|
|
60
|
-
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
61
|
-
}
|
|
62
|
-
return [...counts]
|
|
63
|
-
.map(([name, count]) => (count > 1 ? `${name} ×${count}` : name))
|
|
64
|
-
.join(", ");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** @internal */
|
|
68
|
-
export const pluralize = (count: number, noun: string) =>
|
|
69
|
-
`${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Guarded JSON.stringify for the payload blocks. A circular reference would
|
|
73
|
-
* otherwise crash the render.
|
|
74
|
-
*/
|
|
75
|
-
function stringifyPayload(value: unknown): string {
|
|
76
|
-
if (typeof value === "string") return value;
|
|
77
|
-
try {
|
|
78
|
-
return JSON.stringify(value, null, 2);
|
|
79
|
-
} catch (err) {
|
|
80
|
-
console.warn(
|
|
81
|
-
"[CopilotKit] Failed to JSON.stringify tool-call payload; falling back to String():",
|
|
82
|
-
err,
|
|
83
|
-
);
|
|
84
|
-
try {
|
|
85
|
-
return String(value);
|
|
86
|
-
} catch {
|
|
87
|
-
return "[unserializable]";
|
|
88
|
-
}
|
|
28
|
+
export function toolCallStatusLabel(
|
|
29
|
+
labels: Readonly<CopilotChatLabels>,
|
|
30
|
+
status: ɵToolCallRowStatus,
|
|
31
|
+
) {
|
|
32
|
+
switch (status) {
|
|
33
|
+
case "running":
|
|
34
|
+
return labels.toolCallStatusRunningLabel;
|
|
35
|
+
case "done":
|
|
36
|
+
return labels.toolCallStatusDoneLabel;
|
|
37
|
+
case "failed":
|
|
38
|
+
return labels.toolCallStatusFailedLabel;
|
|
39
|
+
case "stopped":
|
|
40
|
+
return labels.toolCallStatusStoppedLabel;
|
|
89
41
|
}
|
|
90
42
|
}
|
|
91
43
|
|
|
@@ -125,7 +77,7 @@ export const ToolCallStatusIcon = defineComponent({
|
|
|
125
77
|
name: "ToolCallStatusIcon",
|
|
126
78
|
props: {
|
|
127
79
|
status: {
|
|
128
|
-
type: String as PropType
|
|
80
|
+
type: String as PropType<ɵToolCallRowStatus>,
|
|
129
81
|
required: true,
|
|
130
82
|
},
|
|
131
83
|
},
|
|
@@ -173,15 +125,14 @@ export const ToolCallFailedCount = defineComponent({
|
|
|
173
125
|
calls: { type: Array as PropType<ToolCallEntry[]>, required: true },
|
|
174
126
|
},
|
|
175
127
|
setup(props) {
|
|
128
|
+
const labels = useChatLabels();
|
|
176
129
|
return () => {
|
|
177
|
-
const failed = props.calls
|
|
178
|
-
(call) => call.toolMessage?.error,
|
|
179
|
-
).length;
|
|
130
|
+
const failed = ɵcountFailedToolCalls(props.calls);
|
|
180
131
|
if (!failed) return null;
|
|
181
132
|
return h(
|
|
182
133
|
"span",
|
|
183
134
|
{ class: "cpk-tool-call-failed-count" },
|
|
184
|
-
|
|
135
|
+
ɵformatLabel(labels.value.toolCallFailedCountLabel, { count: failed }),
|
|
185
136
|
);
|
|
186
137
|
};
|
|
187
138
|
},
|
|
@@ -190,7 +141,11 @@ export const ToolCallFailedCount = defineComponent({
|
|
|
190
141
|
function payload(label: string, value: unknown) {
|
|
191
142
|
return h("div", [
|
|
192
143
|
h("div", { class: "cpk-tool-call-payload-label" }, label),
|
|
193
|
-
h(
|
|
144
|
+
h(
|
|
145
|
+
"pre",
|
|
146
|
+
{ class: "cpk-tool-call-payload-code" },
|
|
147
|
+
ɵstringifyToolCallPayload(value),
|
|
148
|
+
),
|
|
194
149
|
]);
|
|
195
150
|
}
|
|
196
151
|
|
|
@@ -206,7 +161,7 @@ export const ToolCallRow = defineComponent({
|
|
|
206
161
|
parameters: { type: null, default: undefined },
|
|
207
162
|
result: { type: null, default: undefined },
|
|
208
163
|
status: {
|
|
209
|
-
type: String as PropType
|
|
164
|
+
type: String as PropType<ɵToolCallRowStatus>,
|
|
210
165
|
required: true,
|
|
211
166
|
},
|
|
212
167
|
appearance: {
|
|
@@ -217,8 +172,9 @@ export const ToolCallRow = defineComponent({
|
|
|
217
172
|
setup(props) {
|
|
218
173
|
const open = ref(false);
|
|
219
174
|
const detailsId = useCopilotId("cpk-tool-call-row");
|
|
175
|
+
const labels = useChatLabels();
|
|
220
176
|
return () => {
|
|
221
|
-
const preview =
|
|
177
|
+
const preview = ɵgetArgumentPreview(props.parameters);
|
|
222
178
|
// Rows draw their own divider: a wrapper with `display: contents`
|
|
223
179
|
// around each call would escape a parent's divide-y.
|
|
224
180
|
return h(
|
|
@@ -261,7 +217,7 @@ export const ToolCallRow = defineComponent({
|
|
|
261
217
|
"data-testid": "copilot-tool-render-status",
|
|
262
218
|
class: "cpk-tool-call-row-status",
|
|
263
219
|
},
|
|
264
|
-
|
|
220
|
+
toolCallStatusLabel(labels.value, props.status),
|
|
265
221
|
),
|
|
266
222
|
h(IconChevronRight, {
|
|
267
223
|
"aria-hidden": "true",
|
|
@@ -278,9 +234,12 @@ export const ToolCallRow = defineComponent({
|
|
|
278
234
|
"div",
|
|
279
235
|
{ class: "cpk-tool-call-payloads cpk-tool-call-row-payloads" },
|
|
280
236
|
[
|
|
281
|
-
payload(
|
|
237
|
+
payload(
|
|
238
|
+
labels.value.toolCallArgumentsLabel,
|
|
239
|
+
props.parameters ?? {},
|
|
240
|
+
),
|
|
282
241
|
props.result !== undefined
|
|
283
|
-
? payload(
|
|
242
|
+
? payload(labels.value.toolCallResultLabel, props.result)
|
|
284
243
|
: null,
|
|
285
244
|
],
|
|
286
245
|
),
|
|
@@ -3,15 +3,6 @@ import type { FunctionalComponent } from "vue";
|
|
|
3
3
|
import { CopilotChatCollapsible } from "./tool-call-group-parts";
|
|
4
4
|
import { ToolCallDisplayContextKey } from "./tool-call-display-context";
|
|
5
5
|
|
|
6
|
-
/** "45s", "1m 5s", "2m". Used for the live timer and the final duration. */
|
|
7
|
-
export function formatDuration(ms: number): string {
|
|
8
|
-
const seconds = Math.max(0, Math.floor(ms / 1000));
|
|
9
|
-
if (seconds < 60) return `${seconds}s`;
|
|
10
|
-
const minutes = Math.floor(seconds / 60);
|
|
11
|
-
const rest = seconds % 60;
|
|
12
|
-
return rest ? `${minutes}m ${rest}s` : `${minutes}m`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
6
|
/**
|
|
16
7
|
* Folds its content away with a reply's work in the `"turn"` display. Without
|
|
17
8
|
* `open` (any other display) it renders the content as is.
|
|
@@ -15,13 +15,13 @@ import type {
|
|
|
15
15
|
AttachmentModality,
|
|
16
16
|
InputContentSource,
|
|
17
17
|
} from "@copilotkit/shared";
|
|
18
|
-
import type { CopilotChatLabels } from "../../providers/types";
|
|
19
|
-
import type { InterruptEvent } from "../../types";
|
|
20
|
-
import type { AutoScrollMode } from "./normalize-auto-scroll";
|
|
21
18
|
import type {
|
|
19
|
+
CopilotChatLabels,
|
|
22
20
|
CopilotChatToolCallDisplay,
|
|
23
21
|
ToolCallEntry,
|
|
24
|
-
} from "
|
|
22
|
+
} from "@copilotkit/core";
|
|
23
|
+
import type { InterruptEvent } from "../../types";
|
|
24
|
+
import type { AutoScrollMode } from "./normalize-auto-scroll";
|
|
25
25
|
|
|
26
26
|
export type CopilotChatInputMode = "input" | "transcribe" | "processing";
|
|
27
27
|
export type { Attachment, AttachmentsConfig, AttachmentModality };
|
|
@@ -179,7 +179,15 @@ export interface CopilotChatProps extends Omit<
|
|
|
179
179
|
| "onStartTranscribe"
|
|
180
180
|
| "onCancelTranscribe"
|
|
181
181
|
| "onFinishTranscribe"
|
|
182
|
+
// Redeclared below, deprecated: the chat sets it from its own state
|
|
183
|
+
| "inputMode"
|
|
182
184
|
> {
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated Has no effect. `CopilotChat` sets the input mode from its own
|
|
187
|
+
* transcription state. To set it yourself, render `CopilotChatView` and pass
|
|
188
|
+
* `inputMode` there.
|
|
189
|
+
*/
|
|
190
|
+
inputMode?: CopilotChatInputMode;
|
|
183
191
|
agentId?: string;
|
|
184
192
|
threadId?: string;
|
|
185
193
|
throttleMs?: number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { CopilotChatDefaultLabels } from "@copilotkit/core";
|
|
3
|
+
import type { CopilotChatLabels } from "@copilotkit/core";
|
|
4
|
+
import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The chat labels in effect: the surrounding chat configuration's, or the
|
|
8
|
+
* default English labels outside a chat.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export function useChatLabels() {
|
|
12
|
+
const config = useCopilotChatConfiguration();
|
|
13
|
+
return computed<Readonly<CopilotChatLabels>>(
|
|
14
|
+
() => config.value?.labels ?? CopilotChatDefaultLabels,
|
|
15
|
+
);
|
|
16
|
+
}
|