@copilotkit/shared 1.9.1 → 1.9.2-next.0
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 +6 -0
- package/dist/{chunk-GW2WLY4D.mjs → chunk-KDQB62ME.mjs} +71 -24
- package/dist/chunk-KDQB62ME.mjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +72 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/utils/errors.d.ts +34 -4
- package/dist/utils/errors.js +72 -23
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/errors.mjs +5 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +72 -23
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +5 -1
- package/package.json +3 -3
- package/src/utils/errors.ts +64 -11
- package/dist/chunk-GW2WLY4D.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -24,16 +24,25 @@ function isMacOS() {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// package.json
|
|
27
|
-
var version = "1.9.
|
|
27
|
+
var version = "1.9.2-next.0";
|
|
28
28
|
|
|
29
29
|
// src/index.ts
|
|
30
30
|
var COPILOTKIT_VERSION = version;
|
|
31
31
|
|
|
32
32
|
// src/utils/errors.ts
|
|
33
33
|
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
34
|
-
Severity2["
|
|
34
|
+
Severity2["CRITICAL"] = "critical";
|
|
35
|
+
Severity2["WARNING"] = "warning";
|
|
36
|
+
Severity2["INFO"] = "info";
|
|
35
37
|
return Severity2;
|
|
36
38
|
})(Severity || {});
|
|
39
|
+
var ErrorVisibility = /* @__PURE__ */ ((ErrorVisibility2) => {
|
|
40
|
+
ErrorVisibility2["BANNER"] = "banner";
|
|
41
|
+
ErrorVisibility2["TOAST"] = "toast";
|
|
42
|
+
ErrorVisibility2["SILENT"] = "silent";
|
|
43
|
+
ErrorVisibility2["DEV_ONLY"] = "dev_only";
|
|
44
|
+
return ErrorVisibility2;
|
|
45
|
+
})(ErrorVisibility || {});
|
|
37
46
|
var ERROR_NAMES = {
|
|
38
47
|
COPILOT_ERROR: "CopilotError",
|
|
39
48
|
COPILOT_API_DISCOVERY_ERROR: "CopilotApiDiscoveryError",
|
|
@@ -46,11 +55,15 @@ var ERROR_NAMES = {
|
|
|
46
55
|
MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
|
|
47
56
|
UPGRADE_REQUIRED_ERROR: "UpgradeRequiredError"
|
|
48
57
|
};
|
|
49
|
-
var
|
|
58
|
+
var BANNER_ERROR_NAMES = [
|
|
50
59
|
ERROR_NAMES.CONFIGURATION_ERROR,
|
|
51
60
|
ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR,
|
|
52
|
-
ERROR_NAMES.UPGRADE_REQUIRED_ERROR
|
|
61
|
+
ERROR_NAMES.UPGRADE_REQUIRED_ERROR,
|
|
62
|
+
ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR,
|
|
63
|
+
ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR,
|
|
64
|
+
ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR
|
|
53
65
|
];
|
|
66
|
+
var COPILOT_CLOUD_ERROR_NAMES = BANNER_ERROR_NAMES;
|
|
54
67
|
var CopilotKitErrorCode = /* @__PURE__ */ ((CopilotKitErrorCode2) => {
|
|
55
68
|
CopilotKitErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
56
69
|
CopilotKitErrorCode2["NOT_FOUND"] = "NOT_FOUND";
|
|
@@ -70,69 +83,101 @@ var getSeeMoreMarkdown = (link) => `See more: [${link}](${link})`;
|
|
|
70
83
|
var ERROR_CONFIG = {
|
|
71
84
|
["NETWORK_ERROR" /* NETWORK_ERROR */]: {
|
|
72
85
|
statusCode: 503,
|
|
73
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found
|
|
86
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,
|
|
87
|
+
visibility: "toast" /* TOAST */,
|
|
88
|
+
severity: "info" /* INFO */
|
|
74
89
|
},
|
|
75
90
|
["NOT_FOUND" /* NOT_FOUND */]: {
|
|
76
91
|
statusCode: 404,
|
|
77
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found
|
|
92
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,
|
|
93
|
+
visibility: "toast" /* TOAST */,
|
|
94
|
+
severity: "info" /* INFO */
|
|
78
95
|
},
|
|
79
96
|
["AGENT_NOT_FOUND" /* AGENT_NOT_FOUND */]: {
|
|
80
97
|
statusCode: 500,
|
|
81
|
-
troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error
|
|
98
|
+
troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,
|
|
99
|
+
visibility: "banner" /* BANNER */,
|
|
100
|
+
severity: "critical" /* CRITICAL */
|
|
82
101
|
},
|
|
83
102
|
["API_NOT_FOUND" /* API_NOT_FOUND */]: {
|
|
84
103
|
statusCode: 404,
|
|
85
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found
|
|
104
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,
|
|
105
|
+
visibility: "banner" /* BANNER */,
|
|
106
|
+
severity: "critical" /* CRITICAL */
|
|
86
107
|
},
|
|
87
108
|
["REMOTE_ENDPOINT_NOT_FOUND" /* REMOTE_ENDPOINT_NOT_FOUND */]: {
|
|
88
109
|
statusCode: 404,
|
|
89
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error
|
|
110
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,
|
|
111
|
+
visibility: "banner" /* BANNER */,
|
|
112
|
+
severity: "critical" /* CRITICAL */
|
|
90
113
|
},
|
|
91
114
|
["MISUSE" /* MISUSE */]: {
|
|
92
115
|
statusCode: 400,
|
|
93
|
-
troubleshootingUrl: null
|
|
116
|
+
troubleshootingUrl: null,
|
|
117
|
+
visibility: "dev_only" /* DEV_ONLY */,
|
|
118
|
+
severity: "warning" /* WARNING */
|
|
94
119
|
},
|
|
95
120
|
["UNKNOWN" /* UNKNOWN */]: {
|
|
96
|
-
statusCode: 500
|
|
121
|
+
statusCode: 500,
|
|
122
|
+
visibility: "toast" /* TOAST */,
|
|
123
|
+
severity: "info" /* INFO */
|
|
97
124
|
},
|
|
98
125
|
["CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */]: {
|
|
99
126
|
statusCode: 400,
|
|
100
127
|
troubleshootingUrl: null,
|
|
101
|
-
severity: "
|
|
128
|
+
severity: "warning" /* WARNING */,
|
|
129
|
+
visibility: "banner" /* BANNER */
|
|
102
130
|
},
|
|
103
131
|
["MISSING_PUBLIC_API_KEY_ERROR" /* MISSING_PUBLIC_API_KEY_ERROR */]: {
|
|
104
132
|
statusCode: 400,
|
|
105
133
|
troubleshootingUrl: null,
|
|
106
|
-
severity: "
|
|
134
|
+
severity: "critical" /* CRITICAL */,
|
|
135
|
+
visibility: "banner" /* BANNER */
|
|
107
136
|
},
|
|
108
137
|
["UPGRADE_REQUIRED_ERROR" /* UPGRADE_REQUIRED_ERROR */]: {
|
|
109
138
|
statusCode: 402,
|
|
110
139
|
troubleshootingUrl: null,
|
|
111
|
-
severity: "
|
|
140
|
+
severity: "warning" /* WARNING */,
|
|
141
|
+
visibility: "banner" /* BANNER */
|
|
112
142
|
},
|
|
113
143
|
["VERSION_MISMATCH" /* VERSION_MISMATCH */]: {
|
|
114
144
|
statusCode: 400,
|
|
115
|
-
troubleshootingUrl: null
|
|
145
|
+
troubleshootingUrl: null,
|
|
146
|
+
visibility: "dev_only" /* DEV_ONLY */,
|
|
147
|
+
severity: "info" /* INFO */
|
|
116
148
|
}
|
|
117
149
|
};
|
|
118
150
|
var CopilotKitError = class extends GraphQLError {
|
|
119
151
|
constructor({
|
|
120
152
|
message = "Unknown error occurred",
|
|
121
153
|
code,
|
|
122
|
-
severity
|
|
154
|
+
severity,
|
|
155
|
+
visibility
|
|
123
156
|
}) {
|
|
124
157
|
const name = ERROR_NAMES.COPILOT_ERROR;
|
|
125
|
-
const
|
|
158
|
+
const config = ERROR_CONFIG[code];
|
|
159
|
+
const { statusCode } = config;
|
|
160
|
+
const resolvedVisibility = visibility ?? config.visibility ?? "toast" /* TOAST */;
|
|
161
|
+
const resolvedSeverity = severity ?? ("severity" in config ? config.severity : void 0);
|
|
126
162
|
super(message, {
|
|
127
163
|
extensions: {
|
|
128
164
|
name,
|
|
129
|
-
statusCode
|
|
165
|
+
statusCode,
|
|
166
|
+
code,
|
|
167
|
+
visibility: resolvedVisibility,
|
|
168
|
+
severity: resolvedSeverity,
|
|
169
|
+
troubleshootingUrl: "troubleshootingUrl" in config ? config.troubleshootingUrl : null,
|
|
170
|
+
originalError: {
|
|
171
|
+
message,
|
|
172
|
+
stack: new Error().stack
|
|
173
|
+
}
|
|
130
174
|
}
|
|
131
175
|
});
|
|
132
176
|
this.code = code;
|
|
133
177
|
this.name = name;
|
|
134
178
|
this.statusCode = statusCode;
|
|
135
|
-
this.severity =
|
|
179
|
+
this.severity = resolvedSeverity;
|
|
180
|
+
this.visibility = resolvedVisibility;
|
|
136
181
|
}
|
|
137
182
|
};
|
|
138
183
|
var CopilotKitMisuseError = class extends CopilotKitError {
|
|
@@ -252,7 +297,7 @@ var ResolvedCopilotKitError = class extends CopilotKitError {
|
|
|
252
297
|
throw isRemoteEndpoint ? new CopilotKitRemoteEndpointDiscoveryError({ message, url }) : new CopilotKitApiDiscoveryError({ message, url });
|
|
253
298
|
default:
|
|
254
299
|
resolvedCode = "UNKNOWN" /* UNKNOWN */;
|
|
255
|
-
super({ message, code: resolvedCode });
|
|
300
|
+
super({ message, code: resolvedCode, visibility: "banner" /* BANNER */ });
|
|
256
301
|
}
|
|
257
302
|
} else {
|
|
258
303
|
super({ message, code: resolvedCode });
|
|
@@ -264,21 +309,21 @@ var ConfigurationError = class extends CopilotKitError {
|
|
|
264
309
|
constructor(message) {
|
|
265
310
|
super({ message, code: "CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */ });
|
|
266
311
|
this.name = ERROR_NAMES.CONFIGURATION_ERROR;
|
|
267
|
-
this.severity = "
|
|
312
|
+
this.severity = "warning" /* WARNING */;
|
|
268
313
|
}
|
|
269
314
|
};
|
|
270
315
|
var MissingPublicApiKeyError = class extends ConfigurationError {
|
|
271
316
|
constructor(message) {
|
|
272
317
|
super(message);
|
|
273
318
|
this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;
|
|
274
|
-
this.severity = "
|
|
319
|
+
this.severity = "critical" /* CRITICAL */;
|
|
275
320
|
}
|
|
276
321
|
};
|
|
277
322
|
var UpgradeRequiredError = class extends ConfigurationError {
|
|
278
323
|
constructor(message) {
|
|
279
324
|
super(message);
|
|
280
325
|
this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;
|
|
281
|
-
this.severity = "
|
|
326
|
+
this.severity = "warning" /* WARNING */;
|
|
282
327
|
}
|
|
283
328
|
};
|
|
284
329
|
async function getPossibleVersionMismatch({
|
|
@@ -341,7 +386,9 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
341
386
|
|
|
342
387
|
export {
|
|
343
388
|
Severity,
|
|
389
|
+
ErrorVisibility,
|
|
344
390
|
ERROR_NAMES,
|
|
391
|
+
BANNER_ERROR_NAMES,
|
|
345
392
|
COPILOT_CLOUD_ERROR_NAMES,
|
|
346
393
|
CopilotKitErrorCode,
|
|
347
394
|
ERROR_CONFIG,
|
|
@@ -362,4 +409,4 @@ export {
|
|
|
362
409
|
isMacOS,
|
|
363
410
|
COPILOTKIT_VERSION
|
|
364
411
|
};
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
412
|
+
//# sourceMappingURL=chunk-KDQB62ME.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/errors.ts","../src/utils/index.ts","../package.json","../src/index.ts"],"sourcesContent":["import { GraphQLError } from \"graphql\";\nimport { COPILOTKIT_VERSION } from \"../index\";\n\nexport enum Severity {\n CRITICAL = \"critical\", // Critical errors that block core functionality\n WARNING = \"warning\", // Configuration/setup issues that need attention\n INFO = \"info\", // General errors and network issues\n}\n\nexport enum ErrorVisibility {\n BANNER = \"banner\", // Critical errors shown as fixed banners\n TOAST = \"toast\", // Regular errors shown as dismissible toasts\n SILENT = \"silent\", // Errors logged but not shown to user\n DEV_ONLY = \"dev_only\", // Errors only shown in development mode\n}\n\nexport const ERROR_NAMES = {\n COPILOT_ERROR: \"CopilotError\",\n COPILOT_API_DISCOVERY_ERROR: \"CopilotApiDiscoveryError\",\n COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\n COPILOT_KIT_VERSION_MISMATCH_ERROR: \"CopilotKitVersionMismatchError\",\n RESOLVED_COPILOT_KIT_ERROR: \"ResolvedCopilotKitError\",\n CONFIGURATION_ERROR: \"ConfigurationError\",\n MISSING_PUBLIC_API_KEY_ERROR: \"MissingPublicApiKeyError\",\n UPGRADE_REQUIRED_ERROR: \"UpgradeRequiredError\",\n} as const;\n\n// Banner errors - critical configuration/discovery issues\nexport const BANNER_ERROR_NAMES = [\n ERROR_NAMES.CONFIGURATION_ERROR,\n ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR,\n ERROR_NAMES.UPGRADE_REQUIRED_ERROR,\n ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR,\n ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR,\n ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR,\n];\n\n// Legacy cloud error names for backward compatibility\nexport const COPILOT_CLOUD_ERROR_NAMES = BANNER_ERROR_NAMES;\n\nexport enum CopilotKitErrorCode {\n NETWORK_ERROR = \"NETWORK_ERROR\",\n NOT_FOUND = \"NOT_FOUND\",\n AGENT_NOT_FOUND = \"AGENT_NOT_FOUND\",\n API_NOT_FOUND = \"API_NOT_FOUND\",\n REMOTE_ENDPOINT_NOT_FOUND = \"REMOTE_ENDPOINT_NOT_FOUND\",\n MISUSE = \"MISUSE\",\n UNKNOWN = \"UNKNOWN\",\n VERSION_MISMATCH = \"VERSION_MISMATCH\",\n CONFIGURATION_ERROR = \"CONFIGURATION_ERROR\",\n MISSING_PUBLIC_API_KEY_ERROR = \"MISSING_PUBLIC_API_KEY_ERROR\",\n UPGRADE_REQUIRED_ERROR = \"UPGRADE_REQUIRED_ERROR\",\n}\n\nconst BASE_URL = \"https://docs.copilotkit.ai\";\n\nconst getSeeMoreMarkdown = (link: string) => `See more: [${link}](${link})`;\n\nexport const ERROR_CONFIG = {\n [CopilotKitErrorCode.NETWORK_ERROR]: {\n statusCode: 503,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n visibility: ErrorVisibility.TOAST,\n severity: Severity.INFO,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n visibility: ErrorVisibility.TOAST,\n severity: Severity.INFO,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.API_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.MISUSE]: {\n statusCode: 400,\n troubleshootingUrl: null,\n visibility: ErrorVisibility.DEV_ONLY,\n severity: Severity.WARNING,\n },\n [CopilotKitErrorCode.UNKNOWN]: {\n statusCode: 500,\n visibility: ErrorVisibility.TOAST,\n severity: Severity.INFO,\n },\n [CopilotKitErrorCode.CONFIGURATION_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.WARNING,\n visibility: ErrorVisibility.BANNER,\n },\n [CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.CRITICAL,\n visibility: ErrorVisibility.BANNER,\n },\n [CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR]: {\n statusCode: 402,\n troubleshootingUrl: null,\n severity: Severity.WARNING,\n visibility: ErrorVisibility.BANNER,\n },\n [CopilotKitErrorCode.VERSION_MISMATCH]: {\n statusCode: 400,\n troubleshootingUrl: null,\n visibility: ErrorVisibility.DEV_ONLY,\n severity: Severity.INFO,\n },\n};\n\nexport class CopilotKitError extends GraphQLError {\n code: CopilotKitErrorCode;\n statusCode: number;\n severity?: Severity;\n visibility: ErrorVisibility;\n\n constructor({\n message = \"Unknown error occurred\",\n code,\n severity,\n visibility,\n }: {\n message?: string;\n code: CopilotKitErrorCode;\n severity?: Severity;\n visibility?: ErrorVisibility;\n }) {\n const name = ERROR_NAMES.COPILOT_ERROR;\n const config = ERROR_CONFIG[code];\n const { statusCode } = config;\n const resolvedVisibility = visibility ?? config.visibility ?? ErrorVisibility.TOAST;\n const resolvedSeverity = severity ?? (\"severity\" in config ? config.severity : undefined);\n\n super(message, {\n extensions: {\n name,\n statusCode,\n code,\n visibility: resolvedVisibility,\n severity: resolvedSeverity,\n troubleshootingUrl: \"troubleshootingUrl\" in config ? config.troubleshootingUrl : null,\n originalError: {\n message,\n stack: new Error().stack,\n },\n },\n });\n\n this.code = code;\n this.name = name;\n this.statusCode = statusCode;\n this.severity = resolvedSeverity;\n this.visibility = resolvedVisibility;\n }\n}\n\n/**\n * Error thrown when we can identify wrong usage of our components.\n * This helps us notify the developer before real errors can happen\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitMisuseError extends CopilotKitError {\n constructor({\n message,\n code = CopilotKitErrorCode.MISUSE,\n }: {\n message: string;\n code?: CopilotKitErrorCode;\n }) {\n const docsLink =\n \"troubleshootingUrl\" in ERROR_CONFIG[code] && ERROR_CONFIG[code].troubleshootingUrl\n ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl as string)\n : null;\n const finalMessage = docsLink ? `${message}.\\n\\n${docsLink}` : message;\n super({ message: finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\nconst getVersionMismatchErrorMessage = ({\n reactCoreVersion,\n runtimeVersion,\n runtimeClientGqlVersion,\n}: VersionMismatchResponse) =>\n `Version mismatch detected: @copilotkit/runtime@${runtimeVersion ?? \"\"} is not compatible with @copilotkit/react-core@${reactCoreVersion} and @copilotkit/runtime-client-gql@${runtimeClientGqlVersion}. Please ensure all installed copilotkit packages are on the same version.`;\n/**\n * Error thrown when CPK versions does not match\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitVersionMismatchError extends CopilotKitError {\n constructor({\n reactCoreVersion,\n runtimeVersion,\n runtimeClientGqlVersion,\n }: VersionMismatchResponse) {\n const code = CopilotKitErrorCode.VERSION_MISMATCH;\n super({\n message: getVersionMismatchErrorMessage({\n reactCoreVersion,\n runtimeVersion,\n runtimeClientGqlVersion,\n }),\n code,\n });\n this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;\n }\n}\n\n/**\n * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n * - There are network/firewall issues preventing access\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitApiDiscoveryError extends CopilotKitError {\n constructor(\n params: {\n message?: string;\n code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n url?: string;\n } = {},\n ) {\n const url = params.url ?? \"\";\n let operationSuffix = \"\";\n if (url?.includes(\"/info\")) operationSuffix = `when fetching CopilotKit info`;\n else if (url.includes(\"/actions/execute\"))\n operationSuffix = `when attempting to execute actions.`;\n else if (url.includes(\"/agents/state\")) operationSuffix = `when attempting to get agent state.`;\n else if (url.includes(\"/agents/execute\"))\n operationSuffix = `when attempting to execute agent(s).`;\n const message =\n params.message ??\n (params.url\n ? `Failed to find CopilotKit API endpoint at url ${params.url} ${operationSuffix}`\n : `Failed to find CopilotKit API endpoint.`);\n const code = params.code ?? CopilotKitErrorCode.API_NOT_FOUND;\n const errorMessage = `${message}.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: errorMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n *\n * @extends CopilotKitApiDiscoveryError\n */\nexport class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {\n constructor(params?: { message?: string; url?: string }) {\n const message =\n params?.message ??\n (params?.url\n ? `Failed to find or contact remote endpoint at url ${params.url}`\n : \"Failed to find or contact remote endpoint\");\n const code = CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when a LangGraph agent cannot be found or accessed.\n * This typically occurs when:\n * - The specified agent name does not exist in the deployment\n * - The agent configuration is invalid or missing\n * - The agent service is not properly deployed or initialized\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitAgentDiscoveryError extends CopilotKitError {\n constructor(params: { agentName?: string; availableAgents: { name: string; id: string }[] }) {\n const { agentName, availableAgents } = params;\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n\n let message = \"Failed to find any agents.\";\n const configMessage = \"Please verify the agent name exists and is properly configured.\";\n const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);\n\n if (availableAgents.length) {\n message = agentName\n ? `Failed to find agent '${agentName}'. ${configMessage}`\n : `Failed to find agent. ${configMessage}`;\n\n const bulletList = availableAgents\n .map((agent) => `• ${agent.name} (ID: \\`${agent.id}\\`)`)\n .join(\"\\n\");\n\n message += `\\n\\nThe available agents are:\\n\\n${bulletList}\\n\\n${seeMore}`;\n } else {\n message += `\\n\\n${seeMore}`;\n }\n\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Handles low-level networking errors that occur before a request reaches the server.\n * These errors arise from issues in the underlying communication infrastructure rather than\n * application-level logic or server responses. Typically used to handle \"fetch failed\" errors\n * where no HTTP status code is available.\n *\n * Common scenarios include:\n * - Connection failures (ECONNREFUSED) when server is down/unreachable\n * - DNS resolution failures (ENOTFOUND) when domain can't be resolved\n * - Timeouts (ETIMEDOUT) when request takes too long\n * - Protocol/transport layer errors like SSL/TLS issues\n */\nexport class CopilotKitLowLevelError extends CopilotKitError {\n constructor({ error, url, message }: { error: Error; url: string; message?: string }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n // @ts-expect-error -- code may exist\n const errorCode = error.code as string;\n const errorMessage = message ?? resolveLowLevelErrorMessage({ errorCode, url });\n\n super({ message: errorMessage, code });\n\n this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;\n }\n}\n\n/**\n * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.\n * Used when we receive an HTTP error status and wish to handle broad range of them\n *\n * This differs from CopilotKitLowLevelError in that:\n * - ResolvedCopilotKitError: Server was reached and returned an HTTP status\n * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)\n *\n * @param status - The HTTP status code received from the API response\n * @param message - Optional error message to include\n * @param code - Optional specific CopilotKitErrorCode to override default behavior\n *\n * Default behavior:\n * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError\n * - All other status codes: Maps to UNKNOWN error code if no specific code provided\n */\nexport class ResolvedCopilotKitError extends CopilotKitError {\n constructor({\n status,\n message,\n code,\n isRemoteEndpoint,\n url,\n }: {\n status: number;\n message?: string;\n code?: CopilotKitErrorCode;\n isRemoteEndpoint?: boolean;\n url?: string;\n }) {\n let resolvedCode = code;\n if (!resolvedCode) {\n switch (status) {\n case 400:\n throw new CopilotKitApiDiscoveryError({ message, url });\n case 404:\n throw isRemoteEndpoint\n ? new CopilotKitRemoteEndpointDiscoveryError({ message, url })\n : new CopilotKitApiDiscoveryError({ message, url });\n default:\n resolvedCode = CopilotKitErrorCode.UNKNOWN;\n super({ message, code: resolvedCode, visibility: ErrorVisibility.BANNER });\n }\n } else {\n super({ message, code: resolvedCode });\n }\n this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;\n }\n}\n\nexport class ConfigurationError extends CopilotKitError {\n constructor(message: string) {\n super({ message, code: CopilotKitErrorCode.CONFIGURATION_ERROR });\n this.name = ERROR_NAMES.CONFIGURATION_ERROR;\n this.severity = Severity.WARNING;\n }\n}\n\nexport class MissingPublicApiKeyError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;\n this.severity = Severity.CRITICAL;\n }\n}\n\nexport class UpgradeRequiredError extends ConfigurationError {\n constructor(message: string) {\n super(message);\n this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;\n this.severity = Severity.WARNING;\n }\n}\n\ninterface VersionMismatchResponse {\n runtimeVersion?: string;\n runtimeClientGqlVersion: string;\n reactCoreVersion: string;\n}\n\nexport async function getPossibleVersionMismatch({\n runtimeVersion,\n runtimeClientGqlVersion,\n}: {\n runtimeVersion?: string;\n runtimeClientGqlVersion: string;\n}) {\n if (!runtimeVersion || runtimeVersion === \"\" || !runtimeClientGqlVersion) return;\n if (\n COPILOTKIT_VERSION !== runtimeVersion ||\n COPILOTKIT_VERSION !== runtimeClientGqlVersion ||\n runtimeVersion !== runtimeClientGqlVersion\n ) {\n return {\n runtimeVersion,\n runtimeClientGqlVersion,\n reactCoreVersion: COPILOTKIT_VERSION,\n message: getVersionMismatchErrorMessage({\n runtimeVersion,\n runtimeClientGqlVersion,\n reactCoreVersion: COPILOTKIT_VERSION,\n }),\n };\n }\n\n return;\n}\n\nconst resolveLowLevelErrorMessage = ({ errorCode, url }: { errorCode?: string; url: string }) => {\n const troubleshootingLink = ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;\n const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.\n\nPossible reasons:\n- -The server may have an error preventing it from returning a response (Check the server logs for more info).\n- -The server might be down or unreachable\n- -There might be a network issue (e.g., DNS failure, connection timeout) \n- -The URL might be incorrect\n- -The server is not running on the specified port\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n\n if (url.includes(\"/info\"))\n return genericMessage(`Failed to fetch CopilotKit agents/action information from url ${url}.`);\n if (url.includes(\"/actions/execute\"))\n return genericMessage(`Fetch call to ${url} to execute actions failed.`);\n if (url.includes(\"/agents/state\"))\n return genericMessage(`Fetch call to ${url} to get agent state failed.`);\n if (url.includes(\"/agents/execute\"))\n return genericMessage(`Fetch call to ${url} to execute agent(s) failed.`);\n\n switch (errorCode) {\n case \"ECONNREFUSED\":\n return `Connection to ${url} was refused. Ensure the server is running and accessible.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n case \"ENOTFOUND\":\n return `The server on ${url} could not be found. Check the URL or your network configuration.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;\n case \"ETIMEDOUT\":\n return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n default:\n return;\n }\n};\n","export * from \"./conditions\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./random-id\";\n\n/**\n * Safely parses a JSON string into an object\n * @param json The JSON string to parse\n * @param fallback Optional fallback value to return if parsing fails. If not provided or set to \"unset\", returns null\n * @returns The parsed JSON object, or the fallback value (or null) if parsing fails\n */\nexport function parseJson(json: string, fallback: any = \"unset\") {\n try {\n return JSON.parse(json);\n } catch (e) {\n return fallback === \"unset\" ? null : fallback;\n }\n}\n\n/**\n * Maps an array of items to a new array, skipping items that throw errors during mapping\n * @param items The array to map\n * @param callback The mapping function to apply to each item\n * @returns A new array containing only the successfully mapped items\n */\nexport function tryMap<TItem, TMapped>(\n items: TItem[],\n callback: (item: TItem, index: number, array: TItem[]) => TMapped,\n): TMapped[] {\n return items.reduce<TMapped[]>((acc, item, index, array) => {\n try {\n acc.push(callback(item, index, array));\n } catch (error) {\n console.error(error);\n }\n return acc;\n }, []);\n}\n\n/**\n * Checks if the current environment is macOS\n * @returns {boolean} True if running on macOS, false otherwise\n */\nexport function isMacOS(): boolean {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.9.2-next.0\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n","export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT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AC,EAAE,WAAW,IAAI,MAA2C;AAC/F,QAAM,sBAAsB,aAAa,mCAAiC,EAAE;AAC5E,QAAM,iBAAiB,CAAC,cAAc,4BAA4B,WAAW,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShF,mBAAmB,mBAAmB;AAEtC,MAAI,IAAI,SAAS,OAAO;AACtB,WAAO,eAAe,iEAAiE,MAAM;AAC/F,MAAI,IAAI,SAAS,kBAAkB;AACjC,WAAO,eAAe,iBAAiB,gCAAgC;AACzE,MAAI,IAAI,SAAS,eAAe;AAC9B,WAAO,eAAe,iBAAiB,gCAAgC;AACzE,MAAI,IAAI,SAAS,iBAAiB;AAChC,WAAO,eAAe,iBAAiB,iCAAiC;AAE1E,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO,iBAAiB;AAAA;AAAA,EAAoE,mBAAmB,mBAAmB;AAAA,IACpI,KAAK;AACH,aAAO,iBAAiB;AAAA;AAAA,EAA2E,mBAAmB,aAAa,2BAA6B,EAAE,kBAAkB;AAAA,IACtL,KAAK;AACH,aAAO,qBAAqB;AAAA;AAAA,EAAmF,mBAAmB,mBAAmB;AAAA,IACvJ;AACE;AAAA,EACJ;AACF;","names":["Severity","ErrorVisibility","CopilotKitErrorCode"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { isMacOS, parseJson, tryMap } from './utils/index.js';
|
|
|
6
6
|
export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION } from './constants/index.js';
|
|
7
7
|
export { TelemetryClient } from './telemetry/telemetry-client.js';
|
|
8
8
|
export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from './utils/conditions.js';
|
|
9
|
-
export { COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, getPossibleVersionMismatch } from './utils/errors.js';
|
|
9
|
+
export { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, getPossibleVersionMismatch } from './utils/errors.js';
|
|
10
10
|
export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, jsonSchemaToActionParameters } from './utils/json-schema.js';
|
|
11
11
|
export { dataToUUID, isValidUUID, randomId, randomUUID } from './utils/random-id.js';
|
|
12
12
|
import '@segment/analytics-node';
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
BANNER_ERROR_NAMES: () => BANNER_ERROR_NAMES,
|
|
33
34
|
COPILOTKIT_VERSION: () => COPILOTKIT_VERSION,
|
|
34
35
|
COPILOT_CLOUD_API_URL: () => COPILOT_CLOUD_API_URL,
|
|
35
36
|
COPILOT_CLOUD_CHAT_URL: () => COPILOT_CLOUD_CHAT_URL,
|
|
@@ -47,6 +48,7 @@ __export(src_exports, {
|
|
|
47
48
|
CopilotKitVersionMismatchError: () => CopilotKitVersionMismatchError,
|
|
48
49
|
ERROR_CONFIG: () => ERROR_CONFIG,
|
|
49
50
|
ERROR_NAMES: () => ERROR_NAMES,
|
|
51
|
+
ErrorVisibility: () => ErrorVisibility,
|
|
50
52
|
MissingPublicApiKeyError: () => MissingPublicApiKeyError,
|
|
51
53
|
ResolvedCopilotKitError: () => ResolvedCopilotKitError,
|
|
52
54
|
Severity: () => Severity,
|
|
@@ -116,9 +118,18 @@ function getValueFromPath(obj, path) {
|
|
|
116
118
|
// src/utils/errors.ts
|
|
117
119
|
var import_graphql = require("graphql");
|
|
118
120
|
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
119
|
-
Severity2["
|
|
121
|
+
Severity2["CRITICAL"] = "critical";
|
|
122
|
+
Severity2["WARNING"] = "warning";
|
|
123
|
+
Severity2["INFO"] = "info";
|
|
120
124
|
return Severity2;
|
|
121
125
|
})(Severity || {});
|
|
126
|
+
var ErrorVisibility = /* @__PURE__ */ ((ErrorVisibility2) => {
|
|
127
|
+
ErrorVisibility2["BANNER"] = "banner";
|
|
128
|
+
ErrorVisibility2["TOAST"] = "toast";
|
|
129
|
+
ErrorVisibility2["SILENT"] = "silent";
|
|
130
|
+
ErrorVisibility2["DEV_ONLY"] = "dev_only";
|
|
131
|
+
return ErrorVisibility2;
|
|
132
|
+
})(ErrorVisibility || {});
|
|
122
133
|
var ERROR_NAMES = {
|
|
123
134
|
COPILOT_ERROR: "CopilotError",
|
|
124
135
|
COPILOT_API_DISCOVERY_ERROR: "CopilotApiDiscoveryError",
|
|
@@ -131,11 +142,15 @@ var ERROR_NAMES = {
|
|
|
131
142
|
MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
|
|
132
143
|
UPGRADE_REQUIRED_ERROR: "UpgradeRequiredError"
|
|
133
144
|
};
|
|
134
|
-
var
|
|
145
|
+
var BANNER_ERROR_NAMES = [
|
|
135
146
|
ERROR_NAMES.CONFIGURATION_ERROR,
|
|
136
147
|
ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR,
|
|
137
|
-
ERROR_NAMES.UPGRADE_REQUIRED_ERROR
|
|
148
|
+
ERROR_NAMES.UPGRADE_REQUIRED_ERROR,
|
|
149
|
+
ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR,
|
|
150
|
+
ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR,
|
|
151
|
+
ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR
|
|
138
152
|
];
|
|
153
|
+
var COPILOT_CLOUD_ERROR_NAMES = BANNER_ERROR_NAMES;
|
|
139
154
|
var CopilotKitErrorCode = /* @__PURE__ */ ((CopilotKitErrorCode2) => {
|
|
140
155
|
CopilotKitErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
141
156
|
CopilotKitErrorCode2["NOT_FOUND"] = "NOT_FOUND";
|
|
@@ -155,69 +170,101 @@ var getSeeMoreMarkdown = (link) => `See more: [${link}](${link})`;
|
|
|
155
170
|
var ERROR_CONFIG = {
|
|
156
171
|
["NETWORK_ERROR" /* NETWORK_ERROR */]: {
|
|
157
172
|
statusCode: 503,
|
|
158
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found
|
|
173
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,
|
|
174
|
+
visibility: "toast" /* TOAST */,
|
|
175
|
+
severity: "info" /* INFO */
|
|
159
176
|
},
|
|
160
177
|
["NOT_FOUND" /* NOT_FOUND */]: {
|
|
161
178
|
statusCode: 404,
|
|
162
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found
|
|
179
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,
|
|
180
|
+
visibility: "toast" /* TOAST */,
|
|
181
|
+
severity: "info" /* INFO */
|
|
163
182
|
},
|
|
164
183
|
["AGENT_NOT_FOUND" /* AGENT_NOT_FOUND */]: {
|
|
165
184
|
statusCode: 500,
|
|
166
|
-
troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error
|
|
185
|
+
troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,
|
|
186
|
+
visibility: "banner" /* BANNER */,
|
|
187
|
+
severity: "critical" /* CRITICAL */
|
|
167
188
|
},
|
|
168
189
|
["API_NOT_FOUND" /* API_NOT_FOUND */]: {
|
|
169
190
|
statusCode: 404,
|
|
170
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found
|
|
191
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,
|
|
192
|
+
visibility: "banner" /* BANNER */,
|
|
193
|
+
severity: "critical" /* CRITICAL */
|
|
171
194
|
},
|
|
172
195
|
["REMOTE_ENDPOINT_NOT_FOUND" /* REMOTE_ENDPOINT_NOT_FOUND */]: {
|
|
173
196
|
statusCode: 404,
|
|
174
|
-
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error
|
|
197
|
+
troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,
|
|
198
|
+
visibility: "banner" /* BANNER */,
|
|
199
|
+
severity: "critical" /* CRITICAL */
|
|
175
200
|
},
|
|
176
201
|
["MISUSE" /* MISUSE */]: {
|
|
177
202
|
statusCode: 400,
|
|
178
|
-
troubleshootingUrl: null
|
|
203
|
+
troubleshootingUrl: null,
|
|
204
|
+
visibility: "dev_only" /* DEV_ONLY */,
|
|
205
|
+
severity: "warning" /* WARNING */
|
|
179
206
|
},
|
|
180
207
|
["UNKNOWN" /* UNKNOWN */]: {
|
|
181
|
-
statusCode: 500
|
|
208
|
+
statusCode: 500,
|
|
209
|
+
visibility: "toast" /* TOAST */,
|
|
210
|
+
severity: "info" /* INFO */
|
|
182
211
|
},
|
|
183
212
|
["CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */]: {
|
|
184
213
|
statusCode: 400,
|
|
185
214
|
troubleshootingUrl: null,
|
|
186
|
-
severity: "
|
|
215
|
+
severity: "warning" /* WARNING */,
|
|
216
|
+
visibility: "banner" /* BANNER */
|
|
187
217
|
},
|
|
188
218
|
["MISSING_PUBLIC_API_KEY_ERROR" /* MISSING_PUBLIC_API_KEY_ERROR */]: {
|
|
189
219
|
statusCode: 400,
|
|
190
220
|
troubleshootingUrl: null,
|
|
191
|
-
severity: "
|
|
221
|
+
severity: "critical" /* CRITICAL */,
|
|
222
|
+
visibility: "banner" /* BANNER */
|
|
192
223
|
},
|
|
193
224
|
["UPGRADE_REQUIRED_ERROR" /* UPGRADE_REQUIRED_ERROR */]: {
|
|
194
225
|
statusCode: 402,
|
|
195
226
|
troubleshootingUrl: null,
|
|
196
|
-
severity: "
|
|
227
|
+
severity: "warning" /* WARNING */,
|
|
228
|
+
visibility: "banner" /* BANNER */
|
|
197
229
|
},
|
|
198
230
|
["VERSION_MISMATCH" /* VERSION_MISMATCH */]: {
|
|
199
231
|
statusCode: 400,
|
|
200
|
-
troubleshootingUrl: null
|
|
232
|
+
troubleshootingUrl: null,
|
|
233
|
+
visibility: "dev_only" /* DEV_ONLY */,
|
|
234
|
+
severity: "info" /* INFO */
|
|
201
235
|
}
|
|
202
236
|
};
|
|
203
237
|
var CopilotKitError = class extends import_graphql.GraphQLError {
|
|
204
238
|
constructor({
|
|
205
239
|
message = "Unknown error occurred",
|
|
206
240
|
code,
|
|
207
|
-
severity
|
|
241
|
+
severity,
|
|
242
|
+
visibility
|
|
208
243
|
}) {
|
|
209
244
|
const name = ERROR_NAMES.COPILOT_ERROR;
|
|
210
|
-
const
|
|
245
|
+
const config = ERROR_CONFIG[code];
|
|
246
|
+
const { statusCode } = config;
|
|
247
|
+
const resolvedVisibility = visibility ?? config.visibility ?? "toast" /* TOAST */;
|
|
248
|
+
const resolvedSeverity = severity ?? ("severity" in config ? config.severity : void 0);
|
|
211
249
|
super(message, {
|
|
212
250
|
extensions: {
|
|
213
251
|
name,
|
|
214
|
-
statusCode
|
|
252
|
+
statusCode,
|
|
253
|
+
code,
|
|
254
|
+
visibility: resolvedVisibility,
|
|
255
|
+
severity: resolvedSeverity,
|
|
256
|
+
troubleshootingUrl: "troubleshootingUrl" in config ? config.troubleshootingUrl : null,
|
|
257
|
+
originalError: {
|
|
258
|
+
message,
|
|
259
|
+
stack: new Error().stack
|
|
260
|
+
}
|
|
215
261
|
}
|
|
216
262
|
});
|
|
217
263
|
this.code = code;
|
|
218
264
|
this.name = name;
|
|
219
265
|
this.statusCode = statusCode;
|
|
220
|
-
this.severity =
|
|
266
|
+
this.severity = resolvedSeverity;
|
|
267
|
+
this.visibility = resolvedVisibility;
|
|
221
268
|
}
|
|
222
269
|
};
|
|
223
270
|
var CopilotKitMisuseError = class extends CopilotKitError {
|
|
@@ -337,7 +384,7 @@ var ResolvedCopilotKitError = class extends CopilotKitError {
|
|
|
337
384
|
throw isRemoteEndpoint ? new CopilotKitRemoteEndpointDiscoveryError({ message, url }) : new CopilotKitApiDiscoveryError({ message, url });
|
|
338
385
|
default:
|
|
339
386
|
resolvedCode = "UNKNOWN" /* UNKNOWN */;
|
|
340
|
-
super({ message, code: resolvedCode });
|
|
387
|
+
super({ message, code: resolvedCode, visibility: "banner" /* BANNER */ });
|
|
341
388
|
}
|
|
342
389
|
} else {
|
|
343
390
|
super({ message, code: resolvedCode });
|
|
@@ -349,21 +396,21 @@ var ConfigurationError = class extends CopilotKitError {
|
|
|
349
396
|
constructor(message) {
|
|
350
397
|
super({ message, code: "CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */ });
|
|
351
398
|
this.name = ERROR_NAMES.CONFIGURATION_ERROR;
|
|
352
|
-
this.severity = "
|
|
399
|
+
this.severity = "warning" /* WARNING */;
|
|
353
400
|
}
|
|
354
401
|
};
|
|
355
402
|
var MissingPublicApiKeyError = class extends ConfigurationError {
|
|
356
403
|
constructor(message) {
|
|
357
404
|
super(message);
|
|
358
405
|
this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;
|
|
359
|
-
this.severity = "
|
|
406
|
+
this.severity = "critical" /* CRITICAL */;
|
|
360
407
|
}
|
|
361
408
|
};
|
|
362
409
|
var UpgradeRequiredError = class extends ConfigurationError {
|
|
363
410
|
constructor(message) {
|
|
364
411
|
super(message);
|
|
365
412
|
this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;
|
|
366
|
-
this.severity = "
|
|
413
|
+
this.severity = "warning" /* WARNING */;
|
|
367
414
|
}
|
|
368
415
|
};
|
|
369
416
|
async function getPossibleVersionMismatch({
|
|
@@ -763,12 +810,13 @@ var TelemetryClient = class {
|
|
|
763
810
|
};
|
|
764
811
|
|
|
765
812
|
// package.json
|
|
766
|
-
var version = "1.9.
|
|
813
|
+
var version = "1.9.2-next.0";
|
|
767
814
|
|
|
768
815
|
// src/index.ts
|
|
769
816
|
var COPILOTKIT_VERSION = version;
|
|
770
817
|
// Annotate the CommonJS export names for ESM import in node:
|
|
771
818
|
0 && (module.exports = {
|
|
819
|
+
BANNER_ERROR_NAMES,
|
|
772
820
|
COPILOTKIT_VERSION,
|
|
773
821
|
COPILOT_CLOUD_API_URL,
|
|
774
822
|
COPILOT_CLOUD_CHAT_URL,
|
|
@@ -786,6 +834,7 @@ var COPILOTKIT_VERSION = version;
|
|
|
786
834
|
CopilotKitVersionMismatchError,
|
|
787
835
|
ERROR_CONFIG,
|
|
788
836
|
ERROR_NAMES,
|
|
837
|
+
ErrorVisibility,
|
|
789
838
|
MissingPublicApiKeyError,
|
|
790
839
|
ResolvedCopilotKitError,
|
|
791
840
|
Severity,
|