@copilotkit/react-textarea 0.36.0-mme-push-to-talk.0 → 0.36.0-mme-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/.turbo/turbo-build.log +62 -62
  2. package/CHANGELOG.md +12 -0
  3. package/dist/{chunk-PQIOU3E5.mjs → chunk-2OWOTL6X.mjs} +2 -2
  4. package/dist/chunk-2OWOTL6X.mjs.map +1 -0
  5. package/dist/{chunk-QCPS6IYI.mjs → chunk-HE4GMS2P.mjs} +7 -3
  6. package/dist/chunk-HE4GMS2P.mjs.map +1 -0
  7. package/dist/components/copilot-textarea/copilot-textarea.d.ts +106 -0
  8. package/dist/components/copilot-textarea/copilot-textarea.js +6 -2
  9. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  10. package/dist/components/copilot-textarea/copilot-textarea.mjs +2 -2
  11. package/dist/components/index.js +6 -2
  12. package/dist/components/index.js.map +1 -1
  13. package/dist/components/index.mjs +2 -2
  14. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +6 -2
  15. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  16. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
  17. package/dist/index.js +6 -2
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +3 -3
  20. package/dist/types/base/base-copilot-textarea-props.d.ts +28 -21
  21. package/dist/types/base/base-copilot-textarea-props.js.map +1 -1
  22. package/package.json +6 -6
  23. package/src/components/copilot-textarea/copilot-textarea.tsx +105 -1
  24. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +8 -1
  25. package/src/types/base/base-copilot-textarea-props.tsx +36 -21
  26. package/dist/chunk-PQIOU3E5.mjs.map +0 -1
  27. package/dist/chunk-QCPS6IYI.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
 
2
- > @copilotkit/react-textarea@0.36.0-mme-push-to-talk.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea
2
+ > @copilotkit/react-textarea@0.36.0-mme-pre.1 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea
3
3
  > tsup --clean
4
4
 
5
- CLI Building entry: src/index.tsx, src/components/index.ts, src/hooks/index.ts, src/context/index.ts, src/lib/debouncer.ts, src/lib/editor-to-text.ts, src/lib/get-text-around-cursor.ts, src/lib/retry.tsx, src/lib/stream-promise-flatten.ts, src/lib/utils.test.ts, src/lib/utils.ts, src/types/html-copilot-textarea-element.ts, src/types/index.ts, src/components/base-copilot-textarea/base-copilot-textarea.tsx, src/components/base-copilot-textarea/render-element.tsx, src/components/base-copilot-textarea/render-placeholder.tsx, src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx, src/components/base-copilot-textarea/use-add-branding-css.tsx, src/components/copilot-textarea/copilot-textarea.tsx, src/components/hovering-toolbar/hovering-editor-provider.tsx, src/components/hovering-toolbar/hovering-toolbar-components.tsx, src/components/hovering-toolbar/hovering-toolbar.tsx, src/components/manual-ui/chip-with-icon.tsx, src/components/source-search-box/source-search-box.tsx, src/components/ui/button.tsx, src/components/ui/card.tsx, src/components/ui/command.tsx, src/components/ui/dialog.tsx, src/components/ui/label.tsx, src/components/ui/separator.tsx, src/components/ui/textarea.tsx, src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts, src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx, src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts, src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx, src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx, src/hooks/misc/use-autosize-textarea.tsx, src/lib/slatejs-edits/add-autocompletions.ts, src/lib/slatejs-edits/clear-autocompletions.ts, src/lib/slatejs-edits/replace-text.ts, src/lib/slatejs-edits/with-partial-history.ts, src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx, src/types/autosuggestions-config/autosuggestions-config.tsx, src/types/autosuggestions-config/editing-api-config.tsx, src/types/autosuggestions-config/index.ts, src/types/autosuggestions-config/insertions-api-config.tsx, src/types/autosuggestions-config/suggestions-api-config.tsx, src/types/base/autosuggestion-state.ts, src/types/base/autosuggestions-bare-function.ts, src/types/base/base-autosuggestions-config.tsx, src/types/base/base-copilot-textarea-props.tsx, src/types/base/custom-editor.tsx, src/types/base/editor-autocomplete-state.ts, src/types/base/index.ts, src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx, src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx, src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx, src/components/hovering-toolbar/text-insertion-prompt-box/index.ts, src/types/autosuggestions-config/subtypes/make-system-prompt.ts, src/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.tsx
5
+ CLI Building entry: src/index.tsx, src/components/index.ts, src/context/index.ts, src/hooks/index.ts, src/lib/debouncer.ts, src/lib/editor-to-text.ts, src/lib/get-text-around-cursor.ts, src/lib/retry.tsx, src/lib/stream-promise-flatten.ts, src/lib/utils.test.ts, src/lib/utils.ts, src/types/html-copilot-textarea-element.ts, src/types/index.ts, src/components/base-copilot-textarea/base-copilot-textarea.tsx, src/components/base-copilot-textarea/render-element.tsx, src/components/base-copilot-textarea/render-placeholder.tsx, src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx, src/components/base-copilot-textarea/use-add-branding-css.tsx, src/components/copilot-textarea/copilot-textarea.tsx, src/components/hovering-toolbar/hovering-editor-provider.tsx, src/components/hovering-toolbar/hovering-toolbar-components.tsx, src/components/hovering-toolbar/hovering-toolbar.tsx, src/components/manual-ui/chip-with-icon.tsx, src/components/source-search-box/source-search-box.tsx, src/components/ui/button.tsx, src/components/ui/card.tsx, src/components/ui/command.tsx, src/components/ui/dialog.tsx, src/components/ui/label.tsx, src/components/ui/separator.tsx, src/components/ui/textarea.tsx, src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts, src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx, src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts, src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx, src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx, src/hooks/misc/use-autosize-textarea.tsx, src/lib/slatejs-edits/add-autocompletions.ts, src/lib/slatejs-edits/clear-autocompletions.ts, src/lib/slatejs-edits/replace-text.ts, src/lib/slatejs-edits/with-partial-history.ts, src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx, src/types/autosuggestions-config/autosuggestions-config.tsx, src/types/autosuggestions-config/editing-api-config.tsx, src/types/autosuggestions-config/index.ts, src/types/autosuggestions-config/insertions-api-config.tsx, src/types/autosuggestions-config/suggestions-api-config.tsx, src/types/base/autosuggestion-state.ts, src/types/base/autosuggestions-bare-function.ts, src/types/base/base-autosuggestions-config.tsx, src/types/base/base-copilot-textarea-props.tsx, src/types/base/custom-editor.tsx, src/types/base/editor-autocomplete-state.ts, src/types/base/index.ts, src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx, src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx, src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx, src/components/hovering-toolbar/text-insertion-prompt-box/index.ts, src/types/autosuggestions-config/subtypes/make-system-prompt.ts, src/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.tsx
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-textarea/tsup.config.ts
@@ -18,9 +18,11 @@ Browserslist: caniuse-lite is outdated. Please run:
18
18
  warn - Update your configuration file to eliminate this warning.
