@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "一键配置所有 AI 编程工具接入 HolySheep API — Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw / Aider / Cursor",
5
5
  "keywords": [
6
6
  "claude",
@@ -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(Custom Provider,Anthropic-compatible)────────
59
- // openclaw 通过 auth profile 管理凭证;写入一个 holysheep profile
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
- config.auth.default = 'holysheep'
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
- if (!config.gateway.bind) config.gateway.bind = '127.0.0.1'
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. Workspace 默认路径 ─────────────────────────────────────────
109
- if (!config.workspace) {
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(bin, ['gateway', 'start'], {
202
- shell: true, timeout: 10000, stdio: 'pipe',
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: 无交互 onboard --install-daemon(注册系统服务)
211
- console.log(chalk.gray(' → 首次初始化,注册系统服务...'))
212
- const r2 = spawnSync(bin, ['onboard', '--non-interactive', '--install-daemon'], {
213
- shell: true, timeout: 60000, stdio: 'pipe',
214
- env: { ...process.env },
215
- })
216
- // 再次尝试 start
217
- const r3 = spawnSync(bin, ['gateway', 'start'], {
218
- shell: true, timeout: 10000, stdio: 'pipe',
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/'))