@copilotkit/runtime 1.9.2-next.17 → 1.9.2-next.19

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 (50) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-CORCJNXR.mjs → chunk-BTV2RM2X.mjs} +2 -2
  3. package/dist/{chunk-H3ML2MWF.mjs → chunk-EEARRKK3.mjs} +28 -28
  4. package/dist/chunk-EEARRKK3.mjs.map +1 -0
  5. package/dist/{chunk-7EDOHCIU.mjs → chunk-OVIDH7IH.mjs} +2 -2
  6. package/dist/{chunk-JTFQ5GIL.mjs → chunk-QLLV2QVK.mjs} +2 -1
  7. package/dist/chunk-QLLV2QVK.mjs.map +1 -0
  8. package/dist/{chunk-WXNKOOVD.mjs → chunk-QPMGUSMZ.mjs} +2 -2
  9. package/dist/{chunk-6QK2NO6W.mjs → chunk-ZNDOT3YP.mjs} +2 -2
  10. package/dist/{groq-adapter-172a2ca4.d.ts → groq-adapter-098f97f6.d.ts} +4 -0
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +27 -26
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +6 -6
  15. package/dist/lib/index.d.ts +2 -2
  16. package/dist/lib/index.js +27 -26
  17. package/dist/lib/index.js.map +1 -1
  18. package/dist/lib/index.mjs +6 -6
  19. package/dist/lib/integrations/index.d.ts +2 -2
  20. package/dist/lib/integrations/index.js +2 -2
  21. package/dist/lib/integrations/index.js.map +1 -1
  22. package/dist/lib/integrations/index.mjs +5 -5
  23. package/dist/lib/integrations/nest/index.d.ts +1 -1
  24. package/dist/lib/integrations/nest/index.js +2 -2
  25. package/dist/lib/integrations/nest/index.js.map +1 -1
  26. package/dist/lib/integrations/nest/index.mjs +3 -3
  27. package/dist/lib/integrations/node-express/index.d.ts +1 -1
  28. package/dist/lib/integrations/node-express/index.js +2 -2
  29. package/dist/lib/integrations/node-express/index.js.map +1 -1
  30. package/dist/lib/integrations/node-express/index.mjs +3 -3
  31. package/dist/lib/integrations/node-http/index.d.ts +1 -1
  32. package/dist/lib/integrations/node-http/index.js +2 -2
  33. package/dist/lib/integrations/node-http/index.js.map +1 -1
  34. package/dist/lib/integrations/node-http/index.mjs +2 -2
  35. package/dist/service-adapters/index.d.ts +2 -2
  36. package/dist/service-adapters/index.js +1 -0
  37. package/dist/service-adapters/index.js.map +1 -1
  38. package/dist/service-adapters/index.mjs +1 -1
  39. package/dist/{shared-4164c674.d.ts → shared-41d4988d.d.ts} +13 -13
  40. package/package.json +4 -4
  41. package/src/graphql/resolvers/copilot.resolver.ts +1 -2
  42. package/src/lib/runtime/__tests__/{copilot-runtime-trace.test.ts → copilot-runtime-error.test.ts} +27 -27
  43. package/src/lib/runtime/copilot-runtime.ts +41 -42
  44. package/src/service-adapters/google/google-genai-adapter.ts +5 -0
  45. package/dist/chunk-H3ML2MWF.mjs.map +0 -1
  46. package/dist/chunk-JTFQ5GIL.mjs.map +0 -1
  47. /package/dist/{chunk-CORCJNXR.mjs.map → chunk-BTV2RM2X.mjs.map} +0 -0
  48. /package/dist/{chunk-7EDOHCIU.mjs.map → chunk-OVIDH7IH.mjs.map} +0 -0
  49. /package/dist/{chunk-WXNKOOVD.mjs.map → chunk-QPMGUSMZ.mjs.map} +0 -0
  50. /package/dist/{chunk-6QK2NO6W.mjs.map → chunk-ZNDOT3YP.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-CORCJNXR.mjs";
4
+ } from "./chunk-BTV2RM2X.mjs";
5
5
  import {
6
6
  config,
7
7
  copilotRuntimeNextJSAppRouterEndpoint,
8
8
  copilotRuntimeNextJSPagesRouterEndpoint
9
- } from "./chunk-7EDOHCIU.mjs";
9
+ } from "./chunk-OVIDH7IH.mjs";
10
10
  import {
11
11
  copilotRuntimeNestEndpoint
12
- } from "./chunk-WXNKOOVD.mjs";
12
+ } from "./chunk-QPMGUSMZ.mjs";
13
13
  import {
14
14
  copilotRuntimeNodeExpressEndpoint
15
- } from "./chunk-6QK2NO6W.mjs";
15
+ } from "./chunk-ZNDOT3YP.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-H3ML2MWF.mjs";
31
+ } from "./chunk-EEARRKK3.mjs";
32
32
  import "./chunk-SHBDMA63.mjs";
