@copilotkit/runtime 1.0.0-beta.0 → 1.0.0-beta.2
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.
- package/.turbo/turbo-build.log +79 -65
- package/CHANGELOG.md +16 -0
- package/__snapshots__/schema/schema.graphql +15 -1
- package/dist/chunk-44O2JGUY.mjs +12 -0
- package/dist/{chunk-6YGDE3YI.mjs → chunk-6YZWDFF6.mjs} +154 -19
- package/dist/chunk-6YZWDFF6.mjs.map +1 -0
- package/dist/{chunk-JBDOA7MK.mjs → chunk-7QCEK4DP.mjs} +4 -4
- package/dist/{chunk-FRK6BXXV.mjs → chunk-DVDKD6F5.mjs} +3 -3
- package/dist/{chunk-OZMCHYYR.mjs → chunk-GEIBJJQ4.mjs} +3 -3
- package/dist/chunk-LGRJFIJL.mjs +24 -0
- package/dist/chunk-LGRJFIJL.mjs.map +1 -0
- package/dist/{chunk-6NZ4UMOD.mjs → chunk-RMZWGQ46.mjs} +2 -2
- package/dist/{chunk-2PJG3NAC.mjs → chunk-SVAGAMIO.mjs} +17 -4
- package/dist/chunk-SVAGAMIO.mjs.map +1 -0
- package/dist/{chunk-BYB2LNMK.mjs → chunk-U3V2BCGI.mjs} +2 -2
- package/dist/{chunk-JIKPSUGQ.mjs → chunk-WE6CBBR3.mjs} +5 -5
- package/dist/chunk-X4FJTCSL.mjs +24 -0
- package/dist/chunk-X4FJTCSL.mjs.map +1 -0
- package/dist/graphql/types/base/index.mjs +2 -2
- package/dist/graphql/types/converted/index.mjs +3 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +187 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -9
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.d.ts +6 -3
- package/dist/lib/index.js +187 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +17 -9
- package/dist/lib/integrations/index.d.ts +6 -3
- package/dist/lib/integrations/index.js +187 -13
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +15 -7
- package/dist/lib/integrations/nest/index.d.ts +14 -0
- package/dist/lib/integrations/nest/index.js +1481 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +13 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +14 -0
- package/dist/lib/integrations/node-express/index.js +1481 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +13 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +6 -2
- package/dist/lib/integrations/node-http/index.js +147 -13
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +6 -6
- package/dist/{pages-router-e81920d5.d.ts → pages-router-24897543.d.ts} +1 -1
- package/dist/service-adapters/index.mjs +5 -5
- package/dist/{index-0e75acd2.d.ts → shared-48c0f7b8.d.ts} +2 -5
- package/dist/utils/index.mjs +2 -2
- package/package.json +2 -2
- package/src/graphql/inputs/cloud-guardrails.input.ts +2 -2
- package/src/graphql/inputs/generate-copilot-response.input.ts +10 -0
- package/src/graphql/resolvers/copilot.resolver.ts +12 -3
- package/src/graphql/types/enums.ts +13 -0
- package/src/lib/integrations/index.ts +2 -0
- package/src/lib/integrations/nest/index.ts +14 -0
- package/src/lib/integrations/nextjs/app-router.ts +10 -0
- package/src/lib/integrations/nextjs/pages-router.ts +10 -0
- package/src/lib/integrations/node-express/index.ts +14 -0
- package/src/lib/integrations/node-http/index.ts +10 -0
- package/src/lib/integrations/shared.ts +14 -1
- package/src/lib/telemetry-client.ts +9 -0
- package/dist/chunk-2PJG3NAC.mjs.map +0 -1
- package/dist/chunk-6YGDE3YI.mjs.map +0 -1
- package/dist/chunk-RHQLCJGG.mjs +0 -7
- /package/dist/{chunk-RHQLCJGG.mjs.map → chunk-44O2JGUY.mjs.map} +0 -0
- /package/dist/{chunk-JBDOA7MK.mjs.map → chunk-7QCEK4DP.mjs.map} +0 -0
- /package/dist/{chunk-FRK6BXXV.mjs.map → chunk-DVDKD6F5.mjs.map} +0 -0
- /package/dist/{chunk-OZMCHYYR.mjs.map → chunk-GEIBJJQ4.mjs.map} +0 -0
- /package/dist/{chunk-6NZ4UMOD.mjs.map → chunk-RMZWGQ46.mjs.map} +0 -0
- /package/dist/{chunk-BYB2LNMK.mjs.map → chunk-U3V2BCGI.mjs.map} +0 -0
- /package/dist/{chunk-JIKPSUGQ.mjs.map → chunk-WE6CBBR3.mjs.map} +0 -0
|
@@ -0,0 +1,1481 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// package.json
|
|
34
|
+
var require_package = __commonJS({
|
|
35
|
+
"package.json"(exports, module2) {
|
|
36
|
+
module2.exports = {
|
|
37
|
+
name: "@copilotkit/runtime",
|
|
38
|
+
private: false,
|
|
39
|
+
publishConfig: {
|
|
40
|
+
access: "public"
|
|
41
|
+
},
|
|
42
|
+
version: "1.0.0-beta.2",
|
|
43
|
+
sideEffects: false,
|
|
44
|
+
main: "./dist/index.js",
|
|
45
|
+
module: "./dist/index.mjs",
|
|
46
|
+
exports: {
|
|
47
|
+
".": "./dist/index.js"
|
|
48
|
+
},
|
|
49
|
+
types: "./dist/index.d.ts",
|
|
50
|
+
license: "MIT",
|
|
51
|
+
scripts: {
|
|
52
|
+
build: "tsup --clean",
|
|
53
|
+
dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
|
|
54
|
+
test: "jest --passWithNoTests",
|
|
55
|
+
"check-types": "tsc --noEmit",
|
|
56
|
+
clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
57
|
+
"generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts"
|
|
58
|
+
},
|
|
59
|
+
devDependencies: {
|
|
60
|
+
"@swc/core": "1.5.28",
|
|
61
|
+
"@types/express": "^4.17.21",
|
|
62
|
+
"@types/jest": "^29.5.4",
|
|
63
|
+
"@types/node": "^18.11.17",
|
|
64
|
+
"@whatwg-node/server": "^0.9.34",
|
|
65
|
+
eslint: "^8.56.0",
|
|
66
|
+
"eslint-config-custom": "workspace:*",
|
|
67
|
+
jest: "^29.6.4",
|
|
68
|
+
nodemon: "^3.1.3",
|
|
69
|
+
"ts-jest": "^29.1.1",
|
|
70
|
+
"ts-node": "^10.9.2",
|
|
71
|
+
tsconfig: "workspace:*",
|
|
72
|
+
tsup: "^6.7.0",
|
|
73
|
+
typescript: "^5.2.3"
|
|
74
|
+
},
|
|
75
|
+
dependencies: {
|
|
76
|
+
"@copilotkit/shared": "workspace:*",
|
|
77
|
+
"@google/generative-ai": "^0.11.2",
|
|
78
|
+
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
79
|
+
"@langchain/community": "^0.0.53",
|
|
80
|
+
"@langchain/core": "^0.1.61",
|
|
81
|
+
"@langchain/openai": "^0.0.28",
|
|
82
|
+
"class-transformer": "^0.5.1",
|
|
83
|
+
express: "^4.19.2",
|
|
84
|
+
graphql: "^16.8.1",
|
|
85
|
+
"graphql-scalars": "^1.23.0",
|
|
86
|
+
"graphql-yoga": "^5.3.1",
|
|
87
|
+
"groq-sdk": "^0.5.0",
|
|
88
|
+
"js-tiktoken": "^1.0.8",
|
|
89
|
+
langchain: "^0.1.36",
|
|
90
|
+
nanoid: "3.3.4",
|
|
91
|
+
openai: "^4.50.0",
|
|
92
|
+
pino: "^9.2.0",
|
|
93
|
+
"pino-pretty": "^11.2.1",
|
|
94
|
+
"reflect-metadata": "^0.2.2",
|
|
95
|
+
rxjs: "^7.8.1",
|
|
96
|
+
tiktoken: "^1.0.15",
|
|
97
|
+
"type-graphql": "2.0.0-rc.1",
|
|
98
|
+
zod: "^3.23.3"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// src/lib/integrations/nest/index.ts
|
|
105
|
+
var nest_exports = {};
|
|
106
|
+
__export(nest_exports, {
|
|
107
|
+
copilotRuntimeNestEndpoint: () => copilotRuntimeNestEndpoint
|
|
108
|
+
});
|
|
109
|
+
module.exports = __toCommonJS(nest_exports);
|
|
110
|
+
|
|
111
|
+
// src/lib/integrations/node-http/index.ts
|
|
112
|
+
var import_graphql_yoga2 = require("graphql-yoga");
|
|
113
|
+
|
|
114
|
+
// src/lib/integrations/shared.ts
|
|
115
|
+
var import_type_graphql13 = require("type-graphql");
|
|
116
|
+
|
|
117
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
118
|
+
var import_type_graphql12 = require("type-graphql");
|
|
119
|
+
var import_rxjs2 = require("rxjs");
|
|
120
|
+
|
|
121
|
+
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
122
|
+
var import_type_graphql8 = require("type-graphql");
|
|
123
|
+
|
|
124
|
+
// src/graphql/inputs/message.input.ts
|
|
125
|
+
var import_type_graphql3 = require("type-graphql");
|
|
126
|
+
|
|
127
|
+
// src/graphql/types/enums.ts
|
|
128
|
+
var import_type_graphql = require("type-graphql");
|
|
129
|
+
var MessageRole;
|
|
130
|
+
(function(MessageRole2) {
|
|
131
|
+
MessageRole2["user"] = "user";
|
|
132
|
+
MessageRole2["assistant"] = "assistant";
|
|
133
|
+
MessageRole2["system"] = "system";
|
|
134
|
+
})(MessageRole || (MessageRole = {}));
|
|
135
|
+
var ActionExecutionScope;
|
|
136
|
+
(function(ActionExecutionScope2) {
|
|
137
|
+
ActionExecutionScope2["server"] = "server";
|
|
138
|
+
ActionExecutionScope2["client"] = "client";
|
|
139
|
+
})(ActionExecutionScope || (ActionExecutionScope = {}));
|
|
140
|
+
var CopilotRequestType;
|
|
141
|
+
(function(CopilotRequestType2) {
|
|
142
|
+
CopilotRequestType2["Chat"] = "Chat";
|
|
143
|
+
CopilotRequestType2["Task"] = "Task";
|
|
144
|
+
CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
|
|
145
|
+
CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
|
|
146
|
+
CopilotRequestType2["Suggestion"] = "Suggestion";
|
|
147
|
+
})(CopilotRequestType || (CopilotRequestType = {}));
|
|
148
|
+
(0, import_type_graphql.registerEnumType)(MessageRole, {
|
|
149
|
+
name: "MessageRole",
|
|
150
|
+
description: "The role of the message"
|
|
151
|
+
});
|
|
152
|
+
(0, import_type_graphql.registerEnumType)(ActionExecutionScope, {
|
|
153
|
+
name: "ActionExecutionScope",
|
|
154
|
+
description: "The scope of the action"
|
|
155
|
+
});
|
|
156
|
+
(0, import_type_graphql.registerEnumType)(CopilotRequestType, {
|
|
157
|
+
name: "CopilotRequestType",
|
|
158
|
+
description: "The type of Copilot request"
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// src/graphql/types/base/index.ts
|
|
162
|
+
var import_type_graphql2 = require("type-graphql");
|
|
163
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
164
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
165
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
166
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
167
|
+
else
|
|
168
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
169
|
+
if (d = decorators[i])
|
|
170
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
171
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
172
|
+
}
|
|
173
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
174
|
+
function _ts_metadata(k, v) {
|
|
175
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
176
|
+
return Reflect.metadata(k, v);
|
|
177
|
+
}
|
|
178
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
179
|
+
var BaseMessage = class {
|
|
180
|
+
id;
|
|
181
|
+
createdAt;
|
|
182
|
+
};
|
|
183
|
+
__name(BaseMessage, "BaseMessage");
|
|
184
|
+
_ts_decorate([
|
|
185
|
+
(0, import_type_graphql2.Field)(() => String),
|
|
186
|
+
_ts_metadata("design:type", String)
|
|
187
|
+
], BaseMessage.prototype, "id", void 0);
|
|
188
|
+
_ts_decorate([
|
|
189
|
+
(0, import_type_graphql2.Field)(() => Date),
|
|
190
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
191
|
+
], BaseMessage.prototype, "createdAt", void 0);
|
|
192
|
+
BaseMessage = _ts_decorate([
|
|
193
|
+
(0, import_type_graphql2.InputType)()
|
|
194
|
+
], BaseMessage);
|
|
195
|
+
|
|
196
|
+
// src/graphql/inputs/message.input.ts
|
|
197
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
198
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
199
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
200
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
201
|
+
else
|
|
202
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
203
|
+
if (d = decorators[i])
|
|
204
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
205
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
206
|
+
}
|
|
207
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
208
|
+
function _ts_metadata2(k, v) {
|
|
209
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
210
|
+
return Reflect.metadata(k, v);
|
|
211
|
+
}
|
|
212
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
213
|
+
var MessageInput = class extends BaseMessage {
|
|
214
|
+
textMessage;
|
|
215
|
+
actionExecutionMessage;
|
|
216
|
+
resultMessage;
|
|
217
|
+
};
|
|
218
|
+
__name(MessageInput, "MessageInput");
|
|
219
|
+
_ts_decorate2([
|
|
220
|
+
(0, import_type_graphql3.Field)(() => TextMessageInput, {
|
|
221
|
+
nullable: true
|
|
222
|
+
}),
|
|
223
|
+
_ts_metadata2("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
|
|
224
|
+
], MessageInput.prototype, "textMessage", void 0);
|
|
225
|
+
_ts_decorate2([
|
|
226
|
+
(0, import_type_graphql3.Field)(() => ActionExecutionMessageInput, {
|
|
227
|
+
nullable: true
|
|
228
|
+
}),
|
|
229
|
+
_ts_metadata2("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
|
|
230
|
+
], MessageInput.prototype, "actionExecutionMessage", void 0);
|
|
231
|
+
_ts_decorate2([
|
|
232
|
+
(0, import_type_graphql3.Field)(() => ResultMessageInput, {
|
|
233
|
+
nullable: true
|
|
234
|
+
}),
|
|
235
|
+
_ts_metadata2("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
|
|
236
|
+
], MessageInput.prototype, "resultMessage", void 0);
|
|
237
|
+
MessageInput = _ts_decorate2([
|
|
238
|
+
(0, import_type_graphql3.InputType)()
|
|
239
|
+
], MessageInput);
|
|
240
|
+
var TextMessageInput = class {
|
|
241
|
+
content;
|
|
242
|
+
role;
|
|
243
|
+
};
|
|
244
|
+
__name(TextMessageInput, "TextMessageInput");
|
|
245
|
+
_ts_decorate2([
|
|
246
|
+
(0, import_type_graphql3.Field)(() => String),
|
|
247
|
+
_ts_metadata2("design:type", String)
|
|
248
|
+
], TextMessageInput.prototype, "content", void 0);
|
|
249
|
+
_ts_decorate2([
|
|
250
|
+
(0, import_type_graphql3.Field)(() => MessageRole),
|
|
251
|
+
_ts_metadata2("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
252
|
+
], TextMessageInput.prototype, "role", void 0);
|
|
253
|
+
TextMessageInput = _ts_decorate2([
|
|
254
|
+
(0, import_type_graphql3.InputType)()
|
|
255
|
+
], TextMessageInput);
|
|
256
|
+
var ActionExecutionMessageInput = class {
|
|
257
|
+
name;
|
|
258
|
+
arguments;
|
|
259
|
+
scope;
|
|
260
|
+
};
|
|
261
|
+
__name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
|
|
262
|
+
_ts_decorate2([
|
|
263
|
+
(0, import_type_graphql3.Field)(() => String),
|
|
264
|
+
_ts_metadata2("design:type", String)
|
|
265
|
+
], ActionExecutionMessageInput.prototype, "name", void 0);
|
|
266
|
+
_ts_decorate2([
|
|
267
|
+
(0, import_type_graphql3.Field)(() => String),
|
|
268
|
+
_ts_metadata2("design:type", String)
|
|
269
|
+
], ActionExecutionMessageInput.prototype, "arguments", void 0);
|
|
270
|
+
_ts_decorate2([
|
|
271
|
+
(0, import_type_graphql3.Field)(() => ActionExecutionScope),
|
|
272
|
+
_ts_metadata2("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
|
|
273
|
+
], ActionExecutionMessageInput.prototype, "scope", void 0);
|
|
274
|
+
ActionExecutionMessageInput = _ts_decorate2([
|
|
275
|
+
(0, import_type_graphql3.InputType)()
|
|
276
|
+
], ActionExecutionMessageInput);
|
|
277
|
+
var ResultMessageInput = class {
|
|
278
|
+
actionExecutionId;
|
|
279
|
+
actionName;
|
|
280
|
+
result;
|
|
281
|
+
};
|
|
282
|
+
__name(ResultMessageInput, "ResultMessageInput");
|
|
283
|
+
_ts_decorate2([
|
|
284
|
+
(0, import_type_graphql3.Field)(() => String),
|
|
285
|
+
_ts_metadata2("design:type", String)
|
|
286
|
+
], ResultMessageInput.prototype, "actionExecutionId", void 0);
|
|
287
|
+
_ts_decorate2([
|
|
288
|
+
(0, import_type_graphql3.Field)(() => String),
|
|
289
|
+
_ts_metadata2("design:type", String)
|
|
290
|
+
], ResultMessageInput.prototype, "actionName", void 0);
|
|
291
|
+
_ts_decorate2([
|
|
292
|
+
(0, import_type_graphql3.Field)(() => String),
|
|
293
|
+
_ts_metadata2("design:type", String)
|
|
294
|
+
], ResultMessageInput.prototype, "result", void 0);
|
|
295
|
+
ResultMessageInput = _ts_decorate2([
|
|
296
|
+
(0, import_type_graphql3.InputType)()
|
|
297
|
+
], ResultMessageInput);
|
|
298
|
+
|
|
299
|
+
// src/graphql/inputs/frontend.input.ts
|
|
300
|
+
var import_type_graphql5 = require("type-graphql");
|
|
301
|
+
|
|
302
|
+
// src/graphql/inputs/action.input.ts
|
|
303
|
+
var import_type_graphql4 = require("type-graphql");
|
|
304
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
305
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
306
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
307
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
308
|
+
else
|
|
309
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
310
|
+
if (d = decorators[i])
|
|
311
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
312
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
313
|
+
}
|
|
314
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
315
|
+
function _ts_metadata3(k, v) {
|
|
316
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
317
|
+
return Reflect.metadata(k, v);
|
|
318
|
+
}
|
|
319
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
320
|
+
var ActionInput = class {
|
|
321
|
+
name;
|
|
322
|
+
description;
|
|
323
|
+
jsonSchema;
|
|
324
|
+
};
|
|
325
|
+
__name(ActionInput, "ActionInput");
|
|
326
|
+
_ts_decorate3([
|
|
327
|
+
(0, import_type_graphql4.Field)(() => String),
|
|
328
|
+
_ts_metadata3("design:type", String)
|
|
329
|
+
], ActionInput.prototype, "name", void 0);
|
|
330
|
+
_ts_decorate3([
|
|
331
|
+
(0, import_type_graphql4.Field)(() => String),
|
|
332
|
+
_ts_metadata3("design:type", String)
|
|
333
|
+
], ActionInput.prototype, "description", void 0);
|
|
334
|
+
_ts_decorate3([
|
|
335
|
+
(0, import_type_graphql4.Field)(() => String),
|
|
336
|
+
_ts_metadata3("design:type", String)
|
|
337
|
+
], ActionInput.prototype, "jsonSchema", void 0);
|
|
338
|
+
ActionInput = _ts_decorate3([
|
|
339
|
+
(0, import_type_graphql4.InputType)()
|
|
340
|
+
], ActionInput);
|
|
341
|
+
|
|
342
|
+
// src/graphql/inputs/frontend.input.ts
|
|
343
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
344
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
345
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
346
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
347
|
+
else
|
|
348
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
349
|
+
if (d = decorators[i])
|
|
350
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
351
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
352
|
+
}
|
|
353
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
354
|
+
function _ts_metadata4(k, v) {
|
|
355
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
356
|
+
return Reflect.metadata(k, v);
|
|
357
|
+
}
|
|
358
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
359
|
+
var FrontendInput = class {
|
|
360
|
+
toDeprecate_fullContext;
|
|
361
|
+
actions;
|
|
362
|
+
};
|
|
363
|
+
__name(FrontendInput, "FrontendInput");
|
|
364
|
+
_ts_decorate4([
|
|
365
|
+
(0, import_type_graphql5.Field)(() => String, {
|
|
366
|
+
nullable: true
|
|
367
|
+
}),
|
|
368
|
+
_ts_metadata4("design:type", String)
|
|
369
|
+
], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
|
|
370
|
+
_ts_decorate4([
|
|
371
|
+
(0, import_type_graphql5.Field)(() => [
|
|
372
|
+
ActionInput
|
|
373
|
+
]),
|
|
374
|
+
_ts_metadata4("design:type", Array)
|
|
375
|
+
], FrontendInput.prototype, "actions", void 0);
|
|
376
|
+
FrontendInput = _ts_decorate4([
|
|
377
|
+
(0, import_type_graphql5.InputType)()
|
|
378
|
+
], FrontendInput);
|
|
379
|
+
|
|
380
|
+
// src/graphql/inputs/cloud.input.ts
|
|
381
|
+
var import_type_graphql7 = require("type-graphql");
|
|
382
|
+
|
|
383
|
+
// src/graphql/inputs/cloud-guardrails.input.ts
|
|
384
|
+
var import_type_graphql6 = require("type-graphql");
|
|
385
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
386
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
387
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
388
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
389
|
+
else
|
|
390
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
391
|
+
if (d = decorators[i])
|
|
392
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
393
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
394
|
+
}
|
|
395
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
396
|
+
function _ts_metadata5(k, v) {
|
|
397
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
398
|
+
return Reflect.metadata(k, v);
|
|
399
|
+
}
|
|
400
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
401
|
+
var GuardrailsRuleInput = class {
|
|
402
|
+
allowList = [];
|
|
403
|
+
denyList = [];
|
|
404
|
+
};
|
|
405
|
+
__name(GuardrailsRuleInput, "GuardrailsRuleInput");
|
|
406
|
+
_ts_decorate5([
|
|
407
|
+
(0, import_type_graphql6.Field)(() => [
|
|
408
|
+
String
|
|
409
|
+
], {
|
|
410
|
+
nullable: true
|
|
411
|
+
}),
|
|
412
|
+
_ts_metadata5("design:type", Array)
|
|
413
|
+
], GuardrailsRuleInput.prototype, "allowList", void 0);
|
|
414
|
+
_ts_decorate5([
|
|
415
|
+
(0, import_type_graphql6.Field)(() => [
|
|
416
|
+
String
|
|
417
|
+
], {
|
|
418
|
+
nullable: true
|
|
419
|
+
}),
|
|
420
|
+
_ts_metadata5("design:type", Array)
|
|
421
|
+
], GuardrailsRuleInput.prototype, "denyList", void 0);
|
|
422
|
+
GuardrailsRuleInput = _ts_decorate5([
|
|
423
|
+
(0, import_type_graphql6.InputType)()
|
|
424
|
+
], GuardrailsRuleInput);
|
|
425
|
+
var GuardrailsInput = class {
|
|
426
|
+
inputValidationRules;
|
|
427
|
+
};
|
|
428
|
+
__name(GuardrailsInput, "GuardrailsInput");
|
|
429
|
+
_ts_decorate5([
|
|
430
|
+
(0, import_type_graphql6.Field)(() => GuardrailsRuleInput, {
|
|
431
|
+
nullable: false
|
|
432
|
+
}),
|
|
433
|
+
_ts_metadata5("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
|
|
434
|
+
], GuardrailsInput.prototype, "inputValidationRules", void 0);
|
|
435
|
+
GuardrailsInput = _ts_decorate5([
|
|
436
|
+
(0, import_type_graphql6.InputType)()
|
|
437
|
+
], GuardrailsInput);
|
|
438
|
+
|
|
439
|
+
// src/graphql/inputs/cloud.input.ts
|
|
440
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
441
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
442
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
443
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
444
|
+
else
|
|
445
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
446
|
+
if (d = decorators[i])
|
|
447
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
448
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
449
|
+
}
|
|
450
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
451
|
+
function _ts_metadata6(k, v) {
|
|
452
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
453
|
+
return Reflect.metadata(k, v);
|
|
454
|
+
}
|
|
455
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
456
|
+
var CloudInput = class {
|
|
457
|
+
guardrails;
|
|
458
|
+
};
|
|
459
|
+
__name(CloudInput, "CloudInput");
|
|
460
|
+
_ts_decorate6([
|
|
461
|
+
(0, import_type_graphql7.Field)(() => GuardrailsInput, {
|
|
462
|
+
nullable: true
|
|
463
|
+
}),
|
|
464
|
+
_ts_metadata6("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
|
|
465
|
+
], CloudInput.prototype, "guardrails", void 0);
|
|
466
|
+
CloudInput = _ts_decorate6([
|
|
467
|
+
(0, import_type_graphql7.InputType)()
|
|
468
|
+
], CloudInput);
|
|
469
|
+
|
|
470
|
+
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
471
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
472
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
473
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
474
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
475
|
+
else
|
|
476
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
477
|
+
if (d = decorators[i])
|
|
478
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
479
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
480
|
+
}
|
|
481
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
482
|
+
function _ts_metadata7(k, v) {
|
|
483
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
484
|
+
return Reflect.metadata(k, v);
|
|
485
|
+
}
|
|
486
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
487
|
+
var GenerateCopilotResponseMetadataInput = class {
|
|
488
|
+
requestType;
|
|
489
|
+
};
|
|
490
|
+
__name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
|
|
491
|
+
_ts_decorate7([
|
|
492
|
+
(0, import_type_graphql8.Field)(() => CopilotRequestType, {
|
|
493
|
+
nullable: true
|
|
494
|
+
}),
|
|
495
|
+
_ts_metadata7("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
|
|
496
|
+
], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
|
|
497
|
+
GenerateCopilotResponseMetadataInput = _ts_decorate7([
|
|
498
|
+
(0, import_type_graphql8.InputType)()
|
|
499
|
+
], GenerateCopilotResponseMetadataInput);
|
|
500
|
+
var GenerateCopilotResponseInput = class {
|
|
501
|
+
metadata;
|
|
502
|
+
threadId;
|
|
503
|
+
runId;
|
|
504
|
+
messages;
|
|
505
|
+
frontend;
|
|
506
|
+
cloud;
|
|
507
|
+
};
|
|
508
|
+
__name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
|
|
509
|
+
_ts_decorate7([
|
|
510
|
+
(0, import_type_graphql8.Field)(() => GenerateCopilotResponseMetadataInput, {
|
|
511
|
+
nullable: false
|
|
512
|
+
}),
|
|
513
|
+
_ts_metadata7("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
|
|
514
|
+
], GenerateCopilotResponseInput.prototype, "metadata", void 0);
|
|
515
|
+
_ts_decorate7([
|
|
516
|
+
(0, import_type_graphql8.Field)(() => String, {
|
|
517
|
+
nullable: true
|
|
518
|
+
}),
|
|
519
|
+
_ts_metadata7("design:type", String)
|
|
520
|
+
], GenerateCopilotResponseInput.prototype, "threadId", void 0);
|
|
521
|
+
_ts_decorate7([
|
|
522
|
+
(0, import_type_graphql8.Field)(() => String, {
|
|
523
|
+
nullable: true
|
|
524
|
+
}),
|
|
525
|
+
_ts_metadata7("design:type", String)
|
|
526
|
+
], GenerateCopilotResponseInput.prototype, "runId", void 0);
|
|
527
|
+
_ts_decorate7([
|
|
528
|
+
(0, import_type_graphql8.Field)(() => [
|
|
529
|
+
MessageInput
|
|
530
|
+
]),
|
|
531
|
+
_ts_metadata7("design:type", Array)
|
|
532
|
+
], GenerateCopilotResponseInput.prototype, "messages", void 0);
|
|
533
|
+
_ts_decorate7([
|
|
534
|
+
(0, import_type_graphql8.Field)(() => FrontendInput),
|
|
535
|
+
_ts_metadata7("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
|
|
536
|
+
], GenerateCopilotResponseInput.prototype, "frontend", void 0);
|
|
537
|
+
_ts_decorate7([
|
|
538
|
+
(0, import_type_graphql8.Field)(() => CloudInput, {
|
|
539
|
+
nullable: true
|
|
540
|
+
}),
|
|
541
|
+
_ts_metadata7("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
|
|
542
|
+
], GenerateCopilotResponseInput.prototype, "cloud", void 0);
|
|
543
|
+
GenerateCopilotResponseInput = _ts_decorate7([
|
|
544
|
+
(0, import_type_graphql8.InputType)()
|
|
545
|
+
], GenerateCopilotResponseInput);
|
|
546
|
+
|
|
547
|
+
// src/graphql/types/copilot-response.type.ts
|
|
548
|
+
var import_type_graphql11 = require("type-graphql");
|
|
549
|
+
|
|
550
|
+
// src/graphql/types/message-status.type.ts
|
|
551
|
+
var import_type_graphql9 = require("type-graphql");
|
|
552
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
553
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
554
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
555
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
556
|
+
else
|
|
557
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
558
|
+
if (d = decorators[i])
|
|
559
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
560
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
561
|
+
}
|
|
562
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
563
|
+
function _ts_metadata8(k, v) {
|
|
564
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
565
|
+
return Reflect.metadata(k, v);
|
|
566
|
+
}
|
|
567
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
568
|
+
var MessageStatusCode;
|
|
569
|
+
(function(MessageStatusCode2) {
|
|
570
|
+
MessageStatusCode2["Pending"] = "pending";
|
|
571
|
+
MessageStatusCode2["Success"] = "success";
|
|
572
|
+
MessageStatusCode2["Failed"] = "failed";
|
|
573
|
+
})(MessageStatusCode || (MessageStatusCode = {}));
|
|
574
|
+
(0, import_type_graphql9.registerEnumType)(MessageStatusCode, {
|
|
575
|
+
name: "MessageStatusCode"
|
|
576
|
+
});
|
|
577
|
+
var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
|
|
578
|
+
code;
|
|
579
|
+
}, "BaseMessageStatus");
|
|
580
|
+
_ts_decorate8([
|
|
581
|
+
(0, import_type_graphql9.Field)(() => MessageStatusCode),
|
|
582
|
+
_ts_metadata8("design:type", String)
|
|
583
|
+
], BaseMessageStatus.prototype, "code", void 0);
|
|
584
|
+
BaseMessageStatus = _ts_decorate8([
|
|
585
|
+
(0, import_type_graphql9.ObjectType)()
|
|
586
|
+
], BaseMessageStatus);
|
|
587
|
+
var PendingMessageStatus = class extends BaseMessageStatus {
|
|
588
|
+
code = "pending";
|
|
589
|
+
};
|
|
590
|
+
__name(PendingMessageStatus, "PendingMessageStatus");
|
|
591
|
+
PendingMessageStatus = _ts_decorate8([
|
|
592
|
+
(0, import_type_graphql9.ObjectType)()
|
|
593
|
+
], PendingMessageStatus);
|
|
594
|
+
var SuccessMessageStatus = class extends BaseMessageStatus {
|
|
595
|
+
code = "success";
|
|
596
|
+
};
|
|
597
|
+
__name(SuccessMessageStatus, "SuccessMessageStatus");
|
|
598
|
+
SuccessMessageStatus = _ts_decorate8([
|
|
599
|
+
(0, import_type_graphql9.ObjectType)()
|
|
600
|
+
], SuccessMessageStatus);
|
|
601
|
+
var FailedMessageStatus = class extends BaseMessageStatus {
|
|
602
|
+
code = "failed";
|
|
603
|
+
reason;
|
|
604
|
+
};
|
|
605
|
+
__name(FailedMessageStatus, "FailedMessageStatus");
|
|
606
|
+
_ts_decorate8([
|
|
607
|
+
(0, import_type_graphql9.Field)(() => String),
|
|
608
|
+
_ts_metadata8("design:type", String)
|
|
609
|
+
], FailedMessageStatus.prototype, "reason", void 0);
|
|
610
|
+
FailedMessageStatus = _ts_decorate8([
|
|
611
|
+
(0, import_type_graphql9.ObjectType)()
|
|
612
|
+
], FailedMessageStatus);
|
|
613
|
+
var MessageStatusUnion = (0, import_type_graphql9.createUnionType)({
|
|
614
|
+
name: "MessageStatus",
|
|
615
|
+
types: () => [
|
|
616
|
+
PendingMessageStatus,
|
|
617
|
+
SuccessMessageStatus,
|
|
618
|
+
FailedMessageStatus
|
|
619
|
+
]
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
// src/graphql/types/response-status.type.ts
|
|
623
|
+
var import_graphql_scalars = require("graphql-scalars");
|
|
624
|
+
var import_type_graphql10 = require("type-graphql");
|
|
625
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
626
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
627
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
628
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
629
|
+
else
|
|
630
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
631
|
+
if (d = decorators[i])
|
|
632
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
633
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
634
|
+
}
|
|
635
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
636
|
+
function _ts_metadata9(k, v) {
|
|
637
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
638
|
+
return Reflect.metadata(k, v);
|
|
639
|
+
}
|
|
640
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
641
|
+
var ResponseStatusCode;
|
|
642
|
+
(function(ResponseStatusCode2) {
|
|
643
|
+
ResponseStatusCode2["Pending"] = "pending";
|
|
644
|
+
ResponseStatusCode2["Success"] = "success";
|
|
645
|
+
ResponseStatusCode2["Failed"] = "failed";
|
|
646
|
+
})(ResponseStatusCode || (ResponseStatusCode = {}));
|
|
647
|
+
(0, import_type_graphql10.registerEnumType)(ResponseStatusCode, {
|
|
648
|
+
name: "ResponseStatusCode"
|
|
649
|
+
});
|
|
650
|
+
var BaseResponseStatus = /* @__PURE__ */ __name(class BaseResponseStatus2 {
|
|
651
|
+
code;
|
|
652
|
+
}, "BaseResponseStatus");
|
|
653
|
+
_ts_decorate9([
|
|
654
|
+
(0, import_type_graphql10.Field)(() => ResponseStatusCode),
|
|
655
|
+
_ts_metadata9("design:type", String)
|
|
656
|
+
], BaseResponseStatus.prototype, "code", void 0);
|
|
657
|
+
BaseResponseStatus = _ts_decorate9([
|
|
658
|
+
(0, import_type_graphql10.InterfaceType)({
|
|
659
|
+
resolveType(value) {
|
|
660
|
+
if (value.code === "success") {
|
|
661
|
+
return SuccessResponseStatus;
|
|
662
|
+
} else if (value.code === "failed") {
|
|
663
|
+
return FailedResponseStatus;
|
|
664
|
+
} else if (value.code === "pending") {
|
|
665
|
+
return PendingResponseStatus;
|
|
666
|
+
}
|
|
667
|
+
return void 0;
|
|
668
|
+
}
|
|
669
|
+
}),
|
|
670
|
+
(0, import_type_graphql10.ObjectType)()
|
|
671
|
+
], BaseResponseStatus);
|
|
672
|
+
var PendingResponseStatus = class extends BaseResponseStatus {
|
|
673
|
+
code = "pending";
|
|
674
|
+
};
|
|
675
|
+
__name(PendingResponseStatus, "PendingResponseStatus");
|
|
676
|
+
PendingResponseStatus = _ts_decorate9([
|
|
677
|
+
(0, import_type_graphql10.ObjectType)({
|
|
678
|
+
implements: BaseResponseStatus
|
|
679
|
+
})
|
|
680
|
+
], PendingResponseStatus);
|
|
681
|
+
var SuccessResponseStatus = class extends BaseResponseStatus {
|
|
682
|
+
code = "success";
|
|
683
|
+
};
|
|
684
|
+
__name(SuccessResponseStatus, "SuccessResponseStatus");
|
|
685
|
+
SuccessResponseStatus = _ts_decorate9([
|
|
686
|
+
(0, import_type_graphql10.ObjectType)({
|
|
687
|
+
implements: BaseResponseStatus
|
|
688
|
+
})
|
|
689
|
+
], SuccessResponseStatus);
|
|
690
|
+
var FailedResponseStatusReason;
|
|
691
|
+
(function(FailedResponseStatusReason2) {
|
|
692
|
+
FailedResponseStatusReason2["GUARDRAILS_VALIDATION_FAILED"] = "GUARDRAILS_VALIDATION_FAILED";
|
|
693
|
+
FailedResponseStatusReason2["MESSAGE_STREAM_INTERRUPTED"] = "MESSAGE_STREAM_INTERRUPTED";
|
|
694
|
+
FailedResponseStatusReason2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
695
|
+
})(FailedResponseStatusReason || (FailedResponseStatusReason = {}));
|
|
696
|
+
(0, import_type_graphql10.registerEnumType)(FailedResponseStatusReason, {
|
|
697
|
+
name: "FailedResponseStatusReason"
|
|
698
|
+
});
|
|
699
|
+
var FailedResponseStatus = class extends BaseResponseStatus {
|
|
700
|
+
code = "failed";
|
|
701
|
+
reason;
|
|
702
|
+
details = null;
|
|
703
|
+
};
|
|
704
|
+
__name(FailedResponseStatus, "FailedResponseStatus");
|
|
705
|
+
_ts_decorate9([
|
|
706
|
+
(0, import_type_graphql10.Field)(() => FailedResponseStatusReason),
|
|
707
|
+
_ts_metadata9("design:type", String)
|
|
708
|
+
], FailedResponseStatus.prototype, "reason", void 0);
|
|
709
|
+
_ts_decorate9([
|
|
710
|
+
(0, import_type_graphql10.Field)(() => import_graphql_scalars.GraphQLJSON, {
|
|
711
|
+
nullable: true
|
|
712
|
+
}),
|
|
713
|
+
_ts_metadata9("design:type", typeof Record === "undefined" ? Object : Record)
|
|
714
|
+
], FailedResponseStatus.prototype, "details", void 0);
|
|
715
|
+
FailedResponseStatus = _ts_decorate9([
|
|
716
|
+
(0, import_type_graphql10.ObjectType)({
|
|
717
|
+
implements: BaseResponseStatus
|
|
718
|
+
})
|
|
719
|
+
], FailedResponseStatus);
|
|
720
|
+
var ResponseStatusUnion = (0, import_type_graphql10.createUnionType)({
|
|
721
|
+
name: "ResponseStatus",
|
|
722
|
+
types: () => [
|
|
723
|
+
PendingResponseStatus,
|
|
724
|
+
SuccessResponseStatus,
|
|
725
|
+
FailedResponseStatus
|
|
726
|
+
]
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
// src/graphql/types/copilot-response.type.ts
|
|
730
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
731
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
732
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
733
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
734
|
+
else
|
|
735
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
736
|
+
if (d = decorators[i])
|
|
737
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
738
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
739
|
+
}
|
|
740
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
741
|
+
function _ts_metadata10(k, v) {
|
|
742
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
743
|
+
return Reflect.metadata(k, v);
|
|
744
|
+
}
|
|
745
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
746
|
+
var BaseMessageOutput = /* @__PURE__ */ __name(class BaseMessageOutput2 {
|
|
747
|
+
id;
|
|
748
|
+
createdAt;
|
|
749
|
+
status;
|
|
750
|
+
}, "BaseMessageOutput");
|
|
751
|
+
_ts_decorate10([
|
|
752
|
+
(0, import_type_graphql11.Field)(() => String),
|
|
753
|
+
_ts_metadata10("design:type", String)
|
|
754
|
+
], BaseMessageOutput.prototype, "id", void 0);
|
|
755
|
+
_ts_decorate10([
|
|
756
|
+
(0, import_type_graphql11.Field)(() => Date),
|
|
757
|
+
_ts_metadata10("design:type", typeof Date === "undefined" ? Object : Date)
|
|
758
|
+
], BaseMessageOutput.prototype, "createdAt", void 0);
|
|
759
|
+
_ts_decorate10([
|
|
760
|
+
(0, import_type_graphql11.Field)(() => MessageStatusUnion),
|
|
761
|
+
_ts_metadata10("design:type", Object)
|
|
762
|
+
], BaseMessageOutput.prototype, "status", void 0);
|
|
763
|
+
BaseMessageOutput = _ts_decorate10([
|
|
764
|
+
(0, import_type_graphql11.InterfaceType)({
|
|
765
|
+
resolveType(value) {
|
|
766
|
+
if (value.hasOwnProperty("content")) {
|
|
767
|
+
return TextMessageOutput;
|
|
768
|
+
} else if (value.hasOwnProperty("name")) {
|
|
769
|
+
return ActionExecutionMessageOutput;
|
|
770
|
+
} else if (value.hasOwnProperty("result")) {
|
|
771
|
+
return ResultMessageOutput;
|
|
772
|
+
}
|
|
773
|
+
return void 0;
|
|
774
|
+
}
|
|
775
|
+
})
|
|
776
|
+
], BaseMessageOutput);
|
|
777
|
+
var TextMessageOutput = class {
|
|
778
|
+
role;
|
|
779
|
+
content;
|
|
780
|
+
};
|
|
781
|
+
__name(TextMessageOutput, "TextMessageOutput");
|
|
782
|
+
_ts_decorate10([
|
|
783
|
+
(0, import_type_graphql11.Field)(() => MessageRole),
|
|
784
|
+
_ts_metadata10("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
|
|
785
|
+
], TextMessageOutput.prototype, "role", void 0);
|
|
786
|
+
_ts_decorate10([
|
|
787
|
+
(0, import_type_graphql11.Field)(() => [
|
|
788
|
+
String
|
|
789
|
+
]),
|
|
790
|
+
_ts_metadata10("design:type", Array)
|
|
791
|
+
], TextMessageOutput.prototype, "content", void 0);
|
|
792
|
+
TextMessageOutput = _ts_decorate10([
|
|
793
|
+
(0, import_type_graphql11.ObjectType)({
|
|
794
|
+
implements: BaseMessageOutput
|
|
795
|
+
})
|
|
796
|
+
], TextMessageOutput);
|
|
797
|
+
var ActionExecutionMessageOutput = class {
|
|
798
|
+
name;
|
|
799
|
+
scope;
|
|
800
|
+
arguments;
|
|
801
|
+
};
|
|
802
|
+
__name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
|
|
803
|
+
_ts_decorate10([
|
|
804
|
+
(0, import_type_graphql11.Field)(() => String),
|
|
805
|
+
_ts_metadata10("design:type", String)
|
|
806
|
+
], ActionExecutionMessageOutput.prototype, "name", void 0);
|
|
807
|
+
_ts_decorate10([
|
|
808
|
+
(0, import_type_graphql11.Field)(() => ActionExecutionScope),
|
|
809
|
+
_ts_metadata10("design:type", typeof ActionExecutionScope === "undefined" ? Object : ActionExecutionScope)
|
|
810
|
+
], ActionExecutionMessageOutput.prototype, "scope", void 0);
|
|
811
|
+
_ts_decorate10([
|
|
812
|
+
(0, import_type_graphql11.Field)(() => [
|
|
813
|
+
String
|
|
814
|
+
]),
|
|
815
|
+
_ts_metadata10("design:type", Array)
|
|
816
|
+
], ActionExecutionMessageOutput.prototype, "arguments", void 0);
|
|
817
|
+
ActionExecutionMessageOutput = _ts_decorate10([
|
|
818
|
+
(0, import_type_graphql11.ObjectType)({
|
|
819
|
+
implements: BaseMessageOutput
|
|
820
|
+
})
|
|
821
|
+
], ActionExecutionMessageOutput);
|
|
822
|
+
var ResultMessageOutput = class {
|
|
823
|
+
actionExecutionId;
|
|
824
|
+
actionName;
|
|
825
|
+
result;
|
|
826
|
+
};
|
|
827
|
+
__name(ResultMessageOutput, "ResultMessageOutput");
|
|
828
|
+
_ts_decorate10([
|
|
829
|
+
(0, import_type_graphql11.Field)(() => String),
|
|
830
|
+
_ts_metadata10("design:type", String)
|
|
831
|
+
], ResultMessageOutput.prototype, "actionExecutionId", void 0);
|
|
832
|
+
_ts_decorate10([
|
|
833
|
+
(0, import_type_graphql11.Field)(() => String),
|
|
834
|
+
_ts_metadata10("design:type", String)
|
|
835
|
+
], ResultMessageOutput.prototype, "actionName", void 0);
|
|
836
|
+
_ts_decorate10([
|
|
837
|
+
(0, import_type_graphql11.Field)(() => String),
|
|
838
|
+
_ts_metadata10("design:type", String)
|
|
839
|
+
], ResultMessageOutput.prototype, "result", void 0);
|
|
840
|
+
ResultMessageOutput = _ts_decorate10([
|
|
841
|
+
(0, import_type_graphql11.ObjectType)({
|
|
842
|
+
implements: BaseMessageOutput
|
|
843
|
+
})
|
|
844
|
+
], ResultMessageOutput);
|
|
845
|
+
var CopilotResponse = class {
|
|
846
|
+
threadId;
|
|
847
|
+
status;
|
|
848
|
+
runId;
|
|
849
|
+
messages;
|
|
850
|
+
};
|
|
851
|
+
__name(CopilotResponse, "CopilotResponse");
|
|
852
|
+
_ts_decorate10([
|
|
853
|
+
(0, import_type_graphql11.Field)(() => String),
|
|
854
|
+
_ts_metadata10("design:type", String)
|
|
855
|
+
], CopilotResponse.prototype, "threadId", void 0);
|
|
856
|
+
_ts_decorate10([
|
|
857
|
+
(0, import_type_graphql11.Field)(() => ResponseStatusUnion),
|
|
858
|
+
_ts_metadata10("design:type", Object)
|
|
859
|
+
], CopilotResponse.prototype, "status", void 0);
|
|
860
|
+
_ts_decorate10([
|
|
861
|
+
(0, import_type_graphql11.Field)({
|
|
862
|
+
nullable: true
|
|
863
|
+
}),
|
|
864
|
+
_ts_metadata10("design:type", String)
|
|
865
|
+
], CopilotResponse.prototype, "runId", void 0);
|
|
866
|
+
_ts_decorate10([
|
|
867
|
+
(0, import_type_graphql11.Field)(() => [
|
|
868
|
+
BaseMessageOutput
|
|
869
|
+
]),
|
|
870
|
+
_ts_metadata10("design:type", Array)
|
|
871
|
+
], CopilotResponse.prototype, "messages", void 0);
|
|
872
|
+
CopilotResponse = _ts_decorate10([
|
|
873
|
+
(0, import_type_graphql11.ObjectType)()
|
|
874
|
+
], CopilotResponse);
|
|
875
|
+
|
|
876
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
877
|
+
var import_graphql_yoga = require("graphql-yoga");
|
|
878
|
+
var import_nanoid = require("nanoid");
|
|
879
|
+
|
|
880
|
+
// src/service-adapters/events.ts
|
|
881
|
+
var import_rxjs = require("rxjs");
|
|
882
|
+
|
|
883
|
+
// src/graphql/types/converted/index.ts
|
|
884
|
+
var TextMessage = class extends BaseMessage {
|
|
885
|
+
content;
|
|
886
|
+
role;
|
|
887
|
+
};
|
|
888
|
+
__name(TextMessage, "TextMessage");
|
|
889
|
+
var ActionExecutionMessage = class extends BaseMessage {
|
|
890
|
+
name;
|
|
891
|
+
arguments;
|
|
892
|
+
scope;
|
|
893
|
+
};
|
|
894
|
+
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
895
|
+
var ResultMessage = class extends BaseMessage {
|
|
896
|
+
actionExecutionId;
|
|
897
|
+
actionName;
|
|
898
|
+
result;
|
|
899
|
+
};
|
|
900
|
+
__name(ResultMessage, "ResultMessage");
|
|
901
|
+
|
|
902
|
+
// src/service-adapters/events.ts
|
|
903
|
+
var RuntimeEventTypes;
|
|
904
|
+
(function(RuntimeEventTypes2) {
|
|
905
|
+
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
906
|
+
RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
|
|
907
|
+
RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
|
|
908
|
+
RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
|
|
909
|
+
RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
|
|
910
|
+
RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
|
|
911
|
+
RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
|
|
912
|
+
})(RuntimeEventTypes || (RuntimeEventTypes = {}));
|
|
913
|
+
|
|
914
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
915
|
+
var import_graphql_scalars2 = require("graphql-scalars");
|
|
916
|
+
var import_class_transformer = require("class-transformer");
|
|
917
|
+
var import_graphql = require("graphql");
|
|
918
|
+
|
|
919
|
+
// src/utils/failed-response-status-reasons.ts
|
|
920
|
+
var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
|
|
921
|
+
reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
|
|
922
|
+
constructor({ guardrailsReason }) {
|
|
923
|
+
super();
|
|
924
|
+
this.details = {
|
|
925
|
+
guardrailsReason
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
__name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
|
|
930
|
+
var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
|
|
931
|
+
reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
|
|
932
|
+
constructor({ messageId }) {
|
|
933
|
+
super();
|
|
934
|
+
this.details = {
|
|
935
|
+
messageId,
|
|
936
|
+
description: "Check the message for mode details"
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
__name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
|
|
941
|
+
var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
942
|
+
reason = FailedResponseStatusReason.UNKNOWN_ERROR;
|
|
943
|
+
constructor({ description }) {
|
|
944
|
+
super();
|
|
945
|
+
this.details = {
|
|
946
|
+
description
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
951
|
+
|
|
952
|
+
// src/lib/telemetry-client.ts
|
|
953
|
+
var import_shared = require("@copilotkit/shared");
|
|
954
|
+
var packageJson = require_package();
|
|
955
|
+
var telemetryClient = new import_shared.TelemetryClient({
|
|
956
|
+
packageName: packageJson.name,
|
|
957
|
+
packageVersion: packageJson.version
|
|
958
|
+
});
|
|
959
|
+
var telemetry_client_default = telemetryClient;
|
|
960
|
+
|
|
961
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
962
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
963
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
964
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
965
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
966
|
+
else
|
|
967
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
968
|
+
if (d = decorators[i])
|
|
969
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
970
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
971
|
+
}
|
|
972
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
973
|
+
function _ts_metadata11(k, v) {
|
|
974
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
975
|
+
return Reflect.metadata(k, v);
|
|
976
|
+
}
|
|
977
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
978
|
+
function _ts_param(paramIndex, decorator) {
|
|
979
|
+
return function(target, key) {
|
|
980
|
+
decorator(target, key, paramIndex);
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
__name(_ts_param, "_ts_param");
|
|
984
|
+
var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
|
|
985
|
+
var _a;
|
|
986
|
+
console.log("invokeGuardrails.baseUrl", baseUrl);
|
|
987
|
+
if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
|
|
988
|
+
const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
|
|
989
|
+
role: m.textMessage.role,
|
|
990
|
+
content: m.textMessage.content
|
|
991
|
+
}));
|
|
992
|
+
const lastMessage = messages[messages.length - 1];
|
|
993
|
+
const restOfMessages = messages.slice(0, -1);
|
|
994
|
+
const body = {
|
|
995
|
+
input: lastMessage.content,
|
|
996
|
+
validTopics: data.cloud.guardrails.inputValidationRules.allowList,
|
|
997
|
+
invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
|
|
998
|
+
messages: restOfMessages
|
|
999
|
+
};
|
|
1000
|
+
const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
|
|
1001
|
+
method: "POST",
|
|
1002
|
+
headers: {
|
|
1003
|
+
"Content-Type": "application/json",
|
|
1004
|
+
"X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
|
|
1005
|
+
},
|
|
1006
|
+
body: JSON.stringify(body)
|
|
1007
|
+
});
|
|
1008
|
+
if (guardrailsResult.ok) {
|
|
1009
|
+
const resultJson = await guardrailsResult.json();
|
|
1010
|
+
onResult(resultJson);
|
|
1011
|
+
} else {
|
|
1012
|
+
onError(await guardrailsResult.json());
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}, "invokeGuardrails");
|
|
1016
|
+
var CopilotResolver = class {
|
|
1017
|
+
async hello() {
|
|
1018
|
+
return "Hello World";
|
|
1019
|
+
}
|
|
1020
|
+
async generateCopilotResponse(ctx, data, properties) {
|
|
1021
|
+
var _a, _b, _c;
|
|
1022
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
1023
|
+
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
1024
|
+
requestType: data.metadata.requestType
|
|
1025
|
+
});
|
|
1026
|
+
let logger2 = ctx.logger.child({
|
|
1027
|
+
component: "CopilotResolver.generateCopilotResponse"
|
|
1028
|
+
});
|
|
1029
|
+
logger2.debug({
|
|
1030
|
+
data
|
|
1031
|
+
}, "Generating Copilot response");
|
|
1032
|
+
const copilotRuntime = ctx._copilotkit.runtime;
|
|
1033
|
+
const serviceAdapter = ctx._copilotkit.serviceAdapter;
|
|
1034
|
+
if (properties) {
|
|
1035
|
+
logger2.debug("Properties provided, merging with context properties");
|
|
1036
|
+
ctx.properties = {
|
|
1037
|
+
...ctx.properties,
|
|
1038
|
+
...properties
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
let copilotCloudPublicApiKey = null;
|
|
1042
|
+
let copilotCloudBaseUrl;
|
|
1043
|
+
if (data.cloud) {
|
|
1044
|
+
logger2 = logger2.child({
|
|
1045
|
+
cloud: true
|
|
1046
|
+
});
|
|
1047
|
+
logger2.debug("Cloud configuration provided, checking for public API key in headers");
|
|
1048
|
+
const key = ctx.request.headers.get("x-copilotcloud-public-api-key");
|
|
1049
|
+
if (key) {
|
|
1050
|
+
logger2.debug("Public API key found in headers");
|
|
1051
|
+
copilotCloudPublicApiKey = key;
|
|
1052
|
+
} else {
|
|
1053
|
+
logger2.error("Public API key not found in headers");
|
|
1054
|
+
throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
|
|
1055
|
+
}
|
|
1056
|
+
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
1057
|
+
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
1058
|
+
} else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
|
|
1059
|
+
copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
|
|
1060
|
+
} else {
|
|
1061
|
+
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
1062
|
+
}
|
|
1063
|
+
logger2 = logger2.child({
|
|
1064
|
+
copilotCloudBaseUrl
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
logger2.debug("Setting up subjects");
|
|
1068
|
+
const responseStatus$ = new import_rxjs2.ReplaySubject();
|
|
1069
|
+
const interruptStreaming$ = new import_rxjs2.ReplaySubject();
|
|
1070
|
+
const guardrailsResult$ = new import_rxjs2.ReplaySubject();
|
|
1071
|
+
let outputMessages = [];
|
|
1072
|
+
let resolveOutputMessagesPromise;
|
|
1073
|
+
let rejectOutputMessagesPromise;
|
|
1074
|
+
const outputMessagesPromise = new Promise((resolve, reject) => {
|
|
1075
|
+
resolveOutputMessagesPromise = resolve;
|
|
1076
|
+
rejectOutputMessagesPromise = reject;
|
|
1077
|
+
});
|
|
1078
|
+
logger2.debug("Processing");
|
|
1079
|
+
const { eventSource, threadId = (0, import_nanoid.nanoid)(), runId, actions } = await copilotRuntime.process({
|
|
1080
|
+
serviceAdapter,
|
|
1081
|
+
messages: data.messages,
|
|
1082
|
+
actions: data.frontend.actions,
|
|
1083
|
+
threadId: data.threadId,
|
|
1084
|
+
runId: data.runId,
|
|
1085
|
+
publicApiKey: void 0,
|
|
1086
|
+
properties: ctx.properties || {},
|
|
1087
|
+
outputMessagesPromise
|
|
1088
|
+
});
|
|
1089
|
+
logger2.debug("Event source created, creating response");
|
|
1090
|
+
const response = {
|
|
1091
|
+
threadId,
|
|
1092
|
+
runId,
|
|
1093
|
+
status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
|
|
1094
|
+
messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
1095
|
+
var _a2, _b2;
|
|
1096
|
+
logger2.debug("Messages repeater created");
|
|
1097
|
+
if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
|
|
1098
|
+
logger2 = logger2.child({
|
|
1099
|
+
guardrails: true
|
|
1100
|
+
});
|
|
1101
|
+
logger2.debug("Guardrails is enabled, validating input");
|
|
1102
|
+
invokeGuardrails({
|
|
1103
|
+
baseUrl: copilotCloudBaseUrl,
|
|
1104
|
+
copilotCloudPublicApiKey,
|
|
1105
|
+
data,
|
|
1106
|
+
onResult: (result) => {
|
|
1107
|
+
logger2.debug({
|
|
1108
|
+
status: result.status
|
|
1109
|
+
}, "Guardrails validation done");
|
|
1110
|
+
guardrailsResult$.next(result);
|
|
1111
|
+
if (result.status === "denied") {
|
|
1112
|
+
responseStatus$.next(new GuardrailsValidationFailureResponse({
|
|
1113
|
+
guardrailsReason: result.reason
|
|
1114
|
+
}));
|
|
1115
|
+
interruptStreaming$.next({
|
|
1116
|
+
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
1117
|
+
});
|
|
1118
|
+
outputMessages = [
|
|
1119
|
+
(0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
1120
|
+
id: (0, import_nanoid.nanoid)(),
|
|
1121
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1122
|
+
content: result.reason,
|
|
1123
|
+
role: MessageRole.assistant
|
|
1124
|
+
})
|
|
1125
|
+
];
|
|
1126
|
+
resolveOutputMessagesPromise(outputMessages);
|
|
1127
|
+
}
|
|
1128
|
+
},
|
|
1129
|
+
onError: (err) => {
|
|
1130
|
+
logger2.error({
|
|
1131
|
+
err
|
|
1132
|
+
}, "Error in guardrails validation");
|
|
1133
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
1134
|
+
description: `An unknown error has occurred in the guardrails validation`
|
|
1135
|
+
}));
|
|
1136
|
+
interruptStreaming$.next({
|
|
1137
|
+
reason: `Interrupted due to unknown error in guardrails validation`
|
|
1138
|
+
});
|
|
1139
|
+
rejectOutputMessagesPromise(err);
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
let eventStreamSubscription;
|
|
1144
|
+
const eventStream = eventSource.process({
|
|
1145
|
+
serversideActions: actions,
|
|
1146
|
+
guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null
|
|
1147
|
+
}).pipe(
|
|
1148
|
+
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
1149
|
+
// just the events that were emitted after the subscriber was added.
|
|
1150
|
+
(0, import_rxjs2.shareReplay)(),
|
|
1151
|
+
(0, import_rxjs2.finalize)(() => {
|
|
1152
|
+
logger2.debug("Event stream finalized");
|
|
1153
|
+
})
|
|
1154
|
+
);
|
|
1155
|
+
logger2.debug("Event stream created, subscribing to event stream");
|
|
1156
|
+
eventStreamSubscription = eventStream.subscribe({
|
|
1157
|
+
next: async (event) => {
|
|
1158
|
+
switch (event.type) {
|
|
1159
|
+
case RuntimeEventTypes.TextMessageStart:
|
|
1160
|
+
const textMessageContentStream = eventStream.pipe(
|
|
1161
|
+
// skip until this message start event
|
|
1162
|
+
(0, import_rxjs2.skipWhile)((e) => e !== event),
|
|
1163
|
+
// take until the message end event
|
|
1164
|
+
(0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.TextMessageEnd)
|
|
1165
|
+
);
|
|
1166
|
+
const streamingTextStatus = new import_rxjs2.Subject();
|
|
1167
|
+
const messageId = (0, import_nanoid.nanoid)();
|
|
1168
|
+
pushMessage({
|
|
1169
|
+
id: messageId,
|
|
1170
|
+
status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
|
|
1171
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1172
|
+
role: MessageRole.assistant,
|
|
1173
|
+
content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
|
|
1174
|
+
logger2.debug("Text message content repeater created");
|
|
1175
|
+
const textChunks = [];
|
|
1176
|
+
let textSubscription;
|
|
1177
|
+
interruptStreaming$.pipe((0, import_rxjs2.shareReplay)(), (0, import_rxjs2.take)(1), (0, import_rxjs2.tap)(({ reason, messageId: messageId2 }) => {
|
|
1178
|
+
logger2.debug({
|
|
1179
|
+
reason,
|
|
1180
|
+
messageId: messageId2
|
|
1181
|
+
}, "Text streaming interrupted");
|
|
1182
|
+
streamingTextStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
|
|
1183
|
+
reason
|
|
1184
|
+
}));
|
|
1185
|
+
responseStatus$.next(new MessageStreamInterruptedResponse({
|
|
1186
|
+
messageId: messageId2
|
|
1187
|
+
}));
|
|
1188
|
+
stopStreamingText();
|
|
1189
|
+
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
1190
|
+
})).subscribe();
|
|
1191
|
+
logger2.debug("Subscribing to text message content stream");
|
|
1192
|
+
textSubscription = textMessageContentStream.subscribe({
|
|
1193
|
+
next: async (e) => {
|
|
1194
|
+
if (e.type == RuntimeEventTypes.TextMessageContent) {
|
|
1195
|
+
await pushTextChunk(e.content);
|
|
1196
|
+
textChunks.push(e.content);
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
error: (err) => {
|
|
1200
|
+
logger2.error({
|
|
1201
|
+
err
|
|
1202
|
+
}, "Error in text message content stream");
|
|
1203
|
+
interruptStreaming$.next({
|
|
1204
|
+
reason: "Error streaming message content",
|
|
1205
|
+
messageId
|
|
1206
|
+
});
|
|
1207
|
+
stopStreamingText();
|
|
1208
|
+
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
1209
|
+
},
|
|
1210
|
+
complete: () => {
|
|
1211
|
+
logger2.debug("Text message content stream completed");
|
|
1212
|
+
streamingTextStatus.next(new SuccessMessageStatus());
|
|
1213
|
+
stopStreamingText();
|
|
1214
|
+
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
1215
|
+
outputMessages.push((0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
1216
|
+
id: messageId,
|
|
1217
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1218
|
+
content: textChunks.join(""),
|
|
1219
|
+
role: MessageRole.assistant
|
|
1220
|
+
}));
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
})
|
|
1224
|
+
});
|
|
1225
|
+
break;
|
|
1226
|
+
case RuntimeEventTypes.ActionExecutionStart:
|
|
1227
|
+
logger2.debug("Action execution start event received");
|
|
1228
|
+
const actionExecutionArgumentStream = eventStream.pipe((0, import_rxjs2.skipWhile)((e) => e !== event), (0, import_rxjs2.takeWhile)((e) => e.type != RuntimeEventTypes.ActionExecutionEnd));
|
|
1229
|
+
const streamingArgumentsStatus = new import_rxjs2.Subject();
|
|
1230
|
+
pushMessage({
|
|
1231
|
+
id: event.actionExecutionId,
|
|
1232
|
+
status: (0, import_rxjs2.firstValueFrom)(streamingArgumentsStatus),
|
|
1233
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1234
|
+
name: event.actionName,
|
|
1235
|
+
scope: event.scope,
|
|
1236
|
+
arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
1237
|
+
logger2.debug("Action execution argument stream created");
|
|
1238
|
+
const argumentChunks = [];
|
|
1239
|
+
let actionExecutionArgumentSubscription;
|
|
1240
|
+
actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
|
|
1241
|
+
next: async (e) => {
|
|
1242
|
+
if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
|
|
1243
|
+
await pushArgumentsChunk(e.args);
|
|
1244
|
+
argumentChunks.push(e.args);
|
|
1245
|
+
}
|
|
1246
|
+
},
|
|
1247
|
+
error: (err) => {
|
|
1248
|
+
logger2.error({
|
|
1249
|
+
err
|
|
1250
|
+
}, "Error in action execution argument stream");
|
|
1251
|
+
streamingArgumentsStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
|
|
1252
|
+
reason: "An unknown error has occurred in the action execution argument stream"
|
|
1253
|
+
}));
|
|
1254
|
+
stopStreamingArguments();
|
|
1255
|
+
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
1256
|
+
},
|
|
1257
|
+
complete: () => {
|
|
1258
|
+
logger2.debug("Action execution argument stream completed");
|
|
1259
|
+
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
1260
|
+
stopStreamingArguments();
|
|
1261
|
+
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
1262
|
+
outputMessages.push((0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
|
|
1263
|
+
id: event.actionExecutionId,
|
|
1264
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1265
|
+
name: event.actionName,
|
|
1266
|
+
scope: event.scope,
|
|
1267
|
+
arguments: argumentChunks.join("")
|
|
1268
|
+
}));
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
})
|
|
1272
|
+
});
|
|
1273
|
+
break;
|
|
1274
|
+
case RuntimeEventTypes.ActionExecutionResult:
|
|
1275
|
+
logger2.debug({
|
|
1276
|
+
result: event.result
|
|
1277
|
+
}, "Action execution result event received");
|
|
1278
|
+
pushMessage({
|
|
1279
|
+
id: (0, import_nanoid.nanoid)(),
|
|
1280
|
+
status: new SuccessMessageStatus(),
|
|
1281
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1282
|
+
actionExecutionId: event.actionExecutionId,
|
|
1283
|
+
actionName: event.actionName,
|
|
1284
|
+
result: event.result
|
|
1285
|
+
});
|
|
1286
|
+
outputMessages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
|
|
1287
|
+
id: (0, import_nanoid.nanoid)(),
|
|
1288
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1289
|
+
actionExecutionId: event.actionExecutionId,
|
|
1290
|
+
actionName: event.actionName,
|
|
1291
|
+
result: event.result
|
|
1292
|
+
}));
|
|
1293
|
+
break;
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
error: (err) => {
|
|
1297
|
+
logger2.error({
|
|
1298
|
+
err
|
|
1299
|
+
}, "Error in event stream");
|
|
1300
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
1301
|
+
description: `An unknown error has occurred in the event stream`
|
|
1302
|
+
}));
|
|
1303
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
1304
|
+
stopStreamingMessages();
|
|
1305
|
+
rejectOutputMessagesPromise(err);
|
|
1306
|
+
},
|
|
1307
|
+
complete: async () => {
|
|
1308
|
+
var _a3;
|
|
1309
|
+
logger2.debug("Event stream completed");
|
|
1310
|
+
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
1311
|
+
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
1312
|
+
await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
|
|
1313
|
+
}
|
|
1314
|
+
responseStatus$.next(new SuccessResponseStatus());
|
|
1315
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
1316
|
+
stopStreamingMessages();
|
|
1317
|
+
resolveOutputMessagesPromise(outputMessages);
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
})
|
|
1321
|
+
};
|
|
1322
|
+
return response;
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
__name(CopilotResolver, "CopilotResolver");
|
|
1326
|
+
_ts_decorate11([
|
|
1327
|
+
(0, import_type_graphql12.Query)(() => String),
|
|
1328
|
+
_ts_metadata11("design:type", Function),
|
|
1329
|
+
_ts_metadata11("design:paramtypes", []),
|
|
1330
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1331
|
+
], CopilotResolver.prototype, "hello", null);
|
|
1332
|
+
_ts_decorate11([
|
|
1333
|
+
(0, import_type_graphql12.Mutation)(() => CopilotResponse),
|
|
1334
|
+
_ts_param(0, (0, import_type_graphql12.Ctx)()),
|
|
1335
|
+
_ts_param(1, (0, import_type_graphql12.Arg)("data")),
|
|
1336
|
+
_ts_param(2, (0, import_type_graphql12.Arg)("properties", () => import_graphql_scalars2.GraphQLJSONObject, {
|
|
1337
|
+
nullable: true
|
|
1338
|
+
})),
|
|
1339
|
+
_ts_metadata11("design:type", Function),
|
|
1340
|
+
_ts_metadata11("design:paramtypes", [
|
|
1341
|
+
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
1342
|
+
typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
|
|
1343
|
+
typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
|
|
1344
|
+
]),
|
|
1345
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1346
|
+
], CopilotResolver.prototype, "generateCopilotResponse", null);
|
|
1347
|
+
CopilotResolver = _ts_decorate11([
|
|
1348
|
+
(0, import_type_graphql12.Resolver)(() => CopilotResponse)
|
|
1349
|
+
], CopilotResolver);
|
|
1350
|
+
|
|
1351
|
+
// src/lib/integrations/shared.ts
|
|
1352
|
+
var import_plugin_defer_stream = require("@graphql-yoga/plugin-defer-stream");
|
|
1353
|
+
|
|
1354
|
+
// src/lib/logger.ts
|
|
1355
|
+
var import_pino = __toESM(require("pino"));
|
|
1356
|
+
var import_pino_pretty = __toESM(require("pino-pretty"));
|
|
1357
|
+
function createLogger(options) {
|
|
1358
|
+
const { level, component } = options || {};
|
|
1359
|
+
const stream = (0, import_pino_pretty.default)({
|
|
1360
|
+
colorize: true
|
|
1361
|
+
});
|
|
1362
|
+
const logger2 = (0, import_pino.default)({
|
|
1363
|
+
level: process.env.LOG_LEVEL || level || "error",
|
|
1364
|
+
redact: {
|
|
1365
|
+
paths: [
|
|
1366
|
+
"pid",
|
|
1367
|
+
"hostname"
|
|
1368
|
+
],
|
|
1369
|
+
remove: true
|
|
1370
|
+
}
|
|
1371
|
+
}, stream);
|
|
1372
|
+
if (component) {
|
|
1373
|
+
return logger2.child({
|
|
1374
|
+
component
|
|
1375
|
+
});
|
|
1376
|
+
} else {
|
|
1377
|
+
return logger2;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
__name(createLogger, "createLogger");
|
|
1381
|
+
|
|
1382
|
+
// src/lib/integrations/shared.ts
|
|
1383
|
+
var logger = createLogger();
|
|
1384
|
+
async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
|
|
1385
|
+
logger.debug({
|
|
1386
|
+
copilotKitContext
|
|
1387
|
+
}, "Creating GraphQL context");
|
|
1388
|
+
const ctx = {
|
|
1389
|
+
...initialContext,
|
|
1390
|
+
_copilotkit: {
|
|
1391
|
+
...copilotKitContext
|
|
1392
|
+
},
|
|
1393
|
+
properties: {
|
|
1394
|
+
...properties
|
|
1395
|
+
},
|
|
1396
|
+
logger: contextLogger
|
|
1397
|
+
};
|
|
1398
|
+
return ctx;
|
|
1399
|
+
}
|
|
1400
|
+
__name(createContext, "createContext");
|
|
1401
|
+
function buildSchema(options = {}) {
|
|
1402
|
+
logger.debug("Building GraphQL schema...");
|
|
1403
|
+
const schema = (0, import_type_graphql13.buildSchemaSync)({
|
|
1404
|
+
resolvers: [
|
|
1405
|
+
CopilotResolver
|
|
1406
|
+
],
|
|
1407
|
+
emitSchemaFile: options.emitSchemaFile
|
|
1408
|
+
});
|
|
1409
|
+
logger.debug("GraphQL schema built successfully");
|
|
1410
|
+
return schema;
|
|
1411
|
+
}
|
|
1412
|
+
__name(buildSchema, "buildSchema");
|
|
1413
|
+
function getCommonConfig(options) {
|
|
1414
|
+
const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
|
|
1415
|
+
const logger2 = createLogger({
|
|
1416
|
+
level: logLevel,
|
|
1417
|
+
component: "getCommonConfig"
|
|
1418
|
+
});
|
|
1419
|
+
const contextLogger = createLogger({
|
|
1420
|
+
level: logLevel
|
|
1421
|
+
});
|
|
1422
|
+
if (options.cloud) {
|
|
1423
|
+
telemetry_client_default.setCloudConfiguration({
|
|
1424
|
+
publicApiKey: options.cloud.publicApiKey,
|
|
1425
|
+
baseUrl: options.cloud.baseUrl
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
telemetry_client_default.setGlobalProperties({
|
|
1429
|
+
runtime: {
|
|
1430
|
+
serviceAdapter: options.serviceAdapter.constructor.name
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
return {
|
|
1434
|
+
logging: createLogger({
|
|
1435
|
+
component: "Yoga GraphQL",
|
|
1436
|
+
level: logLevel
|
|
1437
|
+
}),
|
|
1438
|
+
schema: buildSchema(),
|
|
1439
|
+
plugins: [
|
|
1440
|
+
(0, import_plugin_defer_stream.useDeferStream)()
|
|
1441
|
+
],
|
|
1442
|
+
context: (ctx) => createContext(ctx, options, contextLogger, options.properties)
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
__name(getCommonConfig, "getCommonConfig");
|
|
1446
|
+
|
|
1447
|
+
// src/lib/integrations/node-http/index.ts
|
|
1448
|
+
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
1449
|
+
const commonConfig = getCommonConfig(options);
|
|
1450
|
+
telemetry_client_default.setGlobalProperties({
|
|
1451
|
+
runtime: {
|
|
1452
|
+
framework: "node-http"
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1456
|
+
const logger2 = commonConfig.logging;
|
|
1457
|
+
logger2.debug("Creating Node HTTP endpoint");
|
|
1458
|
+
const yoga = (0, import_graphql_yoga2.createYoga)({
|
|
1459
|
+
...commonConfig,
|
|
1460
|
+
graphqlEndpoint: options.endpoint
|
|
1461
|
+
});
|
|
1462
|
+
return yoga;
|
|
1463
|
+
}
|
|
1464
|
+
__name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
|
|
1465
|
+
|
|
1466
|
+
// src/lib/integrations/nest/index.ts
|
|
1467
|
+
function copilotRuntimeNestEndpoint(options) {
|
|
1468
|
+
telemetry_client_default.setGlobalProperties({
|
|
1469
|
+
runtime: {
|
|
1470
|
+
framework: "nest"
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1474
|
+
return copilotRuntimeNodeHttpEndpoint(options);
|
|
1475
|
+
}
|
|
1476
|
+
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
1477
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1478
|
+
0 && (module.exports = {
|
|
1479
|
+
copilotRuntimeNestEndpoint
|
|
1480
|
+
});
|
|
1481
|
+
//# sourceMappingURL=index.js.map
|