syntax = "proto3";

package npagent.plugin.v1;

option go_package = "github.com/nullplatform/np-agent/proto/pluginpb";

import "google/protobuf/empty.proto";

// ExecutorPlugin handles command execution
service ExecutorPlugin {
  rpc Execute(ExecuteRequest) returns (stream ExecuteEvent);
  rpc Capabilities(google.protobuf.Empty) returns (CapabilitiesResponse);
  rpc Health(google.protobuf.Empty) returns (HealthResponse);
  rpc Version(google.protobuf.Empty) returns (VersionResponse);
}

// --- ExecuteRequest ---

message ExecuteRequest {
  string message_id = 1;
  string command_type = 2;
  bytes payload = 3;
  bool supports_partial = 4;
  bool can_cancel = 5;
  string reply_to = 6;
  string action_type = 7;
}

// --- ExecuteEvent lifecycle: Started → Output* → Result ---

message ExecuteEvent {
  oneof event {
    ExecuteStarted started = 1;
    ExecuteOutput output = 2;
    ExecuteResult result = 3;
  }
}

message ExecuteStarted {}

message ExecuteOutput {
  string stdout = 1;
  string stderr = 2;
  bytes data = 3;
}

message ExecuteResult {
  bool success = 1;
  bytes data = 2;
  string error = 3;
  int32 exit_code = 4;
  string error_code = 5;
}

// --- Capabilities ---

message CapabilitiesResponse {
  repeated string command_types = 1;
  int32 priority = 2;
}

// --- Health & Version ---

message HealthResponse {
  bool healthy = 1;
  int64 uptime_ms = 2;
  int32 active_commands = 3;
  int64 memory_bytes = 4;
  string message = 5;
}

message VersionResponse {
  string name = 1;
  string version = 2;
  string git_sha = 3;
  string built_at = 4;
  map<string, string> metadata = 5;
}
