@copilotkit/runtime 1.9.2-next.17 → 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 (41) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{chunk-H3ML2MWF.mjs → chunk-FW5UOGQ2.mjs} +27 -27
  3. package/dist/chunk-FW5UOGQ2.mjs.map +1 -0
  4. package/dist/{chunk-6QK2NO6W.mjs → chunk-JIE2UKYM.mjs} +2 -2
  5. package/dist/{chunk-WXNKOOVD.mjs → chunk-QSSQAW7A.mjs} +2 -2
  6. package/dist/{chunk-CORCJNXR.mjs → chunk-RXWWTMSG.mjs} +2 -2
  7. package/dist/{chunk-7EDOHCIU.mjs → chunk-Y6GPK3Y7.mjs} +2 -2
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +26 -26
  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 +26 -26
  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/copilot-runtime.ts +41 -42
  37. package/dist/chunk-H3ML2MWF.mjs.map +0 -1
  38. /package/dist/{chunk-6QK2NO6W.mjs.map → chunk-JIE2UKYM.mjs.map} +0 -0
  39. /package/dist/{chunk-WXNKOOVD.mjs.map → chunk-QSSQAW7A.mjs.map} +0 -0
  40. /package/dist/{chunk-CORCJNXR.mjs.map → chunk-RXWWTMSG.mjs.map} +0 -0
  41. /package/dist/{chunk-7EDOHCIU.mjs.map → chunk-Y6GPK3Y7.mjs.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-H3ML2MWF.mjs";
5
+ } from "./chunk-FW5UOGQ2.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-6QK2NO6W.mjs.map
25
+ //# sourceMappingURL=chunk-JIE2UKYM.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-H3ML2MWF.mjs";
5
+ } from "./chunk-FW5UOGQ2.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-WXNKOOVD.mjs.map
25
+ //# sourceMappingURL=chunk-QSSQAW7A.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LangGraphEventTypes
3
- } from "./chunk-H3ML2MWF.mjs";
3
+ } from "./chunk-FW5UOGQ2.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-CORCJNXR.mjs.map
158
+ //# sourceMappingURL=chunk-RXWWTMSG.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-H3ML2MWF.mjs";
5
+ } from "./chunk-FW5UOGQ2.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-7EDOHCIU.mjs.map
80
+ //# sourceMappingURL=chunk-Y6GPK3Y7.mjs.map
package/dist/index.d.ts CHANGED
@@ -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 './lib/integrations/index.js';
4
4
  export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
5
5
  export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
