@agents-js/memory-local
v0.5.1
Published
Local single-process MemoryProvider for agents-js (Bun runtime only — depends on `bun:sqlite`). Backed by a pluggable storage seam (sqlite by default) with an optional policy-gate hook.
Maintainers
Readme
@agents-js/memory-local
Local single-process MemoryProvider for agents-js (Bun runtime only — depends on
bun:sqlite). Backed by a pluggable storage seam (sqlite by default) with an optional policy-gate hook.
Installation
bun add @agents-js/memory-localAPI
Classes
LocalMemoryProvider— Local, single-processMemoryProvider. Orchestrates the policy-gate seam, idempotency lookup, creator-only ACL, and optimistic-concurrency checks on top of an injectedStoragebackend (typically...SqliteStorage— sqlite-backed {Storage} impl. Usesbun:sqlite(a runtime built-in; no npm dependency). WAL is enabled so concurrent readers never block a writer, andsynchronous = NORMALtrades a small crash-w...
Functions
cloneRecord— Local deep-clone helper. Why this exists:-js/memorydoes not currently export acloneRecordhelper, but the sqlite storage impl needs to defensively clone records on the way out (so a caller m...migrate— ReadPRAGMA user_version; if 0, apply {SCHEMA_DDL} and stampcurrentVersion. If already equal, no-op. If greater thancurrentVersion, throw — refuse to open a file written by a newer binary. ...
Interfaces
LocalMemoryProviderOptionsMemoryPolicyGate— Optional policy hook injected intoLocalMemoryProvider. Evaluated BEFORE the storage call; the provider lifts adeny(and, in v1,ask) into aMemoryAclError. The interactive"ask"variant...MemoryPolicyInputMemoryPolicyResultSqliteStorageOptionsStorage— Storage seam used byLocalMemoryProvider. Public surface: external consumers can implement this interface to back the provider with their own durable storage (e.g. postgres, level, a remote KV) i...StoredRecord— Backend-stored record shape. Extends the publicMemoryRecordwith provider-internal fields (creator provenance, idempotency key) that are not exposed across theMemoryProviderboundary.StoredRecordPatch— Partial update payload accepted by the storage seam. Mirrors the caller-facingUpdateMemoryInputsemantic: absent fields are untouched, present fields replace.
Types
MemoryPolicyDecisionMemoryPolicyOpUpdateRecordResult
Constants
CURRENT_SCHEMA_VERSION— Bumped whenever the on-disk DDL changes incompatibly. The migration function stamps this intoPRAGMA user_versionafter applying the DDL, and refuses to open a file whose stored version is newer ...noopPolicyGate— Default gate — always allows. Lets the provider work out of the box with no policy plumbing. Callers opt in to enforcement by supplying their own gate.SCHEMA_DDL— Canonical schema.CREATE TABLE IF NOT EXISTSmakes the DDL safe to re-run; the migration function still only applies it on a fresh database (user_version = 0) so the per-process cost is one read....
Exports
MemoryAclErrorMemoryRevisionConflictErrortype LocalMemoryProviderOptionstype SqliteStorageOptions
Dependencies
@agents-js/memory
License
MIT
