syntax = "proto3";
package agent;

option go_package = "github.com/yunis-du/actflow-agent-sdk/go-sdk/pb";

import "google/protobuf/struct.proto";

// Agent service.
service AgentService {
  // Stream real-time interactive to the session.
  rpc Run(RunRequest) returns (stream AgentUpdate);

  // Shut down an existing session.
  rpc Shutdown(Empty) returns (Empty);
}

// Empty message.
message Empty {}

// Request to run an agent.
message RunRequest {
  string pid = 1;// Process id.
  string nid = 2;// Node id.
  google.protobuf.Value inputs = 3;// Inputs.
}

// Update from agent.
message AgentUpdate {
  oneof relay_message {
    string log = 1;
    AgentOutput output = 2;
  }
}

// Log message.
message Log {
  string content = 1;
}

// Agent output.
message AgentOutput {
  // agent execution status
  NodeExecutionStatus status = 1;
  // agent outputs
  google.protobuf.Value outputs = 2;
  // agent error message
  string error = 3;
  // agent exception message
  string exception = 4;
}

// Agent execution status.
enum NodeExecutionStatus {
  PENDING = 0;
  SUCCEEDED = 1;
  FAILED = 2;
  EXCEPTION = 3;
  STOPPED = 4;
  PAUSED = 5;
}