package/dist/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.17",
47
+ version: "1.9.2-next.18",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -4705,8 +4705,8 @@ var CopilotRuntime = class {
4705
4705
  delegateAgentProcessingToServiceAdapter;
4706
4706
  observability;
4707
4707
  availableAgents;
4708
- onTrace;
4709
- hasWarnedAboutTracing = false;
4708
+ onError;
4709
+ hasWarnedAboutError = false;
4710
4710
  // +++ MCP Properties +++
4711
4711
  mcpServersConfig;
4712
4712
  mcpActionCache = /* @__PURE__ */ new Map();
@@ -4732,7 +4732,7 @@ var CopilotRuntime = class {
4732
4732
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
4733
4733
  this.observability = params == null ? void 0 : params.observability_c;
4734
4734
  this.agents = (params == null ? void 0 : params.agents) ?? {};
4735
- this.onTrace = params == null ? void 0 : params.onTrace;
4735
+ this.onError = params == null ? void 0 : params.onError;
4736
4736
  this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
4737
4737
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
4738
4738
  if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
@@ -4811,7 +4811,7 @@ var CopilotRuntime = class {
4811
4811
  const eventSource = new RuntimeEventSource();
4812
4812
  const requestStartTime = Date.now();
4813
4813
  const streamedChunks = [];
4814
- await this.trace("request", {
4814
+ await this.error("request", {
4815
4815
  threadId,
4816
4816
  runId,
4817
4817
  source: "runtime",
@@ -5007,7 +5007,7 @@ please use an LLM adapter instead.`
5007
5007
  } else {
5008
5008
  structuredError = (0, import_shared18.ensureStructuredError)(error, (err) => this.convertStreamingErrorToStructured(err));
5009
5009
  }
5010
- await this.trace("error", {
5010
+ await this.error("error", {
5011
5011
  threadId,
5012
5012
  runId,
5013
5013
  source: "runtime",
@@ -5255,7 +5255,7 @@ please use an LLM adapter instead.`
5255
5255
  const requestStartTime = Date.now();
5256
5256
  const streamedChunks = [];
5257
5257
  const threadId = threadIdFromRequest ?? agentSession.threadId;
5258
- await this.trace("agent_state", {
5258
+ await this.error("agent_state", {
5259
5259
  threadId,
5260
5260
  source: "agent",
5261
5261
  request: {
@@ -5391,7 +5391,7 @@ please use an LLM adapter instead.`
5391
5391
  }
5392
5392
  }
5393
5393
  const structuredError = (0, import_shared18.ensureStructuredError)(err, (error) => this.convertStreamingErrorToStructured(error));
5394
- await this.trace("error", {
5394
+ await this.error("error", {
5395
5395
  threadId,
5396
5396
  source: "agent",
5397
5397
  request: {
@@ -5480,7 +5480,7 @@ please use an LLM adapter instead.`
5480
5480
  }
5481
5481
  }
5482
5482
  const structuredError = (0, import_shared18.ensureStructuredError)(error, (err) => this.convertStreamingErrorToStructured(err));
5483
- await this.trace("error", {
5483
+ await this.error("error", {
5484
5484
  threadId,
5485
5485
  source: "agent",
5486
5486
  request: {
@@ -5612,18 +5612,18 @@ please use an LLM adapter instead.`
5612
5612
  code: import_shared18.CopilotKitErrorCode.UNKNOWN
5613
5613
  });
5614
5614
  }
5615
- async trace(type, context, error, publicApiKey) {
5616
- if (!this.onTrace)
5615
+ async error(type, context, error, publicApiKey) {
5616
+ if (!this.onError)
5617
5617
  return;
5618
5618
  if (!publicApiKey) {
5619
- if (!this.hasWarnedAboutTracing) {
5620
- console.warn("CopilotKit: onTrace handler provided but requires publicApiKey to be defined for tracing to work.");
5621
- this.hasWarnedAboutTracing = true;
5619
+ if (!this.hasWarnedAboutError) {
5620
+ console.warn("CopilotKit: onError handler provided but requires publicApiKey to be defined for error handling to work.");
5621
+ this.hasWarnedAboutError = true;
5622
5622
  }
5623
5623
  return;
5624
5624
  }
5625
5625
  try {
5626
- const traceEvent = {
5626
+ const errorEvent = {
5627
5627
  type,
5628
5628
  timestamp: Date.now(),
5629
5629
  context,
@@ -5631,20 +5631,20 @@ please use an LLM adapter instead.`
5631
5631
  error
5632
5632
  }
5633
5633
  };
5634
- await this.onTrace(traceEvent);
5635
- } catch (traceError) {
5636
- console.error("Error in onTrace handler:", traceError);
5634
+ await this.onError(errorEvent);
5635
+ } catch (errorHandlerError) {
5636
+ console.error("Error in onError handler:", errorHandlerError);
5637
5637
  }
5638
5638
  }
5639
5639
  /**
5640
- * Public method to trace GraphQL validation errors
5641
- * This allows the GraphQL resolver to send validation errors through the trace system
5640
+ * Public method to handle GraphQL validation errors
5641
+ * This allows the GraphQL resolver to send validation errors through the error system
5642
5642
  */
5643
- async traceGraphQLError(error, context) {
5644
- if (!this.onTrace)
5643
+ async errorGraphQLError(error, context) {
5644
+ if (!this.onError)
5645
5645
  return;
5646
5646
  try {
5647
- await this.onTrace({
5647
+ await this.onError({
5648
5648
  type: "error",
5649
5649
  timestamp: Date.now(),
5650
5650
  context: {
@@ -5664,8 +5664,8 @@ please use an LLM adapter instead.`
5664
5664
  },
5665
5665
  error
5666
5666
  });
5667
- } catch (traceError) {
5668
- console.error("Error in onTrace handler:", traceError);
5667
+ } catch (errorHandlerError) {
5668
+ console.error("Error in onError handler:", errorHandlerError);
5669
5669
  }
5670
5670
  }
5671
5671
  };
@@ -7022,7 +7022,7 @@ var CopilotResolver = class {
7022
7022
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
7023
7023
  if (!copilotCloudPublicApiKey) {
7024
7024
  logger2.error("Public API key not found in headers");
7025
- await copilotRuntime.traceGraphQLError({
7025
+ await copilotRuntime.errorGraphQLError({
7026
7026
  message: "X-CopilotCloud-Public-API-Key header is required",
7027
7027
  code: "MISSING_PUBLIC_API_KEY",
7028
7028
  type: "GraphQLError"