Type System

Core TypeScript Types

Message Types
type Message =
  | UserMessage         // User input with content blocks
  | AssistantMessage    // AI response (text, tool use)
  | SystemMessage       // System instructions
  | ProgressMessage     // Progress updates
  | TombstoneMessage    // Deleted/replaced messages
  | AttachmentMessage   // File attachments

type PermissionMode = 'default' | 'auto' | 'bypass'

type ToolProgressData =
  | BashProgress        // Shell output streaming
  | WebSearchProgress   // Search result streaming
  | MCPProgress         // MCP operation progress
  | AgentToolProgress   // Sub-agent status
  | TaskOutputProgress  // Task result display

Try This

Count the message types (6 total). Each serves a purpose. TombstoneMessage replaces deleted messages - why not just remove them? Because the API needs message ordering preserved.

Type System

Design Patterns

1. Build-Time Feature Gating

Uses Bun's feature() for dead code elimination at bundle time.

2. Lazy Circular Dependency Breaking

Uses lazy require() wrappers to break circular imports.

3. Ant-Only Code Elimination

Internal features eliminated from external builds via constant folding.

4. React Context State Management

Central AppState with getter/setter pattern and memoized selectors.

Try This

Go to the Feature Flag Simulator. Toggle COORDINATOR_MODE on. At build time, Bun's feature() includes the coordinator code. Toggle it off - that entire code block is removed from the bundle. Dead code elimination in action.

Type System

All Feature Flags

FlagTypePurposeStatus
COORDINATOR_MODEBuildMulti-agent teamsInternal
KAIROSBuildProactive assistantInternal
VOICE_MODEBuildVoice I/OBeta
BRIDGE_MODEBuildIDE bridgeActive
TRANSCRIPT_CLASSIFIERBuildAuto-mode classifierInternal
DIRECT_CONNECTBuildDirect APIBeta
SSH_REMOTEBuildSSH remoteBeta
PROACTIVEBuildProactive toolsInternal
AGENT_TRIGGERSBuildCron toolsBeta
AGENT_TRIGGERS_REMOTEBuildRemote triggersBeta
MONITOR_TOOLBuildSystem monitorInternal
WORKFLOW_SCRIPTSBuildWorkflowsBeta
HISTORY_SNIPBuildHistory snipInternal
WEB_BROWSER_TOOLBuildWeb browserInternal
PUSH_NOTIFICATIONBuildPush notificationsInternal
tengu_scratchRuntimeScratchpadInternal
tengu_onyx_ploverRuntimeAutoDream configInternal
tengu_ccr_bridge_multi_sessionRuntimeMulti-sessionBeta

Try This

Go to the Feature Flag Simulator. Enable all 8 flags and count the available tools. Now disable all flags - how many tools remain? The difference shows how much functionality is feature-gated.