MCPcopy Create free account
hub / github.com/Noumena-Network/code / fetchBootstrapData

Function fetchBootstrapData

src/services/api/bootstrap.ts:122–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120 * Fetch bootstrap data from the API and persist to disk cache.
121 */
122export async function fetchBootstrapData(): Promise<void> {
123 try {
124 const response = await fetchBootstrapAPI()
125 if (!response) return
126
127 const clientData = response.client_data ?? null
128 const additionalModelOptions = response.additional_model_options ?? []
129
130 // Only persist if data actually changed — avoids a config write on every startup.
131 const config = getGlobalConfig()
132 if (
133 isEqual(config.clientDataCache, clientData) &&
134 isEqual(config.additionalModelOptionsCache, additionalModelOptions)
135 ) {
136 logForDebugging('[Bootstrap] Cache unchanged, skipping write')
137 return
138 }
139
140 logForDebugging('[Bootstrap] Cache updated, persisting to disk')
141 saveGlobalConfig(current => ({
142 ...current,
143 clientDataCache: clientData,
144 additionalModelOptionsCache: additionalModelOptions,
145 }))
146 } catch (error) {
147 logError(error)
148 }
149}

Callers 2

runStartupPrefetchesFunction · 0.85
bootstrap.test.tsFile · 0.85

Calls 5

fetchBootstrapAPIFunction · 0.85
getGlobalConfigFunction · 0.50
logForDebuggingFunction · 0.50
saveGlobalConfigFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected