{"version":3,"file":"skill/index.mjs","sources":["../../../src/skill/index.ts"],"sourcesContent":["import { BaseMidsceneTools } from '@midscene/shared/agent-tools/base-tools';\nimport type { BaseAgent, BaseDevice } from '@midscene/shared/agent-tools/types';\nimport { reportCLIError, runToolsCLI } from '@midscene/shared/cli';\nimport { Agent } from '../agent/agent';\nimport type { AbstractInterface } from '../device';\n\ntype DeviceClass = new (...args: any[]) => AbstractInterface;\n\n/**\n * Skill tools manager that lazily creates Agent from a Device class.\n * Used by runSkillCLI for CLI / Agent Skills scenarios where no agent exists at startup.\n */\nclass SkillMidsceneTools extends BaseMidsceneTools<BaseAgent> {\n  constructor(private DeviceClass: DeviceClass) {\n    super();\n  }\n\n  protected createTemporaryDevice(): BaseDevice {\n    return new this.DeviceClass() as unknown as BaseDevice;\n  }\n\n  protected async ensureAgent(): Promise<BaseAgent> {\n    if (!this.agent) {\n      const device = new this.DeviceClass();\n      this.agent = new Agent(device) as unknown as BaseAgent;\n    }\n    return this.agent;\n  }\n}\n\nexport interface SkillCLIOptions {\n  scriptName: string;\n  DeviceClass: DeviceClass;\n}\n\n/**\n * Launch a Skill CLI for a custom interface Device class.\n * This enables AI coding assistants (Claude Code, Cline, etc.) to control\n * your custom interface through CLI commands.\n *\n * @example\n * ```typescript\n * #!/usr/bin/env node\n * import { runSkillCLI } from '@midscene/core/skill';\n * import { SampleDevice } from './sample-device';\n *\n * runSkillCLI({\n *   DeviceClass: SampleDevice,\n *   scriptName: 'my-device',\n * });\n * ```\n */\nexport function runSkillCLI(options: SkillCLIOptions): Promise<void> {\n  const tools = new SkillMidsceneTools(options.DeviceClass);\n  return runToolsCLI(tools, options.scriptName).catch((e) => {\n    process.exit(reportCLIError(e));\n  });\n}\n"],"names":["SkillMidsceneTools","BaseMidsceneTools","device","Agent","DeviceClass","runSkillCLI","options","tools","runToolsCLI","e","process","reportCLIError"],"mappings":";;;;;;;;;;;;;AAYA,MAAMA,2BAA2BC;IAKrB,wBAAoC;QAC5C,OAAO,IAAI,IAAI,CAAC,WAAW;IAC7B;IAEA,MAAgB,cAAkC;QAChD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,MAAMC,SAAS,IAAI,IAAI,CAAC,WAAW;YACnC,IAAI,CAAC,KAAK,GAAG,IAAIC,MAAMD;QACzB;QACA,OAAO,IAAI,CAAC,KAAK;IACnB;IAdA,YAAoBE,WAAwB,CAAE;QAC5C,KAAK,wDADaA,WAAW,GAAXA;IAEpB;AAaF;AAwBO,SAASC,YAAYC,OAAwB;IAClD,MAAMC,QAAQ,IAAIP,mBAAmBM,QAAQ,WAAW;IACxD,OAAOE,YAAYD,OAAOD,QAAQ,UAAU,EAAE,KAAK,CAAC,CAACG;QACnDC,QAAQ,IAAI,CAACC,eAAeF;IAC9B;AACF"}