yumoqing 5d4e70da8e feat: complete missing UI files and API endpoints for hermes-web-cli
- Added all missing .ui files referenced in index.ui:
  * new_session.ui
  * sessions.ui
  * services.ui
  * settings.ui
  * session_detail.ui
  * add_service.ui
  * edit_service.ui

- Created corresponding .dspy API endpoints with proper directory structure:
  * /hermes-web-cli/services → services/index.dspy
  * /hermes-web-cli/services/list → services/list/index.dspy
  * /hermes-web-cli/services/{id} → services/id/index.dspy
  * /hermes-web-cli/services/test?id={id} → services/test/index.dspy
  * /hermes-web-cli/sessions (POST) → sessions/index.dspy
  * /hermes-web-cli/sessions/messages?session_id={id} → sessions/messages/index.dspy
  * /hermes-web-cli/settings → settings/index.dspy
  * /hermes-web-cli/settings/reset → settings/reset/index.dspy

- Fixed UI styling to comply with bricks-framework (removed nested style objects)
- Updated URL references to use query parameters instead of path parameters for dynamic routes
- All files follow production-ready module development specifications
2026-04-22 11:22:44 +08:00

58 lines
1.8 KiB
Plaintext

# This is a controlled Python script (.dspy file) that will be executed by the web framework
# It provides the API endpoint for /hermes-web-cli/settings
import json
import os
def main():
"""Main function to handle the settings API request."""
try:
request_method = os.environ.get('REQUEST_METHOD', 'GET')
if request_method == 'GET':
# Return current settings (mock data for now)
settings = {
"default_service": "service-1",
"auto_save_sessions": True,
"session_timeout_minutes": 60,
"max_concurrent_sessions": 10
}
return {
"status": "success",
"data": settings
}
elif request_method == 'POST':
# Update settings
content_length = int(os.environ.get('CONTENT_LENGTH', 0))
if content_length > 0:
post_data = json.loads(os.read(0, content_length).decode('utf-8'))
# Here you would save the settings to database or config file
# For now, just return success
return {
"status": "success",
"message": "Settings updated successfully"
}
else:
return {
"status": "error",
"message": "No settings data provided"
}
else:
return {
"status": "error",
"message": "Method not allowed"
}
except Exception as e:
return {
"status": "error",
"message": str(e),
"data": None
}
# Execute and return JSON response
result = main()
print(json.dumps(result, ensure_ascii=False))