@copilotkit/runtime 1.9.2-next.24 → 1.9.2-next.25

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 (43) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-FR4C3TPU.mjs → chunk-3JXN25PL.mjs} +2 -2
  3. package/dist/{chunk-ECQRTXJX.mjs → chunk-BNLL5CH2.mjs} +2 -2
  4. package/dist/{chunk-S2YGYQDH.mjs → chunk-DOXGUQKL.mjs} +2 -2
  5. package/dist/{chunk-TBVA4IGX.mjs → chunk-GJWXNXSA.mjs} +2 -2
  6. package/dist/{chunk-GAUZHH2X.mjs → chunk-YKYBGYYL.mjs} +79 -33
  7. package/dist/chunk-YKYBGYYL.mjs.map +1 -0
  8. package/dist/{groq-adapter-098f97f6.d.ts → groq-adapter-742818f2.d.ts} +1 -1
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +71 -25
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +6 -6
  13. package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
  14. package/dist/lib/index.d.ts +3 -3
  15. package/dist/lib/index.js +71 -25
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/index.mjs +6 -6
  18. package/dist/lib/integrations/index.d.ts +3 -3
  19. package/dist/lib/integrations/index.js +1 -1
  20. package/dist/lib/integrations/index.js.map +1 -1
  21. package/dist/lib/integrations/index.mjs +5 -5
  22. package/dist/lib/integrations/nest/index.d.ts +2 -2
  23. package/dist/lib/integrations/nest/index.js +1 -1
  24. package/dist/lib/integrations/nest/index.js.map +1 -1
  25. package/dist/lib/integrations/nest/index.mjs +3 -3
  26. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  27. package/dist/lib/integrations/node-express/index.js +1 -1
  28. package/dist/lib/integrations/node-express/index.js.map +1 -1
  29. package/dist/lib/integrations/node-express/index.mjs +3 -3
  30. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  31. package/dist/lib/integrations/node-http/index.js +1 -1
  32. package/dist/lib/integrations/node-http/index.js.map +1 -1
  33. package/dist/lib/integrations/node-http/index.mjs +2 -2
  34. package/dist/service-adapters/index.d.ts +4 -4
  35. package/dist/{shared-6b6dbf8b.d.ts → shared-96b46379.d.ts} +1 -1
  36. package/package.json +2 -2
  37. package/src/lib/runtime/copilot-runtime.ts +32 -19
  38. package/src/service-adapters/events.ts +40 -1
  39. package/dist/chunk-GAUZHH2X.mjs.map +0 -1
  40. /package/dist/{chunk-FR4C3TPU.mjs.map → chunk-3JXN25PL.mjs.map} +0 -0
  41. /package/dist/{chunk-ECQRTXJX.mjs.map → chunk-BNLL5CH2.mjs.map} +0 -0
  42. /package/dist/{chunk-S2YGYQDH.mjs.map → chunk-DOXGUQKL.mjs.map} +0 -0
  43. /package/dist/{chunk-TBVA4IGX.mjs.map → chunk-GJWXNXSA.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.9.2-next.25
4
+
5
+ ### Patch Changes
6
+
7
+ - f3f0181: - fix: connect streaming errors to runtime onError handler
8
+ - remove request logging
9
+ - f3f0181: - fix: connect streaming errors to runtime onError handler
10
+ - @copilotkit/shared@1.9.2-next.25
11
+
3
12
  ## 1.9.2-next.24
4
13
 
5
14
  ### Patch Changes
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-GAUZHH2X.mjs";
5
+ } from "./chunk-YKYBGYYL.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-FR4C3TPU.mjs.map
25
+ //# sourceMappingURL=chunk-3JXN25PL.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-GAUZHH2X.mjs";
5
+ } from "./chunk-YKYBGYYL.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-ECQRTXJX.mjs.map
25
+ //# sourceMappingURL=chunk-BNLL5CH2.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LangGraphEventTypes
3
- } from "./chunk-GAUZHH2X.mjs";
3
+ } from "./chunk-YKYBGYYL.mjs";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-FHD4JECV.mjs";
@@ -155,4 +155,4 @@ export {
155
155
  CustomEventNames,
156
156
  LangGraphAgent
157
157
  };
