pi-control-bridge 0.3.10
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.
Potentially problematic release.
This version of pi-control-bridge might be problematic. Click here for more details.
- package/README.md +98 -0
- package/bridge.config.example.json +10 -0
- package/dist/bridge/main.js +4173 -0
- package/extension/bridge_client.ts +76 -0
- package/extension/command_handler.ts +39 -0
- package/extension/ensure_bridge.ts +78 -0
- package/extension/hooks.ts +291 -0
- package/extension/index.ts +7 -0
- package/extension/messages.ts +132 -0
- package/extension/session_metadata.ts +84 -0
- package/extension/session_status.ts +19 -0
- package/package.json +47 -0
- package/shared/agent_dir.ts +17 -0
- package/shared/ansi.ts +9 -0
- package/shared/config.ts +152 -0
- package/shared/constants.ts +13 -0
- package/shared/device_state.ts +21 -0
- package/shared/locale.ts +30 -0
- package/shared/logger.ts +54 -0
- package/shared/migrate.ts +39 -0
- package/shared/telegram.ts +136 -0
- package/shared/types.ts +107 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# pi-control-bridge
|
|
2
|
+
|
|
3
|
+
Pi package + singleton bridge runtime for integrating [pi-control-hub](https://github.com/CodeOnTime-tech/pi-control-hub) with Pi agent sessions.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
- **Extension** (`extension/`) — Pi lifecycle hooks, command consumer, event proxy.
|
|
8
|
+
- **Bridge runtime** (`bridge/`, bin `pi-bridge`) — singleton process: device registration, heartbeat, command polling, IPC server.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install
|
|
14
|
+
npm run build
|
|
15
|
+
pi install /absolute/path/to/pi-control-bridge
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or add to `~/.pi/agent/settings.json`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"packages": ["npm:pi-control-bridge"]
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The npm package ships a prebuilt `dist/bridge/main.js` — no build step is required after `pi update`.
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
Config is loaded from JSON files (no environment variables). Priority from low to high:
|
|
31
|
+
|
|
32
|
+
1. **Defaults** — built into the package
|
|
33
|
+
2. **User config** — `~/.pi/agent/bridge/config.json`
|
|
34
|
+
3. **Project config** — `.pi/bridge.json` (nearest ancestor of Pi `cwd`)
|
|
35
|
+
|
|
36
|
+
Copy [`bridge.config.example.json`](bridge.config.example.json) as a starting point.
|
|
37
|
+
|
|
38
|
+
| Key | Default | Description |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `hub_url` | `http://127.0.0.1:8000` | pi-control-hub base URL |
|
|
41
|
+
| `poll_interval_sec` | `2` | Command polling interval |
|
|
42
|
+
| `heartbeat_interval_sec` | `15` | Device heartbeat interval |
|
|
43
|
+
| `bridge_data_dir` | `~/.pi/agent/bridge` | State and retry queue directory |
|
|
44
|
+
| `ipc_port` | `9473` | Local IPC HTTP port |
|
|
45
|
+
| `auto_start_bridge` | `true` | Auto-start bridge on session |
|
|
46
|
+
|
|
47
|
+
Runtime state (secrets): `~/.pi/agent/bridge/state.json` (`device_token`, `device_id`).
|
|
48
|
+
|
|
49
|
+
Data from the legacy `~/.pi/bridge/` directory is migrated automatically on first load.
|
|
50
|
+
|
|
51
|
+
### Example user config
|
|
52
|
+
|
|
53
|
+
`~/.pi/agent/bridge/config.json`:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"hub_url": "https://hub.example.com"
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Example project config
|
|
62
|
+
|
|
63
|
+
`.pi/bridge.json` in your repo:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"hub_url": "http://127.0.0.1:8000"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Slash commands
|
|
72
|
+
|
|
73
|
+
- `/control-status` — bridge, backend and Telegram connection status
|
|
74
|
+
- `/connect-telegram` — start Telegram binding; shows a direct link to open the bot
|
|
75
|
+
|
|
76
|
+
Hub must return `bot_username` (or `bot_link`) from `POST /telegram/link-token` and Telegram
|
|
77
|
+
connection info from `GET /me?device_token=...` for full status output.
|
|
78
|
+
|
|
79
|
+
## Manual bridge
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pi-bridge start
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Normally the extension starts the bridge automatically on `session_start`.
|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install
|
|
91
|
+
npm run build
|
|
92
|
+
npm test
|
|
93
|
+
npm run check
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Hub prerequisite
|
|
97
|
+
|
|
98
|
+
Device re-register via `POST /devices/register` with `device_token` must be supported by pi-control-hub.
|