clm-kernel
v0.0.22
Published
CLM Kernel Core JavaScript & TypeScript Implementation
Readme
clm-kernel (0.0.22, TypeScript and JavaScript)
clm-kernel is the TypeScript and JavaScript implementation of the Cubical Logic Model (CLM). It ships dual ESM and CommonJS bundles alongside a zero-Node browser entry point (clm-kernel/browser) and modular subpaths for Layers 0 through 4.
Installation
Requires Node.js 22+ for server and CLI targets, or any modern ES2022 browser runtime for clm-kernel/browser.
npm install clm-kernelSubpath exports
package.json defines 21 public export entry points:
| Subpath | Layer and scope |
| :--- | :--- |
| clm-kernel | Unified root entry point (MCard, ContentHash, MemoryBackend, MCardFileSystem, PlaceTypeLattice, ColoredPetriVM) |
| clm-kernel/bin/clmEval | CLI entry point for manifest evaluation, conformance vectors, and formal runtime dispatch |
| clm-kernel/layer0 | MCard, PCard, VCard, BLAKE3 hashing, canonical JSON, TypeLattice, MemoryBackend, NodeSqliteBackend, SqlJsBackend, IndexedDbBackend |
| clm-kernel/layer1 | TokenMCard, PlaceMCard, TransitionMCard, PlaceTypeLattice, ColoredPetriVM, formalWitness |
| clm-kernel/layer2 | MCardCollection, MCardFileSystem, DirectoryManifest, ChunkManifest, PetriProcessPCard, OpenPetriNet, sheafCohomology, bisimulation |
| clm-kernel/layer3 | Cordis Context, DisposableList, SavepointGuard, Satori speech-act envelopes, mesh transport |
| clm-kernel/layer4 | Sovereign CLI runtime, ViewPlaceMCard, NavigationTransitionPCard, presentation adapters |
| clm-kernel/shared | Shared URI, canonicalization, and typed error helpers |
| clm-kernel/membrane | Pluggable presentation membrane SPI |
| clm-kernel/gateway | JSON-RPC 2.0 and WebSocket Triad Gateway for SSR hosts (Astro, Next.js, Vite) |
| clm-kernel/tui | Terminal dashboard components |
| clm-kernel/chatbot | Conversational agent session helpers |
| clm-kernel/client | Browser and Node WebSocket RPC client |
| clm-kernel/drivers/s3 | S3-compatible object storage adapter |
| clm-kernel/drivers/ipfs | IPFS content-addressed block adapter |
| clm-kernel/primitives | Lightweight MCard, ContentHash, g_time, and TypedValue bundle |
| clm-kernel/cel | Hermetic Common Expression Language (CEL) evaluator |
| clm-kernel/vcard | VCard identity, AgentDid, and Pre-VCard / Post-VCard boundary guards |
| clm-kernel/pcard | PCard morphism definitions, PrimitivePCard, BooleanPCard, and DynamicPCard |
| clm-kernel/browser | Browser-safe bundle (MCard, MCardCollection, MemoryBackend, SqlJsBackend, IndexedDbBackend, SyncService) with zero node:* imports |
| clm-kernel/sync | SyncContract v1 (types, codec, petri, service) for MCard delta synchronization |
| clm-kernel/browser/process | Browser-safe process and fibration runtime (PtrCordisEngine, PetriProcessPCard, FiberLifecycle, ProcessFibration, ColoredPetriVM, CodecRegistryService, createBrowserProcessContext) with zero node:* imports |
| clm-kernel/api-surface.json | Generated public type and value exports, with stability and module-format information |
| clm-kernel/published-capabilities.json | Capability register and versioned conformance cases |
The package also contains CHANGELOG.md at its root, synchronized from the repository changelog.
In the TypeScript CEL evaluator, a comparison's right-hand side is a literal by default, including a bare $threshold. To compare against a field, opt in with evaluateCelExpression('score >= $threshold', context, { fieldReferences: true }). In dispatch, set celFieldReferences: true in the dispatchWithHoare options. Field-to-field comparisons read own fields on both sides; input. and output. select that card without falling back to the other. A missing field causes the comparison to bail, and unmatched terms in a compound expression fail closed in this mode. Quote a string such as '$threshold' to compare it literally even with the opt-in enabled.
Quick start
TypeScript and ES modules
import { MCard, MemoryBackend, MCardFileSystem } from 'clm-kernel';
const storage = new MemoryBackend();
const fs = MCardFileSystem.withBackend(storage);
const payload = JSON.stringify({ status: 'active' });
const card = MCard.create(payload, 'did:clm:example');
const stored = fs.writeFile('/agents/card-001.json', payload, 'did:clm:example');
const fetched = fs.readFile('/agents/card-001.json');
console.log(`Card hash: ${card.hash.hex}`);
console.log(`Stored URI: ${stored.uri} (${fetched.payload.kind})`);CommonJS
const { MCard, MemoryBackend, MCardFileSystem } = require('clm-kernel');Contract parameters and generated vocabulary
Inside the kernel, contract-owned values come from modules generated from the CLM runtime contract: src/layer0/vocabulary.ts, vocabularyEnv.ts, vocabularyTypes.ts, vocabularyIdentities.ts, signatureDefaults.ts, and parameterContext.ts, plus src/vcard/dispatchCatalog.ts for dispatch catalog ids. The build inlines the vocabulary constants (see tsup.config.ts), so they add no runtime imports and leave the bundle tree-shakable ("sideEffects": false). parameterContext.ts resolves CLI over environment (CLM_* names) over a signed card override over the contract default, and throws ParameterBoundaryError for a value outside its refinement.
In 0.0.21 these modules, providerProfiles.ts, and the functional.ts combinators (identity, compose, pipe) are internal: no subpath above exports them, so the public API is unchanged.
Build outputs
- ESM:
./dist/index.js(./dist/index.d.ts) - CommonJS:
./dist/index.cjs(./dist/index.d.ts) - Browser:
./dist/browser/index.js(./dist/browser/index.d.ts)
License
MIT License. Source code, formal proofs, and Python and Rust kernels live in the CLM repository.
