@copilotkit/shared 2.0.0-rc.1 → 2.0.0-rc.10

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 (220) hide show
  1. package/README.md +3 -14
  2. package/dist/a2ui-prompts.cjs +21 -62
  3. package/dist/a2ui-prompts.cjs.map +1 -1
  4. package/dist/a2ui-prompts.d.cts +8 -1
  5. package/dist/a2ui-prompts.d.cts.map +1 -1
  6. package/dist/a2ui-prompts.d.mts +8 -1
  7. package/dist/a2ui-prompts.d.mts.map +1 -1
  8. package/dist/a2ui-prompts.mjs +22 -62
  9. package/dist/a2ui-prompts.mjs.map +1 -1
  10. package/dist/generative-ui/basic-functions.cjs +1 -1
  11. package/dist/generative-ui/basic-functions.cjs.map +1 -1
  12. package/dist/generative-ui/basic-functions.mjs +1 -1
  13. package/dist/generative-ui/basic-functions.mjs.map +1 -1
  14. package/dist/generative-ui/compact-schema.cjs +187 -0
  15. package/dist/generative-ui/compact-schema.cjs.map +1 -0
  16. package/dist/generative-ui/compact-schema.d.cts +55 -0
  17. package/dist/generative-ui/compact-schema.d.cts.map +1 -0
  18. package/dist/generative-ui/compact-schema.d.mts +55 -0
  19. package/dist/generative-ui/compact-schema.d.mts.map +1 -0
  20. package/dist/generative-ui/compact-schema.mjs +185 -0
  21. package/dist/generative-ui/compact-schema.mjs.map +1 -0
  22. package/dist/generative-ui/prompt-spec.cjs +225 -0
  23. package/dist/generative-ui/prompt-spec.cjs.map +1 -0
  24. package/dist/generative-ui/prompt-spec.d.cts +94 -0
  25. package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
  26. package/dist/generative-ui/prompt-spec.d.mts +94 -0
  27. package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
  28. package/dist/generative-ui/prompt-spec.mjs +220 -0
  29. package/dist/generative-ui/prompt-spec.mjs.map +1 -0
  30. package/dist/generative-ui/prompt.cjs +10 -36
  31. package/dist/generative-ui/prompt.cjs.map +1 -1
  32. package/dist/generative-ui/prompt.d.cts +2 -1
  33. package/dist/generative-ui/prompt.d.cts.map +1 -1
  34. package/dist/generative-ui/prompt.d.mts +2 -1
  35. package/dist/generative-ui/prompt.d.mts.map +1 -1
  36. package/dist/generative-ui/prompt.mjs +12 -38
  37. package/dist/generative-ui/prompt.mjs.map +1 -1
  38. package/dist/generative-ui/schema-render.cjs +242 -0
  39. package/dist/generative-ui/schema-render.cjs.map +1 -0
  40. package/dist/generative-ui/schema-render.d.cts +44 -0
  41. package/dist/generative-ui/schema-render.d.cts.map +1 -0
  42. package/dist/generative-ui/schema-render.d.mts +44 -0
  43. package/dist/generative-ui/schema-render.d.mts.map +1 -0
  44. package/dist/generative-ui/schema-render.mjs +239 -0
  45. package/dist/generative-ui/schema-render.mjs.map +1 -0
  46. package/dist/index.cjs +17 -15
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +10 -9
  49. package/dist/index.d.cts.map +1 -1
  50. package/dist/index.d.mts +10 -9
  51. package/dist/index.d.mts.map +1 -1
  52. package/dist/index.mjs +9 -7
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/index.umd.js +808 -438
  55. package/dist/index.umd.js.map +1 -1
  56. package/dist/package.cjs +1 -1
  57. package/dist/package.mjs +1 -1
  58. package/dist/standard-schema.cjs +20 -7
  59. package/dist/standard-schema.cjs.map +1 -1
  60. package/dist/standard-schema.d.cts +15 -16
  61. package/dist/standard-schema.d.cts.map +1 -1
  62. package/dist/standard-schema.d.mts +15 -16
  63. package/dist/standard-schema.d.mts.map +1 -1
  64. package/dist/standard-schema.mjs +20 -8
  65. package/dist/standard-schema.mjs.map +1 -1
  66. package/dist/telemetry/lambda-client.cjs.map +1 -1
  67. package/dist/telemetry/lambda-client.d.cts.map +1 -1
  68. package/dist/telemetry/lambda-client.d.mts.map +1 -1
  69. package/dist/telemetry/lambda-client.mjs.map +1 -1
  70. package/dist/telemetry/telemetry-disabled.cjs +3 -6
  71. package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
  72. package/dist/telemetry/telemetry-disabled.d.cts +0 -5
  73. package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
  74. package/dist/telemetry/telemetry-disabled.d.mts +0 -5
  75. package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
  76. package/dist/telemetry/telemetry-disabled.mjs +4 -6
  77. package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
  78. package/dist/types/message.d.cts +1 -18
  79. package/dist/types/message.d.cts.map +1 -1
  80. package/dist/types/message.d.mts +1 -18
  81. package/dist/types/message.d.mts.map +1 -1
  82. package/dist/utils/errors.cjs +4 -42
  83. package/dist/utils/errors.cjs.map +1 -1
  84. package/dist/utils/errors.d.cts +16 -34
  85. package/dist/utils/errors.d.cts.map +1 -1
  86. package/dist/utils/errors.d.mts +16 -34
  87. package/dist/utils/errors.d.mts.map +1 -1
  88. package/dist/utils/errors.mjs +5 -41
  89. package/dist/utils/errors.mjs.map +1 -1
  90. package/dist/utils/index.cjs +1 -2
  91. package/dist/utils/index.cjs.map +1 -1
  92. package/dist/utils/index.d.cts +4 -5
  93. package/dist/utils/index.d.cts.map +1 -1
  94. package/dist/utils/index.d.mts +4 -5
  95. package/dist/utils/index.d.mts.map +1 -1
  96. package/dist/utils/index.mjs +4 -5
  97. package/dist/utils/index.mjs.map +1 -1
  98. package/dist/utils/json-schema.cjs +0 -79
  99. package/dist/utils/json-schema.cjs.map +1 -1
  100. package/dist/utils/json-schema.d.cts +1 -4
  101. package/dist/utils/json-schema.d.cts.map +1 -1
  102. package/dist/utils/json-schema.d.mts +1 -4
  103. package/dist/utils/json-schema.d.mts.map +1 -1
  104. package/dist/utils/json-schema.mjs +1 -78
  105. package/dist/utils/json-schema.mjs.map +1 -1
  106. package/dist/utils/process-env.cjs +14 -0
  107. package/dist/utils/process-env.cjs.map +1 -0
  108. package/dist/utils/process-env.d.cts +10 -0
  109. package/dist/utils/process-env.d.cts.map +1 -0
  110. package/dist/utils/process-env.d.mts +10 -0
  111. package/dist/utils/process-env.d.mts.map +1 -0
  112. package/dist/utils/process-env.mjs +13 -0
  113. package/dist/utils/process-env.mjs.map +1 -0
  114. package/dist/utils/random-id.cjs +13 -26
  115. package/dist/utils/random-id.cjs.map +1 -1
  116. package/dist/utils/random-id.d.cts +6 -3
  117. package/dist/utils/random-id.d.cts.map +1 -1
  118. package/dist/utils/random-id.d.mts +6 -3
  119. package/dist/utils/random-id.d.mts.map +1 -1
  120. package/dist/utils/random-id.mjs +14 -25
  121. package/dist/utils/random-id.mjs.map +1 -1
  122. package/package.json +7 -31
  123. package/src/__tests__/a2ui-prompts.test.ts +42 -9
  124. package/src/__tests__/fixtures/prompt-goldens.json +354 -0
  125. package/src/__tests__/prompt-spec.test.ts +191 -0
  126. package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
  127. package/src/__tests__/schema-render.test.ts +245 -0
  128. package/src/__tests__/standard-schema.test.ts +61 -101
  129. package/src/a2ui-prompts.ts +47 -96
  130. package/src/generative-ui/basic-functions.ts +1 -1
  131. package/src/generative-ui/compact-schema.ts +277 -0
  132. package/src/generative-ui/index.ts +3 -0
  133. package/src/generative-ui/prompt-spec.ts +335 -0
  134. package/src/generative-ui/prompt.ts +25 -75
  135. package/src/generative-ui/schema-render.ts +374 -0
  136. package/src/index.ts +3 -16
  137. package/src/standard-schema.ts +24 -27
  138. package/src/telemetry/lambda-client.ts +3 -2
  139. package/src/telemetry/telemetry-disabled.ts +7 -12
  140. package/src/types/message.ts +1 -19
  141. package/src/utils/__tests__/errors.test.ts +44 -0
  142. package/src/utils/__tests__/json-schema.test.ts +3 -479
  143. package/src/utils/__tests__/process-env.test.ts +22 -0
  144. package/src/utils/__tests__/random-id.test.ts +37 -0
  145. package/src/utils/errors.ts +27 -85
  146. package/src/utils/index.ts +1 -2
  147. package/src/utils/json-schema.ts +1 -152
  148. package/src/utils/process-env.ts +14 -0
  149. package/src/utils/random-id.ts +17 -37
  150. package/tsdown.config.ts +2 -19
  151. package/dist/event-transforms/index.cjs +0 -15
  152. package/dist/event-transforms/index.d.cts +0 -4
  153. package/dist/event-transforms/index.d.mts +0 -4
  154. package/dist/event-transforms/index.mjs +0 -5
  155. package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
  156. package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
  157. package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
  158. package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
  159. package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
  160. package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
  161. package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
  162. package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
  163. package/dist/event-transforms/recorded-events.cjs +0 -59
  164. package/dist/event-transforms/recorded-events.cjs.map +0 -1
  165. package/dist/event-transforms/recorded-events.d.cts +0 -23
  166. package/dist/event-transforms/recorded-events.d.cts.map +0 -1
  167. package/dist/event-transforms/recorded-events.d.mts +0 -23
  168. package/dist/event-transforms/recorded-events.d.mts.map +0 -1
  169. package/dist/event-transforms/recorded-events.mjs +0 -58
  170. package/dist/event-transforms/recorded-events.mjs.map +0 -1
  171. package/dist/telemetry/events.d.cts +0 -72
  172. package/dist/telemetry/events.d.cts.map +0 -1
  173. package/dist/telemetry/events.d.mts +0 -72
  174. package/dist/telemetry/events.d.mts.map +0 -1
  175. package/dist/telemetry/index.cjs +0 -18
  176. package/dist/telemetry/index.d.cts +0 -5
  177. package/dist/telemetry/index.d.mts +0 -5
  178. package/dist/telemetry/index.mjs +0 -6
  179. package/dist/telemetry/telemetry-client.cjs +0 -165
  180. package/dist/telemetry/telemetry-client.cjs.map +0 -1
  181. package/dist/telemetry/telemetry-client.d.cts +0 -87
  182. package/dist/telemetry/telemetry-client.d.cts.map +0 -1
  183. package/dist/telemetry/telemetry-client.d.mts +0 -87
  184. package/dist/telemetry/telemetry-client.d.mts.map +0 -1
  185. package/dist/telemetry/telemetry-client.mjs +0 -164
  186. package/dist/telemetry/telemetry-client.mjs.map +0 -1
  187. package/dist/telemetry/utils.cjs +0 -14
  188. package/dist/telemetry/utils.cjs.map +0 -1
  189. package/dist/telemetry/utils.mjs +0 -13
  190. package/dist/telemetry/utils.mjs.map +0 -1
  191. package/dist/utils/conditions.cjs +0 -32
  192. package/dist/utils/conditions.cjs.map +0 -1
  193. package/dist/utils/conditions.d.cts +0 -31
  194. package/dist/utils/conditions.d.cts.map +0 -1
  195. package/dist/utils/conditions.d.mts +0 -31
  196. package/dist/utils/conditions.d.mts.map +0 -1
  197. package/dist/utils/conditions.mjs +0 -31
  198. package/dist/utils/conditions.mjs.map +0 -1
  199. package/dist/utils/console-styling.cjs +0 -91
  200. package/dist/utils/console-styling.cjs.map +0 -1
  201. package/dist/utils/console-styling.d.cts +0 -65
  202. package/dist/utils/console-styling.d.cts.map +0 -1
  203. package/dist/utils/console-styling.d.mts +0 -65
  204. package/dist/utils/console-styling.d.mts.map +0 -1
  205. package/dist/utils/console-styling.mjs +0 -85
  206. package/dist/utils/console-styling.mjs.map +0 -1
  207. package/src/__tests__/zod-regression.test.ts +0 -319
  208. package/src/event-transforms/index.ts +0 -5
  209. package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
  210. package/src/event-transforms/recorded-events.test.ts +0 -166
  211. package/src/event-transforms/recorded-events.ts +0 -74
  212. package/src/telemetry/events.ts +0 -68
  213. package/src/telemetry/index.ts +0 -9
  214. package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
  215. package/src/telemetry/telemetry-client.test.ts +0 -798
  216. package/src/telemetry/telemetry-client.ts +0 -328
  217. package/src/telemetry/utils.ts +0 -15
  218. package/src/utils/__tests__/conditions.test.ts +0 -161
  219. package/src/utils/conditions.ts +0 -116
  220. package/src/utils/console-styling.ts +0 -126
