multi-project-gateway 0.5.1 → 0.6.0

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
@@ -282,6 +282,7 @@ If `~/.mpg/` does not exist and CWD files do, everything works exactly as before
282
282
  | `defaults.maxTurnsPerAgent` | number | `5` | Max automatic handoffs in a single agent chain |
283
283
  | `defaults.agentTimeoutMs` | number | `180000` (3 min) | Timeout per agent turn during auto-handoff |
284
284
  | `defaults.sessionTtlMs` | number | `604800000` (7 days) | Max age for persisted sessions before pruning |
285
+ | `defaults.persistence` | string | — | Session runtime — set to `"tmux"` for persistent sessions that survive restarts |
285
286
  | `defaults.maxPersistedSessions` | number | `50` | Max number of persisted sessions kept on disk |
286
287
  | `defaults.httpPort` | number \| false | `3100` | Port for the web dashboard and API (`false` to disable) |
287
288
  | `defaults.logLevel` | string | `"info"` | Minimum log level (`debug`, `info`, `warn`, `error`) |
@@ -385,6 +386,26 @@ claude --resume <session-id>
385
386
 
386
387
  **Important:** You must run `claude --resume` from the same directory the session was started in (i.e., the project's `directory` in `config.json`). Claude will not find the session if you run it from a different working directory.
387
388
 
389
+ ### Session persistence (tmux)
390
+
391
+ By default, Claude sessions run as direct child processes and are lost when the gateway stops. With tmux persistence enabled, sessions run inside detached tmux sessions and survive Ctrl+C, crashes, and gateway restarts.
392
+
393
+ **Prerequisites:** tmux must be installed (`apt install tmux` / `brew install tmux`).
394
+
395
+ **Enable it** by adding `"persistence": "tmux"` to your config defaults (or per-project):
396
+
397
+ ```json
398
+ {
399
+ "defaults": {
400
+ "persistence": "tmux"
401
+ }
402
+ }
403
+ ```
404
+
405
+ **How recovery works:** When the gateway restarts, it auto-discovers orphaned tmux sessions from the previous run, waits for any still-running sessions to complete, and delivers their results to the originating Discord thread with a "Resumed after gateway restart" prefix.
406
+
407
+ **Known limitation:** Recovered sessions don't appear as "processing" in the web dashboard and don't trigger Discord's "typing..." indicator during recovery. See [#137](https://github.com/yama-kei/multi-project-gateway/issues/137).
408
+
388
409
  ## Threading and per-thread sessions
389
410
 
390
411
  When a user posts a message in a mapped channel, the bot automatically creates a Discord thread and replies there instead of cluttering the main channel. Follow-up messages within the thread continue the same conversation.
@@ -446,6 +467,8 @@ For detailed architecture documentation — message lifecycle, session managemen
446
467
  | `src/session-manager.ts` | One session per channel/thread, queues concurrent messages, manages idle timeouts |
447
468
  | `src/session-store.ts` | Persists session IDs to `.sessions.json` for resume across restarts |
448
469
  | `src/claude-cli.ts` | Spawns `claude --print` subprocess, parses JSON output |
470
+ | `src/tmux.ts` | Low-level tmux helpers: create, list, kill sessions; ensures tmux is installed |
471
+ | `src/runtimes/tmux-runtime.ts` | Tmux-based agent runtime — runs Claude in detached tmux sessions for persistence across restarts |
449
472
  | `src/agent-dispatch.ts` | Parses `@mentions`, resolves agent targets |
450
473
  | `src/turn-counter.ts` | Tracks handoff turns per thread, enforces `maxTurnsPerAgent` |
451
474
  | `src/worktree.ts` | Manages git worktrees for session isolation; reconciles orphans on startup |