yingclaw 2.5.11 → 2.5.12

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 CHANGED
@@ -93,9 +93,9 @@ claw setup # 兼容旧命令:config + code
93
93
 
94
94
  | 平台 | 终端接入 | 桌面接入 |
95
95
  |------|---------|---------|
96
- | macOS | ✅ 写入 `~/.zshrc` | ✅ 自动重启 Claude Desktop |
96
+ | macOS | ✅ 写入 `~/.zshrc` | ✅ 自动启动本机 Gateway 并重启 Claude Desktop |
97
97
  | Linux / WSL | ✅ 写入 `~/.zshrc` / `~/.bashrc` | — |
98
- | Windows | ✅ 写入用户级环境变量(需重开终端) | ✅ 写入 `%APPDATA%\Claude-3p\` |
98
+ | Windows | ✅ 写入用户级环境变量(需重开终端) | ✅ 写入 `%APPDATA%\Claude-3p\`,并写入登录启动脚本 |
99
99
 
100
100
  ## 原理
101
101
 
@@ -115,6 +115,7 @@ CLAUDE_CODE_EFFORT_LEVEL
115
115
  - macOS / Windows:写入 `Claude-3p/configLibrary/` 中的 yingclaw entry
116
116
  - Claude Desktop 访问 `http://127.0.0.1:18080/yingclaw`
117
117
  - Gateway 再转发到当前保存的 Anthropic 兼容接口
118
+ - macOS 使用 LaunchAgent 登录启动 Gateway,Windows 使用 Startup 目录脚本登录启动 Gateway
118
119
  - 终端接入仍直接使用 `ANTHROPIC_*` 环境变量,不受桌面 Gateway 影响
119
120
 
120
121
  使用 `inferenceProvider=gateway`、`inferenceGatewayAuthScheme=bearer`,将 Gateway Base URL 指向 yingclaw 本机 Gateway。高级用户可用 `claw desktop --direct` 保留旧式直连写入,但新版 Claude Desktop 可能拒绝非 Claude 模型名。
package/lib/autostart.js CHANGED
@@ -4,6 +4,7 @@ const path = require('path');
4
4
  const { spawnSync } = require('child_process');
5
5
 
6
6
  const GATEWAY_LAUNCH_AGENT_LABEL = 'com.yingclaw.gateway';
7
+ const WINDOWS_GATEWAY_STARTUP_SCRIPT = 'yingclaw-gateway.cmd';
7
8
 
8
9
  function xmlEscape(value) {
9
10
  return String(value)
@@ -19,6 +20,12 @@ function getMacLaunchAgentPath(options = {}) {
19
20
  return path.join(homeDir, 'Library', 'LaunchAgents', `${GATEWAY_LAUNCH_AGENT_LABEL}.plist`);
20
21
  }
21
22
 
23
+ function getWindowsStartupScriptPath(options = {}) {
24
+ const homeDir = options.homeDir || os.homedir();
25
+ const appData = options.appData || process.env.APPDATA || path.join(homeDir, 'AppData', 'Roaming');
26
+ return path.join(appData, 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup', WINDOWS_GATEWAY_STARTUP_SCRIPT);
27
+ }
28
+
22
29
  function buildMacLaunchAgentPlist(options = {}) {
23
30
  const nodePath = options.nodePath || process.execPath;
24
31
  const cliPath = options.cliPath || path.join(__dirname, '..', 'bin', 'cli.js');
@@ -54,6 +61,19 @@ function buildMacLaunchAgentPlist(options = {}) {
54
61
  `;
55
62
  }
56
63
 
64
+ function buildWindowsGatewayStartupScript(options = {}) {
65
+ const nodePath = options.nodePath || process.execPath;
66
+ const cliPath = options.cliPath || path.join(__dirname, '..', 'bin', 'cli.js');
67
+ const workingDirectory = options.workingDirectory || path.join(__dirname, '..');
68
+
69
+ return [
70
+ '@echo off',
71
+ `cd /d "${workingDirectory}"`,
72
+ `start "" /min "${nodePath}" "${cliPath}" gateway`,
73
+ '',
74
+ ].join('\r\n');
75
+ }
76
+
57
77
  function runLaunchctl(runner, args, options = {}) {
58
78
  const result = runner('launchctl', args, { encoding: 'utf8', stdio: 'pipe' });
59
79
  if (result.status !== 0 && !options.optional) {
@@ -92,8 +112,24 @@ function waitForLaunchAgentUnload(runner, service, options = {}) {
92
112
  } while (true);
93
113
  }
94
114
 
115
+ function isWindowsPortListening(runner, port) {
116
+ const result = runner('powershell.exe', [
117
+ '-NoProfile',
118
+ '-Command',
119
+ `if (Get-NetTCPConnection -LocalAddress 127.0.0.1 -LocalPort ${Number(port)} -State Listen -ErrorAction SilentlyContinue) { 'LISTEN' }`,
120
+ ], { encoding: 'utf8', stdio: 'pipe', windowsHide: true });
121
+ return result.status === 0 && /LISTEN/i.test(`${result.stdout || ''}\n${result.stderr || ''}`);
122
+ }
123
+
95
124
  function installGatewayAutostart(options = {}) {
96
125
  const platform = options.platform || process.platform;
126
+ if (platform === 'win32') {
127
+ const file = options.file || getWindowsStartupScriptPath(options);
128
+ fs.mkdirSync(path.dirname(file), { recursive: true });
129
+ fs.writeFileSync(file, buildWindowsGatewayStartupScript(options), 'utf8');
130
+ return { result: 'installed', file };
131
+ }
132
+
97
133
  if (platform !== 'darwin') {
98
134
  return { result: 'unsupported', file: null };
99
135
  }
@@ -133,6 +169,18 @@ function installGatewayAutostart(options = {}) {
133
169
 
134
170
  function getGatewayAutostartStatus(options = {}) {
135
171
  const platform = options.platform || process.platform;
172
+ if (platform === 'win32') {
173
+ const file = options.file || getWindowsStartupScriptPath(options);
174
+ const runner = options.runner || spawnSync;
175
+ const port = options.port || 18080;
176
+ return {
177
+ supported: true,
178
+ installed: fs.existsSync(file),
179
+ running: isWindowsPortListening(runner, port),
180
+ file,
181
+ };
182
+ }
183
+
136
184
  if (platform !== 'darwin') {
137
185
  return { supported: false, installed: false, running: false, file: null };
138
186
  }
@@ -162,7 +210,9 @@ function getGatewayAutostartStatus(options = {}) {
162
210
  module.exports = {
163
211
  GATEWAY_LAUNCH_AGENT_LABEL,
164
212
  buildMacLaunchAgentPlist,
213
+ buildWindowsGatewayStartupScript,
165
214
  getGatewayAutostartStatus,
166
215
  getMacLaunchAgentPath,
216
+ getWindowsStartupScriptPath,
167
217
  installGatewayAutostart,
168
218
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yingclaw",
3
- "version": "2.5.11",
3
+ "version": "2.5.12",
4
4
  "description": "Claude Code × 国产大模型一键接入:DeepSeek、Kimi、Qwen、MiniMax、GLM、MiMo",
5
5
  "main": "index.js",
6
6
  "bin": {