@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/dist/index.mjs CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  config,
4
4
  copilotRuntimeNextJSAppRouterEndpoint,
5
5
  copilotRuntimeNextJSPagesRouterEndpoint
6
- } from "./chunk-XXYYCH4X.mjs";
6
+ } from "./chunk-SFLMY3ES.mjs";
7
7
  import {
8
8
  copilotRuntimeNestEndpoint
9
- } from "./chunk-4YJIXJLO.mjs";
9
+ } from "./chunk-BETLEV37.mjs";
10
10
  import {
11
11
  copilotRuntimeNodeExpressEndpoint
12
- } from "./chunk-7BOVBWKI.mjs";
12
+ } from "./chunk-ZCU6UPCY.mjs";
13
13
  import {
14
14
  CopilotRuntime,
15
15
  buildSchema,
@@ -20,7 +20,7 @@ import {
20
20
  getCommonConfig,
21
21
  langGraphPlatformEndpoint,
22
22
  resolveEndpointType
23
- } from "./chunk-4QJA7OT2.mjs";
23
+ } from "./chunk-FA5DJ2TZ.mjs";
24
24
  import {
25
25
  AnthropicAdapter,
26
26
  ExperimentalEmptyAdapter,
@@ -38,7 +38,7 @@ import {
38
38
  MessageStreamInterruptedResponse,
39
39
  UnknownErrorResponse
40
40
  } from "./chunk-U3V2BCGI.mjs";
41
- import "./chunk-RFF5IIZJ.mjs";
41
+ import "./chunk-HNUNXFTW.mjs";
42
42
  import "./chunk-D2WLFQS6.mjs";
43
43
  import "./chunk-44O2JGUY.mjs";
44
44
 
@@ -1,4 +1,4 @@
1
- import { A as ActionInputAvailability, M as Message } from './index-cc2b17be.js';
1
+ import { A as ActionInputAvailability, M as Message } from './index-24315d90.js';
2
2
  import * as rxjs from 'rxjs';
3
3
  import { Subject, ReplaySubject } from 'rxjs';
4
4
  import { Action, Parameter } from '@copilotkit/shared';
@@ -101,10 +101,14 @@ declare class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {
101
101
  args: string;
102
102
  parentMessageId?: string;
103
103
  }): void;
