| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- syntax = "proto3";
- package smartbotic.proto;
- import "common.proto";
- import "workflow.proto";
- option cc_enable_arenas = true;
- // Runner status
- enum RunnerStatus {
- RUNNER_STATUS_UNSPECIFIED = 0;
- RUNNER_STATUS_ONLINE = 1;
- RUNNER_STATUS_BUSY = 2;
- RUNNER_STATUS_OFFLINE = 3;
- RUNNER_STATUS_DRAINING = 4; // Not accepting new work
- }
- // Runner metrics
- message RunnerMetrics {
- int32 active_executions = 1;
- int32 max_executions = 2;
- int64 memory_used_bytes = 3;
- int64 memory_total_bytes = 4;
- double cpu_percent = 5;
- int64 total_executions = 6;
- int64 failed_executions = 7;
- double avg_execution_time_ms = 8;
- }
- // Runner capabilities
- message RunnerCapabilities {
- repeated string node_types = 1; // Supported node types
- int32 max_memory_per_script_mb = 2;
- int32 max_execution_timeout_sec = 3;
- }
- // Runner registration
- message Runner {
- string id = 1;
- string address = 2; // host:port
- RunnerStatus status = 3;
- int64 registered_at = 4;
- int64 last_heartbeat = 5;
- RunnerMetrics metrics = 6;
- RunnerCapabilities capabilities = 7;
- map<string, string> labels = 8;
- }
- // Register runner request
- message RegisterRunnerRequest {
- string runner_id = 1;
- string address = 2;
- RunnerCapabilities capabilities = 3;
- map<string, string> labels = 4;
- }
- // Register runner response
- message RegisterRunnerResponse {
- bool success = 1;
- string message = 2;
- }
- // Heartbeat request
- message HeartbeatRequest {
- string runner_id = 1;
- RunnerStatus status = 2;
- RunnerMetrics metrics = 3;
- }
- // Heartbeat response
- message HeartbeatResponse {
- bool success = 1;
- repeated string pending_cancellations = 2; // Execution IDs to cancel
- }
- // Unregister runner request
- message UnregisterRunnerRequest {
- string runner_id = 1;
- string reason = 2;
- }
- // Node definition
- message NodeDefinition {
- string id = 1;
- string name = 2;
- string category = 3;
- string version = 4;
- string description = 5;
- string icon = 6;
- string config_schema = 7; // JSON Schema
- string input_schema = 8; // JSON Schema
- string output_schema = 9; // JSON Schema
- repeated NodeInput inputs = 10;
- repeated NodeOutput outputs = 11;
- bool is_trigger = 12;
- }
- message NodeInput {
- string name = 1;
- string display_name = 2;
- string type = 3;
- bool required = 4;
- }
- message NodeOutput {
- string name = 1;
- string display_name = 2;
- string type = 3;
- string color = 4; // Optional color for visual representation
- }
- // List nodes request
- message ListNodesRequest {
- string category = 1; // Optional filter
- }
- // List nodes response
- message ListNodesResponse {
- repeated NodeDefinition nodes = 1;
- }
- // Reload node request
- message ReloadNodeRequest {
- string node_id = 1;
- }
- // Reload node response
- message ReloadNodeResponse {
- bool success = 1;
- NodeDefinition node = 2;
- Error error = 3;
- }
- // Get node code request
- message GetNodeCodeRequest {
- string node_id = 1;
- }
- // Get node code response
- message GetNodeCodeResponse {
- bool success = 1;
- string code = 2;
- string file_path = 3;
- Error error = 4;
- }
- // Save node code request
- message SaveNodeCodeRequest {
- string node_id = 1;
- string code = 2;
- }
- // Save node code response
- message SaveNodeCodeResponse {
- bool success = 1;
- NodeDefinition node = 2; // Updated node definition
- Error error = 3;
- }
- // Create node request
- message CreateNodeRequest {
- string id = 1;
- string name = 2;
- string category = 3;
- string code = 4;
- }
- // Create node response
- message CreateNodeResponse {
- bool success = 1;
- NodeDefinition node = 2;
- Error error = 3;
- }
- // Delete node request
- message DeleteNodeRequest {
- string node_id = 1;
- }
- // Delete node response
- message DeleteNodeResponse {
- bool success = 1;
- Error error = 2;
- }
- // Execute node request (for testing)
- message ExecuteNodeRequest {
- string node_type = 1;
- string config = 2; // JSON string
- string input = 3; // JSON string
- string context = 4; // JSON string - execution context
- }
- // Execute node response
- message ExecuteNodeResponse {
- bool success = 1;
- string output = 2; // JSON string
- string error = 3;
- int64 execution_time_ms = 4;
- }
- // Runner service - called by WebServer to execute workflows
- service RunnerService {
- // Execute a workflow
- rpc ExecuteWorkflow(ExecuteWorkflowRequest) returns (ExecuteWorkflowResponse);
- // Cancel an execution
- rpc CancelExecution(CancelExecutionRequest) returns (Empty);
- // Node management
- rpc ListNodes(ListNodesRequest) returns (ListNodesResponse);
- rpc ReloadNode(ReloadNodeRequest) returns (ReloadNodeResponse);
- rpc GetNodeCode(GetNodeCodeRequest) returns (GetNodeCodeResponse);
- rpc SaveNodeCode(SaveNodeCodeRequest) returns (SaveNodeCodeResponse);
- rpc CreateNode(CreateNodeRequest) returns (CreateNodeResponse);
- rpc DeleteNode(DeleteNodeRequest) returns (DeleteNodeResponse);
- // Execute single node (for testing)
- rpc ExecuteNode(ExecuteNodeRequest) returns (ExecuteNodeResponse);
- }
- // Runner registration service - runners call this on WebServer
- service RunnerRegistrationService {
- rpc Register(RegisterRunnerRequest) returns (RegisterRunnerResponse);
- rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse);
- rpc Unregister(UnregisterRunnerRequest) returns (Empty);
- }
- // ============================================================================
- // Node Sync Service - WebServer exposes this for runners to fetch nodes
- // ============================================================================
- // Full node definition with code (for sync)
- message NodeDefinitionWithCode {
- string id = 1;
- string name = 2;
- string category = 3;
- string version = 4;
- string description = 5;
- string icon = 6;
- string code = 7; // Full JavaScript source
- string config_schema = 8; // JSON Schema
- string input_schema = 9; // JSON Schema
- string output_schema = 10; // JSON Schema
- repeated NodeInput inputs = 11;
- repeated NodeOutput outputs = 12;
- bool is_trigger = 13;
- string owner_id = 14;
- int64 created_at = 15;
- int64 updated_at = 16;
- }
- // Get all nodes request
- message GetAllNodesRequest {
- // Empty - returns all nodes
- }
- // Get all nodes response
- message GetAllNodesResponse {
- repeated NodeDefinitionWithCode nodes = 1;
- }
- // Get single node request
- message GetNodeRequest {
- string node_id = 1;
- }
- // Subscribe to node changes request
- message SubscribeToNodeChangesRequest {
- string runner_id = 1; // For tracking subscriptions
- }
- // Node change event
- message NodeChangeEvent {
- enum ChangeType {
- CHANGE_TYPE_UNSPECIFIED = 0;
- CHANGE_TYPE_CREATED = 1;
- CHANGE_TYPE_UPDATED = 2;
- CHANGE_TYPE_DELETED = 3;
- }
- ChangeType type = 1;
- string node_id = 2;
- NodeDefinitionWithCode node = 3; // Present for CREATED/UPDATED
- int64 timestamp = 4;
- }
- // Node sync service - WebServer hosts this for runners to sync nodes
- service NodeSyncService {
- // Get all node definitions
- rpc GetAllNodes(GetAllNodesRequest) returns (GetAllNodesResponse);
- // Get a single node by ID
- rpc GetNode(GetNodeRequest) returns (NodeDefinitionWithCode);
- // Subscribe to node changes (server-side streaming)
- rpc SubscribeToNodeChanges(SubscribeToNodeChangesRequest) returns (stream NodeChangeEvent);
- }
|