19
19
  warn - https://tailwindcss.com/docs/upgrade-guide#configure-content-sources
20
20
  DTS Build start
21
+ CJS dist/types/html-copilot-textarea-element.js 893.00 B
22
+ CJS dist/components/hovering-toolbar/hovering-editor-provider.js 1.85 KB
21
23
  CJS dist/components/manual-ui/chip-with-icon.js 1.73 KB
22
- CJS dist/components/source-search-box/source-search-box.js 9.53 KB
23
24
  CJS dist/components/ui/button.js 4.82 KB
25
+ CJS dist/components/source-search-box/source-search-box.js 9.53 KB
24
26
  CJS dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js 6.34 KB
25
27
  CJS dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js 5.19 KB
26
28
  CJS dist/hooks/misc/use-autosize-textarea.js 1.48 KB
@@ -29,12 +31,12 @@ Browserslist: caniuse-lite is outdated. Please run:
29
31
  CJS dist/types/base/autosuggestion-state.js 862.00 B
30
32
  CJS dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js 24.47 KB
31
33
  CJS dist/types/autosuggestions-config/subtypes/make-system-prompt.js 881.00 B
32
- CJS dist/index.js 79.92 KB
34
+ CJS dist/index.js 80.17 KB
33
35
  CJS dist/index.css 18.82 KB
34
- CJS dist/components/index.js 79.73 KB
36
+ CJS dist/components/index.js 79.98 KB
35
37
  CJS dist/components/index.css 242.00 B
36
- CJS dist/hooks/index.js 797.00 B
37
38
  CJS dist/context/index.js 803.00 B
39
+ CJS dist/hooks/index.js 797.00 B
38
40
  CJS dist/lib/debouncer.js 2.38 KB
39
41
  CJS dist/lib/editor-to-text.js 2.35 KB
40
42
  CJS dist/lib/get-text-around-cursor.js 4.09 KB
@@ -42,32 +44,30 @@ Browserslist: caniuse-lite is outdated. Please run:
42
44
  CJS dist/lib/stream-promise-flatten.js 2.26 KB
43
45
  CJS dist/lib/utils.test.js 182.00 B
44
46
  CJS dist/lib/utils.js 3.08 KB
45
- CJS dist/types/html-copilot-textarea-element.js 893.00 B
46
47
  CJS dist/types/index.js 10.66 KB
47
- CJS dist/components/base-copilot-textarea/base-copilot-textarea.js 63.75 KB
48
48
  CJS dist/components/base-copilot-textarea/base-copilot-textarea.css 258.00 B
49
49
  CJS dist/components/base-copilot-textarea/render-element.js 2.94 KB
50
50
  CJS dist/components/base-copilot-textarea/render-placeholder.js 2.84 KB
51
51
  CJS dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.js 4.02 KB
52
52
  CJS dist/components/base-copilot-textarea/use-add-branding-css.js 3.19 KB
53
- CJS dist/components/copilot-textarea/copilot-textarea.js 79.67 KB
53
+ CJS dist/components/base-copilot-textarea/base-copilot-textarea.js 63.75 KB
54
54
  CJS dist/components/copilot-textarea/copilot-textarea.css 253.00 B
55
- CJS dist/components/hovering-toolbar/hovering-editor-provider.js 1.85 KB
56
55
  CJS dist/components/hovering-toolbar/hovering-toolbar-components.js 5.55 KB
57
56
  CJS dist/components/hovering-toolbar/hovering-toolbar.js 33.66 KB
57
+ CJS dist/components/copilot-textarea/copilot-textarea.js 79.92 KB
58
58
  CJS dist/components/ui/card.js 5.36 KB
59
59
  CJS dist/components/ui/command.js 12.51 KB
60
60
  CJS dist/components/ui/dialog.js 7.83 KB
61
- CJS dist/components/ui/label.js 3.73 KB
62
61
  CJS dist/components/ui/separator.js 3.80 KB
62
+ CJS dist/components/ui/label.js 3.73 KB
63
63
  CJS dist/components/ui/textarea.js 3.76 KB
64
- CJS dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js 6.35 KB
65
- CJS dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js 6.04 KB
66
- CJS dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js 6.74 KB
67
64
  CJS dist/lib/slatejs-edits/clear-autocompletions.js 1.71 KB
68
65
  CJS dist/lib/slatejs-edits/replace-text.js 1.61 KB
69
66
  CJS dist/lib/slatejs-edits/with-partial-history.js 4.30 KB
70
67
  CJS dist/types/autosuggestions-config/autosuggestions-config.js 10.65 KB
68
+ CJS dist/types/autosuggestions-config/editing-api-config.js 3.69 KB
69
+ CJS dist/types/autosuggestions-config/index.js 10.62 KB
70
+ CJS dist/types/autosuggestions-config/insertions-api-config.js 4.11 KB
71
71
  CJS dist/types/autosuggestions-config/suggestions-api-config.js 3.71 KB
72
72
  CJS dist/types/base/autosuggestions-bare-function.js 898.00 B
73
73
  CJS dist/types/base/base-autosuggestions-config.js 1.99 KB
@@ -79,12 +79,14 @@ Browserslist: caniuse-lite is outdated. Please run:
79
79
  CJS dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js 5.48 KB
80
80
  CJS dist/components/hovering-toolbar/text-insertion-prompt-box/index.js 25.19 KB
