SPB Git

Repository Public

research-server.mts 1.5 KB 17 lines typescript

1// Backend for research.spec.ts, in one process (scripts/lib/research-harness.mts): the real API on a scratch PostgreSQL2// database with synthetic candles, the BUILT web bundle, a stub signer that only answers GET /status, and the REAL research3// runner polling the API with its own secret and launching the deterministic FAKE agent under the OS sandbox. No model, no4// key, no network beyond loopback.5//6//   npx tsx tests/e2e/research-server.mts --port 8691 --db spw_v7_research_e2e_phone7import { resolve } from 'node:path';8import { ROOT, startResearchStack } from '../../scripts/lib/research-harness.mts';910const arg = (name: string, d: string) => { const i = process.argv.indexOf(`--${name}`); return i > 0 ? process.argv[i + 1]! : d; };11const st = await startResearchStack({ port: Number(arg('port', '8691')), db: arg('db', 'spw_v7_research_e2e'), agent: 'fake', webDir: resolve(ROOT, 'dist/web'), bars: 1100,12  // test control (this harness only; behind the session and the CSRF check like every /api/ route): what the fake agent does next13  routes: (app, c) => { app.post('/api/v1/__e2e/fake-mode', async (req: { body: { mode: string } }) => { c.setFakeMode(String(req.body.mode)); return { ok: true }; }); } });14const agent = await st.addAgent('Momentum BTC/ETH', ['BTC', 'ETH']);15console.log(`READY ${st.origin} token ${st.token} agent ${agent}`);16for (const sig of ['SIGINT', 'SIGTERM'] as const) process.on(sig, () => { void st.stop().finally(() => process.exit(0)); });17
Files main
Menu

Theme