pool-anything 0.1.0

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.
Files changed (111) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +280 -0
  3. package/bin/pool-anything.js +4 -0
  4. package/data/providers.json +38 -0
  5. package/dist/admin/branding.js +34 -0
  6. package/dist/admin/components.js +189 -0
  7. package/dist/admin/pages.js +1891 -0
  8. package/dist/admin/shell.js +129 -0
  9. package/dist/admin/tokens.js +32 -0
  10. package/dist/cli/nl.js +147 -0
  11. package/dist/cli/repl.js +470 -0
  12. package/dist/cli/ui.js +81 -0
  13. package/dist/cli.js +199 -0
  14. package/dist/common/http.js +55 -0
  15. package/dist/config/env.js +94 -0
  16. package/dist/config/paths.js +112 -0
  17. package/dist/data/providers.json +38 -0
  18. package/dist/db/index.js +20 -0
  19. package/dist/db/init.js +11 -0
  20. package/dist/logo.png +0 -0
  21. package/dist/media/capabilities.js +103 -0
  22. package/dist/middleware/auth.js +37 -0
  23. package/dist/observability/health.js +31 -0
  24. package/dist/pool/index.js +407 -0
  25. package/dist/pool/rotation.js +123 -0
  26. package/dist/proxy/dns.js +39 -0
  27. package/dist/proxy/forward.js +350 -0
  28. package/dist/public/logos/anthropic.svg +1 -0
  29. package/dist/public/logos/anyscale.svg +1 -0
  30. package/dist/public/logos/appwrite.svg +1 -0
  31. package/dist/public/logos/brave.svg +1 -0
  32. package/dist/public/logos/cartesia.svg +4 -0
  33. package/dist/public/logos/claude.svg +1 -0
  34. package/dist/public/logos/cloudflare.svg +1 -0
  35. package/dist/public/logos/cohere-command.svg +1 -0
  36. package/dist/public/logos/cohere.svg +1 -0
  37. package/dist/public/logos/deepgram.svg +1 -0
  38. package/dist/public/logos/elevenlabs.svg +1 -0
  39. package/dist/public/logos/finnhub.png +0 -0
  40. package/dist/public/logos/fireworks.svg +1 -0
  41. package/dist/public/logos/gemini.svg +1 -0
  42. package/dist/public/logos/google.svg +1 -0
  43. package/dist/public/logos/googlemaps.svg +1 -0
  44. package/dist/public/logos/groq.svg +1 -0
  45. package/dist/public/logos/huggingface.svg +1 -0
  46. package/dist/public/logos/mailgun.svg +1 -0
  47. package/dist/public/logos/manifest.json +197 -0
  48. package/dist/public/logos/mapbox.svg +1 -0
  49. package/dist/public/logos/mistral.svg +1 -0
  50. package/dist/public/logos/neon.svg +1 -0
  51. package/dist/public/logos/openai.svg +1 -0
  52. package/dist/public/logos/openrouter.svg +1 -0
  53. package/dist/public/logos/openweather.png +0 -0
  54. package/dist/public/logos/perplexity.svg +1 -0
  55. package/dist/public/logos/pool-anything.svg +111 -0
  56. package/dist/public/logos/postmark.svg +4 -0
  57. package/dist/public/logos/replicate.svg +1 -0
  58. package/dist/public/logos/resend.svg +1 -0
  59. package/dist/public/logos/scrapingbee.svg +72 -0
  60. package/dist/public/logos/sendgrid.svg +1 -0
  61. package/dist/public/logos/serper.png +0 -0
  62. package/dist/public/logos/supabase.svg +1 -0
  63. package/dist/public/logos/tavily.svg +1 -0
  64. package/dist/public/logos/together.svg +1 -0
  65. package/dist/public/logos/turso.svg +1 -0
  66. package/dist/public/logos/twilio.svg +1 -0
  67. package/dist/public/logos/upstash.svg +1 -0
  68. package/dist/router/api.js +20 -0
  69. package/dist/server.js +431 -0
  70. package/dist/upstream/index.js +137 -0
  71. package/package.json +68 -0
  72. package/public/logos/anthropic.svg +1 -0
  73. package/public/logos/anyscale.svg +1 -0
  74. package/public/logos/appwrite.svg +1 -0
  75. package/public/logos/brave.svg +1 -0
  76. package/public/logos/cartesia.svg +4 -0
  77. package/public/logos/claude.svg +1 -0
  78. package/public/logos/cloudflare.svg +1 -0
  79. package/public/logos/cohere-command.svg +1 -0
  80. package/public/logos/cohere.svg +1 -0
  81. package/public/logos/deepgram.svg +1 -0
  82. package/public/logos/elevenlabs.svg +1 -0
  83. package/public/logos/finnhub.png +0 -0
  84. package/public/logos/fireworks.svg +1 -0
  85. package/public/logos/gemini.svg +1 -0
  86. package/public/logos/google.svg +1 -0
  87. package/public/logos/googlemaps.svg +1 -0
  88. package/public/logos/groq.svg +1 -0
  89. package/public/logos/huggingface.svg +1 -0
  90. package/public/logos/mailgun.svg +1 -0
  91. package/public/logos/manifest.json +197 -0
  92. package/public/logos/mapbox.svg +1 -0
  93. package/public/logos/mistral.svg +1 -0
  94. package/public/logos/neon.svg +1 -0
  95. package/public/logos/openai.svg +1 -0
  96. package/public/logos/openrouter.svg +1 -0
  97. package/public/logos/openweather.png +0 -0
  98. package/public/logos/perplexity.svg +1 -0
  99. package/public/logos/pool-anything.svg +111 -0
  100. package/public/logos/postmark.svg +4 -0
  101. package/public/logos/replicate.svg +1 -0
  102. package/public/logos/resend.svg +1 -0
  103. package/public/logos/scrapingbee.svg +72 -0
  104. package/public/logos/sendgrid.svg +1 -0
  105. package/public/logos/serper.png +0 -0
  106. package/public/logos/supabase.svg +1 -0
  107. package/public/logos/tavily.svg +1 -0
  108. package/public/logos/together.svg +1 -0
  109. package/public/logos/turso.svg +1 -0
  110. package/public/logos/twilio.svg +1 -0
  111. package/public/logos/upstash.svg +1 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,280 @@
