Documentation
¶
Overview ¶
Package deepseek reads DeepSeek Harness (DSH) session transcripts.
DSH writes one append-only JSONL transcript per session, compressed with Zstandard, under <dsh-home>/sessions/<encoded-cwd>/<session-id>/. The current on-disk format is v3 (session.v3.jsonl.zstd); older sessions carry session.jsonl.zstd (v0) with the same record kinds. Every record carries a monotonic `seq`, which is what makes a re-read idempotent.
Like Codex, DSH reports token counts and never a cost of its own, so the turns are priced by Caprock's own pricing table (pricing/pricing.json grew DeepSeek rows long ago — see .ai/14-build-status.md).
Index ¶
Constants ¶
const Agent = "deepseek"
Agent is the value written to sessions.agent for DeepSeek Harness sessions.
const EnvDir = "CAPROCK_DSH_DIR"
EnvDir overrides the sessions root, for tests and anyone whose DSH home lives somewhere unusual.
const EnvHome = "DSH_HOME"
EnvHome is DSH's own override for its data root; honoured so Caprock reads the same sessions a user redirected DSH to.
Variables ¶
var ErrNotASession = errors.New("deepseek: not a session transcript")
ErrNotASession is returned for a file that is not a DSH session transcript.
Functions ¶
func Dir ¶
func Dir() string
Dir is the root DSH writes its session transcripts under.
The path follows DSH's own resolution: $DSH_HOME names the data root directly (it already *is* the home, usually ~/.dsh), and otherwise the default ~/.dsh is used — matching the harness so Caprock reads the sessions a user redirected. CAPROCK_DSH_DIR overrides both for tests.
Types ¶
type Ingester ¶
type Ingester struct {
// contains filtered or unexported fields
}
Ingester copies DSH session transcripts into Caprock's store.
It polls rather than watches, exactly like Codex's importer. The transcripts are append-only and every event carries a key derived from its record seq, so a re-read of an already-seen file costs a read and produces nothing: `(session_id, key)` is unique in the store. Only files whose modification time or size moved are re-read.
func NewIngester ¶
NewIngester builds an ingester over a DSH sessions directory.
type Session ¶
type Session struct {
ID string
Path string
Cwd string
Model string
StartedAt time.Time
Turns []Turn
Tools []ToolCall
Users []UserMsg
// Injected is the event key each `user/message` record that DSH wrote
// itself would have been stored under (instructions, runtime context) —
// never imported now, and what the one-time cleanup of rows stored before
// that rule deletes. Read from the transcript, never guessed from text.
Injected []string
// contains filtered or unexported fields
}
Session is one DSH session transcript, parsed.
type Stats ¶
type Stats struct {
Sessions int `json:"sessions"`
Events int `json:"events"`
Unpriced int `json:"unpriced,omitempty"`
LastPoll int64 `json:"last_poll_ms,omitempty"`
}
Stats is what the daemon reports about DSH ingest.
type ToolCall ¶
type ToolCall struct {
At time.Time
Key string
Name string
// Input is the raw arguments JSON as recorded.
Input string
// TurnKey is the Key of the turn whose assistant message carries this
// call's tool-call block, matched by call id. Empty when none does.
TurnKey string
}
ToolCall is one tool invocation.
type Transcript ¶
Transcript is a session file found on disk, before parsing.
func List ¶
func List(dir string) ([]Transcript, error)
List returns every DSH session transcript under dir.
type Turn ¶
type Turn struct {
At time.Time
// Key is stable across re-reads: the transcript is append-only, so the seq
// of the record that produced the turn identifies it forever.
Key string
// Model is the per-turn model DSH recorded for this message.
Model string
In int64
Out int64
// CacheRead is the cached part of the prompt, billed at the cache-read
// rate. DSH reports it separately from fresh input, so no subtraction is
// needed — unlike Codex, whose input total embeds the cached part.
CacheRead int64
CacheWrite int64
// Reasoning tokens are billed as output and already included in Out;
// carried separately only so a reader can see the split.
Reasoning int64
// Text is the visible assistant prose, capped. Reasoning blocks are never
// stored (the same rule Claude's extended thinking is held to).
Text string
}
Turn is one assistant turn: its token usage (already reduced to a delta) and its visible prose, which powers the searchable Answers screen.