Skip to main content

Overview

The contracts package provides foundational TypeScript types and Effect schemas used throughout T3 Code. These types ensure type safety and validation across the client-server boundary.

Base Schemas

String Types

TrimmedString

A string that has leading and trailing whitespace removed.

TrimmedNonEmptyString

A trimmed string that must contain at least one character.

Numeric Types

NonNegativeInt

An integer greater than or equal to zero.

PositiveInt

An integer greater than or equal to one.

DateTime Types

IsoDateTime

An ISO 8601 formatted datetime string.

Branded Identifiers

Branded types provide type-safe identifiers that prevent mixing different ID types.

Entity IDs

ThreadId

Unique identifier for a conversation thread.

ProjectId

Unique identifier for a workspace project.

CommandId

Unique identifier for a command in the event-sourced system.

EventId

Unique identifier for a domain event.

MessageId

Unique identifier for a message in a thread.

TurnId

Unique identifier for a turn (user input + assistant response cycle).

Provider Runtime IDs

ProviderItemId

Identifier for a provider-specific item (e.g., a Codex conversation item).

RuntimeSessionId

Identifier for a runtime session.

RuntimeItemId

Identifier for a runtime item.

RuntimeRequestId

Identifier for a runtime request.

RuntimeTaskId

Identifier for a runtime task.

ApprovalRequestId

Identifier for an approval request.

CheckpointRef

Reference to a git checkpoint for rollback.

Provider Types

ProviderKind

Supported AI provider types.
Currently, only Codex is supported. Additional providers may be added in the future.

Runtime Modes

RuntimeMode

Controls the level of access the provider has to the system.
  • approval-required - User must approve each tool call
  • full-access - Provider can execute tools without approval

ProviderApprovalPolicy

Detailed approval policy configuration.

ProviderSandboxMode

File system access level for the provider.

Interaction Modes

ProviderInteractionMode

Controls how the provider interacts with the user.
  • default - Standard conversational mode
  • plan - Provider proposes a plan before execution

Service Tiers

ProviderServiceTier

Service tier for API requests.

Approval Types

ProviderApprovalDecision

User’s decision on an approval request.
  • accept - Approve this specific request
  • acceptForSession - Approve this and future similar requests in the session
  • decline - Reject this request
  • cancel - Cancel the entire turn

ProviderRequestKind

Type of request requiring approval.

Message Delivery

AssistantDeliveryMode

How assistant messages are delivered to the client.

Chat Attachments

ChatImageAttachment

An image attached to a chat message.
type
'image'
required
Attachment type discriminator
id
string
required
Unique attachment ID (max 128 chars, alphanumeric with dashes/underscores)
name
string
required
File name (max 255 chars)
mimeType
string
required
MIME type starting with “image/” (max 100 chars)
sizeBytes
number
required
File size in bytes (max 10MB)

ChatAttachment

Union of all attachment types.

Git Types

GitBranch

Represents a git branch with metadata.
name
string
required
Branch name
isRemote
boolean
Whether this is a remote branch
remoteName
string
Name of the remote (e.g., “origin”)
current
boolean
required
Whether this is the currently checked out branch
isDefault
boolean
required
Whether this is the default branch (main/master)
worktreePath
string | null
required
Path to the worktree if this branch has one

GitStackedAction

Git actions that can be performed in sequence.
  • commit - Create a commit
  • commit_push - Create a commit and push
  • commit_push_pr - Create a commit, push, and open a PR

Project Types

ProjectEntry

Represents a file or directory in a project.
path
string
required
Relative path from project root
kind
'file' | 'directory'
required
Entry type
parentPath
string
Parent directory path

Editor Types

EditorId

Supported code editors.

Editor Configuration

Usage Examples

Creating Branded IDs

Validating with Effect Schema

Working with Chat Attachments

Using Git Types

Type Guards

Effect Schema provides runtime type guards:
See also: