Complete API documentation for RecCall's Universal Context Management System.
🚀 New in v2.0: Universal Context System with ML-powered context generation and semantic search. See Universal Context System Guide for complete documentation.
The main engine class that orchestrates all RecCall operations.
import { CoreEngine } from 'reccall/core';
const engine = new CoreEngine();
await engine.initialize();Initialize the core engine with optional configuration.
Parameters:
config(optional): Partial configuration object
Example:
await engine.initialize({
storagePath: '/custom/path',
repositoryUrl: 'https://custom-repo.com',
cacheTtl: 3600
});Record a new shortcut with context.
Parameters:
shortcut: Unique identifier for the shortcutcontext: Context/instructions to store
Throws:
RecCallErrorwith codeDUPLICATE_ERRORif shortcut already existsRecCallErrorwith codeVALIDATION_ERRORif shortcut ID is invalid
Example:
await engine.record('react-component' as ShortcutId, 'Create React components with TypeScript');Retrieve context for a shortcut.
Parameters:
shortcut: Shortcut identifier
Returns:
Promise<string>: The stored context
Throws:
RecCallErrorwith codeNOT_FOUND_ERRORif shortcut doesn't exist
Example:
const context = await engine.call('react-component' as ShortcutId);
console.log(context); // "Create React components with TypeScript"List all stored shortcuts.
Returns:
Promise<Shortcut[]>: Array of shortcut objects
Example:
const shortcuts = await engine.list();
console.log(shortcuts);
// [
// { shortcut: 'react-component', context: 'Create React components...' },
// { shortcut: 'api-endpoint', context: 'Create REST API endpoints...' }
// ]Update an existing shortcut's context.
Parameters:
shortcut: Shortcut identifiercontext: New context/instructions
Throws:
RecCallErrorwith codeNOT_FOUND_ERRORif shortcut doesn't exist
Example:
await engine.update('react-component' as ShortcutId, 'Updated React component instructions');Delete a shortcut (idempotent operation).
Parameters:
shortcut: Shortcut identifier
Example:
await engine.delete('react-component' as ShortcutId);Delete all shortcuts with confirmation.
Example:
await engine.purge();Search shortcuts by content.
Parameters:
query: Search query string
Returns:
Promise<Shortcut[]>: Matching shortcuts
Example:
const results = await engine.search('react');
console.log(results); // All shortcuts containing 'react'Install a recipe from a repository.
Parameters:
repositoryUrl: Repository URLshortcut: Recipe shortcut identifier
Throws:
RecCallErrorwith codeREPOSITORY_ERRORif repository is unavailableRecCallErrorwith codeNOT_FOUND_ERRORif recipe doesn't exist
Example:
await engine.installRecipe('https://contexts.reccaller.ai/' as RepositoryUrl, 'sync-main' as ShortcutId);List available recipes from a repository.
Parameters:
repositoryUrl: Repository URL
Returns:
Promise<Recipe[]>: Available recipes
Example:
const recipes = await engine.listRecipes('https://contexts.reccaller.ai/' as RepositoryUrl);
console.log(recipes);Search recipes in a repository.
Parameters:
repositoryUrl: Repository URLquery: Search query
Returns:
Promise<Recipe[]>: Matching recipes
Example:
const results = await engine.searchRecipes('https://contexts.reccaller.ai/' as RepositoryUrl, 'git');Reload starter pack recipes.
Example:
await engine.reloadStarterPack();Dependency injection container for managing services.
import { diContainer, TOKENS } from 'reccall/core';Initialize the container with all dependencies.
Example:
await diContainer.initialize();Get a service from the container.
Parameters:
token: Service token
Returns:
- Service instance
Example:
const engine = diContainer.get<ICoreEngine>(TOKENS.CORE_ENGINE);Register a custom service.
Parameters:
token: Service tokenimplementation: Service implementation class
Example:
diContainer.register(TOKENS.CONTEXT_STORAGE, RedisStorage);Register a custom instance.
Parameters:
token: Service tokeninstance: Service instance
Example:
diContainer.registerInstance(TOKENS.CACHE_MANAGER, customCacheManager);export const TOKENS = {
CORE_ENGINE: 'ICoreEngine',
CONTEXT_STORAGE: 'IContextStorage',
REPOSITORY_CLIENT: 'IRepositoryClient',
CACHE_MANAGER: 'ICacheManager',
RECIPE_VALIDATOR: 'IRecipeValidator',
} as const;Create a core engine instance with dependency injection.
Returns:
Promise<ICoreEngine>: Configured core engine
Example:
const engine = await createCoreEngine();Create a CLI adapter instance.
Returns:
Promise<CLIAdapter>: Configured CLI adapter
Example:
const adapter = await createCLIAdapter();Create an MCP adapter instance.
Returns:
Promise<MCPAdapter>: Configured MCP adapter
Example:
const adapter = await createMCPAdapter();Structured logging and performance monitoring.
import { telemetryManager } from 'reccall/core';Log a custom event.
Parameters:
event: Event object with timestamp, properties, etc.
Example:
telemetryManager.logEvent({
event: 'custom.operation',
timestamp: Date.now(),
properties: { userId: '123', action: 'create' }
});Log an error with context.
Parameters:
error: Error objectcontext: Additional context
Example:
telemetryManager.logError(error, { operation: 'record', shortcut: 'test' });Log performance metrics.
Parameters:
operation: Operation nameduration: Duration in millisecondsproperties: Additional properties
Example:
telemetryManager.logPerformance('shortcut.record', 150, { shortcutCount: 10 });Update current metrics.
Parameters:
metrics: Partial metrics object
Example:
telemetryManager.updateMetrics({
shortcutsCount: 25,
cacheHitRate: 0.85
});Get current metrics.
Returns:
Metrics: Current metrics object
Example:
const metrics = telemetryManager.getMetrics();
console.log(metrics.shortcutsCount);Automatically monitor method performance.
Example:
@Performance('my-operation')
async myMethod() {
// Method execution is automatically timed
}Automatically log method errors.
Example:
@LogErrors({ operation: 'record' })
async recordShortcut() {
// Errors are automatically logged with context
}Centralized configuration management.
import { configManager } from 'reccall/core';Initialize configuration with optional overrides.
Parameters:
config: Partial configuration object
Example:
await configManager.initialize({
storagePath: '/custom/path',
repositoryUrl: 'https://custom-repo.com'
});Get current configuration.
Returns:
CoreConfig: Current configuration
Example:
const config = configManager.getConfig();
console.log(config.storagePath);Check if repository is enabled.
Returns:
boolean: Repository enabled status
Example:
if (configManager.isRepositoryEnabled()) {
await engine.listRecipes(repositoryUrl);
}Check if telemetry is enabled.
Returns:
boolean: Telemetry enabled status
Example:
if (configManager.isTelemetryEnabled()) {
telemetryManager.logEvent({ event: 'test' });
}// Branded types for type safety
export type ShortcutId = string & { readonly __brand: 'ShortcutId' };
export type RepositoryUrl = string & { readonly __brand: 'RepositoryUrl' };
// Core data structures
export interface Shortcut {
shortcut: ShortcutId;
context: string;
}
export interface Recipe {
name: string;
shortcut: ShortcutId;
description: string;
file: string;
category: string;
}
export interface RepositoryManifest {
shortcuts: Recipe[];
}
export interface CoreConfig {
storagePath: string;
repositoryUrl: RepositoryUrl;
cacheTtl: number;
cacheDirectory: string;
enableTelemetry: boolean;
enableRepository: boolean;
}
export interface PlatformContext {
platform: string;
capabilities: PlatformCapabilities;
config: Record<string, any>;
}
export interface PlatformCapabilities {
canRecord: boolean;
canCall: boolean;
canList: boolean;
canUpdate: boolean;
canDelete: boolean;
canPurge: boolean;
supportsRepository: boolean;
}export class RecCallError extends Error {
constructor(message: string, public code: string) {
super(message);
this.name = 'RecCallError';
}
}
export class StorageError extends RecCallError {
constructor(message: string) {
super(message, 'STORAGE_ERROR');
this.name = 'StorageError';
}
}
export class RepositoryError extends RecCallError {
constructor(message: string) {
super(message, 'REPOSITORY_ERROR');
this.name = 'RepositoryError';
}
}
export class ValidationError extends RecCallError {
constructor(message: string) {
super(message, 'VALIDATION_ERROR');
this.name = 'ValidationError';
}
}Command-line interface adapter.
import { CLIAdapter } from 'reccall/adapters/cli';Initialize the CLI adapter.
Example:
const adapter = new CLIAdapter(engine);
await adapter.initialize();Create Commander.js program with all commands.
Returns:
Command: Configured Commander.js program
Example:
const program = adapter.createProgram();
await program.parseAsync();Model Context Protocol server adapter.
import { MCPAdapter } from 'reccall/adapters/mcp';Initialize the MCP adapter.
Example:
const adapter = new MCPAdapter(engine);
await adapter.initialize();Start the MCP server.
Example:
await adapter.start();The MCP adapter provides the following tools:
reccall_rec: Record a shortcutreccall_call: Call a shortcutreccall_list: List shortcutsreccall_update: Update a shortcutreccall_delete: Delete a shortcutreccall_purge: Purge all shortcutsreccall_search: Search shortcutsreccall_install: Install a recipereccall_list_repo: List repository recipesreccall_search_repo: Search repository recipesreccall_reload_starter_pack: Reload starter pack
// Content script API
class PerplexityRecCall {
async callShortcut(shortcut: string): Promise<void>
async recordShortcut(shortcut: string, context: string): Promise<void>
async deleteShortcut(shortcut: string): Promise<void>
async loadShortcuts(): Promise<void>
async saveShortcuts(): Promise<void>
}// Content script API
class SoraRecCall {
async callShortcut(shortcut: string): Promise<void>
async recordShortcut(shortcut: string, context: string): Promise<void>
async copyToClipboard(text: string): Promise<void>
async saveClipboardAsShortcut(text: string): Promise<void>
}import { createCoreEngine } from 'reccall/core';
async function main() {
const engine = await createCoreEngine();
await engine.initialize();
// Record a shortcut
await engine.record('react-component' as ShortcutId, 'Create React components with TypeScript');
// Call a shortcut
const context = await engine.call('react-component' as ShortcutId);
console.log(context);
// List all shortcuts
const shortcuts = await engine.list();
console.log(shortcuts);
}import { IContextStorage, ShortcutId } from 'reccall/core';
export class RedisStorage implements IContextStorage {
async record(shortcut: ShortcutId, context: string): Promise<void> {
// Redis implementation
}
async call(shortcut: ShortcutId): Promise<string> {
// Redis implementation
}
// ... other methods
}
// Register with DI container
diContainer.register(TOKENS.CONTEXT_STORAGE, RedisStorage);import { IPlatformAdapter } from 'reccall/core';
export class MyPlatformAdapter implements IPlatformAdapter {
readonly platform = 'my-platform';
readonly capabilities = {
canRecord: true,
canCall: true,
canList: true,
canUpdate: true,
canDelete: true,
canPurge: true,
supportsRepository: true
};
// ... implement all methods
}All API methods throw typed errors that extend RecCallError:
try {
await engine.record('test' as ShortcutId, 'context');
} catch (error) {
if (error instanceof RecCallError) {
console.error(`RecCall Error [${error.code}]: ${error.message}`);
}
}- Caching: All operations use multi-layer caching (memory + disk)
- Atomic Operations: File operations are atomic to prevent corruption
- Lazy Loading: Components are loaded on-demand
- Telemetry: Performance is automatically monitored with decorators
- Input Validation: All inputs are validated and sanitized
- Type Safety: Branded types prevent type confusion
- Error Handling: Comprehensive error handling prevents information leakage
- Recipe Validation: Repository recipes are validated for security