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