Result Types
PersonaChatResult, AgentResponse, Episode, and PersonaSnapshot.
Result Types
Types returned by MolrooPersona operations.
import type {
PersonaChatResult,
AgentResponse,
Episode,
PersonaSnapshot,
} from '@molroo-io/sdk';PersonaChatResult
Result of persona.chat().
interface PersonaChatResult {
text: string;
response: AgentResponse;
state?: PersonaState;
updatedHistory: Message[];
}| Field | Type | Description |
|---|---|---|
text | string | LLM-generated response text |
response | AgentResponse | Emotion data, memory episode, social updates |
state | PersonaState? | Persona state at the time of interaction (when available) |
updatedHistory | Message[] | Updated conversation history including this turn. Manage externally for simple mode. |
Example:
let history: Message[] = [];
const result = await persona.chat('I brought you flowers!', { history });
console.log(result.text); // "Oh, how sweet of you!"
console.log(result.response.emotion.vad); // { V: 0.72, A: 0.55, D: 0.4 }
console.log(result.response.emotion.discrete.primary); // 'joy'
console.log(result.response.emotion.discrete.intensity); // 0.78
// Save history for next call
history = result.updatedHistory;AgentResponse
Emotion processing result returned by persona.perceive() and persona.event(). Also embedded in PersonaChatResult.
For the full type definition and field descriptions, see AgentResponse in Emotion Types.
Example:
const response = await persona.perceive('You broke your promise.', {
from: 'Alex',
appraisal: {
goal_relevance: 0.9,
goal_congruence: -0.8,
expectedness: 0.3,
controllability: 0.2,
agency: 0.9,
norm_compatibility: -0.7,
internal_standards: -0.6,
adjustment_potential: 0.3,
urgency: 0.7,
},
});
console.log(response.emotion.vad); // { V: -0.6, A: 0.7, D: -0.3 }
console.log(response.emotion.discrete.primary); // 'anger'
console.log(response.memoryEpisode?.content); // The interaction is stored as a memoryEpisode
A memory episode representing a single interaction or event.
For the full type definition, see Episode in Emotion Types.
PersonaSnapshot
Complete serialized state of a persona instance. Can be saved and restored via persona.getSnapshot() and persona.putSnapshot().
type PersonaSnapshot = Record<string, unknown>;The snapshot is an opaque record containing the full internal engine state. It is not intended for direct manipulation — use it for backup and restore only.
Example:
// Save
const snapshot = await persona.getSnapshot();
await saveToStorage(snapshot);
// Restore
const saved = await loadFromStorage();
await persona.putSnapshot(saved);