@copilotkit/react-core 0.15.0-alpha.3 → 0.15.0-alpha.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 (96) hide show
  1. package/.turbo/turbo-build.log +74 -70
  2. package/CHANGELOG.md +11 -0
  3. package/dist/chunk-3MAIWZNZ.mjs +58 -0
  4. package/dist/chunk-3MAIWZNZ.mjs.map +1 -0
  5. package/dist/chunk-45PUEKTG.mjs +19 -0
  6. package/dist/chunk-45PUEKTG.mjs.map +1 -0
  7. package/dist/chunk-6LKBKYRJ.mjs +165 -0
  8. package/dist/chunk-6LKBKYRJ.mjs.map +1 -0
  9. package/dist/chunk-6LNDDH6K.mjs +19 -0
  10. package/dist/chunk-6LNDDH6K.mjs.map +1 -0
  11. package/dist/chunk-6N6X7K7T.mjs +13 -0
  12. package/dist/chunk-6N6X7K7T.mjs.map +1 -0
  13. package/dist/chunk-7GFKOIO7.mjs +3 -0
  14. package/dist/chunk-7GFKOIO7.mjs.map +1 -0
  15. package/dist/chunk-BABVSMJR.mjs +3 -0
  16. package/dist/chunk-BABVSMJR.mjs.map +1 -0
  17. package/dist/chunk-E3P5YZO2.mjs +27 -0
  18. package/dist/chunk-E3P5YZO2.mjs.map +1 -0
  19. package/dist/chunk-EFZPSZWO.mjs +3 -0
  20. package/dist/chunk-EFZPSZWO.mjs.map +1 -0
  21. package/dist/chunk-FRAKUJWH.mjs +3 -0
  22. package/dist/chunk-FRAKUJWH.mjs.map +1 -0
  23. package/dist/chunk-IZPRCKHE.mjs +79 -0
  24. package/dist/chunk-IZPRCKHE.mjs.map +1 -0
  25. package/dist/chunk-JD7BAH7U.mjs +3 -0
  26. package/dist/chunk-JD7BAH7U.mjs.map +1 -0
  27. package/dist/chunk-MRXNTQOX.mjs +55 -0
  28. package/dist/chunk-MRXNTQOX.mjs.map +1 -0
  29. package/dist/chunk-MZ5UN3BY.mjs +28 -0
  30. package/dist/chunk-MZ5UN3BY.mjs.map +1 -0
  31. package/dist/chunk-QACD2U6P.mjs +3 -0
  32. package/dist/chunk-QACD2U6P.mjs.map +1 -0
  33. package/dist/chunk-QFC2R4ZS.mjs +125 -0
  34. package/dist/chunk-QFC2R4ZS.mjs.map +1 -0
  35. package/dist/chunk-SPCZTZCY.mjs +3 -0
  36. package/dist/chunk-SPCZTZCY.mjs.map +1 -0
  37. package/dist/chunk-VUY2K2DI.mjs +135 -0
  38. package/dist/chunk-VUY2K2DI.mjs.map +1 -0
  39. package/dist/chunk-YPSGKPDA.mjs +3 -0
  40. package/dist/chunk-YPSGKPDA.mjs.map +1 -0
  41. package/dist/chunk-YULKJPY3.mjs +70 -0
  42. package/dist/chunk-YULKJPY3.mjs.map +1 -0
  43. package/dist/components/copilot-provider/copilot-provider-props.mjs +2 -1
  44. package/dist/components/copilot-provider/copilot-provider-props.mjs.map +1 -1
  45. package/dist/components/copilot-provider/copilot-provider.mjs +7 -468
  46. package/dist/components/copilot-provider/copilot-provider.mjs.map +1 -1
  47. package/dist/components/copilot-provider/index.mjs +8 -467
  48. package/dist/components/copilot-provider/index.mjs.map +1 -1
  49. package/dist/components/copilot-provider/standard-cpilot-api-config.mjs +3 -12
  50. package/dist/components/copilot-provider/standard-cpilot-api-config.mjs.map +1 -1
  51. package/dist/components/index.mjs +9 -467
  52. package/dist/components/index.mjs.map +1 -1
  53. package/dist/context/copilot-context.mjs +3 -81
  54. package/dist/context/copilot-context.mjs.map +1 -1
  55. package/dist/context/index.mjs +4 -80
  56. package/dist/context/index.mjs.map +1 -1
  57. package/dist/hooks/index.mjs +14 -249
  58. package/dist/hooks/index.mjs.map +1 -1
  59. package/dist/hooks/use-copilot-chat.mjs +10 -194
  60. package/dist/hooks/use-copilot-chat.mjs.map +1 -1
  61. package/dist/hooks/use-flat-category-store.mjs +3 -68
  62. package/dist/hooks/use-flat-category-store.mjs.map +1 -1
  63. package/dist/hooks/use-make-copilot-actionable.mjs +4 -95
  64. package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
  65. package/dist/hooks/use-make-copilot-document-readable.mjs +4 -87
  66. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -1
  67. package/dist/hooks/use-make-copilot-readable.mjs +4 -87
  68. package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
  69. package/dist/hooks/use-tree.mjs +3 -153
  70. package/dist/hooks/use-tree.mjs.map +1 -1
  71. package/dist/index.mjs +21 -755
  72. package/dist/index.mjs.map +1 -1
  73. package/dist/openai-assistants/hooks/index.mjs +14 -245
  74. package/dist/openai-assistants/hooks/index.mjs.map +1 -1
  75. package/dist/openai-assistants/hooks/use-assistants.mjs +8 -52
  76. package/dist/openai-assistants/hooks/use-assistants.mjs.map +1 -1
  77. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +13 -246
  78. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +1 -1
  79. package/dist/openai-assistants/index.mjs +15 -246
  80. package/dist/openai-assistants/index.mjs.map +1 -1
  81. package/dist/openai-assistants/utils/index.mjs +4 -46
  82. package/dist/openai-assistants/utils/index.mjs.map +1 -1
  83. package/dist/openai-assistants/utils/process-message-stream.mjs +3 -46
  84. package/dist/openai-assistants/utils/process-message-stream.mjs.map +1 -1
  85. package/dist/types/annotated-function.mjs +2 -0
  86. package/dist/types/annotated-function.mjs.map +1 -1
  87. package/dist/types/document-pointer.mjs +2 -0
  88. package/dist/types/document-pointer.mjs.map +1 -1
  89. package/dist/types/index.mjs +2 -0
  90. package/dist/types/index.mjs.map +1 -1
  91. package/dist/utils/utils.mjs +2 -0
  92. package/dist/utils/utils.mjs.map +1 -1
  93. package/dist/utils/utils.test.mjs +1 -0
  94. package/dist/utils/utils.test.mjs.map +1 -1
  95. package/package.json +4 -4
  96. package/src/hooks/use-copilot-chat.ts +1 -4
