mlx-bun library API
    Preparing search index...

    Models and adapters known locally: the Hugging Face cache, the app's model and adapter directories, and outputs modules register.

    interface ModelCatalog {
        canPublish(): boolean;
        download(
            id: string,
            options?: {
                onProgress?: DownloadProgress;
                revision?: string;
                signal?: AbortSignal;
            },
        ): Promise<CatalogEntry>;
        downloads(): readonly DownloadRow[];
        estimate(id: string): Promise<{ residentBytes: number } | undefined>;
        find(query: string): Promise<CatalogEntry>;
        list(filter?: CatalogFilter): Promise<readonly CatalogEntry[]>;
        locate(selection: FolderSelection): Promise<LocatedFolder | undefined>;
        pickDefault(options?: { signal?: AbortSignal }): Promise<CatalogEntry>;
        publish(
            directory: string,
            request: PublishRequest,
        ): Promise<{ url: string }>;
        register(directory: string, kind: CatalogKind): Promise<CatalogEntry>;
        rescan(): Promise<number>;
        resolve(id: string): Promise<CatalogEntry | undefined>;
        startDownload(id: string): void;
    }
    Index
    • Fetches a model into the hub cache (resumable, verified) and indexes it; the signal stops it between checkpoints. revision is a git revision (default main).

      Parameters

      • id: string
      • Optionaloptions: { onProgress?: DownloadProgress; revision?: string; signal?: AbortSignal }

      Returns Promise<CatalogEntry>

    • Bytes the model needs resident, for residency plans.

      Parameters

      • id: string

      Returns Promise<{ residentBytes: number } | undefined>

    • The model a verb runs on when the user names none: this host's automatic choice (the preferred model when it fits the machine, else the largest that leaves room for other apps; an empty cache fetches a starter first). Rejects when none fits or the host makes no such choice.

      Parameters

      • Optionaloptions: { signal?: AbortSignal }

      Returns Promise<CatalogEntry>

    • Re-indexes the Hub cache and the app's model directory without reading tensor bytes; resolves to the snapshots indexed. Publishes catalog.changed.

      Returns Promise<number>

    • Starts a download that outlives the caller (the web's) and returns at once; progress is downloads(). Throws a CatalogError coded duplicate-download while the repo already has one running, and not-supported on a host that owns none. Publishes catalog.changed when it completes.

      Parameters

      • id: string

      Returns void