@copilotkit/runtime 1.50.0-beta.0 → 1.50.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/chunk-2OZAGFV3.mjs +43 -0
  3. package/dist/chunk-2OZAGFV3.mjs.map +1 -0
  4. package/dist/chunk-62NE5S6M.mjs +226 -0
  5. package/dist/chunk-62NE5S6M.mjs.map +1 -0
  6. package/dist/chunk-6XRUR5UK.mjs +1 -0
  7. package/dist/chunk-6XRUR5UK.mjs.map +1 -0
  8. package/dist/chunk-AMUJQ6IR.mjs +50 -0
  9. package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
  10. package/dist/chunk-BJEYMRDD.mjs +25 -0
  11. package/dist/chunk-BJEYMRDD.mjs.map +1 -0
  12. package/dist/chunk-DZV4ZIAR.mjs +3063 -0
  13. package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
  14. package/dist/chunk-FHD4JECV.mjs +33 -0
  15. package/dist/chunk-FHD4JECV.mjs.map +1 -0
  16. package/dist/chunk-FMU55SEU.mjs +25 -0
  17. package/dist/chunk-FMU55SEU.mjs.map +1 -0
  18. package/dist/chunk-OWIGJONH.mjs +275 -0
  19. package/dist/chunk-OWIGJONH.mjs.map +1 -0
  20. package/dist/chunk-SBCOROE4.mjs +1112 -0
  21. package/dist/chunk-SBCOROE4.mjs.map +1 -0
  22. package/dist/chunk-TTUAEJLD.mjs +617 -0
  23. package/dist/chunk-TTUAEJLD.mjs.map +1 -0
  24. package/dist/chunk-XWBDEXDA.mjs +153 -0
  25. package/dist/chunk-XWBDEXDA.mjs.map +1 -0
  26. package/dist/chunk-Z752VE75.mjs +74 -0
  27. package/dist/chunk-Z752VE75.mjs.map +1 -0
  28. package/dist/graphql/message-conversion/index.d.ts +18 -0
  29. package/dist/graphql/message-conversion/index.js +725 -0
  30. package/dist/graphql/message-conversion/index.js.map +1 -0
  31. package/dist/graphql/message-conversion/index.mjs +245 -0
  32. package/dist/graphql/message-conversion/index.mjs.map +1 -0
  33. package/dist/graphql/types/base/index.d.ts +6 -0
  34. package/dist/graphql/types/base/index.js +63 -0
  35. package/dist/graphql/types/base/index.js.map +1 -0
  36. package/dist/graphql/types/base/index.mjs +8 -0
  37. package/dist/graphql/types/base/index.mjs.map +1 -0
  38. package/dist/graphql/types/converted/index.d.ts +2 -0
  39. package/dist/graphql/types/converted/index.js +294 -0
  40. package/dist/graphql/types/converted/index.js.map +1 -0
  41. package/dist/graphql/types/converted/index.mjs +20 -0
  42. package/dist/graphql/types/converted/index.mjs.map +1 -0
  43. package/dist/groq-adapter-50bc6e4a.d.ts +326 -0
  44. package/dist/index-adbd78f1.d.ts +154 -0
  45. package/dist/index.d.ts +136 -287
  46. package/dist/index.js +393 -287
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +385 -276
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/langgraph.d.ts +284 -0
  51. package/dist/langgraph.js +211 -0
  52. package/dist/langgraph.js.map +1 -0
  53. package/dist/langgraph.mjs +206 -0
  54. package/dist/langgraph.mjs.map +1 -0
  55. package/dist/langserve-74a52292.d.ts +242 -0
  56. package/dist/lib/cloud/index.d.ts +6 -0
  57. package/dist/lib/cloud/index.js +18 -0
  58. package/dist/lib/cloud/index.js.map +1 -0
  59. package/dist/lib/cloud/index.mjs +1 -0
  60. package/dist/lib/cloud/index.mjs.map +1 -0
  61. package/dist/lib/index.d.ts +266 -0
  62. package/dist/lib/index.js +4944 -0
  63. package/dist/lib/index.js.map +1 -0
  64. package/dist/lib/index.mjs +74 -0
  65. package/dist/lib/index.mjs.map +1 -0
  66. package/dist/lib/integrations/index.d.ts +28 -0
  67. package/dist/lib/integrations/index.js +3024 -0
  68. package/dist/lib/integrations/index.js.map +1 -0
  69. package/dist/lib/integrations/index.mjs +36 -0
  70. package/dist/lib/integrations/index.mjs.map +1 -0
  71. package/dist/lib/integrations/nest/index.d.ts +16 -0
  72. package/dist/lib/integrations/nest/index.js +2937 -0
  73. package/dist/lib/integrations/nest/index.js.map +1 -0
  74. package/dist/lib/integrations/nest/index.mjs +13 -0
  75. package/dist/lib/integrations/nest/index.mjs.map +1 -0
  76. package/dist/lib/integrations/node-express/index.d.ts +16 -0
  77. package/dist/lib/integrations/node-express/index.js +2937 -0
  78. package/dist/lib/integrations/node-express/index.js.map +1 -0
  79. package/dist/lib/integrations/node-express/index.mjs +13 -0
  80. package/dist/lib/integrations/node-express/index.mjs.map +1 -0
  81. package/dist/lib/integrations/node-http/index.d.ts +16 -0
  82. package/dist/lib/integrations/node-http/index.js +2923 -0
  83. package/dist/lib/integrations/node-http/index.js.map +1 -0
  84. package/dist/lib/integrations/node-http/index.mjs +12 -0
  85. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  86. package/dist/service-adapters/index.d.ts +166 -0
  87. package/dist/service-adapters/index.js +1800 -0
  88. package/dist/service-adapters/index.js.map +1 -0
  89. package/dist/service-adapters/index.mjs +36 -0
  90. package/dist/service-adapters/index.mjs.map +1 -0
  91. package/dist/service-adapters/shared/index.d.ts +9 -0
  92. package/dist/service-adapters/shared/index.js +72 -0
  93. package/dist/service-adapters/shared/index.js.map +1 -0
  94. package/dist/service-adapters/shared/index.mjs +8 -0
  95. package/dist/service-adapters/shared/index.mjs.map +1 -0
  96. package/dist/shared-f6d43ef8.d.ts +446 -0
  97. package/dist/utils/index.d.ts +65 -0
  98. package/dist/utils/index.js +175 -0
  99. package/dist/utils/index.js.map +1 -0
  100. package/dist/utils/index.mjs +12 -0
  101. package/dist/utils/index.mjs.map +1 -0
  102. package/dist/v2/index.d.ts +1 -0
  103. package/dist/v2/index.js +7 -0
  104. package/dist/v2/index.js.map +1 -1
  105. package/dist/v2/index.mjs +1 -0
  106. package/dist/v2/index.mjs.map +1 -1
  107. package/package.json +71 -33
  108. package/src/graphql/message-conversion/agui-to-gql.test.ts +2 -2
  109. package/src/graphql/message-conversion/gql-to-agui.test.ts +30 -28
  110. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +8 -8
  111. package/src/langgraph.ts +1 -0
  112. package/src/lib/index.ts +42 -1
  113. package/src/lib/integrations/nextjs/app-router.ts +3 -1
  114. package/src/lib/integrations/node-http/index.ts +132 -11
  115. package/src/lib/integrations/shared.ts +2 -2
  116. package/src/lib/runtime/agent-integrations/{langgraph.agent.ts → langgraph/agent.ts} +5 -30
  117. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +34 -0
  118. package/src/lib/runtime/agent-integrations/langgraph/index.ts +2 -0
  119. package/src/lib/runtime/copilot-runtime.ts +51 -68
  120. package/src/lib/runtime/telemetry-agent-runner.ts +134 -0
  121. package/src/service-adapters/anthropic/anthropic-adapter.ts +16 -3
  122. package/src/service-adapters/bedrock/bedrock-adapter.ts +4 -1
  123. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +2 -1
  124. package/src/service-adapters/google/google-genai-adapter.ts +9 -4
  125. package/src/service-adapters/groq/groq-adapter.ts +16 -3
  126. package/src/service-adapters/langchain/langchain-adapter.ts +5 -3
  127. package/src/service-adapters/langchain/langserve.ts +2 -1
  128. package/src/service-adapters/openai/openai-adapter.ts +17 -3
  129. package/src/service-adapters/openai/openai-assistant-adapter.ts +26 -11
  130. package/src/service-adapters/unify/unify-adapter.ts +3 -1
  131. package/src/v2/index.ts +1 -0
  132. package/tsup.config.ts +5 -2
