Type Generation and Intent Indexing

We’re building the new approach. Fixed meta-tools, unlimited operations, interfaces presented as TypeScript. This month: the type generator and the semantic search infrastructure.

TypeScript Type Generation

The schema compiler generates TypeScript declarations from JSON Schema—not mechanical transliteration, but the types a human would write. Discriminated unions from oneOf with discriminator properties. Eliminated impossible intersections from allOf combinations. Proper handling of optional properties vs nullable types. Clean inline types for simple schemas, named references for complex ones.

Type AST Optimization

The generator operates on an intermediate AST before emitting TypeScript. Three passes run until fixedpoint: Expand inlines type references so LLMs see actual structure. Reduce simplifies expressions—flattens nested unions, eliminates redundant constraints, removes never branches, deduplicates members. Normalize establishes consistent ordering for deterministic output.

Naive schema-to-type mapping produces technically correct but practically useless types. The optimization pipeline produces what a human would write: {name: string} | null instead of ({name?: string} & {name: string}) & ({} | null).

Keyword-Driven Type Generation

The keyword-centric architecture from December pays off. Adding type generation required no changes to core schema processing. Each keyword learned to generate its own TypeScript representation—type emits primitives, properties emits object members, allOf emits intersections. The generator traverses schemas exactly like validation does, but each keyword contributes types instead of errors.

Intent Phrase Generation

Operations indexed by intent—what they accomplish, not just their names. “Send an email” finds the right operation across different APIs even if they call it different things. A frontier model sees each operation’s synthesized TypeScript interface, documentation, and related operations, then generates natural language phrases capturing distinct reasons an agent might search for that operation. Semantic distillation: expensive comprehension amortized into phrases optimized for fast similarity matching.

Vector Indexing

Intent phrases embed into Cloudflare Vectorize for semantic similarity search. Query deduplication retrieves highest-scoring intent per operation. Metadata indexing on service name, operation name, intent ID, and phrase.

Batch Processing

OpenAI Batch API for cost-efficient intent generation. Two-stage pipeline: HTTP endpoint validates and enqueues, Durable Object processes in chunks. Lifecycle tracking with scheduled polling and exponential backoff.

Operation Metadata

Per-operation metadata indexed for efficient retrieval: method, path, servers, authentication schemes, tags. TypeScript signature generation per operation. Full-text search via FTS5.