/** * moe_package.ts — EvermindModelPackage: the portable, publishable AI artifact. * * This is the unit a creator publishes to the marketplace and a buyer downloads * and runs: a self-describing manifest (name, version, config, model card, * integrity checksum) bundled with the trained checkpoint into one `.evermind` * blob. It is the contract every downstream consumer (marketplace listing, * purchase entitlement, workflow generator) reads — define it once, here. * * Zero-dep and isomorphic: serialises via TextEncoder/TextDecoder, runs in the * browser (where models are trained) and in Node/Workers (where they execute). */ import { SharedExpertMoE } from "./moe_model.js"; import { EvermindLM } from "../lm/evermind_lm.js"; import { VideoRVQCodec } from "../codec/video_rvq.js"; /** The kinds of model an `.evermind` package can carry. */ export type EvermindModelType = "shared-expert-moe" | "evermind-lm"; /** Output modality. `text` (default) needs no codec; `video`/`image` bundle a VRQ codec. */ export type EvermindModality = "text" | "video" | "image"; /** Human-facing description published with the model (the "model card"). */ export interface EvermindModelCard { description: string; /** What it was trained on / intended for. */ trainingSummary?: string; /** SPDX id or free text (e.g. "MIT", "proprietary"). */ license?: string; author?: string; tags?: string[]; } /** Self-describing header for a published Evermind model. */ export interface EvermindModelManifest { schema: "evermind.model/1"; name: string; version: string; modelType: EvermindModelType; /** Output modality; absent ⇒ "text". Video/image also carry a `codec` section. */ modality?: EvermindModality; /** Flat numeric model config (the constructor args), serialised verbatim. */ config: Record; /** Total trainable scalar parameters (for sizing / pricing / display). */ paramCount: number; checkpointFormat: "MoE0" | "EVL0"; checkpointFp16: boolean; /** * Byte length of the checkpoint section — REQUIRED when a codec section follows * (so the reader knows where the checkpoint ends). Absent ⇒ checkpoint runs to * end-of-blob (the original text-only layout, still read verbatim). */ checkpointBytes?: number; /** 32-bit FNV-1a over the checkpoint bytes — integrity for download/purchase. */ checksum: number; /** Media codec section format (present for video/image packages). */ codecFormat?: "VRQ0"; /** 32-bit FNV-1a over the codec bytes — integrity for the bundled codec. */ codecChecksum?: number; card: EvermindModelCard; /** ISO timestamp, caller-supplied (the engine avoids Date for determinism). */ createdAt?: string; } export interface PackageMeta { name: string; version: string; card: EvermindModelCard; /** Store the checkpoint in fp16 (half the size). Default false. */ fp16?: boolean; createdAt?: string; } export interface ValidationResult { ok: boolean; errors: string[]; } /** * A trained model packaged for publishing: manifest + checkpoint. Build one with * {@link EvermindModelPackage.fromModel}, ship {@link toBlob}, and a buyer * reconstitutes it with {@link fromBlob} → {@link validate} → {@link loadModel}. */ export declare class EvermindModelPackage { readonly manifest: EvermindModelManifest; readonly checkpoint: ArrayBuffer; /** Serialized media codec ("VRQ0" blob), present for video/image packages. */ readonly codec?: ArrayBuffer | undefined; constructor(manifest: EvermindModelManifest, checkpoint: ArrayBuffer, /** Serialized media codec ("VRQ0" blob), present for video/image packages. */ codec?: ArrayBuffer | undefined); /** Package a trained model with its publishing metadata. */ static fromModel(model: SharedExpertMoE, meta: PackageMeta): EvermindModelPackage; /** Package a trained generative {@link EvermindLM} — the runnable marketplace AI. */ static fromLM(lm: EvermindLM, meta: PackageMeta): EvermindModelPackage; /** * Package a video/image generative model: its {@link EvermindLM} weights AND the * {@link VideoRVQCodec} needed to turn generated tokens back into frames. Without * the bundled codec a served media model would emit undecodable token ids — this * is what makes an `.evermind` media artifact self-contained and servable. */ static fromMediaLM(lm: EvermindLM, codec: VideoRVQCodec, meta: PackageMeta & { modality: "video" | "image"; }): EvermindModelPackage; /** Serialise to a single `.evermind` blob: magic, version, manifest, checkpoint[, codec]. */ toBlob(): ArrayBuffer; /** Parse a `.evermind` blob. Throws on bad magic / truncation. */ static fromBlob(buffer: ArrayBuffer): EvermindModelPackage; /** Verify integrity + structural sanity before trusting a downloaded package. */ validate(): ValidationResult; /** Reconstruct the bare MoE layer. Validates first; throws if invalid / wrong type. */ loadModel(): SharedExpertMoE; /** Reconstruct the runnable generative model — what a marketplace buyer runs. */ loadLM(): EvermindLM; /** * Reconstruct a video/image model: the generative {@link EvermindLM} plus its * {@link VideoRVQCodec}. Pair with `generateVideo` / `generateImage` to produce * frames. This is what a media-serving path (gateway) loads and runs. */ loadMediaLM(): { lm: EvermindLM; codec: VideoRVQCodec; modality: EvermindModality; }; } //# sourceMappingURL=moe_package.d.ts.map