@copilotkit/runtime 1.10.6 → 1.50.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/index.d.ts +1655 -27
  2. package/dist/index.js +2172 -5049
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +5441 -99
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/v2/index.d.ts +1 -0
  7. package/dist/v2/index.js +15 -0
  8. package/dist/v2/index.js.map +1 -0
  9. package/dist/v2/index.mjs +4 -0
  10. package/dist/v2/index.mjs.map +1 -0
  11. package/package.json +33 -21
  12. package/src/graphql/message-conversion/agui-to-gql.test.ts +1263 -0
  13. package/src/graphql/message-conversion/agui-to-gql.ts +333 -0
  14. package/src/graphql/message-conversion/gql-to-agui.test.ts +1578 -0
  15. package/src/graphql/message-conversion/gql-to-agui.ts +278 -0
  16. package/src/graphql/message-conversion/index.ts +2 -0
  17. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +526 -0
  18. package/src/graphql/resolvers/copilot.resolver.ts +3 -48
  19. package/src/graphql/resolvers/state.resolver.ts +3 -2
  20. package/src/graphql/types/converted/index.ts +32 -6
  21. package/src/graphql/types/enums.ts +2 -2
  22. package/src/graphql/types/message-status.type.ts +3 -1
  23. package/src/lib/index.ts +1 -1
  24. package/src/lib/integrations/nextjs/app-router.ts +10 -11
  25. package/src/lib/integrations/nextjs/pages-router.ts +4 -11
  26. package/src/lib/integrations/node-http/index.ts +64 -5
  27. package/src/lib/integrations/shared.ts +1 -1
  28. package/src/lib/observability.ts +87 -0
  29. package/src/lib/runtime/{langgraph/langgraph-agent.ts → agent-integrations/langgraph.agent.ts} +5 -0
  30. package/src/lib/runtime/copilot-runtime.ts +346 -1333
  31. package/src/lib/runtime/types.ts +49 -0
  32. package/src/lib/runtime/utils.ts +87 -0
  33. package/src/lib/telemetry-client.ts +6 -5
  34. package/src/service-adapters/anthropic/anthropic-adapter.ts +5 -1
  35. package/src/service-adapters/bedrock/bedrock-adapter.ts +6 -1
  36. package/src/service-adapters/empty/empty-adapter.ts +3 -0
  37. package/src/service-adapters/events.ts +0 -254
  38. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +5 -1
  39. package/src/service-adapters/google/google-genai-adapter.ts +7 -1
  40. package/src/service-adapters/groq/groq-adapter.ts +5 -1
  41. package/src/service-adapters/langchain/langchain-adapter.ts +3 -0
  42. package/src/service-adapters/openai/openai-adapter.ts +5 -1
  43. package/src/service-adapters/openai/openai-assistant-adapter.ts +4 -0
  44. package/src/service-adapters/service-adapter.ts +3 -0
  45. package/src/service-adapters/unify/unify-adapter.ts +6 -1
  46. package/src/v2/index.ts +2 -0
  47. package/tsup.config.ts +2 -1
  48. package/dist/chunk-27JKTS6P.mjs +0 -1704
  49. package/dist/chunk-27JKTS6P.mjs.map +0 -1
  50. package/dist/chunk-2OZAGFV3.mjs +0 -43
  51. package/dist/chunk-2OZAGFV3.mjs.map +0 -1
  52. package/dist/chunk-AMUJQ6IR.mjs +0 -50
  53. package/dist/chunk-AMUJQ6IR.mjs.map +0 -1
  54. package/dist/chunk-CEOMFPJU.mjs +0 -6020
  55. package/dist/chunk-CEOMFPJU.mjs.map +0 -1
  56. package/dist/chunk-DTPRUTNV.mjs +0 -25
  57. package/dist/chunk-DTPRUTNV.mjs.map +0 -1
  58. package/dist/chunk-FHD4JECV.mjs +0 -33
  59. package/dist/chunk-FHD4JECV.mjs.map +0 -1
  60. package/dist/chunk-I27F2UPA.mjs +0 -175
  61. package/dist/chunk-I27F2UPA.mjs.map +0 -1
  62. package/dist/chunk-LPEPX6NH.mjs +0 -25
  63. package/dist/chunk-LPEPX6NH.mjs.map +0 -1
  64. package/dist/chunk-PTYRVXXP.mjs +0 -80
  65. package/dist/chunk-PTYRVXXP.mjs.map +0 -1
  66. package/dist/chunk-SHBDMA63.mjs +0 -141
  67. package/dist/chunk-SHBDMA63.mjs.map +0 -1
  68. package/dist/chunk-XWBDEXDA.mjs +0 -153
  69. package/dist/chunk-XWBDEXDA.mjs.map +0 -1
  70. package/dist/graphql/types/base/index.d.ts +0 -6
  71. package/dist/graphql/types/base/index.js +0 -63
  72. package/dist/graphql/types/base/index.js.map +0 -1
  73. package/dist/graphql/types/base/index.mjs +0 -8
  74. package/dist/graphql/types/base/index.mjs.map +0 -1
  75. package/dist/graphql/types/converted/index.d.ts +0 -2
  76. package/dist/graphql/types/converted/index.js +0 -200
  77. package/dist/graphql/types/converted/index.js.map +0 -1
  78. package/dist/graphql/types/converted/index.mjs +0 -19
  79. package/dist/graphql/types/converted/index.mjs.map +0 -1
  80. package/dist/groq-adapter-c8aec5c5.d.ts +0 -321
  81. package/dist/index-96b330da.d.ts +0 -119
  82. package/dist/langserve-0c6100e3.d.ts +0 -257
  83. package/dist/lib/cloud/index.d.ts +0 -6
  84. package/dist/lib/cloud/index.js +0 -18
  85. package/dist/lib/cloud/index.js.map +0 -1
  86. package/dist/lib/cloud/index.mjs +0 -1
  87. package/dist/lib/cloud/index.mjs.map +0 -1
  88. package/dist/lib/index.d.ts +0 -212
  89. package/dist/lib/index.js +0 -7843
  90. package/dist/lib/index.js.map +0 -1
  91. package/dist/lib/index.mjs +0 -76
  92. package/dist/lib/index.mjs.map +0 -1
  93. package/dist/lib/integrations/index.d.ts +0 -34
  94. package/dist/lib/integrations/index.js +0 -3052
  95. package/dist/lib/integrations/index.js.map +0 -1
  96. package/dist/lib/integrations/index.mjs +0 -37
  97. package/dist/lib/integrations/index.mjs.map +0 -1
  98. package/dist/lib/integrations/nest/index.d.ts +0 -15
  99. package/dist/lib/integrations/nest/index.js +0 -2959
  100. package/dist/lib/integrations/nest/index.js.map +0 -1
  101. package/dist/lib/integrations/nest/index.mjs +0 -14
  102. package/dist/lib/integrations/nest/index.mjs.map +0 -1
  103. package/dist/lib/integrations/node-express/index.d.ts +0 -15
  104. package/dist/lib/integrations/node-express/index.js +0 -2959
  105. package/dist/lib/integrations/node-express/index.js.map +0 -1
  106. package/dist/lib/integrations/node-express/index.mjs +0 -14
  107. package/dist/lib/integrations/node-express/index.mjs.map +0 -1
  108. package/dist/lib/integrations/node-http/index.d.ts +0 -15
  109. package/dist/lib/integrations/node-http/index.js +0 -2945
  110. package/dist/lib/integrations/node-http/index.js.map +0 -1
  111. package/dist/lib/integrations/node-http/index.mjs +0 -13
  112. package/dist/lib/integrations/node-http/index.mjs.map +0 -1
  113. package/dist/service-adapters/index.d.ts +0 -162
  114. package/dist/service-adapters/index.js +0 -1787
  115. package/dist/service-adapters/index.js.map +0 -1
  116. package/dist/service-adapters/index.mjs +0 -34
  117. package/dist/service-adapters/index.mjs.map +0 -1
  118. package/dist/service-adapters/shared/index.d.ts +0 -9
  119. package/dist/service-adapters/shared/index.js +0 -72
  120. package/dist/service-adapters/shared/index.js.map +0 -1
  121. package/dist/service-adapters/shared/index.mjs +0 -8
  122. package/dist/service-adapters/shared/index.mjs.map +0 -1
  123. package/dist/shared-0a7346ce.d.ts +0 -466
  124. package/dist/utils/index.d.ts +0 -65
  125. package/dist/utils/index.js +0 -175
  126. package/dist/utils/index.js.map +0 -1
  127. package/dist/utils/index.mjs +0 -12
  128. package/dist/utils/index.mjs.map +0 -1
  129. package/src/lib/runtime/__tests__/remote-action-constructors.test.ts +0 -246
  130. package/src/lib/runtime/agui-action.ts +0 -180
  131. package/src/lib/runtime/remote-action-constructors.ts +0 -331
  132. package/src/lib/runtime/remote-actions.ts +0 -217
  133. package/src/lib/runtime/remote-lg-action.ts +0 -1006
