Commit e2b5acb
mios-agent-pipe: standalone FastAPI scaffold (commit 1 of 5)
Step 1 of the migration to extract MiOS-Agent's router + refine +
critic chain out of the OWUI Pipe class into a gateway-agnostic
HTTP service.
Operator directive 2026-05-18: "mios discord chats not going through
MiOS-Agent(OWUI) paths when contacting through discord (uses only
MiOS-Hermes and doesn't have the same tool understanding and
environments details now!!!!)" -- chosen architectural path:
"Standalone pipe service (recommended, bigger lift)".
Architecture:
OWUI ──┐
Hermes Discord gateway ──┼──> :8640 (mios-agent-pipe)
│ │
future Slack/Telegram ──┘ ▼
:8642 (hermes-agent)
│
▼
ollama
NEW: usr/lib/mios/agent-pipe/server.py (~220 lines)
v0 SCAFFOLD -- a transparent OpenAI-compat proxy. Establishes
the deployment shape (port, sysuser, systemd unit, env wiring,
SurrealDB reach) BEFORE the actual router/refine/critic logic
is ported in. Endpoints:
GET /health -> {status, version, backend, port}
POST /v1/chat/completions -> proxy to MIOS_AGENT_PIPE_BACKEND
(streaming + non-streaming)
GET /v1/models -> proxy
POST /v1/embeddings -> proxy
Non-streaming path is robust to backends that return SSE chunks
even when stream=false (hermes-observed): falls back to a 502
envelope with a backend_preview field instead of crashing on a
strict r.json() decode.
NEW: usr/lib/systemd/system/mios-agent-pipe.service
Type=simple, runs uvicorn under the mios-agent-pipe uid. Reuses
the hermes-agent venv interpreter (which already ships fastapi +
uvicorn + httpx + starlette). v1 follow-up: switch to system
python3 + `dnf install python3-fastapi python3-uvicorn` so the
agent-pipe and hermes-agent venvs are decoupled. EnvironmentFile=
/etc/mios/agent-pipe.env is supported for operator overrides.
NEW: usr/lib/tmpfiles.d/mios-agent-pipe.conf
d /var/lib/mios/agent-pipe 0750 822 822 -
NEW: automation/support/hermes-discord-reactions-patch.py
Progressive "thinking" reactions on the Discord side -- adjacent
task (operator directive 2026-05-18 same day "add more reactions
to the MiOS-Hermes Discord bot--Should be using more discord
reactions to show it's thinking!"). Idempotent in-place patch of
the upstream gateway/platforms/discord.py that replaces the
single 👀 emoji surface with a phased sequence:
📡 received -> 🧠 thinking -> 🛠️ tools -> ⏳ working -> ✅/❌
Background asyncio task drives the time-progression so the
gateway's main flow isn't blocked. Per-message id keying so
concurrent in-flight runs don't stomp. Pattern mirrors the
existing hermes-dashboard-shell-patch.py.
SSOT chain entries:
usr/share/mios/mios.toml:
[ports].agent_pipe = 8640
[services.agent_pipe] (user=mios-agent-pipe uid=822 gid=822)
[agent_pipe] section: endpoint, backend, backend_model, enable
tools/lib/userenv.sh:
Slot map gains 7 new dotted->MIOS_* entries
(services.agent_pipe.*, agent_pipe.*, ports.agent_pipe).
usr/lib/sysusers.d/50-mios-services.conf:
mios-agent-pipe at uid 822 (next free after surrealdb=821).
Supplementary groups: systemd-journal + adm (the service is the
critic and needs log read access for run-history aggregation).
usr/share/mios/configurator/mios.html:
New "Agent Pipe" details panel + port + service-uid form fields
so the operator can re-point endpoint / backend / backend_model
without leaving the configurator UI.
Live-verified on podman-MiOS-DEV:
systemctl is-active mios-agent-pipe.service -> active
curl http://localhost:8640/health -> {"status":"ok",...}
streaming chat /v1/chat/completions -> reaches hermes, bytes
stream back
Step 2 (next commit) ports the router/refine/critic/SurrealDB logic
from usr/share/mios/owui/pipes/mios_agent_pipe.py into this server.
Step 3 collapses the OWUI pipe to a thin forwarder. Step 4 re-points
Hermes Discord gateway at this service. Step 5 verifies end-to-end.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 24c258d commit e2b5acb
8 files changed
Lines changed: 526 additions & 0 deletions
File tree
- automation/support
- tools/lib
- usr
- lib
- mios/agent-pipe
- systemd/system
- sysusers.d
- tmpfiles.d
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
316 | 325 | | |
317 | 326 | | |
318 | 327 | | |
| |||
0 commit comments