@copilotkit/shared 1.70.1 → 1.70.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 (70) hide show
  1. package/dist/attachments/types.d.cts +10 -0
  2. package/dist/attachments/types.d.cts.map +1 -1
  3. package/dist/attachments/types.d.mts +10 -0
  4. package/dist/attachments/types.d.mts.map +1 -1
  5. package/dist/index.cjs +8 -5
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +5 -3
  8. package/dist/index.d.cts.map +1 -1
  9. package/dist/index.d.mts +5 -4
  10. package/dist/index.d.mts.map +1 -1
  11. package/dist/index.mjs +5 -4
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/index.umd.js +226 -197
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/package.cjs +1 -1
  16. package/dist/package.mjs +1 -1
  17. package/dist/telemetry/index.cjs +15 -0
  18. package/dist/telemetry/index.d.cts +5 -0
  19. package/dist/telemetry/index.d.mts +4 -2
  20. package/dist/telemetry/index.mjs +6 -0
  21. package/dist/telemetry/telemetry-client.cjs +4 -13
  22. package/dist/telemetry/telemetry-client.cjs.map +1 -1
  23. package/dist/telemetry/telemetry-client.d.cts +2 -8
  24. package/dist/telemetry/telemetry-client.d.cts.map +1 -1
  25. package/dist/telemetry/telemetry-client.d.mts +2 -8
  26. package/dist/telemetry/telemetry-client.d.mts.map +1 -1
  27. package/dist/telemetry/telemetry-client.mjs +4 -12
  28. package/dist/telemetry/telemetry-client.mjs.map +1 -1
  29. package/dist/telemetry/telemetry-disabled.cjs +20 -0
  30. package/dist/telemetry/telemetry-disabled.cjs.map +1 -0
  31. package/dist/telemetry/telemetry-disabled.d.cts +16 -0
  32. package/dist/telemetry/telemetry-disabled.d.cts.map +1 -0
  33. package/dist/telemetry/telemetry-disabled.d.mts +16 -0
  34. package/dist/telemetry/telemetry-disabled.d.mts.map +1 -0
  35. package/dist/telemetry/telemetry-disabled.mjs +19 -0
  36. package/dist/telemetry/telemetry-disabled.mjs.map +1 -0
  37. package/dist/utils/index.cjs +1 -0
  38. package/dist/utils/index.cjs.map +1 -1
  39. package/dist/utils/index.d.cts +2 -1
  40. package/dist/utils/index.d.cts.map +1 -1
  41. package/dist/utils/index.d.mts +2 -1
  42. package/dist/utils/index.d.mts.map +1 -1
  43. package/dist/utils/index.mjs +1 -0
  44. package/dist/utils/index.mjs.map +1 -1
  45. package/dist/utils/inspector-learning.cjs +185 -0
  46. package/dist/utils/inspector-learning.cjs.map +1 -0
  47. package/dist/utils/inspector-learning.d.cts +91 -0
  48. package/dist/utils/inspector-learning.d.cts.map +1 -0
  49. package/dist/utils/inspector-learning.d.mts +91 -0
  50. package/dist/utils/inspector-learning.d.mts.map +1 -0
  51. package/dist/utils/inspector-learning.mjs +182 -0
  52. package/dist/utils/inspector-learning.mjs.map +1 -0
  53. package/dist/utils/types.cjs.map +1 -1
  54. package/dist/utils/types.d.cts +13 -2
  55. package/dist/utils/types.d.cts.map +1 -1
  56. package/dist/utils/types.d.mts +13 -2
  57. package/dist/utils/types.d.mts.map +1 -1
  58. package/dist/utils/types.mjs.map +1 -1
  59. package/package.json +12 -1
  60. package/src/__tests__/license-context.test.ts +22 -1
  61. package/src/__tests__/root-entry-browser-safety.test.ts +85 -0
  62. package/src/attachments/types.ts +10 -0
  63. package/src/index.ts +27 -2
  64. package/src/telemetry/telemetry-client.ts +2 -17
  65. package/src/telemetry/telemetry-disabled.ts +22 -0
  66. package/src/utils/index.ts +1 -0
  67. package/src/utils/inspector-learning.test.ts +213 -0
  68. package/src/utils/inspector-learning.ts +423 -0
  69. package/src/utils/types.ts +16 -1
  70. package/tsdown.config.ts +4 -1
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function(global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('graphql'), require('zod'), require('uuid'), require('partial-json'), require('@segment/analytics-node'), require('chalk'), require('@ag-ui/client')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'graphql', 'zod', 'uuid', 'partial-json', '@segment/analytics-node', 'chalk', '@ag-ui/client'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitShared = {}), global.GraphQL,global.Zod,global.UUID,global.PartialJSON,global.SegmentAnalyticsNode,global.chalk,global.AgUIClient));
5
- })(this, function(exports, graphql, zod, uuid, partial_json, _segment_analytics_node, chalk, _ag_ui_client) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('graphql'), require('zod'), require('uuid'), require('partial-json'), require('@ag-ui/client')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'graphql', 'zod', 'uuid', 'partial-json', '@ag-ui/client'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitShared = {}), global.GraphQL,global.Zod,global.UUID,global.PartialJSON,global.AgUIClient));
5
+ })(this, function(exports, graphql, zod, uuid, partial_json, _ag_ui_client) {
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
7
7
  //#region \0rolldown/runtime.js
8
8
  var __create = Object.create;
@@ -941,6 +941,186 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
941
941
  };
942
942
  }
