@copilotkit/vue 2.0.0-rc.6 → 2.0.0-rc.8
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 +1 -1
- package/dist/index.cjs +1 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +292 -16949
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-C5LCG9a9.js +16451 -0
- package/dist/use-render-activity-message-C5LCG9a9.js.map +1 -0
- package/dist/use-render-activity-message-CPzguixR.cjs +74 -0
- package/dist/use-render-activity-message-CPzguixR.cjs.map +1 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.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/CopilotChatInput.vue.d.ts +6 -270
- package/dist/v2/components/chat/CopilotChatInput.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/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.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/index.d.ts +0 -1
- package/dist/v2/components/chat/index.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 +1 -2
- 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/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.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-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 +196 -199
- package/dist/v2/index.mjs.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.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 +7 -8
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/v2/components/LicenseWarningBanner.vue +31 -15
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +20 -0
- package/src/v2/components/chat/CopilotChat.vue +19 -40
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +14 -10
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
- package/src/v2/components/chat/CopilotChatInput.vue +40 -30
- package/src/v2/components/chat/CopilotChatMessageView.vue +72 -140
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +31 -13
- 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/CopilotChatView.vue +5 -5
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +44 -18
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- 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/copilotChatToolCallItemRender.ts +3 -19
- package/src/v2/components/chat/index.ts +0 -1
- 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 +4 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -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 +4 -3
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- 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/vue-core.ts +3 -5
- package/src/v2/providers/CopilotKitProvider.types.ts +0 -5
- package/src/v2/providers/CopilotKitProvider.vue +29 -80
- 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/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/vite.config.ts +1 -2
- 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/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/tool-call-layout.ts +0 -304
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
GENERATE_SANDBOXED_UI_DESCRIPTION,
|
|
4
4
|
randomUUID,
|
|
5
|
+
ɵanySchema,
|
|
5
6
|
} from "@copilotkit/shared";
|
|
6
7
|
import {
|
|
7
8
|
computed,
|
|
8
9
|
h,
|
|
9
10
|
onMounted,
|
|
11
|
+
onUnmounted,
|
|
10
12
|
provide,
|
|
11
13
|
ref,
|
|
12
14
|
shallowRef,
|
|
@@ -14,7 +16,7 @@ import {
|
|
|
14
16
|
watch,
|
|
15
17
|
} from "vue";
|
|
16
18
|
import type { Component, FunctionalComponent } from "vue";
|
|
17
|
-
import { z } from "zod";
|
|
19
|
+
import type { z } from "zod";
|
|
18
20
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
19
21
|
import { ToolCallStatus } from "@copilotkit/core";
|
|
20
22
|
import type {
|
|
@@ -23,7 +25,7 @@ import type {
|
|
|
23
25
|
CopilotKitHeadersSource,
|
|
24
26
|
FrontendTool,
|
|
25
27
|
} from "@copilotkit/core";
|
|
26
|
-
import { ɵwithHeaderDefaults } from "@copilotkit/core";
|
|
28
|
+
import { ɵresolveLicenseState, ɵwithHeaderDefaults } from "@copilotkit/core";
|
|
27
29
|
import { schemaToJsonSchema, shouldEnableInspector } from "@copilotkit/shared";
|
|
28
30
|
import type {
|
|
29
31
|
RuntimeEntitlementResponse,
|
|
@@ -54,11 +56,7 @@ import {
|
|
|
54
56
|
} from "./keys";
|
|
55
57
|
import type { VueInspectorOpenRequest } from "./keys";
|
|
56
58
|
import { MARKDOWN_RENDERER_KEY } from "./markdown-renderer";
|
|
57
|
-
import {
|
|
58
|
-
LicenseContextKey,
|
|
59
|
-
createLicenseContextValue,
|
|
60
|
-
} from "./license-context";
|
|
61
|
-
import type { LicenseContextValue } from "./license-context";
|
|
59
|
+
import { LicenseContextKey } from "./license-context";
|
|
62
60
|
import CopilotKitInspector from "../components/CopilotKitInspector.vue";
|
|
63
61
|
import LicenseWarningBanner from "../components/LicenseWarningBanner.vue";
|
|
64
62
|
import type {
|
|
@@ -365,7 +363,7 @@ const processedHumanInTheLoop = computed(() => {
|
|
|
365
363
|
|
|
366
364
|
renderToolCalls.push({
|
|
367
365
|
name: tool.name,
|
|
368
|
-
args: tool.parameters ??
|
|
366
|
+
args: tool.parameters ?? ɵanySchema,
|
|
369
367
|
render,
|
|
370
368
|
...(tool.agentId && { agentId: tool.agentId }),
|
|
371
369
|
} as VueToolCallRenderer<unknown>);
|
|
@@ -392,7 +390,8 @@ const allRenderToolCalls = computed(() => {
|
|
|
392
390
|
];
|
|
393
391
|
for (const tool of [...props.frontendTools, ...builtInFrontendTools.value]) {
|
|
394
392
|
if (tool.render) {
|
|
395
|
-
const args =
|
|
393
|
+
const args =
|
|
394
|
+
tool.parameters ?? (tool.name === "*" ? ɵanySchema : undefined);
|
|
396
395
|
if (args) {
|
|
397
396
|
combined.push({
|
|
398
397
|
name: tool.name,
|
|
@@ -469,7 +468,7 @@ const builtInActivityRenderers = computed<
|
|
|
469
468
|
const renderers: VueActivityMessageRenderer<unknown>[] = [
|
|
470
469
|
{
|
|
471
470
|
activityType: MCPAppsActivityType,
|
|
472
|
-
content: MCPAppsActivityContentSchema
|
|
471
|
+
content: MCPAppsActivityContentSchema,
|
|
473
472
|
render: (props.mcpApps?.allowSameOriginFallback
|
|
474
473
|
? SameOriginMCPAppsActivityRenderer
|
|
475
474
|
: MCPAppsActivityRenderer) as unknown as VueActivityMessageRenderer<unknown>["render"],
|
|
@@ -479,7 +478,7 @@ const builtInActivityRenderers = computed<
|
|
|
479
478
|
if (openGenerativeUIActive.value) {
|
|
480
479
|
renderers.push({
|
|
481
480
|
activityType: OpenGenerativeUIActivityType,
|
|
482
|
-
content: OpenGenerativeUIContentSchema
|
|
481
|
+
content: OpenGenerativeUIContentSchema,
|
|
483
482
|
render:
|
|
484
483
|
OpenGenerativeUIActivityRenderer as unknown as VueActivityMessageRenderer<unknown>["render"],
|
|
485
484
|
});
|
|
@@ -894,73 +893,26 @@ provide(CopilotKitKey, {
|
|
|
894
893
|
provide(SandboxFunctionsKey, sandboxFunctions);
|
|
895
894
|
provide(MARKDOWN_RENDERER_KEY, props.markdownRenderer);
|
|
896
895
|
|
|
897
|
-
// License context
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
);
|
|
908
|
-
const hasLegacyRuntimeEntitlementFallback = computed(
|
|
909
|
-
() =>
|
|
910
|
-
runtimeLicenseStatus.value === "valid" ||
|
|
911
|
-
runtimeLicenseStatus.value === "expiring",
|
|
912
|
-
);
|
|
913
|
-
const runtimeEntitlementRetryInProgress = computed(
|
|
914
|
-
() =>
|
|
915
|
-
retryableRuntimeEntitlementFailure.value &&
|
|
916
|
-
runtimeEntitlementRetryPending.value &&
|
|
917
|
-
!hasLegacyRuntimeEntitlementFallback.value,
|
|
918
|
-
);
|
|
919
|
-
// Only a terminal failure denies features. A retryable failure (a timeout,
|
|
920
|
-
// a network error, a 5xx) says nothing about what the project may use.
|
|
921
|
-
const terminalRuntimeEntitlementFailure = computed(
|
|
922
|
-
() =>
|
|
923
|
-
hasNonReadyRuntimeEntitlement.value &&
|
|
924
|
-
!retryableRuntimeEntitlementFailure.value &&
|
|
925
|
-
!hasLegacyRuntimeEntitlementFallback.value,
|
|
926
|
-
);
|
|
927
|
-
const licenseContextValue = computed<LicenseContextValue>(() => {
|
|
928
|
-
const runtimeLicenseContext = createLicenseContextValue(
|
|
929
|
-
runtimeEntitlementRetryInProgress.value
|
|
930
|
-
? undefined
|
|
931
|
-
: runtimeLicenseStatus.value,
|
|
932
|
-
runtimeEntitlements.value,
|
|
933
|
-
);
|
|
934
|
-
if (!terminalRuntimeEntitlementFailure.value) {
|
|
935
|
-
return runtimeLicenseContext;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
return {
|
|
939
|
-
...runtimeLicenseContext,
|
|
940
|
-
checkFeature: () => false,
|
|
941
|
-
getLimit: () => null,
|
|
942
|
-
};
|
|
943
|
-
});
|
|
896
|
+
// License context and banner, from the runtime license status and the
|
|
897
|
+
// structured entitlement response.
|
|
898
|
+
const licenseState = computed(() =>
|
|
899
|
+
ɵresolveLicenseState({
|
|
900
|
+
status: runtimeLicenseStatus.value,
|
|
901
|
+
entitlements: runtimeEntitlements.value,
|
|
902
|
+
retryPending: runtimeEntitlementRetryPending.value,
|
|
903
|
+
publicKey: resolvedPublicKey.value,
|
|
904
|
+
}),
|
|
905
|
+
);
|
|
906
|
+
const licenseContextValue = computed(() => licenseState.value.context);
|
|
944
907
|
provide(LicenseContextKey, licenseContextValue);
|
|
908
|
+
const licenseBannerType = computed(() => licenseState.value.bannerType);
|
|
945
909
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
);
|
|
951
|
-
|
|
952
|
-
() =>
|
|
953
|
-
runtimeLicenseWarningStatus.value === "none" && !resolvedPublicKey.value,
|
|
954
|
-
);
|
|
955
|
-
const showExpiredBanner = computed(
|
|
956
|
-
() => runtimeLicenseWarningStatus.value === "expired",
|
|
957
|
-
);
|
|
958
|
-
const showInvalidBanner = computed(
|
|
959
|
-
() => runtimeLicenseWarningStatus.value === "invalid",
|
|
960
|
-
);
|
|
961
|
-
const showExpiringBanner = computed(
|
|
962
|
-
() => runtimeLicenseWarningStatus.value === "expiring",
|
|
963
|
-
);
|
|
910
|
+
// The provider created this core, so it stops the core's runs, timers and
|
|
911
|
+
// subscriptions. `onUnmounted` runs after the children unmount, so their
|
|
912
|
+
// cleanup still reaches a live core.
|
|
913
|
+
onUnmounted(() => {
|
|
914
|
+
copilotkit.value.dispose();
|
|
915
|
+
});
|
|
964
916
|
</script>
|
|
965
917
|
|
|
966
918
|
<template>
|
|
@@ -971,8 +923,5 @@ const showExpiringBanner = computed(
|
|
|
971
923
|
:open-request="inspectorOpenRequest"
|
|
972
924
|
/>
|
|
973
925
|
<!-- License warnings — driven by server-reported status -->
|
|
974
|
-
<LicenseWarningBanner v-if="
|
|
975
|
-
<LicenseWarningBanner v-if="showExpiredBanner" type="expired" />
|
|
976
|
-
<LicenseWarningBanner v-if="showInvalidBanner" type="invalid" />
|
|
977
|
-
<LicenseWarningBanner v-if="showExpiringBanner" type="expiring" />
|
|
926
|
+
<LicenseWarningBanner v-if="licenseBannerType" :type="licenseBannerType" />
|
|
978
927
|
</template>
|
|
@@ -7,12 +7,12 @@ import { mount } from "@vue/test-utils";
|
|
|
7
7
|
import { defineComponent, h, nextTick } from "vue";
|
|
8
8
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
9
9
|
import { HttpAgent } from "@ag-ui/client";
|
|
10
|
+
import { ɵtranscribeAudio } from "@copilotkit/core";
|
|
10
11
|
import type { CopilotKitHeadersSource } from "@copilotkit/core";
|
|
11
12
|
import CopilotKitProvider from "../CopilotKitProvider.vue";
|
|
12
13
|
import { useCopilotKit } from "../useCopilotKit";
|
|
13
14
|
import { useAgent } from "../../hooks/use-agent";
|
|
14
15
|
import { useThreads } from "../../hooks/use-threads";
|
|
15
|
-
import { transcribeAudio } from "../../lib/transcription-client";
|
|
16
16
|
import type { CopilotKitCoreVue } from "../../lib/vue-core";
|
|
17
17
|
|
|
18
18
|
type Call = { url: string; auth: string | null; publicApiKey: string | null };
|
|
@@ -418,14 +418,14 @@ describe("CopilotKitProvider — headers builder evaluated at send time (#1937)"
|
|
|
418
418
|
// Force an actual resolution while signed in, so the header source's
|
|
419
419
|
// last snapshot is non-empty — otherwise a stale-merge bug has nothing
|
|
420
420
|
// stale to leak, and the assertion below would pass vacuously.
|
|
421
|
-
await
|
|
421
|
+
await ɵtranscribeAudio(getCore(), new Blob(["a"], { type: "audio/webm" }));
|
|
422
422
|
const firstCall = calls.find((c) => c.url.endsWith("/transcribe"));
|
|
423
423
|
expect(firstCall?.auth).toBe("Bearer x");
|
|
424
424
|
|
|
425
425
|
calls.length = 0;
|
|
426
426
|
signedIn = false;
|
|
427
427
|
|
|
428
|
-
await
|
|
428
|
+
await ɵtranscribeAudio(getCore(), new Blob(["a"], { type: "audio/webm" }));
|
|
429
429
|
const secondCall = calls.find((c) => c.url.endsWith("/transcribe"));
|
|
430
430
|
expect(secondCall).toBeDefined();
|
|
431
431
|
expect(secondCall!.auth).toBeNull();
|
|
@@ -478,7 +478,9 @@ describe("CopilotKitProvider learning prop", () => {
|
|
|
478
478
|
const app = renderApp(true);
|
|
479
479
|
|
|
480
480
|
await app.unmount();
|
|
481
|
-
|
|
481
|
+
// The learning watcher stops capture, then disposing the core stops
|
|
482
|
+
// it again. Stopping twice is safe; capture must end either way.
|
|
483
|
+
expect(stop).toHaveBeenCalled();
|
|
482
484
|
expect(History.prototype.pushState).toBe(nativePushState);
|
|
483
485
|
});
|
|
484
486
|
|
|
@@ -810,6 +810,23 @@ describe("CopilotKitProvider", () => {
|
|
|
810
810
|
});
|
|
811
811
|
});
|
|
812
812
|
|
|
813
|
+
describe("Unmount", () => {
|
|
814
|
+
it("disposes the core it created, so subscribers stop hearing from it", () => {
|
|
815
|
+
const { getCore, wrapper } = mountWithProvider(() => h("div"));
|
|
816
|
+
const core = getCore();
|
|
817
|
+
const onPropertiesChanged = vi.fn();
|
|
818
|
+
core.subscribe({ onPropertiesChanged });
|
|
819
|
+
|
|
820
|
+
core.setProperties({ before: "unmount" });
|
|
821
|
+
expect(onPropertiesChanged).toHaveBeenCalledTimes(1);
|
|
822
|
+
|
|
823
|
+
wrapper.unmount();
|
|
824
|
+
core.setProperties({ after: "unmount" });
|
|
825
|
+
|
|
826
|
+
expect(onPropertiesChanged).toHaveBeenCalledTimes(1);
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
|
|
813
830
|
describe("inspector visibility", () => {
|
|
814
831
|
async function settleInspectorLoad(): Promise<void> {
|
|
815
832
|
await vi.dynamicImportSettled();
|
|
@@ -886,39 +903,6 @@ describe("CopilotKitProvider", () => {
|
|
|
886
903
|
view.unmount();
|
|
887
904
|
});
|
|
888
905
|
|
|
889
|
-
it("does not let legacy showDevConsole disable the development Inspector", async () => {
|
|
890
|
-
const view = render(CopilotKitProvider, {
|
|
891
|
-
props: {
|
|
892
|
-
runtimeUrl: "/api/copilotkit",
|
|
893
|
-
showDevConsole: false,
|
|
894
|
-
},
|
|
895
|
-
slots: { default: "child" },
|
|
896
|
-
});
|
|
897
|
-
|
|
898
|
-
await waitFor(() => {
|
|
899
|
-
expect(
|
|
900
|
-
view.container.querySelector("cpk-web-inspector"),
|
|
901
|
-
).not.toBeNull();
|
|
902
|
-
});
|
|
903
|
-
view.unmount();
|
|
904
|
-
});
|
|
905
|
-
|
|
906
|
-
it("does not let legacy showDevConsole enable the production Inspector", async () => {
|
|
907
|
-
vi.stubEnv("NODE_ENV", "production");
|
|
908
|
-
const view = render(CopilotKitProvider, {
|
|
909
|
-
props: {
|
|
910
|
-
runtimeUrl: "/api/copilotkit",
|
|
911
|
-
showDevConsole: "auto",
|
|
912
|
-
},
|
|
913
|
-
slots: { default: "child" },
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
await settleInspectorLoad();
|
|
917
|
-
expect(view.container.querySelector("cpk-web-inspector")).toBeNull();
|
|
918
|
-
expect(defineWebInspector).not.toHaveBeenCalled();
|
|
919
|
-
view.unmount();
|
|
920
|
-
});
|
|
921
|
-
|
|
922
906
|
it("does not render or load the inspector during SSR", async () => {
|
|
923
907
|
vi.stubGlobal("window", undefined);
|
|
924
908
|
const html = await renderToString(
|
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
chatInputPlaceholder: "Type a message...",
|
|
3
|
-
chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
|
|
4
|
-
chatInputToolbarCancelTranscribeButtonLabel: "Cancel",
|
|
5
|
-
chatInputToolbarFinishTranscribeButtonLabel: "Finish",
|
|
6
|
-
chatInputToolbarAddButtonLabel: "Add photos or files",
|
|
7
|
-
chatInputToolbarToolsButtonLabel: "Tools",
|
|
8
|
-
chatInputToolbarSendButtonLabel: "Send message",
|
|
9
|
-
chatInputToolbarStopButtonLabel: "Stop",
|
|
10
|
-
assistantMessageToolbarCopyCodeLabel: "Copy",
|
|
11
|
-
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
12
|
-
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
13
|
-
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
14
|
-
assistantMessageToolbarInspectorDescription:
|
|
15
|
-
"Open this message in the Inspector",
|
|
16
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
|
|
17
|
-
assistantMessageToolbarInspectorLocalOnlyDescription:
|
|
18
|
-
"Only visible on localhost or loopback hosts in development. Never shown in production.",
|
|
19
|
-
assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
|
|
20
|
-
assistantMessageToolbarInspectorHideLabel: "Hide this icon",
|
|
21
|
-
assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
|
|
22
|
-
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
23
|
-
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
24
|
-
assistantMessageFeedbackCommentPlaceholder: "Add a comment (optional)",
|
|
25
|
-
assistantMessageFeedbackCommentSubmitLabel: "Send comment",
|
|
26
|
-
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
27
|
-
assistantMessageToolbarRegenerateLabel: "Regenerate",
|
|
28
|
-
userMessageToolbarCopyMessageLabel: "Copy",
|
|
29
|
-
userMessageToolbarEditMessageLabel: "Edit",
|
|
30
|
-
userMessageToolbarPreviousBranchLabel: "Previous branch",
|
|
31
|
-
userMessageToolbarNextBranchLabel: "Next branch",
|
|
32
|
-
chatDisclaimerText:
|
|
33
|
-
"AI can make mistakes. Please verify important information.",
|
|
34
|
-
chatToggleOpenLabel: "Open chat",
|
|
35
|
-
chatToggleCloseLabel: "Close chat",
|
|
36
|
-
chatScrollToBottomLabel: "Scroll to bottom",
|
|
37
|
-
modalHeaderTitle: "CopilotKit Chat",
|
|
38
|
-
welcomeMessageText: "How can I help you today?",
|
|
39
|
-
reasoningMessageThinkingLabel: "Thinking…",
|
|
40
|
-
chatInputSlashMenuLabel: "Slash commands",
|
|
41
|
-
chatInputSlashMenuEmptyText: "No commands found",
|
|
42
|
-
attachmentRemoveButtonLabel: "Remove attachment",
|
|
43
|
-
attachmentPlayVideoButtonLabel: "Play video",
|
|
44
|
-
attachmentPreviewCloseButtonLabel: "Close preview",
|
|
45
|
-
modalHeaderCloseButtonLabel: "Close",
|
|
46
|
-
modalHeaderThreadsButtonLabel: "Open threads",
|
|
47
|
-
sidebarLabel: "Copilot chat sidebar",
|
|
48
|
-
} as const;
|
|
1
|
+
import type { CopilotChatLabels } from "@copilotkit/core";
|
|
49
2
|
|
|
50
|
-
export
|
|
3
|
+
export { CopilotChatDefaultLabels } from "@copilotkit/core";
|
|
4
|
+
export type { CopilotChatLabels } from "@copilotkit/core";
|
|
51
5
|
|
|
52
6
|
export interface CopilotChatConfigurationValue {
|
|
53
7
|
labels: CopilotChatLabels;
|
|
@@ -2,11 +2,30 @@ import { describe, it, expect } from "vitest";
|
|
|
2
2
|
import { defineComponent, h } from "vue";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ToolCallStatus } from "@copilotkit/core";
|
|
5
|
+
import type { VNode } from "vue";
|
|
5
6
|
import { defineToolCallRenderer } from "../defineToolCallRenderer";
|
|
6
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
VueToolCallRenderer,
|
|
9
|
+
VueToolCallRendererRenderProps,
|
|
10
|
+
} from "../vue-tool-call-renderer";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Calls a renderer built from a render function. `render` is typed as a
|
|
14
|
+
* function or a component, and TypeScript cannot tell which one this test
|
|
15
|
+
* passed, so the narrowing cast lives here once.
|
|
16
|
+
*/
|
|
17
|
+
function callRender<T>(
|
|
18
|
+
renderer: VueToolCallRenderer<T>,
|
|
19
|
+
props: VueToolCallRendererRenderProps<T>,
|
|
20
|
+
) {
|
|
21
|
+
const render = renderer.render as (
|
|
22
|
+
props: VueToolCallRendererRenderProps<T>,
|
|
23
|
+
) => VNode;
|
|
24
|
+
return render(props);
|
|
25
|
+
}
|
|
7
26
|
|
|
8
27
|
describe("defineToolCallRenderer", () => {
|
|
9
|
-
it("defaults wildcard args to
|
|
28
|
+
it("defaults wildcard args to a schema that accepts any value and preserves runtime tool name", () => {
|
|
10
29
|
const wildcardRenderer = defineToolCallRenderer({
|
|
11
30
|
name: "*",
|
|
12
31
|
render: ({ name, args, status }) =>
|
|
@@ -18,19 +37,11 @@ describe("defineToolCallRenderer", () => {
|
|
|
18
37
|
});
|
|
19
38
|
|
|
20
39
|
expect(wildcardRenderer.name).toBe("*");
|
|
21
|
-
expect(
|
|
22
|
-
true,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const rendered = (
|
|
26
|
-
wildcardRenderer.render as (props: {
|
|
27
|
-
name: string;
|
|
28
|
-
toolCallId: string;
|
|
29
|
-
args: Record<string, unknown>;
|
|
30
|
-
status: ToolCallStatus;
|
|
31
|
-
result: string | undefined;
|
|
32
|
-
}) => ReturnType<typeof h>
|
|
33
|
-
)({
|
|
40
|
+
expect(
|
|
41
|
+
wildcardRenderer.args["~standard"].validate({ anything: true }),
|
|
42
|
+
).toEqual({ value: { anything: true } });
|
|
43
|
+
|
|
44
|
+
const rendered = callRender(wildcardRenderer, {
|
|
34
45
|
name: "customTool",
|
|
35
46
|
toolCallId: "tc-wildcard-1",
|
|
36
47
|
args: { x: 1 },
|
|
@@ -53,15 +64,7 @@ describe("defineToolCallRenderer", () => {
|
|
|
53
64
|
),
|
|
54
65
|
});
|
|
55
66
|
|
|
56
|
-
const rendered = (
|
|
57
|
-
wildcardRenderer.render as (props: {
|
|
58
|
-
name: string;
|
|
59
|
-
toolCallId: string;
|
|
60
|
-
args: Record<string, unknown>;
|
|
61
|
-
status: ToolCallStatus;
|
|
62
|
-
result: string | undefined;
|
|
63
|
-
}) => ReturnType<typeof h>
|
|
64
|
-
)({
|
|
67
|
+
const rendered = callRender(wildcardRenderer, {
|
|
65
68
|
name: "customTool",
|
|
66
69
|
toolCallId: "tc-123",
|
|
67
70
|
args: {},
|
|
@@ -136,15 +139,7 @@ describe("defineToolCallRenderer", () => {
|
|
|
136
139
|
},
|
|
137
140
|
});
|
|
138
141
|
|
|
139
|
-
const rendered = (
|
|
140
|
-
typedRenderer.render as (props: {
|
|
141
|
-
name: string;
|
|
142
|
-
toolCallId: string;
|
|
143
|
-
args: { location: string; units?: "celsius" | "fahrenheit" };
|
|
144
|
-
status: ToolCallStatus;
|
|
145
|
-
result: string | undefined;
|
|
146
|
-
}) => ReturnType<typeof h>
|
|
147
|
-
)({
|
|
142
|
+
const rendered = callRender(typedRenderer, {
|
|
148
143
|
name: "get_weather",
|
|
149
144
|
toolCallId: "tc-weather-1",
|
|
150
145
|
args: { location: "Paris", units: "celsius" },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ɵanySchema } from "@copilotkit/shared";
|
|
2
2
|
import type { StandardSchemaV1, InferSchemaOutput } from "@copilotkit/shared";
|
|
3
3
|
import type { VueToolCallRenderer } from "./vue-tool-call-renderer";
|
|
4
4
|
import type { VueToolCallRendererRenderFn } from "./vue-tool-call-renderer";
|
|
@@ -25,11 +25,12 @@ export function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
|
25
25
|
agentId?: string;
|
|
26
26
|
group?: boolean;
|
|
27
27
|
}): VueToolCallRenderer<unknown> {
|
|
28
|
-
|
|
28
|
+
// Only a "*" renderer may leave out `args`; it accepts any arguments.
|
|
29
|
+
const args = def.args ?? ɵanySchema;
|
|
29
30
|
return {
|
|
30
31
|
name: def.name,
|
|
31
|
-
args
|
|
32
|
-
render: def.render
|
|
32
|
+
args,
|
|
33
|
+
render: def.render,
|
|
33
34
|
...(def.agentId ? { agentId: def.agentId } : {}),
|
|
34
35
|
...(def.group ? { group: true } : {}),
|
|
35
36
|
};
|
|
@@ -1,37 +1,13 @@
|
|
|
1
|
-
import type { FrontendTool,
|
|
1
|
+
import type { FrontendTool, HumanInTheLoopRenderProps } from "@copilotkit/core";
|
|
2
2
|
import type { Component, VNodeChild } from "vue";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
status: ToolCallStatus.InProgress;
|
|
12
|
-
result: undefined;
|
|
13
|
-
respond: undefined;
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
toolCallId: string;
|
|
19
|
-
agentId?: string;
|
|
20
|
-
args: T;
|
|
21
|
-
status: ToolCallStatus.Executing;
|
|
22
|
-
result: undefined;
|
|
23
|
-
respond: (result: unknown) => Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
name: string;
|
|
27
|
-
description: string;
|
|
28
|
-
toolCallId: string;
|
|
29
|
-
agentId?: string;
|
|
30
|
-
args: T;
|
|
31
|
-
status: ToolCallStatus.Complete;
|
|
32
|
-
result: string;
|
|
33
|
-
respond: undefined;
|
|
34
|
-
};
|
|
4
|
+
/**
|
|
5
|
+
* Props a Vue human-in-the-loop renderer receives. Same as core's
|
|
6
|
+
* `HumanInTheLoopRenderProps`.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam T - The shape of the tool arguments.
|
|
9
|
+
*/
|
|
10
|
+
export type VueHumanInTheLoopRenderProps<T> = HumanInTheLoopRenderProps<T>;
|
|
35
11
|
|
|
36
12
|
export type VueHumanInTheLoopRenderFn<T> =
|
|
37
13
|
| ((props: VueHumanInTheLoopRenderProps<T>) => VNodeChild)
|
|
@@ -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>;
|