@copilotkit/runtime 1.50.0-beta.0 → 1.50.0-beta.10

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 (132) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/chunk-2OZAGFV3.mjs +43 -0
  3. package/dist/chunk-2OZAGFV3.mjs.map +1 -0
  4. package/dist/chunk-62NE5S6M.mjs +226 -0
  5. package/dist/chunk-62NE5S6M.mjs.map +1 -0
  6. package/dist/chunk-6XRUR5UK.mjs +1 -0
  7. package/dist/chunk-6XRUR5UK.mjs.map +1 -0
  8. package/dist/chunk-AMUJQ6IR.mjs +50 -0
  9. package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
  10. package/dist/chunk-BJEYMRDD.mjs +25 -0
  11. package/dist/chunk-BJEYMRDD.mjs.map +1 -0
  12. package/dist/chunk-DZV4ZIAR.mjs +3063 -0
  13. package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
  14. package/dist/chunk-FHD4JECV.mjs +33 -0
  15. package/dist/chunk-FHD4JECV.mjs.map +1 -0
  16. package/dist/chunk-FMU55SEU.mjs +25 -0
  17. package/dist/chunk-FMU55SEU.mjs.map +1 -0
  18. package/dist/chunk-OWIGJONH.mjs +275 -0
  19. package/dist/chunk-OWIGJONH.mjs.map +1 -0
  20. package/dist/chunk-SBCOROE4.mjs +1112 -0
  21. package/dist/chunk-SBCOROE4.mjs.map +1 -0
  22. package/dist/chunk-TTUAEJLD.mjs +617 -0
  23. package/dist/chunk-TTUAEJLD.mjs.map +1 -0
  24. package/dist/chunk-XWBDEXDA.mjs +153 -0
  25. package/dist/chunk-XWBDEXDA.mjs.map +1 -0
  26. package/dist/chunk-Z752VE75.mjs +74 -0
  27. package/dist/chunk-Z752VE75.mjs.map +1 -0
  28. package/dist/graphql/message-conversion/index.d.ts +18 -0
  29. package/dist/graphql/message-conversion/index.js +725 -0
  30. package/dist/graphql/message-conversion/index.js.map +1 -0
  31. package/dist/graphql/message-conversion/index.mjs +245 -0
  32. package/dist/graphql/message-conversion/index.mjs.map +1 -0
  33. package/dist/graphql/types/base/index.d.ts +6 -0
  34. package/dist/graphql/types/base/index.js +63 -0
  35. package/dist/graphql/types/base/index.js.map +1 -0
  36. package/dist/graphql/types/base/index.mjs +8 -0
  37. package/dist/graphql/types/base/index.mjs.map +1 -0
  38. package/dist/graphql/types/converted/index.d.ts +2 -0
  39. package/dist/graphql/types/converted/index.js +294 -0
  40. package/dist/graphql/types/converted/index.js.map +1 -0
  41. package/dist/graphql/types/converted/index.mjs +20 -0
  42. package/dist/graphql/types/converted/index.mjs.map +1 -0
  43. package/dist/groq-adapter-50bc6e4a.d.ts +326 -0
  44. package/dist/index-adbd78f1.d.ts +154 -0
  45. package/dist/index.d.ts +136 -287
  46. package/dist/index.js +393 -287
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +385 -276
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/langgraph.d.ts +284 -0
  51. package/dist/langgraph.js +211 -0
  52. package/dist/langgraph.js.map +1 -0
  53. package/dist/langgraph.mjs +206 -0
  54. package/dist/langgraph.mjs.map +1 -0
  55. package/dist/langserve-74a52292.d.ts +242 -0
  56. package/dist/lib/cloud/index.d.ts +6 -0
  57. package/dist/lib/cloud/index.js +18 -0
  58. package/dist/lib/cloud/index.js.map +1 -0
  59. package/dist/lib/cloud/index.mjs +1 -0
  60. package/dist/lib/cloud/index.mjs.map +1 -0
  61. package/dist/lib/index.d.ts +266 -0
  62. package/dist/lib/index.js +4944 -0
  63. package/dist/lib/index.js.map +1 -0
  64. package/dist/lib/index.mjs +74 -0
  65. package/dist/lib/index.mjs.map +1 -0
  66. package/dist/lib/integrations/index.d.ts +28 -0
  67. package/dist/lib/integrations/index.js +3024 -0
  68. package/dist/lib/integrations/index.js.map +1 -0
  69. package/dist/lib/integrations/index.mjs +36 -0
  70. package/dist/lib/integrations/index.mjs.map +1 -0
  71. package/dist/lib/integrations/nest/index.d.ts +16 -0
  72. package/dist/lib/integrations/nest/index.js +2937 -0
  73. package/dist/lib/integrations/nest/index.js.map +1 -0
  74. package/dist/lib/integrations/nest/index.mjs +13 -0
  75. package/dist/lib/integrations/nest/index.mjs.map +1 -0
  76. package/dist/lib/integrations/node-express/index.d.ts +16 -0
  77. package/dist/lib/integrations/node-express/index.js +2937 -0
  78. package/dist/lib/integrations/node-express/index.js.map +1 -0
  79. package/dist/lib/integrations/node-express/index.mjs +13 -0
  80. package/dist/lib/integrations/node-express/index.mjs.map +1 -0
  81. package/dist/lib/integrations/node-http/index.d.ts +16 -0
  82. package/dist/lib/integrations/node-http/index.js +2923 -0
  83. package/dist/lib/integrations/node-http/index.js.map +1 -0
  84. package/dist/lib/integrations/node-http/index.mjs +12 -0
  85. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  86. package/dist/service-adapters/index.d.ts +166 -0
  87. package/dist/service-adapters/index.js +1800 -0
  88. package/dist/service-adapters/index.js.map +1 -0
  89. package/dist/service-adapters/index.mjs +36 -0
  90. package/dist/service-adapters/index.mjs.map +1 -0
  91. package/dist/service-adapters/shared/index.d.ts +9 -0
  92. package/dist/service-adapters/shared/index.js +72 -0
  93. package/dist/service-adapters/shared/index.js.map +1 -0
  94. package/dist/service-adapters/shared/index.mjs +8 -0
  95. package/dist/service-adapters/shared/index.mjs.map +1 -0
  96. package/dist/shared-f6d43ef8.d.ts +446 -0
  97. package/dist/utils/index.d.ts +65 -0
  98. package/dist/utils/index.js +175 -0
  99. package/dist/utils/index.js.map +1 -0
  100. package/dist/utils/index.mjs +12 -0
  101. package/dist/utils/index.mjs.map +1 -0
  102. package/dist/v2/index.d.ts +1 -0
  103. package/dist/v2/index.js +7 -0
  104. package/dist/v2/index.js.map +1 -1
  105. package/dist/v2/index.mjs +1 -0
  106. package/dist/v2/index.mjs.map +1 -1
  107. package/package.json +71 -33
  108. package/src/graphql/message-conversion/agui-to-gql.test.ts +2 -2
  109. package/src/graphql/message-conversion/gql-to-agui.test.ts +30 -28
  110. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +8 -8
  111. package/src/langgraph.ts +1 -0
  112. package/src/lib/index.ts +42 -1
  113. package/src/lib/integrations/nextjs/app-router.ts +3 -1
  114. package/src/lib/integrations/node-http/index.ts +132 -11
  115. package/src/lib/integrations/shared.ts +2 -2
  116. package/src/lib/runtime/agent-integrations/{langgraph.agent.ts → langgraph/agent.ts} +5 -30
  117. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +34 -0
  118. package/src/lib/runtime/agent-integrations/langgraph/index.ts +2 -0
  119. package/src/lib/runtime/copilot-runtime.ts +51 -68
  120. package/src/lib/runtime/telemetry-agent-runner.ts +134 -0
  121. package/src/service-adapters/anthropic/anthropic-adapter.ts +16 -3
  122. package/src/service-adapters/bedrock/bedrock-adapter.ts +4 -1
  123. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -1
  124. package/src/service-adapters/google/google-genai-adapter.ts +9 -4
  125. package/src/service-adapters/groq/groq-adapter.ts +16 -3
  126. package/src/service-adapters/langchain/langchain-adapter.ts +5 -3
  127. package/src/service-adapters/langchain/langserve.ts +2 -1
  128. package/src/service-adapters/openai/openai-adapter.ts +17 -3
  129. package/src/service-adapters/openai/openai-assistant-adapter.ts +26 -11
  130. package/src/service-adapters/unify/unify-adapter.ts +3 -1
  131. package/src/v2/index.ts +1 -0
  132. package/tsup.config.ts +5 -2
