@copilotkit/runtime 1.10.4 → 1.10.5-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/__snapshots__/schema/schema.graphql +6 -0
  3. package/dist/{chunk-HV5H6LOK.mjs → chunk-C56AVUZI.mjs} +2 -2
  4. package/dist/{chunk-HHMKB5P4.mjs → chunk-CX4GADTM.mjs} +2 -2
  5. package/dist/{chunk-XAA5PFCY.mjs → chunk-FOXQPOXW.mjs} +184 -136
  6. package/dist/chunk-FOXQPOXW.mjs.map +1 -0
  7. package/dist/{chunk-XGVZS3FD.mjs → chunk-H6QUY5ZQ.mjs} +16 -6
  8. package/dist/chunk-H6QUY5ZQ.mjs.map +1 -0
  9. package/dist/{chunk-CNG7I5M5.mjs → chunk-T4NLPBCY.mjs} +2 -2
  10. package/dist/graphql/types/converted/index.d.ts +1 -1
  11. package/dist/{groq-adapter-4ba7b2f0.d.ts → groq-adapter-c8aec5c5.d.ts} +1 -1
  12. package/dist/{index-d4614f9b.d.ts → index-96b330da.d.ts} +1 -1
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +216 -158
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +5 -5
  17. package/dist/{langserve-3f99bf2e.d.ts → langserve-0c6100e3.d.ts} +1 -1
  18. package/dist/lib/index.d.ts +12 -6
  19. package/dist/lib/index.js +216 -158
  20. package/dist/lib/index.js.map +1 -1
  21. package/dist/lib/index.mjs +5 -5
  22. package/dist/lib/integrations/index.d.ts +4 -4
  23. package/dist/lib/integrations/index.js +188 -143
  24. package/dist/lib/integrations/index.js.map +1 -1
  25. package/dist/lib/integrations/index.mjs +4 -4
  26. package/dist/lib/integrations/nest/index.d.ts +3 -3
  27. package/dist/lib/integrations/nest/index.js +188 -143
  28. package/dist/lib/integrations/nest/index.js.map +1 -1
  29. package/dist/lib/integrations/nest/index.mjs +2 -2
  30. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  31. package/dist/lib/integrations/node-express/index.js +188 -143
  32. package/dist/lib/integrations/node-express/index.js.map +1 -1
  33. package/dist/lib/integrations/node-express/index.mjs +2 -2
  34. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  35. package/dist/lib/integrations/node-http/index.js +188 -143
  36. package/dist/lib/integrations/node-http/index.js.map +1 -1
  37. package/dist/lib/integrations/node-http/index.mjs +1 -1
  38. package/dist/service-adapters/index.d.ts +5 -5
  39. package/dist/{shared-26958730.d.ts → shared-35015e40.d.ts} +9 -2
  40. package/package.json +3 -3
  41. package/src/graphql/inputs/copilot-context.input.ts +10 -0
  42. package/src/graphql/inputs/generate-copilot-response.input.ts +4 -0
  43. package/src/graphql/resolvers/copilot.resolver.ts +1 -0
  44. package/src/lib/runtime/agui-action.ts +4 -0
  45. package/src/lib/runtime/copilot-runtime.ts +5 -0
  46. package/src/lib/runtime/langgraph/langgraph-agent.ts +27 -7
  47. package/src/lib/runtime/remote-actions.ts +4 -0
  48. package/dist/chunk-XAA5PFCY.mjs.map +0 -1
  49. package/dist/chunk-XGVZS3FD.mjs.map +0 -1
  50. /package/dist/{chunk-HV5H6LOK.mjs.map → chunk-C56AVUZI.mjs.map} +0 -0
  51. /package/dist/{chunk-HHMKB5P4.mjs.map → chunk-CX4GADTM.mjs.map} +0 -0
  52. /package/dist/{chunk-CNG7I5M5.mjs.map → chunk-T4NLPBCY.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-XAA5PFCY.mjs";
3
+ } from "../../../chunk-FOXQPOXW.mjs";
4
4
  import "../../../chunk-SHBDMA63.mjs";
5
5
  import "../../../chunk-F7IANE7Z.mjs";
6
6
  import "../../../chunk-XWBDEXDA.mjs";
@@ -1,10 +1,10 @@
1
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-3f99bf2e.js';
2
- export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-3f99bf2e.js';
1
+ import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-0c6100e3.js';
2
+ export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-0c6100e3.js';
3
3
  export { convertServiceAdapterError } from './shared/index.js';
4
- import { L as LangChainAdapter } from '../groq-adapter-4ba7b2f0.js';
5
- export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-4ba7b2f0.js';
4
+ import { L as LangChainAdapter } from '../groq-adapter-c8aec5c5.js';
5
+ export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-c8aec5c5.js';
6
6
  import Anthropic from '@anthropic-ai/sdk';
7
- import '../index-d4614f9b.js';
7
+ import '../index-96b330da.js';
8
8
  import '../graphql/types/base/index.js';
9
9
  import 'rxjs';
10
10
  import '@copilotkit/shared';
@@ -3,8 +3,8 @@ import * as createPinoLogger from 'pino';
3
3
  import createPinoLogger__default from 'pino';
4
4
  import { YogaInitialContext, createYoga } from 'graphql-yoga';
5
5
  import { Parameter, Action, CopilotErrorHandler } from '@copilotkit/shared';
6
- import { b as CopilotServiceAdapter, A as ActionInput, d as AgentSessionInput, e as AgentStateInput, F as ForwardedParametersInput, E as ExtensionsInput, R as RemoteChainParameters, f as RuntimeEventSource, g as ExtensionsResponse } from './langserve-3f99bf2e.js';
7
- import { M as MessageInput, a as Message } from './index-d4614f9b.js';
6
+ import { b as CopilotServiceAdapter, A as ActionInput, d as AgentSessionInput, e as AgentStateInput, F as ForwardedParametersInput, E as ExtensionsInput, R as RemoteChainParameters, f as RuntimeEventSource, g as ExtensionsResponse } from './langserve-0c6100e3.js';
7
+ import { b as MessageInput, M as Message } from './index-96b330da.js';
8
8
  import { CopilotCloudOptions } from './lib/cloud/index.js';
9
9
  import { AbstractAgent } from '@ag-ui/client';
10
10
 
@@ -20,6 +20,11 @@ declare class MetaEventInput {
20
20
  messages?: MessageInput[];
21
21
  }
22
22
 
23
+ declare class CopilotContextInput {
24
+ description: string;
25
+ value: string;
26
+ }
27
+
23
28
  type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
24
29
  declare enum EndpointType {
25
30
  CopilotKit = "copilotKit",
@@ -194,6 +199,7 @@ declare function generateMcpToolInstructions(toolsMap: Record<string, MCPTool>):
194
199
  */
195
200
 
196
201
  type CreateMCPClientFunction = (config: MCPEndpointConfig) => Promise<MCPClient>;
202
+
197
203
  interface CopilotRuntimeRequest {
198
204
  serviceAdapter: CopilotServiceAdapter;
199
205
  messages: MessageInput[];
@@ -209,6 +215,7 @@ interface CopilotRuntimeRequest {
209
215
  url?: string;
210
216
  extensions?: ExtensionsInput;
211
217
  metaEvents?: MetaEventInput[];
218
+ context?: CopilotContextInput[];
212
219
  }
213
220
  interface CopilotRuntimeResponse {
214
221
  threadId: string;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.10.4",
12
+ "version": "1.10.5-next.1",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "@ag-ui/client": "^0.0.37",
41
41
  "@ag-ui/core": "^0.0.37",
42
42
  "@ag-ui/encoder": "^0.0.37",
43
- "@ag-ui/langgraph": "^0.0.12",
43
+ "@ag-ui/langgraph": "^0.0.13",
44
44
  "@ag-ui/proto": "^0.0.37",
45
45
  "@anthropic-ai/sdk": "^0.57.0",
46
46
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
@@ -67,7 +67,7 @@
67
67
  "rxjs": "7.8.1",
68
68
  "type-graphql": "2.0.0-rc.1",
69
69
  "zod": "^3.23.3",
70
- "@copilotkit/shared": "1.10.4"
70
+ "@copilotkit/shared": "1.10.5-next.1"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "@ag-ui/client": ">=0.0.37",
@@ -0,0 +1,10 @@
1
+ import { Field, InputType } from "type-graphql";
2
+
3
+ @InputType()
4
+ export class CopilotContextInput {
5
+ @Field(() => String)
6
+ description: string;
7
+
8
+ @Field(() => String)
9
+ value: string;
10
+ }
@@ -8,6 +8,7 @@ import { AgentSessionInput } from "./agent-session.input";
8
8
  import { AgentStateInput } from "./agent-state.input";
9
9
  import { ExtensionsInput } from "./extensions.input";
10
10
  import { MetaEventInput } from "./meta-event.input";
11
+ import { CopilotContextInput } from "./copilot-context.input";
11
12
 
12
13
  @InputType()
13
14
  export class GenerateCopilotResponseMetadataInput {
@@ -52,4 +53,7 @@ export class GenerateCopilotResponseInput {
52
53
 
53
54
  @Field(() => [MetaEventInput], { nullable: true })
54
55
  metaEvents?: MetaEventInput[];
56
+
57
+ @Field(() => [CopilotContextInput], { nullable: true })
58
+ context?: CopilotContextInput[];
55
59
  }
@@ -257,6 +257,7 @@ export class CopilotResolver {
257
257
  url: data.frontend.url,
258
258
  extensions: data.extensions,
259
259
  metaEvents: data.metaEvents,
260
+ context: data.context,
260
261
  });
261
262
  } catch (error) {
262
263
  // Catch structured CopilotKit errors at the main mutation level and re-throw as GraphQL errors
@@ -16,6 +16,7 @@ import { AbstractAgent } from "@ag-ui/client";
16
16
  import { CopilotKitError, CopilotKitErrorCode, parseJson } from "@copilotkit/shared";
17
17
  import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
18
18
  import { GraphQLContext } from "../integrations/shared";
19
+ import { CopilotContextInput } from "../../graphql/inputs/copilot-context.input";
19
20
 
20
21
  export function constructAGUIRemoteAction({
21
22
  logger,
@@ -25,6 +26,7 @@ export function constructAGUIRemoteAction({
25
26
  metaEvents,
26
27
  threadMetadata,
27
28
  nodeName,
29
+ context,
28
30
  graphqlContext,
29
31
  }: {
30
32
  logger: Logger;
@@ -34,6 +36,7 @@ export function constructAGUIRemoteAction({
34
36
  metaEvents?: MetaEventInput[];
35
37
  threadMetadata?: Record<string, any>;
36
38
  nodeName?: string;
39
+ context?: CopilotContextInput[];
37
40
  graphqlContext: GraphQLContext;
38
41
  }) {
39
42
  const action = {
@@ -92,6 +95,7 @@ export function constructAGUIRemoteAction({
92
95
  agent.legacy_to_be_removed_runAgentBridged({
93
96
  tools,
94
97
  forwardedProps,
98
+ context,
95
99
  }) as Observable<RuntimeEvent>
96
100
  ).pipe(
97
101
  mergeMap((event) => {
@@ -90,6 +90,7 @@ type CreateMCPClientFunction = (config: MCPEndpointConfig) => Promise<MCPClient>
90
90
  // --- MCP Imports ---
91
91
 
92
92
  import { generateHelpfulErrorMessage } from "../streaming";
93
+ import { CopilotContextInput } from "../../graphql/inputs/copilot-context.input";
93
94
 
94
95
  export interface CopilotRuntimeRequest {
95
96
  serviceAdapter: CopilotServiceAdapter;
@@ -106,6 +107,7 @@ export interface CopilotRuntimeRequest {
106
107
  url?: string;
107
108
  extensions?: ExtensionsInput;
108
109
  metaEvents?: MetaEventInput[];
110
+ context?: CopilotContextInput[];
109
111
  }
110
112
 
111
113
  interface CopilotRuntimeResponse {
@@ -484,6 +486,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
484
486
  agentSession,
485
487
  agentStates,
486
488
  publicApiKey,
489
+ context,
487
490
  } = request;
488
491
 
489
492
  const eventSource = new RuntimeEventSource({
@@ -1025,6 +1028,7 @@ please use an LLM adapter instead.`,
1025
1028
  metaEvents,
1026
1029
  publicApiKey,
1027
1030
  forwardedParameters,
1031
+ context,
1028
1032
  } = request;
1029
1033
  const { agentName, nodeName } = agentSession;
1030
1034
 
@@ -1408,6 +1412,7 @@ please use an LLM adapter instead.`,
1408
1412
  agents: this.agents,
1409
1413
  metaEvents: request.metaEvents,
1410
1414
  nodeName: request.agentSession?.nodeName,
1415
+ context: request.context,
1411
1416
  });
1412
1417
 
1413
1418
  const configuredActions =
@@ -19,10 +19,18 @@ import {
19
19
  ProcessedEvents,
20
20
  SchemaKeys,
21
21
  type State,
22
+ StateEnrichment,
22
23
  } from "@ag-ui/langgraph";
23
24
  import { Message as LangGraphMessage } from "@langchain/langgraph-sdk/dist/types.messages";
24
25
  import { ThreadState } from "@langchain/langgraph-sdk";
25
26
 
27
+ interface CopilotKitStateEnrichment {
28
+ copilotkit: {
29
+ actions: StateEnrichment["ag-ui"]["tools"];
30
+ context: StateEnrichment["ag-ui"]["context"];
31
+ };
32
+ }
33
+
26
34
  export interface PredictStateTool {
27
35
  tool: string;
28
36
  state_key: string;
@@ -179,17 +187,29 @@ export class LangGraphAgent extends AGUILangGraphAgent {
179
187
  );
180
188
  }
181
189
 
182
- langGraphDefaultMergeState(state: State, messages: LangGraphMessage[], tools: any): State {
183
- const { tools: returnedTools, ...rest } = super.langGraphDefaultMergeState(
184
- state,
185
- messages,
186
- tools,
190
+ langGraphDefaultMergeState(
191
+ state: State,
192
+ messages: LangGraphMessage[],
193
+ input: RunAgentInput,
194
+ ): State<StateEnrichment & CopilotKitStateEnrichment> {
195
+ const aguiMergedState = super.langGraphDefaultMergeState(state, messages, input);
196
+ const { tools: returnedTools, "ag-ui": agui } = aguiMergedState;
197
+ // tolerate undefined and de-duplicate by stable key (id | name | key)
198
+ const rawCombinedTools = [
199
+ ...((returnedTools as any[]) ?? []),
200
+ ...((agui?.tools as any[]) ?? []),
201
+ ];
202
+ const combinedTools = Array.from(
203
+ new Map(
204
+ rawCombinedTools.map((t: any) => [t?.id ?? t?.name ?? t?.key ?? JSON.stringify(t), t]),
205
+ ).values(),
187
206
  );
188
207
 
189
208
  return {
190
- ...rest,
209
+ ...aguiMergedState,
191
210
  copilotkit: {
192
- actions: returnedTools,
211
+ actions: combinedTools,
212
+ context: agui?.context ?? [],
193
213
  },
194
214
  };
195
215
  }
@@ -19,6 +19,7 @@ import {
19
19
  import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
20
20
  import { AbstractAgent } from "@ag-ui/client";
21
21
  import { constructAGUIRemoteAction } from "./agui-action";
22
+ import { CopilotContextInput } from "../../graphql/inputs/copilot-context.input";
22
23
 
23
24
  export type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
24
25
 
@@ -132,6 +133,7 @@ export async function setupRemoteActions({
132
133
  agents,
133
134
  metaEvents,
134
135
  nodeName,
136
+ context,
135
137
  }: {
136
138
  remoteEndpointDefinitions: EndpointDefinition[];
137
139
  graphqlContext: GraphQLContext;
@@ -141,6 +143,7 @@ export async function setupRemoteActions({
141
143
  agents: Record<string, AbstractAgent>;
142
144
  metaEvents?: MetaEventInput[];
143
145
  nodeName?: string;
146
+ context?: CopilotContextInput[];
144
147
  }): Promise<Action[]> {
145
148
  const logger = graphqlContext.logger.child({ component: "remote-actions.fetchRemoteActions" });
146
149
  logger.debug({ remoteEndpointDefinitions }, "Fetching from remote endpoints");
@@ -211,6 +214,7 @@ export async function setupRemoteActions({
211
214
  threadMetadata,
212
215
  nodeName,
213
216
  graphqlContext,
217
+ context,
214
218
  }),
215
219
  );
216
220
  }