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
new Memory(raw: RawMemory): Memory;Defined in: src/lib/classes/memory.ts:129
Parameters
| Parameter | Type | Description |
|---|---|---|
raw | RawMemory | The raw memory input validated against rawMemorySchema. |
Returns
Memory
Throws
@nhtio/adk!E_INVALID_INITIAL_MEMORY_VALUE when raw does not satisfy the schema.
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
confidence | readonly | number | undefined | Confidence score in the range [0, 1]. | src/lib/classes/memory.ts:110 |
content | readonly | Tokenizable | undefined | The memory content as a @nhtio/adk!Tokenizable for inline token estimation. | src/lib/classes/memory.ts:108 |
createdAt | readonly | DateTime | undefined | When this memory was first recorded. | src/lib/classes/memory.ts:114 |
id | readonly | string | undefined | Stable unique identifier for this memory entry. | src/lib/classes/memory.ts:106 |
importance | readonly | number | undefined | Importance score in the range [0, 1]. | src/lib/classes/memory.ts:112 |
updatedAt | readonly | DateTime | undefined | When this memory was last modified. | src/lib/classes/memory.ts:116 |
schema | static | ObjectSchema<RawMemory> | rawMemorySchema | Validator 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]()
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]()
static DECODE_METHOD: Memory;Defined in: src/lib/classes/memory.ts:206
Reconstruct a Memory from a Memory.[ENCODE_METHOD] snapshot.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | unknown | The snapshot produced by Memory.[ENCODE_METHOD]. |
Returns
Memory
A fully-validated Memory.
isMemory()
static isMemory(value: unknown): value is Memory;Defined in: src/lib/classes/memory.ts:102
Returns true if value is a Memory instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The 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.