@@ -0,0 +1,154 @@
1
+ import { BaseMessageInput } from './graphql/types/base/index.js';
2
+
3
+ declare enum MessageRole {
4
+ assistant = "assistant",
5
+ developer = "developer",
6
+ system = "system",
7
+ tool = "tool",
8
+ user = "user"
9
+ }
10
+ declare enum ActionInputAvailability {
11
+ disabled = "disabled",
12
+ enabled = "enabled",
13
+ remote = "remote"
14
+ }
15
+
16
+ declare class MessageInput extends BaseMessageInput {
17
+ textMessage?: TextMessageInput;
18
+ actionExecutionMessage?: ActionExecutionMessageInput;
19
+ resultMessage?: ResultMessageInput;
20
+ agentStateMessage?: AgentStateMessageInput;
21
+ imageMessage?: ImageMessageInput;
22
+ }
23
+ declare class TextMessageInput {
24
+ content: string;
25
+ parentMessageId?: string;
26
+ role: MessageRole;
27
+ }
28
+ declare class ActionExecutionMessageInput {
29
+ name: string;
30
+ arguments: string;
31
+ parentMessageId?: string;
32
+ scope?: String;
33
+ }
34
+ declare class ResultMessageInput {
35
+ actionExecutionId: string;
36
+ actionName: string;
37
+ parentMessageId?: string;
38
+ result: string;
39
+ }
40
+ declare class AgentStateMessageInput {
41
+ threadId: string;
42
+ agentName: string;
43
+ role: MessageRole;
44
+ state: string;
45
+ running: boolean;
46
+ nodeName: string;
47
+ runId: string;
48
+ active: boolean;
49
+ }
50
+ declare class ImageMessageInput {
51
+ format: string;
52
+ bytes: string;
53
+ parentMessageId?: string;
54
+ role: MessageRole;
55
+ }
56
+
57
+ declare enum MessageStatusCode {
58
+ Pending = "pending",
59
+ Success = "success",
60
+ Failed = "failed"
61
+ }
62
+ declare class BaseMessageStatus {
63
+ code: MessageStatusCode;
64
+ }
65
+ declare class PendingMessageStatus extends BaseMessageStatus {
66
+ code: MessageStatusCode;
67
+ }
68
+ declare class SuccessMessageStatus extends BaseMessageStatus {
69
+ code: MessageStatusCode;
70
+ }
71
+ declare class FailedMessageStatus extends BaseMessageStatus {
72
+ code: MessageStatusCode;
73
+ reason: string;
74
+ }
75
+ declare const MessageStatusUnion: PendingMessageStatus | SuccessMessageStatus | FailedMessageStatus;
76
+ type MessageStatus = typeof MessageStatusUnion;
77
+
78
+ declare abstract class BaseMessageOutput {
79
+ id: string;
80
+ createdAt: Date;
81
+ status: typeof MessageStatusUnion;
82
+ }
83
+
84
+ type MessageType = "TextMessage" | "ActionExecutionMessage" | "ResultMessage" | "AgentStateMessage" | "ImageMessage";
85
+ declare class Message {
86
+ type: MessageType;
87
+ id: BaseMessageOutput["id"];
88
+ createdAt: BaseMessageOutput["createdAt"];
89
+ status: MessageStatus;
90
+ constructor(props: any);
91
+ isTextMessage(): this is TextMessage;
92
+ isActionExecutionMessage(): this is ActionExecutionMessage;
93
+ isResultMessage(): this is ResultMessage;
94
+ isAgentStateMessage(): this is AgentStateMessage;
95
+ isImageMessage(): this is ImageMessage;
96
+ }
97
+ declare const Role: typeof MessageRole;
98
+ type MessageConstructorOptions = Partial<Message>;
99
+ type TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;
100
+ declare class TextMessage extends Message implements TextMessageConstructorOptions {
101
+ content: TextMessageInput["content"];
102
+ parentMessageId: TextMessageInput["parentMessageId"];
103
+ role: TextMessageInput["role"];
104
+ type: "TextMessage";
105
+ constructor(props: TextMessageConstructorOptions);
106
+ }
107
+ declare class ActionExecutionMessage extends Message implements Omit<ActionExecutionMessageInput, "arguments" | "scope"> {
108
+ type: MessageType;
109
+ name: string;
110
+ arguments: Record<string, any>;
111
+ parentMessageId?: string;
112
+ }
113
+ declare class ResultMessage extends Message implements ResultMessageInput {
114
+ type: MessageType;
115
+ actionExecutionId: string;
116
+ actionName: string;
117
+ result: string;
118
+ static encodeResult(result: any, error?: {
119
+ code: string;
120
+ message: string;
121
+ } | string | Error): string;
122
+ static decodeResult(result: string): {
123
+ error?: {
124
+ code: string;
125
+ message: string;
126
+ };
127
+ result: string;
128
+ };
129
+ hasError(): boolean;
130
+ getError(): {
131
+ code: string;
132
+ message: string;
133
+ } | undefined;
134
+ }
135
+ declare class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, "state"> {
136
+ type: MessageType;
137
+ threadId: string;
138
+ agentName: string;
139
+ nodeName: string;
140
+ runId: string;
141
+ active: boolean;
142
+ role: MessageRole;
143
+ state: any;
144
+ running: boolean;
145
+ }
146
+ declare class ImageMessage extends Message implements ImageMessageInput {
147
+ type: MessageType;
148
+ format: string;
149
+ bytes: string;
150
+ role: MessageRole;
151
+ parentMessageId?: string;
152
+ }
153
+
154
+ export { ActionExecutionMessage as A, ImageMessage as I, Message as M, ResultMessage as R, TextMessage as T, MessageInput as a, ActionInputAvailability as b, MessageType as c, Role as d, AgentStateMessage as e };
package/dist/index.d.ts CHANGED
@@ -1,23 +1,19 @@
1
- import OpenAI from 'openai';
2
- import * as rxjs from 'rxjs';
3
1
  import { ReplaySubject } from 'rxjs';
