workflow.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. }
  115. // Execute workflow response
  116. message ExecuteWorkflowResponse {
  117. string execution_id = 1;
  118. ExecutionStatus status = 2;
  119. string result = 3; // JSON string (if wait_for_completion)
  120. Error error = 4;
  121. }
  122. // Cancel execution request
  123. message CancelExecutionRequest {
  124. string execution_id = 1;
  125. string reason = 2;
  126. }
  127. // Retry execution request
  128. message RetryExecutionRequest {
  129. string execution_id = 1;
  130. string from_node_id = 2; // Optional: retry from specific node
  131. }
  132. // Get execution request
  133. message GetExecutionRequest {
  134. string execution_id = 1;
  135. }
  136. // List executions request
  137. message ListExecutionsRequest {
  138. string workflow_id = 1; // Optional filter
  139. repeated ExecutionStatus statuses = 2; // Optional filter
  140. PaginationRequest pagination = 3;
  141. }
  142. // List executions response
  143. message ListExecutionsResponse {
  144. repeated Execution executions = 1;
  145. PaginationResponse pagination = 2;
  146. }