@copilotkit/vue 2.0.0-rc.20 → 2.0.0-rc.22

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 (193) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.mjs +13 -13
  3. package/dist/use-render-activity-message-CyrhHFhA.js +16200 -0
  4. package/dist/use-render-activity-message-CyrhHFhA.js.map +1 -0
  5. package/dist/use-render-activity-message-EwHHrwQB.cjs +114 -0
  6. package/dist/use-render-activity-message-EwHHrwQB.cjs.map +1 -0
  7. package/dist/v2/components/A2UIMessageRenderer.d.ts +14 -0
  8. package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
  9. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +10 -3
  10. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
  11. package/dist/v2/components/CopilotKitInspector.vue.d.ts +5 -1
  12. package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
  13. package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
  14. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +7 -21
  15. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
  16. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +0 -5
  17. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
  18. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -15
  19. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
  20. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +14 -138
  21. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
  22. package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
  23. package/dist/v2/components/a2ui/utils.d.ts +3 -15
  24. package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
  25. package/dist/v2/components/a2ui.d.ts +6 -1
  26. package/dist/v2/components/a2ui.d.ts.map +1 -1
  27. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
  28. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
  29. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +4 -8
  30. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
  31. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
  32. package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -1
  33. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
  34. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
  35. package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
  36. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
  37. package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -1
  38. package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
  39. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
  40. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +1 -1
  41. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +1 -1
  42. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
  43. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -1
  44. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +1 -0
  45. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
  46. package/dist/v2/components/chat/audioRecorder.d.ts +3 -4
  47. package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -1
  48. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +3 -2
  49. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
  50. package/dist/v2/components/chat/index.d.ts +6 -6
  51. package/dist/v2/components/chat/tool-call-display-context.d.ts +3 -1
  52. package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
  53. package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
  54. package/dist/v2/components/chat/types.d.ts +1 -1
  55. package/dist/v2/components/chat/types.d.ts.map +1 -1
  56. package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -1
  57. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +1 -1
  58. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -1
  59. package/dist/v2/hooks/use-agent-context.d.ts +2 -3
  60. package/dist/v2/hooks/use-agent-context.d.ts.map +1 -1
  61. package/dist/v2/hooks/use-agent.d.ts +4 -1
  62. package/dist/v2/hooks/use-agent.d.ts.map +1 -1
  63. package/dist/v2/hooks/use-attachments.d.ts +7 -0
  64. package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
  65. package/dist/v2/hooks/use-capabilities.d.ts.map +1 -1
  66. package/dist/v2/hooks/use-component.d.ts +1 -0
  67. package/dist/v2/hooks/use-component.d.ts.map +1 -1
  68. package/dist/v2/hooks/use-configure-suggestions.d.ts +4 -9
  69. package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -1
  70. package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
  71. package/dist/v2/hooks/use-human-in-the-loop.d.ts +2 -1
  72. package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -1
  73. package/dist/v2/hooks/use-interrupt.d.ts +0 -1
  74. package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
  75. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
  76. package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
  77. package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
  78. package/dist/v2/hooks/use-threads.d.ts +0 -8
  79. package/dist/v2/hooks/use-threads.d.ts.map +1 -1
  80. package/dist/v2/index.cjs +1 -1
  81. package/dist/v2/index.mjs +1 -1
  82. package/dist/v2/lib/vue-core.d.ts +12 -11
  83. package/dist/v2/lib/vue-core.d.ts.map +1 -1
  84. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  85. package/dist/v2/providers/CopilotKitProvider.types.d.ts +9 -124
  86. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
  87. package/dist/v2/providers/CopilotKitProvider.vue.d.ts +9 -10
  88. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
  89. package/dist/v2/providers/chat-configuration-store-key.d.ts +8 -0
  90. package/dist/v2/providers/chat-configuration-store-key.d.ts.map +1 -0
  91. package/dist/v2/providers/markdown-renderer.d.ts +3 -1
  92. package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
  93. package/dist/v2/providers/use-inspector-thread-override.d.ts +5 -0
  94. package/dist/v2/providers/use-inspector-thread-override.d.ts.map +1 -1
  95. package/package.json +8 -8
  96. package/src/v2/__tests__/exports.test.ts +10 -0
  97. package/src/v2/__tests__/mocks/web-inspector.ts +6 -0
  98. package/src/v2/__tests__/utils/test-helpers.ts +34 -4
  99. package/src/v2/components/A2UIMessageRenderer.ts +98 -68
  100. package/src/v2/components/A2UISurfaceActivityRenderer.vue +68 -103
  101. package/src/v2/components/CopilotKitInspector.vue +104 -51
  102. package/src/v2/components/MCPAppsActivityRenderer.ts +75 -201
  103. package/src/v2/components/OpenGenerativeUIRenderer.ts +78 -80
  104. package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +171 -8
  105. package/src/v2/components/__tests__/CopilotKitInspector.test.ts +42 -0
  106. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +9 -2
  107. package/src/v2/components/__tests__/OpenGenerativeUIToolRenderer.test.ts +38 -0
  108. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +1 -6
  109. package/src/v2/components/a2ui/A2UICatalogContext.ts +27 -93
  110. package/src/v2/components/a2ui/A2UIRecoveryStates.ts +127 -327
  111. package/src/v2/components/a2ui/catalog.ts +2 -3
  112. package/src/v2/components/a2ui/utils.ts +13 -67
  113. package/src/v2/components/a2ui.ts +14 -21
  114. package/src/v2/components/chat/CopilotChat.vue +136 -324
  115. package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +22 -45
  116. package/src/v2/components/chat/CopilotChatAudioRecorder.vue +19 -246
  117. package/src/v2/components/chat/CopilotChatInput.vue +69 -407
  118. package/src/v2/components/chat/CopilotChatLightbox.vue +10 -31
  119. package/src/v2/components/chat/CopilotChatMessageView.vue +52 -112
  120. package/src/v2/components/chat/CopilotChatToolCallGroup.vue +14 -45
  121. package/src/v2/components/chat/CopilotChatToolCallItem.vue +6 -4
  122. package/src/v2/components/chat/CopilotChatToolCallsView.vue +16 -19
  123. package/src/v2/components/chat/CopilotChatView.vue +28 -23
  124. package/src/v2/components/chat/CopilotPopupViewInternal.vue +21 -97
  125. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -25
  126. package/src/v2/components/chat/CopilotThreadsDrawer.vue +37 -102
  127. package/src/v2/components/chat/StreamingMarkdownDefault.vue +13 -26
  128. package/src/v2/components/chat/__tests__/CopilotChat.test.ts +12 -10
  129. package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +28 -0
  130. package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +56 -0
  131. package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +19 -0
  132. package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +32 -8
  133. package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +2 -1
  134. package/src/v2/components/chat/__tests__/StreamingMarkdownDefault.test.ts +54 -0
  135. package/src/v2/components/chat/audioRecorder.ts +4 -7
  136. package/src/v2/components/chat/copilotChatToolCallItemRender.ts +22 -71
  137. package/src/v2/components/chat/tool-call-display-context.ts +6 -1
  138. package/src/v2/components/chat/tool-call-group-parts.ts +13 -33
  139. package/src/v2/components/chat/types.ts +1 -1
  140. package/src/v2/components/chat/use-lightbox.ts +15 -33
  141. package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +5 -3
  142. package/src/v2/hooks/__tests__/use-agent-stability.test.ts +25 -4
  143. package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +5 -1
  144. package/src/v2/hooks/__tests__/use-agent.test.ts +6 -3
  145. package/src/v2/hooks/__tests__/use-component.test.ts +21 -0
  146. package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +30 -1
  147. package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +10 -10
  148. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +4 -0
  149. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +6 -1
  150. package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +187 -12
  151. package/src/v2/hooks/__tests__/use-interrupt.test.ts +97 -0
  152. package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +2 -1
  153. package/src/v2/hooks/__tests__/use-threads.test.ts +48 -6
  154. package/src/v2/hooks/use-agent-context.ts +4 -10
  155. package/src/v2/hooks/use-agent.ts +86 -290
  156. package/src/v2/hooks/use-attachments.ts +42 -166
  157. package/src/v2/hooks/use-capabilities.ts +2 -7
  158. package/src/v2/hooks/use-component.ts +7 -4
  159. package/src/v2/hooks/use-configure-suggestions.ts +28 -218
  160. package/src/v2/hooks/use-default-render-tool.ts +34 -94
  161. package/src/v2/hooks/use-human-in-the-loop.ts +11 -80
  162. package/src/v2/hooks/use-interrupt.ts +29 -308
  163. package/src/v2/hooks/use-render-activity-message.ts +17 -20
  164. package/src/v2/hooks/use-render-custom-messages.ts +20 -63
  165. package/src/v2/hooks/use-suggestions.ts +9 -33
  166. package/src/v2/hooks/use-threads.ts +43 -273
  167. package/src/v2/lib/__tests__/vue-core-renderers.test.ts +42 -0
  168. package/src/v2/lib/vue-core.ts +67 -72
  169. package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
  170. package/src/v2/providers/CopilotKitProvider.types.ts +12 -127
  171. package/src/v2/providers/CopilotKitProvider.vue +188 -402
  172. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
  173. package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +19 -1
  174. package/src/v2/providers/__tests__/CopilotKitProvider.config.test.ts +124 -0
  175. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +4 -1
  176. package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +45 -2
  177. package/src/v2/providers/chat-configuration-store-key.ts +9 -0
  178. package/src/v2/providers/markdown-renderer.ts +7 -1
  179. package/src/v2/providers/use-inspector-thread-override.ts +22 -80
  180. package/vite.config.ts +5 -1
  181. package/vitest.config.ts +12 -7
  182. package/dist/use-render-activity-message-CsWYyd6r.cjs +0 -91
  183. package/dist/use-render-activity-message-CsWYyd6r.cjs.map +0 -1
  184. package/dist/use-render-activity-message-DntKKNdd.js +0 -17418
  185. package/dist/use-render-activity-message-DntKKNdd.js.map +0 -1
  186. package/dist/v2/components/chat/normalize-auto-scroll.d.ts +0 -3
  187. package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +0 -1
  188. package/dist/v2/lib/is-mobile-viewport.d.ts +0 -2
  189. package/dist/v2/lib/is-mobile-viewport.d.ts.map +0 -1
  190. package/src/v2/components/__tests__/A2UICatalogContext.test.ts +0 -63
  191. package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +0 -175
  192. package/src/v2/components/chat/normalize-auto-scroll.ts +0 -3
  193. package/src/v2/lib/is-mobile-viewport.ts +0 -5