2
+ import { Parameter, Action, CopilotKitLowLevelError, CopilotErrorHandler, PartialBy, MaybePromise, NonEmptyRecord } from '@copilotkit/shared';
3
+ import OpenAI from 'openai';
4
4
  import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
5
5
  import { DynamicStructuredTool } from '@langchain/core/tools';
6
6
  import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
7
7
  import { Groq } from 'groq-sdk';
8
+ import Anthropic from '@anthropic-ai/sdk';
8
9
  import * as graphql from 'graphql';
9
10
  import * as pino from 'pino';
10
11
  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';
12
+ import { CopilotRuntimeOptions, CopilotRuntime as CopilotRuntime$1, AgentRunner } from '@copilotkitnext/runtime';
13
+ import { AbstractAgent } from '@ag-ui/client';
14
14
  import * as http from 'http';
15
- import { IncomingMessage, ServerResponse } from 'http';
15
+ import { ServerResponse, IncomingMessage } from 'http';
16
16
  import { Readable } from 'node:stream';
17
- import { LangGraphAgent as LangGraphAgent$1, LangGraphAgentConfig, ProcessedEvents, State, StateEnrichment, SchemaKeys } from '@ag-ui/langgraph';
18
- export { LangGraphHttpAgent } from '@ag-ui/langgraph';
19
- import { Message as Message$1 } from '@langchain/langgraph-sdk/dist/types.messages';
20
- import Anthropic from '@anthropic-ai/sdk';
21
17
 
