@copilotkit/react-core 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.
Files changed (53) hide show
  1. package/.turbo/turbo-build.log +51 -51
  2. package/CHANGELOG.md +18 -0
  3. package/README.md +51 -0
  4. package/dist/{chunk-SSQGTCDU.mjs → chunk-4VV74HGR.mjs} +2 -2
  5. package/dist/{chunk-YULKJPY3.mjs → chunk-5FHSUKQL.mjs} +3 -3
  6. package/dist/chunk-5FHSUKQL.mjs.map +1 -0
  7. package/dist/{chunk-YWITCRBI.mjs → chunk-6U3UH3KO.mjs} +3 -3
  8. package/dist/chunk-6U3UH3KO.mjs.map +1 -0
  9. package/dist/{chunk-UTRWUF3Y.mjs → chunk-7YM7LT2G.mjs} +2 -2
  10. package/dist/{chunk-UJNVZO2U.mjs → chunk-CN5BIUCY.mjs} +2 -2
  11. package/dist/{chunk-UMJ5P6TZ.mjs → chunk-CSUYHSF7.mjs} +3 -3
  12. package/dist/chunk-CSUYHSF7.mjs.map +1 -0
  13. package/dist/{chunk-LYC2GBBA.mjs → chunk-KBHWHMQC.mjs} +3 -3
  14. package/dist/components/copilot-provider/copilotkit.js +6 -6
  15. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  16. package/dist/components/copilot-provider/copilotkit.mjs +3 -3
  17. package/dist/components/copilot-provider/index.js +6 -6
  18. package/dist/components/copilot-provider/index.js.map +1 -1
  19. package/dist/components/copilot-provider/index.mjs +3 -3
  20. package/dist/components/index.js +6 -6
  21. package/dist/components/index.js.map +1 -1
  22. package/dist/components/index.mjs +3 -3
  23. package/dist/hooks/index.js +2 -2
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/hooks/index.mjs +5 -5
  26. package/dist/hooks/use-copilot-action.js +2 -2
  27. package/dist/hooks/use-copilot-action.js.map +1 -1
  28. package/dist/hooks/use-copilot-action.mjs +1 -1
  29. package/dist/hooks/use-copilot-chat.mjs +4 -4
  30. package/dist/hooks/use-flat-category-store.js +2 -2
  31. package/dist/hooks/use-flat-category-store.js.map +1 -1
  32. package/dist/hooks/use-flat-category-store.mjs +1 -1
  33. package/dist/hooks/use-tree.js +2 -2
  34. package/dist/hooks/use-tree.js.map +1 -1
  35. package/dist/hooks/use-tree.mjs +1 -1
  36. package/dist/index.js +16 -16
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +7 -7
  39. package/dist/lib/copilot-task.mjs +4 -4
  40. package/dist/lib/index.mjs +4 -4
  41. package/dist/utils/extract.mjs +4 -4
  42. package/dist/utils/index.mjs +4 -4
  43. package/package.json +22 -6
  44. package/src/hooks/use-copilot-action.ts +2 -3
  45. package/src/hooks/use-flat-category-store.ts +2 -2
  46. package/src/hooks/use-tree.ts +2 -2
  47. package/dist/chunk-UMJ5P6TZ.mjs.map +0 -1
  48. package/dist/chunk-YULKJPY3.mjs.map +0 -1
  49. package/dist/chunk-YWITCRBI.mjs.map +0 -1
  50. /package/dist/{chunk-SSQGTCDU.mjs.map → chunk-4VV74HGR.mjs.map} +0 -0
  51. /package/dist/{chunk-UTRWUF3Y.mjs.map → chunk-7YM7LT2G.mjs.map} +0 -0
  52. /package/dist/{chunk-UJNVZO2U.mjs.map → chunk-CN5BIUCY.mjs.map} +0 -0
  53. /package/dist/{chunk-LYC2GBBA.mjs.map → chunk-KBHWHMQC.mjs.map} +0 -0
@@ -1,8 +1,8 @@
1
1
 
2
- > @copilotkit/react-core@1.0.2 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-core
2
+ > @copilotkit/react-core@1.0.4 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-core
3
3
  > tsup --clean
4
4
 
5
- CLI Building entry: src/index.tsx, src/context/copilot-context.tsx, src/context/index.ts, src/components/index.ts, src/hooks/index.ts, src/hooks/use-chat.ts, src/hooks/use-copilot-action.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-copilot-readable.ts, src/hooks/use-flat-category-store.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-tree.ts, src/lib/copilot-task.ts, src/lib/index.ts, src/types/chat-suggestion-configuration.ts, src/types/document-pointer.ts, src/types/frontend-action.ts, src/types/index.ts, src/types/system-message.ts, src/utils/extract.ts, src/utils/index.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/components/copilot-provider/copilotkit-props.tsx, src/components/copilot-provider/copilotkit.tsx, src/components/copilot-provider/index.ts
5
+ CLI Building entry: src/index.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-chat.ts, src/hooks/use-copilot-action.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-copilot-readable.ts, src/hooks/use-flat-category-store.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-tree.ts, src/lib/copilot-task.ts, src/lib/index.ts, src/types/chat-suggestion-configuration.ts, src/types/document-pointer.ts, src/types/frontend-action.ts, src/types/index.ts, src/types/system-message.ts, src/utils/extract.ts, src/utils/index.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/components/copilot-provider/copilotkit-props.tsx, src/components/copilot-provider/copilotkit.tsx, src/components/copilot-provider/index.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/react-core/tsup.config.ts
@@ -14,79 +14,79 @@
14
14
  CJS dist/types/chat-suggestion-configuration.js 893.00 B
15
15
  CJS dist/utils/extract.js 6.85 KB
16
16
  CJS dist/components/copilot-provider/copilotkit-props.js 864.00 B
17
- CJS dist/index.js 37.70 KB
17
+ CJS dist/index.js 37.75 KB
18
+ CJS dist/components/index.js 16.32 KB
18
19
  CJS dist/context/copilot-context.js 3.77 KB
19
20
  CJS dist/context/index.js 3.76 KB
20
- CJS dist/components/index.js 16.29 KB
21
- CJS dist/hooks/index.js 17.96 KB
21
+ CJS dist/hooks/index.js 17.97 KB
22
22
  CJS dist/hooks/use-chat.js 9.36 KB
