open source is social v-it.org
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2026 sol pbc
3
4const AGENTS = new Set(['claude', 'codex', 'gemini']);
5
6export function sandboxArgs(agent, { prompt, systemPrompt, model } = {}) {
7 if (!AGENTS.has(agent)) {
8 throw new Error(`Unknown agent: ${agent}. Must be one of: ${[...AGENTS].join(', ')}`);
9 }
10 if (!prompt) {
11 throw new Error('prompt is required');
12 }
13
14 if (agent === 'claude') {
15 const args = ['-p', '--tools', '', '--output-format', 'json'];
16 if (systemPrompt) args.push('--system-prompt', systemPrompt);
17 args.push('--model', model || 'haiku');
18 args.push(prompt);
19 return { cmd: 'claude', args, env: { CLAUDECODE: '' } };
20 }
21
22 // codex and gemini lack a separate system prompt flag,
23 // so we prepend instructions to the prompt
24 const combined = systemPrompt ? `${systemPrompt}\n\n${prompt}` : prompt;
25
26 if (agent === 'codex') {
27 const args = ['exec', '-s', 'read-only'];
28 if (model) args.push('-m', model);
29 args.push(combined);
30 return { cmd: 'codex', args, env: {} };
31 }
32
33 // gemini
34 const args = ['-p', combined, '-s', '-e', 'none', '--output-format', 'json'];
35 if (model) args.push('-m', model);
36 return { cmd: 'gemini', args, env: {} };
37}