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

Function runCursorAcpModelProbe

cli/src/modules/common/cursorAcpModelProbe.ts:19–51  ·  view source on GitHub ↗
(cwd?: string)

Source from the content-addressed store, hash-verified

17 * Zed-style wire catalog. Used for New Session when no on-disk ACP cache exists.
18 */
19export async function runCursorAcpModelProbe(cwd?: string): Promise<ListCursorModelsResponse> {
20 const resolvedCwd = cwd?.trim() || process.cwd();
21 const backend = createCursorAcpBackend({ cwd: resolvedCwd });
22
23 try {
24 await backend.initialize();
25 const sessionId = await backend.newSession({
26 cwd: resolvedCwd,
27 mcpServers: []
28 });
29 const snapshot = buildCursorModelsSnapshotFromAcp(backend, sessionId);
30 if (!snapshot || snapshot.availableModels.length === 0) {
31 return { success: false, error: 'Cursor ACP session/new returned no models' };
32 }
33
34 const response: ListCursorModelsResponse = {
35 success: true,
36 availableModels: snapshot.availableModels,
37 currentModelId: snapshot.currentModelId
38 };
39 if (!hasAcpWireCatalog(response)) {
40 return { success: false, error: 'Cursor ACP catalog has no wire model ids' };
41 }
42 return response;
43 } catch (error) {
44 return {
45 success: false,
46 error: getErrorMessage(error, 'Failed to discover Cursor models via ACP')
47 };
48 } finally {
49 await backend.disconnect().catch(() => undefined);
50 }
51}
52
53export function cursorProbeResponseHasWireCatalog(response: ListCursorModelsResponse): boolean {
54 return response.success === true && hasAcpWireCatalog(response);

Callers 2

listCursorModelsFunction · 0.90

Calls 7

createCursorAcpBackendFunction · 0.90
getErrorMessageFunction · 0.90
hasAcpWireCatalogFunction · 0.85
initializeMethod · 0.65
newSessionMethod · 0.65
disconnectMethod · 0.65

Tested by

no test coverage detected