@copilotkit/react-core 1.9.1 → 1.9.2-next.1
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 +16 -0
- package/dist/{chunk-B5UA5G3E.mjs → chunk-2FW7HH6W.mjs} +12 -8
- package/dist/chunk-2FW7HH6W.mjs.map +1 -0
- package/dist/{chunk-ERFA53MG.mjs → chunk-6KGEF242.mjs} +2 -2
- package/dist/chunk-6KGEF242.mjs.map +1 -0
- package/dist/{chunk-2J3SMMGW.mjs → chunk-C6F6EQNA.mjs} +2 -2
- package/dist/chunk-CCESTGAM.mjs +102 -0
- package/dist/chunk-CCESTGAM.mjs.map +1 -0
- package/dist/chunk-GFJW4RIM.mjs +9 -0
- package/dist/chunk-GFJW4RIM.mjs.map +1 -0
- package/dist/chunk-HD2GE3DK.mjs +359 -0
- package/dist/chunk-HD2GE3DK.mjs.map +1 -0
- package/dist/{chunk-74AJEJTV.mjs → chunk-HJP2RX5R.mjs} +11 -6
- package/dist/chunk-HJP2RX5R.mjs.map +1 -0
- package/dist/{chunk-EQ4XLLT4.mjs → chunk-LDACFA2B.mjs} +3 -3
- package/dist/{chunk-FGBRHBRR.mjs → chunk-LZDDYZEY.mjs} +2 -2
- package/dist/chunk-NNSXCFQO.mjs +154 -0
- package/dist/chunk-NNSXCFQO.mjs.map +1 -0
- package/dist/{chunk-WZAEVHLK.mjs → chunk-Q5D5XQFA.mjs} +2 -2
- package/dist/{chunk-534J55RX.mjs → chunk-QQZLIEXK.mjs} +9 -7
- package/dist/chunk-QQZLIEXK.mjs.map +1 -0
- package/dist/chunk-RUY6MLHA.mjs +119 -0
- package/dist/chunk-RUY6MLHA.mjs.map +1 -0
- package/dist/{chunk-MDIIRGJD.mjs → chunk-SGLWMQ2J.mjs} +25 -17
- package/dist/chunk-SGLWMQ2J.mjs.map +1 -0
- package/dist/{chunk-G27C5EFO.mjs → chunk-T42PN5VN.mjs} +7 -5
- package/dist/{chunk-G27C5EFO.mjs.map → chunk-T42PN5VN.mjs.map} +1 -1
- package/dist/{chunk-VQ3VTO26.mjs → chunk-UHQMV2CE.mjs} +2 -2
- package/dist/{chunk-4DVPRMVH.mjs → chunk-UIT6QMUJ.mjs} +7 -7
- package/dist/chunk-VRXANACV.mjs +277 -0
- package/dist/chunk-VRXANACV.mjs.map +1 -0
- package/dist/{chunk-2FLZLANO.mjs → chunk-XY5BN4HZ.mjs} +19 -12
- package/dist/chunk-XY5BN4HZ.mjs.map +1 -0
- package/dist/{chunk-7HDYPEWS.mjs → chunk-YDENFEKA.mjs} +2 -2
- package/dist/{chunk-4VWM6JNK.mjs → chunk-YZDRMIOM.mjs} +6 -6
- package/dist/components/copilot-provider/copilot-messages.js +105 -11
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +4 -2
- package/dist/components/copilot-provider/copilotkit-props.d.ts +4 -3
- 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 +863 -441
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +10 -9
- package/dist/components/copilot-provider/index.d.ts +1 -1
- package/dist/components/copilot-provider/index.js +863 -441
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +10 -9
- package/dist/components/error-boundary/error-boundary.js +320 -159
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +4 -3
- package/dist/components/error-boundary/error-utils.js +2 -1
- package/dist/components/error-boundary/error-utils.js.map +1 -1
- package/dist/components/error-boundary/error-utils.mjs +2 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +863 -441
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -9
- package/dist/components/toast/toast-provider.d.ts +9 -12
- package/dist/components/toast/toast-provider.js +218 -191
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -2
- package/dist/components/usage-banner.d.ts +3 -2
- package/dist/components/usage-banner.js +311 -153
- 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 -1
- 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 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{copilot-context-309906bb.d.ts → copilot-context-f9b2b4c3.d.ts} +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +160 -75
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +33 -32
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +243 -68
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +6 -3
- package/dist/hooks/use-coagent-state-render.js +10 -5
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +3 -4
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +148 -67
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +14 -13
- package/dist/hooks/use-copilot-action.js +5 -4
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -3
- package/dist/hooks/use-copilot-additional-instructions.js +1 -1
- 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 +5 -4
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +5 -4
- package/dist/hooks/use-copilot-chat.d.ts +1 -1
- package/dist/hooks/use-copilot-chat.js +138 -62
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +13 -12
- package/dist/hooks/use-copilot-readable.js +1 -1
- 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 +5 -2
- package/dist/hooks/use-copilot-runtime-client.js +101 -128
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +3 -3
- package/dist/hooks/use-langgraph-interrupt-render.js +1 -1
- 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 +140 -64
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +14 -13
- package/dist/hooks/use-make-copilot-document-readable.js +1 -1
- 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 +913 -480
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -34
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +11 -10
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +11 -10
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/utils/dev-console.d.ts +1 -1
- package/dist/utils/dev-console.js +1 -10
- package/dist/utils/dev-console.js.map +1 -1
- package/dist/utils/dev-console.mjs +1 -1
- package/dist/utils/extract.d.ts +1 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +10 -9
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +7 -14
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +12 -11
- package/package.json +3 -3
- package/src/components/copilot-provider/copilot-messages.tsx +163 -4
- package/src/components/copilot-provider/copilotkit-props.tsx +3 -2
- package/src/components/copilot-provider/copilotkit.tsx +8 -2
- package/src/components/error-boundary/error-boundary.tsx +6 -5
- package/src/components/error-boundary/error-utils.tsx +1 -1
- package/src/components/toast/toast-provider.tsx +260 -93
- package/src/components/usage-banner.tsx +311 -131
- package/src/context/copilot-context.tsx +2 -2
- package/src/hooks/use-chat.ts +4 -0
- package/src/hooks/use-coagent-state-render.ts +9 -3
- package/src/hooks/use-coagent.ts +10 -3
- package/src/hooks/use-copilot-runtime-client.ts +153 -12
- package/src/utils/dev-console.ts +2 -17
- package/dist/chunk-22ENANUU.mjs +0 -250
- package/dist/chunk-22ENANUU.mjs.map +0 -1
- package/dist/chunk-2FLZLANO.mjs.map +0 -1
- package/dist/chunk-534J55RX.mjs.map +0 -1
- package/dist/chunk-6PK72HMH.mjs +0 -63
- package/dist/chunk-6PK72HMH.mjs.map +0 -1
- package/dist/chunk-74AJEJTV.mjs.map +0 -1
- package/dist/chunk-B5UA5G3E.mjs.map +0 -1
- package/dist/chunk-BKTARDXX.mjs +0 -40
- package/dist/chunk-BKTARDXX.mjs.map +0 -1
- package/dist/chunk-D34OH4VN.mjs +0 -201
- package/dist/chunk-D34OH4VN.mjs.map +0 -1
- package/dist/chunk-ERFA53MG.mjs.map +0 -1
- package/dist/chunk-MDIIRGJD.mjs.map +0 -1
- package/dist/chunk-MLAS4QUR.mjs +0 -18
- package/dist/chunk-MLAS4QUR.mjs.map +0 -1
- /package/dist/{chunk-2J3SMMGW.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
- /package/dist/{chunk-EQ4XLLT4.mjs.map → chunk-LDACFA2B.mjs.map} +0 -0
- /package/dist/{chunk-FGBRHBRR.mjs.map → chunk-LZDDYZEY.mjs.map} +0 -0
- /package/dist/{chunk-WZAEVHLK.mjs.map → chunk-Q5D5XQFA.mjs.map} +0 -0
- /package/dist/{chunk-VQ3VTO26.mjs.map → chunk-UHQMV2CE.mjs.map} +0 -0
- /package/dist/{chunk-4DVPRMVH.mjs.map → chunk-UIT6QMUJ.mjs.map} +0 -0
- /package/dist/{chunk-7HDYPEWS.mjs.map → chunk-YDENFEKA.mjs.map} +0 -0
- /package/dist/{chunk-4VWM6JNK.mjs.map → chunk-YZDRMIOM.mjs.map} +0 -0
|
@@ -132,7 +132,7 @@ var emptyCopilotContext = {
|
|
|
132
132
|
},
|
|
133
133
|
removeChatSuggestionConfiguration: () => {
|
|
134
134
|
},
|
|
135
|
-
showDevConsole:
|
|
135
|
+
showDevConsole: false,
|
|
136
136
|
coagentStates: {},
|
|
137
137
|
setCoagentStates: () => {
|
|
138
138
|
},
|
|
@@ -177,7 +177,7 @@ var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
|
177
177
|
|
|
178
178
|
// src/hooks/use-chat.ts
|
|
179
179
|
var import_react5 = require("react");
|
|
180
|
-
var
|
|
180
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
181
181
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
182
182
|
|
|
183
183
|
// src/types/frontend-action.ts
|
|
@@ -209,17 +209,126 @@ function processActionsForRuntimeRequest(actions) {
|
|
|
209
209
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
210
210
|
|
|
211
211
|
// src/components/toast/toast-provider.tsx
|
|
212
|
+
var import_react2 = require("react");
|
|
213
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
214
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
215
|
+
var ToastContext = (0, import_react2.createContext)(void 0);
|
|
216
|
+
function useToast() {
|
|
217
|
+
const context = (0, import_react2.useContext)(ToastContext);
|
|
218
|
+
if (!context) {
|
|
219
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
220
|
+
}
|
|
221
|
+
return context;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/hooks/use-copilot-runtime-client.ts
|
|
212
225
|
var import_react3 = require("react");
|
|
226
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
227
|
+
|
|
228
|
+
// src/utils/dev-console.ts
|
|
229
|
+
function shouldShowDevConsole(showDevConsole) {
|
|
230
|
+
return showDevConsole;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/hooks/use-copilot-runtime-client.ts
|
|
234
|
+
var useCopilotRuntimeClient = (options) => {
|
|
235
|
+
const { setBannerError } = useToast();
|
|
236
|
+
const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
|
|
237
|
+
const lastStructuredErrorRef = (0, import_react3.useRef)(null);
|
|
238
|
+
const runtimeClient = (0, import_react3.useMemo)(() => {
|
|
239
|
+
return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
240
|
+
handleGQLErrors: (error) => {
|
|
241
|
+
var _a2;
|
|
242
|
+
if ((_a2 = error.graphQLErrors) == null ? void 0 : _a2.length) {
|
|
243
|
+
const graphQLErrors = error.graphQLErrors;
|
|
244
|
+
const routeError = (gqlError) => {
|
|
245
|
+
const extensions = gqlError.extensions;
|
|
246
|
+
const visibility = extensions == null ? void 0 : extensions.visibility;
|
|
247
|
+
const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
|
|
248
|
+
if (visibility === import_shared3.ErrorVisibility.SILENT) {
|
|
249
|
+
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (!isDev) {
|
|
253
|
+
console.error("CopilotKit Error (hidden in production):", gqlError.message);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const now = Date.now();
|
|
257
|
+
const errorMessage = gqlError.message;
|
|
258
|
+
if (lastStructuredErrorRef.current && lastStructuredErrorRef.current.message === errorMessage && now - lastStructuredErrorRef.current.timestamp < 150) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
lastStructuredErrorRef.current = { message: errorMessage, timestamp: now };
|
|
262
|
+
const ckError = createStructuredError(gqlError);
|
|
263
|
+
if (ckError) {
|
|
264
|
+
setBannerError(ckError);
|
|
265
|
+
} else {
|
|
266
|
+
const fallbackError = new import_shared3.CopilotKitError({
|
|
267
|
+
message: gqlError.message,
|
|
268
|
+
code: import_shared3.CopilotKitErrorCode.UNKNOWN
|
|
269
|
+
});
|
|
270
|
+
setBannerError(fallbackError);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
graphQLErrors.forEach(routeError);
|
|
274
|
+
} else {
|
|
275
|
+
const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
|
|
276
|
+
if (!isDev) {
|
|
277
|
+
console.error("CopilotKit Error (hidden in production):", error);
|
|
278
|
+
} else {
|
|
279
|
+
const fallbackError = new import_shared3.CopilotKitError({
|
|
280
|
+
message: (error == null ? void 0 : error.message) || String(error),
|
|
281
|
+
code: import_shared3.CopilotKitErrorCode.UNKNOWN
|
|
282
|
+
});
|
|
283
|
+
setBannerError(fallbackError);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
handleGQLWarning: (message) => {
|
|
288
|
+
console.warn(message);
|
|
289
|
+
const warningError = new import_shared3.CopilotKitError({
|
|
290
|
+
message,
|
|
291
|
+
code: import_shared3.CopilotKitErrorCode.UNKNOWN
|
|
292
|
+
});
|
|
293
|
+
setBannerError(warningError);
|
|
294
|
+
}
|
|
295
|
+
}));
|
|
296
|
+
}, [runtimeOptions, setBannerError, showDevConsole]);
|
|
297
|
+
return runtimeClient;
|
|
298
|
+
};
|
|
299
|
+
function createStructuredError(gqlError) {
|
|
300
|
+
var _a, _b, _c;
|
|
301
|
+
const extensions = gqlError.extensions;
|
|
302
|
+
const originalError = extensions == null ? void 0 : extensions.originalError;
|
|
303
|
+
const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
|
|
304
|
+
const code = extensions == null ? void 0 : extensions.code;
|
|
305
|
+
if (code) {
|
|
306
|
+
return new import_shared3.CopilotKitError({ message, code });
|
|
307
|
+
}
|
|
308
|
+
if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
|
|
309
|
+
return new import_shared3.CopilotKitApiDiscoveryError({ message });
|
|
310
|
+
}
|
|
311
|
+
if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
|
|
312
|
+
return new import_shared3.CopilotKitRemoteEndpointDiscoveryError({ message });
|
|
313
|
+
}
|
|
314
|
+
if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
|
|
315
|
+
return new import_shared3.CopilotKitAgentDiscoveryError({
|
|
316
|
+
agentName: "",
|
|
317
|
+
availableAgents: []
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
213
322
|
|
|
214
323
|
// src/components/error-boundary/error-utils.tsx
|
|
215
|
-
var
|
|
324
|
+
var import_react4 = require("react");
|
|
216
325
|
|
|
217
326
|
// src/components/toast/exclamation-mark-icon.tsx
|
|
218
|
-
var
|
|
327
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
219
328
|
var ExclamationMarkIcon = ({
|
|
220
329
|
className,
|
|
221
330
|
style
|
|
222
|
-
}) => /* @__PURE__ */ (0,
|
|
331
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
223
332
|
"svg",
|
|
224
333
|
{
|
|
225
334
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -234,23 +343,23 @@ var ExclamationMarkIcon = ({
|
|
|
234
343
|
className: `lucide lucide-circle-alert ${className ? className : ""}`,
|
|
235
344
|
style,
|
|
236
345
|
children: [
|
|
237
|
-
/* @__PURE__ */ (0,
|
|
238
|
-
/* @__PURE__ */ (0,
|
|
239
|
-
/* @__PURE__ */ (0,
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
|
|
240
349
|
]
|
|
241
350
|
}
|
|
242
351
|
);
|
|
243
352
|
|
|
244
353
|
// src/components/error-boundary/error-utils.tsx
|
|
245
354
|
var import_react_markdown = __toESM(require("react-markdown"));
|
|
246
|
-
var
|
|
355
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
247
356
|
function ErrorToast({ errors }) {
|
|
248
357
|
const errorsToRender = errors.map((error, idx) => {
|
|
249
358
|
var _a, _b, _c;
|
|
250
359
|
const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
|
|
251
360
|
const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
|
|
252
361
|
const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
|
|
253
|
-
return /* @__PURE__ */ (0,
|
|
362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
254
363
|
"div",
|
|
255
364
|
{
|
|
256
365
|
style: {
|
|
@@ -258,8 +367,8 @@ function ErrorToast({ errors }) {
|
|
|
258
367
|
marginBottom: 14
|
|
259
368
|
},
|
|
260
369
|
children: [
|
|
261
|
-
/* @__PURE__ */ (0,
|
|
262
|
-
code && /* @__PURE__ */ (0,
|
|
370
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
371
|
+
code && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
263
372
|
"div",
|
|
264
373
|
{
|
|
265
374
|
style: {
|
|
@@ -267,19 +376,19 @@ function ErrorToast({ errors }) {
|
|
|
267
376
|
marginBottom: 4
|
|
268
377
|
},
|
|
269
378
|
children: [
|
|
270
|
-
"Copilot
|
|
379
|
+
"Copilot Runtime Error:",
|
|
271
380
|
" ",
|
|
272
|
-
/* @__PURE__ */ (0,
|
|
381
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
273
382
|
]
|
|
274
383
|
}
|
|
275
384
|
),
|
|
276
|
-
/* @__PURE__ */ (0,
|
|
385
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_markdown.default, { children: message })
|
|
277
386
|
]
|
|
278
387
|
},
|
|
279
388
|
idx
|
|
280
389
|
);
|
|
281
390
|
});
|
|
282
|
-
return /* @__PURE__ */ (0,
|
|
391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
283
392
|
"div",
|
|
284
393
|
{
|
|
285
394
|
style: {
|
|
@@ -288,14 +397,14 @@ function ErrorToast({ errors }) {
|
|
|
288
397
|
},
|
|
289
398
|
children: [
|
|
290
399
|
errorsToRender,
|
|
291
|
-
/* @__PURE__ */ (0,
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
|
|
292
401
|
]
|
|
293
402
|
}
|
|
294
403
|
);
|
|
295
404
|
}
|
|
296
405
|
function useErrorToast() {
|
|
297
406
|
const { addToast } = useToast();
|
|
298
|
-
return (0,
|
|
407
|
+
return (0, import_react4.useCallback)(
|
|
299
408
|
(error) => {
|
|
300
409
|
const errorId = error.map((err) => {
|
|
301
410
|
var _a, _b;
|
|
@@ -307,7 +416,7 @@ function useErrorToast() {
|
|
|
307
416
|
type: "error",
|
|
308
417
|
id: errorId,
|
|
309
418
|
// Toast libraries typically dedupe by id
|
|
310
|
-
message: /* @__PURE__ */ (0,
|
|
419
|
+
message: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorToast, { errors: error })
|
|
311
420
|
});
|
|
312
421
|
},
|
|
313
422
|
[addToast]
|
|
@@ -315,7 +424,7 @@ function useErrorToast() {
|
|
|
315
424
|
}
|
|
316
425
|
function useAsyncCallback(callback, deps) {
|
|
317
426
|
const addErrorToast = useErrorToast();
|
|
318
|
-
return (0,
|
|
427
|
+
return (0, import_react4.useCallback)((...args) => __async(this, null, function* () {
|
|
319
428
|
try {
|
|
320
429
|
return yield callback(...args);
|
|
321
430
|
} catch (error) {
|
|
@@ -326,41 +435,6 @@ function useAsyncCallback(callback, deps) {
|
|
|
326
435
|
}), deps);
|
|
327
436
|
}
|
|
328
437
|
|
|
329
|
-
// src/components/toast/toast-provider.tsx
|
|
330
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
331
|
-
var ToastContext = (0, import_react3.createContext)(void 0);
|
|
332
|
-
function useToast() {
|
|
333
|
-
const context = (0, import_react3.useContext)(ToastContext);
|
|
334
|
-
if (!context) {
|
|
335
|
-
throw new Error("useToast must be used within a ToastProvider");
|
|
336
|
-
}
|
|
337
|
-
return context;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// src/hooks/use-copilot-runtime-client.ts
|
|
341
|
-
var import_react4 = require("react");
|
|
342
|
-
var useCopilotRuntimeClient = (options) => {
|
|
343
|
-
const { addGraphQLErrorsToast } = useToast();
|
|
344
|
-
const addErrorToast = useErrorToast();
|
|
345
|
-
const { addToast } = useToast();
|
|
346
|
-
const runtimeClient = (0, import_react4.useMemo)(() => {
|
|
347
|
-
return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, options), {
|
|
348
|
-
handleGQLErrors: (error) => {
|
|
349
|
-
if (error.graphQLErrors.length) {
|
|
350
|
-
addGraphQLErrorsToast(error.graphQLErrors);
|
|
351
|
-
} else {
|
|
352
|
-
addErrorToast([error]);
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
handleGQLWarning: (message) => {
|
|
356
|
-
console.warn(message);
|
|
357
|
-
addToast({ type: "warning", message });
|
|
358
|
-
}
|
|
359
|
-
}));
|
|
360
|
-
}, [options, addGraphQLErrorsToast, addToast]);
|
|
361
|
-
return runtimeClient;
|
|
362
|
-
};
|
|
363
|
-
|
|
364
438
|
// src/hooks/use-chat.ts
|
|
365
439
|
function useChat(options) {
|
|
366
440
|
const {
|
|
@@ -398,12 +472,14 @@ function useChat(options) {
|
|
|
398
472
|
const extensionsRef = (0, import_react5.useRef)(extensions);
|
|
399
473
|
extensionsRef.current = extensions;
|
|
400
474
|
const publicApiKey = copilotConfig.publicApiKey;
|
|
401
|
-
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [
|
|
475
|
+
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared4.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
476
|
+
const { showDevConsole } = useCopilotContext();
|
|
402
477
|
const runtimeClient = useCopilotRuntimeClient({
|
|
403
478
|
url: copilotConfig.chatApiEndpoint,
|
|
404
479
|
publicApiKey: copilotConfig.publicApiKey,
|
|
405
480
|
headers,
|
|
406
|
-
credentials: copilotConfig.credentials
|
|
481
|
+
credentials: copilotConfig.credentials,
|
|
482
|
+
showDevConsole
|
|
407
483
|
});
|
|
408
484
|
const pendingAppendsRef = (0, import_react5.useRef)([]);
|
|
409
485
|
const runChatCompletion = useAsyncCallback(
|
|
@@ -521,7 +597,7 @@ function useChat(options) {
|
|
|
521
597
|
(metaEvents != null ? metaEvents : []).forEach((ev) => {
|
|
522
598
|
if (ev.name === import_runtime_client_gql3.MetaEventName.LangGraphInterruptEvent) {
|
|
523
599
|
let eventValue = (0, import_runtime_client_gql3.langGraphInterruptEvent)(ev).value;
|
|
524
|
-
eventValue = (0,
|
|
600
|
+
eventValue = (0, import_shared4.parseJson)(eventValue, eventValue);
|
|
525
601
|
setLangGraphInterruptAction({
|
|
526
602
|
event: __spreadProps(__spreadValues({}, (0, import_runtime_client_gql3.langGraphInterruptEvent)(ev)), {
|
|
527
603
|
value: eventValue
|
|
@@ -595,7 +671,7 @@ function useChat(options) {
|
|
|
595
671
|
} else {
|
|
596
672
|
if (agentLock) {
|
|
597
673
|
setAgentSession({
|
|
598
|
-
threadId: (0,
|
|
674
|
+
threadId: (0, import_shared4.randomId)(),
|
|
599
675
|
agentName: agentLock,
|
|
600
676
|
nodeName: void 0
|
|
601
677
|
});
|
|
@@ -656,7 +732,7 @@ function useChat(options) {
|
|
|
656
732
|
if (pairedFeAction) {
|
|
657
733
|
const newExecutionMessage = new import_runtime_client_gql3.ActionExecutionMessage({
|
|
658
734
|
name: pairedFeAction.name,
|
|
659
|
-
arguments: (0,
|
|
735
|
+
arguments: (0, import_shared4.parseJson)(resultMessage.result, resultMessage.result),
|
|
660
736
|
status: message.status,
|
|
661
737
|
createdAt: message.createdAt,
|
|
662
738
|
parentMessageId: message.parentMessageId
|
|
@@ -666,7 +742,7 @@ function useChat(options) {
|
|
|
666
742
|
} else if (message.isResultMessage() && currentResultMessagePairedFeAction) {
|
|
667
743
|
const newExecutionMessage = new import_runtime_client_gql3.ActionExecutionMessage({
|
|
668
744
|
name: currentResultMessagePairedFeAction.name,
|
|
669
|
-
arguments: (0,
|
|
745
|
+
arguments: (0, import_shared4.parseJson)(message.result, message.result),
|
|
670
746
|
status: message.status,
|
|
671
747
|
createdAt: message.createdAt
|
|
672
748
|
});
|
|
@@ -904,7 +980,7 @@ function getPairedFeAction(actions, message) {
|
|
|
904
980
|
// src/components/copilot-provider/copilotkit.tsx
|
|
905
981
|
var import_react7 = require("react");
|
|
906
982
|
var import_react_dom = require("react-dom");
|
|
907
|
-
var
|
|
983
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
908
984
|
|
|
909
985
|
// src/context/copilot-messages-context.tsx
|
|
910
986
|
var import_react6 = __toESM(require("react"));
|
|
@@ -1142,13 +1218,13 @@ ${additionalInstructions}` : "");
|
|
|
1142
1218
|
}
|
|
1143
1219
|
|
|
1144
1220
|
// src/hooks/use-langgraph-interrupt.ts
|
|
1145
|
-
var
|
|
1221
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
1146
1222
|
function useLangGraphInterrupt(action, dependencies) {
|
|
1147
1223
|
var _a;
|
|
1148
1224
|
const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react9.useContext)(CopilotContext);
|
|
1149
1225
|
const { runChatCompletion } = useCopilotChat();
|
|
1150
1226
|
const { addToast } = useToast();
|
|
1151
|
-
const actionId = (0,
|
|
1227
|
+
const actionId = (0, import_shared6.dataToUUID)(JSON.stringify(action), "lgAction");
|
|
1152
1228
|
const hasAction = (0, import_react9.useMemo)(
|
|
1153
1229
|
() => Boolean(langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id),
|
|
1154
1230
|
[langGraphInterruptAction]
|