@copilotkit/runtime 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.eslintrc.js +7 -0
  2. package/.turbo/turbo-build.log +70 -0
  3. package/CHANGELOG.md +1 -0
  4. package/__snapshots__/schema/schema.graphql +178 -0
  5. package/dist/chunk-2CCVVJDU.mjs +56 -0
  6. package/dist/chunk-2CCVVJDU.mjs.map +1 -0
  7. package/dist/chunk-4UA4RB4C.mjs +185 -0
  8. package/dist/chunk-4UA4RB4C.mjs.map +1 -0
  9. package/dist/chunk-5HGYI6EG.mjs +678 -0
  10. package/dist/chunk-5HGYI6EG.mjs.map +1 -0
  11. package/dist/chunk-7IFP53C6.mjs +169 -0
  12. package/dist/chunk-7IFP53C6.mjs.map +1 -0
  13. package/dist/chunk-BLTAUVRP.mjs +30 -0
  14. package/dist/chunk-BLTAUVRP.mjs.map +1 -0
  15. package/dist/chunk-NFCPM5AM.mjs +43 -0
  16. package/dist/chunk-NFCPM5AM.mjs.map +1 -0
  17. package/dist/chunk-XPAUPJMW.mjs +1051 -0
  18. package/dist/chunk-XPAUPJMW.mjs.map +1 -0
  19. package/dist/graphql/types/base/index.d.ts +6 -0
  20. package/dist/graphql/types/base/index.js +63 -0
  21. package/dist/graphql/types/base/index.js.map +1 -0
  22. package/dist/graphql/types/base/index.mjs +7 -0
  23. package/dist/graphql/types/base/index.mjs.map +1 -0
  24. package/dist/graphql/types/converted/index.d.ts +2 -0
  25. package/dist/graphql/types/converted/index.js +88 -0
  26. package/dist/graphql/types/converted/index.js.map +1 -0
  27. package/dist/graphql/types/converted/index.mjs +12 -0
  28. package/dist/graphql/types/converted/index.mjs.map +1 -0
  29. package/dist/index-aa091e3c.d.ts +49 -0
  30. package/dist/index-f0875df3.d.ts +197 -0
  31. package/dist/index.d.ts +15 -0
  32. package/dist/index.js +2171 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/index.mjs +49 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/langchain-adapter-9ce103f3.d.ts +200 -0
  37. package/dist/langserve-fd5066ee.d.ts +96 -0
  38. package/dist/lib/index.d.ts +15 -0
  39. package/dist/lib/index.js +2170 -0
  40. package/dist/lib/index.js.map +1 -0
  41. package/dist/lib/index.mjs +46 -0
  42. package/dist/lib/index.mjs.map +1 -0
  43. package/dist/lib/integrations/index.d.ts +9 -0
  44. package/dist/lib/integrations/index.js +1024 -0
  45. package/dist/lib/integrations/index.js.map +1 -0
  46. package/dist/lib/integrations/index.mjs +24 -0
  47. package/dist/lib/integrations/index.mjs.map +1 -0
  48. package/dist/lib/integrations/node-http/index.d.ts +8 -0
  49. package/dist/lib/integrations/node-http/index.js +969 -0
  50. package/dist/lib/integrations/node-http/index.js.map +1 -0
  51. package/dist/lib/integrations/node-http/index.mjs +10 -0
  52. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  53. package/dist/pages-router-b6bc6c60.d.ts +30 -0
  54. package/dist/service-adapters/index.d.ts +11 -0
  55. package/dist/service-adapters/index.js +912 -0
  56. package/dist/service-adapters/index.js.map +1 -0
  57. package/dist/service-adapters/index.mjs +18 -0
  58. package/dist/service-adapters/index.mjs.map +1 -0
  59. package/jest.config.js +5 -0
  60. package/package.json +63 -0
  61. package/scripts/generate-gql-schema.ts +13 -0
  62. package/src/graphql/inputs/action.input.ts +13 -0
  63. package/src/graphql/inputs/cloud-guardrails.input.ts +19 -0
  64. package/src/graphql/inputs/cloud.input.ts +8 -0
  65. package/src/graphql/inputs/context-property.input.ts +10 -0
  66. package/src/graphql/inputs/custom-property.input.ts +15 -0
  67. package/src/graphql/inputs/frontend.input.ts +11 -0
  68. package/src/graphql/inputs/generate-copilot-response.input.ts +22 -0
  69. package/src/graphql/inputs/message.input.ts +50 -0
  70. package/src/graphql/resolvers/copilot.resolver.ts +147 -0
  71. package/src/graphql/types/base/index.ts +10 -0
  72. package/src/graphql/types/converted/index.ts +29 -0
  73. package/src/graphql/types/copilot-response.type.ts +75 -0
  74. package/src/graphql/types/enums.ts +22 -0
  75. package/src/graphql/types/guardrails-result.type.ts +20 -0
  76. package/src/graphql/types/message-status.type.ts +40 -0
  77. package/src/graphql/types/response-status.type.ts +52 -0
  78. package/src/index.ts +2 -0
  79. package/src/lib/copilot-cloud.ts +63 -0
  80. package/src/lib/copilot-runtime.ts +261 -0
  81. package/src/lib/guardrails.ts +3 -0
  82. package/src/lib/index.ts +7 -0
  83. package/src/lib/integrations/index.ts +4 -0
  84. package/src/lib/integrations/nextjs/app-router.ts +29 -0
  85. package/src/lib/integrations/nextjs/pages-router.ts +36 -0
  86. package/src/lib/integrations/node-http/index.ts +23 -0
  87. package/src/lib/integrations/shared.ts +68 -0
  88. package/src/service-adapters/conversion.ts +47 -0
  89. package/src/service-adapters/events.ts +197 -0
  90. package/src/service-adapters/experimental/groq/groq-adapter.ts +124 -0
  91. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +75 -0
  92. package/src/service-adapters/google/google-genai-adapter.ts +149 -0
  93. package/src/service-adapters/google/utils.ts +94 -0
  94. package/src/service-adapters/index.ts +6 -0
  95. package/src/service-adapters/langchain/langchain-adapter.ts +82 -0
  96. package/src/service-adapters/langchain/langserve.ts +81 -0
  97. package/src/service-adapters/langchain/types.ts +14 -0
  98. package/src/service-adapters/langchain/utils.ts +235 -0
  99. package/src/service-adapters/openai/openai-adapter.ts +142 -0
  100. package/src/service-adapters/openai/openai-assistant-adapter.ts +260 -0
  101. package/src/service-adapters/openai/utils.ts +164 -0
  102. package/src/service-adapters/service-adapter.ts +29 -0
  103. package/tsconfig.json +11 -0
  104. package/tsup.config.ts +17 -0
  105. package/typedoc.json +4 -0
