pi-web is a Bun monorepo for exposing the Pi mono CLI agent to the web through pi --mode rpc.
The repo keeps Pi server-side, adapts its newline-delimited JSON RPC stream into AI SDK UI message chunks, and renders the result with AI SDK Elements-style chat components in a Next.js demo.
@pi-web/client: shared Pi protocol types plus the Node-side RPC process wrapper and session registry.@pi-web/react: a React client built onuseChatand the AI SDK default chat transport.@pi-web/next: Next.js App Router helpers, includingcreatePiChatHandlerfor/api/chat.@pi-web/demo: a Next.js App Router demo that uses AI Elements components for messages, reasoning, tools, and prompt input.
- Bun
piinstalled and available onPATH
bun install
bun run typecheck
bun run build
bun run smoke:rpc
bun run devThe demo app runs on http://localhost:3000.
The demo registry reads a few optional environment variables:
PI_WORKSPACE_DIR: working directory Pi should inspect. Defaults to the repo root.PI_TOOLS: comma-separated tool allowlist. Defaults toread,grep,find,ls.PI_SESSION_MODE:ephemeralorpersistent. Defaults toephemeral.PI_SESSION_DIR: session directory used whenPI_SESSION_MODE=persistent.
- Browser UI:
usePiChat()from@pi-web/reactplus AI Elements chat primitives. - Next.js route:
POST /api/chatviacreatePiChatHandler(). - Session layer:
PiSessionRegistrykeeps one Pi subprocess per chat/session id. - Process layer:
PiRpcClientspawnspi --mode rpcand parses LF-delimited JSONL from stdout. - Transport: AI SDK UI chunks streamed as SSE to the browser.
The demo also keeps the lower-level /api/pi/* routes for direct transport debugging.
apps/
demo/ Next.js + AI Elements reference app
docs/ architecture, package, deployment, and skill docs
packages/
client/ Pi RPC wrapper and session manager
react/ AI SDK React hook wrapper
next/ Next.js route helpers
skills/ repo-local Codex skills for implementing or consuming pi-web
bun run build
bun run typecheck
bun run test
bun run smoke:rpc