@lovelace-ai/compute
v0.0.1
Published
Canonical Lattice Cloud compute types, catalog, and wire protocol
Downloads
286
Maintainers
Readme
@lovelace-ai/compute
Canonical Lattice Cloud compute catalog, protocol, metering, pricing, and client types.
Overview
This package is the shared compute contract for the Lattice gateway, developer portal, SDKs, and provider-facing code. It keeps task classes, runtime kinds, provider tiers, model catalog data, relay wire shapes, and metering units consistent across consumers. Use it when a boundary needs to agree on what a compute task is, how a provider advertises capability, how relay work is represented, or how usage should be priced and metered.
Import Surface
@lovelace-ai/computeexposes catalog helpers, task and modality schemas, relay protocol schemas, personal runtime protocol types, metering and pricing helpers, reputation scoring, revenue split helpers, and the Lattice Cloud client contract.- The package is a shared protocol library. Service startup, request routing, authentication, and persistence are owned by the gateway or consuming service.
- Prefer this package over duplicated protocol definitions in app, SDK, or platform-test code.
Usage
Protocol consumers should validate incoming or outgoing wire payloads at the service boundary and use the shared helpers for catalog normalization.
import {
RelayWorkSubmissionSchema,
canonicalizeModelName,
} from "@lovelace-ai/compute";
const work = RelayWorkSubmissionSchema.parse(await request.json());
const model = canonicalizeModelName("gpt-4o-mini");SDK consumers that need a typed client can use the exported Lattice Cloud client factory with explicit base URL and credential configuration.
Public API
The public API is the compute protocol. It covers catalog aliases, canonical task classes, provider relay messages, personal runtime messages, OpenAI-compatible chat shapes, usage meters, pricing, reputation, and revenue sharing. Any protocol change should update the gateway/service tests, SDK docs, and platform tests together because this package is the contract those surfaces share.
OpenAPI Contract
This package emits the canonical OpenAPI 3.1 document for the buyer-facing
Lattice Cloud API. The TypeScript, Python, and Rust SDKs generate their wire
cores from it. The gateway also merges it with generated gateway routes before
it serves /openapi.json and /docs, so Scalar and the SDKs read the same
compute contract without dropping public gateway callbacks. The document is
assembled from the Zod schemas in this package (buildOpenApiDocument and the
LATTICE_CONTRACT route manifest in src/contract.ts) and committed at
contract/openapi.json.
- Regenerate after changing the contract:
pnpm exec turbo run contract:emit --filter=@lovelace-ai/compute --concurrency=2. - Check for drift:
pnpm exec turbo run contract:check --filter=@lovelace-ai/compute --concurrency=2.
The document is a build artifact — never hand-edit contract/openapi.json.
Development
Run package typechecking from the repository root with
pnpm exec turbo run typecheck --filter=@lovelace-ai/compute --concurrency=2.
Run linting with
pnpm exec turbo run lint --filter=@lovelace-ai/compute --concurrency=2.
Run tests with
pnpm exec turbo run test --filter=@lovelace-ai/compute --concurrency=2 -- --maxWorkers=2.
Update this README when top-level usage, import boundaries, or package ownership changes. Use generated API documentation for symbol-level detail instead of duplicating export catalogs here.
Related Documentation
License
MIT
