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