import { RpaError } from "@/modules/rpa/errors"; /** Kernel step 子阶段 fail-fast 包装(定位非法结构来源) */ export async function runKernelSubStep( step: string, subStep: string, fn: () => Promise, ): Promise { try { return await fn(); } catch (error) { const message = error instanceof Error ? error.message : String(error); const stack = error instanceof Error ? error.stack : undefined; throw new RpaError( "STRUCT_CHANGE", `[${step}/${subStep}] ${message}`, { retryable: true, cause: stack, }, ); } }