waygate-core 0.2.2 → 0.2.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.
Files changed (2) hide show
  1. package/dist/report.js +13 -3
  2. package/package.json +1 -1
package/dist/report.js CHANGED
@@ -11,12 +11,16 @@ function baseUrl(host, port) {
11
11
  return `http://${h}:${port}`;
12
12
  }
13
13
  export function renderReady(r) {
14
+ const origin = baseUrl(r.host, r.port);
14
15
  const lines = [];
15
16
  lines.push(`途关 · ${r.displayName} 反代 v${r.version}`);
16
17
  lines.push('');
17
18
  lines.push(`凭证 ${r.credential.ok ? '✓' : '✗'} ${r.credential.detail}`);
18
19
  lines.push(`上游 ${r.upstream}`);
19
- lines.push(`代理 ${baseUrl(r.host, r.port)}`);
20
+ /* 两种填法都列 —— 客户端对 base_url 的约定不统一(OpenAI 系要带 /v1,
21
+ Claude Code 只填 origin),只给一个必然误导一半人。 */
22
+ lines.push(`代理 ${origin}/v1 (OpenAI 系客户端:Cursor / Cherry Studio / OpenAI SDK)`);
23
+ lines.push(` ${origin} (Anthropic 系客户端:Claude Code,它自己会补 /v1)`);
20
24
  /* 密钥**完整**打印(不打码):它就是给用户复制进客户端的,打码等于不可用。
21
25
  ⚠️ 只在本机终端输出;`--json` 同样给完整值(供脚本消费)。 */
22
26
  lines.push(`密钥 ${r.key}`);
@@ -34,18 +38,24 @@ export function renderReady(r) {
34
38
  lines.push(` ${m.id}${hint}`);
35
39
  }
36
40
  lines.push('');
37
- lines.push(`把上面的「代理地址 + 密钥」填进 Cursor / Claude Code / Cherry Studio 等客户端即可。`);
41
+ lines.push(`把上面的「代理地址 + 密钥」填进对应的客户端即可(两行按你的客户端类型二选一)。`);
38
42
  lines.push('端点:POST /v1/chat/completions(OpenAI 兼容)· POST /v1/messages(Anthropic 兼容)· GET /v1/models');
39
43
  lines.push('按 Ctrl+C 停止。');
40
44
  return lines.join('\n');
41
45
  }
42
46
  export function renderReadyJson(r) {
47
+ const origin = baseUrl(r.host, r.port);
43
48
  return JSON.stringify({
44
49
  command: r.command,
45
50
  displayName: r.displayName,
46
51
  version: r.version,
47
52
  upstream: r.upstream,
48
- proxyUrl: baseUrl(r.host, r.port),
53
+ /* 两种 base_url 都给:openaiBaseUrl 带 /v1(Cursor / Cherry Studio 等);
54
+ anthropicBaseUrl 不带(Claude Code 自己补 /v1)。origin 是裸地址。 */
55
+ origin,
56
+ proxyUrl: origin,
57
+ openaiBaseUrl: `${origin}/v1`,
58
+ anthropicBaseUrl: origin,
49
59
  key: r.key,
50
60
  credential: { ok: r.credential.ok, detail: r.credential.detail, source: r.credential.source ?? null },
51
61
  models: r.models.map((m) => ({ id: m.id, displayName: m.displayName ?? null })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waygate-core",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Waygate 家族共享骨架:本地反代 HTTP 服务、入站密钥、CLI、自检",
5
5
  "type": "module",
6
6
  "license": "MIT",