104
- sendActionExecutionResult({ actionExecutionId, actionName, result, }: {
104
+ sendActionExecutionResult({ actionExecutionId, actionName, result, error, }: {
105
105
  actionExecutionId: string;
106
106
  actionName: string;
107
- result: string;
107
+ result?: string;
108
+ error?: {
109
+ code: string;
110
+ message: string;
111
+ };
108
112
  }): void;
109
113
  sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running, }: {
110
114
  threadId: string;
@@ -1,12 +1,12 @@
1
- export { h as CommonConfig, b as CopilotRequestContextProperties, a as CopilotRuntime, C as CopilotRuntimeConstructorParams, d as CreateCopilotRuntimeServerOptions, G as GraphQLContext, g as buildSchema, c as copilotKitEndpoint, e as createContext, f as flattenToolCallsNoDuplicates, i as getCommonConfig, l as langGraphPlatformEndpoint, r as resolveEndpointType } from '../copilot-runtime-36700e00.js';
2
- export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-696b5d29.js';
1
+ export { h as CommonConfig, b as CopilotRequestContextProperties, a as CopilotRuntime, C as CopilotRuntimeConstructorParams, d as CreateCopilotRuntimeServerOptions, G as GraphQLContext, g as buildSchema, c as copilotKitEndpoint, e as createContext, f as flattenToolCallsNoDuplicates, i as getCommonConfig, l as langGraphPlatformEndpoint, r as resolveEndpointType } from '../copilot-runtime-1a224a0f.js';
2
+ export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-c35c5374.js';
3
3
  export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './integrations/index.js';
4
4
  export { copilotRuntimeNodeHttpEndpoint } from './integrations/node-http/index.js';
5
5
  export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/index.js';
6
6
  export { copilotRuntimeNestEndpoint } from './integrations/nest/index.js';
7
7
  import '@copilotkit/shared';
8
- import '../langserve-9125a12e.js';
9
- import '../index-cc2b17be.js';
8
+ import '../langserve-a16ef8f4.js';
9
+ import '../index-24315d90.js';
10
10
  import '../graphql/types/base/index.js';
11
11
  import 'rxjs';
12
12
  import 'graphql';
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.5.12-next.0",
47
+ version: "1.5.12-next.2",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -2419,6 +2419,69 @@ var ResultMessage = class extends Message {
2419
2419
  actionExecutionId;
2420
2420
  actionName;
2421
2421
  result;
2422
+ static encodeResult(result, error) {
2423
+ const errorObj = error ? typeof error === "string" ? {
2424
+ code: "ERROR",
2425
+ message: error
2426
+ } : error instanceof Error ? {
2427
+ code: "ERROR",
2428
+ message: error.message
2429
+ } : error : void 0;
2430
+ if (errorObj) {
2431
+ return JSON.stringify({
2432
+ error: errorObj,
2433
+ result: result || ""
2434
+ });
2435
+ }
2436
+ if (result === void 0) {
2437
+ return "";
2438
+ }
2439
+ return typeof result === "string" ? result : JSON.stringify(result);
2440
+ }
2441
+ static decodeResult(result) {
2442
+ if (!result) {
2443
+ return {
2444
+ result: ""
2445
+ };
2446
+ }
2447
+ try {
2448
+ const parsed = JSON.parse(result);
2449
+ if (parsed && typeof parsed === "object") {
2450
+ if ("error" in parsed) {
2451
+ return {
2452
+ error: parsed.error,
2453
+ result: parsed.result || ""
2454
+ };
2455
+ }
2456
+ return {
2457
+ result: JSON.stringify(parsed)
2458
+ };
2459
+ }
2460
+ return {
2461
+ result
2462
+ };
2463
+ } catch (e) {
2464
+ return {
2465
+ result
2466
+ };
2467
+ }
2468
+ }
2469
+ hasError() {
2470
+ try {
2471
+ const { error } = ResultMessage.decodeResult(this.result);
2472
+ return !!error;
2473
+ } catch {
2474
+ return false;
2475
+ }
2476
+ }
2477
+ getError() {
2478
+ try {
2479
+ const { error } = ResultMessage.decodeResult(this.result);
2480
+ return error;
2481
+ } catch {
2482
+ return void 0;
2483
+ }
2484
+ }
2422
2485
  };
2423
2486
  __name(ResultMessage, "ResultMessage");
2424
2487
  var AgentStateMessage = class extends Message {
@@ -2518,12 +2581,12 @@ var RuntimeEventSubject = class extends import_rxjs2.ReplaySubject {
2518
2581
  actionExecutionId
2519
2582
  });
2520
2583
  }
2521
- sendActionExecutionResult({ actionExecutionId, actionName, result }) {
2584
+ sendActionExecutionResult({ actionExecutionId, actionName, result, error }) {
2522
2585
  this.next({
2523
2586
  type: "ActionExecutionResult",
2524
2587
  actionName,
2525
2588
  actionExecutionId,
2526
- result
2589
+ result: ResultMessage.encodeResult(result, error)
2527
2590
  });
2528
2591
  }
2529
2592
  sendAgentStateMessage({ threadId, agentName, nodeName, runId, active, role, state, running }) {
@@ -2561,6 +2624,7 @@ var RuntimeEventSource = class {
2561
2624
  this.callback(this.eventStream$).catch((error) => {
2562
2625
  console.error("Error in event source callback", error);
2563
2626
  this.sendErrorMessageToChat();
2627
+ this.eventStream$.complete();
2564
2628
  });
2565
2629
  return this.eventStream$.pipe(
2566
2630
  // track state
@@ -2596,7 +2660,11 @@ var RuntimeEventSource = class {
2596
2660
  console.error(error);
2597
2661
  });
2598
2662
  telemetry_client_default.capture("oss.runtime.server_action_executed", {});
2599
- return (0, import_rxjs2.concat)((0, import_rxjs2.of)(eventWithState.event), toolCallEventStream$);
2663
+ return (0, import_rxjs2.concat)((0, import_rxjs2.of)(eventWithState.event), toolCallEventStream$).pipe((0, import_rxjs2.catchError)((error) => {
2664
+ console.error("Error in tool call stream", error);
2665
+ this.sendErrorMessageToChat();
2666
+ return import_rxjs2.EMPTY;
2667
+ }));
2600
2668
  } else {
2601
2669
  return (0, import_rxjs2.of)(eventWithState.event);
2602
2670
  }
@@ -2619,9 +2687,18 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2619
2687
  try {
2620
2688
  args = JSON.parse(actionArguments);
2621
2689
  } catch (e) {
2622
- console.warn("Action argument unparsable", {
2690
+ console.error("Action argument unparsable", {
2623
2691
  actionArguments
2624
2692
  });
2693
+ eventStream$.sendActionExecutionResult({
2694
+ actionExecutionId,
2695
+ actionName: action.name,
2696
+ error: {
2697
+ code: "INVALID_ARGUMENTS",
2698
+ message: "Failed to parse action arguments"
2699
+ }
2700
+ });
2701
+ return;
2625
2702
  }
2626
2703
  }
2627
2704
  if (isLangGraphAgentAction(action)) {
@@ -2655,19 +2732,43 @@ async function executeAction(eventStream$, guardrailsResult$, action, actionArgu
2655
2732
  });
2656
2733
  (0, import_rxjs2.from)(stream).subscribe({
2657
2734
  next: (event) => eventStream$.next(event),
2658
- error: (err) => console.error("Error in stream", err),
2735
+ error: (err) => {
2736
+ console.error("Error in stream", err);
2737
+ eventStream$.sendActionExecutionResult({
2738
+ actionExecutionId,
2739
+ actionName: action.name,
2740
+ error: {
2741
+ code: "STREAM_ERROR",
2742
+ message: err.message
2743
+ }
2744
+ });
2745
+ eventStream$.complete();
2746
+ },
2659
2747
  complete: () => eventStream$.complete()
2660
2748
  });
2661
2749
  } else {
2662
- const result = await ((_a = action.handler) == null ? void 0 : _a.call(action, args));
2663
- await streamLangChainResponse({
2664
- result,
2665
- eventStream$,
2666
- actionExecution: {
2667
- name: action.name,
2668
- id: actionExecutionId
2669
- }
2670
- });
2750
+ try {
2751
+ const result = await ((_a = action.handler) == null ? void 0 : _a.call(action, args));
2752
+ await streamLangChainResponse({
2753
+ result,
2754
+ eventStream$,
2755
+ actionExecution: {
2756
+ name: action.name,
2757
+ id: actionExecutionId
2758
+ }
2759
+ });
2760
+ } catch (e) {
2761
+ console.error("Error in action handler", e);
2762
+ eventStream$.sendActionExecutionResult({
2763
+ actionExecutionId,
2764
+ actionName: action.name,
2765
+ error: {
2766
+ code: "HANDLER_ERROR",
2767
+ message: e.message
2768
+ }
2769
+ });
2770
+ eventStream$.complete();
2771
+ }
2671
2772
  }
2672
2773
  }
2673
2774
  __name(executeAction, "executeAction");
@@ -2880,7 +2981,11 @@ var CopilotRuntime = class {
2880
2981
  eventSource.stream(async (eventStream$) => {
2881
2982
  (0, import_rxjs3.from)(stream).subscribe({
2882
2983
  next: (event) => eventStream$.next(event),
2883
- error: (err) => console.error("Error in stream", err),
2984
+ error: (err) => {
2985
+ console.error("Error in stream", err);
2986
+ eventStream$.error(err);
2987
+ eventStream$.complete();
2988
+ },
2884
2989
  complete: () => eventStream$.complete()
2885
2990
  });
2886
2991
  });