@copilotkit/react-core 1.9.2-next.10 → 1.9.2-next.3
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 +0 -56
- package/dist/{chunk-3YHYWAHK.mjs → chunk-2FW7HH6W.mjs} +3 -3
- package/dist/{chunk-OF4SZTLL.mjs → chunk-2XSUXRGG.mjs} +4 -4
- package/dist/{chunk-WOGURSAL.mjs → chunk-3XXVDQ7Z.mjs} +8 -10
- package/dist/chunk-3XXVDQ7Z.mjs.map +1 -0
- package/dist/{chunk-XFOTNHYA.mjs → chunk-6KGEF242.mjs} +2 -3
- package/dist/chunk-6KGEF242.mjs.map +1 -0
- package/dist/{chunk-EXU7GWLC.mjs → chunk-C3SYYVMR.mjs} +5 -5
- package/dist/{chunk-JPMIAGI6.mjs → chunk-C6F6EQNA.mjs} +2 -2
- package/dist/{chunk-3OQM3NEK.mjs → chunk-CCESTGAM.mjs} +2 -2
- package/dist/chunk-HD2GE3DK.mjs +359 -0
- package/dist/chunk-HD2GE3DK.mjs.map +1 -0
- package/dist/{chunk-G7LYGERN.mjs → chunk-HJP2RX5R.mjs} +14 -81
- package/dist/chunk-HJP2RX5R.mjs.map +1 -0
- package/dist/{chunk-ADIITPD2.mjs → chunk-IVXB3GYK.mjs} +6 -9
- package/dist/{chunk-ADIITPD2.mjs.map → chunk-IVXB3GYK.mjs.map} +1 -1
- package/dist/{chunk-EF5BNM34.mjs → chunk-LDACFA2B.mjs} +3 -3
- package/dist/{chunk-UBNRUXEK.mjs → chunk-LZDDYZEY.mjs} +2 -2
- package/dist/{chunk-FXK6RQIN.mjs → chunk-PUNALT2S.mjs} +2 -2
- package/dist/{chunk-CMQV4XNY.mjs → chunk-Q5D5XQFA.mjs} +2 -2
- package/dist/{chunk-SJJNFYGQ.mjs → chunk-QQZLIEXK.mjs} +3 -3
- package/dist/{chunk-JDEWNLNP.mjs → chunk-QRGDQSGZ.mjs} +5 -38
- package/dist/chunk-QRGDQSGZ.mjs.map +1 -0
- package/dist/{chunk-55QZ2SVJ.mjs → chunk-RUY6MLHA.mjs} +6 -36
- package/dist/chunk-RUY6MLHA.mjs.map +1 -0
- package/dist/{chunk-NQVCZQ5T.mjs → chunk-T42PN5VN.mjs} +4 -4
- package/dist/{chunk-ERXWDCY6.mjs → chunk-UHQMV2CE.mjs} +2 -2
- package/dist/chunk-VRXANACV.mjs +277 -0
- package/dist/chunk-VRXANACV.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +3 -37
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.d.ts +2 -21
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
- package/dist/components/copilot-provider/copilotkit.js +238 -326
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +8 -8
- package/dist/components/copilot-provider/index.d.ts +1 -1
- package/dist/components/copilot-provider/index.js +238 -326
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +8 -8
- package/dist/components/error-boundary/error-boundary.js +146 -135
- 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.d.ts +1 -1
- package/dist/components/index.js +238 -326
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -8
- package/dist/components/toast/toast-provider.js +85 -118
- 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 +146 -135
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +1 -1
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +1 -2
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +1 -2
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{copilot-context-3da805ab.d.ts → copilot-context-f9b2b4c3.d.ts} +1 -5
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +12 -108
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +19 -19
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +12 -105
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +5 -5
- package/dist/hooks/use-coagent-state-render.js +1 -2
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +3 -3
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +12 -108
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +11 -11
- package/dist/hooks/use-copilot-action.js +1 -2
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -4
- package/dist/hooks/use-copilot-additional-instructions.js +1 -2
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +1 -2
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
- package/dist/hooks/use-copilot-chat.d.ts +1 -1
- package/dist/hooks/use-copilot-chat.js +12 -105
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +10 -10
- package/dist/hooks/use-copilot-readable.js +1 -2
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-copilot-runtime-client.d.ts +0 -2
- package/dist/hooks/use-copilot-runtime-client.js +2 -52
- 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-render.js +1 -2
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
- package/dist/hooks/use-langgraph-interrupt.js +12 -105
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +11 -11
- package/dist/hooks/use-make-copilot-document-readable.js +1 -2
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +247 -400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +9 -9
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -9
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/utils/extract.d.ts +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +8 -8
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +8 -8
- package/dist/utils/utils.test.d.ts +2 -0
- package/dist/utils/utils.test.js +9 -0
- package/dist/utils/utils.test.js.map +1 -0
- package/dist/utils/utils.test.mjs +7 -0
- package/dist/utils/utils.test.mjs.map +1 -0
- package/jest.config.js +3 -7
- package/package.json +3 -4
- package/src/components/copilot-provider/copilot-messages.tsx +3 -42
- package/src/components/copilot-provider/copilotkit-props.tsx +0 -21
- package/src/components/copilot-provider/copilotkit.tsx +0 -2
- package/src/components/toast/toast-provider.tsx +24 -49
- package/src/components/usage-banner.tsx +147 -144
- package/src/context/copilot-context.tsx +1 -7
- package/src/hooks/use-chat.ts +6 -106
- package/src/hooks/use-coagent.ts +0 -5
- package/src/hooks/use-copilot-runtime-client.ts +39 -41
- package/tsconfig.json +8 -1
- package/tsup.config.ts +6 -6
- package/dist/chunk-55QZ2SVJ.mjs.map +0 -1
- package/dist/chunk-57K2ZJ5F.mjs +0 -348
- package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
- package/dist/chunk-G7LYGERN.mjs.map +0 -1
- package/dist/chunk-JDEWNLNP.mjs.map +0 -1
- package/dist/chunk-WOGURSAL.mjs.map +0 -1
- package/dist/chunk-XFOTNHYA.mjs.map +0 -1
- package/dist/chunk-YAF2LATQ.mjs +0 -310
- package/dist/chunk-YAF2LATQ.mjs.map +0 -1
- package/src/components/copilot-provider/__tests__/copilotkit-trace.test.tsx +0 -75
- /package/dist/{chunk-3YHYWAHK.mjs.map → chunk-2FW7HH6W.mjs.map} +0 -0
- /package/dist/{chunk-OF4SZTLL.mjs.map → chunk-2XSUXRGG.mjs.map} +0 -0
- /package/dist/{chunk-EXU7GWLC.mjs.map → chunk-C3SYYVMR.mjs.map} +0 -0
- /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
- /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-CCESTGAM.mjs.map} +0 -0
- /package/dist/{chunk-EF5BNM34.mjs.map → chunk-LDACFA2B.mjs.map} +0 -0
- /package/dist/{chunk-UBNRUXEK.mjs.map → chunk-LZDDYZEY.mjs.map} +0 -0
- /package/dist/{chunk-FXK6RQIN.mjs.map → chunk-PUNALT2S.mjs.map} +0 -0
- /package/dist/{chunk-CMQV4XNY.mjs.map → chunk-Q5D5XQFA.mjs.map} +0 -0
- /package/dist/{chunk-SJJNFYGQ.mjs.map → chunk-QQZLIEXK.mjs.map} +0 -0
- /package/dist/{chunk-NQVCZQ5T.mjs.map → chunk-T42PN5VN.mjs.map} +0 -0
- /package/dist/{chunk-ERXWDCY6.mjs.map → chunk-UHQMV2CE.mjs.map} +0 -0
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
import "../chunk-CQPYJIBH.mjs";
|
|
2
2
|
import {
|
|
3
3
|
useLangGraphInterruptRender
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-Q5D5XQFA.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useLangGraphInterrupt
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-2XSUXRGG.mjs";
|
|
8
8
|
import {
|
|
9
9
|
useMakeCopilotDocumentReadable
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-UHQMV2CE.mjs";
|
|
11
11
|
import {
|
|
12
12
|
useCoAgentStateRender
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-2FW7HH6W.mjs";
|
|
14
14
|
import {
|
|
15
15
|
runAgent,
|
|
16
16
|
startAgent,
|
|
17
17
|
stopAgent,
|
|
18
18
|
useCoAgent
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-IVXB3GYK.mjs";
|
|
20
20
|
import {
|
|
21
21
|
useCopilotAdditionalInstructions
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-C6F6EQNA.mjs";
|
|
23
23
|
import {
|
|
24
24
|
useCopilotAuthenticatedAction_c
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-LDACFA2B.mjs";
|
|
26
26
|
import {
|
|
27
27
|
useCopilotAction
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-T42PN5VN.mjs";
|
|
29
29
|
import {
|
|
30
30
|
useCopilotChat
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-C3SYYVMR.mjs";
|
|
32
32
|
import {
|
|
33
33
|
useCopilotReadable
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import "../chunk-
|
|
36
|
-
import "../chunk-
|
|
37
|
-
import "../chunk-
|
|
34
|
+
} from "../chunk-LZDDYZEY.mjs";
|
|
35
|
+
import "../chunk-3XXVDQ7Z.mjs";
|
|
36
|
+
import "../chunk-QQZLIEXK.mjs";
|
|
37
|
+
import "../chunk-QRGDQSGZ.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-HD2GE3DK.mjs";
|
|
42
42
|
import "../chunk-YPSGKPDA.mjs";
|
|
43
43
|
import "../chunk-DCTJZ742.mjs";
|
|
44
|
-
import "../chunk-
|
|
44
|
+
import "../chunk-HJP2RX5R.mjs";
|
|
45
45
|
import "../chunk-4CEQJ2X6.mjs";
|
|
46
|
-
import "../chunk-
|
|
46
|
+
import "../chunk-CCESTGAM.mjs";
|
|
47
47
|
import "../chunk-O7ARI5CV.mjs";
|
|
48
48
|
import {
|
|
49
49
|
useCopilotRuntimeClient
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-RUY6MLHA.mjs";
|
|
51
51
|
import "../chunk-GFJW4RIM.mjs";
|
|
52
|
-
import "../chunk-
|
|
53
|
-
import "../chunk-
|
|
52
|
+
import "../chunk-VRXANACV.mjs";
|
|
53
|
+
import "../chunk-6KGEF242.mjs";
|
|
54
54
|
import "../chunk-SKC7AJIV.mjs";
|
|
55
55
|
export {
|
|
56
56
|
runAgent,
|
package/dist/hooks/use-chat.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FunctionCallHandler, CoAgentStateRenderHandler } from '@copilotkit/shared';
|
|
3
3
|
import { Message, TextMessage, ForwardedParametersInput, ExtensionsInput } from '@copilotkit/runtime-client-gql';
|
|
4
|
-
import { c as CopilotApiConfig, A as AgentSession, L as LangGraphInterruptAction, d as LangGraphInterruptActionSetter } from '../copilot-context-
|
|
4
|
+
import { c as CopilotApiConfig, A as AgentSession, L as LangGraphInterruptAction, d as LangGraphInterruptActionSetter } from '../copilot-context-f9b2b4c3.js';
|
|
5
5
|
import { FrontendAction } from '../types/frontend-action.js';
|
|
6
6
|
import { CoagentState } from '../types/coagent-state.js';
|
|
7
7
|
import './use-tree.js';
|
package/dist/hooks/use-chat.js
CHANGED
|
@@ -139,35 +139,8 @@ function shouldShowDevConsole(showDevConsole) {
|
|
|
139
139
|
// src/hooks/use-copilot-runtime-client.ts
|
|
140
140
|
var useCopilotRuntimeClient = (options) => {
|
|
141
141
|
const { setBannerError } = useToast();
|
|
142
|
-
const _a = options, { showDevConsole
|
|
142
|
+
const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
|
|
143
143
|
const lastStructuredErrorRef = (0, import_react2.useRef)(null);
|
|
144
|
-
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
145
|
-
if (!onTrace || !runtimeOptions.publicApiKey)
|
|
146
|
-
return;
|
|
147
|
-
try {
|
|
148
|
-
const traceEvent = {
|
|
149
|
-
type: "error",
|
|
150
|
-
timestamp: Date.now(),
|
|
151
|
-
context: {
|
|
152
|
-
source: "ui",
|
|
153
|
-
request: {
|
|
154
|
-
operation: "runtimeClient",
|
|
155
|
-
url: runtimeOptions.url,
|
|
156
|
-
startTime: Date.now()
|
|
157
|
-
},
|
|
158
|
-
technical: {
|
|
159
|
-
environment: "browser",
|
|
160
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
161
|
-
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
error
|
|
165
|
-
};
|
|
166
|
-
yield onTrace(traceEvent);
|
|
167
|
-
} catch (traceError) {
|
|
168
|
-
console.error("Error in onTrace handler:", traceError);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
144
|
const runtimeClient = (0, import_react2.useMemo)(() => {
|
|
172
145
|
return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
173
146
|
handleGQLErrors: (error) => {
|
|
@@ -195,14 +168,12 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
195
168
|
const ckError = createStructuredError(gqlError);
|
|
196
169
|
if (ckError) {
|
|
197
170
|
setBannerError(ckError);
|
|
198
|
-
traceUIError(ckError, gqlError);
|
|
199
171
|
} else {
|
|
200
172
|
const fallbackError = new import_shared3.CopilotKitError({
|
|
201
173
|
message: gqlError.message,
|
|
202
174
|
code: import_shared3.CopilotKitErrorCode.UNKNOWN
|
|
203
175
|
});
|
|
204
176
|
setBannerError(fallbackError);
|
|
205
|
-
traceUIError(fallbackError, gqlError);
|
|
206
177
|
}
|
|
207
178
|
};
|
|
208
179
|
graphQLErrors.forEach(routeError);
|
|
@@ -216,7 +187,6 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
216
187
|
code: import_shared3.CopilotKitErrorCode.UNKNOWN
|
|
217
188
|
});
|
|
218
189
|
setBannerError(fallbackError);
|
|
219
|
-
traceUIError(fallbackError, error);
|
|
220
190
|
}
|
|
221
191
|
}
|
|
222
192
|
},
|
|
@@ -229,7 +199,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
229
199
|
setBannerError(warningError);
|
|
230
200
|
}
|
|
231
201
|
}));
|
|
232
|
-
}, [runtimeOptions, setBannerError, showDevConsole
|
|
202
|
+
}, [runtimeOptions, setBannerError, showDevConsole]);
|
|
233
203
|
return runtimeClient;
|
|
234
204
|
};
|
|
235
205
|
function createStructuredError(gqlError) {
|
|
@@ -329,8 +299,7 @@ var emptyCopilotContext = {
|
|
|
329
299
|
},
|
|
330
300
|
langGraphInterruptAction: null,
|
|
331
301
|
setLangGraphInterruptAction: () => null,
|
|
332
|
-
removeLangGraphInterruptAction: () => null
|
|
333
|
-
onTrace: void 0
|
|
302
|
+
removeLangGraphInterruptAction: () => null
|
|
334
303
|
};
|
|
335
304
|
var CopilotContext = import_react3.default.createContext(emptyCopilotContext);
|
|
336
305
|
function useCopilotContext() {
|
|
@@ -489,35 +458,6 @@ function useChat(options) {
|
|
|
489
458
|
} = options;
|
|
490
459
|
const runChatCompletionRef = (0, import_react5.useRef)();
|
|
491
460
|
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
|
-
});
|
|
521
461
|
const agentSessionRef = (0, import_react5.useRef)(agentSession);
|
|
522
462
|
agentSessionRef.current = agentSession;
|
|
523
463
|
const runIdRef = (0, import_react5.useRef)(runId);
|
|
@@ -537,7 +477,7 @@ function useChat(options) {
|
|
|
537
477
|
const pendingAppendsRef = (0, import_react5.useRef)([]);
|
|
538
478
|
const runChatCompletion = useAsyncCallback(
|
|
539
479
|
(previousMessages) => __async(this, null, function* () {
|
|
540
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o
|
|
480
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
541
481
|
setIsLoading(true);
|
|
542
482
|
const interruptEvent = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event;
|
|
543
483
|
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) {
|
|
@@ -669,53 +609,20 @@ function useChat(options) {
|
|
|
669
609
|
messages2 = (0, import_runtime_client_gql3.convertGqlOutputToMessages)(
|
|
670
610
|
(0, import_runtime_client_gql3.filterAdjacentAgentStateMessages)(rawMessagesResponse)
|
|
671
611
|
);
|
|
612
|
+
if (messages2.length === 0) {
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
672
615
|
newMessages = [];
|
|
673
616
|
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) || "";
|
|
675
617
|
newMessages = [
|
|
676
618
|
new import_runtime_client_gql3.TextMessage({
|
|
677
619
|
role: import_runtime_client_gql3.MessageRole.Assistant,
|
|
678
|
-
content: guardrailsReason
|
|
620
|
+
content: ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || ""
|
|
679
621
|
})
|
|
680
622
|
];
|
|
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
|
-
});
|
|
689
623
|
setMessages([...previousMessages, ...newMessages]);
|
|
690
624
|
break;
|
|
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) {
|
|
625
|
+
} else {
|
|
719
626
|
newMessages = [...messages2];
|
|
720
627
|
for (const message of messages2) {
|
|
721
628
|
if (message.isAgentStateMessage() && !message.active && !executedCoAgentStateRenders.includes(message.id) && onCoAgentStateRender) {
|
|
@@ -846,11 +753,11 @@ function useChat(options) {
|
|
|
846
753
|
followUp !== false && // and we executed an action
|
|
847
754
|
(didExecuteAction || // the last message is a server side result
|
|
848
755
|
!isAgentRun && finalMessages.length && finalMessages[finalMessages.length - 1].isResultMessage()) && // the user did not stop generation
|
|
849
|
-
!((
|
|
756
|
+
!((_m = chatAbortControllerRef.current) == null ? void 0 : _m.signal.aborted)
|
|
850
757
|
) {
|
|
851
758
|
yield new Promise((resolve) => setTimeout(resolve, 10));
|
|
852
759
|
return yield runChatCompletionRef.current(finalMessages);
|
|
853
|
-
} else if ((
|
|
760
|
+
} else if ((_n = chatAbortControllerRef.current) == null ? void 0 : _n.signal.aborted) {
|
|
854
761
|
const repairedMessages = finalMessages.filter((message, actionExecutionIndex) => {
|
|
855
762
|
if (message.isActionExecutionMessage()) {
|
|
856
763
|
return finalMessages.find(
|
|
@@ -861,7 +768,7 @@ function useChat(options) {
|
|
|
861
768
|
});
|
|
862
769
|
const repairedMessageIds = repairedMessages.map((message) => message.id);
|
|
863
770
|
setMessages(repairedMessages);
|
|
864
|
-
if ((
|
|
771
|
+
if ((_o = agentSessionRef.current) == null ? void 0 : _o.nodeName) {
|
|
865
772
|
setAgentSession({
|
|
866
773
|
threadId: agentSessionRef.current.threadId,
|
|
867
774
|
agentName: agentSessionRef.current.agentName,
|