@@ -1,8 +1,10 @@
1
+ Debugger attached.
1
2
 
2
- > @copilotkit/react-core@0.15.0 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
3
+ > @copilotkit/react-core@0.15.0-alpha.3 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
3
4
  > tsup --treeshake
4
5
 
5
- CLI Building entry: src/index.tsx, src/components/index.ts, src/hooks/index.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-flat-category-store.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/context/copilot-context.tsx, src/context/index.ts, src/openai-assistants/index.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/types/annotated-function.ts, src/types/document-pointer.ts, src/types/index.ts, src/components/copilot-provider/copilot-provider-props.tsx, src/components/copilot-provider/copilot-provider.tsx, src/components/copilot-provider/index.ts, src/components/copilot-provider/standard-cpilot-api-config.tsx, src/openai-assistants/hooks/index.ts, src/openai-assistants/hooks/use-assistants.ts, src/openai-assistants/hooks/use-copilot-chat-v2.ts, src/openai-assistants/utils/index.ts, src/openai-assistants/utils/process-message-stream.ts
6
+ Debugger attached.
7
+ 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-copilot-chat.ts, src/hooks/use-flat-category-store.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/openai-assistants/index.ts, src/types/annotated-function.ts, src/types/document-pointer.ts, src/types/index.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/components/copilot-provider/copilot-provider-props.tsx, src/components/copilot-provider/copilot-provider.tsx, src/components/copilot-provider/index.ts, src/components/copilot-provider/standard-cpilot-api-config.tsx, src/openai-assistants/hooks/index.ts, src/openai-assistants/hooks/use-assistants.ts, src/openai-assistants/hooks/use-copilot-chat-v2.ts, src/openai-assistants/utils/index.ts, src/openai-assistants/utils/process-message-stream.ts
6
8
  CLI Using tsconfig: tsconfig.json
7
9
  CLI tsup v6.7.0
8
10
  CLI Using tsup config: /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core/tsup.config.ts
@@ -12,117 +14,117 @@ ESM Build start
12
14
  Module level directives cause errors when bundled, "use client" in "dist/components/copilot-provider/copilot-provider-props.mjs" was ignored.
13
15
  Module level directives cause errors when bundled, "use client" in "dist/components/copilot-provider/copilot-provider.mjs" was ignored.
14
16
  Module level directives cause errors when bundled, "use client" in "dist/openai-assistants/hooks/use-assistants.mjs" was ignored.
15
- Module level directives cause errors when bundled, "use client" in "dist/context/copilot-context.mjs" was ignored.
16
- Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-actionable.mjs" was ignored.
17
17
  Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-document-readable.mjs" was ignored.
18
18
  Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-readable.mjs" was ignored.
19
- Generated an empty chunk: "copilot-provider-props".
19
+ Module level directives cause errors when bundled, "use client" in "dist/context/copilot-context.mjs" was ignored.
20
+ Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-actionable.mjs" was ignored.
20
21
  Generated an empty chunk: "utils".
22
+ Generated an empty chunk: "copilot-provider-props".
21
23
  Generated an empty chunk: "annotated-function".
22
24
  Generated an empty chunk: "document-pointer".
23
- Generated an empty chunk: "chunk-EFZPSZWO".
24
25
  Generated an empty chunk: "chunk-7GFKOIO7".
25
26
  Generated an empty chunk: "chunk-BABVSMJR".
26
27
  Generated an empty chunk: "chunk-FRAKUJWH".
28
+ Generated an empty chunk: "chunk-EFZPSZWO".
27
29
  Generated an empty chunk: "chunk-YPSGKPDA".
28
30
  Generated an empty chunk: "chunk-QACD2U6P".
29
31
  Generated an empty chunk: "chunk-JD7BAH7U".
30
32
  Generated an empty chunk: "chunk-SPCZTZCY".
31
- ESM dist/utils/utils.mjs 67.00 B
33
+ ESM dist/types/annotated-function.mjs 80.00 B
34
+ ESM dist/types/document-pointer.mjs 78.00 B
32
35
  ESM dist/utils/utils.test.mjs 202.00 B
33
36
  ESM dist/chunk-EFZPSZWO.mjs 76.00 B
