@copilotkit/react-core 1.9.2-next.8 → 1.9.2-next.9
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 +9 -0
- package/dist/{chunk-CCESTGAM.mjs → chunk-3OQM3NEK.mjs} +2 -2
- package/dist/{chunk-T4ZKC4X4.mjs → chunk-3YHYWAHK.mjs} +2 -2
- package/dist/{chunk-ISYBUDL4.mjs → chunk-55QZ2SVJ.mjs} +4 -5
- package/dist/chunk-55QZ2SVJ.mjs.map +1 -0
- package/dist/chunk-57K2ZJ5F.mjs +348 -0
- package/dist/chunk-57K2ZJ5F.mjs.map +1 -0
- package/dist/{chunk-ZHEEHGLS.mjs → chunk-ADIITPD2.mjs} +8 -5
- package/dist/{chunk-ZHEEHGLS.mjs.map → chunk-ADIITPD2.mjs.map} +1 -1
- package/dist/{chunk-S4BOATBG.mjs → chunk-EF5BNM34.mjs} +2 -2
- package/dist/{chunk-I4JPQECN.mjs → chunk-EXU7GWLC.mjs} +4 -4
- package/dist/{chunk-7G6RR4HE.mjs → chunk-FXK6RQIN.mjs} +2 -2
- package/dist/{chunk-JXF732XG.mjs → chunk-G7LYGERN.mjs} +80 -13
- package/dist/chunk-G7LYGERN.mjs.map +1 -0
- package/dist/{chunk-VJCHRQ7Q.mjs → chunk-JDEWNLNP.mjs} +37 -4
- package/dist/chunk-JDEWNLNP.mjs.map +1 -0
- package/dist/{chunk-JHIZ5HAI.mjs → chunk-NQVCZQ5T.mjs} +3 -3
- package/dist/{chunk-VF6UPRKM.mjs → chunk-OF4SZTLL.mjs} +3 -3
- package/dist/{chunk-QQZLIEXK.mjs → chunk-SJJNFYGQ.mjs} +3 -3
- package/dist/{chunk-RN3ZRHI7.mjs → chunk-WOGURSAL.mjs} +5 -5
- package/dist/chunk-YAF2LATQ.mjs +310 -0
- package/dist/chunk-YAF2LATQ.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +35 -2
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
- package/dist/components/copilot-provider/copilotkit.js +289 -234
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +7 -7
- package/dist/components/copilot-provider/index.js +289 -234
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +7 -7
- package/dist/components/error-boundary/error-boundary.js +135 -146
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +4 -4
- package/dist/components/error-boundary/error-utils.js.map +1 -1
- package/dist/components/error-boundary/error-utils.mjs +2 -2
- package/dist/components/index.js +289 -234
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +7 -7
- package/dist/components/toast/toast-provider.js +118 -85
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/components/usage-banner.js +135 -146
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +1 -1
- package/dist/hooks/index.js +75 -10
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +14 -14
- package/dist/hooks/use-chat.js +72 -10
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +4 -4
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -2
- package/dist/hooks/use-coagent.js +75 -10
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +10 -10
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +3 -3
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +4 -4
- package/dist/hooks/use-copilot-chat.js +72 -10
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +9 -9
- package/dist/hooks/use-copilot-runtime-client.js +1 -1
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt.js +72 -10
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +10 -10
- package/dist/index.js +363 -243
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/lib/copilot-task.mjs +8 -8
- package/dist/lib/index.mjs +8 -8
- package/dist/utils/extract.mjs +7 -7
- package/dist/utils/index.mjs +7 -7
- package/package.json +3 -3
- package/src/components/copilot-provider/copilot-messages.tsx +42 -3
- package/src/components/toast/toast-provider.tsx +49 -24
- package/src/components/usage-banner.tsx +144 -147
- package/src/hooks/use-chat.ts +106 -6
- package/src/hooks/use-coagent.ts +5 -0
- package/src/hooks/use-copilot-runtime-client.ts +2 -39
- package/dist/chunk-HD2GE3DK.mjs +0 -359
- package/dist/chunk-HD2GE3DK.mjs.map +0 -1
- package/dist/chunk-ISYBUDL4.mjs.map +0 -1
- package/dist/chunk-JXF732XG.mjs.map +0 -1
- package/dist/chunk-VJCHRQ7Q.mjs.map +0 -1
- package/dist/chunk-VRXANACV.mjs +0 -277
- package/dist/chunk-VRXANACV.mjs.map +0 -1
- /package/dist/{chunk-CCESTGAM.mjs.map → chunk-3OQM3NEK.mjs.map} +0 -0
- /package/dist/{chunk-T4ZKC4X4.mjs.map → chunk-3YHYWAHK.mjs.map} +0 -0
- /package/dist/{chunk-S4BOATBG.mjs.map → chunk-EF5BNM34.mjs.map} +0 -0
- /package/dist/{chunk-I4JPQECN.mjs.map → chunk-EXU7GWLC.mjs.map} +0 -0
- /package/dist/{chunk-7G6RR4HE.mjs.map → chunk-FXK6RQIN.mjs.map} +0 -0
- /package/dist/{chunk-JHIZ5HAI.mjs.map → chunk-NQVCZQ5T.mjs.map} +0 -0
- /package/dist/{chunk-VF6UPRKM.mjs.map → chunk-OF4SZTLL.mjs.map} +0 -0
- /package/dist/{chunk-QQZLIEXK.mjs.map → chunk-SJJNFYGQ.mjs.map} +0 -0
- /package/dist/{chunk-RN3ZRHI7.mjs.map → chunk-WOGURSAL.mjs.map} +0 -0
package/dist/hooks/index.mjs
CHANGED
|
@@ -4,52 +4,52 @@ import {
|
|
|
4
4
|
} from "../chunk-CMQV4XNY.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useLangGraphInterrupt
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-OF4SZTLL.mjs";
|
|
8
8
|
import {
|
|
9
9
|
useMakeCopilotDocumentReadable
|
|
10
10
|
} from "../chunk-ERXWDCY6.mjs";
|
|
11
11
|
import {
|
|
12
12
|
useCoAgentStateRender
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-3YHYWAHK.mjs";
|
|
14
14
|
import {
|
|
15
15
|
runAgent,
|
|
16
16
|
startAgent,
|
|
17
17
|
stopAgent,
|
|
18
18
|
useCoAgent
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ADIITPD2.mjs";
|
|
20
20
|
import {
|
|
21
21
|
useCopilotAdditionalInstructions
|
|
22
22
|
} from "../chunk-JPMIAGI6.mjs";
|
|
23
23
|
import {
|
|
24
24
|
useCopilotAuthenticatedAction_c
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-EF5BNM34.mjs";
|
|
26
26
|
import {
|
|
27
27
|
useCopilotAction
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-NQVCZQ5T.mjs";
|
|
29
29
|
import {
|
|
30
30
|
useCopilotChat
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-EXU7GWLC.mjs";
|
|
32
32
|
import {
|
|
33
33
|
useCopilotReadable
|
|
34
34
|
} from "../chunk-UBNRUXEK.mjs";
|
|
35
|
-
import "../chunk-
|
|
36
|
-
import "../chunk-
|
|
37
|
-
import "../chunk-
|
|
35
|
+
import "../chunk-WOGURSAL.mjs";
|
|
36
|
+
import "../chunk-SJJNFYGQ.mjs";
|
|
37
|
+
import "../chunk-JDEWNLNP.mjs";
|
|
38
38
|
import "../chunk-5FHSUKQL.mjs";
|
|
39
39
|
import "../chunk-RKTVJRK7.mjs";
|
|
40
40
|
import "../chunk-PMAFHQ7P.mjs";
|
|
41
|
-
import "../chunk-
|
|
41
|
+
import "../chunk-57K2ZJ5F.mjs";
|
|
42
42
|
import "../chunk-YPSGKPDA.mjs";
|
|
43
43
|
import "../chunk-DCTJZ742.mjs";
|
|
44
|
-
import "../chunk-
|
|
44
|
+
import "../chunk-G7LYGERN.mjs";
|
|
45
45
|
import "../chunk-4CEQJ2X6.mjs";
|
|
46
|
-
import "../chunk-
|
|
46
|
+
import "../chunk-3OQM3NEK.mjs";
|
|
47
47
|
import "../chunk-O7ARI5CV.mjs";
|
|
48
48
|
import {
|
|
49
49
|
useCopilotRuntimeClient
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-55QZ2SVJ.mjs";
|
|
51
51
|
import "../chunk-GFJW4RIM.mjs";
|
|
52
|
-
import "../chunk-
|
|
52
|
+
import "../chunk-YAF2LATQ.mjs";
|
|
53
53
|
import "../chunk-XFOTNHYA.mjs";
|
|
54
54
|
import "../chunk-SKC7AJIV.mjs";
|
|
55
55
|
export {
|
package/dist/hooks/use-chat.js
CHANGED
|
@@ -156,7 +156,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
156
156
|
startTime: Date.now()
|
|
157
157
|
},
|
|
158
158
|
technical: {
|
|
159
|
-
environment:
|
|
159
|
+
environment: "browser",
|
|
160
160
|
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
161
161
|
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
162
162
|
}
|
|
@@ -489,6 +489,35 @@ function useChat(options) {
|
|
|
489
489
|
} = options;
|
|
490
490
|
const runChatCompletionRef = (0, import_react5.useRef)();
|
|
491
491
|
const addErrorToast = useErrorToast();
|
|
492
|
+
const { setBannerError } = useToast();
|
|
493
|
+
const { onTrace } = useCopilotContext();
|
|
494
|
+
const traceUIError = (error, originalError) => __async(this, null, function* () {
|
|
495
|
+
if (!onTrace || !(copilotConfig == null ? void 0 : copilotConfig.publicApiKey))
|
|
496
|
+
return;
|
|
497
|
+
try {
|
|
498
|
+
const traceEvent = {
|
|
499
|
+
type: "error",
|
|
500
|
+
timestamp: Date.now(),
|
|
501
|
+
context: {
|
|
502
|
+
source: "ui",
|
|
503
|
+
request: {
|
|
504
|
+
operation: "useChatCompletion",
|
|
505
|
+
url: copilotConfig.chatApiEndpoint,
|
|
506
|
+
startTime: Date.now()
|
|
507
|
+
},
|
|
508
|
+
technical: {
|
|
509
|
+
environment: "browser",
|
|
510
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
511
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
error
|
|
515
|
+
};
|
|
516
|
+
yield onTrace(traceEvent);
|
|
517
|
+
} catch (traceError) {
|
|
518
|
+
console.error("Error in use-chat onTrace handler:", traceError);
|
|
519
|
+
}
|
|
520
|
+
});
|
|
492
521
|
const agentSessionRef = (0, import_react5.useRef)(agentSession);
|
|
493
522
|
agentSessionRef.current = agentSession;
|
|
494
523
|
const runIdRef = (0, import_react5.useRef)(runId);
|
|
@@ -508,7 +537,7 @@ function useChat(options) {
|
|
|
508
537
|
const pendingAppendsRef = (0, import_react5.useRef)([]);
|
|
509
538
|
const runChatCompletion = useAsyncCallback(
|
|
510
539
|
(previousMessages) => __async(this, null, function* () {
|
|
511
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
540
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
512
541
|
setIsLoading(true);
|
|
513
542
|
const interruptEvent = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event;
|
|
514
543
|
if ((interruptEvent == null ? void 0 : interruptEvent.name) === import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent && (interruptEvent == null ? void 0 : interruptEvent.value) && !(interruptEvent == null ? void 0 : interruptEvent.response) && agentSessionRef.current) {
|
|
@@ -640,20 +669,53 @@ function useChat(options) {
|
|
|
640
669
|
messages2 = (0, import_runtime_client_gql3.convertGqlOutputToMessages)(
|
|
641
670
|
(0, import_runtime_client_gql3.filterAdjacentAgentStateMessages)(rawMessagesResponse)
|
|
642
671
|
);
|
|
643
|
-
if (messages2.length === 0) {
|
|
644
|
-
continue;
|
|
645
|
-
}
|
|
646
672
|
newMessages = [];
|
|
647
673
|
if (((_k = value.generateCopilotResponse.status) == null ? void 0 : _k.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "GUARDRAILS_VALIDATION_FAILED") {
|
|
674
|
+
const guardrailsReason = ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || "";
|
|
648
675
|
newMessages = [
|
|
649
676
|
new import_runtime_client_gql3.TextMessage({
|
|
650
677
|
role: import_runtime_client_gql3.MessageRole.Assistant,
|
|
651
|
-
content:
|
|
678
|
+
content: guardrailsReason
|
|
652
679
|
})
|
|
653
680
|
];
|
|
681
|
+
const guardrailsError = new import_shared4.CopilotKitError({
|
|
682
|
+
message: `Guardrails validation failed: ${guardrailsReason}`,
|
|
683
|
+
code: import_shared4.CopilotKitErrorCode.MISUSE
|
|
684
|
+
});
|
|
685
|
+
yield traceUIError(guardrailsError, {
|
|
686
|
+
statusReason: value.generateCopilotResponse.status.reason,
|
|
687
|
+
statusDetails: value.generateCopilotResponse.status.details
|
|
688
|
+
});
|
|
654
689
|
setMessages([...previousMessages, ...newMessages]);
|
|
655
690
|
break;
|
|
656
|
-
}
|
|
691
|
+
}
|
|
692
|
+
if (((_m = value.generateCopilotResponse.status) == null ? void 0 : _m.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "UNKNOWN_ERROR") {
|
|
693
|
+
const errorMessage = ((_n = value.generateCopilotResponse.status.details) == null ? void 0 : _n.description) || "An unknown error occurred";
|
|
694
|
+
const statusDetails = value.generateCopilotResponse.status.details;
|
|
695
|
+
const originalError = (statusDetails == null ? void 0 : statusDetails.originalError) || (statusDetails == null ? void 0 : statusDetails.error);
|
|
696
|
+
const originalCode = (originalError == null ? void 0 : originalError.code) || ((_o = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _o.code);
|
|
697
|
+
const originalSeverity = (originalError == null ? void 0 : originalError.severity) || ((_p = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _p.severity);
|
|
698
|
+
const originalVisibility = (originalError == null ? void 0 : originalError.visibility) || ((_q = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _q.visibility);
|
|
699
|
+
let errorCode = import_shared4.CopilotKitErrorCode.NETWORK_ERROR;
|
|
700
|
+
if (originalCode && Object.values(import_shared4.CopilotKitErrorCode).includes(originalCode)) {
|
|
701
|
+
errorCode = originalCode;
|
|
702
|
+
}
|
|
703
|
+
const structuredError = new import_shared4.CopilotKitError({
|
|
704
|
+
message: errorMessage,
|
|
705
|
+
code: errorCode,
|
|
706
|
+
severity: originalSeverity,
|
|
707
|
+
visibility: originalVisibility
|
|
708
|
+
});
|
|
709
|
+
setBannerError(structuredError);
|
|
710
|
+
yield traceUIError(structuredError, {
|
|
711
|
+
statusReason: value.generateCopilotResponse.status.reason,
|
|
712
|
+
statusDetails: value.generateCopilotResponse.status.details,
|
|
713
|
+
originalErrorCode: originalCode,
|
|
714
|
+
preservedStructure: !!originalCode
|
|
715
|
+
});
|
|
716
|
+
setIsLoading(false);
|
|
717
|
+
break;
|
|
718
|
+
} else if (messages2.length > 0) {
|
|
657
719
|
newMessages = [...messages2];
|
|
658
720
|
for (const message of messages2) {
|
|
659
721
|
if (message.isAgentStateMessage() && !message.active && !executedCoAgentStateRenders.includes(message.id) && onCoAgentStateRender) {
|
|
@@ -784,11 +846,11 @@ function useChat(options) {
|
|
|
784
846
|
followUp !== false && // and we executed an action
|
|
785
847
|
(didExecuteAction || // the last message is a server side result
|
|
786
848
|
!isAgentRun && finalMessages.length && finalMessages[finalMessages.length - 1].isResultMessage()) && // the user did not stop generation
|
|
787
|
-
!((
|
|
849
|
+
!((_r = chatAbortControllerRef.current) == null ? void 0 : _r.signal.aborted)
|
|
788
850
|
) {
|
|
789
851
|
yield new Promise((resolve) => setTimeout(resolve, 10));
|
|
790
852
|
return yield runChatCompletionRef.current(finalMessages);
|
|
791
|
-
} else if ((
|
|
853
|
+
} else if ((_s = chatAbortControllerRef.current) == null ? void 0 : _s.signal.aborted) {
|
|
792
854
|
const repairedMessages = finalMessages.filter((message, actionExecutionIndex) => {
|
|
793
855
|
if (message.isActionExecutionMessage()) {
|
|
794
856
|
return finalMessages.find(
|
|
@@ -799,7 +861,7 @@ function useChat(options) {
|
|
|
799
861
|
});
|
|
800
862
|
const repairedMessageIds = repairedMessages.map((message) => message.id);
|
|
801
863
|
setMessages(repairedMessages);
|
|
802
|
-
if ((
|
|
864
|
+
if ((_t = agentSessionRef.current) == null ? void 0 : _t.nodeName) {
|
|
803
865
|
setAgentSession({
|
|
804
866
|
threadId: agentSessionRef.current.threadId,
|
|
805
867
|
agentName: agentSessionRef.current.agentName,
|