Overview
TheresolveNavaiBackendRuntimeConfig function scans your project directory for function modules and creates a runtime configuration with module loaders. It handles file system scanning, pattern matching, and exclusions to automatically discover callable function modules.
Function Signature
Parameters
Configuration options for runtime resolution.
Return Type
The resolved runtime configuration.
Pattern Matching
ThefunctionsFolders parameter supports multiple pattern types:
1. Exact Directory Match
src/ai/functions-modules/ and subdirectories.
2. Recursive Wildcard
src/ai/ and all nested subdirectories.
3. Glob Patterns
src/user/functions/src/admin/functions/src/api/functions/
4. Multiple Patterns
Example Usage
Environment Variables
The following environment variables are read whenenv is provided:
NAVAI_FUNCTIONS_FOLDERS- Comma-separated folder patterns to scanNAVAI_FUNCTIONS_BASE_DIR- Base directory for scanning (overridesbaseDiroption)
File Scanning Rules
- Automatic normalization: All paths are normalized (backslashes → forward slashes)
- Relative path resolution: Paths starting with
./or../are resolved - Declaration files: TypeScript
.d.tsfiles are automatically excluded - Extension matching: Case-insensitive extension matching
- Exclude patterns: Applied before include patterns
- Sorting: Results are sorted alphabetically by path
Default Behavior
If no patterns match any modules:- A warning is emitted
- The function falls back to
defaultFunctionsFolder - If the fallback also matches nothing, returns empty loaders
The function does not throw errors when no modules are found. Always check the
warnings array and the size of functionModuleLoaders to detect misconfiguration.Performance Considerations
- File system scanning is performed only once
- Module imports are lazy (not executed until loader is called)
- Exclude patterns prevent scanning large directories like
node_modules - Use specific patterns to limit the scan scope
Source Reference
Defined in:packages/voice-backend/src/runtime.ts:35