@copilotkit/runtime 1.8.10-next.0 → 1.8.10-next.2
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 +13 -0
- package/dist/{chunk-MSBLW6TU.mjs → chunk-34Z6UB6N.mjs} +2 -2
- package/dist/{chunk-F2DLMRBK.mjs → chunk-L57B2EB7.mjs} +2 -2
- package/dist/{chunk-2ICQTCH3.mjs → chunk-R3Z3JTED.mjs} +29 -28
- package/dist/chunk-R3Z3JTED.mjs.map +1 -0
- package/dist/{chunk-PRF2YJTA.mjs → chunk-WOYBKZKY.mjs} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +28 -27
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +6 -6
- 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 +2 -2
- package/dist/lib/integrations/nest/index.js +6 -6
- 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 +2 -2
- package/dist/lib/integrations/node-express/index.js +6 -6
- 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 +2 -2
- package/dist/lib/integrations/node-http/index.js +6 -6
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/{shared-a7b30781.d.ts → shared-ede87417.d.ts} +1 -1
- package/package.json +7 -7
- package/src/lib/runtime/agentwire-action.ts +7 -9
- package/src/lib/runtime/copilot-runtime.ts +1 -1
- package/src/lib/runtime/remote-actions.ts +1 -1
- package/src/lib/runtime/remote-lg-action.ts +37 -24
- package/dist/chunk-2ICQTCH3.mjs.map +0 -1
- /package/dist/{chunk-MSBLW6TU.mjs.map → chunk-34Z6UB6N.mjs.map} +0 -0
- /package/dist/{chunk-F2DLMRBK.mjs.map → chunk-L57B2EB7.mjs.map} +0 -0
- /package/dist/{chunk-PRF2YJTA.mjs.map → chunk-WOYBKZKY.mjs.map} +0 -0
|
@@ -5,7 +5,7 @@ import { Parameter, Action } from '@copilotkit/shared';
|
|
|
5
5
|
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-4a5c9217.js';
|
|
6
6
|
import { M as MessageInput, a as Message } from './index-d4614f9b.js';
|
|
7
7
|
import { CopilotCloudOptions } from './lib/cloud/index.js';
|
|
8
|
-
import { AbstractAgent } from '@
|
|
8
|
+
import { AbstractAgent } from '@ag-ui/client';
|
|
9
9
|
|
|
10
10
|
declare enum MetaEventName {
|
|
11
11
|
LangGraphInterruptEvent = "LangGraphInterruptEvent",
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.8.10-next.
|
|
12
|
+
"version": "1.8.10-next.2",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"tsconfig": "1.4.6"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
39
|
+
"@ag-ui/client": "^0.0.27",
|
|
40
|
+
"@ag-ui/core": "^0.0.27",
|
|
41
|
+
"@ag-ui/encoder": "^0.0.27",
|
|
42
|
+
"@ag-ui/proto": "^0.0.27",
|
|
43
43
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
44
44
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
45
45
|
"@langchain/community": "^0.3.29",
|
|
46
46
|
"@langchain/core": "^0.3.38",
|
|
47
47
|
"@langchain/google-gauth": "^0.1.0",
|
|
48
|
-
"@langchain/langgraph-sdk": "^0.0.
|
|
48
|
+
"@langchain/langgraph-sdk": "^0.0.70",
|
|
49
49
|
"@langchain/openai": "^0.4.2",
|
|
50
50
|
"class-transformer": "^0.5.1",
|
|
51
51
|
"class-validator": "^0.14.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"rxjs": "^7.8.1",
|
|
64
64
|
"type-graphql": "2.0.0-rc.1",
|
|
65
65
|
"zod": "^3.23.3",
|
|
66
|
-
"@copilotkit/shared": "1.8.10-next.
|
|
66
|
+
"@copilotkit/shared": "1.8.10-next.2"
|
|
67
67
|
},
|
|
68
68
|
"keywords": [
|
|
69
69
|
"copilotkit",
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { CopilotKitEndpoint, RemoteAgentHandlerParams } from "./remote-actions";
|
|
3
|
-
import { GraphQLContext } from "../integrations";
|
|
4
1
|
import { Logger } from "pino";
|
|
5
|
-
import { Message } from "../../graphql/types/converted";
|
|
6
|
-
import { AgentStateInput } from "../../graphql/inputs/agent-state.input";
|
|
7
2
|
import { Observable } from "rxjs";
|
|
3
|
+
import { AgentStateInput } from "../../graphql/inputs/agent-state.input";
|
|
4
|
+
import { Message } from "../../graphql/types/converted";
|
|
8
5
|
import { RuntimeEvent } from "../../service-adapters/events";
|
|
9
6
|
import telemetry from "../telemetry-client";
|
|
7
|
+
import { RemoteAgentHandlerParams } from "./remote-actions";
|
|
10
8
|
|
|
11
|
-
import { ToolCall } from "@agentwire/client";
|
|
12
9
|
import {
|
|
13
|
-
Message as AgentWireMessage,
|
|
14
10
|
AssistantMessage as AgentWireAssistantMessage,
|
|
15
|
-
|
|
11
|
+
Message as AgentWireMessage,
|
|
12
|
+
ToolCall,
|
|
13
|
+
} from "@ag-ui/client";
|
|
16
14
|
|
|
15
|
+
import { AbstractAgent } from "@ag-ui/client";
|
|
17
16
|
import { parseJson } from "@copilotkit/shared";
|
|
18
|
-
import { AbstractAgent } from "@agentwire/client";
|
|
19
17
|
|
|
20
18
|
export function constructAgentWireRemoteAction({
|
|
21
19
|
logger,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
LLMResponseData,
|
|
68
68
|
LLMErrorData,
|
|
69
69
|
} from "../observability";
|
|
70
|
-
import { AbstractAgent } from "@
|
|
70
|
+
import { AbstractAgent } from "@ag-ui/client";
|
|
71
71
|
import { MessageRole } from "../../graphql/types/enums";
|
|
72
72
|
|
|
73
73
|
// +++ MCP Imports +++
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
CopilotKitError,
|
|
18
18
|
} from "@copilotkit/shared";
|
|
19
19
|
import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
|
|
20
|
-
import { AbstractAgent } from "@
|
|
20
|
+
import { AbstractAgent } from "@ag-ui/client";
|
|
21
21
|
import { constructAgentWireRemoteAction } from "./agentwire-action";
|
|
22
22
|
|
|
23
23
|
export type EndpointDefinition = CopilotKitEndpoint | LangGraphPlatformEndpoint;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Client as LangGraphClient,
|
|
3
|
+
EventsStreamEvent,
|
|
4
|
+
GraphSchema,
|
|
5
|
+
StreamMode,
|
|
6
|
+
} from "@langchain/langgraph-sdk";
|
|
2
7
|
import { createHash } from "node:crypto";
|
|
3
8
|
import { isValidUUID, randomUUID } from "@copilotkit/shared";
|
|
4
9
|
import { parse as parsePartialJson } from "partial-json";
|
|
@@ -12,7 +17,6 @@ import { CustomEventNames, LangGraphEventTypes } from "../../agents/langgraph/ev
|
|
|
12
17
|
import telemetry from "../telemetry-client";
|
|
13
18
|
import { MetaEventInput } from "../../graphql/inputs/meta-event.input";
|
|
14
19
|
import { MetaEventName } from "../../graphql/types/meta-events.type";
|
|
15
|
-
import { RunsStreamPayload } from "@langchain/langgraph-sdk/dist/types";
|
|
16
20
|
import { parseJson, CopilotKitMisuseError } from "@copilotkit/shared";
|
|
17
21
|
import { RemoveMessage } from "@langchain/core/messages";
|
|
18
22
|
|
|
@@ -184,9 +188,9 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
184
188
|
|
|
185
189
|
const streamInput = mode === "start" ? state : null;
|
|
186
190
|
|
|
187
|
-
const payload
|
|
191
|
+
const payload = {
|
|
188
192
|
input: streamInput,
|
|
189
|
-
streamMode: ["events", "values", "updates"],
|
|
193
|
+
streamMode: ["events", "values", "updates"] satisfies StreamMode[],
|
|
190
194
|
command: undefined,
|
|
191
195
|
};
|
|
192
196
|
|
|
@@ -299,14 +303,24 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
299
303
|
telemetry.capture("oss.runtime.agent_execution_stream_started", {
|
|
300
304
|
hashedLgcKey: streamInfo.hashedLgcKey,
|
|
301
305
|
});
|
|
302
|
-
for await (
|
|
303
|
-
if (!["events", "values", "error", "updates"].includes(
|
|
306
|
+
for await (let streamResponseChunk of streamResponse) {
|
|
307
|
+
if (!["events", "values", "error", "updates"].includes(streamResponseChunk.event)) continue;
|
|
304
308
|
|
|
305
|
-
if (
|
|
306
|
-
throw new Error(`Error event thrown: ${
|
|
309
|
+
if (streamResponseChunk.event === "error") {
|
|
310
|
+
throw new Error(`Error event thrown: ${streamResponseChunk.data.message}`);
|
|
307
311
|
}
|
|
308
312
|
|
|
309
|
-
|
|
313
|
+
// Force event type, as data is not properly defined on the LG side.
|
|
314
|
+
type EventsChunkData = {
|
|
315
|
+
__interrupt__?: any;
|
|
316
|
+
metadata: Record<string, any>;
|
|
317
|
+
event: string;
|
|
318
|
+
data: any;
|
|
319
|
+
[key: string]: unknown;
|
|
320
|
+
};
|
|
321
|
+
const chunk = streamResponseChunk as EventsStreamEvent & { data: EventsChunkData };
|
|
322
|
+
|
|
323
|
+
const interruptEvents = chunk.data.__interrupt__;
|
|
310
324
|
if (interruptEvents?.length) {
|
|
311
325
|
activeInterruptEvent = true;
|
|
312
326
|
const interruptValue = interruptEvents?.[0].value;
|
|
@@ -337,22 +351,21 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
337
351
|
}
|
|
338
352
|
continue;
|
|
339
353
|
}
|
|
340
|
-
if (
|
|
354
|
+
if (streamResponseChunk.event === "updates") continue;
|
|
341
355
|
|
|
342
|
-
if (
|
|
356
|
+
if (streamResponseChunk.event === "values") {
|
|
343
357
|
latestStateValues = chunk.data;
|
|
344
358
|
continue;
|
|
345
359
|
}
|
|
346
360
|
|
|
347
|
-
const
|
|
348
|
-
const currentNodeName =
|
|
349
|
-
const eventType =
|
|
350
|
-
const runId =
|
|
361
|
+
const chunkData = chunk.data;
|
|
362
|
+
const currentNodeName = chunkData.metadata.langgraph_node;
|
|
363
|
+
const eventType = chunkData.event;
|
|
364
|
+
const runId = chunkData.metadata.run_id;
|
|
351
365
|
externalRunId = runId;
|
|
352
|
-
const metadata =
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
streamInfo.provider = event.data?.output?.model;
|
|
366
|
+
const metadata = chunkData.metadata;
|
|
367
|
+
if (chunkData.data?.output?.model != null && chunkData.data?.output?.model != "") {
|
|
368
|
+
streamInfo.provider = chunkData.data?.output?.model;
|
|
356
369
|
}
|
|
357
370
|
if (metadata.langgraph_host != null && metadata.langgraph_host != "") {
|
|
358
371
|
streamInfo.langGraphHost = metadata.langgraph_host;
|
|
@@ -364,12 +377,12 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
364
377
|
shouldExit =
|
|
365
378
|
shouldExit ||
|
|
366
379
|
(eventType === LangGraphEventTypes.OnCustomEvent &&
|
|
367
|
-
|
|
380
|
+
chunkData.name === CustomEventNames.CopilotKitExit);
|
|
368
381
|
|
|
369
382
|
const emitIntermediateState = metadata["copilotkit:emit-intermediate-state"];
|
|
370
383
|
const manuallyEmitIntermediateState =
|
|
371
384
|
eventType === LangGraphEventTypes.OnCustomEvent &&
|
|
372
|
-
|
|
385
|
+
chunkData.name === CustomEventNames.CopilotKitManuallyEmitIntermediateState;
|
|
373
386
|
|
|
374
387
|
const exitingNode =
|
|
375
388
|
nodeName === currentNodeName && eventType === LangGraphEventTypes.OnChainEnd;
|
|
@@ -393,7 +406,7 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
393
406
|
|
|
394
407
|
if (manuallyEmitIntermediateState) {
|
|
395
408
|
// See manuallyEmittedState for explanation
|
|
396
|
-
manuallyEmittedState =
|
|
409
|
+
manuallyEmittedState = chunkData.data;
|
|
397
410
|
emit(
|
|
398
411
|
getStateSyncEvent({
|
|
399
412
|
threadId,
|
|
@@ -419,7 +432,7 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
419
432
|
}
|
|
420
433
|
|
|
421
434
|
if (emitIntermediateState && eventType === LangGraphEventTypes.OnChatModelStream) {
|
|
422
|
-
streamingStateExtractor.bufferToolCalls(
|
|
435
|
+
streamingStateExtractor.bufferToolCalls(chunkData);
|
|
423
436
|
}
|
|
424
437
|
|
|
425
438
|
if (emitIntermediateStateUntilEnd !== null) {
|
|
@@ -459,7 +472,7 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
459
472
|
);
|
|
460
473
|
}
|
|
461
474
|
|
|
462
|
-
emit(JSON.stringify(
|
|
475
|
+
emit(JSON.stringify(chunkData) + "\n");
|
|
463
476
|
}
|
|
464
477
|
|
|
465
478
|
state = await client.threads.getState(threadId);
|