@copilotkit/react-core 1.5.19-next.0 → 1.5.19
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 +20 -0
- package/dist/{chunk-5K2FUI34.mjs → chunk-534J55RX.mjs} +19 -13
- package/dist/chunk-534J55RX.mjs.map +1 -0
- package/dist/{chunk-TI25S2SR.mjs → chunk-6C6ZNKSS.mjs} +2 -2
- package/dist/{chunk-DB25UMNI.mjs → chunk-7YXUCWXF.mjs} +2 -2
- package/dist/{chunk-7IYA4DNK.mjs → chunk-DFNQGERN.mjs} +2 -2
- package/dist/{chunk-WSOA4BGM.mjs → chunk-JFCNSGNU.mjs} +2 -2
- package/dist/{chunk-2RIS4N5Q.mjs → chunk-OBGDZ7BM.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit.js +24 -18
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +2 -2
- package/dist/components/copilot-provider/index.js +24 -18
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +2 -2
- package/dist/components/error-boundary/error-boundary.d.ts +1 -1
- package/dist/components/error-boundary/error-boundary.js +18 -12
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +1 -1
- package/dist/components/index.js +24 -18
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/hooks/index.mjs +5 -5
- package/dist/hooks/use-coagent.mjs +4 -4
- package/dist/hooks/use-copilot-chat.mjs +3 -3
- package/dist/hooks/use-langgraph-interrupt.mjs +4 -4
- package/dist/index.js +37 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/lib/copilot-task.mjs +3 -3
- package/dist/lib/index.mjs +3 -3
- package/dist/utils/extract.mjs +2 -2
- package/dist/utils/index.mjs +2 -2
- package/package.json +3 -3
- package/src/components/error-boundary/error-boundary.tsx +24 -13
- package/dist/chunk-5K2FUI34.mjs.map +0 -1
- /package/dist/{chunk-TI25S2SR.mjs.map → chunk-6C6ZNKSS.mjs.map} +0 -0
- /package/dist/{chunk-DB25UMNI.mjs.map → chunk-7YXUCWXF.mjs.map} +0 -0
- /package/dist/{chunk-7IYA4DNK.mjs.map → chunk-DFNQGERN.mjs.map} +0 -0
- /package/dist/{chunk-WSOA4BGM.mjs.map → chunk-JFCNSGNU.mjs.map} +0 -0
- /package/dist/{chunk-2RIS4N5Q.mjs.map → chunk-OBGDZ7BM.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -326,7 +326,7 @@ function setsHaveIntersection(setA, setB) {
|
|
|
326
326
|
|
|
327
327
|
// src/components/copilot-provider/copilotkit.tsx
|
|
328
328
|
var import_react_dom = require("react-dom");
|
|
329
|
-
var
|
|
329
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
330
330
|
|
|
331
331
|
// src/hooks/use-flat-category-store.ts
|
|
332
332
|
var import_react3 = require("react");
|
|
@@ -1152,6 +1152,7 @@ function renderCopilotKitUsage(error) {
|
|
|
1152
1152
|
}
|
|
1153
1153
|
|
|
1154
1154
|
// src/components/error-boundary/error-boundary.tsx
|
|
1155
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
1155
1156
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1156
1157
|
var statusChecker = new StatusChecker();
|
|
1157
1158
|
var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
@@ -1187,20 +1188,23 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
|
1187
1188
|
var _a, _b;
|
|
1188
1189
|
if (this.state.hasError) {
|
|
1189
1190
|
if (this.state.error instanceof import_shared6.CopilotKitError) {
|
|
1190
|
-
|
|
1191
|
+
if (import_shared7.COPILOT_CLOUD_ERROR_NAMES.includes(this.state.error.name)) {
|
|
1192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorToast2, { error: this.state.error, children: renderCopilotKitUsage(this.state.error) });
|
|
1193
|
+
}
|
|
1194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1195
|
+
this.props.children,
|
|
1196
|
+
this.props.showUsageBanner && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1197
|
+
UsageBanner,
|
|
1198
|
+
{
|
|
1199
|
+
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
1200
|
+
message: (_b = this.state.status) == null ? void 0 : _b.message
|
|
1201
|
+
}
|
|
1202
|
+
)
|
|
1203
|
+
] });
|
|
1191
1204
|
}
|
|
1192
|
-
|
|
1205
|
+
throw this.state.error;
|
|
1193
1206
|
}
|
|
1194
|
-
return
|
|
1195
|
-
this.props.children,
|
|
1196
|
-
this.props.showUsageBanner ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1197
|
-
UsageBanner,
|
|
1198
|
-
{
|
|
1199
|
-
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
1200
|
-
message: (_b = this.state.status) == null ? void 0 : _b.message
|
|
1201
|
-
}
|
|
1202
|
-
) : null
|
|
1203
|
-
] });
|
|
1207
|
+
return this.props.children;
|
|
1204
1208
|
}
|
|
1205
1209
|
};
|
|
1206
1210
|
function ErrorToast2({ error, children }) {
|
|
@@ -1210,6 +1214,8 @@ function ErrorToast2({ error, children }) {
|
|
|
1210
1214
|
addErrorToast([error]);
|
|
1211
1215
|
}
|
|
1212
1216
|
}, [error, addErrorToast]);
|
|
1217
|
+
if (!error)
|
|
1218
|
+
throw error;
|
|
1213
1219
|
return children;
|
|
1214
1220
|
}
|
|
1215
1221
|
|
|
@@ -1224,7 +1230,7 @@ function CopilotKit(_a) {
|
|
|
1224
1230
|
function CopilotKitInternal(cpkProps) {
|
|
1225
1231
|
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
1226
1232
|
validateProps(cpkProps);
|
|
1227
|
-
const chatApiEndpoint = props.runtimeUrl ||
|
|
1233
|
+
const chatApiEndpoint = props.runtimeUrl || import_shared8.COPILOT_CLOUD_CHAT_URL;
|
|
1228
1234
|
const [actions, setActions] = (0, import_react10.useState)({});
|
|
1229
1235
|
const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react10.useState)({});
|
|
1230
1236
|
const chatComponentsCache = (0, import_react10.useRef)({
|
|
@@ -1366,7 +1372,7 @@ ${nonDocumentStrings}`;
|
|
|
1366
1372
|
}
|
|
1367
1373
|
return acc;
|
|
1368
1374
|
}, {});
|
|
1369
|
-
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [
|
|
1375
|
+
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [import_shared8.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {}), authHeaders);
|
|
1370
1376
|
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
1371
1377
|
const runtimeClient = useCopilotRuntimeClient({
|
|
1372
1378
|
url: copilotApiConfig.chatApiEndpoint,
|
|
@@ -1418,7 +1424,7 @@ ${nonDocumentStrings}`;
|
|
|
1418
1424
|
};
|
|
1419
1425
|
}
|
|
1420
1426
|
const [agentSession, setAgentSession] = (0, import_react10.useState)(initialAgentSession);
|
|
1421
|
-
const [internalThreadId, setInternalThreadId] = (0, import_react10.useState)(props.threadId || (0,
|
|
1427
|
+
const [internalThreadId, setInternalThreadId] = (0, import_react10.useState)(props.threadId || (0, import_shared8.randomUUID)());
|
|
1422
1428
|
const setThreadId = (0, import_react10.useCallback)(
|
|
1423
1429
|
(value) => {
|
|
1424
1430
|
if (props.threadId) {
|
|
@@ -1540,10 +1546,10 @@ function formatFeatureName(featureName) {
|
|
|
1540
1546
|
function validateProps(props) {
|
|
1541
1547
|
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
1542
1548
|
if (!props.runtimeUrl && !props.publicApiKey) {
|
|
1543
|
-
throw new
|
|
1549
|
+
throw new import_shared8.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey'");
|
|
1544
1550
|
}
|
|
1545
1551
|
if (cloudFeatures.length > 0 && !props.publicApiKey) {
|
|
1546
|
-
throw new
|
|
1552
|
+
throw new import_shared8.MissingPublicApiKeyError(
|
|
1547
1553
|
`Missing required prop: 'publicApiKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
1548
1554
|
);
|
|
1549
1555
|
}
|
|
@@ -1555,12 +1561,12 @@ var import_runtime_client_gql8 = require("@copilotkit/runtime-client-gql");
|
|
|
1555
1561
|
|
|
1556
1562
|
// src/hooks/use-chat.ts
|
|
1557
1563
|
var import_react11 = require("react");
|
|
1558
|
-
var
|
|
1564
|
+
var import_shared10 = require("@copilotkit/shared");
|
|
1559
1565
|
var import_runtime_client_gql6 = require("@copilotkit/runtime-client-gql");
|
|
1560
1566
|
|
|
1561
1567
|
// src/types/frontend-action.ts
|
|
1562
1568
|
var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
1563
|
-
var
|
|
1569
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
1564
1570
|
function processActionsForRuntimeRequest(actions) {
|
|
1565
1571
|
const filteredActions = actions.filter(
|
|
1566
1572
|
(action) => action.available !== import_runtime_client_gql5.ActionInputAvailability.Disabled && action.disabled !== true && action.name !== "*"
|
|
@@ -1576,7 +1582,7 @@ function processActionsForRuntimeRequest(actions) {
|
|
|
1576
1582
|
return {
|
|
1577
1583
|
name: action.name,
|
|
1578
1584
|
description: action.description || "",
|
|
1579
|
-
jsonSchema: JSON.stringify((0,
|
|
1585
|
+
jsonSchema: JSON.stringify((0, import_shared9.actionParametersToJsonSchema)(action.parameters || [])),
|
|
1580
1586
|
available
|
|
1581
1587
|
};
|
|
1582
1588
|
});
|
|
@@ -1621,7 +1627,7 @@ function useChat(options) {
|
|
|
1621
1627
|
const extensionsRef = (0, import_react11.useRef)(extensions);
|
|
1622
1628
|
extensionsRef.current = extensions;
|
|
1623
1629
|
const publicApiKey = copilotConfig.publicApiKey;
|
|
1624
|
-
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [
|
|
1630
|
+
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared10.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
1625
1631
|
const runtimeClient = useCopilotRuntimeClient({
|
|
1626
1632
|
url: copilotConfig.chatApiEndpoint,
|
|
1627
1633
|
publicApiKey: copilotConfig.publicApiKey,
|
|
@@ -1802,7 +1808,7 @@ function useChat(options) {
|
|
|
1802
1808
|
} else {
|
|
1803
1809
|
if (agentLock) {
|
|
1804
1810
|
setAgentSession({
|
|
1805
|
-
threadId: (0,
|
|
1811
|
+
threadId: (0, import_shared10.randomId)(),
|
|
1806
1812
|
agentName: agentLock,
|
|
1807
1813
|
nodeName: void 0
|
|
1808
1814
|
});
|
|
@@ -2231,11 +2237,11 @@ ${additionalInstructions}` : "");
|
|
|
2231
2237
|
}
|
|
2232
2238
|
|
|
2233
2239
|
// src/hooks/use-copilot-action.ts
|
|
2234
|
-
var
|
|
2240
|
+
var import_shared11 = require("@copilotkit/shared");
|
|
2235
2241
|
var import_react13 = require("react");
|
|
2236
2242
|
function useCopilotAction(action, dependencies) {
|
|
2237
2243
|
const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
|
|
2238
|
-
const idRef = (0, import_react13.useRef)((0,
|
|
2244
|
+
const idRef = (0, import_react13.useRef)((0, import_shared11.randomId)());
|
|
2239
2245
|
const renderAndWaitRef = (0, import_react13.useRef)(null);
|
|
2240
2246
|
const { addToast } = useToast();
|
|
2241
2247
|
action = __spreadValues({}, action);
|
|
@@ -2337,7 +2343,7 @@ function isFrontendAction(action) {
|
|
|
2337
2343
|
|
|
2338
2344
|
// src/hooks/use-coagent-state-render.ts
|
|
2339
2345
|
var import_react14 = require("react");
|
|
2340
|
-
var
|
|
2346
|
+
var import_shared12 = require("@copilotkit/shared");
|
|
2341
2347
|
function useCoAgentStateRender(action, dependencies) {
|
|
2342
2348
|
const {
|
|
2343
2349
|
setCoAgentStateRender,
|
|
@@ -2346,7 +2352,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
2346
2352
|
chatComponentsCache,
|
|
2347
2353
|
availableAgents
|
|
2348
2354
|
} = (0, import_react14.useContext)(CopilotContext);
|
|
2349
|
-
const idRef = (0, import_react14.useRef)((0,
|
|
2355
|
+
const idRef = (0, import_react14.useRef)((0, import_shared12.randomId)());
|
|
2350
2356
|
const { addToast } = useToast();
|
|
2351
2357
|
(0, import_react14.useEffect)(() => {
|
|
2352
2358
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
@@ -2650,13 +2656,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
2650
2656
|
|
|
2651
2657
|
// src/hooks/use-langgraph-interrupt.ts
|
|
2652
2658
|
var import_react20 = require("react");
|
|
2653
|
-
var
|
|
2659
|
+
var import_shared13 = require("@copilotkit/shared");
|
|
2654
2660
|
function useLangGraphInterrupt(action, dependencies) {
|
|
2655
2661
|
var _a;
|
|
2656
2662
|
const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react20.useContext)(CopilotContext);
|
|
2657
2663
|
const { runChatCompletion } = useCopilotChat();
|
|
2658
2664
|
const { addToast } = useToast();
|
|
2659
|
-
const actionId = (0,
|
|
2665
|
+
const actionId = (0, import_shared13.dataToUUID)(JSON.stringify(action), "lgAction");
|
|
2660
2666
|
const hasAction = (0, import_react20.useMemo)(
|
|
2661
2667
|
() => Boolean(langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id),
|
|
2662
2668
|
[langGraphInterruptAction]
|
|
@@ -2698,7 +2704,7 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
2698
2704
|
|
|
2699
2705
|
// src/hooks/use-langgraph-interrupt-render.ts
|
|
2700
2706
|
var import_react21 = __toESM(require("react"));
|
|
2701
|
-
var
|
|
2707
|
+
var import_shared14 = require("@copilotkit/shared");
|
|
2702
2708
|
var InterruptRenderer = ({ event, result, render, resolve }) => {
|
|
2703
2709
|
return render({ event, result, resolve });
|
|
2704
2710
|
};
|
|
@@ -2717,7 +2723,7 @@ function useLangGraphInterruptRender() {
|
|
|
2717
2723
|
if (!langGraphInterruptAction || !langGraphInterruptAction.event || !langGraphInterruptAction.render)
|
|
2718
2724
|
return null;
|
|
2719
2725
|
const { render, handler, event, conditions } = langGraphInterruptAction;
|
|
2720
|
-
const conditionsMet = (0,
|
|
2726
|
+
const conditionsMet = (0, import_shared14.executeConditions)({ conditions, value: event.value });
|
|
2721
2727
|
if (!conditionsMet) {
|
|
2722
2728
|
return null;
|
|
2723
2729
|
}
|