UNPKG

aetherlight-sdk

Version:

ÆtherLight Application Integration SDK - Add voice control to any application with natural language function calling

90 lines (89 loc) 2.74 kB
/** * ÆtherLight Application Integration SDK - WebSocket Client * * DESIGN DECISION: Decorator-based function registration (TypeScript) * WHY: Clean syntax, type-safe, auto-generates function metadata * * REASONING CHAIN: * 1. Developer installs @aetherlight/sdk via npm * 2. Connects to ÆtherLight daemon via WebSocket * 3. Registers functions with decorators/annotations * 4. ÆtherLight automatically handles voice → function calls * 5. Developer receives callbacks with extracted parameters * * PATTERN: Pattern-SDK-001 (Application Integration SDK) * PERFORMANCE: <10ms function invocation latency */ import { EventEmitter } from 'events'; import 'reflect-metadata'; export interface AetherlightConfig { host?: string; port?: number; autoReconnect?: boolean; reconnectInterval?: number; } export interface FunctionMetadata { description: string; examples: string[]; tags?: string[]; } export interface ParamMetadata { name: string; type: string; description: string; required?: boolean; } /** * ÆtherLight Client - WebSocket connection to ÆtherLight daemon * * DESIGN DECISION: EventEmitter base class for async events * WHY: Enables reactive programming patterns for function invocations */ export declare class AetherlightClient extends EventEmitter { private ws?; private config; private registeredFunctions; private requestId; private pendingRequests; constructor(config?: AetherlightConfig); /** * Connect to ÆtherLight daemon * * DESIGN DECISION: Promise-based connection with auto-reconnect * WHY: Enables await syntax + resilient to daemon restarts */ connect(): Promise<void>; /** * Register a class instance with voice-command decorated methods * * DESIGN DECISION: Reflect metadata for automatic parameter extraction * WHY: TypeScript decorators provide compile-time type information * * REASONING CHAIN: * 1. Iterate over instance methods * 2. Check for @Lumina decorator metadata * 3. Extract parameter metadata from @param decorators * 4. Send register_function JSON-RPC request * 5. Store function reference for later invocation */ register(instance: any): void; /** * Disconnect from ÆtherLight daemon */ disconnect(): void; /** * Handle incoming JSON-RPC message * * DESIGN DECISION: Support both requests and responses * WHY: Bidirectional communication (ÆtherLight can invoke our functions) */ private handleMessage; /** * Send JSON-RPC 2.0 request */ private sendRequest; /** * Send JSON-RPC 2.0 response */ private sendResponse; }