From 7d55ef754838b0e300d17dd978e19c4763f23d35 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 22 Apr 2026 13:20:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=89=8B=E5=8A=A8.dspy=E7=AB=AF=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3new=5Fsession.ui=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=A0=87=E5=87=86CRUD=E7=AB=AF=E7=82=B9=E5=92=8CtextField/valu?= =?UTF-8?q?eField=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/hermes_services/list/.index.dspy.swp | Bin 0 -> 12288 bytes wwwroot/hermes_services/list/index.dspy | 20 ----- wwwroot/new_session.ui | 4 +- wwwroot/renew.dspy | 79 ------------------- wwwroot/services/id/index.dspy | 45 ----------- wwwroot/services/index.dspy | 29 ------- wwwroot/services/list/index.dspy | 37 --------- wwwroot/services/test/index.dspy | 56 ------------- wwwroot/sessions/active.dspy | 29 ------- wwwroot/sessions/id.dspy | 45 ----------- wwwroot/sessions/index.dspy | 60 -------------- wwwroot/sessions/messages/index.dspy | 79 ------------------- wwwroot/sessions/recent.dspy | 29 ------- wwwroot/sessions/recent/index.dspy | 29 ------- wwwroot/settings/index.dspy | 58 -------------- wwwroot/settings/reset/index.dspy | 35 -------- 16 files changed, 3 insertions(+), 631 deletions(-) create mode 100644 wwwroot/hermes_services/list/.index.dspy.swp delete mode 100644 wwwroot/hermes_services/list/index.dspy delete mode 100644 wwwroot/renew.dspy delete mode 100644 wwwroot/services/id/index.dspy delete mode 100644 wwwroot/services/index.dspy delete mode 100644 wwwroot/services/list/index.dspy delete mode 100644 wwwroot/services/test/index.dspy delete mode 100644 wwwroot/sessions/active.dspy delete mode 100644 wwwroot/sessions/id.dspy delete mode 100644 wwwroot/sessions/index.dspy delete mode 100644 wwwroot/sessions/messages/index.dspy delete mode 100644 wwwroot/sessions/recent.dspy delete mode 100644 wwwroot/sessions/recent/index.dspy delete mode 100644 wwwroot/settings/index.dspy delete mode 100644 wwwroot/settings/reset/index.dspy diff --git a/wwwroot/hermes_services/list/.index.dspy.swp b/wwwroot/hermes_services/list/.index.dspy.swp new file mode 100644 index 0000000000000000000000000000000000000000..15267bf9367e889373f5533f691fddf205372975 GIT binary patch literal 12288 zcmeI2zi(495XW661_}sR*p75)g3_cd9YRIN7J&p6ltR@XirlJf~}UKXk0mU%6ufOn?b6 z0Vco%m;e)C0!)AjFaajO1pYw+G7#e11tFG(DR}z-zxVt9^CcnnNV}x>q(`JG=_cv> zMIpYD4oLf?H>5kH2~wH#gM57=eI&glCBC1LrbyRG=ShdO=K*P-^ntWT+9idgRZ@jC zM&iZyn;FuR3~*ds_CfJGl$4fhx3AJVgnjCLplVjQD9)2f0ksjB*O0~o#)3AGBvDTNo`h1gqWRO(R|4KEmCJIbPi=Tf^amN4v literal 0 HcmV?d00001 diff --git a/wwwroot/hermes_services/list/index.dspy b/wwwroot/hermes_services/list/index.dspy deleted file mode 100644 index 20b40a9..0000000 --- a/wwwroot/hermes_services/list/index.dspy +++ /dev/null @@ -1,20 +0,0 @@ -# Get hermes_services list for code dropdown -# This .dspy file uses functions released by load_hermes_web_cli() - -try: - # Use the function provided by hermes-web-cli module - services = get_all_services() - - # Format for code component (value, text pairs) - result = [] - for service in services: - result.append({ - "value": str(service.get('id')), - "text": service.get('name', f"Service {service.get('id')}") - }) - - # Return array directly for code component - return result -except Exception as e: - # On error or no data, return empty array - return [] \ No newline at end of file diff --git a/wwwroot/new_session.ui b/wwwroot/new_session.ui index 7452d30..2e1142b 100644 --- a/wwwroot/new_session.ui +++ b/wwwroot/new_session.ui @@ -26,7 +26,9 @@ "label": "Service", "uitype": "code", "required": true, - "data_url": "/hermes-web-cli/hermes_services/list/" + "data_url": "/hermes-web-cli/hermes_services/", + "textField": "name", + "valueField": "id" }, { "name": "initial_message", diff --git a/wwwroot/renew.dspy b/wwwroot/renew.dspy deleted file mode 100644 index f3dbe28..0000000 --- a/wwwroot/renew.dspy +++ /dev/null @@ -1,79 +0,0 @@ -# hermes-web-cli renew.dspy -# Business logic for service renewal and management - -import json -from datetime import datetime, timedelta - -def get_service_info(service_id: str) -> dict: - """Get detailed service information including status and usage stats""" - # This function will be called by the .ui files through data_url - from hermes_web_cli.init import get_service_by_id - service = get_service_by_id(service_id) - if not service: - return {"error": "Service not found"} - - # Add additional info like usage stats, renewal date, etc. - service_info = service.copy() - service_info.update({ - "renewal_date": (datetime.now() + timedelta(days=30)).isoformat(), - "usage_stats": { - "total_sessions": 150, - "active_sessions": 12, - "api_calls_today": 2340 - } - }) - return service_info - -def renew_service(service_id: str, renewal_period: str = "monthly") -> dict: - """Renew a Hermes service subscription""" - from hermes_web_cli.init import get_service_by_id - service = get_service_by_id(service_id) - if not service: - return {"success": False, "error": "Service not found"} - - # Calculate new renewal date based on period - now = datetime.now() - if renewal_period == "monthly": - new_renewal = now + timedelta(days=30) - elif renewal_period == "yearly": - new_renewal = now + timedelta(days=365) - else: - new_renewal = now + timedelta(days=30) - - # Update service in database (placeholder) - renewed_service = service.copy() - renewed_service.update({ - "renewal_date": new_renewal.isoformat(), - "status": "active", - "last_renewed": now.isoformat() - }) - - return {"success": True, "service": renewed_service} - -def get_renewal_options() -> list: - """Get available renewal options""" - return [ - {"id": "monthly", "name": "月度续费", "price": "¥299/月"}, - {"id": "quarterly", "name": "季度续费", "price": "¥799/季"}, - {"id": "yearly", "name": "年度续费", "price": "¥2899/年"} - ] - -def validate_renewal_request(service_id: str, payment_method: str) -> dict: - """Validate renewal request before processing""" - from hermes_web_cli.init import get_service_by_id - service = get_service_by_id(service_id) - if not service: - return {"valid": False, "error": "Service not found"} - - if payment_method not in ["credit_card", "alipay", "wechat_pay"]: - return {"valid": False, "error": "Invalid payment method"} - - return {"valid": True, "service_name": service["name"]} - -# Module exports for template access -__all__ = [ - 'get_service_info', - 'renew_service', - 'get_renewal_options', - 'validate_renewal_request' -] \ No newline at end of file diff --git a/wwwroot/services/id/index.dspy b/wwwroot/services/id/index.dspy deleted file mode 100644 index 6cfa809..0000000 --- a/wwwroot/services/id/index.dspy +++ /dev/null @@ -1,45 +0,0 @@ -# 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/services/{id} - -import json -import os -from hermes_web_cli.init import get_service_by_id - -def main(): - """Main function to handle the service by ID API request.""" - try: - # Get service ID from URL path - path_info = os.environ.get('PATH_INFO', '') - service_id = path_info.strip('/').split('/')[-1] if path_info else '' - - if not service_id: - return { - "status": "error", - "message": "Service ID is required", - "data": None - } - - # Get service by ID - service = get_service_by_id(service_id) - - if service: - return { - "status": "success", - "data": service - } - else: - return { - "status": "error", - "message": "Service not found", - "data": None - } - 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)) \ No newline at end of file diff --git a/wwwroot/services/index.dspy b/wwwroot/services/index.dspy deleted file mode 100644 index 3729c17..0000000 --- a/wwwroot/services/index.dspy +++ /dev/null @@ -1,29 +0,0 @@ -# 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/services - -import json -from hermes_web_cli.init import get_all_services - -def main(): - """Main function to handle the services API request.""" - try: - # Get all services from the module - services = get_all_services() - - # Return as JSON response - return { - "status": "success", - "data": services, - "total": len(services) - } - except Exception as e: - return { - "status": "error", - "message": str(e), - "data": [], - "total": 0 - } - -# Execute and return JSON response -result = main() -print(json.dumps(result, ensure_ascii=False)) \ No newline at end of file diff --git a/wwwroot/services/list/index.dspy b/wwwroot/services/list/index.dspy deleted file mode 100644 index dce6c84..0000000 --- a/wwwroot/services/list/index.dspy +++ /dev/null @@ -1,37 +0,0 @@ -# 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/services/list - -import json -from hermes_web_cli.init import get_all_services - -def main(): - """Main function to handle the services list API request for select dropdowns.""" - try: - # Get all services from the module - services = get_all_services() - - # Format for select dropdown (value, label pairs) - service_options = [] - for service in services: - service_options.append({ - "value": service.get("id"), - "label": service.get("name", f"Service {service.get('id')}") - }) - - # Return as JSON response - return { - "status": "success", - "data": service_options, - "total": len(service_options) - } - except Exception as e: - return { - "status": "error", - "message": str(e), - "data": [], - "total": 0 - } - -# Execute and return JSON response -result = main() -print(json.dumps(result, ensure_ascii=False)) \ No newline at end of file diff --git a/wwwroot/services/test/index.dspy b/wwwroot/services/test/index.dspy deleted file mode 100644 index 3936f69..0000000 --- a/wwwroot/services/test/index.dspy +++ /dev/null @@ -1,56 +0,0 @@ -# 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/services/test?id={service_id} - -import json -import os -from hermes_web_cli.init import get_service_by_id, test_service_connection -from urllib.parse import parse_qs - -def main(): - """Main function to handle the service connection test API request with query parameter.""" - try: - # Get service ID from query string - query_string = os.environ.get('QUERY_STRING', '') - if query_string: - query_params = parse_qs(query_string) - service_id = query_params.get('id', [None])[0] - else: - service_id = None - - if not service_id: - return { - "status": "error", - "message": "Service ID is required (use ?id= parameter)", - "data": None - } - - # Get service by ID - service = get_service_by_id(service_id) - if not service: - return { - "status": "error", - "message": "Service not found", - "data": None - } - - # Test connection - is_connected, status_message = test_service_connection(service.get("service_url", "")) - - return { - "status": "success", - "data": { - "is_connected": is_connected, - "status_message": status_message, - "service_id": service_id - } - } - 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)) \ No newline at end of file diff --git a/wwwroot/sessions/active.dspy b/wwwroot/sessions/active.dspy deleted file mode 100644 index 323f5da..0000000 --- a/wwwroot/sessions/active.dspy +++ /dev/null @@ -1,29 +0,0 @@ -# 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/sessions/active - -import json -from hermes_web_cli.init import get_active_sessions - -def main(): - """Main function to handle the active sessions API request.""" - try: - # Get active sessions from the module - sessions = get_active_sessions() - - # Return as JSON response - return { - "status": "success", - "data": sessions, - "total": len(sessions) - } - except Exception as e: - return { - "status": "error", - "message": str(e), - "data": [], - "total": 0 - } - -# Execute and return JSON response -result = main() -print(json.dumps(result, ensure_ascii=False)) \ No newline at end of file diff --git a/wwwroot/sessions/id.dspy b/wwwroot/sessions/id.dspy deleted file mode 100644 index e0cb098..0000000 --- a/wwwroot/sessions/id.dspy +++ /dev/null @@ -1,45 +0,0 @@ -# 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/sessions/{id} - -import json -import os -from hermes_web_cli.init import get_session_by_id - -def main(): - """Main function to handle the session by ID API request.""" - try: - # Get session ID from URL path - path_info = os.environ.get('PATH_INFO', '') - session_id = path_info.strip('/').split('/')[-1] if path_info else '' - - if not session_id: - return { - "status": "error", - "message": "Session ID is required", - "data": None - } - - # Get session by ID - session = get_session_by_id(session_id) - - if session: - return { - "status": "success", - "data": session - } - else: - return { - "status": "error", - "message": "Session not found", - "data": None - } - 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)) \ No newline at end of file diff --git a/wwwroot/sessions/index.dspy b/wwwroot/sessions/index.dspy deleted file mode 100644 index 85851a7..0000000 --- a/wwwroot/sessions/index.dspy +++ /dev/null @@ -1,60 +0,0 @@ -# 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/sessions (POST to create) - -import json -import os -from hermes_web_cli.init import create_session - -def main(): - """Main function to handle the create session API request.""" - try: - # Get request method - request_method = os.environ.get('REQUEST_METHOD', 'GET') - - if request_method == 'POST': - # Read POST data from stdin - 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')) - service_id = post_data.get('service_id') - initial_message = post_data.get('initial_message') - - if not service_id or not initial_message: - return { - "status": "error", - "message": "service_id and initial_message are required", - "data": None - } - - # Create session - session_id = create_session(service_id, initial_message) - - return { - "status": "success", - "data": { - "session_id": session_id, - "service_id": service_id - } - } - else: - return { - "status": "error", - "message": "No POST data provided", - "data": None - } - else: - return { - "status": "error", - "message": "Method not allowed", - "data": None - } - 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)) \ No newline at end of file diff --git a/wwwroot/sessions/messages/index.dspy b/wwwroot/sessions/messages/index.dspy deleted file mode 100644 index ece779f..0000000 --- a/wwwroot/sessions/messages/index.dspy +++ /dev/null @@ -1,79 +0,0 @@ -# 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/sessions/messages?session_id={session_id} - -import json -import os -from hermes_web_cli.init import get_session_messages, send_message_to_service -from urllib.parse import parse_qs - -def main(): - """Main function to handle the session messages API request with query parameter.""" - try: - # Get session ID from query string - query_string = os.environ.get('QUERY_STRING', '') - if query_string: - query_params = parse_qs(query_string) - session_id = query_params.get('session_id', [None])[0] - else: - session_id = None - - if not session_id: - return { - "status": "error", - "message": "Session ID is required (use ?session_id= parameter)", - "data": None - } - - request_method = os.environ.get('REQUEST_METHOD', 'GET') - - if request_method == 'GET': - # Get session messages - messages = get_session_messages(session_id) - return { - "status": "success", - "data": messages, - "total": len(messages) - } - - elif request_method == 'POST': - # Send new message - 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')) - message = post_data.get('message') - - if not message: - return { - "status": "error", - "message": "Message content is required", - "data": None - } - - # Here you would get the service_id from the session and send the message - # For now, just return success (in real implementation, call send_message_to_service) - return { - "status": "success", - "message": "Message sent successfully" - } - else: - return { - "status": "error", - "message": "No message 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)) \ No newline at end of file diff --git a/wwwroot/sessions/recent.dspy b/wwwroot/sessions/recent.dspy deleted file mode 100644 index 6f88769..0000000 --- a/wwwroot/sessions/recent.dspy +++ /dev/null @@ -1,29 +0,0 @@ -# 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/sessions/recent - -import json -from hermes_web_cli.init import get_recent_sessions - -def main(): - """Main function to handle the recent sessions API request.""" - try: - # Get recent sessions from the module - sessions = get_recent_sessions(limit=5) - - # Return as JSON response - return { - "status": "success", - "data": sessions, - "total": len(sessions) - } - except Exception as e: - return { - "status": "error", - "message": str(e), - "data": [], - "total": 0 - } - -# Execute and return JSON response -result = main() -print(json.dumps(result, ensure_ascii=False)) \ No newline at end of file diff --git a/wwwroot/sessions/recent/index.dspy b/wwwroot/sessions/recent/index.dspy deleted file mode 100644 index a1b204e..0000000 --- a/wwwroot/sessions/recent/index.dspy +++ /dev/null @@ -1,29 +0,0 @@ -# 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/sessions/recent - -import json -from hermes_web_cli.init import get_recent_sessions - -def main(): - """Main function to handle the recent sessions API request.""" - try: - # Get recent sessions from the module (limit to 5 as expected by the UI) - sessions = get_recent_sessions(limit=5) - - # Return as JSON response - return { - "status": "success", - "data": sessions, - "total": len(sessions) - } - except Exception as e: - return { - "status": "error", - "message": str(e), - "data": [], - "total": 0 - } - -# Execute and return JSON response -result = main() -print(json.dumps(result, ensure_ascii=False)) \ No newline at end of file diff --git a/wwwroot/settings/index.dspy b/wwwroot/settings/index.dspy deleted file mode 100644 index afbab89..0000000 --- a/wwwroot/settings/index.dspy +++ /dev/null @@ -1,58 +0,0 @@ -# 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)) \ No newline at end of file diff --git a/wwwroot/settings/reset/index.dspy b/wwwroot/settings/reset/index.dspy deleted file mode 100644 index 3b33ab9..0000000 --- a/wwwroot/settings/reset/index.dspy +++ /dev/null @@ -1,35 +0,0 @@ -# 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/reset - -import json -import os - -def main(): - """Main function to handle the reset settings API request.""" - try: - request_method = os.environ.get('REQUEST_METHOD', 'GET') - - if request_method == 'POST': - # Reset settings to defaults - # Here you would reset settings in database or config file - # For now, just return success - return { - "status": "success", - "message": "Settings reset to defaults successfully" - } - 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)) \ No newline at end of file