freiheit 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-PRESENT Vincent-the-gamer <https://github.com/Vincent-the-gamer>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <img src="static/banner.png" style="width: 1000px;"/>
3
+ <h1>freiheit</h1>
4
+ <p>Set large models free</p>
5
+ </div>
2
6
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
7
+ [![npm version][npm-version-src]][npm-version-href]
8
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
9
+
10
+ English | [中文](README.zh-CN.md)
11
+
12
+ A CLI for free model endpoints, inspired by [dsh-our-free-model](https://github.com/Ebony-Vinyl/dsh-our-free-model).
13
+
14
+ An OpenAI / Anthropic compatible HTTP gateway that aggregates **free** model sources:
15
+
16
+ - **OpenCode Zen** free tier (`opencode.ai/inference/*`, `Bearer public`, with fingerprinting)
17
+ - **Kilo** free models (`ai-gateway.kilo.ai/api/v1`, `isFree: true`)
18
+
19
+ Only free tiers are included. Paid or restricted channels (EAC, ten-account, aggregate) are excluded.
20
+
21
+ ## Usage
22
+
23
+ ```bash
24
+ npx freiheit --help
25
+
26
+ # List available models
27
+ npx freiheit models
28
+
29
+ # Start the endpoint on the local network
30
+ npx freiheit --host 0.0.0.0
31
+ ```
32
+
33
+ ## Endpoints
34
+
35
+ - `GET /v1/models` (or `/models`) — aggregated list of free models
36
+ - `POST /v1/chat/completions` (or `/chat/completions`) — OpenAI chat
37
+ - `POST /v1/messages` (or `/messages`) — Anthropic messages (OpenCode models only)
38
+ - `GET /health`
39
+
40
+ ## Bun dependency (OpenCode models)
41
+
42
+ OpenCode inference is routed through a Bun-based transport layer (the upstream `egressFetch` delegates POST requests to `opencode.ai` to `bun`). If `bun` is not on your PATH, requests for OpenCode models fail with a `laneConfig` error; the API response includes a hint and `laneConfig: true`. Kilo models and the `/v1/models` listing work fine without Bun.
43
+
44
+ Install Bun: https://bun.sh
45
+
46
+ ## Notes
47
+
48
+ - Some OpenCode free model ids are region-sensitive (beam/crouton/pulse/muse-spark).
49
+ - Free quota is pooled per egress IP and rate-limited; heavy use may trigger `FreeUsageLimitError`.
50
+ - Local state (session map, Bun worker) is written to `~/.freiheit`; override with `FREIHEIT_HOME`.
51
+
52
+ <!-- Badges -->
53
+ [npm-version-src]: https://img.shields.io/npm/v/freiheit?style=flat&colorA=080f12&colorB=1fa669
54
+ [npm-version-href]: https://npmjs.com/package/freiheit
55
+ [npm-downloads-src]: https://img.shields.io/npm/dm/freiheit?style=flat&colorA=080f12&colorB=1fa669
56
+ [npm-downloads-href]: https://npmjs.com/package/freiheit
@@ -0,0 +1,57 @@
1
+ <div align="center">
2
+ <img src="static/banner.png" style="width: 1000px;"/>
3
+ <h1>freiheit</h1>
4
+ <p>实现大模型自由</p>
5
+ </div>
6
+
7
+ [![npm version][npm-version-src]][npm-version-href]
8
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
9
+
10
+ [English](README.md) | 中文
11
+
12
+ 免费模型端点 CLI,灵感来自 [dsh-our-free-model](https://github.com/Ebony-Vinyl/dsh-our-free-model)。
13
+
14
+ 兼容 OpenAI / Anthropic 的 HTTP 网关,聚合**免费**模型来源:
15
+
16
+ - **OpenCode Zen** 免费通道(`opencode.ai/inference/*`,`Bearer public`,带指纹)
17
+ - **Kilo** 免费模型(`ai-gateway.kilo.ai/api/v1`,`isFree: true`)
18
+
19
+ 仅包含免费通道。付费/受限通道(EAC、ten-account、aggregate)已经排除。
20
+
21
+ ## 使用
22
+
23
+ ```bash
24
+ npx freiheit --help
25
+
26
+ # 列出可用模型
27
+ npx freiheit models
28
+
29
+ # 以局域网启动端点
30
+ npx freiheit --host 0.0.0.0
31
+ ```
32
+
33
+ ## 端点
34
+
35
+ - `GET /v1/models`(或 `/models`)—— 聚合的免费模型列表
36
+ - `POST /v1/chat/completions`(或 `/chat/completions`)—— OpenAI 对话
37
+ - `POST /v1/messages`(或 `/messages`)—— Anthropic messages(仅 OpenCode 模型)
38
+ - `GET /health`
39
+
40
+ ## Bun 依赖(OpenCode 模型)
41
+
42
+ OpenCode 推理通过基于 Bun 的传输层路由(上游 `egressFetch` 将 opencode.ai 的 POST 请求委托给 `bun`)。如果 PATH 中没有 `bun`,OpenCode 模型请求会因 `laneConfig` 错误而失败;API 响应中会包含提示和 `laneConfig: true`。Kilo 模型和 `/v1/models` 列表在没有 Bun 的情况下也能正常工作。
43
+
44
+ 安装 Bun:https://bun.sh
45
+
46
+ ## 说明
47
+
48
+ - 部分 OpenCode 免费模型的 id 存在地区敏感性(beam/crouton/pulse/muse-spark)。
49
+ - 免费额度是按出口 IP 池化并限制配额的;大量使用可能触发 `FreeUsageLimitError`。
50
+ - 本地状态(会话映射、Bun worker)写入 `~/.freiheit`;可通过 `FREIHEIT_HOME` 覆盖。
51
+
52
+
53
+ <!-- Badges -->
54
+ [npm-version-src]: https://img.shields.io/npm/v/freiheit?style=flat&colorA=080f12&colorB=1fa669
55
+ [npm-version-href]: https://npmjs.com/package/freiheit
56
+ [npm-downloads-src]: https://img.shields.io/npm/dm/freiheit?style=flat&colorA=080f12&colorB=1fa669
57
+ [npm-downloads-href]: https://npmjs.com/package/freiheit
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ import '../dist/cli.mjs'
package/dist/cli.mjs ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ import { i as package_default, n as startServer, r as toPublicModels, t as listAllModels } from "./server-BBI7iyfz.mjs";
3
+ import process from "node:process";
4
+ import { cac } from "cac";
5
+
6
+ // src/cli.ts
7
+ const { version } = package_default;
8
+ const DEFAULT_HOST = "127.0.0.1";
9
+ const DEFAULT_PORT = 8787;
10
+ const cli = cac("freiheit");
11
+ function parsePort(raw) {
12
+ const port = Number(raw);
13
+ return Number.isInteger(port) && port > 0 && port <= 65535 ? port : null;
14
+ }
15
+ function errorMessage(error) {
16
+ return error instanceof Error ? error.message : String(error);
17
+ }
18
+ function serve(options) {
19
+ const port = parsePort(options.port ?? DEFAULT_PORT);
20
+ if (port === null) {
21
+ console.error(`Invalid port \`${options.port}\`: expected an integer between 1 and 65535.`);
22
+ process.exitCode = 1;
23
+ return;
24
+ }
25
+ startServer(port, String(options.host ?? DEFAULT_HOST), { silent: !!options.silent });
26
+ }
27
+ function printModels(models) {
28
+ const header = [
29
+ "MODEL",
30
+ "SOURCE",
31
+ "CONTEXT"
32
+ ];
33
+ const rows = models.map((m) => [
34
+ m.id,
35
+ m.source,
36
+ m.contextWindow ? String(m.contextWindow) : "-"
37
+ ]);
38
+ const widths = header.map((h, i) => Math.max(h.length, ...rows.map((row) => row[i].length)));
39
+ const format = (cells) => cells.map((cell, i) => cell.padEnd(widths[i])).join(" ").trimEnd();
40
+ console.log(format(header));
41
+ console.log(widths.map((width) => "-".repeat(width)).join(" "));
42
+ for (const row of rows) console.log(format(row));
43
+ console.log(`\n${models.length} free model(s).`);
44
+ }
45
+ async function models(options) {
46
+ try {
47
+ const list = await listAllModels();
48
+ if (options.json) console.log(JSON.stringify({
49
+ object: "list",
50
+ data: toPublicModels(list)
51
+ }, null, 2));
52
+ else printModels(list);
53
+ } catch (error) {
54
+ console.error(`Failed to list models: ${errorMessage(error)}`);
55
+ process.exitCode = 1;
56
+ }
57
+ }
58
+ cli.usage("[options]\n freiheit models [--json]");
59
+ cli.option("--host <host>, -H <host>", "Host to bind.", { default: DEFAULT_HOST });
60
+ cli.option("--port, -p <port>", "Port to listen on.", { default: DEFAULT_PORT });
61
+ cli.option("--silent", "Suppress startup logs.");
62
+ cli.command("models", "List the aggregated free models.").option("--json", "Print the OpenAI-style model list as JSON.").action((options) => models(options));
63
+ cli.example("freiheit");
64
+ cli.example("freiheit --host 0.0.0.0 --port 8787");
65
+ cli.example("freiheit models");
66
+ cli.example("freiheit models --json");
67
+ cli.help();
68
+ cli.version(version);
69
+ let parsed;
70
+ try {
71
+ parsed = cli.parse();
72
+ } catch (error) {
73
+ console.error(errorMessage(error));
74
+ process.exit(1);
75
+ }
76
+ if (!cli.matchedCommand && !cli.options.help && !cli.options.version) {
77
+ if (parsed.args.length > 0) {
78
+ console.error(`Unknown command \`${parsed.args[0]}\`.`);
79
+ cli.outputHelp();
80
+ process.exit(1);
81
+ }
82
+ serve(cli.options);
83
+ }
84
+
85
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { n as startServer, r as toPublicModels, t as listAllModels } from "./server-BBI7iyfz.mjs";
2
+
3
+ export { listAllModels, startServer, toPublicModels };