1
+ <p align="center">
2
+ <img src="src/logo.png" alt="pool-anything logo" width="96" height="96" />
3
+ </p>
4
+
5
+ <h1 align="center">pool-anything</h1>
6
+
7
+ <p align="center"><b>Gather free-tier API keys into one pool. Rotate through them automatically.</b></p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/Parithosh-Varma/pool-anything/actions/workflows/ci.yml"><img src="https://github.com/Parithosh-Varma/pool-anything/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License" /></a>
12
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D22.5-brightgreen.svg" alt="Node" /></a>
13
+ <a href="tsconfig.json"><img src="https://img.shields.io/badge/TypeScript-strict-blue.svg" alt="TypeScript" /></a>
14
+ <a href="package.json"><img src="https://img.shields.io/badge/dependencies-0-brightgreen.svg" alt="Dependencies" /></a>
15
+ </p>
16
+
17
+ <p align="center">
18
+ 🖥️ <a href="https://pool-anything-tools.pages.dev"><b>Live demo: tools UI</b></a>
19
+ ·
20
+ 📖 <a href="https://pool-anything.pages.dev/docs"><b>Docs</b></a>
21
+ </p>
22
+
23
+ <hr />
24
+
25
+ Most AI/API providers hand you a free tier: a rate limit, a daily quota, a handful of trial tokens. One key's worth is small — but *several* keys, rotated, adds up. **pool-anything** lets you gather N keys for the same provider into a pool, then serves them through a single endpoint that round-robins across them and tracks usage per key.
26
+
27
+ - 🔁 **Round-robin rotation** — every request draws the next key in the pool
28
+ - 📊 **Usage & quota tracking** — per-key and per-pool token counts in SQLite
29
+ - 🌐 **Drop-in HTTP proxy** — point your client at pool-anything; it forwards with the right key, header, and auth scheme
30
+ - 🔌 **36 providers preconfigured** — Groq, OpenRouter, Gemini, OpenAI, Anthropic, and more (plus any custom provider)
31
+ - 🖥️ **Built-in web UI** — search providers, gather keys, watch usage on the Analytics dashboard
32
+ - 🧰 **Zero runtime dependencies** — Node built-ins + TypeScript only, `node:sqlite` for storage
33
+
34
+ ## Quick start
35
+
36
+ ### Run it globally (recommended)
37
+
38
+ ```bash
39
+ npm install -g pool-anything
40
+ pool-anything
41
+ ```
42
+
43
+ That's it — an interactive assistant shell opens (`pool-anything >`). Type plain language like `list pools`, `add keys to groq`, or `show usage for groq`; type `.help` for all commands, `exit` to quit. Data (SQLite) lives in `~/.pool-anything/` so it works from any directory and survives upgrades.
44
+
45
+ ```bash
46
+ pool-anything serve --port 4000 --open # web UI + API on :4000, open the browser
47
+ pool-anything "list pools" # run one command without the shell
48
+ echo "gsk_abc" | pool-anything -e "add keys to groq" # pipe keys in
49
+ pool-anything --help # all options (serve, -e/--exec, -p/--port, -H/--host, --db, --data-dir, --open)
50
+ ```
51
+
52
+ ### Assistant shell
53
+
54
+ No subcommands to memorize — just say what you want:
55
+
56
+ | Say | It does |
57
+ | --- | --- |
58
+ | `list pools` | All pools with key counts + usage |
59
+ | `show usage for groq` | Token usage, quota, per-key breakdown |
60
+ | `add 5 keys to groq` | Paste keys, one per line (blank line finishes) |
61
+ | `create pool Prod Groq for groq` | Make a new pool |
62
+ | `watch groq` | Live usage, 2s refresh (`q` exits) |
63
+ | `next for groq` / `consume 100 on groq` | Rotate / record usage |
64
+ | `serve` | Start the web UI + API from inside the shell |
65
+
66
+ Keys always print masked (`gsk_…ab`); misunderstood input gets a "Did you mean …?" nudge.
67
+
68
+ ### Run from source
69
+
70
+ ```bash
71
+ git clone https://github.com/Parithosh-Varma/pool-anything.git
72
+ cd pool-anything
73
+ npm install
74
+ npm run dev
75
+ ```
76
+
77
+ Open **http://localhost:3000** (after `pool-anything serve`), search for a provider (try `groq`), paste one or more API keys, and hit **Gather**. Your pool is live. Prefer the terminal? The shell does it without a browser: `create pool Prod for groq`, then `add keys to groq`.
78
+
79
+ Then proxy a request through it straight from `curl` (every proxy call reports the `key_id` that served it, so you can see keys take turns):
80
+
81
+ ```bash
82
+ # Pick the next key from pool 1 (round-robin)
83
+ curl http://localhost:3000/api/pools/1/next
84
+
85
+ # Proxy a request — pool-anything injects the key + auth header
86
+ curl -X POST http://localhost:3000/api/pools/1/proxy \
87
+ -H 'content-type: application/json' \
88
+ -d '{"path": "/chat/completions", "method": "POST",
89
+ "body": {"model": "llama-3.3-70b", "messages": [{"role": "user", "content": "hi"}]},
90
+ "tokens": 25}'
91
+ ```
92
+
93
+ ## How it works
94
+
95
+ ```
96
+ ┌──────────────────────────────────────────┐
97
+ your app ───▶│ POST /api/pools/:id/proxy │
98
+ │ │
99
+ │ 1. nextKeyRaw() → round-robin pick │
100
+ │ 2. inject key → header / query param │
101
+ │ 3. forward → provider baseUrl │
102
+ │ 4. record usage → SQLite (per key) │
103
+ └──────────────────────────────────────────┘
104
+ │ │ │
105
+ ▼ ▼ ▼
106
+ key 1 key 2 … key N
107
+ (Groq) (Groq) (Groq)
108
+ ```
109
+
110
+ A **pool** is a named group of keys for one provider. Rotation is a simple cursor over the key list (`cursor % keys.length`), so keys are used evenly. Usage rows record how many tokens each key consumed, and `/usage` rolls that up per key and per pool against the provider's quota.
111
+
112
+ ## Screenshots
113
+
114
+ | Pools | Analytics |
115
+ | --- | --- |
116
+ | ![Pools page](docs/screenshots/title-pools.png) | ![Analytics page](docs/screenshots/title-analytics.png) |
117
+
118
+ | Key manager | Playground |
119
+ | --- | --- |
120
+ | ![API key manager](docs/screenshots/title-keys.png) | ![Playground](docs/screenshots/title-playground.png) |
121
+
122
+ ## API reference
123
+
124
+ All responses are JSON. `:id` is a pool ID.
125
+
126
+ ### Providers
127
+
128
+ | Method | Path | Description |
129
+ | --- | --- | --- |
130
+ | `GET` | `/api/providers` | List all known providers (id, name, quota, hints) |
131
+
132
+ ### Pools
133
+
134
+ | Method | Path | Description |
135
+ | --- | --- | --- |
136
+ | `GET` | `/api/pools` | List all pools |
137
+ | `POST` | `/api/pools` | Create a pool — `{ provider, name, base_url?, key_header?, key_prefix? }` |
138
+ | `GET` | `/api/pools/:id` | Pool summary: key count, usage, quota, per-key breakdown |
139
+ | `DELETE` | `/api/pools/:id` | Delete a pool and its keys + usage |
140
+ | `GET` | `/api/pools/:id/next` | Rotate: return the next key (masked — never the raw key) |
141
+ | `POST` | `/api/pools/:id/consume` | Record usage — `{ tokens: <positive int ≤ 1000000>, key_id? }` (with `key_id`, bills that key without rotating) |
142
+ | `GET` | `/api/pools/:id/usage` | Usage rollup — `{ used, usedInWindow, quota, quotaWindow, remaining, perKey }` (`used` is lifetime; `remaining`/`usedInWindow`/`perKey` are windowed for monthly quotas) |
143
+ | `POST` | `/api/pools/:id/proxy` | Proxy a request through the pool (see below) |
144
+
145
+ ### Keys
146
+
147
+ | Method | Path | Description |
148
+ | --- | --- | --- |
149
+ | `GET` | `/api/pools/:id/keys` | List keys (masked) |
150
+ | `POST` | `/api/pools/:id/keys` | Add a key — `{ label, api_key, info? }` |
151
+ | `GET` | `/api/pools/:id/keys/:keyId` | Fetch one key (raw) |
152
+ | `PATCH` | `/api/pools/:id/keys/:keyId` | Update label / api_key / info |
153
+ | `DELETE` | `/api/pools/:id/keys/:keyId` | Remove a key |
154
+
155
+ ### Proxy request body
156
+
157
+ ```jsonc
158
+ {
159
+ "path": "/chat/completions", // path appended to the provider baseUrl
160
+ "method": "POST", // HTTP method (default POST)
161
+ "body": { "…": "…" }, // JSON body, forwarded as-is
162
+ "headers": { "…": "…" }, // extra headers (override defaults)
163
+ "tokens": 25 // optional: usage to record for this call
164
+ }
165
+ ```
166
+
167
+ The response reports which key was used and the upstream status:
168
+
169
+ ```json
170
+ {
171
+ "key_id": 3,
172
+ "label": "key 1",
173
+ "masked": "gsk_…ab",
174
+ "status": 200,
175
+ "body": "{ … upstream response, first 4000 chars … }"
176
+ }
177
+ ```
178
+
179
+ ### Health
180
+
181
+ | Method | Path | Description |
182
+ | --- | --- | --- |
183
+ | `GET` | `/health` | Liveness check → `ok` |
184
+ | `GET` | `/api/db/ping` | SQLite reachability → `{ ok: true }` |
185
+ | `GET` | `/api/analytics` | Totals + 7-day deltas + 14-day daily series (drives the dashboard) |
186
+
187
+ ## Web UI
188
+
189
+ | Route | Page |
190
+ | --- | --- |
191
+ | `/` | Provider search + setup panel + Analytics dashboard |
192
+ | `/provider/:id` | Gather keys for one provider, per-key usage, proxy snippet |
193
+ | `/pools` | Pools holding keys, with usage |
194
+ | `/keys` | API key manager — add, view, edit, remove keys |
195
+ | `/playground` | Chat + image playground against a pooled key |
196
+ | `/analytics` | Analytics dashboard (totals, 7-day deltas, 14-day charts) |
197
+ | `/docs` | Redirect → canonical docs on Cloudflare Pages |
198
+
199
+ The home page also shows an Analytics dashboard driven by `GET /api/analytics`; the same dashboard lives on its own `/analytics` page.
200
+
201
+ ### Hosting the UI on Cloudflare Pages
202
+
203
+ The same UI ships as a static site ([pool-anything-tools](https://pool-anything-tools.pages.dev), `pool-anything-tools` Pages project) that talks to a backend you run anywhere:
204
+
205
+ ```bash
206
+ npm run export:tools # builds tools-site/ from src/admin
207
+ npx wrangler pages deploy tools-site --project-name pool-anything-tools
208
+ ```
209
+
210
+ Pushes to `main` redeploy automatically via [pages-tools.yml](.github/workflows/pages-tools.yml); locally, `npm run tools:daemon` watches `src/admin` and redeploys on every save.
211
+
212
+ Open the Pages URL with `?api=https://your-backend` once (or use the Backend pill, bottom-left) to point it at your server. If the backend sets `POOL_API_TOKEN`, prefer the Backend pill for the token; `?token=…` works but places the bearer in the URL (server logs/history). The server only sends CORS headers to the hosted Pages origins, `http://localhost` dev, and `ALLOWED_ORIGINS`, so cross-origin calls work without exposing the API to arbitrary sites. Keys stay on your backend — the Pages site is UI only.
213
+
214
+ ## Configuration
215
+
216
+ | Variable | Default | Purpose |
217
+ | --- | --- | --- |
218
+ | `HOST` | `127.0.0.1` | Interface to bind (loopback by default; no auth, so keep it local) |
219
+ | `PORT` | `3000` | Main server port |
220
+ | `POOL_API_TOKEN` | _(unset)_ | Bearer token gate for raw-key reads, writes, rotation, and proxy |
221
+ | `ALLOWED_ORIGINS` | Pages hosts | Comma-separated CORS allowlist for browser API reads (default: `pool-anything-tools.pages.dev`, `pool-anything.pages.dev`; `http://localhost`/`127.0.0.1` always allowed; set explicitly when self-hosting the UI) |
222
+ | `LOCAL_DB_PATH` | `data/pool-anything.db` (checkout) / `~/.pool-anything/*.db` (global) | SQLite database location (exact file; `--db` flag equivalent) |
223
+ | `POOL_DATA_DIR` | _(unset)_ | Data directory holding the SQLite file (`<dir>/pool-anything.db`; `--data-dir` flag equivalent) |
224
+ | `PROXY_TIMEOUT_MS` | `30000` | Per-attempt upstream timeout for `/proxy` |
225
+ | `ALLOW_PRIVATE_UPSTREAM` | _(unset)_ | `1` disables SSRF protections — tests/loopback only, never in prod |
226
+
227
+ Providers are defined in [`data/providers.json`](data/providers.json). See [CONTRIBUTING.md](CONTRIBUTING.md#adding-a-provider) for the schema — adding a provider is a one-line JSON edit, no code changes.
228
+
229
+ ## Project structure
230
+
231
+ ```
232
+ src/
233
+ server.ts Thin HTTP front door (delegates to router/admin/observability)
234
+ cli.ts Entry dispatch: assistant shell (default) vs `serve` vs one-shot
235
+ cli/ Interactive shell — nl.ts (natural-language parser), ui.ts (terminal rendering), repl.ts (loop, key import, watch)
236
+ router/api.ts Route matchers + abuse caps (MAX_POOLS / MAX_KEYS_PER_POOL)
237
+ admin/branding.ts Logo version, docs URL, sidebar icons
238
+ admin/shell.ts Shared shell CSS/nav/JS
239
+ admin/pages.ts Web UI pages (search, pools, keys, playground, analytics)
240
+ middleware/auth.ts Bearer auth for raw keys, writes, rotation, proxy (POOL_API_TOKEN)
241
+ common/http.ts JSON body + hardened JSON responses
242
+ observability/health.ts /health, /api/db/ping, /api/analytics handlers
243
+ pool/index.ts Providers, quotas (monthly + daily), usage, analytics (SQLite)
244
+ pool/rotation.ts Round-robin rotation, cooldown, multi-window quota enforcement
245
+ proxy/forward.ts Upstream forwarding + literal-IP SSRF guard + failover cap
246
+ proxy/dns.ts DNS rebinding guard (resolve + reject private IPs)
247
+ upstream/index.ts Per-key auth injection (single + multi-field credentials)
248
+ config/env.ts PORT, HOST, POOL_API_TOKEN, DB path, timeouts
249
+ db/ SQLite helpers + init script
250
+ scripts/
251
+ export-tools-ui.ts Static export of the admin UI for Cloudflare Pages
252
+ tools-api-base.js Backend shim (configurable API base + token)
253
+ tools-watch.ts Watch daemon: re-export + redeploy on save
254
+ data/
255
+ providers.json 36 preconfigured providers
256
+ pool-anything.db SQLite database (git-ignored)
257
+ public/logos/ Provider logos
258
+ ```
259
+
260
+ ## Development
261
+
262
+ ```bash
263
+ npm run dev # watch mode, http://localhost:3000
264
+ npm run typecheck # tsc --noEmit
265
+ npm run build # compile to dist/
266
+ npm run start:dist # run the compiled output
267
+ npm run db:init # initialize the local database
268
+ npm test # run the test suite
269
+ ```
270
+
271
+ ## Security notes
272
+
273
+ - Keys are stored in a local SQLite file (`data/pool-anything.db`), which is **git-ignored** — never commit it.
274
+ - List endpoints return **masked** keys (`gsk_…ab`); raw keys are only returned by the single-key `GET`.
275
+ - The server binds `127.0.0.1` by default; set `HOST` to another interface only behind your own auth layer.
276
+ - Without `POOL_API_TOKEN` there is **no authentication** — run it locally or behind your own auth layer, and don't expose it publicly with real keys inside.
277
+
278
+ ## License
279
+
280
+ Licensed under the [Apache License 2.0](LICENSE).
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ // Global `pool-anything` shim — runs the compiled CLI. Keep this file free of
3
+ // dependencies so `npm i -g` works with zero install-time requirements.
4
+ import "../dist/cli.js";
@@ -0,0 +1,38 @@
1
+ [
2
+ {"id":"groq","name":"Groq","baseUrl":"https://api.groq.com/openai/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"30 req/min, 14.4k req/day free (Llama 3.3 70B)","docsUrl":"https://console.groq.com/docs/openai","keyFields":["api_key"],"hint":"console.groq.com/keys, gsk_…","logo":"public/logos/groq.svg"},
3
+ {"id":"openrouter","name":"OpenRouter","baseUrl":"https://openrouter.ai/api/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":":free models $0, unfunded ~20 RPM / 200 RPD","docsUrl":"https://openrouter.ai/docs/api-reference/overview","keyFields":["api_key"],"hint":"openrouter.ai/keys, sk-or-v1-…","logo":"public/logos/openrouter.svg"},
4
+ {"id":"gemini","name":"Google Gemini","baseUrl":"https://generativelanguage.googleapis.com/v1beta","keyHeader":"x-goog-api-key","keyPrefix":"","extraHeaders":{},"quota":"15 RPM / 1500 RPD free (Flash)","docsUrl":"https://ai.google.dev/gemini-api/docs/api-key","keyFields":["api_key"],"hint":"aistudio.google.com/apikey","logo":"public/logos/gemini.svg"},
5
+ {"id":"mistral","name":"Mistral AI","baseUrl":"https://api.mistral.ai/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"trial credits, then PAYG","docsUrl":"https://docs.mistral.ai/api/","keyFields":["api_key"],"hint":"console.mistral.ai/api-keys","logo":"public/logos/mistral.svg"},
6
+ {"id":"cohere","name":"Cohere","baseUrl":"https://api.cohere.ai/compatibility/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"trial key, rate-limited","docsUrl":"https://docs.cohere.com/docs/compatibility-api","keyFields":["api_key"],"hint":"dashboard.cohere.com/api-keys","logo":"public/logos/cohere.svg"},
7
+ {"id":"fireworks","name":"Fireworks AI","baseUrl":"https://api.fireworks.ai/inference/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"$1 credit on signup","docsUrl":"https://fireworks.ai/docs/getting-started/introduction","keyFields":["api_key"],"hint":"fireworks.ai/api-keys, fw_…","logo":"public/logos/fireworks.svg"},
8
+ {"id":"huggingface","name":"Hugging Face","baseUrl":"https://router.huggingface.co/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"serverless free w/ login, hourly limits","docsUrl":"https://huggingface.co/docs/api-inference","keyFields":["api_key"],"hint":"huggingface.co/settings/tokens, hf_…","logo":"public/logos/huggingface.svg"},
9
+ {"id":"together","name":"Together AI","baseUrl":"https://api.together.ai/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"$1 credit, no permanent free","docsUrl":"https://docs.together.ai/docs/openai-api-compatibility","keyFields":["api_key"],"hint":"api.together.ai/settings/api-keys","logo":"public/logos/together.svg"},
10
+ {"id":"replicate","name":"Replicate","baseUrl":"https://api.replicate.com/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"trial ~$5, then per-second GPU","docsUrl":"https://replicate.com/docs/reference/http","keyFields":["api_key"],"hint":"replicate.com/account/api-tokens, r8_…","logo":"public/logos/replicate.svg"},
11
+ {"id":"openai","name":"OpenAI","baseUrl":"https://api.openai.com/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"PAYG, $5 min prepay","docsUrl":"https://platform.openai.com/docs/api-reference","keyFields":["api_key"],"hint":"platform.openai.com/api-keys, sk-…","logo":"public/logos/openai.svg"},
12
+ {"id":"anthropic","name":"Anthropic Claude","baseUrl":"https://api.anthropic.com/v1","keyHeader":"x-api-key","keyPrefix":"","extraHeaders":{"anthropic-version":"2023-06-01"},"quota":"$5 credit new accounts","docsUrl":"https://docs.anthropic.com/en/api/versioning","keyFields":["api_key"],"hint":"console.anthropic.com/settings/keys, sk-ant-…","logo":"public/logos/claude.svg"},
13
+ {"id":"perplexity","name":"Perplexity","baseUrl":"https://api.perplexity.ai","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"$5 credit on signup","docsUrl":"https://docs.perplexity.ai/getting-started/quickstart","keyFields":["api_key"],"hint":"perplexity.ai/settings/api, pplx-…","logo":"public/logos/perplexity.svg"},
14
+ {"id":"anyscale","name":"Anyscale Endpoints","baseUrl":"https://api.endpoints.anyscale.com/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"legacy, deprecated","docsUrl":"https://docs.anyscale.com/endpoints/overview","keyFields":["api_key"],"hint":"app.endpoints.anyscale.com/credentials","logo":"public/logos/anyscale.svg"},
15
+ {"id":"elevenlabs","name":"ElevenLabs","baseUrl":"https://api.elevenlabs.io/v1","keyHeader":"xi-api-key","keyPrefix":"","extraHeaders":{},"quota":"10k credits/mo free","docsUrl":"https://elevenlabs.io/docs","keyFields":["api_key"],"hint":"elevenlabs.io API key","logo":"public/logos/elevenlabs.svg"},
16
+ {"id":"deepgram","name":"Deepgram","baseUrl":"https://api.deepgram.com/v1","keyHeader":"Authorization","keyPrefix":"Token ","extraHeaders":{},"quota":"$200 credit on signup","docsUrl":"https://developers.deepgram.com/docs","keyFields":["api_key"],"hint":"Authorization: Token …","logo":"public/logos/deepgram.svg"},
17
+ {"id":"cartesia","name":"Cartesia","baseUrl":"https://api.cartesia.ai","keyHeader":"X-API-Key","keyPrefix":"","extraHeaders":{"Cartesia-Version":"2024-06-10"},"quota":"20,000 free tokens","docsUrl":"https://docs.cartesia.ai","keyFields":["api_key"],"hint":"Paste a Cartesia API key","logo":"public/logos/cartesia.svg"},
18
+ {"id":"tavily","name":"Tavily","baseUrl":"https://api.tavily.com","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"1,000 credits/mo free","docsUrl":"https://docs.tavily.com/documentation/api-reference/endpoint/search","keyFields":["api_key"],"hint":"app.tavily.com/home, tvly-…","logo":"public/logos/tavily.svg"},
19
+ {"id":"brave-search","name":"Brave Search","baseUrl":"https://api.search.brave.com/res/v1","keyHeader":"X-Subscription-Token","keyPrefix":"","extraHeaders":{},"quota":"2,000 queries/mo free","docsUrl":"https://brave.com/search/api/","keyFields":["api_key"],"hint":"brave.com/search/api/","logo":"public/logos/brave.svg"},
20
+ {"id":"serper","name":"Serper","baseUrl":"https://google.serper.dev","keyHeader":"X-API-KEY","keyPrefix":"","extraHeaders":{},"quota":"2,500 queries one-time","docsUrl":"https://serper.dev/docs","keyFields":["api_key"],"hint":"serper.dev API key","logo":"public/logos/serper.png"},
21
+ {"id":"scrapingbee","name":"ScrapingBee","baseUrl":"https://app.scrapingbee.com/api/v1","keyHeader":"query:api_key","keyPrefix":"","extraHeaders":{},"quota":"1,000 free credits","docsUrl":"https://www.scrapingbee.com/documentation","keyFields":["api_key"],"hint":"?api_key= query param","logo":"public/logos/scrapingbee.svg"},
22
+ {"id":"resend","name":"Resend","baseUrl":"https://api.resend.com","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"3,000/mo, 100/day free","docsUrl":"https://resend.com/docs/api-reference/introduction","keyFields":["api_key"],"hint":"resend.com/api-keys, re_…","logo":"public/logos/resend.svg"},
23
+ {"id":"sendgrid","name":"SendGrid","baseUrl":"https://api.sendgrid.com/v3","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"100/day free (60-day trial)","docsUrl":"https://docs.sendgrid.com/api-reference/","keyFields":["api_key"],"hint":"SG.… Bearer","logo":"public/logos/sendgrid.svg"},
24
+ {"id":"mailgun","name":"Mailgun","baseUrl":"https://api.mailgun.net/v3","keyHeader":"Authorization","keyPrefix":"Basic ","extraHeaders":{},"quota":"5k/3mo trial","docsUrl":"https://documentation.mailgun.com/docs/mailgun/api-reference/","keyFields":["api_key"],"hint":"Basic api:KEY, key-…","logo":"public/logos/mailgun.svg"},
25
+ {"id":"postmark","name":"Postmark","baseUrl":"https://api.postmarkapp.com","keyHeader":"X-Postmark-Server-Token","keyPrefix":"","extraHeaders":{},"quota":"100/mo trial","docsUrl":"https://postmarkapp.com/developer/api/overview","keyFields":["api_key"],"hint":"Server Token per server","logo":"public/logos/postmark.svg"},
26
+ {"id":"twilio","name":"Twilio SMS","baseUrl":"https://api.twilio.com/2010-04-01","keyHeader":"Authorization","keyPrefix":"Basic ","extraHeaders":{},"quota":"$15 credit trial","docsUrl":"https://www.twilio.com/docs/usage/api","keyFields":["accountSid","authToken"],"hint":"AC… SID + AuthToken, Basic base64(SID:Token)","logo":"public/logos/twilio.svg"},
27
+ {"id":"finnhub","name":"Finnhub","baseUrl":"https://finnhub.io/api/v1","keyHeader":"X-Finnhub-Token","keyPrefix":"","extraHeaders":{},"quota":"60/min free","docsUrl":"https://finnhub.io/docs/api","keyFields":["api_key"],"hint":"X-Finnhub-Token or ?token=","logo":"public/logos/finnhub.png"},
28
+ {"id":"mapbox","name":"Mapbox","baseUrl":"https://api.mapbox.com","keyHeader":"query:access_token","keyPrefix":"","extraHeaders":{},"quota":"100k geocode/mo, 50k loads/mo","docsUrl":"https://docs.mapbox.com/api/overview","keyFields":["api_key"],"hint":"?access_token=pk.…","logo":"public/logos/mapbox.svg"},
29
+ {"id":"googlemaps","name":"Google Maps","baseUrl":"https://maps.googleapis.com/maps/api","keyHeader":"query:key","keyPrefix":"","extraHeaders":{},"quota":"~10k/SKU/mo under $200 credit","docsUrl":"https://developers.google.com/maps/get-started","keyFields":["api_key"],"hint":"?key=AIza…","logo":"public/logos/googlemaps.svg"},
30
+ {"id":"openweather","name":"OpenWeather","baseUrl":"https://api.openweathermap.org/data/2.5","keyHeader":"query:appid","keyPrefix":"","extraHeaders":{},"quota":"1,000/day, 60/min free","docsUrl":"https://openweathermap.org/current","keyFields":["api_key"],"hint":"?appid=…","logo":"public/logos/openweather.png"},
31
+ {"id":"supabase","name":"Supabase","baseUrl":"https://<ref>.supabase.co/rest/v1","keyHeader":"apikey","keyPrefix":"","extraHeaders":{"Authorization":"Bearer <anonKey>"},"quota":"500MB DB, 5GB egress, 50k MAU","docsUrl":"https://supabase.com/docs/reference/api/start","keyFields":["url","anonKey"],"hint":"per-project URL + anon key","logo":"public/logos/supabase.svg","poolable":"conditional"},
32
+ {"id":"neon","name":"Neon Postgres","baseUrl":"https://console.neon.tech/api/v2","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"0.5GB, 100 CU-hrs/mo","docsUrl":"https://neon.com/docs/reference/api","keyFields":["api_key"],"hint":"control-plane only; data = conn string","logo":"public/logos/neon.svg","poolable":false},
33
+ {"id":"upstash","name":"Upstash Redis","baseUrl":"https://api.upstash.com/v2","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"500k cmds/mo free","docsUrl":"https://upstash.com/docs/devops/developer-api/introduction","keyFields":["api_key"],"hint":"per-db restUrl+token for data","logo":"public/logos/upstash.svg","poolable":true},
34
+ {"id":"turso","name":"Turso","baseUrl":"https://api.turso.tech/v1","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"5-9GB, 500M reads/mo","docsUrl":"https://docs.turso.tech/api-reference/introduction","keyFields":["orgSlug","platformToken"],"hint":"per-db URL + JWT for data","logo":"public/logos/turso.svg","poolable":true},
35
+ {"id":"appwrite","name":"Appwrite","baseUrl":"https://cloud.appwrite.io/v1","keyHeader":"X-Appwrite-Key","keyPrefix":"","extraHeaders":{"X-Appwrite-Project":"<PROJECT_ID>"},"quota":"75k MAU, 2 projects free","docsUrl":"https://appwrite.io/docs/apis/rest","keyFields":["endpoint","projectId","apiKey"],"hint":"endpoint+project+key","logo":"public/logos/appwrite.svg","poolable":"conditional"},
36
+ {"id":"cloudflare","name":"Cloudflare","baseUrl":"https://api.cloudflare.com/client/v4","keyHeader":"Authorization","keyPrefix":"Bearer ","extraHeaders":{},"quota":"100k req/day Workers, R2 10GB","docsUrl":"https://developers.cloudflare.com/api/","keyFields":["apiToken"],"hint":"account/zone-scoped, not poolable for data","logo":"public/logos/cloudflare.svg","poolable":false},
37
+ {"id":"custom","name":"Custom","baseUrl":"","keyHeader":"X-API-Key","keyPrefix":"","extraHeaders":{},"quota":"bring your own","docsUrl":"","keyFields":["api_key"],"hint":"Anything we don't provide: name it, add keys + info.","logo":""}
38
+ ]
@@ -0,0 +1,34 @@
1
+ import fs from "node:fs";
2
+ import { logoManifestPath } from "../config/paths.js";
3
+ /** Cache-buster for /logos/* URLs: derived from the logo manifest mtime so any
4
+ * logo update changes the query string and browsers drop stale cached bytes. */
5
+ export function logoVersion() {
6
+ try {
7
+ return Math.floor(fs.statSync(logoManifestPath()).mtimeMs).toString(36);
8
+ }
9
+ catch {
10
+ return "1";
11
+ }
12
+ }
13
+ export const LOGO_V = logoVersion();
14
+ /** Canonical docs live on Cloudflare Pages; the local tool links out to them. */
15
+ export const DOCS_URL = "https://pool-anything.pages.dev/docs";
16
+ /** Sidebar icons: custom inline stroke SVGs (currentColor, 18px via `.mi .ic svg`). */
17
+ export const svgIcon = (paths) => `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
18
+ export const ICONS = {
19
+ home: svgIcon('<path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V20a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9.5"/><path d="M9.5 21v-6h5v6"/>'),
20
+ pools: svgIcon('<path d="m12 3 9 4.9-9 4.9-9-4.9L12 3Z"/><path d="m3 12.9 9 4.9 9-4.9"/><path d="m3 17.4 9 4.9 9-4.9"/>'),
21
+ keys: svgIcon('<circle cx="8" cy="16" r="4.5"/><path d="m11.2 12.8 8.3-8.3"/><path d="M17 5.5l2.5 2.5M14.5 8l2.5 2.5"/>'),
22
+ analytics: svgIcon('<path d="M3 21h18"/><path d="M6 21v-7M11 21V5M16 21v-11M21 21v-4"/>'),
23
+ playground: svgIcon('<circle cx="12" cy="12" r="9"/><path d="m10 8.5 5 3.5-5 3.5v-7Z"/>'),
24
+ docs: svgIcon('<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/>'),
25
+ /** Attach-row media icons: same 24px stroke family as sidebar (currentColor, 1.8, round).
26
+ * Sized down to 14px via `.filebtn svg` in playground CSS. */
27
+ image: svgIcon('<rect x="3" y="4.5" width="18" height="15.5" rx="2.5"/><circle cx="9" cy="10.5" r="1.8"/><path d="m4.5 18.5 5-5 3.5 3.5 2.5-2.5 4 4"/>'),
28
+ audio: svgIcon('<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5.5 11.5a6.5 6.5 0 0 0 13 0"/><path d="M12 18v3"/><path d="M9.5 21h5"/>'),
29
+ video: svgIcon('<rect x="2.5" y="6.5" width="13" height="11" rx="2.5"/><path d="m15.5 10.8 6-3.6v9.6l-6-3.6"/>'),
30
+ rec: `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="8.2"/><circle cx="12" cy="12" r="3" fill="#B3261E" stroke="#B3261E"/></svg>`,
31
+ stop: `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="8.2"/><rect x="9.6" y="9.6" width="4.8" height="4.8" rx="1.2" fill="#B3261E" stroke="#B3261E"/></svg>`,
32
+ /** Small external-link marker (12px via `.mi .ext svg`) for sidebar items that leave the app. */
33
+ external: `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7"/><path d="M8 7h9v9"/></svg>`,
34
+ };