@copilotkit/runtime 1.5.12-next.0 → 1.5.12-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 (51) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{chunk-4YJIXJLO.mjs → chunk-BETLEV37.mjs} +2 -2
  3. package/dist/{chunk-4QJA7OT2.mjs → chunk-FA5DJ2TZ.mjs} +61 -19
  4. package/dist/chunk-FA5DJ2TZ.mjs.map +1 -0
  5. package/dist/chunk-HNUNXFTW.mjs +129 -0
  6. package/dist/chunk-HNUNXFTW.mjs.map +1 -0
  7. package/dist/{chunk-XXYYCH4X.mjs → chunk-SFLMY3ES.mjs} +2 -2
  8. package/dist/{chunk-7BOVBWKI.mjs → chunk-ZCU6UPCY.mjs} +2 -2
  9. package/dist/{copilot-runtime-36700e00.d.ts → copilot-runtime-1a224a0f.d.ts} +2 -2
  10. package/dist/graphql/types/converted/index.d.ts +1 -1
  11. package/dist/graphql/types/converted/index.js +63 -0
  12. package/dist/graphql/types/converted/index.js.map +1 -1
  13. package/dist/graphql/types/converted/index.mjs +1 -1
  14. package/dist/{groq-adapter-696b5d29.d.ts → groq-adapter-c35c5374.d.ts} +1 -1
  15. package/dist/{index-cc2b17be.d.ts → index-24315d90.d.ts} +16 -0
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +121 -16
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +5 -5
  20. package/dist/{langserve-9125a12e.d.ts → langserve-a16ef8f4.d.ts} +7 -3
  21. package/dist/lib/index.d.ts +4 -4
  22. package/dist/lib/index.js +121 -16
  23. package/dist/lib/index.js.map +1 -1
  24. package/dist/lib/index.mjs +5 -5
  25. package/dist/lib/integrations/index.d.ts +4 -4
  26. package/dist/lib/integrations/index.js +64 -1
  27. package/dist/lib/integrations/index.js.map +1 -1
  28. package/dist/lib/integrations/index.mjs +5 -5
  29. package/dist/lib/integrations/nest/index.d.ts +3 -3
  30. package/dist/lib/integrations/nest/index.js +64 -1
  31. package/dist/lib/integrations/nest/index.js.map +1 -1
  32. package/dist/lib/integrations/nest/index.mjs +3 -3
  33. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  34. package/dist/lib/integrations/node-express/index.js +64 -1
  35. package/dist/lib/integrations/node-express/index.js.map +1 -1
  36. package/dist/lib/integrations/node-express/index.mjs +3 -3
  37. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  38. package/dist/lib/integrations/node-http/index.js +64 -1
  39. package/dist/lib/integrations/node-http/index.js.map +1 -1
  40. package/dist/lib/integrations/node-http/index.mjs +2 -2
  41. package/dist/service-adapters/index.d.ts +4 -4
  42. package/package.json +2 -2
  43. package/src/graphql/types/converted/index.ts +66 -0
  44. package/src/lib/runtime/copilot-runtime.ts +5 -1
  45. package/src/service-adapters/events.ts +58 -16
  46. package/dist/chunk-4QJA7OT2.mjs.map +0 -1
  47. package/dist/chunk-RFF5IIZJ.mjs +0 -66
  48. package/dist/chunk-RFF5IIZJ.mjs.map +0 -1
  49. /package/dist/{chunk-4YJIXJLO.mjs.map → chunk-BETLEV37.mjs.map} +0 -0
  50. /package/dist/{chunk-XXYYCH4X.mjs.map → chunk-SFLMY3ES.mjs.map} +0 -0
  51. /package/dist/{chunk-7BOVBWKI.mjs.map → chunk-ZCU6UPCY.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.5.12-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - @copilotkit/shared@1.5.12-next.2
8
+
9
+ ## 1.5.12-next.1
10
+
11
+ ### Patch Changes
12
+
13
+ - a2129f4: - fix(streaming): end streaming on error to enable continuity of chat after failed tool call
14
+ - @copilotkit/shared@1.5.12-next.1
15
+
3
16
  ## 1.5.12-next.0
4
17
 
5
18
  ### Patch Changes
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-4QJA7OT2.mjs";
5
+ } from "./chunk-FA5DJ2TZ.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-4YJIXJLO.mjs.map
25
+ //# sourceMappingURL=chunk-BETLEV37.mjs.map
@@ -14,7 +14,7 @@ import {
14
14
  AgentStateMessage,
15
15
  ResultMessage,
16
16
  TextMessage
17
- } from "./chunk-RFF5IIZJ.mjs";
17
+ } from "./chunk-HNUNXFTW.mjs";
18
18
  import {
19
19
  BaseMessageInput
20
20
  } from "./chunk-D2WLFQS6.mjs";
@@ -37,7 +37,7 @@ var require_package = __commonJS({
37
37
  publishConfig: {
38
38
  access: "public"
39
39
  },
40
- version: "1.5.12-next.0",
40
+ version: "1.5.12-next.2",
41
41
  sideEffects: false,
42
42
  main: "./dist/index.js",
43
43
  module: "./dist/index.mjs",
@@ -1080,7 +1080,7 @@ import { Repeater } from "graphql-yoga";
1080
1080
 
1081
1081
  // src/service-adapters/events.ts
1082
1082
  import { randomId as randomId3 } from "@copilotkit/shared";
1083
- import { of, concat, scan as scan2, concatMap, ReplaySubject as ReplaySubject2, firstValueFrom, from as from2 } from "rxjs";
1083
+ import { of, concat, scan as scan2, concatMap, ReplaySubject as ReplaySubject2, firstValueFrom, from as from2, catchError as catchError2, EMPTY } from "rxjs";
1084
1084
 
1085
1085
  // src/lib/telemetry-client.ts
1086
1086
  import { TelemetryClient } from "@copilotkit/shared";
@@ -2352,7 +2352,11 @@ var CopilotRuntime = class {
2352
2352
  eventSource.stream(async (eventStream$) => {
2353
2353
  from(stream).subscribe({
2354
2354
  next: (event) => eventStream$.next(event),
2355
- error: (err) => console.error("Error in stream", err),
2355
+ error: (err) => {
2356
+ console.error("Error in stream", err);
2357
+ eventStream$.error(err);
2358
+ eventStream$.complete();
2359
+ },
2356
2360
  complete: () => eventStream$.complete()
2357
2361
  });
2358
2362
  });
@@ -2582,12 +2586,12 @@ var RuntimeEventSubject = class extends ReplaySubject2 {
2582
2586
  actionExecutionId
2583
2587
  });
2584
2588
  }
2585
- sendActionExecutionResult({ actionExecutionId, actionName, result }) {
2589
+ sendActionExecutionResult({ actionExecutionId, actionName, result, error }) {
2586
2590
  this.next({
2587
2591
  type: "ActionExecutionResult",
2588
2592
  actionName,
2589
2593
  actionExecutionId,
2590
- result
2594
+ result: ResultMessage.encodeResult(result, error)
2591
2595
  });
2592
2596
  }
2593
2597
  sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running }) {
@@ -2625,6 +2629,7 @@ var RuntimeEventSource = class {
2625
2629
  this.callback(this.eventStream$).catch((error) => {
2626
2630
  console.error("Error in event source callback", error);
2627
2631
  this.sendErrorMessageToChat();
2632
+ this.eventStream$.complete();
2628
2633
  });
2629
2634
  return this.eventStream$.pipe(
2630
2635
  // track state
@@ -2660,7 +2665,11 @@ var RuntimeEventSource = class {
2660
2665
  console.error(error);
2661
2666
  });
2662
2667
  telemetry_client_default.capture("oss.runtime.server_action_executed", {});
2663
- return concat(of(eventWithState.event), toolCallEventStream$);
2668
+ return concat(of(eventWithState.event), toolCallEventStream$).pipe(catchError2((error) => {
2669
+ console.error("Error in tool call stream", error);
2670
+ this.sendErrorMessageToChat();
2671
+ return EMPTY;
2672
+ }));
2664
2673
  } else {
2665
2674
  return of(eventWithState.event);
2666
2675
  }
@@ -2683,9 +2692,18 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2683
2692
  try {
2684
2693
  args = JSON.parse(actionArguments);
2685
2694
  } catch (e) {
2686
- console.warn("Action argument unparsable", {
2695
+ console.error("Action argument unparsable", {
2687
2696
  actionArguments
2688
2697
  });
2698
+ eventStream$.sendActionExecutionResult({
2699
+ actionExecutionId,
2700
+ actionName: action.name,
2701
+ error: {
2702
+ code: "INVALID_ARGUMENTS",
2703
+ message: "Failed to parse action arguments"
2704
+ }
2705
+ });
2706
+ return;
2689
2707
  }
2690
2708
  }
2691
2709
  if (isLangGraphAgentAction(action)) {
@@ -2719,19 +2737,43 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2719
2737
  });
2720
2738
  from2(stream).subscribe({
2721
2739
  next: (event) => eventStream$.next(event),
2722
- error: (err) => console.error("Error in stream", err),
2740
+ error: (err) => {
2741
+ console.error("Error in stream", err);
2742
+ eventStream$.sendActionExecutionResult({
2743
+ actionExecutionId,
2744
+ actionName: action.name,
2745
+ error: {
2746
+ code: "STREAM_ERROR",
2747
+ message: err.message
2748
+ }
2749
+ });
2750
+ eventStream$.complete();
2751
+ },
2723
2752
  complete: () => eventStream$.complete()
2724
2753
  });
2725
2754
  } else {
2726
- const result = await ((_a = action.handler) == null ? void 0 : _a.call(action, args));
2727
- await streamLangChainResponse({
2728
- result,
2729
- eventStream$,
2730
- actionExecution: {
2731
- name: action.name,
2732
- id: actionExecutionId
2733
- }
2734
- });
2755
+ try {
2756
+ const result = await ((_a = action.handler) == null ? void 0 : _a.call(action, args));
2757
+ await streamLangChainResponse({
2758
+ result,
2759
+ eventStream$,
2760
+ actionExecution: {
2761
+ name: action.name,
2762
+ id: actionExecutionId
2763
+ }
2764
+ });
2765
+ } catch (e) {
2766
+ console.error("Error in action handler", e);
2767
+ eventStream$.sendActionExecutionResult({
2768
+ actionExecutionId,
2769
+ actionName: action.name,
2770
+ error: {
2771
+ code: "HANDLER_ERROR",
2772
+ message: e.message
2773
+ }
2774
+ });
2775
+ eventStream$.complete();
2776
+ }
2735
2777
  }
2736
2778
  }
2737
2779
  __name(executeAction, "executeAction");
@@ -3392,4 +3434,4 @@ export {
3392
3434
  getCommonConfig,
3393
3435
  copilotRuntimeNodeHttpEndpoint
3394
3436
  };
3395
- //# sourceMappingURL=chunk-4QJA7OT2.mjs.map
3437
+ //# sourceMappingURL=chunk-FA5DJ2TZ.mjs.map