Files
leleka/crates/runtime-client/proto/runtime.proto
T
Pavlo RatushnyiandClaude Sonnet 5.5 c9aad38caa refactor: extract the runtime gRPC client into leleka-runtime-client and add GrpcBackend
proto/runtime.proto, the wire conversions and the validated RuntimeClient move out of
strata-desktop-core so strata-next can use them; strata-desktop-core re-exports them
unchanged. GrpcBackend implements the Backend contract by attaching to a runtime an
operator already loaded (no Load/Unload RPC), re-reading epoch and handle before every
generation, and ending a generation without a terminal event on any transport or frame
error. 9 loopback HTTP/2 tests with a scripted runtime server.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 02:42:11 +02:00

97 lines
4.4 KiB
Protocol Buffer

syntax = "proto3";
package leleka.runtime.v1;
// Separate inference-process contract; strata.node.v1 is unchanged.
service Runtime {
rpc Handshake(Hello) returns (.leleka.runtime.v1.Snapshot);
rpc Snapshot(Empty) returns (.leleka.runtime.v1.Snapshot);
rpc Watch(Cursor) returns (stream .leleka.runtime.v1.Snapshot);
rpc Load(LoadRequest) returns (OperationResult);
rpc Unload(UnloadRequest) returns (OperationResult);
rpc Operation(OperationQuery) returns (OperationResult);
rpc Generate(GenerateRequest) returns (stream GenerationFrame);
rpc Cancel(CancelRequest) returns (CancelAck);
}
message Empty {}
message Hello { uint32 protocol_version = 1; uint32 backend_api_version = 2; }
message Cursor { string epoch = 1; uint64 sequence = 2; }
message ModelDescriptor {
string family = 1;
string architecture = 2;
string artifact_digest = 3;
string weight_format = 4;
}
message NativeMode {}
message KarPleMode { string profile_id = 1; }
message MtpMode { string profile_id = 1; }
message KarExpertsMode {
string bundle_directory = 1; string archive_file = 2;
string binding_file = 3; string provenance_file = 4;
uint32 levels = 5; uint32 cache_mib = 6;
enum Prefill { UNSPECIFIED = 0; DECODE_ONLY = 1; ALL_ROUTED_BATCHED = 2; }
Prefill prefill_mode = 7;
}
message InferenceMode {
oneof selection { NativeMode native = 1; KarPleMode kar_ple = 2; KarExpertsMode kar_experts = 3; MtpMode mtp = 4; }
}
message LoadConfig {
uint32 version = 1; InferenceMode mode = 2;
optional uint64 gpu_memory_limit_bytes = 3; bool allow_experimental = 4;
}
message LoadedModel {
string handle = 1; ModelDescriptor descriptor = 2;
uint32 load_config_version = 3; InferenceMode effective_mode = 4;
string mode_identity_digest = 5;
}
message SupportedModelTuple { string family = 1; string architecture = 2; string weight_format = 3; }
message Capabilities {
repeated SupportedModelTuple models = 1;
uint32 max_concurrent_generations = 2;
bool cancellation = 3; bool tool_call_streaming = 4;
}
message Snapshot {
uint32 protocol_version = 1; uint32 backend_api_version = 2;
string epoch = 3; uint64 sequence = 4; bool full_snapshot = 5;
bool transport_ready = 6; bool model_ready = 7;
LoadedModel loaded = 8; Capabilities capabilities = 9;
string active_request_id = 10;
}
message LoadRequest { string operation_id = 1; string expected_epoch = 2; ModelDescriptor model = 3; LoadConfig config = 4; }
message UnloadRequest { string operation_id = 1; string expected_epoch = 2; string handle = 3; }
message OperationQuery { string operation_id = 1; string expected_epoch = 2; }
message OperationResult {
string operation_id = 1; string epoch = 2;
enum State { UNSPECIFIED = 0; ACCEPTED = 1; COMPLETED = 2; FAILED = 3; INDETERMINATE = 4; }
State state = 3; string reason = 4; LoadedModel loaded = 5;
}
message GenerateRequest {
string request_id = 1; string expected_epoch = 2; string handle = 3;
string prompt = 4; uint32 max_output_tokens = 5; uint32 temperature_milli = 6;
// Remaining Original sampling controls (fixed point; an absent field keeps the Original's default).
// top_p/min_p/repetition_penalty are millionths, frequency/presence penalties signed millionths;
// top_k 0 or above 64 selects the widest list; seed absent or 0 draws a fresh seed per request.
optional uint32 top_p_micro = 7;
optional uint32 top_k = 8;
optional uint32 min_p_micro = 9;
optional uint32 repetition_penalty_micro = 10;
optional sint32 frequency_penalty_micro = 11;
optional sint32 presence_penalty_micro = 12;
optional uint32 penalty_last_n = 13;
optional uint64 seed = 14;
}
message CancelRequest { string request_id = 1; string expected_epoch = 2; }
message CancelAck { string request_id = 1; string epoch = 2; bool acknowledged = 3; }
message Accepted { bool accepted = 1; }
message TextDelta { string text = 1; }
message ToolCallDelta { uint32 index = 1; optional string id = 2; optional string name = 3; string arguments_delta = 4; }
message Usage { uint64 input_tokens = 1; uint64 output_tokens = 2; uint64 reused_input_tokens = 3; }
message Terminal {
enum State { UNSPECIFIED = 0; COMPLETED = 1; FAILED = 2; CANCELLED = 3; }
State state = 1; string reason = 2; Usage usage = 3;
string error_code = 4; bool retryable = 5;
}
message GenerationFrame {
string request_id = 1; string epoch = 2; uint64 sequence = 3;
oneof payload { Accepted accepted = 4; TextDelta text = 5; ToolCallDelta tool = 6; Usage usage = 7; Terminal terminal = 8; }
}