import { CLIError, runToolsCLI } from "@midscene/shared/cli";
import { BaseMidsceneTools } from "@midscene/shared/mcp";
import { Agent } from "../agent/agent.mjs";
function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
class SkillMidsceneTools extends BaseMidsceneTools {
    createTemporaryDevice() {
        return new this.DeviceClass();
    }
    async ensureAgent() {
        if (!this.agent) {
            const device = new this.DeviceClass();
            this.agent = new Agent(device);
        }
        return this.agent;
    }
    constructor(DeviceClass){
        super(), _define_property(this, "DeviceClass", void 0), this.DeviceClass = DeviceClass;
    }
}
function runSkillCLI(options) {
    const tools = new SkillMidsceneTools(options.DeviceClass);
    return runToolsCLI(tools, options.scriptName).catch((e)=>{
        if (!(e instanceof CLIError)) console.error(e);
        process.exit(e instanceof CLIError ? e.exitCode : 1);
    });
}
export { runSkillCLI };

//# sourceMappingURL=index.mjs.map