(deps?: MakaCuSelection)
| 84 | export type ComputerUseBackendSelection = MakaCuSelection; |
| 85 | |
| 86 | export function selectComputerUseBackend(deps?: MakaCuSelection): SelectedComputerUseBackend { |
| 87 | if (process.platform !== 'darwin') return NONE; |
| 88 | if (!deps?.binaryPath || !deps.expectedBinarySha256) return NONE; |
| 89 | const binaryPath = deps.binaryPath; |
| 90 | const expectedBinarySha256 = deps.expectedBinarySha256; |
| 91 | try { |
| 92 | let tools: ComputerUseToolSet | undefined; |
| 93 | const backend = (deps.createBackend ?? createMakaCuBackend)({ |
| 94 | binaryPath, |
| 95 | expectedBinarySha256, |
| 96 | ...(deps.compressFrame ? { compressFrame: deps.compressFrame } : {}), |
| 97 | ...(deps.physicalInputRecentlyActive |
| 98 | ? { physicalInputRecentlyActive: deps.physicalInputRecentlyActive } |
| 99 | : {}), |
| 100 | ...(deps.onTrace ? { onTrace: deps.onTrace } : {}), |
| 101 | ...(deps.allowCompatibilityInputDispatch === undefined |
| 102 | ? {} |
| 103 | : { allowCompatibilityInputDispatch: deps.allowCompatibilityInputDispatch }), |
| 104 | onSessionInvalidated: ({ sessionId }) => { |
| 105 | tools?.sessionEvents.reobserveRequired(sessionId); |
| 106 | }, |
| 107 | }); |
| 108 | tools = buildComputerUseTools({ |
| 109 | backend, |
| 110 | ...(deps.overlay ? { overlay: deps.overlay } : {}), |
| 111 | ...(deps.screenLocked ? { screenLocked: deps.screenLocked } : {}), |
| 112 | }); |
| 113 | return { backend, tools, backendId: DEFAULT_CU_BACKEND_ID }; |
| 114 | } catch { |
| 115 | return NONE; |
| 116 | } |
| 117 | } |
no test coverage detected