import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create('codex', {
envs: { CODEX_API_KEY: process.env.CODEX_API_KEY },
})
await sandbox.files.write('/home/user/schema.json', JSON.stringify({
type: 'object',
properties: {
issues: {
type: 'array',
items: {
type: 'object',
properties: {
file: { type: 'string' },
line: { type: 'number' },
severity: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
description: { type: 'string' },
},
required: ['file', 'severity', 'description'],
},
},
},
required: ['issues'],
}))
const result = await sandbox.commands.run(
`codex exec --full-auto --skip-git-repo-check --output-schema /home/user/schema.json -C /home/user/repo "Review this codebase for security issues"`
)
const response = JSON.parse(result.stdout)
console.log(response.issues)
await sandbox.kill()