yuan-lab-llm--clawmanager
58c19856fd
* feat(runtime): improve Lite gateway scheduling and proxy stability - Expand the runtime gateway port range to match 100 instances per pod - Scale runtime deployments based on pending backlog - Serialize gateway creation per pod and handle starting/creating states - Clean up missing gateway bindings from runtime agent reports - Improve Lite gateway proxy token stripping and auth header injection - Update deployment manifests, docs, and related tests * fix(runtime): harden Hermes Lite gateway recovery - Add hashed gateway token aliases for short-term token compatibility - Fix /resume conversations failing when old sessions use mismatched gateway tokens - Recover ports only from stale error bindings without affecting active gateways * feat(runtime): enable bidirectional desktop clipboard and direct proxy - Enable WebTop/Selkies/Kasm clipboard by default with per-instance overrides - Document clipboard verification, configuration pitfalls, and IME troubleshooting - Enable direct desktop proxy in the K8s and K3s manifests --------- Co-authored-by: litiantian03 <litiantian03@ieisystem.com>
88 行
2.6 KiB
Go
88 行
2.6 KiB
Go
package services
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
RuntimeGatewayBindingCreating = "creating"
|
|
RuntimeGatewayBindingRunning = "running"
|
|
RuntimeGatewayBindingError = "error"
|
|
RuntimeGatewayBindingStopped = "stopped"
|
|
)
|
|
|
|
type RuntimeGatewayLifecycleState struct {
|
|
RawState string
|
|
BindingState string
|
|
InstanceState string
|
|
Running bool
|
|
Recognized bool
|
|
EventType string
|
|
Message *string
|
|
}
|
|
|
|
func NormalizeRuntimeGatewayLifecycle(rawState string, reportedMessage *string) RuntimeGatewayLifecycleState {
|
|
raw := strings.ToLower(strings.TrimSpace(rawState))
|
|
message := normalizedRuntimeGatewayMessage(reportedMessage)
|
|
state := RuntimeGatewayLifecycleState{RawState: raw, Recognized: true}
|
|
|
|
switch raw {
|
|
case "running", "ready", "healthy":
|
|
state.BindingState = RuntimeGatewayBindingRunning
|
|
state.InstanceState = "running"
|
|
state.Running = true
|
|
state.EventType = "runtime.instance.running"
|
|
case "starting", "creating", "pending":
|
|
state.BindingState = RuntimeGatewayBindingCreating
|
|
state.InstanceState = "creating"
|
|
state.EventType = "runtime.instance.starting"
|
|
state.Message = messageOrDefault(message, "runtime gateway starting")
|
|
case "error", "failed", "failure", "errored":
|
|
state.BindingState = RuntimeGatewayBindingError
|
|
state.InstanceState = "error"
|
|
state.EventType = "runtime.instance.error"
|
|
state.Message = messageOrDefault(message, "runtime gateway reported "+raw)
|
|
case "stopped", "deleted":
|
|
state.BindingState = RuntimeGatewayBindingStopped
|
|
state.InstanceState = "stopped"
|
|
state.EventType = "runtime.instance.stopped"
|
|
state.Message = message
|
|
case "":
|
|
state.Recognized = false
|
|
state.BindingState = RuntimeGatewayBindingCreating
|
|
state.InstanceState = "creating"
|
|
state.EventType = "runtime.instance.starting"
|
|
state.Message = messageOrDefault(message, "runtime gateway returned an empty state")
|
|
default:
|
|
state.Recognized = false
|
|
state.BindingState = RuntimeGatewayBindingCreating
|
|
state.InstanceState = "creating"
|
|
state.EventType = "runtime.instance.starting"
|
|
state.Message = messageOrDefault(message, "runtime gateway reported unrecognized state: "+raw)
|
|
}
|
|
return state
|
|
}
|
|
|
|
func (state RuntimeGatewayLifecycleState) CreateAccepted() bool {
|
|
if !state.Recognized {
|
|
return false
|
|
}
|
|
return state.BindingState == RuntimeGatewayBindingRunning || state.BindingState == RuntimeGatewayBindingCreating
|
|
}
|
|
|
|
func normalizedRuntimeGatewayMessage(message *string) *string {
|
|
if message == nil {
|
|
return nil
|
|
}
|
|
trimmed := strings.TrimSpace(*message)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|
|
|
|
func messageOrDefault(message *string, fallback string) *string {
|
|
if message != nil {
|
|
return message
|
|
}
|
|
return &fallback
|
|
}
|