Adapter interface reference
The API accepts a readonly array of FeatureAdapter objects. The reader accepts a readonly array of UiAdapter objects. Each contribution is optional. The declarations below come directly from the two interface files.
API contract
Section titled “API contract”api/src/adapters/registered.ts exports adapters: readonly FeatureAdapter[]. Give each newsletter a unique subtype matching ^[a-z][a-z0-9_]*$. The registry looks up newsletters by exact subtype and crawlers by the first matching URL handler. Choose distinct prompt keys, library kinds and recap IDs across registrations.
api/src/adapters/types.ts
import type { Hono, MiddlewareHandler } from "hono";import type { LibraryResource } from "../lib/mcpLibraryResources.js";
export interface CrawlerHandler { matches(url: string): boolean; schema: object; read(url: string, previous: Record<string, unknown> | null): Promise<{ data: object; changeHtml(): string; }>;}
interface RouteGuards { requireAuth: MiddlewareHandler; requireCron: MiddlewareHandler;}
/** Trusted, build-time extensions. Request data never registers an adapter. */export interface FeatureAdapter { tickers?: Array<{ symbol: string; label: string; type: string }>; recap?: { id: string; title: string; emoji: string; prompt(episodeRules: string): string }; suppliedPhotos?: { section: string; fallbackTitle: string }; recapRules?: RecapRule[]; newsletter?: { subtype: string; icon: string; sourceLabel: string; libraryLabel: string; toolHelp: string }; prompts?: Record<string, string>; crawler?: CrawlerHandler; library?: Array<{ resource: LibraryResource; searchColumns: string[] }>; contentRoutes?(router: Hono, guards: RouteGuards): void; storyRoutes?(router: Hono, guards: RouteGuards): void;}
interface RecapArticle { image_url?: string; recap_section?: string;}
export interface RecapRule { heading: string; prompt: string; matches(article: RecapArticle): boolean; matchesEvaluation?(article: RecapArticle): boolean;}newsletterprovides the subtype, icon and MCP text. Register its queue consumer viacontentRoutes. Registered subtypes are excluded from chronological article search and story clustering.crawler.readreceives the URL and previous snapshot (ornull). Return the new structured data and a function that renders its change report. Escape text before including it in HTML.librarytakes fixedLibraryResourceprojections fromapi/src/lib/mcpLibraryResources.ts. Scope the record and each joined parent to the token owner. Choose explicit fields, title, parent IDs and required scopes. For searchable records, supplysearchColumnsmatching the database index. A list/fetch-only resource setssearchable: falseand supplies an empty list of columns.contentRoutesandstoryRoutesreceive a Hono router and the two middleware functions shown above. Apply the appropriate guard to every route.prompts,tickersandrecapsupply installation defaults.recapRulesselect instructions for matching articles, with an optional evaluation predicate.suppliedPhotosidentifies the recap section that can contribute validated photos from Agent News reports.
Reader contract
Section titled “Reader contract”src/adapters/registered.ts exports adapters: readonly UiAdapter[]. Use the API’s newsletter subtype and a distinct sidebar key. Keep identifiers stable across builds so saved feeds, preferences and recap schedules continue to resolve.
src/adapters/types.ts
import type { AIFeatureConfig } from "@/lib/preferencesApi";import type { ComponentType, ReactNode } from "react";import type { Article, Tag } from "@/types/rss";import type { DeepHandlerDef } from "@/lib/feedCustomizations";
export interface FeedViewProps { feedId: string; articles: Article[]; tags: Tag[]; loading: boolean; selectedArticleId: string | null; onSelectArticle: (id: string) => void; onToggleStar: (id: string) => void; hasMore?: boolean; onLoadMore?: () => void; loadingMore?: boolean;}
export interface NewsletterView { subtype: string; nav: { key: string; label: string; emoji: string }; Icon: ComponentType<{ className?: string }>; emptyText: string; View: ComponentType<FeedViewProps>; Add: ComponentType<{ onClose(): void; onFeedAdded(): void }>; catalog: DeepHandlerDef; prompt: { id: string; label: string; description: string; fallback: string; help: ReactNode };}
export interface UiAdapter { newsletter?: NewsletterView; tickers?: Array<{ symbol: string; label: string; type: string }>; legacyRecap?: { id: string; title: string; fallbackTitle: string; label: string; days: number[]; Icon: ComponentType<{ className?: string }>; feature(defaultModel: string): AIFeatureConfig; };}newsletter.nav,IconandemptyTextdescribe the sidebar and empty state.Addcreates a feed and notifies the parent.Viewreceives the selected feed’s article list, loading state and callbacks for selection, starring and pagination.newsletter.catalogis the settings catalog entry defined byDeepHandlerDefinsrc/lib/feedCustomizations.ts.promptsupplies the preference key, label, description, fallback text and help for AI settings.tickerssupplies initial watchlist entries.legacyRecapsupplies the identity, labels, icon, days and default feature configuration for a legacy edition. Align corresponding API and reader defaults.