diff --git a/packages/rpa-core/src/engine/engine.ts b/packages/rpa-core/src/engine/engine.ts index 796ed46..f352d98 100644 --- a/packages/rpa-core/src/engine/engine.ts +++ b/packages/rpa-core/src/engine/engine.ts @@ -2,7 +2,9 @@ import type { Client } from "basic-ftp"; import type { Workbook as ExcelJSWorkbook } from "exceljs"; import { WindowsDriver } from "../driver/windows/windows-driver"; import type { AutomationDriver } from "../driver/types"; -import { RuntimeError } from "./types"; +import type { CatalogComponent, FlowNode } from "../types"; +import { getHandler } from "./registry"; +import { RuntimeError, type RunContext } from "./types"; /** 人为拟真操作的开关与随机参数(desktop 能力的进程级设置)。 */ export interface ManualOperationSettings { @@ -63,6 +65,25 @@ export class RpaEngine { setDriver(driver: AutomationDriver): void { this._driver = driver; } + + /** + * 单能力直接调用(ADR-R1 语义真实化):CLI/宿主脚本不再裸摸全局 getHandler, + * 而是经引擎入口调用。注意 handler 仍解析自进程注册表(ADR-R1 短期形态)。 + */ + async execute( + componentId: string, + args: Record, + ctx: RunContext, + node?: FlowNode, + component?: CatalogComponent + ): Promise { + const handler = getHandler(componentId); + if (!handler) { + throw new RuntimeError("capability_not_implemented", `能力 ${componentId} 未注册`, { componentId }); + } + const resolvedNode: FlowNode = node ?? { id: "direct", componentId, position: { x: 0, y: 0 }, values: {}, options: {} }; + return handler(ctx, resolvedNode, args, component as CatalogComponent); + } } export interface EngineOptions { diff --git a/packages/rpa-core/src/engine/runtime.ts b/packages/rpa-core/src/engine/runtime.ts index c42af09..1ac57bb 100644 --- a/packages/rpa-core/src/engine/runtime.ts +++ b/packages/rpa-core/src/engine/runtime.ts @@ -147,7 +147,7 @@ export async function runFlow( const summary = issues.filter((issue) => issue.severity === "error").map((item) => item.message).join(";"); throw new RuntimeError("validation_error", `流程图校验未通过:${summary}`, { recommendation: "修复流程图结构后再运行", - issues: JSON.stringify(issues.filter((issue) => issue.severity === "error")) + detail: JSON.stringify(issues.filter((issue) => issue.severity === "error")) }); } await executeTopLevelGraph(flow, ctx, states); diff --git a/resources/capability-snapshot.json b/resources/capability-snapshot.json index 3383ad6..4efdf63 100644 --- a/resources/capability-snapshot.json +++ b/resources/capability-snapshot.json @@ -1,5 +1,5 @@ { - "generatedAt": "2026-11-06T02:47:41.920Z", + "generatedAt": "2026-11-06T03:06:19.728Z", "count": 909, "ids": [ "App_GetPid",