Documentation
¶
Overview ¶
Package ingest moves items captured outside Dibs (voice recordings, dictations) into Dibs as private draft ideas. A Source lists items since a time; the Ingester dedupes them against a Cursor file, applies a local submission budget, and submits each new one through a Sink (DibsSink, the Dibs MCP submit_idea tool).
Index ¶
Constants ¶
const ( // DefaultServer is the public Dibs origin. DefaultServer = "https://dibs.hivecommons.dev" // EnvToken holds the hub bearer token (preferred over --token, which is // visible in the process list). EnvToken = "DIBS_TOKEN" // EnvServer overrides the default --server. EnvServer = "DIBS_URL" )
const ( // DefaultSinceDays bounds how far back the first run looks. DefaultSinceDays = 7 // DefaultMaxPerHour and DefaultMaxPerDay match the intake budget per // identity (10/h, 30/24h). DefaultMaxPerHour = 10 DefaultMaxPerDay = 30 )
Variables ¶
var ErrRateLimited = errors.New("dibs: rate limited (HTTP 429)")
ErrRateLimited reports that Dibs (or a proxy in front of it) answered 429; the batch stops and resumes on the next run.
Functions ¶
Types ¶
type Cursor ¶
type Cursor struct {
Newest time.Time `json:"newest,omitzero"`
Seen map[string]time.Time `json:"seen"`
Submitted []time.Time `json:"submitted,omitempty"`
}
Cursor is the persisted ingest state: which items were already submitted (dedupe on the source's id), the newest item time (the next listing starts there, minus Ingester.Overlap), and recent submission times (rate budget).
func LoadCursor ¶
LoadCursor reads path; a missing file is an empty cursor.
type DibsSink ¶
type DibsSink struct {
// Endpoint is the Dibs MCP URL, e.g. https://dibs.hivecommons.dev/mcp.
Endpoint string
// Token is the hub bearer token. It is only ever sent in the
// Authorization header, never logged.
Token string
// Transport defaults to http.DefaultTransport.
Transport http.RoundTripper
}
DibsSink submits ideas with the Dibs MCP submit_idea tool (private draft owned by the token's identity).
type Flags ¶
type Flags struct {
// contains filtered or unexported fields
}
Flags are the flags every `dibs ingest <source>` command shares.
func AddFlags ¶
func AddFlags(fs *flag.FlagSet, source, unit, defaultTags string, getenv func(string) string) *Flags
AddFlags registers the shared flags on fs for `dibs ingest <source>`. unit names what the source lists (e.g. "recordings") in help text.
type Ingester ¶
type Ingester struct {
// Name labels log lines, e.g. "plaud".
Name string
// Open returns the Source for one run; when nil, Source is used.
Open func(ctx context.Context) (Source, error)
Source Source
Sink Sink
// CursorPath is the JSON state file (see Cursor).
CursorPath string
// Tags replace the tags of every idea.
Tags []string
SinceDays int
// Overlap re-lists this far behind the cursor, for items that were not
// ready (or not final) when they were first listed.
Overlap time.Duration
MaxPerHour int
MaxPerDay int
// MaxPerRun caps items handled in one run (0 = no cap).
MaxPerRun int
// DryRun builds and logs each idea without submitting it or advancing
// the cursor.
DryRun bool
Log *slog.Logger
Now func() time.Time
}
Ingester moves new items from a Source into Dibs.
func (*Ingester) Run ¶
Run calls RunOnce, then every interval until ctx is done. With interval <= 0 it runs once and returns that run's error. In loop mode a failed run is logged and retried on the next tick.
type Item ¶
type Item interface {
// ID is the source's stable id, used to dedupe across runs.
ID() string
// When is the item's capture time (zero if unknown).
When() time.Time
// Idea renders the idea; an error skips the item for this run only.
Idea(ctx context.Context) (Idea, error)
}
Item is one candidate idea listed by a Source.
type Result ¶
type Result struct {
Submitted int
Skipped int
// Planned counts ideas that a dry run would have submitted.
Planned int
// BudgetExhausted is set when the local --max-per-hour/--max-per-day
// budget or the --max per-run cap stopped the batch.
BudgetExhausted bool
// RateLimited is set when Dibs answered HTTP 429.
RateLimited bool
}
Result summarizes one run.
type Source ¶
Source lists items captured at or after since. A Source that also implements io.Closer is closed at the end of each run.
type Watermarker ¶
Watermarker is an optional Source extension for sources that read and drop items that are not ideas (most Wispr Flow dictations). Watermark reports the newest capture time the last List call read, so the cursor moves past dropped items instead of re-reading them every run.