docs: add /api/chat/workflow contract + promote Chats to top-level nav
Summary
Documentation-driven scoping for the upcoming Vercel-Workflow-backed chat endpoint that will live at POST /api/chat/workflow in api. Landing the contract first so the chat team can integrate against a real spec while the implementation is being ported from open-agents.
- New OpenAPI path
/api/chat/workflowwithChatWorkflowRequestschema (messages,chatId,sessionId,recoupAccessToken?) under BearerapiKeyAuth - Response:
text/event-stream+x-workflow-run-idresponse header - Documented status codes:
200/400(incl. "Sandbox not initialized") /401/404/409(duplicate workflow for chat) - Frontmatter-only MDX page at
api-reference/chat/workflow.mdxper docs CLAUDE.md convention — all prose lives in the OpenAPI description - Nav entry under Research → Chat, listed first
The endpoint description verbally maps the deferred sibling routes (GET /api/chat/{chatId}/stream, POST /api/chat/{chatId}/stop) so reviewers see the full planned surface without creating orphan "Coming soon" pages.
This endpoint is parallel to the existing POST /api/chat — does not replace it. The legacy endpoint continues to serve MCP- and Composio-tool chat for clients that need it.
Background
Migration plan worked through in Slack (#recoup) between Sweetman and Arpit on 2026-05-20. Decision: port the open-agents /api/chat agent loop into api as /api/chat/workflow, swap the MCP toolset for the sandbox-only tool set (bash, read, write, grep, glob, todo, task, ask_user_question, skill, fetch), and rely on the recoupable/skills:recoup-api skill (already installed in every sandbox) as the HTTP bridge back to the API.
This is PR 1 of 5. Subsequent PRs land against api:
- Route stub:
POST /api/chat/workflowwith body validation + hardcoded UIMessage stream - Port 10 sandbox tool files +
buildAgentToolsfactory (no wiring) - Port route-level helpers (
createChatRuntime,agentCustomInstructions,extractOrgId,compareAndSetChatActiveStreamId,touchChat,reconcileExistingActiveStream,persistLatestUserMessage) - Wire it all together —
runAgentWorkflow+runAgentStep+ replace stub with realstart()
Test plan
- Mintlify preview renders the new page under Research → Chat → Stream Chat (Workflow + Sandbox)
- OpenAPI playground for
/api/chat/workflowloads with request body, auth, and all five status codes - Legacy
POST /api/chatpage (api-reference/chat/stream) still renders unchanged - No broken cross-links — page references
/api-reference/sandbox/create,/api-reference/sessions/create,/api-reference/sessions/create-chat,/api-reference/chat/stream
🤖 Generated with Claude Code
Summary by cubic
Adds the contract and docs for POST /api/chat/workflow, a Vercel Workflow–backed, sandbox-only chat streaming endpoint. Also promotes Chats to a top-level tab and trims the endpoint/schema descriptions to house style.
-
New Features
- OpenAPI path
POST /api/chat/workflowsecured byapiKeyAuth. ChatWorkflowRequestschema:messages,chatId,sessionId; optionalcontext.contextLimit; norecoupAccessToken(Authorization header is forwarded into the sandbox).- Response:
text/event-streamwithx-workflow-run-idheader; status codes: 200, 400 (sandbox not initialized), 401, 403, 404, 409. - Docs page
api-reference/chat/workflow.mdx; endpoint and schema descriptions tightened. Notes futureGET /api/chat/{chatId}/streamandPOST /api/chat/{chatId}/stop.
- OpenAPI path
-
Docs Navigation
- New top-level tab: Chats.
- Streaming group lists
api-reference/chat/workflow,api-reference/chat/stream,api-reference/chat/generate. - Other chat pages reorganized under Chats and Messages groups.
Summary by CodeRabbit
- New Features
- New streaming chat workflow API endpoint (
POST /api/chat/workflow) with session management capabilities - Built-in support for workflow execution control via
x-workflow-run-idresponse headers - Complete API reference documentation added with request schema specifications and error handling details
- New streaming chat workflow API endpoint (