@baize-ai/core 0.3.9 → 0.3.11

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/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to baize-core will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.11] - 2026-08-27
9
+
10
+ ### Fixed
11
+ - web-console 渠道安装:`cliPath()` 增加大陆 install.sh 布局候选(`~/.local/node/lib/node_modules/@baize-ai/core/cli/baize.js`)+ `npm root -g` 动态兜底——此前候选硬编码 `~/.npm-global`,大陆安装(Node 在 `~/.local/node`)报「baize CLI not found」,web 安装飞书/渠道失败
12
+
13
+ ## [0.3.10] - 2026-08-27
14
+
15
+ ### Fixed
16
+ - web-console 重启 agent 会话改为**硬杀**(`tmux kill-session`)——卡 OAuth 登录页的会话不再因不响应 /exit 而卡死;codex 与 claude 会话均生效
17
+ - `agentSessionName` 修复 ESM 下 `require is not defined` 的隐藏 bug——此前保存 key/重启永远定位 claude-main,从未命中 codex-main(0.3.5 起)
18
+
8
19
  ## [0.3.9] - 2026-08-27
9
20
 
10
21
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baize-ai/core",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "description": "Baize (\u767d\u6cfd) \u2014 autonomous AI agent infrastructure",
6
6
  "main": "cli/baize.js",
@@ -45,8 +45,8 @@ function agentSessionName() {
45
45
  if (process.env.CLAUDE_SESSION) return process.env.CLAUDE_SESSION;
46
46
  let runtime = 'claude';
47
47
  try {
48
- const cfg = JSON.parse(require('node:fs').readFileSync(
49
- require('node:path').join(homeDir(), 'baize', '.baize', 'config.json'), 'utf8'));
48
+ const cfg = JSON.parse(fs.readFileSync(
49
+ path.join(baizeDir(), '.baize', 'config.json'), 'utf8'));
50
50
  if (cfg && cfg.runtime) runtime = cfg.runtime;
51
51
  } catch { /* default claude */ }
52
52
  return runtime === 'codex' ? 'codex-main' : 'claude-main';
@@ -359,9 +359,13 @@ export async function switchRuntime(name) {
359
359
  }
360
360
 
361
361
  /**
362
- * Restart the agent session by sending /exit to the tmux session; the activity
363
- * monitor relaunches it with fresh env (which merges ~/baize/.env). No-op with
364
- * a clear reason when no session is running.
362
+ * Restart the agent session by killing the tmux session; the activity monitor
363
+ * relaunches it with fresh env (which merges ~/baize/.env). The kill is hard
364
+ * by design: a session stuck on an OAuth/login screen ignores /exit, so a soft
365
+ * restart silently failed and left the agent wedged until a manual
366
+ * `tmux kill-session`. State continuity is preserved by codex/Claude session
367
+ * files (turn-level) plus baize memory sync; the Guardian injects startup
368
+ * context on relaunch. Applies to both runtimes (codex-main / claude-main).
365
369
  * @returns {Promise<{success: boolean, restarted: boolean, pending?: boolean, reason?: string}>}
366
370
  */
367
371
  export async function restartAgentSession() {
@@ -378,7 +382,7 @@ export async function restartAgentSession() {
378
382
  return { success: true, restarted: false, pending: true, reason: 'no_session' };
379
383
  }
380
384
  try {
381
- await execFileAsync('tmux', ['send-keys', '-t', session, '/exit', 'Enter'], { timeout: 5000 });
385
+ await execFileAsync('tmux', ['kill-session', '-t', session], { timeout: 5000 });
382
386
  return { success: true, restarted: true, session };
383
387
  } catch (err) {
384
388
  return { success: false, restarted: false, reason: err.message };
@@ -495,8 +495,22 @@ export function cliPath() {
495
495
  path.join(__dirname, '../../../cli/baize.js'),
496
496
  path.join(__dirname, '../../../node_modules/@baize-ai/core/cli/baize.js'),
497
497
  path.join(os.homedir(), '.npm-global', 'lib', 'node_modules', '@baize-ai', 'core', 'cli', 'baize.js'),
498
+ // Mainland install.sh layout: Node installed from the npmmirror binary
499
+ // mirror into ~/.local/node, so the global core package lives there.
500
+ path.join(os.homedir(), '.local', 'node', 'lib', 'node_modules', '@baize-ai', 'core', 'cli', 'baize.js'),
498
501
  ];
499
- return candidates.find((c) => fs.existsSync(c)) || null;
502
+ const found = candidates.find((c) => fs.existsSync(c));
503
+ if (found) return found;
504
+ // Dynamic fallback: resolve via the user's actual global npm root — covers
505
+ // any prefix (mainland ~/.local/node, homebrew, nvm, custom) when npm is on
506
+ // PATH. Static candidates take precedence so source-tree / skills-copy
507
+ // layouts always win.
508
+ try {
509
+ const root = execFileSync('npm', ['root', '-g'], { encoding: 'utf8', timeout: 10000, stdio: 'pipe' }).trim();
510
+ const p = path.join(root, '@baize-ai', 'core', 'cli', 'baize.js');
511
+ if (fs.existsSync(p)) return p;
512
+ } catch { /* npm unavailable */ }
513
+ return null;
500
514
  }
501
515
 
502
516
  function runCli(args, deps = {}) {