Skip to content

feat: implement agent routes#117

Open
2witstudios wants to merge 3 commits intomainfrom
ppg/issue-69-agent-routes
Open

feat: implement agent routes#117
2witstudios wants to merge 3 commits intomainfrom
ppg/issue-69-agent-routes

Conversation

@2witstudios
Copy link
Owner

Summary

  • Add four agent interaction REST endpoints as a Fastify route plugin
  • GET /api/agents/:id/logs?lines=N — capture tmux pane output (default 200 lines)
  • POST /api/agents/:id/send — send text/keys to pane (raw, literal, with-enter modes)
  • POST /api/agents/:id/kill — kill agent via core kill logic, update manifest
  • POST /api/agents/:id/restart — restart with optional prompt override, spawns new agent
  • Input validation on all POST routes with JSON schema
  • PpgError codes mapped to HTTP statuses (404, 400, 409, 503)
  • Server index bootstraps Fastify with CORS, optional bearer auth, and route registration
  • Added serveStatePath and servePidPath to path helpers

Test plan

  • 16 tests covering all four endpoints with mocked core functions
  • Validates error responses (404 for unknown agents, 400 for bad input)
  • Tests all three send modes (raw, literal, with-enter)
  • Tests kill idempotency (already-stopped agents return success)
  • Tests restart with both original prompt and prompt override
  • Full test suite passes (234 tests)

Closes #69

Add Fastify route plugin with four agent interaction endpoints:

- GET /api/agents/:id/logs?lines=N — capture tmux pane output (default 200)
- POST /api/agents/:id/send — send text/keys with raw, literal, or with-enter modes
- POST /api/agents/:id/kill — kill agent via core kill logic with manifest update
- POST /api/agents/:id/restart — restart agent with optional prompt override

Includes input validation, PpgError-to-HTTP status mapping, and 16 tests
covering all endpoints with mocked core functions.

Closes #69
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@2witstudios has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 34deb69 and c3b197d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • package.json
  • src/commands/restart.ts
  • src/commands/spawn.test.ts
  • src/core/agent.ts
  • src/lib/paths.ts
  • src/server/index.ts
  • src/server/routes/agents.test.ts
  • src/server/routes/agents.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ppg/issue-69-agent-routes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- P1: merge duplicate import from core/agent.js
- P2: use crypto.timingSafeEqual for bearer token comparison (OWASP A2)
- P2: refresh live agent status via checkAgentStatus in kill route
- P2: extract shared restartAgent() into core/agent.ts (DRY with CLI)
- P2: remove unused module-level test fixtures, add setupAgentMocks helper
- P3: map PROMPT_NOT_FOUND error code to HTTP 400
- P3: map PANE_NOT_FOUND to HTTP 410, catch capturePane failures
- P3: add tests for pane-gone, restart idle agent, missing prompt file
- P4: cap lines query param at 10,000
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.

Implement agent routes

1 participant