import { E as EdgeworkOptions$1, a as GenerateOptions$1, G as GenerateResult, C as ChatMessage$1, M as Modality, b as ModalityInferenceResult, I as InferenceError, c as ModalityTrainingSignal, T as TrainingFlushResult, d as EngineInfo, D as DownloadProgress } from './base-storage-CfkDwX0r.js'; export { e as GradientEnvelope, f as InferenceBackend, g as InferenceEngine, h as InferenceErrorCode, K as KVCache, L as LayerWeights, i as ModelArchitecture, j as ModelManifest, k as ModelMeta, l as ModelStatus, m as ModelStorage, Q as QuantizationType, R as RLHFFeedback, S as StorageBackend, n as SyncProgress, o as SyncService, p as TensorChunk, q as TokenizerData, r as TrainingLogEntry, U as UserAdapter } from './base-storage-CfkDwX0r.js'; import { z } from 'zod'; export { IndexedDBStorage, MemoryStorage, OPFSStorage, StorageOptions, createStorage, detectBestBackend as detectBestStorageBackend } from './data/storage/index.js'; export { I as InferenceOptions, T as Tokenizer, W as WASMInference, a as WebGPUInference, c as createInferenceEngine, d as detectBestInferenceBackend, l as loadTokenizer } from './factory-CTQWNTae.js'; export { DEFAULT_SYNC_URLS, ModelSync, SyncOptions, createModelSync } from './data/sync/index.js'; export { FederatedSync, RLHFTrainer, RewardModel } from './compute/rlhf/index.js'; export { i as Auth } from './index-BRjPIr0_.js'; export { i as Gateway } from './index-CnOow4Yv.js'; export { i as Distributed } from './index-i7o3ADbK.js'; /** * Edgework SDK Zod Schemas * * Runtime validation schemas for SDK types. */ declare const ModelArchitectureSchema: z.ZodEnum<["llama", "mistral", "qwen", "smollm", "phi"]>; declare const QuantizationTypeSchema: z.ZodEnum<["f32", "f16", "q8_0", "q4_k", "q4_0", "q4_1"]>; declare const ModelMetaSchema: z.ZodObject<{ id: z.ZodString; name: z.ZodString; architecture: z.ZodEnum<["llama", "mistral", "qwen", "smollm", "phi"]>; version: z.ZodString; vocabSize: z.ZodNumber; hiddenDim: z.ZodNumber; numLayers: z.ZodNumber; numHeads: z.ZodNumber; numKvHeads: z.ZodOptional; intermediateDim: z.ZodOptional; maxSeqLength: z.ZodNumber; ropeTheta: z.ZodOptional; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }, { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }>; declare const TensorChunkSchema: z.ZodObject<{ id: z.ZodString; modelId: z.ZodString; tensorName: z.ZodString; layerIndex: z.ZodNullable; chunkIndex: z.ZodNumber; totalChunks: z.ZodNumber; dtype: z.ZodEnum<["f32", "f16", "q8_0", "q4_k", "q4_0", "q4_1"]>; shape: z.ZodArray; offset: z.ZodNumber; data: z.ZodType; hash: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; modelId: string; tensorName: string; layerIndex: number | null; chunkIndex: number; totalChunks: number; dtype: "f32" | "f16" | "q8_0" | "q4_k" | "q4_0" | "q4_1"; shape: number[]; offset: number; data: ArrayBuffer; hash: string; }, { id: string; modelId: string; tensorName: string; layerIndex: number | null; chunkIndex: number; totalChunks: number; dtype: "f32" | "f16" | "q8_0" | "q4_k" | "q4_0" | "q4_1"; shape: number[]; offset: number; data: ArrayBuffer; hash: string; }>; declare const TokenizerDataSchema: z.ZodObject<{ modelId: z.ZodString; vocab: z.ZodType; merges: z.ZodOptional>; specialTokens: z.ZodRecord; chatTemplate: z.ZodOptional; }, "strip", z.ZodTypeAny, { modelId: string; vocab: ArrayBuffer; specialTokens: Record; merges?: ArrayBuffer | undefined; chatTemplate?: string | undefined; }, { modelId: string; vocab: ArrayBuffer; specialTokens: Record; merges?: ArrayBuffer | undefined; chatTemplate?: string | undefined; }>; declare const SyncProgressSchema: z.ZodObject<{ modelId: z.ZodString; tensorName: z.ZodString; chunksDownloaded: z.ZodNumber; totalChunks: z.ZodNumber; lastSync: z.ZodOptional; }, "strip", z.ZodTypeAny, { modelId: string; tensorName: string; totalChunks: number; chunksDownloaded: number; lastSync?: string | undefined; }, { modelId: string; tensorName: string; totalChunks: number; chunksDownloaded: number; lastSync?: string | undefined; }>; declare const AdapterTypeSchema: z.ZodEnum<["reward_head", "style_adapter", "lora"]>; declare const UserAdapterSchema: z.ZodObject<{ id: z.ZodString; modelId: z.ZodString; userId: z.ZodString; adapterType: z.ZodEnum<["reward_head", "style_adapter", "lora"]>; weights: z.ZodType; trainingExamples: z.ZodNumber; lastUpdated: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; modelId: string; userId: string; adapterType: "reward_head" | "style_adapter" | "lora"; weights: ArrayBuffer; trainingExamples: number; lastUpdated: string; }, { id: string; modelId: string; userId: string; adapterType: "reward_head" | "style_adapter" | "lora"; weights: ArrayBuffer; trainingExamples: number; lastUpdated: string; }>; declare const TrainingLogEntrySchema: z.ZodObject<{ id: z.ZodNumber; adapterId: z.ZodString; messageHash: z.ZodString; feedback: z.ZodNumber; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: number; createdAt: string; adapterId: string; messageHash: string; feedback: number; }, { id: number; createdAt: string; adapterId: string; messageHash: string; feedback: number; }>; declare const DownloadStatusSchema: z.ZodEnum<["downloading", "verifying", "ready", "error"]>; declare const DownloadProgressSchema: z.ZodObject<{ modelId: z.ZodString; percent: z.ZodNumber; bytesDownloaded: z.ZodNumber; totalBytes: z.ZodNumber; currentLayer: z.ZodOptional; layersComplete: z.ZodNumber; totalLayers: z.ZodNumber; status: z.ZodEnum<["downloading", "verifying", "ready", "error"]>; error: z.ZodOptional; }, "strip", z.ZodTypeAny, { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }>; declare const StorageBackendSchema: z.ZodEnum<["opfs", "indexeddb", "memory"]>; declare const InferenceBackendSchema: z.ZodEnum<["webgpu", "webnn", "wasm", "cpu"]>; declare const EdgeworkOptionsSchema: z.ZodObject<{ model: z.ZodString; syncUrl: z.ZodOptional; onProgress: z.ZodOptional; layersComplete: z.ZodNumber; totalLayers: z.ZodNumber; status: z.ZodEnum<["downloading", "verifying", "ready", "error"]>; error: z.ZodOptional; }, "strip", z.ZodTypeAny, { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }>], z.ZodUnknown>, z.ZodVoid>>; enableRLHF: z.ZodDefault>; communityParticipation: z.ZodDefault>; federatedSyncUrl: z.ZodOptional; trainingBatchSize: z.ZodDefault>; trainingIdleFlushMs: z.ZodDefault>; cacheDir: z.ZodOptional; userId: z.ZodOptional; storageBackend: z.ZodOptional>; inferenceBackend: z.ZodOptional>; }, "strip", z.ZodTypeAny, { model: string; enableRLHF: boolean; communityParticipation: boolean; trainingBatchSize: number; trainingIdleFlushMs: number; userId?: string | undefined; syncUrl?: string | undefined; onProgress?: ((args_0: { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, ...args: unknown[]) => void) | undefined; federatedSyncUrl?: string | undefined; cacheDir?: string | undefined; storageBackend?: "opfs" | "indexeddb" | "memory" | undefined; inferenceBackend?: "webgpu" | "webnn" | "wasm" | "cpu" | undefined; }, { model: string; userId?: string | undefined; syncUrl?: string | undefined; onProgress?: ((args_0: { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, ...args: unknown[]) => void) | undefined; enableRLHF?: boolean | undefined; communityParticipation?: boolean | undefined; federatedSyncUrl?: string | undefined; trainingBatchSize?: number | undefined; trainingIdleFlushMs?: number | undefined; cacheDir?: string | undefined; storageBackend?: "opfs" | "indexeddb" | "memory" | undefined; inferenceBackend?: "webgpu" | "webnn" | "wasm" | "cpu" | undefined; }>; declare const GenerateOptionsSchema: z.ZodObject<{ maxTokens: z.ZodDefault>; temperature: z.ZodDefault>; topP: z.ZodDefault>; topK: z.ZodDefault>; stopSequences: z.ZodOptional>; stream: z.ZodDefault>; }, "strip", z.ZodTypeAny, { maxTokens: number; temperature: number; topP: number; topK: number; stream: boolean; stopSequences?: string[] | undefined; }, { maxTokens?: number | undefined; temperature?: number | undefined; topP?: number | undefined; topK?: number | undefined; stopSequences?: string[] | undefined; stream?: boolean | undefined; }>; declare const GenerateResultSchema: z.ZodObject<{ text: z.ZodString; tokens: z.ZodArray; tokenCount: z.ZodNumber; durationMs: z.ZodNumber; tokensPerSecond: z.ZodNumber; }, "strip", z.ZodTypeAny, { text: string; tokens: number[]; tokenCount: number; durationMs: number; tokensPerSecond: number; }, { text: string; tokens: number[]; tokenCount: number; durationMs: number; tokensPerSecond: number; }>; declare const ChatRoleSchema: z.ZodEnum<["system", "user", "assistant"]>; declare const ChatMessageSchema: z.ZodObject<{ role: z.ZodEnum<["system", "user", "assistant"]>; content: z.ZodString; }, "strip", z.ZodTypeAny, { role: "system" | "user" | "assistant"; content: string; }, { role: "system" | "user" | "assistant"; content: string; }>; declare const ChatMessagesSchema: z.ZodArray; content: z.ZodString; }, "strip", z.ZodTypeAny, { role: "system" | "user" | "assistant"; content: string; }, { role: "system" | "user" | "assistant"; content: string; }>, "many">; declare const RLHFFeedbackSchema: z.ZodObject<{ messageHash: z.ZodString; feedback: z.ZodNumber; hiddenState: z.ZodOptional, z.ZodTypeDef, Float32Array>>; }, "strip", z.ZodTypeAny, { messageHash: string; feedback: number; hiddenState?: Float32Array | undefined; }, { messageHash: string; feedback: number; hiddenState?: Float32Array | undefined; }>; declare const ModelStatusSchema: z.ZodEnum<["not_downloaded", "downloading", "ready", "offline", "error"]>; declare const EngineInfoSchema: z.ZodObject<{ modelId: z.ZodString; status: z.ZodEnum<["not_downloaded", "downloading", "ready", "offline", "error"]>; backend: z.ZodEnum<["webgpu", "webnn", "wasm", "cpu"]>; storageBackend: z.ZodEnum<["opfs", "indexeddb", "memory"]>; progress: z.ZodOptional; layersComplete: z.ZodNumber; totalLayers: z.ZodNumber; status: z.ZodEnum<["downloading", "verifying", "ready", "error"]>; error: z.ZodOptional; }, "strip", z.ZodTypeAny, { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }>>; config: z.ZodObject<{ id: z.ZodString; name: z.ZodString; architecture: z.ZodEnum<["llama", "mistral", "qwen", "smollm", "phi"]>; version: z.ZodString; vocabSize: z.ZodNumber; hiddenDim: z.ZodNumber; numLayers: z.ZodNumber; numHeads: z.ZodNumber; numKvHeads: z.ZodOptional; intermediateDim: z.ZodOptional; maxSeqLength: z.ZodNumber; ropeTheta: z.ZodOptional; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }, { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }>; }, "strip", z.ZodTypeAny, { status: "downloading" | "ready" | "error" | "not_downloaded" | "offline"; modelId: string; storageBackend: "opfs" | "indexeddb" | "memory"; backend: "webgpu" | "webnn" | "wasm" | "cpu"; config: { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }; progress?: { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; } | undefined; }, { status: "downloading" | "ready" | "error" | "not_downloaded" | "offline"; modelId: string; storageBackend: "opfs" | "indexeddb" | "memory"; backend: "webgpu" | "webnn" | "wasm" | "cpu"; config: { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }; progress?: { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; } | undefined; }>; declare const LayerWeightsSchema: z.ZodObject<{ layerIndex: z.ZodNumber; attnQ: z.ZodType, z.ZodTypeDef, Float32Array>; attnK: z.ZodType, z.ZodTypeDef, Float32Array>; attnV: z.ZodType, z.ZodTypeDef, Float32Array>; attnOut: z.ZodType, z.ZodTypeDef, Float32Array>; attnNorm: z.ZodType, z.ZodTypeDef, Float32Array>; ffnGate: z.ZodType, z.ZodTypeDef, Float32Array>; ffnUp: z.ZodType, z.ZodTypeDef, Float32Array>; ffnDown: z.ZodType, z.ZodTypeDef, Float32Array>; ffnNorm: z.ZodType, z.ZodTypeDef, Float32Array>; }, "strip", z.ZodTypeAny, { layerIndex: number; attnQ: Float32Array; attnK: Float32Array; attnV: Float32Array; attnOut: Float32Array; attnNorm: Float32Array; ffnGate: Float32Array; ffnUp: Float32Array; ffnDown: Float32Array; ffnNorm: Float32Array; }, { layerIndex: number; attnQ: Float32Array; attnK: Float32Array; attnV: Float32Array; attnOut: Float32Array; attnNorm: Float32Array; ffnGate: Float32Array; ffnUp: Float32Array; ffnDown: Float32Array; ffnNorm: Float32Array; }>; declare const KVCacheSchema: z.ZodObject<{ keys: z.ZodArray, z.ZodTypeDef, Float32Array>, "many">; values: z.ZodArray, z.ZodTypeDef, Float32Array>, "many">; position: z.ZodNumber; maxLength: z.ZodNumber; }, "strip", z.ZodTypeAny, { keys: Float32Array[]; values: Float32Array[]; position: number; maxLength: number; }, { keys: Float32Array[]; values: Float32Array[]; position: number; maxLength: number; }>; declare const CogModelConfigSchema: z.ZodObject<{ id: z.ZodLiteral<"cog-360m">; name: z.ZodLiteral<"Cog">; architecture: z.ZodLiteral<"smollm">; version: z.ZodString; vocabSize: z.ZodLiteral<49152>; hiddenDim: z.ZodLiteral<960>; numLayers: z.ZodLiteral<32>; numHeads: z.ZodLiteral<15>; numKvHeads: z.ZodLiteral<5>; intermediateDim: z.ZodLiteral<2560>; maxSeqLength: z.ZodLiteral<2048>; ropeTheta: z.ZodLiteral<10000>; }, "strip", z.ZodTypeAny, { id: "cog-360m"; name: "Cog"; architecture: "smollm"; version: string; vocabSize: 49152; hiddenDim: 960; numLayers: 32; numHeads: 15; numKvHeads: 5; intermediateDim: 2560; maxSeqLength: 2048; ropeTheta: 10000; }, { id: "cog-360m"; name: "Cog"; architecture: "smollm"; version: string; vocabSize: 49152; hiddenDim: 960; numLayers: 32; numHeads: 15; numKvHeads: 5; intermediateDim: 2560; maxSeqLength: 2048; ropeTheta: 10000; }>; declare const CyranoModelConfigSchema: z.ZodObject<{ id: z.ZodLiteral<"cyrano-360m">; name: z.ZodLiteral<"Cyrano">; architecture: z.ZodLiteral<"smollm">; version: z.ZodString; vocabSize: z.ZodLiteral<49152>; hiddenDim: z.ZodLiteral<960>; numLayers: z.ZodLiteral<32>; numHeads: z.ZodLiteral<15>; numKvHeads: z.ZodLiteral<5>; intermediateDim: z.ZodLiteral<2560>; maxSeqLength: z.ZodLiteral<2048>; ropeTheta: z.ZodLiteral<10000>; }, "strip", z.ZodTypeAny, { id: "cyrano-360m"; name: "Cyrano"; architecture: "smollm"; version: string; vocabSize: 49152; hiddenDim: 960; numLayers: 32; numHeads: 15; numKvHeads: 5; intermediateDim: 2560; maxSeqLength: 2048; ropeTheta: 10000; }, { id: "cyrano-360m"; name: "Cyrano"; architecture: "smollm"; version: string; vocabSize: 49152; hiddenDim: 960; numLayers: 32; numHeads: 15; numKvHeads: 5; intermediateDim: 2560; maxSeqLength: 2048; ropeTheta: 10000; }>; type ModelMeta = z.infer; type EdgeworkOptions = z.infer; type GenerateOptions = z.infer; type ChatMessage = z.infer; type RLHFFeedback = z.infer; declare function validateModelMeta(data: unknown): ModelMeta; declare function validateGenerateOptions(data: unknown): GenerateOptions; declare function validateChatMessages(data: unknown): ChatMessage[]; declare function validateEdgeworkOptions(data: unknown): EdgeworkOptions; declare function validateRLHFFeedback(data: unknown): RLHFFeedback; declare function safeParseModelMeta(data: unknown): z.SafeParseReturnType<{ id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }, { id: string; name: string; architecture: "llama" | "mistral" | "qwen" | "smollm" | "phi"; version: string; vocabSize: number; hiddenDim: number; numLayers: number; numHeads: number; maxSeqLength: number; createdAt: string; numKvHeads?: number | undefined; intermediateDim?: number | undefined; ropeTheta?: number | undefined; }>; declare function safeParseGenerateOptions(data: unknown): z.SafeParseReturnType<{ maxTokens?: number | undefined; temperature?: number | undefined; topP?: number | undefined; topK?: number | undefined; stopSequences?: string[] | undefined; stream?: boolean | undefined; }, { maxTokens: number; temperature: number; topP: number; topK: number; stream: boolean; stopSequences?: string[] | undefined; }>; declare function safeParseChatMessages(data: unknown): z.SafeParseReturnType<{ role: "system" | "user" | "assistant"; content: string; }[], { role: "system" | "user" | "assistant"; content: string; }[]>; declare function safeParseEdgeworkOptions(data: unknown): z.SafeParseReturnType<{ model: string; userId?: string | undefined; syncUrl?: string | undefined; onProgress?: ((args_0: { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, ...args: unknown[]) => void) | undefined; enableRLHF?: boolean | undefined; communityParticipation?: boolean | undefined; federatedSyncUrl?: string | undefined; trainingBatchSize?: number | undefined; trainingIdleFlushMs?: number | undefined; cacheDir?: string | undefined; storageBackend?: "opfs" | "indexeddb" | "memory" | undefined; inferenceBackend?: "webgpu" | "webnn" | "wasm" | "cpu" | undefined; }, { model: string; enableRLHF: boolean; communityParticipation: boolean; trainingBatchSize: number; trainingIdleFlushMs: number; userId?: string | undefined; syncUrl?: string | undefined; onProgress?: ((args_0: { status: "downloading" | "verifying" | "ready" | "error"; modelId: string; percent: number; bytesDownloaded: number; totalBytes: number; layersComplete: number; totalLayers: number; error?: string | undefined; currentLayer?: string | undefined; }, ...args: unknown[]) => void) | undefined; federatedSyncUrl?: string | undefined; cacheDir?: string | undefined; storageBackend?: "opfs" | "indexeddb" | "memory" | undefined; inferenceBackend?: "webgpu" | "webnn" | "wasm" | "cpu" | undefined; }>; declare function safeParseRLHFFeedback(data: unknown): z.SafeParseReturnType<{ messageHash: string; feedback: number; hiddenState?: Float32Array | undefined; }, { messageHash: string; feedback: number; hiddenState?: Float32Array | undefined; }>; /** * WASM Loader with Decryption * * Loads and decrypts the encrypted WASM core module. * Requires a valid license token from the oracle. */ /** * WASM module instance */ interface WasmModule { init: (jwt: string) => Promise; is_licensed: () => boolean; get_session: () => unknown; EdgeworkCore: new () => EdgeworkCoreInstance; } /** * EdgeworkCore instance from WASM */ interface EdgeworkCoreInstance { get_router: () => unknown; get_inference_client: (config: unknown) => unknown; get_distributed_client: (config: unknown) => unknown; get_gateway_client: (endpoint: string) => unknown; } /** * Loader configuration */ interface LoaderConfig { wasmUrl?: string; oracleEndpoint?: string; licenseToken?: string; } /** * Load the encrypted WASM core */ declare function loadWasmCore(config: LoaderConfig): Promise; /** * Check if WASM is loaded */ declare function isWasmLoaded(): boolean; /** * Get loaded WASM module */ declare function getWasmModule(): WasmModule | null; /** * Unload WASM module */ declare function unloadWasm(): void; /** * Streaming WASM loader for CLI * Loads WASM in chunks from server, never fully cached on disk */ declare function loadWasmStreaming(endpoint: string, sessionToken: string, functionNames: string[]): Promise unknown>>; /** * WASM Module Exports * * Provides encrypted WASM loading, decryption, and streaming capabilities. */ type index_EdgeworkCoreInstance = EdgeworkCoreInstance; type index_LoaderConfig = LoaderConfig; type index_WasmModule = WasmModule; declare const index_getWasmModule: typeof getWasmModule; declare const index_isWasmLoaded: typeof isWasmLoaded; declare const index_loadWasmCore: typeof loadWasmCore; declare const index_loadWasmStreaming: typeof loadWasmStreaming; declare const index_unloadWasm: typeof unloadWasm; declare namespace index { export { type index_EdgeworkCoreInstance as EdgeworkCoreInstance, type index_LoaderConfig as LoaderConfig, type index_WasmModule as WasmModule, index_getWasmModule as getWasmModule, index_isWasmLoaded as isWasmLoaded, index_loadWasmCore as loadWasmCore, index_loadWasmStreaming as loadWasmStreaming, index_unloadWasm as unloadWasm }; } /** * Model Configurations Stubs */ declare const COG_CONFIG: { readonly id: "cog-360m"; readonly architecture: "smollm"; readonly createdAt: "2025-01-01T00:00:00.000Z"; readonly hiddenDim: 960; readonly intermediateDim: 2560; readonly maxSeqLength: 2048; readonly name: "Cog"; readonly numHeads: 15; readonly numKvHeads: 5; readonly numLayers: 32; readonly ropeTheta: 10000; readonly version: "0.1.0"; readonly vocabSize: 49152; }; declare const CYRANO_CONFIG: { readonly id: "cyrano-360m"; readonly architecture: "smollm"; readonly createdAt: "2025-01-01T00:00:00.000Z"; readonly hiddenDim: 960; readonly intermediateDim: 2560; readonly maxSeqLength: 2048; readonly name: "Cyrano"; readonly numHeads: 15; readonly numKvHeads: 5; readonly numLayers: 32; readonly ropeTheta: 10000; readonly version: "0.1.0"; readonly vocabSize: 49152; }; declare const MODELS: string[]; declare function getModelConfig(modelId: string): { readonly id: "cog-360m"; readonly architecture: "smollm"; readonly createdAt: "2025-01-01T00:00:00.000Z"; readonly hiddenDim: 960; readonly intermediateDim: 2560; readonly maxSeqLength: 2048; readonly name: "Cog"; readonly numHeads: 15; readonly numKvHeads: 5; readonly numLayers: 32; readonly ropeTheta: 10000; readonly version: "0.1.0"; readonly vocabSize: 49152; } | { readonly id: "cyrano-360m"; readonly architecture: "smollm"; readonly createdAt: "2025-01-01T00:00:00.000Z"; readonly hiddenDim: 960; readonly intermediateDim: 2560; readonly maxSeqLength: 2048; readonly name: "Cyrano"; readonly numHeads: 15; readonly numKvHeads: 5; readonly numLayers: 32; readonly ropeTheta: 10000; readonly version: "0.1.0"; readonly vocabSize: 49152; } | null; declare const SYSTEM_PROMPTS: { 'cog-360m': string; 'cyrano-360m': string; }; declare function getSystemPrompt(modelId: string): string; declare const MODEL_SYNC_URLS: { 'cog-360m': string; 'cyrano-360m': string; }; /** * Edgework SDK * * Client-side AI inference with D1/Dash storage, WebGPU inference, and on-device RLHF. * * @example * ```typescript * import { Edgework } from '@affectively/edgework'; * * // Initialize with a model * const ai = await Edgework.init({ * model: 'cyrano-360m', * onProgress: (p) => console.log(`${p.percent}% downloaded`) * }); * * // Generate text * const response = await ai.generate('How are you feeling today?'); * * // Stream responses * for await (const token of ai.stream('Tell me a story')) { * process.stdout.write(token); * } * * // Chat with context * const reply = await ai.chat([ * { role: 'user', content: 'I had a rough day' }, * ]); * ``` */ /** * Edgework - Main SDK class * * Provides a unified interface for client-side AI inference. */ declare class Edgework { private static readonly DEFAULT_TRAINING_BATCH_SIZE; private static readonly DEFAULT_TRAINING_IDLE_FLUSH_MS; private storage; private inference; private sync; private rlhfTrainer; private modalityTrainers; private pendingSignals; private communityParticipation; private idleFlushTimer; private trainingBatchSize; private trainingIdleFlushMs; private modelId; private systemPrompt; private options; private constructor(); /** * Initialize Edgework with a model */ static init(options: EdgeworkOptions$1): Promise; /** * Get an existing Edgework instance (assumes model is already downloaded) */ static get(modelId: string): Promise; /** * Generate text from a prompt */ generate(prompt: string, options?: GenerateOptions$1): Promise; /** * Stream tokens from a prompt */ stream(prompt: string, options?: GenerateOptions$1): AsyncGenerator; /** * Chat with conversation history */ chat(messages: ChatMessage$1[], options?: GenerateOptions$1): Promise; /** * Get embeddings for text */ embed(text: string): Promise; /** * Provide feedback for RLHF (thumbs up/down) */ feedback(messageHash: string, rating: 'positive' | 'negative'): Promise; /** * Unified modality inference API. */ infer(modality: Modality, input: unknown, options?: GenerateOptions$1): Promise; /** * Record a modality-specific training signal for micro-batch training. */ recordSignal(modality: Modality, signal: ModalityTrainingSignal): Promise; /** * Flush pending local training for one modality or all modalities. */ flushTraining(modality?: Modality): Promise; /** * Enable or disable community update sharing. */ setCommunityParticipation(enabled: boolean): Promise; /** * Get model status and info */ get status(): EngineInfo | null; /** * Get download progress */ get progress(): DownloadProgress | null; /** * Check if model is ready for inference */ get isReady(): boolean; /** * Get RLHF training stats */ get rlhfStats(): { examples: number; lastTrained?: string; } | null; /** * Generate a unique device ID for RLHF */ private generateDeviceId; private scheduleIdleFlush; private clearIdleFlushTimer; private bindSessionFlushHooks; private createInferenceError; } export { AdapterTypeSchema, COG_CONFIG, CYRANO_CONFIG, ChatMessage$1 as ChatMessage, ChatMessageSchema, ChatMessagesSchema, ChatRoleSchema, CogModelConfigSchema, CyranoModelConfigSchema, DownloadProgress, DownloadProgressSchema, DownloadStatusSchema, Edgework, EdgeworkOptions$1 as EdgeworkOptions, EdgeworkOptionsSchema, EngineInfo, EngineInfoSchema, GenerateOptions$1 as GenerateOptions, GenerateOptionsSchema, GenerateResult, GenerateResultSchema, InferenceBackendSchema, InferenceError, KVCacheSchema, LayerWeightsSchema, MODELS, MODEL_SYNC_URLS, Modality, ModalityInferenceResult, ModalityTrainingSignal, ModelArchitectureSchema, ModelMetaSchema, ModelStatusSchema, QuantizationTypeSchema, RLHFFeedbackSchema, SYSTEM_PROMPTS, StorageBackendSchema, SyncProgressSchema, TensorChunkSchema, TokenizerDataSchema, TrainingFlushResult, TrainingLogEntrySchema, UserAdapterSchema, index as Wasm, Edgework as default, getModelConfig, getSystemPrompt, safeParseChatMessages, safeParseEdgeworkOptions, safeParseGenerateOptions, safeParseModelMeta, safeParseRLHFFeedback, validateChatMessages, validateEdgeworkOptions, validateGenerateOptions, validateModelMeta, validateRLHFFeedback };