Study/scripts/build-server.mjs
Elijah 5ea61c882c
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 51s
Add sandboxed Python for the assistant and a Python check of generated quizzes
- Pyodide (Python 3.14, WebAssembly) in a separate Node process under the permission
  model: read-only access to Pyodide's files, no writes, processes or network, empty
  environment, JS bridges removed, time limit with kill and restart.
- Assistant tool run_python, which can load a draft or quiz as Python data.
- After quiz generation the model checks question count, type mix, correct answers per
  type, duplicates and recomputed calculations with Python, then submits fixes that are
  applied only if the question still validates. Switch in the Generate dialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 13:03:24 -07:00

18 lines
552 B
JavaScript

// Bundles the server into one file. Dependencies stay external and are installed in the image.
import fs from 'node:fs';
import { build } from 'esbuild';
await build({
entryPoints: ['server/main.ts'],
outfile: 'dist/server/main.js',
bundle: true,
platform: 'node',
format: 'esm',
target: 'node24',
packages: 'external',
sourcemap: true,
logLevel: 'info',
});
// The Python sandbox runs as its own (permission-restricted) process, so it ships as a file.
fs.copyFileSync('server/python-runner.mjs', 'dist/server/python-runner.mjs');