943
943
 
944
+ //#endregion
945
+ //#region src/utils/inspector-learning.ts
946
+ const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
947
+ const string = (value, maximum) => typeof value === "string" && value.trim().length > 0 && value.length <= maximum;
948
+ const integer = (value, minimum = 0) => typeof value === "number" && Number.isSafeInteger(value) && value >= minimum;
949
+ const date = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value));
950
+ /**
951
+ * Accepts only the configured Intelligence web-app origin.
952
+ *
953
+ * Learning links are server-authored actions. Treating every HTTPS origin as
954
+ * trusted would let a misconfigured or compromised upstream turn Inspector
955
+ * copy into a navigation primitive for an arbitrary site.
956
+ */
957
+ function parseInspectorLearningUrl(value, trustedOrigin) {
958
+ if (typeof value !== "string" || value.length > 4e3 || typeof trustedOrigin !== "string" || trustedOrigin.length > 2e3) return;
959
+ try {
960
+ const parsed = new URL(value);
961
+ const configured = new URL(trustedOrigin);
962
+ const loopback = [
963
+ "localhost",
964
+ "127.0.0.1",
965
+ "[::1]"
966
+ ].includes(configured.hostname);
967
+ if (parsed.username || parsed.password || configured.username || configured.password || configured.pathname !== "/" || configured.search || configured.hash || configured.protocol !== "https:" && !(configured.protocol === "http:" && loopback) || parsed.origin !== configured.origin) return;
968
+ return parsed.toString();
969
+ } catch (_unused) {
970
+ return;
971
+ }
972
+ }
973
+ function parseEvidence(value) {
974
+ if (record(value) && value.status === "unavailable") return Object.keys(value).length === 1 ? { status: "unavailable" } : void 0;
975
+ if (!record(value) || value.status !== "available" || !string(value.threadId, 128) || !date(value.updatedAt)) return;
976
+ if (value.threadName !== null && !(typeof value.threadName === "string" && value.threadName.length <= 4e3)) return;
977
+ if (!Array.isArray(value.messageIds) || value.messageIds.length > 200 || !value.messageIds.every((id) => string(id, 128))) return;
978
+ return {
979
+ status: "available",
980
+ threadId: value.threadId,
981
+ threadName: value.threadName,
982
+ messageIds: [...value.messageIds],
983
+ updatedAt: value.updatedAt
984
+ };
985
+ }
986
+ function parseInsight(value) {
987
+ if (!record(value) || !string(value.id, 128) || !string(value.statement, 4e3) || !string(value.impact, 4e3) || !integer(value.totalThreadCount) || typeof value.evidenceTruncated !== "boolean" || !Array.isArray(value.evidence) || value.evidence.length > 100) return;
988
+ const evidence = value.evidence.map(parseEvidence);
989
+ if (evidence.some((item) => item === void 0)) return void 0;
990
+ return {
991
+ id: value.id,
992
+ statement: value.statement,
993
+ impact: value.impact,
994
+ totalThreadCount: value.totalThreadCount,
995
+ evidenceTruncated: value.evidenceTruncated,
996
+ evidence
997
+ };
998
+ }
999
+ function parseSkill(value) {
1000
+ if (!record(value) || !string(value.id, 128) || !string(value.name, 128) || !string(value.description, 4e3) || !integer(value.revision, 1) || typeof value.skillMd !== "string" || value.skillMd.length > 131072) return;
1001
+ const sourceInsight = value.sourceInsight === null ? null : parseInsight(value.sourceInsight);
1002
+ if (sourceInsight === void 0) return void 0;
1003
+ return {
1004
+ id: value.id,
1005
+ name: value.name,
1006
+ description: value.description,
1007
+ revision: value.revision,
1008
+ skillMd: value.skillMd,
1009
+ sourceInsight
1010
+ };
1011
+ }
1012
+ function parsePage(value, pageSize, parseItem) {
1013
+ if (!record(value) || !integer(value.page, 1) || value.pageSize !== pageSize || !integer(value.total) || !integer(value.totalPages) || !Array.isArray(value.items) || value.items.length > pageSize) return;
1014
+ const items = value.items.map(parseItem);
1015
+ if (items.some((item) => item === void 0)) return void 0;
1016
+ if (value.total === 0) {
1017
+ if (value.page !== 1 || value.totalPages !== 0 || items.length !== 0) return;
1018
+ } else {
1019
+ const totalPages = Math.ceil(value.total / pageSize);
1020
+ const expectedItems = Math.min(pageSize, value.total - (value.page - 1) * pageSize);
1021
+ if (value.totalPages !== totalPages || value.page > totalPages || items.length !== expectedItems) return;
1022
+ }
1023
+ return {
1024
+ page: value.page,
1025
+ pageSize,
1026
+ total: value.total,
1027
+ totalPages: value.totalPages,
1028
+ items
1029
+ };
1030
+ }
1031
+ function parseConfiguration(value) {
1032
+ if (!record(value)) return void 0;
1033
+ if (value.state === "not_configured" || value.state === "selection_required") return { state: value.state };
1034
+ if (value.state === "invalid" && (value.reason === "container" || value.reason === "instrumentation")) return {
1035
+ state: value.state,
1036
+ reason: value.reason
1037
+ };
1038
+ if (value.state === "configured" && record(value.container) && string(value.container.id, 128) && string(value.container.name, 128)) return {
1039
+ state: "configured",
1040
+ container: {
1041
+ id: value.container.id,
1042
+ name: value.container.name
1043
+ }
1044
+ };
1045
+ }
1046
+ const runStatuses = new Set([
1047
+ "queued",
1048
+ "freezing",
1049
+ "batching",
1050
+ "reducing",
1051
+ "finalizing",
1052
+ "succeeded",
1053
+ "failed"
1054
+ ]);
1055
+ /** Validates and copies an untrusted Learning snapshot at each process boundary. */
1056
+ function parseInspectorLearningSnapshotV1(value) {
1057
+ if (!record(value) || value.schemaVersion !== 1 || !string(value.projectKey, 128) || !string(value.snapshotVersion, 128) || !integer(value.pendingThreadCount) || !integer(value.pendingCandidateCount) || !record(value.run) || typeof value.run.hasActiveRun !== "boolean" || typeof value.run.hasEverSucceeded !== "boolean") return;
1058
+ const configuration = parseConfiguration(value.configuration);
1059
+ const skillsPage = parsePage(value.skillsPage, 3, parseSkill);
1060
+ const insightsPage = parsePage(value.insightsPage, 4, parseInsight);
1061
+ if (!configuration || !skillsPage || !insightsPage) return void 0;
1062
+ let latest = null;
1063
+ if (value.run.latest !== null) {
1064
+ const latestRun = value.run.latest;
1065
+ if (!record(latestRun)) return;
1066
+ const { status, completedAt } = latestRun;
1067
+ if (typeof status !== "string" || !runStatuses.has(status) || completedAt !== null && !date(completedAt)) return void 0;
1068
+ latest = {
1069
+ status,
1070
+ completedAt
1071
+ };
1072
+ }
1073
+ if (!record(value.links)) return void 0;
1074
+ const originUrl = parseInspectorLearningUrl(value.webAppOrigin, value.webAppOrigin);
1075
+ if (!originUrl || new URL(originUrl).pathname !== "/") return void 0;
1076
+ const webAppOrigin = new URL(originUrl).origin;
1077
+ const learning = parseInspectorLearningUrl(value.links.learning, webAppOrigin);
1078
+ const candidates = value.links.candidates === null ? null : parseInspectorLearningUrl(value.links.candidates, webAppOrigin);
1079
+ const runs = value.links.runs === null ? null : parseInspectorLearningUrl(value.links.runs, webAppOrigin);
1080
+ if (!learning || candidates === void 0 || runs === void 0 || value.pendingThreadCount > 0 && runs === null || value.pendingCandidateCount > 0 && candidates === null) return void 0;
1081
+ return {
1082
+ schemaVersion: 1,
1083
+ projectKey: value.projectKey,
1084
+ snapshotVersion: value.snapshotVersion,
1085
+ webAppOrigin,
1086
+ configuration,
1087
+ pendingThreadCount: value.pendingThreadCount,
1088
+ run: {
1089
+ hasActiveRun: value.run.hasActiveRun,
1090
+ hasEverSucceeded: value.run.hasEverSucceeded,
1091
+ latest
1092
+ },
1093
+ pendingCandidateCount: value.pendingCandidateCount,
1094
+ skillsPage,
1095
+ insightsPage,
1096
+ links: {
1097
+ learning,
1098
+ candidates,
1099
+ runs
1100
+ }
1101
+ };
1102
+ }
1103
+ /** Normalizes the browser-owned request without accepting container scope. */
1104
+ function parseInspectorLearningRequestV1(value) {
1105
+ if (!record(value)) return void 0;
1106
+ if (Object.keys(value).some((key) => ![
1107
+ "agentId",
1108
+ "skillsPage",
1109
+ "insightsPage"
1110
+ ].includes(key))) return;
1111
+ const agentId = value.agentId;
1112
+ const skillsPage = value.skillsPage;
1113
+ const insightsPage = value.insightsPage;
1114
+ if (agentId !== void 0 && !string(agentId, 128)) return void 0;
1115
+ if (skillsPage !== void 0 && !integer(skillsPage, 1)) return void 0;
1116
+ if (insightsPage !== void 0 && !integer(insightsPage, 1)) return void 0;
1117
+ return {
1118
+ ...agentId === void 0 ? {} : { agentId },
1119
+ ...skillsPage === void 0 ? {} : { skillsPage },
1120
+ ...insightsPage === void 0 ? {} : { insightsPage }
1121
+ };
1122
+ }
1123
+
944
1124
  //#endregion
