@copilotkit/runtime 1.50.0-beta.8 → 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 (226) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/dist/chunk-27JKTS6P.mjs +1704 -0
  3. package/dist/chunk-27JKTS6P.mjs.map +1 -0
  4. package/dist/chunk-2GPTVDTO.mjs +25 -0
  5. package/dist/chunk-2GPTVDTO.mjs.map +1 -0
  6. package/dist/chunk-2OZAGFV3.mjs +43 -0
  7. package/dist/chunk-2OZAGFV3.mjs.map +1 -0
  8. package/dist/chunk-3AJVKDZX.mjs +3097 -0
  9. package/dist/chunk-3AJVKDZX.mjs.map +1 -0
  10. package/dist/chunk-45RCC3ZS.mjs +25 -0
  11. package/dist/chunk-45RCC3ZS.mjs.map +1 -0
  12. package/dist/chunk-4EHJ4XFJ.mjs +25 -0
  13. package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
  14. package/dist/chunk-4IANB4TC.mjs +25 -0
  15. package/dist/chunk-4IANB4TC.mjs.map +1 -0
  16. package/dist/chunk-4KES76K3.mjs +74 -0
  17. package/dist/chunk-4KES76K3.mjs.map +1 -0
  18. package/dist/chunk-4OGE3SLW.mjs +3100 -0
  19. package/dist/chunk-4OGE3SLW.mjs.map +1 -0
  20. package/dist/chunk-54YJBMCP.mjs +3097 -0
  21. package/dist/chunk-54YJBMCP.mjs.map +1 -0
  22. package/dist/chunk-62NE5S6M.mjs +226 -0
  23. package/dist/chunk-62NE5S6M.mjs.map +1 -0
  24. package/dist/chunk-6ER4SZYH.mjs +74 -0
  25. package/dist/chunk-6ER4SZYH.mjs.map +1 -0
  26. package/dist/chunk-6TNSLHVR.mjs +74 -0
  27. package/dist/chunk-6TNSLHVR.mjs.map +1 -0
  28. package/dist/chunk-6XRUR5UK.mjs +1 -0
  29. package/dist/chunk-6XRUR5UK.mjs.map +1 -0
  30. package/dist/chunk-7V4BK7TZ.mjs +25 -0
  31. package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
  32. package/dist/chunk-7YZIEXD2.mjs +74 -0
  33. package/dist/chunk-7YZIEXD2.mjs.map +1 -0
  34. package/dist/chunk-A4XHOAFU.mjs +25 -0
  35. package/dist/chunk-A4XHOAFU.mjs.map +1 -0
  36. package/dist/chunk-A555KEAD.mjs +6020 -0
  37. package/dist/chunk-A555KEAD.mjs.map +1 -0
  38. package/dist/chunk-AF73TFTX.mjs +74 -0
  39. package/dist/chunk-AF73TFTX.mjs.map +1 -0
  40. package/dist/chunk-AMUJQ6IR.mjs +50 -0
  41. package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
  42. package/dist/chunk-AQG2SVCA.mjs +25 -0
  43. package/dist/chunk-AQG2SVCA.mjs.map +1 -0
  44. package/dist/chunk-BJZHMXND.mjs +74 -0
  45. package/dist/chunk-BJZHMXND.mjs.map +1 -0
  46. package/dist/chunk-CB2OJXF6.mjs +25 -0
  47. package/dist/chunk-CB2OJXF6.mjs.map +1 -0
  48. package/dist/chunk-CEOMFPJU.mjs +6020 -0
  49. package/dist/chunk-CEOMFPJU.mjs.map +1 -0
  50. package/dist/chunk-CZVLR7CC.mjs +175 -0
  51. package/dist/chunk-CZVLR7CC.mjs.map +1 -0
  52. package/dist/chunk-DCEEHMLJ.mjs +1127 -0
  53. package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
  54. package/dist/chunk-DE3CLKUG.mjs +25 -0
  55. package/dist/chunk-DE3CLKUG.mjs.map +1 -0
  56. package/dist/chunk-DTPRUTNV.mjs +25 -0
  57. package/dist/chunk-DTPRUTNV.mjs.map +1 -0
  58. package/dist/chunk-ERUOA47O.mjs +626 -0
  59. package/dist/chunk-ERUOA47O.mjs.map +1 -0
  60. package/dist/chunk-ESSRC64W.mjs +74 -0
  61. package/dist/chunk-ESSRC64W.mjs.map +1 -0
  62. package/dist/chunk-FHD4JECV.mjs +33 -0
  63. package/dist/chunk-FHD4JECV.mjs.map +1 -0
  64. package/dist/chunk-GRAN6K6N.mjs +25 -0
  65. package/dist/chunk-GRAN6K6N.mjs.map +1 -0
  66. package/dist/chunk-I27F2UPA.mjs +175 -0
  67. package/dist/chunk-I27F2UPA.mjs.map +1 -0
  68. package/dist/chunk-IAZKTOQW.mjs +25 -0
  69. package/dist/chunk-IAZKTOQW.mjs.map +1 -0
  70. package/dist/chunk-J6XZ5MFB.mjs +25 -0
  71. package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
  72. package/dist/chunk-JJ32MA4C.mjs +73 -0
  73. package/dist/chunk-JJ32MA4C.mjs.map +1 -0
  74. package/dist/chunk-JJY4ZTHQ.mjs +25 -0
  75. package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
  76. package/dist/chunk-KEYLBFU2.mjs +3117 -0
  77. package/dist/chunk-KEYLBFU2.mjs.map +1 -0
  78. package/dist/chunk-KQ53L4WZ.mjs +3094 -0
  79. package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
  80. package/dist/chunk-KTELVQ67.mjs +3098 -0
  81. package/dist/chunk-KTELVQ67.mjs.map +1 -0
  82. package/dist/chunk-LPEPX6NH.mjs +25 -0
  83. package/dist/chunk-LPEPX6NH.mjs.map +1 -0
  84. package/dist/chunk-MDXE55DK.mjs +3117 -0
  85. package/dist/chunk-MDXE55DK.mjs.map +1 -0
  86. package/dist/chunk-MMFUVOXH.mjs +73 -0
  87. package/dist/chunk-MMFUVOXH.mjs.map +1 -0
  88. package/dist/chunk-N3Y4U66N.mjs +253 -0
  89. package/dist/chunk-N3Y4U66N.mjs.map +1 -0
  90. package/dist/chunk-O7UYB4MH.mjs +25 -0
  91. package/dist/chunk-O7UYB4MH.mjs.map +1 -0
  92. package/dist/chunk-OFNVQHNM.mjs +3089 -0
  93. package/dist/chunk-OFNVQHNM.mjs.map +1 -0
  94. package/dist/chunk-OFSV5GET.mjs +3074 -0
  95. package/dist/chunk-OFSV5GET.mjs.map +1 -0
  96. package/dist/chunk-OMRST67R.mjs +25 -0
  97. package/dist/chunk-OMRST67R.mjs.map +1 -0
  98. package/dist/chunk-OWIGJONH.mjs +275 -0
  99. package/dist/chunk-OWIGJONH.mjs.map +1 -0
  100. package/dist/chunk-PRZHE74A.mjs +25 -0
  101. package/dist/chunk-PRZHE74A.mjs.map +1 -0
  102. package/dist/chunk-PTYRVXXP.mjs +80 -0
  103. package/dist/chunk-PTYRVXXP.mjs.map +1 -0
  104. package/dist/chunk-R22B5CCO.mjs +25 -0
  105. package/dist/chunk-R22B5CCO.mjs.map +1 -0
  106. package/dist/chunk-SHBDMA63.mjs +141 -0
  107. package/dist/chunk-SHBDMA63.mjs.map +1 -0
  108. package/dist/chunk-SPVXBPRA.mjs +74 -0
  109. package/dist/chunk-SPVXBPRA.mjs.map +1 -0
  110. package/dist/chunk-T72G46ME.mjs +25 -0
  111. package/dist/chunk-T72G46ME.mjs.map +1 -0
  112. package/dist/chunk-TGELROPU.mjs +25 -0
  113. package/dist/chunk-TGELROPU.mjs.map +1 -0
  114. package/dist/chunk-UNX4IAAD.mjs +25 -0
  115. package/dist/chunk-UNX4IAAD.mjs.map +1 -0
  116. package/dist/chunk-V4DHVC7M.mjs +3085 -0
  117. package/dist/chunk-V4DHVC7M.mjs.map +1 -0
  118. package/dist/chunk-VVRFOB66.mjs +25 -0
  119. package/dist/chunk-VVRFOB66.mjs.map +1 -0
  120. package/dist/chunk-W6NVBYM6.mjs +80 -0
  121. package/dist/chunk-W6NVBYM6.mjs.map +1 -0
  122. package/dist/chunk-W7MBACGC.mjs +74 -0
  123. package/dist/chunk-W7MBACGC.mjs.map +1 -0
  124. package/dist/chunk-WMD4XZZS.mjs +25 -0
  125. package/dist/chunk-WMD4XZZS.mjs.map +1 -0
  126. package/dist/chunk-WX2ZNCRT.mjs +74 -0
  127. package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
  128. package/dist/chunk-XWBDEXDA.mjs +153 -0
  129. package/dist/chunk-XWBDEXDA.mjs.map +1 -0
  130. package/dist/chunk-Y2Z62E2T.mjs +74 -0
  131. package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
  132. package/dist/chunk-YO4I6RVI.mjs +25 -0
  133. package/dist/chunk-YO4I6RVI.mjs.map +1 -0
  134. package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
  135. package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
  136. package/dist/chunk-Z726O3G2.mjs +25 -0
  137. package/dist/chunk-Z726O3G2.mjs.map +1 -0
  138. package/dist/chunk-ZE4SMZZR.mjs +3097 -0
  139. package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
  140. package/dist/chunk-ZULZB33C.mjs +73 -0
  141. package/dist/chunk-ZULZB33C.mjs.map +1 -0
  142. package/dist/chunk-ZVRGXMY7.mjs +25 -0
  143. package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
  144. package/dist/chunk-ZZ35WBYQ.mjs +25 -0
  145. package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
  146. package/dist/graphql/message-conversion/index.d.ts +18 -0
  147. package/dist/graphql/message-conversion/index.js +725 -0
  148. package/dist/graphql/message-conversion/index.js.map +1 -0
  149. package/dist/graphql/message-conversion/index.mjs +245 -0
  150. package/dist/graphql/message-conversion/index.mjs.map +1 -0
  151. package/dist/graphql/types/base/index.d.ts +6 -0
  152. package/dist/graphql/types/base/index.js +63 -0
  153. package/dist/graphql/types/base/index.js.map +1 -0
  154. package/dist/graphql/types/base/index.mjs +8 -0
  155. package/dist/graphql/types/base/index.mjs.map +1 -0
  156. package/dist/graphql/types/converted/index.d.ts +2 -0
  157. package/dist/graphql/types/converted/index.js +200 -0
  158. package/dist/graphql/types/converted/index.js.map +1 -0
  159. package/dist/graphql/types/converted/index.mjs +19 -0
  160. package/dist/graphql/types/converted/index.mjs.map +1 -0
  161. package/dist/groq-adapter-540da9c3.d.ts +331 -0
  162. package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
  163. package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
  164. package/dist/index-96b330da.d.ts +119 -0
  165. package/dist/index-adbd78f1.d.ts +154 -0
  166. package/dist/index.d.ts +67 -8
  167. package/dist/index.js +118 -28
  168. package/dist/index.js.map +1 -1
  169. package/dist/index.mjs +120 -31
  170. package/dist/index.mjs.map +1 -1
  171. package/dist/langserve-0c6100e3.d.ts +257 -0
  172. package/dist/langserve-978d5790.d.ts +243 -0
  173. package/dist/langserve-9fc76ce5.d.ts +243 -0
  174. package/dist/lib/cloud/index.d.ts +6 -0
  175. package/dist/lib/cloud/index.js +18 -0
  176. package/dist/lib/cloud/index.js.map +1 -0
  177. package/dist/lib/cloud/index.mjs +1 -0
  178. package/dist/lib/cloud/index.mjs.map +1 -0
  179. package/dist/lib/index.d.ts +212 -0
  180. package/dist/lib/index.js +7843 -0
  181. package/dist/lib/index.js.map +1 -0
  182. package/dist/lib/index.mjs +76 -0
  183. package/dist/lib/index.mjs.map +1 -0
  184. package/dist/lib/integrations/index.d.ts +34 -0
  185. package/dist/lib/integrations/index.js +3052 -0
  186. package/dist/lib/integrations/index.js.map +1 -0
  187. package/dist/lib/integrations/index.mjs +37 -0
  188. package/dist/lib/integrations/index.mjs.map +1 -0
  189. package/dist/lib/integrations/nest/index.d.ts +15 -0
  190. package/dist/lib/integrations/nest/index.js +2959 -0
  191. package/dist/lib/integrations/nest/index.js.map +1 -0
  192. package/dist/lib/integrations/nest/index.mjs +14 -0
  193. package/dist/lib/integrations/nest/index.mjs.map +1 -0
  194. package/dist/lib/integrations/node-express/index.d.ts +15 -0
  195. package/dist/lib/integrations/node-express/index.js +2959 -0
  196. package/dist/lib/integrations/node-express/index.js.map +1 -0
  197. package/dist/lib/integrations/node-express/index.mjs +14 -0
  198. package/dist/lib/integrations/node-express/index.mjs.map +1 -0
  199. package/dist/lib/integrations/node-http/index.d.ts +15 -0
  200. package/dist/lib/integrations/node-http/index.js +2945 -0
  201. package/dist/lib/integrations/node-http/index.js.map +1 -0
  202. package/dist/lib/integrations/node-http/index.mjs +13 -0
  203. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  204. package/dist/service-adapters/index.d.ts +162 -0
  205. package/dist/service-adapters/index.js +1787 -0
  206. package/dist/service-adapters/index.js.map +1 -0
  207. package/dist/service-adapters/index.mjs +34 -0
  208. package/dist/service-adapters/index.mjs.map +1 -0
  209. package/dist/service-adapters/shared/index.d.ts +9 -0
  210. package/dist/service-adapters/shared/index.js +72 -0
  211. package/dist/service-adapters/shared/index.js.map +1 -0
  212. package/dist/service-adapters/shared/index.mjs +8 -0
  213. package/dist/service-adapters/shared/index.mjs.map +1 -0
  214. package/dist/shared-0a7346ce.d.ts +466 -0
  215. package/dist/shared-35c6eb04.d.ts +448 -0
  216. package/dist/shared-9ed1dc31.d.ts +414 -0
  217. package/dist/shared-da5708fe.d.ts +449 -0
  218. package/dist/utils/index.d.ts +65 -0
  219. package/dist/utils/index.js +175 -0
  220. package/dist/utils/index.js.map +1 -0
  221. package/dist/utils/index.mjs +12 -0
  222. package/dist/utils/index.mjs.map +1 -0
  223. package/package.json +14 -20
  224. package/src/lib/index.ts +7 -6
  225. package/src/lib/runtime/copilot-runtime.ts +62 -26
  226. package/src/lib/runtime/telemetry-agent-runner.ts +139 -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 };
