@copilotkit/runtime 1.50.1-next.0 → 1.50.1-next.2

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 (222) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +2 -2
  7. package/dist/chunk-27JKTS6P.mjs +0 -1704
  8. package/dist/chunk-27JKTS6P.mjs.map +0 -1
  9. package/dist/chunk-2GPTVDTO.mjs +0 -25
  10. package/dist/chunk-2GPTVDTO.mjs.map +0 -1
  11. package/dist/chunk-2OZAGFV3.mjs +0 -43
  12. package/dist/chunk-2OZAGFV3.mjs.map +0 -1
  13. package/dist/chunk-3AJVKDZX.mjs +0 -3097
  14. package/dist/chunk-3AJVKDZX.mjs.map +0 -1
  15. package/dist/chunk-45RCC3ZS.mjs +0 -25
  16. package/dist/chunk-45RCC3ZS.mjs.map +0 -1
  17. package/dist/chunk-4EHJ4XFJ.mjs +0 -25
  18. package/dist/chunk-4EHJ4XFJ.mjs.map +0 -1
  19. package/dist/chunk-4IANB4TC.mjs +0 -25
  20. package/dist/chunk-4IANB4TC.mjs.map +0 -1
  21. package/dist/chunk-4KES76K3.mjs +0 -74
  22. package/dist/chunk-4KES76K3.mjs.map +0 -1
  23. package/dist/chunk-4OGE3SLW.mjs +0 -3100
  24. package/dist/chunk-4OGE3SLW.mjs.map +0 -1
  25. package/dist/chunk-54YJBMCP.mjs +0 -3097
  26. package/dist/chunk-54YJBMCP.mjs.map +0 -1
  27. package/dist/chunk-62NE5S6M.mjs +0 -226
  28. package/dist/chunk-62NE5S6M.mjs.map +0 -1
  29. package/dist/chunk-6ER4SZYH.mjs +0 -74
  30. package/dist/chunk-6ER4SZYH.mjs.map +0 -1
  31. package/dist/chunk-6TNSLHVR.mjs +0 -74
  32. package/dist/chunk-6TNSLHVR.mjs.map +0 -1
  33. package/dist/chunk-6XRUR5UK.mjs +0 -1
  34. package/dist/chunk-6XRUR5UK.mjs.map +0 -1
  35. package/dist/chunk-7V4BK7TZ.mjs +0 -25
  36. package/dist/chunk-7V4BK7TZ.mjs.map +0 -1
  37. package/dist/chunk-7YZIEXD2.mjs +0 -74
  38. package/dist/chunk-7YZIEXD2.mjs.map +0 -1
  39. package/dist/chunk-A4XHOAFU.mjs +0 -25
  40. package/dist/chunk-A4XHOAFU.mjs.map +0 -1
  41. package/dist/chunk-A555KEAD.mjs +0 -6020
  42. package/dist/chunk-A555KEAD.mjs.map +0 -1
  43. package/dist/chunk-AF73TFTX.mjs +0 -74
  44. package/dist/chunk-AF73TFTX.mjs.map +0 -1
  45. package/dist/chunk-AMUJQ6IR.mjs +0 -50
  46. package/dist/chunk-AMUJQ6IR.mjs.map +0 -1
  47. package/dist/chunk-AQG2SVCA.mjs +0 -25
  48. package/dist/chunk-AQG2SVCA.mjs.map +0 -1
  49. package/dist/chunk-BJZHMXND.mjs +0 -74
  50. package/dist/chunk-BJZHMXND.mjs.map +0 -1
  51. package/dist/chunk-CB2OJXF6.mjs +0 -25
  52. package/dist/chunk-CB2OJXF6.mjs.map +0 -1
  53. package/dist/chunk-CEOMFPJU.mjs +0 -6020
  54. package/dist/chunk-CEOMFPJU.mjs.map +0 -1
  55. package/dist/chunk-CZVLR7CC.mjs +0 -175
  56. package/dist/chunk-CZVLR7CC.mjs.map +0 -1
  57. package/dist/chunk-DCEEHMLJ.mjs +0 -1127
  58. package/dist/chunk-DCEEHMLJ.mjs.map +0 -1
  59. package/dist/chunk-DE3CLKUG.mjs +0 -25
  60. package/dist/chunk-DE3CLKUG.mjs.map +0 -1
  61. package/dist/chunk-DTPRUTNV.mjs +0 -25
  62. package/dist/chunk-DTPRUTNV.mjs.map +0 -1
  63. package/dist/chunk-ERUOA47O.mjs +0 -626
  64. package/dist/chunk-ERUOA47O.mjs.map +0 -1
  65. package/dist/chunk-ESSRC64W.mjs +0 -74
  66. package/dist/chunk-ESSRC64W.mjs.map +0 -1
  67. package/dist/chunk-FHD4JECV.mjs +0 -33
  68. package/dist/chunk-FHD4JECV.mjs.map +0 -1
  69. package/dist/chunk-GRAN6K6N.mjs +0 -25
  70. package/dist/chunk-GRAN6K6N.mjs.map +0 -1
  71. package/dist/chunk-I27F2UPA.mjs +0 -175
  72. package/dist/chunk-I27F2UPA.mjs.map +0 -1
  73. package/dist/chunk-IAZKTOQW.mjs +0 -25
  74. package/dist/chunk-IAZKTOQW.mjs.map +0 -1
  75. package/dist/chunk-J6XZ5MFB.mjs +0 -25
  76. package/dist/chunk-J6XZ5MFB.mjs.map +0 -1
  77. package/dist/chunk-JJ32MA4C.mjs +0 -73
  78. package/dist/chunk-JJ32MA4C.mjs.map +0 -1
  79. package/dist/chunk-JJY4ZTHQ.mjs +0 -25
  80. package/dist/chunk-JJY4ZTHQ.mjs.map +0 -1
  81. package/dist/chunk-KEYLBFU2.mjs +0 -3117
  82. package/dist/chunk-KEYLBFU2.mjs.map +0 -1
  83. package/dist/chunk-KQ53L4WZ.mjs +0 -3094
  84. package/dist/chunk-KQ53L4WZ.mjs.map +0 -1
  85. package/dist/chunk-KTELVQ67.mjs +0 -3098
  86. package/dist/chunk-KTELVQ67.mjs.map +0 -1
  87. package/dist/chunk-LPEPX6NH.mjs +0 -25
  88. package/dist/chunk-LPEPX6NH.mjs.map +0 -1
  89. package/dist/chunk-MDXE55DK.mjs +0 -3117
  90. package/dist/chunk-MDXE55DK.mjs.map +0 -1
  91. package/dist/chunk-MMFUVOXH.mjs +0 -73
  92. package/dist/chunk-MMFUVOXH.mjs.map +0 -1
  93. package/dist/chunk-N3Y4U66N.mjs +0 -253
  94. package/dist/chunk-N3Y4U66N.mjs.map +0 -1
  95. package/dist/chunk-O7UYB4MH.mjs +0 -25
  96. package/dist/chunk-O7UYB4MH.mjs.map +0 -1
  97. package/dist/chunk-OFNVQHNM.mjs +0 -3089
  98. package/dist/chunk-OFNVQHNM.mjs.map +0 -1
  99. package/dist/chunk-OFSV5GET.mjs +0 -3074
  100. package/dist/chunk-OFSV5GET.mjs.map +0 -1
  101. package/dist/chunk-OMRST67R.mjs +0 -25
  102. package/dist/chunk-OMRST67R.mjs.map +0 -1
  103. package/dist/chunk-OWIGJONH.mjs +0 -275
  104. package/dist/chunk-OWIGJONH.mjs.map +0 -1
  105. package/dist/chunk-PRZHE74A.mjs +0 -25
  106. package/dist/chunk-PRZHE74A.mjs.map +0 -1
  107. package/dist/chunk-PTYRVXXP.mjs +0 -80
  108. package/dist/chunk-PTYRVXXP.mjs.map +0 -1
  109. package/dist/chunk-R22B5CCO.mjs +0 -25
  110. package/dist/chunk-R22B5CCO.mjs.map +0 -1
  111. package/dist/chunk-SHBDMA63.mjs +0 -141
  112. package/dist/chunk-SHBDMA63.mjs.map +0 -1
  113. package/dist/chunk-SPVXBPRA.mjs +0 -74
  114. package/dist/chunk-SPVXBPRA.mjs.map +0 -1
  115. package/dist/chunk-T72G46ME.mjs +0 -25
  116. package/dist/chunk-T72G46ME.mjs.map +0 -1
  117. package/dist/chunk-TGELROPU.mjs +0 -25
  118. package/dist/chunk-TGELROPU.mjs.map +0 -1
  119. package/dist/chunk-UNX4IAAD.mjs +0 -25
  120. package/dist/chunk-UNX4IAAD.mjs.map +0 -1
  121. package/dist/chunk-V4DHVC7M.mjs +0 -3085
  122. package/dist/chunk-V4DHVC7M.mjs.map +0 -1
  123. package/dist/chunk-VVRFOB66.mjs +0 -25
  124. package/dist/chunk-VVRFOB66.mjs.map +0 -1
  125. package/dist/chunk-W6NVBYM6.mjs +0 -80
  126. package/dist/chunk-W6NVBYM6.mjs.map +0 -1
  127. package/dist/chunk-W7MBACGC.mjs +0 -74
  128. package/dist/chunk-W7MBACGC.mjs.map +0 -1
  129. package/dist/chunk-WMD4XZZS.mjs +0 -25
  130. package/dist/chunk-WMD4XZZS.mjs.map +0 -1
  131. package/dist/chunk-WX2ZNCRT.mjs +0 -74
  132. package/dist/chunk-WX2ZNCRT.mjs.map +0 -1
  133. package/dist/chunk-XWBDEXDA.mjs +0 -153
  134. package/dist/chunk-XWBDEXDA.mjs.map +0 -1
  135. package/dist/chunk-Y2Z62E2T.mjs +0 -74
  136. package/dist/chunk-Y2Z62E2T.mjs.map +0 -1
  137. package/dist/chunk-YO4I6RVI.mjs +0 -25
  138. package/dist/chunk-YO4I6RVI.mjs.map +0 -1
  139. package/dist/chunk-Z6Q5IW6I.mjs +0 -3098
  140. package/dist/chunk-Z6Q5IW6I.mjs.map +0 -1
  141. package/dist/chunk-Z726O3G2.mjs +0 -25
  142. package/dist/chunk-Z726O3G2.mjs.map +0 -1
  143. package/dist/chunk-ZE4SMZZR.mjs +0 -3097
  144. package/dist/chunk-ZE4SMZZR.mjs.map +0 -1
  145. package/dist/chunk-ZULZB33C.mjs +0 -73
  146. package/dist/chunk-ZULZB33C.mjs.map +0 -1
  147. package/dist/chunk-ZVRGXMY7.mjs +0 -25
  148. package/dist/chunk-ZVRGXMY7.mjs.map +0 -1
  149. package/dist/chunk-ZZ35WBYQ.mjs +0 -25
  150. package/dist/chunk-ZZ35WBYQ.mjs.map +0 -1
  151. package/dist/graphql/message-conversion/index.d.ts +0 -18
  152. package/dist/graphql/message-conversion/index.js +0 -725
  153. package/dist/graphql/message-conversion/index.js.map +0 -1
  154. package/dist/graphql/message-conversion/index.mjs +0 -245
  155. package/dist/graphql/message-conversion/index.mjs.map +0 -1
  156. package/dist/graphql/types/base/index.d.ts +0 -6
  157. package/dist/graphql/types/base/index.js +0 -63
  158. package/dist/graphql/types/base/index.js.map +0 -1
  159. package/dist/graphql/types/base/index.mjs +0 -8
  160. package/dist/graphql/types/base/index.mjs.map +0 -1
  161. package/dist/graphql/types/converted/index.d.ts +0 -2
  162. package/dist/graphql/types/converted/index.js +0 -200
  163. package/dist/graphql/types/converted/index.js.map +0 -1
  164. package/dist/graphql/types/converted/index.mjs +0 -19
  165. package/dist/graphql/types/converted/index.mjs.map +0 -1
  166. package/dist/groq-adapter-540da9c3.d.ts +0 -331
  167. package/dist/groq-adapter-a6f5e9d2.d.ts +0 -331
  168. package/dist/groq-adapter-c8aec5c5.d.ts +0 -321
  169. package/dist/index-96b330da.d.ts +0 -119
  170. package/dist/index-adbd78f1.d.ts +0 -154
  171. package/dist/langserve-0c6100e3.d.ts +0 -257
  172. package/dist/langserve-978d5790.d.ts +0 -243
  173. package/dist/langserve-9fc76ce5.d.ts +0 -243
  174. package/dist/lib/cloud/index.d.ts +0 -6
  175. package/dist/lib/cloud/index.js +0 -18
  176. package/dist/lib/cloud/index.js.map +0 -1
  177. package/dist/lib/cloud/index.mjs +0 -1
  178. package/dist/lib/cloud/index.mjs.map +0 -1
  179. package/dist/lib/index.d.ts +0 -212
  180. package/dist/lib/index.js +0 -7843
  181. package/dist/lib/index.js.map +0 -1
  182. package/dist/lib/index.mjs +0 -76
  183. package/dist/lib/index.mjs.map +0 -1
  184. package/dist/lib/integrations/index.d.ts +0 -34
  185. package/dist/lib/integrations/index.js +0 -3052
  186. package/dist/lib/integrations/index.js.map +0 -1
  187. package/dist/lib/integrations/index.mjs +0 -37
  188. package/dist/lib/integrations/index.mjs.map +0 -1
  189. package/dist/lib/integrations/nest/index.d.ts +0 -15
  190. package/dist/lib/integrations/nest/index.js +0 -2959
  191. package/dist/lib/integrations/nest/index.js.map +0 -1
  192. package/dist/lib/integrations/nest/index.mjs +0 -14
  193. package/dist/lib/integrations/nest/index.mjs.map +0 -1
  194. package/dist/lib/integrations/node-express/index.d.ts +0 -15
  195. package/dist/lib/integrations/node-express/index.js +0 -2959
  196. package/dist/lib/integrations/node-express/index.js.map +0 -1
  197. package/dist/lib/integrations/node-express/index.mjs +0 -14
  198. package/dist/lib/integrations/node-express/index.mjs.map +0 -1
  199. package/dist/lib/integrations/node-http/index.d.ts +0 -15
  200. package/dist/lib/integrations/node-http/index.js +0 -2945
  201. package/dist/lib/integrations/node-http/index.js.map +0 -1
  202. package/dist/lib/integrations/node-http/index.mjs +0 -13
  203. package/dist/lib/integrations/node-http/index.mjs.map +0 -1
  204. package/dist/service-adapters/index.d.ts +0 -162
  205. package/dist/service-adapters/index.js +0 -1787
  206. package/dist/service-adapters/index.js.map +0 -1
  207. package/dist/service-adapters/index.mjs +0 -34
  208. package/dist/service-adapters/index.mjs.map +0 -1
  209. package/dist/service-adapters/shared/index.d.ts +0 -9
  210. package/dist/service-adapters/shared/index.js +0 -72
  211. package/dist/service-adapters/shared/index.js.map +0 -1
  212. package/dist/service-adapters/shared/index.mjs +0 -8
  213. package/dist/service-adapters/shared/index.mjs.map +0 -1
  214. package/dist/shared-0a7346ce.d.ts +0 -466
  215. package/dist/shared-35c6eb04.d.ts +0 -448
  216. package/dist/shared-9ed1dc31.d.ts +0 -414
  217. package/dist/shared-da5708fe.d.ts +0 -449
  218. package/dist/utils/index.d.ts +0 -65
  219. package/dist/utils/index.js +0 -175
  220. package/dist/utils/index.js.map +0 -1
  221. package/dist/utils/index.mjs +0 -12
  222. package/dist/utils/index.mjs.map +0 -1
@@ -1,414 +0,0 @@
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 { R as RemoteChainParameters, b as CopilotServiceAdapter } from './langserve-978d5790.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
- interface BaseEndpointDefinition<TActionType extends EndpointType> {
12
- type?: TActionType;
13
- }
14
- interface CopilotKitEndpoint extends BaseEndpointDefinition<EndpointType.CopilotKit> {
15
- url: string;
16
- onBeforeRequest?: ({ ctx }: {
17
- ctx: GraphQLContext;
18
- }) => {
19
- headers?: Record<string, string> | undefined;
20
- };
21
- }
22
- interface LangGraphPlatformAgent {
23
- name: string;
24
- description: string;
25
- assistantId?: string;
26
- }
27
- interface LangGraphPlatformEndpoint extends BaseEndpointDefinition<EndpointType.LangGraphPlatform> {
28
- deploymentUrl: string;
29
- langsmithApiKey?: string | null;
30
- agents: LangGraphPlatformAgent[];
31
- }
32
- type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
33
- declare enum EndpointType {
34
- CopilotKit = "copilotKit",
35
- LangGraphPlatform = "langgraph-platform"
36
- }
37
-
38
- interface LLMRequestData {
39
- threadId?: string;
40
- runId?: string;
41
- model?: string;
42
- messages: any[];
43
- actions?: any[];
44
- forwardedParameters?: any;
45
- timestamp: number;
46
- provider?: string;
47
- [key: string]: any;
48
- }
49
- interface LLMResponseData {
50
- threadId: string;
51
- runId?: string;
52
- model?: string;
53
- output: any;
54
- latency: number;
55
- timestamp: number;
56
- provider?: string;
57
- isProgressiveChunk?: boolean;
58
- isFinalResponse?: boolean;
59
- [key: string]: any;
60
- }
61
- interface LLMErrorData {
62
- threadId?: string;
63
- runId?: string;
64
- model?: string;
65
- error: Error | string;
66
- timestamp: number;
67
- provider?: string;
68
- [key: string]: any;
69
- }
70
- interface CopilotObservabilityHooks {
71
- handleRequest: (data: LLMRequestData) => void | Promise<void>;
72
- handleResponse: (data: LLMResponseData) => void | Promise<void>;
73
- handleError: (data: LLMErrorData) => void | Promise<void>;
74
- }
75
- /**
76
- * Configuration for CopilotKit logging functionality.
77
- *
78
- * @remarks
79
- * Custom logging handlers require a valid CopilotKit public API key.
80
- * Sign up at https://docs.copilotkit.ai/quickstart#get-a-copilot-cloud-public-api-key to get your key.
81
- */
82
- interface CopilotObservabilityConfig {
83
- /**
84
- * Enable or disable logging functionality.
85
- *
86
- * @default false
87
- */
88
- enabled: boolean;
89
- /**
90
- * Controls whether logs are streamed progressively or buffered.
91
- * - When true: Each token and update is logged as it's generated (real-time)
92
- * - When false: Complete responses are logged after completion (batched)
93
- *
94
- * @default true
95
- */
96
- progressive: boolean;
97
- /**
98
- * Custom observability hooks for request, response, and error events.
99
- *
100
- * @remarks
101
- * Using custom observability hooks requires a valid CopilotKit public API key.
102
- */
103
- hooks: CopilotObservabilityHooks;
104
- }
105
-
106
- /**
107
- * Represents a tool provided by an MCP server.
108
- */
109
- interface MCPTool {
110
- description?: string;
111
- /** Schema defining parameters, mirroring the MCP structure. */
112
- schema?: {
113
- parameters?: {
114
- properties?: Record<string, any>;
115
- required?: string[];
116
- jsonSchema?: Record<string, any>;
117
- };
118
- };
119
- /** The function to call to execute the tool on the MCP server. */
120
- execute(params: any): Promise<any>;
121
- }
122
- /**
123
- * Defines the contract for *any* MCP client implementation the user might provide.
124
- */
125
- interface MCPClient {
126
- /** A method that returns a map of tool names to MCPTool objects available from the connected MCP server. */
127
- tools(): Promise<Record<string, MCPTool>>;
128
- /** An optional method for cleanup if the underlying client requires explicit disconnection. */
129
- close?(): Promise<void>;
130
- }
131
- /**
132
- * Configuration for connecting to an MCP endpoint.
133
- */
134
- interface MCPEndpointConfig {
135
- endpoint: string;
136
- apiKey?: string;
137
- }
138
- /**
139
- * Extracts CopilotKit-compatible parameters from an MCP tool schema.
140
- * @param toolOrSchema The schema object from an MCPTool or the full MCPTool object.
141
- * @returns An array of Parameter objects.
142
- */
143
- declare function extractParametersFromSchema(toolOrSchema?: MCPTool | MCPTool["schema"]): Parameter[];
144
- /**
145
- * Converts a map of MCPTools into an array of CopilotKit Actions.
146
- * @param mcpTools A record mapping tool names to MCPTool objects.
147
- * @param mcpEndpoint The endpoint URL from which these tools were fetched.
148
- * @returns An array of Action<any> objects.
149
- */
150
- declare function convertMCPToolsToActions(mcpTools: Record<string, MCPTool>, mcpEndpoint: string): Action<any>[];
151
- /**
152
- * Generate better instructions for using MCP tools
153
- * This is used to enhance the system prompt with tool documentation
154
- */
155
- declare function generateMcpToolInstructions(toolsMap: Record<string, MCPTool>): string;
156
-
157
- /**
158
- * <Callout type="info">
159
- * This is the reference for the `CopilotRuntime` class. For more information and example code snippets, please see [Concept: Copilot Runtime](/concepts/copilot-runtime).
160
- * </Callout>
161
- *
162
- * ## Usage
163
- *
164
- * ```tsx
165
- * import { CopilotRuntime } from "@copilotkit/runtime";
166
- *
167
- * const copilotKit = new CopilotRuntime();
168
- * ```
169
- */
170
-
171
- type CreateMCPClientFunction = (config: MCPEndpointConfig) => Promise<MCPClient>;
172
- type ActionsConfiguration<T extends Parameter[] | [] = []> = Action<T>[] | ((ctx: {
173
- properties: any;
174
- url?: string;
175
- }) => Action<T>[]);
176
- interface OnBeforeRequestOptions {
177
- threadId?: string;
178
- runId?: string;
179
- inputMessages: Message[];
180
- properties: any;
181
- url?: string;
182
- }
183
- type OnBeforeRequestHandler = (options: OnBeforeRequestOptions) => void | Promise<void>;
184
- interface OnAfterRequestOptions {
185
- threadId: string;
186
- runId?: string;
187
- inputMessages: Message[];
188
- outputMessages: Message[];
189
- properties: any;
190
- url?: string;
191
- }
192
- type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
193
- interface OnStopGenerationOptions {
194
- threadId: string;
195
- runId?: string;
196
- url?: string;
197
- agentName?: string;
198
- lastMessage: MessageInput;
199
- }
200
- type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
201
- interface Middleware {
202
- /**
203
- * A function that is called before the request is processed.
204
- */
205
- /**
206
- * @deprecated This middleware hook is deprecated and will be removed in a future version.
207
- * Use updated middleware integration methods in CopilotRuntimeVNext instead.
208
- */
209
- onBeforeRequest?: OnBeforeRequestHandler;
210
- /**
211
- * A function that is called after the request is processed.
212
- */
213
- /**
214
- * @deprecated This middleware hook is deprecated and will be removed in a future version.
215
- * Use updated middleware integration methods in CopilotRuntimeVNext instead.
216
- */
217
- onAfterRequest?: OnAfterRequestHandler;
218
- }
219
- interface CopilotRuntimeConstructorParams_BASE<T extends Parameter[] | [] = []> {
220
- /**
221
- * Middleware to be used by the runtime.
222
- *
223
- * ```ts
224
- * onBeforeRequest: (options: {
225
- * threadId?: string;
226
- * runId?: string;
227
- * inputMessages: Message[];
228
- * properties: any;
229
- * }) => void | Promise<void>;
230
- * ```
231
- *
232
- * ```ts
233
- * onAfterRequest: (options: {
234
- * threadId?: string;
235
- * runId?: string;
236
- * inputMessages: Message[];
237
- * outputMessages: Message[];
238
- * properties: any;
239
- * }) => void | Promise<void>;
240
- * ```
241
- */
242
- /**
243
- * @deprecated This middleware hook is deprecated and will be removed in a future version.
244
- * Use updated middleware integration methods in CopilotRuntimeVNext instead.
245
- */
246
- middleware?: Middleware;
247
- actions?: ActionsConfiguration<T>;
248
- remoteActions?: CopilotKitEndpoint[];
249
- remoteEndpoints?: EndpointDefinition[];
250
- langserve?: RemoteChainParameters[];
251
- agents?: Record<string, AbstractAgent>;
252
- delegateAgentProcessingToServiceAdapter?: boolean;
253
- /**
254
- * Configuration for LLM request/response logging.
255
- * Requires publicApiKey from CopilotKit component to be set:
256
- *
257
- * ```tsx
258
- * <CopilotKit publicApiKey="ck_pub_..." />
259
- * ```
260
- *
261
- * Example logging config:
262
- * ```ts
263
- * logging: {
264
- * enabled: true, // Enable or disable logging
265
- * progressive: true, // Set to false for buffered logging
266
- * logger: {
267
- * logRequest: (data) => langfuse.trace({ name: "LLM Request", input: data }),
268
- * logResponse: (data) => langfuse.trace({ name: "LLM Response", output: data }),
269
- * logError: (errorData) => langfuse.trace({ name: "LLM Error", metadata: errorData }),
270
- * },
271
- * }
272
- * ```
273
- */
274
- observability_c?: CopilotObservabilityConfig;
275
- /**
276
- * Configuration for connecting to Model Context Protocol (MCP) servers.
277
- * Allows fetching and using tools defined on external MCP-compliant servers.
278
- * Requires providing the `createMCPClient` function during instantiation.
279
- * @experimental
280
- */
281
- mcpServers?: MCPEndpointConfig[];
282
- /**
283
- * A function that creates an MCP client instance for a given endpoint configuration.
284
- * This function is responsible for using the appropriate MCP client library
285
- * (e.g., `@copilotkit/runtime`, `ai`) to establish a connection.
286
- * Required if `mcpServers` is provided.
287
- *
288
- * ```typescript
289
- * import { experimental_createMCPClient } from "ai"; // Import from vercel ai library
290
- * // ...
291
- * const runtime = new CopilotRuntime({
292
- * mcpServers: [{ endpoint: "..." }],
293
- * async createMCPClient(config) {
294
- * return await experimental_createMCPClient({
295
- * transport: {
296
- * type: "sse",
297
- * url: config.endpoint,
298
- * headers: config.apiKey
299
- * ? { Authorization: `Bearer ${config.apiKey}` }
300
- * : undefined,
301
- * },
302
- * });
303
- * }
304
- * });
305
- * ```
306
- */
307
- createMCPClient?: CreateMCPClientFunction;
308
- /**
309
- * Optional error handler for comprehensive debugging and observability.
310
- *
311
- * **Requires publicApiKey**: Error handling only works when requests include a valid publicApiKey.
312
- * This is a premium Copilot Cloud feature.
313
- *
314
- * @param errorEvent - Structured error event with rich debugging context
315
- *
316
- * @example
317
- * ```typescript
318
- * const runtime = new CopilotRuntime({
319
- * onError: (errorEvent) => {
320
- * debugDashboard.capture(errorEvent);
321
- * }
322
- * });
323
- * ```
324
- */
325
- onError?: CopilotErrorHandler;
326
- onStopGeneration?: OnStopGenerationHandler;
327
- }
328
- interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> extends Omit<CopilotRuntimeConstructorParams_BASE<T>, "agents">, Omit<CopilotRuntimeOptions, "agents" | "transcriptionService"> {
329
- /**
330
- * TODO: un-omit `transcriptionService` above once it's supported
331
- *
332
- * This satisfies...
333
- * – the optional constraint in `CopilotRuntimeConstructorParams_BASE`
334
- * – the `MaybePromise<NonEmptyRecord<T>>` constraint in `CopilotRuntimeOptionsVNext`
335
- * – the `Record<string, AbstractAgent>` constraint in `both
336
- */
337
- agents?: MaybePromise<NonEmptyRecord<Record<string, AbstractAgent>>>;
338
- }
339
- /**
340
- * Central runtime object passed to all request handlers.
341
- */
342
- declare class CopilotRuntime {
343
- params?: CopilotRuntimeConstructorParams;
344
- private observability?;
345
- private mcpToolsCache;
346
- private runtimeArgs;
347
- private _instance;
348
- constructor(params?: CopilotRuntimeConstructorParams & PartialBy<CopilotRuntimeOptions, "agents">);
349
- get instance(): CopilotRuntime$1;
350
- private assignEndpointsToAgents;
351
- handleServiceAdapter(serviceAdapter: CopilotServiceAdapter): void;
352
- private getToolsFromActions;
353
- private assignToolsToAgents;
354
- private createOnBeforeRequestHandler;
355
- private createOnAfterRequestHandler;
356
- /**
357
- * Log LLM request if observability is enabled
358
- */
359
- private logObservabilityBeforeRequest;
360
- /**
361
- * Log final LLM response after request completes
362
- */
363
- private logObservabilityAfterRequest;
364
- private getToolsFromMCP;
365
- }
366
- declare function copilotKitEndpoint(config: Omit<CopilotKitEndpoint, "type">): CopilotKitEndpoint;
367
- declare function langGraphPlatformEndpoint(config: Omit<LangGraphPlatformEndpoint, "type">): LangGraphPlatformEndpoint;
368
- declare function resolveEndpointType(endpoint: EndpointDefinition): EndpointType;
369
-
370
- type LogLevel = "debug" | "info" | "warn" | "error";
371
- type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
372
- declare function createLogger(options?: {
373
- level?: LogLevel;
374
- component?: string;
375
- }): pino.Logger<never>;
376
-
377
- declare const logger: pino.Logger<never>;
378
- declare const addCustomHeaderPlugin: {
379
- onResponse({ response }: {
380
- response: any;
381
- }): void;
382
- };
383
- type AnyPrimitive = string | boolean | number | null;
384
- type CopilotRequestContextProperties = Record<string, AnyPrimitive | Record<string, AnyPrimitive>>;
385
- type GraphQLContext = YogaInitialContext & {
386
- _copilotkit: CreateCopilotRuntimeServerOptions;
387
- properties: CopilotRequestContextProperties;
388
- logger: typeof logger;
389
- };
390
- interface CreateCopilotRuntimeServerOptions {
391
- runtime: CopilotRuntime;
392
- serviceAdapter: CopilotServiceAdapter;
393
- endpoint: string;
394
- baseUrl?: string;
395
- cloud?: CopilotCloudOptions;
396
- properties?: CopilotRequestContextProperties;
397
- logLevel?: LogLevel;
398
- }
399
- declare function createContext(initialContext: YogaInitialContext, copilotKitContext: CreateCopilotRuntimeServerOptions, contextLogger: typeof logger, properties?: CopilotRequestContextProperties): Promise<Partial<GraphQLContext>>;
400
- declare function buildSchema(options?: {
401
- emitSchemaFile?: string;
402
- }): graphql.GraphQLSchema;
403
- type CommonConfig = {
404
- logging: typeof logger;
405
- schema: ReturnType<typeof buildSchema>;
406
- plugins: Parameters<typeof createYoga>[0]["plugins"];
407
- context: (ctx: YogaInitialContext) => Promise<Partial<GraphQLContext>>;
408
- maskedErrors: {
409
- maskError: (error: any, message: string, isDev?: boolean) => any;
410
- };
411
- };
412
- declare function getCommonConfig(options: CreateCopilotRuntimeServerOptions): CommonConfig;
413
-
414
- 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, CopilotRuntimeConstructorParams_BASE as i, CopilotRuntime as j, copilotKitEndpoint as k, langGraphPlatformEndpoint as l, MCPClient as m, MCPEndpointConfig as n, extractParametersFromSchema as o, convertMCPToolsToActions as p, generateMcpToolInstructions as q, resolveEndpointType as r };