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

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 (132) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/chunk-2OZAGFV3.mjs +43 -0
  3. package/dist/chunk-2OZAGFV3.mjs.map +1 -0
  4. package/dist/chunk-62NE5S6M.mjs +226 -0
  5. package/dist/chunk-62NE5S6M.mjs.map +1 -0
  6. package/dist/chunk-6XRUR5UK.mjs +1 -0
  7. package/dist/chunk-6XRUR5UK.mjs.map +1 -0
  8. package/dist/chunk-AMUJQ6IR.mjs +50 -0
  9. package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
  10. package/dist/chunk-BJEYMRDD.mjs +25 -0
  11. package/dist/chunk-BJEYMRDD.mjs.map +1 -0
  12. package/dist/chunk-DZV4ZIAR.mjs +3063 -0
  13. package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
  14. package/dist/chunk-FHD4JECV.mjs +33 -0
  15. package/dist/chunk-FHD4JECV.mjs.map +1 -0
  16. package/dist/chunk-FMU55SEU.mjs +25 -0
  17. package/dist/chunk-FMU55SEU.mjs.map +1 -0
  18. package/dist/chunk-OWIGJONH.mjs +275 -0
  19. package/dist/chunk-OWIGJONH.mjs.map +1 -0
  20. package/dist/chunk-SBCOROE4.mjs +1112 -0
  21. package/dist/chunk-SBCOROE4.mjs.map +1 -0
  22. package/dist/chunk-TTUAEJLD.mjs +617 -0
  23. package/dist/chunk-TTUAEJLD.mjs.map +1 -0
  24. package/dist/chunk-XWBDEXDA.mjs +153 -0
  25. package/dist/chunk-XWBDEXDA.mjs.map +1 -0
  26. package/dist/chunk-Z752VE75.mjs +74 -0
  27. package/dist/chunk-Z752VE75.mjs.map +1 -0
  28. package/dist/graphql/message-conversion/index.d.ts +18 -0
  29. package/dist/graphql/message-conversion/index.js +725 -0
  30. package/dist/graphql/message-conversion/index.js.map +1 -0
  31. package/dist/graphql/message-conversion/index.mjs +245 -0
  32. package/dist/graphql/message-conversion/index.mjs.map +1 -0
  33. package/dist/graphql/types/base/index.d.ts +6 -0
  34. package/dist/graphql/types/base/index.js +63 -0
  35. package/dist/graphql/types/base/index.js.map +1 -0
  36. package/dist/graphql/types/base/index.mjs +8 -0
  37. package/dist/graphql/types/base/index.mjs.map +1 -0
  38. package/dist/graphql/types/converted/index.d.ts +2 -0
  39. package/dist/graphql/types/converted/index.js +294 -0
  40. package/dist/graphql/types/converted/index.js.map +1 -0
  41. package/dist/graphql/types/converted/index.mjs +20 -0
  42. package/dist/graphql/types/converted/index.mjs.map +1 -0
  43. package/dist/groq-adapter-50bc6e4a.d.ts +326 -0
  44. package/dist/index-adbd78f1.d.ts +154 -0
  45. package/dist/index.d.ts +136 -287
  46. package/dist/index.js +393 -287
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +385 -276
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/langgraph.d.ts +284 -0
  51. package/dist/langgraph.js +211 -0
  52. package/dist/langgraph.js.map +1 -0
  53. package/dist/langgraph.mjs +206 -0
  54. package/dist/langgraph.mjs.map +1 -0
  55. package/dist/langserve-74a52292.d.ts +242 -0
  56. package/dist/lib/cloud/index.d.ts +6 -0
  57. package/dist/lib/cloud/index.js +18 -0
  58. package/dist/lib/cloud/index.js.map +1 -0
  59. package/dist/lib/cloud/index.mjs +1 -0
  60. package/dist/lib/cloud/index.mjs.map +1 -0
  61. package/dist/lib/index.d.ts +266 -0
  62. package/dist/lib/index.js +4944 -0
  63. package/dist/lib/index.js.map +1 -0
  64. package/dist/lib/index.mjs +74 -0
  65. package/dist/lib/index.mjs.map +1 -0
  66. package/dist/lib/integrations/index.d.ts +28 -0
  67. package/dist/lib/integrations/index.js +3024 -0
  68. package/dist/lib/integrations/index.js.map +1 -0
  69. package/dist/lib/integrations/index.mjs +36 -0
  70. package/dist/lib/integrations/index.mjs.map +1 -0
  71. package/dist/lib/integrations/nest/index.d.ts +16 -0
  72. package/dist/lib/integrations/nest/index.js +2937 -0
  73. package/dist/lib/integrations/nest/index.js.map +1 -0
  74. package/dist/lib/integrations/nest/index.mjs +13 -0
  75. package/dist/lib/integrations/nest/index.mjs.map +1 -0
  76. package/dist/lib/integrations/node-express/index.d.ts +16 -0
  77. package/dist/lib/integrations/node-express/index.js +2937 -0
  78. package/dist/lib/integrations/node-express/index.js.map +1 -0
  79. package/dist/lib/integrations/node-express/index.mjs +13 -0
  80. package/dist/lib/integrations/node-express/index.mjs.map +1 -0
  81. package/dist/lib/integrations/node-http/index.d.ts +16 -0
  82. package/dist/lib/integrations/node-http/index.js +2923 -0
  83. package/dist/lib/integrations/node-http/index.js.map +1 -0
  84. package/dist/lib/integrations/node-http/index.mjs +12 -0
  85. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  86. package/dist/service-adapters/index.d.ts +166 -0
  87. package/dist/service-adapters/index.js +1800 -0
  88. package/dist/service-adapters/index.js.map +1 -0
  89. package/dist/service-adapters/index.mjs +36 -0
  90. package/dist/service-adapters/index.mjs.map +1 -0
  91. package/dist/service-adapters/shared/index.d.ts +9 -0
  92. package/dist/service-adapters/shared/index.js +72 -0
  93. package/dist/service-adapters/shared/index.js.map +1 -0
  94. package/dist/service-adapters/shared/index.mjs +8 -0
  95. package/dist/service-adapters/shared/index.mjs.map +1 -0
  96. package/dist/shared-f6d43ef8.d.ts +446 -0
  97. package/dist/utils/index.d.ts +65 -0
  98. package/dist/utils/index.js +175 -0
  99. package/dist/utils/index.js.map +1 -0
  100. package/dist/utils/index.mjs +12 -0
  101. package/dist/utils/index.mjs.map +1 -0
  102. package/dist/v2/index.d.ts +1 -0
  103. package/dist/v2/index.js +7 -0
  104. package/dist/v2/index.js.map +1 -1
  105. package/dist/v2/index.mjs +1 -0
  106. package/dist/v2/index.mjs.map +1 -1
  107. package/package.json +71 -33
  108. package/src/graphql/message-conversion/agui-to-gql.test.ts +2 -2
  109. package/src/graphql/message-conversion/gql-to-agui.test.ts +30 -28
  110. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +8 -8
  111. package/src/langgraph.ts +1 -0
  112. package/src/lib/index.ts +42 -1
  113. package/src/lib/integrations/nextjs/app-router.ts +3 -1
  114. package/src/lib/integrations/node-http/index.ts +132 -11
  115. package/src/lib/integrations/shared.ts +2 -2
  116. package/src/lib/runtime/agent-integrations/{langgraph.agent.ts → langgraph/agent.ts} +5 -30
  117. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +34 -0
  118. package/src/lib/runtime/agent-integrations/langgraph/index.ts +2 -0
  119. package/src/lib/runtime/copilot-runtime.ts +51 -68
  120. package/src/lib/runtime/telemetry-agent-runner.ts +134 -0
  121. package/src/service-adapters/anthropic/anthropic-adapter.ts +16 -3
  122. package/src/service-adapters/bedrock/bedrock-adapter.ts +4 -1
  123. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -1
  124. package/src/service-adapters/google/google-genai-adapter.ts +9 -4
  125. package/src/service-adapters/groq/groq-adapter.ts +16 -3
  126. package/src/service-adapters/langchain/langchain-adapter.ts +5 -3
  127. package/src/service-adapters/langchain/langserve.ts +2 -1
  128. package/src/service-adapters/openai/openai-adapter.ts +17 -3
  129. package/src/service-adapters/openai/openai-assistant-adapter.ts +26 -11
  130. package/src/service-adapters/unify/unify-adapter.ts +3 -1
  131. package/src/v2/index.ts +1 -0
  132. package/tsup.config.ts +5 -2
@@ -0,0 +1,3063 @@
1
+ import {
2
+ BaseMessageInput
3
+ } from "./chunk-2OZAGFV3.mjs";
4
+ import {
5
+ GuardrailsValidationFailureResponse,
6
+ MessageStreamInterruptedResponse,
7
+ ResponseStatusUnion,
8
+ SuccessResponseStatus,
9
+ UnknownErrorResponse
10
+ } from "./chunk-XWBDEXDA.mjs";
11
+ import {
12
+ aguiToGQL
13
+ } from "./chunk-62NE5S6M.mjs";
14
+ import {
15
+ ActionExecutionMessage,
16
+ ActionInputAvailability,
17
+ AgentStateMessage,
18
+ CopilotRequestType,
19
+ FailedMessageStatus,
20
+ MessageRole,
21
+ MessageStatusUnion,
22
+ ResultMessage,
23
+ SuccessMessageStatus,
24
+ TextMessage
25
+ } from "./chunk-OWIGJONH.mjs";
26
+ import {
27
+ __commonJS,
28
+ __name,
29
+ __toESM
30
+ } from "./chunk-FHD4JECV.mjs";
31
+
32
+ // package.json
33
+ var require_package = __commonJS({
34
+ "package.json"(exports, module) {
35
+ module.exports = {
36
+ name: "@copilotkit/runtime",
37
+ private: false,
38
+ homepage: "https://github.com/CopilotKit/CopilotKit",
39
+ repository: {
40
+ type: "git",
41
+ url: "https://github.com/CopilotKit/CopilotKit.git"
42
+ },
43
+ publishConfig: {
44
+ access: "public"
45
+ },
46
+ version: "1.10.6",
47
+ sideEffects: false,
48
+ main: "./dist/index.js",
49
+ module: "./dist/index.mjs",
50
+ exports: {
51
+ ".": "./dist/index.js"
52
+ },
53
+ types: "./dist/index.d.ts",
54
+ license: "MIT",
55
+ scripts: {
56
+ build: 'tsup --onSuccess "pnpm run generate-graphql-schema"',
57
+ dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
58
+ test: "jest --passWithNoTests",
59
+ "check-types": "tsc --noEmit",
60
+ clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next && rm -rf __snapshots__",
61
+ "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts",
62
+ "link:global": "pnpm link --global",
63
+ "unlink:global": "pnpm unlink --global"
64
+ },
65
+ devDependencies: {
66
+ "@jest/globals": "^29.7.0",
67
+ "@swc/core": "1.5.28",
68
+ "@types/express": "^4.17.21",
69
+ "@types/jest": "^29.5.12",
70
+ "@types/node": "^18.11.17",
71
+ "@whatwg-node/server": "^0.9.34",
72
+ eslint: "^8.56.0",
73
+ "eslint-config-custom": "workspace:*",
74
+ jest: "^29.6.4",
75
+ nodemon: "^3.1.3",
76
+ "ts-jest": "^29.1.1",
77
+ "ts-node": "^10.9.2",
78
+ tsconfig: "workspace:*",
79
+ tsup: "^6.7.0",
80
+ typescript: "^5.2.3",
81
+ vitest: "^3.2.4",
82
+ "zod-to-json-schema": "^3.23.5"
83
+ },
84
+ dependencies: {
85
+ "@anthropic-ai/sdk": "^0.57.0",
86
+ "@copilotkit/shared": "workspace:*",
87
+ "@copilotkitnext/agent": "^0.0.17",
88
+ "@copilotkitnext/runtime": "^0.0.17",
89
+ "@graphql-yoga/plugin-defer-stream": "^3.3.1",
90
+ "@langchain/aws": "^0.1.9",
91
+ "@langchain/community": "^0.3.29",
92
+ "@langchain/core": "^0.3.38",
93
+ "@langchain/google-gauth": "^0.1.0",
94
+ "@langchain/langgraph-sdk": "^0.0.70",
95
+ "@langchain/openai": "^0.4.2",
96
+ "@scarf/scarf": "^1.3.0",
97
+ "class-transformer": "^0.5.1",
98
+ "class-validator": "^0.14.1",
99
+ express: "^4.19.2",
100
+ graphql: "^16.8.1",
101
+ "graphql-scalars": "^1.23.0",
102
+ "graphql-yoga": "^5.3.1",
103
+ "groq-sdk": "^0.5.0",
104
+ langchain: "^0.3.3",
105
+ openai: "^4.85.1",
106
+ "partial-json": "^0.1.7",
107
+ pino: "^9.2.0",
108
+ "pino-pretty": "^11.2.1",
109
+ "reflect-metadata": "^0.2.2",
110
+ rxjs: "7.8.1",
111
+ "type-graphql": "2.0.0-rc.1",
112
+ zod: "^3.23.3"
113
+ },
114
+ peerDependencies: {
115
+ "@ag-ui/client": ">=0.0.39",
116
+ "@ag-ui/core": ">=0.0.39",
117
+ "@ag-ui/encoder": ">=0.0.39",
118
+ "@ag-ui/langgraph": ">=0.0.18",
119
+ "@ag-ui/proto": ">=0.0.39"
120
+ },
121
+ keywords: [
122
+ "copilotkit",
123
+ "copilot",
124
+ "react",
125
+ "nextjs",
126
+ "nodejs",
127
+ "ai",
128
+ "assistant",
129
+ "javascript",
130
+ "automation",
131
+ "textarea"
132
+ ]
133
+ };
134
+ }
135
+ });
136
+
137
+ // src/lib/integrations/node-http/index.ts
138
+ import { createCopilotEndpoint } from "@copilotkitnext/runtime";
139
+
140
+ // src/lib/integrations/shared.ts
141
+ import { buildSchemaSync } from "type-graphql";
142
+
143
+ // src/graphql/resolvers/copilot.resolver.ts
144
+ import { Arg, Ctx, Mutation, Query, Resolver } from "type-graphql";
145
+ import { ReplaySubject as ReplaySubject2, Subject, filter, finalize, firstValueFrom, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
146
+
147
+ // src/graphql/inputs/generate-copilot-response.input.ts
148
+ import { Field as Field15, InputType as InputType12 } from "type-graphql";
149
+
150
+ // src/graphql/inputs/message.input.ts
151
+ import { Field, InputType } from "type-graphql";
152
+ function _ts_decorate(decorators, target, key, desc) {
153
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
154
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
155
+ r = Reflect.decorate(decorators, target, key, desc);
156
+ else
157
+ for (var i = decorators.length - 1; i >= 0; i--)
158
+ if (d = decorators[i])
159
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
160
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
161
+ }
162
+ __name(_ts_decorate, "_ts_decorate");
163
+ function _ts_metadata(k, v) {
164
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
165
+ return Reflect.metadata(k, v);
166
+ }
167
+ __name(_ts_metadata, "_ts_metadata");
168
+ var MessageInput = class extends BaseMessageInput {
169
+ textMessage;
170
+ actionExecutionMessage;
171
+ resultMessage;
172
+ agentStateMessage;
173
+ imageMessage;
174
+ };
175
+ __name(MessageInput, "MessageInput");
176
+ _ts_decorate([
177
+ Field(() => TextMessageInput, {
178
+ nullable: true
179
+ }),
180
+ _ts_metadata("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
181
+ ], MessageInput.prototype, "textMessage", void 0);
182
+ _ts_decorate([
183
+ Field(() => ActionExecutionMessageInput, {
184
+ nullable: true
185
+ }),
186
+ _ts_metadata("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
187
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
188
+ _ts_decorate([
189
+ Field(() => ResultMessageInput, {
190
+ nullable: true
191
+ }),
192
+ _ts_metadata("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
193
+ ], MessageInput.prototype, "resultMessage", void 0);
194
+ _ts_decorate([
195
+ Field(() => AgentStateMessageInput, {
196
+ nullable: true
197
+ }),
198
+ _ts_metadata("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
199
+ ], MessageInput.prototype, "agentStateMessage", void 0);
200
+ _ts_decorate([
201
+ Field(() => ImageMessageInput, {
202
+ nullable: true
203
+ }),
204
+ _ts_metadata("design:type", typeof ImageMessageInput === "undefined" ? Object : ImageMessageInput)
205
+ ], MessageInput.prototype, "imageMessage", void 0);
206
+ MessageInput = _ts_decorate([
207
+ InputType()
208
+ ], MessageInput);
209
+ var TextMessageInput = class {
210
+ content;
211
+ parentMessageId;
212
+ role;
213
+ };
214
+ __name(TextMessageInput, "TextMessageInput");
215
+ _ts_decorate([
216
+ Field(() => String),
217
+ _ts_metadata("design:type", String)
218
+ ], TextMessageInput.prototype, "content", void 0);
219
+ _ts_decorate([
220
+ Field(() => String, {
221
+ nullable: true
222
+ }),
223
+ _ts_metadata("design:type", String)
224
+ ], TextMessageInput.prototype, "parentMessageId", void 0);
225
+ _ts_decorate([
226
+ Field(() => MessageRole),
227
+ _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
228
+ ], TextMessageInput.prototype, "role", void 0);
229
+ TextMessageInput = _ts_decorate([
230
+ InputType()
231
+ ], TextMessageInput);
232
+ var ActionExecutionMessageInput = class {
233
+ name;
234
+ arguments;
235
+ parentMessageId;
236
+ scope;
237
+ };
238
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
239
+ _ts_decorate([
240
+ Field(() => String),
241
+ _ts_metadata("design:type", String)
242
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
243
+ _ts_decorate([
244
+ Field(() => String),
245
+ _ts_metadata("design:type", String)
246
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
247
+ _ts_decorate([
248
+ Field(() => String, {
249
+ nullable: true
250
+ }),
251
+ _ts_metadata("design:type", String)
252
+ ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
253
+ _ts_decorate([
254
+ Field(() => String, {
255
+ nullable: true,
256
+ deprecationReason: "This field will be removed in a future version"
257
+ }),
258
+ _ts_metadata("design:type", typeof String === "undefined" ? Object : String)
259
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
260
+ ActionExecutionMessageInput = _ts_decorate([
261
+ InputType()
262
+ ], ActionExecutionMessageInput);
263
+ var ResultMessageInput = class {
264
+ actionExecutionId;
265
+ actionName;
266
+ parentMessageId;
267
+ result;
268
+ };
269
+ __name(ResultMessageInput, "ResultMessageInput");
270
+ _ts_decorate([
271
+ Field(() => String),
272
+ _ts_metadata("design:type", String)
273
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
274
+ _ts_decorate([
275
+ Field(() => String),
276
+ _ts_metadata("design:type", String)
277
+ ], ResultMessageInput.prototype, "actionName", void 0);
278
+ _ts_decorate([
279
+ Field(() => String, {
280
+ nullable: true
281
+ }),
282
+ _ts_metadata("design:type", String)
283
+ ], ResultMessageInput.prototype, "parentMessageId", void 0);
284
+ _ts_decorate([
285
+ Field(() => String),
286
+ _ts_metadata("design:type", String)
287
+ ], ResultMessageInput.prototype, "result", void 0);
288
+ ResultMessageInput = _ts_decorate([
289
+ InputType()
290
+ ], ResultMessageInput);
291
+ var AgentStateMessageInput = class {
292
+ threadId;
293
+ agentName;
294
+ role;
295
+ state;
296
+ running;
297
+ nodeName;
298
+ runId;
299
+ active;
300
+ };
301
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
302
+ _ts_decorate([
303
+ Field(() => String),
304
+ _ts_metadata("design:type", String)
305
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
306
+ _ts_decorate([
307
+ Field(() => String),
308
+ _ts_metadata("design:type", String)
309
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
310
+ _ts_decorate([
311
+ Field(() => MessageRole),
312
+ _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
313
+ ], AgentStateMessageInput.prototype, "role", void 0);
314
+ _ts_decorate([
315
+ Field(() => String),
316
+ _ts_metadata("design:type", String)
317
+ ], AgentStateMessageInput.prototype, "state", void 0);
318
+ _ts_decorate([
319
+ Field(() => Boolean),
320
+ _ts_metadata("design:type", Boolean)
321
+ ], AgentStateMessageInput.prototype, "running", void 0);
322
+ _ts_decorate([
323
+ Field(() => String),
324
+ _ts_metadata("design:type", String)
325
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
326
+ _ts_decorate([
327
+ Field(() => String),
328
+ _ts_metadata("design:type", String)
329
+ ], AgentStateMessageInput.prototype, "runId", void 0);
330
+ _ts_decorate([
331
+ Field(() => Boolean),
332
+ _ts_metadata("design:type", Boolean)
333
+ ], AgentStateMessageInput.prototype, "active", void 0);
334
+ AgentStateMessageInput = _ts_decorate([
335
+ InputType()
336
+ ], AgentStateMessageInput);
337
+ var ImageMessageInput = class {
338
+ format;
339
+ bytes;
340
+ parentMessageId;
341
+ role;
342
+ };
343
+ __name(ImageMessageInput, "ImageMessageInput");
344
+ _ts_decorate([
345
+ Field(() => String),
346
+ _ts_metadata("design:type", String)
347
+ ], ImageMessageInput.prototype, "format", void 0);
348
+ _ts_decorate([
349
+ Field(() => String),
350
+ _ts_metadata("design:type", String)
351
+ ], ImageMessageInput.prototype, "bytes", void 0);
352
+ _ts_decorate([
353
+ Field(() => String, {
354
+ nullable: true
355
+ }),
356
+ _ts_metadata("design:type", String)
357
+ ], ImageMessageInput.prototype, "parentMessageId", void 0);
358
+ _ts_decorate([
359
+ Field(() => MessageRole),
360
+ _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
361
+ ], ImageMessageInput.prototype, "role", void 0);
362
+ ImageMessageInput = _ts_decorate([
363
+ InputType()
364
+ ], ImageMessageInput);
365
+
366
+ // src/graphql/inputs/frontend.input.ts
367
+ import { Field as Field3, InputType as InputType3 } from "type-graphql";
368
+
369
+ // src/graphql/inputs/action.input.ts
370
+ import { Field as Field2, InputType as InputType2 } from "type-graphql";
371
+ function _ts_decorate2(decorators, target, key, desc) {
372
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
373
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
374
+ r = Reflect.decorate(decorators, target, key, desc);
375
+ else
376
+ for (var i = decorators.length - 1; i >= 0; i--)
377
+ if (d = decorators[i])
378
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
379
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
380
+ }
381
+ __name(_ts_decorate2, "_ts_decorate");
382
+ function _ts_metadata2(k, v) {
383
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
384
+ return Reflect.metadata(k, v);
385
+ }
386
+ __name(_ts_metadata2, "_ts_metadata");
387
+ var ActionInput = class {
388
+ name;
389
+ description;
390
+ jsonSchema;
391
+ available;
392
+ };
393
+ __name(ActionInput, "ActionInput");
394
+ _ts_decorate2([
395
+ Field2(() => String),
396
+ _ts_metadata2("design:type", String)
397
+ ], ActionInput.prototype, "name", void 0);
398
+ _ts_decorate2([
399
+ Field2(() => String),
400
+ _ts_metadata2("design:type", String)
401
+ ], ActionInput.prototype, "description", void 0);
402
+ _ts_decorate2([
403
+ Field2(() => String),
404
+ _ts_metadata2("design:type", String)
405
+ ], ActionInput.prototype, "jsonSchema", void 0);
406
+ _ts_decorate2([
407
+ Field2(() => ActionInputAvailability, {
408
+ nullable: true
409
+ }),
410
+ _ts_metadata2("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
411
+ ], ActionInput.prototype, "available", void 0);
412
+ ActionInput = _ts_decorate2([
413
+ InputType2()
414
+ ], ActionInput);
415
+
416
+ // src/graphql/inputs/frontend.input.ts
417
+ function _ts_decorate3(decorators, target, key, desc) {
418
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
419
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
420
+ r = Reflect.decorate(decorators, target, key, desc);
421
+ else
422
+ for (var i = decorators.length - 1; i >= 0; i--)
423
+ if (d = decorators[i])
424
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
425
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
426
+ }
427
+ __name(_ts_decorate3, "_ts_decorate");
428
+ function _ts_metadata3(k, v) {
429
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
430
+ return Reflect.metadata(k, v);
431
+ }
432
+ __name(_ts_metadata3, "_ts_metadata");
433
+ var FrontendInput = class {
434
+ toDeprecate_fullContext;
435
+ actions;
436
+ url;
437
+ };
438
+ __name(FrontendInput, "FrontendInput");
439
+ _ts_decorate3([
440
+ Field3(() => String, {
441
+ nullable: true
442
+ }),
443
+ _ts_metadata3("design:type", String)
444
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
445
+ _ts_decorate3([
446
+ Field3(() => [
447
+ ActionInput
448
+ ]),
449
+ _ts_metadata3("design:type", Array)
450
+ ], FrontendInput.prototype, "actions", void 0);
451
+ _ts_decorate3([
452
+ Field3(() => String, {
453
+ nullable: true
454
+ }),
455
+ _ts_metadata3("design:type", String)
456
+ ], FrontendInput.prototype, "url", void 0);
457
+ FrontendInput = _ts_decorate3([
458
+ InputType3()
459
+ ], FrontendInput);
460
+
461
+ // src/graphql/inputs/cloud.input.ts
462
+ import { Field as Field5, InputType as InputType5 } from "type-graphql";
463
+
464
+ // src/graphql/inputs/cloud-guardrails.input.ts
465
+ import { Field as Field4, InputType as InputType4 } from "type-graphql";
466
+ function _ts_decorate4(decorators, target, key, desc) {
467
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
468
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
469
+ r = Reflect.decorate(decorators, target, key, desc);
470
+ else
471
+ for (var i = decorators.length - 1; i >= 0; i--)
472
+ if (d = decorators[i])
473
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
474
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
475
+ }
476
+ __name(_ts_decorate4, "_ts_decorate");
477
+ function _ts_metadata4(k, v) {
478
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
479
+ return Reflect.metadata(k, v);
480
+ }
481
+ __name(_ts_metadata4, "_ts_metadata");
482
+ var GuardrailsRuleInput = class {
483
+ allowList = [];
484
+ denyList = [];
485
+ };
486
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
487
+ _ts_decorate4([
488
+ Field4(() => [
489
+ String
490
+ ], {
491
+ nullable: true
492
+ }),
493
+ _ts_metadata4("design:type", Array)
494
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
495
+ _ts_decorate4([
496
+ Field4(() => [
497
+ String
498
+ ], {
499
+ nullable: true
500
+ }),
501
+ _ts_metadata4("design:type", Array)
502
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
503
+ GuardrailsRuleInput = _ts_decorate4([
504
+ InputType4()
505
+ ], GuardrailsRuleInput);
506
+ var GuardrailsInput = class {
507
+ inputValidationRules;
508
+ };
509
+ __name(GuardrailsInput, "GuardrailsInput");
510
+ _ts_decorate4([
511
+ Field4(() => GuardrailsRuleInput, {
512
+ nullable: false
513
+ }),
514
+ _ts_metadata4("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
515
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
516
+ GuardrailsInput = _ts_decorate4([
517
+ InputType4()
518
+ ], GuardrailsInput);
519
+
520
+ // src/graphql/inputs/cloud.input.ts
521
+ function _ts_decorate5(decorators, target, key, desc) {
522
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
523
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
524
+ r = Reflect.decorate(decorators, target, key, desc);
525
+ else
526
+ for (var i = decorators.length - 1; i >= 0; i--)
527
+ if (d = decorators[i])
528
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
529
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
530
+ }
531
+ __name(_ts_decorate5, "_ts_decorate");
532
+ function _ts_metadata5(k, v) {
533
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
534
+ return Reflect.metadata(k, v);
535
+ }
536
+ __name(_ts_metadata5, "_ts_metadata");
537
+ var CloudInput = class {
538
+ guardrails;
539
+ };
540
+ __name(CloudInput, "CloudInput");
541
+ _ts_decorate5([
542
+ Field5(() => GuardrailsInput, {
543
+ nullable: true
544
+ }),
545
+ _ts_metadata5("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
546
+ ], CloudInput.prototype, "guardrails", void 0);
547
+ CloudInput = _ts_decorate5([
548
+ InputType5()
549
+ ], CloudInput);
550
+
551
+ // src/graphql/inputs/forwarded-parameters.input.ts
552
+ import { Field as Field6, InputType as InputType6 } from "type-graphql";
553
+ function _ts_decorate6(decorators, target, key, desc) {
554
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
555
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
556
+ r = Reflect.decorate(decorators, target, key, desc);
557
+ else
558
+ for (var i = decorators.length - 1; i >= 0; i--)
559
+ if (d = decorators[i])
560
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
561
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
562
+ }
563
+ __name(_ts_decorate6, "_ts_decorate");
564
+ function _ts_metadata6(k, v) {
565
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
566
+ return Reflect.metadata(k, v);
567
+ }
568
+ __name(_ts_metadata6, "_ts_metadata");
569
+ var ForwardedParametersInput = class {
570
+ model;
571
+ maxTokens;
572
+ stop;
573
+ toolChoice;
574
+ toolChoiceFunctionName;
575
+ temperature;
576
+ };
577
+ __name(ForwardedParametersInput, "ForwardedParametersInput");
578
+ _ts_decorate6([
579
+ Field6(() => String, {
580
+ nullable: true
581
+ }),
582
+ _ts_metadata6("design:type", String)
583
+ ], ForwardedParametersInput.prototype, "model", void 0);
584
+ _ts_decorate6([
585
+ Field6(() => Number, {
586
+ nullable: true
587
+ }),
588
+ _ts_metadata6("design:type", Number)
589
+ ], ForwardedParametersInput.prototype, "maxTokens", void 0);
590
+ _ts_decorate6([
591
+ Field6(() => [
592
+ String
593
+ ], {
594
+ nullable: true
595
+ }),
596
+ _ts_metadata6("design:type", Array)
597
+ ], ForwardedParametersInput.prototype, "stop", void 0);
598
+ _ts_decorate6([
599
+ Field6(() => String, {
600
+ nullable: true
601
+ }),
602
+ _ts_metadata6("design:type", typeof String === "undefined" ? Object : String)
603
+ ], ForwardedParametersInput.prototype, "toolChoice", void 0);
604
+ _ts_decorate6([
605
+ Field6(() => String, {
606
+ nullable: true
607
+ }),
608
+ _ts_metadata6("design:type", String)
609
+ ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
610
+ _ts_decorate6([
611
+ Field6(() => Number, {
612
+ nullable: true
613
+ }),
614
+ _ts_metadata6("design:type", Number)
615
+ ], ForwardedParametersInput.prototype, "temperature", void 0);
616
+ ForwardedParametersInput = _ts_decorate6([
617
+ InputType6()
618
+ ], ForwardedParametersInput);
619
+
620
+ // src/graphql/inputs/agent-session.input.ts
621
+ import { Field as Field7, InputType as InputType7 } from "type-graphql";
622
+ function _ts_decorate7(decorators, target, key, desc) {
623
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
624
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
625
+ r = Reflect.decorate(decorators, target, key, desc);
626
+ else
627
+ for (var i = decorators.length - 1; i >= 0; i--)
628
+ if (d = decorators[i])
629
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
630
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
631
+ }
632
+ __name(_ts_decorate7, "_ts_decorate");
633
+ function _ts_metadata7(k, v) {
634
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
635
+ return Reflect.metadata(k, v);
636
+ }
637
+ __name(_ts_metadata7, "_ts_metadata");
638
+ var AgentSessionInput = class {
639
+ agentName;
640
+ threadId;
641
+ nodeName;
642
+ };
643
+ __name(AgentSessionInput, "AgentSessionInput");
644
+ _ts_decorate7([
645
+ Field7(() => String),
646
+ _ts_metadata7("design:type", String)
647
+ ], AgentSessionInput.prototype, "agentName", void 0);
648
+ _ts_decorate7([
649
+ Field7(() => String, {
650
+ nullable: true
651
+ }),
652
+ _ts_metadata7("design:type", String)
653
+ ], AgentSessionInput.prototype, "threadId", void 0);
654
+ _ts_decorate7([
655
+ Field7(() => String, {
656
+ nullable: true
657
+ }),
658
+ _ts_metadata7("design:type", String)
659
+ ], AgentSessionInput.prototype, "nodeName", void 0);
660
+ AgentSessionInput = _ts_decorate7([
661
+ InputType7()
662
+ ], AgentSessionInput);
663
+
664
+ // src/graphql/inputs/agent-state.input.ts
665
+ import { Field as Field8, InputType as InputType8 } from "type-graphql";
666
+ function _ts_decorate8(decorators, target, key, desc) {
667
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
668
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
669
+ r = Reflect.decorate(decorators, target, key, desc);
670
+ else
671
+ for (var i = decorators.length - 1; i >= 0; i--)
672
+ if (d = decorators[i])
673
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
674
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
675
+ }
676
+ __name(_ts_decorate8, "_ts_decorate");
677
+ function _ts_metadata8(k, v) {
678
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
679
+ return Reflect.metadata(k, v);
680
+ }
681
+ __name(_ts_metadata8, "_ts_metadata");
682
+ var AgentStateInput = class {
683
+ agentName;
684
+ state;
685
+ config;
686
+ };
687
+ __name(AgentStateInput, "AgentStateInput");
688
+ _ts_decorate8([
689
+ Field8(() => String),
690
+ _ts_metadata8("design:type", String)
691
+ ], AgentStateInput.prototype, "agentName", void 0);
692
+ _ts_decorate8([
693
+ Field8(() => String),
694
+ _ts_metadata8("design:type", String)
695
+ ], AgentStateInput.prototype, "state", void 0);
696
+ _ts_decorate8([
697
+ Field8(() => String, {
698
+ nullable: true
699
+ }),
700
+ _ts_metadata8("design:type", String)
701
+ ], AgentStateInput.prototype, "config", void 0);
702
+ AgentStateInput = _ts_decorate8([
703
+ InputType8()
704
+ ], AgentStateInput);
705
+
706
+ // src/graphql/inputs/extensions.input.ts
707
+ import { Field as Field9, InputType as InputType9 } from "type-graphql";
708
+ function _ts_decorate9(decorators, target, key, desc) {
709
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
710
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
711
+ r = Reflect.decorate(decorators, target, key, desc);
712
+ else
713
+ for (var i = decorators.length - 1; i >= 0; i--)
714
+ if (d = decorators[i])
715
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
716
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
717
+ }
718
+ __name(_ts_decorate9, "_ts_decorate");
719
+ function _ts_metadata9(k, v) {
720
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
721
+ return Reflect.metadata(k, v);
722
+ }
723
+ __name(_ts_metadata9, "_ts_metadata");
724
+ var ExtensionsInput = class {
725
+ openaiAssistantAPI;
726
+ };
727
+ __name(ExtensionsInput, "ExtensionsInput");
728
+ _ts_decorate9([
729
+ Field9(() => OpenAIApiAssistantAPIInput, {
730
+ nullable: true
731
+ }),
732
+ _ts_metadata9("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
733
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
734
+ ExtensionsInput = _ts_decorate9([
735
+ InputType9()
736
+ ], ExtensionsInput);
737
+ var OpenAIApiAssistantAPIInput = class {
738
+ runId;
739
+ threadId;
740
+ };
741
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
742
+ _ts_decorate9([
743
+ Field9(() => String, {
744
+ nullable: true
745
+ }),
746
+ _ts_metadata9("design:type", String)
747
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
748
+ _ts_decorate9([
749
+ Field9(() => String, {
750
+ nullable: true
751
+ }),
752
+ _ts_metadata9("design:type", String)
753
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
754
+ OpenAIApiAssistantAPIInput = _ts_decorate9([
755
+ InputType9()
756
+ ], OpenAIApiAssistantAPIInput);
757
+
758
+ // src/graphql/inputs/meta-event.input.ts
759
+ import { Field as Field13, InputType as InputType10 } from "type-graphql";
760
+
761
+ // src/graphql/types/meta-events.type.ts
762
+ import { Field as Field12, InterfaceType as InterfaceType2, ObjectType as ObjectType3, registerEnumType } from "type-graphql";
763
+
764
+ // src/graphql/types/copilot-response.type.ts
765
+ import { Field as Field11, InterfaceType, ObjectType as ObjectType2 } from "type-graphql";
766
+
767
+ // src/graphql/types/extensions-response.type.ts
768
+ import { Field as Field10, ObjectType } from "type-graphql";
769
+ function _ts_decorate10(decorators, target, key, desc) {
770
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
771
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
772
+ r = Reflect.decorate(decorators, target, key, desc);
773
+ else
774
+ for (var i = decorators.length - 1; i >= 0; i--)
775
+ if (d = decorators[i])
776
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
777
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
778
+ }
779
+ __name(_ts_decorate10, "_ts_decorate");
780
+ function _ts_metadata10(k, v) {
781
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
782
+ return Reflect.metadata(k, v);
783
+ }
784
+ __name(_ts_metadata10, "_ts_metadata");
785
+ var ExtensionsResponse = class {
786
+ openaiAssistantAPI;
787
+ };
788
+ __name(ExtensionsResponse, "ExtensionsResponse");
789
+ _ts_decorate10([
790
+ Field10(() => OpenAIApiAssistantAPIResponse, {
791
+ nullable: true
792
+ }),
793
+ _ts_metadata10("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
794
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
795
+ ExtensionsResponse = _ts_decorate10([
796
+ ObjectType()
797
+ ], ExtensionsResponse);
798
+ var OpenAIApiAssistantAPIResponse = class {
799
+ runId;
800
+ threadId;
801
+ };
802
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
803
+ _ts_decorate10([
804
+ Field10(() => String, {
805
+ nullable: true
806
+ }),
807
+ _ts_metadata10("design:type", String)
808
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
809
+ _ts_decorate10([
810
+ Field10(() => String, {
811
+ nullable: true
812
+ }),
813
+ _ts_metadata10("design:type", String)
814
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
815
+ OpenAIApiAssistantAPIResponse = _ts_decorate10([
816
+ ObjectType()
817
+ ], OpenAIApiAssistantAPIResponse);
818
+
819
+ // src/graphql/types/copilot-response.type.ts
820
+ function _ts_decorate11(decorators, target, key, desc) {
821
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
822
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
823
+ r = Reflect.decorate(decorators, target, key, desc);
824
+ else
825
+ for (var i = decorators.length - 1; i >= 0; i--)
826
+ if (d = decorators[i])
827
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
828
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
829
+ }
830
+ __name(_ts_decorate11, "_ts_decorate");
831
+ function _ts_metadata11(k, v) {
832
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
833
+ return Reflect.metadata(k, v);
834
+ }
835
+ __name(_ts_metadata11, "_ts_metadata");
836
+ var BaseMessageOutput = class {
837
+ id;
838
+ createdAt;
839
+ status;
840
+ };
841
+ __name(BaseMessageOutput, "BaseMessageOutput");
842
+ _ts_decorate11([
843
+ Field11(() => String),
844
+ _ts_metadata11("design:type", String)
845
+ ], BaseMessageOutput.prototype, "id", void 0);
846
+ _ts_decorate11([
847
+ Field11(() => Date),
848
+ _ts_metadata11("design:type", typeof Date === "undefined" ? Object : Date)
849
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
850
+ _ts_decorate11([
851
+ Field11(() => MessageStatusUnion),
852
+ _ts_metadata11("design:type", Object)
853
+ ], BaseMessageOutput.prototype, "status", void 0);
854
+ BaseMessageOutput = _ts_decorate11([
855
+ InterfaceType({
856
+ resolveType(value) {
857
+ if (value.hasOwnProperty("content")) {
858
+ return TextMessageOutput;
859
+ } else if (value.hasOwnProperty("name")) {
860
+ return ActionExecutionMessageOutput;
861
+ } else if (value.hasOwnProperty("result")) {
862
+ return ResultMessageOutput;
863
+ } else if (value.hasOwnProperty("state")) {
864
+ return AgentStateMessageOutput;
865
+ } else if (value.hasOwnProperty("format") && value.hasOwnProperty("bytes")) {
866
+ return ImageMessageOutput;
867
+ }
868
+ return void 0;
869
+ }
870
+ })
871
+ ], BaseMessageOutput);
872
+ var TextMessageOutput = class {
873
+ role;
874
+ content;
875
+ parentMessageId;
876
+ };
877
+ __name(TextMessageOutput, "TextMessageOutput");
878
+ _ts_decorate11([
879
+ Field11(() => MessageRole),
880
+ _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
881
+ ], TextMessageOutput.prototype, "role", void 0);
882
+ _ts_decorate11([
883
+ Field11(() => [
884
+ String
885
+ ]),
886
+ _ts_metadata11("design:type", Array)
887
+ ], TextMessageOutput.prototype, "content", void 0);
888
+ _ts_decorate11([
889
+ Field11(() => String, {
890
+ nullable: true
891
+ }),
892
+ _ts_metadata11("design:type", String)
893
+ ], TextMessageOutput.prototype, "parentMessageId", void 0);
894
+ TextMessageOutput = _ts_decorate11([
895
+ ObjectType2({
896
+ implements: BaseMessageOutput
897
+ })
898
+ ], TextMessageOutput);
899
+ var ActionExecutionMessageOutput = class {
900
+ name;
901
+ scope;
902
+ arguments;
903
+ parentMessageId;
904
+ };
905
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
906
+ _ts_decorate11([
907
+ Field11(() => String),
908
+ _ts_metadata11("design:type", String)
909
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
910
+ _ts_decorate11([
911
+ Field11(() => String, {
912
+ nullable: true,
913
+ deprecationReason: "This field will be removed in a future version"
914
+ }),
915
+ _ts_metadata11("design:type", String)
916
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
917
+ _ts_decorate11([
918
+ Field11(() => [
919
+ String
920
+ ]),
921
+ _ts_metadata11("design:type", Array)
922
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
923
+ _ts_decorate11([
924
+ Field11(() => String, {
925
+ nullable: true
926
+ }),
927
+ _ts_metadata11("design:type", String)
928
+ ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
929
+ ActionExecutionMessageOutput = _ts_decorate11([
930
+ ObjectType2({
931
+ implements: BaseMessageOutput
932
+ })
933
+ ], ActionExecutionMessageOutput);
934
+ var ResultMessageOutput = class {
935
+ actionExecutionId;
936
+ actionName;
937
+ result;
938
+ };
939
+ __name(ResultMessageOutput, "ResultMessageOutput");
940
+ _ts_decorate11([
941
+ Field11(() => String),
942
+ _ts_metadata11("design:type", String)
943
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
944
+ _ts_decorate11([
945
+ Field11(() => String),
946
+ _ts_metadata11("design:type", String)
947
+ ], ResultMessageOutput.prototype, "actionName", void 0);
948
+ _ts_decorate11([
949
+ Field11(() => String),
950
+ _ts_metadata11("design:type", String)
951
+ ], ResultMessageOutput.prototype, "result", void 0);
952
+ ResultMessageOutput = _ts_decorate11([
953
+ ObjectType2({
954
+ implements: BaseMessageOutput
955
+ })
956
+ ], ResultMessageOutput);
957
+ var AgentStateMessageOutput = class {
958
+ threadId;
959
+ agentName;
960
+ nodeName;
961
+ runId;
962
+ active;
963
+ role;
964
+ state;
965
+ running;
966
+ };
967
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
968
+ _ts_decorate11([
969
+ Field11(() => String),
970
+ _ts_metadata11("design:type", String)
971
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
972
+ _ts_decorate11([
973
+ Field11(() => String),
974
+ _ts_metadata11("design:type", String)
975
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
976
+ _ts_decorate11([
977
+ Field11(() => String),
978
+ _ts_metadata11("design:type", String)
979
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
980
+ _ts_decorate11([
981
+ Field11(() => String),
982
+ _ts_metadata11("design:type", String)
983
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
984
+ _ts_decorate11([
985
+ Field11(() => Boolean),
986
+ _ts_metadata11("design:type", Boolean)
987
+ ], AgentStateMessageOutput.prototype, "active", void 0);
988
+ _ts_decorate11([
989
+ Field11(() => MessageRole),
990
+ _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
991
+ ], AgentStateMessageOutput.prototype, "role", void 0);
992
+ _ts_decorate11([
993
+ Field11(() => String),
994
+ _ts_metadata11("design:type", String)
995
+ ], AgentStateMessageOutput.prototype, "state", void 0);
996
+ _ts_decorate11([
997
+ Field11(() => Boolean),
998
+ _ts_metadata11("design:type", Boolean)
999
+ ], AgentStateMessageOutput.prototype, "running", void 0);
1000
+ AgentStateMessageOutput = _ts_decorate11([
1001
+ ObjectType2({
1002
+ implements: BaseMessageOutput
1003
+ })
1004
+ ], AgentStateMessageOutput);
1005
+ var ImageMessageOutput = class {
1006
+ format;
1007
+ bytes;
1008
+ role;
1009
+ parentMessageId;
1010
+ };
1011
+ __name(ImageMessageOutput, "ImageMessageOutput");
1012
+ _ts_decorate11([
1013
+ Field11(() => String),
1014
+ _ts_metadata11("design:type", String)
1015
+ ], ImageMessageOutput.prototype, "format", void 0);
1016
+ _ts_decorate11([
1017
+ Field11(() => String),
1018
+ _ts_metadata11("design:type", String)
1019
+ ], ImageMessageOutput.prototype, "bytes", void 0);
1020
+ _ts_decorate11([
1021
+ Field11(() => MessageRole),
1022
+ _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1023
+ ], ImageMessageOutput.prototype, "role", void 0);
1024
+ _ts_decorate11([
1025
+ Field11(() => String, {
1026
+ nullable: true
1027
+ }),
1028
+ _ts_metadata11("design:type", String)
1029
+ ], ImageMessageOutput.prototype, "parentMessageId", void 0);
1030
+ ImageMessageOutput = _ts_decorate11([
1031
+ ObjectType2({
1032
+ implements: BaseMessageOutput
1033
+ })
1034
+ ], ImageMessageOutput);
1035
+ var CopilotResponse = class {
1036
+ threadId;
1037
+ status;
1038
+ runId;
1039
+ messages;
1040
+ extensions;
1041
+ metaEvents;
1042
+ };
1043
+ __name(CopilotResponse, "CopilotResponse");
1044
+ _ts_decorate11([
1045
+ Field11(() => String),
1046
+ _ts_metadata11("design:type", String)
1047
+ ], CopilotResponse.prototype, "threadId", void 0);
1048
+ _ts_decorate11([
1049
+ Field11(() => ResponseStatusUnion),
1050
+ _ts_metadata11("design:type", Object)
1051
+ ], CopilotResponse.prototype, "status", void 0);
1052
+ _ts_decorate11([
1053
+ Field11({
1054
+ nullable: true
1055
+ }),
1056
+ _ts_metadata11("design:type", String)
1057
+ ], CopilotResponse.prototype, "runId", void 0);
1058
+ _ts_decorate11([
1059
+ Field11(() => [
1060
+ BaseMessageOutput
1061
+ ]),
1062
+ _ts_metadata11("design:type", Array)
1063
+ ], CopilotResponse.prototype, "messages", void 0);
1064
+ _ts_decorate11([
1065
+ Field11(() => ExtensionsResponse, {
1066
+ nullable: true
1067
+ }),
1068
+ _ts_metadata11("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
1069
+ ], CopilotResponse.prototype, "extensions", void 0);
1070
+ _ts_decorate11([
1071
+ Field11(() => [
1072
+ BaseMetaEvent
1073
+ ], {
1074
+ nullable: true
1075
+ }),
1076
+ _ts_metadata11("design:type", Array)
1077
+ ], CopilotResponse.prototype, "metaEvents", void 0);
1078
+ CopilotResponse = _ts_decorate11([
1079
+ ObjectType2()
1080
+ ], CopilotResponse);
1081
+
1082
+ // src/graphql/types/meta-events.type.ts
1083
+ function _ts_decorate12(decorators, target, key, desc) {
1084
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1085
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1086
+ r = Reflect.decorate(decorators, target, key, desc);
1087
+ else
1088
+ for (var i = decorators.length - 1; i >= 0; i--)
1089
+ if (d = decorators[i])
1090
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1091
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1092
+ }
1093
+ __name(_ts_decorate12, "_ts_decorate");
1094
+ function _ts_metadata12(k, v) {
1095
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1096
+ return Reflect.metadata(k, v);
1097
+ }
1098
+ __name(_ts_metadata12, "_ts_metadata");
1099
+ var MetaEventName;
1100
+ (function(MetaEventName2) {
1101
+ MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1102
+ MetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1103
+ })(MetaEventName || (MetaEventName = {}));
1104
+ registerEnumType(MetaEventName, {
1105
+ name: "MetaEventName",
1106
+ description: "Meta event types"
1107
+ });
1108
+ var BaseMetaEvent = class {
1109
+ type = "MetaEvent";
1110
+ name;
1111
+ };
1112
+ __name(BaseMetaEvent, "BaseMetaEvent");
1113
+ _ts_decorate12([
1114
+ Field12(() => String),
1115
+ _ts_metadata12("design:type", String)
1116
+ ], BaseMetaEvent.prototype, "type", void 0);
1117
+ _ts_decorate12([
1118
+ Field12(() => MetaEventName),
1119
+ _ts_metadata12("design:type", String)
1120
+ ], BaseMetaEvent.prototype, "name", void 0);
1121
+ BaseMetaEvent = _ts_decorate12([
1122
+ InterfaceType2({
1123
+ resolveType(value) {
1124
+ if (value.name === "LangGraphInterruptEvent") {
1125
+ return LangGraphInterruptEvent;
1126
+ } else if (value.name === "CopilotKitLangGraphInterruptEvent") {
1127
+ return CopilotKitLangGraphInterruptEvent;
1128
+ }
1129
+ return void 0;
1130
+ }
1131
+ }),
1132
+ InterfaceType2()
1133
+ ], BaseMetaEvent);
1134
+ var CopilotKitLangGraphInterruptEventData = class {
1135
+ value;
1136
+ messages;
1137
+ };
1138
+ __name(CopilotKitLangGraphInterruptEventData, "CopilotKitLangGraphInterruptEventData");
1139
+ _ts_decorate12([
1140
+ Field12(() => String),
1141
+ _ts_metadata12("design:type", String)
1142
+ ], CopilotKitLangGraphInterruptEventData.prototype, "value", void 0);
1143
+ _ts_decorate12([
1144
+ Field12(() => [
1145
+ BaseMessageOutput
1146
+ ]),
1147
+ _ts_metadata12("design:type", Array)
1148
+ ], CopilotKitLangGraphInterruptEventData.prototype, "messages", void 0);
1149
+ CopilotKitLangGraphInterruptEventData = _ts_decorate12([
1150
+ ObjectType3()
1151
+ ], CopilotKitLangGraphInterruptEventData);
1152
+ var LangGraphInterruptEvent = class {
1153
+ name = "LangGraphInterruptEvent";
1154
+ value;
1155
+ response;
1156
+ };
1157
+ __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
1158
+ _ts_decorate12([
1159
+ Field12(() => MetaEventName),
1160
+ _ts_metadata12("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
1161
+ ], LangGraphInterruptEvent.prototype, "name", void 0);
1162
+ _ts_decorate12([
1163
+ Field12(() => String),
1164
+ _ts_metadata12("design:type", String)
1165
+ ], LangGraphInterruptEvent.prototype, "value", void 0);
1166
+ _ts_decorate12([
1167
+ Field12(() => String, {
1168
+ nullable: true
1169
+ }),
1170
+ _ts_metadata12("design:type", String)
1171
+ ], LangGraphInterruptEvent.prototype, "response", void 0);
1172
+ LangGraphInterruptEvent = _ts_decorate12([
1173
+ ObjectType3({
1174
+ implements: BaseMetaEvent
1175
+ })
1176
+ ], LangGraphInterruptEvent);
1177
+ var CopilotKitLangGraphInterruptEvent = class {
1178
+ name = "CopilotKitLangGraphInterruptEvent";
1179
+ data;
1180
+ response;
1181
+ };
1182
+ __name(CopilotKitLangGraphInterruptEvent, "CopilotKitLangGraphInterruptEvent");
1183
+ _ts_decorate12([
1184
+ Field12(() => MetaEventName),
1185
+ _ts_metadata12("design:type", typeof MetaEventName === "undefined" || false ? Object : "CopilotKitLangGraphInterruptEvent")
1186
+ ], CopilotKitLangGraphInterruptEvent.prototype, "name", void 0);
1187
+ _ts_decorate12([
1188
+ Field12(() => CopilotKitLangGraphInterruptEventData),
1189
+ _ts_metadata12("design:type", typeof CopilotKitLangGraphInterruptEventData === "undefined" ? Object : CopilotKitLangGraphInterruptEventData)
1190
+ ], CopilotKitLangGraphInterruptEvent.prototype, "data", void 0);
1191
+ _ts_decorate12([
1192
+ Field12(() => String, {
1193
+ nullable: true
1194
+ }),
1195
+ _ts_metadata12("design:type", String)
1196
+ ], CopilotKitLangGraphInterruptEvent.prototype, "response", void 0);
1197
+ CopilotKitLangGraphInterruptEvent = _ts_decorate12([
1198
+ ObjectType3({
1199
+ implements: BaseMetaEvent
1200
+ })
1201
+ ], CopilotKitLangGraphInterruptEvent);
1202
+
1203
+ // src/graphql/inputs/meta-event.input.ts
1204
+ function _ts_decorate13(decorators, target, key, desc) {
1205
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1206
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1207
+ r = Reflect.decorate(decorators, target, key, desc);
1208
+ else
1209
+ for (var i = decorators.length - 1; i >= 0; i--)
1210
+ if (d = decorators[i])
1211
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1212
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1213
+ }
1214
+ __name(_ts_decorate13, "_ts_decorate");
1215
+ function _ts_metadata13(k, v) {
1216
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1217
+ return Reflect.metadata(k, v);
1218
+ }
1219
+ __name(_ts_metadata13, "_ts_metadata");
1220
+ var MetaEventInput = class {
1221
+ name;
1222
+ value;
1223
+ response;
1224
+ messages;
1225
+ };
1226
+ __name(MetaEventInput, "MetaEventInput");
1227
+ _ts_decorate13([
1228
+ Field13(() => MetaEventName),
1229
+ _ts_metadata13("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
1230
+ ], MetaEventInput.prototype, "name", void 0);
1231
+ _ts_decorate13([
1232
+ Field13(() => String),
1233
+ _ts_metadata13("design:type", String)
1234
+ ], MetaEventInput.prototype, "value", void 0);
1235
+ _ts_decorate13([
1236
+ Field13(() => String, {
1237
+ nullable: true
1238
+ }),
1239
+ _ts_metadata13("design:type", String)
1240
+ ], MetaEventInput.prototype, "response", void 0);
1241
+ _ts_decorate13([
1242
+ Field13(() => [
1243
+ MessageInput
1244
+ ], {
1245
+ nullable: true
1246
+ }),
1247
+ _ts_metadata13("design:type", Array)
1248
+ ], MetaEventInput.prototype, "messages", void 0);
1249
+ MetaEventInput = _ts_decorate13([
1250
+ InputType10()
1251
+ ], MetaEventInput);
1252
+
1253
+ // src/graphql/inputs/copilot-context.input.ts
1254
+ import { Field as Field14, InputType as InputType11 } from "type-graphql";
1255
+ function _ts_decorate14(decorators, target, key, desc) {
1256
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1257
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1258
+ r = Reflect.decorate(decorators, target, key, desc);
1259
+ else
1260
+ for (var i = decorators.length - 1; i >= 0; i--)
1261
+ if (d = decorators[i])
1262
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1263
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1264
+ }
1265
+ __name(_ts_decorate14, "_ts_decorate");
1266
+ function _ts_metadata14(k, v) {
1267
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1268
+ return Reflect.metadata(k, v);
1269
+ }
1270
+ __name(_ts_metadata14, "_ts_metadata");
1271
+ var CopilotContextInput = class {
1272
+ description;
1273
+ value;
1274
+ };
1275
+ __name(CopilotContextInput, "CopilotContextInput");
1276
+ _ts_decorate14([
1277
+ Field14(() => String),
1278
+ _ts_metadata14("design:type", String)
1279
+ ], CopilotContextInput.prototype, "description", void 0);
1280
+ _ts_decorate14([
1281
+ Field14(() => String),
1282
+ _ts_metadata14("design:type", String)
1283
+ ], CopilotContextInput.prototype, "value", void 0);
1284
+ CopilotContextInput = _ts_decorate14([
1285
+ InputType11()
1286
+ ], CopilotContextInput);
1287
+
1288
+ // src/graphql/inputs/generate-copilot-response.input.ts
1289
+ function _ts_decorate15(decorators, target, key, desc) {
1290
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1291
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1292
+ r = Reflect.decorate(decorators, target, key, desc);
1293
+ else
1294
+ for (var i = decorators.length - 1; i >= 0; i--)
1295
+ if (d = decorators[i])
1296
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1297
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1298
+ }
1299
+ __name(_ts_decorate15, "_ts_decorate");
1300
+ function _ts_metadata15(k, v) {
1301
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1302
+ return Reflect.metadata(k, v);
1303
+ }
1304
+ __name(_ts_metadata15, "_ts_metadata");
1305
+ var GenerateCopilotResponseMetadataInput = class {
1306
+ requestType;
1307
+ };
1308
+ __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
1309
+ _ts_decorate15([
1310
+ Field15(() => CopilotRequestType, {
1311
+ nullable: true
1312
+ }),
1313
+ _ts_metadata15("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
1314
+ ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
1315
+ GenerateCopilotResponseMetadataInput = _ts_decorate15([
1316
+ InputType12()
1317
+ ], GenerateCopilotResponseMetadataInput);
1318
+ var GenerateCopilotResponseInput = class {
1319
+ metadata;
1320
+ threadId;
1321
+ runId;
1322
+ messages;
1323
+ frontend;
1324
+ cloud;
1325
+ forwardedParameters;
1326
+ agentSession;
1327
+ agentState;
1328
+ agentStates;
1329
+ extensions;
1330
+ metaEvents;
1331
+ context;
1332
+ };
1333
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
1334
+ _ts_decorate15([
1335
+ Field15(() => GenerateCopilotResponseMetadataInput, {
1336
+ nullable: false
1337
+ }),
1338
+ _ts_metadata15("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
1339
+ ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
1340
+ _ts_decorate15([
1341
+ Field15(() => String, {
1342
+ nullable: true
1343
+ }),
1344
+ _ts_metadata15("design:type", String)
1345
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
1346
+ _ts_decorate15([
1347
+ Field15(() => String, {
1348
+ nullable: true
1349
+ }),
1350
+ _ts_metadata15("design:type", String)
1351
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
1352
+ _ts_decorate15([
1353
+ Field15(() => [
1354
+ MessageInput
1355
+ ]),
1356
+ _ts_metadata15("design:type", Array)
1357
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
1358
+ _ts_decorate15([
1359
+ Field15(() => FrontendInput),
1360
+ _ts_metadata15("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
1361
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
1362
+ _ts_decorate15([
1363
+ Field15(() => CloudInput, {
1364
+ nullable: true
1365
+ }),
1366
+ _ts_metadata15("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
1367
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
1368
+ _ts_decorate15([
1369
+ Field15(() => ForwardedParametersInput, {
1370
+ nullable: true
1371
+ }),
1372
+ _ts_metadata15("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
1373
+ ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
1374
+ _ts_decorate15([
1375
+ Field15(() => AgentSessionInput, {
1376
+ nullable: true
1377
+ }),
1378
+ _ts_metadata15("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
1379
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
1380
+ _ts_decorate15([
1381
+ Field15(() => AgentStateInput, {
1382
+ nullable: true
1383
+ }),
1384
+ _ts_metadata15("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
1385
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
1386
+ _ts_decorate15([
1387
+ Field15(() => [
1388
+ AgentStateInput
1389
+ ], {
1390
+ nullable: true
1391
+ }),
1392
+ _ts_metadata15("design:type", Array)
1393
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
1394
+ _ts_decorate15([
1395
+ Field15(() => ExtensionsInput, {
1396
+ nullable: true
1397
+ }),
1398
+ _ts_metadata15("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
1399
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
1400
+ _ts_decorate15([
1401
+ Field15(() => [
1402
+ MetaEventInput
1403
+ ], {
1404
+ nullable: true
1405
+ }),
1406
+ _ts_metadata15("design:type", Array)
1407
+ ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
1408
+ _ts_decorate15([
1409
+ Field15(() => [
1410
+ CopilotContextInput
1411
+ ], {
1412
+ nullable: true
1413
+ }),
1414
+ _ts_metadata15("design:type", Array)
1415
+ ], GenerateCopilotResponseInput.prototype, "context", void 0);
1416
+ GenerateCopilotResponseInput = _ts_decorate15([
1417
+ InputType12()
1418
+ ], GenerateCopilotResponseInput);
1419
+
1420
+ // src/graphql/resolvers/copilot.resolver.ts
1421
+ import { Repeater } from "graphql-yoga";
1422
+
1423
+ // src/service-adapters/events.ts
1424
+ import { CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, Severity } from "@copilotkit/shared";
1425
+ import { ReplaySubject } from "rxjs";
1426
+ var RuntimeEventTypes;
1427
+ (function(RuntimeEventTypes2) {
1428
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1429
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1430
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1431
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1432
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1433
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1434
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1435
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1436
+ RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1437
+ RuntimeEventTypes2["RunError"] = "RunError";
1438
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1439
+ var RuntimeMetaEventName;
1440
+ (function(RuntimeMetaEventName2) {
1441
+ RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1442
+ RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1443
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1444
+ })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1445
+
1446
+ // src/graphql/resolvers/copilot.resolver.ts
1447
+ import { GraphQLJSONObject } from "graphql-scalars";
1448
+ import { plainToInstance } from "class-transformer";
1449
+ import { GraphQLError } from "graphql";
1450
+
1451
+ // src/lib/telemetry-client.ts
1452
+ import { TelemetryClient } from "@copilotkit/shared";
1453
+ import { createHash } from "crypto";
1454
+
1455
+ // src/lib/runtime/copilot-runtime.ts
1456
+ import { CopilotKitMisuseError, readBody, getZodParameters } from "@copilotkit/shared";
1457
+ import { CopilotRuntime as CopilotRuntimeVNext, InMemoryAgentRunner as InMemoryAgentRunnerVNext } from "@copilotkitnext/runtime";
1458
+
1459
+ // src/lib/runtime/types.ts
1460
+ var EndpointType;
1461
+ (function(EndpointType2) {
1462
+ EndpointType2["CopilotKit"] = "copilotKit";
1463
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1464
+ })(EndpointType || (EndpointType = {}));
1465
+
1466
+ // src/lib/runtime/mcp-tools-utils.ts
1467
+ function extractParametersFromSchema(toolOrSchema) {
1468
+ var _a;
1469
+ const parameters = [];
1470
+ const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
1471
+ const toolParameters = ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema) || (schema == null ? void 0 : schema.parameters);
1472
+ const properties = toolParameters == null ? void 0 : toolParameters.properties;
1473
+ const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
1474
+ if (!properties) {
1475
+ return parameters;
1476
+ }
1477
+ for (const paramName in properties) {
1478
+ if (Object.prototype.hasOwnProperty.call(properties, paramName)) {
1479
+ const paramDef = properties[paramName];
1480
+ let type = paramDef.type || "string";
1481
+ let description = paramDef.description || "";
1482
+ if (type === "array" && paramDef.items) {
1483
+ const itemType = paramDef.items.type || "object";
1484
+ if (itemType === "object" && paramDef.items.properties) {
1485
+ const itemProperties = Object.keys(paramDef.items.properties).join(", ");
1486
+ description = description + (description ? " " : "") + `Array of objects with properties: ${itemProperties}`;
1487
+ } else {
1488
+ type = `array<${itemType}>`;
1489
+ }
1490
+ }
1491
+ if (paramDef.enum && Array.isArray(paramDef.enum)) {
1492
+ const enumValues = paramDef.enum.join(" | ");
1493
+ description = description + (description ? " " : "") + `Allowed values: ${enumValues}`;
1494
+ }
1495
+ if (type === "object" && paramDef.properties) {
1496
+ const objectProperties = Object.keys(paramDef.properties).join(", ");
1497
+ description = description + (description ? " " : "") + `Object with properties: ${objectProperties}`;
1498
+ }
1499
+ parameters.push({
1500
+ name: paramName,
1501
+ type,
1502
+ description,
1503
+ required: requiredParams.has(paramName)
1504
+ });
1505
+ }
1506
+ }
1507
+ return parameters;
1508
+ }
1509
+ __name(extractParametersFromSchema, "extractParametersFromSchema");
1510
+ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
1511
+ const actions = [];
1512
+ for (const [toolName, tool] of Object.entries(mcpTools)) {
1513
+ const parameters = extractParametersFromSchema(tool);
1514
+ const handler = /* @__PURE__ */ __name(async (params) => {
1515
+ try {
1516
+ const result = await tool.execute(params);
1517
+ return typeof result === "string" ? result : JSON.stringify(result);
1518
+ } catch (error) {
1519
+ console.error(`Error executing MCP tool '${toolName}' from endpoint ${mcpEndpoint}:`, error);
1520
+ throw new Error(`Execution failed for MCP tool '${toolName}': ${error instanceof Error ? error.message : String(error)}`);
1521
+ }
1522
+ }, "handler");
1523
+ actions.push({
1524
+ name: toolName,
1525
+ description: tool.description || `MCP tool: ${toolName} (from ${mcpEndpoint})`,
1526
+ parameters,
1527
+ handler,
1528
+ // Add metadata for easier identification/debugging
1529
+ _isMCPTool: true,
1530
+ _mcpEndpoint: mcpEndpoint
1531
+ });
1532
+ }
1533
+ return actions;
1534
+ }
1535
+ __name(convertMCPToolsToActions, "convertMCPToolsToActions");
1536
+ function generateMcpToolInstructions(toolsMap) {
1537
+ if (!toolsMap || Object.keys(toolsMap).length === 0) {
1538
+ return "";
1539
+ }
1540
+ const toolEntries = Object.entries(toolsMap);
1541
+ const toolsDoc = toolEntries.map(([name, tool]) => {
1542
+ var _a;
1543
+ let paramsDoc = " No parameters required";
1544
+ try {
1545
+ if (tool.schema && typeof tool.schema === "object") {
1546
+ const schema = tool.schema;
1547
+ const toolParameters = ((_a = schema.parameters) == null ? void 0 : _a.jsonSchema) || schema.parameters;
1548
+ const properties = (toolParameters == null ? void 0 : toolParameters.properties) || schema.properties;
1549
+ const requiredParams = (toolParameters == null ? void 0 : toolParameters.required) || schema.required || [];
1550
+ if (properties) {
1551
+ const paramsList = Object.entries(properties).map(([paramName, propSchema]) => {
1552
+ const propDetails = propSchema;
1553
+ const requiredMark = requiredParams.includes(paramName) ? "*" : "";
1554
+ let typeInfo = propDetails.type || "any";
1555
+ let description = propDetails.description ? ` - ${propDetails.description}` : "";
1556
+ if (typeInfo === "array" && propDetails.items) {
1557
+ const itemType = propDetails.items.type || "object";
1558
+ if (itemType === "object" && propDetails.items.properties) {
1559
+ const itemProps = Object.keys(propDetails.items.properties).join(", ");
1560
+ typeInfo = `array<object>`;
1561
+ description = description + (description ? " " : " - ") + `Array of objects with properties: ${itemProps}`;
1562
+ } else {
1563
+ typeInfo = `array<${itemType}>`;
1564
+ }
1565
+ }
1566
+ if (propDetails.enum && Array.isArray(propDetails.enum)) {
1567
+ const enumValues = propDetails.enum.join(" | ");
1568
+ description = description + (description ? " " : " - ") + `Allowed values: ${enumValues}`;
1569
+ }
1570
+ if (typeInfo === "object" && propDetails.properties) {
1571
+ const objectProps = Object.keys(propDetails.properties).join(", ");
1572
+ description = description + (description ? " " : " - ") + `Object with properties: ${objectProps}`;
1573
+ }
1574
+ return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
1575
+ });
1576
+ if (paramsList.length > 0) {
1577
+ paramsDoc = paramsList.join("\n");
1578
+ }
1579
+ }
1580
+ }
1581
+ } catch (e) {
1582
+ console.error(`Error parsing schema for tool ${name}:`, e);
1583
+ }
1584
+ return `- ${name}: ${tool.description || ""}
1585
+ ${paramsDoc}`;
1586
+ }).join("\n\n");
1587
+ return `You have access to the following external tools provided by Model Context Protocol (MCP) servers:
1588
+
1589
+ ${toolsDoc}
1590
+
1591
+ When using these tools:
1592
+ 1. Only provide valid parameters according to their type requirements
1593
+ 2. Required parameters are marked with *
1594
+ 3. For array parameters, provide data in the correct array format
1595
+ 4. For object parameters, include all required nested properties
1596
+ 5. For enum parameters, use only the allowed values listed
1597
+ 6. Format API calls correctly with the expected parameter structure
1598
+ 7. Always check tool responses to determine your next action`;
1599
+ }
1600
+ __name(generateMcpToolInstructions, "generateMcpToolInstructions");
1601
+
1602
+ // src/lib/runtime/agent-integrations/langgraph.agent.ts
1603
+ import { EventType } from "@ag-ui/client";
1604
+ import { map } from "rxjs";
1605
+
1606
+ // src/agents/langgraph/events.ts
1607
+ var LangGraphEventTypes;
1608
+ (function(LangGraphEventTypes2) {
1609
+ LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
1610
+ LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
1611
+ LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
1612
+ LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
1613
+ LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
1614
+ LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
1615
+ LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
1616
+ LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
1617
+ LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
1618
+ LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
1619
+ LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
1620
+ LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
1621
+ LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
1622
+ LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
1623
+ LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
1624
+ })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1625
+ var MetaEventNames;
1626
+ (function(MetaEventNames2) {
1627
+ MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1628
+ MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1629
+ })(MetaEventNames || (MetaEventNames = {}));
1630
+ var CustomEventNames;
1631
+ (function(CustomEventNames3) {
1632
+ CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
1633
+ CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
1634
+ CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
1635
+ CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
1636
+ })(CustomEventNames || (CustomEventNames = {}));
1637
+
1638
+ // src/lib/runtime/agent-integrations/langgraph.agent.ts
1639
+ import { LangGraphAgent as AGUILangGraphAgent, LangGraphHttpAgent } from "@ag-ui/langgraph";
1640
+ var CustomEventNames2;
1641
+ (function(CustomEventNames3) {
1642
+ CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
1643
+ CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
1644
+ CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
1645
+ CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
1646
+ })(CustomEventNames2 || (CustomEventNames2 = {}));
1647
+ var LangGraphAgent = class extends AGUILangGraphAgent {
1648
+ constructor(config) {
1649
+ super(config);
1650
+ }
1651
+ // @ts-ignore
1652
+ clone() {
1653
+ return new LangGraphAgent(this.config);
1654
+ }
1655
+ dispatchEvent(event) {
1656
+ if (event.type === EventType.CUSTOM) {
1657
+ const customEvent = event;
1658
+ if (customEvent.name === "copilotkit_manually_emit_message") {
1659
+ this.subscriber.next({
1660
+ type: EventType.TEXT_MESSAGE_START,
1661
+ role: "assistant",
1662
+ messageId: customEvent.value.message_id,
1663
+ rawEvent: event
1664
+ });
1665
+ this.subscriber.next({
1666
+ type: EventType.TEXT_MESSAGE_CONTENT,
1667
+ messageId: customEvent.value.message_id,
1668
+ delta: customEvent.value.message,
1669
+ rawEvent: event
1670
+ });
1671
+ this.subscriber.next({
1672
+ type: EventType.TEXT_MESSAGE_END,
1673
+ messageId: customEvent.value.message_id,
1674
+ rawEvent: event
1675
+ });
1676
+ return true;
1677
+ }
1678
+ if (customEvent.name === "copilotkit_manually_emit_tool_call") {
1679
+ this.subscriber.next({
1680
+ type: EventType.TOOL_CALL_START,
1681
+ toolCallId: customEvent.value.id,
1682
+ toolCallName: customEvent.value.name,
1683
+ parentMessageId: customEvent.value.id,
1684
+ rawEvent: event
1685
+ });
1686
+ this.subscriber.next({
1687
+ type: EventType.TOOL_CALL_ARGS,
1688
+ toolCallId: customEvent.value.id,
1689
+ delta: customEvent.value.args,
1690
+ rawEvent: event
1691
+ });
1692
+ this.subscriber.next({
1693
+ type: EventType.TOOL_CALL_END,
1694
+ toolCallId: customEvent.value.id,
1695
+ rawEvent: event
1696
+ });
1697
+ return true;
1698
+ }
1699
+ if (customEvent.name === "copilotkit_manually_emit_intermediate_state") {
1700
+ this.activeRun.manuallyEmittedState = customEvent.value;
1701
+ this.dispatchEvent({
1702
+ type: EventType.STATE_SNAPSHOT,
1703
+ snapshot: this.getStateSnapshot({
1704
+ values: this.activeRun.manuallyEmittedState
1705
+ }),
1706
+ rawEvent: event
1707
+ });
1708
+ return true;
1709
+ }
1710
+ if (customEvent.name === "copilotkit_exit") {
1711
+ this.subscriber.next({
1712
+ type: EventType.CUSTOM,
1713
+ name: "Exit",
1714
+ value: true
1715
+ });
1716
+ return true;
1717
+ }
1718
+ }
1719
+ const rawEvent = event.rawEvent;
1720
+ if (!rawEvent) {
1721
+ this.subscriber.next(event);
1722
+ return true;
1723
+ }
1724
+ const isMessageEvent = event.type === EventType.TEXT_MESSAGE_START || event.type === EventType.TEXT_MESSAGE_CONTENT || event.type === EventType.TEXT_MESSAGE_END;
1725
+ const isToolEvent = event.type === EventType.TOOL_CALL_START || event.type === EventType.TOOL_CALL_ARGS || event.type === EventType.TOOL_CALL_END;
1726
+ if ("copilotkit:emit-tool-calls" in (rawEvent.metadata || {})) {
1727
+ if (rawEvent.metadata["copilotkit:emit-tool-calls"] === false && isToolEvent) {
1728
+ return false;
1729
+ }
1730
+ }
1731
+ if ("copilotkit:emit-messages" in (rawEvent.metadata || {})) {
1732
+ if (rawEvent.metadata["copilotkit:emit-messages"] === false && isMessageEvent) {
1733
+ return false;
1734
+ }
1735
+ }
1736
+ this.subscriber.next(event);
1737
+ return true;
1738
+ }
1739
+ // @ts-ignore
1740
+ run(input) {
1741
+ return super.run(input).pipe(map((processedEvent) => {
1742
+ var _a, _b, _c, _d, _e;
1743
+ if (processedEvent.type === EventType.RAW) {
1744
+ const event = processedEvent.event ?? processedEvent.rawEvent;
1745
+ const eventType = event.event;
1746
+ const toolCallData = (_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.tool_call_chunks) == null ? void 0 : _c[0];
1747
+ const toolCallUsedToPredictState = (_e = (_d = event.metadata) == null ? void 0 : _d["copilotkit:emit-intermediate-state"]) == null ? void 0 : _e.some((predictStateTool) => predictStateTool.tool === (toolCallData == null ? void 0 : toolCallData.name));
1748
+ if (eventType === LangGraphEventTypes.OnChatModelStream && toolCallUsedToPredictState) {
1749
+ return {
1750
+ type: EventType.CUSTOM,
1751
+ name: "PredictState",
1752
+ value: event.metadata["copilotkit:emit-intermediate-state"]
1753
+ };
1754
+ }
1755
+ }
1756
+ return processedEvent;
1757
+ }));
1758
+ }
1759
+ langGraphDefaultMergeState(state, messages, input) {
1760
+ const aguiMergedState = super.langGraphDefaultMergeState(state, messages, input);
1761
+ const { tools: returnedTools, "ag-ui": agui } = aguiMergedState;
1762
+ const rawCombinedTools = [
1763
+ ...returnedTools ?? [],
1764
+ ...(agui == null ? void 0 : agui.tools) ?? []
1765
+ ];
1766
+ const combinedTools = Array.from(new Map(rawCombinedTools.map((t) => [
1767
+ (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.key) ?? JSON.stringify(t),
1768
+ t
1769
+ ])).values());
1770
+ return {
1771
+ ...aguiMergedState,
1772
+ copilotkit: {
1773
+ actions: combinedTools,
1774
+ context: (agui == null ? void 0 : agui.context) ?? []
1775
+ }
1776
+ };
1777
+ }
1778
+ async getSchemaKeys() {
1779
+ const CONSTANT_KEYS = [
1780
+ "copilotkit"
1781
+ ];
1782
+ const schemaKeys = await super.getSchemaKeys();
1783
+ return {
1784
+ config: schemaKeys.config,
1785
+ input: schemaKeys.input ? [
1786
+ ...schemaKeys.input,
1787
+ ...CONSTANT_KEYS
1788
+ ] : null,
1789
+ output: schemaKeys.output ? [
1790
+ ...schemaKeys.output,
1791
+ ...CONSTANT_KEYS
1792
+ ] : null,
1793
+ context: schemaKeys.context ? [
1794
+ ...schemaKeys.context,
1795
+ ...CONSTANT_KEYS
1796
+ ] : null
1797
+ };
1798
+ }
1799
+ };
1800
+ __name(LangGraphAgent, "LangGraphAgent");
1801
+
1802
+ // src/lib/runtime/copilot-runtime.ts
1803
+ import { BasicAgent } from "@copilotkitnext/agent";
1804
+ var CopilotRuntime = class {
1805
+ params;
1806
+ observability;
1807
+ // Cache MCP tools per endpoint to avoid re-fetching repeatedly
1808
+ mcpToolsCache = /* @__PURE__ */ new Map();
1809
+ runtimeArgs;
1810
+ instance;
1811
+ constructor(params) {
1812
+ const agents = (params == null ? void 0 : params.agents) ?? {};
1813
+ this.runtimeArgs = {
1814
+ agents: {
1815
+ ...this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []),
1816
+ ...agents
1817
+ },
1818
+ runner: (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunnerVNext(),
1819
+ // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
1820
+ // transcriptionService: params?.transcriptionService,
1821
+ beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
1822
+ afterRequestMiddleware: this.createOnAfterRequestHandler(params).bind(this)
1823
+ };
1824
+ this.params = params;
1825
+ this.observability = params == null ? void 0 : params.observability_c;
1826
+ this.instance = new CopilotRuntimeVNext(this.runtimeArgs);
1827
+ }
1828
+ assignEndpointsToAgents(endpoints) {
1829
+ return endpoints.reduce((acc, endpoint) => {
1830
+ if (resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform) {
1831
+ let lgAgents = {};
1832
+ const lgEndpoint = endpoint;
1833
+ lgEndpoint.agents.forEach((agent) => {
1834
+ const graphId = agent.assistantId ?? agent.name;
1835
+ lgAgents[graphId] = new LangGraphAgent({
1836
+ deploymentUrl: lgEndpoint.deploymentUrl,
1837
+ langsmithApiKey: lgEndpoint.langsmithApiKey,
1838
+ graphId
1839
+ });
1840
+ });
1841
+ return {
1842
+ ...acc,
1843
+ ...lgAgents
1844
+ };
1845
+ }
1846
+ return acc;
1847
+ }, {});
1848
+ }
1849
+ async handleServiceAdapter(serviceAdapter) {
1850
+ var _a;
1851
+ let agents = {
1852
+ ...this.runtimeArgs.agents ?? {},
1853
+ default: new BasicAgent({
1854
+ model: `${serviceAdapter.provider}/${serviceAdapter.model}`
1855
+ })
1856
+ };
1857
+ if ((_a = this.params.actions) == null ? void 0 : _a.length) {
1858
+ const mcpTools = await this.getToolsFromMCP();
1859
+ agents = this.assignToolsToAgents(agents, [
1860
+ ...this.getToolsFromActions(this.params.actions),
1861
+ ...mcpTools
1862
+ ]);
1863
+ }
1864
+ this.instance.agents = agents;
1865
+ }
1866
+ // Receive this.params.action and turn it into the AbstractAgent tools
1867
+ getToolsFromActions(actions) {
1868
+ const actionsArray = typeof actions === "function" ? actions({
1869
+ properties: {},
1870
+ url: void 0
1871
+ }) : actions;
1872
+ return actionsArray.map((action) => {
1873
+ const zodSchema = getZodParameters(action.parameters || []);
1874
+ return {
1875
+ name: action.name,
1876
+ description: action.description || "",
1877
+ parameters: zodSchema
1878
+ };
1879
+ });
1880
+ }
1881
+ assignToolsToAgents(agents, tools) {
1882
+ const enrichedAgents = {
1883
+ ...agents
1884
+ };
1885
+ for (const existingAgent of Object.values(enrichedAgents)) {
1886
+ const config = existingAgent.config ?? {};
1887
+ const existingTools = config.tools ?? [];
1888
+ config.tools = [
1889
+ ...existingTools,
1890
+ ...tools
1891
+ ];
1892
+ }
1893
+ return enrichedAgents;
1894
+ }
1895
+ createOnBeforeRequestHandler(params) {
1896
+ return async (hookParams) => {
1897
+ var _a, _b;
1898
+ (_a = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
1899
+ if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onBeforeRequest) {
1900
+ const { request, runtime, path } = hookParams;
1901
+ const body = await readBody(request);
1902
+ const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
1903
+ if ("role" in msg && msg.role === "user") {
1904
+ acc.inputMessages.push(msg);
1905
+ } else {
1906
+ acc.outputMessages.push(msg);
1907
+ }
1908
+ return acc;
1909
+ }, {
1910
+ inputMessages: [],
1911
+ outputMessages: []
1912
+ });
1913
+ const { inputMessages, outputMessages } = gqlMessages;
1914
+ params.middleware.onBeforeRequest({
1915
+ threadId: body.threadId,
1916
+ runId: body.runId,
1917
+ inputMessages,
1918
+ properties: body.forwardedProps,
1919
+ url: request.url
1920
+ });
1921
+ }
1922
+ };
1923
+ }
1924
+ createOnAfterRequestHandler(params) {
1925
+ return async (hookParams) => {
1926
+ var _a, _b;
1927
+ (_a = params == null ? void 0 : params.afterRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
1928
+ if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest) {
1929
+ params.middleware.onAfterRequest({});
1930
+ }
1931
+ };
1932
+ }
1933
+ // Observability Methods
1934
+ /**
1935
+ * Log LLM request if observability is enabled
1936
+ */
1937
+ async logObservabilityBeforeRequest(requestData) {
1938
+ try {
1939
+ await this.observability.hooks.handleRequest(requestData);
1940
+ } catch (error) {
1941
+ console.error("Error logging LLM request:", error);
1942
+ }
1943
+ }
1944
+ /**
1945
+ * Log final LLM response after request completes
1946
+ */
1947
+ logObservabilityAfterRequest(outputMessagesPromise, baseData, streamedChunks, requestStartTime, publicApiKey) {
1948
+ try {
1949
+ outputMessagesPromise.then((outputMessages) => {
1950
+ const responseData = {
1951
+ threadId: baseData.threadId,
1952
+ runId: baseData.runId,
1953
+ model: baseData.model,
1954
+ // Use collected chunks for progressive mode or outputMessages for regular mode
1955
+ output: this.observability.progressive ? streamedChunks : outputMessages,
1956
+ latency: Date.now() - requestStartTime,
1957
+ timestamp: Date.now(),
1958
+ provider: baseData.provider,
1959
+ isFinalResponse: true,
1960
+ agentName: baseData.agentName,
1961
+ nodeName: baseData.nodeName
1962
+ };
1963
+ try {
1964
+ this.observability.hooks.handleResponse(responseData);
1965
+ } catch (logError) {
1966
+ console.error("Error logging LLM response:", logError);
1967
+ }
1968
+ }).catch((error) => {
1969
+ console.error("Failed to get output messages for logging:", error);
1970
+ });
1971
+ } catch (error) {
1972
+ console.error("Error setting up logging for LLM response:", error);
1973
+ }
1974
+ }
1975
+ // Resolve MCP tools to BasicAgent tool definitions
1976
+ // Optionally accepts request-scoped properties to merge request-provided mcpServers
1977
+ async getToolsFromMCP(options) {
1978
+ var _a, _b, _c, _d;
1979
+ const runtimeMcpServers = ((_a = this.params) == null ? void 0 : _a.mcpServers) ?? [];
1980
+ const createMCPClient = (_b = this.params) == null ? void 0 : _b.createMCPClient;
1981
+ const requestMcpServers = ((_c = options == null ? void 0 : options.properties) == null ? void 0 : _c.mcpServers) ?? ((_d = options == null ? void 0 : options.properties) == null ? void 0 : _d.mcpEndpoints) ?? [];
1982
+ const hasAnyServers = ((runtimeMcpServers == null ? void 0 : runtimeMcpServers.length) ?? 0) > 0 || ((requestMcpServers == null ? void 0 : requestMcpServers.length) ?? 0) > 0;
1983
+ if (!hasAnyServers) {
1984
+ return [];
1985
+ }
1986
+ if (!createMCPClient) {
1987
+ throw new CopilotKitMisuseError({
1988
+ message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
1989
+ });
1990
+ }
1991
+ const effectiveEndpoints = (() => {
1992
+ const byUrl = /* @__PURE__ */ new Map();
1993
+ for (const ep of runtimeMcpServers) {
1994
+ if (ep == null ? void 0 : ep.endpoint)
1995
+ byUrl.set(ep.endpoint, ep);
1996
+ }
1997
+ for (const ep of requestMcpServers) {
1998
+ if (ep == null ? void 0 : ep.endpoint)
1999
+ byUrl.set(ep.endpoint, ep);
2000
+ }
2001
+ return Array.from(byUrl.values());
2002
+ })();
2003
+ const allTools = [];
2004
+ for (const config of effectiveEndpoints) {
2005
+ const endpointUrl = config.endpoint;
2006
+ const cached = this.mcpToolsCache.get(endpointUrl);
2007
+ if (cached) {
2008
+ allTools.push(...cached);
2009
+ continue;
2010
+ }
2011
+ try {
2012
+ const client = await createMCPClient(config);
2013
+ const toolsMap = await client.tools();
2014
+ const toolDefs = Object.entries(toolsMap).map(([toolName, tool]) => {
2015
+ const params = extractParametersFromSchema(tool);
2016
+ const zodSchema = getZodParameters(params);
2017
+ return {
2018
+ name: toolName,
2019
+ description: tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,
2020
+ parameters: zodSchema
2021
+ };
2022
+ });
2023
+ this.mcpToolsCache.set(endpointUrl, toolDefs);
2024
+ allTools.push(...toolDefs);
2025
+ } catch (error) {
2026
+ console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
2027
+ this.mcpToolsCache.set(endpointUrl, []);
2028
+ }
2029
+ }
2030
+ const dedupedByName = /* @__PURE__ */ new Map();
2031
+ for (const tool of allTools) {
2032
+ dedupedByName.set(tool.name, tool);
2033
+ }
2034
+ return Array.from(dedupedByName.values());
2035
+ }
2036
+ };
2037
+ __name(CopilotRuntime, "CopilotRuntime");
2038
+ function copilotKitEndpoint(config) {
2039
+ return {
2040
+ ...config,
2041
+ type: EndpointType.CopilotKit
2042
+ };
2043
+ }
2044
+ __name(copilotKitEndpoint, "copilotKitEndpoint");
2045
+ function langGraphPlatformEndpoint(config) {
2046
+ return {
2047
+ ...config,
2048
+ type: EndpointType.LangGraphPlatform
2049
+ };
2050
+ }
2051
+ __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
2052
+ function resolveEndpointType(endpoint) {
2053
+ if (!endpoint.type) {
2054
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
2055
+ return EndpointType.LangGraphPlatform;
2056
+ } else {
2057
+ return EndpointType.CopilotKit;
2058
+ }
2059
+ }
2060
+ return endpoint.type;
2061
+ }
2062
+ __name(resolveEndpointType, "resolveEndpointType");
2063
+
2064
+ // src/lib/telemetry-client.ts
2065
+ var packageJson = require_package();
2066
+ var telemetryClient = new TelemetryClient({
2067
+ packageName: packageJson.name,
2068
+ packageVersion: packageJson.version
2069
+ });
2070
+ function getRuntimeInstanceTelemetryInfo(options) {
2071
+ var _a, _b, _c, _d, _e;
2072
+ const runtime = options.runtime;
2073
+ const remoteEndpoints = ((_a = runtime.params) == null ? void 0 : _a.remoteEndpoints) ?? [];
2074
+ const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
2075
+ let info = {
2076
+ ...acc
2077
+ };
2078
+ const endpointType = resolveEndpointType(endpoint);
2079
+ if (!info.endpointTypes.includes(endpointType)) {
2080
+ info = {
2081
+ ...info,
2082
+ endpointTypes: [
2083
+ ...info.endpointTypes,
2084
+ endpointType
2085
+ ]
2086
+ };
2087
+ }
2088
+ if (endpointType === EndpointType.LangGraphPlatform) {
2089
+ const ep = endpoint;
2090
+ info = {
2091
+ ...info,
2092
+ agentsAmount: ep.agents.length,
2093
+ hashedKey: ep.langsmithApiKey ? createHash("sha256").update(ep.langsmithApiKey).digest("hex") : null
2094
+ };
2095
+ }
2096
+ return info;
2097
+ }, {
2098
+ endpointTypes: [],
2099
+ agentsAmount: null,
2100
+ hashedKey: null
2101
+ });
2102
+ const publicApiKey = (_b = options.cloud) == null ? void 0 : _b.publicApiKey;
2103
+ const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
2104
+ return {
2105
+ actionsAmount: ((_d = (_c = runtime.params) == null ? void 0 : _c.actions) == null ? void 0 : _d.length) ?? 0,
2106
+ endpointsAmount: remoteEndpoints.length,
2107
+ endpointTypes: endpointsInfo.endpointTypes,
2108
+ agentsAmount: Object.keys(runtime.instance.agents).length,
2109
+ hashedLgcKey: endpointsInfo.hashedKey,
2110
+ "cloud.api_key_provided": apiKeyProvided,
2111
+ ...apiKeyProvided ? {
2112
+ "cloud.public_api_key": publicApiKey
2113
+ } : {},
2114
+ ...((_e = options.cloud) == null ? void 0 : _e.baseUrl) ? {
2115
+ "cloud.base_url": options.cloud.baseUrl
2116
+ } : {}
2117
+ };
2118
+ }
2119
+ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
2120
+ var telemetry_client_default = telemetryClient;
2121
+
2122
+ // src/graphql/resolvers/copilot.resolver.ts
2123
+ import { randomId } from "@copilotkit/shared";
2124
+
2125
+ // src/graphql/types/agents-response.type.ts
2126
+ import { Field as Field16, ObjectType as ObjectType4 } from "type-graphql";
2127
+ function _ts_decorate16(decorators, target, key, desc) {
2128
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2129
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2130
+ r = Reflect.decorate(decorators, target, key, desc);
2131
+ else
2132
+ for (var i = decorators.length - 1; i >= 0; i--)
2133
+ if (d = decorators[i])
2134
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2135
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2136
+ }
2137
+ __name(_ts_decorate16, "_ts_decorate");
2138
+ function _ts_metadata16(k, v) {
2139
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2140
+ return Reflect.metadata(k, v);
2141
+ }
2142
+ __name(_ts_metadata16, "_ts_metadata");
2143
+ var Agent = class {
2144
+ id;
2145
+ name;
2146
+ description;
2147
+ };
2148
+ __name(Agent, "Agent");
2149
+ _ts_decorate16([
2150
+ Field16(() => String),
2151
+ _ts_metadata16("design:type", String)
2152
+ ], Agent.prototype, "id", void 0);
2153
+ _ts_decorate16([
2154
+ Field16(() => String),
2155
+ _ts_metadata16("design:type", String)
2156
+ ], Agent.prototype, "name", void 0);
2157
+ _ts_decorate16([
2158
+ Field16(() => String),
2159
+ _ts_metadata16("design:type", String)
2160
+ ], Agent.prototype, "description", void 0);
2161
+ Agent = _ts_decorate16([
2162
+ ObjectType4()
2163
+ ], Agent);
2164
+ var AgentsResponse = class {
2165
+ agents;
2166
+ };
2167
+ __name(AgentsResponse, "AgentsResponse");
2168
+ _ts_decorate16([
2169
+ Field16(() => [
2170
+ Agent
2171
+ ]),
2172
+ _ts_metadata16("design:type", Array)
2173
+ ], AgentsResponse.prototype, "agents", void 0);
2174
+ AgentsResponse = _ts_decorate16([
2175
+ ObjectType4()
2176
+ ], AgentsResponse);
2177
+
2178
+ // src/graphql/resolvers/copilot.resolver.ts
2179
+ import { CopilotKitError as CopilotKitError2, CopilotKitLowLevelError as CopilotKitLowLevelError2 } from "@copilotkit/shared";
2180
+ function _ts_decorate17(decorators, target, key, desc) {
2181
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2182
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2183
+ r = Reflect.decorate(decorators, target, key, desc);
2184
+ else
2185
+ for (var i = decorators.length - 1; i >= 0; i--)
2186
+ if (d = decorators[i])
2187
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2188
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2189
+ }
2190
+ __name(_ts_decorate17, "_ts_decorate");
2191
+ function _ts_metadata17(k, v) {
2192
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2193
+ return Reflect.metadata(k, v);
2194
+ }
2195
+ __name(_ts_metadata17, "_ts_metadata");
2196
+ function _ts_param(paramIndex, decorator) {
2197
+ return function(target, key) {
2198
+ decorator(target, key, paramIndex);
2199
+ };
2200
+ }
2201
+ __name(_ts_param, "_ts_param");
2202
+ var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
2203
+ var _a;
2204
+ if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
2205
+ const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
2206
+ role: m.textMessage.role,
2207
+ content: m.textMessage.content
2208
+ }));
2209
+ const lastMessage = messages[messages.length - 1];
2210
+ const restOfMessages = messages.slice(0, -1);
2211
+ const body = {
2212
+ input: lastMessage.content,
2213
+ validTopics: data.cloud.guardrails.inputValidationRules.allowList,
2214
+ invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
2215
+ messages: restOfMessages
2216
+ };
2217
+ const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
2218
+ method: "POST",
2219
+ headers: {
2220
+ "Content-Type": "application/json",
2221
+ "X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
2222
+ },
2223
+ body: JSON.stringify(body)
2224
+ });
2225
+ if (guardrailsResult.ok) {
2226
+ const resultJson = await guardrailsResult.json();
2227
+ onResult(resultJson);
2228
+ } else {
2229
+ onError(await guardrailsResult.json());
2230
+ }
2231
+ }
2232
+ }, "invokeGuardrails");
2233
+ var CopilotResolver = class {
2234
+ async hello() {
2235
+ return "Hello World";
2236
+ }
2237
+ async availableAgents(ctx) {
2238
+ let logger2 = ctx.logger.child({
2239
+ component: "CopilotResolver.availableAgents"
2240
+ });
2241
+ logger2.debug("Processing");
2242
+ const agentsWithEndpoints = [];
2243
+ logger2.debug("Event source created, creating response");
2244
+ return {
2245
+ agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
2246
+ };
2247
+ }
2248
+ async generateCopilotResponse(ctx, data, properties) {
2249
+ var _a, _b, _c, _d;
2250
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2251
+ "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2252
+ requestType: data.metadata.requestType,
2253
+ "cloud.api_key_provided": !!ctx.request.headers.get("x-copilotcloud-public-api-key"),
2254
+ ...ctx.request.headers.get("x-copilotcloud-public-api-key") ? {
2255
+ "cloud.public_api_key": ctx.request.headers.get("x-copilotcloud-public-api-key")
2256
+ } : {},
2257
+ ...ctx._copilotkit.baseUrl ? {
2258
+ "cloud.base_url": ctx._copilotkit.baseUrl
2259
+ } : {
2260
+ "cloud.base_url": "https://api.cloud.copilotkit.ai"
2261
+ }
2262
+ });
2263
+ let logger2 = ctx.logger.child({
2264
+ component: "CopilotResolver.generateCopilotResponse"
2265
+ });
2266
+ logger2.debug({
2267
+ data
2268
+ }, "Generating Copilot response");
2269
+ if (properties) {
2270
+ logger2.debug("Properties provided, merging with context properties");
2271
+ ctx.properties = {
2272
+ ...ctx.properties,
2273
+ ...properties
2274
+ };
2275
+ }
2276
+ const copilotRuntime = ctx._copilotkit.runtime;
2277
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
2278
+ let copilotCloudPublicApiKey = null;
2279
+ let copilotCloudBaseUrl;
2280
+ const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
2281
+ if (publicApiKeyFromHeaders) {
2282
+ copilotCloudPublicApiKey = publicApiKeyFromHeaders;
2283
+ }
2284
+ if (data.cloud) {
2285
+ logger2 = logger2.child({
2286
+ cloud: true
2287
+ });
2288
+ logger2.debug("Cloud configuration provided, checking for public API key in headers");
2289
+ if (!copilotCloudPublicApiKey) {
2290
+ logger2.error("Public API key not found in headers");
2291
+ throw new GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2292
+ }
2293
+ if (process.env.COPILOT_CLOUD_BASE_URL) {
2294
+ copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2295
+ } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2296
+ copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2297
+ } else {
2298
+ copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2299
+ }
2300
+ logger2 = logger2.child({
2301
+ copilotCloudBaseUrl
2302
+ });
2303
+ }
2304
+ logger2.debug("Setting up subjects");
2305
+ const responseStatus$ = new ReplaySubject2();
2306
+ const interruptStreaming$ = new ReplaySubject2();
2307
+ const guardrailsResult$ = new ReplaySubject2();
2308
+ let outputMessages = [];
2309
+ let resolveOutputMessagesPromise;
2310
+ let rejectOutputMessagesPromise;
2311
+ const outputMessagesPromise = new Promise((resolve, reject) => {
2312
+ resolveOutputMessagesPromise = resolve;
2313
+ rejectOutputMessagesPromise = reject;
2314
+ });
2315
+ if (copilotCloudPublicApiKey) {
2316
+ ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
2317
+ }
2318
+ logger2.debug("Processing");
2319
+ let runtimeResponse;
2320
+ const { eventSource, threadId = randomId(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2321
+ logger2.debug("Event source created, creating response");
2322
+ const eventStream = eventSource.processRuntimeEvents({
2323
+ serverSideActions,
2324
+ guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2325
+ actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2326
+ // TODO-AGENTS: do not exclude ALL server side actions
2327
+ (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
2328
+ ),
2329
+ threadId
2330
+ }).pipe(
2331
+ // shareReplay() ensures that later subscribers will see the whole stream instead of
2332
+ // just the events that were emitted after the subscriber was added.
2333
+ shareReplay(),
2334
+ finalize(() => {
2335
+ logger2.debug("Event stream finalized");
2336
+ })
2337
+ );
2338
+ const response = {
2339
+ threadId,
2340
+ runId,
2341
+ status: firstValueFrom(responseStatus$),
2342
+ extensions,
2343
+ metaEvents: new Repeater(async (push, stop) => {
2344
+ let eventStreamSubscription;
2345
+ eventStreamSubscription = eventStream.subscribe({
2346
+ next: async (event) => {
2347
+ if (event.type != RuntimeEventTypes.MetaEvent) {
2348
+ return;
2349
+ }
2350
+ switch (event.name) {
2351
+ case LangGraphEventTypes.OnInterrupt:
2352
+ push(plainToInstance(LangGraphInterruptEvent, {
2353
+ // @ts-ignore
2354
+ type: event.type,
2355
+ // @ts-ignore
2356
+ name: RuntimeMetaEventName.LangGraphInterruptEvent,
2357
+ // @ts-ignore
2358
+ value: event.value
2359
+ }));
2360
+ break;
2361
+ case RuntimeMetaEventName.LangGraphInterruptEvent:
2362
+ push(plainToInstance(LangGraphInterruptEvent, {
2363
+ type: event.type,
2364
+ name: event.name,
2365
+ value: event.value
2366
+ }));
2367
+ break;
2368
+ case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
2369
+ push(plainToInstance(CopilotKitLangGraphInterruptEvent, {
2370
+ type: event.type,
2371
+ name: event.name,
2372
+ data: {
2373
+ value: event.data.value,
2374
+ messages: event.data.messages.map((message) => {
2375
+ if (message.type === "TextMessage" || "content" in message && "role" in message) {
2376
+ return plainToInstance(TextMessage, {
2377
+ id: message.id,
2378
+ createdAt: /* @__PURE__ */ new Date(),
2379
+ content: [
2380
+ message.content
2381
+ ],
2382
+ role: message.role,
2383
+ status: new SuccessMessageStatus()
2384
+ });
2385
+ }
2386
+ if ("arguments" in message) {
2387
+ return plainToInstance(ActionExecutionMessage, {
2388
+ name: message.name,
2389
+ id: message.id,
2390
+ arguments: [
2391
+ JSON.stringify(message.arguments)
2392
+ ],
2393
+ createdAt: /* @__PURE__ */ new Date(),
2394
+ status: new SuccessMessageStatus()
2395
+ });
2396
+ }
2397
+ throw new Error("Unknown message in metaEvents copilot resolver");
2398
+ })
2399
+ }
2400
+ }));
2401
+ break;
2402
+ }
2403
+ },
2404
+ error: (err) => {
2405
+ var _a2, _b2;
2406
+ if (((_a2 = err == null ? void 0 : err.name) == null ? void 0 : _a2.includes("CopilotKit")) || ((_b2 = err == null ? void 0 : err.extensions) == null ? void 0 : _b2.visibility)) {
2407
+ responseStatus$.next(new UnknownErrorResponse({
2408
+ description: err.message || "Agent error occurred"
2409
+ }));
2410
+ } else {
2411
+ responseStatus$.next(new UnknownErrorResponse({
2412
+ description: `An unknown error has occurred in the event stream`
2413
+ }));
2414
+ }
2415
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2416
+ stop();
2417
+ },
2418
+ complete: async () => {
2419
+ logger2.debug("Meta events stream completed");
2420
+ responseStatus$.next(new SuccessResponseStatus());
2421
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2422
+ stop();
2423
+ }
2424
+ });
2425
+ }),
2426
+ messages: new Repeater(async (pushMessage, stopStreamingMessages) => {
2427
+ var _a2;
2428
+ logger2.debug("Messages repeater created");
2429
+ if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
2430
+ logger2 = logger2.child({
2431
+ guardrails: true
2432
+ });
2433
+ logger2.debug("Guardrails is enabled, validating input");
2434
+ invokeGuardrails({
2435
+ baseUrl: copilotCloudBaseUrl,
2436
+ copilotCloudPublicApiKey,
2437
+ data,
2438
+ onResult: (result) => {
2439
+ logger2.debug({
2440
+ status: result.status
2441
+ }, "Guardrails validation done");
2442
+ guardrailsResult$.next(result);
2443
+ if (result.status === "denied") {
2444
+ responseStatus$.next(new GuardrailsValidationFailureResponse({
2445
+ guardrailsReason: result.reason
2446
+ }));
2447
+ interruptStreaming$.next({
2448
+ reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
2449
+ });
2450
+ outputMessages = [
2451
+ plainToInstance(TextMessage, {
2452
+ id: randomId(),
2453
+ createdAt: /* @__PURE__ */ new Date(),
2454
+ content: result.reason,
2455
+ role: MessageRole.assistant
2456
+ })
2457
+ ];
2458
+ resolveOutputMessagesPromise(outputMessages);
2459
+ }
2460
+ },
2461
+ onError: (err) => {
2462
+ logger2.error({
2463
+ err
2464
+ }, "Error in guardrails validation");
2465
+ responseStatus$.next(new UnknownErrorResponse({
2466
+ description: `An unknown error has occurred in the guardrails validation`
2467
+ }));
2468
+ interruptStreaming$.next({
2469
+ reason: `Interrupted due to unknown error in guardrails validation`
2470
+ });
2471
+ rejectOutputMessagesPromise(err);
2472
+ }
2473
+ });
2474
+ }
2475
+ let eventStreamSubscription;
2476
+ logger2.debug("Event stream created, subscribing to event stream");
2477
+ eventStreamSubscription = eventStream.subscribe({
2478
+ next: async (event) => {
2479
+ switch (event.type) {
2480
+ case RuntimeEventTypes.MetaEvent:
2481
+ break;
2482
+ case RuntimeEventTypes.TextMessageStart:
2483
+ const textMessageContentStream = eventStream.pipe(
2484
+ // skip until this message start event
2485
+ skipWhile((e) => e !== event),
2486
+ // take until the message end event
2487
+ takeWhile((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2488
+ // filter out any other message events or message ids
2489
+ filter((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2490
+ );
2491
+ const streamingTextStatus = new Subject();
2492
+ const messageId = event.messageId;
2493
+ pushMessage({
2494
+ id: messageId,
2495
+ parentMessageId: event.parentMessageId,
2496
+ status: firstValueFrom(streamingTextStatus),
2497
+ createdAt: /* @__PURE__ */ new Date(),
2498
+ role: MessageRole.assistant,
2499
+ content: new Repeater(async (pushTextChunk, stopStreamingText) => {
2500
+ logger2.debug("Text message content repeater created");
2501
+ const textChunks = [];
2502
+ let textSubscription;
2503
+ interruptStreaming$.pipe(shareReplay(), take(1), tap(({ reason, messageId: messageId2 }) => {
2504
+ logger2.debug({
2505
+ reason,
2506
+ messageId: messageId2
2507
+ }, "Text streaming interrupted");
2508
+ streamingTextStatus.next(plainToInstance(FailedMessageStatus, {
2509
+ reason
2510
+ }));
2511
+ responseStatus$.next(new MessageStreamInterruptedResponse({
2512
+ messageId: messageId2
2513
+ }));
2514
+ stopStreamingText();
2515
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2516
+ })).subscribe();
2517
+ logger2.debug("Subscribing to text message content stream");
2518
+ textSubscription = textMessageContentStream.subscribe({
2519
+ next: async (e) => {
2520
+ if (e.type == RuntimeEventTypes.TextMessageContent) {
2521
+ await pushTextChunk(e.content);
2522
+ textChunks.push(e.content);
2523
+ }
2524
+ },
2525
+ error: (err) => {
2526
+ logger2.error({
2527
+ err
2528
+ }, "Error in text message content stream");
2529
+ interruptStreaming$.next({
2530
+ reason: "Error streaming message content",
2531
+ messageId
2532
+ });
2533
+ stopStreamingText();
2534
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2535
+ },
2536
+ complete: () => {
2537
+ logger2.debug("Text message content stream completed");
2538
+ streamingTextStatus.next(new SuccessMessageStatus());
2539
+ stopStreamingText();
2540
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2541
+ outputMessages.push(plainToInstance(TextMessage, {
2542
+ id: messageId,
2543
+ createdAt: /* @__PURE__ */ new Date(),
2544
+ content: textChunks.join(""),
2545
+ role: MessageRole.assistant
2546
+ }));
2547
+ }
2548
+ });
2549
+ })
2550
+ });
2551
+ break;
2552
+ case RuntimeEventTypes.ActionExecutionStart:
2553
+ logger2.debug("Action execution start event received");
2554
+ const actionExecutionArgumentStream = eventStream.pipe(
2555
+ skipWhile((e) => e !== event),
2556
+ // take until the action execution end event
2557
+ takeWhile((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2558
+ // filter out any other action execution events or action execution ids
2559
+ filter((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2560
+ );
2561
+ const streamingArgumentsStatus = new Subject();
2562
+ pushMessage({
2563
+ id: event.actionExecutionId,
2564
+ parentMessageId: event.parentMessageId,
2565
+ status: firstValueFrom(streamingArgumentsStatus),
2566
+ createdAt: /* @__PURE__ */ new Date(),
2567
+ name: event.actionName,
2568
+ arguments: new Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
2569
+ logger2.debug("Action execution argument stream created");
2570
+ const argumentChunks = [];
2571
+ let actionExecutionArgumentSubscription;
2572
+ actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
2573
+ next: async (e) => {
2574
+ if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
2575
+ await pushArgumentsChunk(e.args);
2576
+ argumentChunks.push(e.args);
2577
+ }
2578
+ },
2579
+ error: (err) => {
2580
+ logger2.error({
2581
+ err
2582
+ }, "Error in action execution argument stream");
2583
+ streamingArgumentsStatus.next(plainToInstance(FailedMessageStatus, {
2584
+ reason: "An unknown error has occurred in the action execution argument stream"
2585
+ }));
2586
+ stopStreamingArguments();
2587
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2588
+ },
2589
+ complete: () => {
2590
+ logger2.debug("Action execution argument stream completed");
2591
+ streamingArgumentsStatus.next(new SuccessMessageStatus());
2592
+ stopStreamingArguments();
2593
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2594
+ outputMessages.push(plainToInstance(ActionExecutionMessage, {
2595
+ id: event.actionExecutionId,
2596
+ createdAt: /* @__PURE__ */ new Date(),
2597
+ name: event.actionName,
2598
+ arguments: argumentChunks.join("")
2599
+ }));
2600
+ }
2601
+ });
2602
+ })
2603
+ });
2604
+ break;
2605
+ case RuntimeEventTypes.ActionExecutionResult:
2606
+ logger2.debug({
2607
+ result: event.result
2608
+ }, "Action execution result event received");
2609
+ pushMessage({
2610
+ id: "result-" + event.actionExecutionId,
2611
+ status: new SuccessMessageStatus(),
2612
+ createdAt: /* @__PURE__ */ new Date(),
2613
+ actionExecutionId: event.actionExecutionId,
2614
+ actionName: event.actionName,
2615
+ result: event.result
2616
+ });
2617
+ outputMessages.push(plainToInstance(ResultMessage, {
2618
+ id: "result-" + event.actionExecutionId,
2619
+ createdAt: /* @__PURE__ */ new Date(),
2620
+ actionExecutionId: event.actionExecutionId,
2621
+ actionName: event.actionName,
2622
+ result: event.result
2623
+ }));
2624
+ break;
2625
+ case RuntimeEventTypes.AgentStateMessage:
2626
+ logger2.debug({
2627
+ event
2628
+ }, "Agent message event received");
2629
+ pushMessage({
2630
+ id: randomId(),
2631
+ status: new SuccessMessageStatus(),
2632
+ threadId: event.threadId,
2633
+ agentName: event.agentName,
2634
+ nodeName: event.nodeName,
2635
+ runId: event.runId,
2636
+ active: event.active,
2637
+ state: event.state,
2638
+ running: event.running,
2639
+ role: MessageRole.assistant,
2640
+ createdAt: /* @__PURE__ */ new Date()
2641
+ });
2642
+ outputMessages.push(plainToInstance(AgentStateMessage, {
2643
+ id: randomId(),
2644
+ threadId: event.threadId,
2645
+ agentName: event.agentName,
2646
+ nodeName: event.nodeName,
2647
+ runId: event.runId,
2648
+ active: event.active,
2649
+ state: event.state,
2650
+ running: event.running,
2651
+ role: MessageRole.assistant,
2652
+ createdAt: /* @__PURE__ */ new Date()
2653
+ }));
2654
+ break;
2655
+ }
2656
+ },
2657
+ error: (err) => {
2658
+ var _a3, _b2, _c2, _d2, _e, _f;
2659
+ if (err instanceof CopilotKitError2 || err instanceof CopilotKitLowLevelError2 || err instanceof Error && err.name && err.name.includes("CopilotKit") || ((_a3 = err == null ? void 0 : err.extensions) == null ? void 0 : _a3.visibility)) {
2660
+ responseStatus$.next(new UnknownErrorResponse({
2661
+ description: err.message || "Agent error occurred",
2662
+ // Include original error information for frontend to extract
2663
+ originalError: {
2664
+ code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
2665
+ statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
2666
+ severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
2667
+ visibility: err.visibility || ((_e = err.extensions) == null ? void 0 : _e.visibility),
2668
+ originalErrorType: err.originalErrorType || ((_f = err.extensions) == null ? void 0 : _f.originalErrorType),
2669
+ extensions: err.extensions
2670
+ }
2671
+ }));
2672
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2673
+ rejectOutputMessagesPromise(err);
2674
+ stopStreamingMessages();
2675
+ return;
2676
+ }
2677
+ responseStatus$.next(new UnknownErrorResponse({
2678
+ description: `An unknown error has occurred in the event stream`
2679
+ }));
2680
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2681
+ stopStreamingMessages();
2682
+ rejectOutputMessagesPromise(err);
2683
+ },
2684
+ complete: async () => {
2685
+ var _a3;
2686
+ logger2.debug("Event stream completed");
2687
+ if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
2688
+ logger2.debug("Guardrails is enabled, waiting for guardrails result");
2689
+ await firstValueFrom(guardrailsResult$);
2690
+ }
2691
+ responseStatus$.next(new SuccessResponseStatus());
2692
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2693
+ stopStreamingMessages();
2694
+ resolveOutputMessagesPromise(outputMessages);
2695
+ }
2696
+ });
2697
+ })
2698
+ };
2699
+ return response;
2700
+ }
2701
+ };
2702
+ __name(CopilotResolver, "CopilotResolver");
2703
+ _ts_decorate17([
2704
+ Query(() => String),
2705
+ _ts_metadata17("design:type", Function),
2706
+ _ts_metadata17("design:paramtypes", []),
2707
+ _ts_metadata17("design:returntype", Promise)
2708
+ ], CopilotResolver.prototype, "hello", null);
2709
+ _ts_decorate17([
2710
+ Query(() => AgentsResponse),
2711
+ _ts_param(0, Ctx()),
2712
+ _ts_metadata17("design:type", Function),
2713
+ _ts_metadata17("design:paramtypes", [
2714
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext
2715
+ ]),
2716
+ _ts_metadata17("design:returntype", Promise)
2717
+ ], CopilotResolver.prototype, "availableAgents", null);
2718
+ _ts_decorate17([
2719
+ Mutation(() => CopilotResponse),
2720
+ _ts_param(0, Ctx()),
2721
+ _ts_param(1, Arg("data")),
2722
+ _ts_param(2, Arg("properties", () => GraphQLJSONObject, {
2723
+ nullable: true
2724
+ })),
2725
+ _ts_metadata17("design:type", Function),
2726
+ _ts_metadata17("design:paramtypes", [
2727
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2728
+ typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
2729
+ typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
2730
+ ]),
2731
+ _ts_metadata17("design:returntype", Promise)
2732
+ ], CopilotResolver.prototype, "generateCopilotResponse", null);
2733
+ CopilotResolver = _ts_decorate17([
2734
+ Resolver(() => CopilotResponse)
2735
+ ], CopilotResolver);
2736
+
2737
+ // src/lib/integrations/shared.ts
2738
+ import { useDeferStream } from "@graphql-yoga/plugin-defer-stream";
2739
+
2740
+ // src/lib/logger.ts
2741
+ import createPinoLogger from "pino";
2742
+ import pretty from "pino-pretty";
2743
+ function createLogger(options) {
2744
+ const { level, component } = options || {};
2745
+ const stream = pretty({
2746
+ colorize: true
2747
+ });
2748
+ const logger2 = createPinoLogger({
2749
+ level: process.env.LOG_LEVEL || level || "error",
2750
+ redact: {
2751
+ paths: [
2752
+ "pid",
2753
+ "hostname"
2754
+ ],
2755
+ remove: true
2756
+ }
2757
+ }, stream);
2758
+ if (component) {
2759
+ return logger2.child({
2760
+ component
2761
+ });
2762
+ } else {
2763
+ return logger2;
2764
+ }
2765
+ }
2766
+ __name(createLogger, "createLogger");
2767
+
2768
+ // src/graphql/resolvers/state.resolver.ts
2769
+ import { Arg as Arg2, Resolver as Resolver2 } from "type-graphql";
2770
+ import { Ctx as Ctx2 } from "type-graphql";
2771
+ import { Query as Query2 } from "type-graphql";
2772
+
2773
+ // src/graphql/types/load-agent-state-response.type.ts
2774
+ import { Field as Field17, ObjectType as ObjectType5 } from "type-graphql";
2775
+ function _ts_decorate18(decorators, target, key, desc) {
2776
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2777
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2778
+ r = Reflect.decorate(decorators, target, key, desc);
2779
+ else
2780
+ for (var i = decorators.length - 1; i >= 0; i--)
2781
+ if (d = decorators[i])
2782
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2783
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2784
+ }
2785
+ __name(_ts_decorate18, "_ts_decorate");
2786
+ function _ts_metadata18(k, v) {
2787
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2788
+ return Reflect.metadata(k, v);
2789
+ }
2790
+ __name(_ts_metadata18, "_ts_metadata");
2791
+ var LoadAgentStateResponse = class {
2792
+ threadId;
2793
+ threadExists;
2794
+ state;
2795
+ messages;
2796
+ };
2797
+ __name(LoadAgentStateResponse, "LoadAgentStateResponse");
2798
+ _ts_decorate18([
2799
+ Field17(() => String),
2800
+ _ts_metadata18("design:type", String)
2801
+ ], LoadAgentStateResponse.prototype, "threadId", void 0);
2802
+ _ts_decorate18([
2803
+ Field17(() => Boolean),
2804
+ _ts_metadata18("design:type", Boolean)
2805
+ ], LoadAgentStateResponse.prototype, "threadExists", void 0);
2806
+ _ts_decorate18([
2807
+ Field17(() => String),
2808
+ _ts_metadata18("design:type", String)
2809
+ ], LoadAgentStateResponse.prototype, "state", void 0);
2810
+ _ts_decorate18([
2811
+ Field17(() => String),
2812
+ _ts_metadata18("design:type", String)
2813
+ ], LoadAgentStateResponse.prototype, "messages", void 0);
2814
+ LoadAgentStateResponse = _ts_decorate18([
2815
+ ObjectType5()
2816
+ ], LoadAgentStateResponse);
2817
+
2818
+ // src/graphql/inputs/load-agent-state.input.ts
2819
+ import { Field as Field18, InputType as InputType13 } from "type-graphql";
2820
+ function _ts_decorate19(decorators, target, key, desc) {
2821
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2822
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2823
+ r = Reflect.decorate(decorators, target, key, desc);
2824
+ else
2825
+ for (var i = decorators.length - 1; i >= 0; i--)
2826
+ if (d = decorators[i])
2827
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2828
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2829
+ }
2830
+ __name(_ts_decorate19, "_ts_decorate");
2831
+ function _ts_metadata19(k, v) {
2832
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2833
+ return Reflect.metadata(k, v);
2834
+ }
2835
+ __name(_ts_metadata19, "_ts_metadata");
2836
+ var LoadAgentStateInput = class {
2837
+ threadId;
2838
+ agentName;
2839
+ };
2840
+ __name(LoadAgentStateInput, "LoadAgentStateInput");
2841
+ _ts_decorate19([
2842
+ Field18(() => String),
2843
+ _ts_metadata19("design:type", String)
2844
+ ], LoadAgentStateInput.prototype, "threadId", void 0);
2845
+ _ts_decorate19([
2846
+ Field18(() => String),
2847
+ _ts_metadata19("design:type", String)
2848
+ ], LoadAgentStateInput.prototype, "agentName", void 0);
2849
+ LoadAgentStateInput = _ts_decorate19([
2850
+ InputType13()
2851
+ ], LoadAgentStateInput);
2852
+
2853
+ // src/graphql/resolvers/state.resolver.ts
2854
+ import { CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
2855
+ function _ts_decorate20(decorators, target, key, desc) {
2856
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2857
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2858
+ r = Reflect.decorate(decorators, target, key, desc);
2859
+ else
2860
+ for (var i = decorators.length - 1; i >= 0; i--)
2861
+ if (d = decorators[i])
2862
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2863
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2864
+ }
2865
+ __name(_ts_decorate20, "_ts_decorate");
2866
+ function _ts_metadata20(k, v) {
2867
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2868
+ return Reflect.metadata(k, v);
2869
+ }
2870
+ __name(_ts_metadata20, "_ts_metadata");
2871
+ function _ts_param2(paramIndex, decorator) {
2872
+ return function(target, key) {
2873
+ decorator(target, key, paramIndex);
2874
+ };
2875
+ }
2876
+ __name(_ts_param2, "_ts_param");
2877
+ var StateResolver = class {
2878
+ async loadAgentState(ctx, data) {
2879
+ const agents = [];
2880
+ const hasAgent = agents.some((agent) => agent.name === data.agentName);
2881
+ if (!hasAgent) {
2882
+ throw new CopilotKitAgentDiscoveryError({
2883
+ agentName: data.agentName,
2884
+ availableAgents: agents.map((a) => ({
2885
+ name: a.name,
2886
+ id: a.name
2887
+ }))
2888
+ });
2889
+ }
2890
+ const state = {};
2891
+ return state;
2892
+ }
2893
+ };
2894
+ __name(StateResolver, "StateResolver");
2895
+ _ts_decorate20([
2896
+ Query2(() => LoadAgentStateResponse),
2897
+ _ts_param2(0, Ctx2()),
2898
+ _ts_param2(1, Arg2("data")),
2899
+ _ts_metadata20("design:type", Function),
2900
+ _ts_metadata20("design:paramtypes", [
2901
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2902
+ typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
2903
+ ]),
2904
+ _ts_metadata20("design:returntype", Promise)
2905
+ ], StateResolver.prototype, "loadAgentState", null);
2906
+ StateResolver = _ts_decorate20([
2907
+ Resolver2(() => LoadAgentStateResponse)
2908
+ ], StateResolver);
2909
+
2910
+ // src/lib/integrations/shared.ts
2911
+ var packageJson2 = __toESM(require_package());
2912
+ import { CopilotKitError as CopilotKitError3, CopilotKitErrorCode as CopilotKitErrorCode2 } from "@copilotkit/shared";
2913
+ var logger = createLogger();
2914
+ var addCustomHeaderPlugin = {
2915
+ onResponse({ response }) {
2916
+ response.headers.set("X-CopilotKit-Runtime-Version", packageJson2.version);
2917
+ }
2918
+ };
2919
+ async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
2920
+ logger.debug({
2921
+ copilotKitContext
2922
+ }, "Creating GraphQL context");
2923
+ const ctx = {
2924
+ ...initialContext,
2925
+ _copilotkit: {
2926
+ ...copilotKitContext
2927
+ },
2928
+ properties: {
2929
+ ...properties
2930
+ },
2931
+ logger: contextLogger
2932
+ };
2933
+ return ctx;
2934
+ }
2935
+ __name(createContext, "createContext");
2936
+ function buildSchema(options = {}) {
2937
+ logger.debug("Building GraphQL schema...");
2938
+ const schema = buildSchemaSync({
2939
+ resolvers: [
2940
+ CopilotResolver,
2941
+ StateResolver
2942
+ ],
2943
+ emitSchemaFile: options.emitSchemaFile
2944
+ });
2945
+ logger.debug("GraphQL schema built successfully");
2946
+ return schema;
2947
+ }
2948
+ __name(buildSchema, "buildSchema");
2949
+ function getCommonConfig(options) {
2950
+ var _a;
2951
+ const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
2952
+ const logger2 = createLogger({
2953
+ level: logLevel,
2954
+ component: "getCommonConfig"
2955
+ });
2956
+ const contextLogger = createLogger({
2957
+ level: logLevel
2958
+ });
2959
+ if (options.cloud) {
2960
+ telemetry_client_default.setCloudConfiguration({
2961
+ publicApiKey: options.cloud.publicApiKey,
2962
+ baseUrl: options.cloud.baseUrl
2963
+ });
2964
+ }
2965
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2966
+ telemetry_client_default.setGlobalProperties({
2967
+ _copilotkit: {
2968
+ ...options.properties._copilotkit
2969
+ }
2970
+ });
2971
+ }
2972
+ telemetry_client_default.setGlobalProperties({
2973
+ runtime: {
2974
+ serviceAdapter: options.serviceAdapter.constructor.name
2975
+ }
2976
+ });
2977
+ const userErrorCodes = [
2978
+ CopilotKitErrorCode2.AGENT_NOT_FOUND,
2979
+ CopilotKitErrorCode2.API_NOT_FOUND,
2980
+ CopilotKitErrorCode2.REMOTE_ENDPOINT_NOT_FOUND,
2981
+ CopilotKitErrorCode2.CONFIGURATION_ERROR,
2982
+ CopilotKitErrorCode2.MISSING_PUBLIC_API_KEY_ERROR
2983
+ ];
2984
+ return {
2985
+ logging: createLogger({
2986
+ component: "Yoga GraphQL",
2987
+ level: logLevel
2988
+ }),
2989
+ schema: buildSchema(),
2990
+ plugins: [
2991
+ useDeferStream(),
2992
+ addCustomHeaderPlugin
2993
+ ],
2994
+ context: (ctx) => createContext(ctx, options, contextLogger, options.properties),
2995
+ // Suppress logging for user configuration errors
2996
+ maskedErrors: {
2997
+ maskError: (error, message, isDev) => {
2998
+ const originalError = error.originalError || error;
2999
+ const extensions = error.extensions;
3000
+ const errorCode = extensions == null ? void 0 : extensions.code;
3001
+ if (errorCode && userErrorCodes.includes(errorCode)) {
3002
+ console.debug("User configuration error:", error.message);
3003
+ return error;
3004
+ }
3005
+ if (originalError instanceof CopilotKitError3 && userErrorCodes.includes(originalError.code)) {
3006
+ console.debug("User configuration error:", error.message);
3007
+ return error;
3008
+ }
3009
+ console.error("Application error:", error);
3010
+ return error;
3011
+ }
3012
+ }
3013
+ };
3014
+ }
3015
+ __name(getCommonConfig, "getCommonConfig");
3016
+
3017
+ // src/lib/integrations/node-http/index.ts
3018
+ function copilotRuntimeNodeHttpEndpoint(options) {
3019
+ var _a;
3020
+ const commonConfig = getCommonConfig(options);
3021
+ telemetry_client_default.setGlobalProperties({
3022
+ runtime: {
3023
+ framework: "node-http"
3024
+ }
3025
+ });
3026
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
3027
+ telemetry_client_default.setGlobalProperties({
3028
+ _copilotkit: options.properties._copilotkit
3029
+ });
3030
+ }
3031
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
3032
+ const logger2 = commonConfig.logging;
3033
+ logger2.debug("Creating Node HTTP endpoint");
3034
+ const serviceAdapter = options.serviceAdapter;
3035
+ options.runtime.handleServiceAdapter(serviceAdapter);
3036
+ return createCopilotEndpoint({
3037
+ runtime: options.runtime.instance,
3038
+ basePath: options.baseUrl
3039
+ });
3040
+ }
3041
+ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
3042
+
3043
+ export {
3044
+ extractParametersFromSchema,
3045
+ convertMCPToolsToActions,
3046
+ generateMcpToolInstructions,
3047
+ LangGraphHttpAgent,
3048
+ CustomEventNames2 as CustomEventNames,
3049
+ LangGraphAgent,
3050
+ CopilotRuntime,
3051
+ copilotKitEndpoint,
3052
+ langGraphPlatformEndpoint,
3053
+ resolveEndpointType,
3054
+ getRuntimeInstanceTelemetryInfo,
3055
+ telemetry_client_default,
3056
+ createLogger,
3057
+ addCustomHeaderPlugin,
3058
+ createContext,
3059
+ buildSchema,
3060
+ getCommonConfig,
3061
+ copilotRuntimeNodeHttpEndpoint
3062
+ };
3063
+ //# sourceMappingURL=chunk-DZV4ZIAR.mjs.map