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:
method
Retrieve the current read model snapshot
method
Execute a command (create/update/delete operations)
method
Get git diff for a specific turn range
method
Get complete diff for all turns in a thread
method
Replay events from a specific sequence number
getSnapshot
Retrieve the complete current state of all projects, threads, and sessions.Request
Response
number
required
Current event sequence number
array
required
Array of project entities
array
required
Array of thread entities with messages, activities, and checkpoints
string
required
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
ClientOrchestrationCommand
required
Command object with type discriminator
Response
number
required
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
string
required
Thread identifier
number
required
Starting turn number (inclusive)
number
required
Ending turn number (inclusive). Must be ≥ fromTurnCount.
Response
string
required
Thread identifier
number
required
Starting turn number
number
required
Ending turn number
string
required
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
string
required
Thread identifier
number
required
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
number
required
Start replaying after this sequence number (exclusive)
Response
array
required
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