22
18
  declare enum MessageRole {
23
19
  assistant = "assistant",
@@ -500,6 +496,7 @@ declare class OpenAIAdapter implements CopilotServiceAdapter {
500
496
  get openai(): OpenAI;
501
497
  get name(): string;
502
498
  constructor(params?: OpenAIAdapterParams);
499
+ private ensureOpenAI;
503
500
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
504
501
  }
505
502
 
@@ -563,6 +560,23 @@ declare class LangChainAdapter implements CopilotServiceAdapter {
563
560
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
564
561
  }
565
562
 
563
+ /**
564
+ * Copilot Runtime adapter for Google Generative AI (e.g. Gemini).
565
+ *
566
+ * ## Example
567
+ *
568
+ * ```ts
569
+ * import { CopilotRuntime, GoogleGenerativeAIAdapter } from "@copilotkit/runtime";
570
+ * const { GoogleGenerativeAI } = require("@google/generative-ai");
571
+ *
572
+ * const genAI = new GoogleGenerativeAI(process.env["GOOGLE_API_KEY"]);
573
+ *
574
+ * const copilotKit = new CopilotRuntime();
575
+ *
576
+ * return new GoogleGenerativeAIAdapter({ model: "gemini-1.5-pro" });
577
+ * ```
578
+ */
579
+
566
580
  interface GoogleGenerativeAIAdapterOptions {
567
581
  /**
568
582
  * A custom Google Generative AI model to use.
@@ -641,7 +655,7 @@ interface OpenAIAssistantAdapterParams {
641
655
  keepSystemRole?: boolean;
642
656
  }
643
657
  declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
644
- private openai;
658
+ private _openai;
645
659
  private codeInterpreterEnabled;
646
660
  private assistantId;
647
661
  private fileSearchEnabled;
@@ -649,6 +663,7 @@ declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
649
663
  private keepSystemRole;
650
664
  get name(): string;
651
665
  constructor(params: OpenAIAssistantAdapterParams);
666
+ private ensureOpenAI;
652
667
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
653
668
  private submitToolOutputs;
654
669
  private submitUserMessage;
@@ -733,6 +748,7 @@ declare class GroqAdapter implements CopilotServiceAdapter {
733
748
  get groq(): Groq;
734
749
  get name(): string;
735
750
  constructor(params?: GroqAdapterParams);
751
+ private ensureGroq;
736
752
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
737
753
  }
738
754
 
@@ -819,6 +835,7 @@ declare class AnthropicAdapter implements CopilotServiceAdapter {
819
835
  get anthropic(): Anthropic;
820
836
  get name(): string;
821
837
  constructor(params?: AnthropicAdapterParams);
838
+ private ensureAnthropic;
822
839
  /**
823
840
  * Adds cache control to system prompt
824
841
  */
@@ -1243,13 +1260,13 @@ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> exten
1243
1260
  /**
1244
1261
  * Central runtime object passed to all request handlers.
1245
1262
  */
1246
- declare class CopilotRuntime {
1247
- params?: CopilotRuntimeConstructorParams;
1263
+ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
1264
+ params?: CopilotRuntimeConstructorParams<T>;
1248
1265
  private observability?;
1249
1266
  private mcpToolsCache;
1250
1267
  private runtimeArgs;
1251
1268
  private _instance;
1252
- constructor(params?: CopilotRuntimeConstructorParams & PartialBy<CopilotRuntimeOptions, "agents">);
1269
+ constructor(params?: CopilotRuntimeConstructorParams<T> & PartialBy<CopilotRuntimeOptions, "agents">);
1253
1270
  get instance(): CopilotRuntime$1;
1254
1271
  private assignEndpointsToAgents;
1255
1272
  handleServiceAdapter(serviceAdapter: CopilotServiceAdapter): void;
@@ -1297,8 +1314,8 @@ type GraphQLContext = YogaInitialContext & {
1297
1314
  logger: typeof logger;
1298
1315
  };
1299
1316
  interface CreateCopilotRuntimeServerOptions {
1300
- runtime: CopilotRuntime;
1301
- serviceAdapter: CopilotServiceAdapter;
1317
+ runtime: CopilotRuntime<any>;
1318
+ serviceAdapter?: CopilotServiceAdapter;
1302
1319
  endpoint: string;
1303
1320
  baseUrl?: string;
1304
1321
  cloud?: CopilotCloudOptions;
@@ -1330,283 +1347,115 @@ declare const config: {
1330
1347
  };
1331
1348
  };
1332
1349
 
1333
- declare function copilotRuntimeNextJSPagesRouterEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
1350
+ declare function copilotRuntimeNextJSPagesRouterEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage & {
1351
+ body?: unknown;
1352
+ complete?: boolean;
1353
+ }, res: http.ServerResponse) => Promise<void>;
1334
1354
 
1355
+ type IncomingWithBody = IncomingMessage & {
1356
+ body?: unknown;
1357
+ complete?: boolean;
1358
+ };
1335
1359
  declare function readableStreamToNodeStream(webStream: ReadableStream): Readable;
1336
- declare function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
1360
+ declare function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions): (req: IncomingWithBody, res: ServerResponse) => Promise<void>;
1337
1361
 
1338
- declare function copilotRuntimeNodeExpressEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
1362
+ declare function copilotRuntimeNodeExpressEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage & {
1363
+ body?: unknown;
1364
+ complete?: boolean;
1365
+ }, res: http.ServerResponse) => Promise<void>;
1339
1366
 
1340
- declare function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
1367
+ declare function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerOptions): (req: http.IncomingMessage & {
1368
+ body?: unknown;
1369
+ complete?: boolean;
1370
+ }, res: http.ServerResponse) => Promise<void>;
1341
1371
 
1342
- interface CopilotKitStateEnrichment {
1343
- copilotkit: {
1344
- actions: StateEnrichment["ag-ui"]["tools"];
1345
- context: StateEnrichment["ag-ui"]["context"];
1346
- };
1372
+ /**
1373
+ * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry
1374
+ * for agent execution streams.
1375
+ *
1376
+ * This captures the following telemetry events:
1377
+ * - oss.runtime.agent_execution_stream_started - when an agent execution starts
1378
+ * - oss.runtime.agent_execution_stream_ended - when an agent execution completes
1379
+ * - oss.runtime.agent_execution_stream_errored - when an agent execution fails
1380
+ */
1381
+
1382
+ /**
1383
+ * Configuration options for TelemetryAgentRunner
1384
+ */
1385
+ interface TelemetryAgentRunnerConfig {
1386
+ /**
1387
+ * The underlying runner to delegate to
1388
+ * If not provided, defaults to InMemoryAgentRunner
1389
+ */
1390
+ runner?: AgentRunner;
1391
+ /**
1392
+ * Optional LangSmith API key (will be hashed for telemetry)
1393
+ */
1394
+ langsmithApiKey?: string;
1347
1395
  }
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>;
1396
+ /**
1397
+ * An AgentRunner wrapper that adds telemetry tracking for agent executions.
1398
+ *
1399
+ * Usage:
1400
+ * ```ts
1401
+ * const runtime = new CopilotRuntime({
1402
+ * runner: new TelemetryAgentRunner(),
1403
+ * // or with custom runner:
1404
+ * runner: new TelemetryAgentRunner({ runner: customRunner }),
1405
+ * });
1406
+ * ```
1407
+ */
1408
+ declare class TelemetryAgentRunner implements AgentRunner {
1409
+ private readonly _runner;
1410
+ private readonly hashedLgcKey;
1411
+ constructor(config?: TelemetryAgentRunnerConfig);
1412
+ /**
1413
+ * Runs an agent with telemetry tracking.
1414
+ * Wraps the underlying runner's Observable stream with telemetry events.
1415
+ */
1416
+ run(...args: Parameters<AgentRunner["run"]>): ReturnType<AgentRunner["run"]>;
1417
+ /**
1418
+ * Delegates to the underlying runner's connect method
1419
+ */
1420
+ connect(...args: Parameters<AgentRunner["connect"]>): ReturnType<AgentRunner["connect"]>;
1421
+ /**
1422
+ * Delegates to the underlying runner's isRunning method
1423
+ */
1424
+ isRunning(...args: Parameters<AgentRunner["isRunning"]>): ReturnType<AgentRunner["isRunning"]>;
1425
+ /**
1426
+ * Delegates to the underlying runner's stop method
1427
+ */
1428
+ stop(...args: Parameters<AgentRunner["stop"]>): ReturnType<AgentRunner["stop"]>;
1429
+ }
1430
+
1431
+ /**
1432
+ * @deprecated LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1433
+ */
1434
+ declare class LangGraphAgent {
1435
+ constructor();
1436
+ }
1437
+ /**
1438
+ * @deprecated LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1439
+ */
1440
+ declare class LangGraphHttpAgent {
1441
+ constructor();
1609
1442
  }
1443
+ /**
1444
+ * @deprecated TextMessageEvents import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1445
+ */
1446
+ type TextMessageEvents = any;
1447
+ /**
1448
+ * @deprecated ToolCallEvents import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1449
+ */
1450
+ type ToolCallEvents = any;
1451
+ /**
1452
+ * @deprecated CustomEventNames import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1453
+ */
1454
+ type CustomEventNames = any;
1455
+ /**
1456
+ * @deprecated PredictStateTool import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead
1457
+ */
1458
+ type PredictStateTool = any;
1610
1459
 
1611
1460
  declare class GuardrailsValidationFailureResponse extends FailedResponseStatus {
1612
1461
  reason: FailedResponseStatusReason;
@@ -1653,4 +1502,4 @@ declare class UnknownErrorResponse extends FailedResponseStatus {
1653
1502
  });
1654
1503
  }
1655
1504
 
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 };
1505
+ 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, LangGraphHttpAgent, LogLevel, MCPClient, MCPEndpointConfig, MCPTool, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAdapterParams, OpenAIAssistantAdapter, OpenAIAssistantAdapterParams, PredictStateTool, RemoteChain, RemoteChainParameters, TelemetryAgentRunner, TelemetryAgentRunnerConfig, TextMessageEvents, ToolCallEvents, UnifyAdapter, UnifyAdapterParams, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };