Skip to content

feat(agent): remote Rex device selection for task dispatch (#209) - #211

Merged
rebuildup merged 3 commits into
release/rex-remotefrom
209
Nov 21, 2026
Merged

rebuildup merged 3 commits into
release/rex-remotefrom
209

Conversation

@rebuildup

@rebuildup rebuildup commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

agent task run --runtime rex --rex-host <label> --cwd <remote-path> selects a remote Rex host (rex hosts entry, e.g. device-wsl → ssh://rex-wsl) independently of the runtime choice. Runtime and device remain separate axes; Herdr stays the default.

  • script/agent/rex.ts: server threaded through every CLI call (rex -S); remote cwd never reaches the local spawn; new helpers checkRexServer, remoteExec, remoteWriteFile, probeRemoteHome.
  • script/agent/runtime.ts: server carried on WorkerHandle/SurfaceRef/WorkerStartSpec/RuntimeTaskMapping — resume/reconcile probe only the recorded host.
  • script/agent/task.ts: rexHost/rexCwd/rexHome persisted on TaskAttempt; remote preflight (dotfiles files, omp via mise shims, remote managed models.yml, remote Infisical credential probe) before worker start; no cross-host/runtime fallback.
  • script/agent/args.ts, commands.ts, help.ts: --rex-host requires --runtime rex; --cwd sets the worker working directory (must be absolute on the remote host).

Test plan

  • bun run typecheck, ./script/test, ./script/test-workflow, ./script/check-secrets, ./script/check
  • Unit: --rex-host/--cwd parsing, mapping round-trip with/without server
  • Live: real-model OMP task on WSL (--rex-host device-wsl --cwd /home/basic/src/pc-setup) completed dispatch→observe→collect; attempt persisted rexHost/rexCwd/rexHome/session/window/block
  • resume/reconcile on interrupted remote attempt, disconnect recovery, Mac GUI remote control (follow-up verification)

Generated with Devin

Summary by CodeRabbit

  • New Features
    • Run tasks on a specified Rex host with a remote working directory. Remote paths must be absolute, and the host option requires the Rex runtime.
    • Remote task launches now use the selected host for worker sessions and related task operations.
    • Remote launches check host availability and required files, tools, profiles, and credentials before starting.

`agent task run --runtime rex --rex-host <label> --cwd <remote-path>`
dispatches the worker to a remote `rex hosts` endpoint (e.g. the WSL
server) instead of the local Rex server.

- rex.ts: every CLI call accepts a server (`rex -S`); remote cwd is
  never passed to the local spawn. New remote helpers: checkRexServer,
  remoteExec (`run --wait`), remoteWriteFile (base64 payload),
  probeRemoteHome (resolves remote $HOME for ~/.dotfiles argv paths).
- runtime.ts: server flows through WorkerHandle/SurfaceRef/
  WorkerStartSpec/RuntimeTaskMapping; resume/reconcile probe ONLY the
  recorded host — no fallback to local, another host, or Herdr.
- task.ts: TaskDescriptor/TaskAttempt gain rexHost/rexCwd/rexHome;
  dispatch preflights the remote host (dotfiles files, mise shims,
  managed models.yml written remotely, Infisical credential probe)
  before starting the worker; candidates reuse the recorded host.
- args/commands/help: --rex-host requires --runtime rex; --cwd is the
  worker working directory (absolute remote path for remote hosts).

Verified live: real-model OMP worker on WSL via `device-wsl` completed
dispatch -> observe -> collect with rexHost/rexCwd/rexHome persisted.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change adds remote Rex host and working-directory options to task execution. Rex operations, runtime handles, OMP paths, and task attempts now carry remote host or location data. Remote dispatch checks host reachability and prerequisites before starting the worker.

Changes: Remote Rex task execution

Layer / File(s) Summary
Task-run options and dispatch
script/agent/args.ts, script/agent/commands.ts, script/agent/help.ts, script/agent.runtime.test.ts
The parser accepts --rex-host and --cwd, defaults both to null, and includes them in usage text. cmdTask rejects a Rex host when the selected runtime is not Rex and forwards supplied values to task dispatch. Tests cover parsing and defaults.
Server-targeted Rex operations
script/agent/rex.ts
Rex session, block, prompt, and cleanup operations accept an optional server. New helpers check server reachability, run remote commands, write remote files, and probe the remote home.
Rex runtime routing and mapping
script/agent/runtime.ts, script/agent/rex.ts
Runtime handles, surface and pane operations, and task mappings carry the optional Rex server. Rex operations use the selected server; Herdr surface creation remains unchanged.
Remote OMP paths
script/agent/omp.ts
OMP profile and worker paths can resolve from the remote home. Remote worker arguments do not add the local Herdr extension.
Remote task setup and persisted location
script/agent/task.ts
Remote dispatch validates the host and absolute working directory, checks remote files, OMP availability, managed-profile ownership, and credentials, then starts workers using the remote location. Attempts retain the Rex host, working directory, and remote home for subsequent worker setup.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant taskrun as agent task run
  participant task as runTaskToCompletion
  participant rexcli as Rex CLI
  participant runtime as Rex runtime adapter
  participant host as Remote Rex host
  taskrun->>task: Pass runtime, rexHost, and cwd
  task->>rexcli: Check Rex host reachability
  rexcli->>host: Check server status
  host-->>task: Return reachability result
  task->>runtime: Create surface on selected server
  runtime->>rexcli: Create and inspect session
  rexcli->>host: Run targeted Rex commands
  task->>rexcli: Run remote preflight and credential checks
  task->>runtime: Start worker with recorded server
Loading

Possibly related issues

Possibly related PRs

  • rebuildup/dotfiles#206 — Adds the Rex runtime and runtime selection that this change extends with remote host targeting.
  • rebuildup/dotfiles#200 — Documents the Rex runtime and future remote execution path implemented by this change.
Merge Risk: Moderate · up to 9b76f

Remote Rex dispatch is a new opt-in feature. As written, repeat dispatches to the same host can fail, invalid or missing host and directory inputs can silently run locally, and stalled Rex commands can hang dispatch. Cleanup and recovery can also target the wrong host, and the credential probe prints the secret into Rex output. Fix these before relying on remote dispatch; default local behavior is unaffected.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The managed marker is a prefix of the first line, matching
ensureOmpManagedProfile startsWith semantics — exact equality rejected
the launcher-managed file the previous dispatch had just written.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The --rex-host documentation pushed the entry point over the limit;
compressed the task-run and fallback entries to compensate.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@rebuildup
rebuildup merged commit 9694e02 into release/rex-remote Nov 21, 2026
3 checks passed
@rebuildup
rebuildup deleted the 209 branch November 23, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant