@copilotkit/react-core 1.50.0-beta.8 → 1.50.0

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 (77) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/dist/{chunk-KYY2WZSR.mjs → chunk-5J7RRLRO.mjs} +2 -2
  3. package/dist/{chunk-ZU6ZBX4E.mjs → chunk-CO6V4G7P.mjs} +17 -9
  4. package/dist/chunk-CO6V4G7P.mjs.map +1 -0
  5. package/dist/{chunk-Y2L7KDVW.mjs → chunk-HQTDDA6V.mjs} +2 -2
  6. package/dist/chunk-LDEWO5XH.mjs +328 -0
  7. package/dist/chunk-LDEWO5XH.mjs.map +1 -0
  8. package/dist/chunk-XDFVCQD3.mjs +27 -0
  9. package/dist/chunk-XDFVCQD3.mjs.map +1 -0
  10. package/dist/{chunk-RQ6LWR6S.mjs → chunk-Z6JV2LRY.mjs} +1 -1
  11. package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
  12. package/dist/{chunk-BLDHD6Q2.mjs → chunk-ZE4JVTEP.mjs} +2 -2
  13. package/dist/components/copilot-provider/copilotkit-props.d.ts +6 -0
  14. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  15. package/dist/components/copilot-provider/copilotkit.js +127 -1150
  16. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  17. package/dist/components/copilot-provider/copilotkit.mjs +3 -6
  18. package/dist/components/copilot-provider/index.js +127 -1150
  19. package/dist/components/copilot-provider/index.js.map +1 -1
  20. package/dist/components/copilot-provider/index.mjs +3 -6
  21. package/dist/components/dev-console/console-trigger.mjs +225 -5
  22. package/dist/components/dev-console/console-trigger.mjs.map +1 -1
  23. package/dist/components/index.js +127 -1150
  24. package/dist/components/index.js.map +1 -1
  25. package/dist/components/index.mjs +3 -6
  26. package/dist/hooks/index.d.ts +1 -1
  27. package/dist/hooks/index.js +124 -554
  28. package/dist/hooks/index.js.map +1 -1
  29. package/dist/hooks/index.mjs +19 -19
  30. package/dist/hooks/use-copilot-chat-headless_c.js +42 -487
  31. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  32. package/dist/hooks/use-copilot-chat-headless_c.mjs +2 -3
  33. package/dist/hooks/{use-configure-chat-suggestions.d.ts → use-copilot-chat-suggestions.d.ts} +2 -3
  34. package/dist/hooks/{use-configure-chat-suggestions.js → use-copilot-chat-suggestions.js} +10 -29
  35. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  36. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  37. package/dist/hooks/use-copilot-chat.js +40 -485
  38. package/dist/hooks/use-copilot-chat.js.map +1 -1
  39. package/dist/hooks/use-copilot-chat.mjs +2 -3
  40. package/dist/hooks/use-copilot-chat_internal.d.ts +17 -0
  41. package/dist/hooks/use-copilot-chat_internal.js +40 -485
  42. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  43. package/dist/hooks/use-copilot-chat_internal.mjs +1 -2
  44. package/dist/hooks/use-copilot-readable.d.ts +2 -3
  45. package/dist/hooks/use-copilot-readable.js.map +1 -1
  46. package/dist/hooks/use-copilot-readable.mjs +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +300 -1746
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +24 -27
  51. package/dist/lib/copilot-task.js.map +1 -1
  52. package/dist/lib/copilot-task.mjs +4 -7
  53. package/dist/lib/index.js.map +1 -1
  54. package/dist/lib/index.mjs +4 -7
  55. package/dist/types/index.mjs +1 -1
  56. package/package.json +8 -8
  57. package/src/components/copilot-provider/copilotkit-props.tsx +7 -0
  58. package/src/components/copilot-provider/copilotkit.tsx +13 -5
  59. package/src/hooks/index.ts +2 -2
  60. package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
  61. package/src/hooks/use-copilot-chat_internal.ts +29 -29
  62. package/src/hooks/use-copilot-readable.ts +2 -4
  63. package/dist/chunk-EKDPRKZT.mjs +0 -746
  64. package/dist/chunk-EKDPRKZT.mjs.map +0 -1
  65. package/dist/chunk-FBVI3LQ6.mjs +0 -48
  66. package/dist/chunk-FBVI3LQ6.mjs.map +0 -1
  67. package/dist/chunk-PMWUKW3Z.mjs +0 -231
  68. package/dist/chunk-PMWUKW3Z.mjs.map +0 -1
  69. package/dist/chunk-RQ6LWR6S.mjs.map +0 -1
  70. package/dist/chunk-ZU6ZBX4E.mjs.map +0 -1
  71. package/dist/hooks/use-configure-chat-suggestions.js.map +0 -1
  72. package/dist/hooks/use-configure-chat-suggestions.mjs +0 -8
  73. package/src/hooks/use-configure-chat-suggestions.tsx +0 -86
  74. /package/dist/{chunk-KYY2WZSR.mjs.map → chunk-5J7RRLRO.mjs.map} +0 -0
  75. /package/dist/{chunk-Y2L7KDVW.mjs.map → chunk-HQTDDA6V.mjs.map} +0 -0
  76. /package/dist/{chunk-BLDHD6Q2.mjs.map → chunk-ZE4JVTEP.mjs.map} +0 -0
  77. /package/dist/hooks/{use-configure-chat-suggestions.mjs.map → use-copilot-chat-suggestions.mjs.map} +0 -0
@@ -83,7 +83,7 @@ __export(use_copilot_chat_headless_c_exports, {
83
83
  useCopilotChatHeadless_c: () => useCopilotChatHeadless_c
84
84
  });
85
85
  module.exports = __toCommonJS(use_copilot_chat_headless_c_exports);
86
- var import_react17 = require("react");
86
+ var import_react15 = require("react");
87
87
 
88
88
  // src/context/copilot-context.tsx
89
89
  var import_react = __toESM(require("react"));
@@ -187,7 +187,7 @@ function returnAndThrowInDebug(_value) {
187
187
  }
188
188
 
189
189
  // src/hooks/use-copilot-chat_internal.ts
190
- var import_react15 = require("react");
190
+ var import_react13 = require("react");
191
191
 
192
192
  // src/components/error-boundary/error-utils.tsx
193
193
  var import_react3 = require("react");
@@ -475,7 +475,7 @@ function useLangGraphInterruptRender(agent) {
475
475
  }
476
476
 
477
477
  // src/hooks/use-copilot-chat_internal.ts
478
- var import_react16 = require("@copilotkitnext/react");
478
+ var import_react14 = require("@copilotkitnext/react");
479
479
 
480
480
  // src/hooks/use-lazy-tool-renderer.tsx
481
481
  var import_react9 = require("@copilotkitnext/react");
@@ -502,448 +502,12 @@ function useLazyToolRenderer() {
502
502
  );
503
503
  }
504
504
 
