@copilotkit/runtime 1.50.0-beta.9 → 1.50.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 (182) hide show
  1. package/CHANGELOG.md +157 -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 +67 -8
  138. package/dist/index.js +118 -28
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +120 -31
  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/dist/chunk-DZV4ZIAR.mjs.map +0 -1
  178. package/dist/chunk-SBCOROE4.mjs.map +0 -1
  179. package/dist/chunk-TTUAEJLD.mjs.map +0 -1
  180. /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
  181. /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
  182. /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
@@ -0,0 +1,449 @@
1
+ import * as graphql from 'graphql';
2
+ import * as pino from 'pino';
3
+ import { YogaInitialContext, createYoga } from 'graphql-yoga';
4
+ import { Parameter, Action, CopilotErrorHandler, PartialBy, MaybePromise, NonEmptyRecord } from '@copilotkit/shared';
5
+ import { b as CopilotServiceAdapter, A as ActionInput, d as AgentSessionInput, e as AgentStateInput, F as ForwardedParametersInput, E as ExtensionsInput, R as RemoteChainParameters } from './langserve-9fc76ce5.js';
6
+ import { CopilotRuntimeOptions, CopilotRuntime as CopilotRuntime$1 } from '@copilotkitnext/runtime';
7
+ import { a as MessageInput, M as Message } from './index-adbd78f1.js';
8
+ import { CopilotCloudOptions } from './lib/cloud/index.js';
9
+ import { AbstractAgent } from '@ag-ui/client';
10
+
11
+ declare enum MetaEventName {
12
+ LangGraphInterruptEvent = "LangGraphInterruptEvent",
13
+ CopilotKitLangGraphInterruptEvent = "CopilotKitLangGraphInterruptEvent"
14
+ }
15
+
16
+ declare class MetaEventInput {
17
+ name: MetaEventName;
18
+ value?: string;
19
+ response?: string;
20
+ messages?: MessageInput[];
21
+ }
22
+
23
+ interface BaseEndpointDefinition<TActionType extends EndpointType> {
24
+ type?: TActionType;
25
+ }
26
+ interface CopilotKitEndpoint extends BaseEndpointDefinition<EndpointType.CopilotKit> {
27
+ url: string;
28
+ onBeforeRequest?: ({ ctx }: {
29
+ ctx: GraphQLContext;
30
+ }) => {
31
+ headers?: Record<string, string> | undefined;
32
+ };
33
+ }
34
+ interface LangGraphPlatformAgent {
35
+ name: string;
36
+ description: string;
37
+ assistantId?: string;
38
+ }
39
+ interface LangGraphPlatformEndpoint extends BaseEndpointDefinition<EndpointType.LangGraphPlatform> {
40
+ deploymentUrl: string;
41
+ langsmithApiKey?: string | null;
42
+ agents: LangGraphPlatformAgent[];
43
+ }
44
+ type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
45
+ declare enum EndpointType {
46
+ CopilotKit = "copilotKit",
47
+ LangGraphPlatform = "langgraph-platform"
48
+ }
49
+
50
+ interface LLMRequestData {
51
+ threadId?: string;
52
+ runId?: string;
53
+ model?: string;
54
+ messages: any[];
55
+ actions?: any[];
56
+ forwardedParameters?: any;
57
+ timestamp: number;
58
+ provider?: string;
59
+ [key: string]: any;
60
+ }
61
+ interface LLMResponseData {
62
+ threadId: string;
63
+ runId?: string;
64
+ model?: string;
65
+ output: any;
66
+ latency: number;
67
+ timestamp: number;
68
+ provider?: string;
69
+ isProgressiveChunk?: boolean;
70
+ isFinalResponse?: boolean;
71
+ [key: string]: any;
72
+ }
73
+ interface LLMErrorData {
74
+ threadId?: string;
75
+ runId?: string;
76
+ model?: string;
77
+ error: Error | string;
78
+ timestamp: number;
79
+ provider?: string;
80
+ [key: string]: any;
81
+ }
82
+ interface CopilotObservabilityHooks {
83
+ handleRequest: (data: LLMRequestData) => void | Promise<void>;
84
+ handleResponse: (data: LLMResponseData) => void | Promise<void>;
85
+ handleError: (data: LLMErrorData) => void | Promise<void>;
86
+ }
87
+ /**
88
+ * Configuration for CopilotKit logging functionality.
89
+ *
90
+ * @remarks
91
+ * Custom logging handlers require a valid CopilotKit public API key.
92
+ * Sign up at https://docs.copilotkit.ai/quickstart#get-a-copilot-cloud-public-api-key to get your key.
93
+ */
94
+ interface CopilotObservabilityConfig {
95
+ /**
96
+ * Enable or disable logging functionality.
97
+ *
98
+ * @default false
99
+ */
100
+ enabled: boolean;
101
+ /**
102
+ * Controls whether logs are streamed progressively or buffered.
103
+ * - When true: Each token and update is logged as it's generated (real-time)
104
+ * - When false: Complete responses are logged after completion (batched)
105
+ *
106
+ * @default true
107
+ */
108
+ progressive: boolean;
109
+ /**
110
+ * Custom observability hooks for request, response, and error events.
111
+ *
112
+ * @remarks
113
+ * Using custom observability hooks requires a valid CopilotKit public API key.
114
+ */
115
+ hooks: CopilotObservabilityHooks;
116
+ }
117
+
118
+ /**
119
+ * Represents a tool provided by an MCP server.
120
+ */
121
+ interface MCPTool {
122
+ description?: string;
123
+ /** Schema defining parameters, mirroring the MCP structure. */
124
+ schema?: {
125
+ parameters?: {
126
+ properties?: Record<string, any>;
127
+ required?: string[];
128
+ jsonSchema?: Record<string, any>;
129
+ };
130
+ };
131
+ /** The function to call to execute the tool on the MCP server. */
132
+ execute(params: any): Promise<any>;
133
+ }
134
+ /**
135
+ * Defines the contract for *any* MCP client implementation the user might provide.
136
+ */
137
+ interface MCPClient {
138
+ /** A method that returns a map of tool names to MCPTool objects available from the connected MCP server. */
139
+ tools(): Promise<Record<string, MCPTool>>;
140
+ /** An optional method for cleanup if the underlying client requires explicit disconnection. */
141
+ close?(): Promise<void>;
142
+ }
143
+ /**
144
+ * Configuration for connecting to an MCP endpoint.
145
+ */
146
+ interface MCPEndpointConfig {
147
+ endpoint: string;
148
+ apiKey?: string;
149
+ }
150
+ /**
151
+ * Extracts CopilotKit-compatible parameters from an MCP tool schema.
152
+ * @param toolOrSchema The schema object from an MCPTool or the full MCPTool object.
153
+ * @returns An array of Parameter objects.
154
+ */
155
+ declare function extractParametersFromSchema(toolOrSchema?: MCPTool | MCPTool["schema"]): Parameter[];
156
+ /**
157
+ * Converts a map of MCPTools into an array of CopilotKit Actions.
158
+ * @param mcpTools A record mapping tool names to MCPTool objects.
159
+ * @param mcpEndpoint The endpoint URL from which these tools were fetched.
160
+ * @returns An array of Action<any> objects.
161
+ */
162
+ declare function convertMCPToolsToActions(mcpTools: Record<string, MCPTool>, mcpEndpoint: string): Action<any>[];
163
+ /**
164
+ * Generate better instructions for using MCP tools
165
+ * This is used to enhance the system prompt with tool documentation
166
+ */
167
+ declare function generateMcpToolInstructions(toolsMap: Record<string, MCPTool>): string;
168
+
169
+ declare class CopilotContextInput {
170
+ description: string;
171
+ value: string;
172
+ }
173
+
174
+ /**
175
+ * <Callout type="info">
176
+ * This is the reference for the `CopilotRuntime` class. For more information and example code snippets, please see [Concept: Copilot Runtime](/concepts/copilot-runtime).
177
+ * </Callout>
178
+ *
179
+ * ## Usage
180
+ *
181
+ * ```tsx
182
+ * import { CopilotRuntime } from "@copilotkit/runtime";
183
+ *
184
+ * const copilotKit = new CopilotRuntime();
185
+ * ```
186
+ */
187
+
188
+ type CreateMCPClientFunction = (config: MCPEndpointConfig) => Promise<MCPClient>;
189
+
190
+ interface CopilotRuntimeRequest {
191
+ serviceAdapter: CopilotServiceAdapter;
192
+ messages: MessageInput[];
193
+ actions: ActionInput[];
194
+ agentSession?: AgentSessionInput;
195
+ agentStates?: AgentStateInput[];
196
+ outputMessagesPromise: Promise<Message[]>;
197
+ threadId?: string;
198
+ runId?: string;
199
+ publicApiKey?: string;
200
+ graphqlContext: GraphQLContext;
201
+ forwardedParameters?: ForwardedParametersInput;
202
+ url?: string;
203
+ extensions?: ExtensionsInput;
204
+ metaEvents?: MetaEventInput[];
205
+ context?: CopilotContextInput[];
206
+ }
207
+ type ActionsConfiguration<T extends Parameter[] | [] = []> = Action<T>[] | ((ctx: {
208
+ properties: any;
209
+ url?: string;
210
+ }) => Action<T>[]);
211
+ interface OnBeforeRequestOptions {
212
+ threadId?: string;
213
+ runId?: string;
214
+ inputMessages: Message[];
215
+ properties: any;
216
+ url?: string;
217
+ }
218
+ type OnBeforeRequestHandler = (options: OnBeforeRequestOptions) => void | Promise<void>;
219
+ interface OnAfterRequestOptions {
220
+ threadId: string;
221
+ runId?: string;
222
+ inputMessages: Message[];
223
+ outputMessages: Message[];
224
+ properties: any;
225
+ url?: string;
226
+ }
227
+ type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
228
+ interface OnStopGenerationOptions {
229
+ threadId: string;
230
+ runId?: string;
231
+ url?: string;
232
+ agentName?: string;
233
+ lastMessage: MessageInput;
234
+ }
235
+ type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
236
+ interface Middleware {
237
+ /**
238
+ * A function that is called before the request is processed.
239
+ */
240
+ /**
241
+ * @deprecated This middleware hook is deprecated and will be removed in a future version.
242
+ * Use updated middleware integration methods in CopilotRuntimeVNext instead.
243
+ */
244
+ onBeforeRequest?: OnBeforeRequestHandler;
245
+ /**
246
+ * A function that is called after the request is processed.
247
+ */
248
+ /**
249
+ * @deprecated This middleware hook is deprecated and will be removed in a future version.
250
+ * Use updated middleware integration methods in CopilotRuntimeVNext instead.
251
+ */
252
+ onAfterRequest?: OnAfterRequestHandler;
253
+ }
254
+ interface CopilotRuntimeConstructorParams_BASE<T extends Parameter[] | [] = []> {
255
+ /**
256
+ * Middleware to be used by the runtime.
257
+ *
258
+ * ```ts
259
+ * onBeforeRequest: (options: {
260
+ * threadId?: string;
261
+ * runId?: string;
262
+ * inputMessages: Message[];
263
+ * properties: any;
264
+ * }) => void | Promise<void>;
265
+ * ```
266
+ *
267
+ * ```ts
268
+ * onAfterRequest: (options: {
269
+ * threadId?: string;
270
+ * runId?: string;
271
+ * inputMessages: Message[];
272
+ * outputMessages: Message[];
273
+ * properties: any;
274
+ * }) => void | Promise<void>;
275
+ * ```
276
+ */
277
+ /**
278
+ * @deprecated This middleware hook is deprecated and will be removed in a future version.
279
+ * Use updated middleware integration methods in CopilotRuntimeVNext instead.
280
+ */
281
+ middleware?: Middleware;
282
+ actions?: ActionsConfiguration<T>;
283
+ remoteActions?: CopilotKitEndpoint[];
284
+ remoteEndpoints?: EndpointDefinition[];
285
+ langserve?: RemoteChainParameters[];
286
+ agents?: Record<string, AbstractAgent>;
287
+ delegateAgentProcessingToServiceAdapter?: boolean;
288
+ /**
289
+ * Configuration for LLM request/response logging.
290
+ * Requires publicApiKey from CopilotKit component to be set:
291
+ *
292
+ * ```tsx
293
+ * <CopilotKit publicApiKey="ck_pub_..." />
294
+ * ```
295
+ *
296
+ * Example logging config:
297
+ * ```ts
298
+ * logging: {
299
+ * enabled: true, // Enable or disable logging
300
+ * progressive: true, // Set to false for buffered logging
301
+ * logger: {
302
+ * logRequest: (data) => langfuse.trace({ name: "LLM Request", input: data }),
303
+ * logResponse: (data) => langfuse.trace({ name: "LLM Response", output: data }),
304
+ * logError: (errorData) => langfuse.trace({ name: "LLM Error", metadata: errorData }),
305
+ * },
306
+ * }
307
+ * ```
308
+ */
309
+ observability_c?: CopilotObservabilityConfig;
310
+ /**
311
+ * Configuration for connecting to Model Context Protocol (MCP) servers.
312
+ * Allows fetching and using tools defined on external MCP-compliant servers.
313
+ * Requires providing the `createMCPClient` function during instantiation.
314
+ * @experimental
315
+ */
316
+ mcpServers?: MCPEndpointConfig[];
317
+ /**
318
+ * A function that creates an MCP client instance for a given endpoint configuration.
319
+ * This function is responsible for using the appropriate MCP client library
320
+ * (e.g., `@copilotkit/runtime`, `ai`) to establish a connection.
321
+ * Required if `mcpServers` is provided.
322
+ *
323
+ * ```typescript
324
+ * import { experimental_createMCPClient } from "ai"; // Import from vercel ai library
325
+ * // ...
326
+ * const runtime = new CopilotRuntime({
327
+ * mcpServers: [{ endpoint: "..." }],
328
+ * async createMCPClient(config) {
329
+ * return await experimental_createMCPClient({
330
+ * transport: {
331
+ * type: "sse",
332
+ * url: config.endpoint,
333
+ * headers: config.apiKey
334
+ * ? { Authorization: `Bearer ${config.apiKey}` }
335
+ * : undefined,
336
+ * },
337
+ * });
338
+ * }
339
+ * });
340
+ * ```
341
+ */
342
+ createMCPClient?: CreateMCPClientFunction;
343
+ /**
344
+ * Optional error handler for comprehensive debugging and observability.
345
+ *
346
+ * **Requires publicApiKey**: Error handling only works when requests include a valid publicApiKey.
347
+ * This is a premium Copilot Cloud feature.
348
+ *
349
+ * @param errorEvent - Structured error event with rich debugging context
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * const runtime = new CopilotRuntime({
354
+ * onError: (errorEvent) => {
355
+ * debugDashboard.capture(errorEvent);
356
+ * }
357
+ * });
358
+ * ```
359
+ */
360
+ onError?: CopilotErrorHandler;
361
+ onStopGeneration?: OnStopGenerationHandler;
362
+ }
363
+ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> extends Omit<CopilotRuntimeConstructorParams_BASE<T>, "agents">, Omit<CopilotRuntimeOptions, "agents" | "transcriptionService"> {
364
+ /**
365
+ * TODO: un-omit `transcriptionService` above once it's supported
366
+ *
367
+ * This satisfies...
368
+ * – the optional constraint in `CopilotRuntimeConstructorParams_BASE`
369
+ * – the `MaybePromise<NonEmptyRecord<T>>` constraint in `CopilotRuntimeOptionsVNext`
370
+ * – the `Record<string, AbstractAgent>` constraint in `both
371
+ */
372
+ agents?: MaybePromise<NonEmptyRecord<Record<string, AbstractAgent>>>;
373
+ }
374
+ /**
375
+ * Central runtime object passed to all request handlers.
376
+ */
377
+ declare class CopilotRuntime {
378
+ params?: CopilotRuntimeConstructorParams;
379
+ private observability?;
380
+ private mcpToolsCache;
381
+ private runtimeArgs;
382
+ private _instance;
383
+ constructor(params?: CopilotRuntimeConstructorParams & PartialBy<CopilotRuntimeOptions, "agents">);
384
+ get instance(): CopilotRuntime$1;
385
+ private assignEndpointsToAgents;
386
+ handleServiceAdapter(serviceAdapter: CopilotServiceAdapter): void;
387
+ private getToolsFromActions;
388
+ private assignToolsToAgents;
389
+ private createOnBeforeRequestHandler;
390
+ private createOnAfterRequestHandler;
391
+ /**
392
+ * Log LLM request if observability is enabled
393
+ */
394
+ private logObservabilityBeforeRequest;
395
+ /**
396
+ * Log final LLM response after request completes
397
+ */
398
+ private logObservabilityAfterRequest;
399
+ private getToolsFromMCP;
400
+ }
401
+ declare function copilotKitEndpoint(config: Omit<CopilotKitEndpoint, "type">): CopilotKitEndpoint;
402
+ declare function langGraphPlatformEndpoint(config: Omit<LangGraphPlatformEndpoint, "type">): LangGraphPlatformEndpoint;
403
+ declare function resolveEndpointType(endpoint: EndpointDefinition): EndpointType;
404
+
405
+ type LogLevel = "debug" | "info" | "warn" | "error";
406
+ type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
407
+ declare function createLogger(options?: {
408
+ level?: LogLevel;
409
+ component?: string;
410
+ }): pino.Logger<never>;
411
+
412
+ declare const logger: pino.Logger<never>;
413
+ declare const addCustomHeaderPlugin: {
414
+ onResponse({ response }: {
415
+ response: any;
416
+ }): void;
417
+ };
418
+ type AnyPrimitive = string | boolean | number | null;
419
+ type CopilotRequestContextProperties = Record<string, AnyPrimitive | Record<string, AnyPrimitive>>;
420
+ type GraphQLContext = YogaInitialContext & {
421
+ _copilotkit: CreateCopilotRuntimeServerOptions;
422
+ properties: CopilotRequestContextProperties;
423
+ logger: typeof logger;
424
+ };
425
+ interface CreateCopilotRuntimeServerOptions {
426
+ runtime: CopilotRuntime;
427
+ serviceAdapter: CopilotServiceAdapter;
428
+ endpoint: string;
429
+ baseUrl?: string;
430
+ cloud?: CopilotCloudOptions;
431
+ properties?: CopilotRequestContextProperties;
432
+ logLevel?: LogLevel;
433
+ }
434
+ declare function createContext(initialContext: YogaInitialContext, copilotKitContext: CreateCopilotRuntimeServerOptions, contextLogger: typeof logger, properties?: CopilotRequestContextProperties): Promise<Partial<GraphQLContext>>;
435
+ declare function buildSchema(options?: {
436
+ emitSchemaFile?: string;
437
+ }): graphql.GraphQLSchema;
438
+ type CommonConfig = {
439
+ logging: typeof logger;
440
+ schema: ReturnType<typeof buildSchema>;
441
+ plugins: Parameters<typeof createYoga>[0]["plugins"];
442
+ context: (ctx: YogaInitialContext) => Promise<Partial<GraphQLContext>>;
443
+ maskedErrors: {
444
+ maskError: (error: any, message: string, isDev?: boolean) => any;
445
+ };
446
+ };
447
+ declare function getCommonConfig(options: CreateCopilotRuntimeServerOptions): CommonConfig;
448
+
449
+ export { CopilotRequestContextProperties as C, GraphQLContext as G, LogLevel as L, MCPTool as M, addCustomHeaderPlugin as a, CreateCopilotRuntimeServerOptions as b, createContext as c, buildSchema as d, CommonConfig as e, CopilotRuntimeLogger as f, getCommonConfig as g, createLogger as h, CopilotRuntimeRequest as i, CopilotRuntimeConstructorParams_BASE as j, CopilotRuntime as k, copilotKitEndpoint as l, langGraphPlatformEndpoint as m, MCPClient as n, MCPEndpointConfig as o, extractParametersFromSchema as p, convertMCPToolsToActions as q, resolveEndpointType as r, generateMcpToolInstructions as s };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.50.0-beta.9",
12
+ "version": "1.50.0",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -50,11 +50,13 @@
50
50
  "tsconfig": "1.4.6"
51
51
  },
52
52
  "dependencies": {
53
- "@copilotkitnext/agent": "0.0.28",
54
- "@copilotkitnext/runtime": "0.0.28",
53
+ "@ag-ui/client": "^0.0.42",
54
+ "@ag-ui/core": "^0.0.42",
55
+ "@ag-ui/langgraph": "^0.0.20",
56
+ "@copilotkitnext/agent": "0.0.31",
57
+ "@copilotkitnext/runtime": "0.0.31",
55
58
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
56
59
  "@hono/node-server": "^1.13.5",
57
- "@langchain/core": "^0.3.38",
58
60
  "@scarf/scarf": "^1.3.0",
59
61
  "class-transformer": "^0.5.1",
60
62
  "class-validator": "^0.14.1",
@@ -62,7 +64,6 @@
62
64
  "graphql-scalars": "^1.23.0",
63
65
  "graphql-yoga": "^5.3.1",
64
66
  "hono": "^4.10.3",
65
- "langchain": "^0.3.3",
66
67
  "openai": "^4.85.1",
67
68
  "partial-json": "^0.1.7",
68
69
  "pino": "^9.2.0",
@@ -71,31 +72,24 @@
71
72
  "rxjs": "7.8.1",
72
73
  "type-graphql": "2.0.0-rc.1",
73
74
  "zod": "^3.23.3",
74
- "@copilotkit/shared": "1.50.0-beta.9"
75
+ "@copilotkit/shared": "1.50.0"
75
76
  },
76
77
  "peerDependencies": {
77
78
  "@anthropic-ai/sdk": "^0.57.0",
78
- "@ag-ui/client": "^0.0.42",
79
- "@ag-ui/core": ">=0.0.42",
80
- "@ag-ui/encoder": ">=0.0.42",
81
- "@ag-ui/langgraph": ">=0.0.20",
82
- "@ag-ui/proto": ">=0.0.42",
83
- "@langchain/aws": "^0.1.9",
84
- "@langchain/community": "^0.3.58",
85
- "@langchain/google-gauth": "^0.1.0",
86
- "@langchain/langgraph-sdk": "^0.0.70",
87
- "@langchain/openai": "^0.4.2",
79
+ "@langchain/aws": ">=0.1.9",
80
+ "@langchain/core": ">=0.3.66",
81
+ "@langchain/community": ">=0.3.58",
82
+ "@langchain/google-gauth": ">=0.1.0",
83
+ "@langchain/langgraph-sdk": ">=0.1.2",
84
+ "@langchain/openai": ">=0.4.2",
88
85
  "groq-sdk": ">=0.3.0 <1.0.0",
89
- "langchain": "^0.3.3",
86
+ "langchain": ">=0.3.3",
90
87
  "openai": "^4.85.1"
91
88
  },
92
89
  "peerDependenciesMeta": {
93
90
  "@anthropic-ai/sdk": {
94
91
  "optional": true
95
92
  },
96
- "@ag-ui/langgraph": {
97
- "optional": true
98
- },
99
93
  "@langchain/aws": {
100
94
  "optional": true
101
95
  },
package/src/lib/index.ts CHANGED
@@ -8,11 +8,12 @@ export * from "./integrations";
8
8
  export * from "./logger";
9
9
  export * from "./runtime/copilot-runtime";
10
10
  export * from "./runtime/mcp-tools-utils";
11
+ export * from "./runtime/telemetry-agent-runner";
11
12
 
12
13
  // The below re-exports "dummy" classes and types, to get a deprecation warning redirecting the users to import these from the correct, new route
13
14
 
14
15
  /**
15
- * @deprecated LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
16
+ * @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
16
17
  */
17
18
  export class LangGraphAgent {
18
19
  constructor() {
@@ -23,7 +24,7 @@ export class LangGraphAgent {
23
24
  }
24
25
 
25
26
  /**
26
- * @deprecated LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
27
+ * @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
27
28
  */
28
29
  export class LangGraphHttpAgent {
29
30
  constructor() {
@@ -34,18 +35,18 @@ export class LangGraphHttpAgent {
34
35
  }
35
36
 
36
37
  /**
37
- * @deprecated TextMessageEvents import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
38
+ * @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
38
39
  */
39
40
  export type TextMessageEvents = any;
40
41
  /**
41
- * @deprecated ToolCallEvents import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
42
+ * @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
42
43
  */
43
44
  export type ToolCallEvents = any;
44
45
  /**
45
- * @deprecated CustomEventNames import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
46
+ * @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
46
47
  */
47
48
  export type CustomEventNames = any;
48
49
  /**
49
- * @deprecated PredictStateTool import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
50
+ * @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead
50
51
  */
51
52
  export type PredictStateTool = any;