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