(
backend: AcpSdkBackend,
sessionId: string,
mode: CursorPermissionMode | undefined
)
| 40 | } |
| 41 | |
| 42 | export 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 | |
| 66 | export type ApplyCursorAcpModelResult = { |
| 67 | applied: boolean; |
no test coverage detected