'use strict' // Offline CLI. It consumes reviewed fixture files and never calls a provider. // A real deployment adapter must reserve/attest its diagnostic lane before // using the pure continuation module; this command is only for acceptance. const fs = require('node:fs') const path = require('node:path') const { runDiagnosticContinuation } = require('./wiki_leaf_diagnostic_continuation.cjs') function argument(name) { const prefix = `--${name}=` const value = process.argv.slice(2).find(arg => arg.startsWith(prefix)) return value?.slice(prefix.length) } const allowed = new Set(['--manifest=', '--source=', '--outcome=']) const unknown = process.argv.slice(2).filter(arg => ![...allowed].some(prefix => arg.startsWith(prefix))) if (unknown.length || !argument('manifest') || !argument('source') || !argument('outcome')) { console.error('usage: node scripts/run_wiki_leaf_diagnostic_continuation.cjs --manifest=FILE --source=FILE --outcome=FILE') process.exitCode = 2 } else { try { const read = file => fs.readFileSync(path.resolve(file), 'utf8') const manifest = JSON.parse(read(argument('manifest'))) const source = read(argument('source')) const outcome = JSON.parse(read(argument('outcome'))) const capture = [] const result = runDiagnosticContinuation(manifest, source, () => outcome, artifact => { // Keep the CLI output replay-safe. The real private capture sink owns // the raw response; this fixture command emits hashes and byte counts. capture.push({ status: artifact.status, idempotency_key: artifact.idempotency_key, response_sha256: artifact.response_sha256, response_bytes: artifact.response_bytes }) }) const windows = result.windows.map(window => ({ key: window.key, status: window.status, start_rune: window.start_rune, end_rune: window.end_rune, text_sha256: window.text_sha256 })) process.stdout.write(JSON.stringify({ receipt: result.receipt, windows, capture }, null, 2) + '\n') } catch (error) { process.stderr.write(JSON.stringify({ passed: false, code: error.code || 'continuation_failed', error: error.message }) + '\n') process.exitCode = 1 } }