34
- ESM dist/types/annotated-function.mjs 80.00 B
35
- ESM dist/chunk-7GFKOIO7.mjs 76.00 B
37
+ ESM dist/utils/utils.mjs 67.00 B
38
+ ESM dist/chunk-FRAKUJWH.mjs 76.00 B
39
+ ESM dist/chunk-SPCZTZCY.mjs 76.00 B
36
40
  ESM dist/chunk-YPSGKPDA.mjs 76.00 B
41
+ ESM dist/chunk-7GFKOIO7.mjs 76.00 B
37
42
  ESM dist/chunk-BABVSMJR.mjs 76.00 B
38
- ESM dist/chunk-JD7BAH7U.mjs 76.00 B
39
43
  ESM dist/chunk-6N6X7K7T.mjs 434.00 B
40
44
  ESM dist/chunk-QACD2U6P.mjs 76.00 B
41
- ESM dist/types/index.mjs 98.00 B
45
+ ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
46
+ ESM dist/openai-assistants/utils/index.mjs 201.00 B
47
+ ESM dist/components/copilot-provider/index.mjs 369.00 B
42
48
  ESM dist/openai-assistants/utils/process-message-stream.mjs 183.00 B
43
- ESM dist/components/copilot-provider/copilot-provider-props.mjs 84.00 B
49
+ ESM dist/components/copilot-provider/copilot-provider.mjs 345.00 B
44
50
  ESM dist/components/copilot-provider/standard-cpilot-api-config.mjs 191.00 B
45
- ESM dist/openai-assistants/hooks/use-assistants.mjs 2.55 KB
51
+ ESM dist/openai-assistants/hooks/index.mjs 547.00 B
46
52
  ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs 548.00 B
53
+ ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
54
+ ESM dist/hooks/use-make-copilot-document-readable.mjs 231.00 B
47
55
  ESM dist/hooks/use-tree.mjs 170.00 B
48
- ESM dist/context/index.mjs 216.00 B
49
- ESM dist/context/copilot-context.mjs 194.00 B
56
+ ESM dist/types/index.mjs 98.00 B
50
57
  ESM dist/index.mjs 984.00 B
51
- ESM dist/chunk-QFC2R4ZS.mjs 4.33 KB
52
- ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
53
- ESM dist/chunk-MZ5UN3BY.mjs 830.00 B
58
+ ESM dist/openai-assistants/index.mjs 570.00 B
59
+ ESM dist/openai-assistants/hooks/use-assistants.mjs 2.55 KB
60
+ ESM dist/context/copilot-context.mjs 194.00 B
61
+ ESM dist/context/index.mjs 216.00 B
54
62
  ESM dist/components/index.mjs 380.00 B
63
+ ESM dist/chunk-QFC2R4ZS.mjs 4.33 KB
55
64
  ESM dist/hooks/index.mjs 612.00 B
56
- ESM dist/chunk-4EKTPSXX.mjs 2.95 KB
57
- ESM dist/components/copilot-provider/index.mjs 369.00 B
58
- ESM dist/chunk-6LKBKYRJ.mjs 5.19 KB
59
- ESM dist/hooks/use-flat-category-store.mjs 200.00 B
60
- ESM dist/chunk-VUY2K2DI.mjs 3.89 KB
61
- ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
62
- ESM dist/hooks/use-make-copilot-document-readable.mjs 231.00 B
63
- ESM dist/chunk-E3P5YZO2.mjs 954.00 B
65
+ ESM dist/hooks/use-copilot-chat.mjs 411.00 B
64
66
  ESM dist/chunk-6LNDDH6K.mjs 677.00 B
65
67
  ESM dist/chunk-45PUEKTG.mjs 626.00 B
66
- ESM dist/chunk-3MAIWZNZ.mjs 1.55 KB
67
- ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
68
+ ESM dist/chunk-VUY2K2DI.mjs 3.89 KB
69
+ ESM dist/hooks/use-flat-category-store.mjs 200.00 B
70
+ ESM dist/components/copilot-provider/copilot-provider-props.mjs 84.00 B
71
+ ESM dist/chunk-JD7BAH7U.mjs 76.00 B
72
+ ESM dist/chunk-6LKBKYRJ.mjs 5.19 KB
68
73
  ESM dist/chunk-YULKJPY3.mjs 1.87 KB
69
- ESM dist/types/document-pointer.mjs 78.00 B
70
- ESM dist/openai-assistants/hooks/index.mjs 547.00 B
71
- ESM dist/openai-assistants/utils/index.mjs 201.00 B
72
- ESM dist/chunk-FRAKUJWH.mjs 76.00 B
73
- ESM dist/chunk-SPCZTZCY.mjs 76.00 B
74
- ESM dist/hooks/use-copilot-chat.mjs 411.00 B
75
- ESM dist/openai-assistants/index.mjs 570.00 B
76
- ESM dist/components/copilot-provider/copilot-provider.mjs 345.00 B
77
- ESM dist/utils/utils.mjs.map 51.00 B
74
+ ESM dist/chunk-E3P5YZO2.mjs 954.00 B
75
+ ESM dist/chunk-3MAIWZNZ.mjs 1.55 KB
76
+ ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
77
+ ESM dist/chunk-MZ5UN3BY.mjs 830.00 B
78
+ ESM dist/chunk-IZPRCKHE.mjs 3.00 KB
79
+ ESM dist/types/annotated-function.mjs.map 51.00 B
78
80
  ESM dist/utils/utils.test.mjs.map 351.00 B