@@ -0,0 +1,2923 @@
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, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, 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.10.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
+ "@jest/globals": "^29.7.0",
68
+ "@swc/core": "1.5.28",
69
+ "@types/express": "^4.17.21",
70
+ "@types/jest": "^29.5.12",
71
+ "@types/node": "^18.11.17",
72
+ "@whatwg-node/server": "^0.9.34",
73
+ eslint: "^8.56.0",
74
+ "eslint-config-custom": "workspace:*",
75
+ jest: "^29.6.4",
76
+ nodemon: "^3.1.3",
77
+ "ts-jest": "^29.1.1",
78
+ "ts-node": "^10.9.2",
79
+ tsconfig: "workspace:*",
80
+ tsup: "^6.7.0",
81
+ typescript: "^5.2.3",
82
+ vitest: "^3.2.4",
83
+ "zod-to-json-schema": "^3.23.5"
84
+ },
85
+ dependencies: {
86
+ "@anthropic-ai/sdk": "^0.57.0",
87
+ "@copilotkit/shared": "workspace:*",
88
+ "@copilotkitnext/agent": "^0.0.17",
89
+ "@copilotkitnext/runtime": "^0.0.17",
90
+ "@graphql-yoga/plugin-defer-stream": "^3.3.1",
91
+ "@langchain/aws": "^0.1.9",
92
+ "@langchain/community": "^0.3.29",
93
+ "@langchain/core": "^0.3.38",
94
+ "@langchain/google-gauth": "^0.1.0",
95
+ "@langchain/langgraph-sdk": "^0.0.70",
96
+ "@langchain/openai": "^0.4.2",
97
+ "@scarf/scarf": "^1.3.0",
98
+ "class-transformer": "^0.5.1",
99
+ "class-validator": "^0.14.1",
100
+ express: "^4.19.2",
101
+ graphql: "^16.8.1",
102
+ "graphql-scalars": "^1.23.0",
103
+ "graphql-yoga": "^5.3.1",
104
+ "groq-sdk": "^0.5.0",
105
+ langchain: "^0.3.3",
106
+ openai: "^4.85.1",
107
+ "partial-json": "^0.1.7",
108
+ pino: "^9.2.0",
109
+ "pino-pretty": "^11.2.1",
110
+ "reflect-metadata": "^0.2.2",
111
+ rxjs: "7.8.1",
112
+ "type-graphql": "2.0.0-rc.1",
113
+ zod: "^3.23.3"
114
+ },
115
+ peerDependencies: {
116
+ "@ag-ui/client": ">=0.0.39",
117
+ "@ag-ui/core": ">=0.0.39",
118
+ "@ag-ui/encoder": ">=0.0.39",
119
+ "@ag-ui/langgraph": ">=0.0.18",
120
+ "@ag-ui/proto": ">=0.0.39"
121
+ },
122
+ keywords: [
123
+ "copilotkit",
124
+ "copilot",
125
+ "react",
126
+ "nextjs",
127
+ "nodejs",
128
+ "ai",
129
+ "assistant",
130
+ "javascript",
131
+ "automation",
132
+ "textarea"
133
+ ]
134
+ };
135
+ }
136
+ });
137
+
138
+ // src/lib/integrations/node-http/index.ts
139
+ var node_http_exports = {};
140
+ __export(node_http_exports, {
141
+ copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint
142
+ });
143
+ module.exports = __toCommonJS(node_http_exports);
144
+ var import_runtime32 = require("@copilotkitnext/runtime");
145
+
146
+ // src/lib/integrations/shared.ts
147
+ var import_type_graphql27 = require("type-graphql");
148
+
149
+ // src/graphql/resolvers/copilot.resolver.ts
150
+ var import_type_graphql21 = require("type-graphql");
151
+ var import_rxjs2 = require("rxjs");
152
+
153
+ // src/graphql/inputs/generate-copilot-response.input.ts
154
+ var import_type_graphql19 = require("type-graphql");
155
+
156
+ // src/graphql/inputs/message.input.ts
157
+ var import_type_graphql3 = require("type-graphql");
158
+
159
+ // src/graphql/types/enums.ts
160
+ var import_type_graphql = require("type-graphql");
161
+ var MessageRole;
162
+ (function(MessageRole2) {
163
+ MessageRole2["assistant"] = "assistant";
164
+ MessageRole2["developer"] = "developer";
165
+ MessageRole2["system"] = "system";
166
+ MessageRole2["tool"] = "tool";
167
+ MessageRole2["user"] = "user";
168
+ })(MessageRole || (MessageRole = {}));
169
+ var CopilotRequestType;
170
+ (function(CopilotRequestType2) {
171
+ CopilotRequestType2["Chat"] = "Chat";
172
+ CopilotRequestType2["Task"] = "Task";
173
+ CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
174
+ CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
175
+ CopilotRequestType2["Suggestion"] = "Suggestion";
176
+ })(CopilotRequestType || (CopilotRequestType = {}));
177
+ var ActionInputAvailability;
178
+ (function(ActionInputAvailability2) {
179
+ ActionInputAvailability2["disabled"] = "disabled";
180
+ ActionInputAvailability2["enabled"] = "enabled";
181
+ ActionInputAvailability2["remote"] = "remote";
182
+ })(ActionInputAvailability || (ActionInputAvailability = {}));
183
+ (0, import_type_graphql.registerEnumType)(MessageRole, {
184
+ name: "MessageRole",
185
+ description: "The role of the message"
186
+ });
187
+ (0, import_type_graphql.registerEnumType)(CopilotRequestType, {
188
+ name: "CopilotRequestType",
189
+ description: "The type of Copilot request"
190
+ });
191
+ (0, import_type_graphql.registerEnumType)(ActionInputAvailability, {
192
+ name: "ActionInputAvailability",
193
+ description: "The availability of the frontend action"
194
+ });
195
+
196
+ // src/graphql/types/base/index.ts
197
+ var import_type_graphql2 = require("type-graphql");
198
+ function _ts_decorate(decorators, target, key, desc) {
199
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
200
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
201
+ r = Reflect.decorate(decorators, target, key, desc);
202
+ else
203
+ for (var i = decorators.length - 1; i >= 0; i--)
204
+ if (d = decorators[i])
205
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
206
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
207
+ }
208
+ __name(_ts_decorate, "_ts_decorate");
209
+ function _ts_metadata(k, v) {
210
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
211
+ return Reflect.metadata(k, v);
212
+ }
213
+ __name(_ts_metadata, "_ts_metadata");
214
+ var BaseMessageInput = class {
215
+ id;
216
+ createdAt;
217
+ };
218
+ __name(BaseMessageInput, "BaseMessageInput");
219
+ _ts_decorate([
220
+ (0, import_type_graphql2.Field)(() => String),
221
+ _ts_metadata("design:type", String)
222
+ ], BaseMessageInput.prototype, "id", void 0);
223
+ _ts_decorate([
224
+ (0, import_type_graphql2.Field)(() => Date),
225
+ _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
226
+ ], BaseMessageInput.prototype, "createdAt", void 0);
227
+ BaseMessageInput = _ts_decorate([
228
+ (0, import_type_graphql2.InputType)()
229
+ ], BaseMessageInput);
230
+
231
+ // src/graphql/inputs/message.input.ts
232
+ function _ts_decorate2(decorators, target, key, desc) {
233
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
234
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
235
+ r = Reflect.decorate(decorators, target, key, desc);
236
+ else
237
+ for (var i = decorators.length - 1; i >= 0; i--)
238
+ if (d = decorators[i])
239
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
240
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
241
+ }
242
+ __name(_ts_decorate2, "_ts_decorate");
243
+ function _ts_metadata2(k, v) {
244
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
245
+ return Reflect.metadata(k, v);
246
+ }
247
+ __name(_ts_metadata2, "_ts_metadata");
248
+ var MessageInput = class extends BaseMessageInput {
249
+ textMessage;
250
+ actionExecutionMessage;
251
+ resultMessage;
252
+ agentStateMessage;
253
+ imageMessage;
254
+ };
255
+ __name(MessageInput, "MessageInput");
256
+ _ts_decorate2([
257
+ (0, import_type_graphql3.Field)(() => TextMessageInput, {
258
+ nullable: true
259
+ }),
260
+ _ts_metadata2("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
261
+ ], MessageInput.prototype, "textMessage", void 0);
262
+ _ts_decorate2([
263
+ (0, import_type_graphql3.Field)(() => ActionExecutionMessageInput, {
264
+ nullable: true
265
+ }),
266
+ _ts_metadata2("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
267
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
268
+ _ts_decorate2([
269
+ (0, import_type_graphql3.Field)(() => ResultMessageInput, {
270
+ nullable: true
271
+ }),
272
+ _ts_metadata2("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
273
+ ], MessageInput.prototype, "resultMessage", void 0);
274
+ _ts_decorate2([
275
+ (0, import_type_graphql3.Field)(() => AgentStateMessageInput, {
276
+ nullable: true
277
+ }),
278
+ _ts_metadata2("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
279
+ ], MessageInput.prototype, "agentStateMessage", void 0);
280
+ _ts_decorate2([
281
+ (0, import_type_graphql3.Field)(() => ImageMessageInput, {
282
+ nullable: true
283
+ }),
284
+ _ts_metadata2("design:type", typeof ImageMessageInput === "undefined" ? Object : ImageMessageInput)
285
+ ], MessageInput.prototype, "imageMessage", void 0);
286
+ MessageInput = _ts_decorate2([
287
+ (0, import_type_graphql3.InputType)()
288
+ ], MessageInput);
289
+ var TextMessageInput = class {
290
+ content;
291
+ parentMessageId;
292
+ role;
293
+ };
294
+ __name(TextMessageInput, "TextMessageInput");
295
+ _ts_decorate2([
296
+ (0, import_type_graphql3.Field)(() => String),
297
+ _ts_metadata2("design:type", String)
298
+ ], TextMessageInput.prototype, "content", void 0);
299
+ _ts_decorate2([
300
+ (0, import_type_graphql3.Field)(() => String, {
301
+ nullable: true
302
+ }),
303
+ _ts_metadata2("design:type", String)
304
+ ], TextMessageInput.prototype, "parentMessageId", void 0);
305
+ _ts_decorate2([
306
+ (0, import_type_graphql3.Field)(() => MessageRole),
307
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
308
+ ], TextMessageInput.prototype, "role", void 0);
309
+ TextMessageInput = _ts_decorate2([
310
+ (0, import_type_graphql3.InputType)()
311
+ ], TextMessageInput);
312
+ var ActionExecutionMessageInput = class {
313
+ name;
314
+ arguments;
315
+ parentMessageId;
316
+ scope;
317
+ };
318
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
319
+ _ts_decorate2([
320
+ (0, import_type_graphql3.Field)(() => String),
321
+ _ts_metadata2("design:type", String)
322
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
323
+ _ts_decorate2([
324
+ (0, import_type_graphql3.Field)(() => String),
325
+ _ts_metadata2("design:type", String)
326
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
327
+ _ts_decorate2([
328
+ (0, import_type_graphql3.Field)(() => String, {
329
+ nullable: true
330
+ }),
331
+ _ts_metadata2("design:type", String)
332
+ ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
333
+ _ts_decorate2([
334
+ (0, import_type_graphql3.Field)(() => String, {
335
+ nullable: true,
336
+ deprecationReason: "This field will be removed in a future version"
337
+ }),
338
+ _ts_metadata2("design:type", typeof String === "undefined" ? Object : String)
339
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
340
+ ActionExecutionMessageInput = _ts_decorate2([
341
+ (0, import_type_graphql3.InputType)()
342
+ ], ActionExecutionMessageInput);
343
+ var ResultMessageInput = class {
344
+ actionExecutionId;
345
+ actionName;
346
+ parentMessageId;
347
+ result;
348
+ };
349
+ __name(ResultMessageInput, "ResultMessageInput");
350
+ _ts_decorate2([
351
+ (0, import_type_graphql3.Field)(() => String),
352
+ _ts_metadata2("design:type", String)
353
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
354
+ _ts_decorate2([
355
+ (0, import_type_graphql3.Field)(() => String),
356
+ _ts_metadata2("design:type", String)
357
+ ], ResultMessageInput.prototype, "actionName", void 0);
358
+ _ts_decorate2([
359
+ (0, import_type_graphql3.Field)(() => String, {
360
+ nullable: true
361
+ }),
362
+ _ts_metadata2("design:type", String)
363
+ ], ResultMessageInput.prototype, "parentMessageId", void 0);
364
+ _ts_decorate2([
365
+ (0, import_type_graphql3.Field)(() => String),
366
+ _ts_metadata2("design:type", String)
367
+ ], ResultMessageInput.prototype, "result", void 0);
368
+ ResultMessageInput = _ts_decorate2([
369
+ (0, import_type_graphql3.InputType)()
370
+ ], ResultMessageInput);
371
+ var AgentStateMessageInput = class {
372
+ threadId;
373
+ agentName;
374
+ role;
375
+ state;
376
+ running;
377
+ nodeName;
378
+ runId;
379
+ active;
380
+ };
381
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
382
+ _ts_decorate2([
383
+ (0, import_type_graphql3.Field)(() => String),
384
+ _ts_metadata2("design:type", String)
385
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
386
+ _ts_decorate2([
387
+ (0, import_type_graphql3.Field)(() => String),
388
+ _ts_metadata2("design:type", String)
389
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
390
+ _ts_decorate2([
391
+ (0, import_type_graphql3.Field)(() => MessageRole),
392
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
393
+ ], AgentStateMessageInput.prototype, "role", void 0);
394
+ _ts_decorate2([
395
+ (0, import_type_graphql3.Field)(() => String),
396
+ _ts_metadata2("design:type", String)
397
+ ], AgentStateMessageInput.prototype, "state", void 0);
398
+ _ts_decorate2([
399
+ (0, import_type_graphql3.Field)(() => Boolean),
400
+ _ts_metadata2("design:type", Boolean)
401
+ ], AgentStateMessageInput.prototype, "running", void 0);
402
+ _ts_decorate2([
403
+ (0, import_type_graphql3.Field)(() => String),
404
+ _ts_metadata2("design:type", String)
405
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
406
+ _ts_decorate2([
407
+ (0, import_type_graphql3.Field)(() => String),
408
+ _ts_metadata2("design:type", String)
409
+ ], AgentStateMessageInput.prototype, "runId", void 0);
410
+ _ts_decorate2([
411
+ (0, import_type_graphql3.Field)(() => Boolean),
412
+ _ts_metadata2("design:type", Boolean)
413
+ ], AgentStateMessageInput.prototype, "active", void 0);
414
+ AgentStateMessageInput = _ts_decorate2([
415
+ (0, import_type_graphql3.InputType)()
416
+ ], AgentStateMessageInput);
417
+ var ImageMessageInput = class {
418
+ format;
419
+ bytes;
420
+ parentMessageId;
421
+ role;
422
+ };
423
+ __name(ImageMessageInput, "ImageMessageInput");
424
+ _ts_decorate2([
425
+ (0, import_type_graphql3.Field)(() => String),
426
+ _ts_metadata2("design:type", String)
427
+ ], ImageMessageInput.prototype, "format", void 0);
428
+ _ts_decorate2([
429
+ (0, import_type_graphql3.Field)(() => String),
430
+ _ts_metadata2("design:type", String)
431
+ ], ImageMessageInput.prototype, "bytes", void 0);
432
+ _ts_decorate2([
433
+ (0, import_type_graphql3.Field)(() => String, {
434
+ nullable: true
435
+ }),
436
+ _ts_metadata2("design:type", String)
437
+ ], ImageMessageInput.prototype, "parentMessageId", void 0);
438
+ _ts_decorate2([
439
+ (0, import_type_graphql3.Field)(() => MessageRole),
440
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
441
+ ], ImageMessageInput.prototype, "role", void 0);
442
+ ImageMessageInput = _ts_decorate2([
443
+ (0, import_type_graphql3.InputType)()
444
+ ], ImageMessageInput);
445
+
446
+ // src/graphql/inputs/frontend.input.ts
447
+ var import_type_graphql5 = require("type-graphql");
448
+
449
+ // src/graphql/inputs/action.input.ts
450
+ var import_type_graphql4 = require("type-graphql");
451
+ function _ts_decorate3(decorators, target, key, desc) {
452
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
453
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
454
+ r = Reflect.decorate(decorators, target, key, desc);
455
+ else
456
+ for (var i = decorators.length - 1; i >= 0; i--)
457
+ if (d = decorators[i])
458
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
459
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
460
+ }
461
+ __name(_ts_decorate3, "_ts_decorate");
462
+ function _ts_metadata3(k, v) {
463
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
464
+ return Reflect.metadata(k, v);
465
+ }
466
+ __name(_ts_metadata3, "_ts_metadata");
467
+ var ActionInput = class {
468
+ name;
469
+ description;
470
+ jsonSchema;
471
+ available;
472
+ };
473
+ __name(ActionInput, "ActionInput");
474
+ _ts_decorate3([
475
+ (0, import_type_graphql4.Field)(() => String),
476
+ _ts_metadata3("design:type", String)
477
+ ], ActionInput.prototype, "name", void 0);
478
+ _ts_decorate3([
479
+ (0, import_type_graphql4.Field)(() => String),
480
+ _ts_metadata3("design:type", String)
481
+ ], ActionInput.prototype, "description", void 0);
482
+ _ts_decorate3([
483
+ (0, import_type_graphql4.Field)(() => String),
484
+ _ts_metadata3("design:type", String)
485
+ ], ActionInput.prototype, "jsonSchema", void 0);
486
+ _ts_decorate3([
487
+ (0, import_type_graphql4.Field)(() => ActionInputAvailability, {
488
+ nullable: true
489
+ }),
490
+ _ts_metadata3("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
491
+ ], ActionInput.prototype, "available", void 0);
492
+ ActionInput = _ts_decorate3([
493
+ (0, import_type_graphql4.InputType)()
494
+ ], ActionInput);
495
+
496
+ // src/graphql/inputs/frontend.input.ts
497
+ function _ts_decorate4(decorators, target, key, desc) {
498
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
499
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
500
+ r = Reflect.decorate(decorators, target, key, desc);
501
+ else
502
+ for (var i = decorators.length - 1; i >= 0; i--)
503
+ if (d = decorators[i])
504
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
505
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
506
+ }
507
+ __name(_ts_decorate4, "_ts_decorate");
508
+ function _ts_metadata4(k, v) {
509
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
510
+ return Reflect.metadata(k, v);
511
+ }
512
+ __name(_ts_metadata4, "_ts_metadata");
513
+ var FrontendInput = class {
514
+ toDeprecate_fullContext;
515
+ actions;
516
+ url;
517
+ };
518
+ __name(FrontendInput, "FrontendInput");
519
+ _ts_decorate4([
520
+ (0, import_type_graphql5.Field)(() => String, {
521
+ nullable: true
522
+ }),
523
+ _ts_metadata4("design:type", String)
524
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
525
+ _ts_decorate4([
526
+ (0, import_type_graphql5.Field)(() => [
527
+ ActionInput
528
+ ]),
529
+ _ts_metadata4("design:type", Array)
530
+ ], FrontendInput.prototype, "actions", void 0);
531
+ _ts_decorate4([
532
+ (0, import_type_graphql5.Field)(() => String, {
533
+ nullable: true
534
+ }),
535
+ _ts_metadata4("design:type", String)
536
+ ], FrontendInput.prototype, "url", void 0);
537
+ FrontendInput = _ts_decorate4([
538
+ (0, import_type_graphql5.InputType)()
539
+ ], FrontendInput);
540
+
541
+ // src/graphql/inputs/cloud.input.ts
542
+ var import_type_graphql7 = require("type-graphql");
543
+
544
+ // src/graphql/inputs/cloud-guardrails.input.ts
545
+ var import_type_graphql6 = require("type-graphql");
546
+ function _ts_decorate5(decorators, target, key, desc) {
547
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
548
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
549
+ r = Reflect.decorate(decorators, target, key, desc);
550
+ else
551
+ for (var i = decorators.length - 1; i >= 0; i--)
552
+ if (d = decorators[i])
553
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
554
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
555
+ }
556
+ __name(_ts_decorate5, "_ts_decorate");
557
+ function _ts_metadata5(k, v) {
558
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
559
+ return Reflect.metadata(k, v);
560
+ }
561
+ __name(_ts_metadata5, "_ts_metadata");
562
+ var GuardrailsRuleInput = class {
563
+ allowList = [];
564
+ denyList = [];
565
+ };
566
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
567
+ _ts_decorate5([
568
+ (0, import_type_graphql6.Field)(() => [
569
+ String
570
+ ], {
571
+ nullable: true
572
+ }),
573
+ _ts_metadata5("design:type", Array)
574
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
575
+ _ts_decorate5([
576
+ (0, import_type_graphql6.Field)(() => [
577
+ String
578
+ ], {
579
+ nullable: true
580
+ }),
581
+ _ts_metadata5("design:type", Array)
582
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
583
+ GuardrailsRuleInput = _ts_decorate5([
584
+ (0, import_type_graphql6.InputType)()
585
+ ], GuardrailsRuleInput);
586
+ var GuardrailsInput = class {
587
+ inputValidationRules;
588
+ };
589
+ __name(GuardrailsInput, "GuardrailsInput");
590
+ _ts_decorate5([
591
+ (0, import_type_graphql6.Field)(() => GuardrailsRuleInput, {
592
+ nullable: false
593
+ }),
594
+ _ts_metadata5("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
595
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
596
+ GuardrailsInput = _ts_decorate5([
597
+ (0, import_type_graphql6.InputType)()
598
+ ], GuardrailsInput);
599
+
600
+ // src/graphql/inputs/cloud.input.ts
601
+ function _ts_decorate6(decorators, target, key, desc) {
602
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
603
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
604
+ r = Reflect.decorate(decorators, target, key, desc);
605
+ else
606
+ for (var i = decorators.length - 1; i >= 0; i--)
607
+ if (d = decorators[i])
608
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
609
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
610
+ }
611
+ __name(_ts_decorate6, "_ts_decorate");
612
+ function _ts_metadata6(k, v) {
613
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
614
+ return Reflect.metadata(k, v);
615
+ }
616
+ __name(_ts_metadata6, "_ts_metadata");
617
+ var CloudInput = class {
618
+ guardrails;
619
+ };
620
+ __name(CloudInput, "CloudInput");
621
+ _ts_decorate6([
622
+ (0, import_type_graphql7.Field)(() => GuardrailsInput, {
623
+ nullable: true
624
+ }),
625
+ _ts_metadata6("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
626
+ ], CloudInput.prototype, "guardrails", void 0);
627
+ CloudInput = _ts_decorate6([
628
+ (0, import_type_graphql7.InputType)()
629
+ ], CloudInput);
630
+
631
+ // src/graphql/inputs/forwarded-parameters.input.ts
632
+ var import_type_graphql8 = require("type-graphql");
633
+ function _ts_decorate7(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_decorate7, "_ts_decorate");
644
+ function _ts_metadata7(k, v) {
645
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
646
+ return Reflect.metadata(k, v);
647
+ }
648
+ __name(_ts_metadata7, "_ts_metadata");
649
+ var ForwardedParametersInput = class {
650
+ model;
651
+ maxTokens;
652
+ stop;
653
+ toolChoice;
654
+ toolChoiceFunctionName;
655
+ temperature;
656
+ };
657
+ __name(ForwardedParametersInput, "ForwardedParametersInput");
658
+ _ts_decorate7([
659
+ (0, import_type_graphql8.Field)(() => String, {
660
+ nullable: true
661
+ }),
662
+ _ts_metadata7("design:type", String)
663
+ ], ForwardedParametersInput.prototype, "model", void 0);
664
+ _ts_decorate7([
665
+ (0, import_type_graphql8.Field)(() => Number, {
666
+ nullable: true
667
+ }),
668
+ _ts_metadata7("design:type", Number)
669
+ ], ForwardedParametersInput.prototype, "maxTokens", void 0);
670
+ _ts_decorate7([
671
+ (0, import_type_graphql8.Field)(() => [
672
+ String
673
+ ], {
674
+ nullable: true
675
+ }),
676
+ _ts_metadata7("design:type", Array)
677
+ ], ForwardedParametersInput.prototype, "stop", void 0);
678
+ _ts_decorate7([
679
+ (0, import_type_graphql8.Field)(() => String, {
680
+ nullable: true
681
+ }),
682
+ _ts_metadata7("design:type", typeof String === "undefined" ? Object : String)
683
+ ], ForwardedParametersInput.prototype, "toolChoice", void 0);
684
+ _ts_decorate7([
685
+ (0, import_type_graphql8.Field)(() => String, {
686
+ nullable: true
687
+ }),
688
+ _ts_metadata7("design:type", String)
689
+ ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
690
+ _ts_decorate7([
691
+ (0, import_type_graphql8.Field)(() => Number, {
692
+ nullable: true
693
+ }),
694
+ _ts_metadata7("design:type", Number)
695
+ ], ForwardedParametersInput.prototype, "temperature", void 0);
696
+ ForwardedParametersInput = _ts_decorate7([
697
+ (0, import_type_graphql8.InputType)()
698
+ ], ForwardedParametersInput);
699
+
700
+ // src/graphql/inputs/agent-session.input.ts
701
+ var import_type_graphql9 = require("type-graphql");
702
+ function _ts_decorate8(decorators, target, key, desc) {
703
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
704
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
705
+ r = Reflect.decorate(decorators, target, key, desc);
706
+ else
707
+ for (var i = decorators.length - 1; i >= 0; i--)
708
+ if (d = decorators[i])
709
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
710
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
711
+ }
712
+ __name(_ts_decorate8, "_ts_decorate");
713
+ function _ts_metadata8(k, v) {
714
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
715
+ return Reflect.metadata(k, v);
716
+ }
717
+ __name(_ts_metadata8, "_ts_metadata");
718
+ var AgentSessionInput = class {
719
+ agentName;
720
+ threadId;
721
+ nodeName;
722
+ };
723
+ __name(AgentSessionInput, "AgentSessionInput");
724
+ _ts_decorate8([
725
+ (0, import_type_graphql9.Field)(() => String),
726
+ _ts_metadata8("design:type", String)
727
+ ], AgentSessionInput.prototype, "agentName", void 0);
728
+ _ts_decorate8([
729
+ (0, import_type_graphql9.Field)(() => String, {
730
+ nullable: true
731
+ }),
732
+ _ts_metadata8("design:type", String)
733
+ ], AgentSessionInput.prototype, "threadId", void 0);
734
+ _ts_decorate8([
735
+ (0, import_type_graphql9.Field)(() => String, {
736
+ nullable: true
737
+ }),
738
+ _ts_metadata8("design:type", String)
739
+ ], AgentSessionInput.prototype, "nodeName", void 0);
740
+ AgentSessionInput = _ts_decorate8([
741
+ (0, import_type_graphql9.InputType)()
742
+ ], AgentSessionInput);
743
+
744
+ // src/graphql/inputs/agent-state.input.ts
745
+ var import_type_graphql10 = require("type-graphql");
746
+ function _ts_decorate9(decorators, target, key, desc) {
747
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
748
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
749
+ r = Reflect.decorate(decorators, target, key, desc);
750
+ else
751
+ for (var i = decorators.length - 1; i >= 0; i--)
752
+ if (d = decorators[i])
753
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
754
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
755
+ }
756
+ __name(_ts_decorate9, "_ts_decorate");
757
+ function _ts_metadata9(k, v) {
758
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
759
+ return Reflect.metadata(k, v);
760
+ }
761
+ __name(_ts_metadata9, "_ts_metadata");
762
+ var AgentStateInput = class {
763
+ agentName;
764
+ state;
765
+ config;
766
+ };
767
+ __name(AgentStateInput, "AgentStateInput");
768
+ _ts_decorate9([
769
+ (0, import_type_graphql10.Field)(() => String),
770
+ _ts_metadata9("design:type", String)
771
+ ], AgentStateInput.prototype, "agentName", void 0);
772
+ _ts_decorate9([
773
+ (0, import_type_graphql10.Field)(() => String),
774
+ _ts_metadata9("design:type", String)
775
+ ], AgentStateInput.prototype, "state", void 0);
776
+ _ts_decorate9([
777
+ (0, import_type_graphql10.Field)(() => String, {
778
+ nullable: true
779
+ }),
780
+ _ts_metadata9("design:type", String)
781
+ ], AgentStateInput.prototype, "config", void 0);
782
+ AgentStateInput = _ts_decorate9([
783
+ (0, import_type_graphql10.InputType)()
784
+ ], AgentStateInput);
785
+
786
+ // src/graphql/inputs/extensions.input.ts
787
+ var import_type_graphql11 = require("type-graphql");
788
+ function _ts_decorate10(decorators, target, key, desc) {
789
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
790
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
791
+ r = Reflect.decorate(decorators, target, key, desc);
792
+ else
793
+ for (var i = decorators.length - 1; i >= 0; i--)
794
+ if (d = decorators[i])
795
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
796
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
797
+ }
798
+ __name(_ts_decorate10, "_ts_decorate");
799
+ function _ts_metadata10(k, v) {
800
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
801
+ return Reflect.metadata(k, v);
802
+ }
803
+ __name(_ts_metadata10, "_ts_metadata");
804
+ var ExtensionsInput = class {
805
+ openaiAssistantAPI;
806
+ };
807
+ __name(ExtensionsInput, "ExtensionsInput");
808
+ _ts_decorate10([
809
+ (0, import_type_graphql11.Field)(() => OpenAIApiAssistantAPIInput, {
810
+ nullable: true
811
+ }),
812
+ _ts_metadata10("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
813
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
814
+ ExtensionsInput = _ts_decorate10([
815
+ (0, import_type_graphql11.InputType)()
816
+ ], ExtensionsInput);
817
+ var OpenAIApiAssistantAPIInput = class {
818
+ runId;
819
+ threadId;
820
+ };
821
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
822
+ _ts_decorate10([
823
+ (0, import_type_graphql11.Field)(() => String, {
824
+ nullable: true
825
+ }),
826
+ _ts_metadata10("design:type", String)
827
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
828
+ _ts_decorate10([
829
+ (0, import_type_graphql11.Field)(() => String, {
830
+ nullable: true
831
+ }),
832
+ _ts_metadata10("design:type", String)
833
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
834
+ OpenAIApiAssistantAPIInput = _ts_decorate10([
835
+ (0, import_type_graphql11.InputType)()
836
+ ], OpenAIApiAssistantAPIInput);
837
+
838
+ // src/graphql/inputs/meta-event.input.ts
839
+ var import_type_graphql17 = require("type-graphql");
840
+
841
+ // src/graphql/types/meta-events.type.ts
842
+ var import_type_graphql16 = require("type-graphql");
843
+
844
+ // src/graphql/types/copilot-response.type.ts
845
+ var import_type_graphql15 = require("type-graphql");
846
+
847
+ // src/graphql/types/message-status.type.ts
848
+ var import_type_graphql12 = require("type-graphql");
849
+ function _ts_decorate11(decorators, target, key, desc) {
850
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
851
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
852
+ r = Reflect.decorate(decorators, target, key, desc);
853
+ else
854
+ for (var i = decorators.length - 1; i >= 0; i--)
855
+ if (d = decorators[i])
856
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
857
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
858
+ }
859
+ __name(_ts_decorate11, "_ts_decorate");
860
+ function _ts_metadata11(k, v) {
861
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
862
+ return Reflect.metadata(k, v);
863
+ }
864
+ __name(_ts_metadata11, "_ts_metadata");
865
+ var MessageStatusCode;
866
+ (function(MessageStatusCode2) {
867
+ MessageStatusCode2["Pending"] = "pending";
868
+ MessageStatusCode2["Success"] = "success";
869
+ MessageStatusCode2["Failed"] = "failed";
870
+ })(MessageStatusCode || (MessageStatusCode = {}));
871
+ (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
872
+ name: "MessageStatusCode"
873
+ });
874
+ var BaseMessageStatus = class {
875
+ code;
876
+ };
877
+ __name(BaseMessageStatus, "BaseMessageStatus");
878
+ _ts_decorate11([
879
+ (0, import_type_graphql12.Field)(() => MessageStatusCode),
880
+ _ts_metadata11("design:type", String)
881
+ ], BaseMessageStatus.prototype, "code", void 0);
882
+ BaseMessageStatus = _ts_decorate11([
883
+ (0, import_type_graphql12.ObjectType)()
884
+ ], BaseMessageStatus);
885
+ var PendingMessageStatus = class extends BaseMessageStatus {
886
+ code = "pending";
887
+ };
888
+ __name(PendingMessageStatus, "PendingMessageStatus");
889
+ PendingMessageStatus = _ts_decorate11([
890
+ (0, import_type_graphql12.ObjectType)()
891
+ ], PendingMessageStatus);
892
+ var SuccessMessageStatus = class extends BaseMessageStatus {
893
+ code = "success";
894
+ };
895
+ __name(SuccessMessageStatus, "SuccessMessageStatus");
896
+ SuccessMessageStatus = _ts_decorate11([
897
+ (0, import_type_graphql12.ObjectType)()
898
+ ], SuccessMessageStatus);
899
+ var FailedMessageStatus = class extends BaseMessageStatus {
900
+ code = "failed";
901
+ reason;
902
+ };
903
+ __name(FailedMessageStatus, "FailedMessageStatus");
904
+ _ts_decorate11([
905
+ (0, import_type_graphql12.Field)(() => String),
906
+ _ts_metadata11("design:type", String)
907
+ ], FailedMessageStatus.prototype, "reason", void 0);
908
+ FailedMessageStatus = _ts_decorate11([
909
+ (0, import_type_graphql12.ObjectType)()
910
+ ], FailedMessageStatus);
911
+ var MessageStatusUnion = (0, import_type_graphql12.createUnionType)({
912
+ name: "MessageStatus",
913
+ types: () => [
914
+ PendingMessageStatus,
915
+ SuccessMessageStatus,
916
+ FailedMessageStatus
917
+ ]
918
+ });
919
+
920
+ // src/graphql/types/response-status.type.ts
921
+ var import_graphql_scalars = require("graphql-scalars");
922
+ var import_type_graphql13 = require("type-graphql");
923
+ function _ts_decorate12(decorators, target, key, desc) {
924
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
925
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
926
+ r = Reflect.decorate(decorators, target, key, desc);
927
+ else
928
+ for (var i = decorators.length - 1; i >= 0; i--)
929
+ if (d = decorators[i])
930
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
931
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
932
+ }
933
+ __name(_ts_decorate12, "_ts_decorate");
934
+ function _ts_metadata12(k, v) {
935
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
936
+ return Reflect.metadata(k, v);
937
+ }
938
+ __name(_ts_metadata12, "_ts_metadata");
939
+ var ResponseStatusCode;
940
+ (function(ResponseStatusCode2) {
941
+ ResponseStatusCode2["Pending"] = "pending";
942
+ ResponseStatusCode2["Success"] = "success";
943
+ ResponseStatusCode2["Failed"] = "failed";
944
+ })(ResponseStatusCode || (ResponseStatusCode = {}));
945
+ (0, import_type_graphql13.registerEnumType)(ResponseStatusCode, {
946
+ name: "ResponseStatusCode"
947
+ });
948
+ var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
949
+ code;
950
+ }, "BaseResponseStatus");
951
+ _ts_decorate12([
952
+ (0, import_type_graphql13.Field)(() => ResponseStatusCode),
953
+ _ts_metadata12("design:type", String)
954
+ ], BaseResponseStatus.prototype, "code", void 0);
955
+ BaseResponseStatus = _ts_decorate12([
956
+ (0, import_type_graphql13.InterfaceType)({
957
+ resolveType(value) {
958
+ if (value.code === "success") {
959
+ return SuccessResponseStatus;
960
+ } else if (value.code === "failed") {
961
+ return FailedResponseStatus;
962
+ } else if (value.code === "pending") {
963
+ return PendingResponseStatus;
964
+ }
965
+ return void 0;
966
+ }
967
+ }),
968
+ (0, import_type_graphql13.ObjectType)()
969
+ ], BaseResponseStatus);
970
+ var PendingResponseStatus = class extends BaseResponseStatus {
971
+ code = "pending";
972
+ };
973
+ __name(PendingResponseStatus, "PendingResponseStatus");
974
+ PendingResponseStatus = _ts_decorate12([
975
+ (0, import_type_graphql13.ObjectType)({
976
+ implements: BaseResponseStatus
977
+ })
978
+ ], PendingResponseStatus);
979
+ var SuccessResponseStatus = class extends BaseResponseStatus {
980
+ code = "success";
981
+ };
982
+ __name(SuccessResponseStatus, "SuccessResponseStatus");
983
+ SuccessResponseStatus = _ts_decorate12([
984
+ (0, import_type_graphql13.ObjectType)({
985
+ implements: BaseResponseStatus
986
+ })
987
+ ], SuccessResponseStatus);
988
+ var FailedResponseStatusReason;
989
+ (function(FailedResponseStatusReason2) {
990
+ FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
991
+ FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
992
+ FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
993
+ })(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
994
+ (0, import_type_graphql13.registerEnumType)(FailedResponseStatusReason, {
995
+ name: "FailedResponseStatusReason"
996
+ });
997
+ var FailedResponseStatus = class extends BaseResponseStatus {
998
+ code = "failed";
999
+ reason;
1000
+ details = null;
1001
+ };
1002
+ __name(FailedResponseStatus, "FailedResponseStatus");
1003
+ _ts_decorate12([
1004
+ (0, import_type_graphql13.Field)(() => FailedResponseStatusReason),
1005
+ _ts_metadata12("design:type", String)
1006
+ ], FailedResponseStatus.prototype, "reason", void 0);
1007
+ _ts_decorate12([
1008
+ (0, import_type_graphql13.Field)(() => import_graphql_scalars.GraphQLJSON, {
1009
+ nullable: true
1010
+ }),
1011
+ _ts_metadata12("design:type", typeof Record === "undefined" ? Object : Record)
1012
+ ], FailedResponseStatus.prototype, "details", void 0);
1013
+ FailedResponseStatus = _ts_decorate12([
1014
+ (0, import_type_graphql13.ObjectType)({
1015
+ implements: BaseResponseStatus
1016
+ })
1017
+ ], FailedResponseStatus);
1018
+ var ResponseStatusUnion = (0, import_type_graphql13.createUnionType)({
1019
+ name: "ResponseStatus",
1020
+ types: () => [
1021
+ PendingResponseStatus,
1022
+ SuccessResponseStatus,
1023
+ FailedResponseStatus
1024
+ ]
1025
+ });
1026
+
1027
+ // src/graphql/types/extensions-response.type.ts
1028
+ var import_type_graphql14 = require("type-graphql");
1029
+ function _ts_decorate13(decorators, target, key, desc) {
1030
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1031
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1032
+ r = Reflect.decorate(decorators, target, key, desc);
1033
+ else
1034
+ for (var i = decorators.length - 1; i >= 0; i--)
1035
+ if (d = decorators[i])
1036
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1037
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1038
+ }
1039
+ __name(_ts_decorate13, "_ts_decorate");
1040
+ function _ts_metadata13(k, v) {
1041
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1042
+ return Reflect.metadata(k, v);
1043
+ }
1044
+ __name(_ts_metadata13, "_ts_metadata");
1045
+ var ExtensionsResponse = class {
1046
+ openaiAssistantAPI;
1047
+ };
1048
+ __name(ExtensionsResponse, "ExtensionsResponse");
1049
+ _ts_decorate13([
1050
+ (0, import_type_graphql14.Field)(() => OpenAIApiAssistantAPIResponse, {
1051
+ nullable: true
1052
+ }),
1053
+ _ts_metadata13("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
1054
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
1055
+ ExtensionsResponse = _ts_decorate13([
1056
+ (0, import_type_graphql14.ObjectType)()
1057
+ ], ExtensionsResponse);
1058
+ var OpenAIApiAssistantAPIResponse = class {
1059
+ runId;
1060
+ threadId;
1061
+ };
1062
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
1063
+ _ts_decorate13([
1064
+ (0, import_type_graphql14.Field)(() => String, {
1065
+ nullable: true
1066
+ }),
1067
+ _ts_metadata13("design:type", String)
1068
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
1069
+ _ts_decorate13([
1070
+ (0, import_type_graphql14.Field)(() => String, {
1071
+ nullable: true
1072
+ }),
1073
+ _ts_metadata13("design:type", String)
1074
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
1075
+ OpenAIApiAssistantAPIResponse = _ts_decorate13([
1076
+ (0, import_type_graphql14.ObjectType)()
1077
+ ], OpenAIApiAssistantAPIResponse);
1078
+
1079
+ // src/graphql/types/copilot-response.type.ts
1080
+ function _ts_decorate14(decorators, target, key, desc) {
1081
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1082
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1083
+ r = Reflect.decorate(decorators, target, key, desc);
1084
+ else
1085
+ for (var i = decorators.length - 1; i >= 0; i--)
1086
+ if (d = decorators[i])
1087
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1088
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1089
+ }
1090
+ __name(_ts_decorate14, "_ts_decorate");
1091
+ function _ts_metadata14(k, v) {
1092
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1093
+ return Reflect.metadata(k, v);
1094
+ }
1095
+ __name(_ts_metadata14, "_ts_metadata");
1096
+ var BaseMessageOutput = class {
1097
+ id;
1098
+ createdAt;
1099
+ status;
1100
+ };
1101
+ __name(BaseMessageOutput, "BaseMessageOutput");
1102
+ _ts_decorate14([
1103
+ (0, import_type_graphql15.Field)(() => String),
1104
+ _ts_metadata14("design:type", String)
1105
+ ], BaseMessageOutput.prototype, "id", void 0);
1106
+ _ts_decorate14([
1107
+ (0, import_type_graphql15.Field)(() => Date),
1108
+ _ts_metadata14("design:type", typeof Date === "undefined" ? Object : Date)
1109
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
1110
+ _ts_decorate14([
1111
+ (0, import_type_graphql15.Field)(() => MessageStatusUnion),
1112
+ _ts_metadata14("design:type", Object)
1113
+ ], BaseMessageOutput.prototype, "status", void 0);
1114
+ BaseMessageOutput = _ts_decorate14([
1115
+ (0, import_type_graphql15.InterfaceType)({
1116
+ resolveType(value) {
1117
+ if (value.hasOwnProperty("content")) {
1118
+ return TextMessageOutput;
1119
+ } else if (value.hasOwnProperty("name")) {
1120
+ return ActionExecutionMessageOutput;
1121
+ } else if (value.hasOwnProperty("result")) {
1122
+ return ResultMessageOutput;
1123
+ } else if (value.hasOwnProperty("state")) {
1124
+ return AgentStateMessageOutput;
1125
+ } else if (value.hasOwnProperty("format") && value.hasOwnProperty("bytes")) {
1126
+ return ImageMessageOutput;
1127
+ }
1128
+ return void 0;
1129
+ }
1130
+ })
1131
+ ], BaseMessageOutput);
1132
+ var TextMessageOutput = class {
1133
+ role;
1134
+ content;
1135
+ parentMessageId;
1136
+ };
1137
+ __name(TextMessageOutput, "TextMessageOutput");
1138
+ _ts_decorate14([
1139
+ (0, import_type_graphql15.Field)(() => MessageRole),
1140
+ _ts_metadata14("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1141
+ ], TextMessageOutput.prototype, "role", void 0);
1142
+ _ts_decorate14([
1143
+ (0, import_type_graphql15.Field)(() => [
1144
+ String
1145
+ ]),
1146
+ _ts_metadata14("design:type", Array)
1147
+ ], TextMessageOutput.prototype, "content", void 0);
1148
+ _ts_decorate14([
1149
+ (0, import_type_graphql15.Field)(() => String, {
1150
+ nullable: true
1151
+ }),
1152
+ _ts_metadata14("design:type", String)
1153
+ ], TextMessageOutput.prototype, "parentMessageId", void 0);
1154
+ TextMessageOutput = _ts_decorate14([
1155
+ (0, import_type_graphql15.ObjectType)({
1156
+ implements: BaseMessageOutput
1157
+ })
1158
+ ], TextMessageOutput);
1159
+ var ActionExecutionMessageOutput = class {
1160
+ name;
1161
+ scope;
1162
+ arguments;
1163
+ parentMessageId;
1164
+ };
1165
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
1166
+ _ts_decorate14([
1167
+ (0, import_type_graphql15.Field)(() => String),
1168
+ _ts_metadata14("design:type", String)
1169
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
1170
+ _ts_decorate14([
1171
+ (0, import_type_graphql15.Field)(() => String, {
1172
+ nullable: true,
1173
+ deprecationReason: "This field will be removed in a future version"
1174
+ }),
1175
+ _ts_metadata14("design:type", String)
1176
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
1177
+ _ts_decorate14([
1178
+ (0, import_type_graphql15.Field)(() => [
1179
+ String
1180
+ ]),
1181
+ _ts_metadata14("design:type", Array)
1182
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
1183
+ _ts_decorate14([
1184
+ (0, import_type_graphql15.Field)(() => String, {
1185
+ nullable: true
1186
+ }),
1187
+ _ts_metadata14("design:type", String)
1188
+ ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
1189
+ ActionExecutionMessageOutput = _ts_decorate14([
1190
+ (0, import_type_graphql15.ObjectType)({
1191
+ implements: BaseMessageOutput
1192
+ })
1193
+ ], ActionExecutionMessageOutput);
1194
+ var ResultMessageOutput = class {
1195
+ actionExecutionId;
1196
+ actionName;
1197
+ result;
1198
+ };
1199
+ __name(ResultMessageOutput, "ResultMessageOutput");
1200
+ _ts_decorate14([
1201
+ (0, import_type_graphql15.Field)(() => String),
1202
+ _ts_metadata14("design:type", String)
1203
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
1204
+ _ts_decorate14([
1205
+ (0, import_type_graphql15.Field)(() => String),
1206
+ _ts_metadata14("design:type", String)
1207
+ ], ResultMessageOutput.prototype, "actionName", void 0);
1208
+ _ts_decorate14([
1209
+ (0, import_type_graphql15.Field)(() => String),
1210
+ _ts_metadata14("design:type", String)
1211
+ ], ResultMessageOutput.prototype, "result", void 0);
1212
+ ResultMessageOutput = _ts_decorate14([
1213
+ (0, import_type_graphql15.ObjectType)({
1214
+ implements: BaseMessageOutput
1215
+ })
1216
+ ], ResultMessageOutput);
1217
+ var AgentStateMessageOutput = class {
1218
+ threadId;
1219
+ agentName;
1220
+ nodeName;
1221
+ runId;
1222
+ active;
1223
+ role;
1224
+ state;
1225
+ running;
1226
+ };
1227
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
1228
+ _ts_decorate14([
1229
+ (0, import_type_graphql15.Field)(() => String),
1230
+ _ts_metadata14("design:type", String)
1231
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
1232
+ _ts_decorate14([
1233
+ (0, import_type_graphql15.Field)(() => String),
1234
+ _ts_metadata14("design:type", String)
1235
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
1236
+ _ts_decorate14([
1237
+ (0, import_type_graphql15.Field)(() => String),
1238
+ _ts_metadata14("design:type", String)
1239
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
1240
+ _ts_decorate14([
1241
+ (0, import_type_graphql15.Field)(() => String),
1242
+ _ts_metadata14("design:type", String)
1243
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
1244
+ _ts_decorate14([
1245
+ (0, import_type_graphql15.Field)(() => Boolean),
1246
+ _ts_metadata14("design:type", Boolean)
1247
+ ], AgentStateMessageOutput.prototype, "active", void 0);
1248
+ _ts_decorate14([
1249
+ (0, import_type_graphql15.Field)(() => MessageRole),
1250
+ _ts_metadata14("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1251
+ ], AgentStateMessageOutput.prototype, "role", void 0);
1252
+ _ts_decorate14([
1253
+ (0, import_type_graphql15.Field)(() => String),
1254
+ _ts_metadata14("design:type", String)
1255
+ ], AgentStateMessageOutput.prototype, "state", void 0);
1256
+ _ts_decorate14([
1257
+ (0, import_type_graphql15.Field)(() => Boolean),
1258
+ _ts_metadata14("design:type", Boolean)
1259
+ ], AgentStateMessageOutput.prototype, "running", void 0);
1260
+ AgentStateMessageOutput = _ts_decorate14([
1261
+ (0, import_type_graphql15.ObjectType)({
1262
+ implements: BaseMessageOutput
1263
+ })
1264
+ ], AgentStateMessageOutput);
1265
+ var ImageMessageOutput = class {
1266
+ format;
1267
+ bytes;
1268
+ role;
1269
+ parentMessageId;
1270
+ };
1271
+ __name(ImageMessageOutput, "ImageMessageOutput");
1272
+ _ts_decorate14([
1273
+ (0, import_type_graphql15.Field)(() => String),
1274
+ _ts_metadata14("design:type", String)
1275
+ ], ImageMessageOutput.prototype, "format", void 0);
1276
+ _ts_decorate14([
1277
+ (0, import_type_graphql15.Field)(() => String),
1278
+ _ts_metadata14("design:type", String)
1279
+ ], ImageMessageOutput.prototype, "bytes", void 0);
1280
+ _ts_decorate14([
1281
+ (0, import_type_graphql15.Field)(() => MessageRole),
1282
+ _ts_metadata14("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1283
+ ], ImageMessageOutput.prototype, "role", void 0);
1284
+ _ts_decorate14([
1285
+ (0, import_type_graphql15.Field)(() => String, {
1286
+ nullable: true
1287
+ }),
1288
+ _ts_metadata14("design:type", String)
1289
+ ], ImageMessageOutput.prototype, "parentMessageId", void 0);
1290
+ ImageMessageOutput = _ts_decorate14([
1291
+ (0, import_type_graphql15.ObjectType)({
1292
+ implements: BaseMessageOutput
1293
+ })
1294
+ ], ImageMessageOutput);
1295
+ var CopilotResponse = class {
1296
+ threadId;
1297
+ status;
1298
+ runId;
1299
+ messages;
1300
+ extensions;
1301
+ metaEvents;
1302
+ };
1303
+ __name(CopilotResponse, "CopilotResponse");
1304
+ _ts_decorate14([
1305
+ (0, import_type_graphql15.Field)(() => String),
1306
+ _ts_metadata14("design:type", String)
1307
+ ], CopilotResponse.prototype, "threadId", void 0);
1308
+ _ts_decorate14([
1309
+ (0, import_type_graphql15.Field)(() => ResponseStatusUnion),
1310
+ _ts_metadata14("design:type", Object)
1311
+ ], CopilotResponse.prototype, "status", void 0);
1312
+ _ts_decorate14([
1313
+ (0, import_type_graphql15.Field)({
1314
+ nullable: true
1315
+ }),
1316
+ _ts_metadata14("design:type", String)
1317
+ ], CopilotResponse.prototype, "runId", void 0);
1318
+ _ts_decorate14([
1319
+ (0, import_type_graphql15.Field)(() => [
1320
+ BaseMessageOutput
1321
+ ]),
1322
+ _ts_metadata14("design:type", Array)
1323
+ ], CopilotResponse.prototype, "messages", void 0);
1324
+ _ts_decorate14([
1325
+ (0, import_type_graphql15.Field)(() => ExtensionsResponse, {
1326
+ nullable: true
1327
+ }),
1328
+ _ts_metadata14("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
1329
+ ], CopilotResponse.prototype, "extensions", void 0);
1330
+ _ts_decorate14([
1331
+ (0, import_type_graphql15.Field)(() => [
1332
+ BaseMetaEvent
1333
+ ], {
1334
+ nullable: true
1335
+ }),
1336
+ _ts_metadata14("design:type", Array)
1337
+ ], CopilotResponse.prototype, "metaEvents", void 0);
1338
+ CopilotResponse = _ts_decorate14([
1339
+ (0, import_type_graphql15.ObjectType)()
1340
+ ], CopilotResponse);
1341
+
1342
+ // src/graphql/types/meta-events.type.ts
1343
+ function _ts_decorate15(decorators, target, key, desc) {
1344
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1345
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1346
+ r = Reflect.decorate(decorators, target, key, desc);
1347
+ else
1348
+ for (var i = decorators.length - 1; i >= 0; i--)
1349
+ if (d = decorators[i])
1350
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1351
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1352
+ }
1353
+ __name(_ts_decorate15, "_ts_decorate");
1354
+ function _ts_metadata15(k, v) {
1355
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1356
+ return Reflect.metadata(k, v);
1357
+ }
1358
+ __name(_ts_metadata15, "_ts_metadata");
1359
+ var MetaEventName;
1360
+ (function(MetaEventName2) {
1361
+ MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1362
+ MetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1363
+ })(MetaEventName || (MetaEventName = {}));
1364
+ (0, import_type_graphql16.registerEnumType)(MetaEventName, {
1365
+ name: "MetaEventName",
1366
+ description: "Meta event types"
1367
+ });
1368
+ var BaseMetaEvent = class {
1369
+ type = "MetaEvent";
1370
+ name;
1371
+ };
1372
+ __name(BaseMetaEvent, "BaseMetaEvent");
1373
+ _ts_decorate15([
1374
+ (0, import_type_graphql16.Field)(() => String),
1375
+ _ts_metadata15("design:type", String)
1376
+ ], BaseMetaEvent.prototype, "type", void 0);
1377
+ _ts_decorate15([
1378
+ (0, import_type_graphql16.Field)(() => MetaEventName),
1379
+ _ts_metadata15("design:type", String)
1380
+ ], BaseMetaEvent.prototype, "name", void 0);
1381
+ BaseMetaEvent = _ts_decorate15([
1382
+ (0, import_type_graphql16.InterfaceType)({
1383
+ resolveType(value) {
1384
+ if (value.name === "LangGraphInterruptEvent") {
1385
+ return LangGraphInterruptEvent;
1386
+ } else if (value.name === "CopilotKitLangGraphInterruptEvent") {
1387
+ return CopilotKitLangGraphInterruptEvent;
1388
+ }
1389
+ return void 0;
1390
+ }
1391
+ }),
1392
+ (0, import_type_graphql16.InterfaceType)()
1393
+ ], BaseMetaEvent);
1394
+ var CopilotKitLangGraphInterruptEventData = class {
1395
+ value;
1396
+ messages;
1397
+ };
1398
+ __name(CopilotKitLangGraphInterruptEventData, "CopilotKitLangGraphInterruptEventData");
1399
+ _ts_decorate15([
1400
+ (0, import_type_graphql16.Field)(() => String),
1401
+ _ts_metadata15("design:type", String)
1402
+ ], CopilotKitLangGraphInterruptEventData.prototype, "value", void 0);
1403
+ _ts_decorate15([
1404
+ (0, import_type_graphql16.Field)(() => [
1405
+ BaseMessageOutput
1406
+ ]),
1407
+ _ts_metadata15("design:type", Array)
1408
+ ], CopilotKitLangGraphInterruptEventData.prototype, "messages", void 0);
1409
+ CopilotKitLangGraphInterruptEventData = _ts_decorate15([
1410
+ (0, import_type_graphql16.ObjectType)()
1411
+ ], CopilotKitLangGraphInterruptEventData);
1412
+ var LangGraphInterruptEvent = class {
1413
+ name = "LangGraphInterruptEvent";
1414
+ value;
1415
+ response;
1416
+ };
1417
+ __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
1418
+ _ts_decorate15([
1419
+ (0, import_type_graphql16.Field)(() => MetaEventName),
1420
+ _ts_metadata15("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
1421
+ ], LangGraphInterruptEvent.prototype, "name", void 0);
1422
+ _ts_decorate15([
1423
+ (0, import_type_graphql16.Field)(() => String),
1424
+ _ts_metadata15("design:type", String)
1425
+ ], LangGraphInterruptEvent.prototype, "value", void 0);
1426
+ _ts_decorate15([
1427
+ (0, import_type_graphql16.Field)(() => String, {
1428
+ nullable: true
1429
+ }),
1430
+ _ts_metadata15("design:type", String)
1431
+ ], LangGraphInterruptEvent.prototype, "response", void 0);
1432
+ LangGraphInterruptEvent = _ts_decorate15([
1433
+ (0, import_type_graphql16.ObjectType)({
1434
+ implements: BaseMetaEvent
1435
+ })
1436
+ ], LangGraphInterruptEvent);
1437
+ var CopilotKitLangGraphInterruptEvent = class {
1438
+ name = "CopilotKitLangGraphInterruptEvent";
1439
+ data;
1440
+ response;
1441
+ };
1442
+ __name(CopilotKitLangGraphInterruptEvent, "CopilotKitLangGraphInterruptEvent");
1443
+ _ts_decorate15([
1444
+ (0, import_type_graphql16.Field)(() => MetaEventName),
1445
+ _ts_metadata15("design:type", typeof MetaEventName === "undefined" || false ? Object : "CopilotKitLangGraphInterruptEvent")
1446
+ ], CopilotKitLangGraphInterruptEvent.prototype, "name", void 0);
1447
+ _ts_decorate15([
1448
+ (0, import_type_graphql16.Field)(() => CopilotKitLangGraphInterruptEventData),
1449
+ _ts_metadata15("design:type", typeof CopilotKitLangGraphInterruptEventData === "undefined" ? Object : CopilotKitLangGraphInterruptEventData)
1450
+ ], CopilotKitLangGraphInterruptEvent.prototype, "data", void 0);
1451
+ _ts_decorate15([
1452
+ (0, import_type_graphql16.Field)(() => String, {
1453
+ nullable: true
1454
+ }),
1455
+ _ts_metadata15("design:type", String)
1456
+ ], CopilotKitLangGraphInterruptEvent.prototype, "response", void 0);
1457
+ CopilotKitLangGraphInterruptEvent = _ts_decorate15([
1458
+ (0, import_type_graphql16.ObjectType)({
1459
+ implements: BaseMetaEvent
1460
+ })
1461
+ ], CopilotKitLangGraphInterruptEvent);
1462
+
1463
+ // src/graphql/inputs/meta-event.input.ts
1464
+ function _ts_decorate16(decorators, target, key, desc) {
1465
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1466
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1467
+ r = Reflect.decorate(decorators, target, key, desc);
1468
+ else
1469
+ for (var i = decorators.length - 1; i >= 0; i--)
1470
+ if (d = decorators[i])
1471
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1472
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1473
+ }
1474
+ __name(_ts_decorate16, "_ts_decorate");
1475
+ function _ts_metadata16(k, v) {
1476
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1477
+ return Reflect.metadata(k, v);
1478
+ }
1479
+ __name(_ts_metadata16, "_ts_metadata");
1480
+ var MetaEventInput = class {
1481
+ name;
1482
+ value;
1483
+ response;
1484
+ messages;
1485
+ };
1486
+ __name(MetaEventInput, "MetaEventInput");
1487
+ _ts_decorate16([
1488
+ (0, import_type_graphql17.Field)(() => MetaEventName),
1489
+ _ts_metadata16("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
1490
+ ], MetaEventInput.prototype, "name", void 0);
1491
+ _ts_decorate16([
1492
+ (0, import_type_graphql17.Field)(() => String),
1493
+ _ts_metadata16("design:type", String)
1494
+ ], MetaEventInput.prototype, "value", void 0);
1495
+ _ts_decorate16([
1496
+ (0, import_type_graphql17.Field)(() => String, {
1497
+ nullable: true
1498
+ }),
1499
+ _ts_metadata16("design:type", String)
1500
+ ], MetaEventInput.prototype, "response", void 0);
1501
+ _ts_decorate16([
1502
+ (0, import_type_graphql17.Field)(() => [
1503
+ MessageInput
1504
+ ], {
1505
+ nullable: true
1506
+ }),
1507
+ _ts_metadata16("design:type", Array)
1508
+ ], MetaEventInput.prototype, "messages", void 0);
1509
+ MetaEventInput = _ts_decorate16([
1510
+ (0, import_type_graphql17.InputType)()
1511
+ ], MetaEventInput);
1512
+
1513
+ // src/graphql/inputs/copilot-context.input.ts
1514
+ var import_type_graphql18 = require("type-graphql");
1515
+ function _ts_decorate17(decorators, target, key, desc) {
1516
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1517
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1518
+ r = Reflect.decorate(decorators, target, key, desc);
1519
+ else
1520
+ for (var i = decorators.length - 1; i >= 0; i--)
1521
+ if (d = decorators[i])
1522
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1523
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1524
+ }
1525
+ __name(_ts_decorate17, "_ts_decorate");
1526
+ function _ts_metadata17(k, v) {
1527
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1528
+ return Reflect.metadata(k, v);
1529
+ }
1530
+ __name(_ts_metadata17, "_ts_metadata");
1531
+ var CopilotContextInput = class {
1532
+ description;
1533
+ value;
1534
+ };
1535
+ __name(CopilotContextInput, "CopilotContextInput");
1536
+ _ts_decorate17([
1537
+ (0, import_type_graphql18.Field)(() => String),
1538
+ _ts_metadata17("design:type", String)
1539
+ ], CopilotContextInput.prototype, "description", void 0);
1540
+ _ts_decorate17([
1541
+ (0, import_type_graphql18.Field)(() => String),
1542
+ _ts_metadata17("design:type", String)
1543
+ ], CopilotContextInput.prototype, "value", void 0);
1544
+ CopilotContextInput = _ts_decorate17([
1545
+ (0, import_type_graphql18.InputType)()
1546
+ ], CopilotContextInput);
1547
+
1548
+ // src/graphql/inputs/generate-copilot-response.input.ts
1549
+ function _ts_decorate18(decorators, target, key, desc) {
1550
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1551
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1552
+ r = Reflect.decorate(decorators, target, key, desc);
1553
+ else
1554
+ for (var i = decorators.length - 1; i >= 0; i--)
1555
+ if (d = decorators[i])
1556
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1557
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1558
+ }
1559
+ __name(_ts_decorate18, "_ts_decorate");
1560
+ function _ts_metadata18(k, v) {
1561
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1562
+ return Reflect.metadata(k, v);
1563
+ }
1564
+ __name(_ts_metadata18, "_ts_metadata");
1565
+ var GenerateCopilotResponseMetadataInput = class {
1566
+ requestType;
1567
+ };
1568
+ __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
1569
+ _ts_decorate18([
1570
+ (0, import_type_graphql19.Field)(() => CopilotRequestType, {
1571
+ nullable: true
1572
+ }),
1573
+ _ts_metadata18("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
1574
+ ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
1575
+ GenerateCopilotResponseMetadataInput = _ts_decorate18([
1576
+ (0, import_type_graphql19.InputType)()
1577
+ ], GenerateCopilotResponseMetadataInput);
1578
+ var GenerateCopilotResponseInput = class {
1579
+ metadata;
1580
+ threadId;
1581
+ runId;
1582
+ messages;
1583
+ frontend;
1584
+ cloud;
1585
+ forwardedParameters;
1586
+ agentSession;
1587
+ agentState;
1588
+ agentStates;
1589
+ extensions;
1590
+ metaEvents;
1591
+ context;
1592
+ };
1593
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
1594
+ _ts_decorate18([
1595
+ (0, import_type_graphql19.Field)(() => GenerateCopilotResponseMetadataInput, {
1596
+ nullable: false
1597
+ }),
1598
+ _ts_metadata18("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
1599
+ ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
1600
+ _ts_decorate18([
1601
+ (0, import_type_graphql19.Field)(() => String, {
1602
+ nullable: true
1603
+ }),
1604
+ _ts_metadata18("design:type", String)
1605
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
1606
+ _ts_decorate18([
1607
+ (0, import_type_graphql19.Field)(() => String, {
1608
+ nullable: true
1609
+ }),
1610
+ _ts_metadata18("design:type", String)
1611
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
1612
+ _ts_decorate18([
1613
+ (0, import_type_graphql19.Field)(() => [
1614
+ MessageInput
1615
+ ]),
1616
+ _ts_metadata18("design:type", Array)
1617
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
1618
+ _ts_decorate18([
1619
+ (0, import_type_graphql19.Field)(() => FrontendInput),
1620
+ _ts_metadata18("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
1621
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
1622
+ _ts_decorate18([
1623
+ (0, import_type_graphql19.Field)(() => CloudInput, {
1624
+ nullable: true
1625
+ }),
1626
+ _ts_metadata18("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
1627
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
1628
+ _ts_decorate18([
1629
+ (0, import_type_graphql19.Field)(() => ForwardedParametersInput, {
1630
+ nullable: true
1631
+ }),
1632
+ _ts_metadata18("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
1633
+ ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
1634
+ _ts_decorate18([
1635
+ (0, import_type_graphql19.Field)(() => AgentSessionInput, {
1636
+ nullable: true
1637
+ }),
1638
+ _ts_metadata18("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
1639
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
1640
+ _ts_decorate18([
1641
+ (0, import_type_graphql19.Field)(() => AgentStateInput, {
1642
+ nullable: true
1643
+ }),
1644
+ _ts_metadata18("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
1645
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
1646
+ _ts_decorate18([
1647
+ (0, import_type_graphql19.Field)(() => [
1648
+ AgentStateInput
1649
+ ], {
1650
+ nullable: true
1651
+ }),
1652
+ _ts_metadata18("design:type", Array)
1653
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
1654
+ _ts_decorate18([
1655
+ (0, import_type_graphql19.Field)(() => ExtensionsInput, {
1656
+ nullable: true
1657
+ }),
1658
+ _ts_metadata18("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
1659
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
1660
+ _ts_decorate18([
1661
+ (0, import_type_graphql19.Field)(() => [
1662
+ MetaEventInput
1663
+ ], {
1664
+ nullable: true
1665
+ }),
1666
+ _ts_metadata18("design:type", Array)
1667
+ ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
1668
+ _ts_decorate18([
1669
+ (0, import_type_graphql19.Field)(() => [
1670
+ CopilotContextInput
1671
+ ], {
1672
+ nullable: true
1673
+ }),
1674
+ _ts_metadata18("design:type", Array)
1675
+ ], GenerateCopilotResponseInput.prototype, "context", void 0);
1676
+ GenerateCopilotResponseInput = _ts_decorate18([
1677
+ (0, import_type_graphql19.InputType)()
1678
+ ], GenerateCopilotResponseInput);
1679
+
1680
+ // src/graphql/resolvers/copilot.resolver.ts
1681
+ var import_graphql_yoga = require("graphql-yoga");
1682
+
1683
+ // src/service-adapters/events.ts
1684
+ var import_shared2 = require("@copilotkit/shared");
1685
+ var import_rxjs = require("rxjs");
1686
+
1687
+ // src/graphql/types/converted/index.ts
1688
+ var import_shared = require("@copilotkit/shared");
1689
+ var Message = class {
1690
+ type;
1691
+ id;
1692
+ createdAt;
1693
+ status;
1694
+ constructor(props) {
1695
+ props.id ?? (props.id = (0, import_shared.randomId)());
1696
+ props.status ?? (props.status = {
1697
+ code: MessageStatusCode.Success
1698
+ });
1699
+ props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
1700
+ Object.assign(this, props);
1701
+ }
1702
+ isTextMessage() {
1703
+ return this.type === "TextMessage";
1704
+ }
1705
+ isActionExecutionMessage() {
1706
+ return this.type === "ActionExecutionMessage";
1707
+ }
1708
+ isResultMessage() {
1709
+ return this.type === "ResultMessage";
1710
+ }
1711
+ isAgentStateMessage() {
1712
+ return this.type === "AgentStateMessage";
1713
+ }
1714
+ isImageMessage() {
1715
+ return this.type === "ImageMessage";
1716
+ }
1717
+ };
1718
+ __name(Message, "Message");
1719
+ var TextMessage = class extends Message {
1720
+ content;
1721
+ parentMessageId;
1722
+ role;
1723
+ type = "TextMessage";
1724
+ constructor(props) {
1725
+ super(props);
1726
+ this.type = "TextMessage";
1727
+ }
1728
+ };
1729
+ __name(TextMessage, "TextMessage");
1730
+ var ActionExecutionMessage = class extends Message {
1731
+ type = "ActionExecutionMessage";
1732
+ name;
1733
+ arguments;
1734
+ parentMessageId;
1735
+ };
1736
+ __name(ActionExecutionMessage, "ActionExecutionMessage");
1737
+ var ResultMessage = class extends Message {
1738
+ type = "ResultMessage";
1739
+ actionExecutionId;
1740
+ actionName;
1741
+ result;
1742
+ static encodeResult(result, error) {
1743
+ const errorObj = error ? typeof error === "string" ? {
1744
+ code: "ERROR",
1745
+ message: error
1746
+ } : error instanceof Error ? {
1747
+ code: "ERROR",
1748
+ message: error.message
1749
+ } : error : void 0;
1750
+ if (errorObj) {
1751
+ return JSON.stringify({
1752
+ error: errorObj,
1753
+ result: result || ""
1754
+ });
1755
+ }
1756
+ if (result === void 0) {
1757
+ return "";
1758
+ }
1759
+ return typeof result === "string" ? result : JSON.stringify(result);
1760
+ }
1761
+ static decodeResult(result) {
1762
+ if (!result) {
1763
+ return {
1764
+ result: ""
1765
+ };
1766
+ }
1767
+ try {
1768
+ const parsed = JSON.parse(result);
1769
+ if (parsed && typeof parsed === "object") {
1770
+ if ("error" in parsed) {
1771
+ return {
1772
+ error: parsed.error,
1773
+ result: parsed.result || ""
1774
+ };
1775
+ }
1776
+ return {
1777
+ result: JSON.stringify(parsed)
1778
+ };
1779
+ }
1780
+ return {
1781
+ result
1782
+ };
1783
+ } catch (e) {
1784
+ return {
1785
+ result
1786
+ };
1787
+ }
1788
+ }
1789
+ hasError() {
1790
+ try {
1791
+ const { error } = ResultMessage.decodeResult(this.result);
1792
+ return !!error;
1793
+ } catch {
1794
+ return false;
1795
+ }
1796
+ }
1797
+ getError() {
1798
+ try {
1799
+ const { error } = ResultMessage.decodeResult(this.result);
1800
+ return error;
1801
+ } catch {
1802
+ return void 0;
1803
+ }
1804
+ }
1805
+ };
1806
+ __name(ResultMessage, "ResultMessage");
1807
+ var AgentStateMessage = class extends Message {
1808
+ type = "AgentStateMessage";
1809
+ threadId;
1810
+ agentName;
1811
+ nodeName;
1812
+ runId;
1813
+ active;
1814
+ role;
1815
+ state;
1816
+ running;
1817
+ };
1818
+ __name(AgentStateMessage, "AgentStateMessage");
1819
+
1820
+ // src/service-adapters/events.ts
1821
+ var RuntimeEventTypes;
1822
+ (function(RuntimeEventTypes2) {
1823
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1824
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1825
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1826
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1827
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1828
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1829
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1830
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1831
+ RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1832
+ RuntimeEventTypes2["RunError"] = "RunError";
1833
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1834
+ var RuntimeMetaEventName;
1835
+ (function(RuntimeMetaEventName2) {
1836
+ RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1837
+ RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1838
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1839
+ })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1840
+
1841
+ // src/graphql/resolvers/copilot.resolver.ts
1842
+ var import_graphql_scalars2 = require("graphql-scalars");
1843
+ var import_class_transformer = require("class-transformer");
1844
+ var import_graphql = require("graphql");
1845
+
1846
+ // src/utils/failed-response-status-reasons.ts
1847
+ var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
1848
+ reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
1849
+ constructor({ guardrailsReason }) {
1850
+ super();
1851
+ this.details = {
1852
+ guardrailsReason
1853
+ };
1854
+ }
1855
+ };
1856
+ __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
1857
+ var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
1858
+ reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
1859
+ constructor({ messageId }) {
1860
+ super();
1861
+ this.details = {
1862
+ messageId,
1863
+ description: "Check the message for mode details"
1864
+ };
1865
+ }
1866
+ };
1867
+ __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
1868
+ var UnknownErrorResponse = class extends FailedResponseStatus {
1869
+ reason = FailedResponseStatusReason.UNKNOWN_ERROR;
1870
+ constructor({ description, originalError }) {
1871
+ super();
1872
+ this.details = {
1873
+ description,
1874
+ originalError
1875
+ };
1876
+ }
1877
+ };
1878
+ __name(UnknownErrorResponse, "UnknownErrorResponse");
1879
+
1880
+ // src/lib/telemetry-client.ts
1881
+ var import_shared4 = require("@copilotkit/shared");
1882
+ var import_node_crypto = require("crypto");
1883
+
1884
+ // src/lib/runtime/copilot-runtime.ts
1885
+ var import_shared3 = require("@copilotkit/shared");
1886
+ var import_runtime22 = require("@copilotkitnext/runtime");
1887
+
1888
+ // src/lib/runtime/types.ts
1889
+ var EndpointType;
1890
+ (function(EndpointType2) {
1891
+ EndpointType2["CopilotKit"] = "copilotKit";
1892
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1893
+ })(EndpointType || (EndpointType = {}));
1894
+
1895
+ // src/agents/langgraph/events.ts
1896
+ var LangGraphEventTypes;
1897
+ (function(LangGraphEventTypes2) {
1898
+ LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
1899
+ LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
1900
+ LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
1901
+ LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
1902
+ LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
1903
+ LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
1904
+ LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
1905
+ LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
1906
+ LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
1907
+ LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
1908
+ LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
1909
+ LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
1910
+ LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
1911
+ LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
1912
+ LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
1913
+ })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1914
+ var MetaEventNames;
1915
+ (function(MetaEventNames2) {
1916
+ MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1917
+ MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1918
+ })(MetaEventNames || (MetaEventNames = {}));
1919
+ var CustomEventNames;
1920
+ (function(CustomEventNames2) {
1921
+ CustomEventNames2["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
1922
+ CustomEventNames2["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
1923
+ CustomEventNames2["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
1924
+ CustomEventNames2["CopilotKitExit"] = "copilotkit_exit";
1925
+ })(CustomEventNames || (CustomEventNames = {}));
1926
+
1927
+ // src/lib/runtime/copilot-runtime.ts
1928
+ var import_agent = require("@copilotkitnext/agent");
1929
+ function resolveEndpointType(endpoint) {
1930
+ if (!endpoint.type) {
1931
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
1932
+ return EndpointType.LangGraphPlatform;
1933
+ } else {
1934
+ return EndpointType.CopilotKit;
1935
+ }
1936
+ }
1937
+ return endpoint.type;
1938
+ }
1939
+ __name(resolveEndpointType, "resolveEndpointType");
1940
+
1941
+ // src/lib/telemetry-client.ts
1942
+ var packageJson = require_package();
1943
+ var telemetryClient = new import_shared4.TelemetryClient({
1944
+ packageName: packageJson.name,
1945
+ packageVersion: packageJson.version
1946
+ });
1947
+ function getRuntimeInstanceTelemetryInfo(options) {
1948
+ var _a, _b, _c, _d, _e;
1949
+ const runtime = options.runtime;
1950
+ const remoteEndpoints = ((_a = runtime.params) == null ? void 0 : _a.remoteEndpoints) ?? [];
1951
+ const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
1952
+ let info = {
1953
+ ...acc
1954
+ };
1955
+ const endpointType = resolveEndpointType(endpoint);
1956
+ if (!info.endpointTypes.includes(endpointType)) {
1957
+ info = {
1958
+ ...info,
1959
+ endpointTypes: [
1960
+ ...info.endpointTypes,
1961
+ endpointType
1962
+ ]
1963
+ };
1964
+ }
1965
+ if (endpointType === EndpointType.LangGraphPlatform) {
1966
+ const ep = endpoint;
1967
+ info = {
1968
+ ...info,
1969
+ agentsAmount: ep.agents.length,
1970
+ hashedKey: ep.langsmithApiKey ? (0, import_node_crypto.createHash)("sha256").update(ep.langsmithApiKey).digest("hex") : null
1971
+ };
1972
+ }
1973
+ return info;
1974
+ }, {
1975
+ endpointTypes: [],
1976
+ agentsAmount: null,
1977
+ hashedKey: null
1978
+ });
1979
+ const publicApiKey = (_b = options.cloud) == null ? void 0 : _b.publicApiKey;
1980
+ const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
1981
+ return {
1982
+ actionsAmount: ((_d = (_c = runtime.params) == null ? void 0 : _c.actions) == null ? void 0 : _d.length) ?? 0,
1983
+ endpointsAmount: remoteEndpoints.length,
1984
+ endpointTypes: endpointsInfo.endpointTypes,
1985
+ agentsAmount: Object.keys(runtime.instance.agents).length,
1986
+ hashedLgcKey: endpointsInfo.hashedKey,
1987
+ "cloud.api_key_provided": apiKeyProvided,
1988
+ ...apiKeyProvided ? {
1989
+ "cloud.public_api_key": publicApiKey
1990
+ } : {},
1991
+ ...((_e = options.cloud) == null ? void 0 : _e.baseUrl) ? {
1992
+ "cloud.base_url": options.cloud.baseUrl
1993
+ } : {}
1994
+ };
1995
+ }
1996
+ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
1997
+ var telemetry_client_default = telemetryClient;
1998
+
1999
+ // src/graphql/resolvers/copilot.resolver.ts
2000
+ var import_shared5 = require("@copilotkit/shared");
2001
+
2002
+ // src/graphql/types/agents-response.type.ts
2003
+ var import_type_graphql20 = require("type-graphql");
2004
+ function _ts_decorate19(decorators, target, key, desc) {
2005
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2006
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2007
+ r = Reflect.decorate(decorators, target, key, desc);
2008
+ else
2009
+ for (var i = decorators.length - 1; i >= 0; i--)
2010
+ if (d = decorators[i])
2011
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2012
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2013
+ }
2014
+ __name(_ts_decorate19, "_ts_decorate");
2015
+ function _ts_metadata19(k, v) {
2016
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2017
+ return Reflect.metadata(k, v);
2018
+ }
2019
+ __name(_ts_metadata19, "_ts_metadata");
2020
+ var Agent = class {
2021
+ id;
2022
+ name;
2023
+ description;
2024
+ };
2025
+ __name(Agent, "Agent");
2026
+ _ts_decorate19([
2027
+ (0, import_type_graphql20.Field)(() => String),
2028
+ _ts_metadata19("design:type", String)
2029
+ ], Agent.prototype, "id", void 0);
2030
+ _ts_decorate19([
2031
+ (0, import_type_graphql20.Field)(() => String),
2032
+ _ts_metadata19("design:type", String)
2033
+ ], Agent.prototype, "name", void 0);
2034
+ _ts_decorate19([
2035
+ (0, import_type_graphql20.Field)(() => String),
2036
+ _ts_metadata19("design:type", String)
2037
+ ], Agent.prototype, "description", void 0);
2038
+ Agent = _ts_decorate19([
2039
+ (0, import_type_graphql20.ObjectType)()
2040
+ ], Agent);
2041
+ var AgentsResponse = class {
2042
+ agents;
2043
+ };
2044
+ __name(AgentsResponse, "AgentsResponse");
2045
+ _ts_decorate19([
2046
+ (0, import_type_graphql20.Field)(() => [
2047
+ Agent
2048
+ ]),
2049
+ _ts_metadata19("design:type", Array)
2050
+ ], AgentsResponse.prototype, "agents", void 0);
2051
+ AgentsResponse = _ts_decorate19([
2052
+ (0, import_type_graphql20.ObjectType)()
2053
+ ], AgentsResponse);
2054
+
2055
+ // src/graphql/resolvers/copilot.resolver.ts
2056
+ var import_shared6 = require("@copilotkit/shared");
2057
+ function _ts_decorate20(decorators, target, key, desc) {
2058
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2059
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2060
+ r = Reflect.decorate(decorators, target, key, desc);
2061
+ else
2062
+ for (var i = decorators.length - 1; i >= 0; i--)
2063
+ if (d = decorators[i])
2064
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2065
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2066
+ }
2067
+ __name(_ts_decorate20, "_ts_decorate");
2068
+ function _ts_metadata20(k, v) {
2069
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2070
+ return Reflect.metadata(k, v);
2071
+ }
2072
+ __name(_ts_metadata20, "_ts_metadata");
2073
+ function _ts_param(paramIndex, decorator) {
2074
+ return function(target, key) {
2075
+ decorator(target, key, paramIndex);
2076
+ };
2077
+ }
2078
+ __name(_ts_param, "_ts_param");
2079
+ var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
2080
+ var _a;
2081
+ if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
2082
+ const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
2083
+ role: m.textMessage.role,
2084
+ content: m.textMessage.content
2085
+ }));
2086
+ const lastMessage = messages[messages.length - 1];
2087
+ const restOfMessages = messages.slice(0, -1);
2088
+ const body = {
2089
+ input: lastMessage.content,
2090
+ validTopics: data.cloud.guardrails.inputValidationRules.allowList,
2091
+ invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
2092
+ messages: restOfMessages
2093
+ };
2094
+ const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
2095
+ method: "POST",
2096
+ headers: {
2097
+ "Content-Type": "application/json",
2098
+ "X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
2099
+ },
2100
+ body: JSON.stringify(body)
2101
+ });
2102
+ if (guardrailsResult.ok) {
2103
+ const resultJson = await guardrailsResult.json();
2104
+ onResult(resultJson);
2105
+ } else {
2106
+ onError(await guardrailsResult.json());
2107
+ }
2108
+ }
2109
+ }, "invokeGuardrails");
2110
+ var CopilotResolver = class {
2111
+ async hello() {
2112
+ return "Hello World";
2113
+ }
2114
+ async availableAgents(ctx) {
2115
+ let logger2 = ctx.logger.child({
2116
+ component: "CopilotResolver.availableAgents"
2117
+ });
2118
+ logger2.debug("Processing");
2119
+ const agentsWithEndpoints = [];
2120
+ logger2.debug("Event source created, creating response");
2121
+ return {
2122
+ agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
2123
+ };
2124
+ }
2125
+ async generateCopilotResponse(ctx, data, properties) {
2126
+ var _a, _b, _c, _d;
2127
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2128
+ "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2129
+ requestType: data.metadata.requestType,
2130
+ "cloud.api_key_provided": !!ctx.request.headers.get("x-copilotcloud-public-api-key"),
2131
+ ...ctx.request.headers.get("x-copilotcloud-public-api-key") ? {
2132
+ "cloud.public_api_key": ctx.request.headers.get("x-copilotcloud-public-api-key")
2133
+ } : {},
2134
+ ...ctx._copilotkit.baseUrl ? {
2135
+ "cloud.base_url": ctx._copilotkit.baseUrl
2136
+ } : {
2137
+ "cloud.base_url": "https://api.cloud.copilotkit.ai"
2138
+ }
2139
+ });
2140
+ let logger2 = ctx.logger.child({
2141
+ component: "CopilotResolver.generateCopilotResponse"
2142
+ });
2143
+ logger2.debug({
2144
+ data
2145
+ }, "Generating Copilot response");
2146
+ if (properties) {
2147
+ logger2.debug("Properties provided, merging with context properties");
2148
+ ctx.properties = {
2149
+ ...ctx.properties,
2150
+ ...properties
2151
+ };
2152
+ }
2153
+ const copilotRuntime = ctx._copilotkit.runtime;
2154
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
2155
+ let copilotCloudPublicApiKey = null;
2156
+ let copilotCloudBaseUrl;
2157
+ const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
2158
+ if (publicApiKeyFromHeaders) {
2159
+ copilotCloudPublicApiKey = publicApiKeyFromHeaders;
2160
+ }
2161
+ if (data.cloud) {
2162
+ logger2 = logger2.child({
2163
+ cloud: true
2164
+ });
2165
+ logger2.debug("Cloud configuration provided, checking for public API key in headers");
2166
+ if (!copilotCloudPublicApiKey) {
2167
+ logger2.error("Public API key not found in headers");
2168
+ throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2169
+ }
2170
+ if (process.env.COPILOT_CLOUD_BASE_URL) {
2171
+ copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2172
+ } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2173
+ copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2174
+ } else {
2175
+ copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2176
+ }
2177
+ logger2 = logger2.child({
2178
+ copilotCloudBaseUrl
2179
+ });
2180
+ }
2181
+ logger2.debug("Setting up subjects");
2182
+ const responseStatus$ = new import_rxjs2.ReplaySubject();
2183
+ const interruptStreaming$ = new import_rxjs2.ReplaySubject();
2184
+ const guardrailsResult$ = new import_rxjs2.ReplaySubject();
2185
+ let outputMessages = [];
2186
+ let resolveOutputMessagesPromise;
2187
+ let rejectOutputMessagesPromise;
2188
+ const outputMessagesPromise = new Promise((resolve, reject) => {
2189
+ resolveOutputMessagesPromise = resolve;
2190
+ rejectOutputMessagesPromise = reject;
2191
+ });
2192
+ if (copilotCloudPublicApiKey) {
2193
+ ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
2194
+ }
2195
+ logger2.debug("Processing");
2196
+ let runtimeResponse;
2197
+ const { eventSource, threadId = (0, import_shared5.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2198
+ logger2.debug("Event source created, creating response");
2199
+ const eventStream = eventSource.processRuntimeEvents({
2200
+ serverSideActions,
2201
+ guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2202
+ actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2203
+ // TODO-AGENTS: do not exclude ALL server side actions
2204
+ (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
2205
+ ),
2206
+ threadId
2207
+ }).pipe(
2208
+ // shareReplay() ensures that later subscribers will see the whole stream instead of
2209
+ // just the events that were emitted after the subscriber was added.
2210
+ (0, import_rxjs2.shareReplay)(),
2211
+ (0, import_rxjs2.finalize)(() => {
2212
+ logger2.debug("Event stream finalized");
2213
+ })
2214
+ );
2215
+ const response = {
2216
+ threadId,
2217
+ runId,
2218
+ status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
2219
+ extensions,
2220
+ metaEvents: new import_graphql_yoga.Repeater(async (push, stop) => {
2221
+ let eventStreamSubscription;
2222
+ eventStreamSubscription = eventStream.subscribe({
2223
+ next: async (event) => {
2224
+ if (event.type != RuntimeEventTypes.MetaEvent) {
2225
+ return;
2226
+ }
2227
+ switch (event.name) {
2228
+ case LangGraphEventTypes.OnInterrupt:
2229
+ push((0, import_class_transformer.plainToInstance)(LangGraphInterruptEvent, {
2230
+ // @ts-ignore
2231
+ type: event.type,
2232
+ // @ts-ignore
2233
+ name: RuntimeMetaEventName.LangGraphInterruptEvent,
2234
+ // @ts-ignore
2235
+ value: event.value
2236
+ }));
2237
+ break;
2238
+ case RuntimeMetaEventName.LangGraphInterruptEvent:
2239
+ push((0, import_class_transformer.plainToInstance)(LangGraphInterruptEvent, {
2240
+ type: event.type,
2241
+ name: event.name,
2242
+ value: event.value
2243
+ }));
2244
+ break;
2245
+ case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
2246
+ push((0, import_class_transformer.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
2247
+ type: event.type,
2248
+ name: event.name,
2249
+ data: {
2250
+ value: event.data.value,
2251
+ messages: event.data.messages.map((message) => {
2252
+ if (message.type === "TextMessage" || "content" in message && "role" in message) {
2253
+ return (0, import_class_transformer.plainToInstance)(TextMessage, {
2254
+ id: message.id,
2255
+ createdAt: /* @__PURE__ */ new Date(),
2256
+ content: [
2257
+ message.content
2258
+ ],
2259
+ role: message.role,
2260
+ status: new SuccessMessageStatus()
2261
+ });
2262
+ }
2263
+ if ("arguments" in message) {
2264
+ return (0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
2265
+ name: message.name,
2266
+ id: message.id,
2267
+ arguments: [
2268
+ JSON.stringify(message.arguments)
2269
+ ],
2270
+ createdAt: /* @__PURE__ */ new Date(),
2271
+ status: new SuccessMessageStatus()
2272
+ });
2273
+ }
2274
+ throw new Error("Unknown message in metaEvents copilot resolver");
2275
+ })
2276
+ }
2277
+ }));
2278
+ break;
2279
+ }
2280
+ },
2281
+ error: (err) => {
2282
+ var _a2, _b2;
2283
+ if (((_a2 = err == null ? void 0 : err.name) == null ? void 0 : _a2.includes("CopilotKit")) || ((_b2 = err == null ? void 0 : err.extensions) == null ? void 0 : _b2.visibility)) {
2284
+ responseStatus$.next(new UnknownErrorResponse({
2285
+ description: err.message || "Agent error occurred"
2286
+ }));
2287
+ } else {
2288
+ responseStatus$.next(new UnknownErrorResponse({
2289
+ description: `An unknown error has occurred in the event stream`
2290
+ }));
2291
+ }
2292
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2293
+ stop();
2294
+ },
2295
+ complete: async () => {
2296
+ logger2.debug("Meta events stream completed");
2297
+ responseStatus$.next(new SuccessResponseStatus());
2298
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2299
+ stop();
2300
+ }
2301
+ });
2302
+ }),
2303
+ messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
2304
+ var _a2;
2305
+ logger2.debug("Messages repeater created");
2306
+ if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
2307
+ logger2 = logger2.child({
2308
+ guardrails: true
2309
+ });
2310
+ logger2.debug("Guardrails is enabled, validating input");
2311
+ invokeGuardrails({
2312
+ baseUrl: copilotCloudBaseUrl,
2313
+ copilotCloudPublicApiKey,
2314
+ data,
2315
+ onResult: (result) => {
2316
+ logger2.debug({
2317
+ status: result.status
2318
+ }, "Guardrails validation done");
2319
+ guardrailsResult$.next(result);
2320
+ if (result.status === "denied") {
2321
+ responseStatus$.next(new GuardrailsValidationFailureResponse({
2322
+ guardrailsReason: result.reason
2323
+ }));
2324
+ interruptStreaming$.next({
2325
+ reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
2326
+ });
2327
+ outputMessages = [
2328
+ (0, import_class_transformer.plainToInstance)(TextMessage, {
2329
+ id: (0, import_shared5.randomId)(),
2330
+ createdAt: /* @__PURE__ */ new Date(),
2331
+ content: result.reason,
2332
+ role: MessageRole.assistant
2333
+ })
2334
+ ];
2335
+ resolveOutputMessagesPromise(outputMessages);
2336
+ }
2337
+ },
2338
+ onError: (err) => {
2339
+ logger2.error({
2340
+ err
2341
+ }, "Error in guardrails validation");
2342
+ responseStatus$.next(new UnknownErrorResponse({
2343
+ description: `An unknown error has occurred in the guardrails validation`
2344
+ }));
2345
+ interruptStreaming$.next({
2346
+ reason: `Interrupted due to unknown error in guardrails validation`
2347
+ });
2348
+ rejectOutputMessagesPromise(err);
2349
+ }
2350
+ });
2351
+ }
2352
+ let eventStreamSubscription;
2353
+ logger2.debug("Event stream created, subscribing to event stream");
2354
+ eventStreamSubscription = eventStream.subscribe({
2355
+ next: async (event) => {
2356
+ switch (event.type) {
2357
+ case RuntimeEventTypes.MetaEvent:
2358
+ break;
2359
+ case RuntimeEventTypes.TextMessageStart:
2360
+ const textMessageContentStream = eventStream.pipe(
2361
+ // skip until this message start event
2362
+ (0, import_rxjs2.skipWhile)((e) => e !== event),
2363
+ // take until the message end event
2364
+ (0, import_rxjs2.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2365
+ // filter out any other message events or message ids
2366
+ (0, import_rxjs2.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2367
+ );
2368
+ const streamingTextStatus = new import_rxjs2.Subject();
2369
+ const messageId = event.messageId;
2370
+ pushMessage({
2371
+ id: messageId,
2372
+ parentMessageId: event.parentMessageId,
2373
+ status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
2374
+ createdAt: /* @__PURE__ */ new Date(),
2375
+ role: MessageRole.assistant,
2376
+ content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
2377
+ logger2.debug("Text message content repeater created");
2378
+ const textChunks = [];
2379
+ let textSubscription;
2380
+ interruptStreaming$.pipe((0, import_rxjs2.shareReplay)(), (0, import_rxjs2.take)(1), (0, import_rxjs2.tap)(({ reason, messageId: messageId2 }) => {
2381
+ logger2.debug({
2382
+ reason,
2383
+ messageId: messageId2
2384
+ }, "Text streaming interrupted");
2385
+ streamingTextStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
2386
+ reason
2387
+ }));
2388
+ responseStatus$.next(new MessageStreamInterruptedResponse({
2389
+ messageId: messageId2
2390
+ }));
2391
+ stopStreamingText();
2392
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2393
+ })).subscribe();
2394
+ logger2.debug("Subscribing to text message content stream");
2395
+ textSubscription = textMessageContentStream.subscribe({
2396
+ next: async (e) => {
2397
+ if (e.type == RuntimeEventTypes.TextMessageContent) {
2398
+ await pushTextChunk(e.content);
2399
+ textChunks.push(e.content);
2400
+ }
2401
+ },
2402
+ error: (err) => {
2403
+ logger2.error({
2404
+ err
2405
+ }, "Error in text message content stream");
2406
+ interruptStreaming$.next({
2407
+ reason: "Error streaming message content",
2408
+ messageId
2409
+ });
2410
+ stopStreamingText();
2411
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2412
+ },
2413
+ complete: () => {
2414
+ logger2.debug("Text message content stream completed");
2415
+ streamingTextStatus.next(new SuccessMessageStatus());
2416
+ stopStreamingText();
2417
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2418
+ outputMessages.push((0, import_class_transformer.plainToInstance)(TextMessage, {
2419
+ id: messageId,
2420
+ createdAt: /* @__PURE__ */ new Date(),
2421
+ content: textChunks.join(""),
2422
+ role: MessageRole.assistant
2423
+ }));
2424
+ }
2425
+ });
2426
+ })
2427
+ });
2428
+ break;
2429
+ case RuntimeEventTypes.ActionExecutionStart:
2430
+ logger2.debug("Action execution start event received");
2431
+ const actionExecutionArgumentStream = eventStream.pipe(
2432
+ (0, import_rxjs2.skipWhile)((e) => e !== event),
2433
+ // take until the action execution end event
2434
+ (0, import_rxjs2.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2435
+ // filter out any other action execution events or action execution ids
2436
+ (0, import_rxjs2.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2437
+ );
2438
+ const streamingArgumentsStatus = new import_rxjs2.Subject();
2439
+ pushMessage({
2440
+ id: event.actionExecutionId,
2441
+ parentMessageId: event.parentMessageId,
2442
+ status: (0, import_rxjs2.firstValueFrom)(streamingArgumentsStatus),
2443
+ createdAt: /* @__PURE__ */ new Date(),
2444
+ name: event.actionName,
2445
+ arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
2446
+ logger2.debug("Action execution argument stream created");
2447
+ const argumentChunks = [];
2448
+ let actionExecutionArgumentSubscription;
2449
+ actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
2450
+ next: async (e) => {
2451
+ if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
2452
+ await pushArgumentsChunk(e.args);
2453
+ argumentChunks.push(e.args);
2454
+ }
2455
+ },
2456
+ error: (err) => {
2457
+ logger2.error({
2458
+ err
2459
+ }, "Error in action execution argument stream");
2460
+ streamingArgumentsStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
2461
+ reason: "An unknown error has occurred in the action execution argument stream"
2462
+ }));
2463
+ stopStreamingArguments();
2464
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2465
+ },
2466
+ complete: () => {
2467
+ logger2.debug("Action execution argument stream completed");
2468
+ streamingArgumentsStatus.next(new SuccessMessageStatus());
2469
+ stopStreamingArguments();
2470
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2471
+ outputMessages.push((0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
2472
+ id: event.actionExecutionId,
2473
+ createdAt: /* @__PURE__ */ new Date(),
2474
+ name: event.actionName,
2475
+ arguments: argumentChunks.join("")
2476
+ }));
2477
+ }
2478
+ });
2479
+ })
2480
+ });
2481
+ break;
2482
+ case RuntimeEventTypes.ActionExecutionResult:
2483
+ logger2.debug({
2484
+ result: event.result
2485
+ }, "Action execution result event received");
2486
+ pushMessage({
2487
+ id: "result-" + event.actionExecutionId,
2488
+ status: new SuccessMessageStatus(),
2489
+ createdAt: /* @__PURE__ */ new Date(),
2490
+ actionExecutionId: event.actionExecutionId,
2491
+ actionName: event.actionName,
2492
+ result: event.result
2493
+ });
2494
+ outputMessages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
2495
+ id: "result-" + event.actionExecutionId,
2496
+ createdAt: /* @__PURE__ */ new Date(),
2497
+ actionExecutionId: event.actionExecutionId,
2498
+ actionName: event.actionName,
2499
+ result: event.result
2500
+ }));
2501
+ break;
2502
+ case RuntimeEventTypes.AgentStateMessage:
2503
+ logger2.debug({
2504
+ event
2505
+ }, "Agent message event received");
2506
+ pushMessage({
2507
+ id: (0, import_shared5.randomId)(),
2508
+ status: new SuccessMessageStatus(),
2509
+ threadId: event.threadId,
2510
+ agentName: event.agentName,
2511
+ nodeName: event.nodeName,
2512
+ runId: event.runId,
2513
+ active: event.active,
2514
+ state: event.state,
2515
+ running: event.running,
2516
+ role: MessageRole.assistant,
2517
+ createdAt: /* @__PURE__ */ new Date()
2518
+ });
2519
+ outputMessages.push((0, import_class_transformer.plainToInstance)(AgentStateMessage, {
2520
+ id: (0, import_shared5.randomId)(),
2521
+ threadId: event.threadId,
2522
+ agentName: event.agentName,
2523
+ nodeName: event.nodeName,
2524
+ runId: event.runId,
2525
+ active: event.active,
2526
+ state: event.state,
2527
+ running: event.running,
2528
+ role: MessageRole.assistant,
2529
+ createdAt: /* @__PURE__ */ new Date()
2530
+ }));
2531
+ break;
2532
+ }
2533
+ },
2534
+ error: (err) => {
2535
+ var _a3, _b2, _c2, _d2, _e, _f;
2536
+ if (err instanceof import_shared6.CopilotKitError || err instanceof import_shared6.CopilotKitLowLevelError || err instanceof Error && err.name && err.name.includes("CopilotKit") || ((_a3 = err == null ? void 0 : err.extensions) == null ? void 0 : _a3.visibility)) {
2537
+ responseStatus$.next(new UnknownErrorResponse({
2538
+ description: err.message || "Agent error occurred",
2539
+ // Include original error information for frontend to extract
2540
+ originalError: {
2541
+ code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
2542
+ statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
2543
+ severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
2544
+ visibility: err.visibility || ((_e = err.extensions) == null ? void 0 : _e.visibility),
2545
+ originalErrorType: err.originalErrorType || ((_f = err.extensions) == null ? void 0 : _f.originalErrorType),
2546
+ extensions: err.extensions
2547
+ }
2548
+ }));
2549
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2550
+ rejectOutputMessagesPromise(err);
2551
+ stopStreamingMessages();
2552
+ return;
2553
+ }
2554
+ responseStatus$.next(new UnknownErrorResponse({
2555
+ description: `An unknown error has occurred in the event stream`
2556
+ }));
2557
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2558
+ stopStreamingMessages();
2559
+ rejectOutputMessagesPromise(err);
2560
+ },
2561
+ complete: async () => {
2562
+ var _a3;
2563
+ logger2.debug("Event stream completed");
2564
+ if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
2565
+ logger2.debug("Guardrails is enabled, waiting for guardrails result");
2566
+ await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
2567
+ }
2568
+ responseStatus$.next(new SuccessResponseStatus());
2569
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2570
+ stopStreamingMessages();
2571
+ resolveOutputMessagesPromise(outputMessages);
2572
+ }
2573
+ });
2574
+ })
2575
+ };
2576
+ return response;
2577
+ }
2578
+ };
2579
+ __name(CopilotResolver, "CopilotResolver");
2580
+ _ts_decorate20([
2581
+ (0, import_type_graphql21.Query)(() => String),
2582
+ _ts_metadata20("design:type", Function),
2583
+ _ts_metadata20("design:paramtypes", []),
2584
+ _ts_metadata20("design:returntype", Promise)
2585
+ ], CopilotResolver.prototype, "hello", null);
2586
+ _ts_decorate20([
2587
+ (0, import_type_graphql21.Query)(() => AgentsResponse),
2588
+ _ts_param(0, (0, import_type_graphql21.Ctx)()),
2589
+ _ts_metadata20("design:type", Function),
2590
+ _ts_metadata20("design:paramtypes", [
2591
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext
2592
+ ]),
2593
+ _ts_metadata20("design:returntype", Promise)
2594
+ ], CopilotResolver.prototype, "availableAgents", null);
2595
+ _ts_decorate20([
2596
+ (0, import_type_graphql21.Mutation)(() => CopilotResponse),
2597
+ _ts_param(0, (0, import_type_graphql21.Ctx)()),
2598
+ _ts_param(1, (0, import_type_graphql21.Arg)("data")),
2599
+ _ts_param(2, (0, import_type_graphql21.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
2600
+ nullable: true
2601
+ })),
2602
+ _ts_metadata20("design:type", Function),
2603
+ _ts_metadata20("design:paramtypes", [
2604
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2605
+ typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
2606
+ typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
2607
+ ]),
2608
+ _ts_metadata20("design:returntype", Promise)
2609
+ ], CopilotResolver.prototype, "generateCopilotResponse", null);
2610
+ CopilotResolver = _ts_decorate20([
2611
+ (0, import_type_graphql21.Resolver)(() => CopilotResponse)
2612
+ ], CopilotResolver);
2613
+
2614
+ // src/lib/integrations/shared.ts
2615
+ var import_plugin_defer_stream = require("@graphql-yoga/plugin-defer-stream");
2616
+
2617
+ // src/lib/logger.ts
2618
+ var import_pino = __toESM(require("pino"));
2619
+ var import_pino_pretty = __toESM(require("pino-pretty"));
2620
+ function createLogger(options) {
2621
+ const { level, component } = options || {};
2622
+ const stream = (0, import_pino_pretty.default)({
2623
+ colorize: true
2624
+ });
2625
+ const logger2 = (0, import_pino.default)({
2626
+ level: process.env.LOG_LEVEL || level || "error",
2627
+ redact: {
2628
+ paths: [
2629
+ "pid",
2630
+ "hostname"
2631
+ ],
2632
+ remove: true
2633
+ }
2634
+ }, stream);
2635
+ if (component) {
2636
+ return logger2.child({
2637
+ component
2638
+ });
2639
+ } else {
2640
+ return logger2;
2641
+ }
2642
+ }
2643
+ __name(createLogger, "createLogger");
2644
+
2645
+ // src/graphql/resolvers/state.resolver.ts
2646
+ var import_type_graphql24 = require("type-graphql");
2647
+ var import_type_graphql25 = require("type-graphql");
2648
+ var import_type_graphql26 = require("type-graphql");
2649
+
2650
+ // src/graphql/types/load-agent-state-response.type.ts
2651
+ var import_type_graphql22 = require("type-graphql");
2652
+ function _ts_decorate21(decorators, target, key, desc) {
2653
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2654
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2655
+ r = Reflect.decorate(decorators, target, key, desc);
2656
+ else
2657
+ for (var i = decorators.length - 1; i >= 0; i--)
2658
+ if (d = decorators[i])
2659
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2660
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2661
+ }
2662
+ __name(_ts_decorate21, "_ts_decorate");
2663
+ function _ts_metadata21(k, v) {
2664
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2665
+ return Reflect.metadata(k, v);
2666
+ }
2667
+ __name(_ts_metadata21, "_ts_metadata");
2668
+ var LoadAgentStateResponse = class {
2669
+ threadId;
2670
+ threadExists;
2671
+ state;
2672
+ messages;
2673
+ };
2674
+ __name(LoadAgentStateResponse, "LoadAgentStateResponse");
2675
+ _ts_decorate21([
2676
+ (0, import_type_graphql22.Field)(() => String),
2677
+ _ts_metadata21("design:type", String)
2678
+ ], LoadAgentStateResponse.prototype, "threadId", void 0);
2679
+ _ts_decorate21([
2680
+ (0, import_type_graphql22.Field)(() => Boolean),
2681
+ _ts_metadata21("design:type", Boolean)
2682
+ ], LoadAgentStateResponse.prototype, "threadExists", void 0);
2683
+ _ts_decorate21([
2684
+ (0, import_type_graphql22.Field)(() => String),
2685
+ _ts_metadata21("design:type", String)
2686
+ ], LoadAgentStateResponse.prototype, "state", void 0);
2687
+ _ts_decorate21([
2688
+ (0, import_type_graphql22.Field)(() => String),
2689
+ _ts_metadata21("design:type", String)
2690
+ ], LoadAgentStateResponse.prototype, "messages", void 0);
2691
+ LoadAgentStateResponse = _ts_decorate21([
2692
+ (0, import_type_graphql22.ObjectType)()
2693
+ ], LoadAgentStateResponse);
2694
+
2695
+ // src/graphql/inputs/load-agent-state.input.ts
2696
+ var import_type_graphql23 = require("type-graphql");
2697
+ function _ts_decorate22(decorators, target, key, desc) {
2698
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2699
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2700
+ r = Reflect.decorate(decorators, target, key, desc);
2701
+ else
2702
+ for (var i = decorators.length - 1; i >= 0; i--)
2703
+ if (d = decorators[i])
2704
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2705
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2706
+ }
2707
+ __name(_ts_decorate22, "_ts_decorate");
2708
+ function _ts_metadata22(k, v) {
2709
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2710
+ return Reflect.metadata(k, v);
2711
+ }
2712
+ __name(_ts_metadata22, "_ts_metadata");
2713
+ var LoadAgentStateInput = class {
2714
+ threadId;
2715
+ agentName;
2716
+ };
2717
+ __name(LoadAgentStateInput, "LoadAgentStateInput");
2718
+ _ts_decorate22([
2719
+ (0, import_type_graphql23.Field)(() => String),
2720
+ _ts_metadata22("design:type", String)
2721
+ ], LoadAgentStateInput.prototype, "threadId", void 0);
2722
+ _ts_decorate22([
2723
+ (0, import_type_graphql23.Field)(() => String),
2724
+ _ts_metadata22("design:type", String)
2725
+ ], LoadAgentStateInput.prototype, "agentName", void 0);
2726
+ LoadAgentStateInput = _ts_decorate22([
2727
+ (0, import_type_graphql23.InputType)()
2728
+ ], LoadAgentStateInput);
2729
+
2730
+ // src/graphql/resolvers/state.resolver.ts
2731
+ var import_shared7 = require("@copilotkit/shared");
2732
+ function _ts_decorate23(decorators, target, key, desc) {
2733
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2734
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2735
+ r = Reflect.decorate(decorators, target, key, desc);
2736
+ else
2737
+ for (var i = decorators.length - 1; i >= 0; i--)
2738
+ if (d = decorators[i])
2739
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2740
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2741
+ }
2742
+ __name(_ts_decorate23, "_ts_decorate");
2743
+ function _ts_metadata23(k, v) {
2744
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2745
+ return Reflect.metadata(k, v);
2746
+ }
2747
+ __name(_ts_metadata23, "_ts_metadata");
2748
+ function _ts_param2(paramIndex, decorator) {
2749
+ return function(target, key) {
2750
+ decorator(target, key, paramIndex);
2751
+ };
2752
+ }
2753
+ __name(_ts_param2, "_ts_param");
2754
+ var StateResolver = class {
2755
+ async loadAgentState(ctx, data) {
2756
+ const agents = [];
2757
+ const hasAgent = agents.some((agent) => agent.name === data.agentName);
2758
+ if (!hasAgent) {
2759
+ throw new import_shared7.CopilotKitAgentDiscoveryError({
2760
+ agentName: data.agentName,
2761
+ availableAgents: agents.map((a) => ({
2762
+ name: a.name,
2763
+ id: a.name
2764
+ }))
2765
+ });
2766
+ }
2767
+ const state = {};
2768
+ return state;
2769
+ }
2770
+ };
2771
+ __name(StateResolver, "StateResolver");
2772
+ _ts_decorate23([
2773
+ (0, import_type_graphql26.Query)(() => LoadAgentStateResponse),
2774
+ _ts_param2(0, (0, import_type_graphql25.Ctx)()),
2775
+ _ts_param2(1, (0, import_type_graphql24.Arg)("data")),
2776
+ _ts_metadata23("design:type", Function),
2777
+ _ts_metadata23("design:paramtypes", [
2778
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2779
+ typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
2780
+ ]),
2781
+ _ts_metadata23("design:returntype", Promise)
2782
+ ], StateResolver.prototype, "loadAgentState", null);
2783
+ StateResolver = _ts_decorate23([
2784
+ (0, import_type_graphql24.Resolver)(() => LoadAgentStateResponse)
2785
+ ], StateResolver);
2786
+
2787
+ // src/lib/integrations/shared.ts
2788
+ var packageJson2 = __toESM(require_package());
2789
+ var import_shared8 = require("@copilotkit/shared");
2790
+ var logger = createLogger();
2791
+ var addCustomHeaderPlugin = {
2792
+ onResponse({ response }) {
2793
+ response.headers.set("X-CopilotKit-Runtime-Version", packageJson2.version);
2794
+ }
2795
+ };
2796
+ async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
2797
+ logger.debug({
2798
+ copilotKitContext
2799
+ }, "Creating GraphQL context");
2800
+ const ctx = {
2801
+ ...initialContext,
2802
+ _copilotkit: {
2803
+ ...copilotKitContext
2804
+ },
2805
+ properties: {
2806
+ ...properties
2807
+ },
2808
+ logger: contextLogger
2809
+ };
2810
+ return ctx;
2811
+ }
2812
+ __name(createContext, "createContext");
2813
+ function buildSchema(options = {}) {
2814
+ logger.debug("Building GraphQL schema...");
2815
+ const schema = (0, import_type_graphql27.buildSchemaSync)({
2816
+ resolvers: [
2817
+ CopilotResolver,
2818
+ StateResolver
2819
+ ],
2820
+ emitSchemaFile: options.emitSchemaFile
2821
+ });
2822
+ logger.debug("GraphQL schema built successfully");
2823
+ return schema;
2824
+ }
2825
+ __name(buildSchema, "buildSchema");
2826
+ function getCommonConfig(options) {
2827
+ var _a;
2828
+ const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
2829
+ const logger2 = createLogger({
2830
+ level: logLevel,
2831
+ component: "getCommonConfig"
2832
+ });
2833
+ const contextLogger = createLogger({
2834
+ level: logLevel
2835
+ });
2836
+ if (options.cloud) {
2837
+ telemetry_client_default.setCloudConfiguration({
2838
+ publicApiKey: options.cloud.publicApiKey,
2839
+ baseUrl: options.cloud.baseUrl
2840
+ });
2841
+ }
2842
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2843
+ telemetry_client_default.setGlobalProperties({
2844
+ _copilotkit: {
2845
+ ...options.properties._copilotkit
2846
+ }
2847
+ });
2848
+ }
2849
+ telemetry_client_default.setGlobalProperties({
2850
+ runtime: {
2851
+ serviceAdapter: options.serviceAdapter.constructor.name
2852
+ }
2853
+ });
2854
+ const userErrorCodes = [
2855
+ import_shared8.CopilotKitErrorCode.AGENT_NOT_FOUND,
2856
+ import_shared8.CopilotKitErrorCode.API_NOT_FOUND,
2857
+ import_shared8.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
2858
+ import_shared8.CopilotKitErrorCode.CONFIGURATION_ERROR,
2859
+ import_shared8.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
2860
+ ];
2861
+ return {
2862
+ logging: createLogger({
2863
+ component: "Yoga GraphQL",
2864
+ level: logLevel
2865
+ }),
2866
+ schema: buildSchema(),
2867
+ plugins: [
2868
+ (0, import_plugin_defer_stream.useDeferStream)(),
2869
+ addCustomHeaderPlugin
2870
+ ],
2871
+ context: (ctx) => createContext(ctx, options, contextLogger, options.properties),
2872
+ // Suppress logging for user configuration errors
2873
+ maskedErrors: {
2874
+ maskError: (error, message, isDev) => {
2875
+ const originalError = error.originalError || error;
2876
+ const extensions = error.extensions;
2877
+ const errorCode = extensions == null ? void 0 : extensions.code;
2878
+ if (errorCode && userErrorCodes.includes(errorCode)) {
2879
+ console.debug("User configuration error:", error.message);
2880
+ return error;
2881
+ }
2882
+ if (originalError instanceof import_shared8.CopilotKitError && userErrorCodes.includes(originalError.code)) {
2883
+ console.debug("User configuration error:", error.message);
2884
+ return error;
2885
+ }
2886
+ console.error("Application error:", error);
2887
+ return error;
2888
+ }
2889
+ }
2890
+ };
2891
+ }
2892
+ __name(getCommonConfig, "getCommonConfig");
2893
+
2894
+ // src/lib/integrations/node-http/index.ts
2895
+ function copilotRuntimeNodeHttpEndpoint(options) {
2896
+ var _a;
2897
+ const commonConfig = getCommonConfig(options);
2898
+ telemetry_client_default.setGlobalProperties({
2899
+ runtime: {
2900
+ framework: "node-http"
2901
+ }
2902
+ });
2903
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
2904
+ telemetry_client_default.setGlobalProperties({
2905
+ _copilotkit: options.properties._copilotkit
2906
+ });
2907
+ }
2908
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
2909
+ const logger2 = commonConfig.logging;
2910
+ logger2.debug("Creating Node HTTP endpoint");
2911
+ const serviceAdapter = options.serviceAdapter;
2912
+ options.runtime.handleServiceAdapter(serviceAdapter);
2913
+ return (0, import_runtime32.createCopilotEndpoint)({
2914
+ runtime: options.runtime.instance,
2915
+ basePath: options.baseUrl
2916
+ });
2917
+ }
2918
+ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
2919
+ // Annotate the CommonJS export names for ESM import in node:
2920
+ 0 && (module.exports = {
2921
+ copilotRuntimeNodeHttpEndpoint
2922
+ });
2923
+ //# sourceMappingURL=index.js.map