@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/dist/index.mjs CHANGED
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  CustomEventNames,
3
3
  LangGraphAgent
4
- } from "./chunk-R22NGLLV.mjs";
4
+ } from "./chunk-RXWWTMSG.mjs";
5
5
  import {
6
6
  config,
7
7
  copilotRuntimeNextJSAppRouterEndpoint,
8
8
  copilotRuntimeNextJSPagesRouterEndpoint
9
- } from "./chunk-RBG2A675.mjs";
9
+ } from "./chunk-Y6GPK3Y7.mjs";
10
10
  import {
11
11
  copilotRuntimeNestEndpoint
12
- } from "./chunk-BCDAWNNK.mjs";
12
+ } from "./chunk-QSSQAW7A.mjs";
13
13
  import {
14
14
  copilotRuntimeNodeExpressEndpoint
15
- } from "./chunk-4ODT32DV.mjs";
15
+ } from "./chunk-JIE2UKYM.mjs";
16
16
  import {
17
17
  CopilotRuntime,
18
18
  addCustomHeaderPlugin,
@@ -28,7 +28,7 @@ import {
28
28
  getCommonConfig,
29
29
  langGraphPlatformEndpoint,
30
30
  resolveEndpointType
31
- } from "./chunk-7F4BIRQF.mjs";
31
+ } from "./chunk-FW5UOGQ2.mjs";
32
32
  import "./chunk-SHBDMA63.mjs";