505
- // src/hooks/use-configure-chat-suggestions.tsx
506
- var import_react11 = require("@copilotkitnext/react");
507
- var import_react12 = require("react");
508
- function useConfigureChatSuggestions(config, dependencies = []) {
509
- var _a;
510
- const existingConfig = (0, import_react11.useCopilotChatConfiguration)();
511
- const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
512
- const { copilotkit } = (0, import_react11.useCopilotKit)();
513
- const available = config.available === "enabled" ? "always" : config.available;
514
- const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
515
- available,
516
- consumerAgentId: resolvedAgentId
517
- // Use chatConfig.agentId here
518
- });
519
- (0, import_react11.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
520
- const result = (0, import_react11.useSuggestions)({ agentId: resolvedAgentId });
521
- (0, import_react12.useEffect)(() => {
522
- if (finalSuggestionConfig.available === "disabled")
523
- return;
524
- const subscription = copilotkit.subscribe({
525
- onAgentsChanged: () => {
526
- const agent = copilotkit.getAgent(resolvedAgentId);
527
- if (agent && !agent.isRunning && !result.suggestions.length) {
528
- copilotkit.reloadSuggestions(resolvedAgentId);
529
- }
530
- }
531
- });
532
- return () => {
533
- subscription.unsubscribe();
534
- };
535
- }, [resolvedAgentId]);
536
- return result;
537
- }
538
-
539
- // ../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/dist/index.mjs
540
- var import_zod = require("zod");
541
- var import_zod2 = require("zod");
542
- var FunctionCallSchema = import_zod.z.object({
543
- name: import_zod.z.string(),
544
- arguments: import_zod.z.string()
545
- });
546
- var ToolCallSchema = import_zod.z.object({
547
- id: import_zod.z.string(),
548
- type: import_zod.z.literal("function"),
549
- function: FunctionCallSchema
550
- });
551
- var BaseMessageSchema = import_zod.z.object({
552
- id: import_zod.z.string(),
553
- role: import_zod.z.string(),
554
- content: import_zod.z.string().optional(),
555
- name: import_zod.z.string().optional()
556
- });
557
- var TextInputContentSchema = import_zod.z.object({
558
- type: import_zod.z.literal("text"),
559
- text: import_zod.z.string()
560
- });
561
- var BinaryInputContentObjectSchema = import_zod.z.object({
562
- type: import_zod.z.literal("binary"),
563
- mimeType: import_zod.z.string(),
564
- id: import_zod.z.string().optional(),
565
- url: import_zod.z.string().optional(),
566
- data: import_zod.z.string().optional(),
567
- filename: import_zod.z.string().optional()
568
- });
569
- var ensureBinaryPayload = (value, ctx) => {
570
- if (!value.id && !value.url && !value.data) {
571
- ctx.addIssue({
572
- code: import_zod.z.ZodIssueCode.custom,
573
- message: "BinaryInputContent requires at least one of id, url, or data.",
574
- path: ["id"]
575
- });
576
- }
577
- };
578
- var BinaryInputContentSchema = BinaryInputContentObjectSchema.superRefine((value, ctx) => {
579
- ensureBinaryPayload(value, ctx);
580
- });
581
- var InputContentBaseSchema = import_zod.z.discriminatedUnion("type", [
582
- TextInputContentSchema,
583
- BinaryInputContentObjectSchema
584
- ]);
585
- var InputContentSchema = InputContentBaseSchema.superRefine((value, ctx) => {
586
- if (value.type === "binary") {
587
- ensureBinaryPayload(value, ctx);
588
- }
589
- });
590
- var DeveloperMessageSchema = BaseMessageSchema.extend({
591
- role: import_zod.z.literal("developer"),
592
- content: import_zod.z.string()
593
- });
594
- var SystemMessageSchema = BaseMessageSchema.extend({
595
- role: import_zod.z.literal("system"),
596
- content: import_zod.z.string()
597
- });
598
- var AssistantMessageSchema = BaseMessageSchema.extend({
599
- role: import_zod.z.literal("assistant"),
600
- content: import_zod.z.string().optional(),
601
- toolCalls: import_zod.z.array(ToolCallSchema).optional()
602
- });
603
- var UserMessageSchema = BaseMessageSchema.extend({
604
- role: import_zod.z.literal("user"),
605
- content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(InputContentSchema)])
606
- });
607
- var ToolMessageSchema = import_zod.z.object({
608
- id: import_zod.z.string(),
609
- content: import_zod.z.string(),
610
- role: import_zod.z.literal("tool"),
611
- toolCallId: import_zod.z.string(),
612
- error: import_zod.z.string().optional()
613
- });
614
- var ActivityMessageSchema = import_zod.z.object({
615
- id: import_zod.z.string(),
616
- role: import_zod.z.literal("activity"),
617
- activityType: import_zod.z.string(),
618
- content: import_zod.z.record(import_zod.z.any())
619
- });
620
- var MessageSchema = import_zod.z.discriminatedUnion("role", [
621
- DeveloperMessageSchema,
622
- SystemMessageSchema,
623
- AssistantMessageSchema,
624
- UserMessageSchema,
625
- ToolMessageSchema,
626
- ActivityMessageSchema
627
- ]);
628
- var RoleSchema = import_zod.z.union([
629
- import_zod.z.literal("developer"),
630
- import_zod.z.literal("system"),
631
- import_zod.z.literal("assistant"),
632
- import_zod.z.literal("user"),
633
- import_zod.z.literal("tool"),
634
- import_zod.z.literal("activity")
635
- ]);
636
- var ContextSchema = import_zod.z.object({
637
- description: import_zod.z.string(),
638
- value: import_zod.z.string()
639
- });
640
- var ToolSchema = import_zod.z.object({
641
- name: import_zod.z.string(),
642
- description: import_zod.z.string(),
643
- parameters: import_zod.z.any()
644
- // JSON Schema for the tool parameters
645
- });
646
- var RunAgentInputSchema = import_zod.z.object({
647
- threadId: import_zod.z.string(),
648
- runId: import_zod.z.string(),
649
- parentRunId: import_zod.z.string().optional(),
650
- state: import_zod.z.any(),
651
- messages: import_zod.z.array(MessageSchema),
652
- tools: import_zod.z.array(ToolSchema),
653
- context: import_zod.z.array(ContextSchema),
654
- forwardedProps: import_zod.z.any()
655
- });
656
- var StateSchema = import_zod.z.any();
657
- var AGUIError = class extends Error {
658
- constructor(message) {
659
- super(message);
660
- }
661
- };
662
- var AGUIConnectNotImplementedError = class extends AGUIError {
663
- constructor() {
664
- super("Connect not implemented. This method is not supported by the current agent.");
665
- }
666
- };
667
- var TextMessageRoleSchema = import_zod2.z.union([
668
- import_zod2.z.literal("developer"),
669
- import_zod2.z.literal("system"),
670
- import_zod2.z.literal("assistant"),
671
- import_zod2.z.literal("user")
672
- ]);
673
- var EventType = /* @__PURE__ */ ((EventType2) => {
674
- EventType2["TEXT_MESSAGE_START"] = "TEXT_MESSAGE_START";
675
- EventType2["TEXT_MESSAGE_CONTENT"] = "TEXT_MESSAGE_CONTENT";
676
- EventType2["TEXT_MESSAGE_END"] = "TEXT_MESSAGE_END";
677
- EventType2["TEXT_MESSAGE_CHUNK"] = "TEXT_MESSAGE_CHUNK";
678
- EventType2["THINKING_TEXT_MESSAGE_START"] = "THINKING_TEXT_MESSAGE_START";
679
- EventType2["THINKING_TEXT_MESSAGE_CONTENT"] = "THINKING_TEXT_MESSAGE_CONTENT";
680
- EventType2["THINKING_TEXT_MESSAGE_END"] = "THINKING_TEXT_MESSAGE_END";
681
- EventType2["TOOL_CALL_START"] = "TOOL_CALL_START";
682
- EventType2["TOOL_CALL_ARGS"] = "TOOL_CALL_ARGS";
683
- EventType2["TOOL_CALL_END"] = "TOOL_CALL_END";
684
- EventType2["TOOL_CALL_CHUNK"] = "TOOL_CALL_CHUNK";
685
- EventType2["TOOL_CALL_RESULT"] = "TOOL_CALL_RESULT";
686
- EventType2["THINKING_START"] = "THINKING_START";
687
- EventType2["THINKING_END"] = "THINKING_END";
688
- EventType2["STATE_SNAPSHOT"] = "STATE_SNAPSHOT";
689
- EventType2["STATE_DELTA"] = "STATE_DELTA";
690
- EventType2["MESSAGES_SNAPSHOT"] = "MESSAGES_SNAPSHOT";
691
- EventType2["ACTIVITY_SNAPSHOT"] = "ACTIVITY_SNAPSHOT";
692
- EventType2["ACTIVITY_DELTA"] = "ACTIVITY_DELTA";
693
- EventType2["RAW"] = "RAW";
694
- EventType2["CUSTOM"] = "CUSTOM";
695
- EventType2["RUN_STARTED"] = "RUN_STARTED";
696
- EventType2["RUN_FINISHED"] = "RUN_FINISHED";
697
- EventType2["RUN_ERROR"] = "RUN_ERROR";
698
- EventType2["STEP_STARTED"] = "STEP_STARTED";
699
- EventType2["STEP_FINISHED"] = "STEP_FINISHED";
700
- return EventType2;
701
- })(EventType || {});
702
- var BaseEventSchema = import_zod2.z.object({
703
- type: import_zod2.z.nativeEnum(EventType),
704
- timestamp: import_zod2.z.number().optional(),
705
- rawEvent: import_zod2.z.any().optional()
706
- });
707
- var TextMessageStartEventSchema = BaseEventSchema.extend({
708
- type: import_zod2.z.literal(
709
- "TEXT_MESSAGE_START"
710
- /* TEXT_MESSAGE_START */
711
- ),
712
- messageId: import_zod2.z.string(),
713
- role: TextMessageRoleSchema.default("assistant")
714
- });
715
- var TextMessageContentEventSchema = BaseEventSchema.extend({
716
- type: import_zod2.z.literal(
717
- "TEXT_MESSAGE_CONTENT"
718
- /* TEXT_MESSAGE_CONTENT */
719
- ),
720
- messageId: import_zod2.z.string(),
721
- delta: import_zod2.z.string().refine((s) => s.length > 0, "Delta must not be an empty string")
722
- });
723
- var TextMessageEndEventSchema = BaseEventSchema.extend({
724
- type: import_zod2.z.literal(
725
- "TEXT_MESSAGE_END"
726
- /* TEXT_MESSAGE_END */
727
- ),
728
- messageId: import_zod2.z.string()
729
- });
730
- var TextMessageChunkEventSchema = BaseEventSchema.extend({
731
- type: import_zod2.z.literal(
732
- "TEXT_MESSAGE_CHUNK"
733
- /* TEXT_MESSAGE_CHUNK */
734
- ),
735
- messageId: import_zod2.z.string().optional(),
736
- role: TextMessageRoleSchema.optional(),
737
- delta: import_zod2.z.string().optional()
738
- });
739
- var ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({
740
- type: import_zod2.z.literal(
741
- "THINKING_TEXT_MESSAGE_START"
742
- /* THINKING_TEXT_MESSAGE_START */
743
- )
744
- });
745
- var ThinkingTextMessageContentEventSchema = TextMessageContentEventSchema.omit({
746
- messageId: true,
747
- type: true
748
- }).extend({
749
- type: import_zod2.z.literal(
750
- "THINKING_TEXT_MESSAGE_CONTENT"
751
- /* THINKING_TEXT_MESSAGE_CONTENT */
752
- )
753
- });
754
- var ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({
755
- type: import_zod2.z.literal(
756
- "THINKING_TEXT_MESSAGE_END"
757
- /* THINKING_TEXT_MESSAGE_END */
758
- )
759
- });
760
- var ToolCallStartEventSchema = BaseEventSchema.extend({
761
- type: import_zod2.z.literal(
762
- "TOOL_CALL_START"
763
- /* TOOL_CALL_START */
764
- ),
765
- toolCallId: import_zod2.z.string(),
766
- toolCallName: import_zod2.z.string(),
767
- parentMessageId: import_zod2.z.string().optional()
768
- });
769
- var ToolCallArgsEventSchema = BaseEventSchema.extend({
770
- type: import_zod2.z.literal(
771
- "TOOL_CALL_ARGS"
772
- /* TOOL_CALL_ARGS */
773
- ),
774
- toolCallId: import_zod2.z.string(),
775
- delta: import_zod2.z.string()
776
- });
777
- var ToolCallEndEventSchema = BaseEventSchema.extend({
778
- type: import_zod2.z.literal(
779
- "TOOL_CALL_END"
780
- /* TOOL_CALL_END */
781
- ),
782
- toolCallId: import_zod2.z.string()
783
- });
784
- var ToolCallResultEventSchema = BaseEventSchema.extend({
785
- messageId: import_zod2.z.string(),
786
- type: import_zod2.z.literal(
787
- "TOOL_CALL_RESULT"
788
- /* TOOL_CALL_RESULT */
789
- ),
790
- toolCallId: import_zod2.z.string(),
791
- content: import_zod2.z.string(),
792
- role: import_zod2.z.literal("tool").optional()
793
- });
794
- var ToolCallChunkEventSchema = BaseEventSchema.extend({
795
- type: import_zod2.z.literal(
796
- "TOOL_CALL_CHUNK"
797
- /* TOOL_CALL_CHUNK */
798
- ),
799
- toolCallId: import_zod2.z.string().optional(),
800
- toolCallName: import_zod2.z.string().optional(),
801
- parentMessageId: import_zod2.z.string().optional(),
802
- delta: import_zod2.z.string().optional()
803
- });
804
- var ThinkingStartEventSchema = BaseEventSchema.extend({
805
- type: import_zod2.z.literal(
806
- "THINKING_START"
807
- /* THINKING_START */
808
- ),
809
- title: import_zod2.z.string().optional()
810
- });
811
- var ThinkingEndEventSchema = BaseEventSchema.extend({
812
- type: import_zod2.z.literal(
813
- "THINKING_END"
814
- /* THINKING_END */
815
- )
816
- });
817
- var StateSnapshotEventSchema = BaseEventSchema.extend({
818
- type: import_zod2.z.literal(
819
- "STATE_SNAPSHOT"
820
- /* STATE_SNAPSHOT */
821
- ),
822
- snapshot: StateSchema
823
- });
824
- var StateDeltaEventSchema = BaseEventSchema.extend({
825
- type: import_zod2.z.literal(
826
- "STATE_DELTA"
827
- /* STATE_DELTA */
828
- ),
829
- delta: import_zod2.z.array(import_zod2.z.any())
830
- // JSON Patch (RFC 6902)
831
- });
832
- var MessagesSnapshotEventSchema = BaseEventSchema.extend({
833
- type: import_zod2.z.literal(
834
- "MESSAGES_SNAPSHOT"
835
- /* MESSAGES_SNAPSHOT */
836
- ),
837
- messages: import_zod2.z.array(MessageSchema)
838
- });
839
- var ActivitySnapshotEventSchema = BaseEventSchema.extend({
840
- type: import_zod2.z.literal(
841
- "ACTIVITY_SNAPSHOT"
842
- /* ACTIVITY_SNAPSHOT */
843
- ),
844
- messageId: import_zod2.z.string(),
845
- activityType: import_zod2.z.string(),
846
- content: import_zod2.z.record(import_zod2.z.any()),
847
- replace: import_zod2.z.boolean().optional().default(true)
848
- });
849
- var ActivityDeltaEventSchema = BaseEventSchema.extend({
850
- type: import_zod2.z.literal(
851
- "ACTIVITY_DELTA"
852
- /* ACTIVITY_DELTA */
853
- ),
854
- messageId: import_zod2.z.string(),
855
- activityType: import_zod2.z.string(),
856
- patch: import_zod2.z.array(import_zod2.z.any())
857
- });
858
- var RawEventSchema = BaseEventSchema.extend({
859
- type: import_zod2.z.literal(
860
- "RAW"
861
- /* RAW */
862
- ),
863
- event: import_zod2.z.any(),
864
- source: import_zod2.z.string().optional()
865
- });
866
- var CustomEventSchema = BaseEventSchema.extend({
867
- type: import_zod2.z.literal(
868
- "CUSTOM"
869
- /* CUSTOM */
870
- ),
871
- name: import_zod2.z.string(),
872
- value: import_zod2.z.any()
873
- });
874
- var RunStartedEventSchema = BaseEventSchema.extend({
875
- type: import_zod2.z.literal(
876
- "RUN_STARTED"
877
- /* RUN_STARTED */
878
- ),
879
- threadId: import_zod2.z.string(),
880
- runId: import_zod2.z.string(),
881
- parentRunId: import_zod2.z.string().optional(),
882
- input: RunAgentInputSchema.optional()
883
- });
884
- var RunFinishedEventSchema = BaseEventSchema.extend({
885
- type: import_zod2.z.literal(
886
- "RUN_FINISHED"
887
- /* RUN_FINISHED */
888
- ),
889
- threadId: import_zod2.z.string(),
890
- runId: import_zod2.z.string(),
891
- result: import_zod2.z.any().optional()
892
- });
893
- var RunErrorEventSchema = BaseEventSchema.extend({
894
- type: import_zod2.z.literal(
895
- "RUN_ERROR"
896
- /* RUN_ERROR */
897
- ),
898
- message: import_zod2.z.string(),
899
- code: import_zod2.z.string().optional()
900
- });
901
- var StepStartedEventSchema = BaseEventSchema.extend({
902
- type: import_zod2.z.literal(
903
- "STEP_STARTED"
904
- /* STEP_STARTED */
905
- ),
906
- stepName: import_zod2.z.string()
907
- });
908
- var StepFinishedEventSchema = BaseEventSchema.extend({
909
- type: import_zod2.z.literal(
910
- "STEP_FINISHED"
911
- /* STEP_FINISHED */
912
- ),
913
- stepName: import_zod2.z.string()
914
- });
915
- var EventSchemas = import_zod2.z.discriminatedUnion("type", [
916
- TextMessageStartEventSchema,
917
- TextMessageContentEventSchema,
918
- TextMessageEndEventSchema,
919
- TextMessageChunkEventSchema,
920
- ThinkingStartEventSchema,
921
- ThinkingEndEventSchema,
922
- ThinkingTextMessageStartEventSchema,
923
- ThinkingTextMessageContentEventSchema,
924
- ThinkingTextMessageEndEventSchema,
925
- ToolCallStartEventSchema,
926
- ToolCallArgsEventSchema,
927
- ToolCallEndEventSchema,
928
- ToolCallChunkEventSchema,
929
- ToolCallResultEventSchema,
930
- StateSnapshotEventSchema,
931
- StateDeltaEventSchema,
932
- MessagesSnapshotEventSchema,
933
- ActivitySnapshotEventSchema,
934
- ActivityDeltaEventSchema,
935
- RawEventSchema,
936
- CustomEventSchema,
937
- RunStartedEventSchema,
938
- RunFinishedEventSchema,
939
- RunErrorEventSchema,
940
- StepStartedEventSchema,
941
- StepFinishedEventSchema
942
- ]);
505
+ // src/hooks/use-copilot-chat_internal.ts
506
+ var import_client = require("@ag-ui/client");
943
507
 
