@copilotkit/shared 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +45 -38
- package/CHANGELOG.md +12 -0
- package/README.md +51 -0
- package/dist/chunk-6P6F44JQ.mjs +9 -0
- package/dist/chunk-6P6F44JQ.mjs.map +1 -0
- package/dist/chunk-CYDWEPFL.mjs +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +9 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +6 -2
- package/dist/utils/random-id.d.ts +3 -0
- package/dist/utils/random-id.js +33 -0
- package/dist/utils/random-id.js.map +1 -0
- package/dist/utils/random-id.mjs +7 -0
- package/dist/utils/random-id.mjs.map +1 -0
- package/package.json +20 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/random-id.ts +3 -0
- package/dist/chunk-YJLRG5U3.mjs +0 -1
- /package/dist/{chunk-YJLRG5U3.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @copilotkit/shared@1.0.
|
|
2
|
+
> @copilotkit/shared@1.0.4 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/shared
|
|
3
3
|
> tsup --clean
|
|
4
4
|
|
|
5
|
-
[34mCLI[39m 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
|
|
5
|
+
[34mCLI[39m 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, src/utils/random-id.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v6.7.0
|
|
8
8
|
[34mCLI[39m Using tsup config: /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/shared/tsup.config.ts
|
|
@@ -10,42 +10,16 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[32m9.39 KB[39m
|
|
15
|
-
[32mCJS[39m [1mdist/constants/index.js [22m[32m1.64 KB[39m
|
|
16
|
-
[32mCJS[39m [1mdist/telemetry/events.js [22m[32m805.00 B[39m
|
|
17
|
-
[32mCJS[39m [1mdist/telemetry/index.js [22m[32m6.58 KB[39m
|
|
18
|
-
[32mCJS[39m [1mdist/telemetry/security-check.js [22m[32m56.00 B[39m
|
|
19
|
-
[32mCJS[39m [1mdist/telemetry/telemetry-client.js [22m[32m6.58 KB[39m
|
|
20
|
-
[32mCJS[39m [1mdist/telemetry/utils.js [22m[32m3.14 KB[39m
|
|
21
|
-
[32mCJS[39m [1mdist/types/action.js [22m[32m801.00 B[39m
|
|
22
|
-
[32mCJS[39m [1mdist/types/copilot-cloud-config.js [22m[32m857.00 B[39m
|
|
23
|
-
[32mCJS[39m [1mdist/types/index.js [22m[32m797.00 B[39m
|
|
24
|
-
[32mCJS[39m [1mdist/types/openai-assistant.js [22m[32m841.00 B[39m
|
|
25
|
-
[32mCJS[39m [1mdist/utils/json-schema.js [22m[32m3.23 KB[39m
|
|
26
|
-
[32mCJS[39m [1mdist/utils/index.js.map [22m[32m4.82 KB[39m
|
|
27
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m13.63 KB[39m
|
|
28
|
-
[32mCJS[39m [1mdist/constants/index.js.map [22m[32m551.00 B[39m
|
|
29
|
-
[32mCJS[39m [1mdist/telemetry/events.js.map [22m[32m330.00 B[39m
|
|
30
|
-
[32mCJS[39m [1mdist/telemetry/index.js.map [22m[32m8.49 KB[39m
|
|
31
|
-
[32mCJS[39m [1mdist/telemetry/security-check.js.map [22m[32m71.00 B[39m
|
|
32
|
-
[32mCJS[39m [1mdist/telemetry/telemetry-client.js.map [22m[32m8.42 KB[39m
|
|
33
|
-
[32mCJS[39m [1mdist/telemetry/utils.js.map [22m[32m2.00 KB[39m
|
|
34
|
-
[32mCJS[39m [1mdist/types/action.js.map [22m[32m4.84 KB[39m
|
|
35
|
-
[32mCJS[39m [1mdist/types/copilot-cloud-config.js.map [22m[32m356.00 B[39m
|
|
36
|
-
[32mCJS[39m [1mdist/types/index.js.map [22m[32m236.00 B[39m
|
|
37
|
-
[32mCJS[39m [1mdist/types/openai-assistant.js.map [22m[32m1.53 KB[39m
|
|
38
|
-
[32mCJS[39m [1mdist/utils/json-schema.js.map [22m[32m4.75 KB[39m
|
|
39
|
-
[32mCJS[39m ⚡️ Build success in 87ms
|
|
40
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m711.00 B[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m774.00 B[39m
|
|
41
14
|
[32mESM[39m [1mdist/constants/index.mjs [22m[32m315.00 B[39m
|
|
42
15
|
[32mESM[39m [1mdist/telemetry/events.mjs [22m[32m35.00 B[39m
|
|
43
16
|
[32mESM[39m [1mdist/types/action.mjs [22m[32m67.00 B[39m
|
|
44
17
|
[32mESM[39m [1mdist/chunk-DE5K76I2.mjs [22m[32m43.00 B[39m
|
|
45
18
|
[32mESM[39m [1mdist/chunk-MSUB6DGR.mjs [22m[32m43.00 B[39m
|
|
46
19
|
[32mESM[39m [1mdist/chunk-IAFBVORQ.mjs [22m[32m43.00 B[39m
|
|
47
|
-
[32mESM[39m [1mdist/chunk-
|
|
20
|
+
[32mESM[39m [1mdist/chunk-CYDWEPFL.mjs [22m[32m43.00 B[39m
|
|
48
21
|
[32mESM[39m [1mdist/chunk-CIPF7PMC.mjs [22m[32m2.20 KB[39m
|
|
22
|
+
[32mESM[39m [1mdist/chunk-6P6F44JQ.mjs [22m[32m166.00 B[39m
|
|
49
23
|
[32mESM[39m [1mdist/chunk-3AJ2GKWG.mjs [22m[32m455.00 B[39m
|
|
50
24
|
[32mESM[39m [1mdist/telemetry/index.mjs [22m[32m187.00 B[39m
|
|
51
25
|
[32mESM[39m [1mdist/chunk-P7STFMPO.mjs [22m[32m43.00 B[39m
|
|
@@ -55,11 +29,12 @@
|
|
|
55
29
|
[32mESM[39m [1mdist/telemetry/utils.mjs [22m[32m165.00 B[39m
|
|
56
30
|
[32mESM[39m [1mdist/chunk-6QGXWNS5.mjs [22m[32m1.41 KB[39m
|
|
57
31
|
[32mESM[39m [1mdist/chunk-NAFEBKSO.mjs [22m[32m43.00 B[39m
|
|
32
|
+
[32mESM[39m [1mdist/utils/index.mjs [22m[32m245.00 B[39m
|
|
58
33
|
[32mESM[39m [1mdist/types/copilot-cloud-config.mjs [22m[32m81.00 B[39m
|
|
59
34
|
[32mESM[39m [1mdist/types/index.mjs [22m[32m162.00 B[39m
|
|
60
35
|
[32mESM[39m [1mdist/types/openai-assistant.mjs [22m[32m77.00 B[39m
|
|
61
|
-
[32mESM[39m [1mdist/utils/index.mjs [22m[32m181.00 B[39m
|
|
62
36
|
[32mESM[39m [1mdist/utils/json-schema.mjs [22m[32m155.00 B[39m
|
|
37
|
+
[32mESM[39m [1mdist/utils/random-id.mjs [22m[32m113.00 B[39m
|
|
63
38
|
[32mESM[39m [1mdist/index.mjs.map [22m[32m71.00 B[39m
|
|
64
39
|
[32mESM[39m [1mdist/constants/index.mjs.map [22m[32m71.00 B[39m
|
|
65
40
|
[32mESM[39m [1mdist/telemetry/events.mjs.map [22m[32m71.00 B[39m
|
|
@@ -67,8 +42,9 @@
|
|
|
67
42
|
[32mESM[39m [1mdist/chunk-DE5K76I2.mjs.map [22m[32m71.00 B[39m
|
|
68
43
|
[32mESM[39m [1mdist/chunk-MSUB6DGR.mjs.map [22m[32m71.00 B[39m
|
|
69
44
|
[32mESM[39m [1mdist/chunk-IAFBVORQ.mjs.map [22m[32m71.00 B[39m
|
|
70
|
-
[32mESM[39m [1mdist/chunk-
|
|
45
|
+
[32mESM[39m [1mdist/chunk-CYDWEPFL.mjs.map [22m[32m71.00 B[39m
|
|
71
46
|
[32mESM[39m [1mdist/chunk-CIPF7PMC.mjs.map [22m[32m4.71 KB[39m
|
|
47
|
+
[32mESM[39m [1mdist/chunk-6P6F44JQ.mjs.map [22m[32m238.00 B[39m
|
|
72
48
|
[32mESM[39m [1mdist/chunk-3AJ2GKWG.mjs.map [22m[32m489.00 B[39m
|
|
73
49
|
[32mESM[39m [1mdist/telemetry/index.mjs.map [22m[32m71.00 B[39m
|
|
74
50
|
[32mESM[39m [1mdist/chunk-P7STFMPO.mjs.map [22m[32m71.00 B[39m
|
|
@@ -78,19 +54,50 @@
|
|
|
78
54
|
[32mESM[39m [1mdist/telemetry/utils.mjs.map [22m[32m71.00 B[39m
|
|
79
55
|
[32mESM[39m [1mdist/chunk-6QGXWNS5.mjs.map [22m[32m1.90 KB[39m
|
|
80
56
|
[32mESM[39m [1mdist/chunk-NAFEBKSO.mjs.map [22m[32m71.00 B[39m
|
|
57
|
+
[32mESM[39m [1mdist/utils/index.mjs.map [22m[32m71.00 B[39m
|
|
81
58
|
[32mESM[39m [1mdist/types/copilot-cloud-config.mjs.map [22m[32m71.00 B[39m
|
|
82
59
|
[32mESM[39m [1mdist/types/index.mjs.map [22m[32m71.00 B[39m
|
|
83
60
|
[32mESM[39m [1mdist/types/openai-assistant.mjs.map [22m[32m71.00 B[39m
|
|
84
|
-
[32mESM[39m [1mdist/utils/index.mjs.map [22m[32m71.00 B[39m
|
|
85
61
|
[32mESM[39m [1mdist/utils/json-schema.mjs.map [22m[32m71.00 B[39m
|
|
86
|
-
[32mESM[39m
|
|
62
|
+
[32mESM[39m [1mdist/utils/random-id.mjs.map [22m[32m71.00 B[39m
|
|
63
|
+
[32mESM[39m ⚡️ Build success in 98ms
|
|
64
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.53 KB[39m
|
|
65
|
+
[32mCJS[39m [1mdist/constants/index.js [22m[32m1.64 KB[39m
|
|
66
|
+
[32mCJS[39m [1mdist/telemetry/events.js [22m[32m805.00 B[39m
|
|
67
|
+
[32mCJS[39m [1mdist/telemetry/index.js [22m[32m6.58 KB[39m
|
|
68
|
+
[32mCJS[39m [1mdist/telemetry/security-check.js [22m[32m56.00 B[39m
|
|
69
|
+
[32mCJS[39m [1mdist/telemetry/telemetry-client.js [22m[32m6.58 KB[39m
|
|
70
|
+
[32mCJS[39m [1mdist/telemetry/utils.js [22m[32m3.14 KB[39m
|
|
71
|
+
[32mCJS[39m [1mdist/types/action.js [22m[32m801.00 B[39m
|
|
72
|
+
[32mCJS[39m [1mdist/types/copilot-cloud-config.js [22m[32m857.00 B[39m
|
|
73
|
+
[32mCJS[39m [1mdist/types/index.js [22m[32m797.00 B[39m
|
|
74
|
+
[32mCJS[39m [1mdist/types/openai-assistant.js [22m[32m841.00 B[39m
|
|
75
|
+
[32mCJS[39m [1mdist/utils/index.js [22m[32m3.37 KB[39m
|
|
76
|
+
[32mCJS[39m [1mdist/utils/json-schema.js [22m[32m3.23 KB[39m
|
|
77
|
+
[32mCJS[39m [1mdist/utils/random-id.js [22m[32m1.15 KB[39m
|
|
78
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m13.80 KB[39m
|
|
79
|
+
[32mCJS[39m [1mdist/constants/index.js.map [22m[32m551.00 B[39m
|
|
80
|
+
[32mCJS[39m [1mdist/telemetry/events.js.map [22m[32m330.00 B[39m
|
|
81
|
+
[32mCJS[39m [1mdist/telemetry/index.js.map [22m[32m8.49 KB[39m
|
|
82
|
+
[32mCJS[39m [1mdist/telemetry/security-check.js.map [22m[32m71.00 B[39m
|
|
83
|
+
[32mCJS[39m [1mdist/telemetry/telemetry-client.js.map [22m[32m8.42 KB[39m
|
|
84
|
+
[32mCJS[39m [1mdist/telemetry/utils.js.map [22m[32m2.00 KB[39m
|
|
85
|
+
[32mCJS[39m [1mdist/types/action.js.map [22m[32m4.84 KB[39m
|
|
86
|
+
[32mCJS[39m [1mdist/types/copilot-cloud-config.js.map [22m[32m356.00 B[39m
|
|
87
|
+
[32mCJS[39m [1mdist/types/index.js.map [22m[32m236.00 B[39m
|
|
88
|
+
[32mCJS[39m [1mdist/types/openai-assistant.js.map [22m[32m1.53 KB[39m
|
|
89
|
+
[32mCJS[39m [1mdist/utils/index.js.map [22m[32m5.02 KB[39m
|
|
90
|
+
[32mCJS[39m [1mdist/utils/json-schema.js.map [22m[32m4.75 KB[39m
|
|
91
|
+
[32mCJS[39m [1mdist/utils/random-id.js.map [22m[32m285.00 B[39m
|
|
92
|
+
[32mCJS[39m ⚡️ Build success in 111ms
|
|
87
93
|
[34mDTS[39m Build start
|
|
88
|
-
[32mDTS[39m ⚡️ Build success in
|
|
89
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
94
|
+
[32mDTS[39m ⚡️ Build success in 5224ms
|
|
95
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m810.00 B[39m
|
|
90
96
|
[32mDTS[39m [1mdist/types/openai-assistant.d.ts [22m[32m1.47 KB[39m
|
|
91
97
|
[32mDTS[39m [1mdist/types/action.d.ts [22m[32m2.24 KB[39m
|
|
92
98
|
[32mDTS[39m [1mdist/types/copilot-cloud-config.d.ts [22m[32m278.00 B[39m
|
|
93
99
|
[32mDTS[39m [1mdist/utils/json-schema.d.ts [22m[32m884.00 B[39m
|
|
100
|
+
[32mDTS[39m [1mdist/utils/random-id.d.ts [22m[32m59.00 B[39m
|
|
94
101
|
[32mDTS[39m [1mdist/constants/index.d.ts [22m[32m397.00 B[39m
|
|
95
102
|
[32mDTS[39m [1mdist/telemetry/telemetry-client.d.ts [22m[32m1.12 KB[39m
|
|
96
103
|
[32mDTS[39m [1mdist/telemetry/events.d.ts [22m[32m223.00 B[39m
|
|
@@ -98,4 +105,4 @@
|
|
|
98
105
|
[32mDTS[39m [1mdist/telemetry/security-check.d.ts [22m[32m12.00 B[39m
|
|
99
106
|
[32mDTS[39m [1mdist/telemetry/utils.d.ts [22m[32m333.00 B[39m
|
|
100
107
|
[32mDTS[39m [1mdist/types/index.d.ts [22m[32m291.00 B[39m
|
|
101
|
-
[32mDTS[39m [1mdist/utils/index.d.ts [22m[
|
|
108
|
+
[32mDTS[39m [1mdist/utils/index.d.ts [22m[32m239.00 B[39m
|
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/CopilotKit/CopilotKit/assets/746397/5890217b-524e-49c5-a89e-b8743d2acd51">
|
|
4
|
+
<img alt="CopilotKit Logo" src="https://github.com/CopilotKit/CopilotKit/assets/746397/bd5c9079-929b-4d55-bdc9-16d1c8181b71" width="450px" max-width="100%"/>
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://discord.gg/6dffbvGU3D">
|
|
11
|
+
<img src="https://dcbadge.vercel.app/api/server/6dffbvGU3D?compact=true&style=flat" alt="Discord">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/CopilotKit/CopilotKit/actions/workflows/ci.yml">
|
|
14
|
+
<img src="https://github.com/CopilotKit/CopilotKit/actions/workflows/ci.yml/badge.svg" alt="GitHub CI">
|
|
15
|
+
</a>
|
|
16
|
+
|
|
17
|
+
<a href="https://www.npmjs.com/package/@copilotkit/react-core">
|
|
18
|
+
<img src="https://img.shields.io/npm/v/@copilotkit/react-core" alt="NPM">
|
|
19
|
+
<img src="https://img.shields.io/github/license/CopilotKit/CopilotKit" alt="MIT">
|
|
20
|
+
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<h1 align="center">
|
|
24
|
+
The Open-Source Copilot Framework
|
|
25
|
+
</h1>
|
|
26
|
+
|
|
27
|
+
<h2 align="center">
|
|
28
|
+
Build, deploy, and operate fully custom AI Copilots.
|
|
29
|
+
</h2>
|
|
30
|
+
|
|
31
|
+
<h3 align="center">
|
|
32
|
+
in-app AI chatbots, AI agents, and AI Textareas.
|
|
33
|
+
</h3>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<a href="https://discord.com/invite/6dffbvGU3D">
|
|
37
|
+
<img src="https://github.com/CopilotKit/CopilotKit/assets/131273140/bf8d96ea-3aeb-4c9a-9043-96a868b7ad0f" alt="Join our Discord" height="30">
|
|
38
|
+
</a>
|
|
39
|
+
·
|
|
40
|
+
<a href="https://docs.copilotkit.ai/getting-started/quickstart-chatbot">
|
|
41
|
+
<img src="https://github.com/CopilotKit/CopilotKit/assets/131273140/a4a0fd04-6aee-4e02-9c3e-3f11d60b4e8b" alt="Read the Docs" height="30">
|
|
42
|
+
</a>
|
|
43
|
+
·
|
|
44
|
+
<a href="https://cloud.copilotkit.ai">
|
|
45
|
+
<img src="https://github.com/CopilotKit/CopilotKit/assets/131273140/28ca62a8-cf93-4d3f-96b0-dc11bf89b734" alt="Try Copilot Cloud" height="30">
|
|
46
|
+
</a>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
# Documentation
|
|
50
|
+
|
|
51
|
+
To get started with CopilotKit, please check out the [documentation](https://docs.copilotkit.ai).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/random-id.ts"],"sourcesContent":["export function randomId() {\n return \"ck-\" + globalThis.crypto.randomUUID();\n}\n"],"mappings":";AAAO,SAAS,WAAW;AACzB,SAAO,QAAQ,WAAW,OAAO,WAAW;AAC9C;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-CYDWEPFL.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { AssistantMessage, FunctionCallHandler, FunctionCallHandlerArguments, Fu
|
|
|
2
2
|
export { Action, MappedParameterTypes, Parameter } from './types/action.js';
|
|
3
3
|
export { CopilotCloudConfig } from './types/copilot-cloud-config.js';
|
|
4
4
|
export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema } from './utils/json-schema.js';
|
|
5
|
+
export { randomId } from './utils/random-id.js';
|
|
5
6
|
export { COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION } from './constants/index.js';
|
|
6
7
|
export { TelemetryClient } from './telemetry/telemetry-client.js';
|
|
7
8
|
import '@segment/analytics-node';
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,8 @@ __export(src_exports, {
|
|
|
35
35
|
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER: () => COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
36
36
|
COPILOT_CLOUD_VERSION: () => COPILOT_CLOUD_VERSION,
|
|
37
37
|
TelemetryClient: () => TelemetryClient,
|
|
38
|
-
actionParametersToJsonSchema: () => actionParametersToJsonSchema
|
|
38
|
+
actionParametersToJsonSchema: () => actionParametersToJsonSchema,
|
|
39
|
+
randomId: () => randomId
|
|
39
40
|
});
|
|
40
41
|
module.exports = __toCommonJS(src_exports);
|
|
41
42
|
|
|
@@ -115,6 +116,11 @@ function convertAttribute(attribute) {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
// src/utils/random-id.ts
|
|
120
|
+
function randomId() {
|
|
121
|
+
return "ck-" + globalThis.crypto.randomUUID();
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
// src/constants/index.ts
|
|
119
125
|
var COPILOT_CLOUD_API_URL = "https://api.copilotkit.ai";
|
|
120
126
|
var COPILOT_CLOUD_VERSION = "v1";
|
|
@@ -263,6 +269,7 @@ var TelemetryClient = class {
|
|
|
263
269
|
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
264
270
|
COPILOT_CLOUD_VERSION,
|
|
265
271
|
TelemetryClient,
|
|
266
|
-
actionParametersToJsonSchema
|
|
272
|
+
actionParametersToJsonSchema,
|
|
273
|
+
randomId
|
|
267
274
|
});
|
|
268
275
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/json-schema.ts","../src/constants/index.ts","../src/telemetry/telemetry-client.ts","../src/telemetry/utils.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n","import { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n","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","import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { randomUUID } from \"crypto\";\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private telemetryBaseUrl: string | undefined;\n private sampleRate: number = 0.05;\n private anonymousId = `anon_${randomUUID()}`;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n sampleRate?: number;\n }) {\n this.packageName = packageName;\n this.packageVersion = packageVersion;\n this.telemetryDisabled =\n telemetryDisabled ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as any).DO_NOT_TRACK === \"true\" ||\n (process.env as any).DO_NOT_TRACK === \"1\";\n\n if (this.telemetryDisabled) {\n return;\n }\n\n this.setSampleRate(sampleRate);\n\n this.telemetryBaseUrl =\n telemetryBaseUrl ||\n (process.env as any).COPILOTKIT_TELEMETRY_BASE_URL ||\n \"https://telemetry.copilotkit.ai\";\n\n this.segment = new Analytics({\n // eslint-disable-next-line\n writeKey: process.env.COPILOTKIT_SEGMENT_WRITE_KEY || \"n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja\",\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.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\n ...flattenedProperties,\n };\n const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal)\n .sort()\n .reduce(\n (obj, key) => {\n obj[key] = propertiesWithGlobal[key];\n return obj;\n },\n {} as Record<string, any>,\n );\n\n this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n\n 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 setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = { ...this.globalProperties, ...flattenedProperties };\n }\n\n setCloudConfiguration(properties: { publicApiKey: string; baseUrl: string }) {\n this.cloudConfiguration = properties;\n\n this.setGlobalProperties({\n cloud: {\n publicApiKey: properties.publicApiKey,\n baseUrl: properties.baseUrl,\n },\n });\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 0.05;\n\n // eslint-disable-next-line\n if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n // eslint-disable-next-line\n _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n });\n }\n}\n","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;AAAA;AAAA;AAAA;;;ACsCO,SAAS,6BAA6B,kBAA2C;AAEtF,MAAI,aAAqC,CAAC;AAC1C,WAAS,aAAa,oBAAoB,CAAC,GAAG;AAC5C,eAAW,UAAU,IAAI,IAAI,iBAAiB,SAAS;AAAA,EACzD;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,oBAAoB,CAAC,GAAG;AACtC,QAAI,IAAI,aAAa,OAAO;AAC1B,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AACF;AAEA,SAAS,iBAAiB,WAAkC;AA5D5D;AA6DE,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,QACvB,GAAI,UAAU,QAAQ,EAAE,MAAM,UAAU,KAAK;AAAA,MAC/C;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,QACL,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,MACzB;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,YAAM,cAAa,eAAU,eAAV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U;AACpD,SAAK,mBAAmB,EAAE,GAAG,KAAK,kBAAkB,GAAG,oBAAoB;AAAA,EAC7E;AAAA,EAEA,sBAAsB,YAAuD;AAC3E,SAAK,qBAAqB;AAE1B,SAAK,oBAAoB;AAAA,MACvB,OAAO;AAAA,QACL,cAAc,WAAW;AAAA,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,IACvC,CAAC;AAAA,EACH;AACF;","names":["chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/json-schema.ts","../src/utils/random-id.ts","../src/constants/index.ts","../src/telemetry/telemetry-client.ts","../src/telemetry/utils.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\n","import { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n","export function randomId() {\n return \"ck-\" + globalThis.crypto.randomUUID();\n}\n","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","import { Analytics } from \"@segment/analytics-node\";\nimport { AnalyticsEvents } from \"./events\";\nimport { flattenObject, printSecurityNotice } from \"./utils\";\nimport { randomUUID } from \"crypto\";\n\nexport class TelemetryClient {\n segment: Analytics | undefined;\n globalProperties: Record<string, any> = {};\n cloudConfiguration: { publicApiKey: string; baseUrl: string } | null = null;\n packageName: string;\n packageVersion: string;\n private telemetryDisabled: boolean = false;\n private telemetryBaseUrl: string | undefined;\n private sampleRate: number = 0.05;\n private anonymousId = `anon_${randomUUID()}`;\n\n constructor({\n packageName,\n packageVersion,\n telemetryDisabled,\n telemetryBaseUrl,\n sampleRate,\n }: {\n packageName: string;\n packageVersion: string;\n telemetryDisabled?: boolean;\n telemetryBaseUrl?: string;\n sampleRate?: number;\n }) {\n this.packageName = packageName;\n this.packageVersion = packageVersion;\n this.telemetryDisabled =\n telemetryDisabled ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n (process.env as any).COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n (process.env as any).DO_NOT_TRACK === \"true\" ||\n (process.env as any).DO_NOT_TRACK === \"1\";\n\n if (this.telemetryDisabled) {\n return;\n }\n\n this.setSampleRate(sampleRate);\n\n this.telemetryBaseUrl =\n telemetryBaseUrl ||\n (process.env as any).COPILOTKIT_TELEMETRY_BASE_URL ||\n \"https://telemetry.copilotkit.ai\";\n\n this.segment = new Analytics({\n // eslint-disable-next-line\n writeKey: process.env.COPILOTKIT_SEGMENT_WRITE_KEY || \"n7XAZtQCGS2v1vvBy3LgBCv2h3Y8whja\",\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.segment) {\n return;\n }\n\n const flattenedProperties = flattenObject(properties);\n const propertiesWithGlobal = {\n ...this.globalProperties,\n ...flattenedProperties,\n };\n const orderedPropertiesWithGlobal = Object.keys(propertiesWithGlobal)\n .sort()\n .reduce(\n (obj, key) => {\n obj[key] = propertiesWithGlobal[key];\n return obj;\n },\n {} as Record<string, any>,\n );\n\n this.segment.track({\n anonymousId: this.anonymousId,\n event,\n properties: { ...orderedPropertiesWithGlobal },\n });\n }\n\n 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 setGlobalProperties(properties: Record<string, any>) {\n const flattenedProperties = flattenObject(properties);\n this.globalProperties = { ...this.globalProperties, ...flattenedProperties };\n }\n\n setCloudConfiguration(properties: { publicApiKey: string; baseUrl: string }) {\n this.cloudConfiguration = properties;\n\n this.setGlobalProperties({\n cloud: {\n publicApiKey: properties.publicApiKey,\n baseUrl: properties.baseUrl,\n },\n });\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 0.05;\n\n // eslint-disable-next-line\n if (process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n // eslint-disable-next-line\n _sampleRate = parseFloat(process.env.COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n if (_sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n this.setGlobalProperties({\n sampleRate: this.sampleRate,\n sampleRateAdjustmentFactor: 1 - this.sampleRate,\n });\n }\n}\n","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;AAAA;AAAA;AAAA;AAAA;;;ACsCO,SAAS,6BAA6B,kBAA2C;AAEtF,MAAI,aAAqC,CAAC;AAC1C,WAAS,aAAa,oBAAoB,CAAC,GAAG;AAC5C,eAAW,UAAU,IAAI,IAAI,iBAAiB,SAAS;AAAA,EACzD;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,oBAAoB,CAAC,GAAG;AACtC,QAAI,IAAI,aAAa,OAAO;AAC1B,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AACF;AAEA,SAAS,iBAAiB,WAAkC;AA5D5D;AA6DE,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACH,aAAO;AAA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AK,8BAA8B,KAAK;AAE9G,UAAM,WAAW,MAAM,MAAM,GAAG;AAEhC,QAAI,CAAC,SAAS,IAAI;AAChB;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,SAAS,KAAK;AACnC,UAAM,EAAE,UAAU,SAAS,IAAI;AAE/B,QAAI,CAAC,aAAa,aAAa,SAAS,aAAa,SAAS;AAC5D;AAAA,IACF;AAEA,wBAAoB,MAAM;AAAA,EAC5B;AAAA,EAEA,oBAAoB,YAAiC;AACnD,UAAM,sBAAsB,cAAc,UAAU;AACpD,SAAK,mBAAmB,EAAE,GAAG,KAAK,kBAAkB,GAAG,oBAAoB;AAAA,EAC7E;AAAA,EAEA,sBAAsB,YAAuD;AAC3E,SAAK,qBAAqB;AAE1B,SAAK,oBAAoB;AAAA,MACvB,OAAO;AAAA,QACL,cAAc,WAAW;AAAA,QACzB,SAAS,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,YAAgC;AACpD,QAAI;AAEJ,kBAAc,cAAc;AAG5B,QAAI,QAAQ,IAAI,kCAAkC;AAEhD,oBAAc,WAAW,QAAQ,IAAI,gCAAgC;AAAA,IACvE;AAEA,QAAI,cAAc,KAAK,cAAc,GAAG;AACtC,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAEA,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,4BAA4B,IAAI,KAAK;AAAA,IACvC,CAAC;AAAA,EACH;AACF;","names":["chalk"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import "./chunk-DE5K76I2.mjs";
|
|
2
2
|
import "./chunk-MSUB6DGR.mjs";
|
|
3
3
|
import "./chunk-IAFBVORQ.mjs";
|
|
4
|
-
import "./chunk-
|
|
4
|
+
import "./chunk-CYDWEPFL.mjs";
|
|
5
5
|
import {
|
|
6
6
|
actionParametersToJsonSchema
|
|
7
7
|
} from "./chunk-CIPF7PMC.mjs";
|
|
8
|
+
import {
|
|
9
|
+
randomId
|
|
10
|
+
} from "./chunk-6P6F44JQ.mjs";
|
|
8
11
|
import {
|
|
9
12
|
COPILOT_CLOUD_API_URL,
|
|
10
13
|
COPILOT_CLOUD_CHAT_URL,
|
|
@@ -23,6 +26,7 @@ export {
|
|
|
23
26
|
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
24
27
|
COPILOT_CLOUD_VERSION,
|
|
25
28
|
TelemetryClient,
|
|
26
|
-
actionParametersToJsonSchema
|
|
29
|
+
actionParametersToJsonSchema,
|
|
30
|
+
randomId
|
|
27
31
|
};
|
|
28
32
|
//# sourceMappingURL=index.mjs.map
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/utils/index.ts
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
-
actionParametersToJsonSchema: () => actionParametersToJsonSchema
|
|
23
|
+
actionParametersToJsonSchema: () => actionParametersToJsonSchema,
|
|
24
|
+
randomId: () => randomId
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(utils_exports);
|
|
26
27
|
|
|
@@ -99,8 +100,14 @@ function convertAttribute(attribute) {
|
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
|
|
104
|
+
// src/utils/random-id.ts
|
|
105
|
+
function randomId() {
|
|
106
|
+
return "ck-" + globalThis.crypto.randomUUID();
|
|
107
|
+
}
|
|
102
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
109
|
0 && (module.exports = {
|
|
104
|
-
actionParametersToJsonSchema
|
|
110
|
+
actionParametersToJsonSchema,
|
|
111
|
+
randomId
|
|
105
112
|
});
|
|
106
113
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts","../../src/utils/json-schema.ts"],"sourcesContent":["export * from \"./json-schema\";\n","import { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsCO,SAAS,6BAA6B,kBAA2C;AAEtF,MAAI,aAAqC,CAAC;AAC1C,WAAS,aAAa,oBAAoB,CAAC,GAAG;AAC5C,eAAW,UAAU,IAAI,IAAI,iBAAiB,SAAS;AAAA,EACzD;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,oBAAoB,CAAC,GAAG;AACtC,QAAI,IAAI,aAAa,OAAO;AAC1B,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AACF;AAEA,SAAS,iBAAiB,WAAkC;AA5D5D;AA6DE,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,QACvB,GAAI,UAAU,QAAQ,EAAE,MAAM,UAAU,KAAK;AAAA,MAC/C;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,QACL,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,MACzB;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,YAAM,cAAa,eAAU,eAAV,mBAAsB;AAAA,QACvC,CAAC,KAAK,SAAS;AACb,cAAI,KAAK,IAAI,IAAI,iBAAiB,IAAI;AACtC,iBAAO;AAAA,QACT;AAAA,QACA,CAAC;AAAA;AAEH,YAAM,YAAW,eAAU,eAAV,mBACb,OAAO,CAAC,SAAS,KAAK,aAAa,OACpC,IAAI,CAAC,SAAS,KAAK;AACtB,UAAI,UAAU,SAAS,YAAY;AACjC,eAAO;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,YACL,MAAM;AAAA,YACN,GAAI,cAAc,EAAE,WAAW;AAAA,YAC/B,GAAI,YAAY,SAAS,SAAS,KAAK,EAAE,SAAS;AAAA,UACpD;AAAA,UACA,aAAa,UAAU;AAAA,QACzB;AAAA,MACF;AACA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,QACvB,GAAI,cAAc,EAAE,WAAW;AAAA,QAC/B,GAAI,YAAY,SAAS,SAAS,KAAK,EAAE,SAAS;AAAA,MACpD;AAAA,IACF;AAEE,WAAI,eAAU,SAAV,mBAAgB,SAAS,OAAO;AAClC,cAAM,WAAW,UAAU,KAAK,MAAM,GAAG,EAAE;AAC3C,eAAO;AAAA,UACL,MAAM;AAAA,UACN,OAAO,EAAE,MAAM,SAAgB;AAAA,UAC/B,aAAa,UAAU;AAAA,QACzB;AAAA,MACF;AAEA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,MACzB;AAAA,EACJ;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts","../../src/utils/json-schema.ts","../../src/utils/random-id.ts"],"sourcesContent":["export * from \"./json-schema\";\nexport * from \"./random-id\";\n","import { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n","export function randomId() {\n return \"ck-\" + globalThis.crypto.randomUUID();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAA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zB;AAAA,MACF;AACA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,QACvB,GAAI,cAAc,EAAE,WAAW;AAAA,QAC/B,GAAI,YAAY,SAAS,SAAS,KAAK,EAAE,SAAS;AAAA,MACpD;AAAA,IACF;AAEE,WAAI,eAAU,SAAV,mBAAgB,SAAS,OAAO;AAClC,cAAM,WAAW,UAAU,KAAK,MAAM,GAAG,EAAE;AAC3C,eAAO;AAAA,UACL,MAAM;AAAA,UACN,OAAO,EAAE,MAAM,SAAgB;AAAA,UAC/B,aAAa,UAAU;AAAA,QACzB;AAAA,MACF;AAEA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,MACzB;AAAA,EACJ;AACF;;;ACvHO,SAAS,WAAW;AACzB,SAAO,QAAQ,WAAW,OAAO,WAAW;AAC9C;","names":[]}
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-CYDWEPFL.mjs";
|
|
2
2
|
import {
|
|
3
3
|
actionParametersToJsonSchema
|
|
4
4
|
} from "../chunk-CIPF7PMC.mjs";
|
|
5
|
+
import {
|
|
6
|
+
randomId
|
|
7
|
+
} from "../chunk-6P6F44JQ.mjs";
|
|
5
8
|
export {
|
|
6
|
-
actionParametersToJsonSchema
|
|
9
|
+
actionParametersToJsonSchema,
|
|
10
|
+
randomId
|
|
7
11
|
};
|
|
8
12
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,33 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/random-id.ts
|
|
21
|
+
var random_id_exports = {};
|
|
22
|
+
__export(random_id_exports, {
|
|
23
|
+
randomId: () => randomId
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(random_id_exports);
|
|
26
|
+
function randomId() {
|
|
27
|
+
return "ck-" + globalThis.crypto.randomUUID();
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
randomId
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=random-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/random-id.ts"],"sourcesContent":["export function randomId() {\n return \"ck-\" + globalThis.crypto.randomUUID();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,WAAW;AACzB,SAAO,QAAQ,WAAW,OAAO,WAAW;AAC9C;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/shared",
|
|
3
3
|
"private": false,
|
|
4
|
+
"homepage": "https://github.com/CopilotKit/CopilotKit",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/CopilotKit/CopilotKit.git"
|
|
8
|
+
},
|
|
4
9
|
"publishConfig": {
|
|
5
10
|
"access": "public"
|
|
6
11
|
},
|
|
7
|
-
"version": "1.0.
|
|
12
|
+
"version": "1.0.4",
|
|
8
13
|
"sideEffects": false,
|
|
9
14
|
"main": "./dist/index.js",
|
|
10
15
|
"module": "./dist/index.mjs",
|
|
@@ -24,13 +29,25 @@
|
|
|
24
29
|
"ts-jest": "^29.1.1",
|
|
25
30
|
"tsup": "^6.7.0",
|
|
26
31
|
"typescript": "^5.2.3",
|
|
27
|
-
"eslint-config-custom": "1.0.
|
|
28
|
-
"tsconfig": "1.0.
|
|
32
|
+
"eslint-config-custom": "1.0.1",
|
|
33
|
+
"tsconfig": "1.0.1"
|
|
29
34
|
},
|
|
30
35
|
"dependencies": {
|
|
31
36
|
"@segment/analytics-node": "^2.1.2",
|
|
32
37
|
"chalk": "4.1.2"
|
|
33
38
|
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"copilotkit",
|
|
41
|
+
"copilot",
|
|
42
|
+
"react",
|
|
43
|
+
"nextjs",
|
|
44
|
+
"nodejs",
|
|
45
|
+
"ai",
|
|
46
|
+
"assistant",
|
|
47
|
+
"javascript",
|
|
48
|
+
"automation",
|
|
49
|
+
"textarea"
|
|
50
|
+
],
|
|
34
51
|
"scripts": {
|
|
35
52
|
"build": "tsup --clean",
|
|
36
53
|
"dev": "tsup --watch --no-splitting",
|
package/src/utils/index.ts
CHANGED
package/dist/chunk-YJLRG5U3.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-YJLRG5U3.mjs.map
|
|
File without changes
|