23
- CJS dist/hooks/use-copilot-action.js 5.03 KB
23
+ CJS dist/hooks/use-copilot-action.js 5.04 KB
24
24
  CJS dist/hooks/use-copilot-chat.js 15.08 KB
25
25
  CJS dist/hooks/use-copilot-readable.js 4.48 KB
26
- CJS dist/hooks/use-flat-category-store.js 2.87 KB
26
+ CJS dist/hooks/use-flat-category-store.js 2.88 KB
27
27
  CJS dist/hooks/use-make-copilot-document-readable.js 4.37 KB
28
- CJS dist/hooks/use-tree.js 5.53 KB
28
+ CJS dist/hooks/use-tree.js 5.54 KB
29
29
  CJS dist/lib/index.js 5.54 KB
30
30
  CJS dist/types/document-pointer.js 841.00 B
31
- CJS dist/types/index.js 797.00 B
32
31
  CJS dist/types/frontend-action.js 837.00 B
32
+ CJS dist/types/index.js 797.00 B
33
33
  CJS dist/types/system-message.js 833.00 B
34
+ CJS dist/utils/index.js 6.87 KB
34
35
  CJS dist/utils/utils.test.js 184.00 B
35
36
  CJS dist/utils/utils.js 797.00 B
36
- CJS dist/components/copilot-provider/copilotkit.js 16.27 KB
37
- CJS dist/components/copilot-provider/index.js 16.33 KB
38
- CJS dist/utils/index.js 6.87 KB
37
+ CJS dist/components/copilot-provider/index.js 16.36 KB
38
+ CJS dist/components/copilot-provider/copilotkit.js 16.30 KB
39
39
  CJS dist/lib/copilot-task.js.map 16.69 KB
40
40
  CJS dist/types/chat-suggestion-configuration.js.map 673.00 B
41
41
  CJS dist/utils/extract.js.map 15.33 KB
42
42
  CJS dist/components/copilot-provider/copilotkit-props.js.map 1.68 KB
43
+ CJS dist/components/index.js.map 29.46 KB
43
44
  CJS dist/context/copilot-context.js.map 6.03 KB
44
- CJS dist/index.js.map 77.19 KB
45
45
  CJS dist/context/index.js.map 6.26 KB
46
- CJS dist/components/index.js.map 29.41 KB
47
- CJS dist/hooks/use-chat.js.map 13.33 KB
48
46
  CJS dist/hooks/index.js.map 45.17 KB
49
- CJS dist/hooks/use-copilot-action.js.map 10.14 KB
50
- CJS dist/hooks/use-copilot-chat.js.map 34.08 KB
51
- CJS dist/hooks/use-flat-category-store.js.map 4.25 KB
47
+ CJS dist/index.js.map 77.22 KB
48
+ CJS dist/hooks/use-chat.js.map 13.33 KB
49
+ CJS dist/hooks/use-copilot-action.js.map 10.12 KB
52
50
  CJS dist/hooks/use-copilot-readable.js.map 11.07 KB
51
+ CJS dist/hooks/use-flat-category-store.js.map 4.26 KB
52
+ CJS dist/hooks/use-copilot-chat.js.map 34.08 KB
53
53
  CJS dist/hooks/use-make-copilot-document-readable.js.map 7.32 KB
54
- CJS dist/hooks/use-tree.js.map 8.32 KB
54
+ CJS dist/hooks/use-tree.js.map 8.33 KB
55
55
  CJS dist/lib/index.js.map 16.76 KB
56
56
  CJS dist/types/document-pointer.js.map 292.00 B
57
57
  CJS dist/types/index.js.map 432.00 B
58
58
  CJS dist/types/frontend-action.js.map 1.77 KB
59
59
  CJS dist/types/system-message.js.map 249.00 B
60
+ CJS dist/utils/index.js.map 15.40 KB
60
61
  CJS dist/utils/utils.test.js.map 354.00 B
61
62
  CJS dist/utils/utils.js.map 137.00 B
62
- CJS dist/components/copilot-provider/copilotkit.js.map 29.35 KB
63
- CJS dist/components/copilot-provider/index.js.map 29.54 KB
64
- CJS dist/utils/index.js.map 15.40 KB
65
- CJS ⚡️ Build success in 88ms
63
+ CJS dist/components/copilot-provider/index.js.map 29.59 KB
64
+ CJS dist/components/copilot-provider/copilotkit.js.map 29.40 KB
65
+ CJS ⚡️ Build success in 89ms
66
66
  ESM dist/index.mjs 1.10 KB
67
- ESM dist/context/copilot-context.mjs 205.00 B
68
67
  ESM dist/components/index.mjs 375.00 B
68
+ ESM dist/context/copilot-context.mjs 205.00 B
69
69
  ESM dist/hooks/index.mjs 681.00 B
70
70
  ESM dist/chunk-EFZPSZWO.mjs 43.00 B
71
71
  ESM dist/chunk-YJLRG5U3.mjs 43.00 B
72
- ESM dist/chunk-UTRWUF3Y.mjs 4.51 KB
72
+ ESM dist/chunk-7YM7LT2G.mjs 4.51 KB
73
73
  ESM dist/chunk-LUGEI4YQ.mjs 43.00 B
74
- ESM dist/chunk-SSQGTCDU.mjs 3.80 KB
74
+ ESM dist/chunk-4VV74HGR.mjs 3.80 KB
75
75
  ESM dist/context/index.mjs 227.00 B
76
76
  ESM dist/chunk-VNRDQJXW.mjs 43.00 B
77
77
  ESM dist/chunk-5JB4B2SV.mjs 43.00 B
78
78
  ESM dist/chunk-2RZ2UMWO.mjs 909.00 B
79
79
  ESM dist/chunk-TWFVVCRS.mjs 700.00 B
80
80
  ESM dist/hooks/use-chat.mjs 142.00 B
81
- ESM dist/chunk-UMJ5P6TZ.mjs 1.42 KB
82
81
  ESM dist/hooks/use-copilot-action.mjs 202.00 B
82
+ ESM dist/chunk-CSUYHSF7.mjs 1.44 KB
83
83
  ESM dist/hooks/use-copilot-chat.mjs 436.00 B
