@openkarta/spec
v0.1.0
Published
OpenKarta protocol schemas, types, and narrowing helpers
Readme
@openkarta/spec
OpenKarta protocol schemas — Zod-first. Ships TypeScript types and runtime validators for:
- Five item types:
ProductItem,StayItem,FlightItem,BusItem,ServiceItem, unified underItem(discriminated ontype). - Discriminated
SearchQueryandCartLine;Cartenforces homogeneity via.refine. Quote,Order,FulfilmentStatus(per-type state machines),Refund.CapabilitiesManifestv0.2 with per-type capability blocks (ProductCapabilities,StayCapabilities, …).- Closed-enum
ErrorCodewith deterministic HTTP status mapping (errorStatusFor). UserTokenPayloadandUSER_TOKEN_HEADER(x-openkarta-user-token) for human→agent delegation.
Install
pnpm add @openkarta/spec zodUsage
import { Item, isProduct } from '@openkarta/spec';
const parsed = Item.parse(payload);
if (isProduct(parsed)) {
// parsed is narrowed to ProductItem
}