Records
kit.crawl and crawlOne return one final record per URL invocation, after any
internal browser retries. The CLI persists those results for crawl and batch.
Record_ shape
type Record_ = {
ts: string
url: string
finalUrl?: string
tier: string
verdict: string
reason: string
ms: number
attempt?: number
status?: number
data?: any
error?: string
meta?: Record<string, any>
}| Field | Meaning |
|---|---|
ts | ISO timestamp when the record is constructed. |
url | Requested URL. |
finalUrl | HTTP final URL or accepted browser location when available; some paths use the requested URL. |
tier | Execution/extraction path, a string rather than a closed union. |
verdict | Classification; typed as string in Record_, although the classifier uses Verdict below. |
reason | Human-readable classification detail. |
ms | Elapsed invocation time including pacing, retries and solver work. |
attempt, status | Optional top-level fields supported by the type. The generic crawler writes these inside meta instead. |
data | Auto extraction, selector object/rows, JavaScript/JSON result, site-plugin data, or null. HTTP JSON is wrapped as { json: parsedValue }. |
error | Final browser exception message, truncated to 300 characters. |
meta | Free-form diagnostics and plugin additions. |
Verdicts
type Verdict = 'ok' | 'empty' | 'blocked' | 'challenge' | 'tarpit' | 'unknown'
type Detection = { verdict: Verdict; reason: string; matched?: string }| Verdict | Meaning in the implementation |
|---|---|
ok | Structured content, a short rendered page, or acceptable substantial HTTP content. Counted as success. |
empty | Blank/thin body or recipe emptyPattern; may be a shell that never mounted. The CLI also uses it for a missed ad-hoc selector. Not counted as blocked. |
blocked | HTTP 401/403/407/429, recognized block text, or recipe/site override. |
challenge | Challenge-page marker, or a known captcha widget with sitekey and no filled response token. |
tarpit | Reserved verdict accepted as terminal by the ladder; the current generic detect function never emits it. Plugins can return it. |
unknown | No classification rule, HTTP 5xx, missing recipe expectation, exceptions or exhausted attempts without a terminal result. Not success. |
detect checks status and challenge/strong block markers before accepting
hasData. Ambiguous block markers apply to bodies under 4000 characters.
Without structured data, visible text under 80 characters is empty unless the
caller marks the page rendered. shouldEscalate returns true for blocked,
challenge and empty; isTerminal accepts ok and tarpit. The crawl loop also
retries unknown results.
Tiers
| Tier | Produced by |
|---|---|
http | Accepted plain HTTP HTML or JSON. |
browser | Accepted auto extraction, exhausted nonterminal attempts or a final exception. |
browser:auto | Empty final attempt with auto extraction. |
browser:selectors | Selector extraction. |
browser:js | Recipe JavaScript expression. |
browser:json | Parsed browser body JSON. |
browser:auto-fallback | Empty selectors degraded to automatic extraction. |
plugin:<name> | Default tier for a site plugin that does not supply one. |
ui | The shipped REPUVE site plugin. |
| Any site/plugin-supplied string | PluginSite permits an arbitrary tier; record hooks can replace records. |
There is no separate interaction tier emitted by the generic crawler: recipe
fill/submit still uses a browser tier. The final nonterminal return uses
browser, even if extraction used another mode.
Metadata
| Key | Generic crawler value |
|---|---|
status | HTTP response status, on accepted HTTP records. |
attempt | Browser attempt number on accepted, final empty or exception records. Not present on every exhausted-attempt result. |
matched | Classifier marker when supplied by Detection. |
plugin | Site plugin name on a takeover result. |
solved | Solver result's via, or solver, on accepted browser records after a returned solver result. |
The current crawler sets solved and re-extracts for any returned SolveResult,
even skipped/failed. Read the verdict and reason as well; meta.solved alone
does not verify a successful solve. No solver cost, token or duration is copied
into generic record metadata. Plugins may add arbitrary fields through record
hooks; successful HTTP returns bypass those hooks.
JSONL output and Store
The CLI creates a new file under the process working directory:
kitsune-results/crawl-<stamp>-<uuid>.jsonl or
kitsune-results/batch-<stamp>-<uuid>.jsonl. Stamp is an ISO timestamp with
colons and periods replaced by hyphens. Root bun run kitsune delegates with
--cwd packages/kitsune, so its output is under packages/kitsune/kitsune-results.
Direct bun packages/kitsune/src/cli.ts ... from the root writes under the root.
Each final URL result is appended as one JSON line and flushed immediately.
Internal retries do not each produce a line. Each run opens a unique file;
kit.crawl alone does not write JSONL. probe, sites, plugins and doctor
print diagnostics; init writes a recipe instead.
import { Store, type Record_ } from 'kitsune'
async function save(record: Record_) {
const store = await Store.open('kitsune-results', 'custom')
try {
await store.write(record)
} finally {
await store.close()
}
console.log(await store.summary())
}| Signature | Behavior |
|---|---|
Store.open(dir: string, label?: string): Promise<Store> | Default label run; creates an empty unique JSONL file, then opens a writer. |
write(r: Record_): Promise<void> | Appends and flushes one JSON line. |
close(): Promise<void> | Ends the writer. |
summary() | Async recomputation from readonly file: string, with the shape below. |
// Return type of summary():
type SummaryResult = Promise<{
total: number
byVerdict: Record<string, number>
byTier: Record<string, number>
byHost: Record<string, { ok: number; total: number }>
avgMs: number
rejectionRate: number
}>Summary ignores malformed JSON when accumulating values, but total counts all
nonempty lines. Rejection rate is (blocked + challenge) / total * 100, rounded
to one decimal; average milliseconds is rounded to an integer. Only ok counts
in each host's success total.
Crawl record fields, verdicts, tiers, metadata and JSONL persistence.