@simonyea/holysheep-cli 1.2.8 → 1.2.9
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 +34 -24
package/package.json
CHANGED
package/src/tools/openclaw.js
CHANGED
|
@@ -55,17 +55,16 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
|
|
|
55
55
|
config.env.ANTHROPIC_API_KEY = apiKey
|
|
56
56
|
config.env.ANTHROPIC_BASE_URL = baseUrlAnthropicNoV1 // https://api.holysheep.ai
|
|
57
57
|
|
|
58
|
-
// ── 2. Auth profile
|
|
59
|
-
// openclaw
|
|
58
|
+
// ── 2. Auth profile — openclaw 官方格式(Anthropic API key)─────────
|
|
59
|
+
// 参考: docs.openclaw.ai — auth profile type=anthropic-api-key
|
|
60
60
|
if (!config.auth) config.auth = {}
|
|
61
61
|
if (!config.auth.profiles) config.auth.profiles = {}
|
|
62
62
|
config.auth.profiles.holysheep = {
|
|
63
|
-
type: 'api-key',
|
|
64
63
|
provider: 'anthropic',
|
|
65
|
-
apiKey,
|
|
64
|
+
key: apiKey,
|
|
66
65
|
baseUrl: baseUrlAnthropicNoV1,
|
|
67
66
|
}
|
|
68
|
-
|
|
67
|
+
// 不设 auth.default — openclaw 不认识这个字段
|
|
69
68
|
|
|
70
69
|
// ── 3. 默认模型 ────────────────────────────────────────────────────
|
|
71
70
|
if (!config.agents) config.agents = {}
|
|
@@ -94,10 +93,13 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
|
|
|
94
93
|
],
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
// ── 5. Gateway
|
|
96
|
+
// ── 5. Gateway 配置(使用 openclaw 2026+ 格式)──────────────────────
|
|
98
97
|
if (!config.gateway) config.gateway = {}
|
|
99
98
|
if (!config.gateway.port) config.gateway.port = 18789
|
|
100
|
-
|
|
99
|
+
// bind 用新格式的 mode,不用 IP 字符串
|
|
100
|
+
if (!config.gateway.bind || config.gateway.bind === '127.0.0.1' || config.gateway.bind === 'localhost') {
|
|
101
|
+
config.gateway.bind = 'loopback'
|
|
102
|
+
}
|
|
101
103
|
// 生成 gateway token(若已有则不覆盖)
|
|
102
104
|
if (!config.gateway.auth) config.gateway.auth = {}
|
|
103
105
|
if (!config.gateway.auth.token) {
|
|
@@ -105,10 +107,8 @@ function buildFullConfig(existing, apiKey, baseUrlAnthropicNoV1, baseUrlOpenAI)
|
|
|
105
107
|
config.gateway.auth.mode = 'token'
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
// ── 6.
|
|
109
|
-
|
|
110
|
-
config.workspace = path.join(OPENCLAW_DIR, 'workspace')
|
|
111
|
-
}
|
|
110
|
+
// ── 6. 不写 workspace 字段(openclaw 不认识,会报 unknown key)──────
|
|
111
|
+
delete config.workspace
|
|
112
112
|
|
|
113
113
|
return config
|
|
114
114
|
}
|
|
@@ -197,26 +197,36 @@ function _initAndStartGateway() {
|
|
|
197
197
|
|
|
198
198
|
console.log(chalk.gray('\n ⚙️ 正在启动 OpenClaw Gateway...'))
|
|
199
199
|
|
|
200
|
+
// Step 0: 先 doctor --fix 修复配置兼容性问题
|
|
201
|
+
spawnSync(isWin ? 'npx' : bin,
|
|
202
|
+
isWin ? ['openclaw', 'doctor', '--fix'] : ['doctor', '--fix'],
|
|
203
|
+
{ shell: true, timeout: 15000, stdio: 'ignore' }
|
|
204
|
+
)
|
|
205
|
+
|
|
200
206
|
// Step 1: gateway start(已有 daemon 时直接生效)
|
|
201
|
-
const r1 = spawnSync(
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
const r1 = spawnSync(
|
|
208
|
+
isWin ? 'npx' : bin,
|
|
209
|
+
isWin ? ['openclaw', 'gateway', 'start'] : ['gateway', 'start'],
|
|
210
|
+
{ shell: true, timeout: 10000, stdio: 'pipe' }
|
|
211
|
+
)
|
|
204
212
|
if (r1.status === 0) {
|
|
205
213
|
console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
|
|
206
214
|
console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
|
|
207
215
|
return
|
|
208
216
|
}
|
|
209
217
|
|
|
210
|
-
// Step 2:
|
|
211
|
-
console.log(chalk.gray(' →
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const r3 = spawnSync(
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
// Step 2: 安装系统服务 + 启动
|
|
219
|
+
console.log(chalk.gray(' → 注册系统服务...'))
|
|
220
|
+
spawnSync(
|
|
221
|
+
isWin ? 'npx' : bin,
|
|
222
|
+
isWin ? ['openclaw', 'gateway', 'install'] : ['gateway', 'install'],
|
|
223
|
+
{ shell: true, timeout: 30000, stdio: 'ignore' }
|
|
224
|
+
)
|
|
225
|
+
const r3 = spawnSync(
|
|
226
|
+
isWin ? 'npx' : bin,
|
|
227
|
+
isWin ? ['openclaw', 'gateway', 'start'] : ['gateway', 'start'],
|
|
228
|
+
{ shell: true, timeout: 10000, stdio: 'pipe' }
|
|
229
|
+
)
|
|
220
230
|
if (r3.status === 0) {
|
|
221
231
|
console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
|
|
222
232
|
console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
|