@@ -1,6 +1,3 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- const require_index = require('../index.cjs');
3
- let graphql = require("graphql");
4
1
 
5
2
  //#region src/utils/errors.ts
6
3
  let Severity = /* @__PURE__ */ function(Severity) {
@@ -22,7 +19,6 @@ const ERROR_NAMES = {
22
19
  COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError",
23
20
  COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError",
24
21
  COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError",
25
- COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError",
26
22
  RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError",
27
23
  CONFIGURATION_ERROR: "ConfigurationError",
28
24
  MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
@@ -127,14 +123,15 @@ const ERROR_CONFIG = {
127
123
  severity: Severity.INFO
128
124
  }
129
125
  };
130
- var CopilotKitError = class extends graphql.GraphQLError {
126
+ var CopilotKitError = class extends Error {
131
127
  constructor({ message = "Unknown error occurred", code, severity, visibility }) {
132
128
  const name = ERROR_NAMES.COPILOT_ERROR;
133
129
  const config = ERROR_CONFIG[code];
134
130
  const { statusCode } = config;
135
131
  const resolvedVisibility = visibility ?? config.visibility ?? ErrorVisibility.TOAST;
136
132
  const resolvedSeverity = severity ?? ("severity" in config ? config.severity : void 0);
137
- super(message, { extensions: {
133
+ super(message);
134
+ this.extensions = {
138
135
  name,
139
136
  statusCode,
140
137
  code,
@@ -145,7 +142,7 @@ var CopilotKitError = class extends graphql.GraphQLError {
145
142
  message,
146
143
  stack: (/* @__PURE__ */ new Error()).stack
147
144
  }
148
- } });
145
+ };
149
146
  this.code = code;
150
147
  this.name = name;
151
148
  this.statusCode = statusCode;
@@ -170,26 +167,6 @@ var CopilotKitMisuseError = class extends CopilotKitError {
170
167
  this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;
171
168
  }
172
169
  };
173
- const getVersionMismatchErrorMessage = ({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion }) => `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.`;
174
- /**
175
- * Error thrown when CPK versions does not match
176
- *
177
- * @extends CopilotKitError
178
- */
179
- var CopilotKitVersionMismatchError = class extends CopilotKitError {
180
- constructor({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion }) {
181
- const code = CopilotKitErrorCode.VERSION_MISMATCH;
182
- super({
183
- message: getVersionMismatchErrorMessage({
184
- reactCoreVersion,
185
- runtimeVersion,
186
- runtimeClientGqlVersion
187
- }),
188
- code
189
- });
190
- this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;
191
- }
192
- };
193
170
  /**
194
171
  * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
195
172
  * This typically occurs when:
@@ -377,19 +354,6 @@ function isStructuredCopilotKitError(error) {
377
354
  function ensureStructuredError(error, converter) {
378
355
  return isStructuredCopilotKitError(error) ? error : converter(error);
379
356
  }
380
- async function getPossibleVersionMismatch({ runtimeVersion, runtimeClientGqlVersion }) {
381
- if (!runtimeVersion || runtimeVersion === "" || !runtimeClientGqlVersion) return;
382
- if (require_index.COPILOTKIT_VERSION !== runtimeVersion || require_index.COPILOTKIT_VERSION !== runtimeClientGqlVersion || runtimeVersion !== runtimeClientGqlVersion) return {
383
- runtimeVersion,
384
- runtimeClientGqlVersion,
385
- reactCoreVersion: require_index.COPILOTKIT_VERSION,
386
- message: getVersionMismatchErrorMessage({
387
- runtimeVersion,
388
- runtimeClientGqlVersion,
389
- reactCoreVersion: require_index.COPILOTKIT_VERSION
390
- })
391
- };
392
- }
393
357
  const resolveLowLevelErrorMessage = ({ errorCode, url }) => {
394
358
  const troubleshootingLink = ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;
395
359
  const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.
@@ -425,7 +389,6 @@ exports.CopilotKitErrorCode = CopilotKitErrorCode;
425
389
  exports.CopilotKitLowLevelError = CopilotKitLowLevelError;
426
390
  exports.CopilotKitMisuseError = CopilotKitMisuseError;
427
391
  exports.CopilotKitRemoteEndpointDiscoveryError = CopilotKitRemoteEndpointDiscoveryError;
428
- exports.CopilotKitVersionMismatchError = CopilotKitVersionMismatchError;
429
392
  exports.ERROR_CONFIG = ERROR_CONFIG;
430
393
  exports.ERROR_NAMES = ERROR_NAMES;
431
394
  exports.ErrorVisibility = ErrorVisibility;
@@ -434,6 +397,5 @@ exports.ResolvedCopilotKitError = ResolvedCopilotKitError;
434
397
  exports.Severity = Severity;
435
398
  exports.UpgradeRequiredError = UpgradeRequiredError;
436
399
  exports.ensureStructuredError = ensureStructuredError;
437
- exports.getPossibleVersionMismatch = getPossibleVersionMismatch;
438
400
  exports.isStructuredCopilotKitError = isStructuredCopilotKitError;
439
401
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":["GraphQLError","COPILOTKIT_VERSION"],"sources":["../../src/utils/errors.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:\n \"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 AUTHENTICATION_ERROR = \"AUTHENTICATION_ERROR\",\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#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/langgraph-python/coagent-troubleshooting/common-coagent-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#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#remote-endpoint-not-found-error`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AUTHENTICATION_ERROR]: {\n statusCode: 401,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues`,\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.CRITICAL,\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 =\n visibility ?? config.visibility ?? ErrorVisibility.TOAST;\n const resolvedSeverity =\n 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:\n \"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] &&\n 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?:\n | CopilotKitErrorCode.API_NOT_FOUND\n | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n url?: string;\n } = {},\n ) {\n const url = params.url ?? \"\";\n let operationSuffix = \"\";\n if (url?.includes(\"/info\"))\n 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\"))\n 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: {\n agentName?: string;\n availableAgents: { name: string; id: string }[];\n }) {\n const { agentName, availableAgents } = params;\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n\n const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);\n let message;\n\n if (availableAgents.length) {\n const agentList = availableAgents.map((agent) => agent.name).join(\", \");\n\n if (agentName) {\n message = `Agent '${agentName}' was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n } else {\n message = `The requested agent was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n }\n } else {\n message = `${agentName ? `Agent '${agentName}'` : \"The requested agent\"} was not found. Please set up at least one agent before proceeding. ${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({\n error,\n url,\n message,\n }: {\n error: Error;\n url: string;\n message?: string;\n }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n // @ts-expect-error -- code may exist\n const errorCode = error.code as string;\n const errorMessage =\n 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 break;\n }\n }\n\n super({ message, code: resolvedCode });\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\n/**\n * Checks if an error is already a structured CopilotKit error.\n * This utility centralizes the logic for detecting structured errors across the codebase.\n *\n * @param error - The error to check\n * @returns true if the error is already structured, false otherwise\n */\nexport function isStructuredCopilotKitError(error: any): boolean {\n return (\n error instanceof CopilotKitError ||\n error instanceof CopilotKitLowLevelError ||\n (error?.name && error.name.includes(\"CopilotKit\")) ||\n error?.extensions?.code !== undefined // Check if it has our structured error properties\n );\n}\n\n/**\n * Returns the error as-is if it's already structured, otherwise converts it using the provided converter function.\n * This utility centralizes the pattern of preserving structured errors while converting unstructured ones.\n *\n * @param error - The error to process\n * @param converter - Function to convert unstructured errors to structured ones\n * @returns The structured error\n */\nexport function ensureStructuredError<T extends CopilotKitError>(\n error: any,\n converter: (error: any) => T,\n): T | any {\n return isStructuredCopilotKitError(error) ? error : converter(error);\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)\n 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 = ({\n errorCode,\n url,\n}: {\n errorCode?: string;\n url: string;\n}) => {\n const troubleshootingLink =\n ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;\n const genericMessage = (\n description = `Failed to fetch from url ${url}.`,\n ) => `${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(\n `Failed to fetch CopilotKit agents/action information from url ${url}.`,\n );\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"],"mappings":";;;;;AAGA,IAAY,8CAAL;AACL;AACA;AACA;;;AAGF,IAAY,4DAAL;AACL;AACA;AACA;AACA;;;AAGF,MAAa,cAAc;CACzB,eAAe;CACf,6BAA6B;CAC7B,yCACE;CACF,mCAAmC;CACnC,6BAA6B;CAC7B,oCAAoC;CACpC,4BAA4B;CAC5B,qBAAqB;CACrB,8BAA8B;CAC9B,wBAAwB;CACzB;AAGD,MAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAGD,MAAa,4BAA4B;AAEzC,IAAY,oEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGF,MAAM,WAAW;AAEjB,MAAM,sBAAsB,SAAiB,cAAc,KAAK,IAAI,KAAK;AAEzE,MAAa,eAAe;EACzB,oBAAoB,gBAAgB;EACnC,YAAY;EACZ,oBAAoB,GAAG,SAAS;EAChC,YAAY,gBAAgB;EAC5B,UAAU,SAAS;EACpB;EACA,oBAAoB,YAAY;EAC/B,YAAY;EACZ,oBAAoB,GAAG,SAAS;EAChC,YAAY,gBAAgB;EAC5B,UAAU,SAAS;EACpB;EACA,oBAAoB,kBAAkB;EACrC,YA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+BAA+B,EACnC,WACA,UAII;CACJ,MAAM,sBACJ,aAAa,oBAAoB,eAAe;CAClD,MAAM,kBACJ,cAAc,4BAA4B,IAAI,OAC3C,GAAG,YAAY;;;;;;;;;EASpB,mBAAmB,oBAAoB;AAEvC,KAAI,IAAI,SAAS,QAAQ,CACvB,QAAO,eACL,iEAAiE,IAAI,GACtE;AACH,KAAI,IAAI,SAAS,mBAAmB,CAClC,QAAO,eAAe,iBAAiB,IAAI,6BAA6B;AAC1E,KAAI,IAAI,SAAS,gBAAgB,CAC/B,QAAO,eAAe,iBAAiB,IAAI,6BAA6B;AAC1E,KAAI,IAAI,SAAS,kBAAkB,CACjC,QAAO,eAAe,iBAAiB,IAAI,8BAA8B;AAE3E,SAAQ,WAAR;EACE,KAAK,eACH,QAAO,iBAAiB,IAAI,gEAAgE,mBAAmB,oBAAoB;EACrI,KAAK,YACH,QAAO,iBAAiB,IAAI,uEAAuE,mBAAmB,aAAa,oBAAoB,WAAW,mBAAmB;EACvL,KAAK,YACH,QAAO,qBAAqB,IAAI,+EAA+E,mBAAmB,oBAAoB;EACxJ,QACE"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["export 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:\n \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\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 AUTHENTICATION_ERROR = \"AUTHENTICATION_ERROR\",\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#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/langgraph-python/coagent-troubleshooting/common-coagent-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#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#remote-endpoint-not-found-error`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AUTHENTICATION_ERROR]: {\n statusCode: 401,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues`,\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.CRITICAL,\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 interface CopilotKitErrorExtensions {\n name: string;\n statusCode: number;\n code: CopilotKitErrorCode;\n visibility: ErrorVisibility;\n severity?: Severity;\n troubleshootingUrl: string | null;\n originalError: { message: string; stack?: string };\n}\n\nexport class CopilotKitError extends Error {\n /** Structured error details, kept in the shape GraphQL errors used in 1.x. */\n extensions: CopilotKitErrorExtensions;\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 =\n visibility ?? config.visibility ?? ErrorVisibility.TOAST;\n const resolvedSeverity =\n severity ?? (\"severity\" in config ? config.severity : undefined);\n\n super(message);\n\n this.extensions = {\n name,\n statusCode,\n code,\n visibility: resolvedVisibility,\n severity: resolvedSeverity,\n troubleshootingUrl:\n \"troubleshootingUrl\" in config ? config.troubleshootingUrl : null,\n originalError: {\n message,\n stack: new Error().stack,\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] &&\n 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\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?:\n | CopilotKitErrorCode.API_NOT_FOUND\n | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n url?: string;\n } = {},\n ) {\n const url = params.url ?? \"\";\n let operationSuffix = \"\";\n if (url?.includes(\"/info\"))\n 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\"))\n 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: {\n agentName?: string;\n availableAgents: { name: string; id: string }[];\n }) {\n const { agentName, availableAgents } = params;\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n\n const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);\n let message;\n\n if (availableAgents.length) {\n const agentList = availableAgents.map((agent) => agent.name).join(\", \");\n\n if (agentName) {\n message = `Agent '${agentName}' was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n } else {\n message = `The requested agent was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n }\n } else {\n message = `${agentName ? `Agent '${agentName}'` : \"The requested agent\"} was not found. Please set up at least one agent before proceeding. ${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({\n error,\n url,\n message,\n }: {\n error: Error;\n url: string;\n message?: string;\n }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n // @ts-expect-error -- code may exist\n const errorCode = error.code as string;\n const errorMessage =\n 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 break;\n }\n }\n\n super({ message, code: resolvedCode });\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\n/**\n * Checks if an error is already a structured CopilotKit error.\n * This utility centralizes the logic for detecting structured errors across the codebase.\n *\n * @param error - The error to check\n * @returns true if the error is already structured, false otherwise\n */\nexport function isStructuredCopilotKitError(error: any): boolean {\n return (\n error instanceof CopilotKitError ||\n error instanceof CopilotKitLowLevelError ||\n (error?.name && error.name.includes(\"CopilotKit\")) ||\n error?.extensions?.code !== undefined // Check if it has our structured error properties\n );\n}\n\n/**\n * Returns the error as-is if it's already structured, otherwise converts it using the provided converter function.\n * This utility centralizes the pattern of preserving structured errors while converting unstructured ones.\n *\n * @param error - The error to process\n * @param converter - Function to convert unstructured errors to structured ones\n * @returns The structured error\n */\nexport function ensureStructuredError<T extends CopilotKitError>(\n error: any,\n converter: (error: any) => T,\n): T | any {\n return isStructuredCopilotKitError(error) ? error : converter(error);\n}\n\nconst resolveLowLevelErrorMessage = ({\n errorCode,\n url,\n}: {\n errorCode?: string;\n url: string;\n}) => {\n const troubleshootingLink =\n ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;\n const genericMessage = (\n description = `Failed to fetch from url ${url}.`,\n ) => `${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(\n `Failed to fetch CopilotKit agents/action information from url ${url}.`,\n );\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"],"mappings":";;AAAA,IAAY,8CAAL;AACL;AACA;AACA;;;AAGF,IAAY,4DAAL;AACL;AACA;AACA;AACA;;;AAGF,MAAa,cAAc;CACzB,eAAe;CACf,6BAA6B;CAC7B,yCACE;CACF,mCAAmC;CACnC,6BAA6B;CAC7B,4BAA4B;CAC5B,qBAAqB;CACrB,8BAA8B;CAC9B,wBAAwB;CACzB;AAGD,MAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAGD,MAAa,4BAA4B;AAEzC,IAAY,oEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGF,MAAM,WAAW;AAEjB,MAAM,sBAAsB,SAAiB,cAAc,KAAK,IAAI,KAAK;AAEzE,MAAa,eAAe;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S,gBAAgB,CAC/B,QAAO,eAAe,iBAAiB,IAAI,6BAA6B;AAC1E,KAAI,IAAI,SAAS,kBAAkB,CACjC,QAAO,eAAe,iBAAiB,IAAI,8BAA8B;AAE3E,SAAQ,WAAR;EACE,KAAK,eACH,QAAO,iBAAiB,IAAI,gEAAgE,mBAAmB,oBAAoB;EACrI,KAAK,YACH,QAAO,iBAAiB,IAAI,uEAAuE,mBAAmB,aAAa,oBAAoB,WAAW,mBAAmB;EACvL,KAAK,YACH,QAAO,qBAAqB,IAAI,+EAA+E,mBAAmB,oBAAoB;EACxJ,QACE"}
@@ -1,5 +1,3 @@
1
- import { GraphQLError } from "graphql";
2
-
3
1
  //#region src/utils/errors.d.ts
4
2
  declare enum Severity {
5
3
  CRITICAL = "critical",
@@ -23,7 +21,6 @@ declare const ERROR_NAMES: {
23
21
  readonly COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError";
24
22
  readonly COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError";
25
23
  readonly COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError";
26
- readonly COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError";
27
24
  readonly RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError";
28
25
  readonly CONFIGURATION_ERROR: "ConfigurationError";
29
26
  readonly MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError";
@@ -118,7 +115,21 @@ declare const ERROR_CONFIG: {
118
115
  severity: Severity;
119
116
  };
120
117
  };
121
- declare class CopilotKitError extends GraphQLError {
118
+ interface CopilotKitErrorExtensions {
119
+ name: string;
120
+ statusCode: number;
121
+ code: CopilotKitErrorCode;
122
+ visibility: ErrorVisibility;
123
+ severity?: Severity;
124
+ troubleshootingUrl: string | null;
125
+ originalError: {
126
+ message: string;
127
+ stack?: string;
128
+ };
129
+ }
130
+ declare class CopilotKitError extends Error {
131
+ /** Structured error details, kept in the shape GraphQL errors used in 1.x. */
132
+ extensions: CopilotKitErrorExtensions;
122
133
  code: CopilotKitErrorCode;
123
134
  statusCode: number;
124
135
  severity?: Severity;
@@ -150,18 +161,6 @@ declare class CopilotKitMisuseError extends CopilotKitError {
150
161
  code?: CopilotKitErrorCode;
151
162
  });
152
163
  }
153
- /**
154
- * Error thrown when CPK versions does not match
155
- *
156
- * @extends CopilotKitError
157
- */
158
- declare class CopilotKitVersionMismatchError extends CopilotKitError {
159
- constructor({
160
- reactCoreVersion,
161
- runtimeVersion,
162
- runtimeClientGqlVersion
163
- }: VersionMismatchResponse);
164
- }
165
164
  /**
166
165
  * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
167
166
  * This typically occurs when:
@@ -290,23 +289,6 @@ declare function isStructuredCopilotKitError(error: any): boolean;
290
289
  * @returns The structured error
291
290
  */
292
291
  declare function ensureStructuredError<T extends CopilotKitError>(error: any, converter: (error: any) => T): T | any;
293
- interface VersionMismatchResponse {
294
- runtimeVersion?: string;
295
- runtimeClientGqlVersion: string;
296
- reactCoreVersion: string;
297
- }
298
- declare function getPossibleVersionMismatch({
299
- runtimeVersion,
300
- runtimeClientGqlVersion
301
- }: {
302
- runtimeVersion?: string;
303
- runtimeClientGqlVersion: string;
304
- }): Promise<{
305
- runtimeVersion: string;
306
- runtimeClientGqlVersion: string;
307
- reactCoreVersion: string;
308
- message: string;
309
- } | undefined>;
310
292
  //#endregion
311
- 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, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError };
293
+ export { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitErrorExtensions, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, isStructuredCopilotKitError };
312
294
  //# sourceMappingURL=errors.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.cts","names":[],"sources":["../../src/utils/errors.ts"],"mappings":";;;aAGY,QAAA;EACV,QAAA;EAAA;EACA,OAAA;EAAA;EACA,IAAA;AAAA;AAAA,aAGU,eAAA;EACV,MAAA;EAAA;EACA,KAAA;EAAA;EACA,MAAA;EAAA;EACA,QAAA;AAAA;AAAA,cAGW,WAAA;EAAA;;;;;;;;;;;cAeA,kBAAA;AAAA,cAUA,yBAAA;AAAA,aAED,mBAAA;EACV,aAAA;EACA,SAAA;EACA,eAAA;EACA,aAAA;EACA,yBAAA;EACA,oBAAA;EACA,MAAA;EACA,OAAA;EACA,gBAAA;EACA,mBAAA;EACA,4BAAA;EACA,sBAAA;AAAA;AAAA,cAOW,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0EA,eAAA,SAAwB,YAAA;EACnC,IAAA,EAAM,mBAAA;EACN,UAAA;EACA,QAAA,GAAW,QAAA;EACX,UAAA,EAAY,eAAA;;IAGV,OAAA;IACA,IAAA;IACA,QAAA;IACA;EAAA;IAEA,OAAA;IACA,IAAA,EAAM,mBAAA;IACN,QAAA,GAAW,QAAA;IACX,UAAA,GAAa,eAAA;EAAA;AAAA;;;;;;;cAwCJ,qBAAA,SAA8B,eAAA;;IAEvC,OAAA;IACA;EAAA;IAEA,OAAA;IACA,IA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aAAA,GACpB,mBAAA,CAAoB,yBAAA;IACxB,GAAA;EAAA;AAAA;;;;;;;;;cAiCO,sCAAA,SAA+C,2BAAA;cAC9C,MAAA;IAAW,OAAA;IAAkB,GAAA;EAAA;AAAA;;;;;;;;;;cAqB9B,6BAAA,SAAsC,eAAA;cACrC,MAAA;IACV,SAAA;IACA,eAAA;MAAmB,IAAA;MAAc,EAAA;IAAA;EAAA;AAAA;;;AArJrC;;;;;;;;;;cA0La,uBAAA,SAAgC,eAAA;;IAEzC,KAAA;IACA,GAAA;IACA;EAAA;IAEA,KAAA,EAAO,KAAA;IACP,GAAA;IACA,OAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;cA+BS,uBAAA,SAAgC,eAAA;;IAEzC,MAAA;IACA,OAAA;IACA,IAAA;IACA,gBAAA;IACA;EAAA;IAEA,MAAA;IACA,OAAA;IACA,IAAA,GAAO,mBAAA;IACP,gBAAA;IACA,GAAA;EAAA;AAAA;AAAA,cAsBS,kBAAA,SAA2B,eAAA;cAC1B,OAAA;AAAA;AAAA,cAOD,wBAAA,SAAiC,kBAAA;cAChC,OAAA;AAAA;AAAA,cAOD,oBAAA,SAA6B,kBAAA;cAC5B,OAAA;AAAA;;;;;;;;iBAcE,2BAAA,CAA4B,KAAA;;;;;;;AA9M5C;;iBA+NgB,qBAAA,WAAgC,eAAA,CAAA,CAC9C,KAAA,OACA,SAAA,GAAY,KAAA,UAAe,CAAA,GAC1B,CAAA"}
@@ -1,5 +1,3 @@
1
- import { GraphQLError } from "graphql";
2
-
3
1
  //#region src/utils/errors.d.ts
4
2
  declare enum Severity {
5
3
  CRITICAL = "critical",
@@ -23,7 +21,6 @@ declare const ERROR_NAMES: {
23
21
  readonly COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError";
24
22
  readonly COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError";
25
23
  readonly COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError";
26
- readonly COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError";
27
24
  readonly RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError";
28
25
  readonly CONFIGURATION_ERROR: "ConfigurationError";
29
26
  readonly MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError";
@@ -118,7 +115,21 @@ declare const ERROR_CONFIG: {
118
115
  severity: Severity;
119
116
  };
120
117
  };
121
- declare class CopilotKitError extends GraphQLError {
118
+ interface CopilotKitErrorExtensions {
119
+ name: string;
120
+ statusCode: number;
121
+ code: CopilotKitErrorCode;
122
+ visibility: ErrorVisibility;
123
+ severity?: Severity;
124
+ troubleshootingUrl: string | null;
125
+ originalError: {
126
+ message: string;
127
+ stack?: string;
128
+ };
129
+ }
130
+ declare class CopilotKitError extends Error {
131
+ /** Structured error details, kept in the shape GraphQL errors used in 1.x. */
132
+ extensions: CopilotKitErrorExtensions;
122
133
  code: CopilotKitErrorCode;
123
134
  statusCode: number;
124
135
  severity?: Severity;
@@ -150,18 +161,6 @@ declare class CopilotKitMisuseError extends CopilotKitError {
150
161
  code?: CopilotKitErrorCode;
151
162
  });
152
163
  }
153
- /**
154
- * Error thrown when CPK versions does not match
155
- *
156
- * @extends CopilotKitError
157
- */
158
- declare class CopilotKitVersionMismatchError extends CopilotKitError {
159
- constructor({
160
- reactCoreVersion,
161
- runtimeVersion,
162
- runtimeClientGqlVersion
163
- }: VersionMismatchResponse);
164
- }
165
164
  /**
166
165
  * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
167
166
  * This typically occurs when:
@@ -290,23 +289,6 @@ declare function isStructuredCopilotKitError(error: any): boolean;
290
289
  * @returns The structured error
291
290
  */
292
291
  declare function ensureStructuredError<T extends CopilotKitError>(error: any, converter: (error: any) => T): T | any;
293
- interface VersionMismatchResponse {
294
- runtimeVersion?: string;
295
- runtimeClientGqlVersion: string;
296
- reactCoreVersion: string;
297
- }
298
- declare function getPossibleVersionMismatch({
299
- runtimeVersion,
300
- runtimeClientGqlVersion
301
- }: {
302
- runtimeVersion?: string;
303
- runtimeClientGqlVersion: string;
304
- }): Promise<{
305
- runtimeVersion: string;
306
- runtimeClientGqlVersion: string;
307
- reactCoreVersion: string;
308
- message: string;
309
- } | undefined>;
310
292
  //#endregion
311
- 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, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError };
293
+ export { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitErrorExtensions, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, isStructuredCopilotKitError };
312
294
  //# sourceMappingURL=errors.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/utils/errors.ts"],"mappings":";;;aAGY,QAAA;EACV,QAAA;EAAA;EACA,OAAA;EAAA;EACA,IAAA;AAAA;AAAA,aAGU,eAAA;EACV,MAAA;EAAA;EACA,KAAA;EAAA;EACA,MAAA;EAAA;EACA,QAAA;AAAA;AAAA,cAGW,WAAA;EAAA;;;;;;;;;;;cAeA,kBAAA;AAAA,cAUA,yBAAA;AAAA,aAED,mBAAA;EACV,aAAA;EACA,SAAA;EACA,eAAA;EACA,aAAA;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AA,cAOD,oBAAA,SAA6B,kBAAA;cAC5B,OAAA;AAAA;;;;;;;;iBAcE,2BAAA,CAA4B,KAAA;;;;;;;AA9M5C;;iBA+NgB,qBAAA,WAAgC,eAAA,CAAA,CAC9C,KAAA,OACA,SAAA,GAAY,KAAA,UAAe,CAAA,GAC1B,CAAA"}
@@ -1,6 +1,3 @@
1
- import { COPILOTKIT_VERSION } from "../index.mjs";
2
- import { GraphQLError } from "graphql";
3
-
4
1
  //#region src/utils/errors.ts
5
2
  let Severity = /* @__PURE__ */ function(Severity) {
6
3
  Severity["CRITICAL"] = "critical";
@@ -21,7 +18,6 @@ const ERROR_NAMES = {
21
18
  COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError",
22
19
  COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError",
23
20
  COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError",
24
- COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError",
25
21
  RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError",
26
22
  CONFIGURATION_ERROR: "ConfigurationError",
27
23
  MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
@@ -126,14 +122,15 @@ const ERROR_CONFIG = {
126
122
  severity: Severity.INFO
127
123
  }
128
124
  };
129
- var CopilotKitError = class extends GraphQLError {
125
+ var CopilotKitError = class extends Error {
130
126
  constructor({ message = "Unknown error occurred", code, severity, visibility }) {
131
127
  const name = ERROR_NAMES.COPILOT_ERROR;
132
128
  const config = ERROR_CONFIG[code];
133
129
  const { statusCode } = config;
134
130
  const resolvedVisibility = visibility ?? config.visibility ?? ErrorVisibility.TOAST;
135
131
  const resolvedSeverity = severity ?? ("severity" in config ? config.severity : void 0);
136
- super(message, { extensions: {
132
+ super(message);
133
+ this.extensions = {
137
134
  name,
138
135
  statusCode,
139
136
  code,
@@ -144,7 +141,7 @@ var CopilotKitError = class extends GraphQLError {
144
141
  message,
145
142
  stack: (/* @__PURE__ */ new Error()).stack
146
143
  }
147
- } });
144
+ };
148
145
  this.code = code;
149
146
  this.name = name;
150
147
  this.statusCode = statusCode;
@@ -169,26 +166,6 @@ var CopilotKitMisuseError = class extends CopilotKitError {
169
166
  this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;
170
167
  }
171
168
  };
172
- const getVersionMismatchErrorMessage = ({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion }) => `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.`;
173
- /**
174
- * Error thrown when CPK versions does not match
175
- *
176
- * @extends CopilotKitError
177
- */
178
- var CopilotKitVersionMismatchError = class extends CopilotKitError {
179
- constructor({ reactCoreVersion, runtimeVersion, runtimeClientGqlVersion }) {
180
- const code = CopilotKitErrorCode.VERSION_MISMATCH;
181
- super({
182
- message: getVersionMismatchErrorMessage({
183
- reactCoreVersion,
184
- runtimeVersion,
185
- runtimeClientGqlVersion
186
- }),
187
- code
188
- });
189
- this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;
190
- }
191
- };
192
169
  /**
193
170
  * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
194
171
  * This typically occurs when:
@@ -376,19 +353,6 @@ function isStructuredCopilotKitError(error) {
376
353
  function ensureStructuredError(error, converter) {
377
354
  return isStructuredCopilotKitError(error) ? error : converter(error);
378
355
  }
379
- async function getPossibleVersionMismatch({ runtimeVersion, runtimeClientGqlVersion }) {
380
- if (!runtimeVersion || runtimeVersion === "" || !runtimeClientGqlVersion) return;
381
- if (COPILOTKIT_VERSION !== runtimeVersion || COPILOTKIT_VERSION !== runtimeClientGqlVersion || runtimeVersion !== runtimeClientGqlVersion) return {
382
- runtimeVersion,
383
- runtimeClientGqlVersion,
384
- reactCoreVersion: COPILOTKIT_VERSION,
385
- message: getVersionMismatchErrorMessage({
386
- runtimeVersion,
387
- runtimeClientGqlVersion,
388
- reactCoreVersion: COPILOTKIT_VERSION
389
- })
390
- };
391
- }
392
356
  const resolveLowLevelErrorMessage = ({ errorCode, url }) => {
393
357
  const troubleshootingLink = ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;
394
358
  const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.
@@ -414,5 +378,5 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
414
378
  };
415
379
 
416
380
  //#endregion
417
- 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, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError };
381
+ export { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, isStructuredCopilotKitError };
418
382
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../src/utils/errors.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:\n \"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 AUTHENTICATION_ERROR = \"AUTHENTICATION_ERROR\",\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#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/langgraph-python/coagent-troubleshooting/common-coagent-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#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#remote-endpoint-not-found-error`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AUTHENTICATION_ERROR]: {\n statusCode: 401,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues`,\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.CRITICAL,\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 =\n visibility ?? config.visibility ?? ErrorVisibility.TOAST;\n const resolvedSeverity =\n 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:\n \"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] &&\n 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?:\n | CopilotKitErrorCode.API_NOT_FOUND\n | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n url?: string;\n } = {},\n ) {\n const url = params.url ?? \"\";\n let operationSuffix = \"\";\n if (url?.includes(\"/info\"))\n 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\"))\n 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: {\n agentName?: string;\n availableAgents: { name: string; id: string }[];\n }) {\n const { agentName, availableAgents } = params;\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n\n const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);\n let message;\n\n if (availableAgents.length) {\n const agentList = availableAgents.map((agent) => agent.name).join(\", \");\n\n if (agentName) {\n message = `Agent '${agentName}' was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n } else {\n message = `The requested agent was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n }\n } else {\n message = `${agentName ? `Agent '${agentName}'` : \"The requested agent\"} was not found. Please set up at least one agent before proceeding. ${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({\n error,\n url,\n message,\n }: {\n error: Error;\n url: string;\n message?: string;\n }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n // @ts-expect-error -- code may exist\n const errorCode = error.code as string;\n const errorMessage =\n 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 break;\n }\n }\n\n super({ message, code: resolvedCode });\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\n/**\n * Checks if an error is already a structured CopilotKit error.\n * This utility centralizes the logic for detecting structured errors across the codebase.\n *\n * @param error - The error to check\n * @returns true if the error is already structured, false otherwise\n */\nexport function isStructuredCopilotKitError(error: any): boolean {\n return (\n error instanceof CopilotKitError ||\n error instanceof CopilotKitLowLevelError ||\n (error?.name && error.name.includes(\"CopilotKit\")) ||\n error?.extensions?.code !== undefined // Check if it has our structured error properties\n );\n}\n\n/**\n * Returns the error as-is if it's already structured, otherwise converts it using the provided converter function.\n * This utility centralizes the pattern of preserving structured errors while converting unstructured ones.\n *\n * @param error - The error to process\n * @param converter - Function to convert unstructured errors to structured ones\n * @returns The structured error\n */\nexport function ensureStructuredError<T extends CopilotKitError>(\n error: any,\n converter: (error: any) => T,\n): T | any {\n return isStructuredCopilotKitError(error) ? error : converter(error);\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)\n 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 = ({\n errorCode,\n url,\n}: {\n errorCode?: string;\n url: string;\n}) => {\n const troubleshootingLink =\n ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;\n const genericMessage = (\n description = `Failed to fetch from url ${url}.`,\n ) => `${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(\n `Failed to fetch CopilotKit agents/action information from url ${url}.`,\n );\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"],"mappings":";;;;AAGA,IAAY,8CAAL;AACL;AACA;AACA;;;AAGF,IAAY,4DAAL;AACL;AACA;AACA;AACA;;;AAGF,MAAa,cAAc;CACzB,eAAe;CACf,6BAA6B;CAC7B,yCACE;CACF,mCAAmC;CACnC,6BAA6B;CAC7B,oCAAoC;CACpC,4BAA4B;CAC5B,qBAAqB;CACrB,8BAA8B;CAC9B,wBAAwB;CACzB;AAGD,MAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAGD,MAAa,4BAA4B;AAEzC,IAAY,oEAAL;A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AAS,aAAa,IACjD,OAAO,YAAY,SAAS;;;;;;;;;;AAYhC,SAAgB,sBACd,OACA,WACS;AACT,QAAO,4BAA4B,MAAM,GAAG,QAAQ,UAAU,MAAM;;AAStE,eAAsB,2BAA2B,EAC/C,gBACA,2BAIC;AACD,KAAI,CAAC,kBAAkB,mBAAmB,MAAM,CAAC,wBAC/C;AACF,KACE,uBAAuB,kBACvB,uBAAuB,2BACvB,mBAAmB,wBAEnB,QAAO;EACL;EACA;EACA,kBAAkB;EAClB,SAAS,+BAA+B;GACtC;GACA;GACA,kBAAkB;GACnB,CAAC;EACH;;AAML,MAAM,+BAA+B,EACnC,WACA,UAII;CACJ,MAAM,sBACJ,aAAa,oBAAoB,eAAe;CAClD,MAAM,kBACJ,cAAc,4BAA4B,IAAI,OAC3C,GAAG,YAAY;;;;;;;;;EASpB,mBAAmB,oBAAoB;AAEvC,KAAI,IAAI,SAAS,QAAQ,CACvB,QAAO,eACL,iEAAiE,IAAI,GACtE;AACH,KAAI,IAAI,SAAS,mBAAmB,CAClC,QAAO,eAAe,iBAAiB,IAAI,6BAA6B;AAC1E,KAAI,IAAI,SAAS,gBAAgB,CAC/B,QAAO,eAAe,iBAAiB,IAAI,6BAA6B;AAC1E,KAAI,IAAI,SAAS,kBAAkB,CACjC,QAAO,eAAe,iBAAiB,IAAI,8BAA8B;AAE3E,SAAQ,WAAR;EACE,KAAK,eACH,QAAO,iBAAiB,IAAI,gEAAgE,mBAAmB,oBAAoB;EACrI,KAAK,YACH,QAAO,iBAAiB,IAAI,uEAAuE,mBAAmB,aAAa,oBAAoB,WAAW,mBAAmB;EACvL,KAAK,YACH,QAAO,qBAAqB,IAAI,+EAA+E,mBAAmB,oBAAoB;EACxJ,QACE"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["export 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:\n \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\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 AUTHENTICATION_ERROR = \"AUTHENTICATION_ERROR\",\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#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#network-errors-api-not-found`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/langgraph-python/coagent-troubleshooting/common-coagent-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#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#remote-endpoint-not-found-error`,\n visibility: ErrorVisibility.BANNER,\n severity: Severity.CRITICAL,\n },\n [CopilotKitErrorCode.AUTHENTICATION_ERROR]: {\n statusCode: 401,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues`,\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.CRITICAL,\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 interface CopilotKitErrorExtensions {\n name: string;\n statusCode: number;\n code: CopilotKitErrorCode;\n visibility: ErrorVisibility;\n severity?: Severity;\n troubleshootingUrl: string | null;\n originalError: { message: string; stack?: string };\n}\n\nexport class CopilotKitError extends Error {\n /** Structured error details, kept in the shape GraphQL errors used in 1.x. */\n extensions: CopilotKitErrorExtensions;\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 =\n visibility ?? config.visibility ?? ErrorVisibility.TOAST;\n const resolvedSeverity =\n severity ?? (\"severity\" in config ? config.severity : undefined);\n\n super(message);\n\n this.extensions = {\n name,\n statusCode,\n code,\n visibility: resolvedVisibility,\n severity: resolvedSeverity,\n troubleshootingUrl:\n \"troubleshootingUrl\" in config ? config.troubleshootingUrl : null,\n originalError: {\n message,\n stack: new Error().stack,\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] &&\n 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\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?:\n | CopilotKitErrorCode.API_NOT_FOUND\n | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n url?: string;\n } = {},\n ) {\n const url = params.url ?? \"\";\n let operationSuffix = \"\";\n if (url?.includes(\"/info\"))\n 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\"))\n 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: {\n agentName?: string;\n availableAgents: { name: string; id: string }[];\n }) {\n const { agentName, availableAgents } = params;\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n\n const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);\n let message;\n\n if (availableAgents.length) {\n const agentList = availableAgents.map((agent) => agent.name).join(\", \");\n\n if (agentName) {\n message = `Agent '${agentName}' was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n } else {\n message = `The requested agent was not found. Available agents are: ${agentList}. Please verify the agent name in your configuration and ensure it matches one of the available agents.\\n\\n${seeMore}`;\n }\n } else {\n message = `${agentName ? `Agent '${agentName}'` : \"The requested agent\"} was not found. Please set up at least one agent before proceeding. ${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({\n error,\n url,\n message,\n }: {\n error: Error;\n url: string;\n message?: string;\n }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n // @ts-expect-error -- code may exist\n const errorCode = error.code as string;\n const errorMessage =\n 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 break;\n }\n }\n\n super({ message, code: resolvedCode });\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\n/**\n * Checks if an error is already a structured CopilotKit error.\n * This utility centralizes the logic for detecting structured errors across the codebase.\n *\n * @param error - The error to check\n * @returns true if the error is already structured, false otherwise\n */\nexport function isStructuredCopilotKitError(error: any): boolean {\n return (\n error instanceof CopilotKitError ||\n error instanceof CopilotKitLowLevelError ||\n (error?.name && error.name.includes(\"CopilotKit\")) ||\n error?.extensions?.code !== undefined // Check if it has our structured error properties\n );\n}\n\n/**\n * Returns the error as-is if it's already structured, otherwise converts it using the provided converter function.\n * This utility centralizes the pattern of preserving structured errors while converting unstructured ones.\n *\n * @param error - The error to process\n * @param converter - Function to convert unstructured errors to structured ones\n * @returns The structured error\n */\nexport function ensureStructuredError<T extends CopilotKitError>(\n error: any,\n converter: (error: any) => T,\n): T | any {\n return isStructuredCopilotKitError(error) ? error : converter(error);\n}\n\nconst resolveLowLevelErrorMessage = ({\n errorCode,\n url,\n}: {\n errorCode?: string;\n url: string;\n}) => {\n const troubleshootingLink =\n ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;\n const genericMessage = (\n description = `Failed to fetch from url ${url}.`,\n ) => `${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(\n `Failed to fetch CopilotKit agents/action information from url ${url}.`,\n );\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"],"mappings":";AAAA,IAAY,8CAAL;AACL;AACA;AACA;;;AAGF,IAAY,4DAAL;AACL;AACA;AACA;AACA;;;AAGF,MAAa,cAAc;CACzB,eAAe;CACf,6BAA6B;CAC7B,yCACE;C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