fix(hooks,db,mcp,worker): add type safety and error handling (#21)

- [x] Add type checking and error handling for JSON type assertions in user-prompt hook
- [x] Add error handling for session update query in CreateSDKSession
- [x] Update MCP tool description to reference sqlite-vec instead of ChromaDB
- [x] Fix MinConfidence sentinel value check from 0 to -1
- [x] Pass project parameter to vector search filter in handleSearchByPrompt
- [x] Return empty map instead of nil for successful responses without JSON body
This commit is contained in:
2026-01-09 22:17:05 +00:00
committed by GitHub
parent e0218c2bd4
commit e07d4174de
5 changed files with 23 additions and 9 deletions
+12 -2
View File
@@ -94,8 +94,18 @@ func handleUserPrompt(ctx *hooks.HookContext, input *Input) (string, error) {
return "", nil
}
sessionID := int64(result["sessionDbId"].(float64))
promptNumber := int(result["promptNumber"].(float64))
// Safely extract session ID and prompt number with type checking
sessionDbIdRaw, ok := result["sessionDbId"].(float64)
if !ok {
return "", fmt.Errorf("invalid or missing sessionDbId in response")
}
sessionID := int64(sessionDbIdRaw)
promptNumberRaw, ok := result["promptNumber"].(float64)
if !ok {
return "", fmt.Errorf("invalid or missing promptNumber in response")
}
promptNumber := int(promptNumberRaw)
fmt.Fprintf(os.Stderr, "[user-prompt] Session %d, prompt #%d\n", sessionID, promptNumber)