@simonyea/holysheep-cli 1.2.4 → 1.2.6
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 +47 -25
package/package.json
CHANGED
package/src/tools/openclaw.js
CHANGED
|
@@ -70,7 +70,7 @@ 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
|
|
73
|
+
// 总是覆写为 HolySheep 最新 Sonnet 4.6
|
|
74
74
|
config.agents.defaults.model = {
|
|
75
75
|
primary: 'anthropic/claude-sonnet-4-6',
|
|
76
76
|
}
|
|
@@ -84,7 +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
|
+
{ id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6 (HolySheep)' },
|
|
88
88
|
{ id: 'claude-sonnet-4-5-20250929', name: 'Claude Sonnet 4.5 (HolySheep)' },
|
|
89
89
|
{ id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4 (HolySheep)' },
|
|
90
90
|
{ id: 'claude-opus-4-5-20251101', name: 'Claude Opus 4.5 (HolySheep)' },
|
|
@@ -138,8 +138,8 @@ module.exports = {
|
|
|
138
138
|
|
|
139
139
|
writeConfig(config)
|
|
140
140
|
|
|
141
|
-
//
|
|
142
|
-
|
|
141
|
+
// 自动初始化并启动 Gateway
|
|
142
|
+
_initAndStartGateway()
|
|
143
143
|
|
|
144
144
|
return { file: CONFIG_FILE, hot: false, _gatewayStarted: true }
|
|
145
145
|
},
|
|
@@ -168,42 +168,64 @@ module.exports = {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
171
|
+
* 自动初始化并启动 OpenClaw Gateway
|
|
172
172
|
*
|
|
173
|
-
*
|
|
174
|
-
* 1. openclaw
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
173
|
+
* 策略:
|
|
174
|
+
* 1. openclaw onboard --non-interactive --install-daemon
|
|
175
|
+
* 读取已写好的 openclaw.json,无交互完成初始化 + 注册系统服务 + 启动 gateway
|
|
176
|
+
* 2. 若 onboard 失败(如 Windows 不支持 daemon),直接 gateway start
|
|
177
|
+
* 3. 仍失败 → Windows: start /B openclaw gateway;Unix: detached spawn
|
|
178
178
|
*/
|
|
179
|
-
function
|
|
179
|
+
function _initAndStartGateway() {
|
|
180
180
|
const chalk = require('chalk')
|
|
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(约 15 秒)...'))
|
|
184
185
|
|
|
185
|
-
//
|
|
186
|
-
const r1 = spawnSync(bin, ['
|
|
186
|
+
// Step 1: 无交互 onboard + install-daemon
|
|
187
|
+
const r1 = spawnSync(bin, ['onboard', '--non-interactive', '--install-daemon'], {
|
|
187
188
|
shell: true,
|
|
188
|
-
timeout:
|
|
189
|
+
timeout: 60000,
|
|
189
190
|
stdio: 'pipe',
|
|
191
|
+
env: { ...process.env },
|
|
190
192
|
})
|
|
193
|
+
|
|
191
194
|
if (r1.status === 0) {
|
|
192
|
-
console.log(chalk.green(' ✓ OpenClaw Gateway 已在后台启动'))
|
|
195
|
+
console.log(chalk.green(' ✓ OpenClaw 初始化完成,Gateway 已在后台启动'))
|
|
196
|
+
console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
|
|
193
197
|
return
|
|
194
198
|
}
|
|
195
199
|
|
|
196
|
-
//
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
stdio: 'ignore',
|
|
200
|
+
// Step 2: onboard 失败,直接 gateway start
|
|
201
|
+
const r2 = spawnSync(bin, ['gateway', 'start'], {
|
|
202
|
+
shell: true,
|
|
203
|
+
timeout: 15000,
|
|
204
|
+
stdio: 'pipe',
|
|
202
205
|
})
|
|
203
|
-
|
|
206
|
+
if (r2.status === 0) {
|
|
207
|
+
console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
|
|
208
|
+
console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Step 3: fallback — 后台守护进程
|
|
213
|
+
if (isWin) {
|
|
214
|
+
// Windows: 用 cmd start 开新窗口后台运行
|
|
215
|
+
spawnSync('cmd', ['/c', `start /B "" openclaw gateway --port 18789`], {
|
|
216
|
+
shell: true, stdio: 'ignore',
|
|
217
|
+
})
|
|
218
|
+
} else {
|
|
219
|
+
const { spawn } = require('child_process')
|
|
220
|
+
const child = spawn(bin, ['gateway', '--port', '18789'], {
|
|
221
|
+
detached: true,
|
|
222
|
+
stdio: 'ignore',
|
|
223
|
+
})
|
|
224
|
+
child.unref()
|
|
225
|
+
}
|
|
204
226
|
|
|
205
|
-
// 等
|
|
206
|
-
|
|
227
|
+
// 等 3 秒让 gateway 起来
|
|
228
|
+
const t = Date.now(); while (Date.now() - t < 3000) {}
|
|
207
229
|
|
|
208
230
|
console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
|
|
209
231
|
console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
|