@@ -0,0 +1,969 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/integrations/node-http/index.ts
21
+ var node_http_exports = {};
22
+ __export(node_http_exports, {
23
+ copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint
24
+ });
25
+ module.exports = __toCommonJS(node_http_exports);
26
+ var import_graphql_yoga2 = require("graphql-yoga");
27
+
28
+ // src/lib/integrations/shared.ts
29
+ var import_type_graphql13 = require("type-graphql");
30
+
31
+ // src/graphql/resolvers/copilot.resolver.ts
32
+ var import_type_graphql12 = require("type-graphql");
33
+ var import_rxjs2 = require("rxjs");
34
+
35
+ // src/graphql/inputs/generate-copilot-response.input.ts
36
+ var import_type_graphql8 = require("type-graphql");
37
+
38
+ // src/graphql/inputs/message.input.ts
39
+ var import_type_graphql3 = require("type-graphql");
40
+
41
+ // src/graphql/types/enums.ts
42
+ var import_type_graphql = require("type-graphql");
43
+ var MessageRole;
44
+ (function(MessageRole2) {
45
+ MessageRole2["user"] = "user";
46
+ MessageRole2["assistant"] = "assistant";
47
+ MessageRole2["system"] = "system";
48
+ })(MessageRole || (MessageRole = {}));
49
+ var ActionExecutionScope;
50
+ (function(ActionExecutionScope2) {
51
+ ActionExecutionScope2["server"] = "server";
52
+ ActionExecutionScope2["client"] = "client";
53
+ })(ActionExecutionScope || (ActionExecutionScope = {}));
54
+ (0, import_type_graphql.registerEnumType)(MessageRole, {
55
+ name: "MessageRole",
56
+ description: "The role of the message"
57
+ });
58
+ (0, import_type_graphql.registerEnumType)(ActionExecutionScope, {
59
+ name: "ActionExecutionScope",
60
+ description: "The scope of the action"
61
+ });
62
+
63
+ // src/graphql/types/base/index.ts
64
+ var import_type_graphql2 = require("type-graphql");
65
+ function _ts_decorate(decorators, target, key, desc) {
66
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
67
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
68
+ r = Reflect.decorate(decorators, target, key, desc);
69
+ else
70
+ for (var i = decorators.length - 1; i >= 0; i--)
71
+ if (d = decorators[i])
72
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
73
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
74
+ }
75
+ __name(_ts_decorate, "_ts_decorate");
76
+ function _ts_metadata(k, v) {
77
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
78
+ return Reflect.metadata(k, v);
79
+ }
80
+ __name(_ts_metadata, "_ts_metadata");
81
+ var BaseMessage = class {
82
+ id;
83
+ createdAt;
84
+ };
85
+ __name(BaseMessage, "BaseMessage");
86
+ _ts_decorate([
87
+ (0, import_type_graphql2.Field)(() => String),
88
+ _ts_metadata("design:type", String)
89
+ ], BaseMessage.prototype, "id", void 0);
90
+ _ts_decorate([
91
+ (0, import_type_graphql2.Field)(() => Date),
92
+ _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
93
+ ], BaseMessage.prototype, "createdAt", void 0);
94
+ BaseMessage = _ts_decorate([
95
+ (0, import_type_graphql2.InputType)()
96
+ ], BaseMessage);
97
+
98
+ // src/graphql/inputs/message.input.ts
99
+ function _ts_decorate2(decorators, target, key, desc) {
100
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
101
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
102
+ r = Reflect.decorate(decorators, target, key, desc);
103
+ else
104
+ for (var i = decorators.length - 1; i >= 0; i--)
105
+ if (d = decorators[i])
106
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
107
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
108
+ }
109
+ __name(_ts_decorate2, "_ts_decorate");
110
+ function _ts_metadata2(k, v) {
111
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
112
+ return Reflect.metadata(k, v);
113
+ }
114
+ __name(_ts_metadata2, "_ts_metadata");
115
+ var MessageInput = class extends BaseMessage {
116
+ textMessage;
117
+ actionExecutionMessage;
118
+ resultMessage;
119
+ };
120
+ __name(MessageInput, "MessageInput");
121
+ _ts_decorate2([
122
+ (0, import_type_graphql3.Field)(() => TextMessageInput, {
123
+ nullable: true
124
+ }),
125
+ _ts_metadata2("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
126
+ ], MessageInput.prototype, "textMessage", void 0);
127
+ _ts_decorate2([
128
+ (0, import_type_graphql3.Field)(() => ActionExecutionMessageInput, {
129
+ nullable: true
130
+ }),
131
+ _ts_metadata2("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
132
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
133
+ _ts_decorate2([
134
+ (0, import_type_graphql3.Field)(() => ResultMessageInput, {
135
+ nullable: true
136
+ }),
137
+ _ts_metadata2("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
138
+ ], MessageInput.prototype, "resultMessage", void 0);
139
+ MessageInput = _ts_decorate2([
140
+ (0, import_type_graphql3.InputType)()
141
+ ], MessageInput);
142
+ var TextMessageInput = class {
143
+ content;
144
+ role;
145
+ };
146
+ __name(TextMessageInput, "TextMessageInput");
147
+ _ts_decorate2([
148
+ (0, import_type_graphql3.Field)(() => String),
149
+ _ts_metadata2("design:type", String)
150
+ ], TextMessageInput.prototype, "content", void 0);
151
+ _ts_decorate2([
152
+ (0, import_type_graphql3.Field)(() => MessageRole),
153
+ _ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
154
+ ], TextMessageInput.prototype, "role", void 0);
155
+ TextMessageInput = _ts_decorate2([
156
+ (0, import_type_graphql3.InputType)()
157
+ ], TextMessageInput);
158
+ var ActionExecutionMessageInput = class {
159
+ name;
160
+ arguments;
161
+ scope;
162
+ };
163
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
164
+ _ts_decorate2([
165
+ (0, import_type_graphql3.Field)(() => String),
166
+ _ts_metadata2("design:type", String)
167
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
168
+ _ts_decorate2([
169
+ (0, import_type_graphql3.Field)(() => String),
170
+ _ts_metadata2("design:type", String)
171
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
172
+ _ts_decorate2([
173
+ (0, import_type_graphql3.Field)(() => ActionExecutionScope),
174
+ _ts_metadata2("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
175
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
176
+ ActionExecutionMessageInput = _ts_decorate2([
177
+ (0, import_type_graphql3.InputType)()
178
+ ], ActionExecutionMessageInput);
179
+ var ResultMessageInput = class {
180
+ actionExecutionId;
181
+ actionName;
182
+ result;
183
+ };
184
+ __name(ResultMessageInput, "ResultMessageInput");
185
+ _ts_decorate2([
186
+ (0, import_type_graphql3.Field)(() => String),
187
+ _ts_metadata2("design:type", String)
188
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
189
+ _ts_decorate2([
190
+ (0, import_type_graphql3.Field)(() => String),
191
+ _ts_metadata2("design:type", String)
192
+ ], ResultMessageInput.prototype, "actionName", void 0);
193
+ _ts_decorate2([
194
+ (0, import_type_graphql3.Field)(() => String),
195
+ _ts_metadata2("design:type", String)
196
+ ], ResultMessageInput.prototype, "result", void 0);
197
+ ResultMessageInput = _ts_decorate2([
198
+ (0, import_type_graphql3.InputType)()
199
+ ], ResultMessageInput);
200
+
201
+ // src/graphql/inputs/frontend.input.ts
202
+ var import_type_graphql5 = require("type-graphql");
203
+
204
+ // src/graphql/inputs/action.input.ts
205
+ var import_type_graphql4 = require("type-graphql");
206
+ function _ts_decorate3(decorators, target, key, desc) {
207
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
208
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
209
+ r = Reflect.decorate(decorators, target, key, desc);
210
+ else
211
+ for (var i = decorators.length - 1; i >= 0; i--)
212
+ if (d = decorators[i])
213
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
214
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
215
+ }
216
+ __name(_ts_decorate3, "_ts_decorate");
217
+ function _ts_metadata3(k, v) {
218
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
219
+ return Reflect.metadata(k, v);
220
+ }
221
+ __name(_ts_metadata3, "_ts_metadata");
222
+ var ActionInput = class {
223
+ name;
224
+ description;
225
+ jsonSchema;
226
+ };
227
+ __name(ActionInput, "ActionInput");
228
+ _ts_decorate3([
229
+ (0, import_type_graphql4.Field)(() => String),
230
+ _ts_metadata3("design:type", String)
231
+ ], ActionInput.prototype, "name", void 0);
232
+ _ts_decorate3([
233
+ (0, import_type_graphql4.Field)(() => String),
234
+ _ts_metadata3("design:type", String)
235
+ ], ActionInput.prototype, "description", void 0);
236
+ _ts_decorate3([
237
+ (0, import_type_graphql4.Field)(() => String),
238
+ _ts_metadata3("design:type", String)
239
+ ], ActionInput.prototype, "jsonSchema", void 0);
240
+ ActionInput = _ts_decorate3([
241
+ (0, import_type_graphql4.InputType)()
242
+ ], ActionInput);
243
+
244
+ // src/graphql/inputs/frontend.input.ts
245
+ function _ts_decorate4(decorators, target, key, desc) {
246
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
247
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
248
+ r = Reflect.decorate(decorators, target, key, desc);
249
+ else
250
+ for (var i = decorators.length - 1; i >= 0; i--)
251
+ if (d = decorators[i])
252
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
253
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
254
+ }
255
+ __name(_ts_decorate4, "_ts_decorate");
256
+ function _ts_metadata4(k, v) {
257
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
258
+ return Reflect.metadata(k, v);
259
+ }
260
+ __name(_ts_metadata4, "_ts_metadata");
261
+ var FrontendInput = class {
262
+ toDeprecate_fullContext;
263
+ actions;
264
+ };
265
+ __name(FrontendInput, "FrontendInput");
266
+ _ts_decorate4([
267
+ (0, import_type_graphql5.Field)(() => String, {
268
+ nullable: true
269
+ }),
270
+ _ts_metadata4("design:type", String)
271
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
272
+ _ts_decorate4([
273
+ (0, import_type_graphql5.Field)(() => [
274
+ ActionInput
275
+ ]),
276
+ _ts_metadata4("design:type", Array)
277
+ ], FrontendInput.prototype, "actions", void 0);
278
+ FrontendInput = _ts_decorate4([
279
+ (0, import_type_graphql5.InputType)()
280
+ ], FrontendInput);
281
+
282
+ // src/graphql/inputs/cloud.input.ts
283
+ var import_type_graphql7 = require("type-graphql");
284
+
285
+ // src/graphql/inputs/cloud-guardrails.input.ts
286
+ var import_type_graphql6 = require("type-graphql");
287
+ function _ts_decorate5(decorators, target, key, desc) {
288
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
289
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
290
+ r = Reflect.decorate(decorators, target, key, desc);
291
+ else
292
+ for (var i = decorators.length - 1; i >= 0; i--)
293
+ if (d = decorators[i])
294
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
295
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
296
+ }
297
+ __name(_ts_decorate5, "_ts_decorate");
298
+ function _ts_metadata5(k, v) {
299
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
300
+ return Reflect.metadata(k, v);
301
+ }
302
+ __name(_ts_metadata5, "_ts_metadata");
303
+ var GuardrailsRuleInput = class {
304
+ id;
305
+ allowList = [];
306
+ denyList = [];
307
+ };
308
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
309
+ _ts_decorate5([
310
+ (0, import_type_graphql6.Field)(() => String),
311
+ _ts_metadata5("design:type", String)
312
+ ], GuardrailsRuleInput.prototype, "id", void 0);
313
+ _ts_decorate5([
314
+ (0, import_type_graphql6.Field)(() => [
315
+ String
316
+ ], {
317
+ nullable: true
318
+ }),
319
+ _ts_metadata5("design:type", Array)
320
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
321
+ _ts_decorate5([
322
+ (0, import_type_graphql6.Field)(() => [
323
+ String
324
+ ], {
325
+ nullable: true
326
+ }),
327
+ _ts_metadata5("design:type", Array)
328
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
329
+ GuardrailsRuleInput = _ts_decorate5([
330
+ (0, import_type_graphql6.InputType)()
331
+ ], GuardrailsRuleInput);
332
+ var GuardrailsInput = class {
333
+ inputValidationRules = [];
334
+ };
335
+ __name(GuardrailsInput, "GuardrailsInput");
336
+ _ts_decorate5([
337
+ (0, import_type_graphql6.Field)(() => [
338
+ GuardrailsRuleInput
339
+ ], {
340
+ nullable: true
341
+ }),
342
+ _ts_metadata5("design:type", Array)
343
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
344
+ GuardrailsInput = _ts_decorate5([
345
+ (0, import_type_graphql6.InputType)()
346
+ ], GuardrailsInput);
347
+
348
+ // src/graphql/inputs/cloud.input.ts
349
+ function _ts_decorate6(decorators, target, key, desc) {
350
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
351
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
352
+ r = Reflect.decorate(decorators, target, key, desc);
353
+ else
354
+ for (var i = decorators.length - 1; i >= 0; i--)
355
+ if (d = decorators[i])
356
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
357
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
358
+ }
359
+ __name(_ts_decorate6, "_ts_decorate");
360
+ function _ts_metadata6(k, v) {
361
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
362
+ return Reflect.metadata(k, v);
363
+ }
364
+ __name(_ts_metadata6, "_ts_metadata");
365
+ var CloudInput = class {
366
+ guardrails;
367
+ };
368
+ __name(CloudInput, "CloudInput");
369
+ _ts_decorate6([
370
+ (0, import_type_graphql7.Field)(() => GuardrailsInput),
371
+ _ts_metadata6("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
372
+ ], CloudInput.prototype, "guardrails", void 0);
373
+ CloudInput = _ts_decorate6([
374
+ (0, import_type_graphql7.InputType)()
375
+ ], CloudInput);
376
+
377
+ // src/graphql/inputs/generate-copilot-response.input.ts
378
+ function _ts_decorate7(decorators, target, key, desc) {
379
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
380
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
381
+ r = Reflect.decorate(decorators, target, key, desc);
382
+ else
383
+ for (var i = decorators.length - 1; i >= 0; i--)
384
+ if (d = decorators[i])
385
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
386
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
387
+ }
388
+ __name(_ts_decorate7, "_ts_decorate");
389
+ function _ts_metadata7(k, v) {
390
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
391
+ return Reflect.metadata(k, v);
392
+ }
393
+ __name(_ts_metadata7, "_ts_metadata");
394
+ var GenerateCopilotResponseInput = class {
395
+ threadId;
396
+ runId;
397
+ messages;
398
+ frontend;
399
+ cloud;
400
+ };
401
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
402
+ _ts_decorate7([
403
+ (0, import_type_graphql8.Field)(() => String, {
404
+ nullable: true
405
+ }),
406
+ _ts_metadata7("design:type", String)
407
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
408
+ _ts_decorate7([
409
+ (0, import_type_graphql8.Field)(() => String, {
410
+ nullable: true
411
+ }),
412
+ _ts_metadata7("design:type", String)
413
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
414
+ _ts_decorate7([
415
+ (0, import_type_graphql8.Field)(() => [
416
+ MessageInput
417
+ ]),
418
+ _ts_metadata7("design:type", Array)
419
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
420
+ _ts_decorate7([
421
+ (0, import_type_graphql8.Field)(() => FrontendInput),
422
+ _ts_metadata7("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
423
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
424
+ _ts_decorate7([
425
+ (0, import_type_graphql8.Field)(() => CloudInput, {
426
+ nullable: true
427
+ }),
428
+ _ts_metadata7("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
429
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
430
+ GenerateCopilotResponseInput = _ts_decorate7([
431
+ (0, import_type_graphql8.InputType)()
432
+ ], GenerateCopilotResponseInput);
433
+
434
+ // src/graphql/types/copilot-response.type.ts
435
+ var import_type_graphql11 = require("type-graphql");
436
+
437
+ // src/graphql/types/message-status.type.ts
438
+ var import_type_graphql9 = require("type-graphql");
439
+ function _ts_decorate8(decorators, target, key, desc) {
440
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
441
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
442
+ r = Reflect.decorate(decorators, target, key, desc);
443
+ else
444
+ for (var i = decorators.length - 1; i >= 0; i--)
445
+ if (d = decorators[i])
446
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
447
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
448
+ }
449
+ __name(_ts_decorate8, "_ts_decorate");
450
+ function _ts_metadata8(k, v) {
451
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
452
+ return Reflect.metadata(k, v);
453
+ }
454
+ __name(_ts_metadata8, "_ts_metadata");
455
+ var MessageStatusCode;
456
+ (function(MessageStatusCode2) {
457
+ MessageStatusCode2["Pending"] = "pending";
458
+ MessageStatusCode2["Success"] = "success";
459
+ MessageStatusCode2["Failed"] = "failed";
460
+ })(MessageStatusCode || (MessageStatusCode = {}));
461
+ (0, import_type_graphql9.registerEnumType)(MessageStatusCode, {
462
+ name: "MessageStatusCode"
463
+ });
464
+ var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
465
+ code;
466
+ }, "BaseMessageStatus");
467
+ _ts_decorate8([
468
+ (0, import_type_graphql9.Field)(() => MessageStatusCode),
469
+ _ts_metadata8("design:type", String)
470
+ ], BaseMessageStatus.prototype, "code", void 0);
471
+ BaseMessageStatus = _ts_decorate8([
472
+ (0, import_type_graphql9.ObjectType)()
473
+ ], BaseMessageStatus);
474
+ var PendingMessageStatus = class extends BaseMessageStatus {
475
+ code = "pending";
476
+ };
477
+ __name(PendingMessageStatus, "PendingMessageStatus");
478
+ PendingMessageStatus = _ts_decorate8([
479
+ (0, import_type_graphql9.ObjectType)()
480
+ ], PendingMessageStatus);
481
+ var SuccessMessageStatus = class extends BaseMessageStatus {
482
+ code = "success";
483
+ };
484
+ __name(SuccessMessageStatus, "SuccessMessageStatus");
485
+ SuccessMessageStatus = _ts_decorate8([
486
+ (0, import_type_graphql9.ObjectType)()
487
+ ], SuccessMessageStatus);
488
+ var FailedMessageStatus = class extends BaseMessageStatus {
489
+ code = "failed";
490
+ reason;
491
+ };
492
+ __name(FailedMessageStatus, "FailedMessageStatus");
493
+ _ts_decorate8([
494
+ (0, import_type_graphql9.Field)(() => String),
495
+ _ts_metadata8("design:type", String)
496
+ ], FailedMessageStatus.prototype, "reason", void 0);
497
+ FailedMessageStatus = _ts_decorate8([
498
+ (0, import_type_graphql9.ObjectType)()
499
+ ], FailedMessageStatus);
500
+ var MessageStatusUnion = (0, import_type_graphql9.createUnionType)({
501
+ name: "MessageStatus",
502
+ types: () => [
503
+ PendingMessageStatus,
504
+ SuccessMessageStatus,
505
+ FailedMessageStatus
506
+ ]
507
+ });
508
+
509
+ // src/graphql/types/response-status.type.ts
510
+ var import_type_graphql10 = require("type-graphql");
511
+ function _ts_decorate9(decorators, target, key, desc) {
512
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
513
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
514
+ r = Reflect.decorate(decorators, target, key, desc);
515
+ else
516
+ for (var i = decorators.length - 1; i >= 0; i--)
517
+ if (d = decorators[i])
518
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
519
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
520
+ }
521
+ __name(_ts_decorate9, "_ts_decorate");
522
+ function _ts_metadata9(k, v) {
523
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
524
+ return Reflect.metadata(k, v);
525
+ }
526
+ __name(_ts_metadata9, "_ts_metadata");
527
+ var ResponseStatusCode;
528
+ (function(ResponseStatusCode2) {
529
+ ResponseStatusCode2["Pending"] = "pending";
530
+ ResponseStatusCode2["Success"] = "success";
531
+ ResponseStatusCode2["Failed"] = "failed";
532
+ })(ResponseStatusCode || (ResponseStatusCode = {}));
533
+ (0, import_type_graphql10.registerEnumType)(ResponseStatusCode, {
534
+ name: "ResponseStatusCode"
535
+ });
536
+ var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
537
+ code;
538
+ }, "BaseResponseStatus");
539
+ _ts_decorate9([
540
+ (0, import_type_graphql10.Field)(() => ResponseStatusCode),
541
+ _ts_metadata9("design:type", String)
542
+ ], BaseResponseStatus.prototype, "code", void 0);
543
+ BaseResponseStatus = _ts_decorate9([
544
+ (0, import_type_graphql10.InterfaceType)({
545
+ resolveType(value) {
546
+ if (value.code === "success") {
547
+ return SuccessResponseStatus;
548
+ } else if (value.code === "failed") {
549
+ return FailedResponseStatus;
550
+ } else if (value.code === "pending") {
551
+ return PendingResponseStatus;
552
+ }
553
+ return void 0;
554
+ }
555
+ }),
556
+ (0, import_type_graphql10.ObjectType)()
557
+ ], BaseResponseStatus);
558
+ var PendingResponseStatus = class extends BaseResponseStatus {
559
+ code = "pending";
560
+ };
561
+ __name(PendingResponseStatus, "PendingResponseStatus");
562
+ PendingResponseStatus = _ts_decorate9([
563
+ (0, import_type_graphql10.ObjectType)({
564
+ implements: BaseResponseStatus
565
+ })
566
+ ], PendingResponseStatus);
567
+ var SuccessResponseStatus = class extends BaseResponseStatus {
568
+ code = "success";
569
+ };
570
+ __name(SuccessResponseStatus, "SuccessResponseStatus");
571
+ SuccessResponseStatus = _ts_decorate9([
572
+ (0, import_type_graphql10.ObjectType)({
573
+ implements: BaseResponseStatus
574
+ })
575
+ ], SuccessResponseStatus);
576
+ var FailedResponseStatus = class extends BaseResponseStatus {
577
+ code = "failed";
578
+ reason;
579
+ };
580
+ __name(FailedResponseStatus, "FailedResponseStatus");
581
+ _ts_decorate9([
582
+ (0, import_type_graphql10.Field)(() => String),
583
+ _ts_metadata9("design:type", String)
584
+ ], FailedResponseStatus.prototype, "reason", void 0);
585
+ FailedResponseStatus = _ts_decorate9([
586
+ (0, import_type_graphql10.ObjectType)({
587
+ implements: BaseResponseStatus
588
+ })
589
+ ], FailedResponseStatus);
590
+ var ResponseStatusUnion = (0, import_type_graphql10.createUnionType)({
591
+ name: "ResponseStatus",
592
+ types: () => [
593
+ PendingResponseStatus,
594
+ SuccessResponseStatus,
595
+ FailedResponseStatus
596
+ ]
597
+ });
598
+
599
+ // src/graphql/types/copilot-response.type.ts
600
+ function _ts_decorate10(decorators, target, key, desc) {
601
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
602
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
603
+ r = Reflect.decorate(decorators, target, key, desc);
604
+ else
605
+ for (var i = decorators.length - 1; i >= 0; i--)
606
+ if (d = decorators[i])
607
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
608
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
609
+ }
610
+ __name(_ts_decorate10, "_ts_decorate");
611
+ function _ts_metadata10(k, v) {
612
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
613
+ return Reflect.metadata(k, v);
614
+ }
615
+ __name(_ts_metadata10, "_ts_metadata");
616
+ var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
617
+ id;
618
+ createdAt;
619
+ status;
620
+ }, "BaseMessageOutput");
621
+ _ts_decorate10([
622
+ (0, import_type_graphql11.Field)(() => String),
623
+ _ts_metadata10("design:type", String)
624
+ ], BaseMessageOutput.prototype, "id", void 0);
625
+ _ts_decorate10([
626
+ (0, import_type_graphql11.Field)(() => Date),
627
+ _ts_metadata10("design:type", typeof Date === "undefined" ? Object : Date)
628
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
629
+ _ts_decorate10([
630
+ (0, import_type_graphql11.Field)(() => MessageStatusUnion),
631
+ _ts_metadata10("design:type", Object)
632
+ ], BaseMessageOutput.prototype, "status", void 0);
633
+ BaseMessageOutput = _ts_decorate10([
634
+ (0, import_type_graphql11.InterfaceType)({
635
+ resolveType(value) {
636
+ if (value.hasOwnProperty("content")) {
637
+ return TextMessageOutput;
638
+ } else if (value.hasOwnProperty("name")) {
639
+ return ActionExecutionMessageOutput;
640
+ } else if (value.hasOwnProperty("result")) {
641
+ return ResultMessageOutput;
642
+ }
643
+ return void 0;
644
+ }
645
+ })
646
+ ], BaseMessageOutput);
647
+ var TextMessageOutput = class {
648
+ role;
649
+ content;
650
+ };
651
+ __name(TextMessageOutput, "TextMessageOutput");
652
+ _ts_decorate10([
653
+ (0, import_type_graphql11.Field)(() => MessageRole),
654
+ _ts_metadata10("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
655
+ ], TextMessageOutput.prototype, "role", void 0);
656
+ _ts_decorate10([
657
+ (0, import_type_graphql11.Field)(() => [
658
+ String
659
+ ]),
660
+ _ts_metadata10("design:type", Array)
661
+ ], TextMessageOutput.prototype, "content", void 0);
662
+ TextMessageOutput = _ts_decorate10([
663
+ (0, import_type_graphql11.ObjectType)({
664
+ implements: BaseMessageOutput
665
+ })
666
+ ], TextMessageOutput);
667
+ var ActionExecutionMessageOutput = class {
668
+ name;
669
+ scope;
670
+ arguments;
671
+ };
672
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
673
+ _ts_decorate10([
674
+ (0, import_type_graphql11.Field)(() => String),
675
+ _ts_metadata10("design:type", String)
676
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
677
+ _ts_decorate10([
678
+ (0, import_type_graphql11.Field)(() => ActionExecutionScope),
679
+ _ts_metadata10("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
680
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
681
+ _ts_decorate10([
682
+ (0, import_type_graphql11.Field)(() => [
683
+ String
684
+ ]),
685
+ _ts_metadata10("design:type", Array)
686
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
687
+ ActionExecutionMessageOutput = _ts_decorate10([
688
+ (0, import_type_graphql11.ObjectType)({
689
+ implements: BaseMessageOutput
690
+ })
691
+ ], ActionExecutionMessageOutput);
692
+ var ResultMessageOutput = class {
693
+ actionExecutionId;
694
+ actionName;
695
+ result;
696
+ };
697
+ __name(ResultMessageOutput, "ResultMessageOutput");
698
+ _ts_decorate10([
699
+ (0, import_type_graphql11.Field)(() => String),
700
+ _ts_metadata10("design:type", String)
701
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
702
+ _ts_decorate10([
703
+ (0, import_type_graphql11.Field)(() => String),
704
+ _ts_metadata10("design:type", String)
705
+ ], ResultMessageOutput.prototype, "actionName", void 0);
706
+ _ts_decorate10([
707
+ (0, import_type_graphql11.Field)(() => String),
708
+ _ts_metadata10("design:type", String)
709
+ ], ResultMessageOutput.prototype, "result", void 0);
710
+ ResultMessageOutput = _ts_decorate10([
711
+ (0, import_type_graphql11.ObjectType)({
712
+ implements: BaseMessageOutput
713
+ })
714
+ ], ResultMessageOutput);
715
+ var CopilotResponse = class {
716
+ threadId;
717
+ status;
718
+ runId;
719
+ messages;
720
+ };
721
+ __name(CopilotResponse, "CopilotResponse");
722
+ _ts_decorate10([
723
+ (0, import_type_graphql11.Field)(() => String),
724
+ _ts_metadata10("design:type", String)
725
+ ], CopilotResponse.prototype, "threadId", void 0);
726
+ _ts_decorate10([
727
+ (0, import_type_graphql11.Field)(() => ResponseStatusUnion),
728
+ _ts_metadata10("design:type", Object)
729
+ ], CopilotResponse.prototype, "status", void 0);
730
+ _ts_decorate10([
731
+ (0, import_type_graphql11.Field)({
732
+ nullable: true
733
+ }),
734
+ _ts_metadata10("design:type", String)
735
+ ], CopilotResponse.prototype, "runId", void 0);
736
+ _ts_decorate10([
737
+ (0, import_type_graphql11.Field)(() => [
738
+ BaseMessageOutput
739
+ ]),
740
+ _ts_metadata10("design:type", Array)
741
+ ], CopilotResponse.prototype, "messages", void 0);
742
+ CopilotResponse = _ts_decorate10([
743
+ (0, import_type_graphql11.ObjectType)()
744
+ ], CopilotResponse);
745
+
746
+ // src/graphql/resolvers/copilot.resolver.ts
747
+ var import_graphql_yoga = require("graphql-yoga");
748
+ var import_nanoid = require("nanoid");
749
+
750
+ // src/service-adapters/events.ts
751
+ var import_rxjs = require("rxjs");
752
+ var RuntimeEventTypes;
753
+ (function(RuntimeEventTypes2) {
754
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
755
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
756
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
757
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
758
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
759
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
760
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
761
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
762
+
763
+ // src/graphql/resolvers/copilot.resolver.ts
764
+ var import_graphql_scalars = require("graphql-scalars");
765
+ function _ts_decorate11(decorators, target, key, desc) {
766
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
767
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
768
+ r = Reflect.decorate(decorators, target, key, desc);
769
+ else
770
+ for (var i = decorators.length - 1; i >= 0; i--)
771
+ if (d = decorators[i])
772
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
773
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
774
+ }
775
+ __name(_ts_decorate11, "_ts_decorate");
776
+ function _ts_metadata11(k, v) {
777
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
778
+ return Reflect.metadata(k, v);
779
+ }
780
+ __name(_ts_metadata11, "_ts_metadata");
781
+ function _ts_param(paramIndex, decorator) {
782
+ return function(target, key) {
783
+ decorator(target, key, paramIndex);
784
+ };
785
+ }
786
+ __name(_ts_param, "_ts_param");
787
+ var CopilotResolver = class {
788
+ async hello() {
789
+ return "Hello World";
790
+ }
791
+ async generateCopilotResponse(ctx, data, properties) {
792
+ if (properties) {
793
+ ctx._copilotkit.properties = {
794
+ ...ctx._copilotkit.properties,
795
+ ...properties
796
+ };
797
+ }
798
+ const copilotRuntime = ctx._copilotkit.runtime;
799
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
800
+ const responseStatus = new import_rxjs2.Subject();
801
+ const { eventSource, threadId = (0, import_nanoid.nanoid)(), runId } = await copilotRuntime.process({
802
+ serviceAdapter,
803
+ messages: data.messages,
804
+ actions: data.frontend.actions,
805
+ threadId: data.threadId,
806
+ runId: data.runId,
807
+ publicApiKey: void 0
808
+ });
809
+ const response = {
810
+ threadId,
811
+ runId,
812
+ status: (0, import_rxjs2.firstValueFrom)(responseStatus),
813
+ messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
814
+ const eventStream = eventSource.process(copilotRuntime.actions).pipe(
815
+ // shareReplay() ensures that later subscribers will see the whole stream instead of
816
+ // just the events that were emitted after the subscriber was added.
817
+ (0, import_rxjs2.shareReplay)()
818
+ );
819
+ eventStream.subscribe({
820
+ next: async (event) => {
821
+ switch (event.type) {
822
+ case RuntimeEventTypes.TextMessageStart:
823
+ const textMessageContentStream = eventStream.pipe(
824
+ // skip until this message start event
825
+ (0, import_rxjs2.skipWhile)((e) => e !== event),
826
+ // take until the message end event
827
+ (0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
828
+ );
829
+ const streamingTextStatus = new import_rxjs2.Subject();
830
+ pushMessage({
831
+ id: (0, import_nanoid.nanoid)(),
832
+ status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
833
+ createdAt: /* @__PURE__ */ new Date(),
834
+ role: MessageRole.assistant,
835
+ content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
836
+ await textMessageContentStream.forEach(async (e) => {
837
+ if (e.type == RuntimeEventTypes.TextMessageContent) {
838
+ await pushTextChunk(e.content);
839
+ }
840
+ });
841
+ stopStreamingText();
842
+ streamingTextStatus.next(new SuccessMessageStatus());
843
+ })
844
+ });
845
+ break;
846
+ case RuntimeEventTypes.ActionExecutionStart:
847
+ const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs2.skipWhile)((e) => e !== event), (0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
848
+ const streamingArgumentsStatus = new import_rxjs2.Subject();
849
+ pushMessage({
850
+ id: event.actionExecutionId,
851
+ status: (0, import_rxjs2.firstValueFrom)(streamingArgumentsStatus),
852
+ createdAt: /* @__PURE__ */ new Date(),
853
+ name: event.actionName,
854
+ scope: event.scope,
855
+ arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
856
+ await actionExecutionArgumentStream.forEach(async (e) => {
857
+ if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
858
+ await pushArgumentsChunk(e.args);
859
+ }
860
+ });
861
+ stopStreamingArguments();
862
+ streamingArgumentsStatus.next(new SuccessMessageStatus());
863
+ })
864
+ });
865
+ break;
866
+ case RuntimeEventTypes.ActionExecutionResult:
867
+ pushMessage({
868
+ id: (0, import_nanoid.nanoid)(),
869
+ status: new SuccessMessageStatus(),
870
+ createdAt: /* @__PURE__ */ new Date(),
871
+ actionExecutionId: event.actionExecutionId,
872
+ actionName: event.actionName,
873
+ result: event.result
874
+ });
875
+ break;
876
+ }
877
+ },
878
+ error: (err) => console.error("Error in event source", err),
879
+ complete: () => {
880
+ responseStatus.next(new SuccessResponseStatus());
881
+ stopStreamingMessages();
882
+ }
883
+ });
884
+ })
885
+ };
886
+ return response;
887
+ }
888
+ };
889
+ __name(CopilotResolver, "CopilotResolver");
890
+ _ts_decorate11([
891
+ (0, import_type_graphql12.Query)(() => String),
892
+ _ts_metadata11("design:type", Function),
893
+ _ts_metadata11("design:paramtypes", []),
894
+ _ts_metadata11("design:returntype", Promise)
895
+ ], CopilotResolver.prototype, "hello", null);
896
+ _ts_decorate11([
897
+ (0, import_type_graphql12.Mutation)(() => CopilotResponse),
898
+ _ts_param(0, (0, import_type_graphql12.Ctx)()),
899
+ _ts_param(1, (0, import_type_graphql12.Arg)("data")),
900
+ _ts_param(2, (0, import_type_graphql12.Arg)("properties", () => import_graphql_scalars.GraphQLJSONObject, {
901
+ nullable: true
902
+ })),
903
+ _ts_metadata11("design:type", Function),
904
+ _ts_metadata11("design:paramtypes", [
905
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
906
+ typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
907
+ typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
908
+ ]),
909
+ _ts_metadata11("design:returntype", Promise)
910
+ ], CopilotResolver.prototype, "generateCopilotResponse", null);
911
+ CopilotResolver = _ts_decorate11([
912
+ (0, import_type_graphql12.Resolver)(() => CopilotResponse)
913
+ ], CopilotResolver);
914
+
915
+ // src/lib/integrations/shared.ts
916
+ var import_plugin_defer_stream = require("@graphql-yoga/plugin-defer-stream");
917
+ async function createContext(initialContext, copilotKitContext) {
918
+ const ctx = {
919
+ ...initialContext,
920
+ _copilotkit: {
921
+ ...copilotKitContext
922
+ }
923
+ };
924
+ return ctx;
925
+ }
926
+ __name(createContext, "createContext");
927
+ function buildSchema(options = {}) {
928
+ const schema = (0, import_type_graphql13.buildSchemaSync)({
929
+ resolvers: [
930
+ CopilotResolver
931
+ ],
932
+ emitSchemaFile: options.emitSchemaFile
933
+ });
934
+ return schema;
935
+ }
936
+ __name(buildSchema, "buildSchema");
937
+ function getCommonConfig(options) {
938
+ return {
939
+ schema: buildSchema(),
940
+ plugins: [
941
+ (0, import_plugin_defer_stream.useDeferStream)()
942
+ ],
943
+ context: (ctx) => createContext(ctx, {
944
+ runtime: options.runtime,
945
+ serviceAdapter: options.serviceAdapter,
946
+ properties: {}
947
+ })
948
+ };
949
+ }
950
+ __name(getCommonConfig, "getCommonConfig");
951
+
952
+ // src/lib/integrations/node-http/index.ts
953
+ function copilotRuntimeNodeHttpEndpoint({ runtime, endpoint, serviceAdapter }) {
954
+ const commonConfig = getCommonConfig({
955
+ runtime,
956
+ serviceAdapter
957
+ });
958
+ const yoga = (0, import_graphql_yoga2.createYoga)({
959
+ ...commonConfig,
960
+ graphqlEndpoint: endpoint
961
+ });
962
+ return yoga;
963
+ }
964
+ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
965
+ // Annotate the CommonJS export names for ESM import in node:
966
+ 0 && (module.exports = {
967
+ copilotRuntimeNodeHttpEndpoint
968
+ });
969
+ //# sourceMappingURL=index.js.map