Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

1.1 KB
Raw Blame
/**
 * Inlines the sandbox Python helper scripts into a generated TS module so
 * `Sandbox` can self-serve its scripts with no loose files in the package.
 * A plain generated `.ts` file works unchanged across tsup, plain `tsc`
 * (the .d.ts build), and @swc/jest — no loaders or transforms needed.
 *
 * Runs via the `build:gen` script before build/typecheck/test. The generated
 * output (src/core/sandbox/sandboxScripts.gen.ts) is gitignored.
 */
import { readFileSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

const root = join(dirname(fileURLToPath(import.meta.url)), '..');
const scriptsDir = join(root, 'src/core/sandbox/scripts');
const read = f => readFileSync(join(scriptsDir, f), 'utf-8');

const out = `// AUTO-GENERATED by scripts/generate-sandbox-scripts.mjs — do not edit.
export const sandboxScripts = {
  mcpClient: ${JSON.stringify(read('mcp_client.py'))},
  skillDownloader: ${JSON.stringify(read('skill_downloader.py'))},
} as const;
`;
writeFileSync(join(root, 'src/core/sandbox/sandboxScripts.gen.ts'), out);