mm_workflow 1.5.0 → 1.6.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/common/mod/dispatcher/load_balance/index.js +8 -6
- package/common/mod/executor/custom/index.js +7 -8
- package/common/mod/generator/llm_gen_workflow/index.js +113 -100
- package/common/mod/manager/database/index.js +39 -26
- package/common/mod/manager/discovery/index.js +17 -3
- package/common/mod/manager/json_util.js +43 -31
- package/common/mod/observer/audit/index.js +7 -4
- package/common/mod/observer/prometheus/index.js +59 -42
- package/common/mod/receiver/webhook/index.js +30 -11
- package/index.js +0 -4
- package/kernel/blockly_converter.js +55 -33
- package/kernel/blockly_defs.js +88 -71
- package/kernel/bpmn_parser.js +27 -15
- package/kernel/kernel.js +145 -103
- package/kernel/kernel_config.js +33 -7
- package/kernel/workflow_engine.js +30 -17
- package/kernel/workflow_state.js +25 -8
- package/package.json +19 -11
- package/tool/circuit_breaker/index.js +187 -5
- package/tool/ip_block/index.js +20 -5
- package/tool/rate_limit/index.js +49 -5
- package/tool/sensitive/index.js +29 -5
- package/tool/spam/index.js +30 -5
- package/tool/sql_inject/index.js +35 -5
- package/tool/workflow_admin/index.js +65 -0
- package/tool/workflow_admin/tool.json +40 -0
- package/tool/workflow_run/index.js +81 -0
- package/tool/workflow_run/tool.json +60 -0
- package/common/workflow/wftest_1789472356864/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472356864/suggest_h.json +0 -14
- package/common/workflow/wftest_1789472528456/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472528456/suggest_h.json +0 -14
- package/common/workflow/wftest_1789472914308/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472914308/suggest_h.json +0 -14
- package/common/workflow/wftest_1789472926735/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472926735/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473005165/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473005165/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473128440/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473128440/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473140984/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473140984/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473444205/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473444205/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473632028/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473632028/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473735755/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473735755/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473793373/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473793373/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474054650/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474054650/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474139961/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474139961/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474522109/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474522109/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474695647/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474695647/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474822920/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474822920/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474863955/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474863955/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474920642/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474920642/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474948523/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474948523/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474977320/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474977320/suggest_h.json +0 -14
- package/common/workflow/wftest_1789475013956/ok_wf.json +0 -20
- package/common/workflow/wftest_1789475013956/suggest_h.json +0 -14
- package/common/workflow/wftest_1789476776624/ok_wf.json +0 -20
- package/common/workflow/wftest_1789476776624/suggest_h.json +0 -14
- package/common/workflow/wftest_1789477074699/ok_wf.json +0 -20
- package/common/workflow/wftest_1789477074699/suggest_h.json +0 -14
- package/common/workflow/wftest_1789478655100/ok_wf.json +0 -20
- package/common/workflow/wftest_1789478655100/suggest_h.json +0 -14
- package/common/workflow/wftest_1789499010987/ok_wf.json +0 -20
- package/common/workflow/wftest_1789499010987/suggest_h.json +0 -14
- package/common/workflow/wftest_1789519488954/ok_wf.json +0 -20
- package/common/workflow/wftest_1789519488954/suggest_h.json +0 -14
- package/docs/API/345/217/202/350/200/203.md +0 -146
- package/docs/Blockly/346/230/240/345/260/204/346/226/271/346/241/210.md +0 -213
- package/docs/LLM/351/233/206/346/210/220/346/214/207/345/215/227.md +0 -29
- package/docs/Workflow/347/274/226/345/206/231/346/214/207/345/215/227.md +0 -194
- package/docs/ctx/344/270/212/344/270/213/346/226/207/350/257/246/350/247/243.md +0 -256
- package/docs//344/272/214/346/254/241/345/274/200/345/217/221/346/214/207/345/215/227.md +0 -151
- package/docs//345/244/232/345/215/217/350/256/256/350/247/246/345/217/221/346/214/207/345/215/227.md +0 -272
- package/docs//345/256/236/346/210/230/346/241/210/344/276/213.md +0 -392
- package/docs//345/267/245/344/275/234/346/265/201/350/246/206/347/233/226/345/210/206/346/236/220.md +0 -585
- package/docs//345/274/200/345/217/221/346/226/207/346/241/243.md +0 -200
- package/docs//345/277/253/351/200/237/345/274/200/345/247/213.md +0 -66
- package/docs//346/234/200/344/275/263/345/256/236/350/267/265.md +0 -265
- package/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +0 -29
- package/docs//346/240/270/345/277/203/346/246/202/345/277/265.md +0 -194
- package/docs//346/250/241/345/235/227/344/275/223/347/263/273/350/257/264/346/230/216.md +0 -111
- package/docs//346/250/241/345/235/227/346/270/205/345/215/225.md +0 -288
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/AI/345/267/245/344/275/234/346/265/201/347/224/237/346/210/220/346/210/220/346/234/254/345/210/206/346/236/220.md +0 -234
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/CM/345/207/275/346/225/260/345/244/247/345/205/250.md +0 -93
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/RPG_Maker_/344/272/213/344/273/266/350/204/232/346/234/254/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -734
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/270/211/345/233/275/346/235/200/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -379
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/277/256/344/273/231/345/206/263/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -256
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/277/256/344/273/231/347/211/210/345/215/241/347/211/214/346/270/270/346/210/217.md +0 -355
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/206/222/351/231/251/345/262/233CM/345/207/275/346/225/260/345/210/206/346/236/220.md +0 -81
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/206/222/351/231/251/345/262/233NPC/350/204/232/346/234/254/346/224/257/346/214/201/345/210/206/346/236/220.md +0 -365
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/244/247/351/203/250/345/210/206/351/200/232/347/224/250/346/250/241/345/235/227/345/210/206/346/236/220.md +0 -33
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/260/217/345/225/206/345/272/227/351/234/200/346/261/202/350/247/204/346/240/274.md +0 -577
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/250/241/346/213/237/344/272/272/347/224/237/346/201/213/347/210/261/345/205/273/346/210/220RPG/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -314
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/255/243/345/274/217/345/217/257/347/224/250/345/267/256/350/267/235/345/210/206/346/236/220.md +0 -463
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/270/270/346/210/217/347/216/213/345/215/241/347/211/214/346/270/270/346/210/217/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -673
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//350/264/252/345/251/252/344/271/213/345/262/233/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -405
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//350/264/252/345/251/252/344/271/213/345/262/233/347/262/276/347/256/200/347/211/210/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -289
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//351/207/215/350/243/205/346/234/272/345/205/265/346/226/207/345/255/227/347/211/210/346/270/270/346/210/217.md +0 -417
- package/docs//350/260/203/350/257/225/344/270/216/346/216/222/351/224/231.md +0 -255
- package/example/common/mod/executor/effect/executor.json +0 -58
- package/example/common/mod/executor/effect/index.js +0 -93
- package/example/common/mod/executor/warp/executor.json +0 -57
- package/example/common/mod/executor/warp/index.js +0 -73
- package/example/common/mod/manager/inventory/index.js +0 -205
- package/example/common/mod/manager/inventory/manager.json +0 -70
- package/example/common/mod/manager/persistence/index.js +0 -176
- package/example/common/mod/manager/persistence/manager.json +0 -67
- package/example/common/mod/manager/player/index.js +0 -187
- package/example/common/mod/manager/player/manager.json +0 -102
- package/example/common/mod/manager/quest/index.js +0 -196
- package/example/common/mod/manager/quest/manager.json +0 -50
- package/example/common/mod/manager/shop/index.js +0 -66
- package/example/common/mod/manager/shop/manager.json +0 -44
- package/example/common/mod/manager/skill/index.js +0 -143
- package/example/common/mod/manager/skill/manager.json +0 -82
- package/example/common/script/demo/index.js +0 -16
- package/example/common/script/demo/script.json +0 -21
- package/example/common/workflow/admin/dashboard.json +0 -87
- package/example/common/workflow/admin/order_deliver.json +0 -99
- package/example/common/workflow/admin/order_list.json +0 -79
- package/example/common/workflow/admin/product_off.json +0 -85
- package/example/common/workflow/admin/product_on.json +0 -85
- package/example/common/workflow/admin/user_list.json +0 -68
- package/example/common/workflow/cart/add.json +0 -86
- package/example/common/workflow/cart/checkout.json +0 -120
- package/example/common/workflow/cart/del.json +0 -47
- package/example/common/workflow/cart/list.json +0 -55
- package/example/common/workflow/cart/set.json +0 -106
- package/example/common/workflow/db/create_table.json +0 -57
- package/example/common/workflow/db/mysql_query.json +0 -47
- package/example/common/workflow/db/sqlite_crud.json +0 -48
- package/example/common/workflow/npc/blacksmith.json +0 -91
- package/example/common/workflow/npc/quest_giver.json +0 -136
- package/example/common/workflow/order/create.json +0 -76
- package/example/common/workflow/order/create_bpmn.json +0 -105
- package/example/common/workflow/order/history.json +0 -69
- package/example/common/workflow/payment/process.json +0 -74
- package/example/common/workflow/product/add.json +0 -72
- package/example/common/workflow/product/categories.json +0 -41
- package/example/common/workflow/product/count.json +0 -65
- package/example/common/workflow/product/del.json +0 -84
- package/example/common/workflow/product/get.json +0 -59
- package/example/common/workflow/product/list.json +0 -80
- package/example/common/workflow/product/search.json +0 -59
- package/example/common/workflow/product/set.json +0 -87
- package/example/common/workflow/shop/create.json +0 -70
- package/example/common/workflow/shop/del.json +0 -84
- package/example/common/workflow/shop/get.json +0 -43
- package/example/common/workflow/shop/list.json +0 -80
- package/example/common/workflow/shop/products.json +0 -69
- package/example/common/workflow/shop/set.json +0 -64
- package/example/common/workflow/system/monitor.json +0 -62
- package/example/common/workflow/user/address_add.json +0 -49
- package/example/common/workflow/user/address_list.json +0 -44
- package/example/common/workflow/user/change_password.json +0 -87
- package/example/common/workflow/user/login.json +0 -83
- package/example/common/workflow/user/profile.json +0 -71
- package/example/common/workflow/user/register.json +0 -77
- package/example/config +0 -122
- package/example/config.json +0 -94
- package/example/data/model/bag.json +0 -28
- package/example/data/model/character.json +0 -38
- package/example/data/model/quest.json +0 -14
- package/example/data/model/save.json +0 -10
- package/example/data/model/shop.json +0 -14
- package/example/data/model/skill.json +0 -28
- package/example/data/test.js +0 -365
- package/example/db/mm.db +0 -0
- package/example/db/mm.db-shm +0 -0
- package/example/db/mm.db-wal +0 -0
- package/example/db/sql/ecommerce.sql +0 -84
- package/example/db/sql/game.sql +0 -72
- package/example/ecom_out.txt +0 -0
- package/example/ecommerce.js +0 -450
- package/example/index.js +0 -262
- package/example/npc_demo.js +0 -361
- package/lib/tools/circuit_breaker/index.js +0 -164
- package/lib/tools/index.js +0 -16
- package/lib/tools/ip_block/index.js +0 -20
- package/lib/tools/rate_limit/index.js +0 -49
- package/lib/tools/sensitive/index.js +0 -29
- package/lib/tools/spam/index.js +0 -30
- package/lib/tools/sql_inject/index.js +0 -35
- package/llm.js +0 -257
- package/scan_modules.js +0 -124
- package/scripts/add_type_field.js +0 -153
- package/scripts/create_project.js +0 -276
- package/scripts/generate_mod.js +0 -229
- package/templates/db/backup_table.json +0 -52
- package/templates/db/create_table.json +0 -68
- package/templates/db/crud_sqlite.json +0 -98
- package/templates/db/db_sqlite.json +0 -52
- package/templates/db/ecommerce.sql +0 -87
- package/templates/db/export_table.json +0 -51
- package/templates/demo/hello.json +0 -47
- package/templates/demo/http_demo.json +0 -48
- package/templates/demo/llm_chat.json +0 -44
- package/templates/demo/render_demo.json +0 -46
- package/templates/demo/validator_demo.json +0 -64
- package/templates/order/create.json +0 -113
- package/templates/user_account/add.json +0 -92
- package/templates/user_account/count.json +0 -24
- package/templates/user_account/del.json +0 -38
- package/templates/user_account/get.json +0 -48
- package/templates/user_account/init.json +0 -76
- package/templates/user_account/list.json +0 -48
- package/templates/user_account/set.json +0 -65
- package/templates/user_account/user_account.sql +0 -21
- package/test.js +0 -253
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* 负载均衡调度器
|
|
3
3
|
* 支持轮询(round_robin)和加权轮询(weighted)两种策略
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
var round_robin_counters = {};
|
|
5
|
+
var { varsAdmin } = require('mm_vars');
|
|
7
6
|
|
|
8
7
|
async function main(params, ctx, options) {
|
|
9
8
|
var nodes = params.nodes || [];
|
|
@@ -23,12 +22,15 @@ async function main(params, ctx, options) {
|
|
|
23
22
|
|
|
24
23
|
switch (strategy) {
|
|
25
24
|
case 'round_robin': {
|
|
25
|
+
var store = varsAdmin((params && params.scope) || 'os');
|
|
26
|
+
var counters = store.get('round_robin') || {};
|
|
26
27
|
var key = (ctx.meta && ctx.meta.workflow_id) || 'default';
|
|
27
|
-
if (
|
|
28
|
-
|
|
28
|
+
if (counters[key] === undefined) {
|
|
29
|
+
counters[key] = 0;
|
|
29
30
|
}
|
|
30
|
-
var idx =
|
|
31
|
-
|
|
31
|
+
var idx = counters[key] % nodes.length;
|
|
32
|
+
counters[key]++;
|
|
33
|
+
store.set('round_robin', counters);
|
|
32
34
|
selected = nodes[idx];
|
|
33
35
|
break;
|
|
34
36
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var path = require('path');
|
|
9
9
|
var { configAdmin } = require('mm_config');
|
|
10
|
+
var { varsAdmin } = require('mm_vars');
|
|
10
11
|
|
|
11
12
|
// 脚本根目录(run_path 取 mm_config 'os' 作用域,缺省回落 process.cwd())
|
|
12
13
|
async function getDir() {
|
|
@@ -14,16 +15,14 @@ async function getDir() {
|
|
|
14
15
|
return path.join(run_path, 'script');
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
// 脚本缓存:{ script_path: { main: function, config: object, mtime: number } }
|
|
18
|
-
var script_cache = {};
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* 加载脚本
|
|
22
20
|
* @param {string} script_dir 脚本目录绝对路径
|
|
23
21
|
* @param {boolean} watch 是否启用热重载
|
|
22
|
+
* @param {object} store 变量存储实例,缓存 { main, config, mtime }
|
|
24
23
|
* @returns {object|null} { main, config } 或 null
|
|
25
24
|
*/
|
|
26
|
-
function loadScript(script_dir, watch) {
|
|
25
|
+
function loadScript(script_dir, watch, store) {
|
|
27
26
|
var index_path = path.join(script_dir, 'index.js');
|
|
28
27
|
var config_path = path.join(script_dir, 'script.json');
|
|
29
28
|
|
|
@@ -32,7 +31,7 @@ function loadScript(script_dir, watch) {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
var stat = fs.statSync(index_path);
|
|
35
|
-
var cached =
|
|
34
|
+
var cached = store.get(script_dir);
|
|
36
35
|
|
|
37
36
|
if (cached && cached.mtime === stat.mtimeMs) {
|
|
38
37
|
return cached;
|
|
@@ -55,12 +54,12 @@ function loadScript(script_dir, watch) {
|
|
|
55
54
|
config: config,
|
|
56
55
|
mtime: stat.mtimeMs
|
|
57
56
|
};
|
|
58
|
-
|
|
57
|
+
store.set(script_dir, entry);
|
|
59
58
|
|
|
60
59
|
// 启用热重载
|
|
61
60
|
if (watch) {
|
|
62
61
|
fs.watch(index_path, () => {
|
|
63
|
-
|
|
62
|
+
store.del(script_dir);
|
|
64
63
|
this.log('info', '脚本热重载: ' + config.name);
|
|
65
64
|
});
|
|
66
65
|
}
|
|
@@ -175,7 +174,7 @@ async function main(params, ctx, options) {
|
|
|
175
174
|
return ctx.output;
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
var entry = loadScript(script_dir, false);
|
|
177
|
+
var entry = loadScript(script_dir, false, varsAdmin((params && params.scope) || 'os'));
|
|
179
178
|
if (!entry) {
|
|
180
179
|
ctx.output = {
|
|
181
180
|
error: {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
const fs = require('fs');
|
|
15
15
|
const path = require('path');
|
|
16
|
+
const { constsAdmin } = require('mm_consts');
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* 创建工作流生成器实例(供程序化调用,如 CLI 工具)
|
|
@@ -763,105 +764,116 @@ async function _parseTextSpec(kernel, opts, text) {
|
|
|
763
764
|
// ==================== 聚焦式 Prompt 构建 ====================
|
|
764
765
|
|
|
765
766
|
/**
|
|
766
|
-
*
|
|
767
|
+
* 初始化中文停用词常量
|
|
768
|
+
* @returns {void}
|
|
767
769
|
*/
|
|
768
|
-
|
|
769
|
-
'
|
|
770
|
-
'
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
770
|
+
function initLlmGenConsts() {
|
|
771
|
+
const consts = constsAdmin('workflow');
|
|
772
|
+
if (!consts.has('LLM_GEN_STOP_WORDS')) {
|
|
773
|
+
/**
|
|
774
|
+
* 中文停用词列表
|
|
775
|
+
*/
|
|
776
|
+
consts.set('LLM_GEN_STOP_WORDS', [
|
|
777
|
+
'的',
|
|
778
|
+
'了',
|
|
779
|
+
'在',
|
|
780
|
+
'是',
|
|
781
|
+
'我',
|
|
782
|
+
'有',
|
|
783
|
+
'和',
|
|
784
|
+
'就',
|
|
785
|
+
'不',
|
|
786
|
+
'人',
|
|
787
|
+
'都',
|
|
788
|
+
'一',
|
|
789
|
+
'一个',
|
|
790
|
+
'上',
|
|
791
|
+
'也',
|
|
792
|
+
'很',
|
|
793
|
+
'到',
|
|
794
|
+
'说',
|
|
795
|
+
'要',
|
|
796
|
+
'去',
|
|
797
|
+
'你',
|
|
798
|
+
'会',
|
|
799
|
+
'着',
|
|
800
|
+
'没有',
|
|
801
|
+
'看',
|
|
802
|
+
'好',
|
|
803
|
+
'自己',
|
|
804
|
+
'这',
|
|
805
|
+
'他',
|
|
806
|
+
'她',
|
|
807
|
+
'它',
|
|
808
|
+
'们',
|
|
809
|
+
'那',
|
|
810
|
+
'些',
|
|
811
|
+
'所',
|
|
812
|
+
'为',
|
|
813
|
+
'所以',
|
|
814
|
+
'因为',
|
|
815
|
+
'但是',
|
|
816
|
+
'然而',
|
|
817
|
+
'虽然',
|
|
818
|
+
'如果',
|
|
819
|
+
'可以',
|
|
820
|
+
'需要',
|
|
821
|
+
'应该',
|
|
822
|
+
'能够',
|
|
823
|
+
'可能',
|
|
824
|
+
'已经',
|
|
825
|
+
'这个',
|
|
826
|
+
'那个',
|
|
827
|
+
'什么',
|
|
828
|
+
'怎么',
|
|
829
|
+
'如何',
|
|
830
|
+
'为什么',
|
|
831
|
+
'请',
|
|
832
|
+
'使用',
|
|
833
|
+
'通过',
|
|
834
|
+
'进行',
|
|
835
|
+
'实现',
|
|
836
|
+
'完成',
|
|
837
|
+
'支持',
|
|
838
|
+
'提供',
|
|
839
|
+
'包含',
|
|
840
|
+
'用于',
|
|
841
|
+
'处理',
|
|
842
|
+
'获取',
|
|
843
|
+
'设置',
|
|
844
|
+
'返回',
|
|
845
|
+
'根据',
|
|
846
|
+
'按照',
|
|
847
|
+
'将',
|
|
848
|
+
'把',
|
|
849
|
+
'被',
|
|
850
|
+
'对',
|
|
851
|
+
'从',
|
|
852
|
+
'以',
|
|
853
|
+
'或',
|
|
854
|
+
'并',
|
|
855
|
+
'及',
|
|
856
|
+
'与',
|
|
857
|
+
'且',
|
|
858
|
+
'而',
|
|
859
|
+
'则',
|
|
860
|
+
'但',
|
|
861
|
+
'只',
|
|
862
|
+
'先',
|
|
863
|
+
'后',
|
|
864
|
+
'前',
|
|
865
|
+
'再',
|
|
866
|
+
'然后',
|
|
867
|
+
'接着',
|
|
868
|
+
'最后',
|
|
869
|
+
'首先',
|
|
870
|
+
'其次',
|
|
871
|
+
'同时'
|
|
872
|
+
]);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
initLlmGenConsts();
|
|
865
877
|
|
|
866
878
|
/**
|
|
867
879
|
* 从中文文本中提取关键词
|
|
@@ -871,6 +883,7 @@ var STOP_WORDS = [
|
|
|
871
883
|
function _extractKeywords(text) {
|
|
872
884
|
if (!text) return [];
|
|
873
885
|
var keywords = [];
|
|
886
|
+
var stop_words = constsAdmin('workflow').get('LLM_GEN_STOP_WORDS');
|
|
874
887
|
|
|
875
888
|
// 提取英文单词(如 MySQL, HTTP, JSON 等)
|
|
876
889
|
var eng_matches = text.match(/[a-zA-Z][a-zA-Z0-9_]{1,11}/g);
|
|
@@ -888,7 +901,7 @@ function _extractKeywords(text) {
|
|
|
888
901
|
for (var si = 0; si < segments.length; si++) {
|
|
889
902
|
var seg = segments[si].trim();
|
|
890
903
|
if (seg.length < 2 || seg.length > 12) continue;
|
|
891
|
-
if (
|
|
904
|
+
if (stop_words.indexOf(seg) !== -1) continue;
|
|
892
905
|
if (keywords.indexOf(seg) === -1) {
|
|
893
906
|
keywords.push(seg);
|
|
894
907
|
}
|
|
@@ -897,7 +910,7 @@ function _extractKeywords(text) {
|
|
|
897
910
|
for (var win = 2; win <= 4; win++) {
|
|
898
911
|
for (var pos = 0; pos <= seg.length - win; pos++) {
|
|
899
912
|
var sub = seg.substring(pos, pos + win);
|
|
900
|
-
if (
|
|
913
|
+
if (stop_words.indexOf(sub) === -1 && keywords.indexOf(sub) === -1) {
|
|
901
914
|
keywords.push(sub);
|
|
902
915
|
}
|
|
903
916
|
}
|
|
@@ -3,33 +3,45 @@
|
|
|
3
3
|
* mysql/sqlite 委托给对应的管理器模块,mongodb/json 使用独立处理器
|
|
4
4
|
* 返回统一格式 { list, count } | { obj } | { msg, affected }
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
* mongodb/json 内部 action 映射
|
|
8
|
-
*/
|
|
9
|
-
const MONGO_ACTION_MAP = {
|
|
10
|
-
get: 'find',
|
|
11
|
-
getObj: 'findOne',
|
|
12
|
-
add: 'insert',
|
|
13
|
-
set: 'update',
|
|
14
|
-
del: 'delete',
|
|
15
|
-
count: 'count',
|
|
16
|
-
runSql: 'runSql'
|
|
17
|
-
};
|
|
6
|
+
const { constsAdmin } = require('mm_consts');
|
|
18
7
|
|
|
19
8
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* mysql/sqlite/mongodb/json 的 ORM 方法均为 add/del/set/list/getObj/count
|
|
9
|
+
* 初始化数据库动作映射常量
|
|
10
|
+
* @returns {void}
|
|
23
11
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
function initDatabaseConsts() {
|
|
13
|
+
const consts = constsAdmin('workflow');
|
|
14
|
+
if (!consts.has('DB_MONGO_ACTION_MAP')) {
|
|
15
|
+
/**
|
|
16
|
+
* mongodb/json 内部 action 映射
|
|
17
|
+
*/
|
|
18
|
+
consts.set('DB_MONGO_ACTION_MAP', {
|
|
19
|
+
get: 'find',
|
|
20
|
+
getObj: 'findOne',
|
|
21
|
+
add: 'insert',
|
|
22
|
+
set: 'update',
|
|
23
|
+
del: 'delete',
|
|
24
|
+
count: 'count',
|
|
25
|
+
runSql: 'runSql'
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* 通用动作转 ORM 原生动作映射
|
|
29
|
+
* 统一查询器收到 insert/update/delete/findOne/find 时转换为各 ORM 的原生动作
|
|
30
|
+
* mysql/sqlite/mongodb/json 的 ORM 方法均为 add/del/set/list/getObj/count
|
|
31
|
+
*/
|
|
32
|
+
consts.set('DB_ORM_ACTION_MAP', {
|
|
33
|
+
insert: 'add',
|
|
34
|
+
update: 'set',
|
|
35
|
+
delete: 'del',
|
|
36
|
+
findOne: 'getObj',
|
|
37
|
+
find: 'list',
|
|
38
|
+
count: 'count',
|
|
39
|
+
runSql: 'runSql'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
initDatabaseConsts();
|
|
33
45
|
|
|
34
46
|
module.exports = {
|
|
35
47
|
async main(params, ctx, options) {
|
|
@@ -57,8 +69,9 @@ module.exports = {
|
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
// ORM 动作映射: insert→add, update→set, delete→del, findOne→getObj, find→list
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
var orm_action_map = constsAdmin('workflow').get('DB_ORM_ACTION_MAP');
|
|
73
|
+
if (orm_action_map[action]) {
|
|
74
|
+
action = orm_action_map[action];
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
// 委托给对应分类下的具体数据库管理器模块
|
|
@@ -3,7 +3,21 @@
|
|
|
3
3
|
* 用 global.__service_registry 管理服务实例的注册、发现、心跳与过期清理
|
|
4
4
|
* 支持多实例、健康检查与按服务名/标签发现
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
6
|
+
const { constsAdmin } = require('mm_consts');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 初始化服务发现常量
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
function initDiscoveryConsts() {
|
|
13
|
+
const consts = constsAdmin('workflow');
|
|
14
|
+
if (!consts.has('DISCOVERY_DEFAULT_TTL')) {
|
|
15
|
+
// 默认存活时长(毫秒)
|
|
16
|
+
consts.set('DISCOVERY_DEFAULT_TTL', 30000);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
initDiscoveryConsts();
|
|
7
21
|
|
|
8
22
|
/**
|
|
9
23
|
* 服务注册与发现
|
|
@@ -97,7 +111,7 @@ function _register(registry, params) {
|
|
|
97
111
|
if (!service_name || !address) {
|
|
98
112
|
throw new TypeError('缺少 service_name 或 address');
|
|
99
113
|
}
|
|
100
|
-
var ttl = params.ttl ||
|
|
114
|
+
var ttl = params.ttl || constsAdmin('workflow').get('DISCOVERY_DEFAULT_TTL');
|
|
101
115
|
var instance = {
|
|
102
116
|
id: params.instance_id || service_name + ':' + address,
|
|
103
117
|
address: address,
|
|
@@ -221,7 +235,7 @@ function _heartbeat(registry, params) {
|
|
|
221
235
|
if (!service_name || !instance_id) {
|
|
222
236
|
throw new TypeError('缺少 service_name 或 instance_id');
|
|
223
237
|
}
|
|
224
|
-
var ttl = params.ttl ||
|
|
238
|
+
var ttl = params.ttl || constsAdmin('workflow').get('DISCOVERY_DEFAULT_TTL');
|
|
225
239
|
var instances = registry[service_name] || [];
|
|
226
240
|
var found = instances.find(function (item) {
|
|
227
241
|
return item.id === instance_id;
|
|
@@ -1,35 +1,47 @@
|
|
|
1
1
|
const { configAdmin } = require('mm_config');
|
|
2
2
|
|
|
3
3
|
const { jsonAdmin } = require('mm_jsondb');
|
|
4
|
+
const { constsAdmin } = require('mm_consts');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
stage: '',
|
|
12
|
-
input_preview: '',
|
|
13
|
-
status: '',
|
|
14
|
-
last_error: '',
|
|
15
|
-
timestamp: 0
|
|
16
|
-
};
|
|
6
|
+
/**
|
|
7
|
+
* 初始化记录表与样例模型常量
|
|
8
|
+
* @returns {void}
|
|
9
|
+
*/
|
|
10
|
+
function initJsonUtilConsts() {
|
|
11
|
+
const consts = constsAdmin('workflow');
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
if (!consts.has('TABLE_CALL_LOGS')) {
|
|
14
|
+
// 调用记录表与样例模型(createTable 据样例值推断字段类型)
|
|
15
|
+
consts.set('TABLE_CALL_LOGS', 'work_call_logs');
|
|
16
|
+
consts.set('MODEL_CALL_LOGS', {
|
|
17
|
+
id: 0,
|
|
18
|
+
session_id: '',
|
|
19
|
+
work_name: '',
|
|
20
|
+
stage: '',
|
|
21
|
+
input_preview: '',
|
|
22
|
+
status: '',
|
|
23
|
+
last_error: '',
|
|
24
|
+
timestamp: 0
|
|
25
|
+
});
|
|
26
|
+
// 存储记录表与样例模型
|
|
27
|
+
consts.set('TABLE_ARTIFACTS', 'work_artifacts');
|
|
28
|
+
consts.set('MODEL_ARTIFACTS', {
|
|
29
|
+
id: 0,
|
|
30
|
+
session_id: '',
|
|
31
|
+
work_name: '',
|
|
32
|
+
stage: '',
|
|
33
|
+
file_path: '',
|
|
34
|
+
valid: false,
|
|
35
|
+
error_count: 0,
|
|
36
|
+
exit_code: 0,
|
|
37
|
+
fix_rounds: 0,
|
|
38
|
+
line_count: 0,
|
|
39
|
+
timestamp: 0
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
initJsonUtilConsts();
|
|
33
45
|
|
|
34
46
|
/**
|
|
35
47
|
* 打开 mm_jsondb 数据库并返回 db 对象
|
|
@@ -109,10 +121,10 @@ function errorResult(code, message) {
|
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
module.exports = {
|
|
112
|
-
TABLE_CALL_LOGS,
|
|
113
|
-
MODEL_CALL_LOGS,
|
|
114
|
-
TABLE_ARTIFACTS,
|
|
115
|
-
MODEL_ARTIFACTS,
|
|
124
|
+
TABLE_CALL_LOGS: constsAdmin('workflow').get('TABLE_CALL_LOGS'),
|
|
125
|
+
MODEL_CALL_LOGS: constsAdmin('workflow').get('MODEL_CALL_LOGS'),
|
|
126
|
+
TABLE_ARTIFACTS: constsAdmin('workflow').get('TABLE_ARTIFACTS'),
|
|
127
|
+
MODEL_ARTIFACTS: constsAdmin('workflow').get('MODEL_ARTIFACTS'),
|
|
116
128
|
openDb,
|
|
117
129
|
ensureTable,
|
|
118
130
|
checkDup,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 审计观察器
|
|
3
|
-
*
|
|
3
|
+
* 记录操作审计日志到变量存储并输出
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var { varsAdmin } = require('mm_vars');
|
|
6
|
+
|
|
7
7
|
async function main(params, ctx, options) {
|
|
8
|
+
var store = varsAdmin((params && params.scope) || 'os');
|
|
8
9
|
var action = params.action || '';
|
|
9
10
|
var target = params.target || '';
|
|
10
11
|
var user = params.user || (ctx.meta && ctx.meta.user_id) || '';
|
|
@@ -19,8 +20,10 @@ async function main(params, ctx, options) {
|
|
|
19
20
|
details: details
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
//
|
|
23
|
+
// 追加到审计日志
|
|
24
|
+
var audit_logs = store.get('logs') || [];
|
|
23
25
|
audit_logs.push(entry);
|
|
26
|
+
store.set('logs', audit_logs);
|
|
24
27
|
|
|
25
28
|
// 控制台输出
|
|
26
29
|
this.log('info', timestamp + ' | ' + user + ' | ' + action + ' | ' + target);
|