@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
48 lines (47 loc) • 1.89 kB
JavaScript
/**
* Conversation Memory Types for NeuroLink
* Provides type-safe conversation storage and context management
*
* ## Timestamp Conventions
*
* NeuroLink uses two timestamp formats throughout the conversation system:
*
* ### Unix Milliseconds (number)
* Used for internal storage, event timestamps, and performance-critical operations.
* - `SessionMemory.createdAt` - Session creation time as Unix epoch milliseconds
* - `SessionMemory.lastActivity` - Last activity time as Unix epoch milliseconds
* - `SessionMemory.lastCountedAt` - Token count timestamp as Unix epoch milliseconds
* - `ConversationMemoryEvents.*.timestamp` - Event timestamps as Unix epoch milliseconds
* - `ChatMessage.metadata.timestamp` - Optional numeric timestamp for internal tracking
*
* Example: `1735689600000` represents January 1, 2025, 00:00:00 UTC
*
* ### ISO 8601 String (string)
* Used for human-readable fields and API responses.
* - `ChatMessage.timestamp` - Message timestamp as ISO 8601 string
* - `ConversationBase.createdAt` - Conversation creation as ISO 8601 string
* - `ConversationBase.updatedAt` - Last update as ISO 8601 string
* - `ConversationSummary.firstMessage.timestamp` - Message preview timestamp
* - `ConversationSummary.lastMessage.timestamp` - Message preview timestamp
*
* Example: `"2025-01-01T00:00:00.000Z"`
*
* ### Conversion Guidelines
* - Unix ms to ISO: `new Date(unixMs).toISOString()`
* - ISO to Unix ms: `new Date(isoString).getTime()`
* - Current time (Unix ms): `Date.now()`
* - Current time (ISO): `new Date().toISOString()`
*/
/**
* Error types specific to conversation memory
*/
export class ConversationMemoryError extends Error {
code;
details;
constructor(message, code, details) {
super(message);
this.code = code;
this.details = details;
this.name = "ConversationMemoryError";
}
}