81
81
  CJS dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js 906.00 B
82
- CJS dist/types/autosuggestions-config/insertions-api-config.js 4.11 KB
83
- CJS dist/types/autosuggestions-config/index.js 10.62 KB
84
- CJS dist/types/autosuggestions-config/editing-api-config.js 3.69 KB
82
+ CJS dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js 6.04 KB
83
+ CJS dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js 6.99 KB
84
+ CJS dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js 6.35 KB
85
+ CJS dist/types/html-copilot-textarea-element.js.map 280.00 B
86
+ CJS dist/components/hovering-toolbar/hovering-editor-provider.js.map 1.40 KB
85
87
  CJS dist/components/manual-ui/chip-with-icon.js.map 969.00 B
86
- CJS dist/components/source-search-box/source-search-box.js.map 13.01 KB
87
88
  CJS dist/components/ui/button.js.map 4.34 KB
89
+ CJS dist/components/source-search-box/source-search-box.js.map 13.01 KB
88
90
  CJS dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map 10.30 KB
89
91
  CJS dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map 5.83 KB
90
92
  CJS dist/hooks/misc/use-autosize-textarea.js.map 1.17 KB
@@ -93,20 +95,19 @@ Browserslist: caniuse-lite is outdated. Please run:
93
95
  CJS dist/types/base/autosuggestion-state.js.map 269.00 B
94
96
  CJS dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.js.map 36.34 KB
95
97
  CJS dist/types/autosuggestions-config/subtypes/make-system-prompt.js.map 268.00 B
96
- CJS dist/index.js.map 143.16 KB
98
+ CJS dist/index.js.map 146.78 KB
97
99
  CJS dist/index.css.map 29.12 KB
100
+ CJS dist/components/index.js.map 146.97 KB
98
101
  CJS dist/components/index.css.map 429.00 B
99
- CJS dist/components/index.js.map 143.35 KB
100
- CJS dist/hooks/index.js.map 137.00 B
101
102
  CJS dist/context/index.js.map 139.00 B
103
+ CJS dist/hooks/index.js.map 137.00 B
102
104
  CJS dist/lib/debouncer.js.map 1.68 KB
103
105
  CJS dist/lib/editor-to-text.js.map 2.86 KB
106
+ CJS dist/lib/get-text-around-cursor.js.map 5.75 KB
104
107
  CJS dist/lib/retry.js.map 1018.00 B
105
108
  CJS dist/lib/stream-promise-flatten.js.map 1.45 KB
106
- CJS dist/lib/get-text-around-cursor.js.map 5.75 KB
107
109
  CJS dist/lib/utils.test.js.map 352.00 B
108
110
  CJS dist/lib/utils.js.map 2.53 KB
109
- CJS dist/types/html-copilot-textarea-element.js.map 280.00 B
110
111
  CJS dist/types/index.js.map 18.56 KB
111
112
  CJS dist/components/base-copilot-textarea/base-copilot-textarea.css.map 432.00 B
112
113
  CJS dist/components/base-copilot-textarea/render-element.js.map 1.75 KB
@@ -115,51 +116,50 @@ Browserslist: caniuse-lite is outdated. Please run:
115
116
  CJS dist/components/base-copilot-textarea/use-add-branding-css.js.map 3.50 KB
116
117
  CJS dist/components/base-copilot-textarea/base-copilot-textarea.js.map 113.32 KB
117
118
  CJS dist/components/copilot-textarea/copilot-textarea.css.map 432.00 B
118
- CJS dist/components/hovering-toolbar/hovering-editor-provider.js.map 1.40 KB
119
119
  CJS dist/components/hovering-toolbar/hovering-toolbar-components.js.map 3.75 KB
120
120
  CJS dist/components/hovering-toolbar/hovering-toolbar.js.map 53.52 KB
121
- CJS dist/components/copilot-textarea/copilot-textarea.js.map 143.18 KB
121
+ CJS dist/components/copilot-textarea/copilot-textarea.js.map 146.80 KB
122
122
  CJS dist/components/ui/card.js.map 4.86 KB
123
- CJS dist/components/ui/dialog.js.map 7.44 KB
124
123
  CJS dist/components/ui/command.js.map 14.31 KB
125
- CJS dist/components/ui/label.js.map 2.85 KB
124
+ CJS dist/components/ui/dialog.js.map 7.44 KB
126
125
  CJS dist/components/ui/separator.js.map 2.96 KB
126
+ CJS dist/components/ui/label.js.map 2.85 KB
127
127
  CJS dist/components/ui/textarea.js.map 2.87 KB
128
- CJS dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map 9.92 KB
129
- CJS dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map 10.48 KB
130
128
  CJS dist/lib/slatejs-edits/clear-autocompletions.js.map 1.14 KB
131
- CJS dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map 8.60 KB
132
129
  CJS dist/lib/slatejs-edits/replace-text.js.map 1.17 KB
133
130
  CJS dist/lib/slatejs-edits/with-partial-history.js.map 6.16 KB
134
- CJS dist/types/autosuggestions-config/suggestions-api-config.js.map 3.63 KB
135
131
  CJS dist/types/autosuggestions-config/autosuggestions-config.js.map 18.42 KB
132
+ CJS dist/types/autosuggestions-config/editing-api-config.js.map 3.96 KB
133
+ CJS dist/types/autosuggestions-config/index.js.map 19.08 KB
134
+ CJS dist/types/autosuggestions-config/insertions-api-config.js.map 4.22 KB
135
+ CJS dist/types/autosuggestions-config/suggestions-api-config.js.map 3.63 KB
136
136
  CJS dist/types/base/autosuggestions-bare-function.js.map 1.01 KB
137
- CJS dist/types/base/base-copilot-textarea-props.js.map 2.29 KB
138
137
  CJS dist/types/base/base-autosuggestions-config.js.map 5.34 KB
139
- CJS dist/types/base/editor-autocomplete-state.js.map 2.64 KB
138
+ CJS dist/types/base/base-copilot-textarea-props.js.map 1.84 KB
140
139
  CJS dist/types/base/custom-editor.js.map 886.00 B
140
+ CJS dist/types/base/editor-autocomplete-state.js.map 2.64 KB
141
141
  CJS dist/types/base/index.js.map 5.72 KB
