npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@novaproto/contracts

v0.2.0

Published

Canonical AI-provider contracts (chat, embeddings, models, health) shared by llamactl, sirius-gateway, and embersynth.

Readme

@novaproto/contracts

license MIT npm version runtime Node-portable TypeScript strict

One vocabulary for every AI provider. The Zod-validated contract layer every gateway, agent harness, and operator surface otherwise re-derives.

Schemas for chat, embeddings, models, streaming, health, usage, and pricing — plus the AiProvider interface and an OpenAI-compatible adapter factory.

This is the SDK core of Nova. It carries zero runtime logic of its own beyond zod (dependencies: { zod: ^4.3.6 }): schemas for the types that cross the wire, TypeScript interfaces for the runtime abstractions, and one concrete adapter factory for the OpenAI REST dialect. Implement AiProvider once; route, bill, observe, and proxy everywhere.

Install

npm install @novaproto/contracts
# or: bun add @novaproto/contracts

Range in package.json: "@novaproto/contracts": "^0.1.0".

What it gives you

Each capability below is backed by a real export from src/ — no invented surface.

  • Canonical chat wire types — UnifiedAiRequestSchema / UnifiedAiResponseSchema (+ inferred UnifiedAiRequest / UnifiedAiResponse), ChatMessageSchema, ContentBlockSchema (discriminated union of text / image_url / input-audio blocks), ToolSchema, ToolCallSchema, ToolChoiceSchema, ResponseFormatSchema (text / json_object / json_schema), RoleSchema, FinishReasonSchema, UsageSchema.
  • Streaming events — UnifiedStreamEventSchema, a discriminated union of chunk / tool_call / error / done, with tool-call delta preservation (UnifiedStreamChunkSchema, StreamChoiceSchema, StreamDeltaSchema).
  • Execution events — ExecutionEventV1Schema, one accepted execution attempt as accepted → content → exactly one terminal, with request and attempt identity and a gap-free sequence on every event. Content wraps the canonical chunk / tool_call stream events; the terminal is completed (requires completion: "upstream"), cancelled, failed (typed ExecutionErrorCodeSchema code) or unknown-outcome, and always carries a UsageObservationV1. validateExecutionEventSequence, or stepExecutionSequence + finishExecutionSequence for a live stream, returns typed violations. Golden fixtures: test/fixtures/execution-event-v1/.
  • Embeddings — UnifiedEmbeddingRequestSchema / UnifiedEmbeddingResponseSchema, EmbeddingRowSchema; string / array / token-array input union, encoding_format, dimensions.
  • Models catalog — ModelInfoSchema, ModelListResponseSchema, ModelCapabilitySchema, ModelCostSchema.
  • Health — ProviderHealthSchema, ProviderHealthStateSchema (healthy / degraded / unhealthy / unknown).
  • Usage record — UsageRecordSchema and UsageKindSchema. Privacy lock by construction: it records token counts, not content.
  • Pricing — ModelPricingSchema, ProviderPricingSchema, and the PricingCatalog type (Map<string, ProviderPricing>).
  • Retrieval (RAG) — SearchRequest / SearchResponse, StoreRequest / StoreResponse, DeleteRequest / DeleteResponse, ListCollectionsResponse, DocumentSchema, SearchResultSchema, CollectionInfoSchema. Score is cosine similarity normalized 0..1.
  • Runtime abstractions (TypeScript interfaces, not Zod) — AiProvider (createResponse, optional streamResponse / createEmbeddings / listModels / healthCheck), RetrievalProvider, ProviderFactory / ProviderFactoryInput, ProviderRegistry.
  • OpenAI-compat adapter factory — createOpenAICompatProvider(opts): AiProvider. Covers non-streaming and SSE streaming (content + tool-call deltas), embeddings, listModels, and healthCheck; fires an onUsage hook after each successful call; strips Nova-only capabilities / providerOptions before going on the wire. Also exports mergeRequestHeaders, OpenAICompatUsageSnapshot, OpenAICompatOnUsage.

Example

Build a provider for any OpenAI-compatible upstream — OpenAI itself, Together, groq, Mistral, or a local llama-server:

import { createOpenAICompatProvider } from "@novaproto/contracts";

const provider = createOpenAICompatProvider({
  name: "together",
  baseUrl: "https://api.together.xyz/v1",
  apiKey: process.env.TOGETHER_API_KEY!,
});

const res = await provider.createResponse({
  model: "meta-llama/Llama-3.3-70B-Instruct",
  messages: [{ role: "user", content: "hello" }],
});

console.log(res.choices[0].message.content, res.latencyMs, res.provider);

OpenAICompatOptions fields: name, displayName?, baseUrl, apiKey, fetch?, extraHeaders?, healthPath? (default /models), onUsage?.

The adapter is kept deliberately thin — no retry loop, no failover, no logging. Those belong in the orchestrator that composes providers. To persist usage, wire the onUsage hook to the JSONL sink in @novaproto/mcp-shared.

Node-portable

The package has no bun:* or Bun.* dependencies — it runs on plain Node.js and on Bun alike. It builds to dist/src/*.js + .d.ts via tsc --build, and main / types point at the compiled JavaScript. Bun is the monorepo's dev and CI runtime only; consumers are not required to adopt it.

License

MIT — part of the Nova monorepo. See the root README for the sibling packages @novaproto/mcp-shared and @novaproto/mcp, and the architecture overview.