Skip to content

feat(cli): show how machines connect - #65347

Merged
kitlangton merged 2 commits into
devfrom
machine-list-carrier
Nov 21, 2026
Merged

kitlangton merged 2 commits into
devfrom
machine-list-carrier

Conversation

@kitlangton

@kitlangton kitlangton commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

machine list shows how each machine is connected, and machine add says who can use the join string.
Until now you had to read the worker's log to learn whether a link was direct or relayed, and machine add listed addresses without the Iroh entry the server adds.

🚦 Flag: machines. Nothing new is read or started with the flag off.

🐛 Before → after

$ opencode machine list
before   gpu  paired  connected  linux/x64
after    gpu  paired  connected  linux/x64  iroh direct 82ms
         cpu  paired  connected  linux/arm64  websocket
$ opencode machine add gpu
Machine: gpu
Expires in 5 minutes (at 04:05 PM).

ocjoin_example

Works from any network.            ← new
Addresses:
  ws://localhost:4096
  iroh                             ← new: what the join string really holds
The join string holds Sentence
An iroh entry Works from any network.
No iroh, an address that isn't loopback Works from computers that can reach one of these addresses.
Loopback only Only works on this computer. Pass --url with an address other computers can reach.

🔧 How

// link.ts: a carrier may describe itself; read only when the list is asked for
Carrier.describe?: () => { kind: "websocket" | "iroh", path?: "direct" | "relayed", rtt?: number }

// GET  /api/experimental/machine        each connected machine gains an optional `connection`
// POST /api/experimental/machine        the response gains `reach`, the final list in the join string

No history, events or metrics. Output that isn't a terminal is still the bare join string.

📊 Proof

Check Result
The three sentences and the new column (packages/cli/test/machine.test.ts) ✅
The field over a WebSocket link and over an Iroh link (server tests, ×5) ✅ 35 pass
Typecheck in core, cli, server, client, protocol; both generators ✅
Independent review on another model family One finding, fixed: this CLI against an older server crashed on the missing reach

👀 Read: packages/core/src/machine/iroh.ts (describe), then packages/cli/src/commands/handlers/machine/common.ts.

Follows #65341


Added by the opencode bot (AI-generated).

Public API: adds optional connection to experimental machine list items and reach to the machine add response (backwards compatible)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I ran machine add against the PR's server with the machines flag on: it shows the new access sentence and the iroh entry under Addresses. machine list behaves as before when no worker is connected. The new CLI and server tests pass (the WebSocket and Iroh connection cases are covered there), and cli, server, client and protocol typecheck cleanly.

Public API (experimental machine routes, machines flag), all additions:

  • GET /api/experimental/machine: each item gains an optional connection: { kind: "websocket" | "iroh", path?: "direct" | "relayed", rtt?: number }.
  • POST /api/experimental/machine: the response gains a required reach array of { type: "url", url } or { type: "iroh" }. The OpenAPI spec and the generated client types are updated to match, and MachineReach is now exported from the promise client types.
  • machine list output gets a connection column, and machine add gets a sentence saying who can use the join string.

This is backwards compatible for existing callers. The new CLI falls back to the addresses it sent when an older server returns no reach.

No blocking concerns.

@kitlangton
kitlangton merged commit cfb1b4a into dev Nov 21, 2026
29 checks passed
@kitlangton
kitlangton deleted the machine-list-carrier branch November 21, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant