Skip to content

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/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;
}
  • newsletter provides the subtype, icon and MCP text. Register its queue consumer via contentRoutes. Registered subtypes are excluded from chronological article search and story clustering.
  • crawler.read receives the URL and previous snapshot (or null). Return the new structured data and a function that renders its change report. Escape text before including it in HTML.
  • library takes fixed LibraryResource projections from api/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, supply searchColumns matching the database index. A list/fetch-only resource sets searchable: false and supplies an empty list of columns.
  • contentRoutes and storyRoutes receive a Hono router and the two middleware functions shown above. Apply the appropriate guard to every route.
  • prompts, tickers and recap supply installation defaults. recapRules select instructions for matching articles, with an optional evaluation predicate. suppliedPhotos identifies the recap section that can contribute validated photos from Agent News reports.

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, Icon and emptyText describe the sidebar and empty state. Add creates a feed and notifies the parent. View receives the selected feed’s article list, loading state and callbacks for selection, starring and pagination.
  • newsletter.catalog is the settings catalog entry defined by DeepHandlerDef in src/lib/feedCustomizations.ts. prompt supplies the preference key, label, description, fallback text and help for AI settings.
  • tickers supplies initial watchlist entries. legacyRecap supplies the identity, labels, icon, days and default feature configuration for a legacy edition. Align corresponding API and reader defaults.

Build a classifieds adapter · MCP tool discovery