@raysonmeng/agentbridge 0.1.6 → 0.1.7

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.
@@ -12,7 +12,7 @@
12
12
  {
13
13
  "name": "agentbridge",
14
14
  "description": "Bridge Claude Code and Codex through a shared daemon, push channel delivery, and reply/get_messages tools.",
15
- "version": "0.1.6",
15
+ "version": "0.1.7",
16
16
  "author": {
17
17
  "name": "AgentBridge Contributors",
18
18
  "email": "raysonmeng@qq.com"
package/README.md CHANGED
@@ -156,12 +156,17 @@ After modifying AgentBridge source code, re-run `agentbridge dev` to sync change
156
156
  |---------|-------------|
157
157
  | `abg init` | Install plugin, check dependencies (bun/claude/codex), generate `.agentbridge/config.json` |
158
158
  | `abg claude [args...]` | Start Claude Code with push channel enabled. Clears any killed sentinel from a previous `kill`. Pass-through args are forwarded to `claude` |
159
- | `abg codex [args...]` | Start Codex TUI connected to AgentBridge daemon. Manages TUI process lifecycle (pid tracking, cleanup). Pass-through args forwarded to `codex` |
160
- | `abg kill` | Gracefully stop both daemon and managed Codex TUI, clean up state files, write killed sentinel |
159
+ | `abg codex [args...]` | Start Codex TUI connected to AgentBridge daemon. **Bare `abg codex` auto-resumes the pair's last thread; use `abg codex --new` for a fresh thread.** Manages TUI process lifecycle (pid tracking, cleanup). Pass-through args forwarded to `codex` |
160
+ | `abg pairs` | List registered pairs; `abg pairs rm <name\|id>` removes one, `abg pairs prune` deletes orphan state dirs |
161
+ | `abg doctor [--json]` | Read-only diagnosis: env, daemon health/readiness, build drift, artifact alignment, TUI attachment, logs |
162
+ | `abg budget [--json]` | Both agents' subscription quota snapshot (5h/weekly windows, drift, pause state) |
163
+ | `abg kill` | Gracefully stop this pair's daemon and managed Codex TUI, write killed sentinel; `abg kill --all` stops every pair |
161
164
  | `abg dev` | (Dev only) Register local marketplace + force-sync plugin to cache |
162
165
  | `abg --help` | Show help |
163
166
  | `abg --version` | Show version |
164
167
 
168
+ The pair-aware commands (`claude`, `codex`, `kill`, `doctor`, `budget`) accept `--pair <name>` to target a specific pair — one pair per project directory by default, with ports allocated per pair in +10 strides from 4500.
169
+
165
170
  ### Owned flags
166
171
 
167
172
  Some flags are automatically injected and cannot be manually specified:
@@ -171,6 +176,15 @@ Some flags are automatically injected and cannot be manually specified:
171
176
 
172
177
  Passing these flags manually will result in a hard error with guidance to use the native command directly.
173
178
 
179
+ > **Note on flag positioning for `agentbridge codex`:** For the bare TUI form
180
+ > (`agentbridge codex …`), bridge flags are injected at the front. For TUI
181
+ > subcommands that carry per-subcommand args (`resume`, `fork`), they are
182
+ > injected *after* the subcommand name (so clap parses them as options of the
183
+ > actually-invoked command, not the root). Non-TUI subcommands like `exec`,
184
+ > `mcp`, `plugin`, `remote-control`, `update` etc. are passed through
185
+ > unchanged — no bridge flags injected. See `src/cli/codex.ts buildCodexArgs`
186
+ > for the full positioning logic.
187
+
174
188
  ## Project Config
175
189
 
176
190
  Running `agentbridge init` creates a `.agentbridge/` directory in your project root:
@@ -217,7 +231,11 @@ agent_bridge/
217
231
  │ ├── init.ts # agentbridge init
218
232
  │ ├── claude.ts # agentbridge claude
219
233
  │ ├── codex.ts # agentbridge codex
234
+ │ ├── pairs.ts # agentbridge pairs (list / rm / prune)
235
+ │ ├── doctor.ts # agentbridge doctor (read-only diagnosis)
236
+ │ ├── budget.ts # agentbridge budget (quota snapshot)
220
237
  │ ├── kill.ts # agentbridge kill
238
+ │ ├── pkg-root.ts # package-root resolution helper
221
239
  │ └── dev.ts # agentbridge dev
222
240
  ├── CLAUDE.md # Project rules for AI agents
223
241
  ├── CODE_OF_CONDUCT.md
@@ -239,9 +257,26 @@ agent_bridge/
239
257
  | `CODEX_WS_PORT` | `4500` | Codex app-server WebSocket port |
240
258
  | `CODEX_PROXY_PORT` | `4501` | Bridge proxy port for the Codex TUI |
241
259
  | `AGENTBRIDGE_CONTROL_PORT` | `4502` | Control port between bridge.ts and daemon.ts |
260
+ | `AGENTBRIDGE_LIVENESS_PROBE_TIMEOUT_MS` | `3000` | Maximum wait for incumbent Claude pong before evicting on contention (issue #68) |
261
+ | `AGENTBRIDGE_TURN_WATCHDOG_MS` | `300000` | Per-turn inactivity watchdog: force-completes a turn after this many ms of app-server silence so a lost `turn/completed` can't lock injection forever (issue #69) |
262
+ | `AGENTBRIDGE_CODEX_TRANSPORT` | `auto` | How the daemon reaches the Codex app-server: `auto` (probe `codex app-server --help`, use `ws://` if supported else fall back to a `unix://` socket via a transparent relay), `ws` (force ws), or `unix` (force unix socket + relay). For builds that drop `ws://` listen support (issue #85) |
242
263
  | `AGENTBRIDGE_STATE_DIR` | Platform default | State directory for pid, status, logs (macOS: `~/Library/Application Support/agentbridge/`, Linux: `$XDG_STATE_HOME/agentbridge/`) |
243
- | `AGENTBRIDGE_MODE` | `push` | Message delivery mode (`push` for channels, `pull` for API key mode) |
244
264
  | `AGENTBRIDGE_DAEMON_ENTRY` | `./daemon.ts` | Override daemon entry point (used by plugin bundles) |
265
+ | `NO_UPDATE_NOTIFIER` | unset | Set to any value to disable the "update available" notice (ecosystem-standard opt-out) |
266
+ | `AGENTBRIDGE_NO_UPDATE_NOTIFIER` | unset | Namespaced opt-out for the update notice (same effect as `NO_UPDATE_NOTIFIER`) |
267
+ | `AGENTBRIDGE_UPDATE_CHECK_INTERVAL_MS` | `86400000` | How often `abg claude`/`abg codex` may check npm for a newer version (default once/day). The notice is otherwise printed from cache — zero network on most runs |
268
+
269
+ ### Update notifications
270
+
271
+ `abg claude` and `abg codex` print a one-line notice to stderr when a newer **stable** AgentBridge is published to npm, e.g.:
272
+
273
+ ```
274
+ ⚠ AgentBridge update available: 0.1.6 → 0.1.7
275
+ CLI: npm install -g @raysonmeng/agentbridge@latest
276
+ Plugin: /plugin marketplace update agentbridge (then /reload-plugins)
277
+ ```
278
+
279
+ The check is best-effort and never blocks, delays, or fails your command: the notice is printed from a cached result, the npm check runs at most once per day in the background, and any network/registry failure is silently ignored. It is suppressed automatically for non-interactive (piped) output and in CI, and can be disabled with `NO_UPDATE_NOTIFIER=1`. The notifier never installs anything — it only shows you the command.
245
280
 
246
281
  ### State Directory
247
282
 
@@ -254,12 +289,24 @@ The daemon stores runtime state in a platform-aware directory:
254
289
 
255
290
  Contents: `daemon.pid`, `status.json`, `agentbridge.log`, `killed` (sentinel), `startup.lock`
256
291
 
292
+ ### Disabled Bridge States
293
+
294
+ The bridge can enter several dormant states when it cannot accept new MCP replies. Each state surfaces to the agent as an error message (and, for the transient ones, an in-band push notification):
295
+
296
+ | State | Cause | Recovery |
297
+ |-------|-------|----------|
298
+ | `killed` | `agentbridge kill` was run, sentinel file present. | Restart Claude Code (`agentbridge claude`), switch to a new conversation, or run `/resume`. |
299
+ | `rejected` | Daemon rejected the connection: another Claude session is already attached. | Close the other session, or run `agentbridge kill` to reset, then `agentbridge claude` again. |
300
+ | `evicted` | A newer session evicted this one after the incumbent failed a liveness probe (issue #68). | Close this session and start a fresh one with `agentbridge claude`. |
301
+ | `probe_in_progress` | A liveness probe is currently checking the incumbent — contention window. Transient (auto-recovers within `DISABLED_RECOVERY_INTERVAL_MS` × cap, ~30 s). | None needed; the recovery poller reconnects automatically when the slot clears. |
302
+ | `auto_recovery_exhausted` | The auto-recovery poller for `probe_in_progress` ran its full retry budget (6 attempts, ~30 s) without succeeding. Terminal. | Retry manually with `agentbridge claude`. |
303
+
257
304
  ## Current Limitations
258
305
 
259
306
  - Only forwards `agentMessage` items, not intermediate `commandExecution`, `fileChange`, or similar events
260
- - Single Codex thread, no multi-session support yet
261
- - Single Claude foreground connection; a new Claude session replaces the previous one
262
- - Fixed ports mean only one AgentBridge instance per machine (multi-project support planned for post-v1)
307
+ - Single Codex thread per pair, no multi-session support within a pair yet
308
+ - Single Claude foreground connection per pair; a new Claude session replaces the previous one
309
+ - Multiple pairs run side-by-side on one machine (one per project directory, per-pair port allocation); Windows is not an officially supported platform yet
263
310
 
264
311
  ### Codex git restrictions
265
312
 
package/README.zh-CN.md CHANGED
@@ -171,6 +171,13 @@ agentbridge codex
171
171
 
172
172
  手动传入这些参数会报错,并提示使用原生命令。
173
173
 
174
+ > **关于 `agentbridge codex` 参数位置的说明:** 对于无子命令的 TUI 形式
175
+ > (`agentbridge codex …`),bridge 注入的参数放在最前面。对于带有自己参数的
176
+ > TUI 子命令(`resume`、`fork`),bridge 参数注入到**子命令名之后**(这样
177
+ > clap 才会把它们解析为该子命令的选项,而不是根命令的)。`exec`、`mcp`、
178
+ > `plugin`、`remote-control`、`update` 等非 TUI 子命令则原样透传,不注入
179
+ > bridge 参数。完整定位逻辑见 `src/cli/codex.ts` 的 `buildCodexArgs`。
180
+
174
181
  ## 项目配置
175
182
 
176
183
  运行 `agentbridge init` 会在项目根目录创建 `.agentbridge/` 目录:
@@ -239,9 +246,26 @@ agent_bridge/
239
246
  | `CODEX_WS_PORT` | `4500` | Codex app-server WebSocket 端口 |
240
247
  | `CODEX_PROXY_PORT` | `4501` | Bridge 代理端口,Codex TUI 连接此端口 |
241
248
  | `AGENTBRIDGE_CONTROL_PORT` | `4502` | bridge.ts 与 daemon.ts 之间的控制端口 |
249
+ | `AGENTBRIDGE_LIVENESS_PROBE_TIMEOUT_MS` | `3000` | 等待在位 Claude pong 的最长时间,超时后在争用时驱逐(issue #68) |
250
+ | `AGENTBRIDGE_TURN_WATCHDOG_MS` | `300000` | 单 turn 非活动看门狗:app-server 静默超过该毫秒数后强制完成该 turn,避免丢失 `turn/completed` 永久锁死注入(issue #69) |
251
+ | `AGENTBRIDGE_CODEX_TRANSPORT` | `auto` | daemon 连接 Codex app-server 的方式:`auto`(探测 `codex app-server --help`,支持 `ws://` 则用 ws,否则经透明中继回退到 `unix://` socket)、`ws`(强制 ws)、`unix`(强制 unix socket + 中继)。用于去掉 `ws://` listen 支持的 Codex 版本(issue #85) |
242
252
  | `AGENTBRIDGE_STATE_DIR` | 平台默认 | 状态目录(pid、status、日志)。macOS: `~/Library/Application Support/agentbridge/`,Linux: `$XDG_STATE_HOME/agentbridge/` |
243
- | `AGENTBRIDGE_MODE` | `push` | 消息投递模式(`push` 用于 channel,`pull` 用于 API key 模式) |
244
253
  | `AGENTBRIDGE_DAEMON_ENTRY` | `./daemon.ts` | 覆盖 daemon 入口(插件包使用) |
254
+ | `NO_UPDATE_NOTIFIER` | 未设置 | 设为任意值即关闭「有新版本」提示(生态通用 opt-out) |
255
+ | `AGENTBRIDGE_NO_UPDATE_NOTIFIER` | 未设置 | 命名空间化的关闭开关(效果同 `NO_UPDATE_NOTIFIER`) |
256
+ | `AGENTBRIDGE_UPDATE_CHECK_INTERVAL_MS` | `86400000` | `abg claude`/`abg codex` 多久查一次 npm 新版本(默认每天一次)。其余时候只读缓存打印,大多数调用零网络 |
257
+
258
+ ### 更新提示
259
+
260
+ `abg claude` 和 `abg codex` 在 npm 上有更新的**稳定**版本时,会向 stderr 打印一行提示,例如:
261
+
262
+ ```
263
+ ⚠ AgentBridge update available: 0.1.6 → 0.1.7
264
+ CLI: npm install -g @raysonmeng/agentbridge@latest
265
+ Plugin: /plugin marketplace update agentbridge (then /reload-plugins)
266
+ ```
267
+
268
+ 该检查是 best-effort,绝不阻塞/拖慢/弄坏你的命令:提示从缓存打印,npm 检查每天最多在后台跑一次,任何网络/registry 失败都静默忽略。非交互(管道)输出和 CI 下自动抑制,可用 `NO_UPDATE_NOTIFIER=1` 关闭。notifier 永远不会自动安装任何东西——只告诉你升级命令。
245
269
 
246
270
  ### 状态目录
247
271
 
@@ -254,6 +278,18 @@ daemon 在平台感知的目录中存储运行时状态:
254
278
 
255
279
  内容:`daemon.pid`、`status.json`、`agentbridge.log`、`killed`(sentinel)、`startup.lock`
256
280
 
281
+ ### Bridge 禁用状态
282
+
283
+ Bridge 在无法接受新 MCP 回复时会进入若干休眠状态。每种状态都会以错误信息返回给 agent;瞬态状态还会推送一条带内通知:
284
+
285
+ | 状态 | 原因 | 恢复方式 |
286
+ |------|------|---------|
287
+ | `killed` | 运行过 `agentbridge kill`,存在 sentinel 文件。 | 重启 Claude Code(`agentbridge claude`),切换到新会话,或运行 `/resume`。 |
288
+ | `rejected` | daemon 拒绝连接:已有另一个 Claude 会话连接中。 | 先关闭另一个会话,或运行 `agentbridge kill` 重置,然后重新 `agentbridge claude`。 |
289
+ | `evicted` | 在位会话未响应存活探测,被更新的会话驱逐(issue #68)。 | 关闭本会话,用 `agentbridge claude` 重新启动一个。 |
290
+ | `probe_in_progress` | 当前正在对在位会话执行存活探测——争用窗口期。瞬态(在 `DISABLED_RECOVERY_INTERVAL_MS` × 重试上限内自动恢复,约 30 秒)。 | 无需操作;恢复轮询会在槽位释放后自动重连。 |
291
+ | `auto_recovery_exhausted` | `probe_in_progress` 的自动恢复轮询用尽了完整的重试预算(6 次,约 30 秒)仍未成功。终态。 | 手动用 `agentbridge claude` 重试。 |
292
+
257
293
  ## 当前限制
258
294
 
259
295
  - 目前只转发 `agentMessage`,不转发 `commandExecution`、`fileChange` 等中间过程事件