digitalsee-ai-flow-cli 0.9.24-beta → 0.9.29-beta
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/README.md +146 -2
- package/dist/api/client.js +9 -0
- package/dist/api/flow.js +4 -1
- package/dist/api/node.js +78 -7
- package/dist/api/trigger.js +242 -0
- package/dist/commands/flow/account.js +439 -1
- package/dist/commands/flow/analyze.js +10 -2
- package/dist/commands/flow/export.js +29 -4
- package/dist/commands/flow/helpers.js +439 -53
- package/dist/commands/flow/node.js +290 -32
- package/dist/commands/flow/offline.js +3 -2
- package/dist/commands/flow/trigger.js +190 -0
- package/dist/commands/flow/validate.js +57 -0
- package/dist/commands/flow/variables.js +1 -0
- package/dist/commands/flow.js +2 -0
- package/dist/constants/node-type.js +23 -0
- package/dist/services/classicNodePorts.js +167 -368
- package/dist/services/fieldTypeRegistry.js +496 -0
- package/dist/services/flowAnalyzer.js +8 -1
- package/dist/services/flowValidator.js +145 -0
- package/dist/services/portValidator.js +76 -70
- package/dist/services/skillGenerator.js +236 -194
- package/dist/services/triggerConfig.js +252 -0
- package/dist/utils/conditionRules.js +128 -0
- package/dist/utils/format.js +268 -168
- package/dist/utils/nodeEnvelope.js +128 -0
- package/dist/utils/switchBranch.js +83 -0
- package/dist/utils/updateCheck.js +50 -6
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBMIT_ENVELOPE_KEYS = void 0;
|
|
4
|
+
exports.normalizeProxyId = normalizeProxyId;
|
|
5
|
+
exports.getProxyFieldKey = getProxyFieldKey;
|
|
6
|
+
exports.extractProxyField = extractProxyField;
|
|
7
|
+
exports.unwrapNodePackagePropertiesEnvelope = unwrapNodePackagePropertiesEnvelope;
|
|
8
|
+
exports.unwrapNodeDetailEnvelope = unwrapNodeDetailEnvelope;
|
|
9
|
+
/**
|
|
10
|
+
* NodePackage 提交信封契约(对齐 rcs 侧 submitPayload.ts / proxyField.ts)。
|
|
11
|
+
*
|
|
12
|
+
* NodePackage 节点提交体是「信封 + properties」两层结构:
|
|
13
|
+
* - 业务配置放在 `properties` 中
|
|
14
|
+
* - 宿主能力字段提升到信封顶层:`account_id`(账号)、`proxy_id`(代理网关,
|
|
15
|
+
* 字符串,`'0'`=不使用)、`mcp_tool_description`(MCP 工具描述)
|
|
16
|
+
* - `flow_id` / `position` / `action_id` / `action_key` / `action_ver`
|
|
17
|
+
* 由 CLI 组装,同样位于信封顶层
|
|
18
|
+
*
|
|
19
|
+
* PROXY 类型字段(node_schema.input_fields 中 type=PROXY)是工作流宿主
|
|
20
|
+
* 能力,不属于业务参数:提交时必须从 properties 中移除并提升为顶层
|
|
21
|
+
* `proxy_id`,写在 properties 里服务端不会读取。
|
|
22
|
+
*/
|
|
23
|
+
exports.SUBMIT_ENVELOPE_KEYS = new Set([
|
|
24
|
+
'flow_id',
|
|
25
|
+
'properties',
|
|
26
|
+
'position',
|
|
27
|
+
'action_id',
|
|
28
|
+
'account_id',
|
|
29
|
+
'proxy_id',
|
|
30
|
+
'mcp_tool_description',
|
|
31
|
+
'action_key',
|
|
32
|
+
'action_ver',
|
|
33
|
+
]);
|
|
34
|
+
/** rcs 读取侧解包时认可的元数据键(含画布内部标记 isNodePackage) */
|
|
35
|
+
const READ_ENVELOPE_KEYS = new Set([
|
|
36
|
+
'properties',
|
|
37
|
+
'params',
|
|
38
|
+
'account_id',
|
|
39
|
+
'proxy_id',
|
|
40
|
+
'mcp_tool_description',
|
|
41
|
+
'isNodePackage',
|
|
42
|
+
]);
|
|
43
|
+
const READ_ENVELOPE_META_KEYS = ['account_id', 'proxy_id', 'mcp_tool_description', 'isNodePackage'];
|
|
44
|
+
function isRecord(value) {
|
|
45
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 将代理网关 ID 归一化为 ACM 接口使用的字符串('0' = 不使用)。
|
|
49
|
+
* 对齐 rcs proxyField.ts normalizeProxyId。
|
|
50
|
+
*/
|
|
51
|
+
function normalizeProxyId(value) {
|
|
52
|
+
if (value === null || value === undefined || value === '') {
|
|
53
|
+
return '0';
|
|
54
|
+
}
|
|
55
|
+
return String(value);
|
|
56
|
+
}
|
|
57
|
+
/** 查找 node_schema.input_fields 中由宿主处理的 PROXY 类型字段 key。 */
|
|
58
|
+
function getProxyFieldKey(inputFields) {
|
|
59
|
+
return inputFields?.find((f) => String(f.type || '').toUpperCase() === 'PROXY')?.key;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 从 properties 中提取 PROXY 字段并提升为信封顶层 proxy_id。
|
|
63
|
+
*
|
|
64
|
+
* 返回新的 properties(不含 PROXY 键)与归一化后的 proxyId;
|
|
65
|
+
* schema 无 PROXY 字段时原样返回。
|
|
66
|
+
*/
|
|
67
|
+
function extractProxyField(properties, inputFields) {
|
|
68
|
+
const proxyFieldKey = getProxyFieldKey(inputFields);
|
|
69
|
+
if (!proxyFieldKey || !(proxyFieldKey in properties)) {
|
|
70
|
+
return { properties };
|
|
71
|
+
}
|
|
72
|
+
const next = { ...properties };
|
|
73
|
+
const proxyId = normalizeProxyId(next[proxyFieldKey]);
|
|
74
|
+
delete next[proxyFieldKey];
|
|
75
|
+
return { properties: next, proxyId };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 解包 NodePackage properties 信封(对齐 rcs unwrapNodePackagePropertiesEnvelope 语义)。
|
|
79
|
+
*
|
|
80
|
+
* 读取侧 node.properties 可能是意外包裹后的信封:
|
|
81
|
+
* `{ properties: {...业务字段}, account_id, proxy_id, mcp_tool_description }`。
|
|
82
|
+
* 当对象仅含信封键、或含任一信封元数据键时,剥出内层业务 properties;
|
|
83
|
+
* 普通恰好含 `properties` 字段的表单值不会被误剥。
|
|
84
|
+
*/
|
|
85
|
+
function unwrapNodePackagePropertiesEnvelope(value) {
|
|
86
|
+
if (!isRecord(value)) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
const nestedProperties = value.properties;
|
|
90
|
+
const nestedParams = value.params;
|
|
91
|
+
const nested = isRecord(nestedProperties)
|
|
92
|
+
? nestedProperties
|
|
93
|
+
: isRecord(nestedParams)
|
|
94
|
+
? nestedParams
|
|
95
|
+
: undefined;
|
|
96
|
+
if (!nested) {
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
const keys = Object.keys(value);
|
|
100
|
+
const hasOnlyEnvelopeKeys = keys.every((key) => READ_ENVELOPE_KEYS.has(key));
|
|
101
|
+
const hasEnvelopeMeta = READ_ENVELOPE_META_KEYS.some((key) => Object.prototype.hasOwnProperty.call(value, key));
|
|
102
|
+
return hasOnlyEnvelopeKeys || hasEnvelopeMeta ? nested : value;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 解包节点详情的 properties 信封并识别宿主元数据。
|
|
106
|
+
*
|
|
107
|
+
* - 先经 unwrapNodePackagePropertiesEnvelope 剥出内层业务字段
|
|
108
|
+
* - 信封顶层的 proxy_id / mcp_tool_description 单独提取,
|
|
109
|
+
* proxy_id 经 normalizeProxyId 归一化('0'=不使用)
|
|
110
|
+
*/
|
|
111
|
+
function unwrapNodeDetailEnvelope(nodeDetail) {
|
|
112
|
+
const raw = isRecord(nodeDetail?.properties) ? nodeDetail.properties : {};
|
|
113
|
+
const unwrapped = unwrapNodePackagePropertiesEnvelope(raw);
|
|
114
|
+
const result = {
|
|
115
|
+
properties: isRecord(unwrapped) ? { ...unwrapped } : {},
|
|
116
|
+
};
|
|
117
|
+
if (raw !== unwrapped) {
|
|
118
|
+
if ('proxy_id' in raw) {
|
|
119
|
+
result.proxyId = normalizeProxyId(raw.proxy_id);
|
|
120
|
+
}
|
|
121
|
+
const mcpDesc = raw.mcp_tool_description;
|
|
122
|
+
if (typeof mcpDesc === 'string' && mcpDesc) {
|
|
123
|
+
result.mcpToolDescription = mcpDesc;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=nodeEnvelope.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_BRANCH_HANDLE = void 0;
|
|
4
|
+
exports.isRoutableBranchId = isRoutableBranchId;
|
|
5
|
+
exports.generateBranchId = generateBranchId;
|
|
6
|
+
exports.normalizeNullConditionValue = normalizeNullConditionValue;
|
|
7
|
+
exports.normalizeSwitchBranchNullConditionValues = normalizeSwitchBranchNullConditionValues;
|
|
8
|
+
const nodeEnvelope_1 = require("@/utils/nodeEnvelope");
|
|
9
|
+
/** rcs 固定的 Switch 默认分支端口名(switchNodePackage.ts DEFAULT_BRANCH_HANDLE) */
|
|
10
|
+
exports.DEFAULT_BRANCH_HANDLE = 'default-branch';
|
|
11
|
+
const NULL_CONDITION_OPERATORS = new Set(['is_null', 'is_not_null']);
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 判断分支 id 是否可路由:以 "branch" 开头、非 default-branch、未重复。
|
|
17
|
+
* 对齐 rcs switchNodePackage.ts hasRoutableId 语义。
|
|
18
|
+
*/
|
|
19
|
+
function isRoutableBranchId(id, usedIds) {
|
|
20
|
+
return id.startsWith('branch') && id !== exports.DEFAULT_BRANCH_HANDLE && !usedIds.has(id);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 生成符合 rcs createUniqueBranchId 约定的分支 id:branch_<ts>_<rand36>。
|
|
24
|
+
*/
|
|
25
|
+
function generateBranchId(usedIds = []) {
|
|
26
|
+
const used = new Set(usedIds);
|
|
27
|
+
let id = '';
|
|
28
|
+
do {
|
|
29
|
+
id = `branch_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
30
|
+
} while (used.has(id));
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 对齐 rcs normalizeNullConditionCompareValue:
|
|
35
|
+
* is_null / is_not_null 算子的 value 强制归一为空字符串。
|
|
36
|
+
*/
|
|
37
|
+
function normalizeNullConditionValue(operator, value) {
|
|
38
|
+
return typeof operator === 'string' && NULL_CONDITION_OPERATORS.has(operator) ? '' : value;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 就地归一 SwitchNode branches 中 is_null / is_not_null 条件的 value 为空字符串。
|
|
42
|
+
*
|
|
43
|
+
* 对齐 rcs SwitchNodeConfig 提交前归一(normalizeNullConditionCompareValue),
|
|
44
|
+
* 兼容 properties 信封包裹形态({ properties: { branches }, account_id, ... })。
|
|
45
|
+
*/
|
|
46
|
+
function normalizeSwitchBranchNullConditionValues(data) {
|
|
47
|
+
const paths = [];
|
|
48
|
+
const props = isRecord(data.properties) ? data.properties : undefined;
|
|
49
|
+
if (!props)
|
|
50
|
+
return { changed: false, paths };
|
|
51
|
+
let container;
|
|
52
|
+
if (Array.isArray(props.branches)) {
|
|
53
|
+
container = props;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const unwrapped = (0, nodeEnvelope_1.unwrapNodePackagePropertiesEnvelope)(props);
|
|
57
|
+
if (unwrapped !== props && isRecord(unwrapped) && Array.isArray(unwrapped.branches)) {
|
|
58
|
+
container = unwrapped;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!container)
|
|
62
|
+
return { changed: false, paths };
|
|
63
|
+
const branches = container.branches;
|
|
64
|
+
branches.forEach((branch, bi) => {
|
|
65
|
+
if (!isRecord(branch) || !Array.isArray(branch.or_list))
|
|
66
|
+
return;
|
|
67
|
+
branch.or_list.forEach((orItem, oi) => {
|
|
68
|
+
if (!isRecord(orItem) || !Array.isArray(orItem.and_list))
|
|
69
|
+
return;
|
|
70
|
+
orItem.and_list.forEach((andItem, ai) => {
|
|
71
|
+
if (!isRecord(andItem))
|
|
72
|
+
return;
|
|
73
|
+
const normalized = normalizeNullConditionValue(andItem.operator, andItem.value);
|
|
74
|
+
if (normalized !== andItem.value) {
|
|
75
|
+
andItem.value = normalized;
|
|
76
|
+
paths.push(`properties.branches[${bi}].or_list[${oi}].and_list[${ai}].value`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
return { changed: paths.length > 0, paths };
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=switchBranch.js.map
|
|
@@ -75,19 +75,63 @@ function writeState(state) {
|
|
|
75
75
|
ensureStateDir();
|
|
76
76
|
fs.writeFileSync(STATE_FILE, JSON.stringify(state), 'utf-8');
|
|
77
77
|
}
|
|
78
|
+
/** 拆分版本号:数字核心段 + 预发布段('0.9.28-beta.1' → [0,9,28] + 'beta.1') */
|
|
79
|
+
function parseVersion(version) {
|
|
80
|
+
const dash = version.indexOf('-');
|
|
81
|
+
const coreStr = dash >= 0 ? version.slice(0, dash) : version;
|
|
82
|
+
const prerelease = dash >= 0 ? version.slice(dash + 1) : null;
|
|
83
|
+
// 非数字段(含 NaN)归 0,与历史兜底语义一致
|
|
84
|
+
return { core: coreStr.split('.').map((part) => Number(part) || 0), prerelease };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* semver 预发布段比较(核心版本相同时使用):
|
|
88
|
+
* - 无预发布段(正式版)高于有预发布段:0.9.28 > 0.9.28-beta
|
|
89
|
+
* - 双方都有:按点分标识符比较,数字标识符按数值且低于字母标识符,字母按字典序
|
|
90
|
+
*/
|
|
91
|
+
function comparePrerelease(a, b) {
|
|
92
|
+
if (a === b)
|
|
93
|
+
return 0;
|
|
94
|
+
if (a === null)
|
|
95
|
+
return 1;
|
|
96
|
+
if (b === null)
|
|
97
|
+
return -1;
|
|
98
|
+
const aIds = a.split('.');
|
|
99
|
+
const bIds = b.split('.');
|
|
100
|
+
const len = Math.min(aIds.length, bIds.length);
|
|
101
|
+
for (let i = 0; i < len; i++) {
|
|
102
|
+
const aNum = /^\d+$/.test(aIds[i]) ? Number(aIds[i]) : null;
|
|
103
|
+
const bNum = /^\d+$/.test(bIds[i]) ? Number(bIds[i]) : null;
|
|
104
|
+
if (aNum !== null && bNum !== null) {
|
|
105
|
+
if (aNum !== bNum)
|
|
106
|
+
return aNum < bNum ? -1 : 1;
|
|
107
|
+
}
|
|
108
|
+
else if (aNum === null && bNum === null) {
|
|
109
|
+
if (aIds[i] !== bIds[i])
|
|
110
|
+
return aIds[i] < bIds[i] ? -1 : 1;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// semver:数字标识符低于字母标识符
|
|
114
|
+
return aNum !== null ? -1 : 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (aIds.length !== bIds.length)
|
|
118
|
+
return aIds.length < bIds.length ? -1 : 1;
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
78
121
|
function isNewerVersion(current, latest) {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const maxLen = Math.max(
|
|
122
|
+
const currentVer = parseVersion(current);
|
|
123
|
+
const latestVer = parseVersion(latest);
|
|
124
|
+
const maxLen = Math.max(currentVer.core.length, latestVer.core.length);
|
|
82
125
|
for (let i = 0; i < maxLen; i++) {
|
|
83
|
-
const c =
|
|
84
|
-
const l =
|
|
126
|
+
const c = currentVer.core[i] ?? 0;
|
|
127
|
+
const l = latestVer.core[i] ?? 0;
|
|
85
128
|
if (l > c)
|
|
86
129
|
return true;
|
|
87
130
|
if (l < c)
|
|
88
131
|
return false;
|
|
89
132
|
}
|
|
90
|
-
|
|
133
|
+
// 核心版本相同:latest 预发布段更低才算更新(0.9.28-beta → 0.9.28 提示,反之不提示)
|
|
134
|
+
return comparePrerelease(currentVer.prerelease, latestVer.prerelease) < 0;
|
|
91
135
|
}
|
|
92
136
|
function fetchLatestVersion() {
|
|
93
137
|
return new Promise((resolve, reject) => {
|