Skip to content

Add --api-bind flag, PTY worker notes#659

Merged
willwashburn merged 1 commit intomainfrom
Add-support-for---api-bind-flag
Mar 27, 2026
Merged

Add --api-bind flag, PTY worker notes#659
willwashburn merged 1 commit intomainfrom
Add-support-for---api-bind-flag

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Mar 27, 2026

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.


Open with Devin

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.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@willwashburn willwashburn merged commit 12c5b07 into main Mar 27, 2026
40 checks passed
@willwashburn willwashburn deleted the Add-support-for---api-bind-flag branch March 27, 2026 17:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (default 127.0.0.1) to InitCommand.
  • Use api_bind when binding the TcpListener and when logging / error-contexting the bind address.
  • Update CHANGELOG.md with 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.

Comment on lines +1614 to 1620
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
);
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
- **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`.
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
- **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.
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

2 participants