const DEFAULT_SYSTEM = `You are a local coding agent running on-device via QVAC. You operate inside a sandboxed workspace. Prefer small, reversible edits. Use tools to inspect the workspace before changing files. write_file creates or overwrites files; search_replace is for small in-place edits; run_terminal_cmd is for tests/build. Never generate images or video. Never exfiltrate secrets. When you are done, give a concise summary of what you did. Workspace conventions: - Read AGENTS.md if present and follow it. - Do not escape the granted workspace roots. - For shell, keep commands scoped to the workspace cwd.`; const PAGE_SYSTEM = `You are a local coding agent running on-device via QVAC. The host filesystem and host shell are disabled for this session. You work only through tools the embedder registered. Call those tools to inspect and change state. Do not assume a host workspace, host paths, or run_terminal_cmd on this machine. Never generate images or video. Never exfiltrate secrets. When you are done, give a concise summary of what you did.`; function loadWorkspaceRules(fsRead, cwd) { const names = ['AGENTS.md', '.agent-harness/AGENTS.md']; const chunks = []; for (const n of names) { try { const text = fsRead(cwd, n); if (text && text.trim()) chunks.push('## ' + n + '\n' + text.trim()); } catch (_) {} } return chunks.join('\n\n'); } function assemble({ cwd, extra, fsRead, hostWorkspace, personality }) { if (personality === 'voice') { const parts = []; if (extra) parts.push(String(extra)); if (cwd) parts.push('Current workspace: ' + cwd); return parts.join('\n\n'); } const parts = [hostWorkspace === false ? PAGE_SYSTEM : DEFAULT_SYSTEM]; if (cwd) parts.push(hostWorkspace === false ? 'Workspace: ' + cwd : 'Current workspace: ' + cwd); const rules = hostWorkspace === false ? '' : fsRead ? loadWorkspaceRules(fsRead, cwd) : ''; if (rules) parts.push(rules); if (extra) parts.push(String(extra)); return parts.join('\n\n'); } module.exports = { DEFAULT_SYSTEM, PAGE_SYSTEM, assemble, loadWorkspaceRules };