()
| 57 | } |
| 58 | |
| 59 | public async initialize() { |
| 60 | for (const key of GLOBAL_STATE_KEYS) { |
| 61 | try { |
| 62 | // Revert to original assignment |
| 63 | this.stateCache[key] = this.originalContext.globalState.get(key) |
| 64 | } catch (error) { |
| 65 | logger.error(`Error loading global ${key}: ${error instanceof Error ? error.message : String(error)}`) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | const promises = [ |
| 70 | ...SECRET_STATE_KEYS.map(async (key) => { |
| 71 | try { |
| 72 | this.secretCache[key] = await this.originalContext.secrets.get(key) |
| 73 | } catch (error) { |
| 74 | logger.error( |
| 75 | `Error loading secret ${key}: ${error instanceof Error ? error.message : String(error)}`, |
| 76 | ) |
| 77 | } |
| 78 | }), |
| 79 | ...GLOBAL_SECRET_KEYS.map(async (key) => { |
| 80 | try { |
| 81 | this.secretCache[key] = await this.originalContext.secrets.get(key) |
| 82 | } catch (error) { |
| 83 | logger.error( |
| 84 | `Error loading global secret ${key}: ${error instanceof Error ? error.message : String(error)}`, |
| 85 | ) |
| 86 | } |
| 87 | }), |
| 88 | ] |
| 89 | |
| 90 | await Promise.all(promises) |
| 91 | |
| 92 | // Migration: Check for old nested image generation settings and migrate them |
| 93 | await this.migrateImageGenerationSettings() |
| 94 | |
| 95 | // Migration: Downgrade legacy Roo Code Router state before generic sanitization. |
| 96 | await this.migrateLegacyRooApiProvider() |
| 97 | |
| 98 | // Migration: Sanitize invalid/removed API providers |
| 99 | await this.migrateInvalidApiProvider() |
| 100 | |
| 101 | // Migration: Move legacy customCondensingPrompt to customSupportPrompts |
| 102 | await this.migrateLegacyCondensingPrompt() |
| 103 | |
| 104 | // Migration: Clear old default condensing prompt so users get the improved v2 default |
| 105 | await this.migrateOldDefaultCondensingPrompt() |
| 106 | |
| 107 | this._isInitialized = true |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Migrates the legacy customCondensingPrompt to the new customSupportPrompts structure |
no test coverage detected