Skip to content

feat: POST /s/:id/execute — headless CLI invocation endpoint#31

Merged
jesse23 merged 5 commits into
mainfrom
feat/server-execute-endpoint
Jun 17, 2026
Merged

feat: POST /s/:id/execute — headless CLI invocation endpoint#31
jesse23 merged 5 commits into
mainfrom
feat/server-execute-endpoint

Conversation

@jesse23

@jesse23 jesse23 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds POST /s/:id/execute to run a CLI command non-interactively alongside a running session
  • Streams stdout/stderr as ndjson lines ({"stream":"stdout","data":"…"}), closes with {"exit":N}
  • Requires an active PTY (409 if not running), consistent with the publish channel
  • Spawns via child_process.spawn (no PTY) so tools like claude -p stay in pipe mode

Test plan

  • 404 — unknown session
  • 400 — wrong Content-Type
  • 409 — session exists but no PTY
  • 400 — invalid body (cmd not a string)
  • Happy path — verifies 200, Content-Type: application/x-ndjson, stdout line, and exit line

Spec: docs/specs/server.pipe.md · ADR: docs/adrs/026.server.pipe.md

🤖 Generated with Claude Code

jesse23 and others added 5 commits June 11, 2026 15:07
Spawns a command non-interactively alongside a running session and
streams stdout/stderr as ndjson, closing with an exit-code line.
Requires an active PTY (409 otherwise), consistent with publish.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iness

Alpine CI shells don't reliably produce output within 5s, causing the
execute-endpoint tests to time out. The PTY is already spawned before
the WebSocket handshake completes, so onopen is the correct signal.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Alpine CI containers don't set SHELL in the environment, causing the
server to spawn an undefined shell when a WebSocket triggers PTY init,
crashing the process. Mirror the same env setup as the websocket tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@jesse23 jesse23 added bug Something isn't working and removed bug Something isn't working labels Jun 17, 2026
@jesse23 jesse23 merged commit 8a92b54 into main Jun 17, 2026
3 checks passed
@jesse23 jesse23 deleted the feat/server-execute-endpoint branch June 17, 2026 15:19
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