chore: initial commit

This commit is contained in:
2026-10-22 17:07:08 +08:00
commit 0acef64f48
200 changed files with 35546 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import type {NodeHandler} from '../../../types/bot/workflow/runtime.ts';
import type {WorkflowNodeTemplate} from '../../../types/bot/workflow/metadata.ts';
import {describe, failure_port, output, port} from '../metadata.ts';
import {evaluate_condition} from '../runtime/value.ts';
export const config_template: WorkflowNodeTemplate = {
name: 'condition', version: '1.0.0',
i18n: describe('条件判断', '计算条件表达式,根据布尔结果选择为真或为假分支。'),
config: [
{name: 'condition', type: 'condition', required: true,
i18n: describe('判断条件', '支持多个条件全部满足(and/且)、任一满足(or/或)及嵌套分组、取反;每项可使用 eq、contains、gt、lt 比较字面量或状态引用。')},
],
output: {...output('boolean', '判断结果', '条件表达式的布尔结果,true 和 false 均为成功执行;计算失败时输出 null。'), nullable: true},
ports: [port('true', '为真', '条件结果为 true 时执行。'),
port('false', '为假', '条件结果为 false 时执行。'), failure_port],
};
export const execute: NodeHandler = async (node, state, signal) => {
if (node.type !== 'condition') throw new Error('Expected a condition node');
signal.throwIfAborted();
const output = evaluate_condition(node.config.condition, state);
return {port: output ? 'true' : 'false', result: {status: 'success', output}};
};