944
508
  // src/hooks/use-coagent-state-render-bridge.tsx
945
- var import_react13 = require("@copilotkitnext/react");
946
- var import_react14 = require("react");
509
+ var import_react11 = require("@copilotkitnext/react");
510
+ var import_react12 = require("react");
947
511
  var import_shared3 = require("@copilotkit/shared");
948
512
  function getStateWithoutConstantKeys(state) {
949
513
  if (!state)
@@ -970,11 +534,11 @@ function useCoagentStateRenderBridge(agentId, props) {
970
534
  var _a;
971
535
  const { stateSnapshot, messageIndexInRun, message } = props;
972
536
  const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
973
- const { agent } = (0, import_react13.useAgent)({ agentId });
974
- const [nodeName, setNodeName] = (0, import_react14.useState)(void 0);
537
+ const { agent } = (0, import_react11.useAgent)({ agentId });
538
+ const [nodeName, setNodeName] = (0, import_react12.useState)(void 0);
975
539
  const runId = (_a = props.runId) != null ? _a : message.runId;
976
540
  const effectiveRunId = runId || "pending";
977
- (0, import_react14.useEffect)(() => {
541
+ (0, import_react12.useEffect)(() => {
978
542
  if (!agent)
979
543
  return;
980
544
  const subscriber = {
@@ -994,7 +558,7 @@ function useCoagentStateRenderBridge(agentId, props) {
994
558
  unsubscribe();
995
559
  };
996
560
  }, [agentId, nodeName]);
997
- const getStateRender = (0, import_react14.useCallback)(
561
+ const getStateRender = (0, import_react12.useCallback)(
998
562
  (messageId) => {
999
563
  return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
1000
564
  if (claimsRef.current[messageId]) {
@@ -1036,7 +600,7 @@ function useCoagentStateRenderBridge(agentId, props) {
1036
600
  claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
1037
601
  return true;
1038
602
  };
1039
- return (0, import_react14.useMemo)(() => {
603
+ return (0, import_react12.useMemo)(() => {
1040
604
  var _a2, _b, _c;
1041
605
  if (messageIndexInRun !== 0) {
1042
606
  return null;
@@ -1096,42 +660,24 @@ function CoAgentStateRenderBridge(props) {
1096
660
  }
1097
661
 
1098
662
  // src/hooks/use-copilot-chat_internal.ts
1099
- function useConfigureSuggestions2(suggestions) {
1100
- let suggestionsConfig;
1101
- if (Array.isArray(suggestions)) {
1102
- suggestionsConfig = {
1103
- suggestions,
1104
- available: "always"
1105
- };
1106
- } else if (suggestions === "auto") {
1107
- suggestionsConfig = {
1108
- available: suggestions === "auto" ? "always" : "disabled",
1109
- instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls."
1110
- };
1111
- } else {
1112
- suggestionsConfig = { available: "disabled" };
1113
- }
1114
- useConfigureChatSuggestions(suggestionsConfig);
1115
- }
1116
663
  function useCopilotChatInternal({
1117
664
  suggestions
1118
665
  } = {}) {
1119
666
  var _a, _b, _c;
1120
- const { copilotkit } = (0, import_react16.useCopilotKit)();
667
+ const { copilotkit } = (0, import_react14.useCopilotKit)();
1121
668
  const { threadId, agentSession } = useCopilotContext();
1122
- const existingConfig = (0, import_react16.useCopilotChatConfiguration)();
1123
- const [agentAvailable, setAgentAvailable] = (0, import_react15.useState)(false);
1124
- useConfigureSuggestions2(suggestions);
669
+ const existingConfig = (0, import_react14.useCopilotChatConfiguration)();
670
+ const [agentAvailable, setAgentAvailable] = (0, import_react13.useState)(false);
1125
671
  const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
1126
- const { agent } = (0, import_react16.useAgent)({ agentId: resolvedAgentId });
1127
- (0, import_react15.useEffect)(() => {
672
+ const { agent } = (0, import_react14.useAgent)({ agentId: resolvedAgentId });
673
+ (0, import_react13.useEffect)(() => {
1128
674
  const connect = (agent2) => __async(this, null, function* () {
1129
675
  setAgentAvailable(false);
1130
676
  try {
1131
677
  yield copilotkit.connectAgent({ agent: agent2 });
1132
678
  setAgentAvailable(true);
1133
679
  } catch (error) {
1134
- if (error instanceof AGUIConnectNotImplementedError) {
680
+ if (error instanceof import_client.AGUIConnectNotImplementedError) {
1135
681
  } else {
1136
682
  throw error;
1137
683
  }
@@ -1149,7 +695,7 @@ function useCopilotChatInternal({
1149
695
  agent == null ? void 0 : agent.setMessages([]);
1150
696
  agent == null ? void 0 : agent.setState(null);
1151
697
  };
1152
- const deleteMessage = (0, import_react15.useCallback)(
698
+ const deleteMessage = (0, import_react13.useCallback)(
1153
699
  (messageId) => {
1154
700
  var _a2;
1155
701
  const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
@@ -1160,13 +706,13 @@ function useCopilotChatInternal({
1160
706
  [agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
1161
707
  );
1162
708
  const latestDelete = useUpdatedRef(deleteMessage);
1163
- const latestDeleteFunc = (0, import_react15.useCallback)(
709
+ const latestDeleteFunc = (0, import_react13.useCallback)(
1164
710
  (messageId) => {
1165
711
  return latestDelete.current(messageId);
1166
712
  },
1167
713
  [latestDelete]
1168
714
  );
1169
- const currentSuggestions = (0, import_react16.useSuggestions)({ agentId: resolvedAgentId });
715
+ const currentSuggestions = (0, import_react14.useSuggestions)({ agentId: resolvedAgentId });
1170
716
  const reload = useAsyncCallback(
1171
717
  (reloadMessageId) => __async(this, null, function* () {
1172
718
  var _a2;
@@ -1233,7 +779,7 @@ function useCopilotChatInternal({
1233
779
  }),
1234
780
  [latestSendMessageFunc]
1235
781
  );
1236
- const latestSetMessagesFunc = (0, import_react15.useCallback)(
782
+ const latestSetMessagesFunc = (0, import_react13.useCallback)(
1237
783
  (messages) => {
1238
784
  var _a2, _b2;
1239
785
  if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
@@ -1250,16 +796,16 @@ function useCopilotChatInternal({
1250
796
  }),
1251
797
  [latestReload]
1252
798
  );
1253
- const latestStopFunc = (0, import_react15.useCallback)(() => {
799
+ const latestStopFunc = (0, import_react13.useCallback)(() => {
1254
800
  var _a2;
1255
801
  return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
1256
802
  }, [agent == null ? void 0 : agent.abortRun]);
1257
803
  const latestReset = useUpdatedRef(reset);
1258
- const latestResetFunc = (0, import_react15.useCallback)(() => {
804
+ const latestResetFunc = (0, import_react13.useCallback)(() => {
1259
805
  return latestReset.current();
1260
806
  }, [latestReset]);
1261
807
  const lazyToolRendered = useLazyToolRenderer();
1262
- const renderCustomMessage = (0, import_react16.useRenderCustomMessages)();
808
+ const renderCustomMessage = (0, import_react14.useRenderCustomMessages)();
1263
809
  const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
1264
810
  copilotkit,
1265
811
  agent,
@@ -1267,7 +813,7 @@ function useCopilotChatInternal({
1267
813
  threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
1268
814
  });
1269
815
  const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
1270
- const resolvedMessages = (0, import_react15.useMemo)(() => {
816
+ const resolvedMessages = (0, import_react13.useMemo)(() => {
1271
817
  let processedMessages = allMessages.map((message) => {
1272
818
  if (message.role !== "assistant") {
1273
819
  return message;
@@ -1304,6 +850,15 @@ function useCopilotChatInternal({
1304
850
  // legacyCustomMessageRenderer,
1305
851
  resolvedAgentId
1306
852
  ]);
853
+ const renderedSuggestions = (0, import_react13.useMemo)(() => {
854
+ if (Array.isArray(suggestions)) {
855
+ return {
856
+ suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
857
+ isLoading: false
858
+ };
859
+ }
860
+ return currentSuggestions;
861
+ }, [suggestions, currentSuggestions]);
1307
862
  return {
1308
863
  messages: resolvedMessages,
1309
864
  sendMessage: latestSendMessageFunc,
@@ -1317,21 +872,21 @@ function useCopilotChatInternal({
1317
872
  isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
1318
873
  // mcpServers,
1319
874
  // setMcpServers,
1320
- suggestions: currentSuggestions.suggestions,
875
+ suggestions: renderedSuggestions.suggestions,
1321
876
  setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
1322
877
  generateSuggestions: () => __async(this, null, function* () {
1323
878
  return copilotkit.reloadSuggestions(resolvedAgentId);
1324
879
  }),
1325
880
  resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
1326
- isLoadingSuggestions: currentSuggestions.isLoading,
881
+ isLoadingSuggestions: renderedSuggestions.isLoading,
1327
882
  interrupt,
1328
883
  agent,
1329
884
  threadId
1330
885
  };
1331
886
  }
1332
887
  function useUpdatedRef(value) {
1333
- const ref = (0, import_react15.useRef)(value);
1334
- (0, import_react15.useEffect)(() => {
888
+ const ref = (0, import_react13.useRef)(value);
889
+ (0, import_react13.useEffect)(() => {
1335
890
  ref.current = value;
1336
891
  }, [value]);
1337
892
  return ref;
@@ -1342,7 +897,7 @@ function useLegacyCoagentRenderer({
1342
897
  agentId,
1343
898
  threadId
1344
899
  }) {
1345
- return (0, import_react15.useMemo)(() => {
900
+ return (0, import_react13.useMemo)(() => {
1346
901
  if (!copilotkit || !agent) {
1347
902
  return null;
1348
903
  }
@@ -1365,7 +920,7 @@ function useLegacyCoagentRenderer({
1365
920
  agentId,
1366
921
  stateSnapshot: message.state
1367
922
  };
1368
- return (0, import_react15.createElement)(CoAgentStateRenderBridge, bridgeProps);
923
+ return (0, import_react13.createElement)(CoAgentStateRenderBridge, bridgeProps);
1369
924
  };
1370
925
  }, [agent, agentId, copilotkit, threadId]);
1371
926
  }
@@ -1437,7 +992,7 @@ function useCopilotChatHeadless_c(options = {}) {
1437
992
  const { copilotApiConfig, setBannerError } = useCopilotContext();
1438
993
  const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
1439
994
  const internalResult = useCopilotChatInternal(options);
1440
- (0, import_react17.useEffect)(() => {
995
+ (0, import_react15.useEffect)(() => {
1441
996
  if (!hasPublicApiKey) {
1442
997
  setBannerError(
1443
998
  new import_shared4.CopilotKitError({