TraeAPI - Hosting Trae Agent as a HTTP server #280
+11,746
−15
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.
Introduces a new FastAPI-based API package (trae_api) with agent execution, streaming, health/metrics, echo, and task endpoints; comprehensive logging, metrics, middleware, tracing, config, and lifecycle scaffolding; TaskIQ broker, tasks, and SQLite result backend; extensive tests; new schemas in trae_agent; minor agent tweaks; Makefile updates; README additions.
New Features
Introduced a REST API with agent execution (sync/stream), health, metrics, readiness/liveness, echo, and background task endpoints.
Agent Execution Endpoints:
Added real-time streaming (SSE/NDJSON), structured logging, observability, and Prometheus-compatible metrics.
Provided local task queue with SQLite result backend and an application entrypoint to run the server.
Documentation: Added API Usage guidance with start instructions, base URL, examples, and endpoint list.
Chores: Expanded Makefile with install/run/test/format/type-check commands for the API and Updated ignore rules.
Tests: Added comprehensive unit, integration, and end-to-end tests across API, logging, metrics, tasks, and SQLite.
Validation
Start API:

API Tests:

API Endpoints:

OpenAPI Spec:

Linked Issues
Closes: #250
If this PR fully resolves the issue, use one of the following keywords to automatically close the issue when this PR is merged: