@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 +1 -1
- package/src/tools/openclaw.js +58 -28
package/package.json
CHANGED
package/src/tools/openclaw.js
CHANGED
|
@@ -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
|
|
73
|
+
// 总是覆写为 HolySheep 最新 Sonnet 4.6
|
|
74
74
|
config.agents.defaults.model = {
|
|
75
|
-
primary: 'anthropic/claude-sonnet-4-
|
|
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 ⚙️
|
|
184
|
+
console.log(chalk.gray('\n ⚙️ 正在启动 OpenClaw Gateway...'))
|
|
184
185
|
|
|
185
|
-
// Step 1:
|
|
186
|
-
const r1 = spawnSync(bin, ['
|
|
187
|
-
shell:
|
|
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
|
|
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
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
timeout:
|
|
203
|
-
|
|
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
|
-
|
|
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:
|
|
214
|
-
spawnSync('
|
|
215
|
-
|
|
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
|
-
// 等
|
|
227
|
-
const
|
|
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
|
-
|
|
230
|
-
|
|
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
|
}
|