@copilotkit/runtime 1.50.0-beta.9 → 1.50.0

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 (182) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/dist/chunk-27JKTS6P.mjs +1704 -0
  3. package/dist/chunk-27JKTS6P.mjs.map +1 -0
  4. package/dist/{chunk-FMU55SEU.mjs → chunk-2GPTVDTO.mjs} +2 -2
  5. package/dist/chunk-3AJVKDZX.mjs +3097 -0
  6. package/dist/chunk-3AJVKDZX.mjs.map +1 -0
  7. package/dist/{chunk-BJEYMRDD.mjs → chunk-45RCC3ZS.mjs} +2 -2
  8. package/dist/chunk-4EHJ4XFJ.mjs +25 -0
  9. package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
  10. package/dist/chunk-4IANB4TC.mjs +25 -0
  11. package/dist/chunk-4IANB4TC.mjs.map +1 -0
  12. package/dist/{chunk-Z752VE75.mjs → chunk-4KES76K3.mjs} +2 -2
  13. package/dist/chunk-4OGE3SLW.mjs +3100 -0
  14. package/dist/chunk-4OGE3SLW.mjs.map +1 -0
  15. package/dist/chunk-54YJBMCP.mjs +3097 -0
  16. package/dist/chunk-54YJBMCP.mjs.map +1 -0
  17. package/dist/chunk-6ER4SZYH.mjs +74 -0
  18. package/dist/chunk-6ER4SZYH.mjs.map +1 -0
  19. package/dist/chunk-6TNSLHVR.mjs +74 -0
  20. package/dist/chunk-6TNSLHVR.mjs.map +1 -0
  21. package/dist/chunk-7V4BK7TZ.mjs +25 -0
  22. package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
  23. package/dist/chunk-7YZIEXD2.mjs +74 -0
  24. package/dist/chunk-7YZIEXD2.mjs.map +1 -0
  25. package/dist/chunk-A4XHOAFU.mjs +25 -0
  26. package/dist/chunk-A4XHOAFU.mjs.map +1 -0
  27. package/dist/chunk-A555KEAD.mjs +6020 -0
  28. package/dist/chunk-A555KEAD.mjs.map +1 -0
  29. package/dist/chunk-AF73TFTX.mjs +74 -0
  30. package/dist/chunk-AF73TFTX.mjs.map +1 -0
  31. package/dist/chunk-AQG2SVCA.mjs +25 -0
  32. package/dist/chunk-AQG2SVCA.mjs.map +1 -0
  33. package/dist/chunk-BJZHMXND.mjs +74 -0
  34. package/dist/chunk-BJZHMXND.mjs.map +1 -0
  35. package/dist/chunk-CB2OJXF6.mjs +25 -0
  36. package/dist/chunk-CB2OJXF6.mjs.map +1 -0
  37. package/dist/chunk-CEOMFPJU.mjs +6020 -0
  38. package/dist/chunk-CEOMFPJU.mjs.map +1 -0
  39. package/dist/chunk-CZVLR7CC.mjs +175 -0
  40. package/dist/chunk-CZVLR7CC.mjs.map +1 -0
  41. package/dist/{chunk-SBCOROE4.mjs → chunk-DCEEHMLJ.mjs} +16 -1
  42. package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
  43. package/dist/chunk-DE3CLKUG.mjs +25 -0
  44. package/dist/chunk-DE3CLKUG.mjs.map +1 -0
  45. package/dist/chunk-DTPRUTNV.mjs +25 -0
  46. package/dist/chunk-DTPRUTNV.mjs.map +1 -0
  47. package/dist/{chunk-TTUAEJLD.mjs → chunk-ERUOA47O.mjs} +11 -2
  48. package/dist/chunk-ERUOA47O.mjs.map +1 -0
  49. package/dist/chunk-ESSRC64W.mjs +74 -0
  50. package/dist/chunk-ESSRC64W.mjs.map +1 -0
  51. package/dist/chunk-GRAN6K6N.mjs +25 -0
  52. package/dist/chunk-GRAN6K6N.mjs.map +1 -0
  53. package/dist/chunk-I27F2UPA.mjs +175 -0
  54. package/dist/chunk-I27F2UPA.mjs.map +1 -0
  55. package/dist/chunk-IAZKTOQW.mjs +25 -0
  56. package/dist/chunk-IAZKTOQW.mjs.map +1 -0
  57. package/dist/chunk-J6XZ5MFB.mjs +25 -0
  58. package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
  59. package/dist/chunk-JJ32MA4C.mjs +73 -0
  60. package/dist/chunk-JJ32MA4C.mjs.map +1 -0
  61. package/dist/chunk-JJY4ZTHQ.mjs +25 -0
  62. package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
  63. package/dist/chunk-KEYLBFU2.mjs +3117 -0
  64. package/dist/chunk-KEYLBFU2.mjs.map +1 -0
  65. package/dist/chunk-KQ53L4WZ.mjs +3094 -0
  66. package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
  67. package/dist/chunk-KTELVQ67.mjs +3098 -0
  68. package/dist/chunk-KTELVQ67.mjs.map +1 -0
  69. package/dist/chunk-LPEPX6NH.mjs +25 -0
  70. package/dist/chunk-LPEPX6NH.mjs.map +1 -0
  71. package/dist/chunk-MDXE55DK.mjs +3117 -0
  72. package/dist/chunk-MDXE55DK.mjs.map +1 -0
  73. package/dist/chunk-MMFUVOXH.mjs +73 -0
  74. package/dist/chunk-MMFUVOXH.mjs.map +1 -0
  75. package/dist/chunk-N3Y4U66N.mjs +253 -0
  76. package/dist/chunk-N3Y4U66N.mjs.map +1 -0
  77. package/dist/chunk-O7UYB4MH.mjs +25 -0
  78. package/dist/chunk-O7UYB4MH.mjs.map +1 -0
  79. package/dist/chunk-OFNVQHNM.mjs +3089 -0
  80. package/dist/chunk-OFNVQHNM.mjs.map +1 -0
  81. package/dist/{chunk-DZV4ZIAR.mjs → chunk-OFSV5GET.mjs} +17 -6
  82. package/dist/chunk-OFSV5GET.mjs.map +1 -0
  83. package/dist/chunk-OMRST67R.mjs +25 -0
  84. package/dist/chunk-OMRST67R.mjs.map +1 -0
  85. package/dist/chunk-PRZHE74A.mjs +25 -0
  86. package/dist/chunk-PRZHE74A.mjs.map +1 -0
  87. package/dist/chunk-PTYRVXXP.mjs +80 -0
  88. package/dist/chunk-PTYRVXXP.mjs.map +1 -0
  89. package/dist/chunk-R22B5CCO.mjs +25 -0
  90. package/dist/chunk-R22B5CCO.mjs.map +1 -0
  91. package/dist/chunk-SHBDMA63.mjs +141 -0
  92. package/dist/chunk-SHBDMA63.mjs.map +1 -0
  93. package/dist/chunk-SPVXBPRA.mjs +74 -0
  94. package/dist/chunk-SPVXBPRA.mjs.map +1 -0
  95. package/dist/chunk-T72G46ME.mjs +25 -0
  96. package/dist/chunk-T72G46ME.mjs.map +1 -0
  97. package/dist/chunk-TGELROPU.mjs +25 -0
  98. package/dist/chunk-TGELROPU.mjs.map +1 -0
  99. package/dist/chunk-UNX4IAAD.mjs +25 -0
  100. package/dist/chunk-UNX4IAAD.mjs.map +1 -0
  101. package/dist/chunk-V4DHVC7M.mjs +3085 -0
  102. package/dist/chunk-V4DHVC7M.mjs.map +1 -0
  103. package/dist/chunk-VVRFOB66.mjs +25 -0
  104. package/dist/chunk-VVRFOB66.mjs.map +1 -0
  105. package/dist/chunk-W6NVBYM6.mjs +80 -0
  106. package/dist/chunk-W6NVBYM6.mjs.map +1 -0
  107. package/dist/chunk-W7MBACGC.mjs +74 -0
  108. package/dist/chunk-W7MBACGC.mjs.map +1 -0
  109. package/dist/chunk-WMD4XZZS.mjs +25 -0
  110. package/dist/chunk-WMD4XZZS.mjs.map +1 -0
  111. package/dist/chunk-WX2ZNCRT.mjs +74 -0
  112. package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
  113. package/dist/chunk-Y2Z62E2T.mjs +74 -0
  114. package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
  115. package/dist/chunk-YO4I6RVI.mjs +25 -0
  116. package/dist/chunk-YO4I6RVI.mjs.map +1 -0
  117. package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
  118. package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
  119. package/dist/chunk-Z726O3G2.mjs +25 -0
  120. package/dist/chunk-Z726O3G2.mjs.map +1 -0
  121. package/dist/chunk-ZE4SMZZR.mjs +3097 -0
  122. package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
  123. package/dist/chunk-ZULZB33C.mjs +73 -0
  124. package/dist/chunk-ZULZB33C.mjs.map +1 -0
  125. package/dist/chunk-ZVRGXMY7.mjs +25 -0
  126. package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
  127. package/dist/chunk-ZZ35WBYQ.mjs +25 -0
  128. package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
  129. package/dist/graphql/types/converted/index.d.ts +1 -1
  130. package/dist/graphql/types/converted/index.js +16 -110
  131. package/dist/graphql/types/converted/index.js.map +1 -1
  132. package/dist/graphql/types/converted/index.mjs +2 -3
  133. package/dist/{groq-adapter-50bc6e4a.d.ts → groq-adapter-540da9c3.d.ts} +6 -1
  134. package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
  135. package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
  136. package/dist/index-96b330da.d.ts +119 -0
  137. package/dist/index.d.ts +67 -8
  138. package/dist/index.js +118 -28
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +120 -31
  141. package/dist/index.mjs.map +1 -1
  142. package/dist/langserve-0c6100e3.d.ts +257 -0
  143. package/dist/langserve-978d5790.d.ts +243 -0
  144. package/dist/{langserve-74a52292.d.ts → langserve-9fc76ce5.d.ts} +1 -0
  145. package/dist/lib/index.d.ts +5 -59
  146. package/dist/lib/index.js +3702 -803
  147. package/dist/lib/index.js.map +1 -1
  148. package/dist/lib/index.mjs +20 -18
  149. package/dist/lib/integrations/index.d.ts +15 -9
  150. package/dist/lib/integrations/index.js +215 -187
  151. package/dist/lib/integrations/index.js.map +1 -1
  152. package/dist/lib/integrations/index.mjs +8 -7
  153. package/dist/lib/integrations/nest/index.d.ts +5 -6
  154. package/dist/lib/integrations/nest/index.js +197 -175
  155. package/dist/lib/integrations/nest/index.js.map +1 -1
  156. package/dist/lib/integrations/nest/index.mjs +6 -5
  157. package/dist/lib/integrations/node-express/index.d.ts +5 -6
  158. package/dist/lib/integrations/node-express/index.js +197 -175
  159. package/dist/lib/integrations/node-express/index.js.map +1 -1
  160. package/dist/lib/integrations/node-express/index.mjs +6 -5
  161. package/dist/lib/integrations/node-http/index.d.ts +5 -6
  162. package/dist/lib/integrations/node-http/index.js +197 -175
  163. package/dist/lib/integrations/node-http/index.js.map +1 -1
  164. package/dist/lib/integrations/node-http/index.mjs +5 -4
  165. package/dist/service-adapters/index.d.ts +7 -11
  166. package/dist/service-adapters/index.js +8 -21
  167. package/dist/service-adapters/index.js.map +1 -1
  168. package/dist/service-adapters/index.mjs +2 -4
  169. package/dist/shared-0a7346ce.d.ts +466 -0
  170. package/dist/{shared-f6d43ef8.d.ts → shared-35c6eb04.d.ts} +3 -1
  171. package/dist/shared-9ed1dc31.d.ts +414 -0
  172. package/dist/shared-da5708fe.d.ts +449 -0
  173. package/package.json +14 -20
  174. package/src/lib/index.ts +7 -6
  175. package/src/lib/runtime/copilot-runtime.ts +62 -26
  176. package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
  177. package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
  178. package/dist/chunk-SBCOROE4.mjs.map +0 -1
  179. package/dist/chunk-TTUAEJLD.mjs.map +0 -1
  180. /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
  181. /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
  182. /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import 'reflect-metadata';
