{"_id":"@cohesiumai/core","_rev":"3-36289299acdf14e13cbcf06f7e8efcda","name":"@cohesiumai/core","dist-tags":{"latest":"2.1.2"},"versions":{"0.2.0":{"name":"@cohesiumai/core","version":"0.2.0","license":"MIT","_id":"@cohesiumai/core@0.2.0","maintainers":[{"name":"cohesiumai","email":"renald@cohesium.ai"}],"dist":{"shasum":"23f670614e84ff659a7bcf03e1c1cf428f8d28c0","tarball":"https://registry.npmjs.org/@cohesiumai/core/-/core-0.2.0.tgz","fileCount":6,"integrity":"sha512-5wy5XyVl35QjwJetibIawHwFD4motySZCA7m9B5TDkKhhlHC1r6HqEsXzX/Ahxpg0hW3mt2SD37JRedaLbHI/w==","signatures":[{"sig":"MEUCIG2Z2iCvOKWV7fd+hmVat+MK5WfE03h9DdsDCCLzl0fMAiEAjTGtx5pyJtky0LRNFRwRJ6jR/KmJmv0h8qFVoJbqr5g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":392775},"main":"dist/index.js","type":"module","_from":"file:cohesiumai-core-0.2.0.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"eslint src/","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc -p tsconfig.json --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"cohesiumai","email":"renald@cohesium.ai"},"_resolved":"/tmp/e15ad38320c9bae166a8ca8da32903d3/cohesiumai-core-0.2.0.tgz","_integrity":"sha512-5wy5XyVl35QjwJetibIawHwFD4motySZCA7m9B5TDkKhhlHC1r6HqEsXzX/Ahxpg0hW3mt2SD37JRedaLbHI/w==","_npmVersion":"10.8.2","description":"> Core package for browser-ai — Types, FSM, protocol, storage, and plugins.","directories":{},"_nodeVersion":"20.19.6","dependencies":{"fetch-in-chunks":"^1.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.2.0_1768902460190_0.810229812809576","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@cohesiumai/core","version":"0.2.1","license":"MIT","_id":"@cohesiumai/core@0.2.1","maintainers":[{"name":"cohesiumai","email":"renald@cohesium.ai"}],"dist":{"shasum":"22f39bab5e40c59f289a9ea79017030d9b763416","tarball":"https://registry.npmjs.org/@cohesiumai/core/-/core-0.2.1.tgz","fileCount":6,"integrity":"sha512-MxcasgqnnsgtOmsVKSSd6QK+5rfKl4KzC3i31K0SD70oQLqTz17+qYtj6GGU0pE/9YCnSewtbNcrMPzjtUmtXA==","signatures":[{"sig":"MEYCIQCdUNc1J+o+s+aDFBguo/1yDxcjREDSkUDRE8rGZSDyxAIhAOxpKxuQjD3PfASFmz2s1GL0iO2vqF3o4UiEBNjaNLbD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":392775},"main":"dist/index.js","type":"module","_from":"file:cohesiumai-core-0.2.1.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"eslint src/","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc -p tsconfig.json --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"cohesiumai","email":"renald@cohesium.ai"},"_resolved":"/tmp/9a72ad0248936a72ef89198c386db6ce/cohesiumai-core-0.2.1.tgz","_integrity":"sha512-MxcasgqnnsgtOmsVKSSd6QK+5rfKl4KzC3i31K0SD70oQLqTz17+qYtj6GGU0pE/9YCnSewtbNcrMPzjtUmtXA==","_npmVersion":"10.8.2","description":"> Core package for browser-ai — Types, FSM, protocol, storage, and plugins.","directories":{},"_nodeVersion":"20.19.6","dependencies":{"fetch-in-chunks":"^1.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.2.1_1768905733118_0.2706198825864057","host":"s3://npm-registry-packages-npm-production"}},"2.1.2":{"name":"@cohesiumai/core","version":"2.1.2","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"dependencies":{"fetch-in-chunks":"^1.4.0"},"peerDependencies":{"typescript":"^5.0.0"},"publishConfig":{"access":"public"},"license":"MIT","scripts":{"build":"tsup","typecheck":"tsc -p tsconfig.json --noEmit","lint":"eslint src/","test":"vitest run --passWithNoTests","test:coverage":"vitest run --coverage"},"_id":"@cohesiumai/core@2.1.2","description":"> Core package for browser-ai — Types, FSM, protocol, storage, and plugins.","_integrity":"sha512-mgP35bWoatphVlKP1VYAtS5zYoSylQcXLGRHr1uK4ab7BMMO6QDIjkeDlwxTWmTkC4ONXsiyf0vTanEa8MeVoA==","_resolved":"/tmp/e0653fb262b1966981340268a7cadafb/cohesiumai-core-2.1.2.tgz","_from":"file:cohesiumai-core-2.1.2.tgz","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-mgP35bWoatphVlKP1VYAtS5zYoSylQcXLGRHr1uK4ab7BMMO6QDIjkeDlwxTWmTkC4ONXsiyf0vTanEa8MeVoA==","shasum":"9cf29e87645298f6595eb0e5ad5161fe3c178a1f","tarball":"https://registry.npmjs.org/@cohesiumai/core/-/core-2.1.2.tgz","fileCount":6,"unpackedSize":392775,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDCH1SAgPZxE65JCA9OQgt2vmFC00L0kCh10N8DyLnrcAiAUwv0oBoKeWkYhaUrmM6dgIIJYohKqpnqlLqkRQnEcHg=="}]},"_npmUser":{"name":"cohesiumai","email":"renald@cohesium.ai"},"directories":{},"maintainers":[{"name":"cohesiumai","email":"renald@cohesium.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_2.1.2_1768910610644_0.6243603499366304"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-20T09:47:40.086Z","modified":"2026-01-20T12:03:30.947Z","0.2.0":"2026-01-20T09:47:40.375Z","0.2.1":"2026-01-20T10:42:13.324Z","2.1.2":"2026-01-20T12:03:30.812Z"},"license":"MIT","description":"> Core package for browser-ai — Types, FSM, protocol, storage, and plugins.","maintainers":[{"name":"cohesiumai","email":"renald@cohesium.ai"}],"readme":"# @cohesiumai/core\n\n> Core package for browser-ai — Types, FSM, protocol, storage, and plugins.\n\n## Installation\n\n```bash\npnpm add @cohesiumai/core\n```\n\n## Features\n\n### Core (V0.1)\n- **BrowserAI Class** — Main entry point with lifecycle management\n- **FSM (12 states)** — Predictable state machine\n- **Epoch/Sequence Protocol** — Race condition prevention\n- **Provider Selection** — Automatic best-provider selection\n- **Diagnostics API** — Runtime introspection\n- **Error Catalog** — Typed errors with recovery hints\n\n### V0.2 Additions\n- **Healthcheck Manager** — Token-aware stall detection\n- **Download Watchdog** — Stuck download detection\n- **tierOverride** — Force specific provider tier\n\n### V1.0 Additions\n- **OPFS Manager** — Persistent storage via Origin Private File System\n- **LRU Cache Manager** — Automatic model eviction\n- **Model Manager** — Multi-model support\n- **Plugin Manager** — Extensible hooks system\n\n### V2.1 Additions\n- **Unified Model Registry** — Central memory management across modules\n- **Abort Recovery** — Watchdog timing reset after engine recreation\n- **`onRecreate` Callback** — Provider-to-core communication\n- **`resetGeneratingTiming()`** — FSM timing reset for GENERATING state\n\n## Usage\n\n### Basic\n\n```typescript\nimport { createBrowserAI } from '@cohesiumai/core';\n\nconst ai = createBrowserAI({\n  config: { providerPolicy: { order: ['native', 'webllm'] } },\n  providers: [nativeProvider, webllmProvider],\n});\n\nawait ai.init();\nconst { result } = ai.generate({ messages: [...] });\n```\n\n### Multi-Model (V1.0)\n\n```typescript\nimport { createModelManager } from '@cohesiumai/core';\n\nconst manager = createModelManager({ maxLoadedModels: 2 });\nawait manager.loadModel(spec1, provider1);\nawait manager.loadModel(spec2, provider2);\nawait manager.setActiveModel('model-2');\n```\n\n### Plugins (V1.0)\n\n```typescript\nimport { createPluginManager, createLoggingPlugin } from '@cohesiumai/core';\n\nconst plugins = createPluginManager();\nplugins.register(createLoggingPlugin());\nplugins.register({\n  name: 'custom',\n  afterGenerate(ctx) { console.log(ctx.result.text); },\n});\n```\n\n### OPFS Storage (V1.0)\n\n```typescript\nimport { createOPFSManager } from '@cohesiumai/core';\n\nconst opfs = createOPFSManager();\nif (opfs.isAvailable()) {\n  await opfs.storeShard('model-id', 0, data);\n}\n```\n\n### LRU Cache (V1.0)\n\n```typescript\nimport { createLRUCacheManager } from '@cohesiumai/core';\n\nconst cache = await createLRUCacheManager({ maxUsageRatio: 0.8 });\nawait cache.autoEvict();\n```\n\n### Model Registry (V2.1)\n\n```typescript\nimport { getGlobalRegistry } from '@cohesiumai/core';\n\nconst registry = getGlobalRegistry({ maxMemoryMB: 1500 });\n\n// Acquire model with reference counting\nconst model = await registry.acquire('model-id', 'transformers', loaderFn);\n\n// Release when done (starts idle timer)\nregistry.release('model-id');\n\n// Check memory usage\nconst usage = registry.getMemoryUsage();\n```\n\n## Exports\n\n### Types\n- `BrowserAIConfig`, `GenerateParams`, `GenerateResult`\n- `Provider`, `ProviderId`, `DetectResult`\n- `ModelSpec`, `RuntimeState`, `DiagnosticsSnapshot`\n- `BrowserAIError`, `ErrorCode`\n\n### Storage\n- `createCacheManager()` — CacheStorage-based caching\n- `createOPFSManager()` — OPFS persistent storage (V1.0)\n- `createLRUCacheManager()` — LRU eviction manager (V1.0)\n- `createIDBManager()` — IndexedDB utilities\n\n### Models\n- `createModelManager()` — Multi-model management (V1.0)\n\n### Plugins\n- `createPluginManager()` — Plugin system (V1.0)\n- `createLoggingPlugin()` — Built-in logging\n- `createTelemetryPlugin()` — Built-in local telemetry\n\n### Utils\n- `getQuotaEstimate()` — Storage quota check\n- `createError()` — Typed error creation\n\n## License\n\nMIT © 2026\n","readmeFilename":"README.md"}