@copilotkit/shared 1.0.0-beta.0 → 1.0.0-beta.1

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 (46) hide show
  1. package/.turbo/turbo-build.log +56 -25
  2. package/CHANGELOG.md +6 -0
  3. package/dist/chunk-3VA36BKL.mjs +122 -0
  4. package/dist/chunk-3VA36BKL.mjs.map +1 -0
  5. package/dist/chunk-6QGXWNS5.mjs +34 -0
  6. package/dist/chunk-6QGXWNS5.mjs.map +1 -0
  7. package/dist/chunk-P7STFMPO.mjs +1 -0
  8. package/dist/chunk-P7STFMPO.mjs.map +1 -0
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.js +156 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +15 -9
  13. package/dist/telemetry/events.d.ts +9 -0
  14. package/dist/telemetry/events.js +19 -0
  15. package/dist/telemetry/events.js.map +1 -0
  16. package/dist/telemetry/events.mjs +1 -0
  17. package/dist/telemetry/events.mjs.map +1 -0
  18. package/dist/telemetry/index.d.ts +3 -0
  19. package/dist/telemetry/index.js +184 -0
  20. package/dist/telemetry/index.js.map +1 -0
  21. package/dist/telemetry/index.mjs +9 -0
  22. package/dist/telemetry/index.mjs.map +1 -0
  23. package/dist/telemetry/security-check.d.ts +2 -0
  24. package/dist/telemetry/security-check.js +2 -0
  25. package/dist/telemetry/security-check.js.map +1 -0
  26. package/dist/telemetry/security-check.mjs +1 -0
  27. package/dist/telemetry/security-check.mjs.map +1 -0
  28. package/dist/telemetry/telemetry-client.d.ts +36 -0
  29. package/dist/telemetry/telemetry-client.js +182 -0
  30. package/dist/telemetry/telemetry-client.js.map +1 -0
  31. package/dist/telemetry/telemetry-client.mjs +8 -0
  32. package/dist/telemetry/telemetry-client.mjs.map +1 -0
  33. package/dist/telemetry/utils.d.ts +8 -0
  34. package/dist/telemetry/utils.js +69 -0
  35. package/dist/telemetry/utils.js.map +1 -0
  36. package/dist/telemetry/utils.mjs +9 -0
  37. package/dist/telemetry/utils.mjs.map +1 -0
  38. package/dist/types/index.mjs +1 -1
  39. package/dist/utils/index.mjs +3 -3
  40. package/package.json +5 -3
  41. package/src/index.ts +1 -0
  42. package/src/telemetry/events.ts +7 -0
  43. package/src/telemetry/index.ts +1 -0
  44. package/src/telemetry/security-check.ts +0 -0
  45. package/src/telemetry/telemetry-client.ts +164 -0
  46. package/src/telemetry/utils.ts +39 -0
package/dist/index.mjs CHANGED
@@ -1,4 +1,13 @@
1
+ import "./chunk-BANDZXMP.mjs";
2
+ import "./chunk-YBHX4Y25.mjs";
3
+ import "./chunk-MSUB6DGR.mjs";
4
+ import "./chunk-IAFBVORQ.mjs";
1
5
  import "./chunk-CYDWEPFL.mjs";
6
+ import {
7
+ actionToChatCompletionFunction,
8
+ annotatedFunctionToAction,
9
+ annotatedFunctionToChatCompletionFunction
10
+ } from "./chunk-S4HGLK2E.mjs";
2
11
  import {
3
12
  actionParametersToJsonSchema
4
13
  } from "./chunk-CIPF7PMC.mjs";
@@ -8,21 +17,18 @@ import {
8
17
  COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
9
18
  COPILOT_CLOUD_VERSION
10
19
  } from "./chunk-2VLE6D3W.mjs";
