Skip to content
2 min read · 480 words

Class: Memory

Defined in: src/lib/classes/memory.ts:82

An immutable, validated memory entry held by the agent.

Remarks

Constructed from a RawMemory via rawMemorySchema. All temporal fields are normalised to Luxon DateTime instances at construction time. The content field is always a @nhtio/adk!Tokenizable so callers can estimate token cost without an additional wrapping step.

Constructors

Constructor

ts
new Memory(raw: RawMemory): Memory;

Defined in: src/lib/classes/memory.ts:129

Parameters

ParameterTypeDescription
rawRawMemoryThe raw memory input validated against rawMemorySchema.

Returns

Memory

Throws

@nhtio/adk!E_INVALID_INITIAL_MEMORY_VALUE when raw does not satisfy the schema.

Properties

PropertyModifierTypeDefault valueDescriptionDefined in
confidencereadonlynumberundefinedConfidence score in the range [0, 1].src/lib/classes/memory.ts:110
contentreadonlyTokenizableundefinedThe memory content as a @nhtio/adk!Tokenizable for inline token estimation.src/lib/classes/memory.ts:108
createdAtreadonlyDateTimeundefinedWhen this memory was first recorded.src/lib/classes/memory.ts:114
idreadonlystringundefinedStable unique identifier for this memory entry.src/lib/classes/memory.ts:106
importancereadonlynumberundefinedImportance score in the range [0, 1].src/lib/classes/memory.ts:112
updatedAtreadonlyDateTimeundefinedWhen this memory was last modified.src/lib/classes/memory.ts:116
schemastaticObjectSchema<RawMemory>rawMemorySchemaValidator schema that accepts a RawMemory object. Remarks Reusable fragment for any schema that needs to validate or nest a memory entry — for example, a collection schema that holds an array of memories.src/lib/classes/memory.ts:90

Methods

[ENCODE_METHOD]()

ts
ENCODE_METHOD: unknown;

Defined in: src/lib/classes/memory.ts:189

Serialise this Memory into an @nhtio/encoder snapshot.

Returns

unknown

A RawMemory-shaped snapshot.

Remarks

Emits a RawMemory-shaped object; content is the live @nhtio/adk!Tokenizable and the temporal fields are live Luxon DateTime instances (the encoder recurses into both). Round-trips via Memory.[DECODE_METHOD], which re-validates through the constructor.


[DECODE_METHOD]()

ts
static DECODE_METHOD: Memory;

Defined in: src/lib/classes/memory.ts:206

Reconstruct a Memory from a Memory.[ENCODE_METHOD] snapshot.

Parameters

ParameterTypeDescription
dataunknownThe snapshot produced by Memory.[ENCODE_METHOD].

Returns

Memory

A fully-validated Memory.


isMemory()

ts
static isMemory(value: unknown): value is Memory;

Defined in: src/lib/classes/memory.ts:102

Returns true if value is a Memory instance.

Parameters

ParameterTypeDescription
valueunknownThe value to test.

Returns

value is Memory

true when value is a Memory instance.

Remarks

Uses @nhtio/adk!isInstanceOf for cross-realm safety — instanceof would fail for instances created in a different module copy or VM context.