@baize-ai/core 0.3.4 → 0.3.5

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,11 @@ 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.5] - 2026-08-26
9
+
10
+ ### Fixed
11
+ - web-console 重启 agent 会话按当前 runtime 定位 tmux 会话(codex-main/claude-main)——保存 Codex API key 后自动重启生效,不再因会话名不匹配报"无 tmux session"
12
+
8
13
  ## [0.3.4] - 2026-08-26
9
14
 
10
15
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baize-ai/core",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "description": "Baize (\u767d\u6cfd) \u2014 autonomous AI agent infrastructure",
6
6
  "main": "cli/baize.js",
@@ -37,7 +37,20 @@ export function envFile() { return path.join(baizeDir(), '.env'); }
37
37
  function configFile() { return path.join(baizeDir(), '.baize', 'config.json'); }
38
38
  function claudeSettings() { return path.join(homeDir(), '.claude', 'settings.json'); }
39
39
  function codexAuth() { return path.join(homeDir(), '.codex', 'auth.json'); }
40
- const CLAUDE_SESSION = process.env.CLAUDE_SESSION || 'claude-main';
40
+ // Session name follows the active runtime: codex runs in 'codex-main',
41
+ // claude in 'claude-main'. Hard-coding 'claude-main' made the web-console
42
+ // restart button report "no tmux session" while the codex session was alive
43
+ // (stuck on login) — a dead end for browser-only recovery.
44
+ function agentSessionName() {
45
+ if (process.env.CLAUDE_SESSION) return process.env.CLAUDE_SESSION;
46
+ let runtime = 'claude';
47
+ try {
48
+ const cfg = JSON.parse(require('node:fs').readFileSync(
49
+ require('node:path').join(homeDir(), 'baize', '.baize', 'config.json'), 'utf8'));
50
+ if (cfg && cfg.runtime) runtime = cfg.runtime;
51
+ } catch { /* default claude */ }
52
+ return runtime === 'codex' ? 'codex-main' : 'claude-main';
53
+ }
41
54
  const CLI = process.env.BAIZE_CLI || 'baize';
42
55
 
43
56
  // ── Low-level helpers ────────────────────────────────────────────────────────
@@ -352,14 +365,15 @@ export async function switchRuntime(name) {
352
365
  * @returns {Promise<{success: boolean, restarted: boolean, reason?: string}>}
353
366
  */
354
367
  export async function restartAgentSession() {
368
+ const session = agentSessionName();
355
369
  try {
356
- await execFileAsync('tmux', ['has-session', '-t', CLAUDE_SESSION], { timeout: 5000 });
370
+ await execFileAsync('tmux', ['has-session', '-t', session], { timeout: 5000 });
357
371
  } catch {
358
372
  return { success: true, restarted: false, reason: 'no_session' };
359
373
  }
360
374
  try {
361
- await execFileAsync('tmux', ['send-keys', '-t', CLAUDE_SESSION, '/exit', 'Enter'], { timeout: 5000 });
362
- return { success: true, restarted: true };
375
+ await execFileAsync('tmux', ['send-keys', '-t', session, '/exit', 'Enter'], { timeout: 5000 });
376
+ return { success: true, restarted: true, session };
363
377
  } catch (err) {
364
378
  return { success: false, restarted: false, reason: err.message };
365
379
  }