@aiti-ai/pi-web-bridge 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aiti-ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @aiti-ai/pi-web-bridge
2
+
3
+ > Bridge a [pi](https://pi.dev) TUI session to the browser with `/web` — the pi-web side opens the same session live, with bidirectional IO (prompt / steer / follow-up / abort / model switching), queued-message echo, and image attachment passthrough.
4
+
5
+ A small [pi package](https://pi.dev/packages) that pairs with the [pi-web](https://github.com/aiti-ai/pi-web) attach backend (`aiti-attach-agent`).
6
+
7
+ ## 来源 · Origin
8
+
9
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
+
11
+ This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
12
+
13
+ - 工作台 / workbench: <https://github.com/aiti-ai/pi-web>
14
+ - 生态仓库 / monorepo: <https://github.com/aiti-ai/aiti-ai>
15
+ - 官网 / site: <https://aiti.pw>
16
+
17
+ ## What it does
18
+
19
+ Run `pi` in a terminal as usual, then:
20
+
21
+ - **`/web`** — interactive wizard: pick *attach* (rpc bridge; browser and TUI work the session together) or *takeover* (pi-web runs the pi SDK in-process and the TUI hands the session over), optionally spawn a new pi-web and open the browser.
22
+ - **`/web --attach --no-spawn --no-open`** — direct mode: start the bridge and attach to an already-running pi-web.
23
+ - **`/web off`** — stop the bridge.
24
+
25
+ While bridged:
26
+
27
+ - Every agent event streams to the browser (messages, tool calls, turns, model changes).
28
+ - Input from the browser is forwarded into the TUI session: prompt, steer (interrupt), follow-up (queue), abort, model / thinking-level switching, compact, session rename — plus the registered slash commands list.
29
+ - Messages queued while the model is streaming are echoed to the browser (`queue_update` mirror synthesized inside the bridge — pi does not forward queue events to extensions).
30
+ - Image attachments sent from the browser are validated and passed through to the session.
31
+ - The session shows a `tui-bridge` tag in the pi-web "All Sessions" panel, and session ownership stays with the pi process (single-writer rule — the web side attaches to the socket, never opens the file).
32
+
33
+ ### Full-auto mode
34
+
35
+ Export `PI_WEB_BRIDGE_AUTO=1` in your shell profile and every plain terminal `pi` session starts the bridge automatically on boot (no `/web`, no wizard): open the session from any running pi-web instance and watch / interact live. Idle sessions exit on their own after 10 minutes (`PI_WEB_IDLE_TIMEOUT_MS`, `0` disables).
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ pi install @aiti-ai/pi-web-bridge
41
+ ```
42
+
43
+ Requires a running [pi-web](https://github.com/aiti-ai/pi-web) (the `aiti-attach-agent` extension ships with it) — that is the browser side this bridge pairs with. See the pi-web README for how to run it.
44
+
45
+ ## Configuration (environment)
46
+
47
+ | Variable | Meaning |
48
+ |---|---|
49
+ | `PI_WEB_BRIDGE_AUTO=1` | Auto-start the bridge on every TUI session start |
50
+ | `PI_WEB_BRIDGE_BASE` | URL of a running pi-web (used for URL derivation and aiti_* tool routing) |
51
+ | `PI_WEB_BRIDGE_PORT` | Default port for spawned pi-web (default `3000`) |
52
+ | `PI_WEB_BRIDGE_ENTRY` | Command used to spawn pi-web (default `pi-web`) |
53
+ | `PI_WEB_BRIDGE_LANG` | UI language: `zh` or `en` (defaults from the locale) |
54
+ | `PI_WEB_IDLE_TIMEOUT_MS` | Auto-bridge idle exit timeout (default `600000`, `0` disables) |
55
+
56
+ `/web` also accepts flags: `--port`, `--base`, `--domain`, `--scheme`, `--webport`, `--takeover` / `--attach`, `--open` / `--no-open`, `--spawn` / `--no-spawn`.
57
+
58
+ ## How it works
59
+
60
+ ```
61
+ pi TUI ── /web ──▶ Unix-socket JSONL bridge ◀── attach ── pi-web (aiti-attach-agent)
62
+ (events out, commands in) │
63
+ └─ bridge-registry.json
64
+ ~/.pi/agent/bridge-registry.json maps live session
65
+ files → sockets so pi-web attaches instead of opening
66
+ the file (single-writer rule)
67
+ ```
68
+
69
+ The extension registers a socket server inside the pi process, forwards agent events, translates browser commands into pi APIs, and keeps a registry (`~/.pi/agent/bridge-registry.json`) that pi-web consults when opening a session. The second entry point (`dist/aiti-devtools-pi.js`) is the aiti-devtools connector bundle: when the [aiti-devtools](https://github.com/aiti-ai/aiti-ai) MCP bridge is in play, its tools route through this same socket to the page pi-web is showing.
70
+
71
+ ## 文档 · Documentation
72
+
73
+ - 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-attach-agent.html>
74
+ - English docs: <https://aiti.pw/en/extensions/aiti-attach-agent.html>
75
+
76
+ ## License
77
+
78
+ MIT