Skip to content
2 min read · 382 words

Class: Memory

Defined in: lib/classes/memory.ts:80

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: lib/classes/memory.ts:127

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].lib/classes/memory.ts:108
contentreadonlyTokenizableundefinedThe memory content as a @nhtio/adk!Tokenizable for inline token estimation.lib/classes/memory.ts:106
createdAtreadonlyDateTimeundefinedWhen this memory was first recorded.lib/classes/memory.ts:112
idreadonlystringundefinedStable unique identifier for this memory entry.lib/classes/memory.ts:104
importancereadonlynumberundefinedImportance score in the range [0, 1].lib/classes/memory.ts:110
updatedAtreadonlyDateTimeundefinedWhen this memory was last modified.lib/classes/memory.ts:114
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.lib/classes/memory.ts:88

Methods

isMemory()

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

Defined in: lib/classes/memory.ts:100

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.