Documentation
¶
Overview ¶
Package inject runs inside agent hooks and returns the context MemSpace adds to the conversation: a card for unfinished work at session start and related history when the user submits a prompt.
Hooks are latency-sensitive and must never break the agent: every server call has a tight deadline, nothing is attempted while the client knows it is offline, and failures simply mean no injection. Session-start context falls back to a recent local cache when the server cannot be reached.
Index ¶
Constants ¶
const Hint = "" /* 236-byte string literal not displayed */
Hint is injected at session start when there is no unfinished work, so the agent knows the tools exist.
Variables ¶
var ( SessionStartTimeout = 2 * time.Second PromptTimeout = 1500 * time.Millisecond CacheMaxAge = 24 * time.Hour )
Deadlines for the server call; agents wait for these hooks.
Functions ¶
Types ¶
type Config ¶
type Config struct {
ServerURL string
Token string
StateDir string
Agent string // agent_type, e.g. claude-code
Offline bool // the client is backing off after failed syncs
MCP bool // the MCP server is registered (the hint names its tools)
// StartWithFirstPrompt adds the session-start context to the first
// prompt of a session, for agents whose SessionStart hook cannot.
StartWithFirstPrompt bool
// MarkerDir holds per-session markers (context already delivered);
// default StateDir. DSH runs hooks in a sandbox that can write only to
// the workspace and temporary directories.
MarkerDir string
// ProjectDir, when set, identifies the project instead of the hook's
// cwd: the directory the session was started in.
ProjectDir string
// Notice, when set, returns a line for the user (e.g. a failed client
// upgrade) to put first in the session-start context; "" for none.
Notice func() string
HTTP *http.Client
}
Config is what a hook needs to fetch context.