@copilotkit/vue 1.57.1 → 1.57.3

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 (30) hide show
  1. package/README.md +3 -3
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.mjs +4 -4
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/{use-render-activity-message-CqtxiFSs.js → use-render-activity-message-BCoXRqzE.js} +230 -202
  7. package/dist/use-render-activity-message-BCoXRqzE.js.map +1 -0
  8. package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -1
  9. package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
  10. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
  11. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
  12. package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
  13. package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
  14. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
  15. package/dist/v2/index.mjs +1 -1
  16. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  17. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
  18. package/package.json +24 -24
  19. package/src/hooks/use-frontend-tool.ts +2 -2
  20. package/src/v2/components/MCPAppsActivityRenderer.ts +1 -3
  21. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +23 -11
  22. package/src/v2/components/a2ui/A2UICatalogContext.ts +5 -6
  23. package/src/v2/components/a2ui/catalog.ts +235 -210
  24. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +2 -6
  25. package/src/v2/hooks/use-interrupt.ts +15 -10
  26. package/src/v2/hooks/use-render-activity-message.ts +7 -6
  27. package/src/v2/providers/CopilotChatConfigurationProvider.vue +1 -3
  28. package/src/v2/providers/CopilotKitProvider.types.ts +4 -1
  29. package/src/v2/providers/CopilotKitProvider.vue +7 -7
  30. package/dist/use-render-activity-message-CqtxiFSs.js.map +0 -1
@@ -452,127 +452,144 @@ const Button = createVueComponent(ButtonApi, ({ props, buildChild }) => {
452
452
  );
453
453
  });
454
454
 
