Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mattpocock/sandcastle/llms.txt
Use this file to discover all available pages before exploring further.
run() is the primary entry point for executing an AI coding agent in a sandboxed environment. You call it once, pass a prompt and a provider, and Sandcastle takes care of creating the worktree, starting the container, running the agent for up to maxIterations rounds, collecting commits, and tearing everything down. Use createSandbox() instead when you need to run multiple agents inside the same container without paying the startup cost each time.
Import
Signature
output option, the return type is narrowed:
Usage example
Options
See RunOptions for the complete field reference.Return value
run() returns a Promise<RunResult>.
Per-iteration results. Use
.length to get the count of iterations executed.The completion signal string that caused the iteration loop to stop early, or
undefined if the loop ran to maxIterations without a match.Combined stdout output from all agent iterations concatenated together.
List of commits the agent created during the run, each identified by its SHA.
The branch name the agent worked on inside the sandbox.
Absolute path to the log file. Only present when
logging is set to { type: "file", ... }.Typed structured output. Only present when you pass an
output option (Output.object(...) or Output.string(...)). The type is inferred from your schema.Notes
promptandpromptFileare mutually exclusive. Providing neither, or both, is an error.promptFilealways resolves againstprocess.cwd(), not againstcwd.- If you need to run multiple agents inside the same container, use
createSandbox()instead. - When you pass a
signalthat is already aborted,run()rejects immediately without doing any setup work.