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