945
1125
  //#region src/utils/inspector-visibility.ts
946
1126
  /**
@@ -1134,14 +1314,43 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1134
1314
  const AG_UI_CHANNEL_EVENT = "ag-ui";
1135
1315
 
1136
1316
  //#endregion
1137
- //#region src/telemetry/utils.ts
1138
- function flattenObject(obj, parentKey = "", res = {}) {
1139
- for (let key in obj) {
1140
- const propName = parentKey ? `${parentKey}.${key}` : key;
1141
- if (typeof obj[key] === "object" && obj[key] !== null) flattenObject(obj[key], propName, res);
1142
- else res[propName] = obj[key];
1143
- }
1144
- return res;
1317
+ //#region src/telemetry/telemetry-disabled.ts
1318
+ /**
1319
+ * Checks if telemetry is disabled via environment variables.
1320
+ * Users can opt out by setting:
1321
+ * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
1322
+ * - DO_NOT_TRACK=true or DO_NOT_TRACK=1
1323
+ *
1324
+ * Lives in its own module so that the browser-facing root entry can
1325
+ * re-export it without pulling in `telemetry-client.ts`, whose
1326
+ * `@segment/analytics-node` import drags Node built-ins into browser
1327
+ * bundler module graphs. See the note in `../index.ts`.
1328
+ */
1329
+ function isTelemetryDisabled() {
1330
+ return process.env.COPILOTKIT_TELEMETRY_DISABLED === "true" || process.env.COPILOTKIT_TELEMETRY_DISABLED === "1" || process.env.DO_NOT_TRACK === "true" || process.env.DO_NOT_TRACK === "1";
1331
+ }
1332
+
1333
+ //#endregion
1334
+ //#region src/telemetry/sampling.ts
1335
+ /** Identifies which client emitted an event. */
1336
+ const TELEMETRY_EMITTER_V1 = "v1-shared";
1337
+ const TELEMETRY_EMITTER_V2 = "v2-runtime";
1338
+ /**
1339
+ * Compute the sampling block for one captured event.
1340
+ *
1341
+ * `telemetryId` is the caller's parsed license telemetry_id, or null when
1342
+ * anonymous — it decides the branch, and is deliberately not returned:
1343
+ * only the non-PII shape below travels on the event.
1344
+ */
1345
+ function computeSamplingMeta({ telemetryId, sampleRate }) {
1346
+ const identified = Boolean(telemetryId);
1347
+ const effectiveSampleRate = identified ? 1 : sampleRate;
1348
+ return {
1349
+ sampleRate: effectiveSampleRate,
1350
+ sampleRateAdjustmentFactor: 1 - effectiveSampleRate,
1351
+ sampleWeight: 1 / effectiveSampleRate,
1352
+ telemetry_identified: identified
1353
+ };
1145
1354
  }
