workflow.proto 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. // A whole workflow, as JSON, to run instead of loading workflow_id from the
  106. // database. Used to run one node on demand - the editor asking a node what
  107. // options it can offer - where the node's config is being edited and has
  108. // not been saved anywhere.
  109. //
  110. // workflow_id must still be set to the workflow this node belongs to.
  111. // Credential access is checked against it, and an empty workflow id is
  112. // treated as an administrative call with access to every credential.
  113. string inline_workflow = 6;
  114. // Run the published version rather than whatever was saved last.
  115. //
  116. // Set by everything that starts a workflow on its own - a schedule, a
  117. // webhook, an error handler - so that editing a live workflow does not put
  118. // half-finished work into production the moment it is saved. A run somebody
  119. // started by hand deliberately leaves this false: testing a change before
  120. // publishing it is the whole point of being able to.
  121. bool use_published = 7;
  122. }
  123. // Execute workflow response
  124. message ExecuteWorkflowResponse {
  125. string execution_id = 1;
  126. ExecutionStatus status = 2;
  127. string result = 3; // JSON string (if wait_for_completion)
  128. Error error = 4;
  129. }
  130. // Cancel execution request
  131. message CancelExecutionRequest {
  132. string execution_id = 1;
  133. string reason = 2;
  134. }
  135. // Which executions a runner is running right now
  136. message ListActiveExecutionsRequest {
  137. }
  138. message ListActiveExecutionsResponse {
  139. // Execution ids this runner currently has in flight. A runner keeps them in
  140. // memory, so a restart empties this - which is exactly how an execution
  141. // recorded as running is found to have nobody left to finish it.
  142. repeated string execution_ids = 1;
  143. }
  144. // Cancel execution response
  145. message CancelExecutionResponse {
  146. // False when this runner has never heard of the execution - it finished
  147. // before the request arrived, or the runner has restarted since it started.
  148. // The caller needs to know, because a cancel nobody can act on leaves the
  149. // record saying "running" for ever.
  150. bool was_running = 1;
  151. // How many executions were marked, counting sub-workflows this one started.
  152. int32 marked = 2;
  153. }
  154. // Retry execution request
  155. message RetryExecutionRequest {
  156. string execution_id = 1;
  157. string from_node_id = 2; // Optional: retry from specific node
  158. }
  159. // Get execution request
  160. message GetExecutionRequest {
  161. string execution_id = 1;
  162. }
  163. // List executions request
  164. message ListExecutionsRequest {
  165. string workflow_id = 1; // Optional filter
  166. repeated ExecutionStatus statuses = 2; // Optional filter
  167. PaginationRequest pagination = 3;
  168. }
  169. // List executions response
  170. message ListExecutionsResponse {
  171. repeated Execution executions = 1;
  172. PaginationResponse pagination = 2;
  173. }