@copilotkit/vue 1.69.1 → 1.69.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.mjs +2 -2
  3. package/dist/use-render-activity-message-CIlNtfvE.cjs +85 -0
  4. package/dist/use-render-activity-message-CIlNtfvE.cjs.map +1 -0
  5. package/dist/{use-render-activity-message-CADUB--8.js → use-render-activity-message-Db2rOZkW.js} +3940 -4241
  6. package/dist/use-render-activity-message-Db2rOZkW.js.map +1 -0
  7. package/dist/v2/components/CopilotKitInspector.vue.d.ts +0 -2
  8. package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
  9. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
  10. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
  11. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +0 -18
  12. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
  13. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
  14. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
  15. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
  16. package/dist/v2/components/icons/index.d.ts +1 -1
  17. package/dist/v2/components/icons/index.d.ts.map +1 -1
  18. package/dist/v2/index.cjs +1 -1
  19. package/dist/v2/index.mjs +1 -1
  20. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
  21. package/dist/v2/providers/keys.d.ts +0 -36
  22. package/dist/v2/providers/keys.d.ts.map +1 -1
  23. package/dist/v2/providers/types.d.ts +0 -3
  24. package/dist/v2/providers/types.d.ts.map +1 -1
  25. package/package.json +5 -5
  26. package/src/v2/components/CopilotKitInspector.vue +1 -19
  27. package/src/v2/components/OpenGenerativeUIRenderer.ts +1 -42
  28. package/src/v2/components/chat/CopilotChatAssistantMessage.vue +1 -52
  29. package/src/v2/components/chat/CopilotChatMessageView.vue +23 -57
  30. package/src/v2/components/chat/CopilotChatReasoningMessage.vue +32 -68
  31. package/src/v2/components/chat/CopilotChatToolCallsView.vue +16 -70
  32. package/src/v2/components/icons/__tests__/icons.test.ts +0 -2
  33. package/src/v2/components/icons/index.ts +0 -1
  34. package/src/v2/providers/CopilotKitProvider.vue +6 -66
  35. package/src/v2/providers/keys.ts +0 -47
  36. package/src/v2/providers/types.ts +0 -3
  37. package/dist/use-render-activity-message-BtaJ2iQc.cjs +0 -97
  38. package/dist/use-render-activity-message-BtaJ2iQc.cjs.map +0 -1
  39. package/dist/use-render-activity-message-CADUB--8.js.map +0 -1
  40. package/dist/v2/components/chat/SaveSnippetBeside.vue.d.ts +0 -20
  41. package/dist/v2/components/chat/SaveSnippetBeside.vue.d.ts.map +0 -1
  42. package/dist/v2/components/chat/save-snippet-beside.d.ts +0 -20
  43. package/dist/v2/components/chat/save-snippet-beside.d.ts.map +0 -1
  44. package/src/v2/components/chat/SaveSnippetBeside.vue +0 -82
  45. package/src/v2/components/chat/save-snippet-beside.ts +0 -84
@@ -1,11 +1,8 @@
1
1
  <script setup lang="ts">
2
- import { computed, inject, onBeforeUnmount, ref, watch } from "vue";
2
+ import { computed, onBeforeUnmount, ref, watch } from "vue";
3
3
  import type { Message, ReasoningMessage } from "@ag-ui/core";
4
4
  import { StreamMarkdown } from "streamdown-vue";
5
- import { IconBookmark, IconChevronRight } from "../icons";
6
- import { InspectorKey } from "../../providers/keys";
7
- import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
8
- import { CopilotChatDefaultLabels } from "../../providers/types";
5
+ import { IconChevronRight } from "../icons";
9
6
 
