@copilotkit/shared 0.0.0-feat-langgraph-interrupt-hook-20250203094147 → 0.0.0-feat-enable-setting-recursion-limit-20250424165940

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,240 @@
1
1
  # @copilotkit/shared
2
2
 
3
- ## 0.0.0-feat-langgraph-interrupt-hook-20250203094147
3
+ ## 0.0.0-feat-enable-setting-recursion-limit-20250424165940
4
+
5
+ ## 1.8.7
6
+
7
+ ## 1.8.7-next.0
8
+
9
+ ## 1.8.6
10
+
11
+ ## 1.8.6-next.0
12
+
13
+ ## 1.8.5
14
+
15
+ ## 1.8.5-next.5
16
+
17
+ ## 1.8.5-next.4
18
+
19
+ ## 1.8.5-next.3
20
+
21
+ ## 1.8.5-next.2
22
+
23
+ ## 1.8.5-next.1
24
+
25
+ ## 1.8.5-next.0
26
+
27
+ ## 1.8.4
28
+
29
+ ### Patch Changes
30
+
31
+ - f363760: - fix: when unable to find specified agent, show what's available
32
+
33
+ ## 1.8.4-next.4
34
+
35
+ ## 1.8.4-next.3
36
+
37
+ ## 1.8.4-next.2
38
+
39
+ ## 1.8.4-next.1
40
+
41
+ ### Patch Changes
42
+
43
+ - f363760: - fix: when unable to find specified agent, show what's available
44
+
45
+ ## 1.8.4-next.0
46
+
47
+ ## 1.8.3
48
+
49
+ ## 1.8.3-next.0
50
+
51
+ ## 1.8.2-next.3
52
+
53
+ ## 1.8.2-next.2
54
+
55
+ ## 1.8.2-next.1
56
+
57
+ ## 1.8.2-next.0
58
+
59
+ ## 1.8.1
60
+
61
+ ## 1.8.1-next.1
62
+
63
+ ## 1.8.1-next.0
64
+
65
+ ## 1.8.0
66
+
67
+ ## 1.8.0-next.8
68
+
69
+ ## 1.8.0-next.7
70
+
71
+ ## 1.8.0-next.6
72
+
73
+ ## 1.8.0-next.5
74
+
75
+ ## 1.8.0-next.4
76
+
77
+ ## 1.8.0-next.3
78
+
79
+ ## 1.7.2-next.2
80
+
81
+ ## 1.7.2-next.1
82
+
83
+ ## 1.7.2-next.0
84
+
85
+ ## 1.7.1
86
+
87
+ ## 1.7.1-next.0
88
+
89
+ ## 1.7.0
90
+
91
+ ## 1.7.0-next.1
92
+
93
+ ## 1.7.0-next.0
94
+
95
+ ## 1.6.0
96
+
97
+ ### Patch Changes
98
+
99
+ - 090203d: - fix: use tryMap method to filter out possibly invalid items
100
+
101
+ ## 1.6.0-next.12
102
+
103
+ ## 1.6.0-next.11
104
+
105
+ ## 1.6.0-next.10
106
+
107
+ ## 1.6.0-next.9
108
+
109
+ ## 1.6.0-next.8
110
+
111
+ ## 1.6.0-next.7
112
+
113
+ ## 1.6.0-next.6
114
+
115
+ ## 1.6.0-next.5
116
+
117
+ ### Patch Changes
118
+
119
+ - 090203d: - fix: use tryMap method to filter out possibly invalid items
120
+
121
+ ## 1.6.0-next.4
122
+
123
+ ## 1.6.0-next.3
124
+
125
+ ## 1.6.0-next.2
126
+
127
+ ## 1.6.0-next.1
128
+
129
+ ## 1.6.0-next.0
130
+
131
+ ## 1.5.20
132
+
133
+ ### Patch Changes
134
+
135
+ - 51f0d66: - fix(errors): fix internal usage of error resolver
136
+
137
+ ## 1.5.20-next.0
138
+
139
+ ### Patch Changes
140
+
141
+ - 51f0d66: - fix(errors): fix internal usage of error resolver
142
+
143
+ ## 1.5.19
144
+
145
+ ### Patch Changes
146
+
147
+ - 0dd1ab9: - fix(errors): allow non copilotkit errors to pass to consumer app error boundary
148
+
149
+ ## 1.5.19-next.1
150
+
151
+ ### Patch Changes
152
+
153
+ - 0dd1ab9: - fix(errors): allow non copilotkit errors to pass to consumer app error boundary
154
+
155
+ ## 1.5.19-next.0
156
+
157
+ ## 1.5.18
158
+
159
+ ### Patch Changes
160
+
161
+ - d47cd26: - fix: detect and alert on version mismatch
162
+ - f77a7b9: - fix: use warning when version mismatch is not expected to error out
163
+ - 38d3ac2: - fix: add additional info the our error messages
164
+
165
+ ## 1.5.18-next.3
166
+
167
+ ### Patch Changes
168
+
169
+ - f77a7b9: - fix: use warning when version mismatch is not expected to error out
170
+
171
+ ## 1.5.18-next.2
172
+
173
+ ### Patch Changes
174
+
175
+ - 38d3ac2: - fix: add additional info the our error messages
176
+
177
+ ## 1.5.18-next.1
178
+
179
+ ## 1.5.18-next.0
180
+
181
+ ### Patch Changes
182
+
183
+ - d47cd26: - fix: detect and alert on version mismatch
184
+
185
+ ## 1.5.17
186
+
187
+ ### Patch Changes
188
+
189
+ - 1fc3902: - Revert "fix: detect and alert on version mismatch (#1333)"
190
+
191
+ This reverts commit 48b7c7b1bd48ced82ffb9a00d6eddc1f7581e0c1.
192
+
193
+ ## 1.5.17-next.0
194
+
195
+ ### Patch Changes
196
+
197
+ - 1fc3902: - Revert "fix: detect and alert on version mismatch (#1333)"
198
+
199
+ This reverts commit 48b7c7b1bd48ced82ffb9a00d6eddc1f7581e0c1.
200
+
201
+ ## 1.5.16
202
+
203
+ ### Patch Changes
204
+
205
+ - 48b7c7b: - fix: detect and alert on version mismatch
206
+
207
+ ## 1.5.16-next.2
208
+
209
+ ## 1.5.16-next.1
210
+
211
+ ### Patch Changes
212
+
213
+ - 48b7c7b: - fix: detect and alert on version mismatch
214
+
215
+ ## 1.5.16-next.0
216
+
217
+ ## 1.5.15
218
+
219
+ ### Patch Changes
220
+
221
+ - 7b3141d: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
222
+ - chore(interrupt): add e2e test to interrupt functionality
223
+ - feat(interrupt): add support for multiple interrupts and conditions
224
+
225
+ ## 1.5.15-next.8
226
+
227
+ ## 1.5.15-next.7
228
+
229
+ ## 1.5.15-next.6
230
+
231
+ ## 1.5.15-next.5
232
+
233
+ ## 1.5.15-next.4
4
234
 
