@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
@@ -1,8 +1,8 @@
1
1
 
2
- > @copilotkit/shared@1.0.0-beta.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/shared
2
+ > @copilotkit/shared@1.0.0-beta.2 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/shared
3
3
  > tsup --clean
4
4
 
5
- CLI Building entry: src/index.ts, src/constants/index.ts, src/types/action.ts, src/types/annotated-function.ts, src/types/copilot-cloud-config.ts, src/types/index.ts, src/types/openai-assistant.ts, src/utils/annotated-function.ts, src/utils/index.ts, src/utils/json-schema.ts
5
+ CLI Building entry: src/index.ts, src/constants/index.ts, src/telemetry/events.ts, src/telemetry/index.ts, src/telemetry/security-check.ts, src/telemetry/telemetry-client.ts, src/telemetry/utils.ts, src/types/action.ts, src/types/copilot-cloud-config.ts, src/types/index.ts, src/types/openai-assistant.ts, src/utils/index.ts, src/utils/json-schema.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v6.7.0
8
8
  CLI Using tsup config: /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/shared/tsup.config.ts
@@ -10,75 +10,92 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- CJS dist/index.js 8.66 KB
14
- CJS dist/constants/index.js 1.65 KB
13
+ CJS dist/utils/index.js 3.23 KB
14
+ CJS dist/index.js 9.45 KB
15
+ CJS dist/constants/index.js 1.64 KB
16
+ CJS dist/telemetry/events.js 805.00 B
17
+ CJS dist/telemetry/index.js 6.63 KB
18
+ CJS dist/telemetry/security-check.js 56.00 B
19
+ CJS dist/telemetry/telemetry-client.js 6.63 KB
20
+ CJS dist/telemetry/utils.js 3.14 KB
15
21
  CJS dist/types/action.js 801.00 B
16
- CJS dist/types/annotated-function.js 849.00 B
17
22
  CJS dist/types/copilot-cloud-config.js 857.00 B
18
23
  CJS dist/types/index.js 797.00 B
19
24
  CJS dist/types/openai-assistant.js 841.00 B
20
- CJS dist/utils/annotated-function.js 5.84 KB
21
- CJS dist/utils/index.js 8.03 KB
22
25
  CJS dist/utils/json-schema.js 3.23 KB
23
- CJS dist/index.js.map 13.67 KB
24
- CJS dist/constants/index.js.map 564.00 B
26
+ CJS dist/utils/index.js.map 4.82 KB
27
+ CJS dist/index.js.map 13.75 KB
28
+ CJS dist/constants/index.js.map 551.00 B
29
+ CJS dist/telemetry/events.js.map 330.00 B
30
+ CJS dist/telemetry/index.js.map 8.61 KB
31
+ CJS dist/telemetry/security-check.js.map 71.00 B
32
+ CJS dist/telemetry/telemetry-client.js.map 8.54 KB
33
+ CJS dist/telemetry/utils.js.map 2.00 KB
25
34
  CJS dist/types/action.js.map 4.84 KB
26
- CJS dist/types/annotated-function.js.map 871.00 B
27
35
  CJS dist/types/copilot-cloud-config.js.map 356.00 B
28
- CJS dist/types/index.js.map 277.00 B
36
+ CJS dist/types/index.js.map 236.00 B
29
37
  CJS dist/types/openai-assistant.js.map 1.53 KB
30
- CJS dist/utils/annotated-function.js.map 8.45 KB
31
- CJS dist/utils/index.js.map 13.23 KB
32
38
  CJS dist/utils/json-schema.js.map 4.75 KB
33
- CJS ⚡️ Build success in 82ms
34
- ESM dist/index.mjs 858.00 B
39
+ CJS ⚡️ Build success in 104ms
40
+ ESM dist/index.mjs 711.00 B
35
41
  ESM dist/constants/index.mjs 315.00 B
42
+ ESM dist/telemetry/events.mjs 35.00 B
36
43
  ESM dist/types/action.mjs 67.00 B
37
- ESM dist/utils/annotated-function.mjs 314.00 B
38
- ESM dist/chunk-CYDWEPFL.mjs 43.00 B
44
+ ESM dist/chunk-DE5K76I2.mjs 43.00 B
45
+ ESM dist/chunk-MSUB6DGR.mjs 43.00 B
46
+ ESM dist/chunk-IAFBVORQ.mjs 43.00 B
47
+ ESM dist/chunk-YJLRG5U3.mjs 43.00 B
39
48
  ESM dist/chunk-CIPF7PMC.mjs 2.20 KB
