refactor(assistant): improve sandbox version extraction logic

- Enhanced the extractSandboxVersion function to support multiple input types, including *sandboxTypes.SandboxConfig and map[string]any, for better flexibility in version retrieval.
- Simplified the version extraction process, ensuring consistent handling of sandbox configurations.
This commit is contained in:
Max 2026-03-24 20:45:05 +08:00
parent d43b637ad4
commit 96194110d1

View file

@ -1101,8 +1101,15 @@ func mergeSearchConfig(base, override *searchTypes.Config) *searchTypes.Config {
// extractSandboxVersion tries to read the "version" field from a sandbox config value.
func extractSandboxVersion(v any) string {
if m, ok := v.(map[string]any); ok {
if ver, ok := m["version"].(string); ok {
switch sb := v.(type) {
case *sandboxTypes.SandboxConfig:
if sb != nil {
return sb.Version
}
case sandboxTypes.SandboxConfig:
return sb.Version
case map[string]any:
if ver, ok := sb["version"].(string); ok {
return ver
}
}