/** Record an acceptance interruption and skip clarification, never change OS rights. */ import {appendFile,readFile} from 'node:fs/promises'; import path from 'node:path'; import {connect} from './dsh_cdp.mjs'; export async function skipQuestion(c,output,id){ const selector=`[...document.querySelectorAll('button')].find(e=>e.innerText.trim()==='跳过'&&e.getBoundingClientRect().width>0)`; if(!await c.evaluate(`!!(${selector})`))return false; const text=await c.evaluate('document.body.innerText.slice(-4000)'); await appendFile(path.join(output,'interventions.jsonl'),JSON.stringify({id,at:new Date().toISOString(), action:'skip-model-question',reason:'Inputs and task are complete; acceptance does not authorize OS permission changes',text})+'\n'); await c.click(selector);return true; } if(process.argv[1]?.endsWith('dsh_skip_question.mjs')){ const c=await connect(Number(process.argv[2])); try{ const output=path.resolve(process.argv[3]); do{ let report; try{report=JSON.parse(await readFile(path.join(output,'report.json'),'utf8'));} catch(error){ if(process.argv[4]!=='--watch'||!(error instanceof SyntaxError))throw error; await new Promise(resolve=>setTimeout(resolve,100));continue; } if(report.status)break; const id=report.samples.at(-1)?.id??process.argv[4]; if(await skipQuestion(c,output,id))console.log(JSON.stringify({id,skipped:true})); if(process.argv[4]!=='--watch')break; await new Promise(resolve=>setTimeout(resolve,1000)); }while(true); }finally{c.close();} }