@copilotkit/runtime 1.50.0-beta.9 → 1.50.1-next.0

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 (183) hide show
  1. package/CHANGELOG.md +165 -0
  2. package/dist/chunk-27JKTS6P.mjs +1704 -0
  3. package/dist/chunk-27JKTS6P.mjs.map +1 -0
  4. package/dist/{chunk-FMU55SEU.mjs → chunk-2GPTVDTO.mjs} +2 -2
  5. package/dist/chunk-3AJVKDZX.mjs +3097 -0
  6. package/dist/chunk-3AJVKDZX.mjs.map +1 -0
  7. package/dist/{chunk-BJEYMRDD.mjs → chunk-45RCC3ZS.mjs} +2 -2
  8. package/dist/chunk-4EHJ4XFJ.mjs +25 -0
  9. package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
  10. package/dist/chunk-4IANB4TC.mjs +25 -0
  11. package/dist/chunk-4IANB4TC.mjs.map +1 -0
  12. package/dist/{chunk-Z752VE75.mjs → chunk-4KES76K3.mjs} +2 -2
  13. package/dist/chunk-4OGE3SLW.mjs +3100 -0
  14. package/dist/chunk-4OGE3SLW.mjs.map +1 -0
  15. package/dist/chunk-54YJBMCP.mjs +3097 -0
  16. package/dist/chunk-54YJBMCP.mjs.map +1 -0
  17. package/dist/chunk-6ER4SZYH.mjs +74 -0
  18. package/dist/chunk-6ER4SZYH.mjs.map +1 -0
  19. package/dist/chunk-6TNSLHVR.mjs +74 -0
  20. package/dist/chunk-6TNSLHVR.mjs.map +1 -0
  21. package/dist/chunk-7V4BK7TZ.mjs +25 -0
  22. package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
  23. package/dist/chunk-7YZIEXD2.mjs +74 -0
  24. package/dist/chunk-7YZIEXD2.mjs.map +1 -0
  25. package/dist/chunk-A4XHOAFU.mjs +25 -0
  26. package/dist/chunk-A4XHOAFU.mjs.map +1 -0
  27. package/dist/chunk-A555KEAD.mjs +6020 -0
  28. package/dist/chunk-A555KEAD.mjs.map +1 -0
  29. package/dist/chunk-AF73TFTX.mjs +74 -0
  30. package/dist/chunk-AF73TFTX.mjs.map +1 -0
  31. package/dist/chunk-AQG2SVCA.mjs +25 -0
  32. package/dist/chunk-AQG2SVCA.mjs.map +1 -0
  33. package/dist/chunk-BJZHMXND.mjs +74 -0
  34. package/dist/chunk-BJZHMXND.mjs.map +1 -0
  35. package/dist/chunk-CB2OJXF6.mjs +25 -0
  36. package/dist/chunk-CB2OJXF6.mjs.map +1 -0
  37. package/dist/chunk-CEOMFPJU.mjs +6020 -0
  38. package/dist/chunk-CEOMFPJU.mjs.map +1 -0
  39. package/dist/chunk-CZVLR7CC.mjs +175 -0
  40. package/dist/chunk-CZVLR7CC.mjs.map +1 -0
  41. package/dist/{chunk-SBCOROE4.mjs → chunk-DCEEHMLJ.mjs} +16 -1
  42. package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
  43. package/dist/chunk-DE3CLKUG.mjs +25 -0
  44. package/dist/chunk-DE3CLKUG.mjs.map +1 -0
  45. package/dist/chunk-DTPRUTNV.mjs +25 -0
  46. package/dist/chunk-DTPRUTNV.mjs.map +1 -0
  47. package/dist/{chunk-TTUAEJLD.mjs → chunk-ERUOA47O.mjs} +11 -2
  48. package/dist/chunk-ERUOA47O.mjs.map +1 -0
  49. package/dist/chunk-ESSRC64W.mjs +74 -0
  50. package/dist/chunk-ESSRC64W.mjs.map +1 -0
  51. package/dist/chunk-GRAN6K6N.mjs +25 -0
  52. package/dist/chunk-GRAN6K6N.mjs.map +1 -0
  53. package/dist/chunk-I27F2UPA.mjs +175 -0
  54. package/dist/chunk-I27F2UPA.mjs.map +1 -0
  55. package/dist/chunk-IAZKTOQW.mjs +25 -0
  56. package/dist/chunk-IAZKTOQW.mjs.map +1 -0
  57. package/dist/chunk-J6XZ5MFB.mjs +25 -0
  58. package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
  59. package/dist/chunk-JJ32MA4C.mjs +73 -0
  60. package/dist/chunk-JJ32MA4C.mjs.map +1 -0
  61. package/dist/chunk-JJY4ZTHQ.mjs +25 -0
  62. package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
  63. package/dist/chunk-KEYLBFU2.mjs +3117 -0
  64. package/dist/chunk-KEYLBFU2.mjs.map +1 -0
  65. package/dist/chunk-KQ53L4WZ.mjs +3094 -0
  66. package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
  67. package/dist/chunk-KTELVQ67.mjs +3098 -0
  68. package/dist/chunk-KTELVQ67.mjs.map +1 -0
  69. package/dist/chunk-LPEPX6NH.mjs +25 -0
  70. package/dist/chunk-LPEPX6NH.mjs.map +1 -0
  71. package/dist/chunk-MDXE55DK.mjs +3117 -0
  72. package/dist/chunk-MDXE55DK.mjs.map +1 -0
  73. package/dist/chunk-MMFUVOXH.mjs +73 -0
  74. package/dist/chunk-MMFUVOXH.mjs.map +1 -0
  75. package/dist/chunk-N3Y4U66N.mjs +253 -0
  76. package/dist/chunk-N3Y4U66N.mjs.map +1 -0
  77. package/dist/chunk-O7UYB4MH.mjs +25 -0
  78. package/dist/chunk-O7UYB4MH.mjs.map +1 -0
  79. package/dist/chunk-OFNVQHNM.mjs +3089 -0
  80. package/dist/chunk-OFNVQHNM.mjs.map +1 -0
  81. package/dist/{chunk-DZV4ZIAR.mjs → chunk-OFSV5GET.mjs} +17 -6
  82. package/dist/chunk-OFSV5GET.mjs.map +1 -0
  83. package/dist/chunk-OMRST67R.mjs +25 -0
  84. package/dist/chunk-OMRST67R.mjs.map +1 -0
  85. package/dist/chunk-PRZHE74A.mjs +25 -0
  86. package/dist/chunk-PRZHE74A.mjs.map +1 -0
  87. package/dist/chunk-PTYRVXXP.mjs +80 -0
  88. package/dist/chunk-PTYRVXXP.mjs.map +1 -0
  89. package/dist/chunk-R22B5CCO.mjs +25 -0
  90. package/dist/chunk-R22B5CCO.mjs.map +1 -0
  91. package/dist/chunk-SHBDMA63.mjs +141 -0
  92. package/dist/chunk-SHBDMA63.mjs.map +1 -0
  93. package/dist/chunk-SPVXBPRA.mjs +74 -0
  94. package/dist/chunk-SPVXBPRA.mjs.map +1 -0
  95. package/dist/chunk-T72G46ME.mjs +25 -0
  96. package/dist/chunk-T72G46ME.mjs.map +1 -0
  97. package/dist/chunk-TGELROPU.mjs +25 -0
  98. package/dist/chunk-TGELROPU.mjs.map +1 -0
  99. package/dist/chunk-UNX4IAAD.mjs +25 -0
  100. package/dist/chunk-UNX4IAAD.mjs.map +1 -0
  101. package/dist/chunk-V4DHVC7M.mjs +3085 -0
  102. package/dist/chunk-V4DHVC7M.mjs.map +1 -0
  103. package/dist/chunk-VVRFOB66.mjs +25 -0
  104. package/dist/chunk-VVRFOB66.mjs.map +1 -0
  105. package/dist/chunk-W6NVBYM6.mjs +80 -0
  106. package/dist/chunk-W6NVBYM6.mjs.map +1 -0
  107. package/dist/chunk-W7MBACGC.mjs +74 -0
  108. package/dist/chunk-W7MBACGC.mjs.map +1 -0
  109. package/dist/chunk-WMD4XZZS.mjs +25 -0
  110. package/dist/chunk-WMD4XZZS.mjs.map +1 -0
  111. package/dist/chunk-WX2ZNCRT.mjs +74 -0
  112. package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
  113. package/dist/chunk-Y2Z62E2T.mjs +74 -0
  114. package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
  115. package/dist/chunk-YO4I6RVI.mjs +25 -0
  116. package/dist/chunk-YO4I6RVI.mjs.map +1 -0
  117. package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
  118. package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
  119. package/dist/chunk-Z726O3G2.mjs +25 -0
  120. package/dist/chunk-Z726O3G2.mjs.map +1 -0
  121. package/dist/chunk-ZE4SMZZR.mjs +3097 -0
  122. package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
  123. package/dist/chunk-ZULZB33C.mjs +73 -0
  124. package/dist/chunk-ZULZB33C.mjs.map +1 -0
  125. package/dist/chunk-ZVRGXMY7.mjs +25 -0
  126. package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
  127. package/dist/chunk-ZZ35WBYQ.mjs +25 -0
  128. package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
  129. package/dist/graphql/types/converted/index.d.ts +1 -1
  130. package/dist/graphql/types/converted/index.js +16 -110
  131. package/dist/graphql/types/converted/index.js.map +1 -1
  132. package/dist/graphql/types/converted/index.mjs +2 -3
  133. package/dist/{groq-adapter-50bc6e4a.d.ts → groq-adapter-540da9c3.d.ts} +6 -1
  134. package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
  135. package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
  136. package/dist/index-96b330da.d.ts +119 -0
  137. package/dist/index.d.ts +72 -9
  138. package/dist/index.js +127 -31
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +129 -34
  141. package/dist/index.mjs.map +1 -1
  142. package/dist/langserve-0c6100e3.d.ts +257 -0
  143. package/dist/langserve-978d5790.d.ts +243 -0
  144. package/dist/{langserve-74a52292.d.ts → langserve-9fc76ce5.d.ts} +1 -0
  145. package/dist/lib/index.d.ts +5 -59
  146. package/dist/lib/index.js +3702 -803
  147. package/dist/lib/index.js.map +1 -1
  148. package/dist/lib/index.mjs +20 -18
  149. package/dist/lib/integrations/index.d.ts +15 -9
  150. package/dist/lib/integrations/index.js +215 -187
  151. package/dist/lib/integrations/index.js.map +1 -1
  152. package/dist/lib/integrations/index.mjs +8 -7
  153. package/dist/lib/integrations/nest/index.d.ts +5 -6
  154. package/dist/lib/integrations/nest/index.js +197 -175
  155. package/dist/lib/integrations/nest/index.js.map +1 -1
  156. package/dist/lib/integrations/nest/index.mjs +6 -5
  157. package/dist/lib/integrations/node-express/index.d.ts +5 -6
  158. package/dist/lib/integrations/node-express/index.js +197 -175
  159. package/dist/lib/integrations/node-express/index.js.map +1 -1
  160. package/dist/lib/integrations/node-express/index.mjs +6 -5
  161. package/dist/lib/integrations/node-http/index.d.ts +5 -6
  162. package/dist/lib/integrations/node-http/index.js +197 -175
  163. package/dist/lib/integrations/node-http/index.js.map +1 -1
  164. package/dist/lib/integrations/node-http/index.mjs +5 -4
  165. package/dist/service-adapters/index.d.ts +7 -11
  166. package/dist/service-adapters/index.js +8 -21
  167. package/dist/service-adapters/index.js.map +1 -1
  168. package/dist/service-adapters/index.mjs +2 -4
  169. package/dist/shared-0a7346ce.d.ts +466 -0
  170. package/dist/{shared-f6d43ef8.d.ts → shared-35c6eb04.d.ts} +3 -1
  171. package/dist/shared-9ed1dc31.d.ts +414 -0
  172. package/dist/shared-da5708fe.d.ts +449 -0
  173. package/package.json +14 -20
  174. package/src/lib/index.ts +7 -6
  175. package/src/lib/runtime/copilot-runtime.ts +62 -26
  176. package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
  177. package/src/service-adapters/google/google-genai-adapter.ts +19 -4
  178. package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
  179. package/dist/chunk-SBCOROE4.mjs.map +0 -1
  180. package/dist/chunk-TTUAEJLD.mjs.map +0 -1
  181. /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
  182. /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
  183. /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
@@ -0,0 +1,321 @@
1
+ import OpenAI from 'openai';
2
+ import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-0c6100e3.js';
3
+ import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
4
+ import { DynamicStructuredTool } from '@langchain/core/tools';
5
+ import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
6
+ import { Groq } from 'groq-sdk';
7
+
8
+ /**
9
+ * Copilot Runtime adapter for OpenAI.
10
+ *
11
+ * ## Example
12
+ *
13
+ * ```ts
14
+ * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
15
+ * import OpenAI from "openai";
16
+ *
17
+ * const copilotKit = new CopilotRuntime();
18
+ *
19
+ * const openai = new OpenAI({
20
+ * organization: "<your-organization-id>", // optional
21
+ * apiKey: "<your-api-key>",
22
+ * });
23
+ *
24
+ * return new OpenAIAdapter({ openai });
25
+ * ```
26
+ *
27
+ * ## Example with Azure OpenAI
28
+ *
29
+ * ```ts
30
+ * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
31
+ * import OpenAI from "openai";
32
+ *
33
+ * // The name of your Azure OpenAI Instance.
34
+ * // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
35
+ * const instance = "<your instance name>";
36
+ *
37
+ * // Corresponds to your Model deployment within your OpenAI resource, e.g. my-gpt35-16k-deployment
38
+ * // Navigate to the Azure OpenAI Studio to deploy a model.
39
+ * const model = "<your model>";
40
+ *
41
+ * const apiKey = process.env["AZURE_OPENAI_API_KEY"];
42
+ * if (!apiKey) {
43
+ * throw new Error("The AZURE_OPENAI_API_KEY environment variable is missing or empty.");
44
+ * }
45
+ *
46
+ * const copilotKit = new CopilotRuntime();
47
+ *
48
+ * const openai = new OpenAI({
49
+ * apiKey,
50
+ * baseURL: `https://${instance}.openai.azure.com/openai/deployments/${model}`,
51
+ * defaultQuery: { "api-version": "2024-04-01-preview" },
52
+ * defaultHeaders: { "api-key": apiKey },
53
+ * });
54
+ *
55
+ * return new OpenAIAdapter({ openai });
56
+ * ```
57
+ */
58
+
59
+ interface OpenAIAdapterParams {
60
+ /**
61
+ * An optional OpenAI instance to use. If not provided, a new instance will be
62
+ * created.
63
+ */
64
+ openai?: OpenAI;
65
+ /**
66
+ * The model to use.
67
+ */
68
+ model?: string;
69
+ /**
70
+ * Whether to disable parallel tool calls.
71
+ * You can disable parallel tool calls to force the model to execute tool calls sequentially.
72
+ * This is useful if you want to execute tool calls in a specific order so that the state changes
73
+ * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
74
+ *
75
+ * @default false
76
+ */
77
+ disableParallelToolCalls?: boolean;
78
+ /**
79
+ * Whether to keep the role in system messages as "System".
80
+ * By default, it is converted to "developer", which is used by newer OpenAI models
81
+ *
82
+ * @default false
83
+ */
84
+ keepSystemRole?: boolean;
85
+ }
86
+ declare class OpenAIAdapter implements CopilotServiceAdapter {
87
+ private model;
88
+ private disableParallelToolCalls;
89
+ private _openai;
90
+ private keepSystemRole;
91
+ get openai(): OpenAI;
92
+ constructor(params?: OpenAIAdapterParams);
93
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
94
+ }
95
+
96
+ type LangChainBaseMessageChunkStream = IterableReadableStream<BaseMessageChunk>;
97
+ type LangChainAIMessageChunkStream = IterableReadableStreamInterface<AIMessageChunk>;
98
+ type LangChainReturnType = LangChainBaseMessageChunkStream | LangChainAIMessageChunkStream | BaseMessageChunk | string | AIMessage;
99
+
100
+ /**
101
+ * Copilot Runtime adapter for LangChain.
102
+ *
103
+ * ## Example
104
+ *
105
+ * ```ts
106
+ * import { CopilotRuntime, LangChainAdapter } from "@copilotkit/runtime";
107
+ * import { ChatOpenAI } from "@langchain/openai";
108
+ *
109
+ * const copilotKit = new CopilotRuntime();
110
+ *
111
+ * const model = new ChatOpenAI({
112
+ * model: "gpt-4o",
113
+ * apiKey: "<your-api-key>",
114
+ * });
115
+ *
116
+ * return new LangChainAdapter({
117
+ * chainFn: async ({ messages, tools }) => {
118
+ * return model.bindTools(tools).stream(messages);
119
+ * // or optionally enable strict mode
120
+ * // return model.bindTools(tools, { strict: true }).stream(messages);
121
+ * }
122
+ * });
123
+ * ```
124
+ *
125
+ * The asynchronous handler function (`chainFn`) can return any of the following:
126
+ *
127
+ * - A simple `string` response
128
+ * - A LangChain stream (`IterableReadableStream`)
129
+ * - A LangChain `BaseMessageChunk` object
130
+ * - A LangChain `AIMessage` object
131
+ */
132
+
133
+ interface ChainFnParameters {
134
+ model: string;
135
+ messages: BaseMessage[];
136
+ tools: DynamicStructuredTool[];
137
+ threadId?: string;
138
+ runId?: string;
139
+ }
140
+ interface LangChainAdapterOptions {
141
+ /**
142
+ * A function that uses the LangChain API to generate a response.
143
+ */
144
+ chainFn: (parameters: ChainFnParameters) => Promise<LangChainReturnType>;
145
+ }
146
+ declare class LangChainAdapter implements CopilotServiceAdapter {
147
+ private options;
148
+ /**
149
+ * To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
150
+ */
151
+ constructor(options: LangChainAdapterOptions);
152
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
153
+ }
154
+
155
+ interface GoogleGenerativeAIAdapterOptions {
156
+ /**
157
+ * A custom Google Generative AI model to use.
158
+ */
159
+ model?: string;
160
+ /**
161
+ * The API key to use.
162
+ */
163
+ apiKey?: string;
164
+ }
165
+ declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
166
+ constructor(options?: GoogleGenerativeAIAdapterOptions);
167
+ }
168
+
169
+ /**
170
+ * Copilot Runtime adapter for the OpenAI Assistant API.
171
+ *
172
+ * ## Example
173
+ *
174
+ * ```ts
175
+ * import { CopilotRuntime, OpenAIAssistantAdapter } from "@copilotkit/runtime";
176
+ * import OpenAI from "openai";
177
+ *
178
+ * const copilotKit = new CopilotRuntime();
179
+ *
180
+ * const openai = new OpenAI({
181
+ * organization: "<your-organization-id>",
182
+ * apiKey: "<your-api-key>",
183
+ * });
184
+ *
185
+ * return new OpenAIAssistantAdapter({
186
+ * openai,
187
+ * assistantId: "<your-assistant-id>",
188
+ * codeInterpreterEnabled: true,
189
+ * fileSearchEnabled: true,
190
+ * });
191
+ * ```
192
+ */
193
+
194
+ interface OpenAIAssistantAdapterParams {
195
+ /**
196
+ * The ID of the assistant to use.
197
+ */
198
+ assistantId: string;
199
+ /**
200
+ * An optional OpenAI instance to use. If not provided, a new instance will be created.
201
+ */
202
+ openai?: OpenAI;
203
+ /**
204
+ * Whether to enable code interpretation.
205
+ * @default true
206
+ */
207
+ codeInterpreterEnabled?: boolean;
208
+ /**
209
+ * Whether to enable file search.
210
+ * @default true
211
+ */
212
+ fileSearchEnabled?: boolean;
213
+ /**
214
+ * Whether to disable parallel tool calls.
215
+ * You can disable parallel tool calls to force the model to execute tool calls sequentially.
216
+ * This is useful if you want to execute tool calls in a specific order so that the state changes
217
+ * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
218
+ *
219
+ * @default false
220
+ */
221
+ disableParallelToolCalls?: boolean;
222
+ /**
223
+ * Whether to keep the role in system messages as "System".
224
+ * By default, it is converted to "developer", which is used by newer OpenAI models
225
+ *
226
+ * @default false
227
+ */
228
+ keepSystemRole?: boolean;
229
+ }
230
+ declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
231
+ private openai;
232
+ private codeInterpreterEnabled;
233
+ private assistantId;
234
+ private fileSearchEnabled;
235
+ private disableParallelToolCalls;
236
+ private keepSystemRole;
237
+ constructor(params: OpenAIAssistantAdapterParams);
238
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
239
+ private submitToolOutputs;
240
+ private submitUserMessage;
241
+ private streamResponse;
242
+ }
243
+
244
+ /**
245
+ * CopilotKit Adapter for Unify
246
+ *
247
+ * <RequestExample>
248
+ * ```jsx CopilotRuntime Example
249
+ * const copilotKit = new CopilotRuntime();
250
+ * return copilotKit.response(req, new UnifyAdapter());
251
+ * ```
252
+ * </RequestExample>
253
+ *
254
+ * You can easily set the model to use by passing it to the constructor.
255
+ * ```jsx
256
+ * const copilotKit = new CopilotRuntime();
257
+ * return copilotKit.response(
258
+ * req,
259
+ * new UnifyAdapter({ model: "llama-3-8b-chat@fireworks-ai" }),
260
+ * );
261
+ * ```
262
+ */
263
+
264
+ interface UnifyAdapterParams {
265
+ apiKey?: string;
266
+ model: string;
267
+ }
268
+ declare class UnifyAdapter implements CopilotServiceAdapter {
269
+ private apiKey;
270
+ private model;
271
+ private start;
272
+ constructor(options?: UnifyAdapterParams);
273
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
274
+ }
275
+
276
+ /**
277
+ * Copilot Runtime adapter for Groq.
278
+ *
279
+ * ## Example
280
+ *
281
+ * ```ts
282
+ * import { CopilotRuntime, GroqAdapter } from "@copilotkit/runtime";
283
+ * import { Groq } from "groq-sdk";
284
+ *
285
+ * const groq = new Groq({ apiKey: process.env["GROQ_API_KEY"] });
286
+ *
287
+ * const copilotKit = new CopilotRuntime();
288
+ *
289
+ * return new GroqAdapter({ groq, model: "<model-name>" });
290
+ * ```
291
+ */
292
+
293
+ interface GroqAdapterParams {
294
+ /**
295
+ * An optional Groq instance to use.
296
+ */
297
+ groq?: Groq;
298
+ /**
299
+ * The model to use.
300
+ */
301
+ model?: string;
302
+ /**
303
+ * Whether to disable parallel tool calls.
304
+ * You can disable parallel tool calls to force the model to execute tool calls sequentially.
305
+ * This is useful if you want to execute tool calls in a specific order so that the state changes
306
+ * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
307
+ *
308
+ * @default false
309
+ */
310
+ disableParallelToolCalls?: boolean;
311
+ }
312
+ declare class GroqAdapter implements CopilotServiceAdapter {
313
+ private model;
314
+ private disableParallelToolCalls;
315
+ private _groq;
316
+ get groq(): Groq;
317
+ constructor(params?: GroqAdapterParams);
318
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
319
+ }
320
+
321
+ export { GoogleGenerativeAIAdapter as G, LangChainAdapter as L, OpenAIAdapterParams as O, UnifyAdapterParams as U, OpenAIAdapter as a, OpenAIAssistantAdapterParams as b, OpenAIAssistantAdapter as c, UnifyAdapter as d, GroqAdapterParams as e, GroqAdapter as f };
@@ -0,0 +1,119 @@
1
+ import { BaseMessageInput } from './graphql/types/base/index.js';
2
+
3
+ declare enum MessageRole {
4
+ user = "user",
5
+ assistant = "assistant",
6
+ system = "system",
7
+ tool = "tool",
8
+ developer = "developer"
9
+ }
10
+ declare enum ActionInputAvailability {
11
+ disabled = "disabled",
12
+ enabled = "enabled",
13
+ remote = "remote"
14
+ }
15
+
16
+ declare class MessageInput extends BaseMessageInput {
17
+ textMessage?: TextMessageInput;
18
+ actionExecutionMessage?: ActionExecutionMessageInput;
19
+ resultMessage?: ResultMessageInput;
20
+ agentStateMessage?: AgentStateMessageInput;
21
+ imageMessage?: ImageMessageInput;
22
+ }
23
+ declare class TextMessageInput {
24
+ content: string;
25
+ parentMessageId?: string;
26
+ role: MessageRole;
27
+ }
28
+ declare class ActionExecutionMessageInput {
29
+ name: string;
30
+ arguments: string;
31
+ parentMessageId?: string;
32
+ scope?: String;
33
+ }
34
+ declare class ResultMessageInput {
35
+ actionExecutionId: string;
36
+ actionName: string;
37
+ parentMessageId?: string;
38
+ result: string;
39
+ }
40
+ declare class AgentStateMessageInput {
41
+ threadId: string;
42
+ agentName: string;
43
+ role: MessageRole;
44
+ state: string;
45
+ running: boolean;
46
+ nodeName: string;
47
+ runId: string;
48
+ active: boolean;
49
+ }
50
+ declare class ImageMessageInput {
51
+ format: string;
52
+ bytes: string;
53
+ parentMessageId?: string;
54
+ role: MessageRole;
55
+ }
56
+
57
+ type MessageType = "TextMessage" | "ActionExecutionMessage" | "ResultMessage" | "AgentStateMessage" | "ImageMessage";
58
+ declare class Message extends BaseMessageInput {
59
+ type: MessageType;
60
+ isTextMessage(): this is TextMessage;
61
+ isActionExecutionMessage(): this is ActionExecutionMessage;
62
+ isResultMessage(): this is ResultMessage;
63
+ isAgentStateMessage(): this is AgentStateMessage;
64
+ isImageMessage(): this is ImageMessage;
65
+ }
66
+ declare class TextMessage extends Message implements TextMessageInput {
67
+ type: MessageType;
68
+ content: string;
69
+ role: MessageRole;
70
+ parentMessageId?: string;
71
+ }
72
+ declare class ActionExecutionMessage extends Message implements Omit<ActionExecutionMessageInput, "arguments" | "scope"> {
73
+ type: MessageType;
74
+ name: string;
75
+ arguments: Record<string, any>;
76
+ parentMessageId?: string;
77
+ }
78
+ declare class ResultMessage extends Message implements ResultMessageInput {
79
+ type: MessageType;
80
+ actionExecutionId: string;
81
+ actionName: string;
82
+ result: string;
83
+ static encodeResult(result: any, error?: {
84
+ code: string;
85
+ message: string;
86
+ } | string | Error): string;
87
+ static decodeResult(result: string): {
88
+ error?: {
89
+ code: string;
90
+ message: string;
91
+ };
92
+ result: string;
93
+ };
94
+ hasError(): boolean;
95
+ getError(): {
96
+ code: string;
97
+ message: string;
98
+ } | undefined;
99
+ }
100
+ declare class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, "state"> {
101
+ type: MessageType;
102
+ threadId: string;
103
+ agentName: string;
104
+ nodeName: string;
105
+ runId: string;
106
+ active: boolean;
107
+ role: MessageRole;
108
+ state: any;
109
+ running: boolean;
110
+ }
111
+ declare class ImageMessage extends Message implements ImageMessageInput {
112
+ type: MessageType;
113
+ format: string;
114
+ bytes: string;
115
+ role: MessageRole;
116
+ parentMessageId?: string;
117
+ }
118
+
119
+ export { ActionInputAvailability as A, ImageMessage as I, Message as M, ResultMessage as R, TextMessage as T, ActionExecutionMessage as a, MessageInput as b, MessageType as c, AgentStateMessage as d };
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import Anthropic from '@anthropic-ai/sdk';
9
9
  import * as graphql from 'graphql';
10
10
  import * as pino from 'pino';
11
11
  import { YogaInitialContext, createYoga } from 'graphql-yoga';
12
- import { CopilotRuntimeOptions, CopilotRuntime as CopilotRuntime$1 } from '@copilotkitnext/runtime';
12
+ import { CopilotRuntimeOptions, CopilotRuntime as CopilotRuntime$1, AgentRunner } from '@copilotkitnext/runtime';
13
13
  import { AbstractAgent } from '@ag-ui/client';
14
14
  import * as http from 'http';
15
15
  import { ServerResponse, IncomingMessage } from 'http';
@@ -573,7 +573,7 @@ declare class LangChainAdapter implements CopilotServiceAdapter {
573
573
  *
574
574
  * const copilotKit = new CopilotRuntime();
575
575
  *
576
- * return new GoogleGenerativeAIAdapter({ model: "gemini-1.5-pro" });
576
+ * return new GoogleGenerativeAIAdapter({ model: "gemini-2.5-flash", apiVersion: "v1" });
577
577
  * ```
578
578
  */
579
579
 
@@ -582,6 +582,10 @@ interface GoogleGenerativeAIAdapterOptions {
582
582
  * A custom Google Generative AI model to use.
583
583
  */
584
584
  model?: string;
585
+ /**
586
+ * The API version to use (e.g. "v1" or "v1beta"). Defaults to "v1".
587
+ */
588
+ apiVersion?: "v1" | "v1beta";
585
589
  /**
586
590
  * The API key to use.
587
591
  */
@@ -1370,31 +1374,90 @@ declare function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerO
1370
1374
  }, res: http.ServerResponse) => Promise<void>;
1371
1375
 
1372
1376
  /**
1373
- * @deprecated LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1377
+ * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry
1378
+ * for agent execution streams.
1379
+ *
1380
+ * This captures the following telemetry events:
1381
+ * - oss.runtime.agent_execution_stream_started - when an agent execution starts
1382
+ * - oss.runtime.agent_execution_stream_ended - when an agent execution completes
1383
+ * - oss.runtime.agent_execution_stream_errored - when an agent execution fails
1384
+ */
1385
+
1386
+ /**
1387
+ * Configuration options for TelemetryAgentRunner
1388
+ */
1389
+ interface TelemetryAgentRunnerConfig {
1390
+ /**
1391
+ * The underlying runner to delegate to
1392
+ * If not provided, defaults to InMemoryAgentRunner
1393
+ */
1394
+ runner?: AgentRunner;
1395
+ /**
1396
+ * Optional LangSmith API key (will be hashed for telemetry)
1397
+ */
1398
+ langsmithApiKey?: string;
1399
+ }
1400
+ /**
1401
+ * An AgentRunner wrapper that adds telemetry tracking for agent executions.
1402
+ *
1403
+ * Usage:
1404
+ * ```ts
1405
+ * const runtime = new CopilotRuntime({
1406
+ * runner: new TelemetryAgentRunner(),
1407
+ * // or with custom runner:
1408
+ * runner: new TelemetryAgentRunner({ runner: customRunner }),
1409
+ * });
1410
+ * ```
1411
+ */
1412
+ declare class TelemetryAgentRunner implements AgentRunner {
1413
+ private readonly _runner;
1414
+ private readonly hashedLgcKey;
1415
+ constructor(config?: TelemetryAgentRunnerConfig);
1416
+ /**
1417
+ * Runs an agent with telemetry tracking.
1418
+ * Wraps the underlying runner's Observable stream with telemetry events.
1419
+ */
1420
+ run(...args: Parameters<AgentRunner["run"]>): ReturnType<AgentRunner["run"]>;
1421
+ /**
1422
+ * Delegates to the underlying runner's connect method
1423
+ */
1424
+ connect(...args: Parameters<AgentRunner["connect"]>): ReturnType<AgentRunner["connect"]>;
1425
+ /**
1426
+ * Delegates to the underlying runner's isRunning method
1427
+ */
1428
+ isRunning(...args: Parameters<AgentRunner["isRunning"]>): ReturnType<AgentRunner["isRunning"]>;
1429
+ /**
1430
+ * Delegates to the underlying runner's stop method
1431
+ */
1432
+ stop(...args: Parameters<AgentRunner["stop"]>): ReturnType<AgentRunner["stop"]>;
1433
+ }
1434
+
1435
+ /**
1436
+ * @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
1374
1437
  */
1375
1438
  declare class LangGraphAgent {
1376
1439
  constructor();
1377
1440
  }
1378
1441
  /**
1379
- * @deprecated LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1442
+ * @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
1380
1443
  */
1381
1444
  declare class LangGraphHttpAgent {
1382
1445
  constructor();
1383
1446
  }
1384
1447
  /**
1385
- * @deprecated TextMessageEvents import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1448
+ * @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
1386
1449
  */
1387
1450
  type TextMessageEvents = any;
1388
1451
  /**
1389
- * @deprecated ToolCallEvents import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1452
+ * @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
1390
1453
  */
1391
1454
  type ToolCallEvents = any;
1392
1455
  /**
1393
- * @deprecated CustomEventNames import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1456
+ * @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
1394
1457
  */
1395
1458
  type CustomEventNames = any;
1396
1459
  /**
1397
- * @deprecated PredictStateTool import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1460
+ * @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
1398
1461
  */
1399
1462
  type PredictStateTool = any;
1400
1463
 
@@ -1443,4 +1506,4 @@ declare class UnknownErrorResponse extends FailedResponseStatus {
1443
1506
  });
1444
1507
  }
1445
1508
 
1446
- export { AnthropicAdapter, AnthropicAdapterParams, AnthropicPromptCachingConfig, BedrockAdapter, BedrockAdapterParams, CommonConfig, CopilotRequestContextProperties, CopilotRuntime, CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotRuntimeConstructorParams_BASE, CopilotRuntimeLogger, CopilotServiceAdapter, CreateCopilotRuntimeServerOptions, CustomEventNames, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GraphQLContext, GroqAdapter, GroqAdapterParams, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, LogLevel, MCPClient, MCPEndpointConfig, MCPTool, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAdapterParams, OpenAIAssistantAdapter, OpenAIAssistantAdapterParams, PredictStateTool, RemoteChain, RemoteChainParameters, TextMessageEvents, ToolCallEvents, UnifyAdapter, UnifyAdapterParams, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
1509
+ export { AnthropicAdapter, AnthropicAdapterParams, AnthropicPromptCachingConfig, BedrockAdapter, BedrockAdapterParams, CommonConfig, CopilotRequestContextProperties, CopilotRuntime, CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotRuntimeConstructorParams_BASE, CopilotRuntimeLogger, CopilotServiceAdapter, CreateCopilotRuntimeServerOptions, CustomEventNames, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GraphQLContext, GroqAdapter, GroqAdapterParams, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, LogLevel, MCPClient, MCPEndpointConfig, MCPTool, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAdapterParams, OpenAIAssistantAdapter, OpenAIAssistantAdapterParams, PredictStateTool, RemoteChain, RemoteChainParameters, TelemetryAgentRunner, TelemetryAgentRunnerConfig, TextMessageEvents, ToolCallEvents, UnifyAdapter, UnifyAdapterParams, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };