diff --git a/json/executions_by_workflow.json b/json/executions_by_workflow.json index 6446908..bd8521b 100644 --- a/json/executions_by_workflow.json +++ b/json/executions_by_workflow.json @@ -3,24 +3,61 @@ "alias": "executions_by_workflow", "title": "Workflow Executions", "params": { - "sortby": ["created_at desc"], + "sortby": [ + "created_at desc" + ], "logined_userid": "user_id", - "confidential_fields": ["result_json", "error_message"], + "confidential_fields": [ + "result_json", + "error_message" + ], "browserfields": { - "exclouded": ["id", "user_id", "result_json", "error_message", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "result_json", + "error_message", + "created_at", + "updated_at" + ], "alters": { "execution_status": { "uitype": "code", "data": [ - {"value": "pending", "text": "Pending"}, - {"value": "running", "text": "Running"}, - {"value": "completed", "text": "Completed"}, - {"value": "failed", "text": "Failed"}, - {"value": "cancelled", "text": "Cancelled"} + { + "value": "pending", + "text": "Pending" + }, + { + "value": "running", + "text": "Running" + }, + { + "value": "completed", + "text": "Completed" + }, + { + "value": "failed", + "text": "Failed" + }, + { + "value": "cancelled", + "text": "Cancelled" + } ] } } }, - "editexclouded": ["id", "user_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/executions_by_workflow_create.dspy')}}", + "update_data_url": "{{entire_url('../api/executions_by_workflow_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/executions_by_workflow_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/harnessed_agent_config_view.json b/json/harnessed_agent_config_view.json index c1de688..81a79af 100644 --- a/json/harnessed_agent_config_view.json +++ b/json/harnessed_agent_config_view.json @@ -10,12 +10,27 @@ "auto_cleanup_enabled": { "uitype": "code", "data": [ - {"value": "1", "text": "Enabled"}, - {"value": "0", "text": "Disabled"} + { + "value": "1", + "text": "Enabled" + }, + { + "value": "0", + "text": "Disabled" + } ] } } }, - "editexclouded": ["id", "user_id", "created_at"] + "editexclouded": [ + "id", + "user_id", + "created_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/harnessed_agent_config_view_create.dspy')}}", + "update_data_url": "{{entire_url('../api/harnessed_agent_config_view_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/harnessed_agent_config_view_delete.dspy')}}" + } } } \ No newline at end of file diff --git a/json/hermes_executions_crud.json b/json/hermes_executions_crud.json index d8d3417..59b0ef7 100644 --- a/json/hermes_executions_crud.json +++ b/json/hermes_executions_crud.json @@ -2,24 +2,65 @@ "tblname": "hermes_executions", "title": "Execution Monitoring", "params": { - "sortby": ["created_at desc"], + "sortby": [ + "created_at desc" + ], "logined_userid": "user_id", - "confidential_fields": ["result_json", "error_message"], + "confidential_fields": [ + "result_json", + "error_message" + ], "browserfields": { - "exclouded": ["id", "user_id", "workflow_id", "task_id", "result_json", "error_message", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "workflow_id", + "task_id", + "result_json", + "error_message", + "created_at", + "updated_at" + ], "alters": { "execution_status": { "uitype": "code", "data": [ - {"value": "pending", "text": "Pending"}, - {"value": "running", "text": "Running"}, - {"value": "completed", "text": "Completed"}, - {"value": "failed", "text": "Failed"}, - {"value": "cancelled", "text": "Cancelled"} + { + "value": "pending", + "text": "Pending" + }, + { + "value": "running", + "text": "Running" + }, + { + "value": "completed", + "text": "Completed" + }, + { + "value": "failed", + "text": "Failed" + }, + { + "value": "cancelled", + "text": "Cancelled" + } ] } } }, - "editexclouded": ["id", "user_id", "workflow_id", "task_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "workflow_id", + "task_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_executions_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_executions_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_executions_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/hermes_executions_task_crud.json b/json/hermes_executions_task_crud.json index 7d32bd4..dfa934a 100644 --- a/json/hermes_executions_task_crud.json +++ b/json/hermes_executions_task_crud.json @@ -3,24 +3,59 @@ "alias": "hermes_executions_task", "title": "Task Executions", "params": { - "sortby": ["created_at desc"], + "sortby": [ + "created_at desc" + ], "logined_userid": "user_id", "confidential_fields": [], "browserfields": { - "exclouded": ["id", "user_id", "workflow_id", "task_id", "updated_at"], + "exclouded": [ + "id", + "user_id", + "workflow_id", + "task_id", + "updated_at" + ], "alters": { "execution_status": { "uitype": "code", "data": [ - {"value": "pending", "text": "Pending"}, - {"value": "running", "text": "Running"}, - {"value": "completed", "text": "Completed"}, - {"value": "failed", "text": "Failed"}, - {"value": "cancelled", "text": "Cancelled"} + { + "value": "pending", + "text": "Pending" + }, + { + "value": "running", + "text": "Running" + }, + { + "value": "completed", + "text": "Completed" + }, + { + "value": "failed", + "text": "Failed" + }, + { + "value": "cancelled", + "text": "Cancelled" + } ] } } }, - "editexclouded": ["id", "user_id", "workflow_id", "task_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "workflow_id", + "task_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_executions_task_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_executions_task_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_executions_task_delete.dspy')}}" + } } } \ No newline at end of file diff --git a/json/hermes_memory_crud.json b/json/hermes_memory_crud.json index d404db2..6040562 100644 --- a/json/hermes_memory_crud.json +++ b/json/hermes_memory_crud.json @@ -2,7 +2,10 @@ "tblname": "hermes_memory", "title": "Hermes Agent Intelligent Memory", "params": { - "sortby": ["priority desc", "last_accessed desc"], + "sortby": [ + "priority desc", + "last_accessed desc" + ], "logined_userid": "user_id", "confidential_fields": [], "editor": { @@ -17,25 +20,58 @@ ] }, "browserfields": { - "exclouded": ["id", "access_count", "last_accessed", "created_at", "updated_at"], + "exclouded": [ + "id", + "access_count", + "last_accessed", + "created_at", + "updated_at" + ], "alters": { "target": { "uitype": "code", "data": [ - {"value": "memory", "text": "System Memory"}, - {"value": "user", "text": "User Preferences"} + { + "value": "memory", + "text": "System Memory" + }, + { + "value": "user", + "text": "User Preferences" + } ] }, "priority": { "uitype": "code", "data": [ - {"value": "0", "text": "Low (0-29)"}, - {"value": "30", "text": "Medium (30-69)"}, - {"value": "70", "text": "High (70-100)"} + { + "value": "0", + "text": "Low (0-29)" + }, + { + "value": "30", + "text": "Medium (30-69)" + }, + { + "value": "70", + "text": "High (70-100)" + } ] } } }, - "editexclouded": ["id", "user_id", "access_count", "last_accessed", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "access_count", + "last_accessed", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_memory_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_memory_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_memory_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/hermes_remote_skills_crud.json b/json/hermes_remote_skills_crud.json index 45eda11..b5ec0fc 100644 --- a/json/hermes_remote_skills_crud.json +++ b/json/hermes_remote_skills_crud.json @@ -2,28 +2,66 @@ "tblname": "harnessed_remote_skills", "title": "Remote Skills Management", "params": { - "sortby": ["name"], + "sortby": [ + "name" + ], "logined_userid": "user_id", - "confidential_fields": ["ssh_key_path"], + "confidential_fields": [ + "ssh_key_path" + ], "browserfields": { - "exclouded": ["id", "user_id", "ssh_key_path", "last_deployed", "last_executed", "last_connected", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "ssh_key_path", + "last_deployed", + "last_executed", + "last_connected", + "created_at", + "updated_at" + ], "alters": { "enabled": { "uitype": "code", "data": [ - {"value": "1", "text": "Enabled"}, - {"value": "0", "text": "Disabled"} + { + "value": "1", + "text": "Enabled" + }, + { + "value": "0", + "text": "Disabled" + } ] }, "auth_method": { "uitype": "code", "data": [ - {"value": "key", "text": "SSH Key"}, - {"value": "password", "text": "Password"} + { + "value": "key", + "text": "SSH Key" + }, + { + "value": "password", + "text": "Password" + } ] } } }, - "editexclouded": ["id", "user_id", "last_deployed", "last_executed", "last_connected", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "last_deployed", + "last_executed", + "last_connected", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/harnessed_remote_skills_create.dspy')}}", + "update_data_url": "{{entire_url('../api/harnessed_remote_skills_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/harnessed_remote_skills_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/hermes_sessions_crud.json b/json/hermes_sessions_crud.json index 6c1ef7f..6c51f3d 100644 --- a/json/hermes_sessions_crud.json +++ b/json/hermes_sessions_crud.json @@ -2,21 +2,45 @@ "tblname": "hermes_sessions", "title": "Session Management", "params": { - "sortby": ["started_at desc"], + "sortby": [ + "started_at desc" + ], "logined_userid": "user_id", "confidential_fields": [], "browserfields": { - "exclouded": ["id", "user_id", "metadata_json", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "metadata_json", + "created_at", + "updated_at" + ], "alters": { "is_active": { "uitype": "code", "data": [ - {"value": "1", "text": "Active"}, - {"value": "0", "text": "Inactive"} + { + "value": "1", + "text": "Active" + }, + { + "value": "0", + "text": "Inactive" + } ] } } }, - "editexclouded": ["id", "user_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_sessions_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_sessions_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_sessions_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/hermes_skills_crud.json b/json/hermes_skills_crud.json index 34cafc9..25c6ed2 100644 --- a/json/hermes_skills_crud.json +++ b/json/hermes_skills_crud.json @@ -2,21 +2,45 @@ "tblname": "hermes_skills", "title": "Skills Management", "params": { - "sortby": ["name"], + "sortby": [ + "name" + ], "logined_userid": "user_id", "confidential_fields": [], "browserfields": { - "exclouded": ["id", "user_id", "content", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "content", + "created_at", + "updated_at" + ], "alters": { "is_active": { "uitype": "code", "data": [ - {"value": "1", "text": "Active"}, - {"value": "0", "text": "Inactive"} + { + "value": "1", + "text": "Active" + }, + { + "value": "0", + "text": "Inactive" + } ] } } }, - "editexclouded": ["id", "user_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_skills_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_skills_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_skills_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/hermes_tasks_crud.json b/json/hermes_tasks_crud.json index 26f229d..e7c3780 100644 --- a/json/hermes_tasks_crud.json +++ b/json/hermes_tasks_crud.json @@ -2,24 +2,61 @@ "tblname": "hermes_tasks", "title": "Task Management", "params": { - "sortby": ["order_index"], + "sortby": [ + "order_index" + ], "logined_userid": "user_id", - "confidential_fields": ["parameters_json"], + "confidential_fields": [ + "parameters_json" + ], "browserfields": { - "exclouded": ["id", "user_id", "workflow_id", "parameters_json", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "workflow_id", + "parameters_json", + "created_at", + "updated_at" + ], "alters": { "task_type": { "uitype": "code", "data": [ - {"value": "skill", "text": "Skill Execution"}, - {"value": "tool", "text": "Tool Execution"}, - {"value": "memory", "text": "Memory Operation"}, - {"value": "session_search", "text": "Session Search"}, - {"value": "custom", "text": "Custom Script"} + { + "value": "skill", + "text": "Skill Execution" + }, + { + "value": "tool", + "text": "Tool Execution" + }, + { + "value": "memory", + "text": "Memory Operation" + }, + { + "value": "session_search", + "text": "Session Search" + }, + { + "value": "custom", + "text": "Custom Script" + } ] } } }, - "editexclouded": ["id", "user_id", "workflow_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "workflow_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_tasks_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_tasks_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_tasks_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/hermes_tasks_workflow_crud.json b/json/hermes_tasks_workflow_crud.json index 9ad99f8..0c9a085 100644 --- a/json/hermes_tasks_workflow_crud.json +++ b/json/hermes_tasks_workflow_crud.json @@ -3,32 +3,65 @@ "alias": "hermes_tasks_workflow", "title": "Workflow Tasks", "params": { - "sortby": ["order_index"], + "sortby": [ + "order_index" + ], "logined_userid": "user_id", "confidential_fields": [], "browserfields": { - "exclouded": ["id", "user_id", "workflow_id", "updated_at"], + "exclouded": [ + "id", + "user_id", + "workflow_id", + "updated_at" + ], "alters": { "task_type": { "uitype": "code", "data": [ - {"value": "skill", "text": "Skill Execution"}, - {"value": "tool", "text": "Tool Execution"}, - {"value": "memory", "text": "Memory Operation"}, - {"value": "session_search", "text": "Session Search"}, - {"value": "custom", "text": "Custom Script"} + { + "value": "skill", + "text": "Skill Execution" + }, + { + "value": "tool", + "text": "Tool Execution" + }, + { + "value": "memory", + "text": "Memory Operation" + }, + { + "value": "session_search", + "text": "Session Search" + }, + { + "value": "custom", + "text": "Custom Script" + } ] } } }, - "editexclouded": ["id", "user_id", "workflow_id", "created_at", "updated_at"], + "editexclouded": [ + "id", + "user_id", + "workflow_id", + "created_at", + "updated_at" + ], "subtables": [ { "field": "id", "title": "Task Executions", - "url": "{{entire_url(hermes_executions_task)}}", + "url": "{{entire_url('hermes_executions_task')}}", "subtable": "hermes_executions" } - ] + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_tasks_workflow_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_tasks_workflow_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_tasks_workflow_delete.dspy')}}" + } } } \ No newline at end of file diff --git a/json/hermes_workflows_crud.json b/json/hermes_workflows_crud.json index 7e4cdfb..5abb6a5 100644 --- a/json/hermes_workflows_crud.json +++ b/json/hermes_workflows_crud.json @@ -2,44 +2,79 @@ "tblname": "hermes_workflows", "title": "Workflow Management", "params": { - "sortby": ["created_at desc"], + "sortby": [ + "created_at desc" + ], "logined_userid": "user_id", "confidential_fields": [], "browserfields": { - "exclouded": ["id", "user_id", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "created_at", + "updated_at" + ], "alters": { "workflow_type": { "uitype": "code", "data": [ - {"value": "sequential", "text": "Sequential"}, - {"value": "parallel", "text": "Parallel"}, - {"value": "hybrid", "text": "Hybrid"} + { + "value": "sequential", + "text": "Sequential" + }, + { + "value": "parallel", + "text": "Parallel" + }, + { + "value": "hybrid", + "text": "Hybrid" + } ] }, "status": { "uitype": "code", "data": [ - {"value": "active", "text": "Active"}, - {"value": "inactive", "text": "Inactive"}, - {"value": "archived", "text": "Archived"} + { + "value": "active", + "text": "Active" + }, + { + "value": "inactive", + "text": "Inactive" + }, + { + "value": "archived", + "text": "Archived" + } ] } } }, - "editexclouded": ["id", "user_id", "created_at", "updated_at"], + "editexclouded": [ + "id", + "user_id", + "created_at", + "updated_at" + ], "subtables": [ { "field": "id", "title": "Tasks", - "url": "{{entire_url(hermes_tasks_workflow)}}", + "url": "{{entire_url('hermes_tasks_workflow')}}", "subtable": "hermes_tasks" }, { "field": "id", "title": "Executions", - "url": "{{entire_url(hermes_executions_crud)}}", + "url": "{{entire_url('hermes_executions_crud')}}", "subtable": "hermes_executions" } - ] + ], + "editable": { + "new_data_url": "{{entire_url('../api/hermes_workflows_create.dspy')}}", + "update_data_url": "{{entire_url('../api/hermes_workflows_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/hermes_workflows_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/json/task_dependencies.json b/json/task_dependencies.json index 1cd292b..51aa447 100644 --- a/json/task_dependencies.json +++ b/json/task_dependencies.json @@ -2,23 +2,54 @@ "tblname": "task_dependencies", "title": "Task Dependencies", "params": { - "sortby": ["created_at desc"], + "sortby": [ + "created_at desc" + ], "logined_userid": "user_id", "confidential_fields": [], "browserfields": { - "exclouded": ["id", "user_id", "workflow_id", "created_at", "updated_at"], + "exclouded": [ + "id", + "user_id", + "workflow_id", + "created_at", + "updated_at" + ], "alters": { "dependency_type": { "uitype": "code", "data": [ - {"value": "completion", "text": "Completion"}, - {"value": "success", "text": "Success"}, - {"value": "failure", "text": "Failure"}, - {"value": "data_available", "text": "Data Available"} + { + "value": "completion", + "text": "Completion" + }, + { + "value": "success", + "text": "Success" + }, + { + "value": "failure", + "text": "Failure" + }, + { + "value": "data_available", + "text": "Data Available" + } ] } } }, - "editexclouded": ["id", "user_id", "workflow_id", "created_at", "updated_at"] + "editexclouded": [ + "id", + "user_id", + "workflow_id", + "created_at", + "updated_at" + ], + "editable": { + "new_data_url": "{{entire_url('../api/task_dependencies_create.dspy')}}", + "update_data_url": "{{entire_url('../api/task_dependencies_update.dspy')}}", + "delete_data_url": "{{entire_url('../api/task_dependencies_delete.dspy')}}" + } } -} +} \ No newline at end of file diff --git a/wwwroot/api/executions_by_workflow_create.dspy b/wwwroot/api/executions_by_workflow_create.dspy new file mode 100644 index 0000000..43ef12b --- /dev/null +++ b/wwwroot/api/executions_by_workflow_create.dspy @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + workflow_id = params_kw.get('workflow_id', '').strip() + task_id = params_kw.get('task_id', '').strip() + execution_status = params_kw.get('execution_status', '').strip() + start_time = params_kw.get('start_time', '').strip() + end_time = params_kw.get('end_time', '').strip() + duration_seconds = params_kw.get('duration_seconds', '').strip() + result_json = params_kw.get('result_json', '').strip() + error_message = params_kw.get('error_message', '').strip() + retry_count = params_kw.get('retry_count', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO executions_by_workflow (id, user_id, workflow_id, task_id, execution_status, start_time, end_time, duration_seconds, result_json, error_message, retry_count, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${workflow_id}$, ${task_id}$, ${execution_status}$, ${start_time}$, ${end_time}$, ${duration_seconds}$, ${result_json}$, ${error_message}$, ${retry_count}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'workflow_id': workflow_id, + 'task_id': task_id, + 'execution_status': execution_status, + 'start_time': start_time, + 'end_time': end_time, + 'duration_seconds': duration_seconds, + 'result_json': result_json, + 'error_message': error_message, + 'retry_count': retry_count, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Execution创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/executions_by_workflow_delete.dspy b/wwwroot/api/executions_by_workflow_delete.dspy new file mode 100644 index 0000000..d75acca --- /dev/null +++ b/wwwroot/api/executions_by_workflow_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM executions_by_workflow WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/executions_by_workflow_update.dspy b/wwwroot/api/executions_by_workflow_update.dspy new file mode 100644 index 0000000..259ef71 --- /dev/null +++ b/wwwroot/api/executions_by_workflow_update.dspy @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE executions_by_workflow SET workflow_id = ${workflow_id}$, task_id = ${task_id}$, execution_status = ${execution_status}$, start_time = ${start_time}$, end_time = ${end_time}$, duration_seconds = ${duration_seconds}$, result_json = ${result_json}$, error_message = ${error_message}$, retry_count = ${retry_count}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'workflow_id': workflow_id, + 'task_id': task_id, + 'execution_status': execution_status, + 'start_time': start_time, + 'end_time': end_time, + 'duration_seconds': duration_seconds, + 'result_json': result_json, + 'error_message': error_message, + 'retry_count': retry_count, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/harnessed_agent_config_create.dspy b/wwwroot/api/harnessed_agent_config_create.dspy new file mode 100644 index 0000000..b851f0c --- /dev/null +++ b/wwwroot/api/harnessed_agent_config_create.dspy @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Config create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + work_dir = params_kw.get('work_dir', '').strip() + skills_path = params_kw.get('skills_path', '').strip() + max_memory_tokens = params_kw.get('max_memory_tokens', '').strip() + default_priority = params_kw.get('default_priority', '').strip() + high_priority_threshold = params_kw.get('high_priority_threshold', '').strip() + low_priority_threshold = params_kw.get('low_priority_threshold', '').strip() + auto_cleanup_enabled = params_kw.get('auto_cleanup_enabled', '').strip() + min_retention_days = params_kw.get('min_retention_days', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO harnessed_agent_config (id, user_id, work_dir, skills_path, max_memory_tokens, default_priority, high_priority_threshold, low_priority_threshold, auto_cleanup_enabled, min_retention_days, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${work_dir}$, ${skills_path}$, ${max_memory_tokens}$, ${default_priority}$, ${high_priority_threshold}$, ${low_priority_threshold}$, ${auto_cleanup_enabled}$, ${min_retention_days}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'work_dir': work_dir, + 'skills_path': skills_path, + 'max_memory_tokens': max_memory_tokens, + 'default_priority': default_priority, + 'high_priority_threshold': high_priority_threshold, + 'low_priority_threshold': low_priority_threshold, + 'auto_cleanup_enabled': auto_cleanup_enabled, + 'min_retention_days': min_retention_days, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Config创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/harnessed_agent_config_delete.dspy b/wwwroot/api/harnessed_agent_config_delete.dspy new file mode 100644 index 0000000..4d623de --- /dev/null +++ b/wwwroot/api/harnessed_agent_config_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Config delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM harnessed_agent_config WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/harnessed_agent_config_update.dspy b/wwwroot/api/harnessed_agent_config_update.dspy new file mode 100644 index 0000000..a9de2b2 --- /dev/null +++ b/wwwroot/api/harnessed_agent_config_update.dspy @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Config update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE harnessed_agent_config SET work_dir = ${work_dir}$, skills_path = ${skills_path}$, max_memory_tokens = ${max_memory_tokens}$, default_priority = ${default_priority}$, high_priority_threshold = ${high_priority_threshold}$, low_priority_threshold = ${low_priority_threshold}$, auto_cleanup_enabled = ${auto_cleanup_enabled}$, min_retention_days = ${min_retention_days}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'work_dir': work_dir, + 'skills_path': skills_path, + 'max_memory_tokens': max_memory_tokens, + 'default_priority': default_priority, + 'high_priority_threshold': high_priority_threshold, + 'low_priority_threshold': low_priority_threshold, + 'auto_cleanup_enabled': auto_cleanup_enabled, + 'min_retention_days': min_retention_days, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/harnessed_remote_skills_create.dspy b/wwwroot/api/harnessed_remote_skills_create.dspy new file mode 100644 index 0000000..7562e66 --- /dev/null +++ b/wwwroot/api/harnessed_remote_skills_create.dspy @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Remote Skill create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + name = params_kw.get('name', '').strip() + host = params_kw.get('host', '').strip() + port = params_kw.get('port', '').strip() + username = params_kw.get('username', '').strip() + remote_path = params_kw.get('remote_path', '').strip() + auth_method = params_kw.get('auth_method', '').strip() + ssh_key_path = params_kw.get('ssh_key_path', '').strip() + description = params_kw.get('description', '').strip() + category = params_kw.get('category', '').strip() + version = params_kw.get('version', '').strip() + enabled = params_kw.get('enabled', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO harnessed_remote_skills (id, user_id, name, host, port, username, remote_path, auth_method, ssh_key_path, description, category, version, enabled, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${name}$, ${host}$, ${port}$, ${username}$, ${remote_path}$, ${auth_method}$, ${ssh_key_path}$, ${description}$, ${category}$, ${version}$, ${enabled}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'name': name, + 'host': host, + 'port': port, + 'username': username, + 'remote_path': remote_path, + 'auth_method': auth_method, + 'ssh_key_path': ssh_key_path, + 'description': description, + 'category': category, + 'version': version, + 'enabled': enabled, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Remote Skill创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/harnessed_remote_skills_delete.dspy b/wwwroot/api/harnessed_remote_skills_delete.dspy new file mode 100644 index 0000000..ce0cb69 --- /dev/null +++ b/wwwroot/api/harnessed_remote_skills_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Remote Skill delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM harnessed_remote_skills WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/harnessed_remote_skills_update.dspy b/wwwroot/api/harnessed_remote_skills_update.dspy new file mode 100644 index 0000000..11adc3b --- /dev/null +++ b/wwwroot/api/harnessed_remote_skills_update.dspy @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Remote Skill update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE harnessed_remote_skills SET name = ${name}$, host = ${host}$, port = ${port}$, username = ${username}$, remote_path = ${remote_path}$, auth_method = ${auth_method}$, ssh_key_path = ${ssh_key_path}$, description = ${description}$, category = ${category}$, version = ${version}$, enabled = ${enabled}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'name': name, + 'host': host, + 'port': port, + 'username': username, + 'remote_path': remote_path, + 'auth_method': auth_method, + 'ssh_key_path': ssh_key_path, + 'description': description, + 'category': category, + 'version': version, + 'enabled': enabled, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_executions_create.dspy b/wwwroot/api/hermes_executions_create.dspy new file mode 100644 index 0000000..b6e8100 --- /dev/null +++ b/wwwroot/api/hermes_executions_create.dspy @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + workflow_id = params_kw.get('workflow_id', '').strip() + task_id = params_kw.get('task_id', '').strip() + execution_status = params_kw.get('execution_status', '').strip() + start_time = params_kw.get('start_time', '').strip() + end_time = params_kw.get('end_time', '').strip() + duration_seconds = params_kw.get('duration_seconds', '').strip() + result_json = params_kw.get('result_json', '').strip() + error_message = params_kw.get('error_message', '').strip() + retry_count = params_kw.get('retry_count', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_executions (id, user_id, workflow_id, task_id, execution_status, start_time, end_time, duration_seconds, result_json, error_message, retry_count, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${workflow_id}$, ${task_id}$, ${execution_status}$, ${start_time}$, ${end_time}$, ${duration_seconds}$, ${result_json}$, ${error_message}$, ${retry_count}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'workflow_id': workflow_id, + 'task_id': task_id, + 'execution_status': execution_status, + 'start_time': start_time, + 'end_time': end_time, + 'duration_seconds': duration_seconds, + 'result_json': result_json, + 'error_message': error_message, + 'retry_count': retry_count, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Execution创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_executions_delete.dspy b/wwwroot/api/hermes_executions_delete.dspy new file mode 100644 index 0000000..02c2253 --- /dev/null +++ b/wwwroot/api/hermes_executions_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_executions WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_executions_task_create.dspy b/wwwroot/api/hermes_executions_task_create.dspy new file mode 100644 index 0000000..a1a20a0 --- /dev/null +++ b/wwwroot/api/hermes_executions_task_create.dspy @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + workflow_id = params_kw.get('workflow_id', '').strip() + task_id = params_kw.get('task_id', '').strip() + execution_status = params_kw.get('execution_status', '').strip() + start_time = params_kw.get('start_time', '').strip() + end_time = params_kw.get('end_time', '').strip() + duration_seconds = params_kw.get('duration_seconds', '').strip() + result_json = params_kw.get('result_json', '').strip() + error_message = params_kw.get('error_message', '').strip() + retry_count = params_kw.get('retry_count', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_executions_task (id, user_id, workflow_id, task_id, execution_status, start_time, end_time, duration_seconds, result_json, error_message, retry_count, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${workflow_id}$, ${task_id}$, ${execution_status}$, ${start_time}$, ${end_time}$, ${duration_seconds}$, ${result_json}$, ${error_message}$, ${retry_count}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'workflow_id': workflow_id, + 'task_id': task_id, + 'execution_status': execution_status, + 'start_time': start_time, + 'end_time': end_time, + 'duration_seconds': duration_seconds, + 'result_json': result_json, + 'error_message': error_message, + 'retry_count': retry_count, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Execution创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_executions_task_delete.dspy b/wwwroot/api/hermes_executions_task_delete.dspy new file mode 100644 index 0000000..cd4bb43 --- /dev/null +++ b/wwwroot/api/hermes_executions_task_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_executions_task WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_executions_task_update.dspy b/wwwroot/api/hermes_executions_task_update.dspy new file mode 100644 index 0000000..2d567e0 --- /dev/null +++ b/wwwroot/api/hermes_executions_task_update.dspy @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_executions_task SET workflow_id = ${workflow_id}$, task_id = ${task_id}$, execution_status = ${execution_status}$, start_time = ${start_time}$, end_time = ${end_time}$, duration_seconds = ${duration_seconds}$, result_json = ${result_json}$, error_message = ${error_message}$, retry_count = ${retry_count}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'workflow_id': workflow_id, + 'task_id': task_id, + 'execution_status': execution_status, + 'start_time': start_time, + 'end_time': end_time, + 'duration_seconds': duration_seconds, + 'result_json': result_json, + 'error_message': error_message, + 'retry_count': retry_count, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_executions_update.dspy b/wwwroot/api/hermes_executions_update.dspy new file mode 100644 index 0000000..213b9e3 --- /dev/null +++ b/wwwroot/api/hermes_executions_update.dspy @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Execution update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_executions SET workflow_id = ${workflow_id}$, task_id = ${task_id}$, execution_status = ${execution_status}$, start_time = ${start_time}$, end_time = ${end_time}$, duration_seconds = ${duration_seconds}$, result_json = ${result_json}$, error_message = ${error_message}$, retry_count = ${retry_count}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'workflow_id': workflow_id, + 'task_id': task_id, + 'execution_status': execution_status, + 'start_time': start_time, + 'end_time': end_time, + 'duration_seconds': duration_seconds, + 'result_json': result_json, + 'error_message': error_message, + 'retry_count': retry_count, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_memory_create.dspy b/wwwroot/api/hermes_memory_create.dspy new file mode 100644 index 0000000..c64db59 --- /dev/null +++ b/wwwroot/api/hermes_memory_create.dspy @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Memory create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + target = params_kw.get('target', '').strip() + content = params_kw.get('content', '').strip() + priority = params_kw.get('priority', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_memory (id, user_id, target, content, priority, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${target}$, ${content}$, ${priority}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'target': target, + 'content': content, + 'priority': priority, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Memory创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_memory_delete.dspy b/wwwroot/api/hermes_memory_delete.dspy new file mode 100644 index 0000000..135ee8a --- /dev/null +++ b/wwwroot/api/hermes_memory_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Memory delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_memory WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_memory_update.dspy b/wwwroot/api/hermes_memory_update.dspy new file mode 100644 index 0000000..cd96d5f --- /dev/null +++ b/wwwroot/api/hermes_memory_update.dspy @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Memory update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_memory SET target = ${target}$, content = ${content}$, priority = ${priority}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'target': target, + 'content': content, + 'priority': priority, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_sessions_create.dspy b/wwwroot/api/hermes_sessions_create.dspy new file mode 100644 index 0000000..7c4df88 --- /dev/null +++ b/wwwroot/api/hermes_sessions_create.dspy @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Session create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + title = params_kw.get('title', '').strip() + preview = params_kw.get('preview', '').strip() + tags = params_kw.get('tags', '').strip() + is_active = params_kw.get('is_active', '').strip() + metadata_json = params_kw.get('metadata_json', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_sessions (id, user_id, title, preview, tags, is_active, metadata_json, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${title}$, ${preview}$, ${tags}$, ${is_active}$, ${metadata_json}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'title': title, + 'preview': preview, + 'tags': tags, + 'is_active': is_active, + 'metadata_json': metadata_json, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Session创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_sessions_delete.dspy b/wwwroot/api/hermes_sessions_delete.dspy new file mode 100644 index 0000000..b83e368 --- /dev/null +++ b/wwwroot/api/hermes_sessions_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Session delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_sessions WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_sessions_update.dspy b/wwwroot/api/hermes_sessions_update.dspy new file mode 100644 index 0000000..5dd6dd8 --- /dev/null +++ b/wwwroot/api/hermes_sessions_update.dspy @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Session update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_sessions SET title = ${title}$, preview = ${preview}$, tags = ${tags}$, is_active = ${is_active}$, metadata_json = ${metadata_json}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'title': title, + 'preview': preview, + 'tags': tags, + 'is_active': is_active, + 'metadata_json': metadata_json, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_skills_create.dspy b/wwwroot/api/hermes_skills_create.dspy new file mode 100644 index 0000000..b1e5f5a --- /dev/null +++ b/wwwroot/api/hermes_skills_create.dspy @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Skill create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + name = params_kw.get('name', '').strip() + description = params_kw.get('description', '').strip() + content = params_kw.get('content', '').strip() + category = params_kw.get('category', '').strip() + version = params_kw.get('version', '').strip() + is_active = params_kw.get('is_active', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_skills (id, user_id, name, description, content, category, version, is_active, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${name}$, ${description}$, ${content}$, ${category}$, ${version}$, ${is_active}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'name': name, + 'description': description, + 'content': content, + 'category': category, + 'version': version, + 'is_active': is_active, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Skill创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_skills_delete.dspy b/wwwroot/api/hermes_skills_delete.dspy new file mode 100644 index 0000000..89498c8 --- /dev/null +++ b/wwwroot/api/hermes_skills_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Skill delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_skills WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_skills_update.dspy b/wwwroot/api/hermes_skills_update.dspy new file mode 100644 index 0000000..69e5f90 --- /dev/null +++ b/wwwroot/api/hermes_skills_update.dspy @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Skill update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_skills SET name = ${name}$, description = ${description}$, content = ${content}$, category = ${category}$, version = ${version}$, is_active = ${is_active}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'name': name, + 'description': description, + 'content': content, + 'category': category, + 'version': version, + 'is_active': is_active, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_tasks_create.dspy b/wwwroot/api/hermes_tasks_create.dspy new file mode 100644 index 0000000..3af1c2f --- /dev/null +++ b/wwwroot/api/hermes_tasks_create.dspy @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + workflow_id = params_kw.get('workflow_id', '').strip() + task_name = params_kw.get('task_name', '').strip() + task_type = params_kw.get('task_type', '').strip() + skill_name = params_kw.get('skill_name', '').strip() + tool_name = params_kw.get('tool_name', '').strip() + parameters_json = params_kw.get('parameters_json', '').strip() + depends_on = params_kw.get('depends_on', '').strip() + parallel_group = params_kw.get('parallel_group', '').strip() + timeout_seconds = params_kw.get('timeout_seconds', '').strip() + retry_count = params_kw.get('retry_count', '').strip() + order_index = params_kw.get('order_index', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_tasks (id, user_id, workflow_id, task_name, task_type, skill_name, tool_name, parameters_json, depends_on, parallel_group, timeout_seconds, retry_count, order_index, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${workflow_id}$, ${task_name}$, ${task_type}$, ${skill_name}$, ${tool_name}$, ${parameters_json}$, ${depends_on}$, ${parallel_group}$, ${timeout_seconds}$, ${retry_count}$, ${order_index}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'workflow_id': workflow_id, + 'task_name': task_name, + 'task_type': task_type, + 'skill_name': skill_name, + 'tool_name': tool_name, + 'parameters_json': parameters_json, + 'depends_on': depends_on, + 'parallel_group': parallel_group, + 'timeout_seconds': timeout_seconds, + 'retry_count': retry_count, + 'order_index': order_index, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Task创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_tasks_delete.dspy b/wwwroot/api/hermes_tasks_delete.dspy new file mode 100644 index 0000000..a110ed5 --- /dev/null +++ b/wwwroot/api/hermes_tasks_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_tasks WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_tasks_update.dspy b/wwwroot/api/hermes_tasks_update.dspy new file mode 100644 index 0000000..1dfa4e5 --- /dev/null +++ b/wwwroot/api/hermes_tasks_update.dspy @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_tasks SET workflow_id = ${workflow_id}$, task_name = ${task_name}$, task_type = ${task_type}$, skill_name = ${skill_name}$, tool_name = ${tool_name}$, parameters_json = ${parameters_json}$, depends_on = ${depends_on}$, parallel_group = ${parallel_group}$, timeout_seconds = ${timeout_seconds}$, retry_count = ${retry_count}$, order_index = ${order_index}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'workflow_id': workflow_id, + 'task_name': task_name, + 'task_type': task_type, + 'skill_name': skill_name, + 'tool_name': tool_name, + 'parameters_json': parameters_json, + 'depends_on': depends_on, + 'parallel_group': parallel_group, + 'timeout_seconds': timeout_seconds, + 'retry_count': retry_count, + 'order_index': order_index, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_tasks_workflow_create.dspy b/wwwroot/api/hermes_tasks_workflow_create.dspy new file mode 100644 index 0000000..5973cff --- /dev/null +++ b/wwwroot/api/hermes_tasks_workflow_create.dspy @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + workflow_id = params_kw.get('workflow_id', '').strip() + task_name = params_kw.get('task_name', '').strip() + task_type = params_kw.get('task_type', '').strip() + skill_name = params_kw.get('skill_name', '').strip() + tool_name = params_kw.get('tool_name', '').strip() + parameters_json = params_kw.get('parameters_json', '').strip() + depends_on = params_kw.get('depends_on', '').strip() + parallel_group = params_kw.get('parallel_group', '').strip() + timeout_seconds = params_kw.get('timeout_seconds', '').strip() + retry_count = params_kw.get('retry_count', '').strip() + order_index = params_kw.get('order_index', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_tasks_workflow (id, user_id, workflow_id, task_name, task_type, skill_name, tool_name, parameters_json, depends_on, parallel_group, timeout_seconds, retry_count, order_index, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${workflow_id}$, ${task_name}$, ${task_type}$, ${skill_name}$, ${tool_name}$, ${parameters_json}$, ${depends_on}$, ${parallel_group}$, ${timeout_seconds}$, ${retry_count}$, ${order_index}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'workflow_id': workflow_id, + 'task_name': task_name, + 'task_type': task_type, + 'skill_name': skill_name, + 'tool_name': tool_name, + 'parameters_json': parameters_json, + 'depends_on': depends_on, + 'parallel_group': parallel_group, + 'timeout_seconds': timeout_seconds, + 'retry_count': retry_count, + 'order_index': order_index, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Task创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_tasks_workflow_delete.dspy b/wwwroot/api/hermes_tasks_workflow_delete.dspy new file mode 100644 index 0000000..4102efe --- /dev/null +++ b/wwwroot/api/hermes_tasks_workflow_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_tasks_workflow WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_tasks_workflow_update.dspy b/wwwroot/api/hermes_tasks_workflow_update.dspy new file mode 100644 index 0000000..67decee --- /dev/null +++ b/wwwroot/api/hermes_tasks_workflow_update.dspy @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_tasks_workflow SET workflow_id = ${workflow_id}$, task_name = ${task_name}$, task_type = ${task_type}$, skill_name = ${skill_name}$, tool_name = ${tool_name}$, parameters_json = ${parameters_json}$, depends_on = ${depends_on}$, parallel_group = ${parallel_group}$, timeout_seconds = ${timeout_seconds}$, retry_count = ${retry_count}$, order_index = ${order_index}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'workflow_id': workflow_id, + 'task_name': task_name, + 'task_type': task_type, + 'skill_name': skill_name, + 'tool_name': tool_name, + 'parameters_json': parameters_json, + 'depends_on': depends_on, + 'parallel_group': parallel_group, + 'timeout_seconds': timeout_seconds, + 'retry_count': retry_count, + 'order_index': order_index, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_workflows_create.dspy b/wwwroot/api/hermes_workflows_create.dspy new file mode 100644 index 0000000..c19c970 --- /dev/null +++ b/wwwroot/api/hermes_workflows_create.dspy @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Workflow create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + name = params_kw.get('name', '').strip() + description = params_kw.get('description', '').strip() + workflow_type = params_kw.get('workflow_type', '').strip() + max_concurrent_tasks = params_kw.get('max_concurrent_tasks', '').strip() + timeout_seconds = params_kw.get('timeout_seconds', '').strip() + retry_count = params_kw.get('retry_count', '').strip() + status = params_kw.get('status', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO hermes_workflows (id, user_id, name, description, workflow_type, max_concurrent_tasks, timeout_seconds, retry_count, status, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${name}$, ${description}$, ${workflow_type}$, ${max_concurrent_tasks}$, ${timeout_seconds}$, ${retry_count}$, ${status}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'name': name, + 'description': description, + 'workflow_type': workflow_type, + 'max_concurrent_tasks': max_concurrent_tasks, + 'timeout_seconds': timeout_seconds, + 'retry_count': retry_count, + 'status': status, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Workflow创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_workflows_delete.dspy b/wwwroot/api/hermes_workflows_delete.dspy new file mode 100644 index 0000000..3c3d48e --- /dev/null +++ b/wwwroot/api/hermes_workflows_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Workflow delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM hermes_workflows WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/hermes_workflows_update.dspy b/wwwroot/api/hermes_workflows_update.dspy new file mode 100644 index 0000000..6635ca2 --- /dev/null +++ b/wwwroot/api/hermes_workflows_update.dspy @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Workflow update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE hermes_workflows SET name = ${name}$, description = ${description}$, workflow_type = ${workflow_type}$, max_concurrent_tasks = ${max_concurrent_tasks}$, timeout_seconds = ${timeout_seconds}$, retry_count = ${retry_count}$, status = ${status}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'name': name, + 'description': description, + 'workflow_type': workflow_type, + 'max_concurrent_tasks': max_concurrent_tasks, + 'timeout_seconds': timeout_seconds, + 'retry_count': retry_count, + 'status': status, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/task_dependencies_create.dspy b/wwwroot/api/task_dependencies_create.dspy new file mode 100644 index 0000000..1cd24bd --- /dev/null +++ b/wwwroot/api/task_dependencies_create.dspy @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task Dependency create API""" +import json, uuid, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + new_id = str(uuid.uuid4()).replace('-', '') + + workflow_id = params_kw.get('workflow_id', '').strip() + dependent_task_id = params_kw.get('dependent_task_id', '').strip() + dependency_task_id = params_kw.get('dependency_task_id', '').strip() + dependency_type = params_kw.get('dependency_type', '').strip() + + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""INSERT INTO task_dependencies (id, user_id, workflow_id, dependent_task_id, dependency_task_id, dependency_type, created_at, updated_at) + VALUES (${id}$, ${user_id}$, ${workflow_id}$, ${dependent_task_id}$, ${dependency_task_id}$, ${dependency_type}$, ${created_at}$, ${updated_at}$)""", { + 'id': new_id, 'user_id': user_id, + 'workflow_id': workflow_id, + 'dependent_task_id': dependent_task_id, + 'dependency_task_id': dependency_task_id, + 'dependency_type': dependency_type, + 'created_at': now, 'updated_at': now + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': 'Task Dependency创建成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/task_dependencies_delete.dspy b/wwwroot/api/task_dependencies_delete.dspy new file mode 100644 index 0000000..21df87e --- /dev/null +++ b/wwwroot/api/task_dependencies_delete.dspy @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task Dependency delete API""" +import json + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""DELETE FROM task_dependencies WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '删除成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/api/task_dependencies_update.dspy b/wwwroot/api/task_dependencies_update.dspy new file mode 100644 index 0000000..6144ff3 --- /dev/null +++ b/wwwroot/api/task_dependencies_update.dspy @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Task Dependency update API""" +import json, time + +result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}} + +try: + dbname = get_module_dbname('harnessed_agent') + user_id = await get_user() + now = time.strftime('%Y-%m-%d %H:%M:%S') + record_id = params_kw.get('id', '').strip() + if not record_id: + result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'} + else: + async with DBPools().sqlorContext(dbname) as sor: + await sor.sqlExe("""UPDATE task_dependencies SET workflow_id = ${workflow_id}$, dependent_task_id = ${dependent_task_id}$, dependency_task_id = ${dependency_task_id}$, dependency_type = ${dependency_type}$, updated_at = ${updated_at}$ WHERE id = ${id}$ AND user_id = ${user_id}$""", { + 'id': record_id, 'user_id': user_id, 'updated_at': now, + 'workflow_id': workflow_id, + 'dependent_task_id': dependent_task_id, + 'dependency_task_id': dependency_task_id, + 'dependency_type': dependency_type, + }) + result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '更新成功', 'type': 'success'}} + +except Exception as e: + result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} + +return json.dumps(result, ensure_ascii=False) diff --git a/wwwroot/memory.ui b/wwwroot/memory.ui index 5e700dc..274b1ca 100644 --- a/wwwroot/memory.ui +++ b/wwwroot/memory.ui @@ -23,7 +23,7 @@ { "widgettype": "urlwidget", "options": { - "url": "{{entire_url(hermes_memory_crud)}}", + "url": "{{entire_url('hermes_memory_crud')}}", "width": "100%", "height": "100%" } diff --git a/wwwroot/remote_skills.ui b/wwwroot/remote_skills.ui index 62f6e5e..5ac35e9 100644 --- a/wwwroot/remote_skills.ui +++ b/wwwroot/remote_skills.ui @@ -23,7 +23,7 @@ { "widgettype": "urlwidget", "options": { - "url": "{{entire_url(hermes_remote_skills_crud)}}", + "url": "{{entire_url('hermes_remote_skills_crud')}}", "width": "100%", "height": "100%" } diff --git a/wwwroot/sessions.ui b/wwwroot/sessions.ui index 2eb9195..e50684e 100644 --- a/wwwroot/sessions.ui +++ b/wwwroot/sessions.ui @@ -23,7 +23,7 @@ { "widgettype": "urlwidget", "options": { - "url": "{{entire_url(hermes_sessions_crud)}}", + "url": "{{entire_url('hermes_sessions_crud')}}", "width": "100%", "height": "100%" } diff --git a/wwwroot/skills.ui b/wwwroot/skills.ui index 4b9d342..68fb13c 100644 --- a/wwwroot/skills.ui +++ b/wwwroot/skills.ui @@ -23,7 +23,7 @@ { "widgettype": "urlwidget", "options": { - "url": "{{entire_url(hermes_skills_crud)}}", + "url": "{{entire_url('hermes_skills_crud')}}", "width": "100%", "height": "100%" } diff --git a/wwwroot/tasks.ui b/wwwroot/tasks.ui index b819af1..9d8fea3 100644 --- a/wwwroot/tasks.ui +++ b/wwwroot/tasks.ui @@ -23,7 +23,7 @@ { "widgettype": "urlwidget", "options": { - "url": "{{entire_url(hermes_tasks_workflow)}}", + "url": "{{entire_url('hermes_tasks_workflow')}}", "width": "100%", "height": "100%" } diff --git a/wwwroot/workflows.ui b/wwwroot/workflows.ui index 034e99c..e7f2b39 100644 --- a/wwwroot/workflows.ui +++ b/wwwroot/workflows.ui @@ -23,7 +23,7 @@ { "widgettype": "urlwidget", "options": { - "url": "{{entire_url(hermes_workflows_crud)}}", + "url": "{{entire_url('hermes_workflows_crud')}}", "width": "100%", "height": "100%" }