MCPcopy Create free account
hub / github.com/tiann/hapi / listCursorModelsWhileAcpActive

Function listCursorModelsWhileAcpActive

cli/src/modules/common/cursorModels.ts:240–259  ·  view source on GitHub ↗

ACP session snapshot (Zed-style); falls back to seeded / on-disk cache from the last live session.

()

Source from the content-addressed store, hash-verified

238
239/** ACP session snapshot (Zed-style); falls back to seeded / on-disk cache from the last live session. */
240async function listCursorModelsWhileAcpActive(): Promise<ListCursorModelsResponse> {
241 const acp = getCursorAcpModelsSnapshot();
242 if (acp && acp.availableModels.length > 0) {
243 return applyInMemoryCache({ success: true, ...acp });
244 }
245 // Session child writes the on-disk cache; prefer it over this process's in-memory entry.
246 const shared = readSharedCursorModelsCache();
247 if (shared) {
248 return applyInMemoryCache(shared);
249 }
250 if (cache.expiresAt > Date.now() && (cache.response.availableModels?.length ?? 0) > 0) {
251 const shared = readSharedCursorModelsCache();
252 const cachedSkus = mergeCliModelSkus(
253 cache.response.cliModelSkus ?? [],
254 shared?.cliModelSkus ?? []
255 );
256 return attachCliSkusToResponse(cache.response, cachedSkus);
257 }
258 return { success: true, availableModels: [], currentModelId: null };
259}
260
261export async function listCursorModels(): Promise<ListCursorModelsResponse> {
262 if (isAgentAcpTransportActive()) {

Callers 1

listCursorModelsFunction · 0.85

Calls 5

applyInMemoryCacheFunction · 0.85
mergeCliModelSkusFunction · 0.85
attachCliSkusToResponseFunction · 0.85

Tested by

no test coverage detected