Overview
The NAVAI frontend package provides utilities for working with route definitions. These functions enable fuzzy route resolution and generate formatted route descriptions for agent instructions.Import
NavaiRoute Type
Example
resolveNavaiRoute
Resolves a user input string to a route path using fuzzy matching.Signature
Parameters
User input to match against routes. Can be:
- Route path:
"/profile","/settings" - Route name:
"profile","settings" - Synonym:
"perfil","account" - Partial match:
"prof","sett"
Array of route definitions to search. Defaults to empty array.
Return Value
- Returns the matched route’s
pathif found - Returns
nullif no match is found
Matching Strategy
The function uses a multi-level matching strategy:- Exact path match: Input exactly matches a route’s path
- Exact name match: Input exactly matches a route’s name
- Exact synonym match: Input exactly matches any route synonym
- Partial name match: Input is contained in a route’s name
- Partial synonym match: Input is contained in any route synonym
Examples
Usage in Navigation
getNavaiRoutePromptLines
Generates formatted route descriptions for agent instructions.Signature
Parameters
Array of route definitions to format. Defaults to empty array.
Return Value
Array of formatted route description strings, one per route.Format:
"- {name} ({path})[, aliases: {synonyms}]"Examples
Usage with buildNavaiAgent
Complete Example
Normalization Details
Both functions use the same normalization for consistent matching:"Profile"→"profile""Configuración"→"configuracion""Mi Cuenta"→"mi cuenta"" Settings "→"settings"
Source Reference
resolveNavaiRoute:packages/voice-frontend/src/routes.ts:16getNavaiRoutePromptLines:packages/voice-frontend/src/routes.ts:35NavaiRoute:packages/voice-frontend/src/routes.ts:1
