@copilotkit/runtime 1.10.5-next.1 → 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.
Files changed (41) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/{chunk-C56AVUZI.mjs → chunk-COGFQ4V4.mjs} +2 -2
  3. package/dist/{chunk-T4NLPBCY.mjs → chunk-M65Z27MR.mjs} +2 -2
  4. package/dist/{chunk-FOXQPOXW.mjs → chunk-NFB4H6NT.mjs} +30 -11
  5. package/dist/chunk-NFB4H6NT.mjs.map +1 -0
  6. package/dist/{chunk-CX4GADTM.mjs → chunk-NNBTOZO3.mjs} +2 -2
  7. package/dist/{chunk-H6QUY5ZQ.mjs → chunk-Y5BKTUH2.mjs} +6 -2
  8. package/dist/{chunk-H6QUY5ZQ.mjs.map → chunk-Y5BKTUH2.mjs.map} +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +33 -10
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +5 -5
  13. package/dist/lib/index.d.ts +1 -1
  14. package/dist/lib/index.js +33 -10
  15. package/dist/lib/index.js.map +1 -1
  16. package/dist/lib/index.mjs +5 -5
  17. package/dist/lib/integrations/index.d.ts +2 -2
  18. package/dist/lib/integrations/index.js +10 -10
  19. package/dist/lib/integrations/index.js.map +1 -1
  20. package/dist/lib/integrations/index.mjs +4 -4
  21. package/dist/lib/integrations/nest/index.d.ts +1 -1
  22. package/dist/lib/integrations/nest/index.js +10 -10
  23. package/dist/lib/integrations/nest/index.js.map +1 -1
  24. package/dist/lib/integrations/nest/index.mjs +2 -2
  25. package/dist/lib/integrations/node-express/index.d.ts +1 -1
  26. package/dist/lib/integrations/node-express/index.js +10 -10
  27. package/dist/lib/integrations/node-express/index.js.map +1 -1
  28. package/dist/lib/integrations/node-express/index.mjs +2 -2
  29. package/dist/lib/integrations/node-http/index.d.ts +1 -1
  30. package/dist/lib/integrations/node-http/index.js +10 -10
  31. package/dist/lib/integrations/node-http/index.js.map +1 -1
  32. package/dist/lib/integrations/node-http/index.mjs +1 -1
  33. package/dist/{shared-35015e40.d.ts → shared-0a7346ce.d.ts} +10 -0
  34. package/package.json +11 -11
  35. package/src/lib/runtime/agui-action.ts +7 -0
  36. package/src/lib/runtime/copilot-runtime.ts +25 -0
  37. package/src/lib/runtime/langgraph/langgraph-agent.ts +1 -0
  38. package/dist/chunk-FOXQPOXW.mjs.map +0 -1
  39. /package/dist/{chunk-C56AVUZI.mjs.map → chunk-COGFQ4V4.mjs.map} +0 -0
  40. /package/dist/{chunk-T4NLPBCY.mjs.map → chunk-M65Z27MR.mjs.map} +0 -0
  41. /package/dist/{chunk-CX4GADTM.mjs.map → chunk-NNBTOZO3.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-FOXQPOXW.mjs";
3
+ } from "../../../chunk-NFB4H6NT.mjs";
4
4
  import "../../../chunk-SHBDMA63.mjs";
5
5
  import "../../../chunk-F7IANE7Z.mjs";
6
6
  import "../../../chunk-XWBDEXDA.mjs";
@@ -246,6 +246,14 @@ interface OnAfterRequestOptions {
246
246
  url?: string;
247
247
  }
248
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>;
249
257
  interface Middleware {
250
258
  /**
251
259
  * A function that is called before the request is processed.
@@ -362,6 +370,7 @@ interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
362
370
  * ```
363
371
  */
364
372
  onError?: CopilotErrorHandler;
373
+ onStopGeneration?: OnStopGenerationHandler;
365
374
  }
366
375
  declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
367
376
  actions: ActionsConfiguration<T>;
@@ -370,6 +379,7 @@ declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
370
379
  private langserve;
371
380
  private onBeforeRequest?;
372
381
  private onAfterRequest?;
382
+ private onStopGeneration?;
373
383
  private delegateAgentProcessingToServiceAdapter;
374
384
  private observability?;
375
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.1",
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.37",
41
- "@ag-ui/core": "^0.0.37",
42
- "@ag-ui/encoder": "^0.0.37",
43
- "@ag-ui/langgraph": "^0.0.13",
44
- "@ag-ui/proto": "^0.0.37",
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.1"
70
+ "@copilotkit/shared": "1.10.5-next.10"
71
71
  },
72
72
  "peerDependencies": {
73
- "@ag-ui/client": ">=0.0.37",
74
- "@ag-ui/core": ">=0.0.37",
75
- "@ag-ui/encoder": ">=0.0.37",
76
- "@ag-ui/proto": ">=0.0.37"
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",
@@ -48,6 +48,13 @@ export function constructAGUIRemoteAction({
48
48
  actionInputsWithoutAgents,
49
49
  threadId,
50
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
+ );
51
58
  logger.debug({ actionName: agent.agentId }, "Executing remote agent");
52
59
 
53
60
  const agentWireMessages = convertMessagesToAGUIMessage(messages);
@@ -144,6 +144,15 @@ interface OnAfterRequestOptions {
144
144
 
145
145
  type OnAfterRequestHandler = (options: OnAfterRequestOptions) => void | Promise<void>;
146
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
+
147
156
  interface Middleware {
148
157
  /**
149
158
  * A function that is called before the request is processed.
@@ -301,6 +310,8 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
301
310
  * ```
302
311
  */
303
312
  onError?: CopilotErrorHandler;
313
+
314
+ onStopGeneration?: OnStopGenerationHandler;
304
315
  }
305
316
 
306
317
  export class CopilotRuntime<const T extends Parameter[] | [] = []> {
@@ -310,6 +321,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
310
321
  private langserve: Promise<Action<any>>[] = [];
311
322
  private onBeforeRequest?: OnBeforeRequestHandler;
312
323
  private onAfterRequest?: OnAfterRequestHandler;
324
+ private onStopGeneration?: OnStopGenerationHandler;
313
325
  private delegateAgentProcessingToServiceAdapter: boolean;
314
326
  private observability?: CopilotObservabilityConfig;
315
327
  private availableAgents: Pick<AgentWithEndpoint, "name" | "id">[];
@@ -359,6 +371,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
359
371
 
360
372
  this.onBeforeRequest = params?.middleware?.onBeforeRequest;
361
373
  this.onAfterRequest = params?.middleware?.onAfterRequest;
374
+ this.onStopGeneration = params?.onStopGeneration;
362
375
  this.delegateAgentProcessingToServiceAdapter =
363
376
  params?.delegateAgentProcessingToServiceAdapter || false;
364
377
  this.observability = params?.observability_c;
@@ -488,6 +501,18 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
488
501
  publicApiKey,
489
502
  context,
490
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
+ );
491
516
 
492
517
  const eventSource = new RuntimeEventSource({
493
518
  errorHandler: async (error, context) => {
@@ -221,6 +221,7 @@ export class LangGraphAgent extends AGUILangGraphAgent {
221
221
  config: schemaKeys.config,
222
222
  input: schemaKeys.input ? [...schemaKeys.input, ...CONSTANT_KEYS] : null,
223
223
  output: schemaKeys.output ? [...schemaKeys.output, ...CONSTANT_KEYS] : null,
224
+ context: schemaKeys.context ? [...schemaKeys.context, ...CONSTANT_KEYS] : null,
224
225
  };
225
226
  }
226
227
  }