@@ -1,321 +0,0 @@
1
- import OpenAI from 'openai';
2
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-0c6100e3.js';
3
- import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
4
- import { DynamicStructuredTool } from '@langchain/core/tools';
5
- import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
6
- import { Groq } from 'groq-sdk';
7
-
8
- /**
9
- * Copilot Runtime adapter for OpenAI.
10
- *
11
- * ## Example
12
- *
13
- * ```ts
14
- * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
15
- * import OpenAI from "openai";
16
- *
17
- * const copilotKit = new CopilotRuntime();
18
- *
19
- * const openai = new OpenAI({
20
- * organization: "<your-organization-id>", // optional
21
- * apiKey: "<your-api-key>",
22
- * });
23
- *
24
- * return new OpenAIAdapter({ openai });
25
- * ```
26
- *
27
- * ## Example with Azure OpenAI
28
- *
29
- * ```ts
30
- * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
31
- * import OpenAI from "openai";
32
- *
33
- * // The name of your Azure OpenAI Instance.
34
- * // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
35
- * const instance = "<your instance name>";
36
- *
37
- * // Corresponds to your Model deployment within your OpenAI resource, e.g. my-gpt35-16k-deployment
38
- * // Navigate to the Azure OpenAI Studio to deploy a model.
39
- * const model = "<your model>";
40
- *
41
- * const apiKey = process.env["AZURE_OPENAI_API_KEY"];
42
- * if (!apiKey) {
43
- * throw new Error("The AZURE_OPENAI_API_KEY environment variable is missing or empty.");
44
- * }
45
- *
46
- * const copilotKit = new CopilotRuntime();
47
- *
48
- * const openai = new OpenAI({
49
- * apiKey,
50
- * baseURL: `https://${instance}.openai.azure.com/openai/deployments/${model}`,
51
- * defaultQuery: { "api-version": "2024-04-01-preview" },
52
- * defaultHeaders: { "api-key": apiKey },
53
- * });
54
- *
55
- * return new OpenAIAdapter({ openai });
56
- * ```
57
- */
58
-
59
- interface OpenAIAdapterParams {
60
- /**
61
- * An optional OpenAI instance to use. If not provided, a new instance will be
62
- * created.
63
- */
64
- openai?: OpenAI;
65
- /**
66
- * The model to use.
67
- */
68
- model?: string;
69
- /**
70
- * Whether to disable parallel tool calls.
71
- * You can disable parallel tool calls to force the model to execute tool calls sequentially.
72
- * This is useful if you want to execute tool calls in a specific order so that the state changes
73
- * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
74
- *
75
- * @default false
76
- */
77
- disableParallelToolCalls?: boolean;
78
- /**
79
- * Whether to keep the role in system messages as "System".
80
- * By default, it is converted to "developer", which is used by newer OpenAI models
81
- *
82
- * @default false
83
- */
84
- keepSystemRole?: boolean;
85
- }
86
- declare class OpenAIAdapter implements CopilotServiceAdapter {
87
- private model;
88
- private disableParallelToolCalls;
89
- private _openai;
90
- private keepSystemRole;
91
- get openai(): OpenAI;
92
- constructor(params?: OpenAIAdapterParams);
93
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
94
- }
95
-
96
- type LangChainBaseMessageChunkStream = IterableReadableStream<BaseMessageChunk>;
97
- type LangChainAIMessageChunkStream = IterableReadableStreamInterface<AIMessageChunk>;
98
- type LangChainReturnType = LangChainBaseMessageChunkStream | LangChainAIMessageChunkStream | BaseMessageChunk | string | AIMessage;
99
-
100
- /**
101
- * Copilot Runtime adapter for LangChain.
102
- *
103
- * ## Example
104
- *
105
- * ```ts
106
- * import { CopilotRuntime, LangChainAdapter } from "@copilotkit/runtime";
107
- * import { ChatOpenAI } from "@langchain/openai";
108
- *
109
- * const copilotKit = new CopilotRuntime();
110
- *
111
- * const model = new ChatOpenAI({
112
- * model: "gpt-4o",
113
- * apiKey: "<your-api-key>",
114
- * });
115
- *
116
- * return new LangChainAdapter({
117
- * chainFn: async ({ messages, tools }) => {
118
- * return model.bindTools(tools).stream(messages);
119
- * // or optionally enable strict mode
120
- * // return model.bindTools(tools, { strict: true }).stream(messages);
121
- * }
122
- * });
123
- * ```
124
- *
125
- * The asynchronous handler function (`chainFn`) can return any of the following:
126
- *
127
- * - A simple `string` response
128
- * - A LangChain stream (`IterableReadableStream`)
129
- * - A LangChain `BaseMessageChunk` object
130
- * - A LangChain `AIMessage` object
131
- */
132
-
133
- interface ChainFnParameters {
134
- model: string;
135
- messages: BaseMessage[];
136
- tools: DynamicStructuredTool[];
137
- threadId?: string;
138
- runId?: string;
139
- }
140
- interface LangChainAdapterOptions {
141
- /**
142
- * A function that uses the LangChain API to generate a response.
143
- */
144
- chainFn: (parameters: ChainFnParameters) => Promise<LangChainReturnType>;
145
- }
146
- declare class LangChainAdapter implements CopilotServiceAdapter {
147
- private options;
148
- /**
149
- * To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
150
- */
151
- constructor(options: LangChainAdapterOptions);
152
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
153
- }
154
-
155
- interface GoogleGenerativeAIAdapterOptions {
156
- /**
157
- * A custom Google Generative AI model to use.
158
- */
159
- model?: string;
160
- /**
161
- * The API key to use.
162
- */
163
- apiKey?: string;
164
- }
165
- declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
166
- constructor(options?: GoogleGenerativeAIAdapterOptions);
167
- }
168
-
169
- /**
170
- * Copilot Runtime adapter for the OpenAI Assistant API.
171
- *
172
- * ## Example
173
- *
174
- * ```ts
175
- * import { CopilotRuntime, OpenAIAssistantAdapter } from "@copilotkit/runtime";
176
- * import OpenAI from "openai";
177
- *
178
- * const copilotKit = new CopilotRuntime();
179
- *
180
- * const openai = new OpenAI({
181
- * organization: "<your-organization-id>",
182
- * apiKey: "<your-api-key>",
183
- * });
184
- *
185
- * return new OpenAIAssistantAdapter({
186
- * openai,
187
- * assistantId: "<your-assistant-id>",
188
- * codeInterpreterEnabled: true,
189
- * fileSearchEnabled: true,
190
- * });
191
- * ```
192
- */
193
-
194
- interface OpenAIAssistantAdapterParams {
195
- /**
196
- * The ID of the assistant to use.
197
- */
198
- assistantId: string;
199
- /**
200
- * An optional OpenAI instance to use. If not provided, a new instance will be created.
201
- */
202
- openai?: OpenAI;
203
- /**
204
- * Whether to enable code interpretation.
205
- * @default true
206
- */
207
- codeInterpreterEnabled?: boolean;
208
- /**
209
- * Whether to enable file search.
210
- * @default true
211
- */
212
- fileSearchEnabled?: boolean;
213
- /**
214
- * Whether to disable parallel tool calls.
215
- * You can disable parallel tool calls to force the model to execute tool calls sequentially.
216
- * This is useful if you want to execute tool calls in a specific order so that the state changes
217
- * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
218
- *
219
- * @default false
220
- */
221
- disableParallelToolCalls?: boolean;
222
- /**
223
- * Whether to keep the role in system messages as "System".
224
- * By default, it is converted to "developer", which is used by newer OpenAI models
225
- *
226
- * @default false
227
- */
228
- keepSystemRole?: boolean;
229
- }
230
- declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
231
- private openai;
232
- private codeInterpreterEnabled;
233
- private assistantId;
234
- private fileSearchEnabled;
235
- private disableParallelToolCalls;
236
- private keepSystemRole;
237
- constructor(params: OpenAIAssistantAdapterParams);
238
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
239
- private submitToolOutputs;
240
- private submitUserMessage;
241
- private streamResponse;
242
- }
243
-
244
- /**
245
- * CopilotKit Adapter for Unify
246
- *
247
- * <RequestExample>
248
- * ```jsx CopilotRuntime Example
249
- * const copilotKit = new CopilotRuntime();
250
- * return copilotKit.response(req, new UnifyAdapter());
251
- * ```
252
- * </RequestExample>
253
- *
254
- * You can easily set the model to use by passing it to the constructor.
255
- * ```jsx
256
- * const copilotKit = new CopilotRuntime();
257
- * return copilotKit.response(
258
- * req,
259
- * new UnifyAdapter({ model: "llama-3-8b-chat@fireworks-ai" }),
260
- * );
261
- * ```
262
- */
263
-
264
- interface UnifyAdapterParams {
265
- apiKey?: string;
266
- model: string;
267
- }
268
- declare class UnifyAdapter implements CopilotServiceAdapter {
269
- private apiKey;
270
- private model;
271
- private start;
272
- constructor(options?: UnifyAdapterParams);
273
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
274
- }
275
-
276
- /**
277
- * Copilot Runtime adapter for Groq.
278
- *
279
- * ## Example
280
- *
281
- * ```ts
282
- * import { CopilotRuntime, GroqAdapter } from "@copilotkit/runtime";
283
- * import { Groq } from "groq-sdk";
284
- *
285
- * const groq = new Groq({ apiKey: process.env["GROQ_API_KEY"] });
286
- *
287
- * const copilotKit = new CopilotRuntime();
288
- *
289
- * return new GroqAdapter({ groq, model: "<model-name>" });
290
- * ```
291
- */
292
-
293
- interface GroqAdapterParams {
294
- /**
295
- * An optional Groq instance to use.
296
- */
297
- groq?: Groq;
298
- /**
299
- * The model to use.
300
- */
301
- model?: string;
302
- /**
303
- * Whether to disable parallel tool calls.
304
- * You can disable parallel tool calls to force the model to execute tool calls sequentially.
305
- * This is useful if you want to execute tool calls in a specific order so that the state changes
306
- * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
307
- *
308
- * @default false
309
- */
310
- disableParallelToolCalls?: boolean;
311
- }
312
- declare class GroqAdapter implements CopilotServiceAdapter {
313
- private model;
314
- private disableParallelToolCalls;
315
- private _groq;
316
- get groq(): Groq;
317
- constructor(params?: GroqAdapterParams);
318
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
319
- }
320
-
321
- export { GoogleGenerativeAIAdapter as G, LangChainAdapter as L, OpenAIAdapterParams as O, UnifyAdapterParams as U, OpenAIAdapter as a, OpenAIAssistantAdapterParams as b, OpenAIAssistantAdapter as c, UnifyAdapter as d, GroqAdapterParams as e, GroqAdapter as f };
@@ -1,119 +0,0 @@
1
- import { BaseMessageInput } from './graphql/types/base/index.js';
2
-
3
- declare enum MessageRole {
4
- user = "user",
5
- assistant = "assistant",
6
- system = "system",
7
- tool = "tool",
8
- developer = "developer"
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
- type MessageType = "TextMessage" | "ActionExecutionMessage" | "ResultMessage" | "AgentStateMessage" | "ImageMessage";
58
- declare class Message extends BaseMessageInput {
59
- type: MessageType;
60
- isTextMessage(): this is TextMessage;
61
- isActionExecutionMessage(): this is ActionExecutionMessage;
62
- isResultMessage(): this is ResultMessage;
63
- isAgentStateMessage(): this is AgentStateMessage;
64
- isImageMessage(): this is ImageMessage;
65
- }
66
- declare class TextMessage extends Message implements TextMessageInput {
67
- type: MessageType;
68
- content: string;
69
- role: MessageRole;
70
- parentMessageId?: string;
71
- }
72
- declare class ActionExecutionMessage extends Message implements Omit<ActionExecutionMessageInput, "arguments" | "scope"> {
73
- type: MessageType;
74
- name: string;
75
- arguments: Record<string, any>;
76
- parentMessageId?: string;
77
- }
78
- declare class ResultMessage extends Message implements ResultMessageInput {
79
- type: MessageType;
80
- actionExecutionId: string;
81
- actionName: string;
82
- result: string;
83
- static encodeResult(result: any, error?: {
84
- code: string;
85
- message: string;
86
- } | string | Error): string;
87
- static decodeResult(result: string): {
88
- error?: {
89
- code: string;
90
- message: string;
91
- };
92
- result: string;
93
- };
94
- hasError(): boolean;
95
- getError(): {
96
- code: string;
97
- message: string;
98
- } | undefined;
99
- }
100
- declare class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, "state"> {
101
- type: MessageType;
102
- threadId: string;
103
- agentName: string;
104
- nodeName: string;
105
- runId: string;
106
- active: boolean;
107
- role: MessageRole;
108
- state: any;
109
- running: boolean;
110
- }
111
- declare class ImageMessage extends Message implements ImageMessageInput {
112
- type: MessageType;
113
- format: string;
114
- bytes: string;
115
- role: MessageRole;
116
- parentMessageId?: string;
117
- }
118
-
119
- export { ActionInputAvailability as A, ImageMessage as I, Message as M, ResultMessage as R, TextMessage as T, ActionExecutionMessage as a, MessageInput as b, MessageType as c, AgentStateMessage as d };
@@ -1,257 +0,0 @@
1
- import { A as ActionInputAvailability, T as TextMessage, a as ActionExecutionMessage, R as ResultMessage, M as Message } from './index-96b330da.js';
2
- import * as rxjs from 'rxjs';
3
- import { Subject, ReplaySubject } from 'rxjs';
4
- import { Action, Parameter } from '@copilotkit/shared';
5
-
6
- declare class ActionInput {
7
- name: string;
8
- description: string;
9
- jsonSchema: string;
10
- available?: ActionInputAvailability;
11
- }
12
-
13
- declare enum GuardrailsResultStatus {
14
- ALLOWED = "allowed",
15
- DENIED = "denied"
16
- }
17
- declare class GuardrailsResult {
18
- status: GuardrailsResultStatus;
19
- reason?: string;
20
- }
21
-
22
- declare enum RuntimeEventTypes {
23
- TextMessageStart = "TextMessageStart",
24
- TextMessageContent = "TextMessageContent",
25
- TextMessageEnd = "TextMessageEnd",
26
- ActionExecutionStart = "ActionExecutionStart",
27
- ActionExecutionArgs = "ActionExecutionArgs",
28
- ActionExecutionEnd = "ActionExecutionEnd",
29
- ActionExecutionResult = "ActionExecutionResult",
30
- AgentStateMessage = "AgentStateMessage",
31
- MetaEvent = "MetaEvent",
32
- RunError = "RunError"
33
- }
34
- declare enum RuntimeMetaEventName {
35
- LangGraphInterruptEvent = "LangGraphInterruptEvent",
36
- LangGraphInterruptResumeEvent = "LangGraphInterruptResumeEvent",
37
- CopilotKitLangGraphInterruptEvent = "CopilotKitLangGraphInterruptEvent"
38
- }
39
- type RunTimeMetaEvent = {
40
- type: RuntimeEventTypes.MetaEvent;
41
- name: RuntimeMetaEventName.LangGraphInterruptEvent;
42
- value: string;
43
- } | {
44
- type: RuntimeEventTypes.MetaEvent;
45
- name: RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent;
46
- data: {
47
- value: string;
48
- messages: (TextMessage | ActionExecutionMessage | ResultMessage)[];
49
- };
50
- } | {
51
- type: RuntimeEventTypes.MetaEvent;
52
- name: RuntimeMetaEventName.LangGraphInterruptResumeEvent;
53
- data: string;
54
- };
55
- type RuntimeErrorEvent = {
56
- type: RuntimeEventTypes.RunError;
57
- message: string;
58
- code?: string;
59
- };
60
- type RuntimeEvent = {
61
- type: RuntimeEventTypes.TextMessageStart;
62
- messageId: string;
63
- parentMessageId?: string;
64
- } | {
65
- type: RuntimeEventTypes.TextMessageContent;
66
- messageId: string;
67
- content: string;
68
- } | {
69
- type: RuntimeEventTypes.TextMessageEnd;
70
- messageId: string;
71
- } | {
72
- type: RuntimeEventTypes.ActionExecutionStart;
73
- actionExecutionId: string;
74
- actionName: string;
75
- parentMessageId?: string;
76
- } | {
77
- type: RuntimeEventTypes.ActionExecutionArgs;
78
- actionExecutionId: string;
79
- args: string;
80
- } | {
81
- type: RuntimeEventTypes.ActionExecutionEnd;
82
- actionExecutionId: string;
83
- } | {
84
- type: RuntimeEventTypes.ActionExecutionResult;
85
- actionName: string;
86
- actionExecutionId: string;
87
- result: string;
88
- } | {
89
- type: RuntimeEventTypes.AgentStateMessage;
90
- threadId: string;
91
- agentName: string;
92
- nodeName: string;
93
- runId: string;
94
- active: boolean;
95
- role: string;
96
- state: string;
97
- running: boolean;
98
- } | RunTimeMetaEvent | RuntimeErrorEvent;
99
- type EventSourceCallback = (eventStream$: RuntimeEventSubject) => Promise<void>;
100
- declare class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {
101
- constructor();
102
- sendTextMessageStart({ messageId, parentMessageId, }: {
103
- messageId: string;
104
- parentMessageId?: string;
105
- }): void;
106
- sendTextMessageContent({ messageId, content }: {
107
- messageId: string;
108
- content: string;
109
- }): void;
110
- sendTextMessageEnd({ messageId }: {
111
- messageId: string;
112
- }): void;
113
- sendTextMessage(messageId: string, content: string): void;
114
- sendActionExecutionStart({ actionExecutionId, actionName, parentMessageId, }: {
115
- actionExecutionId: string;
116
- actionName: string;
117
- parentMessageId?: string;
118
- }): void;
119
- sendActionExecutionArgs({ actionExecutionId, args, }: {
120
- actionExecutionId: string;
121
- args: string;
122
- }): void;
123
- sendActionExecutionEnd({ actionExecutionId }: {
124
- actionExecutionId: string;
125
- }): void;
126
- sendActionExecution({ actionExecutionId, actionName, args, parentMessageId, }: {
127
- actionExecutionId: string;
128
- actionName: string;
129
- args: string;
130
- parentMessageId?: string;
131
- }): void;
132
- sendActionExecutionResult({ actionExecutionId, actionName, result, error, }: {
133
- actionExecutionId: string;
134
- actionName: string;
135
- result?: string;
136
- error?: {
137
- code: string;
138
- message: string;
139
- };
140
- }): void;
141
- sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running, }: {
142
- threadId: string;
143
- agentName: string;
144
- nodeName: string;
145
- runId: string;
146
- active: boolean;
147
- role: string;
148
- state: string;
149
- running: boolean;
150
- }): void;
151
- }
152
- declare class RuntimeEventSource {
153
- private eventStream$;
154
- private callback;
155
- private errorHandler?;
156
- private errorContext?;
157
- constructor(params?: {
158
- errorHandler?: (error: any, context: any) => Promise<void>;
159
- errorContext?: any;
160
- });
161
- stream(callback: EventSourceCallback): Promise<void>;
162
- sendErrorMessageToChat(message?: string): void;
163
- processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId, }: {
164
- serverSideActions: Action<any>[];
165
- guardrailsResult$?: Subject<GuardrailsResult>;
166
- actionInputsWithoutAgents: ActionInput[];
167
- threadId: string;
168
- }): rxjs.Observable<RuntimeEvent>;
169
- }
170
-
171
- declare class ForwardedParametersInput {
172
- model?: string;
173
- maxTokens?: number;
174
- stop?: string[];
175
- toolChoice?: String;
176
- toolChoiceFunctionName?: string;
177
- temperature?: number;
178
- }
179
-
180
- /**
181
- * The extensions input is used to pass additional information to the copilot runtime, specific to a
182
- * service adapter or agent framework.
183
- */
184
- declare class ExtensionsInput {
185
- openaiAssistantAPI?: OpenAIApiAssistantAPIInput;
186
- }
187
- declare class OpenAIApiAssistantAPIInput {
188
- runId?: string;
189
- threadId?: string;
190
- }
191
-
192
- /**
193
- * The extensions response is used to receive additional information from the copilot runtime, specific to a
194
- * service adapter or agent framework.
195
- *
196
- * Next time a request to the runtime is made, the extensions response will be included in the request as input.
197
- */
198
- declare class ExtensionsResponse {
199
- openaiAssistantAPI?: OpenAIApiAssistantAPIResponse;
200
- }
201
- declare class OpenAIApiAssistantAPIResponse {
202
- runId?: string;
203
- threadId?: string;
204
- }
205
-
206
- declare class AgentSessionInput {
207
- agentName: string;
208
- threadId?: string;
209
- nodeName?: string;
210
- }
211
-
212
- declare class AgentStateInput {
213
- agentName: string;
214
- state: string;
215
- config?: string;
216
- }
217
-
218
- interface CopilotRuntimeChatCompletionRequest {
219
- eventSource: RuntimeEventSource;
220
- messages: Message[];
221
- actions: ActionInput[];
222
- model?: string;
223
- threadId?: string;
224
- runId?: string;
225
- forwardedParameters?: ForwardedParametersInput;
226
- extensions?: ExtensionsInput;
227
- agentSession?: AgentSessionInput;
228
- agentStates?: AgentStateInput[];
229
- }
230
- interface CopilotRuntimeChatCompletionResponse {
231
- threadId: string;
232
- runId?: string;
233
- extensions?: ExtensionsResponse;
234
- }
235
- interface CopilotServiceAdapter {
236
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
237
- }
238
-
239
- interface RemoteChainParameters {
240
- name: string;
241
- description: string;
242
- chainUrl: string;
243
- parameters?: Parameter[];
244
- parameterType?: "single" | "multi";
245
- }
246
- declare class RemoteChain {
247
- name: string;
248
- description: string;
249
- chainUrl: string;
250
- parameters?: Parameter[];
251
- parameterType: "single" | "multi";
252
- constructor(options: RemoteChainParameters);
253
- toAction(): Promise<Action<any>>;
254
- inferLangServeParameters(): Promise<void>;
255
- }
256
-
257
- export { ActionInput as A, CopilotRuntimeChatCompletionRequest as C, ExtensionsInput as E, ForwardedParametersInput as F, RemoteChainParameters as R, CopilotRuntimeChatCompletionResponse as a, CopilotServiceAdapter as b, RemoteChain as c, AgentSessionInput as d, AgentStateInput as e, RuntimeEventSource as f, ExtensionsResponse as g };
@@ -1,6 +0,0 @@
1
- interface CopilotCloudOptions {
2
- baseUrl?: string;
3
- publicApiKey?: string;
4
- }
5
-
6
- export { CopilotCloudOptions };