@copilotkit/runtime 1.50.0 → 1.50.1-next.1

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