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

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-XDBXF3Q6.mjs → chunk-5FNEYAWH.mjs} +2 -2
  3. package/dist/{chunk-N24X5I3C.mjs → chunk-6W7TKZNY.mjs} +2 -2
  4. package/dist/{chunk-MIPAKFI5.mjs → chunk-CJ44W4R2.mjs} +2 -2
  5. package/dist/{chunk-WFYPJXWX.mjs → chunk-NK2XARWT.mjs} +2 -2
  6. package/dist/{chunk-GSYE3DGY.mjs → chunk-ZUF3A5TW.mjs} +197 -16
  7. package/dist/chunk-ZUF3A5TW.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-XDBXF3Q6.mjs.map → chunk-5FNEYAWH.mjs.map} +0 -0
  39. /package/dist/{chunk-N24X5I3C.mjs.map → chunk-6W7TKZNY.mjs.map} +0 -0
  40. /package/dist/{chunk-MIPAKFI5.mjs.map → chunk-CJ44W4R2.mjs.map} +0 -0
  41. /package/dist/{chunk-WFYPJXWX.mjs.map → chunk-NK2XARWT.mjs.map} +0 -0
@@ -2,20 +2,20 @@ import {
2
2
  config,
3
3
  copilotRuntimeNextJSAppRouterEndpoint,
4
4
  copilotRuntimeNextJSPagesRouterEndpoint
5
- } from "../../chunk-WFYPJXWX.mjs";
5
+ } from "../../chunk-NK2XARWT.mjs";
6
6
  import {
7
7
  copilotRuntimeNestEndpoint
8
- } from "../../chunk-MIPAKFI5.mjs";
8
+ } from "../../chunk-CJ44W4R2.mjs";
9
9
  import {
10
10
  copilotRuntimeNodeExpressEndpoint
11
- } from "../../chunk-N24X5I3C.mjs";
11
+ } from "../../chunk-6W7TKZNY.mjs";
12
12
  import {
13
13
  addCustomHeaderPlugin,
14
14
  buildSchema,
15
15
  copilotRuntimeNodeHttpEndpoint,
16
16
  createContext,
17
17
  getCommonConfig
18
- } from "../../chunk-GSYE3DGY.mjs";
18
+ } from "../../chunk-ZUF3A5TW.mjs";
19
19
  import "../../chunk-IIXJVVTV.mjs";
20
20
  import "../../chunk-5BIEM2UU.mjs";
21
21
  import "../../chunk-SHBDMA63.mjs";
@@ -1,5 +1,5 @@
1
1
  import * as graphql_yoga from 'graphql-yoga';
2
- import { b as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../../shared-e272b15a.js';
2
+ import { b as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../../shared-ba062831.js';
3
3
  import 'graphql';
4
4
  import 'pino';
5
5
  import '@copilotkit/shared';
@@ -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.4",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -2067,7 +2067,7 @@ var CopilotResolver = class {
2067
2067
  };
2068
2068
  }
2069
2069
  async generateCopilotResponse(ctx, data, properties) {
2070
- var _a, _b, _c, _d;
2070
+ var _a, _b, _c, _d, _e;
2071
2071
  telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2072
2072
  "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2073
2073
  requestType: data.metadata.requestType,
@@ -2098,23 +2098,32 @@ var CopilotResolver = class {
2098
2098
  const serviceAdapter = ctx._copilotkit.serviceAdapter;
2099
2099
  let copilotCloudPublicApiKey = null;
2100
2100
  let copilotCloudBaseUrl;
2101
+ const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
2102
+ if (publicApiKeyFromHeaders) {
2103
+ copilotCloudPublicApiKey = publicApiKeyFromHeaders;
2104
+ }
2101
2105
  if (data.cloud) {
2102
2106
  logger2 = logger2.child({
2103
2107
  cloud: true
2104
2108
  });
2105
2109
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
2106
- const key = ctx.request.headers.get("x-copilotcloud-public-api-key");
2107
- if (key) {
2108
- logger2.debug("Public API key found in headers");
2109
- copilotCloudPublicApiKey = key;
2110
- } else {
2110
+ if (!copilotCloudPublicApiKey) {
2111
2111
  logger2.error("Public API key not found in headers");
2112
+ await copilotRuntime.traceGraphQLError({
2113
+ message: "X-CopilotCloud-Public-API-Key header is required",
2114
+ code: "MISSING_PUBLIC_API_KEY",
2115
+ type: "GraphQLError"
2116
+ }, {
2117
+ operation: "generateCopilotResponse",
2118
+ cloudConfigPresent: Boolean(data.cloud),
2119
+ guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
2120
+ });
2112
2121
  throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2113
2122
  }
2114
2123
  if (process.env.COPILOT_CLOUD_BASE_URL) {
2115
2124
  copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2116
- } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2117
- copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2125
+ } else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
2126
+ copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
2118
2127
  } else {
2119
2128
  copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2120
2129
  }
@@ -2156,7 +2165,7 @@ var CopilotResolver = class {
2156
2165
  logger2.debug("Event source created, creating response");
2157
2166
  const eventStream = eventSource.processRuntimeEvents({
2158
2167
  serverSideActions,
2159
- guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2168
+ guardrailsResult$: ((_e = data.cloud) == null ? void 0 : _e.guardrails) ? guardrailsResult$ : null,
2160
2169
  actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2161
2170
  // TODO-AGENTS: do not exclude ALL server side actions
2162
2171
  (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)