Documentation
¶
Overview ¶
Package store is refetch's local event log: one SQLite file with the hook handler's tool calls and the MCP server's fetch attempts. Nothing in it leaves the machine.
Index ¶
- Constants
- func NormalizeURL(raw string) (normalized, host string)
- func Path(dir string) string
- type Attempt
- type Store
- func (s *Store) Attempts(ctx context.Context, since time.Time) ([]Attempt, error)
- func (s *Store) Calls(ctx context.Context, since time.Time) ([]ToolCall, error)
- func (s *Store) Close() error
- func (s *Store) File() string
- func (s *Store) NeedsRender(ctx context.Context, host string, since time.Time, n int) (bool, error)
- func (s *Store) RecordAttempt(ctx context.Context, a Attempt) error
- func (s *Store) RecordCall(ctx context.Context, c ToolCall) error
- func (s *Store) Reset(ctx context.Context) error
- func (s *Store) Rollup(ctx context.Context, cutoff time.Time) error
- func (s *Store) Size() int64
- type ToolCall
Constants ¶
const ( CallStarted = "started" // PreToolUse seen, no post event yet CallOK = "ok" // returned page text CallFailed = "failed" // tool error, or a page the block detector flags CallRedirected = "redirected" // denied by another hook in favor of another tool (context-mode) CallDenied = "denied" // denied for any other reason )
Tool call outcomes.
const Retention = 180 * 24 * time.Hour
Retention is how long raw rows are kept before they are rolled into the daily table.
Variables ¶
This section is empty.
Functions ¶
func NormalizeURL ¶
NormalizeURL lowercases the scheme and host, drops user info, default ports, the query string and the fragment, and returns the URL and its host. A string that is not an absolute URL comes back as is.
Types ¶
type Attempt ¶
type Attempt struct {
Time time.Time
FetchID string // groups the attempts of one call
Via string // mcp or cli
URL string // normalized on write
Host string // set on write
Client string
Outcome string
Status int
Bytes int
Duration time.Duration
Error string // first 300 characters
}
Attempt is one step inside a fetch_page call (or refetch get).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an open events.db.
func Open ¶
Open opens or creates the database at path and applies the schema. It stays cheap enough for a hook; callers roll old rows up with Rollup.
func (*Store) NeedsRender ¶ added in v0.3.0
NeedsRender reports whether host's last n fetches since t were each read by the headless Chrome step ("headless") and by no HTTP client.
func (*Store) RecordAttempt ¶
RecordAttempt inserts one fetch attempt.
func (*Store) RecordCall ¶
RecordCall inserts a tool call, or updates the row with the same ToolUseID (a post event completing its PreToolUse record).
type ToolCall ¶
type ToolCall struct {
Time time.Time
SessionID string
ToolUseID string
Tool string
URL string // normalized on write
Host string // set on write
Outcome string
Error string // first 300 characters
CCVersion string // Claude Code version
}
ToolCall is one web-reading tool call seen by the hook handler.