1146
1355
 
1147
1356
  //#endregion
@@ -1232,188 +1441,6 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1232
1441
  }
1233
1442
  const lambdaClient = { send };
1234
1443
 
1235
- //#endregion
1236
- //#region src/telemetry/sampling.ts
1237
- /** Identifies which client emitted an event. */
1238
- const TELEMETRY_EMITTER_V1 = "v1-shared";
1239
- const TELEMETRY_EMITTER_V2 = "v2-runtime";
1240
- /**
1241
- * Compute the sampling block for one captured event.
1242
- *
1243
- * `telemetryId` is the caller's parsed license telemetry_id, or null when
1244
- * anonymous — it decides the branch, and is deliberately not returned:
1245
- * only the non-PII shape below travels on the event.
1246
- */
1247
- function computeSamplingMeta({ telemetryId, sampleRate }) {
1248
- const identified = Boolean(telemetryId);
1249
- const effectiveSampleRate = identified ? 1 : sampleRate;
1250
- return {
1251
- sampleRate: effectiveSampleRate,
1252
- sampleRateAdjustmentFactor: 1 - effectiveSampleRate,
1253
- sampleWeight: 1 / effectiveSampleRate,
1254
- telemetry_identified: identified
1255
- };
1256
- }
1257
-
1258
- //#endregion
1259
- //#region src/telemetry/telemetry-client.ts
1260
- /**
1261
- * Checks if telemetry is disabled via environment variables.
1262
- * Users can opt out by setting:
1263
- * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
1264
- * - DO_NOT_TRACK=true or DO_NOT_TRACK=1
1265
- */
1266
- function isTelemetryDisabled() {
1267
- return process.env.COPILOTKIT_TELEMETRY_DISABLED === "true" || process.env.COPILOTKIT_TELEMETRY_DISABLED === "1" || process.env.DO_NOT_TRACK === "true" || process.env.DO_NOT_TRACK === "1";
1268
- }
1269
- var TelemetryClient = class {
1270
- constructor({ packageName, packageVersion, telemetryDisabled, telemetryBaseUrl, sampleRate }) {
1271
- this.globalProperties = {};
1272
- this.cloudConfiguration = null;
1273
- this.licenseToken = null;
1274
- this.telemetryId = null;
1275
- this.licenseTelemetryId = null;
1276
- this.telemetryDisabled = false;
1277
- this.sampleRate = .05;
1278
- this.anonymousId = `anon_${(0, uuid.v4)()}`;
1279
- this.packageName = packageName;
1280
- this.packageVersion = packageVersion;
1281
- this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();
1282
- if (this.telemetryDisabled) return;
1283
- this.setSampleRate(sampleRate);
1284
- this.segment = new _segment_analytics_node.Analytics({ writeKey: process.env.COPILOTKIT_SEGMENT_WRITE_KEY || "n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja" });
1285
- this.setGlobalProperties({
1286
- "copilotkit.package.name": packageName,
1287
- "copilotkit.package.version": packageVersion
1288
- });
1289
- }
1290
- shouldSendEvent() {
1291
- return Math.random() < this.sampleRate;
1292
- }
1293
- async capture(event, properties) {
1294
- return this.captureWithIdentity(event, properties, {
1295
- telemetryId: this.telemetryId,
1296
- licenseToken: this.licenseToken,
1297
- licenseTelemetryId: this.licenseTelemetryId
1298
- });
1299
- }
1300
- async captureWithIdentity(event, properties, identity) {
1301
- var _identity$telemetryId, _identity$licenseToke;
1302
- if (this.telemetryDisabled) return;
1303
- if (!identity.licenseTelemetryId && !this.shouldSendEvent()) return;
1304
- const eventMeta = {
1305
- ...computeSamplingMeta({
1306
- telemetryId: identity.licenseTelemetryId,
1307
- sampleRate: this.sampleRate
1308
- }),
1309
- telemetry_emitter: TELEMETRY_EMITTER_V1,
1310
- telemetry_event_id: (0, uuid.v4)()
1311
- };
1312
- const flattenedProperties = flattenObject(properties);
1313
- const propertiesWithGlobal = {
1314
- ...this.globalProperties,
1315
- ...eventMeta,
1316
- telemetry_transport: "segment",
1317
- ...flattenedProperties
1318
- };
1319
- const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce((obj, key) => {
1320
- obj[key] = propertiesWithGlobal[key];
1321
- return obj;
1322
- }, {});
1323
- await lambdaClient.send({
1324
- event,
1325
- properties: flattenedProperties,
1326
- globalProperties: {
1327
- ...this.globalProperties,
1328
- ...eventMeta,
1329
- telemetry_transport: "lambda"
1330
- },
1331
- packageName: this.packageName,
1332
- packageVersion: this.packageVersion,
1333
- telemetryId: (_identity$telemetryId = identity.telemetryId) !== null && _identity$telemetryId !== void 0 ? _identity$telemetryId : void 0,
1334
- licenseToken: (_identity$licenseToke = identity.licenseToken) !== null && _identity$licenseToke !== void 0 ? _identity$licenseToke : void 0
1335
- });
1336
- if (this.segment) this.segment.track({
1337
- anonymousId: this.anonymousId,
1338
- event,
1339
- properties: { ...orderedPropertiesWithGlobal }
1340
- });
1341
- }
1342
- setGlobalProperties(properties) {
1343
- const flattenedProperties = flattenObject(properties);
1344
- this.globalProperties = {
1345
- ...this.globalProperties,
1346
- ...flattenedProperties
1347
- };
1348
- }
1349
- setCloudConfiguration(properties) {
1350
- this.cloudConfiguration = properties;
1351
- this.setGlobalProperties({ cloud: {
1352
- publicApiKey: properties.publicApiKey,
1353
- baseUrl: properties.baseUrl
1354
- } });
1355
- }
1356
- /**
1357
- * Atomically configure standalone, legacy, or anonymous telemetry identity.
1358
- *
1359
- * A standalone id takes transport precedence over a supplied legacy license
1360
- * token, but only a license-derived id grants sampling authority. Neither
1361
- * value is added to event properties.
1362
- *
1363
- * @param identity - One standalone id, one legacy license token, or neither.
1364
- */
1365
- setTelemetryIdentity(identity) {
1366
- const resolvedIdentity = this.resolveTelemetryIdentity(identity);
1367
- this.telemetryId = resolvedIdentity.telemetryId;
1368
- this.licenseToken = resolvedIdentity.licenseToken;
1369
- this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;
1370
- }
1371
- /**
1372
- * Configure legacy license-derived telemetry identity.
1373
- *
1374
- * @param licenseToken - License token whose telemetry claim identifies sends.
1375
- */
1376
- setLicenseToken(licenseToken) {
1377
- this.setTelemetryIdentity({ licenseToken });
1378
- }
1379
- /**
1380
- * Create an immutable capture scope for one runtime.
1381
- *
1382
- * The scope shares this client's sinks, process-wide opt-out, global
1383
- * properties, and sampling settings, but snapshots transport identity and
1384
- * license-derived sampling authority. Constructing another runtime cannot
1385
- * rewrite an existing scope.
1386
- *
1387
- * @param identity - The runtime's construction-time telemetry identity.
1388
- * @returns A capture-only client bound to that identity.
1389
- */
1390
- createScope(identity) {
1391
- const resolvedIdentity = this.resolveTelemetryIdentity(identity);
1392
- return { capture: (event, properties) => this.captureWithIdentity(event, properties, resolvedIdentity) };
1393
- }
1394
- resolveTelemetryIdentity(identity) {
1395
- var _identity$licenseToke2;
1396
- const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);
1397
- if (telemetryId !== void 0) return {
1398
- telemetryId,
1399
- licenseToken: null,
1400
- licenseTelemetryId: null
1401
- };
1402
- return {
1403
- telemetryId: null,
1404
- licenseToken: (_identity$licenseToke2 = identity.licenseToken) !== null && _identity$licenseToke2 !== void 0 ? _identity$licenseToke2 : null,
1405
- licenseTelemetryId: identity.licenseToken ? parseAndWarnTelemetryId(identity.licenseToken) : null
1406
- };
1407
- }
1408
- setSampleRate(sampleRate) {
1409
- let _sampleRate;
1410
- _sampleRate = sampleRate !== null && sampleRate !== void 0 ? sampleRate : .05;
1411
- if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
1412
- if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) throw new Error("Sample rate must be between 0 and 1");
1413
- this.sampleRate = _sampleRate;
1414
- }
1415
- };
1416
-
1417
1444
  //#endregion
