Skip to content
Merged
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
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ The table is static imports, not a runtime glob, so `bun build --compile` (`scri
`part`, whole lines and no unacked window (`link.sender.parts`). Main keeps at least N-1, and
dropping one is an explicit decision (a hello
outside the range gets close 4426 with `{"serverVersion":N}`, a pre-WebSocket
daemon's POST gets 426; an update-only mode is planned). Upgrade order: web app
daemon's POST gets 426). Once the WebSocket experiments end, the first version
released after them is a floor: the handshake, version report and an update op
keep working for every daemon on it or newer, and `MIN_LINK_PROTOCOL_VERSION`
never goes above it (spec, "Decided: backward compatibility"). Upgrade order: web app
first, then hosts; a daemon need not support a newer main (a v5 daemon gets
4426 from a v4 server and exits 1). A daemon dialing a pre-WebSocket server
keeps redialing with a hint.
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **Restarting or redeploying ompweb no longer interrupts a run on this machine.** "This machine" now runs through a local `ompweb host` daemon, installed as a second service (`ompweb-host`) by `ompweb systemd install`, `ompweb launchd install` and the Windows tray install. The daemon keeps the omp processes; a restarted web server adopts them, with no resume prompt, and the dialogs and browser tool calls omp was waiting on come back. The daemon is required: until it is installed and linked, "This machine" shows offline (with a banner showing the install command) and new sessions there cannot start. An `ompweb` run in a terminal or with npx installs no service: keep `ompweb host` running in a second terminal. Restarting the daemon still ends runs, and `ompweb systemd restart` leaves it alone. If the web server comes back on another port, the daemon follows it. A `npm run dev` server does not take over the daemon. "This machine" can be renamed in **Settings → Hosts**.
- **ompweb as a single binary, with no Node or npm.** Each release now also carries `ompweb-linux-x64`, `ompweb-linux-arm64`, `ompweb-darwin-x64`, `ompweb-darwin-arm64` (`.tar.gz`) and `ompweb-windows-x64` (`.zip`): one `ompweb` program with the web files beside it. It takes the same options and environment variables as the npm `ompweb`, and runs the daemon too (`ompweb host`). It has no tray, service installers or in-app update: the README's "Single binary" section shows the service units, and Settings → System links the release page when an update is out. Build one with `npm run build:binary`.
- **Binary prereleases from `main`.** Each commit on `main` that passes CI is published as a GitHub prerelease titled with its build time in ISO 8601 UTC (for example `2026-11-01T10:30:00Z`; tag `20261101T103000Z-<short sha>`) with the five single-binary archives. Prereleases are never marked latest, publish no npm package and trigger no update notice.
- **Settings → Hosts shows link protocol versions.** Each host shows the link protocol version its daemon speaks, and the page shows the version this web app expects.
- **Keep a host running with the single binary.** The README's "Keep a host running as a service" section has a systemd user unit (Linux), a logon scheduled task (Windows) and, for macOS, a restart script to run in tmux: launchd jobs cannot use the login keychain and SSH agent that omp sessions need. In tmux, macOS Local Network privacy blocks the daemon from LAN addresses, so link it to a URL that does not resolve to one (the server's public URL, or a VPN or tailnet name).

### Fixes & Improvements

Expand Down
121 changes: 116 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,9 @@ host (KDE Plasma, and most Wayland/X11 desktops).

One ompweb can start and watch omp sessions on other machines. Each machine keeps
its own `omp` install, `~/.omp/agent` directory, sessions, and credentials;
ompweb only routes. The remote machine needs Node 24 and `omp` installed, and must
be able to reach the ompweb server over HTTP(S). It dials out, so it can sit behind NAT.
ompweb only routes. The remote machine needs `omp` and either Node 24 (for `npx`) or
the [single binary](#single-binary), and must be able to reach the ompweb server over
HTTP(S). It dials out, so it can sit behind NAT.

1. On the ompweb server, open **Settings → Hosts → Add host**, enter a name, and copy
the token. The token is shown once; only its hash is stored.
Expand Down Expand Up @@ -481,9 +482,8 @@ Notes:
- **Service helpers:** `ompweb systemd install` and `ompweb launchd install` set up
this machine's own daemon next to its web server (see
[Two services](#two-services-the-web-server-and-the-local-daemon)). On the other
machine you only need the daemon, and the helpers would also start a web server
there, so run `ompweb host` under a supervisor of your choice that restarts it
after failure to keep the link up across logouts or reboots.
machine you only need the daemon, so use
[Keep a host running as a service](#keep-a-host-running-as-a-service) instead.
The daemon exits with code `1` when the server revokes its token or when its
link protocol version is outside the range the server supports (older than the
server's oldest supported version, or newer than the server: update ompweb on
Expand All @@ -507,6 +507,117 @@ Notes:
is switched on for it in Settings → Hosts. An agent running on a remote host
always asks before it starts or messages a session on this machine.

### Keep a host running as a service

These run the [single binary](#single-binary) in host mode. On Linux and Windows a
service keeps the link up across logouts and reboots; on macOS a script keeps it
running in a terminal (see below for why). Unpack the release for the machine first,
then save the link once with `ompweb host login --url …` as in step 2 (with the
binary's path in place of `npx @kahme247/ompweb@latest`). Each setup starts
`ompweb host` again 10 seconds after it fails, but not after exit 0: that means a
newer link with the same token replaced it, and restarting would take the link back
every 10 seconds. Add `--allow-http` after `host` if
the server URL is plain `http://`, and set `PI_CODING_AGENT_DIR` in the service too
if you saved the link with it set. A machine links to one server: do not also run an
ompweb web server on it, which writes the same link file for its own daemon. To
update, stop the service, replace the release directory, and start it again. After
revoking a host, stop and remove its service: it otherwise keeps retrying.

**Linux (systemd user service).** Create `~/.config/systemd/user/ompweb-host.service`
(adjust the release path, and add omp's directory to `PATH` or set `OMP_WEB_OMP_BIN`):

```ini
[Unit]
Description=ompweb host
StartLimitIntervalSec=0

[Service]
WorkingDirectory=%h
ExecStart=%h/.local/share/ompweb-linux-x64/ompweb host
Environment=PATH=%h/.local/bin:%h/.bun/bin:/usr/local/bin:/usr/bin:/bin
Restart=always
# Exit 0: a newer link for this host replaced it. Restarting would take the link back.
RestartPreventExitStatus=0
RestartSec=10
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

[Install]
WantedBy=default.target
```

```bash
systemctl --user daemon-reload
systemctl --user enable --now ompweb-host
loginctl enable-linger "$USER" # keep it running while you are logged out
journalctl --user -u ompweb-host -f # logs
```

**macOS (from a terminal).** No launchd job can run a host that omp sessions can
fully use: a LaunchDaemon has no login keychain or SSH agent, which sessions need
for SSH keys and commit signing, and a LaunchAgent cannot reach LAN addresses. A
process started from a terminal inherits the terminal's keychain and SSH agent, so
run the host there, in tmux so it outlives the window.

tmux does not keep the terminal's Local Network permission, though: the tmux server
detaches from the terminal app, and macOS Local Network privacy then blocks the
ad-hoc signed `ompweb` binary from LAN addresses (`connect` fails with "No route to
host", which the daemon reports as `ECONNREFUSED`; Apple's own tools such as `curl`
are not blocked, so a `curl` test passes). Link the host to a URL that does not
resolve to a LAN address, for example the server's public URL, or its VPN or
tailnet name (a Tailscale MagicDNS name served by your reverse proxy with its own
certificate). Save this as `~/.local/bin/ompweb-host-run` (adjust `DIR`) and make
it executable with `chmod +x`:

```sh
#!/bin/sh
# Keeps `ompweb host` running in this terminal, which lends it its keychain and SSH agent.
# Restarts it 10 s after a crash; stops when the token is revoked or the link protocol is
# unsupported (exit 1), or on exit 0: a newer link replaced it, or it was stopped (Ctrl-C).
DIR=${OMPWEB_DIR:-$HOME/.local/share/ompweb-darwin-arm64}
# A tmux started over SSH sees the login keychain locked: unlock it while a terminal can ask.
security show-keychain-info login.keychain-db 2>/dev/null || security unlock-keychain login.keychain-db || exit 1
while :; do
(cd "$DIR" && exec ./ompweb host)
rc=$?
case $rc in 0 | 1) exit "$rc" ;; esac
echo "ompweb host exited $rc; restarting in 10 s" >&2
sleep 10
done
```

Run `ompweb-host-run` in a tmux window; Ctrl-C stops the daemon and its sessions.
Start it again after a reboot or logout. If the login keychain locks itself after
inactivity or on sleep, SSH key passphrases and signing fail until you restart it.

**Windows (scheduled task at logon).** In PowerShell, with `$dir` set to the
unpacked release:

```powershell
$dir = "$env:LOCALAPPDATA\ompweb-windows-x64"
New-Item -ItemType Directory -Force "$env:USERPROFILE\.omp\agent\logs" | Out-Null
Set-Content "$dir\ompweb-host.ps1" @'
# Starts `ompweb host` again 10 s after it fails, and stops on exit 0 (a newer link replaced it).
# Output goes to ~\.omp\agent\logs\ompweb-host.log, moved to .log.1 past 10 MB (checked between restarts).
# For a plain http:// server URL, put --allow-http after `host` below.
$log = "$env:USERPROFILE\.omp\agent\logs\ompweb-host.log"
while ($true) {
if ((Test-Path $log) -and (Get-Item $log).Length -gt 10MB) { Move-Item $log "$log.1" -Force }
& "$PSScriptRoot\ompweb.exe" host 2>&1 | ForEach-Object { "$_" } | Out-File -Append -Encoding utf8 $log
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
if ($LASTEXITCODE -eq 0) { break }
Start-Sleep 10
}
'@
Register-ScheduledTask -TaskName ompweb-host -Force `
-Trigger (New-ScheduledTaskTrigger -AtLogOn -User "$env:USERDOMAIN\$env:USERNAME") `
-Action (New-ScheduledTaskAction -Execute powershell.exe -Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$dir\ompweb-host.ps1`"") `
-Settings (New-ScheduledTaskSettingsSet -ExecutionTimeLimit 0 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries)
Start-ScheduledTask ompweb-host
```

Stop it with `Stop-ScheduledTask ompweb-host`, then end the running host with
`Get-Process ompweb | Where-Object Path -eq "$env:LOCALAPPDATA\ompweb-windows-x64\ompweb.exe" | Stop-Process`
(only this release's `ompweb.exe`; adjust the path as for `$dir`). Remove it with
`Unregister-ScheduledTask ompweb-host`.

## Features

- **Interactive Chat**: Real-time streaming conversation with your local `omp` agent — tool calls, thinking levels, token counts, cost, context gauge, queue controls, and interrupt & retry.
Expand Down
7 changes: 6 additions & 1 deletion components/HostsConfig.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ test("an offline this-machine row says to start the service, with the server's i
send([row({ daemonManaged: false })]);
await waitFor(() => assert.equal(screen.queryByText(/ompweb-host service/), null));

send([row({ status: "online", hostVersion: 3 })]);
send([row({ status: "online", hostVersion: 2, serverVersion: 3 })]);
await waitFor(() => assert.equal(screen.queryByText(/ompweb-host service/), null));
// The daemon's protocol on its row, the web app's in the header; a needs-upgrade status already names both.
assert.match(screen.getByRole("button", { name: "Rename This machine" }).closest("li").textContent, /link protocol v2/);
screen.getByText("This web app expects link protocol v3.");
send([row({ status: "needs-upgrade", hostVersion: 2, serverVersion: 3 })]);
await waitFor(() => assert.doesNotMatch(screen.getByRole("button", { name: "Rename This machine" }).closest("li").textContent, /link protocol v2/));
});

test("the local name hint is the input's description, not part of its label", async (t) => {
Expand Down
6 changes: 5 additions & 1 deletion components/HostsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function HostCard({ host, onRename, onRevoke }: { host: HostRow; onRename: () =>
const details = [
host.ompVersion,
host.platform,
host.hostVersion !== null && host.status !== "needs-upgrade" && t("hostsConfig.protocol", { version: host.hostVersion }),
linked && (host.lastSeenAt ? t("hostsConfig.lastSeen", { time: new Date(host.lastSeenAt).toLocaleString() }) : t("hostsConfig.neverSeen")),
].filter(Boolean).join(" · ");

Expand Down Expand Up @@ -186,7 +187,10 @@ export function HostsConfig() {
return (
<div style={{ display: "flex", flexDirection: "column", gap: 12, width: "100%" }}>
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
<p style={{ margin: 0, fontSize: 13, color: "var(--text-muted)", lineHeight: 1.45 }}>{t("hostsConfig.subtitle")}</p>
<p style={{ margin: 0, fontSize: 13, color: "var(--text-muted)", lineHeight: 1.45 }}>
{t("hostsConfig.subtitle")}
{hosts?.[0] && <span style={{ display: "block" }}>{t("hostsConfig.serverProtocol", { version: hosts[0].serverVersion })}</span>}
</p>
<button type="button" className="ui-focus-ring" style={{ ...primaryStyle, display: "inline-flex", alignItems: "center", gap: 5, flexShrink: 0 }} onClick={() => setDialog({ kind: "add" })}>
<Plus size={14} aria-hidden="true" />{t("hostsConfig.add")}
</button>
Expand Down
14 changes: 12 additions & 2 deletions docs/specs/2026-10-28-remote-hosts-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ the one socket keeps that order.
understands (to a v4 daemon: no `part`, every line whole, and no unacked
window, since it acks only inside its next uplink frame).
A daemon on a dropped version gets 426
(a POST) or close 4426 (a hello frame); an update-only mode for it is
planned, separately.
(a POST) or close 4426 (a hello frame). Dropping versions ends with the
decision below.
- **Upgrade order: web app first, then hosts.** Main supports older daemons; a
daemon is not required to support a newer main, and one newer than main gets
close 4426.
Expand All @@ -363,6 +363,16 @@ the one socket keeps that order.
dialing a v4 server gets close 4426 with `{"serverVersion":4}`, logs "this
host's ompweb is newer than the server's: update ompweb on the server" and
exits 1; update the server first.
- **Decided: backward compatibility becomes enforced once the WebSocket
experiments end.** Until then (the browser transport experiment and the
host-link measurements), versions may still be dropped as above. Call N the
first link protocol version released after them. From N on the guarantees
are enforced, so the web app can always update an old host from Settings →
Hosts: the handshake (`hello`/`welcome` and the version close codes), the
version report, and an update op form a fixed core that every later web app
keeps working with every daemon on N or newer. `MIN_LINK_PROTOCOL_VERSION`
never goes above N. This replaces the update-only mode that was planned
for dropped versions.

## Host ops (this sub-project)

Expand Down
2 changes: 1 addition & 1 deletion docs/specs/2026-10-29-local-daemon-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ or an adoption failure.
| Web server restarts, daemon fine | Runs continue; adopted on `hello`; no resume prompt. |
| Daemon restarts or upgrades | Children end; sessions that were running resume once (existing auto-resume). |
| Daemon one link protocol version behind the web server (N-1) | The web server links a daemon one version behind: today a v4 daemon links beside v5 (no `part`, whole lines, no unacked window). It runs sessions, and its hello carries `pending`, so after a web restart its live children are adopted as a v5 daemon's are. From a later protocol bump on, a version whose hello lacks what adoption needs gets its live children killed and resumed on `hello` instead. The web server is upgraded first; the daemon catches up at its next restart. |
| Daemon on a version the web server dropped, or newer than it | 426 (a pre-WebSocket daemon's POST) or close 4426 (a hello frame); "This machine" shows "needs upgrade"; new sessions there are disabled until the daemon is restarted on a supported version. An update-only mode for this is planned. |
| Daemon on a version the web server dropped, or newer than it | 426 (a pre-WebSocket daemon's POST) or close 4426 (a hello frame); "This machine" shows "needs upgrade"; new sessions there are disabled until the daemon is restarted on a supported version. From the first link protocol version released after the WebSocket experiments (N) on, no version N or newer is dropped: the web app keeps the handshake and an update op working for them (remote-hosts spec, "Decided: backward compatibility"). |
| Dev server running | It never writes `host.json`, so the daemon stays linked to production; dev shows "This machine" offline. |
| Daemon not installed or not running | "This machine" shows offline with "start the ompweb-host service"; new local sessions are disabled. |
| `host.json` token stale (web regenerated it) | Daemon gets 401, re-reads `host.json`, redials. It exits only if the file still holds the rejected token. |
Expand Down
2 changes: 1 addition & 1 deletion graphify-out/graph.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,8 @@
"agentSession.transportLostMaybeSent": "Connection lost while sending; the message may have been delivered. Check the conversation before sending it again.",
"hostsConfig.lastSeen": "last seen {time}",
"hostsConfig.neverSeen": "never connected",
"hostsConfig.protocol": "link protocol v{version}",
"hostsConfig.serverProtocol": "This web app expects link protocol v{version}.",
"hostsConfig.allowAgentStart": "Agents can start sessions here without asking",
"hostsConfig.allowAgentStartAria": "Agents can start sessions on {name} without asking",
"hostsConfig.rename": "Rename",
Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,8 @@
"agentSession.transportLostMaybeSent": "送信中に接続が切れました。メッセージは届いている可能性があります。もう一度送信する前に会話を確認してください。",
"hostsConfig.lastSeen": "最終接続 {time}",
"hostsConfig.neverSeen": "未接続",
"hostsConfig.protocol": "リンクプロトコル v{version}",
"hostsConfig.serverProtocol": "この Web アプリはリンクプロトコル v{version} を想定しています。",
"hostsConfig.allowAgentStart": "エージェントが確認なしでここにセッションを開始できる",
"hostsConfig.allowAgentStartAria": "エージェントが確認なしで {name} にセッションを開始できる",
"hostsConfig.rename": "名前を変更",
Expand Down
2 changes: 2 additions & 0 deletions lib/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,8 @@
"agentSession.transportLostMaybeSent": "发送时连接中断,消息可能已送达。再次发送前请先查看对话。",
"hostsConfig.lastSeen": "最近在线 {time}",
"hostsConfig.neverSeen": "从未连接",
"hostsConfig.protocol": "链接协议 v{version}",
"hostsConfig.serverProtocol": "此 Web 应用使用链接协议 v{version}。",
"hostsConfig.allowAgentStart": "智能体可在此无需确认即启动会话",
"hostsConfig.allowAgentStartAria": "智能体可在 {name} 上无需确认即启动会话",
"hostsConfig.rename": "重命名",
Expand Down
Loading