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 +325 -279
- package/package.json +1 -1
- package/src/catalog.ts +222 -207
- package/src/commands.ts +670 -618
- package/src/config.ts +144 -145
- package/src/deploy.ts +496 -126
- package/src/index.ts +301 -277
- package/src/models.ts +399 -399
- package/src/proxy.ts +503 -500
- package/src/relay.ts +213 -210
- package/src/stream-pipe.ts +265 -263
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
|
-
[](https://www.npmjs.com/package/pi-freeflow)
|
|
8
|
-
[](https://www.npmjs.com/package/pi-freeflow)
|
|
9
|
-
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://github.com/badlogic/pi-ai)
|
|
11
|
-
[](https://github.com/coder/oh-my-pi)
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
/model → freeflow → pick
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
#### OpenCode Zen (9 Models)
|
|
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
|
|
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
|
|
50
|
-
| `laguna-s-2.1-free` | Poolside | **1M** (1.048.576) | **131K** (131.072) | `low
|
|
51
|
-
| `nemotron-3.5-lightning-free` | NVIDIA | **1M** (1.000.000) | **262K** (262.144) | `low
|
|
52
|
-
| `nemotron-3-ultra-free` | NVIDIA | **1M** (1.000.000) | **128K** (128.000) | `low
|
|
53
|
-
| `hy3-free` | Tencent Hunyuan | **262K** (262.144) | **262K** (262.144) | `low
|
|
54
|
-
| `big-pickle` | Big Pickle | **200K** (200.000) | **32K** (32.000) | `high / max` | ❌ |
|
|
55
|
-
|
|
56
|
-
#### KiloCode Gateway (14 Models)
|
|
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) | `
|
|
62
|
-
| `step-3.7-flash` (`stepfun/...:free`) | StepFun | **262K** (262.144) | **262K** (262.144) | `
|
|
63
|
-
| `nemotron-3-nano-omni` (`nvidia/...:free`) | NVIDIA | **256K** (256.000) | **65K** (65.536) | `
|
|
64
|
-
| `nemotron-3-ultra-550b` (`nvidia/...:free`) | NVIDIA | **1M** (1.000.000) | **65K** (65.536) | `
|
|
65
|
-
| `nvidia/nemotron-3.5-lightning:free` | NVIDIA | **1M** (1.000.000) | **131K** (131.072) | `
|
|
66
|
-
| `nemotron-3-super` (`nvidia/...:free`) | NVIDIA | **262K** (262.144) | **262K** (262.144) | `
|
|
67
|
-
| `hy3:free` (`tencent/hy3:free`) | Tencent Hunyuan | **262K** (262.144) | **262K** (262.144) |
|
|
68
|
-
| `north-mini-code` (`cohere/...:free`) | Cohere | **256K** (256.000) | **64K** (64.000) | `
|
|
69
|
-
| `laguna-s-2.1:free` (`poolside/...:free`) | Poolside | **1M** (1.048.576) | **131K** (131.072) | `
|
|
70
|
-
| `laguna-xs-2.1:free` (`poolside/...:free`) | Poolside | **262K** (262.144) | **32K** (32.768) | `
|
|
71
|
-
| `lfm-2.5` (`liquid/lfm-2.5-2.6b:free`) | Liquid AI | **128K** (128.000) | **32K** (32.768) | `
|
|
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
|
-
|
|
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
|
-
/freeflow
|
|
104
|
-
/freeflow
|
|
105
|
-
/freeflow
|
|
106
|
-
/freeflow
|
|
107
|
-
/freeflow
|
|
108
|
-
/freeflow
|
|
109
|
-
/freeflow
|
|
110
|
-
/freeflow
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
omp plugin
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
# or
|
|
140
|
-
omp -p --model freeflow/
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/freeflow
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
+
[](https://www.npmjs.com/package/pi-freeflow)
|
|
8
|
+
[](https://www.npmjs.com/package/pi-freeflow)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://github.com/badlogic/pi-ai)
|
|
11
|
+
[](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.
|
|
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",
|