@daytona/pi

中文文档
0.191.2发布于 2026/10/01Apache-2.0ES Module构建来源已验证近 30 天下载 3704

Pi coding agent extension that runs all tool calls inside a remote, ephemeral Daytona sandbox while the agent runs locally

原始使用文档
文档目录15 节
  1. Features
  2. Usage
  3. Installation
  4. Environment Configuration
  5. Running Pi
  6. How It Works
  7. Lifecycle
  8. GitHub branch sync
  9. Tools
  10. Development
  11. Setup
  12. Development and Testing
  13. Publishing
  14. Project Structure
  15. License

Daytona Sandbox Extension for Pi

This is a Pi extension that runs every Pi tool call inside a Daytona sandbox. The agent runs on your machine, while bash, file I/O, and search execute in a remote sandbox that is created when you launch Pi with --daytona, kept with your session (and reattached when you resume it), and deleted when you delete that session.

Features

  • Runs Pi's tool calls in an isolated Daytona sandbox while the agent stays on your machine
  • Clones the repo you're in (or a --repo you pass) into the sandbox automatically
  • Syncs each session to its own GitHub branch — the agent commits, the extension pushes
  • Keeps one sandbox per session and reattaches it when you resume
  • Generates live preview links when a server starts in the sandbox

Usage

Installation

First, install Pi:

npm install -g @earendil-works/pi-coding-agent

See pi.dev for other install options.

Then add the Daytona extension to Pi:

pi install npm:@daytona/pi

[!NOTE] To update the extension later, run pi update — pi install won't refresh an existing install.

Environment Configuration

This extension requires a Daytona account and Daytona API key to create sandboxes.

Set your Daytona API key as an environment variable (e.g. in your shell profile):

export DAYTONA_API_KEY="your-api-key"

The extension also reads these optional variables:

  • DAYTONA_API_URL — defaults to https://app.daytona.io/api.
  • DAYTONA_TARGET — e.g. us.

If no key is set and a UI is available, Pi prompts you for one once per session.

Running Pi

Run Pi from inside a git repository:

cd my-project
pi --daytona

The extension clones the repo you're in into the sandbox and syncs your work to a GitHub branch (see GitHub branch sync).

Or point at a different repository:

pi --daytona --repo github.com/acme/api --branch dev

Or run outside a git repo to get a blank workspace.

Flags

FlagDescription
--daytonaRun tools inside a Daytona sandbox
--repo <url>Git repo to clone into the sandbox (defaults to the repo you're in)
--branch <name>Branch to clone (defaults to your current branch)
--snapshot <name>Choose a Daytona snapshot / base image
--publicCreate a public sandbox so preview URLs need no token

Slash commands

While Pi is running with --daytona, you can manage the active sandbox:

  • /sandbox — show the active sandbox's status: state, working directory, branch, sync status, and its GitHub branch link
  • /github — open this session's branch on GitHub
  • /compare — open this session's branch compare view on GitHub
  • /merge — merge this session's branch into its base on GitHub
  • /pr — open a GitHub pull request for this session's branch

How It Works

The agent runs on your machine. Pi's tool layer is pluggable, so this extension substitutes Daytona-backed implementations of bash, read, write, edit, and ls, plus dedicated in-sandbox tools for find and grep. A footer badge is the always-visible signal that work is remote.

Lifecycle

  • One sandbox per session, kept across runs. A session's sandbox is recorded and reattached when you resume the session — your work and environment persist.
  • Idle pauses the sandbox after 15 min (autoStopInterval, overridable with --idle-stop <minutes>). Its filesystem is preserved; resuming transparently restarts it.
  • Deleted when the session is. When you delete a session from Pi's resume menu, its sandbox is reaped on the next Pi launch/exit (Pi has no session-deleted hook, so the extension reconciles live sessions against its sandboxes). There is no auto-delete timer — a sandbox lives until its session is gone.
  • In-memory sessions (--blank / no session) can't be resumed, so their sandbox is deleted on exit.

GitHub branch sync

If you're in a github.com repo and logged in via the GitHub CLI (gh auth login), each session gets its own branch and the agent's commits are pushed there automatically. The repo comes from --repo, or — when you omit it — is detected from the git project you launched Pi in (its origin and current branch).

  • On start, the extension creates pi/<short-session-id> on GitHub (off your current branch, or --branch) and clones it into the sandbox over HTTPS.
  • The agent commits its own work — it's prompted to commit after making changes, and not to push. After each turn the extension pushes those commits to the branch via the Daytona git API. A branch with nothing new is skipped.
  • /merge merges the branch into its base, and /pr opens a pull request.
  • Forks start a fresh sandbox and branch off the parent session's branch.

All network git operations (clone/push) run inside the sandbox through Daytona; the host only uses gh to mint a token and call the GitHub API. A temporary git identity is configured in the sandbox so commits work out of the box.

[!NOTE] When you're not in a github.com repo (or gh isn't authenticated), push is disabled. The sandbox still gets a local git repo so the agent can commit, but nothing is pushed.

