@copilotkit/runtime 1.10.7-next.0 → 1.50.0-beta.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 (134) hide show
  1. package/CHANGELOG.md +0 -6
  2. package/dist/index.d.ts +1655 -27
  3. package/dist/index.js +2172 -5049
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +5441 -99
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/v2/index.d.ts +1 -0
  8. package/dist/v2/index.js +15 -0
  9. package/dist/v2/index.js.map +1 -0
  10. package/dist/v2/index.mjs +4 -0
  11. package/dist/v2/index.mjs.map +1 -0
  12. package/package.json +17 -5
  13. package/src/graphql/message-conversion/agui-to-gql.test.ts +1263 -0
  14. package/src/graphql/message-conversion/agui-to-gql.ts +333 -0
  15. package/src/graphql/message-conversion/gql-to-agui.test.ts +1578 -0
  16. package/src/graphql/message-conversion/gql-to-agui.ts +278 -0
  17. package/src/graphql/message-conversion/index.ts +2 -0
  18. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +526 -0
  19. package/src/graphql/resolvers/copilot.resolver.ts +3 -48
  20. package/src/graphql/resolvers/state.resolver.ts +3 -2
  21. package/src/graphql/types/converted/index.ts +32 -6
  22. package/src/graphql/types/enums.ts +2 -2
  23. package/src/graphql/types/message-status.type.ts +3 -1
  24. package/src/lib/index.ts +1 -1
  25. package/src/lib/integrations/nextjs/app-router.ts +10 -11
  26. package/src/lib/integrations/nextjs/pages-router.ts +4 -11
  27. package/src/lib/integrations/node-http/index.ts +64 -5
  28. package/src/lib/integrations/shared.ts +1 -1
  29. package/src/lib/observability.ts +87 -0
  30. package/src/lib/runtime/{langgraph/langgraph-agent.ts → agent-integrations/langgraph.agent.ts} +5 -0
  31. package/src/lib/runtime/copilot-runtime.ts +346 -1333
  32. package/src/lib/runtime/types.ts +49 -0
  33. package/src/lib/runtime/utils.ts +87 -0
  34. package/src/lib/telemetry-client.ts +6 -5
  35. package/src/service-adapters/anthropic/anthropic-adapter.ts +5 -1
  36. package/src/service-adapters/bedrock/bedrock-adapter.ts +6 -1
  37. package/src/service-adapters/empty/empty-adapter.ts +3 -0
  38. package/src/service-adapters/events.ts +0 -254
  39. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +5 -1
  40. package/src/service-adapters/google/google-genai-adapter.ts +7 -1
  41. package/src/service-adapters/groq/groq-adapter.ts +5 -1
  42. package/src/service-adapters/langchain/langchain-adapter.ts +3 -0
  43. package/src/service-adapters/openai/openai-adapter.ts +5 -1
  44. package/src/service-adapters/openai/openai-assistant-adapter.ts +4 -0
  45. package/src/service-adapters/service-adapter.ts +3 -0
  46. package/src/service-adapters/unify/unify-adapter.ts +6 -1
  47. package/src/v2/index.ts +2 -0
  48. package/tsup.config.ts +2 -1
  49. package/dist/chunk-27JKTS6P.mjs +0 -1704
  50. package/dist/chunk-27JKTS6P.mjs.map +0 -1
  51. package/dist/chunk-2OZAGFV3.mjs +0 -43
  52. package/dist/chunk-2OZAGFV3.mjs.map +0 -1
  53. package/dist/chunk-5BW5IBTZ.mjs +0 -80
  54. package/dist/chunk-5BW5IBTZ.mjs.map +0 -1
  55. package/dist/chunk-AMUJQ6IR.mjs +0 -50
  56. package/dist/chunk-AMUJQ6IR.mjs.map +0 -1
  57. package/dist/chunk-BMIYSM5W.mjs +0 -25
  58. package/dist/chunk-BMIYSM5W.mjs.map +0 -1
  59. package/dist/chunk-FDTCG47E.mjs +0 -25
  60. package/dist/chunk-FDTCG47E.mjs.map +0 -1
  61. package/dist/chunk-FHD4JECV.mjs +0 -33
  62. package/dist/chunk-FHD4JECV.mjs.map +0 -1
  63. package/dist/chunk-LRCKLBMO.mjs +0 -6020
  64. package/dist/chunk-LRCKLBMO.mjs.map +0 -1
  65. package/dist/chunk-R7RMYEPZ.mjs +0 -175
  66. package/dist/chunk-R7RMYEPZ.mjs.map +0 -1
  67. package/dist/chunk-SHBDMA63.mjs +0 -141
  68. package/dist/chunk-SHBDMA63.mjs.map +0 -1
  69. package/dist/chunk-XWBDEXDA.mjs +0 -153
  70. package/dist/chunk-XWBDEXDA.mjs.map +0 -1
  71. package/dist/graphql/types/base/index.d.ts +0 -6
  72. package/dist/graphql/types/base/index.js +0 -63
  73. package/dist/graphql/types/base/index.js.map +0 -1
  74. package/dist/graphql/types/base/index.mjs +0 -8
  75. package/dist/graphql/types/base/index.mjs.map +0 -1
  76. package/dist/graphql/types/converted/index.d.ts +0 -2
  77. package/dist/graphql/types/converted/index.js +0 -200
  78. package/dist/graphql/types/converted/index.js.map +0 -1
  79. package/dist/graphql/types/converted/index.mjs +0 -19
  80. package/dist/graphql/types/converted/index.mjs.map +0 -1
  81. package/dist/groq-adapter-c8aec5c5.d.ts +0 -321
  82. package/dist/index-96b330da.d.ts +0 -119
  83. package/dist/langserve-0c6100e3.d.ts +0 -257
  84. package/dist/lib/cloud/index.d.ts +0 -6
  85. package/dist/lib/cloud/index.js +0 -18
  86. package/dist/lib/cloud/index.js.map +0 -1
  87. package/dist/lib/cloud/index.mjs +0 -1
  88. package/dist/lib/cloud/index.mjs.map +0 -1
  89. package/dist/lib/index.d.ts +0 -212
  90. package/dist/lib/index.js +0 -7843
  91. package/dist/lib/index.js.map +0 -1
  92. package/dist/lib/index.mjs +0 -76
  93. package/dist/lib/index.mjs.map +0 -1
  94. package/dist/lib/integrations/index.d.ts +0 -34
  95. package/dist/lib/integrations/index.js +0 -3052
  96. package/dist/lib/integrations/index.js.map +0 -1
  97. package/dist/lib/integrations/index.mjs +0 -37
  98. package/dist/lib/integrations/index.mjs.map +0 -1
  99. package/dist/lib/integrations/nest/index.d.ts +0 -15
  100. package/dist/lib/integrations/nest/index.js +0 -2959
  101. package/dist/lib/integrations/nest/index.js.map +0 -1
  102. package/dist/lib/integrations/nest/index.mjs +0 -14
  103. package/dist/lib/integrations/nest/index.mjs.map +0 -1
  104. package/dist/lib/integrations/node-express/index.d.ts +0 -15
  105. package/dist/lib/integrations/node-express/index.js +0 -2959
  106. package/dist/lib/integrations/node-express/index.js.map +0 -1
  107. package/dist/lib/integrations/node-express/index.mjs +0 -14
  108. package/dist/lib/integrations/node-express/index.mjs.map +0 -1
  109. package/dist/lib/integrations/node-http/index.d.ts +0 -15
  110. package/dist/lib/integrations/node-http/index.js +0 -2945
  111. package/dist/lib/integrations/node-http/index.js.map +0 -1
  112. package/dist/lib/integrations/node-http/index.mjs +0 -13
  113. package/dist/lib/integrations/node-http/index.mjs.map +0 -1
  114. package/dist/service-adapters/index.d.ts +0 -162
  115. package/dist/service-adapters/index.js +0 -1787
  116. package/dist/service-adapters/index.js.map +0 -1
  117. package/dist/service-adapters/index.mjs +0 -34
  118. package/dist/service-adapters/index.mjs.map +0 -1
  119. package/dist/service-adapters/shared/index.d.ts +0 -9
  120. package/dist/service-adapters/shared/index.js +0 -72
  121. package/dist/service-adapters/shared/index.js.map +0 -1
  122. package/dist/service-adapters/shared/index.mjs +0 -8
  123. package/dist/service-adapters/shared/index.mjs.map +0 -1
  124. package/dist/shared-0a7346ce.d.ts +0 -466
  125. package/dist/utils/index.d.ts +0 -65
  126. package/dist/utils/index.js +0 -175
  127. package/dist/utils/index.js.map +0 -1
  128. package/dist/utils/index.mjs +0 -12
  129. package/dist/utils/index.mjs.map +0 -1
  130. package/src/lib/runtime/__tests__/remote-action-constructors.test.ts +0 -246
  131. package/src/lib/runtime/agui-action.ts +0 -180
  132. package/src/lib/runtime/remote-action-constructors.ts +0 -331
  133. package/src/lib/runtime/remote-actions.ts +0 -217
  134. package/src/lib/runtime/remote-lg-action.ts +0 -1006
