返回 CodeWhale
darwin-targeting-backend.mjs
根目录 / crates / tui / plugins / computer-use / tests / fixtures / darwin-targeting-backend.mjs
1 // The real backend receives app-handler arguments. Only its native executable
2 // is substituted; no installed helper, app, or desktop is involved.
3 import assert from 'node:assert/strict';
4 import fs from 'node:fs';
5 import path from 'node:path';
6 import { run } from '../../src/exec.mjs';
7 import { create as createDarwin } from '../../src/backends/darwin.mjs';
8
9 export function create() {
10 return createDarwin({exec:{async run(cmd,args,opts) {
11 assert.equal(cmd,path.join(process.env.CODEWHALE_CU_APP_BUNDLE,'Contents','MacOS','accessibility'));
12 const request=JSON.parse(args[0]);
13 assert.ok(['list_windows','get_app_state','resolve_element','window_info'].includes(request.tool));
14 fs.appendFileSync(process.env.CU_TARGETING_CALLS,JSON.stringify(request)+'\n');
15 if(process.env.CU_TARGETING_NATIVE==='1') return run(cmd,args,opts);
16 return {code:0,stderr:'',stdout:JSON.stringify({found:true,pid:123,name:'Fixture',bundle_id:'test.fixture',windows:[],elements:[]})};
17 }}});
18 }
19
19 lines Plain Text