@copilotkit/shared 1.51.5-next.0 → 1.51.5-next.2

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 (254) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/constants/index.cjs +13 -0
  4. package/dist/constants/index.cjs.map +1 -0
  5. package/dist/constants/{index.d.ts → index.d.cts} +3 -1
  6. package/dist/constants/index.d.cts.map +1 -0
  7. package/dist/constants/index.d.mts +8 -0
  8. package/dist/constants/index.d.mts.map +1 -0
  9. package/dist/constants/index.mjs +8 -12
  10. package/dist/constants/index.mjs.map +1 -1
  11. package/dist/index.cjs +64 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +22 -0
  14. package/dist/index.d.cts.map +1 -0
  15. package/dist/index.d.mts +23 -0
  16. package/dist/index.d.mts.map +1 -0
  17. package/dist/index.mjs +16 -123
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/index.umd.js +1017 -2
  20. package/dist/index.umd.js.map +1 -1
  21. package/dist/package.cjs +12 -0
  22. package/dist/package.cjs.map +1 -0
  23. package/dist/package.mjs +6 -0
  24. package/dist/package.mjs.map +1 -0
  25. package/dist/telemetry/events.d.cts +47 -0
  26. package/dist/telemetry/events.d.cts.map +1 -0
  27. package/dist/telemetry/events.d.mts +47 -0
  28. package/dist/telemetry/events.d.mts.map +1 -0
  29. package/dist/telemetry/index.d.mts +1 -0
  30. package/dist/telemetry/scarf-client.cjs +29 -0
  31. package/dist/telemetry/scarf-client.cjs.map +1 -0
  32. package/dist/telemetry/scarf-client.mjs +27 -5
  33. package/dist/telemetry/scarf-client.mjs.map +1 -1
  34. package/dist/telemetry/telemetry-client.cjs +87 -0
  35. package/dist/telemetry/telemetry-client.cjs.map +1 -0
  36. package/dist/telemetry/telemetry-client.d.cts +48 -0
  37. package/dist/telemetry/telemetry-client.d.cts.map +1 -0
  38. package/dist/telemetry/telemetry-client.d.mts +48 -0
  39. package/dist/telemetry/telemetry-client.d.mts.map +1 -0
  40. package/dist/telemetry/telemetry-client.mjs +83 -9
  41. package/dist/telemetry/telemetry-client.mjs.map +1 -1
  42. package/dist/telemetry/utils.cjs +16 -0
  43. package/dist/telemetry/utils.cjs.map +1 -0
  44. package/dist/telemetry/utils.mjs +14 -8
  45. package/dist/telemetry/utils.mjs.map +1 -1
  46. package/dist/types/{action.d.ts → action.d.cts} +32 -32
  47. package/dist/types/action.d.cts.map +1 -0
  48. package/dist/types/action.d.mts +59 -0
  49. package/dist/types/action.d.mts.map +1 -0
  50. package/dist/types/copilot-cloud-config.d.cts +15 -0
  51. package/dist/types/copilot-cloud-config.d.cts.map +1 -0
  52. package/dist/types/copilot-cloud-config.d.mts +15 -0
  53. package/dist/types/copilot-cloud-config.d.mts.map +1 -0
  54. package/dist/types/error.d.cts +57 -0
  55. package/dist/types/error.d.cts.map +1 -0
  56. package/dist/types/error.d.mts +57 -0
  57. package/dist/types/error.d.mts.map +1 -0
  58. package/dist/types/{message.d.ts → message.d.cts} +14 -12
  59. package/dist/types/message.d.cts.map +1 -0
  60. package/dist/types/message.d.mts +31 -0
  61. package/dist/types/message.d.mts.map +1 -0
  62. package/dist/types/openai-assistant.d.cts +55 -0
  63. package/dist/types/openai-assistant.d.cts.map +1 -0
  64. package/dist/types/openai-assistant.d.mts +55 -0
  65. package/dist/types/openai-assistant.d.mts.map +1 -0
  66. package/dist/types/utility.d.cts +6 -0
  67. package/dist/types/utility.d.cts.map +1 -0
  68. package/dist/types/utility.d.mts +6 -0
  69. package/dist/types/utility.d.mts.map +1 -0
  70. package/dist/utils/conditions.cjs +32 -0
  71. package/dist/utils/conditions.cjs.map +1 -0
  72. package/dist/utils/{conditions.d.ts → conditions.d.cts} +16 -11
  73. package/dist/utils/conditions.d.cts.map +1 -0
  74. package/dist/utils/conditions.d.mts +31 -0
  75. package/dist/utils/conditions.d.mts.map +1 -0
  76. package/dist/utils/conditions.mjs +30 -6
  77. package/dist/utils/conditions.mjs.map +1 -1
  78. package/dist/utils/console-styling.cjs +91 -0
  79. package/dist/utils/console-styling.cjs.map +1 -0
  80. package/dist/utils/console-styling.d.cts +65 -0
  81. package/dist/utils/console-styling.d.cts.map +1 -0
  82. package/dist/utils/console-styling.d.mts +65 -0
  83. package/dist/utils/console-styling.d.mts.map +1 -0
  84. package/dist/utils/console-styling.mjs +83 -15
  85. package/dist/utils/console-styling.mjs.map +1 -1
  86. package/dist/utils/errors.cjs +439 -0
  87. package/dist/utils/errors.cjs.map +1 -0
  88. package/dist/utils/{errors.d.ts → errors.d.cts} +188 -156
  89. package/dist/utils/errors.d.cts.map +1 -0
  90. package/dist/utils/errors.d.mts +312 -0
  91. package/dist/utils/errors.d.mts.map +1 -0
  92. package/dist/utils/errors.mjs +416 -63
  93. package/dist/utils/errors.mjs.map +1 -1
  94. package/dist/utils/index.cjs +50 -0
  95. package/dist/utils/index.cjs.map +1 -0
  96. package/dist/utils/{index.d.ts → index.d.cts} +10 -11
  97. package/dist/utils/index.d.cts.map +1 -0
  98. package/dist/utils/index.d.mts +31 -0
  99. package/dist/utils/index.d.mts.map +1 -0
  100. package/dist/utils/index.mjs +47 -107
  101. package/dist/utils/index.mjs.map +1 -1
  102. package/dist/utils/json-schema.cjs +157 -0
  103. package/dist/utils/json-schema.cjs.map +1 -0
  104. package/dist/utils/{json-schema.d.ts → json-schema.d.cts} +19 -17
  105. package/dist/utils/json-schema.d.cts.map +1 -0
  106. package/dist/utils/json-schema.d.mts +36 -0
  107. package/dist/utils/json-schema.d.mts.map +1 -0
  108. package/dist/utils/json-schema.mjs +152 -12
  109. package/dist/utils/json-schema.mjs.map +1 -1
  110. package/dist/utils/random-id.cjs +38 -0
  111. package/dist/utils/random-id.cjs.map +1 -0
  112. package/dist/utils/{random-id.d.ts → random-id.d.cts} +3 -1
  113. package/dist/utils/random-id.d.cts.map +1 -0
  114. package/dist/utils/random-id.d.mts +8 -0
  115. package/dist/utils/random-id.d.mts.map +1 -0
  116. package/dist/utils/random-id.mjs +33 -12
  117. package/dist/utils/random-id.mjs.map +1 -1
  118. package/dist/utils/requests.cjs +58 -0
  119. package/dist/utils/requests.cjs.map +1 -0
  120. package/dist/utils/{requests.d.ts → requests.d.cts} +3 -1
  121. package/dist/utils/requests.d.cts.map +1 -0
  122. package/dist/utils/requests.d.mts +12 -0
  123. package/dist/utils/requests.d.mts.map +1 -0
  124. package/dist/utils/requests.mjs +56 -6
  125. package/dist/utils/requests.mjs.map +1 -1
  126. package/dist/utils/{types.d.ts → types.d.cts} +9 -7
  127. package/dist/utils/types.d.cts.map +1 -0
  128. package/dist/utils/types.d.mts +22 -0
  129. package/dist/utils/types.d.mts.map +1 -0
  130. package/package.json +16 -14
  131. package/tsdown.config.ts +36 -0
  132. package/vitest.config.mjs +11 -0
  133. package/dist/chunk-2OJ5OJ2D.mjs +0 -1
  134. package/dist/chunk-2OJ5OJ2D.mjs.map +0 -1
  135. package/dist/chunk-3DK3UMRW.mjs +0 -217
  136. package/dist/chunk-3DK3UMRW.mjs.map +0 -1
  137. package/dist/chunk-7KOT4KP4.mjs +0 -435
  138. package/dist/chunk-7KOT4KP4.mjs.map +0 -1
  139. package/dist/chunk-DE5XAMMI.mjs +0 -110
  140. package/dist/chunk-DE5XAMMI.mjs.map +0 -1
  141. package/dist/chunk-FCCOSO5L.mjs +0 -1
  142. package/dist/chunk-FCCOSO5L.mjs.map +0 -1
  143. package/dist/chunk-GS5BLXSZ.mjs +0 -41
  144. package/dist/chunk-GS5BLXSZ.mjs.map +0 -1
  145. package/dist/chunk-IAFBVORQ.mjs +0 -1
  146. package/dist/chunk-IAFBVORQ.mjs.map +0 -1
  147. package/dist/chunk-M2RJI5BZ.mjs +0 -94
  148. package/dist/chunk-M2RJI5BZ.mjs.map +0 -1
  149. package/dist/chunk-MSUB6DGR.mjs +0 -1
  150. package/dist/chunk-MSUB6DGR.mjs.map +0 -1
  151. package/dist/chunk-N5EP5OD5.mjs +0 -1
  152. package/dist/chunk-N5EP5OD5.mjs.map +0 -1
  153. package/dist/chunk-NAFEBKSO.mjs +0 -1
  154. package/dist/chunk-NAFEBKSO.mjs.map +0 -1
  155. package/dist/chunk-P7STFMPO.mjs +0 -1
  156. package/dist/chunk-P7STFMPO.mjs.map +0 -1
  157. package/dist/chunk-UYARLQNA.mjs +0 -1
  158. package/dist/chunk-UYARLQNA.mjs.map +0 -1
  159. package/dist/chunk-V7BSERGI.mjs +0 -62
  160. package/dist/chunk-V7BSERGI.mjs.map +0 -1
  161. package/dist/chunk-WAZHII6M.mjs +0 -67
  162. package/dist/chunk-WAZHII6M.mjs.map +0 -1
  163. package/dist/chunk-XTHC46M2.mjs +0 -1
  164. package/dist/chunk-XTHC46M2.mjs.map +0 -1
  165. package/dist/chunk-ZI7ZVRL3.mjs +0 -38
  166. package/dist/chunk-ZI7ZVRL3.mjs.map +0 -1
  167. package/dist/chunk-ZIC6V6S5.mjs +0 -13
  168. package/dist/chunk-ZIC6V6S5.mjs.map +0 -1
  169. package/dist/chunk-ZUE2VR7D.mjs +0 -38
  170. package/dist/chunk-ZUE2VR7D.mjs.map +0 -1
  171. package/dist/constants/index.js +0 -40
  172. package/dist/constants/index.js.map +0 -1
  173. package/dist/index.d.ts +0 -25
  174. package/dist/index.js +0 -1138
  175. package/dist/index.js.map +0 -1
  176. package/dist/telemetry/events.d.ts +0 -45
  177. package/dist/telemetry/events.js +0 -19
  178. package/dist/telemetry/events.js.map +0 -1
  179. package/dist/telemetry/events.mjs +0 -1
  180. package/dist/telemetry/events.mjs.map +0 -1
  181. package/dist/telemetry/index.d.ts +0 -3
  182. package/dist/telemetry/index.js +0 -191
  183. package/dist/telemetry/index.js.map +0 -1
  184. package/dist/telemetry/index.mjs +0 -12
  185. package/dist/telemetry/index.mjs.map +0 -1
  186. package/dist/telemetry/scarf-client.d.ts +0 -7
  187. package/dist/telemetry/scarf-client.js +0 -59
  188. package/dist/telemetry/scarf-client.js.map +0 -1
  189. package/dist/telemetry/security-check.d.ts +0 -2
  190. package/dist/telemetry/security-check.js +0 -2
  191. package/dist/telemetry/security-check.js.map +0 -1
  192. package/dist/telemetry/security-check.mjs +0 -1
  193. package/dist/telemetry/security-check.mjs.map +0 -1
  194. package/dist/telemetry/telemetry-client.d.ts +0 -40
  195. package/dist/telemetry/telemetry-client.js +0 -189
  196. package/dist/telemetry/telemetry-client.js.map +0 -1
  197. package/dist/telemetry/utils.d.ts +0 -8
  198. package/dist/telemetry/utils.js +0 -73
  199. package/dist/telemetry/utils.js.map +0 -1
  200. package/dist/types/action.js +0 -19
  201. package/dist/types/action.js.map +0 -1
  202. package/dist/types/action.mjs +0 -2
  203. package/dist/types/action.mjs.map +0 -1
  204. package/dist/types/copilot-cloud-config.d.ts +0 -13
  205. package/dist/types/copilot-cloud-config.js +0 -19
  206. package/dist/types/copilot-cloud-config.js.map +0 -1
  207. package/dist/types/copilot-cloud-config.mjs +0 -2
  208. package/dist/types/copilot-cloud-config.mjs.map +0 -1
  209. package/dist/types/error.d.ts +0 -55
  210. package/dist/types/error.js +0 -19
  211. package/dist/types/error.js.map +0 -1
  212. package/dist/types/error.mjs +0 -2
  213. package/dist/types/error.mjs.map +0 -1
  214. package/dist/types/index.d.ts +0 -7
  215. package/dist/types/index.js +0 -19
  216. package/dist/types/index.js.map +0 -1
  217. package/dist/types/index.mjs +0 -8
  218. package/dist/types/index.mjs.map +0 -1
  219. package/dist/types/message.js +0 -19
  220. package/dist/types/message.js.map +0 -1
  221. package/dist/types/message.mjs +0 -2
  222. package/dist/types/message.mjs.map +0 -1
  223. package/dist/types/openai-assistant.d.ts +0 -53
  224. package/dist/types/openai-assistant.js +0 -19
  225. package/dist/types/openai-assistant.js.map +0 -1
  226. package/dist/types/openai-assistant.mjs +0 -2
  227. package/dist/types/openai-assistant.mjs.map +0 -1
  228. package/dist/types/utility.d.ts +0 -6
  229. package/dist/types/utility.js +0 -19
  230. package/dist/types/utility.js.map +0 -1
  231. package/dist/types/utility.mjs +0 -2
  232. package/dist/types/utility.mjs.map +0 -1
  233. package/dist/utils/conditions.js +0 -86
  234. package/dist/utils/conditions.js.map +0 -1
  235. package/dist/utils/console-styling.d.ts +0 -84
  236. package/dist/utils/console-styling.js +0 -123
  237. package/dist/utils/console-styling.js.map +0 -1
  238. package/dist/utils/errors.js +0 -452
  239. package/dist/utils/errors.js.map +0 -1
  240. package/dist/utils/index.js +0 -964
  241. package/dist/utils/index.js.map +0 -1
  242. package/dist/utils/json-schema.js +0 -244
  243. package/dist/utils/json-schema.js.map +0 -1
  244. package/dist/utils/random-id.js +0 -68
  245. package/dist/utils/random-id.js.map +0 -1
  246. package/dist/utils/requests.js +0 -91
  247. package/dist/utils/requests.js.map +0 -1
  248. package/dist/utils/types.js +0 -19
  249. package/dist/utils/types.js.map +0 -1
  250. package/dist/utils/types.mjs +0 -2
  251. package/dist/utils/types.mjs.map +0 -1
  252. package/jest.config.js +0 -5
  253. package/rollup.config.mjs +0 -54
  254. package/tsup.config.ts +0 -15
