Skip to content
2 min read · 354 words

Class: Memory

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;

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 valueDescription
confidencereadonlynumberundefinedConfidence score in the range [0, 1].
contentreadonlyTokenizableundefinedThe memory content as a @nhtio/adk!Tokenizable for inline token estimation.
createdAtreadonlyDateTimeundefinedWhen this memory was first recorded.
idreadonlystringundefinedStable unique identifier for this memory entry.
importancereadonlynumberundefinedImportance score in the range [0, 1].
updatedAtreadonlyDateTimeundefinedWhen this memory was last modified.
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.

Methods

isMemory()

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

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.