baozang-activator 1.2.1 → 1.2.2

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/README.md CHANGED
@@ -201,7 +201,7 @@ requires_openai_auth = true
201
201
  - 配置完成后会自动:
202
202
  - 启动网关 `openclaw gateway start`
203
203
  - 校验安装结果(版本 + 网关状态)
204
- - 自动打开浏览器到网关 Dashboard(默认 `http://127.0.0.1:18789/`)
204
+ - 自动通过 `openclaw dashboard --no-open` 获取带 token 的 Dashboard 链接并打开浏览器(默认地址 `http://127.0.0.1:18789/`)
205
205
  - 提示后续操作(默认不需要关联社交账号)
206
206
  - 可预装常见 skills(默认开启):`xiaohongshu`、`zhihu`、`wechat-official`、`douyin-script`
207
207
 
package/bin/cli.js CHANGED
@@ -284,11 +284,16 @@ async function doConfig(type, apiKey, config) {
284
284
 
285
285
  console.log('');
286
286
  console.log(chalk.yellow('打开网关控制台(Dashboard):'));
287
- console.log(chalk.cyan(` ${result.dashboardUrl || 'http://127.0.0.1:18789/'}`));
287
+ const dashboardDisplayUrl = result.dashboardUrl || 'http://127.0.0.1:18789/';
288
+ const dashboardOpenUrl = result.dashboardOpenUrl || dashboardDisplayUrl;
289
+ console.log(chalk.cyan(` ${dashboardDisplayUrl}`));
290
+ if (result.dashboardTokenized) {
291
+ console.log(chalk.gray(' (已自动携带 gateway token 打开浏览器)'));
292
+ }
288
293
 
289
- const opened = openBrowser(result.dashboardUrl || 'http://127.0.0.1:18789/');
294
+ const opened = openBrowser(dashboardOpenUrl);
290
295
  if (!opened) {
291
- console.log(chalk.gray(' (无法自动打开浏览器,请手动复制以上地址到浏览器)'));
296
+ console.log(chalk.gray(' (无法自动打开浏览器,请运行 openclaw dashboard 或 openclaw dashboard --no-open 获取带 token 链接)'));
292
297
  }
293
298
 
294
299
  console.log('');
@@ -649,6 +649,7 @@ function configureOpenClaw(apiKey, config) {
649
649
  restartGateway,
650
650
  getGatewayStatusText,
651
651
  installBuiltinSkills,
652
+ getDashboardUrl,
652
653
  getDefaultDashboardUrl,
653
654
  } = require('./openclaw');
654
655
 
@@ -711,6 +712,9 @@ function configureOpenClaw(apiKey, config) {
711
712
  }
712
713
 
713
714
  const gatewayStatus = getGatewayStatusText();
715
+ const dashboard = getDashboardUrl({ includeToken: true });
716
+ const dashboardUrl = getDefaultDashboardUrl();
717
+ const dashboardOpenUrl = sanitizeValue((dashboard && dashboard.url) || '') || dashboardUrl;
714
718
 
715
719
  return {
716
720
  installed: install.installed,
@@ -721,7 +725,9 @@ function configureOpenClaw(apiKey, config) {
721
725
  modelId,
722
726
  primaryModel,
723
727
  configFile,
724
- dashboardUrl: getDefaultDashboardUrl(),
728
+ dashboardUrl,
729
+ dashboardOpenUrl,
730
+ dashboardTokenized: !!(dashboard && dashboard.tokenized),
725
731
  gatewayStatus: gatewayStatus.text,
726
732
  skillsDir: skillMeta ? skillMeta.dir : '',
727
733
  installedSkills: skillMeta ? skillMeta.skills : [],
package/lib/index.js CHANGED
@@ -28,6 +28,7 @@ const {
28
28
  uninstallOpenClaw,
29
29
  openBrowser,
30
30
  getDefaultDashboardUrl,
31
+ getDashboardUrl,
31
32
  } = require('./openclaw');
32
33
 
33
34
  module.exports = {
@@ -60,4 +61,5 @@ module.exports = {
60
61
  uninstallOpenClaw,
61
62
  openBrowser,
62
63
  getDefaultDashboardUrl,
64
+ getDashboardUrl,
63
65
  };
package/lib/openclaw.js CHANGED
@@ -152,6 +152,49 @@ function getDefaultDashboardUrl() {
152
152
  return 'http://127.0.0.1:18789/';
153
153
  }
154
154
 
155
+ function extractFirstUrl(text) {
156
+ const matched = String(text || '').match(/https?:\/\/[^\s"'<>]+/i);
157
+ if (!matched) {
158
+ return '';
159
+ }
160
+ return sanitizeText(matched[0]).replace(/[),.;]+$/, '');
161
+ }
162
+
163
+ function getDashboardUrl(options = {}) {
164
+ const includeToken = (options && options.includeToken) !== false;
165
+ const fallback = getDefaultDashboardUrl();
166
+ if (!includeToken) {
167
+ return {
168
+ ok: true,
169
+ url: fallback,
170
+ tokenized: false,
171
+ source: 'default',
172
+ error: '',
173
+ };
174
+ }
175
+
176
+ const result = openclaw(['dashboard', '--no-open'], { stdio: ['ignore', 'pipe', 'pipe'] });
177
+ const combined = `${result.stdout || ''}\n${result.stderr || ''}`;
178
+ const url = extractFirstUrl(combined);
179
+ if (url) {
180
+ return {
181
+ ok: true,
182
+ url,
183
+ tokenized: url.includes('#token='),
184
+ source: 'openclaw-dashboard',
185
+ error: '',
186
+ };
187
+ }
188
+
189
+ return {
190
+ ok: false,
191
+ url: fallback,
192
+ tokenized: false,
193
+ source: 'default',
194
+ error: sanitizeText(combined || '无法获取 Dashboard 地址'),
195
+ };
196
+ }
197
+
155
198
  function openclaw(args, options = {}) {
156
199
  const resolved = resolveOpenClawCommand();
157
200
  const env = resolved.env ? resolved.env : process.env;
@@ -740,5 +783,6 @@ module.exports = {
740
783
  uninstallOpenClaw,
741
784
  openBrowser,
742
785
  getDefaultDashboardUrl,
786
+ getDashboardUrl,
743
787
  HOME,
744
788
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baozang-activator",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "API 激活工具 (生产环境 - baozangaizhongzhuan.net)",
5
5
  "main": "lib/index.js",
6
6
  "bin": {