158
- //# sourceMappingURL=chunk-S2YGYQDH.mjs.map
158
+ //# sourceMappingURL=chunk-DOXGUQKL.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-GAUZHH2X.mjs";
5
+ } from "./chunk-YKYBGYYL.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-TBVA4IGX.mjs.map
80
+ //# sourceMappingURL=chunk-GJWXNXSA.mjs.map
@@ -1,3 +1,10 @@
1
+ import {
2
+ ActionExecutionMessage,
3
+ AgentStateMessage,
4
+ ImageMessage,
5
+ ResultMessage,
6
+ TextMessage
7
+ } from "./chunk-SHBDMA63.mjs";
1
8
  import {
2
9
  EmptyAdapter,
3
10
  RemoteChain,
@@ -10,13 +17,6 @@ import {
10
17
  SuccessResponseStatus,
11
18
  UnknownErrorResponse
12
19
  } from "./chunk-XWBDEXDA.mjs";
13
- import {
14
- ActionExecutionMessage,
15
- AgentStateMessage,
16
- ImageMessage,
17
- ResultMessage,
18
- TextMessage
19
- } from "./chunk-SHBDMA63.mjs";
20
20
  import {
21
21
  BaseMessageInput
22
22
  } from "./chunk-2OZAGFV3.mjs";
@@ -40,7 +40,7 @@ var require_package = __commonJS({
40
40
  publishConfig: {
41
41
  access: "public"
42
42
  },
43
- version: "1.9.2-next.24",
43
+ version: "1.9.2-next.25",
44
44
  sideEffects: false,
45
45
  main: "./dist/index.js",
46
46
  module: "./dist/index.mjs",
@@ -2877,30 +2877,30 @@ var CopilotRuntime = class {
2877
2877
  async processRuntimeRequest(request) {
2878
2878
  var _a, _b, _c, _d, _e;
2879
2879
  const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, url, extensions, agentSession, agentStates, publicApiKey } = request;
2880
- const eventSource = new RuntimeEventSource();
2881
- const requestStartTime = Date.now();
2882
- const streamedChunks = [];
2883
- await this.error("request", {
2884
- threadId,
2885
- runId,
2886
- source: "runtime",
2887
- request: {
2888
- operation: "processRuntimeRequest",
2889
- method: "POST",
2890
- url,
2891
- startTime: requestStartTime
2892
- },
2893
- agent: agentSession ? {
2894
- name: agentSession.agentName
2895
- } : void 0,
2896
- messages: {
2897
- input: rawMessages,
2898
- messageCount: rawMessages.length
2880
+ const eventSource = new RuntimeEventSource({
2881
+ errorHandler: async (error, context) => {
2882
+ await this.error("error", context, error, publicApiKey);
2899
2883
  },
2900
- technical: {
2901
- environment: process.env.NODE_ENV
2884
+ errorContext: {
2885
+ threadId,
2886
+ runId,
2887
+ source: "runtime",
2888
+ request: {
2889
+ operation: "processRuntimeRequest",
2890
+ method: "POST",
2891
+ url,
2892
+ startTime: Date.now()
2893
+ },
2894
+ agent: agentSession ? {
2895
+ name: agentSession.agentName
2896
+ } : void 0,
2897
+ technical: {
2898
+ environment: process.env.NODE_ENV
2899
+ }
2902
2900
  }
2903
- }, void 0, publicApiKey);
2901
+ });
2902
+ const requestStartTime = Date.now();
2903
+ const streamedChunks = [];
2904
2904
  try {
2905
2905
  if (Object.keys(this.agents).length && (agentSession == null ? void 0 : agentSession.agentName) && !this.delegateAgentProcessingToServiceAdapter) {
2906
2906
  this.agents = {
@@ -3392,7 +3392,27 @@ please use an LLM adapter instead.`
3392
3392
  properties: graphqlContext.properties
3393
3393
  }));
3394
3394
  try {
3395
- const eventSource = new RuntimeEventSource();
3395
+ const eventSource = new RuntimeEventSource({
3396
+ errorHandler: async (error, context) => {
3397
+ await this.error("error", context, error, publicApiKey);
3398
+ },
3399
+ errorContext: {
3400
+ threadId,
3401
+ source: "agent",
3402
+ request: {
3403
+ operation: "processAgentRequest",
3404
+ method: "POST",
3405
+ startTime: requestStartTime
3406
+ },
3407
+ agent: {
3408
+ name: agentName,
3409
+ nodeName
3410
+ },
3411
+ technical: {
3412
+ environment: process.env.NODE_ENV
3413
+ }
3414
+ }
3415
+ });
3396
3416
  const stream = await currentAgent.remoteAgentHandler({
3397
3417
  name: agentName,
3398
3418
  threadId,
@@ -4693,6 +4713,12 @@ __name(RuntimeEventSubject, "RuntimeEventSubject");
4693
4713
  var RuntimeEventSource = class {
4694
4714
  eventStream$ = new RuntimeEventSubject();
4695
4715
  callback;
4716
+ errorHandler;
4717
+ errorContext;
4718
+ constructor(params) {
4719
+ this.errorHandler = params == null ? void 0 : params.errorHandler;
4720
+ this.errorContext = params == null ? void 0 : params.errorContext;
4721
+ }
4696
4722
  async stream(callback) {
4697
4723
  this.callback = callback;
4698
4724
  }
@@ -4707,8 +4733,15 @@ var RuntimeEventSource = class {
4707
4733
  }
4708
4734
  }
4709
4735
  processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents, threadId }) {
4710
- this.callback(this.eventStream$).catch((error) => {
4736
+ this.callback(this.eventStream$).catch(async (error) => {
4711
4737
  const structuredError = ensureStructuredError3(error, convertStreamingErrorToStructured2);
4738
+ if (this.errorHandler && this.errorContext) {
4739
+ try {
4740
+ await this.errorHandler(structuredError, this.errorContext);
4741
+ } catch (errorHandlerError) {
4742
+ console.error("Error in streaming error handler:", errorHandlerError);
4743
+ }
4744
+ }
4712
4745
  this.eventStream$.error(structuredError);
4713
4746
  this.eventStream$.complete();
4714
4747
  });
@@ -4747,6 +4780,19 @@ var RuntimeEventSource = class {
4747
4780
  telemetry_client_default.capture("oss.runtime.server_action_executed", {});
4748
4781
  return concat(of(eventWithState.event), toolCallEventStream$).pipe(catchError2((error) => {
4749
4782
  const structuredError = ensureStructuredError3(error, convertStreamingErrorToStructured2);
4783
+ if (this.errorHandler && this.errorContext) {
4784
+ from2(this.errorHandler(structuredError, {
4785
+ ...this.errorContext,
4786
+ action: {
4787
+ name: eventWithState.action.name,
4788
+ executionId: eventWithState.actionExecutionId
4789
+ }
4790
+ })).subscribe({
4791
+ error: (errorHandlerError) => {
4792
+ console.error("Error in action execution error handler:", errorHandlerError);
4793
+ }
4794
+ });
4795
+ }
4750
4796
  toolCallEventStream$.sendActionExecutionResult({
4751
4797
  actionExecutionId: eventWithState.actionExecutionId,
4752
4798
  actionName: eventWithState.action.name,
@@ -5863,4 +5909,4 @@ export {
5863
5909
  getCommonConfig,
5864
5910
  copilotRuntimeNodeHttpEndpoint
5865
5911
  };
5866
- //# sourceMappingURL=chunk-GAUZHH2X.mjs.map
5912
+ //# sourceMappingURL=chunk-YKYBGYYL.mjs.map