package/dist/index.d.ts CHANGED
@@ -1,28 +1,1656 @@
1
- export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from './groq-adapter-c8aec5c5.js';
2
- export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from './shared-0a7346ce.js';
3
- export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './lib/integrations/index.js';
4
- export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
5
- export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
6
- export { copilotRuntimeNestEndpoint } from './lib/integrations/nest/index.js';
7
- export { CustomEventNames, LangGraphAgent, PredictStateTool, TextMessageEvents, ToolCallEvents } from './lib/index.js';
8
- export { GuardrailsValidationFailureResponse, MessageStreamInterruptedResponse, UnknownErrorResponse } from './utils/index.js';
9
- export { C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse, b as CopilotServiceAdapter, c as RemoteChain, R as RemoteChainParameters } from './langserve-0c6100e3.js';
10
- export { convertServiceAdapterError } from './service-adapters/shared/index.js';
11
- export { AnthropicAdapter, AnthropicAdapterParams, AnthropicPromptCachingConfig, BedrockAdapter, BedrockAdapterParams, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter } from './service-adapters/index.js';
1
+ import OpenAI from 'openai';
2
+ import * as rxjs from 'rxjs';
3
+ import { ReplaySubject } from 'rxjs';
4
+ import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
5
+ import { DynamicStructuredTool } from '@langchain/core/tools';
6
+ import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
7
+ import { Groq } from 'groq-sdk';
8
+ import * as graphql from 'graphql';
9
+ import * as pino from 'pino';
10
+ import { YogaInitialContext, createYoga } from 'graphql-yoga';
11
+ import { Parameter, Action, CopilotKitLowLevelError, CopilotErrorHandler, PartialBy, MaybePromise, NonEmptyRecord } from '@copilotkit/shared';
12
+ import { CopilotRuntimeOptions, CopilotRuntime as CopilotRuntime$1 } from '@copilotkitnext/runtime';
13
+ import { AbstractAgent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, RunAgentInput, EventType } from '@ag-ui/client';
14
+ import * as http from 'http';
15
+ import { IncomingMessage, ServerResponse } from 'http';
16
+ import { Readable } from 'node:stream';
17
+ import { LangGraphAgent as LangGraphAgent$1, LangGraphAgentConfig, ProcessedEvents, State, StateEnrichment, SchemaKeys } from '@ag-ui/langgraph';
12
18
  export { LangGraphHttpAgent } from '@ag-ui/langgraph';
