@copilotkit/runtime 1.5.1-next.3 → 1.5.1-next.4

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