Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Long commands: keep the wait fix, say the no-detach rule in one sentence
milind-soni45814293a599
diff --git a/server/system-prompt.test.ts b/server/system-prompt.test.tsindex 1d0106351a..cdb5492f1c 100644--- a/server/system-prompt.test.ts+++ b/server/system-prompt.test.ts@@ -433,25 +433,21 @@ describe("longCommandsPrompt", () => {}});- it("keeps a long command in a tracked foreground session instead of detaching it", () => {+ it("keeps a long command in the foreground, and trusts only its own fresh exit code", () => {for (const kind of [null, "local", "vps", "box"] as const) {const text = longCommandsPrompt(kind);expect(text).toContain("keep the command in the foreground until it exits");- expect(text).toContain("until it reaches terminal exit or the timeout elapses");- expect(text).toContain("still running and unresolved");- expect(text).toContain("split it into shorter pieces that each finish within it");- expect(text).toContain("Do not detach a command with nohup");- expect(text).not.toContain("nohup <command>");- expect(text).toContain("require the command's own fresh exit code and output");+ expect(text).toContain("split work that cannot finish within that into shorter pieces");+ expect(text).toContain("A detached job may be killed when the call ends");+ expect(text).not.toContain("nohup");+ expect(text).toContain("trust only the command's own fresh exit code and output");expect(text).toContain("cannot set a wait, so finish it in this turn");}});it("keeps the Local VM's own detached path, where the container outlives the call", () => {for (const kind of ["vm-private", "vm-shared"] as const) {- const text = longCommandsPrompt(kind);- expect(text).toContain("This is the exception to the no-detach rule above");- expect(text).toContain("start it detached inside the VM (`nohup <command> > /tmp/<job>.log 2>&1 &`)");+ expect(longCommandsPrompt(kind)).toContain("may start detached inside it (`nohup <command> > /tmp/<job>.log 2>&1 &`)");}});});diff --git a/server/system-prompt.ts b/server/system-prompt.tsindex a2bb9d13da..ec668e5986 100644--- a/server/system-prompt.ts+++ b/server/system-prompt.ts@@ -217,9 +217,9 @@ export const CREDENTIAL_PROMPT =/** Ten minutes stays inside the 20-minute turn stall watchdog, which sees nothing while a command runs. */export const BASH_MAX_TIMEOUT_MS = 600_000;const LONG_COMMANDS_TEXT =- ` Long-running shell commands: a shell call is stopped after a default limit (2 minutes for a Bash call) and the output of a stopped command is lost. Before running anything that can take more than a minute, such as transcription (whisper), ffmpeg or ffprobe over long media, renders, large builds or big file transfers, pass a longer per-call timeout (Bash takes \`timeout\` in milliseconds, up to ${BASH_MAX_TIMEOUT_MS}) and keep the command in the foreground until it exits: if the call returns a live session, keep polling that session until it reaches terminal exit or the timeout elapses, then check its fresh exit code and output before moving on; if it has not exited by then, stop polling and tell the person the command is still running and unresolved instead of claiming it finished. If a command cannot finish within the timeout, split it into shorter pieces that each finish within it, confirming each piece's fresh exit code and output. Do not detach a command with nohup or \`&\`: a detached job is not tracked, its shell exit does not mean the work finished, and a later call may find no process left to wait on. A launch exit 0 or an old output file is not proof the work completed; require the command's own fresh exit code and output. Never scan the whole disk with \`find /\` or similar: search by name with \`mdfind -name\` on macOS, or search a specific folder such as your workspace or home with a depth limit. If a command times out, do not rerun it the same way. Never wait inside a command for CI, a deploy or any other job to finish (no sleep loops or repeated polls): check it once, and if it is still running, tell the person what you made (with links). Only on a turn the person started in their own chat, set wait_until or a one-time trigger to check back and end your turn; work handed to you by a bot, a routine or an outside event cannot set a wait, so finish it in this turn instead of scheduling a continuation you cannot authorize. When the person writes while you work, answer them first.`;+ ` Long-running shell commands: a shell call is stopped after a default limit (2 minutes for a Bash call) and the output of a stopped command is lost. Before running anything that can take more than a minute, such as transcription (whisper), ffmpeg or ffprobe over long media, renders, large builds or big file transfers, pass a longer per-call timeout (Bash takes \`timeout\` in milliseconds, up to ${BASH_MAX_TIMEOUT_MS}) and keep the command in the foreground until it exits; split work that cannot finish within that into shorter pieces. A detached job may be killed when the call ends, so keep work whose result you need in the foreground, and trust only the command's own fresh exit code and output, not a launch exit 0 or an old output file. Never scan the whole disk with \`find /\` or similar: search by name with \`mdfind -name\` on macOS, or search a specific folder such as your workspace or home with a depth limit. If a command times out, do not rerun it the same way. Never wait inside a command for CI, a deploy or any other job to finish (no sleep loops or repeated polls): check it once, and if it is still running, tell the person what you made (with links). Only on a turn the person started in their own chat, set wait_until or a one-time trigger to check back and end your turn; work handed to you by a bot, a routine or an outside event cannot set a wait, so finish it in this turn. When the person writes while you work, answer them first.`;const VM_LONG_COMMANDS_TEXT =- " In your Local VM, vm_exec takes `timeout_seconds` instead (default 60, at most 300). This is the exception to the no-detach rule above: the VM container keeps running between calls, so for a job longer than 300 seconds start it detached inside the VM (`nohup <command> > /tmp/<job>.log 2>&1 &`) and check its log with later vm_exec calls.";+ " In your Local VM, vm_exec takes `timeout_seconds` instead (default 60, at most 300). The VM keeps running between calls, so a job longer than that may start detached inside it (`nohup <command> > /tmp/<job>.log 2>&1 &`); check its log with later vm_exec calls.";export function longCommandsPrompt(computer: ComputerPromptKind | null): string {return LONG_COMMANDS_TEXT + (computer === "vm-private" || computer === "vm-shared" ? VM_LONG_COMMANDS_TEXT : "");}