40
- ESM dist/chunk-2VLE6D3W.mjs 468.00 B
41
- ESM dist/types/annotated-function.mjs 79.00 B
42
- ESM dist/types/copilot-cloud-config.mjs 81.00 B
43
- ESM dist/types/index.mjs 194.00 B
44
- ESM dist/chunk-BANDZXMP.mjs 43.00 B
49
+ ESM dist/chunk-3AJ2GKWG.mjs 455.00 B
50
+ ESM dist/telemetry/index.mjs 187.00 B
51
+ ESM dist/chunk-P7STFMPO.mjs 43.00 B
52
+ ESM dist/telemetry/security-check.mjs 43.00 B
53
+ ESM dist/telemetry/telemetry-client.mjs 166.00 B
54
+ ESM dist/chunk-2WEXXBTK.mjs 3.58 KB
55
+ ESM dist/telemetry/utils.mjs 165.00 B
56
+ ESM dist/chunk-6QGXWNS5.mjs 1.41 KB
45
57
  ESM dist/chunk-NAFEBKSO.mjs 43.00 B
46
- ESM dist/chunk-YBHX4Y25.mjs 43.00 B
47
- ESM dist/chunk-MSUB6DGR.mjs 43.00 B
58
+ ESM dist/types/copilot-cloud-config.mjs 81.00 B
59
+ ESM dist/types/index.mjs 162.00 B
48
60
  ESM dist/types/openai-assistant.mjs 77.00 B
49
- ESM dist/chunk-IAFBVORQ.mjs 43.00 B
50
- ESM dist/chunk-S4HGLK2E.mjs 4.62 KB
51
- ESM dist/utils/index.mjs 437.00 B
61
+ ESM dist/utils/index.mjs 181.00 B
52
62
  ESM dist/utils/json-schema.mjs 155.00 B
53
63
  ESM dist/index.mjs.map 71.00 B
54
64
  ESM dist/constants/index.mjs.map 71.00 B
65
+ ESM dist/telemetry/events.mjs.map 71.00 B
55
66
  ESM dist/types/action.mjs.map 71.00 B
56
- ESM dist/utils/annotated-function.mjs.map 71.00 B
57
- ESM dist/chunk-CYDWEPFL.mjs.map 71.00 B
67
+ ESM dist/chunk-DE5K76I2.mjs.map 71.00 B
68
+ ESM dist/chunk-MSUB6DGR.mjs.map 71.00 B
69
+ ESM dist/chunk-IAFBVORQ.mjs.map 71.00 B
70
+ ESM dist/chunk-YJLRG5U3.mjs.map 71.00 B
58
71
  ESM dist/chunk-CIPF7PMC.mjs.map 4.71 KB
59
- ESM dist/chunk-2VLE6D3W.mjs.map 502.00 B
60
- ESM dist/types/annotated-function.mjs.map 71.00 B
72
+ ESM dist/chunk-3AJ2GKWG.mjs.map 489.00 B
73
+ ESM dist/telemetry/index.mjs.map 71.00 B
74
+ ESM dist/chunk-P7STFMPO.mjs.map 71.00 B
75
+ ESM dist/telemetry/security-check.mjs.map 71.00 B
76
+ ESM dist/telemetry/telemetry-client.mjs.map 71.00 B
77
+ ESM dist/chunk-2WEXXBTK.mjs.map 6.61 KB
78
+ ESM dist/telemetry/utils.mjs.map 71.00 B
79
+ ESM dist/chunk-6QGXWNS5.mjs.map 1.90 KB
80
+ ESM dist/chunk-NAFEBKSO.mjs.map 71.00 B
61
81
  ESM dist/types/copilot-cloud-config.mjs.map 71.00 B
62
82
  ESM dist/types/index.mjs.map 71.00 B
63
- ESM dist/chunk-BANDZXMP.mjs.map 71.00 B
64
- ESM dist/chunk-NAFEBKSO.mjs.map 71.00 B
65
- ESM dist/chunk-YBHX4Y25.mjs.map 71.00 B
66
- ESM dist/chunk-MSUB6DGR.mjs.map 71.00 B
67
83
  ESM dist/types/openai-assistant.mjs.map 71.00 B
68
- ESM dist/chunk-IAFBVORQ.mjs.map 71.00 B
69
- ESM dist/chunk-S4HGLK2E.mjs.map 8.40 KB
70
84
  ESM dist/utils/index.mjs.map 71.00 B