33
33
  import {
34
34
  AnthropicAdapter,
@@ -1,5 +1,5 @@
1
1
  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-172a2ca4.js';
2
- export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-4164c674.js';
2
+ export { e as CommonConfig, C as CopilotRequestContextProperties, k as CopilotRuntime, j as CopilotRuntimeConstructorParams, f as CopilotRuntimeLogger, i as CopilotRuntimeRequest, b as CreateCopilotRuntimeServerOptions, G as GraphQLContext, L as LogLevel, o as MCPClient, p as MCPEndpointConfig, M as MCPTool, a as addCustomHeaderPlugin, d as buildSchema, s as convertMCPToolsToActions, m as copilotKitEndpoint, c as createContext, h as createLogger, q as extractParametersFromSchema, l as flattenToolCallsNoDuplicates, t as generateMcpToolInstructions, g as getCommonConfig, n as langGraphPlatformEndpoint, r as resolveEndpointType } from '../shared-41d4988d.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';
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.9.2-next.16",
47
+ version: "1.9.2-next.18",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -4251,8 +4251,8 @@ var CopilotRuntime = class {
4251
4251
  delegateAgentProcessingToServiceAdapter;
4252
4252
  observability;
4253
4253
  availableAgents;
4254
- onTrace;
4255
- hasWarnedAboutTracing = false;
4254
+ onError;
4255
+ hasWarnedAboutError = false;
4256
4256
  // +++ MCP Properties +++
4257
4257
  mcpServersConfig;
4258
4258
  mcpActionCache = /* @__PURE__ */ new Map();
@@ -4278,7 +4278,7 @@ var CopilotRuntime = class {
4278
4278
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
4279
4279
  this.observability = params == null ? void 0 : params.observability_c;
4280
4280
  this.agents = (params == null ? void 0 : params.agents) ?? {};
4281
- this.onTrace = params == null ? void 0 : params.onTrace;
4281
+ this.onError = params == null ? void 0 : params.onError;
4282
4282
  this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
4283
4283
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
4284
4284
  if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
@@ -4357,7 +4357,7 @@ var CopilotRuntime = class {
4357
4357
  const eventSource = new RuntimeEventSource();
4358
4358
  const requestStartTime = Date.now();
4359
4359
  const streamedChunks = [];
4360
- await this.trace("request", {
4360
+ await this.error("request", {
4361
4361
  threadId,
4362
4362
  runId,
4363
4363
  source: "runtime",
@@ -4553,7 +4553,7 @@ please use an LLM adapter instead.`
4553
4553
  } else {
4554
4554
  structuredError = (0, import_shared15.ensureStructuredError)(error, (err) => this.convertStreamingErrorToStructured(err));
4555
4555
  }
4556
- await this.trace("error", {
4556
+ await this.error("error", {
4557
4557
  threadId,
4558
4558
  runId,
4559
4559
  source: "runtime",
@@ -4801,7 +4801,7 @@ please use an LLM adapter instead.`
4801
4801
  const requestStartTime = Date.now();
4802
4802
  const streamedChunks = [];
4803
4803
  const threadId = threadIdFromRequest ?? agentSession.threadId;
4804
- await this.trace("agent_state", {
4804
+ await this.error("agent_state", {
4805
4805
  threadId,
4806
4806
  source: "agent",
4807
4807
  request: {
@@ -4937,7 +4937,7 @@ please use an LLM adapter instead.`
4937
4937
  }
4938
4938
  }
4939
4939
  const structuredError = (0, import_shared15.ensureStructuredError)(err, (error) => this.convertStreamingErrorToStructured(error));
4940
- await this.trace("error", {
4940
+ await this.error("error", {
4941
4941
  threadId,
4942
4942
  source: "agent",
4943
4943
  request: {
@@ -5026,7 +5026,7 @@ please use an LLM adapter instead.`
5026
5026
  }
5027
5027
  }
5028
5028
  const structuredError = (0, import_shared15.ensureStructuredError)(error, (err) => this.convertStreamingErrorToStructured(err));
5029
- await this.trace("error", {
5029
+ await this.error("error", {
5030
5030
  threadId,
5031
5031
  source: "agent",
5032
5032
  request: {
@@ -5052,7 +5052,7 @@ please use an LLM adapter instead.`
5052
5052
  }
5053
5053
  }
5054
5054
  async getServerSideActions(request) {
5055
- var _a, _b;
5055
+ var _a, _b, _c;
5056
5056
  const { graphqlContext, messages: rawMessages, agentStates, url } = request;
5057
5057
  const inputMessages = convertGqlInputToMessages(rawMessages);
5058
5058
  const langserveFunctions = [];
@@ -5075,7 +5075,8 @@ please use an LLM adapter instead.`
5075
5075
  agentStates,
5076
5076
  frontendUrl: url,
5077
5077
  agents: this.agents,
5078
- metaEvents: request.metaEvents
5078
+ metaEvents: request.metaEvents,
5079
+ nodeName: (_a = request.agentSession) == null ? void 0 : _a.nodeName
5079
5080
  });
5080
5081
  const configuredActions = typeof this.actions === "function" ? this.actions({
5081
5082
  properties: graphqlContext.properties,
@@ -5084,7 +5085,7 @@ please use an LLM adapter instead.`
5084
5085
  const requestSpecificMCPActions = [];
5085
5086
  if (this.createMCPClientImpl) {
5086
5087
  const baseEndpoints = this.mcpServersConfig || [];
5087
- const requestEndpoints = ((_a = graphqlContext.properties) == null ? void 0 : _a.mcpServers) || ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpEndpoints) || [];
5088
+ const requestEndpoints = ((_b = graphqlContext.properties) == null ? void 0 : _b.mcpServers) || ((_c = graphqlContext.properties) == null ? void 0 : _c.mcpEndpoints) || [];
5088
5089
  const effectiveEndpointsMap = /* @__PURE__ */ new Map();
5089
5090
  [
5090
5091
  ...baseEndpoints
@@ -5157,18 +5158,18 @@ please use an LLM adapter instead.`
5157
5158
  code: import_shared15.CopilotKitErrorCode.UNKNOWN
5158
5159
  });
5159
5160
  }
5160
- async trace(type, context, error, publicApiKey) {
5161
- if (!this.onTrace)
5161
+ async error(type, context, error, publicApiKey) {
5162
+ if (!this.onError)
5162
5163
  return;
5163
5164
  if (!publicApiKey) {
5164
- if (!this.hasWarnedAboutTracing) {
5165
- console.warn("CopilotKit: onTrace handler provided but requires publicApiKey to be defined for tracing to work.");
5166
- this.hasWarnedAboutTracing = true;
5165
+ if (!this.hasWarnedAboutError) {
5166
+ console.warn("CopilotKit: onError handler provided but requires publicApiKey to be defined for error handling to work.");
5167
+ this.hasWarnedAboutError = true;
5167
5168
  }
5168
5169
  return;
5169
5170
  }
5170
5171
  try {
5171
- const traceEvent = {
5172
+ const errorEvent = {
5172
5173
  type,
5173
5174
  timestamp: Date.now(),
5174
5175
  context,
@@ -5176,20 +5177,20 @@ please use an LLM adapter instead.`
5176
5177
  error
5177
5178
  }
5178
5179
  };
5179
- await this.onTrace(traceEvent);
5180
- } catch (traceError) {
5181
- console.error("Error in onTrace handler:", traceError);
5180
+ await this.onError(errorEvent);
5181
+ } catch (errorHandlerError) {
5182
+ console.error("Error in onError handler:", errorHandlerError);
5182
5183
  }
5183
5184
  }
5184
5185
  /**
5185
- * Public method to trace GraphQL validation errors
5186
- * This allows the GraphQL resolver to send validation errors through the trace system
5186
+ * Public method to handle GraphQL validation errors
5187
+ * This allows the GraphQL resolver to send validation errors through the error system
5187
5188
  */
5188
- async traceGraphQLError(error, context) {
5189
- if (!this.onTrace)
5189
+ async errorGraphQLError(error, context) {
5190
+ if (!this.onError)
5190
5191
  return;
5191
5192
  try {
5192
- await this.onTrace({
5193
+ await this.onError({
5193
5194
  type: "error",
5194
5195
  timestamp: Date.now(),
5195
5196
  context: {
@@ -5209,8 +5210,8 @@ please use an LLM adapter instead.`
5209
5210
  },
5210
5211
  error
5211
5212
  });
5212
- } catch (traceError) {
5213
- console.error("Error in onTrace handler:", traceError);
5213
+ } catch (errorHandlerError) {
5214
+ console.error("Error in onError handler:", errorHandlerError);
5214
5215
  }
5215
5216
  }
5216
5217
  };
@@ -5818,7 +5819,7 @@ var import_shared23 = require("@copilotkit/shared");
5818
5819
 
5819
5820
  // src/lib/runtime/agui-action.ts
5820
5821
  var import_shared21 = require("@copilotkit/shared");
5821
- function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, agent, metaEvents, threadMetadata }) {
5822
+ function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, agent, metaEvents, threadMetadata, nodeName }) {
5822
5823
  const action = {
5823
5824
  name: agent.agentId,
5824
5825
  description: agent.description,
@@ -5861,6 +5862,9 @@ function constructAGUIRemoteAction({ logger: logger2, messages, agentStates, age
5861
5862
  } : {},
5862
5863
  ...threadMetadata ? {
5863
5864
  threadMetadata
5865
+ } : {},
5866
+ ...nodeName ? {
5867
+ nodeName
5864
5868
  } : {}
5865
5869
  };
5866
5870
  return agent.legacy_to_be_removed_runAgentBridged({
@@ -5976,7 +5980,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
5976
5980
  }
5977
5981
  }
5978
5982
  __name(fetchRemoteInfo, "fetchRemoteInfo");
5979
- async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents, metaEvents }) {
5983
+ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents, metaEvents, nodeName }) {
5980
5984
  var _a;
5981
5985
  const logger2 = graphqlContext.logger.child({
5982
5986
  component: "remote-actions.fetchRemoteActions"
@@ -6042,7 +6046,8 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
6042
6046
  agentStates,
6043
6047
  agent,
6044
6048
  metaEvents,
6045
- threadMetadata
6049
+ threadMetadata,
6050
+ nodeName
6046
6051
  }));
6047
6052
  }
6048
6053
  return result.flat();
@@ -6563,7 +6568,7 @@ var CopilotResolver = class {
6563
6568
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
6564
6569
  if (!copilotCloudPublicApiKey) {
6565
6570
  logger2.error("Public API key not found in headers");
6566
- await copilotRuntime.traceGraphQLError({
6571
+ await copilotRuntime.errorGraphQLError({
6567
6572
  message: "X-CopilotCloud-Public-API-Key header is required",
6568
6573
  code: "MISSING_PUBLIC_API_KEY",
6569
6574
  type: "GraphQLError"