67220a14ea
Prevent phase2/phase3/all reruns from burning DashScope tokens unless GOOSE_V149_ALLOW_REAL_LLM=1 is explicitly set with human approval. Co-authored-by: Cursor <cursoragent@cursor.com>
73 lines
2.3 KiB
JavaScript
73 lines
2.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Smoke harness bootstrap/remember on local Goose v1.49 candidate.
|
|
*/
|
|
import { Agent, fetch } from 'undici';
|
|
|
|
import { enforceRealLlmGate } from './goose-v149-real-llm-gate.mjs';
|
|
|
|
enforceRealLlmGate('check-goosed-v149-harness.mjs');
|
|
|
|
const port = process.env.GOOSE_V149_PORT || '18049';
|
|
const host = process.env.GOOSE_V149_HOST || '127.0.0.1';
|
|
const secret = process.env.GOOSE_SERVER__SECRET_KEY || 'local-v149-dev-secret';
|
|
const workingDir = process.env.GOOSE_V149_WORKING_DIR || process.cwd();
|
|
const base = `https://${host}:${port}`;
|
|
const blockedHosts = ['58.38.22.103', '120.26.184.105'];
|
|
|
|
if (blockedHosts.includes(host)) {
|
|
console.error(`GOOSE_V149_HARNESS_FAIL: refusing production host ${host}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const dispatcher = new Agent({ connect: { rejectUnauthorized: false } });
|
|
|
|
async function apiJson(pathname, body) {
|
|
const response = await fetch(`${base}${pathname}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-Secret-Key': secret,
|
|
},
|
|
body: JSON.stringify(body),
|
|
dispatcher,
|
|
});
|
|
const text = await response.text();
|
|
if (!response.ok) {
|
|
throw new Error(`${pathname} ${response.status}: ${text.slice(0, 400)}`);
|
|
}
|
|
return text.trim() ? JSON.parse(text) : {};
|
|
}
|
|
|
|
async function main() {
|
|
const started = await apiJson('/agent/start', { working_dir: workingDir });
|
|
if (!started?.id) throw new Error('missing session id from /agent/start');
|
|
|
|
const bootstrap = await apiJson('/agent/harness_bootstrap', {
|
|
sessionId: started.id,
|
|
force: true,
|
|
query: 'project architecture conventions',
|
|
});
|
|
if (typeof bootstrap.summary !== 'string') {
|
|
throw new Error(`harness_bootstrap missing summary: ${JSON.stringify(bootstrap)}`);
|
|
}
|
|
|
|
const remember = await apiJson('/agent/harness_remember', {
|
|
sessionId: started.id,
|
|
title: 'goose-v149 harness smoke',
|
|
content: 'v1.49 harness remember smoke marker',
|
|
});
|
|
if (typeof remember.remembered !== 'boolean') {
|
|
throw new Error(`harness_remember missing remembered flag: ${JSON.stringify(remember)}`);
|
|
}
|
|
|
|
console.log(
|
|
`GOOSE_V149_HARNESS_OK: session=${started.id} bootstrapSource=${bootstrap.source} remembered=${remember.remembered}`,
|
|
);
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error(`GOOSE_V149_HARNESS_FAIL: ${error.message}`);
|
|
process.exit(1);
|
|
});
|