455
- const TextField = createVueComponent(TextFieldApi, ({ props, state }) => {
456
- const uniqueId = state.id;
457
- const isLong = props.variant === "longText";
458
- const type =
459
- props.variant === "number"
460
- ? "number"
461
- : props.variant === "obscured"
462
- ? "password"
463
- : "text";
464
-
465
- const inputStyle = {
466
- padding: "8px",
467
- width: "100%",
468
- border:
469
- props.validationErrors && props.validationErrors.length > 0
470
- ? "1px solid red"
471
- : STANDARD_BORDER,
472
- borderRadius: STANDARD_RADIUS,
473
- boxSizing: "border-box",
474
- };
455
+ const TextField = createVueComponent(
456
+ TextFieldApi,
457
+ ({ props, state }) => {
458
+ const uniqueId = state.id;
459
+ const isLong = props.variant === "longText";
460
+ const type =
461
+ props.variant === "number"
462
+ ? "number"
463
+ : props.variant === "obscured"
464
+ ? "password"
465
+ : "text";
466
+
467
+ const inputStyle = {
468
+ padding: "8px",
469
+ width: "100%",
470
+ border:
471
+ props.validationErrors && props.validationErrors.length > 0
472
+ ? "1px solid red"
473
+ : STANDARD_BORDER,
474
+ borderRadius: STANDARD_RADIUS,
475
+ boxSizing: "border-box",
476
+ };
475
477
 
476
- const hasError = props.validationErrors && props.validationErrors.length > 0;
478
+ const hasError =
479
+ props.validationErrors && props.validationErrors.length > 0;
477
480
 
478
- return h(
479
- "div",
480
- {
481
- style: {
482
- display: "flex",
483
- flexDirection: "column",
484
- gap: "4px",
485
- width: "100%",
486
- margin: LEAF_MARGIN,
481
+ return h(
482
+ "div",
483
+ {
484
+ style: {
485
+ display: "flex",
486
+ flexDirection: "column",
487
+ gap: "4px",
488
+ width: "100%",
489
+ margin: LEAF_MARGIN,
490
+ },
487
491
  },
488
- },
489
- [
490
- props.label
491
- ? h(
492
- "label",
493
- { for: uniqueId, style: { fontSize: "14px", fontWeight: "bold" } },
494
- props.label,
495
- )
496
- : null,
497
- isLong
498
- ? h("textarea", {
499
- id: uniqueId,
500
- style: inputStyle,
501
- value: props.value || "",
502
- onInput: (e: Event) =>
503
- props.setValue((e.target as HTMLTextAreaElement).value),
504
- })
505
- : h("input", {
506
- id: uniqueId,
507
- type,
508
- style: inputStyle,
509
- value: props.value || "",
510
- onInput: (e: Event) =>
511
- props.setValue((e.target as HTMLInputElement).value),
512
- }),
513
- hasError
514
- ? h(
515
- "span",
516
- { style: { fontSize: "12px", color: "red" } },
517
- props.validationErrors![0],
518
- )
519
- : null,
520
- ],
521
- );
522
- }, () => ({ id: useA2UIUniqueId() }));
492
+ [
493
+ props.label
494
+ ? h(
495
+ "label",
496
+ {
497
+ for: uniqueId,
498
+ style: { fontSize: "14px", fontWeight: "bold" },
499
+ },
500
+ props.label,
501
+ )
502
+ : null,
503
+ isLong
504
+ ? h("textarea", {
505
+ id: uniqueId,
506
+ style: inputStyle,
507
+ value: props.value || "",
508
+ onInput: (e: Event) =>
509
+ props.setValue((e.target as HTMLTextAreaElement).value),
510
+ })
511
+ : h("input", {
512
+ id: uniqueId,
513
+ type,
514
+ style: inputStyle,
515
+ value: props.value || "",
516
+ onInput: (e: Event) =>
517
+ props.setValue((e.target as HTMLInputElement).value),
518
+ }),
519
+ hasError
520
+ ? h(
521
+ "span",
522
+ { style: { fontSize: "12px", color: "red" } },
523
+ props.validationErrors![0],
524
+ )
525
+ : null,
526
+ ],
527
+ );
528
+ },
529
+ () => ({ id: useA2UIUniqueId() }),
530
+ );
523
531
 
524
- const CheckBox = createVueComponent(CheckBoxApi, ({ props, state }) => {
525
- const uniqueId = state.id;
526
- const hasError = props.validationErrors && props.validationErrors.length > 0;
532
+ const CheckBox = createVueComponent(
533
+ CheckBoxApi,
534
+ ({ props, state }) => {
535
+ const uniqueId = state.id;
536
+ const hasError =
537
+ props.validationErrors && props.validationErrors.length > 0;
527
538
 
528
- return h(
529
- "div",
530
- {
531
- style: { display: "flex", flexDirection: "column", margin: LEAF_MARGIN },
532
- },
533
- [
534
- h(
535
- "div",
536
- { style: { display: "flex", alignItems: "center", gap: "8px" } },
537
- [
538
- h("input", {
539
- id: uniqueId,
540
- type: "checkbox",
541
- checked: !!props.value,
542
- onChange: (e: Event) =>
543
- props.setValue((e.target as HTMLInputElement).checked),
544
- style: {
545
- cursor: "pointer",
546
- outline: hasError ? "1px solid red" : "none",
547
- },
548
- }),
549
- props.label
550
- ? h(
551
- "label",
552
- {
553
- for: uniqueId,
554
- style: {
555
- cursor: "pointer",
556
- color: hasError ? "red" : "inherit",
539
+ return h(
540
+ "div",
541
+ {
542
+ style: {
543
+ display: "flex",
544
+ flexDirection: "column",
545
+ margin: LEAF_MARGIN,
546
+ },
547
+ },
548
+ [
549
+ h(
550
+ "div",
551
+ { style: { display: "flex", alignItems: "center", gap: "8px" } },
552
+ [
553
+ h("input", {
554
+ id: uniqueId,
555
+ type: "checkbox",
556
+ checked: !!props.value,
557
+ onChange: (e: Event) =>
558
+ props.setValue((e.target as HTMLInputElement).checked),
559
+ style: {
560
+ cursor: "pointer",
561
+ outline: hasError ? "1px solid red" : "none",
562
+ },
563
+ }),
564
+ props.label
565
+ ? h(
566
+ "label",
567
+ {
568
+ for: uniqueId,
569
+ style: {
570
+ cursor: "pointer",
571
+ color: hasError ? "red" : "inherit",
572
+ },
557
573
  },
558
- },
559
- props.label,
560
- )
561
- : null,
562
- ],
563
- ),
564
- hasError
565
- ? h(
566
- "span",
567
- {
568
- style: { fontSize: "12px", color: "red", marginTop: "4px" },
569
- },
570
- props.validationErrors?.[0],
571
- )
572
- : null,
573
- ],
574
- );
575
- }, () => ({ id: useA2UIUniqueId() }));
574
+ props.label,
575
+ )
576
+ : null,
577
+ ],
578
+ ),
579
+ hasError
580
+ ? h(
581
+ "span",
582
+ {
583
+ style: { fontSize: "12px", color: "red", marginTop: "4px" },
584
+ },
585
+ props.validationErrors?.[0],
586
+ )
587
+ : null,
588
+ ],
589
+ );
590
+ },
591
+ () => ({ id: useA2UIUniqueId() }),
592
+ );
576
593
 
577
594
  const ChoicePicker = createVueComponent(
578
595
  ChoicePickerApi,
@@ -704,106 +721,114 @@ const ChoicePicker = createVueComponent(
704
721
  () => ({ filter: ref("") }),
705
722
  );
706
723
 
707
- const Slider = createVueComponent(SliderApi, ({ props, state }) => {
708
- const uniqueId = state.id;
724
+ const Slider = createVueComponent(
725
+ SliderApi,
726
+ ({ props, state }) => {
727
+ const uniqueId = state.id;
709
728
 
710
- return h(
711
- "div",
712
- {
713
- style: {
714
- display: "flex",
715
- flexDirection: "column",
716
- gap: "4px",
717
- margin: LEAF_MARGIN,
718
- width: "100%",
729
+ return h(
730
+ "div",
731
+ {
732
+ style: {
733
+ display: "flex",
734
+ flexDirection: "column",
735
+ gap: "4px",
736
+ margin: LEAF_MARGIN,
737
+ width: "100%",
738
+ },
719
739
  },
720
- },
721
- [
722
- h(
723
- "div",
724
- { style: { display: "flex", justifyContent: "space-between" } },
725
- [
726
- props.label
727
- ? h(
728
- "label",
729
- {
730
- for: uniqueId,
731
- style: { fontSize: "14px", fontWeight: "bold" },
732
- },
733
- props.label,
734
- )
735
- : null,
736
- h(
737
- "span",
738
- { style: { fontSize: "12px", color: "#666" } },
739
- String(props.value),
740
- ),
741
- ],
742
- ),
743
- h("input", {
744
- id: uniqueId,
745
- type: "range",
746
- min: props.min ?? 0,
747
- max: props.max,
748
- value: props.value ?? 0,
749
- onInput: (e: Event) =>
750
- props.setValue(Number((e.target as HTMLInputElement).value)),
751
- style: { width: "100%", cursor: "pointer" },
752
- }),
753
- ],
754
- );
755
- }, () => ({ id: useA2UIUniqueId() }));
756
-
757
- const DateTimeInput = createVueComponent(DateTimeInputApi, ({ props, state }) => {
758
- const uniqueId = state.id;
759
-
760
- let type = "datetime-local";
761
- if (props.enableDate && !props.enableTime) type = "date";
762
- if (!props.enableDate && props.enableTime) type = "time";
740
+ [
741
+ h(
742
+ "div",
743
+ { style: { display: "flex", justifyContent: "space-between" } },
744
+ [
745
+ props.label
746
+ ? h(
747
+ "label",
748
+ {
749
+ for: uniqueId,
750
+ style: { fontSize: "14px", fontWeight: "bold" },
751
+ },
752
+ props.label,
753
+ )
754
+ : null,
755
+ h(
756
+ "span",
757
+ { style: { fontSize: "12px", color: "#666" } },
758
+ String(props.value),
759
+ ),
760
+ ],
761
+ ),
762
+ h("input", {
763
+ id: uniqueId,
764
+ type: "range",
765
+ min: props.min ?? 0,
766
+ max: props.max,
767
+ value: props.value ?? 0,
768
+ onInput: (e: Event) =>
769
+ props.setValue(Number((e.target as HTMLInputElement).value)),
770
+ style: { width: "100%", cursor: "pointer" },
771
+ }),
772
+ ],
773
+ );
774
+ },
775
+ () => ({ id: useA2UIUniqueId() }),
776
+ );
763
777
 
764
- const style = {
765
- padding: "8px",
766
- width: "100%",
767
- border: STANDARD_BORDER,
768
- borderRadius: STANDARD_RADIUS,
769
- boxSizing: "border-box",
770
- };
778
+ const DateTimeInput = createVueComponent(
779
+ DateTimeInputApi,
780
+ ({ props, state }) => {
781
+ const uniqueId = state.id;
782
+
783
+ let type = "datetime-local";
784
+ if (props.enableDate && !props.enableTime) type = "date";
785
+ if (!props.enableDate && props.enableTime) type = "time";
786
+
787
+ const style = {
788
+ padding: "8px",
789
+ width: "100%",
790
+ border: STANDARD_BORDER,
791
+ borderRadius: STANDARD_RADIUS,
792
+ boxSizing: "border-box",
793
+ };
771
794
 
772
- return h(
773
- "div",
774
- {
775
- style: {
776
- display: "flex",
777
- flexDirection: "column",
778
- gap: "4px",
779
- width: "100%",
780
- margin: LEAF_MARGIN,
795
+ return h(
796
+ "div",
797
+ {
798
+ style: {
799
+ display: "flex",
800
+ flexDirection: "column",
801
+ gap: "4px",
802
+ width: "100%",
803
+ margin: LEAF_MARGIN,
804
+ },
781
805
  },
782
- },
783
- [
784
- props.label
785
- ? h(
786
- "label",
787
- {
788
- for: uniqueId,
789
- style: { fontSize: "14px", fontWeight: "bold" },
790
- },
791
- props.label,
792
- )
793
- : null,
794
- h("input", {
795
- id: uniqueId,
796
- type,
797
- style,
798
- value: props.value || "",
799
- onInput: (e: Event) =>
800
- props.setValue((e.target as HTMLInputElement).value),
801
- min: typeof props.min === "string" ? props.min : undefined,
802
- max: typeof props.max === "string" ? props.max : undefined,
803
- }),
804
- ],
805
- );
806
- }, () => ({ id: useA2UIUniqueId() }));
806
+ [
807
+ props.label
808
+ ? h(
809
+ "label",
810
+ {
811
+ for: uniqueId,
812
+ style: { fontSize: "14px", fontWeight: "bold" },
813
+ },
814
+ props.label,
815
+ )
816
+ : null,
817
+ h("input", {
818
+ id: uniqueId,
819
+ type,
820
+ style,
821
+ value: props.value || "",
822
+ onInput: (e: Event) =>
823
+ props.setValue((e.target as HTMLInputElement).value),
824
+ min: typeof props.min === "string" ? props.min : undefined,
825
+ max: typeof props.max === "string" ? props.max : undefined,
826
+ }),
827
+ ],
828
+ );
829
+ },
830
+ () => ({ id: useA2UIUniqueId() }),
831
+ );
807
832
 
808
833
  // ============================================================
809
834
  // Catalog Assembly
@@ -392,9 +392,7 @@ describe("CopilotChat activity message rendering", () => {
392
392
  // React's useEffect which defers). The connectAgent path calls
393
393
  // setMessages([]) which would race with the submit's addMessage.
394
394
  await waitFor(() => {
395
- expect(
396
- screen.queryByTestId("copilot-chat-view"),
397
- ).not.toBeNull();
395
+ expect(screen.queryByTestId("copilot-chat-view")).not.toBeNull();
398
396
  });
399
397
  await new Promise((r) => setTimeout(r, 50));
400
398
 
@@ -634,9 +632,7 @@ describe("CopilotChat activity message rendering", () => {
634
632
  // Allow the /connect bootstrap cycle to settle before submitting.
635
633
  // See the A2UI reconnect test above for the full rationale.
636
634
  await waitFor(() => {
637
- expect(
638
- screen.queryByTestId("copilot-chat-view"),
639
- ).not.toBeNull();
635
+ expect(screen.queryByTestId("copilot-chat-view")).not.toBeNull();
640
636
  });
641
637
  await new Promise((r) => setTimeout(r, 50));
642
638
 
@@ -139,17 +139,22 @@ export function useInterrupt<TValue = unknown, TResult = never>(
139
139
 
140
140
  const interruptEventValue = interrupt.value?.value;
141
141
  interrupt.value = null;
142
- void copilotkit.value.runAgent({
143
- agent: resolvedAgent,
144
- forwardedProps: {
145
- command: {
146
- resume: response,
147
- interruptEvent: interruptEventValue,
142
+ void copilotkit.value
143
+ .runAgent({
144
+ agent: resolvedAgent,
145
+ forwardedProps: {
146
+ command: {
147
+ resume: response,
148
+ interruptEvent: interruptEventValue,
149
+ },
148
150
  },
149
- },
150
- }).catch((error) => {
151
- console.error("[CopilotKit] useInterrupt: failed to resume agent:", error);
152
- });
151
+ })
152
+ .catch((error) => {
153
+ console.error(
154
+ "[CopilotKit] useInterrupt: failed to resume agent:",
155
+ error,
156
+ );
157
+ });
153
158
  };
154
159
 
155
160
  watch(
@@ -26,11 +26,11 @@ interface ActivityRendererResult {
26
26
  export function useRenderActivityMessage() {
27
27
  const { copilotkit } = useCopilotKit();
28
28
  const config = useCopilotChatConfiguration();
29
- const agentId = computed(
30
- () => config.value?.agentId ?? DEFAULT_AGENT_ID,
31
- );
29
+ const agentId = computed(() => config.value?.agentId ?? DEFAULT_AGENT_ID);
32
30
 
33
- const renderers = computed(() => [...copilotkit.value.renderActivityMessages]);
31
+ const renderers = computed(() => [
32
+ ...copilotkit.value.renderActivityMessages,
33
+ ]);
34
34
 
35
35
  function findRenderer(
36
36
  activityType: string,
@@ -72,8 +72,9 @@ export function useRenderActivityMessage() {
72
72
  return null;
73
73
  }
74
74
 
75
- const agent: AbstractAgent | undefined =
76
- copilotkit.value.getAgent(agentId.value);
75
+ const agent: AbstractAgent | undefined = copilotkit.value.getAgent(
76
+ agentId.value,
77
+ );
77
78
 
78
79
  return {
79
80
  renderer: renderer.render as Component<
@@ -55,9 +55,7 @@ const resolvedHasExplicitThreadId = computed(() => {
55
55
  const shouldCreateModalState = computed(
56
56
  () => props.isModalDefaultOpen !== undefined,
57
57
  );
58
- const resolvedDefaultOpen = computed(
59
- () => props.isModalDefaultOpen ?? true,
60
- );
58
+ const resolvedDefaultOpen = computed(() => props.isModalDefaultOpen ?? true);
61
59
 
62
60
  const internalModalOpen = ref<boolean>(
63
61
  parentConfigValue.value?.isModalOpen ?? resolvedDefaultOpen.value,
@@ -54,7 +54,10 @@ export interface CopilotKitProviderProps {
54
54
  * Only used on first load before the user drags to a custom position.
55
55
  * Defaults to `{ horizontal: "right", vertical: "top" }`.
56
56
  */
57
- inspectorDefaultAnchor?: { horizontal: "left" | "right"; vertical: "top" | "bottom" };
57
+ inspectorDefaultAnchor?: {
58
+ horizontal: "left" | "right";
59
+ vertical: "top" | "bottom";
60
+ };
58
61
  /**
59
62
  * Enable debug logging for the client-side event pipeline.
60
63
  *
@@ -315,7 +315,8 @@ const builtInFrontendTools = computed<VueFrontendTool[]>(() => {
315
315
  parameters: GenerateSandboxedUiArgsSchema,
316
316
  handler: async () => "UI generated",
317
317
  followUp: true,
318
- render: OpenGenerativeUIToolRenderer as unknown as VueFrontendTool["render"],
318
+ render:
319
+ OpenGenerativeUIToolRenderer as unknown as VueFrontendTool["render"],
319
320
  } as VueFrontendTool,
320
321
  ];
321
322
  });
@@ -327,7 +328,8 @@ const builtInActivityRenderers = computed<
327
328
  {
328
329
  activityType: MCPAppsActivityType,
329
330
  content: MCPAppsActivityContentSchema as unknown as z.ZodSchema<unknown>,
330
- render: MCPAppsActivityRenderer as unknown as VueActivityMessageRenderer<unknown>["render"],
331
+ render:
332
+ MCPAppsActivityRenderer as unknown as VueActivityMessageRenderer<unknown>["render"],
331
333
  },
332
334
  ];
333
335
 
@@ -335,7 +337,8 @@ const builtInActivityRenderers = computed<
335
337
  renderers.push({
336
338
  activityType: OpenGenerativeUIActivityType,
337
339
  content: OpenGenerativeUIContentSchema as unknown as z.ZodSchema<unknown>,
338
- render: OpenGenerativeUIActivityRenderer as unknown as VueActivityMessageRenderer<unknown>["render"],
340
+ render:
341
+ OpenGenerativeUIActivityRenderer as unknown as VueActivityMessageRenderer<unknown>["render"],
339
342
  });
340
343
  }
341
344
 
@@ -545,10 +548,7 @@ const a2uiLoadingComponent = computed(() => props.a2ui?.loadingComponent);
545
548
  const a2uiIncludeSchema = computed(() => props.a2ui?.includeSchema ?? true);
546
549
 
547
550
  // A2UI tool call renderer (progress indicator) — auto-registered when A2UI enabled
548
- registerA2UIBuiltInToolCallRenderer(
549
- copilotkit,
550
- () => runtimeA2UIEnabled.value,
551
- );
551
+ registerA2UIBuiltInToolCallRenderer(copilotkit, () => runtimeA2UIEnabled.value);
552
552
 
553
553
  // A2UI catalog context, schema, and generation/design guidelines
554
554
  registerA2UICatalogContext(copilotkit, {