deepseek

package
v0.99.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Agent = "deepseek"

Agent is the value written to sessions.agent for DeepSeek Harness sessions.

View Source
const EnvDir = "CAPROCK_DSH_DIR"

EnvDir overrides the sessions root, for tests and anyone whose DSH home lives somewhere unusual.

View Source
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

View Source
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

func NewIngester(dir string, rec *rollup.Recorder, log *slog.Logger, every time.Duration) *Ingester

NewIngester builds an ingester over a DSH sessions directory.

func (*Ingester) Run

func (in *Ingester) Run(ctx context.Context) error

Run polls until the context is cancelled, importing once immediately so a fresh daemon shows history straight away rather than after the first tick.

func (*Ingester) Stats

func (in *Ingester) Stats() Stats

Stats returns a snapshot of what has been imported.

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.

func ParseFile

func ParseFile(path string) (*Session, error)

ParseFile decodes one transcript into a Session.

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

type Transcript struct {
	Path     string
	Modified time.Time
	Size     int64
}

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.

type UserMsg

type UserMsg struct {
	At   time.Time
	Key  string
	Text string
}

UserMsg is one user prompt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL