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
|
@@ -1,7 +1,189 @@
|
|
|
1
|
-
|
|
1
|
+
const { workflowAdmin } = require('../../index.js');
|
|
2
|
+
const { constsAdmin } = require('mm_consts');
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 熔断器
|
|
5
|
+
* 实现 CLOSED -> OPEN -> HALF_OPEN 状态机,保护下游服务不被持续故障拖垮
|
|
6
|
+
* 用 global.__circuit_breakers 存储各熔断器状态
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 初始化熔断器常量
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
function initCircuitBreakerConsts() {
|
|
13
|
+
const consts = constsAdmin('workflow');
|
|
14
|
+
if (!consts.has('CB_STATE_CLOSED')) {
|
|
15
|
+
consts.set('CB_STATE_CLOSED', 'closed');
|
|
16
|
+
consts.set('CB_STATE_OPEN', 'open');
|
|
17
|
+
consts.set('CB_STATE_HALF_OPEN', 'half_open');
|
|
18
|
+
consts.set('CB_DEFAULT_FAILURE_THRESHOLD', 5);
|
|
19
|
+
consts.set('CB_DEFAULT_RESET_TIMEOUT', 30000);
|
|
20
|
+
consts.set('CB_DEFAULT_SUCCESS_THRESHOLD', 2);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
initCircuitBreakerConsts();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 熔断检查与状态记录
|
|
28
|
+
* @param {object} ctx 上下文对象
|
|
29
|
+
* @param {object} params 步骤参数
|
|
30
|
+
* @returns {object} 处理结果或错误信息
|
|
31
|
+
*/
|
|
32
|
+
async function main(params, ctx, options) {
|
|
33
|
+
const admin = workflowAdmin((params && params.scope) || 'os');
|
|
34
|
+
var action = params.action || 'check';
|
|
35
|
+
if (!global.__circuit_breakers) {
|
|
36
|
+
global.__circuit_breakers = {};
|
|
37
|
+
}
|
|
38
|
+
var result = null;
|
|
39
|
+
if (action === 'reset') {
|
|
40
|
+
result = _reset(global.__circuit_breakers, params);
|
|
41
|
+
} else if (action === 'state') {
|
|
42
|
+
result = _state(global.__circuit_breakers, params);
|
|
43
|
+
} else {
|
|
44
|
+
result = _check(global.__circuit_breakers, params);
|
|
45
|
+
}
|
|
46
|
+
ctx.output = result;
|
|
47
|
+
return ctx.output;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 获取熔断器状态对象
|
|
52
|
+
* @param {object} breakers 熔断器注册表
|
|
53
|
+
* @param {object} params 步骤参数
|
|
54
|
+
* @returns {object} 熔断器状态
|
|
55
|
+
*/
|
|
56
|
+
function _getBreaker(breakers, params) {
|
|
57
|
+
var consts = constsAdmin('workflow');
|
|
58
|
+
var key = params.key || 'default';
|
|
59
|
+
var breaker = breakers[key];
|
|
60
|
+
if (!breaker) {
|
|
61
|
+
breaker = {
|
|
62
|
+
state: consts.get('CB_STATE_CLOSED'),
|
|
63
|
+
failures: 0,
|
|
64
|
+
successes: 0,
|
|
65
|
+
opened_at: 0,
|
|
66
|
+
failure_threshold: params.failure_threshold || consts.get('CB_DEFAULT_FAILURE_THRESHOLD'),
|
|
67
|
+
reset_timeout: params.reset_timeout || consts.get('CB_DEFAULT_RESET_TIMEOUT'),
|
|
68
|
+
success_threshold: params.success_threshold || consts.get('CB_DEFAULT_SUCCESS_THRESHOLD')
|
|
69
|
+
};
|
|
70
|
+
breakers[key] = breaker;
|
|
71
|
+
}
|
|
72
|
+
return breaker;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 检查并记录熔断状态
|
|
77
|
+
* @param {object} breakers 熔断器注册表
|
|
78
|
+
* @param {object} params 步骤参数
|
|
79
|
+
* @returns {object} 检查结果
|
|
80
|
+
*/
|
|
81
|
+
function _check(breakers, params) {
|
|
82
|
+
var consts = constsAdmin('workflow');
|
|
83
|
+
var state_open = consts.get('CB_STATE_OPEN');
|
|
84
|
+
var breaker = _getBreaker(breakers, params);
|
|
85
|
+
var now = Date.now();
|
|
86
|
+
if (breaker.state === state_open && now - breaker.opened_at >= breaker.reset_timeout) {
|
|
87
|
+
breaker.state = consts.get('CB_STATE_HALF_OPEN');
|
|
88
|
+
breaker.successes = 0;
|
|
89
|
+
}
|
|
90
|
+
var allowed = breaker.state !== state_open;
|
|
91
|
+
if (params.success === true || params.success === false) {
|
|
92
|
+
_record(breaker, params.success);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
key: params.key || 'default',
|
|
96
|
+
allowed: allowed,
|
|
97
|
+
state: breaker.state,
|
|
98
|
+
tip: allowed ? '通过熔断检查' : '熔断器已打开,拒绝请求',
|
|
99
|
+
failures: breaker.failures,
|
|
100
|
+
successes: breaker.successes
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 记录调用结果并更新状态
|
|
106
|
+
* @param {object} breaker 熔断器状态
|
|
107
|
+
* @param {boolean} success 是否成功
|
|
108
|
+
*/
|
|
109
|
+
function _record(breaker, success) {
|
|
110
|
+
var consts = constsAdmin('workflow');
|
|
111
|
+
var state_closed = consts.get('CB_STATE_CLOSED');
|
|
112
|
+
var state_half_open = consts.get('CB_STATE_HALF_OPEN');
|
|
113
|
+
if (success) {
|
|
114
|
+
if (breaker.state === state_half_open) {
|
|
115
|
+
breaker.successes++;
|
|
116
|
+
if (breaker.successes >= breaker.success_threshold) {
|
|
117
|
+
_close(breaker);
|
|
118
|
+
}
|
|
119
|
+
} else if (breaker.state === state_closed) {
|
|
120
|
+
breaker.failures = 0;
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (breaker.state === state_closed) {
|
|
125
|
+
breaker.failures++;
|
|
126
|
+
if (breaker.failures >= breaker.failure_threshold) {
|
|
127
|
+
_open(breaker);
|
|
128
|
+
}
|
|
129
|
+
} else if (breaker.state === state_half_open) {
|
|
130
|
+
_open(breaker);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 打开熔断器
|
|
136
|
+
* @param {object} breaker 熔断器状态
|
|
137
|
+
*/
|
|
138
|
+
function _open(breaker) {
|
|
139
|
+
breaker.state = constsAdmin('workflow').get('CB_STATE_OPEN');
|
|
140
|
+
breaker.opened_at = Date.now();
|
|
141
|
+
breaker.failures = 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 关闭熔断器
|
|
146
|
+
* @param {object} breaker 熔断器状态
|
|
147
|
+
*/
|
|
148
|
+
function _close(breaker) {
|
|
149
|
+
breaker.state = constsAdmin('workflow').get('CB_STATE_CLOSED');
|
|
150
|
+
breaker.failures = 0;
|
|
151
|
+
breaker.successes = 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 手动重置熔断器
|
|
156
|
+
* @param {object} breakers 熔断器注册表
|
|
157
|
+
* @param {object} params 步骤参数
|
|
158
|
+
* @returns {object} 重置结果
|
|
159
|
+
*/
|
|
160
|
+
function _reset(breakers, params) {
|
|
161
|
+
var key = params.key || 'default';
|
|
162
|
+
delete breakers[key];
|
|
163
|
+
return {
|
|
164
|
+
action: 'reset',
|
|
165
|
+
key: key,
|
|
166
|
+
state: constsAdmin('workflow').get('CB_STATE_CLOSED'),
|
|
167
|
+
msg: '熔断器已重置'
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 查询熔断器状态
|
|
173
|
+
* @param {object} breakers 熔断器注册表
|
|
174
|
+
* @param {object} params 步骤参数
|
|
175
|
+
* @returns {object} 状态信息
|
|
176
|
+
*/
|
|
177
|
+
function _state(breakers, params) {
|
|
178
|
+
var breaker = _getBreaker(breakers, params);
|
|
179
|
+
return {
|
|
180
|
+
action: 'state',
|
|
181
|
+
key: params.key || 'default',
|
|
182
|
+
state: breaker.state,
|
|
183
|
+
failures: breaker.failures,
|
|
184
|
+
successes: breaker.successes,
|
|
185
|
+
opened_at: breaker.opened_at
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
module.exports = { main };
|
package/tool/ip_block/index.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
const { workflowAdmin } = require('../../index.js');
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* IP黑名单过滤器 - 过滤黑名单IP
|
|
4
|
+
* @param {object} ctx 上下文对象
|
|
5
|
+
* @param {object} params 步骤参数
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
async function main(params, ctx, options) {
|
|
8
|
+
const admin = workflowAdmin((params && params.scope) || 'os');
|
|
9
|
+
var input = ctx.input || {};
|
|
10
|
+
var ip = input.ip || input.remote_ip || '';
|
|
11
|
+
var blacklist = params.blacklist || [];
|
|
12
|
+
var blocked = blacklist.indexOf(ip) !== -1;
|
|
13
|
+
ctx.output = {
|
|
14
|
+
blocked: blocked,
|
|
15
|
+
tip: blocked ? 'IP ' + ip + ' 在黑名单中' : 'IP 放行',
|
|
16
|
+
ip: ip,
|
|
17
|
+
reason: blocked ? 'IP ' + ip + ' 在黑名单中' : 'IP 放行'
|
|
18
|
+
};
|
|
19
|
+
return ctx.output;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { main };
|
package/tool/rate_limit/index.js
CHANGED
|
@@ -1,7 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
const { workflowAdmin } = require('../../index.js');
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* 其它模块可直接 require('mm_workflow').tools.rate_limit 复用。
|
|
3
|
+
* 频率限制过滤器
|
|
4
|
+
* 用 global.__rate_limits 存储滑动窗口记录
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
async function main(params, ctx, options) {
|
|
7
|
+
const admin = workflowAdmin((params && params.scope) || 'os');
|
|
8
|
+
if (!global.__rate_limits) {
|
|
9
|
+
global.__rate_limits = {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var key = params.key || 'default';
|
|
13
|
+
var max_requests = params.max_requests || 100;
|
|
14
|
+
var window_ms = params.window_ms || 60000;
|
|
15
|
+
|
|
16
|
+
if (!global.__rate_limits[key]) {
|
|
17
|
+
global.__rate_limits[key] = { timestamps: [] };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var record = global.__rate_limits[key];
|
|
21
|
+
var now = Date.now();
|
|
22
|
+
var window_start = now - window_ms;
|
|
23
|
+
|
|
24
|
+
var kept = [];
|
|
25
|
+
for (var i = 0; i < record.timestamps.length; i++) {
|
|
26
|
+
if (record.timestamps[i] > window_start) {
|
|
27
|
+
kept.push(record.timestamps[i]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
record.timestamps = kept;
|
|
31
|
+
|
|
32
|
+
var current_count = record.timestamps.length;
|
|
33
|
+
var allowed = current_count < max_requests;
|
|
34
|
+
|
|
35
|
+
if (allowed) {
|
|
36
|
+
record.timestamps.push(now);
|
|
37
|
+
current_count = record.timestamps.length;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ctx.output = {
|
|
41
|
+
blocked: !allowed,
|
|
42
|
+
tip: allowed ? '通过频率检查' : '请求频率超限',
|
|
43
|
+
key: key,
|
|
44
|
+
limit: max_requests,
|
|
45
|
+
window: window_ms,
|
|
46
|
+
count: current_count
|
|
47
|
+
};
|
|
48
|
+
return ctx.output;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = { main };
|
package/tool/sensitive/index.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
const { workflowAdmin } = require('../../index.js');
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* 敏感词过滤器 - 敏感词过滤
|
|
4
|
+
* @param {object} ctx 上下文对象
|
|
5
|
+
* @param {object} params 步骤参数
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
async function main(params, ctx, options) {
|
|
8
|
+
const admin = workflowAdmin((params && params.scope) || 'os');
|
|
9
|
+
var input = ctx.input || {};
|
|
10
|
+
var text = input.text || input.content || '';
|
|
11
|
+
var sensitive_words = params.sensitiveWords || ['敏感词1', '敏感词2'];
|
|
12
|
+
var replaced = String(text);
|
|
13
|
+
var matched = [];
|
|
14
|
+
for (var i = 0; i < sensitive_words.length; i++) {
|
|
15
|
+
var word = sensitive_words[i];
|
|
16
|
+
if (replaced.indexOf(word) !== -1) {
|
|
17
|
+
matched.push(word);
|
|
18
|
+
var reg = new RegExp(word, 'g');
|
|
19
|
+
replaced = replaced.replace(reg, '***');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
ctx.output = {
|
|
23
|
+
blocked: matched.length > 0,
|
|
24
|
+
tip: matched.length > 0 ? '发现 ' + matched.length + ' 个敏感词' : '未发现敏感词',
|
|
25
|
+
matched_words: matched,
|
|
26
|
+
replaced_text: replaced
|
|
27
|
+
};
|
|
28
|
+
return ctx.output;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { main };
|
package/tool/spam/index.js
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
const { workflowAdmin } = require('../../index.js');
|
|
2
|
+
var path = require('path');
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* 垃圾信息过滤器 - 垃圾信息过滤
|
|
6
|
+
* @param {object} ctx 上下文对象
|
|
7
|
+
* @param {object} params 步骤参数
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
async function main(params, ctx, options) {
|
|
10
|
+
const admin = workflowAdmin((params && params.scope) || 'os');
|
|
11
|
+
var input = ctx.input || {};
|
|
12
|
+
var text = input.text || input.content || '';
|
|
13
|
+
var spam_keywords = params.spamKeywords || ['广告', '推广', '加V'];
|
|
14
|
+
var is_spam = false;
|
|
15
|
+
var matched_keywords = [];
|
|
16
|
+
for (var i = 0; i < spam_keywords.length; i++) {
|
|
17
|
+
var keyword = spam_keywords[i];
|
|
18
|
+
if (String(text).indexOf(keyword) !== -1) {
|
|
19
|
+
is_spam = true;
|
|
20
|
+
matched_keywords.push(keyword);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
ctx.output = {
|
|
24
|
+
blocked: is_spam,
|
|
25
|
+
tip: is_spam ? '判定为垃圾内容' : '内容正常',
|
|
26
|
+
matched_words: matched_keywords,
|
|
27
|
+
content: text
|
|
28
|
+
};
|
|
29
|
+
return ctx.output;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { main };
|
package/tool/sql_inject/index.js
CHANGED
|
@@ -1,7 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
const { workflowAdmin } = require('../../index.js');
|
|
2
|
+
var path = require('path');
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* SQL注入检测过滤器 - SQL注入检测过滤
|
|
6
|
+
* @param {object} ctx 上下文对象
|
|
7
|
+
* @param {object} params 步骤参数
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
async function main(params, ctx, options) {
|
|
10
|
+
const admin = workflowAdmin((params && params.scope) || 'os');
|
|
11
|
+
var input = ctx.input || {};
|
|
12
|
+
var text = input.text || input.content || input.value || '';
|
|
13
|
+
var sql_patterns = [
|
|
14
|
+
/'/g,
|
|
15
|
+
/--/g,
|
|
16
|
+
/;\s*$/g,
|
|
17
|
+
/\/\*.*\*\//g,
|
|
18
|
+
/(\bSELECT\b|\bDROP\b|\bDELETE\b|\bINSERT\b|\bUPDATE\b|\bUNION\b)/gi
|
|
19
|
+
];
|
|
20
|
+
var has_sql_inject = false;
|
|
21
|
+
var filtered = String(text);
|
|
22
|
+
for (var i = 0; i < sql_patterns.length; i++) {
|
|
23
|
+
if (sql_patterns[i].test(filtered)) {
|
|
24
|
+
has_sql_inject = true;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
ctx.output = {
|
|
29
|
+
blocked: has_sql_inject,
|
|
30
|
+
tip: has_sql_inject ? '检测到 SQL 注入' : '未检测到注入',
|
|
31
|
+
patterns_matched: sql_patterns.length,
|
|
32
|
+
input_length: String(text).length
|
|
33
|
+
};
|
|
34
|
+
return ctx.output;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { main };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* workflow_admin —— 工作流引擎实例管理工具
|
|
4
|
+
* 管理 mm_workflow 的实例池,不执行规则拦截。
|
|
5
|
+
*/
|
|
6
|
+
const { admin } = require('../../index.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 管理工作流引擎实例池
|
|
10
|
+
* @param {object} params 参数:action/scope
|
|
11
|
+
* @param {object} ctx 执行上下文
|
|
12
|
+
* @returns {Promise<object>} 执行结果
|
|
13
|
+
*/
|
|
14
|
+
async function main(params, ctx, options) {
|
|
15
|
+
void options;
|
|
16
|
+
const p = params || {};
|
|
17
|
+
const action = p.action || 'list';
|
|
18
|
+
const scope = p.scope || 'os';
|
|
19
|
+
const done = (data) => {
|
|
20
|
+
if (ctx) ctx.output = data;
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
if (action === 'list') {
|
|
26
|
+
const scopes = [...admin.keys()];
|
|
27
|
+
return done({ code: 0, msg: '获取成功', action, count: scopes.length, scopes });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (action === 'inspect') {
|
|
31
|
+
const exists = admin.has(scope);
|
|
32
|
+
if (!exists) {
|
|
33
|
+
return done({ code: 0, msg: '实例不存在', action, scope, exists: false });
|
|
34
|
+
}
|
|
35
|
+
const instance = admin.get(scope);
|
|
36
|
+
return done({
|
|
37
|
+
code: 0,
|
|
38
|
+
msg: '获取成功',
|
|
39
|
+
action,
|
|
40
|
+
scope,
|
|
41
|
+
exists: true,
|
|
42
|
+
config: instance && instance.config ? instance.config : null
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (action === 'del') {
|
|
47
|
+
return done({ code: 0, msg: '删除成功', action, scope, ok: admin.del(scope) });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (action === 'clear') {
|
|
51
|
+
admin.clear();
|
|
52
|
+
return done({ code: 0, msg: '实例池已清空', action });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return done({ code: 10001, msg: '不支持的操作: ' + action });
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return done({
|
|
58
|
+
code: 10000,
|
|
59
|
+
msg: '执行失败:' + error.message,
|
|
60
|
+
error: { name: error.name, message: error.message }
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = { main };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "workflow_admin",
|
|
3
|
+
"title": "工作流引擎实例管理",
|
|
4
|
+
"description": "管理 mm_workflow 的实例池:列出作用域、查看实例配置、删除实例或清空实例池。适用场景:排查规则未生效、切换规则配置后释放旧实例、退出前清理。",
|
|
5
|
+
"category": "工作流",
|
|
6
|
+
"group": "workflow",
|
|
7
|
+
"type": "function",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"params": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"action": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "操作类型: list 实例列表 / inspect 查看实例 / del 删除实例 / clear 清空实例池",
|
|
15
|
+
"enum": ["list", "inspect", "del", "clear"],
|
|
16
|
+
"default": "list"
|
|
17
|
+
},
|
|
18
|
+
"scope": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "实例作用域(inspect/del 使用),缺省 os",
|
|
21
|
+
"default": "os"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": ["action"]
|
|
25
|
+
},
|
|
26
|
+
"returns": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"code": { "type": "number", "description": "0 表示成功" },
|
|
30
|
+
"msg": { "type": "string", "description": "结果描述" },
|
|
31
|
+
"count": { "type": "number", "description": "实例数量" },
|
|
32
|
+
"scopes": { "type": "array", "items": { "type": "string" }, "description": "作用域列表" },
|
|
33
|
+
"exists": { "type": "boolean", "description": "实例是否存在" },
|
|
34
|
+
"config": { "type": "object", "description": "实例配置" },
|
|
35
|
+
"ok": { "type": "boolean", "description": "操作是否成功" },
|
|
36
|
+
"error": { "type": "object", "description": "异常信息" }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"handler": "manager"
|
|
40
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* workflow_run —— 工作流执行工具
|
|
4
|
+
* 调用 mm_workflow 引擎实例执行工作流蓝图、恢复挂起会话或查询可用算子。
|
|
5
|
+
*/
|
|
6
|
+
const { workflowAdmin } = require('../../index.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 汇总算子分类与模块名
|
|
10
|
+
* @param {object} operators 算子集合 { 分类名: { 模块名: 模块实例 } }
|
|
11
|
+
* @returns {object} 分类到模块名列表的映射
|
|
12
|
+
*/
|
|
13
|
+
function _briefOperators(operators) {
|
|
14
|
+
const detail = {};
|
|
15
|
+
const source = operators || {};
|
|
16
|
+
for (const category of Object.keys(source)) {
|
|
17
|
+
detail[category] = Object.keys(source[category] || {});
|
|
18
|
+
}
|
|
19
|
+
return detail;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 执行工作流、恢复挂起会话或查询算子
|
|
24
|
+
* @param {object} params 参数:action/scope/workflow/input/meta/session_id/response
|
|
25
|
+
* @param {object} ctx 执行上下文
|
|
26
|
+
* @returns {Promise<object>} 执行结果
|
|
27
|
+
*/
|
|
28
|
+
async function main(params, ctx, options) {
|
|
29
|
+
void options;
|
|
30
|
+
const p = params || {};
|
|
31
|
+
const action = p.action || 'run';
|
|
32
|
+
const done = (data) => {
|
|
33
|
+
if (ctx) ctx.output = data;
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const engine = workflowAdmin(p.scope || 'os');
|
|
39
|
+
|
|
40
|
+
if (action === 'run') {
|
|
41
|
+
if (!p.workflow || typeof p.workflow !== 'object') {
|
|
42
|
+
throw new TypeError('workflow 必须是对象');
|
|
43
|
+
}
|
|
44
|
+
const result = await engine.run(p.workflow, {
|
|
45
|
+
input: p.input || {},
|
|
46
|
+
output: {},
|
|
47
|
+
meta: p.meta || { timestamp: new Date().toISOString() }
|
|
48
|
+
});
|
|
49
|
+
return done({ code: 0, msg: '执行完成', action, result });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (action === 'resume') {
|
|
53
|
+
if (!p.session_id) throw new TypeError('session_id 不能为空');
|
|
54
|
+
const response = p.response === undefined ? null : p.response;
|
|
55
|
+
const result = await engine.resume(p.session_id, response);
|
|
56
|
+
return done({ code: 0, msg: '执行完成', action, session_id: p.session_id, result });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (action === 'operators') {
|
|
60
|
+
const operators = (typeof engine.getOperators === 'function' && engine.getOperators()) || {};
|
|
61
|
+
const categories = Object.keys(operators);
|
|
62
|
+
return done({
|
|
63
|
+
code: 0,
|
|
64
|
+
msg: '获取成功',
|
|
65
|
+
action,
|
|
66
|
+
count: categories.length,
|
|
67
|
+
operators: _briefOperators(operators)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return done({ code: 10001, msg: '不支持的操作: ' + action });
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return done({
|
|
74
|
+
code: 10000,
|
|
75
|
+
msg: '执行失败:' + error.message,
|
|
76
|
+
error: { name: error.name, message: error.message }
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = { main };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "workflow_run",
|
|
3
|
+
"title": "工作流执行",
|
|
4
|
+
"description": "调用 mm_workflow 引擎实例执行工作流蓝图、恢复挂起的工作流会话或查询当前可用算子。适用场景:运行工作流、处理需人工确认后的 yield 恢复、核对已装配的算子分类。工作流提示:run 需传 workflow 对象(含 steps),resume 需传 session_id 与 response,operators 用于自省。",
|
|
5
|
+
"category": "工作流",
|
|
6
|
+
"group": "workflow",
|
|
7
|
+
"type": "core",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"params": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"action": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "操作类型: run 执行 / resume 恢复挂起 / operators 查询算子",
|
|
15
|
+
"enum": ["run", "resume", "operators"],
|
|
16
|
+
"default": "run"
|
|
17
|
+
},
|
|
18
|
+
"workflow": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"description": "工作流蓝图对象,run 使用,必须包含 steps 数组"
|
|
21
|
+
},
|
|
22
|
+
"input": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"description": "工作流入参,run 使用"
|
|
25
|
+
},
|
|
26
|
+
"meta": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"description": "工作流元数据,run 使用,缺省自动生成"
|
|
29
|
+
},
|
|
30
|
+
"session_id": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "挂起会话 ID,resume 必填"
|
|
33
|
+
},
|
|
34
|
+
"response": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "恢复时的用户回复数据,resume 使用"
|
|
37
|
+
},
|
|
38
|
+
"scope": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "引擎实例作用域,缺省 os",
|
|
41
|
+
"default": "os"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": ["action"]
|
|
45
|
+
},
|
|
46
|
+
"returns": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"code": { "type": "number", "description": "0 表示成功" },
|
|
50
|
+
"msg": { "type": "string", "description": "结果描述" },
|
|
51
|
+
"action": { "type": "string", "description": "执行的操作类型" },
|
|
52
|
+
"result": { "type": "object", "description": "run/resume 的执行结果" },
|
|
53
|
+
"session_id": { "type": "string", "description": "恢复的会话 ID" },
|
|
54
|
+
"count": { "type": "number", "description": "算子分类数量" },
|
|
55
|
+
"operators": { "type": "object", "description": "算子分类与模块名映射" },
|
|
56
|
+
"error": { "type": "object", "description": "异常对象 { name, message }" }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"handler": "manager"
|
|
60
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ok_wf",
|
|
3
|
-
"title": "测试工作流",
|
|
4
|
-
"description": "",
|
|
5
|
-
"group": "wftest_1789472356864",
|
|
6
|
-
"version": "1.0",
|
|
7
|
-
"steps": [
|
|
8
|
-
{
|
|
9
|
-
"id": "s1",
|
|
10
|
-
"operator": "calculator",
|
|
11
|
-
"handler": "sum",
|
|
12
|
-
"params": {
|
|
13
|
-
"values": [
|
|
14
|
-
1,
|
|
15
|
-
2
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|