Methods
# _buildSystemPrompt(userContext) → {string}
Build the system prompt for classification
Parameters:
| Name | Type | Description |
|---|---|---|
userContext |
Object
|
User context for personalization |
System prompt
string
# _enrichParams(toolName, params, userContext, originalQuery) → {Object}
Enrich parameters with user context
Parameters:
| Name | Type | Description |
|---|---|---|
toolName |
string
|
Tool being called |
params |
Object
|
Extracted parameters |
userContext |
Object
|
User context |
originalQuery |
string
|
Original user query (for keyword detection) |
Enriched parameters
Object
# _ensureInitialized()
Initialize the classifier with AI service Called lazily on first classification request
# async _extractSingleParam(query, paramName, toolName, userContext, collectedParams) → {Promise.<Object>}
Extract a single parameter value from user's follow-up answer
Parameters:
| Name | Type | Description |
|---|---|---|
query |
string
|
User's answer |
paramName |
string
|
Parameter being collected |
toolName |
string
|
Tool being called |
userContext |
Object
|
User context for date parsing |
collectedParams |
Object
|
Previously collected parameters |
Extracted parameter value
Promise.<Object>
# _getFollowUpQuestion(toolName, paramName, params) → {string}
Get follow-up question for a missing parameter
Parameters:
| Name | Type | Description |
|---|---|---|
toolName |
string
|
Tool being called |
paramName |
string
|
Missing parameter name |
params |
Object
|
Already collected parameters |
Follow-up question
string
# _getMissingParams(toolName, params) → {Array.<string>}
Check for missing required parameters
Parameters:
| Name | Type | Description |
|---|---|---|
toolName |
string
|
Tool being called |
params |
Object
|
Extracted parameters |
Array of missing parameter names
Array.<string>
# _isCancelIntent(query) → {boolean}
Check if user wants to cancel a pending action
Parameters:
| Name | Type | Description |
|---|---|---|
query |
string
|
User's query |
True if user wants to cancel
boolean
# _parseResponse(content, userContext, originalQuery) → {Object}
Parse the AI response into a structured result
Parameters:
| Name | Type | Description |
|---|---|---|
content |
string
|
AI response content |
userContext |
Object
|
User context for defaults |
originalQuery |
string
|
Original user query (for keyword detection) |
Parsed classification result
Object
# _sanitizeQuery(query) → {Object}
SECURITY: Sanitize user query to prevent prompt injection attacks P2-3: Enhanced to block dangerous patterns and sanitize suspicious ones
Parameters:
| Name | Type | Description |
|---|---|---|
query |
string
|
Raw user query |
Sanitization result
Object
# async classifyAndExtract(query, userContext, options) → {Promise.<Object>}
Classify a user query and extract parameters
Parameters:
| Name | Type | Description |
|---|---|---|
query |
string
|
User's natural language query |
userContext |
Object
|
User context (email, userId, apiKey) |
options |
Object
|
Additional options |
pendingAction |
Object
|
Pending action context from previous interaction |
Classification result
Promise.<Object>