@copilotkit/runtime 1.10.5-next.0 → 1.10.5-next.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.
- package/CHANGELOG.md +68 -0
- package/__snapshots__/schema/schema.graphql +6 -0
- package/dist/{chunk-2JRX6LGW.mjs → chunk-COGFQ4V4.mjs} +2 -2
- package/dist/{chunk-WGOBL6DV.mjs → chunk-M65Z27MR.mjs} +2 -2
- package/dist/{chunk-HZWVUP7K.mjs → chunk-NFB4H6NT.mjs} +211 -144
- package/dist/chunk-NFB4H6NT.mjs.map +1 -0
- package/dist/{chunk-4GRKJVD6.mjs → chunk-NNBTOZO3.mjs} +2 -2
- package/dist/{chunk-TPMK44TE.mjs → chunk-Y5BKTUH2.mjs} +20 -6
- package/dist/chunk-Y5BKTUH2.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/{groq-adapter-4ba7b2f0.d.ts → groq-adapter-c8aec5c5.d.ts} +1 -1
- package/dist/{index-d4614f9b.d.ts → index-96b330da.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +247 -166
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{langserve-3f99bf2e.d.ts → langserve-0c6100e3.d.ts} +1 -1
- package/dist/lib/index.d.ts +12 -6
- package/dist/lib/index.js +247 -166
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +196 -151
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.d.ts +3 -3
- package/dist/lib/integrations/nest/index.js +196 -151
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +2 -2
- package/dist/lib/integrations/node-express/index.d.ts +3 -3
- package/dist/lib/integrations/node-express/index.js +196 -151
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +2 -2
- package/dist/lib/integrations/node-http/index.d.ts +3 -3
- package/dist/lib/integrations/node-http/index.js +196 -151
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/service-adapters/index.d.ts +5 -5
- package/dist/{shared-26958730.d.ts → shared-0a7346ce.d.ts} +19 -2
- package/package.json +11 -11
- package/src/graphql/inputs/copilot-context.input.ts +10 -0
- package/src/graphql/inputs/generate-copilot-response.input.ts +4 -0
- package/src/graphql/resolvers/copilot.resolver.ts +1 -0
- package/src/lib/runtime/agui-action.ts +11 -0
- package/src/lib/runtime/copilot-runtime.ts +30 -0
- package/src/lib/runtime/langgraph/langgraph-agent.ts +28 -7
- package/src/lib/runtime/remote-actions.ts +4 -0
- package/dist/chunk-HZWVUP7K.mjs.map +0 -1
- package/dist/chunk-TPMK44TE.mjs.map +0 -1
- /package/dist/{chunk-2JRX6LGW.mjs.map → chunk-COGFQ4V4.mjs.map} +0 -0
- /package/dist/{chunk-WGOBL6DV.mjs.map → chunk-M65Z27MR.mjs.map} +0 -0
- /package/dist/{chunk-4GRKJVD6.mjs.map → chunk-NNBTOZO3.mjs.map} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-
|
|
2
|
-
export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
7
|
-
import {
|
|
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;
|
|
@@ -239,6 +246,14 @@ interface OnAfterRequestOptions {
|
|
|
239
246
|
url?: string;
|
|
240
247
|
}
|
|
241
248
|
type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
|
|
249
|
+
interface OnStopGenerationOptions {
|
|
250
|
+
threadId: string;
|
|
251
|
+
runId?: string;
|
|
252
|
+
url?: string;
|
|
253
|
+
agentName?: string;
|
|
254
|
+
lastMessage: MessageInput;
|
|
255
|
+
}
|
|
256
|
+
type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
|
|
242
257
|
interface Middleware {
|
|
243
258
|
/**
|
|
244
259
|
* A function that is called before the request is processed.
|
|
@@ -355,6 +370,7 @@ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
|
|
|
355
370
|
* ```
|
|
356
371
|
*/
|
|
357
372
|
onError?: CopilotErrorHandler;
|
|
373
|
+
onStopGeneration?: OnStopGenerationHandler;
|
|
358
374
|
}
|
|
359
375
|
declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
360
376
|
actions: ActionsConfiguration<T>;
|
|
@@ -363,6 +379,7 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
363
379
|
private langserve;
|
|
364
380
|
private onBeforeRequest?;
|
|
365
381
|
private onAfterRequest?;
|
|
382
|
+
private onStopGeneration?;
|
|
366
383
|
private delegateAgentProcessingToServiceAdapter;
|
|
367
384
|
private observability?;
|
|
368
385
|
private availableAgents;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.10.5-next.
|
|
12
|
+
"version": "1.10.5-next.10",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"tsconfig": "1.4.6"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ag-ui/client": "^0.0.
|
|
41
|
-
"@ag-ui/core": "^0.0.
|
|
42
|
-
"@ag-ui/encoder": "^0.0.
|
|
43
|
-
"@ag-ui/langgraph": "^0.0.
|
|
44
|
-
"@ag-ui/proto": "^0.0.
|
|
40
|
+
"@ag-ui/client": "^0.0.39",
|
|
41
|
+
"@ag-ui/core": "^0.0.39",
|
|
42
|
+
"@ag-ui/encoder": "^0.0.39",
|
|
43
|
+
"@ag-ui/langgraph": "^0.0.17",
|
|
44
|
+
"@ag-ui/proto": "^0.0.39",
|
|
45
45
|
"@anthropic-ai/sdk": "^0.57.0",
|
|
46
46
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
47
47
|
"@langchain/aws": "^0.1.9",
|
|
@@ -67,13 +67,13 @@
|
|
|
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.5-next.
|
|
70
|
+
"@copilotkit/shared": "1.10.5-next.10"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@ag-ui/client": ">=0.0.
|
|
74
|
-
"@ag-ui/core": ">=0.0.
|
|
75
|
-
"@ag-ui/encoder": ">=0.0.
|
|
76
|
-
"@ag-ui/proto": ">=0.0.
|
|
73
|
+
"@ag-ui/client": ">=0.0.39",
|
|
74
|
+
"@ag-ui/core": ">=0.0.39",
|
|
75
|
+
"@ag-ui/encoder": ">=0.0.39",
|
|
76
|
+
"@ag-ui/proto": ">=0.0.39"
|
|
77
77
|
},
|
|
78
78
|
"keywords": [
|
|
79
79
|
"copilotkit",
|
|
@@ -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 = {
|
|
@@ -45,6 +48,13 @@ export function constructAGUIRemoteAction({
|
|
|
45
48
|
actionInputsWithoutAgents,
|
|
46
49
|
threadId,
|
|
47
50
|
}: RemoteAgentHandlerParams): Promise<Observable<RuntimeEvent>> => {
|
|
51
|
+
graphqlContext.request.signal.addEventListener(
|
|
52
|
+
"abort",
|
|
53
|
+
() => {
|
|
54
|
+
agent.abortRun();
|
|
55
|
+
},
|
|
56
|
+
{ once: true }, // optional: fire only once
|
|
57
|
+
);
|
|
48
58
|
logger.debug({ actionName: agent.agentId }, "Executing remote agent");
|
|
49
59
|
|
|
50
60
|
const agentWireMessages = convertMessagesToAGUIMessage(messages);
|
|
@@ -92,6 +102,7 @@ export function constructAGUIRemoteAction({
|
|
|
92
102
|
agent.legacy_to_be_removed_runAgentBridged({
|
|
93
103
|
tools,
|
|
94
104
|
forwardedProps,
|
|
105
|
+
context,
|
|
95
106
|
}) as Observable<RuntimeEvent>
|
|
96
107
|
).pipe(
|
|
97
108
|
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 {
|
|
@@ -142,6 +144,15 @@ interface OnAfterRequestOptions {
|
|
|
142
144
|
|
|
143
145
|
type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
|
|
144
146
|
|
|
147
|
+
interface OnStopGenerationOptions {
|
|
148
|
+
threadId: string;
|
|
149
|
+
runId?: string;
|
|
150
|
+
url?: string;
|
|
151
|
+
agentName?: string;
|
|
152
|
+
lastMessage: MessageInput;
|
|
153
|
+
}
|
|
154
|
+
type OnStopGenerationHandler = (options: OnStopGenerationOptions) => void | Promise<void>;
|
|
155
|
+
|
|
145
156
|
interface Middleware {
|
|
146
157
|
/**
|
|
147
158
|
* A function that is called before the request is processed.
|
|
@@ -299,6 +310,8 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
|
|
|
299
310
|
* ```
|
|
300
311
|
*/
|
|
301
312
|
onError?: CopilotErrorHandler;
|
|
313
|
+
|
|
314
|
+
onStopGeneration?: OnStopGenerationHandler;
|
|
302
315
|
}
|
|
303
316
|
|
|
304
317
|
export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
@@ -308,6 +321,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
308
321
|
private langserve: Promise<Action<any>>[] = [];
|
|
309
322
|
private onBeforeRequest?: OnBeforeRequestHandler;
|
|
310
323
|
private onAfterRequest?: OnAfterRequestHandler;
|
|
324
|
+
private onStopGeneration?: OnStopGenerationHandler;
|
|
311
325
|
private delegateAgentProcessingToServiceAdapter: boolean;
|
|
312
326
|
private observability?: CopilotObservabilityConfig;
|
|
313
327
|
private availableAgents: Pick<AgentWithEndpoint, "name" | "id">[];
|
|
@@ -357,6 +371,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
357
371
|
|
|
358
372
|
this.onBeforeRequest = params?.middleware?.onBeforeRequest;
|
|
359
373
|
this.onAfterRequest = params?.middleware?.onAfterRequest;
|
|
374
|
+
this.onStopGeneration = params?.onStopGeneration;
|
|
360
375
|
this.delegateAgentProcessingToServiceAdapter =
|
|
361
376
|
params?.delegateAgentProcessingToServiceAdapter || false;
|
|
362
377
|
this.observability = params?.observability_c;
|
|
@@ -484,7 +499,20 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
484
499
|
agentSession,
|
|
485
500
|
agentStates,
|
|
486
501
|
publicApiKey,
|
|
502
|
+
context,
|
|
487
503
|
} = request;
|
|
504
|
+
graphqlContext.request.signal.addEventListener(
|
|
505
|
+
"abort",
|
|
506
|
+
() =>
|
|
507
|
+
this.onStopGeneration?.({
|
|
508
|
+
threadId,
|
|
509
|
+
runId,
|
|
510
|
+
url,
|
|
511
|
+
agentName: agentSession?.agentName,
|
|
512
|
+
lastMessage: rawMessages[rawMessages.length - 1],
|
|
513
|
+
}),
|
|
514
|
+
{ once: true }, // optional: fire only once
|
|
515
|
+
);
|
|
488
516
|
|
|
489
517
|
const eventSource = new RuntimeEventSource({
|
|
490
518
|
errorHandler: async (error, context) => {
|
|
@@ -1025,6 +1053,7 @@ please use an LLM adapter instead.`,
|
|
|
1025
1053
|
metaEvents,
|
|
1026
1054
|
publicApiKey,
|
|
1027
1055
|
forwardedParameters,
|
|
1056
|
+
context,
|
|
1028
1057
|
} = request;
|
|
1029
1058
|
const { agentName, nodeName } = agentSession;
|
|
1030
1059
|
|
|
@@ -1408,6 +1437,7 @@ please use an LLM adapter instead.`,
|
|
|
1408
1437
|
agents: this.agents,
|
|
1409
1438
|
metaEvents: request.metaEvents,
|
|
1410
1439
|
nodeName: request.agentSession?.nodeName,
|
|
1440
|
+
context: request.context,
|
|
1411
1441
|
});
|
|
1412
1442
|
|
|
1413
1443
|
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(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
...
|
|
209
|
+
...aguiMergedState,
|
|
191
210
|
copilotkit: {
|
|
192
|
-
actions:
|
|
211
|
+
actions: combinedTools,
|
|
212
|
+
context: agui?.context ?? [],
|
|
193
213
|
},
|
|
194
214
|
};
|
|
195
215
|
}
|
|
@@ -201,6 +221,7 @@ export class LangGraphAgent extends AGUILangGraphAgent {
|
|
|
201
221
|
config: schemaKeys.config,
|
|
202
222
|
input: schemaKeys.input ? [...schemaKeys.input, ...CONSTANT_KEYS] : null,
|
|
203
223
|
output: schemaKeys.output ? [...schemaKeys.output, ...CONSTANT_KEYS] : null,
|
|
224
|
+
context: schemaKeys.context ? [...schemaKeys.context, ...CONSTANT_KEYS] : null,
|
|
204
225
|
};
|
|
205
226
|
}
|
|
206
227
|
}
|
|
@@ -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
|
}
|