71
85
  ESM dist/utils/json-schema.mjs.map 71.00 B
72
- ESM ⚡️ Build success in 95ms
86
+ ESM ⚡️ Build success in 123ms
73
87
  DTS Build start
74
- DTS ⚡️ Build success in 4409ms
75
- DTS dist/index.d.ts 937.00 B
88
+ DTS ⚡️ Build success in 5474ms
89
+ DTS dist/index.d.ts 750.00 B
76
90
  DTS dist/types/openai-assistant.d.ts 1.47 KB
77
- DTS dist/types/annotated-function.d.ts 766.00 B
78
91
  DTS dist/types/action.d.ts 2.24 KB
79
92
  DTS dist/types/copilot-cloud-config.d.ts 278.00 B
80
- DTS dist/utils/annotated-function.d.ts 600.00 B
81
93
  DTS dist/utils/json-schema.d.ts 884.00 B
82
- DTS dist/constants/index.d.ts 410.00 B
83
- DTS dist/types/index.d.ts 444.00 B
84
- DTS dist/utils/index.d.ts 420.00 B
94
+ DTS dist/constants/index.d.ts 397.00 B
95
+ DTS dist/telemetry/telemetry-client.d.ts 1.16 KB
96
+ DTS dist/telemetry/events.d.ts 223.00 B
97
+ DTS dist/telemetry/index.d.ts 102.00 B
98
+ DTS dist/telemetry/security-check.d.ts 12.00 B
99
+ DTS dist/telemetry/utils.d.ts 333.00 B
100
+ DTS dist/types/index.d.ts 291.00 B
101
+ DTS dist/utils/index.d.ts 196.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @copilotkit/shared
2
2
 
3
+ ## 1.0.0-beta.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Set default Copilot Cloud runtime URL to versioned URL (v1)
8
+
9
+ ## 1.0.0-beta.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Introduce anonymous telemetry
14
+
3
15
  ## 1.0.0-beta.0
4
16
 
5
17
  ### Major Changes
@@ -0,0 +1,119 @@
1
+ import {
2
+ flattenObject,
3
+ printSecurityNotice
4
+ } from "./chunk-6QGXWNS5.mjs";
5
+
6
+ // src/telemetry/telemetry-client.ts
7
+ import { PostHog } from "posthog-node";
8
+ import { randomUUID } from "crypto";
9
+ var TelemetryClient = class {
10
+ constructor({
11
+ packageName,
12
+ packageVersion,
13
+ telemetryDisabled,
14
+ telemetryBaseUrl,
15
+ posthogToken,
16
+ sampleRate
17
+ }) {
18
+ this.globalProperties = {};
19
+ this.cloudConfiguration = null;
20
+ this.telemetryDisabled = false;
21
+ this.sampleRate = 0.05;
22
+ this.packageName = packageName;
23
+ this.packageVersion = packageVersion;
24
+ 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";
25
+ if (this.telemetryDisabled) {
26
+ return;
27
+ }
28
+ this.setSampleRate(sampleRate);
29
+ this.telemetryBaseUrl = telemetryBaseUrl || process.env.COPILOTKIT_TELEMETRY_BASE_URL || "https://telemetry.copilotkit.ai";
30
+ this.posthog = new PostHog(posthogToken || "token", {
31
+ host: `${this.telemetryBaseUrl}/telemetry/ingest`
32
+ });
33
+ this.setGlobalProperties({
34
+ "copilotkit.package.name": packageName,
35
+ "copilotkit.package.version": packageVersion
36
+ });
37
+ }
38
+ shouldSendEvent() {
39
+ if (!this.telemetryBaseUrl) {
40
+ return false;
41
+ }
42
+ const randomNumber = Math.random();
43
+ return randomNumber < this.sampleRate;
44
+ }
45
+ async capture(event, properties) {
46
+ if (!this.shouldSendEvent() || !this.posthog) {
47
+ return;
48
+ }
49
+ const flattenedProperties = flattenObject(properties);
50
+ const propertiesWithGlobal = {
51
+ ...this.globalProperties,
52
+ ...flattenedProperties
53
+ };
54
+ const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal).sort().reduce(
55
+ (obj, key) => {
56
+ obj[key] = propertiesWithGlobal[key];
57
+ return obj;
58
+ },
59
+ {}
60
+ );
61
+ this.posthog.capture({
62
+ distinctId: randomUUID(),
63
+ event,
64
+ properties: { ...orderedPropertiesWithGlobal }
65
+ });
66
+ }
67
+ async checkForUpdates() {
68
+ const url = `${this.telemetryBaseUrl}/check-for-updates?packageName=${this.packageName}&packageVersion=${this.packageVersion}`;
69
+ const response = await fetch(url);
70
+ if (!response.ok) {
71
+ return;
72
+ }
73
+ const result = await response.json();
74
+ const { advisory, severity } = result;
75
+ if (!advisory && (severity === "low" || severity === "none")) {
76
+ return;
77
+ }
78
+ printSecurityNotice(result);
79
+ }
80
+ setTelemetryBaseUrl(url) {
81
+ this.telemetryBaseUrl = url;
82
+ if (this.posthog) {
83
+ this.posthog.host = `${url}/telemetry/ingest`;
84
+ }
85
+ }
86
+ setGlobalProperties(properties) {
87
+ const flattenedProperties = flattenObject(properties);
88
+ this.globalProperties = { ...this.globalProperties, ...flattenedProperties };
89
+ }
90
+ setCloudConfiguration(properties) {
91
+ this.cloudConfiguration = properties;
92
+ this.setGlobalProperties({
93
+ cloud: {
94
+ publicApiKey: properties.publicApiKey,
95
+ baseUrl: properties.baseUrl
96
+ }
97
+ });
98
+ }
99
+ setSampleRate(sampleRate) {
100
+ let _sampleRate;
101
+ _sampleRate = sampleRate ?? 0.05;
102
+ if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {
103
+ _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);
104
+ }
105
+ if (_sampleRate < 0 || _sampleRate > 1) {
106
+ throw new Error("Sample rate must be between 0 and 1");
107
+ }
108
+ this.sampleRate = _sampleRate;
109
+ this.setGlobalProperties({
110
+ sampleRate: this.sampleRate,
111
+ sampleRateAdjustmentFactor: 1 - this.sampleRate
112
+ });
113
+ }
114
+ };
115
+
116
+ export {
117
+ TelemetryClient
118
+ };
119
+ //# sourceMappingURL=chunk-2WEXXBTK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/telemetry/telemetry-client.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"],"mappings":"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","names":[]}
@@ -1,7 +1,7 @@
1
1
  // src/constants/index.ts
2
2
  var COPILOT_CLOUD_API_URL = "https://api.copilotkit.ai";
3
3
  var COPILOT_CLOUD_VERSION = "v1";
4
- var COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/${COPILOT_CLOUD_VERSION}/copilotkit/runtime/chat`;
4
+ var COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;
5
5
  var COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
6
6
 
7
7
  export {
@@ -10,4 +10,4 @@ export {
10
10
  COPILOT_CLOUD_CHAT_URL,
11
11
  COPILOT_CLOUD_PUBLIC_API_KEY_HEADER
12
12
  };
13
- //# sourceMappingURL=chunk-2VLE6D3W.mjs.map
13
+ //# sourceMappingURL=chunk-3AJ2GKWG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants/index.ts"],"sourcesContent":["export const COPILOT_CLOUD_API_URL = \"https://api.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = \"X-CopilotCloud-Public-Api-Key\";\n"],"mappings":";AAAO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB,GAAG,oCAAoC;AACtE,IAAM,sCAAsC;","names":[]}
@@ -0,0 +1,34 @@
1
+ // src/telemetry/utils.ts
2
+ import chalk from "chalk";
3
+ function flattenObject(obj, parentKey = "", res = {}) {
4
+ for (let key in obj) {
5
+ const propName = parentKey ? `${parentKey}.${key}` : key;
6
+ if (typeof obj[key] === "object" && obj[key] !== null) {
7
+ flattenObject(obj[key], propName, res);
8
+ } else {
9
+ res[propName] = obj[key];
10
+ }
11
+ }
12
+ return res;
13
+ }
14
+ function printSecurityNotice(advisory) {
15
+ const severityColor = {
16
+ low: chalk.blue,
17
+ medium: chalk.yellow,
18
+ high: chalk.red
19
+ }[advisory.severity.toLowerCase()] || chalk.white;
20
+ console.log();
21
+ console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 ${chalk.bold(`CopilotKit`)} \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
22
+ console.log();
23
+ console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`);
24
+ console.log();
25
+ console.log(`${chalk.bold(advisory.message)}`);
26
+ console.log();
27
+ 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`);
28
+ }
29
+
30
+ export {
31
+ flattenObject,
32
+ printSecurityNotice
33
+ };
34
+ //# sourceMappingURL=chunk-6QGXWNS5.mjs.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,OAAO,WAAW;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,MAAM;AAAA,IACX,QAAQ,MAAM;AAAA,IACd,MAAM,MAAM;AAAA,EACd,EAAE,SAAS,SAAS,YAAY,CAAC,KAAK,MAAM;AAE9C,UAAQ,IAAI;AACZ,UAAQ,IAAI,gHAAsB,MAAM,KAAK,YAAY,gHAAsB;AAC/E,UAAQ,IAAI;AACZ,UAAQ,IAAI,GAAG,MAAM,KAAK,aAAa,cAAc,SAAS,SAAS,YAAY,CAAC,GAAG,GAAG;AAC1F,UAAQ,IAAI;AACZ,UAAQ,IAAI,GAAG,MAAM,KAAK,SAAS,OAAO,GAAG;AAC7C,UAAQ,IAAI;AACZ,UAAQ,IAAI,kSAAkD;AAChE;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-DE5K76I2.mjs.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-P7STFMPO.mjs.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-YJLRG5U3.mjs.map
@@ -1,6 +1,6 @@
1
1
  declare const COPILOT_CLOUD_API_URL = "https://api.copilotkit.ai";
2
2
  declare const COPILOT_CLOUD_VERSION = "v1";
3
- declare const COPILOT_CLOUD_CHAT_URL = "https://api.copilotkit.ai/v1/copilotkit/runtime/chat";
3
+ declare const COPILOT_CLOUD_CHAT_URL = "https://api.copilotkit.ai/copilotkit/v1";
4
4
  declare const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
5
5
 
6
6
  export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION };
@@ -28,7 +28,7 @@ __export(constants_exports, {
28
28
  module.exports = __toCommonJS(constants_exports);
29
29
  var COPILOT_CLOUD_API_URL = "https://api.copilotkit.ai";
30
30
  var COPILOT_CLOUD_VERSION = "v1";
31
- var COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/${COPILOT_CLOUD_VERSION}/copilotkit/runtime/chat`;
31
+ var COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;
32
32
  var COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = "X-CopilotCloud-Public-Api-Key";
