Overview
The Orchestration API provides the core command/event architecture for T3 Code. It follows event sourcing principles where commands are dispatched, domain events are persisted, and read models are projected from the event stream.Architecture
Available Methods
All orchestration methods use theorchestration.* namespace:
Retrieve the current read model snapshot
Execute a command (create/update/delete operations)
Get git diff for a specific turn range
Get complete diff for all turns in a thread
Replay events from a specific sequence number
getSnapshot
Retrieve the complete current state of all projects, threads, and sessions.Request
Response
Current event sequence number
Array of project entities
Array of thread entities with messages, activities, and checkpoints
Last snapshot update timestamp (ISO 8601)
Example Response
dispatchCommand
Execute a command to modify system state. Commands are validated, processed, and result in domain events.Request
Command object with type discriminator
Response
Event sequence number after command processing
Available Commands
See Commands for the complete list of command types.getTurnDiff
Retrieve the git diff for a specific range of turns within a thread.Request
Thread identifier
Starting turn number (inclusive)
Ending turn number (inclusive). Must be ≥ fromTurnCount.
Response
Thread identifier
Starting turn number
Ending turn number
Unified diff format showing file changes
getFullThreadDiff
Retrieve the complete diff for all turns in a thread from turn 0 to the specified turn.Request
Thread identifier
Final turn number (inclusive)
Response
Same structure asgetTurnDiff, with fromTurnCount always set to 0.
replayEvents
Replay all events after a specific sequence number. Useful for rebuilding read models or catching up after reconnection.Request
Start replaying after this sequence number (exclusive)
Response
Array of OrchestrationEvent objects in sequence order
Source Code References
Orchestration implementation:- Schemas:
packages/contracts/src/orchestration.ts - Engine:
apps/server/src/orchestration/Services/OrchestrationEngine.ts - Read Model:
apps/server/src/orchestration/Services/ProjectionSnapshotQuery.ts - Reactor:
apps/server/src/orchestration/Services/OrchestrationReactor.ts - WebSocket Router:
apps/server/src/wsServer.ts:684-714
Domain Model
The orchestration domain is split into two aggregate roots:Project Aggregate
Manages project metadata, workspace root, default model, and scripts
Thread Aggregate
Manages conversation threads, messages, activities, checkpoints, and provider sessions
Event Sourcing Flow
- Client dispatches command via
dispatchCommand - Server validates command against schema
- Command handler processes business logic
- Domain events are persisted to event store
- Read model is updated via projection
- Events are broadcast to all connected clients via push
- Client updates UI based on events
Next Steps
Commands
Explore all available command types
Events
Learn about domain event types
WebSocket Protocol
Understand the transport layer