Tools

ToolWhat it does
bash (+ user !)Run a command in the sandbox; backgrounded processes (&) don't hang the agent
readRead a file from the sandbox
writeWrite a file to the sandbox
editEdit a file (download → modify → upload; preserves Pi's exact-match semantics)
lsList a sandbox directory
findFind files by glob inside the sandbox (gitignore-aware, supports path globs)
grepSearch file contents inside the sandbox
preview_url(port)Get a public preview URL for a port — the agent calls this after starting a server

Development

This package lives in the daytona/integrations monorepo under packages/pi-extension, and is self-contained — it has its own package.json, lockfile, and dependencies (no workspace tooling).

Setup

git clone https://github.com/daytona/integrations
cd integrations/packages/pi-extension
npm install

Development and Testing

To modify the extension, edit the source files in this package.

[!NOTE] Because Pi loads extensions as TypeScript via jiti, there is no build step — Pi runs the source directly.

Run from source

Remove any previously installed copy (loading two copies makes every tool and flag conflict):

pi list                        # shows installed packages and their exact source
pi uninstall <source>          # e.g. npm:@daytona/pi — use the source shown by `pi list`

Install the local directory:

pi install .    # add --local to scope it to the current project instead of globally

Run Pi:

DAYTONA_API_KEY=dtn_... pi --daytona

Edits to the source take effect on the next run — no reinstall needed.

Alternatively, load the source for a single run without installing:

DAYTONA_API_KEY=dtn_... pi -e ./index.ts --daytona

Tests

npm run typecheck                 # type-check (tsc --noEmit)
npm run smoke                     # offline: load the extension and check it registers (no API key/network)
npm run test:live                 # end-to-end against real Daytona (needs DAYTONA_API_KEY)

Publishing

Releases are automated: merging this package's release-please Release PR tags it and publishes the TypeScript source to npm (public, with provenance) from the repo's release workflow — there is no manual publish step.

Project Structure

packages/pi-extension/
├── index.ts            # Extension entry point: flags, lifecycle, commands
├── src/                # Daytona-backed tool implementations
│   ├── tools.ts        # Tool registration (sandbox-backed tools + preview_url)
│   ├── auth.ts         # Daytona API key resolution
│   ├── sandbox.ts      # Sandbox resilience layer (auto-restart, exec)
│   ├── ops.ts          # Daytona-backed bash/read/write/edit/ls operations
│   ├── find-tool.ts    # In-sandbox find (ripgrep/find)
│   ├── grep-tool.ts    # In-sandbox grep (ripgrep/grep)
│   ├── github.ts       # Host gh control-plane (token + GitHub API)
│   ├── sync.ts         # Sandbox-side git push (Daytona git API)
│   └── util.ts         # Small shared helpers
├── scripts/            # Offline smoke + live integration tests
├── package.json        # Package metadata (includes the "pi" extensions field)
├── tsconfig.json       # TypeScript config
└── README.md

License

Apache-2.0

版本与发布记录

@daytona/pi 共发布 6 个版本,首次发布于 2026/06/19;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.191.2latest2026/10/011 个月前
0.191.12026/09/181 个月前
0.191.02026/07/074 个月前
0.190.12026/06/234 个月前
0.190.02026/06/234 个月前
0.189.0alpha2026/06/194 个月前

关于 @daytona/pi 的常见问题

@daytona/pi 是什么?

Pi coding agent extension that runs all tool calls inside a remote, ephemeral Daytona sandbox while the agent runs locally

如何安装 @daytona/pi?

在项目目录运行 npm install @daytona/pi,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typebox(^1.1.38)、@earendil-works/pi-coding-agent(>=0.79.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@daytona/pi 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/daytona__pi 是否存在。

@daytona/pi 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@daytona/pi 可以商用吗?

@daytona/pi 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@daytona/pi 的下载量有多少?

根据 npm 官方下载统计,@daytona/pi 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,704 次,日均约 123 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@daytona/pi 还在维护吗?

最新版本 0.191.2 发布于 2026/10/01(1 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/06/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。