Add Docker Compose Lingma bootstrap support
Package the proxy for Docker Compose deployments and add Lingma bootstrap, session restore, and runtime status support for containerized remote usage. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,15 @@ type Credential struct {
|
||||
TokenExpireTime int64
|
||||
}
|
||||
|
||||
type CredentialStatus struct {
|
||||
Loaded bool `json:"loaded"`
|
||||
Source string `json:"source,omitempty"`
|
||||
UserIDMasked string `json:"user_id_masked,omitempty"`
|
||||
MachineMasked string `json:"machine_id_masked,omitempty"`
|
||||
ExpireAt string `json:"expire_at,omitempty"`
|
||||
Expired bool `json:"expired"`
|
||||
}
|
||||
|
||||
type storedCredentialFile struct {
|
||||
Source string `json:"source"`
|
||||
TokenExpireTime string `json:"token_expire_time"`
|
||||
@@ -44,6 +53,24 @@ func LoadCredential(authFile string) (Credential, error) {
|
||||
return importLingmaCacheCredential()
|
||||
}
|
||||
|
||||
func LoadCredentialStatus(authFile string) (CredentialStatus, error) {
|
||||
cred, err := LoadCredential(authFile)
|
||||
if err != nil {
|
||||
return CredentialStatus{}, err
|
||||
}
|
||||
status := CredentialStatus{
|
||||
Loaded: true,
|
||||
Source: cred.Source,
|
||||
UserIDMasked: maskTail(cred.UserID),
|
||||
MachineMasked: maskTail(cred.MachineID),
|
||||
Expired: IsExpired(cred, 0),
|
||||
}
|
||||
if cred.TokenExpireTime > 0 {
|
||||
status.ExpireAt = time.UnixMilli(cred.TokenExpireTime).UTC().Format(time.RFC3339)
|
||||
}
|
||||
return status, nil
|
||||
}
|
||||
|
||||
func loadCredentialFile(path string) (Credential, error) {
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
@@ -359,6 +386,17 @@ func MachineOSHeader() string {
|
||||
}
|
||||
}
|
||||
|
||||
func maskTail(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
if value == "" {
|
||||
return ""
|
||||
}
|
||||
if len(value) <= 6 {
|
||||
return strings.Repeat("*", len(value))
|
||||
}
|
||||
return value[:3] + strings.Repeat("*", len(value)-6) + value[len(value)-3:]
|
||||
}
|
||||
|
||||
func uniquePathStrings(values []string) []string {
|
||||
seen := make(map[string]struct{}, len(values))
|
||||
out := make([]string, 0, len(values))
|
||||
|
||||
Reference in New Issue
Block a user