UNPKG

@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

1,540 lines (1,539 loc) • 39.4 kB
import type { CommandModule } from "yargs"; /** Space-separated form for the bash-completion script, kept in sync with DERIVED_PROVIDER_CHOICES by construction. */ export declare const BASH_COMPLETION_PROVIDERS: string; /** * CLI Command Factory for generate commands */ export declare class CLICommandFactory { /** * Normalize loop session variables before merging them into provider options. * * The CLI loop schema models some fields (e.g. `stopSequences`, * `enabledToolNames`) as a single comma-separated string for ergonomic * input, but providers expect `string[]`. Without conversion, * `set stopSequences a,b` would be sent as one stop token "a,b" instead * of two ("a", "b"); `set enabledToolNames read,write` would be cast to * a `string[]` containing the single literal "read,write" and silently * filter out every tool. This helper splits and trims those fields so * the spread into `enhancedOptions` produces the correct shape across * generate / batch / stream paths. */ private static normalizeLoopSessionVariables; static readonly commonOptions: { provider: { choices: string[]; default: string; description: string; alias: string; }; authMethod: { type: "string"; choices: string[]; default: string; description: string; }; subscriptionTier: { type: "string"; choices: string[]; description: string; }; enableBeta: { type: "boolean"; default: boolean; description: string; alias: string; }; image: { type: "string"; description: string; alias: string; }; csv: { type: "string"; description: string; alias: string; }; pdf: { type: "string"; description: string; }; "pdf-password": { type: "string"; description: string; }; video: { type: "string"; description: string; }; "video-frames": { type: "number"; description: string; }; "video-quality": { type: "number"; description: string; }; "video-format": { type: "string"; choices: string[]; default: string; description: string; }; "transcribe-audio": { type: "boolean"; default: boolean; description: string; }; file: { type: "string"; description: string; }; csvMaxRows: { type: "number"; default: number; description: string; }; csvFormat: { type: "string"; choices: string[]; default: string; description: string; }; "csv-encoding": { type: "string"; description: string; }; "csv-sanitize-names": { type: "boolean"; default: boolean; description: string; }; "csv-name-case": { type: "string"; choices: string[]; default: string; description: string; }; "csv-parse-timeout-ms": { type: "number"; description: string; }; "csv-skip-empty-lines": { type: "boolean"; default: boolean; description: string; }; model: { type: "string"; description: string; alias: string; }; temperature: { type: "number"; default: number; description: string; alias: string; }; maxTokens: { type: "number"; default: number; description: string; alias: string; }; system: { type: "string"; description: string; alias: string; }; toolRoot: { type: "string"; array: boolean; description: string; }; format: { choices: string[]; default: string; alias: string[]; description: string; }; output: { type: "string"; description: string; alias: string; }; imageOutput: { type: "string"; description: string; alias: string; }; timeout: { type: "number"; default: number; description: string; }; delay: { type: "number"; description: string; }; disableTools: { type: "boolean"; default: boolean; description: string; }; enableAnalytics: { type: "boolean"; default: boolean; description: string; }; enableEvaluation: { type: "boolean"; default: boolean; description: string; }; domain: { type: "string"; choices: string[]; description: string; alias: string; }; evaluationDomain: { type: "string"; description: string; }; toolUsageContext: { type: "string"; description: string; }; domainAware: { type: "boolean"; default: boolean; description: string; }; context: { type: "string"; description: string; }; debug: { type: "boolean"; alias: string[]; default: boolean; description: string; }; quiet: { type: "boolean"; alias: string; default: boolean; description: string; }; noColor: { type: "boolean"; default: boolean; description: string; }; configFile: { type: "string"; description: string; }; dryRun: { type: "boolean"; default: boolean; description: string; }; tts: { type: "boolean"; default: boolean; description: string; }; ttsVoice: { type: "string"; description: string; }; ttsProvider: { type: "string"; choices: string[]; description: string; }; ttsFormat: { type: "string"; choices: string[]; default: string; description: string; }; ttsSpeed: { type: "number"; default: number; description: string; }; ttsQuality: { type: "string"; choices: string[]; default: string; description: string; }; ttsOutput: { type: "string"; description: string; }; ttsPlay: { type: "boolean"; default: boolean; description: string; }; stt: { type: "boolean"; default: boolean; description: string; }; sttProvider: { type: "string"; choices: string[]; description: string; }; sttLanguage: { type: "string"; description: string; }; inputAudio: { type: "string"; description: string; }; outputMode: { type: "string"; choices: string[]; default: string; description: string; }; videoProvider: { type: "string"; choices: string[]; description: string; }; videoOutput: { type: "string"; alias: string; description: string; }; videoResolution: { type: "string"; choices: string[]; description: string; }; videoLength: { type: "number"; choices: number[]; description: string; }; videoAspectRatio: { type: "string"; choices: string[]; description: string; }; videoAudio: { type: "boolean"; description: string; }; avatarProvider: { type: "string"; choices: string[]; description: string; }; avatarImage: { type: "string"; description: string; }; avatarAudio: { type: "string"; description: string; }; avatarText: { type: "string"; description: string; }; avatarVoice: { type: "string"; description: string; }; avatarQuality: { type: "string"; choices: string[]; description: string; }; avatarFormat: { type: "string"; choices: string[]; description: string; }; avatarOutput: { type: "string"; description: string; }; musicProvider: { type: "string"; choices: string[]; description: string; }; musicDuration: { type: "number"; description: string; }; musicFormat: { type: "string"; choices: string[]; description: string; }; musicGenre: { type: "string"; description: string; }; musicMood: { type: "string"; description: string; }; musicTempo: { type: "number"; description: string; }; musicOutput: { type: "string"; description: string; }; pptPages: { type: "number"; alias: string; description: string; }; pptTheme: { type: "string"; choices: string[]; description: string; }; pptAudience: { type: "string"; choices: string[]; description: string; }; pptTone: { type: "string"; choices: string[]; description: string; }; pptOutput: { type: "string"; alias: string; description: string; }; pptAspectRatio: { type: "string"; choices: string[]; description: string; }; pptNoImages: { type: "boolean"; default: boolean; description: string; }; thinking: { alias: string; type: "boolean"; description: string; default: boolean; }; thinkingBudget: { type: "number"; description: string; default: number; }; thinkingLevel: { type: "string"; description: string; choices: readonly ["minimal", "low", "medium", "high"]; }; toolRouting: { type: "boolean"; description: string; }; toolRoutingTimeout: { type: "number"; description: string; alias: string; }; toolRoutingRouterProvider: { type: "string"; description: string; alias: string; }; toolRoutingRouterModel: { type: "string"; description: string; alias: string; }; toolRoutingRouterRegion: { type: "string"; description: string; alias: string; }; toolRoutingAlwaysInclude: { type: "array"; description: string; alias: string; string: boolean; }; toolRoutingServers: { type: "string"; description: string; alias: string; }; classifierRouter: { type: "boolean"; description: string; alias: string; }; classifierStrategy: { type: "string"; description: string; choices: readonly ["auto", "heuristic", "llm", "jev"]; alias: string; }; classifierMinUpgradeConfidence: { type: "number"; description: string; alias: string; }; classifierMinDowngradeConfidence: { type: "number"; description: string; alias: string; }; classifierModelProvider: { type: "string"; description: string; alias: string; }; classifierModelName: { type: "string"; description: string; alias: string; }; classifierModelRegion: { type: "string"; description: string; alias: string; }; classifierPool: { type: "string"; description: string; alias: string; }; classifierTimeout: { type: "number"; description: string; alias: string; }; region: { type: "string"; description: string; alias: string; }; ragFiles: { type: "array"; description: string; alias: string; string: boolean; }; ragStrategy: { type: "string"; description: string; alias: string; choices: readonly ["character", "recursive", "sentence", "token", "markdown", "html", "json", "latex", "semantic", "semantic-markdown"]; }; ragChunkSize: { type: "number"; description: string; alias: string; default: number; }; ragChunkOverlap: { type: "number"; description: string; alias: string; default: number; }; ragTopK: { type: "number"; description: string; alias: string; default: number; }; piiRedact: { type: "boolean"; description: string; alias: string; default: boolean; }; piiTypes: { type: "string"; description: string; alias: string; }; piiAction: { type: "string"; description: string; alias: string; default: string; }; inputMaxLength: { type: "number"; description: string; alias: string; }; trimWhitespace: { type: "boolean"; description: string; alias: string; default: boolean; }; requireContent: { type: "boolean"; description: string; alias: string; default: boolean; }; outputMaxLength: { type: "number"; description: string; alias: string; }; outputMinLength: { type: "number"; description: string; alias: string; }; skillsDir: { type: "string"; description: string; alias: string; }; }; static readonly agentOptions: { agentMode: { type: "boolean"; description: string; }; maxSteps: { type: "number"; description: string; coerce: (value: unknown) => number; }; }; private static buildOptions; private static processCliImages; private static processCliCSVFiles; private static processCliPDFFiles; /** * Resolve the PDF decryption password, preferring the NEUROLINK_PDF_PASSWORD * env var over the `--pdf-password` flag. A plaintext CLI flag leaks into * shell history, `ps`/process listings, and CI logs — the env var avoids * that, matching the project's existing "credentials via env vars, not * flags" stance for the loop session. The flag stays supported (dropping it * would be a breaking CLI change), but using it prints a one-line stderr * warning recommending the env var instead. */ private static resolvePdfPassword; private static processCliFiles; private static processCliVideoFiles; private static processOptions; /** * Validate Anthropic subscription options * Ensures subscription tier is provided when using anthropic-subscription provider * or when oauth auth method is selected */ private static validateAnthropicSubscriptionOptions; private static handleOutput; /** * Helper method to handle TTS audio file output and playback * Saves audio to file when --tts-output flag is provided * Plays audio when --tts-play flag is provided */ private static handleTTSOutput; /** * Helper method to configure options for video generation mode * Auto-configures provider, model, and tools settings for video generation */ private static configureVideoMode; /** * Helper method to configure options for PPT generation mode * Auto-configures provider, model, and tools settings for presentation generation */ private static configurePPTMode; /** * Helper method to handle video file output * Saves generated video to file when --videoOutput flag is provided */ private static handleVideoOutput; /** * Helper method to handle avatar video file output. * Saves the generated avatar buffer to --avatarOutput path when provided. */ private static handleAvatarOutput; /** * Helper method to handle music audio file output. * Saves the generated music buffer to --musicOutput path when provided. */ private static handleMusicOutput; /** * Helper method to handle PPT file output * Displays PPT generation result info */ private static handlePPTOutput; private static isValidTokenUsage; private static normalizeTokenUsage; private static formatAnalyticsForTextMode; /** * Create the new primary 'generate' command */ static createGenerateCommand(): CommandModule; /** * Create stream command */ static createStreamCommand(): CommandModule; /** * Create batch command */ static createBatchCommand(): CommandModule; /** * Create provider commands */ static createProviderCommands(): CommandModule; /** * Create status command (alias for provider status) */ static createStatusCommand(): CommandModule; /** * Create models commands */ static createModelsCommands(): CommandModule; /** * Create MCP commands */ static createMCPCommands(): CommandModule; /** * Create discover command */ static createDiscoverCommand(): CommandModule; /** * Create agent commands for multi-agent orchestration */ static createAgentCommands(): CommandModule; /** * Create network commands for agent network orchestration */ static createNetworkCommands(): CommandModule; /** * Create memory commands */ static createMemoryCommands(): CommandModule; /** * Create skills commands — manage the local skills store * (list / show / search / create / delete). The store directory comes * from --skills-dir, NEUROLINK_SKILLS_DIR, or defaults to ./skills. */ static createSkillsCommands(): CommandModule; /** * Create config commands */ static createConfigCommands(): CommandModule; /** * Create validate command */ static createValidateCommand(): CommandModule; /** * Create get-best-provider command */ static createBestProviderCommand(): CommandModule; /** * Create Ollama commands */ static createOllamaCommands(): CommandModule; /** * Create setup command */ static createSetupCommand(): CommandModule; /** * Create SageMaker commands */ static createSageMakerCommands(): CommandModule; /** * Create completion command */ /** * Create loop command */ static createLoopCommand(): CommandModule; /** * Create completion command */ static createCompletionCommand(): CommandModule; /** * Execute provider status command */ private static executeProviderStatus; /** * Handle stdin input for generate command */ private static handleGenerateStdinInput; /** * Detect output mode (video, ppt, avatar, music, or text) based on CLI arguments */ private static detectGenerateOutputMode; /** * Process context for generation command */ private static processGenerateContext; /** * Build multimodal input from CLI arguments */ private static buildGenerateMultimodalInput; /** * Build CSV processor options from CLI argv (#1199). Shared by executeGenerate * and executeRealStream, which previously built byte-for-byte identical * objects independently. */ private static buildCsvOptionsFromArgv; /** * Build video processor options from CLI argv. Shared by executeGenerate, * executeStream and executeBatch, which previously built byte-for-byte * identical `videoOptions` objects independently (mirrors * {@link buildCsvOptionsFromArgv}). */ private static buildVideoOptionsFromArgv; /** * Build output configuration for generate request */ private static buildGenerateOutputConfig; /** * Handle successful generation result */ private static handleGenerateSuccess; /** * Execute the generate command */ private static executeGenerate; /** * Process context for streaming */ private static processStreamContext; /** * Execute dry-run streaming simulation */ private static executeDryRunStream; /** * Execute real streaming with timeout handling */ private static executeRealStream; /** * Process stream with timeout handling */ private static processStreamWithTimeout; /** * Display analytics and evaluation results */ private static displayStreamResults; /** * Handle stream output file writing and debug output */ private static handleStreamOutput; /** * Log debug information for stream result */ private static logStreamDebugInfo; /** * Handle stdin input for stream command */ private static handleStdinInput; /** * Execute the stream command */ private static executeStream; /** * Execute the batch command */ private static executeBatch; /** * Execute config export command */ private static executeConfigExport; /** * Execute get best provider command */ private static executeGetBestProvider; /** * Execute memory stats command */ /** * Resolve a standalone SkillsManager for the `skills` command group. * Directory precedence: --skills-dir > NEUROLINK_SKILLS_DIR > ./skills. * Cache is disabled so every command sees the directory's current state. */ private static resolveSkillsManagerForCli; private static executeSkillsList; private static executeSkillsShow; private static executeSkillsSearch; private static executeSkillsCreate; private static executeSkillsDelete; private static executeMemoryStats; /** * Execute memory history command */ private static executeMemoryHistory; /** * Execute memory clear command */ private static executeMemoryClear; /** * Execute memory list command */ private static executeMemoryList; /** * Resolve the requested export format for memory export commands. * The generic `--format` flag is typed for the generate/stream commands * (text/json/table/yaml), so read the raw value here and narrow it to the * two serializations the memory export path actually supports. */ private static resolveMemoryExportFormat; /** * Build a filesystem-safe filename for a session export. * * A session ID is caller-controlled data (it can come from Redis keys, user * input, etc.), so it must never be interpolated directly into a path — a * value like `../../etc/cron.d/x` would otherwise let export-all write * outside the chosen output directory. We reduce the ID to a bare basename * and allow-list its characters; callers additionally verify containment. */ private static sanitizeSessionExportFilename; /** * Serialize one or more session exports to CSV. Each message becomes a row; * session-level fields are repeated per row so the output is a flat, * spreadsheet-friendly table. */ private static sessionExportsToCsv; /** * Execute memory export command */ private static executeMemoryExport; /** * Execute memory export-all command */ private static executeMemoryExportAll; /** * Execute memory delete command */ private static executeMemoryDelete; /** * Execute completion command */ private static executeCompletion; /** * Flush Langfuse traces before exit */ private static flushLangfuseTraces; /** process.exit discards piped stdout queued past the 64 KiB buffer; resolves false if the reader stalls past the bound. */ private static flushStdout; /** Forced exit that fails loudly when queued output could not be delivered. */ private static exitAfterStdoutDrain; } /** Re-export of CLICommandFactory's static option definitions for direct import by tests/tooling. */ export declare const commonOptions: { provider: { choices: string[]; default: string; description: string; alias: string; }; authMethod: { type: "string"; choices: string[]; default: string; description: string; }; subscriptionTier: { type: "string"; choices: string[]; description: string; }; enableBeta: { type: "boolean"; default: boolean; description: string; alias: string; }; image: { type: "string"; description: string; alias: string; }; csv: { type: "string"; description: string; alias: string; }; pdf: { type: "string"; description: string; }; "pdf-password": { type: "string"; description: string; }; video: { type: "string"; description: string; }; "video-frames": { type: "number"; description: string; }; "video-quality": { type: "number"; description: string; }; "video-format": { type: "string"; choices: string[]; default: string; description: string; }; "transcribe-audio": { type: "boolean"; default: boolean; description: string; }; file: { type: "string"; description: string; }; csvMaxRows: { type: "number"; default: number; description: string; }; csvFormat: { type: "string"; choices: string[]; default: string; description: string; }; "csv-encoding": { type: "string"; description: string; }; "csv-sanitize-names": { type: "boolean"; default: boolean; description: string; }; "csv-name-case": { type: "string"; choices: string[]; default: string; description: string; }; "csv-parse-timeout-ms": { type: "number"; description: string; }; "csv-skip-empty-lines": { type: "boolean"; default: boolean; description: string; }; model: { type: "string"; description: string; alias: string; }; temperature: { type: "number"; default: number; description: string; alias: string; }; maxTokens: { type: "number"; default: number; description: string; alias: string; }; system: { type: "string"; description: string; alias: string; }; toolRoot: { type: "string"; array: boolean; description: string; }; format: { choices: string[]; default: string; alias: string[]; description: string; }; output: { type: "string"; description: string; alias: string; }; imageOutput: { type: "string"; description: string; alias: string; }; timeout: { type: "number"; default: number; description: string; }; delay: { type: "number"; description: string; }; disableTools: { type: "boolean"; default: boolean; description: string; }; enableAnalytics: { type: "boolean"; default: boolean; description: string; }; enableEvaluation: { type: "boolean"; default: boolean; description: string; }; domain: { type: "string"; choices: string[]; description: string; alias: string; }; evaluationDomain: { type: "string"; description: string; }; toolUsageContext: { type: "string"; description: string; }; domainAware: { type: "boolean"; default: boolean; description: string; }; context: { type: "string"; description: string; }; debug: { type: "boolean"; alias: string[]; default: boolean; description: string; }; quiet: { type: "boolean"; alias: string; default: boolean; description: string; }; noColor: { type: "boolean"; default: boolean; description: string; }; configFile: { type: "string"; description: string; }; dryRun: { type: "boolean"; default: boolean; description: string; }; tts: { type: "boolean"; default: boolean; description: string; }; ttsVoice: { type: "string"; description: string; }; ttsProvider: { type: "string"; choices: string[]; description: string; }; ttsFormat: { type: "string"; choices: string[]; default: string; description: string; }; ttsSpeed: { type: "number"; default: number; description: string; }; ttsQuality: { type: "string"; choices: string[]; default: string; description: string; }; ttsOutput: { type: "string"; description: string; }; ttsPlay: { type: "boolean"; default: boolean; description: string; }; stt: { type: "boolean"; default: boolean; description: string; }; sttProvider: { type: "string"; choices: string[]; description: string; }; sttLanguage: { type: "string"; description: string; }; inputAudio: { type: "string"; description: string; }; outputMode: { type: "string"; choices: string[]; default: string; description: string; }; videoProvider: { type: "string"; choices: string[]; description: string; }; videoOutput: { type: "string"; alias: string; description: string; }; videoResolution: { type: "string"; choices: string[]; description: string; }; videoLength: { type: "number"; choices: number[]; description: string; }; videoAspectRatio: { type: "string"; choices: string[]; description: string; }; videoAudio: { type: "boolean"; description: string; }; avatarProvider: { type: "string"; choices: string[]; description: string; }; avatarImage: { type: "string"; description: string; }; avatarAudio: { type: "string"; description: string; }; avatarText: { type: "string"; description: string; }; avatarVoice: { type: "string"; description: string; }; avatarQuality: { type: "string"; choices: string[]; description: string; }; avatarFormat: { type: "string"; choices: string[]; description: string; }; avatarOutput: { type: "string"; description: string; }; musicProvider: { type: "string"; choices: string[]; description: string; }; musicDuration: { type: "number"; description: string; }; musicFormat: { type: "string"; choices: string[]; description: string; }; musicGenre: { type: "string"; description: string; }; musicMood: { type: "string"; description: string; }; musicTempo: { type: "number"; description: string; }; musicOutput: { type: "string"; description: string; }; pptPages: { type: "number"; alias: string; description: string; }; pptTheme: { type: "string"; choices: string[]; description: string; }; pptAudience: { type: "string"; choices: string[]; description: string; }; pptTone: { type: "string"; choices: string[]; description: string; }; pptOutput: { type: "string"; alias: string; description: string; }; pptAspectRatio: { type: "string"; choices: string[]; description: string; }; pptNoImages: { type: "boolean"; default: boolean; description: string; }; thinking: { alias: string; type: "boolean"; description: string; default: boolean; }; thinkingBudget: { type: "number"; description: string; default: number; }; thinkingLevel: { type: "string"; description: string; choices: readonly ["minimal", "low", "medium", "high"]; }; toolRouting: { type: "boolean"; description: string; }; toolRoutingTimeout: { type: "number"; description: string; alias: string; }; toolRoutingRouterProvider: { type: "string"; description: string; alias: string; }; toolRoutingRouterModel: { type: "string"; description: string; alias: string; }; toolRoutingRouterRegion: { type: "string"; description: string; alias: string; }; toolRoutingAlwaysInclude: { type: "array"; description: string; alias: string; string: boolean; }; toolRoutingServers: { type: "string"; description: string; alias: string; }; classifierRouter: { type: "boolean"; description: string; alias: string; }; classifierStrategy: { type: "string"; description: string; choices: readonly ["auto", "heuristic", "llm", "jev"]; alias: string; }; classifierMinUpgradeConfidence: { type: "number"; description: string; alias: string; }; classifierMinDowngradeConfidence: { type: "number"; description: string; alias: string; }; classifierModelProvider: { type: "string"; description: string; alias: string; }; classifierModelName: { type: "string"; description: string; alias: string; }; classifierModelRegion: { type: "string"; description: string; alias: string; }; classifierPool: { type: "string"; description: string; alias: string; }; classifierTimeout: { type: "number"; description: string; alias: string; }; region: { type: "string"; description: string; alias: string; }; ragFiles: { type: "array"; description: string; alias: string; string: boolean; }; ragStrategy: { type: "string"; description: string; alias: string; choices: readonly ["character", "recursive", "sentence", "token", "markdown", "html", "json", "latex", "semantic", "semantic-markdown"]; }; ragChunkSize: { type: "number"; description: string; alias: string; default: number; }; ragChunkOverlap: { type: "number"; description: string; alias: string; default: number; }; ragTopK: { type: "number"; description: string; alias: string; default: number; }; piiRedact: { type: "boolean"; description: string; alias: string; default: boolean; }; piiTypes: { type: "string"; description: string; alias: string; }; piiAction: { type: "string"; description: string; alias: string; default: string; }; inputMaxLength: { type: "number"; description: string; alias: string; }; trimWhitespace: { type: "boolean"; description: string; alias: string; default: boolean; }; requireContent: { type: "boolean"; description: string; alias: string; default: boolean; }; outputMaxLength: { type: "number"; description: string; alias: string; }; outputMinLength: { type: "number"; description: string; alias: string; }; skillsDir: { type: "string"; description: string; alias: string; }; };