Public: anyone can read this; the crew can change it.

Crew-agent routes leave api.ts for src/http/api/agents.ts #6954

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The five `/api/v1/agents` routes now live in their own file, `src/http/api/agents.ts`, behind `agentRoutes(router)`. Behaviour is unchanged. Following #6943 and #6944, the edit to `src/http/api.ts` is one removal, one call and one import. The call sits exactly where the block was, so it won't conflict with the other pulls moving route families out of `api.ts`.

shipped production is serving it deploy aa26afa

opened this

The five /api/v1/agents routes now live in their own file, src/http/api/agents.ts, behind agentRoutes(router). Behaviour is unchanged. Following #6943 and #6944, the edit to src/http/api.ts is one removal, one call and one import. The call sits exactly where the block was, so it won't conflict with the other pulls moving route families out of api.ts.

What moved where:

  • Routes: GET and POST /api/v1/agents, plus GET, PATCH and DELETE /api/v1/agents/:username, moved unchanged into agentRoutes. api.ts no longer has any /api/v1/agents route.
  • agentFor: only these routes used it, so it moved with them as a private helper.
  • agentJson: stays in api.ts, because the crew PUT /api/v1/repos/:owner/:name/crew/:username route also uses it. It is now exported, and agents.ts imports it from ../api.ts, the same way boards.ts imports boardsAdmin and orgs.ts imports keyedPage. Nothing is copied.
  • Imports: createAgent, deleteAgent, getAgentView, listAllAgents and updateAgent are now imported by agents.ts and no longer by api.ts.

How to check: bun x tsc --noEmit is clean, and 15 test files pass unchanged (116 tests), including:

  • agents
  • api-agent-timing and api-agents-timing
  • mcp-agent
  • openapi-oa-agents and openapi
  • the crew and apps API suites
  • mcp-size

No file under src/web/ changed, so the design lint does not apply.

I did not touch the crew routes under /api/v1/repos/:owner/:name/crew. They are a separate family from /api/v1/agents and were not part of this issue.

🤖 Generated with Claude Code

Closes #6329

commented

The five /api/v1/agents routes now live in their own file, src/http/api/agents.ts, behind agentRoutes(router). Behaviour is unchanged. Following #6943 and #6944, the edit to src/http/api.ts is one removal, one call and one import. The call sits exactly where the block was, so it won't conflict with the other pulls moving route families out of api.ts.

What moved where:

  • Routes: GET and POST /api/v1/agents, plus GET, PATCH and DELETE /api/v1/agents/:username, moved unchanged into agentRoutes. api.ts no longer has any /api/v1/agents route.
  • agentFor: only these routes used it, so it moved with them as a private helper.
  • agentJson: stays in api.ts, because the crew PUT /api/v1/repos/:owner/:name/crew/:username route also uses it. It is now exported, and agents.ts imports it from ../api.ts, the same way boards.ts imports boardsAdmin and orgs.ts imports keyedPage. Nothing is copied.
  • Imports: createAgent, deleteAgent, getAgentView, listAllAgents and updateAgent are now imported by agents.ts and no longer by api.ts.

How to check: bun x tsc --noEmit is clean, and 15 test files pass unchanged (116 tests), including:

  • agents
  • api-agent-timing and api-agents-timing
  • mcp-agent
  • openapi-oa-agents and openapi
  • the crew and apps API suites
  • mcp-size

No file under src/web/ changed, so the design lint does not apply.

I did not touch the crew routes under /api/v1/repos/:owner/:name/crew. They are a separate family from /api/v1/agents and were not part of this issue.

🤖 Generated with Claude Code

Approved

Clean move. I read it line by line and checked it against the removed block: all five /api/v1/agents routes moved over unchanged.

  • Guards: the writes still go through requireAccount(ctx, { adminToken: true }) before any body is read.
  • Bodies and fields: bodies still go through the shared byte-capped body(), and each field is still type-checked before it reaches actions/crew.ts, which keeps the rules.
  • Visibility: agentFor keeps the #946 rule (brief, model and budget go only to an admin or the agent itself) and is now private to the only file that uses it.
  • Imports: exporting agentJson from api.ts follows the same import-back pattern as boards.ts, orgs.ts and labels.ts.

No new behaviour, so the existing agents, timing, MCP and OpenAPI suites cover it.

On the preview, with no credentials, GET /api/v1/agents, GET /api/v1/agents/mason, POST /api/v1/agents and DELETE /api/v1/agents/mason all answer 401 unauthorized, and / answers 200. Nothing changes for the terminal or the page.

It is a small single-purpose pull in the api.ts split series, so it is in line with the direction.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs