@copilotkit/react-core 1.5.1-next.3 → 1.5.1-next.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 (228) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/package.json +5 -5
  3. package/dist/chunk-2KCEHGSI.mjs +0 -192
  4. package/dist/chunk-2KCEHGSI.mjs.map +0 -1
  5. package/dist/chunk-5FHSUKQL.mjs +0 -70
  6. package/dist/chunk-5FHSUKQL.mjs.map +0 -1
  7. package/dist/chunk-6OR25P32.mjs +0 -426
  8. package/dist/chunk-6OR25P32.mjs.map +0 -1
  9. package/dist/chunk-6U3UH3KO.mjs +0 -140
  10. package/dist/chunk-6U3UH3KO.mjs.map +0 -1
  11. package/dist/chunk-DCTJZ742.mjs +0 -22
  12. package/dist/chunk-DCTJZ742.mjs.map +0 -1
  13. package/dist/chunk-DDVXFNYA.mjs +0 -126
  14. package/dist/chunk-DDVXFNYA.mjs.map +0 -1
  15. package/dist/chunk-EFZPSZWO.mjs +0 -1
  16. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  17. package/dist/chunk-FXHKK52V.mjs +0 -119
  18. package/dist/chunk-FXHKK52V.mjs.map +0 -1
  19. package/dist/chunk-H4VZMKR6.mjs +0 -23
  20. package/dist/chunk-H4VZMKR6.mjs.map +0 -1
  21. package/dist/chunk-H7LSKIDK.mjs +0 -167
  22. package/dist/chunk-H7LSKIDK.mjs.map +0 -1
  23. package/dist/chunk-JDQCJCAQ.mjs +0 -295
  24. package/dist/chunk-JDQCJCAQ.mjs.map +0 -1
  25. package/dist/chunk-L34MHAXR.mjs +0 -1
  26. package/dist/chunk-L34MHAXR.mjs.map +0 -1
  27. package/dist/chunk-LODRWFMB.mjs +0 -75
  28. package/dist/chunk-LODRWFMB.mjs.map +0 -1
  29. package/dist/chunk-LUGEI4YQ.mjs +0 -1
  30. package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
  31. package/dist/chunk-MLAS4QUR.mjs +0 -18
  32. package/dist/chunk-MLAS4QUR.mjs.map +0 -1
  33. package/dist/chunk-MWZO6TUR.mjs +0 -91
  34. package/dist/chunk-MWZO6TUR.mjs.map +0 -1
  35. package/dist/chunk-O7ARI5CV.mjs +0 -31
  36. package/dist/chunk-O7ARI5CV.mjs.map +0 -1
  37. package/dist/chunk-ODN4H66E.mjs +0 -31
  38. package/dist/chunk-ODN4H66E.mjs.map +0 -1
  39. package/dist/chunk-QDGDXRRJ.mjs +0 -28
  40. package/dist/chunk-QDGDXRRJ.mjs.map +0 -1
  41. package/dist/chunk-SKC7AJIV.mjs +0 -61
  42. package/dist/chunk-SKC7AJIV.mjs.map +0 -1
  43. package/dist/chunk-XINZBP3J.mjs +0 -49
  44. package/dist/chunk-XINZBP3J.mjs.map +0 -1
  45. package/dist/chunk-XXR4QFAQ.mjs +0 -29
  46. package/dist/chunk-XXR4QFAQ.mjs.map +0 -1
  47. package/dist/chunk-YPSGKPDA.mjs +0 -1
  48. package/dist/chunk-YPSGKPDA.mjs.map +0 -1
  49. package/dist/components/copilot-provider/copilot-messages.d.ts +0 -7
  50. package/dist/components/copilot-provider/copilot-messages.js +0 -80
  51. package/dist/components/copilot-provider/copilot-messages.js.map +0 -1
  52. package/dist/components/copilot-provider/copilot-messages.mjs +0 -9
  53. package/dist/components/copilot-provider/copilot-messages.mjs.map +0 -1
  54. package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -72
  55. package/dist/components/copilot-provider/copilotkit-props.js +0 -19
  56. package/dist/components/copilot-provider/copilotkit-props.js.map +0 -1
  57. package/dist/components/copilot-provider/copilotkit-props.mjs +0 -1
  58. package/dist/components/copilot-provider/copilotkit-props.mjs.map +0 -1
  59. package/dist/components/copilot-provider/copilotkit.d.ts +0 -9
  60. package/dist/components/copilot-provider/copilotkit.js +0 -861
  61. package/dist/components/copilot-provider/copilotkit.js.map +0 -1
  62. package/dist/components/copilot-provider/copilotkit.mjs +0 -21
  63. package/dist/components/copilot-provider/copilotkit.mjs.map +0 -1
  64. package/dist/components/copilot-provider/index.d.ts +0 -4
  65. package/dist/components/copilot-provider/index.js +0 -861
  66. package/dist/components/copilot-provider/index.js.map +0 -1
  67. package/dist/components/copilot-provider/index.mjs +0 -19
  68. package/dist/components/copilot-provider/index.mjs.map +0 -1
  69. package/dist/components/index.d.ts +0 -4
  70. package/dist/components/index.js +0 -861
  71. package/dist/components/index.js.map +0 -1
  72. package/dist/components/index.mjs +0 -19
  73. package/dist/components/index.mjs.map +0 -1
  74. package/dist/components/toast/exclamation-mark-icon.d.ts +0 -9
  75. package/dist/components/toast/exclamation-mark-icon.js +0 -55
  76. package/dist/components/toast/exclamation-mark-icon.js.map +0 -1
  77. package/dist/components/toast/exclamation-mark-icon.mjs +0 -8
  78. package/dist/components/toast/exclamation-mark-icon.mjs.map +0 -1
  79. package/dist/components/toast/toast-provider.d.ts +0 -29
  80. package/dist/components/toast/toast-provider.js +0 -255
  81. package/dist/components/toast/toast-provider.js.map +0 -1
  82. package/dist/components/toast/toast-provider.mjs +0 -11
  83. package/dist/components/toast/toast-provider.mjs.map +0 -1
  84. package/dist/context/copilot-context.d.ts +0 -109
  85. package/dist/context/copilot-context.js +0 -126
  86. package/dist/context/copilot-context.js.map +0 -1
  87. package/dist/context/copilot-context.mjs +0 -10
  88. package/dist/context/copilot-context.mjs.map +0 -1
  89. package/dist/context/copilot-messages-context.d.ts +0 -15
  90. package/dist/context/copilot-messages-context.js +0 -57
  91. package/dist/context/copilot-messages-context.js.map +0 -1
  92. package/dist/context/copilot-messages-context.mjs +0 -10
  93. package/dist/context/copilot-messages-context.mjs.map +0 -1
  94. package/dist/context/index.d.ts +0 -11
  95. package/dist/context/index.js +0 -149
  96. package/dist/context/index.js.map +0 -1
  97. package/dist/context/index.mjs +0 -17
  98. package/dist/context/index.mjs.map +0 -1
  99. package/dist/hooks/index.d.ts +0 -19
  100. package/dist/hooks/index.js +0 -897
  101. package/dist/hooks/index.js.map +0 -1
  102. package/dist/hooks/index.mjs +0 -44
  103. package/dist/hooks/index.mjs.map +0 -1
  104. package/dist/hooks/use-chat.d.ts +0 -92
  105. package/dist/hooks/use-chat.js +0 -360
  106. package/dist/hooks/use-chat.js.map +0 -1
  107. package/dist/hooks/use-chat.mjs +0 -11
  108. package/dist/hooks/use-chat.mjs.map +0 -1
  109. package/dist/hooks/use-coagent-state-render.d.ts +0 -60
  110. package/dist/hooks/use-coagent-state-render.js +0 -160
  111. package/dist/hooks/use-coagent-state-render.js.map +0 -1
  112. package/dist/hooks/use-coagent-state-render.mjs +0 -9
  113. package/dist/hooks/use-coagent-state-render.mjs.map +0 -1
  114. package/dist/hooks/use-coagent.d.ts +0 -186
  115. package/dist/hooks/use-coagent.js +0 -726
  116. package/dist/hooks/use-coagent.js.map +0 -1
  117. package/dist/hooks/use-coagent.mjs +0 -21
  118. package/dist/hooks/use-coagent.mjs.map +0 -1
  119. package/dist/hooks/use-copilot-action.d.ts +0 -130
  120. package/dist/hooks/use-copilot-action.js +0 -219
  121. package/dist/hooks/use-copilot-action.js.map +0 -1
  122. package/dist/hooks/use-copilot-action.mjs +0 -9
  123. package/dist/hooks/use-copilot-action.mjs.map +0 -1
  124. package/dist/hooks/use-copilot-chat.d.ts +0 -36
  125. package/dist/hooks/use-copilot-chat.js +0 -623
  126. package/dist/hooks/use-copilot-chat.js.map +0 -1
  127. package/dist/hooks/use-copilot-chat.mjs +0 -22
  128. package/dist/hooks/use-copilot-chat.mjs.map +0 -1
  129. package/dist/hooks/use-copilot-readable.d.ts +0 -33
  130. package/dist/hooks/use-copilot-readable.js +0 -146
  131. package/dist/hooks/use-copilot-readable.js.map +0 -1
  132. package/dist/hooks/use-copilot-readable.mjs +0 -9
  133. package/dist/hooks/use-copilot-readable.mjs.map +0 -1
  134. package/dist/hooks/use-copilot-runtime-client.d.ts +0 -5
  135. package/dist/hooks/use-copilot-runtime-client.js +0 -76
  136. package/dist/hooks/use-copilot-runtime-client.js.map +0 -1
  137. package/dist/hooks/use-copilot-runtime-client.mjs +0 -10
  138. package/dist/hooks/use-copilot-runtime-client.mjs.map +0 -1
  139. package/dist/hooks/use-flat-category-store.d.ts +0 -9
  140. package/dist/hooks/use-flat-category-store.js +0 -90
  141. package/dist/hooks/use-flat-category-store.js.map +0 -1
  142. package/dist/hooks/use-flat-category-store.mjs +0 -8
  143. package/dist/hooks/use-flat-category-store.mjs.map +0 -1
  144. package/dist/hooks/use-make-copilot-document-readable.d.ts +0 -12
  145. package/dist/hooks/use-make-copilot-document-readable.js +0 -141
  146. package/dist/hooks/use-make-copilot-document-readable.js.map +0 -1
  147. package/dist/hooks/use-make-copilot-document-readable.mjs +0 -9
  148. package/dist/hooks/use-make-copilot-document-readable.mjs.map +0 -1
  149. package/dist/hooks/use-tree.d.ts +0 -18
  150. package/dist/hooks/use-tree.js +0 -172
  151. package/dist/hooks/use-tree.js.map +0 -1
  152. package/dist/hooks/use-tree.mjs +0 -8
  153. package/dist/hooks/use-tree.mjs.map +0 -1
  154. package/dist/index.d.ts +0 -26
  155. package/dist/index.js +0 -1810
  156. package/dist/index.js.map +0 -1
  157. package/dist/index.mjs +0 -71
  158. package/dist/index.mjs.map +0 -1
  159. package/dist/lib/copilot-task.d.ts +0 -92
  160. package/dist/lib/copilot-task.js +0 -157
  161. package/dist/lib/copilot-task.js.map +0 -1
  162. package/dist/lib/copilot-task.mjs +0 -18
  163. package/dist/lib/copilot-task.mjs.map +0 -1
  164. package/dist/lib/index.d.ts +0 -11
  165. package/dist/lib/index.js +0 -159
  166. package/dist/lib/index.js.map +0 -1
  167. package/dist/lib/index.mjs +0 -19
  168. package/dist/lib/index.mjs.map +0 -1
  169. package/dist/types/chat-suggestion-configuration.d.ts +0 -22
  170. package/dist/types/chat-suggestion-configuration.js +0 -19
  171. package/dist/types/chat-suggestion-configuration.js.map +0 -1
  172. package/dist/types/chat-suggestion-configuration.mjs +0 -1
  173. package/dist/types/chat-suggestion-configuration.mjs.map +0 -1
  174. package/dist/types/coagent-action.d.ts +0 -29
  175. package/dist/types/coagent-action.js +0 -19
  176. package/dist/types/coagent-action.js.map +0 -1
  177. package/dist/types/coagent-action.mjs +0 -1
  178. package/dist/types/coagent-action.mjs.map +0 -1
  179. package/dist/types/coagent-state.d.ts +0 -11
  180. package/dist/types/coagent-state.js +0 -19
  181. package/dist/types/coagent-state.js.map +0 -1
  182. package/dist/types/coagent-state.mjs +0 -1
  183. package/dist/types/coagent-state.mjs.map +0 -1
  184. package/dist/types/document-pointer.d.ts +0 -9
  185. package/dist/types/document-pointer.js +0 -19
  186. package/dist/types/document-pointer.js.map +0 -1
  187. package/dist/types/document-pointer.mjs +0 -1
  188. package/dist/types/document-pointer.mjs.map +0 -1
  189. package/dist/types/frontend-action.d.ts +0 -107
  190. package/dist/types/frontend-action.js +0 -19
  191. package/dist/types/frontend-action.js.map +0 -1
  192. package/dist/types/frontend-action.mjs +0 -1
  193. package/dist/types/frontend-action.mjs.map +0 -1
  194. package/dist/types/index.d.ts +0 -6
  195. package/dist/types/index.js +0 -19
  196. package/dist/types/index.js.map +0 -1
  197. package/dist/types/index.mjs +0 -2
  198. package/dist/types/index.mjs.map +0 -1
  199. package/dist/types/system-message.d.ts +0 -3
  200. package/dist/types/system-message.js +0 -19
  201. package/dist/types/system-message.js.map +0 -1
  202. package/dist/types/system-message.mjs +0 -1
  203. package/dist/types/system-message.mjs.map +0 -1
  204. package/dist/utils/dev-console.d.ts +0 -3
  205. package/dist/utils/dev-console.js +0 -42
  206. package/dist/utils/dev-console.js.map +0 -1
  207. package/dist/utils/dev-console.mjs +0 -8
  208. package/dist/utils/dev-console.mjs.map +0 -1
  209. package/dist/utils/extract.d.ts +0 -42
  210. package/dist/utils/extract.js +0 -190
  211. package/dist/utils/extract.js.map +0 -1
  212. package/dist/utils/extract.mjs +0 -17
  213. package/dist/utils/extract.mjs.map +0 -1
  214. package/dist/utils/index.d.ts +0 -13
  215. package/dist/utils/index.js +0 -208
  216. package/dist/utils/index.js.map +0 -1
  217. package/dist/utils/index.mjs +0 -20
  218. package/dist/utils/index.mjs.map +0 -1
  219. package/dist/utils/utils.d.ts +0 -2
  220. package/dist/utils/utils.js +0 -19
  221. package/dist/utils/utils.js.map +0 -1
  222. package/dist/utils/utils.mjs +0 -1
  223. package/dist/utils/utils.mjs.map +0 -1
  224. package/dist/utils/utils.test.d.ts +0 -2
  225. package/dist/utils/utils.test.js +0 -9
  226. package/dist/utils/utils.test.js.map +0 -1
  227. package/dist/utils/utils.test.mjs +0 -7
  228. package/dist/utils/utils.test.mjs.map +0 -1
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __async = (__this, __arguments, generator) => {
20
- return new Promise((resolve, reject) => {
21
- var fulfilled = (value) => {
22
- try {
23
- step(generator.next(value));
24
- } catch (e) {
25
- reject(e);
26
- }
27
- };
28
- var rejected = (value) => {
29
- try {
30
- step(generator.throw(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- };
35
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
- step((generator = generator.apply(__this, __arguments)).next());
37
- });
38
- };
39
-
40
- // src/lib/copilot-task.ts
41
- var copilot_task_exports = {};
42
- __export(copilot_task_exports, {
43
- CopilotTask: () => CopilotTask
44
- });
45
- module.exports = __toCommonJS(copilot_task_exports);
46
- var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
47
-
48
- // src/components/copilot-provider/copilotkit.tsx
49
- var import_react = require("react");
50
- var import_react_dom = require("react-dom");
51
- var import_shared = require("@copilotkit/shared");
52
- var import_jsx_runtime = require("react/jsx-runtime");
53
- var defaultCopilotContextCategories = ["global"];
54
-
55
- // src/lib/copilot-task.ts
56
- var import_shared2 = require("@copilotkit/shared");
57
- var CopilotTask = class {
58
- constructor(config) {
59
- this.instructions = config.instructions;
60
- this.actions = config.actions || [];
61
- this.includeCopilotReadable = config.includeCopilotReadable !== false;
62
- this.includeCopilotActions = config.includeCopilotActions !== false;
63
- }
64
- /**
65
- * Run the task.
66
- * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.
67
- * @param data The data to use for the task.
68
- */
69
- run(context, data) {
70
- return __async(this, null, function* () {
71
- var _a, _b;
72
- const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};
73
- for (const fn of this.actions) {
74
- actions[fn.name] = fn;
75
- }
76
- let contextString = "";
77
- if (data) {
78
- contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
79
- }
80
- if (this.includeCopilotReadable) {
81
- contextString += context.getContextString([], defaultCopilotContextCategories);
82
- }
83
- const systemMessage = new import_runtime_client_gql.TextMessage({
84
- content: taskSystemMessage(contextString, this.instructions),
85
- role: import_runtime_client_gql.Role.System
86
- });
87
- const messages = [systemMessage];
88
- const runtimeClient = new import_runtime_client_gql.CopilotRuntimeClient({
89
- url: context.copilotApiConfig.chatApiEndpoint,
90
- publicApiKey: context.copilotApiConfig.publicApiKey,
91
- headers: context.copilotApiConfig.headers,
92
- credentials: context.copilotApiConfig.credentials
93
- });
94
- const response = yield runtimeClient.generateCopilotResponse({
95
- data: {
96
- frontend: {
97
- actions: Object.values(actions).map((action) => ({
98
- name: action.name,
99
- description: action.description || "",
100
- jsonSchema: JSON.stringify((0, import_shared2.actionParametersToJsonSchema)(action.parameters || []))
101
- })),
102
- url: window.location.href
103
- },
104
- messages: (0, import_runtime_client_gql.convertMessagesToGqlInput)((0, import_runtime_client_gql.filterAgentStateMessages)(messages)),
105
- metadata: {
106
- requestType: import_runtime_client_gql.CopilotRequestType.Task
107
- },
108
- forwardedParameters: {
109
- toolChoice: "required"
110
- }
111
- },
112
- properties: context.copilotApiConfig.properties
113
- }).toPromise();
114
- const functionCallHandler = context.getFunctionCallHandler(actions);
115
- const functionCalls = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
116
- ((_b = (_a = response.data) == null ? void 0 : _a.generateCopilotResponse) == null ? void 0 : _b.messages) || []
117
- ).filter((m) => m.isActionExecutionMessage());
118
- for (const functionCall of functionCalls) {
119
- yield functionCallHandler({
120
- messages,
121
- name: functionCall.name,
122
- args: functionCall.arguments
123
- });
124
- }
125
- });
126
- }
127
- };
128
- function taskSystemMessage(contextString, instructions) {
129
- return `
130
- Please act as an efficient, competent, conscientious, and industrious professional assistant.
131
-
132
- Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
133
- Always be polite and respectful, and prefer brevity over verbosity.
134
-
135
- The user has provided you with the following context:
136
- \`\`\`
137
- ${contextString}
138
- \`\`\`
139
-
140
- They have also provided you with functions you can call to initiate actions on their behalf.
141
-
142
- Please assist them as best you can.
143
-
144
- This is not a conversation, so please do not ask questions. Just call a function without saying anything else.
145
-
146
- The user has given you the following task to complete:
147
-
148
- \`\`\`
149
- ${instructions}
150
- \`\`\`
151
- `;
152
- }
153
- // Annotate the CommonJS export names for ESM import in node:
154
- 0 && (module.exports = {
155
- CopilotTask
156
- });
157
- //# sourceMappingURL=copilot-task.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/copilot-task.ts","../../src/components/copilot-provider/copilotkit.tsx"],"sourcesContent":["/**\n * This class is used to execute one-off tasks, for example on button press. It can use the context available via [useCopilotReadable](/reference/hooks/useCopilotReadable) and the actions provided by [useCopilotAction](/reference/hooks/useCopilotAction), or you can provide your own context and actions.\n *\n * ## Example\n * In the simplest case, use CopilotTask in the context of your app by giving it instructions on what to do.\n *\n * ```tsx\n * import { CopilotTask, useCopilotContext } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const context = useCopilotContext();\n *\n * const task = new CopilotTask({\n * instructions: \"Set a random message\",\n * actions: [\n * {\n * name: \"setMessage\",\n * description: \"Set the message.\",\n * argumentAnnotations: [\n * {\n * name: \"message\",\n * type: \"string\",\n * description:\n * \"A message to display.\",\n * required: true,\n * },\n * ],\n * }\n * ]\n * });\n *\n * const executeTask = async () => {\n * await task.run(context, action);\n * }\n *\n * return (\n * <>\n * <button onClick={executeTask}>\n * Execute task\n * </button>\n * </>\n * )\n * }\n * ```\n *\n * Have a look at the [Presentation Example App](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/examples/next-openai/src/app/presentation/page.tsx) for a more complete example.\n */\n\nimport {\n ActionExecutionMessage,\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n CopilotRequestType,\n} from \"@copilotkit/runtime-client-gql\";\nimport { FrontendAction } from \"../types/frontend-action\";\nimport { CopilotContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\n\nexport interface CopilotTaskConfig {\n /**\n * The instructions to be given to the assistant.\n */\n instructions: string;\n /**\n * An array of action definitions that can be called.\n */\n actions?: FrontendAction<any>[];\n /**\n * Whether to include the copilot readable context in the task.\n */\n includeCopilotReadable?: boolean;\n\n /**\n * Whether to include actions defined via useCopilotAction in the task.\n */\n includeCopilotActions?: boolean;\n}\n\nexport class CopilotTask<T = any> {\n private instructions: string;\n private actions: FrontendAction<any>[];\n private includeCopilotReadable: boolean;\n private includeCopilotActions: boolean;\n\n constructor(config: CopilotTaskConfig) {\n this.instructions = config.instructions;\n this.actions = config.actions || [];\n this.includeCopilotReadable = config.includeCopilotReadable !== false;\n this.includeCopilotActions = config.includeCopilotActions !== false;\n }\n\n /**\n * Run the task.\n * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.\n * @param data The data to use for the task.\n */\n async run(context: CopilotContextParams, data?: T): Promise<void> {\n const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};\n\n // merge functions into entry points\n for (const fn of this.actions) {\n actions[fn.name] = fn;\n }\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (this.includeCopilotReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage = new TextMessage({\n content: taskSystemMessage(contextString, this.instructions),\n role: Role.System,\n });\n\n const messages: Message[] = [systemMessage];\n\n const runtimeClient = new CopilotRuntimeClient({\n url: context.copilotApiConfig.chatApiEndpoint,\n publicApiKey: context.copilotApiConfig.publicApiKey,\n headers: context.copilotApiConfig.headers,\n credentials: context.copilotApiConfig.credentials,\n });\n\n const response = await runtimeClient\n .generateCopilotResponse({\n data: {\n frontend: {\n actions: Object.values(actions).map((action) => ({\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || [])),\n })),\n url: window.location.href,\n },\n messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),\n metadata: {\n requestType: CopilotRequestType.Task,\n },\n forwardedParameters: {\n toolChoice: \"required\",\n },\n },\n properties: context.copilotApiConfig.properties,\n })\n .toPromise();\n\n const functionCallHandler = context.getFunctionCallHandler(actions);\n const functionCalls = convertGqlOutputToMessages(\n response.data?.generateCopilotResponse?.messages || [],\n ).filter((m): m is ActionExecutionMessage => m.isActionExecutionMessage());\n\n for (const functionCall of functionCalls) {\n await functionCallHandler({\n messages,\n name: functionCall.name,\n args: functionCall.arguments,\n });\n }\n }\n}\n\nfunction taskSystemMessage(contextString: string, instructions: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call a function without saying anything else.\n\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n`;\n}\n","/**\n * This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.\n *\n * ## Example\n *\n * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).\n *\n * ```tsx\n * import { CopilotKit } from \"@copilotkit/react-core\";\n *\n * <CopilotKit runtimeUrl=\"<your-runtime-url>\">\n * // ... your app ...\n * </CopilotKit>\n * ```\n */\n\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n CopilotContext,\n CopilotApiConfig,\n ChatComponentsCache,\n AgentSession,\n} from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { CopilotChatSuggestionConfiguration, DocumentPointer } from \"../../types\";\nimport { flushSync } from \"react-dom\";\nimport {\n COPILOT_CLOUD_CHAT_URL,\n CopilotCloudConfig,\n FunctionCallHandler,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n} from \"@copilotkit/shared\";\n\nimport { FrontendAction } from \"../../types/frontend-action\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\nimport { CoAgentStateRender } from \"../../types/coagent-action\";\nimport { CoagentState } from \"../../types/coagent-state\";\nimport { CopilotMessages } from \"./copilot-messages\";\nimport { ToastProvider } from \"../toast/toast-provider\";\nimport { useCopilotRuntimeClient } from \"../../hooks/use-copilot-runtime-client\";\nimport { shouldShowDevConsole } from \"../../utils\";\n\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n const showDevConsole = props.showDevConsole === undefined ? \"auto\" : props.showDevConsole;\n const enabled = shouldShowDevConsole(showDevConsole);\n return (\n <ToastProvider enabled={enabled}>\n <CopilotKitInternal {...props}>{children}</CopilotKitInternal>\n </ToastProvider>\n );\n}\n\nexport function CopilotKitInternal({ children, ...props }: CopilotKitProps) {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n if (!props.runtimeUrl && !props.publicApiKey) {\n throw new Error(\n \"Please provide either a runtimeUrl or a publicApiKey to the CopilotKit component.\",\n );\n }\n\n const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;\n\n const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});\n const [coAgentStateRenders, setCoAgentStateRenders] = useState<\n Record<string, CoAgentStateRender<any>>\n >({});\n const chatComponentsCache = useRef<ChatComponentsCache>({\n actions: {},\n coAgentStateRenders: {},\n });\n const { addElement, removeElement, printTree } = useTree();\n const [isLoading, setIsLoading] = useState(false);\n const [chatInstructions, setChatInstructions] = useState(\"\");\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setAction = useCallback((id: string, action: FrontendAction<any>) => {\n setActions((prevPoints) => {\n return {\n ...prevPoints,\n [id]: action,\n };\n });\n }, []);\n\n const removeAction = useCallback((id: string) => {\n setActions((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {\n setCoAgentStateRenders((prevPoints) => {\n return {\n ...prevPoints,\n [id]: stateRender,\n };\n });\n }, []);\n\n const removeCoAgentStateRender = useCallback((id: string) => {\n setCoAgentStateRenders((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 getFunctionCallHandler = useCallback(\n (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));\n },\n [actions],\n );\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 if (!props.publicApiKey) {\n if (props.cloudRestrictToTopic) {\n throw new Error(\n \"To use the cloudRestrictToTopic feature, please sign up at https://copilotkit.ai and provide a publicApiKey.\",\n );\n }\n }\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = useMemo(() => {\n let cloud: CopilotCloudConfig | undefined = undefined;\n if (props.publicApiKey) {\n cloud = {\n guardrails: {\n input: {\n restrictToTopic: {\n enabled: props.cloudRestrictToTopic ? true : false,\n validTopics: props.cloudRestrictToTopic?.validTopics || [],\n invalidTopics: props.cloudRestrictToTopic?.invalidTopics || [],\n },\n },\n },\n };\n }\n\n return {\n publicApiKey: props.publicApiKey,\n ...(cloud ? { cloud } : {}),\n chatApiEndpoint: chatApiEndpoint,\n headers: props.headers || {},\n properties: props.properties || {},\n transcribeAudioUrl: props.transcribeAudioUrl,\n textToSpeechUrl: props.textToSpeechUrl,\n credentials: props.credentials,\n };\n }, [\n props.publicApiKey,\n props.headers,\n props.properties,\n props.transcribeAudioUrl,\n props.textToSpeechUrl,\n props.credentials,\n props.cloudRestrictToTopic,\n ]);\n\n const headers = {\n ...(copilotApiConfig.headers || {}),\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n };\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n });\n\n const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{\n [key: string]: CopilotChatSuggestionConfiguration;\n }>({});\n\n const addChatSuggestionConfiguration = (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => {\n setChatSuggestionConfiguration((prev) => ({ ...prev, [id]: suggestion }));\n };\n\n const removeChatSuggestionConfiguration = (id: string) => {\n setChatSuggestionConfiguration((prev) => {\n const { [id]: _, ...rest } = prev;\n return rest;\n });\n };\n\n const [coagentStates, setCoagentStates] = useState<Record<string, CoagentState>>({});\n let initialAgentSession: AgentSession | null = null;\n if (props.agent) {\n initialAgentSession = {\n agentName: props.agent,\n };\n }\n\n const [agentSession, setAgentSession] = useState<AgentSession | null>(initialAgentSession);\n\n const showDevConsole = props.showDevConsole === undefined ? \"auto\" : props.showDevConsole;\n\n return (\n <CopilotContext.Provider\n value={{\n actions,\n chatComponentsCache,\n getFunctionCallHandler,\n setAction,\n removeAction,\n coAgentStateRenders,\n setCoAgentStateRender,\n removeCoAgentStateRender,\n getContextString,\n addContext,\n removeContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n isLoading,\n setIsLoading,\n chatSuggestionConfiguration,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n chatInstructions,\n setChatInstructions,\n showDevConsole,\n coagentStates,\n setCoagentStates,\n agentSession,\n setAgentSession,\n runtimeClient,\n }}\n >\n <CopilotMessages>{children}</CopilotMessages>\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {\n return async ({ messages, name, args }) => {\n let actionsByFunctionName: Record<string, FrontendAction<any>> = {};\n for (let action of actions) {\n actionsByFunctionName[action.name] = action;\n }\n\n const action = actionsByFunctionName[name];\n let result: any = undefined;\n if (action) {\n await new Promise<void>((resolve, reject) => {\n flushSync(async () => {\n try {\n result = await action.handler?.(args);\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n });\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n return result;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDA,gCAUO;;;AC1CP,mBAAuD;AASvD,uBAA0B;AAC1B,oBAKO;AAiBD;AAiQC,IAAM,kCAAkC,CAAC,QAAQ;;;ADlPxD,IAAAA,iBAA6C;AAsBtC,IAAM,cAAN,MAA2B;AAAA,EAMhC,YAAY,QAA2B;AACrC,SAAK,eAAe,OAAO;AAC3B,SAAK,UAAU,OAAO,WAAW,CAAC;AAClC,SAAK,yBAAyB,OAAO,2BAA2B;AAChE,SAAK,wBAAwB,OAAO,0BAA0B;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOM,IAAI,SAA+B,MAAyB;AAAA;AAvGpE;AAwGI,YAAM,UAAU,KAAK,wBAAwB,OAAO,OAAO,CAAC,GAAG,QAAQ,OAAO,IAAI,CAAC;AAGnF,iBAAW,MAAM,KAAK,SAAS;AAC7B,gBAAQ,GAAG,IAAI,IAAI;AAAA,MACrB;AAEA,UAAI,gBAAgB;AAEpB,UAAI,MAAM;AACR,yBAAiB,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,IAAI,KAAK;AAAA,MAC7E;AAEA,UAAI,KAAK,wBAAwB;AAC/B,yBAAiB,QAAQ,iBAAiB,CAAC,GAAG,+BAA+B;AAAA,MAC/E;AAEA,YAAM,gBAAgB,IAAI,sCAAY;AAAA,QACpC,SAAS,kBAAkB,eAAe,KAAK,YAAY;AAAA,QAC3D,MAAM,+BAAK;AAAA,MACb,CAAC;AAED,YAAM,WAAsB,CAAC,aAAa;AAE1C,YAAM,gBAAgB,IAAI,+CAAqB;AAAA,QAC7C,KAAK,QAAQ,iBAAiB;AAAA,QAC9B,cAAc,QAAQ,iBAAiB;AAAA,QACvC,SAAS,QAAQ,iBAAiB;AAAA,QAClC,aAAa,QAAQ,iBAAiB;AAAA,MACxC,CAAC;AAED,YAAM,WAAW,MAAM,cACpB,wBAAwB;AAAA,QACvB,MAAM;AAAA,UACJ,UAAU;AAAA,YACR,SAAS,OAAO,OAAO,OAAO,EAAE,IAAI,CAAC,YAAY;AAAA,cAC/C,MAAM,OAAO;AAAA,cACb,aAAa,OAAO,eAAe;AAAA,cACnC,YAAY,KAAK,cAAU,6CAA6B,OAAO,cAAc,CAAC,CAAC,CAAC;AAAA,YAClF,EAAE;AAAA,YACF,KAAK,OAAO,SAAS;AAAA,UACvB;AAAA,UACA,cAAU,yDAA0B,oDAAyB,QAAQ,CAAC;AAAA,UACtE,UAAU;AAAA,YACR,aAAa,6CAAmB;AAAA,UAClC;AAAA,UACA,qBAAqB;AAAA,YACnB,YAAY;AAAA,UACd;AAAA,QACF;AAAA,QACA,YAAY,QAAQ,iBAAiB;AAAA,MACvC,CAAC,EACA,UAAU;AAEb,YAAM,sBAAsB,QAAQ,uBAAuB,OAAO;AAClE,YAAM,oBAAgB;AAAA,UACpB,oBAAS,SAAT,mBAAe,4BAAf,mBAAwC,aAAY,CAAC;AAAA,MACvD,EAAE,OAAO,CAAC,MAAmC,EAAE,yBAAyB,CAAC;AAEzE,iBAAW,gBAAgB,eAAe;AACxC,cAAM,oBAAoB;AAAA,UACxB;AAAA,UACA,MAAM,aAAa;AAAA,UACnB,MAAM,aAAa;AAAA,QACrB,CAAC;AAAA,MACH;AAAA,IACF;AAAA;AACF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AAAA;AAAA;AAGF;","names":["import_shared"]}
@@ -1,18 +0,0 @@
1
- import {
2
- CopilotTask
3
- } from "../chunk-FXHKK52V.mjs";
4
- import "../chunk-6OR25P32.mjs";
5
- import "../chunk-5FHSUKQL.mjs";
6
- import "../chunk-6U3UH3KO.mjs";
7
- import "../chunk-XXR4QFAQ.mjs";
8
- import "../chunk-ODN4H66E.mjs";
9
- import "../chunk-2KCEHGSI.mjs";
10
- import "../chunk-O7ARI5CV.mjs";
11
- import "../chunk-LODRWFMB.mjs";
12
- import "../chunk-DCTJZ742.mjs";
13
- import "../chunk-MLAS4QUR.mjs";
14
- import "../chunk-SKC7AJIV.mjs";
15
- export {
16
- CopilotTask
17
- };
18
- //# sourceMappingURL=copilot-task.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,11 +0,0 @@
1
- export { CopilotTask, CopilotTaskConfig } from './copilot-task.js';
2
- import '../types/frontend-action.js';
3
- import '@copilotkit/shared';
4
- import 'react';
5
- import '../context/copilot-context.js';
6
- import '../hooks/use-tree.js';
7
- import '../types/document-pointer.js';
8
- import '../types/chat-suggestion-configuration.js';
9
- import '../types/coagent-action.js';
10
- import '../types/coagent-state.js';
11
- import '@copilotkit/runtime-client-gql';
package/dist/lib/index.js DELETED
@@ -1,159 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __async = (__this, __arguments, generator) => {
20
- return new Promise((resolve, reject) => {
21
- var fulfilled = (value) => {
22
- try {
23
- step(generator.next(value));
24
- } catch (e) {
25
- reject(e);
26
- }
27
- };
28
- var rejected = (value) => {
29
- try {
30
- step(generator.throw(value));
31
- } catch (e) {
32
- reject(e);
33
- }
34
- };
35
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
- step((generator = generator.apply(__this, __arguments)).next());
37
- });
38
- };
39
-
40
- // src/lib/index.ts
41
- var lib_exports = {};
42
- __export(lib_exports, {
43
- CopilotTask: () => CopilotTask
44
- });
45
- module.exports = __toCommonJS(lib_exports);
46
-
47
- // src/lib/copilot-task.ts
48
- var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
49
-
50
- // src/components/copilot-provider/copilotkit.tsx
51
- var import_react = require("react");
52
- var import_react_dom = require("react-dom");
53
- var import_shared = require("@copilotkit/shared");
54
- var import_jsx_runtime = require("react/jsx-runtime");
55
- var defaultCopilotContextCategories = ["global"];
56
-
57
- // src/lib/copilot-task.ts
58
- var import_shared2 = require("@copilotkit/shared");
59
- var CopilotTask = class {
60
- constructor(config) {
61
- this.instructions = config.instructions;
62
- this.actions = config.actions || [];
63
- this.includeCopilotReadable = config.includeCopilotReadable !== false;
64
- this.includeCopilotActions = config.includeCopilotActions !== false;
65
- }
66
- /**
67
- * Run the task.
68
- * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.
69
- * @param data The data to use for the task.
70
- */
71
- run(context, data) {
72
- return __async(this, null, function* () {
73
- var _a, _b;
74
- const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};
75
- for (const fn of this.actions) {
76
- actions[fn.name] = fn;
77
- }
78
- let contextString = "";
79
- if (data) {
80
- contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
81
- }
82
- if (this.includeCopilotReadable) {
83
- contextString += context.getContextString([], defaultCopilotContextCategories);
84
- }
85
- const systemMessage = new import_runtime_client_gql.TextMessage({
86
- content: taskSystemMessage(contextString, this.instructions),
87
- role: import_runtime_client_gql.Role.System
88
- });
89
- const messages = [systemMessage];
90
- const runtimeClient = new import_runtime_client_gql.CopilotRuntimeClient({
91
- url: context.copilotApiConfig.chatApiEndpoint,
92
- publicApiKey: context.copilotApiConfig.publicApiKey,
93
- headers: context.copilotApiConfig.headers,
94
- credentials: context.copilotApiConfig.credentials
95
- });
96
- const response = yield runtimeClient.generateCopilotResponse({
97
- data: {
98
- frontend: {
99
- actions: Object.values(actions).map((action) => ({
100
- name: action.name,
101
- description: action.description || "",
102
- jsonSchema: JSON.stringify((0, import_shared2.actionParametersToJsonSchema)(action.parameters || []))
103
- })),
104
- url: window.location.href
105
- },
106
- messages: (0, import_runtime_client_gql.convertMessagesToGqlInput)((0, import_runtime_client_gql.filterAgentStateMessages)(messages)),
107
- metadata: {
108
- requestType: import_runtime_client_gql.CopilotRequestType.Task
109
- },
110
- forwardedParameters: {
111
- toolChoice: "required"
112
- }
113
- },
114
- properties: context.copilotApiConfig.properties
115
- }).toPromise();
116
- const functionCallHandler = context.getFunctionCallHandler(actions);
117
- const functionCalls = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
118
- ((_b = (_a = response.data) == null ? void 0 : _a.generateCopilotResponse) == null ? void 0 : _b.messages) || []
119
- ).filter((m) => m.isActionExecutionMessage());
120
- for (const functionCall of functionCalls) {
121
- yield functionCallHandler({
122
- messages,
123
- name: functionCall.name,
124
- args: functionCall.arguments
125
- });
126
- }
127
- });
128
- }
129
- };
130
- function taskSystemMessage(contextString, instructions) {
131
- return `
132
- Please act as an efficient, competent, conscientious, and industrious professional assistant.
133
-
134
- Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
135
- Always be polite and respectful, and prefer brevity over verbosity.
136
-
137
- The user has provided you with the following context:
138
- \`\`\`
139
- ${contextString}
140
- \`\`\`
141
-
142
- They have also provided you with functions you can call to initiate actions on their behalf.
143
-
144
- Please assist them as best you can.
145
-
146
- This is not a conversation, so please do not ask questions. Just call a function without saying anything else.
147
-
148
- The user has given you the following task to complete:
149
-
150
- \`\`\`
151
- ${instructions}
152
- \`\`\`
153
- `;
154
- }
155
- // Annotate the CommonJS export names for ESM import in node:
156
- 0 && (module.exports = {
157
- CopilotTask
158
- });
159
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/index.ts","../../src/lib/copilot-task.ts","../../src/components/copilot-provider/copilotkit.tsx"],"sourcesContent":["export * from \"./copilot-task\";\n","/**\n * This class is used to execute one-off tasks, for example on button press. It can use the context available via [useCopilotReadable](/reference/hooks/useCopilotReadable) and the actions provided by [useCopilotAction](/reference/hooks/useCopilotAction), or you can provide your own context and actions.\n *\n * ## Example\n * In the simplest case, use CopilotTask in the context of your app by giving it instructions on what to do.\n *\n * ```tsx\n * import { CopilotTask, useCopilotContext } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const context = useCopilotContext();\n *\n * const task = new CopilotTask({\n * instructions: \"Set a random message\",\n * actions: [\n * {\n * name: \"setMessage\",\n * description: \"Set the message.\",\n * argumentAnnotations: [\n * {\n * name: \"message\",\n * type: \"string\",\n * description:\n * \"A message to display.\",\n * required: true,\n * },\n * ],\n * }\n * ]\n * });\n *\n * const executeTask = async () => {\n * await task.run(context, action);\n * }\n *\n * return (\n * <>\n * <button onClick={executeTask}>\n * Execute task\n * </button>\n * </>\n * )\n * }\n * ```\n *\n * Have a look at the [Presentation Example App](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/examples/next-openai/src/app/presentation/page.tsx) for a more complete example.\n */\n\nimport {\n ActionExecutionMessage,\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n CopilotRequestType,\n} from \"@copilotkit/runtime-client-gql\";\nimport { FrontendAction } from \"../types/frontend-action\";\nimport { CopilotContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\n\nexport interface CopilotTaskConfig {\n /**\n * The instructions to be given to the assistant.\n */\n instructions: string;\n /**\n * An array of action definitions that can be called.\n */\n actions?: FrontendAction<any>[];\n /**\n * Whether to include the copilot readable context in the task.\n */\n includeCopilotReadable?: boolean;\n\n /**\n * Whether to include actions defined via useCopilotAction in the task.\n */\n includeCopilotActions?: boolean;\n}\n\nexport class CopilotTask<T = any> {\n private instructions: string;\n private actions: FrontendAction<any>[];\n private includeCopilotReadable: boolean;\n private includeCopilotActions: boolean;\n\n constructor(config: CopilotTaskConfig) {\n this.instructions = config.instructions;\n this.actions = config.actions || [];\n this.includeCopilotReadable = config.includeCopilotReadable !== false;\n this.includeCopilotActions = config.includeCopilotActions !== false;\n }\n\n /**\n * Run the task.\n * @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.\n * @param data The data to use for the task.\n */\n async run(context: CopilotContextParams, data?: T): Promise<void> {\n const actions = this.includeCopilotActions ? Object.assign({}, context.actions) : {};\n\n // merge functions into entry points\n for (const fn of this.actions) {\n actions[fn.name] = fn;\n }\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (this.includeCopilotReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage = new TextMessage({\n content: taskSystemMessage(contextString, this.instructions),\n role: Role.System,\n });\n\n const messages: Message[] = [systemMessage];\n\n const runtimeClient = new CopilotRuntimeClient({\n url: context.copilotApiConfig.chatApiEndpoint,\n publicApiKey: context.copilotApiConfig.publicApiKey,\n headers: context.copilotApiConfig.headers,\n credentials: context.copilotApiConfig.credentials,\n });\n\n const response = await runtimeClient\n .generateCopilotResponse({\n data: {\n frontend: {\n actions: Object.values(actions).map((action) => ({\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || [])),\n })),\n url: window.location.href,\n },\n messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),\n metadata: {\n requestType: CopilotRequestType.Task,\n },\n forwardedParameters: {\n toolChoice: \"required\",\n },\n },\n properties: context.copilotApiConfig.properties,\n })\n .toPromise();\n\n const functionCallHandler = context.getFunctionCallHandler(actions);\n const functionCalls = convertGqlOutputToMessages(\n response.data?.generateCopilotResponse?.messages || [],\n ).filter((m): m is ActionExecutionMessage => m.isActionExecutionMessage());\n\n for (const functionCall of functionCalls) {\n await functionCallHandler({\n messages,\n name: functionCall.name,\n args: functionCall.arguments,\n });\n }\n }\n}\n\nfunction taskSystemMessage(contextString: string, instructions: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call a function without saying anything else.\n\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n`;\n}\n","/**\n * This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.\n *\n * ## Example\n *\n * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).\n *\n * ```tsx\n * import { CopilotKit } from \"@copilotkit/react-core\";\n *\n * <CopilotKit runtimeUrl=\"<your-runtime-url>\">\n * // ... your app ...\n * </CopilotKit>\n * ```\n */\n\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n CopilotContext,\n CopilotApiConfig,\n ChatComponentsCache,\n AgentSession,\n} from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { CopilotChatSuggestionConfiguration, DocumentPointer } from \"../../types\";\nimport { flushSync } from \"react-dom\";\nimport {\n COPILOT_CLOUD_CHAT_URL,\n CopilotCloudConfig,\n FunctionCallHandler,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n} from \"@copilotkit/shared\";\n\nimport { FrontendAction } from \"../../types/frontend-action\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\nimport { CoAgentStateRender } from \"../../types/coagent-action\";\nimport { CoagentState } from \"../../types/coagent-state\";\nimport { CopilotMessages } from \"./copilot-messages\";\nimport { ToastProvider } from \"../toast/toast-provider\";\nimport { useCopilotRuntimeClient } from \"../../hooks/use-copilot-runtime-client\";\nimport { shouldShowDevConsole } from \"../../utils\";\n\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n const showDevConsole = props.showDevConsole === undefined ? \"auto\" : props.showDevConsole;\n const enabled = shouldShowDevConsole(showDevConsole);\n return (\n <ToastProvider enabled={enabled}>\n <CopilotKitInternal {...props}>{children}</CopilotKitInternal>\n </ToastProvider>\n );\n}\n\nexport function CopilotKitInternal({ children, ...props }: CopilotKitProps) {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n if (!props.runtimeUrl && !props.publicApiKey) {\n throw new Error(\n \"Please provide either a runtimeUrl or a publicApiKey to the CopilotKit component.\",\n );\n }\n\n const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;\n\n const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});\n const [coAgentStateRenders, setCoAgentStateRenders] = useState<\n Record<string, CoAgentStateRender<any>>\n >({});\n const chatComponentsCache = useRef<ChatComponentsCache>({\n actions: {},\n coAgentStateRenders: {},\n });\n const { addElement, removeElement, printTree } = useTree();\n const [isLoading, setIsLoading] = useState(false);\n const [chatInstructions, setChatInstructions] = useState(\"\");\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setAction = useCallback((id: string, action: FrontendAction<any>) => {\n setActions((prevPoints) => {\n return {\n ...prevPoints,\n [id]: action,\n };\n });\n }, []);\n\n const removeAction = useCallback((id: string) => {\n setActions((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {\n setCoAgentStateRenders((prevPoints) => {\n return {\n ...prevPoints,\n [id]: stateRender,\n };\n });\n }, []);\n\n const removeCoAgentStateRender = useCallback((id: string) => {\n setCoAgentStateRenders((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 getFunctionCallHandler = useCallback(\n (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));\n },\n [actions],\n );\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 if (!props.publicApiKey) {\n if (props.cloudRestrictToTopic) {\n throw new Error(\n \"To use the cloudRestrictToTopic feature, please sign up at https://copilotkit.ai and provide a publicApiKey.\",\n );\n }\n }\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = useMemo(() => {\n let cloud: CopilotCloudConfig | undefined = undefined;\n if (props.publicApiKey) {\n cloud = {\n guardrails: {\n input: {\n restrictToTopic: {\n enabled: props.cloudRestrictToTopic ? true : false,\n validTopics: props.cloudRestrictToTopic?.validTopics || [],\n invalidTopics: props.cloudRestrictToTopic?.invalidTopics || [],\n },\n },\n },\n };\n }\n\n return {\n publicApiKey: props.publicApiKey,\n ...(cloud ? { cloud } : {}),\n chatApiEndpoint: chatApiEndpoint,\n headers: props.headers || {},\n properties: props.properties || {},\n transcribeAudioUrl: props.transcribeAudioUrl,\n textToSpeechUrl: props.textToSpeechUrl,\n credentials: props.credentials,\n };\n }, [\n props.publicApiKey,\n props.headers,\n props.properties,\n props.transcribeAudioUrl,\n props.textToSpeechUrl,\n props.credentials,\n props.cloudRestrictToTopic,\n ]);\n\n const headers = {\n ...(copilotApiConfig.headers || {}),\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n };\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: copilotApiConfig.publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n });\n\n const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{\n [key: string]: CopilotChatSuggestionConfiguration;\n }>({});\n\n const addChatSuggestionConfiguration = (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => {\n setChatSuggestionConfiguration((prev) => ({ ...prev, [id]: suggestion }));\n };\n\n const removeChatSuggestionConfiguration = (id: string) => {\n setChatSuggestionConfiguration((prev) => {\n const { [id]: _, ...rest } = prev;\n return rest;\n });\n };\n\n const [coagentStates, setCoagentStates] = useState<Record<string, CoagentState>>({});\n let initialAgentSession: AgentSession | null = null;\n if (props.agent) {\n initialAgentSession = {\n agentName: props.agent,\n };\n }\n\n const [agentSession, setAgentSession] = useState<AgentSession | null>(initialAgentSession);\n\n const showDevConsole = props.showDevConsole === undefined ? \"auto\" : props.showDevConsole;\n\n return (\n <CopilotContext.Provider\n value={{\n actions,\n chatComponentsCache,\n getFunctionCallHandler,\n setAction,\n removeAction,\n coAgentStateRenders,\n setCoAgentStateRender,\n removeCoAgentStateRender,\n getContextString,\n addContext,\n removeContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n isLoading,\n setIsLoading,\n chatSuggestionConfiguration,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n chatInstructions,\n setChatInstructions,\n showDevConsole,\n coagentStates,\n setCoagentStates,\n agentSession,\n setAgentSession,\n runtimeClient,\n }}\n >\n <CopilotMessages>{children}</CopilotMessages>\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {\n return async ({ messages, name, args }) => {\n let actionsByFunctionName: Record<string, FrontendAction<any>> = {};\n for (let action of actions) {\n actionsByFunctionName[action.name] = action;\n }\n\n const action = actionsByFunctionName[name];\n let result: any = undefined;\n if (action) {\n await new Promise<void>((resolve, reject) => {\n flushSync(async () => {\n try {\n result = await action.handler?.(args);\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n });\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n return result;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgDA,gCAUO;;;AC1CP,mBAAuD;AASvD,uBAA0B;AAC1B,oBAKO;AAiBD;AAiQC,IAAM,kCAAkC,CAAC,QAAQ;;;ADlPxD,IAAAA,iBAA6C;AAsBtC,IAAM,cAAN,MAA2B;AAAA,EAMhC,YAAY,QAA2B;AACrC,SAAK,eAAe,OAAO;AAC3B,SAAK,UAAU,OAAO,WAAW,CAAC;AAClC,SAAK,yBAAyB,OAAO,2BAA2B;AAChE,SAAK,wBAAwB,OAAO,0BAA0B;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOM,IAAI,SAA+B,MAAyB;AAAA;AAvGpE;AAwGI,YAAM,UAAU,KAAK,wBAAwB,OAAO,OAAO,CAAC,GAAG,QAAQ,OAAO,IAAI,CAAC;AAGnF,iBAAW,MAAM,KAAK,SAAS;AAC7B,gBAAQ,GAAG,IAAI,IAAI;AAAA,MACrB;AAEA,UAAI,gBAAgB;AAEpB,UAAI,MAAM;AACR,yBAAiB,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,IAAI,KAAK;AAAA,MAC7E;AAEA,UAAI,KAAK,wBAAwB;AAC/B,yBAAiB,QAAQ,iBAAiB,CAAC,GAAG,+BAA+B;AAAA,MAC/E;AAEA,YAAM,gBAAgB,IAAI,sCAAY;AAAA,QACpC,SAAS,kBAAkB,eAAe,KAAK,YAAY;AAAA,QAC3D,MAAM,+BAAK;AAAA,MACb,CAAC;AAED,YAAM,WAAsB,CAAC,aAAa;AAE1C,YAAM,gBAAgB,IAAI,+CAAqB;AAAA,QAC7C,KAAK,QAAQ,iBAAiB;AAAA,QAC9B,cAAc,QAAQ,iBAAiB;AAAA,QACvC,SAAS,QAAQ,iBAAiB;AAAA,QAClC,aAAa,QAAQ,iBAAiB;AAAA,MACxC,CAAC;AAED,YAAM,WAAW,MAAM,cACpB,wBAAwB;AAAA,QACvB,MAAM;AAAA,UACJ,UAAU;AAAA,YACR,SAAS,OAAO,OAAO,OAAO,EAAE,IAAI,CAAC,YAAY;AAAA,cAC/C,MAAM,OAAO;AAAA,cACb,aAAa,OAAO,eAAe;AAAA,cACnC,YAAY,KAAK,cAAU,6CAA6B,OAAO,cAAc,CAAC,CAAC,CAAC;AAAA,YAClF,EAAE;AAAA,YACF,KAAK,OAAO,SAAS;AAAA,UACvB;AAAA,UACA,cAAU,yDAA0B,oDAAyB,QAAQ,CAAC;AAAA,UACtE,UAAU;AAAA,YACR,aAAa,6CAAmB;AAAA,UAClC;AAAA,UACA,qBAAqB;AAAA,YACnB,YAAY;AAAA,UACd;AAAA,QACF;AAAA,QACA,YAAY,QAAQ,iBAAiB;AAAA,MACvC,CAAC,EACA,UAAU;AAEb,YAAM,sBAAsB,QAAQ,uBAAuB,OAAO;AAClE,YAAM,oBAAgB;AAAA,UACpB,oBAAS,SAAT,mBAAe,4BAAf,mBAAwC,aAAY,CAAC;AAAA,MACvD,EAAE,OAAO,CAAC,MAAmC,EAAE,yBAAyB,CAAC;AAEzE,iBAAW,gBAAgB,eAAe;AACxC,cAAM,oBAAoB;AAAA,UACxB;AAAA,UACA,MAAM,aAAa;AAAA,UACnB,MAAM,aAAa;AAAA,QACrB,CAAC;AAAA,MACH;AAAA,IACF;AAAA;AACF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA;AAAA;AAAA;AAGF;","names":["import_shared"]}
@@ -1,19 +0,0 @@
1
- import "../chunk-LUGEI4YQ.mjs";
2
- import {
3
- CopilotTask
4
- } from "../chunk-FXHKK52V.mjs";
5
- import "../chunk-6OR25P32.mjs";
6
- import "../chunk-5FHSUKQL.mjs";
7
- import "../chunk-6U3UH3KO.mjs";
8
- import "../chunk-XXR4QFAQ.mjs";
9
- import "../chunk-ODN4H66E.mjs";
10
- import "../chunk-2KCEHGSI.mjs";
11
- import "../chunk-O7ARI5CV.mjs";
12
- import "../chunk-LODRWFMB.mjs";
13
- import "../chunk-DCTJZ742.mjs";
14
- import "../chunk-MLAS4QUR.mjs";
15
- import "../chunk-SKC7AJIV.mjs";
16
- export {
17
- CopilotTask
18
- };
19
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,22 +0,0 @@
1
- interface CopilotChatSuggestionConfiguration {
2
- /**
3
- * A prompt or instructions for the GPT to generate suggestions.
4
- */
5
- instructions: string;
6
- /**
7
- * The minimum number of suggestions to generate. Defaults to `1`.
8
- * @default 1
9
- */
10
- minSuggestions?: number;
11
- /**
12
- * The maximum number of suggestions to generate. Defaults to `3`.
13
- * @default 1
14
- */
15
- maxSuggestions?: number;
16
- /**
17
- * An optional class name to apply to the suggestions.
18
- */
19
- className?: string;
20
- }
21
-
22
- export { CopilotChatSuggestionConfiguration };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types/chat-suggestion-configuration.ts
17
- var chat_suggestion_configuration_exports = {};
18
- module.exports = __toCommonJS(chat_suggestion_configuration_exports);
19
- //# sourceMappingURL=chat-suggestion-configuration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types/chat-suggestion-configuration.ts"],"sourcesContent":["export interface CopilotChatSuggestionConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chat-suggestion-configuration.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,29 +0,0 @@
1
- type CoAgentStateRenderProps<T> = {
2
- state: T;
3
- nodeName: string;
4
- status: "inProgress" | "complete";
5
- };
6
- type CoAgentStateRenderHandlerArguments<T> = {
7
- nodeName: string;
8
- state: T;
9
- };
10
- interface CoAgentStateRender<T = any> {
11
- /**
12
- * The name of the coagent.
13
- */
14
- name: string;
15
- /**
16
- * The node name of the coagent.
17
- */
18
- nodeName?: string;
19
- /**
20
- * The handler function to handle the state of the agent.
21
- */
22
- handler?: (props: CoAgentStateRenderHandlerArguments<T>) => void | Promise<void>;
23
- /**
24
- * The render function to handle the state of the agent.
25
- */
26
- render?: ((props: CoAgentStateRenderProps<T>) => string | React.ReactElement | undefined | null) | string;
27
- }
28
-
29
- export { CoAgentStateRender, CoAgentStateRenderHandlerArguments, CoAgentStateRenderProps };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types/coagent-action.ts
17
- var coagent_action_exports = {};
18
- module.exports = __toCommonJS(coagent_action_exports);
19
- //# sourceMappingURL=coagent-action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types/coagent-action.ts"],"sourcesContent":["export type CoAgentStateRenderProps<T> = {\n state: T;\n nodeName: string;\n status: \"inProgress\" | \"complete\";\n};\n\nexport type CoAgentStateRenderHandlerArguments<T> = {\n nodeName: string;\n state: T;\n};\n\nexport interface CoAgentStateRender<T = any> {\n /**\n * The name of the coagent.\n */\n name: string;\n /**\n * The node name of the coagent.\n */\n nodeName?: string;\n /**\n * The handler function to handle the state of the agent.\n */\n handler?: (props: CoAgentStateRenderHandlerArguments<T>) => void | Promise<void>;\n /**\n * The render function to handle the state of the agent.\n */\n render?:\n | ((props: CoAgentStateRenderProps<T>) => string | React.ReactElement | undefined | null)\n | string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=coagent-action.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,11 +0,0 @@
1
- interface CoagentState {
2
- name: string;
3
- state: any;
4
- running: boolean;
5
- active: boolean;
6
- threadId?: string;
7
- nodeName?: string;
8
- runId?: string;
9
- }
10
-
11
- export { CoagentState };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types/coagent-state.ts
17
- var coagent_state_exports = {};
18
- module.exports = __toCommonJS(coagent_state_exports);
19
- //# sourceMappingURL=coagent-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types/coagent-state.ts"],"sourcesContent":["export interface CoagentState {\n name: string;\n state: any;\n running: boolean;\n active: boolean;\n threadId?: string;\n nodeName?: string;\n runId?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=coagent-state.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,9 +0,0 @@
1
- interface DocumentPointer {
2
- id: string;
3
- name: string;
4
- sourceApplication: string;
5
- iconImageUri: string;
6
- getContents: () => string;
7
- }
8
-
9
- export { DocumentPointer };