81
+ ESM dist/utils/utils.mjs.map 51.00 B
82
+ ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
83
+ ESM dist/types/document-pointer.mjs.map 51.00 B
84
+ ESM dist/chunk-FRAKUJWH.mjs.map 51.00 B
85
+ ESM dist/chunk-YPSGKPDA.mjs.map 51.00 B
86
+ ESM dist/chunk-SPCZTZCY.mjs.map 51.00 B
79
87
  ESM dist/chunk-7GFKOIO7.mjs.map 51.00 B
80
88
  ESM dist/chunk-BABVSMJR.mjs.map 51.00 B
81
- ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
82
89
  ESM dist/chunk-6N6X7K7T.mjs.map 1.12 KB
83
90
  ESM dist/chunk-QACD2U6P.mjs.map 51.00 B
84
- ESM dist/types/index.mjs.map 51.00 B
85
- ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
91
+ ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
92
+ ESM dist/openai-assistants/utils/index.mjs.map 51.00 B
86
93
  ESM dist/openai-assistants/utils/process-message-stream.mjs.map 51.00 B
87
- ESM dist/components/copilot-provider/copilot-provider-props.mjs.map 51.00 B
94
+ ESM dist/components/copilot-provider/index.mjs.map 51.00 B
95
+ ESM dist/components/copilot-provider/copilot-provider.mjs.map 51.00 B
88
96
  ESM dist/components/copilot-provider/standard-cpilot-api-config.mjs.map 51.00 B
89
- ESM dist/chunk-YPSGKPDA.mjs.map 51.00 B
90
- ESM dist/types/annotated-function.mjs.map 51.00 B
91
- ESM dist/openai-assistants/hooks/use-assistants.mjs.map 4.67 KB
92
- ESM dist/context/index.mjs.map 51.00 B
93
- ESM dist/chunk-QFC2R4ZS.mjs.map 7.87 KB
94
- ESM dist/index.mjs.map 51.00 B
97
+ ESM dist/openai-assistants/hooks/index.mjs.map 51.00 B
98
+ ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map 51.00 B
99
+ ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
100
+ ESM dist/hooks/use-make-copilot-document-readable.mjs.map 51.00 B
101
+ ESM dist/types/index.mjs.map 51.00 B
95
102
  ESM dist/hooks/use-tree.mjs.map 51.00 B
103
+ ESM dist/index.mjs.map 51.00 B
104
+ ESM dist/openai-assistants/index.mjs.map 51.00 B
105
+ ESM dist/openai-assistants/hooks/use-assistants.mjs.map 4.67 KB
96
106
  ESM dist/context/copilot-context.mjs.map 51.00 B
97
- ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
98
- ESM dist/chunk-4EKTPSXX.mjs.map 4.80 KB
99
- ESM dist/chunk-VUY2K2DI.mjs.map 8.27 KB
100
- ESM dist/components/copilot-provider/index.mjs.map 51.00 B
101
- ESM dist/hooks/index.mjs.map 51.00 B
102
- ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map 51.00 B
107
+ ESM dist/chunk-QFC2R4ZS.mjs.map 7.87 KB
103
108
  ESM dist/components/index.mjs.map 51.00 B
109
+ ESM dist/hooks/index.mjs.map 51.00 B
110
+ ESM dist/chunk-6LNDDH6K.mjs.map 1.42 KB
111
+ ESM dist/chunk-VUY2K2DI.mjs.map 8.27 KB
112
+ ESM dist/chunk-45PUEKTG.mjs.map 1.47 KB
104
113
  ESM dist/hooks/use-flat-category-store.mjs.map 51.00 B
105
114
  ESM dist/chunk-6LKBKYRJ.mjs.map 10.71 KB
106
- ESM dist/hooks/use-make-copilot-document-readable.mjs.map 51.00 B
107
- ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
108
- ESM dist/chunk-45PUEKTG.mjs.map 1.47 KB
109
- ESM dist/chunk-3MAIWZNZ.mjs.map 4.68 KB
110
- ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
115
+ ESM dist/components/copilot-provider/copilot-provider-props.mjs.map 51.00 B
111
116
  ESM dist/chunk-E3P5YZO2.mjs.map 1.67 KB
112
- ESM dist/types/document-pointer.mjs.map 51.00 B
113
117
  ESM dist/chunk-YULKJPY3.mjs.map 4.21 KB
114
- ESM dist/openai-assistants/hooks/index.mjs.map 51.00 B
118
+ ESM dist/chunk-3MAIWZNZ.mjs.map 4.68 KB
115
119
  ESM dist/chunk-MZ5UN3BY.mjs.map 1.26 KB
116
- ESM dist/chunk-6LNDDH6K.mjs.map 1.42 KB
117
- ESM dist/openai-assistants/utils/index.mjs.map 51.00 B
118
- ESM dist/chunk-SPCZTZCY.mjs.map 51.00 B
119
- ESM dist/chunk-FRAKUJWH.mjs.map 51.00 B
120
+ ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
121
+ ESM dist/chunk-IZPRCKHE.mjs.map 4.98 KB
120
122
  ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
121
- ESM dist/openai-assistants/index.mjs.map 51.00 B
122
- ESM dist/components/copilot-provider/copilot-provider.mjs.map 51.00 B
123
- ESM ⚡️ Build success in 171ms
123
+ ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
124
+ ESM dist/context/index.mjs.map 51.00 B
125
+ ESM ⚡️ Build success in 254ms
124
126
  DTS Build start
125
- DTS ⚡️ Build success in 1935ms
127
+ DTS ⚡️ Build success in 2663ms
126
128
  DTS dist/index.d.ts 1.29 KB
127
129
  DTS dist/components/copilot-provider/copilot-provider.d.ts 1.17 KB
128
130
  DTS dist/components/copilot-provider/copilot-provider-props.d.ts 1.50 KB
@@ -137,15 +139,17 @@ DTS dist/openai-assistants/hooks/use-copilot-chat-v2.d.ts 1.41 KB
137
139
  DTS dist/openai-assistants/utils/process-message-stream.d.ts 196.00 B
138
140
  DTS dist/hooks/use-tree.d.ts 543.00 B
139
141
  DTS dist/components/index.d.ts 468.00 B
142
+ DTS dist/context/index.d.ts 297.00 B
140
143
  DTS dist/hooks/index.d.ts 434.00 B
141
144
  DTS dist/hooks/use-flat-category-store.d.ts 424.00 B
142
- DTS dist/context/index.d.ts 297.00 B
143
145
  DTS dist/openai-assistants/index.d.ts 262.00 B
146
+ DTS dist/types/index.d.ts 145.00 B
144
147
  DTS dist/utils/utils.test.d.ts 12.00 B
145
148
  DTS dist/utils/utils.d.ts 12.00 B
146
- DTS dist/types/index.d.ts 145.00 B
147
149
  DTS dist/components/copilot-provider/index.d.ts 446.00 B
148
150
  DTS dist/components/copilot-provider/standard-cpilot-api-config.d.ts 894.00 B
149
151
  DTS dist/openai-assistants/hooks/index.d.ts 182.00 B
150
152
  DTS dist/openai-assistants/hooks/use-assistants.d.ts 551.00 B
151
153
  DTS dist/openai-assistants/utils/index.d.ts 68.00 B
154
+ Waiting for the debugger to disconnect...
155
+ Waiting for the debugger to disconnect...
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # ui
2
2
 
3
+ ## 0.15.0-alpha.4
4
+
5
+ ### Minor Changes
6
+
7
+ - only forward functions if non-empty
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @copilotkit/shared@0.1.0-alpha.4
13
+
3
14
  ## 0.15.0-alpha.3
4
15
 
5
16
  ### Minor Changes
@@ -0,0 +1,58 @@
1
+ import './chunk-MRXNTQOX.mjs';
2
+ import React from 'react';
3
+
4
+ function copilotApiConfigExtrapolator(config) {
5
+ return {
6
+ get chatApiEndpoint() {
7
+ return `${config.chatApiEndpoint}`;
8
+ },
9
+ get chatApiEndpointV2() {
10
+ return `${config.chatApiEndpointV2}`;
11
+ }
12
+ };
13
+ }
14
+ var emptyCopilotContext = {
15
+ entryPoints: {},
16
+ setEntryPoint: () => {
17
+ },
18
+ removeEntryPoint: () => {
19
+ },
20
+ getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug(),
21
+ getFunctionCallHandler: () => returnAndThrowInDebug(),
22
+ getContextString: (documents, categories) => returnAndThrowInDebug(),
23
+ addContext: () => "",
24
+ removeContext: () => {
25
+ },
26
+ getDocumentsContext: (categories) => returnAndThrowInDebug(),
27
+ addDocumentContext: () => returnAndThrowInDebug(),
28
+ removeDocumentContext: () => {
29
+ },
30
+ copilotApiConfig: new class {
31
+ get chatApiEndpoint() {
32
+ throw new Error(
33
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
34
+ );
35
+ }
36
+ get chatApiEndpointV2() {
37
+ throw new Error(
38
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
39
+ );
40
+ }
41
+ get headers() {
42
+ return {};
43
+ }
44
+ get body() {
45
+ return {};
46
+ }
47
+ }()
48
+ };
49
+ var CopilotContext = React.createContext(emptyCopilotContext);
50
+ function returnAndThrowInDebug(value) {
51
+ throw new Error(
52
+ "Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
53
+ );
54
+ }
55
+
56
+ export { CopilotContext, copilotApiConfigExtrapolator };
57
+ //# sourceMappingURL=out.js.map
58
+ //# sourceMappingURL=chunk-3MAIWZNZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,WAAW;AA6CX,SAAS,6BAA6B,QAA0B;AACrE,SAAO;AAAA,IACL,IAAI,kBAA0B;AAC5B,aAAO,GAAG,OAAO;AAAA,IACnB;AAAA,IACA,IAAI,oBAA4B;AAC9B,aAAO,GAAG,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAwBA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,IACA,IAAI,oBAA4B;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,IACA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBAAiB,MAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT","sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the chat API v2.\n */\n chatApiEndpointV2: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Additional body params to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'message': 'Hello, world!'\n * }\n * ```\n */\n body: Record<string, any>;\n}\n\nexport function copilotApiConfigExtrapolator(config: CopilotApiConfig) {\n return {\n get chatApiEndpoint(): string {\n return `${config.chatApiEndpoint}`;\n },\n get chatApiEndpointV2(): string {\n return `${config.chatApiEndpointV2}`;\n },\n };\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // document context\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\",\n );\n }\n get chatApiEndpointV2(): string {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\",\n );\n }\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\",\n );\n return value;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { CopilotContext } from './chunk-3MAIWZNZ.mjs';
2
+ import { useContext, useRef, useEffect } from 'react';
3
+
4
+ function useMakeCopilotReadable(information, parentId, categories) {
5
+ const { addContext, removeContext } = useContext(CopilotContext);
6
+ const idRef = useRef();
7
+ useEffect(() => {
8
+ const id = addContext(information, parentId, categories);
9
+ idRef.current = id;
10
+ return () => {
11
+ removeContext(id);
12
+ };
13
+ }, [information, parentId, addContext, removeContext]);
14
+ return idRef.current;
15
+ }
16
+
17
+ export { useMakeCopilotReadable };
18
+ //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=chunk-45PUEKTG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-make-copilot-readable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAUvC,SAAS,uBACd,aACA,UACA,YACoB;AACpB,QAAM,EAAE,YAAY,cAAc,IAAI,WAAW,cAAc;AAC/D,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,WAAW,aAAa,UAAU,UAAU;AACvD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,oBAAc,EAAE;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,aAAa,UAAU,YAAY,aAAa,CAAC;AAErD,SAAO,MAAM;AACf","sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n * @param information - The information to be added to the Copilot context.\n * @param parentId - The ID of the parent context, if any.\n * @param categories - An array of categories to control which context are visible where. Particularly useful with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n * @returns The ID of the added context.\n */\nexport function useMakeCopilotReadable(\n information: string,\n parentId?: string,\n categories?: string[],\n): string | undefined {\n const { addContext, removeContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addContext(information, parentId, categories);\n idRef.current = id;\n\n return () => {\n removeContext(id);\n };\n }, [information, parentId, addContext, removeContext]);\n\n return idRef.current;\n}\n"]}
@@ -0,0 +1,165 @@
1
+ import { StandardCopilotApiConfig } from './chunk-6N6X7K7T.mjs';
2
+ import { use_tree_default } from './chunk-VUY2K2DI.mjs';
3
+ import { use_flat_category_store_default } from './chunk-YULKJPY3.mjs';
4
+ import { CopilotContext } from './chunk-3MAIWZNZ.mjs';
5
+ import { __objRest, __spreadProps, __spreadValues, __async } from './chunk-MRXNTQOX.mjs';
6
+ import { useState, useCallback } from 'react';
7
+ import { jsx } from 'react/jsx-runtime';
8
+
9
+ function CopilotProvider(_a) {
10
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
11
+ const [entryPoints, setEntryPoints] = useState({});
12
+ const { addElement, removeElement, printTree } = use_tree_default();
13
+ const {
14
+ addElement: addDocument,
15
+ removeElement: removeDocument,
16
+ allElements: allDocuments
17
+ } = use_flat_category_store_default();
18
+ const setEntryPoint = useCallback((id, entryPoint) => {
19
+ setEntryPoints((prevPoints) => {
20
+ return __spreadProps(__spreadValues({}, prevPoints), {
21
+ [id]: entryPoint
22
+ });
23
+ });
24
+ }, []);
25
+ const removeEntryPoint = useCallback((id) => {
26
+ setEntryPoints((prevPoints) => {
27
+ const newPoints = __spreadValues({}, prevPoints);
28
+ delete newPoints[id];
29
+ return newPoints;
30
+ });
31
+ }, []);
32
+ const getContextString = useCallback(
33
+ (documents, categories) => {
34
+ const documentsString = documents.map((document) => {
35
+ return `${document.name} (${document.sourceApplication}):
36
+ ${document.getContents()}`;
37
+ }).join("\n\n");
38
+ const nonDocumentStrings = printTree(categories);
39
+ return `${documentsString}
40
+
41
+ ${nonDocumentStrings}`;
42
+ },
43
+ [printTree]
44
+ );
45
+ const addContext = useCallback(
46
+ (context, parentId, categories = defaultCopilotContextCategories) => {
47
+ return addElement(context, categories, parentId);
48
+ },
49
+ [addElement]
50
+ );
51
+ const removeContext = useCallback(
52
+ (id) => {
53
+ removeElement(id);
54
+ },
55
+ [removeElement]
56
+ );
57
+ const getChatCompletionFunctionDescriptions = useCallback(() => {
58
+ return entryPointsToChatCompletionFunctions(Object.values(entryPoints));
59
+ }, [entryPoints]);
60
+ const getFunctionCallHandler = useCallback(() => {
61
+ return entryPointsToFunctionCallHandler(Object.values(entryPoints));
62
+ }, [entryPoints]);
63
+ const getDocumentsContext = useCallback(
64
+ (categories) => {
65
+ return allDocuments(categories);
66
+ },
67
+ [allDocuments]
68
+ );
69
+ const addDocumentContext = useCallback(
70
+ (documentPointer, categories = defaultCopilotContextCategories) => {
71
+ return addDocument(documentPointer, categories);
72
+ },
73
+ [addDocument]
74
+ );
75
+ const removeDocumentContext = useCallback(
76
+ (documentId) => {
77
+ removeDocument(documentId);
78
+ },
79
+ [removeDocument]
80
+ );
81
+ let copilotApiConfig;
82
+ if ("chatApiEndpoint" in props) {
83
+ copilotApiConfig = new StandardCopilotApiConfig(
84
+ props.chatApiEndpoint,
85
+ props.chatApiEndpointV2 || `${props.chatApiEndpoint}/v2`,
86
+ {},
87
+ {}
88
+ );
89
+ } else {
90
+ copilotApiConfig = props.chatApiConfig;
91
+ }
92
+ return /* @__PURE__ */ jsx(
93
+ CopilotContext.Provider,
94
+ {
95
+ value: {
96
+ entryPoints,
97
+ getChatCompletionFunctionDescriptions,
98
+ getFunctionCallHandler,
99
+ setEntryPoint,
100
+ removeEntryPoint,
101
+ getContextString,
102
+ addContext,
103
+ removeContext,
104
+ getDocumentsContext,
105
+ addDocumentContext,
106
+ removeDocumentContext,
107
+ copilotApiConfig
108
+ },
109
+ children
110
+ }
111
+ );
112
+ }
113
+ var defaultCopilotContextCategories = ["global"];
114
+ function entryPointsToFunctionCallHandler(entryPoints) {
115
+ return (chatMessages, functionCall) => __async(this, null, function* () {
116
+ let entrypointsByFunctionName = {};
117
+ for (let entryPoint of entryPoints) {
118
+ entrypointsByFunctionName[entryPoint.name] = entryPoint;
119
+ }
120
+ const entryPointFunction = entrypointsByFunctionName[functionCall.name || ""];
121
+ if (entryPointFunction) {
122
+ let parsedFunctionCallArguments = [];
123
+ if (functionCall.arguments) {
124
+ parsedFunctionCallArguments = JSON.parse(functionCall.arguments);
125
+ }
126
+ const paramsInCorrectOrder = [];
127
+ for (let arg of entryPointFunction.argumentAnnotations) {
128
+ paramsInCorrectOrder.push(
129
+ parsedFunctionCallArguments[arg.name]
130
+ );
131
+ }
132
+ yield entryPointFunction.implementation(...paramsInCorrectOrder);
133
+ }
134
+ });
135
+ }
136
+ function entryPointsToChatCompletionFunctions(entryPoints) {
137
+ return entryPoints.map(annotatedFunctionToChatCompletionFunction);
138
+ }
139
+ function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
140
+ let parameters = {};
141
+ for (let arg of annotatedFunction.argumentAnnotations) {
142
+ let _a = arg, forwardedArgs = __objRest(_a, ["name", "required"]);
143
+ parameters[arg.name] = forwardedArgs;
144
+ }
145
+ let requiredParameterNames = [];
146
+ for (let arg of annotatedFunction.argumentAnnotations) {
147
+ if (arg.required) {
148
+ requiredParameterNames.push(arg.name);
149
+ }
150
+ }
151
+ let chatCompletionFunction = {
152
+ name: annotatedFunction.name,
153
+ description: annotatedFunction.description,
154
+ parameters: {
155
+ type: "object",
156
+ properties: parameters,
157
+ required: requiredParameterNames
158
+ }
159
+ };
160
+ return chatCompletionFunction;
161
+ }
162
+
163
+ export { CopilotProvider, defaultCopilotContextCategories };
164
+ //# sourceMappingURL=out.js.map
165
+ //# sourceMappingURL=chunk-6LKBKYRJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/copilot-provider/copilot-provider.tsx"],"names":[],"mappings":"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","sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport { useCallback, useState } from \"react\";\nimport { CopilotContext, CopilotApiConfig } from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\nimport { DocumentPointer } from \"../../types\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { StandardCopilotApiConfig } from \"./standard-cpilot-api-config\";\nimport { CopilotProviderProps } from \"./copilot-provider-props\";\n\n/**\n * The CopilotProvider component.\n * This component provides the Copilot context to its children.\n * It can be configured either with a chat API endpoint or a CopilotApiConfig.\n *\n * Example usage:\n * ```\n * <CopilotProvider chatApiEndpoint=\"https://api.copilot.chat\">\n * <App />\n * </CopilotProvider>\n * ```\n *\n * or\n *\n * ```\n * const copilotApiConfig = new StandardCopilotApiConfig(\n * \"https://api.copilot.chat\",\n * \"https://api.copilot.chat/v2\",\n * {},\n * {}\n * );\n *\n * // ...\n *\n * <CopilotProvider chatApiConfig={copilotApiConfig}>\n * <App />\n * </CopilotProvider>\n * ```\n *\n * @param props - The props for the component.\n * @returns The CopilotProvider component.\n */\nexport function CopilotProvider({ children, ...props }: CopilotProviderProps): JSX.Element {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n const [entryPoints, setEntryPoints] = useState<Record<string, AnnotatedFunction<any[]>>>({});\n\n const { addElement, removeElement, printTree } = useTree();\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setEntryPoint = useCallback((id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n }, []);\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${document.sourceApplication}):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree],\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories,\n ) => {\n return addElement(context, categories, parentId);\n },\n [addElement],\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement],\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments],\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument],\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument],\n );\n\n // get the appropriate CopilotApiConfig from the props\n let copilotApiConfig: CopilotApiConfig;\n if (\"chatApiEndpoint\" in props) {\n copilotApiConfig = new StandardCopilotApiConfig(\n props.chatApiEndpoint,\n props.chatApiEndpointV2 || `${props.chatApiEndpoint}/v2`,\n {},\n {},\n );\n } else {\n copilotApiConfig = props.chatApiConfig;\n }\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[],\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<string, AnnotatedFunction<any[]>> = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction = entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let parsedFunctionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n parsedFunctionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n parsedFunctionCallArguments[arg.name as keyof typeof parsedFunctionCallArguments],\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(\n entryPoints: AnnotatedFunction<any[]>[],\n): ChatCompletionCreateParams.Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n\nfunction annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>,\n): ChatCompletionCreateParams.Function {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let arg of annotatedFunction.argumentAnnotations) {\n // isolate the args we should forward inline\n let { name, required, ...forwardedArgs } = arg;\n parameters[arg.name] = forwardedArgs;\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n if (arg.required) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ChatCompletionCreateParams.Function = {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n };\n\n return chatCompletionFunction;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { CopilotContext } from './chunk-3MAIWZNZ.mjs';
2
+ import { useContext, useRef, useEffect } from 'react';
3
+
4
+ function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
5
+ const { addDocumentContext, removeDocumentContext } = useContext(CopilotContext);
6
+ const idRef = useRef();
7
+ useEffect(() => {
8
+ const id = addDocumentContext(document, categories);
9
+ idRef.current = id;
10
+ return () => {
11
+ removeDocumentContext(id);
12
+ };
13
+ }, [addDocumentContext, removeDocumentContext, ...dependencies]);
14
+ return idRef.current;
15
+ }
16
+
17
+ export { useMakeCopilotDocumentReadable };
18
+ //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=chunk-6LNDDH6K.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-make-copilot-document-readable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAWvC,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,WAAW,cAAc;AAC/E,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf","sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ // src/components/copilot-provider/standard-cpilot-api-config.tsx
2
+ var StandardCopilotApiConfig = class {
3
+ constructor(chatApiEndpoint, chatApiEndpointV2, headers, body) {
4
+ this.chatApiEndpoint = chatApiEndpoint;
5
+ this.chatApiEndpointV2 = chatApiEndpointV2;
6
+ this.headers = headers;
7
+ this.body = body;
8
+ }
9
+ };
10
+
11
+ export { StandardCopilotApiConfig };
12
+ //# sourceMappingURL=out.js.map
13
+ //# sourceMappingURL=chunk-6N6X7K7T.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/copilot-provider/standard-cpilot-api-config.tsx"],"names":[],"mappings":";AAUO,IAAM,2BAAN,MAA2D;AAAA,EAMhE,YACE,iBACA,mBACA,SACA,MACA;AACA,SAAK,kBAAkB;AACvB,SAAK,oBAAoB;AACzB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AACF","sourcesContent":["import { CopilotApiConfig } from \"../../context/copilot-context\";\n\n/**\n * A standard implementation of the CopilotApiConfig interface.\n *\n * Pass in the base URL of the chat API, the headers to be sent with each request, and the body to be sent with each request.\n * The rest of the CopilotApiConfig interface is implemented by default.\n *\n */\n\nexport class StandardCopilotApiConfig implements CopilotApiConfig {\n chatApiEndpoint: string;\n chatApiEndpointV2: string;\n headers: Record<string, string>;\n body: Record<string, any>;\n\n constructor(\n chatApiEndpoint: string,\n chatApiEndpointV2: string,\n headers: Record<string, string>,\n body: Record<string, any>,\n ) {\n this.chatApiEndpoint = chatApiEndpoint;\n this.chatApiEndpointV2 = chatApiEndpointV2;\n this.headers = headers;\n this.body = body;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=chunk-7GFKOIO7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=chunk-BABVSMJR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { CopilotContext } from './chunk-3MAIWZNZ.mjs';
2
+ import { useRef, useContext, useMemo, useEffect } from 'react';
3
+ import { nanoid } from 'nanoid';
4
+
5
+ function useMakeCopilotActionable(annotatedFunction, dependencies) {
6
+ const idRef = useRef(nanoid());
7
+ const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);
8
+ const memoizedAnnotatedFunction = useMemo(
9
+ () => ({
10
+ name: annotatedFunction.name,
11
+ description: annotatedFunction.description,
12
+ argumentAnnotations: annotatedFunction.argumentAnnotations,
13
+ implementation: annotatedFunction.implementation
14
+ }),
15
+ dependencies
16
+ );
17
+ useEffect(() => {
18
+ setEntryPoint(idRef.current, memoizedAnnotatedFunction);
19
+ return () => {
20
+ removeEntryPoint(idRef.current);
21
+ };
22
+ }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);
23
+ }
24
+
25
+ export { useMakeCopilotActionable };
26
+ //# sourceMappingURL=out.js.map
27
+ //# sourceMappingURL=chunk-E3P5YZO2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-make-copilot-actionable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,QAAQ,YAAY,WAAW,eAAe;AAGvD,SAAS,cAAc;AAEhB,SAAS,yBACd,mBACA,cACA;AACA,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,cAAc;AAErE,QAAM,4BAA4D;AAAA,IAChE,OAAO;AAAA,MACL,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,qBAAqB,kBAAkB;AAAA,MACvC,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd,kBAAc,MAAM,SAAS,yBAAqD;AAElF,WAAO,MAAM;AACX,uBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,2BAA2B,eAAe,gBAAgB,CAAC;AACjE","sourcesContent":["\"use client\";\n\nimport { useRef, useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { nanoid } from \"nanoid\";\n\nexport function useMakeCopilotActionable<ActionInput extends any[]>(\n annotatedFunction: AnnotatedFunction<ActionInput>,\n dependencies: any[],\n) {\n const idRef = useRef(nanoid()); // generate a unique id\n const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);\n\n const memoizedAnnotatedFunction: AnnotatedFunction<ActionInput> = useMemo(\n () => ({\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n argumentAnnotations: annotatedFunction.argumentAnnotations,\n implementation: annotatedFunction.implementation,\n }),\n dependencies,\n );\n\n useEffect(() => {\n setEntryPoint(idRef.current, memoizedAnnotatedFunction as AnnotatedFunction<any[]>);\n\n return () => {\n removeEntryPoint(idRef.current);\n };\n }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);\n}\n"]}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=chunk-EFZPSZWO.mjs.map