Condukt.Sandbox.Setup (Condukt v3.0.0)

Copy Markdown View Source

Prepares a sandbox before a session's first turn, and again when the session comes back on a sandbox that was paused.

prepare/3 runs a repository's setup script as a sandbox process, streams its output to :on_output, and, when the script succeeds and the sandbox implements Condukt.Sandbox.snapshot/2, saves a snapshot. A later sandbox started with that snapshot (its init/1 takes :snapshot) skips the setup. resume/3 runs a resume script, such as one that starts what a pause stopped, the same way, without a snapshot.

{:ok, %{snapshot: snapshot_id}} =
  Condukt.Sandbox.Setup.prepare(sandbox, File.read!(".agents/setup"),
    on_output: &IO.write/1,
    snapshot: [key: "repo@" <> sha]
  )

Which snapshot to boot from, and when to refresh it, is the host's policy: Condukt only runs the script and asks the sandbox to save.

Summary

Functions

Runs script and saves a snapshot when it succeeds. Options

Runs a resume script. Takes prepare/3's options but :snapshot.

Functions

prepare(sandbox, script, opts \\ [])

Runs script and saves a snapshot when it succeeds. Options:

Returns {:ok, %{snapshot: id_or_nil}}, or {:error, {:setup_failed, status, tail}} with the end of the output.

resume(sandbox, script, opts \\ [])

Runs a resume script. Takes prepare/3's options but :snapshot.