Documentation
¶
Overview ¶
Package daemon wires up and runs the Kram daemon's HTTP server — extracted out of cmd/daemon so the unified cmd/kram binary can start a daemon in-process (a goroutine, not a subprocess) instead of shelling out to a separate binary. Subpackages (store, session, agent, tools, server, gatewayclient, compaction) hold the actual logic; this is just the wiring cmd/daemon and cmd/kram both need.
Index ¶
Constants ¶
const TokenFileName = "daemon.token"
TokenFileName is the 0600 file, written next to the daemon's DB, that carries the per-process auth token. A standalone CLI reads it to attach to a running daemon; the single-binary cmd/kram threads the token in-process and only writes this for external attach/debugging.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Host string
Port int
DBPath string
GatewayURL string
Model string // gateway combo used for new messages
Workspace string // project root the agent's tools operate within
MaxTurns int // model calls per automatic continuation segment
// PreferStreaming threads through to agent.Config.PreferStreaming —
// see that field's own doc comment for the real tradeoff it accepts.
// This struct's own zero value (false) is buffered, matching
// agent.Config's own field; cmd/kram's -stream flag defaults to true
// at that call site so the live indicator's reasoning excerpt works
// out of the box, but can be turned off per deployment. The concrete
// reason an opt-out turned out to be necessary, not just
// theoretical: a large local model whose inference server sends
// nothing at all (not even a reasoning fragment) during prompt
// prefill trips router.BoundedPeek's fixed idle timeout well before
// the first token streams, failing every turn outright — buffered
// mode has no such window and works fine for the exact same setup.
PreferStreaming bool
// PromptProfile threads through to agent.Config.PromptProfile (#130)
// — "frontier" or empty for compact. cmd/kram derives it from the
// active combo's configured model names (see resolvePromptProfile);
// the standalone daemon takes it as a flag.
PromptProfile string
// AuthToken is the bearer token the daemon's HTTP surface requires on
// every route except /health (see server.New). Empty means Run
// generates a fresh random one at boot. The single-binary cmd/kram
// passes the same token it hands its in-process CLI, so the two agree
// without a file round-trip; either way Run writes the resolved token
// to a 0600 daemon.token file next to the DB so a standalone CLI can
// attach.
AuthToken string
// GatewayClientTimeout caps the whole HTTP call the daemon makes to the
// gateway. Zero means gatewayclient.DefaultTimeout. cmd/kram sets this
// to a value derived from the gateway config's provider timeout and
// longest fallback chain (config.Tunables.ResolvedGatewayClientTimeout),
// so the client never cuts off a legitimate multi-provider round.
GatewayClientTimeout time.Duration
// MaxContextTokens is the model context-window budget that governs when
// the agent loop compacts history. Zero falls back to
// compaction.DefaultMaxTokens (via agent.Config). cmd/kram derives it
// from the active combo's smallest provider context window
// (config.Config.ComboContextWindow), or the --max-context-tokens flag
// overrides both.
MaxContextTokens int
}
Config configures one daemon instance.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent is Kram's tool-calling loop: the piece that actually makes the daemon useful rather than a plain chat relay.
|
Package agent is Kram's tool-calling loop: the piece that actually makes the daemon useful rather than a plain chat relay. |
|
Package compaction keeps a long session's history within a model's context budget using the tiered strategy every production agent loop we looked at converges on (opencode, Crush): cheap structural pruning first, full LLM summarization only as a last resort.
|
Package compaction keeps a long session's history within a model's context budget using the tiered strategy every production agent loop we looked at converges on (opencode, Crush): cheap structural pruning first, full LLM summarization only as a last resort. |
|
Package contextpolicy turns Kram's context limits into one explicit plan.
|
Package contextpolicy turns Kram's context limits into one explicit plan. |
|
Package gatewayclient is the daemon's HTTP client for kram-gateway.
|
Package gatewayclient is the daemon's HTTP client for kram-gateway. |
|
Package server exposes the daemon's HTTP control surface: sessions are created, listed and messaged through here.
|
Package server exposes the daemon's HTTP control surface: sessions are created, listed and messaged through here. |
|
Package session owns session lifecycle (create/list/get) — the durable record a client attaches to.
|
Package session owns session lifecycle (create/list/get) — the durable record a client attaches to. |
|
Package store persists sessions and messages to a local SQLite database so the daemon remains the single source of truth across restarts — a client disconnecting, or the daemon itself being restarted, never loses a session's history, including its tool-call trail.
|
Package store persists sessions and messages to a local SQLite database so the daemon remains the single source of truth across restarts — a client disconnecting, or the daemon itself being restarted, never loses a session's history, including its tool-call trail. |
|
Package tools: grep is a pure-Go recursive search over the workspace — no dependency on an external ripgrep/grep binary being installed, in keeping with Kram's "never crash / always works" goal.
|
Package tools: grep is a pure-Go recursive search over the workspace — no dependency on an external ripgrep/grep binary being installed, in keeping with Kram's "never crash / always works" goal. |