@copilotkit/shared 1.0.0-beta.0 → 1.0.0-beta.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 (79) hide show
  1. package/.turbo/turbo-build.log +62 -45
  2. package/CHANGELOG.md +12 -0
  3. package/dist/chunk-2WEXXBTK.mjs +119 -0
  4. package/dist/chunk-2WEXXBTK.mjs.map +1 -0
  5. package/dist/{chunk-2VLE6D3W.mjs → chunk-3AJ2GKWG.mjs} +2 -2
  6. package/dist/chunk-3AJ2GKWG.mjs.map +1 -0
  7. package/dist/chunk-6QGXWNS5.mjs +34 -0
  8. package/dist/chunk-6QGXWNS5.mjs.map +1 -0
  9. package/dist/chunk-DE5K76I2.mjs +1 -0
  10. package/dist/chunk-P7STFMPO.mjs +1 -0
  11. package/dist/chunk-YJLRG5U3.mjs +1 -0
  12. package/dist/constants/index.d.ts +1 -1
  13. package/dist/constants/index.js +1 -1
  14. package/dist/constants/index.js.map +1 -1
  15. package/dist/constants/index.mjs +1 -1
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.js +159 -169
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +12 -15
  20. package/dist/telemetry/events.d.ts +9 -0
  21. package/dist/{types/annotated-function.js → telemetry/events.js} +4 -4
  22. package/dist/telemetry/events.js.map +1 -0
  23. package/dist/telemetry/events.mjs +1 -0
  24. package/dist/telemetry/index.d.ts +3 -0
  25. package/dist/telemetry/index.js +181 -0
  26. package/dist/telemetry/index.js.map +1 -0
  27. package/dist/telemetry/index.mjs +9 -0
  28. package/dist/telemetry/security-check.d.ts +2 -0
  29. package/dist/telemetry/security-check.js +2 -0
  30. package/dist/telemetry/security-check.js.map +1 -0
  31. package/dist/telemetry/security-check.mjs +1 -0
  32. package/dist/telemetry/security-check.mjs.map +1 -0
  33. package/dist/telemetry/telemetry-client.d.ts +36 -0
  34. package/dist/telemetry/telemetry-client.js +179 -0
  35. package/dist/telemetry/telemetry-client.js.map +1 -0
  36. package/dist/telemetry/telemetry-client.mjs +8 -0
  37. package/dist/telemetry/telemetry-client.mjs.map +1 -0
  38. package/dist/telemetry/utils.d.ts +8 -0
  39. package/dist/telemetry/utils.js +69 -0
  40. package/dist/telemetry/utils.js.map +1 -0
  41. package/dist/telemetry/utils.mjs +9 -0
  42. package/dist/telemetry/utils.mjs.map +1 -0
  43. package/dist/types/index.d.ts +0 -1
  44. package/dist/types/index.js.map +1 -1
  45. package/dist/types/index.mjs +2 -3
  46. package/dist/utils/index.d.ts +0 -3
  47. package/dist/utils/index.js +5 -168
  48. package/dist/utils/index.js.map +1 -1
  49. package/dist/utils/index.mjs +2 -10
  50. package/package.json +5 -3
  51. package/src/constants/index.ts +1 -1
  52. package/src/index.ts +1 -0
  53. package/src/telemetry/events.ts +7 -0
  54. package/src/telemetry/index.ts +1 -0
  55. package/src/telemetry/security-check.ts +0 -0
  56. package/src/telemetry/telemetry-client.ts +159 -0
  57. package/src/telemetry/utils.ts +39 -0
  58. package/src/types/index.ts +0 -1
  59. package/src/utils/index.ts +0 -1
  60. package/dist/chunk-2VLE6D3W.mjs.map +0 -1
  61. package/dist/chunk-BANDZXMP.mjs +0 -1
  62. package/dist/chunk-CYDWEPFL.mjs +0 -1
  63. package/dist/chunk-S4HGLK2E.mjs +0 -163
  64. package/dist/chunk-S4HGLK2E.mjs.map +0 -1
  65. package/dist/chunk-YBHX4Y25.mjs +0 -1
  66. package/dist/types/annotated-function.d.ts +0 -24
  67. package/dist/types/annotated-function.js.map +0 -1
  68. package/dist/types/annotated-function.mjs +0 -2
  69. package/dist/utils/annotated-function.d.ts +0 -9
  70. package/dist/utils/annotated-function.js +0 -189
  71. package/dist/utils/annotated-function.js.map +0 -1
  72. package/dist/utils/annotated-function.mjs +0 -11
  73. package/src/types/annotated-function.ts +0 -27
  74. package/src/utils/annotated-function.ts +0 -179
  75. /package/dist/{chunk-BANDZXMP.mjs.map → chunk-DE5K76I2.mjs.map} +0 -0
  76. /package/dist/{chunk-CYDWEPFL.mjs.map → chunk-P7STFMPO.mjs.map} +0 -0
  77. /package/dist/{chunk-YBHX4Y25.mjs.map → chunk-YJLRG5U3.mjs.map} +0 -0
  78. /package/dist/{types/annotated-function.mjs.map → telemetry/events.mjs.map} +0 -0
  79. /package/dist/{utils/annotated-function.mjs.map → telemetry/index.mjs.map} +0 -0
@@ -0,0 +1,181 @@
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
+ }
100
+ shouldSendEvent() {
101
+ if (!this.telemetryBaseUrl) {
102
+ return false;
103
+ }
104
+ const randomNumber = Math.random();
105
+ return randomNumber < this.sampleRate;
106
+ }
107
+ async capture(event, properties) {
108
+ if (!this.shouldSendEvent() || !this.posthog) {
109
+ return;
110
+ }
111
+ const flattenedProperties = flattenObject(properties);
112
+ const propertiesWithGlobal = {
113
+ ...this.globalProperties,
114
+ ...flattenedProperties
115
+ };
116
+ const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce(
117
+ (obj, key) => {
118
+ obj[key] = propertiesWithGlobal[key];
119
+ return obj;
120
+ },
121
+ {}
122
+ );
123
+ this.posthog.capture({
124
+ distinctId: (0, import_crypto.randomUUID)(),
125
+ event,
126
+ properties: { ...orderedPropertiesWithGlobal }
127
+ });
128
+ }
129
+ async checkForUpdates() {
130
+ const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;
131
+ const response = await fetch(url);
132
+ if (!response.ok) {
133
+ return;
134
+ }
135
+ const result = await response.json();
136
+ const { advisory, severity } = result;
137
+ if (!advisory && (severity === "low" || severity === "none")) {
138
+ return;
139
+ }
140
+ printSecurityNotice(result);
141
+ }
142
+ setTelemetryBaseUrl(url) {
143
+ this.telemetryBaseUrl = url;
144
+ if (this.posthog) {
145
+ this.posthog.host = `${url}/telemetry/ingest`;
146
+ }
147
+ }
148
+ setGlobalProperties(properties) {
149
+ const flattenedProperties = flattenObject(properties);
150
+ this.globalProperties = { ...this.globalProperties, ...flattenedProperties };
151
+ }
152
+ setCloudConfiguration(properties) {
153
+ this.cloudConfiguration = properties;
154
+ this.setGlobalProperties({
155
+ cloud: {
156
+ publicApiKey: properties.publicApiKey,
157
+ baseUrl: properties.baseUrl
158
+ }
159
+ });
160
+ }
161
+ setSampleRate(sampleRate) {
162
+ let _sampleRate;
163
+ _sampleRate = sampleRate ?? 0.05;
164
+ if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {
165
+ _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
166
+ }
167
+ if (_sampleRate < 0 || _sampleRate > 1) {
168
+ throw new Error("Sample rate must be between 0 and 1");
169
+ }
170
+ this.sampleRate = _sampleRate;
171
+ this.setGlobalProperties({
172
+ sampleRate: this.sampleRate,
173
+ sampleRateAdjustmentFactor: 1 - this.sampleRate
174
+ });
175
+ }
176
+ };
177
+ // Annotate the CommonJS export names for ESM import in node:
178
+ 0 && (module.exports = {
179
+ TelemetryClient
180
+ });
181
+ //# 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\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,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AAI,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-2WEXXBTK.mjs";
5
+ import "../chunk-6QGXWNS5.mjs";
6
+ export {
7
+ TelemetryClient
8
+ };
9
+ //# sourceMappingURL=index.mjs.map
@@ -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,179 @@
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
+ }
98
+ shouldSendEvent() {
99
+ if (!this.telemetryBaseUrl) {
100
+ return false;
101
+ }
102
+ const randomNumber = Math.random();
103
+ return randomNumber < this.sampleRate;
104
+ }
105
+ async capture(event, properties) {
106
+ if (!this.shouldSendEvent() || !this.posthog) {
107
+ return;
108
+ }
109
+ const flattenedProperties = flattenObject(properties);
110
+ const propertiesWithGlobal = {
111
+ ...this.globalProperties,
112
+ ...flattenedProperties
113
+ };
114
+ const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce(
115
+ (obj, key) => {
116
+ obj[key] = propertiesWithGlobal[key];
117
+ return obj;
118
+ },
119
+ {}
120
+ );
121
+ this.posthog.capture({
122
+ distinctId: (0, import_crypto.randomUUID)(),
123
+ event,
124
+ properties: { ...orderedPropertiesWithGlobal }
125
+ });
126
+ }
127
+ async checkForUpdates() {
128
+ const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;
129
+ const response = await fetch(url);
130
+ if (!response.ok) {
131
+ return;
132
+ }
133
+ const result = await response.json();
134
+ const { advisory, severity } = result;
135
+ if (!advisory && (severity === "low" || severity === "none")) {
136
+ return;
137
+ }
138
+ printSecurityNotice(result);
139
+ }
140
+ setTelemetryBaseUrl(url) {
141
+ this.telemetryBaseUrl = url;
142
+ if (this.posthog) {
143
+ this.posthog.host = `${url}/telemetry/ingest`;
144
+ }
145
+ }
146
+ setGlobalProperties(properties) {
147
+ const flattenedProperties = flattenObject(properties);
148
+ this.globalProperties = { ...this.globalProperties, ...flattenedProperties };
149
+ }
150
+ setCloudConfiguration(properties) {
151
+ this.cloudConfiguration = properties;
152
+ this.setGlobalProperties({
153
+ cloud: {
154
+ publicApiKey: properties.publicApiKey,
155
+ baseUrl: properties.baseUrl
156
+ }
157
+ });
158
+ }
159
+ setSampleRate(sampleRate) {
160
+ let _sampleRate;
161
+ _sampleRate = sampleRate ?? 0.05;
162
+ if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {
163
+ _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
164
+ }
165
+ if (_sampleRate < 0 || _sampleRate > 1) {
166
+ throw new Error("Sample rate must be between 0 and 1");
167
+ }
168
+ this.sampleRate = _sampleRate;
169
+ this.setGlobalProperties({
170
+ sampleRate: this.sampleRate,
171
+ sampleRateAdjustmentFactor: 1 - this.sampleRate
172
+ });
173
+ }
174
+ };
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ TelemetryClient
178
+ });
179
+ //# 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\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,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,GAAG,aAAAA,QAAM,KAAK,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a;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-2WEXXBTK.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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/telemetry/utils.ts"],"sourcesContent":["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;AAAA,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,GAAG,aAAAA,QAAM,KAAK,SAAS,OAAO,GAAG;AAC7C,UAAQ,IAAI;AACZ,UAAQ,IAAI,kSAAkD;AAChE;","names":["chalk"]}
@@ -0,0 +1,9 @@
1
+ import {
2
+ flattenObject,
3
+ printSecurityNotice
4
+ } from "../chunk-6QGXWNS5.mjs";
5
+ export {
6
+ flattenObject,
7
+ printSecurityNotice
8
+ };
9
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,3 @@
1
1
  export { AssistantMessage, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, JSONValue, ToolDefinition } from './openai-assistant.js';