10
7
  const props = withDefaults(
11
8
  defineProps<{
@@ -142,27 +139,6 @@ function toggleOpen() {
142
139
  userToggledDuringStreaming.value = true;
143
140
  isOpen.value = !isOpen.value;
144
141
  }
145
-
146
- const inspector = inject(InspectorKey, null);
147
- const chatConfiguration = useCopilotChatConfiguration();
148
- const canSaveReasoning = computed(
149
- () => inspector?.isLocalInspectorEnabled.value === true && hasContent.value,
150
- );
151
- const saveLabel = computed(
152
- () =>
153
- chatConfiguration.value?.labels.assistantMessageToolbarSaveSnippetLabel ??
154
- CopilotChatDefaultLabels.assistantMessageToolbarSaveSnippetLabel,
155
- );
156
-
157
- function saveReasoningSnippet() {
158
- void inspector?.saveEventSnippet({
159
- kind: "reasoning",
160
- messageId: props.message.id,
161
- content: normalizedContent.value,
162
- threadId: chatConfiguration.value?.threadId,
163
- agentId: chatConfiguration.value?.agentId,
164
- });
165
- }
166
142
  </script>
167
143
 
168
144
  <template>
@@ -193,53 +169,41 @@ function saveReasoningSnippet() {
193
169
  },
194
170
  }"
195
171
  >
196
- <div class="cpk:flex cpk:items-center cpk:gap-1">
197
- <slot
198
- name="header"
199
- :is-open="isOpen"
200
- :label="label"
201
- :has-content="hasContent"
202
- :is-streaming="isStreaming"
203
- :on-click="hasContent ? toggleOpen : undefined"
172
+ <slot
173
+ name="header"
174
+ :is-open="isOpen"
175
+ :label="label"
176
+ :has-content="hasContent"
177
+ :is-streaming="isStreaming"
178
+ :on-click="hasContent ? toggleOpen : undefined"
179
+ >
180
+ <button
181
+ type="button"
182
+ class="cpk:inline-flex cpk:items-center cpk:gap-1 cpk:py-1 cpk:text-sm cpk:text-muted-foreground cpk:transition-colors cpk:select-none"
183
+ :class="
184
+ hasContent
185
+ ? 'cpk:hover:text-foreground cpk:cursor-pointer'
186
+ : 'cpk:cursor-default'
187
+ "
188
+ :aria-expanded="hasContent ? isOpen : undefined"
189
+ @click="hasContent ? toggleOpen() : undefined"
204
190
  >
205
- <button
206
- type="button"
207
- class="cpk:inline-flex cpk:items-center cpk:gap-1 cpk:py-1 cpk:text-sm cpk:text-muted-foreground cpk:transition-colors cpk:select-none"
208
- :class="
209
- hasContent
210
- ? 'cpk:hover:text-foreground cpk:cursor-pointer'
211
- : 'cpk:cursor-default'
212
- "
213
- :aria-expanded="hasContent ? isOpen : undefined"
214
- @click="hasContent ? toggleOpen() : undefined"
191
+ <span class="cpk:font-medium">{{ label }}</span>
192
+ <span
193
+ v-if="isStreaming && !hasContent"
194
+ class="cpk:inline-flex cpk:items-center cpk:ml-1"
215
195
  >
216
- <span class="cpk:font-medium">{{ label }}</span>
217
196
  <span
218
- v-if="isStreaming && !hasContent"
219
- class="cpk:inline-flex cpk:items-center cpk:ml-1"
220
- >
221
- <span
222
- class="cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"
223
- />
224
- </span>
225
- <IconChevronRight
226
- v-if="hasContent"
227
- class="cpk:size-3.5 cpk:shrink-0 cpk:transition-transform cpk:duration-200"
228
- :class="{ 'cpk:rotate-90': isOpen }"
197
+ class="cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"
229
198
  />
230
- </button>
231
- </slot>
232
- <button
233
- v-if="canSaveReasoning"
234
- type="button"
235
- class="cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0 cpk:text-[rgb(93,93,93)] cpk:hover:bg-[#E8E8E8] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030]"
236
- data-testid="copilot-save-snippet-button"
237
- :aria-label="`${saveLabel} (Local Only)`"
238
- @click="saveReasoningSnippet"
239
- >
240
- <IconBookmark class="cpk:size-[18px]" />
199
+ </span>
200
+ <IconChevronRight
201
+ v-if="hasContent"
202
+ class="cpk:size-3.5 cpk:shrink-0 cpk:transition-transform cpk:duration-200"
203
+ :class="{ 'cpk:rotate-90': isOpen }"
204
+ />
241
205
  </button>
242
- </div>
206
+ </slot>
243
207
 
244
208
  <slot
245
209
  name="toggle"
@@ -1,15 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { inject, useSlots } from "vue";
2
+ import { useSlots } from "vue";
3
3
  import type { AssistantMessage, Message } from "@ag-ui/core";
4
4
  import type { CopilotChatToolCallRenderSlotProps } from "./types";
5
5
  import CopilotChatToolCallItem from "./CopilotChatToolCallItem.vue";
6
- import SaveSnippetBeside from "./SaveSnippetBeside.vue";
7
- import { InspectorKey } from "../../providers/keys";
8
- import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
9
- import { CopilotChatDefaultLabels } from "../../providers/types";
10
- import { IconBookmark } from "../icons";
11
6
 
12
- const props = withDefaults(
7
+ withDefaults(
13
8
  defineProps<{
14
9
  message: AssistantMessage;
15
10
  messages?: Message[];
@@ -34,70 +29,21 @@ const componentSlots = useSlots() as Record<
34
29
  function getForwardedSlotNames(): ToolCallSlotName[] {
35
30
  return Object.keys(componentSlots) as ToolCallSlotName[];
36
31
  }
37
-
38
- // A streaming tool call has truncated arguments. Do not offer to capture it
39
- // until the JSON is complete, or the snippet holds a broken partial payload.
40
- function hasCompleteArgs(args: string | undefined): boolean {
41
- const trimmed = (args ?? "").trim();
42
- if (!trimmed) {
43
- return true;
44
- }
45
- try {
46
- JSON.parse(trimmed);
47
- return true;
48
- } catch {
49
- return false;
50
- }
51
- }
52
-
53
- const inspector = inject(InspectorKey, null);
54
- const chatConfiguration = useCopilotChatConfiguration();
55
- const canSave = (toolCall: { function: { arguments: string } }) =>
56
- inspector?.isLocalInspectorEnabled.value === true &&
57
- hasCompleteArgs(toolCall.function.arguments);
58
- const saveLabel = () =>
59
- chatConfiguration.value?.labels.assistantMessageToolbarSaveSnippetLabel ??
60
- CopilotChatDefaultLabels.assistantMessageToolbarSaveSnippetLabel;
61
-
62
- function saveToolCall(toolCall: {
63
- id: string;
64
- function: { name: string; arguments: string };
65
- }) {
66
- void inspector?.saveEventSnippet({
67
- kind: "tool-call",
68
- messageId: props.message.id,
69
- toolCallId: toolCall.id,
70
- toolName: toolCall.function.name,
71
- argsJson: toolCall.function.arguments || "{}",
72
- threadId: chatConfiguration.value?.threadId,
73
- agentId: chatConfiguration.value?.agentId,
74
- });
75
- }
76
32
  </script>
77
33
 
78
34
  <template>
79
- <div v-for="toolCall in message.toolCalls ?? []" :key="toolCall.id">
80
- <SaveSnippetBeside :enabled="canSave(toolCall)">
81
- <CopilotChatToolCallItem :tool-call="toolCall" :messages="messages">
82
- <template
83
- v-for="slotName in getForwardedSlotNames()"
84
- :key="slotName"
85
- #[slotName]="slotProps"
86
- >
87
- <slot :name="slotName" v-bind="slotProps ?? {}" />
88
- </template>
89
- </CopilotChatToolCallItem>
90
- <template #save>
91
- <button
92
- type="button"
93
- class="cpk:inline-flex cpk:h-8 cpk:w-8 cpk:items-center cpk:justify-center cpk:rounded-md cpk:p-0 cpk:text-[rgb(93,93,93)] cpk:hover:bg-[#E8E8E8] cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030]"
94
- data-testid="copilot-tool-save-snippet-button"
95
- :aria-label="`${saveLabel()} (Local Only)`"
96
- @click="saveToolCall(toolCall)"
97
- >
98
- <IconBookmark class="cpk:size-[18px]" />
99
- </button>
100
- </template>
101
- </SaveSnippetBeside>
102
- </div>
35
+ <CopilotChatToolCallItem
36
+ v-for="toolCall in message.toolCalls ?? []"
37
+ :key="toolCall.id"
38
+ :tool-call="toolCall"
39
+ :messages="messages"
40
+ >
41
+ <template
42
+ v-for="slotName in getForwardedSlotNames()"
43
+ :key="slotName"
44
+ #[slotName]="slotProps"
45
+ >
46
+ <slot :name="slotName" v-bind="slotProps ?? {}" />
47
+ </template>
48
+ </CopilotChatToolCallItem>
103
49
  </template>
@@ -2,7 +2,6 @@ import { describe, expect, it } from "vitest";
2
2
  import { mount } from "@vue/test-utils";
3
3
  import {
4
4
  IconArrowUp,
5
- IconBookmark,
6
5
  IconCheck,
7
6
  IconCheckCircle,
8
7
  IconChevronDown,
@@ -32,7 +31,6 @@ describe("icons adapter", () => {
32
31
  IconPlus,
33
32
  IconMic,
34
33
  IconArrowUp,
35
- IconBookmark,
36
34
  IconCheck,
37
35
  IconSquare,
38
36
  IconLoader2,
@@ -5,7 +5,6 @@ export {
5
5
  Plus as IconPlus,
6
6
  Mic as IconMic,
7
7
  ArrowUp as IconArrowUp,
8
- Bookmark as IconBookmark,
9
8
  Check as IconCheck,
10
9
  Square as IconSquare,
11
10
  Loader2 as IconLoader2,
@@ -34,8 +34,7 @@ import {
34
34
  MCPAppsActivityRenderer,
35
35
  MCPAppsActivityType,
36
36
  } from "../components/MCPAppsActivityRenderer";
37
- import { CopilotKitKey, InspectorKey, SandboxFunctionsKey } from "./keys";
38
- import type { VueInspectorOpenRequest, VueInspectorSaveRequest } from "./keys";
37
+ import { CopilotKitKey, SandboxFunctionsKey } from "./keys";
39
38
  import {
40
39
  LicenseContextKey,
41
40
  createLicenseContextValue,
@@ -110,86 +109,28 @@ const props = withDefaults(defineProps<CopilotKitProviderProps>(), {
110
109
  });
111
110
 
112
111
  const shouldRenderInspector = ref(false);
113
- // Mounting the overlay follows showDevConsole. The in-chat affordances are
114
- // narrower: a dev build on localhost only, so `showDevConsole: true` on a
115
- // staging URL never puts a bookmark into a production chat. Matches React.
116
- const canShowLocalInspectorAction = ref(false);
117
112
 
118
113
  const updateInspectorVisibility = () => {
119
- const isLocalhost =
120
- typeof window !== "undefined" &&
121
- new Set(["localhost", "127.0.0.1"]).has(window.location?.hostname ?? "");
122
- canShowLocalInspectorAction.value =
123
- process.env.NODE_ENV === "development" && isLocalhost;
124
-
125
114
  if (props.showDevConsole === true) {
126
115
  shouldRenderInspector.value = true;
127
116
  return;
128
117
  }
129
118
  if (props.showDevConsole === "auto") {
130
- shouldRenderInspector.value = isLocalhost;
131
- if (!isLocalhost) {
132
- canShowLocalInspectorAction.value = false;
119
+ if (typeof window === "undefined") {
120
+ shouldRenderInspector.value = false;
121
+ return;
133
122
  }
123
+ const localhostHosts = new Set(["localhost", "127.0.0.1"]);
124
+ shouldRenderInspector.value = localhostHosts.has(window.location.hostname);
134
125
  return;
135
126
  }
136
127
  shouldRenderInspector.value = false;
137
- canShowLocalInspectorAction.value = false;
138
128
  };
139
129
 
140
130
  watch(() => props.showDevConsole, updateInspectorVisibility, {
141
131
  immediate: true,
142
132
  });
143
133
 
144
- const inspectorOpenRequest = ref<VueInspectorOpenRequest | null>(null);
145
- const isLocalInspectorEnabled = computed(
146
- () => shouldRenderInspector.value && canShowLocalInspectorAction.value,
147
- );
148
-
149
- function openInspector(request: VueInspectorOpenRequest) {
150
- inspectorOpenRequest.value = { ...request };
151
- }
152
-
153
- async function saveEventSnippet(request: VueInspectorSaveRequest) {
154
- try {
155
- const mod = await import("@copilotkit/web-inspector");
156
- const threadId = request.threadId ?? "inspector-snippet";
157
- const runId = `inspector-snippet-${Date.now()}`;
158
- const compiled = mod.compileChatSnippet({
159
- ...request,
160
- threadId,
161
- runId,
162
- });
163
- const now = new Date().toISOString();
164
- const snippet = {
165
- id: crypto.randomUUID(),
166
- name: compiled.name,
167
- recipe: compiled.recipe,
168
- events: compiled.events,
169
- createdAt: now,
170
- updatedAt: now,
171
- };
172
- mod.upsertEventSnippet(snippet);
173
- openInspector({
174
- messageId: request.messageId,
175
- threadId: request.threadId,
176
- agentId: request.agentId,
177
- menu: "event-snippets",
178
- snippetId: snippet.id,
179
- });
180
- } catch (error) {
181
- // Compile can throw on bad args, and storage can throw QuotaExceededError.
182
- // Callers fire this as `void saveEventSnippet(...)`, so report it here.
183
- console.error("[CopilotKit] Could not save the event snippet.", error);
184
- }
185
- }
186
-
187
- provide(InspectorKey, {
188
- isLocalInspectorEnabled,
189
- openInspector,
190
- saveEventSnippet,
191
- });
192
-
193
134
  const initialFrontendTools = props.frontendTools;
194
135
  const initialHumanInTheLoop = props.humanInTheLoop;
195
136
  const initialRenderCustomMessages = props.renderCustomMessages;
@@ -716,7 +657,6 @@ const showExpiringBanner = computed(
716
657
  v-if="shouldRenderInspector"
717
658
  :core="copilotkit"
718
659
  :default-anchor="props.inspectorDefaultAnchor"
719
- :open-request="inspectorOpenRequest"
720
660
  />
721
661
  <!-- License warnings — driven by server-reported status -->
722
662
  <LicenseWarningBanner v-if="showNoLicenseBanner" type="no_license" />
@@ -23,50 +23,3 @@ export const CopilotChatConfigurationKey: InjectionKey<
23
23
  export const SandboxFunctionsKey: InjectionKey<
24
24
  Ref<readonly SandboxFunction[]>
25
25
  > = Symbol("SandboxFunctions");
26
-
27
- export type VueInspectorOpenRequest = {
28
- messageId: string;
29
- threadId?: string;
30
- agentId?: string;
31
- menu?: "event-snippets";
32
- snippetId?: string;
33
- };
34
-
35
- export type VueInspectorSaveRequest = {
36
- threadId?: string;
37
- agentId?: string;
38
- } & (
39
- | {
40
- kind: "text";
41
- messageId: string;
42
- content: string;
43
- }
44
- | {
45
- kind: "reasoning";
46
- messageId: string;
47
- content: string;
48
- }
49
- | {
50
- kind: "tool-call";
51
- messageId: string;
52
- toolCallId: string;
53
- toolName: string;
54
- argsJson: string | Record<string, unknown>;
55
- }
56
- | {
57
- kind: "activity";
58
- messageId: string;
59
- activityType: string;
60
- content: unknown;
61
- }
62
- );
63
-
64
- export type VueInspectorContextValue = {
65
- isLocalInspectorEnabled: ComputedRef<boolean>;
66
- openInspector: (request: VueInspectorOpenRequest) => void;
67
- saveEventSnippet: (request: VueInspectorSaveRequest) => Promise<void>;
68
- };
69
-
70
- export const InspectorKey: InjectionKey<VueInspectorContextValue> = Symbol(
71
- "CopilotKitInspector",
72
- );
@@ -8,9 +8,6 @@ export const CopilotChatDefaultLabels = {
8
8
  assistantMessageToolbarCopyCodeLabel: "Copy",
9
9
  assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
10
10
  assistantMessageToolbarCopyMessageLabel: "Copy",
11
- assistantMessageToolbarInspectorLabel: "View in Inspector",
12
- assistantMessageToolbarInspectorLocalOnlyLabel: "Local Only",
13
- assistantMessageToolbarSaveSnippetLabel: "Save as snippet",
14
11
  assistantMessageToolbarThumbsUpLabel: "Good response",
15
12
  assistantMessageToolbarThumbsDownLabel: "Bad response",
16
13
  assistantMessageToolbarReadAloudLabel: "Read aloud",