Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ lib/
local-bootstrap.ts web server side of the local link: `localLinkUrl`, `ensureLocalHostLink` (the `local` record + `host.json`)
host-login.ts `host.json` (`loginHost`, `readHostLogin`) and `isLoopbackHost`, shared by the daemon and local-bootstrap
session-ops.ts file-reading half of the session/project routes, run on the owning host's daemon (this machine's too)
session-ownership.ts daemon side of the `sessionOwnership` op: `ChannelTable` first (ours), then one bounded process scan (foreign), then the transcript tail (activity only); `unknown` for a failed or switched-off inspection, never `none`
omp-processes.ts the process scan behind that op: Windows CIM / POSIX `ps` parsing, own-user and own-child filtering, `--resume`/`--restore`/`-r` values and unique id-prefix matching, a 10 s cached snapshot with a liveness re-check
uploads.ts daemon side of composer uploads: `StagedUploads` (staging dir `<agent dir>/omp-web/uploads/`, offset writes, 24 h sweep, attach into the session's `local/uploads/`), `sanitizeUploadName`
upload-retention.ts daemon side of sent-upload retention: `UploadRetention` (op `setUploadRetention`, `<agent dir>/omp-web/upload-retention.json`, sweep at start and every 24 h), `sweepSentUploads`; `upload-retention-sync.ts` is main's side (`startUploadRetentionSync` on every hello, `pushUploadRetention` when the setting changes)
link-protocol.ts link messages, codec, binary blob frames, close codes, size limits, `HOST_OP_NAMES`, `SeqWindow`/`Outbox`, `LinkSender`/`PartJoiner` (pieces, fair sending)
Expand Down Expand Up @@ -377,6 +379,34 @@ The table is static imports, not a runtime glob, so `bun build --compile` (`scri
must not open a session file on main for a session that may be remote or local.
`SessionInfo.hostId` and `ManagedProject.hostId` carry the host; sidebar and
project state key on `hostProjectKey` (bare path on this machine, `<hostId>:<path>`).
- **Session ownership is a daemon op** (`sessionOwnership {ids}` ->
one `{id, owner, running?, source?, lastActivityAt?}` per id in request order,
≤ 256 ids; `docs/specs/2026-11-05-session-ownership-design.md`). It lives in the
daemon because only there the three facts meet: `ChannelTable` (ours),
a process scan in the children's PID namespace and uid (foreign), and the
transcript on the machine that owns the file (activity). `owner` is
`daemon`/`foreign`/`none`/`unknown`; a failed, switched-off or unsupported
inspection is `unknown`, never `none`, and then reports no `running` fact.
Ownership and activity are separate: an idle foreign writer still owns the
file, and a fresh transcript without a process is an activity hint only.
Every requested id goes to the scan (a file that does not resolve must not
turn a named writer into `none`), and a scan hit is re-checked against the OS
because the snapshot is cached for 10 s. `--resume`, `--restore` and `-r` are
recognised, including a unique id prefix; only an omp row can own a session,
and the entry point must be anchored — `argv[0]`, or the program a known
launcher runs (`cmd[.exe] /c …`, `sh|bash -c …`, `node|bun …`, after
`env`/`nice`/`nohup`) — so a token that merely appears as an argument
(`grep -r <id> lib/omp`, `cp -r <id> …/omp`, `--exclude-dir=omp`) cannot
claim one, and on Windows a `.cmd`/node shim row counts too. A quoted
command string is re-split and walked the same way, so `sh -c "omp …"` counts
while `sh -c "grep -r <id> lib/omp"` does not; a quoted program path with
spaces (`"C:\Program Files\omp\omp.cmd"`) is still recognised. The POSIX scan
asks `ps` for `-ww`, which lifts the width to procps's 131 072-column cap
instead of the screen width, because `args` is its last column and a clipped
command line would read as naming no session.
The daemon's own children are excluded by transport pid plus a bounded
ppid-chain walk. Detection is advisory, not an atomic lock: a writer can start
between the inspection and a later spawn.
- **Link = one WebSocket per host per web server, dialled by the daemon** (`/api/hosts/link`;
design `docs/specs/2026-10-31-websocket-link-design.md`). **Text frames**
carry the messages (hub → daemon one per frame; daemon → hub newline-separated
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f

### Added

- **Session ownership is answered where the children run.** A new `sessionOwnership` host op reports, per session, whether this host's daemon runs it, a foreign `omp --resume` process holds it, nobody does, or inspection was impossible (`unknown`). It exists because only the daemon knows its own children (`ChannelTable`), shares the PID namespace and uid of the process scan, and owns the session files; a web-server-side scan silently fails open. Ownership and activity are separate answers: an idle foreign writer still owns the file, and a fresh transcript without a process is an activity hint, never proof of a writer. One bounded process scan answers up to 256 ids per request (larger lists are paged), a failed or switched-off scan is `unknown` and never `none`, and the op never spawns, kills or writes. Every requested id is scanned even when its file does not resolve, so a session a foreign `omp` created since the last list scan is never reported as nobody's; `--resume`, `--restore` and `-r` are recognised (including a unique id prefix), and only an omp row can own a session: its entry point must be anchored at `argv[0]` or after a known launcher (`cmd /c`, `sh -c`, `node`, `env`/`nice`), so `grep -r <id> lib/omp` and `cp -r <id> …/omp` cannot block a send, not even one quote level down (`sh -c "grep -r <id> lib/omp"`) — while a quoted install path with spaces (`"C:\Program Files\omp\omp.cmd"`) still counts. On Windows there is no `process.getuid` and another user's process owner is unreadable unelevated, so the scan keeps every row and narrows by process identity instead: `omp.exe`/`omp`, or a command line naming an omp entry, which also covers a `.cmd`/node shim launcher — a same-machine `omp` of any account counts as a possible owner, the documented process-identity limit. Detection is advisory: it is not an atomic native ownership lock, so a writer can still start between the inspection and a spawn. This is the first of five slices; the command gate, the wire/UI wiring, explicit force and the outbox behaviour follow.
- **Archive and restore sessions on linked hosts.** Archiving now works for sessions on any linked machine, not only this one. The Archived Sessions browser lists every host's archive, shows which host each session is on, and restores it on that host. A host that is offline or runs an older ompweb host is named in the browser instead of hiding its archive silently. Restore rejects a session ID already active on any registered host, so every registered host must be online to restore, even an archive on this machine; the browser names the offline host that blocks it. A per-session claim stops web-server processes that share one agent directory from restoring the same session together; it does not coordinate separate web servers that share a daemon. A restore on another host keeps running when the web server stops waiting for it (after 30 s, or when the link drops), so the session stays claimed until that host's daemon process confirms it stopped: restoring the same ID again, on any host, is refused until then instead of creating a second active copy. Only the daemon process that took the restore can confirm that, so if the daemon was replaced, restarted or shut down meanwhile, or its host was unregistered, the session stays blocked: there is no timeout and no automatic clearing, and recovery is manual (see AGENTS.md). A restored session's attachments and other files are put back before the session becomes visible, so a file attached from another tab at that moment can no longer fail the restore or block retrying it. Restore streams archives with fixed 256 MiB compressed and expanded limits and rejects unsupported session IDs before consuming the archive.
- **Several web apps can share one host daemon and the same live sessions.** Link additional servers with `ompweb host login --add --url <server>` (token from stdin). Prompts, tool progress, results and dialogs stay synchronized, and restarting one web app leaves the other connected to the same omp process. Link protocol v7 moves session startup, idle cleanup and interrupted-run recovery into the host; older links remain supported without sharing their processes. Schedule the first daemon upgrade while its host is quiescent.
- **Sidebar marks sessions with an unsent draft.** A session whose composer still holds text or attachments shows a small pencil beside its title, so a half-written message is easy to find again. The mark follows this browser tab's drafts.
Expand Down
1 change: 1 addition & 0 deletions docs/specs/2026-10-28-remote-hosts-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ parts of those routes stay on main.
| `sessionFileExists {path}` / `invalidateSessionLists {path}` | `AgentSessionWrapper` |
| `uploadStart {id, name, size, type, attempt}` / `uploadAbort {id}` / `uploadAttach {id, sessionFile, sessionId}` | new in v6: composer uploads (`docs/specs/2026-11-02-file-uploads-design.md`, U3, U5) |
| `setUploadRetention {days}` | compatible addition (the link version is unchanged; older daemons answer 501 `unknown_op`, which main ignores): days to keep sent uploads, `null` = for ever; sent on every hello and when the web setting changes (`docs/specs/2026-11-02-file-uploads-design.md`, U6) |
| `sessionOwnership {ids}` | compatible addition (the link version is unchanged; older daemons answer 501 `unknown_op`, which main reads as `unknown`): who holds each session's writer lease on that host — `{id, owner: "daemon"\|"foreign"\|"none"\|"unknown", running?, source?: "process"\|"transcript", lastActivityAt?}` per id, in request order, at most 256 ids per request (main pages a larger list). It lives in the daemon because only there the three facts meet: `ChannelTable` is the authority for "ours" (a spawning, adopted, idle or running child), the process scan runs in the same PID namespace and as the same uid as the children, and the transcript tail is read on the machine that owns the file. Read-only: it never spawns, kills or writes. A failed, switched-off or unsupported inspection answers `unknown`, never `none`, and reports no `running` fact. Ownership is separate from activity: a live foreign `omp` owns the file even while idle (`running: false`), and a fresh transcript without positive owner evidence is an activity hint only (`owner: "none"`, `source: "transcript"`). One bounded process scan answers a whole batch. On POSIX, rows of another uid are dropped; Windows has no `process.getuid` and cannot read another user's process owner unelevated, so the scan narrows by process name instead and a same-machine `omp` of any account counts as a possible owner — the documented process-identity limit. The inspection is not an atomic native ownership lock: a writer can start between it and a later spawn, so a copy can still occur without the user's confirmation (`docs/specs/2026-11-05-session-ownership-design.md`) |

Op timeout: 30 s of silence (each result byte frame that arrives restarts it), then 504 naming the host; `uploadAttach` gets 10 minutes (a 2 GiB copy across file systems).

Expand Down
Loading