Repository navigation
Serve tasks over the api: create, read, and cancel - #216
Merged
Merged
Conversation
POST /v1/tasks creates a session on an agent config and starts its run with the task's content, in one call (Store.createTask). GET /v1/tasks/:id reads a task back, and POST /v1/tasks/:id/cancel forwards to its session's cancel. Errors match the session routes: 400 for an unknown config or version, 409 for an archived config or session, 404 for an unknown or foreign task. The string-or-array content a session message accepts moves to common.ts (WireContent), so tasks and messages normalize it the same way. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second PR of the task API, on top of #215 (merged), which added tasks to the store.
Routes
POST /v1/taskscontent, in one store transaction (createTask)201with the task, including thesessionIdit startedGET /v1/tasks/:id200, or404if the task is unknown or in another namespacePOST /v1/tasks/:id/cancelrequestCancel202,404as above, or409if the session is archivedPOST /v1/tasks:{ namespace?, agentConfigId, agentConfigVersion?, content, metadata? }.namespacedefaults the same way it does on sessions.contentcan be a plain string or an array of content blocks, like a session message's.POST /v1/sessions:400for an unknown or foreign config or version,409for an archived config./v1/sessions/:sessionId.Also
contenthandling thatPOST /v1/sessions/:id/messagesdid inline moved tocommon.ts(WireContent). Tasks and messages now share it, and the message route behaves the same as before.Tests
apps/api/test/tasks.test.ts, run over the real store (PGlite + the pg adapter), checks:content, the default namespace, and an explicit version400for an unknown, foreign or bad-version config, and for missing or malformed content409for an archived config404for an unknown or foreign task on read and on cancel; a foreign cancel leaves the owned task's log alone409once the session is archivedpnpm typecheck,pnpm format:checkandpnpm testpass.🤖 Generated with Claude Code