@alineo-labs/memory 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.mts +22 -23
  2. package/package.json +5 -5
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { IStorageAdapter, LedgerEntry, SandboxHooks, WorkflowError } from "@alineo-labs/core";
2
-
3
2
  //#region src/types.d.ts
4
3
  /**
5
4
  * The durable identity memory is scoped by — deliberately NOT a `sandboxId` or session id.
@@ -27,7 +26,7 @@ interface ResourceRef {
27
26
  * its check entirely for a `ref` with no `teamId`, an unescaped join made that a real
28
27
  * cross-tenant read/write, not just a naming curiosity.
29
28
  */
30
- declare function scopeKey(ref: ResourceRef): string;
29
+ export declare function scopeKey(ref: ResourceRef): string;
31
30
  //#endregion
32
31
  //#region src/errors.d.ts
33
32
  /** Memory capabilities a `Memory` instance may or may not have been configured with. */
@@ -39,7 +38,7 @@ type MemoryCapability = "semantic";
39
38
  * catch specifically — rather than a silent no-op or an empty result set that looks
40
39
  * indistinguishable from "no facts matched."
41
40
  */
42
- declare class MemoryCapabilityError extends WorkflowError {
41
+ export declare class MemoryCapabilityError extends WorkflowError {
43
42
  readonly capability: MemoryCapability;
44
43
  constructor(capability: MemoryCapability);
45
44
  }
@@ -64,7 +63,7 @@ interface IWorkingMemoryProvider {
64
63
  * Not a production recommendation — the same relationship `InMemoryStore` has to LangGraph's
65
64
  * real backends.
66
65
  */
67
- declare class InMemoryWorkingMemoryProvider implements IWorkingMemoryProvider {
66
+ export declare class InMemoryWorkingMemoryProvider implements IWorkingMemoryProvider {
68
67
  private readonly buckets;
69
68
  private bucketFor;
70
69
  get(ref: ResourceRef, key: string): Promise<unknown | undefined>;
@@ -151,7 +150,7 @@ interface IPrunableSemanticMemoryProvider extends ISemanticMemoryProvider {
151
150
  forget(ref: ResourceRef, ids: string[]): Promise<number>;
152
151
  }
153
152
  /** True if `provider` implements the optional pruning capability. */
154
- declare function isPrunable(provider: ISemanticMemoryProvider): provider is IPrunableSemanticMemoryProvider;
153
+ export declare function isPrunable(provider: ISemanticMemoryProvider): provider is IPrunableSemanticMemoryProvider;
155
154
  /**
156
155
  * Optional capability: a semantic memory provider that can remember many facts in one call,
157
156
  * batching the embedding call (one `embed()` invocation covering every fact's content) instead
@@ -165,7 +164,7 @@ interface IBulkSemanticMemoryProvider extends ISemanticMemoryProvider {
165
164
  rememberMany(ref: ResourceRef, facts: MemoryFact[]): Promise<void>;
166
165
  }
167
166
  /** True if `provider` implements the optional bulk-remember capability. */
168
- declare function isBulkRememberable(provider: ISemanticMemoryProvider): provider is IBulkSemanticMemoryProvider;
167
+ export declare function isBulkRememberable(provider: ISemanticMemoryProvider): provider is IBulkSemanticMemoryProvider;
169
168
  /**
170
169
  * Row shape common to `@alineo-labs/sqlite-memory` and `@alineo-labs/postgres-memory`'s
171
170
  * semantic-memory tables — both store the same columns, differing only in what each driver
@@ -182,12 +181,12 @@ interface SemanticFactRow {
182
181
  /** Shared row→fact mapping for any backend storing facts in the shape above — exported so
183
182
  * `@alineo-labs/sqlite-memory` and `@alineo-labs/postgres-memory` don't each hand-roll the
184
183
  * same conversion (including the `verified` derivation) with their own copy of this logic. */
185
- declare function factFromRow(row: SemanticFactRow): RememberedFact;
184
+ export declare function factFromRow(row: SemanticFactRow): RememberedFact;
186
185
  /** Shared ranking primitive for any backend doing its own naive (non-indexed) vector scan —
187
186
  * exported so real backends (`@alineo-labs/sqlite-memory`, `@alineo-labs/postgres-memory`)
188
187
  * don't each reimplement it. A backend with a real vector index (pgvector, sqlite-vec) should
189
188
  * rank in SQL instead and never needs this. */
190
- declare function cosineSimilarity(a: number[], b: number[]): number;
189
+ export declare function cosineSimilarity(a: number[], b: number[]): number;
191
190
  /**
192
191
  * Reference implementation — an array per resource, ranked by naive cosine similarity over
193
192
  * whatever `EmbeddingProvider` is passed in. Same purpose as `InMemoryWorkingMemoryProvider`:
@@ -195,7 +194,7 @@ declare function cosineSimilarity(a: number[], b: number[]): number;
195
194
  * production recommendation (no persistence, no approximate-nearest-neighbor indexing —
196
195
  * O(n) scan per `recall()`).
197
196
  */
198
- declare class InMemorySemanticMemoryProvider implements IPrunableSemanticMemoryProvider, IBulkSemanticMemoryProvider {
197
+ export declare class InMemorySemanticMemoryProvider implements IPrunableSemanticMemoryProvider, IBulkSemanticMemoryProvider {
199
198
  private readonly embeddings;
200
199
  private readonly entries;
201
200
  constructor(embeddings: EmbeddingProvider);
@@ -248,7 +247,7 @@ interface EpisodicRecallOptions {
248
247
  * `sandbox_created` payload the same way `runId` does. See `resolveSessionsByResourceId`'s own
249
248
  * doc comment for exactly how `teamId` is enforced (and its one documented trade-off).
250
249
  */
251
- declare function episodicRecall(adapter: IStorageAdapter, ref: ResourceRef, opts?: EpisodicRecallOptions): Promise<LedgerEntry[]>;
250
+ export declare function episodicRecall(adapter: IStorageAdapter, ref: ResourceRef, opts?: EpisodicRecallOptions): Promise<LedgerEntry[]>;
252
251
  //#endregion
253
252
  //#region src/episodic-tree.d.ts
254
253
  /** One session's place in the fork tree — its own entries plus every session forked from it. */
@@ -283,7 +282,7 @@ interface EpisodicTreeOptions {
283
282
  * to reach descendants. Root order and each branch's `children` are sorted by the branch's own
284
283
  * first entry timestamp, for a deterministic result.
285
284
  */
286
- declare function episodicTree(adapter: IStorageAdapter, ref: ResourceRef, opts?: EpisodicTreeOptions): Promise<EpisodicBranch[]>;
285
+ export declare function episodicTree(adapter: IStorageAdapter, ref: ResourceRef, opts?: EpisodicTreeOptions): Promise<EpisodicBranch[]>;
287
286
  //#endregion
288
287
  //#region src/compaction.d.ts
289
288
  interface CompactionOptions {
@@ -323,7 +322,7 @@ interface CompactionResult {
323
322
  * count cap is applied to whatever's left. Neither set is a no-op (returns `{removed: 0, ...}`
324
323
  * without calling `forget()`).
325
324
  */
326
- declare function compactSemanticMemory(provider: ISemanticMemoryProvider, ref: ResourceRef, opts?: CompactionOptions): Promise<CompactionResult>;
325
+ export declare function compactSemanticMemory(provider: ISemanticMemoryProvider, ref: ResourceRef, opts?: CompactionOptions): Promise<CompactionResult>;
327
326
  //#endregion
328
327
  //#region src/memory.d.ts
329
328
  /** Auto-compaction settings — see `Memory.remember()`. Shares its thresholds with
@@ -368,7 +367,7 @@ interface MemoryOptions {
368
367
  * load/attach/spawn factory pattern `Agent` uses — `Memory` has no async setup step (no
369
368
  * snapshot restore, no bridge process) that would need a factory to hide.
370
369
  */
371
- declare class Memory {
370
+ export declare class Memory {
372
371
  readonly workingMemory: {
373
372
  get(ref: ResourceRef, key: string): Promise<unknown | undefined>;
374
373
  set(ref: ResourceRef, key: string, value: unknown): Promise<void>;
@@ -479,7 +478,7 @@ interface LastCheckpointRecord {
479
478
  * });
480
479
  * ```
481
480
  */
482
- declare function createMemoryLifecycleHooks(memory: Memory, ref: ResourceRef, opts?: MemoryLifecycleHooksOptions): SandboxHooks;
481
+ export declare function createMemoryLifecycleHooks(memory: Memory, ref: ResourceRef, opts?: MemoryLifecycleHooksOptions): SandboxHooks;
483
482
  //#endregion
484
483
  //#region src/schema-working-memory.d.ts
485
484
  /**
@@ -520,13 +519,13 @@ interface SchemaValidator<T> {
520
519
  * `update()` should succeed before every field has been filled in — this class imposes no
521
520
  * partial/full policy of its own, it only merges and validates with whatever `schema` given.
522
521
  */
523
- declare class SchemaWorkingMemory<T extends Record<string, unknown>> {
522
+ export declare class SchemaWorkingMemory<T extends Record<string, unknown>> {
524
523
  private readonly provider;
525
524
  private readonly schema;
526
525
  /** Working-memory key the whole profile is stored under. */
527
526
  private readonly key;
528
- constructor(provider: IWorkingMemoryProvider, schema: SchemaValidator<T>, /** Working-memory key the whole profile is stored under. */
529
-
527
+ constructor(provider: IWorkingMemoryProvider, schema: SchemaValidator<T>,
528
+ /** Working-memory key the whole profile is stored under. */
530
529
  key?: string);
531
530
  /** The stored profile, or `{}` if nothing has been set yet. Not re-validated on read. */
532
531
  get(ref: ResourceRef): Promise<Partial<T>>;
@@ -565,7 +564,7 @@ interface MemoryTool {
565
564
  * surrounding application code, decide to persist or retrieve a fact mid-conversation — the
566
565
  * gap left by `Memory` being a plain TS API a developer must call explicitly.
567
566
  */
568
- declare function createMemoryTools(memory: Memory, ref: ResourceRef): MemoryTool[];
567
+ export declare function createMemoryTools(memory: Memory, ref: ResourceRef): MemoryTool[];
569
568
  //#endregion
570
569
  //#region src/pipeline.d.ts
571
570
  interface ContextSnippetOptions {
@@ -595,10 +594,10 @@ interface ContextSnippetOptions {
595
594
  * for await (const chunk of agent.prompt(context ? `${context}\n\n${userMessage}` : userMessage)) { ... }
596
595
  * ```
597
596
  */
598
- declare function buildContextSnippet(memory: Memory, ref: ResourceRef, opts?: ContextSnippetOptions): Promise<string>;
597
+ export declare function buildContextSnippet(memory: Memory, ref: ResourceRef, opts?: ContextSnippetOptions): Promise<string>;
599
598
  //#endregion
600
599
  //#region src/access-control.d.ts
601
- declare class MemoryAccessDeniedError extends Error {
600
+ export declare class MemoryAccessDeniedError extends Error {
602
601
  readonly teamId: string;
603
602
  constructor(teamId: string);
604
603
  }
@@ -625,7 +624,7 @@ interface TeamAccessChecker {
625
624
  * A `ResourceRef` with no `teamId` always passes through untouched — there's nothing to check
626
625
  * for an untenanted resource.
627
626
  */
628
- declare function withTeamAccessControl(provider: IWorkingMemoryProvider, checker: TeamAccessChecker): IWorkingMemoryProvider;
627
+ export declare function withTeamAccessControl(provider: IWorkingMemoryProvider, checker: TeamAccessChecker): IWorkingMemoryProvider;
629
628
  /**
630
629
  * Which of `ISemanticMemoryProvider`'s optional capability interfaces `withTeamAccessControlSemantic`
631
630
  * returns, computed from what the *input* provider actually implements — never the input's
@@ -646,6 +645,6 @@ type TeamGuardedSemanticProvider<T extends ISemanticMemoryProvider> = T extends
646
645
  * `compactSemanticMemory()` and `Memory.fork()`'s batched-embed path keep working through the
647
646
  * wrapper. See `TeamGuardedSemanticProvider` for why the return type is never just `T`.
648
647
  */
649
- declare function withTeamAccessControlSemantic<T extends ISemanticMemoryProvider>(provider: T, checker: TeamAccessChecker): TeamGuardedSemanticProvider<T>;
648
+ export declare function withTeamAccessControlSemantic<T extends ISemanticMemoryProvider>(provider: T, checker: TeamAccessChecker): TeamGuardedSemanticProvider<T>;
650
649
  //#endregion
651
- export { type AutoCompactOptions, type CompactionOptions, type CompactionResult, type ContextSnippetOptions, type EmbeddingProvider, type EpisodicBranch, type EpisodicRecallOptions, type EpisodicTreeOptions, type ForkMemoryResult, type IBulkSemanticMemoryProvider, type IPrunableSemanticMemoryProvider, type ISemanticMemoryProvider, type IWorkingMemoryProvider, InMemorySemanticMemoryProvider, InMemoryWorkingMemoryProvider, type LastCheckpointRecord, Memory, MemoryAccessDeniedError, type MemoryCapability, MemoryCapabilityError, type MemoryFact, type MemoryLifecycleHooksOptions, type MemoryOptions, type MemoryTool, type RememberedFact, type ResourceRef, type SandboxSessionRef, type SchemaValidator, SchemaWorkingMemory, type SemanticFactRow, type TeamAccessChecker, buildContextSnippet, compactSemanticMemory, cosineSimilarity, createMemoryLifecycleHooks, createMemoryTools, episodicRecall, episodicTree, factFromRow, isBulkRememberable, isPrunable, scopeKey, withTeamAccessControl, withTeamAccessControlSemantic };
650
+ export type { AutoCompactOptions, CompactionOptions, CompactionResult, ContextSnippetOptions, EmbeddingProvider, EpisodicBranch, EpisodicRecallOptions, EpisodicTreeOptions, ForkMemoryResult, IBulkSemanticMemoryProvider, IPrunableSemanticMemoryProvider, ISemanticMemoryProvider, IWorkingMemoryProvider, LastCheckpointRecord, MemoryCapability, MemoryFact, MemoryLifecycleHooksOptions, MemoryOptions, MemoryTool, RememberedFact, ResourceRef, SandboxSessionRef, SchemaValidator, SemanticFactRow, TeamAccessChecker };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alineo-labs/memory",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,12 +29,12 @@
29
29
  "test:watch": "vitest"
30
30
  },
31
31
  "dependencies": {
32
- "@alineo-labs/core": "0.3.0"
32
+ "@alineo-labs/core": "0.4.1"
33
33
  },
34
34
  "devDependencies": {
35
- "bun-types": "1.3.14",
36
- "tsdown": "0.22.3",
35
+ "bun-types": "1.4.2",
36
+ "tsdown": "0.23.0",
37
37
  "typescript": "6.0.3",
38
- "vitest": "4.1.9"
38
+ "vitest": "5.0.0"
39
39
  }
40
40
  }