feat: 完整游戏运维功能

This commit is contained in:
npc0-hue
2026-07-18 09:04:01 +08:00
parent f3b14b7945
commit 48b8ad8d6c
187 changed files with 16607 additions and 1140 deletions
+390 -36
View File
@@ -81,6 +81,7 @@ const (
JobStateQueued JobState = "queued"
JobStateAccepted JobState = "accepted"
JobStateRunning JobState = "running"
JobStateRetrying JobState = "retrying"
JobStateSucceeded JobState = "succeeded"
JobStateFailed JobState = "failed"
JobStateCancelled JobState = "cancelled"
@@ -154,6 +155,19 @@ const (
DistributionJobStatusDenied DistributionJobStatus = "denied"
)
type RunUpdatePhase string
const (
RunUpdatePhaseQueued RunUpdatePhase = "queued"
RunUpdatePhaseDownloading RunUpdatePhase = "downloading"
RunUpdatePhaseStaged RunUpdatePhase = "staged"
RunUpdatePhaseRestartRequested RunUpdatePhase = "restart-requested"
RunUpdatePhaseActivating RunUpdatePhase = "activating"
RunUpdatePhaseSucceeded RunUpdatePhase = "succeeded"
RunUpdatePhaseRolledBack RunUpdatePhase = "rolled-back"
RunUpdatePhaseFailed RunUpdatePhase = "failed"
)
type LogStreamSource string
const (
@@ -227,6 +241,26 @@ type AuthSession struct {
User User
Status string
Message string
ExpiresAt time.Time
}
type AuthSessionStatus string
const (
AuthSessionStatusActive AuthSessionStatus = "active"
AuthSessionStatusRevoked AuthSessionStatus = "revoked"
)
type AuthSessionRecord struct {
ID string
UserID string
TokenHash string
Status AuthSessionStatus
Generation int
IssuedAt time.Time
ExpiresAt time.Time
LastSeenAt time.Time
RevokedAt time.Time
}
type AIProvider struct {
@@ -305,21 +339,126 @@ type GamePluginRemoteAccess struct {
LogTransfer bool
}
type GamePluginManifest struct {
ID string
Name string
Description string
Version string
type RuntimeTarget struct {
OS string
Arch string
}
type RuntimeDiscoveryProbe struct {
Key string
Kind string
TargetKey string
Required bool
Expected string
Platforms []string
}
type RuntimeLifecycleProfile struct {
Key string
Mode string
Capabilities []string
ActionRefs PluginLifecycleActions
TransportKeys []string
ClientManagerRef string
Platforms []string
}
type RuntimeDependencyProbe struct {
Key string
Kind string
TargetKey string
Required bool
MinimumVersion string
Platforms []string
}
type RuntimeInstallStep struct {
Type string
TargetKey string
PackageManager string
PackageName string
Version string
DownloadRef string
Checksum string
}
type RuntimeInstallPlan struct {
Key string
Title string
Platforms []string
Steps []RuntimeInstallStep
}
type RuntimeLogSource struct {
Key string
Kind string
TargetKey string
StreamKey string
CursorKind string
RetentionDays int
}
type RuntimeTransportProfile struct {
Key string
Kind string
Tags []string
Server GamePluginManifestServer
Bridge GamePluginBridge
TargetKey string
Capabilities []string
Permissions []string
Actions PluginLifecycleActions
Pages []GamePluginPage
AI GamePluginManifestAI
RemoteAccess GamePluginRemoteAccess
}
type RuntimeClientManagerProfile struct {
Key string
DisplayName string
Version string
RepositoryURL string
RevisionPolicy string
Branch string
Tag string
Revision string
SupportedTargets []RuntimeTarget
BuildSystem string
WorkspaceRef string
EntryRef string
ConfigTemplates []RuntimeConfigTemplate
OutputArtifacts []string
Deployment RuntimeClientManagerDeployment
Lifecycle RuntimeClientManagerLifecycle
Health RuntimeClientManagerHealth
Compatibility RuntimeClientManagerCompatibility
UpdatePolicy RuntimeClientManagerUpdatePolicy
}
type RuntimeConfigTemplate struct {
Key string
TemplateRef string
OutputRef string
}
type GamePluginRuntimeProfiles struct {
Discovery []RuntimeDiscoveryProbe
LifecycleProfiles []RuntimeLifecycleProfile
DependencyProbes []RuntimeDependencyProbe
InstallPlans []RuntimeInstallPlan
LogSources []RuntimeLogSource
TransportProfiles []RuntimeTransportProfile
ClientManagers []RuntimeClientManagerProfile
}
type GamePluginManifest struct {
ID string
Name string
Description string
Version string
Kind string
Tags []string
Server GamePluginManifestServer
Bridge GamePluginBridge
Capabilities []string
Permissions []string
Actions PluginLifecycleActions
Pages []GamePluginPage
AI GamePluginManifestAI
RemoteAccess GamePluginRemoteAccess
RuntimeProfiles GamePluginRuntimeProfiles
}
type GamePluginManifestRegistration struct {
@@ -346,6 +485,7 @@ type GamePlugin struct {
Tags []string
AIPurposes []string
RemoteAccess GamePluginRemoteAccess
RuntimeProfiles GamePluginRuntimeProfiles
ValidationViolations []string
Status GamePluginStatus
}
@@ -369,6 +509,7 @@ type PluginMarketplacePlugin struct {
Tags []string
AIPurposes []string
RemoteAccess GamePluginRemoteAccess
RuntimeProfiles GamePluginRuntimeProfiles
ValidationViolations []string
Status GamePluginStatus
Source string
@@ -437,17 +578,21 @@ type PluginBridgeExecuteResponse struct {
}
type ServerInstance struct {
ID string
PluginID string
PluginVersion string
RunEndpointID string
Name string
OwnerUserID string
AdminUserIDs []string
State ServerInstanceState
ConfigVersion int
CreatedAt time.Time
UpdatedAt time.Time
ID string
PluginID string
PluginVersion string
RunEndpointID string
Name string
OwnerUserID string
AdminUserIDs []string
State ServerInstanceState
ConfigVersion int
ConfigKey string
ConfigContent string
ConfigChecksum string
ConfigUpdatedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
type ServerInstanceUpdate struct {
@@ -482,6 +627,7 @@ type ServerConfig struct {
Format string
Key string
Content string
Checksum string
Source string
UpdatedAt time.Time
}
@@ -496,6 +642,7 @@ type ConfigDiffLine struct {
type ServerConfigDiffRequest struct {
ServerInstanceID string
ExpectedConfigVersion int
ExpectedChecksum string
Key string
ProposedContent string
ProposedContentInputRef string
@@ -504,6 +651,7 @@ type ServerConfigDiffRequest struct {
type ServerConfigDiffPreview struct {
ServerInstanceID string
ConfigVersion int
Checksum string
Key string
CurrentContent string
ProposedContent string
@@ -517,6 +665,7 @@ type ServerConfigDiffPreview struct {
type ServerConfigWriteApproval struct {
ServerInstanceID string
ExpectedConfigVersion int
ExpectedChecksum string
Key string
ProposedContent string
ProposedContentInputRef string
@@ -542,7 +691,9 @@ type FileOperationDispatchRequest struct {
Operation FileOperationKind
Key string
InputRef string
Content string
ExpectedConfigVersion int
ExpectedChecksum string
IdempotencyKey string
}
@@ -590,6 +741,8 @@ type RunEndpoint struct {
ID string
DisplayName string
Version string
Platform string
Architecture string
Status RunEndpointStatus
Capabilities []string
Capacity RunCapacity
@@ -601,19 +754,67 @@ type JobProgress struct {
Message string
}
type JobRetryPolicy struct {
MaxAttempts int
InitialBackoffSeconds int
MaxBackoffSeconds int
}
type JobExecutionInput struct {
WorkspaceScope string
Content string
ExpectedVersion int
ExpectedChecksum string
MaxReadBytes int
RemoteAdapterKey string
RemoteAdapterKind string
TimeoutSeconds int
}
type JobExecutionResult struct {
Kind string
ProcessState string
ExitClassification string
ExitCode int
Version int
Checksum string
SizeBytes int64
AuditSummary string
Content string
}
type Job struct {
ID string
ServerInstanceID string
RunEndpointID string
Capability string
TargetKey string
InputRef string
IdempotencyKey string
State JobState
Progress JobProgress
ResultRef string
CreatedAt time.Time
UpdatedAt time.Time
ID string
ServerInstanceID string
RunEndpointID string
Capability string
TargetKey string
InputRef string
IdempotencyKey string
State JobState
Progress JobProgress
ResultRef string
ExecutionInput JobExecutionInput
ExecutionResult JobExecutionResult
RetryPolicy JobRetryPolicy
Attempt int
QueueEligibleAt time.Time
NextAttemptAt time.Time
LeaseTokenHash string
LeaseSessionGen int
AckDeadlineAt time.Time
LeaseExpiresAt time.Time
LastProgressSeq uint64
CancelReason string
CancelRequestedAt time.Time
CancelCompletedAt time.Time
TerminalAt time.Time
TerminalFingerprint string
LastReconciledAt time.Time
ReconcileCount int
ReconcileOutcome string
CreatedAt time.Time
UpdatedAt time.Time
}
type Artifact struct {
@@ -631,6 +832,7 @@ type RuntimeBinding struct {
ID string
ServerInstanceID string
PluginID string
PluginVersion string
ProfileKey string
Mode string
Bindings map[string]string
@@ -640,6 +842,32 @@ type RuntimeBinding struct {
UpdatedAt time.Time
}
type RuntimeBindingUpdate struct {
ProfileKey string
Bindings map[string]string
}
type RuntimeBindingKeyView struct {
Key string
Required bool
Configured bool
Secret bool
}
type RuntimeBindingView struct {
ServerInstanceID string
PluginID string
ProfileKey string
Mode string
Configured bool
Keys []RuntimeBindingKeyView
MissingKeys []string
Status RuntimeBindingStatus
Reason string
CreatedAt time.Time
UpdatedAt time.Time
}
type EncryptedComponentKey struct {
ID string
ServerInstanceID string
@@ -679,6 +907,7 @@ type ClientManagerDistribution struct {
ServerInstanceID string
PluginID string
ProfileKey string
Version string
TargetOS string
TargetArch string
RepositoryURL string
@@ -703,6 +932,10 @@ type DependencyStatus struct {
State DependencyState
Required bool
InstallPlanKey string
PlanDigest string
JobID string
Evidence string
CompletedSteps int
Message string
CheckedAt time.Time
UpdatedAt time.Time
@@ -713,6 +946,7 @@ type ClientManagerBuildJob struct {
ServerInstanceID string
PluginID string
ProfileKey string
Version string
TargetOS string
TargetArch string
RepositoryURL string
@@ -732,9 +966,16 @@ type RunUpdateJob struct {
RunEndpointID string
ArtifactID string
Checksum string
TargetOS string
TargetArch string
TargetRelease string
PreviousVersion string
JobID string
IdempotencyKey string
Status DistributionJobStatus
Phase RunUpdatePhase
Message string
Rollback bool
CreatedAt time.Time
UpdatedAt time.Time
}
@@ -805,12 +1046,54 @@ type DependencyJobRequest struct {
ServerInstanceID string
ProbeKey string
InstallPlanKey string
PlanDigest string
TargetOS string
TargetArch string
IdempotencyKey string
Install bool
}
type DependencyProbeView struct {
Key string
Kind string
Required bool
MinimumVersion string
State DependencyState
Evidence string
InstallPlanKey string
}
type DependencyPlanStepView struct {
Type string
TargetKey string
PackageManager string
PackageName string
Version string
DownloadHost string
SizeBytes int64
}
type DependencyPlanView struct {
Key string
Title string
TargetOS string
TargetArch string
Digest string
Steps []DependencyPlanStepView
}
type DependencyCatalog struct {
ServerInstanceID string
PluginID string
PluginVersion string
ProfileKey string
TargetOS string
TargetArch string
Probes []DependencyProbeView
Plans []DependencyPlanView
UpdatedAt time.Time
}
type LogBackfillRequest struct {
ServerInstanceID string
SourceKey string
@@ -846,6 +1129,12 @@ type UserFilter struct {
Status UserStatus
}
type AuthSessionFilter struct {
UserID string
TokenHash string
Status AuthSessionStatus
}
type AIProviderFilter struct {
Kind AIProviderKind
Status AIProviderStatus
@@ -968,6 +1257,10 @@ func CopyUser(user User) User {
return user
}
func CopyAuthSessionRecord(session AuthSessionRecord) AuthSessionRecord {
return session
}
func CopyAIProvider(provider AIProvider) AIProvider {
provider.Models = CopyStringSlice(provider.Models)
return provider
@@ -992,6 +1285,7 @@ func CopyGamePlugin(plugin GamePlugin) GamePlugin {
plugin.Tags = CopyStringSlice(plugin.Tags)
plugin.AIPurposes = CopyStringSlice(plugin.AIPurposes)
plugin.RemoteAccess = CopyGamePluginRemoteAccess(plugin.RemoteAccess)
plugin.RuntimeProfiles = CopyGamePluginRuntimeProfiles(plugin.RuntimeProfiles)
plugin.ValidationViolations = CopyStringSlice(plugin.ValidationViolations)
return plugin
}
@@ -1005,6 +1299,7 @@ func CopyPluginMarketplacePlugin(plugin PluginMarketplacePlugin) PluginMarketpla
plugin.Tags = CopyStringSlice(plugin.Tags)
plugin.AIPurposes = CopyStringSlice(plugin.AIPurposes)
plugin.RemoteAccess = CopyGamePluginRemoteAccess(plugin.RemoteAccess)
plugin.RuntimeProfiles = CopyGamePluginRuntimeProfiles(plugin.RuntimeProfiles)
plugin.ValidationViolations = CopyStringSlice(plugin.ValidationViolations)
return plugin
}
@@ -1034,9 +1329,48 @@ func CopyGamePluginManifest(manifest GamePluginManifest) GamePluginManifest {
manifest.Pages = CopyGamePluginPageSlice(manifest.Pages)
manifest.AI.Purposes = CopyStringSlice(manifest.AI.Purposes)
manifest.RemoteAccess = CopyGamePluginRemoteAccess(manifest.RemoteAccess)
manifest.RuntimeProfiles = CopyGamePluginRuntimeProfiles(manifest.RuntimeProfiles)
return manifest
}
func CopyGamePluginRuntimeProfiles(profiles GamePluginRuntimeProfiles) GamePluginRuntimeProfiles {
profiles.Discovery = append([]RuntimeDiscoveryProbe(nil), profiles.Discovery...)
for i := range profiles.Discovery {
profiles.Discovery[i].Platforms = CopyStringSlice(profiles.Discovery[i].Platforms)
}
profiles.LifecycleProfiles = append([]RuntimeLifecycleProfile(nil), profiles.LifecycleProfiles...)
for i := range profiles.LifecycleProfiles {
profiles.LifecycleProfiles[i].Capabilities = CopyStringSlice(profiles.LifecycleProfiles[i].Capabilities)
profiles.LifecycleProfiles[i].TransportKeys = CopyStringSlice(profiles.LifecycleProfiles[i].TransportKeys)
profiles.LifecycleProfiles[i].Platforms = CopyStringSlice(profiles.LifecycleProfiles[i].Platforms)
}
profiles.DependencyProbes = append([]RuntimeDependencyProbe(nil), profiles.DependencyProbes...)
for i := range profiles.DependencyProbes {
profiles.DependencyProbes[i].Platforms = CopyStringSlice(profiles.DependencyProbes[i].Platforms)
}
profiles.InstallPlans = append([]RuntimeInstallPlan(nil), profiles.InstallPlans...)
for i := range profiles.InstallPlans {
profiles.InstallPlans[i].Platforms = CopyStringSlice(profiles.InstallPlans[i].Platforms)
profiles.InstallPlans[i].Steps = append([]RuntimeInstallStep(nil), profiles.InstallPlans[i].Steps...)
}
profiles.LogSources = append([]RuntimeLogSource(nil), profiles.LogSources...)
profiles.TransportProfiles = append([]RuntimeTransportProfile(nil), profiles.TransportProfiles...)
for i := range profiles.TransportProfiles {
profiles.TransportProfiles[i].Capabilities = CopyStringSlice(profiles.TransportProfiles[i].Capabilities)
}
profiles.ClientManagers = append([]RuntimeClientManagerProfile(nil), profiles.ClientManagers...)
for i := range profiles.ClientManagers {
profiles.ClientManagers[i].SupportedTargets = append([]RuntimeTarget(nil), profiles.ClientManagers[i].SupportedTargets...)
profiles.ClientManagers[i].ConfigTemplates = append([]RuntimeConfigTemplate(nil), profiles.ClientManagers[i].ConfigTemplates...)
profiles.ClientManagers[i].OutputArtifacts = CopyStringSlice(profiles.ClientManagers[i].OutputArtifacts)
profiles.ClientManagers[i].Deployment.Arguments = CopyStringSlice(profiles.ClientManagers[i].Deployment.Arguments)
profiles.ClientManagers[i].Deployment.RequiredRunCapabilities = CopyStringSlice(profiles.ClientManagers[i].Deployment.RequiredRunCapabilities)
profiles.ClientManagers[i].Lifecycle.Actions = CopyStringSlice(profiles.ClientManagers[i].Lifecycle.Actions)
profiles.ClientManagers[i].Health.RequiredCapabilities = CopyStringSlice(profiles.ClientManagers[i].Health.RequiredCapabilities)
}
return profiles
}
func CopyGamePluginRemoteAccess(remote GamePluginRemoteAccess) GamePluginRemoteAccess {
remote.Methods = CopyStringSlice(remote.Methods)
remote.RunCapabilities = CopyStringSlice(remote.RunCapabilities)
@@ -1148,6 +1482,17 @@ func CopyRuntimeBinding(binding RuntimeBinding) RuntimeBinding {
return binding
}
func CopyRuntimeBindingUpdate(update RuntimeBindingUpdate) RuntimeBindingUpdate {
update.Bindings = CopyStringMap(update.Bindings)
return update
}
func CopyRuntimeBindingView(view RuntimeBindingView) RuntimeBindingView {
view.Keys = append([]RuntimeBindingKeyView(nil), view.Keys...)
view.MissingKeys = CopyStringSlice(view.MissingKeys)
return view
}
func CopyEncryptedComponentKey(key EncryptedComponentKey) EncryptedComponentKey {
return key
}
@@ -1164,6 +1509,15 @@ func CopyDependencyStatus(status DependencyStatus) DependencyStatus {
return status
}
func CopyDependencyCatalog(catalog DependencyCatalog) DependencyCatalog {
catalog.Probes = append([]DependencyProbeView(nil), catalog.Probes...)
catalog.Plans = append([]DependencyPlanView(nil), catalog.Plans...)
for i := range catalog.Plans {
catalog.Plans[i].Steps = append([]DependencyPlanStepView(nil), catalog.Plans[i].Steps...)
}
return catalog
}
func CopyClientManagerBuildJob(job ClientManagerBuildJob) ClientManagerBuildJob {
return job
}