@copilotkit/runtime 1.5.9 → 1.5.10-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/__snapshots__/schema/schema.graphql +273 -0
  3. package/dist/chunk-44O2JGUY.mjs +12 -0
  4. package/dist/chunk-44O2JGUY.mjs.map +1 -0
  5. package/dist/chunk-5SDH2PVU.mjs +3395 -0
  6. package/dist/chunk-5SDH2PVU.mjs.map +1 -0
  7. package/dist/chunk-CLGKEUOA.mjs +1408 -0
  8. package/dist/chunk-CLGKEUOA.mjs.map +1 -0
  9. package/dist/chunk-D2WLFQS6.mjs +43 -0
  10. package/dist/chunk-D2WLFQS6.mjs.map +1 -0
  11. package/dist/chunk-DFOKBSIS.mjs +1 -0
  12. package/dist/chunk-DFOKBSIS.mjs.map +1 -0
  13. package/dist/chunk-OZLXON7T.mjs +25 -0
  14. package/dist/chunk-OZLXON7T.mjs.map +1 -0
  15. package/dist/chunk-RFF5IIZJ.mjs +66 -0
  16. package/dist/chunk-RFF5IIZJ.mjs.map +1 -0
  17. package/dist/chunk-T4EYPND5.mjs +25 -0
  18. package/dist/chunk-T4EYPND5.mjs.map +1 -0
  19. package/dist/chunk-U3V2BCGI.mjs +152 -0
  20. package/dist/chunk-U3V2BCGI.mjs.map +1 -0
  21. package/dist/chunk-YTXDY7ZM.mjs +80 -0
  22. package/dist/chunk-YTXDY7ZM.mjs.map +1 -0
  23. package/dist/copilot-runtime-36700e00.d.ts +196 -0
  24. package/dist/graphql/types/base/index.d.ts +6 -0
  25. package/dist/graphql/types/base/index.js +63 -0
  26. package/dist/graphql/types/base/index.js.map +1 -0
  27. package/dist/graphql/types/base/index.mjs +8 -0
  28. package/dist/graphql/types/base/index.mjs.map +1 -0
  29. package/dist/graphql/types/converted/index.d.ts +2 -0
  30. package/dist/graphql/types/converted/index.js +124 -0
  31. package/dist/graphql/types/converted/index.js.map +1 -0
  32. package/dist/graphql/types/converted/index.mjs +17 -0
  33. package/dist/graphql/types/converted/index.mjs.map +1 -0
  34. package/dist/groq-adapter-696b5d29.d.ts +281 -0
  35. package/dist/index-cc2b17be.d.ts +87 -0
  36. package/dist/index.d.ts +23 -0
  37. package/dist/index.js +5153 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/index.mjs +76 -0
  40. package/dist/index.mjs.map +1 -0
  41. package/dist/langserve-9125a12e.d.ts +176 -0
  42. package/dist/lib/cloud/index.d.ts +6 -0
  43. package/dist/lib/cloud/index.js +18 -0
  44. package/dist/lib/cloud/index.js.map +1 -0
  45. package/dist/lib/cloud/index.mjs +1 -0
  46. package/dist/lib/cloud/index.mjs.map +1 -0
  47. package/dist/lib/index.d.ts +20 -0
  48. package/dist/lib/index.js +4801 -0
  49. package/dist/lib/index.js.map +1 -0
  50. package/dist/lib/index.mjs +58 -0
  51. package/dist/lib/index.mjs.map +1 -0
  52. package/dist/lib/integrations/index.d.ts +33 -0
  53. package/dist/lib/integrations/index.js +2166 -0
  54. package/dist/lib/integrations/index.js.map +1 -0
  55. package/dist/lib/integrations/index.mjs +34 -0
  56. package/dist/lib/integrations/index.mjs.map +1 -0
  57. package/dist/lib/integrations/nest/index.d.ts +14 -0
  58. package/dist/lib/integrations/nest/index.js +2075 -0
  59. package/dist/lib/integrations/nest/index.js.map +1 -0
  60. package/dist/lib/integrations/nest/index.mjs +13 -0
  61. package/dist/lib/integrations/nest/index.mjs.map +1 -0
  62. package/dist/lib/integrations/node-express/index.d.ts +14 -0
  63. package/dist/lib/integrations/node-express/index.js +2075 -0
  64. package/dist/lib/integrations/node-express/index.js.map +1 -0
  65. package/dist/lib/integrations/node-express/index.mjs +13 -0
  66. package/dist/lib/integrations/node-express/index.mjs.map +1 -0
  67. package/dist/lib/integrations/node-http/index.d.ts +14 -0
  68. package/dist/lib/integrations/node-http/index.js +2061 -0
  69. package/dist/lib/integrations/node-http/index.js.map +1 -0
  70. package/dist/lib/integrations/node-http/index.mjs +12 -0
  71. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  72. package/dist/service-adapters/index.d.ts +84 -0
  73. package/dist/service-adapters/index.js +1448 -0
  74. package/dist/service-adapters/index.js.map +1 -0
  75. package/dist/service-adapters/index.mjs +26 -0
  76. package/dist/service-adapters/index.mjs.map +1 -0
  77. package/dist/utils/index.d.ts +49 -0
  78. package/dist/utils/index.js +174 -0
  79. package/dist/utils/index.js.map +1 -0
  80. package/dist/utils/index.mjs +12 -0
  81. package/dist/utils/index.mjs.map +1 -0
  82. package/package.json +2 -2
@@ -0,0 +1,2166 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from3, except, desc) => {
16
+ if (from3 && typeof from3 === "object" || typeof from3 === "function") {
17
+ for (let key of __getOwnPropNames(from3))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // package.json
34
+ var require_package = __commonJS({
35
+ "package.json"(exports, module2) {
36
+ module2.exports = {
37
+ name: "@copilotkit/runtime",
38
+ private: false,
39
+ homepage: "https://github.com/CopilotKit/CopilotKit",
40
+ repository: {
41
+ type: "git",
42
+ url: "https://github.com/CopilotKit/CopilotKit.git"
43
+ },
44
+ publishConfig: {
45
+ access: "public"
46
+ },
47
+ version: "1.5.10-next.0",
48
+ sideEffects: false,
49
+ main: "./dist/index.js",
50
+ module: "./dist/index.mjs",
51
+ exports: {
52
+ ".": "./dist/index.js"
53
+ },
54
+ types: "./dist/index.d.ts",
55
+ license: "MIT",
56
+ scripts: {
57
+ build: 'tsup --onSuccess "pnpm run generate-graphql-schema"',
58
+ dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
59
+ test: "jest --passWithNoTests",
60
+ "check-types": "tsc --noEmit",
61
+ clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next && rm -rf __snapshots__",
62
+ "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts",
63
+ "link:global": "pnpm link --global",
64
+ "unlink:global": "pnpm unlink --global"
65
+ },
66
+ devDependencies: {
67
+ "@swc/core": "1.5.28",
68
+ "@types/express": "^4.17.21",
69
+ "@types/jest": "^29.5.4",
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
+ "zod-to-json-schema": "^3.23.5"
82
+ },
83
+ dependencies: {
84
+ "@anthropic-ai/sdk": "^0.27.3",
85
+ "@copilotkit/shared": "workspace:*",
86
+ "@graphql-yoga/plugin-defer-stream": "^3.3.1",
87
+ "@langchain/community": "^0.0.53",
88
+ "@langchain/core": "^0.3.13",
89
+ "@langchain/google-gauth": "^0.1.0",
90
+ "@langchain/langgraph-sdk": "^0.0.16",
91
+ "@langchain/openai": "^0.0.28",
92
+ "class-transformer": "^0.5.1",
93
+ express: "^4.19.2",
94
+ graphql: "^16.8.1",
95
+ "graphql-scalars": "^1.23.0",
96
+ "graphql-yoga": "^5.3.1",
97
+ "groq-sdk": "^0.5.0",
98
+ langchain: "^0.3.3",
99
+ openai: "^4.50.0",
100
+ "partial-json": "^0.1.7",
101
+ pino: "^9.2.0",
102
+ "pino-pretty": "^11.2.1",
103
+ "reflect-metadata": "^0.2.2",
104
+ rxjs: "^7.8.1",
105
+ "type-graphql": "2.0.0-rc.1",
106
+ zod: "^3.23.3"
107
+ },
108
+ keywords: [
109
+ "copilotkit",
110
+ "copilot",
111
+ "react",
112
+ "nextjs",
113
+ "nodejs",
114
+ "ai",
115
+ "assistant",
116
+ "javascript",
117
+ "automation",
118
+ "textarea"
119
+ ]
120
+ };
121
+ }
122
+ });
123
+
124
+ // src/lib/integrations/index.ts
125
+ var integrations_exports = {};
126
+ __export(integrations_exports, {
127
+ buildSchema: () => buildSchema,
128
+ config: () => config,
129
+ copilotRuntimeNestEndpoint: () => copilotRuntimeNestEndpoint,
130
+ copilotRuntimeNextJSAppRouterEndpoint: () => copilotRuntimeNextJSAppRouterEndpoint,
131
+ copilotRuntimeNextJSPagesRouterEndpoint: () => copilotRuntimeNextJSPagesRouterEndpoint,
132
+ copilotRuntimeNodeExpressEndpoint: () => copilotRuntimeNodeExpressEndpoint,
133
+ copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint,
134
+ createContext: () => createContext,
135
+ getCommonConfig: () => getCommonConfig
136
+ });
137
+ module.exports = __toCommonJS(integrations_exports);
138
+
139
+ // src/lib/integrations/shared.ts
140
+ var import_type_graphql17 = require("type-graphql");
141
+
142
+ // src/graphql/resolvers/copilot.resolver.ts
143
+ var import_type_graphql16 = require("type-graphql");
144
+ var import_rxjs3 = require("rxjs");
145
+
146
+ // src/graphql/inputs/generate-copilot-response.input.ts
147
+ var import_type_graphql11 = require("type-graphql");
148
+
149
+ // src/graphql/inputs/message.input.ts
150
+ var import_type_graphql3 = require("type-graphql");
151
+
152
+ // src/graphql/types/enums.ts
153
+ var import_type_graphql = require("type-graphql");
154
+ var MessageRole;
155
+ (function(MessageRole2) {
156
+ MessageRole2["user"] = "user";
157
+ MessageRole2["assistant"] = "assistant";
158
+ MessageRole2["system"] = "system";
159
+ MessageRole2["tool"] = "tool";
160
+ })(MessageRole || (MessageRole = {}));
161
+ var CopilotRequestType;
162
+ (function(CopilotRequestType2) {
163
+ CopilotRequestType2["Chat"] = "Chat";
164
+ CopilotRequestType2["Task"] = "Task";
165
+ CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
166
+ CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
167
+ CopilotRequestType2["Suggestion"] = "Suggestion";
168
+ })(CopilotRequestType || (CopilotRequestType = {}));
169
+ var ActionInputAvailability;
170
+ (function(ActionInputAvailability2) {
171
+ ActionInputAvailability2["disabled"] = "disabled";
172
+ ActionInputAvailability2["enabled"] = "enabled";
173
+ ActionInputAvailability2["remote"] = "remote";
174
+ })(ActionInputAvailability || (ActionInputAvailability = {}));
175
+ (0, import_type_graphql.registerEnumType)(MessageRole, {
176
+ name: "MessageRole",
177
+ description: "The role of the message"
178
+ });
179
+ (0, import_type_graphql.registerEnumType)(CopilotRequestType, {
180
+ name: "CopilotRequestType",
181
+ description: "The type of Copilot request"
182
+ });
183
+ (0, import_type_graphql.registerEnumType)(ActionInputAvailability, {
184
+ name: "ActionInputAvailability",
185
+ description: "The availability of the frontend action"
186
+ });
187
+
188
+ // src/graphql/types/base/index.ts
189
+ var import_type_graphql2 = require("type-graphql");
190
+ function _ts_decorate(decorators, target, key, desc) {
191
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
192
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
193
+ r = Reflect.decorate(decorators, target, key, desc);
194
+ else
195
+ for (var i = decorators.length - 1; i >= 0; i--)
196
+ if (d = decorators[i])
197
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
198
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
199
+ }
200
+ __name(_ts_decorate, "_ts_decorate");
201
+ function _ts_metadata(k, v) {
202
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
203
+ return Reflect.metadata(k, v);
204
+ }
205
+ __name(_ts_metadata, "_ts_metadata");
206
+ var BaseMessageInput = class {
207
+ id;
208
+ createdAt;
209
+ };
210
+ __name(BaseMessageInput, "BaseMessageInput");
211
+ _ts_decorate([
212
+ (0, import_type_graphql2.Field)(() => String),
213
+ _ts_metadata("design:type", String)
214
+ ], BaseMessageInput.prototype, "id", void 0);
215
+ _ts_decorate([
216
+ (0, import_type_graphql2.Field)(() => Date),
217
+ _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
218
+ ], BaseMessageInput.prototype, "createdAt", void 0);
219
+ BaseMessageInput = _ts_decorate([
220
+ (0, import_type_graphql2.InputType)()
221
+ ], BaseMessageInput);
222
+
223
+ // src/graphql/inputs/message.input.ts
224
+ function _ts_decorate2(decorators, target, key, desc) {
225
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
226
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
227
+ r = Reflect.decorate(decorators, target, key, desc);
228
+ else
229
+ for (var i = decorators.length - 1; i >= 0; i--)
230
+ if (d = decorators[i])
231
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
232
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
233
+ }
234
+ __name(_ts_decorate2, "_ts_decorate");
235
+ function _ts_metadata2(k, v) {
236
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
237
+ return Reflect.metadata(k, v);
238
+ }
239
+ __name(_ts_metadata2, "_ts_metadata");
240
+ var MessageInput = class extends BaseMessageInput {
241
+ textMessage;
242
+ actionExecutionMessage;
243
+ resultMessage;
244
+ agentStateMessage;
245
+ };
246
+ __name(MessageInput, "MessageInput");
247
+ _ts_decorate2([
248
+ (0, import_type_graphql3.Field)(() => TextMessageInput, {
249
+ nullable: true
250
+ }),
251
+ _ts_metadata2("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
252
+ ], MessageInput.prototype, "textMessage", void 0);
253
+ _ts_decorate2([
254
+ (0, import_type_graphql3.Field)(() => ActionExecutionMessageInput, {
255
+ nullable: true
256
+ }),
257
+ _ts_metadata2("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
258
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
259
+ _ts_decorate2([
260
+ (0, import_type_graphql3.Field)(() => ResultMessageInput, {
261
+ nullable: true
262
+ }),
263
+ _ts_metadata2("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
264
+ ], MessageInput.prototype, "resultMessage", void 0);
265
+ _ts_decorate2([
266
+ (0, import_type_graphql3.Field)(() => AgentStateMessageInput, {
267
+ nullable: true
268
+ }),
269
+ _ts_metadata2("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
270
+ ], MessageInput.prototype, "agentStateMessage", void 0);
271
+ MessageInput = _ts_decorate2([
272
+ (0, import_type_graphql3.InputType)()
273
+ ], MessageInput);
274
+ var TextMessageInput = class {
275
+ content;
276
+ parentMessageId;
277
+ role;
278
+ };
279
+ __name(TextMessageInput, "TextMessageInput");
280
+ _ts_decorate2([
281
+ (0, import_type_graphql3.Field)(() => String),
282
+ _ts_metadata2("design:type", String)
283
+ ], TextMessageInput.prototype, "content", void 0);
284
+ _ts_decorate2([
285
+ (0, import_type_graphql3.Field)(() => String, {
286
+ nullable: true
287
+ }),
288
+ _ts_metadata2("design:type", String)
289
+ ], TextMessageInput.prototype, "parentMessageId", void 0);
290
+ _ts_decorate2([
291
+ (0, import_type_graphql3.Field)(() => MessageRole),
292
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
293
+ ], TextMessageInput.prototype, "role", void 0);
294
+ TextMessageInput = _ts_decorate2([
295
+ (0, import_type_graphql3.InputType)()
296
+ ], TextMessageInput);
297
+ var ActionExecutionMessageInput = class {
298
+ name;
299
+ arguments;
300
+ parentMessageId;
301
+ scope;
302
+ };
303
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
304
+ _ts_decorate2([
305
+ (0, import_type_graphql3.Field)(() => String),
306
+ _ts_metadata2("design:type", String)
307
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
308
+ _ts_decorate2([
309
+ (0, import_type_graphql3.Field)(() => String),
310
+ _ts_metadata2("design:type", String)
311
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
312
+ _ts_decorate2([
313
+ (0, import_type_graphql3.Field)(() => String, {
314
+ nullable: true
315
+ }),
316
+ _ts_metadata2("design:type", String)
317
+ ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
318
+ _ts_decorate2([
319
+ (0, import_type_graphql3.Field)(() => String, {
320
+ nullable: true,
321
+ deprecationReason: "This field will be removed in a future version"
322
+ }),
323
+ _ts_metadata2("design:type", typeof String === "undefined" ? Object : String)
324
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
325
+ ActionExecutionMessageInput = _ts_decorate2([
326
+ (0, import_type_graphql3.InputType)()
327
+ ], ActionExecutionMessageInput);
328
+ var ResultMessageInput = class {
329
+ actionExecutionId;
330
+ actionName;
331
+ parentMessageId;
332
+ result;
333
+ };
334
+ __name(ResultMessageInput, "ResultMessageInput");
335
+ _ts_decorate2([
336
+ (0, import_type_graphql3.Field)(() => String),
337
+ _ts_metadata2("design:type", String)
338
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
339
+ _ts_decorate2([
340
+ (0, import_type_graphql3.Field)(() => String),
341
+ _ts_metadata2("design:type", String)
342
+ ], ResultMessageInput.prototype, "actionName", void 0);
343
+ _ts_decorate2([
344
+ (0, import_type_graphql3.Field)(() => String, {
345
+ nullable: true
346
+ }),
347
+ _ts_metadata2("design:type", String)
348
+ ], ResultMessageInput.prototype, "parentMessageId", void 0);
349
+ _ts_decorate2([
350
+ (0, import_type_graphql3.Field)(() => String),
351
+ _ts_metadata2("design:type", String)
352
+ ], ResultMessageInput.prototype, "result", void 0);
353
+ ResultMessageInput = _ts_decorate2([
354
+ (0, import_type_graphql3.InputType)()
355
+ ], ResultMessageInput);
356
+ var AgentStateMessageInput = class {
357
+ threadId;
358
+ agentName;
359
+ role;
360
+ state;
361
+ running;
362
+ nodeName;
363
+ runId;
364
+ active;
365
+ };
366
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
367
+ _ts_decorate2([
368
+ (0, import_type_graphql3.Field)(() => String),
369
+ _ts_metadata2("design:type", String)
370
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
371
+ _ts_decorate2([
372
+ (0, import_type_graphql3.Field)(() => String),
373
+ _ts_metadata2("design:type", String)
374
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
375
+ _ts_decorate2([
376
+ (0, import_type_graphql3.Field)(() => MessageRole),
377
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
378
+ ], AgentStateMessageInput.prototype, "role", void 0);
379
+ _ts_decorate2([
380
+ (0, import_type_graphql3.Field)(() => String),
381
+ _ts_metadata2("design:type", String)
382
+ ], AgentStateMessageInput.prototype, "state", void 0);
383
+ _ts_decorate2([
384
+ (0, import_type_graphql3.Field)(() => Boolean),
385
+ _ts_metadata2("design:type", Boolean)
386
+ ], AgentStateMessageInput.prototype, "running", void 0);
387
+ _ts_decorate2([
388
+ (0, import_type_graphql3.Field)(() => String),
389
+ _ts_metadata2("design:type", String)
390
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
391
+ _ts_decorate2([
392
+ (0, import_type_graphql3.Field)(() => String),
393
+ _ts_metadata2("design:type", String)
394
+ ], AgentStateMessageInput.prototype, "runId", void 0);
395
+ _ts_decorate2([
396
+ (0, import_type_graphql3.Field)(() => Boolean),
397
+ _ts_metadata2("design:type", Boolean)
398
+ ], AgentStateMessageInput.prototype, "active", void 0);
399
+ AgentStateMessageInput = _ts_decorate2([
400
+ (0, import_type_graphql3.InputType)()
401
+ ], AgentStateMessageInput);
402
+
403
+ // src/graphql/inputs/frontend.input.ts
404
+ var import_type_graphql5 = require("type-graphql");
405
+
406
+ // src/graphql/inputs/action.input.ts
407
+ var import_type_graphql4 = require("type-graphql");
408
+ function _ts_decorate3(decorators, target, key, desc) {
409
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
410
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
411
+ r = Reflect.decorate(decorators, target, key, desc);
412
+ else
413
+ for (var i = decorators.length - 1; i >= 0; i--)
414
+ if (d = decorators[i])
415
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
416
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
417
+ }
418
+ __name(_ts_decorate3, "_ts_decorate");
419
+ function _ts_metadata3(k, v) {
420
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
421
+ return Reflect.metadata(k, v);
422
+ }
423
+ __name(_ts_metadata3, "_ts_metadata");
424
+ var ActionInput = class {
425
+ name;
426
+ description;
427
+ jsonSchema;
428
+ available;
429
+ };
430
+ __name(ActionInput, "ActionInput");
431
+ _ts_decorate3([
432
+ (0, import_type_graphql4.Field)(() => String),
433
+ _ts_metadata3("design:type", String)
434
+ ], ActionInput.prototype, "name", void 0);
435
+ _ts_decorate3([
436
+ (0, import_type_graphql4.Field)(() => String),
437
+ _ts_metadata3("design:type", String)
438
+ ], ActionInput.prototype, "description", void 0);
439
+ _ts_decorate3([
440
+ (0, import_type_graphql4.Field)(() => String),
441
+ _ts_metadata3("design:type", String)
442
+ ], ActionInput.prototype, "jsonSchema", void 0);
443
+ _ts_decorate3([
444
+ (0, import_type_graphql4.Field)(() => ActionInputAvailability, {
445
+ nullable: true
446
+ }),
447
+ _ts_metadata3("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
448
+ ], ActionInput.prototype, "available", void 0);
449
+ ActionInput = _ts_decorate3([
450
+ (0, import_type_graphql4.InputType)()
451
+ ], ActionInput);
452
+
453
+ // src/graphql/inputs/frontend.input.ts
454
+ function _ts_decorate4(decorators, target, key, desc) {
455
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
456
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
457
+ r = Reflect.decorate(decorators, target, key, desc);
458
+ else
459
+ for (var i = decorators.length - 1; i >= 0; i--)
460
+ if (d = decorators[i])
461
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
462
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
463
+ }
464
+ __name(_ts_decorate4, "_ts_decorate");
465
+ function _ts_metadata4(k, v) {
466
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
467
+ return Reflect.metadata(k, v);
468
+ }
469
+ __name(_ts_metadata4, "_ts_metadata");
470
+ var FrontendInput = class {
471
+ toDeprecate_fullContext;
472
+ actions;
473
+ url;
474
+ };
475
+ __name(FrontendInput, "FrontendInput");
476
+ _ts_decorate4([
477
+ (0, import_type_graphql5.Field)(() => String, {
478
+ nullable: true
479
+ }),
480
+ _ts_metadata4("design:type", String)
481
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
482
+ _ts_decorate4([
483
+ (0, import_type_graphql5.Field)(() => [
484
+ ActionInput
485
+ ]),
486
+ _ts_metadata4("design:type", Array)
487
+ ], FrontendInput.prototype, "actions", void 0);
488
+ _ts_decorate4([
489
+ (0, import_type_graphql5.Field)(() => String, {
490
+ nullable: true
491
+ }),
492
+ _ts_metadata4("design:type", String)
493
+ ], FrontendInput.prototype, "url", void 0);
494
+ FrontendInput = _ts_decorate4([
495
+ (0, import_type_graphql5.InputType)()
496
+ ], FrontendInput);
497
+
498
+ // src/graphql/inputs/cloud.input.ts
499
+ var import_type_graphql7 = require("type-graphql");
500
+
501
+ // src/graphql/inputs/cloud-guardrails.input.ts
502
+ var import_type_graphql6 = require("type-graphql");
503
+ function _ts_decorate5(decorators, target, key, desc) {
504
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
505
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
506
+ r = Reflect.decorate(decorators, target, key, desc);
507
+ else
508
+ for (var i = decorators.length - 1; i >= 0; i--)
509
+ if (d = decorators[i])
510
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
511
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
512
+ }
513
+ __name(_ts_decorate5, "_ts_decorate");
514
+ function _ts_metadata5(k, v) {
515
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
516
+ return Reflect.metadata(k, v);
517
+ }
518
+ __name(_ts_metadata5, "_ts_metadata");
519
+ var GuardrailsRuleInput = class {
520
+ allowList = [];
521
+ denyList = [];
522
+ };
523
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
524
+ _ts_decorate5([
525
+ (0, import_type_graphql6.Field)(() => [
526
+ String
527
+ ], {
528
+ nullable: true
529
+ }),
530
+ _ts_metadata5("design:type", Array)
531
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
532
+ _ts_decorate5([
533
+ (0, import_type_graphql6.Field)(() => [
534
+ String
535
+ ], {
536
+ nullable: true
537
+ }),
538
+ _ts_metadata5("design:type", Array)
539
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
540
+ GuardrailsRuleInput = _ts_decorate5([
541
+ (0, import_type_graphql6.InputType)()
542
+ ], GuardrailsRuleInput);
543
+ var GuardrailsInput = class {
544
+ inputValidationRules;
545
+ };
546
+ __name(GuardrailsInput, "GuardrailsInput");
547
+ _ts_decorate5([
548
+ (0, import_type_graphql6.Field)(() => GuardrailsRuleInput, {
549
+ nullable: false
550
+ }),
551
+ _ts_metadata5("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
552
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
553
+ GuardrailsInput = _ts_decorate5([
554
+ (0, import_type_graphql6.InputType)()
555
+ ], GuardrailsInput);
556
+
557
+ // src/graphql/inputs/cloud.input.ts
558
+ function _ts_decorate6(decorators, target, key, desc) {
559
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
560
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
561
+ r = Reflect.decorate(decorators, target, key, desc);
562
+ else
563
+ for (var i = decorators.length - 1; i >= 0; i--)
564
+ if (d = decorators[i])
565
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
566
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
567
+ }
568
+ __name(_ts_decorate6, "_ts_decorate");
569
+ function _ts_metadata6(k, v) {
570
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
571
+ return Reflect.metadata(k, v);
572
+ }
573
+ __name(_ts_metadata6, "_ts_metadata");
574
+ var CloudInput = class {
575
+ guardrails;
576
+ };
577
+ __name(CloudInput, "CloudInput");
578
+ _ts_decorate6([
579
+ (0, import_type_graphql7.Field)(() => GuardrailsInput, {
580
+ nullable: true
581
+ }),
582
+ _ts_metadata6("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
583
+ ], CloudInput.prototype, "guardrails", void 0);
584
+ CloudInput = _ts_decorate6([
585
+ (0, import_type_graphql7.InputType)()
586
+ ], CloudInput);
587
+
588
+ // src/graphql/inputs/forwarded-parameters.input.ts
589
+ var import_type_graphql8 = require("type-graphql");
590
+ function _ts_decorate7(decorators, target, key, desc) {
591
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
592
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
593
+ r = Reflect.decorate(decorators, target, key, desc);
594
+ else
595
+ for (var i = decorators.length - 1; i >= 0; i--)
596
+ if (d = decorators[i])
597
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
598
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
599
+ }
600
+ __name(_ts_decorate7, "_ts_decorate");
601
+ function _ts_metadata7(k, v) {
602
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
603
+ return Reflect.metadata(k, v);
604
+ }
605
+ __name(_ts_metadata7, "_ts_metadata");
606
+ var ForwardedParametersInput = class {
607
+ model;
608
+ maxTokens;
609
+ stop;
610
+ toolChoice;
611
+ toolChoiceFunctionName;
612
+ temperature;
613
+ };
614
+ __name(ForwardedParametersInput, "ForwardedParametersInput");
615
+ _ts_decorate7([
616
+ (0, import_type_graphql8.Field)(() => String, {
617
+ nullable: true
618
+ }),
619
+ _ts_metadata7("design:type", String)
620
+ ], ForwardedParametersInput.prototype, "model", void 0);
621
+ _ts_decorate7([
622
+ (0, import_type_graphql8.Field)(() => Number, {
623
+ nullable: true
624
+ }),
625
+ _ts_metadata7("design:type", Number)
626
+ ], ForwardedParametersInput.prototype, "maxTokens", void 0);
627
+ _ts_decorate7([
628
+ (0, import_type_graphql8.Field)(() => [
629
+ String
630
+ ], {
631
+ nullable: true
632
+ }),
633
+ _ts_metadata7("design:type", Array)
634
+ ], ForwardedParametersInput.prototype, "stop", void 0);
635
+ _ts_decorate7([
636
+ (0, import_type_graphql8.Field)(() => String, {
637
+ nullable: true
638
+ }),
639
+ _ts_metadata7("design:type", typeof String === "undefined" ? Object : String)
640
+ ], ForwardedParametersInput.prototype, "toolChoice", void 0);
641
+ _ts_decorate7([
642
+ (0, import_type_graphql8.Field)(() => String, {
643
+ nullable: true
644
+ }),
645
+ _ts_metadata7("design:type", String)
646
+ ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
647
+ _ts_decorate7([
648
+ (0, import_type_graphql8.Field)(() => Number, {
649
+ nullable: true
650
+ }),
651
+ _ts_metadata7("design:type", Number)
652
+ ], ForwardedParametersInput.prototype, "temperature", void 0);
653
+ ForwardedParametersInput = _ts_decorate7([
654
+ (0, import_type_graphql8.InputType)()
655
+ ], ForwardedParametersInput);
656
+
657
+ // src/graphql/inputs/agent-session.input.ts
658
+ var import_type_graphql9 = require("type-graphql");
659
+ function _ts_decorate8(decorators, target, key, desc) {
660
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
661
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
662
+ r = Reflect.decorate(decorators, target, key, desc);
663
+ else
664
+ for (var i = decorators.length - 1; i >= 0; i--)
665
+ if (d = decorators[i])
666
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
667
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
668
+ }
669
+ __name(_ts_decorate8, "_ts_decorate");
670
+ function _ts_metadata8(k, v) {
671
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
672
+ return Reflect.metadata(k, v);
673
+ }
674
+ __name(_ts_metadata8, "_ts_metadata");
675
+ var AgentSessionInput = class {
676
+ agentName;
677
+ threadId;
678
+ nodeName;
679
+ };
680
+ __name(AgentSessionInput, "AgentSessionInput");
681
+ _ts_decorate8([
682
+ (0, import_type_graphql9.Field)(() => String),
683
+ _ts_metadata8("design:type", String)
684
+ ], AgentSessionInput.prototype, "agentName", void 0);
685
+ _ts_decorate8([
686
+ (0, import_type_graphql9.Field)(() => String, {
687
+ nullable: true
688
+ }),
689
+ _ts_metadata8("design:type", String)
690
+ ], AgentSessionInput.prototype, "threadId", void 0);
691
+ _ts_decorate8([
692
+ (0, import_type_graphql9.Field)(() => String, {
693
+ nullable: true
694
+ }),
695
+ _ts_metadata8("design:type", String)
696
+ ], AgentSessionInput.prototype, "nodeName", void 0);
697
+ AgentSessionInput = _ts_decorate8([
698
+ (0, import_type_graphql9.InputType)()
699
+ ], AgentSessionInput);
700
+
701
+ // src/graphql/inputs/agent-state.input.ts
702
+ var import_type_graphql10 = require("type-graphql");
703
+ function _ts_decorate9(decorators, target, key, desc) {
704
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
705
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
706
+ r = Reflect.decorate(decorators, target, key, desc);
707
+ else
708
+ for (var i = decorators.length - 1; i >= 0; i--)
709
+ if (d = decorators[i])
710
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
711
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
712
+ }
713
+ __name(_ts_decorate9, "_ts_decorate");
714
+ function _ts_metadata9(k, v) {
715
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
716
+ return Reflect.metadata(k, v);
717
+ }
718
+ __name(_ts_metadata9, "_ts_metadata");
719
+ var AgentStateInput = class {
720
+ agentName;
721
+ state;
722
+ };
723
+ __name(AgentStateInput, "AgentStateInput");
724
+ _ts_decorate9([
725
+ (0, import_type_graphql10.Field)(() => String),
726
+ _ts_metadata9("design:type", String)
727
+ ], AgentStateInput.prototype, "agentName", void 0);
728
+ _ts_decorate9([
729
+ (0, import_type_graphql10.Field)(() => String),
730
+ _ts_metadata9("design:type", String)
731
+ ], AgentStateInput.prototype, "state", void 0);
732
+ AgentStateInput = _ts_decorate9([
733
+ (0, import_type_graphql10.InputType)()
734
+ ], AgentStateInput);
735
+
736
+ // src/graphql/inputs/generate-copilot-response.input.ts
737
+ function _ts_decorate10(decorators, target, key, desc) {
738
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
739
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
740
+ r = Reflect.decorate(decorators, target, key, desc);
741
+ else
742
+ for (var i = decorators.length - 1; i >= 0; i--)
743
+ if (d = decorators[i])
744
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
745
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
746
+ }
747
+ __name(_ts_decorate10, "_ts_decorate");
748
+ function _ts_metadata10(k, v) {
749
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
750
+ return Reflect.metadata(k, v);
751
+ }
752
+ __name(_ts_metadata10, "_ts_metadata");
753
+ var GenerateCopilotResponseMetadataInput = class {
754
+ requestType;
755
+ };
756
+ __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
757
+ _ts_decorate10([
758
+ (0, import_type_graphql11.Field)(() => CopilotRequestType, {
759
+ nullable: true
760
+ }),
761
+ _ts_metadata10("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
762
+ ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
763
+ GenerateCopilotResponseMetadataInput = _ts_decorate10([
764
+ (0, import_type_graphql11.InputType)()
765
+ ], GenerateCopilotResponseMetadataInput);
766
+ var GenerateCopilotResponseInput = class {
767
+ metadata;
768
+ threadId;
769
+ runId;
770
+ messages;
771
+ frontend;
772
+ cloud;
773
+ forwardedParameters;
774
+ agentSession;
775
+ agentState;
776
+ agentStates;
777
+ };
778
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
779
+ _ts_decorate10([
780
+ (0, import_type_graphql11.Field)(() => GenerateCopilotResponseMetadataInput, {
781
+ nullable: false
782
+ }),
783
+ _ts_metadata10("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
784
+ ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
785
+ _ts_decorate10([
786
+ (0, import_type_graphql11.Field)(() => String, {
787
+ nullable: true
788
+ }),
789
+ _ts_metadata10("design:type", String)
790
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
791
+ _ts_decorate10([
792
+ (0, import_type_graphql11.Field)(() => String, {
793
+ nullable: true
794
+ }),
795
+ _ts_metadata10("design:type", String)
796
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
797
+ _ts_decorate10([
798
+ (0, import_type_graphql11.Field)(() => [
799
+ MessageInput
800
+ ]),
801
+ _ts_metadata10("design:type", Array)
802
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
803
+ _ts_decorate10([
804
+ (0, import_type_graphql11.Field)(() => FrontendInput),
805
+ _ts_metadata10("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
806
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
807
+ _ts_decorate10([
808
+ (0, import_type_graphql11.Field)(() => CloudInput, {
809
+ nullable: true
810
+ }),
811
+ _ts_metadata10("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
812
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
813
+ _ts_decorate10([
814
+ (0, import_type_graphql11.Field)(() => ForwardedParametersInput, {
815
+ nullable: true
816
+ }),
817
+ _ts_metadata10("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
818
+ ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
819
+ _ts_decorate10([
820
+ (0, import_type_graphql11.Field)(() => AgentSessionInput, {
821
+ nullable: true
822
+ }),
823
+ _ts_metadata10("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
824
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
825
+ _ts_decorate10([
826
+ (0, import_type_graphql11.Field)(() => AgentStateInput, {
827
+ nullable: true
828
+ }),
829
+ _ts_metadata10("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
830
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
831
+ _ts_decorate10([
832
+ (0, import_type_graphql11.Field)(() => [
833
+ AgentStateInput
834
+ ], {
835
+ nullable: true
836
+ }),
837
+ _ts_metadata10("design:type", Array)
838
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
839
+ GenerateCopilotResponseInput = _ts_decorate10([
840
+ (0, import_type_graphql11.InputType)()
841
+ ], GenerateCopilotResponseInput);
842
+
843
+ // src/graphql/types/copilot-response.type.ts
844
+ var import_type_graphql14 = require("type-graphql");
845
+
846
+ // src/graphql/types/message-status.type.ts
847
+ var import_type_graphql12 = require("type-graphql");
848
+ function _ts_decorate11(decorators, target, key, desc) {
849
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
850
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
851
+ r = Reflect.decorate(decorators, target, key, desc);
852
+ else
853
+ for (var i = decorators.length - 1; i >= 0; i--)
854
+ if (d = decorators[i])
855
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
856
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
857
+ }
858
+ __name(_ts_decorate11, "_ts_decorate");
859
+ function _ts_metadata11(k, v) {
860
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
861
+ return Reflect.metadata(k, v);
862
+ }
863
+ __name(_ts_metadata11, "_ts_metadata");
864
+ var MessageStatusCode;
865
+ (function(MessageStatusCode2) {
866
+ MessageStatusCode2["Pending"] = "pending";
867
+ MessageStatusCode2["Success"] = "success";
868
+ MessageStatusCode2["Failed"] = "failed";
869
+ })(MessageStatusCode || (MessageStatusCode = {}));
870
+ (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
871
+ name: "MessageStatusCode"
872
+ });
873
+ var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
874
+ code;
875
+ }, "BaseMessageStatus");
876
+ _ts_decorate11([
877
+ (0, import_type_graphql12.Field)(() => MessageStatusCode),
878
+ _ts_metadata11("design:type", String)
879
+ ], BaseMessageStatus.prototype, "code", void 0);
880
+ BaseMessageStatus = _ts_decorate11([
881
+ (0, import_type_graphql12.ObjectType)()
882
+ ], BaseMessageStatus);
883
+ var PendingMessageStatus = class extends BaseMessageStatus {
884
+ code = "pending";
885
+ };
886
+ __name(PendingMessageStatus, "PendingMessageStatus");
887
+ PendingMessageStatus = _ts_decorate11([
888
+ (0, import_type_graphql12.ObjectType)()
889
+ ], PendingMessageStatus);
890
+ var SuccessMessageStatus = class extends BaseMessageStatus {
891
+ code = "success";
892
+ };
893
+ __name(SuccessMessageStatus, "SuccessMessageStatus");
894
+ SuccessMessageStatus = _ts_decorate11([
895
+ (0, import_type_graphql12.ObjectType)()
896
+ ], SuccessMessageStatus);
897
+ var FailedMessageStatus = class extends BaseMessageStatus {
898
+ code = "failed";
899
+ reason;
900
+ };
901
+ __name(FailedMessageStatus, "FailedMessageStatus");
902
+ _ts_decorate11([
903
+ (0, import_type_graphql12.Field)(() => String),
904
+ _ts_metadata11("design:type", String)
905
+ ], FailedMessageStatus.prototype, "reason", void 0);
906
+ FailedMessageStatus = _ts_decorate11([
907
+ (0, import_type_graphql12.ObjectType)()
908
+ ], FailedMessageStatus);
909
+ var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
910
+ name: "MessageStatus",
911
+ types: () => [
912
+ PendingMessageStatus,
913
+ SuccessMessageStatus,
914
+ FailedMessageStatus
915
+ ]
916
+ });
917
+
918
+ // src/graphql/types/response-status.type.ts
919
+ var import_graphql_scalars = require("graphql-scalars");
920
+ var import_type_graphql13 = require("type-graphql");
921
+ function _ts_decorate12(decorators, target, key, desc) {
922
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
923
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
924
+ r = Reflect.decorate(decorators, target, key, desc);
925
+ else
926
+ for (var i = decorators.length - 1; i >= 0; i--)
927
+ if (d = decorators[i])
928
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
929
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
930
+ }
931
+ __name(_ts_decorate12, "_ts_decorate");
932
+ function _ts_metadata12(k, v) {
933
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
934
+ return Reflect.metadata(k, v);
935
+ }
936
+ __name(_ts_metadata12, "_ts_metadata");
937
+ var ResponseStatusCode;
938
+ (function(ResponseStatusCode2) {
939
+ ResponseStatusCode2["Pending"] = "pending";
940
+ ResponseStatusCode2["Success"] = "success";
941
+ ResponseStatusCode2["Failed"] = "failed";
942
+ })(ResponseStatusCode || (ResponseStatusCode = {}));
943
+ (0, import_type_graphql13.registerEnumType)(ResponseStatusCode, {
944
+ name: "ResponseStatusCode"
945
+ });
946
+ var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
947
+ code;
948
+ }, "BaseResponseStatus");
949
+ _ts_decorate12([
950
+ (0, import_type_graphql13.Field)(() => ResponseStatusCode),
951
+ _ts_metadata12("design:type", String)
952
+ ], BaseResponseStatus.prototype, "code", void 0);
953
+ BaseResponseStatus = _ts_decorate12([
954
+ (0, import_type_graphql13.InterfaceType)({
955
+ resolveType(value) {
956
+ if (value.code === "success") {
957
+ return SuccessResponseStatus;
958
+ } else if (value.code === "failed") {
959
+ return FailedResponseStatus;
960
+ } else if (value.code === "pending") {
961
+ return PendingResponseStatus;
962
+ }
963
+ return void 0;
964
+ }
965
+ }),
966
+ (0, import_type_graphql13.ObjectType)()
967
+ ], BaseResponseStatus);
968
+ var PendingResponseStatus = class extends BaseResponseStatus {
969
+ code = "pending";
970
+ };
971
+ __name(PendingResponseStatus, "PendingResponseStatus");
972
+ PendingResponseStatus = _ts_decorate12([
973
+ (0, import_type_graphql13.ObjectType)({
974
+ implements: BaseResponseStatus
975
+ })
976
+ ], PendingResponseStatus);
977
+ var SuccessResponseStatus = class extends BaseResponseStatus {
978
+ code = "success";
979
+ };
980
+ __name(SuccessResponseStatus, "SuccessResponseStatus");
981
+ SuccessResponseStatus = _ts_decorate12([
982
+ (0, import_type_graphql13.ObjectType)({
983
+ implements: BaseResponseStatus
984
+ })
985
+ ], SuccessResponseStatus);
986
+ var FailedResponseStatusReason;
987
+ (function(FailedResponseStatusReason2) {
988
+ FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
989
+ FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
990
+ FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
991
+ })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
992
+ (0, import_type_graphql13.registerEnumType)(FailedResponseStatusReason, {
993
+ name: "FailedResponseStatusReason"
994
+ });
995
+ var FailedResponseStatus = class extends BaseResponseStatus {
996
+ code = "failed";
997
+ reason;
998
+ details = null;
999
+ };
1000
+ __name(FailedResponseStatus, "FailedResponseStatus");
1001
+ _ts_decorate12([
1002
+ (0, import_type_graphql13.Field)(() => FailedResponseStatusReason),
1003
+ _ts_metadata12("design:type", String)
1004
+ ], FailedResponseStatus.prototype, "reason", void 0);
1005
+ _ts_decorate12([
1006
+ (0, import_type_graphql13.Field)(() => import_graphql_scalars.GraphQLJSON, {
1007
+ nullable: true
1008
+ }),
1009
+ _ts_metadata12("design:type", typeof Record === "undefined" ? Object : Record)
1010
+ ], FailedResponseStatus.prototype, "details", void 0);
1011
+ FailedResponseStatus = _ts_decorate12([
1012
+ (0, import_type_graphql13.ObjectType)({
1013
+ implements: BaseResponseStatus
1014
+ })
1015
+ ], FailedResponseStatus);
1016
+ var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
1017
+ name: "ResponseStatus",
1018
+ types: () => [
1019
+ PendingResponseStatus,
1020
+ SuccessResponseStatus,
1021
+ FailedResponseStatus
1022
+ ]
1023
+ });
1024
+
1025
+ // src/graphql/types/copilot-response.type.ts
1026
+ function _ts_decorate13(decorators, target, key, desc) {
1027
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1028
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1029
+ r = Reflect.decorate(decorators, target, key, desc);
1030
+ else
1031
+ for (var i = decorators.length - 1; i >= 0; i--)
1032
+ if (d = decorators[i])
1033
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1034
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1035
+ }
1036
+ __name(_ts_decorate13, "_ts_decorate");
1037
+ function _ts_metadata13(k, v) {
1038
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1039
+ return Reflect.metadata(k, v);
1040
+ }
1041
+ __name(_ts_metadata13, "_ts_metadata");
1042
+ var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
1043
+ id;
1044
+ createdAt;
1045
+ status;
1046
+ }, "BaseMessageOutput");
1047
+ _ts_decorate13([
1048
+ (0, import_type_graphql14.Field)(() => String),
1049
+ _ts_metadata13("design:type", String)
1050
+ ], BaseMessageOutput.prototype, "id", void 0);
1051
+ _ts_decorate13([
1052
+ (0, import_type_graphql14.Field)(() => Date),
1053
+ _ts_metadata13("design:type", typeof Date === "undefined" ? Object : Date)
1054
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
1055
+ _ts_decorate13([
1056
+ (0, import_type_graphql14.Field)(() => MessageStatusUnion),
1057
+ _ts_metadata13("design:type", Object)
1058
+ ], BaseMessageOutput.prototype, "status", void 0);
1059
+ BaseMessageOutput = _ts_decorate13([
1060
+ (0, import_type_graphql14.InterfaceType)({
1061
+ resolveType(value) {
1062
+ if (value.hasOwnProperty("content")) {
1063
+ return TextMessageOutput;
1064
+ } else if (value.hasOwnProperty("name")) {
1065
+ return ActionExecutionMessageOutput;
1066
+ } else if (value.hasOwnProperty("result")) {
1067
+ return ResultMessageOutput;
1068
+ } else if (value.hasOwnProperty("state")) {
1069
+ return AgentStateMessageOutput;
1070
+ }
1071
+ return void 0;
1072
+ }
1073
+ })
1074
+ ], BaseMessageOutput);
1075
+ var TextMessageOutput = class {
1076
+ role;
1077
+ content;
1078
+ parentMessageId;
1079
+ };
1080
+ __name(TextMessageOutput, "TextMessageOutput");
1081
+ _ts_decorate13([
1082
+ (0, import_type_graphql14.Field)(() => MessageRole),
1083
+ _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1084
+ ], TextMessageOutput.prototype, "role", void 0);
1085
+ _ts_decorate13([
1086
+ (0, import_type_graphql14.Field)(() => [
1087
+ String
1088
+ ]),
1089
+ _ts_metadata13("design:type", Array)
1090
+ ], TextMessageOutput.prototype, "content", void 0);
1091
+ _ts_decorate13([
1092
+ (0, import_type_graphql14.Field)(() => String, {
1093
+ nullable: true
1094
+ }),
1095
+ _ts_metadata13("design:type", String)
1096
+ ], TextMessageOutput.prototype, "parentMessageId", void 0);
1097
+ TextMessageOutput = _ts_decorate13([
1098
+ (0, import_type_graphql14.ObjectType)({
1099
+ implements: BaseMessageOutput
1100
+ })
1101
+ ], TextMessageOutput);
1102
+ var ActionExecutionMessageOutput = class {
1103
+ name;
1104
+ scope;
1105
+ arguments;
1106
+ parentMessageId;
1107
+ };
1108
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
1109
+ _ts_decorate13([
1110
+ (0, import_type_graphql14.Field)(() => String),
1111
+ _ts_metadata13("design:type", String)
1112
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
1113
+ _ts_decorate13([
1114
+ (0, import_type_graphql14.Field)(() => String, {
1115
+ nullable: true,
1116
+ deprecationReason: "This field will be removed in a future version"
1117
+ }),
1118
+ _ts_metadata13("design:type", String)
1119
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
1120
+ _ts_decorate13([
1121
+ (0, import_type_graphql14.Field)(() => [
1122
+ String
1123
+ ]),
1124
+ _ts_metadata13("design:type", Array)
1125
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
1126
+ _ts_decorate13([
1127
+ (0, import_type_graphql14.Field)(() => String, {
1128
+ nullable: true
1129
+ }),
1130
+ _ts_metadata13("design:type", String)
1131
+ ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
1132
+ ActionExecutionMessageOutput = _ts_decorate13([
1133
+ (0, import_type_graphql14.ObjectType)({
1134
+ implements: BaseMessageOutput
1135
+ })
1136
+ ], ActionExecutionMessageOutput);
1137
+ var ResultMessageOutput = class {
1138
+ actionExecutionId;
1139
+ actionName;
1140
+ result;
1141
+ };
1142
+ __name(ResultMessageOutput, "ResultMessageOutput");
1143
+ _ts_decorate13([
1144
+ (0, import_type_graphql14.Field)(() => String),
1145
+ _ts_metadata13("design:type", String)
1146
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
1147
+ _ts_decorate13([
1148
+ (0, import_type_graphql14.Field)(() => String),
1149
+ _ts_metadata13("design:type", String)
1150
+ ], ResultMessageOutput.prototype, "actionName", void 0);
1151
+ _ts_decorate13([
1152
+ (0, import_type_graphql14.Field)(() => String),
1153
+ _ts_metadata13("design:type", String)
1154
+ ], ResultMessageOutput.prototype, "result", void 0);
1155
+ ResultMessageOutput = _ts_decorate13([
1156
+ (0, import_type_graphql14.ObjectType)({
1157
+ implements: BaseMessageOutput
1158
+ })
1159
+ ], ResultMessageOutput);
1160
+ var AgentStateMessageOutput = class {
1161
+ threadId;
1162
+ agentName;
1163
+ nodeName;
1164
+ runId;
1165
+ active;
1166
+ role;
1167
+ state;
1168
+ running;
1169
+ };
1170
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
1171
+ _ts_decorate13([
1172
+ (0, import_type_graphql14.Field)(() => String),
1173
+ _ts_metadata13("design:type", String)
1174
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
1175
+ _ts_decorate13([
1176
+ (0, import_type_graphql14.Field)(() => String),
1177
+ _ts_metadata13("design:type", String)
1178
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
1179
+ _ts_decorate13([
1180
+ (0, import_type_graphql14.Field)(() => String),
1181
+ _ts_metadata13("design:type", String)
1182
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
1183
+ _ts_decorate13([
1184
+ (0, import_type_graphql14.Field)(() => String),
1185
+ _ts_metadata13("design:type", String)
1186
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
1187
+ _ts_decorate13([
1188
+ (0, import_type_graphql14.Field)(() => Boolean),
1189
+ _ts_metadata13("design:type", Boolean)
1190
+ ], AgentStateMessageOutput.prototype, "active", void 0);
1191
+ _ts_decorate13([
1192
+ (0, import_type_graphql14.Field)(() => MessageRole),
1193
+ _ts_metadata13("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1194
+ ], AgentStateMessageOutput.prototype, "role", void 0);
1195
+ _ts_decorate13([
1196
+ (0, import_type_graphql14.Field)(() => String),
1197
+ _ts_metadata13("design:type", String)
1198
+ ], AgentStateMessageOutput.prototype, "state", void 0);
1199
+ _ts_decorate13([
1200
+ (0, import_type_graphql14.Field)(() => Boolean),
1201
+ _ts_metadata13("design:type", Boolean)
1202
+ ], AgentStateMessageOutput.prototype, "running", void 0);
1203
+ AgentStateMessageOutput = _ts_decorate13([
1204
+ (0, import_type_graphql14.ObjectType)({
1205
+ implements: BaseMessageOutput
1206
+ })
1207
+ ], AgentStateMessageOutput);
1208
+ var CopilotResponse = class {
1209
+ threadId;
1210
+ status;
1211
+ runId;
1212
+ messages;
1213
+ };
1214
+ __name(CopilotResponse, "CopilotResponse");
1215
+ _ts_decorate13([
1216
+ (0, import_type_graphql14.Field)(() => String),
1217
+ _ts_metadata13("design:type", String)
1218
+ ], CopilotResponse.prototype, "threadId", void 0);
1219
+ _ts_decorate13([
1220
+ (0, import_type_graphql14.Field)(() => ResponseStatusUnion),
1221
+ _ts_metadata13("design:type", Object)
1222
+ ], CopilotResponse.prototype, "status", void 0);
1223
+ _ts_decorate13([
1224
+ (0, import_type_graphql14.Field)({
1225
+ nullable: true
1226
+ }),
1227
+ _ts_metadata13("design:type", String)
1228
+ ], CopilotResponse.prototype, "runId", void 0);
1229
+ _ts_decorate13([
1230
+ (0, import_type_graphql14.Field)(() => [
1231
+ BaseMessageOutput
1232
+ ]),
1233
+ _ts_metadata13("design:type", Array)
1234
+ ], CopilotResponse.prototype, "messages", void 0);
1235
+ CopilotResponse = _ts_decorate13([
1236
+ (0, import_type_graphql14.ObjectType)()
1237
+ ], CopilotResponse);
1238
+
1239
+ // src/graphql/resolvers/copilot.resolver.ts
1240
+ var import_graphql_yoga = require("graphql-yoga");
1241
+
1242
+ // src/service-adapters/events.ts
1243
+ var import_shared3 = require("@copilotkit/shared");
1244
+ var import_rxjs2 = require("rxjs");
1245
+
1246
+ // src/lib/telemetry-client.ts
1247
+ var import_shared2 = require("@copilotkit/shared");
1248
+
1249
+ // src/lib/runtime/remote-actions.ts
1250
+ var EndpointType;
1251
+ (function(EndpointType2) {
1252
+ EndpointType2["CopilotKit"] = "copilotKit";
1253
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1254
+ })(EndpointType || (EndpointType = {}));
1255
+
1256
+ // src/lib/telemetry-client.ts
1257
+ var import_node_crypto = require("crypto");
1258
+
1259
+ // src/lib/runtime/copilot-runtime.ts
1260
+ var import_shared = require("@copilotkit/shared");
1261
+
1262
+ // src/graphql/types/converted/index.ts
1263
+ var Message = class extends BaseMessageInput {
1264
+ type;
1265
+ isTextMessage() {
1266
+ return this.type === "TextMessage";
1267
+ }
1268
+ isActionExecutionMessage() {
1269
+ return this.type === "ActionExecutionMessage";
1270
+ }
1271
+ isResultMessage() {
1272
+ return this.type === "ResultMessage";
1273
+ }
1274
+ isAgentStateMessage() {
1275
+ return this.type === "AgentStateMessage";
1276
+ }
1277
+ };
1278
+ __name(Message, "Message");
1279
+ var TextMessage = class extends Message {
1280
+ type = "TextMessage";
1281
+ content;
1282
+ role;
1283
+ parentMessageId;
1284
+ };
1285
+ __name(TextMessage, "TextMessage");
1286
+ var ActionExecutionMessage = class extends Message {
1287
+ type = "ActionExecutionMessage";
1288
+ name;
1289
+ arguments;
1290
+ parentMessageId;
1291
+ };
1292
+ __name(ActionExecutionMessage, "ActionExecutionMessage");
1293
+ var ResultMessage = class extends Message {
1294
+ type = "ResultMessage";
1295
+ actionExecutionId;
1296
+ actionName;
1297
+ result;
1298
+ };
1299
+ __name(ResultMessage, "ResultMessage");
1300
+ var AgentStateMessage = class extends Message {
1301
+ type = "AgentStateMessage";
1302
+ threadId;
1303
+ agentName;
1304
+ nodeName;
1305
+ runId;
1306
+ active;
1307
+ role;
1308
+ state;
1309
+ running;
1310
+ };
1311
+ __name(AgentStateMessage, "AgentStateMessage");
1312
+
1313
+ // src/lib/runtime/copilot-runtime.ts
1314
+ var import_rxjs = require("rxjs");
1315
+ function resolveEndpointType(endpoint) {
1316
+ if (!endpoint.type) {
1317
+ if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
1318
+ return EndpointType.LangGraphPlatform;
1319
+ } else {
1320
+ return EndpointType.CopilotKit;
1321
+ }
1322
+ }
1323
+ return endpoint.type;
1324
+ }
1325
+ __name(resolveEndpointType, "resolveEndpointType");
1326
+
1327
+ // src/lib/telemetry-client.ts
1328
+ var packageJson = require_package();
1329
+ var telemetryClient = new import_shared2.TelemetryClient({
1330
+ packageName: packageJson.name,
1331
+ packageVersion: packageJson.version
1332
+ });
1333
+ function getRuntimeInstanceTelemetryInfo(runtime) {
1334
+ const endpointsInfo = runtime.remoteEndpointDefinitions.reduce((acc, endpoint) => {
1335
+ let info = {
1336
+ ...acc
1337
+ };
1338
+ const endpointType = resolveEndpointType(endpoint);
1339
+ if (!info.endpointTypes.includes(endpointType)) {
1340
+ info = {
1341
+ ...info,
1342
+ endpointTypes: [
1343
+ ...info.endpointTypes,
1344
+ endpointType
1345
+ ]
1346
+ };
1347
+ }
1348
+ if (endpointType === EndpointType.LangGraphPlatform) {
1349
+ const ep = endpoint;
1350
+ info = {
1351
+ ...info,
1352
+ agentsAmount: ep.agents.length,
1353
+ hashedKey: (0, import_node_crypto.createHash)("sha256").update(ep.langsmithApiKey).digest("hex")
1354
+ };
1355
+ }
1356
+ return info;
1357
+ }, {
1358
+ endpointTypes: [],
1359
+ agentsAmount: null,
1360
+ hashedKey: null
1361
+ });
1362
+ return {
1363
+ actionsAmount: runtime.actions.length,
1364
+ endpointsAmount: runtime.remoteEndpointDefinitions.length,
1365
+ endpointTypes: endpointsInfo.endpointTypes,
1366
+ agentsAmount: endpointsInfo.agentsAmount,
1367
+ hashedLgcKey: endpointsInfo.hashedKey
1368
+ };
1369
+ }
1370
+ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
1371
+ var telemetry_client_default = telemetryClient;
1372
+
1373
+ // src/service-adapters/events.ts
1374
+ var import_class_transformer = require("class-transformer");
1375
+ var RuntimeEventTypes;
1376
+ (function(RuntimeEventTypes2) {
1377
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1378
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1379
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1380
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1381
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1382
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1383
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1384
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1385
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1386
+
1387
+ // src/graphql/resolvers/copilot.resolver.ts
1388
+ var import_graphql_scalars2 = require("graphql-scalars");
1389
+ var import_class_transformer2 = require("class-transformer");
1390
+ var import_graphql = require("graphql");
1391
+
1392
+ // src/utils/failed-response-status-reasons.ts
1393
+ var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
1394
+ reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
1395
+ constructor({ guardrailsReason }) {
1396
+ super();
1397
+ this.details = {
1398
+ guardrailsReason
1399
+ };
1400
+ }
1401
+ };
1402
+ __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
1403
+ var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
1404
+ reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
1405
+ constructor({ messageId }) {
1406
+ super();
1407
+ this.details = {
1408
+ messageId,
1409
+ description: "Check the message for mode details"
1410
+ };
1411
+ }
1412
+ };
1413
+ __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
1414
+ var UnknownErrorResponse = class extends FailedResponseStatus {
1415
+ reason = FailedResponseStatusReason.UNKNOWN_ERROR;
1416
+ constructor({ description }) {
1417
+ super();
1418
+ this.details = {
1419
+ description
1420
+ };
1421
+ }
1422
+ };
1423
+ __name(UnknownErrorResponse, "UnknownErrorResponse");
1424
+
1425
+ // src/graphql/resolvers/copilot.resolver.ts
1426
+ var import_shared4 = require("@copilotkit/shared");
1427
+
1428
+ // src/graphql/types/agents-response.type.ts
1429
+ var import_type_graphql15 = require("type-graphql");
1430
+ function _ts_decorate14(decorators, target, key, desc) {
1431
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1432
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1433
+ r = Reflect.decorate(decorators, target, key, desc);
1434
+ else
1435
+ for (var i = decorators.length - 1; i >= 0; i--)
1436
+ if (d = decorators[i])
1437
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1438
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1439
+ }
1440
+ __name(_ts_decorate14, "_ts_decorate");
1441
+ function _ts_metadata14(k, v) {
1442
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1443
+ return Reflect.metadata(k, v);
1444
+ }
1445
+ __name(_ts_metadata14, "_ts_metadata");
1446
+ var Agent = class {
1447
+ id;
1448
+ name;
1449
+ description;
1450
+ };
1451
+ __name(Agent, "Agent");
1452
+ _ts_decorate14([
1453
+ (0, import_type_graphql15.Field)(() => String),
1454
+ _ts_metadata14("design:type", String)
1455
+ ], Agent.prototype, "id", void 0);
1456
+ _ts_decorate14([
1457
+ (0, import_type_graphql15.Field)(() => String),
1458
+ _ts_metadata14("design:type", String)
1459
+ ], Agent.prototype, "name", void 0);
1460
+ _ts_decorate14([
1461
+ (0, import_type_graphql15.Field)(() => String),
1462
+ _ts_metadata14("design:type", String)
1463
+ ], Agent.prototype, "description", void 0);
1464
+ Agent = _ts_decorate14([
1465
+ (0, import_type_graphql15.ObjectType)()
1466
+ ], Agent);
1467
+ var AgentsResponse = class {
1468
+ agents;
1469
+ };
1470
+ __name(AgentsResponse, "AgentsResponse");
1471
+ _ts_decorate14([
1472
+ (0, import_type_graphql15.Field)(() => [
1473
+ Agent
1474
+ ]),
1475
+ _ts_metadata14("design:type", Array)
1476
+ ], AgentsResponse.prototype, "agents", void 0);
1477
+ AgentsResponse = _ts_decorate14([
1478
+ (0, import_type_graphql15.ObjectType)()
1479
+ ], AgentsResponse);
1480
+
1481
+ // src/graphql/resolvers/copilot.resolver.ts
1482
+ function _ts_decorate15(decorators, target, key, desc) {
1483
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1484
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1485
+ r = Reflect.decorate(decorators, target, key, desc);
1486
+ else
1487
+ for (var i = decorators.length - 1; i >= 0; i--)
1488
+ if (d = decorators[i])
1489
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1490
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1491
+ }
1492
+ __name(_ts_decorate15, "_ts_decorate");
1493
+ function _ts_metadata15(k, v) {
1494
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1495
+ return Reflect.metadata(k, v);
1496
+ }
1497
+ __name(_ts_metadata15, "_ts_metadata");
1498
+ function _ts_param(paramIndex, decorator) {
1499
+ return function(target, key) {
1500
+ decorator(target, key, paramIndex);
1501
+ };
1502
+ }
1503
+ __name(_ts_param, "_ts_param");
1504
+ var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
1505
+ var _a;
1506
+ if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
1507
+ const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
1508
+ role: m.textMessage.role,
1509
+ content: m.textMessage.content
1510
+ }));
1511
+ const lastMessage = messages[messages.length - 1];
1512
+ const restOfMessages = messages.slice(0, -1);
1513
+ const body = {
1514
+ input: lastMessage.content,
1515
+ validTopics: data.cloud.guardrails.inputValidationRules.allowList,
1516
+ invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
1517
+ messages: restOfMessages
1518
+ };
1519
+ const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
1520
+ method: "POST",
1521
+ headers: {
1522
+ "Content-Type": "application/json",
1523
+ "X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
1524
+ },
1525
+ body: JSON.stringify(body)
1526
+ });
1527
+ if (guardrailsResult.ok) {
1528
+ const resultJson = await guardrailsResult.json();
1529
+ onResult(resultJson);
1530
+ } else {
1531
+ onError(await guardrailsResult.json());
1532
+ }
1533
+ }
1534
+ }, "invokeGuardrails");
1535
+ var CopilotResolver = class {
1536
+ async hello() {
1537
+ return "Hello World";
1538
+ }
1539
+ async availableAgents(ctx) {
1540
+ let logger2 = ctx.logger.child({
1541
+ component: "CopilotResolver.availableAgents"
1542
+ });
1543
+ logger2.debug("Processing");
1544
+ const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
1545
+ logger2.debug("Event source created, creating response");
1546
+ return {
1547
+ agents
1548
+ };
1549
+ }
1550
+ async generateCopilotResponse(ctx, data, properties) {
1551
+ var _a, _b, _c;
1552
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
1553
+ "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
1554
+ requestType: data.metadata.requestType
1555
+ });
1556
+ let logger2 = ctx.logger.child({
1557
+ component: "CopilotResolver.generateCopilotResponse"
1558
+ });
1559
+ logger2.debug({
1560
+ data
1561
+ }, "Generating Copilot response");
1562
+ if (properties) {
1563
+ logger2.debug("Properties provided, merging with context properties");
1564
+ ctx.properties = {
1565
+ ...ctx.properties,
1566
+ ...properties
1567
+ };
1568
+ }
1569
+ const copilotRuntime = ctx._copilotkit.runtime;
1570
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
1571
+ let copilotCloudPublicApiKey = null;
1572
+ let copilotCloudBaseUrl;
1573
+ if (data.cloud) {
1574
+ logger2 = logger2.child({
1575
+ cloud: true
1576
+ });
1577
+ logger2.debug("Cloud configuration provided, checking for public API key in headers");
1578
+ const key = ctx.request.headers.get("x-copilotcloud-public-api-key");
1579
+ if (key) {
1580
+ logger2.debug("Public API key found in headers");
1581
+ copilotCloudPublicApiKey = key;
1582
+ } else {
1583
+ logger2.error("Public API key not found in headers");
1584
+ throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
1585
+ }
1586
+ if (process.env.COPILOT_CLOUD_BASE_URL) {
1587
+ copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
1588
+ } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
1589
+ copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
1590
+ } else {
1591
+ copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
1592
+ }
1593
+ logger2 = logger2.child({
1594
+ copilotCloudBaseUrl
1595
+ });
1596
+ }
1597
+ logger2.debug("Setting up subjects");
1598
+ const responseStatus$ = new import_rxjs3.ReplaySubject();
1599
+ const interruptStreaming$ = new import_rxjs3.ReplaySubject();
1600
+ const guardrailsResult$ = new import_rxjs3.ReplaySubject();
1601
+ let outputMessages = [];
1602
+ let resolveOutputMessagesPromise;
1603
+ let rejectOutputMessagesPromise;
1604
+ const outputMessagesPromise = new Promise((resolve, reject) => {
1605
+ resolveOutputMessagesPromise = resolve;
1606
+ rejectOutputMessagesPromise = reject;
1607
+ });
1608
+ logger2.debug("Processing");
1609
+ const { eventSource, threadId = (0, import_shared4.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
1610
+ serviceAdapter,
1611
+ messages: data.messages,
1612
+ actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
1613
+ threadId: data.threadId,
1614
+ runId: data.runId,
1615
+ publicApiKey: void 0,
1616
+ outputMessagesPromise,
1617
+ graphqlContext: ctx,
1618
+ forwardedParameters: data.forwardedParameters,
1619
+ agentSession: data.agentSession,
1620
+ agentStates: data.agentStates,
1621
+ url: data.frontend.url
1622
+ });
1623
+ logger2.debug("Event source created, creating response");
1624
+ const response = {
1625
+ threadId,
1626
+ runId,
1627
+ status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
1628
+ messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
1629
+ var _a2, _b2;
1630
+ logger2.debug("Messages repeater created");
1631
+ if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
1632
+ logger2 = logger2.child({
1633
+ guardrails: true
1634
+ });
1635
+ logger2.debug("Guardrails is enabled, validating input");
1636
+ invokeGuardrails({
1637
+ baseUrl: copilotCloudBaseUrl,
1638
+ copilotCloudPublicApiKey,
1639
+ data,
1640
+ onResult: (result) => {
1641
+ logger2.debug({
1642
+ status: result.status
1643
+ }, "Guardrails validation done");
1644
+ guardrailsResult$.next(result);
1645
+ if (result.status === "denied") {
1646
+ responseStatus$.next(new GuardrailsValidationFailureResponse({
1647
+ guardrailsReason: result.reason
1648
+ }));
1649
+ interruptStreaming$.next({
1650
+ reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
1651
+ });
1652
+ outputMessages = [
1653
+ (0, import_class_transformer2.plainToInstance)(TextMessage, {
1654
+ id: (0, import_shared4.randomId)(),
1655
+ createdAt: /* @__PURE__ */ new Date(),
1656
+ content: result.reason,
1657
+ role: MessageRole.assistant
1658
+ })
1659
+ ];
1660
+ resolveOutputMessagesPromise(outputMessages);
1661
+ }
1662
+ },
1663
+ onError: (err) => {
1664
+ logger2.error({
1665
+ err
1666
+ }, "Error in guardrails validation");
1667
+ responseStatus$.next(new UnknownErrorResponse({
1668
+ description: `An unknown error has occurred in the guardrails validation`
1669
+ }));
1670
+ interruptStreaming$.next({
1671
+ reason: `Interrupted due to unknown error in guardrails validation`
1672
+ });
1673
+ rejectOutputMessagesPromise(err);
1674
+ }
1675
+ });
1676
+ }
1677
+ let eventStreamSubscription;
1678
+ const eventStream = eventSource.processRuntimeEvents({
1679
+ serverSideActions,
1680
+ guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null,
1681
+ actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
1682
+ // TODO-AGENTS: do not exclude ALL server side actions
1683
+ (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
1684
+ )
1685
+ }).pipe(
1686
+ // shareReplay() ensures that later subscribers will see the whole stream instead of
1687
+ // just the events that were emitted after the subscriber was added.
1688
+ (0, import_rxjs3.shareReplay)(),
1689
+ (0, import_rxjs3.finalize)(() => {
1690
+ logger2.debug("Event stream finalized");
1691
+ })
1692
+ );
1693
+ logger2.debug("Event stream created, subscribing to event stream");
1694
+ eventStreamSubscription = eventStream.subscribe({
1695
+ next: async (event) => {
1696
+ switch (event.type) {
1697
+ case RuntimeEventTypes.TextMessageStart:
1698
+ const textMessageContentStream = eventStream.pipe(
1699
+ // skip until this message start event
1700
+ (0, import_rxjs3.skipWhile)((e) => e !== event),
1701
+ // take until the message end event
1702
+ (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
1703
+ // filter out any other message events or message ids
1704
+ (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
1705
+ );
1706
+ const streamingTextStatus = new import_rxjs3.Subject();
1707
+ const messageId = event.messageId;
1708
+ pushMessage({
1709
+ id: messageId,
1710
+ parentMessageId: event.parentMessageId,
1711
+ status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
1712
+ createdAt: /* @__PURE__ */ new Date(),
1713
+ role: MessageRole.assistant,
1714
+ content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
1715
+ logger2.debug("Text message content repeater created");
1716
+ const textChunks = [];
1717
+ let textSubscription;
1718
+ interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
1719
+ logger2.debug({
1720
+ reason,
1721
+ messageId: messageId2
1722
+ }, "Text streaming interrupted");
1723
+ streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
1724
+ reason
1725
+ }));
1726
+ responseStatus$.next(new MessageStreamInterruptedResponse({
1727
+ messageId: messageId2
1728
+ }));
1729
+ stopStreamingText();
1730
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
1731
+ })).subscribe();
1732
+ logger2.debug("Subscribing to text message content stream");
1733
+ textSubscription = textMessageContentStream.subscribe({
1734
+ next: async (e) => {
1735
+ if (e.type == RuntimeEventTypes.TextMessageContent) {
1736
+ await pushTextChunk(e.content);
1737
+ textChunks.push(e.content);
1738
+ }
1739
+ },
1740
+ error: (err) => {
1741
+ logger2.error({
1742
+ err
1743
+ }, "Error in text message content stream");
1744
+ interruptStreaming$.next({
1745
+ reason: "Error streaming message content",
1746
+ messageId
1747
+ });
1748
+ stopStreamingText();
1749
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
1750
+ },
1751
+ complete: () => {
1752
+ logger2.debug("Text message content stream completed");
1753
+ streamingTextStatus.next(new SuccessMessageStatus());
1754
+ stopStreamingText();
1755
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
1756
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
1757
+ id: messageId,
1758
+ createdAt: /* @__PURE__ */ new Date(),
1759
+ content: textChunks.join(""),
1760
+ role: MessageRole.assistant
1761
+ }));
1762
+ }
1763
+ });
1764
+ })
1765
+ });
1766
+ break;
1767
+ case RuntimeEventTypes.ActionExecutionStart:
1768
+ logger2.debug("Action execution start event received");
1769
+ const actionExecutionArgumentStream = eventStream.pipe(
1770
+ (0, import_rxjs3.skipWhile)((e) => e !== event),
1771
+ // take until the action execution end event
1772
+ (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
1773
+ // filter out any other action execution events or action execution ids
1774
+ (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
1775
+ );
1776
+ const streamingArgumentsStatus = new import_rxjs3.Subject();
1777
+ pushMessage({
1778
+ id: event.actionExecutionId,
1779
+ parentMessageId: event.parentMessageId,
1780
+ status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
1781
+ createdAt: /* @__PURE__ */ new Date(),
1782
+ name: event.actionName,
1783
+ arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
1784
+ logger2.debug("Action execution argument stream created");
1785
+ const argumentChunks = [];
1786
+ let actionExecutionArgumentSubscription;
1787
+ actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
1788
+ next: async (e) => {
1789
+ if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
1790
+ await pushArgumentsChunk(e.args);
1791
+ argumentChunks.push(e.args);
1792
+ }
1793
+ },
1794
+ error: (err) => {
1795
+ logger2.error({
1796
+ err
1797
+ }, "Error in action execution argument stream");
1798
+ streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
1799
+ reason: "An unknown error has occurred in the action execution argument stream"
1800
+ }));
1801
+ stopStreamingArguments();
1802
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
1803
+ },
1804
+ complete: () => {
1805
+ logger2.debug("Action execution argument stream completed");
1806
+ streamingArgumentsStatus.next(new SuccessMessageStatus());
1807
+ stopStreamingArguments();
1808
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
1809
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
1810
+ id: event.actionExecutionId,
1811
+ createdAt: /* @__PURE__ */ new Date(),
1812
+ name: event.actionName,
1813
+ arguments: argumentChunks.join("")
1814
+ }));
1815
+ }
1816
+ });
1817
+ })
1818
+ });
1819
+ break;
1820
+ case RuntimeEventTypes.ActionExecutionResult:
1821
+ logger2.debug({
1822
+ result: event.result
1823
+ }, "Action execution result event received");
1824
+ pushMessage({
1825
+ id: "result-" + event.actionExecutionId,
1826
+ status: new SuccessMessageStatus(),
1827
+ createdAt: /* @__PURE__ */ new Date(),
1828
+ actionExecutionId: event.actionExecutionId,
1829
+ actionName: event.actionName,
1830
+ result: event.result
1831
+ });
1832
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
1833
+ id: "result-" + event.actionExecutionId,
1834
+ createdAt: /* @__PURE__ */ new Date(),
1835
+ actionExecutionId: event.actionExecutionId,
1836
+ actionName: event.actionName,
1837
+ result: event.result
1838
+ }));
1839
+ break;
1840
+ case RuntimeEventTypes.AgentStateMessage:
1841
+ logger2.debug({
1842
+ event
1843
+ }, "Agent message event received");
1844
+ pushMessage({
1845
+ id: (0, import_shared4.randomId)(),
1846
+ status: new SuccessMessageStatus(),
1847
+ threadId: event.threadId,
1848
+ agentName: event.agentName,
1849
+ nodeName: event.nodeName,
1850
+ runId: event.runId,
1851
+ active: event.active,
1852
+ state: event.state,
1853
+ running: event.running,
1854
+ role: MessageRole.assistant,
1855
+ createdAt: /* @__PURE__ */ new Date()
1856
+ });
1857
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
1858
+ id: (0, import_shared4.randomId)(),
1859
+ threadId: event.threadId,
1860
+ agentName: event.agentName,
1861
+ nodeName: event.nodeName,
1862
+ runId: event.runId,
1863
+ active: event.active,
1864
+ state: event.state,
1865
+ running: event.running,
1866
+ role: MessageRole.assistant,
1867
+ createdAt: /* @__PURE__ */ new Date()
1868
+ }));
1869
+ break;
1870
+ }
1871
+ },
1872
+ error: (err) => {
1873
+ logger2.error({
1874
+ err
1875
+ }, "Error in event stream");
1876
+ responseStatus$.next(new UnknownErrorResponse({
1877
+ description: `An unknown error has occurred in the event stream`
1878
+ }));
1879
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
1880
+ stopStreamingMessages();
1881
+ rejectOutputMessagesPromise(err);
1882
+ },
1883
+ complete: async () => {
1884
+ var _a3;
1885
+ logger2.debug("Event stream completed");
1886
+ if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
1887
+ logger2.debug("Guardrails is enabled, waiting for guardrails result");
1888
+ await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
1889
+ }
1890
+ responseStatus$.next(new SuccessResponseStatus());
1891
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
1892
+ stopStreamingMessages();
1893
+ resolveOutputMessagesPromise(outputMessages);
1894
+ }
1895
+ });
1896
+ })
1897
+ };
1898
+ return response;
1899
+ }
1900
+ };
1901
+ __name(CopilotResolver, "CopilotResolver");
1902
+ _ts_decorate15([
1903
+ (0, import_type_graphql16.Query)(() => String),
1904
+ _ts_metadata15("design:type", Function),
1905
+ _ts_metadata15("design:paramtypes", []),
1906
+ _ts_metadata15("design:returntype", Promise)
1907
+ ], CopilotResolver.prototype, "hello", null);
1908
+ _ts_decorate15([
1909
+ (0, import_type_graphql16.Query)(() => AgentsResponse),
1910
+ _ts_param(0, (0, import_type_graphql16.Ctx)()),
1911
+ _ts_metadata15("design:type", Function),
1912
+ _ts_metadata15("design:paramtypes", [
1913
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext
1914
+ ]),
1915
+ _ts_metadata15("design:returntype", Promise)
1916
+ ], CopilotResolver.prototype, "availableAgents", null);
1917
+ _ts_decorate15([
1918
+ (0, import_type_graphql16.Mutation)(() => CopilotResponse),
1919
+ _ts_param(0, (0, import_type_graphql16.Ctx)()),
1920
+ _ts_param(1, (0, import_type_graphql16.Arg)("data")),
1921
+ _ts_param(2, (0, import_type_graphql16.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
1922
+ nullable: true
1923
+ })),
1924
+ _ts_metadata15("design:type", Function),
1925
+ _ts_metadata15("design:paramtypes", [
1926
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
1927
+ typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
1928
+ typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
1929
+ ]),
1930
+ _ts_metadata15("design:returntype", Promise)
1931
+ ], CopilotResolver.prototype, "generateCopilotResponse", null);
1932
+ CopilotResolver = _ts_decorate15([
1933
+ (0, import_type_graphql16.Resolver)(() => CopilotResponse)
1934
+ ], CopilotResolver);
1935
+
1936
+ // src/lib/integrations/shared.ts
1937
+ var import_plugin_defer_stream = require("@graphql-yoga/plugin-defer-stream");
1938
+
1939
+ // src/lib/logger.ts
1940
+ var import_pino = __toESM(require("pino"));
1941
+ var import_pino_pretty = __toESM(require("pino-pretty"));
1942
+ function createLogger(options) {
1943
+ const { level, component } = options || {};
1944
+ const stream = (0, import_pino_pretty.default)({
1945
+ colorize: true
1946
+ });
1947
+ const logger2 = (0, import_pino.default)({
1948
+ level: process.env.LOG_LEVEL || level || "error",
1949
+ redact: {
1950
+ paths: [
1951
+ "pid",
1952
+ "hostname"
1953
+ ],
1954
+ remove: true
1955
+ }
1956
+ }, stream);
1957
+ if (component) {
1958
+ return logger2.child({
1959
+ component
1960
+ });
1961
+ } else {
1962
+ return logger2;
1963
+ }
1964
+ }
1965
+ __name(createLogger, "createLogger");
1966
+
1967
+ // src/lib/integrations/shared.ts
1968
+ var logger = createLogger();
1969
+ async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
1970
+ logger.debug({
1971
+ copilotKitContext
1972
+ }, "Creating GraphQL context");
1973
+ const ctx = {
1974
+ ...initialContext,
1975
+ _copilotkit: {
1976
+ ...copilotKitContext
1977
+ },
1978
+ properties: {
1979
+ ...properties
1980
+ },
1981
+ logger: contextLogger
1982
+ };
1983
+ return ctx;
1984
+ }
1985
+ __name(createContext, "createContext");
1986
+ function buildSchema(options = {}) {
1987
+ logger.debug("Building GraphQL schema...");
1988
+ const schema = (0, import_type_graphql17.buildSchemaSync)({
1989
+ resolvers: [
1990
+ CopilotResolver
1991
+ ],
1992
+ emitSchemaFile: options.emitSchemaFile
1993
+ });
1994
+ logger.debug("GraphQL schema built successfully");
1995
+ return schema;
1996
+ }
1997
+ __name(buildSchema, "buildSchema");
1998
+ function getCommonConfig(options) {
1999
+ var _a;
2000
+ const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
2001
+ const logger2 = createLogger({
2002
+ level: logLevel,
2003
+ component: "getCommonConfig"
2004
+ });
2005
+ const contextLogger = createLogger({
2006
+ level: logLevel
2007
+ });
2008
+ if (options.cloud) {
2009
+ telemetry_client_default.setCloudConfiguration({
2010
+ publicApiKey: options.cloud.publicApiKey,
2011
+ baseUrl: options.cloud.baseUrl
2012
+ });
2013
+ }
2014
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2015
+ telemetry_client_default.setGlobalProperties({
2016
+ _copilotkit: {
2017
+ ...options.properties._copilotkit
2018
+ }
2019
+ });
2020
+ }
2021
+ telemetry_client_default.setGlobalProperties({
2022
+ runtime: {
2023
+ serviceAdapter: options.serviceAdapter.constructor.name
2024
+ }
2025
+ });
2026
+ return {
2027
+ logging: createLogger({
2028
+ component: "Yoga GraphQL",
2029
+ level: logLevel
2030
+ }),
2031
+ schema: buildSchema(),
2032
+ plugins: [
2033
+ (0, import_plugin_defer_stream.useDeferStream)()
2034
+ ],
2035
+ context: (ctx) => createContext(ctx, options, contextLogger, options.properties)
2036
+ };
2037
+ }
2038
+ __name(getCommonConfig, "getCommonConfig");
2039
+
2040
+ // src/lib/integrations/nextjs/app-router.ts
2041
+ var import_graphql_yoga2 = require("graphql-yoga");
2042
+ function copilotRuntimeNextJSAppRouterEndpoint(options) {
2043
+ var _a;
2044
+ const commonConfig = getCommonConfig(options);
2045
+ telemetry_client_default.setGlobalProperties({
2046
+ runtime: {
2047
+ framework: "nextjs-app-router"
2048
+ }
2049
+ });
2050
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2051
+ telemetry_client_default.setGlobalProperties({
2052
+ _copilotkit: options.properties._copilotkit
2053
+ });
2054
+ }
2055
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
2056
+ const logger2 = commonConfig.logging;
2057
+ logger2.debug("Creating NextJS App Router endpoint");
2058
+ const yoga = (0, import_graphql_yoga2.createYoga)({
2059
+ ...commonConfig,
2060
+ graphqlEndpoint: options.endpoint,
2061
+ fetchAPI: {
2062
+ Response: globalThis.Response
2063
+ }
2064
+ });
2065
+ return {
2066
+ handleRequest: yoga,
2067
+ GET: yoga,
2068
+ POST: yoga,
2069
+ OPTIONS: yoga
2070
+ };
2071
+ }
2072
+ __name(copilotRuntimeNextJSAppRouterEndpoint, "copilotRuntimeNextJSAppRouterEndpoint");
2073
+
2074
+ // src/lib/integrations/nextjs/pages-router.ts
2075
+ var import_graphql_yoga3 = require("graphql-yoga");
2076
+ var config = {
2077
+ api: {
2078
+ bodyParser: false
2079
+ }
2080
+ };
2081
+ function copilotRuntimeNextJSPagesRouterEndpoint(options) {
2082
+ var _a;
2083
+ const commonConfig = getCommonConfig(options);
2084
+ telemetry_client_default.setGlobalProperties({
2085
+ runtime: {
2086
+ framework: "nextjs-pages-router"
2087
+ }
2088
+ });
2089
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2090
+ telemetry_client_default.setGlobalProperties({
2091
+ _copilotkit: options.properties._copilotkit
2092
+ });
2093
+ }
2094
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
2095
+ const logger2 = commonConfig.logging;
2096
+ logger2.debug("Creating NextJS Pages Router endpoint");
2097
+ const yoga = (0, import_graphql_yoga3.createYoga)({
2098
+ ...commonConfig,
2099
+ graphqlEndpoint: options.endpoint
2100
+ });
2101
+ return yoga;
2102
+ }
2103
+ __name(copilotRuntimeNextJSPagesRouterEndpoint, "copilotRuntimeNextJSPagesRouterEndpoint");
2104
+
2105
+ // src/lib/integrations/node-http/index.ts
2106
+ var import_graphql_yoga4 = require("graphql-yoga");
2107
+ function copilotRuntimeNodeHttpEndpoint(options) {
2108
+ var _a;
2109
+ const commonConfig = getCommonConfig(options);
2110
+ telemetry_client_default.setGlobalProperties({
2111
+ runtime: {
2112
+ framework: "node-http"
2113
+ }
2114
+ });
2115
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2116
+ telemetry_client_default.setGlobalProperties({
2117
+ _copilotkit: options.properties._copilotkit
2118
+ });
2119
+ }
2120
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
2121
+ const logger2 = commonConfig.logging;
2122
+ logger2.debug("Creating Node HTTP endpoint");
2123
+ const yoga = (0, import_graphql_yoga4.createYoga)({
2124
+ ...commonConfig,
2125
+ graphqlEndpoint: options.endpoint
2126
+ });
2127
+ return yoga;
2128
+ }
2129
+ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
2130
+
2131
+ // src/lib/integrations/node-express/index.ts
2132
+ function copilotRuntimeNodeExpressEndpoint(options) {
2133
+ telemetry_client_default.setGlobalProperties({
2134
+ runtime: {
2135
+ framework: "node-express"
2136
+ }
2137
+ });
2138
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
2139
+ return copilotRuntimeNodeHttpEndpoint(options);
2140
+ }
2141
+ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
2142
+
2143
+ // src/lib/integrations/nest/index.ts
2144
+ function copilotRuntimeNestEndpoint(options) {
2145
+ telemetry_client_default.setGlobalProperties({
2146
+ runtime: {
2147
+ framework: "nest"
2148
+ }
2149
+ });
2150
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
2151
+ return copilotRuntimeNodeHttpEndpoint(options);
2152
+ }
2153
+ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
2154
+ // Annotate the CommonJS export names for ESM import in node:
2155
+ 0 && (module.exports = {
2156
+ buildSchema,
2157
+ config,
2158
+ copilotRuntimeNestEndpoint,
2159
+ copilotRuntimeNextJSAppRouterEndpoint,
2160
+ copilotRuntimeNextJSPagesRouterEndpoint,
2161
+ copilotRuntimeNodeExpressEndpoint,
2162
+ copilotRuntimeNodeHttpEndpoint,
2163
+ createContext,
2164
+ getCommonConfig
2165
+ });
2166
+ //# sourceMappingURL=index.js.map