Creates a new Memory instance.
Configuration options for logging destinations and behavior
Log entry to database (Supabase).
The log entry to store in the database
Log entry to file.
The file path to write to
The log entry to write
Log entry using configured destinations. This is the main logging method that handles routing to database and/or file.
The log entry data (without id and timestamp)
Promise resolving to the generated log entry ID
const logId = await memory.log({
level: 'info',
message: 'Shinobi execution completed',
context: 'TravelExpert',
shinobi_id: 'shinobi-uuid',
execution_time: 2500,
estimated_cost: 0.001234,
metadata: {
katas_executed: 3,
total_tokens: 1500
}
});
Query logs from database with filtering options.
Object containing filter criteria
Optional
shinobi_Optional
kata_Optional
shuriken_Optional
level?: stringOptional
start_Optional
end_Optional
limit?: numberPromise resolving to array of matching log entries
// Get recent errors
const errors = await memory.queryLogs({
level: 'error',
limit: 5
});
// Get logs for specific Shinobi
const shinobiLogs = await memory.queryLogs({
shinobi_id: 'shinobi-uuid',
start_time: new Date(Date.now() - 24 * 60 * 60 * 1000) // Last 24 hours
});
Get execution statistics and analytics.
Optional filters to scope the statistics
Optional
shinobi_Optional
kata_Optional
start_Optional
end_Promise resolving to aggregated statistics
// Get overall statistics
const stats = await memory.getExecutionStats();
console.log(`Total executions: ${stats.total_executions}`);
console.log(`Total cost: $${stats.total_cost.toFixed(6)}`);
// Get statistics for specific Shinobi
const shinobiStats = await memory.getExecutionStats({
shinobi_id: 'shinobi-uuid'
});
Update configuration at runtime.
Partial configuration updates to apply
Persistent storage and logging system for the AI crew orchestration framework. Provides both database (Supabase) and file-based logging capabilities with comprehensive analytics and querying features.
Example