142
- CJS dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map 5.26 KB
143
142
  CJS dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.js.map 37.75 KB
144
- CJS dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map 283.00 B
143
+ CJS dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.js.map 5.26 KB
145
144
  CJS dist/components/hovering-toolbar/text-insertion-prompt-box/index.js.map 37.98 KB
146
- CJS dist/types/autosuggestions-config/insertions-api-config.js.map 4.22 KB
147
- CJS dist/types/autosuggestions-config/index.js.map 19.08 KB
148
- CJS dist/types/autosuggestions-config/editing-api-config.js.map 3.96 KB
149
- CJS ⚡️ Build success in 1884ms
145
+ CJS dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map 283.00 B
146
+ CJS dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map 10.48 KB
147
+ CJS dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map 8.94 KB
148
+ CJS dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.js.map 9.92 KB
149
+ CJS ⚡️ Build success in 1731ms
150
150
  ESM dist/index.mjs 1.76 KB
151
151
  ESM dist/components/index.mjs 1.52 KB
152
- ESM dist/hooks/index.mjs 66.00 B
153
152
  ESM dist/context/index.mjs 66.00 B
153
+ ESM dist/hooks/index.mjs 66.00 B
154
154
  ESM dist/lib/debouncer.mjs 147.00 B
155
155
  ESM dist/components/copilot-textarea/copilot-textarea.css 253.00 B
156
156
  ESM dist/components/base-copilot-textarea/base-copilot-textarea.css 258.00 B
157
157
  ESM dist/chunk-DE5K76I2.mjs 43.00 B
158
158
  ESM dist/chunk-WADHCMPK.mjs 43.00 B
159
159
  ESM dist/chunk-MMVDU6DF.mjs 43.00 B
160
- ESM dist/chunk-PQIOU3E5.mjs 1.88 KB
160
+ ESM dist/chunk-2OWOTL6X.mjs 1.88 KB
161
161
  ESM dist/chunk-SJ2TM5GA.mjs 2.34 KB
162
- ESM dist/chunk-QCPS6IYI.mjs 3.85 KB
162
+ ESM dist/chunk-HE4GMS2P.mjs 4.10 KB
163
163
  ESM dist/chunk-RUV6NBIF.mjs 43.00 B
164
164
  ESM dist/chunk-DKE57EAC.mjs 919.00 B
165
165
  ESM dist/chunk-4OJ3H65F.mjs 2.50 KB
@@ -195,8 +195,8 @@ Browserslist: caniuse-lite is outdated. Please run:
195
195
  ESM dist/chunk-LCDTIJSD.mjs 905.00 B
196
196
  ESM dist/chunk-224UKA7C.mjs 1.13 KB
197
197
  ESM dist/chunk-XW3ICO4S.mjs 688.00 B
198
- ESM dist/chunk-H4VKQGVU.mjs 43.00 B
199
198
  ESM dist/chunk-IU3WTXLQ.mjs 43.00 B
199
+ ESM dist/chunk-H4VKQGVU.mjs 43.00 B
200
200
  ESM dist/chunk-DFTV4TST.mjs 931.00 B
201
201
  ESM dist/lib/editor-to-text.mjs 158.00 B
202
202
  ESM dist/chunk-T6MTDQZ7.mjs 1.31 KB
@@ -208,8 +208,10 @@ Browserslist: caniuse-lite is outdated. Please run:
208
208
  ESM dist/index.css 18.82 KB
209
209
  ESM dist/components/index.css 242.00 B
210
210
  ESM dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs 308.00 B
211
- ESM dist/types/base/autosuggestions-bare-function.mjs 58.00 B
212
211
  ESM dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs 645.00 B
212
+ ESM dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs 47.00 B
213
+ ESM dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs 53.00 B
214
+ ESM dist/types/base/autosuggestions-bare-function.mjs 58.00 B
213
215
  ESM dist/types/base/base-autosuggestions-config.mjs 217.00 B
214
216
  ESM dist/types/base/base-copilot-textarea-props.mjs 56.00 B
215
217
  ESM dist/types/base/custom-editor.mjs 42.00 B
@@ -235,8 +237,8 @@ Browserslist: caniuse-lite is outdated. Please run:
235
237
  ESM dist/lib/slatejs-edits/replace-text.mjs 172.00 B
236
238
  ESM dist/components/ui/button.mjs 215.00 B
237
239
  ESM dist/components/ui/card.mjs 2.21 KB
238
- ESM dist/components/ui/dialog.mjs 383.00 B
239
240
  ESM dist/components/ui/command.mjs 485.00 B
241
+ ESM dist/components/ui/dialog.mjs 383.00 B
240
242
  ESM dist/components/ui/label.mjs 176.00 B
241
243
  ESM dist/components/ui/separator.mjs 921.00 B
242
244
  ESM dist/components/ui/textarea.mjs 886.00 B
@@ -248,8 +250,8 @@ Browserslist: caniuse-lite is outdated. Please run:
248
250
  ESM dist/components/hovering-toolbar/hovering-toolbar-components.mjs 239.00 B
249
251
  ESM dist/components/hovering-toolbar/hovering-toolbar.mjs 697.00 B
250
252
  ESM dist/components/manual-ui/chip-with-icon.mjs 690.00 B
251
- ESM dist/lib/stream-promise-flatten.mjs 182.00 B
252
253
  ESM dist/components/source-search-box/source-search-box.mjs 294.00 B
254
+ ESM dist/lib/stream-promise-flatten.mjs 182.00 B
253
255
  ESM dist/lib/utils.test.mjs 168.00 B
254
256
  ESM dist/lib/utils.mjs 305.00 B
255
257
  ESM dist/types/html-copilot-textarea-element.mjs 90.00 B
@@ -259,17 +261,17 @@ Browserslist: caniuse-lite is outdated. Please run:
259
261
  ESM dist/components/base-copilot-textarea/render-placeholder.mjs 202.00 B
260
262
  ESM dist/index.mjs.map 71.00 B
261
263
  ESM dist/components/index.mjs.map 71.00 B
262
- ESM dist/hooks/index.mjs.map 71.00 B
263
264
  ESM dist/context/index.mjs.map 71.00 B
265
+ ESM dist/hooks/index.mjs.map 71.00 B
264
266
  ESM dist/lib/debouncer.mjs.map 71.00 B
265
267
  ESM dist/components/copilot-textarea/copilot-textarea.css.map 432.00 B
266
268
  ESM dist/components/base-copilot-textarea/base-copilot-textarea.css.map 432.00 B
267
269
  ESM dist/chunk-DE5K76I2.mjs.map 71.00 B
268
270
  ESM dist/chunk-WADHCMPK.mjs.map 71.00 B
269
271
  ESM dist/chunk-MMVDU6DF.mjs.map 71.00 B
270
- ESM dist/chunk-PQIOU3E5.mjs.map 3.41 KB
272
+ ESM dist/chunk-2OWOTL6X.mjs.map 6.66 KB
271
273
  ESM dist/chunk-SJ2TM5GA.mjs.map 4.86 KB
272
- ESM dist/chunk-QCPS6IYI.mjs.map 7.62 KB
274
+ ESM dist/chunk-HE4GMS2P.mjs.map 7.97 KB
273
275
  ESM dist/chunk-RUV6NBIF.mjs.map 71.00 B
274
276
  ESM dist/chunk-DKE57EAC.mjs.map 1.65 KB
275
277
  ESM dist/chunk-4OJ3H65F.mjs.map 3.91 KB
@@ -305,8 +307,8 @@ Browserslist: caniuse-lite is outdated. Please run:
305
307
  ESM dist/chunk-LCDTIJSD.mjs.map 5.30 KB
306
308
  ESM dist/chunk-224UKA7C.mjs.map 1.71 KB
307
309
  ESM dist/chunk-XW3ICO4S.mjs.map 947.00 B
308
- ESM dist/chunk-H4VKQGVU.mjs.map 71.00 B
309
310
  ESM dist/chunk-IU3WTXLQ.mjs.map 71.00 B
311
+ ESM dist/chunk-H4VKQGVU.mjs.map 71.00 B
310
312
  ESM dist/chunk-DFTV4TST.mjs.map 1.62 KB
311
313
  ESM dist/lib/editor-to-text.mjs.map 71.00 B
312
314
  ESM dist/chunk-T6MTDQZ7.mjs.map 2.82 KB
@@ -317,11 +319,11 @@ Browserslist: caniuse-lite is outdated. Please run:
317
319
  ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
318
320
  ESM dist/index.css.map 29.12 KB
319
321
  ESM dist/components/index.css.map 429.00 B
320
- ESM dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs 47.00 B
321
- ESM dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs 53.00 B
322
322
  ESM dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map 71.00 B
323
- ESM dist/types/base/autosuggestions-bare-function.mjs.map 71.00 B
324
323
  ESM dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map 71.00 B
324
+ ESM dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map 71.00 B
325
+ ESM dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map 71.00 B
326
+ ESM dist/types/base/autosuggestions-bare-function.mjs.map 71.00 B
325
327
  ESM dist/types/base/base-autosuggestions-config.mjs.map 71.00 B
326
328
  ESM dist/types/base/base-copilot-textarea-props.mjs.map 71.00 B
327
329
  ESM dist/types/base/custom-editor.mjs.map 71.00 B
@@ -347,8 +349,8 @@ Browserslist: caniuse-lite is outdated. Please run:
347
349
  ESM dist/lib/slatejs-edits/replace-text.mjs.map 71.00 B
348
350
  ESM dist/components/ui/button.mjs.map 71.00 B
349
351
  ESM dist/components/ui/card.mjs.map 3.08 KB
350
- ESM dist/components/ui/dialog.mjs.map 71.00 B
351
352
  ESM dist/components/ui/command.mjs.map 71.00 B
353
+ ESM dist/components/ui/dialog.mjs.map 71.00 B
352
354
  ESM dist/components/ui/label.mjs.map 71.00 B
353
355
  ESM dist/components/ui/separator.mjs.map 1.20 KB
354
356
  ESM dist/components/ui/textarea.mjs.map 1.11 KB
@@ -360,8 +362,8 @@ Browserslist: caniuse-lite is outdated. Please run:
360
362
  ESM dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map 71.00 B
361
363
  ESM dist/components/hovering-toolbar/hovering-toolbar.mjs.map 71.00 B
362
364
  ESM dist/components/manual-ui/chip-with-icon.mjs.map 937.00 B
363
- ESM dist/lib/stream-promise-flatten.mjs.map 71.00 B
364
365
  ESM dist/components/source-search-box/source-search-box.mjs.map 71.00 B
366
+ ESM dist/lib/stream-promise-flatten.mjs.map 71.00 B
365
367
  ESM dist/lib/utils.test.mjs.map 350.00 B
366
368
  ESM dist/lib/utils.mjs.map 71.00 B
367
369
  ESM dist/types/html-copilot-textarea-element.mjs.map 71.00 B
@@ -369,16 +371,14 @@ Browserslist: caniuse-lite is outdated. Please run:
369
371
  ESM dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map 71.00 B
370
372
  ESM dist/components/base-copilot-textarea/render-element.mjs.map 71.00 B
371
373
  ESM dist/components/base-copilot-textarea/render-placeholder.mjs.map 71.00 B
372
- ESM dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map 71.00 B
373
- ESM dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map 71.00 B
374
- ESM ⚡️ Build success in 1896ms
375
- DTS ⚡️ Build success in 19175ms
374
+ ESM ⚡️ Build success in 1771ms
375
+ DTS ⚡️ Build success in 19223ms
376
376
  DTS dist/index.d.ts 1.34 KB
377
377
  DTS dist/components/base-copilot-textarea/base-copilot-textarea.d.ts 1.62 KB
378
- DTS dist/components/copilot-textarea/copilot-textarea.d.ts 1.36 KB
378
+ DTS dist/components/copilot-textarea/copilot-textarea.d.ts 4.61 KB
379
379
  DTS dist/types/base/base-autosuggestions-config.d.ts 3.87 KB
380
380
  DTS dist/types/base/autosuggestions-bare-function.d.ts 970.00 B
381
- DTS dist/types/base/base-copilot-textarea-props.d.ts 2.21 KB
381
+ DTS dist/types/base/base-copilot-textarea-props.d.ts 1.79 KB
382
382
  DTS dist/types/html-copilot-textarea-element.d.ts 165.00 B
