#!/usr/bin/env node /** * Page Data delivery evidence for Goose v1.49 local canary (artifact chain + runtime). */ import { spawnSync } from 'node:child_process'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { applyGooseV149CanaryBlockEnv } from './goose-v149-canary.mjs'; import { loadMemindEnvFiles } from './memind-runtime-profile.mjs'; import { resolvePortalBase } from './scenario-test-lib.mjs'; const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); loadMemindEnvFiles(root, process.env); applyGooseV149CanaryBlockEnv(process.env, root); const baseUrl = resolvePortalBase(Number(process.env.H5_PORT ?? 8081)); const skip = process.env.GOOSE_V149_PAGE_DATA_EVIDENCE_SKIP === '1'; async function main() { if (skip) { console.log('GOOSE_V149_PAGE_DATA_EVIDENCE_OK: skipped'); return; } try { const status = await fetch(`${baseUrl}/auth/status`); if (!status.ok) throw new Error(`Portal not reachable: ${status.status}`); } catch (error) { throw new Error(`Portal not reachable at ${baseUrl}: ${error.message}`); } const runtime = await fetch(`${baseUrl}/api/runtime/status`).then((r) => r.json()).catch(() => null); const targets = (runtime?.targets ?? []).map((item) => item.target ?? item).filter(Boolean); const v149Port = process.env.GOOSE_V149_PORT || '18049'; if (!targets.some((item) => String(item).includes(`:${v149Port}`))) { throw new Error(`Portal not routing to v1.49 :${v149Port}; targets=${JSON.stringify(targets)}`); } const survey = spawnSync( process.execPath, [path.join(root, 'scripts', 'verify-children-hobby-diet-survey.mjs'), '--no-runs'], { cwd: root, env: process.env, encoding: 'utf8' }, ); if (survey.status !== 0) { throw new Error(survey.stderr?.trim() || survey.stdout?.trim() || 'children-hobby-diet survey verify failed'); } console.log('GOOSE_V149_PAGE_DATA_EVIDENCE_OK:'); console.log(` portal=${baseUrl} gooseTarget=${targets.join(',')}`); console.log(' survey=verify-children-hobby-diet-survey (--no-runs)'); console.log(' note=full Agent E2E: npm run test:scenario:john4-diet'); } main().catch((error) => { console.error(`GOOSE_V149_PAGE_DATA_EVIDENCE_FAIL: ${error.message}`); process.exit(1); });