2
- import { TelemetryClient, CopilotKitLowLevelError, CopilotKitErrorCode, randomUUID, randomId, CopilotKitMisuseError, getZodParameters, readBody, CopilotKitError, CopilotKitAgentDiscoveryError, parseJson, convertJsonSchemaToZodSchema } from '@copilotkit/shared';
2
+ import { TelemetryClient, CopilotKitLowLevelError, CopilotKitErrorCode, randomUUID, randomId, isTelemetryDisabled, CopilotKitMisuseError, getZodParameters, readBody, CopilotKitError, CopilotKitAgentDiscoveryError, parseJson, convertJsonSchemaToZodSchema } from '@copilotkit/shared';
3
3
  import { HumanMessage, AIMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
4
4
  import { DynamicStructuredTool } from '@langchain/core/tools';
5
5
  import { registerEnumType, Field, InputType, ObjectType, createUnionType, InterfaceType, Query, Ctx, Mutation, Arg, Resolver, buildSchemaSync } from 'type-graphql';
6
- import { ReplaySubject, shareReplay, finalize, firstValueFrom, skipWhile, takeWhile, filter, Subject, take, tap } from 'rxjs';
6
+ import { tap, catchError, finalize, ReplaySubject, shareReplay, firstValueFrom, skipWhile, takeWhile, filter, Subject, take } from 'rxjs';
7
7
  import { GraphQLJSON, GraphQLJSONObject } from 'graphql-scalars';
8
8
  import { Repeater } from 'graphql-yoga';
9
9
  import { plainToInstance } from 'class-transformer';
@@ -65,7 +65,7 @@ var require_package = __commonJS({
65
65
  publishConfig: {
66
66
  access: "public"
67
67
  },
68
- version: "1.50.0-beta.9",
68
+ version: "1.50.0",
69
69
  sideEffects: false,
70
70
  main: "./dist/index.js",
71
71
  module: "./dist/index.mjs",
@@ -116,12 +116,14 @@ var require_package = __commonJS({
116
116
  vitest: "^3.2.4"
117
117
  },
118
118
  dependencies: {
119
+ "@ag-ui/client": "^0.0.42",
120
+ "@ag-ui/core": "^0.0.42",
121
+ "@ag-ui/langgraph": "^0.0.20",
119
122
  "@copilotkit/shared": "workspace:*",
120
- "@copilotkitnext/agent": "0.0.28",
121
- "@copilotkitnext/runtime": "0.0.28",
123
+ "@copilotkitnext/agent": "0.0.31",
124
+ "@copilotkitnext/runtime": "0.0.31",
122
125
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
123
126
  "@hono/node-server": "^1.13.5",
124
- "@langchain/core": "^0.3.38",
125
127
  "@scarf/scarf": "^1.3.0",
126
128
  "class-transformer": "^0.5.1",
127
129
  "class-validator": "^0.14.1",
@@ -129,7 +131,6 @@ var require_package = __commonJS({
129
131
  "graphql-scalars": "^1.23.0",
130
132
  "graphql-yoga": "^5.3.1",
131
133
  hono: "^4.10.3",
132
- langchain: "^0.3.3",
133
134
  openai: "^4.85.1",
134
135
  "partial-json": "^0.1.7",
135
136
  pino: "^9.2.0",
@@ -141,27 +142,20 @@ var require_package = __commonJS({
141
142
  },
142
143
  peerDependencies: {
143
144
  "@anthropic-ai/sdk": "^0.57.0",
144
- "@ag-ui/client": "^0.0.42",
145
- "@ag-ui/core": ">=0.0.42",
146
- "@ag-ui/encoder": ">=0.0.42",
147
- "@ag-ui/langgraph": ">=0.0.20",
148
- "@ag-ui/proto": ">=0.0.42",
149
- "@langchain/aws": "^0.1.9",
150
- "@langchain/community": "^0.3.58",
151
- "@langchain/google-gauth": "^0.1.0",
152
- "@langchain/langgraph-sdk": "^0.0.70",
153
- "@langchain/openai": "^0.4.2",
145
+ "@langchain/aws": ">=0.1.9",
146
+ "@langchain/core": ">=0.3.66",
147
+ "@langchain/community": ">=0.3.58",
148
+ "@langchain/google-gauth": ">=0.1.0",
149
+ "@langchain/langgraph-sdk": ">=0.1.2",
150
+ "@langchain/openai": ">=0.4.2",
154
151
  "groq-sdk": ">=0.3.0 <1.0.0",
155
- langchain: "^0.3.3",
152
+ langchain: ">=0.3.3",
156
153
  openai: "^4.85.1"
157
154
  },
158
155
  peerDependenciesMeta: {
159
156
  "@anthropic-ai/sdk": {
160
157
  optional: true
161
158
  },
162
- "@ag-ui/langgraph": {
163
- optional: true
164
- },
165
159
  "@langchain/aws": {
166
160
  optional: true
167
161
  },
@@ -3233,6 +3227,82 @@ function aguiMessageWithImageToGQLMessage(message) {
3233
3227
  });
3234
3228
  }
3235
3229
  __name(aguiMessageWithImageToGQLMessage, "aguiMessageWithImageToGQLMessage");
3230
+ var TelemetryAgentRunner = class {
3231
+ _runner;
3232
+ hashedLgcKey;
3233
+ constructor(config2) {
3234
+ this._runner = (config2 == null ? void 0 : config2.runner) ?? new InMemoryAgentRunner();
3235
+ this.hashedLgcKey = (config2 == null ? void 0 : config2.langsmithApiKey) ? createHash("sha256").update(config2.langsmithApiKey).digest("hex") : void 0;
3236
+ }
3237
+ /**
3238
+ * Runs an agent with telemetry tracking.
3239
+ * Wraps the underlying runner's Observable stream with telemetry events.
3240
+ */
3241
+ run(...args) {
3242
+ const streamInfo = {
3243
+ hashedLgcKey: this.hashedLgcKey
3244
+ };
3245
+ let streamErrored = false;
3246
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
3247
+ hashedLgcKey: this.hashedLgcKey
3248
+ });
3249
+ return this._runner.run(...args).pipe(
3250
+ // Extract metadata from events if available
3251
+ tap((event) => {
3252
+ var _a;
3253
+ const rawEvent = event.rawEvent;
3254
+ if (rawEvent == null ? void 0 : rawEvent.data) {
3255
+ const data = rawEvent.data;
3256
+ if ((_a = data == null ? void 0 : data.output) == null ? void 0 : _a.model) {
3257
+ streamInfo.model = data.output.model;
3258
+ streamInfo.provider = data.output.model;
3259
+ }
3260
+ }
3261
+ if (rawEvent == null ? void 0 : rawEvent.metadata) {
3262
+ const metadata = rawEvent.metadata;
3263
+ if (metadata == null ? void 0 : metadata.langgraph_host) {
3264
+ streamInfo.langGraphHost = metadata.langgraph_host;
3265
+ }
3266
+ if (metadata == null ? void 0 : metadata.langgraph_version) {
3267
+ streamInfo.langGraphVersion = metadata.langgraph_version;
3268
+ }
3269
+ }
3270
+ }),
3271
+ catchError((error) => {
3272
+ streamErrored = true;
3273
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
3274
+ ...streamInfo,
3275
+ error: error instanceof Error ? error.message : String(error)
3276
+ });
3277
+ throw error;
3278
+ }),
3279
+ finalize(() => {
3280
+ if (!streamErrored) {
3281
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
3282
+ }
3283
+ })
3284
+ );
3285
+ }
3286
+ /**
3287
+ * Delegates to the underlying runner's connect method
3288
+ */
3289
+ connect(...args) {
3290
+ return this._runner.connect(...args);
3291
+ }
3292
+ /**
3293
+ * Delegates to the underlying runner's isRunning method
3294
+ */
3295
+ isRunning(...args) {
3296
+ return this._runner.isRunning(...args);
3297
+ }
3298
+ /**
3299
+ * Delegates to the underlying runner's stop method
3300
+ */
3301
+ stop(...args) {
3302
+ return this._runner.stop(...args);
3303
+ }
3304
+ };
3305
+ __name(TelemetryAgentRunner, "TelemetryAgentRunner");
3236
3306
 
3237
3307
  // src/lib/runtime/types.ts
3238
3308
  var EndpointType;
@@ -3386,12 +3456,16 @@ var CopilotRuntime = class {
3386
3456
  constructor(params) {
3387
3457
  const agents = (params == null ? void 0 : params.agents) ?? {};
3388
3458
  const endpointAgents = this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []);
3459
+ const baseRunner = (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunner();
3460
+ const runner = isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
3461
+ runner: baseRunner
3462
+ });
3389
3463
  this.runtimeArgs = {
3390
3464
  agents: {
3391
3465
  ...endpointAgents,
3392
3466
  ...agents
3393
3467
  },
3394
- runner: (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunner(),
3468
+ runner,
3395
3469
  // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
3396
3470
  // transcriptionService: params?.transcriptionService,
3397
3471
  beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
@@ -3417,6 +3491,7 @@ var CopilotRuntime = class {
3417
3491
  }
3418
3492
  handleServiceAdapter(serviceAdapter) {
3419
3493
  this.runtimeArgs.agents = Promise.resolve(this.runtimeArgs.agents ?? {}).then(async (agents) => {
3494
+ var _a;
3420
3495
  let agentsList = agents;
3421
3496
  const isAgentsListEmpty = !Object.keys(agents).length;
3422
3497
  const hasServiceAdapter = Boolean(serviceAdapter);
@@ -3434,10 +3509,11 @@ var CopilotRuntime = class {
3434
3509
  model: `${serviceAdapter.provider}/${serviceAdapter.model}`
3435
3510
  });
3436
3511
  }
3437
- if (this.params.actions) {
3512
+ const actions = (_a = this.params) == null ? void 0 : _a.actions;
3513
+ if (actions) {
3438
3514
  const mcpTools = await this.getToolsFromMCP();
3439
3515
  agentsList = this.assignToolsToAgents(agents, [
3440
- ...this.getToolsFromActions(this.params.actions),
3516
+ ...this.getToolsFromActions(actions),
3441
3517
  ...mcpTools
3442
3518
  ]);
3443
3519
  }
@@ -3484,11 +3560,24 @@ var CopilotRuntime = class {
3484
3560
  }
3485
3561
  createOnBeforeRequestHandler(params) {
3486
3562
  return async (hookParams) => {
3487
- var _a, _b;
3488
- (_a = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
3489
- if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onBeforeRequest) {
3490
- const { request, runtime, path } = hookParams;
3491
- const body = await readBody(request);
3563
+ var _a, _b, _c, _d;
3564
+ const { request } = hookParams;
3565
+ const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
3566
+ const body = await readBody(request);
3567
+ const forwardedProps = body.forwardedProps;
3568
+ const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
3569
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
3570
+ "cloud.guardrails.enabled": ((_a = forwardedProps == null ? void 0 : forwardedProps.cloud) == null ? void 0 : _a.guardrails) !== void 0,
3571
+ requestType: ((_b = forwardedProps == null ? void 0 : forwardedProps.metadata) == null ? void 0 : _b.requestType) ?? "unknown",
3572
+ "cloud.api_key_provided": !!publicApiKey,
3573
+ ...publicApiKey ? {
3574
+ "cloud.public_api_key": publicApiKey
3575
+ } : {},
3576
+ "cloud.base_url": cloudBaseUrl
3577
+ });
3578
+ (_c = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _c.call(params, hookParams);
3579
+ if ((_d = params == null ? void 0 : params.middleware) == null ? void 0 : _d.onBeforeRequest) {
3580
+ const { request: request2, runtime, path } = hookParams;
3492
3581
  const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
3493
3582
  if ("role" in msg && msg.role === "user") {
3494
3583
  acc.inputMessages.push(msg);
@@ -3506,7 +3595,7 @@ var CopilotRuntime = class {
3506
3595
  runId: body.runId,
3507
3596
  inputMessages,
3508
3597
  properties: body.forwardedProps,
3509
- url: request.url
3598
+ url: request2.url
3510
3599
  });
3511
3600
  }
3512
3601
  };
@@ -5469,6 +5558,6 @@ var EmptyAdapter = class {
5469
5558
  __name(EmptyAdapter, "EmptyAdapter");
5470
5559
  var ExperimentalEmptyAdapter = EmptyAdapter;
5471
5560
 
5472
- export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
5561
+ export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, TelemetryAgentRunner, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
5473
5562
  //# sourceMappingURL=out.js.map
5474
5563
  //# sourceMappingURL=index.mjs.map