1418
1445
  //#region src/debug.ts
1419
1446
  /** The all-off config used when debug is falsy. */
@@ -1791,7 +1818,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1791
1818
 
1792
1819
  //#endregion
1793
1820
  //#region package.json
1794
- var version = "1.70.1";
1821
+ var version = "1.70.2";
1795
1822
 
1796
1823
  //#endregion
1797
1824
  //#region src/a2ui-prompts.ts
@@ -1939,7 +1966,7 @@ Use the SAME surfaceId as the main surface. Match action names to button action
1939
1966
  const hasUsableSelfHostedLegacyFallback = readyEntitlement && !readyEntitlement.active && readyEntitlement.source === "selfHostedDeploymentLicense" && (status === "valid" || status === "expiring");
1940
1967
  const featureAuthority = readyEntitlement && !hasUsableSelfHostedLegacyFallback ? readyEntitlement : null;
1941
1968
  const activeEntitlement = (featureAuthority === null || featureAuthority === void 0 ? void 0 : featureAuthority.active) ? featureAuthority : null;
1942
- const resolvedStatus = activeEntitlement ? "valid" : (readyEntitlement === null || readyEntitlement === void 0 ? void 0 : readyEntitlement.source) === "managedOrgSubscription" ? "none" : featureAuthority ? status !== null && status !== void 0 ? status : "none" : status !== null && status !== void 0 ? status : null;
1969
+ const resolvedStatus = activeEntitlement ? "valid" : (readyEntitlement === null || readyEntitlement === void 0 ? void 0 : readyEntitlement.source) === "managedOrgSubscription" || (readyEntitlement === null || readyEntitlement === void 0 ? void 0 : readyEntitlement.source) === "awsMarketplaceDeploymentLicense" ? "none" : featureAuthority ? status !== null && status !== void 0 ? status : "none" : status !== null && status !== void 0 ? status : null;
1943
1970
  const featuresEnabled = resolvedStatus !== "expired" && resolvedStatus !== "invalid";
