@copilotkit/runtime 1.5.1-test-custom-tag-prerelease-1.0 → 1.5.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +56 -4
  2. package/package.json +2 -2
  3. package/src/graphql/resolvers/copilot.resolver.ts +16 -0
  4. package/src/graphql/types/agents-response.type.ts +22 -0
  5. package/src/lib/runtime/copilot-runtime.ts +50 -0
  6. package/__snapshots__/schema/schema.graphql +0 -262
  7. package/dist/chunk-44O2JGUY.mjs +0 -12
  8. package/dist/chunk-44O2JGUY.mjs.map +0 -1
  9. package/dist/chunk-CLGKEUOA.mjs +0 -1408
  10. package/dist/chunk-CLGKEUOA.mjs.map +0 -1
  11. package/dist/chunk-D2WLFQS6.mjs +0 -43
  12. package/dist/chunk-D2WLFQS6.mjs.map +0 -1
  13. package/dist/chunk-DFOKBSIS.mjs +0 -1
  14. package/dist/chunk-DFOKBSIS.mjs.map +0 -1
  15. package/dist/chunk-F4RA4OOZ.mjs +0 -80
  16. package/dist/chunk-F4RA4OOZ.mjs.map +0 -1
  17. package/dist/chunk-L3RX2YCQ.mjs +0 -25
  18. package/dist/chunk-L3RX2YCQ.mjs.map +0 -1
  19. package/dist/chunk-RFF5IIZJ.mjs +0 -66
  20. package/dist/chunk-RFF5IIZJ.mjs.map +0 -1
  21. package/dist/chunk-U3V2BCGI.mjs +0 -152
  22. package/dist/chunk-U3V2BCGI.mjs.map +0 -1
  23. package/dist/chunk-YEAV6DRC.mjs +0 -3281
  24. package/dist/chunk-YEAV6DRC.mjs.map +0 -1
  25. package/dist/chunk-YOQGCPIU.mjs +0 -25
  26. package/dist/chunk-YOQGCPIU.mjs.map +0 -1
  27. package/dist/copilot-runtime-6285d897.d.ts +0 -189
  28. package/dist/graphql/types/base/index.d.ts +0 -6
  29. package/dist/graphql/types/base/index.js +0 -63
  30. package/dist/graphql/types/base/index.js.map +0 -1
  31. package/dist/graphql/types/base/index.mjs +0 -8
  32. package/dist/graphql/types/base/index.mjs.map +0 -1
  33. package/dist/graphql/types/converted/index.d.ts +0 -2
  34. package/dist/graphql/types/converted/index.js +0 -124
  35. package/dist/graphql/types/converted/index.js.map +0 -1
  36. package/dist/graphql/types/converted/index.mjs +0 -17
  37. package/dist/graphql/types/converted/index.mjs.map +0 -1
  38. package/dist/groq-adapter-15d41154.d.ts +0 -281
  39. package/dist/index-ff3fbc33.d.ts +0 -87
  40. package/dist/index.d.ts +0 -23
  41. package/dist/index.js +0 -5039
  42. package/dist/index.js.map +0 -1
  43. package/dist/index.mjs +0 -76
  44. package/dist/index.mjs.map +0 -1
  45. package/dist/langserve-48e976ac.d.ts +0 -176
  46. package/dist/lib/cloud/index.d.ts +0 -6
  47. package/dist/lib/cloud/index.js +0 -18
  48. package/dist/lib/cloud/index.js.map +0 -1
  49. package/dist/lib/cloud/index.mjs +0 -1
  50. package/dist/lib/cloud/index.mjs.map +0 -1
  51. package/dist/lib/index.d.ts +0 -20
  52. package/dist/lib/index.js +0 -4687
  53. package/dist/lib/index.js.map +0 -1
  54. package/dist/lib/index.mjs +0 -58
  55. package/dist/lib/index.mjs.map +0 -1
  56. package/dist/lib/integrations/index.d.ts +0 -33
  57. package/dist/lib/integrations/index.js +0 -2091
  58. package/dist/lib/integrations/index.js.map +0 -1
  59. package/dist/lib/integrations/index.mjs +0 -34
  60. package/dist/lib/integrations/index.mjs.map +0 -1
  61. package/dist/lib/integrations/nest/index.d.ts +0 -14
  62. package/dist/lib/integrations/nest/index.js +0 -2000
  63. package/dist/lib/integrations/nest/index.js.map +0 -1
  64. package/dist/lib/integrations/nest/index.mjs +0 -13
  65. package/dist/lib/integrations/nest/index.mjs.map +0 -1
  66. package/dist/lib/integrations/node-express/index.d.ts +0 -14
  67. package/dist/lib/integrations/node-express/index.js +0 -2000
  68. package/dist/lib/integrations/node-express/index.js.map +0 -1
  69. package/dist/lib/integrations/node-express/index.mjs +0 -13
  70. package/dist/lib/integrations/node-express/index.mjs.map +0 -1
  71. package/dist/lib/integrations/node-http/index.d.ts +0 -14
  72. package/dist/lib/integrations/node-http/index.js +0 -1986
  73. package/dist/lib/integrations/node-http/index.js.map +0 -1
  74. package/dist/lib/integrations/node-http/index.mjs +0 -12
  75. package/dist/lib/integrations/node-http/index.mjs.map +0 -1
  76. package/dist/service-adapters/index.d.ts +0 -84
  77. package/dist/service-adapters/index.js +0 -1448
  78. package/dist/service-adapters/index.js.map +0 -1
  79. package/dist/service-adapters/index.mjs +0 -26
  80. package/dist/service-adapters/index.mjs.map +0 -1
  81. package/dist/utils/index.d.ts +0 -49
  82. package/dist/utils/index.js +0 -174
  83. package/dist/utils/index.js.map +0 -1
  84. package/dist/utils/index.mjs +0 -12
  85. package/dist/utils/index.mjs.map +0 -1