13
- import 'openai';
14
- import '@langchain/core/messages';
15
- import '@langchain/core/tools';
16
- import '@langchain/core/utils/stream';
17
- import 'groq-sdk';
18
- import 'graphql';
19
- import 'pino';
20
- import 'graphql-yoga';
21
- import '@copilotkit/shared';
22
- import './index-96b330da.js';
23
- import './graphql/types/base/index.js';
24
- import './lib/cloud/index.js';
25
- import '@ag-ui/client';
26
- import 'rxjs';
27
- import '@langchain/langgraph-sdk/dist/types.messages';
28
- import '@anthropic-ai/sdk';
19
+ import { Message as Message$1 } from '@langchain/langgraph-sdk/dist/types.messages';
20
+ import Anthropic from '@anthropic-ai/sdk';
21
+
22
+ declare enum MessageRole {
23
+ assistant = "assistant",
24
+ developer = "developer",
25
+ system = "system",
26
+ tool = "tool",
27
+ user = "user"
28
+ }
29
+ declare enum ActionInputAvailability {
30
+ disabled = "disabled",
31
+ enabled = "enabled",
32
+ remote = "remote"
33
+ }
34
+
35
+ declare class BaseMessageInput {
36
+ id: string;
37
+ createdAt: Date;
38
+ }
39
+
40
+ declare class MessageInput extends BaseMessageInput {
41
+ textMessage?: TextMessageInput;
42
+ actionExecutionMessage?: ActionExecutionMessageInput;
43
+ resultMessage?: ResultMessageInput;
44
+ agentStateMessage?: AgentStateMessageInput;
45
+ imageMessage?: ImageMessageInput;
46
+ }
47
+ declare class TextMessageInput {
48
+ content: string;
49
+ parentMessageId?: string;
50
+ role: MessageRole;
51
+ }
52
+ declare class ActionExecutionMessageInput {
53
+ name: string;
54
+ arguments: string;
55
+ parentMessageId?: string;
56
+ scope?: String;
57
+ }
58
+ declare class ResultMessageInput {
59
+ actionExecutionId: string;
60
+ actionName: string;
61
+ parentMessageId?: string;
62
+ result: string;
63
+ }
64
+ declare class AgentStateMessageInput {
65
+ threadId: string;
66
+ agentName: string;
67
+ role: MessageRole;
68
+ state: string;
69
+ running: boolean;
70
+ nodeName: string;
71
+ runId: string;
72
+ active: boolean;
73
+ }
74
+ declare class ImageMessageInput {
75
+ format: string;
76
+ bytes: string;
77
+ parentMessageId?: string;
78
+ role: MessageRole;
79
+ }
80
+
81
+ declare enum MessageStatusCode {
82
+ Pending = "pending",
83
+ Success = "success",
84
+ Failed = "failed"
85
+ }
86
+ declare class BaseMessageStatus {
87
+ code: MessageStatusCode;
88
+ }
89
+ declare class PendingMessageStatus extends BaseMessageStatus {
90
+ code: MessageStatusCode;
91
+ }
92
+ declare class SuccessMessageStatus extends BaseMessageStatus {
93
+ code: MessageStatusCode;
94
+ }
95
+ declare class FailedMessageStatus extends BaseMessageStatus {
96
+ code: MessageStatusCode;
97
+ reason: string;
98
+ }
99
+ declare const MessageStatusUnion: PendingMessageStatus | SuccessMessageStatus | FailedMessageStatus;
100
+ type MessageStatus = typeof MessageStatusUnion;
101
+
102
+ declare enum ResponseStatusCode {
103
+ Pending = "pending",
104
+ Success = "success",
105
+ Failed = "failed"
106
+ }
107
+ declare abstract class BaseResponseStatus {
108
+ code: ResponseStatusCode;
109
+ }
110
+ declare enum FailedResponseStatusReason {
111
+ GUARDRAILS_VALIDATION_FAILED = "GUARDRAILS_VALIDATION_FAILED",
112
+ MESSAGE_STREAM_INTERRUPTED = "MESSAGE_STREAM_INTERRUPTED",
113
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
114
+ }
115
+ declare class FailedResponseStatus extends BaseResponseStatus {
116
+ code: ResponseStatusCode;
117
+ reason: FailedResponseStatusReason;
118
+ details?: Record<string, any>;
119
+ }
120
+
121
+ /**
122
+ * The extensions response is used to receive additional information from the copilot runtime, specific to a
123
+ * service adapter or agent framework.
124
+ *
125
+ * Next time a request to the runtime is made, the extensions response will be included in the request as input.
126
+ */
127
+ declare class ExtensionsResponse {
128
+ openaiAssistantAPI?: OpenAIApiAssistantAPIResponse;
129
+ }
130
+ declare class OpenAIApiAssistantAPIResponse {
131
+ runId?: string;
132
+ threadId?: string;
133
+ }
134
+
135
+ declare abstract class BaseMessageOutput {
136
+ id: string;
137
+ createdAt: Date;
138
+ status: typeof MessageStatusUnion;
139
+ }
140
+
141
+ type MessageType = "TextMessage" | "ActionExecutionMessage" | "ResultMessage" | "AgentStateMessage" | "ImageMessage";
142
+ declare class Message {
143
+ type: MessageType;
144
+ id: BaseMessageOutput["id"];
145
+ createdAt: BaseMessageOutput["createdAt"];
146
+ status: MessageStatus;
147
+ constructor(props: any);
148
+ isTextMessage(): this is TextMessage;
149
+ isActionExecutionMessage(): this is ActionExecutionMessage;
150
+ isResultMessage(): this is ResultMessage;
151
+ isAgentStateMessage(): this is AgentStateMessage;
152
+ isImageMessage(): this is ImageMessage;
153
+ }
154
+ type MessageConstructorOptions = Partial<Message>;
155
+ type TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;
156
+ declare class TextMessage extends Message implements TextMessageConstructorOptions {
157
+ content: TextMessageInput["content"];
158
+ parentMessageId: TextMessageInput["parentMessageId"];
159
+ role: TextMessageInput["role"];
160
+ type: "TextMessage";
161
+ constructor(props: TextMessageConstructorOptions);
162
+ }
163
+ declare class ActionExecutionMessage extends Message implements Omit<ActionExecutionMessageInput, "arguments" | "scope"> {
164
+ type: MessageType;
165
+ name: string;
166
+ arguments: Record<string, any>;
167
+ parentMessageId?: string;
168
+ }
169
+ declare class ResultMessage extends Message implements ResultMessageInput {
170
+ type: MessageType;
171
+ actionExecutionId: string;
172
+ actionName: string;
173
+ result: string;
174
+ static encodeResult(result: any, error?: {
175
+ code: string;
176
+ message: string;
177
+ } | string | Error): string;
178
+ static decodeResult(result: string): {
179
+ error?: {
180
+ code: string;
181
+ message: string;
182
+ };
183
+ result: string;
184
+ };
185
+ hasError(): boolean;
186
+ getError(): {
187
+ code: string;
188
+ message: string;
189
+ } | undefined;
190
+ }
191
+ declare class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, "state"> {
192
+ type: MessageType;
193
+ threadId: string;
194
+ agentName: string;
195
+ nodeName: string;
196
+ runId: string;
197
+ active: boolean;
198
+ role: MessageRole;
199
+ state: any;
200
+ running: boolean;
201
+ }
202
+ declare class ImageMessage extends Message implements ImageMessageInput {
203
+ type: MessageType;
204
+ format: string;
205
+ bytes: string;
206
+ role: MessageRole;
207
+ parentMessageId?: string;
208
+ }
209
+
210
+ declare enum RuntimeEventTypes {
211
+ TextMessageStart = "TextMessageStart",
212
+ TextMessageContent = "TextMessageContent",
213
+ TextMessageEnd = "TextMessageEnd",
214
+ ActionExecutionStart = "ActionExecutionStart",
215
+ ActionExecutionArgs = "ActionExecutionArgs",
216
+ ActionExecutionEnd = "ActionExecutionEnd",
217
+ ActionExecutionResult = "ActionExecutionResult",
218
+ AgentStateMessage = "AgentStateMessage",
219
+ MetaEvent = "MetaEvent",
220
+ RunError = "RunError"
221
+ }
222
+ declare enum RuntimeMetaEventName {
223
+ LangGraphInterruptEvent = "LangGraphInterruptEvent",
224
+ LangGraphInterruptResumeEvent = "LangGraphInterruptResumeEvent",
225
+ CopilotKitLangGraphInterruptEvent = "CopilotKitLangGraphInterruptEvent"
226
+ }
227
+ type RunTimeMetaEvent = {
228
+ type: RuntimeEventTypes.MetaEvent;
229
+ name: RuntimeMetaEventName.LangGraphInterruptEvent;
230
+ value: string;
231
+ } | {
232
+ type: RuntimeEventTypes.MetaEvent;
233
+ name: RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent;
234
+ data: {
235
+ value: string;
236
+ messages: (TextMessage | ActionExecutionMessage | ResultMessage)[];
237
+ };
238
+ } | {
239
+ type: RuntimeEventTypes.MetaEvent;
240
+ name: RuntimeMetaEventName.LangGraphInterruptResumeEvent;
241
+ data: string;
242
+ };
243
+ type RuntimeErrorEvent = {
244
+ type: RuntimeEventTypes.RunError;
245
+ message: string;
246
+ code?: string;
247
+ };
248
+ type RuntimeEvent = {
249
+ type: RuntimeEventTypes.TextMessageStart;
250
+ messageId: string;
251
+ parentMessageId?: string;
252
+ } | {
253
+ type: RuntimeEventTypes.TextMessageContent;
254
+ messageId: string;
255
+ content: string;
256
+ } | {
257
+ type: RuntimeEventTypes.TextMessageEnd;
258
+ messageId: string;
259
+ } | {
260
+ type: RuntimeEventTypes.ActionExecutionStart;
261
+ actionExecutionId: string;
262
+ actionName: string;
263
+ parentMessageId?: string;
264
+ } | {
265
+ type: RuntimeEventTypes.ActionExecutionArgs;
266
+ actionExecutionId: string;
267
+ args: string;
268
+ } | {
269
+ type: RuntimeEventTypes.ActionExecutionEnd;
270
+ actionExecutionId: string;
271
+ } | {
272
+ type: RuntimeEventTypes.ActionExecutionResult;
273
+ actionName: string;
274
+ actionExecutionId: string;
275
+ result: string;
276
+ } | {
277
+ type: RuntimeEventTypes.AgentStateMessage;
278
+ threadId: string;
279
+ agentName: string;
280
+ nodeName: string;
281
+ runId: string;
282
+ active: boolean;
283
+ role: string;
284
+ state: string;
285
+ running: boolean;
286
+ } | RunTimeMetaEvent | RuntimeErrorEvent;
287
+ type EventSourceCallback = (eventStream$: RuntimeEventSubject) => Promise<void>;
288
+ declare class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {
289
+ constructor();
290
+ sendTextMessageStart({ messageId, parentMessageId, }: {
291
+ messageId: string;
292
+ parentMessageId?: string;
293
+ }): void;
294
+ sendTextMessageContent({ messageId, content }: {
295
+ messageId: string;
296
+ content: string;
297
+ }): void;
298
+ sendTextMessageEnd({ messageId }: {
299
+ messageId: string;
300
+ }): void;
301
+ sendTextMessage(messageId: string, content: string): void;
302
+ sendActionExecutionStart({ actionExecutionId, actionName, parentMessageId, }: {
303
+ actionExecutionId: string;
304
+ actionName: string;
305
+ parentMessageId?: string;
306
+ }): void;
307
+ sendActionExecutionArgs({ actionExecutionId, args, }: {
308
+ actionExecutionId: string;
309
+ args: string;
310
+ }): void;
311
+ sendActionExecutionEnd({ actionExecutionId }: {
312
+ actionExecutionId: string;
313
+ }): void;
314
+ sendActionExecution({ actionExecutionId, actionName, args, parentMessageId, }: {
315
+ actionExecutionId: string;
316
+ actionName: string;
317
+ args: string;
318
+ parentMessageId?: string;
319
+ }): void;
320
+ sendActionExecutionResult({ actionExecutionId, actionName, result, error, }: {
321
+ actionExecutionId: string;
322
+ actionName: string;
323
+ result?: string;
324
+ error?: {
325
+ code: string;
326
+ message: string;
327
+ };
328
+ }): void;
329
+ sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running, }: {
330
+ threadId: string;
331
+ agentName: string;
332
+ nodeName: string;
333
+ runId: string;
334
+ active: boolean;
335
+ role: string;
336
+ state: string;
337
+ running: boolean;
338
+ }): void;
339
+ }
340
+ declare class RuntimeEventSource {
341
+ private eventStream$;
342
+ private callback;
343
+ private errorHandler?;
344
+ private errorContext?;
345
+ constructor(params?: {
346
+ errorHandler?: (error: any, context: any) => Promise<void>;
347
+ errorContext?: any;
348
+ });
349
+ stream(callback: EventSourceCallback): Promise<void>;
350
+ }
351
+
352
+ declare class ActionInput {
353
+ name: string;
354
+ description: string;
355
+ jsonSchema: string;
356
+ available?: ActionInputAvailability;
357
+ }
358
+
359
+ declare class ForwardedParametersInput {
360
+ model?: string;
361
+ maxTokens?: number;
362
+ stop?: string[];
363
+ toolChoice?: String;
364
+ toolChoiceFunctionName?: string;
365
+ temperature?: number;
366
+ }
367
+
368
+ /**
369
+ * The extensions input is used to pass additional information to the copilot runtime, specific to a
370
+ * service adapter or agent framework.
371
+ */
372
+ declare class ExtensionsInput {
373
+ openaiAssistantAPI?: OpenAIApiAssistantAPIInput;
374
+ }
375
+ declare class OpenAIApiAssistantAPIInput {
376
+ runId?: string;
377
+ threadId?: string;
378
+ }
379
+
380
+ declare class AgentSessionInput {
381
+ agentName: string;
382
+ threadId?: string;
383
+ nodeName?: string;
384
+ }
385
+
386
+ declare class AgentStateInput {
387
+ agentName: string;
388
+ state: string;
389
+ config?: string;
390
+ }
391
+
392
+ interface CopilotRuntimeChatCompletionRequest {
393
+ eventSource: RuntimeEventSource;
394
+ messages: Message[];
395
+ actions: ActionInput[];
396
+ model?: string;
397
+ threadId?: string;
398
+ runId?: string;
399
+ forwardedParameters?: ForwardedParametersInput;
400
+ extensions?: ExtensionsInput;
401
+ agentSession?: AgentSessionInput;
402
+ agentStates?: AgentStateInput[];
403
+ }
404
+ interface CopilotRuntimeChatCompletionResponse {
405
+ threadId: string;
406
+ runId?: string;
407
+ extensions?: ExtensionsResponse;
408
+ }
409
+ interface CopilotServiceAdapter {
410
+ provider?: string;
411
+ model?: string;
412
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
413
+ name?: string;
414
+ }
415
+
416
+ /**
417
+ * Copilot Runtime adapter for OpenAI.
418
+ *
419
+ * ## Example
420
+ *
421
+ * ```ts
422
+ * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
423
+ * import OpenAI from "openai";
424
+ *
425
+ * const copilotKit = new CopilotRuntime();
426
+ *
427
+ * const openai = new OpenAI({
428
+ * organization: "<your-organization-id>", // optional
429
+ * apiKey: "<your-api-key>",
430
+ * });
431
+ *
432
+ * return new OpenAIAdapter({ openai });
433
+ * ```
434
+ *
435
+ * ## Example with Azure OpenAI
436
+ *
437
+ * ```ts
438
+ * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
439
+ * import OpenAI from "openai";
440
+ *
441
+ * // The name of your Azure OpenAI Instance.
442
+ * // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
443
+ * const instance = "<your instance name>";
444
+ *
445
+ * // Corresponds to your Model deployment within your OpenAI resource, e.g. my-gpt35-16k-deployment
446
+ * // Navigate to the Azure OpenAI Studio to deploy a model.
447
+ * const model = "<your model>";
448
+ *
449
+ * const apiKey = process.env["AZURE_OPENAI_API_KEY"];
450
+ * if (!apiKey) {
451
+ * throw new Error("The AZURE_OPENAI_API_KEY environment variable is missing or empty.");
452
+ * }
453
+ *
454
+ * const copilotKit = new CopilotRuntime();
455
+ *
456
+ * const openai = new OpenAI({
457
+ * apiKey,
458
+ * baseURL: `https://${instance}.openai.azure.com/openai/deployments/${model}`,
459
+ * defaultQuery: { "api-version": "2024-04-01-preview" },
460
+ * defaultHeaders: { "api-key": apiKey },
461
+ * });
462
+ *
463
+ * return new OpenAIAdapter({ openai });
464
+ * ```
465
+ */
466
+
467
+ interface OpenAIAdapterParams {
468
+ /**
469
+ * An optional OpenAI instance to use. If not provided, a new instance will be
470
+ * created.
471
+ */
472
+ openai?: OpenAI;
473
+ /**
474
+ * The model to use.
475
+ */
476
+ model?: string;
477
+ /**
478
+ * Whether to disable parallel tool calls.
479
+ * You can disable parallel tool calls to force the model to execute tool calls sequentially.
480
+ * This is useful if you want to execute tool calls in a specific order so that the state changes
481
+ * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
482
+ *
483
+ * @default false
484
+ */
485
+ disableParallelToolCalls?: boolean;
486
+ /**
487
+ * Whether to keep the role in system messages as "System".
488
+ * By default, it is converted to "developer", which is used by newer OpenAI models
489
+ *
490
+ * @default false
491
+ */
492
+ keepSystemRole?: boolean;
493
+ }
494
+ declare class OpenAIAdapter implements CopilotServiceAdapter {
495
+ model: string;
496
+ provider: string;
497
+ private disableParallelToolCalls;
498
+ private _openai;
499
+ private keepSystemRole;
500
+ get openai(): OpenAI;
501
+ get name(): string;
502
+ constructor(params?: OpenAIAdapterParams);
503
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
504
+ }
505
+
506
+ type LangChainBaseMessageChunkStream = IterableReadableStream<BaseMessageChunk>;
507
+ type LangChainAIMessageChunkStream = IterableReadableStreamInterface<AIMessageChunk>;
508
+ type LangChainReturnType = LangChainBaseMessageChunkStream | LangChainAIMessageChunkStream | BaseMessageChunk | string | AIMessage;
509
+
510
+ /**
511
+ * Copilot Runtime adapter for LangChain.
512
+ *
513
+ * ## Example
514
+ *
515
+ * ```ts
516
+ * import { CopilotRuntime, LangChainAdapter } from "@copilotkit/runtime";
517
+ * import { ChatOpenAI } from "@langchain/openai";
518
+ *
519
+ * const copilotKit = new CopilotRuntime();
520
+ *
521
+ * const model = new ChatOpenAI({
522
+ * model: "gpt-4o",
523
+ * apiKey: "<your-api-key>",
524
+ * });
525
+ *
526
+ * return new LangChainAdapter({
527
+ * chainFn: async ({ messages, tools }) => {
528
+ * return model.bindTools(tools).stream(messages);
529
+ * // or optionally enable strict mode
530
+ * // return model.bindTools(tools, { strict: true }).stream(messages);
531
+ * }
532
+ * });
533
+ * ```
534
+ *
535
+ * The asynchronous handler function (`chainFn`) can return any of the following:
536
+ *
537
+ * - A simple `string` response
538
+ * - A LangChain stream (`IterableReadableStream`)
539
+ * - A LangChain `BaseMessageChunk` object
540
+ * - A LangChain `AIMessage` object
541
+ */
542
+
543
+ interface ChainFnParameters {
544
+ model: string;
545
+ messages: BaseMessage[];
546
+ tools: DynamicStructuredTool[];
547
+ threadId?: string;
548
+ runId?: string;
549
+ }
550
+ interface LangChainAdapterOptions {
551
+ /**
552
+ * A function that uses the LangChain API to generate a response.
553
+ */
554
+ chainFn: (parameters: ChainFnParameters) => Promise<LangChainReturnType>;
555
+ }
556
+ declare class LangChainAdapter implements CopilotServiceAdapter {
557
+ private options;
558
+ /**
559
+ * To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
560
+ */
561
+ get name(): string;
562
+ constructor(options: LangChainAdapterOptions);
563
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
564
+ }
565
+
566
+ interface GoogleGenerativeAIAdapterOptions {
567
+ /**
568
+ * A custom Google Generative AI model to use.
569
+ */
570
+ model?: string;
571
+ /**
572
+ * The API key to use.
573
+ */
574
+ apiKey?: string;
575
+ }
576
+ declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
577
+ provider: string;
578
+ model: string;
579
+ constructor(options?: GoogleGenerativeAIAdapterOptions);
580
+ }
581
+
582
+ /**
583
+ * Copilot Runtime adapter for the OpenAI Assistant API.
584
+ *
585
+ * ## Example
586
+ *
587
+ * ```ts
588
+ * import { CopilotRuntime, OpenAIAssistantAdapter } from "@copilotkit/runtime";
589
+ * import OpenAI from "openai";
590
+ *
591
+ * const copilotKit = new CopilotRuntime();
592
+ *
593
+ * const openai = new OpenAI({
594
+ * organization: "<your-organization-id>",
595
+ * apiKey: "<your-api-key>",
596
+ * });
597
+ *
598
+ * return new OpenAIAssistantAdapter({
599
+ * openai,
600
+ * assistantId: "<your-assistant-id>",
601
+ * codeInterpreterEnabled: true,
602
+ * fileSearchEnabled: true,
603
+ * });
604
+ * ```
605
+ */
606
+
607
+ interface OpenAIAssistantAdapterParams {
608
+ /**
609
+ * The ID of the assistant to use.
610
+ */
611
+ assistantId: string;
612
+ /**
613
+ * An optional OpenAI instance to use. If not provided, a new instance will be created.
614
+ */
615
+ openai?: OpenAI;
616
+ /**
617
+ * Whether to enable code interpretation.
618
+ * @default true
619
+ */
620
+ codeInterpreterEnabled?: boolean;
621
+ /**
622
+ * Whether to enable file search.
623
+ * @default true
624
+ */
625
+ fileSearchEnabled?: boolean;
626
+ /**
627
+ * Whether to disable parallel tool calls.
628
+ * You can disable parallel tool calls to force the model to execute tool calls sequentially.
629
+ * This is useful if you want to execute tool calls in a specific order so that the state changes
630
+ * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
631
+ *
632
+ * @default false
633
+ */
634
+ disableParallelToolCalls?: boolean;
635
+ /**
636
+ * Whether to keep the role in system messages as "System".
637
+ * By default, it is converted to "developer", which is used by newer OpenAI models
638
+ *
639
+ * @default false
640
+ */
641
+ keepSystemRole?: boolean;
642
+ }
643
+ declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
644
+ private openai;
645
+ private codeInterpreterEnabled;
646
+ private assistantId;
647
+ private fileSearchEnabled;
648
+ private disableParallelToolCalls;
649
+ private keepSystemRole;
650
+ get name(): string;
651
+ constructor(params: OpenAIAssistantAdapterParams);
652
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
653
+ private submitToolOutputs;
654
+ private submitUserMessage;
655
+ private streamResponse;
656
+ }
657
+
658
+ /**
659
+ * CopilotKit Adapter for Unify
660
+ *
661
+ * <RequestExample>
662
+ * ```jsx CopilotRuntime Example
663
+ * const copilotKit = new CopilotRuntime();
664
+ * return copilotKit.response(req, new UnifyAdapter());
665
+ * ```
666
+ * </RequestExample>
667
+ *
668
+ * You can easily set the model to use by passing it to the constructor.
669
+ * ```jsx
670
+ * const copilotKit = new CopilotRuntime();
671
+ * return copilotKit.response(
672
+ * req,
673
+ * new UnifyAdapter({ model: "llama-3-8b-chat@fireworks-ai" }),
674
+ * );
675
+ * ```
676
+ */
677
+
678
+ interface UnifyAdapterParams {
679
+ apiKey?: string;
680
+ model: string;
681
+ }
682
+ declare class UnifyAdapter implements CopilotServiceAdapter {
683
+ private apiKey;
684
+ model: string;
685
+ private start;
686
+ provider: string;
687
+ get name(): string;
688
+ constructor(options?: UnifyAdapterParams);
689
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
690
+ }
691
+
692
+ /**
693
+ * Copilot Runtime adapter for Groq.
694
+ *
695
+ * ## Example
696
+ *
697
+ * ```ts
698
+ * import { CopilotRuntime, GroqAdapter } from "@copilotkit/runtime";
699
+ * import { Groq } from "groq-sdk";
700
+ *
701
+ * const groq = new Groq({ apiKey: process.env["GROQ_API_KEY"] });
702
+ *
703
+ * const copilotKit = new CopilotRuntime();
704
+ *
705
+ * return new GroqAdapter({ groq, model: "<model-name>" });
706
+ * ```
707
+ */
708
+
709
+ interface GroqAdapterParams {
710
+ /**
711
+ * An optional Groq instance to use.
712
+ */
713
+ groq?: Groq;
714
+ /**
715
+ * The model to use.
716
+ */
717
+ model?: string;
718
+ /**
719
+ * Whether to disable parallel tool calls.
720
+ * You can disable parallel tool calls to force the model to execute tool calls sequentially.
721
+ * This is useful if you want to execute tool calls in a specific order so that the state changes
722
+ * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
723
+ *
724
+ * @default false
725
+ */
726
+ disableParallelToolCalls?: boolean;
727
+ }
728
+ declare class GroqAdapter implements CopilotServiceAdapter {
729
+ model: string;
730
+ provider: string;
731
+ private disableParallelToolCalls;
732
+ private _groq;
733
+ get groq(): Groq;
734
+ get name(): string;
735
+ constructor(params?: GroqAdapterParams);
736
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
737
+ }
738
+
739
+ interface RemoteChainParameters {
740
+ name: string;
741
+ description: string;
742
+ chainUrl: string;
743
+ parameters?: Parameter[];
744
+ parameterType?: "single" | "multi";
745
+ }
746
+ declare class RemoteChain {
747
+ name: string;
748
+ description: string;
749
+ chainUrl: string;
750
+ parameters?: Parameter[];
751
+ parameterType: "single" | "multi";
752
+ constructor(options: RemoteChainParameters);
753
+ toAction(): Promise<Action<any>>;
754
+ inferLangServeParameters(): Promise<void>;
755
+ }
756
+
757
+ /**
758
+ * Converts service adapter errors to structured CopilotKitError format using HTTP status codes.
759
+ * This provides consistent error classification across all service adapters.
760
+ */
761
+ declare function convertServiceAdapterError(error: any, adapterName: string): CopilotKitLowLevelError;
762
+
763
+ /**
764
+ * Copilot Runtime adapter for Anthropic.
765
+ *
766
+ * ## Example
767
+ *
768
+ * ```ts
769
+ * import { CopilotRuntime, AnthropicAdapter } from "@copilotkit/runtime";
770
+ * import Anthropic from "@anthropic-ai/sdk";
771
+ *
772
+ * const copilotKit = new CopilotRuntime();
773
+ *
774
+ * const anthropic = new Anthropic({
775
+ * apiKey: "<your-api-key>",
776
+ * });
777
+ *
778
+ * return new AnthropicAdapter({
779
+ * anthropic,
780
+ * promptCaching: {
781
+ * enabled: true,
782
+ * debug: true
783
+ * }
784
+ * });
785
+ * ```
786
+ */
787
+
788
+ interface AnthropicPromptCachingConfig {
789
+ /**
790
+ * Whether to enable prompt caching.
791
+ */
792
+ enabled: boolean;
793
+ /**
794
+ * Whether to enable debug logging for cache operations.
795
+ */
796
+ debug?: boolean;
797
+ }
798
+ interface AnthropicAdapterParams {
799
+ /**
800
+ * An optional Anthropic instance to use. If not provided, a new instance will be
801
+ * created.
802
+ */
803
+ anthropic?: Anthropic;
804
+ /**
805
+ * The model to use.
806
+ */
807
+ model?: string;
808
+ /**
809
+ * Configuration for prompt caching.
810
+ * See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
811
+ */
812
+ promptCaching?: AnthropicPromptCachingConfig;
813
+ }
814
+ declare class AnthropicAdapter implements CopilotServiceAdapter {
815
+ model: string;
816
+ provider: string;
817
+ private promptCaching;
818
+ private _anthropic;
819
+ get anthropic(): Anthropic;
820
+ get name(): string;
821
+ constructor(params?: AnthropicAdapterParams);
822
+ /**
823
+ * Adds cache control to system prompt
824
+ */
825
+ private addSystemPromptCaching;
826
+ /**
827
+ * Adds cache control to the final message
828
+ */
829
+ private addIncrementalMessageCaching;
830
+ private shouldGenerateFallbackResponse;
831
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
832
+ }
833
+
834
+ interface OllamaAdapterOptions {
835
+ model?: string;
836
+ }
837
+ declare class ExperimentalOllamaAdapter implements CopilotServiceAdapter {
838
+ model: string;
839
+ provider: string;
840
+ get name(): string;
841
+ constructor(options?: OllamaAdapterOptions);
842
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
843
+ }
844
+
845
+ /**
846
+ * Copilot Runtime adapter for AWS Bedrock.
847
+ *
848
+ * ## Example
849
+ *
850
+ * ```ts
851
+ * import { CopilotRuntime, BedrockAdapter } from "@copilotkit/runtime";
852
+ *
853
+ * const copilotKit = new CopilotRuntime();
854
+ *
855
+ * return new BedrockAdapter({
856
+ * model: "amazon.nova-lite-v1:0",
857
+ * region: "us-east-1",
858
+ * credentials: {
859
+ * accessKeyId: process.env.AWS_ACCESS_KEY_ID,
860
+ * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
861
+ * }
862
+ * });
863
+ * ```
864
+ */
865
+
866
+ interface BedrockAdapterParams {
867
+ /**
868
+ * AWS Bedrock model ID to use.
869
+ * @default "amazon.nova-lite-v1:0"
870
+ */
871
+ model?: string;
872
+ /**
873
+ * AWS region where Bedrock is available.
874
+ * @default "us-east-1"
875
+ */
876
+ region?: string;
877
+ /**
878
+ * AWS credentials for Bedrock access.
879
+ */
880
+ credentials?: {
881
+ accessKeyId?: string;
882
+ secretAccessKey?: string;
883
+ };
884
+ }
885
+ declare class BedrockAdapter extends LangChainAdapter {
886
+ provider: string;
887
+ model: string;
888
+ constructor(options?: BedrockAdapterParams);
889
+ }
890
+
891
+ /**
892
+ * CopilotKit Empty Adapter
893
+ *
894
+ * This adapter is meant to preserve adherence to runtime requirements, while doing nothing
895
+ * Ideal if you don't want to connect an LLM the to the runtime, and only use your LangGraph agent.
896
+ * Be aware that Copilot Suggestions will not work if you use this adapter
897
+ *
898
+ * ## Example
899
+ *
900
+ * ```ts
901
+ * import { CopilotRuntime, EmptyAdapter } from "@copilotkit/runtime";
902
+ *
903
+ * const copilotKit = new CopilotRuntime();
904
+ *
905
+ * return new EmptyAdapter();
906
+ * ```
907
+ */
908
+
909
+ declare class EmptyAdapter implements CopilotServiceAdapter {
910
+ process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
911
+ get name(): string;
912
+ }
913
+ declare const ExperimentalEmptyAdapter: typeof EmptyAdapter;
914
+
915
+ interface BaseEndpointDefinition<TActionType extends EndpointType> {
916
+ type?: TActionType;
917
+ }
918
+ interface CopilotKitEndpoint extends BaseEndpointDefinition<EndpointType.CopilotKit> {
919
+ url: string;
920
+ onBeforeRequest?: ({ ctx }: {
921
+ ctx: GraphQLContext;
922
+ }) => {
923
+ headers?: Record<string, string> | undefined;
924
+ };
925
+ }
926
+ interface LangGraphPlatformAgent {
927
+ name: string;
928
+ description: string;
929
+ assistantId?: string;
930
+ }
931
+ interface LangGraphPlatformEndpoint extends BaseEndpointDefinition<EndpointType.LangGraphPlatform> {
932
+ deploymentUrl: string;
933
+ langsmithApiKey?: string | null;
934
+ agents: LangGraphPlatformAgent[];
935
+ }
936
+ type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
937
+ declare enum EndpointType {
938
+ CopilotKit = "copilotKit",
939
+ LangGraphPlatform = "langgraph-platform"
940
+ }
941
+
942
+ interface LLMRequestData {
943
+ threadId?: string;
944
+ runId?: string;
945
+ model?: string;
946
+ messages: any[];
947
+ actions?: any[];
948
+ forwardedParameters?: any;
949
+ timestamp: number;
950
+ provider?: string;
951
+ [key: string]: any;
952
+ }
953
+ interface LLMResponseData {
954
+ threadId: string;
955
+ runId?: string;
956
+ model?: string;
957
+ output: any;
958
+ latency: number;
959
+ timestamp: number;
960
+ provider?: string;
961
+ isProgressiveChunk?: boolean;
962
+ isFinalResponse?: boolean;
963
+ [key: string]: any;
964
+ }
965
+ interface LLMErrorData {
966
+ threadId?: string;
967
+ runId?: string;
968
+ model?: string;
969
+ error: Error | string;
970
+ timestamp: number;
971
+ provider?: string;
972
+ [key: string]: any;
973
+ }
974
+ interface CopilotObservabilityHooks {
975
+ handleRequest: (data: LLMRequestData) => void | Promise<void>;
976
+ handleResponse: (data: LLMResponseData) => void | Promise<void>;
977
+ handleError: (data: LLMErrorData) => void | Promise<void>;
978
+ }
979
+ /**
980
+ * Configuration for CopilotKit logging functionality.
981
+ *
982
+ * @remarks
983
+ * Custom logging handlers require a valid CopilotKit public API key.
984
+ * Sign up at https://docs.copilotkit.ai/quickstart#get-a-copilot-cloud-public-api-key to get your key.
985
+ */
986
+ interface CopilotObservabilityConfig {
987
+ /**
988
+ * Enable or disable logging functionality.
989
+ *
990
+ * @default false
991
+ */
992
+ enabled: boolean;
993
+ /**
994
+ * Controls whether logs are streamed progressively or buffered.
995
+ * - When true: Each token and update is logged as it's generated (real-time)
996
+ * - When false: Complete responses are logged after completion (batched)
997
+ *
998
+ * @default true
999
+ */
1000
+ progressive: boolean;
1001
+ /**
1002
+ * Custom observability hooks for request, response, and error events.
1003
+ *
1004
+ * @remarks
1005
+ * Using custom observability hooks requires a valid CopilotKit public API key.
1006
+ */
1007
+ hooks: CopilotObservabilityHooks;
1008
+ }
1009
+
1010
+ /**
1011
+ * Represents a tool provided by an MCP server.
1012
+ */
1013
+ interface MCPTool {
1014
+ description?: string;
1015
+ /** Schema defining parameters, mirroring the MCP structure. */
1016
+ schema?: {
1017
+ parameters?: {
1018
+ properties?: Record<string, any>;
1019
+ required?: string[];
1020
+ jsonSchema?: Record<string, any>;
1021
+ };
1022
+ };
1023
+ /** The function to call to execute the tool on the MCP server. */
1024
+ execute(params: any): Promise<any>;
1025
+ }
1026
+ /**
1027
+ * Defines the contract for *any* MCP client implementation the user might provide.
1028
+ */
1029
+ interface MCPClient {
1030
+ /** A method that returns a map of tool names to MCPTool objects available from the connected MCP server. */
1031
+ tools(): Promise<Record<string, MCPTool>>;
1032
+ /** An optional method for cleanup if the underlying client requires explicit disconnection. */
1033
+ close?(): Promise<void>;
1034
+ }
1035
+ /**
1036
+ * Configuration for connecting to an MCP endpoint.
1037
+ */
1038
+ interface MCPEndpointConfig {
1039
+ endpoint: string;
1040
+ apiKey?: string;
1041
+ }
1042
+ /**
1043
+ * Extracts CopilotKit-compatible parameters from an MCP tool schema.
1044
+ * @param toolOrSchema The schema object from an MCPTool or the full MCPTool object.
1045
+ * @returns An array of Parameter objects.
1046
+ */
1047
+ declare function extractParametersFromSchema(toolOrSchema?: MCPTool | MCPTool["schema"]): Parameter[];
1048
+ /**
1049
+ * Converts a map of MCPTools into an array of CopilotKit Actions.
1050
+ * @param mcpTools A record mapping tool names to MCPTool objects.
1051
+ * @param mcpEndpoint The endpoint URL from which these tools were fetched.
1052
+ * @returns An array of Action<any> objects.
1053
+ */
1054
+ declare function convertMCPToolsToActions(mcpTools: Record<string, MCPTool>, mcpEndpoint: string): Action<any>[];
1055
+ /**
1056
+ * Generate better instructions for using MCP tools
1057
+ * This is used to enhance the system prompt with tool documentation
1058
+ */
1059
+ declare function generateMcpToolInstructions(toolsMap: Record<string, MCPTool>): string;
1060
+
1061
+ /**
1062
+ * <Callout type="info">
1063
+ * This is the reference for the `CopilotRuntime` class. For more information and example code snippets, please see [Concept: Copilot Runtime](/concepts/copilot-runtime).
1064
+ * </Callout>
1065
+ *
1066
+ * ## Usage
1067
+ *
1068
+ * ```tsx
1069
+ * import { CopilotRuntime } from "@copilotkit/runtime";
1070
+ *
1071
+ * const copilotKit = new CopilotRuntime();
1072
+ * ```
1073
+ */
1074
+
1075
+ type CreateMCPClientFunction = (config: MCPEndpointConfig) => Promise<MCPClient>;
1076
+ type ActionsConfiguration<T extends Parameter[] | [] = []> = Action<T>[] | ((ctx: {
1077
+ properties: any;
1078
+ url?: string;
1079
+ }) => Action<T>[]);
1080
+ interface OnBeforeRequestOptions {
1081
+ threadId?: string;
1082
+ runId?: string;
1083
+ inputMessages: Message[];
1084
+ properties: any;
1085
+ url?: string;
1086
+ }
1087
+ type OnBeforeRequestHandler = (options: OnBeforeRequestOptions) => void | Promise<void>;
1088
+ interface OnAfterRequestOptions {
1089
+ threadId: string;
1090
+ runId?: string;
1091
+ inputMessages: Message[];
1092
+ outputMessages: Message[];
1093
+ properties: any;
1094
+ url?: string;
1095
+ }
1096
+ type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
1097
+ interface OnStopGenerationOptions {
1098
+ threadId: string;
1099
+ runId?: string;
1100
+ url?: string;
1101
+ agentName?: string;
1102
+ lastMessage: MessageInput;
1103
+ }
1104
+ type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
1105
+ interface Middleware {
1106
+ /**
1107
+ * A function that is called before the request is processed.
1108
+ */
1109
+ /**
1110
+ * @deprecated This middleware hook is deprecated and will be removed in a future version.
1111
+ * Use updated middleware integration methods in CopilotRuntimeVNext instead.
1112
+ */
1113
+ onBeforeRequest?: OnBeforeRequestHandler;
1114
+ /**
1115
+ * A function that is called after the request is processed.
1116
+ */
1117
+ /**
1118
+ * @deprecated This middleware hook is deprecated and will be removed in a future version.
1119
+ * Use updated middleware integration methods in CopilotRuntimeVNext instead.
1120
+ */
1121
+ onAfterRequest?: OnAfterRequestHandler;
1122
+ }
1123
+ interface CopilotRuntimeConstructorParams_BASE<T extends Parameter[] | [] = []> {
1124
+ /**
1125
+ * Middleware to be used by the runtime.
1126
+ *
1127
+ * ```ts
1128
+ * onBeforeRequest: (options: {
1129
+ * threadId?: string;
1130
+ * runId?: string;
1131
+ * inputMessages: Message[];
1132
+ * properties: any;
1133
+ * }) => void | Promise<void>;
1134
+ * ```
1135
+ *
1136
+ * ```ts
1137
+ * onAfterRequest: (options: {
1138
+ * threadId?: string;
1139
+ * runId?: string;
1140
+ * inputMessages: Message[];
1141
+ * outputMessages: Message[];
1142
+ * properties: any;
1143
+ * }) => void | Promise<void>;
1144
+ * ```
1145
+ */
1146
+ /**
1147
+ * @deprecated This middleware hook is deprecated and will be removed in a future version.
1148
+ * Use updated middleware integration methods in CopilotRuntimeVNext instead.
1149
+ */
1150
+ middleware?: Middleware;
1151
+ actions?: ActionsConfiguration<T>;
1152
+ remoteActions?: CopilotKitEndpoint[];
1153
+ remoteEndpoints?: EndpointDefinition[];
1154
+ langserve?: RemoteChainParameters[];
1155
+ agents?: Record<string, AbstractAgent>;
1156
+ delegateAgentProcessingToServiceAdapter?: boolean;
1157
+ /**
1158
+ * Configuration for LLM request/response logging.
1159
+ * Requires publicApiKey from CopilotKit component to be set:
1160
+ *
1161
+ * ```tsx
1162
+ * <CopilotKit publicApiKey="ck_pub_..." />
1163
+ * ```
1164
+ *
1165
+ * Example logging config:
1166
+ * ```ts
1167
+ * logging: {
1168
+ * enabled: true, // Enable or disable logging
1169
+ * progressive: true, // Set to false for buffered logging
1170
+ * logger: {
1171
+ * logRequest: (data) => langfuse.trace({ name: "LLM Request", input: data }),
1172
+ * logResponse: (data) => langfuse.trace({ name: "LLM Response", output: data }),
1173
+ * logError: (errorData) => langfuse.trace({ name: "LLM Error", metadata: errorData }),
1174
+ * },
1175
+ * }
1176
+ * ```
1177
+ */
1178
+ observability_c?: CopilotObservabilityConfig;
1179
+ /**
1180
+ * Configuration for connecting to Model Context Protocol (MCP) servers.
1181
+ * Allows fetching and using tools defined on external MCP-compliant servers.
1182
+ * Requires providing the `createMCPClient` function during instantiation.
1183
+ * @experimental
1184
+ */
1185
+ mcpServers?: MCPEndpointConfig[];
1186
+ /**
1187
+ * A function that creates an MCP client instance for a given endpoint configuration.
1188
+ * This function is responsible for using the appropriate MCP client library
1189
+ * (e.g., `@copilotkit/runtime`, `ai`) to establish a connection.
1190
+ * Required if `mcpServers` is provided.
1191
+ *
1192
+ * ```typescript
1193
+ * import { experimental_createMCPClient } from "ai"; // Import from vercel ai library
1194
+ * // ...
1195
+ * const runtime = new CopilotRuntime({
1196
+ * mcpServers: [{ endpoint: "..." }],
1197
+ * async createMCPClient(config) {
1198
+ * return await experimental_createMCPClient({
1199
+ * transport: {
1200
+ * type: "sse",
1201
+ * url: config.endpoint,
1202
+ * headers: config.apiKey
1203
+ * ? { Authorization: `Bearer ${config.apiKey}` }
1204
+ * : undefined,
1205
+ * },
1206
+ * });
1207
+ * }
1208
+ * });
1209
+ * ```
1210
+ */
1211
+ createMCPClient?: CreateMCPClientFunction;
1212
+ /**
1213
+ * Optional error handler for comprehensive debugging and observability.
1214
+ *
1215
+ * **Requires publicApiKey**: Error handling only works when requests include a valid publicApiKey.
1216
+ * This is a premium Copilot Cloud feature.
1217
+ *
1218
+ * @param errorEvent - Structured error event with rich debugging context
1219
+ *
1220
+ * @example
1221
+ * ```typescript
1222
+ * const runtime = new CopilotRuntime({
1223
+ * onError: (errorEvent) => {
1224
+ * debugDashboard.capture(errorEvent);
1225
+ * }
1226
+ * });
1227
+ * ```
1228
+ */
1229
+ onError?: CopilotErrorHandler;
1230
+ onStopGeneration?: OnStopGenerationHandler;
1231
+ }
1232
+ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> extends Omit<CopilotRuntimeConstructorParams_BASE<T>, "agents">, Omit<CopilotRuntimeOptions, "agents" | "transcriptionService"> {
1233
+ /**
1234
+ * TODO: un-omit `transcriptionService` above once it's supported
1235
+ *
1236
+ * This satisfies...
1237
+ * – the optional constraint in `CopilotRuntimeConstructorParams_BASE`
1238
+ * – the `MaybePromise<NonEmptyRecord<T>>` constraint in `CopilotRuntimeOptionsVNext`
1239
+ * – the `Record<string, AbstractAgent>` constraint in `both
1240
+ */
1241
+ agents?: MaybePromise<NonEmptyRecord<Record<string, AbstractAgent>>>;
1242
+ }
1243
+ /**
1244
+ * Central runtime object passed to all request handlers.
1245
+ */
1246
+ declare class CopilotRuntime {
1247
+ params?: CopilotRuntimeConstructorParams;
1248
+ private observability?;
1249
+ private mcpToolsCache;
1250
+ private runtimeArgs;
1251
+ private _instance;
1252
+ constructor(params?: CopilotRuntimeConstructorParams & PartialBy<CopilotRuntimeOptions, "agents">);
1253
+ get instance(): CopilotRuntime$1;
1254
+ private assignEndpointsToAgents;
1255
+ handleServiceAdapter(serviceAdapter: CopilotServiceAdapter): void;
1256
+ private getToolsFromActions;
1257
+ private assignToolsToAgents;
1258
+ private createOnBeforeRequestHandler;
1259
+ private createOnAfterRequestHandler;
1260
+ /**
1261
+ * Log LLM request if observability is enabled
1262
+ */
1263
+ private logObservabilityBeforeRequest;
1264
+ /**
1265
+ * Log final LLM response after request completes
1266
+ */
1267
+ private logObservabilityAfterRequest;
1268
+ private getToolsFromMCP;
1269
+ }
1270
+ declare function copilotKitEndpoint(config: Omit<CopilotKitEndpoint, "type">): CopilotKitEndpoint;
1271
+ declare function langGraphPlatformEndpoint(config: Omit<LangGraphPlatformEndpoint, "type">): LangGraphPlatformEndpoint;
1272
+ declare function resolveEndpointType(endpoint: EndpointDefinition): EndpointType;
1273
+
1274
+ interface CopilotCloudOptions {
1275
+ baseUrl?: string;
1276
+ publicApiKey?: string;
1277
+ }
1278
+
1279
+ type LogLevel = "debug" | "info" | "warn" | "error";
1280
+ type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
1281
+ declare function createLogger(options?: {
1282
+ level?: LogLevel;
1283
+ component?: string;
1284
+ }): pino.Logger<never>;
1285
+
1286
+ declare const logger: pino.Logger<never>;
1287
+ declare const addCustomHeaderPlugin: {
1288
+ onResponse({ response }: {
1289
+ response: any;
1290
+ }): void;
1291
+ };
1292
+ type AnyPrimitive = string | boolean | number | null;
1293
+ type CopilotRequestContextProperties = Record<string, AnyPrimitive | Record<string, AnyPrimitive>>;
1294
+ type GraphQLContext = YogaInitialContext & {
1295
+ _copilotkit: CreateCopilotRuntimeServerOptions;
1296
+ properties: CopilotRequestContextProperties;
1297
+ logger: typeof logger;
1298
+ };
1299
+ interface CreateCopilotRuntimeServerOptions {
1300
+ runtime: CopilotRuntime;
1301
+ serviceAdapter: CopilotServiceAdapter;
1302
+ endpoint: string;
1303
+ baseUrl?: string;
1304
+ cloud?: CopilotCloudOptions;
1305
+ properties?: CopilotRequestContextProperties;
1306
+ logLevel?: LogLevel;
1307
+ }
1308
+ declare function createContext(initialContext: YogaInitialContext, copilotKitContext: CreateCopilotRuntimeServerOptions, contextLogger: typeof logger, properties?: CopilotRequestContextProperties): Promise<Partial<GraphQLContext>>;
1309
+ declare function buildSchema(options?: {
1310
+ emitSchemaFile?: string;
1311
+ }): graphql.GraphQLSchema;
1312
+ type CommonConfig = {
1313
+ logging: typeof logger;
1314
+ schema: ReturnType<typeof buildSchema>;
1315
+ plugins: Parameters<typeof createYoga>[0]["plugins"];
1316
+ context: (ctx: YogaInitialContext) => Promise<Partial<GraphQLContext>>;
1317
+ maskedErrors: {
1318
+ maskError: (error: any, message: string, isDev?: boolean) => any;
1319
+ };
1320
+ };
1321
+ declare function getCommonConfig(options: CreateCopilotRuntimeServerOptions): CommonConfig;
1322
+
1323
+ declare function copilotRuntimeNextJSAppRouterEndpoint(options: CreateCopilotRuntimeServerOptions): {
1324
+ handleRequest: (req: Request) => Response | Promise<Response>;
1325
+ };
1326
+
1327
+ declare const config: {
1328
+ api: {
1329
+ bodyParser: boolean;
1330
+ };
1331
+ };
1332
+
1333
+ declare function copilotRuntimeNextJSPagesRouterEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
1334
+
1335
+ declare function readableStreamToNodeStream(webStream: ReadableStream): Readable;
1336
+ declare function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
1337
+
1338
+ declare function copilotRuntimeNodeExpressEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
1339
+
1340
+ declare function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
1341
+
1342
+ interface CopilotKitStateEnrichment {
1343
+ copilotkit: {
1344
+ actions: StateEnrichment["ag-ui"]["tools"];
1345
+ context: StateEnrichment["ag-ui"]["context"];
1346
+ };
1347
+ }
1348
+ interface PredictStateTool {
1349
+ tool: string;
1350
+ state_key: string;
1351
+ tool_argument: string;
1352
+ }
1353
+ type TextMessageEvents = TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent;
1354
+ type ToolCallEvents = ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent;
1355
+ declare enum CustomEventNames {
1356
+ CopilotKitManuallyEmitMessage = "copilotkit_manually_emit_message",
1357
+ CopilotKitManuallyEmitToolCall = "copilotkit_manually_emit_tool_call",
1358
+ CopilotKitManuallyEmitIntermediateState = "copilotkit_manually_emit_intermediate_state",
1359
+ CopilotKitExit = "copilotkit_exit"
1360
+ }
1361
+ declare class LangGraphAgent extends LangGraphAgent$1 {
1362
+ constructor(config: LangGraphAgentConfig);
1363
+ clone(): LangGraphAgent;
1364
+ dispatchEvent(event: ProcessedEvents): boolean;
1365
+ run(input: RunAgentInput): rxjs.Observable<{
1366
+ type: EventType.TEXT_MESSAGE_START;
1367
+ role: "developer" | "system" | "assistant" | "user";
1368
+ messageId: string;
1369
+ timestamp?: number | undefined;
1370
+ rawEvent?: any;
1371
+ } | {
1372
+ type: EventType.TEXT_MESSAGE_CONTENT;
1373
+ messageId: string;
1374
+ delta: string;
1375
+ timestamp?: number | undefined;
1376
+ rawEvent?: any;
1377
+ } | {
1378
+ type: EventType.TEXT_MESSAGE_END;
1379
+ messageId: string;
1380
+ timestamp?: number | undefined;
1381
+ rawEvent?: any;
1382
+ } | {
1383
+ type: EventType.TOOL_CALL_START;
1384
+ toolCallId: string;
1385
+ toolCallName: string;
1386
+ timestamp?: number | undefined;
1387
+ rawEvent?: any;
1388
+ parentMessageId?: string | undefined;
1389
+ } | {
1390
+ type: EventType.TOOL_CALL_ARGS;
1391
+ toolCallId: string;
1392
+ delta: string;
1393
+ timestamp?: number | undefined;
1394
+ rawEvent?: any;
1395
+ } | {
1396
+ type: EventType.TOOL_CALL_END;
1397
+ toolCallId: string;
1398
+ timestamp?: number | undefined;
1399
+ rawEvent?: any;
1400
+ } | {
1401
+ type: EventType.THINKING_TEXT_MESSAGE_START;
1402
+ timestamp?: number | undefined;
1403
+ rawEvent?: any;
1404
+ } | {
1405
+ type: EventType.THINKING_TEXT_MESSAGE_CONTENT;
1406
+ delta: string;
1407
+ timestamp?: number | undefined;
1408
+ rawEvent?: any;
1409
+ } | {
1410
+ type: EventType.THINKING_TEXT_MESSAGE_END;
1411
+ timestamp?: number | undefined;
1412
+ rawEvent?: any;
1413
+ } | {
1414
+ type: EventType.TOOL_CALL_RESULT;
1415
+ content: string;
1416
+ toolCallId: string;
1417
+ messageId: string;
1418
+ role?: "tool" | undefined;
1419
+ timestamp?: number | undefined;
1420
+ rawEvent?: any;
1421
+ } | {
1422
+ type: EventType.THINKING_START;
1423
+ timestamp?: number | undefined;
1424
+ rawEvent?: any;
1425
+ title?: string | undefined;
1426
+ } | {
1427
+ type: EventType.THINKING_END;
1428
+ timestamp?: number | undefined;
1429
+ rawEvent?: any;
1430
+ } | {
1431
+ type: EventType.STATE_SNAPSHOT;
1432
+ timestamp?: number | undefined;
1433
+ rawEvent?: any;
1434
+ snapshot?: any;
1435
+ } | {
1436
+ type: EventType.STATE_DELTA;
1437
+ delta: any[];
1438
+ timestamp?: number | undefined;
1439
+ rawEvent?: any;
1440
+ } | {
1441
+ type: EventType.MESSAGES_SNAPSHOT;
1442
+ messages: ({
1443
+ id: string;
1444
+ role: "developer";
1445
+ content: string;
1446
+ name?: string | undefined;
1447
+ } | {
1448
+ id: string;
1449
+ role: "system";
1450
+ content: string;
1451
+ name?: string | undefined;
1452
+ } | {
1453
+ id: string;
1454
+ role: "assistant";
1455
+ name?: string | undefined;
1456
+ content?: string | undefined;
1457
+ toolCalls?: {
1458
+ function: {
1459
+ name: string;
1460
+ arguments: string;
1461
+ };
1462
+ type: "function";
1463
+ id: string;
1464
+ }[] | undefined;
1465
+ } | {
1466
+ id: string;
1467
+ role: "user";
1468
+ content: string | ({
1469
+ type: "text";
1470
+ text: string;
1471
+ } | {
1472
+ type: "binary";
1473
+ mimeType: string;
1474
+ id?: string | undefined;
1475
+ url?: string | undefined;
1476
+ data?: string | undefined;
1477
+ filename?: string | undefined;
1478
+ })[];
1479
+ name?: string | undefined;
1480
+ } | {
1481
+ id: string;
1482
+ role: "tool";
1483
+ content: string;
1484
+ toolCallId: string;
1485
+ error?: string | undefined;
1486
+ } | {
1487
+ id: string;
1488
+ role: "activity";
1489
+ content: Record<string, any>;
1490
+ activityType: string;
1491
+ })[];
1492
+ timestamp?: number | undefined;
1493
+ rawEvent?: any;
1494
+ } | {
1495
+ type: EventType.RAW;
1496
+ timestamp?: number | undefined;
1497
+ rawEvent?: any;
1498
+ event?: any;
1499
+ source?: string | undefined;
1500
+ } | {
1501
+ name: string;
1502
+ type: EventType.CUSTOM;
1503
+ value?: any;
1504
+ timestamp?: number | undefined;
1505
+ rawEvent?: any;
1506
+ } | {
1507
+ type: EventType.RUN_STARTED;
1508
+ threadId: string;
1509
+ runId: string;
1510
+ parentRunId?: string | undefined;
1511
+ timestamp?: number | undefined;
1512
+ rawEvent?: any;
1513
+ input?: {
1514
+ threadId: string;
1515
+ runId: string;
1516
+ messages: ({
1517
+ id: string;
1518
+ role: "developer";
1519
+ content: string;
1520
+ name?: string | undefined;
1521
+ } | {
1522
+ id: string;
1523
+ role: "system";
1524
+ content: string;
1525
+ name?: string | undefined;
1526
+ } | {
1527
+ id: string;
1528
+ role: "assistant";
1529
+ name?: string | undefined;
1530
+ content?: string | undefined;
1531
+ toolCalls?: {
1532
+ function: {
1533
+ name: string;
1534
+ arguments: string;
1535
+ };
1536
+ type: "function";
1537
+ id: string;
1538
+ }[] | undefined;
1539
+ } | {
1540
+ id: string;
1541
+ role: "user";
1542
+ content: string | ({
1543
+ type: "text";
1544
+ text: string;
1545
+ } | {
1546
+ type: "binary";
1547
+ mimeType: string;
1548
+ id?: string | undefined;
1549
+ url?: string | undefined;
1550
+ data?: string | undefined;
1551
+ filename?: string | undefined;
1552
+ })[];
1553
+ name?: string | undefined;
1554
+ } | {
1555
+ id: string;
1556
+ role: "tool";
1557
+ content: string;
1558
+ toolCallId: string;
1559
+ error?: string | undefined;
1560
+ } | {
1561
+ id: string;
1562
+ role: "activity";
1563
+ content: Record<string, any>;
1564
+ activityType: string;
1565
+ })[];
1566
+ tools: {
1567
+ name: string;
1568
+ description: string;
1569
+ parameters?: any;
1570
+ }[];
1571
+ context: {
1572
+ value: string;
1573
+ description: string;
1574
+ }[];
1575
+ parentRunId?: string | undefined;
1576
+ state?: any;
1577
+ forwardedProps?: any;
1578
+ } | undefined;
1579
+ } | {
1580
+ type: EventType.RUN_FINISHED;
1581
+ threadId: string;
1582
+ runId: string;
1583
+ timestamp?: number | undefined;
1584
+ rawEvent?: any;
1585
+ result?: any;
1586
+ } | {
1587
+ message: string;
1588
+ type: EventType.RUN_ERROR;
1589
+ code?: string | undefined;
1590
+ timestamp?: number | undefined;
1591
+ rawEvent?: any;
1592
+ } | {
1593
+ type: EventType.STEP_STARTED;
1594
+ stepName: string;
1595
+ timestamp?: number | undefined;
1596
+ rawEvent?: any;
1597
+ } | {
1598
+ type: EventType.STEP_FINISHED;
1599
+ stepName: string;
1600
+ timestamp?: number | undefined;
1601
+ rawEvent?: any;
1602
+ } | {
1603
+ type: EventType;
1604
+ name: string;
1605
+ value: any;
1606
+ }>;
1607
+ langGraphDefaultMergeState(state: State, messages: Message$1[], input: RunAgentInput): State<StateEnrichment & CopilotKitStateEnrichment>;
1608
+ getSchemaKeys(): Promise<SchemaKeys>;
1609
+ }
1610
+
1611
+ declare class GuardrailsValidationFailureResponse extends FailedResponseStatus {
1612
+ reason: FailedResponseStatusReason;
1613
+ details: {
1614
+ guardrailsReason: string;
1615
+ };
1616
+ constructor({ guardrailsReason }: {
1617
+ guardrailsReason: any;
1618
+ });
1619
+ }
1620
+ declare class MessageStreamInterruptedResponse extends FailedResponseStatus {
1621
+ reason: FailedResponseStatusReason;
1622
+ details: {
1623
+ messageId: string;
1624
+ description: string;
1625
+ };
1626
+ constructor({ messageId }: {
1627
+ messageId: string;
1628
+ });
1629
+ }
1630
+ declare class UnknownErrorResponse extends FailedResponseStatus {
1631
+ reason: FailedResponseStatusReason;
1632
+ details: {
1633
+ description?: string;
1634
+ originalError?: {
1635
+ code?: string;
1636
+ statusCode?: number;
1637
+ severity?: string;
1638
+ visibility?: string;
1639
+ originalErrorType?: string;
1640
+ extensions?: any;
1641
+ };
1642
+ };
1643
+ constructor({ description, originalError, }: {
1644
+ description?: string;
1645
+ originalError?: {
1646
+ code?: string;
1647
+ statusCode?: number;
1648
+ severity?: string;
1649
+ visibility?: string;
1650
+ originalErrorType?: string;
1651
+ extensions?: any;
1652
+ };
1653
+ });
1654
+ }
1655
+
1656
+ export { AnthropicAdapter, AnthropicAdapterParams, AnthropicPromptCachingConfig, BedrockAdapter, BedrockAdapterParams, CommonConfig, CopilotRequestContextProperties, CopilotRuntime, CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotRuntimeConstructorParams_BASE, CopilotRuntimeLogger, CopilotServiceAdapter, CreateCopilotRuntimeServerOptions, CustomEventNames, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GraphQLContext, GroqAdapter, GroqAdapterParams, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LogLevel, MCPClient, MCPEndpointConfig, MCPTool, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAdapterParams, OpenAIAssistantAdapter, OpenAIAssistantAdapterParams, PredictStateTool, RemoteChain, RemoteChainParameters, TextMessageEvents, ToolCallEvents, UnifyAdapter, UnifyAdapterParams, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };