Files
CLIProxyAPI/sdk/pluginabi/types.go
Luis Pater 693ce1c55a feat(pluginhost, scheduler): introduce Go-based plugin with scheduler capabilities
- Added a Go scheduler plugin demonstrating CLIProxyAPI capabilities, such as `plugin.register`, `plugin.reconfigure`, and `scheduler.pick`.
- Implemented methods for plugin configuration, built-in scheduler delegation (`fill-first`, `round-robin`), dynamic candidate selection, and error handling.
- Extended `pluginhost` with scheduler handling, candidate normalization, and fallback mechanisms.
- Included examples, tests, and detailed documentation for scheduler usage and implementation.
2026-06-09 13:57:36 +08:00

78 lines
2.5 KiB
Go

package pluginabi
import "encoding/json"
const (
ABIVersion uint32 = 1
SchemaVersion uint32 = 1
)
const (
MethodPluginRegister = "plugin.register"
MethodPluginReconfigure = "plugin.reconfigure"
MethodPluginShutdown = "plugin.shutdown"
MethodModelRegister = "model.register"
MethodModelStatic = "model.static"
MethodModelForAuth = "model.for_auth"
MethodAuthIdentifier = "auth.identifier"
MethodAuthParse = "auth.parse"
MethodAuthLoginStart = "auth.login.start"
MethodAuthLoginPoll = "auth.login.poll"
MethodAuthRefresh = "auth.refresh"
MethodFrontendAuthIdentifier = "frontend_auth.identifier"
MethodFrontendAuthAuthenticate = "frontend_auth.authenticate"
// MethodSchedulerPick asks a scheduler plugin to select an auth candidate.
MethodSchedulerPick = "scheduler.pick"
MethodExecutorIdentifier = "executor.identifier"
MethodExecutorExecute = "executor.execute"
MethodExecutorExecuteStream = "executor.execute_stream"
MethodExecutorCountTokens = "executor.count_tokens"
MethodExecutorHTTPRequest = "executor.http_request"
MethodRequestTranslate = "request.translate"
MethodRequestNormalize = "request.normalize"
MethodRequestInterceptBefore = "request.intercept_before"
MethodResponseTranslate = "response.translate"
MethodResponseNormalizeBefore = "response.normalize_before"
MethodResponseNormalizeAfter = "response.normalize_after"
MethodResponseInterceptAfter = "response.intercept_after"
MethodResponseInterceptStreamChunk = "response.intercept_stream_chunk"
MethodThinkingIdentifier = "thinking.identifier"
MethodThinkingApply = "thinking.apply"
MethodUsageHandle = "usage.handle"
MethodCommandLineRegister = "command_line.register"
MethodCommandLineExecute = "command_line.execute"
MethodManagementRegister = "management.register"
MethodManagementHandle = "management.handle"
MethodHostHTTPDo = "host.http.do"
MethodHostHTTPDoStream = "host.http.do_stream"
MethodHostHTTPStreamRead = "host.http.stream_read"
MethodHostHTTPStreamClose = "host.http.stream_close"
MethodHostStreamEmit = "host.stream.emit"
MethodHostStreamClose = "host.stream.close"
MethodHostLog = "host.log"
)
type Envelope struct {
OK bool `json:"ok"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Retryable bool `json:"retryable,omitempty"`
}