Repository navigation
Conversation
…artup and draining
d477d4c to
bf14d89
Compare
bf14d89 to
8dfdc15
Compare
There was a problem hiding this comment.
The change looks sound and works as described. I built the daemon on Linux and ran the lib, ownership and pipe tests. All the new output-file tests pass, and the handoff test confirms the file holds the full output across a restart handoff. Two older pipe tests fail here, and they fail the same way on the base: the sandbox doesn't reap orphaned processes. I didn't run clippy, fmt, or the macOS or Windows targets.
Public API: this changes only the process-daemon wire protocol, not the SDK, HTTP API, plugins or config. Every change is an addition:
featuresgainsoutput_pathon Unix.createaccepts an optionaloutput_path.TerminalInfoand theexitedevent gain an optionaloutput_error.
All of it is backwards compatible. The new fields are left out of the JSON when unset, so PTY create requests and normal exited frames are byte-identical to before. Clients only send output_path to a daemon that lists the feature.
No blocking concerns.
|
Superseded by #61875, which includes these commits (rebased) plus protocol v8. |
Issue for this PR
Closes #
Type of change
What does this PR do?
Lets a pipe process write its output straight to a file, so OpenCode can keep a command's complete output even when it exceeds the 2 MiB replay window, finishes before the server subscribes, or runs while no server is attached during a restart handoff. Stacked on #60697.
createtakesoutput_path(pipe only; featureoutput_path, so clients only send it to a daemon that lists it). It must be absolute; PTYs reject it.0600if missing, otherwise appended to. A path that can't be opened failscreatewithout starting the process.O_NOFOLLOW, so a symlink as the final path component is refused.output_erroronTerminalInfoand on theexitedevent (omitted otherwise), ordered before the output the file lacks, so OpenCode can tell the saved file is incomplete. The process keeps running.output_pathis left out of the JSON when unset, so PTYcreaterequests serialize exactly as before.OpenCode will point this at the shell tool's existing
sh_*.outfiles, soShell.outputand the "full output saved to …" notice keep working unchanged.How did you verify your code works?
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warningsand the macOS test suite inpackages/process-daemon; clippy forx86_64-pc-windows-msvcandx86_64-unknown-linux-gnu. New tests:seq 1 20000plus stderr lands in the file in full (the replay is truncated), with mode0600output_path, an unopenable path and a symlink are rejected, and nothing is spawned/dev/fullsetsoutput_errorwhile output and exit still reach subscribersoutput_pathon the wireChecklist
Added by the opencode bot (AI-generated).
Public API: process-daemon protocol: adds the
output_pathfeature, an optionalcreate.output_path, and optionaloutput_erroron TerminalInfo and theexitedevent (backwards compatible)