import type { TensorRole, TensorSourceTransform } from '../formats/rdrr/index.js'; import type { ManifestEmbeddingPostprocessorSchema } from '../config/schema/index.js'; import type { RuntimeModelContract } from '../inference/runtime-model.js'; import type { SourceArtifactKind } from './source-artifact-adapter.js'; export declare const DIRECT_SOURCE_RUNTIME_MODE: 'direct-source'; export declare const DIRECT_SOURCE_RUNTIME_SCHEMA_VERSION: 1; export declare const DIRECT_SOURCE_RUNTIME_SCHEMA: 'direct-source/v1'; export declare const DIRECT_SOURCE_PATH_RUNTIME_LOCAL: 'runtime-local'; export declare const DIRECT_SOURCE_PATH_ARTIFACT_RELATIVE: 'artifact-relative'; export interface SourceRuntimeTensor { name: string; shape: number[]; dtype: string; size: number; offset: number; sourcePath: string; layout?: string | null; role?: TensorRole; group?: string | null; sourceTransform?: TensorSourceTransform | { kind: 'litert_rowwise_dequant'; scheme: 'per_row_affine'; sourceDtype: 'INT8' | 'UINT8' | 'INT4' | 'INT2'; targetDtype: 'F16'; storageEncoding: 'signed' | 'offset_binary'; scaleSemantics: 'step' | 'qmax_abs'; scaleDivisor?: number; scaleSourcePath: string; scaleOffset: number; scaleSize: number; rowSumSourcePath?: string; rowSumOffset?: number; rowSumSize?: number; } | { kind: 'litert_axis_dequant'; scheme: 'per_axis_affine'; sourceDtype: 'INT8' | 'UINT8' | 'INT4' | 'INT2'; targetDtype: 'F16'; storageEncoding: 'signed' | 'offset_binary'; scaleSemantics: 'step' | 'qmax_abs'; scaleDivisor?: number; storageShape: [number, number]; quantAxis: 0 | 1; scaleCompanionDtype?: 'UINT8'; scaleCompanionDequant?: { scale: number; zeroPoint: number; }; scaleSourcePath: string; scaleOffset: number; scaleSize: number; sumSourcePath?: string; sumOffset?: number; sumSize?: number; } | { kind: 'litert_axis_blocked_dequant'; scheme: 'per_axis_affine'; sourceDtype: 'INT8' | 'UINT8' | 'INT4' | 'INT2'; targetDtype: 'F16'; storageEncoding: 'signed' | 'offset_binary'; scaleSemantics: 'step' | 'qmax_abs'; scaleDivisor?: number; storageShape: [number, number]; quantAxis: 0; storageBlockSize: number; storageLaneOrder: number[]; scaleSourcePath: string; scaleOffset: number; scaleSize: number; sumSourcePath?: string; sumOffset?: number; sumSize?: number; } | null; } export interface SourceRuntimeFile { path: string; size: number; hash?: string | null; hashAlgorithm?: string | null; kind?: string | null; } export interface SourceRuntimeShardSource { index: number; path: string; filename: string; size: number; hash: string; hashAlgorithm: string; } export interface SourceRuntimeTokenizerMetadata { jsonPath: string | null; configPath: string | null; modelPath: string | null; } export interface SourceRuntimeMetadata { mode: 'direct-source'; schema: 'direct-source/v1'; schemaVersion: 1; sourceKind: SourceArtifactKind | 'rdrr' | null; hashAlgorithm: string; pathSemantics: 'runtime-local' | 'artifact-relative'; sourceFiles: SourceRuntimeShardSource[]; auxiliaryFiles: SourceRuntimeFile[]; tokenizer: SourceRuntimeTokenizerMetadata; } export interface BuildSourceRuntimeBundleOptions { modelId: string; modelName?: string | null; modelType: string; sourceKind?: SourceArtifactKind | 'rdrr' | null; architecture: Record | string | null; architectureHint?: string | null; rawConfig?: Record | null; manifestConfig?: { visionConfig?: Record | null; audioConfig?: Record | null; } | null; inference: Record; tensors: SourceRuntimeTensor[]; embeddingPostprocessor?: ManifestEmbeddingPostprocessorSchema | null; sourceFiles?: SourceRuntimeFile[] | null; auxiliaryFiles?: SourceRuntimeFile[] | null; resolveSourceSize?: ((path: string) => Promise | number) | null; sourceQuantization?: string | null; quantizationInfo?: Record | null; manifestQuantization?: string | null; hashAlgorithm?: string | null; tokenizerJson?: Record | null; tokenizerConfig?: Record | null; tokenizerModelName?: string | null; tokenizerJsonPath?: string | null; tokenizerConfigPath?: string | null; tokenizerModelPath?: string | null; eosTokenId?: number | number[] | null; convertedAt?: string | null; conversionInfo?: Record | null; } export interface BuildSourceRuntimeBundleResult { model: RuntimeModelContract; manifest: RuntimeModelContract; shardSources: SourceRuntimeShardSource[]; } export declare function buildSourceRuntimeBundle( options: BuildSourceRuntimeBundleOptions ): Promise; export declare function getSourceRuntimeMetadata( manifest: RuntimeModelContract | Record | null | undefined ): SourceRuntimeMetadata | null; export interface CreateSourceStorageContextOptions { model?: RuntimeModelContract | null; manifest?: RuntimeModelContract | null; shardSources?: SourceRuntimeShardSource[] | null; readRange: ( path: string, offset: number, length: number ) => Promise; streamRange?: ( path: string, offset: number, length: number, options?: { chunkBytes?: number } ) => AsyncIterable; readText?: (path: string) => Promise | null | undefined>; readBinary?: (path: string) => Promise; close?: (() => Promise) | null; tokenizerJsonPath?: string | null; tokenizerConfigPath?: string | null; tokenizerModelPath?: string | null; verifyHashes?: boolean; sourceHashesTrusted?: boolean; } export interface SourceStorageContext { preflight?: () => Promise; loadShard: (index: number) => Promise; loadShardRange: (( index: number, offset?: number, length?: number | null ) => Promise) | null; streamShardRange: (( index: number, offset?: number, length?: number | null, options?: { chunkBytes?: number } ) => AsyncIterable) | null; loadTokenizerJson: (() => Promise | null>) | null; loadTokenizerModel: ((pathHint?: string) => Promise) | null; loadAuxiliaryFile: ((path: string) => Promise) | null; loadTensorsJson?: (() => Promise | null>) | null; verifyHashes: boolean; close?: (() => Promise) | null; } export declare function createSourceStorageContext( options: CreateSourceStorageContextOptions ): SourceStorageContext;