95 lines
2.8 KiB
JavaScript
95 lines
2.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import process from 'node:process';
|
|
import { runOrchestratorAdapter } from '../plugins/reporting-governance/src/adapters/orchestrator.mjs';
|
|
|
|
const cliArgs = parseCliArgs(process.argv.slice(2));
|
|
|
|
try {
|
|
const payload = runOrchestratorAdapter({
|
|
compact: cliArgs.compact,
|
|
...cliArgs,
|
|
});
|
|
process.stdout.write(`${JSON.stringify(payload, null, cliArgs.compact ? 0 : 2)}\n`);
|
|
} catch (error) {
|
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
process.exit(1);
|
|
}
|
|
|
|
function parseCliArgs(argv) {
|
|
const args = {
|
|
state: null,
|
|
evidenceDir: null,
|
|
eventDir: null,
|
|
queueDir: null,
|
|
spoolDir: null,
|
|
receiptDir: null,
|
|
watchdogScript: null,
|
|
dispatcherScript: null,
|
|
supervisorScript: null,
|
|
senderCommand: null,
|
|
senderMode: null,
|
|
openclawBin: 'openclaw',
|
|
now: null,
|
|
compact: false,
|
|
writeState: false,
|
|
claim: false,
|
|
dryRun: false,
|
|
help: false,
|
|
};
|
|
|
|
for (let i = 0; i < argv.length; i += 1) {
|
|
const token = argv[i];
|
|
if (token === '--compact') { args.compact = true; continue; }
|
|
if (token === '--write-state') { args.writeState = true; continue; }
|
|
if (token === '--claim') { args.claim = true; continue; }
|
|
if (token === '--dry-run') { args.dryRun = true; continue; }
|
|
if (token === '--help' || token === '-h') { args.help = true; continue; }
|
|
|
|
const pairs = [
|
|
['--state', 'state'],
|
|
['--evidence-dir', 'evidenceDir'],
|
|
['--event-dir', 'eventDir'],
|
|
['--queue-dir', 'queueDir'],
|
|
['--spool-dir', 'spoolDir'],
|
|
['--receipt-dir', 'receiptDir'],
|
|
['--watchdog-script', 'watchdogScript'],
|
|
['--dispatcher-script', 'dispatcherScript'],
|
|
['--supervisor-script', 'supervisorScript'],
|
|
['--sender-command', 'senderCommand'],
|
|
['--sender-mode', 'senderMode'],
|
|
['--openclaw-bin', 'openclawBin'],
|
|
['--now', 'now'],
|
|
];
|
|
|
|
let matched = false;
|
|
for (const [flag, key] of pairs) {
|
|
if (token === flag) {
|
|
args[key] = argv[i + 1] ?? args[key];
|
|
i += 1;
|
|
matched = true;
|
|
break;
|
|
}
|
|
if (token.startsWith(`${flag}=`)) {
|
|
args[key] = token.slice(flag.length + 1) || args[key];
|
|
matched = true;
|
|
break;
|
|
}
|
|
}
|
|
if (matched) continue;
|
|
}
|
|
|
|
if (args.help) {
|
|
process.stdout.write([
|
|
'Usage:',
|
|
' node scripts/watchdog_auto_notify_orchestrator.mjs [--write-state] [--claim] [--dry-run] [--sender-command <shell>] [--sender-mode shim|openclaw-cli] [--openclaw-bin <path>] [--now <iso>] [--compact]',
|
|
'',
|
|
'Repo-root shim that forwards to package-owned orchestrator implementation.',
|
|
'Default runtime binding now resolves package script first; env/override can still point elsewhere.',
|
|
].join('\n') + '\n');
|
|
process.exit(0);
|
|
}
|
|
|
|
return args;
|
|
}
|