@copilotkit/runtime 1.10.0-next.9 → 1.10.0

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 (32) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/{chunk-YU35HUT7.mjs → chunk-IP22MV6G.mjs} +2 -2
  3. package/dist/{chunk-253F6PVG.mjs → chunk-ODQCOZ55.mjs} +2 -2
  4. package/dist/{chunk-4GZZVKJJ.mjs → chunk-QBCAKCOM.mjs} +2 -2
  5. package/dist/{chunk-UWHAKVQV.mjs → chunk-RODRL3FY.mjs} +30 -24
  6. package/dist/chunk-RODRL3FY.mjs.map +1 -0
  7. package/dist/{chunk-N3L3KQIA.mjs → chunk-SNCAMGEK.mjs} +2 -2
  8. package/dist/index.js +40 -34
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +5 -5
  11. package/dist/lib/index.js +40 -34
  12. package/dist/lib/index.js.map +1 -1
  13. package/dist/lib/index.mjs +5 -5
  14. package/dist/lib/integrations/index.js +2 -2
  15. package/dist/lib/integrations/index.js.map +1 -1
  16. package/dist/lib/integrations/index.mjs +4 -4
  17. package/dist/lib/integrations/nest/index.js +2 -2
  18. package/dist/lib/integrations/nest/index.js.map +1 -1
  19. package/dist/lib/integrations/nest/index.mjs +2 -2
  20. package/dist/lib/integrations/node-express/index.js +2 -2
  21. package/dist/lib/integrations/node-express/index.js.map +1 -1
  22. package/dist/lib/integrations/node-express/index.mjs +2 -2
  23. package/dist/lib/integrations/node-http/index.js +2 -2
  24. package/dist/lib/integrations/node-http/index.js.map +1 -1
  25. package/dist/lib/integrations/node-http/index.mjs +1 -1
  26. package/package.json +3 -3
  27. package/src/lib/runtime/agui-action.ts +15 -6
  28. package/dist/chunk-UWHAKVQV.mjs.map +0 -1
  29. /package/dist/{chunk-YU35HUT7.mjs.map → chunk-IP22MV6G.mjs.map} +0 -0
  30. /package/dist/{chunk-253F6PVG.mjs.map → chunk-ODQCOZ55.mjs.map} +0 -0
  31. /package/dist/{chunk-4GZZVKJJ.mjs.map → chunk-QBCAKCOM.mjs.map} +0 -0
  32. /package/dist/{chunk-N3L3KQIA.mjs.map → chunk-SNCAMGEK.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -2,18 +2,18 @@ import {
2
2
  CustomEventNames,
3
3
  LangGraphAgent,
4
4
  LangGraphHttpAgent
5
- } from "./chunk-253F6PVG.mjs";
5
+ } from "./chunk-ODQCOZ55.mjs";
6
6
  import {
7
7
  config,
8
8
  copilotRuntimeNextJSAppRouterEndpoint,
9
9
  copilotRuntimeNextJSPagesRouterEndpoint
10
- } from "./chunk-N3L3KQIA.mjs";
10
+ } from "./chunk-SNCAMGEK.mjs";
11
11
  import {
12
12
  copilotRuntimeNestEndpoint
13
- } from "./chunk-4GZZVKJJ.mjs";
13
+ } from "./chunk-QBCAKCOM.mjs";
14
14
  import {
15
15
  copilotRuntimeNodeExpressEndpoint
16
- } from "./chunk-YU35HUT7.mjs";
16
+ } from "./chunk-IP22MV6G.mjs";
17
17
  import {
18
18
  CopilotRuntime,
19
19
  addCustomHeaderPlugin,
@@ -29,7 +29,7 @@ import {
29
29
  getCommonConfig,
30
30
  langGraphPlatformEndpoint,
31
31
  resolveEndpointType
32
- } from "./chunk-UWHAKVQV.mjs";
32
+ } from "./chunk-RODRL3FY.mjs";
33
33
  import "./chunk-SHBDMA63.mjs";
34
34
  import {
35
35
  AnthropicAdapter,
package/dist/lib/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.10.0-next.9",
47
+ version: "1.10.0",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -85,7 +85,7 @@ var require_package = __commonJS({
85
85
  "@ag-ui/client": "0.0.35",
86
86
  "@ag-ui/core": "0.0.35",
87
87
  "@ag-ui/encoder": "0.0.35",
88
- "@ag-ui/langgraph": "0.0.7",
88
+ "@ag-ui/langgraph": "0.0.8",
89
89
  "@ag-ui/proto": "0.0.35",
90
90
  "@anthropic-ai/sdk": "^0.57.0",
91
91
  "@copilotkit/shared": "workspace:*",
@@ -1302,7 +1302,7 @@ var import_type_graphql26 = require("type-graphql");
1302
1302
 
1303
1303
  // src/graphql/resolvers/copilot.resolver.ts
1304
1304
  var import_type_graphql20 = require("type-graphql");
1305
- var import_rxjs4 = require("rxjs");
1305
+ var import_rxjs5 = require("rxjs");
1306
1306
 
1307
1307
  // src/graphql/inputs/generate-copilot-response.input.ts
1308
1308
  var import_type_graphql18 = require("type-graphql");
@@ -2792,7 +2792,7 @@ var import_graphql_yoga = require("graphql-yoga");
2792
2792
  // src/service-adapters/events.ts
2793
2793
  var import_shared24 = require("@copilotkit/shared");
2794
2794
  var import_class_transformer2 = require("class-transformer");
2795
- var import_rxjs3 = require("rxjs");
2795
+ var import_rxjs4 = require("rxjs");
2796
2796
 
2797
2797
  // src/graphql/types/converted/index.ts
2798
2798
  var Message = class extends BaseMessageInput {
@@ -5887,6 +5887,7 @@ __name(createHeaders, "createHeaders");
5887
5887
  var import_shared23 = require("@copilotkit/shared");
5888
5888
 
5889
5889
  // src/lib/runtime/agui-action.ts
5890
+ var import_rxjs3 = require("rxjs");
5890
5891
  var import_shared21 = require("@copilotkit/shared");
5891
5892
  function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, agent, metaEvents, threadMetadata, nodeName, graphqlContext }) {
5892
5893
  const action = {
@@ -5944,7 +5945,12 @@ function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, age
5944
5945
  return agent.legacy_to_be_removed_runAgentBridged({
5945
5946
  tools,
5946
5947
  forwardedProps
5947
- });
5948
+ }).pipe((0, import_rxjs3.catchError)((err) => {
5949
+ throw new import_shared21.CopilotKitError({
5950
+ message: err.message,
5951
+ code: import_shared21.CopilotKitErrorCode.UNKNOWN
5952
+ });
5953
+ }));
5948
5954
  }
5949
5955
  };
5950
5956
  return [
@@ -6148,7 +6154,7 @@ var RuntimeMetaEventName;
6148
6154
  RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
6149
6155
  RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
6150
6156
  })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
6151
- var RuntimeEventSubject = class extends import_rxjs3.ReplaySubject {
6157
+ var RuntimeEventSubject = class extends import_rxjs4.ReplaySubject {
6152
6158
  constructor() {
6153
6159
  super();
6154
6160
  }
@@ -6279,7 +6285,7 @@ var RuntimeEventSource = class {
6279
6285
  });
6280
6286
  return this.eventStream$.pipe(
6281
6287
  // track state
6282
- (0, import_rxjs3.scan)((acc, event) => {
6288
+ (0, import_rxjs4.scan)((acc, event) => {
6283
6289
  acc = {
6284
6290
  ...acc
6285
6291
  };
@@ -6304,16 +6310,16 @@ var RuntimeEventSource = class {
6304
6310
  action: null,
6305
6311
  actionExecutionParentMessageId: null
6306
6312
  }),
6307
- (0, import_rxjs3.concatMap)((eventWithState) => {
6313
+ (0, import_rxjs4.concatMap)((eventWithState) => {
6308
6314
  if (eventWithState.event.type === "ActionExecutionEnd" && eventWithState.callActionServerSide) {
6309
6315
  const toolCallEventStream$ = new RuntimeEventSubject();
6310
6316
  executeAction(toolCallEventStream$, guardrailsResult$ ? guardrailsResult$ : null, eventWithState.action, eventWithState.args, eventWithState.actionExecutionParentMessageId, eventWithState.actionExecutionId, actionInputsWithoutAgents, threadId).catch((error) => {
6311
6317
  });
6312
6318
  telemetry_client_default.capture("oss.runtime.server_action_executed", {});
6313
- return (0, import_rxjs3.concat)((0, import_rxjs3.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs3.catchError)((error) => {
6319
+ return (0, import_rxjs4.concat)((0, import_rxjs4.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs4.catchError)((error) => {
6314
6320
  const structuredError = (0, import_shared24.ensureStructuredError)(error, convertStreamingErrorToStructured2);
6315
6321
  if (this.errorHandler && this.errorContext) {
6316
- (0, import_rxjs3.from)(this.errorHandler(structuredError, {
6322
+ (0, import_rxjs4.from)(this.errorHandler(structuredError, {
6317
6323
  ...this.errorContext,
6318
6324
  action: {
6319
6325
  name: eventWithState.action.name,
@@ -6333,10 +6339,10 @@ var RuntimeEventSource = class {
6333
6339
  message: structuredError.message
6334
6340
  }
6335
6341
  });
6336
- return import_rxjs3.EMPTY;
6342
+ return import_rxjs4.EMPTY;
6337
6343
  }));
6338
6344
  } else {
6339
- return (0, import_rxjs3.of)(eventWithState.event);
6345
+ return (0, import_rxjs4.of)(eventWithState.event);
6340
6346
  }
6341
6347
  })
6342
6348
  );
@@ -6346,7 +6352,7 @@ __name(RuntimeEventSource, "RuntimeEventSource");
6346
6352
  async function executeAction(eventStream$, guardrailsResult$, action, actionArguments, actionExecutionParentMessageId, actionExecutionId, actionInputsWithoutAgents, threadId) {
6347
6353
  var _a;
6348
6354
  if (guardrailsResult$) {
6349
- const { status } = await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
6355
+ const { status } = await (0, import_rxjs4.firstValueFrom)(guardrailsResult$);
6350
6356
  if (status === "denied") {
6351
6357
  eventStream$.complete();
6352
6358
  return;
@@ -6401,7 +6407,7 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
6401
6407
  agentExecutionResult
6402
6408
  ]
6403
6409
  });
6404
- (0, import_rxjs3.from)(stream).subscribe({
6410
+ (0, import_rxjs4.from)(stream).subscribe({
6405
6411
  next: (event) => eventStream$.next(event),
6406
6412
  error: (err) => {
6407
6413
  const structuredError = (0, import_shared24.ensureStructuredError)(err, convertStreamingErrorToStructured2);
@@ -6692,9 +6698,9 @@ var CopilotResolver = class {
6692
6698
  });
6693
6699
  }
6694
6700
  logger2.debug("Setting up subjects");
6695
- const responseStatus$ = new import_rxjs4.ReplaySubject();
6696
- const interruptStreaming$ = new import_rxjs4.ReplaySubject();
6697
- const guardrailsResult$ = new import_rxjs4.ReplaySubject();
6701
+ const responseStatus$ = new import_rxjs5.ReplaySubject();
6702
+ const interruptStreaming$ = new import_rxjs5.ReplaySubject();
6703
+ const guardrailsResult$ = new import_rxjs5.ReplaySubject();
6698
6704
  let outputMessages = [];
6699
6705
  let resolveOutputMessagesPromise;
6700
6706
  let rejectOutputMessagesPromise;
@@ -6749,15 +6755,15 @@ var CopilotResolver = class {
6749
6755
  }).pipe(
6750
6756
  // shareReplay() ensures that later subscribers will see the whole stream instead of
6751
6757
  // just the events that were emitted after the subscriber was added.
6752
- (0, import_rxjs4.shareReplay)(),
6753
- (0, import_rxjs4.finalize)(() => {
6758
+ (0, import_rxjs5.shareReplay)(),
6759
+ (0, import_rxjs5.finalize)(() => {
6754
6760
  logger2.debug("Event stream finalized");
6755
6761
  })
6756
6762
  );
6757
6763
  const response = {
6758
6764
  threadId,
6759
6765
  runId,
6760
- status: (0, import_rxjs4.firstValueFrom)(responseStatus$),
6766
+ status: (0, import_rxjs5.firstValueFrom)(responseStatus$),
6761
6767
  extensions,
6762
6768
  metaEvents: new import_graphql_yoga.Repeater(async (push, stop) => {
6763
6769
  let eventStreamSubscription;
@@ -6901,25 +6907,25 @@ var CopilotResolver = class {
6901
6907
  case RuntimeEventTypes.TextMessageStart:
6902
6908
  const textMessageContentStream = eventStream.pipe(
6903
6909
  // skip until this message start event
6904
- (0, import_rxjs4.skipWhile)((e) => e !== event),
6910
+ (0, import_rxjs5.skipWhile)((e) => e !== event),
6905
6911
  // take until the message end event
6906
- (0, import_rxjs4.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
6912
+ (0, import_rxjs5.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
6907
6913
  // filter out any other message events or message ids
6908
- (0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
6914
+ (0, import_rxjs5.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
6909
6915
  );
6910
- const streamingTextStatus = new import_rxjs4.Subject();
6916
+ const streamingTextStatus = new import_rxjs5.Subject();
6911
6917
  const messageId = event.messageId;
6912
6918
  pushMessage({
6913
6919
  id: messageId,
6914
6920
  parentMessageId: event.parentMessageId,
6915
- status: (0, import_rxjs4.firstValueFrom)(streamingTextStatus),
6921
+ status: (0, import_rxjs5.firstValueFrom)(streamingTextStatus),
6916
6922
  createdAt: /* @__PURE__ */ new Date(),
6917
6923
  role: MessageRole.assistant,
6918
6924
  content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
6919
6925
  logger2.debug("Text message content repeater created");
6920
6926
  const textChunks = [];
6921
6927
  let textSubscription;
6922
- interruptStreaming$.pipe((0, import_rxjs4.shareReplay)(), (0, import_rxjs4.take)(1), (0, import_rxjs4.tap)(({ reason, messageId: messageId2 }) => {
6928
+ interruptStreaming$.pipe((0, import_rxjs5.shareReplay)(), (0, import_rxjs5.take)(1), (0, import_rxjs5.tap)(({ reason, messageId: messageId2 }) => {
6923
6929
  logger2.debug({
6924
6930
  reason,
6925
6931
  messageId: messageId2
@@ -6971,17 +6977,17 @@ var CopilotResolver = class {
6971
6977
  case RuntimeEventTypes.ActionExecutionStart:
6972
6978
  logger2.debug("Action execution start event received");
6973
6979
  const actionExecutionArgumentStream = eventStream.pipe(
6974
- (0, import_rxjs4.skipWhile)((e) => e !== event),
6980
+ (0, import_rxjs5.skipWhile)((e) => e !== event),
6975
6981
  // take until the action execution end event
6976
- (0, import_rxjs4.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
6982
+ (0, import_rxjs5.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
6977
6983
  // filter out any other action execution events or action execution ids
6978
- (0, import_rxjs4.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
6984
+ (0, import_rxjs5.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
6979
6985
  );
6980
- const streamingArgumentsStatus = new import_rxjs4.Subject();
6986
+ const streamingArgumentsStatus = new import_rxjs5.Subject();
6981
6987
  pushMessage({
6982
6988
  id: event.actionExecutionId,
6983
6989
  parentMessageId: event.parentMessageId,
6984
- status: (0, import_rxjs4.firstValueFrom)(streamingArgumentsStatus),
6990
+ status: (0, import_rxjs5.firstValueFrom)(streamingArgumentsStatus),
6985
6991
  createdAt: /* @__PURE__ */ new Date(),
6986
6992
  name: event.actionName,
6987
6993
  arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
@@ -7105,7 +7111,7 @@ var CopilotResolver = class {
7105
7111
  logger2.debug("Event stream completed");
7106
7112
  if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
7107
7113
  logger2.debug("Guardrails is enabled, waiting for guardrails result");
7108
- await (0, import_rxjs4.firstValueFrom)(guardrailsResult$);
7114
+ await (0, import_rxjs5.firstValueFrom)(guardrailsResult$);
7109
7115
  }
7110
7116
  responseStatus$.next(new SuccessResponseStatus());
7111
7117
  eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
@@ -7550,7 +7556,7 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
7550
7556
 
7551
7557
  // src/lib/runtime/langgraph/langgraph-agent.ts
7552
7558
  var import_client = require("@ag-ui/client");
7553
- var import_rxjs5 = require("rxjs");
7559
+ var import_rxjs6 = require("rxjs");
7554
7560
  var import_langgraph = require("@ag-ui/langgraph");
7555
7561
  var CustomEventNames2;
7556
7562
  (function(CustomEventNames3) {
@@ -7647,7 +7653,7 @@ var LangGraphAgent = class extends import_langgraph.LangGraphAgent {
7647
7653
  }
7648
7654
  // @ts-ignore
7649
7655
  run(input) {
7650
- return super.run(input).pipe((0, import_rxjs5.map)((processedEvent) => {
7656
+ return super.run(input).pipe((0, import_rxjs6.map)((processedEvent) => {
7651
7657
  var _a, _b, _c, _d, _e;
7652
7658
  if (processedEvent.type === import_client.EventType.RAW) {
7653
7659
  const event = processedEvent.event ?? processedEvent.rawEvent;