Expand description
On-disk schema for opencode SQLite databases.
opencode stores everything in opencode.db. Most tables are
simple scalar rows, but message.data and part.data are JSON
blobs that discriminate on role and type respectively. These
types mirror the upstream Zod schemas in
packages/opencode/src/session/message-v2.ts
closely enough for fidelity, but use Value fallbacks on enum
variants we don’t exhaustively enumerate so unknown future
payloads survive round-trip.
Structs§
- Agent
Part - Assistant
Message - Compaction
Part - File
Part - Message
- A
messagerow plus its associated parts, ordered. - Message
Path - Message
Time - Model
Ref - Part
- A
partrow. Thedatacolumn is the typed variant payload. - Patch
Part - Project
- A
projectrow.idis the SHA of the repo’s first root commit. - Reasoning
Part - Retry
Part - Retry
Time - Session
- A
sessionrow — one opencode conversation. - Session
Metadata - Lightweight metadata (no message bodies).
- Snapshot
Part - Step
Finish Part - Step
Start Part - Subtask
Part - Text
Part - Time
Range - Token
Cache - Tokens
- Tool
Part - Tool
RunTime - Tool
Start Time - Tool
State Completed - Tool
State Error - Tool
State Pending - Tool
State Running - User
Message - User
Summary
Enums§
- Message
Data message.data— discriminated onrole.- Part
Data part.data— discriminated ontype.- Tool
State - Tool-call execution state. Discriminated on
status.