@copilotkit/runtime 1.8.14-next.1 → 1.8.14-next.3
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 +14 -0
- package/dist/{chunk-F4NU7EVL.mjs → chunk-6P6VMQLZ.mjs} +28 -14
- package/dist/chunk-6P6VMQLZ.mjs.map +1 -0
- package/dist/{chunk-KTTUYDBP.mjs → chunk-BMA7V5T7.mjs} +2 -2
- package/dist/{chunk-WUBMXNOG.mjs → chunk-C7XHY7LW.mjs} +2 -2
- package/dist/{chunk-JJBN24EK.mjs → chunk-T2RKWYXN.mjs} +2 -2
- package/dist/index.js +27 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.js +27 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/lib/integrations/index.js +44 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.js +44 -1
- 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.js +44 -1
- 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.js +44 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/package.json +2 -2
- package/src/graphql/resolvers/copilot.resolver.ts +14 -0
- package/src/lib/runtime/{agentwire-action.ts → agui-action.ts} +13 -8
- package/src/lib/runtime/copilot-runtime.ts +11 -2
- package/src/lib/runtime/remote-actions.ts +5 -2
- package/dist/chunk-F4NU7EVL.mjs.map +0 -1
- /package/dist/{chunk-KTTUYDBP.mjs.map → chunk-BMA7V5T7.mjs.map} +0 -0
- /package/dist/{chunk-WUBMXNOG.mjs.map → chunk-C7XHY7LW.mjs.map} +0 -0
- /package/dist/{chunk-JJBN24EK.mjs.map → chunk-T2RKWYXN.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.8.14-next.
|
|
12
|
+
"version": "1.8.14-next.3",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"rxjs": "^7.8.1",
|
|
65
65
|
"type-graphql": "2.0.0-rc.1",
|
|
66
66
|
"zod": "^3.23.3",
|
|
67
|
-
"@copilotkit/shared": "1.8.14-next.
|
|
67
|
+
"@copilotkit/shared": "1.8.14-next.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@ag-ui/client": ">=0.0.28",
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
import telemetry from "../../lib/telemetry-client";
|
|
54
54
|
import { randomId } from "@copilotkit/shared";
|
|
55
55
|
import { AgentsResponse } from "../types/agents-response.type";
|
|
56
|
+
import { LangGraphEventTypes } from "../../agents/langgraph/events";
|
|
56
57
|
|
|
57
58
|
const invokeGuardrails = async ({
|
|
58
59
|
baseUrl,
|
|
@@ -263,6 +264,19 @@ export class CopilotResolver {
|
|
|
263
264
|
return;
|
|
264
265
|
}
|
|
265
266
|
switch (event.name) {
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
case LangGraphEventTypes.OnInterrupt:
|
|
269
|
+
push(
|
|
270
|
+
plainToInstance(LangGraphInterruptEvent, {
|
|
271
|
+
// @ts-ignore
|
|
272
|
+
type: event.type,
|
|
273
|
+
// @ts-ignore
|
|
274
|
+
name: RuntimeMetaEventName.LangGraphInterruptEvent,
|
|
275
|
+
// @ts-ignore
|
|
276
|
+
value: event.value,
|
|
277
|
+
}),
|
|
278
|
+
);
|
|
279
|
+
break;
|
|
266
280
|
case RuntimeMetaEventName.LangGraphInterruptEvent:
|
|
267
281
|
push(
|
|
268
282
|
plainToInstance(LangGraphInterruptEvent, {
|
|
@@ -7,24 +7,27 @@ import telemetry from "../telemetry-client";
|
|
|
7
7
|
import { RemoteAgentHandlerParams } from "./remote-actions";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
AssistantMessage as
|
|
11
|
-
Message as
|
|
10
|
+
AssistantMessage as AGUIAssistantMessage,
|
|
11
|
+
Message as AGUIMessage,
|
|
12
12
|
ToolCall,
|
|
13
13
|
} from "@ag-ui/client";
|
|
14
14
|
|
|
15
15
|
import { AbstractAgent } from "@ag-ui/client";
|
|
16
16
|
import { parseJson } from "@copilotkit/shared";
|
|
17
|
+
import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
|
|
17
18
|
|
|
18
|
-
export function
|
|
19
|
+
export function constructAGUIRemoteAction({
|
|
19
20
|
logger,
|
|
20
21
|
messages,
|
|
21
22
|
agentStates,
|
|
22
23
|
agent,
|
|
24
|
+
metaEvents,
|
|
23
25
|
}: {
|
|
24
26
|
logger: Logger;
|
|
25
27
|
messages: Message[];
|
|
26
28
|
agentStates?: AgentStateInput[];
|
|
27
29
|
agent: AbstractAgent;
|
|
30
|
+
metaEvents?: MetaEventInput[];
|
|
28
31
|
}) {
|
|
29
32
|
const action = {
|
|
30
33
|
name: agent.agentId,
|
|
@@ -37,7 +40,7 @@ export function constructAgentWireRemoteAction({
|
|
|
37
40
|
}: RemoteAgentHandlerParams): Promise<Observable<RuntimeEvent>> => {
|
|
38
41
|
logger.debug({ actionName: agent.agentId }, "Executing remote agent");
|
|
39
42
|
|
|
40
|
-
const agentWireMessages =
|
|
43
|
+
const agentWireMessages = convertMessagesToAGUIMessage(messages);
|
|
41
44
|
agent.messages = agentWireMessages;
|
|
42
45
|
agent.threadId = threadId;
|
|
43
46
|
|
|
@@ -66,14 +69,16 @@ export function constructAgentWireRemoteAction({
|
|
|
66
69
|
|
|
67
70
|
return agent.legacy_to_be_removed_runAgentBridged({
|
|
68
71
|
tools,
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
resume: metaEvents[0]?.response,
|
|
69
74
|
}) as Observable<RuntimeEvent>;
|
|
70
75
|
},
|
|
71
76
|
};
|
|
72
77
|
return [action];
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
export function
|
|
76
|
-
const result:
|
|
80
|
+
export function convertMessagesToAGUIMessage(messages: Message[]): AGUIMessage[] {
|
|
81
|
+
const result: AGUIMessage[] = [];
|
|
77
82
|
|
|
78
83
|
for (const message of messages) {
|
|
79
84
|
if (message.isTextMessage()) {
|
|
@@ -93,9 +98,9 @@ export function convertMessagesToAgentWire(messages: Message[]): AgentWireMessag
|
|
|
93
98
|
};
|
|
94
99
|
|
|
95
100
|
if (message.parentMessageId && result.some((m) => m.id === message.parentMessageId)) {
|
|
96
|
-
const parentMessage:
|
|
101
|
+
const parentMessage: AGUIAssistantMessage | undefined = result.find(
|
|
97
102
|
(m) => m.id === message.parentMessageId,
|
|
98
|
-
) as
|
|
103
|
+
) as AGUIAssistantMessage;
|
|
99
104
|
if (parentMessage.toolCalls === undefined) {
|
|
100
105
|
parentMessage.toolCalls = [];
|
|
101
106
|
}
|
|
@@ -193,7 +193,16 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
|
|
|
193
193
|
langserve?: RemoteChainParameters[];
|
|
194
194
|
|
|
195
195
|
/*
|
|
196
|
-
* A map of agent names to
|
|
196
|
+
* A map of agent names to AGUI agents.
|
|
197
|
+
* Example agent config:
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { AbstractAgent } from "@ag-ui/client";
|
|
200
|
+
* // ...
|
|
201
|
+
* agents: {
|
|
202
|
+
* "support": new CustomerSupportAgent(),
|
|
203
|
+
* "technical": new TechnicalAgent()
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
197
206
|
*/
|
|
198
207
|
agents?: Record<string, AbstractAgent>;
|
|
199
208
|
|
|
@@ -416,7 +425,6 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
416
425
|
|
|
417
426
|
return newMessages;
|
|
418
427
|
}
|
|
419
|
-
// --- MCP Instruction Injection Method ---
|
|
420
428
|
|
|
421
429
|
async processRuntimeRequest(request: CopilotRuntimeRequest): Promise<CopilotRuntimeResponse> {
|
|
422
430
|
const {
|
|
@@ -1122,6 +1130,7 @@ please use an LLM adapter instead.`,
|
|
|
1122
1130
|
agentStates,
|
|
1123
1131
|
frontendUrl: url,
|
|
1124
1132
|
agents: this.agents,
|
|
1133
|
+
metaEvents: request.metaEvents,
|
|
1125
1134
|
});
|
|
1126
1135
|
|
|
1127
1136
|
const configuredActions =
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "@copilotkit/shared";
|
|
19
19
|
import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
|
|
20
20
|
import { AbstractAgent } from "@ag-ui/client";
|
|
21
|
-
import {
|
|
21
|
+
import { constructAGUIRemoteAction } from "./agui-action";
|
|
22
22
|
|
|
23
23
|
export type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
|
|
24
24
|
|
|
@@ -130,6 +130,7 @@ export async function setupRemoteActions({
|
|
|
130
130
|
agentStates,
|
|
131
131
|
frontendUrl,
|
|
132
132
|
agents,
|
|
133
|
+
metaEvents,
|
|
133
134
|
}: {
|
|
134
135
|
remoteEndpointDefinitions: EndpointDefinition[];
|
|
135
136
|
graphqlContext: GraphQLContext;
|
|
@@ -137,6 +138,7 @@ export async function setupRemoteActions({
|
|
|
137
138
|
agentStates?: AgentStateInput[];
|
|
138
139
|
frontendUrl?: string;
|
|
139
140
|
agents: Record<string, AbstractAgent>;
|
|
141
|
+
metaEvents?: MetaEventInput[];
|
|
140
142
|
}): Promise<Action[]> {
|
|
141
143
|
const logger = graphqlContext.logger.child({ component: "remote-actions.fetchRemoteActions" });
|
|
142
144
|
logger.debug({ remoteEndpointDefinitions }, "Fetching from remote endpoints");
|
|
@@ -196,11 +198,12 @@ export async function setupRemoteActions({
|
|
|
196
198
|
}
|
|
197
199
|
|
|
198
200
|
result.push(
|
|
199
|
-
|
|
201
|
+
constructAGUIRemoteAction({
|
|
200
202
|
logger,
|
|
201
203
|
messages,
|
|
202
204
|
agentStates,
|
|
203
205
|
agent: agent,
|
|
206
|
+
metaEvents,
|
|
204
207
|
}),
|
|
205
208
|
);
|
|
206
209
|
}
|