Skip to main content
Pi Durable is Pi’s durable agent harness: conversations, turns and tool calls are stored before anything is shown, so a restarted process picks a run up where it stopped. Its built-in tools (read, write, edit, bash, code mode) reach files and commands only through an ExecutionEnv. @struktoai/mirage-pi-durable provides one over a Mirage Workspace, so the tools work on whatever the workspace mounts.

Install

Usage

Install Pi’s coding tools and the Mirage extension, and build a MirageExecutionEnv for each call:
mirageExtension adds a mirage prompt section that describes the mounts. The conversation’s cwd (root.configure({ cwd })) reaches the environment, so each conversation can work in its own directory.

Durable runs

Open the harness on stored state to keep conversations across restarts. The workspace’s files persist as their mounts do:

Behavior

  • Commands run in Mirage’s shell as one session. Each call starts from its cwd, so a cd or export does not carry over to the next one, as with a new process.
  • Sessions: pass sessionId to act as a Mirage session, under its profile’s mounts, hides and policies. A refused command’s output ends with the policy’s reason.
  • Long output past Pi’s bounds is written to a file under /tmp as it arrives, which needs a writable mount there. A command cancelled after that keeps its file.
  • Mount roots cannot be removed or renamed, nor can a folder holding one, as in the shell.
  • Watching polls: every watch.pollIntervalMs, Pi compares snapshots of each watched path, asked of the backend each time. A file new to a remote folder shows once the mount’s listing of that folder refreshes.
  • Binary reads copy the file when Pi opens it, so a later rename or rewrite of the path does not reach an open reader.

Exports

MirageExecutionEnv accepts:

Examples