SPB Git

Repository Public

main.ts 3.2 KB 59 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : SP Wallet8 * File             : services/research-runner/src/main.ts9 * Module           : services10 * Repository       : https://git.spboucher.ai/sp-wallet11 * Project Website  : https://wallet.spboucher.ai12 * Created          : 2026-11-1113 * Last Modified    : 2026-11-1114 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// SP Wallet research runner — a standalone service for a research node. It is NOT part of the wallet API and shares no44// secret with it except its own runner secret. See docs/v7/RESEARCH-RUNTIME.md and services/research-runner/README.md.45import { existsSync } from 'node:fs';46import { httpApi } from './api-client.ts';47import { configFromEnv } from './config.ts';48import { sandboxAvailable } from './job.ts';49import { startRunner } from './runner.ts';5051const cfg = configFromEnv();52// refuse to start with anything of the wallet in the environment: the runner must not be able to hand it to a job by mistake53for (const k of Object.keys(process.env)) if (/^SPW_SIGNER|^DATABASE_URL$|^RESEARCH_DATABASE_URL$|^SPW_ORIGIN$|^SPW_RP_ID$/.test(k)) throw new Error(`${k} is set: the research runner must not run with the wallet's environment`);54if (!existsSync(cfg.python)) throw new Error(`no laboratory interpreter at ${cfg.python}: run "uv sync --frozen" in the laboratory checkout`);55if (cfg.sandbox === 'required' && !sandboxAvailable()) throw new Error('sandbox-exec is not available on this machine; the runner refuses to start (SPW_RUNNER_SANDBOX=off runs jobs WITHOUT OS isolation and says so in every result)');56const stop = startRunner(cfg, httpApi(cfg));57console.log(`sp-wallet research runner "${cfg.runnerId}" → ${cfg.apiUrl}; agent=${cfg.agent.kind}; sandbox=${sandboxAvailable() ? 'sandbox-exec' : 'NONE'}; lab=${cfg.labDir} (${cfg.labPin})`);58for (const sig of ['SIGINT', 'SIGTERM'] as const) process.on(sig, () => { stop(); process.exit(0); });59
Files main
Menu

Theme