@copilotkit/shared 0.0.0-feat-dynamic-copilotcloud-qa-20250117190454 → 0.0.0-feat-enable-setting-recursion-limit-20250424165940

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +285 -1
  2. package/dist/chunk-FDMXZMSN.mjs +361 -0
  3. package/dist/chunk-FDMXZMSN.mjs.map +1 -0
  4. package/dist/{chunk-QFITLWYZ.mjs → chunk-LGWATNA5.mjs} +3 -2
  5. package/dist/{chunk-QFITLWYZ.mjs.map → chunk-LGWATNA5.mjs.map} +1 -1
  6. package/dist/chunk-PL5WNHFZ.mjs +50 -0
  7. package/dist/chunk-PL5WNHFZ.mjs.map +1 -0
  8. package/dist/chunk-VNNKZIFB.mjs +24 -0
  9. package/dist/chunk-VNNKZIFB.mjs.map +1 -0
  10. package/dist/index.d.ts +8 -4
  11. package/dist/index.js +438 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +56 -12
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/telemetry/index.js +2 -1
  16. package/dist/telemetry/index.js.map +1 -1
  17. package/dist/telemetry/index.mjs +1 -1
  18. package/dist/telemetry/telemetry-client.js +2 -1
  19. package/dist/telemetry/telemetry-client.js.map +1 -1
  20. package/dist/telemetry/telemetry-client.mjs +1 -1
  21. package/dist/types/index.d.ts +1 -1
  22. package/dist/types/utility.d.ts +4 -1
  23. package/dist/types/utility.js.map +1 -1
  24. package/dist/utils/conditions.d.ts +26 -0
  25. package/dist/utils/conditions.js +74 -0
  26. package/dist/utils/conditions.js.map +1 -0
  27. package/dist/utils/conditions.mjs +7 -0
  28. package/dist/utils/errors.d.ts +226 -0
  29. package/dist/utils/errors.js +379 -0
  30. package/dist/utils/errors.js.map +1 -0
  31. package/dist/utils/errors.mjs +51 -0
  32. package/dist/utils/errors.mjs.map +1 -0
  33. package/dist/utils/index.d.ts +21 -1
  34. package/dist/utils/index.js +443 -2
  35. package/dist/utils/index.js.map +1 -1
  36. package/dist/utils/index.mjs +63 -5
  37. package/dist/utils/random-id.d.ts +4 -1
  38. package/dist/utils/random-id.js +19 -2
  39. package/dist/utils/random-id.js.map +1 -1
  40. package/dist/utils/random-id.mjs +9 -3
  41. package/package.json +2 -1
  42. package/src/telemetry/telemetry-client.ts +1 -0
  43. package/src/types/utility.ts +1 -0
  44. package/src/utils/conditions.ts +98 -0
  45. package/src/utils/errors.ts +437 -0
  46. package/src/utils/index.ts +36 -0
  47. package/src/utils/random-id.ts +16 -1
  48. package/dist/chunk-CYDWEPFL.mjs +0 -1
  49. package/dist/chunk-RIPX6APP.mjs +0 -10
  50. package/dist/chunk-RIPX6APP.mjs.map +0 -1
  51. /package/dist/{chunk-CYDWEPFL.mjs.map → utils/conditions.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,290 @@
1
1
  # @copilotkit/shared
2
2
 
3
- ## 0.0.0-feat-dynamic-copilotcloud-qa-20250117190454
3
+ ## 0.0.0-feat-enable-setting-recursion-limit-20250424165940
4
+
5
+ ## 1.8.7
6
+
7
+ ## 1.8.7-next.0
8
+
9
+ ## 1.8.6
10
+
11
+ ## 1.8.6-next.0
12
+
13
+ ## 1.8.5
14
+
15
+ ## 1.8.5-next.5
16
+
17
+ ## 1.8.5-next.4
18
+
19
+ ## 1.8.5-next.3
20
+
21
+ ## 1.8.5-next.2
22
+
23
+ ## 1.8.5-next.1
24
+
25
+ ## 1.8.5-next.0
26
+
27
+ ## 1.8.4
28
+
29
+ ### Patch Changes
30
+
31
+ - f363760: - fix: when unable to find specified agent, show what's available
32
+
33
+ ## 1.8.4-next.4
34
+
35
+ ## 1.8.4-next.3
36
+
37
+ ## 1.8.4-next.2
38
+
39
+ ## 1.8.4-next.1
40
+
41
+ ### Patch Changes
42
+
43
+ - f363760: - fix: when unable to find specified agent, show what's available
44
+
45
+ ## 1.8.4-next.0
46
+
47
+ ## 1.8.3
48
+
49
+ ## 1.8.3-next.0
50
+
51
+ ## 1.8.2-next.3
52
+
53
+ ## 1.8.2-next.2
54
+
55
+ ## 1.8.2-next.1
56
+
57
+ ## 1.8.2-next.0
58
+
59
+ ## 1.8.1
60
+
61
+ ## 1.8.1-next.1
62
+
63
+ ## 1.8.1-next.0
64
+
65
+ ## 1.8.0
66
+
67
+ ## 1.8.0-next.8
68
+
69
+ ## 1.8.0-next.7
70
+
71
+ ## 1.8.0-next.6
72
+
73
+ ## 1.8.0-next.5
74
+
75
+ ## 1.8.0-next.4
76
+
77
+ ## 1.8.0-next.3
78
+
79
+ ## 1.7.2-next.2
80
+
81
+ ## 1.7.2-next.1
82
+
83
+ ## 1.7.2-next.0
84
+
85
+ ## 1.7.1
86
+
87
+ ## 1.7.1-next.0
88
+
89
+ ## 1.7.0
90
+
91
+ ## 1.7.0-next.1
92
+
93
+ ## 1.7.0-next.0
94
+
95
+ ## 1.6.0
96
+
97
+ ### Patch Changes
98
+
99
+ - 090203d: - fix: use tryMap method to filter out possibly invalid items
100
+
101
+ ## 1.6.0-next.12
102
+
103
+ ## 1.6.0-next.11
104
+
105
+ ## 1.6.0-next.10
106
+
107
+ ## 1.6.0-next.9
108
+
109
+ ## 1.6.0-next.8
110
+
111
+ ## 1.6.0-next.7
112
+
113
+ ## 1.6.0-next.6
114
+
115
+ ## 1.6.0-next.5
116
+
117
+ ### Patch Changes
118
+
119
+ - 090203d: - fix: use tryMap method to filter out possibly invalid items
120
+
121
+ ## 1.6.0-next.4
122
+
123
+ ## 1.6.0-next.3
124
+
125
+ ## 1.6.0-next.2
126
+
127
+ ## 1.6.0-next.1
128
+
129
+ ## 1.6.0-next.0
130
+
131
+ ## 1.5.20
132
+
133
+ ### Patch Changes
134
+
135
+ - 51f0d66: - fix(errors): fix internal usage of error resolver
136
+
137
+ ## 1.5.20-next.0
138
+
139
+ ### Patch Changes
140
+
141
+ - 51f0d66: - fix(errors): fix internal usage of error resolver
142
+
143
+ ## 1.5.19
144
+
145
+ ### Patch Changes
146
+
147
+ - 0dd1ab9: - fix(errors): allow non copilotkit errors to pass to consumer app error boundary
148
+
149
+ ## 1.5.19-next.1
150
+
151
+ ### Patch Changes
152
+
153
+ - 0dd1ab9: - fix(errors): allow non copilotkit errors to pass to consumer app error boundary
154
+
155
+ ## 1.5.19-next.0
156
+
157
+ ## 1.5.18
158
+
159
+ ### Patch Changes
160
+
161
+ - d47cd26: - fix: detect and alert on version mismatch
162
+ - f77a7b9: - fix: use warning when version mismatch is not expected to error out
163
+ - 38d3ac2: - fix: add additional info the our error messages
164
+
165
+ ## 1.5.18-next.3
166
+
167
+ ### Patch Changes
168
+
169
+ - f77a7b9: - fix: use warning when version mismatch is not expected to error out
170
+
171
+ ## 1.5.18-next.2
172
+
173
+ ### Patch Changes
174
+
175
+ - 38d3ac2: - fix: add additional info the our error messages
176
+
177
+ ## 1.5.18-next.1
178
+
179
+ ## 1.5.18-next.0
180
+
181
+ ### Patch Changes
182
+
183
+ - d47cd26: - fix: detect and alert on version mismatch
184
+
185
+ ## 1.5.17
186
+
187
+ ### Patch Changes
188
+
189
+ - 1fc3902: - Revert "fix: detect and alert on version mismatch (#1333)"
190
+
191
+ This reverts commit 48b7c7b1bd48ced82ffb9a00d6eddc1f7581e0c1.
192
+
193
+ ## 1.5.17-next.0
194
+
195
+ ### Patch Changes
196
+
197
+ - 1fc3902: - Revert "fix: detect and alert on version mismatch (#1333)"
198
+
199
+ This reverts commit 48b7c7b1bd48ced82ffb9a00d6eddc1f7581e0c1.
200
+
201
+ ## 1.5.16
202
+
203
+ ### Patch Changes
204
+
205
+ - 48b7c7b: - fix: detect and alert on version mismatch
206
+
207
+ ## 1.5.16-next.2
208
+
209
+ ## 1.5.16-next.1
210
+
211
+ ### Patch Changes
212
+
213
+ - 48b7c7b: - fix: detect and alert on version mismatch
214
+
215
+ ## 1.5.16-next.0
216
+
217
+ ## 1.5.15
218
+
219
+ ### Patch Changes
220
+
221
+ - 7b3141d: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
222
+ - chore(interrupt): add e2e test to interrupt functionality
223
+ - feat(interrupt): add support for multiple interrupts and conditions
224
+
225
+ ## 1.5.15-next.8
226
+
227
+ ## 1.5.15-next.7
228
+
229
+ ## 1.5.15-next.6
230
+
231
+ ## 1.5.15-next.5
232
+
233
+ ## 1.5.15-next.4
234
+
235
+ ### Patch Changes
236
+
237
+ - 7b3141d: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
238
+ - chore(interrupt): add e2e test to interrupt functionality
239
+ - feat(interrupt): add support for multiple interrupts and conditions
240
+
241
+ ## 1.5.15-next.3
242
+
243
+ ## 1.5.15-next.2
244
+
245
+ ## 1.5.15-next.1
246
+
247
+ ## 1.5.15-next.0
248
+
249
+ ## 1.5.14
250
+
251
+ ### Patch Changes
252
+
253
+ - 0061f65: - feat: allows dev mode for cloud onboarding flow
254
+
255
+ ## 1.5.14-next.0
256
+
257
+ ### Patch Changes
258
+
259
+ - 0061f65: - feat: allows dev mode for cloud onboarding flow
260
+
261
+ ## 1.5.13
262
+
263
+ ## 1.5.13-next.0
264
+
265
+ ## 1.5.12
266
+
267
+ ### Patch Changes
268
+
269
+ - 6136a57: - fix(errors): add custom error classes to better describe library errors
270
+ - fix(errors): use new errors in error handling
271
+ - chore: add documentation and links to respective errors
272
+
273
+ ## 1.5.12-next.7
274
+
275
+ ## 1.5.12-next.6
276
+
277
+ ### Patch Changes
278
+
279
+ - 6136a57: - fix(errors): add custom error classes to better describe library errors
280
+ - fix(errors): use new errors in error handling
281
+ - chore: add documentation and links to respective errors
282
+
283
+ ## 1.5.12-next.5
284
+
285
+ ## 1.5.12-next.4
286
+
287
+ ## 1.5.12-next.3
4
288
 
5
289
  ## 1.5.12-next.2
6
290
 
@@ -0,0 +1,361 @@
1
+ // src/utils/errors.ts
2
+ import { GraphQLError } from "graphql";
3
+
4
+ // src/utils/index.ts
5
+ function parseJson(json, fallback = "unset") {
6
+ try {
7
+ return JSON.parse(json);
8
+ } catch (e) {
9
+ return fallback === "unset" ? null : fallback;
10
+ }
11
+ }
12
+ function tryMap(items, callback) {
13
+ return items.reduce((acc, item, index, array) => {
14
+ try {
15
+ acc.push(callback(item, index, array));
16
+ } catch (error) {
17
+ console.error(error);
18
+ }
19
+ return acc;
20
+ }, []);
21
+ }
22
+
23
+ // package.json
24
+ var version = "1.8.7";
25
+
26
+ // src/index.ts
27
+ var COPILOTKIT_VERSION = version;
28
+
29
+ // src/utils/errors.ts
30
+ var Severity = /* @__PURE__ */ ((Severity2) => {
31
+ Severity2["Error"] = "error";
32
+ return Severity2;
33
+ })(Severity || {});
34
+ var ERROR_NAMES = {
35
+ COPILOT_ERROR: "CopilotError",
36
+ COPILOT_API_DISCOVERY_ERROR: "CopilotApiDiscoveryError",
37
+ COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError",
38
+ COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError",
39
+ COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError",
40
+ COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError",
41
+ RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError",
42
+ CONFIGURATION_ERROR: "ConfigurationError",
43
+ MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
44
+ UPGRADE_REQUIRED_ERROR: "UpgradeRequiredError"
45
+ };
46
+ var COPILOT_CLOUD_ERROR_NAMES = [
47
+ ERROR_NAMES.CONFIGURATION_ERROR,
48
+ ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR,
49
+ ERROR_NAMES.UPGRADE_REQUIRED_ERROR
50
+ ];
51
+ var CopilotKitErrorCode = /* @__PURE__ */ ((CopilotKitErrorCode2) => {
52
+ CopilotKitErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
53
+ CopilotKitErrorCode2["NOT_FOUND"] = "NOT_FOUND";
54
+ CopilotKitErrorCode2["AGENT_NOT_FOUND"] = "AGENT_NOT_FOUND";
55
+ CopilotKitErrorCode2["API_NOT_FOUND"] = "API_NOT_FOUND";
56
+ CopilotKitErrorCode2["REMOTE_ENDPOINT_NOT_FOUND"] = "REMOTE_ENDPOINT_NOT_FOUND";
57
+ CopilotKitErrorCode2["MISUSE"] = "MISUSE";
58
+ CopilotKitErrorCode2["UNKNOWN"] = "UNKNOWN";
59
+ CopilotKitErrorCode2["VERSION_MISMATCH"] = "VERSION_MISMATCH";
60
+ CopilotKitErrorCode2["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
61
+ CopilotKitErrorCode2["MISSING_PUBLIC_API_KEY_ERROR"] = "MISSING_PUBLIC_API_KEY_ERROR";
62
+ CopilotKitErrorCode2["UPGRADE_REQUIRED_ERROR"] = "UPGRADE_REQUIRED_ERROR";
63
+ return CopilotKitErrorCode2;
64
+ })(CopilotKitErrorCode || {});
65
+ var BASE_URL = "https://docs.copilotkit.ai";
66
+ var getSeeMoreMarkdown = (link) => `See more: [${link}](${link})`;
67
+ var ERROR_CONFIG = {
68
+ ["NETWORK_ERROR" /* NETWORK_ERROR */]: {
69
+ statusCode: 503,
70
+ troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`
71
+ },
72
+ ["NOT_FOUND" /* NOT_FOUND */]: {
73
+ statusCode: 404,
74
+ troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`
75
+ },
76
+ ["AGENT_NOT_FOUND" /* AGENT_NOT_FOUND */]: {
77
+ statusCode: 500,
78
+ troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`
79
+ },
80
+ ["API_NOT_FOUND" /* API_NOT_FOUND */]: {
81
+ statusCode: 404,
82
+ troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`
83
+ },
84
+ ["REMOTE_ENDPOINT_NOT_FOUND" /* REMOTE_ENDPOINT_NOT_FOUND */]: {
85
+ statusCode: 404,
86
+ troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`
87
+ },
88
+ ["MISUSE" /* MISUSE */]: {
89
+ statusCode: 400,
90
+ troubleshootingUrl: null
91
+ },
92
+ ["UNKNOWN" /* UNKNOWN */]: {
93
+ statusCode: 500
94
+ },
95
+ ["CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */]: {
96
+ statusCode: 400,
97
+ troubleshootingUrl: null,
98
+ severity: "error" /* Error */
99
+ },
100
+ ["MISSING_PUBLIC_API_KEY_ERROR" /* MISSING_PUBLIC_API_KEY_ERROR */]: {
101
+ statusCode: 400,
102
+ troubleshootingUrl: null,
103
+ severity: "error" /* Error */
104
+ },
105
+ ["UPGRADE_REQUIRED_ERROR" /* UPGRADE_REQUIRED_ERROR */]: {
106
+ statusCode: 402,
107
+ troubleshootingUrl: null,
108
+ severity: "error" /* Error */
109
+ },
110
+ ["VERSION_MISMATCH" /* VERSION_MISMATCH */]: {
111
+ statusCode: 400,
112
+ troubleshootingUrl: null
113
+ }
114
+ };
115
+ var CopilotKitError = class extends GraphQLError {
116
+ constructor({
117
+ message = "Unknown error occurred",
118
+ code,
119
+ severity
120
+ }) {
121
+ const name = ERROR_NAMES.COPILOT_ERROR;
122
+ const { statusCode } = ERROR_CONFIG[code];
123
+ super(message, {
124
+ extensions: {
125
+ name,
126
+ statusCode
127
+ }
128
+ });
129
+ this.code = code;
130
+ this.name = name;
131
+ this.statusCode = statusCode;
132
+ this.severity = severity;
133
+ }
134
+ };
135
+ var CopilotKitMisuseError = class extends CopilotKitError {
136
+ constructor({
137
+ message,
138
+ code = "MISUSE" /* MISUSE */
139
+ }) {
140
+ const docsLink = "troubleshootingUrl" in ERROR_CONFIG[code] && ERROR_CONFIG[code].troubleshootingUrl ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl) : null;
141
+ const finalMessage = docsLink ? `${message}.
142
+
143
+ ${docsLink}` : message;
144
+ super({ message: finalMessage, code });
145
+ this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;
146
+ }
147
+ };
148
+ var getVersionMismatchErrorMessage = ({
149
+ reactCoreVersion,
150
+ runtimeVersion,
151
+ runtimeClientGqlVersion
152
+ }) => `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.`;
153
+ var CopilotKitVersionMismatchError = class extends CopilotKitError {
154
+ constructor({
155
+ reactCoreVersion,
156
+ runtimeVersion,
157
+ runtimeClientGqlVersion
158
+ }) {
159
+ const code = "VERSION_MISMATCH" /* VERSION_MISMATCH */;
160
+ super({
161
+ message: getVersionMismatchErrorMessage({
162
+ reactCoreVersion,
163
+ runtimeVersion,
164
+ runtimeClientGqlVersion
165
+ }),
166
+ code
167
+ });
168
+ this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;
169
+ }
170
+ };
171
+ var CopilotKitApiDiscoveryError = class extends CopilotKitError {
172
+ constructor(params = {}) {
173
+ const url = params.url ?? "";
174
+ let operationSuffix = "";
175
+ if (url == null ? void 0 : url.includes("/info"))
176
+ operationSuffix = `when fetching CopilotKit info`;
177
+ else if (url.includes("/actions/execute"))
178
+ operationSuffix = `when attempting to execute actions.`;
179
+ else if (url.includes("/agents/state"))
180
+ operationSuffix = `when attempting to get agent state.`;
181
+ else if (url.includes("/agents/execute"))
182
+ operationSuffix = `when attempting to execute agent(s).`;
183
+ const message = params.message ?? (params.url ? `Failed to find CopilotKit API endpoint at url ${params.url} ${operationSuffix}` : `Failed to find CopilotKit API endpoint.`);
184
+ const code = params.code ?? "API_NOT_FOUND" /* API_NOT_FOUND */;
185
+ const errorMessage = `${message}.
186
+
187
+ ${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;
188
+ super({ message: errorMessage, code });
189
+ this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;
190
+ }
191
+ };
192
+ var CopilotKitRemoteEndpointDiscoveryError = class extends CopilotKitApiDiscoveryError {
193
+ constructor(params) {
194
+ const message = (params == null ? void 0 : params.message) ?? ((params == null ? void 0 : params.url) ? `Failed to find or contact remote endpoint at url ${params.url}` : "Failed to find or contact remote endpoint");
195
+ const code = "REMOTE_ENDPOINT_NOT_FOUND" /* REMOTE_ENDPOINT_NOT_FOUND */;
196
+ super({ message, code });
197
+ this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;
198
+ }
199
+ };
200
+ var CopilotKitAgentDiscoveryError = class extends CopilotKitError {
201
+ constructor(params) {
202
+ const { agentName, availableAgents } = params;
203
+ const code = "AGENT_NOT_FOUND" /* AGENT_NOT_FOUND */;
204
+ let message = "Failed to find any agents.";
205
+ const configMessage = "Please verify the agent name exists and is properly configured.";
206
+ const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);
207
+ if (availableAgents.length) {
208
+ message = agentName ? `Failed to find agent '${agentName}'. ${configMessage}` : `Failed to find agent. ${configMessage}`;
209
+ const bulletList = availableAgents.map((agent) => `\u2022 ${agent.name} (ID: \`${agent.id}\`)`).join("\n");
210
+ message += `
211
+
212
+ The available agents are:
213
+
214
+ ${bulletList}
215
+
216
+ ${seeMore}`;
217
+ } else {
218
+ message += `
219
+
220
+ ${seeMore}`;
221
+ }
222
+ super({ message, code });
223
+ this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;
224
+ }
225
+ };
226
+ var CopilotKitLowLevelError = class extends CopilotKitError {
227
+ constructor({ error, url, message }) {
228
+ let code = "NETWORK_ERROR" /* NETWORK_ERROR */;
229
+ const errorCode = error.code;
230
+ const errorMessage = message ?? resolveLowLevelErrorMessage({ errorCode, url });
231
+ super({ message: errorMessage, code });
232
+ this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;
233
+ }
234
+ };
235
+ var ResolvedCopilotKitError = class extends CopilotKitError {
236
+ constructor({
237
+ status,
238
+ message,
239
+ code,
240
+ isRemoteEndpoint,
241
+ url
242
+ }) {
243
+ let resolvedCode = code;
244
+ if (!resolvedCode) {
245
+ switch (status) {
246
+ case 400:
247
+ throw new CopilotKitApiDiscoveryError({ message, url });
248
+ case 404:
249
+ throw isRemoteEndpoint ? new CopilotKitRemoteEndpointDiscoveryError({ message, url }) : new CopilotKitApiDiscoveryError({ message, url });
250
+ default:
251
+ resolvedCode = "UNKNOWN" /* UNKNOWN */;
252
+ super({ message, code: resolvedCode });
253
+ }
254
+ } else {
255
+ super({ message, code: resolvedCode });
256
+ }
257
+ this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;
258
+ }
259
+ };
260
+ var ConfigurationError = class extends CopilotKitError {
261
+ constructor(message) {
262
+ super({ message, code: "CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */ });
263
+ this.name = ERROR_NAMES.CONFIGURATION_ERROR;
264
+ this.severity = "error" /* Error */;
265
+ }
266
+ };
267
+ var MissingPublicApiKeyError = class extends ConfigurationError {
268
+ constructor(message) {
269
+ super(message);
270
+ this.name = ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR;
271
+ this.severity = "error" /* Error */;
272
+ }
273
+ };
274
+ var UpgradeRequiredError = class extends ConfigurationError {
275
+ constructor(message) {
276
+ super(message);
277
+ this.name = ERROR_NAMES.UPGRADE_REQUIRED_ERROR;
278
+ this.severity = "error" /* Error */;
279
+ }
280
+ };
281
+ async function getPossibleVersionMismatch({
282
+ runtimeVersion,
283
+ runtimeClientGqlVersion
284
+ }) {
285
+ if (!runtimeVersion || runtimeVersion === "" || !runtimeClientGqlVersion)
286
+ return;
287
+ if (COPILOTKIT_VERSION !== runtimeVersion || COPILOTKIT_VERSION !== runtimeClientGqlVersion || runtimeVersion !== runtimeClientGqlVersion) {
288
+ return {
289
+ runtimeVersion,
290
+ runtimeClientGqlVersion,
291
+ reactCoreVersion: COPILOTKIT_VERSION,
292
+ message: getVersionMismatchErrorMessage({
293
+ runtimeVersion,
294
+ runtimeClientGqlVersion,
295
+ reactCoreVersion: COPILOTKIT_VERSION
296
+ })
297
+ };
298
+ }
299
+ return;
300
+ }
301
+ var resolveLowLevelErrorMessage = ({ errorCode, url }) => {
302
+ const troubleshootingLink = ERROR_CONFIG["NETWORK_ERROR" /* NETWORK_ERROR */].troubleshootingUrl;
303
+ const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.
304
+
305
+ Possible reasons:
306
+ - -The server may have an error preventing it from returning a response (Check the server logs for more info).
307
+ - -The server might be down or unreachable
308
+ - -There might be a network issue (e.g., DNS failure, connection timeout)
309
+ - -The URL might be incorrect
310
+ - -The server is not running on the specified port
311
+
312
+ ${getSeeMoreMarkdown(troubleshootingLink)}`;
313
+ if (url.includes("/info"))
314
+ return genericMessage(`Failed to fetch CopilotKit agents/action information from url ${url}.`);
315
+ if (url.includes("/actions/execute"))
316
+ return genericMessage(`Fetch call to ${url} to execute actions failed.`);
317
+ if (url.includes("/agents/state"))
318
+ return genericMessage(`Fetch call to ${url} to get agent state failed.`);
319
+ if (url.includes("/agents/execute"))
320
+ return genericMessage(`Fetch call to ${url} to execute agent(s) failed.`);
321
+ switch (errorCode) {
322
+ case "ECONNREFUSED":
323
+ return `Connection to ${url} was refused. Ensure the server is running and accessible.
324
+
325
+ ${getSeeMoreMarkdown(troubleshootingLink)}`;
326
+ case "ENOTFOUND":
327
+ return `The server on ${url} could not be found. Check the URL or your network configuration.
328
+
329
+ ${getSeeMoreMarkdown(ERROR_CONFIG["NOT_FOUND" /* NOT_FOUND */].troubleshootingUrl)}`;
330
+ case "ETIMEDOUT":
331
+ return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.
332
+
333
+ ${getSeeMoreMarkdown(troubleshootingLink)}`;
334
+ default:
335
+ return;
336
+ }
337
+ };
338
+
339
+ export {
340
+ Severity,
341
+ ERROR_NAMES,
342
+ COPILOT_CLOUD_ERROR_NAMES,
343
+ CopilotKitErrorCode,
344
+ ERROR_CONFIG,
345
+ CopilotKitError,
346
+ CopilotKitMisuseError,
347
+ CopilotKitVersionMismatchError,
348
+ CopilotKitApiDiscoveryError,
349
+ CopilotKitRemoteEndpointDiscoveryError,
350
+ CopilotKitAgentDiscoveryError,
351
+ CopilotKitLowLevelError,
352
+ ResolvedCopilotKitError,
353
+ ConfigurationError,
354
+ MissingPublicApiKeyError,
355
+ UpgradeRequiredError,
356
+ getPossibleVersionMismatch,
357
+ parseJson,
358
+ tryMap,
359
+ COPILOTKIT_VERSION
360
+ };
361
+ //# sourceMappingURL=chunk-FDMXZMSN.mjs.map