Full programmatic API for the Timoro class — methods, events and TypeScript types.
import { Timoro } from 'timoro' const ai = new Timoro(config: TimoroConfig)
Initializes the Timoro engine: loads the native Rust binding, starts the event loop and indexes the knowledge base. Must be called before any other method.
ai.init(): Promise<void>
Starts the terminal watcher and autonomous agent. Spawns the configured process and reads stdout/stderr in real time. Blocks until stop() is called.
ai.watch(): Promise<void>
Queries the knowledge base and returns an LLM response grounded in your indexed project context.
ai.ask(query: string): Promise<string> // Example const answer = await ai.ask('How does the auth service work?')
Runs the security analysis engine. Behavior depends on pentester.mode in config.
ai.pentest(): Promise<void>
Re-indexes all configured knowledge sources. Use when you've added new files, updated the database or changed the config.
ai.index(): Promise<void>
Stops all watchers, releases the Rust native binding and shuts down gracefully.
ai.stop(): Promise<void>
ai.isInitialized(): boolean ai.isRunning(): boolean if (!ai.isInitialized()) await ai.init() if (!ai.isRunning()) await ai.watch()
Returns the logger instance for writing custom entries to .timoro/log.md.
const logger = ai.getLogger() await logger.info('Deployment started') await logger.securityFinding( 'high', 'SQL Injection', 'src/db.ts', 28, 'String concatenation in query', 'Use parameterized queries' )
All events are emitted during watch() and pentest().
ai.on('error-detected', (e) => { // e.file, e.line, e.column, e.message, e.stackTrace console.log(`Error in ${e.file}:${e.line}`) }) ai.on('fix-applied', (e) => { // e.file, e.line, e.before, e.after, e.diff console.log(`Fixed ${e.file}`) }) ai.on('pentest-finding', (e) => { // e.severity, e.type, e.file, e.description, e.recommendation console.log(`[${e.severity}] ${e.type}`) }) ai.on('indexed', (e) => { // e.totalDocuments, e.totalChunks, e.diskSize console.log(`Indexed ${e.totalDocuments} documents`) })
import { Timoro } from 'timoro' import config from './timoro.config' const ai = new Timoro(config) ai.on('error-detected', (e) => { console.log(`✗ ${e.file}:${e.line} — ${e.message}`) }) ai.on('fix-applied', (e) => { console.log(`✓ Fixed ${e.file}`) }) ai.on('pentest-finding', (e) => { console.log(`[${e.severity.toUpperCase()}] ${e.description}`) }) await ai.init() await ai.watch() // graceful shutdown process.on('SIGINT', async () => { await ai.stop() process.exit(0) })