@@ -1,1986 +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.5.1-test-custom-tag-prerelease-1.0",
48
- sideEffects: false,
49
- main: "./dist/index.js",
50
- module: "./dist/index.mjs",
51
- exports: {
52
- ".": "./dist/index.js"
53
- },
54
- types: "./dist/index.d.ts",
55
- license: "MIT",
56
- scripts: {
57
- build: 'tsup --onSuccess "pnpm run generate-graphql-schema"',
58
- dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
59
- test: "jest --passWithNoTests",
60
- "check-types": "tsc --noEmit",
61
- clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next && rm -rf __snapshots__",
62
- "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts",
63
- "link:global": "pnpm link --global",
64
- "unlink:global": "pnpm unlink --global"
65
- },
66
- devDependencies: {
67
- "@swc/core": "1.5.28",
68
- "@types/express": "^4.17.21",
69
- "@types/jest": "^29.5.4",
70
- "@types/node": "^18.11.17",
71
- "@whatwg-node/server": "^0.9.34",
72
- eslint: "^8.56.0",
73
- "eslint-config-custom": "workspace:*",
74
- jest: "^29.6.4",
75
- nodemon: "^3.1.3",
76
- "ts-jest": "^29.1.1",
77
- "ts-node": "^10.9.2",
78
- tsconfig: "workspace:*",
79
- tsup: "^6.7.0",
80
- typescript: "^5.2.3",
81
- "zod-to-json-schema": "^3.23.5"
82
- },
83
- dependencies: {
84
- "@anthropic-ai/sdk": "^0.27.3",
85
- "@copilotkit/shared": "workspace:*",
86
- "@graphql-yoga/plugin-defer-stream": "^3.3.1",
87
- "@langchain/community": "^0.0.53",
88
- "@langchain/core": "^0.3.13",
89
- "@langchain/google-gauth": "^0.1.0",
90
- "@langchain/langgraph-sdk": "^0.0.16",
91
- "@langchain/openai": "^0.0.28",
92
- "class-transformer": "^0.5.1",
93
- express: "^4.19.2",
94
- graphql: "^16.8.1",
95
- "graphql-scalars": "^1.23.0",
96
- "graphql-yoga": "^5.3.1",
97
- "groq-sdk": "^0.5.0",
98
- langchain: "^0.3.3",
99
- openai: "^4.50.0",
100
- "partial-json": "^0.1.7",
101
- pino: "^9.2.0",
102
- "pino-pretty": "^11.2.1",
103
- "reflect-metadata": "^0.2.2",
104
- rxjs: "^7.8.1",
105
- "type-graphql": "2.0.0-rc.1",
106
- zod: "^3.23.3"
107
- },
108
- keywords: [
109
- "copilotkit",
110
- "copilot",
111
- "react",
112
- "nextjs",
113
- "nodejs",
114
- "ai",
115
- "assistant",
116
- "javascript",
117
- "automation",
118
- "textarea"
119
- ]
120
- };
121
- }
122
- });
123
-
124
- // src/lib/integrations/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 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
- function _ts_decorate14(decorators, target, key, desc) {
1421
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1422
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1423
- r = Reflect.decorate(decorators, target, key, desc);
1424
- else
1425
- for (var i = decorators.length - 1; i >= 0; i--)
1426
- if (d = decorators[i])
1427
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1428
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1429
- }
1430
- __name(_ts_decorate14, "_ts_decorate");
1431
- function _ts_metadata14(k, v) {
1432
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1433
- return Reflect.metadata(k, v);
1434
- }
1435
- __name(_ts_metadata14, "_ts_metadata");
1436
- function _ts_param(paramIndex, decorator) {
1437
- return function(target, key) {
1438
- decorator(target, key, paramIndex);
1439
- };
1440
- }
1441
- __name(_ts_param, "_ts_param");
1442
- var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
1443
- var _a;
1444
- if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
1445
- const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
1446
- role: m.textMessage.role,
1447
- content: m.textMessage.content
1448
- }));
1449
- const lastMessage = messages[messages.length - 1];
1450
- const restOfMessages = messages.slice(0, -1);
1451
- const body = {
1452
- input: lastMessage.content,
1453
- validTopics: data.cloud.guardrails.inputValidationRules.allowList,
1454
- invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
1455
- messages: restOfMessages
1456
- };
1457
- const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
1458
- method: "POST",
1459
- headers: {
1460
- "Content-Type": "application/json",
1461
- "X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
1462
- },
1463
- body: JSON.stringify(body)
1464
- });
1465
- if (guardrailsResult.ok) {
1466
- const resultJson = await guardrailsResult.json();
1467
- onResult(resultJson);
1468
- } else {
1469
- onError(await guardrailsResult.json());
1470
- }
1471
- }
1472
- }, "invokeGuardrails");
1473
- var CopilotResolver = class {
1474
- async hello() {
1475
- return "Hello World";
1476
- }
1477
- async generateCopilotResponse(ctx, data, properties) {
1478
- var _a, _b, _c;
1479
- telemetry_client_default.capture("oss.runtime.copilot_request_created", {
1480
- "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
1481
- requestType: data.metadata.requestType
1482
- });
1483
- let logger2 = ctx.logger.child({
1484
- component: "CopilotResolver.generateCopilotResponse"
1485
- });
1486
- logger2.debug({
1487
- data
1488
- }, "Generating Copilot response");
1489
- if (properties) {
1490
- logger2.debug("Properties provided, merging with context properties");
1491
- ctx.properties = {
1492
- ...ctx.properties,
1493
- ...properties
1494
- };
1495
- }
1496
- const copilotRuntime = ctx._copilotkit.runtime;
1497
- const serviceAdapter = ctx._copilotkit.serviceAdapter;
1498
- let copilotCloudPublicApiKey = null;
1499
- let copilotCloudBaseUrl;
1500
- if (data.cloud) {
1501
- logger2 = logger2.child({
1502
- cloud: true
1503
- });
1504
- logger2.debug("Cloud configuration provided, checking for public API key in headers");
1505
- const key = ctx.request.headers.get("x-copilotcloud-public-api-key");
1506
- if (key) {
1507
- logger2.debug("Public API key found in headers");
1508
- copilotCloudPublicApiKey = key;
1509
- } else {
1510
- logger2.error("Public API key not found in headers");
1511
- throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
1512
- }
1513
- if (process.env.COPILOT_CLOUD_BASE_URL) {
1514
- copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
1515
- } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
1516
- copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
1517
- } else {
1518
- copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
1519
- }
1520
- logger2 = logger2.child({
1521
- copilotCloudBaseUrl
1522
- });
1523
- }
1524
- logger2.debug("Setting up subjects");
1525
- const responseStatus$ = new import_rxjs3.ReplaySubject();
1526
- const interruptStreaming$ = new import_rxjs3.ReplaySubject();
1527
- const guardrailsResult$ = new import_rxjs3.ReplaySubject();
1528
- let outputMessages = [];
1529
- let resolveOutputMessagesPromise;
1530
- let rejectOutputMessagesPromise;
1531
- const outputMessagesPromise = new Promise((resolve, reject) => {
1532
- resolveOutputMessagesPromise = resolve;
1533
- rejectOutputMessagesPromise = reject;
1534
- });
1535
- logger2.debug("Processing");
1536
- const { eventSource, threadId = (0, import_shared4.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
1537
- serviceAdapter,
1538
- messages: data.messages,
1539
- actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
1540
- threadId: data.threadId,
1541
- runId: data.runId,
1542
- publicApiKey: void 0,
1543
- outputMessagesPromise,
1544
- graphqlContext: ctx,
1545
- forwardedParameters: data.forwardedParameters,
1546
- agentSession: data.agentSession,
1547
- agentStates: data.agentStates,
1548
- url: data.frontend.url
1549
- });
1550
- logger2.debug("Event source created, creating response");
1551
- const response = {
1552
- threadId,
1553
- runId,
1554
- status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
1555
- messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
1556
- var _a2, _b2;
1557
- logger2.debug("Messages repeater created");
1558
- if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
1559
- logger2 = logger2.child({
1560
- guardrails: true
1561
- });
1562
- logger2.debug("Guardrails is enabled, validating input");
1563
- invokeGuardrails({
1564
- baseUrl: copilotCloudBaseUrl,
1565
- copilotCloudPublicApiKey,
1566
- data,
1567
- onResult: (result) => {
1568
- logger2.debug({
1569
- status: result.status
1570
- }, "Guardrails validation done");
1571
- guardrailsResult$.next(result);
1572
- if (result.status === "denied") {
1573
- responseStatus$.next(new GuardrailsValidationFailureResponse({
1574
- guardrailsReason: result.reason
1575
- }));
1576
- interruptStreaming$.next({
1577
- reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
1578
- });
1579
- outputMessages = [
1580
- (0, import_class_transformer2.plainToInstance)(TextMessage, {
1581
- id: (0, import_shared4.randomId)(),
1582
- createdAt: /* @__PURE__ */ new Date(),
1583
- content: result.reason,
1584
- role: MessageRole.assistant
1585
- })
1586
- ];
1587
- resolveOutputMessagesPromise(outputMessages);
1588
- }
1589
- },
1590
- onError: (err) => {
1591
- logger2.error({
1592
- err
1593
- }, "Error in guardrails validation");
1594
- responseStatus$.next(new UnknownErrorResponse({
1595
- description: `An unknown error has occurred in the guardrails validation`
1596
- }));
1597
- interruptStreaming$.next({
1598
- reason: `Interrupted due to unknown error in guardrails validation`
1599
- });
1600
- rejectOutputMessagesPromise(err);
1601
- }
1602
- });
1603
- }
1604
- let eventStreamSubscription;
1605
- const eventStream = eventSource.processRuntimeEvents({
1606
- serverSideActions,
1607
- guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null,
1608
- actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
1609
- // TODO-AGENTS: do not exclude ALL server side actions
1610
- (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
1611
- )
1612
- }).pipe(
1613
- // shareReplay() ensures that later subscribers will see the whole stream instead of
1614
- // just the events that were emitted after the subscriber was added.
1615
- (0, import_rxjs3.shareReplay)(),
1616
- (0, import_rxjs3.finalize)(() => {
1617
- logger2.debug("Event stream finalized");
1618
- })
1619
- );
1620
- logger2.debug("Event stream created, subscribing to event stream");
1621
- eventStreamSubscription = eventStream.subscribe({
1622
- next: async (event) => {
1623
- switch (event.type) {
1624
- case RuntimeEventTypes.TextMessageStart:
1625
- const textMessageContentStream = eventStream.pipe(
1626
- // skip until this message start event
1627
- (0, import_rxjs3.skipWhile)((e) => e !== event),
1628
- // take until the message end event
1629
- (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
1630
- // filter out any other message events or message ids
1631
- (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
1632
- );
1633
- const streamingTextStatus = new import_rxjs3.Subject();
1634
- const messageId = event.messageId;
1635
- pushMessage({
1636
- id: messageId,
1637
- parentMessageId: event.parentMessageId,
1638
- status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
1639
- createdAt: /* @__PURE__ */ new Date(),
1640
- role: MessageRole.assistant,
1641
- content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
1642
- logger2.debug("Text message content repeater created");
1643
- const textChunks = [];
1644
- let textSubscription;
1645
- interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
1646
- logger2.debug({
1647
- reason,
1648
- messageId: messageId2
1649
- }, "Text streaming interrupted");
1650
- streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
1651
- reason
1652
- }));
1653
- responseStatus$.next(new MessageStreamInterruptedResponse({
1654
- messageId: messageId2
1655
- }));
1656
- stopStreamingText();
1657
- textSubscription == null ? void 0 : textSubscription.unsubscribe();
1658
- })).subscribe();
1659
- logger2.debug("Subscribing to text message content stream");
1660
- textSubscription = textMessageContentStream.subscribe({
1661
- next: async (e) => {
1662
- if (e.type == RuntimeEventTypes.TextMessageContent) {
1663
- await pushTextChunk(e.content);
1664
- textChunks.push(e.content);
1665
- }
1666
- },
1667
- error: (err) => {
1668
- logger2.error({
1669
- err
1670
- }, "Error in text message content stream");
1671
- interruptStreaming$.next({
1672
- reason: "Error streaming message content",
1673
- messageId
1674
- });
1675
- stopStreamingText();
1676
- textSubscription == null ? void 0 : textSubscription.unsubscribe();
1677
- },
1678
- complete: () => {
1679
- logger2.debug("Text message content stream completed");
1680
- streamingTextStatus.next(new SuccessMessageStatus());
1681
- stopStreamingText();
1682
- textSubscription == null ? void 0 : textSubscription.unsubscribe();
1683
- outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
1684
- id: messageId,
1685
- createdAt: /* @__PURE__ */ new Date(),
1686
- content: textChunks.join(""),
1687
- role: MessageRole.assistant
1688
- }));
1689
- }
1690
- });
1691
- })
1692
- });
1693
- break;
1694
- case RuntimeEventTypes.ActionExecutionStart:
1695
- logger2.debug("Action execution start event received");
1696
- const actionExecutionArgumentStream = eventStream.pipe(
1697
- (0, import_rxjs3.skipWhile)((e) => e !== event),
1698
- // take until the action execution end event
1699
- (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
1700
- // filter out any other action execution events or action execution ids
1701
- (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
1702
- );
1703
- const streamingArgumentsStatus = new import_rxjs3.Subject();
1704
- pushMessage({
1705
- id: event.actionExecutionId,
1706
- parentMessageId: event.parentMessageId,
1707
- status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
1708
- createdAt: /* @__PURE__ */ new Date(),
1709
- name: event.actionName,
1710
- arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
1711
- logger2.debug("Action execution argument stream created");
1712
- const argumentChunks = [];
1713
- let actionExecutionArgumentSubscription;
1714
- actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
1715
- next: async (e) => {
1716
- if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
1717
- await pushArgumentsChunk(e.args);
1718
- argumentChunks.push(e.args);
1719
- }
1720
- },
1721
- error: (err) => {
1722
- logger2.error({
1723
- err
1724
- }, "Error in action execution argument stream");
1725
- streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
1726
- reason: "An unknown error has occurred in the action execution argument stream"
1727
- }));
1728
- stopStreamingArguments();
1729
- actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
1730
- },
1731
- complete: () => {
1732
- logger2.debug("Action execution argument stream completed");
1733
- streamingArgumentsStatus.next(new SuccessMessageStatus());
1734
- stopStreamingArguments();
1735
- actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
1736
- outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
1737
- id: event.actionExecutionId,
1738
- createdAt: /* @__PURE__ */ new Date(),
1739
- name: event.actionName,
1740
- arguments: argumentChunks.join("")
1741
- }));
1742
- }
1743
- });
1744
- })
1745
- });
1746
- break;
1747
- case RuntimeEventTypes.ActionExecutionResult:
1748
- logger2.debug({
1749
- result: event.result
1750
- }, "Action execution result event received");
1751
- pushMessage({
1752
- id: "result-" + event.actionExecutionId,
1753
- status: new SuccessMessageStatus(),
1754
- createdAt: /* @__PURE__ */ new Date(),
1755
- actionExecutionId: event.actionExecutionId,
1756
- actionName: event.actionName,
1757
- result: event.result
1758
- });
1759
- outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
1760
- id: "result-" + event.actionExecutionId,
1761
- createdAt: /* @__PURE__ */ new Date(),
1762
- actionExecutionId: event.actionExecutionId,
1763
- actionName: event.actionName,
1764
- result: event.result
1765
- }));
1766
- break;
1767
- case RuntimeEventTypes.AgentStateMessage:
1768
- logger2.debug({
1769
- event
1770
- }, "Agent message event received");
1771
- pushMessage({
1772
- id: (0, import_shared4.randomId)(),
1773
- status: new SuccessMessageStatus(),
1774
- threadId: event.threadId,
1775
- agentName: event.agentName,
1776
- nodeName: event.nodeName,
1777
- runId: event.runId,
1778
- active: event.active,
1779
- state: event.state,
1780
- running: event.running,
1781
- role: MessageRole.assistant,
1782
- createdAt: /* @__PURE__ */ new Date()
1783
- });
1784
- outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
1785
- id: (0, import_shared4.randomId)(),
1786
- threadId: event.threadId,
1787
- agentName: event.agentName,
1788
- nodeName: event.nodeName,
1789
- runId: event.runId,
1790
- active: event.active,
1791
- state: event.state,
1792
- running: event.running,
1793
- role: MessageRole.assistant,
1794
- createdAt: /* @__PURE__ */ new Date()
1795
- }));
1796
- break;
1797
- }
1798
- },
1799
- error: (err) => {
1800
- logger2.error({
1801
- err
1802
- }, "Error in event stream");
1803
- responseStatus$.next(new UnknownErrorResponse({
1804
- description: `An unknown error has occurred in the event stream`
1805
- }));
1806
- eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
1807
- stopStreamingMessages();
1808
- rejectOutputMessagesPromise(err);
1809
- },
1810
- complete: async () => {
1811
- var _a3;
1812
- logger2.debug("Event stream completed");
1813
- if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
1814
- logger2.debug("Guardrails is enabled, waiting for guardrails result");
1815
- await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
1816
- }
1817
- responseStatus$.next(new SuccessResponseStatus());
1818
- eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
1819
- stopStreamingMessages();
1820
- resolveOutputMessagesPromise(outputMessages);
1821
- }
1822
- });
1823
- })
1824
- };
1825
- return response;
1826
- }
1827
- };
1828
- __name(CopilotResolver, "CopilotResolver");
1829
- _ts_decorate14([
1830
- (0, import_type_graphql15.Query)(() => String),
1831
- _ts_metadata14("design:type", Function),
1832
- _ts_metadata14("design:paramtypes", []),
1833
- _ts_metadata14("design:returntype", Promise)
1834
- ], CopilotResolver.prototype, "hello", null);
1835
- _ts_decorate14([
1836
- (0, import_type_graphql15.Mutation)(() => CopilotResponse),
1837
- _ts_param(0, (0, import_type_graphql15.Ctx)()),
1838
- _ts_param(1, (0, import_type_graphql15.Arg)("data")),
1839
- _ts_param(2, (0, import_type_graphql15.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
1840
- nullable: true
1841
- })),
1842
- _ts_metadata14("design:type", Function),
1843
- _ts_metadata14("design:paramtypes", [
1844
- typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
1845
- typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
1846
- typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
1847
- ]),
1848
- _ts_metadata14("design:returntype", Promise)
1849
- ], CopilotResolver.prototype, "generateCopilotResponse", null);
1850
- CopilotResolver = _ts_decorate14([
1851
- (0, import_type_graphql15.Resolver)(() => CopilotResponse)
1852
- ], CopilotResolver);
1853
-
1854
- // src/lib/integrations/shared.ts
1855
- var import_plugin_defer_stream = require("@graphql-yoga/plugin-defer-stream");
1856
-
1857
- // src/lib/logger.ts
1858
- var import_pino = __toESM(require("pino"));
1859
- var import_pino_pretty = __toESM(require("pino-pretty"));
1860
- function createLogger(options) {
1861
- const { level, component } = options || {};
1862
- const stream = (0, import_pino_pretty.default)({
1863
- colorize: true
1864
- });
1865
- const logger2 = (0, import_pino.default)({
1866
- level: process.env.LOG_LEVEL || level || "error",
1867
- redact: {
1868
- paths: [
1869
- "pid",
1870
- "hostname"
1871
- ],
1872
- remove: true
1873
- }
1874
- }, stream);
1875
- if (component) {
1876
- return logger2.child({
1877
- component
1878
- });
1879
- } else {
1880
- return logger2;
1881
- }
1882
- }
1883
- __name(createLogger, "createLogger");
1884
-
1885
- // src/lib/integrations/shared.ts
1886
- var logger = createLogger();
1887
- async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
1888
- logger.debug({
1889
- copilotKitContext
1890
- }, "Creating GraphQL context");
1891
- const ctx = {
1892
- ...initialContext,
1893
- _copilotkit: {
1894
- ...copilotKitContext
1895
- },
1896
- properties: {
1897
- ...properties
1898
- },
1899
- logger: contextLogger
1900
- };
1901
- return ctx;
1902
- }
1903
- __name(createContext, "createContext");
1904
- function buildSchema(options = {}) {
1905
- logger.debug("Building GraphQL schema...");
1906
- const schema = (0, import_type_graphql16.buildSchemaSync)({
1907
- resolvers: [
1908
- CopilotResolver
1909
- ],
1910
- emitSchemaFile: options.emitSchemaFile
1911
- });
1912
- logger.debug("GraphQL schema built successfully");
1913
- return schema;
1914
- }
1915
- __name(buildSchema, "buildSchema");
1916
- function getCommonConfig(options) {
1917
- var _a;
1918
- const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
1919
- const logger2 = createLogger({
1920
- level: logLevel,
1921
- component: "getCommonConfig"
1922
- });
1923
- const contextLogger = createLogger({
1924
- level: logLevel
1925
- });
1926
- if (options.cloud) {
1927
- telemetry_client_default.setCloudConfiguration({
1928
- publicApiKey: options.cloud.publicApiKey,
1929
- baseUrl: options.cloud.baseUrl
1930
- });
1931
- }
1932
- if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
1933
- telemetry_client_default.setGlobalProperties({
1934
- _copilotkit: {
1935
- ...options.properties._copilotkit
1936
- }
1937
- });
1938
- }
1939
- telemetry_client_default.setGlobalProperties({
1940
- runtime: {
1941
- serviceAdapter: options.serviceAdapter.constructor.name
1942
- }
1943
- });
1944
- return {
1945
- logging: createLogger({
1946
- component: "Yoga GraphQL",
1947
- level: logLevel
1948
- }),
1949
- schema: buildSchema(),
1950
- plugins: [
1951
- (0, import_plugin_defer_stream.useDeferStream)()
1952
- ],
1953
- context: (ctx) => createContext(ctx, options, contextLogger, options.properties)
1954
- };
1955
- }
1956
- __name(getCommonConfig, "getCommonConfig");
1957
-
1958
- // src/lib/integrations/node-http/index.ts
1959
- function copilotRuntimeNodeHttpEndpoint(options) {
1960
- var _a;
1961
- const commonConfig = getCommonConfig(options);
1962
- telemetry_client_default.setGlobalProperties({
1963
- runtime: {
1964
- framework: "node-http"
1965
- }
1966
- });
1967
- if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
1968
- telemetry_client_default.setGlobalProperties({
1969
- _copilotkit: options.properties._copilotkit
1970
- });
1971
- }
1972
- telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
1973
- const logger2 = commonConfig.logging;
1974
- logger2.debug("Creating Node HTTP endpoint");
1975
- const yoga = (0, import_graphql_yoga2.createYoga)({
1976
- ...commonConfig,
1977
- graphqlEndpoint: options.endpoint
1978
- });
1979
- return yoga;
1980
- }
1981
- __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
1982
- // Annotate the CommonJS export names for ESM import in node:
1983
- 0 && (module.exports = {
1984
- copilotRuntimeNodeHttpEndpoint
1985
- });
1986
- //# sourceMappingURL=index.js.map