Documentation
¶
Overview ¶
Package seaportal provides fast content extraction for AI agents. HTTP-first, no browser required.
This is the public API. All implementation lives in internal/.
Index ¶
- Constants
- Variables
- func CleanupMarkdown(md string) string
- func ContentChanged(oldContent, newContent string) bool
- func DetectBlocked(html string) bool
- func DetectSPA(html string) (signals []string, isSPA bool)
- func ExtractFromHTML(html string, targetURL string) (string, error)
- func FetchBytes(ctx context.Context, rawURL string, opts FetchBytesOptions) ([]byte, http.Header, int, error)
- func PreprocessHTML(html string) string
- func QuickNeedsBrowser(html string) (needsBrowser bool, reason string)
- func ResultToTEIXML(r Result) ([]byte, error)
- func SemanticFingerprint(content string) string
- type BrowserDecision
- type CardItem
- type Chunk
- type ChunkConfig
- type ChunkStrategy
- type DedupeOptions
- type DedupeResult
- type ExtractionOutcome
- type FeedItem
- type FetchBytesOptions
- type FlattenSitemapOptions
- type IndexPageResult
- type LinkRetention
- type Options
- type PageClass
- type PageProfile
- type ParseFeedOptions
- type RankedSection
- type Result
- func FromHTML(html string, targetURL string) Result
- func FromHTMLWithOptions(html string, targetURL string, opts Options) Result
- func FromResponse(resp *http.Response, targetURL string, start time.Time) Result
- func FromURL(targetURL string) Result
- func FromURLWithDedupe(targetURL string) Result
- func FromURLWithOptions(targetURL string, opts Options) Result
- type SecurityPolicy
- type SitemapEntry
- type SnapshotNode
- type SnapshotOptions
- type SplitConfig
- type SplitFile
- type Validation
Constants ¶
const ( // LinkRetentionAll keeps inline `[text](url)` as-is (default). LinkRetentionAll = engine.LinkRetentionAll // LinkRetentionNone strips both link text and URL. LinkRetentionNone = engine.LinkRetentionNone // LinkRetentionText keeps the link text, drops the URL. LinkRetentionText = engine.LinkRetentionText // numbered `⟨N⟩` markers and a `## References` section. LinkRetentionFooter = engine.LinkRetentionFooter )
const ( // ChunkOff disables chunking (default). ChunkOff = engine.ChunkOff // ChunkHeading splits at H2/H3 boundaries. ChunkHeading = engine.ChunkHeading // ChunkSentence groups sentences to a token target. ChunkSentence = engine.ChunkSentence // ChunkWindow slides a char window with overlap. ChunkWindow = engine.ChunkWindow )
const ( DecisionStaticHighConfidence = engine.DecisionStaticHighConfidence DecisionStaticOK = engine.DecisionStaticOK DecisionStaticCaution = engine.DecisionStaticCaution DecisionBrowserNeeded = engine.DecisionBrowserNeeded DecisionBlocked = engine.DecisionBlocked DecisionUnreachable = engine.DecisionUnreachable DecisionNotFound = engine.DecisionNotFound DecisionUnsupported = engine.DecisionUnsupported )
Browser-routing decisions. See docs/reference/browser-discriminator.md.
Variables ¶
var FlattenSitemap = engine.FlattenSitemap
FlattenSitemap fetches a sitemap URL and recursively flattens `<sitemapindex>` references into a single slice of SitemapEntry.
var ParseFeed = engine.ParseFeed
ParseFeed fetches a feed URL and parses it as RSS 2.0, Atom 1.0, or JSON Feed 1.x, returning a unified slice of FeedItem.
Functions ¶
func CleanupMarkdown ¶
CleanupMarkdown normalises whitespace and formatting in markdown.
func ContentChanged ¶
ContentChanged checks if content has changed based on fingerprints.
func DetectBlocked ¶
DetectBlocked checks if a page is blocked by bot protection.
func ExtractFromHTML ¶
ExtractFromHTML extracts markdown from raw HTML (simple interface).
func FetchBytes ¶
func FetchBytes(ctx context.Context, rawURL string, opts FetchBytesOptions) ([]byte, http.Header, int, error)
FetchBytes returns response bytes, headers, and status for rawURL.
func PreprocessHTML ¶
PreprocessHTML cleans HTML before extraction.
func QuickNeedsBrowser ¶
QuickNeedsBrowser checks if HTML likely needs a browser to render.
func ResultToTEIXML ¶
ResultToTEIXML wraps a Result into a TEI-Lite XML document.
func SemanticFingerprint ¶
SemanticFingerprint generates a content fingerprint for change detection.
Types ¶
type BrowserDecision ¶
type BrowserDecision = engine.BrowserDecision
BrowserDecision is the routing category exposed on Profile.Decision for callers (e.g. PinchTab) deciding whether to fall through to a real browser.
type Chunk ¶
Chunk is one piece of a chunked Markdown body.
func ChunkMarkdown ¶
func ChunkMarkdown(md string, cfg ChunkConfig) []Chunk
ChunkMarkdown returns Markdown chunks under cfg, or nil when off / too short.
type ChunkConfig ¶
type ChunkConfig = engine.ChunkConfig
ChunkConfig controls Markdown chunking.
func ParseChunkConfig ¶
func ParseChunkConfig(s string) (ChunkConfig, error)
ParseChunkConfig parses the CLI form "heading" / "sentence[:N]" / "window[:N[:O]]".
type ChunkStrategy ¶
type ChunkStrategy = engine.ChunkStrategy
ChunkStrategy selects a chunking algorithm.
type DedupeOptions ¶
type DedupeOptions = engine.DedupeOptions
DedupeOptions configures deduplication behaviour.
type DedupeResult ¶
type DedupeResult = engine.DedupeResult
DedupeResult holds content deduplication metrics.
func DedupeWithOptions ¶
func DedupeWithOptions(content string, opts DedupeOptions) DedupeResult
DedupeWithOptions removes duplicate content blocks with custom options.
type ExtractionOutcome ¶
type ExtractionOutcome = engine.ExtractionOutcome
ExtractionOutcome indicates whether content is usable or needs a browser.
type FeedItem ¶
FeedItem is a normalised feed entry across RSS 2.0, Atom 1.0, and JSON Feed 1.x sources.
type FetchBytesOptions ¶
type FetchBytesOptions = engine.FetchBytesOptions
FetchBytesOptions controls a raw network fetch with optional security checks.
type FlattenSitemapOptions ¶
type FlattenSitemapOptions = engine.FlattenSitemapOptions
FlattenSitemapOptions controls FlattenSitemap behaviour.
type IndexPageResult ¶
type IndexPageResult = engine.IndexPageResult
IndexPageResult holds index/listing page extraction results.
type LinkRetention ¶
type LinkRetention = engine.LinkRetention
LinkRetention controls how inline Markdown links are kept in extracted output.
func ParseLinkRetention ¶
func ParseLinkRetention(s string) (LinkRetention, error)
ParseLinkRetention parses a mode name ("none"|"text"|"all"|"footer").
type PageProfile ¶
type PageProfile = engine.PageProfile
PageProfile describes the classification of a page.
func ClassifyPage ¶
func ClassifyPage(result Result) PageProfile
ClassifyPage determines the page type from extraction results.
type ParseFeedOptions ¶
type ParseFeedOptions = engine.ParseFeedOptions
ParseFeedOptions controls ParseFeed behaviour.
type RankedSection ¶
type RankedSection = engine.RankedSection
RankedSection is a BM25-scored, heading-bounded slice of Markdown.
func RankSections ¶
func RankSections(content, query string, k1, b float64, topN int) []RankedSection
RankSections scores Markdown sections (H2/H3-bounded) by BM25 against the query and returns them in descending score order. topN > 0 truncates; defaults k1=1.5, b=0.75 are applied when 0 is passed.
type Result ¶
Result holds the extraction output for a URL.
func FromHTMLWithOptions ¶
FromHTMLWithOptions extracts content from raw HTML with custom options.
func FromResponse ¶
FromResponse extracts content from an HTTP response.
func FromURLWithDedupe ¶
FromURLWithDedupe extracts content with deduplication enabled.
func FromURLWithOptions ¶
FromURLWithOptions extracts content from a URL with custom options.
type SecurityPolicy ¶
type SecurityPolicy = engine.SecurityPolicy
SecurityPolicy is the opt-in SSRF / private-IP / redirect / decompression guard threaded through the fetch path. Set it on Options.Security. A nil policy keeps the historical unguarded behaviour.
func DefaultSecurityPolicy ¶
func DefaultSecurityPolicy() *SecurityPolicy
DefaultSecurityPolicy returns the recommended secure-by-default policy: block private/internal IPs, http/https only, a 10-redirect cap with per-hop revalidation, and 50 MiB raw / 200 MiB decompressed body caps.
type SitemapEntry ¶
type SitemapEntry = engine.SitemapEntry
SitemapEntry is a single URL entry flattened from a sitemap.
type SnapshotNode ¶
type SnapshotNode = engine.SnapshotNode
SnapshotNode is a node in the accessibility snapshot tree.
func BuildSnapshot ¶
func BuildSnapshot(htmlStr string) (*SnapshotNode, error)
BuildSnapshot creates an accessibility tree from HTML.
func BuildSnapshotWithOptions ¶
func BuildSnapshotWithOptions(htmlStr string, opts SnapshotOptions) (*SnapshotNode, error)
BuildSnapshotWithOptions creates an accessibility tree with custom options.
type SnapshotOptions ¶
type SnapshotOptions = engine.SnapshotOptions
SnapshotOptions controls accessibility snapshot generation.
type SplitFile ¶
SplitFile is one entry in the SplitResultToFiles manifest.
func SplitResultToFiles ¶
func SplitResultToFiles(r Result, cfg SplitConfig) ([]SplitFile, error)
SplitResultToFiles writes the Result's content split across multiple files under cfg.Dir and returns the manifest.
type Validation ¶
type Validation = engine.Validation
Validation holds extraction quality validation results.
func ValidateExtraction ¶
func ValidateExtraction(r *Result) Validation
ValidateExtraction assesses extraction quality.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
seabench
command
Command seabench is the SeaPortal benchmark / evaluation harness.
|
Command seabench is the SeaPortal benchmark / evaluation harness. |
|
seaportal
command
|
|
|
internal
|
|
|
engine
Package portal provides content extraction with SPA detection
|
Package portal provides content extraction with SPA detection |
|
engine/leakcheck
Package leakcheck provides a test helper that fails a Go test when it finishes with more live goroutines than it started with.
|
Package leakcheck provides a test helper that fails a Go test when it finishes with more live goroutines than it started with. |
|
engine/mock
Package mock provides a record/replay HTTP RoundTripper layer for tests that exercise the engine's HTTP-fetch paths without paying real-network latency or flakiness costs.
|
Package mock provides a record/replay HTTP RoundTripper layer for tests that exercise the engine's HTTP-fetch paths without paying real-network latency or flakiness costs. |
|
mcp
Package mcp implements a minimal Model Context Protocol (MCP) server over JSON-RPC 2.0 line-delimited stdio.
|
Package mcp implements a minimal Model Context Protocol (MCP) server over JSON-RPC 2.0 line-delimited stdio. |
|
quality
Package quality provides extraction quality analysis for markdown content.
|
Package quality provides extraction quality analysis for markdown content. |
|
testserver/fixture
Package fixture provides a declarative, in-process HTTP test server for per-test scenarios that exercise HTTP-level behaviour (status codes, redirects, slow responses, charset declarations, header echoes, etc.).
|
Package fixture provides a declarative, in-process HTTP test server for per-test scenarios that exercise HTTP-level behaviour (status codes, redirects, slow responses, charset declarations, header echoes, etc.). |