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