pi-freeflow 1.4.2 → 1.4.3

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/README.md CHANGED
@@ -1,279 +1,325 @@
1
- # pi-freeflow 🌊
2
-
3
- > **23 free models. Up to 1M context. Zero API keys. Infinite scale via your own relay pool.**
4
-
5
- Thin by design: model list + dumb relay + log. Host `pi-ai` owns thinking, normalization & provider magic. We just make it free, fast, and unbreakable.
6
-
7
- [![npm version](https://img.shields.io/npm/v/pi-freeflow?style=flat-square&color=00E5FF)](https://www.npmjs.com/package/pi-freeflow)
8
- [![npm downloads](https://img.shields.io/npm/dm/pi-freeflow?style=flat-square)](https://www.npmjs.com/package/pi-freeflow)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
10
- [![Pi](https://img.shields.io/badge/Powered%20by-Pi-7c3aed?style=flat-square)](https://github.com/badlogic/pi-ai)
11
- [![Oh My Pi](https://img.shields.io/badge/Compatible-OMP-black?style=flat-square)](https://github.com/coder/oh-my-pi)
12
-
13
- **Join devs bypassing rate limits with their own relay pools BYO, add as many as you need.**
14
-
15
- ---
16
-
17
- ### Features at a Glance
18
-
19
- | Feature | Description | Value | Cost |
20
- | :--- | :--- | :--- | :--- |
21
- | **23 Curated Free Models** | 9 OpenCode Zen + 14 KiloCode Gateway models, up to 1M context & 512K output | Ceiling Unlocked | **$0** |
22
- | **BYO Relay Pool** | Round-robin load balancing across your Cloudflare Workers & Vercel Edges | Zero Rate Limits | **$0** (your free tiers) |
23
- | **Adaptive Health & Error Detection** | Auto-cooldown on 429 rate limits, 504 timeouts, and socket drops | 0ms Wasted Latency | **$0** |
24
- | **Stream Truncation Resilience** | Stateful SSE terminal tracking (`response.failed` / `response.incomplete` injection) | Zero Host Crashes | **$0** |
25
- | **Smart Model Aliasing** | Clean slash-free & colon-free CLI model names compatible with thinking selectors | DX Optimized | **$0** |
26
- | **Auto-Enabled on Session** | Relay stays enabled in `auto` mode on session start and model switch | Zero Friction | **$0** |
27
- | **Interactive CLI Management** | 10+ `/freeflow` subcommands (`status`, `list`, `use`, `add`, `label`, `remove`, `deploy`, `logs`, `debug`) | Full Control | **$0** |
28
- | **Dumb Proxy That Never Breaks** | `127.0.0.1:18080`, host-normalized, pathname-guarded `/v1/models` | 100% Uptime | **$0** |
29
- | **Observable Real Logs** | `~/.pi/agent/pi-freeflow.log`, 5MB auto-rotation, real-time debug toggle | Observable | **$0** |
30
-
31
- Philosophy: **Thin by design.** We only ship model list + relay proxy + log. Host owns thinking & normalization.
32
-
33
- ---
34
-
35
- ### 23 Curated Models One Command
36
-
37
- ```bash
38
- /model → freeflow → pick
39
- ```
40
-
41
- #### OpenCode Zen (9 Models) Responses & Chat API
42
- Optimized for deep reasoning, long-horizon coding & autonomous agentic workflows.
43
-
44
- | Model ID | Creator / Lab | Context | Max Output | Thinking | Vision |
45
- | :--- | :--- | :--- | :--- | :--- | :--- |
46
- | `muse-spark-1.2-contributor-free` | Meta Superintelligence Labs | **1M** (1.048.576) | **131K** (131.072) | `minimal max` | ✅ |
47
- | `x-preview-f-free` | Ox Alpha | **1M** (1.048.576) | **131K** (131.072) | `low / high / max` | ✅ |
48
- | `mimo-v2.5-free` | Xiaomi MiMo | **1M** (1.048.576) | **131K** (131.072) | `low / medium / high` | ✅ |
49
- | `deepseek-v4-flash-free` | DeepSeek | **1M** (1.000.000) | **384K** (384.000) | `low max` | ❌ |
50
- | `laguna-s-2.1-free` | Poolside | **1M** (1.048.576) | **131K** (131.072) | `low max` | ❌ |
51
- | `nemotron-3.5-lightning-free` | NVIDIA | **1M** (1.000.000) | **262K** (262.144) | `low max` | ❌ |
52
- | `nemotron-3-ultra-free` | NVIDIA | **1M** (1.000.000) | **128K** (128.000) | `low max` | ❌ |
53
- | `hy3-free` | Tencent Hunyuan | **262K** (262.144) | **262K** (262.144) | `low max` | ❌ |
54
- | `big-pickle` | Big Pickle | **200K** (200.000) | **32K** (32.000) | `high / max` | ❌ |
55
-
56
- #### KiloCode Gateway (14 Models) OpenRouter Compatible
57
- Keyless access with `Bearer kilo-free`. Clean slash-free and colon-free CLI aliases supported.
58
-
59
- | Model ID | Creator / Lab | Context | Max Output | Thinking | Vision |
60
- | :--- | :--- | :--- | :--- | :--- | :--- |
61
- | `dots-3-note-preview` (`dots-studio/...:free`) | Dots Studio | **512K** (512.000) | **512K** (512.000) | `openrouter` (auto) | ✅ |
62
- | `step-3.7-flash` (`stepfun/...:free`) | StepFun | **262K** (262.144) | **262K** (262.144) | `openrouter` (auto) | ✅ |
63
- | `nemotron-3-nano-omni` (`nvidia/...:free`) | NVIDIA | **256K** (256.000) | **65K** (65.536) | `openrouter` (auto) | ✅ |
64
- | `nemotron-3-ultra-550b` (`nvidia/...:free`) | NVIDIA | **1M** (1.000.000) | **65K** (65.536) | `openrouter` (auto) | ❌ |
65
- | `nvidia/nemotron-3.5-lightning:free` | NVIDIA | **1M** (1.000.000) | **131K** (131.072) | `openrouter` (auto) | ❌ |
66
- | `nemotron-3-super` (`nvidia/...:free`) | NVIDIA | **262K** (262.144) | **262K** (262.144) | `openrouter` (auto) | ❌ |
67
- | `hy3:free` (`tencent/hy3:free`) | Tencent Hunyuan | **262K** (262.144) | **262K** (262.144) | `openrouter` (auto) | ❌ |
68
- | `north-mini-code` (`cohere/...:free`) | Cohere | **256K** (256.000) | **64K** (64.000) | `openrouter` (auto) | ❌ |
69
- | `laguna-s-2.1:free` (`poolside/...:free`) | Poolside | **1M** (1.048.576) | **131K** (131.072) | `openrouter` (auto) | ❌ |
70
- | `laguna-xs-2.1:free` (`poolside/...:free`) | Poolside | **262K** (262.144) | **32K** (32.768) | `openrouter` (auto) | ❌ |
71
- | `lfm-2.5` (`liquid/lfm-2.5-2.6b:free`) | Liquid AI | **128K** (128.000) | **32K** (32.768) | `openrouter` (auto) | ❌ |
72
- | `kilo-auto` (`kilo-auto/free`) | Kilo Gateway Auto | **256K** (256.000) | **10K** (10.000) | ❌ *(non-thinking)* | ❌ |
73
- | `openrouter` (`openrouter/free`) | OpenRouter Free | **200K** (200.000) | **65K** (65.536) | ❌ *(non-thinking)* | ✅ |
74
- | `content-safety` (`nvidia/...:free`) | NVIDIA | **128K** (128.000) | **8K** (8.192) | ❌ *(non-thinking)* | ✅ |
75
-
76
- ---
77
-
78
- ### How It Works — The Magic: BYO Relays, Zero Rate Limits
79
-
80
- ```
81
- You → 127.0.0.1:18080 (dumb proxy, host-normalized) → x-relay-target → N egress IPs (your pool) → opencode.ai / api.kilo.ai
82
- ↑ host already normalized thinking → proxy just forwards
83
- ```
84
-
85
- 1. **Per-Request Round-Robin**: 10 parallel subagents hit N different egress IPs (your pool size). No thundering herd.
86
- 2. **Adaptive Health & Error Cooldown**: Relays hitting 429, 504, or socket disconnects enter temporary cooldown (30-90s) and automatically move behind healthy candidates. Healthy relays handle traffic with 0ms wasted delay.
87
- 3. **Seamless 429 Roll**: `429 / 408 / 502 / 503 / 504 / 520-530` instant roll to next relay, never 429 to agent.
88
- 4. **Stream Truncation Resilience**: Stateful SSE terminal tracking prevents fatal unhandled stream closed errors when connections drop.
89
- 5. **Direct Fallback Safety Net**: If all relays in the pool are exhausted, transparent direct fetch to upstream.
90
- 6. **Zero Subagent Connect Errors**: 24h `DISK_CACHE_ONLY` model catalog avoids subagents hammering remote catalogs.
91
-
92
- You bring the relays (free tiers). We bring the rolling.
93
-
94
- ---
95
-
96
- ### Interactive Commands Reference (`/freeflow`)
97
-
98
- Manage your relay pool directly from the OMP / Pi terminal:
99
-
100
- ```bash
101
- /freeflow status # View active relay, pool status, and candidates
102
- /freeflow list # List all relays with real-time health badges (✓ / ⚠️ [cooling])
103
- /freeflow use <url|index|label> # Switch active relay
104
- /freeflow add <url> [label] # Add new relay to the pool
105
- /freeflow label <index|url> <name># Assign a friendly label to a relay
106
- /freeflow remove <index|url|label># Remove a relay from the pool
107
- /freeflow on | off | auto # Toggle relay mode (auto = enabled for freeflow)
108
- /freeflow deploy # Guided deploy of ONE Vercel Edge relay (in-memory token)
109
- /freeflow logs [lines] # Inspect recent proxy logs
110
- /freeflow debug on | off # Toggle full HTTP lifecycle debug logging
111
- ```
112
-
113
- ---
114
-
115
- ### Quick Start — 30 Seconds
116
-
117
- #### 1. Install
118
-
119
- **Oh My Pi (Recommended):**
120
- ```bash
121
- omp plugin install pi-freeflow
122
- # or local dev
123
- omp plugin link /path/to/pi-freeflow
124
- ```
125
-
126
- **Pi:**
127
- ```bash
128
- pi install npm:pi-freeflow
129
- ```
130
-
131
- #### 2. Pick a Model
132
-
133
- ```bash
134
- omp
135
- /model → freeflow → muse-spark-1.2-contributor-free (1M) → max
136
-
137
- # or CLI
138
- omp -p --model freeflow/muse-spark-1.2-contributor-free "build me a SaaS"
139
- # or with short alias & thinking level
140
- omp -p --model freeflow/step-3.7-flash:high "solve this bug"
141
- ```
142
-
143
- #### 3. Add Your Free Relays (Scale Infinitely)
144
-
145
- Default ships direct. Add relays via `/freeflow add <url> [label]`.
146
-
147
- **Option A: Cloudflare Workers (100k req/day, no 25s timeout)**
148
- 1. Go to `dash.cloudflare.com` → Workers → Create → Deploy → Edit code
149
- 2. Paste this Worker relay snippet:
150
-
151
- ```js
152
- // Only the 2 upstreams pi-freeflow talks to. Anything else = open proxy abuse.
153
- const ALLOWED_TARGETS = ["https://opencode.ai", "https://api.kilo.ai"];
154
-
155
- export default {
156
- async fetch(req) {
157
- const target = req.headers.get("x-relay-target");
158
- const relayPath = req.headers.get("x-relay-path") || "/";
159
- if (!target) return new Response(JSON.stringify({ error: "Missing x-relay-target header" }), { status: 400 });
160
- const cleanTarget = target.replace(/\/$/, "");
161
- if (!ALLOWED_TARGETS.includes(cleanTarget)) return new Response(JSON.stringify({ error: "Forbidden target" }), { status: 403 });
162
- if (!relayPath.startsWith("/")) return new Response(JSON.stringify({ error: "Bad path" }), { status: 400 });
163
- const headers = new Headers(req.headers);
164
- headers.delete("x-relay-target"); headers.delete("x-relay-path"); headers.delete("host");
165
- return fetch(cleanTarget + relayPath, { method: req.method, headers, body: req.method !== "GET" && req.method !== "HEAD" ? req.body : undefined });
166
- },
167
- };
168
- ```
169
- 3. Deploy and add it:
170
-
171
- ```bash
172
- omp → /freeflow add https://your.workers.dev cf-worker-1
173
- ```
174
-
175
- **Option B: Vercel Edge Relay (1M req/mo) — Auto Deploy**
176
- ```bash
177
- /freeflow deploy # prompts token in-memory, auto-adds to pool
178
- ```
179
-
180
- **Option C: Deno Deploy (100k req/day)**
181
- 1. Go to `dash.deno.com` New Project → Playground
182
- 2. Paste this relay and click **Deploy**:
183
-
184
- ```ts
185
- const ALLOWED_TARGETS = ["https://opencode.ai", "https://api.kilo.ai"];
186
-
187
- Deno.serve(async (req) => {
188
- const target = req.headers.get("x-relay-target");
189
- const relayPath = req.headers.get("x-relay-path") || "/";
190
- if (!target || !ALLOWED_TARGETS.includes(target.replace(/\/$/, ""))) {
191
- return new Response(JSON.stringify({ error: "Forbidden target" }), { status: 403 });
192
- }
193
- const headers = new Headers(req.headers);
194
- headers.delete("x-relay-target"); headers.delete("x-relay-path"); headers.delete("host");
195
- const res = await fetch(target.replace(/\/$/, "") + relayPath, { method: req.method, headers, body: req.method !== "GET" && req.method !== "HEAD" ? req.body : undefined });
196
- return new Response(res.body, { status: res.status, headers: res.headers });
197
- });
198
- ```
199
-
200
- 3. Add it:
201
-
202
- ```bash
203
- /freeflow add https://your-project.deno.dev deno-relay-1
204
- ```
205
-
206
- **Verify your pool:**
207
- ```bash
208
- /freeflow status # relay-A 1/N (ON) → candidates:N
209
- /freeflow list # lists all relays with health status
210
- /freeflow logs # tail -25
211
- cat ~/.pi/agent/pi-freeflow.log | tail -n 20
212
- ```
213
-
214
- ---
215
-
216
- ### Logs & Debugging
217
-
218
- ```bash
219
- /freeflow logs
220
- cat ~/.pi/agent/pi-freeflow.log | tail -n 50
221
-
222
- # debug toggle
223
- /freeflow debug on
224
- ```
225
-
226
- Log rotation at 5MB. Clean, parseable, real-time HTTP lifecycle tracking.
227
-
228
- ---
229
-
230
- ### Philosophy: Thin vs Fat
231
-
232
- | Fat Plugin (Before) | Thin FreeFlow (Now) |
233
- | :--- | :--- |
234
- | `src/normalizer.ts` 200 LOC duplicates host | Deleted — host `pi-ai` owns 10 `thinkingFormat` |
235
- | Live fetch 10s in subagent → timeout | Disk-only 24h, proxy-only |
236
- | 400 loops relays | Narrow 429/5xx only, 400 surfaces instantly |
237
- | `GET /v1/models?foo` leaks paid | Pathname-guarded |
238
-
239
- **Result: ~3.6k LOC total, 53 tests PASS, typecheck PASS.**
240
-
241
- ---
242
-
243
- ### FAQ
244
-
245
- **Do I need API keys?**
246
- No. Kilo uses `Bearer kilo-free`, OpenCode uses `opencodeHeaders()`.
247
-
248
- **What if all relays are 429?**
249
- Proxy tries direct. If that's also 429, Pi shows rate limit — that means global upstream limit, even without relay you'd be 429.
250
-
251
- **Can I use without relays?**
252
- Yes. `/freeflow off` → direct. Add relays later to scale.
253
-
254
- **Where's the normalizer?**
255
- Deleted in 1.3.0. If zai/qwen/deepseek thinking broke before, it's fixed now because host handles it.
256
-
257
- **Why is context free?**
258
- We use OpenCode Zen & Kilo free tiers. You pay only with your own Cloudflare/Vercel free tiers for egress.
259
-
260
- ---
261
-
262
- ### Contributing
263
-
264
- ```bash
265
- git clone https://github.com/trefeon/pi-freeflow
266
- pnpm install
267
- pnpm test
268
- ```
269
-
270
- PRs welcome. `reference/` holds pi, oh-my-pi, opencode, kilocode shallow clones for audit (gitignored).
271
-
272
- ### License
273
-
274
- MIT © trefeon
275
-
276
- Start now:
277
- ```bash
278
- omp plugin install pi-freeflow && omp --model freeflow/muse-spark-1.2-contributor-free --thinking max "make it sell"
279
- ```
1
+ # pi-freeflow 🌊
2
+
3
+ > **23 free models. Up to 1M context. Zero API keys. Infinite scale via your own relay pool.**
4
+
5
+ Thin by design: model list + dumb relay + log. Host `pi-ai` owns thinking, normalization & provider magic. We just make it free, fast, and unbreakable.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/pi-freeflow?style=flat-square&color=00E5FF)](https://www.npmjs.com/package/pi-freeflow)
8
+ [![npm downloads](https://img.shields.io/npm/dm/pi-freeflow?style=flat-square)](https://www.npmjs.com/package/pi-freeflow)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
10
+ [![Pi](https://img.shields.io/badge/Powered%20by-Pi-7c3aed?style=flat-square)](https://github.com/badlogic/pi-ai)
11
+ [![Oh My Pi](https://img.shields.io/badge/Compatible-OMP-black?style=flat-square)](https://github.com/coder/oh-my-pi)
12
+
13
+ Join devs bypassing rate limits with their own relay pools. BYO, add as many as you need.
14
+
15
+ ---
16
+
17
+ ### Features at a Glance
18
+
19
+ | Feature | Description | Value | Cost |
20
+ | :--- | :--- | :--- | :--- |
21
+ | **23 Curated Free Models** | 9 OpenCode Zen + 14 KiloCode Gateway models, up to 1M context & 512K output | Ceiling Unlocked | **$0** |
22
+ | **BYO Relay Pool** | Round-robin load balancing across your Cloudflare Workers & Vercel Edges | Zero Rate Limits | **$0** (your free tiers) |
23
+ | **Adaptive Health & Error Detection** | Auto-cooldown on 429 rate limits, 504 timeouts, and socket drops | 0ms Wasted Latency | **$0** |
24
+ | **Stream Truncation Resilience** | Stateful SSE terminal tracking (`response.failed` / `response.incomplete` injection) | Zero Host Crashes | **$0** |
25
+ | **Smart Model Aliasing** | Clean slash-free & colon-free CLI model names compatible with thinking selectors | DX Optimized | **$0** |
26
+ | **Auto-Enabled on Session** | Relay stays enabled in `auto` mode on session start and model switch | Zero Friction | **$0** |
27
+ | **Interactive CLI Management** | 10+ `/freeflow` subcommands (`status`, `list`, `use`, `add`, `label`, `remove`, `deploy`, `logs`, `debug`) | Full Control | **$0** |
28
+ | **Dumb Proxy That Never Breaks** | `127.0.0.1:18080`, host-normalized, pathname-guarded `/v1/models` | 100% Uptime | **$0** |
29
+ | **Observable Real Logs** | `~/.pi/agent/pi-freeflow.log`, 5MB auto-rotation, real-time debug toggle | Observable | **$0** |
30
+
31
+ Philosophy: **Thin by design.** We only ship model list + relay proxy + log. Host owns thinking & normalization.
32
+
33
+ ---
34
+
35
+ ### 23 Curated Models, One Command
36
+
37
+ ```bash
38
+ /model → freeflow → pick
39
+ ```
40
+
41
+ #### OpenCode Zen (9 Models), Responses & Chat API
42
+ Optimized for deep reasoning, long-horizon coding & autonomous agentic workflows.
43
+
44
+ | Model ID | Creator / Lab | Context | Max Output | Thinking | Vision |
45
+ | :--- | :--- | :--- | :--- | :--- | :--- |
46
+ | `muse-spark-1.2-contributor-free` | Meta Superintelligence Labs | **1M** (1.048.576) | **131K** (131.072) | `minimal / low / medium / high / xhigh / max` | ✅ |
47
+ | `x-preview-f-free` | Ox Alpha | **1M** (1.048.576) | **131K** (131.072) | `low / high / max` | ✅ |
48
+ | `mimo-v2.5-free` | Xiaomi MiMo | **1M** (1.048.576) | **131K** (131.072) | `low / medium / high` | ✅ |
49
+ | `deepseek-v4-flash-free` | DeepSeek | **1M** (1.000.000) | **384K** (384.000) | `low / high / max` | ❌ |
50
+ | `laguna-s-2.1-free` | Poolside | **1M** (1.048.576) | **131K** (131.072) | `low / high / max` | ❌ |
51
+ | `nemotron-3.5-lightning-free` | NVIDIA | **1M** (1.000.000) | **262K** (262.144) | `low / high / max` | ❌ |
52
+ | `nemotron-3-ultra-free` | NVIDIA | **1M** (1.000.000) | **128K** (128.000) | `low / high / max` | ❌ |
53
+ | `hy3-free` | Tencent Hunyuan | **262K** (262.144) | **262K** (262.144) | `low / high / max` | ❌ |
54
+ | `big-pickle` | Big Pickle | **200K** (200.000) | **32K** (32.000) | `high / max` | ❌ |
55
+
56
+ #### KiloCode Gateway (14 Models), OpenRouter Compatible
57
+ Keyless access with `Bearer kilo-free`. Clean slash-free and colon-free CLI aliases supported.
58
+
59
+ | Model ID | Creator / Lab | Context | Max Output | Thinking | Vision |
60
+ | :--- | :--- | :--- | :--- | :--- | :--- |
61
+ | `dots-3-note-preview` (`dots-studio/...:free`) | Dots Studio | **512K** (512.000) | **512K** (512.000) | `minimal…xhigh`\* | ✅ |
62
+ | `step-3.7-flash` (`stepfun/...:free`) | StepFun | **262K** (262.144) | **262K** (262.144) | `minimal…xhigh`\* | ✅ |
63
+ | `nemotron-3-nano-omni` (`nvidia/...:free`) | NVIDIA | **256K** (256.000) | **65K** (65.536) | `minimal…xhigh`\* | ✅ |
64
+ | `nemotron-3-ultra-550b` (`nvidia/...:free`) | NVIDIA | **1M** (1.000.000) | **65K** (65.536) | `minimal…xhigh`\* | ❌ |
65
+ | `nvidia/nemotron-3.5-lightning:free` | NVIDIA | **1M** (1.000.000) | **131K** (131.072) | `minimal…xhigh`\* | ❌ |
66
+ | `nemotron-3-super` (`nvidia/...:free`) | NVIDIA | **262K** (262.144) | **262K** (262.144) | `minimal…xhigh`\* | ❌ |
67
+ | `hy3:free` (`tencent/hy3:free`) | Tencent Hunyuan | **262K** (262.144) | **262K** (262.144) | *(none sent)* | ❌ |
68
+ | `north-mini-code` (`cohere/...:free`) | Cohere | **256K** (256.000) | **64K** (64.000) | `minimal…xhigh`\* | ❌ |
69
+ | `laguna-s-2.1:free` (`poolside/...:free`) | Poolside | **1M** (1.048.576) | **131K** (131.072) | `minimal…xhigh`\* | ❌ |
70
+ | `laguna-xs-2.1:free` (`poolside/...:free`) | Poolside | **262K** (262.144) | **32K** (32.768) | `minimal…xhigh`\* | ❌ |
71
+ | `lfm-2.5` (`liquid/lfm-2.5-2.6b:free`) | Liquid AI | **128K** (128.000) | **32K** (32.768) | `minimal…xhigh`\* | ❌ |
72
+ | `kilo-auto` (`kilo-auto/free`) | Kilo Gateway Auto | **256K** (256.000) | **10K** (10.000) | ❌ *(non-thinking)* | ❌ |
73
+ | `openrouter` (`openrouter/free`) | OpenRouter Free | **200K** (200.000) | **65K** (65.536) | ❌ *(non-thinking)* | ✅ |
74
+ | `content-safety` (`nvidia/...:free`) | NVIDIA | **128K** (128.000) | **8K** (8.192) | ❌ *(non-thinking)* | ✅ |
75
+
76
+ \* Levels are forwarded as-is through the OpenRouter-style nested `reasoning` parameter; effort mapping is decided by each model. hy3 accepts no reasoning parameter today.
77
+
78
+ ---
79
+
80
+ ### How It Works: BYO Relays, Zero Rate Limits
81
+
82
+ ```
83
+ You → 127.0.0.1:18080 (dumb proxy, host-normalized) → x-relay-target → N egress IPs (your pool) → opencode.ai / api.kilo.ai
84
+ ↑ host already normalized thinking → proxy just forwards
85
+ ```
86
+
87
+ 1. **Per-Request Round-Robin**: 10 parallel subagents hit N different egress IPs (your pool size). No thundering herd.
88
+ 2. **Adaptive Health & Error Cooldown**: Relays hitting 429, 504, or socket disconnects enter temporary cooldown (30-90s) and automatically move behind healthy candidates. Healthy relays handle traffic with 0ms wasted delay.
89
+ 3. **Seamless 429 Roll**: `429 / 408 / 502 / 503 / 504 / 520-530` → instant roll to next relay, never 429 to agent.
90
+ 4. **Stream Truncation Resilience**: Stateful SSE terminal tracking prevents fatal unhandled stream closed errors when connections drop.
91
+ 5. **Direct Fallback Safety Net**: If all relays in the pool are exhausted, transparent direct fetch to upstream.
92
+ 6. **Zero Subagent Connect Errors**: 24h `DISK_CACHE_ONLY` model catalog avoids subagents hammering remote catalogs.
93
+
94
+ You bring the relays (free tiers). We bring the rolling.
95
+
96
+ ---
97
+
98
+ ### Interactive Commands Reference (`/freeflow`)
99
+
100
+ Manage your relay pool directly from the OMP / Pi terminal:
101
+
102
+ ```bash
103
+ /freeflow status # View active relay, pool status, and candidates
104
+ /freeflow list # List all relays with real-time health badges (✓ / ⚠️ [cooling])
105
+ /freeflow use <url|index|label> # Switch active relay
106
+ /freeflow add <url> [label] # Add new relay to the pool
107
+ /freeflow label <index|url> <name># Assign a friendly label to a relay
108
+ /freeflow remove <index|url|label># Remove a relay from the pool
109
+ /freeflow on | off | auto # Toggle relay mode (auto = enabled for freeflow)
110
+ /freeflow deploy vercel # Guided Vercel Edge relay deploy (also: deploy cloudflare, deploy deno)
111
+ /freeflow logs [lines] # Inspect recent proxy logs
112
+ /freeflow debug on | off # Toggle full HTTP lifecycle debug logging
113
+ ```
114
+
115
+ ---
116
+
117
+ ### Quick Start in 30 Seconds
118
+
119
+ #### 1. Install
120
+
121
+ **Oh My Pi (Recommended):**
122
+ ```bash
123
+ omp plugin install pi-freeflow
124
+ # or local dev
125
+ omp plugin link /path/to/pi-freeflow
126
+ ```
127
+
128
+ **Pi:**
129
+ ```bash
130
+ pi install npm:pi-freeflow
131
+ ```
132
+
133
+ #### 2. Pick a Model
134
+
135
+ ```bash
136
+ omp
137
+ /model freeflow → muse-spark-1.2-contributor-free (1M) → max
138
+
139
+ # or CLI
140
+ omp -p --model freeflow/muse-spark-1.2-contributor-free "build me a SaaS"
141
+ # or with short alias & thinking level
142
+ omp -p --model freeflow/step-3.7-flash:high "solve this bug"
143
+ ```
144
+
145
+ #### 3. Add Your Free Relays (Scale Infinitely)
146
+
147
+ Default ships direct. Add relays via `/freeflow add <url> [label]`.
148
+
149
+ **Zero setup?** Run `/freeflow deploy cloudflare` (or `deno`, `vercel`), paste your platform token once, and the relay is created and activated for you. Manual snippets below.
150
+
151
+ **Option A: Cloudflare Workers (100k req/day, no 25s timeout)**
152
+ 1. Go to `dash.cloudflare.com` Workers Create Deploy Edit code
153
+ 2. Paste this Worker relay snippet:
154
+
155
+ ```js
156
+ // Only the 2 upstreams pi-freeflow talks to. Anything else = open proxy abuse.
157
+ const ALLOWED_TARGETS = ["https://opencode.ai", "https://api.kilo.ai"];
158
+
159
+ export default {
160
+ async fetch(req) {
161
+ const target = req.headers.get("x-relay-target");
162
+ const relayPath = req.headers.get("x-relay-path") || "/";
163
+ if (!target) return new Response(JSON.stringify({ error: "Missing x-relay-target header" }), { status: 400 });
164
+ const cleanTarget = target.replace(/\/$/, "");
165
+ if (!ALLOWED_TARGETS.includes(cleanTarget)) return new Response(JSON.stringify({ error: "Forbidden target" }), { status: 403 });
166
+ if (!relayPath.startsWith("/")) return new Response(JSON.stringify({ error: "Bad path" }), { status: 400 });
167
+ const headers = new Headers(req.headers);
168
+ headers.delete("x-relay-target"); headers.delete("x-relay-path"); headers.delete("host");
169
+ return fetch(cleanTarget + relayPath, { method: req.method, headers, body: req.method !== "GET" && req.method !== "HEAD" ? req.body : undefined });
170
+ },
171
+ };
172
+ ```
173
+ 3. Deploy and add it:
174
+
175
+ ```bash
176
+ omp → /freeflow add https://your.workers.dev cf-worker-1
177
+ ```
178
+
179
+ **Option B: Vercel Edge Relay (1M req/mo), Auto Deploy**
180
+ ```bash
181
+ /freeflow deploy # prompts token in-memory, auto-adds to pool
182
+ ```
183
+
184
+ **Option C: Deno Deploy (100k req/day)**
185
+ 1. Go to `dash.deno.com` → New Project → Playground
186
+ 2. Paste this relay and click **Deploy**:
187
+
188
+ ```ts
189
+ const ALLOWED_TARGETS = ["https://opencode.ai", "https://api.kilo.ai"];
190
+
191
+ Deno.serve(async (req) => {
192
+ const target = req.headers.get("x-relay-target");
193
+ const relayPath = req.headers.get("x-relay-path") || "/";
194
+ if (!target || !ALLOWED_TARGETS.includes(target.replace(/\/$/, ""))) {
195
+ return new Response(JSON.stringify({ error: "Forbidden target" }), { status: 403 });
196
+ }
197
+ const headers = new Headers(req.headers);
198
+ headers.delete("x-relay-target"); headers.delete("x-relay-path"); headers.delete("host");
199
+ const res = await fetch(target.replace(/\/$/, "") + relayPath, { method: req.method, headers, body: req.method !== "GET" && req.method !== "HEAD" ? req.body : undefined });
200
+ return new Response(res.body, { status: res.status, headers: res.headers });
201
+ });
202
+ ```
203
+
204
+ 3. Add it:
205
+
206
+ ```bash
207
+ /freeflow add https://your-project.deno.dev deno-relay-1
208
+ ```
209
+
210
+ **Verify your pool:**
211
+ ```bash
212
+ /freeflow status # relay-A 1/N (ON) → candidates:N
213
+ /freeflow list # lists all relays with health status
214
+ /freeflow logs # tail -25
215
+ cat ~/.pi/agent/pi-freeflow.log | tail -n 20
216
+ ```
217
+
218
+ ---
219
+
220
+ ### Logs & Debugging
221
+
222
+ ```bash
223
+ /freeflow logs
224
+ cat ~/.pi/agent/pi-freeflow.log | tail -n 50
225
+
226
+ # debug toggle
227
+ /freeflow debug on
228
+ ```
229
+
230
+ Log rotation at 5MB. Clean, parseable, real-time HTTP lifecycle tracking.
231
+
232
+ ---
233
+
234
+ ### Design
235
+
236
+ This package stays thin. It ships three things: a model catalog, a relay proxy, and a log. There is no build step and there are no runtime dependencies. Thinking and prompt normalization stay with the host (`pi-ai`).
237
+
238
+ Current size: about 4.6k lines including tests. 16 tests pass, typecheck clean.
239
+
240
+ ---
241
+
242
+ ### FAQ
243
+
244
+ **Do I need API keys?**
245
+ No. Kilo uses `Bearer kilo-free`, OpenCode uses `opencodeHeaders()`.
246
+
247
+ **What if all relays are 429?**
248
+ Proxy tries direct. If that is also 429, Pi shows the rate limit. That number is the global upstream cap; without relays you would hit the same wall.
249
+
250
+ **Can I use without relays?**
251
+ Yes. `/freeflow off` direct. Add relays later to scale.
252
+
253
+ **Where's the normalizer?**
254
+ Deleted in 1.3.0. If zai/qwen/deepseek thinking broke before, it's fixed now because host handles it.
255
+
256
+ **Why is context free?**
257
+ We use OpenCode Zen & Kilo free tiers. You pay only with your own Cloudflare/Vercel free tiers for egress.
258
+
259
+ ---
260
+
261
+ ### Contributing
262
+
263
+ Contributions welcome — bug fixes, new relay platforms, model additions, docs improvements.
264
+
265
+ #### Prerequisites
266
+
267
+ - **Node.js ≥ 22.6.0** (uses `--experimental-strip-types`, no build step)
268
+ - **pnpm** (package manager)
269
+
270
+ #### Setup & Verify
271
+
272
+ ```bash
273
+ git clone https://github.com/trefeon/pi-freeflow
274
+ cd pi-freeflow
275
+ pnpm install
276
+
277
+ # run all three before opening a PR
278
+ pnpm test # 16 tests across 2 test files
279
+ pnpm typecheck # tsc --noEmit, must pass clean
280
+ pnpm smoke # verifies extensions/index.ts loads without crashing
281
+ ```
282
+
283
+ #### Project Structure
284
+
285
+ ```
286
+ src/
287
+ ├── index.ts # extension entry, lifecycle hooks
288
+ ├── models.ts # 23-model catalog definitions
289
+ ├── catalog.ts # model catalog cache (24h disk)
290
+ ├── proxy.ts # local proxy server (127.0.0.1:18080)
291
+ ├── relay.ts # relay selection & round-robin
292
+ ├── relay-state.ts # relay pool state, health tracking
293
+ ├── rate-limiter.ts # adaptive cooldown on 429/504/socket errors
294
+ ├── stream-pipe.ts # SSE stream piping & truncation resilience
295
+ ├── commands.ts # /freeflow CLI subcommands
296
+ ├── deploy.ts # guided relay deploy (vercel/cloudflare/deno)
297
+ ├── config.ts # relay pool persistence
298
+ ├── logger.ts # file logger with 5MB rotation
299
+ └── types.ts # shared type definitions
300
+ extensions/
301
+ └── index.ts # OMP/Pi extension manifest
302
+ test/
303
+ └── *.test.ts # mirrors src/, node:test runner
304
+ ```
305
+
306
+ #### Guidelines
307
+
308
+ - **Stay thin.** No runtime dependencies. No build step. If it belongs in the host (`pi-ai`), don't add it here.
309
+ - **Test what you touch.** Every `src/*.ts` has a matching `test/*.test.ts`. Add or update tests for your change.
310
+ - **Keep model IDs clean.** Slash-free, colon-free aliases for CLI compatibility. See existing patterns in `models.ts`.
311
+ - **One concern per PR.** Bug fix? One PR. New relay platform? Separate PR. Easier to review, faster to merge.
312
+
313
+ #### Reporting Issues
314
+
315
+ Found a bug or want a feature? [Open an issue](https://github.com/trefeon/pi-freeflow/issues) with:
316
+ - What happened vs what you expected
317
+ - Your relay setup (`/freeflow status` output helps)
318
+ - Relevant logs (`/freeflow logs` or `~/.pi/agent/pi-freeflow.log`)
319
+
320
+ ---
321
+
322
+ ### License
323
+
324
+ MIT © trefeon
325
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-freeflow",
3
3
  "type": "module",
4
- "version": "1.4.2",
4
+ "version": "1.4.3",
5
5
  "description": "Thin provider for OMP/Pi — model list + dumb relay proxy + log; host pi-ai owns thinking/normalization",
6
6
  "main": "extensions/index.ts",
7
7
  "types": "src/index.ts",