5
235
  ### Patch Changes
6
236
 
7
- - 3b1b633: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
237
+ - 7b3141d: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
8
238
  - chore(interrupt): add e2e test to interrupt functionality
9
239
  - feat(interrupt): add support for multiple interrupts and conditions
10
240
 
@@ -1,5 +1,32 @@
1
1
  // src/utils/errors.ts
2
2
  import { GraphQLError } from "graphql";
3
+
4
+ // src/utils/index.ts
5
+ function parseJson(json, fallback = "unset") {
6
+ try {
7
+ return JSON.parse(json);
8
+ } catch (e) {
9
+ return fallback === "unset" ? null : fallback;
10
+ }
11
+ }
12
+ function tryMap(items, callback) {
13
+ return items.reduce((acc, item, index, array) => {
14
+ try {
15
+ acc.push(callback(item, index, array));
16
+ } catch (error) {
17
+ console.error(error);
18
+ }
19
+ return acc;
20
+ }, []);
21
+ }
22
+
23
+ // package.json
24
+ var version = "1.8.7";
25
+
26
+ // src/index.ts
27
+ var COPILOTKIT_VERSION = version;
28
+
29
+ // src/utils/errors.ts
3
30
  var Severity = /* @__PURE__ */ ((Severity2) => {
4
31
  Severity2["Error"] = "error";
5
32
  return Severity2;
@@ -10,11 +37,17 @@ var ERROR_NAMES = {
10
37
  COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: "CopilotKitRemoteEndpointDiscoveryError",
11
38
  COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError",
12
39
  COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError",
40
+ COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError",
13
41
  RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError",
14
42
  CONFIGURATION_ERROR: "ConfigurationError",
15
43
  MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
16
44
  UPGRADE_REQUIRED_ERROR: "UpgradeRequiredError"
17
45
  };
46
+ var COPILOT_CLOUD_ERROR_NAMES = [
47
+ ERROR_NAMES.CONFIGURATION_ERROR,
48
+ ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR,
49
+ ERROR_NAMES.UPGRADE_REQUIRED_ERROR
50
+ ];
18
51
  var CopilotKitErrorCode = /* @__PURE__ */ ((CopilotKitErrorCode2) => {
19
52
  CopilotKitErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
20
53
  CopilotKitErrorCode2["NOT_FOUND"] = "NOT_FOUND";
@@ -23,6 +56,7 @@ var CopilotKitErrorCode = /* @__PURE__ */ ((CopilotKitErrorCode2) => {
23
56
  CopilotKitErrorCode2["REMOTE_ENDPOINT_NOT_FOUND"] = "REMOTE_ENDPOINT_NOT_FOUND";
24
57
  CopilotKitErrorCode2["MISUSE"] = "MISUSE";
25
58
  CopilotKitErrorCode2["UNKNOWN"] = "UNKNOWN";
59
+ CopilotKitErrorCode2["VERSION_MISMATCH"] = "VERSION_MISMATCH";
26
60
  CopilotKitErrorCode2["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
27
61
  CopilotKitErrorCode2["MISSING_PUBLIC_API_KEY_ERROR"] = "MISSING_PUBLIC_API_KEY_ERROR";
28
62
  CopilotKitErrorCode2["UPGRADE_REQUIRED_ERROR"] = "UPGRADE_REQUIRED_ERROR";
@@ -72,6 +106,10 @@ var ERROR_CONFIG = {
72
106
  statusCode: 402,
73
107
  troubleshootingUrl: null,
74
108
  severity: "error" /* Error */
109
+ },
110
+ ["VERSION_MISMATCH" /* VERSION_MISMATCH */]: {
111
+ statusCode: 400,
112
+ troubleshootingUrl: null
75
113
  }
76
114
  };
77
115
  var CopilotKitError = class extends GraphQLError {
@@ -99,7 +137,7 @@ var CopilotKitMisuseError = class extends CopilotKitError {
99
137
  message,
100
138
  code = "MISUSE" /* MISUSE */
101
139
  }) {
102
- const docsLink = "troubleshootingUrl" in ERROR_CONFIG[code] ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl) : null;
140
+ const docsLink = "troubleshootingUrl" in ERROR_CONFIG[code] && ERROR_CONFIG[code].troubleshootingUrl ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl) : null;
103
141
  const finalMessage = docsLink ? `${message}.
104
142
 
105
143
  ${docsLink}` : message;
@@ -107,9 +145,42 @@ ${docsLink}` : message;
107
145
  this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;
108
146
  }
109
147
  };
148
+ var getVersionMismatchErrorMessage = ({
149
+ reactCoreVersion,
150
+ runtimeVersion,
151
+ runtimeClientGqlVersion
152
+ }) => `Version mismatch detected: @copilotkit/runtime@${runtimeVersion ?? ""} is not compatible with @copilotkit/react-core@${reactCoreVersion} and @copilotkit/runtime-client-gql@${runtimeClientGqlVersion}. Please ensure all installed copilotkit packages are on the same version.`;
153
+ var CopilotKitVersionMismatchError = class extends CopilotKitError {
154
+ constructor({
155
+ reactCoreVersion,
156
+ runtimeVersion,
157
+ runtimeClientGqlVersion
158
+ }) {
159
+ const code = "VERSION_MISMATCH" /* VERSION_MISMATCH */;
160
+ super({
161
+ message: getVersionMismatchErrorMessage({
162
+ reactCoreVersion,
163
+ runtimeVersion,
164
+ runtimeClientGqlVersion
165
+ }),
166
+ code
167
+ });
168
+ this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;
169
+ }
170
+ };
110
171
  var CopilotKitApiDiscoveryError = class extends CopilotKitError {
111
172
  constructor(params = {}) {
112
- const message = params.message ?? "Failed to find CopilotKit API endpoint";
173
+ const url = params.url ?? "";
174
+ let operationSuffix = "";
175
+ if (url == null ? void 0 : url.includes("/info"))
176
+ operationSuffix = `when fetching CopilotKit info`;
177
+ else if (url.includes("/actions/execute"))
178
+ operationSuffix = `when attempting to execute actions.`;
179
+ else if (url.includes("/agents/state"))
180
+ operationSuffix = `when attempting to get agent state.`;
181
+ else if (url.includes("/agents/execute"))
182
+ operationSuffix = `when attempting to execute agent(s).`;
183
+ const message = params.message ?? (params.url ? `Failed to find CopilotKit API endpoint at url ${params.url} ${operationSuffix}` : `Failed to find CopilotKit API endpoint.`);
113
184
  const code = params.code ?? "API_NOT_FOUND" /* API_NOT_FOUND */;
114
185
  const errorMessage = `${message}.
115
186
 
@@ -120,7 +191,7 @@ ${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;
120
191
  };
121
192
  var CopilotKitRemoteEndpointDiscoveryError = class extends CopilotKitApiDiscoveryError {
122
193
  constructor(params) {
123
- const message = (params == null ? void 0 : params.message) ?? "Failed to find or contact remote endpoint";
194
+ const message = (params == null ? void 0 : params.message) ?? ((params == null ? void 0 : params.url) ? `Failed to find or contact remote endpoint at url ${params.url}` : "Failed to find or contact remote endpoint");
124
195
  const code = "REMOTE_ENDPOINT_NOT_FOUND" /* REMOTE_ENDPOINT_NOT_FOUND */;
125
196
  super({ message, code });
126
197
  this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;
@@ -128,49 +199,35 @@ var CopilotKitRemoteEndpointDiscoveryError = class extends CopilotKitApiDiscover
128
199
  };
129
200
  var CopilotKitAgentDiscoveryError = class extends CopilotKitError {
130
201
  constructor(params) {
202
+ const { agentName, availableAgents } = params;
131
203
  const code = "AGENT_NOT_FOUND" /* AGENT_NOT_FOUND */;
132
- const baseMessage = "Failed to find agent";
204
+ let message = "Failed to find any agents.";
133
205
  const configMessage = "Please verify the agent name exists and is properly configured.";
134
- const finalMessage = (params == null ? void 0 : params.agentName) ? `${baseMessage} '${params.agentName}'. ${configMessage}
206
+ const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);
207
+ if (availableAgents.length) {
208
+ message = agentName ? `Failed to find agent '${agentName}'. ${configMessage}` : `Failed to find agent. ${configMessage}`;
209
+ const bulletList = availableAgents.map((agent) => `\u2022 ${agent.name} (ID: \`${agent.id}\`)`).join("\n");
210
+ message += `
135
211
 
136
- ${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}` : `${baseMessage}. ${configMessage}
212
+ The available agents are:
137
213
 
138
- ${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;
139
- super({ message: finalMessage || finalMessage, code });
214
+ ${bulletList}
215
+
216
+ ${seeMore}`;
217
+ } else {
218
+ message += `
219
+
220
+ ${seeMore}`;
221
+ }
222
+ super({ message, code });
140
223
  this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;
141
224
  }
142
225
  };
143
226
  var CopilotKitLowLevelError = class extends CopilotKitError {
144
227
  constructor({ error, url, message }) {
145
228
  let code = "NETWORK_ERROR" /* NETWORK_ERROR */;
146
- const getMessageByCode = (errorCode) => {
147
- const troubleshootingLink = ERROR_CONFIG[code].troubleshootingUrl;
148
- switch (errorCode) {
149
- case "ECONNREFUSED":
150
- return `Connection to ${url} was refused. Ensure the server is running and accessible.
151
-
152
- ${getSeeMoreMarkdown(troubleshootingLink)}`;
153
- case "ENOTFOUND":
154
- return `The server on ${url} could not be found. Check the URL or your network configuration.
155
-
156
- ${getSeeMoreMarkdown(ERROR_CONFIG["NOT_FOUND" /* NOT_FOUND */].troubleshootingUrl)}`;
157
- case "ETIMEDOUT":
158
- return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.
159
-
160
- ${getSeeMoreMarkdown(troubleshootingLink)}`;
161
- default:
162
- return `Failed to fetch from url ${url}.
163
-
164
- Possible reasons:
165
- - -The server might be down or unreachable
166
- - -There might be a network issue (e.g., DNS failure, connection timeout)
167
- - -The URL might be incorrect
168
- - -The server is not running on the specified port
169
-
170
- ${getSeeMoreMarkdown(troubleshootingLink)}`;
171
- }
172
- };
173
- const errorMessage = message ?? getMessageByCode(error.code);
229
+ const errorCode = error.code;
230
+ const errorMessage = message ?? resolveLowLevelErrorMessage({ errorCode, url });
174
231
  super({ message: errorMessage, code });
175
232
  this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;
176
233
  }
@@ -180,15 +237,16 @@ var ResolvedCopilotKitError = class extends CopilotKitError {
180
237
  status,
181
238
  message,
182
239
  code,
183
- isRemoteEndpoint
240
+ isRemoteEndpoint,
241
+ url
184
242
  }) {
185
243
  let resolvedCode = code;
186
244
  if (!resolvedCode) {
187
245
  switch (status) {
188
246
  case 400:
189
- throw new CopilotKitApiDiscoveryError({ message });
247
+ throw new CopilotKitApiDiscoveryError({ message, url });
190
248
  case 404:
191
- throw isRemoteEndpoint ? new CopilotKitRemoteEndpointDiscoveryError({ message }) : new CopilotKitApiDiscoveryError({ message });
249
+ throw isRemoteEndpoint ? new CopilotKitRemoteEndpointDiscoveryError({ message, url }) : new CopilotKitApiDiscoveryError({ message, url });
192
250
  default:
193
251
  resolvedCode = "UNKNOWN" /* UNKNOWN */;
194
252
  super({ message, code: resolvedCode });
@@ -220,14 +278,73 @@ var UpgradeRequiredError = class extends ConfigurationError {
220
278
  this.severity = "error" /* Error */;
221
279
  }
222
280
  };
281
+ async function getPossibleVersionMismatch({
282
+ runtimeVersion,
283
+ runtimeClientGqlVersion
284
+ }) {
285
+ if (!runtimeVersion || runtimeVersion === "" || !runtimeClientGqlVersion)
286
+ return;
287
+ if (COPILOTKIT_VERSION !== runtimeVersion || COPILOTKIT_VERSION !== runtimeClientGqlVersion || runtimeVersion !== runtimeClientGqlVersion) {
288
+ return {
289
+ runtimeVersion,
290
+ runtimeClientGqlVersion,
291
+ reactCoreVersion: COPILOTKIT_VERSION,
292
+ message: getVersionMismatchErrorMessage({
293
+ runtimeVersion,
294
+ runtimeClientGqlVersion,
295
+ reactCoreVersion: COPILOTKIT_VERSION
296
+ })
297
+ };
298
+ }
299
+ return;
300
+ }
301
+ var resolveLowLevelErrorMessage = ({ errorCode, url }) => {
302
+ const troubleshootingLink = ERROR_CONFIG["NETWORK_ERROR" /* NETWORK_ERROR */].troubleshootingUrl;
303
+ const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.
304
+
305
+ Possible reasons:
306
+ - -The server may have an error preventing it from returning a response (Check the server logs for more info).
307
+ - -The server might be down or unreachable
308
+ - -There might be a network issue (e.g., DNS failure, connection timeout)
309
+ - -The URL might be incorrect
310
+ - -The server is not running on the specified port
311
+
312
+ ${getSeeMoreMarkdown(troubleshootingLink)}`;
313
+ if (url.includes("/info"))
314
+ return genericMessage(`Failed to fetch CopilotKit agents/action information from url ${url}.`);
315
+ if (url.includes("/actions/execute"))
316
+ return genericMessage(`Fetch call to ${url} to execute actions failed.`);
317
+ if (url.includes("/agents/state"))
318
+ return genericMessage(`Fetch call to ${url} to get agent state failed.`);
319
+ if (url.includes("/agents/execute"))
320
+ return genericMessage(`Fetch call to ${url} to execute agent(s) failed.`);
321
+ switch (errorCode) {
322
+ case "ECONNREFUSED":
323
+ return `Connection to ${url} was refused. Ensure the server is running and accessible.
324
+
325
+ ${getSeeMoreMarkdown(troubleshootingLink)}`;
326
+ case "ENOTFOUND":
327
+ return `The server on ${url} could not be found. Check the URL or your network configuration.
328
+
329
+ ${getSeeMoreMarkdown(ERROR_CONFIG["NOT_FOUND" /* NOT_FOUND */].troubleshootingUrl)}`;
330
+ case "ETIMEDOUT":
331
+ return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.
332
+
333
+ ${getSeeMoreMarkdown(troubleshootingLink)}`;
334
+ default:
335
+ return;
336
+ }
337
+ };
223
338
 
224
339
  export {
225
340
  Severity,
226
341
  ERROR_NAMES,
342
+ COPILOT_CLOUD_ERROR_NAMES,
227
343
  CopilotKitErrorCode,
228
344
  ERROR_CONFIG,
229
345
  CopilotKitError,
230
346
  CopilotKitMisuseError,
347
+ CopilotKitVersionMismatchError,
231
348
  CopilotKitApiDiscoveryError,
232
349
  CopilotKitRemoteEndpointDiscoveryError,
233
350
  CopilotKitAgentDiscoveryError,
@@ -235,6 +352,10 @@ export {
235
352
  ResolvedCopilotKitError,
236
353
  ConfigurationError,
237
354
  MissingPublicApiKeyError,
238
- UpgradeRequiredError
355
+ UpgradeRequiredError,
356
+ getPossibleVersionMismatch,
357
+ parseJson,
358
+ tryMap,
359
+ COPILOTKIT_VERSION
239
360
  };
240
- //# sourceMappingURL=chunk-NVY7ED2F.mjs.map
361
+ //# sourceMappingURL=chunk-FDMXZMSN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/errors.ts","../src/utils/index.ts","../package.json","../src/index.ts"],"sourcesContent":["import { GraphQLError } from \"graphql\";\nimport { COPILOTKIT_VERSION } from \"../index\";\n\nexport enum Severity {\n Error = \"error\",\n}\n\nexport const ERROR_NAMES = {\n COPILOT_ERROR: \"CopilotError\",\n COPILOT_API_DISCOVERY_ERROR: \"CopilotApiDiscoveryError\",\n COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR: \"CopilotKitRemoteEndpointDiscoveryError\",\n COPILOT_KIT_AGENT_DISCOVERY_ERROR: \"CopilotKitAgentDiscoveryError\",\n COPILOT_KIT_LOW_LEVEL_ERROR: \"CopilotKitLowLevelError\",\n COPILOT_KIT_VERSION_MISMATCH_ERROR: \"CopilotKitVersionMismatchError\",\n RESOLVED_COPILOT_KIT_ERROR: \"ResolvedCopilotKitError\",\n CONFIGURATION_ERROR: \"ConfigurationError\",\n MISSING_PUBLIC_API_KEY_ERROR: \"MissingPublicApiKeyError\",\n UPGRADE_REQUIRED_ERROR: \"UpgradeRequiredError\",\n} as const;\nexport const COPILOT_CLOUD_ERROR_NAMES = [\n ERROR_NAMES.CONFIGURATION_ERROR,\n ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR,\n ERROR_NAMES.UPGRADE_REQUIRED_ERROR,\n];\n\nexport enum CopilotKitErrorCode {\n NETWORK_ERROR = \"NETWORK_ERROR\",\n NOT_FOUND = \"NOT_FOUND\",\n AGENT_NOT_FOUND = \"AGENT_NOT_FOUND\",\n API_NOT_FOUND = \"API_NOT_FOUND\",\n REMOTE_ENDPOINT_NOT_FOUND = \"REMOTE_ENDPOINT_NOT_FOUND\",\n MISUSE = \"MISUSE\",\n UNKNOWN = \"UNKNOWN\",\n VERSION_MISMATCH = \"VERSION_MISMATCH\",\n CONFIGURATION_ERROR = \"CONFIGURATION_ERROR\",\n MISSING_PUBLIC_API_KEY_ERROR = \"MISSING_PUBLIC_API_KEY_ERROR\",\n UPGRADE_REQUIRED_ERROR = \"UPGRADE_REQUIRED_ERROR\",\n}\n\nconst BASE_URL = \"https://docs.copilotkit.ai\";\n\nconst getSeeMoreMarkdown = (link: string) => `See more: [${link}](${link})`;\n\nexport const ERROR_CONFIG = {\n [CopilotKitErrorCode.NETWORK_ERROR]: {\n statusCode: 503,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.AGENT_NOT_FOUND]: {\n statusCode: 500,\n troubleshootingUrl: `${BASE_URL}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,\n },\n [CopilotKitErrorCode.API_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,\n },\n [CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND]: {\n statusCode: 404,\n troubleshootingUrl: `${BASE_URL}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,\n },\n [CopilotKitErrorCode.MISUSE]: {\n statusCode: 400,\n troubleshootingUrl: null,\n },\n [CopilotKitErrorCode.UNKNOWN]: {\n statusCode: 500,\n },\n [CopilotKitErrorCode.CONFIGURATION_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR]: {\n statusCode: 400,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR]: {\n statusCode: 402,\n troubleshootingUrl: null,\n severity: Severity.Error,\n },\n [CopilotKitErrorCode.VERSION_MISMATCH]: {\n statusCode: 400,\n troubleshootingUrl: null,\n },\n};\n\nexport class CopilotKitError extends GraphQLError {\n code: CopilotKitErrorCode;\n statusCode: number;\n severity?: Severity;\n constructor({\n message = \"Unknown error occurred\",\n code,\n severity,\n }: {\n message?: string;\n code: CopilotKitErrorCode;\n severity?: Severity;\n }) {\n const name = ERROR_NAMES.COPILOT_ERROR;\n const { statusCode } = ERROR_CONFIG[code];\n\n super(message, {\n extensions: {\n name,\n statusCode,\n },\n });\n this.code = code;\n this.name = name;\n this.statusCode = statusCode;\n this.severity = severity;\n }\n}\n\n/**\n * Error thrown when we can identify wrong usage of our components.\n * This helps us notify the developer before real errors can happen\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitMisuseError extends CopilotKitError {\n constructor({\n message,\n code = CopilotKitErrorCode.MISUSE,\n }: {\n message: string;\n code?: CopilotKitErrorCode;\n }) {\n const docsLink =\n \"troubleshootingUrl\" in ERROR_CONFIG[code] && ERROR_CONFIG[code].troubleshootingUrl\n ? getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl as string)\n : null;\n const finalMessage = docsLink ? `${message}.\\n\\n${docsLink}` : message;\n super({ message: finalMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\nconst getVersionMismatchErrorMessage = ({\n reactCoreVersion,\n runtimeVersion,\n runtimeClientGqlVersion,\n}: VersionMismatchResponse) =>\n `Version mismatch detected: @copilotkit/runtime@${runtimeVersion ?? \"\"} is not compatible with @copilotkit/react-core@${reactCoreVersion} and @copilotkit/runtime-client-gql@${runtimeClientGqlVersion}. Please ensure all installed copilotkit packages are on the same version.`;\n/**\n * Error thrown when CPK versions does not match\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitVersionMismatchError extends CopilotKitError {\n constructor({\n reactCoreVersion,\n runtimeVersion,\n runtimeClientGqlVersion,\n }: VersionMismatchResponse) {\n const code = CopilotKitErrorCode.VERSION_MISMATCH;\n super({\n message: getVersionMismatchErrorMessage({\n reactCoreVersion,\n runtimeVersion,\n runtimeClientGqlVersion,\n }),\n code,\n });\n this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;\n }\n}\n\n/**\n * Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n * - There are network/firewall issues preventing access\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitApiDiscoveryError extends CopilotKitError {\n constructor(\n params: {\n message?: string;\n code?: CopilotKitErrorCode.API_NOT_FOUND | CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n url?: string;\n } = {},\n ) {\n const url = params.url ?? \"\";\n let operationSuffix = \"\";\n if (url?.includes(\"/info\")) operationSuffix = `when fetching CopilotKit info`;\n else if (url.includes(\"/actions/execute\"))\n operationSuffix = `when attempting to execute actions.`;\n else if (url.includes(\"/agents/state\")) operationSuffix = `when attempting to get agent state.`;\n else if (url.includes(\"/agents/execute\"))\n operationSuffix = `when attempting to execute agent(s).`;\n const message =\n params.message ??\n (params.url\n ? `Failed to find CopilotKit API endpoint at url ${params.url} ${operationSuffix}`\n : `Failed to find CopilotKit API endpoint.`);\n const code = params.code ?? CopilotKitErrorCode.API_NOT_FOUND;\n const errorMessage = `${message}.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl)}`;\n super({ message: errorMessage, code });\n this.name = ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR;\n }\n}\n\n/**\n * This error is used for endpoints specified in runtime's remote endpoints. If they cannot be contacted\n * This typically occurs when:\n * - The API endpoint URL is invalid or misconfigured\n * - The API service is not running at the expected location\n *\n * @extends CopilotKitApiDiscoveryError\n */\nexport class CopilotKitRemoteEndpointDiscoveryError extends CopilotKitApiDiscoveryError {\n constructor(params?: { message?: string; url?: string }) {\n const message =\n params?.message ??\n (params?.url\n ? `Failed to find or contact remote endpoint at url ${params.url}`\n : \"Failed to find or contact remote endpoint\");\n const code = CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND;\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Error thrown when a LangGraph agent cannot be found or accessed.\n * This typically occurs when:\n * - The specified agent name does not exist in the deployment\n * - The agent configuration is invalid or missing\n * - The agent service is not properly deployed or initialized\n *\n * @extends CopilotKitError\n */\nexport class CopilotKitAgentDiscoveryError extends CopilotKitError {\n constructor(params: { agentName?: string; availableAgents: { name: string; id: string }[] }) {\n const { agentName, availableAgents } = params;\n const code = CopilotKitErrorCode.AGENT_NOT_FOUND;\n\n let message = \"Failed to find any agents.\";\n const configMessage = \"Please verify the agent name exists and is properly configured.\";\n const seeMore = getSeeMoreMarkdown(ERROR_CONFIG[code].troubleshootingUrl);\n\n if (availableAgents.length) {\n message = agentName\n ? `Failed to find agent '${agentName}'. ${configMessage}`\n : `Failed to find agent. ${configMessage}`;\n\n const bulletList = availableAgents\n .map((agent) => `• ${agent.name} (ID: \\`${agent.id}\\`)`)\n .join(\"\\n\");\n\n message += `\\n\\nThe available agents are:\\n\\n${bulletList}\\n\\n${seeMore}`;\n } else {\n message += `\\n\\n${seeMore}`;\n }\n\n super({ message, code });\n this.name = ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR;\n }\n}\n\n/**\n * Handles low-level networking errors that occur before a request reaches the server.\n * These errors arise from issues in the underlying communication infrastructure rather than\n * application-level logic or server responses. Typically used to handle \"fetch failed\" errors\n * where no HTTP status code is available.\n *\n * Common scenarios include:\n * - Connection failures (ECONNREFUSED) when server is down/unreachable\n * - DNS resolution failures (ENOTFOUND) when domain can't be resolved\n * - Timeouts (ETIMEDOUT) when request takes too long\n * - Protocol/transport layer errors like SSL/TLS issues\n */\nexport class CopilotKitLowLevelError extends CopilotKitError {\n constructor({ error, url, message }: { error: Error; url: string; message?: string }) {\n let code = CopilotKitErrorCode.NETWORK_ERROR;\n\n // @ts-expect-error -- code may exist\n const errorCode = error.code as string;\n const errorMessage = message ?? resolveLowLevelErrorMessage({ errorCode, url });\n\n super({ message: errorMessage, code });\n\n this.name = ERROR_NAMES.COPILOT_KIT_LOW_LEVEL_ERROR;\n }\n}\n\n/**\n * Generic catch-all error handler for HTTP responses from the CopilotKit API where a status code is available.\n * Used when we receive an HTTP error status and wish to handle broad range of them\n *\n * This differs from CopilotKitLowLevelError in that:\n * - ResolvedCopilotKitError: Server was reached and returned an HTTP status\n * - CopilotKitLowLevelError: Error occurred before reaching server (e.g. network failure)\n *\n * @param status - The HTTP status code received from the API response\n * @param message - Optional error message to include\n * @param code - Optional specific CopilotKitErrorCode to override default behavior\n *\n * Default behavior:\n * - 400 Bad Request: Maps to CopilotKitApiDiscoveryError\n * - All other status codes: Maps to UNKNOWN error code if no specific code provided\n */\nexport class ResolvedCopilotKitError extends CopilotKitError {\n constructor({\n status,\n message,\n code,\n isRemoteEndpoint,\n url,\n }: {\n status: number;\n message?: string;\n code?: CopilotKitErrorCode;\n isRemoteEndpoint?: boolean;\n url?: string;\n }) {\n let resolvedCode = code;\n if (!resolvedCode) {\n switch (status) {\n case 400:\n throw new CopilotKitApiDiscoveryError({ message, url });\n case 404:\n throw isRemoteEndpoint\n ? new CopilotKitRemoteEndpointDiscoveryError({ message, url })\n : new CopilotKitApiDiscoveryError({ message, url });\n default:\n resolvedCode = CopilotKitErrorCode.UNKNOWN;\n super({ message, code: resolvedCode });\n }\n } else {\n super({ message, code: resolvedCode });\n }\n this.name = ERROR_NAMES.RESOLVED_COPILOT_KIT_ERROR;\n }\n}\n\nexport class ConfigurationError extends CopilotKitError {\n constructor(message: string) {\n super({ message, code: CopilotKitErrorCode.CONFIGURATION_ERROR });\n this.name = ERROR_NAMES.CONFIGURATION_ERROR;\n this.severity = Severity.Error;\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.Error;\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.Error;\n }\n}\n\ninterface VersionMismatchResponse {\n runtimeVersion?: string;\n runtimeClientGqlVersion: string;\n reactCoreVersion: string;\n}\n\nexport async function getPossibleVersionMismatch({\n runtimeVersion,\n runtimeClientGqlVersion,\n}: {\n runtimeVersion?: string;\n runtimeClientGqlVersion: string;\n}) {\n if (!runtimeVersion || runtimeVersion === \"\" || !runtimeClientGqlVersion) return;\n if (\n COPILOTKIT_VERSION !== runtimeVersion ||\n COPILOTKIT_VERSION !== runtimeClientGqlVersion ||\n runtimeVersion !== runtimeClientGqlVersion\n ) {\n return {\n runtimeVersion,\n runtimeClientGqlVersion,\n reactCoreVersion: COPILOTKIT_VERSION,\n message: getVersionMismatchErrorMessage({\n runtimeVersion,\n runtimeClientGqlVersion,\n reactCoreVersion: COPILOTKIT_VERSION,\n }),\n };\n }\n\n return;\n}\n\nconst resolveLowLevelErrorMessage = ({ errorCode, url }: { errorCode?: string; url: string }) => {\n const troubleshootingLink = ERROR_CONFIG[CopilotKitErrorCode.NETWORK_ERROR].troubleshootingUrl;\n const genericMessage = (description = `Failed to fetch from url ${url}.`) => `${description}.\n\nPossible reasons:\n- -The server may have an error preventing it from returning a response (Check the server logs for more info).\n- -The server might be down or unreachable\n- -There might be a network issue (e.g., DNS failure, connection timeout) \n- -The URL might be incorrect\n- -The server is not running on the specified port\n\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n\n if (url.includes(\"/info\"))\n return genericMessage(`Failed to fetch CopilotKit agents/action information from url ${url}.`);\n if (url.includes(\"/actions/execute\"))\n return genericMessage(`Fetch call to ${url} to execute actions failed.`);\n if (url.includes(\"/agents/state\"))\n return genericMessage(`Fetch call to ${url} to get agent state failed.`);\n if (url.includes(\"/agents/execute\"))\n return genericMessage(`Fetch call to ${url} to execute agent(s) failed.`);\n\n switch (errorCode) {\n case \"ECONNREFUSED\":\n return `Connection to ${url} was refused. Ensure the server is running and accessible.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n case \"ENOTFOUND\":\n return `The server on ${url} could not be found. Check the URL or your network configuration.\\n\\n${getSeeMoreMarkdown(ERROR_CONFIG[CopilotKitErrorCode.NOT_FOUND].troubleshootingUrl)}`;\n case \"ETIMEDOUT\":\n return `The connection to ${url} timed out. The server might be overloaded or taking too long to respond.\\n\\n${getSeeMoreMarkdown(troubleshootingLink)}`;\n default:\n return;\n }\n};\n","export * from \"./conditions\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./random-id\";\n\n/**\n * Safely parses a JSON string into an object\n * @param json The JSON string to parse\n * @param fallback Optional fallback value to return if parsing fails. If not provided or set to \"unset\", returns null\n * @returns The parsed JSON object, or the fallback value (or null) if parsing fails\n */\nexport function parseJson(json: string, fallback: any = \"unset\") {\n try {\n return JSON.parse(json);\n } catch (e) {\n return fallback === \"unset\" ? null : fallback;\n }\n}\n\n/**\n * Maps an array of items to a new array, skipping items that throw errors during mapping\n * @param items The array to map\n * @param callback The mapping function to apply to each item\n * @returns A new array containing only the successfully mapped items\n */\nexport function tryMap<TItem, TMapped>(\n items: TItem[],\n callback: (item: TItem, index: number, array: TItem[]) => TMapped,\n): TMapped[] {\n return items.reduce<TMapped[]>((acc, item, index, array) => {\n try {\n acc.push(callback(item, index, array));\n } catch (error) {\n console.error(error);\n }\n return acc;\n }, []);\n}\n","{\n \"name\": \"@copilotkit/shared\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.8.7\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/uuid\": \"^10.0.0\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\"\n },\n \"dependencies\": {\n \"@segment/analytics-node\": \"^2.1.2\",\n \"chalk\": \"4.1.2\",\n \"graphql\": \"^16.8.1\",\n \"uuid\": \"^10.0.0\",\n \"zod\": \"^3.23.3\",\n \"zod-to-json-schema\": \"^3.23.5\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n","export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACWtB,SAAS,UAAU,MAAc,WAAgB,SAAS;AAC/D,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,SAAS,GAAP;AACA,WAAO,aAAa,UAAU,OAAO;AAAA,EACvC;AACF;AAQO,SAAS,OACd,OACA,UACW;AACX,SAAO,MAAM,OAAkB,CAAC,KAAK,MAAM,OAAO,UAAU;AAC1D,QAAI;AACF,UAAI,KAAK,SAAS,MAAM,OAAO,KAAK,CAAC;AAAA,IACvC,SAAS,OAAP;AACA,c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;AAAA;AAAA;AAAA;AAAA;AAAA,EAShF,mBAAmB,mBAAmB;AAEtC,MAAI,IAAI,SAAS,OAAO;AACtB,WAAO,eAAe,iEAAiE,MAAM;AAC/F,MAAI,IAAI,SAAS,kBAAkB;AACjC,WAAO,eAAe,iBAAiB,gCAAgC;AACzE,MAAI,IAAI,SAAS,eAAe;AAC9B,WAAO,eAAe,iBAAiB,gCAAgC;AACzE,MAAI,IAAI,SAAS,iBAAiB;AAChC,WAAO,eAAe,iBAAiB,iCAAiC;AAE1E,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO,iBAAiB;AAAA;AAAA,EAAoE,mBAAmB,mBAAmB;AAAA,IACpI,KAAK;AACH,aAAO,iBAAiB;AAAA;AAAA,EAA2E,mBAAmB,aAAa,2BAA6B,EAAE,kBAAkB;AAAA,IACtL,KAAK;AACH,aAAO,qBAAqB;AAAA;AAAA,EAAmF,mBAAmB,mBAAmB;AAAA,IACvJ;AACE;AAAA,EACJ;AACF;","names":["Severity","CopilotKitErrorCode"]}
@@ -85,7 +85,8 @@ var TelemetryClient = class {
85
85
  this.sampleRate = _sampleRate;
86
86
  this.setGlobalProperties({
87
87
  sampleRate: this.sampleRate,
88
- sampleRateAdjustmentFactor: 1 - this.sampleRate
88
+ sampleRateAdjustmentFactor: 1 - this.sampleRate,
89
+ sampleWeight: 1 / this.sampleRate
89
90
  });
90
91
  }
91
92
  };
@@ -93,4 +94,4 @@ var TelemetryClient = class {
93
94
  export {
94
95
  TelemetryClient
95
96
  };
96
- //# sourceMappingURL=chunk-QFITLWYZ.mjs.map
97
+ //# sourceMappingURL=chunk-LGWATNA5.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/telemetry/telemetry-client.ts"],"sourcesContent":["import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private sampleRate: number = 0.05;\n private anonymousId = `anon_${uuidv4()}`;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n sampleRate?: number;\n }) {\n this.packageName = packageName;\n this.packageVersion = packageVersion;\n this.telemetryDisabled =\n telemetryDisabled ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as any).DO_NOT_TRACK === \"true\" ||\n (process.env as any).DO_NOT_TRACK === \"1\";\n\n if (this.telemetryDisabled) {\n return;\n }\n\n this.setSampleRate(sampleRate);\n\n // eslint-disable-next-line\n const writeKey = process.env.COPILOTKIT_SEGMENT_WRITE_KEY || \"n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja\";\n\n this.segment = new Analytics({\n writeKey,\n });\n\n this.setGlobalProperties({\n \"copilotkit.package.name\": packageName,\n \"copilotkit.package.version\": packageVersion,\n });\n }\n\n private shouldSendEvent() {\n const randomNumber = Math.random();\n return randomNumber < this.sampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(event: K, properties: AnalyticsEvents[K]) {\n if (!this.shouldSendEvent() || !this.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\n ...flattenedProperties,\n };\n const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal)\n .sort()\n .reduce(\n (obj, key) => {\n obj[key] = propertiesWithGlobal[key];\n return obj;\n },\n {} as Record<string, any>,\n );\n\n this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n\n setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = { ...this.globalProperties, ...flattenedProperties };\n }\n\n setCloudConfiguration(properties: { publicApiKey: string; baseUrl: string }) {\n this.cloudConfiguration = properties;\n\n this.setGlobalProperties({\n cloud: {\n publicApiKey: properties.publicApiKey,\n baseUrl: properties.baseUrl,\n },\n });\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 0.05;\n\n // eslint-disable-next-line\n if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n // eslint-disable-next-line\n _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n });\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAG1B,SAAS,MAAM,cAAc;AAEtB,IAAM,kBAAN,MAAsB;AAAA,EAU3B,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAMG;AApBH,4BAAwC,CAAC;AACzC,8BAAuE;AAGvE,SAAQ,oBAA6B;AACrC,SAAQ,aAAqB;AAC7B,SAAQ,cAAc,QAAQ,OAAO;AAenC,SAAK,cAAc;AACnB,SAAK,iBAAiB;AACtB,SAAK,oBACH,qBACC,QAAQ,IAAY,kCAAkC,UACtD,QAAQ,IAAY,kCAAkC,OACtD,QAAQ,IAAY,iBAAiB,UACrC,QAAQ,IAAY,iBAAiB;AAExC,QAAI,KAAK,mBAAmB;AAC1B;AAAA,IACF;AAEA,SAAK,cAAc,UAAU;AAG7B,UAAM,WAAW,QAAQ,IAAI,gCAAgC;AAE7D,SAAK,UAAU,IAAI,UAAU;AAAA,MAC3B;AAAA,IACF,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qC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,IACvC,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/telemetry/telemetry-client.ts"],"sourcesContent":["import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private sampleRate: number = 0.05;\n private anonymousId = `anon_${uuidv4()}`;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n sampleRate?: number;\n }) {\n this.packageName = packageName;\n this.packageVersion = packageVersion;\n this.telemetryDisabled =\n telemetryDisabled ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as any).DO_NOT_TRACK === \"true\" ||\n (process.env as any).DO_NOT_TRACK === \"1\";\n\n if (this.telemetryDisabled) {\n return;\n }\n\n this.setSampleRate(sampleRate);\n\n // eslint-disable-next-line\n const writeKey = process.env.COPILOTKIT_SEGMENT_WRITE_KEY || \"n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja\";\n\n this.segment = new Analytics({\n writeKey,\n });\n\n this.setGlobalProperties({\n \"copilotkit.package.name\": packageName,\n \"copilotkit.package.version\": packageVersion,\n });\n }\n\n private shouldSendEvent() {\n const randomNumber = Math.random();\n return randomNumber < this.sampleRate;\n }\n\n async capture<K extends keyof AnalyticsEvents>(event: K, properties: AnalyticsEvents[K]) {\n if (!this.shouldSendEvent() || !this.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\n ...flattenedProperties,\n };\n const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal)\n .sort()\n .reduce(\n (obj, key) => {\n obj[key] = propertiesWithGlobal[key];\n return obj;\n },\n {} as Record<string, any>,\n );\n\n this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n\n setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = { ...this.globalProperties, ...flattenedProperties };\n }\n\n setCloudConfiguration(properties: { publicApiKey: string; baseUrl: string }) {\n this.cloudConfiguration = properties;\n\n this.setGlobalProperties({\n cloud: {\n publicApiKey: properties.publicApiKey,\n baseUrl: properties.baseUrl,\n },\n });\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 0.05;\n\n // eslint-disable-next-line\n if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n // eslint-disable-next-line\n _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n sampleWeight: 1 / this.sampleRate,\n });\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAG1B,SAAS,MAAM,cAAc;AAEtB,IAAM,kBAAN,MAAsB;AAAA,EAU3B,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAMG;AApBH,4BAAwC,CAAC;AACzC,8BAAuE;AAGvE,SAAQ,oBAA6B;AACrC,SAAQ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BAAsB,YAAuD;AAC3E,SAAK,qBAAqB;AAE1B,SAAK,oBAAoB;AAAA,MACvB,OAAO;AAAA,QACL,cAAc,WAAW;AAAA,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,MACrC,cAAc,IAAI,KAAK;AAAA,IACzB,CAAC;AAAA,EACH;AACF;","names":[]}
package/dist/index.d.ts CHANGED
@@ -2,16 +2,17 @@ export { AssistantMessage, CoAgentStateRenderHandler, CoAgentStateRenderHandlerA
2
2
  export { Action, MappedParameterTypes, Parameter } from './types/action.js';
3
3
  export { CopilotCloudConfig } from './types/copilot-cloud-config.js';
4
4
  export { PartialBy, RequiredBy } from './types/utility.js';
5
+ export { parseJson, tryMap } from './utils/index.js';
6
+ export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION } from './constants/index.js';
7
+ export { TelemetryClient } from './telemetry/telemetry-client.js';
5
8
  export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from './utils/conditions.js';
6
- export { ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, ERROR_CONFIG, ERROR_NAMES, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError } from './utils/errors.js';
9
+ export { COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, getPossibleVersionMismatch } from './utils/errors.js';
7
10
  export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema, convertJsonSchemaToZodSchema } from './utils/json-schema.js';
8
11
  export { dataToUUID, isValidUUID, randomId, randomUUID } from './utils/random-id.js';
9
- export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION } from './constants/index.js';
10
- export { TelemetryClient } from './telemetry/telemetry-client.js';
11
- import 'graphql';
12
- import 'zod';
13
12
  import '@segment/analytics-node';
14
13
  import './telemetry/events.js';
14
+ import 'graphql';
15
+ import 'zod';
15
16
 
16
17
  declare const COPILOTKIT_VERSION: string;
17
18