You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mirror aicodebox env var rename + add PIBOX_MCP_MODE
aicodebox v0.2.0 normalized every mode env var to <MODE>_MODE /
<MODE>_MODE_<KNOB>. The pibox alias map and README follow:
PIBOX_MODE_API → PIBOX_API_MODE
PIBOX_MODE_API_PORT → PIBOX_API_MODE_PORT
PIBOX_MODE_API_TOKEN → PIBOX_API_MODE_TOKEN
PIBOX_MODE_TELEGRAM → PIBOX_TELEGRAM_MODE
PIBOX_TELEGRAM_BOT_TOKEN → PIBOX_TELEGRAM_MODE_TOKEN
PIBOX_TELEGRAM_CONFIG → PIBOX_TELEGRAM_MODE_CONFIG
PIBOX_TELEGRAM_OVERRIDES → PIBOX_TELEGRAM_MODE_OVERRIDES
PIBOX_MODE_CRON → PIBOX_CRON_MODE
PIBOX_MODE_CRON_FILE → PIBOX_CRON_MODE_FILE
PIBOX_CRON_HISTORY_DIR → PIBOX_CRON_MODE_HISTORY_DIR
MCP is now its own toggle (PIBOX_MCP_MODE=1) on top of the foreground
mode. In API mode it stays mounted at /mcp (gated on MCP_MODE=1 now,
not always-on); in telegram/cron/passthrough it spawns as a sidecar
uvicorn on PIBOX_MCP_MODE_PORT (default 8081). Auth via
PIBOX_MCP_MODE_TOKEN — own bearer, no fallback to API_MODE_TOKEN.
E2E tests updated to the new AICODEBOX_* names they pass to docker
run, and the API test fixture now enables MCP_MODE + shares the API
bearer with MCP so the existing /mcp handshake + auth assertions
stay valid.
.env.test.example bumps AICODEBOX_TELEGRAM_BOT_TOKEN to
AICODEBOX_TELEGRAM_MODE_TOKEN. README rewritten around the new shape
with explicit MCP mode + coexistence sections.
@@ -44,11 +44,13 @@ docker run -d --network host \
44
44
45
45
## Modes
46
46
47
-
One mode per container, with one exception: `PIBOX_MODE_TELEGRAM=1` and `PIBOX_MODE_CRON=1` can run together — cron runs in-thread inside the telegram process. API mode always takes priority if set alongside anything else.
47
+
**Foreground modes** (API / Telegram / Cron) are mutually exclusive — except `PIBOX_TELEGRAM_MODE=1` + `PIBOX_CRON_MODE=1`, which run together (cron in-thread inside telegram). API wins if set alongside anything else.
48
+
49
+
**MCP mode** (`PIBOX_MCP_MODE=1`) is independent — it coexists with whatever foreground mode is running. In API mode it's mounted at `/mcp` on the API port; in other modes it runs as a sidecar uvicorn on its own port.
48
50
49
51
### API mode
50
52
51
-
`PIBOX_MODE_API=1`. FastAPI server on `:8080` (override with `PIBOX_MODE_API_PORT`).
53
+
`PIBOX_API_MODE=1`. FastAPI server on `:8080` (override with `PIBOX_API_MODE_PORT`).
52
54
53
55
| Method | Path | What it does |
54
56
|--------|------|--------------|
@@ -64,7 +66,7 @@ One mode per container, with one exception: `PIBOX_MODE_TELEGRAM=1` and `PIBOX_M
64
66
|`DELETE`|`/files/{path}`| delete a file (refuses directories — 400) |
|`POST`|`/mcp`| MCP server (streamable HTTP) — mounted only when `PIBOX_MCP_MODE=1`|
68
70
69
71
All `/files/*` paths are resolved against the workspace root with traversal checking — `..` segments that escape the root return 400. Same `Authorization: Bearer ...` token gates them as the rest of the API.
- Text in → pi runs → Markdown→HTML rendered response back.
105
107
- File uploads land in the chat's workspace. `[SEND_FILE: path]` in pi's output delivers workspace files as Telegram attachments.
106
108
- Per-chat overrides: `/model`, `/effort` (maps to pi's `--thinking` levels), `/system_prompt`, `/append_system_prompt`. Persisted across restarts.
107
109
-`/cancel` kills the in-flight run. `/reload` re-reads config. `/config` dumps merged settings. `/fetch <path>` downloads a file.
108
110
- Replies to cron messages inject the job's instruction + result so pi has full context for follow-ups.
109
111
110
-
Config at `$HOME/.aicodebox/telegram.yml` (override via `PIBOX_TELEGRAM_CONFIG`):
112
+
Config at `$HOME/.aicodebox/telegram.yml` (override via `PIBOX_TELEGRAM_MODE_CONFIG`):
111
113
112
114
```yaml
113
115
allowed_chats: [-100123, 42]
@@ -122,7 +124,7 @@ chats:
122
124
123
125
### Cron mode
124
126
125
-
`PIBOX_MODE_CRON=1` + `PIBOX_MODE_CRON_FILE=/path/to/cron.yaml`. 6-field schedules via croniter. Each job fires pi with the given instruction.
127
+
`PIBOX_CRON_MODE=1` + `PIBOX_CRON_MODE_FILE=/path/to/cron.yaml`. 6-field schedules via croniter. Each job fires pi with the given instruction.
126
128
127
129
```yaml
128
130
jobs:
@@ -139,28 +141,60 @@ jobs:
139
141
140
142
Each run gets a history dir at `$HOME/.aicodebox/cron/history/<workspace>/<timestamp>-<job>/` with `meta.json`, `stdout.log`, `stderr.log`, `result.txt`. If telegram is configured, `telegram.json` lands there too and the next run's prompt gets a "prior run" hint so pi can reference its own history without you wiring it up.
141
143
144
+
### MCP mode
145
+
146
+
`PIBOX_MCP_MODE=1`. Exposes the MCP (Model Context Protocol) surface — `run_prompt`, `list_files`, `read_file`, `write_file`, `delete_file` as tools. Coexists with any foreground mode:
147
+
148
+
| Foreground | MCP placement |
149
+
|---|---|
150
+
| API mode (`PIBOX_API_MODE=1`) | mounted at `/mcp` on the API port — no extra process |
Auth: `PIBOX_MCP_MODE_TOKEN=<token>`— bearer in the `Authorization: Bearer …` header, or `?apiToken=…` for clients that can't set headers. Empty = no auth. **No fallback to `API_MODE_TOKEN`** — MCP has its own bearer.
154
+
142
155
## Configuration
143
156
144
-
Every var below is `PIBOX_*`. The image is built on top of [aicodebox](https://github.com/psyb0t/docker-aicodebox), so the original `AICODEBOX_*` names also work — the entrypoint translates `PIBOX_X` to `AICODEBOX_X` when only the pibox-prefixed one is set. If you set both, `AICODEBOX_*` wins.
157
+
Naming convention: `PIBOX_<MODE>_MODE=1`is the on/off flag, `PIBOX_<MODE>_MODE_<KNOB>=...` is its config. Non-mode-scoped vars (workspace, container name, available models) are bare.
158
+
159
+
The image is built on top of [aicodebox](https://github.com/psyb0t/docker-aicodebox), so the equivalent `AICODEBOX_*` names also work — the entrypoint translates `PIBOX_X` to `AICODEBOX_X` when only the pibox-prefixed one is set. If you set both, `AICODEBOX_*` wins.
160
+
161
+
### Mode flags
162
+
163
+
| Var | Default | What it does |
164
+
|-----|---------|--------------|
165
+
| `PIBOX_API_MODE` | `0` | Boot the HTTP API server (foreground) |
0 commit comments