11
- import "./chunk-BANDZXMP.mjs";
12
- import "./chunk-NAFEBKSO.mjs";
13
- import "./chunk-YBHX4Y25.mjs";
14
- import "./chunk-MSUB6DGR.mjs";
15
- import "./chunk-IAFBVORQ.mjs";
20
+ import "./chunk-P7STFMPO.mjs";
16
21
  import {
17
- actionToChatCompletionFunction,
18
- annotatedFunctionToAction,
19
- annotatedFunctionToChatCompletionFunction
20
- } from "./chunk-S4HGLK2E.mjs";
22
+ TelemetryClient
23
+ } from "./chunk-3VA36BKL.mjs";
24
+ import "./chunk-6QGXWNS5.mjs";
25
+ import "./chunk-NAFEBKSO.mjs";
21
26
  export {
22
27
  COPILOT_CLOUD_API_URL,
23
28
  COPILOT_CLOUD_CHAT_URL,
24
29
  COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
25
30
  COPILOT_CLOUD_VERSION,
31
+ TelemetryClient,
26
32
  actionParametersToJsonSchema,
27
33
  actionToChatCompletionFunction,
28
34
  annotatedFunctionToAction,
@@ -0,0 +1,9 @@
1
+ type AnalyticsEvents = {
2
+ "oss.runtime.instance_created": {};
3
+ "oss.runtime.copilot_request_created": {
4
+ "cloud.guardrails.enabled": boolean;
5
+ requestType: string;
6
+ };
7
+ };
8
+
9
+ export { AnalyticsEvents };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/telemetry/events.ts
17
+ var events_exports = {};
18
+ module.exports = __toCommonJS(events_exports);
19
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/telemetry/events.ts"],"sourcesContent":["export type AnalyticsEvents = {\n \"oss.runtime.instance_created\": {};\n \"oss.runtime.copilot_request_created\": {\n \"cloud.guardrails.enabled\": boolean;\n requestType: string;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=events.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,3 @@
1
+ export { TelemetryClient } from './telemetry-client.js';
2
+ import 'posthog-node';
3
+ import './events.js';
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/telemetry/index.ts
31
+ var telemetry_exports = {};
32
+ __export(telemetry_exports, {
33
+ TelemetryClient: () => TelemetryClient
34
+ });
35
+ module.exports = __toCommonJS(telemetry_exports);
36
+
37
+ // src/telemetry/telemetry-client.ts
38
+ var import_posthog_node = require("posthog-node");
39
+
40
+ // src/telemetry/utils.ts
41
+ var import_chalk = __toESM(require("chalk"));
42
+ function flattenObject(obj, parentKey = "", res = {}) {
43
+ for (let key in obj) {
44
+ const propName = parentKey ? `${parentKey}.${key}` : key;
45
+ if (typeof obj[key] === "object" && obj[key] !== null) {
46
+ flattenObject(obj[key], propName, res);
47
+ } else {
48
+ res[propName] = obj[key];
49
+ }
50
+ }
51
+ return res;
52
+ }
53
+ function printSecurityNotice(advisory) {
54
+ const severityColor = {
55
+ low: import_chalk.default.blue,
56
+ medium: import_chalk.default.yellow,
57
+ high: import_chalk.default.red
58
+ }[advisory.severity.toLowerCase()] || import_chalk.default.white;
59
+ console.log();
60
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 ${import_chalk.default.bold(`CopilotKit`)} \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
61
+ console.log();
62
+ console.log(`${import_chalk.default.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);
63
+ console.log();
64
+ console.log(`${import_chalk.default.bold(advisory.message)}`);
65
+ console.log();
66
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
67
+ }
68
+
69
+ // src/telemetry/telemetry-client.ts
70
+ var import_crypto = require("crypto");
71
+ var TelemetryClient = class {
72
+ constructor({
73
+ packageName,
74
+ packageVersion,
75
+ telemetryDisabled,
76
+ telemetryBaseUrl,
77
+ posthogToken,
78
+ sampleRate
79
+ }) {
80
+ this.globalProperties = {};
81
+ this.cloudConfiguration = null;
82
+ this.telemetryDisabled = false;
83
+ this.sampleRate = 0.05;
84
+ this.packageName = packageName;
85
+ this.packageVersion = packageVersion;
86
+ this.telemetryDisabled = telemetryDisabled || process.env.COPILOTKIT_TELEMETRY_DISABLED === "true" || process.env.COPILOTKIT_TELEMETRY_DISABLED === "1" || process.env.DO_NOT_TRACK === "true" || process.env.DO_NOT_TRACK === "1";
87
+ if (this.telemetryDisabled) {
88
+ return;
89
+ }
90
+ this.setSampleRate(sampleRate);
91
+ this.telemetryBaseUrl = telemetryBaseUrl || process.env.COPILOTKIT_TELEMETRY_BASE_URL || "https://telemetry.copilotkit.ai";
92
+ this.posthog = new import_posthog_node.PostHog(posthogToken || "token", {
93
+ host: `${this.telemetryBaseUrl}/telemetry/ingest`
94
+ });
95
+ this.setGlobalProperties({
96
+ "copilotkit.package.name": packageName,
97
+ "copilotkit.package.version": packageVersion
98
+ });
99
+ if (typeof globalThis.navigator !== "undefined") {
100
+ globalThis.navigator = {};
101
+ }
102
+ }
103
+ shouldSendEvent() {
104
+ if (!this.telemetryBaseUrl) {
105
+ return false;
106
+ }
107
+ const randomNumber = Math.random();
108
+ return randomNumber < this.sampleRate;
109
+ }
110
+ async capture(event, properties) {
111
+ if (!this.shouldSendEvent() || !this.posthog) {
112
+ return;
113
+ }
114
+ const flattenedProperties = flattenObject(properties);
115
+ const propertiesWithGlobal = {
116
+ ...this.globalProperties,
117
+ ...flattenedProperties
118
+ };
119
+ const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce(
120
+ (obj, key) => {
121
+ obj[key] = propertiesWithGlobal[key];
122
+ return obj;
123
+ },
124
+ {}
125
+ );
126
+ this.posthog.capture({
127
+ distinctId: (0, import_crypto.randomUUID)(),
128
+ event,
129
+ properties: { ...orderedPropertiesWithGlobal }
130
+ });
131
+ }
132
+ async checkForUpdates() {
133
+ const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;
134
+ const response = await fetch(url);
135
+ if (!response.ok) {
136
+ return;
137
+ }
138
+ const result = await response.json();
139
+ const { advisory, severity } = result;
140
+ if (!advisory && (severity === "low" || severity === "none")) {
141
+ return;
142
+ }
143
+ printSecurityNotice(result);
144
+ }
145
+ setTelemetryBaseUrl(url) {
146
+ this.telemetryBaseUrl = url;
147
+ if (this.posthog) {
148
+ this.posthog.host = `${url}/telemetry/ingest`;
149
+ }
150
+ }
151
+ setGlobalProperties(properties) {
152
+ const flattenedProperties = flattenObject(properties);
153
+ this.globalProperties = { ...this.globalProperties, ...flattenedProperties };
154
+ }
155
+ setCloudConfiguration(properties) {
156
+ this.cloudConfiguration = properties;
157
+ this.setGlobalProperties({
158
+ cloud: {
159
+ publicApiKey: properties.publicApiKey,
160
+ baseUrl: properties.baseUrl
161
+ }
162
+ });
163
+ }
164
+ setSampleRate(sampleRate) {
165
+ let _sampleRate;
166
+ _sampleRate = sampleRate ?? 0.05;
167
+ if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {
168
+ _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
169
+ }
170
+ if (_sampleRate < 0 || _sampleRate > 1) {
171
+ throw new Error("Sample rate must be between 0 and 1");
172
+ }
173
+ this.sampleRate = _sampleRate;
174
+ this.setGlobalProperties({
175
+ sampleRate: this.sampleRate,
176
+ sampleRateAdjustmentFactor: 1 - this.sampleRate
177
+ });
178
+ }
179
+ };
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ TelemetryClient
183
+ });
184
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/telemetry/index.ts","../../src/telemetry/telemetry-client.ts","../../src/telemetry/utils.ts"],"sourcesContent":["export * from \"./telemetry-client\";\n","import { PostHog } from \"posthog-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { randomUUID } from \"crypto\";\n\nexport class TelemetryClient {\n posthog: PostHog | 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 telemetryBaseUrl: string | undefined;\n private sampleRate: number = 0.05;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n posthogToken,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n posthogToken?: 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 this.telemetryBaseUrl =\n telemetryBaseUrl ||\n (process.env as any).COPILOTKIT_TELEMETRY_BASE_URL ||\n \"https://telemetry.copilotkit.ai\";\n\n this.posthog = new PostHog(posthogToken || \"token\", {\n host: `${this.telemetryBaseUrl}/telemetry/ingest`,\n });\n\n this.setGlobalProperties({\n \"copilotkit.package.name\": packageName,\n \"copilotkit.package.version\": packageVersion,\n });\n\n // Eliminates a PostHog error on Next.js\n if (typeof (globalThis as any).navigator !== \"undefined\") {\n (globalThis as any).navigator = {};\n }\n }\n\n private shouldSendEvent() {\n if (!this.telemetryBaseUrl) {\n return false;\n }\n\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.posthog) {\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.posthog.capture({\n distinctId: randomUUID(),\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n\n async checkForUpdates() {\n const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n return;\n }\n\n const result = await response.json();\n const { advisory, severity } = result;\n\n if (!advisory && (severity === \"low\" || severity === \"none\")) {\n return;\n }\n\n printSecurityNotice(result);\n }\n\n setTelemetryBaseUrl(url: string) {\n this.telemetryBaseUrl = url;\n\n if (this.posthog) {\n this.posthog.host = `${url}/telemetry/ingest`;\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 if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\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","import chalk from \"chalk\";\n\nexport function flattenObject(\n obj: Record<string, any>,\n parentKey = \"\",\n res: Record<string, any> = {},\n): Record<string, any> {\n for (let key in obj) {\n const propName = parentKey ? `${parentKey}.${key}` : key;\n if (typeof obj[key] === \"object\" && obj[key] !== null) {\n flattenObject(obj[key], propName, res);\n } else {\n res[propName] = obj[key];\n }\n }\n return res;\n}\n\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`);\n console.log();\n console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,0BAAwB;;;ACAxB,mBAAkB;AAEX,SAAS,cACd,KACA,YAAY,IACZ,MAA2B,CAAC,GACP;AACrB,WAAS,OAAO,KAAK;AACnB,UAAM,WAAW,YAAY,GAAG,aAAa,QAAQ;AACrD,QAAI,OAAO,IAAI,GAAG,MAAM,YAAY,IAAI,GAAG,MAAM,MAAM;AACrD,oBAAc,IAAI,GAAG,GAAG,UAAU,GAAG;AAAA,IACvC,OAAO;AACL,UAAI,QAAQ,IAAI,IAAI,GAAG;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,oBAAoB,UAIjC;AACD,QAAM,gBACJ;AAAA,IACE,KAAK,aAAAA,QAAM;AAAA,IACX,QAAQ,aAAAA,QAAM;AAAA,IACd,MAAM,aAAAA,QAAM;AAAA,EACd,EAAE,SAAS,SAAS,YAAY,CAAC,KAAK,aAAAA,QAAM;AAE9C,UAAQ,IAAI;AACZ,UAAQ,IAAI,gHAAsB,aAAAA,QAAM,KAAK,YAAY,gHAAsB;AAC/E,UAAQ,IAAI;AACZ,UAAQ,IAAI,GAAG,aAAAA,QAAM,KAAK,aAAa,cAAc,SAAS,SAAS,YAAY,CAAC,GAAG,GAAG;AAC1F,UAAQ,IAAI;AACZ,UAAQ,IAAI,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AAA,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,IACvC,CAAC;AAAA,EACH;AACF;","names":["chalk"]}
@@ -0,0 +1,9 @@
1
+ import "../chunk-P7STFMPO.mjs";
2
+ import {
3
+ TelemetryClient
4
+ } from "../chunk-3VA36BKL.mjs";
5
+ import "../chunk-6QGXWNS5.mjs";
6
+ export {
7
+ TelemetryClient
8
+ };
9
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=security-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=security-check.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,36 @@
1
+ import { PostHog } from 'posthog-node';
2
+ import { AnalyticsEvents } from './events.js';
3
+
4
+ declare class TelemetryClient {
5
+ posthog: PostHog | undefined;
6
+ globalProperties: Record<string, any>;
7
+ cloudConfiguration: {
8
+ publicApiKey: string;
9
+ baseUrl: string;
10
+ } | null;
11
+ packageName: string;
12
+ packageVersion: string;
13
+ private telemetryDisabled;
14
+ private telemetryBaseUrl;
15
+ private sampleRate;
16
+ constructor({ packageName, packageVersion, telemetryDisabled, telemetryBaseUrl, posthogToken, sampleRate, }: {
17
+ packageName: string;
18
+ packageVersion: string;
19
+ telemetryDisabled?: boolean;
20
+ telemetryBaseUrl?: string;
21
+ posthogToken?: string;
22
+ sampleRate?: number;
23
+ });
24
+ private shouldSendEvent;
25
+ capture<K extends keyof AnalyticsEvents>(event: K, properties: AnalyticsEvents[K]): Promise<void>;
26
+ checkForUpdates(): Promise<void>;
27
+ setTelemetryBaseUrl(url: string): void;
28
+ setGlobalProperties(properties: Record<string, any>): void;
29
+ setCloudConfiguration(properties: {
30
+ publicApiKey: string;
31
+ baseUrl: string;
32
+ }): void;
33
+ private setSampleRate;
34
+ }
35
+
36
+ export { TelemetryClient };
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/telemetry/telemetry-client.ts
31
+ var telemetry_client_exports = {};
32
+ __export(telemetry_client_exports, {
33
+ TelemetryClient: () => TelemetryClient
34
+ });
35
+ module.exports = __toCommonJS(telemetry_client_exports);
36
+ var import_posthog_node = require("posthog-node");
37
+
38
+ // src/telemetry/utils.ts
39
+ var import_chalk = __toESM(require("chalk"));
40
+ function flattenObject(obj, parentKey = "", res = {}) {
41
+ for (let key in obj) {
42
+ const propName = parentKey ? `${parentKey}.${key}` : key;
43
+ if (typeof obj[key] === "object" && obj[key] !== null) {
44
+ flattenObject(obj[key], propName, res);
45
+ } else {
46
+ res[propName] = obj[key];
47
+ }
48
+ }
49
+ return res;
50
+ }
51
+ function printSecurityNotice(advisory) {
52
+ const severityColor = {
53
+ low: import_chalk.default.blue,
54
+ medium: import_chalk.default.yellow,
55
+ high: import_chalk.default.red
56
+ }[advisory.severity.toLowerCase()] || import_chalk.default.white;
57
+ console.log();
58
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 ${import_chalk.default.bold(`CopilotKit`)} \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
59
+ console.log();
60
+ console.log(`${import_chalk.default.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);
61
+ console.log();
62
+ console.log(`${import_chalk.default.bold(advisory.message)}`);
63
+ console.log();
64
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
65
+ }
66
+
67
+ // src/telemetry/telemetry-client.ts
68
+ var import_crypto = require("crypto");
69
+ var TelemetryClient = class {
70
+ constructor({
71
+ packageName,
72
+ packageVersion,
73
+ telemetryDisabled,
74
+ telemetryBaseUrl,
75
+ posthogToken,
76
+ sampleRate
77
+ }) {
78
+ this.globalProperties = {};
79
+ this.cloudConfiguration = null;
80
+ this.telemetryDisabled = false;
81
+ this.sampleRate = 0.05;
82
+ this.packageName = packageName;
83
+ this.packageVersion = packageVersion;
84
+ this.telemetryDisabled = telemetryDisabled || process.env.COPILOTKIT_TELEMETRY_DISABLED === "true" || process.env.COPILOTKIT_TELEMETRY_DISABLED === "1" || process.env.DO_NOT_TRACK === "true" || process.env.DO_NOT_TRACK === "1";
85
+ if (this.telemetryDisabled) {
86
+ return;
87
+ }
88
+ this.setSampleRate(sampleRate);
89
+ this.telemetryBaseUrl = telemetryBaseUrl || process.env.COPILOTKIT_TELEMETRY_BASE_URL || "https://telemetry.copilotkit.ai";
90
+ this.posthog = new import_posthog_node.PostHog(posthogToken || "token", {
91
+ host: `${this.telemetryBaseUrl}/telemetry/ingest`
92
+ });
93
+ this.setGlobalProperties({
94
+ "copilotkit.package.name": packageName,
95
+ "copilotkit.package.version": packageVersion
96
+ });
97
+ if (typeof globalThis.navigator !== "undefined") {
98
+ globalThis.navigator = {};
99
+ }
100
+ }
101
+ shouldSendEvent() {
102
+ if (!this.telemetryBaseUrl) {
103
+ return false;
104
+ }
105
+ const randomNumber = Math.random();
106
+ return randomNumber < this.sampleRate;
107
+ }
108
+ async capture(event, properties) {
109
+ if (!this.shouldSendEvent() || !this.posthog) {
110
+ return;
111
+ }
112
+ const flattenedProperties = flattenObject(properties);
113
+ const propertiesWithGlobal = {
114
+ ...this.globalProperties,
115
+ ...flattenedProperties
116
+ };
117
+ const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce(
118
+ (obj, key) => {
119
+ obj[key] = propertiesWithGlobal[key];
120
+ return obj;
121
+ },
122
+ {}
123
+ );
124
+ this.posthog.capture({
125
+ distinctId: (0, import_crypto.randomUUID)(),
126
+ event,
127
+ properties: { ...orderedPropertiesWithGlobal }
128
+ });
129
+ }
130
+ async checkForUpdates() {
131
+ const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;
132
+ const response = await fetch(url);
133
+ if (!response.ok) {
134
+ return;
135
+ }
136
+ const result = await response.json();
137
+ const { advisory, severity } = result;
138
+ if (!advisory && (severity === "low" || severity === "none")) {
139
+ return;
140
+ }
141
+ printSecurityNotice(result);
142
+ }
143
+ setTelemetryBaseUrl(url) {
144
+ this.telemetryBaseUrl = url;
145
+ if (this.posthog) {
146
+ this.posthog.host = `${url}/telemetry/ingest`;
147
+ }
148
+ }
149
+ setGlobalProperties(properties) {
150
+ const flattenedProperties = flattenObject(properties);
151
+ this.globalProperties = { ...this.globalProperties, ...flattenedProperties };
152
+ }
153
+ setCloudConfiguration(properties) {
154
+ this.cloudConfiguration = properties;
155
+ this.setGlobalProperties({
156
+ cloud: {
157
+ publicApiKey: properties.publicApiKey,
158
+ baseUrl: properties.baseUrl
159
+ }
160
+ });
161
+ }
162
+ setSampleRate(sampleRate) {
163
+ let _sampleRate;
164
+ _sampleRate = sampleRate ?? 0.05;
165
+ if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {
166
+ _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
167
+ }
168
+ if (_sampleRate < 0 || _sampleRate > 1) {
169
+ throw new Error("Sample rate must be between 0 and 1");
170
+ }
171
+ this.sampleRate = _sampleRate;
172
+ this.setGlobalProperties({
173
+ sampleRate: this.sampleRate,
174
+ sampleRateAdjustmentFactor: 1 - this.sampleRate
175
+ });
176
+ }
177
+ };
178
+ // Annotate the CommonJS export names for ESM import in node:
179
+ 0 && (module.exports = {
180
+ TelemetryClient
181
+ });
182
+ //# sourceMappingURL=telemetry-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/telemetry/telemetry-client.ts","../../src/telemetry/utils.ts"],"sourcesContent":["import { PostHog } from \"posthog-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { randomUUID } from \"crypto\";\n\nexport class TelemetryClient {\n posthog: PostHog | 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 telemetryBaseUrl: string | undefined;\n private sampleRate: number = 0.05;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n posthogToken,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n posthogToken?: 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 this.telemetryBaseUrl =\n telemetryBaseUrl ||\n (process.env as any).COPILOTKIT_TELEMETRY_BASE_URL ||\n \"https://telemetry.copilotkit.ai\";\n\n this.posthog = new PostHog(posthogToken || \"token\", {\n host: `${this.telemetryBaseUrl}/telemetry/ingest`,\n });\n\n this.setGlobalProperties({\n \"copilotkit.package.name\": packageName,\n \"copilotkit.package.version\": packageVersion,\n });\n\n // Eliminates a PostHog error on Next.js\n if (typeof (globalThis as any).navigator !== \"undefined\") {\n (globalThis as any).navigator = {};\n }\n }\n\n private shouldSendEvent() {\n if (!this.telemetryBaseUrl) {\n return false;\n }\n\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.posthog) {\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.posthog.capture({\n distinctId: randomUUID(),\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n\n async checkForUpdates() {\n const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n return;\n }\n\n const result = await response.json();\n const { advisory, severity } = result;\n\n if (!advisory && (severity === \"low\" || severity === \"none\")) {\n return;\n }\n\n printSecurityNotice(result);\n }\n\n setTelemetryBaseUrl(url: string) {\n this.telemetryBaseUrl = url;\n\n if (this.posthog) {\n this.posthog.host = `${url}/telemetry/ingest`;\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 if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\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","import chalk from \"chalk\";\n\nexport function flattenObject(\n obj: Record<string, any>,\n parentKey = \"\",\n res: Record<string, any> = {},\n): Record<string, any> {\n for (let key in obj) {\n const propName = parentKey ? `${parentKey}.${key}` : key;\n if (typeof obj[key] === \"object\" && obj[key] !== null) {\n flattenObject(obj[key], propName, res);\n } else {\n res[propName] = obj[key];\n }\n }\n return res;\n}\n\nexport function printSecurityNotice(advisory: {\n advisory: string | null;\n message: string;\n severity: \"low\" | \"medium\" | \"high\" | \"none\";\n}) {\n const severityColor =\n {\n low: chalk.blue,\n medium: chalk.yellow,\n high: chalk.red,\n }[advisory.severity.toLowerCase()] || chalk.white;\n\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`);\n console.log();\n console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);\n console.log();\n console.log(`${chalk.bold(advisory.message)}`);\n console.log();\n console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAwB;;;ACAxB,mBAAkB;AAEX,SAAS,cACd,KACA,YAAY,IACZ,MAA2B,CAAC,GACP;AACrB,WAAS,OAAO,KAAK;AACnB,UAAM,WAAW,YAAY,GAAG,aAAa,QAAQ;AACrD,QAAI,OAAO,IAAI,GAAG,MAAM,YAAY,IAAI,GAAG,MAAM,MAAM;AACrD,oBAAc,IAAI,GAAG,GAAG,UAAU,GAAG;AAAA,IACvC,OAAO;AACL,UAAI,QAAQ,IAAI,IAAI,GAAG;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,oBAAoB,UAIjC;AACD,QAAM,gBACJ;AAAA,IACE,KAAK,aAAAA,QAAM;AAAA,IACX,QAAQ,aAAAA,QAAM;AAAA,IACd,MAAM,aAAAA,QAAM;AAAA,EACd,EAAE,SAAS,SAAS,YAAY,CAAC,KAAK,aAAAA,QAAM;AAE9C,UAAQ,IAAI;AACZ,UAAQ,IAAI,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,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAE5B,QAAI,QAAQ,IAAI,kCAAkC;AAChD,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,IACvC,CAAC;AAAA,EACH;AACF;","names":["chalk"]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ TelemetryClient
3
+ } from "../chunk-3VA36BKL.mjs";
4
+ import "../chunk-6QGXWNS5.mjs";
5
+ export {
6
+ TelemetryClient
7
+ };
8
+ //# sourceMappingURL=telemetry-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,8 @@
1
+ declare function flattenObject(obj: Record<string, any>, parentKey?: string, res?: Record<string, any>): Record<string, any>;
2
+ declare function printSecurityNotice(advisory: {
3
+ advisory: string | null;
4
+ message: string;
5
+ severity: "low" | "medium" | "high" | "none";
6
+ }): void;
7
+
8
+ export { flattenObject, printSecurityNotice };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/telemetry/utils.ts
31
+ var utils_exports = {};
32
+ __export(utils_exports, {
33
+ flattenObject: () => flattenObject,
34
+ printSecurityNotice: () => printSecurityNotice
35
+ });
36
+ module.exports = __toCommonJS(utils_exports);
37
+ var import_chalk = __toESM(require("chalk"));
38
+ function flattenObject(obj, parentKey = "", res = {}) {
39
+ for (let key in obj) {
40
+ const propName = parentKey ? `${parentKey}.${key}` : key;
41
+ if (typeof obj[key] === "object" && obj[key] !== null) {
42
+ flattenObject(obj[key], propName, res);
43
+ } else {
44
+ res[propName] = obj[key];
45
+ }
46
+ }
47
+ return res;
48
+ }
49
+ function printSecurityNotice(advisory) {
50
+ const severityColor = {
51
+ low: import_chalk.default.blue,
52
+ medium: import_chalk.default.yellow,
53
+ high: import_chalk.default.red
54
+ }[advisory.severity.toLowerCase()] || import_chalk.default.white;
55
+ console.log();
56
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 ${import_chalk.default.bold(`CopilotKit`)} \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
57
+ console.log();
58
+ console.log(`${import_chalk.default.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);
59
+ console.log();
60
+ console.log(`${import_chalk.default.bold(advisory.message)}`);
61
+ console.log();
62
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ flattenObject,
67
+ printSecurityNotice
68
+ });
69
+ //# sourceMappingURL=utils.js.map