#!/usr/bin/env tsx
/**
 * Priority1 人机协作 — FTL 等路径自动填至卡住，人工补全并记录至报价
 *
 * 用法:
 *   npm run visual:priority1-human-assist
 *   $env:PRIORITY1_PATH_ID="F01-ftl-dry-van-full"; npm run visual:priority1-human-assist
 */
import {
  DEFAULT_FTL_DEMO,
  PRIORITY1_CANONICAL_PATHS,
} from "@/workers/rpa/priority1/demo-input";
import { runPriority1HumanAssistChain } from "./visual-priority1-full-chain";

async function main(): Promise<void> {
  const pathId = process.env.PRIORITY1_PATH_ID?.trim() ?? "F01-ftl-dry-van-full";
  const canonical = PRIORITY1_CANONICAL_PATHS.find((p) => p.id === pathId);
  const demo = canonical?.input ?? DEFAULT_FTL_DEMO;
  const title = canonical?.title ?? "FTL 默认";

  console.log(`\n[human-assist] 路径=${pathId} (${title})\n`);

  const result = await runPriority1HumanAssistChain({
    demo,
    caseId: pathId,
    keepBrowserOpen: true,
  });

  process.exit(result.ok ? 0 : 1);
}

main().catch((e) => {
  console.error(e);
  process.exit(1);
});
