@simonyea/holysheep-cli 1.2.5 → 1.2.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "一键配置所有 AI 编程工具接入 HolySheep API — Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw / Aider / Cursor",
5
5
  "keywords": [
6
6
  "claude",
@@ -70,9 +70,9 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
70
70
  // ── 3. 默认模型 ────────────────────────────────────────────────────
71
71
  if (!config.agents) config.agents = {}
72
72
  if (!config.agents.defaults) config.agents.defaults = {}
73
- // 总是覆写为 HolySheep 最新 Sonnet(用户可以在 /model 命令里切换)
73
+ // 总是覆写为 HolySheep 最新 Sonnet 4.6
74
74
  config.agents.defaults.model = {
75
- primary: 'anthropic/claude-sonnet-4-5-20250929',
75
+ primary: 'anthropic/claude-sonnet-4-6',
76
76
  }
77
77
 
78
78
  // ── 4. 自定义 holysheep provider(OpenAI-compatible,支持所有模型)
@@ -84,6 +84,7 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
84
84
  apiKey,
85
85
  api: 'openai-completions',
86
86
  models: [
87
+ { id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6 (HolySheep)' },
87
88
  { id: 'claude-sonnet-4-5-20250929', name: 'Claude Sonnet 4.5 (HolySheep)' },
88
89
  { id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4 (HolySheep)' },
89
90
  { id: 'claude-opus-4-5-20251101', name: 'Claude Opus 4.5 (HolySheep)' },
@@ -180,52 +181,81 @@ function _initAndStartGateway() {
180
181
  const isWin = process.platform === 'win32'
181
182
  const bin = 'openclaw'
182
183
 
183
- console.log(chalk.gray('\n ⚙️ 正在初始化并启动 OpenClaw Gateway(约 15 秒)...'))
184
+ console.log(chalk.gray('\n ⚙️ 正在启动 OpenClaw Gateway...'))
184
185
 
185
- // Step 1: 无交互 onboard + install-daemon
186
- const r1 = spawnSync(bin, ['onboard', '--non-interactive', '--install-daemon'], {
187
- shell: true,
188
- timeout: 60000,
189
- stdio: 'pipe',
190
- env: { ...process.env },
186
+ // Step 1: gateway start(已有 daemon 时直接生效)
187
+ const r1 = spawnSync(bin, ['gateway', 'start'], {
188
+ shell: true, timeout: 10000, stdio: 'pipe',
191
189
  })
192
-
193
190
  if (r1.status === 0) {
194
- console.log(chalk.green(' ✓ OpenClaw 初始化完成,Gateway 已在后台启动'))
191
+ console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
195
192
  console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
196
193
  return
197
194
  }
198
195
 
199
- // Step 2: onboard 失败,直接 gateway start
200
- const r2 = spawnSync(bin, ['gateway', 'start'], {
201
- shell: true,
202
- timeout: 15000,
203
- stdio: 'pipe',
196
+ // Step 2: 无交互 onboard --install-daemon(注册系统服务)
197
+ console.log(chalk.gray(' 首次初始化,注册系统服务...'))
198
+ const r2 = spawnSync(bin, ['onboard', '--non-interactive', '--install-daemon'], {
199
+ shell: true, timeout: 60000, stdio: 'pipe',
200
+ env: { ...process.env },
204
201
  })
205
- if (r2.status === 0) {
202
+ // 再次尝试 start
203
+ const r3 = spawnSync(bin, ['gateway', 'start'], {
204
+ shell: true, timeout: 10000, stdio: 'pipe',
205
+ })
206
+ if (r3.status === 0) {
206
207
  console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
207
208
  console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
208
209
  return
209
210
  }
210
211
 
211
- // Step 3: fallback — 后台守护进程
212
+ // Step 3: fallback — 直接后台运行进程
213
+ console.log(chalk.gray(' → 以守护进程模式启动...'))
212
214
  if (isWin) {
213
- // Windows: cmd start 开新窗口后台运行
214
- spawnSync('cmd', ['/c', `start /B "" openclaw gateway --port 18789`], {
215
- shell: true, stdio: 'ignore',
216
- })
215
+ // Windows: PowerShell Start-Process 后台运行,不弹窗
216
+ spawnSync('powershell', [
217
+ '-NonInteractive', '-WindowStyle', 'Hidden', '-Command',
218
+ `Start-Process -FilePath "openclaw" -ArgumentList "gateway","--port","18789" -WindowStyle Hidden`
219
+ ], { shell: false, timeout: 5000, stdio: 'ignore' })
217
220
  } else {
218
221
  const { spawn } = require('child_process')
219
222
  const child = spawn(bin, ['gateway', '--port', '18789'], {
220
- detached: true,
221
- stdio: 'ignore',
223
+ detached: true, stdio: 'ignore',
222
224
  })
223
225
  child.unref()
224
226
  }
225
227
 
226
- // 等 3 秒让 gateway 起来
227
- const t = Date.now(); while (Date.now() - t < 3000) {}
228
+ // 等 4 秒让 gateway 起来再报告
229
+ const deadline = Date.now() + 4000
230
+ while (Date.now() < deadline) {}
231
+
232
+ // 验证是否真的起来了
233
+ const http = require('http')
234
+ const verify = new Promise(resolve => {
235
+ const req = http.get('http://127.0.0.1:18789/', res => resolve(true))
236
+ req.on('error', () => resolve(false))
237
+ req.setTimeout(3000, () => { req.destroy(); resolve(false) })
238
+ })
239
+
240
+ // 用同步方式等验证(node 18+)
241
+ let ok = false
242
+ try {
243
+ const { execSync } = require('child_process')
244
+ execSync(
245
+ isWin
246
+ ? 'powershell -NonInteractive -Command "Invoke-WebRequest -Uri http://127.0.0.1:18789/ -TimeoutSec 3 -UseBasicParsing | Out-Null"'
247
+ : 'curl -sf http://127.0.0.1:18789/ -o /dev/null --max-time 3',
248
+ { stdio: 'ignore', timeout: 5000 }
249
+ )
250
+ ok = true
251
+ } catch {}
228
252
 
229
- console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
230
- console.log(chalk.cyan(' 浏览器打开: http://127.0.0.1:18789/'))
253
+ if (ok) {
254
+ console.log(chalk.green(' OpenClaw Gateway 已启动'))
255
+ console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
256
+ } else {
257
+ console.log(chalk.yellow(' ⚠️ Gateway 启动中,请稍等 10 秒后访问:'))
258
+ console.log(chalk.cyan(' → http://127.0.0.1:18789/'))
259
+ console.log(chalk.gray(' 如仍无法访问,请手动运行: openclaw gateway start'))
260
+ }
231
261
  }