84
- ESM dist/chunk-UJNVZO2U.mjs 3.12 KB
85
- ESM dist/chunk-SPCZTZCY.mjs 43.00 B
84
+ ESM dist/chunk-CN5BIUCY.mjs 3.12 KB
86
85
  ESM dist/chunk-JD7BAH7U.mjs 43.00 B
87
- ESM dist/chunk-LYC2GBBA.mjs 5.67 KB
88
- ESM dist/chunk-YULKJPY3.mjs 1.84 KB
89
- ESM dist/chunk-YWITCRBI.mjs 3.89 KB
86
+ ESM dist/chunk-SPCZTZCY.mjs 43.00 B
87
+ ESM dist/chunk-KBHWHMQC.mjs 5.67 KB
88
+ ESM dist/chunk-5FHSUKQL.mjs 1.86 KB
89
+ ESM dist/chunk-6U3UH3KO.mjs 3.91 KB
90
90
  ESM dist/chunk-S357AOAD.mjs 6.93 KB
91
91
  ESM dist/chunk-2F7V4NDT.mjs 1.59 KB
92
92
  ESM dist/chunk-SKC7AJIV.mjs 1.97 KB
@@ -96,66 +96,66 @@
96
96
  ESM dist/types/index.mjs 66.00 B
97
97
  ESM dist/utils/extract.mjs 333.00 B
98
98
  ESM dist/utils/index.mjs 363.00 B
99
- ESM dist/types/system-message.mjs 43.00 B
100
99
  ESM dist/utils/utils.test.mjs 170.00 B
101
100
  ESM dist/utils/utils.mjs 34.00 B
102
101
  ESM dist/components/copilot-provider/copilotkit-props.mjs 45.00 B
103
102
  ESM dist/hooks/use-copilot-readable.mjs 208.00 B
104
103
  ESM dist/hooks/use-flat-category-store.mjs 216.00 B
104
+ ESM dist/types/system-message.mjs 43.00 B
105
105
  ESM dist/hooks/use-make-copilot-document-readable.mjs 246.00 B
106
106
  ESM dist/hooks/use-tree.mjs 171.00 B
107
107
  ESM dist/lib/copilot-task.mjs 346.00 B
108
- ESM dist/types/chat-suggestion-configuration.mjs 58.00 B
109
108
  ESM dist/lib/index.mjs 371.00 B
109
+ ESM dist/types/chat-suggestion-configuration.mjs 58.00 B
110
110
  ESM dist/types/document-pointer.mjs 45.00 B
111
111
  ESM dist/index.mjs.map 71.00 B
112
- ESM dist/context/copilot-context.mjs.map 71.00 B
113
112
  ESM dist/components/index.mjs.map 71.00 B
113
+ ESM dist/context/copilot-context.mjs.map 71.00 B
114
114
  ESM dist/hooks/index.mjs.map 71.00 B
115
115
  ESM dist/chunk-EFZPSZWO.mjs.map 71.00 B
116
116
  ESM dist/chunk-YJLRG5U3.mjs.map 71.00 B
117
- ESM dist/chunk-UTRWUF3Y.mjs.map 7.64 KB
117
+ ESM dist/chunk-7YM7LT2G.mjs.map 7.64 KB
118
118
  ESM dist/chunk-LUGEI4YQ.mjs.map 71.00 B
119
- ESM dist/chunk-SSQGTCDU.mjs.map 9.04 KB
119
+ ESM dist/chunk-4VV74HGR.mjs.map 9.04 KB
120
120
  ESM dist/context/index.mjs.map 71.00 B
121
121
  ESM dist/chunk-VNRDQJXW.mjs.map 71.00 B
122
122
  ESM dist/chunk-5JB4B2SV.mjs.map 71.00 B
123
123
  ESM dist/chunk-2RZ2UMWO.mjs.map 5.15 KB
124
124
  ESM dist/chunk-TWFVVCRS.mjs.map 1.40 KB
125
- ESM dist/hooks/use-chat.mjs.map 71.00 B
126
- ESM dist/chunk-UMJ5P6TZ.mjs.map 4.22 KB
127
125
  ESM dist/hooks/use-copilot-action.mjs.map 71.00 B
126
+ ESM dist/hooks/use-chat.mjs.map 71.00 B
127
+ ESM dist/chunk-CSUYHSF7.mjs.map 4.20 KB
128
+ ESM dist/chunk-CN5BIUCY.mjs.map 7.22 KB
128
129
  ESM dist/hooks/use-copilot-chat.mjs.map 71.00 B
129
- ESM dist/chunk-UJNVZO2U.mjs.map 7.22 KB
130
- ESM dist/chunk-SPCZTZCY.mjs.map 71.00 B
131
130
  ESM dist/chunk-JD7BAH7U.mjs.map 71.00 B
132
- ESM dist/chunk-LYC2GBBA.mjs.map 10.98 KB
133
- ESM dist/chunk-YULKJPY3.mjs.map 4.21 KB
134
- ESM dist/chunk-YWITCRBI.mjs.map 8.27 KB
131
+ ESM dist/chunk-SPCZTZCY.mjs.map 71.00 B
132
+ ESM dist/chunk-KBHWHMQC.mjs.map 10.98 KB
133
+ ESM dist/chunk-5FHSUKQL.mjs.map 4.22 KB
134
+ ESM dist/chunk-6U3UH3KO.mjs.map 8.28 KB
135
135
  ESM dist/chunk-S357AOAD.mjs.map 13.37 KB
136
136
  ESM dist/chunk-2F7V4NDT.mjs.map 5.94 KB
137
137
  ESM dist/chunk-SKC7AJIV.mjs.map 71.00 B
138
- ESM dist/components/copilot-provider/copilotkit.mjs.map 71.00 B
139
138
  ESM dist/components/copilot-provider/index.mjs.map 71.00 B
140
139
  ESM dist/types/frontend-action.mjs.map 71.00 B
140
+ ESM dist/components/copilot-provider/copilotkit.mjs.map 71.00 B
141
141
  ESM dist/types/index.mjs.map 71.00 B
142
142
  ESM dist/utils/extract.mjs.map 71.00 B
143
143
  ESM dist/utils/index.mjs.map 71.00 B
144
- ESM dist/types/system-message.mjs.map 71.00 B
145
144
  ESM dist/utils/utils.test.mjs.map 352.00 B
146
- ESM dist/components/copilot-provider/copilotkit-props.mjs.map 71.00 B
147
145
  ESM dist/utils/utils.mjs.map 71.00 B