383
383
  DTS dist/types/autosuggestions-config/autosuggestions-config.d.ts 924.00 B
384
384
  DTS dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.d.ts 129.00 B
@@ -388,8 +388,8 @@ Browserslist: caniuse-lite is outdated. Please run:
388
388
  DTS dist/types/autosuggestions-config/insertions-api-config.d.ts 673.00 B
389
389
  DTS dist/types/autosuggestions-config/editing-api-config.d.ts 646.00 B
390
390
  DTS dist/components/index.d.ts 954.00 B
391
- DTS dist/hooks/index.d.ts 12.00 B
392
391
  DTS dist/context/index.d.ts 12.00 B
392
+ DTS dist/hooks/index.d.ts 12.00 B
393
393
  DTS dist/lib/debouncer.d.ts 372.00 B
394
394
  DTS dist/lib/editor-to-text.d.ts 243.00 B
395
395
  DTS dist/lib/get-text-around-cursor.d.ts 745.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # ui
2
2
 
3
+ ## 0.36.0-mme-pre.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Pre: CopilotChat, useCopilotChatSuggestions
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @copilotkit/react-core@0.36.0-mme-pre.1
13
+ - @copilotkit/shared@0.36.0-mme-pre.1
14
+
3
15
  ## 0.36.0-mme-push-to-talk.0
4
16
 
5
17
  ### Minor Changes
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SJ2TM5GA.mjs";
4
4
  import {
5
5
  useMakeStandardInsertionOrEditingFunction
6
- } from "./chunk-QCPS6IYI.mjs";
6
+ } from "./chunk-HE4GMS2P.mjs";
7
7
  import {
8
8
  defaultAutosuggestionsConfig
9
9
  } from "./chunk-DKE57EAC.mjs";
@@ -57,4 +57,4 @@ var CopilotTextarea = React.forwardRef(
57
57
  export {
58
58
  CopilotTextarea
59
59
  };
60
- //# sourceMappingURL=chunk-PQIOU3E5.mjs.map
60
+ //# sourceMappingURL=chunk-2OWOTL6X.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/copilot-textarea/copilot-textarea.tsx"],"sourcesContent":["/**\n * A context-aware, auto-completing textarea.\n *\n * <RequestExample>\n * ```jsx CopilotTextarea Example\n * <CopilotTextarea\n * autosuggestionsConfig={{\n * textareaPurpose:\n * \"the body of an email message\",\n * chatApiConfigs: {},\n * }}\n * />\n * ```\n * </RequestExample>\n *\n * `<CopilotTextarea>` is a React component that acts as a drop-in replacement for the standard `<textarea>`,\n * offering enhanced autocomplete features powered by AI. It is context-aware, integrating seamlessly with the\n * [useCopilotReadable()](./useCopilotReadable) hook to provide intelligent suggestions based on the application context.\n *\n * In addition, it provides a hovering editor window (available by default via `Cmd+k`) that allows the user to\n * suggest changes to the text, for example providing a summary or rephrasing the text.\n *\n * <img src=\"/images/CopilotTextarea/CopilotTextarea.gif\" width=\"500\" />\n *\n * ## Integrating CopilotTextarea\n *\n * Install the CopilotTextarea frontend packagess:\n *\n * <CodeGroup>\n * ```bash npm\n * npm i @copilotkit/react-core @copilotkit/react-textarea\n * ```\n *\n * ```bash yarn\n * yarn add @copilotkit/react-core @copilotkit/react-textarea\n * ```\n *\n * ```bash pnpm\n * pnpm add @copilotkit/react-core @copilotkit/react-textarea\n * ```\n * </CodeGroup>\n *\n * Use the CopilotTextarea component in your React application similarly to a standard `<textarea />`,\n * with additional configurations for AI-powered features.\n *\n * For example:\n *\n * ```tsx\n * import { CopilotTextarea } from \"@copilotkit/react-textarea\";\n * import { useState } from \"react\";\n *\n * export function ExampleComponent() {\n * const [text, setText] = useState(\"\");\n *\n * return (\n * <CopilotTextarea\n * className=\"custom-textarea-class\"\n * value={text}\n * onValueChange={(value: string) => setText(value)}\n * placeholder=\"Enter your text here...\"\n * autosuggestionsConfig={{\n * textareaPurpose: \"Provide context or purpose of the textarea.\",\n * chatApiConfigs: {\n * suggestionsApiConfig: {\n * forwardedParams: {\n * max_tokens: 20,\n * stop: [\".\", \"?\", \"!\"],\n * },\n * },\n * },\n * }}\n * />\n * );\n * }\n * ```\n */\nimport React from \"react\";\nimport { useMakeStandardAutosuggestionFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport {\n AutosuggestionsConfig,\n defaultAutosuggestionsConfig,\n} from \"../../types/autosuggestions-config\";\nimport { BaseCopilotTextarea } from \"../base-copilot-textarea/base-copilot-textarea\";\nimport { useMakeStandardInsertionOrEditingFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-insertion-function\";\nimport merge from \"lodash.merge\";\nimport { AutosuggestionsConfigUserSpecified } from \"../../types/autosuggestions-config/autosuggestions-config-user-specified\";\n\n// Like the base copilot textarea props,\n// but with baseAutosuggestionsConfig replaced with autosuggestionsConfig.\nexport interface CopilotTextareaProps\n extends Omit<BaseCopilotTextareaProps, \"baseAutosuggestionsConfig\"> {\n /**\n * Configuration settings for the autosuggestions feature.\n * Includes a mandatory `textareaPurpose` to guide the autosuggestions.\n *\n * Autosuggestions can be configured as follows:\n *\n * ```ts\n * {\n * // the purpose of the textarea\n * textareaPurpose: string,\n * chatApiConfigs: {\n * // the config for the suggestions api (optional)\n * suggestionsApiConfig: {\n * // use this to provide a custom system prompt\n * makeSystemPrompt: (textareaPurpose: string, contextString: string) => string;\n * // custom few shot messages\n * fewShotMessages: MinimalChatGPTMessage[];\n * forwardedParams: {\n * // max number of tokens to generate\n * max_tokens: number,\n * // stop generating when these characters are encountered, e.g. [\".\", \"?\", \"!\"]\n * stop: string[],\n * },\n * },\n * insertionApiConfig: //... the same options as suggestionsApiConfig\n * },\n * }\n * ```\n */\n autosuggestionsConfig: AutosuggestionsConfigUserSpecified;\n}\n\n/**\n * A copilot textarea that uses the standard autosuggestions function.\n */\nexport const CopilotTextarea = React.forwardRef(\n (props: CopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>) => {\n // separate the AutosuggestionsConfigUserSpecified from the rest of the props\n const { autosuggestionsConfig: autosuggestionsConfigUserSpecified, ...forwardedProps } = props;\n\n const autosuggestionsConfig: AutosuggestionsConfig = merge(\n defaultAutosuggestionsConfig,\n autosuggestionsConfigUserSpecified,\n );\n\n const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig,\n );\n\n const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.insertionApiConfig,\n autosuggestionsConfig.chatApiConfigs.editingApiConfig,\n );\n\n return (\n <>\n <BaseCopilotTextarea\n ref={ref}\n {...forwardedProps}\n baseAutosuggestionsConfig={{\n ...autosuggestionsConfig,\n apiConfig: {\n insertionOrEditingFunction: insertionOrEditingFunction,\n autosuggestionsFunction: autosuggestionsFunction,\n },\n }}\n />\n </>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4EA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAkEZ,mBACE,WADF;AAxBC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CAAC,OAA6B,QAA+C;AAE3E,UAAyF,YAAjF,yBAAuB,mCAnInC,IAmI6F,IAAnB,2BAAmB,IAAnB,CAA9D;AAER,UAAM,wBAA+C;AAAA,MACnD;AAAA,MACA;AAAA,IACF;AAEA,UAAM,0BAA0B;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,IACvC;AAEA,UAAM,6BAA6B;AAAA,MACjC,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,MACrC,sBAAsB,eAAe;AAAA,IACvC;AAEA,WACE,gCACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,SACI,iBAFL;AAAA,QAGC,2BAA2B,iCACtB,wBADsB;AAAA,UAEzB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;","names":[]}
@@ -8,11 +8,13 @@ import {
8
8
  } from "./chunk-MRXNTQOX.mjs";
9
9
 
10
10
  // src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
11
+ import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from "@copilotkit/shared";
11
12
  import { CopilotContext } from "@copilotkit/react-core";
12
13
  import { useCallback, useContext } from "react";
13
14
  import { fetchAndDecodeChatCompletionAsText } from "@copilotkit/react-core";
14
15
  function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
15
16
  const { getContextString, copilotApiConfig } = useContext(CopilotContext);
17
+ const headers = __spreadValues({}, copilotApiConfig.publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {});
16
18
  const insertionFunction = useCallback(
17
19
  (editorState, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
18
20
  const res = yield retry(() => __async(this, null, function* () {
@@ -45,7 +47,8 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
45
47
  messages
46
48
  }, insertionApiConfig.forwardedParams), {
47
49
  copilotConfig: copilotApiConfig,
48
- signal: abortSignal
50
+ signal: abortSignal,
51
+ headers
49
52
  }));
50
53
  return stream.events;
51
54
  }));
@@ -90,7 +93,8 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
90
93
  messages
91
94
  }, editingApiConfig.forwardedParams), {
92
95
  copilotConfig: copilotApiConfig,
93
- signal: abortSignal
96
+ signal: abortSignal,
97
+ headers
94
98
  }));
95
99
  return stream.events;
96
100
  }));
@@ -114,4 +118,4 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
114
118
  export {
115
119
  useMakeStandardInsertionOrEditingFunction
116
120
  };
117
- //# sourceMappingURL=chunk-QCPS6IYI.mjs.map
121
+ //# sourceMappingURL=chunk-HE4GMS2P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx"],"sourcesContent":["import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, Message } from \"@copilotkit/shared\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { MinimalChatGPTMessage } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n InsertionEditorApiConfig,\n InsertionEditorState,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { InsertionsApiConfig } from \"../../types/autosuggestions-config/insertions-api-config\";\nimport { EditingApiConfig } from \"../../types/autosuggestions-config/editing-api-config\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\nimport { fetchAndDecodeChatCompletionAsText } from \"@copilotkit/react-core\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardInsertionOrEditingFunction(\n textareaPurpose: string,\n contextCategories: string[],\n insertionApiConfig: InsertionsApiConfig,\n editingApiConfig: EditingApiConfig,\n): Generator_InsertionOrEditingSuggestion {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n const headers = {\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n };\n\n const insertionFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: insertionApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...insertionApiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: insertionPrompt,\n },\n ];\n\n const stream = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...insertionApiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n headers,\n });\n return stream.events!;\n });\n\n return res;\n },\n [insertionApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const editingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n editingPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: editingApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...editingApiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: editorState.selectedText,\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: editingPrompt,\n },\n ];\n\n const stream = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...editingApiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n headers,\n });\n return stream.events!;\n });\n\n return res;\n },\n [editingApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const insertionOrEditingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n if (editorState.selectedText === \"\") {\n return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);\n } else {\n return await editingFunction(editorState, insertionPrompt, documents, abortSignal);\n }\n },\n [insertionFunction, editingFunction],\n );\n\n return insertionOrEditingFunction;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,2CAAoD;AAC7D,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAYxC,SAAS,0CAA0C;AAe5C,SAAS,0CACd,iBACA,mBACA,oBACA,kBACwC;AACxC,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AACxE,QAAM,UAAU,mBACV,iBAAiB,eACjB,EAAE,CAAC,mCAAmC,GAAG,iBAAiB,aAAa,IACvE,CAAC;AAGP,QAAM,oBAAoB;AAAA,IACxB,CACE,aACA,iBACA,WACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,mBAAmB;AAAA,cAC1B;AAAA,cACA,iBAAiB,WAAW,iBAAiB;AAAA,YAC/C;AAAA,UACF;AAAA,UACA,GAAG,mBAAmB;AAAA,UACtB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF;AAEA,cAAM,SAAS,MAAM,mCAAmC;AAAA,UACtD;AAAA,WACG,mBAAmB,kBAFgC;AAAA,UAGtD,eAAe;AAAA,UACf,QAAQ;AAAA,UACR;AAAA,QACF,EAAC;AACD,eAAO,OAAO;AAAA,MAChB,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,oBAAoB,kBAAkB,mBAAmB,eAAe;AAAA,EAC3E;AAEA,QAAM,kBAAkB;AAAA,IACtB,CACE,aACA,eACA,WACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,iBAAiB;AAAA,cACxB;AAAA,cACA,iBAAiB,WAAW,iBAAiB;AAAA,YAC/C;AAAA,UACF;AAAA,UACA,GAAG,iBAAiB;AAAA,UACpB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF;AAEA,cAAM,SAAS,MAAM,mCAAmC;AAAA,UACtD;AAAA,WACG,iBAAiB,kBAFkC;AAAA,UAGtD,eAAe;AAAA,UACf,QAAQ;AAAA,UACR;AAAA,QACF,EAAC;AACD,eAAO,OAAO;AAAA,MAChB,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,kBAAkB,kBAAkB,mBAAmB,eAAe;AAAA,EACzE;AAEA,QAAM,6BAA6B;AAAA,IACjC,CACE,aACA,iBACA,WACA,gBACG;AACH,UAAI,YAAY,iBAAiB,IAAI;AACnC,eAAO,MAAM,kBAAkB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACrF,OAAO;AACL,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACnF;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,eAAe;AAAA,EACrC;AAEA,SAAO;AACT;","names":[]}
@@ -12,7 +12,113 @@ import '../../types/autosuggestions-config/subtypes/make-system-prompt.js';
12
12
  import '../../types/autosuggestions-config/insertions-api-config.js';
