Document several live sessions for `clai2` plugins and users: `Plugin.scope`, `host.live`, and the web UI

Merged
MP
2mo ago
+329-55

Part 9 of the clai2 multi-session stack (#10468 → #10469 → #10477 → #10485 → #10494 → #10495 → #10504 → #10541 → this PR). Based on #10541. No linked issue: requested by the CLAI maintainer.

Why. The stack lets one CLAI process keep many sessions live, each with its own folder, plugins, and running turn, and the maintainer decided process-scoped plugins are public. Plugin authors need the rules that keep a plugin correct when several instances run at once, and users need to know what the web UI and terminal now do.

New public surface. None in code. This PR writes the public contract for Plugin.scope and PluginHost.live (LiveSessions, LiveSession), which the base branch already exports.

What changes

  • PLUGINS.md: a new Several live sessions section with six rules (one instance per live session, host.workspace instead of Path.cwd()/os.chdir, no module-level mutable state, check host.console.is_terminal, on_session_end may come from idle closing with 'exit', bounded background tasks), and One instance for the whole process: scope = 'process', the public contract for:
    • Plugin.scope: ClassVar[Literal['session', 'process']]
    • PluginHost.live: LiveSessions | None, with tables for every LiveSessions member (listing, get, current, open, new, close, subscribe) and LiveSession member, plus a short Turns example.
  • PLUGINS.md: the web section rewritten for per-session opening (host.live.open/new, watchers, idle close, status from live, Esc per session, /web from a terminal); the orchestrator runs on the saved default model; the session moments table names live sessions.
  • docs/declarative-plugins.md: the scope design note. docs/reference.md: Several sessions in the web UI (click opens live, status dots, idle close after an hour, Esc, settings fan-out, read-only, terminal focus, /reload//update refusals). README.md tour entry; clai2_web_README.md drops the "moves CLAI" text and the stale /web fallback.
  • AGENTS.md/FILE_MAP.md: per session on SessionRuntime, per process on ClaiProcess, never the other way; chat opens sessions beside the terminal.

Verification. Every documented name and signature was checked against the code merged from mike/clai2-multi-8-terminal-focus (plugins/__init__.py, process_plugins.py, live_runtimes.py, session_runtime.py, terminal.py, web/service.py). No doc-example test covers PLUGINS.md, so the Turns example was run with load_plugin and a JoinedSessions host (Counter({'/tmp/a': 1}) ['1 running, 1 done']), and passes ruff check, ruff format --check, and pyright strict. All new anchors resolve. tests/clai2/test_plugin_loader.py and test_customization.py pass (74).

What changes for existing users. Nothing: documentation only.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.