@@ -0,0 +1,65 @@
1
+ declare enum ResponseStatusCode {
2
+ Pending = "pending",
3
+ Success = "success",
4
+ Failed = "failed"
5
+ }
6
+ declare abstract class BaseResponseStatus {
7
+ code: ResponseStatusCode;
8
+ }
9
+ declare enum FailedResponseStatusReason {
10
+ GUARDRAILS_VALIDATION_FAILED = "GUARDRAILS_VALIDATION_FAILED",
11
+ MESSAGE_STREAM_INTERRUPTED = "MESSAGE_STREAM_INTERRUPTED",
12
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
13
+ }
14
+ declare class FailedResponseStatus extends BaseResponseStatus {
15
+ code: ResponseStatusCode;
16
+ reason: FailedResponseStatusReason;
17
+ details?: Record<string, any>;
18
+ }
19
+
20
+ declare class GuardrailsValidationFailureResponse extends FailedResponseStatus {
21
+ reason: FailedResponseStatusReason;
22
+ details: {
23
+ guardrailsReason: string;
24
+ };
25
+ constructor({ guardrailsReason }: {
26
+ guardrailsReason: any;
27
+ });
28
+ }
29
+ declare class MessageStreamInterruptedResponse extends FailedResponseStatus {
30
+ reason: FailedResponseStatusReason;
31
+ details: {
32
+ messageId: string;
33
+ description: string;
34
+ };
35
+ constructor({ messageId }: {
36
+ messageId: string;
37
+ });
38
+ }
39
+ declare class UnknownErrorResponse extends FailedResponseStatus {
40
+ reason: FailedResponseStatusReason;
41
+ details: {
42
+ description?: string;
43
+ originalError?: {
44
+ code?: string;
45
+ statusCode?: number;
46
+ severity?: string;
47
+ visibility?: string;
48
+ originalErrorType?: string;
49
+ extensions?: any;
50
+ };
51
+ };
52
+ constructor({ description, originalError, }: {
53
+ description?: string;
54
+ originalError?: {
55
+ code?: string;
56
+ statusCode?: number;
57
+ severity?: string;
58
+ visibility?: string;
59
+ originalErrorType?: string;
60
+ extensions?: any;
61
+ };
62
+ });
63
+ }
64
+
65
+ export { GuardrailsValidationFailureResponse, MessageStreamInterruptedResponse, UnknownErrorResponse };
@@ -0,0 +1,175 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/index.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ GuardrailsValidationFailureResponse: () => GuardrailsValidationFailureResponse,
24
+ MessageStreamInterruptedResponse: () => MessageStreamInterruptedResponse,
25
+ UnknownErrorResponse: () => UnknownErrorResponse
26
+ });
27
+ module.exports = __toCommonJS(utils_exports);
28
+
29
+ // src/graphql/types/response-status.type.ts
30
+ var import_graphql_scalars = require("graphql-scalars");
31
+ var import_type_graphql = require("type-graphql");
32
+ function _ts_decorate(decorators, target, key, desc) {
33
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
34
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
35
+ r = Reflect.decorate(decorators, target, key, desc);
36
+ else
37
+ for (var i = decorators.length - 1; i >= 0; i--)
38
+ if (d = decorators[i])
39
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
40
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
41
+ }
42
+ __name(_ts_decorate, "_ts_decorate");
43
+ function _ts_metadata(k, v) {
44
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
45
+ return Reflect.metadata(k, v);
46
+ }
47
+ __name(_ts_metadata, "_ts_metadata");
48
+ var ResponseStatusCode;
49
+ (function(ResponseStatusCode2) {
50
+ ResponseStatusCode2["Pending"] = "pending";
51
+ ResponseStatusCode2["Success"] = "success";
52
+ ResponseStatusCode2["Failed"] = "failed";
53
+ })(ResponseStatusCode || (ResponseStatusCode = {}));
54
+ (0, import_type_graphql.registerEnumType)(ResponseStatusCode, {
55
+ name: "ResponseStatusCode"
56
+ });
57
+ var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
58
+ code;
59
+ }, "BaseResponseStatus");
60
+ _ts_decorate([
61
+ (0, import_type_graphql.Field)(() => ResponseStatusCode),
62
+ _ts_metadata("design:type", String)
63
+ ], BaseResponseStatus.prototype, "code", void 0);
64
+ BaseResponseStatus = _ts_decorate([
65
+ (0, import_type_graphql.InterfaceType)({
66
+ resolveType(value) {
67
+ if (value.code === "success") {
68
+ return SuccessResponseStatus;
69
+ } else if (value.code === "failed") {
70
+ return FailedResponseStatus;
71
+ } else if (value.code === "pending") {
72
+ return PendingResponseStatus;
73
+ }
74
+ return void 0;
75
+ }
76
+ }),
77
+ (0, import_type_graphql.ObjectType)()
78
+ ], BaseResponseStatus);
79
+ var PendingResponseStatus = class extends BaseResponseStatus {
80
+ code = "pending";
81
+ };
82
+ __name(PendingResponseStatus, "PendingResponseStatus");
83
+ PendingResponseStatus = _ts_decorate([
84
+ (0, import_type_graphql.ObjectType)({
85
+ implements: BaseResponseStatus
86
+ })
87
+ ], PendingResponseStatus);
88
+ var SuccessResponseStatus = class extends BaseResponseStatus {
89
+ code = "success";
90
+ };
91
+ __name(SuccessResponseStatus, "SuccessResponseStatus");
92
+ SuccessResponseStatus = _ts_decorate([
93
+ (0, import_type_graphql.ObjectType)({
94
+ implements: BaseResponseStatus
95
+ })
96
+ ], SuccessResponseStatus);
97
+ var FailedResponseStatusReason;
98
+ (function(FailedResponseStatusReason2) {
99
+ FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
100
+ FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
101
+ FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
102
+ })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
103
+ (0, import_type_graphql.registerEnumType)(FailedResponseStatusReason, {
104
+ name: "FailedResponseStatusReason"
105
+ });
106
+ var FailedResponseStatus = class extends BaseResponseStatus {
107
+ code = "failed";
108
+ reason;
109
+ details = null;
110
+ };
111
+ __name(FailedResponseStatus, "FailedResponseStatus");
112
+ _ts_decorate([
113
+ (0, import_type_graphql.Field)(() => FailedResponseStatusReason),
114
+ _ts_metadata("design:type", String)
115
+ ], FailedResponseStatus.prototype, "reason", void 0);
116
+ _ts_decorate([
117
+ (0, import_type_graphql.Field)(() => import_graphql_scalars.GraphQLJSON, {
118
+ nullable: true
119
+ }),
120
+ _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
121
+ ], FailedResponseStatus.prototype, "details", void 0);
122
+ FailedResponseStatus = _ts_decorate([
123
+ (0, import_type_graphql.ObjectType)({
124
+ implements: BaseResponseStatus
125
+ })
126
+ ], FailedResponseStatus);
127
+ var ResponseStatusUnion = (0, import_type_graphql.createUnionType)({
128
+ name: "ResponseStatus",
129
+ types: () => [
130
+ PendingResponseStatus,
131
+ SuccessResponseStatus,
132
+ FailedResponseStatus
133
+ ]
134
+ });
135
+
136
+ // src/utils/failed-response-status-reasons.ts
137
+ var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
138
+ reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
139
+ constructor({ guardrailsReason }) {
140
+ super();
141
+ this.details = {
142
+ guardrailsReason
143
+ };
144
+ }
145
+ };
146
+ __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
147
+ var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
148
+ reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
149
+ constructor({ messageId }) {
150
+ super();
151
+ this.details = {
152
+ messageId,
153
+ description: "Check the message for mode details"
154
+ };
155
+ }
156
+ };
157
+ __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
158
+ var UnknownErrorResponse = class extends FailedResponseStatus {
159
+ reason = FailedResponseStatusReason.UNKNOWN_ERROR;
160
+ constructor({ description, originalError }) {
161
+ super();
162
+ this.details = {
163
+ description,
164
+ originalError
165
+ };
166
+ }
167
+ };
168
+ __name(UnknownErrorResponse, "UnknownErrorResponse");
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ GuardrailsValidationFailureResponse,
172
+ MessageStreamInterruptedResponse,
173
+ UnknownErrorResponse
174
+ });
175
+ //# sourceMappingURL=index.js.map