@copilotkit/runtime 1.9.2-next.16 → 1.9.2-next.18

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 +18 -0
  2. package/dist/{chunk-7F4BIRQF.mjs → chunk-FW5UOGQ2.mjs} +38 -33
  3. package/dist/chunk-FW5UOGQ2.mjs.map +1 -0
  4. package/dist/{chunk-4ODT32DV.mjs → chunk-JIE2UKYM.mjs} +2 -2
  5. package/dist/{chunk-BCDAWNNK.mjs → chunk-QSSQAW7A.mjs} +2 -2
  6. package/dist/{chunk-R22NGLLV.mjs → chunk-RXWWTMSG.mjs} +2 -2
  7. package/dist/{chunk-RBG2A675.mjs → chunk-Y6GPK3Y7.mjs} +2 -2
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +37 -32
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +5 -5
  12. package/dist/lib/index.d.ts +1 -1
  13. package/dist/lib/index.js +37 -32
  14. package/dist/lib/index.js.map +1 -1
  15. package/dist/lib/index.mjs +5 -5
  16. package/dist/lib/integrations/index.d.ts +2 -2
  17. package/dist/lib/integrations/index.js +2 -2
  18. package/dist/lib/integrations/index.js.map +1 -1
  19. package/dist/lib/integrations/index.mjs +4 -4
  20. package/dist/lib/integrations/nest/index.d.ts +1 -1
  21. package/dist/lib/integrations/nest/index.js +2 -2
  22. package/dist/lib/integrations/nest/index.js.map +1 -1
  23. package/dist/lib/integrations/nest/index.mjs +2 -2
  24. package/dist/lib/integrations/node-express/index.d.ts +1 -1
  25. package/dist/lib/integrations/node-express/index.js +2 -2
  26. package/dist/lib/integrations/node-express/index.js.map +1 -1
  27. package/dist/lib/integrations/node-express/index.mjs +2 -2
  28. package/dist/lib/integrations/node-http/index.d.ts +1 -1
  29. package/dist/lib/integrations/node-http/index.js +2 -2
  30. package/dist/lib/integrations/node-http/index.js.map +1 -1
  31. package/dist/lib/integrations/node-http/index.mjs +1 -1
  32. package/dist/{shared-4164c674.d.ts → shared-41d4988d.d.ts} +13 -13
  33. package/package.json +2 -2
  34. package/src/graphql/resolvers/copilot.resolver.ts +1 -2
  35. package/src/lib/runtime/__tests__/{copilot-runtime-trace.test.ts → copilot-runtime-error.test.ts} +27 -27
  36. package/src/lib/runtime/agui-action.ts +3 -0
  37. package/src/lib/runtime/copilot-runtime.ts +42 -42
  38. package/src/lib/runtime/remote-actions.ts +3 -0
  39. package/dist/chunk-7F4BIRQF.mjs.map +0 -1
  40. /package/dist/{chunk-4ODT32DV.mjs.map → chunk-JIE2UKYM.mjs.map} +0 -0
  41. /package/dist/{chunk-BCDAWNNK.mjs.map → chunk-QSSQAW7A.mjs.map} +0 -0
  42. /package/dist/{chunk-R22NGLLV.mjs.map → chunk-RXWWTMSG.mjs.map} +0 -0
  43. /package/dist/{chunk-RBG2A675.mjs.map → chunk-Y6GPK3Y7.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.9.2-next.18
4
+
5
+ ### Patch Changes
6
+
7
+ - fac89c2: - refactor: rename onTrace to onError throughout codebase
8
+
9
+ - Rename CopilotTraceEvent to CopilotErrorEvent and CopilotTraceHandler to CopilotErrorHandler
10
+
11
+ - Updated dependencies [fac89c2]
12
+ - @copilotkit/shared@1.9.2-next.18
13
+
14
+ ## 1.9.2-next.17
15
+
16
+ ### Patch Changes
17
+
18
+ - 7ca7023: - feat: send node name to agui agent
19
+ - @copilotkit/shared@1.9.2-next.17
20
+
3
21
  ## 1.9.2-next.16
4
22
 
5
23
  ### Patch Changes
@@ -40,7 +40,7 @@ var require_package = __commonJS({
40
40
  publishConfig: {
41
41
  access: "public"
42
42
  },
43
- version: "1.9.2-next.16",
43
+ version: "1.9.2-next.18",
44
44
  sideEffects: false,
45
45
  main: "./dist/index.js",
46
46
  module: "./dist/index.mjs",
@@ -2735,8 +2735,8 @@ var CopilotRuntime = class {
2735
2735
  delegateAgentProcessingToServiceAdapter;
2736
2736
  observability;
2737
2737
  availableAgents;
2738
- onTrace;
2739
- hasWarnedAboutTracing = false;
2738
+ onError;
2739
+ hasWarnedAboutError = false;
2740
2740
  // +++ MCP Properties +++
2741
2741
  mcpServersConfig;
2742
2742
  mcpActionCache = /* @__PURE__ */ new Map();
@@ -2762,7 +2762,7 @@ var CopilotRuntime = class {
2762
2762
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
2763
2763
  this.observability = params == null ? void 0 : params.observability_c;
2764
2764
  this.agents = (params == null ? void 0 : params.agents) ?? {};
2765
- this.onTrace = params == null ? void 0 : params.onTrace;
2765
+ this.onError = params == null ? void 0 : params.onError;
2766
2766
  this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
2767
2767
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
2768
2768
  if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
@@ -2841,7 +2841,7 @@ var CopilotRuntime = class {
2841
2841
  const eventSource = new RuntimeEventSource();
2842
2842
  const requestStartTime = Date.now();
2843
2843
  const streamedChunks = [];
2844
- await this.trace("request", {
2844
+ await this.error("request", {
2845
2845
  threadId,
2846
2846
  runId,
2847
2847
  source: "runtime",
@@ -3037,7 +3037,7 @@ please use an LLM adapter instead.`
3037
3037
  } else {
3038
3038
  structuredError = ensureStructuredError2(error, (err) => this.convertStreamingErrorToStructured(err));
3039
3039
  }
3040
- await this.trace("error", {
3040
+ await this.error("error", {
3041
3041
  threadId,
3042
3042
  runId,
3043
3043
  source: "runtime",
@@ -3285,7 +3285,7 @@ please use an LLM adapter instead.`
3285
3285
  const requestStartTime = Date.now();
3286
3286
  const streamedChunks = [];
3287
3287
  const threadId = threadIdFromRequest ?? agentSession.threadId;
3288
- await this.trace("agent_state", {
3288
+ await this.error("agent_state", {
3289
3289
  threadId,
3290
3290
  source: "agent",
3291
3291
  request: {
@@ -3421,7 +3421,7 @@ please use an LLM adapter instead.`
3421
3421
  }
3422
3422
  }
3423
3423
  const structuredError = ensureStructuredError2(err, (error) => this.convertStreamingErrorToStructured(error));
3424
- await this.trace("error", {
3424
+ await this.error("error", {
3425
3425
  threadId,
3426
3426
  source: "agent",
3427
3427
  request: {
@@ -3510,7 +3510,7 @@ please use an LLM adapter instead.`
3510
3510
  }
3511
3511
  }
3512
3512
  const structuredError = ensureStructuredError2(error, (err) => this.convertStreamingErrorToStructured(err));
3513
- await this.trace("error", {
3513
+ await this.error("error", {
3514
3514
  threadId,
3515
3515
  source: "agent",
3516
3516
  request: {
@@ -3536,7 +3536,7 @@ please use an LLM adapter instead.`
3536
3536
  }
3537
3537
  }
3538
3538
  async getServerSideActions(request) {
3539
- var _a, _b;
3539
+ var _a, _b, _c;
3540
3540
  const { graphqlContext, messages: rawMessages, agentStates, url } = request;
3541
3541
  const inputMessages = convertGqlInputToMessages(rawMessages);
3542
3542
  const langserveFunctions = [];
@@ -3559,7 +3559,8 @@ please use an LLM adapter instead.`
3559
3559
  agentStates,
3560
3560
  frontendUrl: url,
3561
3561
  agents: this.agents,
3562
- metaEvents: request.metaEvents
3562
+ metaEvents: request.metaEvents,
3563
+ nodeName: (_a = request.agentSession) == null ? void 0 : _a.nodeName
3563
3564
  });
3564
3565
  const configuredActions = typeof this.actions === "function" ? this.actions({
3565
3566
  properties: graphqlContext.properties,
@@ -3568,7 +3569,7 @@ please use an LLM adapter instead.`
3568
3569
  const requestSpecificMCPActions = [];
3569
3570
  if (this.createMCPClientImpl) {
3570
3571
  const baseEndpoints = this.mcpServersConfig || [];
3571
- const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
3572
+ const requestEndpoints = ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpServers) || ((_c = graphqlContext.properties) == null ? void 0 : _c.mcpEndpoints) || [];
3572
3573
  const effectiveEndpointsMap = /* @__PURE__ */ new Map();
3573
3574
  [
3574
3575
  ...baseEndpoints
@@ -3641,18 +3642,18 @@ please use an LLM adapter instead.`
3641
3642
  code: CopilotKitErrorCode2.UNKNOWN
3642
3643
  });
3643
3644
  }
3644
- async trace(type, context, error, publicApiKey) {
3645
- if (!this.onTrace)
3645
+ async error(type, context, error, publicApiKey) {
3646
+ if (!this.onError)
3646
3647
  return;
3647
3648
  if (!publicApiKey) {
3648
- if (!this.hasWarnedAboutTracing) {
3649
- console.warn("CopilotKit: onTrace handler provided but requires publicApiKey to be defined for tracing to work.");
3650
- this.hasWarnedAboutTracing = true;
3649
+ if (!this.hasWarnedAboutError) {
3650
+ console.warn("CopilotKit: onError handler provided but requires publicApiKey to be defined for error handling to work.");
3651
+ this.hasWarnedAboutError = true;
3651
3652
  }
3652
3653
  return;
3653
3654
  }
3654
3655
  try {
3655
- const traceEvent = {
3656
+ const errorEvent = {
3656
3657
  type,
3657
3658
  timestamp: Date.now(),
3658
3659
  context,
@@ -3660,20 +3661,20 @@ please use an LLM adapter instead.`
3660
3661
  error
3661
3662
  }
3662
3663
  };
3663
- await this.onTrace(traceEvent);
3664
- } catch (traceError) {
3665
- console.error("Error in onTrace handler:", traceError);
3664
+ await this.onError(errorEvent);
3665
+ } catch (errorHandlerError) {
3666
+ console.error("Error in onError handler:", errorHandlerError);
3666
3667
  }
3667
3668
  }
3668
3669
  /**
3669
- * Public method to trace GraphQL validation errors
3670
- * This allows the GraphQL resolver to send validation errors through the trace system
3670
+ * Public method to handle GraphQL validation errors
3671
+ * This allows the GraphQL resolver to send validation errors through the error system
3671
3672
  */
3672
- async traceGraphQLError(error, context) {
3673
- if (!this.onTrace)
3673
+ async errorGraphQLError(error, context) {
3674
+ if (!this.onError)
3674
3675
  return;
3675
3676
  try {
3676
- await this.onTrace({
3677
+ await this.onError({
3677
3678
  type: "error",
3678
3679
  timestamp: Date.now(),
3679
3680
  context: {
@@ -3693,8 +3694,8 @@ please use an LLM adapter instead.`
3693
3694
  },
3694
3695
  error
3695
3696
  });
3696
- } catch (traceError) {
3697
- console.error("Error in onTrace handler:", traceError);
3697
+ } catch (errorHandlerError) {
3698
+ console.error("Error in onError handler:", errorHandlerError);
3698
3699
  }
3699
3700
  }
3700
3701
  };
@@ -4302,7 +4303,7 @@ import { CopilotKitLowLevelError as CopilotKitLowLevelError6, ResolvedCopilotKit
4302
4303
 
4303
4304
  // src/lib/runtime/agui-action.ts
4304
4305
  import { parseJson as parseJson3 } from "@copilotkit/shared";
4305
- function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, agent, metaEvents, threadMetadata }) {
4306
+ function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, agent, metaEvents, threadMetadata, nodeName }) {
4306
4307
  const action = {
4307
4308
  name: agent.agentId,
4308
4309
  description: agent.description,
@@ -4345,6 +4346,9 @@ function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, age
4345
4346
  } : {},
4346
4347
  ...threadMetadata ? {
4347
4348
  threadMetadata
4349
+ } : {},
4350
+ ...nodeName ? {
4351
+ nodeName
4348
4352
  } : {}
4349
4353
  };
4350
4354
  return agent.legacy_to_be_removed_runAgentBridged({
@@ -4460,7 +4464,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
4460
4464
  }
4461
4465
  }
4462
4466
  __name(fetchRemoteInfo, "fetchRemoteInfo");
4463
- async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents, metaEvents }) {
4467
+ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents, metaEvents, nodeName }) {
4464
4468
  var _a;
4465
4469
  const logger2 = graphqlContext.logger.child({
4466
4470
  component: "remote-actions.fetchRemoteActions"
@@ -4526,7 +4530,8 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
4526
4530
  agentStates,
4527
4531
  agent,
4528
4532
  metaEvents,
4529
- threadMetadata
4533
+ threadMetadata,
4534
+ nodeName
4530
4535
  }));
4531
4536
  }
4532
4537
  return result.flat();
@@ -5011,7 +5016,7 @@ var CopilotResolver = class {
5011
5016
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
5012
5017
  if (!copilotCloudPublicApiKey) {
5013
5018
  logger2.error("Public API key not found in headers");
5014
- await copilotRuntime.traceGraphQLError({
5019
+ await copilotRuntime.errorGraphQLError({
5015
5020
  message: "X-CopilotCloud-Public-API-Key header is required",
5016
5021
  code: "MISSING_PUBLIC_API_KEY",
5017
5022
  type: "GraphQLError"
@@ -5819,4 +5824,4 @@ export {
5819
5824
  getCommonConfig,
5820
5825
  copilotRuntimeNodeHttpEndpoint
5821
5826
  };
5822
- //# sourceMappingURL=chunk-7F4BIRQF.mjs.map
5827
+ //# sourceMappingURL=chunk-FW5UOGQ2.mjs.map