@copilotkit/runtime 1.50.0-beta.9 → 1.50.1-next.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 (183) hide show
  1. package/CHANGELOG.md +165 -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 +72 -9
  138. package/dist/index.js +127 -31
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +129 -34
  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/src/service-adapters/google/google-genai-adapter.ts +19 -4
  178. package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
  179. package/dist/chunk-SBCOROE4.mjs.map +0 -1
  180. package/dist/chunk-TTUAEJLD.mjs.map +0 -1
  181. /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
  182. /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
  183. /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.1-next.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
  },
@@ -855,11 +849,17 @@ var LangChainAdapter = class {
855
849
  __name(LangChainAdapter, "LangChainAdapter");
856
850
 
857
851
  // src/service-adapters/google/google-genai-adapter.ts
858
- var DEFAULT_MODEL2 = "gemini-1.5-pro";
852
+ var DEFAULT_MODEL2 = "gemini-2.5-flash";
853
+ var DEFAULT_API_VERSION = "v1";
854
+ var hasWarnedDefaultGoogleModel = false;
859
855
  var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
860
856
  provider = "google";
861
857
  model = DEFAULT_MODEL2;
862
858
  constructor(options) {
859
+ if (!hasWarnedDefaultGoogleModel && !(options == null ? void 0 : options.model) && !(options == null ? void 0 : options.apiVersion)) {
860
+ console.warn(`You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. CopilotKit will default to apiVersion="v1" and model="${DEFAULT_MODEL2}". To silence this warning, pass model and apiVersion when constructing the adapter.`);
861
+ hasWarnedDefaultGoogleModel = true;
862
+ }
863
863
  super({
864
864
  chainFn: async ({ messages, tools, threadId }) => {
865
865
  const { ChatGoogle } = __require("@langchain/google-gauth");
@@ -871,11 +871,11 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
871
871
  const aiMsg = message;
872
872
  return aiMsg.content && String(aiMsg.content).trim().length > 0 || aiMsg.tool_calls && aiMsg.tool_calls.length > 0;
873
873
  });
874
- this.model = (options == null ? void 0 : options.model) ?? "gemini-1.5-pro";
874
+ this.model = (options == null ? void 0 : options.model) ?? DEFAULT_MODEL2;
875
875
  const model = new ChatGoogle({
876
876
  apiKey: (options == null ? void 0 : options.apiKey) ?? process.env.GOOGLE_API_KEY,
877
877
  modelName: this.model,
878
- apiVersion: "v1beta"
878
+ apiVersion: (options == null ? void 0 : options.apiVersion) ?? DEFAULT_API_VERSION
879
879
  }).bindTools(tools);
880
880
  return model.stream(filteredMessages, {
881
881
  metadata: {
@@ -3233,6 +3233,82 @@ function aguiMessageWithImageToGQLMessage(message) {
3233
3233
  });
3234
3234
  }
3235
3235
  __name(aguiMessageWithImageToGQLMessage, "aguiMessageWithImageToGQLMessage");
3236
+ var TelemetryAgentRunner = class {
3237
+ _runner;
3238
+ hashedLgcKey;
3239
+ constructor(config2) {
3240
+ this._runner = (config2 == null ? void 0 : config2.runner) ?? new InMemoryAgentRunner();
3241
+ this.hashedLgcKey = (config2 == null ? void 0 : config2.langsmithApiKey) ? createHash("sha256").update(config2.langsmithApiKey).digest("hex") : void 0;
3242
+ }
3243
+ /**
3244
+ * Runs an agent with telemetry tracking.
3245
+ * Wraps the underlying runner's Observable stream with telemetry events.
3246
+ */
3247
+ run(...args) {
3248
+ const streamInfo = {
3249
+ hashedLgcKey: this.hashedLgcKey
3250
+ };
3251
+ let streamErrored = false;
3252
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
3253
+ hashedLgcKey: this.hashedLgcKey
3254
+ });
3255
+ return this._runner.run(...args).pipe(
3256
+ // Extract metadata from events if available
3257
+ tap((event) => {
3258
+ var _a;
3259
+ const rawEvent = event.rawEvent;
3260
+ if (rawEvent == null ? void 0 : rawEvent.data) {
3261
+ const data = rawEvent.data;
3262
+ if ((_a = data == null ? void 0 : data.output) == null ? void 0 : _a.model) {
3263
+ streamInfo.model = data.output.model;
3264
+ streamInfo.provider = data.output.model;
3265
+ }
3266
+ }
3267
+ if (rawEvent == null ? void 0 : rawEvent.metadata) {
3268
+ const metadata = rawEvent.metadata;
3269
+ if (metadata == null ? void 0 : metadata.langgraph_host) {
3270
+ streamInfo.langGraphHost = metadata.langgraph_host;
3271
+ }
3272
+ if (metadata == null ? void 0 : metadata.langgraph_version) {
3273
+ streamInfo.langGraphVersion = metadata.langgraph_version;
3274
+ }
3275
+ }
3276
+ }),
3277
+ catchError((error) => {
3278
+ streamErrored = true;
3279
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
3280
+ ...streamInfo,
3281
+ error: error instanceof Error ? error.message : String(error)
3282
+ });
3283
+ throw error;
3284
+ }),
3285
+ finalize(() => {
3286
+ if (!streamErrored) {
3287
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
3288
+ }
3289
+ })
3290
+ );
3291
+ }
3292
+ /**
3293
+ * Delegates to the underlying runner's connect method
3294
+ */
3295
+ connect(...args) {
3296
+ return this._runner.connect(...args);
3297
+ }
3298
+ /**
3299
+ * Delegates to the underlying runner's isRunning method
3300
+ */
3301
+ isRunning(...args) {
3302
+ return this._runner.isRunning(...args);
3303
+ }
3304
+ /**
3305
+ * Delegates to the underlying runner's stop method
3306
+ */
3307
+ stop(...args) {
3308
+ return this._runner.stop(...args);
3309
+ }
3310
+ };
3311
+ __name(TelemetryAgentRunner, "TelemetryAgentRunner");
3236
3312
 
3237
3313
  // src/lib/runtime/types.ts
3238
3314
  var EndpointType;
@@ -3386,12 +3462,16 @@ var CopilotRuntime = class {
3386
3462
  constructor(params) {
3387
3463
  const agents = (params == null ? void 0 : params.agents) ?? {};
3388
3464
  const endpointAgents = this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []);
3465
+ const baseRunner = (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunner();
3466
+ const runner = isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
3467
+ runner: baseRunner
3468
+ });
3389
3469
  this.runtimeArgs = {
3390
3470
  agents: {
3391
3471
  ...endpointAgents,
3392
3472
  ...agents
3393
3473
  },
3394
- runner: (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunner(),
3474
+ runner,
3395
3475
  // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
3396
3476
  // transcriptionService: params?.transcriptionService,
3397
3477
  beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
@@ -3417,6 +3497,7 @@ var CopilotRuntime = class {
3417
3497
  }
3418
3498
  handleServiceAdapter(serviceAdapter) {
3419
3499
  this.runtimeArgs.agents = Promise.resolve(this.runtimeArgs.agents ?? {}).then(async (agents) => {
3500
+ var _a;
3420
3501
  let agentsList = agents;
3421
3502
  const isAgentsListEmpty = !Object.keys(agents).length;
3422
3503
  const hasServiceAdapter = Boolean(serviceAdapter);
@@ -3434,10 +3515,11 @@ var CopilotRuntime = class {
3434
3515
  model: `${serviceAdapter.provider}/${serviceAdapter.model}`
3435
3516
  });
3436
3517
  }
3437
- if (this.params.actions) {
3518
+ const actions = (_a = this.params) == null ? void 0 : _a.actions;
3519
+ if (actions) {
3438
3520
  const mcpTools = await this.getToolsFromMCP();
3439
3521
  agentsList = this.assignToolsToAgents(agents, [
3440
- ...this.getToolsFromActions(this.params.actions),
3522
+ ...this.getToolsFromActions(actions),
3441
3523
  ...mcpTools
3442
3524
  ]);
3443
3525
  }
@@ -3484,11 +3566,24 @@ var CopilotRuntime = class {
3484
3566
  }
3485
3567
  createOnBeforeRequestHandler(params) {
3486
3568
  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);
3569
+ var _a, _b, _c, _d;
3570
+ const { request } = hookParams;
3571
+ const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
3572
+ const body = await readBody(request);
3573
+ const forwardedProps = body.forwardedProps;
3574
+ const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
3575
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
3576
+ "cloud.guardrails.enabled": ((_a = forwardedProps == null ? void 0 : forwardedProps.cloud) == null ? void 0 : _a.guardrails) !== void 0,
3577
+ requestType: ((_b = forwardedProps == null ? void 0 : forwardedProps.metadata) == null ? void 0 : _b.requestType) ?? "unknown",
3578
+ "cloud.api_key_provided": !!publicApiKey,
3579
+ ...publicApiKey ? {
3580
+ "cloud.public_api_key": publicApiKey
3581
+ } : {},
3582
+ "cloud.base_url": cloudBaseUrl
3583
+ });
3584
+ (_c = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _c.call(params, hookParams);
3585
+ if ((_d = params == null ? void 0 : params.middleware) == null ? void 0 : _d.onBeforeRequest) {
3586
+ const { request: request2, runtime, path } = hookParams;
3492
3587
  const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
3493
3588
  if ("role" in msg && msg.role === "user") {
3494
3589
  acc.inputMessages.push(msg);
@@ -3506,7 +3601,7 @@ var CopilotRuntime = class {
3506
3601
  runId: body.runId,
3507
3602
  inputMessages,
3508
3603
  properties: body.forwardedProps,
3509
- url: request.url
3604
+ url: request2.url
3510
3605
  });
3511
3606
  }
3512
3607
  };
@@ -5469,6 +5564,6 @@ var EmptyAdapter = class {
5469
5564
  __name(EmptyAdapter, "EmptyAdapter");
5470
5565
  var ExperimentalEmptyAdapter = EmptyAdapter;
5471
5566
 
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 };
5567
+ 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
5568
  //# sourceMappingURL=out.js.map
5474
5569
  //# sourceMappingURL=index.mjs.map