/** * Hard gate: block unattended Goose v1.49 smoke that calls real LLM providers. * Bulk portal/page/memory smokes can consume 100M+ tokens/day on DashScope. * * Opt-in only: * GOOSE_V149_ALLOW_REAL_LLM=1 node scripts/check-goosed-v149-all.mjs * * See docs/goose-v149-real-llm-gate.md */ export const REAL_LLM_GATE_ENV = 'GOOSE_V149_ALLOW_REAL_LLM'; export function isRealLlmAllowed(env = process.env) { return String(env[REAL_LLM_GATE_ENV] ?? '') === '1'; } export function realLlmGateMessage(source) { return [ `GOOSE_V149_REAL_LLM_BLOCKED: ${source}`, 'Unattended v1.49 smokes that call real LLM providers are disabled by default.', 'They previously consumed ~150M tokens/day on local DashScope during phase3 reruns.', `To run once with explicit approval: ${REAL_LLM_GATE_ENV}=1 `, 'See docs/goose-v149-real-llm-gate.md', ].join('\n'); } export function enforceRealLlmGate(source, env = process.env) { if (isRealLlmAllowed(env)) return; console.error(realLlmGateMessage(source)); process.exit(2); } /** Force skip flags for the heaviest portal/page smokes unless explicitly allowed. */ export function applyRealLlmSkipDefaults(env = process.env) { if (isRealLlmAllowed(env)) return env; env.GOOSE_V149_PORTAL_SMOKE_SKIP = '1'; env.GOOSE_V149_PAGE_E2E_SKIP = '1'; env.GOOSE_V149_PORTAL_RESUME_SKIP = env.GOOSE_V149_PORTAL_RESUME_SKIP ?? '1'; return env; }