Class: Thought
Defined in: src/lib/classes/thought.ts:198
An immutable, validated internal reasoning trace produced by an agent.
Remarks
Represents an agent's internal thinking — distinct from @nhtio/adk!Message (which is part of the visible conversation) and never shown to end users directly. Carries an identity so reasoning traces can be attributed to a specific agent in multi-agent conversations. Constructed from a RawThought via rawThoughtSchema. The content field is always a @nhtio/adk!Tokenizable so token cost can be estimated inline — including when the raw input omitted it or supplied '', which is legal in opaque-replay mode and resolves to an empty @nhtio/adk!Tokenizable.
Constructors
Constructor
new Thought(raw: RawThought): Thought;Defined in: src/lib/classes/thought.ts:260
Parameters
| Parameter | Type | Description |
|---|---|---|
raw | RawThought | The raw thought input validated against rawThoughtSchema. |
Returns
Thought
Throws
@nhtio/adk!E_INVALID_INITIAL_THOUGHT_VALUE when raw does not satisfy the schema.
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
content | readonly | Tokenizable | undefined | The reasoning content as a @nhtio/adk!Tokenizable for inline token estimation. Remarks Never undefined — an opaque thought constructed without prose carries an empty @nhtio/adk!Tokenizable here, so readers need no presence guard. | src/lib/classes/thought.ts:230 |
createdAt | readonly | DateTime | undefined | When this thought was recorded. | src/lib/classes/thought.ts:244 |
id | readonly | string | undefined | Stable unique identifier for this thought. | src/lib/classes/thought.ts:222 |
identity | readonly | Identity | undefined | The identity of the agent who produced this thought. | src/lib/classes/thought.ts:232 |
payload | readonly | unknown | undefined | Optional vendor-opaque payload that round-trips back to a matching model wire. See RawThought.payload. | src/lib/classes/thought.ts:237 |
replayCompatibility | readonly | string | undefined | undefined | Optional wire-shape identifier describing which adapter can safely replay this thought. See RawThought.replayCompatibility. | src/lib/classes/thought.ts:242 |
updatedAt | readonly | DateTime | undefined | When this thought was last modified. | src/lib/classes/thought.ts:246 |
schema | static | ObjectSchema<RawThought> | rawThoughtSchema | Validator schema that accepts a RawThought object. Remarks Reusable fragment for any schema that needs to validate or nest a thought entry. | src/lib/classes/thought.ts:205 |
Methods
[ENCODE_METHOD]()
ENCODE_METHOD: unknown;Defined in: src/lib/classes/thought.ts:336
Serialise this Thought into an @nhtio/encoder snapshot.
Returns
unknown
A RawThought-shaped snapshot.
Remarks
Emits a RawThought-shaped object; content is the live @nhtio/adk!Tokenizable, identity the live @nhtio/adk!Identity, and the temporal fields live Luxon DateTimes (the encoder recurses into each). The vendor-opaque payload is passed through as-is — if it holds a value the encoder cannot serialise, encode throws (standard encoder behaviour). Round-trips via Thought.[DECODE_METHOD], which re-validates through the constructor.
[DECODE_METHOD]()
static DECODE_METHOD: Thought;Defined in: src/lib/classes/thought.ts:354
Reconstruct a Thought from a Thought.[ENCODE_METHOD] snapshot.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | unknown | The snapshot produced by Thought.[ENCODE_METHOD]. |
Returns
Thought
A fully-validated Thought.
isThought()
static isThought(value: unknown): value is Thought;Defined in: src/lib/classes/thought.ts:217
Returns true if value is a Thought instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to test. |
Returns
value is Thought
true when value is a Thought instance.
Remarks
Uses @nhtio/adk!isInstanceOf for cross-realm safety — instanceof would fail for instances created in a different module copy or VM context.