@copilotkit/runtime 1.50.0-beta.10 → 1.50.0-beta.11

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.50.0-beta.11
4
+
5
+ ### Minor Changes
6
+
7
+ - fix telemetry in v1.50 runtime
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @copilotkit/shared@1.50.0-beta.11
13
+
3
14
  ## 1.50.0-beta.10
4
15
 
5
16
  ### Minor Changes
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ var require_package = __commonJS({
72
72
  publishConfig: {
73
73
  access: "public"
74
74
  },
75
- version: "1.50.0-beta.9",
75
+ version: "1.50.0-beta.10",
76
76
  sideEffects: false,
77
77
  main: "./dist/index.js",
78
78
  module: "./dist/index.mjs",
@@ -3469,14 +3469,16 @@ var CopilotRuntime = class {
3469
3469
  constructor(params) {
3470
3470
  const agents = (params == null ? void 0 : params.agents) ?? {};
3471
3471
  const endpointAgents = this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []);
3472
+ const baseRunner = (params == null ? void 0 : params.runner) ?? new runtime.InMemoryAgentRunner();
3473
+ const runner = shared.isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
3474
+ runner: baseRunner
3475
+ });
3472
3476
  this.runtimeArgs = {
3473
3477
  agents: {
3474
3478
  ...endpointAgents,
3475
3479
  ...agents
3476
3480
  },
3477
- // Use TelemetryAgentRunner by default to track agent execution telemetry
3478
- // Users can pass their own runner which will be wrapped for telemetry
3479
- runner: (params == null ? void 0 : params.runner) ?? new TelemetryAgentRunner(),
3481
+ runner,
3480
3482
  // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
3481
3483
  // transcriptionService: params?.transcriptionService,
3482
3484
  beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
@@ -3569,11 +3571,24 @@ var CopilotRuntime = class {
3569
3571
  }
3570
3572
  createOnBeforeRequestHandler(params) {
3571
3573
  return async (hookParams) => {
3572
- var _a, _b;
3573
- (_a = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
3574
- if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onBeforeRequest) {
3575
- const { request, runtime, path } = hookParams;
3576
- const body = await shared.readBody(request);
3574
+ var _a, _b, _c, _d;
3575
+ const { request } = hookParams;
3576
+ const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
3577
+ const body = await shared.readBody(request);
3578
+ const forwardedProps = body.forwardedProps;
3579
+ const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
3580
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
3581
+ "cloud.guardrails.enabled": ((_a = forwardedProps == null ? void 0 : forwardedProps.cloud) == null ? void 0 : _a.guardrails) !== void 0,
3582
+ requestType: ((_b = forwardedProps == null ? void 0 : forwardedProps.metadata) == null ? void 0 : _b.requestType) ?? "unknown",
3583
+ "cloud.api_key_provided": !!publicApiKey,
3584
+ ...publicApiKey ? {
3585
+ "cloud.public_api_key": publicApiKey
3586
+ } : {},
3587
+ "cloud.base_url": cloudBaseUrl
3588
+ });
3589
+ (_c = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _c.call(params, hookParams);
3590
+ if ((_d = params == null ? void 0 : params.middleware) == null ? void 0 : _d.onBeforeRequest) {
3591
+ const { request: request2, runtime, path } = hookParams;
3577
3592
  const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
3578
3593
  if ("role" in msg && msg.role === "user") {
3579
3594
  acc.inputMessages.push(msg);
@@ -3591,7 +3606,7 @@ var CopilotRuntime = class {
3591
3606
  runId: body.runId,
3592
3607
  inputMessages,
3593
3608
  properties: body.forwardedProps,
3594
- url: request.url
3609
+ url: request2.url
3595
3610
  });
3596
3611
  }
3597
3612
  };