package tech.easyflow.ai.easyagentsflow.code;

import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.code.CodeRuntimeEngine;
import com.easyagents.flow.core.node.CodeNode;

import java.util.Map;

public class UnavailableCodeRuntimeEngine implements CodeRuntimeEngine {

    private final String reason;

    public UnavailableCodeRuntimeEngine(String reason) {
        this.reason = reason;
    }

    @Override
    public Map<String, Object> execute(String code, CodeNode node, Chain chain) {
        String engine = node == null ? "unknown" : node.getEngine();
        throw new RuntimeException("代码执行引擎不可用: " + engine + "，原因: " + reason);
    }
}
