waygate-core 0.2.0 → 0.2.2

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/dist/report.js CHANGED
@@ -17,7 +17,9 @@ export function renderReady(r) {
17
17
  lines.push(`凭证 ${r.credential.ok ? '✓' : '✗'} ${r.credential.detail}`);
18
18
  lines.push(`上游 ${r.upstream}`);
19
19
  lines.push(`代理 ${baseUrl(r.host, r.port)}`);
20
- lines.push(`密钥 ${maskKey(r.key)}`);
20
+ /* 密钥**完整**打印(不打码):它就是给用户复制进客户端的,打码等于不可用。
21
+ ⚠️ 只在本机终端输出;`--json` 同样给完整值(供脚本消费)。 */
22
+ lines.push(`密钥 ${r.key}`);
21
23
  if (r.host === '0.0.0.0' || r.host === '::') {
22
24
  lines.push('');
23
25
  lines.push(`⚠️ 正在监听所有网络接口(${r.host})—— 局域网内任何设备都能访问你的订阅。`);
package/dist/server.js CHANGED
@@ -77,7 +77,11 @@ export function startServer(adapter, opts) {
77
77
  sendError(res, 401, '入站密钥缺失或不正确(Authorization: Bearer <key> 或 x-api-key)', 'invalid_api_key');
78
78
  return;
79
79
  }
80
- if (path === '/v1/models' && req.method === 'GET') {
80
+ /* [v0.2.2] 路径兼容:客户端对 base_url 的填法不一 —— 有的填 `http://host:port/v1`
81
+ (拼出 /v1/chat/completions),有的填 `http://host:port`(拼出 /chat/completions)。
82
+ 两种都接受,避免"多一个 /v1 就 404"这类让人摸不着头脑的失败。 */
83
+ const normalize = (p) => (p.startsWith('/v1/') ? p.slice(3) : p);
84
+ if (normalize(path) === '/models' && req.method === 'GET') {
81
85
  const models = await adapter.listModels();
82
86
  sendJson(res, 200, {
83
87
  object: 'list',
@@ -85,7 +89,7 @@ export function startServer(adapter, opts) {
85
89
  });
86
90
  return;
87
91
  }
88
- if ((path === '/v1/chat/completions' || path === '/v1/messages') && req.method === 'POST') {
92
+ if ((normalize(path) === '/chat/completions' || normalize(path) === '/messages') && req.method === 'POST') {
89
93
  const raw = (await readJsonBody(req));
90
94
  if (!raw || typeof raw.model !== 'string' || !raw.model.trim()) {
91
95
  sendError(res, 400, 'model 为必填项', 'invalid_request_error');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waygate-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Waygate 家族共享骨架:本地反代 HTTP 服务、入站密钥、CLI、自检",
5
5
  "type": "module",
6
6
  "license": "MIT",