You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* Flock Freight RPA 探针PRD §14.7
* 用法RPA_MOCK_MODE=true npm run probe:flock-rpa
* 或真实模式 FLOCK_RPA_ENABLED=true npm run probe:flock-rpa
*/
import { runFlockQuoteRpa } from "@/workers/rpa/flock/run-quote";
import { DEFAULT_FLOCK_DEMO } from "@/workers/rpa/flock/demo-input";
import type { FlockQuoteInput } from "@/workers/rpa/flock/types";
/** 与 flock-manual-20260713-152051.js 录制样例一致 */
const sample: FlockQuoteInput = {
pickupDate: DEFAULT_FLOCK_DEMO.pickupDateDisplay,
pickupZip: DEFAULT_FLOCK_DEMO.pickupZip,
deliveryZip: DEFAULT_FLOCK_DEMO.deliveryZip,
palletCount: DEFAULT_FLOCK_DEMO.palletCount,
totalWeightLb: DEFAULT_FLOCK_DEMO.totalWeightLb,
lengthIn: DEFAULT_FLOCK_DEMO.lengthIn,
widthIn: DEFAULT_FLOCK_DEMO.widthIn,
heightIn: DEFAULT_FLOCK_DEMO.heightIn,
};
async function main() {
const rounds = Number(process.env.FLOCK_PROBE_ROUNDS ?? "1");
let ok = 0;
for (let i = 1; i <= rounds; i++) {
console.log(`[probe-flock] round ${i}/${rounds}`);
console.log(
`[probe-flock] sample ${sample.pickupZip}${sample.deliveryZip} ` +
`${sample.palletCount}pl ${sample.totalWeightLb}lb`,
);
const result = await runFlockQuoteRpa(sample);
if (result.ok && result.quotes.length >= 2) {
ok += 1;
console.log(
`[probe-flock] OK ref=${result.reference ?? "-"} prices=${result.quotes
.map((q) => `${q.label}:$${q.totalUsd}`)
.join(", ")}`,
);
} else {
console.error(`[probe-flock] FAIL: ${result.errorMessage ?? "unknown"}`);
process.exitCode = 1;
return;
}
}
console.log(`[probe-flock] passed ${ok}/${rounds}`);
}
main().catch((error) => {
console.error("[probe-flock] fatal:", error);
process.exit(1);
});