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

Function applyCursorAcpMode

cli/src/cursor/utils/cursorModeConfig.ts:42–64  ·  view source on GitHub ↗
(
    backend: AcpSdkBackend,
    sessionId: string,
    mode: CursorPermissionMode | undefined
)

Source from the content-addressed store, hash-verified

40}
41
42export async function applyCursorAcpMode(
43 backend: AcpSdkBackend,
44 sessionId: string,
45 mode: CursorPermissionMode | undefined
46): Promise<void> {
47 const configValue = resolveAcpModeConfigValue(mode, backend, sessionId);
48
49 const modeOption = backend.getConfigOptionByCategory?.(sessionId, 'mode');
50 if (modeOption && backend.setConfigOption) {
51 try {
52 await backend.setConfigOption(sessionId, modeOption.id, configValue);
53 return;
54 } catch (error) {
55 logger.debug('[cursor-acp] session/set_config_option for mode failed, trying set_mode', error);
56 }
57 }
58
59 try {
60 await backend.setMode(sessionId, configValue);
61 } catch (error) {
62 logger.warn(`[cursor-acp] Failed to set mode ${configValue}`, error);
63 }
64}
65
66export type ApplyCursorAcpModelResult = {
67 applied: boolean;

Callers 3

runMainLoopMethod · 0.90

Calls 6

debugMethod · 0.80
setModeMethod · 0.80
warnMethod · 0.80
setConfigOptionMethod · 0.65

Tested by

no test coverage detected