33
33
  // Annotate the CommonJS export names for ESM import in node:
34
34
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["export const COPILOT_CLOUD_API_URL = \"https://api.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/${COPILOT_CLOUD_VERSION}/copilotkit/runtime/chat`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = \"X-CopilotCloud-Public-Api-Key\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB,GAAG,yBAAyB;AAC3D,IAAM,sCAAsC;","names":[]}
1
+ {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["export const COPILOT_CLOUD_API_URL = \"https://api.copilotkit.ai\";\nexport const COPILOT_CLOUD_VERSION = \"v1\";\nexport const COPILOT_CLOUD_CHAT_URL = `${COPILOT_CLOUD_API_URL}/copilotkit/${COPILOT_CLOUD_VERSION}`;\nexport const COPILOT_CLOUD_PUBLIC_API_KEY_HEADER = \"X-CopilotCloud-Public-Api-Key\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB,GAAG,oCAAoC;AACtE,IAAM,sCAAsC;","names":[]}
@@ -3,7 +3,7 @@ import {
3
3
  COPILOT_CLOUD_CHAT_URL,
4
4
  COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
5
5
  COPILOT_CLOUD_VERSION
6
- } from "../chunk-2VLE6D3W.mjs";
6
+ } from "../chunk-3AJ2GKWG.mjs";
7
7
  export {
8
8
  COPILOT_CLOUD_API_URL,
9
9
  COPILOT_CLOUD_CHAT_URL,
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { AssistantMessage, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, JSONValue, ToolDefinition } from './types/openai-assistant.js';
2
- export { AnnotatedFunction, AnnotatedFunctionArgument, AnnotatedFunctionArrayArgument, AnnotatedFunctionSimpleArgument } from './types/annotated-function.js';
3
2
  export { Action, MappedParameterTypes, Parameter } from './types/action.js';
4
3
  export { CopilotCloudConfig } from './types/copilot-cloud-config.js';
5
- export { actionToChatCompletionFunction, annotatedFunctionToAction, annotatedFunctionToChatCompletionFunction } from './utils/annotated-function.js';
6
4
  export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema } from './utils/json-schema.js';
7
5
  export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION } from './constants/index.js';
6
+ export { TelemetryClient } from './telemetry/telemetry-client.js';
7
+ import 'posthog-node';
8
+ import './telemetry/events.js';