2
- export { AnnotatedFunction, AnnotatedFunctionArgument, AnnotatedFunctionArrayArgument, AnnotatedFunctionSimpleArgument } from './annotated-function.js';
3
2
  export { Action, MappedParameterTypes, Parameter } from './action.js';
4
3
  export { CopilotCloudConfig } from './copilot-cloud-config.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./openai-assistant\";\nexport * from \"./annotated-function\";\nexport * from \"./action\";\nexport * from \"./copilot-cloud-config\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./openai-assistant\";\nexport * from \"./action\";\nexport * from \"./copilot-cloud-config\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,6 +1,5 @@
1
- import "../chunk-BANDZXMP.mjs";
2
- import "../chunk-NAFEBKSO.mjs";
3
- import "../chunk-YBHX4Y25.mjs";
1
+ import "../chunk-DE5K76I2.mjs";
4
2
  import "../chunk-MSUB6DGR.mjs";
5
3
  import "../chunk-IAFBVORQ.mjs";
4
+ import "../chunk-NAFEBKSO.mjs";
6
5
  //# sourceMappingURL=index.mjs.map
@@ -1,5 +1,2 @@
1
- export { actionToChatCompletionFunction, annotatedFunctionToAction, annotatedFunctionToChatCompletionFunction } from './annotated-function.js';
2
1
  export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema } from './json-schema.js';
3
- import '../types/openai-assistant.js';
4
- import '../types/annotated-function.js';
5
2
  import '../types/action.js';