Skip to main content

Overview

The orchestration schemas define the core domain model for T3 Code’s event-sourced architecture. These schemas handle projects, threads, messages, turns, and provider sessions using Effect Schema for validation and type safety.

Core Domain Models

OrchestrationProject

Represents a workspace project with configuration and scripts.
ProjectId
required
Unique project identifier
string
required
Project display name
string
required
Absolute path to the workspace root directory
string | null
required
Default AI model for new threads in this project
ProjectScript[]
required
Configured project scripts (build, test, lint, etc.)
IsoDateTime
required
Project creation timestamp
IsoDateTime
required
Last update timestamp
IsoDateTime | null
required
Soft deletion timestamp

ProjectScript

Configurable script that can be run in the project context.
string
required
Script identifier
string
required
Display name
string
required
Shell command to execute
ProjectScriptIcon
required
Icon identifier: "play" | "test" | "lint" | "configure" | "build" | "debug"
boolean
required
Whether to automatically run when creating a new worktree

OrchestrationThread

A conversation thread with an AI provider.
ThreadId
required
Unique thread identifier
ProjectId
required
Parent project ID
string
required
Thread title
string
required
AI model slug for this thread
RuntimeMode
required
Runtime mode: "approval-required" | "full-access"
ProviderInteractionMode
required
Interaction mode: "default" | "plan"
string | null
required
Git branch associated with this thread
string | null
required
Git worktree path if using worktrees
OrchestrationLatestTurn | null
required
Current or most recent turn state
OrchestrationMessage[]
required
All messages in the thread
OrchestrationProposedPlan[]
required
Plans proposed by the assistant (when in plan mode)
OrchestrationThreadActivity[]
required
Activity log (tool calls, approvals, errors)
OrchestrationCheckpointSummary[]
required
Git checkpoints for rollback
OrchestrationSession | null
required
Active provider session
IsoDateTime
required
Thread creation timestamp
IsoDateTime
required
Last update timestamp
IsoDateTime | null
required
Soft deletion timestamp

OrchestrationMessage

A single message in a thread conversation.
MessageId
required
Unique message identifier
OrchestrationMessageRole
required
Message role: "user" | "assistant" | "system"
string
required
Message content
ChatAttachment[]
Attached images or files
TurnId | null
required
Associated turn ID
boolean
required
Whether the message is currently streaming
IsoDateTime
required
Message creation timestamp
IsoDateTime
required
Last update timestamp

OrchestrationSession

Active provider session state.
ThreadId
required
Associated thread ID
OrchestrationSessionStatus
required
Session status: "idle" | "starting" | "running" | "ready" | "interrupted" | "stopped" | "error"
string | null
required
Provider name (e.g., “codex”)
RuntimeMode
required
Current runtime mode
TurnId | null
required
Currently active turn ID
string | null
required
Last error message if status is “error”
IsoDateTime
required
Last update timestamp

Commands

Thread Commands

Commands for managing threads and turns.

ThreadTurnStartCommand

Starts a new turn in a thread.
'thread.turn.start'
required
Command type discriminator
CommandId
required
Unique command identifier
ThreadId
required
Target thread ID
MessageId
required
ID for the user message
string
required
User input text (max 120,000 characters)
ChatAttachment[]
required
Attached images (max 8 attachments)
string
Override model for this turn
'fast' | 'flex' | null
Service tier for the turn
ProviderModelOptions
Model-specific options
'buffered' | 'streaming'
How to deliver assistant responses
RuntimeMode
required
Runtime mode for this turn
ProviderInteractionMode
required
Interaction mode for this turn

ThreadTurnInterruptCommand

Interrupts an active turn.

ThreadApprovalRespondCommand

Responds to an approval request from the provider.
ProviderApprovalDecision
required
Approval decision: "accept" | "acceptForSession" | "decline" | "cancel"

Project Commands

ProjectCreateCommand

Creates a new project.

Events

Event Types

All orchestration events:

Event Structure

All events share these base fields:
number
required
Global event sequence number
EventId
required
Unique event identifier
'project' | 'thread'
required
Type of aggregate this event belongs to
ProjectId | ThreadId
required
Aggregate root ID
IsoDateTime
required
Event occurrence timestamp
CommandId | null
required
Command that caused this event
EventId | null
required
Event that caused this event
CommandId | null
required
Correlation ID for event chain (equals commandId)
OrchestrationEventMetadata
required
Additional metadata (provider turn ID, adapter key, etc.)

Event Payloads

ThreadCreatedPayload

ThreadMessageSentPayload

Read Model

OrchestrationReadModel

The current state projection of all projects and threads.

RPC Schemas

WebSocket Methods

Method Schemas

Usage Examples

Dispatching a Command

Reading the Snapshot

Handling Events

Constants

Validation Limits

Default Values

See also: