workflow.proto 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. syntax = "proto3";
  2. package smartbotic.proto;
  3. import "common.proto";
  4. option cc_enable_arenas = true;
  5. // Node position in editor
  6. message Position {
  7. double x = 1;
  8. double y = 2;
  9. }
  10. // Workflow node definition
  11. message WorkflowNode {
  12. string id = 1;
  13. string type = 2;
  14. string name = 3;
  15. string config = 4; // JSON string
  16. Position position = 5;
  17. bool disabled = 6;
  18. map<string, string> metadata = 7;
  19. }
  20. // Connection between nodes
  21. message Connection {
  22. string source_node_id = 1;
  23. string source_output = 2;
  24. string target_node_id = 3;
  25. string target_input = 4;
  26. }
  27. // Workflow settings
  28. message WorkflowSettings {
  29. int32 timeout_ms = 1;
  30. bool retry_on_fail = 2;
  31. int32 max_retries = 3;
  32. int32 retry_delay_ms = 4;
  33. string error_policy = 5; // "stop", "continue", "retry"
  34. }
  35. // Workflow definition
  36. message Workflow {
  37. string id = 1;
  38. string name = 2;
  39. string description = 3;
  40. string group_id = 4;
  41. string owner_id = 5;
  42. bool active = 6;
  43. repeated WorkflowNode nodes = 7;
  44. repeated Connection connections = 8;
  45. WorkflowSettings settings = 9;
  46. int64 version = 10;
  47. int64 created_at = 11;
  48. int64 updated_at = 12;
  49. map<string, string> tags = 13;
  50. }
  51. // Workflow group
  52. message WorkflowGroup {
  53. string id = 1;
  54. string name = 2;
  55. string description = 3;
  56. string parent_id = 4;
  57. string owner_id = 5;
  58. int64 created_at = 6;
  59. int64 updated_at = 7;
  60. }
  61. // Execution status
  62. enum ExecutionStatus {
  63. EXECUTION_STATUS_UNSPECIFIED = 0;
  64. EXECUTION_STATUS_PENDING = 1;
  65. EXECUTION_STATUS_RUNNING = 2;
  66. EXECUTION_STATUS_COMPLETED = 3;
  67. EXECUTION_STATUS_FAILED = 4;
  68. EXECUTION_STATUS_CANCELLED = 5;
  69. EXECUTION_STATUS_WAITING = 6; // Waiting for external trigger
  70. }
  71. // Node execution result
  72. message NodeExecution {
  73. string node_id = 1;
  74. ExecutionStatus status = 2;
  75. int64 started_at = 3;
  76. int64 finished_at = 4;
  77. string input = 5; // JSON string
  78. string output = 6; // JSON string
  79. string error = 7;
  80. int32 retry_count = 8;
  81. }
  82. // Workflow execution
  83. message Execution {
  84. string id = 1;
  85. string workflow_id = 2;
  86. string workflow_name = 3;
  87. string runner_id = 4;
  88. ExecutionStatus status = 5;
  89. string trigger_type = 6; // "manual", "webhook", "schedule", "node"
  90. string trigger_data = 7; // JSON string
  91. int64 started_at = 8;
  92. int64 finished_at = 9;
  93. repeated NodeExecution node_executions = 10;
  94. string error = 11;
  95. map<string, string> context = 12;
  96. string workflow_snapshot = 13; // JSON string: {nodes, connections} at execution time
  97. }
  98. // Execute workflow request
  99. message ExecuteWorkflowRequest {
  100. string workflow_id = 1;
  101. string trigger_type = 2;
  102. string trigger_data = 3; // JSON string
  103. bool wait_for_completion = 4;
  104. int32 timeout_ms = 5;
  105. }
  106. // Execute workflow response
  107. message ExecuteWorkflowResponse {
  108. string execution_id = 1;
  109. ExecutionStatus status = 2;
  110. string result = 3; // JSON string (if wait_for_completion)
  111. Error error = 4;
  112. }
  113. // Cancel execution request
  114. message CancelExecutionRequest {
  115. string execution_id = 1;
  116. string reason = 2;
  117. }
  118. // Retry execution request
  119. message RetryExecutionRequest {
  120. string execution_id = 1;
  121. string from_node_id = 2; // Optional: retry from specific node
  122. }
  123. // Get execution request
  124. message GetExecutionRequest {
  125. string execution_id = 1;
  126. }
  127. // List executions request
  128. message ListExecutionsRequest {
  129. string workflow_id = 1; // Optional filter
  130. repeated ExecutionStatus statuses = 2; // Optional filter
  131. PaginationRequest pagination = 3;
  132. }
  133. // List executions response
  134. message ListExecutionsResponse {
  135. repeated Execution executions = 1;
  136. PaginationResponse pagination = 2;
  137. }