File size: 1,858 Bytes
90d354b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import fs from 'node:fs'
import path from 'node:path'
import {compilePlan,SYSTEM_PROMPT,PLANNER_VERSION} from '../server/planner.mjs'
const root=process.cwd(),out=path.resolve(root,'../output/kimi-jev-evaluation-20261013')
const cases=JSON.parse(fs.readFileSync(path.join(out,'cases.json'),'utf8'))
fs.mkdirSync(path.join(out,'plans'),{recursive:true})
fs.writeFileSync(path.join(out,'planner-prompt-frozen.txt'),SYSTEM_PROMPT)
const manifest=JSON.parse(fs.readFileSync(path.join(out,'media-manifest.json'),'utf8'))
const seen=new Map()
for(const c of cases){
const file=path.join(out,'plans',c.id+'.json')
if(fs.existsSync(file)){const saved=JSON.parse(fs.readFileSync(file,'utf8'));if(saved.plan){seen.set(c.request,{id:c.id,result:saved});console.log(c.id+' cached '+saved.plan.status);continue}}
if(seen.has(c.request)){const reused=seen.get(c.request);fs.writeFileSync(file,JSON.stringify({...reused.result,reusedFrom:reused.id},null,2));console.log(c.id+' shared contract '+reused.id);continue}
const clip=manifest.find(m=>m.clip_id===c.clip_id)
try{
const result=await compilePlan({request:c.request,context:{selected_camera:clip?.scene||'用户选定的家庭摄像头',external_signals:['away','rain','doorbell'],external_signal_mode:'replay_injection_only',identity_recognition:false},root})
fs.writeFileSync(file,JSON.stringify({...result,request:c.request,caseId:c.id,createdAt:new Date().toISOString()},null,2))
seen.set(c.request,{id:c.id,result})
console.log(c.id+' '+result.plan.status+' '+result.latencyMs+'ms '+result.plan.rules.map(r=>r.mode).join(','),flush())
}catch(e){fs.writeFileSync(file,JSON.stringify({caseId:c.id,error:e.message,version:PLANNER_VERSION},null,2));console.log(c.id+' ERROR '+e.message)}
await new Promise(resolve=>setTimeout(resolve,1200))
}
function flush(){return ''}
console.log('PLANS COMPLETE')
|