@simonyea/holysheep-cli 1.3.7 → 1.3.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 +24 -7
package/package.json
CHANGED
package/src/tools/openclaw.js
CHANGED
|
@@ -47,6 +47,7 @@ function writeCorrectConfig(apiKey, baseUrl) {
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
gateway: {
|
|
50
|
+
mode: 'local', // 必须设置,否则 gateway start 被 blocked
|
|
50
51
|
port: 18789,
|
|
51
52
|
bind: 'loopback', // 新格式,不用 "127.0.0.1"
|
|
52
53
|
auth: {
|
|
@@ -98,19 +99,31 @@ module.exports = {
|
|
|
98
99
|
// 2. doctor --fix 修复任何兼容性问题
|
|
99
100
|
npx('doctor', '--fix')
|
|
100
101
|
|
|
102
|
+
// 读取写入的 token(用于生成带 token 的直接访问 URL)
|
|
103
|
+
let savedToken = ''
|
|
104
|
+
try {
|
|
105
|
+
const cfg = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'))
|
|
106
|
+
savedToken = cfg?.gateway?.auth?.token || ''
|
|
107
|
+
} catch {}
|
|
108
|
+
|
|
101
109
|
// 3. 启动 Gateway
|
|
102
110
|
console.log(chalk.gray(' → 正在启动 Gateway...'))
|
|
103
111
|
const ok = _startGateway()
|
|
104
112
|
|
|
105
113
|
if (ok) {
|
|
106
114
|
console.log(chalk.green(' ✓ OpenClaw Gateway 已启动'))
|
|
107
|
-
console.log(chalk.cyan(' → 浏览器打开: http://127.0.0.1:18789/'))
|
|
108
115
|
} else {
|
|
109
|
-
console.log(chalk.yellow(' ⚠️
|
|
110
|
-
console.log(chalk.cyan(isWin ? ' npx openclaw gateway' : ' openclaw gateway'))
|
|
116
|
+
console.log(chalk.yellow(' ⚠️ Gateway 正在启动,请稍等几秒...'))
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
|
|
119
|
+
// 打印带 token 的直接访问 URL(无需手动填 token)
|
|
120
|
+
const dashUrl = savedToken
|
|
121
|
+
? `http://127.0.0.1:18789/?token=${savedToken}`
|
|
122
|
+
: 'http://127.0.0.1:18789/'
|
|
123
|
+
console.log(chalk.cyan(`\n → 浏览器打开(已含 token,直接可用):`))
|
|
124
|
+
console.log(chalk.bold.cyan(` ${dashUrl}`))
|
|
125
|
+
|
|
126
|
+
return { file: CONFIG_FILE, hot: false, _dashUrl: dashUrl }
|
|
114
127
|
},
|
|
115
128
|
|
|
116
129
|
reset() {
|
|
@@ -121,9 +134,13 @@ module.exports = {
|
|
|
121
134
|
hint: 'Gateway 已启动,打开浏览器即可使用',
|
|
122
135
|
launchCmd: null,
|
|
123
136
|
get launchNote() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
// 读取 token,生成带 token 的 URL
|
|
138
|
+
try {
|
|
139
|
+
const cfg = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'))
|
|
140
|
+
const token = cfg?.gateway?.auth?.token
|
|
141
|
+
if (token) return `🌐 浏览器打开(含 token): http://127.0.0.1:18789/?token=${token}`
|
|
142
|
+
} catch {}
|
|
143
|
+
return '🌐 打开浏览器: http://127.0.0.1:18789/'
|
|
127
144
|
},
|
|
128
145
|
installCmd: 'npm install -g openclaw@latest',
|
|
129
146
|
docsUrl: 'https://docs.openclaw.ai',
|