@@ -0,0 +1,312 @@
1
+ import { GraphQLError } from "graphql";
2
+
3
+ //#region src/utils/errors.d.ts
4
+ declare enum Severity {
5
+ CRITICAL = "critical",
6
+ // Critical errors that block core functionality
7
+ WARNING = "warning",
8
+ // Configuration/setup issues that need attention
9
+ INFO = "info"
10
+ }
11
+ declare enum ErrorVisibility {
12
+ BANNER = "banner",
13
+ // Critical errors shown as fixed banners
14
+ TOAST = "toast",
15
+ // Regular errors shown as dismissible toasts
16
+ SILENT = "silent",
17
+ // Errors logged but not shown to user
18
+ DEV_ONLY = "dev_only"
19
+ }
20
+ declare const ERROR_NAMES: {
21
+ readonly COPILOT_ERROR: "CopilotError";
22
+ readonly COPILOT_API_DISCOVERY_ERROR: "CopilotApiDiscoveryError";
23
+ readonly COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError";
24
+ readonly COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError";
25
+ readonly COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError";
26
+ readonly COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError";
27
+ readonly RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError";
28
+ readonly CONFIGURATION_ERROR: "ConfigurationError";
29
+ readonly MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError";
30
+ readonly UPGRADE_REQUIRED_ERROR: "UpgradeRequiredError";
31
+ };
32
+ declare const BANNER_ERROR_NAMES: ("CopilotApiDiscoveryError" | "CopilotKitRemoteEndpointDiscoveryError" | "CopilotKitAgentDiscoveryError" | "ConfigurationError" | "MissingPublicApiKeyError" | "UpgradeRequiredError")[];
33
+ declare const COPILOT_CLOUD_ERROR_NAMES: ("CopilotApiDiscoveryError" | "CopilotKitRemoteEndpointDiscoveryError" | "CopilotKitAgentDiscoveryError" | "ConfigurationError" | "MissingPublicApiKeyError" | "UpgradeRequiredError")[];
34
+ declare enum CopilotKitErrorCode {
35
+ NETWORK_ERROR = "NETWORK_ERROR",
36
+ NOT_FOUND = "NOT_FOUND",
37
+ AGENT_NOT_FOUND = "AGENT_NOT_FOUND",
38
+ API_NOT_FOUND = "API_NOT_FOUND",
39
+ REMOTE_ENDPOINT_NOT_FOUND = "REMOTE_ENDPOINT_NOT_FOUND",
40
+ AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR",
41
+ MISUSE = "MISUSE",
42
+ UNKNOWN = "UNKNOWN",
43
+ VERSION_MISMATCH = "VERSION_MISMATCH",
44
+ CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
45
+ MISSING_PUBLIC_API_KEY_ERROR = "MISSING_PUBLIC_API_KEY_ERROR",
46
+ UPGRADE_REQUIRED_ERROR = "UPGRADE_REQUIRED_ERROR"
47
+ }
48
+ declare const ERROR_CONFIG: {
49
+ NETWORK_ERROR: {
50
+ statusCode: number;
51
+ troubleshootingUrl: string;
52
+ visibility: ErrorVisibility;
53
+ severity: Severity;
54
+ };
55
+ NOT_FOUND: {
56
+ statusCode: number;
57
+ troubleshootingUrl: string;
58
+ visibility: ErrorVisibility;
59
+ severity: Severity;
60
+ };
61
+ AGENT_NOT_FOUND: {
62
+ statusCode: number;
63
+ troubleshootingUrl: string;
64
+ visibility: ErrorVisibility;
65
+ severity: Severity;
66
+ };
67
+ API_NOT_FOUND: {
68
+ statusCode: number;
69
+ troubleshootingUrl: string;
70
+ visibility: ErrorVisibility;
71
+ severity: Severity;
72
+ };
73
+ REMOTE_ENDPOINT_NOT_FOUND: {
74
+ statusCode: number;
75
+ troubleshootingUrl: string;
76
+ visibility: ErrorVisibility;
77
+ severity: Severity;
78
+ };
79
+ AUTHENTICATION_ERROR: {
80
+ statusCode: number;
81
+ troubleshootingUrl: string;
82
+ visibility: ErrorVisibility;
83
+ severity: Severity;
84
+ };
85
+ MISUSE: {
86
+ statusCode: number;
87
+ troubleshootingUrl: null;
88
+ visibility: ErrorVisibility;
89
+ severity: Severity;
90
+ };
91
+ UNKNOWN: {
92
+ statusCode: number;
93
+ visibility: ErrorVisibility;
94
+ severity: Severity;
95
+ };
96
+ CONFIGURATION_ERROR: {
97
+ statusCode: number;
98
+ troubleshootingUrl: null;
99
+ severity: Severity;
100
+ visibility: ErrorVisibility;
101
+ };
102
+ MISSING_PUBLIC_API_KEY_ERROR: {
103
+ statusCode: number;
104
+ troubleshootingUrl: null;
105
+ severity: Severity;
106
+ visibility: ErrorVisibility;
107
+ };
108
+ UPGRADE_REQUIRED_ERROR: {
109
+ statusCode: number;
110
+ troubleshootingUrl: null;
111
+ severity: Severity;
112
+ visibility: ErrorVisibility;
113
+ };
114
+ VERSION_MISMATCH: {
115
+ statusCode: number;
116
+ troubleshootingUrl: null;
117
+ visibility: ErrorVisibility;
118
+ severity: Severity;
119
+ };
120
+ };
121
+ declare class CopilotKitError extends GraphQLError {
122
+ code: CopilotKitErrorCode;
123
+ statusCode: number;
124
+ severity?: Severity;
125
+ visibility: ErrorVisibility;
126
+ constructor({
127
+ message,
128
+ code,
129
+ severity,
130
+ visibility
131
+ }: {
132
+ message?: string;
133
+ code: CopilotKitErrorCode;
134
+ severity?: Severity;
135
+ visibility?: ErrorVisibility;
136
+ });
137
+ }
138
+ /**
139
+ * Error thrown when we can identify wrong usage of our components.
140
+ * This helps us notify the developer before real errors can happen
141
+ *
142
+ * @extends CopilotKitError
143
+ */
144
+ declare class CopilotKitMisuseError extends CopilotKitError {
145
+ constructor({
146
+ message,
147
+ code
148
+ }: {
149
+ message: string;
150
+ code?: CopilotKitErrorCode;
151
+ });
152
+ }
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
+ /**
166
+ * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
167
+ * This typically occurs when:
168
+ * - The API endpoint URL is invalid or misconfigured
169
+ * - The API service is not running at the expected location
170
+ * - There are network/firewall issues preventing access
171
+ *
172
+ * @extends CopilotKitError
173
+ */
174
+ declare class CopilotKitApiDiscoveryError extends CopilotKitError {
175
+ constructor(params?: {
176
+ message?: string;
177
+ code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;
178
+ url?: string;
179
+ });
180
+ }
181
+ /**
182
+ * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted
183
+ * This typically occurs when:
184
+ * - The API endpoint URL is invalid or misconfigured
185
+ * - The API service is not running at the expected location
186
+ *
187
+ * @extends CopilotKitApiDiscoveryError
188
+ */
189
+ declare class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {
190
+ constructor(params?: {
191
+ message?: string;
192
+ url?: string;
193
+ });
194
+ }
195
+ /**
196
+ * Error thrown when a LangGraph agent cannot be found or accessed.
197
+ * This typically occurs when:
198
+ * - The specified agent name does not exist in the deployment
199
+ * - The agent configuration is invalid or missing
200
+ * - The agent service is not properly deployed or initialized
201
+ *
202
+ * @extends CopilotKitError
203
+ */
204
+ declare class CopilotKitAgentDiscoveryError extends CopilotKitError {
205
+ constructor(params: {
206
+ agentName?: string;
207
+ availableAgents: {
208
+ name: string;
209
+ id: string;
210
+ }[];
211
+ });
212
+ }
213
+ /**
214
+ * Handles low-level networking errors that occur before a request reaches the server.
215
+ * These errors arise from issues in the underlying communication infrastructure rather than
216
+ * application-level logic or server responses. Typically used to handle "fetch failed" errors
217
+ * where no HTTP status code is available.
218
+ *
219
+ * Common scenarios include:
220
+ * - Connection failures (ECONNREFUSED) when server is down/unreachable
221
+ * - DNS resolution failures (ENOTFOUND) when domain can't be resolved
222
+ * - Timeouts (ETIMEDOUT) when request takes too long
223
+ * - Protocol/transport layer errors like SSL/TLS issues
224
+ */
225
+ declare class CopilotKitLowLevelError extends CopilotKitError {
226
+ constructor({
227
+ error,
228
+ url,
229
+ message
230
+ }: {
231
+ error: Error;
232
+ url: string;
233
+ message?: string;
234
+ });
235
+ }
236
+ /**
237
+ * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.
238
+ * Used when we receive an HTTP error status and wish to handle broad range of them
239
+ *
240
+ * This differs from CopilotKitLowLevelError in that:
241
+ * - ResolvedCopilotKitError: Server was reached and returned an HTTP status
242
+ * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)
243
+ *
244
+ * @param status - The HTTP status code received from the API response
245
+ * @param message - Optional error message to include
246
+ * @param code - Optional specific CopilotKitErrorCode to override default behavior
247
+ *
248
+ * Default behavior:
249
+ * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError
250
+ * - All other status codes: Maps to UNKNOWN error code if no specific code provided
251
+ */
252
+ declare class ResolvedCopilotKitError extends CopilotKitError {
253
+ constructor({
254
+ status,
255
+ message,
256
+ code,
257
+ isRemoteEndpoint,
258
+ url
259
+ }: {
260
+ status: number;
261
+ message?: string;
262
+ code?: CopilotKitErrorCode;
263
+ isRemoteEndpoint?: boolean;
264
+ url?: string;
265
+ });
266
+ }
267
+ declare class ConfigurationError extends CopilotKitError {
268
+ constructor(message: string);
269
+ }
270
+ declare class MissingPublicApiKeyError extends ConfigurationError {
271
+ constructor(message: string);
272
+ }
273
+ declare class UpgradeRequiredError extends ConfigurationError {
274
+ constructor(message: string);
275
+ }
276
+ /**
277
+ * Checks if an error is already a structured CopilotKit error.
278
+ * This utility centralizes the logic for detecting structured errors across the codebase.
279
+ *
280
+ * @param error - The error to check
281
+ * @returns true if the error is already structured, false otherwise
282
+ */
283
+ declare function isStructuredCopilotKitError(error: any): boolean;
284
+ /**
285
+ * Returns the error as-is if it's already structured, otherwise converts it using the provided converter function.
286
+ * This utility centralizes the pattern of preserving structured errors while converting unstructured ones.
287
+ *
288
+ * @param error - The error to process
289
+ * @param converter - Function to convert unstructured errors to structured ones
290
+ * @returns The structured error
291
+ */
292
+ 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
+ //#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 };
312
+ //# sourceMappingURL=errors.d.mts.map
@@ -0,0 +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;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,IAAA,GAAO,mBAAA;EAAA;AAAA;;;;;;cAwBE,8BAAA,SAAuC,eAAA;;IAEhD,gBAAA;IACA,cAAA;IACA;EAAA,GACC,uBAAA;AAAA;;;;;;;;;;cAuBQ,2BAAA,SAAoC,eAAA;cAE7C,MAAA;IACE,OAAA;IACA,IAAA,GACI,mBAAA,CAAoB,aAAA,GACpB,mBAAA,CAAoB,yBAAA;IACxB,GAAA;EAAA;AAAA;;;;;;;;;cAiCO,sCAAA,SAA+C,2BAAA;cAC9C,MAAA;IAAW,OAAA;IAAkB,GAAA;EAAA;AAAA;;;;;;AA1J3C;;;;cA+Ka,6BAAA,SAAsC,eAAA;cACrC,MAAA;IACV,SAAA;IACA,eAAA;MAAmB,IAAA;MAAc,EAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;;cAqCxB,uBAAA,SAAgC,eAAA;;IAEzC,KAAA;IACA,GAAA;IACA;EAAA;IAEA,KAAA,EAAO,KAAA;IACP,GAAA;IACA,OAAA;EAAA;AAAA;;;;;;;;;;;AAxKJ;;;;;;cAuMa,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;;;;;;;;;iBAiB5B,qBAAA,WAAgC,eAAA,CAAA,CAC9C,KAAA,OACA,SAAA,GAAY,KAAA,UAAe,CAAA,GAC1B,CAAA;AAAA,UAIO,uBAAA;EACR,cAAA;EACA,uBAAA;EACA,gBAAA;AAAA;AAAA,iBAGoB,0BAAA,CAAA;EACpB,cAAA;EACA;AAAA;EAEA,cAAA;EACA,uBAAA;AAAA,IACD,OAAA"}