33
33
  import {
34
34
  AnthropicAdapter,
@@ -43,7 +43,7 @@ import {
43
43
  OpenAIAssistantAdapter,
44
44
  RemoteChain,
45
45
  UnifyAdapter
46
- } from "./chunk-JTFQ5GIL.mjs";
46
+ } from "./chunk-QLLV2QVK.mjs";
47
47
  import {
48
48
  GuardrailsValidationFailureResponse,
49
49
  MessageStreamInterruptedResponse,
@@ -1,5 +1,5 @@
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';
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-098f97f6.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.17",
47
+ version: "1.9.2-next.19",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -830,6 +830,7 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
830
830
  return message.content && String(message.content).trim().length > 0 || message.tool_calls && message.tool_calls.length > 0;
831
831
  });
832
832
  const model = new import_google_gauth.ChatGoogle({
833
+ apiKey: (options == null ? void 0 : options.apiKey) ?? process.env.GOOGLE_API_KEY,
833
834
  modelName: (options == null ? void 0 : options.model) ?? "gemini-1.5-pro",
834
835
  apiVersion: "v1beta"
835
836
  }).bindTools(tools);
@@ -4251,8 +4252,8 @@ var CopilotRuntime = class {
4251
4252
  delegateAgentProcessingToServiceAdapter;
4252
4253
  observability;
4253
4254
  availableAgents;
4254
- onTrace;
4255
- hasWarnedAboutTracing = false;
4255
+ onError;
4256
+ hasWarnedAboutError = false;
4256
4257
  // +++ MCP Properties +++
4257
4258
  mcpServersConfig;
4258
4259
  mcpActionCache = /* @__PURE__ */ new Map();
@@ -4278,7 +4279,7 @@ var CopilotRuntime = class {
4278
4279
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
4279
4280
  this.observability = params == null ? void 0 : params.observability_c;
4280
4281
  this.agents = (params == null ? void 0 : params.agents) ?? {};
4281
- this.onTrace = params == null ? void 0 : params.onTrace;
4282
+ this.onError = params == null ? void 0 : params.onError;
4282
4283
  this.mcpServersConfig = params == null ? void 0 : params.mcpServers;
4283
4284
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
4284
4285
  if (this.mcpServersConfig && this.mcpServersConfig.length > 0 && !this.createMCPClientImpl) {
@@ -4357,7 +4358,7 @@ var CopilotRuntime = class {
4357
4358
  const eventSource = new RuntimeEventSource();
4358
4359
  const requestStartTime = Date.now();
4359
4360
  const streamedChunks = [];
4360
- await this.trace("request", {
4361
+ await this.error("request", {
4361
4362
  threadId,
4362
4363
  runId,
4363
4364
  source: "runtime",
@@ -4553,7 +4554,7 @@ please use an LLM adapter instead.`
4553
4554
  } else {
4554
4555
  structuredError = (0, import_shared15.ensureStructuredError)(error, (err) => this.convertStreamingErrorToStructured(err));
4555
4556
  }
4556
- await this.trace("error", {
4557
+ await this.error("error", {
4557
4558
  threadId,
4558
4559
  runId,
4559
4560
  source: "runtime",
@@ -4801,7 +4802,7 @@ please use an LLM adapter instead.`
4801
4802
  const requestStartTime = Date.now();
4802
4803
  const streamedChunks = [];
4803
4804
  const threadId = threadIdFromRequest ?? agentSession.threadId;
4804
- await this.trace("agent_state", {
4805
+ await this.error("agent_state", {
4805
4806
  threadId,
4806
4807
  source: "agent",
4807
4808
  request: {
@@ -4937,7 +4938,7 @@ please use an LLM adapter instead.`
4937
4938
  }
4938
4939
  }
4939
4940
  const structuredError = (0, import_shared15.ensureStructuredError)(err, (error) => this.convertStreamingErrorToStructured(error));
4940
- await this.trace("error", {
4941
+ await this.error("error", {
4941
4942
  threadId,
4942
4943
  source: "agent",
4943
4944
  request: {
@@ -5026,7 +5027,7 @@ please use an LLM adapter instead.`
5026
5027
  }
5027
5028
  }
5028
5029
  const structuredError = (0, import_shared15.ensureStructuredError)(error, (err) => this.convertStreamingErrorToStructured(err));
5029
- await this.trace("error", {
5030
+ await this.error("error", {
5030
5031
  threadId,
5031
5032
  source: "agent",
5032
5033
  request: {
@@ -5158,18 +5159,18 @@ please use an LLM adapter instead.`
5158
5159
  code: import_shared15.CopilotKitErrorCode.UNKNOWN
5159
5160
  });
5160
5161
  }
5161
- async trace(type, context, error, publicApiKey) {
5162
- if (!this.onTrace)
5162
+ async error(type, context, error, publicApiKey) {
5163
+ if (!this.onError)
5163
5164
  return;
5164
5165
  if (!publicApiKey) {
5165
- if (!this.hasWarnedAboutTracing) {
5166
- console.warn("CopilotKit: onTrace handler provided but requires publicApiKey to be defined for tracing to work.");
5167
- this.hasWarnedAboutTracing = true;
5166
+ if (!this.hasWarnedAboutError) {
5167
+ console.warn("CopilotKit: onError handler provided but requires publicApiKey to be defined for error handling to work.");
5168
+ this.hasWarnedAboutError = true;
5168
5169
  }
5169
5170
  return;
5170
5171
  }
5171
5172
  try {
5172
- const traceEvent = {
5173
+ const errorEvent = {
5173
5174
  type,
5174
5175
  timestamp: Date.now(),
5175
5176
  context,
@@ -5177,20 +5178,20 @@ please use an LLM adapter instead.`
5177
5178
  error
5178
5179
  }
5179
5180
  };
5180
- await this.onTrace(traceEvent);
5181
- } catch (traceError) {
5182
- console.error("Error in onTrace handler:", traceError);
5181
+ await this.onError(errorEvent);
5182
+ } catch (errorHandlerError) {
5183
+ console.error("Error in onError handler:", errorHandlerError);
5183
5184
  }
5184
5185
  }
5185
5186
  /**
5186
- * Public method to trace GraphQL validation errors
5187
- * This allows the GraphQL resolver to send validation errors through the trace system
5187
+ * Public method to handle GraphQL validation errors
5188
+ * This allows the GraphQL resolver to send validation errors through the error system
5188
5189
  */
5189
- async traceGraphQLError(error, context) {
5190
- if (!this.onTrace)
5190
+ async errorGraphQLError(error, context) {
5191
+ if (!this.onError)
5191
5192
  return;
5192
5193
  try {
5193
- await this.onTrace({
5194
+ await this.onError({
5194
5195
  type: "error",
5195
5196
  timestamp: Date.now(),
5196
5197
  context: {
@@ -5210,8 +5211,8 @@ please use an LLM adapter instead.`
5210
5211
  },
5211
5212
  error
5212
5213
  });
5213
- } catch (traceError) {
5214
- console.error("Error in onTrace handler:", traceError);
5214
+ } catch (errorHandlerError) {
5215
+ console.error("Error in onError handler:", errorHandlerError);
5215
5216
  }
5216
5217
  }
5217
5218
  };
@@ -6568,7 +6569,7 @@ var CopilotResolver = class {
6568
6569
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
6569
6570
  if (!copilotCloudPublicApiKey) {
6570
6571
  logger2.error("Public API key not found in headers");
6571
- await copilotRuntime.traceGraphQLError({
6572
+ await copilotRuntime.errorGraphQLError({
6572
6573
  message: "X-CopilotCloud-Public-API-Key header is required",
6573
6574
  code: "MISSING_PUBLIC_API_KEY",
6574
6575
  type: "GraphQLError"