13
13
  import '../../types/autosuggestions-config/editing-api-config.js';
14
14
 
15
+ /**
16
+ * A context-aware, auto-completing textarea.
17
+ *
18
+ * <RequestExample>
19
+ * ```jsx CopilotTextarea Example
20
+ * <CopilotTextarea
21
+ * autosuggestionsConfig={{
22
+ * textareaPurpose:
23
+ * "the body of an email message",
24
+ * chatApiConfigs: {},
25
+ * }}
26
+ * />
27
+ * ```
28
+ * </RequestExample>
29
+ *
30
+ * `<CopilotTextarea>` is a React component that acts as a drop-in replacement for the standard `<textarea>`,
31
+ * offering enhanced autocomplete features powered by AI. It is context-aware, integrating seamlessly with the
32
+ * [useCopilotReadable()](./useCopilotReadable) hook to provide intelligent suggestions based on the application context.
33
+ *
34
+ * In addition, it provides a hovering editor window (available by default via `Cmd+k`) that allows the user to
35
+ * suggest changes to the text, for example providing a summary or rephrasing the text.
36
+ *
37
+ * <img src="/images/CopilotTextarea/CopilotTextarea.gif" width="500" />
38
+ *
39
+ * ## Integrating CopilotTextarea
40
+ *
41
+ * Install the CopilotTextarea frontend packagess:
42
+ *
43
+ * <CodeGroup>
44
+ * ```bash npm
45
+ * npm i @copilotkit/react-core @copilotkit/react-textarea
46
+ * ```
47
+ *
48
+ * ```bash yarn
49
+ * yarn add @copilotkit/react-core @copilotkit/react-textarea
50
+ * ```
51
+ *
52
+ * ```bash pnpm
53
+ * pnpm add @copilotkit/react-core @copilotkit/react-textarea
54
+ * ```
55
+ * </CodeGroup>
56
+ *
57
+ * Use the CopilotTextarea component in your React application similarly to a standard `<textarea />`,
58
+ * with additional configurations for AI-powered features.
59
+ *
60
+ * For example:
61
+ *
62
+ * ```tsx
63
+ * import { CopilotTextarea } from "@copilotkit/react-textarea";
64
+ * import { useState } from "react";
65
+ *
66
+ * export function ExampleComponent() {
67
+ * const [text, setText] = useState("");
68
+ *
69
+ * return (
70
+ * <CopilotTextarea
71
+ * className="custom-textarea-class"
72
+ * value={text}
73
+ * onValueChange={(value: string) => setText(value)}
74
+ * placeholder="Enter your text here..."
75
+ * autosuggestionsConfig={{
76
+ * textareaPurpose: "Provide context or purpose of the textarea.",
77
+ * chatApiConfigs: {
78
+ * suggestionsApiConfig: {
79
+ * forwardedParams: {
80
+ * max_tokens: 20,
81
+ * stop: [".", "?", "!"],
82
+ * },
83
+ * },
84
+ * },
85
+ * }}
86
+ * />
87
+ * );
88
+ * }
89
+ * ```
90
+ */
91
+
15
92
  interface CopilotTextareaProps extends Omit<BaseCopilotTextareaProps, "baseAutosuggestionsConfig"> {
93
+ /**
94
+ * Configuration settings for the autosuggestions feature.
95
+ * Includes a mandatory `textareaPurpose` to guide the autosuggestions.
96
+ *
97
+ * Autosuggestions can be configured as follows:
98
+ *
99
+ * ```ts
100
+ * {
101
+ * // the purpose of the textarea
102
+ * textareaPurpose: string,
103
+ * chatApiConfigs: {
104
+ * // the config for the suggestions api (optional)
105
+ * suggestionsApiConfig: {
106
+ * // use this to provide a custom system prompt
107
+ * makeSystemPrompt: (textareaPurpose: string, contextString: string) => string;
108
+ * // custom few shot messages
109
+ * fewShotMessages: MinimalChatGPTMessage[];
110
+ * forwardedParams: {
111
+ * // max number of tokens to generate
112
+ * max_tokens: number,
113
+ * // stop generating when these characters are encountered, e.g. [".", "?", "!"]
114
+ * stop: string[],
115
+ * },
116
+ * },
117
+ * insertionApiConfig: //... the same options as suggestionsApiConfig
118
+ * },
119
+ * }
120
+ * ```
121
+ */
16
122
  autosuggestionsConfig: AutosuggestionsConfigUserSpecified;
17
123
  }
18
124
  /**