From c31ce90306ed2300e1e1e69f530af1bb5de81730 Mon Sep 17 00:00:00 2001 From: pptx704 Date: Tue, 10 Mar 2026 02:49:31 +0600 Subject: [PATCH] Centralize envd proto source of truth to proto/envd/ Remove duplicate proto files from envd/spec/ and update envd's buf.gen.yaml to generate stubs from the canonical proto/envd/ location. Both modules now generate their own Connect RPC stubs from the same source protos. --- envd/spec/buf.gen.yaml | 15 +-- envd/spec/filesystem/filesystem.proto | 135 -------------------- envd/spec/generate.go | 2 +- envd/spec/process/process.proto | 171 -------------------------- 4 files changed, 9 insertions(+), 314 deletions(-) delete mode 100644 envd/spec/filesystem/filesystem.proto delete mode 100644 envd/spec/process/process.proto diff --git a/envd/spec/buf.gen.yaml b/envd/spec/buf.gen.yaml index c467274..51282c2 100644 --- a/envd/spec/buf.gen.yaml +++ b/envd/spec/buf.gen.yaml @@ -1,14 +1,15 @@ -version: v1 +version: v2 plugins: - - plugin: go + - protoc_builtin: go out: ../internal/services/spec opt: paths=source_relative - - plugin: connect-go + - local: protoc-gen-connect-go out: ../internal/services/spec opt: paths=source_relative - +inputs: + - directory: ../../proto/envd managed: enabled: true - optimize_for: SPEED - go_package_prefix: - default: git.omukk.dev/wrenn/sandbox/envd/internal/services/spec + override: + - file_option: go_package_prefix + value: git.omukk.dev/wrenn/sandbox/envd/internal/services/spec diff --git a/envd/spec/filesystem/filesystem.proto b/envd/spec/filesystem/filesystem.proto deleted file mode 100644 index 54bda3c..0000000 --- a/envd/spec/filesystem/filesystem.proto +++ /dev/null @@ -1,135 +0,0 @@ -syntax = "proto3"; - -package filesystem; - -import "google/protobuf/timestamp.proto"; - -service Filesystem { - rpc Stat(StatRequest) returns (StatResponse); - rpc MakeDir(MakeDirRequest) returns (MakeDirResponse); - rpc Move(MoveRequest) returns (MoveResponse); - rpc ListDir(ListDirRequest) returns (ListDirResponse); - rpc Remove(RemoveRequest) returns (RemoveResponse); - - rpc WatchDir(WatchDirRequest) returns (stream WatchDirResponse); - - // Non-streaming versions of WatchDir - rpc CreateWatcher(CreateWatcherRequest) returns (CreateWatcherResponse); - rpc GetWatcherEvents(GetWatcherEventsRequest) returns (GetWatcherEventsResponse); - rpc RemoveWatcher(RemoveWatcherRequest) returns (RemoveWatcherResponse); -} - -message MoveRequest { - string source = 1; - string destination = 2; -} - -message MoveResponse { - EntryInfo entry = 1; -} - -message MakeDirRequest { - string path = 1; -} - -message MakeDirResponse { - EntryInfo entry = 1; -} - -message RemoveRequest { - string path = 1; -} - -message RemoveResponse {} - -message StatRequest { - string path = 1; -} - -message StatResponse { - EntryInfo entry = 1; -} - -message EntryInfo { - string name = 1; - FileType type = 2; - string path = 3; - int64 size = 4; - uint32 mode = 5; - string permissions = 6; - string owner = 7; - string group = 8; - google.protobuf.Timestamp modified_time = 9; - // If the entry is a symlink, this field contains the target of the symlink. - optional string symlink_target = 10; -} - -enum FileType { - FILE_TYPE_UNSPECIFIED = 0; - FILE_TYPE_FILE = 1; - FILE_TYPE_DIRECTORY = 2; - FILE_TYPE_SYMLINK = 3; -} - -message ListDirRequest { - string path = 1; - uint32 depth = 2; -} - -message ListDirResponse { - repeated EntryInfo entries = 1; -} - -message WatchDirRequest { - string path = 1; - bool recursive = 2; -} - -message FilesystemEvent { - string name = 1; - EventType type = 2; -} - -message WatchDirResponse { - oneof event { - StartEvent start = 1; - FilesystemEvent filesystem = 2; - KeepAlive keepalive = 3; - } - - message StartEvent {} - - message KeepAlive {} -} - -message CreateWatcherRequest { - string path = 1; - bool recursive = 2; -} - -message CreateWatcherResponse { - string watcher_id = 1; -} - -message GetWatcherEventsRequest { - string watcher_id = 1; -} - -message GetWatcherEventsResponse { - repeated FilesystemEvent events = 1; -} - -message RemoveWatcherRequest { - string watcher_id = 1; -} - -message RemoveWatcherResponse {} - -enum EventType { - EVENT_TYPE_UNSPECIFIED = 0; - EVENT_TYPE_CREATE = 1; - EVENT_TYPE_WRITE = 2; - EVENT_TYPE_REMOVE = 3; - EVENT_TYPE_RENAME = 4; - EVENT_TYPE_CHMOD = 5; -} diff --git a/envd/spec/generate.go b/envd/spec/generate.go index 0e9f11b..60bb0d1 100644 --- a/envd/spec/generate.go +++ b/envd/spec/generate.go @@ -1,3 +1,3 @@ package spec -//go:generate buf generate --template buf.gen.yaml +//go:generate buf generate diff --git a/envd/spec/process/process.proto b/envd/spec/process/process.proto deleted file mode 100644 index 99376a0..0000000 --- a/envd/spec/process/process.proto +++ /dev/null @@ -1,171 +0,0 @@ -syntax = "proto3"; - -package process; - -service Process { - rpc List(ListRequest) returns (ListResponse); - - rpc Connect(ConnectRequest) returns (stream ConnectResponse); - rpc Start(StartRequest) returns (stream StartResponse); - - rpc Update(UpdateRequest) returns (UpdateResponse); - - // Client input stream ensures ordering of messages - rpc StreamInput(stream StreamInputRequest) returns (StreamInputResponse); - rpc SendInput(SendInputRequest) returns (SendInputResponse); - rpc SendSignal(SendSignalRequest) returns (SendSignalResponse); - - // Close stdin to signal EOF to the process. - // Only works for non-PTY processes. For PTY, send Ctrl+D (0x04) instead. - rpc CloseStdin(CloseStdinRequest) returns (CloseStdinResponse); -} - -message PTY { - Size size = 1; - - message Size { - uint32 cols = 1; - uint32 rows = 2; - } -} - -message ProcessConfig { - string cmd = 1; - repeated string args = 2; - - map envs = 3; - optional string cwd = 4; -} - -message ListRequest {} - -message ProcessInfo { - ProcessConfig config = 1; - uint32 pid = 2; - optional string tag = 3; -} - -message ListResponse { - repeated ProcessInfo processes = 1; -} - -message StartRequest { - ProcessConfig process = 1; - optional PTY pty = 2; - optional string tag = 3; - // This is optional for backwards compatibility. - // We default to true. New SDK versions will set this to false by default. - optional bool stdin = 4; -} - -message UpdateRequest { - ProcessSelector process = 1; - - optional PTY pty = 2; -} - -message UpdateResponse {} - -message ProcessEvent { - oneof event { - StartEvent start = 1; - DataEvent data = 2; - EndEvent end = 3; - KeepAlive keepalive = 4; - } - - message StartEvent { - uint32 pid = 1; - } - - message DataEvent { - oneof output { - bytes stdout = 1; - bytes stderr = 2; - bytes pty = 3; - } - } - - message EndEvent { - sint32 exit_code = 1; - bool exited = 2; - string status = 3; - optional string error = 4; - } - - message KeepAlive {} -} - -message StartResponse { - ProcessEvent event = 1; -} - -message ConnectResponse { - ProcessEvent event = 1; -} - -message SendInputRequest { - ProcessSelector process = 1; - - ProcessInput input = 2; -} - -message SendInputResponse {} - -message ProcessInput { - oneof input { - bytes stdin = 1; - bytes pty = 2; - } -} - -message StreamInputRequest { - oneof event { - StartEvent start = 1; - DataEvent data = 2; - KeepAlive keepalive = 3; - } - - message StartEvent { - ProcessSelector process = 1; - } - - message DataEvent { - ProcessInput input = 2; - } - - message KeepAlive {} -} - -message StreamInputResponse {} - -enum Signal { - SIGNAL_UNSPECIFIED = 0; - SIGNAL_SIGTERM = 15; - SIGNAL_SIGKILL = 9; -} - -message SendSignalRequest { - ProcessSelector process = 1; - - Signal signal = 2; -} - -message SendSignalResponse {} - -message CloseStdinRequest { - ProcessSelector process = 1; -} - -message CloseStdinResponse {} - -message ConnectRequest { - ProcessSelector process = 1; -} - -message ProcessSelector { - oneof selector { - uint32 pid = 1; - string tag = 2; - } -}