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