1944
1971
  return {
1945
1972
  status: resolvedStatus,
@@ -1988,7 +2015,6 @@ exports.ResolvedCopilotKitError = ResolvedCopilotKitError;
1988
2015
  exports.Severity = Severity;
1989
2016
  exports.TELEMETRY_EMITTER_V1 = TELEMETRY_EMITTER_V1;
1990
2017
  exports.TELEMETRY_EMITTER_V2 = TELEMETRY_EMITTER_V2;
1991
- exports.TelemetryClient = TelemetryClient;
1992
2018
  exports.TranscriptionErrorCode = TranscriptionErrorCode;
1993
2019
  exports.TranscriptionErrors = TranscriptionErrors;
1994
2020
  exports.UpgradeRequiredError = UpgradeRequiredError;
@@ -2021,6 +2047,9 @@ exports.logStyled = logStyled;
2021
2047
  exports.logger = logger;
2022
2048
  exports.matchesAcceptFilter = matchesAcceptFilter;
2023
2049
  exports.parseAndWarnTelemetryId = parseAndWarnTelemetryId;
2050
+ exports.parseInspectorLearningRequestV1 = parseInspectorLearningRequestV1;
2051
+ exports.parseInspectorLearningSnapshotV1 = parseInspectorLearningSnapshotV1;
2052
+ exports.parseInspectorLearningUrl = parseInspectorLearningUrl;
2024
2053
  exports.parseInspectorMetadataV1 = parseInspectorMetadataV1;
2025
2054
  exports.parseJson = parseJson;
2026
2055
  exports.parseTelemetryIdFromLicense = parseTelemetryIdFromLicense;