digipair 0.0.1
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/assets/default/avatar.png +0 -0
- package/assets/default/chat.json +18 -0
- package/assets/default/config.json +27 -0
- package/assets/default/conversation.json +26 -0
- package/assets/default/history.json +23 -0
- package/assets/digipairs/admin/avatar.png +0 -0
- package/assets/digipairs/admin/boost-add-reasoning.json +54 -0
- package/assets/digipairs/admin/boost-duplicate-reasoning.json +62 -0
- package/assets/digipairs/admin/boost-plan-reasoning.json +46 -0
- package/assets/digipairs/admin/chat.json +18 -0
- package/assets/digipairs/admin/config.json +34 -0
- package/assets/digipairs/admin/conversation.json +26 -0
- package/assets/digipairs/admin/digipair-list.json +465 -0
- package/assets/digipairs/admin/history.json +23 -0
- package/assets/digipairs/admin/json-editor.json +221 -0
- package/assets/digipairs/admin/reasoning-editor.json +225 -0
- package/assets/digipairs/admin/reasoning-list.json +762 -0
- package/assets/digipairs/common/avatar.png +0 -0
- package/assets/digipairs/common/boosts.json +18 -0
- package/assets/digipairs/common/config.json +10 -0
- package/assets/digipairs/common/metadata.json +18 -0
- package/assets/digipairs/planning.json +0 -0
- package/assets/domains.json +1 -0
- package/bin/digipair.js +3 -0
- package/package.json +43 -0
- package/src/app/app.controller.js +55 -0
- package/src/app/app.controller.js.map +1 -0
- package/src/app/app.module.js +18 -0
- package/src/app/app.module.js.map +1 -0
- package/src/app/app.service.js +63 -0
- package/src/app/app.service.js.map +1 -0
- package/src/main.js +65 -0
- package/src/main.js.map +1 -0
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Get boosts",
|
|
3
|
+
"description": "Get boosts for a Digipair.",
|
|
4
|
+
"metadata": {},
|
|
5
|
+
"library": "@digipair/skill-service",
|
|
6
|
+
"element": "service",
|
|
7
|
+
"properties": {
|
|
8
|
+
"execute": [
|
|
9
|
+
{
|
|
10
|
+
"library": "@digipair/skill-common",
|
|
11
|
+
"element": "boosts",
|
|
12
|
+
"properties": {
|
|
13
|
+
"digipair": "{{request.body.digipair}}"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "common",
|
|
3
|
+
"description": "common actions.",
|
|
4
|
+
"metadata": { "avatar": "avatar.png", "color": "#3b82f6" },
|
|
5
|
+
"libraries": { "@digipair/skill-service": "latest", "@digipair/skill-common": "latest" },
|
|
6
|
+
"variables": {},
|
|
7
|
+
"privates": {},
|
|
8
|
+
"digipair": "common",
|
|
9
|
+
"id": "config"
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Get metadata",
|
|
3
|
+
"description": "Get metadata for a Digipair.",
|
|
4
|
+
"metadata": {},
|
|
5
|
+
"library": "@digipair/skill-service",
|
|
6
|
+
"element": "service",
|
|
7
|
+
"properties": {
|
|
8
|
+
"execute": [
|
|
9
|
+
{
|
|
10
|
+
"library": "@digipair/skill-common",
|
|
11
|
+
"element": "metadata",
|
|
12
|
+
"properties": {
|
|
13
|
+
"digipair": "{{request.body.digipair}}"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/bin/digipair.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "digipair",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"bin": {
|
|
6
|
+
"digipair": "./bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@digipair/engine": "latest",
|
|
10
|
+
"@digipair/skill-chatbot": "latest",
|
|
11
|
+
"@digipair/skill-common": "latest",
|
|
12
|
+
"@digipair/skill-cron": "latest",
|
|
13
|
+
"@digipair/skill-data-management": "latest",
|
|
14
|
+
"@digipair/skill-debug": "latest",
|
|
15
|
+
"@digipair/skill-dsp": "latest",
|
|
16
|
+
"@digipair/skill-editor": "latest",
|
|
17
|
+
"@digipair/skill-factory": "latest",
|
|
18
|
+
"@digipair/skill-git": "latest",
|
|
19
|
+
"@digipair/skill-http": "latest",
|
|
20
|
+
"@digipair/skill-keycloak": "latest",
|
|
21
|
+
"@digipair/skill-linkedin": "latest",
|
|
22
|
+
"@digipair/skill-llm": "latest",
|
|
23
|
+
"@digipair/skill-microsoft": "latest",
|
|
24
|
+
"@digipair/skill-mongodb": "latest",
|
|
25
|
+
"@digipair/skill-nuki": "latest",
|
|
26
|
+
"@digipair/skill-ollama": "latest",
|
|
27
|
+
"@digipair/skill-openai": "latest",
|
|
28
|
+
"@digipair/skill-pushbullet": "latest",
|
|
29
|
+
"@digipair/skill-sendmail": "latest",
|
|
30
|
+
"@digipair/skill-service": "latest",
|
|
31
|
+
"@digipair/skill-smoobu": "latest",
|
|
32
|
+
"@digipair/skill-temporal": "latest",
|
|
33
|
+
"@digipair/skill-twilio": "latest",
|
|
34
|
+
"@digipair/skill-vespa": "latest",
|
|
35
|
+
"@digipair/skill-web": "latest",
|
|
36
|
+
"tslib": "^2.6.3",
|
|
37
|
+
"@nestjs/common": "^10.3.9",
|
|
38
|
+
"@nestjs/core": "^10.3.9",
|
|
39
|
+
"@nestjs/platform-express": "^10.3.9",
|
|
40
|
+
"@nestjs/serve-static": "^4.0.2"
|
|
41
|
+
},
|
|
42
|
+
"main": "./src/main.js"
|
|
43
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppController = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const app_service_1 = require("./app.service");
|
|
8
|
+
let AppController = class AppController {
|
|
9
|
+
constructor(appService) {
|
|
10
|
+
this.appService = appService;
|
|
11
|
+
}
|
|
12
|
+
async domain(res, request, body) {
|
|
13
|
+
const assets = process.env.DIGIPAIR_AGENTS_PATH || './factory';
|
|
14
|
+
const host = request.headers.host.split(':')[0];
|
|
15
|
+
const path = request.params['0'];
|
|
16
|
+
let params, digipair, reasoning;
|
|
17
|
+
const domains = JSON.parse(await fs_1.promises.readFile(`${assets}/domains.json`, 'utf8'));
|
|
18
|
+
if (path === 'favicon.ico') {
|
|
19
|
+
return res.send(null);
|
|
20
|
+
}
|
|
21
|
+
if (domains[host]) {
|
|
22
|
+
params = path.split('/');
|
|
23
|
+
digipair = domains[host].digipair;
|
|
24
|
+
reasoning = params[0];
|
|
25
|
+
params = params.slice(1);
|
|
26
|
+
if (!reasoning) {
|
|
27
|
+
res.redirect(`/${domains[host].reasoning}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
params = path.split('/');
|
|
33
|
+
digipair = params[0];
|
|
34
|
+
reasoning = params[1];
|
|
35
|
+
params = params.slice(2);
|
|
36
|
+
}
|
|
37
|
+
const method = request.method;
|
|
38
|
+
res.send(await this.appService.agent(`${assets}/digipairs`, digipair, reasoning, body, params, method, request.headers));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.AppController = AppController;
|
|
42
|
+
tslib_1.__decorate([
|
|
43
|
+
(0, common_1.All)('*'),
|
|
44
|
+
tslib_1.__param(0, (0, common_1.Res)()),
|
|
45
|
+
tslib_1.__param(1, (0, common_1.Req)()),
|
|
46
|
+
tslib_1.__param(2, (0, common_1.Body)()),
|
|
47
|
+
tslib_1.__metadata("design:type", Function),
|
|
48
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
|
|
49
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
50
|
+
], AppController.prototype, "domain", null);
|
|
51
|
+
exports.AppController = AppController = tslib_1.__decorate([
|
|
52
|
+
(0, common_1.Controller)(),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [app_service_1.AppService])
|
|
54
|
+
], AppController);
|
|
55
|
+
//# sourceMappingURL=app.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../../../../../apps/factory/src/app/app.controller.ts"],"names":[],"mappings":";;;;AAAA,2CAAiE;AAEjE,2BAA8B;AAC9B,+CAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGjD,AAAN,KAAK,CAAC,MAAM,CAAQ,GAAa,EAAS,OAAgB,EAAU,IAAS;QAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,WAAW,CAAC;QAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAgB,EAAE,QAAgB,EAAE,SAAiB,CAAC;QAE1D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,aAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;QAEtF,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;YAClC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAEzB,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,GAAG,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;gBAC5C,OAAO;YACT,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACrB,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,GAAG,CAAC,IAAI,CACN,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CACzB,GAAG,MAAM,YAAY,EACrB,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,CAAC,OAAO,CAChB,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AA9CY,sCAAa;AAIlB;IADL,IAAA,YAAG,EAAC,GAAG,CAAC;IACK,mBAAA,IAAA,YAAG,GAAE,CAAA;IAAiB,mBAAA,IAAA,YAAG,GAAE,CAAA;IAAoB,mBAAA,IAAA,aAAI,GAAE,CAAA;;;;2CAyClE;wBA7CU,aAAa;IADzB,IAAA,mBAAU,GAAE;6CAE8B,wBAAU;GADxC,aAAa,CA8CzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const app_controller_1 = require("./app.controller");
|
|
7
|
+
const app_service_1 = require("./app.service");
|
|
8
|
+
let AppModule = class AppModule {
|
|
9
|
+
};
|
|
10
|
+
exports.AppModule = AppModule;
|
|
11
|
+
exports.AppModule = AppModule = tslib_1.__decorate([
|
|
12
|
+
(0, common_1.Module)({
|
|
13
|
+
imports: [],
|
|
14
|
+
controllers: [app_controller_1.AppController],
|
|
15
|
+
providers: [app_service_1.AppService],
|
|
16
|
+
})
|
|
17
|
+
], AppModule);
|
|
18
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../../../apps/factory/src/app/app.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAOpC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const engine_1 = require("@digipair/engine");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
let AppService = class AppService {
|
|
9
|
+
async onModuleInit() {
|
|
10
|
+
const path = process.env.DIGIPAIR_AGENTS_PATH ? `${process.env.DIGIPAIR_AGENTS_PATH}/digipairs` : './factory/digipairs';
|
|
11
|
+
// initialize factory skill
|
|
12
|
+
const skillFactory = require('@digipair/skill-cron');
|
|
13
|
+
skillFactory.initialize((_context, digipair, reasoning, body) => this.agent(path, digipair, reasoning, body, [], null, {}));
|
|
14
|
+
// start cron manager
|
|
15
|
+
try {
|
|
16
|
+
const skillCron = require('@digipair/skill-cron');
|
|
17
|
+
skillCron.initialize((path, digipair, reasoning) => this.agent(path, digipair, reasoning, {}, [], null, {}));
|
|
18
|
+
skillCron.start(`${path}`);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error(error);
|
|
22
|
+
}
|
|
23
|
+
// start workflow manager
|
|
24
|
+
try {
|
|
25
|
+
const skillTemporal = require('@digipair/skill-temporal');
|
|
26
|
+
if (process.env.TEMPORAL_CLUSTER_HOST) {
|
|
27
|
+
skillTemporal.initialize();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async agent(path, digipair, reasoning, body, params, method, headers) {
|
|
35
|
+
let content;
|
|
36
|
+
content = await fs_1.promises.readFile(`${path}/${digipair}/config.json`, 'utf8');
|
|
37
|
+
const config = JSON.parse(content);
|
|
38
|
+
content = await fs_1.promises.readFile(`${path}/${digipair}/${reasoning}.json`, 'utf8');
|
|
39
|
+
const settings = JSON.parse(content);
|
|
40
|
+
const context = {
|
|
41
|
+
config: {
|
|
42
|
+
VERSIONS: config.libraries,
|
|
43
|
+
},
|
|
44
|
+
privates: config.privates,
|
|
45
|
+
variables: config.variables,
|
|
46
|
+
request: {
|
|
47
|
+
digipair,
|
|
48
|
+
reasoning,
|
|
49
|
+
method,
|
|
50
|
+
body,
|
|
51
|
+
params,
|
|
52
|
+
headers,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const result = (0, engine_1.executePinsList)([settings], context);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.AppService = AppService;
|
|
60
|
+
exports.AppService = AppService = tslib_1.__decorate([
|
|
61
|
+
(0, common_1.Injectable)()
|
|
62
|
+
], AppService);
|
|
63
|
+
//# sourceMappingURL=app.service.js.map
|
|
@@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+
/**
|
|
3
|
+
* This is not a production server yet!
|
|
4
|
+
* This is only a minimal backend to get started.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const common_1 = require("@nestjs/common");
|
|
9
|
+
const core_1 = require("@nestjs/core");
|
|
10
|
+
const bodyParser = tslib_1.__importStar(require("body-parser"));
|
|
11
|
+
const app_module_1 = require("./app/app.module");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
|
+
function copyDirectoryRecursive(source, target) {
|
|
15
|
+
if (!(0, fs_1.existsSync)(source)) {
|
|
16
|
+
common_1.Logger.error(`The source directory "${source}" doesn't exist.`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!(0, fs_1.existsSync)(target)) {
|
|
20
|
+
(0, fs_1.mkdirSync)(target);
|
|
21
|
+
}
|
|
22
|
+
const files = (0, fs_1.readdirSync)(source);
|
|
23
|
+
files.forEach(file => {
|
|
24
|
+
const sourcePath = path_1.default.join(source, file);
|
|
25
|
+
const targetPath = path_1.default.join(target, file);
|
|
26
|
+
if ((0, fs_1.lstatSync)(sourcePath).isDirectory()) {
|
|
27
|
+
copyDirectoryRecursive(sourcePath, targetPath);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
(0, fs_1.copyFileSync)(sourcePath, targetPath);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function bootstrap() {
|
|
35
|
+
/* create factory directory and copy files from assets if empty or not exist */
|
|
36
|
+
const digipairsDir = process.env.DIGIPAIR_FACTORY_PATH || './factory';
|
|
37
|
+
common_1.Logger.log(`Check if the digipairs folder exists`);
|
|
38
|
+
if (!(0, fs_1.existsSync)(digipairsDir)) {
|
|
39
|
+
common_1.Logger.log(`-> digipairs folder not exists: ${digipairsDir}`);
|
|
40
|
+
(0, fs_1.mkdirSync)(digipairsDir);
|
|
41
|
+
common_1.Logger.log(`-> digipairs folder created: ${digipairsDir}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
common_1.Logger.log(`-> digipairs folder exists: ${digipairsDir}`);
|
|
45
|
+
}
|
|
46
|
+
const assetsDir = `${__dirname}/assets`;
|
|
47
|
+
const digipairsFiles = (0, fs_1.readdirSync)(digipairsDir);
|
|
48
|
+
common_1.Logger.log(`Check if the factory folder is already filled with digipairs files. Number files found: ${digipairsFiles.length}`);
|
|
49
|
+
if (!digipairsFiles.length) {
|
|
50
|
+
common_1.Logger.log(`Digipair files not found -> start copy from digipair assets folder: ${assetsDir}`);
|
|
51
|
+
copyDirectoryRecursive(assetsDir, digipairsDir);
|
|
52
|
+
common_1.Logger.log(`Copy finished`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
common_1.Logger.log(`Digipair files already present: ${digipairsFiles.join(', ')}`);
|
|
56
|
+
}
|
|
57
|
+
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
|
58
|
+
app.use(bodyParser.json({ limit: '50mb' }));
|
|
59
|
+
app.enableCors();
|
|
60
|
+
const port = process.env.PORT || 8080;
|
|
61
|
+
await app.listen(port);
|
|
62
|
+
common_1.Logger.log(`🚀 Application is running on: http://localhost:${port}`);
|
|
63
|
+
}
|
|
64
|
+
bootstrap();
|
|
65
|
+
//# sourceMappingURL=main.js.map
|
package/src/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../apps/factory/src/main.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAwC;AACxC,uCAA2C;AAC3C,gEAA0C;AAE1C,iDAA6C;AAC7C,2BAAiF;AACjF,wDAAwB;AAExB,SAAS,sBAAsB,CAAC,MAAM,EAAE,MAAM;IAC5C,IAAI,CAAC,IAAA,eAAU,EAAC,MAAM,CAAC,EAAE,CAAC;QACxB,eAAM,CAAC,KAA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