digipair 0.92.1 → 0.93.0-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.
- package/bin/digipair.js +0 -0
- package/main.js +461 -0
- package/main.js.map +1 -0
- package/package.json +54 -45
- package/src/app/app.controller.js +0 -88
- package/src/app/app.controller.js.map +0 -1
- package/src/app/app.module.js +0 -18
- package/src/app/app.module.js.map +0 -1
- package/src/app/app.service.js +0 -160
- package/src/app/app.service.js.map +0 -1
- package/src/assets/digipairs/studio/action-answer.json +0 -120
- package/src/assets/digipairs/studio/action-openapi2schema.json +0 -193
- package/src/assets/digipairs/studio/avatar.png +0 -0
- package/src/assets/digipairs/studio/boost-duplicate.json +0 -87
- package/src/assets/digipairs/studio/boost-pair-add.json +0 -84
- package/src/assets/digipairs/studio/boost-plan.json +0 -76
- package/src/assets/digipairs/studio/boost-tool-add-library.json +0 -125
- package/src/assets/digipairs/studio/boost-tool-add-openapi.json +0 -178
- package/src/assets/digipairs/studio/boost-tool-add.json +0 -84
- package/src/assets/digipairs/studio/boost-tool-task-add.json +0 -90
- package/src/assets/digipairs/studio/boost-worker-add.json +0 -86
- package/src/assets/digipairs/studio/boost-worker-task-add.json +0 -90
- package/src/assets/digipairs/studio/config.json +0 -1
- package/src/assets/digipairs/studio/consumptions-monthly.json +0 -327
- package/src/assets/digipairs/studio/consumptions.json +0 -329
- package/src/assets/digipairs/studio/conversation.json +0 -84
- package/src/assets/digipairs/studio/logs.json +0 -306
- package/src/assets/digipairs/studio/pair-add.json +0 -253
- package/src/assets/digipairs/studio/pair-edit.json +0 -528
- package/src/assets/digipairs/studio/pair-tasks.json +0 -657
- package/src/assets/digipairs/studio/pair-worker-add.json +0 -303
- package/src/assets/digipairs/studio/pairs.json +0 -356
- package/src/assets/digipairs/studio/process-list.json +0 -267
- package/src/assets/digipairs/studio/service-base64.csv.json +0 -1
- package/src/assets/digipairs/studio/service-base64.json +0 -1
- package/src/assets/digipairs/studio/test.json +0 -1
- package/src/assets/digipairs/studio/tool-add.json +0 -1
- package/src/assets/digipairs/studio/tool-edit.json +0 -547
- package/src/assets/digipairs/studio/tool-task-add.json +0 -348
- package/src/assets/digipairs/studio/tool-task-edit.json +0 -378
- package/src/assets/digipairs/studio/tool-task-editor.json +0 -381
- package/src/assets/digipairs/studio/tool-task-json.json +0 -287
- package/src/assets/digipairs/studio/tool-tasks.json +0 -885
- package/src/assets/digipairs/studio/tool-tool-add.json +0 -321
- package/src/assets/digipairs/studio/tools.json +0 -1
- package/src/assets/digipairs/studio/worker-add.json +0 -214
- package/src/assets/digipairs/studio/worker-edit.json +0 -565
- package/src/assets/digipairs/studio/worker-task-add.json +0 -344
- package/src/assets/digipairs/studio/worker-task-edit.json +0 -377
- package/src/assets/digipairs/studio/worker-task-editor.json +0 -382
- package/src/assets/digipairs/studio/worker-task-flow.json +0 -654
- package/src/assets/digipairs/studio/worker-task-json.json +0 -284
- package/src/assets/digipairs/studio/worker-tasks.json +0 -882
- package/src/assets/digipairs/studio/worker-tool-add.json +0 -325
- package/src/assets/digipairs/studio/workers.json +0 -505
- package/src/assets/public/api.svg +0 -1
- package/src/assets/public/libraries/@digipair/skill-agent/action.svg +0 -1
- package/src/assets/public/libraries/@digipair/skill-agent/task.svg +0 -1
- package/src/assets/public/libraries/@digipair/skill-agent/trigger.svg +0 -1
- package/src/assets/public/tool.svg +0 -1
- package/src/main.js +0 -65
- package/src/main.js.map +0 -1
- /package/{src/assets → assets}/default.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/avatar.png +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-digipair-api.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-digipair-business-process.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-digipair-expert.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-digipair-imap-listener-oauth2.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-digipair-imap-listener.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-digipair-teams.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-add-reasoning.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-duplicate-reasoning.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/boost-plan-reasoning.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/compute-consumption-daily.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/config.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/consumptions-monthly.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/consumptions.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/digipair-list.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/json-editor.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/logs.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/openapi2schema.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/process-list.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/reasoning-editor.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/reasoning-list.json +0 -0
- /package/{src/assets → assets}/digipairs/admin/schema.json +0 -0
- /package/{src/assets → assets}/digipairs/common/answer.json +0 -0
- /package/{src/assets → assets}/digipairs/common/avatar.png +0 -0
- /package/{src/assets → assets}/digipairs/common/boosts.json +0 -0
- /package/{src/assets → assets}/digipairs/common/chat.json +0 -0
- /package/{src/assets → assets}/digipairs/common/config.json +0 -0
- /package/{src/assets → assets}/digipairs/common/conversation.json +0 -0
- /package/{src/assets → assets}/digipairs/common/history.json +0 -0
- /package/{src/assets → assets}/digipairs/common/metadata.json +0 -0
- /package/{src/assets → assets}/digipairs/common/notification.json +0 -0
- /package/{src/assets → assets}/digipairs/common/schema.json +0 -0
- /package/{src/assets → assets}/digipairs/common/schema.json.json +0 -0
- /package/{src/assets → assets}/digipairs/planning.jsonl +0 -0
- /package/{src/assets → assets}/domains.json +0 -0
- /package/{src/assets → assets}/public/push-notification.worker.js +0 -0
- /package/{src/assets → assets}/templates/business-process/avatar.png +0 -0
- /package/{src/assets → assets}/templates/business-process/config.json +0 -0
- /package/{src/assets → assets}/templates/business-process/schema.json +0 -0
- /package/{src/assets → assets}/templates/expert/avatar.png +0 -0
- /package/{src/assets → assets}/templates/expert/config.json +0 -0
- /package/{src/assets → assets}/templates/expert/conversation.json +0 -0
- /package/{src/assets → assets}/templates/expert/schema.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener/action-message.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener/avatar.png +0 -0
- /package/{src/assets → assets}/templates/imap-listener/config.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener/conversation.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener/imap.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener/schema.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener-oauth2/action-message.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener-oauth2/avatar.png +0 -0
- /package/{src/assets → assets}/templates/imap-listener-oauth2/config.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener-oauth2/conversation.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener-oauth2/imap.json +0 -0
- /package/{src/assets → assets}/templates/imap-listener-oauth2/schema.json +0 -0
- /package/{src/assets → assets}/templates/msteams-incoming-webhook/avatar.png +0 -0
- /package/{src/assets → assets}/templates/msteams-incoming-webhook/config.json +0 -0
- /package/{src/assets → assets}/templates/msteams-incoming-webhook/conversation.json +0 -0
- /package/{src/assets → assets}/templates/msteams-incoming-webhook/messagecard.json +0 -0
- /package/{src/assets → assets}/templates/msteams-incoming-webhook/schema.json +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/avatar.png +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/config.json +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/conversation.json +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/fallback.json +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/openapi.json +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/request.json +0 -0
- /package/{src/assets → assets}/templates/openapi-apikey/schema.json +0 -0
package/bin/digipair.js
CHANGED
|
File without changes
|
package/main.js
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ var __webpack_modules__ = ([
|
|
3
|
+
/* 0 */,
|
|
4
|
+
/* 1 */
|
|
5
|
+
/***/ ((module) => {
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
module.exports = require("tslib");
|
|
9
|
+
|
|
10
|
+
/***/ }),
|
|
11
|
+
/* 2 */
|
|
12
|
+
/***/ ((module) => {
|
|
13
|
+
|
|
14
|
+
"use strict";
|
|
15
|
+
module.exports = require("@nestjs/common");
|
|
16
|
+
|
|
17
|
+
/***/ }),
|
|
18
|
+
/* 3 */
|
|
19
|
+
/***/ ((module) => {
|
|
20
|
+
|
|
21
|
+
"use strict";
|
|
22
|
+
module.exports = require("@nestjs/core");
|
|
23
|
+
|
|
24
|
+
/***/ }),
|
|
25
|
+
/* 4 */
|
|
26
|
+
/***/ ((module) => {
|
|
27
|
+
|
|
28
|
+
"use strict";
|
|
29
|
+
module.exports = require("body-parser");
|
|
30
|
+
|
|
31
|
+
/***/ }),
|
|
32
|
+
/* 5 */
|
|
33
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
34
|
+
|
|
35
|
+
"use strict";
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
38
|
+
exports.AppModule = void 0;
|
|
39
|
+
const tslib_1 = __webpack_require__(1);
|
|
40
|
+
const common_1 = __webpack_require__(2);
|
|
41
|
+
const app_controller_1 = __webpack_require__(6);
|
|
42
|
+
const app_service_1 = __webpack_require__(8);
|
|
43
|
+
let AppModule = class AppModule {
|
|
44
|
+
};
|
|
45
|
+
exports.AppModule = AppModule;
|
|
46
|
+
exports.AppModule = AppModule = tslib_1.__decorate([
|
|
47
|
+
(0, common_1.Module)({
|
|
48
|
+
imports: [],
|
|
49
|
+
controllers: [app_controller_1.AppController],
|
|
50
|
+
providers: [app_service_1.AppService],
|
|
51
|
+
})
|
|
52
|
+
], AppModule);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/***/ }),
|
|
56
|
+
/* 6 */
|
|
57
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
58
|
+
|
|
59
|
+
"use strict";
|
|
60
|
+
|
|
61
|
+
var _a;
|
|
62
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
63
|
+
exports.AppController = void 0;
|
|
64
|
+
const tslib_1 = __webpack_require__(1);
|
|
65
|
+
const common_1 = __webpack_require__(2);
|
|
66
|
+
const fs_1 = __webpack_require__(7);
|
|
67
|
+
const app_service_1 = __webpack_require__(8);
|
|
68
|
+
const requireDynamic = (module) => __webpack_require__(10)(module);
|
|
69
|
+
let AppController = class AppController {
|
|
70
|
+
constructor(appService) {
|
|
71
|
+
this.appService = appService;
|
|
72
|
+
}
|
|
73
|
+
async public(res, req) {
|
|
74
|
+
const filePath = `${__dirname}/assets/public${req.url.replace('/public', '')}`;
|
|
75
|
+
res.sendFile(filePath, err => {
|
|
76
|
+
if (err) {
|
|
77
|
+
res.status(404).send('File not found');
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async domain(res, request, body, query) {
|
|
82
|
+
const assets = process.env.DIGIPAIR_FACTORY_PATH || './factory';
|
|
83
|
+
const host = request.headers.host?.split(':')[0];
|
|
84
|
+
const path = request.params['0'];
|
|
85
|
+
let params, digipair, reasoning;
|
|
86
|
+
const domains = JSON.parse(await fs_1.promises.readFile(`${assets}/domains.json`, 'utf8'));
|
|
87
|
+
if (path === 'favicon.ico') {
|
|
88
|
+
return res.send(null);
|
|
89
|
+
}
|
|
90
|
+
params = path.split('/');
|
|
91
|
+
if (domains[host]) {
|
|
92
|
+
digipair = domains[host].digipair;
|
|
93
|
+
reasoning = params[0];
|
|
94
|
+
params = params.slice(1);
|
|
95
|
+
if (!reasoning) {
|
|
96
|
+
res.redirect(`/${domains[host].reasoning}`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (params.length < 2) {
|
|
101
|
+
res.redirect(`/admin/digipair-list`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
digipair = params[0];
|
|
106
|
+
reasoning = params[1];
|
|
107
|
+
params = params.slice(2);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const skillProcess = requireDynamic('@digipair/skill-process');
|
|
111
|
+
const { id, signal } = skillProcess.add(digipair, reasoning, null);
|
|
112
|
+
const method = request.method;
|
|
113
|
+
res.on('close', () => {
|
|
114
|
+
skillProcess.remove(id);
|
|
115
|
+
});
|
|
116
|
+
const result = await this.appService.agent(`${assets}/digipairs`, digipair, reasoning, body, params, query, method, request.headers, {}, request, res, signal);
|
|
117
|
+
res.send(result);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (error.type !== 'DIGIPAIR_KEEPALIVE') {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.AppController = AppController;
|
|
127
|
+
tslib_1.__decorate([
|
|
128
|
+
(0, common_1.Get)('/public/*'),
|
|
129
|
+
tslib_1.__param(0, (0, common_1.Res)()),
|
|
130
|
+
tslib_1.__param(1, (0, common_1.Req)()),
|
|
131
|
+
tslib_1.__metadata("design:type", Function),
|
|
132
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
133
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
134
|
+
], AppController.prototype, "public", null);
|
|
135
|
+
tslib_1.__decorate([
|
|
136
|
+
(0, common_1.All)('*'),
|
|
137
|
+
tslib_1.__param(0, (0, common_1.Res)()),
|
|
138
|
+
tslib_1.__param(1, (0, common_1.Req)()),
|
|
139
|
+
tslib_1.__param(2, (0, common_1.Body)()),
|
|
140
|
+
tslib_1.__param(3, (0, common_1.Query)()),
|
|
141
|
+
tslib_1.__metadata("design:type", Function),
|
|
142
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object]),
|
|
143
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
144
|
+
], AppController.prototype, "domain", null);
|
|
145
|
+
exports.AppController = AppController = tslib_1.__decorate([
|
|
146
|
+
(0, common_1.Controller)(),
|
|
147
|
+
tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof app_service_1.AppService !== "undefined" && app_service_1.AppService) === "function" ? _a : Object])
|
|
148
|
+
], AppController);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/***/ }),
|
|
152
|
+
/* 7 */
|
|
153
|
+
/***/ ((module) => {
|
|
154
|
+
|
|
155
|
+
"use strict";
|
|
156
|
+
module.exports = require("fs");
|
|
157
|
+
|
|
158
|
+
/***/ }),
|
|
159
|
+
/* 8 */
|
|
160
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
161
|
+
|
|
162
|
+
"use strict";
|
|
163
|
+
|
|
164
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165
|
+
exports.AppService = void 0;
|
|
166
|
+
const tslib_1 = __webpack_require__(1);
|
|
167
|
+
const engine_1 = __webpack_require__(9);
|
|
168
|
+
const common_1 = __webpack_require__(2);
|
|
169
|
+
const fs_1 = __webpack_require__(7);
|
|
170
|
+
const requireDynamic = (module) => __webpack_require__(10)(module);
|
|
171
|
+
engine_1.config.set('ALIAS', [
|
|
172
|
+
{
|
|
173
|
+
name: 'digipair',
|
|
174
|
+
library: '@digipair/skill-factory',
|
|
175
|
+
element: 'start',
|
|
176
|
+
properties: {
|
|
177
|
+
digipair: '{{settings.library}}',
|
|
178
|
+
reasoning: '{{settings.element}}',
|
|
179
|
+
version: '{{settings.version}}',
|
|
180
|
+
body: 'EVALUATE:settings.properties',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
engine_1.config.set('LOGGER', (level, path, message, context, data) => {
|
|
185
|
+
const time = new Date().toISOString();
|
|
186
|
+
switch (level) {
|
|
187
|
+
case 'INFO':
|
|
188
|
+
console.log(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`);
|
|
189
|
+
break;
|
|
190
|
+
case 'ERROR':
|
|
191
|
+
console.error(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`, data);
|
|
192
|
+
break;
|
|
193
|
+
case 'DEBUG':
|
|
194
|
+
console.debug(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`, data);
|
|
195
|
+
break;
|
|
196
|
+
default:
|
|
197
|
+
console.log(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
let AppService = class AppService {
|
|
202
|
+
async onModuleInit() {
|
|
203
|
+
const path = process.env.DIGIPAIR_FACTORY_PATH
|
|
204
|
+
? `${process.env.DIGIPAIR_FACTORY_PATH}/digipairs`
|
|
205
|
+
: './factory/digipairs';
|
|
206
|
+
// initialize logs management
|
|
207
|
+
const skillLogger = requireDynamic('@digipair/skill-logger');
|
|
208
|
+
await skillLogger.initialize();
|
|
209
|
+
// initialize factory skill
|
|
210
|
+
const skillFactory = requireDynamic('@digipair/skill-factory');
|
|
211
|
+
skillFactory.initialize((context, digipair, reasoning, body) => this.agent(path, digipair, reasoning, body, [], {}, null, {}, context, null, null, context.protected.signal));
|
|
212
|
+
// start cron manager
|
|
213
|
+
try {
|
|
214
|
+
const skillCron = requireDynamic('@digipair/skill-cron');
|
|
215
|
+
skillCron.initialize(async (path, digipair, reasoning) => {
|
|
216
|
+
const skillProcess = requireDynamic('@digipair/skill-process');
|
|
217
|
+
const { id, signal } = skillProcess.add(digipair, reasoning, null);
|
|
218
|
+
try {
|
|
219
|
+
await this.agent(path, digipair, reasoning, {}, [], {}, null, {}, {}, null, null, signal);
|
|
220
|
+
skillProcess.remove(id);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error.type !== 'DIGIPAIR_KEEPALIVE') {
|
|
224
|
+
console.error(error);
|
|
225
|
+
skillProcess.remove(id);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
skillCron.start(path);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
console.error(error);
|
|
233
|
+
}
|
|
234
|
+
// start workflow manager
|
|
235
|
+
try {
|
|
236
|
+
const skillTemporal = requireDynamic('@digipair/skill-temporal');
|
|
237
|
+
if (process.env.TEMPORAL_CLUSTER_HOST) {
|
|
238
|
+
skillTemporal.initialize();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
console.error(error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async agent(path, digipair, reasoning, body, params, query, method, headers, requester, req, res, signal) {
|
|
246
|
+
const assets = process.env.DIGIPAIR_FACTORY_PATH || './factory';
|
|
247
|
+
let context;
|
|
248
|
+
try {
|
|
249
|
+
let content;
|
|
250
|
+
content = await fs_1.promises.readFile(`${assets}/default.json`, 'utf8');
|
|
251
|
+
const defaultConfig = JSON.parse(content);
|
|
252
|
+
content = await fs_1.promises.readFile(`${path}/common/config.json`, 'utf8');
|
|
253
|
+
const commonConfig = JSON.parse(content);
|
|
254
|
+
content = await fs_1.promises.readFile(`${path}/${digipair}/config.json`, 'utf8');
|
|
255
|
+
const config = JSON.parse(content);
|
|
256
|
+
context = {
|
|
257
|
+
config: {
|
|
258
|
+
VERSIONS: { ...defaultConfig.libraries, ...commonConfig.libraries, ...config.libraries },
|
|
259
|
+
WEB_VERSIONS: {
|
|
260
|
+
...defaultConfig.webLibraries,
|
|
261
|
+
...commonConfig.webLibraries,
|
|
262
|
+
...config.webLibraries,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
privates: { ...defaultConfig.privates, ...commonConfig.privates, ...config.privates },
|
|
266
|
+
variables: { ...defaultConfig.variables, ...commonConfig.variables, ...config.variables },
|
|
267
|
+
request: {
|
|
268
|
+
digipair,
|
|
269
|
+
reasoning,
|
|
270
|
+
method,
|
|
271
|
+
body,
|
|
272
|
+
params,
|
|
273
|
+
query,
|
|
274
|
+
headers,
|
|
275
|
+
},
|
|
276
|
+
protected: {
|
|
277
|
+
req,
|
|
278
|
+
res,
|
|
279
|
+
signal,
|
|
280
|
+
},
|
|
281
|
+
requester,
|
|
282
|
+
};
|
|
283
|
+
if ((0, fs_1.existsSync)(`${path}/${digipair}/${reasoning}.json`)) {
|
|
284
|
+
content = await fs_1.promises.readFile(`${path}/${digipair}/${reasoning}.json`, 'utf8');
|
|
285
|
+
}
|
|
286
|
+
else if ((0, fs_1.existsSync)(`${path}/common/${reasoning}.json`) === true) {
|
|
287
|
+
content = await fs_1.promises.readFile(`${path}/common/${reasoning}.json`, 'utf8');
|
|
288
|
+
}
|
|
289
|
+
else if ((0, fs_1.existsSync)(`${path}/${digipair}/fallback.json`)) {
|
|
290
|
+
content = await fs_1.promises.readFile(`${path}/${digipair}/fallback.json`, 'utf8');
|
|
291
|
+
}
|
|
292
|
+
else if ((0, fs_1.existsSync)(`${path}/common/fallback.json`) === true) {
|
|
293
|
+
content = await fs_1.promises.readFile(`${path}/common/fallback.json`, 'utf8');
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
res.status(404);
|
|
297
|
+
return { status: 'not found' };
|
|
298
|
+
}
|
|
299
|
+
const settings = JSON.parse(content);
|
|
300
|
+
const result = await (0, engine_1.executePinsList)([settings], context, 'reasoning');
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
if (error.type === 'DIGIPAIR_KEEPALIVE') {
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
if (error.type === 'DIGIPAIR_STOP') {
|
|
308
|
+
return error.value;
|
|
309
|
+
}
|
|
310
|
+
console.error(error);
|
|
311
|
+
if (!context) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const skillLogger = requireDynamic('@digipair/skill-logger');
|
|
315
|
+
skillLogger.addLog(context, 'ERROR', error.message);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
exports.AppService = AppService;
|
|
320
|
+
exports.AppService = AppService = tslib_1.__decorate([
|
|
321
|
+
(0, common_1.Injectable)()
|
|
322
|
+
], AppService);
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
/***/ }),
|
|
326
|
+
/* 9 */
|
|
327
|
+
/***/ ((module) => {
|
|
328
|
+
|
|
329
|
+
"use strict";
|
|
330
|
+
module.exports = require("@digipair/engine");
|
|
331
|
+
|
|
332
|
+
/***/ }),
|
|
333
|
+
/* 10 */
|
|
334
|
+
/***/ ((module) => {
|
|
335
|
+
|
|
336
|
+
function webpackEmptyContext(req) {
|
|
337
|
+
var e = new Error("Cannot find module '" + req + "'");
|
|
338
|
+
e.code = 'MODULE_NOT_FOUND';
|
|
339
|
+
throw e;
|
|
340
|
+
}
|
|
341
|
+
webpackEmptyContext.keys = () => ([]);
|
|
342
|
+
webpackEmptyContext.resolve = webpackEmptyContext;
|
|
343
|
+
webpackEmptyContext.id = 10;
|
|
344
|
+
module.exports = webpackEmptyContext;
|
|
345
|
+
|
|
346
|
+
/***/ }),
|
|
347
|
+
/* 11 */
|
|
348
|
+
/***/ ((module) => {
|
|
349
|
+
|
|
350
|
+
"use strict";
|
|
351
|
+
module.exports = require("path");
|
|
352
|
+
|
|
353
|
+
/***/ })
|
|
354
|
+
/******/ ]);
|
|
355
|
+
/************************************************************************/
|
|
356
|
+
/******/ // The module cache
|
|
357
|
+
/******/ var __webpack_module_cache__ = {};
|
|
358
|
+
/******/
|
|
359
|
+
/******/ // The require function
|
|
360
|
+
/******/ function __webpack_require__(moduleId) {
|
|
361
|
+
/******/ // Check if module is in cache
|
|
362
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
363
|
+
/******/ if (cachedModule !== undefined) {
|
|
364
|
+
/******/ return cachedModule.exports;
|
|
365
|
+
/******/ }
|
|
366
|
+
/******/ // Create a new module (and put it into the cache)
|
|
367
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
368
|
+
/******/ // no module.id needed
|
|
369
|
+
/******/ // no module.loaded needed
|
|
370
|
+
/******/ exports: {}
|
|
371
|
+
/******/ };
|
|
372
|
+
/******/
|
|
373
|
+
/******/ // Execute the module function
|
|
374
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
375
|
+
/******/
|
|
376
|
+
/******/ // Return the exports of the module
|
|
377
|
+
/******/ return module.exports;
|
|
378
|
+
/******/ }
|
|
379
|
+
/******/
|
|
380
|
+
/************************************************************************/
|
|
381
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
382
|
+
/******/ (() => {
|
|
383
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
384
|
+
/******/ })();
|
|
385
|
+
/******/
|
|
386
|
+
/************************************************************************/
|
|
387
|
+
var __webpack_exports__ = {};
|
|
388
|
+
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
|
|
389
|
+
(() => {
|
|
390
|
+
"use strict";
|
|
391
|
+
var exports = __webpack_exports__;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* This is not a production server yet!
|
|
395
|
+
* This is only a minimal backend to get started.
|
|
396
|
+
*/
|
|
397
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
398
|
+
const tslib_1 = __webpack_require__(1);
|
|
399
|
+
const common_1 = __webpack_require__(2);
|
|
400
|
+
const core_1 = __webpack_require__(3);
|
|
401
|
+
const bodyParser = tslib_1.__importStar(__webpack_require__(4));
|
|
402
|
+
const app_module_1 = __webpack_require__(5);
|
|
403
|
+
const fs_1 = __webpack_require__(7);
|
|
404
|
+
const path_1 = tslib_1.__importDefault(__webpack_require__(11));
|
|
405
|
+
function copyDirectoryRecursive(source, target) {
|
|
406
|
+
if (!(0, fs_1.existsSync)(source)) {
|
|
407
|
+
common_1.Logger.error(`The source directory "${source}" doesn't exist.`);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (!(0, fs_1.existsSync)(target)) {
|
|
411
|
+
(0, fs_1.mkdirSync)(target);
|
|
412
|
+
}
|
|
413
|
+
const files = (0, fs_1.readdirSync)(source);
|
|
414
|
+
files.forEach(file => {
|
|
415
|
+
const sourcePath = path_1.default.join(source, file);
|
|
416
|
+
const targetPath = path_1.default.join(target, file);
|
|
417
|
+
if ((0, fs_1.lstatSync)(sourcePath).isDirectory()) {
|
|
418
|
+
copyDirectoryRecursive(sourcePath, targetPath);
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
(0, fs_1.copyFileSync)(sourcePath, targetPath);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
async function bootstrap() {
|
|
426
|
+
/* create factory directory and copy files from assets if empty or not exist */
|
|
427
|
+
const digipairsDir = process.env.DIGIPAIR_FACTORY_PATH || './factory';
|
|
428
|
+
common_1.Logger.log(`Check if the digipairs folder exists`);
|
|
429
|
+
if (!(0, fs_1.existsSync)(digipairsDir)) {
|
|
430
|
+
common_1.Logger.log(`-> digipairs folder not exists: ${digipairsDir}`);
|
|
431
|
+
(0, fs_1.mkdirSync)(digipairsDir);
|
|
432
|
+
common_1.Logger.log(`-> digipairs folder created: ${digipairsDir}`);
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
common_1.Logger.log(`-> digipairs folder exists: ${digipairsDir}`);
|
|
436
|
+
}
|
|
437
|
+
const assetsDir = `${__dirname}/assets`;
|
|
438
|
+
const digipairsFiles = (0, fs_1.readdirSync)(digipairsDir);
|
|
439
|
+
common_1.Logger.log(`Check if the factory folder is already filled with digipairs files. Number files found: ${digipairsFiles.length}`);
|
|
440
|
+
if (!digipairsFiles.length) {
|
|
441
|
+
common_1.Logger.log(`Digipair files not found -> start copy from digipair assets folder: ${assetsDir}`);
|
|
442
|
+
copyDirectoryRecursive(assetsDir, digipairsDir);
|
|
443
|
+
common_1.Logger.log(`Copy finished`);
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
common_1.Logger.log(`Digipair files already present: ${digipairsFiles.join(', ')}`);
|
|
447
|
+
}
|
|
448
|
+
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
|
449
|
+
app.use(bodyParser.json({ limit: '50mb' }));
|
|
450
|
+
app.enableCors();
|
|
451
|
+
const port = process.env.PORT || 8080;
|
|
452
|
+
await app.listen(port);
|
|
453
|
+
common_1.Logger.log(`🚀 Application is running on: http://localhost:${port}`);
|
|
454
|
+
}
|
|
455
|
+
bootstrap();
|
|
456
|
+
|
|
457
|
+
})();
|
|
458
|
+
|
|
459
|
+
/******/ })()
|
|
460
|
+
;
|
|
461
|
+
//# sourceMappingURL=main.js.map
|
package/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","mappings":"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U,UAAU;AACnF;AACA,6CAA6C,KAAK,GAAG,SAAS;AAC9D,0DAA0D,KAAK,GAAG,SAAS;AAC3E;AACA,6CAA6C,KAAK;AAClD,0DAA0D,KAAK;AAC/D;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,kBAAkB;AAClB;AACA;;;;;;;;AC/JA,6C;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qC;;;;;;;ACRA,iC;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA,wF;;;;;;;;;ACAa;AACb;AACA;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,gBAAgB,mBAAO,CAAC,CAAO;AAC/B,iBAAiB,mBAAO,CAAC,CAAgB;AACzC,eAAe,mBAAO,CAAC,CAAc;AACrC,wCAAwC,mBAAO,CAAC,CAAa;AAC7D,qBAAqB,mBAAO,CAAC,CAAkB;AAC/C,aAAa,mBAAO,CAAC,CAAI;AACzB,uCAAuC,mBAAO,CAAC,EAAM;AACrD;AACA;AACA,uDAAuD,OAAO;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,+DAA+D,aAAa;AAC5E;AACA,4DAA4D,aAAa;AACzE;AACA;AACA,2DAA2D,aAAa;AACxE;AACA,yBAAyB,UAAU;AACnC;AACA,mHAAmH,sBAAsB;AACzI;AACA,mGAAmG,UAAU;AAC7G;AACA;AACA;AACA;AACA,+DAA+D,0BAA0B;AACzF;AACA;AACA,8BAA8B,eAAe;AAC7C;AACA;AACA;AACA,0EAA0E,KAAK;AAC/E;AACA","sources":["webpack://digipair/external commonjs \"tslib\"","webpack://digipair/external commonjs \"@nestjs/common\"","webpack://digipair/external commonjs \"@nestjs/core\"","webpack://digipair/external commonjs \"body-parser\"","webpack://digipair/./src/app/app.module.ts","webpack://digipair/./src/app/app.controller.ts","webpack://digipair/external node-commonjs \"fs\"","webpack://digipair/./src/app/app.service.ts","webpack://digipair/external commonjs \"@digipair/engine\"","webpack://digipair/./src/app/ sync","webpack://digipair/external node-commonjs \"path\"","webpack://digipair/webpack/bootstrap","webpack://digipair/webpack/runtime/hasOwnProperty shorthand","webpack://digipair/./src/main.ts"],"sourcesContent":["module.exports = require(\"tslib\");","module.exports = require(\"@nestjs/common\");","module.exports = require(\"@nestjs/core\");","module.exports = require(\"body-parser\");","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AppModule = void 0;\nconst tslib_1 = require(\"tslib\");\nconst common_1 = require(\"@nestjs/common\");\nconst app_controller_1 = require(\"./app.controller\");\nconst app_service_1 = require(\"./app.service\");\nlet AppModule = class AppModule {\n};\nexports.AppModule = AppModule;\nexports.AppModule = AppModule = tslib_1.__decorate([\n (0, common_1.Module)({\n imports: [],\n controllers: [app_controller_1.AppController],\n providers: [app_service_1.AppService],\n })\n], AppModule);\n","\"use strict\";\nvar _a;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AppController = void 0;\nconst tslib_1 = require(\"tslib\");\nconst common_1 = require(\"@nestjs/common\");\nconst fs_1 = require(\"fs\");\nconst app_service_1 = require(\"./app.service\");\nconst requireDynamic = (module) => require(module);\nlet AppController = class AppController {\n constructor(appService) {\n this.appService = appService;\n }\n async public(res, req) {\n const filePath = `${__dirname}/assets/public${req.url.replace('/public', '')}`;\n res.sendFile(filePath, err => {\n if (err) {\n res.status(404).send('File not found');\n }\n });\n }\n async domain(res, request, body, query) {\n const assets = process.env.DIGIPAIR_FACTORY_PATH || './factory';\n const host = request.headers.host?.split(':')[0];\n const path = request.params['0'];\n let params, digipair, reasoning;\n const domains = JSON.parse(await fs_1.promises.readFile(`${assets}/domains.json`, 'utf8'));\n if (path === 'favicon.ico') {\n return res.send(null);\n }\n params = path.split('/');\n if (domains[host]) {\n digipair = domains[host].digipair;\n reasoning = params[0];\n params = params.slice(1);\n if (!reasoning) {\n res.redirect(`/${domains[host].reasoning}`);\n return;\n }\n }\n else if (params.length < 2) {\n res.redirect(`/admin/digipair-list`);\n return;\n }\n else {\n digipair = params[0];\n reasoning = params[1];\n params = params.slice(2);\n }\n try {\n const skillProcess = requireDynamic('@digipair/skill-process');\n const { id, signal } = skillProcess.add(digipair, reasoning, null);\n const method = request.method;\n res.on('close', () => {\n skillProcess.remove(id);\n });\n const result = await this.appService.agent(`${assets}/digipairs`, digipair, reasoning, body, params, query, method, request.headers, {}, request, res, signal);\n res.send(result);\n }\n catch (error) {\n if (error.type !== 'DIGIPAIR_KEEPALIVE') {\n throw error;\n }\n }\n }\n};\nexports.AppController = AppController;\ntslib_1.__decorate([\n (0, common_1.Get)('/public/*'),\n tslib_1.__param(0, (0, common_1.Res)()),\n tslib_1.__param(1, (0, common_1.Req)()),\n tslib_1.__metadata(\"design:type\", Function),\n tslib_1.__metadata(\"design:paramtypes\", [Object, Object]),\n tslib_1.__metadata(\"design:returntype\", Promise)\n], AppController.prototype, \"public\", null);\ntslib_1.__decorate([\n (0, common_1.All)('*'),\n tslib_1.__param(0, (0, common_1.Res)()),\n tslib_1.__param(1, (0, common_1.Req)()),\n tslib_1.__param(2, (0, common_1.Body)()),\n tslib_1.__param(3, (0, common_1.Query)()),\n tslib_1.__metadata(\"design:type\", Function),\n tslib_1.__metadata(\"design:paramtypes\", [Object, Object, Object, Object]),\n tslib_1.__metadata(\"design:returntype\", Promise)\n], AppController.prototype, \"domain\", null);\nexports.AppController = AppController = tslib_1.__decorate([\n (0, common_1.Controller)(),\n tslib_1.__metadata(\"design:paramtypes\", [typeof (_a = typeof app_service_1.AppService !== \"undefined\" && app_service_1.AppService) === \"function\" ? _a : Object])\n], AppController);\n","module.exports = require(\"fs\");","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AppService = void 0;\nconst tslib_1 = require(\"tslib\");\nconst engine_1 = require(\"@digipair/engine\");\nconst common_1 = require(\"@nestjs/common\");\nconst fs_1 = require(\"fs\");\nconst requireDynamic = (module) => require(module);\nengine_1.config.set('ALIAS', [\n {\n name: 'digipair',\n library: '@digipair/skill-factory',\n element: 'start',\n properties: {\n digipair: '{{settings.library}}',\n reasoning: '{{settings.element}}',\n version: '{{settings.version}}',\n body: 'EVALUATE:settings.properties',\n },\n },\n]);\nengine_1.config.set('LOGGER', (level, path, message, context, data) => {\n const time = new Date().toISOString();\n switch (level) {\n case 'INFO':\n console.log(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`);\n break;\n case 'ERROR':\n console.error(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`, data);\n break;\n case 'DEBUG':\n console.debug(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`, data);\n break;\n default:\n console.log(`[${time}][${context.request.digipair}@${context.request.reasoning}][${path}] ${message}`);\n break;\n }\n});\nlet AppService = class AppService {\n async onModuleInit() {\n const path = process.env.DIGIPAIR_FACTORY_PATH\n ? `${process.env.DIGIPAIR_FACTORY_PATH}/digipairs`\n : './factory/digipairs';\n // initialize logs management\n const skillLogger = requireDynamic('@digipair/skill-logger');\n await skillLogger.initialize();\n // initialize factory skill\n const skillFactory = requireDynamic('@digipair/skill-factory');\n skillFactory.initialize((context, digipair, reasoning, body) => this.agent(path, digipair, reasoning, body, [], {}, null, {}, context, null, null, context.protected.signal));\n // start cron manager\n try {\n const skillCron = requireDynamic('@digipair/skill-cron');\n skillCron.initialize(async (path, digipair, reasoning) => {\n const skillProcess = requireDynamic('@digipair/skill-process');\n const { id, signal } = skillProcess.add(digipair, reasoning, null);\n try {\n await this.agent(path, digipair, reasoning, {}, [], {}, null, {}, {}, null, null, signal);\n skillProcess.remove(id);\n }\n catch (error) {\n if (error.type !== 'DIGIPAIR_KEEPALIVE') {\n console.error(error);\n skillProcess.remove(id);\n }\n }\n });\n skillCron.start(path);\n }\n catch (error) {\n console.error(error);\n }\n // start workflow manager\n try {\n const skillTemporal = requireDynamic('@digipair/skill-temporal');\n if (process.env.TEMPORAL_CLUSTER_HOST) {\n skillTemporal.initialize();\n }\n }\n catch (error) {\n console.error(error);\n }\n }\n async agent(path, digipair, reasoning, body, params, query, method, headers, requester, req, res, signal) {\n const assets = process.env.DIGIPAIR_FACTORY_PATH || './factory';\n let context;\n try {\n let content;\n content = await fs_1.promises.readFile(`${assets}/default.json`, 'utf8');\n const defaultConfig = JSON.parse(content);\n content = await fs_1.promises.readFile(`${path}/common/config.json`, 'utf8');\n const commonConfig = JSON.parse(content);\n content = await fs_1.promises.readFile(`${path}/${digipair}/config.json`, 'utf8');\n const config = JSON.parse(content);\n context = {\n config: {\n VERSIONS: { ...defaultConfig.libraries, ...commonConfig.libraries, ...config.libraries },\n WEB_VERSIONS: {\n ...defaultConfig.webLibraries,\n ...commonConfig.webLibraries,\n ...config.webLibraries,\n },\n },\n privates: { ...defaultConfig.privates, ...commonConfig.privates, ...config.privates },\n variables: { ...defaultConfig.variables, ...commonConfig.variables, ...config.variables },\n request: {\n digipair,\n reasoning,\n method,\n body,\n params,\n query,\n headers,\n },\n protected: {\n req,\n res,\n signal,\n },\n requester,\n };\n if ((0, fs_1.existsSync)(`${path}/${digipair}/${reasoning}.json`)) {\n content = await fs_1.promises.readFile(`${path}/${digipair}/${reasoning}.json`, 'utf8');\n }\n else if ((0, fs_1.existsSync)(`${path}/common/${reasoning}.json`) === true) {\n content = await fs_1.promises.readFile(`${path}/common/${reasoning}.json`, 'utf8');\n }\n else if ((0, fs_1.existsSync)(`${path}/${digipair}/fallback.json`)) {\n content = await fs_1.promises.readFile(`${path}/${digipair}/fallback.json`, 'utf8');\n }\n else if ((0, fs_1.existsSync)(`${path}/common/fallback.json`) === true) {\n content = await fs_1.promises.readFile(`${path}/common/fallback.json`, 'utf8');\n }\n else {\n res.status(404);\n return { status: 'not found' };\n }\n const settings = JSON.parse(content);\n const result = await (0, engine_1.executePinsList)([settings], context, 'reasoning');\n return result;\n }\n catch (error) {\n if (error.type === 'DIGIPAIR_KEEPALIVE') {\n throw error;\n }\n if (error.type === 'DIGIPAIR_STOP') {\n return error.value;\n }\n console.error(error);\n if (!context) {\n return;\n }\n const skillLogger = requireDynamic('@digipair/skill-logger');\n skillLogger.addLog(context, 'ERROR', error.message);\n }\n }\n};\nexports.AppService = AppService;\nexports.AppService = AppService = tslib_1.__decorate([\n (0, common_1.Injectable)()\n], AppService);\n","module.exports = require(\"@digipair/engine\");","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = () => ([]);\nwebpackEmptyContext.resolve = webpackEmptyContext;\nwebpackEmptyContext.id = 10;\nmodule.exports = webpackEmptyContext;","module.exports = require(\"path\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","\"use strict\";\n/**\n * This is not a production server yet!\n * This is only a minimal backend to get started.\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst tslib_1 = require(\"tslib\");\nconst common_1 = require(\"@nestjs/common\");\nconst core_1 = require(\"@nestjs/core\");\nconst bodyParser = tslib_1.__importStar(require(\"body-parser\"));\nconst app_module_1 = require(\"./app/app.module\");\nconst fs_1 = require(\"fs\");\nconst path_1 = tslib_1.__importDefault(require(\"path\"));\nfunction copyDirectoryRecursive(source, target) {\n if (!(0, fs_1.existsSync)(source)) {\n common_1.Logger.error(`The source directory \"${source}\" doesn't exist.`);\n return;\n }\n if (!(0, fs_1.existsSync)(target)) {\n (0, fs_1.mkdirSync)(target);\n }\n const files = (0, fs_1.readdirSync)(source);\n files.forEach(file => {\n const sourcePath = path_1.default.join(source, file);\n const targetPath = path_1.default.join(target, file);\n if ((0, fs_1.lstatSync)(sourcePath).isDirectory()) {\n copyDirectoryRecursive(sourcePath, targetPath);\n }\n else {\n (0, fs_1.copyFileSync)(sourcePath, targetPath);\n }\n });\n}\nasync function bootstrap() {\n /* create factory directory and copy files from assets if empty or not exist */\n const digipairsDir = process.env.DIGIPAIR_FACTORY_PATH || './factory';\n common_1.Logger.log(`Check if the digipairs folder exists`);\n if (!(0, fs_1.existsSync)(digipairsDir)) {\n common_1.Logger.log(`-> digipairs folder not exists: ${digipairsDir}`);\n (0, fs_1.mkdirSync)(digipairsDir);\n common_1.Logger.log(`-> digipairs folder created: ${digipairsDir}`);\n }\n else {\n common_1.Logger.log(`-> digipairs folder exists: ${digipairsDir}`);\n }\n const assetsDir = `${__dirname}/assets`;\n const digipairsFiles = (0, fs_1.readdirSync)(digipairsDir);\n common_1.Logger.log(`Check if the factory folder is already filled with digipairs files. Number files found: ${digipairsFiles.length}`);\n if (!digipairsFiles.length) {\n common_1.Logger.log(`Digipair files not found -> start copy from digipair assets folder: ${assetsDir}`);\n copyDirectoryRecursive(assetsDir, digipairsDir);\n common_1.Logger.log(`Copy finished`);\n }\n else {\n common_1.Logger.log(`Digipair files already present: ${digipairsFiles.join(', ')}`);\n }\n const app = await core_1.NestFactory.create(app_module_1.AppModule);\n app.use(bodyParser.json({ limit: '50mb' }));\n app.enableCors();\n const port = process.env.PORT || 8080;\n await app.listen(port);\n common_1.Logger.log(`🚀 Application is running on: http://localhost:${port}`);\n}\nbootstrap();\n"],"names":[],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,51 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "digipair",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.93.0-0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"nx": {
|
|
6
|
+
"name": "factory",
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "nx:run-commands",
|
|
10
|
+
"options": {
|
|
11
|
+
"command": "webpack-cli build",
|
|
12
|
+
"args": [
|
|
13
|
+
"node-env=production"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"configurations": {
|
|
17
|
+
"development": {
|
|
18
|
+
"args": [
|
|
19
|
+
"node-env=development"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"serve": {
|
|
25
|
+
"continuous": true,
|
|
26
|
+
"executor": "@nx/js:node",
|
|
27
|
+
"defaultConfiguration": "development",
|
|
28
|
+
"dependsOn": [
|
|
29
|
+
"build"
|
|
30
|
+
],
|
|
31
|
+
"options": {
|
|
32
|
+
"buildTarget": "factory:build",
|
|
33
|
+
"runBuildTargetDependencies": false
|
|
34
|
+
},
|
|
35
|
+
"configurations": {
|
|
36
|
+
"development": {
|
|
37
|
+
"buildTarget": "factory:build:development"
|
|
38
|
+
},
|
|
39
|
+
"production": {
|
|
40
|
+
"buildTarget": "factory:build:production"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
7
45
|
},
|
|
8
46
|
"dependencies": {
|
|
9
|
-
"@
|
|
10
|
-
"@
|
|
11
|
-
"@
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"@digipair/skill-http": "0.92.1",
|
|
20
|
-
"@digipair/skill-llm": "0.92.1",
|
|
21
|
-
"@digipair/skill-openai": "0.92.1",
|
|
22
|
-
"@digipair/skill-service": "0.92.1",
|
|
23
|
-
"@digipair/skill-sse": "0.92.1",
|
|
24
|
-
"@digipair/skill-temporal": "0.92.1",
|
|
25
|
-
"@digipair/skill-web": "0.92.1",
|
|
26
|
-
"@digipair/skill-logger": "0.92.1",
|
|
27
|
-
"@digipair/skill-process": "0.92.1",
|
|
28
|
-
"@digipair/skill-oauth2": "0.92.1",
|
|
29
|
-
"@digipair/skill-imap": "0.92.1",
|
|
30
|
-
"@digipair/skill-sendmail": "0.92.1",
|
|
31
|
-
"@digipair/skill-web-debug": "0.92.1",
|
|
32
|
-
"@digipair/skill-web-jsoneditor": "0.92.1",
|
|
33
|
-
"@digipair/skill-web-notification": "0.92.1",
|
|
34
|
-
"@digipair/skill-web-chatbot": "0.92.1",
|
|
35
|
-
"@digipair/skill-web-editor": "0.92.1",
|
|
36
|
-
"@digipair/skill-web-inputs": "0.92.1",
|
|
37
|
-
"@digipair/skill-web-spectrum": "0.92.1",
|
|
38
|
-
"@digipair/skill-web-interact": "0.92.1",
|
|
39
|
-
"@digipair/skill-web-font-awesome": "0.92.1",
|
|
40
|
-
"@digipair/skill-yaml": "0.92.1",
|
|
41
|
-
"tslib": "^2.6.3",
|
|
42
|
-
"@nestjs/common": "^10.3.9",
|
|
43
|
-
"@nestjs/core": "^10.3.9",
|
|
44
|
-
"@nestjs/platform-express": "^10.3.9",
|
|
45
|
-
"@nestjs/serve-static": "^4.0.2",
|
|
46
|
-
"reflect-metadata": "^0.2.2",
|
|
47
|
-
"blockly": "10.4.3",
|
|
48
|
-
"toastify-js": "1.12.0"
|
|
47
|
+
"@nestjs/common": "10.4.19",
|
|
48
|
+
"@nestjs/core": "10.4.19",
|
|
49
|
+
"@nestjs/platform-express": "10.4.19",
|
|
50
|
+
"body-parser": "1.20.3",
|
|
51
|
+
"class-transformer": "0.5.1",
|
|
52
|
+
"class-validator": "0.14.2",
|
|
53
|
+
"express": "4.21.2",
|
|
54
|
+
"handlebars": "4.7.8",
|
|
55
|
+
"reflect-metadata": "0.1.14",
|
|
56
|
+
"rxjs": "7.8.2"
|
|
49
57
|
},
|
|
50
|
-
"
|
|
58
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
|
59
|
+
"main": "main.js"
|
|
51
60
|
}
|