@@ -1,18 +1,22 @@
1
1
  <script setup lang="ts">
2
- import { computed, inject, onMounted, provide, ref, watch } from "vue";
2
+ import {
3
+ computed,
4
+ inject,
5
+ onBeforeUnmount,
6
+ onMounted,
7
+ provide,
8
+ shallowRef,
9
+ watch,
10
+ } from "vue";
11
+ import { ɵChatConfigurationStore } from "@copilotkit/core";
3
12
  import type { ComputedRef } from "vue";
4
- import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkit/shared";
5
- import type { OpenThreadRegistration } from "@copilotkit/core";
6
13
  import { CopilotChatConfigurationKey, CopilotKitKey } from "./keys";
14
+ import { ChatConfigurationStoreKey } from "./chat-configuration-store-key";
7
15
  import { CopilotChatDefaultLabels } from "./types";
8
16
  import type { CopilotChatConfigurationValue, CopilotChatLabels } from "./types";
9
17
  import type { CopilotChatConfigurationProviderProps } from "./CopilotChatConfigurationProvider.types";
10
18
  import { useShallowStableRef } from "../lib/shallow-stable";
11
- import { isMobileViewport } from "../lib/is-mobile-viewport";
12
19
 
13
- // Vue normalizes optional Boolean props to `false` when not supplied; declare
14
- // `undefined` defaults so we can faithfully distinguish "caller passed false"
15
- // from "caller did not pass the prop", matching React's prop semantics.
16
20
  const props = withDefaults(
17
21
  defineProps<CopilotChatConfigurationProviderProps>(),
18
22
  {
@@ -25,210 +29,68 @@ const parentConfig = inject<ComputedRef<CopilotChatConfigurationValue> | null>(
25
29
  CopilotChatConfigurationKey,
26
30
  null,
27
31
  );
28
- const parentConfigValue = computed(() => parentConfig?.value ?? null);
29
32
 
30
- // Caller-authoritative when a threadId prop is supplied AND not explicitly
31
- // flagged non-explicit. A <CopilotKit>-seeded non-explicit id
32
- // (threadId + hasExplicitThreadId=false) stays overridable — the round-2 fix.
33
- const propIsAuthoritative = computed(
34
- () => props.threadId !== undefined && props.hasExplicitThreadId !== false,
33
+ // Core owns thread, agent, modal and drawer resolution across the provider
34
+ // chain; this component feeds it props and projects its snapshot.
35
+ const readOptions = () => ({
36
+ agentId: props.agentId,
37
+ threadId: props.threadId,
38
+ hasExplicitThreadId: props.hasExplicitThreadId,
39
+ isModalDefaultOpen: props.isModalDefaultOpen,
40
+ });
41
+ const store = new ɵChatConfigurationStore(
42
+ readOptions(),
43
+ inject(ChatConfigurationStoreKey, null),
35
44
  );
36
-
37
- // Imperative active-thread override (a picked row or a fresh startNewThread).
38
- const activeThreadOverride = ref<{
39
- threadId: string;
40
- explicit: boolean;
41
- } | null>(null);
45
+ const snapshot = shallowRef(store.getSnapshot());
46
+ const unsubscribe = store.subscribe(() => {
47
+ snapshot.value = store.getSnapshot();
48
+ });
49
+ watch(readOptions, (options) => store.update(options));
50
+ onBeforeUnmount(() => {
51
+ unsubscribe();
52
+ store.dispose();
53
+ });
42
54
 
43
55
  const stableLabels = useShallowStableRef(computed(() => props.labels));
44
56
 
45
57
  const mergedLabels = computed<CopilotChatLabels>(() => ({
46
58
  ...CopilotChatDefaultLabels,
47
- ...parentConfigValue.value?.labels,
59
+ ...parentConfig?.value?.labels,
48
60
  ...stableLabels.value,
49
61
  }));
50
62
 
51
- const resolvedAgentId = computed(
52
- () => props.agentId ?? parentConfigValue.value?.agentId ?? DEFAULT_AGENT_ID,
53
- );
54
-
55
- const fallbackThreadId = randomUUID();
56
- const resolvedThreadId = computed(() => {
57
- if (propIsAuthoritative.value) return props.threadId as string;
58
- if (activeThreadOverride.value) return activeThreadOverride.value.threadId;
59
- if (props.threadId) return props.threadId;
60
- if (parentConfigValue.value?.threadId)
61
- return parentConfigValue.value.threadId;
62
- return fallbackThreadId;
63
- });
64
-
65
63
  // Tell Core which Thread this view shows, so captured interactions can link
66
- // to it. This provider also works without a CopilotKitProvider, and then there
67
- // is nothing to register with. Registration starts on mount, so a server
68
- // render never registers a Thread that it can't unregister.
64
+ // to it. Works without a CopilotKitProvider: then there is nothing to register.
69
65
  const copilotKitContext = inject(CopilotKitKey, null);
70
- let openThread: OpenThreadRegistration | null = null;
71
66
  onMounted(() => {
72
67
  watch(
73
- () => [copilotKitContext?.copilotkit.value, resolvedAgentId.value] as const,
74
- ([core, agentId], _previous, onCleanup) => {
68
+ () => copilotKitContext?.copilotkit.value,
69
+ (core, _previous, onCleanup) => {
75
70
  if (!core) return;
76
- const registration = core.registerOpenThread({
77
- agentId,
78
- threadId: resolvedThreadId.value,
79
- });
80
- openThread = registration;
81
- onCleanup(() => {
82
- registration.unregister();
83
- openThread = null;
84
- });
71
+ onCleanup(store.bindOpenThread(core));
85
72
  },
86
73
  { immediate: true },
87
74
  );
88
- watch(resolvedThreadId, (threadId) => openThread?.update(threadId));
89
- });
90
-
91
- const resolvedHasExplicitThreadId = computed(() => {
92
- if (propIsAuthoritative.value) return true;
93
- const own = activeThreadOverride.value
94
- ? activeThreadOverride.value.explicit
95
- : props.hasExplicitThreadId !== undefined
96
- ? props.hasExplicitThreadId
97
- : !!props.threadId;
98
- return own || !!parentConfigValue.value?.hasExplicitThreadId;
99
- });
100
-
101
- const shouldCreateModalState = computed(
102
- () => props.isModalDefaultOpen !== undefined,
103
- );
104
- const resolvedDefaultOpen = computed(() => props.isModalDefaultOpen ?? true);
105
-
106
- const internalModalOpen = ref<boolean>(
107
- parentConfigValue.value?.isModalOpen ?? resolvedDefaultOpen.value,
108
- );
109
-
110
- function setInternalModalOpen(open: boolean) {
111
- internalModalOpen.value = open;
112
- }
113
-
114
- const resolvedIsModalOpen = computed(() =>
115
- shouldCreateModalState.value
116
- ? internalModalOpen.value
117
- : parentConfigValue.value?.isModalOpen,
118
- );
119
- const resolvedSetModalOpen = computed(() =>
120
- shouldCreateModalState.value
121
- ? setInternalModalOpen
122
- : parentConfigValue.value?.setModalOpen,
123
- );
124
-
125
- function setActiveThreadId(threadId: string, options?: { explicit?: boolean }) {
126
- if (propIsAuthoritative.value) {
127
- console.warn(
128
- "[CopilotKit] Ignoring setActiveThreadId(): threadId is controlled " +
129
- "via the `threadId` prop on CopilotChatConfigurationProvider.",
130
- );
131
- return;
132
- }
133
- activeThreadOverride.value = {
134
- threadId,
135
- explicit: options?.explicit ?? true,
136
- };
137
- }
138
-
139
- function startNewThread() {
140
- if (propIsAuthoritative.value) {
141
- console.warn(
142
- "[CopilotKit] Ignoring startNewThread(): threadId is controlled via " +
143
- "the `threadId` prop on CopilotChatConfigurationProvider.",
144
- );
145
- return;
146
- }
147
- activeThreadOverride.value = { threadId: randomUUID(), explicit: false };
148
- }
149
-
150
- // Drawer presence + open state. The top-most provider owns the state; a nested
151
- // provider proxies its parent so the whole chain shares one drawer.
152
- const ownDrawerOpen = ref(false);
153
- const ownDrawerCount = ref(0);
154
-
155
- function ownSetDrawerOpen(open: boolean) {
156
- ownDrawerOpen.value = open;
157
- // Mobile mutual-exclusion: opening the drawer closes the chat modal.
158
- if (open && isMobileViewport()) {
159
- resolvedSetModalOpen.value?.(false);
160
- }
161
- }
162
-
163
- function ownRegisterDrawer(): () => void {
164
- ownDrawerCount.value += 1;
165
- return () => {
166
- ownDrawerCount.value = Math.max(0, ownDrawerCount.value - 1);
167
- };
168
- }
169
-
170
- const resolvedDrawerOpen = computed(() =>
171
- parentConfigValue.value
172
- ? parentConfigValue.value.drawerOpen
173
- : ownDrawerOpen.value,
174
- );
175
- const resolvedSetDrawerOpen = computed(() =>
176
- parentConfigValue.value
177
- ? parentConfigValue.value.setDrawerOpen
178
- : ownSetDrawerOpen,
179
- );
180
- const resolvedDrawerRegistered = computed(() =>
181
- parentConfigValue.value
182
- ? parentConfigValue.value.drawerRegistered
183
- : ownDrawerCount.value > 0,
184
- );
185
- const resolvedRegisterDrawer = computed(() =>
186
- parentConfigValue.value
187
- ? parentConfigValue.value.registerDrawer
188
- : ownRegisterDrawer,
189
- );
190
-
191
- // Public modal setter (mobile mutual-exclusion, other direction: opening the
192
- // chat modal closes the drawer). Preserve the contract that it is `undefined`
193
- // when this provider owns no modal state AND no parent provides one —
194
- // CopilotChatToggleButton relies on that absence to fall back to its own
195
- // local open-state. When a real modal setter exists (own `isModalDefaultOpen`
196
- // state or an inherited parent setter), wrap it so opening the modal on
197
- // mobile also closes the drawer.
198
- //
199
- // Note: this diverges from the React reference (CopilotChatConfigurationProvider.tsx),
200
- // which keeps `setModalOpen` always-defined and always backed by internal state. We
201
- // intentionally take the minimal Vue-local fix here — preserving the `undefined`
202
- // contract CopilotChatToggleButton depends on — rather than also reworking
203
- // `resolvedIsModalOpen`'s backing, to avoid changing bare-provider modal-open
204
- // semantics.
205
- const publicSetModalOpen = computed(() => {
206
- const base = resolvedSetModalOpen.value; // undefined when no modal state + no parent
207
- if (!base) return undefined;
208
- return (open: boolean) => {
209
- if (open && isMobileViewport()) {
210
- resolvedSetDrawerOpen.value?.(false);
211
- }
212
- base(open);
213
- };
214
75
  });
215
76
 
216
77
  const configurationValue = computed<CopilotChatConfigurationValue>(() => ({
217
78
  labels: mergedLabels.value,
218
- agentId: resolvedAgentId.value,
219
- threadId: resolvedThreadId.value,
220
- hasExplicitThreadId: resolvedHasExplicitThreadId.value,
221
- isModalOpen: resolvedIsModalOpen.value,
222
- setModalOpen: publicSetModalOpen.value,
223
- drawerOpen: resolvedDrawerOpen.value,
224
- setDrawerOpen: resolvedSetDrawerOpen.value,
225
- drawerRegistered: resolvedDrawerRegistered.value,
226
- registerDrawer: resolvedRegisterDrawer.value,
227
- setActiveThreadId,
228
- startNewThread,
79
+ agentId: snapshot.value.agentId,
80
+ threadId: snapshot.value.threadId,
81
+ hasExplicitThreadId: snapshot.value.hasExplicitThreadId,
82
+ isModalOpen: snapshot.value.isModalOpen,
83
+ setModalOpen: store.setModalOpen,
84
+ drawerOpen: snapshot.value.drawerOpen,
85
+ setDrawerOpen: store.setDrawerOpen,
86
+ drawerRegistered: snapshot.value.drawerRegistered,
87
+ registerDrawer: store.registerDrawer,
88
+ setActiveThreadId: store.setActiveThreadId,
89
+ startNewThread: store.startNewThread,
229
90
  }));
230
91
 
231
92
  provide(CopilotChatConfigurationKey, configurationValue);
93
+ provide(ChatConfigurationStoreKey, store);
232
94
  </script>
233
95
 
234
96
  <template>
@@ -1,12 +1,10 @@
1
1
  import type { A2UIRecoveryRendererOptions } from "../components/a2ui/A2UIRecoveryStates";
2
- import type { AbstractAgent } from "@ag-ui/client";
3
2
  import type {
4
- CopilotKitCoreErrorCode,
5
- CopilotKitHeadersSource,
6
- CopilotKitMessageFilter,
7
- LearningConfig,
3
+ ɵA2UIActionInterceptor,
4
+ ɵA2UIBaseOptions,
5
+ ɵCopilotKitLearningOptions,
6
+ ɵCopilotKitProviderBaseOptions,
8
7
  } from "@copilotkit/core";
9
- import type { DebugConfig } from "@copilotkit/shared";
10
8
  import type {
11
9
  A2UITheme,
12
10
  SandboxFunction,
@@ -19,15 +17,7 @@ import type {
19
17
  import type { Component } from "vue";
20
18
  import type { MarkdownRendererValue } from "./markdown-renderer";
21
19
 
22
- export interface CopilotKitProviderProps {
23
- runtimeUrl?: string;
24
- /**
25
- * Headers sent with every request. A record, or a sync or async builder
26
- * that runs when each request is sent. An inline arrow is fine. The builder
27
- * should be cheap; cache tokens in it.
28
- */
29
- headers?: CopilotKitHeadersSource;
30
- credentials?: RequestCredentials;
20
+ export interface CopilotKitProviderProps extends ɵCopilotKitProviderBaseOptions {
31
21
  /**
32
22
  * CSP nonce for the `<style>` tag CopilotKit adds. Set it when your
33
23
  * Content-Security-Policy limits `style-src` to a nonce.
@@ -39,42 +29,6 @@ export interface CopilotKitProviderProps {
39
29
  * @default true
40
30
  */
41
31
  injectStyles?: boolean;
42
- /**
43
- * Rewrites the message list sent to runtime agents on every run.
44
- *
45
- * CopilotKit sends the whole thread each time. When your agent already
46
- * stores the conversation, most of that payload is waste, and an agent that
47
- * merges the inbound list with its own store can show the model every turn
48
- * twice. Return the messages to send:
49
- *
50
- * ```vue
51
- * <CopilotKitProvider
52
- * runtime-url="/api/copilotkit"
53
- * :message-filter="(messages) => messages.slice(-1)"
54
- * />
55
- * ```
56
- *
57
- * The filter changes the request body only. The transcript the UI renders is
58
- * untouched. Broken tool-call pairs are repaired before the request is sent,
59
- * so a filter this blunt cannot strand a tool result mid-HITL.
60
- *
61
- * Agents reached through your CopilotRuntime honor this. An agent your app
62
- * passes in directly does not, and neither Intelligence runs nor suggestion
63
- * runs are ever filtered.
64
- */
65
- messageFilter?: CopilotKitMessageFilter;
66
- defaultThrottleMs?: number;
67
- publicApiKey?: string;
68
- publicLicenseKey?: string;
69
- /**
70
- * Signed license token for offline verification of CopilotKit Intelligence features.
71
- * Obtain from https://dashboard.operations.copilotkit.ai.
72
- */
73
- licenseToken?: string;
74
- properties?: Record<string, unknown>;
75
- useSingleEndpoint?: boolean;
76
- agents__unsafe_dev_only?: Record<string, AbstractAgent>;
77
- selfManagedAgents?: Record<string, AbstractAgent>;
78
32
  renderToolCalls?: VueToolCallRenderer<any>[];
79
33
  renderActivityMessages?: VueActivityMessageRenderer<unknown>[];
80
34
  renderCustomMessages?: VueCustomMessageRenderer[];
@@ -90,49 +44,23 @@ export interface CopilotKitProviderProps {
90
44
  * always disabled in production and during server rendering.
91
45
  */
92
46
  enableInspector?: boolean;
93
- onError?: (event: {
94
- error: Error;
95
- code: CopilotKitCoreErrorCode;
96
- context: Record<string, any>;
97
- }) => void | Promise<void>;
98
- a2ui?: {
47
+ a2ui?: ɵA2UIBaseOptions & {
99
48
  theme?: A2UITheme;
100
49
  catalog?: any;
101
50
  loadingComponent?: Component;
102
- /**
103
- * When true (the default), the full component schemas from the catalog are
104
- * sent as agent context so the agent knows what components and props are
105
- * available. The A2UI middleware can overwrite this with a server-side
106
- * schema if configured.
107
- *
108
- * When false, the agent context still describes the catalog, but only by its
109
- * catalog ID and the names of its custom components, without their JSON
110
- * schemas. The component schema entry and the A2UI generation and design
111
- * guidelines are not sent. With the CopilotKit LangGraph middleware's
112
- * injected A2UI tool, the A2UI subagent then gets the component names only;
113
- * a host can still give it a composition guide through the middleware's
114
- * guidelines (`a2uiParams.guidelines.compositionGuide` in TypeScript,
115
- * `a2ui_params["guidelines"]["composition_guide"]` in Python).
116
- */
117
- includeSchema?: boolean;
118
51
  /**
119
52
  * Options for the A2UI error-recovery status UI: how long before the
120
53
  * transient "Retrying…" hint appears, after how many attempts, and how
121
54
  * much retry/debug detail to surface. When omitted, defaults apply.
122
55
  */
123
56
  recovery?: A2UIRecoveryRendererOptions;
124
- };
125
- /** Configuration for the built-in MCP Apps renderer. */
126
- mcpApps?: {
127
57
  /**
128
- * Restore `allow-same-origin` on the MCP App sandbox. Default `false`.
129
- *
130
- * **Unsafe.** The widget then runs with your page's origin: it can read
131
- * your cookies, storage and DOM, and call your APIs as the signed-in user.
132
- * Only set it for widgets you wrote and trust that need `localStorage`,
133
- * `IndexedDB` or cookies. By default widgets get an opaque origin.
58
+ * Intercept A2UI user actions before they reach the agent: return `null`
59
+ * to handle an action client-side (e.g. a `navigate` event), return an
60
+ * action to forward that one instead, or return nothing to forward it
61
+ * unchanged.
134
62
  */
135
- allowSameOriginFallback?: boolean;
63
+ onAction?: ɵA2UIActionInterceptor;
136
64
  };
137
65
  /**
138
66
  * Global markdown renderer for assistant/reasoning messages. Either a Vue
@@ -143,50 +71,7 @@ export interface CopilotKitProviderProps {
143
71
  * a per-message slot still wins.
144
72
  */
145
73
  markdownRenderer?: MarkdownRendererValue;
146
- /**
147
- * Enable debug logging for the client-side event pipeline.
148
- *
149
- * Accepts:
150
- * - `true` / `false` to toggle events + lifecycle logging (verbose off).
151
- * - `{ events?: boolean; lifecycle?: boolean; verbose?: boolean }` for granular control.
152
- */
153
- debug?: DebugConfig;
154
- /**
155
- * Turns on interaction capture (`@copilotkit/learning`). `learning` (short
156
- * for `:learning="true"`) records with the default options; pass an object
157
- * for options. `false` or omitting the prop turns capture off and cancels
158
- * startup. Without a sink, Core authenticates with the runtime and sends
159
- * browser events to Intelligence; a custom sink keeps the standalone
160
- * collector behavior. Updated settings apply to the next Trajectory.
161
- *
162
- * Capture starts after mount. Set `trajectoryId` to use your own ID;
163
- * otherwise the provider generates one. The generated ID stays the same
164
- * across rerenders, reconnects and option changes; turning capture off,
165
- * setting `autoStart: false` or supplying a `trajectoryId` ends it, and the
166
- * next generated Trajectory gets a new ID. Read the active ID from
167
- * `copilotkit.trajectoryId`.
168
- *
169
- * Set `autoStart: false` to start capture yourself with `startTrajectory()`.
170
- * Capture stops on unmount, including manually started Trajectories.
171
- *
172
- * @example
173
- * <CopilotKitProvider runtime-url="/api/copilotkit" learning>
174
- */
175
- learning?: boolean | CopilotKitLearningOptions;
176
74
  }
177
75
 
178
76
  /** The object form of the `learning` prop. */
179
- export type CopilotKitLearningOptions = LearningConfig & {
180
- /**
181
- * Starts a Trajectory after mount. Defaults to `true`; set `false` to call
182
- * `startTrajectory()` yourself.
183
- */
184
- autoStart?: boolean;
185
- trajectoryId?: string;
186
- /**
187
- * Used only by explicit custom sinks. Authenticated capture warns and ignores
188
- * this option; assign Learning Spaces on the server with
189
- * `getTrajectoryLearningContainerIds` on `CopilotKitIntelligence`.
190
- */
191
- learningContainerIds?: string[];
192
- };
77
+ export type CopilotKitLearningOptions = ɵCopilotKitLearningOptions;