feat(plugins): add protocol versioning to plugin interface
Add protocol_version field to Initialize RPC for forward compatibility as the plugin protocol evolves. Changes: - Add protocol_version to InitializeRequest (server → plugin) - Add protocol_version to InitializeResponse (plugin → server) - Set current protocol version to 1 - Version 0 indicates pre-versioning implementations (treated as v1) This allows the server and plugins to negotiate capabilities: - Server can avoid calling RPCs that older plugins don't implement - Plugins can detect newer servers and enable advanced features - Graceful degradation when versions mismatch The AI service now reports protocol version 1 during initialization.
This commit is contained in:
@@ -28,12 +28,21 @@ service PluginService {
|
||||
message InitializeRequest {
|
||||
string server_version = 1;
|
||||
map<string, string> config = 2;
|
||||
// protocol_version is the plugin protocol version the server supports.
|
||||
// The current version is 1. Plugins should check this to know what RPCs
|
||||
// the server may call. A value of 0 means the server predates versioning.
|
||||
int32 protocol_version = 3;
|
||||
}
|
||||
|
||||
message InitializeResponse {
|
||||
bool success = 1;
|
||||
string error = 2;
|
||||
PluginManifest manifest = 3;
|
||||
// protocol_version is the plugin protocol version the plugin supports.
|
||||
// The current version is 1. The server uses this to avoid calling RPCs
|
||||
// that the plugin doesn't implement. A value of 0 means the plugin
|
||||
// predates versioning and is treated as protocol version 1.
|
||||
int32 protocol_version = 4;
|
||||
}
|
||||
|
||||
message ShutdownRequest {
|
||||
|
||||
@@ -13,6 +13,12 @@ namespace GitCaddy.AI.Service.Services;
|
||||
/// </summary>
|
||||
public class PluginServiceImpl : PluginService.PluginServiceBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The plugin protocol version this implementation supports.
|
||||
/// Increment when new RPCs are added to PluginService.
|
||||
/// </summary>
|
||||
private const int ProtocolVersion = 1;
|
||||
|
||||
private readonly ILogger<PluginServiceImpl> _logger;
|
||||
private readonly ILicenseValidator _licenseValidator;
|
||||
|
||||
@@ -27,12 +33,15 @@ public class PluginServiceImpl : PluginService.PluginServiceBase
|
||||
public override Task<InitializeResponse> Initialize(
|
||||
InitializeRequest request, ServerCallContext context)
|
||||
{
|
||||
_logger.LogInformation("Plugin initialized by server version {ServerVersion}", request.ServerVersion);
|
||||
_logger.LogInformation(
|
||||
"Plugin initialized by server version {ServerVersion} (protocol v{ProtocolVersion})",
|
||||
request.ServerVersion, request.ProtocolVersion);
|
||||
|
||||
return Task.FromResult(new InitializeResponse
|
||||
{
|
||||
Success = true,
|
||||
Manifest = BuildManifest()
|
||||
Manifest = BuildManifest(),
|
||||
ProtocolVersion = ProtocolVersion
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user