146
+ ESM dist/components/copilot-provider/copilotkit-props.mjs.map 71.00 B
148
147
  ESM dist/hooks/use-copilot-readable.mjs.map 71.00 B
149
148
  ESM dist/hooks/use-flat-category-store.mjs.map 71.00 B
149
+ ESM dist/types/system-message.mjs.map 71.00 B
150
150
  ESM dist/hooks/use-make-copilot-document-readable.mjs.map 71.00 B
151
151
  ESM dist/hooks/use-tree.mjs.map 71.00 B
152
+ ESM dist/lib/index.mjs.map 71.00 B
152
153
  ESM dist/lib/copilot-task.mjs.map 71.00 B
153
154
  ESM dist/types/chat-suggestion-configuration.mjs.map 71.00 B
154
- ESM dist/lib/index.mjs.map 71.00 B
155
155
  ESM dist/types/document-pointer.mjs.map 71.00 B
156
- ESM ⚡️ Build success in 92ms
156
+ ESM ⚡️ Build success in 94ms
157
157
  DTS Build start
158
- DTS ⚡️ Build success in 5275ms
158
+ DTS ⚡️ Build success in 5310ms
159
159
  DTS dist/index.d.ts 1.22 KB
160
160
  DTS dist/components/copilot-provider/copilotkit.d.ts 271.00 B
161
161
  DTS dist/components/copilot-provider/copilotkit-props.d.ts 1.58 KB
@@ -172,8 +172,8 @@
172
172
  DTS dist/lib/copilot-task.d.ts 3.81 KB
173
173
  DTS dist/utils/extract.d.ts 1.44 KB
174
174
  DTS dist/hooks/use-tree.d.ts 543.00 B
175
- DTS dist/context/index.d.ts 360.00 B
176
175
  DTS dist/components/index.d.ts 186.00 B
176
+ DTS dist/context/index.d.ts 360.00 B
177
177
  DTS dist/hooks/index.d.ts 679.00 B
178
178
  DTS dist/hooks/use-flat-category-store.d.ts 424.00 B
179
179
  DTS dist/lib/index.d.ts 354.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # ui
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Remove nanoid
8
+ - Updated dependencies
9
+ - @copilotkit/runtime-client-gql@1.0.4
10
+ - @copilotkit/shared@1.0.4
11
+
12
+ ## 1.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Add README.md to published packages and add keywords to package.json
17
+ - Updated dependencies
18
+ - @copilotkit/runtime-client-gql@1.0.3
19
+ - @copilotkit/shared@1.0.3
20
+
3
21
  ## 1.0.2
4
22
 
5
23
  ### Patch Changes
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
+ &nbsp;&middot;&nbsp;
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
+ &nbsp;&middot;&nbsp;
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).
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-LYC2GBBA.mjs";
3
+ } from "./chunk-KBHWHMQC.mjs";
4
4
  import {
5
5
  __async
6
6
  } from "./chunk-SKC7AJIV.mjs";
@@ -111,4 +111,4 @@ ${instructions}
111
111
  export {
112
112
  CopilotTask
113
113
  };
114
- //# sourceMappingURL=chunk-SSQGTCDU.mjs.map
114
+ //# sourceMappingURL=chunk-4VV74HGR.mjs.map
@@ -1,10 +1,10 @@
1
1
  // src/hooks/use-flat-category-store.ts
2
- import { nanoid } from "nanoid";
3
2
  import { useCallback, useReducer } from "react";
3
+ import { randomId } from "@copilotkit/shared";
4
4
  var useFlatCategoryStore = () => {
5
5
  const [elements, dispatch] = useReducer(flatCategoryStoreReducer, /* @__PURE__ */ new Map());
6
6
  const addElement = useCallback((value, categories) => {
7
- const newId = nanoid();
7
+ const newId = randomId();
8
8
  dispatch({
9
9
  type: "ADD_ELEMENT",
10
10
  value,
@@ -67,4 +67,4 @@ function setsHaveIntersection(setA, setB) {
67
67
  export {
68
68
  use_flat_category_store_default
69
69
  };
70
- //# sourceMappingURL=chunk-YULKJPY3.mjs.map
70
+ //# sourceMappingURL=chunk-5FHSUKQL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-flat-category-store.ts"],"sourcesContent":["import { useCallback, useReducer } from \"react\";\nimport { randomId } from \"@copilotkit/shared\";\n\nexport type FlatCategoryStoreId = string;\n\nexport interface UseFlatCategoryStoreReturn<T> {\n addElement: (value: T, categories: string[]) => FlatCategoryStoreId;\n removeElement: (id: FlatCategoryStoreId) => void;\n allElements: (categories: string[]) => T[];\n}\n\ninterface FlatCategoryStoreElement<T> {\n id: FlatCategoryStoreId;\n value: T;\n categories: Set<string>;\n}\n\nconst useFlatCategoryStore = <T>(): UseFlatCategoryStoreReturn<T> => {\n const [elements, dispatch] = useReducer<\n React.Reducer<Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>, Action<T>>\n >(flatCategoryStoreReducer, new Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>());\n\n const addElement = useCallback((value: T, categories: string[]): FlatCategoryStoreId => {\n const newId = randomId();\n dispatch({\n type: \"ADD_ELEMENT\",\n value,\n id: newId,\n categories,\n });\n return newId;\n }, []);\n\n const removeElement = useCallback((id: FlatCategoryStoreId): void => {\n dispatch({ type: \"REMOVE_ELEMENT\", id });\n }, []);\n\n const allElements = useCallback(\n (categories: string[]): T[] => {\n const categoriesSet = new Set(categories);\n const result: T[] = [];\n elements.forEach((element) => {\n if (setsHaveIntersection(categoriesSet, element.categories)) {\n result.push(element.value);\n }\n });\n return result;\n },\n [elements],\n );\n\n return { addElement, removeElement, allElements };\n};\n\nexport default useFlatCategoryStore;\n\n// Action types\ntype Action<T> =\n | {\n type: \"ADD_ELEMENT\";\n value: T;\n id: FlatCategoryStoreId;\n categories: string[];\n }\n | { type: \"REMOVE_ELEMENT\"; id: FlatCategoryStoreId };\n\n// Reducer\nfunction flatCategoryStoreReducer<T>(\n state: Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>,\n action: Action<T>,\n): Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>> {\n switch (action.type) {\n case \"ADD_ELEMENT\": {\n const { value, id, categories } = action;\n const newElement: FlatCategoryStoreElement<T> = {\n id,\n value,\n categories: new Set(categories),\n };\n const newState = new Map(state);\n newState.set(id, newElement);\n return newState;\n }\n case \"REMOVE_ELEMENT\": {\n const newState = new Map(state);\n newState.delete(action.id);\n return newState;\n }\n default:\n return state;\n }\n}\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";AAAA,SAAS,aAAa,kBAAkB;AACxC,SAAS,gBAAgB;AAgBzB,IAAM,uBAAuB,MAAwC;AACnE,QAAM,CAAC,UAAU,QAAQ,IAAI,WAE3B,0BAA0B,oBAAI,IAAsD,CAAC;AAEvF,QAAM,aAAa,YAAY,CAAC,OAAU,eAA8C;AACtF,UAAM,QAAQ,SAAS;AACvB,aAAS;AAAA,MACP,MAAM;AAAA,MACN;AAAA,MACA,IAAI;AAAA,MACJ;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,YAAY,CAAC,OAAkC;AACnE,aAAS,EAAE,MAAM,kBAAkB,GAAG,CAAC;AAAA,EACzC,GAAG,CAAC,CAAC;AAEL,QAAM,cAAc;AAAA,IAClB,CAAC,eAA8B;AAC7B,YAAM,gBAAgB,IAAI,IAAI,UAAU;AACxC,YAAM,SAAc,CAAC;AACrB,eAAS,QAAQ,CAAC,YAAY;AAC5B,YAAI,qBAAqB,eAAe,QAAQ,UAAU,GAAG;AAC3D,iBAAO,KAAK,QAAQ,KAAK;AAAA,QAC3B;AAAA,MACF,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,SAAO,EAAE,YAAY,eAAe,YAAY;AAClD;AAEA,IAAO,kCAAQ;AAaf,SAAS,yBACP,OACA,QACuD;AACvD,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,eAAe;AAClB,YAAM,EAAE,OAAO,IAAI,WAAW,IAAI;AAClC,YAAM,aAA0C;AAAA,QAC9C;AAAA,QACA;AAAA,QACA,YAAY,IAAI,IAAI,UAAU;AAAA,MAChC;AACA,YAAM,WAAW,IAAI,IAAI,KAAK;AAC9B,eAAS,IAAI,IAAI,UAAU;AAC3B,aAAO;AAAA,IACT;AAAA,IACA,KAAK,kBAAkB;AACrB,YAAM,WAAW,IAAI,IAAI,KAAK;AAC9B,eAAS,OAAO,OAAO,EAAE;AACzB,aAAO;AAAA,IACT;AAAA,IACA;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,qBAAwB,MAAc,MAAuB;AACpE,QAAM,CAAC,YAAY,SAAS,IAAI,KAAK,QAAQ,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI;AAEnF,WAAS,QAAQ,YAAY;AAC3B,QAAI,UAAU,IAAI,IAAI,GAAG;AACvB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-SKC7AJIV.mjs";
5
5
 
6
6
  // src/hooks/use-tree.ts
7
- import { nanoid } from "nanoid";
7
+ import { randomId } from "@copilotkit/shared";
8
8
  import { useCallback, useReducer } from "react";
9
9
  var removeNode = (nodes, id) => {
10
10
  return nodes.reduce((result, node) => {
@@ -89,7 +89,7 @@ var useTree = () => {
89
89
  const [tree, dispatch] = useReducer(treeReducer, []);
90
90
  const addElement = useCallback(
91
91
  (value, categories, parentId) => {
92
- const newNodeId = nanoid();
92
+ const newNodeId = randomId();
93
93
  dispatch({
94
94
  type: "ADD_NODE",
95
95
  value,
@@ -137,4 +137,4 @@ function setsHaveIntersection(setA, setB) {
137
137
  export {
138
138
  use_tree_default
139
139
  };
140
- //# sourceMappingURL=chunk-YWITCRBI.mjs.map
140
+ //# sourceMappingURL=chunk-6U3UH3KO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-tree.ts"],"sourcesContent":["import { randomId } from \"@copilotkit/shared\";\nimport { useCallback, useReducer } from \"react\";\n\nexport type TreeNodeId = string;\n\nexport interface TreeNode {\n id: TreeNodeId;\n value: string;\n children: TreeNode[];\n parentId?: TreeNodeId;\n categories: Set<string>;\n}\n\nexport type Tree = TreeNode[];\n\nexport interface UseTreeReturn {\n tree: Tree;\n addElement: (value: string, categories: string[], parentId?: TreeNodeId) => TreeNodeId;\n printTree: (categories: string[]) => string;\n removeElement: (id: TreeNodeId) => void;\n}\n\nconst findNode = (nodes: Tree, id: TreeNodeId): TreeNode | undefined => {\n for (const node of nodes) {\n if (node.id === id) {\n return node;\n }\n const result = findNode(node.children, id);\n if (result) {\n return result;\n }\n }\n return undefined;\n};\n\nconst removeNode = (nodes: Tree, id: TreeNodeId): Tree => {\n return nodes.reduce((result: Tree, node) => {\n if (node.id !== id) {\n const newNode = { ...node, children: removeNode(node.children, id) };\n result.push(newNode);\n }\n return result;\n }, []);\n};\n\nconst addNode = (nodes: Tree, newNode: TreeNode, parentId?: TreeNodeId): Tree => {\n if (!parentId) {\n return [...nodes, newNode];\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n return { ...node, children: [...node.children, newNode] };\n } else if (node.children.length) {\n return { ...node, children: addNode(node.children, newNode, parentId) };\n }\n return node;\n });\n};\n\nconst treeIndentationRepresentation = (index: number, indentLevel: number): string => {\n if (indentLevel === 0) {\n return (index + 1).toString();\n } else if (indentLevel === 1) {\n return String.fromCharCode(65 + index); // 65 is the ASCII value for 'A'\n } else if (indentLevel === 2) {\n return String.fromCharCode(97 + index); // 97 is the ASCII value for 'a'\n } else {\n return \"-\";\n }\n};\n\nconst printNode = (node: TreeNode, prefix = \"\", indentLevel = 0): string => {\n const indent = \" \".repeat(3).repeat(indentLevel);\n\n const prefixPlusIndentLength = prefix.length + indent.length;\n const subsequentLinesPrefix = \" \".repeat(prefixPlusIndentLength);\n\n const valueLines = node.value.split(\"\\n\");\n\n const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;\n const outputSubsequentLines = valueLines\n .slice(1)\n .map((line) => `${subsequentLinesPrefix}${line}`)\n .join(\"\\n\");\n\n let output = `${outputFirstLine}\\n`;\n if (outputSubsequentLines) {\n output += `${outputSubsequentLines}\\n`;\n }\n\n const childPrePrefix = \" \".repeat(prefix.length);\n\n node.children.forEach(\n (child, index) =>\n (output += printNode(\n child,\n `${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,\n indentLevel + 1,\n )),\n );\n return output;\n};\n\n// Action types\ntype Action =\n | {\n type: \"ADD_NODE\";\n value: string;\n parentId?: string;\n id: string;\n categories: string[];\n }\n | { type: \"REMOVE_NODE\"; id: string };\n\n// Reducer function\nfunction treeReducer(state: Tree, action: Action): Tree {\n switch (action.type) {\n case \"ADD_NODE\": {\n const { value, parentId, id: newNodeId } = action;\n const newNode: TreeNode = {\n id: newNodeId,\n value,\n children: [],\n categories: new Set(action.categories),\n };\n\n try {\n return addNode(state, newNode, parentId);\n } catch (error) {\n console.error(`Error while adding node with id ${newNodeId}: ${error}`);\n return state;\n }\n }\n case \"REMOVE_NODE\":\n return removeNode(state, action.id);\n default:\n return state;\n }\n}\n\n// useTree hook\nconst useTree = (): UseTreeReturn => {\n const [tree, dispatch] = useReducer(treeReducer, []);\n\n const addElement = useCallback(\n (value: string, categories: string[], parentId?: string): TreeNodeId => {\n const newNodeId = randomId(); // Generate new ID outside of dispatch\n dispatch({\n type: \"ADD_NODE\",\n value,\n parentId,\n id: newNodeId,\n categories: categories,\n });\n return newNodeId; // Return the new ID\n },\n [],\n );\n\n const removeElement = useCallback((id: TreeNodeId): void => {\n dispatch({ type: \"REMOVE_NODE\", id });\n }, []);\n\n const printTree = useCallback(\n (categories: string[]): string => {\n const categoriesSet = new Set(categories);\n\n let output = \"\";\n tree.forEach((node, index) => {\n // if the node does not have any of the desired categories, continue to the next node\n if (!setsHaveIntersection(categoriesSet, node.categories)) {\n return;\n }\n\n // add a new line before each node except the first one\n if (index !== 0) {\n output += \"\\n\";\n }\n\n output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);\n });\n return output;\n },\n [tree],\n );\n\n return { tree, addElement, printTree, removeElement };\n};\n\nexport default useTree;\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,aAAa,kBAAkB;AAkCxC,IAAM,aAAa,CAAC,OAAa,OAAyB;AACxD,SAAO,MAAM,OAAO,CAAC,QAAc,SAAS;AAC1C,QAAI,KAAK,OAAO,IAAI;AAClB,YAAM,UAAU,iCAAK,OAAL,EAAW,UAAU,WAAW,KAAK,UAAU,EAAE,EAAE;AACnE,aAAO,KAAK,OAAO;AAAA,IACrB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;AAEA,IAAM,UAAU,CAAC,OAAa,SAAmB,aAAgC;AAC/E,MAAI,CAAC,UAAU;AACb,WAAO,CAAC,GAAG,OAAO,OAAO;AAAA,EAC3B;AACA,SAAO,MAAM,IAAI,CAAC,SAAS;AACzB,QAAI,KAAK,OAAO,UAAU;AACxB,aAAO,iCAAK,OAAL,EAAW,UAAU,CAAC,GAAG,KAAK,UAAU,OAAO,EAAE;AAAA,IAC1D,WAAW,KAAK,SAAS,QAAQ;AAC/B,aAAO,iCAAK,OAAL,EAAW,UAAU,QAAQ,KAAK,UAAU,SAAS,QAAQ,EAAE;AAAA,IACxE;AACA,WAAO;AAAA,EACT,CAAC;AACH;AAEA,IAAM,gCAAgC,CAAC,OAAe,gBAAgC;AACpF,MAAI,gBAAgB,GAAG;AACrB,YAAQ,QAAQ,GAAG,SAAS;AAAA,EAC9B,WAAW,gBAAgB,GAAG;AAC5B,WAAO,OAAO,aAAa,KAAK,KAAK;AAAA,EACvC,WAAW,gBAAgB,GAAG;AAC5B,WAAO,OAAO,aAAa,KAAK,KAAK;AAAA,EACvC,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAEA,IAAM,YAAY,CAAC,MAAgB,SAAS,IAAI,cAAc,MAAc;AAC1E,QAAM,SAAS,IAAI,OAAO,CAAC,EAAE,OAAO,WAAW;AAE/C,QAAM,yBAAyB,OAAO,SAAS,OAAO;AACtD,QAAM,wBAAwB,IAAI,OAAO,sBAAsB;AAE/D,QAAM,aAAa,KAAK,MAAM,MAAM,IAAI;AAExC,QAAM,kBAAkB,GAAG,SAAS,SAAS,WAAW,CAAC;AACzD,QAAM,wBAAwB,WAC3B,MAAM,CAAC,EACP,IAAI,CAAC,SAAS,GAAG,wBAAwB,MAAM,EAC/C,KAAK,IAAI;AAEZ,MAAI,SAAS,GAAG;AAAA;AAChB,MAAI,uBAAuB;AACzB,cAAU,GAAG;AAAA;AAAA,EACf;AAEA,QAAM,iBAAiB,IAAI,OAAO,OAAO,MAAM;AAE/C,OAAK,SAAS;AAAA,IACZ,CAAC,OAAO,UACL,UAAU;AAAA,MACT;AAAA,MACA,GAAG,iBAAiB,8BAA8B,OAAO,cAAc,CAAC;AAAA,MACxE,cAAc;AAAA,IAChB;AAAA,EACJ;AACA,SAAO;AACT;AAcA,SAAS,YAAY,OAAa,QAAsB;AACtD,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,YAAY;AACf,YAAM,EAAE,OAAO,UAAU,IAAI,UAAU,IAAI;AAC3C,YAAM,UAAoB;AAAA,QACxB,IAAI;AAAA,QACJ;AAAA,QACA,UAAU,CAAC;AAAA,QACX,YAAY,IAAI,IAAI,OAAO,UAAU;AAAA,MACvC;AAEA,UAAI;AACF,eAAO,QAAQ,OAAO,SAAS,QAAQ;AAAA,MACzC,SAAS,OAAP;AACA,gBAAQ,MAAM,mCAAmC,cAAc,OAAO;AACtE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,KAAK;AACH,aAAO,WAAW,OAAO,OAAO,EAAE;AAAA,IACpC;AACE,aAAO;AAAA,EACX;AACF;AAGA,IAAM,UAAU,MAAqB;AACnC,QAAM,CAAC,MAAM,QAAQ,IAAI,WAAW,aAAa,CAAC,CAAC;AAEnD,QAAM,aAAa;AAAA,IACjB,CAAC,OAAe,YAAsB,aAAkC;AACtE,YAAM,YAAY,SAAS;AAC3B,eAAS;AAAA,QACP,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,IAAI;AAAA,QACJ;AAAA,MACF,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,gBAAgB,YAAY,CAAC,OAAyB;AAC1D,aAAS,EAAE,MAAM,eAAe,GAAG,CAAC;AAAA,EACtC,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY;AAAA,IAChB,CAAC,eAAiC;AAChC,YAAM,gBAAgB,IAAI,IAAI,UAAU;AAExC,UAAI,SAAS;AACb,WAAK,QAAQ,CAAC,MAAM,UAAU;AAE5B,YAAI,CAAC,qBAAqB,eAAe,KAAK,UAAU,GAAG;AACzD;AAAA,QACF;AAGA,YAAI,UAAU,GAAG;AACf,oBAAU;AAAA,QACZ;AAEA,kBAAU,UAAU,MAAM,GAAG,8BAA8B,OAAO,CAAC,KAAK;AAAA,MAC1E,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AAEA,SAAO,EAAE,MAAM,YAAY,WAAW,cAAc;AACtD;AAEA,IAAO,mBAAQ;AAEf,SAAS,qBAAwB,MAAc,MAAuB;AACpE,QAAM,CAAC,YAAY,SAAS,IAAI,KAAK,QAAQ,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI;AAEnF,WAAS,QAAQ,YAAY;AAC3B,QAAI,UAAU,IAAI,IAAI,GAAG;AACvB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-LYC2GBBA.mjs";
3
+ } from "./chunk-KBHWHMQC.mjs";
4
4
  import {
5
5
  __async,
6
6
  __spreadValues
@@ -142,4 +142,4 @@ Any additional messages provided are for providing context only and should not b
142
142
  export {
143
143
  extract
144
144
  };
145
- //# sourceMappingURL=chunk-UTRWUF3Y.mjs.map
145
+ //# sourceMappingURL=chunk-7YM7LT2G.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultCopilotContextCategories
3
- } from "./chunk-LYC2GBBA.mjs";
3
+ } from "./chunk-KBHWHMQC.mjs";
4
4
  import {
5
5
  useChat
6
6
  } from "./chunk-S357AOAD.mjs";
@@ -104,4 +104,4 @@ export {
104
104
  useCopilotChat,
105
105
  defaultSystemMessage
106
106
  };
107
- //# sourceMappingURL=chunk-UJNVZO2U.mjs.map
107
+ //# sourceMappingURL=chunk-CN5BIUCY.mjs.map
@@ -4,10 +4,10 @@ import {
4
4
 
5
5
  // src/hooks/use-copilot-action.ts
6
6
  import { useRef, useContext, useEffect } from "react";
7
- import { nanoid } from "nanoid";
7
+ import { randomId } from "@copilotkit/shared";
8
8
  function useCopilotAction(action, dependencies) {
9
9
  const { setAction, removeAction, actions, chatComponentsCache } = useContext(CopilotContext);
10
- const idRef = useRef(nanoid());
10
+ const idRef = useRef(randomId());
11
11
  if (dependencies === void 0) {
12
12
  if (actions[idRef.current]) {
13
13
  actions[idRef.current].handler = action.handler;
@@ -44,4 +44,4 @@ function useCopilotAction(action, dependencies) {
44
44
  export {
45
45
  useCopilotAction
46
46
  };
47
- //# sourceMappingURL=chunk-UMJ5P6TZ.mjs.map
47
+ //# sourceMappingURL=chunk-CSUYHSF7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-action.ts"],"sourcesContent":["import { useRef, useContext, useEffect } from \"react\";\nimport { FrontendAction } from \"../types/frontend-action\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { Parameter, randomId } from \"@copilotkit/shared\";\n\n// We implement useCopilotAction dependency handling so that\n// the developer has the option to not provide any dependencies.\n// In this case, we assume they want to update the handler on each rerender.\n// To avoid getting stuck in an infinite loop, we update the handler directly,\n// skipping React state updates.\n// This is ok in this case, because the handler is not part of any UI that\n// needs to be updated.\n// useCallback, useMemo or other memoization techniques are not suitable here,\n// because they will cause a infinite rerender loop.\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T>,\n dependencies?: any[],\n): void {\n const { setAction, removeAction, actions, chatComponentsCache } = useContext(CopilotContext);\n const idRef = useRef<string>(randomId());\n\n // If the developer doesn't provide dependencies, we assume they want to\n // update handler and render function when the action object changes.\n // This ensures that any captured variables in the handler are up to date.\n if (dependencies === undefined) {\n if (actions[idRef.current]) {\n actions[idRef.current].handler = action.handler as any;\n if (typeof action.render === \"function\") {\n if (chatComponentsCache.current !== null) {\n chatComponentsCache.current[action.name] = action.render;\n }\n }\n }\n }\n\n useEffect(() => {\n setAction(idRef.current, action as any);\n if (chatComponentsCache.current !== null && action.render !== undefined) {\n chatComponentsCache.current[action.name] = action.render;\n }\n return () => {\n // NOTE: For now, we don't remove the chatComponentsCache entry when the action is removed.\n // This is because we currently don't have access to the messages array in CopilotContext.\n removeAction(idRef.current);\n };\n }, [\n setAction,\n removeAction,\n action.description,\n action.name,\n // This should be faster than deep equality checking\n // In addition, all major JS engines guarantee the order of object keys\n JSON.stringify(action.parameters),\n // include render only if it's a string\n typeof action.render === \"string\" ? action.render : undefined,\n // dependencies set by the developer\n ...(dependencies || []),\n ]);\n}\n\n// Usage Example:\n// useCopilotAction({\n// name: \"myAction\",\n// parameters: [\n// { name: \"arg1\", type: \"string\", enum: [\"option1\", \"option2\", \"option3\"], required: false },\n// { name: \"arg2\", type: \"number\" },\n// {\n// name: \"arg3\",\n// type: \"object\",\n// attributes: [\n// { name: \"nestedArg1\", type: \"boolean\" },\n// { name: \"xyz\", required: false },\n// ],\n// },\n// { name: \"arg4\", type: \"number[]\" },\n// ],\n// handler: ({ arg1, arg2, arg3, arg4 }) => {\n// const x = arg3.nestedArg1;\n// const z = arg3.xyz;\n// console.log(arg1, arg2, arg3);\n// },\n// });\n\n// useCopilotAction({\n// name: \"myAction\",\n// handler: () => {\n// console.log(\"No parameters provided.\");\n// },\n// });\n"],"mappings":";;;;;AAAA,SAAS,QAAQ,YAAY,iBAAiB;AAG9C,SAAoB,gBAAgB;AAW7B,SAAS,iBACd,QACA,cACM;AACN,QAAM,EAAE,WAAW,cAAc,SAAS,oBAAoB,IAAI,WAAW,cAAc;AAC3F,QAAM,QAAQ,OAAe,SAAS,CAAC;AAKvC,MAAI,iBAAiB,QAAW;AAC9B,QAAI,QAAQ,MAAM,OAAO,GAAG;AAC1B,cAAQ,MAAM,OAAO,EAAE,UAAU,OAAO;AACxC,UAAI,OAAO,OAAO,WAAW,YAAY;AACvC,YAAI,oBAAoB,YAAY,MAAM;AACxC,8BAAoB,QAAQ,OAAO,IAAI,IAAI,OAAO;AAAA,QACpD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,YAAU,MAAM;AACd,cAAU,MAAM,SAAS,MAAa;AACtC,QAAI,oBAAoB,YAAY,QAAQ,OAAO,WAAW,QAAW;AACvE,0BAAoB,QAAQ,OAAO,IAAI,IAAI,OAAO;AAAA,IACpD;AACA,WAAO,MAAM;AAGX,mBAAa,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA;AAAA;AAAA,IAGP,KAAK,UAAU,OAAO,UAAU;AAAA;AAAA,IAEhC,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;AAAA;AAAA,IAEpD,GAAI,gBAAgB,CAAC;AAAA,EACvB,CAAC;AACH;","names":[]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  use_flat_category_store_default
3
- } from "./chunk-YULKJPY3.mjs";
3
+ } from "./chunk-5FHSUKQL.mjs";
4
4
  import {
5
5
  use_tree_default
6
- } from "./chunk-YWITCRBI.mjs";
6
+ } from "./chunk-6U3UH3KO.mjs";
7
7
  import {
8
8
  CopilotContext
9
9
  } from "./chunk-2F7V4NDT.mjs";
@@ -193,4 +193,4 @@ export {
193
193
  CopilotKit,
194
194
  defaultCopilotContextCategories
195
195
  };
196
- //# sourceMappingURL=chunk-LYC2GBBA.mjs.map
196
+ //# sourceMappingURL=chunk-KBHWHMQC.mjs.map
@@ -135,7 +135,7 @@ function returnAndThrowInDebug(value) {
135
135
  }
136
136
 
137
137
  // src/hooks/use-tree.ts
138
- var import_nanoid = require("nanoid");
138
+ var import_shared = require("@copilotkit/shared");
139
139
  var import_react2 = require("react");
140
140
  var removeNode = (nodes, id) => {
141
141
  return nodes.reduce((result, node) => {
@@ -220,7 +220,7 @@ var useTree = () => {
220
220
  const [tree, dispatch] = (0, import_react2.useReducer)(treeReducer, []);
221
221
  const addElement = (0, import_react2.useCallback)(
222
222
  (value, categories, parentId) => {
223
- const newNodeId = (0, import_nanoid.nanoid)();
223
+ const newNodeId = (0, import_shared.randomId)();
224
224
  dispatch({
225
225
  type: "ADD_NODE",
226
226
  value,
@@ -266,15 +266,15 @@ function setsHaveIntersection(setA, setB) {
266
266
  }
267
267
 
268
268
  // src/components/copilot-provider/copilotkit.tsx
269
- var import_shared = require("@copilotkit/shared");
269
+ var import_shared3 = require("@copilotkit/shared");
270
270
 
271
271
  // src/hooks/use-flat-category-store.ts
272
- var import_nanoid2 = require("nanoid");
273
272
  var import_react3 = require("react");
273
+ var import_shared2 = require("@copilotkit/shared");
274
274
  var useFlatCategoryStore = () => {
275
275
  const [elements, dispatch] = (0, import_react3.useReducer)(flatCategoryStoreReducer, /* @__PURE__ */ new Map());
276
276
  const addElement = (0, import_react3.useCallback)((value, categories) => {
277
- const newId = (0, import_nanoid2.nanoid)();
277
+ const newId = (0, import_shared2.randomId)();
278
278
  dispatch({
279
279
  type: "ADD_ELEMENT",
280
280
  value,
@@ -344,7 +344,7 @@ function CopilotKit(_a) {
344
344
  "Please provide either a runtimeUrl or a publicApiKey to the CopilotKit component."
345
345
  );
346
346
  }
347
- const chatApiEndpoint = props.runtimeUrl || import_shared.COPILOT_CLOUD_CHAT_URL;
347
+ const chatApiEndpoint = props.runtimeUrl || import_shared3.COPILOT_CLOUD_CHAT_URL;
348
348
  const [actions, setActions] = (0, import_react4.useState)({});
349
349
  const chatComponentsCache = (0, import_react4.useRef)({});
350
350
  const { addElement, removeElement, printTree } = use_tree_default();