pi-pocket README

The project's README from github.com/TannerMidd/pi-pocket. As one markdown file: README.md.

Pi Pocket

Your Pi coding agent, in your pocket.

A durable, multiplayer, mobile-first web app for Pi agents, built on Pi Durable.
Runs on your own machine or directly on your phone. No cloud VM.

Release Node.js 22.19+ MIT license

Website · Quick start · Features · Remote access

Pi Pocket in the Tokyo Night theme, on a desktop and a phone. On the desktop, the session list beside a conversation where Pi has fixed a sign-in redirect loop, its edits and a passing run of 48 tests folded into a timeline. On the phone, the same session after a teammate, Alex, asks for the push: Lancet Guard waits for approval before git push.

Quick start

Requires Node.js 22.19 or newer. Runs on Linux, macOS, Windows, and Android (Termux); Linux is the most tested. Sign in to a provider with Pi first (pi, then /login), or later from the app's Providers sheet.

git clone https://github.com/TannerMidd/pi-pocket.git
cd pi-pocket
npm install
npm start

The launcher asks how your devices should connect, then prints the address, a sign-in link, and a QR code. Open the link once per browser; the cookie lasts a year. The link is the owner's key, so keep it private. --rotate-token replaces it and signs out every device that used the old link; people you invited stay signed in until you remove them under Menu → People.

While it runs: q quit · r restart server · a change access · o open in browser · s show QR code.

Features

The full tour is in docs/features.md.

Remote access

Choose a mode in the launcher, or pass --access:

Mode Who can connect Notes
local This machine Listens on 127.0.0.1
lan Your local network All addresses, plain http
cloudflare Anyone with the link Free quick tunnel with https, no account needed (Cloudflare offers quick tunnels for testing and development). The address changes each time the launcher starts but stays the same across server restarts.
tailscale Your tailnet Tailscale address only, encrypted by the tailnet

Cloudflare mode needs cloudflared. On Linux the launcher can download the official release into ~/.pi-pocket/bin. To use another tunnel (ngrok, tailscale serve), choose local and point the tunnel at port 8787.

[!WARNING] Anyone with steering rights can make the agent run commands on this machine, as you. That reaches everything you can: your files, Pi Pocket's own settings and sign-in tokens, and its code. A single-session invite limits what someone sees in the app, not what Pi can reach, and Lancet Guard approvals can come from anyone who can steer, including the person who asked. People who can steer every session can also invite others. Invite only people you would trust at your keyboard. View-only users cannot make Pi act.

Android (Termux)

pkg update && pkg upgrade
pkg install nodejs git
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
pi                      # /login, then quit
# copy or clone pi-pocket to the phone, then:
cd pi-pocket && npm install --ignore-scripts && npm start

Open the link in Chrome and choose Add to Home screen. Run termux-wake-lock so Android does not stop Termux.

Lancet Guard needs ONNX Runtime, which may not load on Android. If the guard is on but cannot load, Pi Pocket blocks bash, write, and edit calls (the status line shows "guard failed"). Turn it off in the app (Menu → Extensions), in ~/.pi/lancet-guard.json, or by starting with PI_POCKET_GUARD=off.

Configuration

Option Default Purpose
--access <mode> last choice Skip the access menu
-y Reuse the last access choice
--port 8787 Port to listen on
--cwd current folder Default folder for new sessions
--data ~/.pi-pocket Database, settings, uploads, and push keys
--host Listen on a specific address instead of choosing access
--rotate-token Issue a new owner link and sign out devices that used the old one

Environment variables: PI_POCKET_ACCESS, PI_POCKET_DIR, PI_POCKET_HOST, PI_POCKET_PORT, PI_POCKET_GUARD=off, PI_POCKET_BROWSER (the browser to run, when Chromium or Chrome is not found by itself), and PI_POCKET_BROWSER_ARGS (extra flags for it, such as --no-sandbox where sandboxes are unavailable). Without a terminal (under systemd, for example), the launcher uses --access or the last choice.

Architecture

Path Role
bin/pi-pocket.js Entry point: checks the Node version, starts the launcher
src/launcher/ Access menu, server supervisor, Cloudflare tunnel, keys, QR code
src/server/app.ts The core: the durable harness over pocket.sqlite, the coordinator every commit goes through, connected tabs, access, and the session list
src/server/attribution.ts, workspace.ts, transcripts.ts Who Pi works for; a conversation's folder and its stored history, as people reach them
src/server/room.ts One conversation's shared live view, sent to every tab watching it
src/server/commands.ts What people ask of Pi: messages, forks, models, plan mode, goals, schedules, worktrees
src/server/collab.ts The people's side: chat, activity lines, reactions, pins, notes, take turns
src/server/http.ts, http/ Web files, JSON API, server-sent events, uploads, artifacts, invites, the Browser panel's frames and input
src/server/browser.ts, browser/ The built-in browser: one headless Chromium over the DevTools protocol, a page per conversation
src/server/projection.ts Turns committed conversation state into compact JSON for browsers
src/server/docs.ts Durable documents: sessions, chat, pins, notes, artifacts, subagents, schedules, goals, spend
src/server/schedules.ts, goals.ts, spend.ts, changes.ts, branches.ts, worktrees.ts One feature each, with its durable tasks or git calls
src/server/push.ts, alerts.ts Dependency-free Web Push (RFC 8291 and RFC 8292), and who gets which notification
src/server/extensions/ Live-reloaded extensions: system prompt, artifacts, browser, subagents, schedules, goals, plan mode, Lancet Guard, codemode
web/ The app: Preact and htm as plain ES modules

Browsers render only committed state. Each session's Pi Durable view is coalesced and sent as small updates over server-sent events, so a device that reconnects or joins late sees exactly what everyone else sees. The engineering page explains the design; docs/map.md is a short map of the code.

Development

npm run check   # type-check
npm test        # server tests with a scripted model
npm run format  # ESLint's layout fixes, then Prettier
npm run lint    # check the layout rules

Changes to web/ reload every open browser. Changes to src/server/extensions/ are reinstalled into the running server. Other server changes need Restart server from the menu, and running work resumes afterward. AGENTS.md covers editing Pi Pocket safely from inside itself, and node test/serve.ts runs a throwaway copy, with its own data and a scripted model, to check a change on.

Pi knows where Pi Pocket's own documentation is: docs/index.md starts it, for agents and people who change how Pi works without code (customizing), write extensions (extensions, with tested examples), or change Pi Pocket itself while it runs (self-editing).

Limitations

Credits

Inspired by Mario Zechner's demo of his own Pi app. Pi Pocket is an independent project, not affiliated with Earendil. JetBrains Mono is bundled under the SIL Open Font License.

License

MIT. To report a security problem, see SECURITY.md.

pi-pocket (TannerMidd/pi-pocket)

Searching Database…

这是什么?Pi Pocket 是一个稳定耐用、支持多人同时使用、以手机为先的网页应用,让你在自己电脑或手机上运行 Pi 编程代理会话,不需要云虚拟机。
这是我自己搭建的服务,还是云端服务?它是自托管应用:你在自己的电脑或手机上运行 Node 启动器,然后通过本地网络、局域网、Cloudflare 快速隧道或 Tailscale 把它暴露出去,而不是连接任何云虚拟机。
怎么把它跑起来?先安装 Node.js 22.19+,用 Pi 登录一个提供商(先运行 pi,再输入 /login),然后运行启动器;它会询问设备之间如何连接,并打印出一个地址、一个登录链接和一个二维码。
我需要先设置好 Pi 编程代理吗?需要。Pi Pocket 只是 Pi 的一个前端界面:它直接复用 Pi 本身的模型运行时、登录、技能和提示词模板,所以你只需按会话选择模型和提供商,不用另外配置后端。
在依赖它之前,最大的坑是什么?同一时间只能有一个服务器进程访问数据库;Pi Durrent 仍是实验性功能,其 API 可能随版本更迭而变化;此外虽然启动器能在 Windows 上运行,但 Windows 支持尚未经过测试。
在手机上真的能用吗?可以。它就是按主屏幕 PWA 设计的:在 Android 上用 Chrome 打开链接,选择“添加到主屏幕”,并运行 termux-wake-lock 让 Termux 在后台保持运行。
一旦我邀请别人加入会话,对方能做多少事?任何被授予 steering(干预)权限的人都能以你的身份在你的电脑上让代理执行命令,访问你的文件以及 Pi Pocket 自身的设置和令牌;只有只读邀请才被限制,不能让 Pi 执行操作。
PiP 是什么?PiP(“Pi in Pocket”,即“口袋里的 Pi”)用 Alt+A 打开,是一个悬浮助手面板:它可以列出、读取、启动你的其他会话并向它们发消息,跟踪它们的运行状态,还能监视一个 GitHub 仓库或 PR 并响应 webhook。
Codemode 是干什么的?Codemode 默认开启,它让 Pi 编写简短的脚本来批量调用自己的工具,而不是一个一个地调用;不过每次调用仍然要经过同样的审批检查。
Lancet Guard 是什么?一个可选扩展(默认关闭),它会让有风险的 bash、写入和编辑调用先等待会话中的某人批准;它依赖 ONNX Runtime,而这个组件在 Android 上可能加载失败。
它为什么自带 Omarchy 主题?它的界面复刻了每一款 Omarchy 桌面主题(也可以实时跟随你的系统主题),采用 Hyprland 风格的平铺窗口和 Walker 风格的启动器,因此在外观上与它一同开发的 Omarchy Linux 环境保持一致。
What are similar projects?herdr-web-ui, 1code, pi-harness, foreman, bivor, learn, Choruz, fleetbase
Creator
TannerMidd
Size
9.1 MB
Stars
465
Age
14d
Commits · 90 Days