@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.
Files changed (40) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{chunk-MSBLW6TU.mjs → chunk-34Z6UB6N.mjs} +2 -2
  3. package/dist/{chunk-F2DLMRBK.mjs → chunk-L57B2EB7.mjs} +2 -2
  4. package/dist/{chunk-2ICQTCH3.mjs → chunk-R3Z3JTED.mjs} +29 -28
  5. package/dist/chunk-R3Z3JTED.mjs.map +1 -0
  6. package/dist/{chunk-PRF2YJTA.mjs → chunk-WOYBKZKY.mjs} +2 -2
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.js +28 -27
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +4 -4
  11. package/dist/lib/index.d.ts +2 -2
  12. package/dist/lib/index.js +28 -27
  13. package/dist/lib/index.js.map +1 -1
  14. package/dist/lib/index.mjs +4 -4
  15. package/dist/lib/integrations/index.d.ts +3 -3
  16. package/dist/lib/integrations/index.js +6 -6
  17. package/dist/lib/integrations/index.js.map +1 -1
  18. package/dist/lib/integrations/index.mjs +4 -4
  19. package/dist/lib/integrations/nest/index.d.ts +2 -2
  20. package/dist/lib/integrations/nest/index.js +6 -6
  21. package/dist/lib/integrations/nest/index.js.map +1 -1
  22. package/dist/lib/integrations/nest/index.mjs +2 -2
  23. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  24. package/dist/lib/integrations/node-express/index.js +6 -6
  25. package/dist/lib/integrations/node-express/index.js.map +1 -1
  26. package/dist/lib/integrations/node-express/index.mjs +2 -2
  27. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  28. package/dist/lib/integrations/node-http/index.js +6 -6
  29. package/dist/lib/integrations/node-http/index.js.map +1 -1
  30. package/dist/lib/integrations/node-http/index.mjs +1 -1
  31. package/dist/{shared-a7b30781.d.ts → shared-ede87417.d.ts} +1 -1
  32. package/package.json +7 -7
  33. package/src/lib/runtime/agentwire-action.ts +7 -9
  34. package/src/lib/runtime/copilot-runtime.ts +1 -1
  35. package/src/lib/runtime/remote-actions.ts +1 -1
  36. package/src/lib/runtime/remote-lg-action.ts +37 -24
  37. package/dist/chunk-2ICQTCH3.mjs.map +0 -1
  38. /package/dist/{chunk-MSBLW6TU.mjs.map → chunk-34Z6UB6N.mjs.map} +0 -0
  39. /package/dist/{chunk-F2DLMRBK.mjs.map → chunk-L57B2EB7.mjs.map} +0 -0
  40. /package/dist/{chunk-PRF2YJTA.mjs.map → chunk-WOYBKZKY.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-2ICQTCH3.mjs";
3
+ } from "../../../chunk-R3Z3JTED.mjs";
4
4
  import "../../../chunk-EY6RUVB7.mjs";
5
5
  import "../../../chunk-5BIEM2UU.mjs";
6
6
  import "../../../chunk-SHBDMA63.mjs";
@@ -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 '@agentwire/client';
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.0",
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
- "@agentwire/client": "0.0.26",
40
- "@agentwire/proto": "0.0.26",
41
- "@agentwire/core": "0.0.26",
42
- "@agentwire/encoder": "0.0.26",
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.36",
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.0"
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
- } from "@agentwire/client";
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 "@agentwire/client";
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 "@agentwire/client";
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 { AssistantGraph, Client as LangGraphClient, GraphSchema } from "@langchain/langgraph-sdk";
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: RunsStreamPayload = {
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 (const chunk of streamResponse) {
303
- if (!["events", "values", "error", "updates"].includes(chunk.event)) continue;
306
+ for await (let streamResponseChunk of streamResponse) {
307
+ if (!["events", "values", "error", "updates"].includes(streamResponseChunk.event)) continue;
304
308
 
305
- if (chunk.event === "error") {
306
- throw new Error(`Error event thrown: ${chunk.data.message}`);
309
+ if (streamResponseChunk.event === "error") {
310
+ throw new Error(`Error event thrown: ${streamResponseChunk.data.message}`);
307
311
  }
308
312
 
309
- const interruptEvents = chunk.data?.__interrupt__;
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 (chunk.event === "updates") continue;
354
+ if (streamResponseChunk.event === "updates") continue;
341
355
 
342
- if (chunk.event === "values") {
356
+ if (streamResponseChunk.event === "values") {
343
357
  latestStateValues = chunk.data;
344
358
  continue;
345
359
  }
346
360
 
347
- const event = chunk.data;
348
- const currentNodeName = event.metadata.langgraph_node;
349
- const eventType = event.event;
350
- const runId = event.metadata.run_id;
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 = event.metadata;
353
-
354
- if (event.data?.output?.model != null && event.data?.output?.model != "") {
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
- event.name === CustomEventNames.CopilotKitExit);
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
- event.name === CustomEventNames.CopilotKitManuallyEmitIntermediateState;
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 = event.data;
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(event);
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(event) + "\n");
475
+ emit(JSON.stringify(chunkData) + "\n");
463
476
  }
464
477
 
465
478
  state = await client.threads.getState(threadId);