@copilotkit/runtime 1.9.2-next.3 → 1.9.2-next.5

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 +17 -0
  2. package/dist/{chunk-N24X5I3C.mjs → chunk-5WRXYU4R.mjs} +2 -2
  3. package/dist/{chunk-XDBXF3Q6.mjs → chunk-BLBS3CQH.mjs} +2 -2
  4. package/dist/{chunk-MIPAKFI5.mjs → chunk-RK7WRNH6.mjs} +2 -2
  5. package/dist/{chunk-WFYPJXWX.mjs → chunk-T4U5EWYD.mjs} +2 -2
  6. package/dist/{chunk-GSYE3DGY.mjs → chunk-ZVJSUAD7.mjs} +197 -16
  7. package/dist/chunk-ZVJSUAD7.mjs.map +1 -0
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +196 -15
  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 +196 -15
  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 +19 -10
  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 +19 -10
  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 +19 -10
  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 +19 -10
  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-e272b15a.d.ts → shared-ba062831.d.ts} +35 -1
  33. package/package.json +2 -2
  34. package/src/graphql/resolvers/copilot.resolver.ts +24 -5
  35. package/src/lib/runtime/__tests__/copilot-runtime-trace.test.ts +169 -0
  36. package/src/lib/runtime/copilot-runtime.ts +254 -6
  37. package/dist/chunk-GSYE3DGY.mjs.map +0 -1
  38. /package/dist/{chunk-N24X5I3C.mjs.map → chunk-5WRXYU4R.mjs.map} +0 -0
  39. /package/dist/{chunk-XDBXF3Q6.mjs.map → chunk-BLBS3CQH.mjs.map} +0 -0
  40. /package/dist/{chunk-MIPAKFI5.mjs.map → chunk-RK7WRNH6.mjs.map} +0 -0
  41. /package/dist/{chunk-WFYPJXWX.mjs.map → chunk-T4U5EWYD.mjs.map} +0 -0
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  CustomEventNames,
3
3
  LangGraphAgent
4
- } from "../chunk-XDBXF3Q6.mjs";
4
+ } from "../chunk-BLBS3CQH.mjs";
5
5
  import {
6
6
  config,
7
7
  copilotRuntimeNextJSAppRouterEndpoint,
8
8
  copilotRuntimeNextJSPagesRouterEndpoint
9
- } from "../chunk-WFYPJXWX.mjs";
9
+ } from "../chunk-T4U5EWYD.mjs";
10
10
  import {
11
11
  copilotRuntimeNestEndpoint
12
- } from "../chunk-MIPAKFI5.mjs";
12
+ } from "../chunk-RK7WRNH6.mjs";
13
13
  import {
14
14
  copilotRuntimeNodeExpressEndpoint
15
- } from "../chunk-N24X5I3C.mjs";
15
+ } from "../chunk-5WRXYU4R.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-GSYE3DGY.mjs";
31
+ } from "../chunk-ZVJSUAD7.mjs";
32
32
  import {
33
33
  GoogleGenerativeAIAdapter,
34
34
  GroqAdapter,
@@ -1,5 +1,5 @@
1
- import { b as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../shared-e272b15a.js';
2
- export { e as CommonConfig, C as CopilotRequestContextProperties, a as addCustomHeaderPlugin, d as buildSchema, c as createContext, g as getCommonConfig } from '../../shared-e272b15a.js';
1
+ import { b as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../shared-ba062831.js';
2
+ export { e as CommonConfig, C as CopilotRequestContextProperties, a as addCustomHeaderPlugin, d as buildSchema, c as createContext, g as getCommonConfig } from '../../shared-ba062831.js';
3
3
  import * as graphql_yoga from 'graphql-yoga';
4
4
  import { YogaServerInstance } from 'graphql-yoga';
5
5
  export { copilotRuntimeNodeHttpEndpoint } from './node-http/index.js';
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.9.2-next.3",
47
+ version: "1.9.2-next.5",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -2073,7 +2073,7 @@ var CopilotResolver = class {
2073
2073
  };
2074
2074
  }
2075
2075
  async generateCopilotResponse(ctx, data, properties) {
2076
- var _a, _b, _c, _d;
2076
+ var _a, _b, _c, _d, _e;
2077
2077
  telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2078
2078
  "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2079
2079
  requestType: data.metadata.requestType,
@@ -2104,23 +2104,32 @@ var CopilotResolver = class {
2104
2104
  const serviceAdapter = ctx._copilotkit.serviceAdapter;
2105
2105
  let copilotCloudPublicApiKey = null;
2106
2106
  let copilotCloudBaseUrl;
2107
+ const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
2108
+ if (publicApiKeyFromHeaders) {
2109
+ copilotCloudPublicApiKey = publicApiKeyFromHeaders;
2110
+ }
2107
2111
  if (data.cloud) {
2108
2112
  logger2 = logger2.child({
2109
2113
  cloud: true
2110
2114
  });
2111
2115
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
2112
- const key = ctx.request.headers.get("x-copilotcloud-public-api-key");
2113
- if (key) {
2114
- logger2.debug("Public API key found in headers");
2115
- copilotCloudPublicApiKey = key;
2116
- } else {
2116
+ if (!copilotCloudPublicApiKey) {
2117
2117
  logger2.error("Public API key not found in headers");
2118
+ await copilotRuntime.traceGraphQLError({
2119
+ message: "X-CopilotCloud-Public-API-Key header is required",
2120
+ code: "MISSING_PUBLIC_API_KEY",
2121
+ type: "GraphQLError"
2122
+ }, {
2123
+ operation: "generateCopilotResponse",
2124
+ cloudConfigPresent: Boolean(data.cloud),
2125
+ guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
2126
+ });
2118
2127
  throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2119
2128
  }
2120
2129
  if (process.env.COPILOT_CLOUD_BASE_URL) {
2121
2130
  copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2122
- } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2123
- copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2131
+ } else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
2132
+ copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
2124
2133
  } else {
2125
2134
  copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2126
2135
  }
@@ -2162,7 +2171,7 @@ var CopilotResolver = class {
2162
2171
  logger2.debug("Event source created, creating response");
2163
2172
  const eventStream = eventSource.processRuntimeEvents({
2164
2173
  serverSideActions,
2165
- guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2174
+ guardrailsResult$: ((_e = data.cloud) == null ? void 0 : _e.guardrails) ? guardrailsResult$ : null,
2166
2175
  actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2167
2176
  // TODO-AGENTS: do not exclude ALL server side actions
2168
2177
  (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)