Add --api-bind flag, PTY worker notes#659
Conversation
Introduce a new --api-bind CLI option (default: 127.0.0.1) on InitCommand to configure the broker HTTP/WS bind address, use it when creating the TcpListener, and include the bind address in the startup log and error context. Also update CHANGELOG.md to document the --api-bind flag, the new write_pty PTY worker message, and that sendInput now routes through the PTY worker protocol.
There was a problem hiding this comment.
Pull request overview
Adds configurability for the broker’s optional HTTP/WS API listener by introducing an --api-bind flag, wiring it into the listener bind and startup/error messages, and documenting the change in the changelog.
Changes:
- Add
--api-bind(default127.0.0.1) toInitCommand. - Use
api_bindwhen binding theTcpListenerand when logging / error-contexting the bind address. - Update
CHANGELOG.mdwith new entries (including PTY worker notes).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/main.rs |
Introduces --api-bind and uses it in the HTTP API listener bind/log/error context. |
CHANGELOG.md |
Documents the new flag and adds PTY-worker-related notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let listener = tokio::net::TcpListener::bind(format!("{}:{}", cmd.api_bind, cmd.api_port)) | ||
| .await | ||
| .with_context(|| format!("failed to bind API on port {}", cmd.api_port))?; | ||
| .with_context(|| format!("failed to bind API on {}:{}", cmd.api_bind, cmd.api_port))?; | ||
| eprintln!( | ||
| "[agent-relay] API listening on http://127.0.0.1:{}", | ||
| cmd.api_port | ||
| "[agent-relay] API listening on http://{}:{}", | ||
| cmd.api_bind, cmd.api_port | ||
| ); |
There was a problem hiding this comment.
format!("{}:{}", cmd.api_bind, cmd.api_port) will produce invalid addresses and URLs for IPv6 (needs [addr]:port), and using a raw String defers validation to runtime. Consider parsing --api-bind as std::net::IpAddr (or a full SocketAddr) with clap value parsing, then constructing a SocketAddr for both TcpListener::bind and the startup log so IPv4/IPv6 formatting is correct and errors are caught at CLI parse time.
| - **Model Hotswap**: Runtime model switching for agents, allowing dynamic provider and model changes without restart (#5a80bdc0). | ||
| - **Prerelease Publishing**: New prerelease script for staging environment, enabling faster iteration and testing cycles (#495428cd). | ||
| - **`--api-bind` flag for broker HTTP API**: Configures the bind address for the broker's HTTP/WS server (default: `127.0.0.1`). Use `--api-bind 0.0.0.0` when running inside Daytona sandboxes to accept remote connections from the desktop app. | ||
| - **`write_pty` PTY worker message**: New protocol message type that writes arbitrary data to the PTY. Used internally by the broker's `send_input` handler. The PTY worker responds with `ok` (including `bytes_written`) or `worker_error`. |
There was a problem hiding this comment.
This entry describes a new write_pty PTY worker protocol message, but there is no write_pty symbol/message type anywhere in the repo (a search only finds this changelog line). Either include the corresponding protocol/implementation changes in this PR, or remove/adjust the changelog item so it matches what is actually shipped.
| - **Breaking cache removed**: Removed cache logic that caused agent initialization failures (#d1166cf9). | ||
| - **Better-sqlite3 optional in tests**: Database dependency now properly marked as optional for test environments, improving CI reliability (#190611b7). | ||
| - Doctor command now correctly validates test expectations for partial driver availability (#9b545ff9). | ||
| - **`sendInput` now routes through PTY worker protocol**: Previously `sendInput` wrote raw bytes to the PTY worker's stdin, which the worker's JSON parser rejected silently. Input never reached the PTY. Now `sendInput` sends a proper `write_pty` protocol frame, and the PTY worker writes the data to the actual PTY. |
There was a problem hiding this comment.
This claims sendInput now routes through the PTY worker protocol, but the broker send_input handler in src/main.rs still writes raw bytes directly to the worker process stdin (which the PTY worker reads as JSON lines). Please update the implementation in this PR to match the changelog, or revise the changelog entry to reflect current behavior.
Introduce a new --api-bind CLI option (default: 127.0.0.1) on InitCommand to configure the broker HTTP/WS bind address, use it when creating the TcpListener, and include the bind address in the startup log and error context. Also update CHANGELOG.md to document the --api-bind flag, the new write_pty PTY worker message, and that sendInput now routes through the PTY worker protocol.