@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
package/dist/hooks/index.js
CHANGED
|
@@ -81,13 +81,13 @@ var hooks_exports = {};
|
|
|
81
81
|
__export(hooks_exports, {
|
|
82
82
|
useCoAgent: () => useCoAgent,
|
|
83
83
|
useCoAgentStateRender: () => useCoAgentStateRender,
|
|
84
|
-
useConfigureChatSuggestions: () => useConfigureChatSuggestions,
|
|
85
84
|
useCopilotAction: () => useCopilotAction,
|
|
86
85
|
useCopilotAdditionalInstructions: () => useCopilotAdditionalInstructions,
|
|
87
86
|
useCopilotAuthenticatedAction_c: () => useCopilotAuthenticatedAction_c,
|
|
88
87
|
useCopilotChat: () => useCopilotChat,
|
|
89
88
|
useCopilotChatHeadless_c: () => useCopilotChatHeadless_c,
|
|
90
89
|
useCopilotChatInternal: () => useCopilotChatInternal,
|
|
90
|
+
useCopilotChatSuggestions: () => useCopilotChatSuggestions,
|
|
91
91
|
useCopilotReadable: () => useCopilotReadable,
|
|
92
92
|
useCopilotRuntimeClient: () => useCopilotRuntimeClient,
|
|
93
93
|
useDefaultTool: () => useDefaultTool,
|
|
@@ -102,7 +102,7 @@ __export(hooks_exports, {
|
|
|
102
102
|
module.exports = __toCommonJS(hooks_exports);
|
|
103
103
|
|
|
104
104
|
// src/hooks/use-copilot-chat_internal.ts
|
|
105
|
-
var
|
|
105
|
+
var import_react13 = require("react");
|
|
106
106
|
|
|
107
107
|
// src/context/copilot-context.tsx
|
|
108
108
|
var import_react = __toESM(require("react"));
|
|
@@ -491,7 +491,7 @@ function useLangGraphInterruptRender(agent) {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
// src/hooks/use-copilot-chat_internal.ts
|
|
494
|
-
var
|
|
494
|
+
var import_react14 = require("@copilotkitnext/react");
|
|
495
495
|
|
|
496
496
|
// src/hooks/use-lazy-tool-renderer.tsx
|
|
497
497
|
var import_react9 = require("@copilotkitnext/react");
|
|
@@ -518,448 +518,12 @@ function useLazyToolRenderer() {
|
|
|
518
518
|
);
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
-
// src/hooks/use-
|
|
522
|
-
var
|
|
523
|
-
var import_react12 = require("react");
|
|
524
|
-
function useConfigureChatSuggestions(config, dependencies = []) {
|
|
525
|
-
var _a;
|
|
526
|
-
const existingConfig = (0, import_react11.useCopilotChatConfiguration)();
|
|
527
|
-
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
528
|
-
const { copilotkit } = (0, import_react11.useCopilotKit)();
|
|
529
|
-
const available = config.available === "enabled" ? "always" : config.available;
|
|
530
|
-
const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
|
|
531
|
-
available,
|
|
532
|
-
consumerAgentId: resolvedAgentId
|
|
533
|
-
// Use chatConfig.agentId here
|
|
534
|
-
});
|
|
535
|
-
(0, import_react11.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
|
|
536
|
-
const result = (0, import_react11.useSuggestions)({ agentId: resolvedAgentId });
|
|
537
|
-
(0, import_react12.useEffect)(() => {
|
|
538
|
-
if (finalSuggestionConfig.available === "disabled")
|
|
539
|
-
return;
|
|
540
|
-
const subscription = copilotkit.subscribe({
|
|
541
|
-
onAgentsChanged: () => {
|
|
542
|
-
const agent = copilotkit.getAgent(resolvedAgentId);
|
|
543
|
-
if (agent && !agent.isRunning && !result.suggestions.length) {
|
|
544
|
-
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
return () => {
|
|
549
|
-
subscription.unsubscribe();
|
|
550
|
-
};
|
|
551
|
-
}, [resolvedAgentId]);
|
|
552
|
-
return result;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// ../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/dist/index.mjs
|
|
556
|
-
var import_zod = require("zod");
|
|
557
|
-
var import_zod2 = require("zod");
|
|
558
|
-
var FunctionCallSchema = import_zod.z.object({
|
|
559
|
-
name: import_zod.z.string(),
|
|
560
|
-
arguments: import_zod.z.string()
|
|
561
|
-
});
|
|
562
|
-
var ToolCallSchema = import_zod.z.object({
|
|
563
|
-
id: import_zod.z.string(),
|
|
564
|
-
type: import_zod.z.literal("function"),
|
|
565
|
-
function: FunctionCallSchema
|
|
566
|
-
});
|
|
567
|
-
var BaseMessageSchema = import_zod.z.object({
|
|
568
|
-
id: import_zod.z.string(),
|
|
569
|
-
role: import_zod.z.string(),
|
|
570
|
-
content: import_zod.z.string().optional(),
|
|
571
|
-
name: import_zod.z.string().optional()
|
|
572
|
-
});
|
|
573
|
-
var TextInputContentSchema = import_zod.z.object({
|
|
574
|
-
type: import_zod.z.literal("text"),
|
|
575
|
-
text: import_zod.z.string()
|
|
576
|
-
});
|
|
577
|
-
var BinaryInputContentObjectSchema = import_zod.z.object({
|
|
578
|
-
type: import_zod.z.literal("binary"),
|
|
579
|
-
mimeType: import_zod.z.string(),
|
|
580
|
-
id: import_zod.z.string().optional(),
|
|
581
|
-
url: import_zod.z.string().optional(),
|
|
582
|
-
data: import_zod.z.string().optional(),
|
|
583
|
-
filename: import_zod.z.string().optional()
|
|
584
|
-
});
|
|
585
|
-
var ensureBinaryPayload = (value, ctx) => {
|
|
586
|
-
if (!value.id && !value.url && !value.data) {
|
|
587
|
-
ctx.addIssue({
|
|
588
|
-
code: import_zod.z.ZodIssueCode.custom,
|
|
589
|
-
message: "BinaryInputContent requires at least one of id, url, or data.",
|
|
590
|
-
path: ["id"]
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
var BinaryInputContentSchema = BinaryInputContentObjectSchema.superRefine((value, ctx) => {
|
|
595
|
-
ensureBinaryPayload(value, ctx);
|
|
596
|
-
});
|
|
597
|
-
var InputContentBaseSchema = import_zod.z.discriminatedUnion("type", [
|
|
598
|
-
TextInputContentSchema,
|
|
599
|
-
BinaryInputContentObjectSchema
|
|
600
|
-
]);
|
|
601
|
-
var InputContentSchema = InputContentBaseSchema.superRefine((value, ctx) => {
|
|
602
|
-
if (value.type === "binary") {
|
|
603
|
-
ensureBinaryPayload(value, ctx);
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
var DeveloperMessageSchema = BaseMessageSchema.extend({
|
|
607
|
-
role: import_zod.z.literal("developer"),
|
|
608
|
-
content: import_zod.z.string()
|
|
609
|
-
});
|
|
610
|
-
var SystemMessageSchema = BaseMessageSchema.extend({
|
|
611
|
-
role: import_zod.z.literal("system"),
|
|
612
|
-
content: import_zod.z.string()
|
|
613
|
-
});
|
|
614
|
-
var AssistantMessageSchema = BaseMessageSchema.extend({
|
|
615
|
-
role: import_zod.z.literal("assistant"),
|
|
616
|
-
content: import_zod.z.string().optional(),
|
|
617
|
-
toolCalls: import_zod.z.array(ToolCallSchema).optional()
|
|
618
|
-
});
|
|
619
|
-
var UserMessageSchema = BaseMessageSchema.extend({
|
|
620
|
-
role: import_zod.z.literal("user"),
|
|
621
|
-
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(InputContentSchema)])
|
|
622
|
-
});
|
|
623
|
-
var ToolMessageSchema = import_zod.z.object({
|
|
624
|
-
id: import_zod.z.string(),
|
|
625
|
-
content: import_zod.z.string(),
|
|
626
|
-
role: import_zod.z.literal("tool"),
|
|
627
|
-
toolCallId: import_zod.z.string(),
|
|
628
|
-
error: import_zod.z.string().optional()
|
|
629
|
-
});
|
|
630
|
-
var ActivityMessageSchema = import_zod.z.object({
|
|
631
|
-
id: import_zod.z.string(),
|
|
632
|
-
role: import_zod.z.literal("activity"),
|
|
633
|
-
activityType: import_zod.z.string(),
|
|
634
|
-
content: import_zod.z.record(import_zod.z.any())
|
|
635
|
-
});
|
|
636
|
-
var MessageSchema = import_zod.z.discriminatedUnion("role", [
|
|
637
|
-
DeveloperMessageSchema,
|
|
638
|
-
SystemMessageSchema,
|
|
639
|
-
AssistantMessageSchema,
|
|
640
|
-
UserMessageSchema,
|
|
641
|
-
ToolMessageSchema,
|
|
642
|
-
ActivityMessageSchema
|
|
643
|
-
]);
|
|
644
|
-
var RoleSchema = import_zod.z.union([
|
|
645
|
-
import_zod.z.literal("developer"),
|
|
646
|
-
import_zod.z.literal("system"),
|
|
647
|
-
import_zod.z.literal("assistant"),
|
|
648
|
-
import_zod.z.literal("user"),
|
|
649
|
-
import_zod.z.literal("tool"),
|
|
650
|
-
import_zod.z.literal("activity")
|
|
651
|
-
]);
|
|
652
|
-
var ContextSchema = import_zod.z.object({
|
|
653
|
-
description: import_zod.z.string(),
|
|
654
|
-
value: import_zod.z.string()
|
|
655
|
-
});
|
|
656
|
-
var ToolSchema = import_zod.z.object({
|
|
657
|
-
name: import_zod.z.string(),
|
|
658
|
-
description: import_zod.z.string(),
|
|
659
|
-
parameters: import_zod.z.any()
|
|
660
|
-
// JSON Schema for the tool parameters
|
|
661
|
-
});
|
|
662
|
-
var RunAgentInputSchema = import_zod.z.object({
|
|
663
|
-
threadId: import_zod.z.string(),
|
|
664
|
-
runId: import_zod.z.string(),
|
|
665
|
-
parentRunId: import_zod.z.string().optional(),
|
|
666
|
-
state: import_zod.z.any(),
|
|
667
|
-
messages: import_zod.z.array(MessageSchema),
|
|
668
|
-
tools: import_zod.z.array(ToolSchema),
|
|
669
|
-
context: import_zod.z.array(ContextSchema),
|
|
670
|
-
forwardedProps: import_zod.z.any()
|
|
671
|
-
});
|
|
672
|
-
var StateSchema = import_zod.z.any();
|
|
673
|
-
var AGUIError = class extends Error {
|
|
674
|
-
constructor(message) {
|
|
675
|
-
super(message);
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
var AGUIConnectNotImplementedError = class extends AGUIError {
|
|
679
|
-
constructor() {
|
|
680
|
-
super("Connect not implemented. This method is not supported by the current agent.");
|
|
681
|
-
}
|
|
682
|
-
};
|
|
683
|
-
var TextMessageRoleSchema = import_zod2.z.union([
|
|
684
|
-
import_zod2.z.literal("developer"),
|
|
685
|
-
import_zod2.z.literal("system"),
|
|
686
|
-
import_zod2.z.literal("assistant"),
|
|
687
|
-
import_zod2.z.literal("user")
|
|
688
|
-
]);
|
|
689
|
-
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
690
|
-
EventType2["TEXT_MESSAGE_START"] = "TEXT_MESSAGE_START";
|
|
691
|
-
EventType2["TEXT_MESSAGE_CONTENT"] = "TEXT_MESSAGE_CONTENT";
|
|
692
|
-
EventType2["TEXT_MESSAGE_END"] = "TEXT_MESSAGE_END";
|
|
693
|
-
EventType2["TEXT_MESSAGE_CHUNK"] = "TEXT_MESSAGE_CHUNK";
|
|
694
|
-
EventType2["THINKING_TEXT_MESSAGE_START"] = "THINKING_TEXT_MESSAGE_START";
|
|
695
|
-
EventType2["THINKING_TEXT_MESSAGE_CONTENT"] = "THINKING_TEXT_MESSAGE_CONTENT";
|
|
696
|
-
EventType2["THINKING_TEXT_MESSAGE_END"] = "THINKING_TEXT_MESSAGE_END";
|
|
697
|
-
EventType2["TOOL_CALL_START"] = "TOOL_CALL_START";
|
|
698
|
-
EventType2["TOOL_CALL_ARGS"] = "TOOL_CALL_ARGS";
|
|
699
|
-
EventType2["TOOL_CALL_END"] = "TOOL_CALL_END";
|
|
700
|
-
EventType2["TOOL_CALL_CHUNK"] = "TOOL_CALL_CHUNK";
|
|
701
|
-
EventType2["TOOL_CALL_RESULT"] = "TOOL_CALL_RESULT";
|
|
702
|
-
EventType2["THINKING_START"] = "THINKING_START";
|
|
703
|
-
EventType2["THINKING_END"] = "THINKING_END";
|
|
704
|
-
EventType2["STATE_SNAPSHOT"] = "STATE_SNAPSHOT";
|
|
705
|
-
EventType2["STATE_DELTA"] = "STATE_DELTA";
|
|
706
|
-
EventType2["MESSAGES_SNAPSHOT"] = "MESSAGES_SNAPSHOT";
|
|
707
|
-
EventType2["ACTIVITY_SNAPSHOT"] = "ACTIVITY_SNAPSHOT";
|
|
708
|
-
EventType2["ACTIVITY_DELTA"] = "ACTIVITY_DELTA";
|
|
709
|
-
EventType2["RAW"] = "RAW";
|
|
710
|
-
EventType2["CUSTOM"] = "CUSTOM";
|
|
711
|
-
EventType2["RUN_STARTED"] = "RUN_STARTED";
|
|
712
|
-
EventType2["RUN_FINISHED"] = "RUN_FINISHED";
|
|
713
|
-
EventType2["RUN_ERROR"] = "RUN_ERROR";
|
|
714
|
-
EventType2["STEP_STARTED"] = "STEP_STARTED";
|
|
715
|
-
EventType2["STEP_FINISHED"] = "STEP_FINISHED";
|
|
716
|
-
return EventType2;
|
|
717
|
-
})(EventType || {});
|
|
718
|
-
var BaseEventSchema = import_zod2.z.object({
|
|
719
|
-
type: import_zod2.z.nativeEnum(EventType),
|
|
720
|
-
timestamp: import_zod2.z.number().optional(),
|
|
721
|
-
rawEvent: import_zod2.z.any().optional()
|
|
722
|
-
});
|
|
723
|
-
var TextMessageStartEventSchema = BaseEventSchema.extend({
|
|
724
|
-
type: import_zod2.z.literal(
|
|
725
|
-
"TEXT_MESSAGE_START"
|
|
726
|
-
/* TEXT_MESSAGE_START */
|
|
727
|
-
),
|
|
728
|
-
messageId: import_zod2.z.string(),
|
|
729
|
-
role: TextMessageRoleSchema.default("assistant")
|
|
730
|
-
});
|
|
731
|
-
var TextMessageContentEventSchema = BaseEventSchema.extend({
|
|
732
|
-
type: import_zod2.z.literal(
|
|
733
|
-
"TEXT_MESSAGE_CONTENT"
|
|
734
|
-
/* TEXT_MESSAGE_CONTENT */
|
|
735
|
-
),
|
|
736
|
-
messageId: import_zod2.z.string(),
|
|
737
|
-
delta: import_zod2.z.string().refine((s) => s.length > 0, "Delta must not be an empty string")
|
|
738
|
-
});
|
|
739
|
-
var TextMessageEndEventSchema = BaseEventSchema.extend({
|
|
740
|
-
type: import_zod2.z.literal(
|
|
741
|
-
"TEXT_MESSAGE_END"
|
|
742
|
-
/* TEXT_MESSAGE_END */
|
|
743
|
-
),
|
|
744
|
-
messageId: import_zod2.z.string()
|
|
745
|
-
});
|
|
746
|
-
var TextMessageChunkEventSchema = BaseEventSchema.extend({
|
|
747
|
-
type: import_zod2.z.literal(
|
|
748
|
-
"TEXT_MESSAGE_CHUNK"
|
|
749
|
-
/* TEXT_MESSAGE_CHUNK */
|
|
750
|
-
),
|
|
751
|
-
messageId: import_zod2.z.string().optional(),
|
|
752
|
-
role: TextMessageRoleSchema.optional(),
|
|
753
|
-
delta: import_zod2.z.string().optional()
|
|
754
|
-
});
|
|
755
|
-
var ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({
|
|
756
|
-
type: import_zod2.z.literal(
|
|
757
|
-
"THINKING_TEXT_MESSAGE_START"
|
|
758
|
-
/* THINKING_TEXT_MESSAGE_START */
|
|
759
|
-
)
|
|
760
|
-
});
|
|
761
|
-
var ThinkingTextMessageContentEventSchema = TextMessageContentEventSchema.omit({
|
|
762
|
-
messageId: true,
|
|
763
|
-
type: true
|
|
764
|
-
}).extend({
|
|
765
|
-
type: import_zod2.z.literal(
|
|
766
|
-
"THINKING_TEXT_MESSAGE_CONTENT"
|
|
767
|
-
/* THINKING_TEXT_MESSAGE_CONTENT */
|
|
768
|
-
)
|
|
769
|
-
});
|
|
770
|
-
var ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({
|
|
771
|
-
type: import_zod2.z.literal(
|
|
772
|
-
"THINKING_TEXT_MESSAGE_END"
|
|
773
|
-
/* THINKING_TEXT_MESSAGE_END */
|
|
774
|
-
)
|
|
775
|
-
});
|
|
776
|
-
var ToolCallStartEventSchema = BaseEventSchema.extend({
|
|
777
|
-
type: import_zod2.z.literal(
|
|
778
|
-
"TOOL_CALL_START"
|
|
779
|
-
/* TOOL_CALL_START */
|
|
780
|
-
),
|
|
781
|
-
toolCallId: import_zod2.z.string(),
|
|
782
|
-
toolCallName: import_zod2.z.string(),
|
|
783
|
-
parentMessageId: import_zod2.z.string().optional()
|
|
784
|
-
});
|
|
785
|
-
var ToolCallArgsEventSchema = BaseEventSchema.extend({
|
|
786
|
-
type: import_zod2.z.literal(
|
|
787
|
-
"TOOL_CALL_ARGS"
|
|
788
|
-
/* TOOL_CALL_ARGS */
|
|
789
|
-
),
|
|
790
|
-
toolCallId: import_zod2.z.string(),
|
|
791
|
-
delta: import_zod2.z.string()
|
|
792
|
-
});
|
|
793
|
-
var ToolCallEndEventSchema = BaseEventSchema.extend({
|
|
794
|
-
type: import_zod2.z.literal(
|
|
795
|
-
"TOOL_CALL_END"
|
|
796
|
-
/* TOOL_CALL_END */
|
|
797
|
-
),
|
|
798
|
-
toolCallId: import_zod2.z.string()
|
|
799
|
-
});
|
|
800
|
-
var ToolCallResultEventSchema = BaseEventSchema.extend({
|
|
801
|
-
messageId: import_zod2.z.string(),
|
|
802
|
-
type: import_zod2.z.literal(
|
|
803
|
-
"TOOL_CALL_RESULT"
|
|
804
|
-
/* TOOL_CALL_RESULT */
|
|
805
|
-
),
|
|
806
|
-
toolCallId: import_zod2.z.string(),
|
|
807
|
-
content: import_zod2.z.string(),
|
|
808
|
-
role: import_zod2.z.literal("tool").optional()
|
|
809
|
-
});
|
|
810
|
-
var ToolCallChunkEventSchema = BaseEventSchema.extend({
|
|
811
|
-
type: import_zod2.z.literal(
|
|
812
|
-
"TOOL_CALL_CHUNK"
|
|
813
|
-
/* TOOL_CALL_CHUNK */
|
|
814
|
-
),
|
|
815
|
-
toolCallId: import_zod2.z.string().optional(),
|
|
816
|
-
toolCallName: import_zod2.z.string().optional(),
|
|
817
|
-
parentMessageId: import_zod2.z.string().optional(),
|
|
818
|
-
delta: import_zod2.z.string().optional()
|
|
819
|
-
});
|
|
820
|
-
var ThinkingStartEventSchema = BaseEventSchema.extend({
|
|
821
|
-
type: import_zod2.z.literal(
|
|
822
|
-
"THINKING_START"
|
|
823
|
-
/* THINKING_START */
|
|
824
|
-
),
|
|
825
|
-
title: import_zod2.z.string().optional()
|
|
826
|
-
});
|
|
827
|
-
var ThinkingEndEventSchema = BaseEventSchema.extend({
|
|
828
|
-
type: import_zod2.z.literal(
|
|
829
|
-
"THINKING_END"
|
|
830
|
-
/* THINKING_END */
|
|
831
|
-
)
|
|
832
|
-
});
|
|
833
|
-
var StateSnapshotEventSchema = BaseEventSchema.extend({
|
|
834
|
-
type: import_zod2.z.literal(
|
|
835
|
-
"STATE_SNAPSHOT"
|
|
836
|
-
/* STATE_SNAPSHOT */
|
|
837
|
-
),
|
|
838
|
-
snapshot: StateSchema
|
|
839
|
-
});
|
|
840
|
-
var StateDeltaEventSchema = BaseEventSchema.extend({
|
|
841
|
-
type: import_zod2.z.literal(
|
|
842
|
-
"STATE_DELTA"
|
|
843
|
-
/* STATE_DELTA */
|
|
844
|
-
),
|
|
845
|
-
delta: import_zod2.z.array(import_zod2.z.any())
|
|
846
|
-
// JSON Patch (RFC 6902)
|
|
847
|
-
});
|
|
848
|
-
var MessagesSnapshotEventSchema = BaseEventSchema.extend({
|
|
849
|
-
type: import_zod2.z.literal(
|
|
850
|
-
"MESSAGES_SNAPSHOT"
|
|
851
|
-
/* MESSAGES_SNAPSHOT */
|
|
852
|
-
),
|
|
853
|
-
messages: import_zod2.z.array(MessageSchema)
|
|
854
|
-
});
|
|
855
|
-
var ActivitySnapshotEventSchema = BaseEventSchema.extend({
|
|
856
|
-
type: import_zod2.z.literal(
|
|
857
|
-
"ACTIVITY_SNAPSHOT"
|
|
858
|
-
/* ACTIVITY_SNAPSHOT */
|
|
859
|
-
),
|
|
860
|
-
messageId: import_zod2.z.string(),
|
|
861
|
-
activityType: import_zod2.z.string(),
|
|
862
|
-
content: import_zod2.z.record(import_zod2.z.any()),
|
|
863
|
-
replace: import_zod2.z.boolean().optional().default(true)
|
|
864
|
-
});
|
|
865
|
-
var ActivityDeltaEventSchema = BaseEventSchema.extend({
|
|
866
|
-
type: import_zod2.z.literal(
|
|
867
|
-
"ACTIVITY_DELTA"
|
|
868
|
-
/* ACTIVITY_DELTA */
|
|
869
|
-
),
|
|
870
|
-
messageId: import_zod2.z.string(),
|
|
871
|
-
activityType: import_zod2.z.string(),
|
|
872
|
-
patch: import_zod2.z.array(import_zod2.z.any())
|
|
873
|
-
});
|
|
874
|
-
var RawEventSchema = BaseEventSchema.extend({
|
|
875
|
-
type: import_zod2.z.literal(
|
|
876
|
-
"RAW"
|
|
877
|
-
/* RAW */
|
|
878
|
-
),
|
|
879
|
-
event: import_zod2.z.any(),
|
|
880
|
-
source: import_zod2.z.string().optional()
|
|
881
|
-
});
|
|
882
|
-
var CustomEventSchema = BaseEventSchema.extend({
|
|
883
|
-
type: import_zod2.z.literal(
|
|
884
|
-
"CUSTOM"
|
|
885
|
-
/* CUSTOM */
|
|
886
|
-
),
|
|
887
|
-
name: import_zod2.z.string(),
|
|
888
|
-
value: import_zod2.z.any()
|
|
889
|
-
});
|
|
890
|
-
var RunStartedEventSchema = BaseEventSchema.extend({
|
|
891
|
-
type: import_zod2.z.literal(
|
|
892
|
-
"RUN_STARTED"
|
|
893
|
-
/* RUN_STARTED */
|
|
894
|
-
),
|
|
895
|
-
threadId: import_zod2.z.string(),
|
|
896
|
-
runId: import_zod2.z.string(),
|
|
897
|
-
parentRunId: import_zod2.z.string().optional(),
|
|
898
|
-
input: RunAgentInputSchema.optional()
|
|
899
|
-
});
|
|
900
|
-
var RunFinishedEventSchema = BaseEventSchema.extend({
|
|
901
|
-
type: import_zod2.z.literal(
|
|
902
|
-
"RUN_FINISHED"
|
|
903
|
-
/* RUN_FINISHED */
|
|
904
|
-
),
|
|
905
|
-
threadId: import_zod2.z.string(),
|
|
906
|
-
runId: import_zod2.z.string(),
|
|
907
|
-
result: import_zod2.z.any().optional()
|
|
908
|
-
});
|
|
909
|
-
var RunErrorEventSchema = BaseEventSchema.extend({
|
|
910
|
-
type: import_zod2.z.literal(
|
|
911
|
-
"RUN_ERROR"
|
|
912
|
-
/* RUN_ERROR */
|
|
913
|
-
),
|
|
914
|
-
message: import_zod2.z.string(),
|
|
915
|
-
code: import_zod2.z.string().optional()
|
|
916
|
-
});
|
|
917
|
-
var StepStartedEventSchema = BaseEventSchema.extend({
|
|
918
|
-
type: import_zod2.z.literal(
|
|
919
|
-
"STEP_STARTED"
|
|
920
|
-
/* STEP_STARTED */
|
|
921
|
-
),
|
|
922
|
-
stepName: import_zod2.z.string()
|
|
923
|
-
});
|
|
924
|
-
var StepFinishedEventSchema = BaseEventSchema.extend({
|
|
925
|
-
type: import_zod2.z.literal(
|
|
926
|
-
"STEP_FINISHED"
|
|
927
|
-
/* STEP_FINISHED */
|
|
928
|
-
),
|
|
929
|
-
stepName: import_zod2.z.string()
|
|
930
|
-
});
|
|
931
|
-
var EventSchemas = import_zod2.z.discriminatedUnion("type", [
|
|
932
|
-
TextMessageStartEventSchema,
|
|
933
|
-
TextMessageContentEventSchema,
|
|
934
|
-
TextMessageEndEventSchema,
|
|
935
|
-
TextMessageChunkEventSchema,
|
|
936
|
-
ThinkingStartEventSchema,
|
|
937
|
-
ThinkingEndEventSchema,
|
|
938
|
-
ThinkingTextMessageStartEventSchema,
|
|
939
|
-
ThinkingTextMessageContentEventSchema,
|
|
940
|
-
ThinkingTextMessageEndEventSchema,
|
|
941
|
-
ToolCallStartEventSchema,
|
|
942
|
-
ToolCallArgsEventSchema,
|
|
943
|
-
ToolCallEndEventSchema,
|
|
944
|
-
ToolCallChunkEventSchema,
|
|
945
|
-
ToolCallResultEventSchema,
|
|
946
|
-
StateSnapshotEventSchema,
|
|
947
|
-
StateDeltaEventSchema,
|
|
948
|
-
MessagesSnapshotEventSchema,
|
|
949
|
-
ActivitySnapshotEventSchema,
|
|
950
|
-
ActivityDeltaEventSchema,
|
|
951
|
-
RawEventSchema,
|
|
952
|
-
CustomEventSchema,
|
|
953
|
-
RunStartedEventSchema,
|
|
954
|
-
RunFinishedEventSchema,
|
|
955
|
-
RunErrorEventSchema,
|
|
956
|
-
StepStartedEventSchema,
|
|
957
|
-
StepFinishedEventSchema
|
|
958
|
-
]);
|
|
521
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
522
|
+
var import_client = require("@ag-ui/client");
|
|
959
523
|
|
|
960
524
|
// src/hooks/use-coagent-state-render-bridge.tsx
|
|
961
|
-
var
|
|
962
|
-
var
|
|
525
|
+
var import_react11 = require("@copilotkitnext/react");
|
|
526
|
+
var import_react12 = require("react");
|
|
963
527
|
var import_shared3 = require("@copilotkit/shared");
|
|
964
528
|
function getStateWithoutConstantKeys(state) {
|
|
965
529
|
if (!state)
|
|
@@ -986,11 +550,11 @@ function useCoagentStateRenderBridge(agentId, props) {
|
|
|
986
550
|
var _a;
|
|
987
551
|
const { stateSnapshot, messageIndexInRun, message } = props;
|
|
988
552
|
const { coAgentStateRenders, claimsRef } = useCoAgentStateRenders();
|
|
989
|
-
const { agent } = (0,
|
|
990
|
-
const [nodeName, setNodeName] = (0,
|
|
553
|
+
const { agent } = (0, import_react11.useAgent)({ agentId });
|
|
554
|
+
const [nodeName, setNodeName] = (0, import_react12.useState)(void 0);
|
|
991
555
|
const runId = (_a = props.runId) != null ? _a : message.runId;
|
|
992
556
|
const effectiveRunId = runId || "pending";
|
|
993
|
-
(0,
|
|
557
|
+
(0, import_react12.useEffect)(() => {
|
|
994
558
|
if (!agent)
|
|
995
559
|
return;
|
|
996
560
|
const subscriber = {
|
|
@@ -1010,7 +574,7 @@ function useCoagentStateRenderBridge(agentId, props) {
|
|
|
1010
574
|
unsubscribe();
|
|
1011
575
|
};
|
|
1012
576
|
}, [agentId, nodeName]);
|
|
1013
|
-
const getStateRender = (0,
|
|
577
|
+
const getStateRender = (0, import_react12.useCallback)(
|
|
1014
578
|
(messageId) => {
|
|
1015
579
|
return Object.entries(coAgentStateRenders).find(([stateRenderId, stateRender]) => {
|
|
1016
580
|
if (claimsRef.current[messageId]) {
|
|
@@ -1052,7 +616,7 @@ function useCoagentStateRenderBridge(agentId, props) {
|
|
|
1052
616
|
claimsRef.current[messageId] = { stateRenderId, runId: runId2 };
|
|
1053
617
|
return true;
|
|
1054
618
|
};
|
|
1055
|
-
return (0,
|
|
619
|
+
return (0, import_react12.useMemo)(() => {
|
|
1056
620
|
var _a2, _b, _c;
|
|
1057
621
|
if (messageIndexInRun !== 0) {
|
|
1058
622
|
return null;
|
|
@@ -1112,42 +676,24 @@ function CoAgentStateRenderBridge(props) {
|
|
|
1112
676
|
}
|
|
1113
677
|
|
|
1114
678
|
// src/hooks/use-copilot-chat_internal.ts
|
|
1115
|
-
function useConfigureSuggestions2(suggestions) {
|
|
1116
|
-
let suggestionsConfig;
|
|
1117
|
-
if (Array.isArray(suggestions)) {
|
|
1118
|
-
suggestionsConfig = {
|
|
1119
|
-
suggestions,
|
|
1120
|
-
available: "always"
|
|
1121
|
-
};
|
|
1122
|
-
} else if (suggestions === "auto") {
|
|
1123
|
-
suggestionsConfig = {
|
|
1124
|
-
available: suggestions === "auto" ? "always" : "disabled",
|
|
1125
|
-
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls."
|
|
1126
|
-
};
|
|
1127
|
-
} else {
|
|
1128
|
-
suggestionsConfig = { available: "disabled" };
|
|
1129
|
-
}
|
|
1130
|
-
useConfigureChatSuggestions(suggestionsConfig);
|
|
1131
|
-
}
|
|
1132
679
|
function useCopilotChatInternal({
|
|
1133
680
|
suggestions
|
|
1134
681
|
} = {}) {
|
|
1135
682
|
var _a, _b, _c;
|
|
1136
|
-
const { copilotkit } = (0,
|
|
683
|
+
const { copilotkit } = (0, import_react14.useCopilotKit)();
|
|
1137
684
|
const { threadId, agentSession } = useCopilotContext();
|
|
1138
|
-
const existingConfig = (0,
|
|
1139
|
-
const [agentAvailable, setAgentAvailable] = (0,
|
|
1140
|
-
useConfigureSuggestions2(suggestions);
|
|
685
|
+
const existingConfig = (0, import_react14.useCopilotChatConfiguration)();
|
|
686
|
+
const [agentAvailable, setAgentAvailable] = (0, import_react13.useState)(false);
|
|
1141
687
|
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
1142
|
-
const { agent } = (0,
|
|
1143
|
-
(0,
|
|
688
|
+
const { agent } = (0, import_react14.useAgent)({ agentId: resolvedAgentId });
|
|
689
|
+
(0, import_react13.useEffect)(() => {
|
|
1144
690
|
const connect = (agent2) => __async(this, null, function* () {
|
|
1145
691
|
setAgentAvailable(false);
|
|
1146
692
|
try {
|
|
1147
693
|
yield copilotkit.connectAgent({ agent: agent2 });
|
|
1148
694
|
setAgentAvailable(true);
|
|
1149
695
|
} catch (error) {
|
|
1150
|
-
if (error instanceof AGUIConnectNotImplementedError) {
|
|
696
|
+
if (error instanceof import_client.AGUIConnectNotImplementedError) {
|
|
1151
697
|
} else {
|
|
1152
698
|
throw error;
|
|
1153
699
|
}
|
|
@@ -1165,7 +711,7 @@ function useCopilotChatInternal({
|
|
|
1165
711
|
agent == null ? void 0 : agent.setMessages([]);
|
|
1166
712
|
agent == null ? void 0 : agent.setState(null);
|
|
1167
713
|
};
|
|
1168
|
-
const deleteMessage = (0,
|
|
714
|
+
const deleteMessage = (0, import_react13.useCallback)(
|
|
1169
715
|
(messageId) => {
|
|
1170
716
|
var _a2;
|
|
1171
717
|
const filteredMessages = ((_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []).filter(
|
|
@@ -1176,13 +722,13 @@ function useCopilotChatInternal({
|
|
|
1176
722
|
[agent == null ? void 0 : agent.setMessages, agent == null ? void 0 : agent.messages]
|
|
1177
723
|
);
|
|
1178
724
|
const latestDelete = useUpdatedRef(deleteMessage);
|
|
1179
|
-
const latestDeleteFunc = (0,
|
|
725
|
+
const latestDeleteFunc = (0, import_react13.useCallback)(
|
|
1180
726
|
(messageId) => {
|
|
1181
727
|
return latestDelete.current(messageId);
|
|
1182
728
|
},
|
|
1183
729
|
[latestDelete]
|
|
1184
730
|
);
|
|
1185
|
-
const currentSuggestions = (0,
|
|
731
|
+
const currentSuggestions = (0, import_react14.useSuggestions)({ agentId: resolvedAgentId });
|
|
1186
732
|
const reload = useAsyncCallback(
|
|
1187
733
|
(reloadMessageId) => __async(this, null, function* () {
|
|
1188
734
|
var _a2;
|
|
@@ -1249,7 +795,7 @@ function useCopilotChatInternal({
|
|
|
1249
795
|
}),
|
|
1250
796
|
[latestSendMessageFunc]
|
|
1251
797
|
);
|
|
1252
|
-
const latestSetMessagesFunc = (0,
|
|
798
|
+
const latestSetMessagesFunc = (0, import_react13.useCallback)(
|
|
1253
799
|
(messages) => {
|
|
1254
800
|
var _a2, _b2;
|
|
1255
801
|
if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
|
|
@@ -1266,16 +812,16 @@ function useCopilotChatInternal({
|
|
|
1266
812
|
}),
|
|
1267
813
|
[latestReload]
|
|
1268
814
|
);
|
|
1269
|
-
const latestStopFunc = (0,
|
|
815
|
+
const latestStopFunc = (0, import_react13.useCallback)(() => {
|
|
1270
816
|
var _a2;
|
|
1271
817
|
return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
|
|
1272
818
|
}, [agent == null ? void 0 : agent.abortRun]);
|
|
1273
819
|
const latestReset = useUpdatedRef(reset);
|
|
1274
|
-
const latestResetFunc = (0,
|
|
820
|
+
const latestResetFunc = (0, import_react13.useCallback)(() => {
|
|
1275
821
|
return latestReset.current();
|
|
1276
822
|
}, [latestReset]);
|
|
1277
823
|
const lazyToolRendered = useLazyToolRenderer();
|
|
1278
|
-
const renderCustomMessage = (0,
|
|
824
|
+
const renderCustomMessage = (0, import_react14.useRenderCustomMessages)();
|
|
1279
825
|
const legacyCustomMessageRenderer = useLegacyCoagentRenderer({
|
|
1280
826
|
copilotkit,
|
|
1281
827
|
agent,
|
|
@@ -1283,7 +829,7 @@ function useCopilotChatInternal({
|
|
|
1283
829
|
threadId: (_b = existingConfig == null ? void 0 : existingConfig.threadId) != null ? _b : threadId
|
|
1284
830
|
});
|
|
1285
831
|
const allMessages = (_c = agent == null ? void 0 : agent.messages) != null ? _c : [];
|
|
1286
|
-
const resolvedMessages = (0,
|
|
832
|
+
const resolvedMessages = (0, import_react13.useMemo)(() => {
|
|
1287
833
|
let processedMessages = allMessages.map((message) => {
|
|
1288
834
|
if (message.role !== "assistant") {
|
|
1289
835
|
return message;
|
|
@@ -1320,6 +866,15 @@ function useCopilotChatInternal({
|
|
|
1320
866
|
// legacyCustomMessageRenderer,
|
|
1321
867
|
resolvedAgentId
|
|
1322
868
|
]);
|
|
869
|
+
const renderedSuggestions = (0, import_react13.useMemo)(() => {
|
|
870
|
+
if (Array.isArray(suggestions)) {
|
|
871
|
+
return {
|
|
872
|
+
suggestions: suggestions.map((s) => __spreadProps(__spreadValues({}, s), { isLoading: false })),
|
|
873
|
+
isLoading: false
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
return currentSuggestions;
|
|
877
|
+
}, [suggestions, currentSuggestions]);
|
|
1323
878
|
return {
|
|
1324
879
|
messages: resolvedMessages,
|
|
1325
880
|
sendMessage: latestSendMessageFunc,
|
|
@@ -1333,21 +888,21 @@ function useCopilotChatInternal({
|
|
|
1333
888
|
isLoading: Boolean(agent == null ? void 0 : agent.isRunning),
|
|
1334
889
|
// mcpServers,
|
|
1335
890
|
// setMcpServers,
|
|
1336
|
-
suggestions:
|
|
891
|
+
suggestions: renderedSuggestions.suggestions,
|
|
1337
892
|
setSuggestions: (suggestions2) => copilotkit.addSuggestionsConfig({ suggestions: suggestions2 }),
|
|
1338
893
|
generateSuggestions: () => __async(this, null, function* () {
|
|
1339
894
|
return copilotkit.reloadSuggestions(resolvedAgentId);
|
|
1340
895
|
}),
|
|
1341
896
|
resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),
|
|
1342
|
-
isLoadingSuggestions:
|
|
897
|
+
isLoadingSuggestions: renderedSuggestions.isLoading,
|
|
1343
898
|
interrupt,
|
|
1344
899
|
agent,
|
|
1345
900
|
threadId
|
|
1346
901
|
};
|
|
1347
902
|
}
|
|
1348
903
|
function useUpdatedRef(value) {
|
|
1349
|
-
const ref = (0,
|
|
1350
|
-
(0,
|
|
904
|
+
const ref = (0, import_react13.useRef)(value);
|
|
905
|
+
(0, import_react13.useEffect)(() => {
|
|
1351
906
|
ref.current = value;
|
|
1352
907
|
}, [value]);
|
|
1353
908
|
return ref;
|
|
@@ -1358,7 +913,7 @@ function useLegacyCoagentRenderer({
|
|
|
1358
913
|
agentId,
|
|
1359
914
|
threadId
|
|
1360
915
|
}) {
|
|
1361
|
-
return (0,
|
|
916
|
+
return (0, import_react13.useMemo)(() => {
|
|
1362
917
|
if (!copilotkit || !agent) {
|
|
1363
918
|
return null;
|
|
1364
919
|
}
|
|
@@ -1381,7 +936,7 @@ function useLegacyCoagentRenderer({
|
|
|
1381
936
|
agentId,
|
|
1382
937
|
stateSnapshot: message.state
|
|
1383
938
|
};
|
|
1384
|
-
return (0,
|
|
939
|
+
return (0, import_react13.createElement)(CoAgentStateRenderBridge, bridgeProps);
|
|
1385
940
|
};
|
|
1386
941
|
}, [agent, agentId, copilotkit, threadId]);
|
|
1387
942
|
}
|
|
@@ -1415,7 +970,7 @@ function useCopilotChat(options = {}) {
|
|
|
1415
970
|
}
|
|
1416
971
|
|
|
1417
972
|
// src/hooks/use-copilot-chat-headless_c.ts
|
|
1418
|
-
var
|
|
973
|
+
var import_react15 = require("react");
|
|
1419
974
|
var import_shared4 = require("@copilotkit/shared");
|
|
1420
975
|
var createNonFunctionalReturn = () => ({
|
|
1421
976
|
visibleMessages: [],
|
|
@@ -1456,7 +1011,7 @@ function useCopilotChatHeadless_c(options = {}) {
|
|
|
1456
1011
|
const { copilotApiConfig, setBannerError } = useCopilotContext();
|
|
1457
1012
|
const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
|
|
1458
1013
|
const internalResult = useCopilotChatInternal(options);
|
|
1459
|
-
(0,
|
|
1014
|
+
(0, import_react15.useEffect)(() => {
|
|
1460
1015
|
if (!hasPublicApiKey) {
|
|
1461
1016
|
setBannerError(
|
|
1462
1017
|
new import_shared4.CopilotKitError({
|
|
@@ -1481,13 +1036,13 @@ function useCopilotChatHeadless_c(options = {}) {
|
|
|
1481
1036
|
}
|
|
1482
1037
|
|
|
1483
1038
|
// src/hooks/use-copilot-action.ts
|
|
1484
|
-
var
|
|
1039
|
+
var import_react22 = require("react");
|
|
1485
1040
|
|
|
1486
1041
|
// src/hooks/use-frontend-tool.ts
|
|
1487
|
-
var
|
|
1042
|
+
var import_react16 = __toESM(require("react"));
|
|
1488
1043
|
var import_shared5 = require("@copilotkit/shared");
|
|
1489
1044
|
var import_shared6 = require("@copilotkit/shared");
|
|
1490
|
-
var
|
|
1045
|
+
var import_react17 = require("@copilotkitnext/react");
|
|
1491
1046
|
function useFrontendTool(tool, dependencies) {
|
|
1492
1047
|
const { name, description, parameters, render, followUp } = tool;
|
|
1493
1048
|
const zodParameters = (0, import_shared5.getZodParameters)(parameters);
|
|
@@ -1497,8 +1052,8 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1497
1052
|
}
|
|
1498
1053
|
if (typeof render === "string") {
|
|
1499
1054
|
const staticRender = render;
|
|
1500
|
-
return () =>
|
|
1501
|
-
|
|
1055
|
+
return () => import_react16.default.createElement(
|
|
1056
|
+
import_react16.default.Fragment,
|
|
1502
1057
|
null,
|
|
1503
1058
|
staticRender
|
|
1504
1059
|
);
|
|
@@ -1509,12 +1064,12 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1509
1064
|
});
|
|
1510
1065
|
const rendered = render(renderArgs);
|
|
1511
1066
|
if (typeof rendered === "string") {
|
|
1512
|
-
return
|
|
1067
|
+
return import_react16.default.createElement(import_react16.default.Fragment, null, rendered);
|
|
1513
1068
|
}
|
|
1514
1069
|
return rendered != null ? rendered : null;
|
|
1515
1070
|
};
|
|
1516
1071
|
})();
|
|
1517
|
-
(0,
|
|
1072
|
+
(0, import_react17.useFrontendTool)({
|
|
1518
1073
|
name,
|
|
1519
1074
|
description,
|
|
1520
1075
|
parameters: zodParameters,
|
|
@@ -1526,23 +1081,23 @@ function useFrontendTool(tool, dependencies) {
|
|
|
1526
1081
|
|
|
1527
1082
|
// src/hooks/use-render-tool-call.ts
|
|
1528
1083
|
var import_shared7 = require("@copilotkit/shared");
|
|
1529
|
-
var
|
|
1530
|
-
var
|
|
1084
|
+
var import_react18 = require("react");
|
|
1085
|
+
var import_react19 = require("@copilotkitnext/react");
|
|
1531
1086
|
var import_shared8 = require("@copilotkit/shared");
|
|
1532
1087
|
function useRenderToolCall2(tool, dependencies) {
|
|
1533
|
-
const { copilotkit } = (0,
|
|
1534
|
-
const hasAddedRef = (0,
|
|
1535
|
-
(0,
|
|
1088
|
+
const { copilotkit } = (0, import_react19.useCopilotKit)();
|
|
1089
|
+
const hasAddedRef = (0, import_react18.useRef)(false);
|
|
1090
|
+
(0, import_react18.useEffect)(() => {
|
|
1536
1091
|
const { name, parameters, render } = tool;
|
|
1537
1092
|
const zodParameters = (0, import_shared7.getZodParameters)(parameters);
|
|
1538
|
-
const renderToolCall = name === "*" ? (0,
|
|
1093
|
+
const renderToolCall = name === "*" ? (0, import_react19.defineToolCallRenderer)({
|
|
1539
1094
|
name: "*",
|
|
1540
1095
|
render: (args) => {
|
|
1541
1096
|
return render(__spreadProps(__spreadValues({}, args), {
|
|
1542
1097
|
result: args.result ? (0, import_shared8.parseJson)(args.result, args.result) : args.result
|
|
1543
1098
|
}));
|
|
1544
1099
|
}
|
|
1545
|
-
}) : (0,
|
|
1100
|
+
}) : (0, import_react19.defineToolCallRenderer)({
|
|
1546
1101
|
name,
|
|
1547
1102
|
args: zodParameters,
|
|
1548
1103
|
render: (args) => {
|
|
@@ -1571,18 +1126,18 @@ function useRenderToolCall2(tool, dependencies) {
|
|
|
1571
1126
|
|
|
1572
1127
|
// src/hooks/use-human-in-the-loop.ts
|
|
1573
1128
|
var import_shared9 = require("@copilotkit/shared");
|
|
1574
|
-
var
|
|
1129
|
+
var import_react20 = require("@copilotkitnext/react");
|
|
1575
1130
|
var import_core = require("@copilotkitnext/core");
|
|
1576
|
-
var
|
|
1131
|
+
var import_react21 = __toESM(require("react"));
|
|
1577
1132
|
function useHumanInTheLoop(tool, dependencies) {
|
|
1578
1133
|
const _a = tool, { render } = _a, toolRest = __objRest(_a, ["render"]);
|
|
1579
1134
|
const { name, description, parameters, followUp } = toolRest;
|
|
1580
1135
|
const zodParameters = (0, import_shared9.getZodParameters)(parameters);
|
|
1581
|
-
const renderRef = (0,
|
|
1582
|
-
(0,
|
|
1136
|
+
const renderRef = (0, import_react21.useRef)(null);
|
|
1137
|
+
(0, import_react21.useEffect)(() => {
|
|
1583
1138
|
renderRef.current = (args) => {
|
|
1584
1139
|
if (typeof render === "string") {
|
|
1585
|
-
return
|
|
1140
|
+
return import_react21.default.createElement(import_react21.default.Fragment, null, render);
|
|
1586
1141
|
}
|
|
1587
1142
|
if (!render) {
|
|
1588
1143
|
return null;
|
|
@@ -1622,12 +1177,12 @@ function useHumanInTheLoop(tool, dependencies) {
|
|
|
1622
1177
|
})();
|
|
1623
1178
|
const rendered = render(renderProps);
|
|
1624
1179
|
if (typeof rendered === "string") {
|
|
1625
|
-
return
|
|
1180
|
+
return import_react21.default.createElement(import_react21.default.Fragment, null, rendered);
|
|
1626
1181
|
}
|
|
1627
1182
|
return rendered != null ? rendered : null;
|
|
1628
1183
|
};
|
|
1629
1184
|
}, [render, ...dependencies != null ? dependencies : []]);
|
|
1630
|
-
(0,
|
|
1185
|
+
(0, import_react20.useHumanInTheLoop)({
|
|
1631
1186
|
name,
|
|
1632
1187
|
description,
|
|
1633
1188
|
followUp,
|
|
@@ -1683,7 +1238,7 @@ function getActionConfig(action) {
|
|
|
1683
1238
|
throw new Error("Invalid action configuration");
|
|
1684
1239
|
}
|
|
1685
1240
|
function useCopilotAction(action, dependencies) {
|
|
1686
|
-
const [initialActionConfig] = (0,
|
|
1241
|
+
const [initialActionConfig] = (0, import_react22.useState)(getActionConfig(action));
|
|
1687
1242
|
const currentActionConfig = getActionConfig(action);
|
|
1688
1243
|
if (initialActionConfig.type !== currentActionConfig.type) {
|
|
1689
1244
|
throw new Error("Action configuration changed between renders");
|
|
@@ -1701,14 +1256,14 @@ function useCopilotAction(action, dependencies) {
|
|
|
1701
1256
|
}
|
|
1702
1257
|
|
|
1703
1258
|
// src/hooks/use-coagent-state-render.ts
|
|
1704
|
-
var
|
|
1259
|
+
var import_react23 = require("react");
|
|
1705
1260
|
var import_shared10 = require("@copilotkit/shared");
|
|
1706
1261
|
function useCoAgentStateRender(action, dependencies) {
|
|
1707
|
-
const { chatComponentsCache, availableAgents } = (0,
|
|
1262
|
+
const { chatComponentsCache, availableAgents } = (0, import_react23.useContext)(CopilotContext);
|
|
1708
1263
|
const { setCoAgentStateRender, removeCoAgentStateRender, coAgentStateRenders } = useCoAgentStateRenders();
|
|
1709
|
-
const idRef = (0,
|
|
1264
|
+
const idRef = (0, import_react23.useRef)((0, import_shared10.randomId)());
|
|
1710
1265
|
const { setBannerError, addToast } = useToast();
|
|
1711
|
-
(0,
|
|
1266
|
+
(0, import_react23.useEffect)(() => {
|
|
1712
1267
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
1713
1268
|
const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
|
|
1714
1269
|
const agentError = new import_shared10.CopilotKitAgentDiscoveryError({
|
|
@@ -1729,7 +1284,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
1729
1284
|
}
|
|
1730
1285
|
}
|
|
1731
1286
|
}
|
|
1732
|
-
(0,
|
|
1287
|
+
(0, import_react23.useEffect)(() => {
|
|
1733
1288
|
const currentId = idRef.current;
|
|
1734
1289
|
const hasDuplicate = Object.entries(coAgentStateRenders).some(([id, otherAction]) => {
|
|
1735
1290
|
if (id === currentId)
|
|
@@ -1753,7 +1308,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
1753
1308
|
});
|
|
1754
1309
|
}
|
|
1755
1310
|
}, [coAgentStateRenders]);
|
|
1756
|
-
(0,
|
|
1311
|
+
(0, import_react23.useEffect)(() => {
|
|
1757
1312
|
setCoAgentStateRender(idRef.current, action);
|
|
1758
1313
|
if (chatComponentsCache.current !== null && action.render !== void 0) {
|
|
1759
1314
|
chatComponentsCache.current.coAgentStateRenders[key] = action.render;
|
|
@@ -1773,11 +1328,11 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
1773
1328
|
}
|
|
1774
1329
|
|
|
1775
1330
|
// src/hooks/use-make-copilot-document-readable.ts
|
|
1776
|
-
var
|
|
1331
|
+
var import_react24 = require("react");
|
|
1777
1332
|
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
1778
1333
|
const { addDocumentContext, removeDocumentContext } = useCopilotContext();
|
|
1779
|
-
const idRef = (0,
|
|
1780
|
-
(0,
|
|
1334
|
+
const idRef = (0, import_react24.useRef)(void 0);
|
|
1335
|
+
(0, import_react24.useEffect)(() => {
|
|
1781
1336
|
const id = addDocumentContext(document, categories);
|
|
1782
1337
|
idRef.current = id;
|
|
1783
1338
|
return () => {
|
|
@@ -1788,12 +1343,12 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
1788
1343
|
}
|
|
1789
1344
|
|
|
1790
1345
|
// src/hooks/use-copilot-readable.ts
|
|
1791
|
-
var
|
|
1792
|
-
var
|
|
1346
|
+
var import_react25 = require("@copilotkitnext/react");
|
|
1347
|
+
var import_react26 = require("react");
|
|
1793
1348
|
function useCopilotReadable({ description, value, convert, available }, dependencies) {
|
|
1794
|
-
const { copilotkit } = (0,
|
|
1795
|
-
const ctxIdRef = (0,
|
|
1796
|
-
(0,
|
|
1349
|
+
const { copilotkit } = (0, import_react25.useCopilotKit)();
|
|
1350
|
+
const ctxIdRef = (0, import_react26.useRef)(void 0);
|
|
1351
|
+
(0, import_react26.useEffect)(() => {
|
|
1797
1352
|
if (!copilotkit)
|
|
1798
1353
|
return;
|
|
1799
1354
|
const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
|
|
@@ -1821,13 +1376,13 @@ function useCopilotReadable({ description, value, convert, available }, dependen
|
|
|
1821
1376
|
}
|
|
1822
1377
|
|
|
1823
1378
|
// src/hooks/use-coagent.ts
|
|
1824
|
-
var
|
|
1825
|
-
var
|
|
1379
|
+
var import_react27 = require("react");
|
|
1380
|
+
var import_react28 = require("@copilotkitnext/react");
|
|
1826
1381
|
function useCoAgent(options) {
|
|
1827
|
-
const { agent } = (0,
|
|
1828
|
-
const { copilotkit } = (0,
|
|
1382
|
+
const { agent } = (0, import_react28.useAgent)({ agentId: options.name });
|
|
1383
|
+
const { copilotkit } = (0, import_react28.useCopilotKit)();
|
|
1829
1384
|
const nodeName = useAgentNodeName(options.name);
|
|
1830
|
-
const handleStateUpdate = (0,
|
|
1385
|
+
const handleStateUpdate = (0, import_react27.useCallback)(
|
|
1831
1386
|
(newState) => {
|
|
1832
1387
|
if (!agent)
|
|
1833
1388
|
return;
|
|
@@ -1840,7 +1395,7 @@ function useCoAgent(options) {
|
|
|
1840
1395
|
},
|
|
1841
1396
|
[agent == null ? void 0 : agent.state, agent == null ? void 0 : agent.setState]
|
|
1842
1397
|
);
|
|
1843
|
-
(0,
|
|
1398
|
+
(0, import_react27.useEffect)(() => {
|
|
1844
1399
|
var _a;
|
|
1845
1400
|
if (!options.config && !options.configurable)
|
|
1846
1401
|
return;
|
|
@@ -1852,22 +1407,22 @@ function useCoAgent(options) {
|
|
|
1852
1407
|
}
|
|
1853
1408
|
copilotkit.setProperties(config);
|
|
1854
1409
|
}, [options.config, options.configurable]);
|
|
1855
|
-
const externalStateStr = (0,
|
|
1410
|
+
const externalStateStr = (0, import_react27.useMemo)(
|
|
1856
1411
|
() => isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
|
|
1857
1412
|
[isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]
|
|
1858
1413
|
);
|
|
1859
|
-
(0,
|
|
1414
|
+
(0, import_react27.useEffect)(() => {
|
|
1860
1415
|
if ((agent == null ? void 0 : agent.state) && isExternalStateManagement(options) && JSON.stringify(options.state) !== JSON.stringify(agent.state)) {
|
|
1861
1416
|
handleStateUpdate(options.state);
|
|
1862
1417
|
}
|
|
1863
1418
|
}, [agent, externalStateStr, handleStateUpdate]);
|
|
1864
|
-
const hasStateValues = (0,
|
|
1419
|
+
const hasStateValues = (0, import_react27.useCallback)((value) => {
|
|
1865
1420
|
return Boolean(value && Object.keys(value).length);
|
|
1866
1421
|
}, []);
|
|
1867
|
-
const initialStateRef = (0,
|
|
1422
|
+
const initialStateRef = (0, import_react27.useRef)(
|
|
1868
1423
|
isExternalStateManagement(options) ? options.state : "initialState" in options ? options.initialState : void 0
|
|
1869
1424
|
);
|
|
1870
|
-
(0,
|
|
1425
|
+
(0, import_react27.useEffect)(() => {
|
|
1871
1426
|
if (isExternalStateManagement(options)) {
|
|
1872
1427
|
initialStateRef.current = options.state;
|
|
1873
1428
|
} else if ("initialState" in options) {
|
|
@@ -1876,7 +1431,7 @@ function useCoAgent(options) {
|
|
|
1876
1431
|
}, [
|
|
1877
1432
|
isExternalStateManagement(options) ? JSON.stringify(options.state) : "initialState" in options ? JSON.stringify(options.initialState) : void 0
|
|
1878
1433
|
]);
|
|
1879
|
-
(0,
|
|
1434
|
+
(0, import_react27.useEffect)(() => {
|
|
1880
1435
|
if (!agent)
|
|
1881
1436
|
return;
|
|
1882
1437
|
const subscriber = {
|
|
@@ -1904,7 +1459,7 @@ function useCoAgent(options) {
|
|
|
1904
1459
|
subscription.unsubscribe();
|
|
1905
1460
|
};
|
|
1906
1461
|
}, [agent, handleStateUpdate, hasStateValues]);
|
|
1907
|
-
return (0,
|
|
1462
|
+
return (0, import_react27.useMemo)(() => {
|
|
1908
1463
|
var _a, _b, _c;
|
|
1909
1464
|
if (!agent) {
|
|
1910
1465
|
const noop = () => {
|
|
@@ -1960,12 +1515,12 @@ var isExternalStateManagement = (options) => {
|
|
|
1960
1515
|
|
|
1961
1516
|
// src/hooks/use-copilot-runtime-client.ts
|
|
1962
1517
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
1963
|
-
var
|
|
1518
|
+
var import_react29 = require("react");
|
|
1964
1519
|
var import_shared11 = require("@copilotkit/shared");
|
|
1965
1520
|
var useCopilotRuntimeClient = (options) => {
|
|
1966
1521
|
const { setBannerError } = useToast();
|
|
1967
1522
|
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
1968
|
-
const lastStructuredErrorRef = (0,
|
|
1523
|
+
const lastStructuredErrorRef = (0, import_react29.useRef)(null);
|
|
1969
1524
|
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
1970
1525
|
try {
|
|
1971
1526
|
const errorEvent = {
|
|
@@ -1991,7 +1546,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
1991
1546
|
console.error("Error in onError handler:", error2);
|
|
1992
1547
|
}
|
|
1993
1548
|
});
|
|
1994
|
-
const runtimeClient = (0,
|
|
1549
|
+
const runtimeClient = (0, import_react29.useMemo)(() => {
|
|
1995
1550
|
return new import_runtime_client_gql3.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
1996
1551
|
handleGQLErrors: (error) => {
|
|
1997
1552
|
var _a2;
|
|
@@ -2070,28 +1625,28 @@ function createStructuredError(gqlError) {
|
|
|
2070
1625
|
}
|
|
2071
1626
|
|
|
2072
1627
|
// src/hooks/use-copilot-authenticated-action.ts
|
|
2073
|
-
var
|
|
2074
|
-
var
|
|
1628
|
+
var import_react30 = require("react");
|
|
1629
|
+
var import_react31 = __toESM(require("react"));
|
|
2075
1630
|
function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
2076
1631
|
const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
|
|
2077
|
-
const pendingActionRef = (0,
|
|
2078
|
-
const executeAction = (0,
|
|
1632
|
+
const pendingActionRef = (0, import_react30.useRef)(null);
|
|
1633
|
+
const executeAction = (0, import_react30.useCallback)(
|
|
2079
1634
|
(props) => {
|
|
2080
1635
|
if (typeof action.render === "function") {
|
|
2081
1636
|
return action.render(props);
|
|
2082
1637
|
}
|
|
2083
|
-
return action.render ||
|
|
1638
|
+
return action.render || import_react31.default.createElement(import_react30.Fragment);
|
|
2084
1639
|
},
|
|
2085
1640
|
[action]
|
|
2086
1641
|
);
|
|
2087
|
-
const wrappedRender = (0,
|
|
1642
|
+
const wrappedRender = (0, import_react30.useCallback)(
|
|
2088
1643
|
(props) => {
|
|
2089
1644
|
const isAuthenticated = Object.values(authStates_c || {}).some(
|
|
2090
1645
|
(state) => state.status === "authenticated"
|
|
2091
1646
|
);
|
|
2092
1647
|
if (!isAuthenticated) {
|
|
2093
1648
|
pendingActionRef.current = props;
|
|
2094
|
-
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ?
|
|
1649
|
+
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react31.default.createElement(authConfig_c.SignInComponent, {
|
|
2095
1650
|
onSignInComplete: (authState) => {
|
|
2096
1651
|
setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
|
|
2097
1652
|
if (pendingActionRef.current) {
|
|
@@ -2099,7 +1654,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2099
1654
|
pendingActionRef.current = null;
|
|
2100
1655
|
}
|
|
2101
1656
|
}
|
|
2102
|
-
}) :
|
|
1657
|
+
}) : import_react31.default.createElement(import_react30.Fragment);
|
|
2103
1658
|
}
|
|
2104
1659
|
return executeAction(props);
|
|
2105
1660
|
},
|
|
@@ -2114,13 +1669,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2114
1669
|
}
|
|
2115
1670
|
|
|
2116
1671
|
// src/hooks/use-langgraph-interrupt.ts
|
|
2117
|
-
var
|
|
1672
|
+
var import_react32 = require("react");
|
|
2118
1673
|
var import_shared12 = require("@copilotkit/shared");
|
|
2119
1674
|
function useLangGraphInterrupt(action, dependencies) {
|
|
2120
|
-
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0,
|
|
1675
|
+
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, import_react32.useContext)(CopilotContext);
|
|
2121
1676
|
const { addToast } = useToast();
|
|
2122
1677
|
const actionId = (0, import_shared12.dataToUUID)(action, "lgAction");
|
|
2123
|
-
(0,
|
|
1678
|
+
(0, import_react32.useEffect)(() => {
|
|
2124
1679
|
if (!action)
|
|
2125
1680
|
return;
|
|
2126
1681
|
setInterruptAction(__spreadProps(__spreadValues({}, action), { id: actionId }));
|
|
@@ -2131,10 +1686,10 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
2131
1686
|
}
|
|
2132
1687
|
|
|
2133
1688
|
// src/hooks/use-copilot-additional-instructions.ts
|
|
2134
|
-
var
|
|
1689
|
+
var import_react33 = require("react");
|
|
2135
1690
|
function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
|
|
2136
1691
|
const { setAdditionalInstructions } = useCopilotContext();
|
|
2137
|
-
(0,
|
|
1692
|
+
(0, import_react33.useEffect)(() => {
|
|
2138
1693
|
if (available === "disabled")
|
|
2139
1694
|
return;
|
|
2140
1695
|
setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);
|
|
@@ -2150,17 +1705,32 @@ function useCopilotAdditionalInstructions({ instructions, available = "enabled"
|
|
|
2150
1705
|
function useDefaultTool(tool, dependencies) {
|
|
2151
1706
|
useCopilotAction(__spreadProps(__spreadValues({}, tool), { name: "*" }), dependencies);
|
|
2152
1707
|
}
|
|
1708
|
+
|
|
1709
|
+
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
1710
|
+
var import_react34 = require("@copilotkitnext/react");
|
|
1711
|
+
function useCopilotChatSuggestions(config, dependencies = []) {
|
|
1712
|
+
var _a, _b;
|
|
1713
|
+
const existingConfig = (0, import_react34.useCopilotChatConfiguration)();
|
|
1714
|
+
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
1715
|
+
const available = (_b = config.available === "enabled" ? "always" : config.available) != null ? _b : "before-first-message";
|
|
1716
|
+
const finalSuggestionConfig = __spreadProps(__spreadValues({}, config), {
|
|
1717
|
+
available,
|
|
1718
|
+
consumerAgentId: resolvedAgentId
|
|
1719
|
+
// Use chatConfig.agentId here
|
|
1720
|
+
});
|
|
1721
|
+
(0, import_react34.useConfigureSuggestions)(finalSuggestionConfig, dependencies);
|
|
1722
|
+
}
|
|
2153
1723
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2154
1724
|
0 && (module.exports = {
|
|
2155
1725
|
useCoAgent,
|
|
2156
1726
|
useCoAgentStateRender,
|
|
2157
|
-
useConfigureChatSuggestions,
|
|
2158
1727
|
useCopilotAction,
|
|
2159
1728
|
useCopilotAdditionalInstructions,
|
|
2160
1729
|
useCopilotAuthenticatedAction_c,
|
|
2161
1730
|
useCopilotChat,
|
|
2162
1731
|
useCopilotChatHeadless_c,
|
|
2163
1732
|
useCopilotChatInternal,
|
|
1733
|
+
useCopilotChatSuggestions,
|
|
2164
1734
|
useCopilotReadable,
|
|
2165
1735
|
useCopilotRuntimeClient,
|
|
2166
1736
|
useDefaultTool,
|