@copilotkit/react-core 1.5.19-next.0 → 1.5.19-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 +9 -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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.5.19-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0dd1ab9: - fix(errors): allow non copilotkit errors to pass to consumer app error boundary
|
|
8
|
+
- Updated dependencies [0dd1ab9]
|
|
9
|
+
- @copilotkit/shared@1.5.19-next.1
|
|
10
|
+
- @copilotkit/runtime-client-gql@1.5.19-next.1
|
|
11
|
+
|
|
3
12
|
## 1.5.19-next.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
// src/components/error-boundary/error-boundary.tsx
|
|
13
13
|
import React, { useEffect } from "react";
|
|
14
14
|
import { CopilotKitError } from "@copilotkit/shared";
|
|
15
|
+
import { COPILOT_CLOUD_ERROR_NAMES } from "@copilotkit/shared";
|
|
15
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
17
|
var statusChecker = new StatusChecker();
|
|
17
18
|
var CopilotErrorBoundary = class extends React.Component {
|
|
@@ -47,20 +48,23 @@ var CopilotErrorBoundary = class extends React.Component {
|
|
|
47
48
|
var _a, _b;
|
|
48
49
|
if (this.state.hasError) {
|
|
49
50
|
if (this.state.error instanceof CopilotKitError) {
|
|
50
|
-
|
|
51
|
+
if (COPILOT_CLOUD_ERROR_NAMES.includes(this.state.error.name)) {
|
|
52
|
+
return /* @__PURE__ */ jsx(ErrorToast, { error: this.state.error, children: renderCopilotKitUsage(this.state.error) });
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
+
this.props.children,
|
|
56
|
+
this.props.showUsageBanner && /* @__PURE__ */ jsx(
|
|
57
|
+
UsageBanner,
|
|
58
|
+
{
|
|
59
|
+
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
60
|
+
message: (_b = this.state.status) == null ? void 0 : _b.message
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
51
64
|
}
|
|
52
|
-
|
|
65
|
+
throw this.state.error;
|
|
53
66
|
}
|
|
54
|
-
return
|
|
55
|
-
this.props.children,
|
|
56
|
-
this.props.showUsageBanner ? /* @__PURE__ */ jsx(
|
|
57
|
-
UsageBanner,
|
|
58
|
-
{
|
|
59
|
-
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
60
|
-
message: (_b = this.state.status) == null ? void 0 : _b.message
|
|
61
|
-
}
|
|
62
|
-
) : null
|
|
63
|
-
] });
|
|
67
|
+
return this.props.children;
|
|
64
68
|
}
|
|
65
69
|
};
|
|
66
70
|
function ErrorToast({ error, children }) {
|
|
@@ -70,6 +74,8 @@ function ErrorToast({ error, children }) {
|
|
|
70
74
|
addErrorToast([error]);
|
|
71
75
|
}
|
|
72
76
|
}, [error, addErrorToast]);
|
|
77
|
+
if (!error)
|
|
78
|
+
throw error;
|
|
73
79
|
return children;
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -77,4 +83,4 @@ export {
|
|
|
77
83
|
CopilotErrorBoundary,
|
|
78
84
|
ErrorToast
|
|
79
85
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-534J55RX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/error-boundary/error-boundary.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { Severity, CopilotKitError } from \"@copilotkit/shared\";\nimport { StatusChecker } from \"../../lib/status-checker\";\nimport { renderCopilotKitUsage, UsageBanner } from \"../usage-banner\";\nimport { useErrorToast } from \"./error-utils\";\nimport { COPILOT_CLOUD_ERROR_NAMES } from \"@copilotkit/shared\";\n\nconst statusChecker = new StatusChecker();\n\ninterface Props {\n children: React.ReactNode;\n publicApiKey?: string;\n showUsageBanner?: boolean;\n}\n\ninterface State {\n hasError: boolean;\n error?: CopilotKitError;\n status?: {\n severity: Severity;\n message: string;\n };\n}\n\nexport class CopilotErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n hasError: false,\n };\n }\n\n static getDerivedStateFromError(error: CopilotKitError): State {\n return { hasError: true, error };\n }\n\n componentDidMount() {\n if (this.props.publicApiKey) {\n statusChecker.start(this.props.publicApiKey, (newStatus) => {\n this.setState((prevState) => {\n if (newStatus?.severity !== prevState.status?.severity) {\n return { status: newStatus ?? undefined };\n }\n return null;\n });\n });\n }\n }\n\n componentWillUnmount() {\n statusChecker.stop();\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error(\"CopilotKit Error:\", error, errorInfo);\n }\n\n render() {\n if (this.state.hasError) {\n if (this.state.error instanceof CopilotKitError) {\n // @ts-expect-error -- It's a copilotkit error at this state. Name is valid\n if (COPILOT_CLOUD_ERROR_NAMES.includes(this.state.error.name)) {\n return (\n <ErrorToast error={this.state.error}>\n {renderCopilotKitUsage(this.state.error)}\n </ErrorToast>\n );\n }\n\n return (\n <>\n {this.props.children}\n {this.props.showUsageBanner && (\n <UsageBanner\n severity={this.state.status?.severity}\n message={this.state.status?.message}\n />\n )}\n </>\n );\n }\n throw this.state.error;\n }\n\n return this.props.children;\n }\n}\n\nexport function ErrorToast({ error, children }: { error?: Error; children: React.ReactNode }) {\n const addErrorToast = useErrorToast();\n\n useEffect(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AAA,YAAC;AAAA;AAAA,cACC,WAAU,UAAK,MAAM,WAAX,mBAAmB;AAAA,cAC7B,UAAS,UAAK,MAAM,WAAX,mBAAmB;AAAA;AAAA,UAC9B;AAAA,WAEJ;AAAA,MAEJ;AACA,YAAM,KAAK,MAAM;AAAA,IACnB;AAEA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;AAEO,SAAS,WAAW,EAAE,OAAO,SAAS,GAAiD;AAC5F,QAAM,gBAAgB,cAAc;AAEpC,YAAU,MAAM;AACd,QAAI,OAAO;AACT,oBAAc,CAAC,KAAK,CAAC;AAAA,IACvB;AAAA,EACF,GAAG,CAAC,OAAO,aAAa,CAAC;AAEzB,MAAI,CAAC;AAAO,UAAM;AAClB,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OBGDZ7BM.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CopilotContext
|
|
6
6
|
} from "./chunk-ZM56S3LJ.mjs";
|
|
@@ -63,4 +63,4 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
63
63
|
export {
|
|
64
64
|
useLangGraphInterrupt
|
|
65
65
|
};
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-6C6ZNKSS.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotErrorBoundary
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-534J55RX.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CopilotMessages
|
|
6
6
|
} from "./chunk-5M47BILE.mjs";
|
|
@@ -527,4 +527,4 @@ export {
|
|
|
527
527
|
CopilotKitInternal,
|
|
528
528
|
defaultCopilotContextCategories
|
|
529
529
|
};
|
|
530
|
-
//# sourceMappingURL=chunk-
|
|
530
|
+
//# sourceMappingURL=chunk-7YXUCWXF.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OBGDZ7BM.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useCopilotContext
|
|
6
6
|
} from "./chunk-ZM56S3LJ.mjs";
|
|
@@ -187,4 +187,4 @@ export {
|
|
|
187
187
|
stopAgent,
|
|
188
188
|
runAgent
|
|
189
189
|
};
|
|
190
|
-
//# sourceMappingURL=chunk-
|
|
190
|
+
//# sourceMappingURL=chunk-DFNQGERN.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultCopilotContextCategories
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7YXUCWXF.mjs";
|
|
4
4
|
import {
|
|
5
5
|
processActionsForRuntimeRequest
|
|
6
6
|
} from "./chunk-XERJQUHA.mjs";
|
|
@@ -117,4 +117,4 @@ ${instructions}
|
|
|
117
117
|
export {
|
|
118
118
|
CopilotTask
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-JFCNSGNU.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultCopilotContextCategories
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7YXUCWXF.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useCopilotContext
|
|
6
6
|
} from "./chunk-ZM56S3LJ.mjs";
|
|
@@ -222,4 +222,4 @@ export {
|
|
|
222
222
|
useCopilotChat,
|
|
223
223
|
defaultSystemMessage
|
|
224
224
|
};
|
|
225
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-OBGDZ7BM.mjs.map
|
|
@@ -304,7 +304,7 @@ function setsHaveIntersection(setA, setB) {
|
|
|
304
304
|
|
|
305
305
|
// src/components/copilot-provider/copilotkit.tsx
|
|
306
306
|
var import_react_dom = require("react-dom");
|
|
307
|
-
var
|
|
307
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
308
308
|
|
|
309
309
|
// src/hooks/use-flat-category-store.ts
|
|
310
310
|
var import_react3 = require("react");
|
|
@@ -975,6 +975,7 @@ function renderCopilotKitUsage(error) {
|
|
|
975
975
|
}
|
|
976
976
|
|
|
977
977
|
// src/components/error-boundary/error-boundary.tsx
|
|
978
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
978
979
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
979
980
|
var statusChecker = new StatusChecker();
|
|
980
981
|
var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
@@ -1010,20 +1011,23 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
|
1010
1011
|
var _a, _b;
|
|
1011
1012
|
if (this.state.hasError) {
|
|
1012
1013
|
if (this.state.error instanceof import_shared5.CopilotKitError) {
|
|
1013
|
-
|
|
1014
|
+
if (import_shared6.COPILOT_CLOUD_ERROR_NAMES.includes(this.state.error.name)) {
|
|
1015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorToast2, { error: this.state.error, children: renderCopilotKitUsage(this.state.error) });
|
|
1016
|
+
}
|
|
1017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1018
|
+
this.props.children,
|
|
1019
|
+
this.props.showUsageBanner && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1020
|
+
UsageBanner,
|
|
1021
|
+
{
|
|
1022
|
+
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
1023
|
+
message: (_b = this.state.status) == null ? void 0 : _b.message
|
|
1024
|
+
}
|
|
1025
|
+
)
|
|
1026
|
+
] });
|
|
1014
1027
|
}
|
|
1015
|
-
|
|
1028
|
+
throw this.state.error;
|
|
1016
1029
|
}
|
|
1017
|
-
return
|
|
1018
|
-
this.props.children,
|
|
1019
|
-
this.props.showUsageBanner ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1020
|
-
UsageBanner,
|
|
1021
|
-
{
|
|
1022
|
-
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
1023
|
-
message: (_b = this.state.status) == null ? void 0 : _b.message
|
|
1024
|
-
}
|
|
1025
|
-
) : null
|
|
1026
|
-
] });
|
|
1030
|
+
return this.props.children;
|
|
1027
1031
|
}
|
|
1028
1032
|
};
|
|
1029
1033
|
function ErrorToast2({ error, children }) {
|
|
@@ -1033,6 +1037,8 @@ function ErrorToast2({ error, children }) {
|
|
|
1033
1037
|
addErrorToast([error]);
|
|
1034
1038
|
}
|
|
1035
1039
|
}, [error, addErrorToast]);
|
|
1040
|
+
if (!error)
|
|
1041
|
+
throw error;
|
|
1036
1042
|
return children;
|
|
1037
1043
|
}
|
|
1038
1044
|
|
|
@@ -1047,7 +1053,7 @@ function CopilotKit(_a) {
|
|
|
1047
1053
|
function CopilotKitInternal(cpkProps) {
|
|
1048
1054
|
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
1049
1055
|
validateProps(cpkProps);
|
|
1050
|
-
const chatApiEndpoint = props.runtimeUrl ||
|
|
1056
|
+
const chatApiEndpoint = props.runtimeUrl || import_shared7.COPILOT_CLOUD_CHAT_URL;
|
|
1051
1057
|
const [actions, setActions] = (0, import_react10.useState)({});
|
|
1052
1058
|
const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react10.useState)({});
|
|
1053
1059
|
const chatComponentsCache = (0, import_react10.useRef)({
|
|
@@ -1189,7 +1195,7 @@ ${nonDocumentStrings}`;
|
|
|
1189
1195
|
}
|
|
1190
1196
|
return acc;
|
|
1191
1197
|
}, {});
|
|
1192
|
-
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [
|
|
1198
|
+
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [import_shared7.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {}), authHeaders);
|
|
1193
1199
|
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
1194
1200
|
const runtimeClient = useCopilotRuntimeClient({
|
|
1195
1201
|
url: copilotApiConfig.chatApiEndpoint,
|
|
@@ -1241,7 +1247,7 @@ ${nonDocumentStrings}`;
|
|
|
1241
1247
|
};
|
|
1242
1248
|
}
|
|
1243
1249
|
const [agentSession, setAgentSession] = (0, import_react10.useState)(initialAgentSession);
|
|
1244
|
-
const [internalThreadId, setInternalThreadId] = (0, import_react10.useState)(props.threadId || (0,
|
|
1250
|
+
const [internalThreadId, setInternalThreadId] = (0, import_react10.useState)(props.threadId || (0, import_shared7.randomUUID)());
|
|
1245
1251
|
const setThreadId = (0, import_react10.useCallback)(
|
|
1246
1252
|
(value) => {
|
|
1247
1253
|
if (props.threadId) {
|
|
@@ -1363,10 +1369,10 @@ function formatFeatureName(featureName) {
|
|
|
1363
1369
|
function validateProps(props) {
|
|
1364
1370
|
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
1365
1371
|
if (!props.runtimeUrl && !props.publicApiKey) {
|
|
1366
|
-
throw new
|
|
1372
|
+
throw new import_shared7.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey'");
|
|
1367
1373
|
}
|
|
1368
1374
|
if (cloudFeatures.length > 0 && !props.publicApiKey) {
|
|
1369
|
-
throw new
|
|
1375
|
+
throw new import_shared7.MissingPublicApiKeyError(
|
|
1370
1376
|
`Missing required prop: 'publicApiKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
1371
1377
|
);
|
|
1372
1378
|
}
|